Screenshots

* reworked upload process to be more user-friendly
  * handle bricks that consist mostly of localized text separately
  * added handle to display errors, when adding CommunityContent on the page they originated from
This commit is contained in:
Sarjuuk
2015-07-09 23:31:57 +02:00
parent f6d80cf473
commit 08270ae09e
19 changed files with 1518 additions and 370 deletions

View File

@@ -1395,11 +1395,11 @@ class Util
public static function createHash($length = 40) // just some random numbers for unsafe identifictaion purpose
{
static $seed = ".abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
static $seed = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
$hash = '';
for ($i = 0; $i < $length; $i++)
$hash .= substr($seed, mt_rand(0, 62), 1);
$hash .= substr($seed, mt_rand(0, 61), 1);
return $hash;
}

View File

@@ -8,7 +8,10 @@ class Lang
private static $user;
private static $mail;
private static $game;
private static $maps;
private static $screenshot;
// types
private static $achievement;
private static $chrClass;
private static $currency;
@@ -17,7 +20,6 @@ class Lang
private static $gameObject;
private static $item;
private static $itemset;
private static $maps;
private static $npc;
private static $pet;
private static $quest;

View File

@@ -143,30 +143,24 @@ $lang = array(
'genericError' => "Ein Fehler trat auf; aktualisiert die Seite und versucht es nochmal. Wenn der Fehler bestehen bleibt, bitte meldet es bei <a href='#contact'>feedback</a>", # LANG.genericerror
'bannedRating' => "Ihr wurdet davon gesperrt, Kommentare zu bewerten.", # LANG.tooltip_banned_rating
'tooManyVotes' => "Ihr habt die tägliche Grenze für erlaubte Bewertungen erreicht. Kommt morgen mal wieder!", # LANG.tooltip_too_many_votes
// screenshots
'prepError' => "Bei der Aufbereitung eures Screenshots ist ein Fehler aufgetreten",
'cropHint' => "Schneidet das Bild zu, indem ihr die Auswahl verschiebt.<br>Bitte beachtet <a href=\"?help=screenshots-tips-tricks\">Screenshots: Tipps & Tricks</a> für eine optimale Darstellung.",
),
'screenshot' => array(
'submission' => "Screenshot-Einsendung",
'selectAll' => "Alles auswählen",
'cropHint' => "Ihr könnt Euren Screenshot zuschneiden und beschriften.",
'displayOn' => "Hochgeladen für:[br]%s - [%s=%d]",
'caption' => "Kurzbeschreibung",
'originalSize' => "Originalgröße",
'targetSize' => "Zielgröße",
'minSize' => "Mindestgröße",
'displayOn' => "Hochgeladen für: %s[br][%s=%d]",
'ssEdit' => "Screenshot bearbeiten",
'ssUpload' => "Screenshot hochladen",
'ssSubmit' => "Screenshot einsenden",
'ssErrors' => array(
'noUpload' => "Die Datei wurde nicht hochgeladen!",
'maxSize' => "Die Datei überschreitet die max. Größe von %s!",
'interrupted' => "Der Vorgang wurde unterbrochen!",
'noFile' => "Es wurde keine Datei empfangen!",
'noDest' => "Die Seite auf welcher der Screenshot angezeigt werden sollte existiert nicht!",
'charLimit' => "Optional, bis zu 200 Zeichen",
'thanks' => array(
'contrib' => "Vielen Dank für Euren Beitrag!",
'goBack' => '<a href="?%s=%d">Klickt hier</a>, um zu der vorherigen Seite zurückzukehren.',
'note' => "Hinweis: Euer Screenshot muss zunächst zugelassen werden, bevor es auf der Seite erscheint. Dies kann bis zu 72 Stunden dauern."
),
'error' => array(
'unkFormat' => "Unbekanntes Bildformat.",
'tooSmall' => "Euer Screenshot ist viel zu klein. (&lt; ".CFG_SCREENSHOT_MIN_SIZE."x".CFG_SCREENSHOT_MIN_SIZE.").",
'selectSS' => "Wählt bitte den Screenshot aus, den Ihr hochladen möchtet.",
'notAllowed' => "Es ist euch nicht erlaubt einen Screenshot hochzuladen!",
'noImage' => "Die hochgeladene Datei ist kein Bild!",
'wrongFormat' => "Das Bild muss im PNG oder JPG-Format sein!",
'load' => "Das Bild konnte nicht geladen werden!",
'tooSmall' => "Die Abmessungen sind zu klein! (kleiner als %d x %d)",
'tooLarge' => "Die Abmessungen sind zu groß! (größer als %d x %d)"
)
),
'game' => array(

View File

@@ -138,30 +138,24 @@ $lang = array(
'genericError' => "An error has occurred; refresh the page and try again. If the error persists email <a href=\"#contact\">feedback</a>", # LANG.genericerror
'bannedRating' => "You have been banned from rating comments.", # LANG.tooltip_banned_rating
'tooManyVotes' => "You have reached the daily voting cap. Come back tomorrow!", # LANG.tooltip_too_many_votes
// screenshots
'prepError' => "An error occured preparing your screenshot",
'cropHint' => "Crop the image by dragging the selection.<br>Please refer to <a href=\"?help=screenshots-tips-tricks\">Screenshots: Tips & Tricks</a> for an optimal layout.",
),
'screenshot' => array(
'submission' => "Screenshot Submission",
'selectAll' => "Select all",
'cropHint' => "You may crop your screenshot and enter a caption.",
'displayOn' => "Displayed on:[br]%s - [%s=%d]",
'caption' => "Caption",
'originalSize' => "Original size",
'targetSize' => "Target size",
'minSize' => "Minimum size",
'displayOn' => "Displayed on: %s[br][%s=%d]",
'ssEdit' => "Edit uploaded screenshot",
'ssUpload' => "Screenshot Upload",
'ssSubmit' => "Submit Screenshot",
'ssErrors' => array(
'noUpload' => "The file was not uploaded!",
'maxSize' => "The file exceeds the maximum size of %s!",
'interrupted' => "The upload process was interrupted!",
'noFile' => "The file was not received!",
'noDest' => "The page this screenshot should be displayed on, does not exist!",
'charLimit' => "Optional, up to 200 characters",
'thanks' => array(
'contrib' => "Thanks a lot for your contribution!",
'goBack' => '<a href="?%s=%d">Click here</a> to go back to the page you came from.',
'note' => "Note: Your screenshot will need to be approved before appearing on the site. This can take up to 72 hours."
),
'error' => array(
'unkFormat' => "Unknown image format.",
'tooSmall' => "Your screenshot is way too small. (&lt; ".CFG_SCREENSHOT_MIN_SIZE."x".CFG_SCREENSHOT_MIN_SIZE.").",
'selectSS' => "Please select the screenshot to upload.",
'notAllowed' => "You are not allowed to upload screenshots!",
'noImage' => "The uploaded file is not an image file!",
'wrongFormat' => "The image file must be a png or jpg!",
'load' => "The image file could not be loaded!",
'tooSmall' => "The image size is too small! (lower than %d x %d)",
'tooLarge' => "The image size is too large! (greater than %d x %d)"
)
),
'game' => array(

View File

@@ -143,30 +143,24 @@ $lang = array(
'genericError' => "Ha ocurrido un error; refresca la página e inténtalo de nuevo. Si el error persiste manda un correo a <a href='#contact'>feedback</a>", # LANG.genericerror
'bannedRating' => "Has sido baneado y no podrás valorar comentarios.", # LANG.tooltip_banned_rating
'tooManyVotes' => "Has alcanzado el límite diario de votos. Vuelve mañana.", # LANG.tooltip_too_many_votes
// screenshots
'prepError' => "[An error occured preparing your screenshot]",
'cropHint' => "[Crop the image by dragging the selection.<br>Please refer to <a href=\"?help=screenshots-tips-tricks\">Screenshots: Tips & Tricks</a> for an optimal layout.]",
),
'screenshot' => array(
'submission' => "Enviar una captura de pantalla",
'selectAll' => "Seleccionar todos",
'cropHint' => "Puede reducir su imagen e introducir una etiqueta.",
'displayOn' => "[Displayed on:[br]%s - [%s=%d]]",
'caption' => "[Caption]",
'originalSize' => "[Original size]",
'targetSize' => "[Target size]",
'minSize' => "[Minimum size]",
'displayOn' => "[Displayed on: %s[br][%s=%d]]",
'ssEdit' => "[Edit uploaded screenshot]",
'ssUpload' => "[Screenshot Upload]",
'ssSubmit' => "[Submit Screenshot]",
'ssErrors' => array(
'noUpload' => "[The file was not uploaded!]",
'maxSize' => "[The file exceeds the maximum size of %s!]",
'interrupted' => "[The upload process was interrupted!]",
'noFile' => "[The file was not received!]",
'noDest' => "[The page this screenshot should be displayed on, does not exist!]",
'charLimit' => "Opcional, hasta 200 caracteres",
'thanks' => array(
'contrib' => "¡Muchísimas gracias por tu aportación!",
'goBack' => '<a href="?%s=%d">aquí vuelve</a> a la página de la que viniste.',
'note' => "Nota: Su captura de imagen tiene que ser aprobada antes de que pueda aparecer en el sitio. Esto puede tomar hasta 72 horas."
),
'error' => array(
'unkFormat' => "Formato de imagen desconocido.",
'tooSmall' => "Su captura de pantalla es muy pequeña. (&lt; ".CFG_SCREENSHOT_MIN_SIZE."x".CFG_SCREENSHOT_MIN_SIZE.").",
'selectSS' => "Por favor seleccione la captura de pantalla para subir.",
'notAllowed' => "[You are not allowed to upload screenshots!]",
'noImage' => "[The uploaded file is not an image file!]",
'wrongFormat' => "[The image file must be a png or jpg!]",
'load' => "[The image file could not be loaded!]",
'tooSmall' => "[The image size is too small! (lower than %d x %d)]",
'tooLarge' => "[The image size is too large! (greater than %d x %d)]"
)
),
'game' => array(

View File

@@ -143,30 +143,24 @@ $lang = array(
'genericError' => "Une erreur est survenue; Actualisez la page et essayez à nouveau. Si l'erreur persiste, envoyez un email à <a href='#contact'>feedback</a>", # LANG.genericerror
'bannedRating' => "Vous avez été banni du score des commentaires.", # LANG.tooltip_banned_rating
'tooManyVotes' => "Vous avez voté trop souvent aujourd'hui! Revenez demain.", # LANG.tooltip_too_many_votes
// screenshots
'prepError' => "[An error occured preparing your screenshot]",
'cropHint' => "[Crop the image by dragging the selection.<br>Please refer to <a href=\"?help=screenshots-tips-tricks\">Screenshots: Tips & Tricks</a> for an optimal layout.]",
),
'screenshot' => array(
'submission' => "Envoi d'une capture d'écran",
'selectAll' => "Sélectionner tout",
'cropHint' => "Vous pouvez recadrer votre capture d'écran.",
'displayOn' => "[Displayed on:[br]%s - [%s=%d]]",
'caption' => "[Caption]",
'originalSize' => "[Original size]",
'targetSize' => "[Target size]",
'minSize' => "[Minimum size]",
'displayOn' => "[Displayed on: %s[br][%s=%d]]",
'ssEdit' => "[Edit uploaded screenshot]",
'ssUpload' => "[Screenshot Upload]",
'ssSubmit' => "[Submit Screenshot]",
'ssErrors' => array(
'noUpload' => "[The file was not uploaded!]",
'maxSize' => "[The file exceeds the maximum size of %s!]",
'interrupted' => "[The upload process was interrupted!]",
'noFile' => "[The file was not received!]",
'noDest' => "[The page this screenshot should be displayed on, does not exist!]",
'charLimit' => "Optionnel, jusqu'à 200 caractères",
'thanks' => array(
'contrib' => "Merci beaucoup de votre contribution!",
'goBack' => '<a href="?%s=%d">ici</a> pour retourner à la page d\'où vous venez.',
'note' => "Note : Votre capture d'écran devra être approuvée avant d'apparaître sur le site. Cela peut prendre jusqu'à 72 heures."
),
'error' => array(
'unkFormat' => "Format d'image inconnu.",
'tooSmall' => "Votre capture est bien trop petite. (&lt; ".CFG_SCREENSHOT_MIN_SIZE."x".CFG_SCREENSHOT_MIN_SIZE.").",
'selectSS' => "Veuillez sélectionner la capture d'écran à envoyer.",
'notAllowed' => "[You are not allowed to upload screenshots!]",
'noImage' => "[The uploaded file is not an image file!]",
'wrongFormat' => "[The image file must be a png or jpg!]",
'load' => "[The image file could not be loaded!]",
'tooSmall' => "[The image size is too small! (lower than %d x %d)]",
'tooLarge' => "[The image size is too large! (greater than %d x %d)]"
)
),
'game' => array(

View File

@@ -143,30 +143,24 @@ $lang = array(
'genericError' => "Произошла ошибка; обновите страницу и попробуйте снова. Если ситуация повторяется, отправьте сообщение на <a href='#contact'>feedback</a>", # LANG.genericerror
'bannedRating' => "Вам была заблокирована возможность оценивать комментарии.", # LANG.tooltip_banned_rating
'tooManyVotes' => "Вы сегодня проголосовали слишком много раз! Вы сможете продолжить завтра.", # LANG.tooltip_too_many_votes
// screenshots
'prepError' => "[An error occured preparing your screenshot]",
'cropHint' => "[Crop the image by dragging the selection.<br>Please refer to <a href=\"?help=screenshots-tips-tricks\">Screenshots: Tips & Tricks</a> for an optimal layout.]",
),
'screenshot' => array(
'submission' => "Добавление изображения",
'selectAll' => "Выбрать всё",
'cropHint' => "Вы можете произвести кадрирование изображения и указать заголовок.",
'displayOn' => "[Displayed on:[br]%s - [%s=%d]]",
'caption' => "[Caption]",
'originalSize' => "[Original size]",
'targetSize' => "[Target size]",
'minSize' => "[Minimum size]",
'displayOn' => "[Displayed on: %s[br][%s=%d]]",
'ssEdit' => "[Edit uploaded screenshot]",
'ssUpload' => "[Screenshot Upload]",
'ssSubmit' => "[Submit Screenshot]",
'ssErrors' => array(
'noUpload' => "[The file was not uploaded!]",
'maxSize' => "[The file exceeds the maximum size of %s!]",
'interrupted' => "[The upload process was interrupted!]",
'noFile' => "[The file was not received!]",
'noDest' => "[The page this screenshot should be displayed on, does not exist!]",
'charLimit' => "Не обязательно, вплоть до 200 знаков",
'thanks' => array(
'contrib' => "Спасибо за ваш вклад!",
'goBack' => '<a href="?%s=%d">здесь</a> чтобы перейти к предыдущей странице.',
'note' => "Примечание: Перед появлением на сайте, ваше изображение должно быть одобрено. Это может занять до 72 часов."
),
'error' => array(
'unkFormat' => "неизвестный формат изображения.",
'tooSmall' => "Изображение слишком маленькое. (&lt; ".CFG_SCREENSHOT_MIN_SIZE."x".CFG_SCREENSHOT_MIN_SIZE.").",
'selectSS' => "Выберите изображение для загрузки.",
'notAllowed' => "[You are not allowed to upload screenshots!]",
'noImage' => "[The uploaded file is not an image file!]",
'wrongFormat' => "[The image file must be a png or jpg!]",
'load' => "[The image file could not be loaded!]",
'tooSmall' => "[The image size is too small! (lower than %d x %d)]",
'tooLarge' => "[The image size is too large! (greater than %d x %d)]"
)
),
'game' => array(

View File

@@ -10,7 +10,11 @@ trait DetailPage
protected $category = null; // not used on detail pages
protected $lvTabs = []; // most pages have this
private $subject = null; // so it will not get cached
protected $ssError = null;
protected $coError = null;
protected $viError = null;
protected $subject = null; // so it will not get cached
protected function generateCacheKey($withStaff = true)
{
@@ -25,6 +29,21 @@ trait DetailPage
return implode('_', $key);
}
protected function applyCCErrors()
{
if (!empty($_SESSION['error']['co']))
$this->coError = $_SESSION['error']['co'];
if (!empty($_SESSION['error']['ss']))
$this->ssError = $_SESSION['error']['ss'];
if (!empty($_SESSION['error']['vi']))
$this->viError = $_SESSION['error']['vi'];
unset($_SESSION['error']);
}
}
@@ -133,6 +152,10 @@ class GenericPage
$this->maintenance();
else if (CFG_MAINTENANCE && User::isInGroup(U_GROUP_EMPLOYEE))
Util::addNote(U_GROUP_EMPLOYEE, 'Maintenance mode enabled!');
// get errors from previous page from session and apply to template
if (method_exists($this, 'applyCCErrors'))
$this->applyCCErrors();
}
/**********/
@@ -369,8 +392,8 @@ class GenericPage
array_unshift($this->title, Lang::main('nfPageTitle'));
$this->notFound = array(
'title' => $this->typeId ? Util::ucFirst($title).' #'.$this->typeId : $title,
'msg' => !$msg && $this->typeId ? sprintf(Lang::main('pageNotFound'), $title) : $msg
'title' => isset($this->typeId) ? Util::ucFirst($title).' #'.$this->typeId : $title,
'msg' => !$msg && isset($this->typeId) ? sprintf(Lang::main('pageNotFound'), $title) : $msg
);
$this->hasComContent = false;
Util::arraySumByKey($this->mysql, DB::Aowow()->getStatistics(), DB::World()->getStatistics());
@@ -509,6 +532,19 @@ class GenericPage
include('template/listviews/'.$file.'.tpl.php');
}
public function localizedBrick($file, $loc = LOCALE_EN) // load brick with more text then vars
{
if (!$this->isSaneInclude('template/localized/', $file.'_'.$loc))
{
if ($loc == LOCALE_EN || !$this->isSaneInclude('template/localized/', $file.'_'.LOCALE_EN))
echo User::isInGroup(U_GROUP_EMPLOYEE) ? "\n\nError: nonexistant template requested: template/localized/".$file.'_'.$loc.".tpl.php\n\n" : null;
else
include('template/localized/'.$file.'_'.LOCALE_EN.'.tpl.php');
}
else
include('template/localized/'.$file.'_'.$loc.'.tpl.php');
}
/**********************/
/* Prepare js-Globals */
/**********************/
@@ -662,6 +698,7 @@ class GenericPage
if (!CFG_CACHE_MODE || CFG_DEBUG)
return;
$noCache = ['coError', 'ssError', 'viError'];
$cKey = $this->generateCacheKey();
$cache = [];
if (!$saveString)
@@ -672,6 +709,7 @@ class GenericPage
{
// public, protected and an undocumented flag added to properties created on the fly..?
if ((new ReflectionProperty($this, $key))->getModifiers() & 0x1300)
if (!in_array($key, $noCache))
$cache[$key] = $val;
}
catch (ReflectionException $e) { } // shut up!

View File

@@ -7,84 +7,194 @@ if (!defined('AOWOW_REVISION'))
class ScreenshotPage extends GenericPage
{
const MAX_W = 488;
const MAX_H = 325;
protected $tpl = 'screenshot';
protected $js = ['Cropper.js'];
protected $css = [['path' => 'Cropper.css']];
protected $reqAuth = true;
protected $tabId = 0;
private $tmpPath = 'static/uploads/temp/';
private $pendingPath = 'static/uploads/screenshots/pending/';
private $destination = null;
private $minSize = CFG_SCREENSHOT_MIN_SIZE;
protected $validCats = ['add', 'crop', 'complete', 'thankyou'];
protected $destType = 0;
protected $destTypeId = 0;
protected $imgHash = '';
public function __construct($pageCall, $pageParam)
{
parent::__construct($pageCall, $pageParam);
$this->name = Lang::main('ssEdit');
// do not htmlEscape caption. It's applied as textnode
$this->caption = !empty($_POST['screenshotcaption']) ? $_POST['screenshotcaption'] : '';
$this->name = Lang::screenshot('submission');
$this->command = $pageParam;
// what are its other uses..? (finalize is custom)
if ($pageParam == 'finalize')
if ($this->minSize <= 0)
{
if (!$this->handleFinalize())
$this->error();
Util::addNote(U_GROUP_EMPLOYEE, 'ScreenshotPage::__construct() - config error: dimensions for uploaded screenshots egual or less than zero. Value forced to 200');
$this->minSize = 200;
}
else if ($pageParam != 'add')
$this->error();
// get screenshot destination
foreach ($_GET as $k => $v)
// target delivered as screenshot=<command>&<type>.<typeId>.<hash:16> (hash is optional)
if (preg_match('/^screenshot=\w+&(-?\d+)\.(-?\d+)(\.(\w{16}))?$/i', $_SERVER['QUERY_STRING'], $m))
{
if ($v) // target delivered as empty type.typeId key
continue;
$x = explode('_', $k); // . => _ as array key
if (count($x) != 2)
continue;
// no such type
if (empty(Util::$typeClasses[$x[0]]))
continue;
if (empty(Util::$typeClasses[$m[1]]))
$this->error();
$t = Util::$typeClasses[$x[0]];
$c = [['id', intVal($x[1])]];
if ($x[0] == TYPE_WORLDEVENT) // ohforfsake..
$c = array_merge($c, ['OR', ['holidayId', intVal($x[1])]]);
$t = Util::$typeClasses[$m[1]];
$c = [['id', intVal($m[2])]];
if ($m[1] == TYPE_WORLDEVENT && $m[2] < 0) // ohforfsake..
$c = [['id', -intVal($m[2])]];
$this->destination = new $t($c);
// no such typeId
if ($this->destination->error)
continue;
$this->error();
$this->destType = intVal($x[0]);
$this->destTypeId = intVal($x[1]);
// only accept/expect hash for crop & complete
if (empty($m[4]) && ($this->command == 'crop' || $this->command == 'complete'))
$this->error();
else if (!empty($m[4]) && ($this->command == 'add' || $this->command == 'thankyou'))
$this->error();
else if (!empty($m[4]))
$this->imgHash = $m[4];
$this->destType = intVal($m[1]);
$this->destTypeId = intVal($m[2]);
}
else
$this->error();
}
private function handleFinalize()
protected function generateContent()
{
if (empty($_SESSION['ssUpload']))
switch ($this->command)
{
case 'add':
if ($this->handleAdd())
header('Location: ?screenshot=crop&'.$this->destType.'.'.$this->destTypeId.'.'.$this->imgHash, true, 302);
else
header('Location: ?'.Util::$typeStrings[$this->destType].'='.$this->destTypeId.'#submit-a-screenshot', true, 302);
die();
case 'crop':
$this->handleCrop();
break;
case 'complete':
if ($_ = $this->handleComplete())
$this->notFound(Lang::main('nfPageTitle'), sprintf(Lang::main('intError2'), '#'.$_));
else
header('Location: ?screenshot=thankyou&'.$this->destType.'.'.$this->destTypeId, true, 302);
die();
case 'thankyou':
$this->tpl = 'text-page-generic';
$this->handleThankyou();
break;
}
}
/*******************/
/* command handler */
/*******************/
private function handleAdd()
{
$this->imgHash = Util::createHash(16);
if (User::$banStatus & ACC_BAN_SCREENSHOT)
{
$_SESSION['error']['ss'] = Lang::screenshot('error', 'notAllowed');
return false;
}
// as its saved in session it should be valid
$file = $_SESSION['ssUpload']['file'];
if ($_ = $this->validateScreenshot($isPNG))
{
$_SESSION['error']['ss'] = $_;
return false;
}
$im = $isPNG ? $this->loadFromPNG() : $this->loadFromJPG();
if (!$im)
{
$_SESSION['error']['ss'] = Lang::main('intError');
return false;
}
$oSize = $rSize = [imagesx($im), imagesy($im)];
$rel = $oSize[0] / $oSize[1];
// check for oversize and refit to crop-screen
if ($rel >= 1.5 && $oSize[0] > self::MAX_W)
$rSize = [self::MAX_W, self::MAX_W / $rel];
else if ($rel < 1.5 && $oSize[1] > self::MAX_H)
$rSize = [self::MAX_H * $rel, self::MAX_H];
$name = User::$displayName.'-'.$this->destType.'-'.$this->destTypeId.'-'.$this->imgHash;
$this->writeImage($im, $oSize, $name.'_original'); // use this image for work
$this->writeImage($im, $rSize, $name); // use this image to display
return true;
}
private function handleCrop()
{
$im = imagecreatefromjpeg($this->tmpPath.$this->ssName().'_original.jpg');
$oSize = $rSize = [imagesx($im), imagesy($im)];
$rel = $oSize[0] / $oSize[1];
// check for oversize and refit to crop-screen
if ($rel >= 1.5 && $oSize[0] > self::MAX_W)
$rSize = [self::MAX_W, self::MAX_W / $rel];
else if ($rel < 1.5 && $oSize[1] > self::MAX_H)
$rSize = [self::MAX_H * $rel, self::MAX_H];
// r: resized; o: original
// r: x <= 488 && y <= 325 while x proportional to y
// mincrop is optional and specifies the minimum resulting image size
$this->cropper = [
'url' => STATIC_URL.'/uploads/temp/'.$this->ssName().'.jpg',
'parent' => 'ss-container',
'oWidth' => $oSize[0],
'rWidth' => $rSize[0],
'oHeight' => $oSize[1],
'rHeight' => $rSize[1],
'type' => $this->destType, // only used to check against NPC: 15384 [OLDWorld Trigger (DO NOT DELETE)]
'typeId' => $this->destTypeId // i guess this was used to upload arbitrary imagery
];
// minimum dimensions
if (!User::isInGroup(U_GROUP_STAFF))
$this->cropper['minCrop'] = $this->minSize;
// target
$this->infobox = sprintf(Lang::screenshot('displayOn'), Util::ucFirst(Lang::game(Util::$typeStrings[$this->destType])), Util::$typeStrings[$this->destType], $this->destTypeId);
$this->extendGlobalIds($this->destType, $this->destTypeId);
}
private function handleComplete()
{
// check tmp file
$fullPath = $this->tmpPath.$file.'_original.jpg';
$fullPath = $this->tmpPath.$this->ssName().'_original.jpg';
if (!file_exists($fullPath))
return false;
return 1;
// check post data
if (empty($_POST) || empty($_POST['selection']))
return false;
if (empty($_POST) || empty($_POST['coords']))
return 2;
$dims = explode(',', $_POST['selection']);
$dims = explode(',', $_POST['coords']);
if (count($dims) != 4)
return false;
return 3;
Util::checkNumeric($dims);
@@ -105,108 +215,31 @@ class ScreenshotPage extends GenericPage
// write to db
$newId = DB::Aowow()->query(
'INSERT INTO ?_screenshots (type, typeId, userIdOwner, date, width, height, caption) VALUES (?d, ?d, ?d, UNIX_TIMESTAMP(), ?d, ?d, ?)',
$_SESSION['ssUpload']['type'], $_SESSION['ssUpload']['typeId'],
$this->destType, $this->destTypeId,
User::$id,
$w, $h,
$this->caption
!empty($_POST['screenshotalt']) ? $_POST['screenshotalt'] : ''
);
// write to file
if (is_int($newId)) // 0 is valid, NULL or FALSE is not
imagejpeg($destImg, $this->pendingPath.$newId.'.jpg', 100);
unset($_SESSION['ssUpload']);
header('Location: ?user='.User::$displayName.'#screenshots');
else
return 6;
}
protected function generateContent()
private function handleThankyou()
{
$maxW = 488;
$maxH = 325;
$minCrop = CFG_SCREENSHOT_MIN_SIZE;
if ($minCrop <= 0)
{
Util::addNote(U_GROUP_DEV | U_GROUP_ADMIN, 'ScreenshotPage::generateContent() - config error: dimensions for uploaded screenshots egual or less than zero. Value forced to 200');
$minCrop = 200;
$this->extraHTML = Lang::screenshot('thanks', 'contrib').'<br><br>';
$this->extraHTML .= sprintf(Lang::screenshot('thanks', 'goBack'), Util::$typeStrings[$this->destType], $this->destTypeId)."<br /><br />\n";
$this->extraHTML .= '<i>'.Lang::screenshot('thanks', 'note').'</i>';
}
if (!$this->destType)
{
$this->error = Lang::main('ssErrors', 'noDest');
return;
}
if (User::$banStatus & ACC_BAN_SCREENSHOT)
{
$this->error = Lang::main('ssErrors', 'notAllowed');
return;
}
/**********/
/* helper */
/**********/
if ($_ = $this->validateScreenshot($isPNG))
{
$this->error = $_;
return;
}
$im = $isPNG ? $this->loadFromPNG() : $this->loadFromJPG();
if (!$im)
{
$this->error = Lang::main('ssErrors', 'load');
return;
}
$name = User::$displayName.'-'.$this->destType.'-'.$this->destTypeId.'-'.Util::createHash(16);
$oSize = $rSize = [imagesx($im), imagesy($im)];
$rel = $oSize[0] / $oSize[1];
// not sure if this is the best way
$_SESSION['ssUpload'] = array(
'file' => $name,
'type' => $this->destType,
'typeId' => $this->destTypeId
);
// check for oversize and refit to crop-screen
if ($rel >= 1.5 && $oSize[0] > $maxW)
$rSize = [$maxW, $maxW / $rel];
else if ($rel < 1.5 && $oSize[1] > $maxH)
$rSize = [$maxH * $rel, $maxH];
$this->writeImage($im, $oSize, $name.'_original'); // use this image for work
$this->writeImage($im, $rSize, $name); // use this image to display
// r: resized; o: original
// r: x <= 488 && y <= 325 while x proportional to y
// mincrop is optional and specifies the minimum resulting image size
$this->cropper = [
'url' => $this->tmpPath.$name.'.jpg',
'parent' => 'ss-container',
'oWidth' => $oSize[0],
'rWidth' => $rSize[0],
'oHeight' => $oSize[1],
'rHeight' => $rSize[1],
];
$infobox = [];
// target
$infobox[] = sprintf(Lang::main('displayOn'), Util::ucFirst(Lang::game(Util::$typeStrings[$this->destType])), Util::$typeStrings[$this->destType], $this->destTypeId);
$this->extendGlobalIds($this->destType, $this->destTypeId);
// dimensions
$infobox[] = Lang::main('originalSize').Lang::main('colon').$oSize[0].' x '.$oSize[1];
$infobox[] = Lang::main('targetSize').Lang::main('colon').'[span id=qf-newSize][/span]';
// minimum dimensions
if (!User::isInGroup(U_GROUP_STAFF))
{
$infobox[] = Lang::main('minSize').Lang::main('colon').$minCrop.' x '.$minCrop;
$this->cropper['minCrop'] = $minCrop;
}
$this->infobox = '[ul][li]'.implode('[/li][li]', $infobox).'[/li][/ul]';
}
private function loadFromPNG()
{
@@ -240,35 +273,38 @@ class ScreenshotPage extends GenericPage
{
// no upload happened or some error occured
if (!$_FILES || empty($_FILES['screenshotfile']))
return Lang::main('ssErrors', 'noUpload');
return Lang::screenshot('error', 'selectSS');
switch ($_FILES['screenshotfile']['error'])
{
case 1:
return sprintf(Lang::main('ssErrors', 'maxSize'), ini_get('upload_max_filesize'));;
Util::addNote(U_GROUP_EMPLOYEE, 'ScreenshotPage::validateScreenshot() - the file exceeds the maximum size of '.ini_get('upload_max_filesize'));
return Lang::screenshot('error', 'selectSS');
case 3:
return Lang::main('ssErrors', 'interrupted');
Util::addNote(U_GROUP_EMPLOYEE, 'ScreenshotPage::validateScreenshot() - upload was interrupted');
return Lang::screenshot('error', 'selectSS');
case 4:
return Lang::main('ssErrors', 'noFile');
Util::addNote(U_GROUP_EMPLOYEE, 'ScreenshotPage::validateScreenshot() - no file was received');
return Lang::screenshot('error', 'selectSS');
case 6:
Util::addNote(U_GROUP_ADMIN, 'ScreenshotPage::validateScreenshot() - temporary upload directory is not set');
Util::addNote(U_GROUP_EMPLOYEE, 'ScreenshotPage::validateScreenshot() - temporary upload directory is not set');
return Lang::main('intError');
case 7:
Util::addNote(U_GROUP_ADMIN, 'ScreenshotPage::validateScreenshot() - could not write temporary file to disk');
return Lang::main('genericError');
Util::addNote(U_GROUP_EMPLOYEE, 'ScreenshotPage::validateScreenshot() - could not write temporary file to disk');
return Lang::main('intError');
}
// points to invalid file (hack attempt)
if (!is_uploaded_file($_FILES['screenshotfile']['tmp_name']))
{
Util::addNote(U_GROUP_ADMIN, 'ScreenshotPage::validateScreenshot() - uploaded file not in upload directory');
return Lang::main('genericError');
Util::addNote(U_GROUP_EMPLOYEE, 'ScreenshotPage::validateScreenshot() - uploaded file not in upload directory');
return Lang::main('intError');
}
// invalid file
$is = getimagesize($_FILES['screenshotfile']['tmp_name']);
if (!$is || empty($is['mime']))
return Lang::main('ssErrors', 'notImage');
return Lang::screenshot('error', 'selectSS');
// allow jpeg, png
switch ($is['mime'])
@@ -279,23 +315,27 @@ class ScreenshotPage extends GenericPage
case 'image/jpeg':
break;
default:
return Lang::main('ssErrors', 'wrongFormat');
return Lang::screenshot('error', 'unkFormat');
}
// size-missmatch: 4k UHD upper limit; 150px lower limit
if ($is[0] < 150 || $is[1] < 150)
return sprintf(Lang::main('ssErrors', 'tooSmall'), 150, 150);
if ($is[0] > 3840 || $is[1] > 2160)
return sprintf(Lang::main('ssErrors', 'tooLarge'), 150, 150);
if ($is[0] < $this->minSize || $is[1] < $this->minSize)
return Lang::screenshot('error', 'tooSmall');
else if ($is[0] > 3840 || $is[1] > 2160)
return Lang::screenshot('error', 'selectSS');
return null;
}
private function ssName()
{
return $this->imgHash ? User::$displayName.'-'.$this->destType.'-'.$this->destTypeId.'-'.$this->imgHash : '';
}
protected function generatePath() { }
protected function generateTitle()
{
array_unshift($this->title, Lang::main('ssUpload'));
array_unshift($this->title, Lang::screenshot('submission'));
}
}

File diff suppressed because one or more lines are too long

View File

@@ -6,7 +6,7 @@
<div class="text" style="margin-right: 310px">
<div class="tabbed-contents" style="clear: none">
<?php
$this->brick('contrib_'.User::$localeId);
$this->localizedBrick('contrib', User::$localeId);
?>
</div>
</div>

View File

@@ -30,11 +30,12 @@ if (User::$id > 0):
<li><div>Be sure to read the <a href="?help=screenshots-tips-tricks" target="_blank">tips &amp; tricks</a> if you haven't before.</div></li>
</ul>
<?php
echo $this->ssError ? ' <div class="msg-failure">'.$this->ssError."</div>\n <div class=\"pad\"></div>\n" : '';
?>
<form action="?screenshot=add&<?php echo $this->type.'.'.$this->typeId; ?>" method="post" enctype="multipart/form-data" onsubmit="return ss_validateForm(this)">
File:<input type="file" name="screenshotfile" style="width: 35%"/><br />
<div class="pad2"></div>
Caption:<input type="text" name="screenshotcaption" maxlength="200" /> <small>Optional, up to 200 characters</small><br />
<input type="file" name="screenshotfile" style="width: 35%"/><br />
<div class="pad2"></div>
<input type="submit" value="Submit" />
@@ -51,10 +52,8 @@ if (User::$id > 0):
<div class="pad2"></div>
<form action="?video=add&<?php echo $this->type.'.'.$this->typeId; ?>" method="post" enctype="multipart/form-data" onsubmit="return vi_validateForm(this)">
URL:<input type="text" name="videourl" style="width: 35%" /> <small>Supported: YouTube only</small>
<input type="text" name="videourl" style="width: 35%" /> <small>Supported: YouTube only</small>
<div class="pad2"></div>
Title:<input type="text" name="videotitle" maxlength="200" /> <small>Optional, up to 200 characters</small><br />
<div class="pad"></div>
<input type="submit" value="Submit" />
<div class="pad3"></div>

View File

@@ -16,7 +16,7 @@ if (User::$id > 0):
<div id="funcbox-generic"></div>
<script type="text/javascript">Listview.funcBox.coEditAppend($('#funcbox-generic'), {body: ''}, 1)</script>
<div class="pad"></div>
<input type="submit" value="Submit"></input>
<input type="submit" value="Soumettre"></input>
</form>
</div>
@@ -30,13 +30,14 @@ if (User::$id > 0):
<li><div>Assurez-vous de lire les <a href="?help=screenshots-tips-tricks" target="_blank">trucs et astuces</a> si ce n'est pas déjà fait.</div></li>
</ul>
<?php
echo $this->ssError ? ' <div class="msg-failure">'.$this->ssError."</div>\n <div class=\"pad\"></div>\n" : '';
?>
<form action="?screenshot=add&<?php echo $this->type.'.'.$this->typeId; ?>" method="post" enctype="multipart/form-data" onsubmit="return ss_validateForm(this)">
File : <input type="file" name="screenshotfile" style="width: 35%"/><br />
<input type="file" name="screenshotfile" style="width: 35%"/><br />
<div class="pad2"></div>
Caption : <input type="text" name="screenshotcaption" maxlength="200" /> <small>Optional, up to 200 characters</small><br />
<div class="pad2"></div>
<input type="submit" value="Submit" />
<input type="submit" value="Soumettre" />
<div class="pad3"></div>
<small class="q0">Note: Votre capture d'écran devra être approuvé avant d'apparaitre sur le site.</small>
@@ -51,11 +52,9 @@ if (User::$id > 0):
<div class="pad2"></div>
<form action="?video=add&<?php echo $this->type.'.'.$this->typeId; ?>" method="post" enctype="multipart/form-data" onsubmit="return vi_validateForm(this)">
URL : <input type="text" name="videourl" style="width: 35%" /> <small>Supporté: Youtube seulement</small>
<input type="text" name="videourl" style="width: 35%" /> <small>Supporté: Youtube seulement</small>
<div class="pad2"></div>
Title : <input type="text" name="videotitle" maxlength="200" /> <small>Optional, up to 200 characters</small><br />
<div class="pad"></div>
<input type="submit" value="Submit" />
<input type="submit" value="Soumettre" />
<div class="pad3"></div>
<small class="q0">Note: Votre vidéo devra être approuvé avant d'apparaitre sur le site.</small>

View File

@@ -20,7 +20,6 @@ if (User::$id > 0):
</form>
</div>
<div id="tab-submit-a-screenshot" style="display: none">
Wählt einfach Euren Screenshot mit dem folgenden Formular aus.
@@ -31,11 +30,12 @@ if (User::$id > 0):
<li><div>Lest Euch unbedingt die <a href="?help=screenshots-tips-tricks" target="_blank">Tipps &amp; Tricks</a> durch, wenn nicht bereits geschehen.</div></li>
</ul>
<?php
echo $this->ssError ? ' <div class="msg-failure">'.$this->ssError."</div>\n <div class=\"pad\"></div>\n" : '';
?>
<form action="?screenshot=add&<?php echo $this->type.'.'.$this->typeId; ?>" method="post" enctype="multipart/form-data" onsubmit="return ss_validateForm(this)">
Datei:<input type="file" name="screenshotfile" style="width: 35%"/><br />
<div class="pad2"></div>
Titel:<input type="text" name="screenshotcaption" maxlength="200" /> <small>Optional, bis zu 200 Zeichen</small><br />
<input type="file" name="screenshotfile" style="width: 35%"/><br />
<div class="pad2"></div>
<input type="submit" value="Senden" />
@@ -45,7 +45,6 @@ if (User::$id > 0):
</form>
</div>
<div id="tab-suggest-a-video" style="display: none">
Gebt einfach die URL des Videos im folgenden Formular ein.
@@ -53,10 +52,8 @@ if (User::$id > 0):
<div class="pad2"></div>
<form action="?video=add&<?php echo $this->type.'.'.$this->typeId; ?>" method="post" enctype="multipart/form-data" onsubmit="return vi_validateForm(this)">
URL:<input type="text" name="videourl" style="width: 35%" /> <small>Unterstützt: nur YouTube</small>
<input type="text" name="videourl" style="width: 35%" /> <small>Unterstützt: nur YouTube</small>
<div class="pad2"></div>
Titel:<input type="text" name="videotitle" maxlength="200" /> <small>Optional, bis zu 200 Zeichen</small><br />
<div class="pad"></div>
<input type="submit" value="Senden" />
<div class="pad3"></div>
@@ -87,7 +84,6 @@ else:
</form>
</div>
<div id="tab-submit-a-screenshot" style="display: none">
Wählt einfach Euren Screenshot mit dem folgenden Formular aus.
@@ -106,7 +102,6 @@ else:
</form>
</div>
<div id="tab-suggest-a-video" style="display: none">
Gebt einfach die URL des Videos im folgenden Formular ein.
@@ -114,7 +109,7 @@ else:
<div class="pad2"></div>
<form action="/video=add&amp;13.7" method="post" enctype="multipart/form-data" onsubmit="return vi_validateForm(this)">
URL:<input type="text" name="videourl" style="width: 35%" /> <small>Unterstützt: nur YouTube</small>
<input type="text" name="videourl" style="width: 35%" /> <small>Unterstützt: nur YouTube</small>
<div class="pad"></div>
<input type="submit" value="Senden" />

View File

@@ -16,7 +16,7 @@ if (User::$id > 0):
<div id="funcbox-generic"></div>
<script type="text/javascript">Listview.funcBox.coEditAppend($('#funcbox-generic'), {body: ''}, 1)</script>
<div class="pad"></div>
<input type="submit" value="Submit"></input>
<input type="submit" value="Enviar"></input>
</form>
</div>
@@ -30,13 +30,14 @@ if (User::$id > 0):
<li><div>Asegurate de leer las <a href="?help=screenshots-tips-tricks" target="_blank">sugerencias y trucos</a> si no lo has hecho antes.</div></li>
</ul>
<?php
echo $this->ssError ? ' <div class="msg-failure">'.$this->ssError."</div>\n <div class=\"pad\"></div>\n" : '';
?>
<form action="?screenshot=add&<?php echo $this->type.'.'.$this->typeId; ?>" method="post" enctype="multipart/form-data" onsubmit="return ss_validateForm(this)">
File:<input type="file" name="screenshotfile" style="width: 35%"/><br />
<input type="file" name="screenshotfile" style="width: 35%"/><br />
<div class="pad2"></div>
Caption:<input type="text" name="screenshotcaption" maxlength="200" /> <small>Optional, up to 200 characters</small><br />
<div class="pad2"></div>
<input type="submit" value="Submit" />
<input type="submit" value="Enviar" />
<div class="pad3"></div>
<small class="q0">Nota: Su captura de imagen deberá ser aprobado antes de aparecer en el sitio.</small>
@@ -51,11 +52,9 @@ if (User::$id > 0):
<div class="pad2"></div>
<form action="?video=add&<?php echo $this->type.'.'.$this->typeId; ?>" method="post" enctype="multipart/form-data" onsubmit="return vi_validateForm(this)">
URL:<input type="text" name="videourl" style="width: 35%" /> <small>Soportado: Sólo YouTube</small>
<input type="text" name="videourl" style="width: 35%" /> <small>Soportado: Sólo YouTube</small>
<div class="pad2"></div>
Title:<input type="text" name="videotitle" maxlength="200" /> <small>Optional, up to 200 characters</small><br />
<div class="pad"></div>
<input type="submit" value="Submit" />
<input type="submit" value="Enviar" />
<div class="pad3"></div>
<small class="q0">Nota: Tu vídeo deberá ser aprobado antes de aparecer en el sitio.</small>

View File

@@ -16,7 +16,7 @@ if (User::$id > 0):
<div id="funcbox-generic"></div>
<script type="text/javascript">Listview.funcBox.coEditAppend($('#funcbox-generic'), {body: ''}, 1)</script>
<div class="pad"></div>
<input type="submit" value="Submit"></input>
<input type="submit" value="Отправить"></input>
</form>
</div>
@@ -30,13 +30,14 @@ if (User::$id > 0):
<li><div>Если вы ещё не читали, то настоятельно рекомендуем вам прочесть <a href="?help=screenshots-tips-tricks" target="_blank">советы и особенности</a> получения изображений при помощи снимков экрана.</div></li>
</ul>
<?php
echo $this->ssError ? ' <div class="msg-failure">'.$this->ssError."</div>\n <div class=\"pad\"></div>\n" : '';
?>
<form action="?screenshot=add&<?php echo $this->type.'.'.$this->typeId; ?>" method="post" enctype="multipart/form-data" onsubmit="return ss_validateForm(this)">
File:<input type="file" name="screenshotfile" style="width: 35%"/><br />
<input type="file" name="screenshotfile" style="width: 35%"/><br />
<div class="pad2"></div>
Caption:<input type="text" name="screenshotcaption" maxlength="200" /> <small>Optional, up to 200 characters</small><br />
<div class="pad2"></div>
<input type="submit" value="Submit" />
<input type="submit" value="Отправить" />
<div class="pad3"></div>
<small class="q0">Примечание: перед тем как появиться на сайте, ваше Скриншот должны быть утверждены.</small>
@@ -51,11 +52,9 @@ if (User::$id > 0):
<div class="pad2"></div>
<form action="?video=add&<?php echo $this->type.'.'.$this->typeId; ?>" method="post" enctype="multipart/form-data" onsubmit="return vi_validateForm(this)">
URL:<input type="text" name="videourl" style="width: 35%" /> <small>Поддерживается: только YouTube</small>
<input type="text" name="videourl" style="width: 35%" /> <small>Поддерживается: только YouTube</small>
<div class="pad2"></div>
Title:<input type="text" name="videotitle" maxlength="200" /> <small>Optional, up to 200 characters</small><br />
<div class="pad"></div>
<input type="submit" value="Submit" />
<input type="submit" value="Отправить" />
<div class="pad3"></div>
<small class="q0">Примечание: перед тем как появиться на сайте, ваше видео должно быть одобрено.</small>

View File

@@ -0,0 +1,10 @@
<h2><img src="<?php echo STATIC_URL; ?>/images/icons/bubble-big.gif" width="32" height="29" alt="" style="vertical-align:middle;margin-right:8px">Reminder</h2>
Your screenshot will <b class="q10">not</b> be approved if it doesn't correspond to the following guidelines.
<ul>
<li><div>Be sure to turn up your <u><b>graphics settings</b></u> to make sure the shot looks good!</div></li>
<li><div><u><b>Model viewer</b></u> shots are deleted on sight (this also includes character select, typically).</div></li>
<li><div>Don't include the <u><b>onscreen text</b></u> and the <u><b>selection circle</b></u> of a NPC.</div></li>
<li><div>Don't include any <u><b>UI</b></u> in the shot if you can help it.</div></li>
<li><div>Use the screenshot <u><b>cropping tool</b></u> to focus on the item as much as possible and reduce any unnecessary surrounding, as to better show off the item in question when reduced to the thumbnail that will be present on the item's page.</div></li>
</ul>

View File

@@ -0,0 +1,10 @@
<h2><img src="<?php echo STATIC_URL; ?>/images/icons/bubble-big.gif" width="32" height="29" alt="" style="vertical-align:middle;margin-right:8px">Hinweis</h2>
Euer Screenshot wird <b class="q10">nicht</b> zugelassen werden, wenn er nicht unseren Richtlinien entspricht.
<ul>
<li><div>Achtet darauf die Qualität Eurer <u><b>Video Einstellungen</b></u> zu erhöhen, damit Euer Bild gut aussieht!</div></li>
<li><div>Bilder des <u><b>Modelviewers</b></u> werden sofort gelöscht (das beinhaltet in der Regel auch Bilder der Charakterauswahl).</div></li>
<li><div>Vermeidet <u><b>Bildschirmtext</b></u> und die <u><b>Zielmarkierung</b></u> an NPCs.</div></li>
<li><div>Bezieht das <u><b>Interface</b></u> nicht ins Bild mit ein, wenn Ihr es vermeiden könnt.</div></li>
<li><div>Benutzt das <u><b>Zuschneidewerkzeug</b></u> um den Fokus so weit wie möglich auf das Objekt zu legen und unnötigen Rand zu reduzieren. Dies hilft das Objekt besser in der Vorschau zu erkennen, welche auf der entsprechenden Seite angezeigt wird.</div></li>
</ul>

View File

@@ -11,60 +11,46 @@ $this->brick('pageTemplate');
$this->brick('infobox');
if (isset($this->error)):
?>
<div class="pad3"></div>
<div class="inputbox">
<h1><?php echo Lang::main('prepError'); ?></h1>
<div id="inputbox-error"><?php echo $this->error; ?><br><a href="<?php echo $this->destType ? '?'.Util::$typeStrings[$this->destType].'='.$this->destTypeId : 'javascript:history.back();'; ?>"><?php echo Lang::main('back'); ?></a></div>
<?php
else:
?>
<div class="text">
<h1><?php echo $this->name; ?></h1>
<?php
if ($this->mode == 'add'):
?>
<div id="ss-container" style="float:right;"></div>
<div id="img-edit-form">
<span><?php echo Lang::main('cropHint'); ?></span>
<span><?php echo Lang::screenshot('cropHint'); ?></span>
<div class="pad"></div>
<b><?php echo Lang::main('caption').Lang::main('colon'); ?></b><br>
<form action="?screenshot=finalize" method="post">
<textarea style="resize: none;" name="screenshotcaption" cols="27" rows="4"><?php echo $this->caption; ?></textarea>
<div class="text-counter">text counter ph</div>
<div style="clear:right;"></div>
<input type="hidden" id="selection" name="selection" value=""></input>
<input type="submit" value="<?php echo Lang::main('ssSubmit'); ?>"></input>
<div id="ss-container"></div><script type="text/javascript">//<![CDATA[
var myCropper = new Cropper(<?php echo json_encode($this->cropper, JSON_NUMERIC_CHECK); ?>);
//]]></script>
<div class="pad"></div>
<button style="margin:4px 0 0 5px" onclick="myCropper.selectAll()"><?php echo Lang::screenshot('selectAll'); ?></button>
<div class="clear"></div>
<div class="pad3"></div>
<form action="?screenshot=complete&amp;<?php echo $this->destType.'.'.$this->destTypeId.'.'.$this->imgHash; ?>" method="post" onsubmit="this.elements['coords'].value = myCropper.getCoords()">
<?php echo Lang::screenshot('caption').Lang::main('colon'); ?><input type="text" name="screenshotalt" style="width: 55%" maxlength="200" /> <small> <?php echo Lang::screenshot('charLimit'); ?></small><br />
<div class="pad"></div>
<?php $this->localizedBrick('ssReminder', User::$localeId); ?>
<input type="submit" value="<?php echo Lang::main('submit'); ?>" />
<input type="hidden" name="coords" />
</form>
</div>
<script type="text/javascript">//<![CDATA[
var
cropper = new Cropper(<?php echo json_encode($this->cropper, JSON_NUMERIC_CHECK); ?>),
captionMaxLen = 200;
Body = $('#img-edit-form').find('textarea');
TextCounter = $('#img-edit-form').find('div.text-counter');
Form = $('#img-edit-form').find('form');
qfSizeDiv = $('.infobox').find('#qf-newSize');
$('body').mouseup(UpdateImageSelection);
Form.submit(function () { return submitSS(); });
UpdateTextCounter();
UpdateImageSelection();
Body = $('#main-contents').find('input[type=text]');
TextCounter = $('#main-contents').find('small');
Body.focus();
Body.keyup(function (e) { return UpdateTextCounter(); });
Body.keypress(function (e) { // ENTER
if (e.keyCode == 13 || captionMaxLen - getCaptionLen() <= 0 )
return false;
});
Form.find('textarea').focus();
function getCaptionLen()
{
return Body.val().replace(/(\s+)/g, ' ').replace(/^\s*/, '').replace(/\s*$/, '').length;
@@ -89,29 +75,7 @@ else:
TextCounter.html(text).attr('class', cssClass);
}
function UpdateImageSelection()
{
dims = cropper.getCoords().split(',');
w = Math.floor(cropper.oWidth * dims[2]);
h = Math.floor(cropper.oHeight * dims[3]);
qfSizeDiv.html(w + ' x ' + h);
}
function submitSS()
{
$('#selection').val(cropper.getCoords());
return true;
}
//]]></script>
<div class="pad2"></div>
<?php
endif;
endif;
?>
</div>
</div><!-- main-contents -->
</div><!-- main -->