Example #1
0
 /** Constructor.
  *
  * @param WikiDB_Page $page
  * @param string $text  The packed page revision content.
  * @param hash $meta    The version meta-data.
  * @param string $type_override  For markup of page using a different
  *        pagetype than that specified in its version meta-data.
  */
 function TransformedText($page, $text, $meta, $type_override = false)
 {
     $pagetype = false;
     if ($type_override) {
         $pagetype = $type_override;
     } elseif (isset($meta['pagetype'])) {
         $pagetype = $meta['pagetype'];
     }
     $this->_type = PageType::GetPageType($pagetype);
     $this->CacheableMarkup($this->_type->transform($page, $text, $meta), $page->getName());
 }
Example #2
0
 /**
  * Get the transformed content of a page.
  *
  * @param string $pagetype  Override the page-type of the revision.
  *
  * @return object An XmlContent-like object containing the page transformed
  * contents.
  */
 function getTransformedContent($pagetype_override = false)
 {
     $backend =& $this->_wikidb->_backend;
     if ($pagetype_override) {
         // Figure out the normal page-type for this page.
         $type = PageType::GetPageType($this->get('pagetype'));
         if ($type->getName() == $pagetype_override) {
             $pagetype_override = false;
         }
         // Not really an override...
     }
     if ($pagetype_override) {
         // Overriden page type, don't cache (or check cache).
         return new TransformedText($this->getPage(), $this->getPackedContent(), $this->getMetaData(), $pagetype_override);
     }
     $possibly_cache_results = true;
     if (!USECACHE or WIKIDB_NOCACHE_MARKUP) {
         if (WIKIDB_NOCACHE_MARKUP == 'purge') {
             // flush cache for this page.
             $page = $this->getPage();
             $page->set('_cached_html', '');
             // ignored with !USECACHE
         }
         $possibly_cache_results = false;
     } elseif (USECACHE and !$this->_transformedContent) {
         //$backend->lock();
         if ($this->isCurrent()) {
             $page = $this->getPage();
             $this->_transformedContent = TransformedText::unpack($page->get('_cached_html'));
         } else {
             $possibly_cache_results = false;
         }
         //$backend->unlock();
     }
     if (!$this->_transformedContent) {
         $this->_transformedContent = new TransformedText($this->getPage(), $this->getPackedContent(), $this->getMetaData());
         if ($possibly_cache_results and !WIKIDB_NOCACHE_MARKUP) {
             // If we're still the current version, cache the transfomed page.
             //$backend->lock();
             if ($this->isCurrent()) {
                 $page->set('_cached_html', $this->_transformedContent->pack());
             }
             //$backend->unlock();
         }
     }
     return $this->_transformedContent;
 }