[ Index ]

PHP Cross Reference of Joomla 1.5.26 DE

title

Body

[close]

/components/com_contact/models/ -> contact.php (source)

   1  <?php
   2  /**
   3   * @version        $Id: contact.php 14401 2010-01-26 14:10:00Z louis $
   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.model');
  19  
  20  /**
  21   * @package        Joomla
  22   * @subpackage    Contact
  23   */
  24  class ContactModelContact extends JModel
  25  {
  26      /**
  27       * Builds the query to select contact items
  28       * @param array
  29       * @return string
  30       * @access protected
  31       */
  32  	function _getContactQuery( &$options )
  33      {
  34          // TODO: Cache on the fingerprint of the arguments
  35          $db            =& JFactory::getDBO();
  36          $aid        = @$options['aid'];
  37          $id            = @$options['id'];
  38          $groupBy    = @$options['group by'];
  39          $orderBy    = @$options['order by'];
  40  
  41          $select = 'a.*, cc.access as category_access, cc.title as category_name, '
  42          . ' CASE WHEN CHAR_LENGTH(a.alias) THEN CONCAT_WS(\':\', a.id, a.alias) ELSE a.id END as slug, '
  43          . ' CASE WHEN CHAR_LENGTH(cc.alias) THEN CONCAT_WS(\':\', cc.id, cc.alias) ELSE cc.id END AS catslug ';
  44          $from    = '#__contact_details AS a';
  45  
  46          $joins[] = 'INNER JOIN #__categories AS cc on cc.id = a.catid';
  47  
  48          $wheres[] = 'a.id = ' . (int) $id;
  49          $wheres[] = 'a.published = 1';
  50          $wheres[] = 'cc.published = 1';
  51  
  52          /*
  53           * Query to retrieve all categories that belong under the contacts
  54           * section and that are published.
  55           */
  56          $query = 'SELECT ' . $select .
  57                  ' FROM ' . $from .
  58                  ' '. implode ( ' ', $joins ) .
  59                  ' WHERE ' . implode( ' AND ', $wheres );
  60  
  61          return $query;
  62      }
  63  
  64      /**
  65       * Gets a list of categories
  66       * @param array
  67       * @return mixed Object or null
  68       */
  69  	function getContact( $options=array() )
  70      {
  71          $query    = $this->_getContactQuery( $options );
  72          $result = $this->_getList( $query );
  73          return @$result[0];
  74      }
  75  }


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