Exemple #1
0
 /**
  * Really should have a _fixupPagedata and _fixupVersiondata, but this works.
  */
 function _fixupData(&$data)
 {
     global $request;
     $user = $request->getUser();
     foreach ($data as $key => $val) {
         if (is_integer($key)) {
         } elseif ($key == 'passwd' and !$user->isAdmin()) {
             $data[$key] = $val ? _("<not displayed>") : _("<empty>");
         } elseif ($key and $key == '_cached_html') {
             $val = TransformedText::unpack($val);
             ob_start();
             print_r($val);
             $data[$key] = HTML::pre(ob_get_contents());
             ob_end_clean();
         } elseif (is_bool($val)) {
             $data[$key] = $val ? "<true>" : "<false>";
         } elseif (is_string($val) && substr($val, 0, 2) == 'a:') {
             // how to indent this table?
             $val = unserialize($val);
             $this->_fixupData($val);
             $data[$key] = HTML::table(array('border' => 1, 'cellpadding' => 2, 'cellspacing' => 0), $this->_showhash(false, $val));
         } elseif (is_array($val)) {
             // how to indent this table?
             $this->_fixupData($val);
             $data[$key] = HTML::table(array('border' => 1, 'cellpadding' => 2, 'cellspacing' => 0), $this->_showhash(false, $val));
         } elseif ($key and $key == '%content') {
             if ($val === true) {
                 $val = '<true>';
             } elseif (strlen($val) > 40) {
                 $val = substr($val, 0, 40) . " ...";
             }
             $data[$key] = $val;
         }
     }
     unset($data['%pagedata']);
     // problem in backend
 }
Exemple #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;
 }