1 <?php
 2  3  4  5  6  7  8 
 9 
10 defined('JPATH_PLATFORM') or die;
11 
12 13 14 15 16 
17 class JTableLanguage extends JTable
18 {
19     20 21 22 23 24 25 
26     public function __construct($db)
27     {
28         parent::__construct('#__languages', 'lang_id', $db);
29     }
30 
31     32 33 34 35 36 37 
38     public function check()
39     {
40         if (trim($this->title) == '')
41         {
42             $this->setError(JText::_('JLIB_DATABASE_ERROR_LANGUAGE_NO_TITLE'));
43 
44             return false;
45         }
46 
47         return true;
48     }
49 
50     51 52 53 54 55 56 57 58 
59     public function store($updateNulls = false)
60     {
61         $table = JTable::getInstance('Language', 'JTable', array('dbo' => $this->getDbo()));
62 
63         
64         if ($table->load(array('lang_code' => $this->lang_code)) && ($table->lang_id != $this->lang_id || $this->lang_id == 0))
65         {
66             $this->setError(JText::_('JLIB_DATABASE_ERROR_LANGUAGE_UNIQUE_LANG_CODE'));
67 
68             return false;
69         }
70 
71         
72         if ($table->load(array('sef' => $this->sef)) && ($table->lang_id != $this->lang_id || $this->lang_id == 0))
73         {
74             $this->setError(JText::_('JLIB_DATABASE_ERROR_LANGUAGE_UNIQUE_SEF'));
75 
76             return false;
77         }
78 
79         
80         if ($this->image && $table->load(array('image' => $this->image)) && ($table->lang_id != $this->lang_id || $this->lang_id == 0))
81         {
82             $this->setError(JText::_('JLIB_DATABASE_ERROR_LANGUAGE_UNIQUE_IMAGE'));
83 
84             return false;
85         }
86 
87         return parent::store($updateNulls);
88     }
89 }
90