Fix DB_MySQL_PDO::escape_binary().
[bugdar.git] / includes / api_language.php
1 <?php
2 /*=====================================================================*\
3 || ###################################################################
4 || # Bugdar
5 || # Copyright (c)2002-2007 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 2 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 (c)2002 - 2007, 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 'direction' => array(TYPE_STR, REQ_NO, ':self'),
47 'userselect' => array(TYPE_BOOL, REQ_NO),
48 'langcode' => array(TYPE_STR, REQ_YES)
49 );
50
51 /**
52 * Table
53 * @var string
54 * @access private
55 */
56 var $table = 'language';
57
58 /**
59 * Table prefix
60 * @var string
61 * @access private
62 */
63 var $prefix = TABLE_PREFIX;
64
65 // ###################################################################
66 /**
67 * Post-insert
68 *
69 * @access private
70 */
71 function post_insert()
72 {
73 build_languages();
74 }
75
76 // ###################################################################
77 /**
78 * Post-update
79 *
80 * @access private
81 */
82 function post_update()
83 {
84 build_languages();
85 }
86
87 // ###################################################################
88 /**
89 * Pre-delete
90 */
91 function pre_delete()
92 {
93 $count = $this->registry->db->query_first("SELECT COUNT(*) AS count FROM " . TABLE_PREFIX . "language");
94 if ($count['count'] < 2)
95 {
96 $this->error(T('At least one language needs to be present. Deleting this language would violate that.'));
97 }
98
99 if ($this->registry->options['defaultlanguage'] == $this->values['languageid'])
100 {
101 $this->error(T('You cannot delete the default language. Please select another language to be the default language and then delete this one.'));
102 }
103 }
104
105 // ###################################################################
106 /**
107 * Post-delete
108 *
109 * @access private
110 */
111 function post_delete()
112 {
113 build_languages();
114 }
115
116 // ###################################################################
117 /**
118 * Verify: direction
119 *
120 * @access private
121 */
122 function verify_direction()
123 {
124 if (!in_array($this->values['direction'], array('ltr', 'rtl')))
125 {
126 return T('The direction must be ltr (left-to-right) or rtl (right-to-left)');
127 }
128 return true;
129 }
130 }
131