From 5c67768166dfb0eb2239f6a7020eacaa9dca13df Mon Sep 17 00:00:00 2001 From: wlx Date: Wed, 9 Nov 2011 02:47:52 +0000 Subject: [PATCH] add mdjsonAction --- .../default/controllers/ServiceController.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/application/default/controllers/ServiceController.php b/application/default/controllers/ServiceController.php index c818146f..2fed1b05 100644 --- a/application/default/controllers/ServiceController.php +++ b/application/default/controllers/ServiceController.php @@ -741,6 +741,21 @@ class ServiceController extends Zend_Controller_Action throw new Exception('发生严重意外!您确认链接正确?'); } + } + + function mdjsonAction() + { + $this->_helper->layout->disableLayout(); + $this->_helper->viewRenderer->setNoRender(); + $num=(int)$this->_request->getParam('num'); + $source=$this->_request->getParam('source'); + if (empty($num)) $num=3; + $sql="select m.uuid,m.title,m.id,substring(m.description from 0 for 200) as description from normalmetadata m left join thumbnail t on m.id=t.id where "; + if (!empty($source)) + $sql.=$this->db->quoteInto(" m.uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code=?) and ",$source); + $sql.=" length(t.data)>2 order by random() limit $num"; + $rows=$this->db->fetchAll($sql); + echo Zend_Json::encode($rows); } }