diff --git a/includes/utilities.php b/includes/utilities.php index a362bb0d..8b162347 100644 --- a/includes/utilities.php +++ b/includes/utilities.php @@ -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; } diff --git a/localization/lang.class.php b/localization/lang.class.php index f87ffca8..5f775d37 100644 --- a/localization/lang.class.php +++ b/localization/lang.class.php @@ -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; diff --git a/localization/locale_dede.php b/localization/locale_dede.php index 51b01ba7..0e89a619 100644 --- a/localization/locale_dede.php +++ b/localization/locale_dede.php @@ -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 feedback", # 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.
Bitte beachtet Screenshots: Tipps & Tricks 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' => 'Klickt hier, 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. (< ".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( diff --git a/localization/locale_enus.php b/localization/locale_enus.php index 876d88ca..3e115810 100644 --- a/localization/locale_enus.php +++ b/localization/locale_enus.php @@ -138,30 +138,24 @@ $lang = array( 'genericError' => "An error has occurred; refresh the page and try again. If the error persists email feedback", # 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.
Please refer to Screenshots: Tips & Tricks 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' => 'Click here 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. (< ".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( diff --git a/localization/locale_eses.php b/localization/locale_eses.php index 7b56d5aa..e158657a 100644 --- a/localization/locale_eses.php +++ b/localization/locale_eses.php @@ -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 feedback", # 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.
Please refer to Screenshots: Tips & Tricks 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' => 'aquí vuelve 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. (< ".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( diff --git a/localization/locale_frfr.php b/localization/locale_frfr.php index 67941ed4..3ef26007 100644 --- a/localization/locale_frfr.php +++ b/localization/locale_frfr.php @@ -143,30 +143,24 @@ $lang = array( 'genericError' => "Une erreur est survenue; Actualisez la page et essayez à nouveau. Si l'erreur persiste, envoyez un email à feedback", # 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.
Please refer to Screenshots: Tips & Tricks 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' => 'ici 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. (< ".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( diff --git a/localization/locale_ruru.php b/localization/locale_ruru.php index 59867a62..ced46cfc 100644 --- a/localization/locale_ruru.php +++ b/localization/locale_ruru.php @@ -143,30 +143,24 @@ $lang = array( 'genericError' => "Произошла ошибка; обновите страницу и попробуйте снова. Если ситуация повторяется, отправьте сообщение на feedback", # 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.
Please refer to Screenshots: Tips & Tricks 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' => 'здесь чтобы перейти к предыдущей странице.', + 'note' => "Примечание: Перед появлением на сайте, ваше изображение должно быть одобрено. Это может занять до 72 часов." + ), + 'error' => array( + 'unkFormat' => "неизвестный формат изображения.", + 'tooSmall' => "Изображение слишком маленькое. (< ".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( diff --git a/pages/genericPage.class.php b/pages/genericPage.class.php index 4b9be014..5c55ffce 100644 --- a/pages/genericPage.class.php +++ b/pages/genericPage.class.php @@ -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,8 +698,9 @@ class GenericPage if (!CFG_CACHE_MODE || CFG_DEBUG) return; - $cKey = $this->generateCacheKey(); - $cache = []; + $noCache = ['coError', 'ssError', 'viError']; + $cKey = $this->generateCacheKey(); + $cache = []; if (!$saveString) { foreach ($this as $key => $val) @@ -672,7 +709,8 @@ class GenericPage { // public, protected and an undocumented flag added to properties created on the fly..? if ((new ReflectionProperty($this, $key))->getModifiers() & 0x1300) - $cache[$key] = $val; + if (!in_array($key, $noCache)) + $cache[$key] = $val; } catch (ReflectionException $e) { } // shut up! } diff --git a/pages/screenshot.php b/pages/screenshot.php index fda12f7b..b98fb30e 100644 --- a/pages/screenshot.php +++ b/pages/screenshot.php @@ -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=&.. (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; + if ($this->destination->error) + $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(); + } + + protected function generateContent() + { + 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; } } - private function handleFinalize() + + /*******************/ + /* command handler */ + /*******************/ + + + private function handleAdd() { - if (empty($_SESSION['ssUpload'])) + $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,109 +215,32 @@ 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; - } - - if (!$this->destType) - { - $this->error = Lang::main('ssErrors', 'noDest'); - return; - } - - if (User::$banStatus & ACC_BAN_SCREENSHOT) - { - $this->error = Lang::main('ssErrors', 'notAllowed'); - return; - } - - 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]'; + $this->extraHTML = Lang::screenshot('thanks', 'contrib').'

'; + $this->extraHTML .= sprintf(Lang::screenshot('thanks', 'goBack'), Util::$typeStrings[$this->destType], $this->destTypeId)."

\n"; + $this->extraHTML .= ''.Lang::screenshot('thanks', 'note').''; } + + /**********/ + /* helper */ + /**********/ + + private function loadFromPNG() { $image = imagecreatefrompng($_FILES['screenshotfile']['tmp_name']); @@ -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')); } } diff --git a/static/js/screenshot.js b/static/js/screenshot.js index 8515855a..d13821bc 100644 --- a/static/js/screenshot.js +++ b/static/js/screenshot.js @@ -1 +1,1124 @@ -var ss_managedRow = null; var ss_getAll = false; // never changed (maybe with ?admin=screenshots&all) var ssm_ViewedRow = null; var ssm_screenshotData = []; var ssm_screenshotPages = []; var ssm_numPagesFound = 0; var ssm_numPages = 0; // never accessed var ssm_numPending = 0; var ssm_statuses = { 0 : 'Pending', 999: 'Deleted', 100: 'Approved', 105: 'Sticky' }; function makePipe() { var sp = $WH.ce('span'); $WH.ae(sp, $WH.ct(' ')); var sm = $WH.ce('small'); sm.className = 'q0'; $WH.ae(sm, $WH.ct('|')); $WH.ae(sp, sm); $WH.ae(sp, $WH.ct(' ')); return sp; } function ss_OnResize() { var _ = Math.max(100, Math.min($WH.g_getWindowSize().h - 50, 700)); $WH.ge('menu-container').style.height = $WH.ge('pages-container').style.height = _ + 'px'; $WH.ge('data-container').style.height = _ + 'px'; } $WH.aE(window, 'resize', ss_OnResize); function ss_Refresh(openNext, type, typeId) { new Ajax('?admin=screenshots&action=list' + (ss_getAll ? '&all' : ''), { method: 'get', onSuccess: function (xhr) { eval(xhr.responseText); if (ssm_screenshotPages.length > 0) { $WH.ge('show-all-pages').innerHTML = ' – Show All (' + ssm_numPagesFound + ')'; ssm_UpdatePages(); if (openNext) { ss_Manage($WH.ge('pages-container').firstChild.firstChild, ssm_screenshotPages[0].type, ssm_screenshotPages[0].typeId, true); } else if (type && typeId) { ss_Manage(null, type, typeId, true); } } else { $WH.ee($WH.ge('show-all-pages')); $WH.ge('pages-container').innerHTML = 'NO SCREENZSHOT NEEDS 2 BE APPRVED NOW KTHX. :)'; if (type && typeId) { ss_Manage(null, type, typeId, true); } } } }); } function ss_Manage(_this, type, typeId, openNext) { new Ajax('?admin=screenshots&action=manage&type=' + type + '&typeid=' + typeId, { method: 'get', onSuccess: function (xhr) { eval(xhr.responseText); ssm_numPending = 0; for (var i in ssm_screenshotData) { if (ssm_screenshotData[i].pending) { ssm_numPending++; } } var nRows = ssm_screenshotData.length; $WH.ge('screenshotTotal').innerHTML = nRows + ' total' + (nRows == 100 ? ' (limit reached)' : ''); ssm_UpdateList(openNext); ssm_UpdateMassLinks(); if (ss_managedRow != null) { ss_ColorizeRow('transparent'); } ss_managedRow = _this; if (ss_managedRow != null) { ss_ColorizeRow('#282828'); } } }); } function ss_ManageUser() { var username = $WH.ge('usermanage'); username.value = $WH.trim(username.value); if (username.value.length < 4) { alert('Username must be at least 4 characters long.'); username.focus(); return false; } if (username.value.match(/[^a-z0-9]/i) != null) { alert('Username can only contain letters and numbers.'); username.focus(); return false; } new Ajax('?admin=screenshots&action=manage&user=' + username.value, { method: 'get', onSuccess: function (xhr) { eval(xhr.responseText); var nRows = ssm_screenshotData.length; $WH.ge('screenshotTotal').innerHTML = nRows + ' total' + (nRows == 100 ? ' (limit reached)' : ''); ssm_UpdateList(); ssm_UpdateMassLinks(); if (ss_managedRow != null) { ss_ColorizeRow('transparent'); } } }); return true; } function ss_ColorizeRow(color) { for (var i = 0; i < ss_managedRow.childNodes.length; ++i) { ss_managedRow.childNodes[i].style.backgroundColor = color; } } function ssm_GetScreenshot(id) { for (var i in ssm_screenshotData) { if (ssm_screenshotData[i].id == id) { return ssm_screenshotData[i]; } } return null; } function ssm_View(row, id) { if (ssm_ViewedRow != null) { ssm_ColorizeRow('transparent'); } ssm_ViewedRow = row; ssm_ColorizeRow('#282828'); var screenshot = ssm_GetScreenshot(id); if (screenshot != null) { ScreenshotManager.show(screenshot); } } function ssm_ColorizeRow(color) { for (var i = 0; i < ssm_ViewedRow.childNodes.length; ++i) { ssm_ViewedRow.childNodes[i].style.backgroundColor = color; } } function ssm_ConfirmMassApprove() { ajaxAnchor(this); // sarjuuk custom - there has to be something in place or we are manually using a script for ajax return false; // return true; } function ssm_ConfirmMassDelete() { if (confirm('Delete selected screenshot(s)?')) // sarjuuk custom - see above ajaxAnchor(this); return false; // return confirm('Delete selected screenshot(s)?'); } function ssm_ConfirmMassSticky() { if (confirm('Sticky selected screenshot(s)?')) // sarjuuk custom - see above ajaxAnchor(this); return false; // return confirm('Sticky selected screenshot(s)?'); } function ssm_UpdatePages(UNUSED) { var pc = $WH.ge('pages-container'); $WH.ee(pc); var tbl = $WH.ce('table'); tbl.className = 'grid'; tbl.style.width = '400px'; var tr = $WH.ce('tr'); var th = $WH.ce('th'); $WH.ae(th, $WH.ct('Page')); $WH.ae(tr, th); th = $WH.ce('th'); $WH.ae(th, $WH.ct('Submitted')); $WH.ae(tr, th); th = $WH.ce('th'); th.align = 'right'; $WH.ae(th, $WH.ct('#')); $WH.ae(tr, th); $WH.ae(tbl, tr); var now = new Date(); for (var i in ssm_screenshotPages) { var ssPage = ssm_screenshotPages[i]; tr = $WH.ce('tr'); tr.onclick = ss_Manage.bind(tr, tr, ssPage.type, ssPage.typeId, true, i); var td = $WH.ce('td'); var a = $WH.ce('a'); a.href = '?' + g_types[ssPage.type] + '=' + ssPage.typeId; a.target = '_blank'; $WH.ae(a, $WH.ct(ssPage.name)); $WH.ae(td, a); $WH.ae(tr, td); td = $WH.ce('td'); var elapsed = new Date(ssPage.date); $WH.ae(td, $WH.ct(g_formatTimeElapsed((now.getTime() - elapsed.getTime()) / 1000) + ' ago')); $WH.ae(tr, td); td = $WH.ce('td'); td.align = 'right'; $WH.ae(td, $WH.ct(ssPage.count)); $WH.ae(tr, td); $WH.ae(tbl, tr); } $WH.ae(pc, tbl); } function ssm_UpdateList(openNext) { var tsl = $WH.ge('theScreenshotsList'); var tBody = false; var i = 1; while (tsl.childNodes.length > i) { if (tsl.childNodes[i].nodeName == 'TR' && tBody) { $WH.de(tsl.childNodes[i]); } else if (tsl.childNodes[i].nodeName == 'TR') { tBody = true; } else { i++; } } var now = new Date(); var ssId = 0; for (var i in ssm_screenshotData) { var screenshot = ssm_screenshotData[i]; var tr = $WH.ce('tr'); if (ssId == 0 && screenshot.pending) { ssId = screenshot.id; tr.id = 'highlightedRow'; } var td = $WH.ce('td'); td.align = 'center'; var a = $WH.ce('a'); a.href = g_staticUrl + '/uploads/screenshots/' + (screenshot.status != 999 && !screenshot.pending ? 'normal' : 'pending') + '/' + screenshot.id + '.jpg'; a.target = '_blank'; a.onclick = function (id, e) { $WH.sp(e); (ssm_View.bind(this, id))(); return false; }.bind(tr, screenshot.id); var img = $WH.ce('img'); img.src = g_staticUrl + '/uploads/screenshots/' + (screenshot.status != 999 && !screenshot.pending ? 'thumb' : 'pending') + '/' + screenshot.id + '.jpg'; img.height = 50; $WH.ae(a, img); $WH.ae(td, a); $WH.ae(tr, td); td = $WH.ce('td'); if (screenshot.status != 999 && !screenshot.pending) { var a = $WH.ce('a'); a.href = '?' + g_types[screenshot.type] + '=' + screenshot.typeId + '#screenshots:id=' + screenshot.id; a.target = '_blank'; a.onclick = function (e) { $WH.sp(e); }; $WH.ae(a, $WH.ct(screenshot.id)); $WH.ae(td, a); } else { $WH.ae(td, $WH.ct(screenshot.id)); } $WH.ae(tr, td); td = $WH.ce('td'); td.id = 'alt-' + screenshot.id; var sp = $WH.ce('span'); sp.style.paddingRight = '8px'; if (screenshot.caption) { var sp2 = $WH.ce('span'); sp2.className = 'q2'; var b = $WH.ce('b'); $WH.ae(b, $WH.ct(screenshot.caption)); $WH.ae(sp2, b); $WH.ae(sp, sp2); } else { var it = $WH.ce('i'); it.className = 'q0'; $WH.ae(it, $WH.ct('NULL')); $WH.ae(sp, it); } $WH.ae(td, sp); sp = $WH.ce('span'); sp.style.whiteSpace = 'nowrap'; var a = $WH.ce('a'); a.href = 'javascript:;'; a.onclick = function (id, e) { $WH.sp(e); (ssm_ShowEdit.bind(this, id))() }.bind(a, screenshot); $WH.ae(a, $WH.ct('Edit')); $WH.ae(sp, a); $WH.ae(sp, makePipe()); a = $WH.ce('a'); a.href = 'javascript:;'; a.onclick = function (id, e) { $WH.sp(e); (ssm_Clear.bind(this, id))() }.bind(a, screenshot); $WH.ae(a, $WH.ct('Clear')); $WH.ae(sp, a); $WH.ae(td, sp); $WH.ae(tr, td); td = $WH.ce('td'); var elapsed = new Date(screenshot.date); $WH.ae(td, $WH.ct(g_formatTimeElapsed((now.getTime() - elapsed.getTime()) / 1000) + ' ago')); $WH.ae(tr, td); td = $WH.ce('td'); a = $WH.ce('a'); a.href = '?user=' + screenshot.user; a.target = '_blank'; a.onclick = function (e) { $WH.sp(e); }; $WH.ae(a, $WH.ct(screenshot.user)); $WH.ae(td, a); $WH.ae(tr, td); td = $WH.ce('td'); $WH.ae(td, $WH.ct(ssm_statuses[screenshot.status])); $WH.ae(tr, td); td = $WH.ce('td'); var cb = $WH.ce('input'); cb.type = 'checkbox'; cb.value = screenshot.id; cb.onclick = function (e) { $WH.sp(e); (ssm_UpdateMassLinks.bind(this))(); }.bind(cb); $WH.ae(td, cb); $WH.ae(td, $WH.ct(' ')); if (screenshot.status != 999) { tr.onclick = function (id) { ssm_View(this, id); return false; }.bind(tr, screenshot.id); if (screenshot.id == ssId && openNext) { ssm_View(tr, screenshot.id); } if (screenshot.pending) { a = $WH.ce('a'); a.href = 'javascript:;'; a.onclick = function (e) { $WH.sp(e); (ssm_Approve.bind(this, false))() }.bind(screenshot); $WH.ae(a, $WH.ct('Approve')); $WH.ae(td, a); } else { $WH.ae(td, $WH.ct('Approve')); } $WH.ae(td, makePipe()); if (screenshot.status != 105) { a = $WH.ce('a'); a.href = 'javascript:;'; a.onclick = function (e) { $WH.sp(e); (ssm_Sticky.bind(this, false))(); }.bind(screenshot); $WH.ae(a, $WH.ct('Make sticky')); $WH.ae(td, a); } else { $WH.ae(td, $WH.ct('Make sticky')); } $WH.ae(td, makePipe()); a = $WH.ce('a'); a.href = 'javascript:;'; a.onclick = function (e) { $WH.sp(e); (ssm_Delete.bind(this, false))(); }.bind(screenshot); $WH.ae(a, $WH.ct('Delete')); $WH.ae(td, a); $WH.ae(td, makePipe()); a = $WH.ce('a'); a.href = 'javascript:;'; a.onclick = function (e) { $WH.sp(e); var id = prompt('Enter the ID to move this screenshot to:'); (ssm_Relocate.bind(this, id))(); }.bind(screenshot); $WH.ae(a, $WH.ct('Relocate')); $WH.ae(td, a); } $WH.ae(tr, td); $WH.ae(tsl, tr); } } function ssm_UpdateMassLinks() { var buff = ''; var i = 0; var tSL = $WH.ge('theScreenshotsList'); var inp = $WH.gE(tSL, 'input'); $WH.array_walk(inp, function (x) { if (x.checked) { buff += x.value + ','; ++i; } }); buff = $WH.rtrim(buff, ','); var selCnt = $WH.ge('withselected'); if (i > 0) { selCnt.style.display = ''; $WH.gE(selCnt, 'b')[0].firstChild.nodeValue = '(' + i + ')'; var c = $WH.ge('massapprove'); var b = $WH.ge('massdelete'); var a = $WH.ge('masssticky'); c.href = '?admin=screenshots&action=approve&id=' + buff; c.onclick = ssm_ConfirmMassApprove; b.href = '?admin=screenshots&action=delete&id=' + buff; b.onclick = ssm_ConfirmMassDelete; a.href = '?admin=screenshots&action=sticky&id=' + buff; a.onclick = ssm_ConfirmMassSticky; } else { selCnt.style.display = 'none'; } } function ssm_MassSelect(action) { var tSL = $WH.ge('theScreenshotsList'); var inp = $WH.gE(tSL, 'input'); switch (parseInt(action)) { case 1: $WH.array_walk(inp, function (x) { x.checked = true }); break; case 0: $WH.array_walk(inp, function (x) { x.checked = false }); break; case -1: $WH.array_walk(inp, function (x) { x.checked = !x.checked }); break; case 2: $WH.array_walk(inp, function (x) { x.checked = ssm_GetScreenshot(x.value).status == 0 }); break; case 5: $WH.array_walk(inp, function (x) { x.checked = ssm_GetScreenshot(x.value).unique == 1 && ssm_GetScreenshot(x.value).status == 0 }); break; case 3: $WH.array_walk(inp, function (x) { x.checked = ssm_GetScreenshot(x.value).status == 100 }); break; case 4: $WH.array_walk(inp, function (x) { x.checked = ssm_GetScreenshot(x.value).status == 105 }); break; default: return; } ssm_UpdateMassLinks(); } function ssm_ShowEdit(screenshot, isAlt) { var node; if (isAlt) { node = $WH.ge('alt2-' + screenshot.id) } else { node = $WH.ge('alt-' + screenshot.id) } var sp = $WH.gE(node, 'span')[0]; var div = $WH.ce('div'); div.style.whiteSpace = 'nowrap'; var iCaption = $WH.ce('input'); iCaption.type = 'text'; iCaption.value = screenshot.caption; iCaption.maxLength = 200; iCaption.size = 35; iCaption.onclick = function (e) { $WH.sp(e); } // sarjuuk - custom to inhibit screenshot popup, when clicking into input element div.appendChild(iCaption); var btn = $WH.ce('input'); btn.type = 'button'; btn.value = 'Update'; btn.onclick = function (i, j, k) { if (!j) { $WH.sp(k); } (ssm_Edit.bind(this, i, j))(); }.bind(btn, screenshot, isAlt); div.appendChild(btn); var c = $WH.ce('span'); c.appendChild($WH.ct(' ')); div.appendChild(c); btn = $WH.ce('input'); btn.type = 'button'; btn.value = 'Cancel'; btn.onclick = function (i, j, k) { if (!j) { $WH.sp(k); } (ssm_CancelEdit.bind(this, i, j))(); }.bind(btn, screenshot, isAlt); div.appendChild(btn); sp.style.display = 'none'; sp.nextSibling.style.display = 'none'; node.insertBefore(div, sp); iCaption.focus() } function ssm_CancelEdit(screenshot, isAlt) { var node; if (isAlt) { node = $WH.ge('alt2-' + screenshot.id); } else { node = $WH.ge('alt-' + screenshot.id); } var sp = $WH.gE(node, 'span')[1]; sp.style.display = ''; sp.nextSibling.style.display = ''; node.removeChild(node.firstChild); } function ssm_Edit(screenshot, isAlt) { var node; if (isAlt) { node = $WH.ge('alt2-' + screenshot.id); } else { node = $WH.ge('alt-' + screenshot.id); } var desc = node.firstChild.childNodes; if (desc[0].value == screenshot.caption) { ssm_CancelEdit(screenshot, isAlt); return } screenshot.caption = desc[0].value; ssm_CancelEdit(screenshot, isAlt); node = node.firstChild; while (node.childNodes.length > 0) { node.removeChild(node.firstChild); } $WH.ae(node, $WH.ct(screenshot.caption)); new Ajax('?admin=screenshots&action=editalt&id=' + screenshot.id, { method: 'POST', params: 'alt=' + $WH.urlencode(screenshot.caption) }) } function ssm_Clear(screenshot, isAlt) { var node; if (isAlt) { node = $WH.ge('alt2-' + screenshot.id); } else { node = $WH.ge('alt-' + screenshot.id); } var sp = $WH.gE(node, 'span'); var a = $WH.gE(sp[1], 'a'); sp = sp[0]; if (screenshot.caption == '') { return; } screenshot.caption = ''; sp.innerHTML = 'NULL'; new Ajax('?admin=screenshots&action=editalt&id=' + screenshot.id, { method: 'POST', params: 'alt=' + $WH.urlencode('') }) } function ssm_Approve(openNext) { var _self = this; new Ajax('?admin=screenshots&action=approve&id=' + _self.id, { method: 'get', onSuccess: function (x) { Lightbox.hide(); if (ssm_numPending == 1 && _self.pending) { ss_Refresh(true); } else { ss_Refresh(); ss_Manage(ss_managedRow, _self.type, _self.typeId, openNext, 0); } } }) } function ssm_Sticky(openNext) { var _self = this; new Ajax('?admin=screenshots&action=sticky&id=' + _self.id, { method: 'get', onSuccess: function (x) { Lightbox.hide(); if (ssm_numPending == 1 && _self.pending) { ss_Refresh(true); } else { ss_Refresh(); ss_Manage(ss_managedRow, _self.type, _self.typeId, openNext, 0); } } }) } function ssm_Delete(openNext) { var _self = this; new Ajax('?admin=screenshots&action=delete&id=' + _self.id, { method: 'get', onSuccess: function (x) { Lightbox.hide(); if (ssm_numPending == 1 && _self.pending) { ss_Refresh(true); } else { ss_Refresh(); ss_Manage(ss_managedRow, _self.type, _self.typeId, openNext, 0); } } }); } function ssm_Relocate(typeId) { var _self = this; new Ajax('?admin=screenshots&action=relocate&id=' + _self.id + '&typeid=' + typeId, { method: 'get', onSuccess: function (x) { ss_Refresh(); ss_Manage(ss_managedRow, _self.type, typeId); } }); } var ScreenshotManager = new function () { var screenshot, pos, imgWidth, imgHeight, scale, desiredScale, container, screen, imgDiv, aPrev, aNext, aCover, aOriginal, divFrom, divCaption, __div, h2Name, u, aEdit, aClear, spApprove, aApprove, aMakeSticky, aDelete, loadingImage, lightboxComponents; function computeDimensions(captionExtraHeight) { var availHeight = Math.max(50, Math.min(618, $WH.g_getWindowSize().h - 122 - captionExtraHeight)); if (screenshot.id) { desiredScale = Math.min(772 / screenshot.width, 618 / screenshot.height); scale = Math.min(772 / screenshot.width, availHeight / screenshot.height); } else { desiredScale = scale = 1; } if (desiredScale > 1) { desiredScale = 1; } if (scale > 1) { scale = 1; } imgWidth = Math.round(scale * screenshot.width); imgHeight = Math.round(scale * screenshot.height); var lbWidth = Math.max(480, imgWidth); Lightbox.setSize(lbWidth + 20, imgHeight + 116 + captionExtraHeight); if (captionExtraHeight) { imgDiv.firstChild.width = imgWidth; imgDiv.firstChild.height = imgHeight; } } function render(resizing) { if (resizing && (scale == desiredScale) && $WH.g_getWindowSize().h > container.offsetHeight) { return; } container.style.visibility = 'hidden'; var resized = (screenshot.width > 772 || screenshot.height > 618); computeDimensions(0); var url = g_staticUrl + '/uploads/screenshots/' + (screenshot.pending ? 'pending' : 'normal') + '/' + screenshot.id + '.jpg'; var html = ''; } divCaption.innerHTML = html; } else { divCaption.innerHTML = 'NULL'; } __div.id = 'alt2-' + screenshot.id; aEdit.onclick = ssm_ShowEdit.bind(aEdit, screenshot, true); aClear.onclick = ssm_Clear.bind(aClear, screenshot, true); if (screenshot.next !== undefined) { aPrev.style.display = aNext.style.display = ''; aCover.style.display = 'none'; } else { aPrev.style.display = aNext.style.display = 'none'; aCover.style.display = ''; } } Lightbox.reveal(); if (divCaption.offsetHeight > 18) { computeDimensions(divCaption.offsetHeight - 18); } container.style.visibility = 'visible'; } function nextScreenshot() { if (screenshot.next !== undefined) { screenshot = ssm_screenshotData[screenshot.next]; } onRender(); } function prevScreenshot() { if (screenshot.prev !== undefined) { screenshot = ssm_screenshotData[screenshot.prev]; } onRender(); } function onResize() { render(1); } function onHide() { aApprove.onclick = aMakeSticky.onclick = aDelete.onclick = null; cancelImageLoading(); } function onShow(dest, first, opt) { screenshot = opt; container = dest; if (first) { dest.className = 'screenshotviewer'; screen = $WH.ce('div'); screen.className = 'screenshotviewer-screen'; aPrev = $WH.ce('a'); aNext = $WH.ce('a'); aPrev.className = 'screenshotviewer-prev'; aNext.className = 'screenshotviewer-next'; aPrev.href = 'javascript:;'; aNext.href = 'javascript:;'; var foo = $WH.ce('span'); $WH.ae(foo, $WH.ce('b')); $WH.ae(aPrev, foo); var foo = $WH.ce('span'); $WH.ae(foo, $WH.ce('b')); $WH.ae(aNext, foo); aPrev.onclick = prevScreenshot; aNext.onclick = nextScreenshot; aCover = $WH.ce('a'); aCover.className = 'screenshotviewer-cover'; aCover.href = 'javascript:;'; aCover.onclick = Lightbox.hide; var foo = $WH.ce('span'); $WH.ae(foo, $WH.ce('b')); $WH.ae(aCover, foo); $WH.ae(screen, aPrev); $WH.ae(screen, aNext); $WH.ae(screen, aCover); var _div = $WH.ce('div'); _div.className = 'text'; h2Name = $WH.ce('h2'); h2Name.className = 'first'; $WH.ae(h2Name, $WH.ct(screenshot.name)); $WH.ae(_div, h2Name); $WH.ae(dest, _div); imgDiv = $WH.ce('div'); $WH.ae(screen, imgDiv); $WH.ae(dest, screen); var _div = $WH.ce('div'); _div.style.paddingTop = '6px'; _div.style.cssFloat = _div.style.styleFloat = 'right'; _div.className = 'bigger-links'; aApprove = $WH.ce('a'); aApprove.href = 'javascript:;'; $WH.ae(aApprove, $WH.ct('Approve')); $WH.ae(_div, aApprove); spApprove = $WH.ce('span'); spApprove.style.display = 'none'; $WH.ae(spApprove, $WH.ct('Approve')); $WH.ae(_div, spApprove); $WH.ae(_div, makePipe()); aMakeSticky = $WH.ce('a'); aMakeSticky.href = 'javascript:;'; $WH.ae(aMakeSticky, $WH.ct('Make sticky')); $WH.ae(_div, aMakeSticky); $WH.ae(_div, makePipe()); aDelete = $WH.ce('a'); aDelete.href = 'javascript:;'; $WH.ae(aDelete, $WH.ct('Delete')); $WH.ae(_div, aDelete); u = _div; $WH.ae(dest, _div); divFrom = $WH.ce('div'); divFrom.className = 'screenshotviewer-from'; var sp = $WH.ce('span'); $WH.ae(sp, $WH.ct(LANG.lvscreenshot_from)); $WH.ae(sp, $WH.ce('a')); $WH.ae(sp, $WH.ct(' ')); $WH.ae(sp, $WH.ce('span')); $WH.ae(divFrom, sp); $WH.ae(dest, divFrom); _div = $WH.ce('div'); _div.className = 'clear'; $WH.ae(dest, _div); var aClose = $WH.ce('a'); aClose.className = 'screenshotviewer-close'; aClose.href = 'javascript:;'; aClose.onclick = Lightbox.hide; $WH.ae(aClose, $WH.ce('span')); $WH.ae(dest, aClose); aOriginal = $WH.ce('a'); aOriginal.className = 'screenshotviewer-original'; aOriginal.href = 'javascript:;'; aOriginal.target = '_blank'; $WH.ae(aOriginal, $WH.ce('span')); $WH.ae(dest, aOriginal); __div = $WH.ce('div'); divCaption = $WH.ce('span'); divCaption.style.paddingRight = '8px'; $WH.ae(__div, divCaption); var sp = $WH.ce('span'); sp.style.whiteSpace = 'nowrap'; aEdit = $WH.ce('a'); aEdit.href = 'javascript:;'; $WH.ae(aEdit, $WH.ct('Edit')); $WH.ae(sp, aEdit); $WH.ae(sp, makePipe()); aClear = $WH.ce('a'); aClear.href = 'javascript:;'; $WH.ae(aClear, $WH.ct('Clear')); $WH.ae(sp, aClear); $WH.ae(__div, sp); $WH.ae(dest, __div); _div = $WH.ce('div'); _div.className = 'clear'; $WH.ae(dest, _div); } else { $WH.ee(h2Name); $WH.ae(h2Name, $WH.ct(screenshot.name)); } onRender(); } function onRender() { if (screenshot.pending) { aApprove.onclick = ssm_Approve.bind(screenshot, true); aMakeSticky.onclick = ssm_Sticky.bind(screenshot, true); aDelete.onclick = ssm_Delete.bind(screenshot, true); } else { aMakeSticky.onclick = ssm_Sticky.bind(screenshot, true); aDelete.onclick = ssm_Delete.bind(screenshot, true); } aApprove.style.display = screenshot.pending ? '' : 'none'; spApprove.style.display = screenshot.pending ? 'none' : ''; if (!screenshot.width || !screenshot.height) { if (loadingImage) { loadingImage.onload = null; loadingImage.onerror = null; } else { container.className = ''; lightboxComponents = []; while (container.firstChild) { lightboxComponents.push(container.firstChild); $WH.de(container.firstChild); } } var lightboxTimer = setTimeout(function () { screenshot.width = 126; screenshot.height = 22; computeDimensions(0); screenshot.width = null; screenshot.height = null; var div = $WH.ce('div'); div.style.margin = '0 auto'; div.style.width = '126px'; var img = $WH.ce('img'); img.src = g_staticUrl + '/images/ui/misc/progress-anim.gif'; img.width = 126; img.height = 22; $WH.ae(div, img); $WH.ae(container, div); Lightbox.reveal(); container.style.visiblity = 'visible'; }, 150); loadingImage = new Image(); loadingImage.onload = (function (screen, timer) { clearTimeout(timer); screen.width = this.width; screen.height = this.height; loadingImage = null; restoreLightbox(); render(); }).bind(loadingImage, screenshot, lightboxTimer); loadingImage.onerror = (function (timer) { clearTimeout(timer); loadingImage = null; Lightbox.hide(); restoreLightbox(); }).bind(loadingImage, lightboxTimer); loadingImage.src = (screenshot.url ? screenshot.url : g_staticUrl + '/uploads/screenshots/' + (screenshot.pending ? 'pending' : 'normal') + '/' + screenshot.id + '.jpg'); } else { render(); } } function cancelImageLoading() { if (!loadingImage) { return; } loadingImage.onload = null; loadingImage.onerror = null; loadingImage = null; restoreLightbox(); } function restoreLightbox() { if (!lightboxComponents) { return; } $WH.ee(container); container.className = 'screenshotviewer'; for (var i = 0; i < lightboxComponents.length; ++i) { $WH.ae(container, lightboxComponents[i]); } lightboxComponents = null; } this.show = function (opt) { Lightbox.show('screenshotmanager', { onShow: onShow, onHide: onHide, onResize: onResize }, opt); } }; \ No newline at end of file +var ss_managedRow = null; +var ss_getAll = false; // never changed (maybe with ?admin=screenshots&all) +var ssm_ViewedRow = null; +var ssm_screenshotData = []; +var ssm_screenshotPages = []; +var ssm_numPagesFound = 0; +var ssm_numPages = 0; // never accessed +var ssm_numPending = 0; +var ssm_statuses = { + 0 : 'Pending', + 999: 'Deleted', + 100: 'Approved', + 105: 'Sticky' +}; + +function makePipe() { + var sp = $WH.ce('span'); + $WH.ae(sp, $WH.ct(' ')); + + var sm = $WH.ce('small'); + sm.className = 'q0'; + $WH.ae(sm, $WH.ct('|')); + + $WH.ae(sp, sm); + $WH.ae(sp, $WH.ct(' ')); + + return sp; +} + +function ss_OnResize() { + var _ = Math.max(100, Math.min($WH.g_getWindowSize().h - 50, 700)); + + $WH.ge('menu-container').style.height = $WH.ge('pages-container').style.height = _ + 'px'; + $WH.ge('data-container').style.height = _ + 'px'; +} + +$WH.aE(window, 'resize', ss_OnResize); + +function ss_Refresh(openNext, type, typeId) { + new Ajax('?admin=screenshots&action=list' + (ss_getAll ? '&all' : ''), { + method: 'get', + onSuccess: function (xhr) { + eval(xhr.responseText); + + if (ssm_screenshotPages.length > 0) { + $WH.ge('show-all-pages').innerHTML = ' – Show All (' + ssm_numPagesFound + ')'; + + ssm_UpdatePages(); + + if (openNext) { + ss_Manage($WH.ge('pages-container').firstChild.firstChild, ssm_screenshotPages[0].type, ssm_screenshotPages[0].typeId, true); + } + else if (type && typeId) { + ss_Manage(null, type, typeId, true); + } + } + else { + $WH.ee($WH.ge('show-all-pages')); + $WH.ge('pages-container').innerHTML = 'NO SCREENZSHOT NEEDS 2 BE APPRVED NOW KTHX. :)'; + if (type && typeId) { + ss_Manage(null, type, typeId, true); + } + } + } + }); +} + +function ss_Manage(_this, type, typeId, openNext) { + new Ajax('?admin=screenshots&action=manage&type=' + type + '&typeid=' + typeId, { + method: 'get', + onSuccess: function (xhr) { + + eval(xhr.responseText); + ssm_numPending = 0; + + for (var i in ssm_screenshotData) { + if (ssm_screenshotData[i].pending) { + ssm_numPending++; + } + } + + var nRows = ssm_screenshotData.length; + $WH.ge('screenshotTotal').innerHTML = nRows + ' total' + (nRows == 100 ? ' (limit reached)' : ''); + + ssm_UpdateList(openNext); + ssm_UpdateMassLinks(); + + if (ss_managedRow != null) { + ss_ColorizeRow('transparent'); + } + + ss_managedRow = _this; + + if (ss_managedRow != null) { + ss_ColorizeRow('#282828'); + } + } + }); +} + +function ss_ManageUser() { + var username = $WH.ge('usermanage'); + username.value = $WH.trim(username.value); + + if (username.value.length < 4) { + alert('Username must be at least 4 characters long.'); + username.focus(); + + return false; + } + + if (username.value.match(/[^a-z0-9]/i) != null) { + alert('Username can only contain letters and numbers.'); + username.focus(); + + return false; + } + + new Ajax('?admin=screenshots&action=manage&user=' + username.value, { + method: 'get', + onSuccess: function (xhr) { + eval(xhr.responseText); + var nRows = ssm_screenshotData.length; + $WH.ge('screenshotTotal').innerHTML = nRows + ' total' + (nRows == 100 ? ' (limit reached)' : ''); + ssm_UpdateList(); + ssm_UpdateMassLinks(); + if (ss_managedRow != null) { + ss_ColorizeRow('transparent'); + } + } + }); + + return true; +} + +function ss_ColorizeRow(color) { + for (var i = 0; i < ss_managedRow.childNodes.length; ++i) { + ss_managedRow.childNodes[i].style.backgroundColor = color; + } +} + +function ssm_GetScreenshot(id) { + for (var i in ssm_screenshotData) { + if (ssm_screenshotData[i].id == id) { + return ssm_screenshotData[i]; + } + } + + return null; +} + +function ssm_View(row, id) { + if (ssm_ViewedRow != null) { + ssm_ColorizeRow('transparent'); + } + + ssm_ViewedRow = row; + ssm_ColorizeRow('#282828'); + + var screenshot = ssm_GetScreenshot(id); + if (screenshot != null) { + ScreenshotManager.show(screenshot); + } +} + +function ssm_ColorizeRow(color) { + for (var i = 0; i < ssm_ViewedRow.childNodes.length; ++i) { + ssm_ViewedRow.childNodes[i].style.backgroundColor = color; + } +} + +function ssm_ConfirmMassApprove() { + ajaxAnchor(this); // sarjuuk custom - there has to be something in place or we are manually using a script for ajax + + return false; + // return true; +} + +function ssm_ConfirmMassDelete() { + if (confirm('Delete selected screenshot(s)?')) // sarjuuk custom - see above + ajaxAnchor(this); + + return false; + // return confirm('Delete selected screenshot(s)?'); +} + +function ssm_ConfirmMassSticky() { + if (confirm('Sticky selected screenshot(s)?')) // sarjuuk custom - see above + ajaxAnchor(this); + + return false; + // return confirm('Sticky selected screenshot(s)?'); +} + +function ssm_UpdatePages(UNUSED) { + var pc = $WH.ge('pages-container'); + $WH.ee(pc); + + var tbl = $WH.ce('table'); + tbl.className = 'grid'; + tbl.style.width = '400px'; + + var tr = $WH.ce('tr'); + + var th = $WH.ce('th'); + $WH.ae(th, $WH.ct('Page')); + $WH.ae(tr, th); + + th = $WH.ce('th'); + $WH.ae(th, $WH.ct('Submitted')); + $WH.ae(tr, th); + + th = $WH.ce('th'); + th.align = 'right'; + $WH.ae(th, $WH.ct('#')); + $WH.ae(tr, th); + + $WH.ae(tbl, tr); + + var now = new Date(); + for (var i in ssm_screenshotPages) { + var ssPage = ssm_screenshotPages[i]; + tr = $WH.ce('tr'); + tr.onclick = ss_Manage.bind(tr, tr, ssPage.type, ssPage.typeId, true, i); + + var td = $WH.ce('td'); + var a = $WH.ce('a'); + a.href = '?' + g_types[ssPage.type] + '=' + ssPage.typeId; + a.target = '_blank'; + $WH.ae(a, $WH.ct(ssPage.name)); + $WH.ae(td, a); + $WH.ae(tr, td); + + td = $WH.ce('td'); + var elapsed = new Date(ssPage.date); + $WH.ae(td, $WH.ct(g_formatTimeElapsed((now.getTime() - elapsed.getTime()) / 1000) + ' ago')); + $WH.ae(tr, td); + + td = $WH.ce('td'); + td.align = 'right'; + $WH.ae(td, $WH.ct(ssPage.count)); + $WH.ae(tr, td); + + $WH.ae(tbl, tr); + } + + $WH.ae(pc, tbl); +} + +function ssm_UpdateList(openNext) { + var tsl = $WH.ge('theScreenshotsList'); + var tBody = false; + var i = 1; + + while (tsl.childNodes.length > i) { + if (tsl.childNodes[i].nodeName == 'TR' && tBody) { + $WH.de(tsl.childNodes[i]); + } + else if (tsl.childNodes[i].nodeName == 'TR') { + tBody = true; + } + else { + i++; + } + } + + var now = new Date(); + var ssId = 0; + for (var i in ssm_screenshotData) { + var screenshot = ssm_screenshotData[i]; + var tr = $WH.ce('tr'); + if (ssId == 0 && screenshot.pending) { + ssId = screenshot.id; + tr.id = 'highlightedRow'; + } + + var td = $WH.ce('td'); + td.align = 'center'; + + var a = $WH.ce('a'); + a.href = g_staticUrl + '/uploads/screenshots/' + (screenshot.status != 999 && !screenshot.pending ? 'normal' : 'pending') + '/' + screenshot.id + '.jpg'; + a.target = '_blank'; + a.onclick = function (id, e) { + $WH.sp(e); + (ssm_View.bind(null, this, id))(); + return false; + }.bind(tr, screenshot.id); + + var img = $WH.ce('img'); + img.src = g_staticUrl + '/uploads/screenshots/' + (screenshot.status != 999 && !screenshot.pending ? 'thumb' : 'pending') + '/' + screenshot.id + '.jpg'; + img.height = 50; + $WH.ae(a, img); + + $WH.ae(td, a); + $WH.ae(tr, td); + + td = $WH.ce('td'); + if (screenshot.status != 999 && !screenshot.pending) { + var a = $WH.ce('a'); + a.href = '?' + g_types[screenshot.type] + '=' + screenshot.typeId + '#screenshots:id=' + screenshot.id; + a.target = '_blank'; + a.onclick = function (e) { + $WH.sp(e); + }; + $WH.ae(a, $WH.ct(screenshot.id)); + $WH.ae(td, a); + } + else { + $WH.ae(td, $WH.ct(screenshot.id)); + } + $WH.ae(tr, td); + + td = $WH.ce('td'); + td.id = 'alt-' + screenshot.id; + + var sp = $WH.ce('span'); + sp.style.paddingRight = '8px'; + if (screenshot.caption) { + var sp2 = $WH.ce('span'); + sp2.className = 'q2'; + var b = $WH.ce('b'); + $WH.ae(b, $WH.ct(screenshot.caption)); + $WH.ae(sp2, b); + $WH.ae(sp, sp2); + } + else { + var it = $WH.ce('i'); + it.className = 'q0'; + $WH.ae(it, $WH.ct('NULL')); + $WH.ae(sp, it); + } + $WH.ae(td, sp); + + sp = $WH.ce('span'); + sp.style.whiteSpace = 'nowrap'; + + var a = $WH.ce('a'); + a.href = 'javascript:;'; + a.onclick = function (id, e) { + $WH.sp(e); + (ssm_ShowEdit.bind(this, id))() + }.bind(a, screenshot); + $WH.ae(a, $WH.ct('Edit')); + $WH.ae(sp, a); + $WH.ae(sp, makePipe()); + + a = $WH.ce('a'); + a.href = 'javascript:;'; + a.onclick = function (id, e) { + $WH.sp(e); + (ssm_Clear.bind(this, id))() + }.bind(a, screenshot); + $WH.ae(a, $WH.ct('Clear')); + $WH.ae(sp, a); + $WH.ae(td, sp); + $WH.ae(tr, td); + + td = $WH.ce('td'); + var elapsed = new Date(screenshot.date); + $WH.ae(td, $WH.ct(g_formatTimeElapsed((now.getTime() - elapsed.getTime()) / 1000) + ' ago')); + $WH.ae(tr, td); + + td = $WH.ce('td'); + a = $WH.ce('a'); + a.href = '?user=' + screenshot.user; + a.target = '_blank'; + a.onclick = function (e) { + $WH.sp(e); + }; + $WH.ae(a, $WH.ct(screenshot.user)); + $WH.ae(td, a); + $WH.ae(tr, td); + + td = $WH.ce('td'); + $WH.ae(td, $WH.ct(ssm_statuses[screenshot.status])); + $WH.ae(tr, td); + + td = $WH.ce('td'); + var cb = $WH.ce('input'); + cb.type = 'checkbox'; + cb.value = screenshot.id; + cb.onclick = function (e) { + $WH.sp(e); + (ssm_UpdateMassLinks.bind(this))(); + }.bind(cb); + $WH.ae(td, cb); + $WH.ae(td, $WH.ct(' ')); + + if (screenshot.status != 999) { + tr.onclick = function (id) { + ssm_View(this, id); + return false; + }.bind(tr, screenshot.id); + + if (screenshot.id == ssId && openNext) { + ssm_View(tr, screenshot.id); + } + + if (screenshot.pending) { + a = $WH.ce('a'); + a.href = 'javascript:;'; + a.onclick = function (e) { + $WH.sp(e); + (ssm_Approve.bind(this, false))() + }.bind(screenshot); + $WH.ae(a, $WH.ct('Approve')); + $WH.ae(td, a); + } + else { + $WH.ae(td, $WH.ct('Approve')); + } + + $WH.ae(td, makePipe()); + + if (screenshot.status != 105) { + a = $WH.ce('a'); + a.href = 'javascript:;'; + a.onclick = function (e) { + $WH.sp(e); + (ssm_Sticky.bind(this, false))(); + }.bind(screenshot); + $WH.ae(a, $WH.ct('Make sticky')); + $WH.ae(td, a); + } + else { + $WH.ae(td, $WH.ct('Make sticky')); + } + $WH.ae(td, makePipe()); + + a = $WH.ce('a'); + a.href = 'javascript:;'; + a.onclick = function (e) { + $WH.sp(e); + (ssm_Delete.bind(this, false))(); + }.bind(screenshot); + $WH.ae(a, $WH.ct('Delete')); + $WH.ae(td, a); + $WH.ae(td, makePipe()); + + a = $WH.ce('a'); + a.href = 'javascript:;'; + a.onclick = function (e) { + $WH.sp(e); + var id = prompt('Enter the ID to move this screenshot to:'); + (ssm_Relocate.bind(this, id))(); + }.bind(screenshot); + $WH.ae(a, $WH.ct('Relocate')); + $WH.ae(td, a); + } + + $WH.ae(tr, td); + $WH.ae(tsl, tr); + } +} + +function ssm_UpdateMassLinks() { + var buff = ''; + var i = 0; + var tSL = $WH.ge('theScreenshotsList'); + var inp = $WH.gE(tSL, 'input'); + + $WH.array_walk(inp, function (x) { + if (x.checked) { + buff += x.value + ','; + ++i; + } + }); + + buff = $WH.rtrim(buff, ','); + + var selCnt = $WH.ge('withselected'); + if (i > 0) { + selCnt.style.display = ''; + $WH.gE(selCnt, 'b')[0].firstChild.nodeValue = '(' + i + ')'; + + var c = $WH.ge('massapprove'); + var b = $WH.ge('massdelete'); + var a = $WH.ge('masssticky'); + + c.href = '?admin=screenshots&action=approve&id=' + buff; + c.onclick = ssm_ConfirmMassApprove; + + b.href = '?admin=screenshots&action=delete&id=' + buff; + b.onclick = ssm_ConfirmMassDelete; + + a.href = '?admin=screenshots&action=sticky&id=' + buff; + a.onclick = ssm_ConfirmMassSticky; + } + else { + selCnt.style.display = 'none'; + } +} + +function ssm_MassSelect(action) { + var tSL = $WH.ge('theScreenshotsList'); + var inp = $WH.gE(tSL, 'input'); + + switch (parseInt(action)) { + case 1: + $WH.array_walk(inp, function (x) { x.checked = true }); + break; + case 0: + $WH.array_walk(inp, function (x) { x.checked = false }); + break; + case -1: + $WH.array_walk(inp, function (x) { x.checked = !x.checked }); + break; + case 2: + $WH.array_walk(inp, function (x) { x.checked = ssm_GetScreenshot(x.value).status == 0 }); + break; + case 5: + $WH.array_walk(inp, function (x) { x.checked = ssm_GetScreenshot(x.value).unique == 1 && ssm_GetScreenshot(x.value).status == 0 }); + break; + case 3: + $WH.array_walk(inp, function (x) { x.checked = ssm_GetScreenshot(x.value).status == 100 }); + break; + case 4: + $WH.array_walk(inp, function (x) { x.checked = ssm_GetScreenshot(x.value).status == 105 }); + break; + default: + return; + } + + ssm_UpdateMassLinks(); +} + +function ssm_ShowEdit(screenshot, isAlt) { + var node; + + if (isAlt) { + node = $WH.ge('alt2-' + screenshot.id) + } + else { + node = $WH.ge('alt-' + screenshot.id) + } + + var sp = $WH.gE(node, 'span')[0]; + var div = $WH.ce('div'); + div.style.whiteSpace = 'nowrap'; + var iCaption = $WH.ce('input'); + iCaption.type = 'text'; + iCaption.value = screenshot.caption; + iCaption.maxLength = 200; + iCaption.size = 35; + iCaption.onclick = function (e) { $WH.sp(e); } // sarjuuk - custom to inhibit screenshot popup, when clicking into input element + div.appendChild(iCaption); + + var btn = $WH.ce('input'); + btn.type = 'button'; + btn.value = 'Update'; + btn.onclick = function (i, j, k) { + if (!j) { + $WH.sp(k); + } + + (ssm_Edit.bind(this, i, j))(); + }.bind(btn, screenshot, isAlt); + div.appendChild(btn); + + var c = $WH.ce('span'); + c.appendChild($WH.ct(' ')); + div.appendChild(c); + + btn = $WH.ce('input'); + btn.type = 'button'; + btn.value = 'Cancel'; + btn.onclick = function (i, j, k) { + if (!j) { + $WH.sp(k); + } + + (ssm_CancelEdit.bind(this, i, j))(); + }.bind(btn, screenshot, isAlt); + div.appendChild(btn); + + sp.style.display = 'none'; + sp.nextSibling.style.display = 'none'; + node.insertBefore(div, sp); + + iCaption.focus() +} + +function ssm_CancelEdit(screenshot, isAlt) { + var node; + + if (isAlt) { + node = $WH.ge('alt2-' + screenshot.id); + } + else { + node = $WH.ge('alt-' + screenshot.id); + } + + var sp = $WH.gE(node, 'span')[1]; + sp.style.display = ''; + sp.nextSibling.style.display = ''; + + node.removeChild(node.firstChild); +} + +function ssm_Edit(screenshot, isAlt) { + var node; + + if (isAlt) { + node = $WH.ge('alt2-' + screenshot.id); + } + else { + node = $WH.ge('alt-' + screenshot.id); + } + + var desc = node.firstChild.childNodes; + if (desc[0].value == screenshot.caption) { + ssm_CancelEdit(screenshot, isAlt); + return + } + screenshot.caption = desc[0].value; + + ssm_CancelEdit(screenshot, isAlt); + + node = node.firstChild; + while (node.childNodes.length > 0) { + node.removeChild(node.firstChild); + } + $WH.ae(node, $WH.ct(screenshot.caption)); + + new Ajax('?admin=screenshots&action=editalt&id=' + screenshot.id, { + method: 'POST', + params: 'alt=' + $WH.urlencode(screenshot.caption) + }) +} + +function ssm_Clear(screenshot, isAlt) { + var node; + + if (isAlt) { + node = $WH.ge('alt2-' + screenshot.id); + } + else { + node = $WH.ge('alt-' + screenshot.id); + } + + var sp = $WH.gE(node, 'span'); + var a = $WH.gE(sp[1], 'a'); + sp = sp[0]; + + if (screenshot.caption == '') { + return; + } + + screenshot.caption = ''; + sp.innerHTML = 'NULL'; + + new Ajax('?admin=screenshots&action=editalt&id=' + screenshot.id, { + method: 'POST', + params: 'alt=' + $WH.urlencode('') + }) +} + +function ssm_Approve(openNext) { + var _self = this; + new Ajax('?admin=screenshots&action=approve&id=' + _self.id, { + method: 'get', + onSuccess: function (x) { + Lightbox.hide(); + if (ssm_numPending == 1 && _self.pending) { + ss_Refresh(true); + } + else { + ss_Refresh(); + ss_Manage(ss_managedRow, _self.type, _self.typeId, openNext, 0); + } + } + }) +} + +function ssm_Sticky(openNext) { + var _self = this; + new Ajax('?admin=screenshots&action=sticky&id=' + _self.id, { + method: 'get', + onSuccess: function (x) { + Lightbox.hide(); + if (ssm_numPending == 1 && _self.pending) { + ss_Refresh(true); + } + else { + ss_Refresh(); + ss_Manage(ss_managedRow, _self.type, _self.typeId, openNext, 0); + } + } + }) +} + +function ssm_Delete(openNext) { + var _self = this; + new Ajax('?admin=screenshots&action=delete&id=' + _self.id, { + method: 'get', + onSuccess: function (x) { + Lightbox.hide(); + if (ssm_numPending == 1 && _self.pending) { + ss_Refresh(true); + } + else { + ss_Refresh(); + ss_Manage(ss_managedRow, _self.type, _self.typeId, openNext, 0); + } + } + }); +} + +function ssm_Relocate(typeId) { + var _self = this; + new Ajax('?admin=screenshots&action=relocate&id=' + _self.id + '&typeid=' + typeId, { + method: 'get', + onSuccess: function (x) { + ss_Refresh(); + ss_Manage(ss_managedRow, _self.type, typeId); + } + }); +} + +var ScreenshotManager = new function () { + var + screenshot, + pos, + imgWidth, + imgHeight, + scale, + desiredScale, + container, + screen, + imgDiv, + aPrev, + aNext, + aCover, + aOriginal, + divFrom, + divCaption, + __div, + h2Name, + u, + aEdit, + aClear, + spApprove, + aApprove, + aMakeSticky, + aDelete, + loadingImage, + lightboxComponents; + + function computeDimensions(captionExtraHeight) { + var availHeight = Math.max(50, Math.min(618, $WH.g_getWindowSize().h - 122 - captionExtraHeight)); + + if (screenshot.id) { + desiredScale = Math.min(772 / screenshot.width, 618 / screenshot.height); + scale = Math.min(772 / screenshot.width, availHeight / screenshot.height); + } + else { + desiredScale = scale = 1; + } + + if (desiredScale > 1) { + desiredScale = 1; + } + + if (scale > 1) { + scale = 1; + } + + imgWidth = Math.round(scale * screenshot.width); + imgHeight = Math.round(scale * screenshot.height); + var lbWidth = Math.max(480, imgWidth); + + Lightbox.setSize(lbWidth + 20, imgHeight + 116 + captionExtraHeight); + + if (captionExtraHeight) { + imgDiv.firstChild.width = imgWidth; + imgDiv.firstChild.height = imgHeight; + } + } + + function render(resizing) { + if (resizing && (scale == desiredScale) && $WH.g_getWindowSize().h > container.offsetHeight) { + return; + } + + container.style.visibility = 'hidden'; + + var + resized = (screenshot.width > 772 || screenshot.height > 618); + + computeDimensions(0); + + var url = g_staticUrl + '/uploads/screenshots/' + (screenshot.pending ? 'pending' : 'normal') + '/' + screenshot.id + '.jpg'; + + var html = ''; + } + + divCaption.innerHTML = html; + } + else { + divCaption.innerHTML = 'NULL'; + } + + __div.id = 'alt2-' + screenshot.id; + + aEdit.onclick = ssm_ShowEdit.bind(aEdit, screenshot, true); + aClear.onclick = ssm_Clear.bind(aClear, screenshot, true); + + if (screenshot.next !== undefined) { + aPrev.style.display = aNext.style.display = ''; + aCover.style.display = 'none'; + } + else { + aPrev.style.display = aNext.style.display = 'none'; + aCover.style.display = ''; + } + } + + Lightbox.reveal(); + + if (divCaption.offsetHeight > 18) { + computeDimensions(divCaption.offsetHeight - 18); + } + container.style.visibility = 'visible'; + } + + function nextScreenshot() { + if (screenshot.next !== undefined) { + screenshot = ssm_screenshotData[screenshot.next]; + } + + onRender(); + } + + function prevScreenshot() { + if (screenshot.prev !== undefined) { + screenshot = ssm_screenshotData[screenshot.prev]; + } + + onRender(); + } + + function onResize() { + render(1); + } + + function onHide() { + aApprove.onclick = aMakeSticky.onclick = aDelete.onclick = null; + cancelImageLoading(); + } + + function onShow(dest, first, opt) { + screenshot = opt; + container = dest; + + if (first) { + dest.className = 'screenshotviewer'; + + screen = $WH.ce('div'); + + screen.className = 'screenshotviewer-screen'; + + aPrev = $WH.ce('a'); + aNext = $WH.ce('a'); + aPrev.className = 'screenshotviewer-prev'; + aNext.className = 'screenshotviewer-next'; + aPrev.href = 'javascript:;'; + aNext.href = 'javascript:;'; + + var foo = $WH.ce('span'); + $WH.ae(foo, $WH.ce('b')); + $WH.ae(aPrev, foo); + var foo = $WH.ce('span'); + $WH.ae(foo, $WH.ce('b')); + $WH.ae(aNext, foo); + + aPrev.onclick = prevScreenshot; + aNext.onclick = nextScreenshot; + + aCover = $WH.ce('a'); + aCover.className = 'screenshotviewer-cover'; + aCover.href = 'javascript:;'; + aCover.onclick = Lightbox.hide; + var foo = $WH.ce('span'); + $WH.ae(foo, $WH.ce('b')); + $WH.ae(aCover, foo); + $WH.ae(screen, aPrev); + $WH.ae(screen, aNext); + $WH.ae(screen, aCover); + var _div = $WH.ce('div'); + _div.className = 'text'; + h2Name = $WH.ce('h2'); + h2Name.className = 'first'; + $WH.ae(h2Name, $WH.ct(screenshot.name)); + $WH.ae(_div, h2Name); + $WH.ae(dest, _div); + + imgDiv = $WH.ce('div'); + $WH.ae(screen, imgDiv); + + $WH.ae(dest, screen); + + var _div = $WH.ce('div'); + _div.style.paddingTop = '6px'; + _div.style.cssFloat = _div.style.styleFloat = 'right'; + _div.className = 'bigger-links'; + aApprove = $WH.ce('a'); + aApprove.href = 'javascript:;'; + $WH.ae(aApprove, $WH.ct('Approve')); + $WH.ae(_div, aApprove); + spApprove = $WH.ce('span'); + spApprove.style.display = 'none'; + $WH.ae(spApprove, $WH.ct('Approve')); + $WH.ae(_div, spApprove); + $WH.ae(_div, makePipe()); + aMakeSticky = $WH.ce('a'); + aMakeSticky.href = 'javascript:;'; + $WH.ae(aMakeSticky, $WH.ct('Make sticky')); + $WH.ae(_div, aMakeSticky); + $WH.ae(_div, makePipe()); + aDelete = $WH.ce('a'); + aDelete.href = 'javascript:;'; + $WH.ae(aDelete, $WH.ct('Delete')); + $WH.ae(_div, aDelete); + u = _div; + $WH.ae(dest, _div); + divFrom = $WH.ce('div'); + divFrom.className = 'screenshotviewer-from'; + var sp = $WH.ce('span'); + $WH.ae(sp, $WH.ct(LANG.lvscreenshot_from)); + $WH.ae(sp, $WH.ce('a')); + $WH.ae(sp, $WH.ct(' ')); + $WH.ae(sp, $WH.ce('span')); + $WH.ae(divFrom, sp); + $WH.ae(dest, divFrom); + _div = $WH.ce('div'); + _div.className = 'clear'; + $WH.ae(dest, _div); + var aClose = $WH.ce('a'); + aClose.className = 'screenshotviewer-close'; + aClose.href = 'javascript:;'; + aClose.onclick = Lightbox.hide; + $WH.ae(aClose, $WH.ce('span')); + $WH.ae(dest, aClose); + + aOriginal = $WH.ce('a'); + aOriginal.className = 'screenshotviewer-original'; + aOriginal.href = 'javascript:;'; + aOriginal.target = '_blank'; + $WH.ae(aOriginal, $WH.ce('span')); + $WH.ae(dest, aOriginal); + + __div = $WH.ce('div'); + divCaption = $WH.ce('span'); + divCaption.style.paddingRight = '8px'; + $WH.ae(__div, divCaption); + var sp = $WH.ce('span'); + sp.style.whiteSpace = 'nowrap'; + aEdit = $WH.ce('a'); + aEdit.href = 'javascript:;'; + $WH.ae(aEdit, $WH.ct('Edit')); + $WH.ae(sp, aEdit); + $WH.ae(sp, makePipe()); + aClear = $WH.ce('a'); + aClear.href = 'javascript:;'; + $WH.ae(aClear, $WH.ct('Clear')); + $WH.ae(sp, aClear); + $WH.ae(__div, sp); + $WH.ae(dest, __div); + _div = $WH.ce('div'); + _div.className = 'clear'; + $WH.ae(dest, _div); + } + else { + $WH.ee(h2Name); + $WH.ae(h2Name, $WH.ct(screenshot.name)); + } + + onRender(); + } + + function onRender() { + if (screenshot.pending) { + aApprove.onclick = ssm_Approve.bind(screenshot, true); + aMakeSticky.onclick = ssm_Sticky.bind(screenshot, true); + aDelete.onclick = ssm_Delete.bind(screenshot, true); + } + else { + aMakeSticky.onclick = ssm_Sticky.bind(screenshot, true); + aDelete.onclick = ssm_Delete.bind(screenshot, true); + } + + aApprove.style.display = screenshot.pending ? '' : 'none'; + spApprove.style.display = screenshot.pending ? 'none' : ''; + + if (!screenshot.width || !screenshot.height) { + if (loadingImage) { + loadingImage.onload = null; + loadingImage.onerror = null; + } + else { + container.className = ''; + lightboxComponents = []; + + while (container.firstChild) { + lightboxComponents.push(container.firstChild); + $WH.de(container.firstChild); + } + } + + var lightboxTimer = setTimeout(function () { + screenshot.width = 126; + screenshot.height = 22; + + computeDimensions(0); + + screenshot.width = null; + screenshot.height = null; + + var div = $WH.ce('div'); + div.style.margin = '0 auto'; + div.style.width = '126px'; + + var img = $WH.ce('img'); + img.src = g_staticUrl + '/images/ui/misc/progress-anim.gif'; + img.width = 126; + img.height = 22; + + $WH.ae(div, img); + $WH.ae(container, div); + + Lightbox.reveal(); + container.style.visiblity = 'visible'; + }, 150); + + loadingImage = new Image(); + loadingImage.onload = (function (screen, timer) { + clearTimeout(timer); + screen.width = this.width; + screen.height = this.height; + loadingImage = null; + restoreLightbox(); + render(); + }).bind(loadingImage, screenshot, lightboxTimer); + loadingImage.onerror = (function (timer) { + clearTimeout(timer); + loadingImage = null; + Lightbox.hide(); + restoreLightbox(); + }).bind(loadingImage, lightboxTimer); + loadingImage.src = (screenshot.url ? screenshot.url : g_staticUrl + '/uploads/screenshots/' + (screenshot.pending ? 'pending' : 'normal') + '/' + screenshot.id + '.jpg'); + } + else { + render(); + } + } + + function cancelImageLoading() { + if (!loadingImage) { + return; + } + + loadingImage.onload = null; + loadingImage.onerror = null; + loadingImage = null; + + restoreLightbox(); + } + + function restoreLightbox() { + if (!lightboxComponents) { + return; + } + + $WH.ee(container); + container.className = 'screenshotviewer'; + for (var i = 0; i < lightboxComponents.length; ++i) { + $WH.ae(container, lightboxComponents[i]); + } + + lightboxComponents = null; + } + + this.show = function (opt) { + Lightbox.show('screenshotmanager', { + onShow: onShow, + onHide: onHide, + onResize: onResize + }, opt); + } +}; diff --git a/template/bricks/contribute.tpl.php b/template/bricks/contribute.tpl.php index 90289714..4e4ddbca 100644 --- a/template/bricks/contribute.tpl.php +++ b/template/bricks/contribute.tpl.php @@ -6,7 +6,7 @@
brick('contrib_'.User::$localeId); + $this->localizedBrick('contrib', User::$localeId); ?>
diff --git a/template/bricks/contrib_0.tpl.php b/template/localized/contrib_0.tpl.php similarity index 90% rename from template/bricks/contrib_0.tpl.php rename to template/localized/contrib_0.tpl.php index e6f2531f..3216d5df 100644 --- a/template/bricks/contrib_0.tpl.php +++ b/template/localized/contrib_0.tpl.php @@ -30,11 +30,12 @@ if (User::$id > 0):
  • Be sure to read the tips & tricks if you haven't before.
  • +ssError ? '
    '.$this->ssError."
    \n
    \n" : ''; +?>
    - File:
    -
    - Caption: Optional, up to 200 characters
    +
    @@ -51,10 +52,8 @@ if (User::$id > 0):
    - URL: Supported: YouTube only + Supported: YouTube only
    - Title: Optional, up to 200 characters
    -
    diff --git a/template/bricks/contrib_2.tpl.php b/template/localized/contrib_2.tpl.php similarity index 87% rename from template/bricks/contrib_2.tpl.php rename to template/localized/contrib_2.tpl.php index 57dae98e..0bb8593a 100644 --- a/template/bricks/contrib_2.tpl.php +++ b/template/localized/contrib_2.tpl.php @@ -16,7 +16,7 @@ if (User::$id > 0):
    - +
    @@ -30,13 +30,14 @@ if (User::$id > 0):
  • Assurez-vous de lire les trucs et astuces si ce n'est pas déjà fait.
  • +ssError ? '
    '.$this->ssError."
    \n
    \n" : ''; +?>
    - File :
    +
    - Caption : Optional, up to 200 characters
    -
    - +
    Note: Votre capture d'écran devra être approuvé avant d'apparaitre sur le site. @@ -51,11 +52,9 @@ if (User::$id > 0):
    - URL : Supporté: Youtube seulement + Supporté: Youtube seulement
    - Title : Optional, up to 200 characters
    -
    - +
    Note: Votre vidéo devra être approuvé avant d'apparaitre sur le site. diff --git a/template/bricks/contrib_3.tpl.php b/template/localized/contrib_3.tpl.php similarity index 89% rename from template/bricks/contrib_3.tpl.php rename to template/localized/contrib_3.tpl.php index 4f6cf8bb..93ac0d93 100644 --- a/template/bricks/contrib_3.tpl.php +++ b/template/localized/contrib_3.tpl.php @@ -20,7 +20,6 @@ if (User::$id > 0):
    - - - - @@ -30,13 +30,14 @@ if (User::$id > 0):
  • Asegurate de leer las sugerencias y trucos si no lo has hecho antes.
  • +ssError ? '
    '.$this->ssError."
    \n
    \n" : ''; +?>
    - File:
    +
    - Caption: Optional, up to 200 characters
    -
    - +
    Nota: Su captura de imagen deberá ser aprobado antes de aparecer en el sitio. @@ -51,11 +52,9 @@ if (User::$id > 0):
    - URL: Soportado: Sólo YouTube + Soportado: Sólo YouTube
    - Title: Optional, up to 200 characters
    -
    - +
    Nota: Tu vídeo deberá ser aprobado antes de aparecer en el sitio. diff --git a/template/bricks/contrib_8.tpl.php b/template/localized/contrib_8.tpl.php similarity index 90% rename from template/bricks/contrib_8.tpl.php rename to template/localized/contrib_8.tpl.php index 2ba5e8ec..ebf79bc7 100644 --- a/template/bricks/contrib_8.tpl.php +++ b/template/localized/contrib_8.tpl.php @@ -16,7 +16,7 @@ if (User::$id > 0):
    - +
    @@ -30,13 +30,14 @@ if (User::$id > 0):
  • Если вы ещё не читали, то настоятельно рекомендуем вам прочесть советы и особенности получения изображений при помощи снимков экрана.
  • +ssError ? '
    '.$this->ssError."
    \n
    \n" : ''; +?>
    - File:
    +
    - Caption: Optional, up to 200 characters
    -
    - +
    Примечание: перед тем как появиться на сайте, ваше Скриншот должны быть утверждены. @@ -51,11 +52,9 @@ if (User::$id > 0):
    - URL: Поддерживается: только YouTube + Поддерживается: только YouTube
    - Title: Optional, up to 200 characters
    -
    - +
    Примечание: перед тем как появиться на сайте, ваше видео должно быть одобрено. diff --git a/template/localized/ssReminder_0.tpl.php b/template/localized/ssReminder_0.tpl.php new file mode 100644 index 00000000..5adbd61b --- /dev/null +++ b/template/localized/ssReminder_0.tpl.php @@ -0,0 +1,10 @@ +

    Reminder

    + Your screenshot will not be approved if it doesn't correspond to the following guidelines. + +
      +
    • Be sure to turn up your graphics settings to make sure the shot looks good!
    • +
    • Model viewer shots are deleted on sight (this also includes character select, typically).
    • +
    • Don't include the onscreen text and the selection circle of a NPC.
    • +
    • Don't include any UI in the shot if you can help it.
    • +
    • Use the screenshot cropping tool 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.
    • +
    diff --git a/template/localized/ssReminder_3.tpl.php b/template/localized/ssReminder_3.tpl.php new file mode 100644 index 00000000..038fd885 --- /dev/null +++ b/template/localized/ssReminder_3.tpl.php @@ -0,0 +1,10 @@ +

    Hinweis

    + Euer Screenshot wird nicht zugelassen werden, wenn er nicht unseren Richtlinien entspricht. + +
      +
    • Achtet darauf die Qualität Eurer Video Einstellungen zu erhöhen, damit Euer Bild gut aussieht!
    • +
    • Bilder des Modelviewers werden sofort gelöscht (das beinhaltet in der Regel auch Bilder der Charakterauswahl).
    • +
    • Vermeidet Bildschirmtext und die Zielmarkierung an NPCs.
    • +
    • Bezieht das Interface nicht ins Bild mit ein, wenn Ihr es vermeiden könnt.
    • +
    • Benutzt das Zuschneidewerkzeug 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.
    • +
    diff --git a/template/pages/screenshot.tpl.php b/template/pages/screenshot.tpl.php index e6d1083f..9cb51ab8 100644 --- a/template/pages/screenshot.tpl.php +++ b/template/pages/screenshot.tpl.php @@ -11,60 +11,46 @@ $this->brick('pageTemplate'); $this->brick('infobox'); -if (isset($this->error)): -?> -
    - -
    -

    -
    error; ?>
    -

    name; ?>

    -mode == 'add'): -?> -
    -
    - + +
    +
    + +
    + +
    + +
    + + +
    -
    - - -
    text counter ph
    -
    - - - -
    + +localizedBrick('ssReminder', User::$localeId); ?> + + + + + - -
    -