当前位置: 首页>>代码示例>>PHP>>正文


PHP XenForo_DataWriter::error方法代码示例

本文整理汇总了PHP中XenForo_DataWriter::error方法的典型用法代码示例。如果您正苦于以下问题:PHP XenForo_DataWriter::error方法的具体用法?PHP XenForo_DataWriter::error怎么用?PHP XenForo_DataWriter::error使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在XenForo_DataWriter的用法示例。


在下文中一共展示了XenForo_DataWriter::error方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: verifyOption

 /**
  * Verifies database connection information
  *
  * @param array $words List of words to censor (from input). Keys: word, exact, replace
  * @param XenForo_DataWriter $dw Calling DW
  * @param string $fieldName Name of field/option
  *
  * @return true
  */
 public static function verifyOption(array &$database, XenForo_DataWriter $dw = null, $fieldName = null)
 {
     if (array_key_exists('newInstall', $database)) {
         return true;
     }
     if (!array_key_exists('adapter', $database) || !array_key_exists('host', $database) || !array_key_exists('port', $database) || !array_key_exists('dbname', $database) || !array_key_exists('username', $database) || !array_key_exists('password', $database)) {
         return false;
     }
     try {
         $db = Zend_Db::factory($database['adapter'], array('host' => $database['host'], 'port' => $database['port'], 'dbname' => $database['dbname'], 'username' => $database['username'], 'password' => $database['password']));
         $db->getConnection();
         $sbTables = array($database['table_prefix'] . '_admins', $database['table_prefix'] . '_admins_servers_groups', $database['table_prefix'] . '_banlog', $database['table_prefix'] . '_bans', $database['table_prefix'] . '_comments', $database['table_prefix'] . '_demos', $database['table_prefix'] . '_groups', $database['table_prefix'] . '_log', $database['table_prefix'] . '_mods', $database['table_prefix'] . '_overrides', $database['table_prefix'] . '_protests', $database['table_prefix'] . '_servers', $database['table_prefix'] . '_servers_groups', $database['table_prefix'] . '_settings', $database['table_prefix'] . '_srvgroups', $database['table_prefix'] . '_srvgroups_overrides', $database['table_prefix'] . '_submissions');
         $query = $db->listTables();
         if (count(array_diff($sbTables, $query)) > 0) {
             $dw->error(new XenForo_Phrase('sourcebans_table_prefix_invalid'));
             return false;
         }
     } catch (Zend_Db_Adapter_Exception $e) {
         if ($dw) {
             $dw->error($e->getMessage(), $fieldName);
         }
         return false;
     }
     return true;
 }
开发者ID:jljr222,项目名称:sourcebans-xenforo-sync,代码行数:34,代码来源:Database.php

示例2: watermark

 public static function watermark(array &$optionValues, XenForo_DataWriter $optionDw, $optionId)
 {
     if ($optionId !== 'sonnbXG_watermark') {
         return true;
     }
     if (!empty($optionValues['enabled'])) {
         switch ($optionValues['overlay']) {
             case 'image':
                 if (!Zend_Uri::check($optionValues['url']) && !is_file($optionValues['url'])) {
                     $optionDw->error(new XenForo_Phrase('sonnb_xengallery_watermark_image_not_valid'), $optionId);
                     return false;
                 }
                 break;
             case 'text':
                 if (!self::isTextColorValid($optionValues['textColor'])) {
                     $optionDw->error(new XenForo_Phrase('sonnb_xengallery_watermark_text_color_not_valid'), $optionId);
                     return false;
                 }
                 if (!self::isBgColorValid($optionValues['bgColor'])) {
                     $optionDw->error(new XenForo_Phrase('sonnb_xengallery_watermark_bg_color_not_valid'), $optionId);
                     return false;
                 }
                 if (!empty($optionValues['font']) && !is_file($optionValues['font'])) {
                     $optionDw->error(new XenForo_Phrase('sonnb_xengallery_watermark_font_path_not_valid'), $optionId);
                     return false;
                 }
                 break;
         }
     }
     return true;
 }
