r63834 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r63833‎ | r63834 | r63835 >
Date:20:45, 16 March 2010
Author:bigsmoke
Status:deferred
Tags:
Comment:
Merged the SemanticGallery extension into SemanticResultFormats.
Modified paths:
  • /trunk/extensions/SemanticResultFormats/Gallery (added) (history)
  • /trunk/extensions/SemanticResultFormats/Gallery/SRF_Gallery.php (added) (history)
  • /trunk/extensions/SemanticResultFormats/README (modified) (history)
  • /trunk/extensions/SemanticResultFormats/SRF_Settings.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticResultFormats/README
@@ -90,7 +90,11 @@
9191 Creates a graph based on the relations in the wiki. Requires the GraphViz
9292 extension.
9393
 94+=== gallery ===
9495
 96+Creates a gallery of images (and captions) dynamically. The output is the
 97+same as when using MediaWiki's built-in <gallery>-tag.
 98+
9599 == Contact ==
96100
97101 If you have remarks, questions, or suggestions, please send them to
@@ -136,6 +140,8 @@
137141
138142 * The BibTeX format was contributed by Steren Giannini.
139143
 144+* The Gallery format was contributed by Rowan van der Molen.
 145+
140146 * Many people have contributed to the project by providing helpful comments and
141147 suggestions. Among them are the members of the Semantic Wiki Interest Group
142148 (swikig@aifb.uni-karlsruhe.de; see semanticweb.org), the people at the project
Index: trunk/extensions/SemanticResultFormats/Gallery/SRF_Gallery.php
@@ -0,0 +1,73 @@
 2+<?php
 3+/**
 4+ * Print query results as a gallery.
 5+ * @author Rowan Rodrik van der Molen
 6+ * @file
 7+ * @ingroup SemanticResultFormats
 8+ */
 9+
 10+if (!defined('MEDIAWIKI')) die();
 11+
 12+/**
 13+ * Result printer that prints query results as a gallery.
 14+ */
 15+class SRFGallery extends SMWResultPrinter
 16+{
 17+
 18+ public function getResult($results, $params, $outputmode)
 19+ {
 20+ // skip checks, results with 0 entries are normal
 21+ $this->readParameters($params, $outputmode);
 22+ return $this->getResultText($results, SMW_OUTPUT_HTML);
 23+ }
 24+
 25+
 26+ public function getResultText($results, $outputmode)
 27+ {
 28+ global $smwgIQRunningNumber, $wgUser, $wgParser;
 29+ $skin = $wgUser->getSkin();
 30+
 31+ $ig = new ImageGallery();
 32+ $ig->setShowBytes(false);
 33+ $ig->setShowFilename(false);
 34+ $ig->setParser($wgParser);
 35+ $ig->useSkin($skin);
 36+ $ig->setCaption($this->mIntro); // set caption to IQ header
 37+
 38+ if ( isset($this->m_params['perrow']) )
 39+ $ig->setPerRow( $this->m_params['perrow'] );
 40+ if ( isset($this->m_params['widths']) )
 41+ $ig->setWidths( $this->m_params['widths'] );
 42+ if ( isset($this->m_params['heights']) )
 43+ $ig->setHeights( $this->m_params['heights'] );
 44+
 45+ while ($row = $results->getNext()) {
 46+ $firstField = $row[0];
 47+ $imgTitle = $firstField->getNextObject()->getTitle();
 48+ $imgCaption = '';
 49+
 50+ // Is there a property queried for display with ?property
 51+ if ( isset($row[1]) ) {
 52+ $imgCaption = $row[1]->getNextObject();
 53+ if ( is_object($imgCaption) ) {
 54+ $imgCaption = $imgCaption->getShortText( SMW_OUTPUT_HTML, $this->getLinker(true) );
 55+ $imgCaption = $wgParser->recursiveTagParse($imgCaption);
 56+ }
 57+ }
 58+
 59+ if ( empty($imgCaption) ) {
 60+ $imgCaption = $imgTitle->getBaseText();
 61+ $imgCaption = preg_replace('#\.[^.]+$#', '', $imgCaption); // Remove image extension
 62+ }
 63+
 64+ $ig->add( $imgTitle, $imgCaption );
 65+
 66+ // Only add real images (bug #5586)
 67+ if ( $imgTitle->getNamespace() == NS_IMAGE ) {
 68+ $wgParser->mOutput->addImage( $imgTitle->getDBkey() );
 69+ }
 70+ }
 71+
 72+ return array($ig->toHTML(), 'nowiki' => true, 'isHTML' => true);
 73+ }
 74+}
Property changes on: trunk/extensions/SemanticResultFormats/Gallery/SRF_Gallery.php
___________________________________________________________________
Added: svn:eol-style
175 + native
Index: trunk/extensions/SemanticResultFormats/SRF_Settings.php
@@ -99,6 +99,10 @@
100100 $class = 'SRFPloticusVBar';
101101 $file = $srfgIP . '/Ploticus/SRF_PloticusVBar.php';
102102 break;
 103+ case 'gallery':
 104+ $class = 'SRFGallery';
 105+ $file = $srfgIP . '/Gallery/SRF_Gallery.php';
 106+ break;
103107 }
104108 if ( ( $class ) && ( $file ) ) {
105109 $smwgResultFormats[$format] = $class;

Status & tagging log