diff options
| author | Geo Halkiadakis <gchalkiadakis@sklavenitis.co.gr> | 2023-04-24 12:47:53 +0300 |
|---|---|---|
| committer | Geo Halkiadakis <gchalkiadakis@sklavenitis.co.gr> | 2023-04-24 12:47:53 +0300 |
| commit | 41d3b5fb68829bbc61ef13ed127dcfb86fa124a0 (patch) | |
| tree | 1d98c269c6b2314e2f0e3d128c3c76e173b5ad2c /public/app/views/components | |
| parent | 17d243371c43847e9dbdeb21395afc0e8f5437ae (diff) | |
| download | classroom-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.php | 97 | ||||
| -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 |
