diff --git a/application/admin/controllers/DataController.php b/application/admin/controllers/DataController.php index 3a9bf35b..e1a46ef0 100755 --- a/application/admin/controllers/DataController.php +++ b/application/admin/controllers/DataController.php @@ -4145,6 +4145,64 @@ class Admin_DataController extends Zend_Controller_Action return; } + /** + * 地图可视化 + */ + public function mapAction() + { + $uuid = $this->_getParam('uuid'); + + if(empty($uuid)) + { + $map = new Visual\Map; + view::addPaginator($map->fetchAll(),$this,10); + return true; + } + + if(!empty($uuid)) + { + $submit = $this->_getParam('submit'); + + $map = new Visual\Map; + + if(!empty($submit)) + { + $data = [ + 'uuid' => $uuid, + 'status' => $this->_getParam('status'), + 'layers' => $this->_getParam('status'), + 'zoom_min' => $this->_getParam('zoom_min'), + 'zoom_max' => $this->_getParam('zoom_max'), + 'zoom_default' => $this->_getParam('zoom_default'), + 'center_lon' => $this->_getParam('center_lon'), + 'center_lat' => $this->_getParam('center_lat'), + ]; + + $data = $map->processParam($data); + $status = $map->add($data); + + if($status === true) + return view::Post($this,"添加成功!",-1); + + $this->view->error = "添加失败"; + + if(is_string($status)) + $this->view->error = $status; + + $this->view->info = $data; + } + + $this->_helper->viewRenderer('map-add'); + $this->view->info = $map->fetch($uuid); + + if(!isset($this->view->info['uuid'])) + $this->view->info['uuid'] = $uuid; + + return true; + } + + }//mapAction() + /** * 數據導入 */ @@ -4330,15 +4388,6 @@ class Admin_DataController extends Zend_Controller_Action return true; }//dataimportAction() - - /** - * 地图可视化 - */ - public function mapAction() - { - $map = new Visual\Map; - view::addPaginator($map->fetchAll(),$this,10); - }//mapAction() public function doiAction() { diff --git a/application/admin/views/scripts/data/map-add.phtml b/application/admin/views/scripts/data/map-add.phtml new file mode 100644 index 00000000..a7c9061f --- /dev/null +++ b/application/admin/views/scripts/data/map-add.phtml @@ -0,0 +1,274 @@ +headTitle($this->config->title->site); + $this->headTitle('后台管理'); + $this->headTitle()->setSeparator(' - '); + $this->breadcrumb('首页'); + $this->breadcrumb('后台首页'); + $this->breadcrumb('数据管理'); + $this->breadcrumb()->setSeparator(' > '); +?> +
+
+ partial('data/left.phtml'); ?> +
+ +
+

地图可视化要素编辑

+
+ error)) {?> +
+ error ?> +
+ + +
+ +
+ +
+ +
+
+ +
+ +
+ + +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ + info['layers'])) { ?> + info['layers']) ?> + + + decode($this->info['layers']);?> + $value) { ?> +
+ +
+ + +
+
+ +
+
+ + + + +
+
+ + + + +
+
+ +
+
+ + +
+
+ + +
+
+ +
+ +
+
+ + diff --git a/application/admin/views/scripts/data/map.phtml b/application/admin/views/scripts/data/map.phtml index 96b91fb5..33862b20 100644 --- a/application/admin/views/scripts/data/map.phtml +++ b/application/admin/views/scripts/data/map.phtml @@ -31,7 +31,7 @@

操作: - 编辑可视化要素 | + 编辑可视化要素 | 前台预览

diff --git a/application/admin/views/scripts/data/md.phtml b/application/admin/views/scripts/data/md.phtml index ba10b860..50b78164 100644 --- a/application/admin/views/scripts/data/md.phtml +++ b/application/admin/views/scripts/data/md.phtml @@ -77,6 +77,7 @@ 邮件通知 | 数据可视化 | + 地图可视化 | DOI注册

diff --git a/application/module/Westdc/Visual/Map.php b/application/module/Westdc/Visual/Map.php index 29ca1edc..3a1dcdcb 100644 --- a/application/module/Westdc/Visual/Map.php +++ b/application/module/Westdc/Visual/Map.php @@ -8,6 +8,8 @@ namespace Westdc\Visual; +use Helpers\dbh; + class Map { private $db; @@ -41,12 +43,54 @@ class Map { return $rs->fetchAll(\PDO::FETCH_ASSOC); } + public function fetch($uuid) + { + $sql = "SELECT * FROM {$this->mainTable} WHERE uuid='$uuid'"; + + $rs = $this->db->query($sql); + return $rs->fetch(\PDO::FETCH_ASSOC); + } + public function delete($id) { $sql = "DELETE FROM {$this->mainTable} WHERE id=$id"; return $this->db->exec($sql); } + public function add($data){ + $dbh = new dbh(); + + if($this->checkExists($data['uuid']) === true) + return $dbh->insert($this->mainTable,$data); + + return $dbh->update($this->mainTable,$data," uuid={$data['uuid']} "); + + } + + 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; + } + } + + $data['layers'] = json_encode($data['layers'],JSON_NUMERIC_CHECK); + } + + return $data; + } + + public function checkExists($uuid){ + $row = $this->fetch($uuid); + + if(!isset($row['id']) || empty($row['id'])) + return false; + + return true; + } } \ No newline at end of file