本文整理汇总了PHP中ContentHelperRoute类的典型用法代码示例。如果您正苦于以下问题:PHP ContentHelperRoute类的具体用法?PHP ContentHelperRoute怎么用?PHP ContentHelperRoute使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ContentHelperRoute类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getRelatedAsHtml
/**
* @param $id
* @param $tags
* @return string
*/
public function getRelatedAsHtml($id, $catid, $access, $tags)
{
$count = CedTagsHelper::param('RelatedArticlesCountByTags', 10);
$relatedArticlesTitle = CedTagsHelper::param('RelatedArticlesTitleByTags', "Related Articles");
//$max=max(intval($relatedArticlesCount),array_count_values($termIds));
//find the unique article ids
$contentIds = $this->getUniqueArticleId($tags, $id);
$html = "";
if (is_array($contentIds) && sizeof($contentIds) > 0) {
$rows = $this->getModel($contentIds, $count);
if (empty($rows)) {
return '';
}
$user = JFactory::getUser();
$aid = JVERSION < 1.6 ? $user->get('aid', 0) : max($user->getAuthorisedViewLevels());
$html = '<div class="relateditemsbytags">' . $relatedArticlesTitle . '</div>
<div>
<ul class="relateditems">';
foreach ($rows as $row) {
if ($row->access <= $aid) {
$link = JVERSION < 1.6 ? JRoute::_(ContentHelperRoute::getArticleRoute($row->slug, $row->catslug, $row->sectionid)) : JRoute::_(ContentHelperRoute::getArticleRoute($row->slug, $row->catslug));
} else {
$link = JRoute::_('index.php?option=com_user&view=login');
}
$html .= '<li> <a href="' . $link . '">' . htmlspecialchars($row->title) . '</a></li>';
}
$html .= '</ul></div>';
}
return $html;
}
示例2: getActionForm
public function getActionForm($formAction, $formData, &$return)
{
switch ($formAction) {
case 1:
$return->actionForm = "url";
$return->actionFormData = $formData;
break;
case 2:
$this->_db->setQuery($this->_db->getQuery(true)->select('link')->from("#__menu")->where("id = " . (int) $formData));
$menuItem = $this->_db->loadObject();
$return->actionForm = "url";
$return->actionFormData = isset($menuItem->link) ? $menuItem->link : '';
break;
case 3:
require_once JPATH_SITE . '/components/com_content/helpers/route.php';
$this->_db->setQuery($this->_db->getQuery(true)->select('a.catid,CASE WHEN CHAR_LENGTH(a.alias) THEN CONCAT_WS(":", a.id, a.alias) ELSE a.id END as slug')->from("#__content AS a")->join("LEFT", "#__categories AS cc ON a.catid = cc.id")->where('a.id = ' . (int) $formData));
$article = $this->_db->loadObject();
$return->actionForm = "url";
$return->actionFormData = JRoute::_(ContentHelperRoute::getArticleRoute($article->slug, $article->catid));
break;
case 4:
$return->actionForm = "message";
$return->actionFormData = $formData;
break;
}
}
示例3: getArticle
/**
* Funkce pro načtení dat 1 článku z databáze
*/
function getArticle($articleId, $text = 'all', $skipPlugins = false)
{
$db =& JFactory::getDBO();
$db->setQuery("SELECT * FROM #__content WHERE id='{$articleId}' LIMIT 1;");
$rows = $db->loadObjectList();
if (count($rows) == 1) {
$article = $rows[0]->introtext . $rows[0]->fulltext;
} else {
return false;
}
//připravíme text
if ($text == 'introtext') {
$rows[0]->text = $rows[0]->introtext;
} elseif ($text == 'fulltext') {
$rows[0]->text = $rows[0]->fulltext;
} else {
$rows[0]->text = $rows[0]->introtext . $rows[0]->fulltext;
}
if (!$skipPlugins) {
$dispatcher =& JDispatcher::getInstance();
JPluginHelper::importPlugin("content");
//naimportujeme všechny pluginy pro zpracování obsahu
$rows[0]->parameters = new JParameter($rows[0]->attribs);
//vytvoříme objekt s parametry článku
$results = $dispatcher->trigger('onPrepareContent', array(&$rows[0], &$rows[0]->parameters, 0));
//načtení pluginů
}
//doplnime uri na clanek
$rows[0]->uri = JRoute::_(JURI::root() . ContentHelperRoute::getArticleRoute($rows[0]->id), true, -1);
return $rows[0];
}
示例4: getList
function getList(&$params)
{
global $mainframe;
$db =& JFactory::getDBO();
$user =& JFactory::getUser();
$userId = (int) $user->get('id');
$count = (int) $params->get('count', 5);
$catid = trim($params->get('catid'));
$secid = trim($params->get('secid'));
$show_front = $params->get('show_front', 1);
$aid = $user->get('aid', 0);
$contentConfig =& JComponentHelper::getParams('com_content');
$access = !$contentConfig->get('shownoauth');
$nullDate = $db->getNullDate();
jimport('joomla.utilities.date');
$date = new JDate();
$now = $date->toMySQL();
$where = 'a.state = 1' . ' AND ( a.publish_up = ' . $db->Quote($nullDate) . ' OR a.publish_up <= ' . $db->Quote($now) . ' )' . ' AND ( a.publish_down = ' . $db->Quote($nullDate) . ' OR a.publish_down >= ' . $db->Quote($now) . ' )';
// User Filter
switch ($params->get('user_id')) {
case 'by_me':
$where .= ' AND (created_by = ' . (int) $userId . ' OR modified_by = ' . (int) $userId . ')';
break;
case 'not_me':
$where .= ' AND (created_by <> ' . (int) $userId . ' AND modified_by <> ' . (int) $userId . ')';
break;
}
// Ordering
switch ($params->get('ordering')) {
case 'm_dsc':
$ordering = 'a.modified DESC, a.created DESC';
break;
case 'c_dsc':
default:
$ordering = 'a.created DESC';
break;
}
if ($catid) {
$ids = explode(',', $catid);
JArrayHelper::toInteger($ids);
$catCondition = ' AND (cc.id=' . implode(' OR cc.id=', $ids) . ')';
}
if ($secid) {
$ids = explode(',', $secid);
JArrayHelper::toInteger($ids);
$secCondition = ' AND (s.id=' . implode(' OR s.id=', $ids) . ')';
}
// Content Items only
$query = 'SELECT a.*, ' . ' CASE WHEN CHAR_LENGTH(a.alias) THEN CONCAT_WS(":", a.id, a.alias) ELSE a.id END as slug,' . ' CASE WHEN CHAR_LENGTH(cc.alias) THEN CONCAT_WS(":", cc.id, cc.alias) ELSE cc.id END as catslug' . ' FROM #__content AS a' . ($show_front == '0' ? ' LEFT JOIN #__content_frontpage AS f ON f.content_id = a.id' : '') . ' INNER JOIN #__categories AS cc ON cc.id = a.catid' . ' INNER JOIN #__sections AS s ON s.id = a.sectionid' . ' WHERE ' . $where . ' AND s.id > 0' . ($access ? ' AND a.access <= ' . (int) $aid . ' AND cc.access <= ' . (int) $aid . ' AND s.access <= ' . (int) $aid : '') . ($catid ? $catCondition : '') . ($secid ? $secCondition : '') . ($show_front == '0' ? ' AND f.content_id IS NULL ' : '') . ' AND s.published = 1' . ' AND cc.published = 1' . ' ORDER BY ' . $ordering;
$db->setQuery($query, 0, $count);
$rows = $db->loadObjectList();
$i = 0;
$lists = array();
foreach ($rows as $row) {
$lists[$i]->link = JRoute::_(ContentHelperRoute::getArticleRoute($row->slug, $row->catslug, $row->sectionid));
$lists[$i]->text = htmlspecialchars($row->title);
$i++;
}
return $lists;
}
示例5: getRelatedItemsJumpList
function getRelatedItemsJumpList()
{
$cids = func_get_args();
$groups = count($cids) > 1 ? true : false;
$list = '<select class="relatedtech" name="data[related][]" onchange="window.location=this.value;return false;">' . "\n";
$list .= '<option value="" selection="selected">Velg...</option>' . "\n";
foreach ($cids as $catID) {
if (!is_numeric($catID)) {
continue;
}
$db =& JFactory::getDBO();
$sql = "SELECT c.id, c.title, c.catid, c.sectionid, cat.title AS cat_title FROM #__content c " . "LEFT JOIN #__categories cat ON c.catid = cat.id " . "WHERE catid='{$catID}' AND c.state > 0 ORDER BY title";
$db->setQuery($sql);
$items = $db->loadObjectList();
if ($groups && count($items) > 1) {
$list .= '<optgroup label="' . $items[0]->cat_title . '">' . "\n";
}
require_once JPATH_SITE . DS . 'components' . DS . 'com_content' . DS . 'helpers' . DS . 'route.php';
foreach ($items as $item) {
$listinglink = ContentHelperRoute::getArticleRoute($item->id, $item->catid, $item->sectionid);
$list .= '<option value="' . $listinglink . '">' . $item->title . '</option>' . "\n";
}
if ($groups && count($items) > 1) {
$list .= '</optgroup>' . "\n";
}
}
$list .= '</select>' . "\n";
return $list;
}
示例6: renderItem
function renderItem(&$item, &$params, &$access)
{
global $mainframe;
$user =& JFactory::getUser();
$item->text = $item->introtext;
$item->groups = '';
$item->readmore = trim($item->fulltext) != '';
$item->metadesc = '';
$item->metakey = '';
$item->access = '';
$item->created = '';
$item->modified = '';
if ($params->get('readmore') || $params->get('link_titles')) {
if ($params->get('intro_only')) {
// Check to see if the user has access to view the full article
if ($item->access <= $user->get('aid', 0)) {
$linkOn = ContentHelperRoute::getArticleRoute($item->slug, $item->catslug);
} else {
$linkOn = JRoute::_('index.php?option=com_user&task=register');
}
}
$item->linkOn = $linkOn;
}
$results = $mainframe->triggerEvent('onAfterDisplayTitle', array(&$item, &$params, 1));
$item->afterDisplayTitle = trim(implode("\n", $results));
$results = $mainframe->triggerEvent('onBeforeDisplayContent', array(&$item, &$params, 1));
$item->beforeDisplayContent = trim(implode("\n", $results));
require JModuleHelper::getLayoutPath('mod_yoo_drawer', '_item');
}
示例7: getContent
/**
* Generate content
* @param object The article object. Note $article->text is also available
* @param object The article params
* @param boolean Modules context
* @return string Returns html code or empty string.
*/
private function getContent(&$article, &$params, $moduleContext = false)
{
$doc = JFactory::getDocument();
/* @var $doc JDocumentHtml */
$doc->addStyleSheet(JURI::root() . "plugins/content/fastsocialshare/style/style.css");
$uriInstance = JURI::getInstance();
if (!$moduleContext) {
if (!class_exists('ContentHelperRoute')) {
include_once JPATH_SITE . '/components/com_content/helpers/route.php';
}
$url = JRoute::_(ContentHelperRoute::getArticleRoute($article->slug, $article->catslug), false);
$root = rtrim($uriInstance->getScheme() . '://' . $uriInstance->getHost(), '/');
$url = $root . $url;
$title = htmlentities($article->title, ENT_QUOTES, "UTF-8");
} else {
$url = JURI::current();
$title = htmlentities($doc->title, ENT_QUOTES, "UTF-8");
}
$html = $this->getFacebookLike($this->params, $url, $title);
$html .= $this->getFacebookShareMe($this->params, $url, $title);
$html .= $this->getTwitter($this->params, $url, $title);
$html .= $this->getGooglePlusOne($this->params, $url, $title);
$html .= $this->getLinkedIn($this->params, $url, $title);
$html .= $this->getPinterest($this->params, $url, $title);
return '<div class="fastsocialshare_container">' . $html . '<div class="fastsocialshare_clearer"></div></div>';
}
示例8: renderItem
function renderItem(&$item, &$params, &$access)
{
global $mainframe;
$user =& JFactory::getUser();
$item->text = $item->introtext;
$item->groups = '';
$item->readmore = trim($item->fulltext) != '';
$item->metadesc = '';
$item->metakey = '';
$item->created = '';
$item->modified = '';
if ($params->get('readmore') || $params->get('link_titles')) {
if ($params->get('intro_only')) {
// Check to see if the user has access to view the full article
if ($item->access <= $user->get('aid', 0)) {
$itemparams = new JParameter($item->attribs);
$readmoretxt = $itemparams->get('readmore', JText::_('Read more text'));
$item->linkOn = JRoute::_(ContentHelperRoute::getArticleRoute($item->slug, $item->catslug, $item->sectionid));
$item->linkText = $readmoretxt;
} else {
$item->linkOn = JRoute::_('index.php?option=com_user&view=login');
$item->linkText = JText::_('Login To Read More');
}
}
}
if (!$params->get('image')) {
$item->text = preg_replace('/<img[^>]*>/', '', $item->text);
}
$results = $mainframe->triggerEvent('onAfterDisplayTitle', array(&$item, &$params, 1));
$item->afterDisplayTitle = trim(implode("\n", $results));
$results = $mainframe->triggerEvent('onBeforeDisplayContent', array(&$item, &$params, 1));
$item->beforeDisplayContent = trim(implode("\n", $results));
require JModuleHelper::getLayoutPath('mod_newsflash', '_item');
}
示例9: _getList
protected function _getList($params, $module){
$this->params = $params;
$list = array();
$source_category = $params->get('source');
$items = $this->getCategoryItems($source_category, $params);
if(!empty($items)) {
include_once JPATH_SITE . DS . 'components' . DS . 'com_content' . DS . 'helpers' . DS . 'route.php';
$custom = $this->_getCustomUrl($params);
foreach($items as $key => $item){
$category = $this->getCategory($item->catid);
$item->catitle = $category->title;
if(!$this->getItemImage($item)){
$item->image = 'modules/'.Ytools::getModule()->module . '/assets/images/nophoto.png';
}
if(array_key_exists($item->id, $custom)){
$item->link= trim($custom[$item->id]->url);
}else{
$item->link = JRoute::_(ContentHelperRoute::getArticleRoute($item->id, $item->catid));
}
$item->description = strip_tags($item->introtext);
}
}
return $items;
}
示例10: getData
function getData($ids)
{
// prepare an array
$results = array();
// prepare an query part
$query_ids = implode(',', $ids);
// generate the query
$database = JFactory::getDBO();
// SQL query for slides
$query = '
SELECT
`c`.`id` AS `id`,
`c`.`catid` AS `cid`,
`c`.`title` AS `title`
FROM
#__content AS `c`
WHERE
`c`.`id` IN (' . $query_ids . ')
;';
// running query
$database->setQuery($query);
// if results exists
if ($datas = $database->loadObjectList()) {
// parsing data
foreach ($datas as $item) {
// array with prepared image
$results[$item->id] = array('id' => $item->id, 'cid' => $item->cid, 'title' => stripslashes($item->title), 'link' => JRoute::_(ContentHelperRoute::getArticleRoute($item->id, $item->cid)));
}
}
// return the results
return $results;
}
示例11: 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;
}
示例12: display
function display($tpl = null)
{
global $mainframe;
// parameters
$db =& JFactory::getDBO();
$document =& JFactory::getDocument();
$params =& $mainframe->getParams();
$document->link = JRoute::_('index.php?option=com_content&view=frontpage');
// Get some data from the model
JRequest::setVar('limit', $mainframe->getCfg('feed_limit'));
$rows =& $this->get('Data');
foreach ($rows as $row) {
// strip html from feed item title
$title = $this->escape($row->title);
$title = html_entity_decode($title);
// url link to article
$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 = 'frontpage';
// loads item info into rss array
$document->addItem($item);
}
}
示例13: email
/**
* Icon for email
*
* @param object $member Member info
* @param JRegistry $params HTML Params
* @param array $attribs Member attribs
*
* @return string
*
* @since 1.5
*/
public static function email($member, $params, $attribs = [])
{
require_once JPATH_SITE . '/components/com_mailto/helpers/mailto.php';
$uri = JUri::getInstance();
$base = $uri->toString(['scheme', 'host', 'port']);
$link = $base . JRoute::_(ContentHelperRoute::getArticleRoute($member->slug, $member->catid), false);
$url = 'index.php?option=com_mailto&tmpl=component&link=' . MailtoHelper::addLink($link);
$status = 'width=400,height=350,menubar=yes,resizable=yes';
if ($params->get('show_icons'))
{
$text = JHtml::_('image', 'system/emailButton.png', JText::_('JGLOBAL_EMAIL'), null, true);
}
else
{
$text = ' ' . JText::_('JGLOBAL_EMAIL');
}
$attribs['title'] = JText::_('JGLOBAL_EMAIL');
$attribs['onclick'] = "window.open(this.href,'win2','" . $status . "'); return false;";
$output = JHtml::_('link', JRoute::_($url), $text, $attribs);
return $output;
}
示例14: onContentPrepare
/**
* onContentPrepare
*
* Replaces IMG H5P placeholder with an iFrame.
*/
public function onContentPrepare($context, &$article, &$params, $page = 0)
{
$matches = array();
if (preg_match_all($this->h5p_re, $article->text, $matches, PREG_SET_ORDER)) {
// We need to add a little script
$doc = JFactory::getDocument();
$doc->addScript(JURI::root(true) . '/libraries/h5pcore/core/js/jquery.js' . $this->fileSuffix);
$doc->addScript(JURI::root(true) . '/libraries/h5pcore/core/js/h5p.js' . $this->fileSuffix);
$doc->addScript(JURI::root(true) . '/libraries/h5pcore/js/h5piframeresize.js' . $this->fileSuffix);
$doc->addStyleSheet(JURI::root(true) . '/libraries/h5pcore/core/styles/h5p.css' . $this->fileSuffix);
$doc->addStyleSheet(JURI::root(true) . '/libraries/h5pcore/media/h5pdisplay.css' . $this->fileSuffix);
$html = '<div class="h5p-iframe-wrapper" id="iframe-wrapper-##h5pId##">';
$html .= '<iframe id="iframe-##h5pId##" class="h5p-iframe" src="##iframeSrc##" style="width: 100%; height: 400px; border: none;"></iframe>';
$html .= '</div>';
$article_url = JRoute::_(ContentHelperRoute::getArticleRoute($article->id, $article->catid, $article->itemid)) . "-{$article->alias}";
foreach ($matches as $key => $match) {
$h5pId = $match[1];
$h5pDomId = str_replace('.', '_', $h5pId);
// Periods make jQuery unhappy.
if ($context === 'com_content.article') {
$iframeSrc = 'index.php?option=com_h5p&view=h5p&layout=view&tmpl=component&cid=' . $h5pId;
$replacement = str_replace(array('##h5pId##', '##iframeSrc##'), array($h5pDomId, $iframeSrc), $html);
$article->text = preg_replace('/\\<img.*?h5p-placeholder-image.*?data-content-id\\=\\"' . $h5pId . '\\".*?\\>/', $replacement, $article->text, 1);
$this->registerStartTime($h5pId);
} elseif (isset($article->id)) {
$article->text = preg_replace('/\\<img.*?h5p-placeholder-image.*?data-content-id\\=\\"' . $h5pId . '\\".*?\\>/', '<a href="' . $article_url . '">$0</a>', $article->text, 1);
} else {
$article->text = preg_replace('/\\<img.*?h5p-placeholder-image.*?data-content-id\\=\\"' . $h5pId . '\\".*?\\>/', '', $article->text, 1);
}
}
}
}
示例15: _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;
}