From 123a76c464435edf0c0659c6d79ef50576ee2103 Mon Sep 17 00:00:00 2001 From: Li Jianxuan Date: Tue, 4 Mar 2014 09:10:59 +0000 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=8C=89=E5=8D=95=E4=BD=8D?= =?UTF-8?q?=E6=B5=8F=E8=A7=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- module/Metadata/config/module.config.php | 24 +- .../Metadata/Controller/IndexController.php | 261 ++++++++++-------- .../Metadata/view/metadata/index/index.phtml | 1 + vendor/Westdc/Metadata/Extra/Unit.php | 55 ++++ 4 files changed, 218 insertions(+), 123 deletions(-) create mode 100644 vendor/Westdc/Metadata/Extra/Unit.php diff --git a/module/Metadata/config/module.config.php b/module/Metadata/config/module.config.php index 483814fe..3987686f 100644 --- a/module/Metadata/config/module.config.php +++ b/module/Metadata/config/module.config.php @@ -148,7 +148,29 @@ return array( 'type' => 'Wildcard' ) ) - ),//online + ),//offlinelist + + 'unit' => array( + 'type' => 'Segment', + 'options' => array( + 'route' => '/unit[/page/:page]', + 'constraints' => array( + 'page' => "[a-zA-Z0-9][a-zA-Z0-9_-]*", + ), + 'defaults' => array( + 'module' => 'Metadata', + '__NAMESPACE__' => 'Metadata\Controller', + 'controller' => 'Metadata\Controller\Index', + 'action' => 'unit', + ), + ), + 'may_terminate' => true, + 'child_routes' => array( + 'wildcard' => array( + 'type' => 'Wildcard' + ) + ) + ),//offlinelist ),//data diff --git a/module/Metadata/src/Metadata/Controller/IndexController.php b/module/Metadata/src/Metadata/Controller/IndexController.php index 31b3aafc..c549734a 100644 --- a/module/Metadata/src/Metadata/Controller/IndexController.php +++ b/module/Metadata/src/Metadata/Controller/IndexController.php @@ -1,122 +1,139 @@ -ViewModel = new ViewModel(); - } - - public function indexAction() - { - $metadata = new \Westdc\Metadata\Outlink; - $metadata->opt->limit = 10; - $this->ViewModel->setVariable('metadata_latest',$metadata->fetchAll()); - unset($metadata); - - $mdtags = new \Westdc\Metadata\Tags; - $keywords = array( - 'place' => $mdtags->getTagsByKeywordType('place'), - 'theme' => $mdtags->getTagsByKeywordType('theme'), - 'discipline' => $mdtags->getTagsByKeywordType('discipline'), - 'stratum' => $mdtags->getTagsByKeywordType('stratum'), - 'temporal' => $mdtags->getTagsByKeywordType('temporal') - ); - $this->ViewModel->setVariable('keywords',$keywords); - unset($mdtags); - - return $this->ViewModel; - } - - public function viewAction() - { - $uuid = $this->params()->fromRoute('uuid'); - - if(!\Sookon\Helpers\Uuid::test($uuid)) - view::Post($this,"参数错误",-1); - - $metadata = new \Westdc\Metadata\Outlink; - $tags = new \Westdc\Metadata\Tags; - - $md = $metadata->fetch($uuid); - - $this->ViewModel->setVariable('data',$md); - $this->ViewModel->setVariable('keys',$tags->getMetadataTags($md['id'])); - - return $this->ViewModel; - } - - public function tagAction() - { - $tag = $this->params()->fromRoute('tag'); - - if(preg_match("/\'/",$tag)) - view::Post($this,"参数错误",-1); - - if(empty($tag)) - { - $tags = new \Westdc\Metadata\Tags; - $this->ViewModel->setVariable('keywords',$tags->getAllTagsAndCount()); - return $this->ViewModel; - } - - if(!empty($tag)) - { - $this->ViewModel->setVariable('codename',$tag); - $this->ViewModel->setTemplate("layout/metadata/tag/list"); - $tags = new \Westdc\Metadata\Tags; - view::addPaginator($tags->getMetadataByTag($tag),$this,10,'layout/metadata/tag/pagination'); - return $this->ViewModel; - } - - return $this->ViewModel; - } - - public function listAction() - { - $this->ViewModel->setTemplate("layout/metadata/datalist"); - - $metadata = new \Westdc\Metadata\Metadata; - - view::addPaginator($metadata->fetchAll(),$this,10,'layout/metadata/pagination/browse'); - - return $this->ViewModel; - } - - public function onlinelistAction() - { - $this->ViewModel->setTemplate("layout/metadata/datalist"); - - $metadata = new \Westdc\Metadata\Metadata; - $metadata->opt->where = array(' m.datatype=0 '); - view::addPaginator($metadata->fetchAll(),$this,10,'layout/metadata/pagination/onlinelist'); - - return $this->ViewModel; - } - - public function offlinelistAction() - { - $this->ViewModel->setTemplate("layout/metadata/datalist"); - - $metadata = new \Westdc\Metadata\Metadata; - $metadata->opt->where = array(' m.datatype=1 '); - view::addPaginator($metadata->fetchAll(),$this,10,'layout/metadata/pagination/offlinelist'); - - return $this->ViewModel; - } -} +ViewModel = new ViewModel(); + } + + public function indexAction() + { + $metadata = new \Westdc\Metadata\Outlink; + $metadata->opt->limit = 10; + $this->ViewModel->setVariable('metadata_latest',$metadata->fetchAll()); + unset($metadata); + + $mdtags = new \Westdc\Metadata\Tags; + $keywords = array( + 'place' => $mdtags->getTagsByKeywordType('place'), + 'theme' => $mdtags->getTagsByKeywordType('theme'), + 'discipline' => $mdtags->getTagsByKeywordType('discipline'), + 'stratum' => $mdtags->getTagsByKeywordType('stratum'), + 'temporal' => $mdtags->getTagsByKeywordType('temporal') + ); + $this->ViewModel->setVariable('keywords',$keywords); + unset($mdtags); + + return $this->ViewModel; + } + + public function viewAction() + { + $uuid = $this->params()->fromRoute('uuid'); + + if(!\Sookon\Helpers\Uuid::test($uuid)) + view::Post($this,"参数错误",-1); + + $metadata = new \Westdc\Metadata\Outlink; + $tags = new \Westdc\Metadata\Tags; + + $md = $metadata->fetch($uuid); + + $this->ViewModel->setVariable('data',$md); + $this->ViewModel->setVariable('keys',$tags->getMetadataTags($md['id'])); + + return $this->ViewModel; + } + + public function tagAction() + { + $tag = $this->params()->fromRoute('tag'); + + if(preg_match("/\'/",$tag)) + view::Post($this,"参数错误",-1); + + if(empty($tag)) + { + $tags = new \Westdc\Metadata\Tags; + $this->ViewModel->setVariable('keywords',$tags->getAllTagsAndCount()); + return $this->ViewModel; + } + + if(!empty($tag)) + { + $this->ViewModel->setVariable('codename',$tag); + $this->ViewModel->setTemplate("layout/metadata/tag/list"); + $tags = new \Westdc\Metadata\Tags; + view::addPaginator($tags->getMetadataByTag($tag),$this,10,'layout/metadata/tag/pagination'); + return $this->ViewModel; + } + + return $this->ViewModel; + } + + public function listAction() + { + $this->ViewModel->setTemplate("layout/metadata/datalist"); + + $metadata = new \Westdc\Metadata\Metadata; + + view::addPaginator($metadata->fetchAll(),$this,10,'layout/metadata/pagination/browse'); + + return $this->ViewModel; + } + + public function onlinelistAction() + { + $this->ViewModel->setTemplate("layout/metadata/datalist"); + + $metadata = new \Westdc\Metadata\Metadata; + $metadata->opt->where = array(' m.datatype=0 '); + view::addPaginator($metadata->fetchAll(),$this,10,'layout/metadata/pagination/onlinelist'); + + return $this->ViewModel; + } + + public function offlinelistAction() + { + $this->ViewModel->setTemplate("layout/metadata/datalist"); + + $metadata = new \Westdc\Metadata\Metadata; + $metadata->opt->where = array(' m.datatype=1 '); + view::addPaginator($metadata->fetchAll(),$this,10,'layout/metadata/pagination/offlinelist'); + + return $this->ViewModel; + } + + public function unitAction() + { + $this->ViewModel->setTemplate("layout/metadata/datalist"); + + $unit = new \Westdc\Metadata\Extra\Unit; + $this->ViewModel->setVariable('unit',$unit->fetchAll()); + + $name = $this->params()->fromRoute('name'); + if(!empty($name)) + { + + } + //view::addPaginator($metadata->fetchAll(),$this,10,'layout/metadata/pagination/offlinelist'); + + return $this->ViewModel; + } +} diff --git a/module/Metadata/view/metadata/index/index.phtml b/module/Metadata/view/metadata/index/index.phtml index 0b54c72a..95717e93 100644 --- a/module/Metadata/view/metadata/index/index.phtml +++ b/module/Metadata/view/metadata/index/index.phtml @@ -5,6 +5,7 @@ 数据列表浏览 在线数据清单 离线数据清单 + 分单位浏览
  • diff --git a/vendor/Westdc/Metadata/Extra/Unit.php b/vendor/Westdc/Metadata/Extra/Unit.php new file mode 100644 index 00000000..4d188ee9 --- /dev/null +++ b/vendor/Westdc/Metadata/Extra/Unit.php @@ -0,0 +1,55 @@ +db = new PDO; + $this->config = Config::get(); + $this->table = new Table; + + $this->opt = new \stdClass(); + + $this->opt->sort = "DESC"; + $this->opt->logic = "AND"; + } + + public function fetchAll() + { + $sql = "select distinct responsible.organisation from responsible left join role on role.resid=responsible.id where role.role='pointOfContact'"; + $rs = $this->db->query($sql); + return $rs->fetchAll(); + } + + public function fetch($id) + { + if(is_numeric($id)) + { + $sql = "SELECT * FROM {$this->table->metadata} WHERE id=$id"; + }else if(\Sookon\Helpers\Uuid::test($id)){ + $sql = "SELECT * FROM {$this->table->metadata} WHERE uuid='$id'"; + }else{ + return false; + } + + $rs = $this->db->query($sql); + return $rs->fetch(); + } + +} \ No newline at end of file