#1470 major update; these changes were necessary for the admin tool; currently untested - need new testserver with php 5.4
--HG-- branch : gsoc2012-achievements
This commit is contained in:
parent
a874eb6f04
commit
a3d40de283
15 changed files with 309 additions and 196 deletions
|
@ -1,21 +1,23 @@
|
||||||
<?php
|
<?php
|
||||||
class AchAchievement extends AchList {
|
class AchAchievement extends AchList {
|
||||||
private $id;
|
use Node;
|
||||||
private $parent;
|
|
||||||
private $category;
|
|
||||||
private $tie_race;
|
|
||||||
private $tie_civ;
|
|
||||||
private $tie_cult;
|
|
||||||
private $image;
|
|
||||||
private $name;
|
|
||||||
private $template;
|
|
||||||
private $dev;
|
|
||||||
|
|
||||||
function AchAchievement(&$data) {
|
protected $parent_id;
|
||||||
|
protected $category;
|
||||||
|
protected $tie_race;
|
||||||
|
protected $tie_civ;
|
||||||
|
protected $tie_cult;
|
||||||
|
protected $image;
|
||||||
|
protected $name;
|
||||||
|
protected $template;
|
||||||
|
protected $dev;
|
||||||
|
|
||||||
|
function AchAchievement($data,$parent) {
|
||||||
global $DBc,$_USER;
|
global $DBc,$_USER;
|
||||||
|
|
||||||
$this->id = $data['aa_id'];
|
$this->setParent($parent);
|
||||||
$this->parent = $data['aa_parent'];
|
$this->setID($data['aa_id']);
|
||||||
|
$this->parent_id = $data['aa_parent'];
|
||||||
$this->category = $data['aa_category'];
|
$this->category = $data['aa_category'];
|
||||||
$this->tie_race = $data['aa_tie_race'];
|
$this->tie_race = $data['aa_tie_race'];
|
||||||
$this->tie_civ = $data['aa_tie_civ'];
|
$this->tie_civ = $data['aa_tie_civ'];
|
||||||
|
@ -25,44 +27,27 @@
|
||||||
$this->template = $data['aal_template'];
|
$this->template = $data['aal_template'];
|
||||||
$this->dev = $data['aa_dev'];
|
$this->dev = $data['aa_dev'];
|
||||||
|
|
||||||
#echo $this->id;
|
|
||||||
|
|
||||||
$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");
|
$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
|
#MISSING: or parent is done
|
||||||
$sz = sizeof($res);
|
$sz = sizeof($res);
|
||||||
for($i=0;$i<$sz;$i++) {
|
for($i=0;$i<$sz;$i++) {
|
||||||
#echo "Z";
|
|
||||||
$res[$i]['this'] = $this;
|
|
||||||
$tmp = $this->makeChild($res[$i]);
|
$tmp = $this->makeChild($res[$i]);
|
||||||
|
|
||||||
#echo var_export($tmp,true);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if($tmp->isDone()) {
|
if($tmp->isDone()) {
|
||||||
$this->child_done[] = sizeof($this->nodes);
|
$this->addDone($tmp);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$this->child_open[] = sizeof($this->nodes);
|
$this->addOpen($tmp);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$this->nodes[] = $tmp;
|
|
||||||
#MISSING: divide into groups -> open/done
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#echo var_export($this->child_open,true);
|
protected function makeChild($a) {
|
||||||
#echo "X-".$this->hasOpen();
|
return new AchPerk($a,$this);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function makeChild(&$a) {
|
function getParentID() {
|
||||||
return new AchPerk($a);
|
return $this->parent_id;
|
||||||
}
|
|
||||||
|
|
||||||
function getID() {
|
|
||||||
return $this->id;
|
|
||||||
}
|
|
||||||
|
|
||||||
function getParent() {
|
|
||||||
return $this->parent;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getTieRace() {
|
function getTieRace() {
|
||||||
|
@ -87,14 +72,21 @@
|
||||||
|
|
||||||
function getValueDone() {
|
function getValueDone() {
|
||||||
$val = 0;
|
$val = 0;
|
||||||
foreach($this->child_done as $elem) {
|
$iter = $this->getDone();
|
||||||
$val += $this->nodes[$elem]->getValue();
|
while($iter->hasNext()) {
|
||||||
|
$curr = $this->findNodeIdx($iter->getNext());
|
||||||
|
$val += $curr->getValue();
|
||||||
}
|
}
|
||||||
return $val;
|
return $val;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getValueOpen() {
|
function getValueOpen() {
|
||||||
return $this->nodes[$this->child_open[0]]->getValue();
|
$iter = $this->getDone();
|
||||||
|
if($iter->hasNext()) {
|
||||||
|
$curr = $this->findNodeIdx($iter->getNext());
|
||||||
|
return $curr->getValue();
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getTemplate($insert = array()) {
|
function getTemplate($insert = array()) {
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
<?php
|
<?php
|
||||||
class AchCategory extends AchList implements Tieable {
|
class AchCategory extends AchList implements Tieable {
|
||||||
private $id = false;
|
protected $id;
|
||||||
private $ties_cult;
|
protected $ties_cult;
|
||||||
private $ties_civ;
|
protected $ties_civ;
|
||||||
private $ties_cult_dev;
|
protected $ties_cult_dev;
|
||||||
private $ties_civ_dev;
|
protected $ties_civ_dev;
|
||||||
private $cult;
|
protected $cult;
|
||||||
private $civ;
|
protected $civ;
|
||||||
|
|
||||||
function AchCategory($id,$cult = null,$civ = null) {
|
function AchCategory($id,$cult = null,$civ = null) {
|
||||||
global $DBc,$_USER;
|
global $DBc,$_USER;
|
||||||
|
@ -28,17 +28,14 @@
|
||||||
|
|
||||||
$sz = sizeof($res);
|
$sz = sizeof($res);
|
||||||
for($i=0;$i<$sz;$i++) {
|
for($i=0;$i<$sz;$i++) {
|
||||||
#echo "Y";
|
|
||||||
$tmp = $this->makeChild($res[$i]);
|
$tmp = $this->makeChild($res[$i]);
|
||||||
#echo var_export($tmp,true);
|
|
||||||
if($tmp->hasOpen()) {
|
if($tmp->hasOpen()) {
|
||||||
$this->child_open[] = sizeof($this->nodes);
|
$this->addOpen($tmp);
|
||||||
}
|
}
|
||||||
if($tmp->hasDone()) {
|
if($tmp->hasDone()) {
|
||||||
$this->child_done[] = sizeof($this->nodes);
|
$this->addDone($tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->nodes[] = $tmp;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$res = $DBc->sqlQuery("SELECT count(*) as anz FROM ach_achievement WHERE aa_tie_cult IS NOT NULL AND aa_category='".$this->id."' AND aa_dev='0'");
|
$res = $DBc->sqlQuery("SELECT count(*) as anz FROM ach_achievement WHERE aa_tie_cult IS NOT NULL AND aa_category='".$this->id."' AND aa_dev='0'");
|
||||||
|
@ -54,8 +51,8 @@
|
||||||
$this->ties_civ_dev = $res[0]['anz'];
|
$this->ties_civ_dev = $res[0]['anz'];
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function makeChild(&$a) {
|
protected function makeChild($a) {
|
||||||
return new AchAchievement($a);
|
return new AchAchievement($a,$this);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getID() {
|
function getID() {
|
||||||
|
|
|
@ -1,22 +1,39 @@
|
||||||
<?php
|
<?php
|
||||||
abstract class AchList extends RenderNodeIterator {
|
abstract class AchList extends Parentum {
|
||||||
protected $child_done = array();
|
protected $child_done = array();
|
||||||
protected $child_open = array();
|
protected $child_open = array();
|
||||||
|
|
||||||
function getDone() {
|
final function getDone() {
|
||||||
return $this->child_done;
|
return new NodeIterator($this->child_done);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getOpen() {
|
final function getOpen() {
|
||||||
return $this->child_open;
|
return new NodeIterator($this->child_open);
|
||||||
}
|
}
|
||||||
|
|
||||||
function hasOpen() {
|
final function hasOpen() {
|
||||||
return (sizeof($this->child_open) != 0);
|
return (sizeof($this->child_open) != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
function hasDone() {
|
final function hasDone() {
|
||||||
return (sizeof($this->child_done) != 0);
|
return (sizeof($this->child_done) != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final function addOpen($n) {
|
||||||
|
$this->child_open[] = $this->addChild($n);
|
||||||
|
}
|
||||||
|
|
||||||
|
final function addDone($n) {
|
||||||
|
$this->child_done[] = $this->addChild($n);
|
||||||
|
}
|
||||||
|
|
||||||
|
function removeChild() {
|
||||||
|
$idx = $this->getIdx($id);
|
||||||
|
if($idx != null) {
|
||||||
|
unset($this->child_open[$idx]);
|
||||||
|
unset($this->child_done[$idx]);
|
||||||
|
parent::removeIdx($idx);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
|
@ -1,6 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
class AchMenuNode extends RenderNodeIterator {
|
class AchMenuNode extends Parentum {
|
||||||
protected $id;
|
use Node;
|
||||||
|
|
||||||
protected $parent_id;
|
protected $parent_id;
|
||||||
protected $name;
|
protected $name;
|
||||||
protected $open;
|
protected $open;
|
||||||
|
@ -8,10 +9,11 @@
|
||||||
protected $order;
|
protected $order;
|
||||||
protected $dev;
|
protected $dev;
|
||||||
|
|
||||||
function AchMenuNode(&$data) {
|
function AchMenuNode($data,$parent) {
|
||||||
global $DBc,$_USER;
|
global $DBc,$_USER;
|
||||||
|
|
||||||
$this->id = $data['ac_id'];
|
$this->setParent($parent);
|
||||||
|
$this->setID($data['ac_id']);
|
||||||
$this->parent_id = $data['ac_parent'];
|
$this->parent_id = $data['ac_parent'];
|
||||||
$this->name = $data['acl_name'];
|
$this->name = $data['acl_name'];
|
||||||
$this->image = $data['ac_image'];
|
$this->image = $data['ac_image'];
|
||||||
|
@ -28,12 +30,8 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function makeChild(&$a) {
|
protected function makeChild($a) {
|
||||||
return new AchMenuNode($a);
|
return new AchMenuNode($a,$this);
|
||||||
}
|
|
||||||
|
|
||||||
function getID() {
|
|
||||||
return $this->id;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getName() {
|
function getName() {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
class AchMenu extends RenderNodeIterator {
|
class AchMenu extends Parentum {
|
||||||
/*---------------------------
|
/*---------------------------
|
||||||
This class is the dispatcher for actual MenuNodes.
|
This class is the dispatcher for actual MenuNodes.
|
||||||
Since every MenuNode will only keep a list of it's children,
|
Since every MenuNode will only keep a list of it's children,
|
||||||
|
@ -20,7 +20,7 @@
|
||||||
$tmp['ac_image'] = "test.png";
|
$tmp['ac_image'] = "test.png";
|
||||||
$tmp['ac_order'] = -1;
|
$tmp['ac_order'] = -1;
|
||||||
$tmp['open'] = $open;
|
$tmp['open'] = $open;
|
||||||
$this->nodes[] = new AchMenuNode($tmp);
|
$this->nodes[] = new AchMenuNode($tmp,$this);
|
||||||
|
|
||||||
$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");
|
$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");
|
||||||
|
|
||||||
|
@ -45,8 +45,8 @@
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function makeChild(&$a) {
|
protected function makeChild($a) {
|
||||||
return new AchMenuNode($a);
|
return new AchMenuNode($a,$this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
|
@ -1,19 +1,21 @@
|
||||||
<?php
|
<?php
|
||||||
class AchObjective extends Parentum {
|
class AchObjective extends Parentum {
|
||||||
private $id;
|
use Node;
|
||||||
private $perk;
|
|
||||||
private $condition;
|
|
||||||
private $value;
|
|
||||||
private $name;
|
|
||||||
private $display;
|
|
||||||
private $done;
|
|
||||||
private $progress;
|
|
||||||
private $meta_image;
|
|
||||||
|
|
||||||
function AchObjective(&$data) {
|
protected $perk;
|
||||||
|
protected $condition;
|
||||||
|
protected $value;
|
||||||
|
protected $name;
|
||||||
|
protected $display;
|
||||||
|
protected $done;
|
||||||
|
protected $progress;
|
||||||
|
protected $meta_image;
|
||||||
|
|
||||||
|
function AchObjective($data,$parent) {
|
||||||
global $DBc,$_USER;
|
global $DBc,$_USER;
|
||||||
|
|
||||||
$this->id = $data['ao_id'];
|
$this->setParent($parent);
|
||||||
|
$this->setID($data['ao_id']);
|
||||||
$this->perk = $data['ao_perk'];
|
$this->perk = $data['ao_perk'];
|
||||||
$this->condition = $data['ao_condition'];
|
$this->condition = $data['ao_condition'];
|
||||||
$this->value = $data['ao_value'];
|
$this->value = $data['ao_value'];
|
||||||
|
@ -30,7 +32,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function makeChild(&$a) {
|
protected function makeChild($a) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,10 +40,6 @@
|
||||||
return $this->meta_image;
|
return $this->meta_image;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getID() {
|
|
||||||
return $this->id;
|
|
||||||
}
|
|
||||||
|
|
||||||
function getPerk() {
|
function getPerk() {
|
||||||
return $this->perk;
|
return $this->perk;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
<?php
|
<?php
|
||||||
class AchPerk extends RenderNodeIterator {
|
class AchPerk extends Parentum {
|
||||||
private $id;
|
use Node;
|
||||||
private $parent;
|
|
||||||
private $achievement;
|
|
||||||
private $value;
|
|
||||||
private $name;
|
|
||||||
private $done;
|
|
||||||
private $dev;
|
|
||||||
|
|
||||||
function AchPerk(&$data) {
|
protected $achievement;
|
||||||
|
protected $value;
|
||||||
|
protected $name;
|
||||||
|
protected $done;
|
||||||
|
protected $dev;
|
||||||
|
|
||||||
|
function AchPerk($data,$parent) {
|
||||||
global $DBc,$_USER;
|
global $DBc,$_USER;
|
||||||
|
|
||||||
$this->id = $data['ap_id'];
|
$this->setParent($parent);
|
||||||
$this->parent = $data['this'];
|
$this->setID($data['ap_id']);
|
||||||
$this->achievement = $data['ap_achievement'];
|
$this->achievement = $data['ap_achievement'];
|
||||||
$this->value = $data['ap_value'];
|
$this->value = $data['ap_value'];
|
||||||
$this->name = $data['apl_name'];
|
$this->name = $data['apl_name'];
|
||||||
|
@ -22,20 +22,12 @@
|
||||||
$res = $DBc->sqlQuery("SELECT * FROM ach_objective LEFT JOIN (ach_objective_lang) ON (aol_lang='".$_USER->getLang()."' AND aol_objective=ao_id) LEFT JOIN (ach_player_objective) ON (apo_objective=ao_id AND apo_player='".$_USER->getID()."') LEFT JOIN (ach_achievement) ON (aa_id=ao_metalink) WHERE ao_perk='".$this->id."'");
|
$res = $DBc->sqlQuery("SELECT * FROM ach_objective LEFT JOIN (ach_objective_lang) ON (aol_lang='".$_USER->getLang()."' AND aol_objective=ao_id) LEFT JOIN (ach_player_objective) ON (apo_objective=ao_id AND apo_player='".$_USER->getID()."') LEFT JOIN (ach_achievement) ON (aa_id=ao_metalink) WHERE ao_perk='".$this->id."'");
|
||||||
$sz = sizeof($res);
|
$sz = sizeof($res);
|
||||||
for($i=0;$i<$sz;$i++) {
|
for($i=0;$i<$sz;$i++) {
|
||||||
$this->nodes[] = $this->makeChild($res[$i]);
|
$this->addChild($this->makeChild($res[$i]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function makeChild(&$a) {
|
protected function makeChild($a) {
|
||||||
return new AchObjective($a);
|
return new AchObjective($a,$this);
|
||||||
}
|
|
||||||
|
|
||||||
function getID() {
|
|
||||||
return $this->id;
|
|
||||||
}
|
|
||||||
|
|
||||||
function getParent() {
|
|
||||||
return $this->parent;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getAchievement() {
|
function getAchievement() {
|
||||||
|
@ -51,11 +43,14 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function objDrawable() {
|
function objDrawable() {
|
||||||
foreach($this->nodes as $elem) {
|
$iter = $this->getIterator();
|
||||||
if($elem->getDisplay() != "hidden") {
|
while($iter->hasNext()) {
|
||||||
|
$curr = $iter->getNext();
|
||||||
|
if($curr->getDisplay() != "hidden") {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,15 +15,12 @@
|
||||||
|
|
||||||
$sz = sizeof($res);
|
$sz = sizeof($res);
|
||||||
for($i=0;$i<$sz;$i++) {
|
for($i=0;$i<$sz;$i++) {
|
||||||
$tmp = $this->makeChild($res[$i]);
|
$this->addDone($this->makeChild($res[$i]));
|
||||||
|
|
||||||
$this->child_done[] = sizeof($this->nodes);
|
|
||||||
$this->nodes[] = $tmp;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function makeChild(&$a) {
|
protected function makeChild($a) {
|
||||||
return new AchAchievement($a);
|
return new AchAchievement($a,$this);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getSummary() {
|
function getSummary() {
|
||||||
|
@ -32,13 +29,15 @@
|
||||||
//and also sum up how many have been completed
|
//and also sum up how many have been completed
|
||||||
$this->stats = array(); // [][name,done,total]
|
$this->stats = array(); // [][name,done,total]
|
||||||
|
|
||||||
$tmp = $this->menu->getChildren();
|
$iter = $this->menu->getIterator();
|
||||||
foreach($tmp as $elem) {
|
while($iter->hasNext()) {
|
||||||
if($elem->getID() == 0 || $elem->inDev()) {
|
$curr = $iter->getNext();
|
||||||
|
|
||||||
|
if($curr->getID() == 0 || $curr->inDev()) {
|
||||||
continue; // skip summary page
|
continue; // skip summary page
|
||||||
}
|
}
|
||||||
$res = $this->sumStats($elem);
|
$res = $this->sumStats($curr);
|
||||||
$this->stats[] = array($elem->getName(),$res[0],$res[1]);
|
$this->stats[] = array($curr->getName(),$res[0],$res[1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,8 +58,10 @@
|
||||||
$res = $DBc->sqlQuery("SELECT count(ap_id) as anz FROM ach_perk,ach_achievement WHERE aa_category='".$node->getID()."' AND ap_achievement=aa_id AND aa_dev='0' AND ap_dev='0'");
|
$res = $DBc->sqlQuery("SELECT count(ap_id) as anz FROM ach_perk,ach_achievement WHERE aa_category='".$node->getID()."' AND ap_achievement=aa_id AND aa_dev='0' AND ap_dev='0'");
|
||||||
$total += $res[0]["anz"];
|
$total += $res[0]["anz"];
|
||||||
|
|
||||||
$tmp = $node->getChildren();
|
$iter = $node->getIterator();
|
||||||
foreach($tmp as $elem) {
|
while($iter->hasNext()) {
|
||||||
|
$curr = $iter->getNext();
|
||||||
|
|
||||||
$res = $this->sumStats($elem);
|
$res = $this->sumStats($elem);
|
||||||
$done += $res[0];
|
$done += $res[0];
|
||||||
$total += $res[1];
|
$total += $res[1];
|
||||||
|
|
25
code/web/app/app_achievements/class/NodeIterator_class.php
Normal file
25
code/web/app/app_achievements/class/NodeIterator_class.php
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
<?php
|
||||||
|
class NodeIterator {
|
||||||
|
private $nodes;
|
||||||
|
private $curr;
|
||||||
|
|
||||||
|
function NodeIterator(&$nodes) {
|
||||||
|
$this->nodes = $nodes;
|
||||||
|
$this->curr = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
function hasNext() {
|
||||||
|
$tmp = array_keys($this->nodes);
|
||||||
|
return isset($this->nodes[$tmp[$this->curr]]);
|
||||||
|
}
|
||||||
|
|
||||||
|
function getNext() {
|
||||||
|
$tmp = array_keys($this->nodes);
|
||||||
|
return $this->nodes[$tmp[$this->curr++]];
|
||||||
|
}
|
||||||
|
|
||||||
|
function first() {
|
||||||
|
$this->curr = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
22
code/web/app/app_achievements/class/Node_trait.php
Normal file
22
code/web/app/app_achievements/class/Node_trait.php
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
<?php
|
||||||
|
trait Node {
|
||||||
|
protected $id;
|
||||||
|
protected $parent;
|
||||||
|
|
||||||
|
final function getID() {
|
||||||
|
return $this->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
final function getParent() {
|
||||||
|
return $this->parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
final protected function setID($id) {
|
||||||
|
$this->id = $id;
|
||||||
|
}
|
||||||
|
|
||||||
|
final protected function setParent($p) {
|
||||||
|
$this->parent = $p;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
|
@ -1,5 +1,68 @@
|
||||||
<?php
|
<?php
|
||||||
abstract class Parentum {
|
abstract class Parentum {
|
||||||
abstract protected function makeChild(&$args);
|
/*---------------------------
|
||||||
|
This class allows external access to the child-node list.
|
||||||
|
Use the NodeIterator to iterate through the list since
|
||||||
|
the numeric array keys might have gaps due to node removals!
|
||||||
|
---------------------------*/
|
||||||
|
protected $nodes = array();
|
||||||
|
|
||||||
|
abstract protected function makeChild($args); // overwriteable child generator; allows to define child type (eg.: admin classes that inherit base class)
|
||||||
|
|
||||||
|
final function getSize() {
|
||||||
|
return sizeof($this->nodes);
|
||||||
|
}
|
||||||
|
|
||||||
|
final function isEmpty() {
|
||||||
|
return (sizeof($this->nodes) == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
final function getIterator() {
|
||||||
|
return new NodeIterator($this->nodes);
|
||||||
|
}
|
||||||
|
|
||||||
|
final function addChild($n) {
|
||||||
|
$tmp = sizeof($this->nodes);
|
||||||
|
$this->nodes[] = $n;
|
||||||
|
return $tmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
function removeChild($id) {
|
||||||
|
$this->removeIdx($this->getIdx($id));
|
||||||
|
}
|
||||||
|
|
||||||
|
function removeNode($n) {
|
||||||
|
$this->removeIdx($this->findNode($n));
|
||||||
|
}
|
||||||
|
|
||||||
|
final protected function removeIdx($idx) {
|
||||||
|
if($idx != null) {
|
||||||
|
unset($this->nodes[$idx]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
final protected function findNode($n) {
|
||||||
|
foreach($this->nodes as $key=>$elem) {
|
||||||
|
if($this->nodes[$key] === $n) {
|
||||||
|
return $key;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
final protected function findNodeIdx($idx) {
|
||||||
|
return $this->nodes[$idx];
|
||||||
|
}
|
||||||
|
|
||||||
|
final protected function getIdx($id) {
|
||||||
|
foreach($this->nodes as $key=>$elem) {
|
||||||
|
if($elem->getID() == $id) {
|
||||||
|
return $key;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
|
@ -1,21 +0,0 @@
|
||||||
<?php
|
|
||||||
abstract class RenderNodeIterator extends Parentum {
|
|
||||||
protected $nodes = array();
|
|
||||||
|
|
||||||
function getSize() {
|
|
||||||
return sizeof($this->nodes);
|
|
||||||
}
|
|
||||||
|
|
||||||
function getChild($i) {
|
|
||||||
return $this->nodes[$i];
|
|
||||||
}
|
|
||||||
|
|
||||||
function isEmpty() {
|
|
||||||
return (sizeof($this->nodes) == 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
function getChildren() {
|
|
||||||
return $this->nodes;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
?>
|
|
|
@ -132,9 +132,13 @@
|
||||||
if($sub == 0) {
|
if($sub == 0) {
|
||||||
$html = "<table cellpadding='2px'>";
|
$html = "<table cellpadding='2px'>";
|
||||||
}
|
}
|
||||||
$sz = $menu->getSize();
|
|
||||||
for($i=0;$i<$sz;$i++) {
|
$iter = $menu->getIterator();
|
||||||
$curr = $menu->getChild($i);
|
while($iter->hasNext()) {
|
||||||
|
$curr = $iter->getNext();
|
||||||
|
#$sz = $menu->getSize();
|
||||||
|
#for($i=0;$i<$sz;$i++) {
|
||||||
|
#$curr = $menu->getChild($i);
|
||||||
if($curr->inDev()) {
|
if($curr->inDev()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -176,24 +180,28 @@
|
||||||
$html .= ach_render_tiebar($cat->getCurrentCult(),$cat->getCurrentCiv(),$cat);
|
$html .= ach_render_tiebar($cat->getCurrentCult(),$cat->getCurrentCiv(),$cat);
|
||||||
}
|
}
|
||||||
|
|
||||||
$tmp = $cat->getDone();
|
$iter = $cat->getDone();
|
||||||
$sz = sizeof($tmp);
|
while($iter->hasNext()) {
|
||||||
for($i=0;$i<$sz;$i++) {
|
$curr = $cat->findNodeIdx($iter->getNext());
|
||||||
|
#$sz = sizeof($tmp);
|
||||||
|
#for($i=0;$i<$sz;$i++) {
|
||||||
#echo "A";
|
#echo "A";
|
||||||
if($cat->getChild($tmp[$i])->inDev()) {
|
if($curr->inDev()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$html .= ach_render_achievement_done($cat->getChild($tmp[$i]));
|
$html .= ach_render_achievement_done($curr);
|
||||||
}
|
}
|
||||||
|
|
||||||
$tmp = $cat->getOpen();
|
$iter = $cat->getOpen();
|
||||||
$sz = sizeof($tmp);
|
while($iter->hasNext()) {
|
||||||
for($i=0;$i<$sz;$i++) {
|
$curr = $cat->findNodeIdx($iter->getNext());
|
||||||
|
#$sz = sizeof($tmp);
|
||||||
|
#for($i=0;$i<$sz;$i++) {
|
||||||
#echo "B";
|
#echo "B";
|
||||||
if($cat->getChild($tmp[$i])->inDev()) {
|
if($curr->inDev()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$html .= ach_render_achievement_open($cat->getChild($tmp[$i]));
|
$html .= ach_render_achievement_open($curr));
|
||||||
}
|
}
|
||||||
|
|
||||||
return $html;
|
return $html;
|
||||||
|
@ -251,8 +259,7 @@
|
||||||
$html = "";
|
$html = "";
|
||||||
|
|
||||||
$perk_list = $ach->getOpen();
|
$perk_list = $ach->getOpen();
|
||||||
|
$perk = $ach->findNodeIdx($perk_list->getNext());
|
||||||
$perk = $ach->getChild($perk_list[0]);
|
|
||||||
|
|
||||||
if($perk->inDev()) {
|
if($perk->inDev()) {
|
||||||
return $html;
|
return $html;
|
||||||
|
@ -273,9 +280,11 @@
|
||||||
$html = "";
|
$html = "";
|
||||||
|
|
||||||
$perk_list = $ach->getDone();
|
$perk_list = $ach->getDone();
|
||||||
|
while($perk_list->hasNext()) {
|
||||||
|
$perk = $this->findNodeIdx($perk_list->getNext());
|
||||||
|
|
||||||
foreach($perk_list as $elem) {
|
#foreach($perk_list as $elem) {
|
||||||
$perk = $ach->getChild($elem);
|
#$perk = $ach->getChild($elem);
|
||||||
if($perk->inDev()) {
|
if($perk->inDev()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -291,7 +300,9 @@
|
||||||
$i = 0;
|
$i = 0;
|
||||||
$skip = false;
|
$skip = false;
|
||||||
|
|
||||||
foreach($obj as $elem) {
|
while($obj->hasNext()) {
|
||||||
|
#foreach($obj as $elem) {
|
||||||
|
$elem = $obj->getNext();
|
||||||
if(($i%2) == 0) {
|
if(($i%2) == 0) {
|
||||||
$html .= "<tr>";
|
$html .= "<tr>";
|
||||||
}
|
}
|
||||||
|
|
|
@ -134,8 +134,6 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function ach_render_menu(&$menu,$sub = 0) {
|
function ach_render_menu(&$menu,$sub = 0) {
|
||||||
global $_CONF;
|
|
||||||
|
|
||||||
$html = "<style>
|
$html = "<style>
|
||||||
.ach_menu {
|
.ach_menu {
|
||||||
display:block;
|
display:block;
|
||||||
|
@ -153,9 +151,18 @@
|
||||||
}
|
}
|
||||||
</style>";
|
</style>";
|
||||||
|
|
||||||
$sz = $menu->getSize();
|
return $html.ach_render_mnode($menu,$sub);
|
||||||
for($i=0;$i<$sz;$i++) {
|
}
|
||||||
$curr = $menu->getChild($i);
|
|
||||||
|
function ach_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()) {
|
if($curr->inDev()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -172,7 +179,7 @@
|
||||||
</tr>
|
</tr>
|
||||||
</table></a></span>";
|
</table></a></span>";
|
||||||
if($curr->hasOpenCat() != 0) {
|
if($curr->hasOpenCat() != 0) {
|
||||||
$html .= "<div style='display:block;margin-left:25px;'>".ach_render_menu($curr,($sub+4))."</div>";
|
$html .= "<div style='display:block;margin-left:25px;'>".ach_render_mnode($curr,($sub+4))."</div>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -186,24 +193,28 @@
|
||||||
$html .= ach_render_tiebar($cat->getCurrentCult(),$cat->getCurrentCiv(),$cat);
|
$html .= ach_render_tiebar($cat->getCurrentCult(),$cat->getCurrentCiv(),$cat);
|
||||||
}
|
}
|
||||||
|
|
||||||
$tmp = $cat->getDone();
|
$iter = $cat->getDone();
|
||||||
$sz = sizeof($tmp);
|
while($iter->hasNext()) {
|
||||||
for($i=0;$i<$sz;$i++) {
|
$curr = $cat->findNodeIdx($iter->getNext());
|
||||||
|
#$sz = sizeof($tmp);
|
||||||
|
#for($i=0;$i<$sz;$i++) {
|
||||||
#echo "A";
|
#echo "A";
|
||||||
if($cat->getChild($tmp[$i])->inDev()) {
|
if($curr->inDev()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$html .= ach_render_achievement_done($cat->getChild($tmp[$i]));
|
$html .= ach_render_achievement_done($curr);
|
||||||
}
|
}
|
||||||
|
|
||||||
$tmp = $cat->getOpen();
|
$iter = $cat->getOpen();
|
||||||
$sz = sizeof($tmp);
|
while($iter->hasNext()) {
|
||||||
for($i=0;$i<$sz;$i++) {
|
$curr = $cat->findNodeIdx($iter->getNext());
|
||||||
|
#$sz = sizeof($tmp);
|
||||||
|
#for($i=0;$i<$sz;$i++) {
|
||||||
#echo "B";
|
#echo "B";
|
||||||
if($cat->getChild($tmp[$i])->inDev()) {
|
if($curr->inDev()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$html .= ach_render_achievement_open($cat->getChild($tmp[$i]));
|
$html .= ach_render_achievement_open($curr));
|
||||||
}
|
}
|
||||||
|
|
||||||
return $html;
|
return $html;
|
||||||
|
@ -284,8 +295,9 @@
|
||||||
$html = "";
|
$html = "";
|
||||||
|
|
||||||
$perk_list = $ach->getOpen();
|
$perk_list = $ach->getOpen();
|
||||||
|
$perk = $ach->findNodeIdx($perk_list->getNext());
|
||||||
|
|
||||||
$perk = $ach->getChild($perk_list[0]);
|
#$perk = $ach->getChild($perk_list[0]);
|
||||||
|
|
||||||
if($perk->inDev()) {
|
if($perk->inDev()) {
|
||||||
return $html;
|
return $html;
|
||||||
|
@ -295,7 +307,7 @@
|
||||||
$html .= "<span style='color:#999999;font-weight:bold;display:block;'>".$perk->getName()."</span>";
|
$html .= "<span style='color:#999999;font-weight:bold;display:block;'>".$perk->getName()."</span>";
|
||||||
}
|
}
|
||||||
if($perk->objDrawable()) {
|
if($perk->objDrawable()) {
|
||||||
$html .= ach_render_obj_list($perk->getChildren());
|
$html .= ach_render_obj_list($perk->getIterator());
|
||||||
}
|
}
|
||||||
|
|
||||||
return $html;
|
return $html;
|
||||||
|
@ -306,9 +318,10 @@
|
||||||
$html = "";
|
$html = "";
|
||||||
|
|
||||||
$perk_list = $ach->getDone();
|
$perk_list = $ach->getDone();
|
||||||
|
while($perk_list->hasNext()) {
|
||||||
foreach($perk_list as $elem) {
|
$perk = $this->findNodeIdx($perk_list->getNext());
|
||||||
$perk = $ach->getChild($elem);
|
#foreach($perk_list as $elem) {
|
||||||
|
#$perk = $ach->getChild($elem);
|
||||||
if($perk->inDev()) {
|
if($perk->inDev()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -324,7 +337,9 @@
|
||||||
$i = 0;
|
$i = 0;
|
||||||
$skip = false;
|
$skip = false;
|
||||||
|
|
||||||
foreach($obj as $elem) {
|
while($obj->hasNext()) {
|
||||||
|
#foreach($obj as $elem) {
|
||||||
|
$elem = $obj->getNext();
|
||||||
if(($i%2) == 0) {
|
if(($i%2) == 0) {
|
||||||
$html .= "<tr>";
|
$html .= "<tr>";
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,10 +34,10 @@ else {
|
||||||
require_once("include/ach_render_common.php");
|
require_once("include/ach_render_common.php");
|
||||||
|
|
||||||
require_once("class/Parentum_abstract.php");
|
require_once("class/Parentum_abstract.php");
|
||||||
require_once("class/RenderNodeIteraor_abstract.php");
|
|
||||||
require_once("class/AchList_abstract.php");
|
require_once("class/AchList_abstract.php");
|
||||||
require_once("class/Tieable_inter.php");
|
require_once("class/Tieable_inter.php");
|
||||||
|
require_once("class/NodeIterator_class.php");
|
||||||
|
require_once("class/Node_trait.php");
|
||||||
|
|
||||||
require_once("class/AchMenu_class.php");
|
require_once("class/AchMenu_class.php");
|
||||||
require_once("class/AchMenuNode_class.php");
|
require_once("class/AchMenuNode_class.php");
|
||||||
|
|
Loading…
Reference in a new issue