diff --git a/code/web/app/app_achievements/_doc/Class_scheme.dia b/code/web/app/app_achievements/_doc/Class_scheme.dia new file mode 100644 index 000000000..cee3d3deb Binary files /dev/null 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 new file mode 100644 index 000000000..e1848de30 Binary files /dev/null and b/code/web/app/app_achievements/_doc/Class_scheme.png differ diff --git a/code/web/app/app_achievements/_doc/ER_scheme.dia b/code/web/app/app_achievements/_doc/ER_scheme.dia index 97df04ff7..346035702 100644 Binary files a/code/web/app/app_achievements/_doc/ER_scheme.dia and b/code/web/app/app_achievements/_doc/ER_scheme.dia differ diff --git a/code/web/app/app_achievements/_doc/ER_scheme.png b/code/web/app/app_achievements/_doc/ER_scheme.png index 40c9687c0..1281febfb 100644 Binary files a/code/web/app/app_achievements/_doc/ER_scheme.png and b/code/web/app/app_achievements/_doc/ER_scheme.png differ diff --git a/code/web/app/app_achievements/_doc/devshot_002.jpg b/code/web/app/app_achievements/_doc/devshot_002.jpg new file mode 100644 index 000000000..8244cb103 Binary files /dev/null and b/code/web/app/app_achievements/_doc/devshot_002.jpg differ diff --git a/code/web/app/app_achievements/_doc/testdata.sql b/code/web/app/app_achievements/_doc/testdata.sql index 92a0074f5..8f230fd55 100644 --- a/code/web/app/app_achievements/_doc/testdata.sql +++ b/code/web/app/app_achievements/_doc/testdata.sql @@ -3,7 +3,7 @@ -- http://www.phpmyadmin.net -- -- Host: localhost --- Erstellungszeit: 27. Mai 2012 um 21:06 +-- Erstellungszeit: 28. Mai 2012 um 21:07 -- Server Version: 5.1.46 -- PHP-Version: 5.3.2 @@ -51,11 +51,37 @@ INSERT INTO `ach_atom` (`atom_id`, `atom_objective`, `atom_mandatory`, `atom_rul -- INSERT INTO `ach_category` (`ac_id`, `ac_parent`, `ac_order`, `ac_image`) VALUES -(1, NULL, 0, ''), -(2, NULL, 0, ''), -(3, 1, 0, ''), -(4, 1, 0, ''), -(5, 1, 0, ''); +(1, NULL, 20, ''), +(2, NULL, 40, ''), +(3, 1, 2000, ''), +(4, 1, 2000, ''), +(5, 1, 2000, ''), +(6, NULL, 70, ''), +(7, NULL, 30, ''), +(8, NULL, 50, ''), +(9, NULL, 10, ''), +(10, 1, 2000, ''), +(11, 1, 2010, ''), +(12, 8, 5000, ''), +(13, 8, 5000, ''), +(14, 8, 5000, ''), +(15, 8, 5000, ''), +(16, 6, 7010, ''), +(17, 6, 7020, ''), +(18, 6, 7200, ''), +(19, 7, 3010, ''), +(20, 7, 3010, ''), +(21, 7, 3020, ''), +(22, 7, 3020, ''), +(23, 7, 3020, ''), +(24, 7, 3030, ''), +(25, 7, 3040, ''), +(26, 7, 3020, ''), +(27, 6, 7100, ''), +(28, NULL, 60, ''), +(29, 28, 6010, ''), +(30, 28, 6020, ''), +(31, NULL, 80, ''); -- -- Daten für Tabelle `ach_category_lang` @@ -66,7 +92,33 @@ INSERT INTO `ach_category_lang` (`acl_category`, `acl_lang`, `acl_name`) VALUES (2, 'en', 'Occupations'), (3, 'en', 'Aeden Aqueous'), (4, 'en', 'Burning Desert'), -(5, 'en', 'Witherings'); +(5, 'en', 'Witherings'), +(6, 'en', 'The Saga of Ryzom'), +(7, 'en', 'Fame'), +(8, 'en', 'Skills'), +(9, 'en', 'General'), +(10, 'en', 'Verdant Heights'), +(11, 'en', 'Prime Roots'), +(12, 'en', 'Craft'), +(13, 'en', 'Fight'), +(14, 'en', 'Harvest'), +(15, 'en', 'Magic'), +(16, 'en', 'Episode I'), +(17, 'en', 'Episode II'), +(18, 'en', 'Legacy'), +(19, 'en', 'Civilizations'), +(20, 'en', 'Higher Powers'), +(21, 'en', 'Aeden Aqueous'), +(22, 'en', 'Burning Desert'), +(23, 'en', 'Verdant Heights'), +(24, 'en', 'The Nexus'), +(25, 'en', 'Prime Roots'), +(26, 'en', 'Witherings'), +(27, 'en', 'Encyclopedia'), +(28, 'en', 'PvP'), +(29, 'en', 'Civilizations'), +(30, 'en', 'Higher Powers'), +(31, 'en', 'Ryzom Ring'); -- -- Daten für Tabelle `ach_objective` diff --git a/code/web/app/app_achievements/include/AchMenu_class.php b/code/web/app/app_achievements/include/AchMenu_class.php index 9ae468406..041b492fe 100644 --- a/code/web/app/app_achievements/include/AchMenu_class.php +++ b/code/web/app/app_achievements/include/AchMenu_class.php @@ -6,6 +6,14 @@ global $db; $this->open = $open; + + $tmp = array(); + $tmp['ac_id'] = 0; + $tmp['ac_parent'] = null; + $tmp['acl_name'] = get_translation('ach_summary',$lang); + $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"); @@ -15,9 +23,19 @@ } } - function getCat() { + function getOpen() { return $this->open; } + + function getOpenCat() { + foreach($this->nodes as $elem) { + $res = $elem->hasOpenCat(); + if($res != 0) { + return $res; + } + } + return 0; + } } class AchMenuNode extends RenderNodeIterator { @@ -36,7 +54,7 @@ $this->name = $data['acl_name']; $this->image = $data['ac_image']; $this->order = $data['ac_order']; - $this->open = ($open==$data['ac_id']); + $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"); @@ -58,6 +76,20 @@ return $this->parent; } + function hasOpenCat() { + if($this->open) { + return $this->id; + } + + foreach($this->nodes as $elem) { + $res = $elem->hasOpenCat(); + if($res != 0) { + return $res; + } + } + return 0; + } + function isOpen() { return $this->open; } diff --git a/code/web/app/app_achievements/include/AchSummary_class.php b/code/web/app/app_achievements/include/AchSummary_class.php index ba402726a..836642f82 100644 --- a/code/web/app/app_achievements/include/AchSummary_class.php +++ b/code/web/app/app_achievements/include/AchSummary_class.php @@ -1,20 +1,69 @@ sqlQuery("SELECT * FROM ach_achievement LEFT JOIN (ach_achievement_lang) ON (aal_lang='".$lang."' AND aal_achievement=aa_id) WHERE aa_parent IS NULL"); - #MISSING: or parent is done - #MISSING: player's status on achievement + $this->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); - if($tmp->hasDone()) { - $this->child_done[] = sizeof($this->nodes); - $this->nodes[] = $tmp; + $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 4abf20f83..6aead3225 100644 --- a/code/web/app/app_achievements/include/ach_render_web.php +++ b/code/web/app/app_achievements/include/ach_render_web.php @@ -25,17 +25,21 @@ $sz = $menu->getSize(); for($i=0;$i<$sz;$i++) { $curr = $menu->getChild($i); - $html .= " - - -
+ "; + if($sub == 0) { + $html .= ""; + } + $html .= " -
".$curr->getName()."
-
".ach_render_menu($curr,($sub+4))."
"; +
"; + if($curr->hasOpenCat() != 0) { + $html .= "
".ach_render_menu($curr,($sub+4))."
"; + } } return $html; @@ -256,15 +260,18 @@ else { $col = "#999999"; } - $html .= "
".$obj->getName()."
"; + $html .= "
".$obj->getName()."
"; - $val = $obj->getValue(); - $prog = $obj->getProgress(); + $html .= ach_render_progressbar($obj->getProgress(),$obj->getValue(),350); + + return $html; + } - $width = 350; + function ach_render_progressbar($prog,$val,$width) { + $val = max(1,$val); $left = floor($width*(100*($prog/$val))/100); - $html .= " + $html = " "; + } + + $html .= ""; + $sum_done += $elem[1]; + $sum_total += $elem[2]; + + if(($i%3) == 2) { + $html .= ""; + } + + $i++; + } + + if(($i%3) == 2) { + $html .= ""; + } + + $html = "

