diff --git a/application/default/controllers/AuthorController.php b/application/default/controllers/AuthorController.php index 2f98b510..5f298323 100644 --- a/application/default/controllers/AuthorController.php +++ b/application/default/controllers/AuthorController.php @@ -3496,13 +3496,82 @@ class AuthorController extends Zend_Controller_Action } $ac = $this->_getParam('ac'); - - if(empty($ac) || $ac=="index") + + if(empty($ac)) { + include_once("MetaData.php"); $md = new Metadata($this->db); $this->view->Field = $md->MetadataFields; + + $MDList = $md->getRecord($uid); + + if(!empty($MDList)) + { + foreach($MDList as $k=>$v) + { + $MDList[$k]['content'] = json_decode($v['content']); + } + $this->view->MDList = $MDList; + } + } + + if($ac=="new") + { + $this->_helper->viewRenderer('metadata-new'); + + include_once("MetaData.php"); + $md = new Metadata($this->db); + $this->view->Field = $md->MetadataFields; + + $uuid = $this->_getParam('uuid'); + + if(!empty($uuid) && !preg_match("/^[0-9A-Za-z]{8}-[0-9A-Za-z]{4}-[0-9A-Za-z]{4}-[0-9A-Za-z]{4}-[0-9A-Za-z]{12}$/",$uuid)) + { + $this->view->error = "参数错误"; + return true; + } + + else{ + $this->view->uuid = $uuid; + $datas = $md->getRecord($uid,$uuid); + $data = json_decode($datas['content']); + $this->view->data = $data; + return true; + } + }//创建元数据页面 + + if($ac == "del") + { + $this->_helper->layout->disableLayout(); + $this->_helper->viewRenderer->setNoRender(); + + $uuid = $this->_getParam('uuid'); + + if(!preg_match("/^[0-9A-Za-z]{8}-[0-9A-Za-z]{4}-[0-9A-Za-z]{4}-[0-9A-Za-z]{4}-[0-9A-Za-z]{12}$/",$uuid)) + { + $this->jsonexit(array('error'=>"参数错误")); + return true; + } + + $sql = "DELETE FROM metadata_temp WHERE userid=? AND uuid=?"; + + $sth = $this->db->prepare($sql); + $rs = $sth->execute(array($uid,$uuid)); + + if($rs>0) + { + $this->jsonexit(array('msg'=>"删除成功",'deleted'=>1)); + return true; + }else{ + $this->jsonexit(array('error'=>"删除失败,请刷新页面后查看")); + return true; + } + + return true; + + }//删除 if($ac == "save") { @@ -3513,13 +3582,77 @@ class AuthorController extends Zend_Controller_Action $md = new Metadata($this->db); $uuid = $this->_getParam('uuid'); + $commit = $this->_getParam('commit'); $data = array(); foreach($md->MetadataFields as $k=>$v) { $data[$v['FieldName_temp']] = $this->_getParam($v['FieldName']); - } + + if(!empty($commit)) + { + if(isset($v['Required']) && $v['Required'] == true) + { + if($v['Type'] == 'varchar') + { + if(empty($data[$v['FieldName_temp']])) + { + $this->jsonexit(array("error"=>$v['Title']." 必须填写")); + return true; + } + } // 文本数据 + + if($v['Type'] == 'array') + { + if(!is_array($data[$v['FieldName_temp']]) || count($data[$v['FieldName_temp']]) < 1 ) + { + $this->jsonexit(array("error"=>$v['Title']." 信息不完整")); + return true; + }//数组没有值 + + foreach($data[$v['FieldName_temp']] as $sk=>$sv) + { + if(empty($sv)) + { + unset($data[$v['FieldName_temp']][$sk]); + } + + if(is_array($sv)) + { + $error_cu = 0; + foreach($sv as $sub_val) + { + if(empty($sub_val)) + { + $error_cu ++ ; + } + } + + if($error_cu >= count($sv)) + { + unset($data[$v['FieldName_temp']][$sk]); + $error_cu = 0; + } + + if($error_cu > 0 && $error_cu < count($sv)){ + $this->jsonexit(array("error"=>$v['Title']." 信息不完整")); + return true; + } + } + } + + if(count($data[$v['FieldName_temp']]) < 1) + { + $this->jsonexit(array("error"=>$v['Title']." 必须填写")); + return true; + } + + } // 数组数据 + + } // 是否必填 + }// empty($commit) + }// end foreach if(empty($data['title'])) { @@ -3527,11 +3660,18 @@ class AuthorController extends Zend_Controller_Action return true; } + if(!empty($commit)) + { + $status = 1; + }else{ + $status = 0; + } + if(!empty($uuid)) { - $rs = $md->Record($uid,$data,$uuid); + $rs = $md->Record($uid,$data,$status,$uuid); }else{ - $rs = $md->Record($uid,$data); + $rs = $md->Record($uid,$data,$status); } if($rs !== false) @@ -3542,7 +3682,7 @@ class AuthorController extends Zend_Controller_Action $this->jsonexit(array("error"=>'保存失败')); return false; } - } + }// 新元数据保存 if($ac == "process") { @@ -3564,7 +3704,7 @@ class AuthorController extends Zend_Controller_Action echo ""; return true; - } + }// 元数据处理 }//metadata() diff --git a/application/default/views/scripts/author/metadata-new.phtml b/application/default/views/scripts/author/metadata-new.phtml new file mode 100644 index 00000000..a51dc9be --- /dev/null +++ b/application/default/views/scripts/author/metadata-new.phtml @@ -0,0 +1,451 @@ +headTitle($this->config->title->site); +$this->headTitle($this->config->title->author); +$this->headTitle()->setSeparator(' - '); +$this->theme->AppendPlus($this,'jquery'); +$this->theme->AppendPlus($this,'jquery_ui'); +$this->theme->AppendPlus($this,'google_map_v3'); +$this->theme->AppendPlus($this,'google_map_keydragzone'); +$this->theme->AppendPlus($this,'colorbox'); +$this->headLink()->appendStylesheet('/css/author.css'); +$this->headLink()->appendStylesheet('/css/author-metadata.css'); +$this->breadcrumb('首页'); +$this->breadcrumb(''.$this->config->title->author.''); +$this->breadcrumb('新建数据'); +$this->breadcrumb()->setSeparator(' > '); +?> + + + + + +
+
+ +
+
+ error)) { ?> + uuid)) { + $F = array(); + }?> +
+ + uuid ?>" /> +
+

