コード例 #1
0
 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
0
ファイル: Templates.php プロジェクト: Sywooch/forums
 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);
     }
 }
コード例 #3
0
 /**
  * @param DOMElement $rootNode
  * @param array $moderator
  */
 protected function _appendContentModeratorXml(DOMElement $rootNode, $moderator)
 {
     $document = $rootNode->ownerDocument;
     $rootNode->setAttribute('content_id', $moderator['content_id']);
     $rootNode->setAttribute('content_type', $moderator['content_type']);
     $rootNode->setAttribute('username', $moderator['username']);
     $rootNode->setAttribute('user_id', $moderator['user_id']);
     $permissionsNode = $document->createElement('moderator_permissions');
     $rootNode->appendChild($permissionsNode);
     $permissionsNode->appendChild(XenForo_Helper_DevelopmentXml::createDomCdataSection($document, $moderator['moderator_permissions']));
 }
コード例 #4
0
 /**
  * Appends the admin template XML for admin templates in the specified
  * custom field.
  *
  * @param DOMElement $rootNode
  * @param array $field
  */
 public function appendAdminTemplatesFieldXml(DOMElement $rootNode, array $field)
 {
     $document = $rootNode->ownerDocument;
     $titles = array();
     if ($field['export_callback_class'] && $field['export_callback_method']) {
         $error = '';
         $exportInfo = call_user_func_array(array($field['export_callback_class'], $field['export_callback_method']), array($field, &$error));
         $titles = $exportInfo['admin_templates'];
     }
     if (!empty($titles)) {
         $templates = $this->_getAdminTemplateModel()->getAdminTemplatesByTitles($titles);
         foreach ($templates as $template) {
             $templateNode = $document->createElement('template');
             $templateNode->setAttribute('title', $template['title']);
             $templateNode->setAttribute('addon_id', $template['addon_id']);
             $templateNode->appendChild(XenForo_Helper_DevelopmentXml::createDomCdataSection($document, $template['template']));
             $rootNode->appendChild($templateNode);
         }
     }
 }
コード例 #5
0
ファイル: Smilie.php プロジェクト: Sywooch/forums
 /**
  * @param DOMElement $rootNode
  * @param array $smilie
  */
 protected function _appendSmilieXml(DOMElement $rootNode, $smilie)
 {
     $document = $rootNode->ownerDocument;
     if ($smilie['sprite_params']) {
         $spriteParams = unserialize($smilie['sprite_params']);
     } else {
         $spriteParams = array('w' => '', 'h' => '', 'x' => '', 'y' => '');
     }
     $rootNode->setAttribute('y', $spriteParams['y']);
     $rootNode->setAttribute('x', $spriteParams['x']);
     $rootNode->setAttribute('h', $spriteParams['h']);
     $rootNode->setAttribute('w', $spriteParams['w']);
     $rootNode->setAttribute('sprite_mode', $smilie['sprite_mode']);
     $titleNode = $document->createElement('title');
     $rootNode->appendChild($titleNode);
     $titleNode->appendChild(XenForo_Helper_DevelopmentXml::createDomCdataSection($document, $smilie['title']));
     $titleNode = $document->createElement('image_url');
     $rootNode->appendChild($titleNode);
     $titleNode->appendChild(XenForo_Helper_DevelopmentXml::createDomCdataSection($document, $smilie['image_url']));
     $titleNode = $document->createElement('smilie_text');
     $rootNode->appendChild($titleNode);
     $titleNode->appendChild(XenForo_Helper_DevelopmentXml::createDomCdataSection($document, $smilie['smilie_text']));
 }
コード例 #6
0
ファイル: Template.php プロジェクト: namgiangle90/tokyobaito
 /**
  * Appends the template XML for templates in the specified style.
  *
  * @param DOMElement $rootNode
  * @param integer $styleId
  * @param string|null $limitAddOnId If non-null, limits only to templates in this add-on
  * @param boolean $independent If true, all customizations from parent styles will be included in this
  */
 public function appendTemplatesStyleXml(DOMElement $rootNode, $styleId, $limitAddOnId = null, $independent = false)
 {
     $document = $rootNode->ownerDocument;
     if (!$styleId) {
         // getting master data
         $independent = false;
     }
     if ($independent) {
         $templates = $this->getAllEffectiveTemplatesInStyle($styleId);
     } else {
         $templates = $this->getAllTemplatesInStyle($styleId);
     }
     foreach ($templates as $template) {
         if ($limitAddOnId !== null && $template['addon_id'] !== $limitAddOnId) {
             // wrong add-on
             continue;
         }
         if ($independent && !$template['style_id']) {
             // master version of a template
             continue;
         }
         $templateNode = $document->createElement('template');
         $templateNode->setAttribute('title', $template['title']);
         $templateNode->setAttribute('addon_id', $template['addon_id']);
         $templateNode->setAttribute('version_id', $template['version_id']);
         $templateNode->setAttribute('version_string', $template['version_string']);
         $templateNode->setAttribute('disable_modifications', $template['disable_modifications']);
         $templateNode->appendChild(XenForo_Helper_DevelopmentXml::createDomCdataSection($document, $template['template']));
         $rootNode->appendChild($templateNode);
     }
 }
