添加按单位浏览
This commit is contained in:
parent
1f14a20433
commit
123a76c464
|
@ -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
|
||||
|
|
|
@ -1,122 +1,139 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework (http://framework.zend.com/)
|
||||
*
|
||||
* @link http://github.com/zendframework/ZendSkeletonApplication for the canonical source repository
|
||||
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
namespace Metadata\Controller;
|
||||
|
||||
use Zend\Mvc\Controller\AbstractActionController;
|
||||
use Zend\View\Model\ViewModel;
|
||||
use Sookon\Helpers\View as view;
|
||||
|
||||
class IndexController extends AbstractActionController
|
||||
{
|
||||
public $ViewModel;
|
||||
|
||||
function __construct($db = NULL)
|
||||
{
|
||||
$this->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;
|
||||
}
|
||||
}
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework (http://framework.zend.com/)
|
||||
*
|
||||
* @link http://github.com/zendframework/ZendSkeletonApplication for the canonical source repository
|
||||
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
namespace Metadata\Controller;
|
||||
|
||||
use Zend\Mvc\Controller\AbstractActionController;
|
||||
use Zend\View\Model\ViewModel;
|
||||
use Sookon\Helpers\View as view;
|
||||
|
||||
class IndexController extends AbstractActionController
|
||||
{
|
||||
public $ViewModel;
|
||||
|
||||
function __construct($db = NULL)
|
||||
{
|
||||
$this->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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
<a class="btn" href="/data/browse"><i class="icon-reorder"></i>数据列表浏览</a>
|
||||
<a class="btn" href="/data/onlinelist"><i class="icon-th"></i>在线数据清单</a>
|
||||
<a class="btn" href="/data/offlinelist"><i class="icon-th"></i>离线数据清单</a>
|
||||
<a class="btn" href="/data/unit"><i class="icon-th"></i>分单位浏览</a>
|
||||
<li class="input-append">
|
||||
<input type="text" value="" id="q" name="q" class="span2 search-query " placeholder="全文搜索">
|
||||
<button type="submit" class="btn"><i class="icon-search"></i>搜索</button>
|
||||
|
|
|
@ -0,0 +1,55 @@
|
|||
<?php
|
||||
namespace Westdc\Metadata\Extra;
|
||||
|
||||
use Sookon\Helpers\View as view;
|
||||
use Sookon\Helpers\Dbh as dbh;
|
||||
use Sookon\Helpers\PDO;
|
||||
use Sookon\Helpers\Config;
|
||||
use Sookon\Helpers\Table;
|
||||
use Zend\Http\PhpEnvironment\Request;
|
||||
|
||||
class Unit
|
||||
{
|
||||
private $db; //传入PDO对象
|
||||
private $config; //站点设置
|
||||
private $table;
|
||||
|
||||
public $opt;
|
||||
|
||||
protected $events = NULL;
|
||||
|
||||
function __construct()
|
||||
{
|
||||
$this->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();
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue