Index: trunk/extensions/SemanticResultFormats/README |
— | — | @@ -90,7 +90,11 @@ |
91 | 91 | Creates a graph based on the relations in the wiki. Requires the GraphViz |
92 | 92 | extension. |
93 | 93 | |
| 94 | +=== gallery === |
94 | 95 | |
| 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 | + |
95 | 99 | == Contact == |
96 | 100 | |
97 | 101 | If you have remarks, questions, or suggestions, please send them to |
— | — | @@ -136,6 +140,8 @@ |
137 | 141 | |
138 | 142 | * The BibTeX format was contributed by Steren Giannini. |
139 | 143 | |
| 144 | +* The Gallery format was contributed by Rowan van der Molen. |
| 145 | + |
140 | 146 | * Many people have contributed to the project by providing helpful comments and |
141 | 147 | suggestions. Among them are the members of the Semantic Wiki Interest Group |
142 | 148 | (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 |
1 | 75 | + native |
Index: trunk/extensions/SemanticResultFormats/SRF_Settings.php |
— | — | @@ -99,6 +99,10 @@ |
100 | 100 | $class = 'SRFPloticusVBar'; |
101 | 101 | $file = $srfgIP . '/Ploticus/SRF_PloticusVBar.php'; |
102 | 102 | break; |
| 103 | + case 'gallery': |
| 104 | + $class = 'SRFGallery'; |
| 105 | + $file = $srfgIP . '/Gallery/SRF_Gallery.php'; |
| 106 | + break; |
103 | 107 | } |
104 | 108 | if ( ( $class ) && ( $file ) ) { |
105 | 109 | $smwgResultFormats[$format] = $class; |