コード例 #7
0
ファイル: BbCode.php プロジェクト: Sywooch/forums
 /**
  * Appends the add-on BB code media sites XML to a given DOM element.
  *
  * @param DOMElement $rootNode Node to append all elements to
  * @param string $addOnId Add-on ID to be exported
  */
 public function appendBbCodeMediaSitesAddOnXml(DOMElement $rootNode, $addOnId)
 {
     $document = $rootNode->ownerDocument;
     $siteFields = XenForo_DataWriter::create('XenForo_DataWriter_BbCodeMediaSite')->getFieldNames();
     $childTags = array('match_urls', 'embed_html');
     foreach ($this->getBbCodeMediaSitesByAddOnId($addOnId) as $site) {
         $siteNode = $document->createElement('site');
         foreach ($siteFields as $fieldName) {
             if ($fieldName != 'addon_id') {
                 if (in_array($fieldName, $childTags)) {
                     $fieldNode = $document->createElement($fieldName);
                     $fieldNode->appendChild(XenForo_Helper_DevelopmentXml::createDomCdataSection($document, $site[$fieldName]));
                     $siteNode->appendChild($fieldNode);
                 } else {
                     $siteNode->setAttribute($fieldName, $site[$fieldName]);
                 }
             }
         }
         $rootNode->appendChild($siteNode);
     }
 }
コード例 #8
0
ファイル: Hooks.php プロジェクト: Sywooch/forums
 protected function _getHookXmlNode(DOMDocument $document, array $hook)
 {
     $attributes = array('hook_id', 'active');
     $children = array('hook_title', 'template', 'hook_name');
     $hookNode = $document->createElement('hook');
     foreach ($attributes as $attribute) {
         $hookNode->setAttribute($attribute, $hook[$attribute]);
     }
     foreach ($children as $child) {
         $fieldNode = $document->createElement($child);
         $fieldNode->appendChild(XenForo_Helper_DevelopmentXml::createDomCdataSection($document, $hook[$child]));
         $hookNode->appendChild($fieldNode);
     }
     return $hookNode;
 }
