本文整理汇总了PHP中XenForo_DataWriter::create方法的典型用法代码示例。如果您正苦于以下问题:PHP XenForo_DataWriter::create方法的具体用法?PHP XenForo_DataWriter::create怎么用?PHP XenForo_DataWriter::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XenForo_DataWriter
的用法示例。
在下文中一共展示了XenForo_DataWriter::create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createContent
public function createContent($tabId, $tabName, array $createCriteria, array $params)
{
if (empty($params['existing_content_id'])) {
return $tabId;
}
/* @var $mediaDw XenGallery_DataWriter_Media */
$mediaDw = XenForo_DataWriter::create('XenGallery_DataWriter_Media', XenForo_DataWriter::ERROR_SILENT);
if (!$mediaDw->setExistingData($params['existing_content_id'])) {
return $tabId;
}
if ($tabId && $mediaDw->get('tab_id')) {
$this->_getTabModel()->mergeTabIds($tabId, $mediaDw->get('tab_id'));
return $tabId;
}
if (!$tabId) {
if ($mediaDw->get('tab_id')) {
$tabId = $mediaDw->get('tab_id');
} else {
$newTabId = $this->getTabId();
$mediaDw->set('tab_id', $newTabId);
if (!$mediaDw->save()) {
return $tabId;
}
$tabId = $newTabId;
$this->insertTab($tabId, 'xengallery_media', $mediaDw->get('media_id'), $tabName);
}
}
return $tabId;
}
示例2: _log
protected function _log(array $logUser, array $content, $action, array $actionParams = array(), $parentContent = null)
{
$dw = XenForo_DataWriter::create('XenForo_DataWriter_ModeratorLog');
$dw->bulkSet(array('user_id' => $logUser['user_id'], 'content_type' => 'resource_category', 'content_id' => $content['resource_category_id'], 'content_user_id' => $logUser['user_id'], 'content_username' => $logUser['username'], 'content_title' => $content['category_title'], 'content_url' => XenForo_Link::buildPublicLink('resources/categories', $content), 'discussion_content_type' => 'resource_category', 'discussion_content_id' => $content['resource_category_id'], 'action' => $action, 'action_params' => $actionParams));
$dw->save();
return $dw->get('moderator_log_id');
}
示例3: actionTrash
public function actionTrash()
{
if (!XenForo_Visitor::getInstance()->hasPermission('forum', 'trashThreads')) {
throw $this->getErrorOrNoPermissionResponseException(false);
}
if (!($targetNode = XenForo_Application::getOptions()->nixfifty_trash_can)) {
return $this->responseError(new XenForo_Phrase('trash_can_node_not_set'));
}
$threadId = $this->_input->filterSingle('thread_id', XenForo_Input::UINT);
list($thread, $forum) = $this->getHelper('ForumThreadPost')->assertThreadValidAndViewable($threadId);
if ($this->isConfirmedPost()) {
$softDelete = $this->_input->filterSingle('trash_type', XenForo_Input::UINT);
$trashType = $softDelete ? 'move' : 'soft';
$options = array('reason' => $this->_input->filterSingle('reason', XenForo_Input::STRING));
$dw = XenForo_DataWriter::create('XenForo_DataWriter_Discussion_Thread');
$dw->setExistingData($threadId);
$dw->set('node_id', $targetNode);
$dw->save();
if ($trashType == 'soft' && XenForo_Visitor::getInstance()->hasPermission('forum', 'softDeleteTrashedThreads')) {
$this->_getThreadModel()->deleteThread($threadId, $trashType, $options);
XenForo_Model_Log::logModeratorAction('thread', $thread, 'delete_' . $trashType, array('reason' => $options['reason']));
}
XenForo_Model_Log::logModeratorAction('thread', $thread, 'move', array('from' => $forum['title']));
$this->_updateModeratorLogThreadEdit($thread, $dw, array('node_id'));
return $this->responseRedirect(XenForo_ControllerResponse_Redirect::SUCCESS, XenForo_Link::buildPublicLink('forums', $forum));
} else {
return $this->responseView('', 'trash_thread', array('thread' => $thread));
}
}
示例4: execute
public function execute(array $deferred, array $data, $targetRunTime, &$status)
{
$data = array_merge(array('batch' => 100, 'position' => 0, 'positionRebuild' => false), $data);
/* @var $threadModel XenForo_Model_Thread */
$threadModel = XenForo_Model::create('XenForo_Model_Thread');
$threadIds = $threadModel->getThreadIdsInRange($data['position'], $data['batch']);
if (sizeof($threadIds) == 0) {
return false;
}
$forums = XenForo_Model::create('XenForo_Model_Forum')->getForumsByThreadIds($threadIds);
foreach ($threadIds as $threadId) {
$data['position'] = $threadId;
$dw = XenForo_DataWriter::create('XenForo_DataWriter_Discussion_Thread', XenForo_DataWriter::ERROR_SILENT);
if ($dw->setExistingData($threadId)) {
$dw->setOption(XenForo_DataWriter_Discussion::OPTION_UPDATE_CONTAINER, false);
if (isset($forums[$dw->get('node_id')])) {
$dw->setExtraData(XenForo_DataWriter_Discussion_Thread::DATA_FORUM, $forums[$dw->get('node_id')]);
}
if ($data['positionRebuild']) {
$dw->rebuildDiscussion();
} else {
$dw->rebuildDiscussionCounters();
}
$dw->save();
}
}
$actionPhrase = new XenForo_Phrase('rebuilding');
$typePhrase = new XenForo_Phrase('threads');
$status = sprintf('%s... %s (%s)', $actionPhrase, $typePhrase, XenForo_Locale::numberFormat($data['position']));
return $data;
}
示例5: actionExpire
public function actionExpire()
{
$warningId = $this->_input->filterSingle('warning_id', XenForo_Input::UINT);
$warning = $this->_getWarningOrError($warningId);
if (!$this->_getUserModel()->canViewWarnings() || !$this->_getWarningModel()->canUpdateWarningExpiration($warning)) {
return $this->responseNoPermission();
}
if ($this->isConfirmedPost()) {
$expire = $this->_input->filterSingle('expire', XenForo_Input::STRING);
if ($expire == 'now') {
$expiryDate = XenForo_Application::$time;
} else {
if ($expire == 'future') {
$expiryLength = $this->_input->filterSingle('expiry_length', XenForo_Input::UINT);
$expiryUnit = $this->_input->filterSingle('expiry_unit', XenForo_Input::STRING);
$expiryDate = strtotime("+{$expiryLength} {$expiryUnit}");
$expiryDate = min(pow(2, 32) - 1, $expiryDate);
if (!$expiryDate || $expiryDate < XenForo_Application::$time) {
$expiryDate = XenForo_Application::$time;
}
} else {
return $this->responseReroute(__CLASS__, 'index');
}
}
$dw = XenForo_DataWriter::create('XenForo_DataWriter_Warning');
$dw->setExistingData($warning, true);
$dw->set('expiry_date', $expiryDate);
$dw->save();
return $this->responseRedirect(XenForo_ControllerResponse_Redirect::SUCCESS, $this->getDynamicRedirect());
} else {
return $this->responseReroute(__CLASS__, 'index');
}
}
示例6: execute
public function execute(array $deferred, array $data, $targetRunTime, &$status)
{
$data = array_merge(array('position' => 0, 'batch' => 5), $data);
$data['batch'] = max(1, $data['batch']);
/* @var $albumModel XenGallery_Model_Album */
$albumModel = XenForo_Model::create('XenGallery_Model_Album');
/* @var $mediaModel XenGallery_Model_Media */
$mediaModel = XenForo_Model::create('XenGallery_Model_Media');
$albumIds = $albumModel->getAlbumIdsInRange($data['position'], $data['batch']);
if (sizeof($albumIds) == 0) {
return true;
}
foreach ($albumIds as $albumId) {
$count = $mediaModel->countMedia(array('album_id' => $albumId));
$albumWriter = XenForo_DataWriter::create('XenGallery_DataWriter_Album');
$albumWriter->setExistingData($albumId);
$albumWriter->set('album_media_count', $count);
$albumWriter->save();
$data['position'] = $albumId;
}
$actionPhrase = new XenForo_Phrase('rebuilding');
$typePhrase = new XenForo_Phrase('xengallery_rebuilding_album_media_counts');
$status = sprintf('%s... %s (%s)', $actionPhrase, $typePhrase, XenForo_Locale::numberFormat($data['position']));
return $data;
}
示例7: actionSave
/**
* Saves a custom resource field.
*
* @return XenForo_ControllerResponse_Abstract
*/
public function actionSave()
{
$fieldId = $this->_input->filterSingle('field_id', XenForo_Input::STRING);
$newFieldId = $this->_input->filterSingle('new_field_id', XenForo_Input::STRING);
$dwInput = $this->_input->filter(array('display_group' => XenForo_Input::STRING, 'display_order' => XenForo_Input::UINT, 'field_type' => XenForo_Input::STRING, 'match_type' => XenForo_Input::STRING, 'match_regex' => XenForo_Input::STRING, 'match_callback_class' => XenForo_Input::STRING, 'match_callback_method' => XenForo_Input::STRING, 'max_length' => XenForo_Input::UINT, 'required' => XenForo_Input::UINT, 'display_template' => XenForo_Input::STRING));
$categoryIds = $this->_input->filterSingle('resource_category_ids', XenForo_Input::UINT, array('array' => true));
$dw = XenForo_DataWriter::create('XenResource_DataWriter_ResourceField');
if ($fieldId) {
$dw->setExistingData($fieldId);
} else {
$dw->set('field_id', $newFieldId);
}
$dw->bulkSet($dwInput);
$dw->setExtraData(XenResource_DataWriter_ResourceField::DATA_CATEGORY_IDS, $categoryIds);
$dw->setExtraData(XenResource_DataWriter_ResourceField::DATA_TITLE, $this->_input->filterSingle('title', XenForo_Input::STRING));
$dw->setExtraData(XenResource_DataWriter_ResourceField::DATA_DESCRIPTION, $this->_input->filterSingle('description', XenForo_Input::STRING));
$fieldChoices = $this->_input->filterSingle('field_choice', XenForo_Input::STRING, array('array' => true));
$fieldChoicesText = $this->_input->filterSingle('field_choice_text', XenForo_Input::STRING, array('array' => true));
$fieldChoicesCombined = array();
foreach ($fieldChoices as $key => $choice) {
if (isset($fieldChoicesText[$key])) {
$fieldChoicesCombined[$choice] = $fieldChoicesText[$key];
}
}
$dw->setFieldChoices($fieldChoicesCombined);
$dw->save();
return $this->responseRedirect(XenForo_ControllerResponse_Redirect::SUCCESS, XenForo_Link::buildAdminLink('resource-fields') . $this->getLastHash($dw->get('field_id')));
}
示例8: actionDiscordLink
public function actionDiscordLink()
{
$this->_assertPostOnly();
$visitor = XenForo_Visitor::getInstance();
if (!$visitor->hasPermission('general', 'linkDiscord')) {
return $this->responseNoPermission();
}
$tokenModel = $this->_getTokenmodel();
$generate = $this->_input->filterSingle('create', XenForo_Input::STRING, array('default' => ''));
if (strlen($generate)) {
$dw = XenForo_DataWriter::create('DiscordAuth_DataWriter_Token');
$existing = $tokenModel->getTokenByUserId($visitor['user_id']);
if ($existing === false || !$existing['valid']) {
if ($existing !== false) {
$dw->setExistingData($existing, true);
}
try {
$dw->set('user_id', $visitor['user_id']);
$dw->set('token', self::generateToken());
$dw->save();
// self::generateToken may throw Exception
} catch (Exception $e) {
XenForo_Error::logException($e, false);
}
}
}
$unlink = $this->_input->filterSingle('unlink', XenForo_Input::STRING, array('default' => ''));
if (strlen($unlink)) {
$dw = XenForo_DataWriter::create('XenForo_DataWriter_User');
$dw->setExistingData($visitor['user_id']);
$dw->set('da_discord_id', null);
$dw->save();
}
return $this->responseRedirect(XenForo_ControllerResponse_Redirect::SUCCESS, $this->getDynamicRedirect(XenForo_Link::buildPublicLink('account/discord')));
}
示例9: deleteTemplate
public function deleteTemplate($input)
{
$dw = XenForo_DataWriter::create('EWRcarta_DataWriter_Templates');
$dw->setExistingData($input);
$dw->delete();
return true;
}
示例10: createContent
public function createContent($tabId, $tabName, array $createCriteria, array $params)
{
if (!$createCriteria['resource_category_id']) {
return $tabId;
}
/* @var $dw XenResource_DataWriter_Resource */
$dw = XenForo_DataWriter::create('XenResource_DataWriter_Resource', XenForo_DataWriter::ERROR_SILENT);
$dw->bulkSet(array('resource_category_id' => $createCriteria['resource_category_id'], 'title' => $params['title'], 'tag_line' => isset($params['tag_line']) ? $params['tag_line'] : new XenForo_Phrase('waindigo_resource_tag_line_create_tabs', $params, false), 'user_id' => $params['user_id'], 'username' => $params['username'], 'tab_id' => $tabId));
$dw->setOption(Waindigo_Tabs_Extend_XenResource_DataWriter_Resource::OPTION_CHECK_TAB_RULES, false);
$descriptionDw = $dw->getDescriptionDw();
$descriptionDw->set('message', $params['message']);
$versionDw = $dw->getVersionDw();
$dw->set('is_fileless', 1);
$versionDw->setOption(XenResource_DataWriter_Version::OPTION_IS_FILELESS, true);
$versionDw->set('version_string', XenForo_Locale::date(XenForo_Application::$time, 'Y-m-d'));
if ($dw->hasErrors()) {
return $tabId;
}
if (!$tabId) {
$tabId = $this->getTabId();
$dw->set('tab_id', $tabId);
}
if (!$dw->save()) {
return $tabId;
}
$this->insertTab($tabId, 'resource', $dw->get('resource_id'), $tabName);
return $tabId;
}
示例11: execute
public function execute(array $deferred, array $data, $targetRunTime, &$status)
{
$data = array_merge(array('position' => 0, 'batch' => 70), $data);
$data['batch'] = max(1, $data['batch']);
/* @var $postModel XenForo_Model_Post */
$postModel = XenForo_Model::create('XenForo_Model_Post');
$postIds = $postModel->getPostIdsInRange($data['position'], $data['batch']);
if (sizeof($postIds) == 0) {
return true;
}
foreach ($postIds as $postId) {
$data['position'] = $postId;
/* @var $postDw XenForo_DataWriter_DiscussionMessage_Post */
$postDw = XenForo_DataWriter::create('XenForo_DataWriter_DiscussionMessage_Post', XenForo_DataWriter::ERROR_SILENT);
if ($postDw->setExistingData($postId)) {
XenForo_Db::beginTransaction();
$postDw->rebuildPostVerseCache();
XenForo_Db::commit();
}
}
$actionPhrase = new XenForo_Phrase('rebuilding');
$typePhrase = new XenForo_Phrase('posts');
$status = sprintf('%s... %s (%s)', $actionPhrase, $typePhrase, XenForo_Locale::numberFormat($data['position']));
return $data;
}
示例12: insert
public function insert()
{
$dw = XenForo_DataWriter::create($this->dataWriter);
$dw->bulkSet($this->getValidatedInputFields());
$dw->save();
return $dw->getMergedData();
}
示例13: _postInstall
protected function _postInstall()
{
/* @var $captchaQuestionModel XenForo_Model_CaptchaQuestion */
$captchaQuestionModel = XenForo_Model::create('XenForo_Model_CaptchaQuestion');
$captchaQuestions = $captchaQuestionModel->getAllCaptchaQuestions();
/* @var $phraseModel XenForo_Model_Phrase */
$phraseModel = XenForo_Model::create('XenForo_Model_Phrase');
$phrases = $phraseModel->getEffectivePhraseListForLanguage(0, array('title' => 'captcha_question_'));
$phraseTitles = array();
foreach ($phrases as $phrase) {
$phraseTitles[substr($phrase['title'], strlen('captcha_question'))] = $phrase['phrase_id'];
}
foreach ($captchaQuestions as $captchaQuestion) {
$data = array('title' => 'captcha_question_' . $captchaQuestion['captcha_question_id'], 'phrase_text' => $captchaQuestion['question'], 'language_id' => 0, 'global_cache' => 0);
/* @var $writer XenForo_DataWriter_Phrase */
$writer = XenForo_DataWriter::create('XenForo_DataWriter_Phrase');
$phraseId = array_search('captcha_question' . $captchaQuestion['captcha_question_id'], $phraseTitles);
if ($phraseId) {
$writer->setExistingData($phraseId);
}
$writer->bulkSet($data);
if ($writer->isChanged('title') || $writer->isChanged('phrase_text')) {
$writer->updateVersionId();
}
$writer->save();
}
}
示例14: _postSave
/**
*
* @see Waindigo_Library_DataWriter_Library::_postSave()
*/
protected function _postSave()
{
if (isset($GLOBALS['Waindigo_Library_ControllerAdmin_Library'])) {
/* @var $controller Waindigo_Library_ControllerAdmin_Library */
$controller = $GLOBALS['Waindigo_Library_ControllerAdmin_Library'];
$fieldIds = $controller->getInput()->filterSingle('available_fields', XenForo_Input::STRING, array('array' => true));
$this->_getThreadFieldModel()->updateThreadFieldForumAssociationByForum($this->get('node_id'), $fieldIds);
$templates = $controller->getInput()->filter(array('thread_header' => XenForo_Input::STRING, 'thread_footer' => XenForo_Input::STRING));
$headerName = '_header_node.' . $this->get('node_id');
$footerName = '_footer_node.' . $this->get('node_id');
$oldTemplates = $this->_getTemplateModel()->getTemplatesInStyleByTitles(array($headerName, $footerName));
/* @var $templateWriter XenForo_DataWriter_Template */
$templateWriter = XenForo_DataWriter::create('XenForo_DataWriter_Template');
if (isset($oldTemplates[$headerName])) {
$templateWriter->setExistingData($oldTemplates[$headerName]);
}
$templateWriter->set('title', $headerName);
$templateWriter->set('style_id', 0);
$templateWriter->set('template', $templates['thread_header']);
$templateWriter->save();
/* @var $templateWriter XenForo_DataWriter_Template */
$templateWriter = XenForo_DataWriter::create('XenForo_DataWriter_Template');
if (isset($oldTemplates[$footerName])) {
$templateWriter->setExistingData($oldTemplates[$footerName]);
}
$templateWriter->set('title', $footerName);
$templateWriter->set('style_id', 0);
$templateWriter->set('template', $templates['thread_footer']);
$templateWriter->save();
$this->_updateCustomFields = unserialize($this->get('custom_fields'));
}
$this->updateCustomFields();
parent::_postSave();
}
示例15: setPageWatchState
public function setPageWatchState($userID, $pageID, $state, $overWrite = true)
{
$pageWatch = $this->getUserPageWatchByPageId($userID, $pageID);
if ($pageWatch && !$overWrite) {
return true;
}
switch ($state) {
case 'watch_email':
case 'watch_no_email':
$dw = XenForo_DataWriter::create('EWRcarta_DataWriter_PageWatch');
if ($pageWatch) {
$dw->setExistingData($pageWatch, true);
} else {
$dw->set('user_id', $userID);
$dw->set('page_id', $pageID);
}
$dw->set('email_subscribe', $state == 'watch_email' ? 1 : 0);
$dw->save();
return true;
case '':
if ($pageWatch) {
$dw = XenForo_DataWriter::create('EWRcarta_DataWriter_PageWatch');
$dw->setExistingData($pageWatch, true);
$dw->delete();
}
return true;
default:
return false;
}
}