* renamed screenshots to gallery and movies to videos

This commit is contained in:
slawkens
2017-10-16 09:25:26 +02:00
parent 3fef1a6eec
commit dd572b00d0
23 changed files with 206 additions and 177 deletions

View File

@@ -1,6 +1,6 @@
<?php
/**
* Screenshots
* Gallery
*
* @package MyAAC
* @author Slawkens <slawkens@gmail.com>
@@ -9,9 +9,9 @@
* @link http://my-aac.org
*/
defined('MYAAC') or die('Direct access not allowed!');
$title = 'Screenshots';
$title = 'Gallery';
$canEdit = hasFlag(FLAG_CONTENT_SCREENSHOTS) || superAdmin();
$canEdit = hasFlag(FLAG_CONTENT_GALLERY) || superAdmin();
if($canEdit) {
if(function_exists('imagecreatefrompng')) {
if (!empty($action)) {
@@ -30,34 +30,34 @@ if($canEdit) {
$errors = array();
if ($action == 'add') {
if (Screenshots::add($comment, $image, $author, $errors))
if (Gallery::add($comment, $image, $author, $errors))
$comment = $image = $author = '';
} else if ($action == 'delete') {
Screenshots::delete($id, $errors);
Gallery::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'];
$tmp = Gallery::get($id);
$comment = $tmp['comment'];
$image = $tmp['image'];
$author = $tmp['author'];
} else {
Screenshots::update($id, $comment, $image, $author);
Gallery::update($id, $comment, $image, $author);
$action = $comment = $image = $author = '';
}
} else if ($action == 'hide') {
Screenshots::toggleHidden($id, $errors);
Gallery::toggleHidden($id, $errors);
} else if ($action == 'moveup') {
Screenshots::move($id, -1, $errors);
Gallery::move($id, -1, $errors);
} else if ($action == 'movedown') {
Screenshots::move($id, 1, $errors);
Gallery::move($id, 1, $errors);
}
if (!empty($errors))
echo $twig->render('error_box.html.twig', array('errors' => $errors));
}
echo $twig->render('screenshots.form.html.twig', array(
'link' => getLink('screenshots/' . ($action == 'edit' ? 'edit' : 'add')),
echo $twig->render('gallery.form.html.twig', array(
'link' => getLink('gallery/' . ($action == 'edit' ? 'edit' : 'add')),
'action' => $action,
'id' => isset($id) ? $id : null,
'comment' => isset($comment) ? $comment : null,
@@ -66,63 +66,63 @@ if($canEdit) {
));
}
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.';
echo 'You cannot edit/add gallery items 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']))
if(isset($_GET['image']))
{
$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();
$image = $db->query('SELECT * FROM `' . TABLE_PREFIX . 'gallery` WHERE `id` = ' . $db->quote($_GET['image']) . ' ORDER by `ordering` LIMIT 1;');
if($image->rowCount() == 1)
$image = $image->fetch();
else
{
echo 'Screenshot with this name does not exists.';
echo 'Image with this name does not exists.';
return;
}
$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();
$previous_image = $db->query('SELECT * FROM `' . TABLE_PREFIX . 'gallery` WHERE `id` = ' . $db->quote($image['id'] - 1) . ' ORDER by `ordering`;');
if($previous_image->rowCount() == 1)
$previous_image = $previous_image->fetch();
else
$previous_screenshot = NULL;
$previous_image = NULL;
$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();
$next_image = $db->query('SELECT * FROM `' . TABLE_PREFIX . 'gallery` WHERE `id` = ' . $db->quote($image['id'] + 1) . ' ORDER by `ordering`;');
if($next_image->rowCount() == 1)
$next_image = $next_image->fetch();
else
$next_screenshot = NULL;
$next_image = NULL;
echo $twig->render('screenshots.get.html.twig', array(
'previous' => $previous_screenshot ? $previous_screenshot['id'] : null,
'next' => $next_screenshot ? $next_screenshot['id'] : null,
'screenshot' => $screenshot
echo $twig->render('gallery.get.html.twig', array(
'previous' => $previous_image ? $previous_image['id'] : null,
'next' => $next_image ? $next_image['id'] : null,
'image' => $image
));
return;
}
$screenshots =
$images =
$db->query('SELECT `id`, `comment`, `image`, `author`, `thumb`' .
($canEdit ? ', `hidden`, `ordering`' : '') .
' FROM `' . TABLE_PREFIX . 'screenshots`' .
' FROM `' . TABLE_PREFIX . 'gallery`' .
(!$canEdit ? ' WHERE `hidden` != 1' : '') .
' ORDER BY `ordering`;');
$last = $screenshots->rowCount();
$last = $images->rowCount();
if(!$last)
{
?>
There are no screenshots added to gallery yet.
There are no images added to gallery yet.
<?php
return;
}
echo $twig->render('screenshots.html.twig', array(
'screenshots' => $screenshots,
echo $twig->render('gallery.html.twig', array(
'images' => $images,
'last' => $last,
'canEdit' => $canEdit
));
class Screenshots
class Gallery
{
static public function add($comment, $image, $author, &$errors)
{
@@ -132,7 +132,7 @@ class Screenshots
$query =
$db->query(
'SELECT `ordering`' .
' FROM `' . TABLE_PREFIX . 'screenshots`' .
' FROM `' . TABLE_PREFIX . 'gallery`' .
' ORDER BY `ordering`' . ' DESC LIMIT 1'
);
@@ -144,9 +144,9 @@ class Screenshots
$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(
$thumb_filename = 'images/gallery/' . $pathinfo['filename'] . '_thumb.' . $extension;
$filename = 'images/gallery/' . $pathinfo['filename'] . '.' . $extension;
if($db->insert(TABLE_PREFIX . 'gallery', array(
'comment' => $comment,
'image' => $filename, 'author' => $author,
'thumb' => $thumb_filename,
@@ -163,7 +163,7 @@ class Screenshots
static public function get($id) {
global $db;
return $db->select(TABLE_PREFIX . 'screenshots', array('id' => $id));
return $db->select(TABLE_PREFIX . 'gallery', array('id' => $id));
}
static public function update($id, $comment, $image, $author) {
@@ -171,9 +171,9 @@ class Screenshots
$pathinfo = pathinfo($image);
$extension = strtolower($pathinfo['extension']);
$filename = 'images/screenshots/' . $pathinfo['filename'] . '.' . $extension;
$filename = 'images/gallery/' . $pathinfo['filename'] . '.' . $extension;
if($db->update(TABLE_PREFIX . 'screenshots', array(
if($db->update(TABLE_PREFIX . 'gallery', array(
'comment' => $comment,
'image' => $filename, 'author' => $author),
array('id' => $id)
@@ -189,9 +189,9 @@ class Screenshots
if(isset($id))
{
if(self::get($id) !== false)
$db->delete(TABLE_PREFIX . 'screenshots', array('id' => $id));
$db->delete(TABLE_PREFIX . 'gallery', array('id' => $id));
else
$errors[] = 'Screenshot with id ' . $id . ' does not exists.';
$errors[] = 'Image with id ' . $id . ' does not exists.';
}
else
$errors[] = 'id not set';
@@ -206,9 +206,9 @@ class Screenshots
{
$query = self::get($id);
if($query !== false)
$db->update(TABLE_PREFIX . 'screenshots', array('hidden' => ($query['hidden'] == 1 ? 0 : 1)), array('id' => $id));
$db->update(TABLE_PREFIX . 'gallery', array('hidden' => ($query['hidden'] == 1 ? 0 : 1)), array('id' => $id));
else
$errors[] = 'Screenshot with id ' . $id . ' does not exists.';
$errors[] = 'Image with id ' . $id . ' does not exists.';
}
else
$errors[] = 'id not set';
@@ -223,14 +223,14 @@ class Screenshots
if($query !== false)
{
$ordering = $query['ordering'] + $i;
$old_record = $db->select(TABLE_PREFIX . 'screenshots', array('ordering' => $ordering));
$old_record = $db->select(TABLE_PREFIX . 'gallery', array('ordering' => $ordering));
if($old_record !== false)
$db->update(TABLE_PREFIX . 'screenshots', array('ordering' => $query['ordering']), array('ordering' => $ordering));
$db->update(TABLE_PREFIX . 'gallery', array('ordering' => $query['ordering']), array('ordering' => $ordering));
$db->update(TABLE_PREFIX . 'screenshots', array('ordering' => $ordering), array('id' => $id));
$db->update(TABLE_PREFIX . 'gallery', array('ordering' => $ordering), array('id' => $id));
}
else
$errors[] = 'Screenshot with id ' . $id . ' does not exists.';
$errors[] = 'Image with id ' . $id . ' does not exists.';
return !count($errors);
}
@@ -290,7 +290,7 @@ class Screenshots
{
$pathinfo = pathinfo($file);
$extension = strtolower($pathinfo['extension']);
$thumb_filename = 'images/screenshots/' . $pathinfo['filename'] . '_thumb.' . $extension;
$thumb_filename = 'images/gallery/' . $pathinfo['filename'] . '_thumb.' . $extension;
if(!self::resize($file, 170, 110, $thumb_filename, $errors))
return false;
@@ -300,9 +300,9 @@ class Screenshots
{
$query = self::get($id);
if($query !== false)
$db->update(TABLE_PREFIX . 'screenshots', array('thumb' => $thumb_filename), array('id' => $id));
$db->update(TABLE_PREFIX . 'gallery', array('thumb' => $thumb_filename), array('id' => $id));
else
$errors[] = 'Screenshot with id ' . $id . ' does not exists.';
$errors[] = 'Image with id ' . $id . ' does not exists.';
}
else
$errors[] = 'id not set';

View File

@@ -1,28 +0,0 @@
<?php
/**
* Movies
*
* @package MyAAC
* @author Slawkens <slawkens@gmail.com>
* @copyright 2017 MyAAC
* @version 0.5.1
* @link http://my-aac.org
*/
defined('MYAAC') or die('Direct access not allowed!');
$title = 'Movies';
$movies = $db->query('SELECT * FROM `' . TABLE_PREFIX . 'movies` ORDER BY `ordering`;');
if(!$movies->rowCount())
{
?>
There are no movies added yet.
<?php
if(admin())
echo ' You can add new movies in phpmyadmin under ' . TABLE_PREFIX . 'movies table.';
return;
}
echo $twig->render('movies.html.twig', array(
'movies' => $movies
));
?>

28
system/pages/videos.php Normal file
View File

@@ -0,0 +1,28 @@
<?php
/**
* Videos
*
* @package MyAAC
* @author Slawkens <slawkens@gmail.com>
* @copyright 2017 MyAAC
* @version 0.5.1
* @link http://my-aac.org
*/
defined('MYAAC') or die('Direct access not allowed!');
$title = 'Videos';
$videos = $db->query('SELECT * FROM `' . TABLE_PREFIX . 'videos` ORDER BY `ordering`;');
if(!$videos->rowCount())
{
?>
There are no videos added yet.
<?php
if(admin())
echo ' You can add new videos in phpmyadmin under ' . TABLE_PREFIX . 'videos table.';
return;
}
echo $twig->render('videos.html.twig', array(
'videos' => $videos
));
?>