From bf150590b0a58cf3a746fcd98ab0a444e840ddcc Mon Sep 17 00:00:00 2001 From: Li Jianxuan Date: Wed, 11 Feb 2015 09:05:38 +0000 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E5=9C=B0=E5=9B=BE=E5=8F=AF?= =?UTF-8?q?=E8=A7=86=E5=8C=96=E7=BC=96=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/controllers/DataController.php | 2 +- .../admin/views/scripts/data/map-add.phtml | 3 +- application/module/Westdc/Visual/Map.php | 52 +++++++++++++++++-- 3 files changed, 51 insertions(+), 6 deletions(-) diff --git a/application/admin/controllers/DataController.php b/application/admin/controllers/DataController.php index e1a46ef0..987b31f5 100755 --- a/application/admin/controllers/DataController.php +++ b/application/admin/controllers/DataController.php @@ -4170,7 +4170,7 @@ class Admin_DataController extends Zend_Controller_Action $data = [ 'uuid' => $uuid, 'status' => $this->_getParam('status'), - 'layers' => $this->_getParam('status'), + 'layers' => $this->_getParam('layers'), 'zoom_min' => $this->_getParam('zoom_min'), 'zoom_max' => $this->_getParam('zoom_max'), 'zoom_default' => $this->_getParam('zoom_default'), diff --git a/application/admin/views/scripts/data/map-add.phtml b/application/admin/views/scripts/data/map-add.phtml index a7c9061f..7412fe9e 100644 --- a/application/admin/views/scripts/data/map-add.phtml +++ b/application/admin/views/scripts/data/map-add.phtml @@ -116,7 +116,6 @@ info['layers'])) { ?> - info['layers']) ?> decode($this->info['layers']);?> @@ -128,7 +127,7 @@
- +
diff --git a/application/module/Westdc/Visual/Map.php b/application/module/Westdc/Visual/Map.php index 3a1dcdcb..50287924 100644 --- a/application/module/Westdc/Visual/Map.php +++ b/application/module/Westdc/Visual/Map.php @@ -32,6 +32,10 @@ class Map { } } + /** + * 查询所有地图可视化 + * @return mixed + */ public function fetchAll() { $sql = "SELECT * FROM {$this->metadataTable} md @@ -43,6 +47,11 @@ class Map { return $rs->fetchAll(\PDO::FETCH_ASSOC); } + /** + * 获得某一条可视化信息 + * @param $uuid + * @return mixed + */ public function fetch($uuid) { $sql = "SELECT * FROM {$this->mainTable} WHERE uuid='$uuid'"; @@ -51,39 +60,76 @@ class Map { return $rs->fetch(\PDO::FETCH_ASSOC); } + /** + * 删除一条 + * @param $id + * @return mixed + */ public function delete($id) { $sql = "DELETE FROM {$this->mainTable} WHERE id=$id"; return $this->db->exec($sql); } + /** + * 添加一条 + * @param $data + * @return bool + */ public function add($data){ $dbh = new dbh(); - if($this->checkExists($data['uuid']) === true) + if($this->checkExists($data['uuid']) === false) return $dbh->insert($this->mainTable,$data); - return $dbh->update($this->mainTable,$data," uuid={$data['uuid']} "); + return $dbh->update($this->mainTable,$data," uuid='{$data['uuid']}' "); } + /** + * 处理表单中接收的数据 + * @param $data + * @return mixed + */ public function processParam($data){ if(is_array($data['layers']) && count($data['layers'])){ + foreach($data['layers'] as $index=>$value){ if(!is_array($value) || count($value) < 1) { unset($data['layers']['index']); continue; } + + if(empty(array_filter($value['extent']))) + unset($value['extent']); + + if(empty(array_filter($value))){ + unset($data['layers'][$index]); + continue; + } } - $data['layers'] = json_encode($data['layers'],JSON_NUMERIC_CHECK); + $data['layers'] = json_encode($data['layers'],JSON_UNESCAPED_UNICODE); + }else{ + $data['layers'] = json_encode([]); } + $data['zoom_min'] = (int)$data['zoom_min'] + 0; + $data['zoom_max'] = (int)$data['zoom_max'] + 0; + $data['zoom_default'] = (int)$data['zoom_default'] + 0; + $data['center_lon'] = (float)$data['center_lon']; + $data['center_lon'] = (float)$data['center_lon']; + return $data; } + /** + * 检查某条信息是否存在 + * @param $uuid + * @return bool + */ public function checkExists($uuid){ $row = $this->fetch($uuid);