public function killlist($request) { if (empty($request['ownerType']) || empty($request['ownerID'])) { return $this->error("type / id not given"); } $ownerType = $request['ownerType']; $ownerID = $request['ownerID']; $currentPage = 1; if (!empty($request['page'])) { $currentPage = (int) $request['page'] < 1 ? 1 : (int) $request['page']; } $templateVars = array(); // kill list $killList = new KillList($ownerType, $ownerID); $templateVars['killstats'] = $killList->getKillStats(); $templateVars['lossstats'] = $killList->getLossStats(); $templateVars['totalstats'] = $killList->getTotalStats(); $paginator = new Paginator($currentPage, $killList->getCount()); // fetch kill data $templateVars['data'] = $killList->getKills($paginator->getSkip(), $paginator->getKillsPerPage()); // merge in pagination data $templateVars = array_merge($templateVars, $paginator->getNavArray()); $templateVars['count'] = $killList->getCount(); $info = null; $template = null; switch ($ownerType) { case "character": case "char": case "pilot": $template = "pilot/index.html"; $info = KillModel::getPilotInfoFromId($ownerID); break; case "corp": case "corporation": $template = "corporation/index.html"; $info = KillModel::getCorporationInfoFromId($ownerID); break; case "faction": $template = "faction/index.html"; $info = KillModel::getFactionInfoFromId($ownerID); break; case "alliance": $template = "alliance/index.html"; $info = KillModel::getAllianceInfoFromId($ownerID); break; } if (is_null($template) || is_null($info)) { return $this->error("unknown ownerType: " . $ownerType); } $templateVars['info'] = $info; // we replace the defaults with the ones of the current look $templateVars['ownerID'] = $ownerID; $templateVars['ownerType'] = $ownerType; $templateVars['action'] = "/details/{$ownerType}/{$ownerID}"; return $this->render($template, $templateVars); }
/** * display a list of battles * @param array $request * @return string */ public function index(array $request) { $templateVars = array(); $currentPage = 1; if (!empty($request['page'])) { $currentPage = (int) $request['page'] < 1 ? 1 : (int) $request['page']; } $count = BattleSettings::find()->count(); $paginator = new Paginator($currentPage, $count); // merge in pagination data $templateVars = array_merge($templateVars, $paginator->getNavArray()); // battles $templateVars['reports'] = BattleSettings::find()->skip($paginator->getSkip())->limit($paginator->getKillsPerPage())->sort(array('enddate' => -1)); $templateVars['action'] = "/battles"; return $this->render("battle/index.html", $templateVars); }