From 51d73c862b439646f8c65682002db03d8b2ba40f Mon Sep 17 00:00:00 2001 From: Harald Bamberger Date: Mon, 11 May 2026 16:42:48 +0200 Subject: [PATCH] treemenu trial --- application/config/treemenu/stv_menu.php | 43 ++++++++++ .../controllers/api/frontend/v1/TreeMenu.php | 85 +++++++++++++++++++ application/libraries/treemenu/InOutLib.php | 39 +++++++++ application/libraries/treemenu/StgLib.php | 39 +++++++++ application/libraries/treemenu/StvMenuLib.php | 16 ++++ .../libraries/treemenu/TreeMenuLib.php | 39 +++++++++ 6 files changed, 261 insertions(+) create mode 100644 application/config/treemenu/stv_menu.php create mode 100644 application/controllers/api/frontend/v1/TreeMenu.php create mode 100644 application/libraries/treemenu/InOutLib.php create mode 100644 application/libraries/treemenu/StgLib.php create mode 100644 application/libraries/treemenu/StvMenuLib.php create mode 100644 application/libraries/treemenu/TreeMenuLib.php diff --git a/application/config/treemenu/stv_menu.php b/application/config/treemenu/stv_menu.php new file mode 100644 index 000000000..1460ca5f3 --- /dev/null +++ b/application/config/treemenu/stv_menu.php @@ -0,0 +1,43 @@ + 'treemenu/StvMenuLib', + 'children' => array( + 'stg' => array( + 'library' => 'treemenu/StgLib', + 'children' => array( + 'pre' => array( + 'library' => 'treemenu/Prestudent' + ), + 'sem' => array( + 'library' => 'treemenu/AusbSemester', + 'children' => array( + 'vbd' => array( + 'library' => 'treemenu/Verband' + ) + ) + ), + 'orgform' => array( + 'library' => 'treemenu/OrgForm', + 'children' => array( + 'pre' => array( + 'library' => 'treemenu/Prestudent' + ), + 'sem' => array( + 'library' => 'treemenu/AusbSemester', + 'children' => array( + 'vbd' => array( + 'library' => 'treemenu/Verband' + ) + ) + ) + ) + ) + ) + ), + 'inout' => array( + 'library' => 'treemenu/InOutLib' + ), + ) +); diff --git a/application/controllers/api/frontend/v1/TreeMenu.php b/application/controllers/api/frontend/v1/TreeMenu.php new file mode 100644 index 000000000..2f7834bff --- /dev/null +++ b/application/controllers/api/frontend/v1/TreeMenu.php @@ -0,0 +1,85 @@ +. + */ + +if (! defined('BASEPATH')) exit('No direct script access allowed'); + +/** + * This controller operates between (interface) the JS (GUI) and the back-end + * Provides data to the ajax get calls about verbände + * This controller works with JSON calls on the HTTP GET or POST and the output is always JSON + */ +class TreeMenu extends FHCAPI_Controller +{ + protected $treemenuconfig; + + public function __construct() + { + parent::__construct([ + 'fullMenu' => ['admin:r', 'assistenz:r'], + 'partMenu' => ['admin:r', 'assistenz:r'], + ]); + } + + public function fullMenu($treemenu=null) + { + if(is_null($treemenu)) + { + $this->terminateWithError('missing parameter treemenu.'); + } + + $this->loadMenuConfig($treemenu); + + $bhdebug = (object) array( + 'treemenu' => $treemenu, + 'treemenuconfig' => $this->treemenuconfig + + ); + $this->addMeta('bhdebug', $bhdebug); + + $data = array(); + $this->terminateWithSuccess($data); + } + + public function partMenu($treemenu=null) + { + if(is_null($treemenu)) + { + $this->terminateWithError('missing parameter treemenu.'); + } + + $this->loadMenuConfig($treemenu); + + $bhdebug = (object) array( + 'treemenu' => $treemenu, + 'treemenuconfig' => $this->treemenuconfig, + 'uri' => $this->uri->uri_to_assoc(7) + ); + $this->addMeta('bhdebug', $bhdebug); + + $this->load->library($this->treemenuconfig->library, $this->treemenuconfig->children); + + $data = $this->StvMenuLib->getSubMenu(); + $this->terminateWithSuccess($data); + } + + protected function loadMenuConfig($treemenu) + { + $this->config->load('treemenu/' . $treemenu . '.php'); + $this->treemenuconfig = $this->config->item($treemenu); + } +} \ No newline at end of file diff --git a/application/libraries/treemenu/InOutLib.php b/application/libraries/treemenu/InOutLib.php new file mode 100644 index 000000000..b16e258ec --- /dev/null +++ b/application/libraries/treemenu/InOutLib.php @@ -0,0 +1,39 @@ + '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 + ] + ] + ]; + } +} diff --git a/application/libraries/treemenu/StgLib.php b/application/libraries/treemenu/StgLib.php new file mode 100644 index 000000000..6a495dc46 --- /dev/null +++ b/application/libraries/treemenu/StgLib.php @@ -0,0 +1,39 @@ + '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 + ] + ] + ]; + } +} diff --git a/application/libraries/treemenu/StvMenuLib.php b/application/libraries/treemenu/StvMenuLib.php new file mode 100644 index 000000000..257a56735 --- /dev/null +++ b/application/libraries/treemenu/StvMenuLib.php @@ -0,0 +1,16 @@ + null + ]; + } +} diff --git a/application/libraries/treemenu/TreeMenuLib.php b/application/libraries/treemenu/TreeMenuLib.php new file mode 100644 index 000000000..02485b5a6 --- /dev/null +++ b/application/libraries/treemenu/TreeMenuLib.php @@ -0,0 +1,39 @@ +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); + } + } + + public function getNode($name) + { + $node = array( + 'name' => $name + ); + + return $node; + } + + public abstract function getSubMenu(); +}