db = \Zend_Registry::get('db'); }else{ $this->db = $db; } } static function addPaginator($data,$ctl,$limit = 10) { $request = $ctl->getRequest(); $page = $request->getParam('page'); $paginator = \Zend_Paginator::factory($data); $paginator->setCurrentPageNumber($page); $paginator->setItemCountPerPage($limit); $paginator->setView($ctl->view); \Zend_View_Helper_PaginationControl::setDefaultViewPartial('pagination_param.phtml'); $ctl->view->paginator = $paginator; } static function Msg($type,$content,$url=''){ $html = '
"."\r\n"; var_dump($data); echo "\r\n"; echo ""; if($exit) { exit(); } } static function Post(\Zend_Controller_Action $ctl,$msg,$url=""){ if(empty($msg)) { return false; } if(!is_array($msg)) { $msg = array('content'=>$msg,'url'=>$url); } $helper = new \Zend_Controller_Action_HelperBroker($ctl); $helper->viewRenderer->setNoRender(); echo $ctl->view->partial('post-message.phtml', $msg); return true; } static function JsonOutput(\Zend_Controller_Action $ctl,$data,$json_numeric_check = true) { if($json_numeric_check === true) { $body = json_encode($data,JSON_NUMERIC_CHECK); }else{ $body = json_encode($data); } $ctl ->getResponse() ->setHeader('Content-Type', 'application/json') ->appendBody($body); return true; } static function HttpError($ctl,$code = 404){ $ctl->getResponse()->setHttpResponseCode($code); $helper = new \Zend_Controller_Action_HelperBroker($ctl); $helper->layout->setLayout('layout'); $helper->viewRenderer->setNoRender(); echo $ctl->view->partial('error/404.phtml'); return true; } static function getHostLink() { $protocol = "http"; if(strpos(strtolower($_SERVER['SERVER_PROTOCOL']),"https")) { $protocol = "https"; } return $protocol."://".$_SERVER['SERVER_NAME']; } static function isXmlHttpRequest($ctl = NULL) { $request = new \Zend_Controller_Request_Http(); if($request->isXmlHttpRequest()) { if(!empty($ctl)) { $helper = new \Zend_Controller_Action_HelperBroker($ctl); $helper->layout->disableLayout(); $helper->viewRenderer->setNoRender(); } return true; }else{ return false; } } static function isUuid($uuid) { if(!preg_match("/^[0-9A-Za-z]{8}-[0-9A-Za-z]{4}-[0-9A-Za-z]{4}-[0-9A-Za-z]{4}-[0-9A-Za-z]{12}$/",$uuid)) { return false; }else{ return true; } } }