diff --git a/Westdc/Helpers/Assist.php b/Westdc/Helpers/Assist.php index cab69e7..91bab44 100644 --- a/Westdc/Helpers/Assist.php +++ b/Westdc/Helpers/Assist.php @@ -14,7 +14,7 @@ class Assist } - static function addPaginator($data,$ctl,$limit = 10,$viewPartial = "layout/manager/pagination") + static function addPaginator($data,$ctl,$limit = 10,$viewPartial = "layout/manager/pagination" ) { $request = $ctl->getRequest(); $page = $ctl->params()->fromRoute('page'); @@ -33,8 +33,10 @@ class Assist $paginator->setDefaultScrollingStyle('Sliding'); $pagination = $ctl->getServiceLocator()->get('viewhelpermanager')->get('PaginationControl'); - $renderer = $ctl->getServiceLocator()->get('Zend\View\Renderer\PhpRenderer'); - $paginator->setView($renderer); + $renderer = $ctl->getServiceLocator()->get('Zend\View\Renderer\PhpRenderer'); + + $paginator->setView($renderer); + $pagination->setDefaultViewPartial($viewPartial); $ctl->ViewModel->setVariable('paginator',$paginator); diff --git a/Westdc/Helpers/Paginator.php b/Westdc/Helpers/Paginator.php new file mode 100644 index 0000000..5b37e77 --- /dev/null +++ b/Westdc/Helpers/Paginator.php @@ -0,0 +1,62 @@ +serviceManager = $serviceManager; + + return $this; + } + + public function add($data,$ctl,$limit = 10,$route = "",$viewPartial = "layout/manager/pagination") + { + $page = $ctl->params()->fromRoute('page'); + + if(is_array($data)) + $data = new ArrayAdapter($data); + + if($data instanceof Select) + { + $dbService = $this->serviceManager->get('Db'); + $zendDb = $dbService->getZendDb(); + $data = new DbSelect($data,$zendDb); + } + + if($data instanceof TableGateway) + $data = new DbTableGateway($data,$this->sqlQuery,$this->sqlOrder,$this->sqlGroup,$this->sqlHaving); + + $paginator = new Zend_Paginator($data); + $paginator->setCurrentPageNumber($page) + ->setItemCountPerPage($limit) + ->setPageRange(6); + + $pagination = $ctl->getServiceLocator()->get('viewhelpermanager')->get('PaginationControl'); + $pageSliding = $pagination($paginator,'Sliding',$viewPartial,array('route'=>$route)); + + $ctl->ViewModel->setVariable('pagination',$pageSliding); + $ctl->ViewModel->setVariable('paginator',$paginator); + } + +} \ No newline at end of file diff --git a/Westdc/Mail/Mail.php b/Westdc/Mail/Mail.php index b0a5590..6a7b120 100644 --- a/Westdc/Mail/Mail.php +++ b/Westdc/Mail/Mail.php @@ -15,7 +15,6 @@ use Westdc\Service\ServiceManager as WestdcServiceManager; use Zend\Mail\Message; use Zend\Mail\Transport\Smtp as SmtpTransport; use Zend\Mail\Transport\SmtpOptions; -use Zend\Mime\Mime; use Zend\Mime\Message as MimeMessage; use Zend\Mime\Part as MimePart; @@ -130,6 +129,10 @@ class Mail extends AbstractEventManager implements ServiceManagerAwareInterface{ } + /** + * @param null $from + * @return bool + */ public function preSend($from = NULL) { if(empty($this->subject) || empty($this->body)) @@ -168,6 +171,9 @@ class Mail extends AbstractEventManager implements ServiceManagerAwareInterface{ //使用loadTemplate 的结果发送邮件 //在此之前需要使用 $this->mail->addTo()添加收件人 + /** + * @param null $from + */ public function send($from = NULL){ if(!$status = $this->preSend($from)) diff --git a/Westdc/Reference/Reference.php b/Westdc/Reference/Reference.php index 47c9655..c19b6ae 100644 --- a/Westdc/Reference/Reference.php +++ b/Westdc/Reference/Reference.php @@ -1,15 +1,15 @@ db = \Zend_Registry::get('db'); - }else{ - $this->db = $db; - } - - $this->config = \Zend_Registry::get('config'); - - $Listener = new ReferenceListener(); - @$this->events()->attachAggregate($Listener); - - $this->table = new \Helpers\Table(); + } - - public function events(\Zend_EventManager_EventCollection $events = NULL) + + public function setServiceManager(ServiceManager $serviceManager) { - if ($events !== NULL) { - $this->events = $events; - } elseif ($this->events === NULL) { - $this->events = new \Zend_EventManager_EventManager(__CLASS__); - } - return $this->events; + $this->serviceManager = $serviceManager; + + $this->init(); + + return $this; } + + private function init(){ + $dbService = $this->serviceManager->get('Db'); + $this->db = $dbService->getPdo(); + unset($dbService); + + $this->table = new \stdClass(); + $this->table->reference = "reference"; + $this->table->reference_author = "ref_author"; + $this->table->source = "source"; + } + public function reference($id = 0) { @@ -170,7 +169,7 @@ class Reference } //所有文献 - public function fetchReferences() + public function fetchAll() { $wheresql = array(); if(!empty($this->keyword)) @@ -209,7 +208,7 @@ class Reference $order = "{$this->table->reference}.{$this->order}"; } - $sql = "SELECT {$this->table->reference}.* FROM + $sql = "SELECT {$this->table->reference}.* FROM {$this->table->reference} $wheresql ORDER BY $order {$this->sort}"; @@ -240,7 +239,7 @@ class Reference $order = "ref.{$this->order} {$this->sort}"; } - $sql="select distinct ref.* from {$this->table->reference} ref where ref.id in (select r.refid from mdref r + $sql="select distinct ref.* from {$this->table->reference} ref where ref.id in (select r.refid from mdref r left join datasource ds on r.uuid=ds.uuid left join {$this->table->source} s on s.id=ds.sourceid where s.code='$code') $wheresql