Example #1
0
 function _getValue($page_handle, &$revision_handle)
 {
     if (!$revision_handle or (!$revision_handle->_data['%content'] or $revision_handle->_data['%content'] === true)) {
         $revision_handle = $page_handle->getCurrentRevision(true);
     }
     // Not sure why implode is needed here, I thought
     // getContent() already did this, but it seems necessary.
     $c = implode("\n", $revision_handle->getContent());
     if (empty($pagelist->_sortby[$this->_field])) {
         unset($revision_handle->_data['%content']);
     }
     if ($this->_field == 'hi_content') {
         global $HTTP_POST_VARS;
         unset($revision_handle->_data['%pagedata']['_cached_html']);
         $search = $HTTP_POST_VARS['admin_replace']['from'];
         if ($search and $i = strpos($c, $search)) {
             $l = strlen($search);
             $j = max(0, $i - $this->bytes / 2);
             return HTML::div(array('style' => 'font-size:x-small'), HTML::div(array('class' => 'transclusion'), HTML::span(substr($c, $j, $this->bytes / 2)), HTML::span(array("style" => "background:yellow"), $search), HTML::span(substr($c, $i + $l, $this->bytes / 2))));
         } else {
             $c = sprintf(_("%s not found"), '»' . $search . '«');
             return HTML::div(array('style' => 'font-size:x-small', 'align' => 'center'), $c);
         }
     } elseif (($len = strlen($c)) > $this->bytes) {
         $c = substr($c, 0, $this->bytes);
     }
     include_once 'lib/BlockParser.php';
     // false --> don't bother processing hrefs for embedded WikiLinks
     $ct = TransformText($c, $revision_handle->get('markup'), false);
     if (empty($pagelist->_sortby[$this->_field])) {
         unset($revision_handle->_data['%pagedata']['_cached_html']);
     }
     return HTML::div(array('style' => 'font-size:x-small'), HTML::div(array('class' => 'transclusion'), $ct), ($this->parent->_columns_seen['size'] or !$len) ? "" : ByteFormatter($len, true));
 }
Example #2
0
 function _getValue($page_handle, &$revision_handle)
 {
     if (!$revision_handle or (!$revision_handle->_data['%content'] or $revision_handle->_data['%content'] === true)) {
         $revision_handle = $page_handle->getCurrentRevision(true);
     }
     if ($this->_field == 'hi_content') {
         if (!empty($revision_handle->_data['%pagedata'])) {
             $revision_handle->_data['%pagedata']['_cached_html'] = '';
         }
         $search = $this->search;
         $score = '';
         if (is_object($page_handle) and !empty($page_handle->score)) {
             $score = $page_handle->score;
         } elseif (is_array($page_handle) and !empty($page_handle['score'])) {
             $score = $page_handle['score'];
         }
         $hilight_re = $this->hilight_re;
         // use the TextSearchQuery highlighter
         if ($search and $hilight_re) {
             $matches = preg_grep("/{$hilight_re}/i", $revision_handle->getContent());
             $html = array();
             foreach (array_slice($matches, 0, 5) as $line) {
                 $line = WikiPlugin_FullTextSearch::highlight_line($line, $hilight_re);
                 $html[] = HTML::p(HTML::small(array('class' => 'search-context'), $line));
             }
             if ($score) {
                 $html[] = HTML::small(sprintf("... [%0.1f]", $score));
             }
             return $html;
         }
         // Remove special characters so that highlighting works
         $search = preg_replace('/^[\\^\\*]/', '', $search);
         $search = preg_replace('/[\\^\\*]$/', '', $search);
         $c =& $revision_handle->getPackedContent();
         if ($search and ($i = strpos(strtolower($c), strtolower($search))) !== false) {
             $l = strlen($search);
             $j = max(0, $i - $this->bytes / 2);
             return HTML::div(array('style' => 'font-size:x-small'), HTML::div(array('class' => 'transclusion'), HTML::span(($j ? '...' : '') . substr($c, $j, $j ? $this->bytes / 2 : $i)), HTML::span(array("style" => "background:yellow"), substr($c, $i, $l)), HTML::span(substr($c, $i + $l, $this->bytes / 2) . "..." . " " . ($score ? sprintf("[%0.1f]", $score) : ""))));
         } else {
             if (strpos($c, " ") !== false) {
                 $c = "";
             } else {
                 $c = sprintf(_("%s not found"), '»' . $search . '«');
             }
             return HTML::div(array('style' => 'font-size:x-small', 'align' => 'center'), $c . " " . ($score ? sprintf("[%0.1f]", $score) : ""));
         }
     } elseif (($len = strlen($c)) > $this->bytes) {
         $c = substr($c, 0, $this->bytes);
     }
     include_once 'lib/BlockParser.php';
     // false --> don't bother processing hrefs for embedded WikiLinks
     $ct = TransformText($c, $revision_handle->get('markup'), false);
     if (empty($pagelist->_sortby[$this->_field])) {
         unset($revision_handle->_data['%pagedata']['_cached_html']);
     }
     return HTML::div(array('style' => 'font-size:x-small'), HTML::div(array('class' => 'transclusion'), $ct), ($this->parent->_columns_seen['size'] or !$len) ? "" : ByteFormatter($len, true));
 }