function getLayer($layerId = null) { $user = new User(Mapbender::session()->get("mb_user_id")); $wmsIdArray = $user->getOwnedWms(); if (!is_array($wmsIdArray) || count($wmsIdArray) === 0) { abort(_mb("No metadata sets available.")); } $wmsId = wms::getWmsIdByLayerId($layerId); if (is_null($wmsId) || !in_array($wmsId, $wmsIdArray)) { abort(_mb("You are not allowed to access WMS " . $wmsId)); } return; }
$upload_id = intval($_POST['upl_id' . $i]); if ($upd_wmsid) { // get upload URL $sql = "SELECT wms_upload_url, wms_owner FROM wms WHERE wms_id = \$1"; $v = array($upd_wmsid); $t = array("i"); $res = db_prep_query($sql, $v, $t); $row = db_fetch_array($res); $uploadUrl = $row["wms_upload_url"]; $wmsOwner = $row["wms_owner"]; if ($wmsOwner !== $user->id) { echo "<br>Skipped: " . $upd_wmsid . "<br>"; continue; } // update WMS from upload URL $mywms = new wms(); $mywms->createObjFromXML($uploadUrl); $mywms->optimizeWMS(); echo "<br />"; $mywms->updateObjInDB($upd_wmsid); echo "<br>Updated: " . $upd_wmsid . "<br>"; /* // start new monitoring for this WMS $now = time(); $sql = "UPDATE mb_monitor SET status = '-2', status_comment = 'Monitoring is still in progress...', " . "timestamp_begin = $1, timestamp_end = $2 WHERE upload_id = $3 AND fkey_wms_id = $4"; $v = array($now, $now, $upload_id, $upd_wmsid); $t = array('s', 's', 's', 'i'); $res = db_prep_query($sql,$v,$t); $currentFilename = "wms_monitor_report_" . $upload_id . "_" .
public function getParents() { $parents = array(); $wmsId = wms::getWmsIdByLayerId($this->layer_uid); $wmsFactory = new UniversalWmsFactory(); $wms = $wmsFactory->createFromDb($wmsId); if (!is_null($wms)) { try { $currentLayer = $wms->getLayerById($this->layer_uid); } catch (Exception $e) { return $parents; } while (!is_null($currentLayer)) { $pos = $currentLayer->layer_parent; $currentLayer = $wms->getLayerByPos($pos); if (!is_null($currentLayer)) { $parents[] = $currentLayer; } } } return $parents; }
# # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. require_once dirname(__FILE__) . "/mb_validatePermission.php"; require_once dirname(__FILE__) . "/../classes/class_wms.php"; if (isset($_REQUEST["wms_id"]) == false) { echo "file: " . $_REQUEST["xml_file"]; $gui_id = $_REQUEST["guiList"]; $xml = $_REQUEST["xml_file"]; if ($_REQUEST["auth_type"] == 'basic' || $_REQUEST["auth_type"] == 'digest') { $auth = array(); $auth['username'] = $_REQUEST["username"]; $auth['password'] = $_REQUEST["password"]; $auth['auth_type'] = $_REQUEST["auth_type"]; } $mywms = new wms(); if (isset($auth)) { $mywms->createObjFromXML($xml, $auth); $mywms->writeObjInDB($gui_id, $auth); } else { $mywms->createObjFromXML($xml); $mywms->writeObjInDB($gui_id); } $mywms->displayWMS(); $wms_id = $mywms->wms_id; } else { $wms_id = $_REQUEST["wms_id"]; } require_once dirname(__FILE__) . "/../php/mod_editWMS_Metadata.php"; editWMSByWMSID($wms_id);
?> <!--Line for showing wms metadata--> view wms metadata: <a id='metadatalink' href='' onclick="window.open(this.href,'Metadaten','width=500,height=600,left=100,top=200,scrollbars=yes ,dependent=yes'); return false" target="_blank"><span id="metadatatext">no WMS selected</span></a><br><br> <?php echo "Link to the last uploaded Online Resource URL:<br><input type='text' size='120' name='capURL'><br />"; echo "<input type='hidden' name='myWMS' value=''><br>"; echo "Add the following REQUEST to the Online Resource URL to obtain the Capabilities document:<br>"; echo "<i>(Triple click to select and copy)</i><br>"; echo "REQUEST=GetCapabilities&SERVICE=WMS&VERSION=1.1.1<br>"; echo "REQUEST=GetCapabilities&SERVICE=WMS&VERSION=1.1.0<br>"; echo "REQUEST=capabilities&WMTVER=1.0.0<br><br>"; echo "Link to new WMS Capabilities URL:<br><input size='120' type='text' name='myURL'><br>"; echo "<input type='button' value='Preview Capabilities' onclick='window.open(this.form.myURL.value,\"\",\"\")'> "; echo "<input type='button' value='Upload Capabilities' onclick='validate()'><br>"; if (isset($myURL) && $myURL != '') { $mywms = new wms(); $mywms->createObjFromXML($myURL); $mywms->optimizeWMS(); echo "<br />"; if (!MD_OVERWRITE) { $mywms->overwrite = false; } $mywms->updateObjInDB($myWMS); $mywms->displayWMS(); // start (owners of the updated wms will be notified by email) if ($use_php_mailing) { $owner_ids = $admin->getOwnerByWms($myWMS); if ($owner_ids && count($owner_ids) > 0) { $owner_mail_addresses = array(); $j = 0; for ($i = 0; $i < count($owner_ids); $i++) {
private static function selectByApplication($appId, $frameName) { // find the mapframe in the application elements... $sql = "SELECT * FROM gui_element WHERE fkey_gui_id = \$1 AND " . "e_id = \$2 AND e_public = 1 LIMIT 1"; $v = array($appId, $frameName); $t = array('s', 's'); $res = db_prep_query($sql, $v, $t); $row = db_fetch_array($res); // if found... if ($row) { $currentMap = new Map(); // use settings from database $currentMap->setWidth($row["e_width"]); $currentMap->setHeight($row["e_height"]); $currentMap->setFrameName($row["e_id"]); // get the WMS $wmsArray = wms::selectMyWmsByApplication($appId); // $e = new mb_notice("WMS in this map: " . implode(",", $wmsArray)); // if this is the overview, find the WMS index and // reset the WMS array // BEWARE, SUPER UGLY CODE AHEAD!! // (BUT THERE IS NO OTHER WAY TO DO IT) if (strpos($row["e_js_file"], "mb_overview.js") !== false) { // $e = new mb_exception("guess this is the OV"); $ov_sql = "SELECT var_value FROM gui_element_vars WHERE " . "var_name = 'overview_wms' AND fkey_e_id = \$1 AND " . "fkey_gui_id = \$2"; $ov_v = array($frameName, $appId); $ov_t = array('s', 's'); $ov_res = db_prep_query($ov_sql, $ov_v, $ov_t); $ov_row = db_fetch_array($ov_res); if ($ov_row) { $ovIndex = intval($ov_row["var_value"]); } // $e = new mb_exception("OV index: " . $ovIndex); if (!isset($ovIndex)) { $ovIndex = 0; } $wmsArray = array($wmsArray[$ovIndex]); // $e = new mb_notice("WMS in this map (corrected): " . implode(",", $wmsArray)); } else { // $e = new mb_exception("guess this is NOT the OV"); } $currentMap->wmsArray = $wmsArray; // EXTENT $sql = "SELECT gui_wms_epsg FROM gui_wms WHERE gui_wms_position = 0 AND fkey_gui_id = \$1"; $v = array($appId); $t = array('s'); $res = db_prep_query($sql, $v, $t); $row = db_fetch_array($res); $epsg = $row["gui_wms_epsg"]; $layer_epsg = $wmsArray[0]->objLayer[0]->layer_epsg; $j = 0; for ($i = 0; $i < count($layer_epsg); $i++) { if ($layer_epsg[$i]["epsg"] === $epsg) { $j = $i; break; } } $minx = $wmsArray[0]->objLayer[0]->layer_epsg[$j]["minx"]; $miny = $wmsArray[0]->objLayer[0]->layer_epsg[$j]["miny"]; $maxx = $wmsArray[0]->objLayer[0]->layer_epsg[$j]["maxx"]; $maxy = $wmsArray[0]->objLayer[0]->layer_epsg[$j]["maxy"]; $epsg = $wmsArray[0]->objLayer[0]->layer_epsg[$j]["epsg"]; $mapExtent = new Mapbender_bbox($minx, $miny, $maxx, $maxy, $epsg); $currentMap->setExtent($mapExtent); return $currentMap; } else { return null; } }
# but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. require_once dirname(__FILE__) . "/../php/mb_validateSession.php"; require_once dirname(__FILE__) . "/../classes/class_wms.php"; require_once dirname(__FILE__) . "/../classes/class_administration.php"; #require_once(dirname(__FILE__)."/../classes/class_mb_exception.php"); $capabilitiesURL = $_REQUEST['caps']; $noHtml = intval($_GET["noHtml"]); $output = ""; $charset = CHARSET; $mywms = new wms(); #$e = new mb_exception("mod_createJSObjFromXML: CapUrl encoded to load: ".$capabilitiesURL); $caps = $capabilitiesURL; #$e = new mb_exception("mod_createJSObjFromXML: CapUrl decodes to load: ".$caps); $caps = html_entity_decode($_REQUEST['caps']); //$caps = html_entity_decode(base64_decode($_REQUEST['caps'])); $mywms->createObjFromXML($caps); $errorMessage = _mb("Error: The Capabilities Document could not be accessed. " . "Please check whether the server is responding and accessible to " . "Mapbender."); if (!$mywms->wms_status) { $output .= "try {" . "Mapbender.Modules.dialogManager.openDialog({" . "content: '" . $errorMessage . "<br><br><b>" . $capabilitiesURL . "', modal: false, effectShow: 'puff'});" . "} catch (e) {" . "prompt('" . $errorMessage . "', '" . $capabilitiesURL . "');" . "}"; } else { if ($noHtml) { $output .= $mywms->createJsObjFromWMS_(false); } else { $output .= $mywms->createJsObjFromWMS_(true); }
<?php // // Load WMS // require_once dirname(__FILE__) . "/../php/mb_validateSession.php"; require_once dirname(__FILE__) . "/../classes/class_wms.php"; require_once dirname(__FILE__) . "/../classes/class_administration.php"; $wmsArray = wms::selectMyWmsByApplication($gui_id); for ($i = 0; $i < count($wmsArray); $i++) { $currentWms = $wmsArray[$i]; $output = $currentWms->createJsObjFromWMS_(); echo administration::convertOutgoingString($output); unset($output); }
$singleAssocArray[$key] = $val; } } } //get WMS by ID with settings of given application if (array_key_exists('application', $singleAssocArray) && array_key_exists('id', $singleAssocArray)) { $currentWms = new wms(); $currentWms->createObjFromDB($singleAssocArray['application'], $singleAssocArray['id']); array_push($wmsArray, $currentWms); $options['visible'] = $singleAssocArray['visible'] === "1" ? true : false; $options['zoom'] = $singleAssocArray['zoom'] === "1" ? true : false; $wmcGetApi->mergeWmsArray($wmsArray, $options); $wmsArray = array(); $singleAssocArray = array(); } elseif (array_key_exists('url', $singleAssocArray)) { $currentWms = new wms(); $currentWms->createObjFromXML($singleAssocArray['url']); array_push($wmsArray, $currentWms); if ($singleAssocArray['visible']) { $options['visible'] = $singleAssocArray['visible'] === "1" ? true : false; } if ($singleAssocArray['zoom']) { $options['zoom'] = $singleAssocArray['zoom'] === "1" ? true : false; } $wmcGetApi->mergeWmsArray($wmsArray, $options); $wmsArray = array(); $singleAssocArray = array(); } } // // LAYER
$sql_le = "SELECT * FROM layer_epsg WHERE fkey_layer_id = \$1"; $v = array($layer_id[0]); $t = array('i'); $res_le = db_prep_query($sql_le, $v, $t); $cnt_le = 0; while ($row = db_fetch_array($res_le)) { $epsg[$cnt_le] = $row["epsg"]; $cnt_le++; } # Save button echo "<div style='position:absolute;left:500px; top:225px;' ><input type='button' style='width:130px;height:80px;background-color:#ffeded' value='Save Settings' onclick='checkBoxValue()'></div>"; echo "<table class='table_top'>"; echo "<tr>"; echo "<td colspan='2'>"; echo "<a href='" . $wms_getcapabilities[0]; echo wms::getConjunctionCharacter($wms_getcapabilities[0]); if ($wms_version[0] == "1.0.0") { echo "WMTVER=" . $wms_version[0] . "&REQUEST=capabilities"; } else { echo "VERSION=" . $wms_version[0] . "&REQUEST=GetCapabilities&SERVICE=WMS"; } echo "' style='font-size:14px' target='_blank'>LINK: Capabilities</a>"; echo "</td>"; echo "<td align = right>WMS ID: " . $wms_id[0] . "</td>"; echo "<tr>"; #epsg if ($gui_wms_position[0] == 0) { echo "<tr>"; echo "<td>EPSG: </td><td>"; echo "<select class='mySelect' name='this_gui_wms_epsg'>"; for ($i = 0; $i < count($epsg); $i++) {
# but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. require_once dirname(__FILE__) . "/../php/mb_validateSession.php"; require_once dirname(__FILE__) . "/../classes/class_wms.php"; require_once dirname(__FILE__) . "/../classes/class_administration.php"; $capabilitiesURL = $_REQUEST['caps']; $layerName = $_REQUEST['layerName']; $noHtml = intval($_GET["noHtml"]); $output = ""; $charset = CHARSET; $mywms = new wms(); $mywms->createObjFromXML($capabilitiesURL); $errorMessage = _mb("Error: The Capabilities Document could not be accessed. " . "Please check whether the server is responding and accessible to " . "Mapbender."); if (!$mywms->wms_status) { $output .= "try {" . "Mapbender.Modules.dialogManager.openDialog({" . "content: '" . $errorMessage . "<br><br><b>" . $capabilitiesURL . "', modal: false, effectShow: 'puff'});" . "} catch (e) {" . "prompt('" . $errorMessage . "', '" . $capabilitiesURL . "');" . "}"; } else { if ($noHtml) { $output .= $mywms->createJsLayerObjFromWMS(false, $layerName); } else { $output .= $mywms->createJsLayerObjFromWMS(true, $layerName); } } $js = administration::convertOutgoingString($output); unset($output); if ($noHtml) { echo $js;
* http://svn.osgeo.org/mapbender/trunk/mapbender/license/license.txt */ var ol_map = Mapbender.modules[options.target[0]]; ol_map.mapbenderEvents.mapInstantiated.register(function () { var ol_map = Mapbender.modules[options.target[0]]; <?php require_once dirname(__FILE__) . "/../php/mb_validateSession.php"; require_once dirname(__FILE__) . "/../classes/class_wms.php"; $sql = "SELECT fkey_wms_id FROM gui_wms WHERE fkey_gui_id = \$1 ORDER BY gui_wms_position"; $v = array(Mapbender::session()->get("mb_user_gui")); $t = array('s'); $res = db_prep_query($sql, $v, $t); $cnt = 0; while ($row = db_fetch_array($res)) { $mywms = new wms(); $mywms->createObjFromDB(Mapbender::session()->get("mb_user_gui"), $row["fkey_wms_id"]); // create the first OL-layer as baselayer $isBaseLayer = $cnt === 0 ? true : false; $mywms->createOlObjFromWMS($isBaseLayer); $cnt++; } ?> // fire the mapInstantiated event // often the controls will be listening to this event ol_map.mapbenderEvents.layersAdded.trigger(); // fire the mapInstantiated event ol_map.mapbenderEvents.mapReady.trigger(); });
# # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. require_once dirname(__FILE__) . "/../php/mb_validateSession.php"; require_once dirname(__FILE__) . "/../classes/class_wms.php"; require_once dirname(__FILE__) . "/../classes/class_administration.php"; $wms_id = $_GET["wms_id"]; $gui_id = $_GET["gui_id"]; $user_id = $_SESSION["mb_user_id"]; $noHtml = intval($_GET["noHtml"]); $js = ""; // check if user is allowed to access this wms $admin = new administration(); if ($admin->getWmsPermission($wms_id, $user_id)) { $mywms = new wms(); if ($gui_id !== '') { $mywms->createObjFromDB($gui_id, $wms_id); } else { $mywms->createObjFromDBNoGui($wms_id); } if ($noHtml) { $output .= $mywms->createJsObjFromWMS_(false); } else { $output .= $mywms->createJsObjFromWMS_(true); } $js .= administration::convertOutgoingString($output); unset($output); } else { $e = new mb_exception("You are not allowed to access this WMS (WMS ID " . $wms_id . ")."); }
public function createLayerFromDb($id, $appId = null) { $wmsId = intval(wms::getWmsIdByLayerId($id)); $version = $this->getVersionByWmsId($wmsId); if (!is_null($version)) { $factory = $this->getFactory($version); if (!is_null($factory)) { if (!is_null($appId)) { return $factory->createLayerFromDb($id, $wmsId, $appId); } return $factory->createLayerFromDb($id, $wmsId); } return null; } }