예제 #1
0
 function WikiDB_backend_dumb_TextSearchIter(&$backend, &$pages, $search, $fulltext = false, $options = array())
 {
     $this->_backend =& $backend;
     $this->_pages = $pages;
     $this->_fulltext = $fulltext;
     $this->_search =& $search;
     $this->_index = 0;
     $this->_stoplist =& $search->_stoplist;
     $this->stoplisted = array();
     $this->_from = 0;
     if (isset($options['limit'])) {
         // extract from,count from limit
         list($this->_from, $this->_count) = WikiDB_backend::limit($options['limit']);
     } else {
         $this->_count = 0;
     }
     if (isset($options['exclude'])) {
         $this->_exclude = $options['exclude'];
     } else {
         $this->_exclude = false;
     }
 }
예제 #2
0
파일: dbaBase.php 프로젝트: hugcoday/wiki
 function WikiDB_backend_dbaBase_pageiter(&$backend, &$pages, $options = false)
 {
     $this->_backend = $backend;
     $this->_options = $options;
     if ($pages) {
         if (!empty($options['sortby'])) {
             $sortby = WikiDB_backend::sortby($options['sortby'], 'db', array('pagename', 'mtime'));
             // check for which column to sortby
             if ($sortby and !strstr($sortby, "hits ")) {
                 usort($pages, 'WikiDB_backend_dbaBase_sortby_' . str_replace(' ', '_', $sortby));
             }
         }
         if (!empty($options['limit'])) {
             list($offset, $limit) = WikiDB_backend::limit($options['limit']);
             $pages = array_slice($pages, $offset, $limit);
         }
         $this->_pages = $pages;
     } else {
         $this->_pages = array();
     }
 }
예제 #3
0
파일: backend.php 프로젝트: hugcoday/wiki
 /**
  * Handle sortby requests for the DB iterator and table header links.
  * Prefix the column with + or - like "+pagename","-mtime", ...
  * supported actions: 'flip_order' "mtime" => "+mtime" => "-mtime" ...
  *                    'db'         "-pagename" => "pagename DESC"
  * In PageList all columns are sortable. (patch by DanFr)
  * Here with the backend only some, the rest is delayed to PageList.
  * (some kind of DumbIter)
  * Duplicate the PageList function here to avoid loading the whole
  * PageList.php, and it forces the backend specific sortable_columns()
  */
 function sortby($column, $action, $sortable_columns = false)
 {
     if (empty($column)) {
         return '';
     }
     //support multiple comma-delimited sortby args: "+hits,+pagename"
     if (strstr($column, ',')) {
         $result = array();
         foreach (explode(',', $column) as $col) {
             if (empty($this)) {
                 $result[] = WikiDB_backend::sortby($col, $action);
             } else {
                 $result[] = $this->sortby($col, $action);
             }
         }
         return join(",", $result);
     }
     if (substr($column, 0, 1) == '+') {
         $order = '+';
         $column = substr($column, 1);
     } elseif (substr($column, 0, 1) == '-') {
         $order = '-';
         $column = substr($column, 1);
     }
     // default order: +pagename, -mtime, -hits
     if (empty($order)) {
         if (in_array($column, array('mtime', 'hits'))) {
             $order = '-';
         } else {
             $order = '+';
         }
     }
     if ($action == 'flip_order') {
         return ($order == '+' ? '-' : '+') . $column;
     } elseif ($action == 'init') {
         $this->_sortby[$column] = $order;
         return $order . $column;
     } elseif ($action == 'check') {
         return !empty($this->_sortby[$column]) or $GLOBALS['request']->getArg('sortby') and strstr($GLOBALS['request']->getArg('sortby'), $column);
     } elseif ($action == 'db') {
         // native sort possible?
         if (!empty($this) and !$sortable_columns) {
             $sortable_columns = $this->sortable_columns();
         }
         if (in_array($column, $sortable_columns)) {
             // asc or desc: +pagename, -pagename
             return $column . ($order == '+' ? ' ASC' : ' DESC');
         } else {
             return '';
         }
     }
     return '';
 }
예제 #4
0
파일: PageList.php 프로젝트: hugcoday/wiki
 function addPageList(&$list)
 {
     if (empty($list)) {
         return;
     }
     // Protect reset from a null arg
     if (isset($this->_options['limit'])) {
         // extract from,count from limit
         list($from, $limit) = WikiDB_backend::limit($this->_options['limit']);
         $limit += $from;
     } else {
         $limit = 0;
     }
     $this->_options['slice'] = 0;
     $i = 0;
     foreach ($list as $page) {
         $i++;
         if ($from and $i < $from) {
             continue;
         }
         if (!$limit or $limit and $i < $limit) {
             if (is_object($page)) {
                 $page = $page->_pagename;
             }
             $this->addPage((string) $page);
         }
     }
 }