本文整理汇总了PHP中XenForo_DataWriter::getMergedData方法的典型用法代码示例。如果您正苦于以下问题:PHP XenForo_DataWriter::getMergedData方法的具体用法?PHP XenForo_DataWriter::getMergedData怎么用?PHP XenForo_DataWriter::getMergedData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XenForo_DataWriter
的用法示例。
在下文中一共展示了XenForo_DataWriter::getMergedData方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: postDataWriterSave
public static function postDataWriterSave(XenForo_DataWriter $writer, array $extraData = array())
{
$self = new self();
$oldPath = false;
$oldData = array_merge($writer->getMergedExistingData(), array('id' => $writer->get('phrase_id')));
if ($writer->isUpdate()) {
$oldPath = $self->getDirectory($writer->getMergedExistingData()) . self::$s . $self->getFileName($oldData);
}
$newPath = false;
$newData = array_merge($writer->getMergedData(), array('id' => $writer->get('phrase_id')));
if ($writer->isChanged('addon_id') or $writer->isChanged('title')) {
$newPath = $self->getDirectory($newData) . self::$s . $self->getFileName($newData);
}
if (!$oldPath) {
$oldPath = $newPath;
}
if (!DevTools_Helper_File::write($oldPath, $writer->get('phrase_text'), array('id' => $writer->get('phrase_id')))) {
throw new XenForo_Exception("Failed to write phrase file to {$oldPath}");
return;
}
if ($newPath && $oldPath) {
rename($oldPath, $newPath);
}
$self->touchDb();
}
示例3: 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();
}
示例4: assertNoDwErrors
public function assertNoDwErrors(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()) {
$filePath = $this->getDirectory($dw->getMergedData()) . self::$s . $this->getFileName($dw->getMergedData());
if (count($errors) == 1) {
$error = htmlspecialchars_decode($errors[key($errors)]);
// Yes Nathan, I could use regex but fuu
if (strpos($error, 'Line ') === 0) {
$pos = strpos($error, ':');
$line = substr($error, 5, $pos - 5);
$error = trim(substr($error, $pos + 1));
}
$errorString = 'E: ' . $dataType . ' Error: ' . $error . " in " . $filePath;
if (isset($line)) {
$errorString .= ", line {$line} \n\n";
} else {
$errorString .= "\n\n";
}
} else {
foreach ($errors as &$err) {
$err = htmlspecialchars_decode($err);
}
$errorString = 'E: ' . $dataType . " Error: \nin " . $filePath . "\n";
$errorString .= implode("\n", $errors) . "\n\n";
}
XenForo_Helper_File::log('devtools-error', str_replace("\n", ' ', $errorString));
$this->printDebugInfo($errorString);
die;
// throwing wasn't working with console so just doing this
throw new XenForo_Exception($errorString);
}
}