Code clean up + datatables (#64)

* Reformat Code

Reformat Code
- spaces + tabs

* Code cleanup

removed duplicated datatables code

* Datatables

replace spells, monsters tables with JavaScript Sortable Tables (DataTables?)
This commit is contained in:
Lee 2018-12-02 05:30:36 +00:00 committed by slawkens
parent e3bcbc4da9
commit 876b1b988a
38 changed files with 2396 additions and 2510 deletions

View File

@ -37,6 +37,7 @@ td.details-control {
color: forestgreen;
cursor: pointer;
}
tr.shown td.details-control {
text-align: center;
color: red;

View File

@ -10,7 +10,7 @@
<link rel="stylesheet" href="<?php echo BASE_URL; ?>tools/css/font-awesome.min.css">
<link rel="stylesheet" href="<?php echo BASE_URL; ?>tools/css/ionicons.min.css">
<link rel="stylesheet" href="<?php echo BASE_URL; ?>tools/css/dataTables.bootstrap.min.css">
<link rel="stylesheet" href="<?php echo BASE_URL; ?>tools/css/jquery.dataTables.min.css">
<link rel="stylesheet" type="text/css" href="<?php echo $template_path; ?>style.css"/>
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
@ -29,7 +29,7 @@
<header class="main-header">
<a href="." class="logo">
<span class="logo-mini"><b>M</b>A</span>
<span class="logo-lg"><b>My</b>ACC</span>
<span class="logo-lg"><b>My</b>AAC</span>
</a>
<nav class="navbar navbar-static-top" role="navigation">
@ -129,7 +129,8 @@
<div class="content-wrapper">
<section class="content-header">
<h1><?php echo (isset($title) ? $title : ''); ?><small> - Admin Panel</small>
<h1><?php echo(isset($title) ? $title : ''); ?>
<small> - Admin Panel</small>
<div class="pull-right">
<span class="label label-<?php echo(($status['online']) ? 'success' : 'danger'); ?>"><?php echo $config['lua']['serverName'] ?></span>
</div>
@ -169,7 +170,8 @@
<i class="menu-icon fa fa-sign-out bg-red"></i>
<div class="menu-info">
<h4 class="control-sidebar-subheading">Log out</h4>
<p>This will log you out of <?php echo (USE_ACCOUNT_NAME ? $account_logged->getName() : $account_logged->getId()); ?></p>
<p>This will log you out
of <?php echo(USE_ACCOUNT_NAME ? $account_logged->getName() : $account_logged->getId()); ?></p>
</div>
</a>
</li>
@ -215,7 +217,6 @@
<script src="<?php echo BASE_URL; ?>tools/js/jquery.min.js"></script>
<script src="<?php echo BASE_URL; ?>tools/js/jquery-ui.min.js"></script>
<script src="<?php echo BASE_URL; ?>tools/js/jquery.dataTables.min.js"></script>
<script src="<?php echo BASE_URL; ?>tools/js/dataTables.bootstrap.min.js"></script>
<script src="<?php echo BASE_URL; ?>tools/js/adminlte.min.js"></script>
</body>
</html>

View File

@ -161,12 +161,12 @@ if ($id > 0) {
$account->setCountry($rl_country);
if ($db->hasColumn('accounts', 'premium_points')) {
$account->setCustomField('premium_points', $p_points);}
$account->setCustomField('premium_points', $p_points);
}
if (isset($password)) {
$config_salt_enabled = $db->hasColumn('accounts', 'salt');
if($config_salt_enabled)
{
if ($config_salt_enabled) {
$salt = generateRandomString(10, false, true, true);
$password = $salt . $password;
$account_logged->setCustomField('salt', $salt);
@ -205,7 +205,8 @@ else if ($id > 0 && isset($account) && $account->isLoaded())
?>
<?php $acc_type = array("Normal", "Tutor", "Senior Tutor", "Gamemaster", "God"); ?>
<form action="<?php echo $base . ((isset($id) && $id > 0) ? '&id=' . $id : ''); ?>" method="post" class="form-horizontal">
<form action="<?php echo $base . ((isset($id) && $id > 0) ? '&id=' . $id : ''); ?>" method="post"
class="form-horizontal">
<div class="col-md-8">
<div class="box box-primary">
<div class="box-body">
@ -382,7 +383,8 @@ else if ($id > 0 && isset($account) && $account->isLoaded())
</div>
<div class="box-body no-padding">
<table class="table table-striped">
<tbody><tr>
<tbody>
<tr>
<th style="width: 10px">#</th>
<th>Name</th>
<th>Level</th>

View File

@ -10,14 +10,12 @@
defined('MYAAC') or die('Direct access not allowed!');
$title = 'Mailer';
if(!hasFlag(FLAG_CONTENT_MAILER) && !superAdmin())
{
if (!hasFlag(FLAG_CONTENT_MAILER) && !superAdmin()) {
echo 'Access denied.';
return;
}
if(!$config['mail_enabled'])
{
if (!$config['mail_enabled']) {
echo 'Mail support disabled.';
return;
}
@ -56,12 +54,10 @@ if($config['account_mail_verify']) {
}
$query = $db->query('SELECT ' . $db->fieldName('email') . ' FROM ' . $db->tableName('accounts') . ' WHERE ' . $db->fieldName('email') . ' != ""' . $add);
foreach($query as $email)
{
foreach ($query as $email) {
if (_mail($email['email'], $mail_subject, $mail_content))
$success++;
else
{
else {
$failed++;
echo '<br />';
error('An error occorred while sending email to <b>' . $email['email'] . '</b>. Error: ' . $mailer->ErrorInfo);

View File

@ -10,8 +10,7 @@
defined('MYAAC') or die('Direct access not allowed!');
$title = 'Menus';
if(!hasFlag(FLAG_CONTENT_MENUS) && !superAdmin())
{
if (!hasFlag(FLAG_CONTENT_MENUS) && !superAdmin()) {
echo 'Access denied.';
return;
}
@ -37,8 +36,7 @@ if(isset($_REQUEST['template'])) {
try {
$db->insert(TABLE_PREFIX . 'menu', array('template' => $template, 'name' => $menu, 'link' => $post_menu_link[$category][$i], 'blank' => $post_menu_blank[$category][$i] == 'on' ? 1 : 0, 'color' => str_replace('#', '', $post_menu_color[$category][$i]), 'category' => $category, 'ordering' => $i));
}
catch(PDOException $error) {
} catch (PDOException $error) {
warning('Error while adding menu item (' . $menu . '): ' . $error->getMessage());
}
}
@ -50,8 +48,7 @@ if(isset($_REQUEST['template'])) {
$file = TEMPLATES . $template . '/config.php';
if (file_exists($file)) {
require_once $file;
}
else {
} else {
echo 'Cannot find template config.php file.';
return;
}
@ -120,8 +117,7 @@ if(isset($_REQUEST['template'])) {
?>
<?php
}
else {
} else {
$templates = $db->query('SELECT `template` FROM `' . TABLE_PREFIX . 'menu` GROUP BY `template`;')->fetchAll();
foreach ($templates as $key => $value) {
$file = TEMPLATES . $value['template'] . '/config.php';

View File

@ -11,8 +11,7 @@ defined('MYAAC') or die('Direct access not allowed!');
$title = 'Notepad';
$notepad_content = Notepad::get($account_logged->getId());
if(isset($_POST['content']))
{
if (isset($_POST['content'])) {
$_content = html_entity_decode(stripslashes($_POST['content']));
if (!$notepad_content)
Notepad::create($account_logged->getId(), $_content);
@ -20,9 +19,7 @@ if(isset($_POST['content']))
Notepad::update($account_logged->getId(), $_content);
echo '<div class="success" style="text-align: center;">Saved at ' . date('H:i') . '</div>';
}
else
{
} else {
if ($notepad_content !== false)
$_content = $notepad_content;
}

View File

@ -10,8 +10,7 @@
defined('MYAAC') or die('Direct access not allowed!');
$title = 'Pages';
if(!hasFlag(FLAG_CONTENT_PAGES) && !superAdmin())
{
if (!hasFlag(FLAG_CONTENT_PAGES) && !superAdmin()) {
echo 'Access denied.';
return;
}
@ -24,8 +23,7 @@ $groups = new OTS_Groups_List();
$php = false;
$access = 0;
if(!empty($action))
{
if (!empty($action)) {
if ($action == 'delete' || $action == 'edit' || $action == 'hide')
$id = $_REQUEST['id'];
@ -50,19 +48,15 @@ if(!empty($action))
$player_id = 1;
if ($action == 'add') {
if(Pages::add($name, $p_title, $body, $player_id, $php, $access, $errors))
{
if (Pages::add($name, $p_title, $body, $player_id, $php, $access, $errors)) {
$name = $p_title = $body = '';
$player_id = $access = 0;
$php = false;
}
}
else if($action == 'delete') {
} else if ($action == 'delete') {
if (Pages::delete($id, $errors))
success('Page with id ' . $id . ' has been deleted');
}
else if($action == 'edit')
{
} else if ($action == 'edit') {
if (isset($id) && !isset($_REQUEST['name'])) {
$_page = Pages::get($id);
$name = $_page['name'];
@ -70,16 +64,14 @@ if(!empty($action))
$body = $_page['body'];
$php = $_page['php'] == '1';
$access = $_page['access'];
}
else {
} else {
Pages::update($id, $name, $p_title, $body, $player_id, $php, $access);
$action = $name = $p_title = $body = '';
$player_id = 1;
$access = 0;
$php = false;
}
}
else if($action == 'hide') {
} else if ($action == 'hide') {
Pages::toggleHidden($id, $errors);
}
@ -130,21 +122,20 @@ class Pages
static public function add($name, $title, $body, $player_id, $php, $access, &$errors)
{
global $db;
if(isset($name[0]) && isset($title[0]) && isset($body[0]) && $player_id != 0)
{
if (isset($name[0]) && isset($title[0]) && isset($body[0]) && $player_id != 0) {
$query = $db->select(TABLE_PREFIX . 'pages', array('name' => $name));
if ($query === false)
$db->insert(TABLE_PREFIX . 'pages', array('name' => $name, 'title' => $title, 'body' => $body, 'player_id' => $player_id, 'php' => $php ? '1' : '0', 'access' => $access));
else
$errors[] = 'Page with this link already exists.';
}
else
} else
$errors[] = 'Please fill all inputs.';
return !count($errors);
}
static public function update($id, $name, $title, $body, $player_id, $php, $access) {
static public function update($id, $name, $title, $body, $player_id, $php, $access)
{
global $db;
$db->update(TABLE_PREFIX . 'pages', array('name' => $name, 'title' => $title, 'body' => $body, 'player_id' => $player_id, 'php' => $php ? '1' : '0', 'access' => $access), array('id' => $id));
}
@ -152,14 +143,12 @@ class Pages
static public function delete($id, &$errors)
{
global $db;
if(isset($id))
{
if (isset($id)) {
if ($db->select(TABLE_PREFIX . 'pages', array('id' => $id)) !== false)
$db->delete(TABLE_PREFIX . 'pages', array('id' => $id));
else
$errors[] = 'Page with id ' . $id . ' does not exists.';
}
else
} else
$errors[] = 'id not set';
return !count($errors);
@ -168,18 +157,17 @@ class Pages
static public function toggleHidden($id, &$errors)
{
global $db;
if(isset($id))
{
if (isset($id)) {
$query = $db->select(TABLE_PREFIX . 'pages', array('id' => $id));
if ($query !== false)
$db->update(TABLE_PREFIX . 'pages', array('hidden' => ($query['hidden'] == 1 ? 0 : 1)), array('id' => $id));
else
$errors[] = 'Page with id ' . $id . ' does not exists.';
}
else
} else
$errors[] = 'id not set';
return !count($errors);
}
}
?>

View File

@ -330,7 +330,9 @@ else if ($id > 0 && isset($player) && $player->isLoaded())
<li class=""><a href="#tab_3" data-toggle="tab" aria-expanded="false">Skills</a></li>
<li class=""><a href="#tab_4" data-toggle="tab" aria-expanded="false">Pos/Look</a></li>
<li class=""><a href="#tab_5" data-toggle="tab" aria-expanded="false">Misc</a></li>
<li class="pull-right"><a href="<?php echo ADMIN_URL; ?>?p=accounts&search_name=<?php echo $account->getId(); ?>" class="text-muted"><i class="fa fa-gear" title="Edit Account"></i></a></li>
<li class="pull-right"><a
href="<?php echo ADMIN_URL; ?>?p=accounts&search_name=<?php echo $account->getId(); ?>"
class="text-muted"><i class="fa fa-gear" title="Edit Account"></i></a></li>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="tab_1">
@ -785,7 +787,8 @@ else if ($id > 0 && isset($player) && $player->isLoaded())
<!-- /.box-header -->
<div class="box-body no-padding">
<table class="table table-striped">
<tbody><tr>
<tbody>
<tr>
<th style="width: 10px">#</th>
<th>Name</th>
<th>Level</th>

View File

@ -19,13 +19,10 @@ if(isset($_REQUEST['uninstall'])){
if (Plugins::uninstall($uninstall)) {
success('Successfully uninstalled plugin ' . $uninstall);
}
else {
} else {
error('Error while uninstalling plugin ' . $uninstall . ': ' . Plugins::getError());
}
}
else if(isset($_FILES["plugin"]["name"]))
{
} else if (isset($_FILES["plugin"]["name"])) {
$file = $_FILES["plugin"];
$filename = $file["name"];
$tmp_name = $file["tmp_name"];
@ -58,8 +55,7 @@ else if(isset($_FILES["plugin"]["name"]))
if (isset($error) && $error != false) {
error($error);
}
else {
} else {
if (is_uploaded_file($file['tmp_name'])) {
$filetype = strtolower(pathinfo($filename, PATHINFO_EXTENSION));
if ($filetype == 'zip') // check if it is zipped/compressed file
@ -75,37 +71,31 @@ else if(isset($_FILES["plugin"]["name"]))
$info = Plugins::getPlugin();
success((isset($info['name']) ? '<strong>' . $info['name'] . '</strong> p' : 'P') . 'lugin has been successfully installed.');
}
else {
} else {
$error = Plugins::getError();
error(!empty($error) ? $error : 'Unexpected error happened while installing plugin. Please try again later.');
}
unlink($targetzip); // delete the Zipped file
}
else
} else
error('There was a problem with the upload. Please try again.');
}
else {
} else {
error('The file you are trying to upload is not a .zip file. Please try again.');
}
}
else {
} else {
error('Error uploading file - unknown error.');
}
}
}
$plugins = array();
foreach(get_plugins() as $plugin)
{
foreach (get_plugins() as $plugin) {
$string = file_get_contents(BASE . 'plugins/' . $plugin . '.json');
$string = Plugins::removeComments($string);
$plugin_info = json_decode($string, true);
if ($plugin_info == false) {
warning('Cannot load plugin info ' . $plugin . '.json');
}
else {
} else {
$plugins[] = array(
'name' => isset($plugin_info['name']) ? $plugin_info['name'] : '',
'description' => isset($plugin_info['description']) ? $plugin_info['description'] : '',

View File

@ -11,14 +11,12 @@ defined('MYAAC') or die('Direct access not allowed!');
$title = 'Tools';
$tool = $_GET['tool'];
if(!isset($tool))
{
if (!isset($tool)) {
echo 'Tool not set.';
return;
}
if(preg_match("/[^A-z0-9_\-]/", $tool))
{
if (preg_match("/[^A-z0-9_\-]/", $tool)) {
echo 'Invalid tool.';
return;
}

View File

@ -25,12 +25,10 @@ $version_compare = version_compare($myaac_version, MYAAC_VERSION);
if ($version_compare == 0) {
success('MyAAC latest version is ' . $myaac_version . '. You\'re using the latest version.
<br/>View CHANGELOG ' . generateLink(ADMIN_URL . '?p=changelog', 'here'));
}
else if($version_compare < 0) {
} else if ($version_compare < 0) {
echo success('Woah, seems you\'re using newer version as latest released one! MyAAC latest released version is ' . $myaac_version . ', and you\'re using version ' . MYAAC_VERSION . '.
<br/>View CHANGELOG ' . generateLink(ADMIN_URL . '?p=changelog', 'here'));
}
else {
} else {
warning('You\'re using outdated version.<br/>
Your version: <b>' . MYAAC_VERSION . '</b><br/>
Latest version: <b>' . $myaac_version . '</b><br/>

View File

@ -21,7 +21,8 @@ endif;
require SYSTEM . 'libs/visitors.php';
$visitors = new Visitors($config['visitors_counter_ttl']);
function compare($a, $b) {
function compare($a, $b)
{
return $a['lastvisit'] > $b['lastvisit'] ? -1 : 1;
}

View File

@ -14,6 +14,8 @@ $title = "Creatures";
?>
<script type="text/javascript" src="tools/js/tipped.js"></script>
<link rel="stylesheet" type="text/css" href="tools/css/tipped.css"/>
<link rel="stylesheet" href="<?php echo BASE_URL; ?>tools/css/jquery.dataTables.min.css">
<script>
$(document).ready(function () {
Tipped.create('.tooltip');
@ -22,20 +24,17 @@ $title = "Creatures";
<?php
$canEdit = hasFlag(FLAG_CONTENT_MONSTERS) || admin();
if(isset($_POST['reload_monsters']) && $canEdit)
{
if (isset($_POST['reload_monsters']) && $canEdit) {
require LIBS . 'creatures.php';
if (Creatures::loadFromXML(true)) {
if (Creatures::getMonstersList()->hasErrors())
error('There were some problems loading your monsters.xml file. Please check system/logs/error.log for more info.');
}
else {
} else {
error(Creatures::getLastError());
}
}
if($canEdit)
{
if ($canEdit) {
?>
<form method="post" action="<?php echo getLink('creatures'); ?>">
<input type="hidden" name="reload_monsters" value="yes"/>
@ -44,99 +43,28 @@ if($canEdit)
<?php
}
if(empty($_REQUEST['creature']))
{
$allowed_order_by = array('name', 'exp', 'health', 'summonable', 'convinceable', 'race');
$order = isset($_REQUEST['order']) ? $_REQUEST['order'] : 'name';
//generate sql query
$desc = '';
if(isset($_REQUEST['desc']) && $_REQUEST['desc'] == 1) {
$desc = " DESC";
}
if($order == 'name') {
$whereandorder = ' ORDER BY name'.$desc;
}
elseif($order == 'exp') {
$whereandorder = ' ORDER BY exp'.$desc.', name';
}
elseif($order == 'health') {
$whereandorder = ' ORDER BY health'.$desc.', name';
}
elseif($order == 'summonable') {
$whereandorder = ' AND summonable = 1 ORDER BY mana'.$desc;
}
elseif($order == 'convinceable') {
$whereandorder = ' AND convinceable = 1 ORDER BY mana'.$desc;
}
elseif($order == 'race') {
$whereandorder = ' ORDER BY race'.$desc.', name';
}
else {
$whereandorder = ' ORDER BY name';
}
if (empty($_REQUEST['creature'])) {
//send query to database
$monsters = $db->query('SELECT * FROM `' . TABLE_PREFIX . 'monsters` WHERE `hidden` != 1'.$whereandorder);
echo '<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=100%><TR BGCOLOR='.$config['vdarkborder'].'>';
if($order == 'name' && !isset($_REQUEST['desc'])) {
echo '<TD class="white" width="200"><B><a href="?subtopic=creatures&order=name&desc=1"><span class="white">Name DESC</span></a></B></TD>';
} else {
echo '<TD class="white" width="200"><B><a href="?subtopic=creatures&order=name"><span class="white">Name</span></a></B></TD>';
}
if($order == 'health' && !isset($_REQUEST['desc'])) {
echo '<TD class="white"><B><a href="?subtopic=creatures&order=health&desc=1"><span class="white">Health<br/>DESC</span></a></B></TD>';
} else {
echo '<TD class="white"><B><a href="?subtopic=creatures&order=health"><span class="white">Health</span></a></B></TD>';
}
if($order == 'exp' && !isset($_REQUEST['desc'])) {
echo '<TD class="white"><B><a href="?subtopic=creatures&order=exp&desc=1"><span class="white">Experience<br/>DESC</span></a></B></TD>';
} else {
echo '<TD class="white"><B><a href="?subtopic=creatures&order=exp"><span class="white">Experience</span></a></B></TD>';
}
if($order == 'summonable' && !isset($_REQUEST['desc'])) {
echo '<TD class="white"><B><a href="?subtopic=creatures&order=summonable&desc=1"><span class="white">Summonable<br/>Mana DESC</span></a></B></TD>';
} else {
echo '<TD class="white"><B><a href="?subtopic=creatures&order=summonable"><span class="white">Summonable<br/>Mana</span></a></B></TD>';
}
if($order == 'convinceable' && !isset($_REQUEST['desc'])) {
echo '<TD class="white"><B><a href="?subtopic=creatures&order=convinceable&desc=1"><span class="white">Convinceable<br/>Mana DESC</span></a></B></TD>';
} else {
echo '<TD class="white"><B><a href="?subtopic=creatures&order=convinceable"><span class="white">Convinceable<br/>Mana</span></a></B></TD>';
}
if($order == 'race' && !isset($_REQUEST['desc'])) {
echo '<TD class="white"><B><a href="?subtopic=creatures&order=race&desc=1"><span class="white">Race<br/>DESC</span></a></B></TD></TR>';
} else {
echo '<TD class="white"><B><a href="?subtopic=creatures&order=race"><span class="white">Race</span></a></B></TD></TR>';
}
$number_of_rows = 0;
$monsters = $db->query('SELECT * FROM `' . TABLE_PREFIX . 'monsters` WHERE `hidden` != 1 ORDER BY name asc');
echo '<table id="creaturestb" class=""><thead>
<tr role="row"><th>Name</th><th>Health</th><th>Experience</th>
<th>Summonable Mana</th><th>Convinceable Mana</th><th>Race</th></tr>
</thead><tbody>';
foreach ($monsters as $monster) {
echo '<TR BGCOLOR="' . getStyle($number_of_rows++) . '"><TD><a href="?subtopic=creatures&creature='.urlencode($monster['name']).'">'.$monster['name'].'</a></TD><TD>'.$monster['health'].'</TD><TD>'.$monster['exp'].'</TD>';
if($monster['summonable']) {
echo '<TD>'.$monster['mana'].'</TD>';
}
else {
echo '<TD>---</TD>';
echo '<tr><td><a href="?subtopic=creatures&creature=' . urlencode($monster['name']) . '">' . $monster['name'] . '</a></td>
<td>' . $monster['health'] . '</td>
<td>' . $monster['exp'] . '</td>
<td>' . ($monster['summonable'] ? $monster['mana'] : "---") . '</td>
<td>' . ($monster['convinceable'] ? $monster['mana'] : "---") . '</td>
<td>' . ucwords($monster['race']) . '</td></tr>';
}
echo '</tbody></table>';
if($monster['convinceable']) {
echo '<TD>'.$monster['mana'].'</TD>';
}
else {
echo '<TD>---</TD>';
}
echo '<td>'.ucwords($monster['race']).'</td></tr>';
}
echo '</table>';
return;
}
} else {
$monster_name = stripslashes(trim(ucwords($_REQUEST['creature'])));
$monster = $db->query('SELECT * FROM `' . TABLE_PREFIX . 'monsters` WHERE `hidden` != 1 AND `name` = ' . $db->quote($monster_name) . ';')->fetch();
if(isset($monster['name']))
{
if (isset($monster['name'])) {
$title = $monster['name'] . " - Creatures";
echo '<div style="text-align:center"><h2>' . $monster['name'] . '</h2></div>';
@ -177,23 +105,20 @@ if(isset($monster['name']))
echo '<img src="images/monsters/' . $gfx_name . '" height="128" width="128">';
else
echo '<img src="images/monsters/nophoto.png" height="128" width="128">';
}
else
} else
echo '<img src="images/monsters/' . $monster['gfx_name'] . '" height="128" width="128">';
echo '</td></tr>
</TABLE></td></tr><tr><td>
<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=100%>';
$immunities = json_decode($monster['immunities'], true);
if(count($immunities) > 0)
{
if (count($immunities) > 0) {
$number_of_rows++;
echo '<tr BGCOLOR="' . getStyle($number_of_rows) . '"><td width="100"><b>Immunities: </b></td><td width="100%">' . implode(', ', $immunities) . '</td></tr>';
}
$voices = json_decode($monster['voices'], true);
if(count($voices) > 0)
{
if (count($voices) > 0) {
foreach ($voices as &$voice) {
$voice = '"' . $voice . '"';
}
@ -204,8 +129,7 @@ if(isset($monster['name']))
echo '</TABLE></td></tr>';
$loot = json_decode($monster['loot'], true);
if($loot)
{
if ($loot) {
echo '<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=100%><tr><td style="display: block;">';
function sort_by_chance($a, $b)
{
@ -231,12 +155,20 @@ if(isset($monster['name']))
echo '</td></tr>';
echo '</TABLE>';
}
else
{
} else {
echo "Monster with name <b>" . $monster_name . "</b> doesn't exist.";
}
//back button
$twig->display('creatures.back_button.html.twig');
}
?>
<script>
$(document).ready(function () {
$('#creaturestb').DataTable();
});
</script>
<script src="<?php echo BASE_URL; ?>tools/js/jquery.min.js"></script>
<script src="<?php echo BASE_URL; ?>tools/js/jquery.dataTables.min.js"></script>

View File

@ -41,15 +41,8 @@ else {
}
}
$order = 'words';
if(isset($_REQUEST['order']))
$order = $_REQUEST['order'];
if(!in_array($order, array('words', 'type', 'mana', 'level', 'maglevel', 'soul')))
$order = 'level';
$spells = array();
$spells_db = $db->query('SELECT * FROM `' . TABLE_PREFIX . 'spells` WHERE `hidden` != 1 AND `type` < 3 ORDER BY ' . $order . ', level');
$spells_db = $db->query('SELECT * FROM `' . TABLE_PREFIX . 'spells` WHERE `hidden` != 1 AND `type` < 3 ORDER BY name, level');
if((string)$vocation_id != 'all') {
foreach($spells_db->fetchAll() as $spell) {
@ -76,11 +69,23 @@ else {
}
}
?>
<link rel="stylesheet" href="<?php echo BASE_URL; ?>tools/css/jquery.dataTables.min.css">
<?php
$twig->display('spells.html.twig', array(
'canEdit' => $canEdit,
'post_vocation_id' => $vocation_id,
'post_vocation' => $vocation,
'post_order' => $order,
'spells' => $spells,
));
?>
<script>
$(document).ready( function () {
$('#spellstb').DataTable();
} );
</script>
<script src="<?php echo BASE_URL; ?>tools/js/jquery.min.js"></script>
<script src="<?php echo BASE_URL; ?>tools/js/jquery.dataTables.min.js"></script>

View File

@ -39,7 +39,13 @@
});
</script>
<style type="text/css">
.sortable { list-style-type: none; margin: 0; padding: 0; width: 100%; }
.sortable {
list-style-type: none;
margin: 0;
padding: 0;
width: 100%;
}
.remove-button, .add-button {
cursor: pointer;
}
@ -48,6 +54,7 @@
<link type="text/css" rel="stylesheet" href="{{ constant('BASE_URL') }}tools/css/spectrum.css"/>
<script type="text/javascript">
initialiceSpectrum();
function initialiceSpectrum() {
$(".color-picker").spectrum({
preferredFormat: "hex",

View File

@ -19,7 +19,8 @@
<th class="sorting" tabindex="0" aria-controls="tb_pages" rowspan="1" colspan="1"
aria-sort="ascending" aria-label="Title: activate to sort column descending">Title
</th>
<th class="" tabindex="0" aria-controls="tb_pages" rowspan="1" colspan="1" style="width: 150px;">Options
<th class="" tabindex="0" aria-controls="tb_pages" rowspan="1" colspan="1"
style="width: 150px;">Options
</th>
</tr>
</thead>
@ -38,9 +39,11 @@
<a href="?p=pages&action=hide&id={{ page.id }}" class="ico"
title="{% if page.hidden != 1 %}Hide{% else %}Show{% endif %}">
{% if page.hidden != 1 %}
<span class="btn btn-primary btn-sm btn-flat"><i class="fa fa-eye"></i></span>
<span class="btn btn-primary btn-sm btn-flat"><i
class="fa fa-eye"></i></span>
{% else %}
<span class="btn btn-default btn-sm btn-flat"><i class="fa fa-eye-slash"></i></span>
<span class="btn btn-default btn-sm btn-flat"><i
class="fa fa-eye-slash"></i></span>
{% endif %}
</a>
</td>

View File

@ -2,10 +2,12 @@
<a href="admin/?p=pages&action=edit&id={{ page.id }}" title="Edit in Admin Panel" target="_blank">
<img src="images/edit.png"/>Edit
</a>
<a id="delete" href="admin/?p=pages&action=delete&id={{ page.id }}" onclick="return confirm('Are you sure?');" title="Delete in Admin Panel" target="_blank">
<a id="delete" href="admin/?p=pages&action=delete&id={{ page.id }}" onclick="return confirm('Are you sure?');"
title="Delete in Admin Panel" target="_blank">
<img src="images/del.png"/>Delete
</a>
<a href="admin/?p=pages&action=hide&id={{ page.id }}" title="{% if page.hidden != 1 %}Hide{% else %}Show{% endif %} in Admin Panel" target="_blank">
<a href="admin/?p=pages&action=hide&id={{ page.id }}"
title="{% if page.hidden != 1 %}Hide{% else %}Show{% endif %} in Admin Panel" target="_blank">
<img src="images/{% if page.hidden != 1 %}success{% else %}error{% endif %}.png"/>{% if page.hidden != 1 %}Hide{% else %}Show{% endif %}
</a>
<br/>

View File

@ -1,3 +1,4 @@
{% if canEdit %}
<form method="post" action="{{ getLink('spells') }}">
<input type="hidden" name="reload_spells" value="yes"/>
@ -20,7 +21,6 @@
<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') }}
@ -32,40 +32,14 @@
</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|urlencode ~ '/spell' }}"><span class="white">Name</span></a></b>
</td>
<td class="white">
<b><a href="{{ getLink('spells') ~ '/' ~ post_vocation|urlencode ~ '/words' }}"><span class="white">Words</span></a></b>
</td>
<td class="white">
<b><a href="{{ getLink('spells') ~ '/' ~ post_vocation|urlencode ~ '/type' }}"><span class="white">Type<br/>(count)</span></a></b>
</td>
<td class="white">
<b><a href="{{ getLink('spells') ~ '/' ~ post_vocation|urlencode ~ '/mana' }}"><span class="white">Mana</span></a></b>
</td>
<td class="white">
<b><a href="{{ getLink('spells') ~ '/' ~ post_vocation|urlencode ~ '/level' }}"><span class="white">Level</span></a></b>
</td>
<td class="white">
<b><a href="{{ getLink('spells') ~ '/' ~ post_vocation|urlencode ~ '/maglevel' }}"><span class="white">Magic<br/>Level</span></a></b>
</td>
<td class="white">
<b><a href="{{ getLink('spells') ~ '/' ~ post_vocation|urlencode ~ '/soul' }}"><span class="white">Soul</span></a></b>
</td>
<td class="white">
<b>Premium</b>
</td>
<td class="white">
<b>Vocations:</b>
</td>
</tr>
<table id="spellstb" class=""><thead>
<tr role="row"><th>Name</th><th>Words</th><th>Type<br/>(count)</th>
<th>Mana</th><th>Level</th><th>Magic Level</th><th>Soul</th><th>Premium</th><th>Vocations</th></tr>
</thead><tbody>
{% set i = 0 %}
{% for spell in spells %}
{% set i = i + 1 %}
<tr bgcolor="{{ getStyle(i) }}">
<tr>
<td>{{ spell.name }}</td>
<td>{{ spell.words }}</td>
<td>
@ -93,4 +67,4 @@
</td>
</tr>
{% endfor %}
</table>
</tbody></table>

View File

@ -1 +0,0 @@
table.dataTable{clear:both;margin-top:6px !important;margin-bottom:6px !important;max-width:none !important;border-collapse:separate !important}table.dataTable td,table.dataTable th{-webkit-box-sizing:content-box;box-sizing:content-box}table.dataTable td.dataTables_empty,table.dataTable th.dataTables_empty{text-align:center}table.dataTable.nowrap th,table.dataTable.nowrap td{white-space:nowrap}div.dataTables_wrapper div.dataTables_length label{font-weight:normal;text-align:left;white-space:nowrap}div.dataTables_wrapper div.dataTables_length select{width:75px;display:inline-block}div.dataTables_wrapper div.dataTables_filter{text-align:right}div.dataTables_wrapper div.dataTables_filter label{font-weight:normal;white-space:nowrap;text-align:left}div.dataTables_wrapper div.dataTables_filter input{margin-left:0.5em;display:inline-block;width:auto}div.dataTables_wrapper div.dataTables_info{padding-top:8px;white-space:nowrap}div.dataTables_wrapper div.dataTables_paginate{margin:0;white-space:nowrap;text-align:right}div.dataTables_wrapper div.dataTables_paginate ul.pagination{margin:2px 0;white-space:nowrap}div.dataTables_wrapper div.dataTables_processing{position:absolute;top:50%;left:50%;width:200px;margin-left:-100px;margin-top:-26px;text-align:center;padding:1em 0}table.dataTable thead>tr>th.sorting_asc,table.dataTable thead>tr>th.sorting_desc,table.dataTable thead>tr>th.sorting,table.dataTable thead>tr>td.sorting_asc,table.dataTable thead>tr>td.sorting_desc,table.dataTable thead>tr>td.sorting{padding-right:30px}table.dataTable thead>tr>th:active,table.dataTable thead>tr>td:active{outline:none}table.dataTable thead .sorting,table.dataTable thead .sorting_asc,table.dataTable thead .sorting_desc,table.dataTable thead .sorting_asc_disabled,table.dataTable thead .sorting_desc_disabled{cursor:pointer;position:relative}table.dataTable thead .sorting:after,table.dataTable thead .sorting_asc:after,table.dataTable thead .sorting_desc:after,table.dataTable thead .sorting_asc_disabled:after,table.dataTable thead .sorting_desc_disabled:after{position:absolute;bottom:8px;right:8px;display:block;font-family:'Glyphicons Halflings';opacity:0.5}table.dataTable thead .sorting:after{opacity:0.2;content:"\e150"}table.dataTable thead .sorting_asc:after{content:"\e155"}table.dataTable thead .sorting_desc:after{content:"\e156"}table.dataTable thead .sorting_asc_disabled:after,table.dataTable thead .sorting_desc_disabled:after{color:#eee}div.dataTables_scrollHead table.dataTable{margin-bottom:0 !important}div.dataTables_scrollBody table{border-top:none;margin-top:0 !important;margin-bottom:0 !important}div.dataTables_scrollBody table thead .sorting:after,div.dataTables_scrollBody table thead .sorting_asc:after,div.dataTables_scrollBody table thead .sorting_desc:after{display:none}div.dataTables_scrollBody table tbody tr:first-child th,div.dataTables_scrollBody table tbody tr:first-child td{border-top:none}div.dataTables_scrollFoot table{margin-top:0 !important;border-top:none}@media screen and (max-width: 767px){div.dataTables_wrapper div.dataTables_length,div.dataTables_wrapper div.dataTables_filter,div.dataTables_wrapper div.dataTables_info,div.dataTables_wrapper div.dataTables_paginate{text-align:center}}table.dataTable.table-condensed>thead>tr>th{padding-right:20px}table.dataTable.table-condensed .sorting:after,table.dataTable.table-condensed .sorting_asc:after,table.dataTable.table-condensed .sorting_desc:after{top:6px;right:6px}table.table-bordered.dataTable th,table.table-bordered.dataTable td{border-left-width:0}table.table-bordered.dataTable th:last-child,table.table-bordered.dataTable th:last-child,table.table-bordered.dataTable td:last-child,table.table-bordered.dataTable td:last-child{border-right-width:0}table.table-bordered.dataTable tbody th,table.table-bordered.dataTable tbody td{border-bottom-width:0}div.dataTables_scrollHead table.table-bordered{border-bottom-width:0}div.table-responsive>div.dataTables_wrapper>div.row{margin:0}div.table-responsive>div.dataTables_wrapper>div.row>div[class^="col-"]:first-child{padding-left:0}div.table-responsive>div.dataTables_wrapper>div.row>div[class^="col-"]:last-child{padding-right:0}

1
tools/css/jquery.dataTables.min.css vendored Normal file

File diff suppressed because one or more lines are too long

View File

@ -1,8 +0,0 @@
/*!
DataTables Bootstrap 3 integration
©2011-2015 SpryMedia Ltd - datatables.net/license
*/
(function(b){"function"===typeof define&&define.amd?define(["jquery","datatables.net"],function(a){return b(a,window,document)}):"object"===typeof exports?module.exports=function(a,d){a||(a=window);if(!d||!d.fn.dataTable)d=require("datatables.net")(a,d).$;return b(d,a,a.document)}:b(jQuery,window,document)})(function(b,a,d,m){var f=b.fn.dataTable;b.extend(!0,f.defaults,{dom:"<'row'<'col-sm-6'l><'col-sm-6'f>><'row'<'col-sm-12'tr>><'row'<'col-sm-5'i><'col-sm-7'p>>",renderer:"bootstrap"});b.extend(f.ext.classes,
{sWrapper:"dataTables_wrapper form-inline dt-bootstrap",sFilterInput:"form-control input-sm",sLengthSelect:"form-control input-sm",sProcessing:"dataTables_processing panel panel-default"});f.ext.renderer.pageButton.bootstrap=function(a,h,r,s,j,n){var o=new f.Api(a),t=a.oClasses,k=a.oLanguage.oPaginate,u=a.oLanguage.oAria.paginate||{},e,g,p=0,q=function(d,f){var l,h,i,c,m=function(a){a.preventDefault();!b(a.currentTarget).hasClass("disabled")&&o.page()!=a.data.action&&o.page(a.data.action).draw("page")};
l=0;for(h=f.length;l<h;l++)if(c=f[l],b.isArray(c))q(d,c);else{g=e="";switch(c){case "ellipsis":e="&#x2026;";g="disabled";break;case "first":e=k.sFirst;g=c+(0<j?"":" disabled");break;case "previous":e=k.sPrevious;g=c+(0<j?"":" disabled");break;case "next":e=k.sNext;g=c+(j<n-1?"":" disabled");break;case "last":e=k.sLast;g=c+(j<n-1?"":" disabled");break;default:e=c+1,g=j===c?"active":""}e&&(i=b("<li>",{"class":t.sPageButton+" "+g,id:0===r&&"string"===typeof c?a.sTableId+"_"+c:null}).append(b("<a>",{href:"#",
"aria-controls":a.sTableId,"aria-label":u[c],"data-dt-idx":p,tabindex:a.iTabIndex}).html(e)).appendTo(d),a.oApi._fnBindAction(i,{action:c},m),p++)}},i;try{i=b(h).find(d.activeElement).data("dt-idx")}catch(v){}q(b(h).empty().html('<ul class="pagination"/>').children("ul"),s);i!==m&&b(h).find("[data-dt-idx="+i+"]").focus()};return f});