$pValue) { $value = str_replace('{$' . $pKey . '}', $pValue, $value); } return $value; } /** * Used internally by installSettings to recursively build nested arrays. * Deals with translation and variable replacement calls. * @param $node object XMLNode tag * @param $paramArray array Parameters to be replaced in key/value contents */ function &_buildObject (&$node, $paramArray = array()) { $value = array(); foreach ($node->getChildren() as $element) { $key = $element->getAttribute('key'); $childArray = &$element->getChildByName('array'); if (isset($childArray)) { $content = $this->_buildObject($childArray, $paramArray); } else { $content = $this->_performReplacement($element->getValue(), $paramArray); } if (!empty($key)) { $key = $this->_performReplacement($key, $paramArray); $value[$key] = $content; } else $value[] = $content; } return $value; } /** * Install conference settings from an XML file. * @param $id int ID of scheduled conference/conference for settings to apply to * @param $filename string Name of XML file to parse and install * @param $paramArray array Optional parameters for variable replacement in settings */ function installSettings($id, $filename, $paramArray = array()) { $xmlParser = &new XMLParser(); $tree = $xmlParser->parse($filename); if (!$tree) { $xmlParser->destroy(); return false; } foreach ($tree->getChildren() as $setting) { $nameNode = &$setting->getChildByName('name'); $valueNode = &$setting->getChildByName('value'); if (isset($nameNode) && isset($valueNode)) { $type = $setting->getAttribute('type'); $isLocaleField = $setting->getAttribute('locale'); $name = &$nameNode->getValue(); if ($type == 'date') { $value = strtotime($valueNode->getValue()); } elseif ($type == 'object') { $arrayNode = &$valueNode->getChildByName('array'); $value = $this->_buildObject($arrayNode, $paramArray); } else { $value = $this->_performReplacement($valueNode->getValue(), $paramArray); } // Replace translate calls with translated content $this->updateSetting( $id, $name, $isLocaleField?array(Locale::getLocale() => $value):$value, $type, $isLocaleField ); } } $xmlParser->destroy(); } } /** * Used internally by conference setting installation code to perform translation function. */ function _installer_regexp_callback($matches) { return Locale::translate($matches[1]); } ?>