开发者ID:Sywooch,项目名称:forums,代码行数:31,代码来源:Check.php

示例3: verifyOption

 public static function verifyOption(array &$values, XenForo_DataWriter $dw, $fieldName)
 {
     if ($dw->isInsert()) {
         return true;
     }
     if (empty($values['enabled'])) {
         return true;
     }
     try {
         $helper = new XenGallery_Helper_Video(null, $values['ffmpegPath'], !empty($values['transcode']));
         $errors = $helper->getFfmpegErrors();
         if ($errors) {
             $dw->error(reset($errors), $fieldName);
             return false;
         }
     } catch (Exception $e) {
         $dw->error($e->getMessage(), $fieldName);
         return false;
     }
     if (!empty($values['transcode'])) {
         try {
             if (!is_file($values['phpPath']) && !is_executable($values['phpPath'])) {
                 $dw->error(new XenForo_Phrase('xengallery_php_binary_path_could_not_be_verified'));
                 return false;
             }
         } catch (Exception $e) {
             $dw->error($e->getMessage(), $fieldName);
             return false;
         }
     }
     return true;
 }
开发者ID:VoDongMy,项目名称:xenforo-laravel5.1,代码行数:32,代码来源:Transcoding.php

示例4: verifyPosition

 public static function verifyPosition(&$positions, XenForo_DataWriter $dw, $fieldName = false)
 {
     $positions = trim($positions);
     if (empty($positions)) {
         $dw->error(new XenForo_Phrase('wf_position_can_not_be_empty'), $fieldName);
     }
     if ('all' == $positions) {
         return true;
     }
     /** @var XenForo_Model_Template $templateModel */
     $templateModel = $dw->getModelFromCache('XenForo_Model_Template');
     $db = XenForo_Application::getDb();
     $positionsArray = explode(',', $positions);
     $positionsGood = array();
     $templateForHooks = array();
     foreach ($positionsArray as $position) {
         $position = trim($position);
         if (empty($position)) {
             continue;
         }
         if (in_array($position, array('wf_widget_page', 'hook:wf_widget_page_contents'), true) and !$dw->get('widget_page_id')) {
             $dw->error(new XenForo_Phrase('wf_position_x_requires_widget_page', array('position' => $position)), $fieldName);
             return false;
         }
         if (in_array($position, array('wf_widget_ajax'), true)) {
             $dw->error(new XenForo_Phrase('wf_invalid_position_x', array('position' => $position)), $fieldName);
             return false;
         }
         // sondh@2012-08-25
         // added support for hook:hook_name
         if (substr($position, 0, 5) == 'hook:') {
             // accept all kind of hooks, just need to get parent templates for them
             $templates = $db->fetchAll("\n\t\t\t\t\tSELECT title\n\t\t\t\t\tFROM `xf_template_compiled`\n\t\t\t\t\tWHERE template_compiled LIKE " . XenForo_Db::quoteLike('callTemplateHook(\'' . substr($position, 5) . '\',', 'lr') . "\n\t\t\t\t");
             if (count($templates) > 0) {
                 $templateForHooks[$position] = array();
                 foreach ($templates as $template) {
                     $templateForHooks[$position][] = $template['title'];
                 }
                 $templateForHooks[$position] = array_unique($templateForHooks[$position]);
             } else {
                 $dw->error(new XenForo_Phrase('wf_non_existent_hook_x', array('hook' => substr($position, 5))), $fieldName);
                 return false;
             }
         } elseif (!$templateModel->getTemplateInStyleByTitle($position)) {
             $dw->error(new XenForo_Phrase('wf_invalid_position_x', array('position' => $position)), $fieldName);
             return false;
         }
         $positionsGood[] = $position;
     }
     $dw->setExtraData(WidgetFramework_DataWriter_Widget::EXTRA_DATA_TEMPLATE_FOR_HOOKS, $templateForHooks);
     asort($positionsGood);
     $positions = implode(', ', $positionsGood);
     return true;
 }
