Skip to content
Open
Show file tree
Hide file tree
Changes from 39 commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
20753c6
Course Article Page
PolinaShneider Apr 5, 2018
578bf7e
Update course articles
PolinaShneider Apr 7, 2018
46661bc
Merge branch 'master' into course-design
PolinaShneider Apr 12, 2018
92c35fe
Update course article
PolinaShneider Apr 12, 2018
0e5dede
Make course title both toggleable and clickable
PolinaShneider Apr 12, 2018
fd57fef
Merge branch 'master' of https://github.com/codex-team/codex into cou…
PolinaShneider Apr 18, 2018
4d58954
Add submodule
PolinaShneider Apr 18, 2018
f783cce
update migrations
talyguryn Apr 19, 2018
2451ed5
Merge branch 'articles-redesign' into course-design
talyguryn Apr 19, 2018
f60140b
Add courses progress state
PolinaShneider Apr 26, 2018
d9af702
Minor design update
PolinaShneider May 23, 2018
87a0e3c
Update
PolinaShneider May 25, 2018
2211d65
Update styles
PolinaShneider May 25, 2018
708cb68
Fix margins
PolinaShneider May 26, 2018
9958547
Return back
PolinaShneider May 26, 2018
2663249
Update cover styles
PolinaShneider May 27, 2018
c449a33
Quick fix
PolinaShneider May 27, 2018
401bd89
Get rid of height hardcode
PolinaShneider May 27, 2018
d232315
Rearrange styles
PolinaShneider May 27, 2018
1bf58ab
Quick font fix
PolinaShneider May 27, 2018
4a5c9ea
Zvuchit kak zadacha
PolinaShneider May 27, 2018
d7f564f
Add comments
PolinaShneider May 27, 2018
dc38095
Remove gray entirely
PolinaShneider May 27, 2018
6be9908
Merge branch 'master' of https://github.com/codex-team/codex into cou…
PolinaShneider May 28, 2018
8cc8386
Course in feed
PolinaShneider May 29, 2018
10dc77d
Update courses
PolinaShneider Jun 1, 2018
f23f0c9
Minor fix
PolinaShneider Jun 1, 2018
7e4fc4a
Add course page
PolinaShneider Jun 1, 2018
a8a10fc
Fix courses appearance
PolinaShneider Jun 4, 2018
2272aa7
Update font-size
PolinaShneider Jun 4, 2018
d61d17d
Update hover colors
PolinaShneider Jun 4, 2018
153c10b
Backend for course in feed
PolinaShneider Jun 4, 2018
fb2d980
Add check for courses without articles
PolinaShneider Jun 4, 2018
dfda9e6
One more check for courses without articles
PolinaShneider Jun 4, 2018
4bf9c66
Check for courses articles in feed
PolinaShneider Jun 4, 2018
063eafa
Fix for a single course item in feed
PolinaShneider Jun 4, 2018
17c0120
Improve padding
PolinaShneider Jun 4, 2018
b855948
Update templates
PolinaShneider Jun 4, 2018
467b686
Rename some classes and other minor fixes
PolinaShneider Jun 4, 2018
6f52ee6
Some upds
PolinaShneider Jun 4, 2018
5220317
Model update
PolinaShneider Jun 5, 2018
6970f5c
Remove hardcode
PolinaShneider Jun 5, 2018
79a2d78
Remove margin before description
PolinaShneider Jun 5, 2018
a59e526
Update margin
PolinaShneider Jun 5, 2018
a145f9e
Change margin again
PolinaShneider Jun 5, 2018
182c628
Update Model + sum small bugfixes
PolinaShneider Jun 5, 2018
203e52c
Remove extra addEventListener
PolinaShneider Jun 5, 2018
8c92086
Merge branch 'master' into course-design
talyguryn Jun 7, 2018
2bbc4df
use dt_publish top arrange items
talyguryn Jun 8, 2018
a6d5552
Revert "use dt_publish top arrange items"
talyguryn Jun 8, 2018
bf263dc
Update templates and some bug fixes
PolinaShneider Jun 8, 2018
e978608
Update courses
PolinaShneider Jun 8, 2018
c1dac14
Add comments
PolinaShneider Jun 9, 2018
97541c3
webpack 4
talyguryn Jun 12, 2018
fbe70cb
fix links to articles
talyguryn Jun 12, 2018
0faa975
fix transport
talyguryn Jun 13, 2018
a884934
Resolve merge conflicts
PolinaShneider Nov 19, 2018
ebe6c03
Merge branch 'master' of https://github.com/codex-team/codex into cou…
PolinaShneider Nov 21, 2018
a48651b
Temporarily remove caching
PolinaShneider Nov 21, 2018
c6be3fd
Removing extra stuff
PolinaShneider Nov 24, 2018
67bf79a
For debugging purposes
PolinaShneider Nov 24, 2018
e356bf3
Remove debugging stuff
PolinaShneider Nov 24, 2018
379d502
Fix cache
n0str Nov 25, 2018
13455e8
Merge branch 'master' of https://github.com/codex-team/codex into cou…
PolinaShneider Nov 25, 2018
c4c16e5
Fix dt_update for courses
PolinaShneider Nov 25, 2018
1246c08
Fix comments
PolinaShneider Nov 27, 2018
38c2a1f
Improve coments once more
PolinaShneider Nov 27, 2018
b9f0cbe
Alter article $isNotInCourse check
PolinaShneider Nov 27, 2018
2512f24
Return usage of feed
PolinaShneider Nov 27, 2018
2160f5e
Update hawk link
PolinaShneider Nov 27, 2018
fa2159d
Merge branch 'master' of https://github.com/codex-team/codex into cou…
PolinaShneider Feb 11, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 20 additions & 4 deletions www/application/classes/Controller/Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,11 +204,27 @@ public function scripts_resetArticlesTimeline()
$articles[$key] = $article;
}

