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


PHP K2HelperRoute::model方法代码示例

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


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

示例1: _findItem

 public static function _findItem($needles)
 {
     $component = JComponentHelper::getComponent('com_k2');
     $application = JFactory::getApplication();
     $menus = $application->getMenu('site', array());
     if (K2_JVERSION != '15') {
         $items = $menus->getItems('component_id', $component->id);
     } else {
         $items = $menus->getItems('componentid', $component->id);
     }
     $match = null;
     foreach ($needles as $needle => $id) {
         if (count($items)) {
             foreach ($items as $item) {
                 // Detect multiple K2 categories link and set the generic K2 link ( if any )
                 if (@$item->query['view'] == 'itemlist' && @$item->query['task'] == '') {
                     if (!isset(self::$multipleCategoriesMapping[$item->id])) {
                         if (K2_JVERSION == '15') {
                             $menuparams = explode("\n", $item->params);
                             foreach ($menuparams as $param) {
                                 if (strpos($param, 'categories=') === 0) {
                                     $array = explode('categories=', $param);
                                     $item->K2Categories = explode('|', $array[1]);
                                 }
                             }
                             if (!isset($item->K2Categories)) {
                                 $item->K2Categories = array();
                             }
                         } else {
                             $menuparams = json_decode($item->params);
                             $item->K2Categories = isset($menuparams->categories) ? $menuparams->categories : array();
                         }
                         self::$multipleCategoriesMapping[$item->id] = $item->K2Categories;
                         if (count($item->K2Categories) === 0) {
                             self::$anyK2Link = $item;
                         }
                     }
                 }
                 if ($needle == 'user' || $needle == 'category') {
                     if (@$item->query['task'] == $needle && @$item->query['id'] == $id) {
                         $match = $item;
                         break;
                     }
                 } else {
                     if ($needle == 'tag') {
                         if (@$item->query['task'] == $needle && @$item->query['tag'] == $id) {
                             $match = $item;
                             break;
                         }
                     } else {
                         if (@$item->query['view'] == $needle && @$item->query['id'] == $id) {
                             $match = $item;
                             break;
                         }
                     }
                 }
                 if (!is_null($match)) {
                     break;
                 }
             }
             // Second pass [START]
             // Only for multiple categories links. Triggered only if we do not have find any match (link to direct category)
             if (is_null($match) && $needle == 'category') {
                 foreach ($items as $item) {
                     if (@$item->query['view'] == 'itemlist' && @$item->query['task'] == '') {
                         if (isset(self::$multipleCategoriesMapping[$item->id]) && is_array(self::$multipleCategoriesMapping[$item->id])) {
                             foreach (self::$multipleCategoriesMapping[$item->id] as $catid) {
                                 if ((int) $catid == $id) {
                                     $match = $item;
                                     break;
                                 }
                             }
                         }
                         if (!is_null($match)) {
                             break;
                         }
                     }
                 }
             }
             // Second pass [END]
         }
         if (!is_null($match)) {
             break;
         }
     }
     if (is_null($match)) {
         // Try to detect any parent category menu item....
         if ($needle == 'category') {
             if (is_null(self::$tree)) {
                 K2Model::addIncludePath(JPATH_SITE . '/components/com_k2/models');
                 $model = K2Model::getInstance('Itemlist', 'K2Model');
                 self::$model = $model;
                 self::$tree = $model->getCategoriesTree();
             }
             $parents = self::$model->getTreePath(self::$tree, $id);
             if (is_array($parents)) {
                 foreach ($parents as $categoryID) {
                     if ($categoryID != $id) {
                         $match = K2HelperRoute::_findItem(array('category' => $categoryID));
                         if (!is_null($match)) {
//.........这里部分代码省略.........
开发者ID:emavro,项目名称:k2,代码行数:101,代码来源:route.php


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