本文整理汇总了PHP中ContentHelperRoute::getCategoryRoute方法的典型用法代码示例。如果您正苦于以下问题:PHP ContentHelperRoute::getCategoryRoute方法的具体用法?PHP ContentHelperRoute::getCategoryRoute怎么用?PHP ContentHelperRoute::getCategoryRoute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ContentHelperRoute
的用法示例。
在下文中一共展示了ContentHelperRoute::getCategoryRoute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getBacklink
function getBacklink($id, $type, $category = true)
{
$db =& JFactory::getDBO();
if (!$category) {
$query = "SELECT articleid from #__fieldsattach_values WHERE (value LIKE '%," . $id . ",%' OR value LIKE '" . $id . ",%' OR value LIKE '%," . $id . "' OR value LIKE '" . $id . "') AND fieldsid = 23";
} else {
$query = "SELECT catid from #__fieldsattach_categories_values WHERE (value LIKE '%," . $id . ",%' OR value LIKE '" . $id . ",%' OR value LIKE '%," . $id . "' OR value LIKE '" . $id . "') AND fieldsid = 22";
}
$db->setQuery($query);
$result = $db->loadObjectList();
$function = '';
foreach ($result as $item) {
if (!$category) {
$parent = getParent(getCategory($item->articleid));
} else {
$parent = getParent($item->catid);
}
if ($parent == $type) {
if (!$category) {
$function .= '<li><a href="' . ContentHelperRoute::getArticleRoute($item->articleid, $parent) . '">' . getTitle($item->articleid, $category) . '</a></li>';
} else {
$function .= '<li><a href="' . ContentHelperRoute::getCategoryRoute($item->catid, $parent) . '">' . getTitle($item->catid, $category) . '</a></li>';
}
}
}
return $function;
}
示例2: format
private function format(&$articles, $params)
{
if (!$articles) {
return;
}
foreach ($articles as $article) {
$category = JTable::getInstance('Category');
$category->load($article->catid);
$article->category = $category;
$article->permalink = ContentHelperRoute::getArticleRoute($article->id . ':' . $article->alias, $article->catid);
$article->permalink = JRoute::_($article->permalink);
$article->category->permalink = ContentHelperRoute::getCategoryRoute($category->id . ':' . $category->alias);
$article->category->permalink = JRoute::_($article->category->permalink);
$article->content = empty($article->introtext) ? $article->fulltext : $article->introtext;
$titleLength = $params->get('title_length');
$contentLength = $params->get('content_length');
if ($titleLength) {
$article->title = JString::substr($article->title, 0, $titleLength);
}
// Try to get image of the article
$image = $this->processContentImage($article->content);
if ($image) {
$article->image = $image;
}
if ($contentLength) {
$article->content = JString::substr(strip_tags($article->content), 0, $contentLength) . ' ...';
} else {
$base = JURI::base(true) . '/';
$protocols = '[a-zA-Z0-9]+:';
//To check for all unknown protocals (a protocol must contain at least one alpahnumeric fillowed by :
$regex = '#(src|href|poster)="(?!/|' . $protocols . '|\\#|\')([^"]*)"#m';
$article->content = preg_replace($regex, "\$1=\"{$base}\$2\"", $article->content);
}
}
}
示例3: display
function display()
{
global $mainframe;
$doc =& JFactory::getDocument();
$params =& $mainframe->getParams();
// Get some data from the model
JRequest::setVar('limit', $mainframe->getCfg('feed_limit'));
$category =& $this->get('Category');
$rows =& $this->get('Data');
$doc->link = JRoute::_(ContentHelperRoute::getCategoryRoute($category->id, $category->sectionid));
foreach ($rows as $row) {
// strip html from feed item title
$title = $this->escape($row->title);
$title = html_entity_decode($title);
// url link to article
// & used instead of & as this is converted by feed creator
$link = JRoute::_(ContentHelperRoute::getArticleRoute($row->slug, $row->catslug, $row->sectionid));
// strip html from feed item description text
$description = $params->get('feed_summary', 0) ? $row->introtext . $row->fulltext : $row->introtext;
$author = $row->created_by_alias ? $row->created_by_alias : $row->author;
// load individual item creator class
$item = new JFeedItem();
$item->title = $title;
$item->link = $link;
$item->description = $description;
$item->date = $row->created;
$item->category = $row->category;
// loads item info into rss array
$doc->addItem($item);
}
}
示例4: display
function display()
{
$app = JFactory::getApplication();
$doc =& JFactory::getDocument();
$params =& $app->getParams();
// Get some data from the model
JRequest::setVar('limit', $app->getCfg('feed_limit'));
$category =& $this->get('Category');
$rows =& $this->get('Data');
$doc->link = JRoute::_(ContentHelperRoute::getCategoryRoute($category->id, $cagtegory->sectionid));
foreach ($rows as $row) {
// strip html from feed item title
$title = $this->escape($row->title);
$title = html_entity_decode($title);
// url link to article
// & used instead of & as this is converted by feed creator
$link = JRoute::_(ContentHelperRoute::getArticleRoute($row->slug, $row->catslug, $row->sectionid));
// strip html from feed item description text
// TODO: Only pull fulltext if necessary (actually, just get the necessary fields).
$description = $params->get('feed_summary', 0) ? $row->introtext : $row->introtext;
$author = $row->created_by_alias ? $row->created_by_alias : $row->author;
@($date = $row->created ? date('r', strtotime($row->created)) : '');
// load individual item creator class
$item = new JFeedItem();
$item->title = $title;
$item->link = $link;
$item->description = $description;
$item->date = $date;
$item->category = $row->category;
// loads item info into rss array
$doc->addItem($item);
}
}
示例5: _prepareItem
/**
*
* @param object $item
* @return object
*/
protected function _prepareItem($item)
{
$item->link = JRoute::_(ContentHelperRoute::getArticleRoute($item->slug, $item->catslug));
$item->introtext = JHtml::_('string.truncate', $item->introtext, $this->_params->get('intro_length', 200));
$item->cat_link = JRoute::_(ContentHelperRoute::getCategoryRoute($item->catid));
return $item;
}
示例6: __construct
function __construct($component, $componentParams, $article, $articleParams)
{
parent::__construct($component, $componentParams, $article, $articleParams);
$this->category = $this->_articleParams->get('show_category') ? $this->_article->category_title : '';
$this->categoryLink = $this->_articleParams->get('link_category') ? JRoute::_(ContentHelperRoute::getCategoryRoute($this->_article->catid)) : '';
$this->parentCategory = $this->_articleParams->get('show_parent_category') && $this->_article->parent_id != 1 ? $this->_article->parent_title : '';
$this->parentCategoryLink = $this->_articleParams->get('link_parent_category') ? JRoute::_(ContentHelperRoute::getCategoryRoute($this->_article->parent_id)) : '';
}
示例7: __construct
public function __construct($component, $componentParams, $article, $articleParams)
{
parent::__construct($component, $componentParams, $article, $articleParams);
$this->titleLink = $this->_articleParams->get('link_titles') ? JRoute::_(ContentHelperRoute::getArticleRoute($this->_article->slug, $this->_article->catslug)) : '';
$this->category = $this->_articleParams->get('show_category') ? $this->_article->category_title : '';
$this->categoryLink = $this->_articleParams->get('link_category') && $this->_article->catslug ? JRoute::_(ContentHelperRoute::getCategoryRoute($this->_article->catslug)) : '';
$this->parentCategoryLink = $this->_articleParams->get('link_parent_category') && $this->_article->parent_slug ? JRoute::_(ContentHelperRoute::getCategoryRoute($this->_article->parent_slug)) : '';
$this->intro = $this->_articleParams->get('show_intro') ? $this->_article->introtext : '';
}
示例8: getCategoryLink
/**
* Get category link url by category id.
*
* @param integer $catid Category id to load Table.
* @param bool $absolute Ture to return whole absolute url.
*
* @return string Category link url.
*/
public static function getCategoryLink($catid, $absolute = false)
{
include_once JPATH_ROOT . '/components/com_content/helpers/route.php';
$path = \ContentHelperRoute::getCategoryRoute($catid);
if ($absolute) {
return \JUri::root() . $path;
} else {
return $path;
}
}
示例9: getTitleLink
/**
* Method to get the item title link
*
* @return string The title link
*/
protected function getTitleLink()
{
if ($this->client_id) {
$link = 'index.php?option=com_categories' . '&task=' . $this->item->name . '.edit' . '&id=' . (int) $this->item->item_id;
} else {
$item_slug = $this->item->item_id . ':' . $this->item->metadata->get('alias');
$link = ContentHelperRoute::getCategoryRoute($item_slug);
}
return JRoute::_($link);
}
示例10: getCategoryAssociations
/**
* Method to get the associations for a given category
*
* @param integer $id Id of the item
* @param string $extension Name of the component
*
* @return array Array of associations for the component categories
*
* @since 3.0
*/
public static function getCategoryAssociations($id = 0, $extension = 'com_content')
{
$return = array();
if ($id) {
$associations = CategoriesHelper::getAssociations($id, $extension);
foreach ($associations as $tag => $item) {
$return[$tag] = ContentHelperRoute::getCategoryRoute($item, $tag);
}
}
return $return;
}
示例11: getCategoryLink
/**
* Get category link url by category id.
*
* @param integer $catid Category id to load Table.
* @param boolean $absolute Ture to return whole absolute url.
*
* @return type
*/
public static function getCategoryLink($catid, $absolute = 0)
{
include_once JPATH_ROOT . DS . 'components' . DS . 'com_content' . DS . 'helpers' . DS . 'route.php';
$path = JRoute::_(ContentHelperRoute::getCategoryRoute($catid));
$host = str_replace('http://' . $_SERVER['HTTP_HOST'], '', JURI::root());
$path = str_replace($host, '', $path);
if ($absolute) {
return AKHelper::_('uri.pathAddHost', $path);
} else {
return $path;
}
}
示例12: display
public function display($tpl = null)
{
$app = JFactory::getApplication();
$doc = JFactory::getDocument();
$params = $app->getParams();
$feedEmail = $app->getCfg('feed_email', 'author');
$siteEmail = $app->getCfg('mailfrom');
// Get some data from the model
$app->input->set('limit', $app->getCfg('feed_limit'));
$category = $this->get('Category');
$rows = $this->get('Items');
$doc->link = JRoute::_(ContentHelperRoute::getCategoryRoute($category->id));
foreach ($rows as $row) {
// Strip html from feed item title
$title = $this->escape($row->title);
$title = html_entity_decode($title, ENT_COMPAT, 'UTF-8');
// Compute the article slug
$row->slug = $row->alias ? $row->id . ':' . $row->alias : $row->id;
// Url link to article
$link = JRoute::_(ContentHelperRoute::getArticleRoute($row->slug, $row->catid));
// Get row fulltext
$db = JFactory::getDBO();
$query = 'SELECT' . $db->quoteName('fulltext') . 'FROM #__content WHERE id =' . $row->id;
$db->setQuery($query);
$row->fulltext = $db->loadResult();
// Get description, author and date
$description = $params->get('feed_summary', 0) ? $row->introtext . $row->fulltext : $row->introtext;
$author = $row->created_by_alias ? $row->created_by_alias : $row->author;
@($date = $row->publish_up ? date('r', strtotime($row->publish_up)) : '');
// Load individual item creator class
$item = new JFeedItem();
$item->title = $title;
$item->link = $link;
$item->date = $date;
$item->category = $row->category_title;
$item->author = $author;
if ($feedEmail == 'site') {
$item->authorEmail = $siteEmail;
} elseif ($feedEmail === 'author') {
$item->authorEmail = $row->author_email;
}
// Add readmore link to description if introtext is shown, show_readmore is true and fulltext exists
if (!$params->get('feed_summary', 0) && $params->get('feed_show_readmore', 0) && $row->fulltext) {
$description .= '<p class="feed-readmore"><a target="_blank" href ="' . $item->link . '">' . JText::_('COM_CONTENT_FEED_READMORE') . '</a></p>';
}
// Load item description and add div
$item->description = '<div class="feed-description">' . $description . '</div>';
// Loads item info into rss array
$doc->addItem($item);
}
}
示例13: __construct
public function __construct($component, $componentParams, $article, $articleParams, $properties)
{
parent::__construct($component, $componentParams, $article, $articleParams);
$this->print = isset($properties['print']) ? $properties['print'] : '';
$this->pageHeading = $this->_componentParams->get('show_page_heading', 1) ? $this->_componentParams->get('page_heading') : '';
$this->titleLink = $this->_articleParams->get('link_titles') && !empty($this->_article->readmore_link) ? $this->_article->readmore_link : '';
$this->emailIconVisible = $this->emailIconVisible && !$this->print;
$this->editIconVisible = $this->editIconVisible && !$this->print;
$this->categoryLink = $this->_articleParams->get('link_category') && $this->_article->catslug ? JRoute::_(ContentHelperRoute::getCategoryRoute($this->_article->catslug)) : '';
$this->category = $this->_articleParams->get('show_category') ? $this->_article->category_title : '';
$this->categoryLink = $this->_articleParams->get('link_category') && $this->_article->catslug ? JRoute::_(ContentHelperRoute::getCategoryRoute($this->_article->catslug)) : '';
$this->parentCategory = $this->_articleParams->get('show_parent_category') && $this->_article->parent_slug != '1:root' ? $this->_article->parent_title : '';
$this->parentCategoryLink = $this->_articleParams->get('link_parent_category') && $this->_article->parent_slug ? JRoute::_(ContentHelperRoute::getCategoryRoute($this->_article->parent_slug)) : '';
$this->author = $this->_articleParams->get('show_author') && !empty($this->_article->author) ? $this->_article->created_by_alias ? $this->_article->created_by_alias : $this->_article->author : '';
if (strlen($this->author) && $this->_articleParams->get('link_author')) {
$needle = 'index.php?option=com_contact&view=contact&id=' . $this->_article->contactid;
$menu = JFactory::getApplication()->getMenu();
$item = $menu->getItems('link', $needle, true);
$this->authorLink = !empty($item) ? $needle . '&Itemid=' . $item->id : $needle;
} else {
$this->authorLink = '';
}
$this->toc = isset($this->_article->toc) ? $this->_article->toc : '';
$this->text = $this->_articleParams->get('access-view') ? $this->_article->text : '';
$user = JFactory::getUser();
$this->introVisible = !$this->_articleParams->get('access-view') && $this->_articleParams->get('show_noauth') && $user->get('guest');
$this->intro = $this->_article->introtext;
if (!$this->_articleParams->get('access-view') && $this->_articleParams->get('show_noauth') && $user->get('guest') && $this->_articleParams->get('show_readmore') && $this->_article->fulltext != null) {
$attribs = json_decode($this->_article->attribs);
if ($attribs->alternative_readmore == null) {
$this->readmore = JText::_('COM_CONTENT_REGISTER_TO_READ_MORE');
} elseif ($this->readmore = $this->_article->alternative_readmore) {
if ($this->_articleParams->get('show_readmore_title', 0) != 0) {
$this->readmore .= JHtml::_('string.truncate', $this->_article->title, $this->_articleParams->get('readmore_limit'));
}
} elseif ($this->_articleParams->get('show_readmore_title', 0) == 0) {
$this->readmore = JText::sprintf('COM_CONTENT_READ_MORE_TITLE');
} else {
$this->readmore = JText::_('COM_CONTENT_READ_MORE') . JHtml::_('string.truncate', $this->_article->title, $this->_articleParams->get('readmore_limit'));
}
$link = new JURI(JRoute::_('index.php?option=com_users&view=login'));
$this->readmoreLink = $link->__toString();
} else {
$this->readmore = '';
$this->readmoreLink = '';
}
$this->paginationPosition = isset($this->_article->pagination) && $this->_article->pagination && isset($this->_article->paginationposition) ? ($this->_article->paginationposition ? 'below' : 'above') . ' ' . ($this->_article->paginationrelative ? 'full article' : 'text') : '';
$this->showLinks = isset($this->_article->urls) && is_string($this->_article->urls) && !empty($this->_article->urls);
}
示例14: getLinks
protected function getLinks()
{
$db =& JFactory::getDBO();
$query = $db->getQuery(true);
$query->select('id, alias');
$query->from('#__categories');
$query->where('level > 0 AND extension = "com_content"');
$query->order('alias', 'asc');
$db->setQuery($query);
$this->items = $db->loadObjectList();
foreach ($this->items as $key => $item) {
$this->items[$key]->link = JRoute::_(ContentHelperRoute::getCategoryRoute($item->id));
}
return $this->items;
}
示例15: onSearch
/**
* Categories Search method
*
* The sql must return the following fields that are
* used in a common display routine: href, title, section, created, text,
* browsernav
* @param string Target search string
* @param string mathcing option, exact|any|all
* @param string ordering option, newest|oldest|popular|alpha|category
* @param mixed An array if restricted to areas, null if search all
*/
function onSearch($text, $phrase = '', $ordering = '', $areas = null)
{
$db =& JFactory::getDbo();
$user =& JFactory::getUser();
$groups = implode(',', $user->authorisedLevels());
$searchText = $text;
require_once JPATH_SITE . DS . 'components' . DS . 'com_content' . DS . 'helpers' . DS . 'route.php';
if (is_array($areas)) {
if (!array_intersect($areas, array_keys(plgSearchCategoryAreas()))) {
return array();
}
}
// load plugin params info
$plugin =& JPluginHelper::getPlugin('search', 'categories');
$pluginParams = new JParameter($plugin->params);
$limit = $pluginParams->def('search_limit', 50);
$text = trim($text);
if ($text == '') {
return array();
}
switch ($ordering) {
case 'alpha':
$order = 'a.title ASC';
break;
case 'category':
case 'popular':
case 'newest':
case 'oldest':
default:
$order = 'a.title DESC';
}
$text = $db->Quote('%' . $db->getEscaped($text, true) . '%', false);
$query = 'SELECT a.title, a.description AS text, "" AS created, "2" AS browsernav, a.id AS catid,' . ' CASE WHEN CHAR_LENGTH(a.alias) THEN CONCAT_WS(":", a.id, a.alias) ELSE a.id END as slug' . ' FROM #__categories AS a' . ' WHERE (a.title LIKE ' . $text . ' OR a.description LIKE ' . $text . ')' . ' AND a.published = 1' . ' AND a.access IN (' . $groups . ')' . ' GROUP BY a.id' . ' ORDER BY ' . $order;
$db->setQuery($query, 0, $limit);
$rows = $db->loadObjectList();
$count = count($rows);
for ($i = 0; $i < $count; $i++) {
$rows[$i]->href = ContentHelperRoute::getCategoryRoute($rows[$i]->slug);
$rows[$i]->section = JText::_('Category');
}
$return = array();
foreach ($rows as $key => $category) {
if (searchHelper::checkNoHTML($category, $searchText, array('name', 'title', 'text'))) {
$return[] = $category;
}
}
return $return;
}