Merge pull request #4410 from eileenmcnaughton/CRM-15297
[civicrm-core.git] / CRM / Core / Menu.php
index f6a80befb3d475e3be358f9721a358ad921930ab..e548e2cf658a553d37b2da51e02e3f620ea50ae4 100644 (file)
@@ -69,10 +69,14 @@ class CRM_Core_Menu {
   CONST MENU_ITEM = 1;
 
   /**
+   * This function fetches the menu items from xml and xmlMenu hooks
+   *
+   * @param boolen $fetchFromXML fetch the menu items from xml and not from cache
+   *
    * @return array
    */
-  static function &xmlItems() {
-    if (!self::$_items) {
+  static function &xmlItems($fetchFromXML = FALSE) {
+    if (!self::$_items || $fetchFromXML) {
       $config = CRM_Core_Config::singleton();
 
       // We needs this until Core becomes a component
@@ -158,11 +162,13 @@ class CRM_Core_Menu {
   /**
    * This function defines information for various menu items
    *
+   * @param boolen $fetchFromXML fetch the menu items from xml and not from cache
+   *
    * @static
    * @access public
    */
-  static function &items() {
-    return self::xmlItems();
+  static function &items($fetchFromXML = FALSE) {
+    return self::xmlItems($fetchFromXML);
   }
 
   /**
@@ -255,6 +261,7 @@ class CRM_Core_Menu {
   }
 
   /**
+   * This function recomputes menu from xml and populates civicrm_menu
    * @param bool $truncate
    */
   static function store($truncate = TRUE) {
@@ -263,7 +270,7 @@ class CRM_Core_Menu {
       $query = 'TRUNCATE civicrm_menu';
       CRM_Core_DAO::executeQuery($query);
     }
-    $menuArray = self::items();
+    $menuArray = self::items($truncate);
 
     self::build($menuArray);
 
@@ -315,7 +322,13 @@ class CRM_Core_Menu {
             ',' => '_', '/' => '_',
           )
         ),
-        'url' => CRM_Utils_System::url($path, $query, FALSE),
+        'url' => CRM_Utils_System::url($path, $query, 
+            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
+        ),
         'icon' => CRM_Utils_Array::value('icon', $item),
         'extra' => CRM_Utils_Array::value('extra', $item),
       );