westdc-zf1/application/default/controllers/KnowledgeController.php

130 lines
4.7 KiB
PHP
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
class KnowledgeController extends Zend_Controller_Action
{
function indexAction()
{
}
function preDispatch()
{
$this->db=Zend_Registry::get('db');
$this->view->config = Zend_Registry::get('config');
$this->messenger=$this->_helper->getHelper('FlashMessenger');
$this->view->messages = $this->messenger->getMessages();
$this->view->theme=new Theme();
}
function datacenterAction()
{
$siteid="e31f5ea7-a4af-4ae3-9ac1-1a84132c4338";//site uuid from geonetowrk
$sql="select r.* from mdref mr left join reference r on mr.refid=r.id where r.language<>'zh' and mr.uuid=? order by r.id desc";
$sth = $this->db->prepare($sql);
$sth->execute(array($siteid));
$rows = $sth->fetchAll();
$paginator = Zend_Paginator::factory($rows);
$paginator->setCurrentPageNumber($this->_getParam('page'));
$paginator->setItemCountPerPage(10);
$paginator->setView($this->view);
Zend_View_Helper_PaginationControl::setDefaultViewPartial('pagination_param.phtml');
$this->view->paginator=$paginator;
}
function userAction()
{
$sql="select * from reference where language<>'zh' and id in (select refid from mdref where reftype=1 and uuid in (select uuid from en.normalmetadata)) order by id desc";
$sth = $this->db->prepare($sql);
$sth->execute();
$rows = $sth->fetchAll();
$paginator = Zend_Paginator::factory($rows);
$paginator->setCurrentPageNumber($this->_getParam('page'));
$paginator->setItemCountPerPage(10);
$paginator->setView($this->view);
Zend_View_Helper_PaginationControl::setDefaultViewPartial('pagination_param.phtml');
$this->view->paginator=$paginator;
}
function authorAction()
{
$sql="select * from reference where language<>'zh' and id in (select refid from mdref where reftype=0 and uuid in (select uuid from en.normalmetadata)) order by id desc";
$sth = $this->db->prepare($sql);
$sth->execute();
$rows = $sth->fetchAll();
$paginator = Zend_Paginator::factory($rows);
$paginator->setCurrentPageNumber($this->_getParam('page'));
$paginator->setItemCountPerPage(10);
$paginator->setView($this->view);
Zend_View_Helper_PaginationControl::setDefaultViewPartial('pagination_param.phtml');
$this->view->paginator=$paginator;
}
function waterAction()
{
$sql="select * from reference where language<>'zh' and id in
(select refid from mdref where uuid in
(select m.uuid from en.normalmetadata m left join datasource ds on ds.uuid=m.uuid left join source s on ds.sourceid=s.id where s.code='water'))
order by id desc";
$sth = $this->db->prepare($sql);
$sth->execute();
$rows = $sth->fetchAll();
$paginator = Zend_Paginator::factory($rows);
$paginator->setCurrentPageNumber($this->_getParam('page'));
$paginator->setItemCountPerPage(10);
$paginator->setView($this->view);
Zend_View_Helper_PaginationControl::setDefaultViewPartial('pagination_param.phtml');
$this->view->paginator=$paginator;
}
function searchAction()
{
$key=$this->_request->getParam('q');
$source=$this->_request->getParam('searchsource');
if(preg_match("/\"|'|<|>/",$key))
{
$data=array('<'=>'&lt;','>'=>'&gt;', "\'"=>'', "\""=>'”');
$patterns = array();
$replacements = array();
foreach($data as $k=>$v)
{
$patterns[]='/'.$k.'/i';
$replacements[]=$v;
}
ksort($patterns);
ksort($replacements);
$key=preg_replace($patterns, $replacements, $key);
}
if (!empty($key)) {
$search=new SimpleSearch($key);
$where=$search->sql_expr(array("reference"));
$sql="select * from reference where ".$where." order by id desc";
$sth = $this->db->prepare($sql);
$sth->execute();
$rows = $sth->fetchAll();
$paginator = Zend_Paginator::factory($rows);
$paginator->setCurrentPageNumber($this->_getParam('page'));
$paginator->setItemCountPerPage(10);
$paginator->setView($this->view);
Zend_View_Helper_PaginationControl::setDefaultViewPartial('pagination_param.phtml');
$this->view->paginator=$paginator;
$this->view->key=$key;
$this->view->source=$source;
$this->_helper->viewRenderer('search-data');
}
}
function paperAction()
{
$id = (int)$this->_request->getParam('id');
$sql="select * from reference where id=$id";
$sth = $this->db->prepare($sql);
$sth->execute();
$this->view->paper = $sth->fetch();
$sql="select * from ref_author where id=$id order by place";
$sth = $this->db->prepare($sql);
$sth->execute();
$this->view->author = $sth->fetchAll();
$sql="select * from ref_tag where id=$id";
$sth = $this->db->prepare($sql);
$sth->execute();
$this->view->tag = $sth->fetchAll();
}
}