本文整理汇总了PHP中XMLParser::destroy方法的典型用法代码示例。如果您正苦于以下问题:PHP XMLParser::destroy方法的具体用法?PHP XMLParser::destroy怎么用?PHP XMLParser::destroy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XMLParser
的用法示例。
在下文中一共展示了XMLParser::destroy方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: installSettings
/**
* 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();
}
示例2: array
/**
* Parse an XML file and return data in an array.
* @see xml.XMLParser::parseStruct()
*/
function &parseStruct($file, $tagsToMatch = array())
{
$parser = new XMLParser();
$data =& $parser->parseStruct($file, $tagsToMatch);
$parser->destroy();
return $data;
}
示例3: parseEmails
/**
* Parse into structures the XML contents of an email data file.
* @param $contents string
* @return array
*/
function parseEmails($contents)
{
$parser = new XMLParser();
$result = $parser->parseTextStruct($contents, array('email_text', 'subject', 'body'));
$parser->destroy();
return $result;
}
示例4: XMLParser
/**
* Parse a record's contents into an object
* @param $contents string
* @return object
*/
function &parseContents(&$contents)
{
$xmlParser = new XMLParser();
$result =& $xmlParser->parseText($contents);
$returner = array();
$returner =& $this->handleRootNode($result);
$result->destroy();
$xmlParser->destroy();
return $returner;
}
示例5: XMLParser
/**
* Parse an RT version XML file.
* @param $file string path to the XML file
* @return RTVersion
*/
function &parse($file)
{
$parser = new XMLParser();
$tree = $parser->parse($file);
$parser->destroy();
$version = false;
if ($tree !== false) {
$version =& $this->parseVersion($tree);
}
$tree->destroy();
return $version;
}
示例6: parseTasks
/**
* Parse and execute the scheduled tasks in the specified file.
* @param $file string
*/
function parseTasks($file)
{
$xmlParser = new XMLParser();
$tree = $xmlParser->parse($file);
if (!$tree) {
$xmlParser->destroy();
printf("Unable to parse file \"%s\"!\n", $file);
exit(1);
}
foreach ($tree->getChildren() as $task) {
$className = $task->getAttribute('class');
$frequency = $task->getChildByName('frequency');
if (isset($frequency)) {
$canExecute = ScheduledTaskHelper::checkFrequency($className, $frequency);
} else {
// Always execute if no frequency is specified
$canExecute = true;
}
if ($canExecute) {
$this->executeTask($className, ScheduledTaskHelper::getTaskArgs($task));
}
}
$xmlParser->destroy();
}
示例7: XMLParser
/**
* Parse a record's contents into an object
* @param $contents string
* @return object
*/
function &parseContents(&$contents)
{
$xmlParser = new XMLParser();
$result =& $xmlParser->parseText($contents);
$returner = array();
$modsNode =& $result->getChildByName(array('oai_mods:mods', 'mods:mods', 'mods'));
if (!isset($modsNode)) {
$returner = null;
return $returner;
}
$returner =& $this->handleRootNode($modsNode);
$result->destroy();
$xmlParser->destroy();
return $returner;
}
示例8: parseInstaller
/**
* Parse the installation descriptor XML file.
* @return boolean
*/
function parseInstaller()
{
// Read installation descriptor file
$this->log(sprintf('load: %s', $this->descriptor));
$xmlParser = new XMLParser();
$installPath = $this->isPlugin ? $this->descriptor : INSTALLER_DATA_DIR . DIRECTORY_SEPARATOR . $this->descriptor;
$installTree = $xmlParser->parse($installPath);
if (!$installTree) {
// Error reading installation file
$xmlParser->destroy();
$this->setError(INSTALLER_ERROR_GENERAL, 'installer.installFileError');
return false;
}
$versionString = $installTree->getAttribute('version');
if (isset($versionString)) {
$this->newVersion =& Version::fromString($versionString);
} else {
$this->newVersion = $this->currentVersion;
}
// Parse descriptor
$this->parseInstallNodes($installTree);
$xmlParser->destroy();
$result = $this->getErrorType() == 0;
HookRegistry::call('Installer::parseInstaller', array(&$this, &$result));
return $result;
}
示例9: installFilterConfig
/**
* Install the given filter configuration file.
* @param $filterConfigFile string
* @return boolean true when successful, otherwise false
*/
function installFilterConfig($filterConfigFile)
{
static $filterHelper = false;
// Parse the filter configuration.
$xmlParser = new XMLParser();
$tree =& $xmlParser->parse($filterConfigFile);
// Validate the filter configuration.
if (!$tree) {
$xmlParser->destroy();
return false;
}
// Get the filter helper.
if ($filterHelper === false) {
import('lib.pkp.classes.filter.FilterHelper');
$filterHelper = new FilterHelper();
}
// Are there any filter groups to be installed?
$filterGroupsNode =& $tree->getChildByName('filterGroups');
if (is_a($filterGroupsNode, 'XMLNode')) {
$filterHelper->installFilterGroups($filterGroupsNode);
}
// Are there any filters to be installed?
$filtersNode =& $tree->getChildByName('filters');
if (is_a($filtersNode, 'XMLNode')) {
foreach ($filtersNode->getChildren() as $filterNode) {
/* @var $filterNode XMLNode */
$filterHelper->configureFilter($filterNode);
}
}
// Get rid of the parser.
$xmlParser->destroy();
unset($xmlParser);
return true;
}
示例10: XMLParser
/**
* Parse all scheduled tasks files and
* save the result object in database.
*/
function _parseCrontab()
{
$xmlParser = new XMLParser();
$taskFilesPath = array();
// Load all plugins so any plugin can register a crontab.
PluginRegistry::loadAllPlugins();
// Let plugins register their scheduled tasks too.
HookRegistry::call('AcronPlugin::parseCronTab', array(&$taskFilesPath));
// Reference needed.
// Add the default tasks file.
$taskFilesPath[] = 'registry/scheduledTasks.xml';
// TODO: make this a plugin setting, rather than assuming.
$tasks = array();
foreach ($taskFilesPath as $filePath) {
$tree = $xmlParser->parse($filePath);
if (!$tree) {
$xmlParser->destroy();
// TODO: graceful error handling
fatalError('Error parsing scheduled tasks XML file: ' . $filePath);
}
foreach ($tree->getChildren() as $task) {
$frequency = $task->getChildByName('frequency');
$args = ScheduledTaskHelper::getTaskArgs($task);
// Tasks without a frequency defined, or defined to zero, will run on every request.
// To avoid that happening (may cause performance problems) we
// setup a default period of time.
$setDefaultFrequency = true;
$minHoursRunPeriod = 24;
if ($frequency) {
$frequencyAttributes = $frequency->getAttributes();
if (is_array($frequencyAttributes)) {
foreach ($frequencyAttributes as $key => $value) {
if ($value != 0) {
$setDefaultFrequency = false;
break;
}
}
}
}
$tasks[] = array('className' => $task->getAttribute('class'), 'frequency' => $setDefaultFrequency ? array('hour' => $minHoursRunPeriod) : $frequencyAttributes, 'args' => $args);
}
$xmlParser->destroy();
}
// Store the object.
$this->updateSetting(0, 'crontab', $tasks, 'object');
}
示例11: installSettings
/**
* Install plugin settings from an XML file.
* @param $conferenceId int ID of conference, if applicable
* @param $schedConfId int ID of scheduled conference, if applicable
* @param $pluginName name of plugin 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($conferenceId, $schedConfId, $pluginName, $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');
$name =& $nameNode->getValue();
if ($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($conferenceId, $schedConfId, $pluginName, $name, $value, $type);
}
}
$xmlParser->destroy();
}
示例12: XMLParser
/**
* Parse a record's contents into an object
* @param $contents string
* @return object
*/
function &parseContents(&$contents)
{
$xmlParser = new XMLParser();
$result =& $xmlParser->parseText($contents);
$returner = array();
foreach ($result->getChildren() as $child) {
$name = $child->getName();
$value = $child->getValue();
if (String::substr($name, 0, 6) == 'etdms:') {
$name = String::substr($name, 3);
}
$returner[$name][] = $value;
}
$result->destroy();
$xmlParser->destroy();
unset($result, $xmlParser);
return $returner;
}
示例13: parseCrontab
function parseCrontab()
{
$xmlParser = new XMLParser();
// TODO: make this a plugin setting, rather than assuming.
$tree = $xmlParser->parse(Config::getVar('general', 'registry_dir') . '/scheduledTasks.xml');
if (!$tree) {
$xmlParser->destroy();
// TODO: graceful error handling
fatalError('Error parsing scheduled tasks XML.');
}
$tasks = array();
foreach ($tree->getChildren() as $task) {
$frequency = $task->getChildByName('frequency');
$args = array();
$index = 0;
while (($arg = $task->getChildByName('arg', $index)) != null) {
array_push($args, $arg->getValue());
$index++;
}
$tasks[] = array('className' => $task->getAttribute('class'), 'frequency' => $frequency ? $frequency->getAttributes() : null, 'args' => $args);
}
$xmlParser->destroy();
// Store the object.
$this->updateSetting(0, 0, 'crontab', $tasks, 'object');
}
示例14: installSettings
/**
* Install plugin settings from an XML file.
* @param $pluginName name of plugin 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($contextId, $pluginName, $filename, $paramArray = array())
{
$xmlParser = new XMLParser();
$tree = $xmlParser->parse($filename);
if (!$tree) {
$xmlParser->destroy();
return false;
}
// Check for existing settings and leave them if they are already in place.
$currentSettings = $this->getPluginSettings($contextId, $pluginName);
foreach ($tree->getChildren() as $setting) {
$nameNode = $setting->getChildByName('name');
$valueNode = $setting->getChildByName('value');
if (isset($nameNode) && isset($valueNode)) {
$type = $setting->getAttribute('type');
$name = $nameNode->getValue();
// If the setting already exists, respect it.
if (isset($currentSettings[$name])) {
continue;
}
if ($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($contextId, $pluginName, $name, $value, $type);
}
}
$xmlParser->destroy();
}
示例15: reloadLocalizedDefaultSettings
/**
* Install locale field Only journal settings from an XML file.
* @param $journalId int ID of journal 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
* @param $locale string locale id for which settings will be loaded
*/
function reloadLocalizedDefaultSettings($journalId, $filename, $paramArray, $locale)
{
$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();
//skip all settings that are not locale fields
if (!$isLocaleField) {
continue;
}
if ($type == 'object') {
$arrayNode =& $valueNode->getChildByName('array');
$value = $this->_buildLocalizedObject($arrayNode, $paramArray, $locale);
} else {
$value = $this->_performLocalizedReplacement($valueNode->getValue(), $paramArray, $locale);
}
// Replace translate calls with translated content
$this->updateSetting($journalId, $name, array($locale => $value), $type, true);
}
}
$xmlParser->destroy();
}