本文整理汇总了PHP中XenForo_DataWriter::get方法的典型用法代码示例。如果您正苦于以下问题:PHP XenForo_DataWriter::get方法的具体用法?PHP XenForo_DataWriter::get怎么用?PHP XenForo_DataWriter::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XenForo_DataWriter
的用法示例。
在下文中一共展示了XenForo_DataWriter::get方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Tinhte_XenTag_execute
public function Tinhte_XenTag_execute(XenForo_DataWriter $dw)
{
if ($dw->isChanged('tags')) {
return;
}
/** @var Tinhte_XenTag_XenForo_DataWriter_Discussion_Thread $dw */
if (empty($this->_data['actions']['tinhte_xentag'])) {
return;
}
$data = $this->_data['actions']['tinhte_xentag'];
if (empty($data['remove']) && empty($data['add']) && empty($data['replace']) && empty($data['remove_all'])) {
return;
}
/** @var XenForo_Model_Tag $tagModel */
$tagModel = $dw->getModelFromCache('XenForo_Model_Tag');
$tagger = $tagModel->getTagger('thread');
$tagger->setContent($dw->get('thread_id'))->setPermissionsFromContext($dw->getMergedData(), $dw->Tinhte_XenTag_getForumData());
if (!empty($data['remove'])) {
$tagTexts = $tagModel->splitTags($data['remove']);
$tagger->removeTags($tagTexts, false);
}
if (!empty($data['add'])) {
$tagTexts = $tagModel->splitTags($data['add']);
$tagger->addTags($tagTexts);
}
if (!empty($data['replace'])) {
$tagTexts = $tagModel->splitTags($data['replace']);
$tagger->setTags($tagTexts, false);
} elseif (!empty($data['remove_all'])) {
$tagger->setTags(array(), false);
}
$tagger->save();
}
示例2: bdSocialShare_actionSave
public function bdSocialShare_actionSave(XenForo_DataWriter $dw)
{
$dataId = $dw->get('photo_data_id');
if (empty($dataId)) {
// sonnb - XenGallery v2.0.0
$dataId = $dw->get('content_data_id');
}
if ($this->_bdSocialShare_shouldProcessDataId($dataId)) {
/* @var $helper bdSocialShare_ControllerHelper_SocialShare */
$helper = $this->getHelper('bdSocialShare_ControllerHelper_SocialShare');
if ($dw instanceof sonnb_XenGallery_DataWriter_Photo) {
$helper->publishAsNeeded('sonnbXenGalleryPhotoAttach', new bdSocialShare_Shareable_sonnb_XenGallery_Photo($dw), $dataId);
} else {
$helper->publishAsNeeded('sonnbXenGalleryPhotoAttach', new bdSocialShare_Shareable_sonnb_XenGallery_Video($dw), $dataId);
}
}
}
示例3: 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;
}
示例4: 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;
}
示例5: assertNoErrors
public static function assertNoErrors(XenForo_DataWriter $dw, $checkMethod, $dataType)
{
switch (strtolower($checkMethod)) {
case 'delete':
case 'predelete':
$checkMethod = 'preDelete';
break;
case 'save':
case 'presave':
default:
$checkMethod = 'preSave';
break;
}
$dw->{$checkMethod}();
if ($errors = $dw->getErrors()) {
$errorString = implode("\n\t", $errors);
XenForo_Helper_File::log('webdav-error', sprintf("%s:\n\t%s\n\t%s", $dataType, $dw->get('title'), $errorString), false);
// Note that in order to have Dreamweaver actually show an error, we have to use 'Forbidden'.
throw new Sabre_DAV_Exception_Forbidden($errorString);
}
}
示例6: postDataWriterDelete
public static function postDataWriterDelete(XenForo_DataWriter $writer, array $extraData = array())
{
$self = new self();
$phrase = array('id' => $writer->get('phrase_id'), 'contents' => $writer->get('phrase_text'), 'addon_id' => $writer->get('addon_id'), 'title' => $writer->get('title'));
$phrase['fileName'] = $self->getFileName($phrase);
$self->trashFile($phrase);
unlink($self->getDirectory($phrase) . self::$s . $phrase['fileName']);
}
示例7: rebuildFieldChoices
public function rebuildFieldChoices(XenForo_DataWriter $dw)
{
$classId = $dw->get('class_id');
$objects = $this->getObjects(array('class_id' => $classId));
$fieldChoices = array();
foreach ($objects as $object) {
$fieldChoices[$object['object_id']] = $object['title'];
}
$dw->setFieldChoices($fieldChoices);
}
示例8: verifyPosition
public static function verifyPosition(&$positions, XenForo_DataWriter $dw, $fieldName = false)
{
if ($dw->get('widget_page_id') > 0) {
if ($positions === 'sidebar') {
// good
} else {
$positions = '';
}
return true;
}
// sondh@2012-08-28
// it may be better to use strtolower with $positions (making it easier for
// admins)
// but some add-on developers decided to use template with mixed case characters
// so...
// no strtolower goodness for everyone.
$positions = trim($positions);
if (empty($positions)) {
$dw->error(new XenForo_Phrase('wf_position_can_not_be_empty'), $fieldName);
}
if ('all' == $positions) {
return true;
}
$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;
}
// 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;
}
} else {
$found = $templateModel->getTemplateInStyleByTitle($position);
if (!$found) {
$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;
}
示例9: _checkContentState
protected function _checkContentState(XenForo_DataWriter $dw)
{
switch ($this->get('content_type')) {
case sonnb_XenGallery_Model_Album::$contentType:
return $dw->get('album_state');
break;
case sonnb_XenGallery_Model_Photo::$contentType:
case sonnb_XenGallery_Model_Video::$contentType:
default:
return $dw->get('content_state');
break;
}
}
示例10: postDataWriterDelete
public static function postDataWriterDelete(XenForo_DataWriter $writer, array $extraData = array())
{
if (!isset($extraData['styleId']) || !isset($extraData['self'])) {
return;
}
$styleId = $extraData['styleId'];
$self = $extraData['self'];
$contents = XenForo_Model::create('XenForo_Model_StyleProperty')->replacePropertiesInTemplateForEditor($writer->get('template'), $styleId, $self->getPropertiesInStyle($styleId));
$contents = XenForo_Model::create('XenForo_Model_Template')->replaceIncludesWithLinkRel($contents);
$template = array('id' => $writer->get('template_id'), 'contents' => $contents, 'addon_id' => $writer->get('addon_id'), 'title' => $writer->get('title'));
$template['fileName'] = $self->getFileName($template);
$self->trashFile($template);
unlink($self->getDirectory($writer->getMergedData()) . self::$s . $template['fileName']);
$self->touchDb();
}