function getTopicsTreeTopicHTML($topic_data) { $topic_children_count = count($topic_data['Children']); $topic_lessons_count = count($topic_data['Lessons']); $topic_tags_count = count($topic_data['Tags']); $topic_html = <<<s <div class="tree_item" data-type="topic"> s; if ($topic_children_count || $topic_lessons_count) { $topic_html .= <<<s \t<input class="toggler" id="toggler[topic_{$topic_data['Id']}]" type="checkbox" /> s; } $topic_html .= <<<s \t<div class="self"> s; if ($topic_children_count || $topic_lessons_count) { $topic_html .= <<<s \t\t<label class="toggler" for="toggler[topic_{$topic_data['Id']}]"></label> s; } $topic_html .= <<<s \t\t<a class="link topic" data-topic-id="{$topic_data['Id']}" href="topic.php?id={$topic_data['Id']}"> \t\t\t<h4>{$topic_data['Title']}</h4> \t\t\t<p>Topics: {$topic_children_count} · Lessons: {$topic_lessons_count} · Tags: {$topic_tags_count}</p> \t\t</a> \t</div> s; if ($topic_children_count || $topic_lessons_count) { $topic_html .= <<<s \t<div class="children"> s; if ($topic_children_count) { foreach ($topic_data['Children'] as $topic_child_data) { $topic_html .= getTopicsTreeTopicHTML($topic_child_data); } } if ($topic_lessons_count) { foreach ($topic_data['Lessons'] as $topic_lesson_data) { $topic_html .= getLessonsTreeLessonHTML($topic_lesson_data); } } $topic_html .= <<<s \t</div> s; } $topic_html .= <<<s </div> s; return $topic_html; }
$topics_tree = getTopicsTree(); $lessons_tree = getLessonsTree(); echo <<<s <div class="page" id="overview_page"> <div class="columns"> <div class="column"> <section class="page_section"> <h2>Topics</h2> </section> <section style="max-height: 800px; overflow-x: scroll;"> s; foreach ($topics_tree as $topics_tree_topic_data) { echo getTopicsTreeTopicHTML($topics_tree_topic_data); } echo <<<s </section> </div> <div class="column"> <section> <h2>Lessons</h2> </section> <section style="max-height: 800px; overflow-x: scroll;"> <input onKeyUp="filterLessonFamilies(this);" /> <div class="lesson_family"> s; foreach ($lessons_tree as $lessons_tree_lesson_data) {