/** * Show the overall statistics for this corporation. */ function stats() { global $smarty; // The summary table is also used by the stats. Whichever is called // first generates the table. $this->page->setTitle('Corporation details - ' . $this->corp->getName() . " [" . $this->corp->getShortName() . "]"); $smarty->registerObject('Corp', $this->corp); $smarty->assign('portrait_url', $this->corp->getPortraitURL(128)); if ($this->alliance->getName() == "None") { $smarty->assign('alliance_url', false); } else { if ($this->alliance->getExternalID()) { $smarty->assign('alliance_url', edkURI::build(array('a', 'alliance_detail', true), array('all_ext_id', $this->alliance->getExternalID(), true))); } else { $smarty->assign('alliance_url', edkURI::build(array('a', 'alliance_detail', true), array('all_id', $this->alliance->getID(), true))); } } $smarty->assign('alliance_name', $this->alliance->getName()); $smarty->assign('kill_count', $this->kill_summary->getTotalKills()); $smarty->assign('loss_count', $this->kill_summary->getTotalLosses()); $smarty->assign('damage_done', number_format($this->kill_summary->getTotalKillISK() / 1000000000, 2)); $smarty->assign('damage_received', number_format($this->kill_summary->getTotalLossISK() / 1000000000, 2)); if ($this->kill_summary->getTotalKillISK()) { $smarty->assign('efficiency', number_format(100 * $this->kill_summary->getTotalKillISK() / ($this->kill_summary->getTotalKillISK() + $this->kill_summary->getTotalLossISK()), 2)); } else { $smarty->assign('efficiency', 0); } $smarty->assign('ceo_url', edkURI::build(array('a', 'pilot_detail', true), array('plt_ext_id', $this->corp->getCeoID(), true))); $pilot = new Pilot(0, $this->corp->getCeoID()); $smarty->assign('ceo_name', $pilot->getName()); return $smarty->fetch(get_tpl('corp_detail_stats')); }
function display() { global $smarty; $alls = $corps = $pilots = false; if (config::get('cfg_allianceid')) { $alls = array(); foreach (config::get('cfg_allianceid') as $entity) { $alliance = new Alliance($entity); if ($alliance->getExternalID()) { $url = edkURI::page('alliance_detail', $alliance->getExternalID(), 'all_ext_id'); } else { $url = edkURI::page('alliance_detail', $alliance->getID(), 'all_id'); } $alls[] = array('id' => $alliance->getID(), 'extid' => $alliance->getExternalID(), 'name' => $alliance->getName(), 'portrait' => $alliance->getPortraitURL(128), 'url' => $url); } } if (config::get('cfg_corpid')) { $corps = array(); foreach (config::get('cfg_corpid') as $entity) { $corp = new Corporation($entity); if ($corp->getExternalID()) { $url = edkURI::page('corp_detail', $corp->getExternalID(), 'crp_ext_id'); } else { $url = edkURI::page('corp_detail', $corp->getID(), 'crp_id'); } $corps[] = array('id' => $corp->getID(), 'extid' => $corp->getExternalID(), 'name' => $corp->getName(), 'portrait' => $corp->getPortraitURL(128), 'url' => $url); } } if (config::get('cfg_pilotid')) { $pilots = array(); foreach (config::get('cfg_pilotid') as $entity) { $pilot = new Pilot($entity); if ($pilot->getExternalID()) { $url = edkURI::page('pilot_detail', $pilot->getExternalID(), 'plt_ext_id'); } else { $url = edkURI::page('pilot_detail', $pilot->getID(), 'plt_id'); } $pilots[] = array('id' => $pilot->getID(), 'extid' => $pilot->getExternalID(), 'name' => $pilot->getName(), 'portrait' => $pilot->getPortraitURL(128), 'url' => $url); } } $smarty->assignByRef('alliances', $alls); $smarty->assignByRef('corps', $corps); $smarty->assignByRef('pilots', $pilots); return $smarty->fetch(get_tpl('self')); }
/** * Set the type and ID of the feed to retrieve. * @param string $type pilot/corp/alliance. * @param integer $id * @return boolean false on failure. */ function setID($type = '', $id = 0) { //Check id is int. $id = (int) $id; //Set to board owner. if ($type == '') { if (config::get('cfg_allianceid')) { $alls = array(); foreach (config::get('cfg_allianceid') as $val) { $all = new Alliance($val); if (!$all->getExternalID()) { return false; } $alls[] = $all->getExternalID(); } $this->options['alliance'] = implode(',', $alls); } if (config::get('cfg_corpid')) { $crps = array(); foreach (config::get('cfg_corpid') as $val) { $crp = new Corporation($val); if (!$crp->getExternalID()) { return false; } $crps[] = $crp->getExternalID(); } $this->options['corp'] = implode(',', $crps); } if (config::get('cfg_pilotid')) { $pilots = array(); foreach (config::get('cfg_pilotid') as $val) { $pilot = new Pilot($val); if (!$pilot->getExternalID()) { return false; } $pilots[] = $pilot->getExternalID(); } $this->options['pilot'] = implode(',', $pilots); } return true; } else { if ($id > 0) { if ($type == 'alliance') { $this->options['alliance'] = $id; } else { if ($type == 'corporation') { $this->options['corp'] = $id; } else { if ($type == 'pilot') { $this->options['pilot'] = $id; } else { return false; } } } return true; } } return false; }
/** * Start constructing the page. * Prepare all the shared variables such as dates and check alliance ID. */ function start() { $this->page = new Page(); $this->all_id = (int) edkURI::getArg('all_id'); $this->all_external_id = (int) edkURI::getArg('all_ext_id'); if (!$this->all_id && !$this->all_external_id) { $this->all_id = (int) edkURI::getArg('id', 1); // And now a bit of magic to test if this is an external ID if ($this->all_id > 500000 && $this->all_id < 500021 || $this->all_id > 1000000) { $this->all_external_id = $this->all_id; $this->all_id = 0; } } $this->view = preg_replace('/[^a-zA-Z0-9_-]/', '', edkURI::getArg('view', 2)); // Search engines should only index the main view. if ($this->view) { $this->page->addHeader('<meta name="robots" content="noindex, nofollow" />'); } if (!$this->all_id && !$this->all_external_id) { $html = 'No valid alliance id specified.'; $this->page->setContent($html); $this->page->generate(); exit; } if (!$this->all_id && $this->all_external_id) { $this->alliance = new Alliance($this->all_external_id, true); $this->all_id = $this->alliance->getID(); if (!$this->all_id) { echo 'No valid alliance id specified.'; exit; } } else { $this->alliance = Cacheable::factory('Alliance', $this->all_id); $this->all_external_id = $this->alliance->getExternalID(); } $this->page->addHeader("<link rel='canonical' href='" . $this->alliance->getDetailsURL() . "' />"); if ($this->view) { $this->year = (int) edkURI::getArg('y', 3); $this->month = (int) edkURI::getArg('m', 4); } else { $this->year = (int) edkURI::getArg('y', 2); $this->month = (int) edkURI::getArg('m', 3); } if (!$this->month) { $this->month = kbdate('m'); } if (!$this->year) { $this->year = kbdate('Y'); } if ($this->month == 12) { $this->nmonth = 1; $this->nyear = $this->year + 1; } else { $this->nmonth = $this->month + 1; $this->nyear = $this->year; } if ($this->month == 1) { $this->pmonth = 12; $this->pyear = $this->year - 1; } else { $this->pmonth = $this->month - 1; $this->pyear = $this->year; } $this->monthname = kbdate("F", strtotime("2000-" . $this->month . "-2")); global $smarty; $smarty->assign('monthname', $this->monthname); $smarty->assign('year', $this->year); $smarty->assign('pmonth', $this->pmonth); $smarty->assign('pyear', $this->pyear); $smarty->assign('nmonth', $this->nmonth); $smarty->assign('nyear', $this->nyear); if ($this->alliance->isFaction()) { $this->page->setTitle(Language::get('page_faction_det') . ' - ' . $this->alliance->getName()); } else { $this->page->setTitle(Language::get('page_all_det') . ' - ' . $this->alliance->getName()); } $smarty->assign('all_name', $this->alliance->getName()); $smarty->assign('all_id', $this->alliance->getID()); }