From e26741580e3394e11f7f150cb44d542916a8728b Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Sat, 6 Sep 2008 16:00:15 -0400 Subject: [PATCH] Update api_language.php --- includes/api_language.php | 106 +++++++++++++++++++------------------- 1 file changed, 53 insertions(+), 53 deletions(-) diff --git a/includes/api_language.php b/includes/api_language.php index d0297a4..0f146de 100644 --- a/includes/api_language.php +++ b/includes/api_language.php @@ -19,8 +19,7 @@ || ################################################################### \*=====================================================================*/ -$GLOBALS['isso:callback']->load('api', null); - +require_once ISSO . '/Api.php'; require_once('./includes/functions_datastore.php'); /** @@ -32,101 +31,102 @@ require_once('./includes/functions_datastore.php'); * @package Bugdar * */ -class LanguageAPI extends API +class LanguageAPI extends BSApi { /** - * Fields - * @var array - * @access private - */ - var $fields = array( - 'languageid' => array(TYPE_UINT, REQ_AUTO, 'verify_nozero'), - 'title' => array(TYPE_STR, REQ_YES, 'verify_noempty'), + * Fields + * @var array + */ + protected $fields = array( + 'languageid' => array(TYPE_UINT, REQ_AUTO), + 'title' => array(TYPE_STR, REQ_YES), 'charset' => array(TYPE_STR, REQ_YES), - 'direction' => array(TYPE_STR, REQ_NO, ':self'), + 'direction' => array(TYPE_STR, REQ_NO), 'userselect' => array(TYPE_BOOL, REQ_NO), 'langcode' => array(TYPE_STR, REQ_YES) ); /** - * Table - * @var string - * @access private - */ - var $table = 'language'; + * Table + * @var string + */ + protected $table = 'language'; /** - * Table prefix - * @var string - * @access private - */ - var $prefix = TABLE_PREFIX; + * Table prefix + * @var string + */ + protected $prefix = TABLE_PREFIX; - // ################################################################### /** - * Post-insert - * - * @access private - */ - function post_insert() + * Post-insert + */ + protected function post_insert() { build_languages(); } - // ################################################################### /** - * Post-update - * - * @access private - */ - function post_update() + * Post-update + */ + protected function post_update() { build_languages(); } - // ################################################################### /** - * Pre-delete - */ - function pre_delete() + * Pre-delete + */ + protected function pre_delete() { - $count = $this->registry->db->query_first("SELECT COUNT(*) AS count FROM " . TABLE_PREFIX . "language"); + $count = BSApp::$db->queryFirst("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.')); + throw new FieldException(T('At least one language needs to be present. Deleting this language would violate that.'), 'languageid'); } if (bugdar::$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.')); + 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'); } } - // ################################################################### /** - * Post-delete - * - * @access private - */ - function post_delete() + * Post-delete + */ + protected function post_delete() { build_languages(); } - // ################################################################### /** - * Verify: direction - * - * @access private - */ - function verify_direction() + * Verify: direction + */ + protected function validate_direction($field) { if (!in_array($this->values['direction'], array('ltr', 'rtl'))) { - return T('The direction must be ltr (left-to-right) or rtl (right-to-left)'); + $this->_error(new FieldError(T('The direction must be ltr (left-to-right) or rtl (right-to-left)'), $field)); + return false; } return true; } + + /** + * Validate: languageid + */ + protected function validate_languageid($field) + { + return $this->_verifyIsNotZero($field); + } + + /** + * Validate: title + */ + protected function validate_title($field) + { + return $this->_verifyIsNotEmpty($field); + } } /*=====================================================================*\ -- 2.43.5