コード例 #1
0
ファイル: refer_controller.php プロジェクト: tilitala/nForum
 public function index()
 {
     if (!isset($this->params['type'])) {
         $this->error(ECode::$REFER_NONE);
     }
     $type = $this->params['type'];
     try {
         $refer = new Refer(User::getInstance(), $type);
     } catch (ReferNullException $e) {
         $this->error(ECode::$REFER_NONE);
     }
     $count = isset($this->params['url']['count']) ? $this->params['url']['count'] : Configure::read("pagination.mail");
     if (($count = intval($count)) <= 0) {
         $count = Configure::read('pagination.mail');
     }
     if ($count > Configure::read('plugins.api.page_item_limit')) {
         $count = Configure::read('pagination.mail');
     }
     $page = isset($this->params['url']['page']) ? $this->params['url']['page'] : 1;
     $page = intval($page);
     $pagination = new Pagination($refer, $count);
     $articles = $pagination->getPage($page);
     $wrapper = Wrapper::getInstance();
     $info = array();
     foreach ($articles as $v) {
         $info[] = $wrapper->refer($v);
     }
     $data['description'] = $refer->getDesc();
     $data['pagination'] = $wrapper->page($pagination);
     $data['article'] = $info;
     $this->set('data', $data);
 }
コード例 #2
0
ファイル: refer_controller.php プロジェクト: tilitala/nForum
 public function index()
 {
     $this->js[] = "forum.refer.js";
     $this->css[] = "mail.css";
     $type = Refer::$AT;
     $pageBar = "";
     if (isset($this->params['type'])) {
         $type = $this->params['type'];
     }
     try {
         $refer = new Refer(User::getInstance(), $type);
     } catch (ReferNullException $e) {
         $this->error(ECode::$REFER_NONE);
     }
     $this->notice = 'ндублАпя-' . $refer->getDesc();
     $p = isset($this->params['url']['p']) ? $this->params['url']['p'] : 1;
     App::import('vendor', "inc/pagination");
     try {
         $pagination = new Pagination($refer, Configure::read("pagination.mail"));
         $articles = $pagination->getPage($p);
     } catch (Exception $e) {
         $this->error(ECode::$REFER_NONE);
     }
     if ($refer->getTotalNum() > 0) {
         $info = array();
         App::import('Sanitize');
         foreach ($articles as $v) {
             $info[] = array("index" => $v['INDEX'], "id" => $v['ID'], "board" => $v['BOARD'], "user" => $v['USER'], "title" => Sanitize::html($v['TITLE']), "time" => date("Y-m-d H:i:s", $v['TIME']), "read" => $v['FLAG'] === Refer::$FLAG_READ);
         }
         $this->set("info", $info);
     }
     $this->set("type", $type);
     $this->set("totalNum", $pagination->getTotalNum());
     $this->set("curPage", $pagination->getCurPage());
     $this->set("totalPage", $pagination->getTotalPage());
 }
コード例 #3
0
ファイル: refer_controller.php プロジェクト: tilitala/nForum
 public function ajax_delete()
 {
     if (!$this->RequestHandler->isPost()) {
         $this->error(ECode::$SYS_REQUESTERROR);
     }
     if (!isset($this->params['type'])) {
         $this->error(ECode::$REFER_NONE);
     }
     $type = $this->params['type'];
     try {
         $refer = new Refer(User::getInstance(), $type);
     } catch (ReferNullException $e) {
         $this->error(ECode::$REFER_NONE);
     }
     if (isset($this->params['form']['all'])) {
         //delete all
         $refer->delete();
     } else {
         //delete normal
         foreach ($this->params['form'] as $k => $v) {
             if (!preg_match("/m_/", $k)) {
                 continue;
             }
             $num = split("_", $k);
             $refer->delete(intval($num[1]));
         }
     }
     $ret['ajax_code'] = ECode::$REFER_DELETEOK;
     $ret['default'] = "/refer/{$type}";
     $ret['list'][] = array("text" => $refer->getDesc(), "url" => "/refer/{$type}");
     $this->set('no_html_data', $ret);
 }