Пример #1
0
 function &parseSchemaMap()
 {
     $xmlDao = new XMLDAO();
     $schemaMapHandler = new SchemaMapHandler();
     $schemaMap =& $xmlDao->parseWithHandler(SCHEMA_MAP_REGISTRY_FILE, $schemaMapHandler);
     return $schemaMap;
 }
Пример #2
0
 function _cacheMiss(&$cache, $id)
 {
     $allCodelistItems =& Registry::get('all' . $this->getListName() . 'CodelistItems', true, null);
     if ($allCodelistItems === null) {
         // Add a locale load to the debug notes.
         $notes =& Registry::get('system.debug.notes');
         $locale = $cache->cacheId;
         if ($locale == null) {
             $locale = AppLocale::getLocale();
         }
         $filename = $this->getFilename($locale);
         $notes[] = array('debug.notes.codelistItemListLoad', array('filename' => $filename));
         // Reload locale registry file
         $xmlDao = new XMLDAO();
         $listName =& $this->getListName();
         // i.e., 'List30'
         import('lib.pkp.classes.codelist.ONIXParserDOMHandler');
         $handler = new ONIXParserDOMHandler($listName);
         import('lib.pkp.classes.xslt.XSLTransformer');
         import('lib.pkp.classes.file.FileManager');
         import('classes.file.TemporaryFileManager');
         $temporaryFileManager = new TemporaryFileManager();
         $fileManager = new FileManager();
         $tmpName = tempnam($temporaryFileManager->getBasePath(), 'ONX');
         $xslTransformer = new XSLTransformer();
         $xslTransformer->setParameters(array('listName' => $listName));
         $xslTransformer->setRegisterPHPFunctions(true);
         $xslFile = 'lib/pkp/xml/onixFilter.xsl';
         $filteredXml = $xslTransformer->transform($filename, XSL_TRANSFORMER_DOCTYPE_FILE, $xslFile, XSL_TRANSFORMER_DOCTYPE_FILE, XSL_TRANSFORMER_DOCTYPE_STRING);
         if (!$filteredXml) {
             assert(false);
         }
         $data = null;
         if (is_writeable($tmpName)) {
             $fp = fopen($tmpName, 'wb');
             fwrite($fp, $filteredXml);
             fclose($fp);
             $data = $xmlDao->parseWithHandler($tmpName, $handler);
             $fileManager->deleteFile($tmpName);
         } else {
             fatalError('misconfigured directory permissions on: ' . $temporaryFileManager->getBasePath());
         }
         // Build array with ($charKey => array(stuff))
         if (isset($data[$listName])) {
             foreach ($data[$listName] as $code => $codelistData) {
                 $allCodelistItems[$code] = $codelistData;
             }
         }
         if (is_array($allCodelistItems)) {
             asort($allCodelistItems);
         }
         $cache->setEntireCache($allCodelistItems);
     }
     return null;
 }