r44730 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r44729‎ | r44730 | r44731 >
Date:20:32, 17 December 2008
Author:bigsmoke
Status:deferred
Tags:
Comment:
Imported SemanticGallery extension.

This version is a bit messy. The next commit will have some cleanups.
Only committing this to make it easier to kill my darlings. I like history.
Modified paths:
  • /trunk/extensions/SemanticGallery/SG_ResultPrinter.php (added) (history)
  • /trunk/extensions/SemanticGallery/SemanticGallery.php (added) (history)

Diff [purge]

Index: trunk/extensions/SemanticGallery/SG_ResultPrinter.php
@@ -0,0 +1,64 @@
 2+<?php
 3+if (!defined('MEDIAWIKI')) die();
 4+
 5+/**
 6+ * Print query results as a gallery.
 7+ */
 8+class SemanticGallery_ResultPrinter extends SMWResultPrinter
 9+{
 10+ public function getResult($results, $params, $outputmode)
 11+ {
 12+ // skip checks, results with 0 entries are normal
 13+ $this->readParameters($params, $outputmode);
 14+ return $this->getResultText($results, SMW_OUTPUT_HTML);
 15+ }
 16+
 17+ public function getResultText($res, $outputmode)
 18+ {
 19+ global $smwgIQRunningNumber, $wgUser, $wgParser;
 20+ $skin = $wgUser->getSkin();
 21+
 22+ $ig = new ImageGallery();
 23+ $ig->setShowBytes(false);
 24+ $ig->setShowFilename(false);
 25+ $ig->setParser($wgParser);
 26+ $ig->useSkin($skin);
 27+ $ig->setCaption($this->mIntro); // set caption to IQ header
 28+
 29+ if ( isset($this->m_params['perrow']) )
 30+ $ig->setPerRow( $this->m_params['perrow'] );
 31+ if ( isset($this->m_params['widths']) )
 32+ $ig->setWidths( $this->m_params['widths'] );
 33+ if ( isset($this->m_params['heights']) )
 34+ $ig->setHeights( $this->m_params['heights'] );
 35+
 36+ while ($row = $res->getNext()) {
 37+ $firstField = $row[0];
 38+ $imgTitle = $firstField->getNextObject()->getTitle();
 39+
 40+ if ( isset($row[1]) ) {
 41+ //$imgCaption = $this->recursiveTagParse( trim( $row[1]->getNextObject()-> ) ); // TODO: Support captions
 42+ $imgCaption = $imgTitle->getBaseText();
 43+ }
 44+ else {
 45+ $imgCaption = $imgTitle->getBaseText();
 46+ $imgCaption = preg_replace('#\.[^.]+$#', '', $imgCaption);
 47+ }
 48+
 49+ $ig->add( $imgTitle, $imgCaption );
 50+
 51+ # Only add real images (bug #5586)
 52+ if ( $imgTitle->getNamespace() == NS_IMAGE ) {
 53+ $wgParser->mOutput->addImage( $imgTitle->getDBkey() );
 54+ }
 55+ }
 56+
 57+ $result = $ig->toHTML();
 58+
 59+
 60+ return array($result, 'noparse' => 'true', 'isHTML' => 'true');
 61+ }
 62+}
 63+
 64+# vim:set tabstop=4 noexpandtab shiftwidth=4:
 65+?>
Property changes on: trunk/extensions/SemanticGallery/SG_ResultPrinter.php
___________________________________________________________________
Added: svn:eol-style
166 + native
Index: trunk/extensions/SemanticGallery/SemanticGallery.php
@@ -0,0 +1,51 @@
 2+<?php
 3+
 4+if ( !defined('MEDIAWIKI') )
 5+ die(1);
 6+
 7+$wgExtensionFunctions[] = 'semanticGallery_Setup';
 8+
 9+function semanticGallery_Setup()
 10+{
 11+ global $wgParser, $wgHooks;
 12+
 13+ // credits
 14+ $wgExtensionCredits['parserhook'][] = array(
 15+ 'name' => 'Semantic Gallery',
 16+ 'version' => '0.1.1',
 17+ 'author' => array( 'Rowan Rodrik van der Molen' ),
 18+ 'url' => 'http://www.mediawiki.org/wiki/Extension:Semantic_Gallery',
 19+ 'description' => 'Adds a gallery output format to SMW inline queries',
 20+ 'descriptionmsg' => 'semanticgallery-desc',
 21+ );
 22+
 23+ //$wgHooks['LanguageGetMagic'][] = 'semanticGallery_Magic';
 24+
 25+ //$wgParser->setFunctionHook('semantic-gallery', 'semanticGallery_Render');
 26+
 27+ require_once('SG_ResultPrinter.php');
 28+
 29+ // global variable introduced in SMW 1.2.2
 30+ global $smwgResultFormats;
 31+ if (isset($smwgResultFormats))
 32+ $smwgResultFormats['gallery'] = 'SemanticGallery_ResultPrinter';
 33+ else
 34+ SMWQueryProcessor::$formats['gallery'] = 'SemanticGallery_ResultPrinter';
 35+}
 36+
 37+/*
 38+function semanticGallery_Magic( &$magicWords, $langCode )
 39+{
 40+ $magicWords['semantic-gallery'] = array(0, 'semantic-gallery');
 41+
 42+ return true;
 43+}
 44+
 45+function semanticGallery_Render($input, $args, $parser)
 46+{
 47+ //return $gallery->toHTML();
 48+}
 49+*/
 50+
 51+# vim:set tabstop=4 noexpandtab shiftwidth=4:
 52+?>
Property changes on: trunk/extensions/SemanticGallery/SemanticGallery.php
___________________________________________________________________
Added: svn:eol-style
153 + native

Status & tagging log