当前位置: 首页>>代码示例>>PHP>>正文


PHP CRoute::_getViewItemid方法代码示例

本文整理汇总了PHP中CRoute::_getViewItemid方法的典型用法代码示例。如果您正苦于以下问题:PHP CRoute::_getViewItemid方法的具体用法?PHP CRoute::_getViewItemid怎么用?PHP CRoute::_getViewItemid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CRoute的用法示例。


在下文中一共展示了CRoute::_getViewItemid方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _

 /**
  * Wrapper to JRoute to handle itemid
  * We need to try and capture the correct itemid for different view
  */
 static function _($url, $xhtml = true, $ssl = null)
 {
     global $Itemid;
     $mainframe = JFactory::getApplication();
     $jinput = $mainframe->input;
     $cache = CFactory::getFastCache();
     $cacheid = __FILE__ . __LINE__ . serialize(func_get_args()) . $Itemid;
     if ($data = $cache->get($cacheid)) {
         $data = JRoute::_($data, $xhtml, $ssl);
         return $data;
     }
     static $itemid = array();
     parse_str(JString::str_ireplace('index.php?', '', $url));
     if (empty($view)) {
         $view = 'frontpage';
     }
     if (isset($option) && $option != 'com_community') {
         if (!$Itemid) {
             $db = JFactory::getDBO();
             $query = 'SELECT ' . $db->quoteName('id') . ' FROM ' . $db->quoteName('#__menu') . ' ' . 'WHERE ' . $db->quoteName('link') . ' LIKE ' . $db->Quote('%' . $url . '%');
             $db->setQuery($query);
             $id = $db->loadResult();
             $url .= '&Itemid=' . $id;
         }
         return JRoute::_($url, $xhtml, $ssl);
     }
     if (empty($itemid[$view])) {
         global $Itemid;
         $isValid = false;
         $currentView = $jinput->get('view', 'frontpage', 'NONE');
         //JRequest::getVar('view', 'frontpage');
         $currentOption = $jinput->get('option', '', 'STRING');
         //JRequest::getVar('option');
         // If the current Itemid match the expected Itemid based on view
         // we'll just use it
         $db = JFactory::getDBO();
         $viewId = CRoute::_getViewItemid($view);
         // if current itemid
         if ($currentOption == 'com_community' && $currentView == $view && $Itemid != 0) {
             $itemid[$view] = $Itemid;
             $isValid = true;
         } else {
             if ($viewId === $Itemid && !is_null($viewId) && $Itemid != 0) {
                 $itemid[$view] = $Itemid;
                 $isValid = true;
             } else {
                 if ($viewId !== 0 && !is_null($viewId)) {
                     $itemid[$view] = $viewId;
                     $isValid = true;
                 }
             }
         }
         if (!$isValid) {
             $id = CRoute::_getDefaultItemid();
             if ($id !== 0 && !is_null($id)) {
                 $itemid[$view] = $id;
             }
             $isValid = true;
         }
         // Search the mainmenu for the 1st itemid of jomsocial we can find, that match the current language code
         if (!$isValid) {
             $db = JFactory::getDBO();
             $query = 'SELECT ' . $db->quoteName('id') . ' FROM ' . $db->quoteName('#__menu') . ' WHERE ' . $db->quoteName('link') . ' LIKE ' . $db->Quote('%com_community%') . 'AND ' . $db->quoteName('published') . '=' . $db->Quote(1) . ' ' . 'AND ' . $db->quoteName('menutype') . '=' . $db->Quote('{CRoute::menuname}') . 'AND ' . $db->quoteName('menutype') . '!=' . $db->Quote($config->get('toolbar_menutype')) . ' ' . 'AND ' . $db->quoteName('type') . '=' . $db->Quote('component');
             $db->setQuery($query);
             $isValid = $db->loadResult();
             if (!empty($isValid)) {
                 $itemid[$view] = $isValid;
             }
         }
         // If not in mainmenu, seach in any menu
         if (!$isValid) {
             $query = 'SELECT ' . $db->quoteName('id') . ' FROM ' . $db->quoteName('#__menu') . ' WHERE ' . $db->quoteName('link') . ' LIKE ' . $db->Quote('%com_community%') . 'AND ' . $db->quoteName('published') . '=' . $db->Quote(1) . ' ' . 'AND ' . $db->quoteName('menutype') . '!=' . $db->Quote($config->get('toolbar_menutype')) . ' ' . 'AND ' . $db->quoteName('type') . '=' . $db->Quote('component');
             $db->setQuery($query);
             $isValid = $db->loadResult();
             if (!empty($isValid)) {
                 $itemid[$view] = $isValid;
             }
         }
     }
     $pos = strpos($url, '#');
     if ($pos === false) {
         if (isset($itemid[$view])) {
             if (strpos($url, 'Itemid=') === false && strpos($url, 'com_community') !== false) {
                 $url .= '&Itemid=' . $itemid[$view];
             }
         }
     } else {
         if (isset($itemid[$view])) {
             $url = str_ireplace('#', '&Itemid=' . $itemid[$view] . '#', $url);
         }
     }
     $data = JRoute::_($url, $xhtml, $ssl);
     $cache->store($url, $cacheid);
     return $data;
 }
