#1470 bugfix in webig renderer (bgcolor); ER scheme/SQL update; untested wip of achievement app

This commit is contained in:
SirCotare 2012-05-25 11:48:56 +02:00
parent d894feff2f
commit 675995b325
14 changed files with 457 additions and 78 deletions

View file

@ -47,7 +47,7 @@ function ryzom_app_render($title, $content, $ig=false, $bgcolor='', $javascript=
$c .= ryzom_render_www(ryzom_render_window($title, $content, $homeLink)); $c .= ryzom_render_www(ryzom_render_window($title, $content, $homeLink));
$c .= '</body></html>'; $c .= '</body></html>';
} else { } else {
$c .= '<html><body>'; $c .= '<html><body bgcolor="'.$bgcolor.'">';
$c .= $content; $c .= $content;
$debug = ryLogger::getInstance()->getLogs(); $debug = ryLogger::getInstance()->getLogs();
if ($debug) if ($debug)

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 176 KiB

After

Width:  |  Height:  |  Size: 181 KiB

View file

@ -3,7 +3,7 @@
-- http://www.phpmyadmin.net -- http://www.phpmyadmin.net
-- --
-- Host: localhost -- Host: localhost
-- Erstellungszeit: 17. Mai 2012 um 01:47 -- Erstellungszeit: 25. Mai 2012 um 11:46
-- Server Version: 5.1.46 -- Server Version: 5.1.46
-- PHP-Version: 5.3.2 -- PHP-Version: 5.3.2
@ -36,11 +36,6 @@ CREATE TABLE IF NOT EXISTS `ach_achievement` (
PRIMARY KEY (`aa_id`) PRIMARY KEY (`aa_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin AUTO_INCREMENT=1 ; ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin AUTO_INCREMENT=1 ;
--
-- Daten für Tabelle `ach_achievement`
--
-- -------------------------------------------------------- -- --------------------------------------------------------
-- --
@ -54,11 +49,6 @@ CREATE TABLE IF NOT EXISTS `ach_achievement_lang` (
PRIMARY KEY (`aal_achievement`,`aal_lang`) PRIMARY KEY (`aal_achievement`,`aal_lang`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin; ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
--
-- Daten für Tabelle `ach_achievement_lang`
--
-- -------------------------------------------------------- -- --------------------------------------------------------
-- --
@ -70,14 +60,10 @@ CREATE TABLE IF NOT EXISTS `ach_atom` (
`atom_objective` bigint(20) unsigned NOT NULL, `atom_objective` bigint(20) unsigned NOT NULL,
`atom_mandatory` tinyint(1) unsigned NOT NULL, `atom_mandatory` tinyint(1) unsigned NOT NULL,
`atom_ruleset` blob NOT NULL, `atom_ruleset` blob NOT NULL,
`atom_primary` tinyint(1) unsigned NOT NULL,
PRIMARY KEY (`atom_id`) PRIMARY KEY (`atom_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin AUTO_INCREMENT=1 ; ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin AUTO_INCREMENT=1 ;
--
-- Daten für Tabelle `ach_atom`
--
-- -------------------------------------------------------- -- --------------------------------------------------------
-- --
@ -88,12 +74,7 @@ CREATE TABLE IF NOT EXISTS `ach_category` (
`ac_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, `ac_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`ac_parent` bigint(20) unsigned DEFAULT NULL, `ac_parent` bigint(20) unsigned DEFAULT NULL,
PRIMARY KEY (`ac_id`) PRIMARY KEY (`ac_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin AUTO_INCREMENT=1 ; ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin AUTO_INCREMENT=3 ;
--
-- Daten für Tabelle `ach_category`
--
-- -------------------------------------------------------- -- --------------------------------------------------------
@ -108,11 +89,6 @@ CREATE TABLE IF NOT EXISTS `ach_category_lang` (
PRIMARY KEY (`acl_category`,`acl_lang`) PRIMARY KEY (`acl_category`,`acl_lang`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin; ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
--
-- Daten für Tabelle `ach_category_lang`
--
-- -------------------------------------------------------- -- --------------------------------------------------------
-- --
@ -124,14 +100,10 @@ CREATE TABLE IF NOT EXISTS `ach_objective` (
`ao_perk` bigint(20) unsigned NOT NULL, `ao_perk` bigint(20) unsigned NOT NULL,
`ao_condition` enum('all','any','value') COLLATE utf8_bin NOT NULL, `ao_condition` enum('all','any','value') COLLATE utf8_bin NOT NULL,
`ao_value` int(10) unsigned DEFAULT NULL, `ao_value` int(10) unsigned DEFAULT NULL,
`ao_display` enum('simple','meta','value') COLLATE utf8_bin NOT NULL DEFAULT 'simple',
PRIMARY KEY (`ao_id`) PRIMARY KEY (`ao_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin AUTO_INCREMENT=1 ; ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin AUTO_INCREMENT=1 ;
--
-- Daten für Tabelle `ach_objective`
--
-- -------------------------------------------------------- -- --------------------------------------------------------
-- --
@ -145,11 +117,6 @@ CREATE TABLE IF NOT EXISTS `ach_objective_lang` (
PRIMARY KEY (`aol_objective`,`aol_lang`) PRIMARY KEY (`aol_objective`,`aol_lang`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin; ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
--
-- Daten für Tabelle `ach_objective_lang`
--
-- -------------------------------------------------------- -- --------------------------------------------------------
-- --
@ -165,11 +132,6 @@ CREATE TABLE IF NOT EXISTS `ach_perk` (
UNIQUE KEY `ap_parent` (`ap_parent`) UNIQUE KEY `ap_parent` (`ap_parent`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin AUTO_INCREMENT=1 ; ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin AUTO_INCREMENT=1 ;
--
-- Daten für Tabelle `ach_perk`
--
-- -------------------------------------------------------- -- --------------------------------------------------------
-- --
@ -183,11 +145,6 @@ CREATE TABLE IF NOT EXISTS `ach_perk_lang` (
PRIMARY KEY (`apl_perk`,`apl_lang`) PRIMARY KEY (`apl_perk`,`apl_lang`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin; ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
--
-- Daten für Tabelle `ach_perk_lang`
--
-- -------------------------------------------------------- -- --------------------------------------------------------
-- --
@ -202,11 +159,6 @@ CREATE TABLE IF NOT EXISTS `ach_player_atom` (
PRIMARY KEY (`apa_atom`,`apa_player`) PRIMARY KEY (`apa_atom`,`apa_player`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin; ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
--
-- Daten für Tabelle `ach_player_atom`
--
-- -------------------------------------------------------- -- --------------------------------------------------------
-- --
@ -220,11 +172,6 @@ CREATE TABLE IF NOT EXISTS `ach_player_objective` (
PRIMARY KEY (`apo_objective`,`apo_player`) PRIMARY KEY (`apo_objective`,`apo_player`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin; ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
--
-- Daten für Tabelle `ach_player_objective`
--
-- -------------------------------------------------------- -- --------------------------------------------------------
-- --
@ -238,11 +185,6 @@ CREATE TABLE IF NOT EXISTS `ach_player_perk` (
PRIMARY KEY (`app_perk`,`app_player`) PRIMARY KEY (`app_perk`,`app_player`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin; ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
--
-- Daten für Tabelle `ach_player_perk`
--
-- -------------------------------------------------------- -- --------------------------------------------------------
-- --
@ -256,8 +198,3 @@ CREATE TABLE IF NOT EXISTS `ach_player_valuecache` (
`apv_date` bigint(20) unsigned NOT NULL, `apv_date` bigint(20) unsigned NOT NULL,
PRIMARY KEY (`apv_name`,`apv_player`) PRIMARY KEY (`apv_name`,`apv_player`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin; ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
--
-- Daten für Tabelle `ach_player_valuecache`
--

View file

@ -0,0 +1,13 @@
<?php
if(!defined('APP_NAME')) {
die(-1);
}
$achConf = array();
$achConf['summary_size'] = 12;
$achConf['default_lang'] = 'en';
$achConf['enable_webig'] = true;
$achConf['enable_offgame'] = true;
$achConf['use_cache'] = false;
?>

View file

@ -0,0 +1,78 @@
<?php
class AchAchievement extends AchList {
private $id;
private $parent;
private $category;
private $tie_race;
private $tie_civ;
private $tie_cult;
private $image;
private $name;
function AchAchievement(&$data,$lang) {
global $db;
$this->id = $data['aa_id'];
$this->parent = $data['aa_parent'];
$this->category = $data['aa_category'];
$this->tie_race = $data['aa_tie_race'];
$this->tie_civ = $data['aa_tie_civ'];
$this->tie_cult = $data['aa_tie_cult'];
$this->image = $data['aa_image'];
$this->name = $data['aal_name'];
$res = $db->sqlQuery("SELECT * FROM ach_perk LEFT JOIN (ach_perk_lang) ON (apl_lang='".$lang."' AND apl_achievement=ap_id) WHERE ap_achievement='".$this->id."' AND ap_parent IS NULL");
#MISSING: or parent is done
$sz = sizeof($res);
for($i=0;$i<$sz;$i++) {
$tmp = new AchPerk($res[$i],$lang);
$this->child_open[] = sizeof($this->nodes);
$this->nodes[] = $tmp;
/*if($res[$i]['']) {
}
else {
}*/
#MISSING: divide into groups -> open/done
}
}
function getID() {
return $this->id;
}
function getParent() {
return $this->parent;
}
function getTieRace() {
return $this->tie_race;
}
function getTieCiv() {
return $this->tie_civ;
}
function getTieCult() {
return $this->tie_cult;
}
function getImage() {
return $this->image;
}
function getName() {
return $this->name;
}
function getValue() {
$val = 0;
foreach($this->child_done as $elem) {
$val += $this->nodes[$elem]->getValue();
}
return $val;
}
}
?>

View file

@ -0,0 +1,30 @@
<?php
class AchCategory extends AchList {
private $id = false;
function AchCategory($id,$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");
#MISSING: or parent is done
$sz = sizeof($res);
for($i=0;$i<$sz;$i++) {
$tmp = new AchAchievement($res[$i],$lang);
if($tmp->hasOpen()) {
$this->child_open[] = sizeof($this->nodes);
}
if($tmp->hasDone()) {
$this->child_done[] = sizeof($this->nodes);
}
$this->nodes[] = $tmp;
}
}
function getID() {
return $this->id;
}
}
?>

View file

@ -0,0 +1,42 @@
<?php
abstract class RenderNodeIterator {
private $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 {
private $child_done = array();
private $child_open = array();
function getDone() {
return $this->child_done;
}
function getOpen() {
return $this->child_open;
}
function hasOpen() {
return (sizeof($this->child_open) != 0);
}
function hasDone() {
return (sizeof($this->child_done) != 0);
}
}
?>

View file

@ -0,0 +1,54 @@
<?php
class AchMenu extends RenderNodeIterator {
function AchMenu($open = false,$lang = 'en') {
global $db;
$res = $db->sqlQuery("SELECT * FROM ach_category LEFT JOIN (ach_category_lang) ON (acl_lang='".$lang."' AND acl_category=ac_id) WHERE ac_parent IS NULL");
#MISSING: ORDER by
$sz = sizeof($res);
for($i=0;$i<$sz;$i++) {
$this->nodes[] = new AchMenuNode($res[$i],$open,$lang);
}
}
}
class AchMenuNode extends RenderNodeIterator {
private $id = false;
private $parent = false;
private $name = null;
private $open = false;
function AchMenuNode(&$data,$open,$lang) {
global $db;
$this->id = $data['ac_id'];
$this->parent = $data['ac_parent'];
$this->name = $data['acl_name'];
$this->open = ($open==$data['ac_id']);
$res = $db->sqlQuery("SELECT * FROM ach_category LEFT JOIN (ach_category_lang) ON (acl_lang='".$lang."' AND acl_category=ac_id) WHERE ac_parent='".$this->id."'");
#MISSING: ORDER by
$sz = sizeof($res);
for($i=0;$i<$sz;$i++) {
$this->nodes[] = new AchMenuNode($res[$i],$open,$lang);
}
}
function getID() {
return $this->id;
}
function getName() {
return $this->name;
}
function getParent() {
return $this->parent;
}
function isOpen() {
return $this->open;
}
}
?>

View file

@ -0,0 +1,43 @@
<?php
class AchObjective {
private $id;
private $perk;
private $condition;
private $value;
private $name;
private $display;
function AchObjective(&$data,$lang) {
$this->id = $data['ao_id'];
$this->perk = $data['ao_perk'];
$this->condition = $data['ao_condition'];
$this->value = $data['ao_value'];
$this->name = $data['aol_name'];
$this->display = $data['ao_display'];
}
function getID() {
return $this->id;
}
function getPerk() {
return $this->perk;
}
function getCondition() {
return $this->condition;
}
function getValue() {
return $this->value;
}
function getName() {
return $this->name;
}
function getDisplay() {
return $this->display;
}
}
?>

View file

@ -0,0 +1,45 @@
<?php
class AchPerk extends RenderNodeIterator {
private $id;
private $parent;
private $achievement;
private $value;
private $name;
function AchPerk(&$data,$lang) {
global $db;
$this->id = $data['ap_id'];
$this->parent = $data['ap_parent'];
$this->achievement = $data['ap_achievement'];
$this->value = $data['ap_value'];
$this->name = $data['apl_name'];
$res = $db->sqlQuery("SELECT * FROM ach_objective LEFT JOIN (ach_objective_lang) ON (aol_lang='".$lang."' AND aol_objective=ao_id) WHERE ao_perk='".$this->id."'");
$sz = sizeof($res);
for($i=0;$i<$sz;$i++) {
$this->nodes[] = new AchObjective($res[$i],$lang);
}
}
function getID() {
return $this->id;
}
function getParent() {
return $this->parent;
}
function getAchievement() {
return $this->achievement;
}
function getValue() {
return $this->value;
}
function getName() {
return $this->name;
}
}
?>

View file

@ -0,0 +1,20 @@
<?php
class AchSummary extends AchList {
function AchSummary($size = 10,$lang = 'en') {
global $db;
$res = $db->sqlQuery("SELECT * FROM ach_achievement LEFT JOIN (ach_achievement_lang) ON (aal_lang='".$lang."' AND aal_achievement=aa_id) WHERE aa_category='".$this->id."' AND aa_parent IS NULL");
#MISSING: or parent is done
#MISSING: player's status on achievement
$sz = sizeof($res);
for($i=0;$i<$sz;$i++) {
$tmp = new AchAchievement($res[$i],$lang);
if($tmp->hasDone()) {
$this->child_done[] = sizeof($this->nodes);
$this->nodes[] = $tmp;
}
}
}
}
?>

View file

@ -90,4 +90,98 @@
function ach_render_tiebar($cult = "neutral", $civ = "neutral") { function ach_render_tiebar($cult = "neutral", $civ = "neutral") {
} }
function ach_render_menu(&$menu) {
$html = "";
$sz = $menu->getSize();
for($i=0;$i<$sz;$i++) {
$curr = $menu->getChild($i);
$html .= "<a href='' style='display:block;'></a><div style='display:block;margin-left:50px;'>".ach_render_menu($curr)."</div>";
}
return $html;
}
function ach_render_category(&$cat) {
$html = "";
$tmp = $cat->getDone();
$sz = sizeof($tmp);
for($i=0;$i<$sz;$i++) {
$html .= ach_render_achievement_done($cat->getChild($tmp[$i]));
}
$tmp = $cat->getDone();
$sz = sizeof($tmp);
for($i=0;$i<$sz;$i++) {
$html .= ach_render_achievement_open($cat->getChild($tmp[$i]));
}
return $html;
}
function ach_render_achievement_done(&$ach) {
}
function ach_render_achievement_open(&$ach) {
$html = "";
$html .= '<div style="display: block; margin-bottom: 5px;"><table cellpadding="0" cellspacing="0" width="100%">
<tbody><tr>
<td width="3px"><img src="pic/bar_pending_ul.png"></td>
<td style="background-image: url(pic/bar_pending_u.png);"></td>
<td width="3px"><img src="pic/bar_pending_ur.png"></td>
</tr>
<tr>
<td style="background-image: url(pic/bar_pending_l.png);"></td>
<td>
<center><table>
<tbody><tr>
<td rowspan="2"><img src="pic/icon/13.png"></td>
<td height="35px" width="430px"><center><h2 style="margin: 0px;color:#FFFFFF;">'.$ach->getName().'</h2></center></td>
<td rowspan="2" style="font-weight: bold; text-align: center; font-size: 14px;color:#FFFFFF;">
'.$ach->getValue().'<br><img src="pic/yubo_done.png">
</td>
</tr>';
$html .= ach_render_perk_open($ach->getOpen());
$html .= '</tbody></table></center>
</td>
<td style="background-image: url(pic/bar_pending_r.png);"></td>
</tr>
<tr>
<td><img src="pic/bar_pending_bl.png"></td>
<td style="background-image: url(pic/bar_pending_b.png);"></td>
<td><img src="pic/bar_pending_br.png"></td>
</tr>
</tbody></table></div>';
return $html;
}
function ach_render_perk_open(&$perk_list) {
$html = "";
$perk = $perk_list[0];
$html .= $perk->getName()."<br>";
$html .= ach_render_obj_list($perk->getChildren());
return $html;
}
function ach_render_perk_done() {
}
function ach_render_obj_list(&$obj) {
$html = "";
foreach($obj as $elem) {
$html .= "-".$elem->getName()."<br>";
}
return $html;
}
?> ?>

View file

@ -2,25 +2,31 @@
define('APP_NAME', 'app_achievements'); define('APP_NAME', 'app_achievements');
include_once('../config.php'); require_once('../webig/config.php');
include_once('../lang.php'); include_once('../webig/lang.php');
include_once('lang.php'); include_once('lang.php');
require_once('conf.php');
// Ask to authenticate user (using ingame or session method) and fill $user with all information // Ask to authenticate user (using ingame or session method) and fill $user with all information
ryzom_app_authenticate($user, true); ryzom_app_authenticate($user, true);
if($user['ig']) { if($user['ig']) {
include_once("include/ach_render_ig.php"); require_once("include/ach_render_ig.php");
} }
else { else {
include_once("include/ach_render_web.php"); require_once("include/ach_render_web.php");
} }
include_once("include/ach_render_common.php"); require_once("include/ach_render_common.php");
require_once("include/AchMenu_class.php");
require_once("include/AchSummary_class.php");
require_once("include/AchCategory_class.php");
require_once("include/AchCommon_class.php");
// Update user acces on Db // Update user acces on Db
/*$db = ryDB::getInstance(APP_NAME); $db = ryDB::getInstance(APP_NAME);
$db->setDbDefs('test', array('id' => SQL_DEF_INT, 'num_access' => SQL_DEF_INT)); /*$db->setDbDefs('test', array('id' => SQL_DEF_INT, 'num_access' => SQL_DEF_INT));
$num_access = $db->querySingleAssoc('test', array('id' => $user['id'])); $num_access = $db->querySingleAssoc('test', array('id' => $user['id']));
if ($num_access) if ($num_access)
@ -31,14 +37,31 @@ else
// Content // Content
$c = _t('access', $num_access['num_access']).'<br/>';*/ $c = _t('access', $num_access['num_access']).'<br/>';*/
$c = "<center><table> $c = var_export($user,true);
$c .= "<center><table>
<tr> <tr>
<td valign='top'>awesome menu</td> <td valign='top'>";
$menu = new AchMenu($_REQUEST['mid'],$user['lang']);
$c .= ach_render_menu($menu);
$c .= "</td>
<td width='645px'>"; <td width='645px'>";
for($i=0;$i<15;$i++) { /*for($i=0;$i<15;$i++) {
$c .= ach_render_box_done("Bejeweled"); $c .= ach_render_box_done("Bejeweled");
}*/
if($menu->isSelected()) {
$cat = new AchCategory($menu->getCat(),$user['lang']);
} }
else {
$cat = new AchSummary(12,$user['lang']);
}
$c .= ach_render_category($cat);
$c .= "</td> $c .= "</td>
</tr> </tr>