修改后台菜单,增加数据同步管理

This commit is contained in:
Li Jianxuan 2014-03-05 00:19:31 +00:00
parent 323d61b57f
commit bfa973ab73
3 changed files with 353 additions and 193 deletions

View File

@ -1,134 +1,147 @@
<?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 Admin\Controller;
use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;
use Zend\View\Model\JsonModel;
use Sookon\Helpers\View as view;
use Westdc\Metadata\Metadata;
class MetadataController extends AbstractActionController
{
public $ViewModel;
function __construct($db = NULL)
{
$this->ViewModel = new ViewModel();
}
public function indexAction()
{
$ac = $this->params()->fromRoute('ac');
$metadata = new Metadata;
$filter = new \Sookon\Search\Filter;
$keyword = isset($_GET['q']) ? $filter->mixedKeyword($_GET['q']):"";
if(!empty($keyword))
{
$metadata->opt->logic = "OR";
if(!is_numeric($keyword))
{
if(\Sookon\Helpers\Uuid::test($keyword))
$metadata->opt->where = array(
"m.uuid='$keyword'",
);
else
$metadata->opt->where = array(
"m.title LIKE '%$keyword%'",
"m.description LIKE '%$keyword%'",
"m.fileformat LIKE '%$keyword%'",
"m.projection LIKE '%$keyword%'",
"m.author LIKE '%$keyword%'",
"m.title_en LIKE '%$keyword%'",
"m.source LIKE '%$keyword%'",
"m.doi LIKE '%$keyword%'",
);
}
else
$metadata->opt->where = array(
"m.id=$keyword",
"m.west=$keyword",
"m.east=$keyword",
"m.south=$keyword",
"m.north=$keyword",
"m.datatype=$keyword",
);
}
view::addPaginator($metadata->fetchAll(),$this,10);
$this->ViewModel->setTemplate('layout/admin/metadata/list');
return $this->ViewModel;
}
public function addAction()
{
$submit = $this->params()->fromPost('submit');
$category = new \Sookon\Article\Category;
$this->ViewModel->setVariable('categories',$category->GetFullCategory());
if(empty($submit) || !$this->getRequest()->isXmlHttpRequest())
return $this->ViewModel;
$status = $category->add($category->getParam());
if($status !== true)
{
return new JsonModel(array('error'=>$status));
}else{
return new JsonModel(array('success'=>1));
}
}
public function urlAction()
{
$submit = $this->params()->fromPost('submit');
$uuid = $this->params()->fromRoute('uuid');
$id = (int)$this->params()->fromPost('id');
if(empty($uuid))
{
view::Post($this,"参数错误",-1);
}
$this->ViewModel->setVariable('uuid',$uuid);
$metadataurl = new \Westdc\Metadata\Outlink;
$urlinfo = $metadataurl->getOutlinkByUuid($uuid);
if(isset($urlinfo['url']))
{
$this->ViewModel->setVariable('data',$urlinfo);
}
if(empty($submit) || !$this->getRequest()->isXmlHttpRequest())
return $this->ViewModel;
if(empty($id) || $id < 0)
$status = $metadataurl->add($metadataurl->getParam());
else
$status = $metadataurl->add($metadataurl->getParam(),$id);
if($status !== true)
{
return new JsonModel(array('error'=>$status));
}else{
return new JsonModel(array('success'=>1));
}
}
}
<?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 Admin\Controller;
use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;
use Zend\View\Model\JsonModel;
use Sookon\Helpers\View as view;
use Westdc\Metadata\Metadata;
class MetadataController extends AbstractActionController
{
public $ViewModel;
function __construct($db = NULL)
{
$this->ViewModel = new ViewModel();
}
public function indexAction()
{
$ac = $this->params()->fromRoute('ac');
$metadata = new Metadata;
$filter = new \Sookon\Search\Filter;
$keyword = isset($_GET['q']) ? $filter->mixedKeyword($_GET['q']):"";
if(!empty($keyword))
{
$metadata->opt->logic = "OR";
if(!is_numeric($keyword))
{
if(\Sookon\Helpers\Uuid::test($keyword))
$metadata->opt->where = array(
"m.uuid='$keyword'",
);
else
$metadata->opt->where = array(
"m.title LIKE '%$keyword%'",
"m.description LIKE '%$keyword%'",
"m.fileformat LIKE '%$keyword%'",
"m.projection LIKE '%$keyword%'",
"m.author LIKE '%$keyword%'",
"m.title_en LIKE '%$keyword%'",
"m.source LIKE '%$keyword%'",
"m.doi LIKE '%$keyword%'",
);
}
else
$metadata->opt->where = array(
"m.id=$keyword",
"m.west=$keyword",
"m.east=$keyword",
"m.south=$keyword",
"m.north=$keyword",
"m.datatype=$keyword",
);
}
view::addPaginator($metadata->fetchAll(),$this,10);
$this->ViewModel->setTemplate('layout/admin/metadata/list');
return $this->ViewModel;
}
public function addAction()
{
$submit = $this->params()->fromPost('submit');
$category = new \Sookon\Article\Category;
$this->ViewModel->setVariable('categories',$category->GetFullCategory());
if(empty($submit) || !$this->getRequest()->isXmlHttpRequest())
return $this->ViewModel;
$status = $category->add($category->getParam());
if($status !== true)
{
return new JsonModel(array('error'=>$status));
}else{
return new JsonModel(array('success'=>1));
}
}
public function urlAction()
{
$submit = $this->params()->fromPost('submit');
$uuid = $this->params()->fromRoute('uuid');
$id = (int)$this->params()->fromPost('id');
if(empty($uuid))
{
view::Post($this,"参数错误",-1);
}
$this->ViewModel->setVariable('uuid',$uuid);
$metadataurl = new \Westdc\Metadata\Outlink;
$urlinfo = $metadataurl->getOutlinkByUuid($uuid);
if(isset($urlinfo['url']))
{
$this->ViewModel->setVariable('data',$urlinfo);
}
if(empty($submit) || !$this->getRequest()->isXmlHttpRequest())
return $this->ViewModel;
if(empty($id) || $id < 0)
$status = $metadataurl->add($metadataurl->getParam());
else
$status = $metadataurl->add($metadataurl->getParam(),$id);
if($status !== true)
{
return new JsonModel(array('error'=>$status));
}else{
return new JsonModel(array('success'=>1));
}
}
public function syncAction()
{
$submit = $this->params()->fromPost('submit');
$ac = $this->params()->fromRoute('ac');
if(empty($submit))
return $this->ViewModel;
}
}

