summaryrefslogtreecommitdiff
path: root/public/app/views/components
diff options
context:
space:
mode:
authorGeo Halkiadakis <gchalkiadakis@sklavenitis.co.gr>2023-04-24 12:47:53 +0300
committerGeo Halkiadakis <gchalkiadakis@sklavenitis.co.gr>2023-04-24 12:47:53 +0300
commit41d3b5fb68829bbc61ef13ed127dcfb86fa124a0 (patch)
tree1d98c269c6b2314e2f0e3d128c3c76e173b5ad2c /public/app/views/components
parent17d243371c43847e9dbdeb21395afc0e8f5437ae (diff)
downloadclassroom-41d3b5fb68829bbc61ef13ed127dcfb86fa124a0.tar.gz
classroom-41d3b5fb68829bbc61ef13ed127dcfb86fa124a0.tar.bz2
classroom-41d3b5fb68829bbc61ef13ed127dcfb86fa124a0.zip
frontend and backend design enhancements
Diffstat (limited to 'public/app/views/components')
-rw-r--r--public/app/views/components/courses_menu.php97
-rw-r--r--public/app/views/components/top_bar.php (renamed from public/app/views/components/top-bar.php)0
2 files changed, 97 insertions, 0 deletions
diff --git a/public/app/views/components/courses_menu.php b/public/app/views/components/courses_menu.php
new file mode 100644
index 0000000..6539f8c
--- /dev/null
+++ b/public/app/views/components/courses_menu.php
@@ -0,0 +1,97 @@
+<?php
+/** Categories Menu
+ * -----------------------------------------------------------------------------
+ * sits in the (left) sidebar
+ *
+ * imported variables
+ * ---
+ * @param $categories (array) : the categories tree
+ * @param $open_path (array) : 'id's array of selected categories
+ *
+ * example call:
+ * (draw the categories-menu and set open the categories with ids 1 and 2)
+ * ---
+ * Render::template("section/categories_menu.php",[
+ * 'categories' => $category_tree,
+ * 'open_path' => [1 ,2]
+ * ]);
+ *
+ * -----------------------------------------------------------------------------
+ */
+
+/** tree_ul
+ * creates (recursively) a nested ul-li tree of categories
+ * --- -- -- - - -
+ * @param $tree (array) : categories array formated as tree
+ * @param $open_nodes (array) : array of categor ids that shall be marked open/selected
+ * @return $html (string)
+ */
+function tree_li($tree, $open_nodes = [], $l = 0)
+{
+ $html = "";
+
+ foreach($tree as $node) {
+
+ // if has childs ...
+ // write li ; traverse children recursively
+ if ((isset($node['childs'])) && ( $node['childs']!= [])) {
+
+ if (in_array(intval($node['rec']['id']), $open_nodes)) {
+ $inner_class = "inner show";
+ $sign = "–";
+ $a_class = "has-childs selected";
+
+ } else {
+ $inner_class = "inner";
+ $sign = "+";
+ $a_class = "has-childs";
+ }
+
+ $html .= "<li>
+ <a href='/course/{$node['rec']['id']}' class='{$a_class}'>
+ <span class='label'>{$node['rec']['label']}</span>
+ <span class='toggler'>{$sign}</span>
+ </a>
+ <ul class='{$inner_class}'>"
+ . tree_li($node['childs'], $open_nodes, $l+1)
+ ."</ul>
+ </li>";
+
+
+ } else { // else just write the li
+
+ if (in_array(intval($node['rec']['id']), $open_nodes)) {
+ $u_in = "<u>";
+ $u_out = "</u>";
+ $a_class = "selected";
+
+ } else {
+ $u_in = "";
+ $u_out = "";
+ $a_class = "";
+
+ }
+
+ $html .= "<li>
+ <a href='/course/{$node['rec']['id']}' class='{$a_class}'>
+ <span class='label'>{$node['rec']['label']}</span>
+ </a>
+ </li>";
+ }
+ }
+
+ return $html;
+
+}
+
+
+// draw the menu (hidden on XS screens)
+// -----------------------------------------------------------------------------
+echo "<h3>Διαθέσιμη ύλη</h3>";
+echo "<ul class='hidden-xs side-bar'>". tree_li($categories, $open_path) ."</ul>";
+
+
+
+// TODO:
+// draw menu for XS screens (for example, just the 1st-level categories)
+// (maybe in an accordion so it won;t take too much area on small screens)
diff --git a/public/app/views/components/top-bar.php b/public/app/views/components/top_bar.php
index ed96e35..ed96e35 100644
--- a/public/app/views/components/top-bar.php
+++ b/public/app/views/components/top_bar.php