三江源网站上添加元数据跳转链接功能

This commit is contained in:
Li Jianxuan 2014-02-25 05:45:41 +00:00
parent 9bb1884d6b
commit c691d293c4
6 changed files with 29 additions and 9 deletions

View File

@ -99,6 +99,7 @@ class MetadataController extends AbstractActionController
{
$submit = $this->params()->fromPost('submit');
$uuid = $this->params()->fromRoute('uuid');
$id = (int)$this->params()->fromPost('id');
if(empty($uuid))
{
@ -107,11 +108,21 @@ class MetadataController extends AbstractActionController
$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;
$metadataurl = new \Westdc\Metadata\Outlink;
$status = $metadataurl->add($metadataurl->getParam());
if(empty($id) || $id < 0)
$status = $metadataurl->add($metadataurl->getParam());
else
$status = $metadataurl->add($metadataurl->getParam(),$id);
if($status !== true)
{

View File

@ -45,7 +45,7 @@
<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'] == 1 ? 'checked="checked"' : "" ?>> 有效
<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"' : "" ?>> 无效
@ -131,8 +131,8 @@ function submited(data){
$("#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=\"<?= $_SERVER['REQUEST_URI'] ?>\" class=\"alert-link\">如果没有跳转请点击这里</a>)");
setTimeout("window.location.href ='<?= $_SERVER['REQUEST_URI'] ?>'",3000);
$("#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;
}

View File

@ -28,7 +28,7 @@ class IndexController extends AbstractActionController
$article->opt->limit = 10;
$this->ViewModel->setVariable('articles',$article->fetchAll());
$metadata = new \Westdc\Metadata\Metadata;
$metadata = new \Westdc\Metadata\Outlink;
$metadata->opt->limit = 10;
$this->ViewModel->setVariable('metadata',$metadata->fetchAll());
unset($metadata);

View File

@ -24,7 +24,7 @@ class IndexController extends AbstractActionController
public function indexAction()
{
$metadata = new \Westdc\Metadata\Metadata;
$metadata = new \Westdc\Metadata\Outlink;
$metadata->opt->limit = 10;
$this->ViewModel->setVariable('metadata_latest',$metadata->fetchAll());
unset($metadata);

View File

@ -67,7 +67,7 @@
<?php if(!empty($this->metadata_latest)) { ?>
<ul class="unstyled">
<?php foreach($this->metadata_latest as $K=>$v) { ?>
<li><img src="<?= $this->basePath("img/westdc_20w.gif") ?>" /><a href="<?= $this->url('data/view',array('uuid'=>$v['uuid'])) ?>" title="<?= $v['title'] ?>"><?= $v['title'] ?></a></li>
<li><img src="<?= $this->basePath("img/westdc_20w.gif") ?>" /><a href="<?= $v['url'] ?>" title="<?= $v['title'] ?>"><?= $v['title'] ?></a></li>
<?php } ?>
</ul>
<?php } ?>

View File

@ -77,11 +77,12 @@ class Outlink
}
$sql = "SELECT
m.*,md.viewed, ds.id as datasetid
m.*,md.viewed, ds.id as datasetid ,ol.url
FROM {$this->table->metadata} m
LEFT join {$this->table->metadata_stat} md on m.uuid=md.uuid
LEFT JOIN mdstatus st ON md.uuid=st.uuid
left join dataset ds on m.uuid=ds.uuid
LEFT JOIN mdoutlink ol ON m.uuid = ol.uuid
$wheresql
ORDER BY $order {$this->opt->sort}";
@ -174,4 +175,12 @@ class Outlink
}// add()
//通过uuid获得url
public function getOutlinkByUuid($uuid)
{
$sql = "SELECT * FROM {$this->table->metadata_outlink} WHERE uuid='$uuid'";
$rs = $this->db->query($sql);
return $rs->fetch();
}
}