View File

@ -0,0 +1,142 @@
<div class="pagebody">
<div class="col-lg-10 col-md-8 col-sm-12">
<h3>数据同步</h3>
<hr />
<form class="form-horizontal" role="form" method="post" id="form-record-add">
<div class="form-group">
<label for="inputUuid" class="col-lg-1 col-md-2 col-sm-2 control-label">UUID</label>
<div class="col-lg-7 col-md-10 col-sm-10">
<input type="text" class="form-control" id="inputUuid" placeholder="UUID" name="uuid" value="<?= !empty($this->uuid) ? $this->uuid : '';?>" <?= !empty($this->uuid) ? 'readonly="readonly"' : '';?> />
</div>
<div class="col-lg-4 hidden-md hidden-sm help-block">
<?= !empty($this->uuid) ? '自动填写' : '手工输入';?>
</div>
</div>
<div class="form-group">
<label for="inputUrl" class="col-lg-1 col-md-2 col-sm-2 control-label">跳转链接</label>
<div class="col-lg-7 col-md-10 col-sm-10">
<input type="text" class="form-control" id="inputUrl" placeholder="Url" name="url" value="<?= !empty($this->data['url']) ? $this->data['url'] : '';?>" />
</div>
<div class="col-lg-4 hidden-md hidden-sm help-block">
要跳转的目标链接
</div>
</div>
<div class="form-group">
<label for="inputRemark" class="col-lg-1 col-md-2 col-sm-2 control-label">备注</label>
<div class="col-lg-7 col-md-10 col-sm-10">
<textarea class="form-control" name="remark"><?= !empty($this->data['remark']) ? $this->data['remark'] : '';?></textarea>
</div>
<div class="col-lg-4 hidden-md hidden-sm help-block">
备注
</div>
</div>
<div class="form-group">
<label class="col-lg-1 col-md-2 col-sm-2 control-label">是否有效</label>
<div class="col-lg-7 col-md-10 col-sm-10">
<label class="radio-inline">
<input type="radio" name="status" value="1" <?= (isset($this->data['status']) && $this->data['status']) || empty($this->data['status']) == 1 ? 'checked="checked"' : "" ?>> 有效
</label>
<label class="radio-inline">
<input type="radio" name="status" value="0" <?= isset($this->data['status']) && $this->data['status'] == 0 ? 'checked="checked"' : "" ?>> 无效
</label>
</div>
<div class="col-lg-4 hidden-md hidden-sm help-block">
链接有效性
</div>
</div>
<div class="form-group">
<div class="col-lg-offset-1 col-lg-11 col-md-offset-2 col-md-10">
<div class="" id="alert-info">
</div>
</div>
</div>
<div class="form-group ">
<div class="col-lg-offset-1 col-lg-11 col-md-offset-2 col-md-10">
<input type="hidden" name="submit" value="1" />
<?php if(isset($this->data['id']) && !empty($this->data['id'])) { ?>
<input type="hidden" name="id" value="<?= $this->data['id'] ?>" />
<?php }?>
<button type="button" class="btn btn-success" id="btn-submit">提交</button>
<button type="reset" class="btn btn-default" onclick="return confirm('是否确定重置所有信息?')">重置</button>
</div>
</div>
</form>
</div><!-- col-lg-8 -->
<div class="col-lg-2 col-md-4 col-sm-12">
<?= $this->partial("layout/admin/category/nav") ?>
</div><!-- col-lg-4 -->
</div>
<script>
var _this = {};
_this.source = '<?= isset($this->data['id']) ? "edit":'add' ?>';
$(document).ready(function(e) {
$('#btn-submit').click(function(e) {//submit
$.ajax({
'type':"POST",
'url':"<?= $_SERVER['REQUEST_URI'] ?>",
'data':$("#form-record-add").serialize(),
'success':submited,
'timeout': 30000,
'error': function(){
$("#alert-info").attr('class','alert alert-danger');
$("#alert-info").html("出现错误,请稍后重试");
$('#submit-loading').hide();
return false;
},
'beforeSend': function(){
$("#btn-submit").addClass('disabled');
$("#btn-submit").attr('disabled','disabled');
$('#submit-loading').show();
},
complete: function(){
$("#btn-submit").removeClass('disabled');
$("#btn-submit").removeAttr('disabled');
$('#submit-loading').hide();
}
});
});
});
function submited(data){
if (typeof(data)=='object')
{
if(typeof(data.error)!='undefined')
{
$("#alert-info").attr('class','alert alert-danger');
$("#alert-info").html(data.error);
return false;
}
if(typeof(data.success)!='undefined')
{
$("#btn-submit").attr('disabled','disabled');
$("#alert-info").attr('class','alert alert-success');
if(typeof(_this.source) != 'undefined' && _this.source == 'edit'){
$("#alert-info").html("编辑成功!(页面将自动跳转,<a href=\"javascript:void(0);\" onclick=\"window.history.go(-1)\" class=\"alert-link\">如果没有跳转请点击这里</a>)");
setTimeout("window.history.go(-1)",3000);
}else{
$("#alert-info").html("添加成功!(页面将自动跳转,<a href=\"javascript:void(0);\" onclick=\"window.history.go(-1)\" class=\"alert-link\">如果没有跳转请点击这里</a>)");
setTimeout("window.history.go(-1)",3000);
}
return false;
}
}
else{
$("#alert-info").attr('class','alert alert-danger');
$("#alert-info").html('服务器掉链子了,<a href="/service/reporterror/?content=">通知管理员</a>');
return false;
}
}
</script>

