Ejemplo n.º 1
0
 /**
  * Format and output report results using the given information plus
  * OutputPage
  *
  * @param OutputPage $out OutputPage to print to
  * @param Skin $skin User skin to use
  * @param Database $dbr Database (read) connection to use
  * @param int $res Result pointer
  * @param int $num Number of available result rows
  * @param int $offset Paging offset
  */
 protected function outputResults($out, $skin, $dbr, $res, $num, $offset)
 {
     global $wgContLang;
     $all_display_params = SDUtils::getDisplayParamsForCategory($this->category);
     $querystring = null;
     $printouts = $params = array();
     // only one set of params is handled for now
     if (count($all_display_params) > 0) {
         $display_params = array_map('trim', $all_display_params[0]);
         SMWQueryProcessor::processFunctionParams($display_params, $querystring, $params, $printouts);
     }
     if (!empty($querystring)) {
         $query = SMWQueryProcessor::createQuery($querystring, $params);
     } else {
         $query = new SMWQuery();
     }
     if (!array_key_exists('format', $params)) {
         $params['format'] = 'category';
     }
     if (array_key_exists('mainlabel', $params)) {
         $mainlabel = $params['mainlabel'];
     } else {
         $mainlabel = '';
     }
     $r = $this->addSemanticResultWrapper($dbr, $res, $num, $query, $mainlabel, $printouts);
     $printer = SMWQueryProcessor::getResultPrinter($params['format'], SMWQueryProcessor::SPECIAL_PAGE, $r);
     if (version_compare(SMW_VERSION, '1.6.1', '>')) {
         SMWQueryProcessor::addThisPrintout($printouts, $params);
         $params = SMWQueryProcessor::getProcessedParams($params, $printouts);
     }
     $prresult = $printer->getResult($r, $params, SMW_OUTPUT_HTML);
     $prtext = is_array($prresult) ? $prresult[0] : $prresult;
     SMWOutputs::commitToOutputPage($out);
     // Crappy hack to get the contents of SMWOutputs::$mHeadItems,
     // which may have been set in the result printer, and dump into
     // headItems of $out.
     // How else can we do this?
     global $wgParser;
     SMWOutputs::commitToParser($wgParser);
     if (!is_null($wgParser->mOutput)) {
         // getHeadItems() was added in MW 1.16
         if (method_exists($wgParser->getOutput(), 'getHeadItems')) {
             $headItems = $wgParser->getOutput()->getHeadItems();
         } else {
             $headItems = $wgParser->getOutput()->mHeadItems;
         }
         foreach ($headItems as $key => $item) {
             $out->addHeadItem($key, $item);
         }
         // Force one more parser function, so links appear.
         $wgParser->replaceLinkHolders($prtext);
     }
     $html = array();
     $html[] = $prtext;
     if (!$this->listoutput) {
         $html[] = $this->closeList();
     }
     $html = $this->listoutput ? $wgContLang->listToText($html) : implode('', $html);
     $out->addHTML($html);
 }