/** * @see wcf\form\IForm::validate() */ public function validate() { parent::validate(); // upload if ($this->optionImport && $this->optionImport['error'] != 4) { if ($this->optionImport['error'] != 0) { throw new UserInputException('optionImport', 'uploadFailed'); } try { $xml = new XML($this->optionImport['tmp_name']); $optionsXML = $xml->getElementTree('options'); foreach ($optionsXML['children'] as $option) { $name = $value = ''; foreach ($option['children'] as $optionData) { switch ($optionData['name']) { case 'name': $name = $optionData['cdata']; break; case 'value': $value = $optionData['cdata']; break; } } if (!empty($name)) { $this->options[$name] = $value; } } } catch (SystemException $e) { throw new UserInputException('optionImport', 'importFailed'); } } else { throw new UserInputException('optionImport'); } }
/** * Reads the data of a variables.xml file. * * @param string $string contents of a variable.xml file * @return array data */ public static function readVariablesData($string) { // open variables.xml $variablesXML = new XML(); $variablesXML->loadString($string); $variablesXMLContent = $variablesXML->getElementTree('variables'); // get variables $variables = array(); foreach ($variablesXMLContent['children'] as $variable) { if (isset($variable['attrs']['name'])) { $variables[$variable['attrs']['name']] = $variable['cdata']; } } return $variables; }