Example #1
0
 /**
  * @see MapsLayer::getParameterDefinitions
  * 
  * @since 0.7.2
  * 
  * @return array
  */
 protected function getParameterDefinitions()
 {
     $params = parent::getParameterDefinitions();
     $params['source'] = new Parameter('source');
     $params['source']->addCriteria(new CriterionIsImage());
     $params['source']->addManipulations(new MapsParamFile());
     $params['maxdepth'] = new Parameter('maxdepth', Parameter::TYPE_INTEGER, 2);
     return $params;
 }
Example #2
0
 /**
  * Returns database fields as keys and an associated value taken from a layer as value, ready
  * for database insert.
  *
  * @since 3.0
  *
  * @param MapsLayer $layer
  * @param integer   $pageId The article id of the page the layer should be associated to.
  *                  For example "Title::getArticleID()".
  *
  * @return array
  */
 public static function databaseRowFromLayer(MapsLayer $layer, $pageId)
 {
     // format layer properties array:
     $properties = array();
     foreach ($layer->getProperties() as $key => $prop) {
         $properties[] = "{$key}={$prop}";
     }
     $properties = implode("\n", $properties);
     return array('layer_page_id' => $pageId, 'layer_name' => $layer->getName(), 'layer_type' => $layer->getType(), 'layer_data' => $properties);
 }
 /**
  * Displays the layer definition as a table.
  *
  * @since 3.0
  *
  * @param MapsLayer $layer
  *
  * @return string
  */
 protected function getLayerDefinitionTable(MapsLayer $layer)
 {
     $out = '';
     $outWarning = '';
     // check whether any error occurred during parameter validaton:
     if (!$layer->isValid()) {
         $messages = $layer->getErrorMessages();
         $warnings = '';
         if (count($messages) === 1) {
             $warnings = htmlspecialchars($messages[0]);
         } else {
             $warnings = '<ul><li>' . implode('</li><li>', array_map('htmlspecialchars', $messages)) . '</li></ul>';
         }
         $warnings = '<tr><td class="mapslayerpropname">' . wfMessage('maps-layerdef-invalid' . ($layer->isOk() ? '' : '-fatal'), count($messages))->inContentLanguage()->escaped() . "</td><td class=\"mapslayerpropval\">{$warnings}</td></tr>";
         $outWarning .= Html::rawElement('table', array('width' => '100%', 'class' => $layer->isOk() ? 'mapslayerwarntable' : 'mapslayererrortable'), $warnings);
         if (!$layer->isOk()) {
             // fatal error occurred, don't print definition table since this would be quite empty since
             // parameter validation aborted after fatal error parameter!
             return $outWarning;
         }
     }
     global $wgOut;
     $wgOut->addModules('ext.maps.layers');
     $rows = array();
     // rows with layer definition:
     $properties = $layer->getPropertiesHtmlRepresentation($this->parser);
     foreach ($properties as $property => $value) {
         $rows[] = Html::rawElement('tr', array(), Html::element('td', array('class' => 'mapslayerpropname'), $property) . Html::rawElement('td', array('class' => 'mapslayerpropval'), $value));
     }
     $out .= Html::rawElement('table', array('width' => '100%', 'class' => 'mapslayertable'), implode("\n", $rows));
     return $out . $outWarning;
 }
Example #4
0
 /**
  * @see MapsLayer::doPropertiesHtmlTransform
  *
  * @since 3.0
  *
  * @return array
  */
 protected function doPropertiesHtmlTransform(&$properties)
 {
     parent::doPropertiesHtmlTransform($properties);
     $sp = '&#x202F;';
     // non-breaking thin space
     // image-size:
     $properties['image-size'] = "<b>width:</b> {$properties['width']}{$sp}pixel, <b>height:</b> {$properties['height']}{$sp}pixel";
     unset($properties['width'], $properties['height']);
     // extent:
     $unit = $properties['units'];
     $properties['extent'] = "<b>left:</b> {$properties['leftextent']}{$sp}{$unit}, " . "<b>bottom:</b> {$properties['bottomextent']}{$sp}{$unit}, " . "<b>right:</b> {$properties['rightextent']}{$sp}{$unit}, " . "<b>top:</b> {$properties['topextent']}{$sp}{$unit}";
     unset($properties['leftextent'], $properties['bottomextent'], $properties['rightextent'], $properties['topextent']);
 }