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


PHP K2HelperRoute::getCategoryRoute方法代码示例

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


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

示例1: _prepareItem

 /**
  * Prepare item properties
  */
 protected function _prepareItem($item)
 {
     $item->link = JRoute::_(K2HelperRoute::getItemRoute($item->id, $item->catid));
     $item->introtext = JHtml::_('string.truncate', $item->introtext, $this->_params->get('intro_length', 200));
     $item->cat_link = urldecode(JRoute::_(K2HelperRoute::getCategoryRoute($item->catid . ':' . urlencode($item->catslug))));
     return $item;
 }
开发者ID:jooservices,项目名称:zt-news,代码行数:10,代码来源:k2.php

示例2: getAssociations

 public static function getAssociations($id = 0, $view = null)
 {
     jimport('helper.route', JPATH_COMPONENT_SITE);
     $application = JFactory::getApplication();
     $view = is_null($view) ? $application->input->get('view') : $view;
     $task = $application->input->get('task');
     $id = empty($id) ? $application->input->getInt('id') : $id;
     if ($view == 'item') {
         if ($id) {
             $associations = self::getItemAssociations($id);
             $return = array();
             foreach ($associations as $tag => $item) {
                 $return[$tag] = K2HelperRoute::getItemRoute($item->id, $item->catid, $item->language);
             }
             return $return;
         }
     } else {
         if ($view == 'itemlist' && $task == 'category') {
             if ($id) {
                 $associations = self::getCategoryAssociations($id);
                 $return = array();
                 foreach ($associations as $tag => $category) {
                     $return[$tag] = K2HelperRoute::getCategoryRoute($category->id, $category->language);
                 }
                 return $return;
             }
         }
     }
     return array();
 }
开发者ID:Naldo100,项目名称:k2-v3-dev-build,代码行数:30,代码来源:association.php

示例3: getItems

 /** I HAVE NOT MODIFIED BELOW THIS LINE **/
 function getItems($args)
 {
     global $mainframe;
     $advlink =& AdvLink::getInstance();
     require_once JPATH_SITE . DS . 'components' . DS . 'com_k2' . DS . 'helpers' . DS . 'route.php';
     $items = array();
     $view = isset($args->view) ? $args->view : '';
     switch ($view) {
         default:
             $categories = AdvlinkK2::_getK2Categories();
             foreach ($categories as $category) {
                 $items[] = array('id' => K2HelperRoute::getCategoryRoute($category->id), 'name' => $category->name, 'class' => 'folder content');
             }
             break;
         case 'itemlist':
             $categories = AdvlinkK2::_getK2Categories($args->id);
             $itemlist = AdvlinkK2::_getK2Items($args->id);
             foreach ($categories as $category) {
                 $items[] = array('id' => K2HelperRoute::getCategoryRoute($category->id), 'name' => $category->name, 'class' => 'folder content');
             }
             foreach ($itemlist as $item) {
                 $items[] = array('id' => K2HelperRoute::getItemRoute($item->id, $args->id), 'name' => $item->title, 'class' => 'file');
             }
             break;
         case 'item':
             break;
     }
     return $items;
 }
开发者ID:rlee1962,项目名称:diylegalcenter,代码行数:30,代码来源:k2.php

示例4: getChildCategories

 public function getChildCategories($catId, $titleMax)
 {
     $categories = array();
     $query = "\n\t\t\t\tSELECT c.id, c.name as title, c.alias\n\t\t\t\tFROM #__k2_categories c\n\t\t\t\tWHERE\n\t\t\t\t\tc.published = 1\n\t\t\t\t\tAND c.parent = {$catId}\n\t\t\t";
     $this->db->setQuery($query);
     $rows = $this->db->loadObjectList();
     foreach ($rows as $category) {
         $categories[$category->id] = $category;
         // // category url
         // $slug = $category->alias ? $category->id.':'.$category->alias : $category->id;
         // $category->url = JRoute::_( ContentHelperRoute::getCategoryRoute($slug) );
         $category->url = urldecode(JRoute::_(K2HelperRoute::getCategoryRoute($category->id . ':' . urlencode($category->alias))));
         // category title truncate
         $category->title = YtUtils::shorten($category->title, $titleMax);
     }
     return $categories;
 }
开发者ID:proyectoseb,项目名称:University,代码行数:17,代码来源:sjk2categoriesiij17newsreader.php

