r77335 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r77334‎ | r77335 | r77336 >
Date:17:48, 26 November 2010
Author:jeroendedauw
Status:deferred
Tags:
Comment:
Changes for 0.7.3 - added absolute links to the generated KML
Modified paths:
  • /trunk/extensions/SemanticMaps/SemanticMaps.php (modified) (history)
  • /trunk/extensions/SemanticMaps/includes/queryprinters/SM_QueryHandler.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMaps/includes/queryprinters/SM_QueryHandler.php
@@ -12,6 +12,10 @@
1313 */
1414 class SMQueryHandler {
1515
 16+ const LINK_NONE = 0;
 17+ const LINK_RELATIVE = 1;
 18+ const LINK_ABSOLUTE = 2;
 19+
1620 protected $queryResult;
1721 protected $outputmode;
1822
@@ -20,8 +24,11 @@
2125 // TODO: add system to properly handle query parameters
2226 public $template = false;
2327 public $icon = '';
24 - public $makeLinks = false;
2528
 29+ public $titleLink = self::LINK_ABSOLUTE;
 30+ public $propNameLink = self::LINK_NONE;
 31+ public $propValueLink = self::LINK_NONE;
 32+
2633 /**
2734 * Constructor.
2835 *
@@ -71,6 +78,8 @@
7279 * Returns the locations found in the provided result row.
7380 *
7481 * TODO: split up this method if possible
 82+ * TODO: fix template handling
 83+ * TODO: clean up link type handling
7584 *
7685 * @since 0.7.3
7786 *
@@ -86,7 +95,6 @@
8796 $skin = $wgUser->getSkin();
8897
8998 $title = '';
90 - $titleForTemplate = '';
9199 $text = '';
92100 $lat = '';
93101 $lon = '';
@@ -101,23 +109,28 @@
102110 // Loop throught all the parts of the field value.
103111 while ( ( /* SMWDataValue */ $object = $resultArray->getNextObject() ) !== false ) {
104112 if ( $object->getTypeID() == '_wpg' && $i == 0 ) {
105 - $title = $object->getLongText( $this->outputmode, $this->makeLinks ? $skin : NULL );
106 - $titleForTemplate = $object->getLongText( $this->outputmode, NULL );
 113+ if ( $this->titleLink == self::LINK_ABSOLUTE ) {
 114+ $title = Html::element( 'a', array( 'href' => $object->getTitle()->getFullUrl() ) );
 115+ }
 116+ else {
 117+ $title = $object->getLongText( $this->outputmode, $this->titleLink == self::LINK_RELATIVE ? $skin : NULL );
 118+ }
107119 }
108120
109121 if ( $object->getTypeID() != '_geo' && $i != 0 ) {
110 - if ( $this->template ) {
 122+ /*
 123+ if ( $this->template ) {
111124 if ( $object instanceof SMWWikiPageValue ) {
112125 $label[] = $object->getTitle()->getPrefixedText();
113126 } else {
114127 $label[] = $object->getLongText( $this->outputmode, $this->makeLinks ? $skin : NULL );
115128 }
116129 }
117 - else {
118 - $propertyName = $printRequest->getHTMLText( $this->makeLinks ? $skin : NULL );
 130+ else { */
 131+ $propertyName = $printRequest->getHTMLText( $this->propNameLink == self::LINK_RELATIVE ? $skin : NULL );
119132 if ( $propertyName != '' ) $propertyName .= ': ';
120 - $text .= $propertyName . $object->getLongText( $this->outputmode, $this->makeLinks ? $skin : NULL ) . '<br />';
121 - }
 133+ $text .= $propertyName . $object->getLongText( $this->outputmode, $this->propValueLink == self::LINK_RELATIVE ? $skin : NULL ) . '<br />';
 134+ //}
122135 }
123136
124137 if ( $printRequest->getMode() == SMWPrintRequest::PRINT_PROP && $printRequest->getTypeID() == '_geo' ) {
@@ -126,10 +139,12 @@
127140 }
128141 }
129142
 143+ /*
130144 if ( $this->template ) {
131145 // New parser object to render the templates with.
132146 $parser = new Parser();
133147 }
 148+ */
134149
135150 foreach ( $coords as $coord ) {
136151 if ( count( $coord ) >= 2 ) {
@@ -142,7 +157,7 @@
143158
144159 if ( $lat != '' && $lon != '' ) {
145160 $icon = $this->getLocationIcon( $row );
146 -
 161+ /*
147162 if ( $this->template ) {
148163 $segments = array_merge(
149164 array( $this->template, 'title=' . $titleForTemplate, 'latitude=' . $lat, 'longitude=' . $lon ),
@@ -151,6 +166,7 @@
152167
153168 $text = $parser->parse( '{{' . implode( '|', $segments ) . '}}', $wgTitle, new ParserOptions() )->getText();
154169 }
 170+ */
155171
156172 $location = new MapsLocation();
157173
@@ -171,6 +187,13 @@
172188 }
173189
174190 /**
 191+ * Get
 192+ */
 193+ protected function getDataValueLink() {
 194+
 195+ }
 196+
 197+ /**
175198 * Get the icon for a row.
176199 *
177200 * @since 0.7.3
Index: trunk/extensions/SemanticMaps/SemanticMaps.php
@@ -38,7 +38,7 @@
3939
4040 // Only initialize the extension when all dependencies are present.
4141 if ( defined( 'Maps_VERSION' ) && defined( 'SMW_VERSION' ) ) {
42 - define( 'SM_VERSION', '0.7.3 a2' );
 42+ define( 'SM_VERSION', '0.7.3 a3' );
4343
4444 $useExtensionPath = version_compare( $wgVersion, '1.16', '>=' ) && isset( $wgExtensionAssetsPath ) && $wgExtensionAssetsPath;
4545 $smgScriptPath = ( $useExtensionPath ? $wgExtensionAssetsPath : $wgScriptPath . '/extensions' ) . '/SemanticMaps';

Status & tagging log