mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-21 17:02:19 +00:00
refactor
This commit is contained in:
@@ -8,7 +8,7 @@ require_once APPPATH . 'libraries/treemenu/TreeMenuLib.php';
|
||||
*/
|
||||
class InOutLib extends TreeMenuLib
|
||||
{
|
||||
public function getNodes()
|
||||
public function getNodes($params=array(), $includeSubMenu=false)
|
||||
{
|
||||
return [
|
||||
[
|
||||
@@ -34,9 +34,4 @@ class InOutLib extends TreeMenuLib
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
public function getSubMenu()
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
require_once APPPATH . 'libraries/treemenu/TreeMenuLib.php';
|
||||
|
||||
/**
|
||||
* Description of OrgFormLib
|
||||
*
|
||||
* @author bambi
|
||||
*/
|
||||
class OrgFormLib extends TreeMenuLib
|
||||
{
|
||||
public function getData()
|
||||
{
|
||||
if(!isset($this->params['stg']))
|
||||
{
|
||||
throw new Exception(self::class . ' Missing Parameter stg.');
|
||||
}
|
||||
|
||||
$this->ci->load->model('codex/Orgform_model', 'OrgFormModel');
|
||||
|
||||
$sql = <<<EOSQL
|
||||
select
|
||||
o.*
|
||||
from
|
||||
bis.tbl_orgform o
|
||||
join (
|
||||
SELECT
|
||||
tl.orgform_kurzbz
|
||||
FROM
|
||||
public.tbl_lehrverband AS tl
|
||||
WHERE
|
||||
studiengang_kz = {$this->ci->OrgFormModel->escape($this->params['stg'])}
|
||||
and
|
||||
orgform_kurzbz IS NOT null
|
||||
group by
|
||||
orgform_kurzbz
|
||||
) v on o.orgform_kurzbz = v.orgform_kurzbz
|
||||
order by
|
||||
o.orgform_kurzbz
|
||||
EOSQL;
|
||||
|
||||
$res = $this->ci->OrgFormModel->execReadonlyQuery($sql);
|
||||
$orgforms = hasData($res) ? getData($res) : array();
|
||||
|
||||
$this->ci->addMeta('bhorgform_' . $this->params['stg'] , $orgforms);
|
||||
|
||||
return $orgforms;
|
||||
}
|
||||
|
||||
protected function getParamsForNextLevel($element=null)
|
||||
{
|
||||
if($element)
|
||||
{
|
||||
$paramsstg = array_merge($this->params, array('orgform' => $element->orgform_kurzbz));
|
||||
return $paramsstg;
|
||||
}
|
||||
return $this->params;
|
||||
}
|
||||
|
||||
protected function getName($element)
|
||||
{
|
||||
$name = $element->orgform_kurzbz . ' ' . $element->bezeichnung;
|
||||
return $name;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
require_once APPPATH . 'libraries/treemenu/TreeMenuLib.php';
|
||||
|
||||
/**
|
||||
* Description of PreStudentLib
|
||||
*
|
||||
* @author bambi
|
||||
*/
|
||||
class PreStudentLib extends TreeMenuLib
|
||||
{
|
||||
public function getNodes($params=array())
|
||||
{
|
||||
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
|
||||
]
|
||||
]
|
||||
]
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -8,31 +8,32 @@ require_once APPPATH . 'libraries/treemenu/TreeMenuLib.php';
|
||||
*/
|
||||
class StgLib extends TreeMenuLib
|
||||
{
|
||||
public function getNodes()
|
||||
protected function getData()
|
||||
{
|
||||
$this->ci->load->model('organisation/Studiengang_model', 'StudiengangModel');
|
||||
$this->ci->StudiengangModel->addOrder('typ');
|
||||
$this->ci->StudiengangModel->addOrder('kurzbz');
|
||||
$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;
|
||||
return $stgs;
|
||||
}
|
||||
|
||||
public function getSubMenu()
|
||||
protected function getParamsForNextLevel($element=null)
|
||||
{
|
||||
return [
|
||||
'StgLib' => 'test123'
|
||||
];
|
||||
if($element)
|
||||
{
|
||||
$paramsstg = array_merge($this->params, array('stg' => $element->studiengang_kz));
|
||||
return $paramsstg;
|
||||
}
|
||||
return $this->params;
|
||||
}
|
||||
|
||||
protected function getName($element)
|
||||
{
|
||||
$name = strtoupper($element->typ . $element->kurzbz) . ' ' . $element->bezeichnung;
|
||||
return $name;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,17 +7,8 @@ require_once APPPATH . 'libraries/treemenu/TreeMenuLib.php';
|
||||
*/
|
||||
class StvMenuLib extends TreeMenuLib
|
||||
{
|
||||
public function getSubMenu()
|
||||
public function getNodes($params=array(), $includeSubMenu=false)
|
||||
{
|
||||
$nodes = array();
|
||||
|
||||
foreach($this->children_config as $childconfig)
|
||||
{
|
||||
$childlib = basename($childconfig['library']);
|
||||
$childnodes = $this->ci->$childlib->getNodes();
|
||||
$nodes = array_merge($nodes, $childnodes);
|
||||
}
|
||||
|
||||
return $nodes;
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,15 +10,20 @@
|
||||
*
|
||||
* @author bambi
|
||||
*/
|
||||
abstract class TreeMenuLib
|
||||
class TreeMenuLib
|
||||
{
|
||||
protected $ci;
|
||||
protected $children_config;
|
||||
protected $params;
|
||||
protected $includeSubMenu;
|
||||
|
||||
public function __construct($children_config)
|
||||
{
|
||||
$this->ci =& get_instance();
|
||||
$this->children_config = $children_config;
|
||||
$this->params = array();
|
||||
$this->includeSubMenu = false;
|
||||
|
||||
foreach($this->children_config as $child_config)
|
||||
{
|
||||
$grandchildren_config = isset($child_config['children']) ? $child_config['children'] : [];
|
||||
@@ -26,14 +31,78 @@ abstract class TreeMenuLib
|
||||
}
|
||||
}
|
||||
|
||||
public function getNode($name)
|
||||
public function init($params=array(), $includeSubMenu=false)
|
||||
{
|
||||
$node = array(
|
||||
'name' => $name
|
||||
);
|
||||
|
||||
return $node;
|
||||
$this->params = $params;
|
||||
$this->includeSubMenu = $includeSubMenu;
|
||||
}
|
||||
|
||||
public abstract function getSubMenu();
|
||||
public function getNodes()
|
||||
{
|
||||
$data = $this->getData();
|
||||
|
||||
$nodes = array();
|
||||
foreach($data as $element)
|
||||
{
|
||||
$node = array(
|
||||
'name' => $this->getName($element),
|
||||
'link' => $this->getLink($element),
|
||||
'leaf' => $this->isLeaf()
|
||||
);
|
||||
if($this->includeSubMenu)
|
||||
{
|
||||
$node['children'] = $this->getSubMenu($element);
|
||||
}
|
||||
$nodes[] = $node;
|
||||
};
|
||||
|
||||
return $nodes;
|
||||
}
|
||||
|
||||
public function getSubMenu($element=null)
|
||||
{
|
||||
$nodes = array();
|
||||
|
||||
foreach($this->children_config as $childconfig)
|
||||
{
|
||||
$childlib = basename($childconfig['library']);
|
||||
$this->ci->$childlib->init(
|
||||
$this->getParamsForNextLevel($element),
|
||||
$this->includeSubMenu
|
||||
);
|
||||
$childnodes = $this->ci->$childlib->getNodes();
|
||||
$nodes = array_merge($nodes, $childnodes);
|
||||
}
|
||||
|
||||
return $nodes;
|
||||
}
|
||||
|
||||
protected function getData()
|
||||
{
|
||||
return array();
|
||||
}
|
||||
|
||||
protected function getParamsForNextLevel($element=null)
|
||||
{
|
||||
return $this->params;
|
||||
}
|
||||
|
||||
protected function getName($element)
|
||||
{
|
||||
return __METHOD__ . 'NOT IMPLEMENTED';
|
||||
}
|
||||
|
||||
protected function getLink($element)
|
||||
{
|
||||
$link = $this->ci->uri->assoc_to_uri($this->getParamsForNextLevel($element));
|
||||
return $link;
|
||||
}
|
||||
|
||||
protected function isLeaf()
|
||||
{
|
||||
if(count($this->children_config) === 0) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user