[ Index ]

PHP Cross Reference of Joomla 1.5.26 DE

title

Body

[close]

/components/com_contact/views/category/ -> view.html.php (source)

   1  <?php
   2  /**
   3   * @version        $Id: view.html.php 19343 2010-11-03 18:12:02Z ian $
   4   * @package        Joomla
   5   * @subpackage    Contact
   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  jimport('joomla.application.component.view');
  19  
  20  /**
  21   * @package        Joomla
  22   * @subpackage    Contacts
  23   */
  24  class ContactViewCategory extends JView
  25  {
  26  	function display($tpl = null)
  27      {
  28          global $mainframe, $option;
  29  
  30          $user      = &JFactory::getUser();
  31          $uri       =& JFactory::getURI();
  32          $model      = &$this->getModel();
  33          $document =& JFactory::getDocument();
  34  
  35          $pparams = &$mainframe->getParams('com_contact');
  36  
  37          // Selected Request vars
  38          $categoryId            = JRequest::getVar('catid',                0,                '', 'int');
  39          $limitstart            = JRequest::getVar('limitstart',        0,                '', 'int');
  40          $filter_order        = JRequest::getVar('filter_order',        'cd.ordering',    '', 'cmd');
  41          $filter_order_Dir    = JRequest::getVar('filter_order_Dir',    'ASC',            '', 'word');
  42  
  43          $pparams->def('display_num', $mainframe->getCfg('list_limit'));
  44          $default_limit = $pparams->def('display_num', 20);
  45  
  46          $limit = $mainframe->getUserStateFromRequest('com_contact.'.$this->getLayout().'.limit', 'limit', $default_limit, 'int');
  47  
  48          // sanitize $orderBy
  49          if (!in_array($filter_order, array('cd.ordering', 'cd.name', 'cd.con_position'))) {
  50              $filter_order = 'cd.ordering';
  51          }
  52  
  53          if (!in_array(strtoupper($filter_order_Dir), array('ASC', 'DESC', ''))) {
  54              $filter_order_Dir = 'ASC';
  55          }
  56  
  57          // query options
  58          $options['aid']         = $user->get('aid', 0);
  59          $options['category_id']    = $categoryId;
  60          $options['limit']        = $limit;
  61          $options['limitstart']    = $limitstart;
  62          $options['order by']    = "$filter_order $filter_order_Dir, cd.ordering";
  63  
  64          $categories    = $model->getCategories( $options );
  65          $contacts    = $model->getContacts( $options );
  66          $total         = $model->getContactCount( $options );
  67  
  68          //add alternate feed link
  69          if($pparams->get('show_feed_link', 1) == 1)
  70          {
  71              $link    = '&format=feed&limitstart=';
  72              $attribs = array('type' => 'application/rss+xml', 'title' => 'RSS 2.0');
  73              $document->addHeadLink(JRoute::_($link.'&type=rss'), 'alternate', 'rel', $attribs);
  74              $attribs = array('type' => 'application/atom+xml', 'title' => 'Atom 1.0');
  75              $document->addHeadLink(JRoute::_($link.'&type=atom'), 'alternate', 'rel', $attribs);
  76          }
  77  
  78          //prepare contacts
  79          if($pparams->get('show_email', 0) == 1) {
  80              jimport('joomla.mail.helper');
  81          }
  82  
  83          $k = 0;
  84          for($i = 0; $i <  count( $contacts ); $i++)
  85          {
  86              $contact =& $contacts[$i];
  87  
  88              $contact->link = JRoute::_('index.php?option=com_contact&view=contact&id='.$contact->slug.'&catid='.$contact->catslug, false);
  89              if ($pparams->get('show_email', 0) == 1) {
  90                  $contact->email_to = trim($contact->email_to);
  91                  if (!empty($contact->email_to) && JMailHelper::isEmailAddress($contact->email_to)) {
  92                      $contact->email_to = JHTML::_('email.cloak', $contact->email_to);
  93                  } else {
  94                      $contact->email_to = '';
  95                  }
  96              }
  97  
  98              $contact->odd    = $k;
  99              $contact->count = $i;
 100              $k = 1 - $k;
 101          }
 102  
 103          // find current category
 104          // TODO: Move to model
 105          $category = null;
 106          foreach ($categories as $i => $_cat)
 107          {
 108              if ($_cat->id == $categoryId) {
 109                  $category = &$categories[$i];
 110                  break;
 111              }
 112          }
 113          if ($category == null) {
 114              $db = &JFactory::getDBO();
 115              $category =& JTable::getInstance( 'category' );
 116          }
 117  
 118          $menus    = &JSite::getMenu();
 119          $menu    = $menus->getActive();
 120  
 121          // because the application sets a default page title, we need to get it
 122          // right from the menu item itself
 123          if (is_object( $menu )) {
 124              $menu_params = new JParameter( $menu->params );
 125              if (!$menu_params->get( 'page_title')) {
 126                  $pparams->set('page_title',    $category->title);
 127              }
 128          } else {
 129              $pparams->set('page_title',    $category->title);
 130          }
 131          $document->setTitle( $pparams->get( 'page_title' ) );
 132  
 133          // Prepare category description
 134          $category->description = JHTML::_('content.prepare', $category->description);
 135  
 136          // table ordering
 137          $lists['order_Dir'] = $filter_order_Dir;
 138          $lists['order'] = $filter_order;
 139          $selected = '';
 140  
 141          jimport('joomla.html.pagination');
 142          $pagination = new JPagination($total, $limitstart, $limit);
 143  
 144          $this->assignRef('items',        $contacts);
 145          $this->assignRef('lists',        $lists);
 146          $this->assignRef('pagination',    $pagination);
 147          //$this->assignRef('data',        $data);
 148          $this->assignRef('category',    $category);
 149          $this->assignRef('params',        $pparams);
 150  
 151          $this->assign('action',        str_replace('&', '&amp;', $uri->toString()));
 152  
 153          parent::display($tpl);
 154      }
 155  
 156  	function getItems()
 157      {
 158  
 159      }
 160  }


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