function __construct() { global $postgisschema; parent::__construct(); $parts = $this->getUrlParts(); // $this->auth($parts[3]); $postgisschema = $parts[4]; switch ($parts[5]) { case 'create': makeMapFile($parts[3]); makeTileCacheFile($parts[3]); echo $this->toJSON(array("message" => "Files created")); break; } }
<?php include "../server_header.inc"; $table = new table(NULL); $response = $table->create($_REQUEST['name'], $_REQUEST['type'], $_REQUEST['srid']); $table = new table('settings.geometry_columns_join'); $obj = json_decode('{"data":{"f_table_name":"' . $response['tableName'] . '","f_table_title":""}}'); $response2 = $table->updateRecord($obj->data, 'f_table_name', "f_table_schema='{$postgisschema}'"); // If layer is new (inserted) then insert a new class for it if ($response2['operation'] == "inserted") { $class = new _class($_REQUEST['name'], $postgisschema); $class->insert(); } makeMapFile($_SESSION['screen_name']); include_once "../server_footer.inc";
<?php //god dav include "html_header.php"; $_SESSION['schema'] = $schemaFromUri; $postgisschema = $schemaFromUri; include 'model/tables.php'; include "wms/mapfile.php.map"; include "wms/tilecache.cfg.php"; makeMapFile($postgisdb); makeTileCacheFile($postgisdb); ?> <script type="text/javascript">var screenName = '<?php echo $postgisdb; ?> '</script> <script type="text/javascript">var schema = '<?php echo $postgisschema; ?> '</script> <script type="text/javascript" src="/js/ext/adapter/ext/ext-base.js"></script> <script type="text/javascript" src="/js/ext/ext-all.js"></script> <script type="text/javascript" src="/js/msg.js"></script> <script type="text/javascript" src="/js/jquery/1.6.4/jquery.min.js"></script> <script type="text/javascript" src="/js/store.js"></script> <script type="text/javascript" src="/js/edittablestructure.js"></script> <script type="text/javascript" src="/js/cartomobilesetup.js"></script> <script type="text/javascript" src="/js/editwmsclass.js"></script> <script type="text/javascript" src="/js/editwmslayer.js"></script> <script type="text/javascript" src="/js/addshapeform.js"></script> <script type="text/javascript" src="/js/addmapinfoform.js"></script>
/** * * * @return unknown */ public function loadInDb() { $this->connect("PDO"); $table = new table($this->safeFile); if ($this->pdo) { $cmd = "shp2pgsql -W 'WINDOWS-1252' -I -c -s {$this->srid} {$this->file}.shp {$this->safeFile}"; $result = exec($cmd, $output); $sql_total = implode("", $output); // Create block begin $this->begin(); if ($table->exits) { $table->destroy(); } $this->execQuery($sql_total, "PDO", "transaction"); //Create block end if (!$this->PDOerror) { $this->commit(); if (!$table->exits) { // no need to re-init table object if table exits $table = new table($this->safeFile); } else { $overWriteTxt = " An exiting layer was overwriten"; } //$table->point2multipoint(); $response['success'] = true; $response['message'] = "Your shape file was uploaded and processed. You can find new layer i your geocloud." . $overWriteTxt; } else { $response['success'] = false; $response['message'] = $this->PDOerror; $this->rollback(); } } else { // The psql way // Create block begin $this->begin(); if ($table->exits) { $table->destroy(); } $cmd = "shp2pgsql -W 'WINDOWS-1252' -I -D -c -s {$this->srid} {$this->file}.shp {$this->safeFile}|psql {$this->postgisdb} postgres"; $result = exec($cmd); if ($result == "COMMIT") { if (!$table->exits) { // no need to re-init table object if table exits $table = new table($this->safeFile); } else { $overWriteTxt = " An exiting layer was overwriten"; } //$table->point2multipoint(); $this->commit(); // rename column 'state' if such exits $this->connect("PDO"); // Must re-connect after commit $this->begin(); $sql = "ALTER TABLE {$this->safeFile} RENAME state to _state"; $this->execQuery($sql); $this->commit(); $response['success'] = true; $response['message'] = "Your shape file was uploaded and processed. You can find new layer i your geocloud." . $overWriteTxt; } else { $this->rollback(); $response['success'] = false; $response['message'] = "Something went wrong!"; } $table = new table('settings.geometry_columns_join'); $obj = json_decode('{"data":{"f_table_name":"' . $this->safeFile . '","f_table_title":""}}'); $response2 = $table->updateRecord($obj->data, 'f_table_name'); // If layer is new (inserted) then insert a new class for it if ($response2['operation'] == "inserted") { $class = new _class(); $class->insert($this->safeFile, array(), "_"); } makeMapFile($_SESSION['screen_name']); $response['cmd'] = $cmd; } return $response; }