public function defaultAction() { $pageSize = 20; // 获取参数 $page = Pager::get(); $title = Request::getGET('title'); $status = (int) Request::getGET('status'); // 构建where $where = array(array('user_id', '=', $this->loginUserInfo['id']), array('is_diy', '=', 1)); if (!empty($status) && $status != -1) { $where[] = array('hidden', '=', $status - 1); } if (!empty($title)) { $where[] = array('title', 'LIKE', "%{$title}%"); } // 获取数据 $offset = ($page - 1) * $pageSize; $contestList = OjContestInterface::getList(array('where' => $where, 'limit' => $pageSize, 'offset' => $offset)); $allCount = 0; if (!empty($contestList)) { $allCount = OjContestInterface::getCount($where); } $userIds = array_unique(array_column($contestList, 'user_id')); $userHash = UserCommonInterface::getById(array('id' => $userIds)); // 缓存部分的html $html = array(); $html['pager'] = $this->view->fetch(array('renderAllCount' => $allCount, 'renderPageSize' => $pageSize, 'renderRadius' => 8), 'widget/pager.php'); // 输出 $this->renderFramework(array('contestList' => $contestList, 'userHash' => $userHash, 'html' => $html), 'setup/contest/list.php'); }
public function defaultAction() { $pageSize = 20; // 获取参数 $page = Pager::get(); $status = (int) Request::getGET('status', -1); $contestId = (int) Request::getGET('contest-id', 0); $where = array(); $where[] = array('is_diy', '=', 0); if (!empty($contestId)) { $where[] = array('contest_id', '=', $contestId); } if ($status != -1) { $where[] = array('status', '=', $status); } // 获取数据 $offset = ($page - 1) * $pageSize; $applyList = OjContestApplyInterface::getList(array('where' => $where, 'limit' => $pageSize, 'offset' => $offset)); $allCount = 0; $userHash = array(); $contestHash = array(); if (!empty($applyList)) { $allCount = OjContestApplyInterface::getCount($where); $userIds = array_column($applyList, 'user_id'); $userHash = UserCommonInterface::getById(array('id' => $userIds)); $contestIds = array_unique(array_column($applyList, 'contest_id')); $contestHash = OjContestInterface::getById(array('id' => $contestIds)); } // 缓存部分的html $html = array(); $html['pager'] = $this->view->fetch(array('renderAllCount' => $allCount, 'renderPageSize' => $pageSize, 'renderRadius' => 8), 'widget/pager.php'); $this->renderFramework(array('html' => $html, 'applyList' => $applyList, 'contestHash' => $contestHash, 'userHash' => $userHash), 'contest/apply_list.php'); }
public function defaultAction() { $pageSize = 20; // 获取参数 $page = Pager::get(); $status = (int) Request::getGET('status'); // 构建where $where = array(); $where[] = array('remote', '=', StatusVars::REMOTE_HQU); $where[] = array('user_id', '=', $this->loginUserInfo['id']); if (!empty($status) && $status != -1) { $where[] = array('hidden', '=', $status - 1); } // 获取数据 $offset = ($page - 1) * $pageSize; $problemList = OjProblemInterface::getList(array('where' => $where, 'limit' => $pageSize, 'offset' => $offset)); $allCount = OjProblemInterface::getCount($where); $userIds = array_unique(array_column($problemList, 'user_id')); $userHash = UserCommonInterface::getById(array('id' => $userIds)); // 缓存部分的html $html = array(); $html['pager'] = $this->view->fetch(array('renderAllCount' => $allCount, 'renderPageSize' => $pageSize, 'renderRadius' => 5), 'widget/pager.php'); // 输出 $this->renderFramework(array('problemList' => $problemList, 'userHash' => $userHash, 'html' => $html), 'setup/problem/list.php'); }
public function defaultAction() { $pageSize = 50; $page = Pager::get(); $category = (int) Request::getGET('category', -1); $title = trim(Request::getGET('title', '')); $username = trim(Request::getGET('username', '')); $where = array(); if ($category != -1) { $where[] = array('category', '=', $category); } if (!empty($username)) { $userInfo = UserCommonInterface::getByLoginName(array('login_name' => $username)); $where[] = array('user_id', '=', Arr::get('id', $userInfo, 0)); } if (!empty($title)) { $where[] = array('title', 'LIKE', "%{$title}%"); } if ($category != -1) { $order = array('hidden' => 'ASC', 'title' => 'ASC', 'id' => 'DESC'); } else { $order = array('id' => 'DESC'); } $offset = ($page - 1) * $pageSize; $docList = DocInterface::getList(array('where' => $where, 'order' => $order, 'limit' => $pageSize, 'offset' => $offset)); $allCount = empty($docList) ? 0 : DocInterface::getCount($where); $userIds = array_unique(array_column($docList, 'user_id')); $userHash = UserCommonInterface::getById(array('id' => $userIds)); // 缓存部分的html $html = array(); $html['pager'] = $this->view->fetch(array('renderAllCount' => $allCount, 'renderPageSize' => $pageSize, 'renderRadius' => 7), 'widget/pager.php'); $this->renderFramework(array('html' => $html, 'docList' => $docList, 'userHash' => $userHash), 'doc/list.php'); }
public function defaultAction() { $pageSize = 50; // 获取参数 $page = Pager::get(); $contestId = (int) Request::getGET('contest-id'); $status = (int) Request::getGET('status', -1); $contestInfo = OjContestInterface::getById(array('id' => $contestId)); if (empty($contestInfo) || $contestInfo['hidden'] || $contestInfo['type'] != ContestVars::TYPE_APPLY) { $this->renderError('竞赛不存在,或者竞赛不需要报名!'); } // 构建where $where = array(); $where[] = array('contest_id', '=', $contestId); if ($status != -1) { $where[] = array('status', '=', $status); } // 获取数据 $offset = ($page - 1) * $pageSize; $applyList = OjContestApplyInterface::getList(array('where' => $where, 'limit' => $pageSize, 'offset' => $offset)); $allCount = OjContestApplyInterface::getCount($where); // userHash $userIds = array_unique(array_column($applyList, 'user_id')); $userHash = UserCommonInterface::getById(array('id' => $userIds)); // 缓存部分的html $html = array(); $html['pager'] = $this->view->fetch(array('renderAllCount' => $allCount, 'renderPageSize' => $pageSize, 'renderRadius' => 8), 'widget/pager.php'); $this->renderFramework(array('html' => $html, 'applyList' => $applyList, 'contestInfo' => $contestInfo, 'userHash' => $userHash), 'contest/apply_list.php'); }
public function defaultAction() { $pageSize = 20; // 获取参数 $page = Pager::get(); $title = Request::getGET('title'); $status = (int) Request::getGET('status'); // 构建where $where = array(); $where[] = array('user_id', '=', $this->loginUserInfo['id']); if (!empty($title)) { $where[] = array('title', 'LIKE', "%{$title}%"); } if (!empty($status) && $status != -1) { $where[] = array('hidden', '=', $status - 1); } // 获取数据 $order = array('refresh_at' => 'DESC', 'id' => 'DESC'); $offset = ($page - 1) * $pageSize; $setList = OjProblemSetInterface::getList(array('where' => $where, 'order' => $order, 'limit' => $pageSize, 'offset' => $offset)); $allCount = OjProblemSetInterface::getCount($where); foreach ($setList as &$setInfo) { $problemJson = $setInfo['problem_set']; $globalIds = (array) json_decode($problemJson, true); $setInfo['count'] = count($globalIds); } // 缓存部分的html $html = array(); $html['pager'] = $this->view->fetch(array('renderAllCount' => $allCount, 'renderPageSize' => $pageSize, 'renderRadius' => 8), 'widget/pager.php'); // 输出 $this->renderFramework(array('html' => $html, 'setList' => $setList), 'setup/set/list.php'); }
public function defaultAction() { $pageSize = 100; // 获取参数 $page = Pager::get(); $remote = (int) Request::getGET('remote', 0); $keyword = Request::getGET('keyword'); $searchType = (int) Request::getGET('search-type', 1); // 构建where $where = array(); $where[] = array('remote', '=', $remote); $where[] = array('hidden', '=', 0); if (!empty($keyword)) { if ($searchType == 1) { $where[] = array('OR' => array(array('problem_code', '=', $keyword), array('title', 'LIKE', "%{$keyword}%"))); } else { if ($searchType == 2) { $where[] = array('OR' => array(array('problem_code', '=', $keyword), array('source', 'LIKE', "%{$keyword}%"))); } } } // 获取数据 $order = array('problem_code' => 'ASC'); $offset = ($page - 1) * $pageSize; $problemList = OjProblemInterface::getList(array('where' => $where, 'order' => $order, 'limit' => $pageSize, 'offset' => $offset)); $allCount = OjProblemInterface::getCount($where); // 获取用户解决的题目 $userSolution = array(); if ($this->loginUserInfo) { $globalIds = array_column($problemList, 'id'); $where = array(array('user_id', '=', $this->loginUserInfo['id']), array('contest_id', '=', 0), array('problem_global_id', 'IN', $globalIds)); $solutionList = OjSolutionInterface::getList(array('where' => $where)); foreach ($solutionList as $solutionId => $solutionInfo) { $globalId = $solutionInfo['problem_global_id']; if (!array_key_exists($globalId, $userSolution) || $solutionInfo['result'] == StatusVars::ACCEPTED) { $userSolution[$globalId] = $solutionInfo; } } } $userHash = array(); if ($allCount > 0) { $userIds = array_unique(array_column($problemList, 'user_id')); $userHash = UserCommonInterface::getById(array('id' => $userIds)); } // 缓存部分的html $html = array(); $html['pager'] = $this->view->fetch(array('renderAllCount' => $allCount, 'renderPageSize' => $pageSize, 'renderRadius' => 10), 'widget/pager.php'); $tpl = $remote ? 'problem/list_remote.php' : 'problem/list.php'; // 输出 $this->renderFramework(array('html' => $html, 'problemList' => $problemList, 'userSolution' => $userSolution, 'userHash' => $userHash), $tpl); }
public function defaultAction() { $pageSize = 25; $page = Pager::get(); $order = array('solved_all' => 'DESC', 'submit_all' => 'DESC', 'id' => 'ASC'); $offset = ($page - 1) * $pageSize; $userList = UserCommonInterface::getList(array('order' => $order, 'limit' => $pageSize, 'offset' => $offset)); $allCount = UserCommonInterface::getCount(); // 缓存部分的html $html = array(); $html['pager'] = $this->view->fetch(array('renderAllCount' => $allCount, 'renderPageSize' => $pageSize, 'renderRadius' => 10), 'widget/pager.php'); // 输出 $this->renderFramework(array('userList' => $userList, 'html' => $html, 'beginRank' => $offset + 1), 'rank/list.php'); }
public function defaultAction() { $pageSize = 50; // 获取参数 $page = Pager::get(); $title = Request::getGET('title'); $status = (int) Request::getGET('status'); $username = Request::getGET('username'); // userInfo $userInfo = array(); if (!empty($username)) { $userInfo = UserCommonInterface::getByLoginName(array('login_name' => $username)); } // 构建where if (!empty($username) && empty($userInfo)) { $where = false; } else { $where = array(); if (!empty($userInfo)) { $where[] = array('user_id', '=', $userInfo['id']); } if (!empty($status) && $status != -1) { $where[] = array('hidden', '=', $status - 1); } if (!empty($title)) { $where[] = array('title', 'LIKE', "%{$title}%"); } } $order = array('listing_status' => 'DESC', 'refresh_at' => 'DESC', 'id' => 'DESC'); $offset = ($page - 1) * $pageSize; $setList = OjProblemSetInterface::getList(array('where' => $where, 'order' => $order, 'limit' => $pageSize, 'offset' => $offset)); $allCount = 0; if (!empty($setList)) { $allCount = OjProblemSetInterface::getCount($where); } foreach ($setList as &$setInfo) { $globalIds = (array) json_decode($setInfo['problem_set'], true); $setInfo['count'] = count($globalIds); } // 获取用户 $userIds = array_unique(array_column($setList, 'user_id')); $userHash = UserCommonInterface::getById(array('id' => $userIds)); // 缓存部分的html $html = array(); $html['pager'] = $this->view->fetch(array('renderAllCount' => $allCount, 'renderPageSize' => $pageSize, 'renderRadius' => 8), 'widget/pager.php'); // 输出 $this->renderFramework(array('html' => $html, 'setList' => $setList, 'userHash' => $userHash), 'set/list.php'); }
public function defaultAction() { // 如果已经选定专题,那么跳转 if (Request::getGET('from') == 'nav') { $setId = (int) Cookie::get('current_set'); if ($setId) { $url = '/set_problem/?set-id=' . $setId; Url::redirect($url); } } Cookie::delete('current_set'); $pageSize = 50; // 获取参数 $page = Pager::get(); $title = Request::getGET('title'); $username = Request::getGET('username'); // 构建where $where = array(); $where[] = array('hidden', '=', 0); if (!empty($title)) { $where[] = array('title', 'LIKE', "%{$title}%"); } if (!empty($username)) { $userInfo = UserCommonInterface::getByLoginName(array('login_name' => $username)); $where[] = array('user_id', '=', Arr::get('id', $userInfo, 0)); } // 获取列表 $order = array('listing_status' => 'DESC', 'refresh_at' => 'DESC', 'id' => 'DESC'); $offset = ($page - 1) * $pageSize; $setList = OjProblemSetInterface::getList(array('where' => $where, 'order' => $order, 'limit' => $pageSize, 'offset' => $offset)); $allCount = OjProblemSetInterface::getCount($where); foreach ($setList as &$setInfo) { $problemJson = $setInfo['problem_set']; $globalIds = json_decode($problemJson, true); $setInfo['count'] = count($globalIds); } // 获取用户 $userHash = array(); if (!empty($setList)) { $userIds = array_unique(array_column($setList, 'user_id')); $userHash = UserCommonInterface::getById(array('id' => $userIds)); } // 缓存部分的html $html = array(); $html['pager'] = $this->view->fetch(array('renderAllCount' => $allCount, 'renderPageSize' => $pageSize, 'renderRadius' => 8), 'widget/pager.php'); // 输出 $this->renderFramework(array('html' => $html, 'setList' => $setList, 'userHash' => $userHash), 'set/list.php'); }
/** * テーブルを検索してデータ一覧を取得する * * @param (array|string) $conditions テーブルの検索条件 * @param integer $currentPage 取得するページ * @return array テーブルから取得したデータの配列 */ public function get($conditions, $currentPage) { $_ = $this; // SELECT 条件の設定 $_->TABLE->reset(); $_->TABLE->select('*'); $_->setLimit($currentPage, $this->maxItemsInPage); // SELECTの結果取得 $results = $_->TABLE->find($conditions)->fetchAll(); // ページャの生成 $pagerParams['currentPage'] = $currentPage; $pagerParams['allItemsNum'] = $_->count($conditions); $pagerParams['maxItemsInPage'] = $_->maxItemsInPage; $_->pager = Pager::get($pagerParams); return $results; }
public function defaultAction() { $pageSize = 20; // 获取参数 $page = Pager::get(); $status = (int) Request::getGET('status', -1); $contestId = (int) Request::getGET('contest-id', 0); // 获取属于用户的竞赛 $where = array(array('user_id', '=', $this->loginUserInfo['id']), array('is_diy', '=', 1)); $contestHash = OjContestInterface::getList(array('where' => $where)); $contestHash = Arr::listToHash('id', $contestHash); $contestIds = array_keys($contestHash); $userHash = array(); $applyList = array(); $allCount = 0; if (!empty($contestIds)) { if ($contestId > 0 && !in_array($contestId, $contestIds)) { $where = false; } else { if ($contestId > 0 && in_array($contestId, $contestIds)) { $where = array(array('contest_id', '=', $contestId)); } else { $where = array(array('contest_id', 'IN', $contestIds)); } } if (false !== $where) { if ($status != -1) { $where[] = array('status', '=', $status); } $offset = ($page - 1) * $pageSize; $applyList = OjContestApplyInterface::getList(array('where' => $where, 'limit' => $pageSize, 'offset' => $offset)); if (!empty($applyList)) { $allCount = OjContestApplyInterface::getCount($where); $userIds = array_column($applyList, 'user_id'); $userHash = UserCommonInterface::getById(array('id' => $userIds)); } } } // 缓存部分的html $html = array(); $html['pager'] = $this->view->fetch(array('renderAllCount' => $allCount, 'renderPageSize' => $pageSize, 'renderRadius' => 8), 'widget/pager.php'); $this->renderFramework(array('html' => $html, 'applyList' => $applyList, 'contestHash' => $contestHash, 'userHash' => $userHash), 'setup/contest/apply_list.php'); }
public function defaultAction() { $pageSize = 20; // 获取参数 $page = Pager::get(); $keyword = Request::getGET('keyword'); // 构建where $where = array(); if (!empty($keyword)) { $where[] = array('OR' => array(array('code', 'LIKE', "%{$keyword}%"), array('description', 'LIKE', "%{$keyword}%"))); } // 查询 $offset = ($page - 1) * $pageSize; $permissionList = RootPermissionInterface::getList(array('where' => $where, 'limit' => $pageSize, 'offset' => $offset)); $allCount = RootPermissionInterface::getCount($where); // 缓存部分的html $html = array(); $html['pager'] = $this->view->fetch(array('renderAllCount' => $allCount, 'renderPageSize' => $pageSize, 'renderRadius' => 8), 'widget/pager.php'); $this->renderFramework(array('html' => $html, 'permissionList' => $permissionList), 'permission/list.php'); }
public function defaultAction() { $pageSize = 20; $page = Pager::get(); $level = (int) Request::getGET('level'); $key = Request::getGET('key'); $where = array(); if ($key == 'phpErrors') { $where[] = array('tag', 'IN', LoggerKeys::$phpErrors); } else { if (!empty($key)) { $where[] = array('tag', '=', $key); } } if (!empty($level)) { $where[] = array('level', '=', $level); } $logList = LoggerInterface::getList(array('field' => '*', 'where' => $where, 'limit' => $pageSize, 'offset' => ($page - 1) * $pageSize)); $allCount = LoggerInterface::getCount($where); // 缓存部分的html $html = array(); $html['pager'] = $this->view->fetch(array('renderAllCount' => $allCount, 'renderPageSize' => $pageSize, 'renderRadius' => 4), 'widget/pager_long.php'); $this->renderFramework(array('html' => $html, 'logList' => $logList), 'list.php'); }
public function defaultAction() { $pageSize = 20; $page = Pager::get(); $loginName = Request::getGET('login-name', ''); $path = Request::getGET('path', ''); $includePath = Request::getGET('include-path', ''); // 路径非法提示 if (!empty($path)) { if (!RootPermissionInterface::isValidPath(array('path' => $path))) { $this->setNotice(FrameworkVars::NOTICE_ERROR, "路径{$path}格式不正确!"); $url = Url::getCurrentUrl(array('path' => null)); Url::redirect($url); } } // 路径非法提示 if (!empty($includePath)) { if (!RootPermissionInterface::isValidPath(array('path' => $includePath))) { $this->setNotice(FrameworkVars::NOTICE_ERROR, "路径{$includePath}格式不正确!"); $url = Url::getCurrentUrl(array('include-path' => null)); Url::redirect($url); } } // 用户不存在提示 if (!empty($loginName)) { $userInfo = UserCommonInterface::getByLoginName(array('login_name' => $loginName)); if (empty($userInfo)) { $this->setNotice(FrameworkVars::NOTICE_ERROR, '用户不存在!'); $url = Url::getCurrentUrl(array('login-name' => null)); Url::redirect($url); } } // 构建where $where = array(); if (!empty($userInfo)) { $where[] = array('user_id', '=', $userInfo['id']); } if (!empty($path)) { $managerIds = RootManagerInterface::getAllowedManagerIds(array('path' => $path)); $where[] = array('id', 'IN', $managerIds); } if (!empty($includePath)) { $managerIds = RootManagerInterface::getIncludeManagerIds(array('path' => $includePath)); $where[] = array('id', 'IN', $managerIds); } $offset = ($page - 1) * $pageSize; $managerList = RootManagerInterface::getList(array('where' => $where, 'limit' => $pageSize, 'offset' => $offset)); $allCount = RootManagerInterface::getCount($where); $userList = array(); $pathHash = array(); if (!empty($managerList)) { $userIds = array_column($managerList, 'user_id'); $userList = UserCommonInterface::getById(array('id' => $userIds)); $userList = Arr::listToHash('id', $userList); // 获取权限列表 $managerIds = array_column($managerList, 'id'); $pathHash = RootManagerInterface::getPaths(array('id' => $managerIds)); } // 找出invalid path $invalidHash = array(); foreach ($pathHash as $id => $pathSet) { foreach ($pathSet as $tmpPath) { if (array_key_exists($tmpPath, $invalidHash)) { continue; } $invalidHash[$tmpPath] = RootPermissionInterface::findPath(array('path' => $tmpPath)) ? 0 : 1; } } // 缓存部分的html $html = array(); $html['pager'] = $this->view->fetch(array('renderAllCount' => $allCount, 'renderPageSize' => $pageSize, 'renderRadius' => 8), 'widget/pager.php'); $this->renderFramework(array('html' => $html, 'managerList' => $managerList, 'userList' => $userList, 'pathHash' => $pathHash, 'invalidHash' => $invalidHash), 'manager/list.php'); }
public function defaultAction() { $pageSize = 20; // 获取参数 $page = Pager::get(); $title = Request::getGET('title'); $passed = (int) Request::getGET('passed', 0); $diy = (int) Request::getGET('diy', 0); // 构建where $where = array(); $where[] = array('hidden', '=', 0); if ($passed) { $where[] = array('end_time', '<=', time()); } else { $where[] = array('end_time', '>', time()); } if ($diy) { $where[] = array('is_diy', '=', 1); } else { $where[] = array('is_diy', '=', 0); } if (!empty($title)) { $where[] = array('title', 'LIKE', "%{$title}%"); } if ($passed) { $order = array('end_time' => 'DESC'); } else { $order = array('end_time' => 'ASC'); } // 获取数据 $offset = ($page - 1) * $pageSize; $tmpContestList = OjContestInterface::getList(array('where' => $where, 'order' => $order, 'limit' => $pageSize, 'offset' => $offset)); $allCount = OjContestInterface::getCount($where); // 将进行中的比赛提前 $contestList = array(); if (!$passed) { foreach ($tmpContestList as $i => $contestInfo) { if ($contestInfo['begin_time'] < time()) { $contestList[] = $contestInfo; unset($tmpContestList[$i]); } } foreach ($tmpContestList as $i => $contestInfo) { $contestList[] = $contestInfo; unset($tmpContestList[$i]); } } else { $contestList = $tmpContestList; } $userIds = array_unique(array_column($contestList, 'user_id')); $userHash = UserCommonInterface::getById(array('id' => $userIds)); // 格式化 foreach ($contestList as &$contestInfo) { // row_class $now = time(); if ($contestInfo['end_time'] < $now) { $contestInfo['row_css'] = 'passed'; } else { if ($contestInfo['begin_time'] > $now) { $contestInfo['row_css'] = 'pending'; } else { $contestInfo['row_css'] = 'running'; } } // type_format $type = $contestInfo['type']; if ($type == ContestVars::TYPE_PUBLIC) { $contestInfo['type_format'] = '<p class="red">公开</p>'; } else { if ($type == ContestVars::TYPE_APPLY) { $contestInfo['type_format'] = '<p class="orange">报名</p>'; } else { if ($type == ContestVars::TYPE_PASSWORD) { $contestInfo['type_format'] = '<p class="green">密码</p>'; } else { $contestInfo['type_format'] = '<p class="gray">未定义</p>'; } } } } // 缓存部分的html $html = array(); $html['pager'] = $this->view->fetch(array('renderAllCount' => $allCount, 'renderPageSize' => $pageSize, 'renderRadius' => 8), 'widget/pager.php'); // 输出 $this->renderFramework(array('contestList' => $contestList, 'userHash' => $userHash, 'html' => $html), 'contest/list.php'); }