本文整理汇总了PHP中K2HelperRoute::getTagRoute方法的典型用法代码示例。如果您正苦于以下问题:PHP K2HelperRoute::getTagRoute方法的具体用法?PHP K2HelperRoute::getTagRoute怎么用?PHP K2HelperRoute::getTagRoute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类K2HelperRoute
的用法示例。
在下文中一共展示了K2HelperRoute::getTagRoute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: display
//.........这里部分代码省略.........
}
if ($i < $params->get('num_leading_items')) {
$items[$i]->itemGroup = 'leading';
}
}
//Check if model should use cache for preparing item even if user is logged in
if ($user->guest || $task == 'tag' || $task == 'search' || $task == 'date') {
$cacheFlag = true;
} else {
$cacheFlag = true;
if (K2HelperPermissions::canEditItem($items[$i]->created_by, $items[$i]->catid)) {
$cacheFlag = false;
}
}
//Prepare item
if ($cacheFlag) {
$hits = $items[$i]->hits;
$items[$i]->hits = 0;
JTable::getInstance('K2Category', 'Table');
$items[$i] = $cache->call(array('K2ModelItem', 'prepareItem'), $items[$i], $view, $task);
$items[$i]->hits = $hits;
} else {
$items[$i] = $model->prepareItem($items[$i], $view, $task);
}
//Plugins
$items[$i] = $model->execPlugins($items[$i], $view, $task);
//Trigger comments counter event
$dispatcher =& JDispatcher::getInstance();
JPluginHelper::importPlugin('k2');
$results = $dispatcher->trigger('onK2CommentsCounter', array(&$items[$i], &$params, $limitstart));
$items[$i]->event->K2CommentsCounter = trim(implode("\n", $results));
}
//Pathway
$pathway =& $mainframe->getPathWay();
$pathway->addItem($title);
//Feed link
$config =& JFactory::getConfig();
$menu =& JSite::getMenu();
$default = $menu->getDefault();
$active = $menu->getActive();
if ($task == 'tag') {
$link = K2HelperRoute::getTagRoute(JRequest::getVar('tag'));
} else {
$link = '';
}
if (!is_null($active) && $active->id == $default->id && $config->getValue('config.sef')) {
$link .= '&Itemid=' . $active->id . '&format=feed&limitstart=';
} else {
$link .= '&format=feed&limitstart=';
}
$feed = JRoute::_($link);
$this->assignRef('feed', $feed);
//Assign data
if ($task == "category" || $task == "") {
$leading = @array_slice($items, 0, $params->get('num_leading_items'));
$primary = @array_slice($items, $params->get('num_leading_items'), $params->get('num_primary_items'));
$secondary = @array_slice($items, $params->get('num_leading_items') + $params->get('num_primary_items'), $params->get('num_secondary_items'));
$links = @array_slice($items, $params->get('num_leading_items') + $params->get('num_primary_items') + $params->get('num_secondary_items'), $params->get('num_links'));
$this->assignRef('leading', $leading);
$this->assignRef('primary', $primary);
$this->assignRef('secondary', $secondary);
$this->assignRef('links', $links);
} else {
$this->assignRef('items', $items);
}
//Set default values to avoid division by zero
if ($params->get('num_leading_columns') == 0) {
$params->set('num_leading_columns', 1);
}
if ($params->get('num_primary_columns') == 0) {
$params->set('num_primary_columns', 1);
}
if ($params->get('num_secondary_columns') == 0) {
$params->set('num_secondary_columns', 1);
}
if ($params->get('num_links_columns') == 0) {
$params->set('num_links_columns', 1);
}
$this->assignRef('params', $params);
$this->assignRef('pagination', $pagination);
//Look for template files in component folders
$this->_addPath('template', JPATH_COMPONENT . DS . 'templates');
$this->_addPath('template', JPATH_COMPONENT . DS . 'templates' . DS . 'default');
//Look for overrides in template folder (K2 template structure)
$this->_addPath('template', JPATH_SITE . DS . 'templates' . DS . $mainframe->getTemplate() . DS . 'html' . DS . 'com_k2' . DS . 'templates');
$this->_addPath('template', JPATH_SITE . DS . 'templates' . DS . $mainframe->getTemplate() . DS . 'html' . DS . 'com_k2' . DS . 'templates' . DS . 'default');
//Look for overrides in template folder (Joomla! template structure)
$this->_addPath('template', JPATH_SITE . DS . 'templates' . DS . $mainframe->getTemplate() . DS . 'html' . DS . 'com_k2' . DS . 'default');
$this->_addPath('template', JPATH_SITE . DS . 'templates' . DS . $mainframe->getTemplate() . DS . 'html' . DS . 'com_k2');
//Look for specific K2 theme files
if ($params->get('theme')) {
$this->_addPath('template', JPATH_COMPONENT . DS . 'templates' . DS . $params->get('theme'));
$this->_addPath('template', JPATH_SITE . DS . 'templates' . DS . $mainframe->getTemplate() . DS . 'html' . DS . 'com_k2' . DS . 'templates' . DS . $params->get('theme'));
$this->_addPath('template', JPATH_SITE . DS . 'templates' . DS . $mainframe->getTemplate() . DS . 'html' . DS . 'com_k2' . DS . $params->get('theme'));
}
$db =& JFactory::getDBO();
$nullDate = $db->getNullDate();
$this->assignRef('nullDate', $nullDate);
parent::display($tpl);
}
示例2: prepareItem
function prepareItem($item, $view, $task)
{
jimport('joomla.filesystem.file');
JTable::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR . DS . 'tables');
$limitstart = JRequest::getInt('limitstart');
//Initialize params
if ($view != 'item') {
$component = JComponentHelper::getComponent('com_k2');
$params = new JParameter($component->params);
$itemid = JRequest::getInt('Itemid');
if ($itemid) {
$menu = JSite::getMenu();
$menuparams = $menu->getParams($itemid);
$params->merge($menuparams);
}
} else {
$params =& JComponentHelper::getParams('com_k2');
}
//Category
$db =& JFactory::getDBO();
$query = "SELECT * FROM #__k2_categories WHERE id={$item->catid}";
$db->setQuery($query, 0, 1);
$category = $db->loadObject();
$item->category = $category;
$item->category->link = urldecode(JRoute::_(K2HelperRoute::getCategoryRoute($category->id . ':' . urlencode($category->alias))));
//Read more link
$link = K2HelperRoute::getItemRoute($item->id . ':' . urlencode($item->alias), $item->catid . ':' . urlencode($item->category->alias));
$item->link = urldecode(JRoute::_($link));
//Print link
$item->printLink = urldecode(JRoute::_($link . '&tmpl=component&print=1'));
//Params
$cparams = new JParameter($category->params);
$iparams = new JParameter($item->params);
$item->params = $params;
if ($cparams->get('inheritFrom')) {
$masterCategoryID = $cparams->get('inheritFrom');
$query = "SELECT * FROM #__k2_categories WHERE id={$masterCategoryID}";
$db->setQuery($query, 0, 1);
$masterCategory = $db->loadObject();
$cparams = new JParameter($masterCategory->params);
}
$item->params->merge($cparams);
$item->params->merge($iparams);
//Edit link
if (K2HelperPermissions::canEditItem($item->created_by, $item->catid)) {
$item->editLink = JRoute::_('index.php?option=com_k2&view=item&task=edit&cid=' . $item->id . '&tmpl=component');
}
//Tags
if ($view == 'item' && ($item->params->get('itemTags') || $item->params->get('itemRelated')) || $view == 'itemlist' && ($task == '' || $task == 'category') && $item->params->get('catItemTags') || $view == 'itemlist' && $task == 'user' && $item->params->get('userItemTags') || $view == 'latest' && $params->get('latestItemTags')) {
$tags = K2ModelItem::getItemTags($item->id);
for ($i = 0; $i < sizeof($tags); $i++) {
$tags[$i]->link = urldecode(JRoute::_(K2HelperRoute::getTagRoute($tags[$i]->name)));
}
$item->tags = $tags;
}
//Image
$item->imageXSmall = '';
$item->imageSmall = '';
$item->imageMedium = '';
$item->imageLarge = '';
$item->imageXLarge = '';
if (JFile::exists(JPATH_SITE . DS . 'media' . DS . 'k2' . DS . 'items' . DS . 'cache' . DS . md5("Image" . $item->id) . '_XS.jpg')) {
$item->imageXSmall = JURI::root() . 'media/k2/items/cache/' . md5("Image" . $item->id) . '_XS.jpg';
}
if (JFile::exists(JPATH_SITE . DS . 'media' . DS . 'k2' . DS . 'items' . DS . 'cache' . DS . md5("Image" . $item->id) . '_S.jpg')) {
$item->imageSmall = JURI::root() . 'media/k2/items/cache/' . md5("Image" . $item->id) . '_S.jpg';
}
if (JFile::exists(JPATH_SITE . DS . 'media' . DS . 'k2' . DS . 'items' . DS . 'cache' . DS . md5("Image" . $item->id) . '_M.jpg')) {
$item->imageMedium = JURI::root() . 'media/k2/items/cache/' . md5("Image" . $item->id) . '_M.jpg';
}
if (JFile::exists(JPATH_SITE . DS . 'media' . DS . 'k2' . DS . 'items' . DS . 'cache' . DS . md5("Image" . $item->id) . '_L.jpg')) {
$item->imageLarge = JURI::root() . 'media/k2/items/cache/' . md5("Image" . $item->id) . '_L.jpg';
}
if (JFile::exists(JPATH_SITE . DS . 'media' . DS . 'k2' . DS . 'items' . DS . 'cache' . DS . md5("Image" . $item->id) . '_XL.jpg')) {
$item->imageXLarge = JURI::root() . 'media/k2/items/cache/' . md5("Image" . $item->id) . '_XL.jpg';
}
if (JFile::exists(JPATH_SITE . DS . 'media' . DS . 'k2' . DS . 'items' . DS . 'cache' . DS . md5("Image" . $item->id) . '_Generic.jpg')) {
$item->imageGeneric = JURI::root() . 'media/k2/items/cache/' . md5("Image" . $item->id) . '_Generic.jpg';
}
//Extra fields
if ($view == 'item' && $item->params->get('itemExtraFields') || $view == 'itemlist' && ($task == '' || $task == 'category') && $item->params->get('catItemExtraFields') || $view == 'itemlist' && ($task == 'search' || $task == 'tag' || $task == 'date') && $item->params->get('genericItemExtraFields')) {
$item->extra_fields = K2ModelItem::getItemExtraFields($item->extra_fields);
}
//Attachments
if ($view == 'item' && $item->params->get('itemAttachments') || $view == 'itemlist' && ($task == '' || $task == 'category') && $item->params->get('catItemAttachments')) {
$item->attachments = K2ModelItem::getItemAttachments($item->id);
}
//Import plugins
$dispatcher =& JDispatcher::getInstance();
JPluginHelper::importPlugin('content');
//Gallery
if ($view == 'item' && $item->params->get('itemImageGallery') || $view == 'itemlist' && ($task == '' || $task == 'category') && $item->params->get('catItemImageGallery')) {
$params->set('galleries_rootfolder', 'media/k2/galleries');
$params->set('popup_engine', 'mootools_slimbox');
$params->set('enabledownload', '0');
$item->text = $item->gallery;
$dispatcher->trigger('onPrepareContent', array(&$item, &$params, $limitstart));
$item->gallery = $item->text;
}
//Video
//.........这里部分代码省略.........
示例3: processTagTags
public function processTagTags($extra)
{
require_once JPATH_SITE . '/components/com_k2/helpers/route.php';
$tags = $this->getItemTags($this->article->id);
foreach ($tags as &$tag) {
$tag->link = JRoute::_(K2HelperRoute::getTagRoute($tag->name));
}
$extra = explode(':', $extra, 2);
$clean = trim(array_shift($extra));
$html = array();
if ($clean != 'clean') {
foreach ($tags as $tag) {
if (!$tag->published) {
continue;
}
$html[] = '<li><a href="' . $tag->link . '">' . htmlspecialchars($tag->name, ENT_COMPAT, 'UTF-8') . '</a></li>';
}
return '<div class="itemTagsBlock">' . '<span>' . JText::_('K2_TAGGED_UNDER') . '</span>' . '<ul class="itemTags">' . implode('', $html) . '</ul>' . '<div class="clr"></div>' . '</div>';
}
$separator = array_shift($extra);
$separator = $separator != '' ? str_replace('separator=', '', $separator) : ' ';
foreach ($tags as $tag) {
if (!$tag->published) {
continue;
}
$html[] = '<span class="tag-' . $tag->id . '" itemprop="keywords">' . '<a href = "' . $tag->link . '" class="tag_link">' . htmlspecialchars($tag->name, ENT_COMPAT, 'UTF-8') . '</a>' . '</span>';
}
return '<span class="tags">' . implode($separator, $html) . '</span>';
}
示例4: tagCloud
public static function tagCloud(&$params)
{
$mainframe = JFactory::getApplication();
$user = JFactory::getUser();
$aid = (int) $user->get('aid');
$db = JFactory::getDBO();
$jnow = JFactory::getDate();
$now = K2_JVERSION == '15' ? $jnow->toMySQL() : $jnow->toSql();
$nullDate = $db->getNullDate();
$query = "SELECT i.id FROM #__k2_items as i";
$query .= " LEFT JOIN #__k2_categories c ON c.id = i.catid";
$query .= " WHERE i.published=1 ";
$query .= " AND ( i.publish_up = " . $db->Quote($nullDate) . " OR i.publish_up <= " . $db->Quote($now) . " ) ";
$query .= " AND ( i.publish_down = " . $db->Quote($nullDate) . " OR i.publish_down >= " . $db->Quote($now) . " )";
$query .= " AND i.trash=0 ";
if (K2_JVERSION != '15') {
$query .= " AND i.access IN(" . implode(',', $user->getAuthorisedViewLevels()) . ") ";
} else {
$query .= " AND i.access <= {$aid} ";
}
$query .= " AND c.published=1 ";
$query .= " AND c.trash=0 ";
if (K2_JVERSION != '15') {
$query .= " AND c.access IN(" . implode(',', $user->getAuthorisedViewLevels()) . ") ";
} else {
$query .= " AND c.access <= {$aid} ";
}
$cloudCategory = $params->get('cloud_category');
if (is_array($cloudCategory)) {
$cloudCategory = array_filter($cloudCategory);
}
if ($cloudCategory) {
if (!is_array($cloudCategory)) {
$cloudCategory = (array) $cloudCategory;
}
foreach ($cloudCategory as $cloudCategoryID) {
$categories[] = $cloudCategoryID;
if ($params->get('cloud_category_recursive')) {
$children = modK2ToolsHelper::getCategoryChildren($cloudCategoryID);
$categories = @array_merge($categories, $children);
}
}
$categories = @array_unique($categories);
JArrayHelper::toInteger($categories);
if (count($categories) == 1) {
$query .= " AND i.catid={$categories[0]}";
} else {
$query .= " AND i.catid IN(" . implode(',', $categories) . ")";
}
}
if (K2_JVERSION != '15') {
if ($mainframe->getLanguageFilter()) {
$languageTag = JFactory::getLanguage()->getTag();
$query .= " AND c.language IN (" . $db->Quote($languageTag) . ", " . $db->Quote('*') . ") AND i.language IN (" . $db->Quote($languageTag) . ", " . $db->Quote('*') . ") ";
}
}
$db->setQuery($query);
$IDs = K2_JVERSION == '30' ? $db->loadColumn() : $db->loadResultArray();
if (!is_array($IDs) || !count($IDs)) {
return array();
}
$query = "SELECT tag.name, tag.id\n FROM #__k2_tags as tag\n LEFT JOIN #__k2_tags_xref AS xref ON xref.tagID = tag.id \n WHERE xref.itemID IN (" . implode(',', $IDs) . ") \n AND tag.published = 1";
$db->setQuery($query);
$rows = $db->loadObjectList();
$cloud = array();
if (count($rows)) {
foreach ($rows as $tag) {
if (@array_key_exists($tag->name, $cloud)) {
$cloud[$tag->name]++;
} else {
$cloud[$tag->name] = 1;
}
}
$max_size = $params->get('max_size');
$min_size = $params->get('min_size');
$max_qty = max(array_values($cloud));
$min_qty = min(array_values($cloud));
$spread = $max_qty - $min_qty;
if (0 == $spread) {
$spread = 1;
}
$step = ($max_size - $min_size) / $spread;
$counter = 0;
arsort($cloud, SORT_NUMERIC);
$cloud = @array_slice($cloud, 0, $params->get('cloud_limit'), true);
uksort($cloud, "strnatcasecmp");
foreach ($cloud as $key => $value) {
$size = $min_size + ($value - $min_qty) * $step;
$size = ceil($size);
$tmp = new stdClass();
$tmp->tag = $key;
$tmp->count = $value;
$tmp->size = $size;
$tmp->link = urldecode(JRoute::_(K2HelperRoute::getTagRoute($key)));
$tags[$counter] = $tmp;
$counter++;
}
return $tags;
}
}
示例5: info
static function info($config, $item, $num = 1)
{
// %AUTHOR %DATE %HITS %CATEGORY
$news_info = '';
//
if ($num == 1) {
if ($config['news_content_info_pos'] != 'disabled') {
$class = 'nspInfo1 t' . $config['news_content_info_pos'] . ' f' . $config['news_content_info_float'];
}
} else {
if ($config['news_content_info2_pos'] != 'disabled') {
$class = 'nspInfo2 t' . $config['news_content_info2_pos'] . ' f' . $config['news_content_info2_float'];
}
}
//
if ($config['news_content_info_pos'] != 'disabled' && $num == 1 || $config['news_content_info2_pos'] != 'disabled' && $num == 2) {
$news_info = '<p class="nspInfo ' . $class . '">' . $config['info' . ($num == 2 ? '2' : '') . '_format'] . '</p>';
//
$author = trim(htmlspecialchars($item['author_alias'])) != '' ? htmlspecialchars($item['author_alias']) : htmlspecialchars($item['author_username']);
$info_author = $config['user_avatar'] == 1 ? '<span><img src="' . K2HelperUtilities::getAvatar($item['author_id'], $item['author_email'], $config['avatar_size']) . '" alt="' . $author . ' - avatar" class="nspAvatar" width="' . $config['avatar_size'] . '" height="' . $config['avatar_size'] . '" /> ' . $author . '</span>' : $author;
//
$info_date = JHTML::_('date', $item['date'], $config['date_format']);
//
$info_hits = JText::_('MOD_NEWS_PRO_GK5_NHITS') . $item['hits'];
$info_rate = $item['rating_count'] > 0 ? '<span class="nspRate">' . JText::_('MOD_NEWS_PRO_GK5_NSP_RATE') . ' ' . number_format($item['rating_sum'] / $item['rating_count'], 2) . '</span>' : '';
$info_category = $config['category_link'] == 1 ? '<a href="' . NSP_GK5_com_k2_View::categoryLink($item) . '" >' . $item['catname'] . '</a>' : $item['catname'];
$info_comments = JText::_('MOD_NEWS_PRO_GK5_NO_COMMENTS');
//
if (isset($item['comments'])) {
if ($item['comments'] == 1) {
$info_comments = JText::_('MOD_NEWS_PRO_GK5_1COMMENT');
} else {
if ($item['comments'] > 1 && $item['comments'] < 5) {
$info_comments = $item['comments'] . ' ' . JText::_('MOD_NEWS_PRO_GK5_MORECOMMENTS');
} else {
if ($item['comments'] >= 5) {
$info_comments = $item['comments'] . ' ' . JText::_('MOD_NEWS_PRO_GK5_MUCHMORECOMMENTS');
}
}
}
}
//
$info_tags = '';
if (isset($item['tags']) && count($item['tags']) > 0) {
$i = 0;
foreach ($item['tags'] as $tag) {
$link = urldecode(JRoute::_(K2HelperRoute::getTagRoute($tag)));
if ($i == 0) {
$info_tags .= '<a href="' . $link . '">' . $tag . '</a>';
} else {
$info_tags .= ', <a href="' . $link . '">' . $tag . '</a>';
}
//
$i++;
}
}
//
$news_info = str_replace('%AUTHOR', $info_author, $news_info);
$news_info = str_replace('%DATE', $info_date, $news_info);
$news_info = str_replace('%HITS', $info_hits, $news_info);
$news_info = str_replace('%CATEGORY', $info_category, $news_info);
$news_info = str_replace('%RATE', $info_rate, $news_info);
$news_info = str_replace('%COMMENTS', $info_comments, $news_info);
$news_info = str_replace('%TAGS', $info_tags, $news_info);
} else {
return '';
}
//
return $news_info;
}
示例6: display
//.........这里部分代码省略.........
$pathway = $mainframe->getPathWay();
if (!isset($menu->query['task'])) {
$menu->query['task'] = '';
}
if ($menu) {
switch ($task) {
case 'category':
if ($menu->query['task'] != 'category' || $menu->query['id'] != JRequest::getInt('id')) {
$pathway->addItem($title, '');
}
break;
case 'user':
if ($menu->query['task'] != 'user' || $menu->query['id'] != JRequest::getInt('id')) {
$pathway->addItem($title, '');
}
break;
case 'tag':
if ($menu->query['task'] != 'tag' || $menu->query['tag'] != JRequest::getVar('tag')) {
$pathway->addItem($title, '');
}
break;
case 'search':
case 'date':
$pathway->addItem($title, '');
break;
}
}
// Feed link
$config = JFactory::getConfig();
$menu = $application->getMenu();
$default = $menu->getDefault();
$active = $menu->getActive();
if ($task == 'tag') {
$link = K2HelperRoute::getTagRoute(JRequest::getVar('tag'));
} else {
$link = '';
}
$sef = K2_JVERSION == '30' ? $config->get('sef') : $config->getValue('config.sef');
if (!is_null($active) && $active->id == $default->id && $sef) {
$link .= '&Itemid=' . $active->id . '&format=feed&limitstart=';
} else {
$link .= '&format=feed&limitstart=';
}
$feed = JRoute::_($link);
$this->assignRef('feed', $feed);
// Add head feed link
if ($addHeadFeedLink) {
$attribs = array('type' => 'application/rss+xml', 'title' => 'RSS 2.0');
$document->addHeadLink(JRoute::_($link . '&type=rss'), 'alternate', 'rel', $attribs);
$attribs = array('type' => 'application/atom+xml', 'title' => 'Atom 1.0');
$document->addHeadLink(JRoute::_($link . '&type=atom'), 'alternate', 'rel', $attribs);
}
// Assign data
if ($task == "category" || $task == "") {
$leading = @array_slice($items, 0, $params->get('num_leading_items'));
$primary = @array_slice($items, $params->get('num_leading_items'), $params->get('num_primary_items'));
$secondary = @array_slice($items, $params->get('num_leading_items') + $params->get('num_primary_items'), $params->get('num_secondary_items'));
$links = @array_slice($items, $params->get('num_leading_items') + $params->get('num_primary_items') + $params->get('num_secondary_items'), $params->get('num_links'));
$this->assignRef('leading', $leading);
$this->assignRef('primary', $primary);
$this->assignRef('secondary', $secondary);
$this->assignRef('links', $links);
} else {
$this->assignRef('items', $items);
}
// Set default values to avoid division by zero
示例7: getFeedLink
public function getFeedLink()
{
if (!isset($this->feedLink)) {
$this->feedLink = JRoute::_(K2HelperRoute::getTagRoute($this->id . ':' . $this->alias) . '&format=feed');
}
return $this->feedLink;
}
示例8: display
//.........这里部分代码省略.........
$params->set('page_title', $title);
}
$document->setTitle($params->get('page_title'));
//Pathway
$pathway =& $mainframe->getPathWay();
if (!isset($menu->query['task'])) {
$menu->query['task'] = '';
}
if ($menu) {
switch ($task) {
case 'category':
if ($menu->query['task'] != 'category' || $menu->query['id'] != JRequest::getInt('id')) {
$pathway->addItem($title, '');
}
break;
case 'user':
if ($menu->query['task'] != 'user' || $menu->query['id'] != JRequest::getInt('id')) {
$pathway->addItem($title, '');
}
break;
case 'tag':
if ($menu->query['task'] != 'tag' || $menu->query['tag'] != JRequest::getVar('tag')) {
$pathway->addItem($title, '');
}
break;
case 'search':
case 'date':
$pathway->addItem($title, '');
break;
}
}
//Feed link
$config =& JFactory::getConfig();
$menu =& JSite::getMenu();
$default = $menu->getDefault();
$active = $menu->getActive();
if ($task == 'tag') {
$link = K2HelperRoute::getTagRoute(JRequest::getVar('tag'));
} else {
$link = '';
}
if (!is_null($active) && $active->id == $default->id && $config->getValue('config.sef')) {
$link .= '&Itemid=' . $active->id . '&format=feed&limitstart=';
} else {
$link .= '&format=feed&limitstart=';
}
$feed = JRoute::_($link);
$this->assignRef('feed', $feed);
//Add head feed link
if ($params->get('feedLink', 1)) {
$attribs = array('type' => 'application/rss+xml', 'title' => 'RSS 2.0');
$document->addHeadLink(JRoute::_($link . '&type=rss'), 'alternate', 'rel', $attribs);
$attribs = array('type' => 'application/atom+xml', 'title' => 'Atom 1.0');
$document->addHeadLink(JRoute::_($link . '&type=atom'), 'alternate', 'rel', $attribs);
}
//Assign data
if ($task == "category" || $task == "") {
$leading = @array_slice($items, 0, $params->get('num_leading_items'));
$primary = @array_slice($items, $params->get('num_leading_items'), $params->get('num_primary_items'));
$secondary = @array_slice($items, $params->get('num_leading_items') + $params->get('num_primary_items'), $params->get('num_secondary_items'));
$links = @array_slice($items, $params->get('num_leading_items') + $params->get('num_primary_items') + $params->get('num_secondary_items'), $params->get('num_links'));
$this->assignRef('leading', $leading);
$this->assignRef('primary', $primary);
$this->assignRef('secondary', $secondary);
$this->assignRef('links', $links);
} else {
$this->assignRef('items', $items);
}
//Set default values to avoid division by zero
if ($params->get('num_leading_columns') == 0) {
$params->set('num_leading_columns', 1);
}
if ($params->get('num_primary_columns') == 0) {
$params->set('num_primary_columns', 1);
}
if ($params->get('num_secondary_columns') == 0) {
$params->set('num_secondary_columns', 1);
}
if ($params->get('num_links_columns') == 0) {
$params->set('num_links_columns', 1);
}
$this->assignRef('params', $params);
$this->assignRef('pagination', $pagination);
//Look for template files in component folders
$this->_addPath('template', JPATH_COMPONENT . DS . 'templates');
$this->_addPath('template', JPATH_COMPONENT . DS . 'templates' . DS . 'default');
//Look for overrides in template folder (K2 template structure)
$this->_addPath('template', JPATH_SITE . DS . 'templates' . DS . $mainframe->getTemplate() . DS . 'html' . DS . 'com_k2' . DS . 'templates');
$this->_addPath('template', JPATH_SITE . DS . 'templates' . DS . $mainframe->getTemplate() . DS . 'html' . DS . 'com_k2' . DS . 'templates' . DS . 'default');
//Look for overrides in template folder (Joomla! template structure)
$this->_addPath('template', JPATH_SITE . DS . 'templates' . DS . $mainframe->getTemplate() . DS . 'html' . DS . 'com_k2' . DS . 'default');
$this->_addPath('template', JPATH_SITE . DS . 'templates' . DS . $mainframe->getTemplate() . DS . 'html' . DS . 'com_k2');
//Look for specific K2 theme files
if ($params->get('theme')) {
$this->_addPath('template', JPATH_COMPONENT . DS . 'templates' . DS . $params->get('theme'));
$this->_addPath('template', JPATH_SITE . DS . 'templates' . DS . $mainframe->getTemplate() . DS . 'html' . DS . 'com_k2' . DS . 'templates' . DS . $params->get('theme'));
$this->_addPath('template', JPATH_SITE . DS . 'templates' . DS . $mainframe->getTemplate() . DS . 'html' . DS . 'com_k2' . DS . $params->get('theme'));
}
parent::display($tpl);
}
示例9: prepareItem
function prepareItem($item, $view, $task)
{
jimport('joomla.filesystem.file');
JTable::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR . DS . 'tables');
$limitstart = JRequest::getInt('limitstart');
$application = JFactory::getApplication();
//Initialize params
if ($view != 'item') {
if (K2_JVERSION == '30') {
$params = $application->getParams('com_k2');
} else {
$component = JComponentHelper::getComponent('com_k2');
$params = class_exists('JParameter') ? new JParameter($component->params) : new JRegistry($component->params);
$itemid = JRequest::getInt('Itemid');
if ($itemid) {
$menu = $application->getMenu();
$menuparams = $menu->getParams($itemid);
$params->merge($menuparams);
}
}
} else {
$params = K2HelperUtilities::getParams('com_k2');
}
//Category
$db = JFactory::getDBO();
$category = JTable::getInstance('K2Category', 'Table');
$category->load($item->catid);
$item->category = $category;
$item->category->link = urldecode(JRoute::_(K2HelperRoute::getCategoryRoute($category->id . ':' . urlencode($category->alias))));
//Read more link
$link = K2HelperRoute::getItemRoute($item->id . ':' . urlencode($item->alias), $item->catid . ':' . urlencode($item->category->alias));
$item->link = urldecode(JRoute::_($link));
//Print link
$item->printLink = urldecode(JRoute::_($link . '&tmpl=component&print=1'));
//Params
$cparams = class_exists('JParameter') ? new JParameter($category->params) : new JRegistry($category->params);
$iparams = class_exists('JParameter') ? new JParameter($item->params) : new JRegistry($item->params);
$item->params = version_compare(PHP_VERSION, '5.0.0', '>=') ? clone $params : $params;
if ($cparams->get('inheritFrom')) {
$masterCategoryID = $cparams->get('inheritFrom');
$masterCategory = JTable::getInstance('K2Category', 'Table');
$masterCategory->load((int) $masterCategoryID);
$cparams = class_exists('JParameter') ? new JParameter($masterCategory->params) : new JRegistry($masterCategory->params);
}
$item->params->merge($cparams);
$item->params->merge($iparams);
//Edit link
if (K2HelperPermissions::canEditItem($item->created_by, $item->catid)) {
$item->editLink = JRoute::_('index.php?option=com_k2&view=item&task=edit&cid=' . $item->id . '&tmpl=component');
}
//Tags
if ($view == 'item' && ($item->params->get('itemTags') || $item->params->get('itemRelated')) || $view == 'itemlist' && ($task == '' || $task == 'category') && $item->params->get('catItemTags') || $view == 'itemlist' && $task == 'user' && $item->params->get('userItemTags') || $view == 'latest' && $params->get('latestItemTags')) {
$tags = $this->getItemTags($item->id);
for ($i = 0; $i < sizeof($tags); $i++) {
$tags[$i]->link = JRoute::_(K2HelperRoute::getTagRoute($tags[$i]->name));
}
$item->tags = $tags;
}
//Image
$item->imageXSmall = '';
$item->imageSmall = '';
$item->imageMedium = '';
$item->imageLarge = '';
$item->imageXLarge = '';
$date = JFactory::getDate($item->modified);
$timestamp = '?t=' . $date->toUnix();
if (JFile::exists(JPATH_SITE . DS . 'media' . DS . 'k2' . DS . 'items' . DS . 'cache' . DS . md5("Image" . $item->id) . '_XS.jpg')) {
$item->imageXSmall = JURI::base(true) . '/media/k2/items/cache/' . md5("Image" . $item->id) . '_XS.jpg';
if ($params->get('imageTimestamp')) {
$item->imageXSmall .= $timestamp;
}
}
if (JFile::exists(JPATH_SITE . DS . 'media' . DS . 'k2' . DS . 'items' . DS . 'cache' . DS . md5("Image" . $item->id) . '_S.jpg')) {
$item->imageSmall = JURI::base(true) . '/media/k2/items/cache/' . md5("Image" . $item->id) . '_S.jpg';
if ($params->get('imageTimestamp')) {
$item->imageSmall .= $timestamp;
}
}
if (JFile::exists(JPATH_SITE . DS . 'media' . DS . 'k2' . DS . 'items' . DS . 'cache' . DS . md5("Image" . $item->id) . '_M.jpg')) {
$item->imageMedium = JURI::base(true) . '/media/k2/items/cache/' . md5("Image" . $item->id) . '_M.jpg';
if ($params->get('imageTimestamp')) {
$item->imageMedium .= $timestamp;
}
}
if (JFile::exists(JPATH_SITE . DS . 'media' . DS . 'k2' . DS . 'items' . DS . 'cache' . DS . md5("Image" . $item->id) . '_L.jpg')) {
$item->imageLarge = JURI::base(true) . '/media/k2/items/cache/' . md5("Image" . $item->id) . '_L.jpg';
if ($params->get('imageTimestamp')) {
$item->imageLarge .= $timestamp;
}
}
if (JFile::exists(JPATH_SITE . DS . 'media' . DS . 'k2' . DS . 'items' . DS . 'cache' . DS . md5("Image" . $item->id) . '_XL.jpg')) {
$item->imageXLarge = JURI::base(true) . '/media/k2/items/cache/' . md5("Image" . $item->id) . '_XL.jpg';
if ($params->get('imageTimestamp')) {
$item->imageXLarge .= $timestamp;
}
}
if (JFile::exists(JPATH_SITE . DS . 'media' . DS . 'k2' . DS . 'items' . DS . 'cache' . DS . md5("Image" . $item->id) . '_Generic.jpg')) {
$item->imageGeneric = JURI::base(true) . '/media/k2/items/cache/' . md5("Image" . $item->id) . '_Generic.jpg';
if ($params->get('imageTimestamp')) {
$item->imageGeneric .= $timestamp;
//.........这里部分代码省略.........
示例10: getItems
//.........这里部分代码省略.........
if ($componentParams->get('imageTimestamp')) {
$item->imageMedium .= $timestamp;
}
}
if (JFile::exists(JPATH_SITE . DS . 'media' . DS . 'k2' . DS . 'items' . DS . 'cache' . DS . md5("Image" . $item->id) . '_L.jpg')) {
$item->imageLarge = JURI::base(true) . '/media/k2/items/cache/' . md5("Image" . $item->id) . '_L.jpg';
if ($componentParams->get('imageTimestamp')) {
$item->imageLarge .= $timestamp;
}
}
if (JFile::exists(JPATH_SITE . DS . 'media' . DS . 'k2' . DS . 'items' . DS . 'cache' . DS . md5("Image" . $item->id) . '_XL.jpg')) {
$item->imageXLarge = JURI::base(true) . '/media/k2/items/cache/' . md5("Image" . $item->id) . '_XL.jpg';
if ($componentParams->get('imageTimestamp')) {
$item->imageXLarge .= $timestamp;
}
}
if (JFile::exists(JPATH_SITE . DS . 'media' . DS . 'k2' . DS . 'items' . DS . 'cache' . DS . md5("Image" . $item->id) . '_Generic.jpg')) {
$item->imageGeneric = JURI::base(true) . '/media/k2/items/cache/' . md5("Image" . $item->id) . '_Generic.jpg';
if ($componentParams->get('imageTimestamp')) {
$item->imageGeneric .= $timestamp;
}
}
$image = 'image' . $params->get('itemImgSize', 'Small');
if (isset($item->{$image})) {
$item->image = $item->{$image};
}
}
//Read more link
$item->link = urldecode(JRoute::_(K2HelperRoute::getItemRoute($item->id . ':' . urlencode($item->alias), $item->catid . ':' . urlencode($item->categoryalias))));
//Tags
if ($params->get('itemTags')) {
$tags = $model->getItemTags($item->id);
for ($i = 0; $i < sizeof($tags); $i++) {
$tags[$i]->link = JRoute::_(K2HelperRoute::getTagRoute($tags[$i]->name));
}
$item->tags = $tags;
}
//Category link
//if ($params->get('itemCategory'))
$item->categoryLink = urldecode(JRoute::_(K2HelperRoute::getCategoryRoute($item->catid . ':' . urlencode($item->categoryalias))));
//Extra fields
if ($params->get('itemExtraFields')) {
$item->extra_fields = $model->getItemExtraFields($item->extra_fields, $item);
}
//Comments counter
//if ($params->get('itemCommentsCounter'))
$item->numOfComments = $model->countItemComments($item->id);
$item->rating = $model->getRating($item->id);
//Attachments
if ($params->get('itemAttachments')) {
$item->attachments = $model->getItemAttachments($item->id);
}
//Import plugins
// if ($format != 'feed')
// {
// $dispatcher = JDispatcher::getInstance();
// JPluginHelper::importPlugin('content');
// }
//Video
if ($params->get('itemVideo') && $format != 'feed') {
$params->set('vfolder', 'media/k2/videos');
$params->set('afolder', 'media/k2/audio');
$item->text = $item->video;
if (K2_JVERSION == '15') {
$dispatcher->trigger('onPrepareContent', array(&$item, &$params, $limitstart));
} else {
示例11: prepare
function prepare($items)
{
$intros = $links = array();
if (count($items)) {
foreach ($items as $index => $item) {
$item->slug = $item->id . ':' . urlencode($item->alias);
$item->catslug = $item->catid . ':' . urlencode($item->category_alias);
$item->link = JRoute::_(K2HelperRoute::getItemRoute($item->slug, $item->catslug));
$item->linkcat = JRoute::_(K2HelperRoute::getCategoryRoute($item->catid));
$item->text = $item->introtext . $item->fulltext;
$item->emailLink = JURI::base() . K2HelperRoute::getItemRoute($item->slug, $item->catslug);
if ($index < $this->num_intro) {
if ((bool) $this->params->get('intro_thumbnail')) {
$thumbnail_width = (int) $this->params->get('intro_thumbnail_width', 64);
$thumbnail_height = (int) $this->params->get('intro_thumbnail_height', 64);
$images = JPATH_SITE . DS . 'media' . DS . 'k2' . DS . 'items' . DS . 'cache' . DS . md5("Image" . $item->id) . '_L.jpg';
if (JFile::exists($images)) {
$images = 'media' . DS . 'k2' . DS . 'items' . DS . 'cache' . DS . md5("Image" . $item->id) . '_L.jpg';
$path = $this->createPath();
$item->thumbnails = $this->createThumb($images, $path, $thumbnail_width, $thumbnail_height, $this->params->get('intro_thumbnail'));
} else {
$item->thumbnails = $this->getThumbnails($item->text, $this->params->get('intro_thumbnail'), $thumbnail_width, $thumbnail_height, $this->params->get('intro_thumbnail_position') == 'inside');
}
if (!$item->thumbnails) {
$item->thumbnails = JURI::root() . 'modules/mod_jvlatest_news/tmpl/default/images/noImage.png';
}
} else {
//$images = json_decode($item->image);
//$item->thumbnails = $images[0];
}
if ($this->params->get('cut_intro') > 0) {
$item->text = cut_html_string($this->clearContentImage($item->introtext), (int) $this->params->get('cut_intro'));
} else {
$item->text = $this->clearContentImage($item->introtext);
}
$dispatcher = JDispatcher::getInstance();
$dispatcher->trigger('onPrepareContent', array(&$item, &$params, 0));
if ($this->params->get('show_tag', 0)) {
$model = K2Model::getInstance('Item', 'K2Model');
$tags = $model->getItemTags($item->id);
for ($x = 0; $x < sizeof($tags); $x++) {
$tags[$x]->link = JRoute::_(K2HelperRoute::getTagRoute($tags[$x]->name));
}
$item->tags = $tags;
}
$intros[] = $item;
} elseif ($this->nums_link > 0) {
$links[] = $item;
}
}
}
$items = new stdClass();
$items->intros = $intros;
$items->links = $links;
return $items;
}
示例12: getListItems
//.........这里部分代码省略.........
if (K2_JVERSION != '15') {
if ($mainframe->getLanguageFilter()) {
$languageTag = JFactory::getLanguage()->getTag();
$query .= " AND c.language IN (" . $db->Quote($languageTag) . ", " . $db->Quote('*') . ") AND i.language IN (" . $db->Quote($languageTag) . ", " . $db->Quote('*') . ")";
}
}
switch ($ordering) {
case 'date':
$orderby = 'i.created ASC';
break;
case 'rdate':
$orderby = 'i.created DESC';
break;
case 'alpha':
$orderby = 'i.title';
break;
case 'ralpha':
$orderby = 'i.title DESC';
break;
case 'order':
if ($params->get('FeaturedItems') == '2') {
$orderby = 'i.featured_ordering';
} else {
$orderby = 'i.ordering';
}
break;
case 'rorder':
if ($params->get('FeaturedItems') == '2') {
$orderby = 'i.featured_ordering DESC';
} else {
$orderby = 'i.ordering DESC';
}
break;
case 'hits':
if ($params->get('popularityRange')) {
$datenow = JFactory::getDate();
$date = K2_JVERSION == '15' ? $datenow->toMySQL() : $datenow->toSql();
$query .= " AND i.created > DATE_SUB('{$date}',INTERVAL " . $params->get('popularityRange') . " DAY) ";
}
$orderby = 'i.hits DESC';
break;
case 'rand':
$orderby = 'RAND()';
break;
case 'best':
$orderby = 'rating DESC';
break;
case 'comments':
if ($params->get('popularityRange')) {
$datenow = JFactory::getDate();
$date = K2_JVERSION == '15' ? $datenow->toMySQL() : $datenow->toSql();
$query .= " AND i.created > DATE_SUB('{$date}',INTERVAL " . $params->get('popularityRange') . " DAY) ";
}
$query .= " GROUP BY i.id ";
$orderby = 'numOfComments DESC';
break;
case 'modified':
$orderby = 'lastChanged DESC';
break;
case 'publishUp':
$orderby = 'i.publish_up DESC';
break;
default:
$orderby = 'i.id DESC';
break;
}
$query .= " ORDER BY " . $orderby;
$db->setQuery($query, 0, $limit);
$items = $db->loadObjectList();
$model = K2Model::getInstance('Item', 'K2Model');
$show_introtext = $params->get('item_desc_display', 0);
$introtext_limit = $params->get('item_desc_max_characs', 100);
if (count($items)) {
foreach ($items as $item) {
//Clean title
$item->name = JFilterOutput::ampReplace($item->title);
//Read more link
$item->link = urldecode(JRoute::_(K2HelperRoute::getItemRoute($item->id . ':' . urlencode($item->alias), $item->catid . ':' . urlencode($item->categoryalias))));
//Comments counter
if ($params->get('itemCommentsCounter')) {
$item->numOfComments = $model->countItemComments($item->id);
}
//author
$item->author = JFactory::getUser($item->created_by)->name;
//Tags
$item->tags = '';
if ($params->get('item_tags_display')) {
$tags = $model->getItemTags($item->id);
for ($i = 0; $i < sizeof($tags); $i++) {
$tags[$i]->link = JRoute::_(K2HelperRoute::getTagRoute($tags[$i]->name));
}
$item->tags = $tags;
}
$item->_introtext = self::_cleanText($item->introtext);
$item->displayIntrotext = $show_introtext ? self::truncate($item->_introtext, $introtext_limit) : '';
$rows[] = $item;
}
return $rows;
}
}
示例13: getItems
//.........这里部分代码省略.........
//Clean title
$item->title = JFilterOutput::ampReplace($item->title);
//Images
if ($params->get('itemImage')) {
if (JFile::exists(JPATH_SITE . DS . 'media' . DS . 'k2' . DS . 'items' . DS . 'cache' . DS . md5("Image" . $item->id) . '_XS.jpg')) {
$item->imageXSmall = JURI::root() . 'media/k2/items/cache/' . md5("Image" . $item->id) . '_XS.jpg';
}
if (JFile::exists(JPATH_SITE . DS . 'media' . DS . 'k2' . DS . 'items' . DS . 'cache' . DS . md5("Image" . $item->id) . '_S.jpg')) {
$item->imageSmall = JURI::root() . 'media/k2/items/cache/' . md5("Image" . $item->id) . '_S.jpg';
}
if (JFile::exists(JPATH_SITE . DS . 'media' . DS . 'k2' . DS . 'items' . DS . 'cache' . DS . md5("Image" . $item->id) . '_M.jpg')) {
$item->imageMedium = JURI::root() . 'media/k2/items/cache/' . md5("Image" . $item->id) . '_M.jpg';
}
if (JFile::exists(JPATH_SITE . DS . 'media' . DS . 'k2' . DS . 'items' . DS . 'cache' . DS . md5("Image" . $item->id) . '_L.jpg')) {
$item->imageLarge = JURI::root() . 'media/k2/items/cache/' . md5("Image" . $item->id) . '_L.jpg';
}
if (JFile::exists(JPATH_SITE . DS . 'media' . DS . 'k2' . DS . 'items' . DS . 'cache' . DS . md5("Image" . $item->id) . '_XL.jpg')) {
$item->imageXLarge = JURI::root() . 'media/k2/items/cache/' . md5("Image" . $item->id) . '_XL.jpg';
}
if (JFile::exists(JPATH_SITE . DS . 'media' . DS . 'k2' . DS . 'items' . DS . 'cache' . DS . md5("Image" . $item->id) . '_Generic.jpg')) {
$item->imageGeneric = JURI::root() . 'media/k2/items/cache/' . md5("Image" . $item->id) . '_Generic.jpg';
}
$image = 'image' . $params->get('itemImgSize', 'Small');
if (isset($item->{$image})) {
$item->image = $item->{$image};
}
}
//Read more link
$item->link = urldecode(JRoute::_(K2HelperRoute::getItemRoute($item->id . ':' . urlencode($item->alias), $item->catid . ':' . urlencode($item->categoryalias))));
//Tags
if ($params->get('itemTags')) {
$tags = $model->getItemTags($item->id);
for ($i = 0; $i < sizeof($tags); $i++) {
$tags[$i]->link = JRoute::_(K2HelperRoute::getTagRoute($tags[$i]->name));
}
$item->tags = $tags;
}
//Category link
if ($params->get('itemCategory')) {
$item->categoryLink = urldecode(JRoute::_(K2HelperRoute::getCategoryRoute($item->catid . ':' . urlencode($item->categoryalias))));
}
//Extra fields
if ($params->get('itemExtraFields')) {
$item->extra_fields = $model->getItemExtraFields($item->extra_fields);
}
//Comments counter
if ($params->get('itemCommentsCounter')) {
$item->numOfComments = $model->countItemComments($item->id);
}
//Attachments
if ($params->get('itemAttachments')) {
$item->attachments = $model->getItemAttachments($item->id);
}
//Import plugins
if ($format != 'feed') {
$dispatcher =& JDispatcher::getInstance();
JPluginHelper::importPlugin('content');
}
//Video
if ($params->get('itemVideo') && $format != 'feed') {
$params->set('vfolder', 'media/k2/videos');
$item->text = $item->video;
$dispatcher->trigger('onPrepareContent', array(&$item, &$params, $limitstart));
$item->video = $item->text;
}
// Introtext
示例14: info
static function info($config, $item, $num = 1)
{
// %AUTHOR %DATE %HITS %CATEGORY
$news_info = '';
//
if ($num == 1) {
if ($config['news_content_info_pos'] != 'disabled') {
$class = 'nspInfo1 t' . $config['news_content_info_pos'] . ' f' . $config['news_content_info_float'];
}
} else {
if ($config['news_content_info2_pos'] != 'disabled') {
$class = 'nspInfo2 t' . $config['news_content_info2_pos'] . ' f' . $config['news_content_info2_float'];
}
}
//
if ($config['news_content_info_pos'] != 'disabled' && $num == 1 || $config['news_content_info2_pos'] != 'disabled' && $num == 2) {
$news_info_tag = stripos($config['info' . ($num == 2 ? '2' : '') . '_format'], '%CART') !== FALSE ? 'div' : 'p';
$news_info = '<' . $news_info_tag . ' class="nspInfo ' . $class . '">' . $config['info' . ($num == 2 ? '2' : '') . '_format'] . '</' . $news_info_tag . '>';
//
$author = trim(htmlspecialchars($item['author_alias'])) != '' ? htmlspecialchars($item['author_alias']) : htmlspecialchars($item['author_username']);
$info_author = $config['user_avatar'] == 1 ? '<span><img src="' . K2HelperUtilities::getAvatar($item['author_id'], $item['author_email'], $config['avatar_size']) . '" alt="' . $author . ' - avatar" class="nspAvatar" width="' . $config['avatar_size'] . '" height="' . $config['avatar_size'] . '" /> ' . $author . '</span>' : $author;
//
$info_date = JHTML::_('date', $item['date'], $config['date_format']);
//
$info_hits = JText::_('MOD_NEWS_PRO_GK5_NHITS') . $item['hits'];
// case when there is no rates
if ($item['rating_count'] == 0) {
$item['rating_count'] = 1;
}
$info_rate = $item['rating_count'] > 0 ? '<span class="nspRate">' . JText::_('MOD_NEWS_PRO_GK5_NSP_RATE') . ' ' . number_format($item['rating_sum'] / $item['rating_count'], 2) . '</span>' : '';
$info_stars = '<span class="nsp-stars">';
$stars_count = floor($item['rating_sum'] / $item['rating_count']);
for ($i = 0; $i < 5; $i++) {
$info_stars .= $i < $stars_count ? '<span class="nsp-star-1"></span>' : '<span class="nsp-star-0"></span>';
}
$info_stars .= '</span>';
$info_category = $config['category_link'] == 1 ? '<a href="' . NSP_GK5_com_k2_View::categoryLink($item) . '" >' . $item['catname'] . '</a>' : $item['catname'];
$info_comments = JText::_('MOD_NEWS_PRO_GK5_NO_COMMENTS');
//
if (isset($item['comments'])) {
if ($item['comments'] == 1) {
$info_comments = JText::_('MOD_NEWS_PRO_GK5_1COMMENT');
} else {
if ($item['comments'] > 1 && $item['comments'] < 5) {
$info_comments = $item['comments'] . ' ' . JText::_('MOD_NEWS_PRO_GK5_MORECOMMENTS');
} else {
if ($item['comments'] >= 5) {
$info_comments = $item['comments'] . ' ' . JText::_('MOD_NEWS_PRO_GK5_MUCHMORECOMMENTS');
}
}
}
}
//
$info_comments_short = '0';
$link = NSP_GK5_com_k2_View::itemLink($item);
//
if (isset($item['comments'])) {
$info_comments_short = $item['comments'];
}
$info_comments_short = '<a href="' . $link . '">' . $info_comments_short . '</a>';
//
$info_tags = '';
if (isset($item['tags']) && count($item['tags']) > 0) {
$i = 0;
foreach ($item['tags'] as $tag) {
$link = urldecode(JRoute::_(K2HelperRoute::getTagRoute($tag)));
if ($i == 0) {
$info_tags .= '<a href="' . $link . '">' . $tag . '</a>';
} else {
$info_tags .= ', <a href="' . $link . '">' . $tag . '</a>';
}
//
$i++;
}
}
// get k2 store data
$k2store_data = array('cart' => '', 'price' => '');
// get K2Store data if necessary
if (stripos($news_info, '%CART') !== FALSE || stripos($news_info, '%PRICE') !== FALSE) {
$k2store_data = NSP_GK5_com_k2_View::k2Store($item);
if (stripos($news_info, '%CART') !== FALSE) {
// load K2Store scripts
$uri = JURI::getInstance();
$document = JFactory::getDocument();
$headData = $document->getHeadData();
// generate keys of script section
$headData_keys = array_keys($headData["scripts"]);
// set variable for false
$engine_founded = false;
// searching phrase mootools in scripts paths
if (array_search($uri->root() . 'media/k2store/js/k2store.js', $headData_keys) > 0) {
$engine_founded = true;
}
// if engine doesn't exists in the head section
if (!$engine_founded) {
// add new script tag connected with mootools from module
$document->addScript($uri->root() . 'media/k2store/js/k2store.noconflict.js');
$document->addScript($uri->root() . 'media/k2store/js/k2store.js');
}
}
//.........这里部分代码省略.........
示例15: generateLayout
function generateLayout($config, $data)
{
/*
Available variables:
{TITLE} - article title
{TEXT} - article text
{URL} - article URL
{IMAGE_SRC} - article image URL
{AUTHOR_EMAIL} - article autor e-mail
{AUTHOR_NAME} - article author name
{CATEGORY} - article category name
{CATEGORY_URL} - article category URL
{HITS} - article hits
{DATE} - article date (gets format from the information block settings)
{RATING} - article rating
K2 specific variables:
{TAGS} - article tag lists
{VIDEO_HTML} - HTML of the article video
{CATEGORY_IMAGE_SRC} - article category image URL
*/
//
// Get the values
//
// Image
$viewClass = 'NSP_GK5_' . $config['source_name'] . '_View';
// Basic data
$title = NSP_GK5_Utils::cutText($data['title'], $config, 'title_limit');
$text = NSP_GK5_Utils::cutText($data['text'], $config, 'news_limit');
// URL
$url = '';
if (isset($data['url'])) {
$url = $data['url'];
} else {
$url = call_user_func(array($viewClass, 'itemLink'), $data, $config);
}
// PHP 5.3:
//$image_src = $viewClass::image($config, $data, true);
$image_src = call_user_func(array($viewClass, 'image'), $config, $data, true);
// Author data
$author_email = $data['author_email'];
$author_name = $data['author'];
// Category data
$category = $data['catname'];
$category_url = '';
if (isset($data['caturl'])) {
$category_url = $data['caturl'];
} else {
$category_url = call_user_func(array($viewClass, 'categoryLink'), $data);
}
// Other data
$hits = $data['hits'];
$date = JHTML::_('date', $data['date'], $config['date_format']);
$rating = $data['rating_count'] > 0 ? number_format($data['rating_sum'] / $data['rating_count'], 2) : 0;
//
// Get the layout text
//
if (is_file(JPATH_ROOT . DS . 'modules' . DS . 'mod_news_pro_gk5' . DS . 'article_formats' . DS . $config['article_format'])) {
// read the format file
$format_file = file_get_contents(JPATH_ROOT . DS . 'modules' . DS . 'mod_news_pro_gk5' . DS . 'article_formats' . DS . $config['article_format']);
// replace values
$to_replace = array('{TITLE}', '{TEXT}', '{URL}', '{IMAGE_SRC}', '{AUTHOR_EMAIL}', '{AUTHOR_NAME}', '{CATEGORY}', '{CATEGORY_URL}', '{HITS}', '{DATE}', '{RATING}');
// values for the replacement
$replacement = array($title, $text, $url, $image_src, $author_email, $author_name, $category, $category_url, $hits, $date, $rating);
// replace values in the format file
$format_file = str_replace($to_replace, $replacement, $format_file);
// replacements only for K2
if (stripos($config['data_source'], 'k2_') !== FALSE) {
// tags list value
$tags = '';
// if tags exists
if (isset($data['tags']) && count($data['tags']) > 0) {
$i = 0;
foreach ($data['tags'] as $tag) {
$link = urldecode(JRoute::_(K2HelperRoute::getTagRoute($tag)));
if ($i == 0) {
$tags .= '<a href="' . $link . '">' . $tag . '</a>';
} else {
$tags .= ', <a href="' . $link . '">' . $tag . '</a>';
}
//
$i++;
}
}
// video HTML value
$video_html = $data['video'];
// category image URL value
$category_image_src = '';
// if the category image exists
if ($data['cat_image'] != '') {
$category_image_src = JURI::root() . 'media/k2/categories/' . $data['cat_image'];
}
// replace values
$to_replace = array('{TAGS}', '{VIDEO_HTML}', '{CATEGORY_IMAGE_SRC}');
// values for the replacement
$replacement = array($tags, $video_html, $category_image_src);
// replace values in the format file
$format_file = str_replace($to_replace, $replacement, $format_file);
}
// parse lang rules
$matches = array();
//.........这里部分代码省略.........