开发者ID:maitandat1507,项目名称:bdWidgetFramework,代码行数:54,代码来源:Widget.php

示例5: verifyOption

 /**
  * Verifies the registrationWelcome setting
  *
  * @param array $values
  * @param XenForo_DataWriter $dw Calling DW
  * @param string $fieldName Name of field/option
  *
  * @return true
  */
 public static function verifyOption(array &$values, XenForo_DataWriter $dw, $fieldName)
 {
     if ($dw->isInsert()) {
         // insert - just trust the default value
         return true;
     }
     if (!empty($values['messageEnabled'])) {
         /** @var XenForo_Model_User $userModel */
         $userModel = XenForo_Model::create('XenForo_Model_User');
         $participants = explode(',', $values['messageParticipants']);
         $starter = array_shift($participants);
         $participantUsers = $userModel->getUsersByNames($participants);
         $starterUser = $userModel->getUserByName($starter);
         if (!$starterUser) {
             if ($starter) {
                 $dw->error(new XenForo_Phrase('the_following_recipients_could_not_be_found_x', array('names' => $starter)), $fieldName);
             } else {
                 $dw->error(new XenForo_Phrase('please_enter_at_least_one_valid_recipient'), $fieldName);
             }
             return false;
         }
         /** @var XenForo_DataWriter_ConversationMaster $conversationDw */
         $conversationDw = XenForo_DataWriter::create('XenForo_DataWriter_ConversationMaster');
         $conversationDw->setExtraData(XenForo_DataWriter_ConversationMaster::DATA_ACTION_USER, $starterUser);
         $conversationDw->setExtraData(XenForo_DataWriter_ConversationMaster::DATA_MESSAGE, $values['messageBody']);
         $conversationDw->set('user_id', $starterUser['user_id']);
         $conversationDw->set('username', $starterUser['username']);
         $conversationDw->set('title', $values['messageTitle']);
         $conversationDw->addRecipientUserIds(array_keys($participantUsers));
         // skips permissions
         $messageDw = $conversationDw->getFirstMessageDw();
         $messageDw->set('message', $values['messageBody']);
         $conversationDw->preSave();
         if ($conversationDw->hasErrors()) {
             $errors = $conversationDw->getErrors();
             // Skip recipient errors. We've already verified the recipients are valid.
             if (isset($errors['recipients'])) {
                 unset($errors['recipients']);
             }
             if (count($errors)) {
                 $dw->error(reset($errors), $fieldName);
                 return false;
             }
         }
         $validUsernames = XenForo_Application::arrayColumn($participantUsers, 'username');
         array_unshift($validUsernames, $starter);
         $values['messageParticipants'] = implode(', ', array_unique($validUsernames));
     }
     if (!empty($values['emailEnabled']) && !strlen(trim($values['emailBody']))) {
         $dw->error(new XenForo_Phrase('you_must_enter_email_message_to_enable_welcome_email'), $fieldName);
         return false;
     }
     return true;
 }
开发者ID:darkearl,项目名称:projectT122015,代码行数:63,代码来源:RegistrationWelcome.php

示例6: validateColour

 public static function validateColour($value, XenForo_DataWriter $dw, $fieldName)
 {
     // #fff and #fff444 are acceptable formats here
     if (strlen($value) != 7 && strlen($value) != 4) {
         $dw->error(new XenForo_Phrase("mc_assoc_errors_hex_colour"), $fieldName);
     }
     $truncatedValue = substr($value, 1);
     // chop off the #
     if (!ctype_xdigit($truncatedValue) || $value[0] != "#") {
         $dw->error(new XenForo_Phrase("mc_assoc_errors_hex_colour"), $fieldName);
     }
     return $dw;
 }