开发者ID:joshjim27,项目名称:jobsglobal,代码行数:99,代码来源:core.php

示例2: _

 /**
  * Wrapper to JRoute to handle itemid
  * We need to try and capture the correct itemid for different view	 
  */
 static function _($url, $xhtml = true, $ssl = null)
 {
     static $itemid = array();
     parse_str($url);
     if (empty($view)) {
         $view = 'frontpage';
     }
     if (empty($itemid[$view])) {
         global $Itemid;
         $isValid = false;
         $currentView = JRequest::getVar('view', 'frontpage');
         $currentOption = JRequest::getVar('option');
         // If the current Itemid match the expected Itemid based on view
         // we'll just use it
         $db =& JFactory::getDBO();
         $viewId = CRoute::_getViewItemid($view);
         // if current itemid
         if ($currentOption == 'com_community' && $currentView == $view) {
             $itemid[$view] = $Itemid;
             $isValid = true;
         } else {
             if ($viewId === $Itemid && !is_null($viewId)) {
                 $itemid[$view] = $Itemid;
                 $isValid = true;
             } else {
                 if ($viewId !== 0 && !is_null($viewId)) {
                     $itemid[$view] = $viewId;
                     $isValid = true;
                 }
             }
         }
         if (!$isValid) {
             $id = CRoute::_getDefaultItemid();
             if ($id !== 0 && !is_null($id)) {
                 $itemid[$view] = $id;
             }
             $isValid = true;
         }
         // Search the mainmenu for the 1st itemid of jomsocial we can find
         if (!$isValid) {
             $query = "SELECT `id` FROM #__menu WHERE " . " `link` LIKE '%option=com_community%' " . " AND `published`='1' " . " AND `menutype`='{CRoute::menuname}' ";
             $db->setQuery($query);
             $isValid = $db->loadResult();
             if (!empty($isValid)) {
                 $itemid[$view] = $isValid;
             }
         }
         // If not in mainmenu, seach in any menu
         if (!$isValid) {
             $query = "SELECT `id` FROM #__menu WHERE " . " `link` LIKE '%option=com_community%' " . " AND `published`='1' ";
             $db->setQuery($query);
             $isValid = $db->loadResult();
             if (!empty($isValid)) {
                 $itemid[$view] = $isValid;
             }
         }
     }
     $pos = strpos($url, '#');
     if ($pos === false) {
         if (isset($itemid[$view])) {
             $url .= '&Itemid=' . $itemid[$view];
         }
     } else {
         if (isset($itemid[$view])) {
             $url = str_ireplace('#', '&Itemid=' . $itemid[$view] . '#', $url);
         }
     }
     return JRoute::_($url, $xhtml, $ssl);
 }
开发者ID:bizanto,项目名称:Hooked,代码行数:73,代码来源:core.php


注:本文中的CRoute::_getViewItemid方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。