$courses = Model_Courses::getActiveCoursesWithArticles();

/** rebuld array*/
foreach ($courses as $key => $value) {
$course = array(
'id' => $courses[$key]->id,
'dt_create' => $courses[$key]->dt_publish,
);
$courses[$key] = $course;
}

// #TODO add to $feed array with courses later
$feed = new Model_Feed_Articles('article');
$feed->clear();
$feed->init($articles);
$feed_articles = new Model_Feed_Articles('article');
$feed_courses = new Model_Feed_Articles('course');

$feed_articles->clear();
$feed_courses->clear();

$feed_articles->init($articles);
$feed_courses->init($courses);

return 'Articles timeline was successfully updated';
return 'Articles and Courses timeline was successfully updated';
}
}
10 changes: 8 additions & 2 deletions www/application/classes/Controller/Articles/Index.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,14 @@ public function action_show()
*/
public function getFeed()
{
$feed = new Model_Feed_Articles();
$feed_items = $feed->get();
$articles = new Model_Feed_Articles();
$article_items = $articles->get();

$courses = new Model_Courses();
$course_items = $courses->getActiveCoursesWithArticles();

$feed_items = array_merge($article_items, $course_items);

foreach ($feed_items as $feed_item) {
$coauthorship = new Model_Coauthors($feed_item->id);
$feed_item->coauthor = Model_User::get($coauthorship->user_id);
Expand Down
103 changes: 95 additions & 8 deletions www/application/classes/Model/Courses.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ class Model_Courses extends Model
public $description;
public $cover;
public $is_big_cover;
public $course_articles = [];
public $course_authors = [];
public $dt_publish;
public $dt_create;
public $dt_update;
Expand Down Expand Up @@ -73,14 +75,22 @@ public function insert()
*/
private function fillByRow($course_row)
{
if (empty($course_row['id'])) {
return $this;
}

foreach ($course_row as $fieldname => $value) {
if (property_exists($this, $fieldname)) {
$this->$fieldname = $value;
}
if (!empty($course_row['id'])) {
$this->id = Arr::get($course_row, 'id');
$this->uri = Arr::get($course_row, 'uri');
$this->title = Arr::get($course_row, 'title');
$this->text = Arr::get($course_row, 'text');
$this->description = Arr::get($course_row, 'description');
$this->cover = Arr::get($course_row, 'cover');
$this->is_big_cover = Arr::get($course_row, 'is_big_cover');
$this->marked = Arr::get($course_row, 'marked');
$this->dt_publish = Arr::get($course_row, 'dt_publish');
$this->dt_create = Arr::get($course_row, 'dt_create');
$this->dt_update = Arr::get($course_row, 'dt_update');
$this->is_removed = Arr::get($course_row, 'is_removed');
$this->is_published = Arr::get($course_row, 'is_published');
$this->course_articles = self::getArticlesFromCourseWithCoauthors($this->id);
$this->course_authors = self::getUniqueCourseAuthors($this->course_articles);
}

return $this;
Expand Down Expand Up @@ -222,6 +232,24 @@ public static function getActiveCourses($clearCache = false)
return Model_Courses::getCourses(false, false, !$clearCache ? Date::MINUTE * 5 : null);
}

/**
* Получить все опубликованные курсы, которые содержат хотя бы одну статью
*
* @return Model_Courses[] - экземпляр модели с указанным идентификатором и заполненными полями
*/
public static function getActiveCoursesWithArticles($clearCache = false)
{
$courses = Model_Courses::getCourses(false, false, !$clearCache ? Date::MINUTE * 5 : null);
$courses_with_articles = array();

foreach ($courses as $course) {
if (self::getArticles($course->id)) {
$courses_with_articles[] = $course;
}
}

return $courses_with_articles;
}

/**
* Получить все неудалённые курсы в порядке убывания ID.
Expand Down Expand Up @@ -297,4 +325,63 @@ public static function getArticles($course_id)

return Dao_CoursesArticles::select('article_id')->where('course_id', '=', $course_id)->execute();
}

/**
* Get Articles from Course
* @param [int] $courseId - ID of Course
* @return Model_Article[] - Array of Articles
*/
public static function getArticlesFromCourse($courseId)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

навести порядок: убрать лишние, убрать дублирование

{
/** getting all articles from course */
$course_articles = self::getArticles($courseId);

/** $articleList - empty array. Needs to fill by article ids */
$articleList = array();

if ($course_articles) {
foreach ($course_articles as $articles) {
$articleList[] = Model_Article::get($articles['article_id']);
}
}

return $articleList;
}

/**
* Get articles from course with coauthors
* @return Model_Article[]
*/
public function getArticlesFromCourseWithCoauthors($courseId)
{
$course_articles = self::getArticlesFromCourse($courseId);

foreach ($course_articles as $course_article) {
$coauthorship = new Model_Coauthors($course_article->id);
$course_article->coauthor = Model_User::get($coauthorship->user_id);
}
return $course_articles;
}

/**
* Return unique article authors from the Course
* @param Model_Article[] - Articles included in specific Course
* @return Model_User[] - Array of unique Course authors
*/
public static function getUniqueCourseAuthors($course_articles)
{
$course_authors_ids = array();
$course_authors = array();

foreach ($course_articles as $article) {
$author_id = $article->author->id;

if (!in_array($author_id, $course_authors_ids))
{
$course_authors_ids[] = $author_id;
$course_authors[] = Model_User::get($author_id);
}
}
return $course_authors;
}
}
71 changes: 40 additions & 31 deletions www/application/views/templates/articles/article.php
Original file line number Diff line number Diff line change
@@ -1,34 +1,14 @@
<div class="center_side clear">
<div class="center_side clear course-menu--top">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

course-menu убрать

<? if (isset($articlesFromCourse)): ?>
<?= View::factory('templates/articles/course_list')
->set('articles', $articlesFromCourse)
->set('mobileToggleClass', 'course-menu__title--toggle js-course-menu__title--toggle')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

расхардкодить

->set('currentArticle', $article)
->set('course', $course)
?>
<? endif; ?>
</div>

<? if (isset($previousArticle)): ?>
<div class="course-navigation-wrapper course-navigation-wrapper--previous" name="js-course-navigation">
<a class="course-navigation course-navigation--previous" href="<?= URL::site($previousArticle->uri ?: '/article/' . $previousArticle->id) ?>">
<div class="course-navigation__icon course-navigation__icon--previous"></div>
<div class="course-navigation__title"><?= HTML::chars($previousArticle->title) ?></div>
<img class="course-navigation__avatar" src="<?= $previousArticle->author->photo ?>" itemprop="image">
<div class="course-navigation__author"><?= HTML::chars($previousArticle->author->name) ?></div>
</a>
</div>
<? endif; ?>

<? if (isset($nextArticle)): ?>
<div class="course-navigation-wrapper course-navigation-wrapper--next" name="js-course-navigation">
<a class="course-navigation course-navigation--next" href="<?=URL::site($nextArticle->uri ?: '/article/' . $nextArticle->id); ?>">
<div class="course-navigation__icon course-navigation__icon--next"></div>
<div class="course-navigation__title"><?= HTML::chars($nextArticle->title) ?></div>
<img class="course-navigation__avatar" src="<?= $nextArticle->author->photo ?>" itemprop="image">
<div class="course-navigation__author"><?= HTML::chars($nextArticle->author->name) ?></div>
</a>
</div>
<? endif; ?>

<article class="article" itemscope itemtype="http://schema.org/Article">

<script type="application/ld+json">
Expand Down Expand Up @@ -174,6 +154,35 @@

</div>

<? if (isset($previousArticle) || isset($nextArticle)): ?>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

вынести в отдельный шаблон

<div class="center_side clear course-navigation-wrapper">
<div class="course-navigation" name="js-course-navigation">
<? if (isset($previousArticle)): ?>
<a class="course-navigation__item course-navigation__item--previous" href="<?= URL::site($previousArticle->uri ?: '/article/' . $previousArticle->id) ?>">
<?= HTML::chars($previousArticle->title) ?>
</a>
<? endif; ?>

<? if (isset($nextArticle)): ?>
<a class="course-navigation__item course-navigation__item--next" href="<?=URL::site($nextArticle->uri ?: '/article/' . $nextArticle->id); ?>">
<?= HTML::chars($nextArticle->title) ?>
</a>
<? endif; ?>
</div>
</div>
<? endif; ?>

<div class="center_side clear">
<? if (isset($articlesFromCourse)) : ?>
<?=View::factory('templates/articles/course_list')
->set('articles', $articlesFromCourse)
->set('mobileToggleClass', '')
->set('currentArticle', $article)
->set('course', $course)
?>
<? endif; ?>
</div>

<? if(!empty($quiz)): ?>
<?= View::factory('templates/quizzes/quiz', array('quizData' => $quiz->quiz_data)); ?>
<? endif ?>
Expand All @@ -200,12 +209,12 @@

</article>

<script>

<div class="center_side clear">
<? if (isset($articlesFromCourse)) : ?>
<?=View::factory('templates/articles/course_list')
->set('articles', $articlesFromCourse)
->set('course', $course)
?>
<? endif; ?>
</div>
codex.docReady(function () {

codex.courses.toggleCourse();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

убрать


});

</script>
14 changes: 14 additions & 0 deletions www/application/views/templates/articles/course_articles.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<? if ($articlesFromCourse) : ?>

<ul class="course-menu-list">
<? foreach ($articlesFromCourse as $article) : ?>
<li class="course-menu-list__item">
<a href="<?=URL::site( '/article/ ' . $article->id ); ?>" class="course-menu-list__link course-menu-list__link--black">
<?= $article->title; ?>
<div class="course-menu-list__item-label"></div>
</a>
</li>
<? endforeach; ?>
</ul>

<? endif; ?>
20 changes: 15 additions & 5 deletions www/application/views/templates/articles/course_list.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
<section class="course">
<section class="course-menu">

<h2 class="course__title"><?=$course->title; ?></h2>
<h2 class="course-menu__title <?= $mobileToggleClass ?>">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

лишняя обертка

<a href="<?= "/course/" . $course->id ?>">
<?=$course->title; ?>
</a>
</h2>

<? if (!empty($articles)) : ?>
<ul class="courses-list">
<ul class="course-menu-list js-course-menu-list">
<? foreach ($articles as $article) : ?>
<li class="courses-list__item">
<a href="<?=URL::site($article->uri ?: '/article/ ' . $article->id ); ?>" class="courses-list__link" href=""><?=$article->title; ?></a>
<?
$isCurrent = $article->id == $currentArticle->id;
?>
<li class="course-menu-list__item <?= $isCurrent ? 'course-menu-list__item--current' : '' ?>">
<a href="<?=URL::site($article->uri ?: '/article/ ' . $article->id ); ?>" class="course-menu-list__link">
<?= $article->title; ?>
<div class="course-menu-list__item-label"></div>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

span

</a>
</li>
<? endforeach; ?>
</ul>
Expand Down
69 changes: 69 additions & 0 deletions www/application/views/templates/articles/feed_list_item.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<article class="feed-item clearfix <?= $item->marked ? 'feed-item--big' : ''?> <?= $item->cover ? 'feed-item--with-cover' : '' ?><?= $item->is_big_cover ? ' feed-item--with-big-cover' : ''?>" data-type="<?= $item::FEED_PREFIX; ?>" data-id="<?= HTML::chars($item->id); ?>">

<?
$url = $item->uri ?: 'article/' . $item->id;
?>

<? if ($item::FEED_PREFIX == 'course'): ?>
<?
$articlesFromCourse = $item->course_articles;
$courseAuthors = $item->course_authors;

if ($articlesFromCourse) {
$item->author = $courseAuthors[0];
}

if (count($courseAuthors) > 1) {
$item->coauthor = $courseAuthors[count($courseAuthors) - 1];
}
?>
<? endif; ?>

<? if ($item->cover): ?>
<a class="feed-item__cover" href="<?= HTML::chars($url) ?>">
<img src="<?= HTML::chars($item->cover) ?>">
</a>
<? endif; ?>

<a class="feed-item__title js-emoji-included" href="/<?= HTML::chars($url) ?>">
<?= HTML::chars($item->title) ?>
</a>

<? if ($item::FEED_PREFIX == 'article'): ?>

<div class="feed-item__description">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

вынести из проверки

<?= HTML::chars($item->description) ?>
</div>

<? elseif ($item::FEED_PREFIX == 'course'): ?>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

оставить один if


<?= View::factory('templates/articles/course_articles', array( 'articlesFromCourse' => $articlesFromCourse)); ?>

<? endif; ?>

<div class="feed-item__info">
<time class="feed-item__time">
<?= date_format(date_create($item->dt_publish), 'd M Y'); ?>
</time>

<a class="feed-item__author-photo" href="/user/<?= HTML::chars($item->author->id) ?>">
<img src="<?= HTML::chars($item->author->photo) ?>" alt="<?= HTML::chars($item->author->name) ?>">
</a>
<? if ($item->coauthor->id): ?>
<a class="feed-item__author-photo" href="/user/<?= HTML::chars($item->coauthor->id) ?>">
<img src="<?= HTML::chars($item->coauthor->photo) ?>" alt="<?= HTML::chars($item->coauthor->name) ?>">
</a>
<? endif; ?>

<a class="feed-item__author-name" href="/user/<?= HTML::chars($item->author->id) ?>">
<?= HTML::chars($item->author->name) ?>
</a>
<? if ($item->coauthor->id): ?>
and <a class="feed-item__author-name" href="/user/<?= HTML::chars($item->coauthor->id) ?>">
<?= HTML::chars($item->coauthor->name) ?>
</a>
<? endif; ?>

</div>

</article>
Loading