/** * Handles the request from the parser hook by doing the work that's common for all * mapping services, calling the specific methods and finally returning the resulting output. * * @param array $params * @param Parser $parser * * @return html */ public final function renderMap(array $params, Parser $parser) { $this->handleMarkerData($params, $parser); $mapName = $this->service->getMapId(); $output = $this->getMapHTML($params, $parser, $mapName); $configVars = Skin::makeVariablesScript($this->service->getConfigVariables()); $this->service->addDependencies($parser); $parser->getOutput()->addHeadItem($configVars); return $output; }
private function getMapOutput(array $params, $inputName) { global $wgParser; if (is_object($params['centre'])) { $params['centre'] = $params['centre']->getJSONObject(); } // We can only take care of the zoom defaulting here, // as not all locations are available in whats passed to Validator. if ($params['zoom'] === false && count($params['locations']) <= 1) { $params['zoom'] = $this->service->getDefaultZoom(); } $mapName = $this->service->getMapId(); $params['inputname'] = $inputName; $output = $this->getInputHTML($params, $wgParser, $mapName); $this->service->addResourceModules($this->getResourceModules()); $configVars = Skin::makeVariablesScript($this->service->getConfigVariables()); if (true) { // TODO global $wgOut; $this->service->addDependencies($wgOut); $wgOut->addScript($configVars); } else { $this->service->addDependencies($wgParser); } return $output; }
/** * Handles the request from the parser hook by doing the work that's common for all * mapping services, calling the specific methods and finally returning the resulting output. * * @param array $params * @param Parser $parser * * @return html */ public final function renderMap(array $params, Parser $parser) { $this->handleMarkerData($params, $parser); $mapName = $this->service->getMapId(); $output = $this->getMapHTML($params, $parser, $mapName) . $this->getJSON($params, $parser, $mapName); $configVars = Skin::makeVariablesScript($this->service->getConfigVariables()); // MediaWiki 1.17 does not play nice with addScript, so add the vars via the globals hook. if (version_compare($GLOBALS['wgVersion'], '1.18', '<')) { $GLOBALS['egMapsGlobalJSVars'] += $this->service->getConfigVariables(); } global $wgTitle; if (!is_null($wgTitle) && $wgTitle->isSpecialPage()) { global $wgOut; $this->service->addDependencies($wgOut); $wgOut->addScript($configVars); } else { $this->service->addDependencies($parser); $parser->getOutput()->addHeadItem($configVars); } return $output; }
/** * * * @since 1.0 * * @param string $coordinates * @param string $input_name * @param boolean $is_mandatory * @param boolean $is_disabled * @param array $field_args * * @return string */ public function getInputOutput($coordinates, $input_name, $is_mandatory, $is_disabled, array $params) { $parameters = array(); foreach ($params as $key => $value) { if (!is_array($value) && !is_object($value) && !is_null($value)) { $parameters[$key] = $value; } } if (!is_null($coordinates)) { $parameters['locations'] = $coordinates; } $validator = new Validator(wfMessage('maps_' . $this->service->getName())->text(), false); $validator->setParameters($parameters, $this->getParameterInfo()); $validator->validateParameters(); $fatalError = $validator->hasFatalError(); if ($fatalError === false) { global $wgParser; $params = $validator->getParameterValues(); // We can only take care of the zoom defaulting here, // as not all locations are available in whats passed to Validator. if ($params['zoom'] === false && count($params['locations']) <= 1) { $params['zoom'] = $this->service->getDefaultZoom(); } $mapName = $this->service->getMapId(); $params['inputname'] = $input_name; $output = $this->getInputHTML($params, $wgParser, $mapName); $this->service->addResourceModules($this->getResourceModules()); $configVars = Skin::makeVariablesScript($this->service->getConfigVariables()); // MediaWiki 1.17 does not play nice with addScript, so add the vars via the globals hook. if (version_compare($GLOBALS['wgVersion'], '1.18', '<')) { $GLOBALS['egMapsGlobalJSVars'] += $this->service->getConfigVariables(); } if (true) { // TODO global $wgOut; $this->service->addDependencies($wgOut); $wgOut->addScript($configVars); } else { $this->service->addDependencies($wgParser); } return $output; } else { return '<span class="errorbox">' . htmlspecialchars(wfMessage('validator-fatal-error', $fatalError->getMessage())->text()) . '</span>'; } }