Beispiel #1
0
 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;
 }
Beispiel #2
0
 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;
 }
 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;
     }
 }
 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);
 }
Beispiel #5
0
 /**
  * Imports the options development XML data.
  *
  * @param string $fileName File to read the XML from
  */
 public function importOptionsDevelopmentXml($fileName)
 {
     $document = XenForo_Helper_DevelopmentXml::scanFile($fileName);
     $this->importOptionsAddOnXml($document, 'XenForo');
 }
 /**
  * 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');
 }
Beispiel #7
0
 /**
  * Installs (or upgrades) an add-on using XML from a file.
  *
  * If an upgrade add-on is given, the XML add-on ID will be checked against if.
  * If matching, an upgrade will be performed. Otherwise, installing existing add-ons will
  * be blocked.
  *
  * @param string $fileName Path to file
  * @param string|false $upgradeAddOnId ID of the add-on to upgrade, if there is one
  *
  * @return bool
  */
 public function installAddOnXmlFromFile($fileName, $upgradeAddOnId = 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 = XenForo_Helper_DevelopmentXml::scanFile($fileName);
     } catch (Exception $e) {
         throw new XenForo_Exception(new XenForo_Phrase('provided_file_was_not_valid_xml_file'), true);
     }
     return $this->installAddOnXml($document, $upgradeAddOnId);
 }
 /**
  * Imports the development admin navigation XML data.
  *
  * @param string $fileName File to read the XML from
  */
 public function importAdminNavigationDevelopmentXml($fileName)
 {
     $document = XenForo_Helper_DevelopmentXml::scanFile($fileName);
     $this->importAdminNavigationAddOnXml($document, 'XenForo');
 }
 /**
  * Reads all of the meta-data out of the specified file.
  *
  * @param string $metaDataFile Path to meta data file
  *
  * @return array Format: [title] => meta-data
  */
 public static function readMetaDataFile($metaDataFile)
 {
     if (file_exists($metaDataFile)) {
         $metaData = array();
         $xml = XenForo_Helper_DevelopmentXml::scanFile($metaDataFile);
         foreach ($xml->item as $tag) {
             $title = (string) $tag['title'];
             if (isset($metaData[$title])) {
                 continue;
                 // give precedence to earlier entries as they are more up to date
             }
             $attributes = array();
             foreach ($tag->attributes() as $key => $value) {
                 $attributes[(string) $key] = (string) $value;
             }
             $metaData[$title] = $attributes;
         }
     } else {
         $metaData = array();
     }
     return $metaData;
 }