X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FCore%2FMenu.php;h=c6fefdc91a5951343e3edf09bacfff9781cbea00;hb=543523bfa9cae59aa15d31583dbc405417dbf83b;hp=8ceccdd854eb13d9a1bcbfd9449584479e2a7d70;hpb=24704c73fe5f5ee2ca19a9fc98101841ee7c854a;p=civicrm-core.git diff --git a/CRM/Core/Menu.php b/CRM/Core/Menu.php index 8ceccdd854..c6fefdc91a 100644 --- a/CRM/Core/Menu.php +++ b/CRM/Core/Menu.php @@ -44,16 +44,16 @@ class CRM_Core_Menu { * * @var array */ - static $_items = NULL; + public static $_items = NULL; /** * The list of permissioned menu items. * * @var array */ - static $_permissionedItems = NULL; + public static $_permissionedItems = NULL; - static $_serializedElements = array( + public static $_serializedElements = array( 'access_arguments', 'access_callback', 'page_arguments', @@ -61,7 +61,7 @@ class CRM_Core_Menu { 'breadcrumb', ); - static $_menuCache = NULL; + public static $_menuCache = NULL; const MENU_ITEM = 1; /** @@ -367,13 +367,12 @@ class CRM_Core_Menu { 'title' => $item['title'], 'desc' => CRM_Utils_Array::value('desc', $item), 'id' => strtr($item['title'], array( - '(' => '_', - ')' => '', - ' ' => '', - ',' => '_', - '/' => '_', - ) - ), + '(' => '_', + ')' => '', + ' ' => '', + ',' => '_', + '/' => '_', + )), 'url' => CRM_Utils_System::url($path, $query, FALSE, NULL, @@ -402,120 +401,6 @@ class CRM_Core_Menu { $menu['admin'] = array('breadcrumb' => $values); } - /** - * Get navigation. - * - * @param bool $all - * - * @return mixed - * @throws Exception - */ - public static function &getNavigation($all = FALSE) { - CRM_Core_Error::fatal(); - - if (!self::$_menuCache) { - self::get('navigation'); - } - - if (CRM_Core_Config::isUpgradeMode()) { - return array(); - } - - if (!array_key_exists('navigation', self::$_menuCache)) { - // problem could be due to menu table empty. Just do a - // menu store and try again - self::store(); - - // here we goo - self::get('navigation'); - if (!array_key_exists('navigation', self::$_menuCache)) { - CRM_Core_Error::fatal(); - } - } - $nav = &self::$_menuCache['navigation']; - - if (!$nav || - !isset($nav['breadcrumb']) - ) { - return NULL; - } - - $values = &$nav['breadcrumb']; - $config = CRM_Core_Config::singleton(); - foreach ($values as $index => $item) { - if (strpos(CRM_Utils_Array::value($config->userFrameworkURLVar, $_REQUEST), - $item['path'] - ) === 0 - ) { - $values[$index]['active'] = 'class="active"'; - } - else { - $values[$index]['active'] = ''; - } - - if ($values[$index]['parent']) { - $parent = $values[$index]['parent']; - - // only reset if still a leaf - if ($values[$parent]['class'] == 'leaf') { - $values[$parent]['class'] = 'collapsed'; - } - - // if a child or the parent is active, expand the menu - if ($values[$index]['active'] || - $values[$parent]['active'] - ) { - $values[$parent]['class'] = 'expanded'; - } - - // make the parent inactive if the child is active - if ($values[$index]['active'] && - $values[$parent]['active'] - ) { - $values[$parent]['active'] = ''; - } - } - } - - if (!$all) { - // remove all collapsed menu items from the array - foreach ($values as $weight => $v) { - if ($v['parent'] && - $values[$v['parent']]['class'] == 'collapsed' - ) { - unset($values[$weight]); - } - } - } - - // check permissions for the rest - $activeChildren = array(); - - foreach ($values as $weight => $v) { - if (CRM_Core_Permission::checkMenuItem($v)) { - if ($v['parent']) { - $activeChildren[] = $weight; - } - } - else { - unset($values[$weight]); - } - } - - // add the start / end tags - $len = count($activeChildren) - 1; - if ($len >= 0) { - $values[$activeChildren[0]]['start'] = TRUE; - $values[$activeChildren[$len]]['end'] = TRUE; - } - - ksort($values, SORT_NUMERIC); - $i18n = CRM_Core_I18n::singleton(); - $i18n->localizeTitles($values); - - return $values; - } - /** * Get admin links. * @@ -570,11 +455,16 @@ class CRM_Core_Menu { 'title' => $menu[$currentPath]['title'], 'url' => CRM_Utils_System::url($currentPath, 'reset=1' . $urlVar, - FALSE, // absolute - NULL, // fragment - TRUE, // htmlize - FALSE, // frontend - TRUE // forceBackend; CRM-14439 work-around; acceptable for now because we don't display breadcrumbs on frontend + // absolute + FALSE, + // fragment + NULL, + // htmlize + TRUE, + // frontend + FALSE, + // forceBackend; CRM-14439 work-around; acceptable for now because we don't display breadcrumbs on frontend + TRUE ), ); }