westdc-zf1/application/models/helper/view.php

83 lines
2.0 KiB
PHP
Raw Normal View History

2013-04-24 11:07:25 +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;
}
static function Error($type,$content,$url=''){
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-04-22 10:18:48 +00:00
}