Compare commits
15 Commits
Author | SHA1 | Date |
---|---|---|
Zankaria | 67f461b22f | 2 months ago |
Zankaria | c7f3b95591 | 2 months ago |
Zankaria | 12c96d8a50 | 2 months ago |
Zankaria | 177de81550 | 2 months ago |
Zankaria | b668556814 | 2 months ago |
Zankaria | a1d857b8a7 | 2 months ago |
Zankaria | 86b46522e6 | 2 months ago |
Zankaria | 6e622f8365 | 2 months ago |
Zankaria | 1e05e1e423 | 4 months ago |
Zankaria | 60254bf122 | 4 months ago |
Zankaria | ed8224e4e0 | 4 months ago |
fowr | 3544ff6041 | 1 year ago |
Zankaria | 9112bc05d3 | 4 months ago |
Zankaria | 340f0ff916 | 4 months ago |
Zankaria | eb1ec8c688 | 4 months ago |
75 changed files with 942 additions and 805 deletions
@ -0,0 +1,3 @@ |
|||||
|
**/.git |
||||
|
**/.gitignore |
||||
|
/local-www |
@ -0,0 +1,29 @@ |
|||||
|
FROM php:8.1.8-fpm |
||||
|
|
||||
|
COPY . /code |
||||
|
|
||||
|
RUN docker-php-ext-install pdo pdo_mysql |
||||
|
RUN apt-get update -y && apt-get install -y libpng-dev libjpeg-dev libonig-dev |
||||
|
RUN docker-php-ext-install mbstring |
||||
|
RUN apt-get update -y && apt-get install -y libmcrypt-dev |
||||
|
# RUN docker-php-ext-install -j$(nproc) mcrypt |
||||
|
RUN docker-php-ext-install iconv |
||||
|
RUN apt-get update -y && apt-get install -y imagemagick |
||||
|
RUN apt-get update -y && apt-get install -y graphicsmagick |
||||
|
RUN apt-get update -y && apt-get install -y gifsicle |
||||
|
# RUN docker-php-ext-configure gd |
||||
|
# --with-jpeg=/usr/include |
||||
|
# --with-png-dir=/usr \ |
||||
|
RUN docker-php-ext-install gd |
||||
|
RUN apt-get update -y \ |
||||
|
&& apt-get install -y libmemcached11 libmemcachedutil2 build-essential libmemcached-dev libz-dev git \ |
||||
|
&& pecl install memcached \ |
||||
|
&& echo extension=memcached.so >> /usr/local/etc/php/conf.d/memcached.ini \ |
||||
|
&& apt-get remove -y build-essential libmemcached-dev libz-dev \ |
||||
|
&& apt-get autoremove -y \ |
||||
|
&& apt-get clean \ |
||||
|
&& rm -rf /tmp/pear \ |
||||
|
&& curl -sS https://getcomposer.org/installer -o composer-setup.php \ |
||||
|
&& php composer-setup.php --install-dir=/usr/local/bin --filename=composer \ |
||||
|
&& docker-php-ext-install bcmath \ |
||||
|
&& cd /code && composer install |
@ -4,7 +4,7 @@ |
|||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", |
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", |
||||
"This file is @generated automatically" |
"This file is @generated automatically" |
||||
], |
], |
||||
"content-hash": "346d80deda89b0298a414b565213f312", |
"content-hash": "9390756f1db53a7bb4475fe5b68c9f9d", |
||||
"packages": [ |
"packages": [ |
||||
{ |
{ |
||||
"name": "gettext/gettext", |
"name": "gettext/gettext", |
||||
@ -25,12 +25,12 @@ |
|||||
}, |
}, |
||||
"type": "library", |
"type": "library", |
||||
"autoload": { |
"autoload": { |
||||
"psr-0": { |
|
||||
"Gettext": "" |
|
||||
}, |
|
||||
"files": [ |
"files": [ |
||||
"Gettext/translator_functions.php" |
"Gettext/translator_functions.php" |
||||
] |
], |
||||
|
"psr-0": { |
||||
|
"Gettext": "" |
||||
|
} |
||||
}, |
}, |
||||
"notification-url": "https://packagist.org/downloads/", |
"notification-url": "https://packagist.org/downloads/", |
||||
"license": [ |
"license": [ |
||||
@ -157,6 +157,62 @@ |
|||||
}, |
}, |
||||
"time": "2017-11-03T21:04:01+00:00" |
"time": "2017-11-03T21:04:01+00:00" |
||||
}, |
}, |
||||
|
{ |
||||
|
"name": "phpmyadmin/twig-i18n-extension", |
||||
|
"version": "4.1.0", |
||||
|
"source": { |
||||
|
"type": "git", |
||||
|
"url": "https://github.com/phpmyadmin/twig-i18n-extension.git", |
||||
|
"reference": "a514a2afd29717a2a68c298582cc2739e8edeed0" |
||||
|
}, |
||||
|
"dist": { |
||||
|
"type": "zip", |
||||
|
"url": "https://api.github.com/repos/phpmyadmin/twig-i18n-extension/zipball/a514a2afd29717a2a68c298582cc2739e8edeed0", |
||||
|
"reference": "a514a2afd29717a2a68c298582cc2739e8edeed0", |
||||
|
"shasum": "" |
||||
|
}, |
||||
|
"require": { |
||||
|
"php": "^7.2 || ^8.0", |
||||
|
"twig/twig": "^1.42.3|^2.0|^3.0" |
||||
|
}, |
||||
|
"require-dev": { |
||||
|
"phpmyadmin/coding-standard": "^3.0.0", |
||||
|
"phpmyadmin/motranslator": "^5.2", |
||||
|
"phpstan/phpstan": "^1.9.4", |
||||
|
"phpunit/phpunit": "^7 || ^8 || ^9" |
||||
|
}, |
||||
|
"type": "library", |
||||
|
"autoload": { |
||||
|
"psr-4": { |
||||
|
"PhpMyAdmin\\Twig\\Extensions\\": "src/" |
||||
|
} |
||||
|
}, |
||||
|
"notification-url": "https://packagist.org/downloads/", |
||||
|
"license": [ |
||||
|
"MIT" |
||||
|
], |
||||
|
"authors": [ |
||||
|
{ |
||||
|
"name": "Fabien Potencier", |
||||
|
"email": "[email protected]" |
||||
|
}, |
||||
|
{ |
||||
|
"name": "The phpMyAdmin Team", |
||||
|
"email": "[email protected]", |
||||
|
"homepage": "https://www.phpmyadmin.net/team/" |
||||
|
} |
||||
|
], |
||||
|
"description": "Internationalization support for Twig via the gettext library", |
||||
|
"keywords": [ |
||||
|
"gettext", |
||||
|
"i18n" |
||||
|
], |
||||
|
"support": { |
||||
|
"issues": "https://github.com/phpmyadmin/twig-i18n-extension/issues", |
||||
|
"source": "https://github.com/phpmyadmin/twig-i18n-extension" |
||||
|
}, |
||||
|
"time": "2023-09-12T18:31:42+00:00" |
||||
|
}, |
||||
{ |
{ |
||||
"name": "symfony/polyfill-ctype", |
"name": "symfony/polyfill-ctype", |
||||
"version": "v1.24.0", |
"version": "v1.24.0", |
||||
@ -191,12 +247,12 @@ |
|||||
} |
} |
||||
}, |
}, |
||||
"autoload": { |
"autoload": { |
||||
"psr-4": { |
|
||||
"Symfony\\Polyfill\\Ctype\\": "" |
|
||||
}, |
|
||||
"files": [ |
"files": [ |
||||
"bootstrap.php" |
"bootstrap.php" |
||||
] |
], |
||||
|
"psr-4": { |
||||
|
"Symfony\\Polyfill\\Ctype\\": "" |
||||
|
} |
||||
}, |
}, |
||||
"notification-url": "https://packagist.org/downloads/", |
"notification-url": "https://packagist.org/downloads/", |
||||
"license": [ |
"license": [ |
||||
@ -239,32 +295,187 @@ |
|||||
], |
], |
||||
"time": "2021-10-20T20:35:02+00:00" |
"time": "2021-10-20T20:35:02+00:00" |
||||
}, |
}, |
||||
|
{ |
||||
|
"name": "symfony/polyfill-mbstring", |
||||
|
"version": "v1.29.0", |
||||
|
"source": { |
||||
|
"type": "git", |
||||
|
"url": "https://github.com/symfony/polyfill-mbstring.git", |
||||
|
"reference": "9773676c8a1bb1f8d4340a62efe641cf76eda7ec" |
||||
|
}, |
||||
|
"dist": { |
||||
|
"type": "zip", |
||||
|
"url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/9773676c8a1bb1f8d4340a62efe641cf76eda7ec", |
||||
|
"reference": "9773676c8a1bb1f8d4340a62efe641cf76eda7ec", |
||||
|
"shasum": "" |
||||
|
}, |
||||
|
"require": { |
||||
|
"php": ">=7.1" |
||||
|
}, |
||||
|
"provide": { |
||||
|
"ext-mbstring": "*" |
||||
|
}, |
||||
|
"suggest": { |
||||
|
"ext-mbstring": "For best performance" |
||||
|
}, |
||||
|
"type": "library", |
||||
|
"extra": { |
||||
|
"thanks": { |
||||
|
"name": "symfony/polyfill", |
||||
|
"url": "https://github.com/symfony/polyfill" |
||||
|
} |
||||
|
}, |
||||
|
"autoload": { |
||||
|
"files": [ |
||||
|
"bootstrap.php" |
||||
|
], |
||||
|
"psr-4": { |
||||
|
"Symfony\\Polyfill\\Mbstring\\": "" |
||||
|
} |
||||
|
}, |
||||
|
"notification-url": "https://packagist.org/downloads/", |
||||
|
"license": [ |
||||
|
"MIT" |
||||
|
], |
||||
|
"authors": [ |
||||
|
{ |
||||
|
"name": "Nicolas Grekas", |
||||
|
"email": "[email protected]" |
||||
|
}, |
||||
|
{ |
||||
|
"name": "Symfony Community", |
||||
|
"homepage": "https://symfony.com/contributors" |
||||
|
} |
||||
|
], |
||||
|
"description": "Symfony polyfill for the Mbstring extension", |
||||
|
"homepage": "https://symfony.com", |
||||
|
"keywords": [ |
||||
|
"compatibility", |
||||
|
"mbstring", |
||||
|
"polyfill", |
||||
|
"portable", |
||||
|
"shim" |
||||
|
], |
||||
|
"support": { |
||||
|
"source": "https://github.com/symfony/polyfill-mbstring/tree/v1.29.0" |
||||
|
}, |
||||
|
"funding": [ |
||||
|
{ |
||||
|
"url": "https://symfony.com/sponsor", |
||||
|
"type": "custom" |
||||
|
}, |
||||
|
{ |
||||
|
"url": "https://github.com/fabpot", |
||||
|
"type": "github" |
||||
|
}, |
||||
|
{ |
||||
|
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony", |
||||
|
"type": "tidelift" |
||||
|
} |
||||
|
], |
||||
|
"time": "2024-01-29T20:11:03+00:00" |
||||
|
}, |
||||
|
{ |
||||
|
"name": "symfony/polyfill-php72", |
||||
|
"version": "v1.29.0", |
||||
|
"source": { |
||||
|
"type": "git", |
||||
|
"url": "https://github.com/symfony/polyfill-php72.git", |
||||
|
"reference": "861391a8da9a04cbad2d232ddd9e4893220d6e25" |
||||
|
}, |
||||
|
"dist": { |
||||
|
"type": "zip", |
||||
|
"url": "https://api.github.com/repos/symfony/polyfill-php72/zipball/861391a8da9a04cbad2d232ddd9e4893220d6e25", |
||||
|
"reference": "861391a8da9a04cbad2d232ddd9e4893220d6e25", |
||||
|
"shasum": "" |
||||
|
}, |
||||
|
"require": { |
||||
|
"php": ">=7.1" |
||||
|
}, |
||||
|
"type": "library", |
||||
|
"extra": { |
||||
|
"thanks": { |
||||
|
"name": "symfony/polyfill", |
||||
|
"url": "https://github.com/symfony/polyfill" |
||||
|
} |
||||
|
}, |
||||
|
"autoload": { |
||||
|
"files": [ |
||||
|
"bootstrap.php" |
||||
|
], |
||||
|
"psr-4": { |
||||
|
"Symfony\\Polyfill\\Php72\\": "" |
||||
|
} |
||||
|
}, |
||||
|
"notification-url": "https://packagist.org/downloads/", |
||||
|
"license": [ |
||||
|
"MIT" |
||||
|
], |
||||
|
"authors": [ |
||||
|
{ |
||||
|
"name": "Nicolas Grekas", |
||||
|
"email": "[email protected]" |
||||
|
}, |
||||
|
{ |
||||
|
"name": "Symfony Community", |
||||
|
"homepage": "https://symfony.com/contributors" |
||||
|
} |
||||
|
], |
||||
|
"description": "Symfony polyfill backporting some PHP 7.2+ features to lower PHP versions", |
||||
|
"homepage": "https://symfony.com", |
||||
|
"keywords": [ |
||||
|
"compatibility", |
||||
|
"polyfill", |
||||
|
"portable", |
||||
|
"shim" |
||||
|
], |
||||
|
"support": { |
||||
|
"source": "https://github.com/symfony/polyfill-php72/tree/v1.29.0" |
||||
|
}, |
||||
|
"funding": [ |
||||
|
{ |
||||
|
"url": "https://symfony.com/sponsor", |
||||
|
"type": "custom" |
||||
|
}, |
||||
|
{ |
||||
|
"url": "https://github.com/fabpot", |
||||
|
"type": "github" |
||||
|
}, |
||||
|
{ |
||||
|
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony", |
||||
|
"type": "tidelift" |
||||
|
} |
||||
|
], |
||||
|
"time": "2024-01-29T20:11:03+00:00" |
||||
|
}, |
||||
{ |
{ |
||||
"name": "twig/twig", |
"name": "twig/twig", |
||||
"version": "v1.44.6", |
"version": "v2.15.4", |
||||
"source": { |
"source": { |
||||
"type": "git", |
"type": "git", |
||||
"url": "https://github.com/twigphp/Twig.git", |
"url": "https://github.com/twigphp/Twig.git", |
||||
"reference": "ae39480f010ef88adc7938503c9b02d3baf2f3b3" |
"reference": "3e059001d6d597dd50ea7c74dd2464b4adea48d3" |
||||
}, |
}, |
||||
"dist": { |
"dist": { |
||||
"type": "zip", |
"type": "zip", |
||||
"url": "https://api.github.com/repos/twigphp/Twig/zipball/ae39480f010ef88adc7938503c9b02d3baf2f3b3", |
"url": "https://api.github.com/repos/twigphp/Twig/zipball/3e059001d6d597dd50ea7c74dd2464b4adea48d3", |
||||
"reference": "ae39480f010ef88adc7938503c9b02d3baf2f3b3", |
"reference": "3e059001d6d597dd50ea7c74dd2464b4adea48d3", |
||||
"shasum": "" |
"shasum": "" |
||||
}, |
}, |
||||
"require": { |
"require": { |
||||
"php": ">=7.2.5", |
"php": ">=7.1.3", |
||||
"symfony/polyfill-ctype": "^1.8" |
"symfony/polyfill-ctype": "^1.8", |
||||
|
"symfony/polyfill-mbstring": "^1.3", |
||||
|
"symfony/polyfill-php72": "^1.8" |
||||
}, |
}, |
||||
"require-dev": { |
"require-dev": { |
||||
"psr/container": "^1.0", |
"psr/container": "^1.0", |
||||
"symfony/phpunit-bridge": "^4.4.9|^5.0.9" |
"symfony/phpunit-bridge": "^4.4.9|^5.0.9|^6.0" |
||||
}, |
}, |
||||
"type": "library", |
"type": "library", |
||||
"extra": { |
"extra": { |
||||
"branch-alias": { |
"branch-alias": { |
||||
"dev-master": "1.44-dev" |
"dev-master": "2.15-dev" |
||||
} |
} |
||||
}, |
}, |
||||
"autoload": { |
"autoload": { |
||||
@ -303,7 +514,7 @@ |
|||||
], |
], |
||||
"support": { |
"support": { |
||||
"issues": "https://github.com/twigphp/Twig/issues", |
"issues": "https://github.com/twigphp/Twig/issues", |
||||
"source": "https://github.com/twigphp/Twig/tree/v1.44.6" |
"source": "https://github.com/twigphp/Twig/tree/v2.15.4" |
||||
}, |
}, |
||||
"funding": [ |
"funding": [ |
||||
{ |
{ |
||||
@ -315,7 +526,7 @@ |
|||||
"type": "tidelift" |
"type": "tidelift" |
||||
} |
} |
||||
], |
], |
||||
"time": "2021-11-25T13:31:46+00:00" |
"time": "2022-12-27T12:26:20+00:00" |
||||
} |
} |
||||
], |
], |
||||
"packages-dev": [], |
"packages-dev": [], |
||||
|
@ -1,27 +1,32 @@ |
|||||
#!/bin/sh |
#!/bin/sh |
||||
|
|
||||
set -eu |
#set -eu |
||||
|
# |
||||
install -m 775 -o leftypol -g leftypol -d /var/www-leftypol |
#install -m 544 -o www-data -g www-data -d /var/www |
||||
ln -s \ |
#ln -s \ |
||||
/code/banners/ \ |
# /code/banners/ \ |
||||
/code/static/ \ |
# /code/static/ \ |
||||
/code/stylesheets/ \ |
# /code/stylesheets/ \ |
||||
/code/tools/ \ |
# /code/tools/ \ |
||||
/code/walls/ \ |
# /code/walls/ \ |
||||
/code/*.php \ |
# /code/*.php \ |
||||
/code/404.html \ |
# /code/404.html \ |
||||
/code/LICENSE.* \ |
# /code/LICENSE.* \ |
||||
/code/robots.txt \ |
# /code/robots.txt \ |
||||
/code/install.sql \ |
# /code/install.sql \ |
||||
/var/www-leftypol/ |
# /var/www/ |
||||
|
# |
||||
install -m 775 -o leftypol -g leftypol -d /var/www-leftypol/js |
#install -m 540 -o www-data -g www-data -d /var/tmp/leftypol |
||||
ln -s /code/js/* /var/www-leftypol/js/ |
#install -m 540 -o www-data -g www-data -d /var/tmp/leftypol/cache |
||||
|
#ln -s /var/tmp/leftypol /var/www/tmp |
||||
install -m 775 -o leftypol -g leftypol -d /var/www-leftypol/templates |
# |
||||
install -m 775 -o leftypol -g leftypol -d /var/www-leftypol/templates/cache |
#install -m 544 -o www-data -g www-data -d /var/www/js |
||||
ln -s /code/templates/* /var/www-leftypol/templates/ |
#ln -s /code/js/* /var/www/js/ |
||||
|
# |
||||
install -m 775 -o leftypol -g leftypol -d /var/www-leftypol/inc |
#install -m 544 -o www-data -g www-data -d /var/www/templates |
||||
ln -s /code/inc/* /var/www-leftypol/inc/ |
#install -m 544 -o www-data -g www-data -d /var/www/templates/cache |
||||
|
#ln -s /code/templates/* /var/www/templates/ |
||||
|
# |
||||
|
#install -m 544 -o www-data -g www-data -d /var/www/inc |
||||
|
#ln -s /code/inc/* /var/www/inc/ |
||||
|
# |
@ -0,0 +1,4 @@ |
|||||
|
The `php-fpm` process runs containerized. |
||||
|
The php application always uses `/var/www` as it's work directory and home folder, and if `/var/www` is bind mounted it |
||||
|
is necessary to adjust the path passed via FastCGI to `php-fpm` by changing the root directory to `/var/www`. |
||||
|
This can achieved in nginx by setting the `fastcgi_param SCRIPT_FILENAME` to `/var/www/$fastcgi_script_name;` |
@ -1,11 +1,8 @@ |
|||||
FROM nginx:1.25.3-alpine |
FROM nginx:1.25.3-alpine |
||||
|
|
||||
COPY . /code |
COPY . /code |
||||
RUN addgroup --system leftypol \ |
RUN adduser --system www-data \ |
||||
&& adduser --system leftypol \ |
&& adduser www-data www-data |
||||
&& adduser leftypol leftypol \ |
|
||||
&& /code/docker/common-setup.sh |
|
||||
|
|
||||
|
CMD [ "nginx", "-g", "daemon off;" ] |
||||
CMD ["nginx", "-g", "daemon off;"] |
EXPOSE 80 |
||||
EXPOSE 80 443 |
|
||||
|
@ -0,0 +1,74 @@ |
|||||
|
#!/bin/sh |
||||
|
|
||||
|
set -eu |
||||
|
|
||||
|
if ! mountpoint -q /var/www; then |
||||
|
echo "WARNING: '/var/www' is not a mountpoint. All the data will remain inside the container!" |
||||
|
fi |
||||
|
|
||||
|
if [ ! -w /var/www ] ; then |
||||
|
echo "ERROR: '/var/www' is not writable. Closing." |
||||
|
exit 1 |
||||
|
fi |
||||
|
|
||||
|
# Link the entrypoints from the exposed directory. |
||||
|
ln -nfs \ |
||||
|
/code/banners/ \ |
||||
|
/code/static/ \ |
||||
|
/code/stylesheets/ \ |
||||
|
/code/tools/ \ |
||||
|
/code/walls/ \ |
||||
|
/code/*.php \ |
||||
|
/code/LICENSE.* \ |
||||
|
/code/404.html \ |
||||
|
/code/install.sql \ |
||||
|
/var/www/ |
||||
|
# Ensure correct permissions are set, since this might be bind mount. |
||||
|
chown www-data /var/www |
||||
|
chgrp www-data /var/www |
||||
|
|
||||
|
# Initialize robots.txt with the default if it doesn't exist. |
||||
|
cp -n /code/robots.txt /var/www |
||||
|
|
||||
|
# Link the cache and tmp files directory. |
||||
|
ln -nfs /var/tmp/leftypol /var/www/tmp |
||||
|
|
||||
|
# Link the javascript directory. |
||||
|
ln -nfs /code/js /var/www/ |
||||
|
|
||||
|
# Link the html templates directory and it's cache. |
||||
|
ln -nfs /code/templates /var/www/ |
||||
|
ln -nfs -T /var/cache/template-cache /var/www/templates/cache |
||||
|
chown -h www-data /var/www/templates/cache |
||||
|
chgrp -h www-data /var/www/templates/cache |
||||
|
|
||||
|
# Link the generic cache. |
||||
|
ln -nfs -T /var/cache/gen-cache /var/www/tmp/cache |
||||
|
chown -h www-data /var/www/tmp/cache |
||||
|
chgrp -h www-data /var/www/tmp/cache |
||||
|
|
||||
|
# Create the included files directory and link them |
||||
|
install -d -m 700 -o www-data -g www-data /var/www/inc |
||||
|
for file in /code/inc/*; do |
||||
|
file="${file##*/}" |
||||
|
if [ ! -e /var/www/inc/$file ]; then |
||||
|
ln -s /code/inc/$file /var/www/inc/ |
||||
|
fi |
||||
|
done |
||||
|
# Copy an empty instance configuration if the file is a link (it was linked because it did not exist before). |
||||
|
if [ -L '/var/www/inc/instance-config.php' ]; then |
||||
|
echo 'INFO: Resetting instance configuration' |
||||
|
rm /var/www/inc/instance-config.php |
||||
|
cp /code/inc/instance-config.php /var/www/inc/instance-config.php |
||||
|
chown www-data /var/www/inc/instance-config.php |
||||
|
chgrp www-data /var/www/inc/instance-config.php |
||||
|
chmod 600 /var/www/inc/instance-config.php |
||||
|
else |
||||
|
echo 'INFO: Using existing instance configuration' |
||||
|
fi |
||||
|
|
||||
|
# Link the composer dependencies. |
||||
|
ln -nfs /code/vendor /var/www/ |
||||
|
|
||||
|
# Start the php-fpm server. |
||||
|
exec php-fpm |
@ -1,44 +0,0 @@ |
|||||
<?php |
|
||||
|
|
||||
/* |
|
||||
* This file is part of Twig. |
|
||||
* |
|
||||
* (c) 2010 Fabien Potencier |
|
||||
* |
|
||||
* For the full copyright and license information, please view the LICENSE |
|
||||
* file that was distributed with this source code. |
|
||||
*/ |
|
||||
class Twig_Extensions_Extension_I18n extends Twig_Extension |
|
||||
{ |
|
||||
/** |
|
||||
* Returns the token parser instances to add to the existing list. |
|
||||
* |
|
||||
* @return array An array of Twig_TokenParserInterface or Twig_TokenParserBrokerInterface instances |
|
||||
*/ |
|
||||
public function getTokenParsers() |
|
||||
{ |
|
||||
return array(new Twig_Extensions_TokenParser_Trans()); |
|
||||
} |
|
||||
|
|
||||
/** |
|
||||
* Returns a list of filters to add to the existing list. |
|
||||
* |
|
||||
* @return array An array of filters |
|
||||
*/ |
|
||||
public function getFilters() |
|
||||
{ |
|
||||
return array( |
|
||||
new Twig_SimpleFilter('trans', 'gettext'), |
|
||||
); |
|
||||
} |
|
||||
|
|
||||
/** |
|
||||
* Returns the name of the extension. |
|
||||
* |
|
||||
* @return string The extension name |
|
||||
*/ |
|
||||
public function getName() |
|
||||
{ |
|
||||
return 'i18n'; |
|
||||
} |
|
||||
} |
|
@ -1,137 +0,0 @@ |
|||||
<?php |
|
||||
|
|
||||
class Twig_Extensions_Extension_Tinyboard extends Twig_Extension |
|
||||
{ |
|
||||
/** |
|
||||
* Returns a list of filters to add to the existing list. |
|
||||
* |
|
||||
* @return array An array of filters |
|
||||
*/ |
|
||||
public function getFilters() |
|
||||
{ |
|
||||
return array( |
|
||||
new Twig_SimpleFilter('filesize', 'format_bytes'), |
|
||||
new Twig_SimpleFilter('truncate', 'twig_truncate_filter'), |
|
||||
new Twig_SimpleFilter('truncate_body', 'truncate'), |
|
||||
new Twig_SimpleFilter('truncate_filename', 'twig_filename_truncate_filter'), |
|
||||
new Twig_SimpleFilter('extension', 'twig_extension_filter'), |
|
||||
new Twig_SimpleFilter('sprintf', 'sprintf'), |
|
||||
new Twig_SimpleFilter('capcode', 'capcode'), |
|
||||
new Twig_SimpleFilter('remove_modifiers', 'remove_modifiers'), |
|
||||
new Twig_SimpleFilter('remove_markup', 'remove_markup'), |
|
||||
new Twig_SimpleFilter('newline_to_full_stop', 'newline_to_full_stop'), |
|
||||
new Twig_SimpleFilter('hasPermission', 'twig_hasPermission_filter'), |
|
||||
new Twig_SimpleFilter('date', 'twig_date_filter'), |
|
||||
new Twig_SimpleFilter('poster_id', 'poster_id'), |
|
||||
new Twig_SimpleFilter('remove_whitespace', 'twig_remove_whitespace_filter'), |
|
||||
new Twig_SimpleFilter('count', 'count'), |
|
||||
new Twig_SimpleFilter('ago', 'ago'), |
|
||||
new Twig_SimpleFilter('until', 'until'), |
|
||||
new Twig_SimpleFilter('push', 'twig_push_filter'), |
|
||||
new Twig_SimpleFilter('bidi_cleanup', 'bidi_cleanup'), |
|
||||
new Twig_SimpleFilter('addslashes', 'addslashes'), |
|
||||
); |
|
||||
} |
|
||||
|
|
||||
/** |
|
||||
* Returns a list of functions to add to the existing list. |
|
||||
* |
|
||||
* @return array An array of filters |
|
||||
*/ |
|
||||
public function getFunctions() |
|
||||
{ |
|
||||
return array( |
|
||||
new Twig_SimpleFunction('time', 'time'), |
|
||||
new Twig_SimpleFunction('floor', 'floor'), |
|
||||
new Twig_SimpleFunction('timezone', 'twig_timezone_function'), |
|
||||
new Twig_SimpleFunction('hiddenInputs', 'hiddenInputs'), |
|
||||
new Twig_SimpleFunction('hiddenInputsHash', 'hiddenInputsHash'), |
|
||||
new Twig_SimpleFunction('ratio', 'twig_ratio_function'), |
|
||||
new Twig_SimpleFunction('secure_link_confirm', 'twig_secure_link_confirm'), |
|
||||
new Twig_SimpleFunction('secure_link', 'twig_secure_link'), |
|
||||
new Twig_SimpleFunction('link_for', 'link_for') |
|
||||
); |
|
||||
} |
|
||||
|
|
||||
/** |
|
||||
* Returns the name of the extension. |
|
||||
* |
|
||||
* @return string The extension name |
|
||||
*/ |
|
||||
public function getName() |
|
||||
{ |
|
||||
return 'tinyboard'; |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
function twig_timezone_function() { |
|
||||
return 'Z'; |
|
||||
} |
|
||||
|
|
||||
function twig_push_filter($array, $value) { |
|
||||
array_push($array, $value); |
|
||||
return $array; |
|
||||
} |
|
||||
|
|
||||
function twig_remove_whitespace_filter($data) { |
|
||||
return preg_replace('/[\t\r\n]/', '', $data); |
|
||||
} |
|
||||
|
|
||||
function twig_date_filter($date, $format) { |
|
||||
return gmstrftime($format, $date); |
|
||||
} |
|
||||
|
|
||||
function twig_hasPermission_filter($mod, $permission, $board = null) { |
|
||||
return hasPermission($permission, $board, $mod); |
|
||||
} |
|
||||
|
|
||||
function twig_extension_filter($value, $case_insensitive = true) { |
|
||||
$ext = mb_substr($value, mb_strrpos($value, '.') + 1); |
|
||||
if($case_insensitive) |
|
||||
$ext = mb_strtolower($ext); |
|
||||
return $ext; |
|
||||
} |
|
||||
|
|
||||
function twig_sprintf_filter( $value, $var) { |
|
||||
return sprintf($value, $var); |
|
||||
} |
|
||||
|
|
||||
function twig_truncate_filter($value, $length = 30, $preserve = false, $separator = '…') { |
|
||||
if (mb_strlen($value) > $length) { |
|
||||
if ($preserve) { |
|
||||
if (false !== ($breakpoint = mb_strpos($value, ' ', $length))) { |
|
||||
$length = $breakpoint; |
|
||||
} |
|
||||
} |
|
||||
return mb_substr($value, 0, $length) . $separator; |
|
||||
} |
|
||||
return $value; |
|
||||
} |
|
||||
|
|
||||
function twig_filename_truncate_filter($value, $length = 30, $separator = '…') { |
|
||||
if (mb_strlen($value) > $length) { |
|
||||
$value = strrev($value); |
|
||||
$array = array_reverse(explode(".", $value, 2)); |
|
||||
$array = array_map("strrev", $array); |
|
||||
|
|
||||
$filename = &$array[0]; |
|
||||
$extension = isset($array[1]) ? $array[1] : false; |
|
||||
|
|
||||
$filename = mb_substr($filename, 0, $length - ($extension ? mb_strlen($extension) + 1 : 0)) . $separator; |
|
||||
|
|
||||
return implode(".", $array); |
|
||||
} |
|
||||
return $value; |
|
||||
} |
|
||||
|
|
||||
function twig_ratio_function($w, $h) { |
|
||||
return fraction($w, $h, ':'); |
|
||||
} |
|
||||
function twig_secure_link_confirm($text, $title, $confirm_message, $href) { |
|
||||
global $config; |
|
||||
|
|
||||
return '<a onclick="if (event.which==2) return true;if (confirm(\'' . htmlentities(addslashes($confirm_message)) . '\')) document.location=\'?/' . htmlspecialchars(addslashes($href . '/' . make_secure_link_token($href))) . '\';return false;" title="' . htmlentities($title) . '" href="?/' . $href . '">' . $text . '</a>'; |
|
||||
} |
|
||||
function twig_secure_link($href) { |
|
||||
return $href . '/' . make_secure_link_token($href); |
|
||||
} |
|
@ -1,133 +0,0 @@ |
|||||
<?php |
|
||||
|
|
||||
/* |
|
||||
* This file is part of Twig. |
|
||||
* |
|
||||
* (c) 2010 Fabien Potencier |
|
||||
* |
|
||||
* For the full copyright and license information, please view the LICENSE |
|
||||
* file that was distributed with this source code. |
|
||||
*/ |
|
||||
|
|
||||
/** |
|
||||
* Represents a trans node. |
|
||||
* |
|
||||
* @package twig |
|
||||
* @author Fabien Potencier <fabien.potencier@symfony-project.com> |
|
||||
*/ |
|
||||
class Twig_Extensions_Node_Trans extends Twig_Node |
|
||||
{ |
|
||||
public function __construct(Twig_NodeInterface $body, Twig_NodeInterface $plural = null, Twig_Node_Expression $count = null, $lineno, $tag = null) |
|
||||
{ |
|
||||
parent::__construct(array('count' => $count, 'body' => $body, 'plural' => $plural), array(), $lineno, $tag); |
|
||||
} |
|
||||
|
|
||||
/** |
|
||||
* Compiles the node to PHP. |
|
||||
* |
|
||||
* @param Twig_Compiler A Twig_Compiler instance |
|
||||
*/ |
|
||||
public function compile(Twig_Compiler $compiler) |
|
||||
{ |
|
||||
$compiler->addDebugInfo($this); |
|
||||
|
|
||||
list($msg, $vars) = $this->compileString($this->getNode('body')); |
|
||||
|
|
||||
if (null !== $this->getNode('plural')) { |
|
||||
list($msg1, $vars1) = $this->compileString($this->getNode('plural')); |
|
||||
|
|
||||
$vars = array_merge($vars, $vars1); |
|
||||
} |
|
||||
|
|
||||
$function = null === $this->getNode('plural') ? 'gettext' : 'ngettext'; |
|
||||
|
|
||||
if ($vars) { |
|
||||
$compiler |
|
||||
->write('echo strtr('.$function.'(') |
|
||||
->subcompile($msg) |
|
||||
; |
|
||||
|
|
||||
if (null !== $this->getNode('plural')) { |
|
||||
$compiler |
|
||||
->raw(', ') |
|
||||
->subcompile($msg1) |
|
||||
->raw(', abs(') |
|
||||
->subcompile($this->getNode('count')) |
|
||||
->raw(')') |
|
||||
; |
|
||||
} |
|
||||
|
|
||||
$compiler->raw('), array('); |
|
||||
|
|
||||
foreach ($vars as $var) { |
|
||||
if ('count' === $var->getAttribute('name')) { |
|
||||
$compiler |
|
||||
->string('%count%') |
|
||||
->raw(' => abs(') |
|
||||
->subcompile($this->getNode('count')) |
|
||||
->raw('), ') |
|
||||
; |
|
||||
} else { |
|
||||
$compiler |
|
||||
->string('%'.$var->getAttribute('name').'%') |
|
||||
->raw(' => ') |
|
||||
->subcompile($var) |
|
||||
->raw(', ') |
|
||||
; |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
$compiler->raw("));\n"); |
|
||||
} else { |
|
||||
$compiler |
|
||||
->write('echo '.$function.'(') |
|
||||
->subcompile($msg) |
|
||||
; |
|
||||
|
|
||||
if (null !== $this->getNode('plural')) { |
|
||||
$compiler |
|
||||
->raw(', ') |
|
||||
->subcompile($msg1) |
|
||||
->raw(', abs(') |
|
||||
->subcompile($this->getNode('count')) |
|
||||
->raw(')') |
|
||||
; |
|
||||
} |
|
||||
|
|
||||
$compiler->raw(");\n"); |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
protected function compileString(Twig_NodeInterface $body) |
|
||||
{ |
|
||||
if ($body instanceof Twig_Node_Expression_Name || $body instanceof Twig_Node_Expression_Constant || $body instanceof Twig_Node_Expression_TempName) { |
|
||||
return array($body, array()); |
|
||||
} |
|
||||
|
|
||||
$vars = array(); |
|
||||
if (count($body)) { |
|
||||
$msg = ''; |
|
||||
|
|
||||
foreach ($body as $node) { |
|
||||
if (get_class($node) === 'Twig_Node' && $node->getNode(0) instanceof Twig_Node_SetTemp) { |
|
||||
$node = $node->getNode(1); |
|
||||
} |
|
||||
|
|
||||
if ($node instanceof Twig_Node_Print) { |
|
||||
$n = $node->getNode('expr'); |
|
||||
while ($n instanceof Twig_Node_Expression_Filter) { |
|
||||
$n = $n->getNode('node'); |
|
||||
} |
|
||||
$msg .= sprintf('%%%s%%', $n->getAttribute('name')); |
|
||||
$vars[] = new Twig_Node_Expression_Name($n->getAttribute('name'), $n->getLine()); |
|
||||
} else { |
|
||||
$msg .= $node->getAttribute('data'); |
|
||||
} |
|
||||
} |
|
||||
} else { |
|
||||
$msg = $body->getAttribute('data'); |
|
||||
} |
|
||||
|
|
||||
return array(new Twig_Node(array(new Twig_Node_Expression_Constant(trim($msg), $body->getLine()))), $vars); |
|
||||
} |
|
||||
} |
|
@ -1,80 +0,0 @@ |
|||||
<?php |
|
||||
|
|
||||
/* |
|
||||
* This file is part of Twig. |
|
||||
* |
|
||||
* (c) 2010 Fabien Potencier |
|
||||
* |
|
||||
* For the full copyright and license information, please view the LICENSE |
|
||||
* file that was distributed with this source code. |
|
||||
*/ |
|
||||
class Twig_Extensions_TokenParser_Trans extends Twig_TokenParser |
|
||||
{ |
|
||||
/** |
|
||||
* Parses a token and returns a node. |
|
||||
* |
|
||||
* @param Twig_Token $token A Twig_Token instance |
|
||||
* |
|
||||
* @return Twig_NodeInterface A Twig_NodeInterface instance |
|
||||
*/ |
|
||||
public function parse(Twig_Token $token) |
|
||||
{ |
|
||||
$lineno = $token->getLine(); |
|
||||
$stream = $this->parser->getStream(); |
|
||||
$count = null; |
|
||||
$plural = null; |
|
||||
|
|
||||
if (!$stream->test(Twig_Token::BLOCK_END_TYPE)) { |
|
||||
$body = $this->parser->getExpressionParser()->parseExpression(); |
|
||||
} else { |
|
||||
$stream->expect(Twig_Token::BLOCK_END_TYPE); |
|
||||
$body = $this->parser->subparse(array($this, 'decideForFork')); |
|
||||
if ('plural' === $stream->next()->getValue()) { |
|
||||
$count = $this->parser->getExpressionParser()->parseExpression(); |
|
||||
$stream->expect(Twig_Token::BLOCK_END_TYPE); |
|
||||
$plural = $this->parser->subparse(array($this, 'decideForEnd'), true); |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
$stream->expect(Twig_Token::BLOCK_END_TYPE); |
|
||||
|
|
||||
$this->checkTransString($body, $lineno); |
|
||||
|
|
||||
return new Twig_Extensions_Node_Trans($body, $plural, $count, $lineno, $this->getTag()); |
|
||||
} |
|
||||
|
|
||||
public function decideForFork(Twig_Token $token) |
|
||||
{ |
|
||||
return $token->test(array('plural', 'endtrans')); |
|
||||
} |
|
||||
|
|
||||
public function decideForEnd(Twig_Token $token) |
|
||||
{ |
|
||||
return $token->test('endtrans'); |
|
||||
} |
|
||||
|
|
||||
/** |
|
||||
* Gets the tag name associated with this token parser. |
|
||||
* |
|
||||
* @param string The tag name |
|
||||
*/ |
|
||||
public function getTag() |
|
||||
{ |
|
||||
return 'trans'; |
|
||||
} |
|
||||
|
|
||||
protected function checkTransString(Twig_NodeInterface $body, $lineno) |
|
||||
{ |
|
||||
foreach ($body as $i => $node) { |
|
||||
if ( |
|
||||
$node instanceof Twig_Node_Text |
|
||||
|| |
|
||||
($node instanceof Twig_Node_Print && $node->getNode('expr') instanceof Twig_Node_Expression_Name) |
|
||||
) { |
|
||||
continue; |
|
||||
} |
|
||||
|
|
||||
throw new Twig_Error_Syntax(sprintf('The text to be translated with "trans" can only contain references to simple variables'), $lineno); |
|
||||
} |
|
||||
} |
|
||||
} |
|
@ -1,7 +1,7 @@ |
|||||
{% filter remove_whitespace %} |
{% apply spaceless %} |
||||
{# Automatically removes unnecessary whitespace #} |
{# Automatically removes unnecessary whitespace #} |
||||
<div class="ban"> |
<div class="ban"> |
||||
<h2>You are not banned!</h2> |
<h2>You are not banned!</h2> |
||||
<p class="reason">Well done on not being terrible!</p> |
<p class="reason">Well done on not being terrible!</p> |
||||
</div> |
</div> |
||||
{% endfilter %} |
{% endapply %} |
||||
|
Loading…
Reference in new issue