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


PHP XenForo_DataWriter::isInsert方法代码示例

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


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

示例1: 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

示例2: validateOption

 public static function validateOption(&$choices, XenForo_DataWriter $dw, $fieldName)
 {
     if ($dw->isInsert()) {
         return true;
     }
     if (!in_array($choices, self::$navbarPositions)) {
         $dw->error(new XenForo_Phrase('invalid_argument'), $fieldName);
         return false;
     }
     return true;
 }
开发者ID:NixFifty,项目名称:XenForo-SimplePortal,代码行数:11,代码来源:Tab.php

示例3: verifyOption

 public static function verifyOption(&$optionValue, XenForo_DataWriter $dw, $fieldName)
 {
     if ($dw->isInsert()) {
         return true;
     }
     if ($optionValue == 'enabled' && !class_exists('Imagick')) {
         $dw->error(new XenForo_Phrase('must_have_imagick_pecl_extension'), $fieldName);
         return false;
     }
     return true;
 }
开发者ID:VoDongMy,项目名称:xenforo-laravel5.1,代码行数:11,代码来源:Watermark.php

示例4: 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

示例5: verifyOption

 public static function verifyOption(&$optionValue, XenForo_DataWriter $dw, $fieldName)
 {
     if ($dw->isInsert()) {
         return true;
     }
     $redirects = new XenGallery_Option_Redirects();
     $redirects->addOnId = 'EWRmedio';
     $redirects->route = 'ewrmedio';
     $redirects->replaceRoute = 'media';
     $redirects->verifyOptionForAddOn($optionValue, $dw, $fieldName);
     return true;
 }
开发者ID:VoDongMy,项目名称:xenforo-laravel5.1,代码行数:12,代码来源:XenMedioRedirect.php

示例6: verifyOption

 /**
  * Updates the build date of styles after the value of the minifyCss option changes.
  *
  * @param boolean $option
  * @param XenForo_DataWriter $dw
  * @param string $fieldName
  *
  * @return boolean
  */
 public static function verifyOption(&$option, XenForo_DataWriter $dw, $fieldName)
 {
     if ($dw->isInsert()) {
         return true;
         // don't need to do anything
     }
     if ($option) {
         XenForo_Model::create('XenForo_Model_Template')->writeTemplateFiles(false, false);
     } else {
         XenForo_Model::create('XenForo_Model_Template')->deleteTemplateFiles();
     }
     return true;
 }
开发者ID:Sywooch,项目名称:forums,代码行数:22,代码来源:TemplateFiles.php

示例7: verifyOption

 public static function verifyOption(array &$options, XenForo_DataWriter $dw, $fieldName)
 {
     if (!$dw->isInsert()) {
         $grouped = array();
         foreach ($options as $option) {
             if (!isset($option['group']) || strval($option['group']) === '') {
                 continue;
             }
             $grouped[strval($option['group'])][] = array('group' => strval($option['group']), 'name' => strval($option['name']), 'format' => strval($option['format']));
         }
         $options = $grouped;
     }
     return true;
 }
开发者ID:VoDongMy,项目名称:xenforo-laravel5.1,代码行数:14,代码来源:ExifOptions.php

示例8: verifyOption

 public static function verifyOption(array &$choices, XenForo_DataWriter $dw, $fieldName)
 {
     if ($dw->isInsert()) {
         // insert - just trust the default value
         return true;
     }
     $exclusions = array();
     foreach (XenForo_Model::create('XenForo_Model_AdminSearch')->getAllSearchTypes() as $searchType => $handlerName) {
         if (empty($choices[$searchType])) {
             $exclusions[$searchType] = true;
         }
     }
     $choices = $exclusions;
     return true;
 }
开发者ID:namgiangle90,项目名称:tokyobaito,代码行数:15,代码来源:AdminSearchExclusions.php

示例9: verifyOption

 public static function verifyOption(array &$choices, XenForo_DataWriter $dw, $fieldName)
 {
     if ($dw->isInsert()) {
         // insert - just trust the default value
         return true;
     }
     $exclusions = array();
     /** @var XenForo_Model_Sitemap $sitemapModel */
     $sitemapModel = XenForo_Model::create('XenForo_Model_Sitemap');
     $types = $sitemapModel->getSitemapContentTypes(true);
     unset($types['core']);
     // always enabled
     foreach ($types as $type => $handlerName) {
         if (empty($choices[$type])) {
             $exclusions[$type] = true;
         }
     }
     $choices = $exclusions;
     return true;
 }
开发者ID:Sywooch,项目名称:forums,代码行数:20,代码来源:SitemapExclude.php

