Beispiel #1
0
 /**
  * Execute and display a template script.
  *
  * @param   string  $tpl  The name of the template file to parse; automatically searches through the template paths.
  *
  * @return  mixed  A string if successful, otherwise a Error object.
  *
  * @since   3.2
  */
 public function display($tpl = null)
 {
     $app = JFactory::getApplication();
     $document = JFactory::getDocument();
     $extension = $app->input->getString('option');
     $document->link = JRoute::_(JHelperRoute::getCategoryRoute($app->input->getInt('id'), $language = 0, $extension));
     $app->input->set('limit', $app->get('feed_limit'));
     $siteEmail = $app->get('mailfrom');
     $fromName = $app->get('fromname');
     $feedEmail = $app->get('feed_email', 'author');
     $document->editor = $fromName;
     if ($feedEmail != 'none') {
         $document->editorEmail = $siteEmail;
     }
     // Get some data from the model
     $items = $this->get('Items');
     $category = $this->get('Category');
     foreach ($items as $item) {
         $this->reconcileNames($item);
         // Strip html from feed item title
         $title = $this->escape($item->title);
         $title = html_entity_decode($title, ENT_COMPAT, 'UTF-8');
         // URL link to article
         $router = new JHelperRoute();
         $link = JRoute::_($router->getRoute($item->id, $item->catid));
         // Strip HTML from feed item description text.
         $description = $item->description;
         $author = $item->created_by_alias ? $item->created_by_alias : $item->author;
         $date = isset($item->date) ? date('r', strtotime($item->date)) : '';
         // Load individual item creator class.
         $feeditem = new JFeedItem();
         $feeditem->title = $title;
         $feeditem->link = $link;
         $feeditem->description = $description;
         $feeditem->date = $date;
         $feeditem->category = $category->title;
         $feeditem->author = $author;
         // We don't have the author email so we have to use site in both cases.
         if ($feedEmail == 'site') {
             $feeditem->authorEmail = $siteEmail;
         } elseif ($feedEmail === 'author') {
             $feeditem->authorEmail = $item->author_email;
         }
         // Loads item information into RSS array
         $document->addItem($feeditem);
     }
 }
Beispiel #2
0
 /**
  * Tries to load the router for the component and calls it. Otherwise uses getTagRoute.
  *
  * @param   integer  $contentItemId     Component item id
  * @param   string   $contentItemAlias  Component item alias
  * @param   integer  $contentCatId      Component item category id
  * @param   string   $language          Component item language
  * @param   string   $typeAlias         Component type alias
  * @param   string   $routerName        Component router
  *
  * @return  string  URL link to pass to JRoute
  *
  * @since   3.1
  */
 public static function getItemRoute($contentItemId, $contentItemAlias, $contentCatId, $language, $typeAlias, $routerName)
 {
     $link = '';
     $explodedAlias = explode('.', $typeAlias);
     $explodedRouter = explode('::', $routerName);
     if (file_exists($routerFile = JPATH_BASE . '/components/' . $explodedAlias[0] . '/helpers/route.php')) {
         JLoader::register($explodedRouter[0], $routerFile);
         $routerClass = $explodedRouter[0];
         $routerMethod = $explodedRouter[1];
         if (class_exists($routerClass) && method_exists($routerClass, $routerMethod)) {
             if ($routerMethod == 'getCategoryRoute') {
                 $link = $routerClass::$routerMethod($contentItemId, $language);
             } else {
                 $link = $routerClass::$routerMethod($contentItemId . ':' . $contentItemAlias, $contentCatId, $language);
             }
         }
     }
     if ($link == '') {
         // Create a fallback link in case we can't find the component router
         $router = new JHelperRoute();
         $link = $router->getRoute($contentItemId, $typeAlias, $link, $language, $contentCatId);
     }
     return $link;
 }