mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-26 00:54:27 +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
|
<?php
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------------------------------------------------------
|
||||||
|
// Header menu
|
||||||
|
|
||||||
$config['navigation_header'] = array(
|
$config['navigation_header'] = array(
|
||||||
'*' => array(
|
'*' => array(
|
||||||
'FH-Complete' => site_url(''),
|
'fhcomplete' => array(
|
||||||
'Vilesci' => base_url('vilesci'),
|
'link' => site_url(''),
|
||||||
'CIS' => CIS_ROOT
|
'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'] = array();
|
||||||
|
|
||||||
$config['navigation_menu']['Vilesci/index'] = array(
|
$config['navigation_menu']['Vilesci/index'] = array(
|
||||||
'Dashboard' => array(
|
'dashboard' => array(
|
||||||
'link' => '#',
|
'link' => '#',
|
||||||
'description' => 'Dashboard',
|
'description' => 'Dashboard',
|
||||||
'icon' => 'dashboard'
|
'icon' => 'dashboard',
|
||||||
|
'sort' => 1
|
||||||
),
|
),
|
||||||
'Lehre' => array(
|
'lehre' => array(
|
||||||
'link' => '#',
|
'link' => '#',
|
||||||
'icon' => 'graduation-cap',
|
'icon' => 'graduation-cap',
|
||||||
'description' => 'Lehre',
|
'description' => 'Lehre',
|
||||||
'expand' => true,
|
'expand' => true,
|
||||||
|
'sort' => 2,
|
||||||
'children'=> array(
|
'children'=> array(
|
||||||
'CIS' => array(
|
'cis' => array(
|
||||||
'link' => CIS_ROOT,
|
'link' => CIS_ROOT,
|
||||||
'icon' => '',
|
'icon' => '',
|
||||||
'description' => 'CIS',
|
'description' => 'CIS',
|
||||||
'expand' => true
|
'expand' => true,
|
||||||
|
'sort' => 1
|
||||||
),
|
),
|
||||||
'Infocenter' => array(
|
'infocenter' => array(
|
||||||
'link' => site_url('system/infocenter/InfoCenter'),
|
'link' => site_url('system/infocenter/InfoCenter'),
|
||||||
'icon' => 'info',
|
'icon' => 'info',
|
||||||
'description' => 'Infocenter',
|
'description' => 'Infocenter',
|
||||||
'expand' => true
|
'expand' => true,
|
||||||
|
'sort' => 2
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
'Administration' => array(
|
'administration' => array(
|
||||||
'link' => '#',
|
'link' => '#',
|
||||||
'icon' => 'gear',
|
'icon' => 'gear',
|
||||||
'description' => 'Administration',
|
'description' => 'Administration',
|
||||||
'expand' => false,
|
'expand' => false,
|
||||||
|
'sort' => 3,
|
||||||
'children'=> array(
|
'children'=> array(
|
||||||
'Vilesci' => array(
|
'vilesci' => array(
|
||||||
'link' => base_url('vilesci'),
|
'link' => base_url('vilesci'),
|
||||||
'icon' => '',
|
'icon' => '',
|
||||||
'description' => 'Vilesci',
|
'description' => 'Vilesci',
|
||||||
'expand' => true
|
'expand' => true,
|
||||||
|
'sort' => 1
|
||||||
),
|
),
|
||||||
'Extensions' => array(
|
'extensions' => array(
|
||||||
'link' => site_url('system/extensions/Manager'),
|
'link' => site_url('system/extensions/Manager'),
|
||||||
'icon' => 'cubes',
|
'icon' => 'cubes',
|
||||||
'description' => 'Extensions Manager',
|
'description' => 'Extensions Manager',
|
||||||
'expand' => true
|
'expand' => true,
|
||||||
|
'sort' => 2
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
$config['navigation_menu']['system/infocenter/InfoCenter/index'] = array(
|
$config['navigation_menu']['system/infocenter/InfoCenter/index'] = array(
|
||||||
'freigegeben' => array(
|
'freigegeben' => array(
|
||||||
'link' => site_url('system/infocenter/InfoCenter/freigegeben'),
|
'link' => site_url('system/infocenter/InfoCenter/freigegeben'),
|
||||||
|
|||||||
@@ -85,6 +85,7 @@ function hasData($result)
|
|||||||
/**
|
/**
|
||||||
* Checks if the result represents an error
|
* Checks if the result represents an error
|
||||||
* Wrapper function of isSuccess, more readable code
|
* 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)
|
function isError($result)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -97,6 +97,8 @@ class NavigationLib
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->_sortArray($menuArray);
|
||||||
|
|
||||||
return $menuArray;
|
return $menuArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -150,6 +152,8 @@ class NavigationLib
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->_sortArray($headerArray);
|
||||||
|
|
||||||
return $headerArray;
|
return $headerArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -158,17 +162,20 @@ class NavigationLib
|
|||||||
*/
|
*/
|
||||||
public function oneLevel(
|
public function oneLevel(
|
||||||
$description, $link = '#', $children = null, $icon = '', $expand = false,
|
$description, $link = '#', $children = null, $icon = '', $expand = false,
|
||||||
$subscriptDescription = null, $subscriptLinkClass = null, $subscriptLinkValue = null)
|
$subscriptDescription = null, $subscriptLinkClass = null, $subscriptLinkValue = null, $target = '',
|
||||||
|
$sort = null)
|
||||||
{
|
{
|
||||||
return array(
|
return array(
|
||||||
'description' => $description,
|
'description' => $description,
|
||||||
'link' => $link,
|
'link' => $link,
|
||||||
|
'target' => $target,
|
||||||
'children'=> $children,
|
'children'=> $children,
|
||||||
'icon' => $icon,
|
'icon' => $icon,
|
||||||
'expand' => $expand,
|
'expand' => $expand,
|
||||||
'subscriptDescription' => $subscriptDescription,
|
'subscriptDescription' => $subscriptDescription,
|
||||||
'subscriptLinkClass' => $subscriptLinkClass,
|
'subscriptLinkClass' => $subscriptLinkClass,
|
||||||
'subscriptLinkValue' => $subscriptLinkValue
|
'subscriptLinkValue' => $subscriptLinkValue,
|
||||||
|
'sort' => $sort
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -350,4 +357,34 @@ class NavigationLib
|
|||||||
|
|
||||||
return $navigationPage;
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,3 +33,22 @@
|
|||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
text-decoration: underline;
|
text-decoration: underline;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.navbar-brand {
|
||||||
|
float: left;
|
||||||
|
height: 50px;
|
||||||
|
padding-top: 15px;
|
||||||
|
padding-right: 20px;
|
||||||
|
padding-left: 7px;
|
||||||
|
font-size: 18px;
|
||||||
|
line-height: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.navbar-brand-icon {
|
||||||
|
float: left;
|
||||||
|
height: 50px;
|
||||||
|
padding-top: 15px;
|
||||||
|
padding-right: 12px;
|
||||||
|
padding-left: 7px;
|
||||||
|
font-size: 16px;
|
||||||
|
}
|
||||||
|
|||||||
@@ -31,7 +31,20 @@ var FHC_NavigationWidget = {
|
|||||||
if (FHC_AjaxClient.hasData(data))
|
if (FHC_AjaxClient.hasData(data))
|
||||||
{
|
{
|
||||||
jQuery.each(FHC_AjaxClient.getData(data), function(i, e) {
|
jQuery.each(FHC_AjaxClient.getData(data), function(i, e) {
|
||||||
$(".menu-header-items").append('<a class="navbar-brand" href="' + e + '">' + i + '</a>');
|
|
||||||
|
var headerEntry = '';
|
||||||
|
|
||||||
|
if (e['icon'] != 'undefined' && e['icon'] != '')
|
||||||
|
{
|
||||||
|
headerEntry += '<i class="navbar-brand-icon fa fa-' + e['icon'] + ' fa-fw"></i>';
|
||||||
|
}
|
||||||
|
|
||||||
|
var target = '';
|
||||||
|
if (e['target'] != null) target = e['target'];
|
||||||
|
|
||||||
|
headerEntry += '<a class="navbar-brand" href="' + e['link'] + '" target=' + target + '>' + e['description'] + '</a>';
|
||||||
|
|
||||||
|
$(".menu-header-items").append(headerEntry);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -116,7 +129,10 @@ var FHC_NavigationWidget = {
|
|||||||
strMenu += '<span>';
|
strMenu += '<span>';
|
||||||
}
|
}
|
||||||
|
|
||||||
strMenu += '<a href="' + item['link'] + '"' + expanded + '>';
|
var target = '';
|
||||||
|
if (item['target'] != null) target = item['target'];
|
||||||
|
|
||||||
|
strMenu += '<a href="' + item['link'] + '"' + expanded + ' target="' + target + '">';
|
||||||
|
|
||||||
if (item['icon'] != 'undefined')
|
if (item['icon'] != 'undefined')
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user