コード例 #1
0
 /**
  * Return string containing an XHTML fragment generated from the XML/XSL source
  * This function performs any necessary filtering, like image URL replacement.
  * @param $baseImageUrl string base URL for image references
  * @return string
  */
 function getHTMLContents()
 {
     $xmlGalleyPlugin =& PluginRegistry::getPlugin('generic', $this->parentPluginName);
     // if the XML Galley plugin is not installed or enabled,
     // then pass through to ArticleHTMLGalley
     if (!$xmlGalleyPlugin) {
         return parent::getHTMLContents();
     }
     if (!$xmlGalleyPlugin->getEnabled()) {
         return parent::getHTMLContents();
     }
     $cache =& $this->_getXSLTCache($this->getFileName() . '-' . $this->getId());
     $contents = $cache->getContents();
     // if contents is false/empty, then we have an XSLT error
     // return the straight XML contents instead
     if ($contents == "") {
         return parent::getHTMLContents();
     }
     // Replace image references
     $images =& $this->getImageFiles();
     $journal =& Request::getJournal();
     if ($images !== null) {
         foreach ($images as $image) {
             $imageUrl = Request::url(null, 'article', 'viewFile', array($this->getArticleId(), $this->getBestGalleyId($journal), $image->getFileId()));
             $contents = preg_replace('/(src|href)\\s*=\\s*"([^"]*' . preg_quote($image->getOriginalFileName()) . ')"/i', '$1="' . $imageUrl . '"', $contents);
         }
     }
     // Perform replacement for ojs://... URLs
     $contents = String::regexp_replace_callback('/(<[^<>]*")[Oo][Jj][Ss]:\\/\\/([^"]+)("[^<>]*>)/', array(&$this, '_handleOjsUrl'), $contents);
     // Replace supplementary file references
     $this->suppFileDao =& DAORegistry::getDAO('SuppFileDAO');
     $suppFiles = $this->suppFileDao->getSuppFilesByArticle($this->getArticleId());
     if ($suppFiles) {
         foreach ($suppFiles as $supp) {
             $journal =& Request::getJournal();
             $suppUrl = Request::url(null, 'article', 'downloadSuppFile', array($this->getArticleId(), $supp->getBestSuppFileId($journal)));
             $contents = preg_replace('/href="' . preg_quote($supp->getOriginalFileName()) . '"/', 'href="' . $suppUrl . '"', $contents);
         }
     }
     // if client encoding is set to iso-8859-1, transcode string to HTML entities
     // since we transform all XML in utf8 and can't rely on built-in PHP functions
     if (LOCALE_ENCODING == "iso-8859-1") {
         $contents =& String::utf2html($contents);
     }
     return $contents;
 }
コード例 #2
0
 /**
  * Internal function to return an ArticleGalley object from a row.
  * @param $row array
  * @return ArticleGalley
  */
 function &_returnGalleyFromRow(&$row)
 {
     if ($row['html_galley']) {
         $galley = new ArticleHTMLGalley();
         // HTML-specific settings
         $galley->setStyleFileId($row['style_file_id']);
         if ($row['style_file_id']) {
             $galley->setStyleFile($this->articleFileDao->getArticleFile($row['style_file_id']));
         }
         // Retrieve images
         $images =& $this->getGalleyImages($row['galley_id']);
         $galley->setImageFiles($images);
     } else {
         $galley = new ArticleGalley();
     }
     $galley->setId($row['galley_id']);
     $galley->setArticleId($row['article_id']);
     $galley->setLocale($row['locale']);
     $galley->setFileId($row['file_id']);
     $galley->setLabel($row['label']);
     $galley->setFileStage($row['file_stage']);
     $galley->setSequence($row['seq']);
     $galley->setRemoteURL($row['remote_url']);
     // ArticleFile set methods
     $galley->setFileName($row['file_name']);
     $galley->setOriginalFileName($row['original_file_name']);
     $galley->setFileType($row['file_type']);
     $galley->setFileSize($row['file_size']);
     $galley->setDateModified($this->datetimeFromDB($row['date_modified']));
     $galley->setDateUploaded($this->datetimeFromDB($row['date_uploaded']));
     $this->getDataObjectSettings('article_galley_settings', 'galley_id', $row['galley_id'], $galley);
     HookRegistry::call('ArticleGalleyDAO::_returnGalleyFromRow', array(&$galley, &$row));
     return $galley;
 }
コード例 #3
0
 /**
  * Internal function to return an ArticleGalley object from a row.
  * @param $row array
  * @return ArticleGalley
  */
 function &_returnGalleyFromRow(&$row)
 {
     if ($row['html_galley']) {
         $galley = new ArticleHTMLGalley();
         // HTML-specific settings
         $galley->setStyleFileId($row['style_file_id']);
         if ($row['style_file_id']) {
             $galley->setStyleFile($this->articleFileDao->getArticleFile($row['style_file_id']));
         }
         // Retrieve images
         $images =& $this->getGalleyImages($row['galley_id']);
         $galley->setImageFiles($images);
     } else {
         $galley = new ArticleGalley();
     }
     $galley->setId($row['galley_id']);
     $galley->setPublicGalleyId($row['public_galley_id']);
     $galley->setArticleId($row['article_id']);
     $galley->setLocale($row['locale']);
     $galley->setFileId($row['file_id']);
     $galley->setLabel($row['label']);
     $galley->setType($row['type']);
     $galley->setSequence($row['seq']);
     $galley->setViews($row['views']);
     // ArticleFile set methods
     $galley->setFileName($row['file_name']);
     $galley->setOriginalFileName($row['original_file_name']);
     $galley->setFileType($row['file_type']);
     $galley->setFileSize($row['file_size']);
     $galley->setDateModified($this->datetimeFromDB($row['date_modified']));
     $galley->setDateUploaded($this->datetimeFromDB($row['date_uploaded']));
     //%LP% Fedora set methods (ArticleFile)
     $galley->setFedoraPid($row['fedora_pid']);
     $galley->setFedoraNamespace($row['fedora_namespace']);
     $galley->setFedoraDsid($row['fedora_dsid']);
     HookRegistry::call('ArticleGalleyDAO::_returnGalleyFromRow', array(&$galley, &$row));
     return $galley;
 }