/** * 查询多条记录 * @param integer $paged * @return array */ public function findRows($paged = 0) { $paged = max((int) $paged, 1); $limit = PageHelper::getListRows(); $offset = PageHelper::getFirstRow($paged, $limit); $rows = $this->getService()->findRows(array(), '', $limit, $offset, 'SQL_CALC_FOUND_ROWS'); return $rows; }
/** * (non-PHPdoc) * @see \tfc\mvc\interfaces\Action::run() */ public function run() { $req = Ap::getRequest(); $mod = Model::getInstance('Topic', 'topic'); $paged = PageHelper::getCurrPage(); $ret = $mod->findRows($paged); $this->render($ret); }
/** * (non-PHPdoc) * @see \tfc\mvc\interfaces\Action::run() */ public function run() { Text::_('MOD_MEMBER__'); $httpReferer = PageHelper::getHttpReferer(); if ($httpReferer === '' || strpos($httpReferer, '?r=member/show') !== false) { $httpReferer = 'index.php'; } $this->assign('http_referer', $httpReferer); $this->render(); }
/** * (non-PHPdoc) * @see \tfc\mvc\interfaces\Action::run() */ public function run() { $req = Ap::getRequest(); $postId = $req->getInteger('postid'); $order = $req->getTrim('order', 'dt_last_modified DESC'); $paged = PageHelper::getCurrPage(); $mod = Model::getInstance('Comments', 'posts'); $ret = $mod->getRowsByPostId($postId, $order, $paged); $this->display($ret); }
/** * 获取最后一次访问的列表页参数 * @param array $params * @return array */ public function getLLUParams(array $params = array()) { $attributes = isset($params['attributes']) ? (array) $params['attributes'] : array(); $order = isset($params['order']) ? trim($params['order']) : ''; $listRows = isset($params['limit']) ? (int) $params['limit'] : 0; $firstRow = isset($params['offset']) ? (int) $params['offset'] : 0; if ($order !== '') { $attributes['order'] = $order; } if ($listRows <= 0) { return $attributes; } if ($listRows !== (int) Cfg::getApp('list_rows', 'paginator')) { $attributes[PageHelper::getListRowsVar()] = $listRows; } $firstRow = max($firstRow, 0); $currPage = floor($firstRow / $listRows) + 1; if ($currPage > 0) { $attributes[PageHelper::getPageVar()] = $currPage; } return $attributes; }
/** * (non-PHPdoc) * @see \tfc\mvc\interfaces\Action::run() */ public function run() { $req = Ap::getRequest(); $catId = $req->getInteger('catid'); if ($catId <= 0) { $this->err404(); } $order = $req->getTrim('order', ''); $paged = PageHelper::getCurrPage(); $category = Model::getInstance('Categories', 'posts')->findByPk($catId); if (!$category || !is_array($category)) { $this->err404(); } $tplName = isset($category['tpl_list']) ? Mvc::$module . DS . $category['tpl_list'] : null; $this->assign('category', $category); $this->assign('meta_title', isset($category['meta_title']) ? $category['meta_title'] : ''); $this->assign('meta_keywords', isset($category['meta_keywords']) ? $category['meta_keywords'] : ''); $this->assign('meta_description', isset($category['meta_description']) ? $category['meta_description'] : ''); $this->assign('url', UrlHelper::getInstance()->getPostIndex($category)); $mod = Model::getInstance('Posts', 'posts'); $ret = $mod->findRows(array('category_id' => $catId), $order, $paged); $this->render($ret, $tplName); }
/** * (non-PHPdoc) * @see \tfc\mvc\interfaces\Action::run() */ public function run() { $ret = array(); $this->assignSystem(); $this->assignUrl(); $this->assignLanguage(); $req = Ap::getRequest(); $viw = Mvc::getView(); $mod = new Account(); if ($req->isPost()) { $loginName = $req->getTrim('login_name'); $password = $req->getTrim('password'); $rememberMe = (bool) $req->getInteger('remember_me'); $ret = $mod->login($loginName, $password, $rememberMe); } $httpReferer = PageHelper::getHttpReferer(); if ($httpReferer === '') { $httpReferer = 'administrator.php'; } $viw->assign('http_referer', $httpReferer); $viw->assign($ret); $tplName = $this->getDefaultTplName(); $viw->display($tplName); }
/** * (non-PHPdoc) * @see \tfc\mvc\interfaces\Action::run() */ public function run() { $httpReferer = PageHelper::getHttpReferer(); $this->assign('http_referer', $httpReferer); $this->render(); }
/** * 获取分页处理类 * @return \tfc\util\Paginator */ public function getPaginator() { // 总的记录数 <= 0,表示不需要分页 if (($totalRows = $this->getTotalRows()) <= 0) { return null; } $attributes = isset($this->_tplVars['attributes']) ? (array) $this->_tplVars['attributes'] : array(); $order = isset($this->_tplVars['order']) ? trim($this->_tplVars['order']) : ''; $listRows = isset($this->_tplVars['limit']) ? (int) $this->_tplVars['limit'] : 0; $firstRow = isset($this->_tplVars['offset']) ? (int) $this->_tplVars['offset'] : 0; // 每页展示的行数 <= 0,表示第一页展示所有数据 if ($listRows <= 0) { return null; } if ($order !== '') { $attributes['order'] = $order; } if ($listRows !== (int) Cfg::getApp('list_rows', 'paginator')) { $attributes[PageHelper::getListRowsVar()] = $listRows; } $firstRow = max($firstRow, 0); $currPage = floor($firstRow / $listRows) + 1; $url = $this->getUrlManager()->getUrl(Mvc::$action, Mvc::$controller, Mvc::$module, $attributes); $paginator = new Paginator($totalRows, $url, PageHelper::getPageVar()); $paginator->setListPages(PageHelper::getListPages()); $paginator->setListRows($listRows); $paginator->setCurrPage($currPage); return $paginator; }
/** * (non-PHPdoc) * @see \tfc\mvc\interfaces\Action::run() */ public function run() { Text::_('MOD_MEMBER__'); $this->assign('http_referer', PageHelper::getHttpReferer()); $this->render(); }
/** * 查询数据列表 * @param array $params * @param string $order * @param integer $limit * @param integer $offset * @return array */ public function search(array $params = array(), $order = '', $limit = null, $offset = null) { if ($limit === null) { $limit = PageHelper::getListRows(); } if ($offset === null) { $offset = PageHelper::getFirstRow(); } $ret = $this->callFetchMethod($this->getService(), 'findAll', array($params, $order, $limit, $offset, 'SQL_CALC_FOUND_ROWS')); if ($ret['err_no'] !== ErrorNo::SUCCESS_NUM) { return $ret; } $data = $ret['data']['rows']; unset($ret['data']['rows']); $ret['paginator'] = $ret['data']; $ret['data'] = $data; return $ret; }
/** * 获取分页处理类 * @return \tfc\util\Paginator */ public function getPaginator() { // 总的记录数 <= 0,表示不需要分页 if (($totalRows = $this->getTotalRows()) <= 0) { return null; } // 每页展示的行数 <= 0,表示不需要分页 if (($listRows = $this->getListRows()) <= 0) { return null; } $firstRow = max($this->getFirstRow(), 0); $currPage = floor($firstRow / $listRows) + 1; $paginator = new Paginator($totalRows, $this->getUrl(), PageHelper::getPageVar()); $paginator->setListPages(PageHelper::getListPages()); $paginator->setListRows($listRows); $paginator->setCurrPage($currPage); return $paginator; }