Ejemplo n.º 1
0
 /**
  * @see SMWResultPrinter::getResultText
  *
  * @param $results SMWQueryResult
  * @param $fullParams array
  * @param $outputmode integer
  *
  * @return string
  */
 public function getResultText(SMWQueryResult $results, $outputmode)
 {
     $ig = new ImageGallery();
     $ig->setShowBytes(false);
     $ig->setShowFilename(false);
     $ig->setCaption($this->mIntro);
     // set caption to IQ header
     // No need for a special page to use the parser but for the "normal" page
     // view we have to ensure caption text is parsed correctly through the parser
     if (!$this->isSpecialPage()) {
         $ig->setParser($GLOBALS['wgParser']);
     }
     // Initialize
     static $statNr = 0;
     $html = '';
     $processing = '';
     if ($this->params['widget'] == 'carousel') {
         // Carousel widget
         $ig->setAttributes($this->getCarouselWidget());
     } elseif ($this->params['widget'] == 'slideshow') {
         // Slideshow widget
         $ig->setAttributes($this->getSlideshowWidget());
     } else {
         // Standard gallery attributes
         $attribs = array('id' => uniqid(), 'class' => $this->getImageOverlay());
         $ig->setAttributes($attribs);
     }
     // Only use redirects where the overlay option is not used and redirect
     // thumb images towards a different target
     if ($this->params['redirects'] !== '' && !$this->params['overlay']) {
         SMWOutputs::requireResource('ext.srf.gallery.redirect');
     }
     // For the carousel widget, the perrow option should not be set
     if ($this->params['perrow'] !== '' && $this->params['widget'] !== 'carousel') {
         $ig->setPerRow($this->params['perrow']);
     }
     if ($this->params['widths'] !== '') {
         $ig->setWidths($this->params['widths']);
     }
     if ($this->params['heights'] !== '') {
         $ig->setHeights($this->params['heights']);
     }
     $printReqLabels = array();
     $redirectType = '';
     /**
      * @var SMWPrintRequest $printReq
      */
     foreach ($results->getPrintRequests() as $printReq) {
         $printReqLabels[] = $printReq->getLabel();
         // Get redirect type
         if ($this->params['redirects'] === $printReq->getLabel()) {
             $redirectType = $printReq->getTypeID();
         }
     }
     if ($this->params['imageproperty'] !== '' && in_array($this->params['imageproperty'], $printReqLabels) || $this->params['redirects'] !== '' && in_array($this->params['redirects'], $printReqLabels)) {
         $this->addImageProperties($results, $ig, $this->params['imageproperty'], $this->params['captionproperty'], $this->params['redirects'], $outputmode);
     } else {
         $this->addImagePages($results, $ig);
     }
     // SRF Global settings
     SRFUtils::addGlobalJSVariables();
     // Display a processing image as long as the DOM is no ready
     if ($this->params['widget'] !== '') {
         $processing = SRFUtils::htmlProcessingElement();
     }
     // Beautify the class selector
     $class = $this->params['widget'] ? '-' . $this->params['widget'] . ' ' : '';
     $class = $this->params['redirects'] !== '' && $this->params['overlay'] === false ? $class . ' srf-redirect' . ' ' : $class;
     $class = $this->params['class'] ? $class . ' ' . $this->params['class'] : $class;
     // Separate content from result output
     if (!$ig->isEmpty()) {
         $attribs = array('class' => 'srf-gallery' . $class, 'align' => 'justify', 'data-redirect-type' => $redirectType);
         $html = Html::rawElement('div', $attribs, $processing . $ig->toHTML());
     }
     // If available, create a link that points to further results
     if ($this->linkFurtherResults($results)) {
         $html .= $this->getLink($results, SMW_OUTPUT_HTML)->getText(SMW_OUTPUT_HTML, $this->mLinker);
     }
     return array($html, 'nowiki' => true, 'isHTML' => true);
 }