View File

@ -1,60 +1,65 @@
<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div>
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="<?php echo $this->url('home') ?>">三江源数据门户</a>
</div>
<div class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li><a href="<?php echo $this->url('admin') ?>"><?php echo $this->translate('后台首页') ?></a></li>
<li><a href="<?php echo $this->url('admin',array('controller'=>'metadata','action'=>'index','ac'=>'list')) ?>"><?php echo $this->translate('数据管理') ?></a></li>
<!-- <li><a href="<?php echo $this->url('admin',array('controller'=>'apply','action'=>'index')) ?>"><?php echo $this->translate('申请管理') ?></a></li> -->
<li class="dropdown" id="collapseArchive">
<a href="#" class="dropdown-toggle" data-toggle="dropdown"><i class="icon-list-alt"></i> 新闻<b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a href="<?= $this->url('admin',array('controller'=>'article','action'=>'index')) ?>">文档管理</a></li>
<li><a href="<?= $this->url('admin',array('controller'=>'article','action'=>'add')) ?>">文档添加</a></li>
<li class="divider"></li>
<li><a href="<?= $this->url('admin',array('controller'=>'category','action'=>'index')) ?>">栏目管理</a></li>
<li><a href="<?= $this->url('admin',array('controller'=>'category','action'=>'add')) ?>">栏目添加</a></li>
<li><a href="<?= $this->url('admin',array('controller'=>'category','action'=>'map')) ?>">栏目地图</a></li>
</ul>
</li>
<li class="dropdown" id="collapseSys">
<a href="#" class="dropdown-toggle" data-toggle="dropdown"><i class="icon-wrench"></i> 系统管理<b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a href="<?= $this->url('admin',array('controller'=>'users','action'=>'index','ac'=>'list')) ?>">用户管理</a></li>
<li><a href="<?= $this->url('admin',array('controller'=>'users','action'=>'config')) ?>">邮件模板</a></li>
</ul>
</li>
</ul>
<?php $user = \Sookon\Helpers\View::User(); ?>
<ul class="nav navbar-nav user_menu pull-right">
<li class="divider-vertical hidden-phone hidden-tablet"></li>
<li class="dropdown">
<a href="javascript:void(0);" class="dropdown-toggle" data-toggle="dropdown"><i class="icon-wrench"></i>
<?php
if(isset($user->avatar))
{
echo '<img src="'.$user->avatar.'" alt="" class="user_avatar" style="height:16px;margin-right:3px;" />';
}
echo $user->username;
?>
<b class="caret"></b>
</a>
<ul class="dropdown-menu">
<li><a href="<?= $this->url('home') ?>">前台首页</a></li>
<li><a href="<?= $this->url('home/default',array('controller'=>'account','action'=>'index')) ?>">个人资料</a></li>
<li><a href="<?= $this->url('home/default',array('controller'=>'account','action'=>'edit')) ?>">编辑</a></li>
<li class="divider"></li>
<li><a href="<?= $this->url('home/default',array('controller'=>'account','action'=>'logout')) ?>">注销</a></li>
</ul>
</li>
</ul>
</div><!--/.nav-collapse -->
</div>
<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div>
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="<?php echo $this->url('home') ?>">三江源数据门户</a>
</div>
<div class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li><a href="<?php echo $this->url('admin') ?>"><?php echo $this->translate('后台首页') ?></a></li>
<li class="dropdown" id="collapseArchive">
<a href="#" class="dropdown-toggle" data-toggle="dropdown"><i class="icon-list-alt"></i> 数据<b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a href="<?= $this->url('admin',array('controller'=>'metadata','action'=>'index','ac'=>'list')) ?>"><?= $this->translate('数据管理') ?></a></li>
<li><a href="<?= $this->url('admin',array('controller'=>'metadata','action'=>'sync')) ?>"><?= $this->translate('数据同步') ?></a></li>
</ul>
</li>
<li class="dropdown" id="collapseArchive">
<a href="#" class="dropdown-toggle" data-toggle="dropdown"><i class="icon-list-alt"></i> 新闻<b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a href="<?= $this->url('admin',array('controller'=>'article','action'=>'index')) ?>">文档管理</a></li>
<li><a href="<?= $this->url('admin',array('controller'=>'article','action'=>'add')) ?>">文档添加</a></li>
<li class="divider"></li>
<li><a href="<?= $this->url('admin',array('controller'=>'category','action'=>'index')) ?>">栏目管理</a></li>
<li><a href="<?= $this->url('admin',array('controller'=>'category','action'=>'add')) ?>">栏目添加</a></li>
<li><a href="<?= $this->url('admin',array('controller'=>'category','action'=>'map')) ?>">栏目地图</a></li>
</ul>
</li>
<li class="dropdown" id="collapseSys">
<a href="#" class="dropdown-toggle" data-toggle="dropdown"><i class="icon-wrench"></i> 系统<b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a href="<?= $this->url('admin',array('controller'=>'users','action'=>'index','ac'=>'list')) ?>">用户管理</a></li>
<li><a href="<?= $this->url('admin',array('controller'=>'users','action'=>'config')) ?>">邮件模板</a></li>
</ul>
</li>
</ul>
<?php $user = \Sookon\Helpers\View::User(); ?>
<ul class="nav navbar-nav user_menu pull-right">
<li class="divider-vertical hidden-phone hidden-tablet"></li>
<li class="dropdown">
<a href="javascript:void(0);" class="dropdown-toggle" data-toggle="dropdown"><i class="icon-wrench"></i>
<?php
if(isset($user->avatar))
{
echo '<img src="'.$user->avatar.'" alt="" class="user_avatar" style="height:16px;margin-right:3px;" />';
}
echo $user->username;
?>
<b class="caret"></b>
</a>
<ul class="dropdown-menu">
<li><a href="<?= $this->url('home') ?>">前台首页</a></li>
<li><a href="<?= $this->url('home/default',array('controller'=>'account','action'=>'index')) ?>">个人资料</a></li>
<li><a href="<?= $this->url('home/default',array('controller'=>'account','action'=>'edit')) ?>">编辑</a></li>
<li class="divider"></li>
<li><a href="<?= $this->url('home/default',array('controller'=>'account','action'=>'logout')) ?>">注销</a></li>
</ul>
</li>
</ul>
</div><!--/.nav-collapse -->
</div>
</nav>