當前位置: 首頁>>代碼示例>>PHP>>正文


PHP XMLParser::destroy方法代碼示例

本文整理匯總了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();
 }
開發者ID:ramonsodoma,項目名稱:ocs,代碼行數:35,代碼來源:SettingsDAO.inc.php

示例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;
 }
開發者ID:JovanyJeff,項目名稱:hrp,代碼行數:11,代碼來源:XMLDAO.inc.php

示例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;
 }
開發者ID:laelnasan,項目名稱:UTFPR-ojs,代碼行數:12,代碼來源:genEmailUpdates.php

示例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;
 }
開發者ID:Rygbee,項目名稱:harvester,代碼行數:15,代碼來源:ModsPlugin.inc.php

示例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;
 }
開發者ID:master3395,項目名稱:CBPPlatform,代碼行數:17,代碼來源:RTXMLParser.inc.php

示例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();
 }
開發者ID:farhanabbas1983,項目名稱:ojs-1,代碼行數:28,代碼來源:ScheduledTaskTool.inc.php

示例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;
 }
開發者ID:jalperin,項目名稱:harvester,代碼行數:20,代碼來源:ModsPlugin.inc.php

示例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;
 }
開發者ID:ingmarschuster,項目名稱:MindResearchRepository,代碼行數:30,代碼來源:Installer.inc.php

示例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;
 }
開發者ID:EreminDm,項目名稱:water-cao,代碼行數:39,代碼來源:Installer.inc.php

示例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');
 }
開發者ID:PublishingWithoutWalls,項目名稱:pkp-lib,代碼行數:50,代碼來源:PKPAcronPlugin.inc.php

示例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();
 }
開發者ID:sedici,項目名稱:ocs,代碼行數:34,代碼來源:PluginSettingsDAO.inc.php

示例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;
 }
開發者ID:ramonsodoma,項目名稱:harvester,代碼行數:23,代碼來源:EtdmsPlugin.inc.php

示例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');
 }
開發者ID:sedici,項目名稱:ocs,代碼行數:25,代碼來源:AcronPlugin.inc.php

示例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();
 }
開發者ID:PublishingWithoutWalls,項目名稱:pkp-lib,代碼行數:38,代碼來源:PluginSettingsDAO.inc.php

示例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();
 }
開發者ID:philschatz,項目名稱:ojs,代碼行數:38,代碼來源:JournalSettingsDAO.inc.php


注:本文中的XMLParser::destroy方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。