[ Index ]

PHP Cross Reference of Joomla 1.5.26 DE

title

Body

[close]

/components/com_content/views/category/ -> 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   * @package        Joomla
  24   * @subpackage    Content
  25   * @since 1.5
  26   */
  27  class ContentViewCategory extends ContentView
  28  {
  29  	function display($tpl = null)
  30      {
  31          global $mainframe, $option;
  32  
  33          // Initialize some variables
  34          $user        =& JFactory::getUser();
  35          $uri         =& JFactory::getURI();
  36          $document    =& JFactory::getDocument();
  37          $pathway    =& $mainframe->getPathway();
  38  
  39          // Get the menu item object
  40          $menus = &JSite::getMenu();
  41          $menu  = $menus->getActive();
  42  
  43          // Get the page/component configuration
  44          $params = clone($mainframe->getParams('com_content'));
  45  
  46          // Request variables
  47          $layout     = JRequest::getCmd('layout');
  48          $task        = JRequest::getCmd('task');
  49  
  50          // Parameters
  51          $params->def('num_leading_articles',     1);
  52          $params->def('num_intro_articles',         4);
  53          $params->def('num_columns',                2);
  54          $params->def('num_links',                 4);
  55          $params->def('show_headings',             1);
  56          $params->def('show_pagination',            2);
  57          $params->def('show_pagination_results',    1);
  58          $params->def('show_pagination_limit',    1);
  59          $params->def('filter',                    1);
  60          if (($params->def('filter_type', 'title') != 'hits') && ($params->def('filter_type', 'title') != 'author')) {
  61              $params->set('filter_type', 'title');
  62          }
  63  
  64          $intro        = $params->get('num_intro_articles');
  65          $leading    = $params->get('num_leading_articles');
  66          $links        = $params->get('num_links');
  67  
  68          $limitstart    = JRequest::getVar('limitstart', 0, '', 'int');
  69  
  70          if ($layout == 'blog') {
  71              $default_limit = $intro + $leading + $links;
  72          } else {
  73              $params->def('display_num', $mainframe->getCfg('list_limit'));
  74              $default_limit = $params->get('display_num');
  75          }
  76          $limit = $mainframe->getUserStateFromRequest('com_content.'.$this->getLayout().'.limit', 'limit', $default_limit, 'int');
  77  
  78          JRequest::setVar('limit', (int) $limit);
  79  
  80          $contentConfig = &JComponentHelper::getParams('com_content');
  81          $params->def('show_page_title',     $contentConfig->get('show_title'));
  82  
  83          // Get some data from the model
  84          $items        = & $this->get( 'Data' );
  85          $total        = & $this->get( 'Total' );
  86          $category    = & $this->get( 'Category' );
  87  
  88          //add alternate feed link
  89          if($params->get('show_feed_link', 1) == 1)
  90          {
  91              $link    = '&format=feed&limitstart=';
  92              $attribs = array('type' => 'application/rss+xml', 'title' => 'RSS 2.0');
  93              $document->addHeadLink(JRoute::_($link.'&type=rss'), 'alternate', 'rel', $attribs);
  94              $attribs = array('type' => 'application/atom+xml', 'title' => 'Atom 1.0');
  95              $document->addHeadLink(JRoute::_($link.'&type=atom'), 'alternate', 'rel', $attribs);
  96          }
  97  
  98          // Create a user access object for the user
  99          $access                    = new stdClass();
 100          $access->canEdit        = $user->authorize('com_content', 'edit', 'content', 'all');
 101          $access->canEditOwn        = $user->authorize('com_content', 'edit', 'content', 'own');
 102          $access->canPublish        = $user->authorize('com_content', 'publish', 'content', 'all');
 103  
 104          // Set page title per category
 105          // because the application sets a default page title, we need to get it
 106          // right from the menu item itself
 107          if (is_object( $menu )) {
 108              $menu_params = new JParameter( $menu->params );
 109              if (!$menu_params->get( 'page_title')) {
 110                  $params->set('page_title',    $category->title);
 111              }
 112          } else {
 113              $params->set('page_title',    $category->title);
 114          }
 115          $document->setTitle( $params->get( 'page_title' ) );
 116  
 117          //set breadcrumbs
 118          if(is_object($menu) && $menu->query['view'] != 'category') {
 119              $pathway->addItem($category->title, '');
 120          }
 121  
 122          // Prepare category description
 123          $category->description = JHTML::_('content.prepare', $category->description);
 124  
 125          $params->def('date_format',    JText::_('DATE_FORMAT_LC1'));
 126  
 127          // Keep a copy for safe keeping this is soooooo dirty -- must deal with in a later version
 128          // @todo -- oh my god we need to find this reference issue in 1.6 :)
 129          $this->_params = $params->toArray();
 130  
 131          jimport('joomla.html.pagination');
 132          //In case we are in a blog view set the limit
 133          if ($layout == 'blog' && ($limit - $links != 0)) {
 134              $pagination = new JPagination($total, $limitstart, $limit - $links);
 135          } else {
 136              $pagination = new JPagination($total, $limitstart, $limit);
 137          }
 138  
 139          $this->assign('total',        $total);
 140          $this->assign('action',     str_replace('&', '&amp;', $uri->toString()));
 141  
 142          $this->assignRef('items',        $items);
 143          $this->assignRef('params',        $params);
 144          $this->assignRef('category',    $category);
 145          $this->assignRef('user',        $user);
 146          $this->assignRef('access',        $access);
 147          $this->assignRef('pagination',    $pagination);
 148  
 149          parent::display($tpl);
 150      }
 151  
 152      function &getItems()
 153      {
 154          global $mainframe;
 155  
 156          //create select lists
 157          $user    = &JFactory::getUser();
 158          $lists    = $this->_buildSortLists();
 159  
 160          if (!count( $this->items ) )
 161          {
 162              $this->assign('lists',    $lists);
 163              $return = array();
 164              return $return;
 165          }
 166  
 167          //create paginatiion
 168          if ($lists['filter']) {
 169              $this->data->link .= '&amp;filter='.urlencode($lists['filter']);
 170          }
 171  
 172          $k = 0;
 173          $i = 0;
 174          foreach($this->items as $key => $item)
 175          {
 176              // checks if the item is a public or registered/special item
 177              if ($item->access <= $user->get('aid', 0))
 178              {
 179                  $item->link    = JRoute::_(ContentHelperRoute::getArticleRoute($item->slug, $item->catslug, $item->sectionid));
 180                  $item->readmore_register = false;
 181              }
 182              else
 183              {
 184                  $item->link = JRoute::_('index.php?option=com_user&task=register');
 185                  $returnURL = JRoute::_(ContentHelperRoute::getArticleRoute($item->slug, $item->catslug, $item->sectionid), false);
 186                  $fullURL = new JURI($item->link);
 187                  $fullURL->setVar('return', base64_encode($returnURL));
 188                  $item->link = $fullURL->toString();
 189                  $item->readmore_register = true;
 190              }
 191              $item->created    = JHTML::_('date', $item->created, $this->params->get('date_format'));
 192  
 193              $item->odd        = $k;
 194              $item->count    = $i;
 195  
 196              $this->items[$key] = $item;
 197              $k = 1 - $k;
 198              $i++;
 199          }
 200  
 201          $this->assign('lists',    $lists);
 202  
 203          return $this->items;
 204      }
 205  
 206      function &getItem($index = 0, &$params)
 207      {
 208          global $mainframe;
 209  
 210          // Initialize some variables
 211          $user        =& JFactory::getUser();
 212          $dispatcher    =& JDispatcher::getInstance();
 213  
 214          $SiteName    = $mainframe->getCfg('sitename');
 215  
 216          $item         =& $this->items[$index];
 217          $item->text = $item->introtext;
 218  
 219          $category    = & $this->get( 'Category' );
 220          $item->category = $category->title;
 221          $item->section  = $category->sectiontitle;
 222  
 223          // Get the page/component configuration and article parameters
 224          $item->params = clone($params);
 225          $aparams = new JParameter($item->attribs);
 226  
 227          // Merge article parameters into the page configuration
 228          $item->params->merge($aparams);
 229  
 230          // Process the content preparation plugins
 231          JPluginHelper::importPlugin('content');
 232          $results = $dispatcher->trigger('onPrepareContent', array (& $item, & $item->params, 0));
 233  
 234          // Build the link and text of the readmore button
 235          if (($item->params->get('show_readmore') && @ $item->readmore) || $item->params->get('link_titles'))
 236          {
 237              // checks if the item is a public or registered/special item
 238              if ($item->access <= $user->get('aid', 0))
 239              {
 240                  //$item->readmore_link = JRoute::_('index.php?view=article&catid='.$this->category->slug.'&id='.$item->slug);
 241                  $item->readmore_link = JRoute::_(ContentHelperRoute::getArticleRoute($item->slug, $item->catslug, $item->sectionid));
 242                  $item->readmore_register = false;
 243              }
 244              else
 245              {
 246                  $item->readmore_link = JRoute::_('index.php?option=com_user&view=login');
 247                  $returnURL = JRoute::_(ContentHelperRoute::getArticleRoute($item->slug, $item->catslug, $item->sectionid),false);
 248                  $fullURL = new JURI($item->readmore_link);
 249                  $fullURL->setVar('return', base64_encode($returnURL));
 250                  $item->readmore_link = $fullURL->toString();
 251                  $item->readmore_register = true;
 252              }
 253          }
 254  
 255          $item->event = new stdClass();
 256          $results = $dispatcher->trigger('onAfterDisplayTitle', array (& $item, & $item->params,0));
 257          $item->event->afterDisplayTitle = trim(implode("\n", $results));
 258  
 259          $results = $dispatcher->trigger('onBeforeDisplayContent', array (& $item, & $item->params, 0));
 260          $item->event->beforeDisplayContent = trim(implode("\n", $results));
 261  
 262          $results = $dispatcher->trigger('onAfterDisplayContent', array (& $item, & $item->params, 0));
 263          $item->event->afterDisplayContent = trim(implode("\n", $results));
 264  
 265          return $item;
 266      }
 267  
 268  	function _buildSortLists()
 269      {
 270          // Table ordering values
 271          $filter                = JRequest::getString('filter');
 272          global $mainframe;
 273          $itemid = JRequest::getInt('id',0) . ':' . JRequest::getInt('Itemid',0);
 274          $filter_order  = $mainframe->getUserStateFromRequest('com_content.category.list.' . $itemid . '.filter_order', 'filter_order', '', 'cmd');
 275          $filter_order_Dir = $mainframe->getUserStateFromRequest('com_content.category.list.' . $itemid . '.filter_order_Dir', 'filter_order_Dir', '', 'cmd');
 276          $lists['task']      = 'category';
 277          $lists['filter']    = $filter;
 278          $lists['order']     = $filter_order;
 279          $lists['order_Dir'] = $filter_order_Dir;
 280  
 281          return $lists;
 282      }
 283  }
 284  ?>


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