+

".get_translation('ach_summary_stats',$lang)."
+
"; @@ -282,4 +289,48 @@ return $html; } + + function ach_render_summary_header($lang) { + return "
".get_translation('ach_summary_header',$lang)."
"; + } + + function ach_render_summary_footer($lang,&$summary,$user) { + $nodes = $summary->getSummary($lang,$user); + $html = ""; + + $sum_done = 0; + $sum_total = 0; + + $i = 0; + foreach($nodes as $elem) { + if(($i%3) == 0) { + $html .= "
".$elem[0]."
".ach_render_progressbar($elem[1],$elem[2],200)."
+ + + + ".$html." +
".get_translation('ach_summary_stats_total',$lang)."
".ach_render_progressbar($sum_done,$sum_total,450)."
"; + + return $html; + } ?> \ No newline at end of file diff --git a/code/web/app/app_achievements/index.php b/code/web/app/app_achievements/index.php index 5287f2275..c3f44a8a8 100644 --- a/code/web/app/app_achievements/index.php +++ b/code/web/app/app_achievements/index.php @@ -50,10 +50,10 @@ $c = _t('access', $num_access['num_access']).'
';*/ $c = "
- $c .= ach_render_box_done("Bejeweled"); }*/ -#if($menu->isSelected()) { - $cat = new AchCategory($menu->getCat(),1,$user['lang']); -#} -#else { -# $cat = new AchSummary(12,$user['lang']); -#} +$open = $menu->getOpenCat(); + +if($open != 0) { + $cat = new AchCategory($open,1,$user['lang']); +} +else { + $cat = new AchSummary($menu,1,8,$user['lang']); + $c .= ach_render_summary_header($user['lang']); +} $c .= ach_render_category($cat); +if($open == 0) { + $c .= ach_render_summary_footer($user['lang'],$cat,1); +} $c .= " diff --git a/code/web/app/app_achievements/lang.php b/code/web/app/app_achievements/lang.php index 0a877c548..b3a4fa97b 100644 --- a/code/web/app/app_achievements/lang.php +++ b/code/web/app/app_achievements/lang.php @@ -1,13 +1,37 @@ + 'ach_summary' => array ( - 'en' => 'User access this page %s times', - 'fr' => 'L\'utilisateur a accede a cette page %s fois', + 'en' => 'Summary', + 'fr' => '', + 'de' => '', + 'ru' => '', + ), + 'ach_summary_header' => + array ( + 'en' => 'Recent Achievements', + 'fr' => '', + 'de' => '', + 'ru' => '', + ), + 'ach_summary_stats' => + array ( + 'en' => 'Statistics', + 'fr' => '', + 'de' => '', + 'ru' => '', + ), + 'ach_summary_stats_total' => + array ( + 'en' => 'Total', + 'fr' => '', 'de' => '', 'ru' => '', ), ); + + if(isset($ryzom_texts)) $ryzom_texts = array_merge ($__texts, $ryzom_texts); else
"; - $_REQUEST['mid'] = 1; +
"; + #$_REQUEST['mid'] = 1; - $menu = new AchMenu($_REQUEST['mid'],$user['lang']); + $menu = new AchMenu($_REQUEST['cat'],$user['lang']); $c .= ach_render_menu($menu); @@ -64,14 +64,20 @@ $c .= "