saimod objects, taggable

This commit is contained in:
Ulf Gebhardt 2014-12-22 05:15:32 +01:00
parent 3a0f96b7c1
commit e3a088754d
23 changed files with 247 additions and 37 deletions

View File

@ -7,6 +7,10 @@ class tags {
const TAG_TABLE_SPELLS = 5;
const TAG_TABLE_PLAYERS = 6;
const TAG_TABLE_TOPICS = 7;
public static function statistics($table,$type){
}
public static function get($table, $id, $type = null){
if($type){
return \DBD\TAGS_GET_TYPE::Q1(array($table, $id, $type));}

View File

@ -1,5 +1 @@
Player: ${name}(${guid})<br/>
Race: ${race}<br/>
Class: ${class}<br/>
Gender: ${gender}<br/>
Level: ${level}
Object ${name}(${guid})<br/>

View File

@ -8,8 +8,8 @@ class MAP_OBJECTS extends \SYSTEM\DB\QP {
'',
//mys
'SELECT guid as id,map,position_x as x,position_y as y,position_z as z,orientation as o, value as map_name FROM gameobject'.
' LEFT JOIN host_mojotrollz.mojotrollz_tags_value ON id = map'.
' WHERE type=1 AND map = ? AND entry=? LIMIT 100;',
' LEFT JOIN host_mojotrollz.mojotrollz_tags_value ON host_mojotrollz.mojotrollz_tags_value.id = map'.
' WHERE type=1 AND map = ? AND guid=? LIMIT 100;',
new \DBD\mangos_world()
);}}

View File

