[ Index ]

PHP Cross Reference of Joomla 2.5.4 DE

title

Body

[close]

/libraries/joomla/database/table/ -> language.php (source)

   1  <?php
   2  /**
   3   * @package     Joomla.Platform
   4   * @subpackage  Database
   5   *
   6   * @copyright   Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
   7   * @license     GNU General Public License version 2 or later; see LICENSE
   8   */
   9  
  10  defined('JPATH_PLATFORM') or die;
  11  
  12  jimport('joomla.database.table');
  13  
  14  /**
  15   * Languages table.
  16   *
  17   * @package     Joomla.Platform
  18   * @subpackage  Database
  19   * @since       11.1
  20   */
  21  class JTableLanguage extends JTable
  22  {
  23      /**
  24       * Constructor
  25       *
  26       * @param   JDatabase  &$db  A database connector object
  27       *
  28       * @since   11.1
  29       */
  30  	public function __construct(&$db)
  31      {
  32          parent::__construct('#__languages', 'lang_id', $db);
  33      }
  34  
  35      /**
  36       * Overloaded check method to ensure data integrity
  37       *
  38       * @return  boolean  True on success
  39       *
  40       * @since   11.1
  41       */
  42  	public function check()
  43      {
  44          if (trim($this->title) == '')
  45          {
  46              $this->setError(JText::_('JLIB_DATABASE_ERROR_LANGUAGE_NO_TITLE'));
  47              return false;
  48          }
  49  
  50          return true;
  51      }
  52  
  53      /**
  54       * Overrides JTable::store to check unique fields.
  55       *
  56       * @param   boolean  $updateNulls  True to update fields even if they are null.
  57       *
  58       * @return  boolean  True on success.
  59       *
  60       * @since   11.4
  61       */
  62  	public function store($updateNulls = false)
  63      {
  64          // Verify that the sef field is unique
  65          $table = JTable::getInstance('Language', 'JTable');
  66          if ($table->load(array('sef' => $this->sef)) && ($table->lang_id != $this->lang_id || $this->lang_id == 0))
  67          {
  68              $this->setError(JText::_('JLIB_DATABASE_ERROR_LANGUAGE_UNIQUE_SEF'));
  69              return false;
  70          }
  71  
  72          // Verify that the image field is unique
  73          if ($table->load(array('image' => $this->image)) && ($table->lang_id != $this->lang_id || $this->lang_id == 0))
  74          {
  75              $this->setError(JText::_('JLIB_DATABASE_ERROR_LANGUAGE_UNIQUE_IMAGE'));
  76              return false;
  77          }
  78  
  79          // Verify that the language code is unique
  80          if ($table->load(array('lang_code' => $this->lang_code)) && ($table->lang_id != $this->lang_id || $this->lang_id == 0))
  81          {
  82              $this->setError(JText::_('JLIB_DATABASE_ERROR_LANGUAGE_UNIQUE_LANG_CODE'));
  83              return false;
  84          }
  85          return parent::store($updateNulls);
  86      }
  87  }


Generated: Tue Apr 3 11:40:28 2012 Cross-referenced by PHPXref 0.7.1