mirror of
https://github.com/slawkens/myaac.git
synced 2025-04-26 17:29:21 +02:00
* moved spells to twig template
* removed useless spells.spell column that was duplicate of spells.words * Usage_Statistics reports now plugin version too * (internal) removed $hook_types array, using defined() and constant() functions now * (internal) optimized Spells class
This commit is contained in:
parent
913b4297cf
commit
f9b6e9fa2e
@ -28,7 +28,7 @@ session_start();
|
||||
|
||||
define('MYAAC', true);
|
||||
define('MYAAC_VERSION', '0.6.1');
|
||||
define('DATABASE_VERSION', 12);
|
||||
define('DATABASE_VERSION', 13);
|
||||
define('TABLE_PREFIX', 'myaac_');
|
||||
define('START_TIME', microtime(true));
|
||||
define('MYAAC_OS', (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') ? 'WINDOWS' : (strtoupper(PHP_OS) == 'DARWIN' ? 'MAC' : 'LINUX'));
|
||||
|
23
index.php
23
index.php
@ -54,13 +54,21 @@ if(!empty($tmp))
|
||||
else
|
||||
$uri = str_replace_first('/', '', $uri);
|
||||
|
||||
$uri = strtolower(str_replace(array('index.php/', '?'), '', $uri));
|
||||
$uri = str_replace(array('index.php/', '?'), '', $uri);
|
||||
|
||||
$found = false;
|
||||
if(empty($uri) || isset($_REQUEST['template'])) {
|
||||
$_REQUEST['p'] = 'news';
|
||||
$found = true;
|
||||
}
|
||||
else if(preg_match("/^[A-Za-z0-9-_%\'+]+\.png$/i", $uri)) {
|
||||
$tmp = explode('.', $uri);
|
||||
$_REQUEST['name'] = urldecode($tmp[0]);
|
||||
|
||||
chdir(TOOLS . 'signature');
|
||||
include(TOOLS . 'signature/index.php');
|
||||
exit();
|
||||
}
|
||||
else if(!preg_match('/[^A-z0-9_\-]/', $uri) && file_exists(SYSTEM . 'pages/' . $uri . '.php')) {
|
||||
$_REQUEST['p'] = $uri;
|
||||
$found = true;
|
||||
@ -106,22 +114,15 @@ else {
|
||||
'/^news\/edit\/?$/' => array('subtopic' => 'news', 'action' => 'edit'),
|
||||
'/^news\/archive\/?$/' => array('subtopic' => 'newsarchive'),
|
||||
'/^news\/archive\/[0-9]+\/?$/' => array('subtopic' => 'newsarchive', 'id' => '$2'),
|
||||
'/^polls\/[0-9]+\/?$/' => array('subtopic' => 'polls', 'id' => '$1')
|
||||
'/^polls\/[0-9]+\/?$/' => array('subtopic' => 'polls', 'id' => '$1'),
|
||||
'/^spells\/[A-Za-z0-9-_%]+\/[A-Za-z0-9-_]+\/?$/' => array('subtopic' => 'spells', 'vocation' => '$1', 'order' => '$2'),
|
||||
);
|
||||
|
||||
if (preg_match("/^[A-Za-z0-9-_%\'+]+\.png$/i", $uri)) {
|
||||
$tmp = explode('.', $uri);
|
||||
$_REQUEST['name'] = urldecode($tmp[0]);
|
||||
|
||||
chdir(TOOLS . 'signature');
|
||||
include(TOOLS . 'signature/index.php');
|
||||
exit();
|
||||
}
|
||||
|
||||
foreach($rules as $rule => $redirect) {
|
||||
if (preg_match($rule, $uri)) {
|
||||
$tmp = explode('/', $uri);
|
||||
foreach($redirect as $key => $value) {
|
||||
|
||||
if(strpos($value, '$') !== false) {
|
||||
$value = str_replace('$' . $value[1], $tmp[$value[1]], $value);
|
||||
}
|
||||
|
@ -25,21 +25,6 @@ define('HOOK_CHARACTERS_AFTER_CHARACTERS', 12);
|
||||
define('HOOK_FIRST', HOOK_STARTUP);
|
||||
define('HOOK_LAST', HOOK_CHARACTERS_AFTER_CHARACTERS);
|
||||
|
||||
$hook_types = array(
|
||||
'STARTUP' => HOOK_STARTUP,
|
||||
'BEFORE_PAGE' => HOOK_BEFORE_PAGE,
|
||||
'AFTER_PAGE' => HOOK_AFTER_PAGE,
|
||||
'FINISH' => HOOK_FINISH,
|
||||
'TIBIACOM_ARTICLE' => HOOK_TIBIACOM_ARTICLE,
|
||||
'TIBIACOM_BORDER_3' => HOOK_TIBIACOM_BORDER_3,
|
||||
'CHARACTERS_BEFORE_INFORMATIONS' => HOOK_CHARACTERS_BEFORE_INFORMATIONS,
|
||||
'CHARACTERS_AFTER_INFORMATIONS' => HOOK_CHARACTERS_AFTER_INFORMATIONS,
|
||||
'CHARACTERS_BEFORE_SIGNATURE' => HOOK_CHARACTERS_BEFORE_SIGNATURE,
|
||||
'CHARACTERS_AFTER_SIGNATURE' => HOOK_CHARACTERS_AFTER_SIGNATURE,
|
||||
'CHARACTERS_AFTER_ACCOUNT' => HOOK_CHARACTERS_AFTER_ACCOUNT,
|
||||
'CHARACTERS_AFTER_CHARACTERS' => HOOK_CHARACTERS_AFTER_CHARACTERS
|
||||
);
|
||||
|
||||
class Hook
|
||||
{
|
||||
private $_name, $_type, $_file;
|
||||
|
@ -101,13 +101,14 @@ class Plugins {
|
||||
|
||||
if (isset($plugin['hooks'])) {
|
||||
foreach ($plugin['hooks'] as $_name => $info) {
|
||||
if (isset($hook_types[$info['type']])) {
|
||||
if (defined('HOOK_'. $info['type'])) {
|
||||
$hook = constant('HOOK_'. $info['type']);
|
||||
$query = $db->query('SELECT `id` FROM `' . TABLE_PREFIX . 'hooks` WHERE `name` = ' . $db->quote($_name) . ';');
|
||||
if ($query->rowCount() == 1) { // found something
|
||||
$query = $query->fetch();
|
||||
$db->query('UPDATE `' . TABLE_PREFIX . 'hooks` SET `type` = ' . $hook_types[$info['type']] . ', `file` = ' . $db->quote($info['file']) . ' WHERE `id` = ' . (int)$query['id'] . ';');
|
||||
$db->update(TABLE_PREFIX . 'hooks', array('type' => $hook, 'file' => $info['file']), array('id' => (int)$query['id']));
|
||||
} else {
|
||||
$db->query('INSERT INTO `' . TABLE_PREFIX . 'hooks` (`id`, `name`, `type`, `file`) VALUES (NULL, ' . $db->quote($_name) . ', ' . $hook_types[$info['type']] . ', ' . $db->quote($info['file']) . ');');
|
||||
$db->insert(TABLE_PREFIX . 'hooks', array('id' => 'NULL', 'name' => $_name, 'type' => $hook, 'file' => $info['file']));
|
||||
}
|
||||
} else
|
||||
self::$warnings[] = 'Unknown event type: ' . $info['type'];
|
||||
|
@ -25,10 +25,6 @@ class Spells {
|
||||
echo '<h2>All records deleted from table <b>' . TABLE_PREFIX . 'spells</b> in database.</h2>';
|
||||
}
|
||||
|
||||
foreach($config['vocations'] as $voc_id => $voc_name) {
|
||||
$vocations_ids[$voc_name] = $voc_id;
|
||||
}
|
||||
|
||||
try {
|
||||
self::$spellsList = new OTS_SpellsList($config['data_path'].'spells/spells.xml');
|
||||
}
|
||||
@ -36,6 +32,7 @@ class Spells {
|
||||
self::$lastError = $e->getMessage();
|
||||
return false;
|
||||
}
|
||||
|
||||
//add conjure spells
|
||||
$conjurelist = self::$spellsList->getConjuresList();
|
||||
if($show) {
|
||||
@ -44,35 +41,29 @@ class Spells {
|
||||
|
||||
foreach($conjurelist as $spellname) {
|
||||
$spell = self::$spellsList->getConjure($spellname);
|
||||
$lvl = $spell->getLevel();
|
||||
$mlvl = $spell->getMagicLevel();
|
||||
$mana = $spell->getMana();
|
||||
$name = $spell->getName();
|
||||
$soul = $spell->getSoul();
|
||||
$spell_txt = $spell->getWords();
|
||||
|
||||
$vocations = $spell->getVocations();
|
||||
$words = $spell->getWords();
|
||||
if(strpos($words, '#') !== false)
|
||||
continue;
|
||||
|
||||
$enabled = $spell->isEnabled();
|
||||
if($enabled) {
|
||||
$hide_spell = 0;
|
||||
}
|
||||
else {
|
||||
$hide_spell = 1;
|
||||
}
|
||||
$pacc = $spell->isPremium();
|
||||
if($pacc) {
|
||||
$pacc = '1';
|
||||
}
|
||||
else {
|
||||
$pacc = '0';
|
||||
}
|
||||
$type = 2;
|
||||
$count = $spell->getConjureCount();
|
||||
try {
|
||||
$db->query('INSERT INTO myaac_spells (spell, name, words, type, mana, level, maglevel, soul, premium, vocations, conjure_count, hidden) VALUES (' . $db->quote($spell_txt) . ', ' . $db->quote($name) . ', ' . $db->quote($spell_txt) . ', ' . $db->quote($type) . ', ' . $db->quote($mana) . ', ' . $db->quote($lvl) . ', ' . $db->quote($mlvl) . ', ' . $db->quote($soul) . ', ' . $db->quote($pacc) . ', ' . $db->quote(json_encode($vocations)) . ', ' . $db->quote($count) . ', ' . $db->quote($hide_spell) . ')');
|
||||
$db->insert(TABLE_PREFIX . 'spells', array(
|
||||
'name' => $name,
|
||||
'words' => $words,
|
||||
'type' => 2,
|
||||
'mana' => $spell->getMana(),
|
||||
'level' => $spell->getLevel(),
|
||||
'maglevel' => $spell->getMagicLevel(),
|
||||
'soul' => $spell->getSoul(),
|
||||
'premium' => $spell->isPremium() ? 1 : 0,
|
||||
'vocations' => json_encode($spell->getVocations()),
|
||||
'conjure_count' => $spell->getConjureCount(),
|
||||
'hidden' => $spell->isEnabled() ? 0 : 1
|
||||
));
|
||||
|
||||
if($show) {
|
||||
success("Added: " . $name . "<br>");
|
||||
success('Added: ' . $name . '<br/>');
|
||||
}
|
||||
}
|
||||
catch(PDOException $error) {
|
||||
@ -82,7 +73,7 @@ class Spells {
|
||||
}
|
||||
}
|
||||
|
||||
//add instant spells
|
||||
// add instant spells
|
||||
$instantlist = self::$spellsList->getInstantsList();
|
||||
if($show) {
|
||||
echo "<h3>Instant:</h3>";
|
||||
@ -90,39 +81,29 @@ class Spells {
|
||||
|
||||
foreach($instantlist as $spellname) {
|
||||
$spell = self::$spellsList->getInstant($spellname);
|
||||
$lvl = $spell->getLevel();
|
||||
$mlvl = $spell->getMagicLevel();
|
||||
$mana = $spell->getMana();
|
||||
$name = $spell->getName();
|
||||
$soul = $spell->getSoul();
|
||||
$spell_txt = $spell->getWords();
|
||||
if(strpos($spell_txt, '###') !== false)
|
||||
|
||||
$words = $spell->getWords();
|
||||
if(strpos($words, '#') !== false)
|
||||
continue;
|
||||
|
||||
$vocations = $spell->getVocations();
|
||||
|
||||
$enabled = $spell->isEnabled();
|
||||
if($enabled) {
|
||||
$hide_spell = 0;
|
||||
}
|
||||
else {
|
||||
$hide_spell = 1;
|
||||
}
|
||||
$pacc = $spell->isPremium();
|
||||
if($pacc) {
|
||||
$pacc = '1';
|
||||
}
|
||||
else {
|
||||
$pacc = '0';
|
||||
}
|
||||
$type = 1;
|
||||
$count = 0;
|
||||
|
||||
|
||||
try {
|
||||
$db->query("INSERT INTO myaac_spells (spell, name, words, type, mana, level, maglevel, soul, premium, vocations, conjure_count, hidden) VALUES (".$db->quote($spell_txt).", ".$db->quote($name).", ".$db->quote($spell_txt).", '".$type."', '".$mana."', '".$lvl."', '".$mlvl."', '".$soul."', '".$pacc."', ".$db->quote(json_encode($vocations)).", '".$count."', '".$hide_spell."')");
|
||||
$db->insert(TABLE_PREFIX . 'spells', array(
|
||||
'name' => $name,
|
||||
'words' => $words,
|
||||
'type' => 1,
|
||||
'mana' => $spell->getMana(),
|
||||
'level' => $spell->getLevel(),
|
||||
'maglevel' => $spell->getMagicLevel(),
|
||||
'soul' => $spell->getSoul(),
|
||||
'premium' => $spell->isPremium() ? 1 : 0,
|
||||
'vocations' => json_encode($spell->getVocations()),
|
||||
'conjure_count' => 0,
|
||||
'hidden' => $spell->isEnabled() ? 0 : 1
|
||||
));
|
||||
|
||||
if($show) {
|
||||
success("Added: ".$name."<br/>");
|
||||
success('Added: ' . $name . '<br/>');
|
||||
}
|
||||
}
|
||||
catch(PDOException $error) {
|
||||
@ -132,44 +113,35 @@ class Spells {
|
||||
}
|
||||
}
|
||||
|
||||
//add runes
|
||||
// add runes
|
||||
$runeslist = self::$spellsList->getRunesList();
|
||||
if($show) {
|
||||
echo "<h3>Runes:</h3>";
|
||||
}
|
||||
// runes
|
||||
|
||||
foreach($runeslist as $spellname) {
|
||||
$spell = self::$spellsList->getRune($spellname);
|
||||
$lvl = $spell->getLevel();
|
||||
$mlvl = $spell->getMagicLevel();
|
||||
$mana = $spell->getMana();
|
||||
$name = $spell->getName() . ' (rune)';
|
||||
$soul = $spell->getSoul();
|
||||
$spell_txt = $spell->getWords();
|
||||
$vocations = $spell->getVocations();
|
||||
|
||||
$id = $spell->getID();
|
||||
|
||||
$enabled = $spell->isEnabled();
|
||||
if($enabled) {
|
||||
$hide_spell = 0;
|
||||
}
|
||||
else {
|
||||
$hide_spell = 1;
|
||||
}
|
||||
$pacc = $spell->isPremium();
|
||||
if($pacc) {
|
||||
$pacc = '1';
|
||||
}
|
||||
else {
|
||||
$pacc = '0';
|
||||
}
|
||||
$type = 3;
|
||||
$count = $spell->getConjureCount();
|
||||
$name = $spell->getName() . ' (rune)';
|
||||
|
||||
try {
|
||||
$db->query('INSERT INTO myaac_spells (spell, name, words, type, mana, level, maglevel, soul, premium, vocations, conjure_count, item_id, hidden) VALUES (' . $db->quote($spell_txt) . ', ' . $db->quote($name) . ', ' . $db->quote($spell_txt) . ', ' . $db->quote($type) . ', ' . $db->quote($mana) . ', ' . $db->quote($lvl) . ', ' . $db->quote($mlvl) . ', ' . $db->quote($soul) . ', ' . $db->quote($pacc) . ', ' . $db->quote(json_encode($vocations)) . ', ' . $db->quote($count) . ', ' . $db->quote($id) . ', ' . $db->quote($hide_spell) . ')');
|
||||
$db->insert(TABLE_PREFIX . 'spells', array(
|
||||
'name' => $name,
|
||||
'words' => $spell->getWords(),
|
||||
'type' => 3,
|
||||
'mana' => $spell->getMana(),
|
||||
'level' => $spell->getLevel(),
|
||||
'maglevel' => $spell->getMagicLevel(),
|
||||
'soul' => $spell->getSoul(),
|
||||
'premium' => $spell->isPremium() ? 1 : 0,
|
||||
'vocations' => json_encode($spell->getVocations()),
|
||||
'conjure_count' => 0,
|
||||
'item_id' => $spell->getID(),
|
||||
'hidden' => $spell->isEnabled() ? 0 : 1
|
||||
));
|
||||
|
||||
if($show) {
|
||||
success("Added: " . $name . "<br>");
|
||||
success('Added: ' . $name . '<br/>');
|
||||
}
|
||||
}
|
||||
catch(PDOException $error) {
|
||||
|
@ -97,7 +97,16 @@ WHERE TABLE_SCHEMA = "forgottenserver";');
|
||||
}
|
||||
|
||||
$ret['locales'] = get_locales();
|
||||
$ret['plugins'] = get_plugins();
|
||||
$ret['plugins'] = array();
|
||||
foreach(get_plugins() as $plugin) {
|
||||
$string = file_get_contents(BASE . 'plugins/' . $plugin . '.json');
|
||||
$plugin_info = json_decode($string, true);
|
||||
if($plugin_info != false) {
|
||||
if(isset($plugin_info['version'])) {
|
||||
$ret['plugins'][$plugin] = $plugin_info['version'];
|
||||
}
|
||||
}
|
||||
}
|
||||
$ret['templates'] = get_templates();
|
||||
|
||||
$ret['date_timezone'] = $config['date_timezone'];
|
||||
|
4
system/migrations/13.php
Normal file
4
system/migrations/13.php
Normal file
@ -0,0 +1,4 @@
|
||||
<?php
|
||||
if(fieldExist('spell', TABLE_PREFIX . 'spells'))
|
||||
$db->query("ALTER TABLE `" . TABLE_PREFIX . "spells` DROP COLUMN `spell`;");
|
||||
?>
|
@ -21,145 +21,67 @@ if(isset($_POST['reload_spells']) && $canEdit)
|
||||
}
|
||||
}
|
||||
|
||||
if($canEdit)
|
||||
{
|
||||
?>
|
||||
<form method="post" action="index.php?subtopic=spells">
|
||||
<input type="hidden" name="reload_spells" value="yes"/>
|
||||
<input type="submit" value="(admin) Reload spells"/>
|
||||
</form>
|
||||
<?php
|
||||
if(isset($_REQUEST['vocation_id'])) {
|
||||
$vocation_id = $_REQUEST['vocation_id'];
|
||||
if($vocation_id == 'all') {
|
||||
$vocation = 'all';
|
||||
}
|
||||
else {
|
||||
$vocation = $config['vocations'][$vocation_id];
|
||||
}
|
||||
}
|
||||
else {
|
||||
$vocation = (isset($_REQUEST['vocation']) ? rawurldecode($_REQUEST['vocation']) : 'all');
|
||||
|
||||
if($vocation == 'all') {
|
||||
$vocation_id = 'all';
|
||||
}
|
||||
else {
|
||||
$vocation_ids = array_flip($config['vocations']);
|
||||
$vocation_id = $vocation_ids[$vocation];
|
||||
}
|
||||
}
|
||||
|
||||
$vocation_id = (isset($_REQUEST['vocation_id']) ? (int)$_REQUEST['vocation_id'] : 'All');
|
||||
$order = 'spell';
|
||||
if(isset($_GET['order']))
|
||||
$order = $_GET['order'];
|
||||
$order = 'words';
|
||||
if(isset($_REQUEST['order']))
|
||||
$order = $_REQUEST['order'];
|
||||
|
||||
if(!in_array($order, array('spell', 'words', 'type', 'mana', 'level', 'maglevel', 'soul')))
|
||||
if(!in_array($order, array('words', 'type', 'mana', 'level', 'maglevel', 'soul')))
|
||||
$order = 'level';
|
||||
?>
|
||||
|
||||
<form action="?subtopic=spells" method="post">
|
||||
<table border="0" cellspacing="1" cellpadding="4" width="100%">
|
||||
<tr bgcolor="<?php echo $config['vdarkborder']; ?>">
|
||||
<td class="white"><b>Spell Search</b></td>
|
||||
</tr>
|
||||
<tr bgcolor="<?php echo $config['darkborder']; ?>">
|
||||
<td>
|
||||
<table border="0" cellpadding="1">
|
||||
<tr>
|
||||
<td>Only for vocation: <select name="vocation_id">
|
||||
<option value="All" <?php
|
||||
if('All' == $vocation_id)
|
||||
echo 'SELECTED';
|
||||
|
||||
echo '>All';
|
||||
|
||||
foreach($config['vocations'] as $id => $vocation)
|
||||
{
|
||||
echo '<option value="' . $id . '" ';
|
||||
if($id == $vocation_id && $vocation_id != "All" && $vocation_id != '')
|
||||
echo 'SELECTED';
|
||||
|
||||
echo '>' . $vocation;
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
<input type="hidden" name="order" value="<?php echo $order; ?>">
|
||||
</td>
|
||||
<td>
|
||||
<?php echo $twig->render('buttons.submit.html.twig'); ?>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
$spells = array();
|
||||
$spells_db = $db->query('SELECT * FROM `' . TABLE_PREFIX . 'spells` WHERE `hidden` != 1 AND `type` < 3 ORDER BY ' . $order . ', level');
|
||||
|
||||
<table border="0" cellspacing="1" cellpadding="4" width="100%">
|
||||
<tr bgcolor="<?php echo $config['vdarkborder']; ?>">
|
||||
<td class="white">
|
||||
<b><a href="?subtopic=spells&vocation_id=<?php echo $vocation_id; ?>&order=spell"><font class="white">Name</font></a></b>
|
||||
</td>
|
||||
<td class="white">
|
||||
<b><a href="?subtopic=spells&vocation_id=<?php echo $vocation_id; ?>&order=words"><font class="white">Words</font></a></b>
|
||||
</td>
|
||||
<td class="white">
|
||||
<b><a href="?subtopic=spells&vocation_id=<?php echo $vocation_id; ?>&order=type"><font class="white">Type<br/>(count)</font></a></b>
|
||||
</td>
|
||||
<td class="white">
|
||||
<b><a href="?subtopic=spells&vocation_id=<?php echo $vocation_id; ?>&order=mana"><font class="white">Mana</font></a></b>
|
||||
</td>
|
||||
<td class="white">
|
||||
<b><a href="?subtopic=spells&vocation_id=<?php echo $vocation_id; ?>&order=level"><font class="white">Level</font></a></b>
|
||||
</td>
|
||||
<td class="white">
|
||||
<b><a href="?subtopic=spells&vocation_id=<?php echo $vocation_id; ?>&order=maglevel"><font class="white">Magic<br/>Level</font></a></b>
|
||||
</td>
|
||||
<td class="white">
|
||||
<b><a href="?subtopic=spells&vocation_id=<?php echo $vocation_id; ?>&order=soul"><font class="white">Soul</font></a></b>
|
||||
</td>
|
||||
<td class="white">
|
||||
<b>Premium</b>
|
||||
</td>
|
||||
<td class="white">
|
||||
<b>Vocations:</b>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
|
||||
$i = 0;
|
||||
$spells = $db->query('SELECT * FROM `' . TABLE_PREFIX . 'spells` WHERE `hidden` != 1 AND `type` < 3 ORDER BY ' . $order . ', level');
|
||||
if(isset($vocation_id) && $vocation_id != 'All' && $vocation_id != '')
|
||||
{
|
||||
foreach($spells as $spell)
|
||||
{
|
||||
if((string)$vocation_id != 'all') {
|
||||
foreach($spells_db->fetchAll() as &$spell) {
|
||||
$spell_vocations = json_decode($spell['vocations'], true);
|
||||
if(in_array($vocation_id, $spell_vocations) || count($spell_vocations) == 0)
|
||||
{
|
||||
echo '<TR BGCOLOR="' . getStyle(++$i) . '"><TD>' . $spell['name'] . '</TD><TD>' . $spell['words'] . '</TD>';
|
||||
if($spell['type'] == 1)
|
||||
echo '<TD>Instant</TD>';
|
||||
else if($spell['type'] == 2)
|
||||
echo '<TD>Conjure ('.$spell['conjure_count'].')</TD>';
|
||||
if(in_array($vocation_id, $spell_vocations) || count($spell_vocations) == 0) {
|
||||
$spell['vocations'] = null;
|
||||
$spells[] = $spell;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
foreach($spells_db->fetchAll() as &$spell) {
|
||||
$vocations = json_decode($spell['vocations'], true);
|
||||
|
||||
foreach($vocations as &$tmp_vocation) {
|
||||
if(isset($config['vocations'][$tmp_vocation]))
|
||||
$tmp_vocation = $config['vocations'][$tmp_vocation];
|
||||
else
|
||||
echo '<TD>Rune</TD>';
|
||||
|
||||
echo '<TD>' . $spell['mana'] . '</TD><TD>' . $spell['level'] . '</TD><TD>' . $spell['maglevel'] . '</TD><TD>' . $spell['soul'] . '</TD><TD>' . ($spell ['premium'] == 1 ? 'yes' : 'no') . '</TD><TD>' . $config['vocations'][$vocation_id] . '</TD></TR>';
|
||||
$tmp_vocation = 'Unknown';
|
||||
}
|
||||
|
||||
$spell['vocations'] = implode('</br>', $vocations);
|
||||
$spells[] = $spell;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach($spells as $spell)
|
||||
{
|
||||
$spell_vocations = json_decode($spell['vocations'], true);
|
||||
|
||||
echo '<TR BGCOLOR="' . getStyle(++$i) . '"><TD>' .$spell['name'] . '</TD><TD>' . $spell['words'] . '</TD>';
|
||||
if($spell['type'] == 1)
|
||||
echo '<TD>Instant</TD>';
|
||||
else if($spell['type'] == 2)
|
||||
echo '<TD>Conjure ('.$spell['conjure_count'].')</TD>';
|
||||
else
|
||||
echo '<TD>Rune</TD>';
|
||||
|
||||
echo '<TD>' . $spell['mana'] . '</TD><TD>' . $spell['level'] . '</TD><TD>' . $spell['maglevel'] . '</TD><TD>' . $spell['soul'] . '</TD><TD>'. ($spell ['premium'] == 1 ? 'yes' : 'no') .'</TD><TD><font size="1">';
|
||||
|
||||
$showed_vocations = 0;
|
||||
foreach($spell_vocations as $spell_vocation)
|
||||
{
|
||||
if(isset($config['vocations'][$spell_vocation])) {
|
||||
echo $config['vocations'][$spell_vocation];
|
||||
$showed_vocations++;
|
||||
}
|
||||
if($showed_vocations != count($spell_vocations))
|
||||
echo '<br/>';
|
||||
}
|
||||
|
||||
echo '</font></TD></TR>';
|
||||
}
|
||||
}
|
||||
echo $twig->render('spells.html.twig', array(
|
||||
'canEdit' => $canEdit,
|
||||
'post_vocation_id' => $vocation_id,
|
||||
'post_vocation' => $vocation,
|
||||
'post_order' => $order,
|
||||
'spells' => $spells,
|
||||
));
|
||||
?>
|
||||
</table>
|
||||
|
96
system/templates/spells.html.twig
Normal file
96
system/templates/spells.html.twig
Normal file
@ -0,0 +1,96 @@
|
||||
{% if canEdit %}
|
||||
<form method="post" action="{{ getLink('spells') }}">
|
||||
<input type="hidden" name="reload_spells" value="yes"/>
|
||||
<input type="submit" value="(admin) Reload spells"/>
|
||||
</form>
|
||||
{% endif %}
|
||||
|
||||
<form action="{{ getLink('spells') }}" method="post">
|
||||
<table border="0" cellspacing="1" cellpadding="4" width="100%">
|
||||
<tr bgcolor="{{ config.vdarkborder }}">
|
||||
<td class="white"><b>Spell Search</b></td>
|
||||
</tr>
|
||||
<tr bgcolor="{{ config.darkborder }}">
|
||||
<td>
|
||||
<table border="0" cellpadding="1">
|
||||
<tr>
|
||||
<td>Only for vocation: <select name="vocation_id">
|
||||
<option value="all" {% if post_vocation_id == 'all' %} selected{% endif %}>All</option>
|
||||
{% for id, vocation in config.vocations %}
|
||||
<option value="{{ id }}"{% if id == post_vocation_id and post_vocation_id != "all" and post_vocation_id != '' %} selected{% endif %}>{{ vocation }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
<input type="hidden" name="order" value="{{ post_order }}">
|
||||
</td>
|
||||
<td>
|
||||
{{ include('buttons.submit.html.twig') }}
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
<br/>
|
||||
<table border="0" cellspacing="1" cellpadding="4" width="100%">
|
||||
<tr bgcolor="{{ config.vdarkborder }}">
|
||||
<td class="white">
|
||||
<b><a href="{{ getLink('spells') ~ '/' ~ post_vocation|url_encode ~ '/spell' }}"><font class="white">Name</font></a></b>
|
||||
</td>
|
||||
<td class="white">
|
||||
<b><a href="{{ getLink('spells') ~ '/' ~ post_vocation|url_encode ~ '/words' }}"><font class="white">Words</font></a></b>
|
||||
</td>
|
||||
<td class="white">
|
||||
<b><a href="{{ getLink('spells') ~ '/' ~ post_vocation|url_encode ~ '/type' }}"><font class="white">Type<br/>(count)</font></a></b>
|
||||
</td>
|
||||
<td class="white">
|
||||
<b><a href="{{ getLink('spells') ~ '/' ~ post_vocation|url_encode ~ '/mana' }}"><font class="white">Mana</font></a></b>
|
||||
</td>
|
||||
<td class="white">
|
||||
<b><a href="{{ getLink('spells') ~ '/' ~ post_vocation|url_encode ~ '/level' }}"><font class="white">Level</font></a></b>
|
||||
</td>
|
||||
<td class="white">
|
||||
<b><a href="{{ getLink('spells') ~ '/' ~ post_vocation|url_encode ~ '/maglevel' }}"><font class="white">Magic<br/>Level</font></a></b>
|
||||
</td>
|
||||
<td class="white">
|
||||
<b><a href="{{ getLink('spells') ~ '/' ~ post_vocation|url_encode ~ '/soul' }}"><font class="white">Soul</font></a></b>
|
||||
</td>
|
||||
<td class="white">
|
||||
<b>Premium</b>
|
||||
</td>
|
||||
<td class="white">
|
||||
<b>Vocations:</b>
|
||||
</td>
|
||||
</tr>
|
||||
{% set i = 0 %}
|
||||
{% for spell in spells %}
|
||||
{% set i = i + 1 %}
|
||||
<tr bgcolor="{{ getStyle(i) }}">
|
||||
<td>{{ spell.name }}</td>
|
||||
<td>{{ spell.words }}</td>
|
||||
<td>
|
||||
{% if spell.type == 1 %}
|
||||
Instant
|
||||
{% elseif spell.type == 2 %}
|
||||
Conjure ({{ spell.conjure_count }})
|
||||
{% else %}
|
||||
Rune
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>{{ spell.mana }}</td>
|
||||
<td>{{ spell.level }}</td>
|
||||
<td>{{ spell.maglevel }}</td>
|
||||
<td>{{ spell.soul }}</td>
|
||||
<td>{% if spell.premium == 1 %}yes{% else %}no{% endif %}</td>
|
||||
<td>
|
||||
{% if spell.vocations|length > 0 %}
|
||||
<font size="1">
|
||||
{{ spell.vocations|raw }}
|
||||
</font>
|
||||
{% else %}
|
||||
{{ config.vocations[post_vocation_id] }}
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
Loading…
x
Reference in New Issue
Block a user