示例5: getList

 public static function getList(&$params)
 {
     $list = array();
     $categories = array();
     if ($params->get('catfilter')) {
         $category_ids = $params->get('category_id');
     } else {
         $category_ids = self::getAllCategories();
     }
     if (!empty($category_ids)) {
         foreach ($category_ids as $cat_ids) {
             $category = self::getCategory($cat_ids);
             $categories[$cat_ids] = $category;
         }
         foreach ($categories as $keys => $cat) {
             if (!empty($cat)) {
                 $temp_cat = array();
                 $slug = $cat->alias ? $cat->id . ':' . $cat->alias : $cat->id;
                 $cat->url = JRoute::_(K2HelperRoute::getCategoryRoute($slug));
                 $temp_cat['id'] = $cat->id;
                 $temp_cat['title'] = $cat->name;
                 $temp_cat['url'] = $cat->url;
                 $child_category = array();
                 foreach ($cat->child_category as $key_cat => $cat_child) {
                     $temp_child = array();
                     $slug = $cat_child->alias ? $cat_child->id . ':' . $cat_child->alias : $cat_child->id;
                     $cat_child->url = JRoute::_(K2HelperRoute::getCategoryRoute($slug));
                     $temp_child['id'] = $cat_child->id;
                     $temp_child['title'] = $cat_child->name;
                     $temp_child['url'] = $cat_child->url;
                     $items = array();
                     $cat_child->child = self::getK2Items($cat_child->id, $params);
                     if (isset($cat_child->child) && !empty($cat_child->child)) {
                         $temp_child['child'] = $cat_child->child;
                         $child_category[$key_cat] = $temp_child;
                     }
                 }
                 if (!empty($child_category)) {
                     $temp_cat['child_category'] = $child_category;
                     $list[$keys] = $temp_cat;
                 }
             }
         }
     }
     return $list;
 }
开发者ID:educakanchay,项目名称:educared,代码行数:46,代码来源:helper.php

示例6: go

 public function go($allGet)
 {
     $uri = JUri::getInstance();
     $currentLink = $uri->toString(array('path', 'query'));
     $start = JFactory::getApplication()->input->getInt('start', 0);
     JTable::addIncludePath(JPATH_ROOT . '/administrator/components/com_k2/tables');
     $limitstring = '';
     if ($start > 0) {
         $limits = $this->params->get('limits', 5);
         if ($start % $limits != 0) {
             $start = intval($start / $limits) * $limits;
         }
         $limitstring .= "?start=" . $start;
     }
     if ($allGet['view'] == 'item' && $allGet['task'] == '') {
         $item = JTable::getInstance('K2Item', 'Table');
         $item->load($allGet['id']);
         $category = JTable::getInstance('K2Category', 'Table');
         $category->load($item->catid);
         $original_link = JRoute::_(K2HelperRoute::getItemRoute($item->id . ':' . urlencode($item->alias), $item->catid . ':' . urlencode($category->alias)), false);
     } else {
         if ($allGet['view'] == 'itemlist' && $allGet['task'] == 'category') {
             $category = JTable::getInstance('K2Category', 'Table');
             $category->load((int) $allGet['id']);
             $original_link = JRoute::_(K2HelperRoute::getCategoryRoute((int) $allGet['id'] . ':' . urlencode($category->alias)), false) . $limitstring;
         } else {
             if ($allGet['view'] == 'itemlist' && $allGet['task'] == 'user') {
                 $original_link = JRoute::_(K2HelperRoute::getUserRoute((int) $allGet['id']), false) . $limitstring;
             } else {
                 return false;
             }
         }
     }
     if ($original_link && $original_link != $currentLink) {
         $this->shRedirect($original_link);
     }
     return true;
 }
开发者ID:pupsikus,项目名称:sto-city.test,代码行数:38,代码来源:com_k2.php

示例7: categoryLink

 static function categoryLink($item)
 {
     return urldecode(JRoute::_(K2HelperRoute::getCategoryRoute($item['cid'] . ':' . urlencode($item['cat_alias']))));
 }
开发者ID:Roma48,项目名称:abazherka_old,代码行数:4,代码来源:view.php

示例8: getList


