#1470 class files moved; some rendering improvements;
--HG-- branch : gsoc2012-achievementshg/feature/gsoc2013-dfighter
parent
c4962725a3
commit
29d1d9372f
Binary file not shown.
Binary file not shown.
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 22 KiB |
@ -0,0 +1,48 @@
|
|||||||
|
<?php
|
||||||
|
class AchCategory extends AchList {
|
||||||
|
private $id = false;
|
||||||
|
private $ties_cult;
|
||||||
|
private $ties_civ;
|
||||||
|
|
||||||
|
function AchCategory($id,$cult,$civ) {
|
||||||
|
global $DBc,$_USER;
|
||||||
|
|
||||||
|
$this->id = $id;
|
||||||
|
|
||||||
|
$res = $DBc->sqlQuery("SELECT * FROM ach_achievement LEFT JOIN (ach_achievement_lang) ON (aal_lang='".$_USER->getLang()."' AND aal_achievement=aa_id) WHERE aa_category='".$this->id."' AND aa_parent IS NULL AND (aa_tie_race IS NULL OR aa_tie_race='".$_USER->getParam('race')."') AND (aa_tie_cult IS NULL OR aa_tie_cult='".$cult."') AND (aa_tie_civ IS NULL OR aa_tie_civ='".$civ."') ORDER by aal_name ASC");
|
||||||
|
#MISSING: or parent is done
|
||||||
|
$sz = sizeof($res);
|
||||||
|
for($i=0;$i<$sz;$i++) {
|
||||||
|
#echo "Y";
|
||||||
|
$tmp = new AchAchievement($res[$i]);
|
||||||
|
#echo var_export($tmp,true);
|
||||||
|
if($tmp->hasOpen()) {
|
||||||
|
$this->child_open[] = sizeof($this->nodes);
|
||||||
|
}
|
||||||
|
if($tmp->hasDone()) {
|
||||||
|
$this->child_done[] = sizeof($this->nodes);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->nodes[] = $tmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
$res = $DBc->sqlQuery("SELECT count(*) FROM ach_achievement WHERE aa_tie_cult IS NOT NULL");
|
||||||
|
$this->ties_cult = $res[0]['anz'];
|
||||||
|
|
||||||
|
$res = $DBc->sqlQuery("SELECT count(*) FROM ach_achievement WHERE aa_tie_civ IS NOT NULL");
|
||||||
|
$this->ties_civ = $res[0]['anz'];
|
||||||
|
}
|
||||||
|
|
||||||
|
function getID() {
|
||||||
|
return $this->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
function isTiedCult() {
|
||||||
|
return ($this->ties_cult > 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
function isTiedCiv() {
|
||||||
|
return ($this->ties_civ > 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
@ -1,24 +1,4 @@
|
|||||||
<?php
|
<?php
|
||||||
abstract class RenderNodeIterator {
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
abstract class AchList extends RenderNodeIterator {
|
abstract class AchList extends RenderNodeIterator {
|
||||||
protected $child_done = array();
|
protected $child_done = array();
|
||||||
protected $child_open = array();
|
protected $child_open = array();
|
@ -0,0 +1,69 @@
|
|||||||
|
<?php
|
||||||
|
class AchSummary extends AchList {
|
||||||
|
private $menu;
|
||||||
|
private $stats;
|
||||||
|
|
||||||
|
function AchSummary(&$menu,$size = 10) {
|
||||||
|
global $DBc,$_USER;
|
||||||
|
|
||||||
|
$this->menu = $menu;
|
||||||
|
|
||||||
|
//read all recent perks of user
|
||||||
|
//make distinct achievement list
|
||||||
|
|
||||||
|
$res = $DBc->sqlQuery("SELECT DISTINCT aa_id,ach.*,(SELECT aal_name FROM ach_achievement_lang WHERE aal_lang='".$_USER->getLang()."' AND aal_achievement=ach.aa_id) as aal_name FROM ach_achievement as ach,ach_perk,ach_player_perk WHERE ap_achievement=aa_id AND app_player='".$_USER->getID()."' AND app_perk=ap_id ORDER by app_date DESC LIMIT 0,".($size-1));
|
||||||
|
|
||||||
|
$sz = sizeof($res);
|
||||||
|
for($i=0;$i<$sz;$i++) {
|
||||||
|
$tmp = new AchAchievement($res[$i]);
|
||||||
|
|
||||||
|
$this->child_done[] = sizeof($this->nodes);
|
||||||
|
$this->nodes[] = $tmp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function getSummary() {
|
||||||
|
if(!is_array($this->stats)) { // only load if needed
|
||||||
|
//now we have to find the # of perks for each main menu entry
|
||||||
|
//and also sum up how many have been completed
|
||||||
|
$this->stats = array(); // [][name,done,total]
|
||||||
|
|
||||||
|
$tmp = $this->menu->getChildren();
|
||||||
|
foreach($tmp as $elem) {
|
||||||
|
if($elem->getID() == 0) {
|
||||||
|
continue; // skip summary page
|
||||||
|
}
|
||||||
|
$res = $this->sumStats($elem);
|
||||||
|
$this->stats[] = array($elem->getName(),$res[0],$res[1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->stats;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function sumStats(&$node) {
|
||||||
|
global $DBc,$_USER;
|
||||||
|
|
||||||
|
$done = 0;
|
||||||
|
$total = 0;
|
||||||
|
|
||||||
|
//read for current ID
|
||||||
|
//sum
|
||||||
|
$res = $DBc->sqlQuery("SELECT count(ap_id) as anz FROM ach_perk,ach_achievement,ach_player_perk WHERE aa_category='".$node->getID()."' AND ap_achievement=aa_id AND app_player='".$_USER->getID()."' AND app_perk=ap_id");
|
||||||
|
$done += $res[0]["anz"];
|
||||||
|
|
||||||
|
$res = $DBc->sqlQuery("SELECT count(ap_id) as anz FROM ach_perk,ach_achievement WHERE aa_category='".$node->getID()."' AND ap_achievement=aa_id");
|
||||||
|
$total += $res[0]["anz"];
|
||||||
|
|
||||||
|
$tmp = $node->getChildren();
|
||||||
|
foreach($tmp as $elem) {
|
||||||
|
$res = $this->sumStats($elem);
|
||||||
|
$done += $res[0];
|
||||||
|
$total += $res[1];
|
||||||
|
}
|
||||||
|
|
||||||
|
return array($done,$total);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
@ -0,0 +1,21 @@
|
|||||||
|
<?php
|
||||||
|
abstract class RenderNodeIterator {
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
class RyzomUser {
|
||||||
|
private $data;
|
||||||
|
|
||||||
|
function RyzomUser($data) {
|
||||||
|
$this->data = $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getID() {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getLang() {
|
||||||
|
return $this->data['lang'];
|
||||||
|
}
|
||||||
|
|
||||||
|
function isIG() {
|
||||||
|
return $this->data['ig'];
|
||||||
|
}
|
||||||
|
|
||||||
|
function getParam($p) {
|
||||||
|
return $this->data[$p];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
@ -1,32 +0,0 @@
|
|||||||
<?php
|
|
||||||
class AchCategory extends AchList {
|
|
||||||
private $id = false;
|
|
||||||
|
|
||||||
function AchCategory($id,$user = 0,$lang = 'en') {
|
|
||||||
global $db;
|
|
||||||
|
|
||||||
$this->id = $id;
|
|
||||||
|
|
||||||
$res = $db->sqlQuery("SELECT * FROM ach_achievement LEFT JOIN (ach_achievement_lang) ON (aal_lang='".$lang."' AND aal_achievement=aa_id) WHERE aa_category='".$this->id."' AND aa_parent IS NULL ORDER by aal_name ASC");
|
|
||||||
#MISSING: or parent is done
|
|
||||||
$sz = sizeof($res);
|
|
||||||
for($i=0;$i<$sz;$i++) {
|
|
||||||
#echo "Y";
|
|
||||||
$tmp = new AchAchievement($res[$i],$lang,$user);
|
|
||||||
#echo var_export($tmp,true);
|
|
||||||
if($tmp->hasOpen()) {
|
|
||||||
$this->child_open[] = sizeof($this->nodes);
|
|
||||||
}
|
|
||||||
if($tmp->hasDone()) {
|
|
||||||
$this->child_done[] = sizeof($this->nodes);
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->nodes[] = $tmp;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function getID() {
|
|
||||||
return $this->id;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
?>
|
|
@ -1,69 +0,0 @@
|
|||||||
<?php
|
|
||||||
class AchSummary extends AchList {
|
|
||||||
private $menu;
|
|
||||||
private $stats;
|
|
||||||
|
|
||||||
function AchSummary(&$menu,$user,$size = 10,$lang = 'en') {
|
|
||||||
global $db;
|
|
||||||
|
|
||||||
$this->menu = $menu;
|
|
||||||
|
|
||||||
//read all recent perks of user
|
|
||||||
//make distinct achievement list
|
|
||||||
|
|
||||||
$res = $db->sqlQuery("SELECT DISTINCT aa_id,ach.*,(SELECT aal_name FROM ach_achievement_lang WHERE aal_lang='".$lang."' AND aal_achievement=ach.aa_id) as aal_name FROM ach_achievement as ach,ach_perk,ach_player_perk WHERE ap_achievement=aa_id AND app_player='".$user."' AND app_perk=ap_id ORDER by app_date DESC LIMIT 0,".($size-1));
|
|
||||||
|
|
||||||
$sz = sizeof($res);
|
|
||||||
for($i=0;$i<$sz;$i++) {
|
|
||||||
$tmp = new AchAchievement($res[$i],$lang,$user);
|
|
||||||
|
|
||||||
$this->child_done[] = sizeof($this->nodes);
|
|
||||||
$this->nodes[] = $tmp;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function getSummary($lang,$user) {
|
|
||||||
if(!is_array($this->stats)) { // only load if needed
|
|
||||||
//now we have to find the # of perks for each main menu entry
|
|
||||||
//and also sum up how many have been completed
|
|
||||||
$this->stats = array(); // [][name,done,total]
|
|
||||||
|
|
||||||
$tmp = $this->menu->getChildren();
|
|
||||||
foreach($tmp as $elem) {
|
|
||||||
if($elem->getID() == 0) {
|
|
||||||
continue; // skip summary page
|
|
||||||
}
|
|
||||||
$res = $this->sumStats($elem,$user);
|
|
||||||
$this->stats[] = array($elem->getName(),$res[0],$res[1]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->stats;
|
|
||||||
}
|
|
||||||
|
|
||||||
private function sumStats(&$node,$user) {
|
|
||||||
global $db;
|
|
||||||
|
|
||||||
$done = 0;
|
|
||||||
$total = 0;
|
|
||||||
|
|
||||||
//read for current ID
|
|
||||||
//sum
|
|
||||||
$res = $db->sqlQuery("SELECT count(ap_id) as anz FROM ach_perk,ach_achievement,ach_player_perk WHERE aa_category='".$node->getID()."' AND ap_achievement=aa_id AND app_player='".$user."' AND app_perk=ap_id");
|
|
||||||
$done += $res[0]["anz"];
|
|
||||||
|
|
||||||
$res = $db->sqlQuery("SELECT count(ap_id) as anz FROM ach_perk,ach_achievement WHERE aa_category='".$node->getID()."' AND ap_achievement=aa_id");
|
|
||||||
$total += $res[0]["anz"];
|
|
||||||
|
|
||||||
$tmp = $node->getChildren();
|
|
||||||
foreach($tmp as $elem) {
|
|
||||||
$res = $this->sumStats($elem,$user);
|
|
||||||
$done += $res[0];
|
|
||||||
$total += $res[1];
|
|
||||||
}
|
|
||||||
|
|
||||||
return array($done,$total);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
?>
|
|
Loading…
Reference in New Issue