diff --git a/code/web/app/app_achievements_admin/class/ADM_inter.php b/code/web/app/app_achievements_admin/class/ADM_inter.php
index e158827c7..b1fc15a3d 100644
--- a/code/web/app/app_achievements_admin/class/ADM_inter.php
+++ b/code/web/app/app_achievements_admin/class/ADM_inter.php
@@ -10,8 +10,6 @@
function insert();
- function setInDev($true_false);
-
function getID(); // needed to identify a node
}
?>
\ No newline at end of file
diff --git a/code/web/app/app_achievements_admin/class/AdmAchievement_class.php b/code/web/app/app_achievements_admin/class/AdmAchievement_class.php
index ea76b144e..61898ae5a 100644
--- a/code/web/app/app_achievements_admin/class/AdmAchievement_class.php
+++ b/code/web/app/app_achievements_admin/class/AdmAchievement_class.php
@@ -1,44 +1,20 @@
init();
parent::__construct($data,$parent);
}
- protected function makeChild(&$d) {
+ protected function makeChild($d) {
return new AdmPerk($d,$this);
}
-
- function insertNode(&$n) { // add a Perk
+
+ #@overrides AdmDispatcher::insertNode()
+ function insertNode($n) {
$n->insert();
- $this->nodes[] = $n;
- }
-
- function removeNode($id) { // remove a Perk
- $res = $this->getNode($id);
- if($res != null) {
- $res->delete_me();
- $this->unsetChild($id);
- }
- }
-
- function updateNode($id,$data) { // update a Perk
- $res = $this->getNode($id);
- if($res != null) {
- #MISSING: set new data
- #
- $res->update();
- }
- }
-
- function getNode($id) { // find a Perk
- foreach($this->nodes as $elem) {
- if($elem->getID == $id) {
- return $elem;
- }
- }
-
- return null;
+ $this->addOpen($n);
}
function delete_me() {
@@ -47,56 +23,36 @@
$DBc->sqlQuery("DELETE FROM ach_achievement WHERE aa_id='".$this->getID()."'");
$DBc->sqlQuery("DELETE FROM ach_player_achievement WHERE apa_id='".$this->getID()."'");
$DBc->sqlQuery("DELETE FROM ach_achievement_lang WHERE NOT EXISTS (SELECT * FROM ach_achievement WHERE aa_id=aal_achievement)");
-
- foreach($this->nodes as $elem) {
- $elem->delete_me();
- $this->unsetChild($elem->getID());
+
+ $iter = $this->getIterator();
+ while($iter->hasNext()) {
+ $curr = $iter->getNext();
+ $curr->delete_me();
+ $this->removeChild($curr->getID());
}
}
function update() {
global $DBc;
- $DBc->sqlQuery("UPDATE ach_achievement SET aa_parent='".$this->getParent())."',aa_tie_race='".mysql_real_escape_string($this->getTieRace())."',aa_tie_cult='".mysql_real_escape_string($this->getTieCult())."',aa_tie_civ='".mysql_real_escape_string($this->getTieCiv())."',aa_image='".mysql_real_escape_string($this->getImage())."',aa_dev='".$this->getDev()."' WHERE aa_id='".$this->geID()."'");
+ $DBc->sqlQuery("UPDATE ach_achievement SET aa_category='".$this->getCategory()."',aa_parent=NULL,aa_tie_race=".mkn($this->getTieRace()).",aa_tie_cult=".mkn($this->getTieCult()).",aa_tie_civ=".mkn($this->getTieCiv()).",aa_image='".mysql_real_escape_string($this->getImage())."',aa_dev='".$this->getDev()."' WHERE aa_id='".$this->getID()."'");
#MISSING: update lang entry
+ $DBc->sqlQuery("INSERT INTO ach_achievement_lang (aal_achievement,aal_lang,aal_name,aal_template) VALUES ('".$this->getID()."','en','".mysql_real_escape_string($this->getName())."',".mkn($this->getTemplate()).") ON DUPLICATE KEY UPDATE aal_name='".mysql_real_escape_string($this->getName())."',aal_template=".mkn($this->getTemplate())."");
}
function insert() {
+ global $DBc;
+ $this->dev = 1;
+
+ $DBc->sqlQuery("INSERT INTO ach_achievement (aa_category,aa_parent,aa_tie_race,aa_tie_cult,aa_tie_civ,aa_image,aa_dev) VALUES ('".$this->getCategory()."',NULL,".mkn($this->getTieRace()).",".mkn($this->getTieCult()).",".mkn($this->getTieCiv()).",'".mysql_real_escape_string($this->getImage())."','1')");
+ $id = mysql_insert_id();
+ $this->setID($id);
+
+ $DBc->sqlQuery("INSERT INTO ach_achievement_lang (aal_achievement,aal_lang,aal_name,aal_template) VALUES ('".$this->getID()."','en','".mysql_real_escape_string($this->getName())."',".mkn($this->getTemplate()).")");
}
- function unsetChild($id) { // remove child with given ID from nodes list; unset should destruct it.
- foreach($this->nodes as $key=>$elem) {
- if($elem->getID() == $id) {
- unset($this->nodes[$key]);
- return null;
- }
- }
- }
-
- function setInDev($tf) {
- if($tf == true) {
- $this->setDev(1);
- }
- else {
- $this->setDev(0);
- }
-
- $this->update();
- }
-
- function setDev($d) {
- $this->dev = $d;
- }
-
- function setID($id) {
- $this->id = $id;
- }
-
- function setParent($p) {
- $this->parent = $p
- }
function setCategory($c) {
$this->category = $c;
@@ -122,7 +78,7 @@
$this->name = $n;
}
- function setTemplate($i) {
+ function setTemplate($t) {
$this->template = $t;
}
}
diff --git a/code/web/app/app_achievements_admin/class/AdmAtom_class.php b/code/web/app/app_achievements_admin/class/AdmAtom_class.php
index 17bde5bc9..86ddf3ec2 100644
--- a/code/web/app/app_achievements_admin/class/AdmAtom_class.php
+++ b/code/web/app/app_achievements_admin/class/AdmAtom_class.php
@@ -1,12 +1,12 @@
parent = $parent;
@@ -25,11 +25,11 @@
}
function update() {
- $DBc->sqlQuery("UPDATE ach_atom SET atom_mandatory='".."',atom_ruleset='".."',atom_ruleset_parsed='".."' WHERE atom_id='".$this->id."'");
+ #$DBc->sqlQuery("UPDATE ach_atom SET atom_mandatory='".."',atom_ruleset='".."',atom_ruleset_parsed='".."' WHERE atom_id='".$this->id."'");
}
function insert() {
- $DBc->sqlQuery("INSERT INTO ach_atom (atom_objective,atom_mandatory,atom_ruleset,atom_ruleset_parsed) VALUES ('".."','".."','".."','".."')");
+ #$DBc->sqlQuery("INSERT INTO ach_atom (atom_objective,atom_mandatory,atom_ruleset,atom_ruleset_parsed) VALUES ('".."','".."','".."','".."')");
$id = mysql_insert_id();
$this->setID($id);
}
@@ -63,5 +63,9 @@
private function parse() {
}
+
+ function setInDev($tf) {
+
+ }
}
?>
\ No newline at end of file
diff --git a/code/web/app/app_achievements_admin/class/AdmCategory_class.php b/code/web/app/app_achievements_admin/class/AdmCategory_class.php
index 1ae64f0e1..f69c7d86f 100644
--- a/code/web/app/app_achievements_admin/class/AdmCategory_class.php
+++ b/code/web/app/app_achievements_admin/class/AdmCategory_class.php
@@ -1,54 +1,20 @@
init();
parent::__construct($id,$cult,$civ);
}
- protected function makeChild(&$d) {
+ protected function makeChild($d) {
return new AdmAchievement($d,$this);
}
-
- function insertNode(&$n) {
+
+ #@overrides AdmDispatcher::insertNode()
+ function insertNode($n) {
$n->insert();
- $this->nodes[] = $n;
+ $this->addOpen($n);
}
-
- function removeNode($id) {
- $res = $this->getNode($id);
- if($res != null) {
- $res->delete_me();
- $this->unsetChild($id);
- }
- }
-
- function updateNode($id,$data) {
- $res = $this->getNode($id);
- if($res != null) {
- #MISSING: set new data
- #aa_id aa_category aa_parent aa_tie_race aa_tie_cult aa_tie_civ aa_image aa_dev
- $res->update();
- }
- }
-
- function getNode($id) { // try to find the Achievement node that has the given ID. Return null on failure.
- foreach($this->nodes as $elem) {
- if($elem->getID == $id) {
- return $elem;
- }
- }
-
- return null;
- }
-
- function unsetChild($id) { // remove child with given ID from nodes list; unset should destruct it.
- foreach($this->nodes as $key=>$elem) {
- if($elem->getID() == $id) {
- unset($this->nodes[$key]);
- return null;
- }
- }
- }
-
}
?>
\ No newline at end of file
diff --git a/code/web/app/app_achievements_admin/class/AdmDispatcher_trait.php b/code/web/app/app_achievements_admin/class/AdmDispatcher_trait.php
new file mode 100644
index 000000000..12f9bdc4d
--- /dev/null
+++ b/code/web/app/app_achievements_admin/class/AdmDispatcher_trait.php
@@ -0,0 +1,70 @@
+setParent($this);
+ $n->insert();
+ $this->addChild($n);
+ }
+
+ function removeNode($id) {
+ $res = $this->getChildByID($id);
+ if($res != null) {
+ $res->delete_me();
+ $this->removeChild($id);
+ }
+ }
+
+ function updateNode($id) { // PROBABLY USELESS!
+ $res = $this->getChildByID($id);
+ if($res != null) {
+ $res->update();
+ }
+ }
+
+ function getPathID($path = "") {
+ if($path != "") {
+ $path = ";".$path;
+ }
+ $path = $this->getID().$path;
+ if($this->parent != null) {
+ return $this->parent->getPathID($path);
+ }
+
+ return $path;
+ }
+
+ function getElementByPath($pid) {
+ $tmp = explode(";",$pid);
+ if($tmp[0] == $this->getID()) {
+ if(sizeof($tmp) > 1) {
+ $c = $this->getChildByID($tmp[1]);
+ if($c != null) {
+ unset($tmp[0]);
+ return $c->getElementByPath(implode(";",$tmp));
+ }
+ return null;
+ }
+ else {
+ return $this;
+ }
+ }
+ return null;
+ }
+ }
+?>
\ No newline at end of file
diff --git a/code/web/app/app_achievements_admin/class/AdmMenuNode_class.php b/code/web/app/app_achievements_admin/class/AdmMenuNode_class.php
index 79f60c9df..dad7c8a38 100644
--- a/code/web/app/app_achievements_admin/class/AdmMenuNode_class.php
+++ b/code/web/app/app_achievements_admin/class/AdmMenuNode_class.php
@@ -3,6 +3,7 @@
private $ach_count;
function AdmMenuNode($data,$parent) {
+ $this->init();
parent::__construct($data,$parent);
global $DBc;
@@ -32,18 +33,21 @@
}
function getNode($id) { // try to find the child node that has the given ID. Return null on failure.
- if($id == $this->getID()) { // found!
- return $this;
+ $res = $this->getChildByID($id);
+ if($res != null) {
+ return $res;
}
- else {
- foreach($this->nodes as $elem) { // check children
- $tmp = $elem->getNode($id);
- if($tmp != null) {
- return $tmp;
- }
+
+ $iter = $this->getIterator();
+ while($iter->hasNext()) { // check children
+ $curr = $iter->getNext();
+ $tmp = $curr->getNode($id);
+ if($tmp != null) {
+ return $tmp;
}
- return null;
}
+
+ return null;
}
function delete_me() { // remove this node
@@ -57,18 +61,18 @@
// call delete function for all children
foreach($this->nodes as $elem) {
$elem->delete_me();
- $this->unsetChild($elem->getID());
+ $this->removeChild($elem->getID());
}
}
- function unsetChild($id) { // remove child with given ID from nodes list; unset should destruct.
+ /*function unsetChild($id) { // remove child with given ID from nodes list; unset should destruct.
foreach($this->nodes as $key=>$elem) {
if($elem->getID() == $id) {
unset($this->nodes[$key]);
return null;
}
}
- }
+ }*/
function insertChild(&$n) { // insert a new child
// insert command to create database entry
@@ -76,7 +80,7 @@
// set the new child's parent and add it to the node list
$n->setParent($this);
- $this->nodes[] = $n;
+ $this->addChild($n);
}
function update() {
@@ -151,9 +155,6 @@
}
}
- function setParent(&$p) {
- $this->parent = $p;
- }
function setParentID($p) {
if($p == null || strtolower($p) == "null") {
@@ -164,9 +165,6 @@
}
}
- function setID($id) {
- $this->id = $id;
- }
function getNextOrder() {
if($this->isEmpty()) {
diff --git a/code/web/app/app_achievements_admin/class/AdmMenu_class.php b/code/web/app/app_achievements_admin/class/AdmMenu_class.php
index e259f5ba4..d6debda0b 100644
--- a/code/web/app/app_achievements_admin/class/AdmMenu_class.php
+++ b/code/web/app/app_achievements_admin/class/AdmMenu_class.php
@@ -1,11 +1,14 @@
init();
parent::__construct($open);
- unset($this->nodes[0]); // unset the auto-generated "summary" node
+ #$this->drawTree();
+
+ #$this->removeChild(0); // unset the auto-generated "summary" node
}
protected function makeChild($d) { // override child generator to use admin classes
@@ -16,7 +19,7 @@
$res = $this->getNode($id);
if($res != null) {
$res->delete_me();
- $this->unsetChild($id);
+ $this->removeChild($id);
}
}
@@ -31,7 +34,7 @@
else {
$n->setParent($this);
$n->insert();
- $this->nodes[] = $n;
+ $this->addChild($n);
}
}
@@ -61,8 +64,17 @@
}
function getNode($id) { // try to find the MenuNode that has the given ID. Return null on failure.
- foreach($this->nodes as $elem) {
- $tmp = $elem->getNode($id);
+ #echo "
getNode(".$id.")";
+ $res = $this->getChildByID($id);
+ if($res != null) {
+ return $res;
+ }
+
+ $iter = $this->getIterator();
+ while($iter->hasNext()) {
+ $curr = $iter->getNext();
+ #echo $curr->getID();
+ $tmp = $curr->getNode($id);
if($tmp != null) {
return $tmp;
}
@@ -77,20 +89,22 @@
}
$val = array();
- foreach($this->nodes as $elem) {
- $val[] = $elem->getOrder();
+ $iter = $this->getIterator();
+ while($iter->hasNext()) {
+ $curr = $iter->getNext();
+ $val[] = $curr->getOrder();
}
return (max($val)+1);
}
- function unsetChild($id) { // remove child with given ID from nodes list; unset should destruct it.
+ /*function unsetChild($id) { // remove child with given ID from nodes list; unset should destruct it.
foreach($this->nodes as $key=>$elem) {
if($elem->getID() == $id) {
unset($this->nodes[$key]);
return null;
}
}
- }
+ }*/
}
?>
\ No newline at end of file
diff --git a/code/web/app/app_achievements_admin/class/AdmObjective_class.php b/code/web/app/app_achievements_admin/class/AdmObjective_class.php
index c1a4ebc2d..4a40b9685 100644
--- a/code/web/app/app_achievements_admin/class/AdmObjective_class.php
+++ b/code/web/app/app_achievements_admin/class/AdmObjective_class.php
@@ -1,7 +1,9 @@
init();
parent::__construct($data,$parent);
global $DBc;
@@ -13,63 +15,44 @@
}
}
- private function makeChild($d) {
+ protected function makeChild($d) {
return new AdmAtom($d,$this);
}
- function insertNode(&$n) { // insert an Atom
- $n->insert();
- $this->nodes[] = $n;
- }
-
- function removeNode($id) { // remove an Atom
- $res = $this->getNode($id);
- if($res != null) {
- $res->delete_me();
- $this->unsetChild($id);
- }
- }
-
- function updateNode($id,$data) { // update an Atom
- $res = $this->getNode($id);
- if($res != null) {
- #MISSING: set new data
- #
- $res->update();
- }
- }
-
- function getNode($id) { // find an atom
- foreach($this->nodes as $elem) {
- if($elem->getID == $id) {
- return $elem;
- }
- }
-
- return null;
- }
-
function delete_me() {
global $DBc;
$DBc->sqlQuery("DELETE FROM ach_objective WHERE ao_id='".$this->getID()."'");
$DBc->sqlQuery("DELETE FROM ach_player_objective WHERE apo_objective='".$this->getID()."'");
- foreach($this->nodes as $elem) {
- $elem->delete_me();
+ $iter = $this->getIterator();
+ while($iter->hasNext()) {
+ $curr = $iter->getNext();
+ $curr->delete_me();
+ $this->removeChild($curr->getID());
}
}
function update() {
+ global $DBc;
+ $DBc->sqlQuery("UPDATE ach_objective SET ao_condition='".mysql_real_escape_string($this->getCondition())."',ao_value=".mre($this->getValue()).",ao_display='".mysql_real_escape_string($this->getDisplay())."',ao_metalink=".mkn($this->getMetalink())." WHERE ao_id='".$this->getID()."'");
+
+ $DBc->sqlQuery("INSERT INTO ach_objective_lang (aol_objective,aol_lang,aol_name) VALUES ('".$this->getID()."','en','".mysql_real_escape_string($this->getName())."') ON DUPLICATE KEY UPDATE aol_name='".mysql_real_escape_string($this->getName())."'");
}
function insert() {
+ global $DBc;
+ $DBc->sqlQuery("INSERT INTO ach_objective (ao_perk,ao_condition,ao_value,ao_display,ao_metalink) VALUES ('".$this->getPerk()."','".mysql_real_escape_string($this->getCondition())."',".mre($this->getValue()).",'".mysql_real_escape_string($this->getDisplay())."',".mkn($this->getMetalink()).")");
+ $id = mysql_insert_id();
+ $this->setID($id);
+
+ $DBc->sqlQuery("INSERT INTO ach_objective_lang (aol_objective,aol_lang,aopl_name) VALUES ('".$this->getID()."','en','".mysql_real_escape_string($this->getName())."')");
}
- function setInDev($tf) {
-
+ function setCondition($c) {
+ $this->condition = $c;
}
}
?>
\ No newline at end of file
diff --git a/code/web/app/app_achievements_admin/class/AdmPerk_class.php b/code/web/app/app_achievements_admin/class/AdmPerk_class.php
index f0af45979..3a66585e0 100644
--- a/code/web/app/app_achievements_admin/class/AdmPerk_class.php
+++ b/code/web/app/app_achievements_admin/class/AdmPerk_class.php
@@ -1,77 +1,86 @@
init();
parent::__construct($data,$parent);
+
+ $this->condition = $data["ap_condition"];
+ $this->condition_value = $data["ap_condition_value"];
}
protected function makeChild($d) {
return new AdmObjective($d,$this);
}
- function insertNode(&$n) { // insert an Objective
- $n->insert();
- $this->nodes[] = $n;
- }
-
- function removeNode($id) { // remove an Objective
- $res = $this->getNode($id);
- if($res != null) {
- $res->delete_me();
- $this->unsetChild($id);
- }
- }
-
- function updateNode($id,$data) { // update an Objective
- $res = $this->getNode($id);
- if($res != null) {
- #MISSING: set new data
- #
- $res->update();
- }
- }
-
- function getNode($id) { // find an Objective
- foreach($this->nodes as $elem) {
- if($elem->getID == $id) {
- return $tmp;
- }
- }
-
- return null;
- }
-
function delete_me() {
global $DBc;
$DBc->sqlQuery("DELETE FROM ach_perk WHERE ap_id='".$this->getID()."'");
$DBc->sqlQuery("DELETE FROM ach_player_perk WHERE app_perk='".$this->getID()."'");
- foreach($this->nodes as $elem) {
- $elem->delete_me();
- $this->unsetChild($elem->getID());
+ $iter = $this->getIterator();
+ while($iter->hasNext()) {
+ $curr = $iter->getNext();
+ $curr->delete_me();
+ $this->removeChild($curr->getID());
}
}
function update() {
+ global $DBc;
+ $DBc->sqlQuery("UPDATE ach_perk SET ap_parent=NULL,ap_value='".mysql_real_escape_string($this->getValue())."',ap_condition='".mysql_real_escape_string($this->getCondition())."',ap_condition_value=".mkn($this->getConditionValue()).",ap_dev='".$this->getDev()."' WHERE ap_id='".$this->getID()."'");
+
+ $DBc->sqlQuery("INSERT INTO ach_perk_lang (apl_perk,apl_lang,apl_name,apl_template) VALUES ('".$this->getID()."','en','".mysql_real_escape_string($this->getName())."',".mkn($this->getTemplate()).") ON DUPLICATE KEY UPDATE apl_name='".mysql_real_escape_string($this->getName())."',apl_template=".mkn($this->getTemplate())."");
}
function insert() {
+ global $DBc;
+ $this->dev = 1;
+
+ $DBc->sqlQuery("INSERT INTO ach_perk (ap_achievement,ap_parent,ap_value,ap_condition,ap_condition_value,ap_dev) VALUES ('".$this->getAchievement()."',NULL,'".mysql_real_escape_string($this->getValue())."','".mysql_real_escape_string($this->getCondition())."',".mkn($this->getConditionValue()).",'1')");
+ $id = mysql_insert_id();
+ $this->setID($id);
+
+ $DBc->sqlQuery("INSERT INTO ach_perk_lang (apl_perk,apl_lang,apl_name,apl_template) VALUES ('".$this->getID()."','en','".mysql_real_escape_string($this->getName())."',".mkn($this->getTemplate()).")");
}
- function unsetChild($id) { // remove child with given ID from nodes list; unset should destruct it.
- foreach($this->nodes as $key=>$elem) {
- if($elem->getID() == $id) {
- unset($this->nodes[$key]);
- return null;
- }
- }
+ function setAchievement($a) {
+ $this->achievement = $a;
}
- function setInDev($tf) {
+ function setName($name) {
+ $this->name = $name;
+ }
+ function setTemplate($t) {
+ $this->template = $t;
+ }
+
+ function setValue($v) {
+ $this->value = $v;
+ }
+
+ function getCondition() {
+ return $this->condition;
+ }
+
+ function getConditionValue() {
+ return $this->condition_value;
+ }
+
+ function setCondition($c) {
+ $this->condition = $c;
+ }
+
+ function setConditionValue($v) {
+ $this->condition_value = $v;
}
}
?>
\ No newline at end of file
diff --git a/code/web/app/app_achievements_admin/class/CSRAchievement_class.php b/code/web/app/app_achievements_admin/class/CSRAchievement_class.php
index f5cec8840..e3f49b40c 100644
--- a/code/web/app/app_achievements_admin/class/CSRAchievement_class.php
+++ b/code/web/app/app_achievements_admin/class/CSRAchievement_class.php
@@ -1,19 +1,60 @@
init();
+ parent::__construct($data,$parent);
+ }
+
+ protected function makeChild($d) {
+ return new CSRPerk($d,$this);
}
function grant($pid) {
- foreach($this->nodes as $elem) {
- $elem->grant($pid);
+ $iter = $this->getIterator();
+ while($iter->hasNext()) {
+ $curr = $iter->getNext();
+ $curr->grant($pid);
+ $this->setChildDone($curr->getIdx());
}
+
+ $this->parent->setChildDone($this->idx);
}
function deny($pid) {
- foreach($this->nodes as $elem) {
- $elem->deny($pid);
+ $iter = $this->getIterator();
+ while($iter->hasNext()) {
+ $curr = $iter->getNext();
+ $curr->deny($pid);
+ $this->setChildOpen($curr->getIdx());
+ }
+
+ $this->parent->setChildOpen($this->idx);
+ }
+
+ function setPerkDone($idx) {
+ echo "perk
";
+ $this->setChildDone($idx);
+
+ echo "ach
";
+
+ $this->parent->addChildDone($this->idx);
+
+ if(!$this->hasOpen()) {
+ $this->parent->removeChildOpen($this->idx);
+ }
+ }
+
+ function setPerkOpen($idx) {
+ echo "perk
";
+ $this->setChildOpen($idx);
+ echo "ach
";
+
+ $this->parent->addChildOpen($this->idx);
+
+ if(!$this->hasDone()) {
+ $this->parent->removeChildDone($this->idx);
}
}
}
diff --git a/code/web/app/app_achievements_admin/class/CSRAtom_class.php b/code/web/app/app_achievements_admin/class/CSRAtom_class.php
index 38f04299a..51a651c4b 100644
--- a/code/web/app/app_achievements_admin/class/CSRAtom_class.php
+++ b/code/web/app/app_achievements_admin/class/CSRAtom_class.php
@@ -1,9 +1,10 @@
id = $data['atom_id'];
+ $this->parent = $parent;
}
function grant($pid) {
diff --git a/code/web/app/app_achievements_admin/class/CSRCategory_class.php b/code/web/app/app_achievements_admin/class/CSRCategory_class.php
new file mode 100644
index 000000000..26a774803
--- /dev/null
+++ b/code/web/app/app_achievements_admin/class/CSRCategory_class.php
@@ -0,0 +1,50 @@
+init();
+ parent::__construct($id,$cult,$civ);
+ }
+
+ protected function makeChild($d) {
+ return new CSRAchievement($d,$this);
+ }
+
+ function grant($id) {
+ return false; // category can't grant!
+ }
+
+ function deny($id) {
+ return false; // category can't grant!
+ }
+
+ /*function setAchOpen($idx,$state) {
+ if($state == false) {
+ $this->unsetOpen($idx);
+ if(!in_array($idx,$this->child_done)) {
+ $this->child_done[] = $idx;
+ }
+ }
+ else {
+ if(!in_array($idx,$this->child_open)) {
+ $this->child_open[] = $idx;
+ }
+ }
+ }
+
+ function setAchDone($idx,$state) {
+ if($state == false) {
+ $this->unsetDone($idx);
+ if(!in_array($idx,$this->child_open)) {
+ $this->child_open[] = $idx;
+ }
+ }
+ else {
+ if(!in_array($idx,$this->child_done)) {
+ $this->child_done[] = $idx;
+ }
+ }
+ }*/
+ }
+?>
diff --git a/code/web/app/app_achievements_admin/class/CSRDispatcher_trait.php b/code/web/app/app_achievements_admin/class/CSRDispatcher_trait.php
new file mode 100644
index 000000000..b7618ae3e
--- /dev/null
+++ b/code/web/app/app_achievements_admin/class/CSRDispatcher_trait.php
@@ -0,0 +1,67 @@
+getID()."
";
+ if(is_numeric($path)) {
+ //it's me (id == numeric)
+ if($this->getID() == $path) {
+ $this->grant($player);
+ #echo "grant()
";
+ }
+ }
+ else {
+ //get child with the next level id and dispatch
+ $tmp = explode(";",$path);
+
+ $c = $this->getChildByID($tmp[1]);
+ #echo "...".$tmp[1];
+ if($c != null) { // check if it's really own child
+ unset($tmp[0]);
+ $c->grantNode(implode(";",$tmp),$player);
+ #echo "grantNode()
";
+ }
+ }
+ #echo "end
";
+ }
+
+ function denyNode($path,$player) {
+ if(is_numeric($path)) {
+ //it's me (id == numeric)
+ if($this->getID() == $path) {
+ $this->deny($player);
+ }
+ }
+ else {
+ //get child with the next level id and dispatch
+ $tmp = explode(";",$path);
+
+ if($tmp[0] == $this->getID()) { // it's my id!
+
+ $c = $this->getChildByID($tmp[1]);
+ if($c != null) { // check if it's really own child
+ unset($tmp[0]);
+ $c->denyNode(implode(";",$tmp),$player);
+ }
+ }
+ }
+ }
+
+ function getPath($path = "") {
+ if($path != "") {
+ $path = ";".$path;
+ }
+
+ $path = $this->getID().$path;
+
+ if($this->hasParent()) {
+ $path = $this->parent->getPath($path);
+ }
+
+ return $path;
+ }
+
+ private function hasParent() {
+ return ($this->parent != null);
+ }
+ }
+?>
\ No newline at end of file
diff --git a/code/web/app/app_achievements_admin/class/CSRObjective_class.php b/code/web/app/app_achievements_admin/class/CSRObjective_class.php
index 7fba5a3b0..0a9421d34 100644
--- a/code/web/app/app_achievements_admin/class/CSRObjective_class.php
+++ b/code/web/app/app_achievements_admin/class/CSRObjective_class.php
@@ -1,27 +1,37 @@
init();
+ parent::__construct($data,$parent);
global $DBc;
$res = $DBc->sqlQuery("SELECT atom_id FROM ach_atom WHERE atom_objective='".$this->getID()."'");
$sz = sizeof($res);
for($i=0;$i<$sz;$i++) {
- $this->nodes[] = new CSRAtom($res[$i]);
+ $this->addChild($this->makeChild($res[$i]));
}
}
+ protected function makeChild($d) {
+ return new CSRAtom($d,$this);
+ }
+
function grant($pid) {
global $DBc;
$DBc->sqlQuery("INSERT INTO ach_player_objective (apo_objective,apo_player,apo_date) VALUES ('".$this->getID()."','".$pid."','".time()."')");
+ $this->done = 1;
+ $this->progress = $this->value;
- foreach($this->nodes as $elem) {
- $elem->grant($pid);
+ $iter = $this->getIterator();
+ while($iter->hasNext()) {
+ $curr = $iter->getNext();
+ $curr->grant($pid);
}
}
@@ -29,9 +39,13 @@
global $DBc;
$DBc->sqlQuery("DELETE FROM ach_player_objective WHERE apo_objective='".$this->getID()."' AND apo_player='".$pid."'");
+ $this->done = 0;
+ $this->progress = 0;
- foreach($this->nodes as $elem) {
- $elem->deny($pid);
+ $iter = $this->getIterator();
+ while($iter->hasNext()) {
+ $curr = $iter->getNext();
+ $curr->deny($pid);
}
}
}
diff --git a/code/web/app/app_achievements_admin/class/CSRPerk_class.php b/code/web/app/app_achievements_admin/class/CSRPerk_class.php
index 69eceacf5..3b68bd5ce 100644
--- a/code/web/app/app_achievements_admin/class/CSRPerk_class.php
+++ b/code/web/app/app_achievements_admin/class/CSRPerk_class.php
@@ -1,17 +1,28 @@
init();
+ parent::__construct($data,$parent);
+ }
+
+ protected function makeChild($d) {
+ return new CSRObjective($d,$this);
}
function grant($pid) {
global $DBc;
$DBc->sqlQuery("INSERT INTO ach_player_perk (app_perk,app_player,app_date) VALUES ('".$this->getID()."','".$pid."','".time()."')");
+ $this->done = time();
+ #echo $this->idx."
";
+ $this->parent->setPerkDone($this->idx);
- foreach($this->nodes as $elem) {
- $elem->grant();
+ $iter = $this->getIterator();
+ while($iter->hasNext()) {
+ $curr = $iter->getNext();
+ $curr->grant($pid);
}
}
@@ -19,9 +30,13 @@
global $DBc;
$DBc->sqlQuery("DELETE FROM ach_player_perk WHERE app_perk='".$this->getID()."' AND app_player='".$pid."'");
+ $this->done = 0;
+ $this->parent->setPerkOpen($this->idx);
- foreach($this->nodes as $elem) {
- $elem->deny($pid);
+ $iter = $this->getIterator();
+ while($iter->hasNext()) {
+ $curr = $iter->getNext();
+ $curr->deny($pid);
}
}
}
diff --git a/code/web/app/app_achievements_admin/class/CSR_inter.php b/code/web/app/app_achievements_admin/class/CSR_inter.php
index e62b98ef7..67b64149e 100644
--- a/code/web/app/app_achievements_admin/class/CSR_inter.php
+++ b/code/web/app/app_achievements_admin/class/CSR_inter.php
@@ -1,7 +1,9 @@
\ No newline at end of file
diff --git a/code/web/app/app_achievements_admin/class/mySQL_class.php b/code/web/app/app_achievements_admin/class/mySQL_class.php
new file mode 100644
index 000000000..dba981254
--- /dev/null
+++ b/code/web/app/app_achievements_admin/class/mySQL_class.php
@@ -0,0 +1,160 @@
+$elem) {
+ $in[$key] = mysql_real_escape_string(stripslashes($elem));
+ }
+ }
+ else {
+ $in = mysql_real_escape_string(stripslashes($in));
+ }
+ return $in;
+ }
+
+ function mySQL($err=false) {
+ $this->DBstats = array();
+ $this->DBc = false;
+ if($err === "DIE" || $err === "PRINT" || $err === "ALERT" || $err === "HIDE" || $err === "LOG") {
+ $this->DBerror = $err;
+ }
+ else {
+ $this->DBerror = "HIDE";
+ }
+ $this->resetStats();
+ $this->cached = false;
+ }
+
+ function connect($ip,$user,$pass,$db=false) {
+ $this->DBc = mysql_pconnect($ip,$user,$pass) or $this->error(mysql_error());
+ if($this->DBc && $db) {
+ $this->database($db);
+ }
+ $this->resetStats();
+ }
+
+ function database($db) {
+ if(!$this->DBc) {
+ return false;
+ }
+ mysql_select_db($db,$this->DBc) or $this->error(mysql_error());
+ }
+
+ function resetStats() {
+ $this->DBstats['query'] = 0;
+ $this->DBstats['error'] = 0;
+ }
+
+ function getStats() {
+ return $this->DBstats;
+ }
+
+ function sendSQL($query,$handling="PLAIN",$buffer=false) { // can be INSERT, DELETE, UPDATE, ARRAY, NONE, PLAIN
+ #if($this->cached !== false) {
+ #$this->unlinkSql($this->cached);
+ #}
+ if(!$this->DBc) {
+ return false;
+ }
+
+ if($buffer === false && $handling !== "PLAIN") {
+ $res = mysql_unbuffered_query($query,$this->DBc) or $this->error(mysql_error(),$query);
+ }
+ else {
+ $res = mysql_query($query,$this->DBc) or $this->error(mysql_error(),$query);
+ }
+
+ #$this->cached = $res;
+
+ $this->DBstats['query']++;
+
+ if($res) {
+ if($handling === "INSERT") {
+ $tmp = mysql_insert_id($this->DBc) or $this->error(mysql_error());;
+ $this->unlinkSql($res);
+ return $tmp;
+ }
+ elseif($handling === "DELETE" || $handling === "UPDATE") {
+ $tmp = mysql_affected_rows($this->DBc) or $this->error(mysql_error());
+ $this->unlinkSql($res);
+ return $tmp;
+ }
+ elseif($handling === "ARRAY") {
+ $tmp = $this->parseSql($res);
+ $this->unlinkSql($res);
+ return $tmp;
+ }
+ elseif($handling === "NONE") {
+ $this->unlinkSql($res);
+ return true;
+ }
+ else {
+ return $res;
+ }
+ mysql_free_result($res);
+ }
+ else {
+ return false;
+ }
+ }
+
+ function unlinkSql($res) {
+ @mysql_free_result($res);
+ }
+
+ private function parseSql($res) {
+ $data = array();
+ $k = 0;
+ while($tmp = mysql_fetch_array($res,MYSQL_ASSOC)) {
+ $data[$k] = $tmp;
+ $k++;
+ }
+
+ return $data;
+ }
+
+ function getNext($res) {
+ if($res) {
+ if($tmp = mysql_fetch_array($res,MYSQL_ASSOC)) {
+ return $tmp;
+ }
+ else {
+ return false;
+ }
+ }
+ else {
+ return false;
+ }
+ }
+
+ private function error($error,$query = false) {
+ $this->DBstats['error']++;
+
+ if($query != false) {
+ $error .= " -->|".$query."|<--";
+ }
+
+ switch($this->DBerror) {
+ case 'DIE':
+ die($error);
+ break;
+ case 'PRINT':
+ echo "
".$error."
";
+ break;
+ case 'ALERT':
+ echo "";
+ break;
+ case 'LOG':
+ logf("MySQL ERROR: ".$error);
+ break;
+ default:
+ flush();
+ break;
+ }
+ }
+ }
+?>
\ No newline at end of file
diff --git a/code/web/app/app_achievements_admin/conf.php b/code/web/app/app_achievements_admin/conf.php
index 2032c079f..e33c99e1f 100644
--- a/code/web/app/app_achievements_admin/conf.php
+++ b/code/web/app/app_achievements_admin/conf.php
@@ -11,4 +11,9 @@
$_CONF['enable_offgame'] = true;
$_CONF['enable_CSR'] = true;
$_CONF['enable_ADM'] = true;
+
+ $_CONF['char_mysql_server'] = "localhost";
+ $_CONF['char_mysql_user'] = "root";
+ $_CONF['char_mysql_pass'] = "";
+ $_CONF['char_mysql_database'] = "app_achievements";
?>
\ No newline at end of file
diff --git a/code/web/app/app_achievements_admin/include/adm_render_ach.php b/code/web/app/app_achievements_admin/include/adm_render_ach.php
new file mode 100644
index 000000000..50fc3b1b0
--- /dev/null
+++ b/code/web/app/app_achievements_admin/include/adm_render_ach.php
@@ -0,0 +1,800 @@
+
+ .ach_menu {
+ display:block;
+ padding:2px;
+ border:1px solid #000000;
+ margin-bottom:2px;
+ color:#FFFFFF;
+ }
+ .ach_menu:hover {
+ color:orange;
+ }
+
+ .ach_mspan a {
+ text-decoration:none;
+ }
+ ";
+
+ return $html.adm_render_mnode($menu,$sub);
+ }
+
+ function adm_render_mnode(&$menu,$sub) {
+ global $_CONF;
+
+ $iter = $menu->getIterator();
+ while($iter->hasNext()) {
+ $curr = $iter->getNext();
+ #$sz = $menu->getSize();
+ #for($i=0;$i<$sz;$i++) {
+ # $curr = $menu->getChild($i);
+ if($curr->inDev()) {
+ #continue;
+ }
+ $html .= "";
+ if($curr->hasOpenCat() != 0) {
+ $html .= "
".adm_render_mnode($curr,($sub+4))."
";
+ }
+ }
+
+ return $html;
+ }
+
+ function adm_render_category(&$cat) {
+ $html = "";
+
+ if($_REQUEST['confirm'] == "delete") {
+ $tmp = $cat->getElementByPath($_REQUEST['id']);
+ if($tmp != null) {
+ $html .= "
+
+
";
+ }
+ }
+
+ $html .= "";
+
+ if($cat->isTiedCultDev() || $cat->isTiedCivDev()) {
+ $html .= ach_render_tiebar($cat->getCurrentCult(),$cat->getCurrentCiv(),$cat);
+ }
+
+ /*$iter = $cat->getDone();
+ while($iter->hasNext()) {
+ $curr = $cat->getChildByIdx($iter->getNext());
+ #$sz = sizeof($tmp);
+ #for($i=0;$i<$sz;$i++) {
+ #echo "A";
+ if($curr->inDev()) {
+ continue;
+ }
+ $html .= ach_render_achievement_done($curr);
+ }*/
+
+ $iter = $cat->getOpen();
+ while($iter->hasNext()) {
+ $curr = $cat->getChildByIdx($iter->getNext());
+ #$sz = sizeof($tmp);
+ #for($i=0;$i<$sz;$i++) {
+ #echo "B";
+ if($curr->inDev()) {
+ #continue;
+ }
+ $html .= ach_render_achievement_open($curr);
+ }
+
+ return $html;
+ }
+
+ function ach_render_achievement_done(&$ach) {
+ global $_CONF;
+
+ $html = '
+
+ |
+ |
+ |
+
+
+ |
+
+
+
+ |
+ '.$ach->getName().' |
+
+ '.$ach->getValueDone().'
+ |
+ ';
+ $html .= ach_render_perk_done($ach);
+ $html .= ' |
+ |
+ |
+
+
+ |
+ |
+ |
+
+
';
+
+ return $html;
+ }
+
+ function ach_render_achievement_open(&$ach) {
+ global $_CONF,$menu;
+
+ $html = '
+
+ |
+ |
+ |
+
+
+ |
+
+
+
+ |
+ ";
+
+ $html .= ' |
+ |
+ ';
+
+ $html .= "";
+
+ $html .= "";
+
+ $html .= "";
+
+ $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();
+ while($perk_list->hasNext()) {
+
+ $perk = $ach->getChildByIdx($perk_list->getNext());
+
+ #$perk = $ach->getChild($perk_list[0]);
+
+ if($perk->inDev()) {
+ #return $html;
+ }
+
+ #if($perk->getName() != null) {
+ $html .= "";
+
+ $html .= "";
+
+ $html .= "";
+ #}
+ #if($perk->objDrawable()) {
+ $html .= ach_render_obj_list($perk->getIterator());
+ #}
+ }
+
+ return $html;
+ }
+
+ function ach_render_perk_done(&$ach) {
+ global $_CONF;
+ $html = "";
+
+ $perk_list = $ach->getDone();
+ while($perk_list->hasNext()) {
+ $perk = $ach->getChildByIdx($perk_list->getNext());
+ #foreach($perk_list as $elem) {
+ #$perk = $ach->getChild($elem);
+ if($perk->inDev()) {
+ continue;
+ }
+ $html .= "".$perk->getName()." ( ".date('d.m.Y',$perk->getDone())." )
".$perk->getValue()."
";
+ }
+
+ return $html;
+ }
+
+ function ach_render_obj_list($obj) {
+ $html = "";
+
+ #$i = 0;
+ #$skip = false;
+
+ while($obj->hasNext()) {
+ #foreach($obj as $elem) {
+ $elem = $obj->getNext();
+ #if(($i%2) == 0) {
+ $html .= "";
+ #}
+
+ switch($elem->getDisplay()) {
+ case "meta":
+ $html .= "".ach_render_obj_meta($elem)." | ";
+ break;
+ case "value":
+ #if(($i%2) == 1) {
+ # $html .= " | ";
+ #}
+ $html .= "".ach_render_obj_value($elem)." | ";
+ #$i++;
+ break;
+ case "simple":
+ $html .= "".ach_render_obj_simple($elem)." | ";
+ break;
+ case "hidden":
+ default:
+ //do nothing
+ #$skip = true;
+ #if(($i%2) == 1) {
+ # $html .= " ";
+ #}
+ $html .= "".ach_render_obj_hidden($elem)." | ";
+ #$i++;
+ break;
+ }
+
+ $html .= "";
+
+ $html .= " ";
+
+ $html .= " getPathID()."'> |
+ ";
+
+ #if(($i%2) == 1) {
+ $html .= " |
";
+ #}
+
+
+ #if(!$skip) {
+ # $i++;
+ #}
+ #$skip = false;
+ }
+
+ #if(($i%2) == 1) {
+ # $html .= "";
+ #}
+
+ $html .= "
";
+
+ return $html;
+ }
+
+ function ach_render_obj_simple(&$obj) {
+ global $_CONF;
+ $html = "";
+ if($obj->isdone()) {
+ $html .= " ";
+ }
+ else {
+ $html .= " ";
+ }
+
+ $html .= "[obj:]".$obj->getDisplayName()."";
+
+ return $html;
+ }
+
+ function ach_render_obj_meta(&$obj) {
+ global $_CONF;
+ $html = "";
+ if($obj->isdone()) {
+ $col = "#71BE02";
+ $grey = "";
+ }
+ else {
+ $col = "#999999";
+ $grey = "grey/";
+ }
+
+ return "
+
+ getMetaImage()."' width='20px' /> |
+ [obj:]".$obj->getDisplayName()." |
+
+
";
+ }
+
+ function ach_render_obj_value(&$obj) {
+ $html = "";
+ #if($obj->getName() != null) {
+ if($obj->isdone()) {
+ $col = "#71BE02";
+ }
+ else {
+ $col = "#999999";
+ }
+ $html .= "[obj:]".$obj->getDisplayName()."
";
+ #}
+
+ $html .= ach_render_progressbar($obj->getProgress(),$obj->getValue(),350);
+
+ return $html;
+ }
+
+ function ach_render_obj_hidden(&$obj) {
+ $html = "";
+ #if($obj->getName() != null) {
+ if($obj->isdone()) {
+ $col = "#71BE02";
+ }
+ else {
+ $col = "#999999";
+ }
+ $html .= "[obj: untitled]
";
+ #}
+
+ #$html .= ach_render_progressbar($obj->getProgress(),$obj->getValue(),350);
+
+ return $html;
+ }
+
+ function ach_render_progressbar($prog,$val,$width) {
+ $val = max(1,$val);
+ $left = floor($width*(100*($prog/$val))/100);
+
+ $html = "
+
+
+ ";
+ if(($prog/$val) > 0.85) {
+ $html .= " ".nf($prog)." / ".nf($val)." ";
+ }
+ $html .= " |
+ ";
+ if(($prog/$val) <= 0.85) {
+ $html .= " ".nf($prog)." / ".nf($val)." ";
+ }
+ $html .= " |
+
+
";
+
+ return $html;
+ }
+
+
+ function ach_render_tiebar($cult = "c_neutral", $civ = "c_neutral",&$cat) {
+ global $_USER,$_CONF;
+
+ $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()).""));
+ }
+ 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()).""));
+ }
+ 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()).""));
+ }
+ 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)."";
+ if($cat->isTiedCiv() && $civ != "c_neutral") {
+ #and the 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)."";
+ }
+ }
+ #, accomplish the following achievements:
+ $html .= get_translation('ach_allegiance_end',$_USER->getLang())."
";
+
+ return $html;
+ }
+?>
\ No newline at end of file
diff --git a/code/web/app/app_achievements_admin/include/adm_render_csr.php b/code/web/app/app_achievements_admin/include/adm_render_csr.php
new file mode 100644
index 000000000..cb973d573
--- /dev/null
+++ b/code/web/app/app_achievements_admin/include/adm_render_csr.php
@@ -0,0 +1,565 @@
+sendSQL("SELECT count(*) as anz FROM characters WHERE char_id='".mysql_real_escape_string($id)."'","ARRAY");
+
+ if($res[0]['anz'] > 0) {
+ return true;
+ }
+ return false;
+ }
+
+ function csr_render_yubopoints() {
+ 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']." ";
+
+ return $html;
+ }
+
+ function csr_render_find_player() {
+ global $DBc_char;
+
+ $html = "";
+
+ if($_REQUEST['pname'] != "") {
+ $html .= "";
+
+ $res = $DBc_char->sendSQL("SELECT char_id,char_name FROM characters WHERE char_name LIKE '".mysql_real_escape_string($_REQUEST['pname'])."%'","ARRAY");
+ $sz = sizeof($res);
+
+ if($sz == 0) {
+ $html .= "
no characters found";
+ }
+
+ $cols = 1;
+ if($sz > 8) {
+ $cols = 3;
+ }
+
+ $html .= "
";
+
+ for($i=0;$i<$sz;$i++) {
+ if($cols != 1 && ($i%$cols) == 0) {
+ $html .= "
";
+ }
+
+ $html .= "".$res[$i]['char_name']." | ";
+ }
+
+ $html .= "
";
+
+ $html .= "
";
+ }
+
+ return $html;
+ }
+
+ function csr_render_menu(&$menu,$sub = 0) {
+ $html = "";
+
+ return $html.adm_render_mnode($menu,$sub);
+ }
+
+ function adm_render_mnode(&$menu,$sub) {
+ global $_CONF;
+
+ $iter = $menu->getIterator();
+ while($iter->hasNext()) {
+ $curr = $iter->getNext();
+ #$sz = $menu->getSize();
+ #for($i=0;$i<$sz;$i++) {
+ # $curr = $menu->getChild($i);
+ if($curr->inDev()) {
+ #continue;
+ }
+ $html .= "getID()."'>";
+ if($curr->hasOpenCat() != 0) {
+ $html .= "".adm_render_mnode($curr,($sub+4))."
";
+ }
+ }
+
+ return $html;
+ }
+
+ function csr_render_category(&$cat) {
+ $html = "";
+
+ if($cat->isTiedCult() || $cat->isTiedCiv()) {
+ $html .= ach_render_tiebar($cat->getCurrentCult(),$cat->getCurrentCiv(),$cat);
+ }
+
+ $iter = $cat->getDone();
+ echo "
done: ".var_export($iter,true)."
";
+ while($iter->hasNext()) {
+ $curr = $cat->getChildByIdx($iter->getNext());
+
+ #$sz = sizeof($tmp);
+ #for($i=0;$i<$sz;$i++) {
+ #echo "A";
+ if($curr->inDev()) {
+ continue;
+ }
+ $html .= ach_render_achievement_done($curr);
+ }
+
+ $iter = $cat->getOpen();
+ echo "
open: ".var_export($iter,true)."
";
+ while($iter->hasNext()) {
+ $tmp = $iter->getNext();
+ $curr = $cat->getChildByIdx($tmp);
+ echo "".$tmp."-".$curr->getIdx()."
";
+ #$sz = sizeof($tmp);
+ #for($i=0;$i<$sz;$i++) {
+ #echo "B";
+ if($curr->inDev()) {
+ continue;
+ }
+ $html .= ach_render_achievement_open($curr);
+ }
+
+ return $html;
+ }
+
+ function ach_render_achievement_done(&$ach) {
+ global $_CONF;
+
+ $html = '
+
+ |
+ |
+ |
+
+
+ |
+
+
+
+ |
+ '.$ach->getName().' |
+
+ '.$ach->getValueDone().'
+ |
+ ';
+ $html .= ach_render_perk_done($ach);
+ $html .= ' |
+ |
+ |
+
+
+ |
+ |
+ |
+
+
';
+
+ return $html;
+ }
+
+ function ach_render_achievement_open(&$ach) {
+ global $_CONF;
+
+ $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();
+ $perk = $ach->getChildByIdx($perk_list->getNext());
+
+ echo "".$ach->getIdx()."";
+ echo "
".var_export($perk_list,true)."
";
+
+ #$perk = $ach->getChild($perk_list[0]);
+
+ if($perk->inDev()) {
+ return $html;
+ }
+
+ $html .= "";
+
+ if($perk->getName() != null) {
+ $html .= $perk->getName();
+ }
+ else {
+ $tml .= "[untitled]";
+ }
+ $html .= " getPath()."'>Perk: grant";
+ #if($perk->getName() != null) {
+ $html .= "";
+ #}
+ if($perk->objDrawable()) {
+ $html .= ach_render_obj_list($perk->getIterator());
+ }
+
+ return $html;
+ }
+
+ function ach_render_perk_done(&$ach) {
+ global $_CONF;
+ $html = "";
+
+ $perk_list = $ach->getDone();
+ while($perk_list->hasNext()) {
+ $perk = $ach->getChildByIdx($perk_list->getNext());
+ #foreach($perk_list as $elem) {
+ #$perk = $ach->getChild($elem);
+ if($perk->inDev()) {
+ continue;
+ }
+ $html .= "";
+ }
+
+ return $html;
+ }
+
+ function ach_render_obj_list($obj) {
+ $html = "";
+
+ $i = 0;
+ $skip = false;
+
+ while($obj->hasNext()) {
+ #foreach($obj as $elem) {
+ $elem = $obj->getNext();
+ if(($i%2) == 0) {
+ $html .= "";
+ }
+
+ switch($elem->getDisplay()) {
+ case "meta":
+ $html .= "".ach_render_obj_meta($elem)." | ";
+ break;
+ case "value":
+ if(($i%2) == 1) {
+ $html .= "
";
+ }
+ $html .= "".ach_render_obj_value($elem)." | ";
+ $i++;
+ break;
+ case "simple":
+ $html .= "".ach_render_obj_simple($elem)." | ";
+ break;
+ case "hidden":
+ default:
+ //do nothing
+ $skip = true;
+ break;
+ }
+
+ if(($i%2) == 1) {
+ $html .= "
";
+ }
+
+
+ if(!$skip) {
+ $i++;
+ }
+ $skip = false;
+ }
+
+ if(($i%2) == 1) {
+ $html .= "";
+ }
+
+ $html .= "
";
+
+ return $html;
+ }
+
+ function ach_render_obj_simple(&$obj) {
+ global $_CONF;
+ $html = "";
+ if($obj->isdone()) {
+ $html .= " ";
+ }
+ else {
+ $html .= " ";
+ }
+
+ $html .= $obj->getName();
+ if($obj->isdone()) {
+ $html .= " getPath()."'>Obj: deny";
+ }
+ else {
+ $html .= " getPath()."'>Obj: grant";
+ }
+ $html .= "";
+
+ return $html;
+ }
+
+ function ach_render_obj_meta(&$obj) {
+ global $_CONF;
+ $html = "";
+ if($obj->isdone()) {
+ $col = "#71BE02";
+ $grey = "";
+ }
+ else {
+ $col = "#999999";
+ $grey = "grey/";
+ }
+
+ $html .= "";
+
+ return $html;
+ }
+
+ function ach_render_obj_value(&$obj) {
+ $html = "";
+ if($obj->getName() != null) {
+ if($obj->isdone()) {
+ $col = "#71BE02";
+ }
+ else {
+ $col = "#999999";
+ }
+ $html .= "".$obj->getName()."
";
+ }
+
+ $html .= "";
+
+ return $html;
+ }
+
+ function ach_render_progressbar($prog,$val,$width) {
+ $val = max(1,$val);
+ $left = floor($width*(100*($prog/$val))/100);
+
+ $html = "
+
+
+ ";
+ if(($prog/$val) > 0.85) {
+ $html .= " ".nf($prog)." / ".nf($val)." ";
+ }
+ $html .= " |
+ ";
+ if(($prog/$val) <= 0.85) {
+ $html .= " ".nf($prog)." / ".nf($val)." ";
+ }
+ $html .= " |
+
+
";
+
+ return $html;
+ }
+
+ function ach_render_summary_header() {
+ global $_USER;
+
+ return "".get_translation('ach_summary_header',$_USER->getLang())."
";
+ }
+
+ function ach_render_summary_footer(&$summary) {
+ global $_USER;
+
+ $nodes = $summary->getSummary();
+ $html = "";
+
+ $sum_done = 0;
+ $sum_total = 0;
+
+ $i = 0;
+ foreach($nodes as $elem) {
+ if(($i%3) == 0) {
+ $html .= "";
+ }
+
+ $html .= "".$elem[0]." ".ach_render_progressbar($elem[1],$elem[2],200)." | ";
+ $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',$_USER->getLang())."
+
+
+ ".get_translation('ach_summary_stats_total',$_USER->getLang())." ".ach_render_progressbar($sum_done,$sum_total,450)."
|
+
+ ".$html."
+
";
+
+ return $html;
+ }
+
+ function ach_render_tiebar($cult = "c_neutral", $civ = "c_neutral",&$cat) {
+ global $_USER,$_CONF;
+
+ $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()).""));
+ }
+ 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()).""));
+ }
+ 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()).""));
+ }
+ 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)."";
+ if($cat->isTiedCiv() && $civ != "c_neutral") {
+ #and the 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)."";
+ }
+ }
+ #, accomplish the following achievements:
+ $html .= get_translation('ach_allegiance_end',$_USER->getLang())."
";
+
+ return $html;
+ }
+?>
\ No newline at end of file
diff --git a/code/web/app/app_achievements_admin/include/adm_render_menu.php b/code/web/app/app_achievements_admin/include/adm_render_menu.php
new file mode 100644
index 000000000..2e231bfff
--- /dev/null
+++ b/code/web/app/app_achievements_admin/include/adm_render_menu.php
@@ -0,0 +1,171 @@
+
+ .ach_menu {
+ display:block;
+ padding:2px;
+ border:1px solid #000000;
+ margin-bottom:2px;
+ color:#FFFFFF;
+ }
+ .ach_menu:hover {
+ color:orange;
+ }
+
+ .ach_mspan a {
+ text-decoration:none;
+ }
+ ";
+
+ $html .= "
+
+
+
";
+
+ if($_REQUEST['ac_id'] > 0 && $_REQUEST['confirm'] == "delete") {
+ $curr = $menu->getNode($_REQUEST['ac_id']);
+ $html .= "
+
+
";
+ }
+
+ $html .= "
";
+
+ return $html.ach_render_mnode($menu,$sub);
+ }
+
+ function ach_render_mnode(&$menu,$sub) {
+ global $_CONF;
+
+ # echo "1";
+
+ $iter = $menu->getIterator();
+ while($iter->hasNext()) {
+ $curr = $iter->getNext();
+ #$sz = $menu->getSize();
+ #for($i=0;$i<$sz;$i++) {
+ # $curr = $menu->getChild($i);
+
+ $html .= "";
+ if($sub == 0) {
+ $html .= "";
+ }
+
+ $html .= "";
+
+ if(!$curr->isEmpty()) {
+ $html .= "".ach_render_mnode($curr,($sub+4))."
";
+ }
+ }
+
+ return $html;
+ }
+?>
\ No newline at end of file
diff --git a/code/web/app/app_achievements_admin/index.php b/code/web/app/app_achievements_admin/index.php
index cc6b6cbda..f95aff209 100644
--- a/code/web/app/app_achievements_admin/index.php
+++ b/code/web/app/app_achievements_admin/index.php
@@ -24,44 +24,54 @@ $user['admin'] = true;
require_once($_CONF['app_achievements_path']."class/RyzomUser_class.php");
require_once("class/RyzomAdmin_class.php");
-$_USER = new RyzomAdmin($user);
+$_ADMIN = new RyzomAdmin($user);
-require_once("include/ach_render_admin.php");
-#require_once("include/ach_render_csr.php");
-
-require_once($_CONF['app_achievements_path']."class/RenderNodeIterator_abstract.php");
-require_once($_CONF['app_achievements_path']."class/NodeIterator_class.php");
-require_once($_CONF['app_achievements_path']."class/AchList_abstract.php");
-require_once($_CONF['app_achievements_path']."class/Tieable_inter.php");
-
-require_once($_CONF['app_achievements_path']."class/AchMenu_class.php");
-require_once($_CONF['app_achievements_path']."class/AchMenuNode_class.php");
-#require_once($_CONF['app_achievements_path']."class/AchCategory_class.php");
-#require_once($_CONF['app_achievements_path']."class/AchAchievement_class.php");
-#require_once($_CONF['app_achievements_path']."class/AchPerk_class.php");
-#require_once($_CONF['app_achievements_path']."class/AchObjective_class.php");
-
-require_once("class/ADM_inter.php");
-require_once("class/AdmDispatcher_inter.php");
-require_once("class/AdmMenu_class.php");
-require_once("class/AdmMenuNode_class.php");
-#require_once("class/AdmCategory_class.php");
-#require_once("class/AdmAchievement_class.php");
-#require_once("class/AdmPerk_class.php");
-#require_once("class/AdmObjective_class.php");
-
-/*require_once("class/CSR_inter.php");
-require_once("class/CSRMenu_class.php");
-require_once("class/CSRCategory_class.php");
-require_once("class/CSRAchievement_class.php");
-require_once("class/CSRPerk_class.php");
-require_once("class/CSRObjective_class.php");*/
-
-if($_USER->isIG()) {
+if($_ADMIN->isIG()) {
die("IG disabled for admin tool!");
}
-$DBc = ryDB::getInstance("ahufler");
+require_once("class/mySQL_class.php");
+
+#require_once("include/ach_render_admin.php");
+#require_once("include/ach_render_csr.php");
+require_once($_CONF['app_achievements_path']."include/ach_render_common.php");
+
+require_once($_CONF['app_achievements_path']."class/AVLTree_class.php");
+require_once($_CONF['app_achievements_path']."class/Parentum_abstract.php");
+require_once($_CONF['app_achievements_path']."class/AchList_abstract.php");
+require_once($_CONF['app_achievements_path']."class/Tieable_inter.php");
+require_once($_CONF['app_achievements_path']."class/NodeIterator_class.php");
+require_once($_CONF['app_achievements_path']."class/Node_trait.php");
+require_once($_CONF['app_achievements_path']."class/InDev_trait.php");
+
+require_once($_CONF['app_achievements_path']."class/AchMenu_class.php");
+require_once($_CONF['app_achievements_path']."class/AchMenuNode_class.php");
+require_once($_CONF['app_achievements_path']."class/AchCategory_class.php");
+require_once($_CONF['app_achievements_path']."class/AchAchievement_class.php");
+require_once($_CONF['app_achievements_path']."class/AchPerk_class.php");
+require_once($_CONF['app_achievements_path']."class/AchObjective_class.php");
+
+require_once("class/ADM_inter.php");
+require_once("class/AdmDispatcher_trait.php");
+require_once("class/AdmMenu_class.php");
+require_once("class/AdmMenuNode_class.php");
+require_once("class/AdmCategory_class.php");
+require_once("class/AdmAchievement_class.php");
+require_once("class/AdmPerk_class.php");
+require_once("class/AdmObjective_class.php");
+require_once("class/AdmAtom_class.php");
+
+require_once("class/CSRDispatcher_trait.php");
+require_once("class/CSR_inter.php");
+#require_once("class/CSRMenu_class.php");
+require_once("class/CSRCategory_class.php");
+require_once("class/CSRAchievement_class.php");
+require_once("class/CSRPerk_class.php");
+require_once("class/CSRObjective_class.php");
+require_once("class/CSRAtom_class.php");
+
+$DBc = ryDB::getInstance("app_achievements");
+#$DBc = ryDB::getInstance("ahufler");
function mkn($x) {
if($x == null || strtolower($x) == "null") {
@@ -94,21 +104,27 @@ $c = "
+
+
- ";
+ ";
- if($_USER->isAdmin()) {
+ if($_ADMIN->isAdmin()) {
$c .= " Admin
";
}
- if($_USER->isCSR()) {
+ if($_ADMIN->isCSR()) {
$c .= " CSR
";
}
@@ -118,13 +134,26 @@ $c = " | |