//.........这里部分代码省略.........
                     }
                     break;
                     // EasyDiscuss profile integration - http://stackideas.com
                 // EasyDiscuss profile integration - http://stackideas.com
                 case 'easydiscuss':
                     if (JFile::exists(JPATH_SITE . '/components/com_easydiscuss/easydiscuss.php')) {
                         require_once JPATH_SITE . '/components/com_easydiscuss/helpers/router.php';
                         $profile_link = DiscussHelper::getTable('Profile')->load($item->user_id)->getLink();
                     } else {
                         echo JText::_('MOD_GIANTCONTENT_ERROR_PROFILE_SYSTEM_EASYDISCUSS');
                         return;
                     }
                     break;
             }
         }
         // Show content intro
         if ($show_intro) {
             // Clean HTML tags
             if ($clean_intro) {
                 $item->introtext = strip_tags($item->introtext, $allowed_tags);
                 $item->introtext = str_replace(' ', ' ', $item->introtext);
                 $item->introtext = preg_replace('/\\s{2,}/u', ' ', trim($item->introtext));
             }
             $lists[$i]->intro = $limit_intro ? self::truncateText($item->introtext, $limit_intro) : $item->introtext;
         }
         // Show content title
         if ($show_title) {
             $lists[$i]->title_name = $item->title;
             $lists[$i]->title = $title_link ? '<a href="' . $lists[$i]->link . '">' . $lists[$i]->title_name . '</a>' : $lists[$i]->title_name;
         }
         // Show content category
         if ($show_category) {
             $lists[$i]->category_name = $item->category_name;
             $lists[$i]->category_link = JRoute::_(K2HelperRoute::getCategoryRoute($item->category_id . ':' . $item->category_alias));
             $lists[$i]->category = $category_link ? '<a href="' . $lists[$i]->category_link . '">' . $lists[$i]->category_name . '</a>' : $lists[$i]->category_name;
         }
         // Show content comments
         if ($show_comments) {
             $lists[$i]->comments_count = $item->comments_count;
             $lists[$i]->comments_link = $lists[$i]->link . $comments_link;
             $lists[$i]->comments = '<a href="' . $lists[$i]->comments_link . '">' . $item->comments_count . '</a>';
         }
         // Show content author
         if ($show_author) {
             $lists[$i]->author_name = $item->user_alias ? $item->user_alias : $item->user_name;
             $lists[$i]->author = $show_profile ? '<a href="' . $profile_link . '">' . $lists[$i]->author_name . '</a>' : $lists[$i]->author_name;
         }
         // Show profile avatar
         if ($show_avatar) {
             $avatar_src = 'modules/mod_giantcontent/assets/libraries/includes/timthumb.php?src=' . JURI::base(true) . '/';
             $avatar_attr = '&amp;w=' . $avatar_width . '&amp;h=' . $avatar_height;
             $avatar_default = '<img src="' . $avatar_src . '/modules/mod_giantcontent/assets/images/avatar.png' . $avatar_attr . '"  alt="' . $item->user_name . '" />';
             $lists[$i]->avatar_user = $item->avatar_user;
             if ($avatar_system == 'easysocial') {
                 $avatar_img = $avatar_path . $item->user_id . '/' . $item->avatar_user;
             } else {
                 $avatar_img = $avatar_path . $item->avatar_user;
             }
             if (JFile::exists($avatar_img)) {
                 $lists[$i]->avatar = '<img src="' . $avatar_src . $avatar_img . $avatar_attr . '" alt="' . $item->user_name . '" />';
                 $lists[$i]->avatar = $show_profile ? '<a href="' . $profile_link . '">' . $lists[$i]->avatar . '</a>' : $lists[$i]->avatar;
             } else {
                 $lists[$i]->avatar = $show_profile ? '<a href="' . $profile_link . '">' . $avatar_default . '</a>' : $avatar_default;
             }
         }
         // Show content rating
开发者ID:emeraldstudio,项目名称:somosmaestros,代码行数:67,代码来源:k2.php

