diff --git a/code/web/app/app_achievements/_doc/Class_scheme.dia b/code/web/app/app_achievements/_doc/Class_scheme.dia index cee3d3deb..31768b998 100644 Binary files a/code/web/app/app_achievements/_doc/Class_scheme.dia and b/code/web/app/app_achievements/_doc/Class_scheme.dia differ diff --git a/code/web/app/app_achievements/_doc/Class_scheme.png b/code/web/app/app_achievements/_doc/Class_scheme.png index e1848de30..93d9d08c0 100644 Binary files a/code/web/app/app_achievements/_doc/Class_scheme.png and b/code/web/app/app_achievements/_doc/Class_scheme.png differ diff --git a/code/web/app/app_achievements/include/AchAchievement_class.php b/code/web/app/app_achievements/class/AchAchievement_class.php similarity index 63% rename from code/web/app/app_achievements/include/AchAchievement_class.php rename to code/web/app/app_achievements/class/AchAchievement_class.php index 532d6c160..9fc920dda 100644 --- a/code/web/app/app_achievements/include/AchAchievement_class.php +++ b/code/web/app/app_achievements/class/AchAchievement_class.php @@ -8,9 +8,10 @@ private $tie_cult; private $image; private $name; + private $template; - function AchAchievement(&$data,$lang,$user) { - global $db; + function AchAchievement(&$data) { + global $DBc,$_USER; $this->id = $data['aa_id']; $this->parent = $data['aa_parent']; @@ -20,16 +21,16 @@ $this->tie_cult = $data['aa_tie_cult']; $this->image = $data['aa_image']; $this->name = $data['aal_name']; - $this->done = $data['']; + $this->template = $data['aal_template']; #echo $this->id; - $res = $db->sqlQuery("SELECT * FROM ach_perk LEFT JOIN (ach_perk_lang) ON (apl_lang='".$lang."' AND apl_perk=ap_id) LEFT JOIN (ach_player_perk) ON (app_perk=ap_id AND app_player='".$user."') WHERE ap_achievement='".$this->id."' AND ap_parent IS NULL"); + $res = $DBc->sqlQuery("SELECT * FROM ach_perk LEFT JOIN (ach_perk_lang) ON (apl_lang='".$_USER->getLang()."' AND apl_perk=ap_id) LEFT JOIN (ach_player_perk) ON (app_perk=ap_id AND app_player='".$_USER->getID()."') WHERE ap_achievement='".$this->id."' AND ap_parent IS NULL"); #MISSING: or parent is done $sz = sizeof($res); for($i=0;$i<$sz;$i++) { #echo "Z"; - $tmp = new AchPerk($res[$i],$lang,$user); + $tmp = new AchPerk($res[$i],$this); #echo var_export($tmp,true); @@ -88,5 +89,20 @@ function getValueOpen() { return $this->nodes[$this->child_open[0]]->getValue(); } + + function getTemplate($insert = array()) { + if($this->template == null) { + return implode(";",$insert); + } + else { + $tmp = $this->template; + $match = array(); + preg_match_all('#\[([0-9]+)\]#', $this->template, $match); + foreach($match[0] as $key=>$elem) { + $tmp = str_replace("[".$match[1][$key]."]",$insert[$key],$tmp); + } + return $tmp; + } + } } ?> \ No newline at end of file diff --git a/code/web/app/app_achievements/class/AchCategory_class.php b/code/web/app/app_achievements/class/AchCategory_class.php new file mode 100644 index 000000000..995cb6a2a --- /dev/null +++ b/code/web/app/app_achievements/class/AchCategory_class.php @@ -0,0 +1,48 @@ +id = $id; + + $res = $DBc->sqlQuery("SELECT * FROM ach_achievement LEFT JOIN (ach_achievement_lang) ON (aal_lang='".$_USER->getLang()."' AND aal_achievement=aa_id) WHERE aa_category='".$this->id."' AND aa_parent IS NULL AND (aa_tie_race IS NULL OR aa_tie_race='".$_USER->getParam('race')."') AND (aa_tie_cult IS NULL OR aa_tie_cult='".$cult."') AND (aa_tie_civ IS NULL OR aa_tie_civ='".$civ."') ORDER by aal_name ASC"); + #MISSING: or parent is done + $sz = sizeof($res); + for($i=0;$i<$sz;$i++) { + #echo "Y"; + $tmp = new AchAchievement($res[$i]); + #echo var_export($tmp,true); + if($tmp->hasOpen()) { + $this->child_open[] = sizeof($this->nodes); + } + if($tmp->hasDone()) { + $this->child_done[] = sizeof($this->nodes); + } + + $this->nodes[] = $tmp; + } + + $res = $DBc->sqlQuery("SELECT count(*) FROM ach_achievement WHERE aa_tie_cult IS NOT NULL"); + $this->ties_cult = $res[0]['anz']; + + $res = $DBc->sqlQuery("SELECT count(*) FROM ach_achievement WHERE aa_tie_civ IS NOT NULL"); + $this->ties_civ = $res[0]['anz']; + } + + function getID() { + return $this->id; + } + + function isTiedCult() { + return ($this->ties_cult > 0); + } + + function isTiedCiv() { + return ($this->ties_civ > 0); + } + } +?> \ No newline at end of file diff --git a/code/web/app/app_achievements/include/AchCommon_class.php b/code/web/app/app_achievements/class/AchList_abstract.php similarity index 52% rename from code/web/app/app_achievements/include/AchCommon_class.php rename to code/web/app/app_achievements/class/AchList_abstract.php index e2200c5c5..707aef425 100644 --- a/code/web/app/app_achievements/include/AchCommon_class.php +++ b/code/web/app/app_achievements/class/AchList_abstract.php @@ -1,24 +1,4 @@ nodes); - } - - function getChild($i) { - return $this->nodes[$i]; - } - - function isEmpty() { - return (sizeof($this->nodes) == 0); - } - - function getChildren() { - return $this->nodes; - } - } - abstract class AchList extends RenderNodeIterator { protected $child_done = array(); protected $child_open = array(); diff --git a/code/web/app/app_achievements/include/AchMenu_class.php b/code/web/app/app_achievements/class/AchMenu_class.php similarity index 64% rename from code/web/app/app_achievements/include/AchMenu_class.php rename to code/web/app/app_achievements/class/AchMenu_class.php index 041b492fe..a432dbdb7 100644 --- a/code/web/app/app_achievements/include/AchMenu_class.php +++ b/code/web/app/app_achievements/class/AchMenu_class.php @@ -2,24 +2,24 @@ class AchMenu extends RenderNodeIterator { var $open; - function AchMenu($open = false,$lang = 'en') { - global $db; + function AchMenu($open = false) { + global $DBc,$_USER; $this->open = $open; $tmp = array(); $tmp['ac_id'] = 0; $tmp['ac_parent'] = null; - $tmp['acl_name'] = get_translation('ach_summary',$lang); + $tmp['acl_name'] = get_translation('ach_summary',$_USER->getLang()); $tmp['ac_image'] = ""; $tmp['ac_order'] = -1; $this->nodes[] = new AchMenuNode($tmp,$open,$lang); - $res = $db->sqlQuery("SELECT * FROM ach_category LEFT JOIN (ach_category_lang) ON (acl_lang='".$lang."' AND acl_category=ac_id) WHERE ac_parent IS NULL ORDER by ac_order ASC, acl_name ASC"); + $res = $DBc->sqlQuery("SELECT * FROM ach_category LEFT JOIN (ach_category_lang) ON (acl_lang='".$_USER->getLang()."' AND acl_category=ac_id) WHERE ac_parent IS NULL ORDER by ac_order ASC, acl_name ASC"); $sz = sizeof($res); for($i=0;$i<$sz;$i++) { - $this->nodes[] = new AchMenuNode($res[$i],$open,$lang); + $this->nodes[] = new AchMenuNode($res[$i],$open); } } @@ -46,8 +46,8 @@ private $image; private $order; - function AchMenuNode(&$data,$open,$lang) { - global $db; + function AchMenuNode(&$data,$open) { + global $DBc,$_USER; $this->id = $data['ac_id']; $this->parent = $data['ac_parent']; @@ -56,11 +56,11 @@ $this->order = $data['ac_order']; $this->open = ($this->id == $open); - $res = $db->sqlQuery("SELECT * FROM ach_category LEFT JOIN (ach_category_lang) ON (acl_lang='".$lang."' AND acl_category=ac_id) WHERE ac_parent='".$this->id."' ORDER by ac_order ASC, acl_name ASC"); + $res = $DBc->sqlQuery("SELECT * FROM ach_category LEFT JOIN (ach_category_lang) ON (acl_lang='".$_USER->getLang()."' AND acl_category=ac_id) WHERE ac_parent='".$this->id."' ORDER by ac_order ASC, acl_name ASC"); $sz = sizeof($res); for($i=0;$i<$sz;$i++) { - $this->nodes[] = new AchMenuNode($res[$i],$open,$lang); + $this->nodes[] = new AchMenuNode($res[$i],$open); } } diff --git a/code/web/app/app_achievements/include/AchObjective_class.php b/code/web/app/app_achievements/class/AchObjective_class.php similarity index 77% rename from code/web/app/app_achievements/include/AchObjective_class.php rename to code/web/app/app_achievements/class/AchObjective_class.php index d8a596b8c..2f36fad01 100644 --- a/code/web/app/app_achievements/include/AchObjective_class.php +++ b/code/web/app/app_achievements/class/AchObjective_class.php @@ -9,8 +9,8 @@ private $done; private $progress; - function AchObjective(&$data,$lang,$user) { - global $db; + function AchObjective(&$data) { + global $DBc,$_USER; $this->id = $data['ao_id']; $this->perk = $data['ao_perk']; @@ -23,7 +23,7 @@ $this->progress = $this->value; if(!$this->isDone()) { - $res = $db->sqlQuery("SELECT count(*) as anz FROM ach_player_atom,ach_atom WHERE apa_atom=atom_id AND atom_objective='".$this->id."' AND apa_player='".$user."'"); + $res = $DBc->sqlQuery("SELECT count(*) as anz FROM ach_player_atom,ach_atom WHERE apa_atom=atom_id AND atom_objective='".$this->id."' AND apa_player='".$_USER->getId()."'"); $this->progress = $res[0]['anz']; } } diff --git a/code/web/app/app_achievements/include/AchPerk_class.php b/code/web/app/app_achievements/class/AchPerk_class.php similarity index 63% rename from code/web/app/app_achievements/include/AchPerk_class.php rename to code/web/app/app_achievements/class/AchPerk_class.php index 30adff2e6..e6896e249 100644 --- a/code/web/app/app_achievements/include/AchPerk_class.php +++ b/code/web/app/app_achievements/class/AchPerk_class.php @@ -7,20 +7,20 @@ private $name; private $done; - function AchPerk(&$data,$lang,$user) { - global $db; + function AchPerk(&$data,&$parent) { + global $DBc,$_USER; $this->id = $data['ap_id']; - $this->parent = $data['ap_parent']; + $this->parent = $parent; $this->achievement = $data['ap_achievement']; $this->value = $data['ap_value']; $this->name = $data['apl_name']; $this->done = $data['app_date']; - $res = $db->sqlQuery("SELECT * FROM ach_objective LEFT JOIN (ach_objective_lang) ON (aol_lang='".$lang."' AND aol_objective=ao_id) LEFT JOIN (ach_player_objective) ON (apo_objective=ao_id AND apo_player='".$user."') 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()."') WHERE ao_perk='".$this->id."'"); $sz = sizeof($res); for($i=0;$i<$sz;$i++) { - $this->nodes[] = new AchObjective($res[$i],$lang,$user); + $this->nodes[] = new AchObjective($res[$i]); } } @@ -41,7 +41,7 @@ } function getName() { - return $this->name; + return $this->parent->getTemplate(explode(";",$this->name)); } function objDrawable() { diff --git a/code/web/app/app_achievements/class/AchSummary_class.php b/code/web/app/app_achievements/class/AchSummary_class.php new file mode 100644 index 000000000..5a4c5b5b9 --- /dev/null +++ b/code/web/app/app_achievements/class/AchSummary_class.php @@ -0,0 +1,69 @@ +menu = $menu; + + //read all recent perks of user + //make distinct achievement list + + $res = $DBc->sqlQuery("SELECT DISTINCT aa_id,ach.*,(SELECT aal_name FROM ach_achievement_lang WHERE aal_lang='".$_USER->getLang()."' AND aal_achievement=ach.aa_id) as aal_name FROM ach_achievement as ach,ach_perk,ach_player_perk WHERE ap_achievement=aa_id AND app_player='".$_USER->getID()."' AND app_perk=ap_id ORDER by app_date DESC LIMIT 0,".($size-1)); + + $sz = sizeof($res); + for($i=0;$i<$sz;$i++) { + $tmp = new AchAchievement($res[$i]); + + $this->child_done[] = sizeof($this->nodes); + $this->nodes[] = $tmp; + } + } + + function getSummary() { + if(!is_array($this->stats)) { // only load if needed + //now we have to find the # of perks for each main menu entry + //and also sum up how many have been completed + $this->stats = array(); // [][name,done,total] + + $tmp = $this->menu->getChildren(); + foreach($tmp as $elem) { + if($elem->getID() == 0) { + continue; // skip summary page + } + $res = $this->sumStats($elem); + $this->stats[] = array($elem->getName(),$res[0],$res[1]); + } + } + + return $this->stats; + } + + private function sumStats(&$node) { + global $DBc,$_USER; + + $done = 0; + $total = 0; + + //read for current ID + //sum + $res = $DBc->sqlQuery("SELECT count(ap_id) as anz FROM ach_perk,ach_achievement,ach_player_perk WHERE aa_category='".$node->getID()."' AND ap_achievement=aa_id AND app_player='".$_USER->getID()."' AND app_perk=ap_id"); + $done += $res[0]["anz"]; + + $res = $DBc->sqlQuery("SELECT count(ap_id) as anz FROM ach_perk,ach_achievement WHERE aa_category='".$node->getID()."' AND ap_achievement=aa_id"); + $total += $res[0]["anz"]; + + $tmp = $node->getChildren(); + foreach($tmp as $elem) { + $res = $this->sumStats($elem); + $done += $res[0]; + $total += $res[1]; + } + + return array($done,$total); + + } + } +?> \ No newline at end of file diff --git a/code/web/app/app_achievements/class/RenderNodeIteraor_abstract.php b/code/web/app/app_achievements/class/RenderNodeIteraor_abstract.php new file mode 100644 index 000000000..87ac9b460 --- /dev/null +++ b/code/web/app/app_achievements/class/RenderNodeIteraor_abstract.php @@ -0,0 +1,21 @@ +nodes); + } + + function getChild($i) { + return $this->nodes[$i]; + } + + function isEmpty() { + return (sizeof($this->nodes) == 0); + } + + function getChildren() { + return $this->nodes; + } + } +?> \ No newline at end of file diff --git a/code/web/app/app_achievements/class/RyzomUser_class.php b/code/web/app/app_achievements/class/RyzomUser_class.php new file mode 100644 index 000000000..e2ac7ed7e --- /dev/null +++ b/code/web/app/app_achievements/class/RyzomUser_class.php @@ -0,0 +1,25 @@ +data = $data; + } + + function getID() { + return 1; + } + + function getLang() { + return $this->data['lang']; + } + + function isIG() { + return $this->data['ig']; + } + + function getParam($p) { + return $this->data[$p]; + } + } +?> \ No newline at end of file diff --git a/code/web/app/app_achievements/include/AchCategory_class.php b/code/web/app/app_achievements/include/AchCategory_class.php deleted file mode 100644 index a18f523af..000000000 --- a/code/web/app/app_achievements/include/AchCategory_class.php +++ /dev/null @@ -1,32 +0,0 @@ -id = $id; - - $res = $db->sqlQuery("SELECT * FROM ach_achievement LEFT JOIN (ach_achievement_lang) ON (aal_lang='".$lang."' AND aal_achievement=aa_id) WHERE aa_category='".$this->id."' AND aa_parent IS NULL ORDER by aal_name ASC"); - #MISSING: or parent is done - $sz = sizeof($res); - for($i=0;$i<$sz;$i++) { - #echo "Y"; - $tmp = new AchAchievement($res[$i],$lang,$user); - #echo var_export($tmp,true); - if($tmp->hasOpen()) { - $this->child_open[] = sizeof($this->nodes); - } - if($tmp->hasDone()) { - $this->child_done[] = sizeof($this->nodes); - } - - $this->nodes[] = $tmp; - } - } - - function getID() { - return $this->id; - } - } -?> \ No newline at end of file diff --git a/code/web/app/app_achievements/include/AchSummary_class.php b/code/web/app/app_achievements/include/AchSummary_class.php deleted file mode 100644 index 836642f82..000000000 --- a/code/web/app/app_achievements/include/AchSummary_class.php +++ /dev/null @@ -1,69 +0,0 @@ -menu = $menu; - - //read all recent perks of user - //make distinct achievement list - - $res = $db->sqlQuery("SELECT DISTINCT aa_id,ach.*,(SELECT aal_name FROM ach_achievement_lang WHERE aal_lang='".$lang."' AND aal_achievement=ach.aa_id) as aal_name FROM ach_achievement as ach,ach_perk,ach_player_perk WHERE ap_achievement=aa_id AND app_player='".$user."' AND app_perk=ap_id ORDER by app_date DESC LIMIT 0,".($size-1)); - - $sz = sizeof($res); - for($i=0;$i<$sz;$i++) { - $tmp = new AchAchievement($res[$i],$lang,$user); - - $this->child_done[] = sizeof($this->nodes); - $this->nodes[] = $tmp; - } - } - - function getSummary($lang,$user) { - if(!is_array($this->stats)) { // only load if needed - //now we have to find the # of perks for each main menu entry - //and also sum up how many have been completed - $this->stats = array(); // [][name,done,total] - - $tmp = $this->menu->getChildren(); - foreach($tmp as $elem) { - if($elem->getID() == 0) { - continue; // skip summary page - } - $res = $this->sumStats($elem,$user); - $this->stats[] = array($elem->getName(),$res[0],$res[1]); - } - } - - return $this->stats; - } - - private function sumStats(&$node,$user) { - global $db; - - $done = 0; - $total = 0; - - //read for current ID - //sum - $res = $db->sqlQuery("SELECT count(ap_id) as anz FROM ach_perk,ach_achievement,ach_player_perk WHERE aa_category='".$node->getID()."' AND ap_achievement=aa_id AND app_player='".$user."' AND app_perk=ap_id"); - $done += $res[0]["anz"]; - - $res = $db->sqlQuery("SELECT count(ap_id) as anz FROM ach_perk,ach_achievement WHERE aa_category='".$node->getID()."' AND ap_achievement=aa_id"); - $total += $res[0]["anz"]; - - $tmp = $node->getChildren(); - foreach($tmp as $elem) { - $res = $this->sumStats($elem,$user); - $done += $res[0]; - $total += $res[1]; - } - - return array($done,$total); - - } - } -?> \ No newline at end of file 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 6aead3225..6a8f05a06 100644 --- a/code/web/app/app_achievements/include/ach_render_web.php +++ b/code/web/app/app_achievements/include/ach_render_web.php @@ -1,7 +1,21 @@ sqlQuery("SELECT sum(ap_value) as anz FROM ach_perk,ach_player_perk WHERE ap_id=app_perk AND app_player='".$_USER->getID()."'"); + + $html = "
".get_translation('ach_summary_stats_total',$lang)." ".ach_render_progressbar($sum_done,$sum_total,450)." |
+ ".get_translation('ach_summary_stats_total',$_USER->getLang())." ".ach_render_progressbar($sum_done,$sum_total,450)." |
".ach_render_yubopoints(1)." | +|
";
#$_REQUEST['mid'] = 1;
- $menu = new AchMenu($_REQUEST['cat'],$user['lang']);
+ $menu = new AchMenu($_REQUEST['cat']);
$c .= ach_render_menu($menu);
@@ -67,22 +74,35 @@ $c .= " |
$open = $menu->getOpenCat();
if($open != 0) {
- $cat = new AchCategory($open,1,$user['lang']);
+ if($_REQUEST['cult']) {
+ $cult = mysql_real_escape_string($_REQUEST['cult']);
+ }
+ else {
+ $cult = $_USER->getParam('cult');
+ }
+
+ if($_REQUEST['civ']) {
+ $civ = mysql_real_escape_string($_REQUEST['civ']);
+ }
+ else {
+ $civ = $_USER->getParam('civ');
+ }
+ $cat = new AchCategory($open,$cult,$civ);
}
else {
- $cat = new AchSummary($menu,1,8,$user['lang']);
- $c .= ach_render_summary_header($user['lang']);
+ $cat = new AchSummary($menu,8);
+ $c .= ach_render_summary_header();
}
$c .= ach_render_category($cat);
if($open == 0) {
- $c .= ach_render_summary_footer($user['lang'],$cat,1);
+ $c .= ach_render_summary_footer($cat,1);
}
$c .= "