load('api', null); require_once('./includes/functions_datastore.php'); /** * API: Language * * @author Blue Static * @copyright Copyright (c)2002 - 2007, Blue Static * @version $Revision$ * @package Bugdar * */ class LanguageAPI extends API { /** * Fields * @var array * @access private */ var $fields = array( 'languageid' => array(TYPE_UINT, REQ_AUTO, 'verify_nozero'), 'title' => array(TYPE_STR, REQ_YES, 'verify_noempty'), 'charset' => array(TYPE_STR, REQ_YES), 'direction' => array(TYPE_STR, REQ_NO, ':self'), 'userselect' => array(TYPE_BOOL, REQ_NO), 'langcode' => array(TYPE_STR, REQ_YES) ); /** * Table * @var string * @access private */ var $table = 'language'; /** * Table prefix * @var string * @access private */ var $prefix = TABLE_PREFIX; // ################################################################### /** * Post-insert * * @access private */ function post_insert() { build_languages(); } // ################################################################### /** * Post-update * * @access private */ function post_update() { build_languages(); } // ################################################################### /** * Pre-delete */ function pre_delete() { $count = $this->registry->db->query_first("SELECT COUNT(*) AS count FROM " . TABLE_PREFIX . "language"); if ($count['count'] < 2) { $this->error(T('At least one language needs to be present. Deleting this language would violate that.')); } if ($this->registry->options['defaultlanguage'] == $this->values['languageid']) { $this->error(T('You cannot delete the default language. Please select another language to be the default language and then delete this one.')); } } // ################################################################### /** * Post-delete * * @access private */ function post_delete() { build_languages(); } // ################################################################### /** * Verify: direction * * @access private */ function verify_direction() { if (!in_array($this->values['direction'], array('ltr', 'rtl'))) { return T('The direction must be ltr (left-to-right) or rtl (right-to-left)'); } return true; } }