saimod item

This commit is contained in:
Ulf Gebhardt 2014-12-22 05:38:54 +01:00
parent e3a088754d
commit 2104e10e3e
13 changed files with 222 additions and 258 deletions

View File

@ -4,8 +4,7 @@ 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';
SYSTEM\autoload::registerFolder(dirname(__FILE__).'/saimod_mojotrollz_db_item','');
\SYSTEM\SAI\sai::register('saimod_mojotrollz_db_item');
require_once dirname(__FILE__).'/saimod_mojotrollz_db_item/autoload.inc';
SYSTEM\autoload::registerFolder(dirname(__FILE__).'/saimod_mojotrollz_db_quest','');
\SYSTEM\SAI\sai::register('saimod_mojotrollz_db_quest');
require_once dirname(__FILE__).'/saimod_mojotrollz_db_object/autoload.inc';

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_item');

View File

@ -0,0 +1,9 @@
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (5600, 42, 0, 0, 'saimod_mojotrollz_db_item', 'action', NULL);
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (5610, 42, 3, 5600, 'search', 'search', 'STRING');
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (5611, 42, 3, 5600, 'search', 'tags', 'JSON');
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (5615, 42, 3, 5600, 'item', 'id', 'UINT');
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (5620, 42, 2, 5600, 'tag', 'id', 'UINT');
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (5621, 42, 2, 5600, 'tag', 'tags', 'JSON');

View File

@ -0,0 +1,38 @@
function init_saimod_mojotrollz_db_item(){
$('#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_item&action=search&search=' + $('#filter').val()+'&tags='+ JSON.stringify(tags),function(){
init_saimod_mojotrollz_db_item();
});
});
$('.wow_item').click(function(){
load_item($(this).attr('_id'));
});
}
function load_item(id){
$('#content-wrapper').load(SAI_ENDPOINT + 'sai_mod=saimod_mojotrollz_db_item&action=item&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_item&action=tag'+
'&id='+id+
'&tags='+JSON.stringify(tags),
success : function(data) {
if(data.status){
load_item(id);
}else{
alert('Problem: '+data);}
}
});
});
});
}

View File

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

View File

