mirror of
https://github.com/slawkens/myaac.git
synced 2025-06-10 14:54:30 +02:00
* added administration panel for screenshots management with auto thumbnail generator
* moved commands & screenshots html code to twig template files * minimum PHP version to install the MyAAC is now 5.2.0 cause of pathinfo (extension) function
This commit is contained in:
parent
7890eb14d1
commit
b62ce7ec6f
@ -43,6 +43,8 @@ define('FLAG_CONTENT_FORUM', 32);
|
||||
define('FLAG_CONTENT_COMMANDS', 64);
|
||||
define('FLAG_CONTENT_SPELLS', 128);
|
||||
define('FLAG_CONTENT_MONSTERS', 256);
|
||||
define('FLAG_CONTENT_SCREENSHOTS', 512);
|
||||
define('FLAG_CONTENT_MOVIES', 1024);
|
||||
|
||||
// news
|
||||
define('NEWS', 1);
|
||||
|
@ -22,7 +22,7 @@ function version_check($name, $ok, $info = '', $warning = false)
|
||||
$failed = false;
|
||||
|
||||
// start validating
|
||||
version_check($locale['step_requirements_php_version'], (PHP_VERSION_ID >= 50102), PHP_VERSION);
|
||||
version_check($locale['step_requirements_php_version'], (PHP_VERSION_ID >= 50200), PHP_VERSION);
|
||||
foreach(array('config.local.php', 'images/guilds', 'images/houses', 'images/screenshots') as $value)
|
||||
{
|
||||
$perms = (int) substr(decoct(fileperms(BASE . $value)), 2);
|
||||
|
@ -35,6 +35,11 @@ $twig = new Twig_Environment($loader, array(
|
||||
'cache' => CACHE . 'twig/',
|
||||
));
|
||||
|
||||
$function = new Twig_SimpleFunction('getStyle', function ($i) {
|
||||
return getStyle($i);
|
||||
});
|
||||
$twig->addFunction($function);
|
||||
|
||||
// trim values we receive
|
||||
if(isset($_POST))
|
||||
{
|
||||
|
@ -71,88 +71,33 @@ if($canEdit)
|
||||
if(!empty($errors))
|
||||
output_errors($errors);
|
||||
}
|
||||
?>
|
||||
<form method="post" action="<?php echo getPageLink('commands', ($action == 'edit' ? 'edit' : 'add')); ?>">
|
||||
<?php if($action == 'edit'): ?>
|
||||
<input type="hidden" name="id" value="<?php echo $id; ?>" />
|
||||
<?php endif; ?>
|
||||
<table width="100%" border="0" cellspacing="1" cellpadding="4">
|
||||
<tr>
|
||||
<td bgcolor="<?php echo $config['vdarkborder']; ?>" class="white"><b><?php echo ($action == 'edit' ? 'Edit' : 'Add'); ?> command</b></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td bgcolor="<?php echo $config['darkborder']; ?>">
|
||||
<table border="0" cellpadding="1">
|
||||
<tr>
|
||||
<td>Words:</td>
|
||||
<td><input name="words" value="<?php echo (isset($words) ? $words : ''); ?>" size="29" maxlength="29"/></td>
|
||||
<tr>
|
||||
<td>Description:</td>
|
||||
<td><textarea name="description" maxlength="300" cols="50" rows="5"><?php echo (isset($description) ? $description : ''); ?></textarea></td>
|
||||
<tr/>
|
||||
<tr>
|
||||
<td colspan="2" align="center"><input type="submit" value="Submit"/>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
<?php
|
||||
|
||||
echo $twig->render('commands.form.html', array(
|
||||
'link' => getPageLink('commands', ($action == 'edit' ? 'edit' : 'add')),
|
||||
'action' => $action,
|
||||
'id' => isset($id) ? $id : null,
|
||||
'vdarkborder' => $config['vdarkborder'],
|
||||
'darkborder' => $config['darkborder'],
|
||||
'words' => isset($words) ? $words : null,
|
||||
'description' => isset($description) ? $description : null
|
||||
));
|
||||
}
|
||||
?>
|
||||
|
||||
<table width="100%" border="0" cellspacing="1" cellpadding="4">
|
||||
<tr>
|
||||
<td bgcolor="<?php echo $config['vdarkborder']; ?>" class="white" width="150"><b>Words</b></td>
|
||||
<td bgcolor="<?php echo $config['vdarkborder']; ?>" class="white"><b>Description</b></td>
|
||||
<?php if($canEdit): ?>
|
||||
<td bgcolor="<?php echo $config['vdarkborder']; ?>" class="white"><b>Options</b></td>
|
||||
<?php endif; ?>
|
||||
</tr>
|
||||
<?php
|
||||
|
||||
$commands =
|
||||
$db->query('SELECT ' . $db->fieldName('id') . ', ' . $db->fieldName('words') . ', ' . $db->fieldName('description') .
|
||||
($canEdit ? ', ' . $db->fieldName('hidden') . ', ' . $db->fieldName('ordering') : '') .
|
||||
' FROM ' . $db->tableName(TABLE_PREFIX . 'commands') .
|
||||
(!$canEdit ? ' WHERE ' . $db->fieldName('hidden') . ' != 1' : '') .
|
||||
' ORDER BY ' . $db->fieldName('ordering'));
|
||||
$db->query('SELECT `id`, `words`, `description`' .
|
||||
($canEdit ? ', `hidden`, `ordering`' : '') .
|
||||
' FROM `' . TABLE_PREFIX . 'commands`' .
|
||||
(!$canEdit ? ' WHERE `hidden` != 1' : '') .
|
||||
' ORDER BY `ordering`;');
|
||||
|
||||
$last = $commands->rowCount();
|
||||
$i = 0;
|
||||
foreach($commands as $command): ?>
|
||||
<tr bgcolor="<?php echo getStyle(++$i); ?>">
|
||||
<td><?php echo $command['words']; ?></td>
|
||||
<td><i><?php echo $command['description']; ?></i></td>
|
||||
<?php if($canEdit): ?>
|
||||
<td>
|
||||
<a href="?subtopic=commands&action=edit&id=<?php echo $command['id']; ?>" title="Edit">
|
||||
<img src="images/edit.png"/>Edit
|
||||
</a>
|
||||
<a id="delete" href="<?php echo BASE_URL; ?>?subtopic=commands&action=delete&id=<?php echo $command['id']; ?>" onclick="return confirm('Are you sure?');" title="Delete">
|
||||
<img src="images/del.png"/>Delete
|
||||
</a>
|
||||
<a href="?subtopic=commands&action=hide&id=<?php echo $command['id']; ?>" title="<?php echo ($command['hidden'] != 1 ? 'Hide' : 'Show'); ?>">
|
||||
<img src="images/<?php echo ($command['hidden'] != 1 ? 'success' : 'error'); ?>.png"/><?php echo ($command['hidden'] != 1 ? 'Hide' : 'Show'); ?>
|
||||
</a>
|
||||
<?php if($i != 1): ?>
|
||||
<a href="?subtopic=commands&action=moveup&id=<?php echo $command['id']; ?>" title="Move up">
|
||||
<img src="images/icons/arrow_up.gif"/>Move up
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
<?php if($i != $last): ?>
|
||||
<a href="?subtopic=commands&action=movedown&id=<?php echo $command['id']; ?>" title="Move down">
|
||||
<img src="images/icons/arrow_down.gif"/>Move down
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<?php endif; ?>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</table>
|
||||
echo $twig->render('commands.html', array(
|
||||
'commands' => $commands,
|
||||
'last' => $last,
|
||||
'canEdit' => $canEdit,
|
||||
'vdarkborder' => $config['vdarkborder']
|
||||
));
|
||||
|
||||
<?php
|
||||
class Commands
|
||||
{
|
||||
static public function add($words, $description, &$errors)
|
||||
@ -202,7 +147,7 @@ class Commands
|
||||
global $db;
|
||||
if(isset($id))
|
||||
{
|
||||
if($db->select(TABLE_PREFIX . 'commands', array('id' => $id)) !== false)
|
||||
if(self::get($id) !== false)
|
||||
$db->delete(TABLE_PREFIX . 'commands', array('id' => $id));
|
||||
else
|
||||
$errors[] = 'Command with id ' . $id . ' does not exists.';
|
||||
@ -218,7 +163,7 @@ class Commands
|
||||
global $db;
|
||||
if(isset($id))
|
||||
{
|
||||
$query = $db->select(TABLE_PREFIX . 'commands', array('id' => $id));
|
||||
$query = self::get($id);
|
||||
if($query !== false)
|
||||
$db->update(TABLE_PREFIX . 'commands', array('hidden' => ($query['hidden'] == 1 ? 0 : 1)), array('id' => $id));
|
||||
else
|
||||
@ -233,7 +178,7 @@ class Commands
|
||||
static public function move($id, $i, &$errors)
|
||||
{
|
||||
global $db;
|
||||
$query = $db->select(TABLE_PREFIX . 'commands', array('id' => $id));
|
||||
$query = self::get($id);
|
||||
if($query !== false)
|
||||
{
|
||||
$ordering = $query['ordering'] + $i;
|
||||
|
@ -3,7 +3,6 @@
|
||||
* Screenshots
|
||||
*
|
||||
* @package MyAAC
|
||||
* @author Gesior <jerzyskalski@wp.pl>
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2017 MyAAC
|
||||
* @version 0.2.4
|
||||
@ -12,9 +11,69 @@
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
$title = 'Screenshots';
|
||||
|
||||
$canEdit = hasFlag(FLAG_CONTENT_SCREENSHOTS) || superAdmin();
|
||||
if($canEdit) {
|
||||
if(function_exists('imagecreatefrompng')) {
|
||||
if (!empty($action)) {
|
||||
if ($action == 'delete' || $action == 'edit' || $action == 'hide' || $action == 'moveup' || $action == 'movedown')
|
||||
$id = $_REQUEST['id'];
|
||||
|
||||
if (isset($_REQUEST['comment']))
|
||||
$comment = stripslashes($_REQUEST['comment']);
|
||||
|
||||
if (isset($_REQUEST['image']))
|
||||
$image = $_REQUEST['image'];
|
||||
|
||||
if (isset($_REQUEST['author']))
|
||||
$author = $_REQUEST['author'];
|
||||
|
||||
$errors = array();
|
||||
|
||||
if ($action == 'add') {
|
||||
if (Screenshots::add($comment, $image, $author, $errors))
|
||||
$comment = $image = $author = '';
|
||||
} else if ($action == 'delete') {
|
||||
Screenshots::delete($id, $errors);
|
||||
} else if ($action == 'edit') {
|
||||
if (isset($id) && !isset($name)) {
|
||||
$screenshot = Screenshots::get($id);
|
||||
$comment = $screenshot['comment'];
|
||||
$image = $screenshot['image'];
|
||||
$author = $screenshot['author'];
|
||||
} else {
|
||||
Screenshots::update($id, $comment, $image, $author);
|
||||
$action = $comment = $image = $author = '';
|
||||
}
|
||||
} else if ($action == 'hide') {
|
||||
Screenshots::toggleHidden($id, $errors);
|
||||
} else if ($action == 'moveup') {
|
||||
Screenshots::move($id, -1, $errors);
|
||||
} else if ($action == 'movedown') {
|
||||
Screenshots::move($id, 1, $errors);
|
||||
}
|
||||
|
||||
if (!empty($errors))
|
||||
output_errors($errors);
|
||||
}
|
||||
|
||||
echo $twig->render('screenshots.form.html', array(
|
||||
'link' => getPageLink('screenshots', ($action == 'edit' ? 'edit' : 'add')),
|
||||
'action' => $action,
|
||||
'id' => isset($id) ? $id : null,
|
||||
'vdarkborder' => $config['vdarkborder'],
|
||||
'darkborder' => $config['darkborder'],
|
||||
'comment' => isset($comment) ? $comment : null,
|
||||
'image' => isset($image) ? $image : null,
|
||||
'author' => isset($author) ? $author : null
|
||||
));
|
||||
}
|
||||
else
|
||||
echo 'You cannot edit/add screenshots as it seems your PHP installation doesnt have GD support enabled. Visit <a href="http://be2.php.net/manual/en/image.installation.php">PHP Manual</a> for more info.';
|
||||
}
|
||||
|
||||
if(isset($_GET['screenshot']))
|
||||
{
|
||||
$screenshot = $db->query('SELECT * FROM ' . $db->tableName(TABLE_PREFIX . 'screenshots') . ' WHERE ' . $db->fieldName('name') . ' = ' . $db->quote($_GET['screenshot']) . ' ORDER by ordering LIMIT 1;');
|
||||
$screenshot = $db->query('SELECT * FROM `' . TABLE_PREFIX . 'screenshots` WHERE `id` = ' . $db->quote($_GET['screenshot']) . ' ORDER by `ordering` LIMIT 1;');
|
||||
if($screenshot->rowCount() == 1)
|
||||
$screenshot = $screenshot->fetch();
|
||||
else
|
||||
@ -23,66 +82,234 @@ if(isset($_GET['screenshot']))
|
||||
return;
|
||||
}
|
||||
|
||||
$previous_screenshot = $db->query('SELECT * FROM ' . $db->tableName(TABLE_PREFIX . 'screenshots') . ' WHERE `id` = ' . $db->quote($screenshot['id'] - 1) . ' ORDER by ordering;');
|
||||
$previous_screenshot = $db->query('SELECT * FROM `' . TABLE_PREFIX . 'screenshots` WHERE `id` = ' . $db->quote($screenshot['id'] - 1) . ' ORDER by `ordering`;');
|
||||
if($previous_screenshot->rowCount() == 1)
|
||||
$previous_screenshot = $previous_screenshot->fetch();
|
||||
else
|
||||
$previous_screenshot = NULL;
|
||||
|
||||
$next_screenshot = $db->query('SELECT * FROM ' . $db->tableName(TABLE_PREFIX . 'screenshots') . ' WHERE `id` = ' . $db->quote($screenshot['id'] + 1) . ' ORDER by ordering;');
|
||||
$next_screenshot = $db->query('SELECT * FROM `' . TABLE_PREFIX . 'screenshots` WHERE `id` = ' . $db->quote($screenshot['id'] + 1) . ' ORDER by `ordering`;');
|
||||
if($next_screenshot->rowCount() == 1)
|
||||
$next_screenshot = $next_screenshot->fetch();
|
||||
else
|
||||
$next_screenshot = NULL;
|
||||
?>
|
||||
<div style="position: relative; height: 15px; width: 100%;">
|
||||
<?php if($next_screenshot): ?>
|
||||
<a style="float: right;" href="?subtopic=screenshots&screenshot=<?php echo $next_screenshot['name']; ?>" >next <img src="images/arrow_right.gif" width=15 height=11 border=0 ></a>
|
||||
<?php endif;
|
||||
if($previous_screenshot): ?>
|
||||
<a style="position: absolute;" href="?subtopic=screenshots&screenshot=<?php echo $previous_screenshot['name']; ?>"><img src="images/arrow_left.gif" width=15 height=11 border=0 > previous</a>
|
||||
<?php endif; ?>
|
||||
<div style="position: absolute; width: 80%; margin-left: 10%; margin-right: 10%; text-align: center;">
|
||||
<a href="?subtopic=screenshots" ><img src="images/arrow_up.gif" width=11 height=15 border=0 > back</a>
|
||||
</div>
|
||||
</div>
|
||||
<div style="position: relative; text-align: center; top: 20px; ">
|
||||
<img src="<?php echo $screenshot['image']; ?>" />
|
||||
<div style="margin-top: 15px; margin-bottom: 35px; "><?php echo $screenshot['comment']; ?></div>
|
||||
</div>
|
||||
<?php
|
||||
|
||||
echo $twig->render('screenshots.get.html', array(
|
||||
'previous' => $previous_screenshot ? $previous_screenshot['id'] : null,
|
||||
'next' => $next_screenshot ? $next_screenshot['id'] : null,
|
||||
'screenshot' => $screenshot
|
||||
));
|
||||
return;
|
||||
}
|
||||
|
||||
$screenshots = $db->query('SELECT * FROM ' . $db->tableName(TABLE_PREFIX . 'screenshots') . ' ORDER BY ' . $db->fieldName('ordering'));
|
||||
if(!$screenshots->rowCount())
|
||||
$screenshots =
|
||||
$db->query('SELECT `id`, `comment`, `image`, `author`, `thumb`' .
|
||||
($canEdit ? ', `hidden`, `ordering`' : '') .
|
||||
' FROM `' . TABLE_PREFIX . 'screenshots`' .
|
||||
(!$canEdit ? ' WHERE `hidden` != 1' : '') .
|
||||
' ORDER BY `ordering`;');
|
||||
|
||||
$last = $screenshots->rowCount();
|
||||
if(!$last)
|
||||
{
|
||||
?>
|
||||
There are no screenshots added to gallery yet.
|
||||
<?php
|
||||
if(admin())
|
||||
echo ' You can add new screenshots in phpmyadmin under ' . TABLE_PREFIX . 'screenshots table.';
|
||||
return;
|
||||
}
|
||||
?>
|
||||
|
||||
Click on the image to enlarge.<br/><br/>
|
||||
<?php foreach($screenshots as $screenshot): ?>
|
||||
<table>
|
||||
<tr>
|
||||
<td style="height: 120px;" >
|
||||
<a href="?subtopic=screenshots&screenshot=<?php echo $screenshot['name']; ?>" >
|
||||
<img src="<?php echo $screenshot['thumb']; ?>" border="0" />
|
||||
</a>
|
||||
</td>
|
||||
<td><?php echo $screenshot['comment']; ?></td>
|
||||
</tr>
|
||||
</table>
|
||||
<?php endforeach;
|
||||
echo $twig->render('screenshots.html', array(
|
||||
'screenshots' => $screenshots,
|
||||
'last' => $last,
|
||||
'canEdit' => $canEdit
|
||||
));
|
||||
|
||||
class Screenshots
|
||||
{
|
||||
|
||||
|
||||
static public function add($comment, $image, $author, &$errors)
|
||||
{
|
||||
global $db;
|
||||
if(isset($comment[0]) && isset($image[0]) && isset($author[0]))
|
||||
{
|
||||
$query =
|
||||
$db->query(
|
||||
'SELECT `ordering`' .
|
||||
' FROM `' . TABLE_PREFIX . 'screenshots`' .
|
||||
' ORDER BY `ordering`' . ' DESC LIMIT 1'
|
||||
);
|
||||
|
||||
$ordering = 0;
|
||||
if($query->rowCount() > 0) {
|
||||
$query = $query->fetch();
|
||||
$ordering = $query['ordering'] + 1;
|
||||
}
|
||||
|
||||
$pathinfo = pathinfo($image);
|
||||
$extension = strtolower($pathinfo['extension']);
|
||||
$thumb_filename = 'images/screenshots/' . $pathinfo['filename'] . '_thumb.' . $extension;
|
||||
$filename = 'images/screenshots/' . $pathinfo['filename'] . '.' . $extension;
|
||||
if($db->insert(TABLE_PREFIX . 'screenshots', array(
|
||||
'comment' => $comment,
|
||||
'image' => $filename, 'author' => $author,
|
||||
'thumb' => $thumb_filename,
|
||||
'ordering' => $ordering))) {
|
||||
if(self::generateThumb($db->lastInsertId(), $image, $errors))
|
||||
self::resize($image, 650, 500, $filename, $errors);
|
||||
}
|
||||
}
|
||||
else
|
||||
$errors[] = 'Please fill all inputs.';
|
||||
|
||||
return !count($errors);
|
||||
}
|
||||
|
||||
static public function get($id) {
|
||||
global $db;
|
||||
return $db->select(TABLE_PREFIX . 'screenshots', array('id' => $id));
|
||||
}
|
||||
|
||||
static public function update($id, $comment, $image, $author) {
|
||||
global $db;
|
||||
|
||||
$pathinfo = pathinfo($image);
|
||||
$extension = strtolower($pathinfo['extension']);
|
||||
$filename = 'images/screenshots/' . $pathinfo['filename'] . '.' . $extension;
|
||||
|
||||
if($db->update(TABLE_PREFIX . 'screenshots', array(
|
||||
'comment' => $comment,
|
||||
'image' => $filename, 'author' => $author),
|
||||
array('id' => $id)
|
||||
)) {
|
||||
if(self::generateThumb($id, $image, $errors))
|
||||
self::resize($image, 650, 500, $filename, $errors);
|
||||
}
|
||||
}
|
||||
|
||||
static public function delete($id, &$errors)
|
||||
{
|
||||
global $db;
|
||||
if(isset($id))
|
||||
{
|
||||
if(self::get($id) !== false)
|
||||
$db->delete(TABLE_PREFIX . 'screenshots', array('id' => $id));
|
||||
else
|
||||
$errors[] = 'Screenshot with id ' . $id . ' does not exists.';
|
||||
}
|
||||
else
|
||||
$errors[] = 'id not set';
|
||||
|
||||
return !count($errors);
|
||||
}
|
||||
|
||||
static public function toggleHidden($id, &$errors)
|
||||
{
|
||||
global $db;
|
||||
if(isset($id))
|
||||
{
|
||||
$query = self::get($id);
|
||||
if($query !== false)
|
||||
$db->update(TABLE_PREFIX . 'screenshots', array('hidden' => ($query['hidden'] == 1 ? 0 : 1)), array('id' => $id));
|
||||
else
|
||||
$errors[] = 'Screenshot with id ' . $id . ' does not exists.';
|
||||
}
|
||||
else
|
||||
$errors[] = 'id not set';
|
||||
|
||||
return !count($errors);
|
||||
}
|
||||
|
||||
static public function move($id, $i, &$errors)
|
||||
{
|
||||
global $db;
|
||||
$query = self::get($id);
|
||||
if($query !== false)
|
||||
{
|
||||
$ordering = $query['ordering'] + $i;
|
||||
$old_record = $db->select(TABLE_PREFIX . 'screenshots', array('ordering' => $ordering));
|
||||
if($old_record !== false)
|
||||
$db->update(TABLE_PREFIX . 'screenshots', array('ordering' => $query['ordering']), array('ordering' => $ordering));
|
||||
|
||||
$db->update(TABLE_PREFIX . 'screenshots', array('ordering' => $ordering), array('id' => $id));
|
||||
}
|
||||
else
|
||||
$errors[] = 'Screenshot with id ' . $id . ' does not exists.';
|
||||
|
||||
return !count($errors);
|
||||
}
|
||||
|
||||
static public function resize($file, $new_width, $new_height, $new_file, &$errors)
|
||||
{
|
||||
$pathinfo = pathinfo($file);
|
||||
$extension = strtolower($pathinfo['extension']);
|
||||
|
||||
switch ($extension)
|
||||
{
|
||||
case 'gif': // GIF
|
||||
$image = imagecreatefromgif($file);
|
||||
break;
|
||||
case 'jpg': // JPEG
|
||||
case 'jpeg':
|
||||
$image = imagecreatefromjpeg($file);
|
||||
break;
|
||||
case 'png': // PNG
|
||||
$image = imagecreatefrompng($file);
|
||||
break;
|
||||
default:
|
||||
$errors[] = 'Unsupported file format.';
|
||||
return false;
|
||||
}
|
||||
|
||||
$width = imagesx($image);
|
||||
$height = imagesy($image);
|
||||
|
||||
// create a new temporary image
|
||||
$tmp_img = imagecreatetruecolor($new_width, $new_height);
|
||||
|
||||
// copy and resize old image into new image
|
||||
imagecopyresized($tmp_img, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
|
||||
|
||||
// save thumbnail into a file
|
||||
switch($extension)
|
||||
{
|
||||
case 'gif':
|
||||
imagegif($tmp_img, $new_file);
|
||||
break;
|
||||
|
||||
case 'jpg':
|
||||
case 'jpeg':
|
||||
imagejpeg($tmp_img, $new_file);
|
||||
break;
|
||||
|
||||
case 'png':
|
||||
imagepng($tmp_img, $new_file);
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static public function generateThumb($id, $file, &$errors)
|
||||
{
|
||||
$pathinfo = pathinfo($file);
|
||||
$extension = strtolower($pathinfo['extension']);
|
||||
$thumb_filename = 'images/screenshots/' . $pathinfo['filename'] . '_thumb.' . $extension;
|
||||
|
||||
if(!self::resize($file, 170, 110, $thumb_filename, $errors))
|
||||
return false;
|
||||
|
||||
global $db;
|
||||
if(isset($id))
|
||||
{
|
||||
$query = self::get($id);
|
||||
if($query !== false)
|
||||
$db->update(TABLE_PREFIX . 'screenshots', array('thumb' => $thumb_filename), array('id' => $id));
|
||||
else
|
||||
$errors[] = 'Screenshot with id ' . $id . ' does not exists.';
|
||||
}
|
||||
else
|
||||
$errors[] = 'id not set';
|
||||
|
||||
return !count($errors);
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
26
system/templates/commands.form.html
Normal file
26
system/templates/commands.form.html
Normal file
@ -0,0 +1,26 @@
|
||||
<form method="post" action="{{ link }}">
|
||||
{% if action == 'edit' %}
|
||||
<input type="hidden" name="id" value="{{ id }}" />
|
||||
{% endif %}
|
||||
<table width="100%" border="0" cellspacing="1" cellpadding="4">
|
||||
<tr>
|
||||
<td bgcolor="{{ vdarkborder }}" class="white"><b>{% if action == 'edit' %}Edit{% else %}Add{% endif %} command</b></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td bgcolor="{{ darkborder }}">
|
||||
<table border="0" cellpadding="1">
|
||||
<tr>
|
||||
<td>Words:</td>
|
||||
<td><input name="words" value="{% if words is not null %}{{ words }}{% endif %}" size="29" maxlength="29"/></td>
|
||||
<tr>
|
||||
<td>Description:</td>
|
||||
<td><textarea name="description" maxlength="300" cols="50" rows="5">{% if description is not null %}{{ description }}{% endif %}</textarea></td>
|
||||
<tr/>
|
||||
<tr>
|
||||
<td colspan="2" align="center"><input type="submit" value="Submit"/>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
40
system/templates/commands.html
Normal file
40
system/templates/commands.html
Normal file
@ -0,0 +1,40 @@
|
||||
<table width="100%" border="0" cellspacing="1" cellpadding="4">
|
||||
<tr>
|
||||
<td bgcolor="{{ vdarkborder }}" class="white" width="150"><b>Words</b></td>
|
||||
<td bgcolor="{{ vdarkborder }}" class="white"><b>Description</b></td>
|
||||
{% if canEdit %}
|
||||
<td bgcolor="{{ vdarkborder }}" class="white"><b>Options</b></td>
|
||||
{% endif %}
|
||||
</tr>
|
||||
{% set i = 0 %}
|
||||
{% for command in commands %}
|
||||
{% set i = i + 1 %}
|
||||
<tr bgcolor="{{ getStyle(i) }}">
|
||||
<td>{{ command.words }}</td>
|
||||
<td><i>{{ command.description }}</i></td>
|
||||
{% if canEdit %}
|
||||
<td>
|
||||
<a href="?subtopic=commands&action=edit&id={{ command.id }}" title="Edit">
|
||||
<img src="images/edit.png"/>Edit
|
||||
</a>
|
||||
<a id="delete" href="?subtopic=commands&action=delete&id={{ command.id }}" onclick="return confirm('Are you sure?');" title="Delete">
|
||||
<img src="images/del.png"/>Delete
|
||||
</a>
|
||||
<a href="?subtopic=commands&action=hide&id={{ command.id }}" title="{% if command.hidden != 1 %}Hide{% else %}Show{% endif %}">
|
||||
<img src="images/{% if command.hidden != 1 %}success{% else %}error{% endif %}.png"/>{% if command.hidden != 1 %}Hide{% else %}Show{% endif %}
|
||||
</a>
|
||||
{% if i != 1 %}
|
||||
<a href="?subtopic=commands&action=moveup&id={{ command.id }}" title="Move up">
|
||||
<img src="images/icons/arrow_up.gif"/>Move up
|
||||
</a>
|
||||
{% endif %}
|
||||
{% if i != last %}
|
||||
<a href="?subtopic=commands&action=movedown&id={{ command.id }}" title="Move down">
|
||||
<img src="images/icons/arrow_down.gif"/>Move down
|
||||
</a>
|
||||
{% endif %}
|
||||
</td>
|
||||
{% endif %}
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
32
system/templates/screenshots.form.html
Normal file
32
system/templates/screenshots.form.html
Normal file
@ -0,0 +1,32 @@
|
||||
<form method="post" action="{{ link }}">
|
||||
{% if action == 'edit' %}
|
||||
<input type="hidden" name="id" value="{{ id }}" />
|
||||
{% endif %}
|
||||
<table width="100%" border="0" cellspacing="1" cellpadding="4">
|
||||
<tr>
|
||||
<td bgcolor="{{ vdarkborder }}" class="white"><b>{% if action == 'edit' %}Edit{% else %}Add{% endif %} screenshot</b></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td bgcolor="{{ darkborder }}">
|
||||
<table border="0" cellpadding="1">
|
||||
<tr>
|
||||
<td>Comment:</td>
|
||||
<td><textarea name="comment" maxlength="255" cols="50" rows="5">{% if comment is not null %}{{ comment }}{% endif %}</textarea></td>
|
||||
<tr/>
|
||||
<tr>
|
||||
<td>Image URL:</td>
|
||||
<td><input name="image" value="{% if image is not null %}{{ image }}{% endif %}" size="50" maxlength="255"/></td>
|
||||
<tr/>
|
||||
<tr>
|
||||
<td>Author:</td>
|
||||
<td><input name="author" value="{% if author is not null %}{{ author }}{% endif %}" size="50" maxlength="50"/></td>
|
||||
<tr/>
|
||||
<tr>
|
||||
<td colspan="2" align="center"><input type="submit" value="Submit"/>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
<br/><br/>
|
16
system/templates/screenshots.get.html
Normal file
16
system/templates/screenshots.get.html
Normal file
@ -0,0 +1,16 @@
|
||||
<div style="position: relative; height: 15px; width: 100%;">
|
||||
<?php if($next_screenshot): ?>
|
||||
{% if next is not null %}
|
||||
<a style="float: right;" href="?subtopic=screenshots&screenshot={{ next }}" >next <img src="images/arrow_right.gif" width=15 height=11 border=0 ></a>
|
||||
{% endif %}
|
||||
{% if previous is not null %}
|
||||
<a style="position: absolute;" href="?subtopic=screenshots&screenshot={{ previous }}"><img src="images/arrow_left.gif" width=15 height=11 border=0 > previous</a>
|
||||
{% endif %}
|
||||
<div style="position: absolute; width: 80%; margin-left: 10%; margin-right: 10%; text-align: center;">
|
||||
<a href="?subtopic=screenshots" ><img src="images/arrow_up.gif" width=11 height=15 border=0 > back</a>
|
||||
</div>
|
||||
</div>
|
||||
<div style="position: relative; text-align: center; top: 20px; ">
|
||||
<img src="{{ screenshot.image }}" />
|
||||
<div style="margin-top: 15px; margin-bottom: 35px; ">{{ screenshot.comment }}</div>
|
||||
</div>
|
38
system/templates/screenshots.html
Normal file
38
system/templates/screenshots.html
Normal file
@ -0,0 +1,38 @@
|
||||
Click on the image to enlarge.<br/><br/>
|
||||
{% set i = 0 %}
|
||||
{% for screenshot in screenshots %}
|
||||
{% set i = i + 1 %}
|
||||
<table>
|
||||
<tr>
|
||||
<td style="height: 120px;" >
|
||||
<a href="?subtopic=screenshots&screenshot={{ screenshot.id }}" >
|
||||
<img src="{{ screenshot.thumb }}" border="0" />
|
||||
</a>
|
||||
</td>
|
||||
<td>{{ screenshot.comment }}</td>
|
||||
{% if canEdit %}
|
||||
<td>
|
||||
<a href="?subtopic=screenshots&action=edit&id={{ screenshot.id }}" title="Edit">
|
||||
<img src="images/edit.png"/>Edit
|
||||
</a>
|
||||
<a id="delete" href="?subtopic=screenshots&action=delete&id={{ screenshot.id }}" onclick="return confirm('Are you sure?');" title="Delete">
|
||||
<img src="images/del.png"/>Delete
|
||||
</a>
|
||||
<a href="?subtopic=screenshots&action=hide&id={{ screenshot.id }}" title="{% if screenshot.hidden != 1 %}Hide{% else %}Show{% endif %}">
|
||||
<img src="images/{% if screenshot.hidden != 1 %}success{% else %}error{% endif %}.png"/>{% if screenshot.hidden != 1 %}Hide{% else %}Show{% endif %}
|
||||
</a>
|
||||
{% if i != 1 %}
|
||||
<a href="?subtopic=screenshots&action=moveup&id={{ screenshot.id }}" title="Move up">
|
||||
<img src="images/icons/arrow_up.gif"/>Move up
|
||||
</a>
|
||||
{% endif %}
|
||||
{% if i != last %}
|
||||
<a href="?subtopic=screenshots&action=movedown&id={{ screenshot.id }}" title="Move down">
|
||||
<img src="images/icons/arrow_down.gif"/>Move down
|
||||
</a>
|
||||
{% endif %}
|
||||
</td>
|
||||
{% endif %}
|
||||
</tr>
|
||||
</table>
|
||||
{% endfor %}
|
Loading…
x
Reference in New Issue
Block a user