2013-05-03 06:41:06 +00:00
|
|
|
|
<?php
|
|
|
|
|
class view extends Zend_Controller_Plugin_Abstract
|
|
|
|
|
{
|
|
|
|
|
private $db; //传入PDO对象.
|
|
|
|
|
private $product = 0; //产品环境
|
|
|
|
|
|
|
|
|
|
function __construct($db='')
|
|
|
|
|
{
|
|
|
|
|
$this->db = $db;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static function addPaginator($data,$ctl,Zend_Controller_Request_Abstract $request)
|
|
|
|
|
{
|
|
|
|
|
$page = $request->getParam('page');
|
|
|
|
|
|
|
|
|
|
$paginator = Zend_Paginator::factory($data);
|
|
|
|
|
$paginator->setCurrentPageNumber($page);
|
|
|
|
|
$paginator->setItemCountPerPage(12);
|
|
|
|
|
$paginator->setView($ctl);
|
|
|
|
|
Zend_View_Helper_PaginationControl::setDefaultViewPartial('pagination_param.phtml');
|
|
|
|
|
$ctl->paginator = $paginator;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static function Msg($type,$content,$url=''){
|
|
|
|
|
$html = '<div class="alert '.$type.'">'."\r\n";
|
|
|
|
|
$html.= '<a data-dismiss="alert" class="close">×</a>'."\r\n";
|
|
|
|
|
$html.= $content."\r\n";
|
|
|
|
|
$html.= '</div>'."\r\n";
|
|
|
|
|
if(!empty($url))
|
|
|
|
|
{
|
|
|
|
|
if($url == -1){
|
|
|
|
|
$html.= '<script language="javascript">setTimeout("window.history.back(-1);",3000);</script>'."\r\n";
|
|
|
|
|
}else{
|
|
|
|
|
$html.= '<script language="javascript">setTimeout("self.location=\''.$url.'\'",3000);</script>'."\r\n";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return $html;
|
|
|
|
|
}
|
|
|
|
|
|
2013-05-09 03:53:27 +00:00
|
|
|
|
static function Error($content,$type='',$url=''){
|
2013-05-03 06:41:06 +00:00
|
|
|
|
if(empty($type))
|
|
|
|
|
{
|
|
|
|
|
$AlertType = "alert-error";
|
|
|
|
|
}else{
|
|
|
|
|
$AlertType = $type;
|
|
|
|
|
}
|
|
|
|
|
$html = '<div class="alert alert-block fade in '.$AlertType.'" id="Alert-error-box">'."\r\n";
|
|
|
|
|
$html.= '<a class="close" data-dismiss="alert" href="#">×</a>'."\r\n";
|
|
|
|
|
if(!is_array($content)) {
|
|
|
|
|
$html.= '<h4 class="alert-heading">'.$content.'</h4>'."\r\n";
|
|
|
|
|
}else{
|
|
|
|
|
$html.= '<ul>'."\r\n";
|
|
|
|
|
foreach($content as $v) {
|
|
|
|
|
$html.='<li>'.$v.'</li>'."\r\n";
|
|
|
|
|
}
|
|
|
|
|
$html.= '</ul>'."\r\n";
|
|
|
|
|
}
|
|
|
|
|
$html.= '</div>'."\r\n";
|
|
|
|
|
return $html;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static function User($param){
|
|
|
|
|
$auth = Zend_Auth::getInstance();
|
|
|
|
|
if($auth->hasIdentity())
|
|
|
|
|
{
|
|
|
|
|
$user = $auth->getIdentity();
|
|
|
|
|
return $user->$param;
|
|
|
|
|
}else{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static function Dump($data,$exit = true){
|
|
|
|
|
echo "<pre>";
|
|
|
|
|
var_dump($data);
|
|
|
|
|
echo "</pre>";
|
|
|
|
|
if($exit)
|
|
|
|
|
{
|
|
|
|
|
exit();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-05-21 09:37:33 +00:00
|
|
|
|
static function Post(Zend_Controller_Action $ctl,$msg,$url=""){
|
2013-05-03 06:41:06 +00:00
|
|
|
|
|
|
|
|
|
if(empty($msg))
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2013-05-21 09:37:33 +00:00
|
|
|
|
if(!is_array($msg))
|
2013-05-03 06:41:06 +00:00
|
|
|
|
{
|
2013-05-21 09:37:33 +00:00
|
|
|
|
$msg = array('content'=>$msg,'url'=>$url);
|
2013-05-03 06:41:06 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$helper = new Zend_Controller_Action_HelperBroker($ctl);
|
2013-05-21 09:37:33 +00:00
|
|
|
|
$helper->layout->setLayout('layout');
|
2013-05-03 06:41:06 +00:00
|
|
|
|
$helper->viewRenderer->setNoRender();
|
|
|
|
|
echo $ctl->view->partial('post-message.phtml', $msg);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2013-04-22 10:18:48 +00:00
|
|
|
|
}
|