@ -1,15 +1,15 @@
<?php
namespace DBD;
class MAP_PLAYERS_MAPS extends \SYSTEM\DB\QP {
class MAP_OBJECTS_MAPS extends \SYSTEM\DB\QP {
protected static function query(){
return new \SYSTEM\DB\QQuery(get_class(),
//pg
'',
//mys
'SELECT map, value as map_name FROM gameobject'.
' LEFT JOIN host_mojotrollz.mojotrollz_tags_value ON id = map'.
' WHERE type=1 AND creature.id=? GROUP BY map;',
' LEFT JOIN host_mojotrollz.mojotrollz_tags_value ON host_mojotrollz.mojotrollz_tags_value.id = map'.
' WHERE type=1 AND gameobject.id=? GROUP BY map;',
new \DBD\mangos_world()
);}}

View File

@ -17,7 +17,7 @@
<div class="window_bg2" style="float: left; padding: 20px; width: 70%;" id="achievement_list">
<div style="float: left; width: 50%;">
<img width="400" src="http://www.mojotrollz.eu/web/mojotrollz/api.php?call=files&cat=default_start&id=help_gnome.png"/>
<img width="400" src="http://www.mojotrollz.eu/web/mojotrollz/api.php?call=files&cat=wizard_start&id=help_gnome.png"/>
</div>
<div style="float: left; width: 50%;">

View File

@ -3,13 +3,12 @@ SYSTEM\autoload::registerFolder(dirname(__FILE__).'','');
SYSTEM\autoload::registerFolder(dirname(__FILE__).'/saimod_mojotrollz_server_handling','');
\SYSTEM\SAI\sai::register('saimod_mojotrollz_server_handling');
require_once dirname(__FILE__).'/saimod_mojotrollz_db_creature/autoload.inc.php';
require_once dirname(__FILE__).'/saimod_mojotrollz_db_creature/autoload.inc';
SYSTEM\autoload::registerFolder(dirname(__FILE__).'/saimod_mojotrollz_db_item','');
\SYSTEM\SAI\sai::register('saimod_mojotrollz_db_item');
SYSTEM\autoload::registerFolder(dirname(__FILE__).'/saimod_mojotrollz_db_quest','');
\SYSTEM\SAI\sai::register('saimod_mojotrollz_db_quest');
SYSTEM\autoload::registerFolder(dirname(__FILE__).'/saimod_mojotrollz_db_object','');
\SYSTEM\SAI\sai::register('saimod_mojotrollz_db_object');
require_once dirname(__FILE__).'/saimod_mojotrollz_db_object/autoload.inc';
require_once dirname(__FILE__).'/saimod_mojotrollz_db_player/autoload.inc';
SYSTEM\autoload::registerFolder(dirname(__FILE__).'/saimod_mojotrollz_db_spell','');
\SYSTEM\SAI\sai::register('saimod_mojotrollz_db_spell');

View File

@ -28,7 +28,7 @@ class saimod_mojotrollz_db_creature extends \SYSTEM\SAI\SaiModule {
$vars = array();
$vars['entries'] = $vars['tag_entries'] = '';
$vars['map'] = map::generate(1,$id);
$vars['map'] = map::generate(tags::TAG_TABLE_CREATURE,$id);
$base_row = \DBD\DB_CREATURE_TEMPLATE_CREATURE::Q1(array($id));
foreach($base_row as $key=>$value){
@ -82,7 +82,6 @@ class saimod_mojotrollz_db_creature extends \SYSTEM\SAI\SaiModule {
$vars['entries'] = $vars['tag_entries'] = '';
$tags = json_decode($tags,true);
new INFO(print_r($tags,true));
if(!$tags){
$tags = array();}
@ -100,19 +99,14 @@ class saimod_mojotrollz_db_creature extends \SYSTEM\SAI\SaiModule {
$sql_join = $sql_where = '';
foreach($tags as $type=>$value){
new INFO($type.' '.$value);
if($value == -1){
continue;}
if($value == -2){
$sql_where .= 'entry NOT IN (SELECT id FROM host_mojotrollz.mojotrollz_tags WHERE `table` = '.tags::TAG_TABLE_CREATURE.' AND `type` = '.$type.') AND ';
continue;}
$sql_join .= 'LEFT JOIN host_mojotrollz.mojotrollz_tags as t'.$type.' ON creature_template.Entry = t'.$type.'.id ';
$sql_where .= 't'.$type.'.`table` = 1 AND t'.$type.'.`type` = '.$type.' AND t'.$type.'.value = '.$value.' AND ';
$sql_where .= 't'.$type.'.`table` = '.tags::TAG_TABLE_CREATURE.' AND t'.$type.'.`type` = '.$type.' AND t'.$type.'.value = '.$value.' AND ';
}
new INFO('SELECT creature_template.* FROM creature_template '.
$sql_join.
' WHERE '.$sql_where.
' (`Entry` LIKE ? OR `Name` LIKE ? OR `Subname` LIKE ?) LIMIT 100;');
$con = new \SYSTEM\DB\Connection(new \DBD\mangos_world());
$res = $con->prepare( 'search-creature',
'SELECT creature_template.* FROM creature_template '.

View File

@ -0,0 +1,4 @@
<?php
SYSTEM\autoload::registerFolder(dirname(__FILE__),'');
SYSTEM\autoload::registerFolder(dirname(__FILE__).'/qq','DBD');
\SYSTEM\SAI\sai::register('saimod_mojotrollz_db_object');

View File

@ -0,0 +1,9 @@
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (5500, 42, 0, 0, 'saimod_mojotrollz_db_object', 'action', NULL);
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (5510, 42, 3, 5500, 'search', 'search', 'STRING');
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (5511, 42, 3, 5500, 'search', 'tags', 'JSON');
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (5515, 42, 3, 5500, 'object', 'id', 'UINT');
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (5520, 42, 2, 5500, 'tag', 'id', 'UINT');
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (5521, 42, 2, 5500, 'tag', 'tags', 'JSON');

View File

@ -0,0 +1,39 @@
function init_saimod_mojotrollz_db_object(){
$('#search').click(function(e){
e.preventDefault();
var tags = {};
$('.tag_filter option:selected').each(function(){
var type = $(this).attr('_type');
tags[type] = $(this).val();});
$('#content-wrapper').load(SAI_ENDPOINT + 'sai_mod=saimod_mojotrollz_db_object&action=search&search=' + $('#filter').val()+'&tags='+ JSON.stringify(tags),function(){
init_saimod_mojotrollz_db_object();
});
});
$('.wow_object').click(function(){
load_object($(this).attr('_id'));
});
}
function load_object(id){
$('#content-wrapper').load(SAI_ENDPOINT + 'sai_mod=saimod_mojotrollz_db_object&action=object&id=' + id,function(){
$('#btn_edit').click(function(e){
e.preventDefault();
var tags = {};
$('.tag_filter option:selected').each(function(){
var type = $(this).attr('_type');
tags[type] = $(this).val();});
$.ajax({ type :'GET',
url : SAI_ENDPOINT+'sai_mod=saimod_mojotrollz_db_object&action=tag'+
'&id='+id+
'&tags='+JSON.stringify(tags),
success : function(data) {
if(data.status){
load_object(id);
}else{
alert('Problem: '+data);}
}
});
});
map(2,id);
});
}

View File

@ -0,0 +1,13 @@
<?php
namespace DBD;
class DB_OBJECT_TEMPLATE_OBJECT extends \SYSTEM\DB\QP {
protected static function query(){
return new \SYSTEM\DB\QQuery(get_class(),
//pg
'',
//mys
'SELECT * FROM gameobject_template WHERE `Entry` = ?;',
new \DBD\mangos_world()
);}}

View File

@ -1,23 +1,99 @@
<?php
class saimod_mojotrollz_db_object extends \SYSTEM\SAI\SaiModule {
public static function sai_mod_saimod_mojotrollz_db_object(){
$con = new \SYSTEM\DB\Connection(new \DBD\mangos_world());
$res = $con->query('SELECT * FROM gameobject_template LIMIT 100;');
$result = '<table><tr>
<th>entry</th>
</tr>';
while($row = $res->next()){
$result .= '<tr>
<td>'.$row['entry'].'</td>
</tr>';
public static function sai_mod_saimod_mojotrollz_db_object_action_search($search,$tags=null){
return self::sai_mod_saimod_mojotrollz_db_object($search,$tags);}
public static function sai_mod_saimod_mojotrollz_db_object_action_tag($id,$tags){
$tags = json_decode($tags,true);
foreach ($tags as $type=>$value){
if($value == -2){
tags::del(tags::TAG_TABLE_OBJECT, $id, $type);}
tags::set(tags::TAG_TABLE_OBJECT, $id, $type, $value);}
return JsonResult::ok();
}
public static function sai_mod_saimod_mojotrollz_db_object_action_object($id){
$vars = array();
$vars['entries'] = $vars['tag_entries'] = '';
$vars['map'] = map::generate(tags::TAG_TABLE_OBJECT,$id);
$base_row = \DBD\DB_OBJECT_TEMPLATE_OBJECT::Q1(array($id));
foreach($base_row as $key=>$value){
$vars['entries'] .= \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\SERVERPATH(new PSAI(),'saimod_mojotrollz_db_object/tpl/object_base.tpl'), array('key' => $key, 'value' => $value));}
//Object Tags
$tags_res = tags::get(tags::TAG_TABLE_OBJECT, $base_row['entry']);
$tags = array();
while($tag = $tags_res->next()){
$tags[$tag['type']] = $tag;}
//Tag Types
$tags_types = tags::get_type(tags::TAG_TABLE_OBJECT);
while($tag = $tags_types->next()){
$tag['options'] = '';
$tags_values = tags::get_value($tag['id']);
while($value = $tags_values->next()){
$value['selected'] = '';
if( array_key_exists($value['type'], $tags) &&
$tags[$value['type']]['value'] == $value['id']){
$value['selected'] = 'selected';}
$tag['options'] .= \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\SERVERPATH(new PSAI(),'saimod_mojotrollz_db_object/tpl/tag_entry_option.tpl'), $value);}
$vars['tag_entries'] .= \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\SERVERPATH(new PSAI(),'saimod_mojotrollz_db_object/tpl/tag_object_entry.tpl'), $tag);}
return \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\SERVERPATH(new PSAI(),'saimod_mojotrollz_db_object/tpl/object.tpl'), $vars);
}
public static function sai_mod_saimod_mojotrollz_db_object($search='%',$tags=null){
$vars = array();
$vars['search'] = $search;
$vars['entries'] = $vars['tag_entries'] = '';
$tags = json_decode($tags,true);
if(!$tags){
$tags = array();}
$tags_types = tags::get_type(tags::TAG_TABLE_OBJECT);
while($tag = $tags_types->next()){
$tag['options'] = '';
$tags_values = tags::get_value($tag['id']);
while($value = $tags_values->next()){
$value['selected'] = '';
if( array_key_exists($value['type'], $tags) &&
$tags[$value['type']] == $value['id']){
$value['selected'] = 'selected';}
$tag['options'] .= \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\SERVERPATH(new PSAI(),'saimod_mojotrollz_db_object/tpl/tag_entry_option.tpl'), $value);}
$vars['tag_entries'] .= \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\SERVERPATH(new PSAI(),'saimod_mojotrollz_db_object/tpl/tag_entry.tpl'), $tag);}
$sql_join = $sql_where = '';
foreach($tags as $type=>$value){
if($value == -1){
continue;}
if($value == -2){
$sql_where .= 'entry NOT IN (SELECT id FROM host_mojotrollz.mojotrollz_tags WHERE `table` = '.tags::TAG_TABLE_OBJECT.' AND `type` = '.$type.') AND ';
continue;}
$sql_join .= 'LEFT JOIN host_mojotrollz.mojotrollz_tags as t'.$type.' ON gameobject_template.entry = t'.$type.'.id ';
$sql_where .= 't'.$type.'.`table` = '.tags::TAG_TABLE_OBJECT.' AND t'.$type.'.`type` = '.$type.' AND t'.$type.'.value = '.$value.' AND ';
}
$result .= '</table>';
return $result;}
$con = new \SYSTEM\DB\Connection(new \DBD\mangos_world());
$res = $con->prepare( 'search-object',
'SELECT gameobject_template.* FROM gameobject_template '.
$sql_join.
' WHERE '.$sql_where.
' (`entry` LIKE ? OR `name` LIKE ?) LIMIT 100;',
array($search,$search));
while($row = $res->next()){
$vars['entries'] .= \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\SERVERPATH(new PSAI(),'saimod_mojotrollz_db_object/tpl/search_entry.tpl'), $row);}
return \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\SERVERPATH(new PSAI(),'saimod_mojotrollz_db_object/tpl/search.tpl'), $vars);
}
public static function html_li_menu(){return '<li><a href="#" saimenu="saimod_mojotrollz_db_object">DB:Objects</a></li><li class="divider"></li>';}
public static function right_public(){return false;}
public static function right_right(){return \SYSTEM\SECURITY\Security::check(\SYSTEM\SECURITY\RIGHTS::SYS_SAI);}
public static function sai_mod_saimod_mojotrollz_db_object_flag_js(){return \SYSTEM\LOG\JsonResult::toString(array());}
public static function sai_mod_saimod_mojotrollz_db_object_flag_css(){}
public static function sai_mod_saimod_mojotrollz_db_object_flag_js(){return \SYSTEM\LOG\JsonResult::toString(array(
\SYSTEM\WEBPATH(new PAPI(),'database/js/wow.js'),
\SYSTEM\WEBPATH(new PAPI(),'map/js/map.js'),
\SYSTEM\WEBPATH(new PSAI(),'saimod_mojotrollz_db_object/js/saimod_mojotrollz_db_object.js')));}
public static function sai_mod_saimod_mojotrollz_db_object_flag_css(){return \SYSTEM\LOG\JsonResult::toString(array(
\SYSTEM\WEBPATH(new PAPI(),'map/css/map.css')));}
}

