r84031 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r84030‎ | r84031 | r84032 >
Date:16:45, 15 March 2011
Author:jeroendedauw
Status:deferred
Tags:
Comment:
reinmplemented template parameter
Modified paths:
  • /branches/SemanticMaps0.8/includes/queryprinters/SM_MapPrinter.php (modified) (history)
  • /branches/SemanticMaps0.8/includes/queryprinters/SM_QueryHandler.php (modified) (history)

Diff [purge]

Index: branches/SemanticMaps0.8/includes/queryprinters/SM_MapPrinter.php
@@ -133,6 +133,7 @@
134134 New CriterionNotEmpty()
135135 )
136136 );
 137+ $params['template']->setDoManipulationOfDefault( false );
137138
138139 $params['title'] = new Parameter(
139140 'title',
@@ -166,6 +167,7 @@
167168
168169 $queryHandler = new SMQueryHandler( $res, $outputmode );
169170 $queryHandler->setShowSubject( $params['showtitle'] );
 171+ $queryHandler->setTemplate( $params['template'] );
170172
171173 $this->handleMarkerData( $params, $queryHandler->getLocations() );
172174 $locationAmount = count( $params['locations'] );
Index: branches/SemanticMaps0.8/includes/queryprinters/SM_QueryHandler.php
@@ -17,7 +17,14 @@
1818
1919 protected $locations = false;
2020
21 - public $template = false;
 21+ /**
 22+ * The template to use for the text, or false if there is none.
 23+ *
 24+ * @since 0.7.3
 25+ *
 26+ * @var false or string
 27+ */
 28+ protected $template = false;
2229
2330 /**
2431 * The global icon.
@@ -118,6 +125,17 @@
119126 }
120127
121128 /**
 129+ * Sets the template.
 130+ *
 131+ * @since 0.8
 132+ *
 133+ * @param string $template
 134+ */
 135+ public function setTemplate( $template ) {
 136+ $this->template = $template == '' ? false : $template;
 137+ }
 138+
 139+ /**
122140 * Sets the global icon.
123141 *
124142 * @since 0.8
@@ -253,10 +271,9 @@
254272 $text .= $this->subjectSeparator;
255273 }
256274
257 - $text .= implode( '<br />', $properties );
258275 $icon = $this->getLocationIcon( $row );
259276
260 - return $this->buildLocationsList( $coords, $title, $text, $icon );
 277+ return $this->buildLocationsList( $coords, $title, $text, $icon, $properties );
261278 }
262279
263280 /**
@@ -316,6 +333,14 @@
317334 protected function handleResultProperty( SMWDataValue $object, SMWPrintRequest $printRequest ) {
318335 global $wgUser;
319336
 337+ if ( $this->template ) {
 338+ if ( $object instanceof SMWWikiPageValue ) {
 339+ return $object->getTitle()->getPrefixedText();
 340+ } else {
 341+ return $object->getLongText( SMW_OUTPUT_WIKI, NULL );
 342+ }
 343+ }
 344+
320345 if ( $this->linkAbsolute ) {
321346 $t = Title::newFromText( $printRequest->getHTMLText( NULL ), SMW_NS_PROPERTY );
322347
@@ -369,18 +394,36 @@
370395 * @param string $title
371396 * @param string $text
372397 * @param string $icon
 398+ * @param array $properties
373399 *
374400 * @return array of MapsLocation
375401 */
376 - protected function buildLocationsList( array $coords, $title, $text, $icon ) {
 402+ protected function buildLocationsList( array $coords, $title, $text, $icon, array $properties ) {
377403 $locations = array();
378404
 405+ if ( $this->template ) {
 406+ $parser = new Parser();
 407+ global $wgTitle;
 408+ }
 409+ else {
 410+ $text .= implode( '<br />', $properties );
 411+ }
 412+
379413 foreach ( $coords as $coord ) {
380414 if ( count( $coord ) >= 2 ) {
381415 $location = new MapsLocation();
382416 $location->setCoordinates( $coord );
383417
384418 if ( $location->isValid() ) {
 419+ if ( $this->template ) {
 420+ $segments = array_merge(
 421+ array( $this->template, 'title=' . $title, 'latitude=' . $location->getLatitude(), 'longitude=' . $location->getLongitude() ),
 422+ $properties
 423+ );
 424+
 425+ $text .= $parser->parse( '{{' . implode( '|', $segments ) . '}}', $wgTitle, new ParserOptions() )->getText();
 426+ }
 427+
385428 $location->setTitle( $title );
386429 $location->setText( $text );
387430 $location->setIcon( $icon );

Status & tagging log