예제 #1
0
 /**
  * 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;
 }
예제 #2
0
 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;
 }
예제 #3
0
 /**
  * Builds up and returns the HTML for the map, with the queried coordinate data on it.
  *
  * @param SMWQueryResult $res
  * @param $outputmode
  * 
  * @return array or string
  */
 public final function getResultText(SMWQueryResult $res, $outputmode)
 {
     if ($this->fatalErrorMsg === false) {
         global $wgParser;
         $params = $this->params;
         $queryHandler = new SMQueryHandler($res, $outputmode);
         $queryHandler->setShowSubject($params['showtitle']);
         $queryHandler->setTemplate($params['template']);
         $this->handleMarkerData($params, $queryHandler->getLocations());
         $locationAmount = count($params['locations']);
         if ($params['forceshow'] || $locationAmount > 0) {
             // 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 && $locationAmount <= 1) {
                 $params['zoom'] = $this->service->getDefaultZoom();
             }
             $mapName = $this->service->getMapId();
             // 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();
             }
             SMWOutputs::requireHeadItem($mapName, $this->service->getDependencyHtml() . ($configVars = Skin::makeVariablesScript($this->service->getConfigVariables())));
             foreach ($this->service->getResourceModules() as $resourceModule) {
                 SMWOutputs::requireResource($resourceModule);
             }
             $result = $this->getMapHTML($params, $wgParser, $mapName) . $this->getJSON($params, $wgParser, $mapName);
             return array($result, 'noparse' => true, 'isHTML' => true);
         } else {
             return '';
         }
     } else {
         return $this->fatalErrorMsg;
     }
 }
 /**
  * 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>';
     }
 }
예제 #6
0
 /**
  * Builds up and returns the HTML for the map, with the queried coordinate data on it.
  *
  * @param SMWQueryResult $res
  * @param $outputmode
  * 
  * @return array or string
  */
 public final function getResultText(SMWQueryResult $res, $outputmode)
 {
     if ($this->fatalErrorMsg !== false) {
         return $this->fatalErrorMsg;
     }
     /**
      * @var Parser $wgParser
      */
     global $wgParser;
     $params = $this->params;
     $queryHandler = new SMQueryHandler($res, $outputmode);
     $queryHandler->setLinkStyle($params['link']);
     $queryHandler->setHeaderStyle($params['headers']);
     $queryHandler->setShowSubject($params['showtitle']);
     $queryHandler->setTemplate($params['template']);
     $queryHandler->setHideNamespace($params['hidenamespace']);
     $queryHandler->setActiveIcon($params['activeicon']);
     $this->handleMarkerData($params, $queryHandler);
     $locationAmount = count($params['locations']);
     if ($locationAmount > 0) {
         // We can only take care of the zoom defaulting here,
         // as not all locations are available in whats passed to Validator.
         if ($this->fullParams['zoom']->wasSetToDefault() && $locationAmount > 1) {
             $params['zoom'] = false;
         }
         $mapName = $this->service->getMapId();
         SMWOutputs::requireHeadItem($mapName, $this->service->getDependencyHtml() . ($configVars = Skin::makeVariablesScript($this->service->getConfigVariables())));
         foreach ($this->service->getResourceModules() as $resourceModule) {
             SMWOutputs::requireResource($resourceModule);
         }
         if (array_key_exists('source', $params)) {
             unset($params['source']);
         }
         return $this->getMapHTML($params, $wgParser, $mapName);
     } else {
         return $params['default'];
     }
 }