View File

@ -0,0 +1,15 @@
<div style="float: left;">
${map}
</div>
<table class="sai_table" style="float: left; margin-left: 25px;">
<tr>
<th>TagType</th>
<th>TagTypeValue</th>
</tr>
${tag_entries}
</table>
<button class="btn btn-danger" type="button" id="btn_edit">Edit</button>
<div style="clear: both"></div>
<table class="sai_table">
${entries}
</table>

View File

@ -0,0 +1,4 @@
<tr>
<td>${key}</td>
<td>${value}</td>
</tr>

View File

@ -0,0 +1,24 @@
<div id="filter_container">
<input id="filter" value="${search}" type="text"/>
<table class="sai_table">
<tr>
<th>TagType</th>
<th>TagTypeValue</th>
</tr>
${tag_entries}
</table>
<button class="btn btn-primary" type="button" id="search">Search</button>
</div>
<hr/>
<table class="sai_table">
<tr>
<th>Entry</th>
<th>Name</th>
<th>Type</th>
<th>DisplayId</th>
<th>Faction</th>
<th>MinGold</th>
<th>MaxGold</th>
</tr>
${entries}
</table>

View File

@ -0,0 +1,9 @@
<tr class="wow_object" _id="${entry}">
<td>${entry}</td>
<td>${name}</td>
<td>${type}</td>
<td>${displayId}</td>
<td>${faction}</td>
<td>${mingold}</td>
<td>${maxgold}</td>
</tr>

