Пример #1
0
 /**
  * Generic list of deleted pages
  *
  * @param ResultWrapper $result
  * @return bool
  */
 private function showList($result)
 {
     $out = $this->getOutput();
     if ($result->numRows() == 0) {
         $out->addWikiMsg('undelete-no-results');
         return false;
     }
     $out->addWikiMsg('undeletepagetext', $this->getLanguage()->formatNum($result->numRows()));
     $undelete = $this->getPageTitle();
     $out->addHTML("<ul>\n");
     foreach ($result as $row) {
         $title = Title::makeTitleSafe($row->ar_namespace, $row->ar_title);
         if ($title !== null) {
             $item = Linker::linkKnown($undelete, htmlspecialchars($title->getPrefixedText()), array(), array('target' => $title->getPrefixedText()));
         } else {
             // The title is no longer valid, show as text
             $item = Html::element('span', array('class' => 'mw-invalidtitle'), Linker::getInvalidTitleDescription($this->getContext(), $row->ar_namespace, $row->ar_title));
         }
         $revs = $this->msg('undeleterevisions')->numParams($row->count)->parse();
         $out->addHTML("<li>{$item} ({$revs})</li>\n");
     }
     $result->free();
     $out->addHTML("</ul>\n");
     return true;
 }
Пример #2
0
 /**
  * Fill in member variables from a result wrapper
  */
 function loadFromResult(ResultWrapper $res, $killExpired = true)
 {
     $ret = false;
     if (0 != $res->numRows()) {
         # Get first block
         $row = $res->fetchObject();
         $this->initFromRow($row);
         if ($killExpired) {
             # If requested, delete expired rows
             do {
                 $killed = $this->deleteIfExpired();
                 if ($killed) {
                     $row = $res->fetchObject();
                     if ($row) {
                         $this->initFromRow($row);
                     }
                 }
             } while ($killed && $row);
             # If there were any left after the killing finished, return true
             if ($row) {
                 $ret = true;
             }
         } else {
             $ret = true;
         }
     }
     $res->free();
     return $ret;
 }
 /**
  * Runs through a query result set dumping page and revision records.
  * The result set should be sorted/grouped by page to avoid duplicate
  * page records in the output.
  *
  * The result set will be freed once complete. Should be safe for
  * streaming (non-buffered) queries, as long as it was made on a
  * separate database connection not managed by LoadBalancer; some
  * blob storage types will make queries to pull source data.
  *
  * @param ResultWrapper $resultset
  * @access private
  */
 function outputStream($resultset)
 {
     $last = null;
     while ($row = $resultset->fetchObject()) {
         if (is_null($last) || $last->page_namespace != $row->page_namespace || $last->page_title != $row->page_title) {
             if (isset($last)) {
                 $this->closePage($last);
             }
             $this->openPage($row);
             $last = $row;
         }
         $this->dumpRev($row);
     }
     if (isset($last)) {
         $this->closePage($last);
     }
     $resultset->free();
 }
Пример #4
0
 /**
  * Runs through a query result set dumping page and revision records.
  * The result set should be sorted/grouped by page to avoid duplicate
  * page records in the output.
  *
  * The result set will be freed once complete. Should be safe for
  * streaming (non-buffered) queries, as long as it was made on a
  * separate database connection not managed by LoadBalancer; some
  * blob storage types will make queries to pull source data.
  *
  * @param ResultWrapper $resultset
  * @access private
  */
 function outputStream($resultset)
 {
     $last = null;
     while ($row = $resultset->fetchObject()) {
         if (is_null($last) || $last->page_namespace != $row->page_namespace || $last->page_title != $row->page_title) {
             if (isset($last)) {
                 $output = $this->writer->closePage();
                 $this->sink->writeClosePage($output);
             }
             $output = $this->writer->openPage($row);
             $this->sink->writeOpenPage($row, $output);
             $last = $row;
         }
         $output = $this->writer->writeRevision($row, $this->parse);
         $this->sink->writeRevision($row, $output);
     }
     if (isset($last)) {
         $output = $this->author_list . $this->writer->closePage();
         $this->sink->writeClosePage($output);
     }
     $resultset->free();
 }