[ Index ]

PHP Cross Reference of Joomla 1.5.26 DE

title

Body

[close]

/components/com_content/views/section/ -> view.html.php (source)

   1  <?php
   2  /**
   3   * @version        $Id: view.html.php 15181 2010-03-04 23:06:32Z ian $
   4   * @package        Joomla
   5   * @subpackage    Content
   6   * @copyright    Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved.
   7   * @license        GNU/GPL, see LICENSE.php
   8   * Joomla! is free software. This version may have been modified pursuant to the
   9   * GNU General Public License, and as distributed it includes or is derivative
  10   * of works licensed under the GNU General Public License or other free or open
  11   * source software licenses. See COPYRIGHT.php for copyright notices and
  12   * details.
  13   */
  14  
  15  // Check to ensure this file is included in Joomla!
  16  defined('_JEXEC') or die( 'Restricted access' );
  17  
  18  require_once (JPATH_COMPONENT.DS.'view.php');
  19  
  20  /**
  21   * HTML View class for the Content component
  22   *
  23   * @static
  24   * @package        Joomla
  25   * @subpackage    Content
  26   * @since 1.5
  27   */
  28  class ContentViewSection extends ContentView
  29  {
  30  	function display($tpl = null)
  31      {
  32          global $mainframe, $option;
  33  
  34          // Initialize some variables
  35          $user        =& JFactory::getUser();
  36          $document    =& JFactory::getDocument();
  37  
  38          // Get the page/component configuration
  39          $params = &$mainframe->getParams();
  40  
  41          // Request variables
  42          $limit        = JRequest::getVar('limit', $params->get('display_num'), '', 'int');
  43          $limitstart    = JRequest::getVar('limitstart', 0, '', 'int');
  44  
  45          //parameters
  46          $intro        = $params->def('num_intro_articles',     4);
  47          $leading    = $params->def('num_leading_articles',     1);
  48          $links        = $params->def('num_links',             4);
  49  
  50          $limit    = $intro + $leading + $links;
  51          JRequest::setVar('limit', (int) $limit);
  52  
  53          // Get some data from the model
  54          $items        = & $this->get( 'Data');
  55          $total        = & $this->get( 'Total');
  56          $categories    = & $this->get( 'Categories' );
  57          $section    = & $this->get( 'Section' );
  58  
  59          // Create a user access object for the user
  60          $access                    = new stdClass();
  61          $access->canEdit        = $user->authorize('com_content', 'edit', 'content', 'all');
  62          $access->canEditOwn        = $user->authorize('com_content', 'edit', 'content', 'own');
  63          $access->canPublish        = $user->authorize('com_content', 'publish', 'content', 'all');
  64  
  65          //add alternate feed link
  66          if($params->get('show_feed_link', 1) == 1)
  67          {
  68              $link    = '&format=feed&limitstart=';
  69              $attribs = array('type' => 'application/rss+xml', 'title' => 'RSS 2.0');
  70              $document->addHeadLink(JRoute::_($link.'&type=rss'), 'alternate', 'rel', $attribs);
  71              $attribs = array('type' => 'application/atom+xml', 'title' => 'Atom 1.0');
  72              $document->addHeadLink(JRoute::_($link.'&type=atom'), 'alternate', 'rel', $attribs);
  73          }
  74  
  75          $menus    = &JSite::getMenu();
  76          $menu    = $menus->getActive();
  77  
  78          // because the application sets a default page title, we need to get it
  79          // right from the menu item itself
  80          if (is_object( $menu )) {
  81              $menu_params = new JParameter( $menu->params );
  82              if (!$menu_params->get( 'page_title')) {
  83                  $params->set('page_title',    $section->title);
  84              }
  85          } else {
  86              $params->set('page_title',    $section->title);
  87          }
  88          $document->setTitle( $params->get( 'page_title' ) );
  89  
  90          // Prepare section description
  91          $section->description = JHTML::_('content.prepare', $section->description);
  92  
  93          for($i = 0; $i < count($categories); $i++)
  94          {
  95              $category =& $categories[$i];
  96              $category->link = JRoute::_(ContentHelperRoute::getCategoryRoute($category->slug, $category->section).'&layout=default');
  97  
  98              // Prepare category description
  99              $category->description = JHTML::_('content.prepare', $category->description);
 100          }
 101  
 102          if ($total == 0) {
 103              $params->set('show_categories', false);
 104          }
 105  
 106          jimport('joomla.html.pagination');
 107          $pagination = new JPagination($total, $limitstart, $limit );
 108  
 109          $this->assign('total',            $total);
 110  
 111          $this->assignRef('items',        $items);
 112          $this->assignRef('section',        $section);
 113          $this->assignRef('categories',    $categories);
 114          $this->assignRef('params',        $params);
 115          $this->assignRef('user',        $user);
 116          $this->assignRef('access',        $access);
 117          $this->assignRef('pagination',    $pagination);
 118  
 119          parent::display($tpl);
 120      }
 121  
 122      function &getItem( $index = 0, &$params)
 123      {
 124          global $mainframe;
 125  
 126          // Initialize some variables
 127          $user        =& JFactory::getUser();
 128          $dispatcher    =& JDispatcher::getInstance();
 129  
 130          $SiteName    = $mainframe->getCfg('sitename');
 131  
 132          $task        = JRequest::getCmd('task');
 133  
 134          $linkOn        = null;
 135          $linkText    = null;
 136  
 137          $item =& $this->items[$index];
 138          $item->text = $item->introtext;
 139  
 140          // Get the page/component configuration and article parameters
 141          $item->params = clone($params);
 142          $aparams = new JParameter($item->attribs);
 143  
 144          // Merge article parameters into the page configuration
 145          $item->params->merge($aparams);
 146  
 147          // Process the content preparation plugins
 148          JPluginHelper::importPlugin('content');
 149          $results = $dispatcher->trigger('onPrepareContent', array (& $item, & $item->params, 0));
 150  
 151          // Build the link and text of the readmore button
 152          if (($item->params->get('show_readmore') && @ $item->readmore) || $item->params->get('link_titles'))
 153          {
 154              // checks if the item is a public or registered/special item
 155              if ($item->access <= $user->get('aid', 0))
 156              {
 157                  //$item->readmore_link = JRoute::_("index.php?view=article&id=".$item->slug);
 158                  $item->readmore_link = JRoute::_(ContentHelperRoute::getArticleRoute($item->slug, $item->catslug, $item->sectionid));
 159                  $item->readmore_register = false;
 160              }
 161              else
 162              {
 163                  $item->readmore_link = JRoute::_("index.php?option=com_user&view=login");
 164                  $returnURL = JRoute::_(ContentHelperRoute::getArticleRoute($item->slug, $item->catslug, $item->sectionid),false);
 165                  $fullURL = new JURI($item->readmore_link);
 166                  $fullURL->setVar('return', base64_encode($returnURL));
 167                  $item->readmore_link = $fullURL->toString();
 168                  $item->readmore_register = true;
 169              }
 170          }
 171  
 172          $item->event = new stdClass();
 173          $results = $dispatcher->trigger('onAfterDisplayTitle', array (& $item, & $item->params,0));
 174          $item->event->afterDisplayTitle = trim(implode("\n", $results));
 175  
 176          $results = $dispatcher->trigger('onBeforeDisplayContent', array (& $item, & $item->params, 0));
 177          $item->event->beforeDisplayContent = trim(implode("\n", $results));
 178  
 179          $results = $dispatcher->trigger('onAfterDisplayContent', array (& $item, & $item->params, 0));
 180          $item->event->afterDisplayContent = trim(implode("\n", $results));
 181  
 182          return $item;
 183      }
 184  }


Generated: Wed Mar 28 15:54:07 2012 Cross-referenced by PHPXref 0.7.1