/** * Format and output report results using the given information plus * OutputPage * * @param $out OutputPage to print to * @param $skin Skin: user skin to use * @param $dbr Database (read) connection to use * @param $res Integer: result pointer * @param $num Integer: number of available result rows * @param $offset Integer: paging offset */ protected function outputResults($out, $skin, $dbr, $res, $num, $offset) { if ($num > 0) { $gallery = new ImageGallery(); $gallery->useSkin($skin); # $res might contain the whole 1,000 rows, so we read up to # $num [should update this to use a Pager] for ($i = 0; $i < $num && ($row = $dbr->fetchObject($res)); $i++) { $image = $this->prepareImage($row); if ($image) { $gallery->add($image->getTitle(), $this->getCellHtml($row)); } } $out->addHTML($gallery->toHtml()); } }
public function getResultText($results, $outputmode) { global $smwgIQRunningNumber, $wgUser, $wgParser; $skin = $wgUser->getSkin(); $ig = new ImageGallery(); $ig->setShowBytes(false); $ig->setShowFilename(false); $ig->setParser($wgParser); $ig->useSkin($skin); $ig->setCaption($this->mIntro); // set caption to IQ header if (isset($this->m_params['perrow'])) { $ig->setPerRow($this->m_params['perrow']); } if (isset($this->m_params['widths'])) { $ig->setWidths($this->m_params['widths']); } if (isset($this->m_params['heights'])) { $ig->setHeights($this->m_params['heights']); } while ($row = $results->getNext()) { $firstField = $row[0]; $imgTitle = $firstField->getNextObject()->getTitle(); $imgCaption = ''; // Is there a property queried for display with ?property if (isset($row[1])) { $imgCaption = $row[1]->getNextObject(); if (is_object($imgCaption)) { $imgCaption = $imgCaption->getShortText(SMW_OUTPUT_HTML, $this->getLinker(true)); $imgCaption = $wgParser->recursiveTagParse($imgCaption); } } if (empty($imgCaption)) { $imgCaption = $imgTitle->getBaseText(); $imgCaption = preg_replace('#\\.[^.]+$#', '', $imgCaption); // Remove image extension } $ig->add($imgTitle, $imgCaption); // Only add real images (bug #5586) if ($imgTitle->getNamespace() == NS_IMAGE) { $wgParser->mOutput->addImage($imgTitle->getDBkey()); } } return array($ig->toHTML(), 'nowiki' => true, 'isHTML' => true); }
/** * Renders an image gallery from a text with one line per image. * text labels may be given by using |-style alternative text. E.g. * Image:one.jpg|The number "1" * Image:tree.jpg|A tree * given as text will return the HTML of a gallery with two images, * labeled 'The number "1"' and * 'A tree'. */ function renderImageGallery($text, $params) { $ig = new ImageGallery(); $ig->setContextTitle($this->mTitle); $ig->setShowBytes(false); $ig->setShowFilename(false); $ig->setParser($this); $ig->setHideBadImages(); $ig->setAttributes(Sanitizer::validateTagAttributes($params, 'table')); $ig->useSkin($this->mOptions->getSkin()); $ig->mRevisionId = $this->mRevisionId; if (isset($params['caption'])) { $caption = $params['caption']; $caption = htmlspecialchars($caption); $caption = $this->replaceInternalLinks($caption); $ig->setCaptionHtml($caption); } if (isset($params['perrow'])) { $ig->setPerRow($params['perrow']); } if (isset($params['widths'])) { $ig->setWidths($params['widths']); } if (isset($params['heights'])) { $ig->setHeights($params['heights']); } wfRunHooks('BeforeParserrenderImageGallery', array(&$this, &$ig)); $lines = StringUtils::explode("\n", $text); foreach ($lines as $line) { # match lines like these: # Image:someimage.jpg|This is some image $matches = array(); preg_match("/^([^|]+)(\\|(.*))?\$/", $line, $matches); # Skip empty lines if (count($matches) == 0) { continue; } if (strpos($matches[0], '%') !== false) { $matches[1] = urldecode($matches[1]); } $tp = Title::newFromText($matches[1]); $nt =& $tp; if (is_null($nt)) { # Bogus title. Ignore these so we don't bomb out later. continue; } if (isset($matches[3])) { $label = $matches[3]; } else { $label = ''; } $html = $this->recursiveTagParse(trim($label)); $ig->add($nt, $html); # Only add real images (bug #5586) if ($nt->getNamespace() == NS_FILE) { $this->mOutput->addImage($nt->getDBkey()); } } return $ig->toHTML(); }
/** * Renders an image gallery from a text with one line per image. * text labels may be given by using |-style alternative text. E.g. * Image:one.jpg|The number "1" * Image:tree.jpg|A tree * given as text will return the HTML of a gallery with two images, * labeled 'The number "1"' and * 'A tree'. */ function renderImageGallery($text, $params) { $ig = new ImageGallery(); $ig->setShowBytes(false); $ig->setShowFilename(false); $ig->setParsing(); $ig->useSkin($this->mOptions->getSkin()); if (isset($params['caption'])) { $ig->setCaption($params['caption']); } $lines = explode("\n", $text); foreach ($lines as $line) { # match lines like these: # Image:someimage.jpg|This is some image preg_match("/^([^|]+)(\\|(.*))?\$/", $line, $matches); # Skip empty lines if (count($matches) == 0) { continue; } $tp = Title::newFromText($matches[1]); $nt =& $tp; if (is_null($nt)) { # Bogus title. Ignore these so we don't bomb out later. continue; } if (isset($matches[3])) { $label = $matches[3]; } else { $label = ''; } $pout = $this->parse($label, $this->mTitle, $this->mOptions, false, false); $html = $pout->getText(); $ig->add(new Image($nt), $html); # Only add real images (bug #5586) if ($nt->getNamespace() == NS_IMAGE) { $this->mOutput->addImage($nt->getDBkey()); } } return $ig->toHTML(); }