* moved admin pages to twig

* edited account.management.html.twig to fit modern templates, tibiacom have its own template
* sample characters are now assigned to admin account and have group_id 4 to not be shown on highscores
* fixed database pages loading
* added require.database plugin option, which will prove if DATABASE_VERSION is enough
This commit is contained in:
slawkens
2017-10-10 15:32:59 +02:00
parent 856e72150c
commit 0a82f306f6
11 changed files with 837 additions and 695 deletions

View File

@@ -26,7 +26,7 @@ $access = 0;
if(!empty($action))
{
if($action == 'delete' || $action == 'edit' || $action == 'hide')
$id = $_REQUEST['id'];
$id = $_REQUEST['id'];
if(isset($_REQUEST['name']))
$name = $_REQUEST['name'];
@@ -83,147 +83,35 @@ if(!empty($action))
if(!empty($errors))
echo $twig->render('error_box.html.twig', array('errors' => $errors));
}
?>
<?php
$use_tinymce = false;
//if($action != 'edit' || !$php)
// $use_tinymce = true;
if($use_tinymce): ?>
<script type="text/javascript" src="tools/tiny_mce/jquery.tinymce.js"></script>
<script type="text/javascript">
$(function() {
$('#news-body').tinymce({
script_url : 'tools/tiny_mce/tiny_mce.js',
forced_root_block : false,
theme : "advanced",
plugins: "safari,advimage,emotions,insertdatetime,preview,wordcount",
theme_advanced_buttons3_add : "emotions,insertdate,inserttime,preview,|,forecolor,backcolor",
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "left",
theme_advanced_statusbar_location : "bottom",
theme_advanced_resizing : true,
});
<?php /*if($action != 'edit'): ?>
$("#page-edit-table").hide();
$("#page-button").click(function() {
$("#page-edit-table").toggle();
return false;
});
<?php endif; */ ?>
});
</script>
<!--script type="text/javascript">
tinyMCE.init({
forced_root_block : false,
mode : "textareas",
theme : "advanced",
plugins: "safari,advimage,emotions,insertdatetime,preview,wordcount",
theme_advanced_buttons3_add : "emotions,insertdate,inserttime,preview,|,forecolor,backcolor",
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "left",
theme_advanced_statusbar_location : "bottom",
theme_advanced_resizing : true,
});
</script-->
<?php endif; ?>
<form method="post" action="?p=pages&action=<?php echo ($action == 'edit' ? 'edit' : 'add'); ?>">
<?php if($action == 'edit'): ?>
<input type="hidden" name="id" value="<?php echo $id; ?>" />
<?php endif; ?>
<table class="table" id="page-edit-table" width="100%" border="0" cellspacing="1" cellpadding="4">
<tr>
<th><b><?php echo ($action == 'edit' ? 'Edit' : 'Add'); ?> page</b></th>
</tr>
<tr>
<td>
<table border="0" cellpadding="1">
<tr>
<td>Link/name:</td>
<td><input name="name" value="<?php echo $name; ?>" size="29" maxlength="29"/></td>
</tr>
<tr>
<td>Title:</td>
<td><input name="title" value="<?php echo $p_title; ?>" size="29" maxlength="29"/></td>
</tr>
<tr>
<td>PHP:</td>
<td><input type="checkbox" id="news-checkbox" name="php" title="Check if page should be executed as PHP" value="1" <?php if($php) echo 'checked="true"'; ?>/></td>
</tr>
<tr>
<td>Content:</td>
<td>
<textarea id="news-body" name="body" maxlength="65000" <?php /*if($use_tinymce) echo 'class="tinymce"';*/ ?> cols="50" rows="5"><?php echo htmlentities(isset($body) ? $body : '', ENT_COMPAT, 'UTF-8'); ?></textarea>
<?php if($use_tinymce): ?>
<br/>
<a href="javascript:;" onmousedown="$('#news-body').tinymce().hide();">[Hide]</a>
<a href="javascript:;" onmousedown="$('#news-body').tinymce().show();">[Show]</a>
<?php endif; ?>
</td>
<tr/>
<tr>
<td>Access:</td>
<td>
<select name="access">
<?php foreach($groups->getGroups() as $id => $group): ?>
<option value="<?php echo $group->getAccess(); ?>" <?php echo ($access == $group->getAccess() ? 'selected' : ''); ?>><?php echo $group->getName(); ?></option>
<?php endforeach; ?>
</select>
</td>
</tr>
<tr>
<td align="right"><input type="submit" class="button" value="Save"/></td>
<td align="left">
<input type="button" onclick="window.location = '<?php echo getLink(PAGE) . ($config['friendly_urls'] ? '?' : '&'); ?>p=pages';" class="button" value="Cancel"/>
</td>
</tr>
</table>
</td>
</tr>
</table>
</form>
<table class="table" width="100%" cellspacing="1" cellpadding="4">
<tr>
<th><b>Name</b></th>
<th><b>Title</b></th>
<th><b>Options</b></th>
</tr>
<?php
$pages =
$query =
$db->query('SELECT * FROM ' . $db->tableName(TABLE_PREFIX . 'pages'));
$i = 0;
foreach($pages as $_page): ?>
<tr>
<td><?php echo getFullLink($_page['name'], $_page['name']); ?></td>
<td><i><?php echo substr($_page['title'], 0, 20); ?></i></td>
<td>
<a href="?p=pages&action=edit&id=<?php echo $_page['id']; ?>" class="ico" title="Edit">
<img src="<?php echo BASE_URL; ?>images/edit.png"/>
Edit
</a>
<a href="<?php echo ADMIN_URL; ?>?p=pages&action=delete&id=<?php echo $_page['id']; ?>" class="ico" onclick="return confirm('Are you sure?');" title="Delete">
<img src="<?php echo BASE_URL; ?>images/del.png"/>
Delete
</a>
<a href="?p=pages&action=hide&id=<?php echo $_page['id']; ?>" class="ico" title="<?php echo ($_page['hidden'] != 1 ? 'Hide' : 'Show'); ?>">
<img src="<?php echo BASE_URL; ?>images/<?php echo ($_page['hidden'] != 1 ? 'success' : 'error'); ?>.png"/>
<?php echo ($_page['hidden'] != 1 ? 'Hide' : 'Show'); ?>
</a>
</td>
</tr>
<?php endforeach; ?>
</table>
$pages = array();
foreach($query as $_page) {
$pages[] = array(
'link' => getFullLink($_page['name'], $_page['name']),
'title' => substr($_page['title'], 0, 20),
'id' => $_page['id'],
'hidden' => $_page['hidden']
);
}
echo $twig->render('admin.pages.form.html.twig', array(
'action' => $action,
'id' => $action == 'edit' ? $id : null,
'name' => $name,
'title' => $p_title,
'php' => $php,
'body' => isset($body) ? htmlentities($body, ENT_COMPAT, 'UTF-8') : '',
'groups' => $groups->getGroups(),
'access' => $access
));
echo $twig->render('admin.pages.html.twig', array(
'pages' => $pages
));
<?php
class Pages
{
static public function get($id)
@@ -243,7 +131,7 @@ class Pages
{
$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, 'access' => $access));
$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 words already exists.';
}