diff --git a/application/default/controllers/AuthorController.php b/application/default/controllers/AuthorController.php index f2e81a8b..368d364a 100644 --- a/application/default/controllers/AuthorController.php +++ b/application/default/controllers/AuthorController.php @@ -32,9 +32,10 @@ class AuthorController extends Zend_Controller_Action /* * acceptAction() 我的数据 * + * param string $ac // list|search + * param string $keyword * - * - * + * return view */ function acceptAction() { @@ -72,74 +73,31 @@ class AuthorController extends Zend_Controller_Action //搜索 if($ac == "search") { - $this->_helper->layout->disableLayout(); - $this->_helper->viewRenderer->setNoRender(); - - $data = ""; - - //数据处理代码 EOH<<<<<<<<<<<<<<<< - try{ + $keyword = trim($this->_request->getParam('q')); + $this->view->q = $keyword; + if (!preg_match_all("/^[\x{4e00}-\x{9fa5}A-Za-z0-9_]+$/u",$keyword,$matchs)) + { + $data = array('error'=>'搜索关键字中只能包含汉字、英文、数字'); + } + else + { + //搜索标题和描述两个字段 + $sql = "SELECT m.uuid,m.title,m.description,a.status,a.userid FROM metadata m + LEFT JOIN mdauthor a ON m.uuid=a.uuid + WHERE (m.title like ? OR m.description like ?) AND a.userid=?"; + $sth = $this->db->prepare($sql); + $sth->execute(array("%$keyword%","%$keyword%",$u_id)); + $rows = $sth->fetchAll(); - $keyword = trim($this->_request->getParam('q')); - if (!preg_match_all("/^[\x{4e00}-\x{9fa5}A-Za-z0-9_]+$/u",$keyword,$matchs)) - { - $data = array('error'=>'搜索关键字中只能包含汉字、英文、数字'); - } - else - { - //搜索标题和描述两个字段 - $sql = "SELECT m.uuid,m.title,m.description,a.status,a.userid FROM metadata m - LEFT JOIN mdauthor a ON m.uuid=a.uuid - WHERE m.title like ? OR m.description like ?"; - $sth = $this->db->prepare($sql); - $sth->execute(array("%$keyword%","%$keyword%")); - $rows = $sth->fetchAll(); - - if(is_array($rows) && count($rows)>0) - $data = $rows; - else - $data = ""; - } - - }catch(Exception $e){ - if(empty($data['error'])) - { - $data = array("error"=>"处理过程中遇到错误,请重新尝试"); - //$data = array("error"=>$e->getMessage()); - } - } - // >>>>>>>>>>> F - - $this ->getResponse() - ->setHeader('Content-Type', 'application/json') - ->appendBody(Zend_Json::encode($data)); + $paginator = Zend_Paginator::factory($rows); + $paginator->setCurrentPageNumber($this->_getParam('page')); + $paginator->setItemCountPerPage(5); + $paginator->setView($this->view); + Zend_View_Helper_PaginationControl::setDefaultViewPartial('pagination_param.phtml'); + $this->view->paginator=$paginator; + } }// search - - if($ac == 'sendmail') - { - $this->_helper->layout->disableLayout(); - $this->_helper->viewRenderer->setNoRender(); - - $data = ""; - - //数据处理代码 EOH<<<<<<<<<<<<<<<< - try{ - - }catch(Exception $e){ - if(empty($data['error'])) - { - $data = array("error"=>"处理过程中遇到错误,请重新尝试"); - //$data = array("error"=>$e->getMessage()); - } - } - // >>>>>>>>>>> F - $this ->getResponse() - ->setHeader('Content-Type', 'application/json') - ->appendBody(Zend_Json::encode($data)); - } - - }//acceptAction() 我的数据 diff --git a/application/default/views/scripts/author/accept.phtml b/application/default/views/scripts/author/accept.phtml new file mode 100644 index 00000000..23cff475 --- /dev/null +++ b/application/default/views/scripts/author/accept.phtml @@ -0,0 +1,86 @@ +headTitle($this->config->title->site); +$this->headTitle($this->config->title->author); +$this->headTitle()->setSeparator(' - '); +$this->headScript()->appendFile('/js/jquery-1.7.min.js'); +$this->headLink()->appendStylesheet('/css/author.css'); +$this->breadcrumb('首页'); +$this->breadcrumb('数据作者'); +$this->breadcrumb('我的数据'); +$this->breadcrumb()->setSeparator(' > '); +?> + + + + + +
+

请输入元数据标题关键字进行搜索

+
+ + +
+
+ paginator)): + echo "
+
+ + \ No newline at end of file