本文整理汇总了PHP中XenForo_Helper_DevelopmentXml类的典型用法代码示例。如果您正苦于以下问题:PHP XenForo_Helper_DevelopmentXml类的具体用法?PHP XenForo_Helper_DevelopmentXml怎么用?PHP XenForo_Helper_DevelopmentXml使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了XenForo_Helper_DevelopmentXml类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: renderXml
public function renderXml()
{
$system =& $this->_params['system'];
$widgets =& $this->_params['widgets'];
$document = new DOMDocument('1.0', 'utf-8');
$document->formatOutput = true;
$rootNode = $document->createElement('widget_framework');
$rootNode->setAttribute('version', $system['version_string']);
$document->appendChild($rootNode);
foreach ($widgets as $widget) {
$widgetNode = $document->createElement('widget');
$widgetNode->setAttribute('title', $widget['title']);
$widgetNode->setAttribute('class', $widget['class']);
$optionsNode = $document->createElement('options');
$optionsString = $widget['options'];
if (!is_string($optionsString)) {
$optionsString = serialize($optionsString);
}
$optionsData = XenForo_Helper_DevelopmentXml::createDomCdataSection($document, $optionsString);
$optionsNode->appendChild($optionsData);
$widgetNode->appendChild($optionsNode);
$widgetNode->setAttribute('position', $widget['position']);
$widgetNode->setAttribute('display_order', $widget['display_order']);
$widgetNode->setAttribute('active', $widget['active']);
$rootNode->appendChild($widgetNode);
}
$this->setDownloadFileName('widget_framework-widgets-' . XenForo_Template_Helper_Core::date(XenForo_Application::$time, 'YmdHi') . '.xml');
return $document->saveXml();
}
示例2: renderXml
public function renderXml()
{
$document = new DOMDocument('1.0', 'utf-8');
$document->formatOutput = true;
$rootNode = $document->createElement('errors');
$document->appendChild($rootNode);
if (isset($this->_params['exception']) && $this->_params['exception'] instanceof Exception) {
$e = $this->_params['exception'];
$exceptionMessage = $e->getMessage();
$rootNode->appendChild(XenForo_Helper_DevelopmentXml::createDomElement($document, 'error', $exceptionMessage));
$traceNode = $document->createElement('trace');
foreach ($e->getTrace() as $trace) {
$function = (isset($trace['class']) ? $trace['class'] . $trace['type'] : '') . $trace['function'];
if (!isset($trace['file'])) {
$trace['file'] = '';
}
if (!isset($trace['line'])) {
$trace['line'] = '';
}
$entryNode = $document->createElement('entry');
$entryNode->setAttribute('function', $function);
$entryNode->setAttribute('file', $trace['file']);
$entryNode->setAttribute('line', $trace['line']);
$traceNode->appendChild($entryNode);
}
$rootNode->appendChild($traceNode);
} else {
$rootNode->appendChild($document->createElement('error', 'Unknown error, trace unavailable'));
}
return $document->saveXML();
}
示例3: renderRedirect
/**
* Simple handler for XML redirects - do not redirect, just send status:ok and redirect:$redirectTarget
*
* @param integer Type of redirect. See {@link XenForo_ControllerResponse_Redirect}
* @param string Target to redirect to
* @param mixed Redirect message
*
* @return string XML response (response tag)
*/
public function renderRedirect($redirectType, $redirectTarget, $redirectMessage = null, array $redirectParams = array())
{
$document = new DOMDocument('1.0', 'utf-8');
$document->formatOutput = true;
$rootNode = $document->createElement('response');
XenForo_Helper_DevelopmentXml::createDomElements($rootNode, array('_redirectStatus' => 'ok', '_redirectTarget' => $redirectTarget, '_redirectMessage' => is_null($redirectMessage) ? new XenForo_Phrase('redirect_changes_saved_successfully') : $redirectMessage, 'jsonParams' => XenForo_ViewRenderer_Json::jsonEncodeForOutput($redirectParams)));
$document->appendChild($rootNode);
return $document->saveXML();
}
示例4: renderXml
public function renderXml()
{
$document = new DOMDocument('1.0', 'utf-8');
$document->formatOutput = true;
$rootNode = $document->createElement('user');
$document->appendChild($rootNode);
XenForo_Helper_DevelopmentXml::createDomElements($rootNode, $this->_params['user']);
return $document->saveXML();
}
示例5: appendAdminTemplatesXml
public function appendAdminTemplatesXml(DOMElement $rootNode, $blockId)
{
$document = $rootNode->ownerDocument;
$adminTemplates = $this->getAdminTemplatesByBlock($blockId);
foreach ($adminTemplates as $template) {
$templateNode = $document->createElement('template');
$templateNode->setAttribute('title', $template['title']);
$templateNode->appendChild(XenForo_Helper_DevelopmentXml::createDomCdataSection($document, $template['template']));
$rootNode->appendChild($templateNode);
}
}
示例6: scanXmlFile
public static function scanXmlFile($xmlFile)
{
if (self::callbackChecker('XenForo_Helper_DevelopmentXml', 'scanFile')) {
//Protected method
$file = XenForo_Helper_DevelopmentXml::scanFile($xmlFile);
} else {
//Classic PHP method
$file = new SimpleXMLElement($xmlFile, null, true);
}
return $file;
}
示例7: execute
public function execute(array $deferred, array $data, $targetRunTime, &$status)
{
$data = array_merge(array('file' => XenForo_Application::getInstance()->getRootDir() . '/install/data/email_templates.xml'), $data);
/* @var $templateModel XenForo_Model_EmailTemplate */
$templateModel = XenForo_Model::create('XenForo_Model_EmailTemplate');
$document = XenForo_Helper_DevelopmentXml::scanFile($data['file']);
$templateModel->importEmailTemplatesAddOnXml($document, 'XenForo', false);
$actionPhrase = new XenForo_Phrase('importing');
$typePhrase = new XenForo_Phrase('email_templates');
$status = sprintf('%s... %s', $actionPhrase, $typePhrase);
return false;
}
示例8: importListenersXml
public function importListenersXml(SimpleXMLElement $xml, $blockId)
{
$db = $this->_getDb();
XenForo_Db::beginTransaction($db);
$this->deleteListenersByBlock($blockId);
$listeners = XenForo_Helper_DevelopmentXml::fixPhpBug50670($xml->listener);
foreach ($listeners as $event) {
$eventId = (string) $event['event_id'];
$dw = XenForo_DataWriter::create('XenForo_DataWriter_CodeEventListener');
$dw->setOption(XenForo_DataWriter_CodeEventListener::OPTION_REBUILD_CACHE, false);
$dw->bulkSet(array('event_id' => (string) $event['event_id'], 'execute_order' => (string) $event['execute_order'], 'callback_class' => (string) $event['callback_class'], 'callback_method' => (string) $event['callback_method'], 'active' => (string) $event['active'], 'description' => (string) $event['description']));
$dw->save();
}
$this->getModelFromCache('XenForo_Model_CodeEvent')->rebuildEventListenerCache();
XenForo_Db::commit($db);
return;
}
示例9: importPhrasesXml
public function importPhrasesXml(SimpleXMLElement $xml, $blockId)
{
$existingPhrases = $this->getPhrasesByBlock($blockId);
$db = $this->_getDb();
XenForo_Db::beginTransaction($db);
$phrases = XenForo_Helper_DevelopmentXml::fixPhpBug50670($xml->phrase);
foreach ($phrases as $phrase) {
$phraseName = (string) $phrase['title'];
$dw = XenForo_DataWriter::create('XenForo_DataWriter_Phrase');
if (isset($existingPhrases[$phraseName])) {
$dw->setExistingData($existingPhrases[$phraseName], true);
}
$dw->bulkSet(array('language_id' => '0', 'title' => $phraseName, 'phrase_text' => (string) $phrase));
$dw->save();
}
XenForo_Db::commit($db);
return;
}
示例10: execute
public function execute(array $deferred, array $data, $targetRunTime, &$status)
{
$data = array_merge(array('file' => XenForo_Application::getInstance()->getRootDir() . '/install/data/phrases.xml', 'offset' => 0, 'position' => 0), $data);
/* @var $phraseModel XenForo_Model_Phrase */
$phraseModel = XenForo_Model::create('XenForo_Model_Phrase');
$document = XenForo_Helper_DevelopmentXml::scanFile($data['file']);
$result = $phraseModel->importPhrasesAddOnXml($document, 'XenForo', $targetRunTime, $data['offset']);
if (is_int($result)) {
$data['offset'] = $result;
$data['position']++;
$actionPhrase = new XenForo_Phrase('importing');
$typePhrase = new XenForo_Phrase('phrases');
$status = sprintf('%s... %s %s', $actionPhrase, $typePhrase, str_repeat(' . ', $data['position']));
return $data;
// continue again
} else {
return false;
}
}
示例11: importFromFile
public function importFromFile($fileName, $deleteAll = false)
{
if (!file_exists($fileName) || !is_readable($fileName)) {
throw new XenForo_Exception(new XenForo_Phrase('please_enter_valid_file_name_requested_file_not_read'), true);
}
try {
$document = new SimpleXMLElement($fileName, 0, true);
} catch (Exception $e) {
throw new XenForo_Exception(new XenForo_Phrase('provided_file_was_not_valid_xml_file'), true);
}
if ($document->getName() != 'widget_framework') {
throw new XenForo_Exception(new XenForo_Phrase('wf_provided_file_is_not_an_widgets_xml_file'), true);
}
$widgets = XenForo_Helper_DevelopmentXml::fixPhpBug50670($document->widget);
XenForo_Db::beginTransaction();
if ($deleteAll) {
// get global widgets from database and delete them all!
// NOTE: ignore widget page widgets
$existingWidgets = $this->getGlobalWidgets(false, false);
foreach ($existingWidgets as $existingWidget) {
$dw = XenForo_DataWriter::create('WidgetFramework_DataWriter_Widget');
$dw->setExtraData(WidgetFramework_DataWriter_Widget::EXTRA_DATA_SKIP_REBUILD, true);
$dw->setExistingData($existingWidget);
$dw->delete();
}
}
foreach ($widgets as $widget) {
$dw = XenForo_DataWriter::create('WidgetFramework_DataWriter_Widget');
$dw->setExtraData(WidgetFramework_DataWriter_Widget::EXTRA_DATA_SKIP_REBUILD, true);
$dw->set('title', $widget['title']);
$dw->set('class', $widget['class']);
$dw->set('position', $widget['position']);
$dw->set('display_order', $widget['display_order']);
$dw->set('active', intval($widget['active']));
$dw->set('options', unserialize(XenForo_Helper_DevelopmentXml::processSimpleXmlCdata($widget->options)));
$dw->save();
}
$this->buildCache();
XenForo_Db::commit();
}
示例12: importAdminTemplatesFieldXml
/**
* Imports admin templates.
* It does not check for conflicts.
*
* @param SimpleXMLElement $xml
*/
public function importAdminTemplatesFieldXml(SimpleXMLElement $xml)
{
$db = $this->_getDb();
if ($xml->template === null) {
return;
}
XenForo_Db::beginTransaction($db);
foreach ($xml->template as $template) {
$templateName = (string) $template['title'];
$dw = XenForo_DataWriter::create('XenForo_DataWriter_AdminTemplate');
$existingTemplate = $this->_getAdminTemplateModel()->getAdminTemplateByTitle($templateName);
if ($existingTemplate) {
$dw->setExistingData($existingTemplate);
}
$dw->setOption(XenForo_DataWriter_AdminTemplate::OPTION_DEV_OUTPUT_DIR, '');
$dw->setOption(XenForo_DataWriter_AdminTemplate::OPTION_FULL_COMPILE, false);
$dw->setOption(XenForo_DataWriter_AdminTemplate::OPTION_TEST_COMPILE, false);
$dw->bulkSet(array('title' => (string) $template['title'], 'template' => XenForo_Helper_DevelopmentXml::processSimpleXmlCdata($template), 'addon_id' => (string) $template['addon_id']));
$dw->save();
}
XenForo_Db::commit($db);
}
示例13: parseSVG
public function parseSVG($filename)
{
$svgfile = null;
try {
if (method_exists('XenForo_Helper_DevelopmentXml', 'scanFile')) {
$svgfile = XenForo_Helper_DevelopmentXml::scanFile($filename);
} else {
$svgfile = new SimpleXMLElement($filename, 0, true);
}
} catch (Exception $e) {
XenForo_Error::logException($e, false);
$svgfile = null;
}
if (empty($svgfile)) {
return null;
}
// check for bad tags
$options = XenForo_Application::getOptions();
$badTags = array_fill_keys(explode(',', strtolower($options->SV_AttachImpro_badTags)), true);
$badAttributes = array_fill_keys(explode(',', strtolower($options->SV_AttachmentImprovements_badAttributes)), true);
return $this->_scanSVG($svgfile, $badTags, $badAttributes);
}
示例14: importSmiliesXml
/**
* Imports a smilie XML file.
*
* @param SimpleXMLElement $document
* @param string $smilieGroupId
* @param integer $overwriteSmilieId
*
* @return array List of cache rebuilders to run
*/
public function importSmiliesXml(SimpleXMLElement $document, $overwrite = 0)
{
if ($document->getName() != 'smilies') {
throw new XenForo_Exception(new XenForo_Phrase('waindigo_provided_file_is_not_valid_smilie_xml_smilieimporter'), true);
}
$smilies = XenForo_Helper_DevelopmentXml::fixPhpBug50670($document->smilie);
$db = $this->_getDb();
/* @var $smilie SimpleXMLElement */
XenForo_Db::beginTransaction($db);
foreach ($smilies as $smilie) {
$smilieText = XenForo_Helper_DevelopmentXml::processSimpleXmlCdata($smilie->smilie_text);
$existing = $this->getSmiliesByText($smilieText);
$updateText = array();
foreach ($existing as $text => $existingSmilie) {
if ($overwrite) {
if (isset($updateText[$existingSmilie['smilie_id']])) {
$existingSmilie['smilie_text'] = $updateText[$existingSmilie['smilie_id']];
}
$existingSmilie['smilie_text'] = preg_split('/\\R/m', $existingSmilie['smilie_text']);
unset($existingSmilie['smilie_text'][array_search($text, $existingSmilie['smilie_text'])]);
if (!empty($existingSmilie['smilie_text'])) {
$updateText[$existingSmilie['smilie_id']] = implode(PHP_EOL, $existingSmilie['smilie_text']);
} else {
$dw = XenForo_DataWriter::create('XenForo_DataWriter_Smilie', XenForo_DataWriter::ERROR_SILENT);
$dw->setExistingData($existingSmilie['smilie_id']);
$dw->delete();
}
} else {
$smilieText = preg_split('/\\R/m', $smilieText);
if (in_array($text, $smilieText)) {
unset($smilieText[array_search($text, $smilieText)]);
}
$smilieText = implode(PHP_EOL, $smilieText);
if (!trim($smilieText)) {
continue;
}
}
}
foreach ($updateText as $smilieId => $updateTextItem) {
$dw = XenForo_DataWriter::create('XenForo_DataWriter_Smilie', XenForo_DataWriter::ERROR_SILENT);
$dw->setExistingData($smilieId);
$dw->set('smilie_text', $updateTextItem);
$dw->save();
}
if (!trim($smilieText)) {
continue;
}
$dw = XenForo_DataWriter::create('XenForo_DataWriter_Smilie', XenForo_DataWriter::ERROR_SILENT);
$spriteParams = array('h' => (string) $smilie['h'], 'w' => (string) $smilie['w'], 'x' => (string) $smilie['x'], 'y' => (string) $smilie['y']);
$dw->bulkSet(array('title' => XenForo_Helper_DevelopmentXml::processSimpleXmlCdata($smilie->title), 'image_url' => XenForo_Helper_DevelopmentXml::processSimpleXmlCdata($smilie->image_url), 'smilie_text' => $smilieText, 'sprite_mode' => (string) $smilie['sprite_mode'], 'sprite_params' => $spriteParams));
$dw->save();
}
XenForo_Db::commit($db);
}
示例15: importStylePropertyDevelopmentXml
/**
* Imports the development admin navigation XML data.
*
* @param string $fileName File to read the XML from
*/
public function importStylePropertyDevelopmentXml($fileName, $styleId)
{
$document = XenForo_Helper_DevelopmentXml::scanFile($fileName);
$this->importStylePropertyXml($document, $styleId, 'XenForo');
}