]>
src.bluestatic.org Git - bugdar.git/blob - includes/api_language.php
2 /*=====================================================================*\
3 || ###################################################################
5 || # Copyright ©2002-2007 Blue Static
7 || # This program is free software; you can redistribute it and/or modify
8 || # it under the terms of the GNU General Public License as published by
9 || # the Free Software Foundation; version 2 of the License.
11 || # This program is distributed in the hope that it will be useful, but
12 || # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 || # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
16 || # You should have received a copy of the GNU General Public License along
17 || # with this program; if not, write to the Free Software Foundation, Inc.,
18 || # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
19 || ###################################################################
20 \*=====================================================================*/
22 require_once ISSO
. '/Api.php' ;
23 require_once ( './includes/functions_datastore.php' );
29 * @copyright Copyright ©2002 - 2007, Blue Static
34 class LanguageAPI
extends BSApi
40 protected $fields = array (
41 'languageid' => array ( TYPE_UINT
, REQ_AUTO
),
42 'title' => array ( TYPE_STR
, REQ_YES
),
43 'charset' => array ( TYPE_STR
, REQ_YES
),
44 'direction' => array ( TYPE_STR
, REQ_NO
),
45 'userselect' => array ( TYPE_BOOL
, REQ_NO
),
46 'langcode' => array ( TYPE_STR
, REQ_YES
)
53 protected $table = 'language' ;
59 protected $prefix = TABLE_PREFIX
;
64 protected function post_insert ()
72 protected function post_update ()
80 protected function pre_delete ()
82 $count = BSApp
:: $db- > queryFirst ( "SELECT COUNT(*) AS count FROM " . TABLE_PREFIX
. "language" );
83 if ( $count [ 'count' ] < 2 )
85 throw new FieldException ( T ( 'At least one language needs to be present. Deleting this language would violate that.' ), 'languageid' );
88 if ( bugdar
:: $options [ 'defaultlanguage' ] == $this- > values
[ 'languageid' ])
90 throw new FieldException ( T ( 'You cannot delete the default language. Please select another language to be the default language and then delete this one.' ), 'languageid' );
97 protected function post_delete ()
105 protected function validate_direction ( $field )
107 if (! in_array ( $this- > values
[ 'direction' ], array ( 'ltr' , 'rtl' )))
109 $this- > _error ( new FieldError ( T ( 'The direction must be ltr (left-to-right) or rtl (right-to-left)' ), $field ));
116 * Validate: languageid
118 protected function validate_languageid ( $field )
120 return $this- > _verifyIsNotZero ( $field );
126 protected function validate_title ( $field )
128 return $this- > _verifyIsNotEmpty ( $field );
132 /*=====================================================================*\
133 || ###################################################################
136 || ###################################################################
137 \*=====================================================================*/