From 8f32a220f76a855a949a266d1b75d9fbc8677ae8 Mon Sep 17 00:00:00 2001 From: GodMod Date: Sat, 24 Aug 2019 15:12:19 +0200 Subject: [PATCH] Added classic links --- hooks/warcraftlogs_viewraid_hook.class.php | 8 ++++---- includes/warcraftlogs_helper.class.php | 9 +++++++++ portal/wcl_lastlogs_portal.class.php | 10 +++++----- warcraftlogs_plugin_class.php | 2 +- 4 files changed, 19 insertions(+), 10 deletions(-) diff --git a/hooks/warcraftlogs_viewraid_hook.class.php b/hooks/warcraftlogs_viewraid_hook.class.php index 3558a20..9cb4b9c 100644 --- a/hooks/warcraftlogs_viewraid_hook.class.php +++ b/hooks/warcraftlogs_viewraid_hook.class.php @@ -67,7 +67,7 @@ public function viewraid($data){ $arrData = $this->pdc->get('plugins.warcraftlogs.reports.'.$strCachekey); if($arrData === null){ - $strReportsURL = "https://www.warcraftlogs.com:443/v1/reports/guild/".rawurlencode($strGuildname)."/".$strServername."/".$strServerregion."?start=".($strEventDay*1000)."&end=".(($strEventDay+24*3600)*1000)."&api_key=".$strAPIKey; + $strReportsURL = $objHelper->get_warcraftlogsurl()."/v1/reports/guild/".rawurlencode($strGuildname)."/".$strServername."/".$strServerregion."?start=".($strEventDay*1000)."&end=".(($strEventDay+24*3600)*1000)."&api_key=".$strAPIKey; $strData = register('urlfetcher')->fetch($strReportsURL); if($strData){ $arrData = json_decode($strData, true); @@ -80,12 +80,12 @@ public function viewraid($data){ foreach($arrData as $arrLogInfos){ $strID = $arrLogInfos['id']; - $strOutputReportLinks .= ' warcraftlogs.com
'; + $strOutputReportLinks .= ' warcraftlogs.com
'; //Fetch Fights $strFightData = $this->pdc->get('plugins.warcraftlogs.fights.'.$strID); if($strFightData === null){ - $strFightData = register('urlfetcher')->fetch("https://www.warcraftlogs.com:443/v1/report/fights/".$strID."?api_key=".$strAPIKey); + $strFightData = register('urlfetcher')->fetch($objHelper->get_warcraftlogsurl()."/v1/report/fights/".$strID."?api_key=".$strAPIKey); if($strFightData){ $arrFightData = json_decode($strFightData, true); @@ -135,7 +135,7 @@ public function viewraid($data){ $i++; $arrTries[$arrFightData['boss']]++; - $strBosses .= '
'.sanitize($arrFightData['name']).' ('.$this->user->lang('wcl_tries').' '.$arrTries[$arrFightData['boss']].') '.(($arrFightData['kill']) ? "" : "").' '.(($arrFightData['kill']) ? $arrFightData['duration'] : $arrFightData['info']).'
'; + $strBosses .= '
'.sanitize($arrFightData['name']).' ('.$this->user->lang('wcl_tries').' '.$arrTries[$arrFightData['boss']].') '.(($arrFightData['kill']) ? "" : "").' '.(($arrFightData['kill']) ? $arrFightData['duration'] : $arrFightData['info']).'
'; } $this->tpl->add_listener('viewraid_beforetables', '
diff --git a/includes/warcraftlogs_helper.class.php b/includes/warcraftlogs_helper.class.php index b56770c..900abd5 100644 --- a/includes/warcraftlogs_helper.class.php +++ b/includes/warcraftlogs_helper.class.php @@ -130,4 +130,13 @@ function remove_accents($string) { return $string; } + + function get_warcraftlogsurl(){ + $strGame = registry::register('config')->get('default_game'); + if($strGame == 'wow'){ + return 'https://classic.warcraftlogs.com'; + } else { + return 'https://www.warcraftlogs.com'; + } + } } \ No newline at end of file diff --git a/portal/wcl_lastlogs_portal.class.php b/portal/wcl_lastlogs_portal.class.php index 7dddd22..0d833cb 100644 --- a/portal/wcl_lastlogs_portal.class.php +++ b/portal/wcl_lastlogs_portal.class.php @@ -68,6 +68,9 @@ public function get_settings($state){ */ public function output(){ $arrReports = $this->pdc->get('plugins.warcraftlogs.reports'); + + include_once($this->root_path.'plugins/warcraftlogs/includes/warcraftlogs_helper.class.php'); + $objHelper = register('warcraftlogs_helper'); if($arrReports === null){ $strGuildname = unsanitize($this->config->get('guildtag')); $strServername = unsanitize($this->config->get('servername')); @@ -77,12 +80,9 @@ public function output(){ $strServername = utf8_strtolower($strServername); $strServername = str_replace(' ', '-', $strServername); $strServername = str_replace("'", '', $strServername); - include_once($this->root_path.'plugins/warcraftlogs/includes/warcraftlogs_helper.class.php'); - $objHelper = register('warcraftlogs_helper'); $strServername = $objHelper->remove_accents($strServername); - $strReportsURL = "https://www.warcraftlogs.com:443/v1/reports/guild/".rawurlencode($strGuildname)."/".$strServername."/".$strServerregion."?api_key=".$strAPIKey; - + $strReportsURL = $objHelper->get_warcraftlogsurl()."/v1/reports/guild/".rawurlencode($strGuildname)."/".$strServername."/".$strServerregion."?api_key=".$strAPIKey; $strData = register('urlfetcher')->fetch($strReportsURL); if($strData){ $arrReports = json_decode($strData, true); @@ -106,7 +106,7 @@ public function output(){ $date = $this->time->user_date(round($arrReport['start']/1000, 0), true); - $strOut.="".$date.' - '.sanitize($arrReport['title']).""; + $strOut.="".$date.' - '.sanitize($arrReport['title']).""; $i++; } $strOut .= ""; diff --git a/warcraftlogs_plugin_class.php b/warcraftlogs_plugin_class.php index db67934..d2ede43 100644 --- a/warcraftlogs_plugin_class.php +++ b/warcraftlogs_plugin_class.php @@ -25,7 +25,7 @@ class warcraftlogs extends plugin_generic { public $vstatus = 'Stable'; - public $version = '0.1.5'; + public $version = '0.2.0'; public $copyright = 'GodMod'; protected static $apiLevel = 23;