Source for file language.php

Documentation is available at language.php

  1. <?php
  2. /**
  3.  * @package     Joomla.Platform
  4.  * @subpackage  Table
  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('JPATH_PLATFORM'or die;
  11.  
  12. /**
  13.  * Languages table.
  14.  *
  15.  * @package     Joomla.Platform
  16.  * @subpackage  Table
  17.  * @since       11.1
  18.  */
  19. class JTableLanguage extends JTable
  20. {
  21.     /**
  22.      * Constructor
  23.      *
  24.      * @param   JDatabaseDriver  $db  Database driver object.
  25.      *
  26.      * @since   11.1
  27.      */
  28.     public function __construct(JDatabaseDriver $db)
  29.     {
  30.         parent::__construct('#__languages''lang_id'$db);
  31.     }
  32.  
  33.     /**
  34.      * Overloaded check method to ensure data integrity
  35.      *
  36.      * @return  boolean  True on success
  37.      *
  38.      * @since   11.1
  39.      */
  40.     public function check()
  41.     {
  42.         if (trim($this->title== '')
  43.         {
  44.             $this->setError(JText::_('JLIB_DATABASE_ERROR_LANGUAGE_NO_TITLE'));
  45.  
  46.             return false;
  47.         }
  48.  
  49.         return true;
  50.     }
  51.  
  52.     /**
  53.      * Overrides JTable::store to check unique fields.
  54.      *
  55.      * @param   boolean  $updateNulls  True to update fields even if they are null.
  56.      *
  57.      * @return  boolean  True on success.
  58.      *
  59.      * @since   11.4
  60.      */
  61.     public function store($updateNulls false)
  62.     {
  63.         // Verify that the sef field is unique
  64.         $table JTable::getInstance('Language''JTable');
  65.  
  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.  
  70.             return false;
  71.         }
  72.  
  73.         // Verify that the image field is unique
  74.         if ($table->load(array('image' => $this->image)) && ($table->lang_id != $this->lang_id || $this->lang_id == 0))
  75.         {
  76.             $this->setError(JText::_('JLIB_DATABASE_ERROR_LANGUAGE_UNIQUE_IMAGE'));
  77.  
  78.             return false;
  79.         }
  80.  
  81.         // Verify that the language code is unique
  82.         if ($table->load(array('lang_code' => $this->lang_code)) && ($table->lang_id != $this->lang_id || $this->lang_id == 0))
  83.         {
  84.             $this->setError(JText::_('JLIB_DATABASE_ERROR_LANGUAGE_UNIQUE_LANG_CODE'));
  85.  
  86.             return false;
  87.         }
  88.  
  89.         return parent::store($updateNulls);
  90.     }
  91. }

Documentation generated on Tue, 19 Nov 2013 15:06:26 +0100 by phpDocumentor 1.4.3