元数据基本信息

+
+ +
+ Field['title']['FieldName_temp']; ?> + data->$F['title'] ?>" /> +
+
+
+ +
+ Field['title_en']['FieldName_temp']; ?> + data->$F['title_en'] ?>" /> +
+
+
+ +
+ Field['description']['FieldName_temp']; ?> + + 概括元数据内容 +
+
+ uuid)) { ?> +
+
+ +
+
+ +
+ +
uuid) ? 'style="display:none;"':"" ?>> +
+

时间范围

+
+ +
+ Field['timebegin']['FieldName_temp']; ?> + data->$F['timebegin'] ?>" /> +
+
+
+ +
+ Field['timeend']['FieldName_temp']; ?> + data->$F['timeend'] ?>" /> +
+
+
+ +
+

空间范围

+
+
+ +
+ Field['east']['FieldName_temp']; ?> + data->$F['east'] ?>" /> +
+
+
+ +
+ Field['south']['FieldName_temp']; ?> + data->$F['south'] ?>" /> +
+
+
+ +
+ Field['west']['FieldName_temp']; ?> + data->$F['west'] ?>" /> +
+
+
+ +
+ Field['north']['FieldName_temp']; ?> + data->$F['north'] ?>" /> +
+
+
+ 按住键盘上“Shift”键可以直接在地图上用鼠标拖动选取 +
+
+
+ +
+
+ +
+

数据引用方式

+
+
+ Field['citation']['FieldName_temp']; ?> + data->$F['citation'] ?>" /> +
+
+
+ +
+

参考文献

+
+
+ Field['reference']['FieldName_temp']; ?> + data->$F['reference'])>0) + { + foreach($this->data->$F['reference'] as $k=>$v) + {?> + + +
+
+ +
+ +
+

联系人

+ Field['contact']['FieldName_temp']; ?> + data->$F['reference']) && count($this->data->$F['reference'])>0) + { + $index = 0; + foreach($this->data->$F['contact'] as $k=>$v) + { + $index++ ;?> +
+
+ + + +
+
+ +
+
+ + + +
+
+ + +
+ +
+
+ + +
+
+ +
+ +
+ + error;?> + +
+
+ + \ No newline at end of file diff --git a/application/default/views/scripts/author/metadata.phtml b/application/default/views/scripts/author/metadata.phtml index 34bddc97..3b3d03b7 100644 --- a/application/default/views/scripts/author/metadata.phtml +++ b/application/default/views/scripts/author/metadata.phtml @@ -33,343 +33,49 @@ $this->breadcrumb()->setSeparator(' > ');
  • 新建元数据
  • -
    - -
    - - -
    -

    元数据基本信息

    -
    - -
    - -
    -
    -
    - -
    - -
    -
    -
    - -
    - - 概括元数据内容 -
    -
    -
    -
    - -
    -
    -
    - -
    -
    -

    时间范围

    -
    - -
    - -
    -
    -
    - -
    - -
    -
    -
    - -
    -

    空间范围

    -
    -
    - -
    - -
    -
    -
    - -
    - -
    -
    -
    - -
    - -
    -
    -
    - -
    - -
    -
    -
    - 按住键盘上“Shift”键可以直接在地图上用鼠标拖动选取 -
    -
    -
    - -
    -
    - -
    -

    数据引用方式

    -
    -
    - -
    -
    -
    - -
    -

    参考文献

    -
    -
    - -
    -
    - -
    - -
    -

    联系人

    -
    -
    - - - -
    -
    - -
    - -
    -
    - - -
    -
    - -
    - -
    +
    +