r83439 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r83438‎ | r83439 | r83440 >
Date:06:16, 7 March 2011
Author:jeroendedauw
Status:deferred
Tags:
Comment:
fixess to script loading
Modified paths:
  • /branches/SemanticMaps0.8/includes/queryprinters/SM_MapPrinter.php (modified) (history)
  • /branches/SemanticMaps0.8/includes/queryprinters/SM_QueryPrinters.php (modified) (history)

Diff [purge]

Index: branches/SemanticMaps0.8/includes/queryprinters/SM_QueryPrinters.php
@@ -58,87 +58,6 @@
5959 }
6060
6161 /**
62 - * Returns an array containing the parameter info.
63 - *
64 - * @since 0.7
65 - *
66 - * @return array
67 - */
68 - public static function getParameterInfo() {
69 - global $egMapsDefaultServices, $egMapsAvailableGeoServices, $egMapsDefaultGeoService, $egMapsMapWidth, $egMapsMapHeight;
70 - global $egMapsDefaultLabel, $egMapsDefaultTitle;
71 - global $smgQPForceShow, $smgQPShowTitle, $smgQPTemplate;
72 -
73 - $params = MapsMapper::getCommonParameters();
74 -
75 - $params['staticlocations'] = new ListParameter( 'staticlocations', ';' );
76 - $params['staticlocations']->addAliases( 'locations' );
77 - $params['staticlocations']->addCriteria( new CriterionIsLocation( '~' ) );
78 - $params['staticlocations']->addManipulations( new MapsParamLocation( '~' ) );
79 - $params['staticlocations']->setDefault( array() );
80 -
81 - $params['centre'] = new Parameter( 'centre' );
82 - $params['centre']->setDefault( false );
83 - $params['centre']->addAliases( 'center' );
84 - $params['centre']->addCriteria( new CriterionIsLocation() );
85 - $params['centre']->setDoManipulationOfDefault( false );
86 - $manipulation = new MapsParamLocation();
87 - $manipulation->toJSONObj = true;
88 - $params['centre']->addManipulations( $manipulation );
89 -
90 - $params['icon'] = new Parameter(
91 - 'icon',
92 - Parameter::TYPE_STRING,
93 - '', // TODO
94 - array(),
95 - array(
96 - New CriterionNotEmpty()
97 - )
98 - );
99 -
100 - $params['forceshow'] = new Parameter(
101 - 'forceshow',
102 - Parameter::TYPE_BOOLEAN,
103 - $smgQPForceShow,
104 - array( 'force show' )
105 - );
106 - $params['forceshow']->addManipulations( new ParamManipulationBoolean() );
107 -
108 - $params['showtitle'] = new Parameter(
109 - 'showtitle',
110 - Parameter::TYPE_BOOLEAN,
111 - $smgQPShowTitle,
112 - array( 'show title' )
113 - );
114 - $params['showtitle']->addManipulations( new ParamManipulationBoolean() );
115 -
116 - $params['template'] = new Parameter(
117 - 'template',
118 - Parameter::TYPE_STRING,
119 - $smgQPTemplate,
120 - array(),
121 - array(
122 - New CriterionNotEmpty()
123 - )
124 - );
125 -
126 - $params['title'] = new Parameter(
127 - 'title',
128 - Parameter::TYPE_STRING,
129 - $egMapsDefaultTitle
130 - );
131 -
132 - $params['label'] = new Parameter(
133 - 'label',
134 - Parameter::TYPE_STRING,
135 - $egMapsDefaultLabel,
136 - array( 'text' )
137 - );
138 -
139 - return $params;
140 - }
141 -
142 - /**
14362 * Add the result format for a mapping service or alias.
14463 *
14564 * @param string $format
Index: branches/SemanticMaps0.8/includes/queryprinters/SM_MapPrinter.php
@@ -63,11 +63,8 @@
6464 protected function readParameters( /* array */ $params, $outputmode ) {
6565 parent::readParameters( $params, $outputmode );
6666
67 - $parameterInfo = SMQueryPrinters::getParameterInfo();
68 - $this->service->addParameterInfo( $parameterInfo );
69 -
7067 $validator = new Validator( $this->getName(), false );
71 - $validator->setParameters( $params, $parameterInfo );
 68+ $validator->setParameters( $params, $this->getParameterInfo() );
7269 $validator->validateParameters();
7370
7471 $fatalError = $validator->hasFatalError();
@@ -81,6 +78,90 @@
8279 htmlspecialchars( wfMsgExt( 'validator-fatal-error', 'parsemag', $fatalError->getMessage() ) ) .
8380 '</span>';
8481 }
 82+ }
 83+
 84+ /**
 85+ * Returns an array containing the parameter info.
 86+ *
 87+ * @since 0.8
 88+ *
 89+ * @return array
 90+ */
 91+ protected function getParameterInfo() {
 92+ global $egMapsDefaultLabel, $egMapsDefaultTitle;
 93+ global $smgQPForceShow, $smgQPShowTitle, $smgQPTemplate;
 94+
 95+ $params = MapsMapper::getCommonParameters();
 96+ $this->service->addParameterInfo( $params );
 97+
 98+ $params['zoom']->setDefault( false );
 99+ $params['zoom']->setDoManipulationOfDefault( false );
 100+
 101+ $params['staticlocations'] = new ListParameter( 'staticlocations', ';' );
 102+ $params['staticlocations']->addAliases( 'locations' );
 103+ $params['staticlocations']->addCriteria( new CriterionIsLocation( '~' ) );
 104+ $params['staticlocations']->addManipulations( new MapsParamLocation( '~' ) );
 105+ $params['staticlocations']->setDefault( array() );
 106+
 107+ $params['centre'] = new Parameter( 'centre' );
 108+ $params['centre']->setDefault( false );
 109+ $params['centre']->addAliases( 'center' );
 110+ $params['centre']->addCriteria( new CriterionIsLocation() );
 111+ $params['centre']->setDoManipulationOfDefault( false );
 112+ $manipulation = new MapsParamLocation();
 113+ $manipulation->toJSONObj = true;
 114+ $params['centre']->addManipulations( $manipulation );
 115+
 116+ $params['icon'] = new Parameter(
 117+ 'icon',
 118+ Parameter::TYPE_STRING,
 119+ '', // TODO
 120+ array(),
 121+ array(
 122+ New CriterionNotEmpty()
 123+ )
 124+ );
 125+
 126+ $params['forceshow'] = new Parameter(
 127+ 'forceshow',
 128+ Parameter::TYPE_BOOLEAN,
 129+ $smgQPForceShow,
 130+ array( 'force show' )
 131+ );
 132+ $params['forceshow']->addManipulations( new ParamManipulationBoolean() );
 133+
 134+ $params['showtitle'] = new Parameter(
 135+ 'showtitle',
 136+ Parameter::TYPE_BOOLEAN,
 137+ $smgQPShowTitle,
 138+ array( 'show title' )
 139+ );
 140+ $params['showtitle']->addManipulations( new ParamManipulationBoolean() );
 141+
 142+ $params['template'] = new Parameter(
 143+ 'template',
 144+ Parameter::TYPE_STRING,
 145+ $smgQPTemplate,
 146+ array(),
 147+ array(
 148+ New CriterionNotEmpty()
 149+ )
 150+ );
 151+
 152+ $params['title'] = new Parameter(
 153+ 'title',
 154+ Parameter::TYPE_STRING,
 155+ $egMapsDefaultTitle
 156+ );
 157+
 158+ $params['label'] = new Parameter(
 159+ 'label',
 160+ Parameter::TYPE_STRING,
 161+ $egMapsDefaultLabel,
 162+ array( 'text' )
 163+ );
 164+
 165+ return $params;
85166 }
86167
87168 /**
@@ -97,12 +178,22 @@
98179
99180 $params = $this->parameters;
100181
101 - $queryHandler = new SMQueryHandler( $res, $outputmode, $params );
102 -
 182+ $queryHandler = new SMQueryHandler( $res, $outputmode );
103183 $this->handleMarkerData( $params, $queryHandler->getLocations() );
104184
 185+ // We can only take care of the zoom defaulting here,
 186+ // as not all locations are available in whats passed to Validator.
 187+ if ( $params['zoom'] === false && count( $params['locations'] ) <= 1 ) {
 188+ $params['zoom'] = $this->service->getDefaultZoom();
 189+ }
 190+
105191 $mapName = $this->service->getMapId();
106192
 193+ SMWOutputs::requireHeadItem( $this->service->getDependencyHtml(), $mapName );
 194+ foreach ( $this->service->getResourceModules() as $resourceModule ) {
 195+ SMWOutputs::requireResource( $resourceModule );
 196+ }
 197+
107198 return array(
108199 $this->getMapHTML( $params, $wgParser, $mapName ) . $this->getJSON( $params, $wgParser, $mapName ),
109200 'noparse' => true,
@@ -287,4 +378,4 @@
288379 return $typeMap[$type];
289380 }
290381
291 -}
\ No newline at end of file
 382+}

Status & tagging log