Index: branches/SemanticMaps0.8/includes/queryprinters/SM_QueryPrinters.php |
— | — | @@ -58,87 +58,6 @@ |
59 | 59 | } |
60 | 60 | |
61 | 61 | /** |
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 | | - /** |
143 | 62 | * Add the result format for a mapping service or alias. |
144 | 63 | * |
145 | 64 | * @param string $format |
Index: branches/SemanticMaps0.8/includes/queryprinters/SM_MapPrinter.php |
— | — | @@ -63,11 +63,8 @@ |
64 | 64 | protected function readParameters( /* array */ $params, $outputmode ) { |
65 | 65 | parent::readParameters( $params, $outputmode ); |
66 | 66 | |
67 | | - $parameterInfo = SMQueryPrinters::getParameterInfo(); |
68 | | - $this->service->addParameterInfo( $parameterInfo ); |
69 | | - |
70 | 67 | $validator = new Validator( $this->getName(), false ); |
71 | | - $validator->setParameters( $params, $parameterInfo ); |
| 68 | + $validator->setParameters( $params, $this->getParameterInfo() ); |
72 | 69 | $validator->validateParameters(); |
73 | 70 | |
74 | 71 | $fatalError = $validator->hasFatalError(); |
— | — | @@ -81,6 +78,90 @@ |
82 | 79 | htmlspecialchars( wfMsgExt( 'validator-fatal-error', 'parsemag', $fatalError->getMessage() ) ) . |
83 | 80 | '</span>'; |
84 | 81 | } |
| 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; |
85 | 166 | } |
86 | 167 | |
87 | 168 | /** |
— | — | @@ -97,12 +178,22 @@ |
98 | 179 | |
99 | 180 | $params = $this->parameters; |
100 | 181 | |
101 | | - $queryHandler = new SMQueryHandler( $res, $outputmode, $params ); |
102 | | - |
| 182 | + $queryHandler = new SMQueryHandler( $res, $outputmode ); |
103 | 183 | $this->handleMarkerData( $params, $queryHandler->getLocations() ); |
104 | 184 | |
| 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 | + |
105 | 191 | $mapName = $this->service->getMapId(); |
106 | 192 | |
| 193 | + SMWOutputs::requireHeadItem( $this->service->getDependencyHtml(), $mapName ); |
| 194 | + foreach ( $this->service->getResourceModules() as $resourceModule ) { |
| 195 | + SMWOutputs::requireResource( $resourceModule ); |
| 196 | + } |
| 197 | + |
107 | 198 | return array( |
108 | 199 | $this->getMapHTML( $params, $wgParser, $mapName ) . $this->getJSON( $params, $wgParser, $mapName ), |
109 | 200 | 'noparse' => true, |
— | — | @@ -287,4 +378,4 @@ |
288 | 379 | return $typeMap[$type]; |
289 | 380 | } |
290 | 381 | |
291 | | -} |
\ No newline at end of file |
| 382 | +} |