r74881 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r74880‎ | r74881 | r74882 >
Date:05:32, 17 October 2010
Author:jeroendedauw
Status:deferred
Tags:
Comment:
Changes for 0.7.1 - created table to display property value pairs on layer pages
Modified paths:
  • /trunk/extensions/Maps/Maps.i18n.php (modified) (history)
  • /trunk/extensions/Maps/includes/Maps_LayerPage.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Maps/Maps.i18n.php
@@ -24,6 +24,8 @@
2525 'maps-markers' => 'Markers',
2626 'maps-ns-layer' => 'Layer',
2727 'maps-ns-layer-talk' => 'Layer talk',
 28+ 'maps-layer-property' => 'Property',
 29+ 'maps-layer-value' => 'Value',
2830
2931 // Validation
3032 'validation-error-invalid-location' => 'Parameter $1 must be a valid location.',
Index: trunk/extensions/Maps/includes/Maps_LayerPage.php
@@ -29,7 +29,45 @@
3030 * @since 0.7.1
3131 */
3232 public function view() {
33 - parent::view();
 33+ global $wgOut;
 34+
 35+ $wgOut->setPageTitle( $this->mTitle->getPrefixedText() );
 36+
 37+ $rows = array();
 38+
 39+ $rows[] = Html::rawElement(
 40+ 'tr',
 41+ array(),
 42+ Html::element(
 43+ 'th',
 44+ array( 'width' => '200px' ),
 45+ wfMsg( 'maps-layer-property' )
 46+ ) .
 47+ Html::element(
 48+ 'th',
 49+ array(),
 50+ wfMsg( 'maps-layer-value' )
 51+ )
 52+ );
 53+
 54+ foreach ( $this->getProperties() as $property => $value ) {
 55+ $rows[] = Html::rawElement(
 56+ 'tr',
 57+ array(),
 58+ Html::element(
 59+ 'td',
 60+ array(),
 61+ $property
 62+ ) .
 63+ Html::element(
 64+ 'td',
 65+ array(),
 66+ $value
 67+ )
 68+ );
 69+ }
 70+
 71+ $wgOut->addHTML( Html::rawElement( 'table', array( 'width' => '100%', 'class' => 'wikitable sortable' ), implode( "\n", $rows ) ) );
3472 }
3573
3674 /**
@@ -51,6 +89,12 @@
5290 * @return array
5391 */
5492 protected function getProperties() {
 93+ static $cachedProperties = false;
 94+
 95+ if ( $cachedProperties !== false ) {
 96+ return $cachedProperties;
 97+ }
 98+
5599 $properties = array();
56100
57101 if ( is_null( $this->mContent ) ) {
@@ -65,6 +109,7 @@
66110 }
67111 }
68112
 113+ $cachedProperties = $properties;
69114 return $properties;
70115 }
71116

Status & tagging log