@ -1,263 +1,97 @@
<?php
class saimod_mojotrollz_db_item extends \SYSTEM\SAI\SaiModule {
public static function sai_mod_saimod_mojotrollz_db_item(){
$con = new \SYSTEM\DB\Connection(new \DBD\mangos_world());
$res = $con->query('SELECT * FROM item_template LIMIT 100;');
$result = '<table><tr>
<th>class</th>
<th>subclass</th>
<th>name</th>
<th>displayid</th>
<th>Quality</th>
<th>entry</th>
<th>Flags</th>
<th>BuyCount</th>
<th>BuyPrice</th>
<th>SellPrice</th>
<th>InventoryType</th>
<th>AllowableClass</th>
<th>AllowableRace</th>
<th>ItemLevel</th>
<th>RequiredLevel</th>
<th>RequiredSkill</th>
<th>RequiredSkillRank</th>
<th>requiredspell</th>
<th>requiredhonorrank</th>
<th>RequiredCityRank</th>
<th>RequiredReputationFaction</th>
<th>RequiredReputationRank</th>
<th>maxcount</th>
<th>stackable</th>
<th>ContainerSlots</th>
<th>stat_type1</th>
<th>stat_value1</th>
<th>stat_type2</th>
<th>stat_value2</th>
<th>stat_type3</th>
<th>stat_value3</th>
<th>stat_type4</th>
<th>stat_value4</th>
<th>stat_type5</th>
<th>stat_value5</th>
<th>stat_type6</th>
<th>stat_value6</th>
<th>stat_type7</th>
<th>stat_value7</th>
<th>stat_type8</th>
<th>stat_value8</th>
<th>stat_type9</th>
<th>stat_value9</th>
<th>stat_type10</th>
<th>stat_value10</th>
<th>dmg_min1</th>
<th>dmg_max1</th>
<th>dmg_type1</th>
<th>dmg_min2</th>
<th>dmg_max2</th>
<th>dmg_type2</th>
<th>dmg_min3</th>
<th>dmg_max3</th>
<th>dmg_type3</th>
<th>dmg_min4</th>
<th>dmg_max4</th>
<th>dmg_type4</th>
<th>dmg_min5</th>
<th>dmg_max5</th>
<th>dmg_type5</th>
<th>armor</th>
<th>holy_res</th>
<th>fire_res</th>
<th>nature_res</th>
<th>frost_res</th>
<th>shadow_res</th>
<th>arcane_res</th>
<th>delay</th>
<th>ammo_type</th>
<th>RangedModRange</th>
<th>spellid_1</th>
<th>spelltrigger_1</th>
<th>spellcharges_1</th>
<th>spellppmRate_1</th>
<th>spellcooldown_1</th>
<th>spellcategory_1</th>
<th>spellcategorycooldown_1</th>
<th>spellid_2</th>
<th>spelltrigger_2</th>
<th>spellcharges_2</th>
<th>spellppmRate_2</th>
<th>spellcooldown_2</th>
<th>spellcategory_2</th>
<th>spellcategorycooldown_2</th>
<th>spellid_3</th>
<th>spelltrigger_3</th>
<th>spellcharges_3</th>
<th>spellppmRate_3</th>
<th>spellcooldown_3</th>
<th>spellcategory_3</th>
<th>spellcategorycooldown_3</th>
<th>spellid_4</th>
<th>spelltrigger_4</th>
<th>spellcharges_4</th>
<th>spellppmRate_4</th>
<th>spellcooldown_4</th>
<th>spellcategory_4</th>
<th>spellcategorycooldown_4</th>
<th>spellid_5</th>
<th>spelltrigger_5</th>
<th>spellcharges_5</th>
<th>spellppmRate_5</th>
<th>spellcooldown_5</th>
<th>spellcategory_5</th>
<th>spellcategorycooldown_5</th>
<th>bonding</th>
<th>description</th>
<th>PageText</th>
<th>LanguageID</th>
<th>PageMaterial</th>
<th>startquest</th>
<th>lockid</th>
<th>Material</th>
<th>sheath</th>
<th>RandomProperty</th>
<th>block</th>
<th>itemset</th>
<th>MaxDurability</th>
<th>area</th>
</tr>';
while($row = $res->next()){
$result .= '<tr>
<td>'.$row['class'].'</td>
<td>'.$row['subclass'].'</td>
<td>'.$row['name'].'</td>
<td>'.$row['displayid'].'</td>
<td>'.$row['Quality'].'</td>
<td>'.$row['entry'].'</td>
<td>'.$row['Flags'].'</td>
<td>'.$row['BuyCount'].'</td>
<td>'.$row['BuyPrice'].'</td>
<td>'.$row['SellPrice'].'</td>
<td>'.$row['InventoryType'].'</td>
<td>'.$row['AllowableClass'].'</td>
<td>'.$row['AllowableRace'].'</td>
<td>'.$row['ItemLevel'].'</td>
<td>'.$row['RequiredLevel'].'</td>
<td>'.$row['RequiredSkill'].'</td>
<td>'.$row['RequiredSkillRank'].'</td>
<td>'.$row['requiredspell'].'</td>
<td>'.$row['requiredhonorrank'].'</td>
<td>'.$row['RequiredCityRank'].'</td>
<td>'.$row['RequiredReputationFaction'].'</td>
<td>'.$row['RequiredReputationRank'].'</td>
<td>'.$row['maxcount'].'</td>
<td>'.$row['stackable'].'</td>
<td>'.$row['ContainerSlots'].'</td>
<td>'.$row['stat_type1'].'</td>
<td>'.$row['stat_value1'].'</td>
<td>'.$row['stat_type2'].'</td>
<td>'.$row['stat_value2'].'</td>
<td>'.$row['stat_type3'].'</td>
<td>'.$row['stat_value3'].'</td>
<td>'.$row['stat_type4'].'</td>
<td>'.$row['stat_value4'].'</td>
<td>'.$row['stat_type5'].'</td>
<td>'.$row['stat_value5'].'</td>
<td>'.$row['stat_type6'].'</td>
<td>'.$row['stat_value6'].'</td>
<td>'.$row['stat_type7'].'</td>
<td>'.$row['stat_value7'].'</td>
<td>'.$row['stat_type8'].'</td>
<td>'.$row['stat_value8'].'</td>
<td>'.$row['stat_type9'].'</td>
<td>'.$row['stat_value9'].'</td>
<td>'.$row['stat_type10'].'</td>
<td>'.$row['stat_value10'].'</td>
<td>'.$row['dmg_min1'].'</td>
<td>'.$row['dmg_max1'].'</td>
<td>'.$row['dmg_type1'].'</td>
<td>'.$row['dmg_min2'].'</td>
<td>'.$row['dmg_max2'].'</td>
<td>'.$row['dmg_type2'].'</td>
<td>'.$row['dmg_min3'].'</td>
<td>'.$row['dmg_max3'].'</td>
<td>'.$row['dmg_type3'].'</td>
<td>'.$row['dmg_min4'].'</td>
<td>'.$row['dmg_max4'].'</td>
<td>'.$row['dmg_type4'].'</td>
<td>'.$row['dmg_min5'].'</td>
<td>'.$row['dmg_max5'].'</td>
<td>'.$row['dmg_type5'].'</td>
<td>'.$row['armor'].'</td>
<td>'.$row['holy_res'].'</td>
<td>'.$row['fire_res'].'</td>
<td>'.$row['nature_res'].'</td>
<td>'.$row['frost_res'].'</td>
<td>'.$row['shadow_res'].'</td>
<td>'.$row['arcane_res'].'</td>
<td>'.$row['delay'].'</td>
<td>'.$row['ammo_type'].'</td>
<td>'.$row['RangedModRange'].'</td>
<td>'.$row['spellid_1'].'</td>
<td>'.$row['spelltrigger_1'].'</td>
<td>'.$row['spellcharges_1'].'</td>
<td>'.$row['spellppmRate_1'].'</td>
<td>'.$row['spellcooldown_1'].'</td>
<td>'.$row['spellcategory_1'].'</td>
<td>'.$row['spellcategorycooldown_1'].'</td>
<td>'.$row['spellid_2'].'</td>
<td>'.$row['spelltrigger_2'].'</td>
<td>'.$row['spellcharges_2'].'</td>
<td>'.$row['spellppmRate_2'].'</td>
<td>'.$row['spellcooldown_2'].'</td>
<td>'.$row['spellcategory_2'].'</td>
<td>'.$row['spellcategorycooldown_2'].'</td>
<td>'.$row['spellid_3'].'</td>
<td>'.$row['spelltrigger_3'].'</td>
<td>'.$row['spellcharges_3'].'</td>
<td>'.$row['spellppmRate_3'].'</td>
<td>'.$row['spellcooldown_3'].'</td>
<td>'.$row['spellcategory_3'].'</td>
<td>'.$row['spellcategorycooldown_3'].'</td>
<td>'.$row['spellid_4'].'</td>
<td>'.$row['spelltrigger_4'].'</td>
<td>'.$row['spellcharges_4'].'</td>
<td>'.$row['spellppmRate_4'].'</td>
<td>'.$row['spellcooldown_4'].'</td>
<td>'.$row['spellcategory_4'].'</td>
<td>'.$row['spellcategorycooldown_4'].'</td>
<td>'.$row['spellid_5'].'</td>
<td>'.$row['spelltrigger_5'].'</td>
<td>'.$row['spellcharges_5'].'</td>
<td>'.$row['spellppmRate_5'].'</td>
<td>'.$row['spellcooldown_5'].'</td>
<td>'.$row['spellcategory_5'].'</td>
<td>'.$row['spellcategorycooldown_5'].'</td>
<td>'.$row['bonding'].'</td>
<td>'.$row['description'].'</td>
<td>'.$row['PageText'].'</td>
<td>'.$row['LanguageID'].'</td>
<td>'.$row['PageMaterial'].'</td>
<td>'.$row['startquest'].'</td>
<td>'.$row['lockid'].'</td>
<td>'.$row['Material'].'</td>
<td>'.$row['sheath'].'</td>
<td>'.$row['RandomProperty'].'</td>
<td>'.$row['block'].'</td>
<td>'.$row['itemset'].'</td>
<td>'.$row['MaxDurability'].'</td>
<td>'.$row['area'].'</td>
</tr>';
public static function sai_mod_saimod_mojotrollz_db_item_action_search($search,$tags=null){
return self::sai_mod_saimod_mojotrollz_db_item($search,$tags);}
public static function sai_mod_saimod_mojotrollz_db_item_action_tag($id,$tags){
$tags = json_decode($tags,true);
foreach ($tags as $type=>$value){
if($value == -2){
tags::del(tags::TAG_TABLE_ITEM, $id, $type);}
tags::set(tags::TAG_TABLE_ITEM, $id, $type, $value);}
return JsonResult::ok();
}
public static function sai_mod_saimod_mojotrollz_db_item_action_item($id){
$vars = array();
$vars['entries'] = $vars['tag_entries'] = '';
$base_row = \DBD\DB_ITEM_TEMPLATE_ITEM::Q1(array($id));
foreach($base_row as $key=>$value){
$vars['entries'] .= \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\SERVERPATH(new PSAI(),'saimod_mojotrollz_db_item/tpl/item_base.tpl'), array('key' => $key, 'value' => $value));}
//Item Tags
$tags_res = tags::get(tags::TAG_TABLE_ITEM, $base_row['entry']);
$tags = array();
while($tag = $tags_res->next()){
$tags[$tag['type']] = $tag;}
//Tag Types
$tags_types = tags::get_type(tags::TAG_TABLE_ITEM);
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_item/tpl/tag_entry_option.tpl'), $value);}
$vars['tag_entries'] .= \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\SERVERPATH(new PSAI(),'saimod_mojotrollz_db_item/tpl/tag_item_entry.tpl'), $tag);}
return \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\SERVERPATH(new PSAI(),'saimod_mojotrollz_db_item/tpl/item.tpl'), $vars);
}
public static function sai_mod_saimod_mojotrollz_db_item($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_ITEM);
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_item/tpl/tag_entry_option.tpl'), $value);}
$vars['tag_entries'] .= \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\SERVERPATH(new PSAI(),'saimod_mojotrollz_db_item/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_ITEM.' AND `type` = '.$type.') AND ';
continue;}
$sql_join .= 'LEFT JOIN host_mojotrollz.mojotrollz_tags as t'.$type.' ON item_template.entry = t'.$type.'.id ';
$sql_where .= 't'.$type.'.`table` = '.tags::TAG_TABLE_ITEM.' 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-item',
'SELECT item_template.* FROM item_template '.
$sql_join.
' WHERE '.$sql_where.
' (`entry` LIKE ? OR `name` LIKE ? OR `description` LIKE ?) LIMIT 100;',
array($search,$search,$search));
while($row = $res->next()){
$vars['entries'] .= \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\SERVERPATH(new PSAI(),'saimod_mojotrollz_db_item/tpl/search_entry.tpl'), $row);}
return \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\SERVERPATH(new PSAI(),'saimod_mojotrollz_db_item/tpl/search.tpl'), $vars);
}
public static function html_li_menu(){return '<li><a href="#" saimenu="saimod_mojotrollz_db_item">DB:Items</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_item_flag_js(){return \SYSTEM\LOG\JsonResult::toString(array());}
public static function sai_mod_saimod_mojotrollz_db_item_flag_css(){}
public static function sai_mod_saimod_mojotrollz_db_item_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_item/js/saimod_mojotrollz_db_item.js')));}
public static function sai_mod_saimod_mojotrollz_db_item_flag_css(){return \SYSTEM\LOG\JsonResult::toString(array(
\SYSTEM\WEBPATH(new PAPI(),'map/css/map.css')));}
}

View File

@ -0,0 +1,12 @@
<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,23 @@
<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>Description</th>
<th>Quality</th>
<th>BuyPrice</th>
<th>SellPrice</th>
</tr>
${entries}
</table>

View File

@ -0,0 +1,8 @@
<tr class="wow_item" _id="${entry}">
<td>${entry}</td>
<td>${name}</td>
<td>${description}</td>
<td>${Quality}</td>
<td>${BuyPrice}</td>
<td>${SellPrice}</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>