2014-05-12 02:56:55 +00:00
|
|
|
|
<?php
|
2014-06-11 08:38:38 +00:00
|
|
|
|
use Westdc\Visual;
|
|
|
|
|
use Westdc\Metadata;
|
|
|
|
|
use Helpers\View as view;
|
2014-05-12 02:56:55 +00:00
|
|
|
|
|
|
|
|
|
class VisualController extends Zend_Controller_Action
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
function preDispatch()
|
|
|
|
|
{
|
|
|
|
|
$this->view->config = Zend_Registry::get('config');
|
|
|
|
|
$this->db=Zend_Registry::get('db');
|
2014-06-17 08:49:10 +00:00
|
|
|
|
$this->view->nav = array(
|
|
|
|
|
array('link'=>'/','title'=>'<i class="icon-home"></i>'),
|
|
|
|
|
array('link'=>'/data','title'=>$this->view->config->title->data),
|
|
|
|
|
);
|
2014-05-12 06:53:21 +00:00
|
|
|
|
|
2014-05-12 02:56:55 +00:00
|
|
|
|
$auth = Zend_Auth::getInstance();
|
|
|
|
|
if($auth->hasIdentity())
|
|
|
|
|
{
|
|
|
|
|
$user = $auth->getIdentity();
|
|
|
|
|
$this->uid = $user->id;
|
|
|
|
|
}else{
|
2014-05-12 06:53:21 +00:00
|
|
|
|
$this->_redirect('/account/login?href=/visual');
|
2014-05-12 02:56:55 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function indexAction()
|
|
|
|
|
{
|
2014-05-21 09:26:15 +00:00
|
|
|
|
$record_type = $this->_getParam("dataset");
|
|
|
|
|
|
|
|
|
|
if(empty($record_type))
|
|
|
|
|
return true;
|
|
|
|
|
|
2014-06-11 08:38:38 +00:00
|
|
|
|
$sc = Factory::Bootstrap($record_type);
|
2014-05-12 02:56:55 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//********************************************************
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* dataAction() ajax获取数据
|
|
|
|
|
*
|
|
|
|
|
* param string $ac //请求的数据类型
|
|
|
|
|
* param string $dt //请求的数据来源(气象,水文)
|
|
|
|
|
*
|
|
|
|
|
* return view
|
|
|
|
|
*/
|
|
|
|
|
function dataAction()
|
|
|
|
|
{
|
|
|
|
|
$this->_helper->viewRenderer->setNoRender();
|
2014-05-21 09:26:15 +00:00
|
|
|
|
$this->_helper->layout->disableLayout();
|
2014-05-12 02:56:55 +00:00
|
|
|
|
|
2014-06-11 08:38:38 +00:00
|
|
|
|
$uuid = $this->_getParam("uuid");
|
2014-05-21 09:26:15 +00:00
|
|
|
|
$record_type = $this->_getParam("dataset");
|
|
|
|
|
$record_subset = $this->_getParam("subdataset");
|
2014-05-12 02:56:55 +00:00
|
|
|
|
|
2014-05-21 09:26:15 +00:00
|
|
|
|
if(empty($record_type))
|
2014-05-12 02:56:55 +00:00
|
|
|
|
return true;
|
|
|
|
|
|
2014-06-11 08:38:38 +00:00
|
|
|
|
$record = new Visual\Record($uuid,$record_subset);
|
|
|
|
|
//$record = Visual\Factory::Bootstrap($record_type);
|
2014-05-12 02:56:55 +00:00
|
|
|
|
|
2014-05-21 09:26:15 +00:00
|
|
|
|
if(!empty($record_subset))
|
2014-05-12 02:56:55 +00:00
|
|
|
|
{
|
2014-05-21 09:26:15 +00:00
|
|
|
|
$record->subset = $record_subset;
|
2014-05-12 02:56:55 +00:00
|
|
|
|
}
|
2014-06-11 08:38:38 +00:00
|
|
|
|
|
|
|
|
|
$data = $record();
|
2014-05-12 02:56:55 +00:00
|
|
|
|
|
|
|
|
|
$this->jsonexit($data);
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
}//dataAction() Ajax获取数据
|
|
|
|
|
|
2014-06-11 08:38:38 +00:00
|
|
|
|
//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);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-12 02:56:55 +00:00
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* 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数据
|
|
|
|
|
|
2014-05-21 09:26:15 +00:00
|
|
|
|
}
|