function renderItem(&$item, &$params, &$access) { $app =& JFactory::getApplication(); $user =& JFactory::getUser(); $groups = $user->authorisedLevels(); $groups = implode(',', $groups); $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 (in_array($item->access, $groups)) { $item->linkOn = JRoute::_(ContentRoute::article($item->slug, $item->catslug, $item->sectionid)); $item->linkText = JText::_('Read more text'); } else { $item->linkOn = JRoute::_('index.php?option=com_users&view=login'); $item->linkText = JText::_('Login To Read More'); } } } if (!$params->get('image')) { $item->text = preg_replace('/<img[^>]*>/', '', $item->text); } $results = $app->triggerEvent('onAfterDisplayTitle', array(&$item, &$params, 1)); $item->afterDisplayTitle = trim(implode("\n", $results)); $results = $app->triggerEvent('onBeforeDisplayContent', array(&$item, &$params, 1)); $item->beforeDisplayContent = trim(implode("\n", $results)); require JModuleHelper::getLayoutPath('mod_newsflash', '_item'); }
protected static function _findItemId($needles) { // Prepare the reverse lookup array. if (self::$lookup === null) { self::$lookup = array(); $component =& JComponentHelper::getComponent('com_content'); $menus =& JApplication::getMenu('site', array()); $items = $menus->getItems('component_id', $component->id); foreach ($items as &$item) { if (isset($item->query) && isset($item->query['view'])) { $view = $item->query['view']; if (!isset(self::$lookup[$view])) { self::$lookup[$view] = array(); } if (isset($item->query['id'])) { self::$lookup[$view][$item->query['id']] = $item->id; } } } } $match = null; foreach ($needles as $view => $id) { if (isset(self::$lookup[$view])) { if (isset(self::$lookup[$view][$id])) { return self::$lookup[$view][$id]; } } } return null; }
function getList($params) { $db =& JFactory::getDbo(); $user =& JFactory::getUser(); $userId = (int) $user->get('id'); $count = intval($params->get('count', 5)); $groups = $user->authorisedLevels(); $groups = implode(',', $groups); $date =& JFactory::getDate(); $option = JRequest::getCmd('option'); $view = JRequest::getCmd('view'); $temp = JRequest::getString('id'); $temp = explode(':', $temp); $id = $temp[0]; $showDate = $params->get('showDate', 0); $nullDate = $db->getNullDate(); $now = $date->toMySQL(); $related = array(); if ($option == 'com_content' && $view == 'article' && $id) { // select the meta keywords from the item $query = 'SELECT metakey' . ' FROM #__content' . ' WHERE id = ' . (int) $id; $db->setQuery($query); if ($metakey = trim($db->loadResult())) { // explode the meta keys on a comma $keys = explode(',', $metakey); $likes = array(); // assemble any non-blank word(s) foreach ($keys as $key) { $key = trim($key); if ($key) { $likes[] = ',' . $db->getEscaped($key) . ','; // surround with commas so first and last items have surrounding commas } } if (count($likes)) { // select other items based on the metakey field 'like' the keys found $query = 'SELECT a.id, a.title, DATE_FORMAT(a.created, "%Y-%m-%d") AS created, a.catid, cc.access AS cat_access, cc.published AS cat_state,' . ' 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' . ' LEFT JOIN #__content_frontpage AS f ON f.content_id = a.id' . ' LEFT JOIN #__categories AS cc ON cc.id = a.catid' . ' WHERE a.id != ' . (int) $id . ' AND a.state = 1' . ' AND a.access IN (' . implode(',', $groups) . ')' . ' AND (CONCAT(",", REPLACE(a.metakey,", ",","),",") LIKE "%' . implode('%" OR CONCAT(",", REPLACE(a.metakey,", ",","),",") LIKE "%', $likes) . '%")' . ' 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) . ')'; $db->setQuery($query); $temp = $db->loadObjectList(); if (count($temp)) { foreach ($temp as $row) { if (($row->cat_state == 1 || $row->cat_state == '') && ($row->sec_state == 1 || $row->sec_state == '') && (in_array($row->cat_access, $groups) || $row->cat_access == '') && (in_array($row->sec_access, $groups) || $row->sec_access == '')) { $row->route = JRoute::_(ContentRoute::article($row->slug, $row->catslug, $row->sectionid)); $related[] = $row; } } } unset($temp); } } } return $related; }
static function email($article, $params, $attribs = array()) { $uri =& JURI::getInstance(); $base = $uri->toString(array('scheme', 'host', 'port')); $link = $base . JRoute::_(ContentRoute::article($article->slug, $article->catslug), false); $url = 'index.php?option=com_mailto&tmpl=component&link=' . base64_encode($link); $status = 'width=400,height=350,menubar=yes,resizable=yes'; if ($params->get('show_icons')) { $text = JHtml::_('image', 'system/emailButton.png', JText::_('Email'), NULL, true); } else { $text = ' ' . JText::_('Email'); } $attribs['title'] = JText::_('Email'); $attribs['onclick'] = "window.open(this.href,'win2','" . $status . "'); return false;"; $output = JHtml::_('link', JRoute::_($url), $text, $attribs); return $output; }
function display($tpl = null) { // parameters $app =& JFactory::getApplication(); $db =& JFactory::getDbo(); $document =& JFactory::getDocument(); $params =& $app->getParams(); $feedEmail = @$app->getCfg('feed_email') ? $app->getCfg('feed_email') : 'author'; $siteEmail = $app->getCfg('mailfrom'); $document->link = JRoute::_('index.php?option=com_content&view=frontpage'); // Get some data from the model JRequest::setVar('limit', $app->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::_(ContentRoute::article($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; // load individual item creator class $item = new JFeedItem(); $item->title = $title; $item->link = $link; $item->description = $description; $item->date = $row->created; $item->category = 'frontpage'; $item->author = $author; if ($feedEmail == 'site') { $item->authorEmail = $siteEmail; } else { $item->authorEmail = $row->author_email; } // loads item info into rss array $document->addItem($item); } }
?> </td> <?php } ?> <?php } else { ?> <td> <?php echo $this->escape($article->title) . ' : '; $menu = JSite::getMenu(); $active = $menu->getActive(); $itemId = $active->id; $link = JRoute::_('index.php?option=com_users&view=login&&Itemid=' . $itemId); $returnURL = JRoute::_(ContentRoute::article($article->slug)); $fullURL = new JURI($link); $fullURL->setVar('return', base64_encode($returnURL)); $link = $fullURL->toString(); ?> <a href="<?php echo $link; ?> "> <?php echo JText::_('REGISTER_TO_READ_MORE'); ?> </a> </td> <?php }
// no direct access defined('_JEXEC') or die; JHtml::addIncludePath(JPATH_COMPONENT . DS . 'helpers'); ?> <ul id="archive-items"> <?php foreach ($this->items as $i => $item) { ?> <li class="row<?php echo $i % 2; ?> "> <h2> <a href="<?php echo JRoute::_(ContentRoute::article($item->slug)); ?> "> <?php echo $this->escape($item->title); ?> </a> </h2> <div> <?php if ($this->params->get('show_category') && $item->catid) { ?> <span> <?php
$item->level_diff = isset($this->items[$i + 1]) ? $item->level - $this->items[$i + 1]->level : 0; } echo '<ul>'; for ($i = 0; $i < $itemcount; $i++) { $item =& $this->items[$i]; // The next item is deeper. if ($item->deeper) { echo "<li>"; } elseif ($item->shallower) { echo "<li>"; } else { echo "<li>"; } ?> <span class="item-title"><a href="<?php echo ContentRoute::category('index.php?option=com_content&view=category&id=' . $this->escape($item->slug)); ?> "> <?php echo $this->escape($item->title); ?> </a> </span> <?php if ($item->description) { ?> <div class="category-desc"> <?php echo $item->description; ?> </div>
function display($tpl = null) { // Initialise variables. $app =& JFactory::getApplication(); $user =& JFactory::getUser(); $dispatcher =& JDispatcher::getInstance(); // Get view related request variables. $print = JRequest::getBool('print'); // Get model data. $state = $this->get('State'); $item = $this->get('Item'); // Check for errors. // @TODO Maybe this could go into JComponentHelper::raiseErrors($this->get('Errors')) if (count($errors = $this->get('Errors'))) { foreach ($errors as &$error) { if ($error instanceof Exception) { if ($error->getCode() == 404) { // If there is a 404, throw a hard error. JError::raiseError(404, $error->getMessage()); return false; } else { JError::raiseError(500, $error->getMessage()); } } else { JError::raiseWarning(500, $error); } } return false; } // Add router helpers. $item->slug = $item->alias ? $item->id . ':' . $item->alias : $item->id; $item->catslug = $item->category_alias ? $item->catid . ':' . $item->category_alias : $item->catid; // TODO: Change based on shownoauth $item->readmore_link = JRoute::_(ContentRoute::article($item->slug, $item->catslug)); // Create a shortcut to the paramemters. $params =& $state->params; $offset = $state->get('page.offset'); // If a guest user, they may be able to log in to view the full article // TODO: Does this satisfy the show not auth setting? if (!$item->params->get('access-view')) { if ($user->get('guest')) { // Redirect to login $uri = JFactory::getURI(); $app->redirect('index.php?option=com_users&view=login&return=' . base64_encode($uri), JText::_('Content_Error_Login_to_view_article')); return; } else { JError::raiseWarning(403, JText::_('Content_Error_Not_auth')); return; } } // // Process the content plugins. // JPluginHelper::importPlugin('content'); //$results = $dispatcher->trigger('onPrepareContent', array (& $article, & $params, $limitstart)); $item->text = JHtml::_('content.prepare', $item->introtext . $item->fulltext); $item->event = new stdClass(); $results = $dispatcher->trigger('onAfterDisplayTitle', array(&$item, &$params, $offset)); $item->event->afterDisplayTitle = trim(implode("\n", $results)); $results = $dispatcher->trigger('onBeforeDisplayContent', array(&$item, &$params, $offset)); $item->event->beforeDisplayContent = trim(implode("\n", $results)); $results = $dispatcher->trigger('onAfterDisplayContent', array(&$item, &$params, $offset)); $item->event->afterDisplayContent = trim(implode("\n", $results)); $this->assignRef('state', $state); $this->assignRef('item', $item); $this->assignRef('user', $user); $this->assign('print', $print); // Override the layout. if ($layout = $params->get('layout')) { $this->setLayout($layout); } // Increment the hit counter of the article. if (!$params->get('intro_only') && $offset == 0) { $model =& $this->getModel(); $model->hit(); } $this->_prepareDocument(); parent::display($tpl); }
<dt class="article-info-term"><?php echo JText::_('JContent_Article_Infos'); ?> </dt> <?php } if ($params->get('show_category')) { ?> <dd class="category-name"><?php echo JText::_('JContent_Category'); ?> <?php if ($params->get('link_category')) { ?> <?php echo '<a href="' . JRoute::_(ContentRoute::category($this->item->catslug)) . '">'; ?> <?php echo $this->escape($this->item->category_title); ?> </a> <?php } else { ?> <?php echo $this->escape($this->item->category_title); ?> <?php } ?> </dd>
?> </span> <?php } ?> </div> <?php echo $this->item->introtext; ?> <?php if ($params->get('show_readmore') && $this->item->readmore) { if ($params->get('access-view')) { $link = JRoute::_(ContentRoute::article($this->item->slug, $this->item->catslug)); } else { $link = JRoute::_("index.php?option=com_users&view=login"); } ?> <p class="readmore"> <a href="<?php echo $link; ?> "> <?php if (!$params->get('access-view')) { echo JText::_('REGISTER_TO_READ_MORE'); } elseif ($readmore = $params->get('readmore')) { echo $readmore; } else {
?> no siblings <?php } else { ?> <h5>Siblings</h5> <ul> <?php foreach ($this->siblings as &$item) { ?> <li> <?php if ($item->id != $this->item->id) { ?> <a href="<?php echo JRoute::_(ContentRoute::category($item->slug)); ?> "> <?php echo $this->escape($item->title); ?> </a> <?php } else { ?> <?php echo $this->escape($item->title); ?> <?php } ?>
function beforeBuild(&$uri) { Mijosef::get('uri')->fixUriVar($uri, 'id'); Mijosef::get('uri')->fixUriVar($uri, 'catid'); // Change task=view to view=article for old urls if (!is_null($uri->getVar('task')) && $uri->getVar('task') == 'view') { $uri->delVar('task'); $uri->setVar('view', 'article'); } if (is_null($uri->getVar('limitstart')) && !is_null($uri->getVar('start'))) { $uri->setVar('limitstart', $uri->getVar('start')); $uri->delVar('start'); } // Remove the limitstart and limit variables if they point to the first page if (is_null($uri->getVar('limitstart')) || $uri->getVar('limitstart') == '0') { $uri->delVar('limitstart'); $uri->delVar('limit'); } if (!is_null($uri->getVar('view')) && $uri->getVar('view') == 'article' && (is_null($uri->getVar('catid')) || $uri->getVar('catid') == 0) && !is_null($uri->getVar('id'))) { $catid = self::_getItemCatId(intval($uri->getVar('id'))); if (!empty($catid)) { $uri->setVar('catid', $catid); } } // Add the view variable if it's not set if (!self::_is16()) { if (is_null($uri->getVar('view'))) { if (is_null($uri->getVar('id'))) { $uri->setVar('view', 'frontpage'); } else { $uri->setVar('view', 'article'); } } } else { if (is_null($uri->getVar('view'))) { if (is_null($uri->getVar('limitstart'))) { $uri->setVar('view', 'categories'); } elseif (is_null($uri->getVar('id'))) { $uri->setVar('view', 'featured'); } else { $uri->setVar('view', 'category'); } } } // Fix for AlphaContent if (!is_null($uri->getVar('directory'))) { $uri->delVar('directory'); } if ($this->params->get('smart_itemid', '1') == '2' && !is_null($uri->getVar('view'))) { if (!class_exists('ContentRoute')) { return; } if (!method_exists('ContentRoute', '_findItemExt')) { return; } if (!self::_is16() && $uri->getVar('view') == 'section' && !is_null($uri->getVar('id'))) { $id = $uri->getVar('id'); $needles = array('section' => (int) $id); $item = ContentRoute::_findItemExt($needles); if (!empty($item)) { $uri->setVar('Itemid', $item->id); } } if ($uri->getVar('view') == 'category' && !is_null($uri->getVar('id'))) { $id = $uri->getVar('id'); if (self::_is16()) { $needles = array('category' => array((int) $id)); } else { $needles = array('category' => (int) $id); } $item = ContentRoute::_findItemExt($needles); if (!empty($item)) { if (self::_is16()) { $uri->setVar('Itemid', $item); } else { $uri->setVar('Itemid', $item->id); } } } if ($uri->getVar('view') == 'article' && !is_null($uri->getVar('id'))) { $id = $uri->getVar('id'); $catid = 0; if (!is_null($uri->getVar('catid'))) { $catid = $uri->getVar('catid'); } if (self::_is16()) { $needles = array('article' => array((int) $id), 'category' => array((int) $catid)); } else { $needles = array('article' => (int) $id, 'category' => (int) $catid, 'section' => 0); } $item = ContentRoute::_findItemExt($needles); if (!empty($item)) { if (self::_is16()) { $uri->setVar('Itemid', $item); } else { $uri->setVar('Itemid', $item->id); } } } } }