コード例 #1
0
ファイル: Xml.php プロジェクト: namgiangle90/tokyobaito
 /**
  * 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();
 }
コード例 #2
0
 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();
 }
コード例 #3
0
 /**
  * Appends the add-on options XML to a given DOM element.
  *
  * @param DOMElement $rootNode Node to append all navigation elements to
  * @param string $addOnId Add-on ID to be exported
  */
 public function appendOptionsAddOnXml(DOMElement $rootNode, $addOnId)
 {
     $groups = $this->getOptionGroupsByAddOn($addOnId);
     $options = $this->getOptionsByAddOn($addOnId);
     $relations = $this->getOptionRelationsGroupedByOption(array_keys($options));
     $document = $rootNode->ownerDocument;
     foreach ($groups as $group) {
         $groupNode = $document->createElement('group');
         $groupNode->setAttribute('group_id', $group['group_id']);
         $groupNode->setAttribute('display_order', $group['display_order']);
         $groupNode->setAttribute('debug_only', $group['debug_only']);
         $rootNode->appendChild($groupNode);
     }
     foreach ($options as $option) {
         $optionNode = $document->createElement('option');
         $optionNode->setAttribute('option_id', $option['option_id']);
         $optionNode->setAttribute('edit_format', $option['edit_format']);
         $optionNode->setAttribute('data_type', $option['data_type']);
         $optionNode->setAttribute('can_backup', $option['can_backup']);
         if ($option['validation_class']) {
             $optionNode->setAttribute('validation_class', $option['validation_class']);
             $optionNode->setAttribute('validation_method', $option['validation_method']);
         }
         XenForo_Helper_DevelopmentXml::createDomElements($optionNode, array('default_value' => str_replace("\r\n", "\n", $option['default_value']), 'edit_format_params' => str_replace("\r\n", "\n", $option['edit_format_params']), 'sub_options' => str_replace("\r\n", "\n", $option['sub_options'])));
         if (isset($relations[$option['option_id']])) {
             foreach ($relations[$option['option_id']] as $relation) {
                 $relationNode = $document->createElement('relation');
                 $relationNode->setAttribute('group_id', $relation['group_id']);
                 $relationNode->setAttribute('display_order', $relation['display_order']);
                 $optionNode->appendChild($relationNode);
             }
         }
         $rootNode->appendChild($optionNode);
     }
     return $document;
 }
コード例 #4
0
 /**
  * Appends the style property list to an XML document.
  *
  * @param DOMElement $rootNode Node to append to
  * @param integer $styleId Style to read values/definitions from
  * @param string|null $addOnId If not null, limits to values/definitions in the specified add-on
  * @param boolean $independent If true, exports all customized properties to the root
  */
 public function appendStylePropertyXml(DOMElement $rootNode, $styleId, $addOnId = null, $independent = false)
 {
     $document = $rootNode->ownerDocument;
     if (!$styleId) {
         $independent = false;
     }
     if ($independent) {
         $properties = $this->getEffectiveStylePropertiesInStyle($styleId);
     } else {
         $properties = $this->getStylePropertiesInStyles(array($styleId));
     }
     ksort($properties);
     foreach ($properties as $property) {
         if ($addOnId !== null && $property['addon_id'] !== $addOnId) {
             continue;
         }
         if ($independent && $property['definition_style_id'] == 0 && $property['effectiveState'] == 'default') {
             continue;
         }
         $node = $document->createElement('property');
         $node->setAttribute('property_name', $property['property_name']);
         $node->setAttribute('property_type', $property['property_type']);
         if ($independent && $property['definition_style_id'] || $property['definition_style_id'] == $styleId) {
             $node->setAttribute('definition', 1);
             $node->setAttribute('group_name', $property['group_name']);
             $node->setAttribute('title', isset($property['masterTitle']) ? $property['masterTitle'] : strval($property['title']));
             $node->setAttribute('description', isset($property['masterDescription']) ? $property['masterDescription'] : strval($property['description']));
             $components = unserialize($property['css_components']);
             $node->setAttribute('css_components', implode(',', array_keys($components)));
             $node->setAttribute('scalar_type', $property['scalar_type']);
             $node->setAttribute('scalar_parameters', $property['scalar_parameters']);
             $node->setAttribute('display_order', $property['display_order']);
             $node->setAttribute('sub_group', $property['sub_group']);
         }
         if ($property['property_type'] == 'scalar') {
             $node->appendChild($document->createCDATASection($property['property_value']));
         } else {
             $node->appendChild($document->createCDATASection(json_encode(unserialize($property['property_value']))));
         }
         $rootNode->appendChild($node);
     }
     if ($independent) {
         $groups = $this->getEffectiveStylePropertyGroupsInStyle($styleId);
     } else {
         $groups = $this->getStylePropertyGroupsInStyles(array($styleId));
     }
     ksort($groups);
     foreach ($groups as $group) {
         if ($addOnId !== null && $group['addon_id'] !== $addOnId) {
             continue;
         }
         if ($independent && $group['group_style_id'] == 0) {
             continue;
         }
         $node = $document->createElement('group');
         $rootNode->appendChild($node);
         $node->setAttribute('group_name', $group['group_name']);
         $node->setAttribute('display_order', $group['display_order']);
         XenForo_Helper_DevelopmentXml::createDomElements($node, array('title' => $group['title'], 'description' => $group['description']));
     }
 }
コード例 #5
0
ファイル: Options.php プロジェクト: namgiangle90/tokyobaito
 public function appendOptionsXml(DOMElement $rootNode, $blockId)
 {
     $document = $rootNode->ownerDocument;
     $options = $this->getOptionsByBlock($blockId);
     foreach ($options as $option) {
         $optionNode = $document->createElement('option');
         $optionNode->setAttribute('option_id', $option['option_id']);
         $optionNode->setAttribute('edit_format', $option['edit_format']);
         $optionNode->setAttribute('data_type', $option['data_type']);
         $optionNode->setAttribute('display_order', $option['display_order']);
         if ($option['validation_class']) {
             $optionNode->setAttribute('validation_class', $option['validation_class']);
             $optionNode->setAttribute('validation_method', $option['validation_method']);
         }
         XenForo_Helper_DevelopmentXml::createDomElements($optionNode, array('option_value' => str_replace("\r\n", "\n", $option['option_value']), 'edit_format_params' => str_replace("\r\n", "\n", $option['edit_format_params']), 'sub_options' => str_replace("\r\n", "\n", $option['sub_options']), 'title' => str_replace("\r\n", "\n", $option['title'])));
         $explainNode = $optionNode->appendChild($document->createElement('explain'));
         $explainNode->appendChild($document->createCDATASection($option['explain']));
         $rootNode->appendChild($optionNode);
     }
 }
コード例 #6
0
ファイル: StylePropertyGroup.php プロジェクト: Sywooch/forums
 public function writeGroupDevelopmentFile(array $group)
 {
     $fileName = $this->getGroupDevelopmentFileName($group['group_name'], $group['group_style_id']);
     $document = new DOMDocument('1.0', 'utf-8');
     $document->formatOutput = true;
     $node = $document->createElement('group');
     $document->appendChild($node);
     $node->setAttribute('display_order', $group['display_order']);
     XenForo_Helper_DevelopmentXml::createDomElements($node, array('title' => $group['title'], 'description' => $group['description']));
     $document->save($fileName);
 }