显示缩略图的大图,数据库查询设置为对象模式
This commit is contained in:
parent
cb38a6f11a
commit
557b667f04
|
@ -541,18 +541,19 @@ class DataController extends Zend_Controller_Action
|
|||
*/
|
||||
function viewAction()
|
||||
{
|
||||
$md=new MetadataTable();
|
||||
$db=$md->getAdapter();
|
||||
$id = (int)$this->_request->getParam('id');
|
||||
$id = (int)$this->_request->getParam('id');
|
||||
$sql="select m.*,s.status,g.id as gid,t.filename from normalmetadata m left join mdstatus s on m.uuid=s.uuid
|
||||
left join thumbnail t on t.id=m.id left join geonetworkmetadata g on m.uuid=g.uuid where ";
|
||||
if (empty($id)) {
|
||||
$uuid = $this->_request->getParam('uuid');
|
||||
if (empty($uuid)) $this->_redirect('/data');
|
||||
$where=$db->quoteInto('uuid = ?',$uuid);
|
||||
$row=$md->fetchRow($where);
|
||||
$where=$this->db->quoteInto('m.uuid = ?',$uuid);
|
||||
} else {
|
||||
$where=$db->quoteInto('id = ?',$id);
|
||||
$row=$md->fetchRow($where);
|
||||
}
|
||||
$where=$this->db->quoteInto('m.id = ?',$id);
|
||||
}
|
||||
$sql.=$where;
|
||||
$this->db->setFetchMode(Zend_Db::FETCH_OBJ);
|
||||
$row=$this->db->fetchRow($sql);
|
||||
if (!$row) $this->_redirect('/data');
|
||||
$id=$row->id;
|
||||
$uuid=$row->uuid;
|
||||
|
@ -561,48 +562,50 @@ class DataController extends Zend_Controller_Action
|
|||
$wiki=new WikiFormat();
|
||||
$this->view->metadata->description=$wiki->parseTable($this->view->escape($row->description));
|
||||
//处理外部链接
|
||||
$this->view->metadata->description=preg_replace('/\[\s*(http:\/\/.+?)\s+(.*?)\]/m','<a href="$1">$2</a>',$this->view->metadata->description);
|
||||
$this->view->metadata->description=preg_replace('/\[\s*(http:\/\/.+?)\s+(.*?)\]/m','<a href="$1">$2</a>',$this->view->metadata->description);
|
||||
$this->view->thumburl='/gndata/'.sprintf('%05d',floor(($row->gid+0.1)/100)*100).'-'.sprintf('%05d',ceil(($row->gid+0.1)/100)*100-1)."/".$row->gid;
|
||||
$this->view->thumburl.='/public/'.str_replace('_s.','.',$row->filename);
|
||||
if (is_numeric($row->projection))
|
||||
{
|
||||
$sql="select proj4text from spatial_ref_sys where auth_srid=?";
|
||||
$rs=$db->fetchRow($sql,array((int)$row->projection));
|
||||
if ($rs) $this->view->projection=$rs['proj4text'];
|
||||
$rs=$this->db->fetchRow($sql,array((int)$row->projection));
|
||||
if ($rs) $this->view->projection=$rs->proj4text;
|
||||
}
|
||||
$this->view->keys=$this->db->fetchAll("select * from keyword where id=? order by keytype,ts_created",array($id));
|
||||
$sql='select c.code,cc.name,cc.name_zh from category c,categorycode cc where c.code=cc.code and c.id= ?';
|
||||
$state=$db->query($sql,array($id));
|
||||
$state=$this->db->query($sql,array($id));
|
||||
$this->view->category=$state->fetchAll();
|
||||
$sql='select s.name,s.id from dataseries d, series s where d.sid=s.id and d.id= ?';
|
||||
$state=$db->query($sql,array($id));
|
||||
$state=$this->db->query($sql,array($id));
|
||||
$this->view->series=$state->fetchAll();
|
||||
$sql=$db->quoteInto("select count(*) as count from dataorder where uuid=?",$uuid);
|
||||
$row=$db->fetchRow($sql);
|
||||
$this->view->downloaded=$row['count'];
|
||||
$sql=$this->db->quoteInto("select count(*) as count from dataorder where uuid=?",$uuid);
|
||||
$row=$this->db->fetchRow($sql);
|
||||
$this->view->downloaded=$row->count;
|
||||
//update the viewed times
|
||||
$sql="update mdstat set viewed=viewed+1 where uuid=?";
|
||||
$db->query($sql,array($uuid));
|
||||
$sql=$db->quoteInto("select viewed from mdstat where uuid=?",$uuid);
|
||||
$row=$db->fetchRow($sql);
|
||||
$this->view->viewed=$row['viewed'];
|
||||
$this->db->query($sql,array($uuid));
|
||||
$sql=$this->db->quoteInto("select viewed from mdstat where uuid=?",$uuid);
|
||||
$row=$this->db->fetchRow($sql);
|
||||
$this->view->viewed=$row->viewed;
|
||||
//数据文档
|
||||
$sql="select linkage from onlineresource where uuid=? and description='数据说明文档'";
|
||||
$sql=$db->quoteInto($sql,$uuid);
|
||||
$row=$db->fetchRow($sql);
|
||||
if ($row) $this->view->doc=$row['linkage'];
|
||||
$sql=$this->db->quoteInto($sql,$uuid);
|
||||
$row=$this->db->fetchRow($sql);
|
||||
if ($row) $this->view->doc=$row->linkage;
|
||||
//相关资源
|
||||
$sql="select * from onlineresource where uuid=? and description<>'数据说明文档' and (linkage not like '%ftp.westgis%') and name<>'元数据地址'";
|
||||
$sql=$db->quoteInto($sql,$uuid);
|
||||
$this->view->resources=$db->fetchAll($sql);
|
||||
$sql=$this->db->quoteInto($sql,$uuid);
|
||||
$this->view->resources=$this->db->fetchAll($sql);
|
||||
//建议参考文献
|
||||
$sql="select r.* from reference r left join mdref m on m.refid=r.id where m.uuid=?";
|
||||
$sql=$db->quoteInto($sql,$uuid);
|
||||
$this->view->ref=$db->fetchAll($sql);
|
||||
$sql=$this->db->quoteInto($sql,$uuid);
|
||||
$this->view->ref=$this->db->fetchAll($sql);
|
||||
//相关用户
|
||||
$sql="select p.email,p.individual,p.organisation,r.role from role r left join responsible p on r.resid=p.id where r.uuid=? order by r.role,r.id";
|
||||
$this->view->authors=$db->fetchAll($sql,array($uuid));
|
||||
$this->view->authors=$this->db->fetchAll($sql,array($uuid));
|
||||
//数据限制信息
|
||||
$sql="select u.* from uselimit u left join mdlimit m on u.id=m.lid where m.uuid=?";
|
||||
$this->view->uselimits=$db->fetchAll($sql,array($uuid));
|
||||
$this->view->uselimits=$this->db->fetchAll($sql,array($uuid));
|
||||
//相关元数据,根据同名关键词实现
|
||||
//$sql="select distinct(md.uuid),md.title from keyword kw left join metadata md on kw.id=md.id where kw.keyword in (select k.keyword from keyword k left join metadata m on k.id=m.id where m.id=? and k.keytype='theme') and kw.id<>? limit 10";
|
||||
$sql="select distinct(md.uuid),md.title from keyword kw left join metadata md on kw.id=md.id where kw.keyword in (select k.keyword from keyword k left join metadata m on k.id=m.id where m.id=?) and kw.id<>? limit 10";
|
||||
|
@ -611,9 +614,9 @@ class DataController extends Zend_Controller_Action
|
|||
$sql="select * from knl_article where ";
|
||||
foreach($this->view->keys as $k)
|
||||
{
|
||||
if ($k["keytype"]=='theme')
|
||||
if ($k->keytype=='theme')
|
||||
{
|
||||
$sql.=" title like '%".$k["keyword"]."%' or ";
|
||||
$sql.=" title like '%".$k->keyword."%' or ";
|
||||
}
|
||||
}
|
||||
$sql.=" 1<>1 limit 10";
|
||||
|
|
|
@ -23,7 +23,7 @@ if ($md->title_en) echo '<br />'.$this->escape($md->title_en);?>
|
|||
<div id="ItemSummary">
|
||||
<div id="category">
|
||||
<ul><?php foreach($this->category as $cat): ?>
|
||||
<li><a href="/data/category/code/<?php echo $cat['code'];?>"><?php echo $this->escape($cat['name_zh']);?></a></li>
|
||||
<li><a href="/data/category/code/<?php echo $cat->code;?>"><?php echo $this->escape($cat->name_zh);?></a></li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
</div>
|
||||
|
@ -31,15 +31,15 @@ if ($md->title_en) echo '<br />'.$this->escape($md->title_en);?>
|
|||
$kt='';
|
||||
$i=0;
|
||||
foreach($this->keys as $cg) :
|
||||
if ($kt==$cg['keytype']) :
|
||||
if ($kt==$cg->keytype) :
|
||||
$i+=1;
|
||||
else :
|
||||
if (!empty($kt)) echo '</ul></div>';
|
||||
$kt=$cg['keytype'];
|
||||
$kt=$cg->keytype;
|
||||
$i=0;
|
||||
endif;
|
||||
if ($i==0) echo '<div id="'.$cg['keytype'].'"><ul>';
|
||||
echo '<li><a href="/data/tag/key/'.urlencode($cg['keyword']).'">'.$cg['keyword'].'</a></li>';
|
||||
if ($i==0) echo '<div id="'.$cg->keytype.'"><ul>';
|
||||
echo '<li><a href="/data/tag/key/'.urlencode($cg->keyword).'">'.$cg->keyword.'</a></li>';
|
||||
endforeach;
|
||||
echo '</ul></div>';
|
||||
?>
|
||||
|
@ -48,7 +48,7 @@ echo '</ul></div>';
|
|||
<?php if ($this->series): ?>
|
||||
<div id="series">
|
||||
<ul><?php foreach($this->series as $serie): ?>
|
||||
<li><a href="/data/series/id/<?php echo $serie['id']; ?>"> <?php echo $this->escape($serie['name']);?></a></li>
|
||||
<li><a href="/data/series/id/<?php echo $serie->id; ?>"> <?php echo $this->escape($serie->name);?></a></li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
</div>
|
||||
|
@ -114,24 +114,24 @@ $party_zh=array('resourceProvider'=>'资源提供者','custodian'=>'维护者','
|
|||
$r='';
|
||||
$i=0;
|
||||
foreach($this->authors as $k=>$author) :
|
||||
if ($author['role']!=$r)
|
||||
if ($author->role!=$r)
|
||||
{
|
||||
$r=$author['role'];
|
||||
$r=$author->role;
|
||||
$i=0;
|
||||
if ($k>0) echo '</li>';
|
||||
echo '<li>'.$party_zh[$author['role']].':';
|
||||
echo '<li>'.$party_zh[$author->role].':';
|
||||
}
|
||||
if ($i>0) echo ',';
|
||||
$i+=1;
|
||||
if (!empty($author['email']) && $r!='principalInvestigator')
|
||||
echo '<a href="mailto:'.$author['email'].'">';
|
||||
echo '<strong title="'.$author['organisation'].'">';
|
||||
if (!empty($author['individual']))
|
||||
echo $author['individual'];
|
||||
if (!empty($author->email) && $r!='principalInvestigator')
|
||||
echo '<a href="mailto:'.$author->email.'">';
|
||||
echo '<strong title="'.$author->organisation.'">';
|
||||
if (!empty($author->individual))
|
||||
echo $author->individual;
|
||||
else
|
||||
echo $author['organisation'];
|
||||
echo $author->organisation;
|
||||
echo '</strong>';
|
||||
if (!empty($author['email'])) echo '</a>';
|
||||
if (!empty($author->email)) echo '</a>';
|
||||
if ($k+1==count($this->authors)) echo '</li>';
|
||||
endforeach;
|
||||
?>
|
||||
|
@ -145,7 +145,7 @@ endforeach;
|
|||
|
||||
</div>
|
||||
<div id="left">
|
||||
<div id="ImageViewer"><img src="/data/thumb/id/<?php echo $md->id;?>" onclick="fnCreate('/images/ssimg.jpg')" /> </div>
|
||||
<div id="ImageViewer"><img src="/data/thumb/id/<?php echo $md->id;?>" onclick="fnCreate('<?php echo $this->thumburl; ?>')" /> </div>
|
||||
<div id="abstract">
|
||||
<p>
|
||||
<?php echo str_replace(array("\r\n", "\n", "\r"),'</p><p>',$md->description);?>
|
||||
|
@ -175,7 +175,7 @@ endforeach;
|
|||
<?php
|
||||
if ($this->uselimits) :
|
||||
foreach($this->uselimits as $uselimit) :
|
||||
echo '<p>'.str_replace(array("\r\n", "\n", "\r"),'</p><p>',$this->escape($uselimit['uselimit'])).'</p>';
|
||||
echo '<p>'.str_replace(array("\r\n", "\n", "\r"),'</p><p>',$this->escape($uselimit->uselimit)).'</p>';
|
||||
endforeach;
|
||||
?>
|
||||
<?php else : ?>
|
||||
|
@ -191,14 +191,14 @@ endforeach;
|
|||
<?php if ($this->resources) : ?>
|
||||
<h2>其他在线资源</h2>
|
||||
<ul><?php foreach($this->resources as $link) : ?>
|
||||
<li><a href="<?php echo $link['linkage']; ?>" title="<?php echo $link['description']; ?>">
|
||||
<li><a href="<?php echo $link->linkage; ?>" title="<?php echo $link->description; ?>">
|
||||
<?php
|
||||
if (!empty($link['name']))
|
||||
echo $link['name'];
|
||||
elseif (!empty($link['description']))
|
||||
echo $link['description'];
|
||||
if (!empty($link->name))
|
||||
echo $link->name;
|
||||
elseif (!empty($link->description))
|
||||
echo $link->description;
|
||||
else
|
||||
echo $link['linkage'];
|
||||
echo $link->linkage;
|
||||
?></a></li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
|
@ -211,7 +211,7 @@ endforeach;
|
|||
<h2>相关数据</h2>
|
||||
<ul>
|
||||
<?php foreach ($this->related as $r) : ?>
|
||||
<li><a href="/data/<?= $r['uuid']; ?>"><?= $r['title']; ?></a></li>
|
||||
<li><a href="/data/<?= $r->uuid; ?>"><?= $r->title; ?></a></li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
</div>
|
||||
|
@ -221,14 +221,14 @@ endforeach;
|
|||
<h2>相关文献</h2>
|
||||
<ul>
|
||||
<?php foreach ($this->literature as $r) :
|
||||
$u=parse_url($r['url']);
|
||||
$u=parse_url($r->url);
|
||||
if ($u['host']=='hdl.handle.net')
|
||||
$url=$this->config->seekspace->handleurl.$u['path'];
|
||||
else
|
||||
$url=$r['url'];
|
||||
$url=$r->url;
|
||||
echo '<li>';
|
||||
if ($url) echo '<a href="'.$url.'" target="_blank">';
|
||||
echo $r['title'];
|
||||
echo $r->title;
|
||||
if ($url) echo '</a>';
|
||||
echo '</li>';
|
||||
?>
|
||||
|
@ -241,7 +241,7 @@ echo '</li>';
|
|||
<h2>相关文档</h2>
|
||||
<ul>
|
||||
<?php foreach ($this->documents as $r) : ?>
|
||||
<li><a href="/data/<?= $r['uuid']; ?>"><?= $r['title']; ?></a></li>
|
||||
<li><a href="/data/<?= $r->uuid; ?>"><?= $r->title; ?></a></li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue