From 139be8d7dd4d968644abae5b8dee8addad800753 Mon Sep 17 00:00:00 2001 From: SirCotare Date: Thu, 21 Jun 2012 22:03:36 +0200 Subject: [PATCH] #1470 config options added; some cleanup --HG-- branch : gsoc2012-achievements --- .../class/AchObjective_class.php | 6 + .../app_achievements/class/AchPerk_class.php | 2 +- code/web/app/app_achievements/conf.php | 12 +- .../include/ach_render_common.php | 9 ++ .../include/ach_render_ig.php | 129 +++++------------- .../include/ach_render_web.php | 71 +++++----- code/web/app/app_achievements/index.php | 24 ++-- 7 files changed, 107 insertions(+), 146 deletions(-) diff --git a/code/web/app/app_achievements/class/AchObjective_class.php b/code/web/app/app_achievements/class/AchObjective_class.php index 2f36fad01..f58849742 100644 --- a/code/web/app/app_achievements/class/AchObjective_class.php +++ b/code/web/app/app_achievements/class/AchObjective_class.php @@ -8,6 +8,7 @@ private $display; private $done; private $progress; + private $meta_image; function AchObjective(&$data) { global $DBc,$_USER; @@ -19,6 +20,7 @@ $this->name = $data['aol_name']; $this->display = $data['ao_display']; $this->done = $data['apo_date']; + $this->meta_image = $data['aa_image']; $this->progress = $this->value; @@ -28,6 +30,10 @@ } } + function getMetaImage() { + return $this->meta_image; + } + function getID() { return $this->id; } diff --git a/code/web/app/app_achievements/class/AchPerk_class.php b/code/web/app/app_achievements/class/AchPerk_class.php index a007c729b..c257b6b4c 100644 --- a/code/web/app/app_achievements/class/AchPerk_class.php +++ b/code/web/app/app_achievements/class/AchPerk_class.php @@ -19,7 +19,7 @@ $this->done = $data['app_date']; $this->dev = $data['ap_dev']; - $res = $DBc->sqlQuery("SELECT * FROM ach_objective LEFT JOIN (ach_objective_lang) ON (aol_lang='".$_USER->getLang()."' AND aol_objective=ao_id) LEFT JOIN (ach_player_objective) ON (apo_objective=ao_id AND apo_player='".$_USER->getID()."') WHERE ao_perk='".$this->id."'"); + $res = $DBc->sqlQuery("SELECT * FROM ach_objective LEFT JOIN (ach_objective_lang) ON (aol_lang='".$_USER->getLang()."' AND aol_objective=ao_id) LEFT JOIN (ach_player_objective) ON (apo_objective=ao_id AND apo_player='".$_USER->getID()."') LEFT JOIN (ach_achievement) ON (aa_id=ao_metalink) WHERE ao_perk='".$this->id."'"); $sz = sizeof($res); for($i=0;$i<$sz;$i++) { $this->nodes[] = $this->makeChild($res[$i]); diff --git a/code/web/app/app_achievements/conf.php b/code/web/app/app_achievements/conf.php index e4e3a504e..a9ff621a3 100644 --- a/code/web/app/app_achievements/conf.php +++ b/code/web/app/app_achievements/conf.php @@ -3,11 +3,11 @@ die(-1); } - $achConf = array(); + $_CONF = array(); - $achConf['summary_size'] = 12; - $achConf['default_lang'] = 'en'; - $achConf['enable_webig'] = true; - $achConf['enable_offgame'] = true; - $achConf['use_cache'] = false; + $_CONF['summary_size'] = 5; + #$_CONF['default_lang'] = 'en'; + $_CONF['enable_webig'] = true; + $_CONF['enable_offgame'] = true; + $_CONF['image_url'] = "http://www.3025-game.de/special/app_achievements/"; ?> \ No newline at end of file diff --git a/code/web/app/app_achievements/include/ach_render_common.php b/code/web/app/app_achievements/include/ach_render_common.php index 2c49ac3a7..d3f291038 100644 --- a/code/web/app/app_achievements/include/ach_render_common.php +++ b/code/web/app/app_achievements/include/ach_render_common.php @@ -17,4 +17,13 @@ return $t[$cc]; } + + function ach_render_forbidden($ig) { + if($ig) { + return "This app is NOT available INGAME!"; + } + else { + return "This app is NOT available from the WEB!"; + } + } ?> \ No newline at end of file diff --git a/code/web/app/app_achievements/include/ach_render_ig.php b/code/web/app/app_achievements/include/ach_render_ig.php index b93b11b97..10d2925f1 100644 --- a/code/web/app/app_achievements/include/ach_render_ig.php +++ b/code/web/app/app_achievements/include/ach_render_ig.php @@ -1,10 +1,10 @@ - ".ach_render_yubopoints($user['id'])." + ".ach_render_yubopoints($_USER->getID())." @@ -44,18 +44,12 @@ function ach_render_tiebar($cult = "c_neutral", $civ = "c_neutral",&$cat) { global $_USER; - $html = " - -
+ $html = " "; if($cat->isTiedCult()) { $html.= "
-
 
-
+ -
"; + "; if($cat->isTiedCult() && !$cat->isTiedCiv() && $cult == "c_neutral") { // neutral / xx #While being of neutral allegiance with the higher powers - $html .= get_translation('ach_allegiance_neutral_cult',$_USER->getLang(),array("".get_translation('ach_c_neutral',$_USER->getLang())."")); + $html .= get_translation('ach_allegiance_neutral_cult',$_USER->getLang(),array("".get_translation('ach_c_neutral',$_USER->getLang())."")); } elseif($cat->isTiedCiv() && !$cat->isTiedCult() && $civ == "c_neutral") { // xx / neutral #While being of neutral allegiance with the homin civilizations - $html .= get_translation('ach_allegiance_neutral_civ',$_USER->getLang(),array("".get_translation('ach_c_neutral',$_USER->getLang())."")); + $html .= get_translation('ach_allegiance_neutral_civ',$_USER->getLang(),array("".get_translation('ach_c_neutral',$_USER->getLang())."")); } elseif($cat->isTiedCiv() && $cat->isTiedCult() && $cult == "c_neutral" && $civ == "c_neutral") { // neutral / neutral #While being of neutral allegiance - $html .= get_translation('ach_allegiance_neutral',$_USER->getLang(),array("".get_translation('ach_c_neutral',$_USER->getLang())."")); + $html .= get_translation('ach_allegiance_neutral',$_USER->getLang(),array("".get_translation('ach_c_neutral',$_USER->getLang())."")); } else { //other #While being aligned with the $html .= get_translation('ach_allegiance_start',$_USER->getLang()); if($cat->isTiedCult() && $cult != "c_neutral") { #CULT - $html .= "".ach_translate_cc($cult).""; + $html .= "".ach_translate_cc($cult).""; if($cat->isTiedCiv() && $civ != "c_neutral") { #and the CIV - $html .= get_translation('ach_allegiance_and',$_USER->getLang())." ".ach_translate_cc($civ).""; + $html .= get_translation('ach_allegiance_and',$_USER->getLang())." ".ach_translate_cc($civ).""; } } elseif($cat->isTiedCiv() && $civ != "c_neutral") { #CIV - $html .= "".ach_translate_cc($civ).""; + $html .= "".ach_translate_cc($civ).""; } } #, accomplish the following achievements: - $html .= get_translation('ach_allegiance_end',$_USER->getLang())."
"; + $html .= get_translation('ach_allegiance_end',$_USER->getLang())."

"; return $html; } function ach_render_yubopoints() { - global $DBc,$_USER; + global $DBc,$_USER,$_CONF; $res = $DBc->sqlQuery("SELECT sum(ap_value) as anz FROM ach_perk,ach_player_perk WHERE ap_id=app_perk AND app_player='".$_USER->getID()."'"); - $html = "".$_USER->getName()."  ".$res[0]['anz'].""; + $html = "".$_USER->getName()."  ".$res[0]['anz'].""; return $html; } @@ -132,6 +126,8 @@ } function ach_render_menu(&$menu,$sub = 0) { + global $_CONF; + $html = ""; if($sub == 0) { $html = ""; @@ -145,10 +141,10 @@ $html .= ""; + $html .= ""; } return $html; @@ -395,12 +335,14 @@ } function ach_render_obj_simple(&$obj) { + global $_CONF; + $html = ""; if($obj->isdone()) { - $html .= " "; + $html .= " "; } else { - $html .= " "; + $html .= " "; } $html .= $obj->getName().""; @@ -409,6 +351,7 @@ } function ach_render_obj_meta(&$obj) { + global $_CONF; $html = ""; if($obj->isdone()) { $col = "#71BE02"; @@ -421,7 +364,7 @@ return "
"; if($sub == 0) { - $html .= ""; + $html .= "getImage()."' />"; } else { - $html .= ""; + $html .= ""; } $html .= "isOpen()) { @@ -201,17 +197,19 @@ } function ach_render_achievement_done(&$ach) { + global $_CONF; + $html = " @@ -219,40 +217,11 @@
- + - +
getImage()."'>
".$ach->getName()."
".ach_render_perk_done($ach)."
".$ach->getValueDone()."
".$ach->getValueDone()."
 
"; - /*$html .= '
- - - - - - - - - - - - - - - -
-
- - - - -
'.$ach->getName().'
- '.$ach->getValueDone().'
-
'; - $html .= ach_render_perk_done($ach); - $html .= '
-
';*/ - return $html; } function ach_render_achievement_open(&$ach) { - $html = ""; + global $_CONF; $html = " @@ -260,11 +229,11 @@ @@ -272,40 +241,10 @@
- + - +
getImage()."'>
".$ach->getName()."
".ach_render_perk_open($ach)."
".$ach->getValueOpen()."
".$ach->getValueOpen()."
 
"; - /*$html .= '
- - - - - - - - - - - - - - - -
-
- - - - -
'.$ach->getName().'
- '.$ach->getValueOpen().'
-
'; - $html .= ach_render_perk_open($ach); - $html .= '
-
';*/ - return $html; } function ach_render_perk_open(&$ach) { - #echo var_export($perk_list,true); $html = ""; $perk_list = $ach->getOpen(); @@ -327,6 +266,7 @@ } function ach_render_perk_done(&$ach) { + global $_CONF; $html = ""; $perk_list = $ach->getDone(); @@ -336,7 +276,7 @@ if($perk->inDev()) { continue; } - $html .= "
".$perk->getName()." ( ".date('d.m.Y',$perk->getDone())." ) ".$perk->getValue()."
".$perk->getName()." ( ".date('d.m.Y',$perk->getDone())." ) ".$perk->getValue()."
- +
getMetaImage()."' />  ".$obj->getName()."
"; diff --git a/code/web/app/app_achievements/include/ach_render_web.php b/code/web/app/app_achievements/include/ach_render_web.php index a66f15254..6ae549a09 100644 --- a/code/web/app/app_achievements/include/ach_render_web.php +++ b/code/web/app/app_achievements/include/ach_render_web.php @@ -44,7 +44,7 @@ } function ach_render_tiebar($cult = "c_neutral", $civ = "c_neutral",&$cat) { - global $_USER; + global $_USER,$_CONF; $html = "