diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000000..53f93a1b88 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,74 @@ +name: test suite + +on: [push, pull_request] + +jobs: + tests: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + php-versions: ['7.4', '8.0', '8.1'] + env: + DB_DATABASE: gallery3 + DB_USER: root + DB_PASSWORD: root + DB_PORT: 3306 + DB_HOST: 127.0.0.1 + steps: + - name: Install OS packages + run: sudo apt-get install imagemagick graphicsmagick dcraw ffmpeg git + + - name: Checkout + uses: actions/checkout@v2 + + - name: Set up MySQL + run: | + sudo /etc/init.d/mysql start + mysql -e 'CREATE DATABASE ${{ env.DB_DATABASE }};' -u${{ env.DB_USER }} -p${{ env.DB_PASSWORD }} + mysql -e 'CREATE DATABASE ${{ env.DB_DATABASE }}_test;' -u${{ env.DB_USER }} -p${{ env.DB_PASSWORD }} + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-versions }} + extensions: mbstring, gd, mysql, xml + ini-values: post_max_size=256M, max_execution_time=180 + tools: composer:v2 + + - name: Get composer cache directory + id: composer-cache + run: | + mkdir -p .cache + echo "::set-output name=dir::$(composer config cache-files-dir)" + + - name: Cache dependencies + uses: actions/cache@v2 + with: + path: | + ${{ steps.composer-cache.outputs.dir }} + ~/.cache + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} + restore-keys: ${{ runner.os }}-composer- + + - name: Install dependencies + run: composer install + +# - name: Setup tmate session +# uses: mxschmitt/action-tmate@v3 + + - name: linter + run: bin/linter.sh + + - name: phpcs + run: bin/phpcs.sh + + - name: install db + run: php ./installer/index.php + env: + MYSQL_HOST: ${{ env.DB_HOST }}:${{ env.DB_PORT }} + MYSQL_USER: ${{ env.DB_USER }} + MYSQL_PASSWORD: ${{ env.DB_PASSWORD }} + + - name: tests + run: php index.php test diff --git a/.gitignore b/.gitignore index c3f233da5e..99cb7ecc53 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ # We store Gallery3 data in var var +vendor # local.php is a local customization point that gets loaded at the end of index.php local.php @@ -7,3 +8,5 @@ local.php # http://codex.galleryproject.org/Gallery3:Using_Vagrant Vagrantfile .vagrant + +*.swp diff --git a/.htaccess b/.htaccess index d255efaa1a..d905625125 100644 --- a/.htaccess +++ b/.htaccess @@ -4,7 +4,17 @@ # mirrored in php.ini # - php_flag short_open_tag On + php_flag magic_quotes_gpc Off + php_flag magic_quotes_sybase Off + php_flag magic_quotes_runtime Off + php_flag register_globals Off + php_flag session.auto_start Off + php_flag suhosin.session.encrypt Off + php_value upload_max_filesize 20M + php_value post_max_size 100M + + + php_flag magic_quotes_gpc Off php_flag magic_quotes_sybase Off php_flag magic_quotes_runtime Off diff --git a/.phpcs.xml b/.phpcs.xml new file mode 100644 index 0000000000..b689ca4cae --- /dev/null +++ b/.phpcs.xml @@ -0,0 +1,80 @@ + + + + + + *\.(inc|css|js)$ + + ./application + ./lib + ./system + ./modules + ./themes + ./installer + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 968b8bdd7f..0000000000 --- a/.travis.yml +++ /dev/null @@ -1,25 +0,0 @@ -language: php -php: - - 5.3 - - 5.4 - -branches: - only: - - 3.0.x - - 3.1.x - - master - -services: - - mysql - -before_install: - - sudo apt-get update -qq - - sudo apt-get install -qq graphicsmagick imagemagick php5-gd ffmpeg git-core - -before_script: - - mysql -e 'create database gallery3; create database gallery3_test;' - - cat `php --ini | grep "Loaded Configuration" | sed -e "s|.*:\s*||"` | sed -e "s/short_open_tag = Off/short_open_tag = On/ig" > `php --ini | grep "Loaded Configuration" | sed -e "s|.*:\s*||"` - - php ./installer/index.php - -script: - - 'php index.php test' diff --git a/README.md b/README.md index d84a54536b..ec6effe7ec 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,6 @@ Gallery 3.1+ (development version) ================================== -[![Build Status](https://travis-ci.org/gallery/gallery3.png?branch=master)](https://travis-ci.org/gallery/gallery3) - About ----- @@ -21,24 +19,22 @@ welcome theme and module developers to play with this release and start turning out slick new designs for our happy users. If you have questions or problems, you can get help in the Gallery forums: - http://galleryproject.org/forum/96 + https://groups.google.com/forum/#!forum/gallery-3-users Security -------- -We've contracted a professional security audit, received their results -and resolved all the issues they found. - -Did you find a security flaw? Please email security@galleryproject.org -with the details and we'll fix it ASAP! +Did you find a security flaw? Please submit an issue in github: +https://github.com/bwdutton/gallery3/issues Supported Configuration ----------------------- - Platform: Linux / Unix. - Web server: Apache 2.2 and newer. - - PHP 5.2.3 and newer (PHP's safe_mode must be disabled and simplexml, - filter, and json must be installed). + - PHP 7.4 and newer (PHP's safe_mode must be disabled and simplexml, + filter, and json must be installed). All PHP 7.x versions should work but only 7.4 is tested + - short_open_tag isn't required but additional modules and themes may rely on it. - Database: MySQL 5 and newer. For complete system requirements, please refer to: @@ -47,6 +43,18 @@ For complete system requirements, please refer to: Installing and Upgrading Instructions ------------------------------------- +**NOTE:** When upgrading from PHP 5 to PHP 7 you will need to change the database type from mysql to mysqli in var/database.php: +```php +$config['default'] = array( + 'benchmark' => false, + 'persistent' => false, + 'connection' => array( + 'type' => 'mysqli', +``` + +For docker installations: + + https://hub.docker.com/r/bwdutton/gallery3 For comprehensive instructions, The online User Guide is your best resource: @@ -76,16 +84,22 @@ php installer/index.php [-h host] [-u user] [-p pass] [-d dbname] -x Table prefix (default: ) ``` -Bugs? ------ +### Optional dependencies -Go to http://apps.sourceforge.net/trac/gallery/ click the "login" link -and log in with your SourceForge username and password, then click the -"new ticket" button. +Install composer dependencies to make all of the modules work (currently autorotate, phpmailer). In the top level gallery directory where the composer.json file exists run the following: -Questions, Problems -------------------- +```sh +composer install +``` + +Bugs, Questions, Problems? +-------------------------- - Check out the Gallery 3 FAQ: http://codex.galleryproject.org/Gallery3:FAQ - - Post to the Gallery 3 forums: http://galleryproject.org/forum/96 - - Email gallery-devel@lists.sourceforge.net + - Try the support group: https://groups.google.com/forum/#!forum/gallery-3-users + +### Forgot your password? Use the command line: + +```sh +php index.php passwordreset +``` diff --git a/application/config/config.php b/application/config/config.php index 5adeaa3c3b..8cd04f4955 100644 --- a/application/config/config.php +++ b/application/config/config.php @@ -40,7 +40,7 @@ * * Rawurlencode each of the elements to avoid breaking the page layout. */ -$config["site_domain"] = +$config["site_domain"] = getEnv('SITE_DOMAIN') ? getEnv('SITE_DOMAIN') : implode("/", array_map("rawurlencode", explode("/", substr($_SERVER["SCRIPT_NAME"], 0, strpos($_SERVER["SCRIPT_NAME"], basename($_SERVER["SCRIPT_FILENAME"])))))); @@ -50,7 +50,7 @@ * specified, then the current protocol is used, or when possible, only an * absolute path (with no protocol/domain) is used. */ -$config["site_protocol"] = ""; +$config["site_protocol"] = getEnv('SITE_PROTOCOL') ? getEnv('SITE_PROTOCOL') : ""; /** * Name of the front controller for this application. Default: index.php @@ -64,6 +64,13 @@ */ $config["url_suffix"] = ""; +/** + * For non Apache servers (.e.g nginx), we don't have .htaccess files to block access. + * All requests to the var directory are proxied through the /file_proxy/ for access checks. + * We still create the files in the event you want to change web servers. + */ +$config["no_htaccess"] = isset($_SERVER["SERVER_SOFTWARE"]) && preg_match('/nginx/', $_SERVER["SERVER_SOFTWARE"]) ? "1" : ""; + /** * Length of time of the internal cache in seconds. 0 or FALSE means no caching. * The internal cache stores file paths and config entries across requests and @@ -150,6 +157,10 @@ ); if (TEST_MODE) { + $config["site_domain"] = '.'; + $config["site_protocol"] = 'http'; + $config["index_page"] = 'index.php'; + array_splice($config["modules"], 0, 0, array(MODPATH . "gallery_unit_test", MODPATH . "unit_test")); diff --git a/bin/gallery_movie_maintenance.pl b/bin/gallery_movie_maintenance.pl new file mode 100755 index 0000000000..8b4e2500eb --- /dev/null +++ b/bin/gallery_movie_maintenance.pl @@ -0,0 +1,152 @@ +#!/usr/bin/perl -w + +use strict; +use File::Basename; +use Data::Dumper; + +$| = 1; + +# 0 = no output except for the ffmpeg output +# 1 = in addition to the above, some info about which files are being processd +# 2 = in addition to the above, lots more info about which files are being scanned and processed +my $DEBUG = 2; +my $ALWAYS_CREATE_THUMB = 0; + +# path to your var directory with the photos +# e.g. /home/bdutton/public_html/gallery3/var +my $VAR_DIR = '/var/www/html/var'; + +my $VIDEO_BITRATE = '3000k'; # ffmpeg video bit rate argument +# audio codec to use for ffmpeg, I use libfdk_aac on freebsd. My CentoOS test site +# wants -strict -2 added because aac is apparently experimental +my $ACODEC = 'aac -strict -2'; + +my $CHOWN_USER = ''; # set this if you want chown to change the ownership of the generated files + +my $CLI_SUDO = ''; # set this to the sudo executable if you want to run the conversion as a different user +my $CLI_FIND = 'find'; # path to find, maybe I should use a perl module for this? +my $CLI_CHOWN = 'chown'; # path to chown +my $CLI_FFMPEG = 'ffmpeg'; # path to ffmpeg + +# video extensions you want to process +my @SUFFIXES = ( + 'mp4', + 'm4v', + '3gp', + 'avi', + 'mpg', + 'mpeg', + 'mov', + 'asf', + 'wmv', + 'flv', + 'mts', +); + +# +# need more error checking for above settings +# + +# should be the var folder of the gallery installation +my $dir1 = $ARGV[0] || $VAR_DIR; + +foreach my $dir ($dir1) { + if (!-d $dir) { + print "$dir is not a directory\n"; + exit; + } +} + +my @lower = @SUFFIXES; +foreach (@lower) { + push(@SUFFIXES, uc($_)); +} + +my $results = {}; + +foreach my $dir ($dir1) { + # + # need quoting here + # + chdir($dir); + my @files = `$CLI_FIND . -type f`; + + foreach my $file (@files) { + chomp($file); + + my ($name,$path,$ext) = fileparse($file, @SUFFIXES); + + next unless ($ext); + + $path =~ m#^\./(albums|thumbs|resizes)/(.*)$#; + + $results->{$1}{$2}{$name} = $ext; + } +} + +#print Dumper($results); + +#print "\nDONE\n\n"; + +# create flv files +foreach my $path (keys %{$results->{albums}}) { + #print "check $path\n"; + + my $h = $results->{albums}{$path}; + + foreach my $fname (keys %$h) { + my $ext = $h->{$fname}; + + print "check $path$fname\n" if ($DEBUG); + + #next if (lc($ext) eq 'mp4'); + + my $create_thumb = 0; + if ($results->{resizes}{$path}{$fname.$ext.'.'}) { + my $thumb_ext = $results->{resizes}{$path}{$fname.$ext.'.'}; + + if ($thumb_ext eq 'mp4') { + print "albums/$path$fname has mp4\n" if ($DEBUG >= 2); + } else { + $create_thumb = 1; + } + } else { + $create_thumb = 1; + } + + $create_thumb = 1 if ($ALWAYS_CREATE_THUMB); + + if ($create_thumb) { + my $pixfmt = lc($ext) eq 'avi' ? '-pix_fmt yuv420p' : ''; + + my @cmds = ( + qq{$CLI_SUDO $CLI_FFMPEG -i 'albums/$path$fname$ext' -y -c:v libx264 -profile:v main $pixfmt -level 4.0 -preset slow -b:v $VIDEO_BITRATE -acodec $ACODEC -ac 2 -ar 44100 -b:a 64k 'resizes/$path$fname$ext.mp4'}, + ); + + if ($CHOWN_USER) { + push(@cmds, "$CLI_SUDO $CLI_CHOWN $CHOWN_USER 'resizes/$path$fname$ext.mp4'"); + } + + foreach (@cmds) { + print if ($DEBUG); + `$_`; + } + } + } +} + +foreach my $path (keys %{$results->{resizes}}) { + my $h = $results->{resizes}{$path}; + + foreach my $fname (keys %$h) { + my $ext = $h->{$fname}; + + # chomp off ending . + $fname =~ s/\..+?\.$/./; + if ($results->{albums}{$path}{$fname}) { + print "resizes/$path$fname has counterpart\n" if ($DEBUG >= 2); + } else { + print "resizes/$path$fname is orphaned?\n" if ($DEBUG); + } + } +} diff --git a/bin/linter.sh b/bin/linter.sh new file mode 100755 index 0000000000..8a69d36d1d --- /dev/null +++ b/bin/linter.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +vendor/bin/parallel-lint modules diff --git a/bin/phpcs.sh b/bin/phpcs.sh new file mode 100755 index 0000000000..6b53d16657 --- /dev/null +++ b/bin/phpcs.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +vendor/bin/phpcs -s diff --git a/composer.json b/composer.json new file mode 100644 index 0000000000..3f5b030471 --- /dev/null +++ b/composer.json @@ -0,0 +1,13 @@ +{ + "require": { + "phpmailer/phpmailer": "~6.1", + "lsolesen/pel": "^0.9" + }, + "require-dev": { + "phpstan/phpstan": "^1.0", + "php-parallel-lint/php-parallel-lint": "^1.0", + "php-parallel-lint/php-console-highlighter": "^0.5", + "squizlabs/php_codesniffer": "3.*", + "phpcompatibility/php-compatibility": "^9.0" + } +} diff --git a/composer.lock b/composer.lock new file mode 100644 index 0000000000..324bbfa961 --- /dev/null +++ b/composer.lock @@ -0,0 +1,494 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", + "This file is @generated automatically" + ], + "content-hash": "234386dc58e5012bc4afe06afcfab5a9", + "packages": [ + { + "name": "lsolesen/pel", + "version": "0.9.12", + "source": { + "type": "git", + "url": "https://github.com/pel/pel.git", + "reference": "b95fe29cdacf9d36330da277f10910a13648c84c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/pel/pel/zipball/b95fe29cdacf9d36330da277f10910a13648c84c", + "reference": "b95fe29cdacf9d36330da277f10910a13648c84c", + "shasum": "" + }, + "require": { + "php": ">=7.1.0" + }, + "require-dev": { + "ext-exif": "*", + "ext-gd": "*", + "php-coveralls/php-coveralls": ">2.4", + "squizlabs/php_codesniffer": ">3.5", + "symfony/phpunit-bridge": "^4 || ^5" + }, + "type": "library", + "autoload": { + "psr-4": { + "lsolesen\\pel\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "GPL-2.0" + ], + "authors": [ + { + "name": "Lars Olesen", + "email": "lars@intraface.dk", + "homepage": "http://intraface.dk", + "role": "Developer" + }, + { + "name": "Martin Geisler", + "email": "martin@geisler.net", + "homepage": "http://geisler.net", + "role": "Developer" + } + ], + "description": "PHP Exif Library. A library for reading and writing Exif headers in JPEG and TIFF images using PHP.", + "homepage": "http://pel.github.com/pel/", + "keywords": [ + "exif", + "image" + ], + "support": { + "issues": "https://github.com/pel/pel/issues", + "source": "https://github.com/pel/pel/tree/0.9.12" + }, + "time": "2022-02-18T13:20:54+00:00" + }, + { + "name": "phpmailer/phpmailer", + "version": "v6.6.0", + "source": { + "type": "git", + "url": "https://github.com/PHPMailer/PHPMailer.git", + "reference": "e43bac82edc26ca04b36143a48bde1c051cfd5b1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PHPMailer/PHPMailer/zipball/e43bac82edc26ca04b36143a48bde1c051cfd5b1", + "reference": "e43bac82edc26ca04b36143a48bde1c051cfd5b1", + "shasum": "" + }, + "require": { + "ext-ctype": "*", + "ext-filter": "*", + "ext-hash": "*", + "php": ">=5.5.0" + }, + "require-dev": { + "dealerdirect/phpcodesniffer-composer-installer": "^0.7.0", + "doctrine/annotations": "^1.2", + "php-parallel-lint/php-console-highlighter": "^0.5.0", + "php-parallel-lint/php-parallel-lint": "^1.3.1", + "phpcompatibility/php-compatibility": "^9.3.5", + "roave/security-advisories": "dev-latest", + "squizlabs/php_codesniffer": "^3.6.2", + "yoast/phpunit-polyfills": "^1.0.0" + }, + "suggest": { + "ext-mbstring": "Needed to send email in multibyte encoding charset or decode encoded addresses", + "hayageek/oauth2-yahoo": "Needed for Yahoo XOAUTH2 authentication", + "league/oauth2-google": "Needed for Google XOAUTH2 authentication", + "psr/log": "For optional PSR-3 debug logging", + "stevenmaguire/oauth2-microsoft": "Needed for Microsoft XOAUTH2 authentication", + "symfony/polyfill-mbstring": "To support UTF-8 if the Mbstring PHP extension is not enabled (^1.2)" + }, + "type": "library", + "autoload": { + "psr-4": { + "PHPMailer\\PHPMailer\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "LGPL-2.1-only" + ], + "authors": [ + { + "name": "Marcus Bointon", + "email": "phpmailer@synchromedia.co.uk" + }, + { + "name": "Jim Jagielski", + "email": "jimjag@gmail.com" + }, + { + "name": "Andy Prevost", + "email": "codeworxtech@users.sourceforge.net" + }, + { + "name": "Brent R. Matzelle" + } + ], + "description": "PHPMailer is a full-featured email creation and transfer class for PHP", + "support": { + "issues": "https://github.com/PHPMailer/PHPMailer/issues", + "source": "https://github.com/PHPMailer/PHPMailer/tree/v6.6.0" + }, + "funding": [ + { + "url": "https://github.com/Synchro", + "type": "github" + } + ], + "time": "2022-02-28T15:31:21+00:00" + } + ], + "packages-dev": [ + { + "name": "php-parallel-lint/php-console-color", + "version": "v0.3", + "source": { + "type": "git", + "url": "https://github.com/php-parallel-lint/PHP-Console-Color.git", + "reference": "b6af326b2088f1ad3b264696c9fd590ec395b49e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-parallel-lint/PHP-Console-Color/zipball/b6af326b2088f1ad3b264696c9fd590ec395b49e", + "reference": "b6af326b2088f1ad3b264696c9fd590ec395b49e", + "shasum": "" + }, + "require": { + "php": ">=5.4.0" + }, + "replace": { + "jakub-onderka/php-console-color": "*" + }, + "require-dev": { + "php-parallel-lint/php-code-style": "1.0", + "php-parallel-lint/php-parallel-lint": "1.0", + "php-parallel-lint/php-var-dump-check": "0.*", + "phpunit/phpunit": "~4.3", + "squizlabs/php_codesniffer": "1.*" + }, + "type": "library", + "autoload": { + "psr-4": { + "JakubOnderka\\PhpConsoleColor\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-2-Clause" + ], + "authors": [ + { + "name": "Jakub Onderka", + "email": "jakub.onderka@gmail.com" + } + ], + "support": { + "issues": "https://github.com/php-parallel-lint/PHP-Console-Color/issues", + "source": "https://github.com/php-parallel-lint/PHP-Console-Color/tree/master" + }, + "time": "2020-05-14T05:47:14+00:00" + }, + { + "name": "php-parallel-lint/php-console-highlighter", + "version": "v0.5", + "source": { + "type": "git", + "url": "https://github.com/php-parallel-lint/PHP-Console-Highlighter.git", + "reference": "21bf002f077b177f056d8cb455c5ed573adfdbb8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-parallel-lint/PHP-Console-Highlighter/zipball/21bf002f077b177f056d8cb455c5ed573adfdbb8", + "reference": "21bf002f077b177f056d8cb455c5ed573adfdbb8", + "shasum": "" + }, + "require": { + "ext-tokenizer": "*", + "php": ">=5.4.0", + "php-parallel-lint/php-console-color": "~0.2" + }, + "replace": { + "jakub-onderka/php-console-highlighter": "*" + }, + "require-dev": { + "php-parallel-lint/php-code-style": "~1.0", + "php-parallel-lint/php-parallel-lint": "~1.0", + "php-parallel-lint/php-var-dump-check": "~0.1", + "phpunit/phpunit": "~4.0", + "squizlabs/php_codesniffer": "~1.5" + }, + "type": "library", + "autoload": { + "psr-4": { + "JakubOnderka\\PhpConsoleHighlighter\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jakub Onderka", + "email": "acci@acci.cz", + "homepage": "http://www.acci.cz/" + } + ], + "description": "Highlight PHP code in terminal", + "support": { + "issues": "https://github.com/php-parallel-lint/PHP-Console-Highlighter/issues", + "source": "https://github.com/php-parallel-lint/PHP-Console-Highlighter/tree/master" + }, + "time": "2020-05-13T07:37:49+00:00" + }, + { + "name": "php-parallel-lint/php-parallel-lint", + "version": "v1.3.2", + "source": { + "type": "git", + "url": "https://github.com/php-parallel-lint/PHP-Parallel-Lint.git", + "reference": "6483c9832e71973ed29cf71bd6b3f4fde438a9de" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-parallel-lint/PHP-Parallel-Lint/zipball/6483c9832e71973ed29cf71bd6b3f4fde438a9de", + "reference": "6483c9832e71973ed29cf71bd6b3f4fde438a9de", + "shasum": "" + }, + "require": { + "ext-json": "*", + "php": ">=5.3.0" + }, + "replace": { + "grogy/php-parallel-lint": "*", + "jakub-onderka/php-parallel-lint": "*" + }, + "require-dev": { + "nette/tester": "^1.3 || ^2.0", + "php-parallel-lint/php-console-highlighter": "0.* || ^1.0", + "squizlabs/php_codesniffer": "^3.6" + }, + "suggest": { + "php-parallel-lint/php-console-highlighter": "Highlight syntax in code snippet" + }, + "bin": [ + "parallel-lint" + ], + "type": "library", + "autoload": { + "classmap": [ + "./src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-2-Clause" + ], + "authors": [ + { + "name": "Jakub Onderka", + "email": "ahoj@jakubonderka.cz" + } + ], + "description": "This tool check syntax of PHP files about 20x faster than serial check.", + "homepage": "https://github.com/php-parallel-lint/PHP-Parallel-Lint", + "support": { + "issues": "https://github.com/php-parallel-lint/PHP-Parallel-Lint/issues", + "source": "https://github.com/php-parallel-lint/PHP-Parallel-Lint/tree/v1.3.2" + }, + "time": "2022-02-21T12:50:22+00:00" + }, + { + "name": "phpcompatibility/php-compatibility", + "version": "9.3.5", + "source": { + "type": "git", + "url": "https://github.com/PHPCompatibility/PHPCompatibility.git", + "reference": "9fb324479acf6f39452e0655d2429cc0d3914243" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibility/zipball/9fb324479acf6f39452e0655d2429cc0d3914243", + "reference": "9fb324479acf6f39452e0655d2429cc0d3914243", + "shasum": "" + }, + "require": { + "php": ">=5.3", + "squizlabs/php_codesniffer": "^2.3 || ^3.0.2" + }, + "conflict": { + "squizlabs/php_codesniffer": "2.6.2" + }, + "require-dev": { + "phpunit/phpunit": "~4.5 || ^5.0 || ^6.0 || ^7.0" + }, + "suggest": { + "dealerdirect/phpcodesniffer-composer-installer": "^0.5 || This Composer plugin will sort out the PHPCS 'installed_paths' automatically.", + "roave/security-advisories": "dev-master || Helps prevent installing dependencies with known security issues." + }, + "type": "phpcodesniffer-standard", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "LGPL-3.0-or-later" + ], + "authors": [ + { + "name": "Wim Godden", + "homepage": "https://github.com/wimg", + "role": "lead" + }, + { + "name": "Juliette Reinders Folmer", + "homepage": "https://github.com/jrfnl", + "role": "lead" + }, + { + "name": "Contributors", + "homepage": "https://github.com/PHPCompatibility/PHPCompatibility/graphs/contributors" + } + ], + "description": "A set of sniffs for PHP_CodeSniffer that checks for PHP cross-version compatibility.", + "homepage": "http://techblog.wimgodden.be/tag/codesniffer/", + "keywords": [ + "compatibility", + "phpcs", + "standards" + ], + "support": { + "issues": "https://github.com/PHPCompatibility/PHPCompatibility/issues", + "source": "https://github.com/PHPCompatibility/PHPCompatibility" + }, + "time": "2019-12-27T09:44:58+00:00" + }, + { + "name": "phpstan/phpstan", + "version": "1.6.8", + "source": { + "type": "git", + "url": "https://github.com/phpstan/phpstan.git", + "reference": "d76498c5531232cb8386ceb6004f7e013138d3ba" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/d76498c5531232cb8386ceb6004f7e013138d3ba", + "reference": "d76498c5531232cb8386ceb6004f7e013138d3ba", + "shasum": "" + }, + "require": { + "php": "^7.2|^8.0" + }, + "conflict": { + "phpstan/phpstan-shim": "*" + }, + "bin": [ + "phpstan", + "phpstan.phar" + ], + "type": "library", + "autoload": { + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "PHPStan - PHP Static Analysis Tool", + "support": { + "issues": "https://github.com/phpstan/phpstan/issues", + "source": "https://github.com/phpstan/phpstan/tree/1.6.8" + }, + "funding": [ + { + "url": "https://github.com/ondrejmirtes", + "type": "github" + }, + { + "url": "https://github.com/phpstan", + "type": "github" + }, + { + "url": "https://www.patreon.com/phpstan", + "type": "patreon" + }, + { + "url": "https://tidelift.com/funding/github/packagist/phpstan/phpstan", + "type": "tidelift" + } + ], + "time": "2022-05-10T06:54:21+00:00" + }, + { + "name": "squizlabs/php_codesniffer", + "version": "3.6.2", + "source": { + "type": "git", + "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", + "reference": "5e4e71592f69da17871dba6e80dd51bce74a351a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/5e4e71592f69da17871dba6e80dd51bce74a351a", + "reference": "5e4e71592f69da17871dba6e80dd51bce74a351a", + "shasum": "" + }, + "require": { + "ext-simplexml": "*", + "ext-tokenizer": "*", + "ext-xmlwriter": "*", + "php": ">=5.4.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0" + }, + "bin": [ + "bin/phpcs", + "bin/phpcbf" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.x-dev" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Greg Sherwood", + "role": "lead" + } + ], + "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.", + "homepage": "https://github.com/squizlabs/PHP_CodeSniffer", + "keywords": [ + "phpcs", + "standards" + ], + "support": { + "issues": "https://github.com/squizlabs/PHP_CodeSniffer/issues", + "source": "https://github.com/squizlabs/PHP_CodeSniffer", + "wiki": "https://github.com/squizlabs/PHP_CodeSniffer/wiki" + }, + "time": "2021-12-12T21:44:58+00:00" + } + ], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": [], + "prefer-stable": false, + "prefer-lowest": false, + "platform": [], + "platform-dev": [], + "plugin-api-version": "2.1.0" +} diff --git a/index.php b/index.php index e6636cf18a..99f0fd073a 100644 --- a/index.php +++ b/index.php @@ -20,9 +20,9 @@ // Set this to true to disable demo/debugging controllers define("IN_PRODUCTION", true); -// Gallery requires PHP 5.2+ -version_compare(PHP_VERSION, "5.2.3", "<") and - exit("Gallery requires PHP 5.2.3 or newer (you're using " . PHP_VERSION . ")"); +// Remove this if you want, things should probably work, but you've been warned. +version_compare(PHP_VERSION, "7.0.0", "<") and + exit("Gallery requires PHP 7.0.0 or newer (you're using " . PHP_VERSION . ")"); // Gallery is not supported on Windows. if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { @@ -35,9 +35,6 @@ ini_set("date.timezone", "UTC"); } -// Gallery requires short_tags to be on -!ini_get("short_open_tag") and exit("Gallery requires short_open_tag to be on."); - // Suppress errors. For information on how to debug Gallery 3, see: // http://codex.galleryproject.org/Gallery3:FAQ#How_do_I_see_debug_information.3F error_reporting(0); @@ -73,6 +70,13 @@ case "install": include("installer/index.php"); exit(0); + case "passwordreset": + $username = empty($_SERVER['argv'][2]) ? 'admin' : $_SERVER['argv'][2]; + # need to quote/escape this? + $_SERVER["argv"] = array("index.php", "{$arg_1}/index/$username"); + define("TEST_MODE", 0); + define("VARPATH", realpath("var") . "/"); + break; case "upgrade": case "package": $_SERVER["argv"] = array("index.php", "{$arg_1}r/$arg_1"); @@ -87,7 +91,9 @@ @mkdir("test/var", 0777, true); @mkdir("test/var/logs", 0777, true); } - @copy("var/database.php", "test/var/database.php"); + if (!file_exists("test/var/database.php")) { + @copy("var/database.php", "test/var/database.php"); + } define("VARPATH", realpath("test/var") . "/"); break; @@ -96,6 +102,8 @@ print " php index.php install -d database -h host -u user -p password -x table_prefix -g3p gallery3_admin_password \n\n"; print "To upgrade:\n"; print " php index.php upgrade\n\n"; + print "To reset a password\n"; + print " php index.php passwordreset \n\n"; print "Developer-only features:\n"; print " ** CAUTION! THESE FEATURES -WILL- DAMAGE YOUR INSTALL **\n"; print " php index.php package # create new installer files\n"; diff --git a/installer/cli.php b/installer/cli.php index b31405f161..456d2b9244 100644 --- a/installer/cli.php +++ b/installer/cli.php @@ -32,7 +32,7 @@ $errors = installer::check_environment(); if ($errors) { - oops(implode($errors, "\n")); + oops(implode("\n", $errors)); } $config = parse_cli_params(); @@ -78,20 +78,21 @@ function oops($message) { print "==> " . $message; print "\n"; print "For help you can try:\n"; - print " * The Gallery 3 FAQ - http://codex.galleryproject.org/Gallery3:FAQ\n"; - print " * The Gallery Forums - http://galleryproject.org/forum\n"; + print " * The Gallery Group - https://groups.google.com/forum/#!forum/gallery-3-users\n"; print "\n\n** INSTALLATION FAILED **\n"; exit(1); } function parse_cli_params() { - $config = array("host" => "localhost", - "user" => "root", - "password" => "", - "dbname" => "gallery3", - "prefix" => "", - "g3_password" => "", - "type" => function_exists("mysqli_set_charset") ? "mysqli" : "mysql"); + $config = array( + "host" => getenv('MYSQL_HOST') ? getenv('MYSQL_HOST') : "localhost", + "user" => getenv('MYSQL_USER') ? getenv('MYSQL_USER') : "root", + "password" => getenv('MYSQL_PASSWORD') ? getenv('MYSQL_PASSWORD') : "", + "dbname" => getenv('MYSQL_DATABASE') ? getenv('MYSQL_DATABASE') : "gallery3", + "prefix" => getenv('DB_PREFIX') ? getenv('DB_PREFIX') : "", + "g3_password" => getenv('G3_PASSWORD') ? getenv('G3_PASSWORD') : "", + "type" => function_exists("mysqli_set_charset") ? "mysqli" : "mysql", + ); $argv = $_SERVER["argv"]; for ($i = 1; $i < count($argv); $i++) { diff --git a/installer/database_config.php b/installer/database_config.php index fb7dd1128a..b29363d3dd 100644 --- a/installer/database_config.php +++ b/installer/database_config.php @@ -43,4 +43,4 @@ 'object' => true, 'cache' => false, 'escape' => true -); \ No newline at end of file +); diff --git a/installer/install.sql b/installer/install.sql index 3f63cf7c8f..febab80f19 100644 --- a/installer/install.sql +++ b/installer/install.sql @@ -252,8 +252,7 @@ INSERT INTO {modules} VALUES (4,1,'organize',4,4); INSERT INTO {modules} VALUES (5,1,'info',2,5); INSERT INTO {modules} VALUES (6,1,'rss',1,6); INSERT INTO {modules} VALUES (7,1,'search',1,7); -INSERT INTO {modules} VALUES (8,1,'slideshow',2,8); -INSERT INTO {modules} VALUES (9,1,'tag',3,9); +INSERT INTO {modules} VALUES (8,1,'tag',3,9); DROP TABLE IF EXISTS {outgoing_translations}; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; @@ -429,5 +428,4 @@ INSERT INTO {vars} VALUES (NULL,'info','show_description','1'); INSERT INTO {vars} VALUES (NULL,'info','show_owner','1'); INSERT INTO {vars} VALUES (NULL,'info','show_name','1'); INSERT INTO {vars} VALUES (NULL,'info','show_captured','1'); -INSERT INTO {vars} VALUES (NULL,'slideshow','max_scale','0'); INSERT INTO {vars} VALUES (NULL,'tag','tag_cloud_size','30'); diff --git a/installer/installer.php b/installer/installer.php index 434d8e53f1..f2e513e0fb 100644 --- a/installer/installer.php +++ b/installer/installer.php @@ -77,7 +77,6 @@ static function connect($config) { // counterparts. if (!function_exists("mysql_query")) { function mysql_connect($host, $user, $pass) { - list ($host, $port) = explode(":", $host . ":"); installer::$mysqli = new mysqli($host, $user, $pass, $port); // http://php.net/manual/en/mysqli.connect.php says to use mysqli_connect_error() instead of // $mysqli->connect_error because of bugs before PHP 5.2.9 @@ -96,6 +95,9 @@ function mysql_error() { function mysql_select_db($db) { return installer::$mysqli->select_db($db); } + function mysql_fetch_object($result) { + return $result->fetch_object(); + } } $host = empty($config["port"]) ? $config['host'] : "{$config['host']}:{$config['port']}"; @@ -135,10 +137,11 @@ static function create_admin($config) { $salt = ""; for ($i = 0; $i < 4; $i++) { $char = mt_rand(48, 109); - $char += ($char > 90) ? 13 : ($char > 57) ? 7 : 0; + $char += ($char > 90) ? 13 : (($char > 57) ? 7 : 0); $salt .= chr($char); } - if (!$password = $config["g3_password"]) { + $password = isset($config["g3_password"]) && strlen($config["g3_password"]) ? $config["g3_password"] : ''; + if (!$password) { $password = substr(md5(time() . mt_rand()), 0, 6); } // Escape backslash in preparation for our UPDATE statement. @@ -225,18 +228,12 @@ static function check_environment() { if (!extension_loaded("mbstring")) { $errors[] = "PHP is missing the mbstring extension"; - } else if (ini_get("mbstring.func_overload") & MB_OVERLOAD_STRING) { - $errors[] = "The mbstring extension is overloading PHP's native string functions. Please disable it."; } if (!function_exists("json_encode")) { $errors[] = "PHP is missing the JavaScript Object Notation (JSON) extension. Please install it."; } - if (!ini_get("short_open_tag")) { - $errors[] = "Gallery requires short_open_tag to be on. Please enable it in your php.ini."; - } - if (!function_exists("ctype_alpha")) { $errors[] = "Gallery requires the PHP Ctype extension. Please install it."; } diff --git a/installer/views/install.html.php b/installer/views/install.html.php index 7a30561add..0b49d261bd 100644 --- a/installer/views/install.html.php +++ b/installer/views/install.html.php @@ -15,7 +15,7 @@ Did something go wrong? Try the FAQ or ask in - the Gallery + the Gallery forums.

diff --git a/installer/web.php b/installer/web.php index 5fa8541eb4..5de68d7507 100644 --- a/installer/web.php +++ b/installer/web.php @@ -37,7 +37,8 @@ "password" => $_POST["dbpass"], "dbname" => $_POST["dbname"], "prefix" => $_POST["prefix"], - "type" => function_exists("mysqli_set_charset") ? "mysqli" : "mysql"); + "type" => function_exists("mysqli_set_charset") ? "mysqli" : "mysql", + ); list ($config["host"], $config["port"]) = explode(":", $config["host"] . ":"); foreach ($config as $k => $v) { if ($k == "password") { diff --git a/lib/dropzone.css b/lib/dropzone.css new file mode 100644 index 0000000000..59efc492a0 --- /dev/null +++ b/lib/dropzone.css @@ -0,0 +1,416 @@ +/* + * The MIT License + * Copyright (c) 2012 Matias Meno + */ +@-webkit-keyframes passing-through { + 0% { + opacity: 0; + -webkit-transform: translateY(40px); + -moz-transform: translateY(40px); + -ms-transform: translateY(40px); + -o-transform: translateY(40px); + transform: translateY(40px); } + 30%, 70% { + opacity: 1; + -webkit-transform: translateY(0px); + -moz-transform: translateY(0px); + -ms-transform: translateY(0px); + -o-transform: translateY(0px); + transform: translateY(0px); } + 100% { + opacity: 0; + -webkit-transform: translateY(-40px); + -moz-transform: translateY(-40px); + -ms-transform: translateY(-40px); + -o-transform: translateY(-40px); + transform: translateY(-40px); } } +@-moz-keyframes passing-through { + 0% { + opacity: 0; + -webkit-transform: translateY(40px); + -moz-transform: translateY(40px); + -ms-transform: translateY(40px); + -o-transform: translateY(40px); + transform: translateY(40px); } + 30%, 70% { + opacity: 1; + -webkit-transform: translateY(0px); + -moz-transform: translateY(0px); + -ms-transform: translateY(0px); + -o-transform: translateY(0px); + transform: translateY(0px); } + 100% { + opacity: 0; + -webkit-transform: translateY(-40px); + -moz-transform: translateY(-40px); + -ms-transform: translateY(-40px); + -o-transform: translateY(-40px); + transform: translateY(-40px); } } +@keyframes passing-through { + 0% { + opacity: 0; + -webkit-transform: translateY(40px); + -moz-transform: translateY(40px); + -ms-transform: translateY(40px); + -o-transform: translateY(40px); + transform: translateY(40px); } + 30%, 70% { + opacity: 1; + -webkit-transform: translateY(0px); + -moz-transform: translateY(0px); + -ms-transform: translateY(0px); + -o-transform: translateY(0px); + transform: translateY(0px); } + 100% { + opacity: 0; + -webkit-transform: translateY(-40px); + -moz-transform: translateY(-40px); + -ms-transform: translateY(-40px); + -o-transform: translateY(-40px); + transform: translateY(-40px); } } +@-webkit-keyframes slide-in { + 0% { + opacity: 0; + -webkit-transform: translateY(40px); + -moz-transform: translateY(40px); + -ms-transform: translateY(40px); + -o-transform: translateY(40px); + transform: translateY(40px); } + 30% { + opacity: 1; + -webkit-transform: translateY(0px); + -moz-transform: translateY(0px); + -ms-transform: translateY(0px); + -o-transform: translateY(0px); + transform: translateY(0px); } } +@-moz-keyframes slide-in { + 0% { + opacity: 0; + -webkit-transform: translateY(40px); + -moz-transform: translateY(40px); + -ms-transform: translateY(40px); + -o-transform: translateY(40px); + transform: translateY(40px); } + 30% { + opacity: 1; + -webkit-transform: translateY(0px); + -moz-transform: translateY(0px); + -ms-transform: translateY(0px); + -o-transform: translateY(0px); + transform: translateY(0px); } } +@keyframes slide-in { + 0% { + opacity: 0; + -webkit-transform: translateY(40px); + -moz-transform: translateY(40px); + -ms-transform: translateY(40px); + -o-transform: translateY(40px); + transform: translateY(40px); } + 30% { + opacity: 1; + -webkit-transform: translateY(0px); + -moz-transform: translateY(0px); + -ms-transform: translateY(0px); + -o-transform: translateY(0px); + transform: translateY(0px); } } +@-webkit-keyframes pulse { + 0% { + -webkit-transform: scale(1); + -moz-transform: scale(1); + -ms-transform: scale(1); + -o-transform: scale(1); + transform: scale(1); } + 10% { + -webkit-transform: scale(1.1); + -moz-transform: scale(1.1); + -ms-transform: scale(1.1); + -o-transform: scale(1.1); + transform: scale(1.1); } + 20% { + -webkit-transform: scale(1); + -moz-transform: scale(1); + -ms-transform: scale(1); + -o-transform: scale(1); + transform: scale(1); } } +@-moz-keyframes pulse { + 0% { + -webkit-transform: scale(1); + -moz-transform: scale(1); + -ms-transform: scale(1); + -o-transform: scale(1); + transform: scale(1); } + 10% { + -webkit-transform: scale(1.1); + -moz-transform: scale(1.1); + -ms-transform: scale(1.1); + -o-transform: scale(1.1); + transform: scale(1.1); } + 20% { + -webkit-transform: scale(1); + -moz-transform: scale(1); + -ms-transform: scale(1); + -o-transform: scale(1); + transform: scale(1); } } +@keyframes pulse { + 0% { + -webkit-transform: scale(1); + -moz-transform: scale(1); + -ms-transform: scale(1); + -o-transform: scale(1); + transform: scale(1); } + 10% { + -webkit-transform: scale(1.1); + -moz-transform: scale(1.1); + -ms-transform: scale(1.1); + -o-transform: scale(1.1); + transform: scale(1.1); } + 20% { + -webkit-transform: scale(1); + -moz-transform: scale(1); + -ms-transform: scale(1); + -o-transform: scale(1); + transform: scale(1); } } +.dropzone, .dropzone * { + box-sizing: border-box; +} + +.dropzone { + min-height: 150px; + border: 2px solid rgba(0, 0, 0, 0.3); + padding: 20px 20px; + /* + */ + background: white; +} + .dropzone.dz-clickable { + cursor: pointer; } + .dropzone.dz-clickable * { + cursor: default; } + .dropzone.dz-clickable .dz-message, .dropzone.dz-clickable .dz-message * { + cursor: pointer; } + .dropzone.dz-started .dz-message { + display: none; } + .dropzone.dz-drag-hover { + border-style: solid; } + .dropzone.dz-drag-hover .dz-message { + opacity: 0.5; } + .dropzone .dz-message { + text-align: center; + margin: 2em 0; } + .dropzone .dz-preview { + position: relative; + display: inline-block; + vertical-align: top; + margin: 16px; + min-height: 100px; } + .dropzone .dz-preview:hover { + z-index: 1000; } + .dropzone .dz-preview:hover .dz-details { + opacity: 1; } + .dropzone .dz-preview.dz-file-preview .dz-image { + border-radius: 20px; + background: #999; + background: linear-gradient(to bottom, #eee, #ddd); } + .dropzone .dz-preview.dz-file-preview .dz-details { + opacity: 1; } + .dropzone .dz-preview.dz-image-preview { + background: white; } + .dropzone .dz-preview.dz-image-preview .dz-details { + -webkit-transition: opacity 0.2s linear; + -moz-transition: opacity 0.2s linear; + -ms-transition: opacity 0.2s linear; + -o-transition: opacity 0.2s linear; + transition: opacity 0.2s linear; } + .dropzone .dz-preview .dz-remove { + font-size: 14px; + text-align: center; + display: block; + cursor: pointer; + border: none; } + .dropzone .dz-preview .dz-remove:hover { + text-decoration: underline; } + .dropzone .dz-preview:hover .dz-details { + opacity: 1; } + .dropzone .dz-preview .dz-details { + z-index: 20; + position: absolute; + top: 0; + left: 0; + opacity: 0; + font-size: 13px; + min-width: 100%; + max-width: 100%; + padding: 2em 1em; + text-align: center; + color: rgba(0, 0, 0, 0.9); + line-height: 150%; } + .dropzone .dz-preview .dz-details .dz-size { + margin-bottom: 1em; + font-size: 16px; } + .dropzone .dz-preview .dz-details .dz-filename { + white-space: nowrap; } + .dropzone .dz-preview .dz-details .dz-filename:hover span { + border: 1px solid rgba(200, 200, 200, 0.8); + background-color: rgba(255, 255, 255, 0.8); } + .dropzone .dz-preview .dz-details .dz-filename:not(:hover) { + overflow: hidden; + text-overflow: ellipsis; } + .dropzone .dz-preview .dz-details .dz-filename:not(:hover) span { + border: 1px solid transparent; } + .dropzone .dz-preview .dz-details .dz-filename span, .dropzone .dz-preview .dz-details .dz-size span { + background-color: rgba(255, 255, 255, 0.4); + padding: 0 0.4em; + border-radius: 3px; } + .dropzone .dz-preview:hover .dz-image img { + -webkit-transform: scale(1.05, 1.05); + -moz-transform: scale(1.05, 1.05); + -ms-transform: scale(1.05, 1.05); + -o-transform: scale(1.05, 1.05); + transform: scale(1.05, 1.05); + -webkit-filter: blur(8px); + filter: blur(8px); } + .dropzone .dz-preview .dz-image { + border-radius: 20px; + overflow: hidden; + width: 120px; + height: 120px; + position: relative; + display: block; + z-index: 10; } + .dropzone .dz-preview .dz-image img { + display: block; } + .dropzone .dz-preview.dz-success .dz-success-mark { + -webkit-animation: passing-through 3s cubic-bezier(0.77, 0, 0.175, 1); + -moz-animation: passing-through 3s cubic-bezier(0.77, 0, 0.175, 1); + -ms-animation: passing-through 3s cubic-bezier(0.77, 0, 0.175, 1); + -o-animation: passing-through 3s cubic-bezier(0.77, 0, 0.175, 1); + animation: passing-through 3s cubic-bezier(0.77, 0, 0.175, 1); } + .dropzone .dz-preview.dz-error .dz-error-mark { + opacity: 1; + -webkit-animation: slide-in 3s cubic-bezier(0.77, 0, 0.175, 1); + -moz-animation: slide-in 3s cubic-bezier(0.77, 0, 0.175, 1); + -ms-animation: slide-in 3s cubic-bezier(0.77, 0, 0.175, 1); + -o-animation: slide-in 3s cubic-bezier(0.77, 0, 0.175, 1); + animation: slide-in 3s cubic-bezier(0.77, 0, 0.175, 1); } + .dropzone .dz-preview .dz-success-mark, .dropzone .dz-preview .dz-error-mark { + pointer-events: none; + opacity: 0; + z-index: 500; + position: absolute; + display: block; + top: 50%; + left: 50%; + margin-left: -27px; + margin-top: -27px; } + .dropzone .dz-preview .dz-success-mark svg, .dropzone .dz-preview .dz-error-mark svg { + display: block; + width: 54px; + height: 54px; } + .dropzone .dz-preview.dz-processing .dz-progress { + opacity: 1; + -webkit-transition: all 0.2s linear; + -moz-transition: all 0.2s linear; + -ms-transition: all 0.2s linear; + -o-transition: all 0.2s linear; + transition: all 0.2s linear; } + .dropzone .dz-preview.dz-complete .dz-progress { + opacity: 0; + -webkit-transition: opacity 0.4s ease-in; + -moz-transition: opacity 0.4s ease-in; + -ms-transition: opacity 0.4s ease-in; + -o-transition: opacity 0.4s ease-in; + transition: opacity 0.4s ease-in; } + .dropzone .dz-preview:not(.dz-processing) .dz-progress { + -webkit-animation: pulse 6s ease infinite; + -moz-animation: pulse 6s ease infinite; + -ms-animation: pulse 6s ease infinite; + -o-animation: pulse 6s ease infinite; + animation: pulse 6s ease infinite; } + .dropzone .dz-preview .dz-progress { + opacity: 1; + z-index: 1000; + pointer-events: none; + position: absolute; + height: 16px; + left: 50%; + top: 50%; + margin-top: -8px; + width: 80px; + margin-left: -40px; + background: rgba(255, 255, 255, 0.9); + -webkit-transform: scale(1); + border-radius: 8px; + overflow: hidden; } + .dropzone .dz-preview .dz-progress .dz-upload { + background: #333; + background: linear-gradient(to bottom, #666, #444); + position: absolute; + top: 0; + left: 0; + bottom: 0; + width: 0; + -webkit-transition: width 300ms ease-in-out; + -moz-transition: width 300ms ease-in-out; + -ms-transition: width 300ms ease-in-out; + -o-transition: width 300ms ease-in-out; + transition: width 300ms ease-in-out; } + .dropzone .dz-preview.dz-error .dz-error-message { + display: block; } + .dropzone .dz-preview.dz-error:hover .dz-error-message { + opacity: 1; + pointer-events: auto; } + .dropzone .dz-preview .dz-error-message { + pointer-events: none; + z-index: 1000; + position: absolute; + display: block; + display: none; + opacity: 0; + -webkit-transition: opacity 0.3s ease; + -moz-transition: opacity 0.3s ease; + -ms-transition: opacity 0.3s ease; + -o-transition: opacity 0.3s ease; + transition: opacity 0.3s ease; + border-radius: 8px; + font-size: 13px; + top: 130px; + left: -10px; + width: 140px; + background: #be2626; + background: linear-gradient(to bottom, #be2626, #a92222); + padding: 0.5em 1.2em; + color: white; } + .dropzone .dz-preview .dz-error-message:after { + content: ''; + position: absolute; + top: -6px; + left: 64px; + width: 0; + height: 0; + border-left: 6px solid transparent; + border-right: 6px solid transparent; + border-bottom: 6px solid #be2626; } + +.dropzone { + min-height: 300px; + border: 0; + padding: 0; +} +/* + * these are not matching/working for some reason +.dz-preview .dz-success-mark svg g path { + fill: #bbbbbb; +} +.dz-preview > .dz-error-mark > svg > g > g { + fill: #eeeeee; +} +*/ +.dropzone .dz-default { + border: 2px dashed #5c9ccc; + min-height: 150px; + margin: 0; +} +.dropzone .dz-default > span { + display: block; + padding-top: 2em; +} diff --git a/lib/dropzone.js b/lib/dropzone.js new file mode 100644 index 0000000000..3809d2d9c5 --- /dev/null +++ b/lib/dropzone.js @@ -0,0 +1,3504 @@ +"use strict"; + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +/* + * + * More info at [www.dropzonejs.com](http://www.dropzonejs.com) + * + * Copyright (c) 2012, Matias Meno + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + */ + +// The Emitter class provides the ability to call `.on()` on Dropzone to listen +// to events. +// It is strongly based on component's emitter class, and I removed the +// functionality because of the dependency hell with different frameworks. +var Emitter = function () { + function Emitter() { + _classCallCheck(this, Emitter); + } + + _createClass(Emitter, [{ + key: "on", + + // Add an event listener for given event + value: function on(event, fn) { + this._callbacks = this._callbacks || {}; + // Create namespace for this event + if (!this._callbacks[event]) { + this._callbacks[event] = []; + } + this._callbacks[event].push(fn); + return this; + } + }, { + key: "emit", + value: function emit(event) { + this._callbacks = this._callbacks || {}; + var callbacks = this._callbacks[event]; + + if (callbacks) { + for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { + args[_key - 1] = arguments[_key]; + } + + for (var _iterator = callbacks, _isArray = true, _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) { + var _ref; + + if (_isArray) { + if (_i >= _iterator.length) break; + _ref = _iterator[_i++]; + } else { + _i = _iterator.next(); + if (_i.done) break; + _ref = _i.value; + } + + var callback = _ref; + + callback.apply(this, args); + } + } + + return this; + } + + // Remove event listener for given event. If fn is not provided, all event + // listeners for that event will be removed. If neither is provided, all + // event listeners will be removed. + + }, { + key: "off", + value: function off(event, fn) { + if (!this._callbacks || arguments.length === 0) { + this._callbacks = {}; + return this; + } + + // specific event + var callbacks = this._callbacks[event]; + if (!callbacks) { + return this; + } + + // remove all handlers + if (arguments.length === 1) { + delete this._callbacks[event]; + return this; + } + + // remove specific handler + for (var i = 0; i < callbacks.length; i++) { + var callback = callbacks[i]; + if (callback === fn) { + callbacks.splice(i, 1); + break; + } + } + + return this; + } + }]); + + return Emitter; +}(); + +var Dropzone = function (_Emitter) { + _inherits(Dropzone, _Emitter); + + _createClass(Dropzone, null, [{ + key: "initClass", + value: function initClass() { + + // Exposing the emitter class, mainly for tests + this.prototype.Emitter = Emitter; + + /* + This is a list of all available events you can register on a dropzone object. + You can register an event handler like this: + dropzone.on("dragEnter", function() { }); + */ + this.prototype.events = ["drop", "dragstart", "dragend", "dragenter", "dragover", "dragleave", "addedfile", "addedfiles", "removedfile", "thumbnail", "error", "errormultiple", "processing", "processingmultiple", "uploadprogress", "totaluploadprogress", "sending", "sendingmultiple", "success", "successmultiple", "canceled", "canceledmultiple", "complete", "completemultiple", "reset", "maxfilesexceeded", "maxfilesreached", "queuecomplete"]; + + this.prototype.defaultOptions = { + /** + * Has to be specified on elements other than form (or when the form + * doesn't have an `action` attribute). You can also + * provide a function that will be called with `files` and + * must return the url (since `v3.12.0`) + */ + url: null, + + /** + * Can be changed to `"put"` if necessary. You can also provide a function + * that will be called with `files` and must return the method (since `v3.12.0`). + */ + method: "post", + + /** + * Will be set on the XHRequest. + */ + withCredentials: false, + + /** + * The timeout for the XHR requests in milliseconds (since `v4.4.0`). + */ + timeout: 30000, + + /** + * How many file uploads to process in parallel (See the + * Enqueuing file uploads* documentation section for more info) + */ + parallelUploads: 2, + + /** + * Whether to send multiple files in one request. If + * this it set to true, then the fallback file input element will + * have the `multiple` attribute as well. This option will + * also trigger additional events (like `processingmultiple`). See the events + * documentation section for more information. + */ + uploadMultiple: false, + + /** + * Whether you want files to be uploaded in chunks to your server. This can't be + * used in combination with `uploadMultiple`. + * + * See [chunksUploaded](#config-chunksUploaded) for the callback to finalise an upload. + */ + chunking: false, + + /** + * If `chunking` is enabled, this defines whether **every** file should be chunked, + * even if the file size is below chunkSize. This means, that the additional chunk + * form data will be submitted and the `chunksUploaded` callback will be invoked. + */ + forceChunking: false, + + /** + * If `chunking` is `true`, then this defines the chunk size in bytes. + */ + chunkSize: 2000000, + + /** + * If `true`, the individual chunks of a file are being uploaded simultaneously. + */ + parallelChunkUploads: false, + + /** + * Whether a chunk should be retried if it fails. + */ + retryChunks: false, + + /** + * If `retryChunks` is true, how many times should it be retried. + */ + retryChunksLimit: 3, + + /** + * If not `null` defines how many files this Dropzone handles. If it exceeds, + * the event `maxfilesexceeded` will be called. The dropzone element gets the + * class `dz-max-files-reached` accordingly so you can provide visual feedback. + */ + maxFilesize: 256, + + /** + * The name of the file param that gets transferred. + * **NOTE**: If you have the option `uploadMultiple` set to `true`, then + * Dropzone will append `[]` to the name. + */ + paramName: "file", + + /** + * Whether thumbnails for images should be generated + */ + createImageThumbnails: true, + + /** + * In MB. When the filename exceeds this limit, the thumbnail will not be generated. + */ + maxThumbnailFilesize: 10, + + /** + * If `null`, the ratio of the image will be used to calculate it. + */ + thumbnailWidth: 120, + + /** + * The same as `thumbnailWidth`. If both are null, images will not be resized. + */ + thumbnailHeight: 120, + + /** + * How the images should be scaled down in case both, `thumbnailWidth` and `thumbnailHeight` are provided. + * Can be either `contain` or `crop`. + */ + thumbnailMethod: 'crop', + + /** + * If set, images will be resized to these dimensions before being **uploaded**. + * If only one, `resizeWidth` **or** `resizeHeight` is provided, the original aspect + * ratio of the file will be preserved. + * + * The `options.transformFile` function uses these options, so if the `transformFile` function + * is overridden, these options don't do anything. + */ + resizeWidth: null, + + /** + * See `resizeWidth`. + */ + resizeHeight: null, + + /** + * The mime type of the resized image (before it gets uploaded to the server). + * If `null` the original mime type will be used. To force jpeg, for example, use `image/jpeg`. + * See `resizeWidth` for more information. + */ + resizeMimeType: null, + + /** + * The quality of the resized images. See `resizeWidth`. + */ + resizeQuality: 0.8, + + /** + * How the images should be scaled down in case both, `resizeWidth` and `resizeHeight` are provided. + * Can be either `contain` or `crop`. + */ + resizeMethod: 'contain', + + /** + * The base that is used to calculate the filesize. You can change this to + * 1024 if you would rather display kibibytes, mebibytes, etc... + * 1024 is technically incorrect, because `1024 bytes` are `1 kibibyte` not `1 kilobyte`. + * You can change this to `1024` if you don't care about validity. + */ + filesizeBase: 1000, + + /** + * Can be used to limit the maximum number of files that will be handled by this Dropzone + */ + maxFiles: null, + + /** + * An optional object to send additional headers to the server. Eg: + * `{ "My-Awesome-Header": "header value" }` + */ + headers: null, + + /** + * If `true`, the dropzone element itself will be clickable, if `false` + * nothing will be clickable. + * + * You can also pass an HTML element, a CSS selector (for multiple elements) + * or an array of those. In that case, all of those elements will trigger an + * upload when clicked. + */ + clickable: true, + + /** + * Whether hidden files in directories should be ignored. + */ + ignoreHiddenFiles: true, + + /** + * The default implementation of `accept` checks the file's mime type or + * extension against this list. This is a comma separated list of mime + * types or file extensions. + * + * Eg.: `image/*,application/pdf,.psd` + * + * If the Dropzone is `clickable` this option will also be used as + * [`accept`](https://developer.mozilla.org/en-US/docs/HTML/Element/input#attr-accept) + * parameter on the hidden file input as well. + */ + acceptedFiles: null, + + /** + * **Deprecated!** + * Use acceptedFiles instead. + */ + acceptedMimeTypes: null, + + /** + * If false, files will be added to the queue but the queue will not be + * processed automatically. + * This can be useful if you need some additional user input before sending + * files (or if you want want all files sent at once). + * If you're ready to send the file simply call `myDropzone.processQueue()`. + * + * See the [enqueuing file uploads](#enqueuing-file-uploads) documentation + * section for more information. + */ + autoProcessQueue: true, + + /** + * If false, files added to the dropzone will not be queued by default. + * You'll have to call `enqueueFile(file)` manually. + */ + autoQueue: true, + + /** + * If `true`, this will add a link to every file preview to remove or cancel (if + * already uploading) the file. The `dictCancelUpload`, `dictCancelUploadConfirmation` + * and `dictRemoveFile` options are used for the wording. + */ + addRemoveLinks: false, + + /** + * Defines where to display the file previews – if `null` the + * Dropzone element itself is used. Can be a plain `HTMLElement` or a CSS + * selector. The element should have the `dropzone-previews` class so + * the previews are displayed properly. + */ + previewsContainer: null, + + /** + * This is the element the hidden input field (which is used when clicking on the + * dropzone to trigger file selection) will be appended to. This might + * be important in case you use frameworks to switch the content of your page. + */ + hiddenInputContainer: "body", + + /** + * If null, no capture type will be specified + * If camera, mobile devices will skip the file selection and choose camera + * If microphone, mobile devices will skip the file selection and choose the microphone + * If camcorder, mobile devices will skip the file selection and choose the camera in video mode + * On apple devices multiple must be set to false. AcceptedFiles may need to + * be set to an appropriate mime type (e.g. "image/*", "audio/*", or "video/*"). + */ + capture: null, + + /** + * **Deprecated**. Use `renameFile` instead. + */ + renameFilename: null, + + /** + * A function that is invoked before the file is uploaded to the server and renames the file. + * This function gets the `File` as argument and can use the `file.name`. The actual name of the + * file that gets used during the upload can be accessed through `file.upload.filename`. + */ + renameFile: null, + + /** + * If `true` the fallback will be forced. This is very useful to test your server + * implementations first and make sure that everything works as + * expected without dropzone if you experience problems, and to test + * how your fallbacks will look. + */ + forceFallback: false, + + /** + * The text used before any files are dropped. + */ + dictDefaultMessage: "Drop files here to upload", + + /** + * The text that replaces the default message text it the browser is not supported. + */ + dictFallbackMessage: "Your browser does not support drag'n'drop file uploads.", + + /** + * The text that will be added before the fallback form. + * If you provide a fallback element yourself, or if this option is `null` this will + * be ignored. + */ + dictFallbackText: "Please use the fallback form below to upload your files like in the olden days.", + + /** + * If the filesize is too big. + * `{{filesize}}` and `{{maxFilesize}}` will be replaced with the respective configuration values. + */ + dictFileTooBig: "File is too big ({{filesize}}MiB). Max filesize: {{maxFilesize}}MiB.", + + /** + * If the file doesn't match the file type. + */ + dictInvalidFileType: "You can't upload files of this type.", + + /** + * If the server response was invalid. + * `{{statusCode}}` will be replaced with the servers status code. + */ + dictResponseError: "Server responded with {{statusCode}} code.", + + /** + * If `addRemoveLinks` is true, the text to be used for the cancel upload link. + */ + dictCancelUpload: "Cancel upload", + + /** + * If `addRemoveLinks` is true, the text to be used for confirmation when cancelling upload. + */ + dictCancelUploadConfirmation: "Are you sure you want to cancel this upload?", + + /** + * If `addRemoveLinks` is true, the text to be used to remove a file. + */ + dictRemoveFile: "Remove file", + + /** + * If this is not null, then the user will be prompted before removing a file. + */ + dictRemoveFileConfirmation: null, + + /** + * Displayed if `maxFiles` is st and exceeded. + * The string `{{maxFiles}}` will be replaced by the configuration value. + */ + dictMaxFilesExceeded: "You can not upload any more files.", + + /** + * Allows you to translate the different units. Starting with `tb` for terabytes and going down to + * `b` for bytes. + */ + dictFileSizeUnits: { tb: "TB", gb: "GB", mb: "MB", kb: "KB", b: "b" }, + + /** + * Called when dropzone initialized + * You can add event listeners here + */ + init: function init() {}, + + + /** + * Can be an **object** of additional parameters to transfer to the server, **or** a `Function` + * that gets invoked with the `files`, `xhr` and, if it's a chunked upload, `chunk` arguments. In case + * of a function, this needs to return a map. + * + * The default implementation does nothing for normal uploads, but adds relevant information for + * chunked uploads. + * + * This is the same as adding hidden input fields in the form element. + */ + params: function params(files, xhr, chunk) { + if (chunk) { + return { + dzuuid: chunk.file.upload.uuid, + dzchunkindex: chunk.index, + dztotalfilesize: chunk.file.size, + dzchunksize: this.options.chunkSize, + dztotalchunkcount: chunk.file.upload.totalChunkCount, + dzchunkbyteoffset: chunk.index * this.options.chunkSize + }; + } + }, + + + /** + * A function that gets a [file](https://developer.mozilla.org/en-US/docs/DOM/File) + * and a `done` function as parameters. + * + * If the done function is invoked without arguments, the file is "accepted" and will + * be processed. If you pass an error message, the file is rejected, and the error + * message will be displayed. + * This function will not be called if the file is too big or doesn't match the mime types. + */ + accept: function accept(file, done) { + return done(); + }, + + + /** + * The callback that will be invoked when all chunks have been uploaded for a file. + * It gets the file for which the chunks have been uploaded as the first parameter, + * and the `done` function as second. `done()` needs to be invoked when everything + * needed to finish the upload process is done. + */ + chunksUploaded: function chunksUploaded(file, done) { + done(); + }, + + /** + * Gets called when the browser is not supported. + * The default implementation shows the fallback input field and adds + * a text. + */ + fallback: function fallback() { + // This code should pass in IE7... :( + var messageElement = void 0; + this.element.className = this.element.className + " dz-browser-not-supported"; + + for (var _iterator2 = this.element.getElementsByTagName("div"), _isArray2 = true, _i2 = 0, _iterator2 = _isArray2 ? _iterator2 : _iterator2[Symbol.iterator]();;) { + var _ref2; + + if (_isArray2) { + if (_i2 >= _iterator2.length) break; + _ref2 = _iterator2[_i2++]; + } else { + _i2 = _iterator2.next(); + if (_i2.done) break; + _ref2 = _i2.value; + } + + var child = _ref2; + + if (/(^| )dz-message($| )/.test(child.className)) { + messageElement = child; + child.className = "dz-message"; // Removes the 'dz-default' class + break; + } + } + if (!messageElement) { + messageElement = Dropzone.createElement("
"); + this.element.appendChild(messageElement); + } + + var span = messageElement.getElementsByTagName("span")[0]; + if (span) { + if (span.textContent != null) { + span.textContent = this.options.dictFallbackMessage; + } else if (span.innerText != null) { + span.innerText = this.options.dictFallbackMessage; + } + } + + return this.element.appendChild(this.getFallbackForm()); + }, + + + /** + * Gets called to calculate the thumbnail dimensions. + * + * It gets `file`, `width` and `height` (both may be `null`) as parameters and must return an object containing: + * + * - `srcWidth` & `srcHeight` (required) + * - `trgWidth` & `trgHeight` (required) + * - `srcX` & `srcY` (optional, default `0`) + * - `trgX` & `trgY` (optional, default `0`) + * + * Those values are going to be used by `ctx.drawImage()`. + */ + resize: function resize(file, width, height, resizeMethod) { + var info = { + srcX: 0, + srcY: 0, + srcWidth: file.width, + srcHeight: file.height + }; + + var srcRatio = file.width / file.height; + + // Automatically calculate dimensions if not specified + if (width == null && height == null) { + width = info.srcWidth; + height = info.srcHeight; + } else if (width == null) { + width = height * srcRatio; + } else if (height == null) { + height = width / srcRatio; + } + + // Make sure images aren't upscaled + width = Math.min(width, info.srcWidth); + height = Math.min(height, info.srcHeight); + + var trgRatio = width / height; + + if (info.srcWidth > width || info.srcHeight > height) { + // Image is bigger and needs rescaling + if (resizeMethod === 'crop') { + if (srcRatio > trgRatio) { + info.srcHeight = file.height; + info.srcWidth = info.srcHeight * trgRatio; + } else { + info.srcWidth = file.width; + info.srcHeight = info.srcWidth / trgRatio; + } + } else if (resizeMethod === 'contain') { + // Method 'contain' + if (srcRatio > trgRatio) { + height = width / srcRatio; + } else { + width = height * srcRatio; + } + } else { + throw new Error("Unknown resizeMethod '" + resizeMethod + "'"); + } + } + + info.srcX = (file.width - info.srcWidth) / 2; + info.srcY = (file.height - info.srcHeight) / 2; + + info.trgWidth = width; + info.trgHeight = height; + + return info; + }, + + + /** + * Can be used to transform the file (for example, resize an image if necessary). + * + * The default implementation uses `resizeWidth` and `resizeHeight` (if provided) and resizes + * images according to those dimensions. + * + * Gets the `file` as the first parameter, and a `done()` function as the second, that needs + * to be invoked with the file when the transformation is done. + */ + transformFile: function transformFile(file, done) { + if ((this.options.resizeWidth || this.options.resizeHeight) && file.type.match(/image.*/)) { + return this.resizeImage(file, this.options.resizeWidth, this.options.resizeHeight, this.options.resizeMethod, done); + } else { + return done(file); + } + }, + + + /** + * A string that contains the template used for each dropped + * file. Change it to fulfill your needs but make sure to properly + * provide all elements. + * + * If you want to use an actual HTML element instead of providing a String + * as a config option, you could create a div with the id `tpl`, + * put the template inside it and provide the element like this: + * + * document + * .querySelector('#tpl') + * .innerHTML + * + */ + previewTemplate: "
\n
\n
\n
\n
\n
\n
\n
\n
\n \n Check\n \n \n \n \n \n
\n
\n \n Error\n \n \n \n \n \n \n \n
\n
", + + // END OPTIONS + // (Required by the dropzone documentation parser) + + + /* + Those functions register themselves to the events on init and handle all + the user interface specific stuff. Overwriting them won't break the upload + but can break the way it's displayed. + You can overwrite them if you don't like the default behavior. If you just + want to add an additional event handler, register it on the dropzone object + and don't overwrite those options. + */ + + // Those are self explanatory and simply concern the DragnDrop. + drop: function drop(e) { + return this.element.classList.remove("dz-drag-hover"); + }, + dragstart: function dragstart(e) {}, + dragend: function dragend(e) { + return this.element.classList.remove("dz-drag-hover"); + }, + dragenter: function dragenter(e) { + return this.element.classList.add("dz-drag-hover"); + }, + dragover: function dragover(e) { + return this.element.classList.add("dz-drag-hover"); + }, + dragleave: function dragleave(e) { + return this.element.classList.remove("dz-drag-hover"); + }, + paste: function paste(e) {}, + + + // Called whenever there are no files left in the dropzone anymore, and the + // dropzone should be displayed as if in the initial state. + reset: function reset() { + return this.element.classList.remove("dz-started"); + }, + + + // Called when a file is added to the queue + // Receives `file` + addedfile: function addedfile(file) { + var _this2 = this; + + if (this.element === this.previewsContainer) { + this.element.classList.add("dz-started"); + } + + if (this.previewsContainer) { + file.previewElement = Dropzone.createElement(this.options.previewTemplate.trim()); + file.previewTemplate = file.previewElement; // Backwards compatibility + + this.previewsContainer.appendChild(file.previewElement); + for (var _iterator3 = file.previewElement.querySelectorAll("[data-dz-name]"), _isArray3 = true, _i3 = 0, _iterator3 = _isArray3 ? _iterator3 : _iterator3[Symbol.iterator]();;) { + var _ref3; + + if (_isArray3) { + if (_i3 >= _iterator3.length) break; + _ref3 = _iterator3[_i3++]; + } else { + _i3 = _iterator3.next(); + if (_i3.done) break; + _ref3 = _i3.value; + } + + var node = _ref3; + + node.textContent = file.name; + } + for (var _iterator4 = file.previewElement.querySelectorAll("[data-dz-size]"), _isArray4 = true, _i4 = 0, _iterator4 = _isArray4 ? _iterator4 : _iterator4[Symbol.iterator]();;) { + if (_isArray4) { + if (_i4 >= _iterator4.length) break; + node = _iterator4[_i4++]; + } else { + _i4 = _iterator4.next(); + if (_i4.done) break; + node = _i4.value; + } + + node.innerHTML = this.filesize(file.size); + } + + if (this.options.addRemoveLinks) { + file._removeLink = Dropzone.createElement("" + this.options.dictRemoveFile + ""); + file.previewElement.appendChild(file._removeLink); + } + + var removeFileEvent = function removeFileEvent(e) { + e.preventDefault(); + e.stopPropagation(); + if (file.status === Dropzone.UPLOADING) { + return Dropzone.confirm(_this2.options.dictCancelUploadConfirmation, function () { + return _this2.removeFile(file); + }); + } else { + if (_this2.options.dictRemoveFileConfirmation) { + return Dropzone.confirm(_this2.options.dictRemoveFileConfirmation, function () { + return _this2.removeFile(file); + }); + } else { + return _this2.removeFile(file); + } + } + }; + + for (var _iterator5 = file.previewElement.querySelectorAll("[data-dz-remove]"), _isArray5 = true, _i5 = 0, _iterator5 = _isArray5 ? _iterator5 : _iterator5[Symbol.iterator]();;) { + var _ref4; + + if (_isArray5) { + if (_i5 >= _iterator5.length) break; + _ref4 = _iterator5[_i5++]; + } else { + _i5 = _iterator5.next(); + if (_i5.done) break; + _ref4 = _i5.value; + } + + var removeLink = _ref4; + + removeLink.addEventListener("click", removeFileEvent); + } + } + }, + + + // Called whenever a file is removed. + removedfile: function removedfile(file) { + if (file.previewElement != null && file.previewElement.parentNode != null) { + file.previewElement.parentNode.removeChild(file.previewElement); + } + return this._updateMaxFilesReachedClass(); + }, + + + // Called when a thumbnail has been generated + // Receives `file` and `dataUrl` + thumbnail: function thumbnail(file, dataUrl) { + if (file.previewElement) { + file.previewElement.classList.remove("dz-file-preview"); + for (var _iterator6 = file.previewElement.querySelectorAll("[data-dz-thumbnail]"), _isArray6 = true, _i6 = 0, _iterator6 = _isArray6 ? _iterator6 : _iterator6[Symbol.iterator]();;) { + var _ref5; + + if (_isArray6) { + if (_i6 >= _iterator6.length) break; + _ref5 = _iterator6[_i6++]; + } else { + _i6 = _iterator6.next(); + if (_i6.done) break; + _ref5 = _i6.value; + } + + var thumbnailElement = _ref5; + + thumbnailElement.alt = file.name; + thumbnailElement.src = dataUrl; + } + + return setTimeout(function () { + return file.previewElement.classList.add("dz-image-preview"); + }, 1); + } + }, + + + // Called whenever an error occurs + // Receives `file` and `message` + error: function error(file, message) { + if (file.previewElement) { + file.previewElement.classList.add("dz-error"); + if (typeof message !== "String" && message.error) { + message = message.error; + } + for (var _iterator7 = file.previewElement.querySelectorAll("[data-dz-errormessage]"), _isArray7 = true, _i7 = 0, _iterator7 = _isArray7 ? _iterator7 : _iterator7[Symbol.iterator]();;) { + var _ref6; + + if (_isArray7) { + if (_i7 >= _iterator7.length) break; + _ref6 = _iterator7[_i7++]; + } else { + _i7 = _iterator7.next(); + if (_i7.done) break; + _ref6 = _i7.value; + } + + var node = _ref6; + + node.textContent = message; + } + } + }, + errormultiple: function errormultiple() {}, + + + // Called when a file gets processed. Since there is a cue, not all added + // files are processed immediately. + // Receives `file` + processing: function processing(file) { + if (file.previewElement) { + file.previewElement.classList.add("dz-processing"); + if (file._removeLink) { + return file._removeLink.textContent = this.options.dictCancelUpload; + } + } + }, + processingmultiple: function processingmultiple() {}, + + + // Called whenever the upload progress gets updated. + // Receives `file`, `progress` (percentage 0-100) and `bytesSent`. + // To get the total number of bytes of the file, use `file.size` + uploadprogress: function uploadprogress(file, progress, bytesSent) { + if (file.previewElement) { + for (var _iterator8 = file.previewElement.querySelectorAll("[data-dz-uploadprogress]"), _isArray8 = true, _i8 = 0, _iterator8 = _isArray8 ? _iterator8 : _iterator8[Symbol.iterator]();;) { + var _ref7; + + if (_isArray8) { + if (_i8 >= _iterator8.length) break; + _ref7 = _iterator8[_i8++]; + } else { + _i8 = _iterator8.next(); + if (_i8.done) break; + _ref7 = _i8.value; + } + + var node = _ref7; + + node.nodeName === 'PROGRESS' ? node.value = progress : node.style.width = progress + "%"; + } + } + }, + + + // Called whenever the total upload progress gets updated. + // Called with totalUploadProgress (0-100), totalBytes and totalBytesSent + totaluploadprogress: function totaluploadprogress() {}, + + + // Called just before the file is sent. Gets the `xhr` object as second + // parameter, so you can modify it (for example to add a CSRF token) and a + // `formData` object to add additional information. + sending: function sending() {}, + sendingmultiple: function sendingmultiple() {}, + + + // When the complete upload is finished and successful + // Receives `file` + success: function success(file) { + if (file.previewElement) { + return file.previewElement.classList.add("dz-success"); + } + }, + successmultiple: function successmultiple() {}, + + + // When the upload is canceled. + canceled: function canceled(file) { + return this.emit("error", file, "Upload canceled."); + }, + canceledmultiple: function canceledmultiple() {}, + + + // When the upload is finished, either with success or an error. + // Receives `file` + complete: function complete(file) { + if (file._removeLink) { + file._removeLink.textContent = this.options.dictRemoveFile; + } + if (file.previewElement) { + return file.previewElement.classList.add("dz-complete"); + } + }, + completemultiple: function completemultiple() {}, + maxfilesexceeded: function maxfilesexceeded() {}, + maxfilesreached: function maxfilesreached() {}, + queuecomplete: function queuecomplete() {}, + addedfiles: function addedfiles() {} + }; + + this.prototype._thumbnailQueue = []; + this.prototype._processingThumbnail = false; + } + + // global utility + + }, { + key: "extend", + value: function extend(target) { + for (var _len2 = arguments.length, objects = Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { + objects[_key2 - 1] = arguments[_key2]; + } + + for (var _iterator9 = objects, _isArray9 = true, _i9 = 0, _iterator9 = _isArray9 ? _iterator9 : _iterator9[Symbol.iterator]();;) { + var _ref8; + + if (_isArray9) { + if (_i9 >= _iterator9.length) break; + _ref8 = _iterator9[_i9++]; + } else { + _i9 = _iterator9.next(); + if (_i9.done) break; + _ref8 = _i9.value; + } + + var object = _ref8; + + for (var key in object) { + var val = object[key]; + target[key] = val; + } + } + return target; + } + }]); + + function Dropzone(el, options) { + _classCallCheck(this, Dropzone); + + var _this = _possibleConstructorReturn(this, (Dropzone.__proto__ || Object.getPrototypeOf(Dropzone)).call(this)); + + var fallback = void 0, + left = void 0; + _this.element = el; + // For backwards compatibility since the version was in the prototype previously + _this.version = Dropzone.version; + + _this.defaultOptions.previewTemplate = _this.defaultOptions.previewTemplate.replace(/\n*/g, ""); + + _this.clickableElements = []; + _this.listeners = []; + _this.files = []; // All files + + if (typeof _this.element === "string") { + _this.element = document.querySelector(_this.element); + } + + // Not checking if instance of HTMLElement or Element since IE9 is extremely weird. + if (!_this.element || _this.element.nodeType == null) { + throw new Error("Invalid dropzone element."); + } + + if (_this.element.dropzone) { + throw new Error("Dropzone already attached."); + } + + // Now add this dropzone to the instances. + Dropzone.instances.push(_this); + + // Put the dropzone inside the element itself. + _this.element.dropzone = _this; + + var elementOptions = (left = Dropzone.optionsForElement(_this.element)) != null ? left : {}; + + _this.options = Dropzone.extend({}, _this.defaultOptions, elementOptions, options != null ? options : {}); + + // If the browser failed, just call the fallback and leave + if (_this.options.forceFallback || !Dropzone.isBrowserSupported()) { + var _ret; + + return _ret = _this.options.fallback.call(_this), _possibleConstructorReturn(_this, _ret); + } + + // @options.url = @element.getAttribute "action" unless @options.url? + if (_this.options.url == null) { + _this.options.url = _this.element.getAttribute("action"); + } + + if (!_this.options.url) { + throw new Error("No URL provided."); + } + + if (_this.options.acceptedFiles && _this.options.acceptedMimeTypes) { + throw new Error("You can't provide both 'acceptedFiles' and 'acceptedMimeTypes'. 'acceptedMimeTypes' is deprecated."); + } + + if (_this.options.uploadMultiple && _this.options.chunking) { + throw new Error('You cannot set both: uploadMultiple and chunking.'); + } + + // Backwards compatibility + if (_this.options.acceptedMimeTypes) { + _this.options.acceptedFiles = _this.options.acceptedMimeTypes; + delete _this.options.acceptedMimeTypes; + } + + // Backwards compatibility + if (_this.options.renameFilename != null) { + _this.options.renameFile = function (file) { + return _this.options.renameFilename.call(_this, file.name, file); + }; + } + + _this.options.method = _this.options.method.toUpperCase(); + + if ((fallback = _this.getExistingFallback()) && fallback.parentNode) { + // Remove the fallback + fallback.parentNode.removeChild(fallback); + } + + // Display previews in the previewsContainer element or the Dropzone element unless explicitly set to false + if (_this.options.previewsContainer !== false) { + if (_this.options.previewsContainer) { + _this.previewsContainer = Dropzone.getElement(_this.options.previewsContainer, "previewsContainer"); + } else { + _this.previewsContainer = _this.element; + } + } + + if (_this.options.clickable) { + if (_this.options.clickable === true) { + _this.clickableElements = [_this.element]; + } else { + _this.clickableElements = Dropzone.getElements(_this.options.clickable, "clickable"); + } + } + + _this.init(); + return _this; + } + + // Returns all files that have been accepted + + + _createClass(Dropzone, [{ + key: "getAcceptedFiles", + value: function getAcceptedFiles() { + return this.files.filter(function (file) { + return file.accepted; + }).map(function (file) { + return file; + }); + } + + // Returns all files that have been rejected + // Not sure when that's going to be useful, but added for completeness. + + }, { + key: "getRejectedFiles", + value: function getRejectedFiles() { + return this.files.filter(function (file) { + return !file.accepted; + }).map(function (file) { + return file; + }); + } + }, { + key: "getFilesWithStatus", + value: function getFilesWithStatus(status) { + return this.files.filter(function (file) { + return file.status === status; + }).map(function (file) { + return file; + }); + } + + // Returns all files that are in the queue + + }, { + key: "getQueuedFiles", + value: function getQueuedFiles() { + return this.getFilesWithStatus(Dropzone.QUEUED); + } + }, { + key: "getUploadingFiles", + value: function getUploadingFiles() { + return this.getFilesWithStatus(Dropzone.UPLOADING); + } + }, { + key: "getAddedFiles", + value: function getAddedFiles() { + return this.getFilesWithStatus(Dropzone.ADDED); + } + + // Files that are either queued or uploading + + }, { + key: "getActiveFiles", + value: function getActiveFiles() { + return this.files.filter(function (file) { + return file.status === Dropzone.UPLOADING || file.status === Dropzone.QUEUED; + }).map(function (file) { + return file; + }); + } + + // The function that gets called when Dropzone is initialized. You + // can (and should) setup event listeners inside this function. + + }, { + key: "init", + value: function init() { + var _this3 = this; + + // In case it isn't set already + if (this.element.tagName === "form") { + this.element.setAttribute("enctype", "multipart/form-data"); + } + + if (this.element.classList.contains("dropzone") && !this.element.querySelector(".dz-message")) { + this.element.appendChild(Dropzone.createElement("
" + this.options.dictDefaultMessage + "
")); + } + + if (this.clickableElements.length) { + var setupHiddenFileInput = function setupHiddenFileInput() { + if (_this3.hiddenFileInput) { + _this3.hiddenFileInput.parentNode.removeChild(_this3.hiddenFileInput); + } + _this3.hiddenFileInput = document.createElement("input"); + _this3.hiddenFileInput.setAttribute("type", "file"); + if (_this3.options.maxFiles === null || _this3.options.maxFiles > 1) { + _this3.hiddenFileInput.setAttribute("multiple", "multiple"); + } + _this3.hiddenFileInput.className = "dz-hidden-input"; + + if (_this3.options.acceptedFiles !== null) { + _this3.hiddenFileInput.setAttribute("accept", _this3.options.acceptedFiles); + } + if (_this3.options.capture !== null) { + _this3.hiddenFileInput.setAttribute("capture", _this3.options.capture); + } + + // Not setting `display="none"` because some browsers don't accept clicks + // on elements that aren't displayed. + _this3.hiddenFileInput.style.visibility = "hidden"; + _this3.hiddenFileInput.style.position = "absolute"; + _this3.hiddenFileInput.style.top = "0"; + _this3.hiddenFileInput.style.left = "0"; + _this3.hiddenFileInput.style.height = "0"; + _this3.hiddenFileInput.style.width = "0"; + document.querySelector(_this3.options.hiddenInputContainer).appendChild(_this3.hiddenFileInput); + return _this3.hiddenFileInput.addEventListener("change", function () { + var files = _this3.hiddenFileInput.files; + + if (files.length) { + for (var _iterator10 = files, _isArray10 = true, _i10 = 0, _iterator10 = _isArray10 ? _iterator10 : _iterator10[Symbol.iterator]();;) { + var _ref9; + + if (_isArray10) { + if (_i10 >= _iterator10.length) break; + _ref9 = _iterator10[_i10++]; + } else { + _i10 = _iterator10.next(); + if (_i10.done) break; + _ref9 = _i10.value; + } + + var file = _ref9; + + _this3.addFile(file); + } + } + _this3.emit("addedfiles", files); + return setupHiddenFileInput(); + }); + }; + setupHiddenFileInput(); + } + + this.URL = window.URL !== null ? window.URL : window.webkitURL; + + // Setup all event listeners on the Dropzone object itself. + // They're not in @setupEventListeners() because they shouldn't be removed + // again when the dropzone gets disabled. + for (var _iterator11 = this.events, _isArray11 = true, _i11 = 0, _iterator11 = _isArray11 ? _iterator11 : _iterator11[Symbol.iterator]();;) { + var _ref10; + + if (_isArray11) { + if (_i11 >= _iterator11.length) break; + _ref10 = _iterator11[_i11++]; + } else { + _i11 = _iterator11.next(); + if (_i11.done) break; + _ref10 = _i11.value; + } + + var eventName = _ref10; + + this.on(eventName, this.options[eventName]); + } + + this.on("uploadprogress", function () { + return _this3.updateTotalUploadProgress(); + }); + + this.on("removedfile", function () { + return _this3.updateTotalUploadProgress(); + }); + + this.on("canceled", function (file) { + return _this3.emit("complete", file); + }); + + // Emit a `queuecomplete` event if all files finished uploading. + this.on("complete", function (file) { + if (_this3.getAddedFiles().length === 0 && _this3.getUploadingFiles().length === 0 && _this3.getQueuedFiles().length === 0) { + // This needs to be deferred so that `queuecomplete` really triggers after `complete` + return setTimeout(function () { + return _this3.emit("queuecomplete"); + }, 0); + } + }); + + var noPropagation = function noPropagation(e) { + e.stopPropagation(); + if (e.preventDefault) { + return e.preventDefault(); + } else { + return e.returnValue = false; + } + }; + + // Create the listeners + this.listeners = [{ + element: this.element, + events: { + "dragstart": function dragstart(e) { + return _this3.emit("dragstart", e); + }, + "dragenter": function dragenter(e) { + noPropagation(e); + return _this3.emit("dragenter", e); + }, + "dragover": function dragover(e) { + // Makes it possible to drag files from chrome's download bar + // http://stackoverflow.com/questions/19526430/drag-and-drop-file-uploads-from-chrome-downloads-bar + // Try is required to prevent bug in Internet Explorer 11 (SCRIPT65535 exception) + var efct = void 0; + try { + efct = e.dataTransfer.effectAllowed; + } catch (error) {} + e.dataTransfer.dropEffect = 'move' === efct || 'linkMove' === efct ? 'move' : 'copy'; + + noPropagation(e); + return _this3.emit("dragover", e); + }, + "dragleave": function dragleave(e) { + return _this3.emit("dragleave", e); + }, + "drop": function drop(e) { + noPropagation(e); + return _this3.drop(e); + }, + "dragend": function dragend(e) { + return _this3.emit("dragend", e); + } + + // This is disabled right now, because the browsers don't implement it properly. + // "paste": (e) => + // noPropagation e + // @paste e + } }]; + + this.clickableElements.forEach(function (clickableElement) { + return _this3.listeners.push({ + element: clickableElement, + events: { + "click": function click(evt) { + // Only the actual dropzone or the message element should trigger file selection + if (clickableElement !== _this3.element || evt.target === _this3.element || Dropzone.elementInside(evt.target, _this3.element.querySelector(".dz-message"))) { + _this3.hiddenFileInput.click(); // Forward the click + } + return true; + } + } + }); + }); + + this.enable(); + + return this.options.init.call(this); + } + + // Not fully tested yet + + }, { + key: "destroy", + value: function destroy() { + this.disable(); + this.removeAllFiles(true); + if (this.hiddenFileInput != null ? this.hiddenFileInput.parentNode : undefined) { + this.hiddenFileInput.parentNode.removeChild(this.hiddenFileInput); + this.hiddenFileInput = null; + } + delete this.element.dropzone; + return Dropzone.instances.splice(Dropzone.instances.indexOf(this), 1); + } + }, { + key: "updateTotalUploadProgress", + value: function updateTotalUploadProgress() { + var totalUploadProgress = void 0; + var totalBytesSent = 0; + var totalBytes = 0; + + var activeFiles = this.getActiveFiles(); + + if (activeFiles.length) { + for (var _iterator12 = this.getActiveFiles(), _isArray12 = true, _i12 = 0, _iterator12 = _isArray12 ? _iterator12 : _iterator12[Symbol.iterator]();;) { + var _ref11; + + if (_isArray12) { + if (_i12 >= _iterator12.length) break; + _ref11 = _iterator12[_i12++]; + } else { + _i12 = _iterator12.next(); + if (_i12.done) break; + _ref11 = _i12.value; + } + + var file = _ref11; + + totalBytesSent += file.upload.bytesSent; + totalBytes += file.upload.total; + } + totalUploadProgress = 100 * totalBytesSent / totalBytes; + } else { + totalUploadProgress = 100; + } + + return this.emit("totaluploadprogress", totalUploadProgress, totalBytes, totalBytesSent); + } + + // @options.paramName can be a function taking one parameter rather than a string. + // A parameter name for a file is obtained simply by calling this with an index number. + + }, { + key: "_getParamName", + value: function _getParamName(n) { + if (typeof this.options.paramName === "function") { + return this.options.paramName(n); + } else { + return "" + this.options.paramName + (this.options.uploadMultiple ? "[" + n + "]" : ""); + } + } + + // If @options.renameFile is a function, + // the function will be used to rename the file.name before appending it to the formData + + }, { + key: "_renameFile", + value: function _renameFile(file) { + if (typeof this.options.renameFile !== "function") { + return file.name; + } + return this.options.renameFile(file); + } + + // Returns a form that can be used as fallback if the browser does not support DragnDrop + // + // If the dropzone is already a form, only the input field and button are returned. Otherwise a complete form element is provided. + // This code has to pass in IE7 :( + + }, { + key: "getFallbackForm", + value: function getFallbackForm() { + var existingFallback = void 0, + form = void 0; + if (existingFallback = this.getExistingFallback()) { + return existingFallback; + } + + var fieldsString = "
"; + if (this.options.dictFallbackText) { + fieldsString += "

" + this.options.dictFallbackText + "

"; + } + fieldsString += "
"; + + var fields = Dropzone.createElement(fieldsString); + if (this.element.tagName !== "FORM") { + form = Dropzone.createElement("
"); + form.appendChild(fields); + } else { + // Make sure that the enctype and method attributes are set properly + this.element.setAttribute("enctype", "multipart/form-data"); + this.element.setAttribute("method", this.options.method); + } + return form != null ? form : fields; + } + + // Returns the fallback elements if they exist already + // + // This code has to pass in IE7 :( + + }, { + key: "getExistingFallback", + value: function getExistingFallback() { + var getFallback = function getFallback(elements) { + for (var _iterator13 = elements, _isArray13 = true, _i13 = 0, _iterator13 = _isArray13 ? _iterator13 : _iterator13[Symbol.iterator]();;) { + var _ref12; + + if (_isArray13) { + if (_i13 >= _iterator13.length) break; + _ref12 = _iterator13[_i13++]; + } else { + _i13 = _iterator13.next(); + if (_i13.done) break; + _ref12 = _i13.value; + } + + var el = _ref12; + + if (/(^| )fallback($| )/.test(el.className)) { + return el; + } + } + }; + + var _arr = ["div", "form"]; + for (var _i14 = 0; _i14 < _arr.length; _i14++) { + var tagName = _arr[_i14]; + var fallback; + if (fallback = getFallback(this.element.getElementsByTagName(tagName))) { + return fallback; + } + } + } + + // Activates all listeners stored in @listeners + + }, { + key: "setupEventListeners", + value: function setupEventListeners() { + return this.listeners.map(function (elementListeners) { + return function () { + var result = []; + for (var event in elementListeners.events) { + var listener = elementListeners.events[event]; + result.push(elementListeners.element.addEventListener(event, listener, false)); + } + return result; + }(); + }); + } + + // Deactivates all listeners stored in @listeners + + }, { + key: "removeEventListeners", + value: function removeEventListeners() { + return this.listeners.map(function (elementListeners) { + return function () { + var result = []; + for (var event in elementListeners.events) { + var listener = elementListeners.events[event]; + result.push(elementListeners.element.removeEventListener(event, listener, false)); + } + return result; + }(); + }); + } + + // Removes all event listeners and cancels all files in the queue or being processed. + + }, { + key: "disable", + value: function disable() { + var _this4 = this; + + this.clickableElements.forEach(function (element) { + return element.classList.remove("dz-clickable"); + }); + this.removeEventListeners(); + + return this.files.map(function (file) { + return _this4.cancelUpload(file); + }); + } + }, { + key: "enable", + value: function enable() { + this.clickableElements.forEach(function (element) { + return element.classList.add("dz-clickable"); + }); + return this.setupEventListeners(); + } + + // Returns a nicely formatted filesize + + }, { + key: "filesize", + value: function filesize(size) { + var selectedSize = 0; + var selectedUnit = "b"; + + if (size > 0) { + var units = ['tb', 'gb', 'mb', 'kb', 'b']; + + for (var i = 0; i < units.length; i++) { + var unit = units[i]; + var cutoff = Math.pow(this.options.filesizeBase, 4 - i) / 10; + + if (size >= cutoff) { + selectedSize = size / Math.pow(this.options.filesizeBase, 4 - i); + selectedUnit = unit; + break; + } + } + + selectedSize = Math.round(10 * selectedSize) / 10; // Cutting of digits + } + + return "" + selectedSize + " " + this.options.dictFileSizeUnits[selectedUnit]; + } + + // Adds or removes the `dz-max-files-reached` class from the form. + + }, { + key: "_updateMaxFilesReachedClass", + value: function _updateMaxFilesReachedClass() { + if (this.options.maxFiles != null && this.getAcceptedFiles().length >= this.options.maxFiles) { + if (this.getAcceptedFiles().length === this.options.maxFiles) { + this.emit('maxfilesreached', this.files); + } + return this.element.classList.add("dz-max-files-reached"); + } else { + return this.element.classList.remove("dz-max-files-reached"); + } + } + }, { + key: "drop", + value: function drop(e) { + if (!e.dataTransfer) { + return; + } + this.emit("drop", e); + + var files = e.dataTransfer.files; + + this.emit("addedfiles", files); + + // Even if it's a folder, files.length will contain the folders. + if (files.length) { + var items = e.dataTransfer.items; + + if (items && items.length && items[0].webkitGetAsEntry != null) { + // The browser supports dropping of folders, so handle items instead of files + this._addFilesFromItems(items); + } else { + this.handleFiles(files); + } + } + } + }, { + key: "paste", + value: function paste(e) { + if (__guard__(e != null ? e.clipboardData : undefined, function (x) { + return x.items; + }) == null) { + return; + } + + this.emit("paste", e); + var items = e.clipboardData.items; + + + if (items.length) { + return this._addFilesFromItems(items); + } + } + }, { + key: "handleFiles", + value: function handleFiles(files) { + var _this5 = this; + + return files.map(function (file) { + return _this5.addFile(file); + }); + } + + // When a folder is dropped (or files are pasted), items must be handled + // instead of files. + + }, { + key: "_addFilesFromItems", + value: function _addFilesFromItems(items) { + var _this6 = this; + + return function () { + var result = []; + for (var _iterator14 = items, _isArray14 = true, _i15 = 0, _iterator14 = _isArray14 ? _iterator14 : _iterator14[Symbol.iterator]();;) { + var _ref13; + + if (_isArray14) { + if (_i15 >= _iterator14.length) break; + _ref13 = _iterator14[_i15++]; + } else { + _i15 = _iterator14.next(); + if (_i15.done) break; + _ref13 = _i15.value; + } + + var item = _ref13; + + var entry; + if (item.webkitGetAsEntry != null && (entry = item.webkitGetAsEntry())) { + if (entry.isFile) { + result.push(_this6.addFile(item.getAsFile())); + } else if (entry.isDirectory) { + // Append all files from that directory to files + result.push(_this6._addFilesFromDirectory(entry, entry.name)); + } else { + result.push(undefined); + } + } else if (item.getAsFile != null) { + if (item.kind == null || item.kind === "file") { + result.push(_this6.addFile(item.getAsFile())); + } else { + result.push(undefined); + } + } else { + result.push(undefined); + } + } + return result; + }(); + } + + // Goes through the directory, and adds each file it finds recursively + + }, { + key: "_addFilesFromDirectory", + value: function _addFilesFromDirectory(directory, path) { + var _this7 = this; + + var dirReader = directory.createReader(); + + var errorHandler = function errorHandler(error) { + return __guardMethod__(console, 'log', function (o) { + return o.log(error); + }); + }; + + var readEntries = function readEntries() { + return dirReader.readEntries(function (entries) { + if (entries.length > 0) { + for (var _iterator15 = entries, _isArray15 = true, _i16 = 0, _iterator15 = _isArray15 ? _iterator15 : _iterator15[Symbol.iterator]();;) { + var _ref14; + + if (_isArray15) { + if (_i16 >= _iterator15.length) break; + _ref14 = _iterator15[_i16++]; + } else { + _i16 = _iterator15.next(); + if (_i16.done) break; + _ref14 = _i16.value; + } + + var entry = _ref14; + + if (entry.isFile) { + entry.file(function (file) { + if (_this7.options.ignoreHiddenFiles && file.name.substring(0, 1) === '.') { + return; + } + file.fullPath = path + "/" + file.name; + return _this7.addFile(file); + }); + } else if (entry.isDirectory) { + _this7._addFilesFromDirectory(entry, path + "/" + entry.name); + } + } + + // Recursively call readEntries() again, since browser only handle + // the first 100 entries. + // See: https://developer.mozilla.org/en-US/docs/Web/API/DirectoryReader#readEntries + readEntries(); + } + return null; + }, errorHandler); + }; + + return readEntries(); + } + + // If `done()` is called without argument the file is accepted + // If you call it with an error message, the file is rejected + // (This allows for asynchronous validation) + // + // This function checks the filesize, and if the file.type passes the + // `acceptedFiles` check. + + }, { + key: "accept", + value: function accept(file, done) { + if (file.size > this.options.maxFilesize * 1024 * 1024) { + return done(this.options.dictFileTooBig.replace("{{filesize}}", Math.round(file.size / 1024 / 10.24) / 100).replace("{{maxFilesize}}", this.options.maxFilesize)); + } else if (!Dropzone.isValidFile(file, this.options.acceptedFiles)) { + return done(this.options.dictInvalidFileType); + } else if (this.options.maxFiles != null && this.getAcceptedFiles().length >= this.options.maxFiles) { + done(this.options.dictMaxFilesExceeded.replace("{{maxFiles}}", this.options.maxFiles)); + return this.emit("maxfilesexceeded", file); + } else { + return this.options.accept.call(this, file, done); + } + } + }, { + key: "addFile", + value: function addFile(file) { + var _this8 = this; + + file.upload = { + uuid: Dropzone.uuidv4(), + progress: 0, + // Setting the total upload size to file.size for the beginning + // It's actual different than the size to be transmitted. + total: file.size, + bytesSent: 0, + filename: this._renameFile(file), + chunked: this.options.chunking && (this.options.forceChunking || file.size > this.options.chunkSize), + totalChunkCount: Math.ceil(file.size / this.options.chunkSize) + }; + this.files.push(file); + + file.status = Dropzone.ADDED; + + this.emit("addedfile", file); + + this._enqueueThumbnail(file); + + return this.accept(file, function (error) { + if (error) { + file.accepted = false; + _this8._errorProcessing([file], error); // Will set the file.status + } else { + file.accepted = true; + if (_this8.options.autoQueue) { + _this8.enqueueFile(file); + } // Will set .accepted = true + } + return _this8._updateMaxFilesReachedClass(); + }); + } + + // Wrapper for enqueueFile + + }, { + key: "enqueueFiles", + value: function enqueueFiles(files) { + for (var _iterator16 = files, _isArray16 = true, _i17 = 0, _iterator16 = _isArray16 ? _iterator16 : _iterator16[Symbol.iterator]();;) { + var _ref15; + + if (_isArray16) { + if (_i17 >= _iterator16.length) break; + _ref15 = _iterator16[_i17++]; + } else { + _i17 = _iterator16.next(); + if (_i17.done) break; + _ref15 = _i17.value; + } + + var file = _ref15; + + this.enqueueFile(file); + } + return null; + } + }, { + key: "enqueueFile", + value: function enqueueFile(file) { + var _this9 = this; + + if (file.status === Dropzone.ADDED && file.accepted === true) { + file.status = Dropzone.QUEUED; + if (this.options.autoProcessQueue) { + return setTimeout(function () { + return _this9.processQueue(); + }, 0); // Deferring the call + } + } else { + throw new Error("This file can't be queued because it has already been processed or was rejected."); + } + } + }, { + key: "_enqueueThumbnail", + value: function _enqueueThumbnail(file) { + var _this10 = this; + + if (this.options.createImageThumbnails && file.type.match(/image.*/) && file.size <= this.options.maxThumbnailFilesize * 1024 * 1024) { + this._thumbnailQueue.push(file); + return setTimeout(function () { + return _this10._processThumbnailQueue(); + }, 0); // Deferring the call + } + } + }, { + key: "_processThumbnailQueue", + value: function _processThumbnailQueue() { + var _this11 = this; + + if (this._processingThumbnail || this._thumbnailQueue.length === 0) { + return; + } + + this._processingThumbnail = true; + var file = this._thumbnailQueue.shift(); + return this.createThumbnail(file, this.options.thumbnailWidth, this.options.thumbnailHeight, this.options.thumbnailMethod, true, function (dataUrl) { + _this11.emit("thumbnail", file, dataUrl); + _this11._processingThumbnail = false; + return _this11._processThumbnailQueue(); + }); + } + + // Can be called by the user to remove a file + + }, { + key: "removeFile", + value: function removeFile(file) { + if (file.status === Dropzone.UPLOADING) { + this.cancelUpload(file); + } + this.files = without(this.files, file); + + this.emit("removedfile", file); + if (this.files.length === 0) { + return this.emit("reset"); + } + } + + // Removes all files that aren't currently processed from the list + + }, { + key: "removeAllFiles", + value: function removeAllFiles(cancelIfNecessary) { + // Create a copy of files since removeFile() changes the @files array. + if (cancelIfNecessary == null) { + cancelIfNecessary = false; + } + for (var _iterator17 = this.files.slice(), _isArray17 = true, _i18 = 0, _iterator17 = _isArray17 ? _iterator17 : _iterator17[Symbol.iterator]();;) { + var _ref16; + + if (_isArray17) { + if (_i18 >= _iterator17.length) break; + _ref16 = _iterator17[_i18++]; + } else { + _i18 = _iterator17.next(); + if (_i18.done) break; + _ref16 = _i18.value; + } + + var file = _ref16; + + if (file.status !== Dropzone.UPLOADING || cancelIfNecessary) { + this.removeFile(file); + } + } + return null; + } + + // Resizes an image before it gets sent to the server. This function is the default behavior of + // `options.transformFile` if `resizeWidth` or `resizeHeight` are set. The callback is invoked with + // the resized blob. + + }, { + key: "resizeImage", + value: function resizeImage(file, width, height, resizeMethod, callback) { + var _this12 = this; + + return this.createThumbnail(file, width, height, resizeMethod, false, function (dataUrl, canvas) { + if (canvas === null) { + // The image has not been resized + return callback(file); + } else { + var resizeMimeType = _this12.options.resizeMimeType; + + if (resizeMimeType == null) { + resizeMimeType = file.type; + } + var resizedDataURL = canvas.toDataURL(resizeMimeType, _this12.options.resizeQuality); + if (resizeMimeType === 'image/jpeg' || resizeMimeType === 'image/jpg') { + // Now add the original EXIF information + resizedDataURL = ExifRestore.restore(file.dataURL, resizedDataURL); + } + return callback(Dropzone.dataURItoBlob(resizedDataURL)); + } + }); + } + }, { + key: "createThumbnail", + value: function createThumbnail(file, width, height, resizeMethod, fixOrientation, callback) { + var _this13 = this; + + var fileReader = new FileReader(); + + fileReader.onload = function () { + + file.dataURL = fileReader.result; + + // Don't bother creating a thumbnail for SVG images since they're vector + if (file.type === "image/svg+xml") { + if (callback != null) { + callback(fileReader.result); + } + return; + } + + return _this13.createThumbnailFromUrl(file, width, height, resizeMethod, fixOrientation, callback); + }; + + return fileReader.readAsDataURL(file); + } + }, { + key: "createThumbnailFromUrl", + value: function createThumbnailFromUrl(file, width, height, resizeMethod, fixOrientation, callback, crossOrigin) { + var _this14 = this; + + // Not using `new Image` here because of a bug in latest Chrome versions. + // See https://github.com/enyo/dropzone/pull/226 + var img = document.createElement("img"); + + if (crossOrigin) { + img.crossOrigin = crossOrigin; + } + + img.onload = function () { + var loadExif = function loadExif(callback) { + return callback(1); + }; + if (typeof EXIF !== 'undefined' && EXIF !== null && fixOrientation) { + loadExif = function loadExif(callback) { + return EXIF.getData(img, function () { + return callback(EXIF.getTag(this, 'Orientation')); + }); + }; + } + + return loadExif(function (orientation) { + file.width = img.width; + file.height = img.height; + + var resizeInfo = _this14.options.resize.call(_this14, file, width, height, resizeMethod); + + var canvas = document.createElement("canvas"); + var ctx = canvas.getContext("2d"); + + canvas.width = resizeInfo.trgWidth; + canvas.height = resizeInfo.trgHeight; + + if (orientation > 4) { + canvas.width = resizeInfo.trgHeight; + canvas.height = resizeInfo.trgWidth; + } + + switch (orientation) { + case 2: + // horizontal flip + ctx.translate(canvas.width, 0); + ctx.scale(-1, 1); + break; + case 3: + // 180° rotate left + ctx.translate(canvas.width, canvas.height); + ctx.rotate(Math.PI); + break; + case 4: + // vertical flip + ctx.translate(0, canvas.height); + ctx.scale(1, -1); + break; + case 5: + // vertical flip + 90 rotate right + ctx.rotate(0.5 * Math.PI); + ctx.scale(1, -1); + break; + case 6: + // 90° rotate right + ctx.rotate(0.5 * Math.PI); + ctx.translate(0, -canvas.height); + break; + case 7: + // horizontal flip + 90 rotate right + ctx.rotate(0.5 * Math.PI); + ctx.translate(canvas.width, -canvas.height); + ctx.scale(-1, 1); + break; + case 8: + // 90° rotate left + ctx.rotate(-0.5 * Math.PI); + ctx.translate(-canvas.width, 0); + break; + } + + // This is a bugfix for iOS' scaling bug. + drawImageIOSFix(ctx, img, resizeInfo.srcX != null ? resizeInfo.srcX : 0, resizeInfo.srcY != null ? resizeInfo.srcY : 0, resizeInfo.srcWidth, resizeInfo.srcHeight, resizeInfo.trgX != null ? resizeInfo.trgX : 0, resizeInfo.trgY != null ? resizeInfo.trgY : 0, resizeInfo.trgWidth, resizeInfo.trgHeight); + + var thumbnail = canvas.toDataURL("image/png"); + + if (callback != null) { + return callback(thumbnail, canvas); + } + }); + }; + + if (callback != null) { + img.onerror = callback; + } + + return img.src = file.dataURL; + } + + // Goes through the queue and processes files if there aren't too many already. + + }, { + key: "processQueue", + value: function processQueue() { + var parallelUploads = this.options.parallelUploads; + + var processingLength = this.getUploadingFiles().length; + var i = processingLength; + + // There are already at least as many files uploading than should be + if (processingLength >= parallelUploads) { + return; + } + + var queuedFiles = this.getQueuedFiles(); + + if (!(queuedFiles.length > 0)) { + return; + } + + if (this.options.uploadMultiple) { + // The files should be uploaded in one request + return this.processFiles(queuedFiles.slice(0, parallelUploads - processingLength)); + } else { + while (i < parallelUploads) { + if (!queuedFiles.length) { + return; + } // Nothing left to process + this.processFile(queuedFiles.shift()); + i++; + } + } + } + + // Wrapper for `processFiles` + + }, { + key: "processFile", + value: function processFile(file) { + return this.processFiles([file]); + } + + // Loads the file, then calls finishedLoading() + + }, { + key: "processFiles", + value: function processFiles(files) { + for (var _iterator18 = files, _isArray18 = true, _i19 = 0, _iterator18 = _isArray18 ? _iterator18 : _iterator18[Symbol.iterator]();;) { + var _ref17; + + if (_isArray18) { + if (_i19 >= _iterator18.length) break; + _ref17 = _iterator18[_i19++]; + } else { + _i19 = _iterator18.next(); + if (_i19.done) break; + _ref17 = _i19.value; + } + + var file = _ref17; + + file.processing = true; // Backwards compatibility + file.status = Dropzone.UPLOADING; + + this.emit("processing", file); + } + + if (this.options.uploadMultiple) { + this.emit("processingmultiple", files); + } + + return this.uploadFiles(files); + } + }, { + key: "_getFilesWithXhr", + value: function _getFilesWithXhr(xhr) { + var files = void 0; + return files = this.files.filter(function (file) { + return file.xhr === xhr; + }).map(function (file) { + return file; + }); + } + + // Cancels the file upload and sets the status to CANCELED + // **if** the file is actually being uploaded. + // If it's still in the queue, the file is being removed from it and the status + // set to CANCELED. + + }, { + key: "cancelUpload", + value: function cancelUpload(file) { + if (file.status === Dropzone.UPLOADING) { + var groupedFiles = this._getFilesWithXhr(file.xhr); + for (var _iterator19 = groupedFiles, _isArray19 = true, _i20 = 0, _iterator19 = _isArray19 ? _iterator19 : _iterator19[Symbol.iterator]();;) { + var _ref18; + + if (_isArray19) { + if (_i20 >= _iterator19.length) break; + _ref18 = _iterator19[_i20++]; + } else { + _i20 = _iterator19.next(); + if (_i20.done) break; + _ref18 = _i20.value; + } + + var groupedFile = _ref18; + + groupedFile.status = Dropzone.CANCELED; + } + if (typeof file.xhr !== 'undefined') { + file.xhr.abort(); + } + for (var _iterator20 = groupedFiles, _isArray20 = true, _i21 = 0, _iterator20 = _isArray20 ? _iterator20 : _iterator20[Symbol.iterator]();;) { + var _ref19; + + if (_isArray20) { + if (_i21 >= _iterator20.length) break; + _ref19 = _iterator20[_i21++]; + } else { + _i21 = _iterator20.next(); + if (_i21.done) break; + _ref19 = _i21.value; + } + + var _groupedFile = _ref19; + + this.emit("canceled", _groupedFile); + } + if (this.options.uploadMultiple) { + this.emit("canceledmultiple", groupedFiles); + } + } else if (file.status === Dropzone.ADDED || file.status === Dropzone.QUEUED) { + file.status = Dropzone.CANCELED; + this.emit("canceled", file); + if (this.options.uploadMultiple) { + this.emit("canceledmultiple", [file]); + } + } + + if (this.options.autoProcessQueue) { + return this.processQueue(); + } + } + }, { + key: "resolveOption", + value: function resolveOption(option) { + if (typeof option === 'function') { + for (var _len3 = arguments.length, args = Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) { + args[_key3 - 1] = arguments[_key3]; + } + + return option.apply(this, args); + } + return option; + } + }, { + key: "uploadFile", + value: function uploadFile(file) { + return this.uploadFiles([file]); + } + }, { + key: "uploadFiles", + value: function uploadFiles(files) { + var _this15 = this; + + this._transformFiles(files, function (transformedFiles) { + if (files[0].upload.chunked) { + // This file should be sent in chunks! + + // If the chunking option is set, we **know** that there can only be **one** file, since + // uploadMultiple is not allowed with this option. + var file = files[0]; + var transformedFile = transformedFiles[0]; + var startedChunkCount = 0; + + file.upload.chunks = []; + + var handleNextChunk = function handleNextChunk() { + var chunkIndex = 0; + + // Find the next item in file.upload.chunks that is not defined yet. + while (file.upload.chunks[chunkIndex] !== undefined) { + chunkIndex++; + } + + // This means, that all chunks have already been started. + if (chunkIndex >= file.upload.totalChunkCount) return; + + startedChunkCount++; + + var start = chunkIndex * _this15.options.chunkSize; + var end = Math.min(start + _this15.options.chunkSize, file.size); + + var dataBlock = { + name: _this15._getParamName(0), + data: transformedFile.webkitSlice ? transformedFile.webkitSlice(start, end) : transformedFile.slice(start, end), + filename: file.upload.filename, + chunkIndex: chunkIndex + }; + + file.upload.chunks[chunkIndex] = { + file: file, + index: chunkIndex, + dataBlock: dataBlock, // In case we want to retry. + status: Dropzone.UPLOADING, + progress: 0, + retries: 0 // The number of times this block has been retried. + }; + + _this15._uploadData(files, [dataBlock]); + }; + + file.upload.finishedChunkUpload = function (chunk) { + var allFinished = true; + chunk.status = Dropzone.SUCCESS; + + // Clear the data from the chunk + chunk.dataBlock = null; + + for (var i = 0; i < file.upload.totalChunkCount; i++) { + if (file.upload.chunks[i] === undefined) { + return handleNextChunk(); + } + if (file.upload.chunks[i].status !== Dropzone.SUCCESS) { + allFinished = false; + } + } + + if (allFinished) { + _this15.options.chunksUploaded(file, function () { + _this15._finished(files, '', null); + }); + } + }; + + if (_this15.options.parallelChunkUploads) { + for (var i = 0; i < file.upload.totalChunkCount; i++) { + handleNextChunk(); + } + } else { + handleNextChunk(); + } + } else { + var dataBlocks = []; + for (var _i22 = 0; _i22 < files.length; _i22++) { + dataBlocks[_i22] = { + name: _this15._getParamName(_i22), + data: transformedFiles[_i22], + filename: files[_i22].upload.filename + }; + } + _this15._uploadData(files, dataBlocks); + } + }); + } + + /// Returns the right chunk for given file and xhr + + }, { + key: "_getChunk", + value: function _getChunk(file, xhr) { + for (var i = 0; i < file.upload.totalChunkCount; i++) { + if (file.upload.chunks[i] !== undefined && file.upload.chunks[i].xhr === xhr) { + return file.upload.chunks[i]; + } + } + } + + // This function actually uploads the file(s) to the server. + // If dataBlocks contains the actual data to upload (meaning, that this could either be transformed + // files, or individual chunks for chunked upload). + + }, { + key: "_uploadData", + value: function _uploadData(files, dataBlocks) { + var _this16 = this; + + var xhr = new XMLHttpRequest(); + + // Put the xhr object in the file objects to be able to reference it later. + for (var _iterator21 = files, _isArray21 = true, _i23 = 0, _iterator21 = _isArray21 ? _iterator21 : _iterator21[Symbol.iterator]();;) { + var _ref20; + + if (_isArray21) { + if (_i23 >= _iterator21.length) break; + _ref20 = _iterator21[_i23++]; + } else { + _i23 = _iterator21.next(); + if (_i23.done) break; + _ref20 = _i23.value; + } + + var file = _ref20; + + file.xhr = xhr; + } + if (files[0].upload.chunked) { + // Put the xhr object in the right chunk object, so it can be associated later, and found with _getChunk + files[0].upload.chunks[dataBlocks[0].chunkIndex].xhr = xhr; + } + + var method = this.resolveOption(this.options.method, files); + var url = this.resolveOption(this.options.url, files); + xhr.open(method, url, true); + + // Setting the timeout after open because of IE11 issue: https://gitlab.com/meno/dropzone/issues/8 + xhr.timeout = this.resolveOption(this.options.timeout, files); + + // Has to be after `.open()`. See https://github.com/enyo/dropzone/issues/179 + xhr.withCredentials = !!this.options.withCredentials; + + xhr.onload = function (e) { + _this16._finishedUploading(files, xhr, e); + }; + + xhr.onerror = function () { + _this16._handleUploadError(files, xhr); + }; + + // Some browsers do not have the .upload property + var progressObj = xhr.upload != null ? xhr.upload : xhr; + progressObj.onprogress = function (e) { + return _this16._updateFilesUploadProgress(files, xhr, e); + }; + + var headers = { + "Accept": "application/json", + "Cache-Control": "no-cache", + "X-Requested-With": "XMLHttpRequest" + }; + + if (this.options.headers) { + Dropzone.extend(headers, this.options.headers); + } + + for (var headerName in headers) { + var headerValue = headers[headerName]; + if (headerValue) { + xhr.setRequestHeader(headerName, headerValue); + } + } + + var formData = new FormData(); + + // Adding all @options parameters + if (this.options.params) { + var additionalParams = this.options.params; + if (typeof additionalParams === 'function') { + additionalParams = additionalParams.call(this, files, xhr, files[0].upload.chunked ? this._getChunk(files[0], xhr) : null); + } + + for (var key in additionalParams) { + var value = additionalParams[key]; + formData.append(key, value); + } + } + + // Let the user add additional data if necessary + for (var _iterator22 = files, _isArray22 = true, _i24 = 0, _iterator22 = _isArray22 ? _iterator22 : _iterator22[Symbol.iterator]();;) { + var _ref21; + + if (_isArray22) { + if (_i24 >= _iterator22.length) break; + _ref21 = _iterator22[_i24++]; + } else { + _i24 = _iterator22.next(); + if (_i24.done) break; + _ref21 = _i24.value; + } + + var _file = _ref21; + + this.emit("sending", _file, xhr, formData); + } + if (this.options.uploadMultiple) { + this.emit("sendingmultiple", files, xhr, formData); + } + + this._addFormElementData(formData); + + // Finally add the files + // Has to be last because some servers (eg: S3) expect the file to be the last parameter + for (var i = 0; i < dataBlocks.length; i++) { + var dataBlock = dataBlocks[i]; + formData.append(dataBlock.name, dataBlock.data, dataBlock.filename); + } + + this.submitRequest(xhr, formData, files); + } + + // Transforms all files with this.options.transformFile and invokes done with the transformed files when done. + + }, { + key: "_transformFiles", + value: function _transformFiles(files, done) { + var _this17 = this; + + var transformedFiles = []; + // Clumsy way of handling asynchronous calls, until I get to add a proper Future library. + var doneCounter = 0; + + var _loop = function _loop(i) { + _this17.options.transformFile.call(_this17, files[i], function (transformedFile) { + transformedFiles[i] = transformedFile; + if (++doneCounter === files.length) { + done(transformedFiles); + } + }); + }; + + for (var i = 0; i < files.length; i++) { + _loop(i); + } + } + + // Takes care of adding other input elements of the form to the AJAX request + + }, { + key: "_addFormElementData", + value: function _addFormElementData(formData) { + // Take care of other input elements + if (this.element.tagName === "FORM") { + for (var _iterator23 = this.element.querySelectorAll("input, textarea, select, button"), _isArray23 = true, _i25 = 0, _iterator23 = _isArray23 ? _iterator23 : _iterator23[Symbol.iterator]();;) { + var _ref22; + + if (_isArray23) { + if (_i25 >= _iterator23.length) break; + _ref22 = _iterator23[_i25++]; + } else { + _i25 = _iterator23.next(); + if (_i25.done) break; + _ref22 = _i25.value; + } + + var input = _ref22; + + var inputName = input.getAttribute("name"); + var inputType = input.getAttribute("type"); + if (inputType) inputType = inputType.toLowerCase(); + + // If the input doesn't have a name, we can't use it. + if (typeof inputName === 'undefined' || inputName === null) continue; + + if (input.tagName === "SELECT" && input.hasAttribute("multiple")) { + // Possibly multiple values + for (var _iterator24 = input.options, _isArray24 = true, _i26 = 0, _iterator24 = _isArray24 ? _iterator24 : _iterator24[Symbol.iterator]();;) { + var _ref23; + + if (_isArray24) { + if (_i26 >= _iterator24.length) break; + _ref23 = _iterator24[_i26++]; + } else { + _i26 = _iterator24.next(); + if (_i26.done) break; + _ref23 = _i26.value; + } + + var option = _ref23; + + if (option.selected) { + formData.append(inputName, option.value); + } + } + } else if (!inputType || inputType !== "checkbox" && inputType !== "radio" || input.checked) { + formData.append(inputName, input.value); + } + } + } + } + + // Invoked when there is new progress information about given files. + // If e is not provided, it is assumed that the upload is finished. + + }, { + key: "_updateFilesUploadProgress", + value: function _updateFilesUploadProgress(files, xhr, e) { + var progress = void 0; + if (typeof e !== 'undefined') { + progress = 100 * e.loaded / e.total; + + if (files[0].upload.chunked) { + var file = files[0]; + // Since this is a chunked upload, we need to update the appropriate chunk progress. + var chunk = this._getChunk(file, xhr); + chunk.progress = progress; + chunk.total = e.total; + chunk.bytesSent = e.loaded; + var fileProgress = 0, + fileTotal = void 0, + fileBytesSent = void 0; + file.upload.progress = 0; + file.upload.total = 0; + file.upload.bytesSent = 0; + for (var i = 0; i < file.upload.totalChunkCount; i++) { + if (file.upload.chunks[i] !== undefined && file.upload.chunks[i].progress !== undefined) { + file.upload.progress += file.upload.chunks[i].progress; + file.upload.total += file.upload.chunks[i].total; + file.upload.bytesSent += file.upload.chunks[i].bytesSent; + } + } + file.upload.progress = file.upload.progress / file.upload.totalChunkCount; + } else { + for (var _iterator25 = files, _isArray25 = true, _i27 = 0, _iterator25 = _isArray25 ? _iterator25 : _iterator25[Symbol.iterator]();;) { + var _ref24; + + if (_isArray25) { + if (_i27 >= _iterator25.length) break; + _ref24 = _iterator25[_i27++]; + } else { + _i27 = _iterator25.next(); + if (_i27.done) break; + _ref24 = _i27.value; + } + + var _file2 = _ref24; + + _file2.upload.progress = progress; + _file2.upload.total = e.total; + _file2.upload.bytesSent = e.loaded; + } + } + for (var _iterator26 = files, _isArray26 = true, _i28 = 0, _iterator26 = _isArray26 ? _iterator26 : _iterator26[Symbol.iterator]();;) { + var _ref25; + + if (_isArray26) { + if (_i28 >= _iterator26.length) break; + _ref25 = _iterator26[_i28++]; + } else { + _i28 = _iterator26.next(); + if (_i28.done) break; + _ref25 = _i28.value; + } + + var _file3 = _ref25; + + this.emit("uploadprogress", _file3, _file3.upload.progress, _file3.upload.bytesSent); + } + } else { + // Called when the file finished uploading + + var allFilesFinished = true; + + progress = 100; + + for (var _iterator27 = files, _isArray27 = true, _i29 = 0, _iterator27 = _isArray27 ? _iterator27 : _iterator27[Symbol.iterator]();;) { + var _ref26; + + if (_isArray27) { + if (_i29 >= _iterator27.length) break; + _ref26 = _iterator27[_i29++]; + } else { + _i29 = _iterator27.next(); + if (_i29.done) break; + _ref26 = _i29.value; + } + + var _file4 = _ref26; + + if (_file4.upload.progress !== 100 || _file4.upload.bytesSent !== _file4.upload.total) { + allFilesFinished = false; + } + _file4.upload.progress = progress; + _file4.upload.bytesSent = _file4.upload.total; + } + + // Nothing to do, all files already at 100% + if (allFilesFinished) { + return; + } + + for (var _iterator28 = files, _isArray28 = true, _i30 = 0, _iterator28 = _isArray28 ? _iterator28 : _iterator28[Symbol.iterator]();;) { + var _ref27; + + if (_isArray28) { + if (_i30 >= _iterator28.length) break; + _ref27 = _iterator28[_i30++]; + } else { + _i30 = _iterator28.next(); + if (_i30.done) break; + _ref27 = _i30.value; + } + + var _file5 = _ref27; + + this.emit("uploadprogress", _file5, progress, _file5.upload.bytesSent); + } + } + } + }, { + key: "_finishedUploading", + value: function _finishedUploading(files, xhr, e) { + var response = void 0; + + if (files[0].status === Dropzone.CANCELED) { + return; + } + + if (xhr.readyState !== 4) { + return; + } + + if (xhr.responseType !== 'arraybuffer' && xhr.responseType !== 'blob') { + response = xhr.responseText; + + if (xhr.getResponseHeader("content-type") && ~xhr.getResponseHeader("content-type").indexOf("application/json")) { + try { + response = JSON.parse(response); + } catch (error) { + e = error; + response = "Invalid JSON response from server."; + } + } + } + + this._updateFilesUploadProgress(files); + + if (!(200 <= xhr.status && xhr.status < 300)) { + this._handleUploadError(files, xhr, response); + } else { + if (files[0].upload.chunked) { + files[0].upload.finishedChunkUpload(this._getChunk(files[0], xhr)); + } else { + this._finished(files, response, e); + } + } + } + }, { + key: "_handleUploadError", + value: function _handleUploadError(files, xhr, response) { + if (files[0].status === Dropzone.CANCELED) { + return; + } + + if (files[0].upload.chunked && this.options.retryChunks) { + var chunk = this._getChunk(files[0], xhr); + if (chunk.retries++ < this.options.retryChunksLimit) { + this._uploadData(files, [chunk.dataBlock]); + return; + } else { + console.warn('Retried this chunk too often. Giving up.'); + } + } + + for (var _iterator29 = files, _isArray29 = true, _i31 = 0, _iterator29 = _isArray29 ? _iterator29 : _iterator29[Symbol.iterator]();;) { + var _ref28; + + if (_isArray29) { + if (_i31 >= _iterator29.length) break; + _ref28 = _iterator29[_i31++]; + } else { + _i31 = _iterator29.next(); + if (_i31.done) break; + _ref28 = _i31.value; + } + + var file = _ref28; + + this._errorProcessing(files, response || this.options.dictResponseError.replace("{{statusCode}}", xhr.status), xhr); + } + } + }, { + key: "submitRequest", + value: function submitRequest(xhr, formData, files) { + xhr.send(formData); + } + + // Called internally when processing is finished. + // Individual callbacks have to be called in the appropriate sections. + + }, { + key: "_finished", + value: function _finished(files, responseText, e) { + for (var _iterator30 = files, _isArray30 = true, _i32 = 0, _iterator30 = _isArray30 ? _iterator30 : _iterator30[Symbol.iterator]();;) { + var _ref29; + + if (_isArray30) { + if (_i32 >= _iterator30.length) break; + _ref29 = _iterator30[_i32++]; + } else { + _i32 = _iterator30.next(); + if (_i32.done) break; + _ref29 = _i32.value; + } + + var file = _ref29; + + file.status = Dropzone.SUCCESS; + this.emit("success", file, responseText, e); + this.emit("complete", file); + } + if (this.options.uploadMultiple) { + this.emit("successmultiple", files, responseText, e); + this.emit("completemultiple", files); + } + + if (this.options.autoProcessQueue) { + return this.processQueue(); + } + } + + // Called internally when processing is finished. + // Individual callbacks have to be called in the appropriate sections. + + }, { + key: "_errorProcessing", + value: function _errorProcessing(files, message, xhr) { + for (var _iterator31 = files, _isArray31 = true, _i33 = 0, _iterator31 = _isArray31 ? _iterator31 : _iterator31[Symbol.iterator]();;) { + var _ref30; + + if (_isArray31) { + if (_i33 >= _iterator31.length) break; + _ref30 = _iterator31[_i33++]; + } else { + _i33 = _iterator31.next(); + if (_i33.done) break; + _ref30 = _i33.value; + } + + var file = _ref30; + + file.status = Dropzone.ERROR; + this.emit("error", file, message, xhr); + this.emit("complete", file); + } + if (this.options.uploadMultiple) { + this.emit("errormultiple", files, message, xhr); + this.emit("completemultiple", files); + } + + if (this.options.autoProcessQueue) { + return this.processQueue(); + } + } + }], [{ + key: "uuidv4", + value: function uuidv4() { + return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) { + var r = Math.random() * 16 | 0, + v = c === 'x' ? r : r & 0x3 | 0x8; + return v.toString(16); + }); + } + }]); + + return Dropzone; +}(Emitter); + +Dropzone.initClass(); + +Dropzone.version = "5.2.0"; + +// This is a map of options for your different dropzones. Add configurations +// to this object for your different dropzone elemens. +// +// Example: +// +// Dropzone.options.myDropzoneElementId = { maxFilesize: 1 }; +// +// To disable autoDiscover for a specific element, you can set `false` as an option: +// +// Dropzone.options.myDisabledElementId = false; +// +// And in html: +// +//
+Dropzone.options = {}; + +// Returns the options for an element or undefined if none available. +Dropzone.optionsForElement = function (element) { + // Get the `Dropzone.options.elementId` for this element if it exists + if (element.getAttribute("id")) { + return Dropzone.options[camelize(element.getAttribute("id"))]; + } else { + return undefined; + } +}; + +// Holds a list of all dropzone instances +Dropzone.instances = []; + +// Returns the dropzone for given element if any +Dropzone.forElement = function (element) { + if (typeof element === "string") { + element = document.querySelector(element); + } + if ((element != null ? element.dropzone : undefined) == null) { + throw new Error("No Dropzone found for given element. This is probably because you're trying to access it before Dropzone had the time to initialize. Use the `init` option to setup any additional observers on your Dropzone."); + } + return element.dropzone; +}; + +// Set to false if you don't want Dropzone to automatically find and attach to .dropzone elements. +Dropzone.autoDiscover = true; + +// Looks for all .dropzone elements and creates a dropzone for them +Dropzone.discover = function () { + var dropzones = void 0; + if (document.querySelectorAll) { + dropzones = document.querySelectorAll(".dropzone"); + } else { + dropzones = []; + // IE :( + var checkElements = function checkElements(elements) { + return function () { + var result = []; + for (var _iterator32 = elements, _isArray32 = true, _i34 = 0, _iterator32 = _isArray32 ? _iterator32 : _iterator32[Symbol.iterator]();;) { + var _ref31; + + if (_isArray32) { + if (_i34 >= _iterator32.length) break; + _ref31 = _iterator32[_i34++]; + } else { + _i34 = _iterator32.next(); + if (_i34.done) break; + _ref31 = _i34.value; + } + + var el = _ref31; + + if (/(^| )dropzone($| )/.test(el.className)) { + result.push(dropzones.push(el)); + } else { + result.push(undefined); + } + } + return result; + }(); + }; + checkElements(document.getElementsByTagName("div")); + checkElements(document.getElementsByTagName("form")); + } + + return function () { + var result = []; + for (var _iterator33 = dropzones, _isArray33 = true, _i35 = 0, _iterator33 = _isArray33 ? _iterator33 : _iterator33[Symbol.iterator]();;) { + var _ref32; + + if (_isArray33) { + if (_i35 >= _iterator33.length) break; + _ref32 = _iterator33[_i35++]; + } else { + _i35 = _iterator33.next(); + if (_i35.done) break; + _ref32 = _i35.value; + } + + var dropzone = _ref32; + + // Create a dropzone unless auto discover has been disabled for specific element + if (Dropzone.optionsForElement(dropzone) !== false) { + result.push(new Dropzone(dropzone)); + } else { + result.push(undefined); + } + } + return result; + }(); +}; + +// Since the whole Drag'n'Drop API is pretty new, some browsers implement it, +// but not correctly. +// So I created a blacklist of userAgents. Yes, yes. Browser sniffing, I know. +// But what to do when browsers *theoretically* support an API, but crash +// when using it. +// +// This is a list of regular expressions tested against navigator.userAgent +// +// ** It should only be used on browser that *do* support the API, but +// incorrectly ** +// +Dropzone.blacklistedBrowsers = [ +// The mac os and windows phone version of opera 12 seems to have a problem with the File drag'n'drop API. +/opera.*(Macintosh|Windows Phone).*version\/12/i]; + +// Checks if the browser is supported +Dropzone.isBrowserSupported = function () { + var capableBrowser = true; + + if (window.File && window.FileReader && window.FileList && window.Blob && window.FormData && document.querySelector) { + if (!("classList" in document.createElement("a"))) { + capableBrowser = false; + } else { + // The browser supports the API, but may be blacklisted. + for (var _iterator34 = Dropzone.blacklistedBrowsers, _isArray34 = true, _i36 = 0, _iterator34 = _isArray34 ? _iterator34 : _iterator34[Symbol.iterator]();;) { + var _ref33; + + if (_isArray34) { + if (_i36 >= _iterator34.length) break; + _ref33 = _iterator34[_i36++]; + } else { + _i36 = _iterator34.next(); + if (_i36.done) break; + _ref33 = _i36.value; + } + + var regex = _ref33; + + if (regex.test(navigator.userAgent)) { + capableBrowser = false; + continue; + } + } + } + } else { + capableBrowser = false; + } + + return capableBrowser; +}; + +Dropzone.dataURItoBlob = function (dataURI) { + // convert base64 to raw binary data held in a string + // doesn't handle URLEncoded DataURIs - see SO answer #6850276 for code that does this + var byteString = atob(dataURI.split(',')[1]); + + // separate out the mime component + var mimeString = dataURI.split(',')[0].split(':')[1].split(';')[0]; + + // write the bytes of the string to an ArrayBuffer + var ab = new ArrayBuffer(byteString.length); + var ia = new Uint8Array(ab); + for (var i = 0, end = byteString.length, asc = 0 <= end; asc ? i <= end : i >= end; asc ? i++ : i--) { + ia[i] = byteString.charCodeAt(i); + } + + // write the ArrayBuffer to a blob + return new Blob([ab], { type: mimeString }); +}; + +// Returns an array without the rejected item +var without = function without(list, rejectedItem) { + return list.filter(function (item) { + return item !== rejectedItem; + }).map(function (item) { + return item; + }); +}; + +// abc-def_ghi -> abcDefGhi +var camelize = function camelize(str) { + return str.replace(/[\-_](\w)/g, function (match) { + return match.charAt(1).toUpperCase(); + }); +}; + +// Creates an element from string +Dropzone.createElement = function (string) { + var div = document.createElement("div"); + div.innerHTML = string; + return div.childNodes[0]; +}; + +// Tests if given element is inside (or simply is) the container +Dropzone.elementInside = function (element, container) { + if (element === container) { + return true; + } // Coffeescript doesn't support do/while loops + while (element = element.parentNode) { + if (element === container) { + return true; + } + } + return false; +}; + +Dropzone.getElement = function (el, name) { + var element = void 0; + if (typeof el === "string") { + element = document.querySelector(el); + } else if (el.nodeType != null) { + element = el; + } + if (element == null) { + throw new Error("Invalid `" + name + "` option provided. Please provide a CSS selector or a plain HTML element."); + } + return element; +}; + +Dropzone.getElements = function (els, name) { + var el = void 0, + elements = void 0; + if (els instanceof Array) { + elements = []; + try { + for (var _iterator35 = els, _isArray35 = true, _i37 = 0, _iterator35 = _isArray35 ? _iterator35 : _iterator35[Symbol.iterator]();;) { + if (_isArray35) { + if (_i37 >= _iterator35.length) break; + el = _iterator35[_i37++]; + } else { + _i37 = _iterator35.next(); + if (_i37.done) break; + el = _i37.value; + } + + elements.push(this.getElement(el, name)); + } + } catch (e) { + elements = null; + } + } else if (typeof els === "string") { + elements = []; + for (var _iterator36 = document.querySelectorAll(els), _isArray36 = true, _i38 = 0, _iterator36 = _isArray36 ? _iterator36 : _iterator36[Symbol.iterator]();;) { + if (_isArray36) { + if (_i38 >= _iterator36.length) break; + el = _iterator36[_i38++]; + } else { + _i38 = _iterator36.next(); + if (_i38.done) break; + el = _i38.value; + } + + elements.push(el); + } + } else if (els.nodeType != null) { + elements = [els]; + } + + if (elements == null || !elements.length) { + throw new Error("Invalid `" + name + "` option provided. Please provide a CSS selector, a plain HTML element or a list of those."); + } + + return elements; +}; + +// Asks the user the question and calls accepted or rejected accordingly +// +// The default implementation just uses `window.confirm` and then calls the +// appropriate callback. +Dropzone.confirm = function (question, accepted, rejected) { + if (window.confirm(question)) { + return accepted(); + } else if (rejected != null) { + return rejected(); + } +}; + +// Validates the mime type like this: +// +// https://developer.mozilla.org/en-US/docs/HTML/Element/input#attr-accept +Dropzone.isValidFile = function (file, acceptedFiles) { + if (!acceptedFiles) { + return true; + } // If there are no accepted mime types, it's OK + acceptedFiles = acceptedFiles.split(","); + + var mimeType = file.type; + var baseMimeType = mimeType.replace(/\/.*$/, ""); + + for (var _iterator37 = acceptedFiles, _isArray37 = true, _i39 = 0, _iterator37 = _isArray37 ? _iterator37 : _iterator37[Symbol.iterator]();;) { + var _ref34; + + if (_isArray37) { + if (_i39 >= _iterator37.length) break; + _ref34 = _iterator37[_i39++]; + } else { + _i39 = _iterator37.next(); + if (_i39.done) break; + _ref34 = _i39.value; + } + + var validType = _ref34; + + validType = validType.trim(); + if (validType.charAt(0) === ".") { + if (file.name.toLowerCase().indexOf(validType.toLowerCase(), file.name.length - validType.length) !== -1) { + return true; + } + } else if (/\/\*$/.test(validType)) { + // This is something like a image/* mime type + if (baseMimeType === validType.replace(/\/.*$/, "")) { + return true; + } + } else { + if (mimeType === validType) { + return true; + } + } + } + + return false; +}; + +// Augment jQuery +if (typeof jQuery !== 'undefined' && jQuery !== null) { + jQuery.fn.dropzone = function (options) { + return this.each(function () { + return new Dropzone(this, options); + }); + }; +} + +if (typeof module !== 'undefined' && module !== null) { + module.exports = Dropzone; +} else { + window.Dropzone = Dropzone; +} + +// Dropzone file status codes +Dropzone.ADDED = "added"; + +Dropzone.QUEUED = "queued"; +// For backwards compatibility. Now, if a file is accepted, it's either queued +// or uploading. +Dropzone.ACCEPTED = Dropzone.QUEUED; + +Dropzone.UPLOADING = "uploading"; +Dropzone.PROCESSING = Dropzone.UPLOADING; // alias + +Dropzone.CANCELED = "canceled"; +Dropzone.ERROR = "error"; +Dropzone.SUCCESS = "success"; + +/* + + Bugfix for iOS 6 and 7 + Source: http://stackoverflow.com/questions/11929099/html5-canvas-drawimage-ratio-bug-ios + based on the work of https://github.com/stomita/ios-imagefile-megapixel + + */ + +// Detecting vertical squash in loaded image. +// Fixes a bug which squash image vertically while drawing into canvas for some images. +// This is a bug in iOS6 devices. This function from https://github.com/stomita/ios-imagefile-megapixel +var detectVerticalSquash = function detectVerticalSquash(img) { + var iw = img.naturalWidth; + var ih = img.naturalHeight; + var canvas = document.createElement("canvas"); + canvas.width = 1; + canvas.height = ih; + var ctx = canvas.getContext("2d"); + ctx.drawImage(img, 0, 0); + + var _ctx$getImageData = ctx.getImageData(1, 0, 1, ih), + data = _ctx$getImageData.data; + + // search image edge pixel position in case it is squashed vertically. + + + var sy = 0; + var ey = ih; + var py = ih; + while (py > sy) { + var alpha = data[(py - 1) * 4 + 3]; + + if (alpha === 0) { + ey = py; + } else { + sy = py; + } + + py = ey + sy >> 1; + } + var ratio = py / ih; + + if (ratio === 0) { + return 1; + } else { + return ratio; + } +}; + +// A replacement for context.drawImage +// (args are for source and destination). +var drawImageIOSFix = function drawImageIOSFix(ctx, img, sx, sy, sw, sh, dx, dy, dw, dh) { + var vertSquashRatio = detectVerticalSquash(img); + return ctx.drawImage(img, sx, sy, sw, sh, dx, dy, dw, dh / vertSquashRatio); +}; + +// Based on MinifyJpeg +// Source: http://www.perry.cz/files/ExifRestorer.js +// http://elicon.blog57.fc2.com/blog-entry-206.html + +var ExifRestore = function () { + function ExifRestore() { + _classCallCheck(this, ExifRestore); + } + + _createClass(ExifRestore, null, [{ + key: "initClass", + value: function initClass() { + this.KEY_STR = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='; + } + }, { + key: "encode64", + value: function encode64(input) { + var output = ''; + var chr1 = undefined; + var chr2 = undefined; + var chr3 = ''; + var enc1 = undefined; + var enc2 = undefined; + var enc3 = undefined; + var enc4 = ''; + var i = 0; + while (true) { + chr1 = input[i++]; + chr2 = input[i++]; + chr3 = input[i++]; + enc1 = chr1 >> 2; + enc2 = (chr1 & 3) << 4 | chr2 >> 4; + enc3 = (chr2 & 15) << 2 | chr3 >> 6; + enc4 = chr3 & 63; + if (isNaN(chr2)) { + enc3 = enc4 = 64; + } else if (isNaN(chr3)) { + enc4 = 64; + } + output = output + this.KEY_STR.charAt(enc1) + this.KEY_STR.charAt(enc2) + this.KEY_STR.charAt(enc3) + this.KEY_STR.charAt(enc4); + chr1 = chr2 = chr3 = ''; + enc1 = enc2 = enc3 = enc4 = ''; + if (!(i < input.length)) { + break; + } + } + return output; + } + }, { + key: "restore", + value: function restore(origFileBase64, resizedFileBase64) { + if (!origFileBase64.match('data:image/jpeg;base64,')) { + return resizedFileBase64; + } + var rawImage = this.decode64(origFileBase64.replace('data:image/jpeg;base64,', '')); + var segments = this.slice2Segments(rawImage); + var image = this.exifManipulation(resizedFileBase64, segments); + return "data:image/jpeg;base64," + this.encode64(image); + } + }, { + key: "exifManipulation", + value: function exifManipulation(resizedFileBase64, segments) { + var exifArray = this.getExifArray(segments); + var newImageArray = this.insertExif(resizedFileBase64, exifArray); + var aBuffer = new Uint8Array(newImageArray); + return aBuffer; + } + }, { + key: "getExifArray", + value: function getExifArray(segments) { + var seg = undefined; + var x = 0; + while (x < segments.length) { + seg = segments[x]; + if (seg[0] === 255 & seg[1] === 225) { + return seg; + } + x++; + } + return []; + } + }, { + key: "insertExif", + value: function insertExif(resizedFileBase64, exifArray) { + var imageData = resizedFileBase64.replace('data:image/jpeg;base64,', ''); + var buf = this.decode64(imageData); + var separatePoint = buf.indexOf(255, 3); + var mae = buf.slice(0, separatePoint); + var ato = buf.slice(separatePoint); + var array = mae; + array = array.concat(exifArray); + array = array.concat(ato); + return array; + } + }, { + key: "slice2Segments", + value: function slice2Segments(rawImageArray) { + var head = 0; + var segments = []; + while (true) { + var length; + if (rawImageArray[head] === 255 & rawImageArray[head + 1] === 218) { + break; + } + if (rawImageArray[head] === 255 & rawImageArray[head + 1] === 216) { + head += 2; + } else { + length = rawImageArray[head + 2] * 256 + rawImageArray[head + 3]; + var endPoint = head + length + 2; + var seg = rawImageArray.slice(head, endPoint); + segments.push(seg); + head = endPoint; + } + if (head > rawImageArray.length) { + break; + } + } + return segments; + } + }, { + key: "decode64", + value: function decode64(input) { + var output = ''; + var chr1 = undefined; + var chr2 = undefined; + var chr3 = ''; + var enc1 = undefined; + var enc2 = undefined; + var enc3 = undefined; + var enc4 = ''; + var i = 0; + var buf = []; + // remove all characters that are not A-Z, a-z, 0-9, +, /, or = + var base64test = /[^A-Za-z0-9\+\/\=]/g; + if (base64test.exec(input)) { + console.warn('There were invalid base64 characters in the input text.\nValid base64 characters are A-Z, a-z, 0-9, \'+\', \'/\',and \'=\'\nExpect errors in decoding.'); + } + input = input.replace(/[^A-Za-z0-9\+\/\=]/g, ''); + while (true) { + enc1 = this.KEY_STR.indexOf(input.charAt(i++)); + enc2 = this.KEY_STR.indexOf(input.charAt(i++)); + enc3 = this.KEY_STR.indexOf(input.charAt(i++)); + enc4 = this.KEY_STR.indexOf(input.charAt(i++)); + chr1 = enc1 << 2 | enc2 >> 4; + chr2 = (enc2 & 15) << 4 | enc3 >> 2; + chr3 = (enc3 & 3) << 6 | enc4; + buf.push(chr1); + if (enc3 !== 64) { + buf.push(chr2); + } + if (enc4 !== 64) { + buf.push(chr3); + } + chr1 = chr2 = chr3 = ''; + enc1 = enc2 = enc3 = enc4 = ''; + if (!(i < input.length)) { + break; + } + } + return buf; + } + }]); + + return ExifRestore; +}(); + +ExifRestore.initClass(); + +/* + * contentloaded.js + * + * Author: Diego Perini (diego.perini at gmail.com) + * Summary: cross-browser wrapper for DOMContentLoaded + * Updated: 20101020 + * License: MIT + * Version: 1.2 + * + * URL: + * http://javascript.nwbox.com/ContentLoaded/ + * http://javascript.nwbox.com/ContentLoaded/MIT-LICENSE + */ + +// @win window reference +// @fn function reference +var contentLoaded = function contentLoaded(win, fn) { + var done = false; + var top = true; + var doc = win.document; + var root = doc.documentElement; + var add = doc.addEventListener ? "addEventListener" : "attachEvent"; + var rem = doc.addEventListener ? "removeEventListener" : "detachEvent"; + var pre = doc.addEventListener ? "" : "on"; + var init = function init(e) { + if (e.type === "readystatechange" && doc.readyState !== "complete") { + return; + } + (e.type === "load" ? win : doc)[rem](pre + e.type, init, false); + if (!done && (done = true)) { + return fn.call(win, e.type || e); + } + }; + + var poll = function poll() { + try { + root.doScroll("left"); + } catch (e) { + setTimeout(poll, 50); + return; + } + return init("poll"); + }; + + if (doc.readyState !== "complete") { + if (doc.createEventObject && root.doScroll) { + try { + top = !win.frameElement; + } catch (error) {} + if (top) { + poll(); + } + } + doc[add](pre + "DOMContentLoaded", init, false); + doc[add](pre + "readystatechange", init, false); + return win[add](pre + "load", init, false); + } +}; + +// As a single function to be able to write tests. +Dropzone._autoDiscoverFunction = function () { + if (Dropzone.autoDiscover) { + return Dropzone.discover(); + } +}; +contentLoaded(window, Dropzone._autoDiscoverFunction); + +function __guard__(value, transform) { + return typeof value !== 'undefined' && value !== null ? transform(value) : undefined; +} +function __guardMethod__(obj, methodName, transform) { + if (typeof obj !== 'undefined' && obj !== null && typeof obj[methodName] === 'function') { + return transform(obj, methodName); + } else { + return undefined; + } +} diff --git a/lib/jquery.js b/lib/jquery.js index da4170647d..e836475870 100644 --- a/lib/jquery.js +++ b/lib/jquery.js @@ -1,6 +1,5 @@ -/*! jQuery v1.10.2 | (c) 2005, 2013 jQuery Foundation, Inc. | jquery.org/license -//@ sourceMappingURL=jquery-1.10.2.min.map -*/ -(function(e,t){var n,r,i=typeof t,o=e.location,a=e.document,s=a.documentElement,l=e.jQuery,u=e.$,c={},p=[],f="1.10.2",d=p.concat,h=p.push,g=p.slice,m=p.indexOf,y=c.toString,v=c.hasOwnProperty,b=f.trim,x=function(e,t){return new x.fn.init(e,t,r)},w=/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source,T=/\S+/g,C=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,N=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,k=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,E=/^[\],:{}\s]*$/,S=/(?:^|:|,)(?:\s*\[)+/g,A=/\\(?:["\\\/bfnrt]|u[\da-fA-F]{4})/g,j=/"[^"\\\r\n]*"|true|false|null|-?(?:\d+\.|)\d+(?:[eE][+-]?\d+|)/g,D=/^-ms-/,L=/-([\da-z])/gi,H=function(e,t){return t.toUpperCase()},q=function(e){(a.addEventListener||"load"===e.type||"complete"===a.readyState)&&(_(),x.ready())},_=function(){a.addEventListener?(a.removeEventListener("DOMContentLoaded",q,!1),e.removeEventListener("load",q,!1)):(a.detachEvent("onreadystatechange",q),e.detachEvent("onload",q))};x.fn=x.prototype={jquery:f,constructor:x,init:function(e,n,r){var i,o;if(!e)return this;if("string"==typeof e){if(i="<"===e.charAt(0)&&">"===e.charAt(e.length-1)&&e.length>=3?[null,e,null]:N.exec(e),!i||!i[1]&&n)return!n||n.jquery?(n||r).find(e):this.constructor(n).find(e);if(i[1]){if(n=n instanceof x?n[0]:n,x.merge(this,x.parseHTML(i[1],n&&n.nodeType?n.ownerDocument||n:a,!0)),k.test(i[1])&&x.isPlainObject(n))for(i in n)x.isFunction(this[i])?this[i](n[i]):this.attr(i,n[i]);return this}if(o=a.getElementById(i[2]),o&&o.parentNode){if(o.id!==i[2])return r.find(e);this.length=1,this[0]=o}return this.context=a,this.selector=e,this}return e.nodeType?(this.context=this[0]=e,this.length=1,this):x.isFunction(e)?r.ready(e):(e.selector!==t&&(this.selector=e.selector,this.context=e.context),x.makeArray(e,this))},selector:"",length:0,toArray:function(){return g.call(this)},get:function(e){return null==e?this.toArray():0>e?this[this.length+e]:this[e]},pushStack:function(e){var t=x.merge(this.constructor(),e);return t.prevObject=this,t.context=this.context,t},each:function(e,t){return x.each(this,e,t)},ready:function(e){return x.ready.promise().done(e),this},slice:function(){return this.pushStack(g.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(e){var t=this.length,n=+e+(0>e?t:0);return this.pushStack(n>=0&&t>n?[this[n]]:[])},map:function(e){return this.pushStack(x.map(this,function(t,n){return e.call(t,n,t)}))},end:function(){return this.prevObject||this.constructor(null)},push:h,sort:[].sort,splice:[].splice},x.fn.init.prototype=x.fn,x.extend=x.fn.extend=function(){var e,n,r,i,o,a,s=arguments[0]||{},l=1,u=arguments.length,c=!1;for("boolean"==typeof s&&(c=s,s=arguments[1]||{},l=2),"object"==typeof s||x.isFunction(s)||(s={}),u===l&&(s=this,--l);u>l;l++)if(null!=(o=arguments[l]))for(i in o)e=s[i],r=o[i],s!==r&&(c&&r&&(x.isPlainObject(r)||(n=x.isArray(r)))?(n?(n=!1,a=e&&x.isArray(e)?e:[]):a=e&&x.isPlainObject(e)?e:{},s[i]=x.extend(c,a,r)):r!==t&&(s[i]=r));return s},x.extend({expando:"jQuery"+(f+Math.random()).replace(/\D/g,""),noConflict:function(t){return e.$===x&&(e.$=u),t&&e.jQuery===x&&(e.jQuery=l),x},isReady:!1,readyWait:1,holdReady:function(e){e?x.readyWait++:x.ready(!0)},ready:function(e){if(e===!0?!--x.readyWait:!x.isReady){if(!a.body)return setTimeout(x.ready);x.isReady=!0,e!==!0&&--x.readyWait>0||(n.resolveWith(a,[x]),x.fn.trigger&&x(a).trigger("ready").off("ready"))}},isFunction:function(e){return"function"===x.type(e)},isArray:Array.isArray||function(e){return"array"===x.type(e)},isWindow:function(e){return null!=e&&e==e.window},isNumeric:function(e){return!isNaN(parseFloat(e))&&isFinite(e)},type:function(e){return null==e?e+"":"object"==typeof e||"function"==typeof e?c[y.call(e)]||"object":typeof e},isPlainObject:function(e){var n;if(!e||"object"!==x.type(e)||e.nodeType||x.isWindow(e))return!1;try{if(e.constructor&&!v.call(e,"constructor")&&!v.call(e.constructor.prototype,"isPrototypeOf"))return!1}catch(r){return!1}if(x.support.ownLast)for(n in e)return v.call(e,n);for(n in e);return n===t||v.call(e,n)},isEmptyObject:function(e){var t;for(t in e)return!1;return!0},error:function(e){throw Error(e)},parseHTML:function(e,t,n){if(!e||"string"!=typeof e)return null;"boolean"==typeof t&&(n=t,t=!1),t=t||a;var r=k.exec(e),i=!n&&[];return r?[t.createElement(r[1])]:(r=x.buildFragment([e],t,i),i&&x(i).remove(),x.merge([],r.childNodes))},parseJSON:function(n){return e.JSON&&e.JSON.parse?e.JSON.parse(n):null===n?n:"string"==typeof n&&(n=x.trim(n),n&&E.test(n.replace(A,"@").replace(j,"]").replace(S,"")))?Function("return "+n)():(x.error("Invalid JSON: "+n),t)},parseXML:function(n){var r,i;if(!n||"string"!=typeof n)return null;try{e.DOMParser?(i=new DOMParser,r=i.parseFromString(n,"text/xml")):(r=new ActiveXObject("Microsoft.XMLDOM"),r.async="false",r.loadXML(n))}catch(o){r=t}return r&&r.documentElement&&!r.getElementsByTagName("parsererror").length||x.error("Invalid XML: "+n),r},noop:function(){},globalEval:function(t){t&&x.trim(t)&&(e.execScript||function(t){e.eval.call(e,t)})(t)},camelCase:function(e){return e.replace(D,"ms-").replace(L,H)},nodeName:function(e,t){return e.nodeName&&e.nodeName.toLowerCase()===t.toLowerCase()},each:function(e,t,n){var r,i=0,o=e.length,a=M(e);if(n){if(a){for(;o>i;i++)if(r=t.apply(e[i],n),r===!1)break}else for(i in e)if(r=t.apply(e[i],n),r===!1)break}else if(a){for(;o>i;i++)if(r=t.call(e[i],i,e[i]),r===!1)break}else for(i in e)if(r=t.call(e[i],i,e[i]),r===!1)break;return e},trim:b&&!b.call("\ufeff\u00a0")?function(e){return null==e?"":b.call(e)}:function(e){return null==e?"":(e+"").replace(C,"")},makeArray:function(e,t){var n=t||[];return null!=e&&(M(Object(e))?x.merge(n,"string"==typeof e?[e]:e):h.call(n,e)),n},inArray:function(e,t,n){var r;if(t){if(m)return m.call(t,e,n);for(r=t.length,n=n?0>n?Math.max(0,r+n):n:0;r>n;n++)if(n in t&&t[n]===e)return n}return-1},merge:function(e,n){var r=n.length,i=e.length,o=0;if("number"==typeof r)for(;r>o;o++)e[i++]=n[o];else while(n[o]!==t)e[i++]=n[o++];return e.length=i,e},grep:function(e,t,n){var r,i=[],o=0,a=e.length;for(n=!!n;a>o;o++)r=!!t(e[o],o),n!==r&&i.push(e[o]);return i},map:function(e,t,n){var r,i=0,o=e.length,a=M(e),s=[];if(a)for(;o>i;i++)r=t(e[i],i,n),null!=r&&(s[s.length]=r);else for(i in e)r=t(e[i],i,n),null!=r&&(s[s.length]=r);return d.apply([],s)},guid:1,proxy:function(e,n){var r,i,o;return"string"==typeof n&&(o=e[n],n=e,e=o),x.isFunction(e)?(r=g.call(arguments,2),i=function(){return e.apply(n||this,r.concat(g.call(arguments)))},i.guid=e.guid=e.guid||x.guid++,i):t},access:function(e,n,r,i,o,a,s){var l=0,u=e.length,c=null==r;if("object"===x.type(r)){o=!0;for(l in r)x.access(e,n,l,r[l],!0,a,s)}else if(i!==t&&(o=!0,x.isFunction(i)||(s=!0),c&&(s?(n.call(e,i),n=null):(c=n,n=function(e,t,n){return c.call(x(e),n)})),n))for(;u>l;l++)n(e[l],r,s?i:i.call(e[l],l,n(e[l],r)));return o?e:c?n.call(e):u?n(e[0],r):a},now:function(){return(new Date).getTime()},swap:function(e,t,n,r){var i,o,a={};for(o in t)a[o]=e.style[o],e.style[o]=t[o];i=n.apply(e,r||[]);for(o in t)e.style[o]=a[o];return i}}),x.ready.promise=function(t){if(!n)if(n=x.Deferred(),"complete"===a.readyState)setTimeout(x.ready);else if(a.addEventListener)a.addEventListener("DOMContentLoaded",q,!1),e.addEventListener("load",q,!1);else{a.attachEvent("onreadystatechange",q),e.attachEvent("onload",q);var r=!1;try{r=null==e.frameElement&&a.documentElement}catch(i){}r&&r.doScroll&&function o(){if(!x.isReady){try{r.doScroll("left")}catch(e){return setTimeout(o,50)}_(),x.ready()}}()}return n.promise(t)},x.each("Boolean Number String Function Array Date RegExp Object Error".split(" "),function(e,t){c["[object "+t+"]"]=t.toLowerCase()});function M(e){var t=e.length,n=x.type(e);return x.isWindow(e)?!1:1===e.nodeType&&t?!0:"array"===n||"function"!==n&&(0===t||"number"==typeof t&&t>0&&t-1 in e)}r=x(a),function(e,t){var n,r,i,o,a,s,l,u,c,p,f,d,h,g,m,y,v,b="sizzle"+-new Date,w=e.document,T=0,C=0,N=st(),k=st(),E=st(),S=!1,A=function(e,t){return e===t?(S=!0,0):0},j=typeof t,D=1<<31,L={}.hasOwnProperty,H=[],q=H.pop,_=H.push,M=H.push,O=H.slice,F=H.indexOf||function(e){var t=0,n=this.length;for(;n>t;t++)if(this[t]===e)return t;return-1},B="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",P="[\\x20\\t\\r\\n\\f]",R="(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",W=R.replace("w","w#"),$="\\["+P+"*("+R+")"+P+"*(?:([*^$|!~]?=)"+P+"*(?:(['\"])((?:\\\\.|[^\\\\])*?)\\3|("+W+")|)|)"+P+"*\\]",I=":("+R+")(?:\\(((['\"])((?:\\\\.|[^\\\\])*?)\\3|((?:\\\\.|[^\\\\()[\\]]|"+$.replace(3,8)+")*)|.*)\\)|)",z=RegExp("^"+P+"+|((?:^|[^\\\\])(?:\\\\.)*)"+P+"+$","g"),X=RegExp("^"+P+"*,"+P+"*"),U=RegExp("^"+P+"*([>+~]|"+P+")"+P+"*"),V=RegExp(P+"*[+~]"),Y=RegExp("="+P+"*([^\\]'\"]*)"+P+"*\\]","g"),J=RegExp(I),G=RegExp("^"+W+"$"),Q={ID:RegExp("^#("+R+")"),CLASS:RegExp("^\\.("+R+")"),TAG:RegExp("^("+R.replace("w","w*")+")"),ATTR:RegExp("^"+$),PSEUDO:RegExp("^"+I),CHILD:RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+P+"*(even|odd|(([+-]|)(\\d*)n|)"+P+"*(?:([+-]|)"+P+"*(\\d+)|))"+P+"*\\)|)","i"),bool:RegExp("^(?:"+B+")$","i"),needsContext:RegExp("^"+P+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+P+"*((?:-\\d)?\\d*)"+P+"*\\)|)(?=[^-]|$)","i")},K=/^[^{]+\{\s*\[native \w/,Z=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,et=/^(?:input|select|textarea|button)$/i,tt=/^h\d$/i,nt=/'|\\/g,rt=RegExp("\\\\([\\da-f]{1,6}"+P+"?|("+P+")|.)","ig"),it=function(e,t,n){var r="0x"+t-65536;return r!==r||n?t:0>r?String.fromCharCode(r+65536):String.fromCharCode(55296|r>>10,56320|1023&r)};try{M.apply(H=O.call(w.childNodes),w.childNodes),H[w.childNodes.length].nodeType}catch(ot){M={apply:H.length?function(e,t){_.apply(e,O.call(t))}:function(e,t){var n=e.length,r=0;while(e[n++]=t[r++]);e.length=n-1}}}function at(e,t,n,i){var o,a,s,l,u,c,d,m,y,x;if((t?t.ownerDocument||t:w)!==f&&p(t),t=t||f,n=n||[],!e||"string"!=typeof e)return n;if(1!==(l=t.nodeType)&&9!==l)return[];if(h&&!i){if(o=Z.exec(e))if(s=o[1]){if(9===l){if(a=t.getElementById(s),!a||!a.parentNode)return n;if(a.id===s)return n.push(a),n}else if(t.ownerDocument&&(a=t.ownerDocument.getElementById(s))&&v(t,a)&&a.id===s)return n.push(a),n}else{if(o[2])return M.apply(n,t.getElementsByTagName(e)),n;if((s=o[3])&&r.getElementsByClassName&&t.getElementsByClassName)return M.apply(n,t.getElementsByClassName(s)),n}if(r.qsa&&(!g||!g.test(e))){if(m=d=b,y=t,x=9===l&&e,1===l&&"object"!==t.nodeName.toLowerCase()){c=mt(e),(d=t.getAttribute("id"))?m=d.replace(nt,"\\$&"):t.setAttribute("id",m),m="[id='"+m+"'] ",u=c.length;while(u--)c[u]=m+yt(c[u]);y=V.test(e)&&t.parentNode||t,x=c.join(",")}if(x)try{return M.apply(n,y.querySelectorAll(x)),n}catch(T){}finally{d||t.removeAttribute("id")}}}return kt(e.replace(z,"$1"),t,n,i)}function st(){var e=[];function t(n,r){return e.push(n+=" ")>o.cacheLength&&delete t[e.shift()],t[n]=r}return t}function lt(e){return e[b]=!0,e}function ut(e){var t=f.createElement("div");try{return!!e(t)}catch(n){return!1}finally{t.parentNode&&t.parentNode.removeChild(t),t=null}}function ct(e,t){var n=e.split("|"),r=e.length;while(r--)o.attrHandle[n[r]]=t}function pt(e,t){var n=t&&e,r=n&&1===e.nodeType&&1===t.nodeType&&(~t.sourceIndex||D)-(~e.sourceIndex||D);if(r)return r;if(n)while(n=n.nextSibling)if(n===t)return-1;return e?1:-1}function ft(e){return function(t){var n=t.nodeName.toLowerCase();return"input"===n&&t.type===e}}function dt(e){return function(t){var n=t.nodeName.toLowerCase();return("input"===n||"button"===n)&&t.type===e}}function ht(e){return lt(function(t){return t=+t,lt(function(n,r){var i,o=e([],n.length,t),a=o.length;while(a--)n[i=o[a]]&&(n[i]=!(r[i]=n[i]))})})}s=at.isXML=function(e){var t=e&&(e.ownerDocument||e).documentElement;return t?"HTML"!==t.nodeName:!1},r=at.support={},p=at.setDocument=function(e){var n=e?e.ownerDocument||e:w,i=n.defaultView;return n!==f&&9===n.nodeType&&n.documentElement?(f=n,d=n.documentElement,h=!s(n),i&&i.attachEvent&&i!==i.top&&i.attachEvent("onbeforeunload",function(){p()}),r.attributes=ut(function(e){return e.className="i",!e.getAttribute("className")}),r.getElementsByTagName=ut(function(e){return e.appendChild(n.createComment("")),!e.getElementsByTagName("*").length}),r.getElementsByClassName=ut(function(e){return e.innerHTML="
",e.firstChild.className="i",2===e.getElementsByClassName("i").length}),r.getById=ut(function(e){return d.appendChild(e).id=b,!n.getElementsByName||!n.getElementsByName(b).length}),r.getById?(o.find.ID=function(e,t){if(typeof t.getElementById!==j&&h){var n=t.getElementById(e);return n&&n.parentNode?[n]:[]}},o.filter.ID=function(e){var t=e.replace(rt,it);return function(e){return e.getAttribute("id")===t}}):(delete o.find.ID,o.filter.ID=function(e){var t=e.replace(rt,it);return function(e){var n=typeof e.getAttributeNode!==j&&e.getAttributeNode("id");return n&&n.value===t}}),o.find.TAG=r.getElementsByTagName?function(e,n){return typeof n.getElementsByTagName!==j?n.getElementsByTagName(e):t}:function(e,t){var n,r=[],i=0,o=t.getElementsByTagName(e);if("*"===e){while(n=o[i++])1===n.nodeType&&r.push(n);return r}return o},o.find.CLASS=r.getElementsByClassName&&function(e,n){return typeof n.getElementsByClassName!==j&&h?n.getElementsByClassName(e):t},m=[],g=[],(r.qsa=K.test(n.querySelectorAll))&&(ut(function(e){e.innerHTML="",e.querySelectorAll("[selected]").length||g.push("\\["+P+"*(?:value|"+B+")"),e.querySelectorAll(":checked").length||g.push(":checked")}),ut(function(e){var t=n.createElement("input");t.setAttribute("type","hidden"),e.appendChild(t).setAttribute("t",""),e.querySelectorAll("[t^='']").length&&g.push("[*^$]="+P+"*(?:''|\"\")"),e.querySelectorAll(":enabled").length||g.push(":enabled",":disabled"),e.querySelectorAll("*,:x"),g.push(",.*:")})),(r.matchesSelector=K.test(y=d.webkitMatchesSelector||d.mozMatchesSelector||d.oMatchesSelector||d.msMatchesSelector))&&ut(function(e){r.disconnectedMatch=y.call(e,"div"),y.call(e,"[s!='']:x"),m.push("!=",I)}),g=g.length&&RegExp(g.join("|")),m=m.length&&RegExp(m.join("|")),v=K.test(d.contains)||d.compareDocumentPosition?function(e,t){var n=9===e.nodeType?e.documentElement:e,r=t&&t.parentNode;return e===r||!(!r||1!==r.nodeType||!(n.contains?n.contains(r):e.compareDocumentPosition&&16&e.compareDocumentPosition(r)))}:function(e,t){if(t)while(t=t.parentNode)if(t===e)return!0;return!1},A=d.compareDocumentPosition?function(e,t){if(e===t)return S=!0,0;var i=t.compareDocumentPosition&&e.compareDocumentPosition&&e.compareDocumentPosition(t);return i?1&i||!r.sortDetached&&t.compareDocumentPosition(e)===i?e===n||v(w,e)?-1:t===n||v(w,t)?1:c?F.call(c,e)-F.call(c,t):0:4&i?-1:1:e.compareDocumentPosition?-1:1}:function(e,t){var r,i=0,o=e.parentNode,a=t.parentNode,s=[e],l=[t];if(e===t)return S=!0,0;if(!o||!a)return e===n?-1:t===n?1:o?-1:a?1:c?F.call(c,e)-F.call(c,t):0;if(o===a)return pt(e,t);r=e;while(r=r.parentNode)s.unshift(r);r=t;while(r=r.parentNode)l.unshift(r);while(s[i]===l[i])i++;return i?pt(s[i],l[i]):s[i]===w?-1:l[i]===w?1:0},n):f},at.matches=function(e,t){return at(e,null,null,t)},at.matchesSelector=function(e,t){if((e.ownerDocument||e)!==f&&p(e),t=t.replace(Y,"='$1']"),!(!r.matchesSelector||!h||m&&m.test(t)||g&&g.test(t)))try{var n=y.call(e,t);if(n||r.disconnectedMatch||e.document&&11!==e.document.nodeType)return n}catch(i){}return at(t,f,null,[e]).length>0},at.contains=function(e,t){return(e.ownerDocument||e)!==f&&p(e),v(e,t)},at.attr=function(e,n){(e.ownerDocument||e)!==f&&p(e);var i=o.attrHandle[n.toLowerCase()],a=i&&L.call(o.attrHandle,n.toLowerCase())?i(e,n,!h):t;return a===t?r.attributes||!h?e.getAttribute(n):(a=e.getAttributeNode(n))&&a.specified?a.value:null:a},at.error=function(e){throw Error("Syntax error, unrecognized expression: "+e)},at.uniqueSort=function(e){var t,n=[],i=0,o=0;if(S=!r.detectDuplicates,c=!r.sortStable&&e.slice(0),e.sort(A),S){while(t=e[o++])t===e[o]&&(i=n.push(o));while(i--)e.splice(n[i],1)}return e},a=at.getText=function(e){var t,n="",r=0,i=e.nodeType;if(i){if(1===i||9===i||11===i){if("string"==typeof e.textContent)return e.textContent;for(e=e.firstChild;e;e=e.nextSibling)n+=a(e)}else if(3===i||4===i)return e.nodeValue}else for(;t=e[r];r++)n+=a(t);return n},o=at.selectors={cacheLength:50,createPseudo:lt,match:Q,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(e){return e[1]=e[1].replace(rt,it),e[3]=(e[4]||e[5]||"").replace(rt,it),"~="===e[2]&&(e[3]=" "+e[3]+" "),e.slice(0,4)},CHILD:function(e){return e[1]=e[1].toLowerCase(),"nth"===e[1].slice(0,3)?(e[3]||at.error(e[0]),e[4]=+(e[4]?e[5]+(e[6]||1):2*("even"===e[3]||"odd"===e[3])),e[5]=+(e[7]+e[8]||"odd"===e[3])):e[3]&&at.error(e[0]),e},PSEUDO:function(e){var n,r=!e[5]&&e[2];return Q.CHILD.test(e[0])?null:(e[3]&&e[4]!==t?e[2]=e[4]:r&&J.test(r)&&(n=mt(r,!0))&&(n=r.indexOf(")",r.length-n)-r.length)&&(e[0]=e[0].slice(0,n),e[2]=r.slice(0,n)),e.slice(0,3))}},filter:{TAG:function(e){var t=e.replace(rt,it).toLowerCase();return"*"===e?function(){return!0}:function(e){return e.nodeName&&e.nodeName.toLowerCase()===t}},CLASS:function(e){var t=N[e+" "];return t||(t=RegExp("(^|"+P+")"+e+"("+P+"|$)"))&&N(e,function(e){return t.test("string"==typeof e.className&&e.className||typeof e.getAttribute!==j&&e.getAttribute("class")||"")})},ATTR:function(e,t,n){return function(r){var i=at.attr(r,e);return null==i?"!="===t:t?(i+="","="===t?i===n:"!="===t?i!==n:"^="===t?n&&0===i.indexOf(n):"*="===t?n&&i.indexOf(n)>-1:"$="===t?n&&i.slice(-n.length)===n:"~="===t?(" "+i+" ").indexOf(n)>-1:"|="===t?i===n||i.slice(0,n.length+1)===n+"-":!1):!0}},CHILD:function(e,t,n,r,i){var o="nth"!==e.slice(0,3),a="last"!==e.slice(-4),s="of-type"===t;return 1===r&&0===i?function(e){return!!e.parentNode}:function(t,n,l){var u,c,p,f,d,h,g=o!==a?"nextSibling":"previousSibling",m=t.parentNode,y=s&&t.nodeName.toLowerCase(),v=!l&&!s;if(m){if(o){while(g){p=t;while(p=p[g])if(s?p.nodeName.toLowerCase()===y:1===p.nodeType)return!1;h=g="only"===e&&!h&&"nextSibling"}return!0}if(h=[a?m.firstChild:m.lastChild],a&&v){c=m[b]||(m[b]={}),u=c[e]||[],d=u[0]===T&&u[1],f=u[0]===T&&u[2],p=d&&m.childNodes[d];while(p=++d&&p&&p[g]||(f=d=0)||h.pop())if(1===p.nodeType&&++f&&p===t){c[e]=[T,d,f];break}}else if(v&&(u=(t[b]||(t[b]={}))[e])&&u[0]===T)f=u[1];else while(p=++d&&p&&p[g]||(f=d=0)||h.pop())if((s?p.nodeName.toLowerCase()===y:1===p.nodeType)&&++f&&(v&&((p[b]||(p[b]={}))[e]=[T,f]),p===t))break;return f-=i,f===r||0===f%r&&f/r>=0}}},PSEUDO:function(e,t){var n,r=o.pseudos[e]||o.setFilters[e.toLowerCase()]||at.error("unsupported pseudo: "+e);return r[b]?r(t):r.length>1?(n=[e,e,"",t],o.setFilters.hasOwnProperty(e.toLowerCase())?lt(function(e,n){var i,o=r(e,t),a=o.length;while(a--)i=F.call(e,o[a]),e[i]=!(n[i]=o[a])}):function(e){return r(e,0,n)}):r}},pseudos:{not:lt(function(e){var t=[],n=[],r=l(e.replace(z,"$1"));return r[b]?lt(function(e,t,n,i){var o,a=r(e,null,i,[]),s=e.length;while(s--)(o=a[s])&&(e[s]=!(t[s]=o))}):function(e,i,o){return t[0]=e,r(t,null,o,n),!n.pop()}}),has:lt(function(e){return function(t){return at(e,t).length>0}}),contains:lt(function(e){return function(t){return(t.textContent||t.innerText||a(t)).indexOf(e)>-1}}),lang:lt(function(e){return G.test(e||"")||at.error("unsupported lang: "+e),e=e.replace(rt,it).toLowerCase(),function(t){var n;do if(n=h?t.lang:t.getAttribute("xml:lang")||t.getAttribute("lang"))return n=n.toLowerCase(),n===e||0===n.indexOf(e+"-");while((t=t.parentNode)&&1===t.nodeType);return!1}}),target:function(t){var n=e.location&&e.location.hash;return n&&n.slice(1)===t.id},root:function(e){return e===d},focus:function(e){return e===f.activeElement&&(!f.hasFocus||f.hasFocus())&&!!(e.type||e.href||~e.tabIndex)},enabled:function(e){return e.disabled===!1},disabled:function(e){return e.disabled===!0},checked:function(e){var t=e.nodeName.toLowerCase();return"input"===t&&!!e.checked||"option"===t&&!!e.selected},selected:function(e){return e.parentNode&&e.parentNode.selectedIndex,e.selected===!0},empty:function(e){for(e=e.firstChild;e;e=e.nextSibling)if(e.nodeName>"@"||3===e.nodeType||4===e.nodeType)return!1;return!0},parent:function(e){return!o.pseudos.empty(e)},header:function(e){return tt.test(e.nodeName)},input:function(e){return et.test(e.nodeName)},button:function(e){var t=e.nodeName.toLowerCase();return"input"===t&&"button"===e.type||"button"===t},text:function(e){var t;return"input"===e.nodeName.toLowerCase()&&"text"===e.type&&(null==(t=e.getAttribute("type"))||t.toLowerCase()===e.type)},first:ht(function(){return[0]}),last:ht(function(e,t){return[t-1]}),eq:ht(function(e,t,n){return[0>n?n+t:n]}),even:ht(function(e,t){var n=0;for(;t>n;n+=2)e.push(n);return e}),odd:ht(function(e,t){var n=1;for(;t>n;n+=2)e.push(n);return e}),lt:ht(function(e,t,n){var r=0>n?n+t:n;for(;--r>=0;)e.push(r);return e}),gt:ht(function(e,t,n){var r=0>n?n+t:n;for(;t>++r;)e.push(r);return e})}},o.pseudos.nth=o.pseudos.eq;for(n in{radio:!0,checkbox:!0,file:!0,password:!0,image:!0})o.pseudos[n]=ft(n);for(n in{submit:!0,reset:!0})o.pseudos[n]=dt(n);function gt(){}gt.prototype=o.filters=o.pseudos,o.setFilters=new gt;function mt(e,t){var n,r,i,a,s,l,u,c=k[e+" "];if(c)return t?0:c.slice(0);s=e,l=[],u=o.preFilter;while(s){(!n||(r=X.exec(s)))&&(r&&(s=s.slice(r[0].length)||s),l.push(i=[])),n=!1,(r=U.exec(s))&&(n=r.shift(),i.push({value:n,type:r[0].replace(z," ")}),s=s.slice(n.length));for(a in o.filter)!(r=Q[a].exec(s))||u[a]&&!(r=u[a](r))||(n=r.shift(),i.push({value:n,type:a,matches:r}),s=s.slice(n.length));if(!n)break}return t?s.length:s?at.error(e):k(e,l).slice(0)}function yt(e){var t=0,n=e.length,r="";for(;n>t;t++)r+=e[t].value;return r}function vt(e,t,n){var r=t.dir,o=n&&"parentNode"===r,a=C++;return t.first?function(t,n,i){while(t=t[r])if(1===t.nodeType||o)return e(t,n,i)}:function(t,n,s){var l,u,c,p=T+" "+a;if(s){while(t=t[r])if((1===t.nodeType||o)&&e(t,n,s))return!0}else while(t=t[r])if(1===t.nodeType||o)if(c=t[b]||(t[b]={}),(u=c[r])&&u[0]===p){if((l=u[1])===!0||l===i)return l===!0}else if(u=c[r]=[p],u[1]=e(t,n,s)||i,u[1]===!0)return!0}}function bt(e){return e.length>1?function(t,n,r){var i=e.length;while(i--)if(!e[i](t,n,r))return!1;return!0}:e[0]}function xt(e,t,n,r,i){var o,a=[],s=0,l=e.length,u=null!=t;for(;l>s;s++)(o=e[s])&&(!n||n(o,r,i))&&(a.push(o),u&&t.push(s));return a}function wt(e,t,n,r,i,o){return r&&!r[b]&&(r=wt(r)),i&&!i[b]&&(i=wt(i,o)),lt(function(o,a,s,l){var u,c,p,f=[],d=[],h=a.length,g=o||Nt(t||"*",s.nodeType?[s]:s,[]),m=!e||!o&&t?g:xt(g,f,e,s,l),y=n?i||(o?e:h||r)?[]:a:m;if(n&&n(m,y,s,l),r){u=xt(y,d),r(u,[],s,l),c=u.length;while(c--)(p=u[c])&&(y[d[c]]=!(m[d[c]]=p))}if(o){if(i||e){if(i){u=[],c=y.length;while(c--)(p=y[c])&&u.push(m[c]=p);i(null,y=[],u,l)}c=y.length;while(c--)(p=y[c])&&(u=i?F.call(o,p):f[c])>-1&&(o[u]=!(a[u]=p))}}else y=xt(y===a?y.splice(h,y.length):y),i?i(null,a,y,l):M.apply(a,y)})}function Tt(e){var t,n,r,i=e.length,a=o.relative[e[0].type],s=a||o.relative[" "],l=a?1:0,c=vt(function(e){return e===t},s,!0),p=vt(function(e){return F.call(t,e)>-1},s,!0),f=[function(e,n,r){return!a&&(r||n!==u)||((t=n).nodeType?c(e,n,r):p(e,n,r))}];for(;i>l;l++)if(n=o.relative[e[l].type])f=[vt(bt(f),n)];else{if(n=o.filter[e[l].type].apply(null,e[l].matches),n[b]){for(r=++l;i>r;r++)if(o.relative[e[r].type])break;return wt(l>1&&bt(f),l>1&&yt(e.slice(0,l-1).concat({value:" "===e[l-2].type?"*":""})).replace(z,"$1"),n,r>l&&Tt(e.slice(l,r)),i>r&&Tt(e=e.slice(r)),i>r&&yt(e))}f.push(n)}return bt(f)}function Ct(e,t){var n=0,r=t.length>0,a=e.length>0,s=function(s,l,c,p,d){var h,g,m,y=[],v=0,b="0",x=s&&[],w=null!=d,C=u,N=s||a&&o.find.TAG("*",d&&l.parentNode||l),k=T+=null==C?1:Math.random()||.1;for(w&&(u=l!==f&&l,i=n);null!=(h=N[b]);b++){if(a&&h){g=0;while(m=e[g++])if(m(h,l,c)){p.push(h);break}w&&(T=k,i=++n)}r&&((h=!m&&h)&&v--,s&&x.push(h))}if(v+=b,r&&b!==v){g=0;while(m=t[g++])m(x,y,l,c);if(s){if(v>0)while(b--)x[b]||y[b]||(y[b]=q.call(p));y=xt(y)}M.apply(p,y),w&&!s&&y.length>0&&v+t.length>1&&at.uniqueSort(p)}return w&&(T=k,u=C),x};return r?lt(s):s}l=at.compile=function(e,t){var n,r=[],i=[],o=E[e+" "];if(!o){t||(t=mt(e)),n=t.length;while(n--)o=Tt(t[n]),o[b]?r.push(o):i.push(o);o=E(e,Ct(i,r))}return o};function Nt(e,t,n){var r=0,i=t.length;for(;i>r;r++)at(e,t[r],n);return n}function kt(e,t,n,i){var a,s,u,c,p,f=mt(e);if(!i&&1===f.length){if(s=f[0]=f[0].slice(0),s.length>2&&"ID"===(u=s[0]).type&&r.getById&&9===t.nodeType&&h&&o.relative[s[1].type]){if(t=(o.find.ID(u.matches[0].replace(rt,it),t)||[])[0],!t)return n;e=e.slice(s.shift().value.length)}a=Q.needsContext.test(e)?0:s.length;while(a--){if(u=s[a],o.relative[c=u.type])break;if((p=o.find[c])&&(i=p(u.matches[0].replace(rt,it),V.test(s[0].type)&&t.parentNode||t))){if(s.splice(a,1),e=i.length&&yt(s),!e)return M.apply(n,i),n;break}}}return l(e,f)(i,t,!h,n,V.test(e)),n}r.sortStable=b.split("").sort(A).join("")===b,r.detectDuplicates=S,p(),r.sortDetached=ut(function(e){return 1&e.compareDocumentPosition(f.createElement("div"))}),ut(function(e){return e.innerHTML="","#"===e.firstChild.getAttribute("href")})||ct("type|href|height|width",function(e,n,r){return r?t:e.getAttribute(n,"type"===n.toLowerCase()?1:2)}),r.attributes&&ut(function(e){return e.innerHTML="",e.firstChild.setAttribute("value",""),""===e.firstChild.getAttribute("value")})||ct("value",function(e,n,r){return r||"input"!==e.nodeName.toLowerCase()?t:e.defaultValue}),ut(function(e){return null==e.getAttribute("disabled")})||ct(B,function(e,n,r){var i;return r?t:(i=e.getAttributeNode(n))&&i.specified?i.value:e[n]===!0?n.toLowerCase():null}),x.find=at,x.expr=at.selectors,x.expr[":"]=x.expr.pseudos,x.unique=at.uniqueSort,x.text=at.getText,x.isXMLDoc=at.isXML,x.contains=at.contains}(e);var O={};function F(e){var t=O[e]={};return x.each(e.match(T)||[],function(e,n){t[n]=!0}),t}x.Callbacks=function(e){e="string"==typeof e?O[e]||F(e):x.extend({},e);var n,r,i,o,a,s,l=[],u=!e.once&&[],c=function(t){for(r=e.memory&&t,i=!0,a=s||0,s=0,o=l.length,n=!0;l&&o>a;a++)if(l[a].apply(t[0],t[1])===!1&&e.stopOnFalse){r=!1;break}n=!1,l&&(u?u.length&&c(u.shift()):r?l=[]:p.disable())},p={add:function(){if(l){var t=l.length;(function i(t){x.each(t,function(t,n){var r=x.type(n);"function"===r?e.unique&&p.has(n)||l.push(n):n&&n.length&&"string"!==r&&i(n)})})(arguments),n?o=l.length:r&&(s=t,c(r))}return this},remove:function(){return l&&x.each(arguments,function(e,t){var r;while((r=x.inArray(t,l,r))>-1)l.splice(r,1),n&&(o>=r&&o--,a>=r&&a--)}),this},has:function(e){return e?x.inArray(e,l)>-1:!(!l||!l.length)},empty:function(){return l=[],o=0,this},disable:function(){return l=u=r=t,this},disabled:function(){return!l},lock:function(){return u=t,r||p.disable(),this},locked:function(){return!u},fireWith:function(e,t){return!l||i&&!u||(t=t||[],t=[e,t.slice?t.slice():t],n?u.push(t):c(t)),this},fire:function(){return p.fireWith(this,arguments),this},fired:function(){return!!i}};return p},x.extend({Deferred:function(e){var t=[["resolve","done",x.Callbacks("once memory"),"resolved"],["reject","fail",x.Callbacks("once memory"),"rejected"],["notify","progress",x.Callbacks("memory")]],n="pending",r={state:function(){return n},always:function(){return i.done(arguments).fail(arguments),this},then:function(){var e=arguments;return x.Deferred(function(n){x.each(t,function(t,o){var a=o[0],s=x.isFunction(e[t])&&e[t];i[o[1]](function(){var e=s&&s.apply(this,arguments);e&&x.isFunction(e.promise)?e.promise().done(n.resolve).fail(n.reject).progress(n.notify):n[a+"With"](this===r?n.promise():this,s?[e]:arguments)})}),e=null}).promise()},promise:function(e){return null!=e?x.extend(e,r):r}},i={};return r.pipe=r.then,x.each(t,function(e,o){var a=o[2],s=o[3];r[o[1]]=a.add,s&&a.add(function(){n=s},t[1^e][2].disable,t[2][2].lock),i[o[0]]=function(){return i[o[0]+"With"](this===i?r:this,arguments),this},i[o[0]+"With"]=a.fireWith}),r.promise(i),e&&e.call(i,i),i},when:function(e){var t=0,n=g.call(arguments),r=n.length,i=1!==r||e&&x.isFunction(e.promise)?r:0,o=1===i?e:x.Deferred(),a=function(e,t,n){return function(r){t[e]=this,n[e]=arguments.length>1?g.call(arguments):r,n===s?o.notifyWith(t,n):--i||o.resolveWith(t,n)}},s,l,u;if(r>1)for(s=Array(r),l=Array(r),u=Array(r);r>t;t++)n[t]&&x.isFunction(n[t].promise)?n[t].promise().done(a(t,u,n)).fail(o.reject).progress(a(t,l,s)):--i;return i||o.resolveWith(u,n),o.promise()}}),x.support=function(t){var n,r,o,s,l,u,c,p,f,d=a.createElement("div");if(d.setAttribute("className","t"),d.innerHTML="
a",n=d.getElementsByTagName("*")||[],r=d.getElementsByTagName("a")[0],!r||!r.style||!n.length)return t;s=a.createElement("select"),u=s.appendChild(a.createElement("option")),o=d.getElementsByTagName("input")[0],r.style.cssText="top:1px;float:left;opacity:.5",t.getSetAttribute="t"!==d.className,t.leadingWhitespace=3===d.firstChild.nodeType,t.tbody=!d.getElementsByTagName("tbody").length,t.htmlSerialize=!!d.getElementsByTagName("link").length,t.style=/top/.test(r.getAttribute("style")),t.hrefNormalized="/a"===r.getAttribute("href"),t.opacity=/^0.5/.test(r.style.opacity),t.cssFloat=!!r.style.cssFloat,t.checkOn=!!o.value,t.optSelected=u.selected,t.enctype=!!a.createElement("form").enctype,t.html5Clone="<:nav>"!==a.createElement("nav").cloneNode(!0).outerHTML,t.inlineBlockNeedsLayout=!1,t.shrinkWrapBlocks=!1,t.pixelPosition=!1,t.deleteExpando=!0,t.noCloneEvent=!0,t.reliableMarginRight=!0,t.boxSizingReliable=!0,o.checked=!0,t.noCloneChecked=o.cloneNode(!0).checked,s.disabled=!0,t.optDisabled=!u.disabled;try{delete d.test}catch(h){t.deleteExpando=!1}o=a.createElement("input"),o.setAttribute("value",""),t.input=""===o.getAttribute("value"),o.value="t",o.setAttribute("type","radio"),t.radioValue="t"===o.value,o.setAttribute("checked","t"),o.setAttribute("name","t"),l=a.createDocumentFragment(),l.appendChild(o),t.appendChecked=o.checked,t.checkClone=l.cloneNode(!0).cloneNode(!0).lastChild.checked,d.attachEvent&&(d.attachEvent("onclick",function(){t.noCloneEvent=!1}),d.cloneNode(!0).click());for(f in{submit:!0,change:!0,focusin:!0})d.setAttribute(c="on"+f,"t"),t[f+"Bubbles"]=c in e||d.attributes[c].expando===!1;d.style.backgroundClip="content-box",d.cloneNode(!0).style.backgroundClip="",t.clearCloneStyle="content-box"===d.style.backgroundClip;for(f in x(t))break;return t.ownLast="0"!==f,x(function(){var n,r,o,s="padding:0;margin:0;border:0;display:block;box-sizing:content-box;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;",l=a.getElementsByTagName("body")[0];l&&(n=a.createElement("div"),n.style.cssText="border:0;width:0;height:0;position:absolute;top:0;left:-9999px;margin-top:1px",l.appendChild(n).appendChild(d),d.innerHTML="
t
",o=d.getElementsByTagName("td"),o[0].style.cssText="padding:0;margin:0;border:0;display:none",p=0===o[0].offsetHeight,o[0].style.display="",o[1].style.display="none",t.reliableHiddenOffsets=p&&0===o[0].offsetHeight,d.innerHTML="",d.style.cssText="box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;padding:1px;border:1px;display:block;width:4px;margin-top:1%;position:absolute;top:1%;",x.swap(l,null!=l.style.zoom?{zoom:1}:{},function(){t.boxSizing=4===d.offsetWidth}),e.getComputedStyle&&(t.pixelPosition="1%"!==(e.getComputedStyle(d,null)||{}).top,t.boxSizingReliable="4px"===(e.getComputedStyle(d,null)||{width:"4px"}).width,r=d.appendChild(a.createElement("div")),r.style.cssText=d.style.cssText=s,r.style.marginRight=r.style.width="0",d.style.width="1px",t.reliableMarginRight=!parseFloat((e.getComputedStyle(r,null)||{}).marginRight)),typeof d.style.zoom!==i&&(d.innerHTML="",d.style.cssText=s+"width:1px;padding:1px;display:inline;zoom:1",t.inlineBlockNeedsLayout=3===d.offsetWidth,d.style.display="block",d.innerHTML="
",d.firstChild.style.width="5px",t.shrinkWrapBlocks=3!==d.offsetWidth,t.inlineBlockNeedsLayout&&(l.style.zoom=1)),l.removeChild(n),n=d=o=r=null)}),n=s=l=u=r=o=null,t -}({});var B=/(?:\{[\s\S]*\}|\[[\s\S]*\])$/,P=/([A-Z])/g;function R(e,n,r,i){if(x.acceptData(e)){var o,a,s=x.expando,l=e.nodeType,u=l?x.cache:e,c=l?e[s]:e[s]&&s;if(c&&u[c]&&(i||u[c].data)||r!==t||"string"!=typeof n)return c||(c=l?e[s]=p.pop()||x.guid++:s),u[c]||(u[c]=l?{}:{toJSON:x.noop}),("object"==typeof n||"function"==typeof n)&&(i?u[c]=x.extend(u[c],n):u[c].data=x.extend(u[c].data,n)),a=u[c],i||(a.data||(a.data={}),a=a.data),r!==t&&(a[x.camelCase(n)]=r),"string"==typeof n?(o=a[n],null==o&&(o=a[x.camelCase(n)])):o=a,o}}function W(e,t,n){if(x.acceptData(e)){var r,i,o=e.nodeType,a=o?x.cache:e,s=o?e[x.expando]:x.expando;if(a[s]){if(t&&(r=n?a[s]:a[s].data)){x.isArray(t)?t=t.concat(x.map(t,x.camelCase)):t in r?t=[t]:(t=x.camelCase(t),t=t in r?[t]:t.split(" ")),i=t.length;while(i--)delete r[t[i]];if(n?!I(r):!x.isEmptyObject(r))return}(n||(delete a[s].data,I(a[s])))&&(o?x.cleanData([e],!0):x.support.deleteExpando||a!=a.window?delete a[s]:a[s]=null)}}}x.extend({cache:{},noData:{applet:!0,embed:!0,object:"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"},hasData:function(e){return e=e.nodeType?x.cache[e[x.expando]]:e[x.expando],!!e&&!I(e)},data:function(e,t,n){return R(e,t,n)},removeData:function(e,t){return W(e,t)},_data:function(e,t,n){return R(e,t,n,!0)},_removeData:function(e,t){return W(e,t,!0)},acceptData:function(e){if(e.nodeType&&1!==e.nodeType&&9!==e.nodeType)return!1;var t=e.nodeName&&x.noData[e.nodeName.toLowerCase()];return!t||t!==!0&&e.getAttribute("classid")===t}}),x.fn.extend({data:function(e,n){var r,i,o=null,a=0,s=this[0];if(e===t){if(this.length&&(o=x.data(s),1===s.nodeType&&!x._data(s,"parsedAttrs"))){for(r=s.attributes;r.length>a;a++)i=r[a].name,0===i.indexOf("data-")&&(i=x.camelCase(i.slice(5)),$(s,i,o[i]));x._data(s,"parsedAttrs",!0)}return o}return"object"==typeof e?this.each(function(){x.data(this,e)}):arguments.length>1?this.each(function(){x.data(this,e,n)}):s?$(s,e,x.data(s,e)):null},removeData:function(e){return this.each(function(){x.removeData(this,e)})}});function $(e,n,r){if(r===t&&1===e.nodeType){var i="data-"+n.replace(P,"-$1").toLowerCase();if(r=e.getAttribute(i),"string"==typeof r){try{r="true"===r?!0:"false"===r?!1:"null"===r?null:+r+""===r?+r:B.test(r)?x.parseJSON(r):r}catch(o){}x.data(e,n,r)}else r=t}return r}function I(e){var t;for(t in e)if(("data"!==t||!x.isEmptyObject(e[t]))&&"toJSON"!==t)return!1;return!0}x.extend({queue:function(e,n,r){var i;return e?(n=(n||"fx")+"queue",i=x._data(e,n),r&&(!i||x.isArray(r)?i=x._data(e,n,x.makeArray(r)):i.push(r)),i||[]):t},dequeue:function(e,t){t=t||"fx";var n=x.queue(e,t),r=n.length,i=n.shift(),o=x._queueHooks(e,t),a=function(){x.dequeue(e,t)};"inprogress"===i&&(i=n.shift(),r--),i&&("fx"===t&&n.unshift("inprogress"),delete o.stop,i.call(e,a,o)),!r&&o&&o.empty.fire()},_queueHooks:function(e,t){var n=t+"queueHooks";return x._data(e,n)||x._data(e,n,{empty:x.Callbacks("once memory").add(function(){x._removeData(e,t+"queue"),x._removeData(e,n)})})}}),x.fn.extend({queue:function(e,n){var r=2;return"string"!=typeof e&&(n=e,e="fx",r--),r>arguments.length?x.queue(this[0],e):n===t?this:this.each(function(){var t=x.queue(this,e,n);x._queueHooks(this,e),"fx"===e&&"inprogress"!==t[0]&&x.dequeue(this,e)})},dequeue:function(e){return this.each(function(){x.dequeue(this,e)})},delay:function(e,t){return e=x.fx?x.fx.speeds[e]||e:e,t=t||"fx",this.queue(t,function(t,n){var r=setTimeout(t,e);n.stop=function(){clearTimeout(r)}})},clearQueue:function(e){return this.queue(e||"fx",[])},promise:function(e,n){var r,i=1,o=x.Deferred(),a=this,s=this.length,l=function(){--i||o.resolveWith(a,[a])};"string"!=typeof e&&(n=e,e=t),e=e||"fx";while(s--)r=x._data(a[s],e+"queueHooks"),r&&r.empty&&(i++,r.empty.add(l));return l(),o.promise(n)}});var z,X,U=/[\t\r\n\f]/g,V=/\r/g,Y=/^(?:input|select|textarea|button|object)$/i,J=/^(?:a|area)$/i,G=/^(?:checked|selected)$/i,Q=x.support.getSetAttribute,K=x.support.input;x.fn.extend({attr:function(e,t){return x.access(this,x.attr,e,t,arguments.length>1)},removeAttr:function(e){return this.each(function(){x.removeAttr(this,e)})},prop:function(e,t){return x.access(this,x.prop,e,t,arguments.length>1)},removeProp:function(e){return e=x.propFix[e]||e,this.each(function(){try{this[e]=t,delete this[e]}catch(n){}})},addClass:function(e){var t,n,r,i,o,a=0,s=this.length,l="string"==typeof e&&e;if(x.isFunction(e))return this.each(function(t){x(this).addClass(e.call(this,t,this.className))});if(l)for(t=(e||"").match(T)||[];s>a;a++)if(n=this[a],r=1===n.nodeType&&(n.className?(" "+n.className+" ").replace(U," "):" ")){o=0;while(i=t[o++])0>r.indexOf(" "+i+" ")&&(r+=i+" ");n.className=x.trim(r)}return this},removeClass:function(e){var t,n,r,i,o,a=0,s=this.length,l=0===arguments.length||"string"==typeof e&&e;if(x.isFunction(e))return this.each(function(t){x(this).removeClass(e.call(this,t,this.className))});if(l)for(t=(e||"").match(T)||[];s>a;a++)if(n=this[a],r=1===n.nodeType&&(n.className?(" "+n.className+" ").replace(U," "):"")){o=0;while(i=t[o++])while(r.indexOf(" "+i+" ")>=0)r=r.replace(" "+i+" "," ");n.className=e?x.trim(r):""}return this},toggleClass:function(e,t){var n=typeof e;return"boolean"==typeof t&&"string"===n?t?this.addClass(e):this.removeClass(e):x.isFunction(e)?this.each(function(n){x(this).toggleClass(e.call(this,n,this.className,t),t)}):this.each(function(){if("string"===n){var t,r=0,o=x(this),a=e.match(T)||[];while(t=a[r++])o.hasClass(t)?o.removeClass(t):o.addClass(t)}else(n===i||"boolean"===n)&&(this.className&&x._data(this,"__className__",this.className),this.className=this.className||e===!1?"":x._data(this,"__className__")||"")})},hasClass:function(e){var t=" "+e+" ",n=0,r=this.length;for(;r>n;n++)if(1===this[n].nodeType&&(" "+this[n].className+" ").replace(U," ").indexOf(t)>=0)return!0;return!1},val:function(e){var n,r,i,o=this[0];{if(arguments.length)return i=x.isFunction(e),this.each(function(n){var o;1===this.nodeType&&(o=i?e.call(this,n,x(this).val()):e,null==o?o="":"number"==typeof o?o+="":x.isArray(o)&&(o=x.map(o,function(e){return null==e?"":e+""})),r=x.valHooks[this.type]||x.valHooks[this.nodeName.toLowerCase()],r&&"set"in r&&r.set(this,o,"value")!==t||(this.value=o))});if(o)return r=x.valHooks[o.type]||x.valHooks[o.nodeName.toLowerCase()],r&&"get"in r&&(n=r.get(o,"value"))!==t?n:(n=o.value,"string"==typeof n?n.replace(V,""):null==n?"":n)}}}),x.extend({valHooks:{option:{get:function(e){var t=x.find.attr(e,"value");return null!=t?t:e.text}},select:{get:function(e){var t,n,r=e.options,i=e.selectedIndex,o="select-one"===e.type||0>i,a=o?null:[],s=o?i+1:r.length,l=0>i?s:o?i:0;for(;s>l;l++)if(n=r[l],!(!n.selected&&l!==i||(x.support.optDisabled?n.disabled:null!==n.getAttribute("disabled"))||n.parentNode.disabled&&x.nodeName(n.parentNode,"optgroup"))){if(t=x(n).val(),o)return t;a.push(t)}return a},set:function(e,t){var n,r,i=e.options,o=x.makeArray(t),a=i.length;while(a--)r=i[a],(r.selected=x.inArray(x(r).val(),o)>=0)&&(n=!0);return n||(e.selectedIndex=-1),o}}},attr:function(e,n,r){var o,a,s=e.nodeType;if(e&&3!==s&&8!==s&&2!==s)return typeof e.getAttribute===i?x.prop(e,n,r):(1===s&&x.isXMLDoc(e)||(n=n.toLowerCase(),o=x.attrHooks[n]||(x.expr.match.bool.test(n)?X:z)),r===t?o&&"get"in o&&null!==(a=o.get(e,n))?a:(a=x.find.attr(e,n),null==a?t:a):null!==r?o&&"set"in o&&(a=o.set(e,r,n))!==t?a:(e.setAttribute(n,r+""),r):(x.removeAttr(e,n),t))},removeAttr:function(e,t){var n,r,i=0,o=t&&t.match(T);if(o&&1===e.nodeType)while(n=o[i++])r=x.propFix[n]||n,x.expr.match.bool.test(n)?K&&Q||!G.test(n)?e[r]=!1:e[x.camelCase("default-"+n)]=e[r]=!1:x.attr(e,n,""),e.removeAttribute(Q?n:r)},attrHooks:{type:{set:function(e,t){if(!x.support.radioValue&&"radio"===t&&x.nodeName(e,"input")){var n=e.value;return e.setAttribute("type",t),n&&(e.value=n),t}}}},propFix:{"for":"htmlFor","class":"className"},prop:function(e,n,r){var i,o,a,s=e.nodeType;if(e&&3!==s&&8!==s&&2!==s)return a=1!==s||!x.isXMLDoc(e),a&&(n=x.propFix[n]||n,o=x.propHooks[n]),r!==t?o&&"set"in o&&(i=o.set(e,r,n))!==t?i:e[n]=r:o&&"get"in o&&null!==(i=o.get(e,n))?i:e[n]},propHooks:{tabIndex:{get:function(e){var t=x.find.attr(e,"tabindex");return t?parseInt(t,10):Y.test(e.nodeName)||J.test(e.nodeName)&&e.href?0:-1}}}}),X={set:function(e,t,n){return t===!1?x.removeAttr(e,n):K&&Q||!G.test(n)?e.setAttribute(!Q&&x.propFix[n]||n,n):e[x.camelCase("default-"+n)]=e[n]=!0,n}},x.each(x.expr.match.bool.source.match(/\w+/g),function(e,n){var r=x.expr.attrHandle[n]||x.find.attr;x.expr.attrHandle[n]=K&&Q||!G.test(n)?function(e,n,i){var o=x.expr.attrHandle[n],a=i?t:(x.expr.attrHandle[n]=t)!=r(e,n,i)?n.toLowerCase():null;return x.expr.attrHandle[n]=o,a}:function(e,n,r){return r?t:e[x.camelCase("default-"+n)]?n.toLowerCase():null}}),K&&Q||(x.attrHooks.value={set:function(e,n,r){return x.nodeName(e,"input")?(e.defaultValue=n,t):z&&z.set(e,n,r)}}),Q||(z={set:function(e,n,r){var i=e.getAttributeNode(r);return i||e.setAttributeNode(i=e.ownerDocument.createAttribute(r)),i.value=n+="","value"===r||n===e.getAttribute(r)?n:t}},x.expr.attrHandle.id=x.expr.attrHandle.name=x.expr.attrHandle.coords=function(e,n,r){var i;return r?t:(i=e.getAttributeNode(n))&&""!==i.value?i.value:null},x.valHooks.button={get:function(e,n){var r=e.getAttributeNode(n);return r&&r.specified?r.value:t},set:z.set},x.attrHooks.contenteditable={set:function(e,t,n){z.set(e,""===t?!1:t,n)}},x.each(["width","height"],function(e,n){x.attrHooks[n]={set:function(e,r){return""===r?(e.setAttribute(n,"auto"),r):t}}})),x.support.hrefNormalized||x.each(["href","src"],function(e,t){x.propHooks[t]={get:function(e){return e.getAttribute(t,4)}}}),x.support.style||(x.attrHooks.style={get:function(e){return e.style.cssText||t},set:function(e,t){return e.style.cssText=t+""}}),x.support.optSelected||(x.propHooks.selected={get:function(e){var t=e.parentNode;return t&&(t.selectedIndex,t.parentNode&&t.parentNode.selectedIndex),null}}),x.each(["tabIndex","readOnly","maxLength","cellSpacing","cellPadding","rowSpan","colSpan","useMap","frameBorder","contentEditable"],function(){x.propFix[this.toLowerCase()]=this}),x.support.enctype||(x.propFix.enctype="encoding"),x.each(["radio","checkbox"],function(){x.valHooks[this]={set:function(e,n){return x.isArray(n)?e.checked=x.inArray(x(e).val(),n)>=0:t}},x.support.checkOn||(x.valHooks[this].get=function(e){return null===e.getAttribute("value")?"on":e.value})});var Z=/^(?:input|select|textarea)$/i,et=/^key/,tt=/^(?:mouse|contextmenu)|click/,nt=/^(?:focusinfocus|focusoutblur)$/,rt=/^([^.]*)(?:\.(.+)|)$/;function it(){return!0}function ot(){return!1}function at(){try{return a.activeElement}catch(e){}}x.event={global:{},add:function(e,n,r,o,a){var s,l,u,c,p,f,d,h,g,m,y,v=x._data(e);if(v){r.handler&&(c=r,r=c.handler,a=c.selector),r.guid||(r.guid=x.guid++),(l=v.events)||(l=v.events={}),(f=v.handle)||(f=v.handle=function(e){return typeof x===i||e&&x.event.triggered===e.type?t:x.event.dispatch.apply(f.elem,arguments)},f.elem=e),n=(n||"").match(T)||[""],u=n.length;while(u--)s=rt.exec(n[u])||[],g=y=s[1],m=(s[2]||"").split(".").sort(),g&&(p=x.event.special[g]||{},g=(a?p.delegateType:p.bindType)||g,p=x.event.special[g]||{},d=x.extend({type:g,origType:y,data:o,handler:r,guid:r.guid,selector:a,needsContext:a&&x.expr.match.needsContext.test(a),namespace:m.join(".")},c),(h=l[g])||(h=l[g]=[],h.delegateCount=0,p.setup&&p.setup.call(e,o,m,f)!==!1||(e.addEventListener?e.addEventListener(g,f,!1):e.attachEvent&&e.attachEvent("on"+g,f))),p.add&&(p.add.call(e,d),d.handler.guid||(d.handler.guid=r.guid)),a?h.splice(h.delegateCount++,0,d):h.push(d),x.event.global[g]=!0);e=null}},remove:function(e,t,n,r,i){var o,a,s,l,u,c,p,f,d,h,g,m=x.hasData(e)&&x._data(e);if(m&&(c=m.events)){t=(t||"").match(T)||[""],u=t.length;while(u--)if(s=rt.exec(t[u])||[],d=g=s[1],h=(s[2]||"").split(".").sort(),d){p=x.event.special[d]||{},d=(r?p.delegateType:p.bindType)||d,f=c[d]||[],s=s[2]&&RegExp("(^|\\.)"+h.join("\\.(?:.*\\.|)")+"(\\.|$)"),l=o=f.length;while(o--)a=f[o],!i&&g!==a.origType||n&&n.guid!==a.guid||s&&!s.test(a.namespace)||r&&r!==a.selector&&("**"!==r||!a.selector)||(f.splice(o,1),a.selector&&f.delegateCount--,p.remove&&p.remove.call(e,a));l&&!f.length&&(p.teardown&&p.teardown.call(e,h,m.handle)!==!1||x.removeEvent(e,d,m.handle),delete c[d])}else for(d in c)x.event.remove(e,d+t[u],n,r,!0);x.isEmptyObject(c)&&(delete m.handle,x._removeData(e,"events"))}},trigger:function(n,r,i,o){var s,l,u,c,p,f,d,h=[i||a],g=v.call(n,"type")?n.type:n,m=v.call(n,"namespace")?n.namespace.split("."):[];if(u=f=i=i||a,3!==i.nodeType&&8!==i.nodeType&&!nt.test(g+x.event.triggered)&&(g.indexOf(".")>=0&&(m=g.split("."),g=m.shift(),m.sort()),l=0>g.indexOf(":")&&"on"+g,n=n[x.expando]?n:new x.Event(g,"object"==typeof n&&n),n.isTrigger=o?2:3,n.namespace=m.join("."),n.namespace_re=n.namespace?RegExp("(^|\\.)"+m.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,n.result=t,n.target||(n.target=i),r=null==r?[n]:x.makeArray(r,[n]),p=x.event.special[g]||{},o||!p.trigger||p.trigger.apply(i,r)!==!1)){if(!o&&!p.noBubble&&!x.isWindow(i)){for(c=p.delegateType||g,nt.test(c+g)||(u=u.parentNode);u;u=u.parentNode)h.push(u),f=u;f===(i.ownerDocument||a)&&h.push(f.defaultView||f.parentWindow||e)}d=0;while((u=h[d++])&&!n.isPropagationStopped())n.type=d>1?c:p.bindType||g,s=(x._data(u,"events")||{})[n.type]&&x._data(u,"handle"),s&&s.apply(u,r),s=l&&u[l],s&&x.acceptData(u)&&s.apply&&s.apply(u,r)===!1&&n.preventDefault();if(n.type=g,!o&&!n.isDefaultPrevented()&&(!p._default||p._default.apply(h.pop(),r)===!1)&&x.acceptData(i)&&l&&i[g]&&!x.isWindow(i)){f=i[l],f&&(i[l]=null),x.event.triggered=g;try{i[g]()}catch(y){}x.event.triggered=t,f&&(i[l]=f)}return n.result}},dispatch:function(e){e=x.event.fix(e);var n,r,i,o,a,s=[],l=g.call(arguments),u=(x._data(this,"events")||{})[e.type]||[],c=x.event.special[e.type]||{};if(l[0]=e,e.delegateTarget=this,!c.preDispatch||c.preDispatch.call(this,e)!==!1){s=x.event.handlers.call(this,e,u),n=0;while((o=s[n++])&&!e.isPropagationStopped()){e.currentTarget=o.elem,a=0;while((i=o.handlers[a++])&&!e.isImmediatePropagationStopped())(!e.namespace_re||e.namespace_re.test(i.namespace))&&(e.handleObj=i,e.data=i.data,r=((x.event.special[i.origType]||{}).handle||i.handler).apply(o.elem,l),r!==t&&(e.result=r)===!1&&(e.preventDefault(),e.stopPropagation()))}return c.postDispatch&&c.postDispatch.call(this,e),e.result}},handlers:function(e,n){var r,i,o,a,s=[],l=n.delegateCount,u=e.target;if(l&&u.nodeType&&(!e.button||"click"!==e.type))for(;u!=this;u=u.parentNode||this)if(1===u.nodeType&&(u.disabled!==!0||"click"!==e.type)){for(o=[],a=0;l>a;a++)i=n[a],r=i.selector+" ",o[r]===t&&(o[r]=i.needsContext?x(r,this).index(u)>=0:x.find(r,this,null,[u]).length),o[r]&&o.push(i);o.length&&s.push({elem:u,handlers:o})}return n.length>l&&s.push({elem:this,handlers:n.slice(l)}),s},fix:function(e){if(e[x.expando])return e;var t,n,r,i=e.type,o=e,s=this.fixHooks[i];s||(this.fixHooks[i]=s=tt.test(i)?this.mouseHooks:et.test(i)?this.keyHooks:{}),r=s.props?this.props.concat(s.props):this.props,e=new x.Event(o),t=r.length;while(t--)n=r[t],e[n]=o[n];return e.target||(e.target=o.srcElement||a),3===e.target.nodeType&&(e.target=e.target.parentNode),e.metaKey=!!e.metaKey,s.filter?s.filter(e,o):e},props:"altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),fixHooks:{},keyHooks:{props:"char charCode key keyCode".split(" "),filter:function(e,t){return null==e.which&&(e.which=null!=t.charCode?t.charCode:t.keyCode),e}},mouseHooks:{props:"button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement".split(" "),filter:function(e,n){var r,i,o,s=n.button,l=n.fromElement;return null==e.pageX&&null!=n.clientX&&(i=e.target.ownerDocument||a,o=i.documentElement,r=i.body,e.pageX=n.clientX+(o&&o.scrollLeft||r&&r.scrollLeft||0)-(o&&o.clientLeft||r&&r.clientLeft||0),e.pageY=n.clientY+(o&&o.scrollTop||r&&r.scrollTop||0)-(o&&o.clientTop||r&&r.clientTop||0)),!e.relatedTarget&&l&&(e.relatedTarget=l===e.target?n.toElement:l),e.which||s===t||(e.which=1&s?1:2&s?3:4&s?2:0),e}},special:{load:{noBubble:!0},focus:{trigger:function(){if(this!==at()&&this.focus)try{return this.focus(),!1}catch(e){}},delegateType:"focusin"},blur:{trigger:function(){return this===at()&&this.blur?(this.blur(),!1):t},delegateType:"focusout"},click:{trigger:function(){return x.nodeName(this,"input")&&"checkbox"===this.type&&this.click?(this.click(),!1):t},_default:function(e){return x.nodeName(e.target,"a")}},beforeunload:{postDispatch:function(e){e.result!==t&&(e.originalEvent.returnValue=e.result)}}},simulate:function(e,t,n,r){var i=x.extend(new x.Event,n,{type:e,isSimulated:!0,originalEvent:{}});r?x.event.trigger(i,null,t):x.event.dispatch.call(t,i),i.isDefaultPrevented()&&n.preventDefault()}},x.removeEvent=a.removeEventListener?function(e,t,n){e.removeEventListener&&e.removeEventListener(t,n,!1)}:function(e,t,n){var r="on"+t;e.detachEvent&&(typeof e[r]===i&&(e[r]=null),e.detachEvent(r,n))},x.Event=function(e,n){return this instanceof x.Event?(e&&e.type?(this.originalEvent=e,this.type=e.type,this.isDefaultPrevented=e.defaultPrevented||e.returnValue===!1||e.getPreventDefault&&e.getPreventDefault()?it:ot):this.type=e,n&&x.extend(this,n),this.timeStamp=e&&e.timeStamp||x.now(),this[x.expando]=!0,t):new x.Event(e,n)},x.Event.prototype={isDefaultPrevented:ot,isPropagationStopped:ot,isImmediatePropagationStopped:ot,preventDefault:function(){var e=this.originalEvent;this.isDefaultPrevented=it,e&&(e.preventDefault?e.preventDefault():e.returnValue=!1)},stopPropagation:function(){var e=this.originalEvent;this.isPropagationStopped=it,e&&(e.stopPropagation&&e.stopPropagation(),e.cancelBubble=!0)},stopImmediatePropagation:function(){this.isImmediatePropagationStopped=it,this.stopPropagation()}},x.each({mouseenter:"mouseover",mouseleave:"mouseout"},function(e,t){x.event.special[e]={delegateType:t,bindType:t,handle:function(e){var n,r=this,i=e.relatedTarget,o=e.handleObj;return(!i||i!==r&&!x.contains(r,i))&&(e.type=o.origType,n=o.handler.apply(this,arguments),e.type=t),n}}}),x.support.submitBubbles||(x.event.special.submit={setup:function(){return x.nodeName(this,"form")?!1:(x.event.add(this,"click._submit keypress._submit",function(e){var n=e.target,r=x.nodeName(n,"input")||x.nodeName(n,"button")?n.form:t;r&&!x._data(r,"submitBubbles")&&(x.event.add(r,"submit._submit",function(e){e._submit_bubble=!0}),x._data(r,"submitBubbles",!0))}),t)},postDispatch:function(e){e._submit_bubble&&(delete e._submit_bubble,this.parentNode&&!e.isTrigger&&x.event.simulate("submit",this.parentNode,e,!0))},teardown:function(){return x.nodeName(this,"form")?!1:(x.event.remove(this,"._submit"),t)}}),x.support.changeBubbles||(x.event.special.change={setup:function(){return Z.test(this.nodeName)?(("checkbox"===this.type||"radio"===this.type)&&(x.event.add(this,"propertychange._change",function(e){"checked"===e.originalEvent.propertyName&&(this._just_changed=!0)}),x.event.add(this,"click._change",function(e){this._just_changed&&!e.isTrigger&&(this._just_changed=!1),x.event.simulate("change",this,e,!0)})),!1):(x.event.add(this,"beforeactivate._change",function(e){var t=e.target;Z.test(t.nodeName)&&!x._data(t,"changeBubbles")&&(x.event.add(t,"change._change",function(e){!this.parentNode||e.isSimulated||e.isTrigger||x.event.simulate("change",this.parentNode,e,!0)}),x._data(t,"changeBubbles",!0))}),t)},handle:function(e){var n=e.target;return this!==n||e.isSimulated||e.isTrigger||"radio"!==n.type&&"checkbox"!==n.type?e.handleObj.handler.apply(this,arguments):t},teardown:function(){return x.event.remove(this,"._change"),!Z.test(this.nodeName)}}),x.support.focusinBubbles||x.each({focus:"focusin",blur:"focusout"},function(e,t){var n=0,r=function(e){x.event.simulate(t,e.target,x.event.fix(e),!0)};x.event.special[t]={setup:function(){0===n++&&a.addEventListener(e,r,!0)},teardown:function(){0===--n&&a.removeEventListener(e,r,!0)}}}),x.fn.extend({on:function(e,n,r,i,o){var a,s;if("object"==typeof e){"string"!=typeof n&&(r=r||n,n=t);for(a in e)this.on(a,n,r,e[a],o);return this}if(null==r&&null==i?(i=n,r=n=t):null==i&&("string"==typeof n?(i=r,r=t):(i=r,r=n,n=t)),i===!1)i=ot;else if(!i)return this;return 1===o&&(s=i,i=function(e){return x().off(e),s.apply(this,arguments)},i.guid=s.guid||(s.guid=x.guid++)),this.each(function(){x.event.add(this,e,i,r,n)})},one:function(e,t,n,r){return this.on(e,t,n,r,1)},off:function(e,n,r){var i,o;if(e&&e.preventDefault&&e.handleObj)return i=e.handleObj,x(e.delegateTarget).off(i.namespace?i.origType+"."+i.namespace:i.origType,i.selector,i.handler),this;if("object"==typeof e){for(o in e)this.off(o,n,e[o]);return this}return(n===!1||"function"==typeof n)&&(r=n,n=t),r===!1&&(r=ot),this.each(function(){x.event.remove(this,e,r,n)})},trigger:function(e,t){return this.each(function(){x.event.trigger(e,t,this)})},triggerHandler:function(e,n){var r=this[0];return r?x.event.trigger(e,n,r,!0):t}});var st=/^.[^:#\[\.,]*$/,lt=/^(?:parents|prev(?:Until|All))/,ut=x.expr.match.needsContext,ct={children:!0,contents:!0,next:!0,prev:!0};x.fn.extend({find:function(e){var t,n=[],r=this,i=r.length;if("string"!=typeof e)return this.pushStack(x(e).filter(function(){for(t=0;i>t;t++)if(x.contains(r[t],this))return!0}));for(t=0;i>t;t++)x.find(e,r[t],n);return n=this.pushStack(i>1?x.unique(n):n),n.selector=this.selector?this.selector+" "+e:e,n},has:function(e){var t,n=x(e,this),r=n.length;return this.filter(function(){for(t=0;r>t;t++)if(x.contains(this,n[t]))return!0})},not:function(e){return this.pushStack(ft(this,e||[],!0))},filter:function(e){return this.pushStack(ft(this,e||[],!1))},is:function(e){return!!ft(this,"string"==typeof e&&ut.test(e)?x(e):e||[],!1).length},closest:function(e,t){var n,r=0,i=this.length,o=[],a=ut.test(e)||"string"!=typeof e?x(e,t||this.context):0;for(;i>r;r++)for(n=this[r];n&&n!==t;n=n.parentNode)if(11>n.nodeType&&(a?a.index(n)>-1:1===n.nodeType&&x.find.matchesSelector(n,e))){n=o.push(n);break}return this.pushStack(o.length>1?x.unique(o):o)},index:function(e){return e?"string"==typeof e?x.inArray(this[0],x(e)):x.inArray(e.jquery?e[0]:e,this):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(e,t){var n="string"==typeof e?x(e,t):x.makeArray(e&&e.nodeType?[e]:e),r=x.merge(this.get(),n);return this.pushStack(x.unique(r))},addBack:function(e){return this.add(null==e?this.prevObject:this.prevObject.filter(e))}});function pt(e,t){do e=e[t];while(e&&1!==e.nodeType);return e}x.each({parent:function(e){var t=e.parentNode;return t&&11!==t.nodeType?t:null},parents:function(e){return x.dir(e,"parentNode")},parentsUntil:function(e,t,n){return x.dir(e,"parentNode",n)},next:function(e){return pt(e,"nextSibling")},prev:function(e){return pt(e,"previousSibling")},nextAll:function(e){return x.dir(e,"nextSibling")},prevAll:function(e){return x.dir(e,"previousSibling")},nextUntil:function(e,t,n){return x.dir(e,"nextSibling",n)},prevUntil:function(e,t,n){return x.dir(e,"previousSibling",n)},siblings:function(e){return x.sibling((e.parentNode||{}).firstChild,e)},children:function(e){return x.sibling(e.firstChild)},contents:function(e){return x.nodeName(e,"iframe")?e.contentDocument||e.contentWindow.document:x.merge([],e.childNodes)}},function(e,t){x.fn[e]=function(n,r){var i=x.map(this,t,n);return"Until"!==e.slice(-5)&&(r=n),r&&"string"==typeof r&&(i=x.filter(r,i)),this.length>1&&(ct[e]||(i=x.unique(i)),lt.test(e)&&(i=i.reverse())),this.pushStack(i)}}),x.extend({filter:function(e,t,n){var r=t[0];return n&&(e=":not("+e+")"),1===t.length&&1===r.nodeType?x.find.matchesSelector(r,e)?[r]:[]:x.find.matches(e,x.grep(t,function(e){return 1===e.nodeType}))},dir:function(e,n,r){var i=[],o=e[n];while(o&&9!==o.nodeType&&(r===t||1!==o.nodeType||!x(o).is(r)))1===o.nodeType&&i.push(o),o=o[n];return i},sibling:function(e,t){var n=[];for(;e;e=e.nextSibling)1===e.nodeType&&e!==t&&n.push(e);return n}});function ft(e,t,n){if(x.isFunction(t))return x.grep(e,function(e,r){return!!t.call(e,r,e)!==n});if(t.nodeType)return x.grep(e,function(e){return e===t!==n});if("string"==typeof t){if(st.test(t))return x.filter(t,e,n);t=x.filter(t,e)}return x.grep(e,function(e){return x.inArray(e,t)>=0!==n})}function dt(e){var t=ht.split("|"),n=e.createDocumentFragment();if(n.createElement)while(t.length)n.createElement(t.pop());return n}var ht="abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",gt=/ jQuery\d+="(?:null|\d+)"/g,mt=RegExp("<(?:"+ht+")[\\s/>]","i"),yt=/^\s+/,vt=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,bt=/<([\w:]+)/,xt=/\s*$/g,At={option:[1,""],legend:[1,"
","
"],area:[1,"",""],param:[1,"",""],thead:[1,"","
"],tr:[2,"","
"],col:[2,"","
"],td:[3,"","
"],_default:x.support.htmlSerialize?[0,"",""]:[1,"X
","
"]},jt=dt(a),Dt=jt.appendChild(a.createElement("div"));At.optgroup=At.option,At.tbody=At.tfoot=At.colgroup=At.caption=At.thead,At.th=At.td,x.fn.extend({text:function(e){return x.access(this,function(e){return e===t?x.text(this):this.empty().append((this[0]&&this[0].ownerDocument||a).createTextNode(e))},null,e,arguments.length)},append:function(){return this.domManip(arguments,function(e){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var t=Lt(this,e);t.appendChild(e)}})},prepend:function(){return this.domManip(arguments,function(e){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var t=Lt(this,e);t.insertBefore(e,t.firstChild)}})},before:function(){return this.domManip(arguments,function(e){this.parentNode&&this.parentNode.insertBefore(e,this)})},after:function(){return this.domManip(arguments,function(e){this.parentNode&&this.parentNode.insertBefore(e,this.nextSibling)})},remove:function(e,t){var n,r=e?x.filter(e,this):this,i=0;for(;null!=(n=r[i]);i++)t||1!==n.nodeType||x.cleanData(Ft(n)),n.parentNode&&(t&&x.contains(n.ownerDocument,n)&&_t(Ft(n,"script")),n.parentNode.removeChild(n));return this},empty:function(){var e,t=0;for(;null!=(e=this[t]);t++){1===e.nodeType&&x.cleanData(Ft(e,!1));while(e.firstChild)e.removeChild(e.firstChild);e.options&&x.nodeName(e,"select")&&(e.options.length=0)}return this},clone:function(e,t){return e=null==e?!1:e,t=null==t?e:t,this.map(function(){return x.clone(this,e,t)})},html:function(e){return x.access(this,function(e){var n=this[0]||{},r=0,i=this.length;if(e===t)return 1===n.nodeType?n.innerHTML.replace(gt,""):t;if(!("string"!=typeof e||Tt.test(e)||!x.support.htmlSerialize&&mt.test(e)||!x.support.leadingWhitespace&&yt.test(e)||At[(bt.exec(e)||["",""])[1].toLowerCase()])){e=e.replace(vt,"<$1>");try{for(;i>r;r++)n=this[r]||{},1===n.nodeType&&(x.cleanData(Ft(n,!1)),n.innerHTML=e);n=0}catch(o){}}n&&this.empty().append(e)},null,e,arguments.length)},replaceWith:function(){var e=x.map(this,function(e){return[e.nextSibling,e.parentNode]}),t=0;return this.domManip(arguments,function(n){var r=e[t++],i=e[t++];i&&(r&&r.parentNode!==i&&(r=this.nextSibling),x(this).remove(),i.insertBefore(n,r))},!0),t?this:this.remove()},detach:function(e){return this.remove(e,!0)},domManip:function(e,t,n){e=d.apply([],e);var r,i,o,a,s,l,u=0,c=this.length,p=this,f=c-1,h=e[0],g=x.isFunction(h);if(g||!(1>=c||"string"!=typeof h||x.support.checkClone)&&Nt.test(h))return this.each(function(r){var i=p.eq(r);g&&(e[0]=h.call(this,r,i.html())),i.domManip(e,t,n)});if(c&&(l=x.buildFragment(e,this[0].ownerDocument,!1,!n&&this),r=l.firstChild,1===l.childNodes.length&&(l=r),r)){for(a=x.map(Ft(l,"script"),Ht),o=a.length;c>u;u++)i=l,u!==f&&(i=x.clone(i,!0,!0),o&&x.merge(a,Ft(i,"script"))),t.call(this[u],i,u);if(o)for(s=a[a.length-1].ownerDocument,x.map(a,qt),u=0;o>u;u++)i=a[u],kt.test(i.type||"")&&!x._data(i,"globalEval")&&x.contains(s,i)&&(i.src?x._evalUrl(i.src):x.globalEval((i.text||i.textContent||i.innerHTML||"").replace(St,"")));l=r=null}return this}});function Lt(e,t){return x.nodeName(e,"table")&&x.nodeName(1===t.nodeType?t:t.firstChild,"tr")?e.getElementsByTagName("tbody")[0]||e.appendChild(e.ownerDocument.createElement("tbody")):e}function Ht(e){return e.type=(null!==x.find.attr(e,"type"))+"/"+e.type,e}function qt(e){var t=Et.exec(e.type);return t?e.type=t[1]:e.removeAttribute("type"),e}function _t(e,t){var n,r=0;for(;null!=(n=e[r]);r++)x._data(n,"globalEval",!t||x._data(t[r],"globalEval"))}function Mt(e,t){if(1===t.nodeType&&x.hasData(e)){var n,r,i,o=x._data(e),a=x._data(t,o),s=o.events;if(s){delete a.handle,a.events={};for(n in s)for(r=0,i=s[n].length;i>r;r++)x.event.add(t,n,s[n][r])}a.data&&(a.data=x.extend({},a.data))}}function Ot(e,t){var n,r,i;if(1===t.nodeType){if(n=t.nodeName.toLowerCase(),!x.support.noCloneEvent&&t[x.expando]){i=x._data(t);for(r in i.events)x.removeEvent(t,r,i.handle);t.removeAttribute(x.expando)}"script"===n&&t.text!==e.text?(Ht(t).text=e.text,qt(t)):"object"===n?(t.parentNode&&(t.outerHTML=e.outerHTML),x.support.html5Clone&&e.innerHTML&&!x.trim(t.innerHTML)&&(t.innerHTML=e.innerHTML)):"input"===n&&Ct.test(e.type)?(t.defaultChecked=t.checked=e.checked,t.value!==e.value&&(t.value=e.value)):"option"===n?t.defaultSelected=t.selected=e.defaultSelected:("input"===n||"textarea"===n)&&(t.defaultValue=e.defaultValue)}}x.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(e,t){x.fn[e]=function(e){var n,r=0,i=[],o=x(e),a=o.length-1;for(;a>=r;r++)n=r===a?this:this.clone(!0),x(o[r])[t](n),h.apply(i,n.get());return this.pushStack(i)}});function Ft(e,n){var r,o,a=0,s=typeof e.getElementsByTagName!==i?e.getElementsByTagName(n||"*"):typeof e.querySelectorAll!==i?e.querySelectorAll(n||"*"):t;if(!s)for(s=[],r=e.childNodes||e;null!=(o=r[a]);a++)!n||x.nodeName(o,n)?s.push(o):x.merge(s,Ft(o,n));return n===t||n&&x.nodeName(e,n)?x.merge([e],s):s}function Bt(e){Ct.test(e.type)&&(e.defaultChecked=e.checked)}x.extend({clone:function(e,t,n){var r,i,o,a,s,l=x.contains(e.ownerDocument,e);if(x.support.html5Clone||x.isXMLDoc(e)||!mt.test("<"+e.nodeName+">")?o=e.cloneNode(!0):(Dt.innerHTML=e.outerHTML,Dt.removeChild(o=Dt.firstChild)),!(x.support.noCloneEvent&&x.support.noCloneChecked||1!==e.nodeType&&11!==e.nodeType||x.isXMLDoc(e)))for(r=Ft(o),s=Ft(e),a=0;null!=(i=s[a]);++a)r[a]&&Ot(i,r[a]);if(t)if(n)for(s=s||Ft(e),r=r||Ft(o),a=0;null!=(i=s[a]);a++)Mt(i,r[a]);else Mt(e,o);return r=Ft(o,"script"),r.length>0&&_t(r,!l&&Ft(e,"script")),r=s=i=null,o},buildFragment:function(e,t,n,r){var i,o,a,s,l,u,c,p=e.length,f=dt(t),d=[],h=0;for(;p>h;h++)if(o=e[h],o||0===o)if("object"===x.type(o))x.merge(d,o.nodeType?[o]:o);else if(wt.test(o)){s=s||f.appendChild(t.createElement("div")),l=(bt.exec(o)||["",""])[1].toLowerCase(),c=At[l]||At._default,s.innerHTML=c[1]+o.replace(vt,"<$1>")+c[2],i=c[0];while(i--)s=s.lastChild;if(!x.support.leadingWhitespace&&yt.test(o)&&d.push(t.createTextNode(yt.exec(o)[0])),!x.support.tbody){o="table"!==l||xt.test(o)?""!==c[1]||xt.test(o)?0:s:s.firstChild,i=o&&o.childNodes.length;while(i--)x.nodeName(u=o.childNodes[i],"tbody")&&!u.childNodes.length&&o.removeChild(u)}x.merge(d,s.childNodes),s.textContent="";while(s.firstChild)s.removeChild(s.firstChild);s=f.lastChild}else d.push(t.createTextNode(o));s&&f.removeChild(s),x.support.appendChecked||x.grep(Ft(d,"input"),Bt),h=0;while(o=d[h++])if((!r||-1===x.inArray(o,r))&&(a=x.contains(o.ownerDocument,o),s=Ft(f.appendChild(o),"script"),a&&_t(s),n)){i=0;while(o=s[i++])kt.test(o.type||"")&&n.push(o)}return s=null,f},cleanData:function(e,t){var n,r,o,a,s=0,l=x.expando,u=x.cache,c=x.support.deleteExpando,f=x.event.special;for(;null!=(n=e[s]);s++)if((t||x.acceptData(n))&&(o=n[l],a=o&&u[o])){if(a.events)for(r in a.events)f[r]?x.event.remove(n,r):x.removeEvent(n,r,a.handle); -u[o]&&(delete u[o],c?delete n[l]:typeof n.removeAttribute!==i?n.removeAttribute(l):n[l]=null,p.push(o))}},_evalUrl:function(e){return x.ajax({url:e,type:"GET",dataType:"script",async:!1,global:!1,"throws":!0})}}),x.fn.extend({wrapAll:function(e){if(x.isFunction(e))return this.each(function(t){x(this).wrapAll(e.call(this,t))});if(this[0]){var t=x(e,this[0].ownerDocument).eq(0).clone(!0);this[0].parentNode&&t.insertBefore(this[0]),t.map(function(){var e=this;while(e.firstChild&&1===e.firstChild.nodeType)e=e.firstChild;return e}).append(this)}return this},wrapInner:function(e){return x.isFunction(e)?this.each(function(t){x(this).wrapInner(e.call(this,t))}):this.each(function(){var t=x(this),n=t.contents();n.length?n.wrapAll(e):t.append(e)})},wrap:function(e){var t=x.isFunction(e);return this.each(function(n){x(this).wrapAll(t?e.call(this,n):e)})},unwrap:function(){return this.parent().each(function(){x.nodeName(this,"body")||x(this).replaceWith(this.childNodes)}).end()}});var Pt,Rt,Wt,$t=/alpha\([^)]*\)/i,It=/opacity\s*=\s*([^)]*)/,zt=/^(top|right|bottom|left)$/,Xt=/^(none|table(?!-c[ea]).+)/,Ut=/^margin/,Vt=RegExp("^("+w+")(.*)$","i"),Yt=RegExp("^("+w+")(?!px)[a-z%]+$","i"),Jt=RegExp("^([+-])=("+w+")","i"),Gt={BODY:"block"},Qt={position:"absolute",visibility:"hidden",display:"block"},Kt={letterSpacing:0,fontWeight:400},Zt=["Top","Right","Bottom","Left"],en=["Webkit","O","Moz","ms"];function tn(e,t){if(t in e)return t;var n=t.charAt(0).toUpperCase()+t.slice(1),r=t,i=en.length;while(i--)if(t=en[i]+n,t in e)return t;return r}function nn(e,t){return e=t||e,"none"===x.css(e,"display")||!x.contains(e.ownerDocument,e)}function rn(e,t){var n,r,i,o=[],a=0,s=e.length;for(;s>a;a++)r=e[a],r.style&&(o[a]=x._data(r,"olddisplay"),n=r.style.display,t?(o[a]||"none"!==n||(r.style.display=""),""===r.style.display&&nn(r)&&(o[a]=x._data(r,"olddisplay",ln(r.nodeName)))):o[a]||(i=nn(r),(n&&"none"!==n||!i)&&x._data(r,"olddisplay",i?n:x.css(r,"display"))));for(a=0;s>a;a++)r=e[a],r.style&&(t&&"none"!==r.style.display&&""!==r.style.display||(r.style.display=t?o[a]||"":"none"));return e}x.fn.extend({css:function(e,n){return x.access(this,function(e,n,r){var i,o,a={},s=0;if(x.isArray(n)){for(o=Rt(e),i=n.length;i>s;s++)a[n[s]]=x.css(e,n[s],!1,o);return a}return r!==t?x.style(e,n,r):x.css(e,n)},e,n,arguments.length>1)},show:function(){return rn(this,!0)},hide:function(){return rn(this)},toggle:function(e){return"boolean"==typeof e?e?this.show():this.hide():this.each(function(){nn(this)?x(this).show():x(this).hide()})}}),x.extend({cssHooks:{opacity:{get:function(e,t){if(t){var n=Wt(e,"opacity");return""===n?"1":n}}}},cssNumber:{columnCount:!0,fillOpacity:!0,fontWeight:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{"float":x.support.cssFloat?"cssFloat":"styleFloat"},style:function(e,n,r,i){if(e&&3!==e.nodeType&&8!==e.nodeType&&e.style){var o,a,s,l=x.camelCase(n),u=e.style;if(n=x.cssProps[l]||(x.cssProps[l]=tn(u,l)),s=x.cssHooks[n]||x.cssHooks[l],r===t)return s&&"get"in s&&(o=s.get(e,!1,i))!==t?o:u[n];if(a=typeof r,"string"===a&&(o=Jt.exec(r))&&(r=(o[1]+1)*o[2]+parseFloat(x.css(e,n)),a="number"),!(null==r||"number"===a&&isNaN(r)||("number"!==a||x.cssNumber[l]||(r+="px"),x.support.clearCloneStyle||""!==r||0!==n.indexOf("background")||(u[n]="inherit"),s&&"set"in s&&(r=s.set(e,r,i))===t)))try{u[n]=r}catch(c){}}},css:function(e,n,r,i){var o,a,s,l=x.camelCase(n);return n=x.cssProps[l]||(x.cssProps[l]=tn(e.style,l)),s=x.cssHooks[n]||x.cssHooks[l],s&&"get"in s&&(a=s.get(e,!0,r)),a===t&&(a=Wt(e,n,i)),"normal"===a&&n in Kt&&(a=Kt[n]),""===r||r?(o=parseFloat(a),r===!0||x.isNumeric(o)?o||0:a):a}}),e.getComputedStyle?(Rt=function(t){return e.getComputedStyle(t,null)},Wt=function(e,n,r){var i,o,a,s=r||Rt(e),l=s?s.getPropertyValue(n)||s[n]:t,u=e.style;return s&&(""!==l||x.contains(e.ownerDocument,e)||(l=x.style(e,n)),Yt.test(l)&&Ut.test(n)&&(i=u.width,o=u.minWidth,a=u.maxWidth,u.minWidth=u.maxWidth=u.width=l,l=s.width,u.width=i,u.minWidth=o,u.maxWidth=a)),l}):a.documentElement.currentStyle&&(Rt=function(e){return e.currentStyle},Wt=function(e,n,r){var i,o,a,s=r||Rt(e),l=s?s[n]:t,u=e.style;return null==l&&u&&u[n]&&(l=u[n]),Yt.test(l)&&!zt.test(n)&&(i=u.left,o=e.runtimeStyle,a=o&&o.left,a&&(o.left=e.currentStyle.left),u.left="fontSize"===n?"1em":l,l=u.pixelLeft+"px",u.left=i,a&&(o.left=a)),""===l?"auto":l});function on(e,t,n){var r=Vt.exec(t);return r?Math.max(0,r[1]-(n||0))+(r[2]||"px"):t}function an(e,t,n,r,i){var o=n===(r?"border":"content")?4:"width"===t?1:0,a=0;for(;4>o;o+=2)"margin"===n&&(a+=x.css(e,n+Zt[o],!0,i)),r?("content"===n&&(a-=x.css(e,"padding"+Zt[o],!0,i)),"margin"!==n&&(a-=x.css(e,"border"+Zt[o]+"Width",!0,i))):(a+=x.css(e,"padding"+Zt[o],!0,i),"padding"!==n&&(a+=x.css(e,"border"+Zt[o]+"Width",!0,i)));return a}function sn(e,t,n){var r=!0,i="width"===t?e.offsetWidth:e.offsetHeight,o=Rt(e),a=x.support.boxSizing&&"border-box"===x.css(e,"boxSizing",!1,o);if(0>=i||null==i){if(i=Wt(e,t,o),(0>i||null==i)&&(i=e.style[t]),Yt.test(i))return i;r=a&&(x.support.boxSizingReliable||i===e.style[t]),i=parseFloat(i)||0}return i+an(e,t,n||(a?"border":"content"),r,o)+"px"}function ln(e){var t=a,n=Gt[e];return n||(n=un(e,t),"none"!==n&&n||(Pt=(Pt||x("'}c.style.display="none";c.removeAttribute("autoplay");return j},updateNative:function(a, -b){var c=a.htmlMediaElement,d;for(d in mejs.HtmlMediaElement)c[d]=mejs.HtmlMediaElement[d];b.success(c,c);return c}}; -mejs.YouTubeApi={isIframeStarted:false,isIframeLoaded:false,loadIframeApi:function(){if(!this.isIframeStarted){var a=document.createElement("script");a.src="//www.youtube.com/player_api";var b=document.getElementsByTagName("script")[0];b.parentNode.insertBefore(a,b);this.isIframeStarted=true}},iframeQueue:[],enqueueIframe:function(a){if(this.isLoaded)this.createIframe(a);else{this.loadIframeApi();this.iframeQueue.push(a)}},createIframe:function(a){var b=a.pluginMediaElement,c=new YT.Player(a.containerId, -{height:a.height,width:a.width,videoId:a.videoId,playerVars:{controls:0},events:{onReady:function(){a.pluginMediaElement.pluginApi=c;mejs.MediaPluginBridge.initPlugin(a.pluginId);setInterval(function(){mejs.YouTubeApi.createEvent(c,b,"timeupdate")},250)},onStateChange:function(d){mejs.YouTubeApi.handleStateChange(d.data,c,b)}}})},createEvent:function(a,b,c){c={type:c,target:b};if(a&&a.getDuration){b.currentTime=c.currentTime=a.getCurrentTime();b.duration=c.duration=a.getDuration();c.paused=b.paused; -c.ended=b.ended;c.muted=a.isMuted();c.volume=a.getVolume()/100;c.bytesTotal=a.getVideoBytesTotal();c.bufferedBytes=a.getVideoBytesLoaded();var d=c.bufferedBytes/c.bytesTotal*c.duration;c.target.buffered=c.buffered={start:function(){return 0},end:function(){return d},length:1}}b.dispatchEvent(c.type,c)},iFrameReady:function(){for(this.isIframeLoaded=this.isLoaded=true;this.iframeQueue.length>0;)this.createIframe(this.iframeQueue.pop())},flashPlayers:{},createFlash:function(a){this.flashPlayers[a.pluginId]= -a;var b,c="//www.youtube.com/apiplayer?enablejsapi=1&playerapiid="+a.pluginId+"&version=3&autoplay=0&controls=0&modestbranding=1&loop=0";if(mejs.MediaFeatures.isIE){b=document.createElement("div");a.container.appendChild(b);b.outerHTML=''}else a.container.innerHTML=''},flashReady:function(a){var b=this.flashPlayers[a],c= -document.getElementById(a),d=b.pluginMediaElement;d.pluginApi=d.pluginElement=c;mejs.MediaPluginBridge.initPlugin(a);c.cueVideoById(b.videoId);a=b.containerId+"_callback";window[a]=function(e){mejs.YouTubeApi.handleStateChange(e,c,d)};c.addEventListener("onStateChange",a);setInterval(function(){mejs.YouTubeApi.createEvent(c,d,"timeupdate")},250)},handleStateChange:function(a,b,c){switch(a){case -1:c.paused=true;c.ended=true;mejs.YouTubeApi.createEvent(b,c,"loadedmetadata");break;case 0:c.paused=false; -c.ended=true;mejs.YouTubeApi.createEvent(b,c,"ended");break;case 1:c.paused=false;c.ended=false;mejs.YouTubeApi.createEvent(b,c,"play");mejs.YouTubeApi.createEvent(b,c,"playing");break;case 2:c.paused=true;c.ended=false;mejs.YouTubeApi.createEvent(b,c,"pause");break;case 3:mejs.YouTubeApi.createEvent(b,c,"progress")}}};function onYouTubePlayerAPIReady(){mejs.YouTubeApi.iFrameReady()}function onYouTubePlayerReady(a){mejs.YouTubeApi.flashReady(a)}window.mejs=mejs;window.MediaElement=mejs.MediaElement; -(function(a,b){var c={locale:{language:"",strings:{}},methods:{}};c.locale.getLanguage=function(){return c.locale.language||navigator.language};if(typeof mejsL10n!="undefined")c.locale.language=mejsL10n.language;c.locale.INIT_LANGUAGE=c.locale.getLanguage();c.methods.checkPlain=function(d){var e,f,g={"&":"&",'"':""","<":"<",">":">"};d=String(d);for(e in g)if(g.hasOwnProperty(e)){f=RegExp(e,"g");d=d.replace(f,g[e])}return d};c.methods.formatString=function(d,e){for(var f in e){switch(f.charAt(0)){case "@":e[f]= -c.methods.checkPlain(e[f]);break;case "!":break;default:e[f]=''+c.methods.checkPlain(e[f])+""}d=d.replace(f,e[f])}return d};c.methods.t=function(d,e,f){if(c.locale.strings&&c.locale.strings[f.context]&&c.locale.strings[f.context][d])d=c.locale.strings[f.context][d];if(e)d=c.methods.formatString(d,e);return d};c.t=function(d,e,f){if(typeof d==="string"&&d.length>0){var g=c.locale.getLanguage();f=f||{context:g};return c.methods.t(d,e,f)}else throw{name:"InvalidArgumentException", -message:"First argument is either not a string or empty."};};b.i18n=c})(document,mejs);(function(a){if(typeof mejsL10n!="undefined")a[mejsL10n.language]=mejsL10n.strings})(mejs.i18n.locale.strings);(function(a){a.de={Fullscreen:"Vollbild","Go Fullscreen":"Vollbild an","Turn off Fullscreen":"Vollbild aus",Close:"Schlie\u00dfen"}})(mejs.i18n.locale.strings); -(function(a){a.zh={Fullscreen:"\u5168\u87a2\u5e55","Go Fullscreen":"\u5168\u5c4f\u6a21\u5f0f","Turn off Fullscreen":"\u9000\u51fa\u5168\u5c4f\u6a21\u5f0f",Close:"\u95dc\u9589"}})(mejs.i18n.locale.strings); diff --git a/lib/mediaelementjs/mediaelementplayer.css b/lib/mediaelementjs/mediaelementplayer.css deleted file mode 100644 index 5d88e84e5d..0000000000 --- a/lib/mediaelementjs/mediaelementplayer.css +++ /dev/null @@ -1 +0,0 @@ -.mejs-container{position:relative;background:#000;font-family:Helvetica,Arial;text-align:left;vertical-align:top;text-indent:0;}.me-plugin{position:absolute;}.mejs-embed,.mejs-embed body{width:100%;height:100%;margin:0;padding:0;background:#000;overflow:hidden;}.mejs-fullscreen{overflow:hidden!important;}.mejs-container-fullscreen{position:fixed;left:0;top:0;right:0;bottom:0;overflow:hidden;z-index:1000;}.mejs-container-fullscreen .mejs-mediaelement,.mejs-container-fullscreen video{width:100%;height:100%;}.mejs-clear{clear:both;}.mejs-background{position:absolute;top:0;left:0;}.mejs-mediaelement{position:absolute;top:0;left:0;width:100%;height:100%;}.mejs-poster{position:absolute;top:0;left:0;background-size:contain;background-position:50% 50%;background-repeat:no-repeat;}:root .mejs-poster img{display:none;}.mejs-poster img{border:0;padding:0;border:0;}.mejs-overlay{position:absolute;top:0;left:0;}.mejs-overlay-play{cursor:pointer;}.mejs-overlay-button{position:absolute;top:50%;left:50%;width:100px;height:100px;margin:-50px 0 0 -50px;background:url(bigplay.svg) no-repeat;}.no-svg .mejs-overlay-button{background-image:url(bigplay.png);}.mejs-overlay:hover .mejs-overlay-button{background-position:0 -100px;}.mejs-overlay-loading{position:absolute;top:50%;left:50%;width:80px;height:80px;margin:-40px 0 0 -40px;background:#333;background:url(background.png);background:rgba(0,0,0,0.9);background:-webkit-gradient(linear,0% 0,0% 100%,from(rgba(50,50,50,0.9)),to(rgba(0,0,0,0.9)));background:-webkit-linear-gradient(top,rgba(50,50,50,0.9),rgba(0,0,0,0.9));background:-moz-linear-gradient(top,rgba(50,50,50,0.9),rgba(0,0,0,0.9));background:-o-linear-gradient(top,rgba(50,50,50,0.9),rgba(0,0,0,0.9));background:-ms-linear-gradient(top,rgba(50,50,50,0.9),rgba(0,0,0,0.9));background:linear-gradient(rgba(50,50,50,0.9),rgba(0,0,0,0.9));}.mejs-overlay-loading span{display:block;width:80px;height:80px;background:transparent url(loading.gif) 50% 50% no-repeat;}.mejs-container .mejs-controls{position:absolute;list-style-type:none;margin:0;padding:0;bottom:0;left:0;background:url(background.png);background:rgba(0,0,0,0.7);background:-webkit-gradient(linear,0% 0,0% 100%,from(rgba(50,50,50,0.7)),to(rgba(0,0,0,0.7)));background:-webkit-linear-gradient(top,rgba(50,50,50,0.7),rgba(0,0,0,0.7));background:-moz-linear-gradient(top,rgba(50,50,50,0.7),rgba(0,0,0,0.7));background:-o-linear-gradient(top,rgba(50,50,50,0.7),rgba(0,0,0,0.7));background:-ms-linear-gradient(top,rgba(50,50,50,0.7),rgba(0,0,0,0.7));background:linear-gradient(rgba(50,50,50,0.7),rgba(0,0,0,0.7));height:30px;width:100%;}.mejs-container .mejs-controls div{list-style-type:none;background-image:none;display:block;float:left;margin:0;padding:0;width:26px;height:26px;font-size:11px;line-height:11px;font-family:Helvetica,Arial;border:0;}.mejs-controls .mejs-button button{cursor:pointer;display:block;font-size:0;line-height:0;text-decoration:none;margin:7px 5px;padding:0;position:absolute;height:16px;width:16px;border:0;background:transparent url(controls.svg) no-repeat;}.no-svg .mejs-controls .mejs-button button{background-image:url(controls.png);}.mejs-controls .mejs-button button:focus{outline:solid 1px yellow;}.mejs-container .mejs-controls .mejs-time{color:#fff;display:block;height:17px;width:auto;padding:8px 3px 0 3px;overflow:hidden;text-align:center;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;box-sizing:content-box;}.mejs-container .mejs-controls .mejs-time span{color:#fff;font-size:11px;line-height:12px;display:block;float:left;margin:1px 2px 0 0;width:auto;}.mejs-controls .mejs-play button{background-position:0 0;}.mejs-controls .mejs-pause button{background-position:0 -16px;}.mejs-controls .mejs-stop button{background-position:-112px 0;}.mejs-controls div.mejs-time-rail{direction:ltr;width:200px;padding-top:5px;}.mejs-controls .mejs-time-rail span{display:block;position:absolute;width:180px;height:10px;-webkit-border-radius:2px;-moz-border-radius:2px;border-radius:2px;cursor:pointer;}.mejs-controls .mejs-time-rail .mejs-time-total{margin:5px;background:#333;background:rgba(50,50,50,0.8);background:-webkit-gradient(linear,0% 0,0% 100%,from(rgba(30,30,30,0.8)),to(rgba(60,60,60,0.8)));background:-webkit-linear-gradient(top,rgba(30,30,30,0.8),rgba(60,60,60,0.8));background:-moz-linear-gradient(top,rgba(30,30,30,0.8),rgba(60,60,60,0.8));background:-o-linear-gradient(top,rgba(30,30,30,0.8),rgba(60,60,60,0.8));background:-ms-linear-gradient(top,rgba(30,30,30,0.8),rgba(60,60,60,0.8));background:linear-gradient(rgba(30,30,30,0.8),rgba(60,60,60,0.8));}.mejs-controls .mejs-time-rail .mejs-time-buffering{width:100%;background-image:-o-linear-gradient(-45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:-webkit-gradient(linear,0 100%,100% 0,color-stop(0.25,rgba(255,255,255,0.15)),color-stop(0.25,transparent),color-stop(0.5,transparent),color-stop(0.5,rgba(255,255,255,0.15)),color-stop(0.75,rgba(255,255,255,0.15)),color-stop(0.75,transparent),to(transparent));background-image:-webkit-linear-gradient(-45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:-moz-linear-gradient(-45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:-ms-linear-gradient(-45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:linear-gradient(-45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);-webkit-background-size:15px 15px;-moz-background-size:15px 15px;-o-background-size:15px 15px;background-size:15px 15px;-webkit-animation:buffering-stripes 2s linear infinite;-moz-animation:buffering-stripes 2s linear infinite;-ms-animation:buffering-stripes 2s linear infinite;-o-animation:buffering-stripes 2s linear infinite;animation:buffering-stripes 2s linear infinite;}@-webkit-keyframes buffering-stripes{from{background-position:0 0;}to{background-position:30px 0;}}@-moz-keyframes buffering-stripes{from{background-position:0 0;}to{background-position:30px 0;}}@-ms-keyframes buffering-stripes{from{background-position:0 0;}to{background-position:30px 0;}}@-o-keyframes buffering-stripes{from{background-position:0 0;}to{background-position:30px 0;}}@keyframes buffering-stripes{from{background-position:0 0;}to{background-position:30px 0;}}.mejs-controls .mejs-time-rail .mejs-time-loaded{background:#3caac8;background:rgba(60,170,200,0.8);background:-webkit-gradient(linear,0% 0,0% 100%,from(rgba(44,124,145,0.8)),to(rgba(78,183,212,0.8)));background:-webkit-linear-gradient(top,rgba(44,124,145,0.8),rgba(78,183,212,0.8));background:-moz-linear-gradient(top,rgba(44,124,145,0.8),rgba(78,183,212,0.8));background:-o-linear-gradient(top,rgba(44,124,145,0.8),rgba(78,183,212,0.8));background:-ms-linear-gradient(top,rgba(44,124,145,0.8),rgba(78,183,212,0.8));background:linear-gradient(rgba(44,124,145,0.8),rgba(78,183,212,0.8));width:0;}.mejs-controls .mejs-time-rail .mejs-time-current{background:#fff;background:rgba(255,255,255,0.8);background:-webkit-gradient(linear,0% 0,0% 100%,from(rgba(255,255,255,0.9)),to(rgba(200,200,200,0.8)));background:-webkit-linear-gradient(top,rgba(255,255,255,0.9),rgba(200,200,200,0.8));background:-moz-linear-gradient(top,rgba(255,255,255,0.9),rgba(200,200,200,0.8));background:-o-linear-gradient(top,rgba(255,255,255,0.9),rgba(200,200,200,0.8));background:-ms-linear-gradient(top,rgba(255,255,255,0.9),rgba(200,200,200,0.8));background:linear-gradient(rgba(255,255,255,0.9),rgba(200,200,200,0.8));width:0;}.mejs-controls .mejs-time-rail .mejs-time-handle{display:none;position:absolute;margin:0;width:10px;background:#fff;-webkit-border-radius:5px;-moz-border-radius:5px;border-radius:5px;cursor:pointer;border:solid 2px #333;top:-2px;text-align:center;}.mejs-controls .mejs-time-rail .mejs-time-float{position:absolute;display:none;background:#eee;width:36px;height:17px;border:solid 1px #333;top:-26px;margin-left:-18px;text-align:center;color:#111;}.mejs-controls .mejs-time-rail .mejs-time-float-current{margin:2px;width:30px;display:block;text-align:center;left:0;}.mejs-controls .mejs-time-rail .mejs-time-float-corner{position:absolute;display:block;width:0;height:0;line-height:0;border:solid 5px #eee;border-color:#eee transparent transparent transparent;-webkit-border-radius:0;-moz-border-radius:0;border-radius:0;top:15px;left:13px;}.mejs-long-video .mejs-controls .mejs-time-rail .mejs-time-float{width:48px;}.mejs-long-video .mejs-controls .mejs-time-rail .mejs-time-float-current{width:44px;}.mejs-long-video .mejs-controls .mejs-time-rail .mejs-time-float-corner{left:18px;}.mejs-controls .mejs-fullscreen-button button{background-position:-32px 0;}.mejs-controls .mejs-unfullscreen button{background-position:-32px -16px;}.mejs-controls .mejs-mute button{background-position:-16px -16px;}.mejs-controls .mejs-unmute button{background-position:-16px 0;}.mejs-controls .mejs-volume-button{position:relative;}.mejs-controls .mejs-volume-button .mejs-volume-slider{display:none;height:115px;width:25px;background:url(background.png);background:rgba(50,50,50,0.7);-webkit-border-radius:0;-moz-border-radius:0;border-radius:0;top:-115px;left:0;z-index:1;position:absolute;margin:0;}.mejs-controls .mejs-volume-button:hover{-webkit-border-radius:0 0 4px 4px;-moz-border-radius:0 0 4px 4px;border-radius:0 0 4px 4px;}.mejs-controls .mejs-volume-button .mejs-volume-slider .mejs-volume-total{position:absolute;left:11px;top:8px;width:2px;height:100px;background:#ddd;background:rgba(255,255,255,0.5);margin:0;}.mejs-controls .mejs-volume-button .mejs-volume-slider .mejs-volume-current{position:absolute;left:11px;top:8px;width:2px;height:100px;background:#ddd;background:rgba(255,255,255,0.9);margin:0;}.mejs-controls .mejs-volume-button .mejs-volume-slider .mejs-volume-handle{position:absolute;left:4px;top:-3px;width:16px;height:6px;background:#ddd;background:rgba(255,255,255,0.9);cursor:N-resize;-webkit-border-radius:1px;-moz-border-radius:1px;border-radius:1px;margin:0;}.mejs-controls div.mejs-horizontal-volume-slider{height:26px;width:60px;position:relative;}.mejs-controls .mejs-horizontal-volume-slider .mejs-horizontal-volume-total{position:absolute;left:0;top:11px;width:50px;height:8px;margin:0;padding:0;font-size:1px;-webkit-border-radius:2px;-moz-border-radius:2px;border-radius:2px;background:#333;background:rgba(50,50,50,0.8);background:-webkit-gradient(linear,0% 0,0% 100%,from(rgba(30,30,30,0.8)),to(rgba(60,60,60,0.8)));background:-webkit-linear-gradient(top,rgba(30,30,30,0.8),rgba(60,60,60,0.8));background:-moz-linear-gradient(top,rgba(30,30,30,0.8),rgba(60,60,60,0.8));background:-o-linear-gradient(top,rgba(30,30,30,0.8),rgba(60,60,60,0.8));background:-ms-linear-gradient(top,rgba(30,30,30,0.8),rgba(60,60,60,0.8));background:linear-gradient(rgba(30,30,30,0.8),rgba(60,60,60,0.8));}.mejs-controls .mejs-horizontal-volume-slider .mejs-horizontal-volume-current{position:absolute;left:0;top:11px;width:50px;height:8px;margin:0;padding:0;font-size:1px;-webkit-border-radius:2px;-moz-border-radius:2px;border-radius:2px;background:#fff;background:rgba(255,255,255,0.8);background:-webkit-gradient(linear,0% 0,0% 100%,from(rgba(255,255,255,0.9)),to(rgba(200,200,200,0.8)));background:-webkit-linear-gradient(top,rgba(255,255,255,0.9),rgba(200,200,200,0.8));background:-moz-linear-gradient(top,rgba(255,255,255,0.9),rgba(200,200,200,0.8));background:-o-linear-gradient(top,rgba(255,255,255,0.9),rgba(200,200,200,0.8));background:-ms-linear-gradient(top,rgba(255,255,255,0.9),rgba(200,200,200,0.8));background:linear-gradient(rgba(255,255,255,0.9),rgba(200,200,200,0.8));}.mejs-controls .mejs-horizontal-volume-slider .mejs-horizontal-volume-handle{display:none;}.mejs-controls .mejs-captions-button{position:relative;}.mejs-controls .mejs-captions-button button{background-position:-48px 0;}.mejs-controls .mejs-captions-button .mejs-captions-selector{visibility:hidden;position:absolute;bottom:26px;right:-10px;width:130px;height:100px;background:url(background.png);background:rgba(50,50,50,0.7);border:solid 1px transparent;padding:10px;overflow:hidden;-webkit-border-radius:0;-moz-border-radius:0;border-radius:0;}.mejs-controls .mejs-captions-button .mejs-captions-selector ul{margin:0;padding:0;display:block;list-style-type:none!important;overflow:hidden;}.mejs-controls .mejs-captions-button .mejs-captions-selector ul li{margin:0 0 6px 0;padding:0;list-style-type:none!important;display:block;color:#fff;overflow:hidden;}.mejs-controls .mejs-captions-button .mejs-captions-selector ul li input{clear:both;float:left;margin:3px 3px 0 5px;}.mejs-controls .mejs-captions-button .mejs-captions-selector ul li label{width:100px;float:left;padding:4px 0 0 0;line-height:15px;font-family:helvetica,arial;font-size:10px;}.mejs-controls .mejs-captions-button .mejs-captions-translations{font-size:10px;margin:0 0 5px 0;}.mejs-chapters{position:absolute;top:0;left:0;-xborder-right:solid 1px #fff;width:10000px;z-index:1;}.mejs-chapters .mejs-chapter{position:absolute;float:left;background:#222;background:rgba(0,0,0,0.7);background:-webkit-gradient(linear,0% 0,0% 100%,from(rgba(50,50,50,0.7)),to(rgba(0,0,0,0.7)));background:-webkit-linear-gradient(top,rgba(50,50,50,0.7),rgba(0,0,0,0.7));background:-moz-linear-gradient(top,rgba(50,50,50,0.7),rgba(0,0,0,0.7));background:-o-linear-gradient(top,rgba(50,50,50,0.7),rgba(0,0,0,0.7));background:-ms-linear-gradient(top,rgba(50,50,50,0.7),rgba(0,0,0,0.7));background:linear-gradient(rgba(50,50,50,0.7),rgba(0,0,0,0.7));filter:progid:DXImageTransform.Microsoft.Gradient(GradientType=0,startColorstr=#323232,endColorstr=#000000);overflow:hidden;border:0;}.mejs-chapters .mejs-chapter .mejs-chapter-block{font-size:11px;color:#fff;padding:5px;display:block;border-right:solid 1px #333;border-bottom:solid 1px #333;cursor:pointer;}.mejs-chapters .mejs-chapter .mejs-chapter-block-last{border-right:none;}.mejs-chapters .mejs-chapter .mejs-chapter-block:hover{background:#666;background:rgba(102,102,102,0.7);background:-webkit-gradient(linear,0% 0,0% 100%,from(rgba(102,102,102,0.7)),to(rgba(50,50,50,0.6)));background:-webkit-linear-gradient(top,rgba(102,102,102,0.7),rgba(50,50,50,0.6));background:-moz-linear-gradient(top,rgba(102,102,102,0.7),rgba(50,50,50,0.6));background:-o-linear-gradient(top,rgba(102,102,102,0.7),rgba(50,50,50,0.6));background:-ms-linear-gradient(top,rgba(102,102,102,0.7),rgba(50,50,50,0.6));background:linear-gradient(rgba(102,102,102,0.7),rgba(50,50,50,0.6));filter:progid:DXImageTransform.Microsoft.Gradient(GradientType=0,startColorstr=#666666,endColorstr=#323232);}.mejs-chapters .mejs-chapter .mejs-chapter-block .ch-title{font-size:12px;font-weight:bold;display:block;white-space:nowrap;text-overflow:ellipsis;margin:0 0 3px 0;line-height:12px;}.mejs-chapters .mejs-chapter .mejs-chapter-block .ch-timespan{font-size:12px;line-height:12px;margin:3px 0 4px 0;display:block;white-space:nowrap;text-overflow:ellipsis;}.mejs-captions-layer{position:absolute;bottom:0;left:0;text-align:center;line-height:22px;font-size:12px;color:#fff;}.mejs-captions-layer a{color:#fff;text-decoration:underline;}.mejs-captions-layer[lang=ar]{font-size:20px;font-weight:normal;}.mejs-captions-position{position:absolute;width:100%;bottom:15px;left:0;}.mejs-captions-position-hover{bottom:45px;}.mejs-captions-text{padding:3px 5px;background:url(background.png);background:rgba(20,20,20,0.8);}.me-cannotplay a{color:#fff;font-weight:bold;}.me-cannotplay span{padding:15px;display:block;}.mejs-controls .mejs-loop-off button{background-position:-64px -16px;}.mejs-controls .mejs-loop-on button{background-position:-64px 0;}.mejs-controls .mejs-backlight-off button{background-position:-80px -16px;}.mejs-controls .mejs-backlight-on button{background-position:-80px 0;}.mejs-controls .mejs-picturecontrols-button{background-position:-96px 0;}.mejs-contextmenu{position:absolute;width:150px;padding:10px;border-radius:4px;top:0;left:0;background:#fff;border:solid 1px #999;z-index:1001;}.mejs-contextmenu .mejs-contextmenu-separator{height:1px;font-size:0;margin:5px 6px;background:#333;}.mejs-contextmenu .mejs-contextmenu-item{font-family:Helvetica,Arial;font-size:12px;padding:4px 6px;cursor:pointer;color:#333;}.mejs-contextmenu .mejs-contextmenu-item:hover{background:#2C7C91;color:#fff;}.mejs-controls .mejs-sourcechooser-button{position:relative;}.mejs-controls .mejs-sourcechooser-button button{background-position:-128px 0;}.mejs-controls .mejs-sourcechooser-button .mejs-sourcechooser-selector{visibility:hidden;position:absolute;bottom:26px;right:-10px;width:130px;height:100px;background:url(background.png);background:rgba(50,50,50,0.7);border:solid 1px transparent;padding:10px;overflow:hidden;-webkit-border-radius:0;-moz-border-radius:0;border-radius:0;}.mejs-controls .mejs-sourcechooser-button .mejs-sourcechooser-selector ul{margin:0;padding:0;display:block;list-style-type:none!important;overflow:hidden;}.mejs-controls .mejs-sourcechooser-button .mejs-sourcechooser-selector ul li{margin:0 0 6px 0;padding:0;list-style-type:none!important;display:block;color:#fff;overflow:hidden;}.mejs-controls .mejs-sourcechooser-button .mejs-sourcechooser-selector ul li input{clear:both;float:left;margin:3px 3px 0 5px;}.mejs-controls .mejs-sourcechooser-button .mejs-sourcechooser-selector ul li label{width:100px;float:left;padding:4px 0 0 0;line-height:15px;font-family:helvetica,arial;font-size:10px;}.mejs-postroll-layer{position:absolute;bottom:0;left:0;width:100%;height:100%;background:url(background.png);background:rgba(50,50,50,0.7);z-index:1000;overflow:hidden;}.mejs-postroll-layer-content{width:100%;height:100%;}.mejs-postroll-close{position:absolute;right:0;top:0;background:url(background.png);background:rgba(50,50,50,0.7);color:#fff;padding:4px;z-index:100;cursor:pointer;} \ No newline at end of file diff --git a/lib/mediaelementjs/mediaelementplayer.js b/lib/mediaelementjs/mediaelementplayer.js deleted file mode 100644 index c26b9a0885..0000000000 --- a/lib/mediaelementjs/mediaelementplayer.js +++ /dev/null @@ -1,103 +0,0 @@ -/*! - * MediaElementPlayer - * http://mediaelementjs.com/ - * - * Creates a controller bar for HTML5 "> - +
@@ -70,17 +70,17 @@ class="g-avatar" @@ -89,7 +89,7 @@ class="g-avatar"
diff --git a/modules/comment/views/comment.html.php b/modules/comment/views/comment.html.php index 505bfb2f7d..9a8344bffb 100644 --- a/modules/comment/views/comment.html.php +++ b/modules/comment/views/comment.html.php @@ -8,21 +8,21 @@ class="g-avatar" width="40" height="40" /> - author()->guest): ?> + author()->guest): ?> gallery::date_time($comment->created), "name" => html::clean($comment->author_name()))) ?> - + %name said", array("date_time" => gallery::date_time($comment->created), "url" => user_profile::url($comment->author_id), "name" => html::clean($comment->author_name()))) ?> - +

text)) ?>
- state == "unpublished"): ?> + state == "unpublished"): ?> - + diff --git a/modules/comment/views/comment.mrss.php b/modules/comment/views/comment.mrss.php index 809e78908c..b5144e8dc5 100644 --- a/modules/comment/views/comment.mrss.php +++ b/modules/comment/views/comment.mrss.php @@ -1,5 +1,5 @@ -" ?> +" ?> en-us - previous_page_uri)): ?> + previous_page_uri)): ?> - - next_page_uri)): ?> + + next_page_uri)): ?> diff --git a/modules/comment/views/comments.html.php b/modules/comment/views/comments.html.php index 80072a33d8..8e08140d32 100644 --- a/modules/comment/views/comments.html.php +++ b/modules/comment/views/comments.html.php @@ -1,30 +1,30 @@ - + id}") ?>#comment-form" id="g-add-comment" class="g-button ui-corner-all ui-icon-left ui-state-default"> - +
- count()): ?> + count()): ?>

- + comment!", array("attrs" => html::mark_clean("href=\"" . url::site("form/add/comments/{$item->id}") . "\" class=\"showCommentForm\""))) ?> - + - +

  •  
- + - count()): ?> + count()): ?>
    - +
  • @@ -34,26 +34,26 @@ class="g-avatar" width="40" height="40" /> - author()->guest): ?> + author()->guest): ?> gallery::date_time($comment->created), "name" => html::clean($comment->author_name()))); ?> - + %name said', array("date" => gallery::date_time($comment->created), "url" => user_profile::url($comment->author_id), "name" => html::clean($comment->author_name()))); ?> - +

    text)) ?>
    - state == "unpublished"): ?> + state == "unpublished"): ?> - +
  • - +
- +
diff --git a/modules/comment/views/user_profile_comments.html.php b/modules/comment/views/user_profile_comments.html.php index 377b2d9568..64bbd4e824 100644 --- a/modules/comment/views/user_profile_comments.html.php +++ b/modules/comment/views/user_profile_comments.html.php @@ -1,7 +1,7 @@
    - +
  • text)) ?>

- +
diff --git a/modules/exif/lib/exif.php b/modules/exif/lib/exif.php index 8ba85c8ea9..7b5f21ae86 100644 --- a/modules/exif/lib/exif.php +++ b/modules/exif/lib/exif.php @@ -625,7 +625,7 @@ function formatData($type,$tag,$intel,$data) { case '9000': // ExifVersion case 'a000': // FlashPixVersion case '0002': // InteroperabilityVersion - $data=(string) t('version').' '.$data/100; + $data=(string) t('version').' '.($data && is_numeric($data) ? $data/100 : $data); break; case 'a300': // FileSource $data = bin2hex($data); @@ -1098,6 +1098,8 @@ function ConvertToFraction($v, &$n, &$d) function get35mmEquivFocalLength(&$result) { if (isset($result['SubIFD']['ExifImageWidth'])) { $width = $result['SubIFD']['ExifImageWidth']; + // some cameras have "XXXX pixels" + $width = str_replace(' pixels', '', $width); } else { $width = 0; } @@ -1120,6 +1122,8 @@ function get35mmEquivFocalLength(&$result) { } if (isset($result['SubIFD']['FocalLength'])) { $fl = $result['SubIFD']['FocalLength']; + // some values have " mm" appended + $fl = str_replace(' mm', '', $fl); } else { $fl = 0; } diff --git a/modules/exif/lib/makers/canon.php b/modules/exif/lib/makers/canon.php index aecd266dc8..8c306a3915 100644 --- a/modules/exif/lib/makers/canon.php +++ b/modules/exif/lib/makers/canon.php @@ -404,7 +404,7 @@ function parseCanon($block,&$result,$seek, $globalOffset) { $data = ''; } } - $result['SubIFD']['MakerNote'][$tag_name] = ''; // insure the index exists + $result['SubIFD']['MakerNote'][$tag_name] = array(); // insure the index exists $formated_data = formatCanonData($type,$tag,$intel,$data,$result,$result['SubIFD']['MakerNote'][$tag_name]); if($result['VerboseOutput']==1) { @@ -423,4 +423,4 @@ function parseCanon($block,&$result,$seek, $globalOffset) { } -?> \ No newline at end of file +?> diff --git a/modules/exif/lib/makers/gps.php b/modules/exif/lib/makers/gps.php index 462aae68d5..e69582c7a1 100644 --- a/modules/exif/lib/makers/gps.php +++ b/modules/exif/lib/makers/gps.php @@ -79,7 +79,7 @@ function formatGPSData($type,$tag,$intel,$data) { if($type=="ASCII") { if($tag=="0001" || $tag=="0003"){ // Latitude Reference, Longitude Reference - $data = ($data{1} == $data{2} && $data{1} == $data{3}) ? $data{0} : $data; + $data = ($data[1] == $data[2] && $data[1] == $data[3]) ? $data[0] : $data; } } else if($type=="URATIONAL" || $type=="SRATIONAL") { diff --git a/modules/exif/lib/makers/nikon.php b/modules/exif/lib/makers/nikon.php index d2fff9a2ec..c604accd55 100644 --- a/modules/exif/lib/makers/nikon.php +++ b/modules/exif/lib/makers/nikon.php @@ -119,7 +119,7 @@ function formatNikonData($type,$tag,$intel,$model,$data) { case "ASCII": break; // do nothing! case "URATIONAL": - case"SRATIONAL": + case "SRATIONAL": switch ($tag) { case '0084': // LensInfo $minFL = unRational(substr($data,0,8),$type,$intel); @@ -229,7 +229,7 @@ function formatNikonData($type,$tag,$intel,$model,$data) { case "UNDEFINED": switch ($tag) { case "0001": - if ($model==1) $data=$data/100; break; //Unknown (Version?) + if ($model==1) $data=(int)$data/100; break; //Unknown (Version?) break; case "0088": if ($model==1) { //AF Focus Position @@ -408,4 +408,4 @@ function parseNikon($block,&$result) { } -?> \ No newline at end of file +?> diff --git a/modules/exif/views/exif_dialog.html.php b/modules/exif/views/exif_dialog.html.php index 22744e2da3..0eacadc2e1 100644 --- a/modules/exif/views/exif_dialog.html.php +++ b/modules/exif/views/exif_dialog.html.php @@ -8,7 +8,7 @@
- + - + - + - + - +
diff --git a/modules/g2_import/helpers/g2_import.php b/modules/g2_import/helpers/g2_import.php index 82850e856a..021ee03eb2 100644 --- a/modules/g2_import/helpers/g2_import.php +++ b/modules/g2_import/helpers/g2_import.php @@ -439,7 +439,8 @@ static function import_album(&$queue) { // the time we get to the child. // Dequeue the current album and enqueue its children - list($g2_album_id, $children) = each($queue); + $g2_album_id = key($queue); + $children = current($queue); unset($queue[$g2_album_id]); foreach ($children as $key => $value) { $queue[$key] = $value; @@ -543,7 +544,8 @@ static function set_album_values($album, $g2_album) { */ static function set_album_highlight(&$queue) { // Dequeue the current album and enqueue its children - list($g2_album_id, $children) = each($queue); + $g2_album_id = key($queue); + $children = current($queue); unset($queue[$g2_album_id]); if (!empty($children)) { foreach ($children as $key => $value) { diff --git a/modules/g2_import/views/admin_g2_import.html.php b/modules/g2_import/views/admin_g2_import.html.php index adde83cefd..bcc7a521df 100644 --- a/modules/g2_import/views/admin_g2_import.html.php +++ b/modules/g2_import/views/admin_g2_import.html.php @@ -16,14 +16,14 @@ "; +class Form_Dropzone_buttons_Core extends Form_Input { + public function render() { + $v = new View("form_dropzone_buttons.html"); + return $v; } } diff --git a/modules/gallery/libraries/Gallery_I18n.php b/modules/gallery/libraries/Gallery_I18n.php index 6b216a2946..96f45e4960 100644 --- a/modules/gallery/libraries/Gallery_I18n.php +++ b/modules/gallery/libraries/Gallery_I18n.php @@ -253,7 +253,8 @@ private function pluralize($locale, $entry, $count) { return $entry[$plural_key]; } else { // Fallback to just any plural form. - list ($plural_key, $string) = each($entry); + $plural_key = key($entry); + $string = current($entry); return $string; } } diff --git a/modules/gallery/libraries/MY_Database.php b/modules/gallery/libraries/MY_Database.php index 33759b673c..531e244a2f 100644 --- a/modules/gallery/libraries/MY_Database.php +++ b/modules/gallery/libraries/MY_Database.php @@ -95,7 +95,8 @@ static function set_default_instance($db) { * and \ (the escape character itself). */ static function escape_for_like($value) { + if (is_null($value)) return ''; // backslash must go first to avoid double-escaping return addcslashes($value, '\_%'); } -} \ No newline at end of file +} diff --git a/modules/gallery/libraries/MY_Database_Mysql.php b/modules/gallery/libraries/MY_Database_Mysql.php new file mode 100644 index 0000000000..2f7cdb613d --- /dev/null +++ b/modules/gallery/libraries/MY_Database_Mysql.php @@ -0,0 +1,35 @@ +connection) + return; + + if (!function_exists('mysql_connect')) { + $msg = 'You configured your DB to use the "mysql" module but the PHP mysql module doesn\'t appear to be installed. If you are upgrading to PHP 7 you should update var/database.php to use the mysqli module instead of mysql.'; + print $msg; + throw new Kohana_Exception($msg); + } + + return parent::connect(); + } +} diff --git a/modules/gallery/libraries/MY_Kohana_Exception.php b/modules/gallery/libraries/MY_Kohana_Exception.php index 51490a6ced..f179cd7db4 100644 --- a/modules/gallery/libraries/MY_Kohana_Exception.php +++ b/modules/gallery/libraries/MY_Kohana_Exception.php @@ -52,7 +52,7 @@ public static function safe_dump($value, $key, $length=128, $max_level=5) { * Elides sensitive data which shouldn't be echoed to the client, * such as passwords, and other secrets. */ - /* Visible for testing*/ static function _sanitize_for_dump($value, $key=null, $max_level) { + /* Visible for testing*/ static function _sanitize_for_dump($value, $key, $max_level) { // Better elide too much than letting something through. // Note: unanchored match is intended. if (!$max_level) { @@ -62,7 +62,7 @@ public static function safe_dump($value, $key, $length=128, $max_level=5) { $sensitive_info_pattern = '/(password|pass|email|hash|private_key|session_id|session|g3sid|csrf|secret)/i'; - if (preg_match($sensitive_info_pattern, $key) || + if ((!empty($key) && preg_match($sensitive_info_pattern, $key)) || (is_string($value) && preg_match('/[a-f0-9]{20,}/i', $value))) { return 'removed for display'; } else if (is_object($value)) { @@ -98,4 +98,4 @@ public static function safe_dump($value, $key, $length=128, $max_level=5) { public static function debug_path($file) { return html::clean(parent::debug_path($file)); } -} \ No newline at end of file +} diff --git a/modules/gallery/libraries/MY_ORM.php b/modules/gallery/libraries/MY_ORM.php index 6e538d544e..a0ff02377c 100644 --- a/modules/gallery/libraries/MY_ORM.php +++ b/modules/gallery/libraries/MY_ORM.php @@ -42,11 +42,13 @@ class ORM_Iterator extends ORM_Iterator_Core { /** * Cache the result row */ - public function current() { + #[\ReturnTypeWillChange] + public function current() + { $row = parent::current(); if (is_object($row)) { model_cache::set($row); } return $row; } -} \ No newline at end of file +} diff --git a/modules/gallery/libraries/ORM_MPTT.php b/modules/gallery/libraries/ORM_MPTT.php index 0ad81331aa..7ac1092a79 100644 --- a/modules/gallery/libraries/ORM_MPTT.php +++ b/modules/gallery/libraries/ORM_MPTT.php @@ -325,7 +325,7 @@ protected function move_to($target) { * Lock the tree to prevent concurrent modification. */ protected function lock() { - $timeout = module::get_var("gallery", "lock_timeout", 1); + $timeout = module::get_var("gallery", "lock_timeout", 3); $result = $this->db->query("SELECT GET_LOCK('{$this->table_name}', $timeout) AS l")->current(); if (empty($result->l)) { throw new Exception("@todo UNABLE_TO_LOCK_EXCEPTION"); diff --git a/modules/gallery/models/item.php b/modules/gallery/models/item.php index 2dbd99bb24..70e69faf73 100644 --- a/modules/gallery/models/item.php +++ b/modules/gallery/models/item.php @@ -285,8 +285,8 @@ private function _build_relative_caches() { $names[] = rawurlencode($row->name); $slugs[] = rawurlencode($row->slug); } - $this->relative_path_cache = implode($names, "/"); - $this->relative_url_cache = implode($slugs, "/"); + $this->relative_path_cache = implode("/", $names); + $this->relative_url_cache = implode("/", $slugs); return $this; } @@ -381,7 +381,8 @@ public function save() { // Make an url friendly slug from the name, if necessary if (empty($this->slug)) { - $this->slug = item::convert_filename_to_slug(pathinfo($this->name, PATHINFO_FILENAME)); + $path_info = $this->name ? pathinfo($this->name, PATHINFO_FILENAME) : ''; + $this->slug = $path_info ? item::convert_filename_to_slug(pathinfo($this->name, PATHINFO_FILENAME)) : ''; // If the filename is all invalid characters, then the slug may be empty here. We set a // generic name ("photo", "movie", or "album") based on its type, then rely on @@ -577,7 +578,7 @@ private function _check_and_fix_conflicts() { } else { // Split the filename into its base and extension. This uses a regexp similar to // legal_file::change_extension (which isn't always the same as pathinfo). - if (preg_match("/^(.*)(\.[^\.\/]*?)$/", $this->name, $matches)) { + if ($this->name && preg_match("/^(.*)(\.[^\.\/]*?)$/", $this->name, $matches)) { $base_name = $matches[1]; $extension = $matches[2]; // includes a leading dot } else { diff --git a/modules/gallery/module.info b/modules/gallery/module.info index 49023e45a2..7c29bf4d73 100644 --- a/modules/gallery/module.info +++ b/modules/gallery/module.info @@ -1,6 +1,6 @@ name = "Gallery 3" description = "Gallery core application" -version = 58 +version = 59 author_name = "Gallery Team" author_url = "http://codex.galleryproject.org/Gallery:Team" info_url = "http://codex.galleryproject.org/Gallery3:Modules:gallery" diff --git a/modules/gallery/tests/File_Structure_Test.php b/modules/gallery/tests/File_Structure_Test.php index e42f7dcdcb..63bf29d392 100644 --- a/modules/gallery/tests/File_Structure_Test.php +++ b/modules/gallery/tests/File_Structure_Test.php @@ -25,6 +25,8 @@ public function no_trailing_closing_php_tag_test() { new RecursiveIteratorIterator(new RecursiveDirectoryIterator(DOCROOT))); $count = 0; foreach ($dir as $file) { + if (preg_match("#(vendor|test|\.cache)/#", $file)) continue; + $count++; if (!preg_match("|\.html\.php$|", $file->getPathname())) { $this->assert_false( @@ -57,7 +59,9 @@ public function no_windows_line_endings_test() { $dir = new GalleryCodeFilterIterator( new RecursiveIteratorIterator(new RecursiveDirectoryIterator(DOCROOT))); foreach ($dir as $file) { - if (preg_match("/\.(php|css|html|js)$/", $file)) { + if (preg_match("#(vendor|test|\.cache)/#", $file)) { + continue; + } elseif (preg_match("/\.(php|css|html|js)$/", $file)) { foreach (file($file) as $line) { $this->assert_true(substr($line, -2) != "\r\n", "$file has windows style line endings"); } @@ -177,16 +181,20 @@ public function code_files_start_with_preamble_test() { case DOCROOT . "lib/uploadify/uploadify.swf.php": case DOCROOT . "lib/uploadify/uploadify.allglyphs.swf.php": - case DOCROOT . "lib/mediaelementjs/flashmediaelement.swf.php": // SWF wrappers - directly accessible break; + case DOCROOT . "lib/preload_opcache.php": case DOCROOT . "local.php": // Special case optional file, not part of the codebase break; default: - if (preg_match("/views/", $path)) { + if (preg_match("#(vendor|test|\.cache)/#", $path)) { + # including unmodified 3rd party code + } elseif (preg_match("/modules\/(autorotate|movie_resized)/", $path)) { + # including unmodified 3rd party code + } elseif (preg_match("/views/", $path)) { $this->_check_view_preamble($path, $errors); } else { $this->_check_php_preamble($path, $errors); @@ -206,6 +214,8 @@ public function no_tabs_in_our_code_test() { new RecursiveDirectoryIterator(DOCROOT)))); $errors = array(); foreach ($dir as $file) { + if (preg_match("#/(vendor|\.cache)/#", $file)) continue; + $file_as_string = file_get_contents($file); if (preg_match('/\t/', $file_as_string)) { foreach (explode("\n", $file_as_string) as $l => $line) { @@ -327,7 +337,9 @@ public function no_extra_spaces_at_end_of_line_test() { new RecursiveIteratorIterator(new RecursiveDirectoryIterator(DOCROOT))); $errors = ""; foreach ($dir as $file) { - if (preg_match("/\.(php|css|html|js)$/", $file)) { + if (preg_match("#(vendor|test|\.cache)/#", $file)) { + continue; + } elseif (preg_match("/\.(php|css|html|js)$/", $file)) { foreach (file($file) as $line_num => $line) { if ((substr($line, -2) == " \n") || (substr($line, -1) == " ")) { $errors .= "$file at line " . ($line_num + 1) . "\n"; diff --git a/modules/gallery/tests/Gallery_Filters.php b/modules/gallery/tests/Gallery_Filters.php index 6c2a6aa3cc..64817ce874 100644 --- a/modules/gallery/tests/Gallery_Filters.php +++ b/modules/gallery/tests/Gallery_Filters.php @@ -18,14 +18,14 @@ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ class PhpCodeFilterIterator extends FilterIterator { - public function accept() { + public function accept(): bool { $path_name = $this->getInnerIterator()->getPathName(); return substr($path_name, -4) == ".php"; } } class GalleryCodeFilterIterator extends FilterIterator { - public function accept() { + public function accept(): bool { // Skip anything that we didn't write $path_name = $this->getInnerIterator()->getPathName(); $file_name = $this->getInnerIterator()->getFileName(); diff --git a/modules/gallery/tests/Gallery_I18n_Test.php b/modules/gallery/tests/Gallery_I18n_Test.php index e255c4b989..4b05c01ad2 100644 --- a/modules/gallery/tests/Gallery_I18n_Test.php +++ b/modules/gallery/tests/Gallery_I18n_Test.php @@ -62,6 +62,7 @@ public function set_locale_test() { $this->i18n->locale("de_DE"); $locale = $this->i18n->locale(); $this->assert_equal("de_DE", $locale); + $this->i18n->locale("en_US"); } public function translate_simple_test() { @@ -106,4 +107,4 @@ public function translate_plural_zero_test() { array('count' => 0)); $this->assert_equal('0 Elemente wurden hinzugefuegt.', $result); } -} \ No newline at end of file +} diff --git a/modules/gallery/tests/Graphics_Helper_Test.php b/modules/gallery/tests/Graphics_Helper_Test.php index 2cf5caa762..28e2634039 100644 --- a/modules/gallery/tests/Graphics_Helper_Test.php +++ b/modules/gallery/tests/Graphics_Helper_Test.php @@ -155,4 +155,4 @@ public function generate_album_cover_from_bad_photo_test() { // Check that the images are marked as dirty $this->assert_equal(1, $album->thumb_dirty); } -} \ No newline at end of file +} diff --git a/modules/gallery/tests/Legal_File_Helper_Test.php b/modules/gallery/tests/Legal_File_Helper_Test.php index aab41c413d..74f787abc0 100644 --- a/modules/gallery/tests/Legal_File_Helper_Test.php +++ b/modules/gallery/tests/Legal_File_Helper_Test.php @@ -26,7 +26,7 @@ public function get_photo_types_by_extension_test() { $this->assert_equal(null, legal_file::get_photo_types_by_extension("php.jpg")); // invalid w/ . // No extension returns full array - $this->assert_equal(4, count(legal_file::get_photo_types_by_extension())); + $this->assert_equal(5, count(legal_file::get_photo_types_by_extension())); } public function get_movie_types_by_extension_test() { @@ -47,7 +47,7 @@ public function get_types_by_extension_test() { $this->assert_equal(null, legal_file::get_types_by_extension("php.flv")); // invalid w/ . // No extension returns full array - $this->assert_equal(9, count(legal_file::get_types_by_extension())); + $this->assert_equal(10, count(legal_file::get_types_by_extension())); } public function get_photo_extensions_test() { @@ -58,7 +58,7 @@ public function get_photo_extensions_test() { $this->assert_equal(false, legal_file::get_photo_extensions("php.jpg")); // invalid w/ . // No extension returns full array - $this->assert_equal(4, count(legal_file::get_photo_extensions())); + $this->assert_equal(5, count(legal_file::get_photo_extensions())); } public function get_movie_extensions_test() { @@ -79,17 +79,17 @@ public function get_extensions_test() { $this->assert_equal(false, legal_file::get_extensions("php.jpg")); // invalid w/ . // No extension returns full array - $this->assert_equal(9, count(legal_file::get_extensions())); + $this->assert_equal(10, count(legal_file::get_extensions())); } public function get_filters_test() { // All 9 extensions both uppercase and lowercase - $this->assert_equal(18, count(legal_file::get_filters())); + $this->assert_equal(20, count(legal_file::get_filters())); } public function get_photo_types_test() { // Note that this is one *less* than photo extensions since jpeg and jpg have the same mime. - $this->assert_equal(3, count(legal_file::get_photo_types())); + $this->assert_equal(4, count(legal_file::get_photo_types())); } public function get_movie_types_test() { @@ -184,8 +184,17 @@ public function sanitize_filename_with_no_base_name_test() { } public function sanitize_filename_with_invalid_arguments_test() { - foreach (array("flv" => "photo", "jpg" => "movie", "php" => "photo", - null => "movie", "jpg" => "album", "jpg" => null) as $extension => $type) { + $types = array( + array("flv", "photo"), + array("jpg", "movie"), + array("php", "photo"), + array(null, "movie"), + array("jpg", "album"), + array("jpg", null), + ); + + foreach ($types as $ary) { + list($extension, $type) = $ary; try { legal_file::sanitize_filename("foo.jpg", $extension, $type); $this->assert_true(false, "Shouldn't get here"); @@ -212,4 +221,4 @@ public function sanitize_filename_with_corrections_test() { $this->assert_equal("album", legal_file::sanitize_dirname("_")); $this->assert_equal("album", legal_file::sanitize_dirname(null)); } -} \ No newline at end of file +} diff --git a/modules/gallery/tests/Var_Test.php b/modules/gallery/tests/Var_Test.php index 97bccc35d0..a29521c757 100644 --- a/modules/gallery/tests/Var_Test.php +++ b/modules/gallery/tests/Var_Test.php @@ -41,7 +41,7 @@ public function clear_all_module_parameters_test() { } public function incr_parameter_test() { - module::set_var("Var_Test", "Parameter", "original value"); + module::set_var("Var_Test", "Parameter", "0"); module::incr_var("Var_Test", "Parameter"); $this->assert_equal("1", module::get_var("Var_Test", "Parameter")); @@ -52,4 +52,4 @@ public function incr_parameter_test() { module::incr_var("Var_Test", "NonExistent", "9"); $this->assert_equal(null, module::get_var("Var_Test", "NonExistent")); } -} \ No newline at end of file +} diff --git a/modules/gallery/tests/Xss_Security_Test.php b/modules/gallery/tests/Xss_Security_Test.php index 6f78bb6f41..5b832442f2 100644 --- a/modules/gallery/tests/Xss_Security_Test.php +++ b/modules/gallery/tests/Xss_Security_Test.php @@ -349,7 +349,7 @@ public function find_unescaped_variables_in_views_test() { $canonical = MODPATH . "gallery/tests/xss_data.txt"; exec("diff $canonical $new", $output, $return_value); $this->assert_false( - $return_value, "XSS golden file mismatch. Output:\n" . implode("\n", $output) ); + boolval($return_value), "XSS golden file mismatch. Output:\n" . implode("\n", $output) ); } private static function _create_frame($token, $in_script_block, diff --git a/modules/gallery/tests/xss_data.txt b/modules/gallery/tests/xss_data.txt index 25abdc9eee..18c105abff 100644 --- a/modules/gallery/tests/xss_data.txt +++ b/modules/gallery/tests/xss_data.txt @@ -5,7 +5,7 @@ modules/comment/views/admin_block_recent_comments.html.php 4 DIRTY_ATTR text modules/comment/views/admin_block_recent_comments.html.php 5 DIRTY_ATTR $comment->author()->avatar_url(32,$theme->url(,true)) modules/comment/views/admin_block_recent_comments.html.php 10 DIRTY gallery::date_time($comment->created) modules/comment/views/admin_comments.html.php 5 DIRTY $form -modules/comment/views/admin_manage_comments.html.php 45 DIRTY $menu->render() +modules/comment/views/admin_manage_comments.html.php 60 DIRTY $menu->render() modules/comment/views/admin_manage_comments_queue.html.php 40 DIRTY $theme->paginator() modules/comment/views/admin_manage_comments_queue.html.php 55 DIRTY_ATTR $comment->id modules/comment/views/admin_manage_comments_queue.html.php 55 DIRTY_ATTR text::alternate("g-odd","g-even") @@ -78,7 +78,7 @@ modules/gallery/views/admin_languages.html.php 61 DIRTY_ATTR ($de modules/gallery/views/admin_languages.html.php 62 DIRTY form::checkbox("installed_locales[]",$code,isset($installed_locales[$code])) modules/gallery/views/admin_languages.html.php 63 DIRTY $display_name modules/gallery/views/admin_languages.html.php 65 DIRTY form::radio("default_locale",$code,($default_locale==$code),((isset($installed_locales[$code]))?'':'disabled="disabled"')) -modules/gallery/views/admin_languages.html.php 113 DIRTY $share_translations_form +modules/gallery/views/admin_languages.html.php 114 DIRTY $share_translations_form modules/gallery/views/admin_maintenance.html.php 42 DIRTY_ATTR text::alternate("g-odd","g-even") modules/gallery/views/admin_maintenance.html.php 42 DIRTY_ATTR log::severity_class($task->severity) modules/gallery/views/admin_maintenance.html.php 43 DIRTY_ATTR log::severity_class($task->severity) @@ -180,6 +180,10 @@ modules/gallery/views/error_admin.html.php 285 DIRTY_JS $env_i modules/gallery/views/error_admin.html.php 285 DIRTY $var modules/gallery/views/error_admin.html.php 286 DIRTY_ATTR $env_id modules/gallery/views/error_admin.html.php 296 DIRTY Kohana_Exception::safe_dump($value,$key) +modules/gallery/views/form_dropzone.html.php 18 DIRTY_JS $simultaneous_upload_limit +modules/gallery/views/form_dropzone.html.php 19 DIRTY_JS implode(",",$extensions) +modules/gallery/views/form_dropzone.html.php 20 DIRTY_JS $size_limit_megs +modules/gallery/views/form_dropzone.html.php 23 DIRTY_JS url::site("uploader/add_photo/{$album->id}") modules/gallery/views/form_uploadify.html.php 16 DIRTY_JS url::site("uploader/status/_S/_E") modules/gallery/views/form_uploadify.html.php 24 DIRTY_JS $flash_minimum_version modules/gallery/views/form_uploadify.html.php 28 DIRTY_JS url::file("lib/uploadify/uploadify.swf.php") @@ -225,12 +229,8 @@ modules/gallery/views/menu_link.html.php 3 DIRTY $menu- modules/gallery/views/menu_link.html.php 4 DIRTY_ATTR $menu->css_class modules/gallery/views/menu_link.html.php 5 DIRTY_JS $menu->url modules/gallery/views/movieplayer.html.php 2 DIRTY html::attributes($div_attrs) +modules/gallery/views/movieplayer.html.php 3 DIRTY html::attributes($source_attrs) modules/gallery/views/movieplayer.html.php 3 DIRTY html::attributes($video_attrs) -modules/gallery/views/movieplayer.html.php 4 DIRTY html::attributes($source_attrs) -modules/gallery/views/movieplayer.html.php 8 DIRTY_JS $div_attrs["id"] -modules/gallery/views/movieplayer.html.php 10 DIRTY_JS $width -modules/gallery/views/movieplayer.html.php 11 DIRTY_JS $height -modules/gallery/views/movieplayer.html.php 14 DIRTY_JS url::abs_file("lib/mediaelementjs/") modules/gallery/views/permissions_browse.html.php 3 DIRTY_JS url::site("permissions/form/__ITEM__") modules/gallery/views/permissions_browse.html.php 16 DIRTY_JS url::site("permissions/change/__CMD__/__GROUP__/__PERM__/__ITEM__?csrf=$csrf") modules/gallery/views/permissions_browse.html.php 43 DIRTY_ATTR $parent->id @@ -313,6 +313,7 @@ modules/organize/views/organize_frame.html.php 575 DIRTY_JS html:: modules/organize/views/organize_frame.html.php 577 DIRTY_JS item::root()->id modules/organize/views/organize_frame.html.php 585 DIRTY_JS $album->id modules/organize/views/organize_frame.html.php 586 DIRTY_JS $album->id +modules/phpmailer/views/admin_phpmailer.html.php 7 DIRTY $phpmailer_form modules/recaptcha/views/admin_recaptcha.html.php 11 DIRTY $form modules/recaptcha/views/admin_recaptcha.html.php 23 DIRTY_JS $public_key modules/recaptcha/views/form_recaptcha.html.php 3 DIRTY_ATTR request::protocol() @@ -411,6 +412,53 @@ themes/admin_wind/views/paginator.html.php 35 DIRTY_JS $first themes/admin_wind/views/paginator.html.php 44 DIRTY_JS $previous_page_url themes/admin_wind/views/paginator.html.php 70 DIRTY_JS $next_page_url themes/admin_wind/views/paginator.html.php 79 DIRTY_JS $last_page_url +themes/widewind/views/album.html.php 19 DIRTY_ATTR $child->id +themes/widewind/views/album.html.php 19 DIRTY_ATTR $item_class +themes/widewind/views/album.html.php 21 DIRTY_JS $child->url() +themes/widewind/views/album.html.php 23 DIRTY $child->thumb_img(array("class"=>"g-thumbnail")) +themes/widewind/views/album.html.php 28 DIRTY_ATTR $item_class +themes/widewind/views/album.html.php 29 DIRTY_JS $child->url() +themes/widewind/views/album.html.php 47 DIRTY $theme->paginator() +themes/widewind/views/block.html.php 3 DIRTY_ATTR $anchor +themes/widewind/views/block.html.php 5 DIRTY_ATTR $css_id +themes/widewind/views/block.html.php 6 DIRTY $title +themes/widewind/views/block.html.php 8 DIRTY $content +themes/widewind/views/dynamic.html.php 11 DIRTY_ATTR $child->is_album()?"g-album":"" +themes/widewind/views/dynamic.html.php 13 DIRTY_JS $child->url() +themes/widewind/views/dynamic.html.php 14 DIRTY_ATTR $child->id +themes/widewind/views/dynamic.html.php 15 DIRTY_ATTR $child->thumb_url() +themes/widewind/views/dynamic.html.php 16 DIRTY_ATTR $child->thumb_width +themes/widewind/views/dynamic.html.php 17 DIRTY_ATTR $child->thumb_height +themes/widewind/views/dynamic.html.php 29 DIRTY $theme->paginator() +themes/widewind/views/movie.html.php 5 DIRTY $theme->paginator() +themes/widewind/views/movie.html.php 9 DIRTY $item->movie_img(array("class"=>"g-movie","id"=>"g-item-id-{$item->id}")) +themes/widewind/views/page.html.php 4 DIRTY $theme->html_attributes() +themes/widewind/views/page.html.php 10 DIRTY $page_title +themes/widewind/views/page.html.php 32 DIRTY $new_width +themes/widewind/views/page.html.php 33 DIRTY $new_height +themes/widewind/views/page.html.php 34 DIRTY $thumb_proportion +themes/widewind/views/page.html.php 73 DIRTY_JS $theme->url() +themes/widewind/views/page.html.php 78 DIRTY $theme->get_combined("css") +themes/widewind/views/page.html.php 81 DIRTY $theme->get_combined("script") +themes/widewind/views/page.html.php 91 DIRTY $header_text +themes/widewind/views/page.html.php 93 DIRTY_JS item::root()->url() +themes/widewind/views/page.html.php 97 DIRTY $theme->user_menu() +themes/widewind/views/page.html.php 112 DIRTY_ATTR $breadcrumb->last?"g-active":"" +themes/widewind/views/page.html.php 113 DIRTY_ATTR $breadcrumb->first?"g-first":"" +themes/widewind/views/page.html.php 114 DIRTY_JS $breadcrumb->url +themes/widewind/views/page.html.php 127 DIRTY $content +themes/widewind/views/page.html.php 133 DIRTY newView("sidebar.html") +themes/widewind/views/page.html.php 140 DIRTY $footer_text +themes/widewind/views/paginator.html.php 33 DIRTY_JS $first_page_url +themes/widewind/views/paginator.html.php 42 DIRTY_JS $previous_page_url +themes/widewind/views/paginator.html.php 70 DIRTY_JS $next_page_url +themes/widewind/views/paginator.html.php 79 DIRTY_JS $last_page_url +themes/widewind/views/photo.html.php 7 DIRTY_JS $theme->item()->width +themes/widewind/views/photo.html.php 7 DIRTY_JS $theme->item()->height +themes/widewind/views/photo.html.php 17 DIRTY_JS url::site("items/dimensions/".$theme->item()->id) +themes/widewind/views/photo.html.php 31 DIRTY $theme->paginator() +themes/widewind/views/photo.html.php 36 DIRTY_JS $item->file_url() +themes/widewind/views/photo.html.php 38 DIRTY $item->resize_img(array("id"=>"g-item-id-{$item->id}","class"=>"g-resize")) themes/wind/views/album.html.php 19 DIRTY_ATTR $child->id themes/wind/views/album.html.php 19 DIRTY_ATTR $item_class themes/wind/views/album.html.php 21 DIRTY_JS $child->url() diff --git a/modules/gallery/views/admin_advanced_settings.html.php b/modules/gallery/views/admin_advanced_settings.html.php index f4f0c81daa..8cef2d0e0e 100644 --- a/modules/gallery/views/admin_advanced_settings.html.php +++ b/modules/gallery/views/admin_advanced_settings.html.php @@ -17,7 +17,7 @@ - + "> module_name) ?> name) ?> @@ -25,15 +25,15 @@ module_name/" . html::clean($var->name)) ?>" class="g-dialog-link" title=" $var->name, "module_name" => $var->module_name))->for_html_attr() ?>"> - value) || $var->value === ""): ?> + value) || $var->value === ""): ?> - + value) ?> - + - + diff --git a/modules/gallery/views/admin_block_log_entries.html.php b/modules/gallery/views/admin_block_log_entries.html.php index 5a8ed23c8f..bf847babb2 100644 --- a/modules/gallery/views/admin_block_log_entries.html.php +++ b/modules/gallery/views/admin_block_log_entries.html.php @@ -1,15 +1,15 @@
    - +
  • - user->guest): ?> + user->guest): ?> user->name) ?> - + user->name) ?> - + timestamp) ?> message ?> html ?>
  • - +
diff --git a/modules/gallery/views/admin_block_news.html.php b/modules/gallery/views/admin_block_news.html.php index cb276ae595..330e679a66 100644 --- a/modules/gallery/views/admin_block_news.html.php +++ b/modules/gallery/views/admin_block_news.html.php @@ -1,11 +1,11 @@
    - +
  • ">

  • - +
diff --git a/modules/gallery/views/admin_block_photo_stream.html.php b/modules/gallery/views/admin_block_photo_stream.html.php index f9725eeefe..61851d24de 100644 --- a/modules/gallery/views/admin_block_photo_stream.html.php +++ b/modules/gallery/views/admin_block_photo_stream.html.php @@ -1,13 +1,13 @@

diff --git a/modules/gallery/views/admin_dashboard.html.php b/modules/gallery/views/admin_dashboard.html.php index cf90ef287e..67dfbd1a92 100644 --- a/modules/gallery/views/admin_dashboard.html.php +++ b/modules/gallery/views/admin_dashboard.html.php @@ -32,11 +32,11 @@ });

- +

- +
diff --git a/modules/gallery/views/admin_graphics.html.php b/modules/gallery/views/admin_graphics.html.php index 1f45bb1463..a795157a7b 100644 --- a/modules/gallery/views/admin_graphics.html.php +++ b/modules/gallery/views/admin_graphics.html.php @@ -21,19 +21,19 @@

- + - + $tk->$active, "is_active" => true)) ?> - +

- - + + $tk->$id, "is_active" => false)) ?> - - + +
diff --git a/modules/gallery/views/admin_graphics_gd.html.php b/modules/gallery/views/admin_graphics_gd.html.php index 1cc9dc9e89..e3e088ac38 100644 --- a/modules/gallery/views/admin_graphics_gd.html.php +++ b/modules/gallery/views/admin_graphics_gd.html.php @@ -1,30 +1,30 @@
installed ? " g-installed-toolkit" : " g-unavailable" ?>"> - " alt="" /> + " alt="" />

GD website for more information.", array("url" => "http://www.boutell.com/gd")) ?>

- installed && $tk->rotate): ?> + installed && $tk->rotate): ?>
$tk->version)) ?>

- installed): ?> - error): ?> + installed): ?> + error): ?>

error ?>

- +

- +
- +
diff --git a/modules/gallery/views/admin_graphics_graphicsmagick.html.php b/modules/gallery/views/admin_graphics_graphicsmagick.html.php index 5dae1442e2..e9ec1dc8cd 100644 --- a/modules/gallery/views/admin_graphics_graphicsmagick.html.php +++ b/modules/gallery/views/admin_graphics_graphicsmagick.html.php @@ -1,21 +1,21 @@
installed ? " g-installed-toolkit" : " g-unavailable" ?>"> - " alt="" /> + " alt="" />

GraphicsMagick website for more information.", array("url" => "http://www.graphicsmagick.org")) ?>

- installed): ?> + installed): ?>
$tk->version, "dir" => $tk->dir)) ?>

- +
error ?>
- +
diff --git a/modules/gallery/views/admin_graphics_imagemagick.html.php b/modules/gallery/views/admin_graphics_imagemagick.html.php index 9c1a990939..6e47607658 100644 --- a/modules/gallery/views/admin_graphics_imagemagick.html.php +++ b/modules/gallery/views/admin_graphics_imagemagick.html.php @@ -1,21 +1,21 @@
installed ? " g-installed-toolkit" : " g-unavailable" ?>"> - " alt="" /> + " alt="" />

ImageMagick website for more information.", array("url" => "http://www.imagemagick.org")) ?>

- installed): ?> + installed): ?>
$tk->version, "dir" => $tk->dir)) ?>

- error): ?> + error): ?>
error ?>
- +
diff --git a/modules/gallery/views/admin_languages.html.php b/modules/gallery/views/admin_languages.html.php index d6a9c22578..0018def657 100644 --- a/modules/gallery/views/admin_languages.html.php +++ b/modules/gallery/views/admin_languages.html.php @@ -47,9 +47,9 @@ - - $display_name): ?> - + + $display_name): ?> + @@ -57,7 +57,7 @@ - + "> @@ -65,14 +65,15 @@ - - + +
for_html_attr() ?>" /> + diff --git a/modules/gallery/views/admin_maintenance.html.php b/modules/gallery/views/admin_maintenance.html.php index 230e935390..936dde8236 100644 --- a/modules/gallery/views/admin_maintenance.html.php +++ b/modules/gallery/views/admin_maintenance.html.php @@ -7,15 +7,15 @@ maintenance mode which prevents any non-admin from accessing your Gallery. Some of the tasks below will automatically put your Gallery in maintenance mode for you.") ?>

    - +
  • on. Non admins cannot access your Gallery. Turn off maintenance mode", array("enable_maintenance_mode_url" => url::site("admin/maintenance/maintenance_mode/0?csrf=$csrf"))) ?>
  • - +
  • Turn on maintenance mode", array("enable_maintenance_mode_url" => url::site("admin/maintenance/maintenance_mode/1?csrf=$csrf"))) ?>
  • - +
@@ -38,7 +38,7 @@ - + severity) ?>"> name ?> @@ -53,11 +53,11 @@ class="g-dialog-link g-button ui-icon-left ui-state-default ui-corner-all"> - + - count()): ?> + count()): ?> - + - count()): ?> + count()): ?> - + diff --git a/modules/gallery/views/admin_modules.html.php b/modules/gallery/views/admin_modules.html.php index 96576ae47b..685451ec68 100644 --- a/modules/gallery/views/admin_modules.html.php +++ b/modules/gallery/views/admin_modules.html.php @@ -6,7 +6,7 @@ dataType: "json", success: function(data) { if (data.reload) { - window.location = ""; + window.location = ""; } else { $("body").append('
' + data.dialog + '
'); $("#g-dialog").dialog({ @@ -46,11 +46,11 @@ adding more modules! Each module provides new cool features.", array("url" => "http://codex.galleryproject.org/Category:Gallery_3:Modules")) ?>

- +

- +
"> @@ -63,10 +63,10 @@ - $module_info): ?> + $module_info): ?> "> - $module_name); ?> - locked) $data["disabled"] = 1; ?> + $module_name); ?> + locked) $data["disabled"] = 1; ?> name) ?> version ?> @@ -75,45 +75,45 @@ - + for_html_attr() ?>" />
diff --git a/modules/gallery/views/admin_modules_confirm.html.php b/modules/gallery/views/admin_modules_confirm.html.php index 8c4cb2bd33..b5f6b7e458 100644 --- a/modules/gallery/views/admin_modules_confirm.html.php +++ b/modules/gallery/views/admin_modules_confirm.html.php @@ -6,17 +6,17 @@
    - "g-error", "warn" => "g-warning") as $type => $css_class): ?> - + "g-error", "warn" => "g-warning") as $type => $css_class): ?> +
  • - - + +
"> - + - +
diff --git a/modules/gallery/views/admin_movies.html.php b/modules/gallery/views/admin_movies.html.php index abf8fb29f6..11ed5a0072 100644 --- a/modules/gallery/views/admin_movies.html.php +++ b/modules/gallery/views/admin_movies.html.php @@ -21,21 +21,21 @@

- " alt="" /> + " alt="" />


FFmpeg website for more information.", array("url" => "http://ffmpeg.org")) ?>

- - + +

$ffmpeg_version, "dir" => $ffmpeg_dir)) ?>

- +

$ffmpeg_dir)) ?>

- - + +

- +
diff --git a/modules/gallery/views/admin_sidebar_blocks.html.php b/modules/gallery/views/admin_sidebar_blocks.html.php index 48aa3f0537..cee99d866c 100644 --- a/modules/gallery/views/admin_sidebar_blocks.html.php +++ b/modules/gallery/views/admin_sidebar_blocks.html.php @@ -1,5 +1,5 @@ - $text): ?> + $text): ?>
  • - + diff --git a/modules/gallery/views/admin_themes.html.php b/modules/gallery/views/admin_themes.html.php index 547f27d243..ed6e816a74 100644 --- a/modules/gallery/views/admin_themes.html.php +++ b/modules/gallery/views/admin_themes.html.php @@ -23,15 +23,15 @@ function() { load(type) });

    description ?>

    - info = $themes[$site]; print $v; ?> + info = $themes[$site]; print $v; ?>

    - - $info): ?> - site) continue ?> - + + $info): ?> + site) continue ?> + - - + + - +

    Download one now!", array("url" => "http://codex.galleryproject.org/Category:Gallery_3:Themes")) ?>

    - +
    @@ -63,15 +63,15 @@ function() { load(type) });

    description ?>

    - info = $themes[$admin]; print $v; ?> + info = $themes[$admin]; print $v; ?>

    - - $info): ?> - admin) continue ?> - + + $info): ?> + admin) continue ?> + - - + + - +

    Download one now!", array("url" => "http://codex.galleryproject.org/Category:Gallery_3:Themes")) ?>

    - +
    diff --git a/modules/gallery/views/admin_themes_buttonset.html.php b/modules/gallery/views/admin_themes_buttonset.html.php index bf474a264f..5390d5ff04 100644 --- a/modules/gallery/views/admin_themes_buttonset.html.php +++ b/modules/gallery/views/admin_themes_buttonset.html.php @@ -2,45 +2,45 @@
    • + class="ui-state-default ui-icon ui-icon-person ui-corner-left" href="" - + class="ui-state-disabled ui-icon ui-icon-person ui-corner-left" href="#" - + - + title="" - + > - + - +
    • + class="ui-state-default ui-icon ui-icon-info" href="" - + class="ui-state-disabled ui-icon ui-icon-info" href="#" - + >
    • + class="ui-state-default ui-icon ui-icon-comment ui-corner-right" href="" - + class="ui-state-disabled ui-icon ui-icon-comment ui-corner-right" href="#" - + > diff --git a/modules/gallery/views/error_404.html.php b/modules/gallery/views/error_404.html.php index 42f62b6c5f..7403007367 100644 --- a/modules/gallery/views/error_404.html.php +++ b/modules/gallery/views/error_404.html.php @@ -3,7 +3,7 @@

      - +

      @@ -17,10 +17,10 @@ $("#g-username").focus(); }); - +

      - + diff --git a/modules/gallery/views/error_admin.html.php b/modules/gallery/views/error_admin.html.php index 036e204991..f01d498272 100644 --- a/modules/gallery/views/error_admin.html.php +++ b/modules/gallery/views/error_admin.html.php @@ -1,6 +1,6 @@ - - + + @@ -149,7 +149,7 @@ function koggle(elem) { - +
    • - - $step): ?> + + $step): ?>
    • - - + + [ ] - + [ ] - - + + {} - + » - ( + ( - ) + )

      - + - - - - + + + +
    • - - + + - +

      " onclick="return koggle('')">

      diff --git a/modules/gallery/views/error_cli.txt.php b/modules/gallery/views/error_cli.txt.php index 9f476f5467..ba105f5f18 100644 --- a/modules/gallery/views/error_cli.txt.php +++ b/modules/gallery/views/error_cli.txt.php @@ -1,3 +1,3 @@ - - +
      - + render(); ?> - +

      s

      diff --git a/modules/gallery/views/l10n_client.html.php b/modules/gallery/views/l10n_client.html.php index 47a45e29ad..dfd76c1fd9 100644 --- a/modules/gallery/views/l10n_client.html.php +++ b/modules/gallery/views/l10n_client.html.php @@ -7,9 +7,9 @@ href="">X

      - get('show_all_l10n_messages')): ?> + get('show_all_l10n_messages')): ?> "> - +

        - +
      • "> - + [one] -
        [other] - - + - +
      • - +
      diff --git a/modules/gallery/views/login_ajax.html.php b/modules/gallery/views/login_ajax.html.php index a40d1950f4..3a2aeae364 100644 --- a/modules/gallery/views/login_ajax.html.php +++ b/modules/gallery/views/login_ajax.html.php @@ -43,10 +43,10 @@ function ajaxify_login_reset_form() {
    • - +
    • - +

    diff --git a/modules/gallery/views/login_current_user.html.php b/modules/gallery/views/login_current_user.html.php index 94525576d5..a57eb14616 100644 --- a/modules/gallery/views/login_current_user.html.php +++ b/modules/gallery/views/login_current_user.html.php @@ -1,7 +1,7 @@
  • - label->for_html() ?> - for_html_attr() ?> + label->for_html() ?> + for_html_attr() ?> html::mark_clean( "{$name}"))) ?>
  • diff --git a/modules/gallery/views/menu.html.php b/modules/gallery/views/menu.html.php index 17a249ddf1..bdaed6b349 100644 --- a/modules/gallery/views/menu.html.php +++ b/modules/gallery/views/menu.html.php @@ -1,24 +1,24 @@ -is_empty()): // Don't show the menu if it has no choices ?> -is_root): ?> +is_empty()): // Don't show the menu if it has no choices ?> +is_root): ?>
      css_id ? "id='$menu->css_id'" : "" ?> class="css_class ?>"> - elements as $element): ?> + elements as $element): ?> render() ?> - +
    - +
  • label->for_html() ?>
      - elements as $element): ?> + elements as $element): ?> render() ?> - +
  • - - + + diff --git a/modules/gallery/views/movieplayer.html.php b/modules/gallery/views/movieplayer.html.php index e4046906a7..a81e23dbc4 100644 --- a/modules/gallery/views/movieplayer.html.php +++ b/modules/gallery/views/movieplayer.html.php @@ -1,18 +1,4 @@
    > - +
    - diff --git a/modules/gallery/views/permissions_browse.html.php b/modules/gallery/views/permissions_browse.html.php index 0b27336e6b..2603603631 100644 --- a/modules/gallery/views/permissions_browse.html.php +++ b/modules/gallery/views/permissions_browse.html.php @@ -25,7 +25,7 @@ }
    - +
    • mod_rewrite and set AllowOverride FileInfo Options to fix this.", @@ -33,22 +33,22 @@ "apache_attrs" => html::mark_clean('href="http://httpd.apache.org/docs/2.0/mod/core.html#allowoverride" target="_blank"'))) ?>
    - +

      - - -
    • > - + + +
    • > + title) ?> - + title) ?> - +
    • - - + +
    • title) ?> diff --git a/modules/gallery/views/permissions_form.html.php b/modules/gallery/views/permissions_form.html.php index f171411913..d7d43a85b0 100644 --- a/modules/gallery/views/permissions_form.html.php +++ b/modules/gallery/views/permissions_form.html.php @@ -4,21 +4,21 @@ - + - + - + - - name, $item) ?> - name, $item) ?> - name, $item) ?> + + name, $item) ?> + name, $item) ?> + name, $item) ?> - + - - - + + + - + - + - + - + - - + + - + - +
      name) ?>
      display_name) ?> " title="for_html_attr() ?>" @@ -27,9 +27,9 @@ " alt="for_html_attr() ?>" /> " alt="for_html_attr() ?>" /> @@ -39,7 +39,7 @@ " alt="for_html_attr() ?>" /> @@ -50,43 +50,43 @@ " alt="for_html_attr() ?>" /> " alt="for_html_attr() ?>" /> - id == 1): ?> + id == 1): ?> " alt="for_html_attr() ?>" title="for_html_attr() ?>"/> - + " alt="for_html_attr() ?>" /> - + - id == 1): ?> + id == 1): ?> " title="for_html_attr() ?>" alt="for_html_attr() ?>" /> - + " alt="for_html_attr() ?>" /> - + " alt="for_html_attr() ?>" />
      diff --git a/modules/gallery/views/quick_delete_confirm.html.php b/modules/gallery/views/quick_delete_confirm.html.php index 176ffb964e..d89e5a2d98 100644 --- a/modules/gallery/views/quick_delete_confirm.html.php +++ b/modules/gallery/views/quick_delete_confirm.html.php @@ -1,12 +1,12 @@

      - is_album()): ?> + is_album()): ?> %title? All photos and movies in the album will also be deleted.", array("title" => html::purify($item->title))) ?> - + %title?", array("title" => html::purify($item->title))) ?> - +

      diff --git a/modules/gallery/views/upgrade_checker_block.html.php b/modules/gallery/views/upgrade_checker_block.html.php index c984d99f94..3bd0a8a2b8 100644 --- a/modules/gallery/views/upgrade_checker_block.html.php +++ b/modules/gallery/views/upgrade_checker_block.html.php @@ -4,52 +4,52 @@

      - + %code_name.", array("version" => gallery::VERSION, "code_name" => gallery::CODE_NAME)) ?> - + gallery::VERSION, "branch" => gallery::RELEASE_BRANCH, "build_number" => $build_number)) ?> - + gallery::VERSION, "branch" => gallery::RELEASE_BRANCH, "build_number" => $build_number)) ?> - +

      - +
      - +

      "> - + "> - + "> - +

      - + - + - - + + - + gallery::date_time($version_info->timestamp))) ?> - +

      diff --git a/modules/gallery/views/upgrader.html.php b/modules/gallery/views/upgrader.html.php index 2e485c085f..1d19288fc7 100644 --- a/modules/gallery/views/upgrader.html.php +++ b/modules/gallery/views/upgrader.html.php @@ -8,11 +8,11 @@ media="screen,print,projection" /> - > + >
      " />
      - +

      " @@ -36,12 +36,12 @@ class="g-avatar g-left" width="40" height="40" /> $user->display_name())) ?>

      - +

      title) ?>

      view ?>
      - +
      diff --git a/modules/gallery/views/user_profile_info.html.php b/modules/gallery/views/user_profile_info.html.php index e559abda30..da0f1fe777 100644 --- a/modules/gallery/views/user_profile_info.html.php +++ b/modules/gallery/views/user_profile_info.html.php @@ -1,9 +1,9 @@ - $value): ?> + $value): ?> - +
      diff --git a/modules/gallery_unit_test/controllers/gallery_unit_test.php b/modules/gallery_unit_test/controllers/gallery_unit_test.php index 6b2bf47999..14e364ffe2 100644 --- a/modules/gallery_unit_test/controllers/gallery_unit_test.php +++ b/modules/gallery_unit_test/controllers/gallery_unit_test.php @@ -25,6 +25,7 @@ function index() { // Force strict behavior to flush out bugs early ini_set("display_errors", true); + //error_reporting(E_ALL & ~E_DEPRECATED); error_reporting(-1); // Jump through some hoops to satisfy the way that we check for the site_domain in @@ -41,7 +42,7 @@ function index() { print "Please copy kohana/config/database.php to $original_config.\n"; return; } else { - copy($original_config, $test_config); + if (!file_exists($test_config)) copy($original_config, $test_config); $db_config = Kohana::config('database'); if (empty($db_config['unit_test'])) { $default = $db_config['default']; @@ -92,7 +93,7 @@ function index() { // Clean out the filesystem. Note that this cleans out test/var/database.php, but that's ok // because we technically don't need it anymore. If this is confusing, we could always // arrange to preserve that one file. - @system("rm -rf test/var"); + @system("rm -rf test/var/albums test/var/modules test/var/resizes test/var/thumbs test/var/tmp test/var/uploads"); @mkdir('test/var/logs', 0777, true); $active_modules = module::$active; diff --git a/modules/gallery_unit_test/views/kohana/error.php b/modules/gallery_unit_test/views/kohana/error.php index 079a279bf2..bb4b86b10a 100644 --- a/modules/gallery_unit_test/views/kohana/error.php +++ b/modules/gallery_unit_test/views/kohana/error.php @@ -1,5 +1,5 @@ -getMessage(), "\n"; echo $e->getFile(), ":", $e->getLine(), "\n"; echo $e->getTraceAsString(), "\n"; diff --git a/modules/gallery_unit_test/views/kohana_unit_test_cli.php b/modules/gallery_unit_test/views/kohana_unit_test_cli.php index 61dae7dd5c..ff47f7b85f 100644 --- a/modules/gallery_unit_test/views/kohana_unit_test_cli.php +++ b/modules/gallery_unit_test/views/kohana_unit_test_cli.php @@ -1,5 +1,5 @@ - - + - + diff --git a/modules/info/views/info_block.html.php b/modules/info/views/info_block.html.php index b296fa1d55..3795347329 100644 --- a/modules/info/views/info_block.html.php +++ b/modules/info/views/info_block.html.php @@ -1,8 +1,8 @@ diff --git a/modules/movie_resized/helpers/movie_resized_event.php b/modules/movie_resized/helpers/movie_resized_event.php new file mode 100644 index 0000000000..6b230647b3 --- /dev/null +++ b/modules/movie_resized/helpers/movie_resized_event.php @@ -0,0 +1,14 @@ +resize_path().'.mp4'; + + if (file_exists($resize_file)) { + $resize_url = $obj->resize_url(true); + $relative_file = $obj->relative_path(); + + $movie_img->url = str_replace($relative_file, $relative_file.'.mp4', $resize_url); + } + } +} diff --git a/modules/movie_resized/module.info b/modules/movie_resized/module.info new file mode 100755 index 0000000000..45fe516bce --- /dev/null +++ b/modules/movie_resized/module.info @@ -0,0 +1,7 @@ +name = "Movie Resized" +description = "Will display an alternate version of your video, useful if you want a smaller and more browser compatible video to be streamed on your web site in place of the original" +version = 1 +author_name = "Brad Dutton" +author_url = "" +info_url = "" +discuss_url = "" diff --git a/modules/notification/views/item_added.html.php b/modules/notification/views/item_added.html.php index 1ea3720d37..d0474fef42 100644 --- a/modules/notification/views/item_added.html.php +++ b/modules/notification/views/item_added.html.php @@ -18,12 +18,12 @@ - description): ?> + description): ?> description)) ?> - + diff --git a/modules/notification/views/item_updated.html.php b/modules/notification/views/item_updated.html.php index 7020fd53a5..28c0594795 100644 --- a/modules/notification/views/item_updated.html.php +++ b/modules/notification/views/item_updated.html.php @@ -7,29 +7,29 @@

      - title != $item->title): ?> + title != $item->title): ?> - + - + - description != $item->description): ?> + description != $item->description): ?> - description)): ?> + description)): ?> - +
      title) ?> title) ?>
      abs_url() ?>
      description) ?>
      description) ?>
      diff --git a/modules/notification/views/user_profile_notification.html.php b/modules/notification/views/user_profile_notification.html.php index 8864f0c762..f18bda0aa4 100644 --- a/modules/notification/views/user_profile_notification.html.php +++ b/modules/notification/views/user_profile_notification.html.php @@ -1,12 +1,12 @@
      diff --git a/modules/organize/views/organize_frame.html.php b/modules/organize/views/organize_frame.html.php index 3a70ccff46..8189fa9b47 100644 --- a/modules/organize/views/organize_frame.html.php +++ b/modules/organize/views/organize_frame.html.php @@ -310,9 +310,9 @@ */ sort_order_data = []; - $value): ?> + $value): ?> sort_order_data.push(["", for_js() ?>]); - + var sort_column_combobox = new Ext.form.ComboBox({ mode: "local", editable: false, @@ -428,7 +428,7 @@ sort_order_combobox ] }, - + { xtype: "spacer", flex: 3 @@ -439,12 +439,12 @@ xtype: "spacer", flex: 1 }, - + { xtype: "spacer", flex: 10 }, - + delete_button, { xtype: "button", diff --git a/modules/phpmailer/controllers/admin_phpmailer.php b/modules/phpmailer/controllers/admin_phpmailer.php new file mode 100644 index 0000000000..d572c9d208 --- /dev/null +++ b/modules/phpmailer/controllers/admin_phpmailer.php @@ -0,0 +1,98 @@ +content = new View("admin_phpmailer.html"); + $view->content->phpmailer_form = $this->_get_admin_form(); + print $view; + } + + public function saveprefs() { + // Prevent Cross Site Request Forgery + access::verify_csrf(); + + // Figure out the values of the text boxes + $str_phpmailer_from_addr = Input::instance()->post("phpmailer_from_address"); + $str_phpmailer_from_name = Input::instance()->post("phpmailer_from_name"); + $str_smtp_server = Input::instance()->post("phpmailer_smtp_server"); + $str_smtps = Input::instance()->post("phpmailer_smtps"); + $str_smtp_login = Input::instance()->post("phpmailer_smtp_login"); + $str_smtp_pass = Input::instance()->post("phpmailer_smtp_password"); + $str_smtp_port = Input::instance()->post("phpmailer_smtp_port"); + + // Save Settings. + module::set_var("phpmailer", "phpmailer_from_address", $str_phpmailer_from_addr); + module::set_var("phpmailer", "phpmailer_from_name", $str_phpmailer_from_name); + module::set_var("phpmailer", "smtp_server", $str_smtp_server); + module::set_var("phpmailer", "smtps", $str_smtps); + module::set_var("phpmailer", "smtp_login", $str_smtp_login); + module::set_var("phpmailer", "smtp_password", $str_smtp_pass); + module::set_var("phpmailer", "smtp_port", $str_smtp_port); + message::success(t("Your Settings Have Been Saved.")); + + // Load Admin page. + $view = new Admin_View("admin.html"); + $view->content = new View("admin_phpmailer.html"); + $view->content->phpmailer_form = $this->_get_admin_form(); + print $view; + } + + private function _get_admin_form() { + // Make a new Form. + $form = new Forge("admin/phpmailer/saveprefs", "", "post", + array("id" => "g-php-mailer-admin-form")); + + // Create the input boxes for the PHPMailer Settings + $phpmailerGroup = $form->group("PHPMailerSettings"); + $phpmailerGroup->input("phpmailer_from_address") + ->label(t("From Email Address")) + ->value(module::get_var("phpmailer", "phpmailer_from_address")); + $phpmailerGroup->input("phpmailer_from_name") + ->label(t("From Name")) + ->value(module::get_var("phpmailer", "phpmailer_from_name")); + + // Create the input boxes for the SMTP server settings + $phpmailerSMTP = $form->group("PHPMailerSMTPSettings"); + $phpmailerSMTP->input("phpmailer_smtp_server") + ->label(t("SMTP Server Address")) + ->value(module::get_var("phpmailer", "smtp_server")); + $phpmailerSMTP->input("phpmailer_smtp_login") + ->label(t("SMTP Login Name")) + ->value(module::get_var("phpmailer", "smtp_login")); + $phpmailerSMTP->password("phpmailer_smtp_password") + ->label(t("SMTP Password")) + ->value(module::get_var("phpmailer", "smtp_password")); + $phpmailerSMTP->input("phpmailer_smtp_port") + ->label(t("SMTP Port")) + ->value(module::get_var("phpmailer", "smtp_port")); + $phpmailerSMTP->dropdown("phpmailer_smtps") + ->options(array("" => "", "ssl" => t("SSL"), "tls" => t("TLS"))) + ->selected(module::get_var("phpmailer", "smtps")); + + // Add a save button to the form. + $form->submit("SaveSettings")->value(t("Save")); + + // Return the newly generated form. + return $form; + } +} diff --git a/modules/phpmailer/helpers/phpmailer_event.php b/modules/phpmailer/helpers/phpmailer_event.php new file mode 100644 index 0000000000..ac313f3ad7 --- /dev/null +++ b/modules/phpmailer/helpers/phpmailer_event.php @@ -0,0 +1,28 @@ +get("settings_menu") + ->append(Menu::factory("link") + ->id("phpmailer") + ->label(t("PHPMailer Settings")) + ->url(url::site("admin/phpmailer"))); + } +} diff --git a/modules/phpmailer/helpers/phpmailer_installer.php b/modules/phpmailer/helpers/phpmailer_installer.php new file mode 100644 index 0000000000..50a6972255 --- /dev/null +++ b/modules/phpmailer/helpers/phpmailer_installer.php @@ -0,0 +1,42 @@ +headers = array(); + $this->from(module::get_var("gallery", "email_from", "")); + $this->reply_to(module::get_var("gallery", "email_reply_to", "")); + $this->line_length(module::get_var("gallery", "email_line_length", 70)); + $separator = module::get_var("gallery", "email_header_separator", null); + $this->header_separator(empty($separator) ? "\n" : unserialize($separator)); + } + + public function __get($key) { + return null; + } + + public function __call($key, $value) { + switch ($key) { + case "to": + $this->to = is_array($value[0]) ? $value[0] : array($value[0]); + break; + case "header": + if (count($value) != 2) { + Kohana_Log::add("error", wordwrap("Invalid header parameters\n" . Kohana::debug($value))); + throw new Exception("@todo INVALID_HEADER_PARAMETERS"); + } + $this->headers[$value[0]] = $value[1]; + break; + case "from": + $this->headers["From"] = $value[0]; + break; + case "reply_to": + $this->headers["Reply-To"] = $value[0]; + break; + default: + $this->$key = $value[0]; + } + return $this; + } + + public function send() { + if (empty($this->to)) { + Kohana_Log::add("error", wordwrap("Sending mail failed:\nNo to address specified")); + throw new Exception("@todo TO_IS_REQUIRED_FOR_MAIL"); + } + $to = implode(", ", $this->to); + $headers = array(); + foreach ($this->headers as $key => $value) { + $key = ucfirst($key); + $headers[] = "$key: $value"; + } + + // The docs say headers should be separated by \r\n, but occasionaly that doesn't work and you + // need to use a single \n. This can be set in config/sendmail.php + $headers = implode($this->header_separator, $headers); + $message = wordwrap($this->message, $this->line_length, "\n"); + if (!$this->mail($to, $this->subject, $message, $headers)) { + throw new Exception("@todo SEND_MAIL_FAILED"); + } + return $this; + } + + public function mail($to, $subject, $message, $headers) { + // This function is completely different from the original + // Gallery Sendmail script. Outside of this function, + // no other changes were made. + + $mail = new PHPMailer(); + + $mail->IsSMTP(); + $mail->Host = module::get_var("phpmailer", "smtp_server"); + $mail->Port = module::get_var("phpmailer", "smtp_port"); + $mail->SMTPDebug = 0; + + if (module::get_var("phpmailer", "smtp_login") != "") { + $mail->SMTPAuth = true; + + if (module::get_var("phpmailer", "smtps") == 'ssl') { + $mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS; + } elseif (module::get_var("phpmailer", "smtps") == 'tls') { + $mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS; + } + $mail->Username = module::get_var("phpmailer", "smtp_login"); + $mail->Password = module::get_var("phpmailer", "smtp_password"); + } else { + $mail->SMTPAuth = false; + } + + $mail->From = module::get_var("phpmailer", "phpmailer_from_address"); + $mail->FromName = module::get_var("phpmailer", "phpmailer_from_name"); + $mail->AddAddress($to); + $mail->IsHTML(true); + + // demdel's fix for the ecard module. + $boundaryLine = explode("\n", $message, -1); + $newboundary = substr($boundaryLine[0],2); + if (preg_match("/--/", $boundaryLine[0])) { + if (preg_match("/--".$newboundary."--/", end($boundaryLine))) { + $mail->CharSet = "UTF-8"; + $mail->ContentType = "multipart/related; boundary=\"".$newboundary."\""; + } + } + + $mail->Subject = $subject; + $mail->Body = $message; + + // Log any errors. + if (!$mail->Send()) { + Kohana_Log::add("error", wordwrap($mail->ErrorInfo)); + return false; + } else { + return true; + } + } +} diff --git a/modules/phpmailer/module.info b/modules/phpmailer/module.info new file mode 100644 index 0000000000..6c2ce977c0 --- /dev/null +++ b/modules/phpmailer/module.info @@ -0,0 +1,3 @@ +name = "PHPMailer" +description = "Use PHPMailer when sending email messages. Use 'composer install' to install phpmailer" +version = 3 diff --git a/modules/phpmailer/views/admin_phpmailer.html.php b/modules/phpmailer/views/admin_phpmailer.html.php new file mode 100644 index 0000000000..13022bc1b7 --- /dev/null +++ b/modules/phpmailer/views/admin_phpmailer.html.php @@ -0,0 +1,8 @@ + +
      + + + +

      + +
      diff --git a/modules/recaptcha/views/admin_recaptcha.html.php b/modules/recaptcha/views/admin_recaptcha.html.php index 4f07fef082..880463b3f4 100644 --- a/modules/recaptcha/views/admin_recaptcha.html.php +++ b/modules/recaptcha/views/admin_recaptcha.html.php @@ -10,7 +10,7 @@
      - +

      @@ -29,7 +29,7 @@

      - +
    diff --git a/modules/rest/helpers/rest.php b/modules/rest/helpers/rest.php index c6be1e1db1..e26b0f13a8 100644 --- a/modules/rest/helpers/rest.php +++ b/modules/rest/helpers/rest.php @@ -48,7 +48,7 @@ static function reply($data=array()) { header("Content-type: text/html; charset=UTF-8"); if ($data) { $html = preg_replace( - "#([\w]+?://[\w]+[^ \'\"\n\r\t<]*)#ise", "'\\1'", + "#([\w]+?://[\w]+[^ \'\"\n\r\t<]*)#is", "'\\1'", var_export($data, 1)); } else { $html = t("Empty response"); diff --git a/modules/rest/views/error_rest.json.php b/modules/rest/views/error_rest.json.php index 8c99ef45b2..947530f1af 100644 --- a/modules/rest/views/error_rest.json.php +++ b/modules/rest/views/error_rest.json.php @@ -1,5 +1,5 @@ -response, 1)); ?> diff --git a/modules/rss/views/feed.mrss.php b/modules/rss/views/feed.mrss.php index b609a54128..b232cd2cb2 100644 --- a/modules/rss/views/feed.mrss.php +++ b/modules/rss/views/feed.mrss.php @@ -1,5 +1,5 @@ -' ?> +' ?> en-us - previous_page_uri)): ?> + previous_page_uri)): ?> - - next_page_uri)): ?> + + next_page_uri)): ?> diff --git a/modules/rss/views/rss_block.html.php b/modules/rss/views/rss_block.html.php index 210c72a593..5dd205f1ca 100644 --- a/modules/rss/views/rss_block.html.php +++ b/modules/rss/views/rss_block.html.php @@ -1,6 +1,6 @@ diff --git a/modules/search/views/search.html.php b/modules/search/views/search.html.php index a42c31dd63..4bfc9aaf21 100644 --- a/modules/search/views/search.html.php +++ b/modules/search/views/search.html.php @@ -1,5 +1,5 @@ - +
    " id="g-search-form" class="g-short-form">
    @@ -7,11 +7,11 @@ paginator() ?> - +

    %term", array("term" => $q)) ?>

    - + diff --git a/modules/search/views/search_link.html.php b/modules/search/views/search_link.html.php index 4f9abc1a86..6915ba0ab2 100644 --- a/modules/search/views/search_link.html.php +++ b/modules/search/views/search_link.html.php @@ -1,17 +1,17 @@ " id="g-quick-search-form" class="g-short-form"> - - is_album() ? $item->id : $item->parent_id; ?> - - id; ?> - + + is_album() ? $item->id : $item->parent_id; ?> + + id; ?> +
    • - id): ?> + id): ?> - + - +
    • diff --git a/modules/server_add/views/admin_server_add.html.php b/modules/server_add/views/admin_server_add.html.php index f7e596b4c4..6039eb8744 100644 --- a/modules/server_add/views/admin_server_add.html.php +++ b/modules/server_add/views/admin_server_add.html.php @@ -14,11 +14,11 @@

        - +
      • - + - $path): ?> + $path): ?>
      • - +
      diff --git a/modules/server_add/views/server_add_tree.html.php b/modules/server_add/views/server_add_tree.html.php index 91354329c0..b09f8b70a4 100644 --- a/modules/server_add/views/server_add_tree.html.php +++ b/modules/server_add/views/server_add_tree.html.php @@ -6,16 +6,16 @@
        - +
        • - + - +
        • "> " @@ -23,15 +23,15 @@
        • - - + +
        • - + - +
      • - +
      diff --git a/modules/server_add/views/server_add_tree_dialog.html.php b/modules/server_add/views/server_add_tree_dialog.html.php index 824a86a60e..22aa6dc334 100644 --- a/modules/server_add/views/server_add_tree_dialog.html.php +++ b/modules/server_add/views/server_add_tree_dialog.html.php @@ -9,11 +9,11 @@

        - - parents() as $parent): ?> - > title) ?> - - + + parents() as $parent): ?> + > title) ?> + +
      • title) ?>
      diff --git a/modules/slideshow/helpers/slideshow_event.php b/modules/slideshow/helpers/slideshow_event.php deleted file mode 100644 index add1e33553..0000000000 --- a/modules/slideshow/helpers/slideshow_event.php +++ /dev/null @@ -1,80 +0,0 @@ -module == "rss") { - $data->messages["warn"][] = t("The Slideshow module requires the RSS module."); - } - } - - static function module_change($changes) { - if (!module::is_active("rss") || in_array("rss", $changes->deactivate)) { - site_status::warning( - t("The Slideshow module requires the RSS module. Activate the RSS module now", - array("url" => html::mark_clean(url::site("admin/modules")))), - "slideshow_needs_rss"); - } else { - site_status::clear("slideshow_needs_rss"); - } - } - - static function album_menu($menu, $theme) { - $max_scale = module::get_var("slideshow", "max_scale"); - if ($theme->item()->descendants_count(array(array("type", "=", "photo")))) { - $menu->append(Menu::factory("link") - ->id("slideshow") - ->label(t("View slideshow")) - ->url("javascript:cooliris.embed.show(" . - "{maxScale:$max_scale,feed:'" . self::_feed_url($theme) . "'})") - ->css_id("g-slideshow-link")); - } - } - - static function photo_menu($menu, $theme) { - $max_scale = module::get_var("slideshow", "max_scale"); - $menu->append(Menu::factory("link") - ->id("slideshow") - ->label(t("View slideshow")) - ->url("javascript:cooliris.embed.show(" . - "{maxScale:$max_scale,feed:'" . self::_feed_url($theme) . "'})") - ->css_id("g-slideshow-link")); - } - - static function tag_menu($menu, $theme) { - $max_scale = module::get_var("slideshow", "max_scale"); - $menu->append(Menu::factory("link") - ->id("slideshow") - ->label(t("View slideshow")) - ->url("javascript:cooliris.embed.show(" . - "{maxScale:$max_scale,feed:'" . self::_feed_url($theme) . "'})") - ->css_id("g-slideshow-link")); - } - - private static function _feed_url($theme) { - if ($item = $theme->item()) { - if (!$item->is_album()) { - $item = $item->parent(); - } - return rss::url("gallery/album/{$item->id}"); - } else { - return rss::url("tag/tag/{$theme->tag()->id}"); - } - } -} diff --git a/modules/slideshow/module.info b/modules/slideshow/module.info deleted file mode 100644 index 2d71f71018..0000000000 --- a/modules/slideshow/module.info +++ /dev/null @@ -1,7 +0,0 @@ -name = "Slideshow" -description = "Allows users to view a slideshow of photos" -version = 2 -author_name = "Gallery Team" -author_url = "http://codex.galleryproject.org/Gallery:Team" -info_url = "http://codex.galleryproject.org/Gallery3:Modules:slideshow" -discuss_url = "http://galleryproject.org/forum_module_slideshow" diff --git a/modules/tag/helpers/tag.php b/modules/tag/helpers/tag.php index a946e01cbc..00f78e385b 100644 --- a/modules/tag/helpers/tag.php +++ b/modules/tag/helpers/tag.php @@ -175,7 +175,6 @@ static function get_position($tag, $item, $where=array()) { ->where("items_tags.tag_id", "=", $tag->id) ->where("items.id", "<=", $item->id) ->merge_where($where) - ->order_by("items.id") ->count_all(); } -} \ No newline at end of file +} diff --git a/modules/tag/helpers/tag_event.php b/modules/tag/helpers/tag_event.php index 927153aa1d..e08682832b 100644 --- a/modules/tag/helpers/tag_event.php +++ b/modules/tag/helpers/tag_event.php @@ -81,9 +81,11 @@ static function item_edit_form($item, $form) { static function item_edit_form_completed($item, $form) { tag::clear_all($item); - foreach (explode(",", $form->edit_item->tags->value) as $tag_name) { - if ($tag_name) { - tag::add($item, trim($tag_name)); + if (!is_null($form->edit_item->tags->value)) { + foreach (explode(",", $form->edit_item->tags->value) as $tag_name) { + if ($tag_name) { + tag::add($item, trim($tag_name)); + } } } module::event("item_related_update", $item); diff --git a/modules/tag/helpers/tag_task.php b/modules/tag/helpers/tag_task.php index af9f2f1562..5388b14a23 100644 --- a/modules/tag/helpers/tag_task.php +++ b/modules/tag/helpers/tag_task.php @@ -71,7 +71,7 @@ static function clean_up_tags($task) { $completed++; $tags->next(); } - $task->percent_complete = $completed / $total * 100; + $task->percent_complete = $total ? $completed / $total * 100 : 100; $task->set("completed", $completed); $task->set("last_tag_id", $last_tag_id); } @@ -94,4 +94,4 @@ static function clean_up_tags($task) { $task->log($errors); } } -} \ No newline at end of file +} diff --git a/modules/tag/views/admin_tags.html.php b/modules/tag/views/admin_tags.html.php index e1db387bbe..887c9a98c9 100644 --- a/modules/tag/views/admin_tags.html.php +++ b/modules/tag/views/admin_tags.html.php @@ -12,8 +12,8 @@ }); -count()/5 ?> - +count()/5 ?> +

      @@ -25,22 +25,22 @@ - $tag): ?> - name, 0, 1)) ?> + $tag): ?> + name, 0, 1)) ?> - +
        - +
      - $tags_per_column): /* new column */ ?> - + $tags_per_column): /* new column */ ?> + - +
        - +
      • name) ?> (count ?>) @@ -48,9 +48,9 @@ class="g-dialog-link g-delete-link g-button">
      • - - - + + +
      diff --git a/modules/tag/views/tag_cloud.html.php b/modules/tag/views/tag_cloud.html.php index de12bb4963..4a6b4b5e20 100644 --- a/modules/tag/views/tag_cloud.html.php +++ b/modules/tag/views/tag_cloud.html.php @@ -1,9 +1,9 @@
        - +
      • count ?> photos are tagged with name) ?>
      • - +
      diff --git a/modules/user/lib/PasswordHash.php b/modules/user/lib/PasswordHash.php index d6783c0778..62bc056be8 100644 --- a/modules/user/lib/PasswordHash.php +++ b/modules/user/lib/PasswordHash.php @@ -30,7 +30,7 @@ class PasswordHash { var $portable_hashes; var $random_state; - function PasswordHash($iteration_count_log2, $portable_hashes) + function __construct($iteration_count_log2, $portable_hashes) { $this->itoa64 = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'; diff --git a/modules/user/models/user.php b/modules/user/models/user.php index 8561725e0e..62049de2e7 100644 --- a/modules/user/models/user.php +++ b/modules/user/models/user.php @@ -60,7 +60,7 @@ public function delete($id=null) { */ public function avatar_url($size=80, $default=null) { return sprintf("//www.gravatar.com/avatar/%s.jpg?s=%d&r=pg%s", - md5($this->email), $size, $default ? "&d=" . urlencode($default) : ""); + ($this->email ? md5($this->email) : ''), $size, $default ? "&d=" . urlencode($default) : ""); } public function groups() { diff --git a/modules/user/tests/No_Direct_ORM_Access_Test.php b/modules/user/tests/No_Direct_ORM_Access_Test.php index 30ea9cca14..cad076307f 100644 --- a/modules/user/tests/No_Direct_ORM_Access_Test.php +++ b/modules/user/tests/No_Direct_ORM_Access_Test.php @@ -70,7 +70,7 @@ public function no_access_to_groups_table_test() { } class UserModuleFilterIterator extends FilterIterator { - public function accept() { + public function accept(): bool { $path_name = $this->getInnerIterator()->getPathName(); return strpos($path_name, "/modules/user") === false; } diff --git a/modules/user/views/admin_users.html.php b/modules/user/views/admin_users.html.php index e4336f7f34..4ea85c19ce 100644 --- a/modules/user/views/admin_users.html.php +++ b/modules/user/views/admin_users.html.php @@ -68,7 +68,7 @@ class="g-dialog-link g-button g-right ui-icon-left ui-state-default ui-corner-al - $user): ?> + $user): ?> g-user admin ? "g-admin" : "" ?>"> " @@ -95,18 +95,18 @@ class="g-dialog-link g-button g-right ui-icon-left ui-state-default ui-corner-al data-open-text="for_html_attr() ?>" class="g-panel-link g-button ui-state-default ui-corner-all ui-icon-left"> - id != $user->id && !$user->guest): ?> + id != $user->id && !$user->guest): ?> id") ?>" class="g-dialog-link g-button ui-state-default ui-corner-all ui-icon-left"> - + for_html_attr() ?>" class="g-button ui-state-disabled ui-corner-all ui-icon-left"> - + - +
      @@ -128,12 +128,12 @@ class="g-dialog-link g-button g-right ui-icon-left ui-state-default ui-corner-al
        - $group): ?> + $group): ?>
      • "> - group = $group; ?> + group = $group; ?>
      • - +
      diff --git a/modules/user/views/admin_users_group.html.php b/modules/user/views/admin_users_group.html.php index 31b9135116..ef3090d18e 100644 --- a/modules/user/views/admin_users_group.html.php +++ b/modules/user/views/admin_users_group.html.php @@ -3,38 +3,38 @@ id") ?>" title=" $group->name))->for_html_attr() ?>" class="g-dialog-link">name) ?> - special): ?> + special): ?> id") ?>" title=" $group->name))->for_html_attr() ?>" class="g-dialog-link g-button g-right"> - + for_html_attr() ?>" class="g-button g-right ui-state-disabled ui-icon-left"> - + -users->count_all() > 0): ?> +users->count_all() > 0): ?> - +

      - + diff --git a/modules/watermark/views/admin_watermarks.html.php b/modules/watermark/views/admin_watermarks.html.php index fc634b8285..ce644211db 100644 --- a/modules/watermark/views/admin_watermarks.html.php +++ b/modules/watermark/views/admin_watermarks.html.php @@ -6,11 +6,11 @@

      - + " title="for_html_attr() ?>" class="g-dialog-link g-button ui-icon-left ui-state-default ui-corner-all"> - +

      @@ -34,6 +34,6 @@ class="g-dialog-link g-button ui-icon-left ui-state-default ui-corner-all">

      - + diff --git a/system/core/Event.php b/system/core/Event.php index ab839f4378..8b4b0cf2fa 100644 --- a/system/core/Event.php +++ b/system/core/Event.php @@ -228,4 +228,4 @@ public static function has_run($name) return isset(Event::$has_run[$name]); } -} // End Event \ No newline at end of file +} // End Event diff --git a/system/core/Kohana.php b/system/core/Kohana.php index 96d969ed0f..272a967928 100644 --- a/system/core/Kohana.php +++ b/system/core/Kohana.php @@ -164,35 +164,6 @@ public static function setup() // Set and validate the timezone date_default_timezone_set(Kohana::config('locale.timezone')); - // register_globals is enabled - if (ini_get('register_globals')) - { - if (isset($_REQUEST['GLOBALS'])) - { - // Prevent GLOBALS override attacks - exit('Global variable overload attack.'); - } - - // Destroy the REQUEST global - $_REQUEST = array(); - - // These globals are standard and should not be removed - $preserve = array('GLOBALS', '_REQUEST', '_GET', '_POST', '_FILES', '_COOKIE', '_SERVER', '_ENV', '_SESSION'); - - // This loop has the same effect as disabling register_globals - foreach (array_diff(array_keys($GLOBALS), $preserve) as $key) - { - global $$key; - $$key = NULL; - - // Unset the global variable - unset($GLOBALS[$key], $$key); - } - - // Warn the developer about register globals - Kohana_Log::add('debug', 'Disable register_globals! It is evil and deprecated: http://php.net/register_globals'); - } - // Enable Kohana routing Event::add('system.routing', array('Router', 'find_uri')); Event::add('system.routing', array('Router', 'setup')); diff --git a/system/core/Kohana_Config.php b/system/core/Kohana_Config.php index 9abc5b6c49..fcb16b1c18 100644 --- a/system/core/Kohana_Config.php +++ b/system/core/Kohana_Config.php @@ -230,13 +230,13 @@ public function loaded() * @return mixed * @access public */ - public function offsetGet($key) + public function offsetGet($offset): mixed { foreach ($this->drivers as $driver) { try { - return $driver->get($key); + return $driver->get($offset); } catch (Kohana_Config_Exception $e) { @@ -256,13 +256,13 @@ public function offsetGet($key) * @return bool * @access public */ - public function offsetSet($key, $value) + public function offsetSet($offset, $value): void { foreach ($this->drivers as $driver) { try { - $driver->set($key, $value); + $driver->set($offset, $value); } catch (Kohana_Config_Exception $e) { @@ -271,7 +271,6 @@ public function offsetSet($key, $value) throw $e; } } - return TRUE; } /** @@ -282,7 +281,7 @@ public function offsetSet($key, $value) * @return bool * @access public */ - public function offsetExists($key) + public function offsetExists($key): bool { foreach ($this->drivers as $driver) { @@ -307,13 +306,14 @@ public function offsetExists($key) * @return bool * @access public */ - public function offsetUnset($key) + #[\ReturnTypeWillChange] + public function offsetUnset($offset) { foreach ($this->drivers as $driver) { try { - return $driver->set($key, NULL); + $driver->set($offset, NULL); } catch (Kohana_Config_Exception $e) { @@ -322,7 +322,6 @@ public function offsetUnset($key) throw $e; } } - return TRUE; } } // End KohanaConfig diff --git a/system/core/Kohana_Exception.php b/system/core/Kohana_Exception.php index bc0efd18cd..4214b0e3a4 100644 --- a/system/core/Kohana_Exception.php +++ b/system/core/Kohana_Exception.php @@ -99,7 +99,7 @@ public static function text($e) * @param object exception object * @return void */ - public static function handle(Exception $e) + public static function handle($e) { try { diff --git a/system/helpers/download.php b/system/helpers/download.php index 0bdb04d9a9..7bd6be23b5 100644 --- a/system/helpers/download.php +++ b/system/helpers/download.php @@ -60,7 +60,7 @@ public static function send($filename, $data = NULL) Kohana::close_buffers(FALSE); // Clear any output - Event::add('system.display', create_function('', 'Kohana::$output = "";')); + Event::add('system.display', function() { Kohana::$output = ""; }); // Send headers header("Content-Type: $mime"); diff --git a/system/helpers/expires.php b/system/helpers/expires.php index a3e01b8e0a..745c8cb3a4 100644 --- a/system/helpers/expires.php +++ b/system/helpers/expires.php @@ -97,7 +97,7 @@ public static function check($seconds = 60, $modified=null) header('Cache-Control: public,max-age='.$seconds); // Clear any output - Event::add('system.display', create_function('', 'Kohana::$output = "";')); + Event::add('system.display', function() { Kohana::$output = ""; }); exit; } diff --git a/system/helpers/html.php b/system/helpers/html.php index c16031d23e..563b02093e 100644 --- a/system/helpers/html.php +++ b/system/helpers/html.php @@ -21,6 +21,8 @@ class html_Core { */ public static function chars($str, $double_encode = TRUE) { + if (is_null($str)) return ''; + // Return HTML entities using the Kohana charset return htmlspecialchars($str, ENT_QUOTES, Kohana::CHARSET, $double_encode); } @@ -355,6 +357,7 @@ public static function attributes($attrs) $compiled = ''; foreach ($attrs as $key => $val) { + if (is_null($val)) $val = ''; $compiled .= ' '.$key.'="'.htmlspecialchars($val, ENT_QUOTES, Kohana::CHARSET).'"'; } diff --git a/system/helpers/request.php b/system/helpers/request.php index c04a2fa297..39e5219271 100644 --- a/system/helpers/request.php +++ b/system/helpers/request.php @@ -59,10 +59,16 @@ public static function referrer($default = FALSE, $remove_base = FALSE) */ public static function protocol() { + $config = Kohana::config('config'); + if (Kohana::$server_api === 'cli') { return NULL; } + elseif ($config['site_protocol']) + { + return $config['site_protocol']; + } elseif ( ! empty($_SERVER['HTTPS']) AND $_SERVER['HTTPS'] === 'on') { return 'https'; diff --git a/system/helpers/url.php b/system/helpers/url.php index 02956fc363..e0c4f174e2 100644 --- a/system/helpers/url.php +++ b/system/helpers/url.php @@ -54,7 +54,12 @@ public static function base($index = FALSE, $protocol = FALSE) else { // Guess the protocol to provide full http://domain/path URL - $base_url = ((empty($_SERVER['HTTPS']) OR $_SERVER['HTTPS'] === 'off') ? 'http' : 'https').'://'.$site_domain; + // can be configured with a full + if (preg_match('#^http(s)?://#i', $site_domain)) { + $base_url = $site_domain; + } else { + $base_url = ((empty($_SERVER['HTTPS']) OR $_SERVER['HTTPS'] === 'off') ? 'http' : 'https').'://'.$site_domain; + } } } else @@ -92,22 +97,29 @@ public static function base($index = FALSE, $protocol = FALSE) */ public static function site($uri = '', $protocol = FALSE) { - if ($path = trim(parse_url($uri, PHP_URL_PATH), '/')) - { - // Add path suffix - $path .= Kohana::config('core.url_suffix'); - } + $path = ''; + $query = ''; + $fragment = ''; - if ($query = parse_url($uri, PHP_URL_QUERY)) + if ($uri) { - // ?query=string - $query = '?'.$query; - } + if ($path = trim(parse_url($uri, PHP_URL_PATH), '/')) + { + // Add path suffix + $path .= Kohana::config('core.url_suffix'); + } - if ($fragment = parse_url($uri, PHP_URL_FRAGMENT)) - { - // #fragment - $fragment = '#'.$fragment; + if ($query = parse_url($uri, PHP_URL_QUERY)) + { + // ?query=string + $query = '?'.$query; + } + + if ($fragment = parse_url($uri, PHP_URL_FRAGMENT)) + { + // #fragment + $fragment = '#'.$fragment; + } } // Concat the URL @@ -261,4 +273,4 @@ public static function redirect($uri = '', $method = '302') exit('

      '.$method.' - '.$codes[$method].'

      '.$output); } -} // End url \ No newline at end of file +} // End url diff --git a/system/helpers/valid.php b/system/helpers/valid.php index 1f7be223df..9972fbe2b4 100644 --- a/system/helpers/valid.php +++ b/system/helpers/valid.php @@ -126,7 +126,7 @@ public static function email_rfc($email) */ public static function url($url) { - return (bool) filter_var($url, FILTER_VALIDATE_URL, FILTER_FLAG_HOST_REQUIRED); + return (bool) filter_var($url, FILTER_VALIDATE_URL); } /** @@ -450,4 +450,4 @@ public static function color($str) return (bool) preg_match('/^#?+[0-9a-f]{3}(?:[0-9a-f]{3})?$/iD', $str); } -} // End valid \ No newline at end of file +} // End valid diff --git a/system/libraries/Database.php b/system/libraries/Database.php index 253bb152ed..a1587b3d85 100644 --- a/system/libraries/Database.php +++ b/system/libraries/Database.php @@ -442,7 +442,8 @@ public function quote_table($table, $alias = NULL) if (is_array($table)) { // Using array('u' => 'user') - list($alias, $table) = each($table); + $alias = key($table); + $table = current($table); } elseif (strpos(' ', $table) !== FALSE) { @@ -505,7 +506,8 @@ public function quote_column($column, $alias = NULL) if (is_array($column)) { - list($alias, $column) = each($column); + $alias = key($column); + $column = current($column); } if ($column instanceof Database_Expression) diff --git a/system/libraries/Database_Builder.php b/system/libraries/Database_Builder.php index e86ce379e9..1d8c9f911a 100644 --- a/system/libraries/Database_Builder.php +++ b/system/libraries/Database_Builder.php @@ -1183,7 +1183,8 @@ protected function compile_order_by() foreach ($this->order_by as $column => $order_by) { - list($column, $direction) = each($order_by); + $column = key($order_by); + $direction = current($order_by); $column = $this->db->quote_column($column); diff --git a/system/libraries/Database_Cache_Result.php b/system/libraries/Database_Cache_Result.php index 3945c42c21..6cb97ffa87 100644 --- a/system/libraries/Database_Cache_Result.php +++ b/system/libraries/Database_Cache_Result.php @@ -64,6 +64,7 @@ public function seek($offset) return TRUE; } + #[\ReturnTypeWillChange] public function current() { if ($this->return_objects) @@ -78,4 +79,4 @@ public function current() } } -} // End Database_Cache_Result \ No newline at end of file +} // End Database_Cache_Result diff --git a/system/libraries/Database_Mysql_Result.php b/system/libraries/Database_Mysql_Result.php index 0f8989849c..357a72b0ed 100644 --- a/system/libraries/Database_Mysql_Result.php +++ b/system/libraries/Database_Mysql_Result.php @@ -146,6 +146,7 @@ public function seek($offset) /** * Iterator: current */ + #[\ReturnTypeWillChange] public function current() { if ($this->current_row !== $this->internal_row AND ! $this->seek($this->current_row)) @@ -171,4 +172,4 @@ public function current() } } -} // End Database_MySQL_Result \ No newline at end of file +} // End Database_MySQL_Result diff --git a/system/libraries/Database_Mysqli.php b/system/libraries/Database_Mysqli.php index 41b635d199..542c322210 100644 --- a/system/libraries/Database_Mysqli.php +++ b/system/libraries/Database_Mysqli.php @@ -29,7 +29,7 @@ public function connect() $mysqli = mysqli_init(); - if ( ! $mysqli->real_connect($host, $user, $pass, $database, $port, $socket, $params)) + if ( ! $mysqli->real_connect($host, $user, $pass, $database, $port, $socket)) throw new Database_Exception('#:errno: :error', array(':error' => $mysqli->connect_error, ':errno' => $mysqli->connect_errno)); diff --git a/system/libraries/Database_Mysqli_Result.php b/system/libraries/Database_Mysqli_Result.php index f8b7b588e4..96c4c7213c 100644 --- a/system/libraries/Database_Mysqli_Result.php +++ b/system/libraries/Database_Mysqli_Result.php @@ -129,24 +129,19 @@ public function as_object($class = NULL, $return = FALSE) /** * SeekableIterator: seek */ - public function seek($offset) + public function seek($offset): void { if ($this->offsetExists($offset) AND $this->result->data_seek($offset)) { // Set the current row to the offset $this->current_row = $offset; - - return TRUE; - } - else - { - return FALSE; } } /** * Iterator: current */ + #[\ReturnTypeWillChange] public function current() { if ($this->current_row !== $this->internal_row AND ! $this->seek($this->current_row)) @@ -172,4 +167,4 @@ public function current() } } -} // End Database_MySQLi_Result \ No newline at end of file +} // End Database_MySQLi_Result diff --git a/system/libraries/Database_Result.php b/system/libraries/Database_Result.php index cf2056f340..7d0aa1ce08 100644 --- a/system/libraries/Database_Result.php +++ b/system/libraries/Database_Result.php @@ -80,7 +80,7 @@ public function get($name) /** * Countable: count */ - public function count() + public function count(): int { return $this->total_rows; } @@ -88,7 +88,7 @@ public function count() /** * ArrayAccess: offsetExists */ - public function offsetExists($offset) + public function offsetExists($offset): bool { return ($offset >= 0 AND $offset < $this->total_rows); } @@ -96,7 +96,7 @@ public function offsetExists($offset) /** * ArrayAccess: offsetGet */ - public function offsetGet($offset) + public function offsetGet($offset): mixed { if ( ! $this->seek($offset)) return NULL; @@ -109,7 +109,7 @@ public function offsetGet($offset) * * @throws Kohana_Database_Exception */ - final public function offsetSet($offset, $value) + final public function offsetSet($offset, $value): void { throw new Kohana_Exception('Database results are read-only'); } @@ -119,6 +119,7 @@ final public function offsetSet($offset, $value) * * @throws Kohana_Database_Exception */ + #[\ReturnTypeWillChange] final public function offsetUnset($offset) { throw new Kohana_Exception('Database results are read-only'); @@ -127,7 +128,7 @@ final public function offsetUnset($offset) /** * Iterator: key */ - public function key() + public function key(): mixed { return $this->current_row; } @@ -135,10 +136,9 @@ public function key() /** * Iterator: next */ - public function next() + public function next(): void { ++$this->current_row; - return $this; } /** @@ -153,18 +153,17 @@ public function prev() /** * Iterator: rewind */ - public function rewind() + public function rewind(): void { $this->current_row = 0; - return $this; } /** * Iterator: valid */ - public function valid() + public function valid(): bool { return $this->offsetExists($this->current_row); } -} // End Database_Result \ No newline at end of file +} // End Database_Result diff --git a/system/libraries/Image.php b/system/libraries/Image.php index 991c8d5489..6e646e8608 100644 --- a/system/libraries/Image.php +++ b/system/libraries/Image.php @@ -31,6 +31,7 @@ class Image_Core { IMAGETYPE_GIF => 'gif', IMAGETYPE_JPEG => 'jpg', IMAGETYPE_PNG => 'png', + IMAGETYPE_WEBP => 'webp', IMAGETYPE_TIFF_II => 'tiff', IMAGETYPE_TIFF_MM => 'tiff', ); @@ -498,4 +499,4 @@ protected function valid_size($type, & $value) return TRUE; } -} // End Image \ No newline at end of file +} // End Image diff --git a/system/libraries/Input.php b/system/libraries/Input.php index fa984a882d..5b053750de 100644 --- a/system/libraries/Input.php +++ b/system/libraries/Input.php @@ -65,20 +65,6 @@ public function __construct() if (Input::$instance === NULL) { - // magic_quotes_runtime is enabled - if (get_magic_quotes_runtime()) - { - @set_magic_quotes_runtime(0); - Kohana_Log::add('debug', 'Disable magic_quotes_runtime! It is evil and deprecated: http://php.net/magic_quotes'); - } - - // magic_quotes_gpc is enabled - if (get_magic_quotes_gpc()) - { - $this->magic_quotes_gpc = TRUE; - Kohana_Log::add('debug', 'Disable magic_quotes_gpc! It is evil and deprecated: http://php.net/magic_quotes'); - } - if (is_array($_GET)) { foreach ($_GET as $key => $val) diff --git a/system/libraries/ORM.php b/system/libraries/ORM.php index 16e047bcae..4e8f848619 100644 --- a/system/libraries/ORM.php +++ b/system/libraries/ORM.php @@ -107,7 +107,7 @@ public function __construct($id = NULL) } // Initialize database - $this->__initialize(); + $this->_initialize(); // Clear the object $this->clear(); @@ -133,7 +133,7 @@ public function __construct($id = NULL) * * @return void */ - public function __initialize() + public function _initialize() { if ( ! is_object($this->db)) { @@ -186,7 +186,7 @@ public function __sleep() public function __wakeup() { // Initialize database - $this->__initialize(); + $this->_initialize(); if ($this->reload_on_wakeup === TRUE) { diff --git a/system/libraries/ORM_Iterator.php b/system/libraries/ORM_Iterator.php index 0bf2b47785..2216cdb401 100644 --- a/system/libraries/ORM_Iterator.php +++ b/system/libraries/ORM_Iterator.php @@ -168,7 +168,7 @@ public function range($start, $end) /** * Countable: count */ - public function count() + public function count(): int { return $this->result->count(); } @@ -176,6 +176,7 @@ public function count() /** * Iterator: current */ + #[\ReturnTypeWillChange] public function current() { if ($row = $this->result->current()) @@ -192,7 +193,7 @@ public function current() /** * Iterator: key */ - public function key() + public function key(): mixed { return $this->result->key(); } @@ -200,15 +201,15 @@ public function key() /** * Iterator: next */ - public function next() + public function next(): void { - return $this->result->next(); + $this->result->next(); } /** * Iterator: rewind */ - public function rewind() + public function rewind(): void { $this->result->rewind(); } @@ -216,7 +217,7 @@ public function rewind() /** * Iterator: valid */ - public function valid() + public function valid(): bool { return $this->result->valid(); } @@ -224,7 +225,7 @@ public function valid() /** * ArrayAccess: offsetExists */ - public function offsetExists($offset) + public function offsetExists($offset): bool { return $this->result->offsetExists($offset); } @@ -232,6 +233,7 @@ public function offsetExists($offset) /** * ArrayAccess: offsetGet */ + #[\ReturnTypeWillChange] public function offsetGet($offset) { if ($this->result->offsetExists($offset)) @@ -248,7 +250,7 @@ public function offsetGet($offset) * * @throws Kohana_Database_Exception */ - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { throw new Kohana_Database_Exception('database.result_read_only'); } @@ -258,9 +260,10 @@ public function offsetSet($offset, $value) * * @throws Kohana_Database_Exception */ + #[\ReturnTypeWillChange] public function offsetUnset($offset) { throw new Kohana_Database_Exception('database.result_read_only'); } -} // End ORM Iterator \ No newline at end of file +} // End ORM Iterator diff --git a/system/libraries/Router.php b/system/libraries/Router.php index c36121df4f..3046e23d97 100644 --- a/system/libraries/Router.php +++ b/system/libraries/Router.php @@ -282,7 +282,7 @@ public static function routed_uri($uri) // Trim slashes $key = trim($key, '/'); - $val = trim($val, '/'); + $val = !empty($val) ? trim($val, '/') : ''; if (preg_match('#^'.$key.'$#u', $uri)) { @@ -312,4 +312,4 @@ public static function routed_uri($uri) return trim($routed_uri, '/'); } -} // End Router \ No newline at end of file +} // End Router diff --git a/system/libraries/Validation.php b/system/libraries/Validation.php index 9917fbbca3..4dc76b67c3 100644 --- a/system/libraries/Validation.php +++ b/system/libraries/Validation.php @@ -812,4 +812,4 @@ public function chars($value, array $chars) return ! preg_match('![^'.implode('', $chars).']!u', $value); } -} // End Validation \ No newline at end of file +} // End Validation diff --git a/system/libraries/drivers/Session/Redis.php b/system/libraries/drivers/Session/Redis.php new file mode 100644 index 0000000000..3282c8d0e4 --- /dev/null +++ b/system/libraries/drivers/Session/Redis.php @@ -0,0 +1,116 @@ +config = Kohana::config('session'); + + if ( ! empty($this->config['encryption'])) + { + // Load encryption + $this->encrypt = Encrypt::instance(); + } + + if ( ! extension_loaded('redis')) + throw new Exception('The redis PHP extension must be loaded to use this driver.'); + + $this->backend = new Redis; + + if (empty($this->config['server'])) throw new Cache_Exception('Define the "server" settings in your session config'); + + $server = $this->config['server']; + + if (empty($server['host'])) throw new Cache_Exception('Missing Redis host'); + $method = !empty($server['persistent']) ? 'pconnect' : 'connect'; + + if (empty($server['port'])) + { + $this->backend->$method($server['host'], $server['port']); + } + else + { + $this->backend->$method($server['host']); + } + + Kohana_Log::add('debug', 'Session Redis Driver Initialized'); + } + + public function open($path, $name) + { + return TRUE; + } + + public function close() + { + if (empty($this->config['server']['persistent'])) + { + $this->backend->close(); + } + + return TRUE; + } + + public function read($id) + { + $data = $this->backend->get($id); + + if (!strlen($data)) + { + return ''; + } + + return ($this->encrypt === NULL) ? base64_decode($data) : $this->encrypt->decode($data); + } + + public function write($id, $data) + { + if ( ! Session::$should_save) + return TRUE; + + $this->backend->setEx( + $id, + ini_get('session.gc_maxlifetime'), + ($this->encrypt === NULL) ? base64_encode($data) : $this->encrypt->encode($data) + ); + + return TRUE; + } + + public function destroy($id) + { + $this->backend->del($id); + + return TRUE; + } + + public function regenerate() + { + // Generate a new session id + session_regenerate_id(); + + // Return new session id + return session_id(); + } + + public function gc($maxlifetime) + { + // Delete all expired sessions + + return TRUE; + } + +} // End Session Redis Driver diff --git a/themes/admin_wind/views/admin.html.php b/themes/admin_wind/views/admin.html.php index ea7542f2c7..63b9f7d301 100644 --- a/themes/admin_wind/views/admin.html.php +++ b/themes/admin_wind/views/admin.html.php @@ -4,13 +4,13 @@ html_attributes() ?> xml:lang="en" lang="en"> - start_combining("script,css") ?> + start_combining("script,css") ?> - <? if ($page_title): ?> + <?php if ($page_title): ?> <?= t("Gallery Admin: %page_title", array("page_title" => $page_title)) ?> - <? else: ?> + <?php else: ?> <?= t("Admin dashboard") ?> - <? endif ?> + <?php endif ?> " @@ -22,7 +22,7 @@ script("jquery.form.js") ?> script("jquery-ui.js") ?> script("gallery.common.js") ?> - + @@ -33,15 +33,15 @@ admin_head() ?> - + script("ui.init.js") ?> css("yui/reset-fonts-grids.css") ?> css("themeroller/ui.base.css") ?> css("superfish/css/superfish.css") ?> css("screen.css") ?> - + css("screen-rtl.css") ?> - + + + + get_combined("css") ?> + + + get_combined("script") ?> + + + body_attributes() ?>> + page_top() ?> +
      + site_status() ?> +
      +
      + + + + + + user_menu() ?> + header_top() ?> + + + + + + header_bottom() ?> +
      + + + + +
      +
      +
      +
      +
      + messages() ?> + +
      +
      +
      +
      + page_subtype, array("login", "error"))): ?> + + +
      +
      + +
      + page_bottom() ?> + + diff --git a/themes/widewind/views/paginator.html.php b/themes/widewind/views/paginator.html.php new file mode 100644 index 0000000000..94f6c39275 --- /dev/null +++ b/themes/widewind/views/paginator.html.php @@ -0,0 +1,87 @@ + + + +
        +
      • + + + + + + + + + + + + + + + + + +
      • + +
      • + + + $first_visible_position, + "to_number" => $last_visible_position, + "count" => $total)) ?> + + $position, "total" => $total)) ?> + + + + +
      • + +
      • + + + + + + + + + + + + + + + + + +
      • +
      diff --git a/themes/widewind/views/photo.html.php b/themes/widewind/views/photo.html.php new file mode 100644 index 0000000000..9b9e6602e1 --- /dev/null +++ b/themes/widewind/views/photo.html.php @@ -0,0 +1,51 @@ + + +item())): ?> + + + + +
      + photo_top() ?> + + paginator() ?> + + + +
      +

      title) ?>

      +
      description)) ?>
      +
      + + photo_bottom() ?> +
      diff --git a/themes/widewind/views/sidebar.html.php b/themes/widewind/views/sidebar.html.php new file mode 100644 index 0000000000..928ef8efb4 --- /dev/null +++ b/themes/widewind/views/sidebar.html.php @@ -0,0 +1,16 @@ + +sidebar_top() ?> +
      + + album_menu() ?> + + photo_menu() ?> + + movie_menu() ?> + + tag_menu() ?> + +
      + +sidebar_blocks() ?> +sidebar_bottom() ?> diff --git a/themes/wind/views/album.html.php b/themes/wind/views/album.html.php index ca69bda7a9..36443fe74e 100644 --- a/themes/wind/views/album.html.php +++ b/themes/wind/views/album.html.php @@ -1,5 +1,5 @@ - +
      album_top() ?>

      title) ?>

      @@ -7,21 +7,21 @@
      - - - admin || access::can("add", $item)): ?> - id") ?> + + + admin || access::can("add", $item)): ?> + id") ?>
    • Add some.", array("attrs" => html::mark_clean("href=\"$addurl\" class=\"g-dialog-link\""))) ?>
    • - +
    • - - + +
    album_bottom() ?> diff --git a/themes/wind/views/block.html.php b/themes/wind/views/block.html.php index 699d7c225a..08167a99a2 100644 --- a/themes/wind/views/block.html.php +++ b/themes/wind/views/block.html.php @@ -1,7 +1,7 @@ - + - +

    diff --git a/themes/wind/views/dynamic.html.php b/themes/wind/views/dynamic.html.php index c8b2fcaf70..c4f87673b3 100644 --- a/themes/wind/views/dynamic.html.php +++ b/themes/wind/views/dynamic.html.php @@ -7,7 +7,7 @@
    - + dynamic_bottom() ?> diff --git a/themes/wind/views/no_sidebar.html.php b/themes/wind/views/no_sidebar.html.php index 58c57256a4..ff14ded794 100644 --- a/themes/wind/views/no_sidebar.html.php +++ b/themes/wind/views/no_sidebar.html.php @@ -1,11 +1,11 @@ diff --git a/themes/wind/views/page.html.php b/themes/wind/views/page.html.php index bca1bd8131..7eb7c4c7d6 100644 --- a/themes/wind/views/page.html.php +++ b/themes/wind/views/page.html.php @@ -4,29 +4,29 @@ html_attributes() ?> xml:lang="en" lang="en"> - start_combining("script,css") ?> + start_combining("script,css") ?> - <? if ($page_title): ?> + <?php if ($page_title): ?> <?= $page_title ?> - <? else: ?> - <? if ($theme->item()): ?> + <?php else: ?> + <?php if ($theme->item()): ?> <?= html::purify($theme->item()->title) ?> - <? elseif ($theme->tag()): ?> + <?php elseif ($theme->tag()): ?> <?= t("Photos tagged with %tag_title", array("tag_title" => $theme->tag()->name)) ?> - <? else: /* Not an item, not a tag, no page_title specified. Help! */ ?> + <?php else: /* Not an item, not a tag, no page_title specified. Help! */ ?> <?= html::purify(item::root()->title) ?> - <? endif ?> - <? endif ?> + <?php endif ?> + <?php endif ?> " type="image/x-icon" /> " /> - page_type == "collection"): ?> - thumb_proportion($theme->item(), 100, "width")) != 1): ?> - - + page_type == "collection"): ?> + thumb_proportion($theme->item(), 100, "width")) != 1): ?> + + - - + + script("json2-min.js") ?> script("jquery.js") ?> script("jquery.form.js") ?> script("jquery-ui.js") ?> script("gallery.common.js") ?> - + @@ -55,15 +55,15 @@ head() ?> - + script("ui.init.js") ?> css("yui/reset-fonts-grids.css") ?> css("superfish/css/superfish.css") ?> css("themeroller/ui.base.css") ?> css("screen.css") ?> - + css("screen-rtl.css") ?> - + - +
    photo_top() ?> @@ -32,13 +32,13 @@ diff --git a/themes/wind/views/sidebar.html.php b/themes/wind/views/sidebar.html.php index 086d1359d7..928ef8efb4 100644 --- a/themes/wind/views/sidebar.html.php +++ b/themes/wind/views/sidebar.html.php @@ -1,15 +1,15 @@ sidebar_top() ?>
    - + album_menu() ?> - + photo_menu() ?> - + movie_menu() ?> - + tag_menu() ?> - +
    sidebar_blocks() ?> diff --git a/vendor/.htaccess b/vendor/.htaccess new file mode 100644 index 0000000000..a38155263d --- /dev/null +++ b/vendor/.htaccess @@ -0,0 +1,8 @@ +DirectoryIndex .htaccess +SetHandler Gallery_Security_Do_Not_Remove +Options None + +RewriteEngine off + +Order allow,deny +Deny from all