diff --git a/application/default/controllers/VisualController.php b/application/default/controllers/VisualController.php index eea08e08..49fd4624 100644 --- a/application/default/controllers/VisualController.php +++ b/application/default/controllers/VisualController.php @@ -1,117 +1,115 @@ -view->config = Zend_Registry::get('config'); - $this->db=Zend_Registry::get('db'); - $this->view->nav = array( - array('link'=>'/','title'=>''), - array('link'=>'/data','title'=>$this->view->config->title->data), - ); - - $auth = Zend_Auth::getInstance(); - if($auth->hasIdentity()) - { - $user = $auth->getIdentity(); - $this->uid = $user->id; - }else{ - $this->_redirect('/account/login?href=/visual'); - } - } - - function indexAction() - { - $record_type = $this->_getParam("dataset"); - - if(empty($record_type)) - return true; - - $sc = Factory::Bootstrap($record_type); - } - - - //******************************************************** - - /* - * dataAction() ajax获取数据 - * - * param string $ac //请求的数据类型 - * param string $dt //请求的数据来源(气象,水文) - * - * return view - */ - function dataAction() - { - $this->_helper->viewRenderer->setNoRender(); - $this->_helper->layout->disableLayout(); - - $uuid = $this->_getParam("uuid"); - $record_type = $this->_getParam("dataset"); - $record_subset = $this->_getParam("subdataset"); - - if(empty($record_type)) - return true; - - $record = new Visual\Record($uuid,$record_subset); - //$record = Visual\Factory::Bootstrap($record_type); - - if(!empty($record_subset)) - { - $record->subset = $record_subset; - } - - $data = $record(); - - $this->jsonexit($data); - return true; - - }//dataAction() Ajax获取数据 - - //viewAction - public function viewAction() - { - $uuid = $this->_getParam('uuid'); - - if(empty($uuid) || \Helpers\Uuid::test($uuid) == false) - { - view::Post($this,"参数错误",-1); - return; - } - - $visual = new Visual\Visual; - - $this->view->data = $visual->getVisualVars($uuid); - - if(empty($this->view->data)) - { - view::Post($this,"此数据不支持可视化",-1); - return; - } - - $metadata = new Metadata\Metadata; - - $this->view->info = $metadata->view($uuid); - - - } - - - /* - * jsonexit() 退出并返回json数据 - * - * param array $data 要返回的JSON数据,可以是任意数组 - * - * return application/JSON - */ - public function jsonexit($data){ - $this->getResponse()->setHeader('Content-Type', 'application/json')->appendBody(json_encode($data,JSON_NUMERIC_CHECK)); - return true; - }//jsonexit() 退出并返回json数据 - +view->config = Zend_Registry::get('config'); + $this->db=Zend_Registry::get('db'); + $this->view->nav = array( + array('link'=>'/','title'=>''), + array('link'=>'/data','title'=>$this->view->config->title->data), + ); + + if(view::User() === false) + { + view::Post($this,"请先登陆",'/account/login?href='.urlencode($_SERVER['REQUEST_URI'])); + } + + $this->uid = view::User('id'); + } + + function indexAction() + { + $record_type = $this->_getParam("dataset"); + + if(empty($record_type)) + return true; + + $sc = Factory::Bootstrap($record_type); + } + + + //******************************************************** + + /* + * dataAction() ajax获取数据 + * + * param string $ac //请求的数据类型 + * param string $dt //请求的数据来源(气象,水文) + * + * return view + */ + function dataAction() + { + $this->_helper->viewRenderer->setNoRender(); + $this->_helper->layout->disableLayout(); + + $uuid = $this->_getParam("uuid"); + $record_type = $this->_getParam("dataset"); + $record_subset = $this->_getParam("subdataset"); + + if(empty($record_type)) + return true; + + $record = new Visual\Record($uuid,$record_subset); + //$record = Visual\Factory::Bootstrap($record_type); + + if(!empty($record_subset)) + { + $record->subset = $record_subset; + } + + $data = $record(); + + $this->jsonexit($data); + return true; + + }//dataAction() Ajax获取数据 + + //viewAction + public function viewAction() + { + $uuid = $this->_getParam('uuid'); + + if(empty($uuid) || \Helpers\Uuid::test($uuid) == false) + { + view::Post($this,"参数错误",-1); + return; + } + + $visual = new Visual\Visual; + + $this->view->data = $visual->getVisualVars($uuid); + + if(empty($this->view->data)) + { + view::Post($this,"此数据不支持可视化",-1); + return; + } + + $metadata = new Metadata\Metadata; + + $this->view->info = $metadata->view($uuid); + + + } + + + /* + * jsonexit() 退出并返回json数据 + * + * param array $data 要返回的JSON数据,可以是任意数组 + * + * return application/JSON + */ + public function jsonexit($data){ + $this->getResponse()->setHeader('Content-Type', 'application/json')->appendBody(json_encode($data,JSON_NUMERIC_CHECK)); + return true; + }//jsonexit() 退出并返回json数据 + } \ No newline at end of file diff --git a/application/default/views/scripts/data/index.phtml b/application/default/views/scripts/data/index.phtml index 471b1c8f..0822f124 100755 --- a/application/default/views/scripts/data/index.phtml +++ b/application/default/views/scripts/data/index.phtml @@ -60,7 +60,7 @@