开发者ID:adamjdev,项目名称:XenForo-MCASSOC,代码行数:13,代码来源:Options.php

示例7: verifyTweetOption

 public static function verifyTweetOption(array &$option, XenForo_DataWriter $dw, $fieldName)
 {
     if (!empty($option['enabled'])) {
         if (!empty($option['via']) && !XenForo_Helper_UserField::verifyTwitter(array(), $option['via'], $error)) {
             $dw->error($error, $fieldName);
             return false;
         }
         if (!empty($option['related']) && !XenForo_Helper_UserField::verifyTwitter(array(), $option['related'], $error)) {
             $dw->error($error, $fieldName);
             return false;
         }
     }
     return true;
 }
开发者ID:namgiangle90,项目名称:tokyobaito,代码行数:14,代码来源:Twitter.php

示例8: verifyTweetOption

 public static function verifyTweetOption(array &$option, XenForo_DataWriter $dw, $fieldName)
 {
     if (!empty($option['enabled'])) {
         if (!XenForo_Model_IdentityService_Twitter::verifyAccountName($option['via'], $error)) {
             $dw->error($error);
             return false;
         }
         if (!XenForo_Model_IdentityService_Twitter::verifyAccountName($option['related'], $error)) {
             $dw->error($error);
             return false;
         }
     }
     return true;
 }
开发者ID:hahuunguyen,项目名称:DTUI_201105,代码行数:14,代码来源:Twitter.php

示例9: xenWrapperCallback

 public static function xenWrapperCallback(array &$configs, XenForo_DataWriter $dw, $fieldName)
 {
     if (isset($configs['Bbm_wrapper_callback']) && $configs['Bbm_wrapper_callback'] == 'callback' && !BBM_Helper_Bbm::callbackChecker($configs['class'], $configs['method'])) {
         $dw->error(new XenForo_Phrase('bbm_xenwrapper_callback_not_valid'));
     }
     return true;
 }
开发者ID:Sywooch,项目名称:forums,代码行数:7,代码来源:Verification.php

示例10: verifyOption

 public static function verifyOption(&$optionValue, XenForo_DataWriter $dw, $fieldName)
 {
     if ($optionValue == 'imPecl' && !class_exists('Imagick')) {
         $dw->error(new XenForo_Phrase('must_have_imagick_pecl_extension'), $fieldName);
         return false;
     }
     return true;
 }
开发者ID:Sywooch,项目名称:forums,代码行数:8,代码来源:ImageLibrary.php

示例11: verifyOption

 /**
  * Verifies the license key.
  *
  * @param string $licenseKey license key to be verified
  * @param XenForo_DataWriter $dw Calling DW
  * @param string $fieldName Name of field/option
  *
  * @return true
  */
 public static function verifyOption(&$licenseKey, XenForo_DataWriter $dw, $fieldName)
 {
     if (XenForo_Application::getOptions()->simpleFormsLicenseKey && !self::VerifyLicense($licenseKey)) {
         $errorMessage = 'The license key you entered is invalid. If you are having trouble with your license, please contact <a href="https://liquidpro.net/clients/clientarea.php" target="_blank">LiquidPro Support</a>.';
         $dw->error($errorMessage, $fieldName);
     }
     return true;
 }
开发者ID:jljr222,项目名称:xenforo-simple-forms,代码行数:17,代码来源:LicenseKey.php

示例12: verifyGoogleAnalyticsWebPropertyId

 /**
  * Verifies that the Google Analytics Web Property ID is valid, if specified.
  * See https://www.google.com/support/googleanalytics/bin/answer.py?answer=113500
  *
  * @param string $wpId
  * @param XenForo_DataWriter $dw
  * @param string $fieldName
  *
  * @return boolean
  */
 public static function verifyGoogleAnalyticsWebPropertyId(&$wpId, XenForo_DataWriter $dw, $fieldName)
 {
     if ($wpId !== '' && !preg_match('/^UA-\\d+-\\d+$/', $wpId)) {
         $dw->error(new XenForo_Phrase('please_enter_your_google_analytics_web_property_id_in_format'), $fieldName);
         return false;
     }
     return true;
 }
