Skip to content

Commit

Permalink
Added classic links
Browse files Browse the repository at this point in the history
  • Loading branch information
GodMod committed Aug 24, 2019
1 parent d78f73f commit 8f32a22
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 10 deletions.
8 changes: 4 additions & 4 deletions hooks/warcraftlogs_viewraid_hook.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -80,12 +80,12 @@ public function viewraid($data){
foreach($arrData as $arrLogInfos){
$strID = $arrLogInfos['id'];

$strOutputReportLinks .= '<a href="https://www.warcraftlogs.com/reports/'.$strID.'"><i class="fa fa-external-link fa-lg"></i> warcraftlogs.com</a><br/>';
$strOutputReportLinks .= '<a href="'.$objHelper->get_warcraftlogsurl().'/reports/'.$strID.'"><i class="fa fa-external-link fa-lg"></i> warcraftlogs.com</a><br/>';

//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);

Expand Down Expand Up @@ -135,7 +135,7 @@ public function viewraid($data){
$i++;
$arrTries[$arrFightData['boss']]++;

$strBosses .= '<div style="margin-bottom:5px;" class="col3"><a href="https://www.warcraftlogs.com/reports/'.sanitize($arrFightData['id']).'#fight='.sanitize($arrFightData['fightid']).'"><img src="https://dmszsuqyoe6y6.cloudfront.net/img/warcraft/bosses/'.sanitize($arrFightData['boss']).'-icon.jpg" style="max-height:22px;" /> '.sanitize($arrFightData['name']).' ('.$this->user->lang('wcl_tries').' '.$arrTries[$arrFightData['boss']].') '.(($arrFightData['kill']) ? "<i class='fa fa-check icon-color-green'></i>" : "<i class='fa fa-times icon-color-red'></i>").'</a> '.(($arrFightData['kill']) ? $arrFightData['duration'] : $arrFightData['info']).'</div>';
$strBosses .= '<div style="margin-bottom:5px;" class="col3"><a href="'.$objHelper->get_warcraftlogsurl().'/reports/'.sanitize($arrFightData['id']).'#fight='.sanitize($arrFightData['fightid']).'"><img src="https://dmszsuqyoe6y6.cloudfront.net/img/warcraft/bosses/'.sanitize($arrFightData['boss']).'-icon.jpg" style="max-height:22px;" /> '.sanitize($arrFightData['name']).' ('.$this->user->lang('wcl_tries').' '.$arrTries[$arrFightData['boss']].') '.(($arrFightData['kill']) ? "<i class='fa fa-check icon-color-green'></i>" : "<i class='fa fa-times icon-color-red'></i>").'</a> '.(($arrFightData['kill']) ? $arrFightData['duration'] : $arrFightData['info']).'</div>';
}

$this->tpl->add_listener('viewraid_beforetables', '<div class="tableHeader warcraftlogs">
Expand Down
9 changes: 9 additions & 0 deletions includes/warcraftlogs_helper.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}
}
}
10 changes: 5 additions & 5 deletions portal/wcl_lastlogs_portal.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
Expand All @@ -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);
Expand All @@ -106,7 +106,7 @@ public function output(){

$date = $this->time->user_date(round($arrReport['start']/1000, 0), true);

$strOut.="<tr><td><a href='https://www.warcraftlogs.com/reports/".sanitize($arrReport['id'])."' target='_blank'>".$date.' - '.sanitize($arrReport['title'])."</a></td></tr>";
$strOut.="<tr><td><a href='".$objHelper->get_warcraftlogsurl()."/reports/".sanitize($arrReport['id'])."' target='_blank'>".$date.' - '.sanitize($arrReport['title'])."</a></td></tr>";
$i++;
}
$strOut .= "</table>";
Expand Down
2 changes: 1 addition & 1 deletion warcraftlogs_plugin_class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 8f32a22

Please sign in to comment.