View File

@ -0,0 +1,10 @@
<tr>
<td>${name}</td>
<td>
<select class="tag_filter">
<option value="-1" _type="${id}">No Filter</option>
<option value="-2" _type="${id}">No Tag</option>
${options}
</select>
</td>
</tr>

View File

@ -0,0 +1 @@
<option ${selected} _type="${type}" value="${id}">${value}</option>

View File

@ -0,0 +1,9 @@
<tr>
<td>${name}</td>
<td>
<select class="tag_filter">
<option value="-2" _type="${id}">No Tag</option>
${options}
</select>
</td>
</tr>

View File

@ -5,6 +5,7 @@ class saimod_mojotrollz_db_tags extends \SYSTEM\SAI\SaiModule {
$elements = '';
$res = \DBD\DB_TAGS_TYPE_LIST::QQ(array($table));
while($row = $res->next()){
$row['statistics'] = tags::statistics($table,$row['id']);
$elements .= \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\SERVERPATH(new PSAI(),'saimod_mojotrollz_db_tags/tpl/type_list_element.tpl'),$row);}
return \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\SERVERPATH(new PSAI(),'saimod_mojotrollz_db_tags/tpl/type_list.tpl'),array('table' => $table, 'elements' => $elements));}

View File

@ -5,6 +5,7 @@
<th>table</th>
<th>name</th>
<th>description</th>
<th>statistic</th>
<th>action</th>
</tr>
<tr>
@ -12,6 +13,7 @@
<td>${table}</td>
<td><input id="input_type_name" type="text"/></td>
<td><input id="input_type_description" type="text"/></td>
<td></td>
<td><button class="btn btn-danger" id="btn_type_add" _table="${table}">Add</button></td>
</tr>
${elements}

View File

@ -3,6 +3,7 @@
<td>${table}</td>
<td>${name}</td>
<td>${description}</td>
<td>${statistics}</td>
<td>
<button class="btn btn-success btn_type_edit" _id="${id}" _name="${name}" _description="${description}">Edit</button>
<button class="btn btn-danger btn_type_del" _id="${id}" _table="${table}">Del</button>