mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-18 15:32:17 +00:00
- Navigation header array structure now is the same as the structure of the navigation menu array
- Implemented the sort logic and added the "sort" attribute to sort menu and header entries for the NavigationWidget - Added the private method _sortArray to the NavigationLib to sort menu and header entries - Added the "target" attribute to be used with the attribute "link" to build the link of a menu or header entry - Now the header menu supports icons on the left side of the entry description
This commit is contained in:
@@ -1,64 +1,91 @@
|
||||
<?php
|
||||
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// Header menu
|
||||
|
||||
$config['navigation_header'] = array(
|
||||
'*' => array(
|
||||
'FH-Complete' => site_url(''),
|
||||
'Vilesci' => base_url('vilesci'),
|
||||
'CIS' => CIS_ROOT
|
||||
'fhcomplete' => array(
|
||||
'link' => site_url(''),
|
||||
'icon' => '',
|
||||
'description' => 'FH-Complete',
|
||||
'sort' => 1
|
||||
),
|
||||
'vilesci' => array(
|
||||
'link' => base_url('vilesci'),
|
||||
'icon' => '',
|
||||
'description' => 'Vilesci',
|
||||
'sort' => 2
|
||||
),
|
||||
'cis' => array(
|
||||
'link' => CIS_ROOT,
|
||||
'icon' => '',
|
||||
'description' => 'CIS',
|
||||
'sort' => 3
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// Left side menu
|
||||
|
||||
$config['navigation_menu'] = array();
|
||||
|
||||
$config['navigation_menu']['Vilesci/index'] = array(
|
||||
'Dashboard' => array(
|
||||
'dashboard' => array(
|
||||
'link' => '#',
|
||||
'description' => 'Dashboard',
|
||||
'icon' => 'dashboard'
|
||||
'icon' => 'dashboard',
|
||||
'sort' => 1
|
||||
),
|
||||
'Lehre' => array(
|
||||
'lehre' => array(
|
||||
'link' => '#',
|
||||
'icon' => 'graduation-cap',
|
||||
'description' => 'Lehre',
|
||||
'expand' => true,
|
||||
'sort' => 2,
|
||||
'children'=> array(
|
||||
'CIS' => array(
|
||||
'cis' => array(
|
||||
'link' => CIS_ROOT,
|
||||
'icon' => '',
|
||||
'description' => 'CIS',
|
||||
'expand' => true
|
||||
'expand' => true,
|
||||
'sort' => 1
|
||||
),
|
||||
'Infocenter' => array(
|
||||
'infocenter' => array(
|
||||
'link' => site_url('system/infocenter/InfoCenter'),
|
||||
'icon' => 'info',
|
||||
'description' => 'Infocenter',
|
||||
'expand' => true
|
||||
'expand' => true,
|
||||
'sort' => 2
|
||||
),
|
||||
)
|
||||
),
|
||||
'Administration' => array(
|
||||
'administration' => array(
|
||||
'link' => '#',
|
||||
'icon' => 'gear',
|
||||
'description' => 'Administration',
|
||||
'expand' => false,
|
||||
'sort' => 3,
|
||||
'children'=> array(
|
||||
'Vilesci' => array(
|
||||
'vilesci' => array(
|
||||
'link' => base_url('vilesci'),
|
||||
'icon' => '',
|
||||
'description' => 'Vilesci',
|
||||
'expand' => true
|
||||
'expand' => true,
|
||||
'sort' => 1
|
||||
),
|
||||
'Extensions' => array(
|
||||
'extensions' => array(
|
||||
'link' => site_url('system/extensions/Manager'),
|
||||
'icon' => 'cubes',
|
||||
'description' => 'Extensions Manager',
|
||||
'expand' => true
|
||||
'expand' => true,
|
||||
'sort' => 2
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
$config['navigation_menu']['system/infocenter/InfoCenter/index'] = array(
|
||||
'freigegeben' => array(
|
||||
'link' => site_url('system/infocenter/InfoCenter/freigegeben'),
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
* @license GPLv3
|
||||
* @since Version 1.0.0
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Message Helper
|
||||
*
|
||||
@@ -35,7 +35,7 @@ function success($retval, $code = null, $msg_indx_prefix = 'fhc_')
|
||||
$success->fhcCode = $code;
|
||||
if (!is_null($code)) $success->msg = lang($msg_indx_prefix . $code);
|
||||
$success->retval = $retval;
|
||||
|
||||
|
||||
return $success;
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ function error($retval = '', $code = null, $msg_indx_prefix = 'fhc_')
|
||||
$error->fhcCode = $code;
|
||||
if (!is_null($code)) $error->msg = lang($msg_indx_prefix . $code);
|
||||
$error->retval = $retval;
|
||||
|
||||
|
||||
return $error;
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ function isSuccess($result)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -78,15 +78,16 @@ function hasData($result)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the result represents an error
|
||||
* Wrapper function of isSuccess, more readable code
|
||||
* Bob Dylan: ...there's no success like failure. And that failure's no success at all.
|
||||
*/
|
||||
function isError($result)
|
||||
{
|
||||
return !isSuccess($result);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,6 +97,8 @@ class NavigationLib
|
||||
}
|
||||
}
|
||||
|
||||
$this->_sortArray($menuArray);
|
||||
|
||||
return $menuArray;
|
||||
}
|
||||
|
||||
@@ -150,6 +152,8 @@ class NavigationLib
|
||||
}
|
||||
}
|
||||
|
||||
$this->_sortArray($headerArray);
|
||||
|
||||
return $headerArray;
|
||||
}
|
||||
|
||||
@@ -158,17 +162,20 @@ class NavigationLib
|
||||
*/
|
||||
public function oneLevel(
|
||||
$description, $link = '#', $children = null, $icon = '', $expand = false,
|
||||
$subscriptDescription = null, $subscriptLinkClass = null, $subscriptLinkValue = null)
|
||||
$subscriptDescription = null, $subscriptLinkClass = null, $subscriptLinkValue = null, $target = '',
|
||||
$sort = null)
|
||||
{
|
||||
return array(
|
||||
'description' => $description,
|
||||
'link' => $link,
|
||||
'target' => $target,
|
||||
'children'=> $children,
|
||||
'icon' => $icon,
|
||||
'expand' => $expand,
|
||||
'subscriptDescription' => $subscriptDescription,
|
||||
'subscriptLinkClass' => $subscriptLinkClass,
|
||||
'subscriptLinkValue' => $subscriptLinkValue
|
||||
'subscriptLinkValue' => $subscriptLinkValue,
|
||||
'sort' => $sort
|
||||
);
|
||||
}
|
||||
|
||||
@@ -350,4 +357,34 @@ class NavigationLib
|
||||
|
||||
return $navigationPage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sorts using the sort element present in the array
|
||||
*/
|
||||
private function _sortArray(&$array)
|
||||
{
|
||||
uasort($array, function($a, $b) {
|
||||
|
||||
// If the element sort is not present then the default value is 999
|
||||
$sortA = 999;
|
||||
if (isset($a['sort'])) $sortA = $a['sort'];
|
||||
|
||||
// If the element sort is not present then the default value is 999
|
||||
$sortB = 999;
|
||||
if (isset($b['sort'])) $sortB = $b['sort'];
|
||||
|
||||
return $sortA - $sortB; // < 0 => lt, == 0 => equal, > 0 => gt
|
||||
});
|
||||
|
||||
// Sort also the children
|
||||
foreach ($array as $key => $value)
|
||||
{
|
||||
if (isset($value['children']) && is_array($value['children']) && count($value['children']) > 0)
|
||||
{
|
||||
// NOTE: keep this way to give the element by reference, $value has a different reference!
|
||||
// otherwise the children will not be sorted
|
||||
$this->_sortArray($array[$key]['children']); // recursive call
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user