Chinaunix首页 | 论坛 | 博客
  • 博客访问: 72378
  • 博文数量: 67
  • 博客积分: 1334
  • 博客等级: 中尉
  • 技术积分: 670
  • 用 户 组: 普通用户
  • 注册时间: 2011-03-08 10:56
文章分类

全部博文(67)

文章存档

2016年(2)

2015年(2)

2012年(9)

2011年(54)

我的朋友
最近访客

分类: 系统运维

2011-12-05 18:48:16

  1. <?php
  2. /**
  3.  *
  4.  * Enter description here ...
  5.  * @author maofeng
  6.  *
  7.  */
  8. class DemoController extends Zend_Controller_Action
  9. {

  10.     public function init() {
  11.         $this->registry = Zend_Registry::getInstance();
  12.         $this->view = $this->registry['view'];
  13.         
  14.         $this->_helper->addPath('library/Mf/Helpers/', 'Mf_Helpers');//增加控制器助手目录
  15.     }
  16.     
  17.     /**
  18.      *
  19.      * Enter description here ...
  20.      */
  21.     public function indexAction(){
  22.         
  23.         
  24.     }
  25.     
  26.     /**
  27.      *controller 分页助手使用demo
  28.      * Enter description here ...
  29.      */
  30.     public function paginateAction(){
  31.         $currenPage = $this->_request->getParam('page');
  32.         if($currenPage == null){ $currenPage = 1; }
  33.         
  34.         $Paginate = $this->_helper->getHelper('Paginate');
  35.         $page = $Paginate->number(array('controller'=>'demo', 'action'=>'paginate', 'total'=>1010, 'current'=>$currenPage, 'pageSize'=>5, 'showSize'=>20));

  36.         $this->view->assign('page', $page);
  37.         echo $this->view->render('demo/paginate.phtml');
  38.         
  39.     }
  40.     
  41.     /**
  42.      * controller 绝对路径demo
  43.      * Enter description here ...
  44.      */
  45.     public function realpathAction(){
  46.         $realPath = $this->_helper->getHelper('RealPath');
  47.         echo $realPath->getRealPath();
  48.     }
  49.     
  50.     /**
  51.      *
  52.      * controller 文件读写助手 demo
  53.      * read() 返回 /public/attachment/demo.txt 的内容 ,如果文件不存在则返回空
  54.      * write() 写入操作
  55.      * Enter description here ...
  56.      */
  57.     
  58.     public function readAction(){
  59.         $file = $this->_helper->getHelper('File');
  60.         echo $file->read(array('public', 'attachment', 'demo.txt'));
  61.     }
  62.     
  63.     public function writeAction(){
  64.         $file = $this->_helper->getHelper('File');          
  65.         $file->write(array('public', 'attachment', 'w.txt'), 'conn123');     
  66.     }
  67.     
  68.     public function uploadAction(){
  69.     
  70.         $file = $this->_helper->getHelper('File');
  71.         $file->upload('fileName', array('public', 'attachment'), 'newName123456', array('tailer'=>array('txt'), 'size'=>102400 ));
  72.         
  73.         echo $this->view->render('demo/upload.phtml');
  74.     }
  75.     
  76.     public function downloadAction(){
  77.         $file = $this->_helper->getHelper('File');
  78.         $file->download(array('public', 'attachment', 'demo.txt'));
  79.     }
  80.     
  81.     
  82.     
  83. }

  84. ?>
阅读(616) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~