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 = 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() { list($rankHash, $mat, $userHash) = OjContestInterface::getRankBoard(array('id' => $this->contestInfo['id'])); // 如果是报名,获取报名列表 $applyHash = array(); if ($this->contestInfo['type'] == ContestVars::TYPE_APPLY) { $where = array(array('contest_id', '=', $this->contestInfo['id'])); $applyHash = OjContestApplyInterface::getList(array('where' => $where)); $applyHash = Arr::listToHash('user_id', $applyHash); } $this->renderFramework(array('rankHash' => $rankHash, 'mat' => $mat, 'userHash' => $userHash, 'applyHash' => $applyHash), 'rank/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(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 = 15; // 获取参数 $username = Request::getGET('username'); $language = (int) Request::getGET('language', -1); $result = (int) Request::getGET('result', -1); $problemHash = Request::getGET('problem-hash'); $maxId = (int) Request::getGET('max-id', -1); $minId = (int) Request::getGET('min-id', -1); $globalId = array_search($problemHash, $this->contestInfo['problem_hash']); // 获取userInfo,username转换为userId $userInfo = array(); if (!empty($username)) { $userInfo = UserCommonInterface::getByLoginName(array('login_name' => $username)); } // 构建where $where = array(); $where[] = array('contest_id', '=', $this->contestInfo['id']); $where[] = array('hidden', '=', 0); $where[] = array('problem_global_id', 'IN', $this->contestInfo['global_ids']); if (!empty($username)) { $where[] = array('user_id', '=', Arr::get('id', $userInfo, 0)); } if (!empty($globalId)) { $where[] = array('problem_global_id', '=', $globalId); } if ($language != -1) { $where[] = array('language', '=', $language); } if ($result != -1) { $where[] = array('result', '=', $result); } // 获取solutionList if ($maxId != -1) { $where[] = array('solution_id', '<=', $maxId); $solutionList = OjSolutionInterface::getList(array('where' => $where, 'order' => array('id' => 'DESC'), 'limit' => $pageSize, 'include_contest' => true)); } else { if ($minId != -1) { $where[] = array('solution_id', '>=', $minId); $solutionList = OjSolutionInterface::getList(array('where' => $where, 'order' => array('id' => 'ASC'), 'limit' => $pageSize, 'include_contest' => true)); $solutionList = array_reverse($solutionList, true); } else { $solutionList = OjSolutionInterface::getList(array('where' => $where, 'order' => array('id' => 'DESC'), 'limit' => $pageSize, 'include_contest' => true)); } } // 获取userHash $userIds = array_unique(array_column($solutionList, 'user_id')); $userHash = UserCommonInterface::getById(array('id' => $userIds)); // 格式化solution foreach ($solutionList as &$solutionInfo) { $solutionInfo['permission'] = false; if ($this->isContestAdmin || $solutionInfo['user_id'] == $this->loginUserInfo['id']) { $solutionInfo['permission'] = true; } $solutionInfo['has_log'] = OjSolutionHelper::hasLog($solutionInfo); } // 如果是报名,获取报名列表 $applyHash = array(); if ($this->contestInfo['type'] == ContestVars::TYPE_APPLY) { $where = array(array('contest_id', '=', $this->contestInfo['id'])); $applyHash = OjContestApplyInterface::getList(array('where' => $where)); $applyHash = Arr::listToHash('user_id', $applyHash); } // 计算minId, maxId $minId = $maxId = 0; if (!empty($solutionList)) { $solutionIds = array_keys($solutionList); $maxId = $solutionIds[0]; $minId = end($solutionIds); } // 缓存html $html = array(); $html['pager'] = $this->view->fetch(array('renderMaxId' => $maxId, 'renderMinId' => $minId), 'widget/pager_status.php'); // render $this->renderFramework(array('userHash' => $userHash, 'solutionList' => $solutionList, 'html' => $html, 'applyHash' => $applyHash), 'status/list.php'); }