コード例 #9
0
 /**
  *
  * @param DOMElement $rootCategory
  * @param array $field
  */
 protected function _appendFieldXml(DOMElement $rootCategory, $field)
 {
     $document = $rootCategory->ownerDocument;
     $rootCategory->setAttribute('export_callback_method', $field['export_callback_method']);
     $rootCategory->setAttribute('export_callback_class', $field['export_callback_class']);
     $rootCategory->setAttribute('field_callback_method', $field['field_callback_method']);
     $rootCategory->setAttribute('field_callback_class', $field['field_callback_class']);
     $rootCategory->setAttribute('field_choices_callback_class', $field['field_choices_callback_class']);
     $rootCategory->setAttribute('field_choices_callback_method', $field['field_choices_callback_method']);
     $rootCategory->setAttribute('display_callback_method', $field['display_callback_method']);
     $rootCategory->setAttribute('display_callback_class', $field['display_callback_class']);
     $rootCategory->setAttribute('max_length', $field['max_length']);
     $rootCategory->setAttribute('match_callback_method', $field['match_callback_method']);
     $rootCategory->setAttribute('match_callback_class', $field['match_callback_class']);
     $rootCategory->setAttribute('match_regex', $field['match_regex']);
     $rootCategory->setAttribute('match_type', $field['match_type']);
     $rootCategory->setAttribute('field_type', $field['field_type']);
     $rootCategory->setAttribute('display_order', $field['display_order']);
     $rootCategory->setAttribute('field_id', $field['field_id']);
     $rootCategory->setAttribute('addon_id', $field['addon_id']);
     $titleCategory = $document->createElement('title');
     $rootCategory->appendChild($titleCategory);
     $titleCategory->appendChild(XenForo_Helper_DevelopmentXml::createDomCdataSection($document, new XenForo_Phrase('resource_field_' . $field['field_id'])));
     $descriptionCategory = $document->createElement('description');
     $rootCategory->appendChild($descriptionCategory);
     $descriptionCategory->appendChild(XenForo_Helper_DevelopmentXml::createDomCdataSection($document, new XenForo_Phrase('resource_field_' . $field['field_id'] . '_desc')));
     $displayTemplateCategory = $document->createElement('display_template');
     $rootCategory->appendChild($displayTemplateCategory);
     $displayTemplateCategory->appendChild(XenForo_Helper_DevelopmentXml::createDomCdataSection($document, $field['display_template']));
     $fieldChoicesCategory = $document->createElement('field_choices');
     $rootCategory->appendChild($fieldChoicesCategory);
     if ($field['field_choices']) {
         $fieldChoices = unserialize($field['field_choices']);
         foreach ($fieldChoices as $fieldChoiceValue => $fieldChoiceText) {
             $fieldChoiceCategory = $document->createElement('field_choice');
             $fieldChoiceCategory->setAttribute('value', $fieldChoiceValue);
             $fieldChoiceCategory->appendChild(XenForo_Helper_DevelopmentXml::createDomCdataSection($document, $fieldChoiceText));
             $fieldChoicesCategory->appendChild($fieldChoiceCategory);
         }
     }
 }
コード例 #10
0
ファイル: Class.php プロジェクト: ThemeHouse-XF/Objects
 /**
  * @param DOMElement $rootNode
  * @param array $class
  */
 protected function _appendClassXml(DOMElement $rootNode, $class)
 {
     $document = $rootNode->ownerDocument;
     $rootNode->setAttribute('class_id', $class['class_id']);
     $rootNode->setAttribute('class_id_plural', $class['class_id_plural']);
     $rootNode->setAttribute('route_prefix', $class['route_prefix']);
     $rootNode->setAttribute('route_prefix_admin', $class['route_prefix_admin']);
     $titleNode = $document->createElement('title');
     $rootNode->appendChild($titleNode);
     $titleNode->appendChild(XenForo_Helper_DevelopmentXml::createDomCdataSection($document, $class['title']));
     $titleNode = $document->createElement('title_plural');
     $rootNode->appendChild($titleNode);
     $titleNode->appendChild(XenForo_Helper_DevelopmentXml::createDomCdataSection($document, $class['title_plural']));
     $titleNode = $document->createElement('title_full');
     $rootNode->appendChild($titleNode);
     $titleNode->appendChild(XenForo_Helper_DevelopmentXml::createDomCdataSection($document, $class['title_full']));
     $rootNode->setAttribute('table_name', $class['table_name']);
     //        $rootNode->setAttribute('primary_key_id', $class['primary_key_id']);
 }
コード例 #11
0
 /**
  * Appends the add-on template modification XML to a given DOM element.
  *
  * @param DOMElement $rootNode Node to append all prefix elements to
  * @param string $addOnId Add-on ID to be exported
  */
 public function appendModificationAddOnXml(DOMElement $rootNode, $addOnId)
 {
     $modifications = $this->getModificationsByAddOnId($addOnId);
     $document = $rootNode->ownerDocument;
     foreach ($modifications as $modification) {
         $modNode = $document->createElement('modification');
         $modNode->setAttribute('template', $modification['template']);
         $modNode->setAttribute('modification_key', $modification['modification_key']);
         $modNode->setAttribute('description', $modification['description']);
         $modNode->setAttribute('execution_order', $modification['execution_order']);
         $modNode->setAttribute('enabled', $modification['enabled']);
         $modNode->setAttribute('action', $modification['action']);
         $findNode = $document->createElement('find');
         $findNode->appendChild(XenForo_Helper_DevelopmentXml::createDomCdataSection($document, $modification['find']));
         $modNode->appendChild($findNode);
         $replaceNode = $document->createElement('replace');
         $replaceNode->appendChild(XenForo_Helper_DevelopmentXml::createDomCdataSection($document, $modification['replace']));
         $modNode->appendChild($replaceNode);
         $this->_modifyAddOnXmlNode($modNode, $modification);
         $rootNode->appendChild($modNode);
     }
 }