From e87c60c651c6a9e6f6b0d99a1d5badcdf78593ee Mon Sep 17 00:00:00 2001 From: Li Jianxuan Date: Thu, 13 Mar 2014 09:11:52 +0000 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=BA=86=E6=8C=89=E6=A0=87?= =?UTF-8?q?=E7=AD=BE=E6=B5=8F=E8=A7=88=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- module/Metadata/config/module.config.php | 3 +- .../Metadata/Controller/IndexController.php | 8 ++ vendor/Sookon/Helpers/Uuid.php | 100 ++++++++++-------- 3 files changed, 63 insertions(+), 48 deletions(-) diff --git a/module/Metadata/config/module.config.php b/module/Metadata/config/module.config.php index 5d3a7b17..3724073b 100644 --- a/module/Metadata/config/module.config.php +++ b/module/Metadata/config/module.config.php @@ -65,9 +65,10 @@ return array( 'tag' => array( 'type' => 'Segment', 'options' => array( - 'route' => '/tag[/:tag]', + 'route' => '/tag[/keytype/[:keytype]][/:tag]', 'constraints' => array( 'tag' => ".*", + 'keytype' => '.*' ), 'defaults' => array( 'module' => 'Metadata', diff --git a/module/Metadata/src/Metadata/Controller/IndexController.php b/module/Metadata/src/Metadata/Controller/IndexController.php index 3e43d149..23256090 100644 --- a/module/Metadata/src/Metadata/Controller/IndexController.php +++ b/module/Metadata/src/Metadata/Controller/IndexController.php @@ -68,10 +68,18 @@ class IndexController extends AbstractActionController public function tagAction() { $tag = $this->params()->fromRoute('tag'); + $keytype = $this->params()->fromRoute('keytype'); if(preg_match("/\'/",$tag)) view::Post($this,"参数错误",-1); + if(!empty($keytype)) + { + $tags = new \Westdc\Metadata\Tags; + $this->ViewModel->setVariable('keywords',$tags->getAllTagsAndCount($keytype)); + return $this->ViewModel; + } + if(empty($tag)) { $tags = new \Westdc\Metadata\Tags; diff --git a/vendor/Sookon/Helpers/Uuid.php b/vendor/Sookon/Helpers/Uuid.php index a9c7a40e..2c40abcd 100644 --- a/vendor/Sookon/Helpers/Uuid.php +++ b/vendor/Sookon/Helpers/Uuid.php @@ -1,48 +1,54 @@ -getLocalHost(); - $this->valueBeforeMD5 = $address.':'.$this->currentTimeMillis().':'.$this->nextLong(); - $this->valueAfterMD5 = md5($this->valueBeforeMD5); - } - function toString() - { - $raw = strtoupper($this->valueAfterMD5); - return substr($raw,0,8).'-'.substr($raw,8,4).'-'.substr($raw,12,4).'-'.substr($raw,16,4).'-'.substr($raw,20); - } - - private function nextLong() - { - $tmp = rand(0,1)?'-':''; - return $tmp.rand(1000, 9999).rand(1000, 9999).rand(1000, 9999).rand(100, 999).rand(100, 999); - } - private function currentTimeMillis() - { - list($usec, $sec) = explode(" ",microtime()); - return $sec.substr($usec, 2, 3); - } - private function getLocalHost() - { - $address = isset($_ENV["COMPUTERNAME"]) ? $_ENV["COMPUTERNAME"]."/":"".'/'; - $address.= $_SERVER["SERVER_ADDR"]; - return strtolower($address); - } - - static function test($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)) - { - return false; - }else{ - return true; - } - } +update(); + } + + public function update() + { + $address = $this->getLocalHost(); + $this->valueBeforeMD5 = $address.':'.$this->currentTimeMillis().':'.$this->nextLong(); + $this->valueAfterMD5 = md5($this->valueBeforeMD5); + } + + public function toString() + { + $raw = strtoupper($this->valueAfterMD5); + return substr($raw,0,8).'-'.substr($raw,8,4).'-'.substr($raw,12,4).'-'.substr($raw,16,4).'-'.substr($raw,20); + } + + private function nextLong() + { + $tmp = rand(0,1)?'-':''; + return $tmp.rand(1000, 9999).rand(1000, 9999).rand(1000, 9999).rand(100, 999).rand(100, 999); + } + private function currentTimeMillis() + { + list($usec, $sec) = explode(" ",microtime()); + return $sec.substr($usec, 2, 3); + } + private function getLocalHost() + { + $address = isset($_ENV["COMPUTERNAME"]) ? $_ENV["COMPUTERNAME"]."/":"".'/'; + $address.= $_SERVER["SERVER_ADDR"]; + return strtolower($address); + } + + static function test($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)) + { + return false; + }else{ + return true; + } + } } \ No newline at end of file