添加按单位浏览

This commit is contained in:
Li Jianxuan 2014-03-04 09:10:59 +00:00
parent 1f14a20433
commit 123a76c464
4 changed files with 218 additions and 123 deletions

View File

@ -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

View File

@ -119,4 +119,21 @@ class IndexController extends AbstractActionController
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;
}
}

View File

@ -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>

55
vendor/Westdc/Metadata/Extra/Unit.php vendored Normal file
View File

@ -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();
}
}