示例9: display

 function display($tpl = null)
 {
     $mainframe =& JFactory::getApplication();
     $params =& JComponentHelper::getParams('com_k2');
     $document =& JFactory::getDocument();
     $model =& $this->getModel('itemlist');
     $limitstart = JRequest::getInt('limitstart');
     $moduleID = JRequest::getInt('moduleID');
     if ($moduleID) {
         $result = $model->getModuleItems($moduleID);
         $items = $result->items;
         $title = $result->title;
     } else {
         //Get data depending on task
         $task = JRequest::getCmd('task');
         switch ($task) {
             case 'category':
                 //Get category
                 $id = JRequest::getInt('id');
                 JTable::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR . DS . 'tables');
                 $category =& JTable::getInstance('K2Category', 'Table');
                 $category->load($id);
                 //Access check
                 $user =& JFactory::getUser();
                 if ($category->access > $user->get('aid', 0)) {
                     JError::raiseError(403, JText::_("ALERTNOTAUTH"));
                 }
                 if (!$category->published || $category->trash) {
                     JError::raiseError(404, JText::_("Category not found"));
                 }
                 //Merge params
                 $cparams = new JParameter($category->params);
                 if ($cparams->get('inheritFrom')) {
                     $masterCategory =& JTable::getInstance('K2Category', 'Table');
                     $masterCategory->load($cparams->get('inheritFrom'));
                     $cparams = new JParameter($masterCategory->params);
                 }
                 $params->merge($cparams);
                 //Category link
                 $category->link = urldecode(JRoute::_(K2HelperRoute::getCategoryRoute($category->id . ':' . urlencode($category->alias))));
                 //Set featured flag
                 JRequest::setVar('featured', $params->get('catFeaturedItems'));
                 //Set title
                 $title = $category->name;
                 break;
             case 'user':
                 //Get user
                 $id = JRequest::getInt('id');
                 $user =& JFactory::getUser($id);
                 //Check user status
                 if ($user->block) {
                     JError::raiseError(404, JText::_('User not found'));
                 }
                 //Set title
                 $title = $user->name;
                 break;
             case 'tag':
                 //set title
                 $title = JText::_('Displaying items by tag:') . ' ' . JRequest::getVar('tag');
                 if (JRequest::getCmd('type') != 'atom') {
                     $title = JFilterOutput::ampReplace($title);
                 }
                 break;
             case 'search':
                 //Set title
                 $title = JText::_('Search results for:') . ' ' . JRequest::getVar('searchword');
                 break;
             case 'date':
                 //Set title
                 if (JRequest::getInt('day')) {
                     $date = strtotime(JRequest::getInt('year') . '-' . JRequest::getInt('month') . '-' . JRequest::getInt('day'));
                     $title = JText::_('Items filtered by date:') . ' ' . JHTML::_('date', $date, '%A, %d %B %Y');
                 } else {
                     $date = strtotime(JRequest::getInt('year') . '-' . JRequest::getInt('month'));
                     $title = JText::_('Items filtered by date:') . ' ' . JHTML::_('date', $date, '%B %Y');
                 }
                 break;
             default:
                 //Set featured flag
                 JRequest::setVar('featured', $params->get('catFeaturedItems'));
                 //Set title
                 $title = $params->get('page_title');
                 break;
         }
         //Get ordering
         if ($task == 'tag') {
             $ordering = $params->get('tagOrdering');
         } else {
             $ordering = $params->get('catOrdering');
         }
         //Get items
         $items = $model->getData($ordering);
     }
     //Prepare feed items
     $model =& $this->getModel('item');
     foreach ($items as $item) {
         $item = $model->prepareFeedItem($item);
         $item->title = $this->escape($item->title);
         $item->title = html_entity_decode($item->title);
         $feedItem = new JFeedItem();
//.........这里部分代码省略.........
开发者ID:rlee1962,项目名称:diylegalcenter,代码行数:101,代码来源:view.feed.php

示例10: getLatestComments

 function getLatestComments(&$params)
 {
     $limit = $params->get('comments_limit', '5');
     $user =& JFactory::getUser();
     $aid = $user->get('aid');
     $db =& JFactory::getDBO();
     $cid = $params->get('category_id', NULL);
     $jnow =& JFactory::getDate();
     $now = $jnow->toMySQL();
     $nullDate = $db->getNullDate();
     require_once JPATH_SITE . DS . 'components' . DS . 'com_k2' . DS . 'models' . DS . 'item.php';
     $model = new K2ModelItem();
     $componentParams =& JComponentHelper::getParams('com_k2');
     $query = "SELECT c.*, i.catid, i.title, i.alias, category.alias as catalias, category.name as categoryname  FROM #__k2_comments as c" . " LEFT JOIN #__k2_items as i ON i.id=c.itemID" . " LEFT JOIN #__k2_categories as category ON category.id=i.catid" . " WHERE i.published=1 " . " AND ( i.publish_up = " . $db->Quote($nullDate) . " OR i.publish_up <= " . $db->Quote($now) . " ) " . " AND ( i.publish_down = " . $db->Quote($nullDate) . " OR i.publish_down >= " . $db->Quote($now) . " )" . " AND i.trash=0 AND i.access<={$aid}" . " AND category.published=1 AND category.trash=0 AND category.access<={$aid}" . " AND c.published=1 ";
     if ($params->get('catfilter')) {
         if (!is_null($cid)) {
             if (is_array($cid)) {
                 JArrayHelper::toInteger($cid);
                 $query .= " AND i.catid IN(" . implode(',', $cid) . ")";
             } else {
                 $query .= " AND i.catid=" . (int) $cid;
             }
         }
     }
     $query .= " ORDER BY c.commentDate DESC ";
     $db->setQuery($query, 0, $limit);
     $rows = $db->loadObjectList();
     $pattern = "@\\b(https?://)?(([0-9a-zA-Z_!~*'().&=+\$%-]+:)?[0-9a-zA-Z_!~*'().&=+\$%-]+\\@)?(([0-9]{1,3}\\.){3}[0-9]{1,3}|([0-9a-zA-Z_!~*'()-]+\\.)*([0-9a-zA-Z][0-9a-zA-Z-]{0,61})?[0-9a-zA-Z]\\.[a-zA-Z]{2,6})(:[0-9]{1,4})?((/[0-9a-zA-Z_!~*'().;?:\\@&=+\$,%#-]+)*/?)@";
     if (count($rows)) {
         foreach ($rows as $row) {
             if ($params->get('commentDateFormat') == 'relative') {
                 $config =& JFactory::getConfig();
                 $tzoffset = $config->getValue('config.offset');
                 $now = new JDate();
                 $now->setOffset($tzoffset);
                 $created = new JDate($row->commentDate);
                 $diff = $now->toUnix() - $created->toUnix();
                 $dayDiff = floor($diff / 86400);
                 if ($dayDiff == 0) {
                     if ($diff < 5) {
                         $row->commentDate = JText::_('Just Now');
                     } elseif ($diff < 60) {
                         $row->commentDate = $diff . ' ' . JText::_('Seconds ago');
                     } elseif ($diff < 120) {
                         $row->commentDate = JText::_('1 Minute Ago');
                     } elseif ($diff < 3600) {
                         $row->commentDate = floor($diff / 60) . ' ' . JText::_('Minutes Ago');
                     } elseif ($diff < 7200) {
                         $row->commentDate = JText::_('1 Hour Ago');
                     } elseif ($diff < 86400) {
                         $row->commentDate = floor($diff / 3600) . ' ' . JText::_('Hours Ago');
                     }
                 }
             }
             $row->commentText = K2HelperUtilities::wordLimit($row->commentText, $params->get('comments_word_limit'));
             $row->commentText = preg_replace($pattern, '<a target="_blank" rel="nofollow" href="\\0">\\0</a>', $row->commentText);
             $row->itemLink = urldecode(JRoute::_(K2HelperRoute::getItemRoute($row->itemID . ':' . urlencode($row->alias), $row->catid . ':' . urlencode($row->catalias))));
             $row->link = $row->itemLink . "#comment{$row->id}";
             $row->catLink = urldecode(JRoute::_(K2HelperRoute::getCategoryRoute($row->catid . ':' . urlencode($row->catalias))));
             if ($row->userID > 0) {
                 $row->userLink = JRoute::_(K2HelperRoute::getUserRoute($row->userID));
             }
             $row->userImage = '';
             if ($params->get('commentAvatar')) {
                 $row->userImage = K2HelperUtilities::getAvatar($row->userID, $row->commentEmail, $componentParams->get('commenterImgWidth'));
             }
             $comments[] = $row;
         }
         return $comments;
     }
 }
开发者ID:rlee1962,项目名称:diylegalcenter,代码行数:71,代码来源:helper.php

示例11: getCategoryPath

 public static function getCategoryPath($catid, &$array = array())
 {
     if (isset(self::$paths[$catid])) {
         return self::$paths[$catid];
     }
     $mainframe = JFactory::getApplication();
     $user = JFactory::getUser();
     $aid = (int) $user->get('aid');
     $catid = (int) $catid;
     $db = JFactory::getDBO();
     $query = "SELECT * FROM #__k2_categories WHERE id={$catid} AND published=1 AND trash=0 ";
     if (K2_JVERSION != '15') {
         $query .= " AND access IN(" . implode(',', $user->getAuthorisedViewLevels()) . ") ";
         if ($mainframe->getLanguageFilter()) {
             $languageTag = JFactory::getLanguage()->getTag();
             $query .= " AND language IN (" . $db->Quote($languageTag) . ", " . $db->Quote('*') . ") ";
         }
     } else {
         $query .= " AND access <= {$aid}";
     }
     $db->setQuery($query);
     $rows = $db->loadObjectList();
     if ($db->getErrorNum()) {
         echo $db->stderr();
         return false;
     }
     foreach ($rows as $row) {
         array_push($array, '<a href="' . urldecode(JRoute::_(K2HelperRoute::getCategoryRoute($row->id . ':' . urlencode($row->alias)))) . '">' . $row->name . '</a>');
         modK2ToolsHelper::getCategoryPath($row->parent, $array);
     }
     $return = array_reverse($array);
     self::$paths[$catid] = $return;
     return $return;
 }
开发者ID:educakanchay,项目名称:educared,代码行数:34,代码来源:helper.php

示例12: __getList

 /**
  * get the list of k2 items
  * 
  * @param JParameter $params;
  * @return Array
  */
 public function __getList($params)
 {
     global $mainframe;
     $maxTitle = $params->get('max_title', '100');
     $maxDesciption = $params->get('max_description', 100);
     $openTarget = $params->get('open_target', 'parent');
     $formatter = $params->get('style_displaying', 'title');
     $titleMaxChars = $params->get('title_max_chars', '100');
     $descriptionMaxChars = $params->get('description_max_chars', 100);
     $condition = $this->buildConditionQuery($params);
     $ordering = $params->get('k2_ordering', 'created_asc');
     $limit = $params->get('limit_items', 5);
     $ordering = str_replace('_', '  ', $ordering);
     $my =& JFactory::getUser();
     $aid = $my->get('aid', 0);
     $limitDescriptionBy = $params->get('limit_description_by', 'char');
     $thumbWidth = (int) $params->get('thumbnail_width', 35);
     $thumbHeight = (int) $params->get('thumbnail_height', 60);
     $imageHeight = (int) $params->get('main_height', 300);
     $imageWidth = (int) $params->get('main_width', 660);
     $isThumb = $params->get('auto_renderthumb', 1);
     $isStripedTags = $params->get('auto_strip_tags', 1);
     $extraURL = $params->get('open_target') != 'modalbox' ? '' : '&tmpl=component';
     $db =& JFactory::getDBO();
     $date =& JFactory::getDate();
     $now = $date->toMySQL();
     require_once JPath::clean(JPATH_SITE . '/components/com_k2/helpers/route.php');
     $query = "SELECT a.*, cr.rating_sum/cr.rating_count as rating, c.name as category_title,\n\t\t\t\t\t\t\tc.id as categoryid, c.alias as categoryalias, c.params as categoryparams, cc.commentcount as commentcount" . " FROM #__k2_items as a" . " LEFT JOIN #__k2_categories c ON c.id = a.catid" . " LEFT JOIN #__k2_rating as cr ON a.id = cr.itemid" . " LEFT JOIN (select cm.itemid  as id, count(cm.id) as commentcount from #__k2_comments as cm\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\twhere cm.published=1 group by cm.itemid) as cc on a.id = cc.id";
     $query .= " WHERE a.published = 1" . " AND a.access IN (" . implode(',', $my->authorisedLevels()) . ")" . " AND a.trash = 0";
     if ($params->get('featured_items_show', '0') == 0) {
         $query .= " AND a.featured != 1";
     } elseif ($params->get('featured_items_show', '0') == 2) {
         $query .= " AND a.featured = 1";
     }
     $query .= $condition . ' ORDER BY ' . $ordering;
     $query .= $limit ? ' LIMIT ' . $limit : '';
     $db->setQuery($query);
     $data = $db->loadObjectlist();
     if (empty($data)) {
         return array();
     }
     foreach ($data as $key => &$item) {
         $item->link = JRoute::_(K2HelperRoute::getItemRoute($item->id . ':' . $item->alias, $item->catid . ':' . $item->categoryalias) . $extraURL);
         $item->date = JHtml::_('date', $item->created, JText::_('DATE_FORMAT_LC2'));
         $item->subtitle = $this->substring($item->title, $titleMaxChars);
         if ($limitDescriptionBy == 'word') {
             $string = preg_replace("/\\s+/", " ", strip_tags($item->introtext));
             $tmp = explode(" ", $string);
             $item->description = $descriptionMaxChars > count($tmp) ? $string : implode(" ", array_slice($tmp, 0, $descriptionMaxChars));
         } else {
             $item->description = self::substring($item->introtext, $descriptionMaxChars, '', $isStripedTags);
         }
         $item->rating = is_numeric($item->rating) ? floatval($item->rating / 5 * 100) : null;
         $item->author = $item->created_by;
         $item = $this->generateImages($item, $isThumb);
         $item->categoryLink = urldecode(JRoute::_(K2HelperRoute::getCategoryRoute($item->catid . ':' . urlencode($item->categoryalias))));
         if ($params->get('itemAuthor')) {
             if (!empty($item->created_by_alias)) {
                 $item->author = $item->created_by_alias;
                 $item->authorGender = NULL;
             } else {
                 $author =& JFactory::getUser($item->created_by);
                 $item->author = $author->name;
                 $query = "SELECT `gender` FROM #__k2_users WHERE userID=" . (int) $author->id;
                 $db->setQuery($query, 0, 1);
                 $item->authorGender = $db->loadResult();
                 //Author Link
                 $item->authorLink = JRoute::_(K2HelperRoute::getUserRoute($item->created_by));
             }
         }
     }
     return $data;
 }
开发者ID:vuchannguyen,项目名称:dayhoc,代码行数:79,代码来源:source.php

示例13: getArticles


//.........这里部分代码省略.........
         case 'created':
             $ordering = 'created ' . $sort_order;
             break;
         case 'modified':
             $ordering = 'modified ' . $sort_order;
             break;
         case 'title':
             $ordering = 'title ' . $sort_order;
             break;
     }
     if ($ordering == 'RAND()') {
         $query .= "\n ORDER BY " . $ordering;
     } else {
         $query .= "\n ORDER BY i." . $ordering;
     }
     $db->setQuery($query, 0, $limit);
     $rows = $db->loadObjectList();
     $autoresize = intval(trim($helper->get('autoresize', 0)));
     $width_img = (int) $helper->get('width', 100) < 0 ? 100 : $helper->get('width', 100);
     $height_img = (int) $helper->get('height', 100) < 0 ? 100 : $helper->get('height', 100);
     $img_w = intval(trim($width_img));
     $img_h = intval(trim($height_img));
     //$img_w 				= intval(trim($helper->get('width', 100)));
     //$img_h 				= intval(trim($helper->get('height', 100)));
     $img_align = $helper->get('align', 'left');
     $showimage = $params->get('showimage', $helper->get('showimage', 0));
     $maxchars = intval(trim($helper->get('maxchars', 200)));
     $hiddenClasses = trim($helper->get('hiddenClasses', ''));
     $showdate = $helper->get('showdate', 0);
     $enabletimestamp = $helper->get('timestamp', 0);
     if (count($rows)) {
         foreach ($rows as $j => $row) {
             $row->introtext1 = "";
             $row->cat_link = urldecode(JRoute::_(K2HelperRoute::getCategoryRoute($row->categoryid . ':' . urlencode($row->categoryalias))));
             //Clean title
             $row->title = JFilterOutput::ampReplace($row->title);
             //Images
             $image = '';
             if (JFile::exists(JPATH_SITE . DS . 'media' . DS . 'k2' . DS . 'items' . DS . 'cache' . DS . md5("Image" . $row->id) . '_XL.jpg')) {
                 $image = JURI::root() . 'media/k2/items/cache/' . md5("Image" . $row->id) . '_XL.jpg';
             } elseif (JFile::exists(JPATH_SITE . DS . 'media' . DS . 'k2' . DS . 'items' . DS . 'cache' . DS . md5("Image" . $row->id) . '_XS.jpg')) {
                 $image = JURI::root() . 'media/k2/items/cache/' . md5("Image" . $row->id) . '_XS.jpg';
             } elseif (JFile::exists(JPATH_SITE . DS . 'media' . DS . 'k2' . DS . 'items' . DS . 'cache' . DS . md5("Image" . $row->id) . '_L.jpg')) {
                 $image = JURI::root() . 'media/k2/items/cache/' . md5("Image" . $row->id) . '_L.jpg';
             } elseif (JFile::exists(JPATH_SITE . DS . 'media' . DS . 'k2' . DS . 'items' . DS . 'cache' . DS . md5("Image" . $row->id) . '_S.jpg')) {
                 $image = JURI::root() . 'media/k2/items/cache/' . md5("Image" . $row->id) . '_S.jpg';
             } elseif (JFile::exists(JPATH_SITE . DS . 'media' . DS . 'k2' . DS . 'items' . DS . 'cache' . DS . md5("Image" . $row->id) . '_M.jpg')) {
                 $image = JURI::root() . 'media/k2/items/cache/' . md5("Image" . $row->id) . '_M.jpg';
             } elseif (JFile::exists(JPATH_SITE . DS . 'media' . DS . 'k2' . DS . 'items' . DS . 'cache' . DS . md5("Image" . $row->id) . '_Generic.jpg')) {
                 $image = JURI::root() . 'media/k2/items/cache/' . md5("Image" . $row->id) . '_Generic.jpg';
             }
             if ($image != '') {
                 $thumbnailMode = $helper->get('thumbnail_mode', 'crop');
                 $aspect = $helper->get('use_ratio', '1');
                 $crop = $thumbnailMode == 'crop' ? true : false;
                 $align = $img_align ? "align=\"{$img_align}\"" : "";
                 $jaimage = JAImage::getInstance();
                 if ($thumbnailMode != 'none' && $jaimage->sourceExited($image)) {
                     $imageURL = $jaimage->resize($image, $img_w, $img_h, $crop, $aspect);
                     $imageURL = str_replace(JURI::base(), '', $imageURL);
                     $imageURL = JURI::base() . $imageURL;
                     $row->image = $imageURL ? "<img class=\"{$img_align}\" src=\"" . $imageURL . "\" alt=\"{$row->title}\" {$align} />" : "";
                 } else {
                     $width = $img_w ? "width=\"{$img_w}\"" : "";
                     $height = $img_h ? "height=\"{$img_h}\"" : "";
                     $imageURL = str_replace(JURI::base(), '', $imageURL);
开发者ID:ashanrupasinghe,项目名称:slbcv2,代码行数:67,代码来源:k2.php

示例14: display

 function display($tpl = null)
 {
     $mainframe = JFactory::getApplication();
     $params = K2HelperUtilities::getParams('com_k2');
     $document = JFactory::getDocument();
     if (K2_JVERSION == '15') {
         $document->setMimeEncoding('application/json');
         $document->setType('json');
     }
     $model = $this->getModel('itemlist');
     //Set limit for model
     $limit = JRequest::getInt('limit');
     if ($limit > 100 || $limit == 0) {
         $limit = 100;
         JRequest::setVar('limit', $limit);
     }
     $page = JRequest::getInt('page');
     if ($page <= 0) {
         $limitstart = 0;
     } else {
         $page--;
         $limitstart = $page * $limit;
     }
     JRequest::setVar('limitstart', $limitstart);
     $view = JRequest::getWord('view');
     $task = JRequest::getWord('task');
     $response = new JObject();
     unset($response->_errors);
     // Site
     $response->site = new stdClass();
     $uri = JURI::getInstance();
     $response->site->url = $uri->toString(array('scheme', 'host', 'port'));
     $config = JFactory::getConfig();
     $response->site->name = K2_JVERSION == '30' ? $config->get('sitename') : $config->getValue('config.sitename');
     $moduleID = JRequest::getInt('moduleID');
     if ($moduleID) {
         $result = $model->getModuleItems($moduleID);
         $items = $result->items;
         $title = $result->title;
         $prefix = 'cat';
     } else {
         //Get data depending on task
         switch ($task) {
             case 'category':
                 //Get category
                 $id = JRequest::getInt('id');
                 JTable::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR . DS . 'tables');
                 $category = JTable::getInstance('K2Category', 'Table');
                 $category->load($id);
                 // State Check
                 if (!$category->published || $category->trash) {
                     JError::raiseError(404, JText::_('K2_CATEGORY_NOT_FOUND'));
                 }
                 //Access check
                 $user = JFactory::getUser();
                 if (K2_JVERSION != '15') {
                     if (!in_array($category->access, $user->getAuthorisedViewLevels())) {
                         JError::raiseError(403, JText::_('K2_ALERTNOTAUTH'));
                     }
                     $languageFilter = $mainframe->getLanguageFilter();
                     $languageTag = JFactory::getLanguage()->getTag();
                     if ($languageFilter && $category->language != $languageTag && $category->language != '*') {
                         return;
                     }
                 } else {
                     if ($category->access > $user->get('aid', 0)) {
                         JError::raiseError(403, JText::_('K2_ALERTNOTAUTH'));
                     }
                 }
                 //Merge params
                 $cparams = class_exists('JParameter') ? new JParameter($category->params) : new JRegistry($category->params);
                 if ($cparams->get('inheritFrom')) {
                     $masterCategory = JTable::getInstance('K2Category', 'Table');
                     $masterCategory->load($cparams->get('inheritFrom'));
                     $cparams = class_exists('JParameter') ? new JParameter($masterCategory->params) : new JRegistry($masterCategory->params);
                 }
                 $params->merge($cparams);
                 //Category link
                 $category->link = urldecode(JRoute::_(K2HelperRoute::getCategoryRoute($category->id . ':' . urlencode($category->alias))));
                 //Category image
                 $category->image = K2HelperUtilities::getCategoryImage($category->image, $params);
                 //Category plugins
                 $dispatcher = JDispatcher::getInstance();
                 JPluginHelper::importPlugin('content');
                 $category->text = $category->description;
                 if (K2_JVERSION != '15') {
                     $dispatcher->trigger('onContentPrepare', array('com_k2.category', &$category, &$params, $limitstart));
                 } else {
                     $dispatcher->trigger('onPrepareContent', array(&$category, &$params, $limitstart));
                 }
                 $category->description = $category->text;
                 //Category K2 plugins
                 $category->event->K2CategoryDisplay = '';
                 JPluginHelper::importPlugin('k2');
                 $results = $dispatcher->trigger('onK2CategoryDisplay', array(&$category, &$params, $limitstart));
                 $category->event->K2CategoryDisplay = trim(implode("\n", $results));
                 $category->text = $category->description;
                 $dispatcher->trigger('onK2PrepareContent', array(&$category, &$params, $limitstart));
                 $category->description = $category->text;
                 //Category children
//.........这里部分代码省略.........
开发者ID:jamielaff,项目名称:als_resourcing,代码行数:101,代码来源:view.json.php

示例15: getUrl

 /**
  * Returns the URL for an article
  *
  * @param  Table    $row
  * @param  boolean  $htmlspecialchars
  * @param  string   $type              'article', 'section' or 'category'
  * @return string                      URL
  */
 public static function getUrl($row, $htmlspecialchars = true, $type = 'article')
 {
     global $_CB_framework;
     /** @noinspection PhpIncludeInspection */
     require_once $_CB_framework->getCfg('absolute_path') . '/components/com_k2/helpers/route.php';
     $categorySlug = $row->get('category') . ($row->get('category_alias') ? ':' . $row->get('category_alias') : null);
     $articleSlug = $row->get('id') . ($row->get('alias') ? ':' . $row->get('alias') : null);
     switch ($type) {
         case 'section':
             /** @noinspection PhpUndefinedClassInspection */
             $url = K2HelperRoute::getCategoryRoute($row->get('parent'));
             break;
         case 'category':
             /** @noinspection PhpUndefinedClassInspection */
             $url = K2HelperRoute::getCategoryRoute($categorySlug);
             break;
         case 'article':
         default:
             /** @noinspection PhpUndefinedClassInspection */
             $url = K2HelperRoute::getItemRoute($articleSlug, $categorySlug);
             break;
     }
     if (!stristr($url, 'Itemid')) {
         $url = $_CB_framework->getCfg('live_site') . '/' . $url;
     } else {
         $url = JRoute::_($url, false);
     }
     if ($url) {
         if ($htmlspecialchars) {
             $url = htmlspecialchars($url);
         }
     }
     return $url;
 }
开发者ID:bobozhangshao,项目名称:HeartCare,代码行数:42,代码来源:k2.php


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