示例10: updateTags

 /**
  * Updates list of tags for specified piece of content. Any addition, removal
  * will be processed accordingly with record from database.
  *
  * @param string $contentType
  * @param unsigned int $contentId
  * @param unsigned int $contentUserId
  * @param array $tagTexts
  * @param XenForo_DataWriter $dw
  * @param array $options
  *
  * @return number of tags after update.
  *
  * @throws XenForo_Exception
  */
 public static function updateTags($contentType, $contentId, $contentUserId, array $tagTexts, XenForo_DataWriter $dw, array $options = array())
 {
     $options = array_merge(array('throwException' => true), $options);
     /* @var $tagModel Tinhte_XenTag_Model_Tag */
     $tagModel = $dw->getModelFromCache('Tinhte_XenTag_Model_Tag');
     /* @var $taggedModel Tinhte_XenTag_Model_TaggedContent */
     $taggedModel = $dw->getModelFromCache('Tinhte_XenTag_Model_TaggedContent');
     if ($dw->isInsert()) {
         // saves 1 query
         $existingTags = array();
     } else {
         $existingTags = $tagModel->getTagsOfContent($contentType, $contentId);
     }
     $changed = false;
     $newTagTexts = array();
     $removedTagTexts = array();
     $updatedTags = $existingTags;
     $tagModel->lookForNewAndRemovedTags($existingTags, $tagTexts, $newTagTexts, $removedTagTexts);
     $canCreateNew = XenForo_Visitor::getInstance()->hasPermission('general', Tinhte_XenTag_Constants::PERM_USER_CREATE_NEW);
     $errorHandler = XenForo_DataWriter::ERROR_SILENT;
     if (!empty($options['throwException'])) {
         $errorHandler = XenForo_DataWriter::ERROR_EXCEPTION;
     }
     if (!empty($newTagTexts)) {
         // sondh@2012-09-21
         // remove duplicate
         foreach (array_keys($newTagTexts) as $key) {
             $newTagTexts[$key] = Tinhte_XenTag_Helper::getNormalizedTagText($newTagTexts[$key]);
         }
         $newTagTexts = array_unique($newTagTexts);
         $newButExistingTags = $tagModel->getTagsByText($newTagTexts);
         foreach ($newTagTexts as $newTagText) {
             $newTag = $tagModel->getTagFromArrayByText($newButExistingTags, $newTagText);
             if (empty($newTag)) {
                 if ($canCreateNew) {
                     /* @var $dwTag Tinhte_XenTag_DataWriter_Tag */
                     $dwTag = XenForo_DataWriter::create('Tinhte_XenTag_DataWriter_Tag', $errorHandler);
                     $dwTag->set('tag_text', $newTagText);
                     $dwTag->set('created_user_id', $contentUserId);
                     if ($dwTag->save()) {
                         $newTag = $dwTag->getMergedData();
                     }
                 } else {
                     if (!empty($options['throwException'])) {
                         throw new XenForo_Exception(new XenForo_Phrase('tinhte_xentag_you_can_not_create_new_tag'), true);
                     }
                     continue;
                 }
             }
             if (empty($newTag)) {
                 // no tag to use, abort
                 continue;
             }
             if (!empty($newTag['is_staff']) and !XenForo_Visitor::getInstance()->hasPermission('general', Tinhte_XenTag_Constants::PERM_USER_IS_STAFF)) {
                 if (!empty($options['throwException'])) {
                     throw new XenForo_Exception(new XenForo_Phrase('tinhte_xentag_you_can_not_use_tag_x', array('tag_text' => $newTag['tag_text'])), true);
                 }
                 continue;
             }
             /* @var $dwTag Tinhte_XenTag_DataWriter_TaggedContent */
             $dwTagged = XenForo_DataWriter::create('Tinhte_XenTag_DataWriter_TaggedContent', $errorHandler);
             $dwTagged->set('tag_id', $newTag['tag_id']);
             $dwTagged->set('content_type', $contentType);
             $dwTagged->set('content_id', $contentId);
             $dwTagged->set('tagged_user_id', $contentUserId);
             if ($dwTagged->save()) {
                 $updatedTags[] = $newTag;
                 self::$_newTaggeds[] = array_merge($dwTagged->getMergedData(), $newTag);
                 $changed = true;
             }
         }
     }
     if (!empty($removedTagTexts)) {
         foreach ($removedTagTexts as $removedTagText) {
             $removedTag = $tagModel->getTagFromArrayByText($existingTags, $removedTagText);
             if (!empty($removedTag)) {
                 if (!empty($removedTag['is_staff']) and !XenForo_Visitor::getInstance()->hasPermission('general', Tinhte_XenTag_Constants::PERM_USER_IS_STAFF)) {
                     if (!empty($options['throwException'])) {
                         throw new XenForo_Exception(new XenForo_Phrase('tinhte_xentag_you_can_not_remove_tag_x', array('tag_text' => $removedTag['tag_text'])), true);
                     }
                     continue;
                 }
                 /* @var $dwTag Tinhte_XenTag_DataWriter_TaggedContent */
                 $dwTagged = XenForo_DataWriter::create('Tinhte_XenTag_DataWriter_TaggedContent', $errorHandler);
                 $data = array('tag_id' => $removedTag['tag_id'], 'content_type' => $contentType, 'content_id' => $contentId);
//.........这里部分代码省略.........
开发者ID:Sywooch,项目名称:forums,代码行数:101,代码来源:Integration.php


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