Source for file map.php

Documentation is available at map.php

  1. <?php
  2. /**
  3.  * @package     Joomla.Administrator
  4.  * @subpackage  com_finder
  5.  *
  6.  * @copyright   Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
  7.  * @license     GNU General Public License version 2 or later; see LICENSE
  8.  */
  9.  
  10. defined('_JEXEC'or die;
  11.  
  12. /**
  13.  * Map table class for the Finder package.
  14.  *
  15.  * @package     Joomla.Administrator
  16.  * @subpackage  com_finder
  17.  * @since       2.5
  18.  */
  19. class FinderTableMap extends JTable
  20. {
  21.     /**
  22.      * Constructor
  23.      *
  24.      * @param   JDatabaseDriver  &$db  JDatabaseDriver connector object.
  25.      *
  26.      * @since   2.5
  27.      */
  28.     public function __construct(&$db)
  29.     {
  30.         parent::__construct('#__finder_taxonomy''id'$db);
  31.     }
  32.  
  33.     /**
  34.      * Method to set the publishing state for a row or list of rows in the database
  35.      * table. The method respects checked out rows by other users and will attempt
  36.      * to checkin rows that it can after adjustments are made.
  37.      *
  38.      * @param   mixed    $pks     An array of primary key values to update.  If not
  39.      *                             set the instance property value is used. [optional]
  40.      * @param   integer  $state   The publishing state. eg. [0 = unpublished, 1 = published] [optional]
  41.      * @param   integer  $userId  The user id of the user performing the operation. [optional]
  42.      *
  43.      * @return  boolean  True on success.
  44.      *
  45.      * @since   2.5
  46.      */
  47.     public function publish($pks null$state 1$userId 0)
  48.     {
  49.         $k $this->_tbl_key;
  50.  
  51.         // Sanitize input.
  52.         JArrayHelper::toInteger($pks);
  53.         $state = (int) $state;
  54.  
  55.         // If there are no primary keys set check to see if the instance key is set.
  56.         if (empty($pks))
  57.         {
  58.             if ($this->$k)
  59.             {
  60.                 $pks array($this->$k);
  61.             }
  62.             // Nothing to set publishing state on, return false.
  63.             else
  64.             {
  65.                 $this->setError(JText::_('JLIB_DATABASE_ERROR_NO_ROWS_SELECTED'));
  66.                 return false;
  67.             }
  68.         }
  69.  
  70.         // Build the WHERE clause for the primary keys.
  71.         $where $k '=' implode(' OR ' $k '='$pks);
  72.  
  73.         // Update the publishing state for rows with the given primary keys.
  74.         $query $this->_db->getQuery(true)
  75.             ->update($this->_db->quoteName($this->_tbl))
  76.             ->set($this->_db->quoteName('state'' = ' . (int) $state)
  77.             ->where($where);
  78.         $this->_db->setQuery($query);
  79.  
  80.         try
  81.         {
  82.             $this->_db->execute();
  83.         }
  84.         catch (RuntimeException $e)
  85.         {
  86.             $this->setError($e->getMessage());
  87.             return false;
  88.         }
  89.  
  90.         // If the JTable instance value is in the list of primary keys that were set, set the instance.
  91.         if (in_array($this->$k$pks))
  92.         {
  93.             $this->state $state;
  94.         }
  95.  
  96.         $this->setError('');
  97.  
  98.         return true;
  99.     }
  100. }

Documentation generated on Tue, 19 Nov 2013 15:07:36 +0100 by phpDocumentor 1.4.3