更新助手类,添加新功能 getHostLink()

This commit is contained in:
Li Jianxuan 2013-07-24 10:09:19 +00:00
parent d33d9934be
commit 7fe66c8b4b
2 changed files with 21 additions and 7 deletions

View File

@ -80,6 +80,10 @@ class dbh
{
$v = preg_replace("/\'/","''",$v);
}
if(preg_match("/\"/",$v))
{
$v = preg_replace("/\"/","''",$v);
}
$ups[] = '"'.$k.'"=\''.$v."'";
}
}

View File

@ -1,5 +1,5 @@
<?php
class view extends Zend_Controller_Plugin_Abstract
class view extends \Zend_Controller_Plugin_Abstract
{
private $db; //传入PDO对象.
private $product = 0; //产品环境
@ -9,7 +9,7 @@ class view extends Zend_Controller_Plugin_Abstract
$this->db = $db;
}
static function addPaginator($data,$ctl,Zend_Controller_Request_Abstract $request = NULL,$limit = 10)
static function addPaginator($data,$ctl,\Zend_Controller_Request_Abstract $request = NULL,$limit = 10)
{
if(empty($request))
{
@ -21,11 +21,11 @@ class view extends Zend_Controller_Plugin_Abstract
$view = $ctl;
}
$paginator = Zend_Paginator::factory($data);
$paginator = \Zend_Paginator::factory($data);
$paginator->setCurrentPageNumber($page);
$paginator->setItemCountPerPage($limit);
$paginator->setView($view);
Zend_View_Helper_PaginationControl::setDefaultViewPartial('pagination_param.phtml');
\Zend_View_Helper_PaginationControl::setDefaultViewPartial('pagination_param.phtml');
$view->paginator = $paginator;
}
@ -70,7 +70,7 @@ class view extends Zend_Controller_Plugin_Abstract
}
static function User($param){
$auth = Zend_Auth::getInstance();
$auth = \Zend_Auth::getInstance();
if($auth->hasIdentity())
{
$user = $auth->getIdentity();
@ -90,7 +90,7 @@ class view extends Zend_Controller_Plugin_Abstract
}
}
static function Post(Zend_Controller_Action $ctl,$msg,$url=""){
static function Post(\Zend_Controller_Action $ctl,$msg,$url=""){
if(empty($msg))
{
@ -101,10 +101,20 @@ class view extends Zend_Controller_Plugin_Abstract
$msg = array('content'=>$msg,'url'=>$url);
}
$helper = new Zend_Controller_Action_HelperBroker($ctl);
$helper = new \Zend_Controller_Action_HelperBroker($ctl);
$helper->layout->setLayout('layout');
$helper->viewRenderer->setNoRender();
echo $ctl->view->partial('post-message.phtml', $msg);
return true;
}
static function getHostLink()
{
$protocol = "http";
if(strpos(strtolower($_SERVER['SERVER_PROTOCOL']),"https"))
{
$protocol = "https";
}
return $protocol."://".$_SERVER['SERVER_NAME'];
}
}