From b0fea017f2aa77a8365f553f60b1e01e0b3dc6a6 Mon Sep 17 00:00:00 2001 From: Harald Bamberger Date: Fri, 29 May 2026 08:42:02 +0200 Subject: [PATCH] further progress on rendering partMenu --- application/config/treemenu/stv_menu.php | 16 +++--- .../controllers/api/frontend/v1/TreeMenu.php | 32 ++++++++++-- application/libraries/treemenu/InOutLib.php | 51 ++++++++++--------- application/libraries/treemenu/StgLib.php | 49 +++++++++--------- application/libraries/treemenu/StvMenuLib.php | 15 ++++-- .../libraries/treemenu/TreeMenuLib.php | 4 +- 6 files changed, 101 insertions(+), 66 deletions(-) diff --git a/application/config/treemenu/stv_menu.php b/application/config/treemenu/stv_menu.php index 1460ca5f3..15d64aa64 100644 --- a/application/config/treemenu/stv_menu.php +++ b/application/config/treemenu/stv_menu.php @@ -6,35 +6,37 @@ $config['stv_menu'] = array( 'children' => array( 'stg' => array( 'library' => 'treemenu/StgLib', +/* 'children' => array( 'pre' => array( - 'library' => 'treemenu/Prestudent' + 'library' => 'treemenu/PrestudentLib' ), 'sem' => array( - 'library' => 'treemenu/AusbSemester', + 'library' => 'treemenu/AusbSemesterLib', 'children' => array( 'vbd' => array( - 'library' => 'treemenu/Verband' + 'library' => 'treemenu/VerbandLib' ) ) ), 'orgform' => array( - 'library' => 'treemenu/OrgForm', + 'library' => 'treemenu/OrgFormLib', 'children' => array( 'pre' => array( - 'library' => 'treemenu/Prestudent' + 'library' => 'treemenu/PrestudentLib' ), 'sem' => array( - 'library' => 'treemenu/AusbSemester', + 'library' => 'treemenu/AusbSemesterLib', 'children' => array( 'vbd' => array( - 'library' => 'treemenu/Verband' + 'library' => 'treemenu/VerbandLib' ) ) ) ) ) ) +*/ ), 'inout' => array( 'library' => 'treemenu/InOutLib' diff --git a/application/controllers/api/frontend/v1/TreeMenu.php b/application/controllers/api/frontend/v1/TreeMenu.php index 2f7834bff..f45ea7b52 100644 --- a/application/controllers/api/frontend/v1/TreeMenu.php +++ b/application/controllers/api/frontend/v1/TreeMenu.php @@ -64,19 +64,43 @@ class TreeMenu extends FHCAPI_Controller $this->loadMenuConfig($treemenu); + $startconfig = $this->findStartLib($this->treemenuconfig, array_keys($this->uri->uri_to_assoc(7))); + + $libpath = $startconfig['library']; + $children = isset($startconfig['children']) ? $startconfig['children'] : array(); + $libname = basename($startconfig['library']); + + $this->load->library( + $libpath, + $children, + $libname + ); + $bhdebug = (object) array( 'treemenu' => $treemenu, 'treemenuconfig' => $this->treemenuconfig, - 'uri' => $this->uri->uri_to_assoc(7) + 'uri' => $this->uri->uri_to_assoc(7), + 'libpath' => $libpath, + 'libname' => $libname, + 'children' => $children, + 'startconfig' => $startconfig ); $this->addMeta('bhdebug', $bhdebug); + //$this->addMeta('bhci', $this); - $this->load->library($this->treemenuconfig->library, $this->treemenuconfig->children); - - $data = $this->StvMenuLib->getSubMenu(); + $data = $this->$libname->getSubMenu(); $this->terminateWithSuccess($data); } + protected function findStartLib($config, $uri) + { + $level = array_shift($uri); + if(is_null($level)) { + return $config; + } + return $this->findStartLib($config['children'][$level], $uri); + } + protected function loadMenuConfig($treemenu) { $this->config->load('treemenu/' . $treemenu . '.php'); diff --git a/application/libraries/treemenu/InOutLib.php b/application/libraries/treemenu/InOutLib.php index b16e258ec..5c52da996 100644 --- a/application/libraries/treemenu/InOutLib.php +++ b/application/libraries/treemenu/InOutLib.php @@ -1,39 +1,42 @@ 'International', - 'link' => 'inout', - 'children' => [ - [ - 'name' => 'Incoming', - 'link' => 'inout/incoming', - 'leaf' => true - ], - [ - 'name' => 'Outgoing', - 'link' => 'inout/outgoing', - 'leaf' => true - ], - [ - 'name' => 'Gemeinsame Studien', - 'link' => 'inout/gemeinsamestudien', - 'leaf' => true + [ + 'name' => 'International', + 'link' => 'inout', + 'children' => [ + [ + 'name' => 'Incoming', + 'link' => 'inout/incoming', + 'leaf' => true + ], + [ + 'name' => 'Outgoing', + 'link' => 'inout/outgoing', + 'leaf' => true + ], + [ + 'name' => 'Gemeinsame Studien', + 'link' => 'inout/gemeinsamestudien', + 'leaf' => true + ] ] ] ]; } + + public function getSubMenu() + { + return []; + } } diff --git a/application/libraries/treemenu/StgLib.php b/application/libraries/treemenu/StgLib.php index 6a495dc46..d2f8d9a16 100644 --- a/application/libraries/treemenu/StgLib.php +++ b/application/libraries/treemenu/StgLib.php @@ -1,39 +1,38 @@ ci->load->model('organisation/Studiengang_model', 'StudiengangModel'); + $res = $this->ci->StudiengangModel->loadWhere(array('aktiv' => true)); + $stgs = hasData($res) ? getData($res) : array(); + + $this->ci->addMeta('bhstg', $stgs); + $nodes = array_map( + function($stg) { + return array( + 'name' => strtoupper($stg->typ . $stg->kurzbz) . ' ' . $stg->bezeichnung, + 'link' => 'stg/' . $stg->studiengang_kz, + 'leaf' => false + ); + }, + $stgs + ); + + return $nodes; + } + public function getSubMenu() { return [ - 'name' => 'International', - 'link' => 'inout', - 'children' => [ - [ - 'name' => 'Incoming', - 'link' => 'inout/incoming', - 'leaf' => true - ], - [ - 'name' => 'Outgoing', - 'link' => 'inout/outgoing', - 'leaf' => true - ], - [ - 'name' => 'Gemeinsame Studien', - 'link' => 'inout/gemeinsamestudien', - 'leaf' => true - ] - ] + 'StgLib' => 'test123' ]; } } diff --git a/application/libraries/treemenu/StvMenuLib.php b/application/libraries/treemenu/StvMenuLib.php index 257a56735..e4db7ce28 100644 --- a/application/libraries/treemenu/StvMenuLib.php +++ b/application/libraries/treemenu/StvMenuLib.php @@ -1,5 +1,5 @@ null - ]; + $nodes = array(); + + foreach($this->children_config as $childconfig) + { + $childlib = basename($childconfig['library']); + $childnodes = $this->ci->$childlib->getNodes(); + $nodes = array_merge($nodes, $childnodes); + } + + return $nodes; } } diff --git a/application/libraries/treemenu/TreeMenuLib.php b/application/libraries/treemenu/TreeMenuLib.php index 02485b5a6..618f69e80 100644 --- a/application/libraries/treemenu/TreeMenuLib.php +++ b/application/libraries/treemenu/TreeMenuLib.php @@ -17,12 +17,12 @@ abstract class TreeMenuLib public function __construct($children_config) { - $this->ci = get_instance(); + $this->ci =& get_instance(); $this->children_config = $children_config; foreach($this->children_config as $child_config) { $grandchildren_config = isset($child_config['children']) ? $child_config['children'] : []; - $this->ci->load->library($child_config->library, $grandchildren_config); + $this->ci->load->library($child_config['library'], $grandchildren_config, basename($child_config['library'])); } }