Beispiel #1
0
 function _getMenuItemInfo($option, $task, $id = null, $string = null)
 {
     static $stringCache = array();
     static $idCache = array();
     static $optionCache = array();
     $db = JFactory::getDBO();
     $sefConfig = SEFConfig::getConfig();
     // JF translate extension.
     $jfTranslate = $sefConfig->translateNames ? ', `id`' : '';
     $item = new stdClass();
     $item->title = JoomSEF::_getCustomMenuTitle($option);
     // Which column to use?
     $column = 'title';
     if ($sefConfig->useAlias) {
         $column = 'alias';
     }
     // Try to load data from cache
     $row = false;
     if (isset($id) && $id != 0) {
         if (!isset($idCache[$id])) {
             $query = "SELECT `{$column}` AS `name`, `params`{$jfTranslate} FROM `#__menu` WHERE `id` = {$id} AND `published` > 0";
             $db->setQuery($query);
             $idCache[$id] = $db->loadObject();
             if (!$idCache[$id]) {
                 $idCache[$id] = false;
             }
         }
         $row = $idCache[$id];
     } elseif (isset($string)) {
         if (!isset($stringCache[$string])) {
             $query = "SELECT `{$column}`AS `name`, `params` {$jfTranslate} FROM `#__menu` WHERE `link` = '{$string}' AND `published` > 0";
             $db->setQuery($query);
             $stringCache[$string] = $db->loadObject();
             if (!$stringCache[$string]) {
                 $stringCache[$string] = false;
             }
         }
         $row = $stringCache[$string];
     } else {
         if (!isset($optionCache[$option])) {
             // Search for direct link to component only
             $query = "SELECT `{$column}` AS `name`, `params` {$jfTranslate} FROM `#__menu` WHERE `link` = 'index.php?option={$option}' AND `published` > 0";
             $db->setQuery($query);
             $optionCache[$option] = $db->loadObject();
             if (!$optionCache[$option]) {
                 // Try to extend the search for any link to component
                 $query = "SELECT `{$column}` AS `name`, `params` {$jfTranslate} FROM `#__menu` WHERE `link` LIKE 'index.php?option={$option}%' AND `published` > 0";
                 $db->setQuery($query);
                 $optionCache[$option] = $db->loadObject();
                 if (!$optionCache[$option]) {
                     $optionCache[$option] = false;
                 }
             }
         }
         $row = $optionCache[$option];
     }
     if (!empty($row)) {
         if (!empty($row->name) && !$item->title) {
             $item->title = $row->name;
         }
         $item->params = new JRegistry($row->params);
     } else {
         $item->title = str_replace('com_', '', $option);
     }
     return $item;
 }
 function _getMenuItemInfo($option, $task, $id = null, $string = null)
 {
     $db =& JFactory::getDBO();
     $sefConfig =& SEFConfig::getConfig();
     // JF translate extension.
     $jfTranslate = $sefConfig->translateNames ? ', `id`' : '';
     $item->title = JoomSEF::_getCustomMenuTitle($option);
     // Which column to use?
     $column = 'name';
     if ($sefConfig->useAlias) {
         $column = 'alias';
     }
     // first test Itemid
     if (isset($id) && $id != 0) {
         $sql = "SELECT `{$column}` AS `name`, `params`{$jfTranslate} FROM `#__menu` WHERE `id` = '" . intval($id) . "' AND `published` > 0";
     } elseif (isset($string)) {
         $sql = "SELECT `{$column}`AS `name`, `params` {$jfTranslate} FROM `#__menu` WHERE `link` = " . $db->Quote($string) . " AND `published` > 0";
     } else {
         // Search for direct link to component only
         $sql = "SELECT `{$column}` AS `name`, `params` {$jfTranslate} FROM `#__menu` WHERE `link` = " . $db->Quote('index.php?option=' . $option) . " AND `published` > 0";
     }
     $db->setQuery($sql);
     $row = $db->loadObject();
     if (!empty($row)) {
         if (!empty($row->name) && !$item->title) {
             $item->title = $row->name;
         }
         $item->params = new JParameter($row->params);
     } else {
         $item->title = str_replace('com_', '', $option);
         if (!isset($string) && !isset($id)) {
             // Try to extend the search for any link to component
             $sql = "SELECT `{$column}` AS `name`, `params`{$jfTranslate} FROM `#__menu` WHERE `link` LIKE " . $db->Quote('index.php?option=' . $option . '%') . " AND `published` > 0";
             $db->setQuery($sql);
             $row = $db->loadObject();
             if (!empty($row)) {
                 if (!empty($row->name) && !$item->title) {
                     $item->title = $row->name;
                 }
                 $item->params = new JParameter($row->params);
             }
         }
     }
     return $item;
 }