/** * 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); }
/** * Responsible for actual output on the layer page which gives an overview of the layer definition. * * @since 3.0 * * @param MapsLayer * * @return string */ public function renderLayerInfo(MapsLayer $layer) { global $wgLang; // appropriate layer header: if ($layer->getName() !== null) { // if layer with same name is defined on same page already: if ($this->getLayerStore()->getLayerByName($layer->getName()) !== null) { return $this->errorbox(wfMessage('maps-layerdef-equal-layer-name', $layer->getName())->inContentLanguage()->text()); } $outHeader = wfMessage('maps-layer-of-type-and-name', $layer->getType(), $layer->getName())->inContentLanguage()->text(); } else { $outHeader = wfMessage('maps-layer-of-type', $layer->getType())->inContentLanguage()->text(); } $outHeader = "<span class=\"mapslayerhead\">{$outHeader}</span>"; // info message about which services are supporting the layer(-type): $supportedServices = MapsLayerTypes::getServicesForType($layer->getType()); $outServices = '<span class="mapslayersupports">' . wfMessage('maps-layer-type-supported-by', $wgLang->listToText($supportedServices), count($supportedServices))->inContentLanguage()->escaped() . '</span>'; $outTable = $this->getLayerDefinitionTable($layer); return Html::rawElement('div', array('class' => 'mapslayer' . ($layer->isOk() ? '' : ' mapslayererror')), $outHeader . $outServices . $outTable); }