r1062: Okay. Domain isn't the right word. So I'll change it agian.
[bugdar.git] / includes / api_language.php
1 <?php
2 /*=====================================================================*\
3 || ###################################################################
4 || # Bugdar [#]version[#]
5 || # Copyright ©2002-[#]year[#] Blue Static
6 || #
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 [#]gpl[#] of the License.
10 || #
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
14 || # more details.
15 || #
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 \*=====================================================================*/
21
22 $GLOBALS['isso:callback']->load('api', null);
23
24 require_once('./includes/functions_datastore.php');
25
26 /**
27 * API: Language
28 *
29 * @author Blue Static
30 * @copyright Copyright ©2002 - [#]year[#], Blue Static
31 * @version $Revision$
32 * @package Bugdar
33 *
34 */
35 class LanguageAPI extends API
36 {
37 /**
38 * Fields
39 * @var array
40 * @access private
41 */
42 var $fields = array(
43 'languageid' => array(TYPE_UINT, REQ_AUTO, 'verify_nozero'),
44 'title' => array(TYPE_STR, REQ_YES, 'verify_noempty'),
45 'charset' => array(TYPE_STR, REQ_YES),
46 'debug' => array(TYPE_BOOL, REQ_NO),
47 'direction' => array(TYPE_STR, REQ_NO, ':self'),
48 'userselect' => array(TYPE_BOOL, REQ_NO),
49 'langcode' => array(TYPE_STR, REQ_YES)
50 );
51
52 /**
53 * Table
54 * @var string
55 * @access private
56 */
57 var $table = 'language';
58
59 /**
60 * Table prefix
61 * @var string
62 * @access private
63 */
64 var $prefix = TABLE_PREFIX;
65
66 // ###################################################################
67 /**
68 * Post-insert
69 *
70 * @access private
71 */
72 function post_insert()
73 {
74 build_languages();
75 }
76
77 // ###################################################################
78 /**
79 * Post-update
80 *
81 * @access private
82 */
83 function post_update()
84 {
85 build_languages();
86 }
87
88 // ###################################################################
89 /**
90 * Pre-delete
91 */
92 function pre_delete()
93 {
94 $count = $this->registry->db->query_first("SELECT COUNT(*) AS count FROM " . TABLE_PREFIX . "language");
95 if ($count['count'] < 2)
96 {
97 $this->error(_('At least one language needs to be present. Deleting this language would violate that.'));
98 }
99
100 if ($this->registry->options['defaultlanguage'] == $this->values['languageid'])
101 {
102 $this->error(_('You cannot delete the default language. Please select another language to be the default language and then delete this one.'));
103 }
104 }
105
106 // ###################################################################
107 /**
108 * Post-delete
109 *
110 * @access private
111 */
112 function post_delete()
113 {
114 build_languages();
115 }
116
117 // ###################################################################
118 /**
119 * Verify: direction
120 *
121 * @access private
122 */
123 function verify_direction()
124 {
125 if (!in_array($this->values['direction'], array('ltr', 'rtl')))
126 {
127 return _('The direction must be ltr (left-to-right) or rtl (right-to-left)');
128 }
129 return true;
130 }
131 }
132
133 /*=====================================================================*\
134 || ###################################################################
135 || # $HeadURL$
136 || # $Id$
137 || ###################################################################
138 \*=====================================================================*/
139 ?>