开发者ID:Sywooch,项目名称:forums,代码行数:18,代码来源:Option.php

示例13: verifyUri

 /**
  * Verifies that the provided string is a valid URL
  *
  * @param string $url
  *
  * @return boolean
  */
 public static function verifyUri(&$uri, XenForo_DataWriter $dw, $fieldName = false)
 {
     if (Zend_Uri::check($uri)) {
         return true;
     }
     $dw->error(new XenForo_Phrase('please_enter_valid_url'), $fieldName);
     return false;
 }
开发者ID:Sywooch,项目名称:forums,代码行数:15,代码来源:Uri.php

示例14: VerifyDefaultValue

 public static function VerifyDefaultValue(&$defaultValue, XenForo_DataWriter $dw, $inputName = false)
 {
     if ($defaultValue == '') {
         return true;
     }
     $fieldType = $dw->get('field_type');
     if ($fieldType == 'datetime') {
         if (is_string($defaultValue)) {
             $temp = explode(' ', $defaultValue);
             if (count($temp) != 2) {
                 $dw->error(new XenForo_Phrase('lpsf_please_enter_a_datetime_in_format'), $inputName);
                 return false;
             }
             $defaultValue = array('date' => $temp[0], 'time' => $temp[1]);
         }
         if (is_array($defaultValue) && array_key_exists('date', $defaultValue) && array_key_exists('time', $defaultValue)) {
             // validate
             $dateTimeStr = $defaultValue['date'] . ' ' . $defaultValue['time'];
             $dateTime = DateTime::createFromFormat('Y-m-d g:ia', $dateTimeStr);
             if (!$dateTime) {
                 $dw->error(new XenForo_Phrase('lpsf_please_enter_a_datetime_in_format'), $inputName);
                 return false;
             }
             $defaultValue = $dateTimeStr;
         }
     }
     if ($fieldType == 'time') {
         $dateTime = DateTime::createFromFormat('g:ia', $defaultValue);
         if (!$dateTime) {
             $dw->error(new XenForo_Phrase('lpsf_please_enter_a_time_in_format'), $inputName);
             return false;
         }
     }
     if ($fieldType == 'date') {
         $dateTime = DateTime::createFromFormat('Y-m-d', $defaultValue);
         if (!$dateTime) {
             $dw->error(new XenForo_Phrase('lpsf_please_enter_a_date_in_format'), $inputName);
             return false;
         }
     }
     return true;
 }
开发者ID:jljr222,项目名称:xenforo-simple-forms,代码行数:42,代码来源:Field.php

示例15: verifyOption

 public static function verifyOption(array &$groups, XenForo_DataWriter $dw = null, $fieldName = null)
 {
     // override for a new install, no group validation should be done
     if (is_array($groups) && array_key_exists('newInstall', $groups)) {
         return true;
     }
     if (is_array($groups) && array_key_exists(0, $groups)) {
         unset($groups[0]);
     }
     foreach ($groups as $groupId => $selectedGroups) {
         if (!is_array($selectedGroups)) {
             $dw->error(new XenForo_Phrase('sourcebans_group_association_invalid'));
         } else {
             if ($selectedGroups['web_admin_group_id'] == '' || $selectedGroups['server_admin_group_id'] == '' || $selectedGroups['server_group_id'] == '') {
                 $dw->error(new XenForo_Phrase('sourcebans_group_association_invalid'));
             }
         }
     }
     return true;
 }
开发者ID:Zipcore,项目名称:sourcebans-xenforo-sync,代码行数:20,代码来源:Groups.php


注:本文中的XenForo_DataWriter::error方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。