diff --git a/code/web/api/common/render.php b/code/web/api/common/render.php index 60b101d38..e086db9dd 100644 --- a/code/web/api/common/render.php +++ b/code/web/api/common/render.php @@ -47,7 +47,7 @@ function ryzom_app_render($title, $content, $ig=false, $bgcolor='', $javascript= $c .= ryzom_render_www(ryzom_render_window($title, $content, $homeLink)); $c .= ''; } else { - $c .= ''; + $c .= ''; $c .= $content; $debug = ryLogger::getInstance()->getLogs(); if ($debug) diff --git a/code/web/app/app_achievements/_doc/ER_scheme.dia b/code/web/app/app_achievements/_doc/ER_scheme.dia new file mode 100644 index 000000000..97df04ff7 Binary files /dev/null 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 c75a2efac..40c9687c0 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/app_achievements.sql b/code/web/app/app_achievements/_doc/app_achievements.sql index fdc390dcf..79d22f5f3 100644 --- a/code/web/app/app_achievements/_doc/app_achievements.sql +++ b/code/web/app/app_achievements/_doc/app_achievements.sql @@ -3,7 +3,7 @@ -- http://www.phpmyadmin.net -- -- Host: localhost --- Erstellungszeit: 17. Mai 2012 um 01:47 +-- Erstellungszeit: 25. Mai 2012 um 11:46 -- Server Version: 5.1.46 -- PHP-Version: 5.3.2 @@ -36,11 +36,6 @@ CREATE TABLE IF NOT EXISTS `ach_achievement` ( PRIMARY KEY (`aa_id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin AUTO_INCREMENT=1 ; --- --- Daten für Tabelle `ach_achievement` --- - - -- -------------------------------------------------------- -- @@ -54,11 +49,6 @@ CREATE TABLE IF NOT EXISTS `ach_achievement_lang` ( PRIMARY KEY (`aal_achievement`,`aal_lang`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin; --- --- Daten für Tabelle `ach_achievement_lang` --- - - -- -------------------------------------------------------- -- @@ -70,14 +60,10 @@ CREATE TABLE IF NOT EXISTS `ach_atom` ( `atom_objective` bigint(20) unsigned NOT NULL, `atom_mandatory` tinyint(1) unsigned NOT NULL, `atom_ruleset` blob NOT NULL, + `atom_primary` tinyint(1) unsigned NOT NULL, PRIMARY KEY (`atom_id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin AUTO_INCREMENT=1 ; --- --- Daten für Tabelle `ach_atom` --- - - -- -------------------------------------------------------- -- @@ -88,12 +74,7 @@ CREATE TABLE IF NOT EXISTS `ach_category` ( `ac_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, `ac_parent` bigint(20) unsigned DEFAULT NULL, PRIMARY KEY (`ac_id`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin AUTO_INCREMENT=1 ; - --- --- Daten für Tabelle `ach_category` --- - +) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin AUTO_INCREMENT=3 ; -- -------------------------------------------------------- @@ -108,11 +89,6 @@ CREATE TABLE IF NOT EXISTS `ach_category_lang` ( PRIMARY KEY (`acl_category`,`acl_lang`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin; --- --- Daten für Tabelle `ach_category_lang` --- - - -- -------------------------------------------------------- -- @@ -124,14 +100,10 @@ CREATE TABLE IF NOT EXISTS `ach_objective` ( `ao_perk` bigint(20) unsigned NOT NULL, `ao_condition` enum('all','any','value') COLLATE utf8_bin NOT NULL, `ao_value` int(10) unsigned DEFAULT NULL, + `ao_display` enum('simple','meta','value') COLLATE utf8_bin NOT NULL DEFAULT 'simple', PRIMARY KEY (`ao_id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin AUTO_INCREMENT=1 ; --- --- Daten für Tabelle `ach_objective` --- - - -- -------------------------------------------------------- -- @@ -145,11 +117,6 @@ CREATE TABLE IF NOT EXISTS `ach_objective_lang` ( PRIMARY KEY (`aol_objective`,`aol_lang`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin; --- --- Daten für Tabelle `ach_objective_lang` --- - - -- -------------------------------------------------------- -- @@ -165,11 +132,6 @@ CREATE TABLE IF NOT EXISTS `ach_perk` ( UNIQUE KEY `ap_parent` (`ap_parent`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin AUTO_INCREMENT=1 ; --- --- Daten für Tabelle `ach_perk` --- - - -- -------------------------------------------------------- -- @@ -183,11 +145,6 @@ CREATE TABLE IF NOT EXISTS `ach_perk_lang` ( PRIMARY KEY (`apl_perk`,`apl_lang`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin; --- --- Daten für Tabelle `ach_perk_lang` --- - - -- -------------------------------------------------------- -- @@ -202,11 +159,6 @@ CREATE TABLE IF NOT EXISTS `ach_player_atom` ( PRIMARY KEY (`apa_atom`,`apa_player`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin; --- --- Daten für Tabelle `ach_player_atom` --- - - -- -------------------------------------------------------- -- @@ -220,11 +172,6 @@ CREATE TABLE IF NOT EXISTS `ach_player_objective` ( PRIMARY KEY (`apo_objective`,`apo_player`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin; --- --- Daten für Tabelle `ach_player_objective` --- - - -- -------------------------------------------------------- -- @@ -238,11 +185,6 @@ CREATE TABLE IF NOT EXISTS `ach_player_perk` ( PRIMARY KEY (`app_perk`,`app_player`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin; --- --- Daten für Tabelle `ach_player_perk` --- - - -- -------------------------------------------------------- -- @@ -256,8 +198,3 @@ CREATE TABLE IF NOT EXISTS `ach_player_valuecache` ( `apv_date` bigint(20) unsigned NOT NULL, PRIMARY KEY (`apv_name`,`apv_player`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin; - --- --- Daten für Tabelle `ach_player_valuecache` --- - diff --git a/code/web/app/app_achievements/conf.php b/code/web/app/app_achievements/conf.php new file mode 100644 index 000000000..e4e3a504e --- /dev/null +++ b/code/web/app/app_achievements/conf.php @@ -0,0 +1,13 @@ + \ No newline at end of file diff --git a/code/web/app/app_achievements/include/AchAchievement_class.php b/code/web/app/app_achievements/include/AchAchievement_class.php new file mode 100644 index 000000000..4b92d9ffc --- /dev/null +++ b/code/web/app/app_achievements/include/AchAchievement_class.php @@ -0,0 +1,78 @@ +id = $data['aa_id']; + $this->parent = $data['aa_parent']; + $this->category = $data['aa_category']; + $this->tie_race = $data['aa_tie_race']; + $this->tie_civ = $data['aa_tie_civ']; + $this->tie_cult = $data['aa_tie_cult']; + $this->image = $data['aa_image']; + $this->name = $data['aal_name']; + + $res = $db->sqlQuery("SELECT * FROM ach_perk LEFT JOIN (ach_perk_lang) ON (apl_lang='".$lang."' AND apl_achievement=ap_id) WHERE ap_achievement='".$this->id."' AND ap_parent IS NULL"); + #MISSING: or parent is done + $sz = sizeof($res); + for($i=0;$i<$sz;$i++) { + $tmp = new AchPerk($res[$i],$lang); + + $this->child_open[] = sizeof($this->nodes); + $this->nodes[] = $tmp; + /*if($res[$i]['']) { + + } + else { + + }*/ + #MISSING: divide into groups -> open/done + } + } + + function getID() { + return $this->id; + } + + function getParent() { + return $this->parent; + } + + function getTieRace() { + return $this->tie_race; + } + + function getTieCiv() { + return $this->tie_civ; + } + + function getTieCult() { + return $this->tie_cult; + } + + function getImage() { + return $this->image; + } + + function getName() { + return $this->name; + } + + function getValue() { + $val = 0; + foreach($this->child_done as $elem) { + $val += $this->nodes[$elem]->getValue(); + } + return $val; + } + } +?> \ 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 new file mode 100644 index 000000000..d7b27fd6c --- /dev/null +++ b/code/web/app/app_achievements/include/AchCategory_class.php @@ -0,0 +1,30 @@ +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"); + #MISSING: or parent is done + $sz = sizeof($res); + for($i=0;$i<$sz;$i++) { + $tmp = new AchAchievement($res[$i],$lang); + 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/AchCommon_class.php b/code/web/app/app_achievements/include/AchCommon_class.php new file mode 100644 index 000000000..f0c0778b6 --- /dev/null +++ b/code/web/app/app_achievements/include/AchCommon_class.php @@ -0,0 +1,42 @@ +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 { + private $child_done = array(); + private $child_open = array(); + + function getDone() { + return $this->child_done; + } + + function getOpen() { + return $this->child_open; + } + + function hasOpen() { + return (sizeof($this->child_open) != 0); + } + + function hasDone() { + return (sizeof($this->child_done) != 0); + } + } +?> \ No newline at end of file diff --git a/code/web/app/app_achievements/include/AchMenu_class.php b/code/web/app/app_achievements/include/AchMenu_class.php new file mode 100644 index 000000000..be9fd49fc --- /dev/null +++ b/code/web/app/app_achievements/include/AchMenu_class.php @@ -0,0 +1,54 @@ +sqlQuery("SELECT * FROM ach_category LEFT JOIN (ach_category_lang) ON (acl_lang='".$lang."' AND acl_category=ac_id) WHERE ac_parent IS NULL"); + #MISSING: ORDER by + $sz = sizeof($res); + for($i=0;$i<$sz;$i++) { + $this->nodes[] = new AchMenuNode($res[$i],$open,$lang); + } + } + } + + class AchMenuNode extends RenderNodeIterator { + private $id = false; + private $parent = false; + private $name = null; + private $open = false; + + function AchMenuNode(&$data,$open,$lang) { + global $db; + + $this->id = $data['ac_id']; + $this->parent = $data['ac_parent']; + $this->name = $data['acl_name']; + + $this->open = ($open==$data['ac_id']); + + $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."'"); + #MISSING: ORDER by + $sz = sizeof($res); + for($i=0;$i<$sz;$i++) { + $this->nodes[] = new AchMenuNode($res[$i],$open,$lang); + } + } + + function getID() { + return $this->id; + } + + function getName() { + return $this->name; + } + + function getParent() { + return $this->parent; + } + + function isOpen() { + return $this->open; + } + } +?> \ No newline at end of file diff --git a/code/web/app/app_achievements/include/AchObjective_class.php b/code/web/app/app_achievements/include/AchObjective_class.php new file mode 100644 index 000000000..dd7d6616f --- /dev/null +++ b/code/web/app/app_achievements/include/AchObjective_class.php @@ -0,0 +1,43 @@ +id = $data['ao_id']; + $this->perk = $data['ao_perk']; + $this->condition = $data['ao_condition']; + $this->value = $data['ao_value']; + $this->name = $data['aol_name']; + $this->display = $data['ao_display']; + } + + function getID() { + return $this->id; + } + + function getPerk() { + return $this->perk; + } + + function getCondition() { + return $this->condition; + } + + function getValue() { + return $this->value; + } + + function getName() { + return $this->name; + } + + function getDisplay() { + return $this->display; + } + } +?> \ No newline at end of file diff --git a/code/web/app/app_achievements/include/AchPerk_class.php b/code/web/app/app_achievements/include/AchPerk_class.php new file mode 100644 index 000000000..196d3bae5 --- /dev/null +++ b/code/web/app/app_achievements/include/AchPerk_class.php @@ -0,0 +1,45 @@ +id = $data['ap_id']; + $this->parent = $data['ap_parent']; + $this->achievement = $data['ap_achievement']; + $this->value = $data['ap_value']; + $this->name = $data['apl_name']; + + $res = $db->sqlQuery("SELECT * FROM ach_objective LEFT JOIN (ach_objective_lang) ON (aol_lang='".$lang."' AND aol_objective=ao_id) WHERE ao_perk='".$this->id."'"); + $sz = sizeof($res); + for($i=0;$i<$sz;$i++) { + $this->nodes[] = new AchObjective($res[$i],$lang); + } + } + + function getID() { + return $this->id; + } + + function getParent() { + return $this->parent; + } + + function getAchievement() { + return $this->achievement; + } + + function getValue() { + return $this->value; + } + + function getName() { + return $this->name; + } + } +?> \ 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 new file mode 100644 index 000000000..160854106 --- /dev/null +++ b/code/web/app/app_achievements/include/AchSummary_class.php @@ -0,0 +1,20 @@ +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"); + #MISSING: or parent is done + #MISSING: player's status on achievement + $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; + } + } + } + } +?> \ 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 e05637ac2..ba40f27c0 100644 --- a/code/web/app/app_achievements/include/ach_render_web.php +++ b/code/web/app/app_achievements/include/ach_render_web.php @@ -90,4 +90,98 @@ function ach_render_tiebar($cult = "neutral", $civ = "neutral") { } + + function ach_render_menu(&$menu) { + $html = ""; + + $sz = $menu->getSize(); + for($i=0;$i<$sz;$i++) { + $curr = $menu->getChild($i); + $html .= "
".ach_render_menu($curr)."
"; + } + + return $html; + } + + function ach_render_category(&$cat) { + $html = ""; + + $tmp = $cat->getDone(); + $sz = sizeof($tmp); + for($i=0;$i<$sz;$i++) { + $html .= ach_render_achievement_done($cat->getChild($tmp[$i])); + } + + $tmp = $cat->getDone(); + $sz = sizeof($tmp); + for($i=0;$i<$sz;$i++) { + $html .= ach_render_achievement_open($cat->getChild($tmp[$i])); + } + + return $html; + } + + function ach_render_achievement_done(&$ach) { + + } + + function ach_render_achievement_open(&$ach) { + $html = ""; + + $html .= '
+ + + + + + + + + + + + + + + +
+
+ + + + + '; + $html .= ach_render_perk_open($ach->getOpen()); + $html .= '

'.$ach->getName().'

+ '.$ach->getValue().'
+
+
'; + + return $html; + } + + function ach_render_perk_open(&$perk_list) { + $html = ""; + + $perk = $perk_list[0]; + + $html .= $perk->getName()."
"; + $html .= ach_render_obj_list($perk->getChildren()); + + return $html; + } + + function ach_render_perk_done() { + + } + + function ach_render_obj_list(&$obj) { + $html = ""; + + foreach($obj as $elem) { + $html .= "-".$elem->getName()."
"; + } + + 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 04503ac0b..d4a9d92a8 100644 --- a/code/web/app/app_achievements/index.php +++ b/code/web/app/app_achievements/index.php @@ -2,25 +2,31 @@ define('APP_NAME', 'app_achievements'); -include_once('../config.php'); -include_once('../lang.php'); +require_once('../webig/config.php'); +include_once('../webig/lang.php'); include_once('lang.php'); +require_once('conf.php'); // Ask to authenticate user (using ingame or session method) and fill $user with all information ryzom_app_authenticate($user, true); if($user['ig']) { - include_once("include/ach_render_ig.php"); + require_once("include/ach_render_ig.php"); } else { - include_once("include/ach_render_web.php"); + require_once("include/ach_render_web.php"); } -include_once("include/ach_render_common.php"); +require_once("include/ach_render_common.php"); + +require_once("include/AchMenu_class.php"); +require_once("include/AchSummary_class.php"); +require_once("include/AchCategory_class.php"); +require_once("include/AchCommon_class.php"); // Update user acces on Db -/*$db = ryDB::getInstance(APP_NAME); -$db->setDbDefs('test', array('id' => SQL_DEF_INT, 'num_access' => SQL_DEF_INT)); +$db = ryDB::getInstance(APP_NAME); +/*$db->setDbDefs('test', array('id' => SQL_DEF_INT, 'num_access' => SQL_DEF_INT)); $num_access = $db->querySingleAssoc('test', array('id' => $user['id'])); if ($num_access) @@ -31,14 +37,31 @@ else // Content $c = _t('access', $num_access['num_access']).'
';*/ -$c = "
+$c = var_export($user,true); + +$c .= "
- +
awesome menu"; + + $menu = new AchMenu($_REQUEST['mid'],$user['lang']); + + $c .= ach_render_menu($menu); + +$c .= " "; -for($i=0;$i<15;$i++) { +/*for($i=0;$i<15;$i++) { $c .= ach_render_box_done("Bejeweled"); +}*/ + +if($menu->isSelected()) { + $cat = new AchCategory($menu->getCat(),$user['lang']); } +else { + $cat = new AchSummary(12,$user['lang']); +} + +$c .= ach_render_category($cat); $c .= "