mirror of
https://github.com/getgrav/grav.git
synced 2025-10-26 07:56:07 +01:00
Finally vendor free!
This commit is contained in:
7
vendor/autoload.php
vendored
7
vendor/autoload.php
vendored
@@ -1,7 +0,0 @@
|
||||
<?php
|
||||
|
||||
// autoload.php @generated by Composer
|
||||
|
||||
require_once __DIR__ . '/composer' . '/autoload_real.php';
|
||||
|
||||
return ComposerAutoloaderInitec0ae3d965d9e7b8b1978169aa5cfad1::getLoader();
|
||||
383
vendor/composer/ClassLoader.php
vendored
383
vendor/composer/ClassLoader.php
vendored
@@ -1,383 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Composer.
|
||||
*
|
||||
* (c) Nils Adermann <naderman@naderman.de>
|
||||
* Jordi Boggiano <j.boggiano@seld.be>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Composer\Autoload;
|
||||
|
||||
/**
|
||||
* ClassLoader implements a PSR-0 class loader
|
||||
*
|
||||
* See https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-0.md
|
||||
*
|
||||
* $loader = new \Composer\Autoload\ClassLoader();
|
||||
*
|
||||
* // register classes with namespaces
|
||||
* $loader->add('Symfony\Component', __DIR__.'/component');
|
||||
* $loader->add('Symfony', __DIR__.'/framework');
|
||||
*
|
||||
* // activate the autoloader
|
||||
* $loader->register();
|
||||
*
|
||||
* // to enable searching the include path (eg. for PEAR packages)
|
||||
* $loader->setUseIncludePath(true);
|
||||
*
|
||||
* In this example, if you try to use a class in the Symfony\Component
|
||||
* namespace or one of its children (Symfony\Component\Console for instance),
|
||||
* the autoloader will first look for the class under the component/
|
||||
* directory, and it will then fallback to the framework/ directory if not
|
||||
* found before giving up.
|
||||
*
|
||||
* This class is loosely based on the Symfony UniversalClassLoader.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
* @author Jordi Boggiano <j.boggiano@seld.be>
|
||||
*/
|
||||
class ClassLoader
|
||||
{
|
||||
// PSR-4
|
||||
private $prefixLengthsPsr4 = array();
|
||||
private $prefixDirsPsr4 = array();
|
||||
private $fallbackDirsPsr4 = array();
|
||||
|
||||
// PSR-0
|
||||
private $prefixesPsr0 = array();
|
||||
private $fallbackDirsPsr0 = array();
|
||||
|
||||
private $useIncludePath = false;
|
||||
private $classMap = array();
|
||||
|
||||
public function getPrefixes()
|
||||
{
|
||||
return call_user_func_array('array_merge', $this->prefixesPsr0);
|
||||
}
|
||||
|
||||
public function getPrefixesPsr4()
|
||||
{
|
||||
return $this->prefixDirsPsr4;
|
||||
}
|
||||
|
||||
public function getFallbackDirs()
|
||||
{
|
||||
return $this->fallbackDirsPsr0;
|
||||
}
|
||||
|
||||
public function getFallbackDirsPsr4()
|
||||
{
|
||||
return $this->fallbackDirsPsr4;
|
||||
}
|
||||
|
||||
public function getClassMap()
|
||||
{
|
||||
return $this->classMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $classMap Class to filename map
|
||||
*/
|
||||
public function addClassMap(array $classMap)
|
||||
{
|
||||
if ($this->classMap) {
|
||||
$this->classMap = array_merge($this->classMap, $classMap);
|
||||
} else {
|
||||
$this->classMap = $classMap;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a set of PSR-0 directories for a given prefix, either
|
||||
* appending or prepending to the ones previously set for this prefix.
|
||||
*
|
||||
* @param string $prefix The prefix
|
||||
* @param array|string $paths The PSR-0 root directories
|
||||
* @param bool $prepend Whether to prepend the directories
|
||||
*/
|
||||
public function add($prefix, $paths, $prepend = false)
|
||||
{
|
||||
if (!$prefix) {
|
||||
if ($prepend) {
|
||||
$this->fallbackDirsPsr0 = array_merge(
|
||||
(array) $paths,
|
||||
$this->fallbackDirsPsr0
|
||||
);
|
||||
} else {
|
||||
$this->fallbackDirsPsr0 = array_merge(
|
||||
$this->fallbackDirsPsr0,
|
||||
(array) $paths
|
||||
);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$first = $prefix[0];
|
||||
if (!isset($this->prefixesPsr0[$first][$prefix])) {
|
||||
$this->prefixesPsr0[$first][$prefix] = (array) $paths;
|
||||
|
||||
return;
|
||||
}
|
||||
if ($prepend) {
|
||||
$this->prefixesPsr0[$first][$prefix] = array_merge(
|
||||
(array) $paths,
|
||||
$this->prefixesPsr0[$first][$prefix]
|
||||
);
|
||||
} else {
|
||||
$this->prefixesPsr0[$first][$prefix] = array_merge(
|
||||
$this->prefixesPsr0[$first][$prefix],
|
||||
(array) $paths
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a set of PSR-4 directories for a given namespace, either
|
||||
* appending or prepending to the ones previously set for this namespace.
|
||||
*
|
||||
* @param string $prefix The prefix/namespace, with trailing '\\'
|
||||
* @param array|string $paths The PSR-0 base directories
|
||||
* @param bool $prepend Whether to prepend the directories
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function addPsr4($prefix, $paths, $prepend = false)
|
||||
{
|
||||
if (!$prefix) {
|
||||
// Register directories for the root namespace.
|
||||
if ($prepend) {
|
||||
$this->fallbackDirsPsr4 = array_merge(
|
||||
(array) $paths,
|
||||
$this->fallbackDirsPsr4
|
||||
);
|
||||
} else {
|
||||
$this->fallbackDirsPsr4 = array_merge(
|
||||
$this->fallbackDirsPsr4,
|
||||
(array) $paths
|
||||
);
|
||||
}
|
||||
} elseif (!isset($this->prefixDirsPsr4[$prefix])) {
|
||||
// Register directories for a new namespace.
|
||||
$length = strlen($prefix);
|
||||
if ('\\' !== $prefix[$length - 1]) {
|
||||
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
|
||||
}
|
||||
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
|
||||
$this->prefixDirsPsr4[$prefix] = (array) $paths;
|
||||
} elseif ($prepend) {
|
||||
// Prepend directories for an already registered namespace.
|
||||
$this->prefixDirsPsr4[$prefix] = array_merge(
|
||||
(array) $paths,
|
||||
$this->prefixDirsPsr4[$prefix]
|
||||
);
|
||||
} else {
|
||||
// Append directories for an already registered namespace.
|
||||
$this->prefixDirsPsr4[$prefix] = array_merge(
|
||||
$this->prefixDirsPsr4[$prefix],
|
||||
(array) $paths
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a set of PSR-0 directories for a given prefix,
|
||||
* replacing any others previously set for this prefix.
|
||||
*
|
||||
* @param string $prefix The prefix
|
||||
* @param array|string $paths The PSR-0 base directories
|
||||
*/
|
||||
public function set($prefix, $paths)
|
||||
{
|
||||
if (!$prefix) {
|
||||
$this->fallbackDirsPsr0 = (array) $paths;
|
||||
} else {
|
||||
$this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a set of PSR-4 directories for a given namespace,
|
||||
* replacing any others previously set for this namespace.
|
||||
*
|
||||
* @param string $prefix The prefix/namespace, with trailing '\\'
|
||||
* @param array|string $paths The PSR-4 base directories
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function setPsr4($prefix, $paths)
|
||||
{
|
||||
if (!$prefix) {
|
||||
$this->fallbackDirsPsr4 = (array) $paths;
|
||||
} else {
|
||||
$length = strlen($prefix);
|
||||
if ('\\' !== $prefix[$length - 1]) {
|
||||
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
|
||||
}
|
||||
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
|
||||
$this->prefixDirsPsr4[$prefix] = (array) $paths;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Turns on searching the include path for class files.
|
||||
*
|
||||
* @param bool $useIncludePath
|
||||
*/
|
||||
public function setUseIncludePath($useIncludePath)
|
||||
{
|
||||
$this->useIncludePath = $useIncludePath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Can be used to check if the autoloader uses the include path to check
|
||||
* for classes.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function getUseIncludePath()
|
||||
{
|
||||
return $this->useIncludePath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers this instance as an autoloader.
|
||||
*
|
||||
* @param bool $prepend Whether to prepend the autoloader or not
|
||||
*/
|
||||
public function register($prepend = false)
|
||||
{
|
||||
spl_autoload_register(array($this, 'loadClass'), true, $prepend);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregisters this instance as an autoloader.
|
||||
*/
|
||||
public function unregister()
|
||||
{
|
||||
spl_autoload_unregister(array($this, 'loadClass'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the given class or interface.
|
||||
*
|
||||
* @param string $class The name of the class
|
||||
* @return bool|null True if loaded, null otherwise
|
||||
*/
|
||||
public function loadClass($class)
|
||||
{
|
||||
if ($file = $this->findFile($class)) {
|
||||
includeFile($file);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds the path to the file where the class is defined.
|
||||
*
|
||||
* @param string $class The name of the class
|
||||
*
|
||||
* @return string|false The path if found, false otherwise
|
||||
*/
|
||||
public function findFile($class)
|
||||
{
|
||||
// work around for PHP 5.3.0 - 5.3.2 https://bugs.php.net/50731
|
||||
if ('\\' == $class[0]) {
|
||||
$class = substr($class, 1);
|
||||
}
|
||||
|
||||
// class map lookup
|
||||
if (isset($this->classMap[$class])) {
|
||||
return $this->classMap[$class];
|
||||
}
|
||||
|
||||
$file = $this->findFileWithExtension($class, '.php');
|
||||
|
||||
// Search for Hack files if we are running on HHVM
|
||||
if ($file === null && defined('HHVM_VERSION')) {
|
||||
$file = $this->findFileWithExtension($class, '.hh');
|
||||
}
|
||||
|
||||
if ($file === null) {
|
||||
// Remember that this class does not exist.
|
||||
return $this->classMap[$class] = false;
|
||||
}
|
||||
|
||||
return $file;
|
||||
}
|
||||
|
||||
private function findFileWithExtension($class, $ext)
|
||||
{
|
||||
// PSR-4 lookup
|
||||
$logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext;
|
||||
|
||||
$first = $class[0];
|
||||
if (isset($this->prefixLengthsPsr4[$first])) {
|
||||
foreach ($this->prefixLengthsPsr4[$first] as $prefix => $length) {
|
||||
if (0 === strpos($class, $prefix)) {
|
||||
foreach ($this->prefixDirsPsr4[$prefix] as $dir) {
|
||||
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $length))) {
|
||||
return $file;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// PSR-4 fallback dirs
|
||||
foreach ($this->fallbackDirsPsr4 as $dir) {
|
||||
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) {
|
||||
return $file;
|
||||
}
|
||||
}
|
||||
|
||||
// PSR-0 lookup
|
||||
if (false !== $pos = strrpos($class, '\\')) {
|
||||
// namespaced class name
|
||||
$logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1)
|
||||
. strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR);
|
||||
} else {
|
||||
// PEAR-like class name
|
||||
$logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext;
|
||||
}
|
||||
|
||||
if (isset($this->prefixesPsr0[$first])) {
|
||||
foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) {
|
||||
if (0 === strpos($class, $prefix)) {
|
||||
foreach ($dirs as $dir) {
|
||||
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
|
||||
return $file;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// PSR-0 fallback dirs
|
||||
foreach ($this->fallbackDirsPsr0 as $dir) {
|
||||
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
|
||||
return $file;
|
||||
}
|
||||
}
|
||||
|
||||
// PSR-0 include paths.
|
||||
if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) {
|
||||
return $file;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope isolated include.
|
||||
*
|
||||
* Prevents access to $this/self from included files.
|
||||
*/
|
||||
function includeFile($file)
|
||||
{
|
||||
include $file;
|
||||
}
|
||||
419
vendor/composer/autoload_classmap.php
vendored
419
vendor/composer/autoload_classmap.php
vendored
@@ -1,419 +0,0 @@
|
||||
<?php
|
||||
|
||||
// autoload_classmap.php @generated by Composer
|
||||
|
||||
$vendorDir = dirname(dirname(__FILE__));
|
||||
$baseDir = dirname($vendorDir);
|
||||
|
||||
return array(
|
||||
'CSSmin' => $vendorDir . '/mrclay/minify/min/lib/CSSmin.php',
|
||||
'Doctrine\\Common\\Cache\\ApcCache' => $vendorDir . '/doctrine/cache/lib/Doctrine/Common/Cache/ApcCache.php',
|
||||
'Doctrine\\Common\\Cache\\ArrayCache' => $vendorDir . '/doctrine/cache/lib/Doctrine/Common/Cache/ArrayCache.php',
|
||||
'Doctrine\\Common\\Cache\\Cache' => $vendorDir . '/doctrine/cache/lib/Doctrine/Common/Cache/Cache.php',
|
||||
'Doctrine\\Common\\Cache\\CacheProvider' => $vendorDir . '/doctrine/cache/lib/Doctrine/Common/Cache/CacheProvider.php',
|
||||
'Doctrine\\Common\\Cache\\CouchbaseCache' => $vendorDir . '/doctrine/cache/lib/Doctrine/Common/Cache/CouchbaseCache.php',
|
||||
'Doctrine\\Common\\Cache\\FileCache' => $vendorDir . '/doctrine/cache/lib/Doctrine/Common/Cache/FileCache.php',
|
||||
'Doctrine\\Common\\Cache\\FilesystemCache' => $vendorDir . '/doctrine/cache/lib/Doctrine/Common/Cache/FilesystemCache.php',
|
||||
'Doctrine\\Common\\Cache\\MemcacheCache' => $vendorDir . '/doctrine/cache/lib/Doctrine/Common/Cache/MemcacheCache.php',
|
||||
'Doctrine\\Common\\Cache\\MemcachedCache' => $vendorDir . '/doctrine/cache/lib/Doctrine/Common/Cache/MemcachedCache.php',
|
||||
'Doctrine\\Common\\Cache\\MongoDBCache' => $vendorDir . '/doctrine/cache/lib/Doctrine/Common/Cache/MongoDBCache.php',
|
||||
'Doctrine\\Common\\Cache\\PhpFileCache' => $vendorDir . '/doctrine/cache/lib/Doctrine/Common/Cache/PhpFileCache.php',
|
||||
'Doctrine\\Common\\Cache\\RedisCache' => $vendorDir . '/doctrine/cache/lib/Doctrine/Common/Cache/RedisCache.php',
|
||||
'Doctrine\\Common\\Cache\\RiakCache' => $vendorDir . '/doctrine/cache/lib/Doctrine/Common/Cache/RiakCache.php',
|
||||
'Doctrine\\Common\\Cache\\Version' => $vendorDir . '/doctrine/cache/lib/Doctrine/Common/Cache/Version.php',
|
||||
'Doctrine\\Common\\Cache\\WinCacheCache' => $vendorDir . '/doctrine/cache/lib/Doctrine/Common/Cache/WinCacheCache.php',
|
||||
'Doctrine\\Common\\Cache\\XcacheCache' => $vendorDir . '/doctrine/cache/lib/Doctrine/Common/Cache/XcacheCache.php',
|
||||
'Doctrine\\Common\\Cache\\ZendDataCache' => $vendorDir . '/doctrine/cache/lib/Doctrine/Common/Cache/ZendDataCache.php',
|
||||
'DooDigestAuth' => $vendorDir . '/mrclay/minify/min/lib/DooDigestAuth.php',
|
||||
'FirePHP' => $vendorDir . '/mrclay/minify/min/lib/FirePHP.php',
|
||||
'Grav\\Common\\Assets' => $baseDir . '/system/src/Grav/Common/Assets.php',
|
||||
'Grav\\Common\\Browser' => $baseDir . '/system/src/Grav/Common/Browser.php',
|
||||
'Grav\\Common\\Cache' => $baseDir . '/system/src/Grav/Common/Cache.php',
|
||||
'Grav\\Common\\Config' => $baseDir . '/system/src/Grav/Common/Config.php',
|
||||
'Grav\\Common\\Data\\Blueprint' => $baseDir . '/system/src/Grav/Common/Data/Blueprint.php',
|
||||
'Grav\\Common\\Data\\Blueprints' => $baseDir . '/system/src/Grav/Common/Data/Blueprints.php',
|
||||
'Grav\\Common\\Data\\Data' => $baseDir . '/system/src/Grav/Common/Data/Data.php',
|
||||
'Grav\\Common\\Data\\DataInterface' => $baseDir . '/system/src/Grav/Common/Data/DataInterface.php',
|
||||
'Grav\\Common\\Data\\Validation' => $baseDir . '/system/src/Grav/Common/Data/Validation.php',
|
||||
'Grav\\Common\\Debugger' => $baseDir . '/system/src/Grav/Common/Debugger.php',
|
||||
'Grav\\Common\\Filesystem\\FileInterface' => $baseDir . '/system/src/Grav/Common/Filesystem/FileInterface.php',
|
||||
'Grav\\Common\\Filesystem\\File\\Config' => $baseDir . '/system/src/Grav/Common/Filesystem/File/Config.php',
|
||||
'Grav\\Common\\Filesystem\\File\\General' => $baseDir . '/system/src/Grav/Common/Filesystem/File/General.php',
|
||||
'Grav\\Common\\Filesystem\\File\\Json' => $baseDir . '/system/src/Grav/Common/Filesystem/File/Json.php',
|
||||
'Grav\\Common\\Filesystem\\File\\Log' => $baseDir . '/system/src/Grav/Common/Filesystem/File/Log.php',
|
||||
'Grav\\Common\\Filesystem\\File\\Markdown' => $baseDir . '/system/src/Grav/Common/Filesystem/File/Markdown.php',
|
||||
'Grav\\Common\\Filesystem\\File\\Yaml' => $baseDir . '/system/src/Grav/Common/Filesystem/File/Yaml.php',
|
||||
'Grav\\Common\\Filesystem\\Folder' => $baseDir . '/system/src/Grav/Common/Filesystem/Folder.php',
|
||||
'Grav\\Common\\Filesystem\\GravRecursiveFilterIterator' => $baseDir . '/system/src/Grav/Common/Filesystem/Folder.php',
|
||||
'Grav\\Common\\Getters' => $baseDir . '/system/src/Grav/Common/Getters.php',
|
||||
'Grav\\Common\\Grav' => $baseDir . '/system/src/Grav/Common/Grav.php',
|
||||
'Grav\\Common\\GravTrait' => $baseDir . '/system/src/Grav/Common/GravTrait.php',
|
||||
'Grav\\Common\\Inflector' => $baseDir . '/system/src/Grav/Common/Inflector.php',
|
||||
'Grav\\Common\\Iterator' => $baseDir . '/system/src/Grav/Common/Iterator.php',
|
||||
'Grav\\Common\\Markdown\\Markdown' => $baseDir . '/system/src/Grav/Common/Markdown/Markdown.php',
|
||||
'Grav\\Common\\Markdown\\MarkdownExtra' => $baseDir . '/system/src/Grav/Common/Markdown/MarkdownExtra.php',
|
||||
'Grav\\Common\\Markdown\\MarkdownGravLinkTrait' => $baseDir . '/system/src/Grav/Common/Markdown/MarkdownGravLinkTrait.php',
|
||||
'Grav\\Common\\Page\\Collection' => $baseDir . '/system/src/Grav/Common/Page/Collection.php',
|
||||
'Grav\\Common\\Page\\Media' => $baseDir . '/system/src/Grav/Common/Page/Media.php',
|
||||
'Grav\\Common\\Page\\Medium' => $baseDir . '/system/src/Grav/Common/Page/Medium.php',
|
||||
'Grav\\Common\\Page\\Page' => $baseDir . '/system/src/Grav/Common/Page/Page.php',
|
||||
'Grav\\Common\\Page\\Pages' => $baseDir . '/system/src/Grav/Common/Page/Pages.php',
|
||||
'Grav\\Common\\Plugin' => $baseDir . '/system/src/Grav/Common/Plugin.php',
|
||||
'Grav\\Common\\Plugins' => $baseDir . '/system/src/Grav/Common/Plugins.php',
|
||||
'Grav\\Common\\Registry' => $baseDir . '/system/src/Grav/Common/Registry.php',
|
||||
'Grav\\Common\\Service\\StreamsServiceProvider' => $baseDir . '/system/src/Grav/Common/Service/StreamsServiceProvider.php',
|
||||
'Grav\\Common\\Session\\Message' => $baseDir . '/system/src/Grav/Common/Session/Message.php',
|
||||
'Grav\\Common\\Session\\Session' => $baseDir . '/system/src/Grav/Common/Session/Session.php',
|
||||
'Grav\\Common\\Taxonomy' => $baseDir . '/system/src/Grav/Common/Taxonomy.php',
|
||||
'Grav\\Common\\Theme' => $baseDir . '/system/src/Grav/Common/Theme.php',
|
||||
'Grav\\Common\\Themes' => $baseDir . '/system/src/Grav/Common/Themes.php',
|
||||
'Grav\\Common\\Twig' => $baseDir . '/system/src/Grav/Common/Twig.php',
|
||||
'Grav\\Common\\TwigExtension' => $baseDir . '/system/src/Grav/Common/TwigExtension.php',
|
||||
'Grav\\Common\\Uri' => $baseDir . '/system/src/Grav/Common/Uri.php',
|
||||
'Grav\\Common\\User\\Authentication' => $baseDir . '/system/src/Grav/Common/User/Authentication.php',
|
||||
'Grav\\Common\\User\\User' => $baseDir . '/system/src/Grav/Common/User/User.php',
|
||||
'Grav\\Common\\Utils' => $baseDir . '/system/src/Grav/Common/Utils.php',
|
||||
'Grav\\Component\\ArrayTraits\\ArrayAccess' => $baseDir . '/system/src/Grav/Component/ArrayTraits/ArrayAccess.php',
|
||||
'Grav\\Component\\ArrayTraits\\Constructor' => $baseDir . '/system/src/Grav/Component/ArrayTraits/Constructor.php',
|
||||
'Grav\\Component\\ArrayTraits\\Countable' => $baseDir . '/system/src/Grav/Component/ArrayTraits/Countable.php',
|
||||
'Grav\\Component\\ArrayTraits\\Getters' => $baseDir . '/system/src/Grav/Component/ArrayTraits/Getters.php',
|
||||
'Grav\\Component\\DI\\Container' => $baseDir . '/system/src/Grav/Component/DI/Container.php',
|
||||
'Grav\\Component\\DI\\ServiceProviderInterface' => $baseDir . '/system/src/Grav/Component/DI/ServiceProviderInterface.php',
|
||||
'Grav\\Component\\EventDispatcher\\Event' => $baseDir . '/system/src/Grav/Component/EventDispatcher/Event.php',
|
||||
'Grav\\Component\\EventDispatcher\\EventDispatcher' => $baseDir . '/system/src/Grav/Component/EventDispatcher/EventDispatcher.php',
|
||||
'Grav\\Component\\EventDispatcher\\EventSubscriberInterface' => $baseDir . '/system/src/Grav/Component/EventDispatcher/EventSubscriberInterface.php',
|
||||
'Grav\\Component\\Filesystem\\ResourceLocator' => $baseDir . '/system/src/Grav/Component/Filesystem/ResourceLocator.php',
|
||||
'Grav\\Component\\Filesystem\\StreamWrapper\\ReadOnlyStream' => $baseDir . '/system/src/Grav/Component/Filesystem/StreamWrapper/ReadOnlyStream.php',
|
||||
'Grav\\Component\\Filesystem\\StreamWrapper\\Stream' => $baseDir . '/system/src/Grav/Component/Filesystem/StreamWrapper/Stream.php',
|
||||
'Grav\\Component\\Filesystem\\StreamWrapper\\StreamInterface' => $baseDir . '/system/src/Grav/Component/Filesystem/StreamWrapper/StreamInterface.php',
|
||||
'Grav\\Console\\Cli\\BackupCommand' => $baseDir . '/system/src/Grav/Console/Cli/BackupCommand.php',
|
||||
'Grav\\Console\\Cli\\CleanCommand' => $baseDir . '/system/src/Grav/Console/Cli/CleanCommand.php',
|
||||
'Grav\\Console\\Cli\\ClearCacheCommand' => $baseDir . '/system/src/Grav/Console/Cli/ClearCacheCommand.php',
|
||||
'Grav\\Console\\Cli\\InstallCommand' => $baseDir . '/system/src/Grav/Console/Cli/InstallCommand.php',
|
||||
'Grav\\Console\\Cli\\NewProjectCommand' => $baseDir . '/system/src/Grav/Console/Cli/NewProjectCommand.php',
|
||||
'Grav\\Console\\Cli\\SetupCommand' => $baseDir . '/system/src/Grav/Console/Cli/SetupCommand.php',
|
||||
'Grav\\Console\\Gpm\\FetchCommand' => $baseDir . '/system/src/Grav/Console/Gpm/FetchCommand.php',
|
||||
'Grav\\Console\\Gpm\\IndexCommand' => $baseDir . '/system/src/Grav/Console/Gpm/IndexCommand.php',
|
||||
'Grav\\Console\\Gpm\\InfoCommand' => $baseDir . '/system/src/Grav/Console/Gpm/InfoCommand.php',
|
||||
'Grav\\Console\\Gpm\\InstallCommand' => $baseDir . '/system/src/Grav/Console/Gpm/InstallCommand.php',
|
||||
'Gregwar\\Cache\\Cache' => $vendorDir . '/gregwar/cache/Gregwar/Cache/Cache.php',
|
||||
'Gregwar\\Cache\\GarbageCollect' => $vendorDir . '/gregwar/cache/Gregwar/Cache/GarbageCollect.php',
|
||||
'Gregwar\\Image\\Adapter\\Adapter' => $vendorDir . '/gregwar/image/Gregwar/Image/Adapter/Adapter.php',
|
||||
'Gregwar\\Image\\Adapter\\AdapterInterface' => $vendorDir . '/gregwar/image/Gregwar/Image/Adapter/AdapterInterface.php',
|
||||
'Gregwar\\Image\\Adapter\\Common' => $vendorDir . '/gregwar/image/Gregwar/Image/Adapter/Common.php',
|
||||
'Gregwar\\Image\\Adapter\\GD' => $vendorDir . '/gregwar/image/Gregwar/Image/Adapter/GD.php',
|
||||
'Gregwar\\Image\\Adapter\\Imagick' => $vendorDir . '/gregwar/image/Gregwar/Image/Adapter/Imagick.php',
|
||||
'Gregwar\\Image\\Exceptions\\GenerationError' => $vendorDir . '/gregwar/image/Gregwar/Image/Exceptions/GenerationError.php',
|
||||
'Gregwar\\Image\\GarbageCollect' => $vendorDir . '/gregwar/image/Gregwar/Image/GarbageCollect.php',
|
||||
'Gregwar\\Image\\Image' => $vendorDir . '/gregwar/image/Gregwar/Image/Image.php',
|
||||
'Gregwar\\Image\\ImageColor' => $vendorDir . '/gregwar/image/Gregwar/Image/ImageColor.php',
|
||||
'Gregwar\\Image\\Source\\Create' => $vendorDir . '/gregwar/image/Gregwar/Image/Source/Create.php',
|
||||
'Gregwar\\Image\\Source\\Data' => $vendorDir . '/gregwar/image/Gregwar/Image/Source/Data.php',
|
||||
'Gregwar\\Image\\Source\\File' => $vendorDir . '/gregwar/image/Gregwar/Image/Source/File.php',
|
||||
'Gregwar\\Image\\Source\\Resource' => $vendorDir . '/gregwar/image/Gregwar/Image/Source/Resource.php',
|
||||
'Gregwar\\Image\\Source\\Source' => $vendorDir . '/gregwar/image/Gregwar/Image/Source/Source.php',
|
||||
'HTTP_ConditionalGet' => $vendorDir . '/mrclay/minify/min/lib/HTTP/ConditionalGet.php',
|
||||
'HTTP_Encoder' => $vendorDir . '/mrclay/minify/min/lib/HTTP/Encoder.php',
|
||||
'JSCompilerContext' => $vendorDir . '/mrclay/minify/min/lib/JSMinPlus.php',
|
||||
'JSMin' => $vendorDir . '/mrclay/minify/min/lib/JSMin.php',
|
||||
'JSMinPlus' => $vendorDir . '/mrclay/minify/min/lib/JSMinPlus.php',
|
||||
'JSMin_UnterminatedCommentException' => $vendorDir . '/mrclay/minify/min/lib/JSMin.php',
|
||||
'JSMin_UnterminatedRegExpException' => $vendorDir . '/mrclay/minify/min/lib/JSMin.php',
|
||||
'JSMin_UnterminatedStringException' => $vendorDir . '/mrclay/minify/min/lib/JSMin.php',
|
||||
'JSNode' => $vendorDir . '/mrclay/minify/min/lib/JSMinPlus.php',
|
||||
'JSParser' => $vendorDir . '/mrclay/minify/min/lib/JSMinPlus.php',
|
||||
'JSToken' => $vendorDir . '/mrclay/minify/min/lib/JSMinPlus.php',
|
||||
'JSTokenizer' => $vendorDir . '/mrclay/minify/min/lib/JSMinPlus.php',
|
||||
'Minify' => $vendorDir . '/mrclay/minify/min/lib/Minify.php',
|
||||
'Minify_Build' => $vendorDir . '/mrclay/minify/min/lib/Minify/Build.php',
|
||||
'Minify_CSS' => $vendorDir . '/mrclay/minify/min/lib/Minify/CSS.php',
|
||||
'Minify_CSS_Compressor' => $vendorDir . '/mrclay/minify/min/lib/Minify/CSS/Compressor.php',
|
||||
'Minify_CSS_UriRewriter' => $vendorDir . '/mrclay/minify/min/lib/Minify/CSS/UriRewriter.php',
|
||||
'Minify_CSSmin' => $vendorDir . '/mrclay/minify/min/lib/Minify/CSSmin.php',
|
||||
'Minify_Cache_APC' => $vendorDir . '/mrclay/minify/min/lib/Minify/Cache/APC.php',
|
||||
'Minify_Cache_File' => $vendorDir . '/mrclay/minify/min/lib/Minify/Cache/File.php',
|
||||
'Minify_Cache_Memcache' => $vendorDir . '/mrclay/minify/min/lib/Minify/Cache/Memcache.php',
|
||||
'Minify_Cache_XCache' => $vendorDir . '/mrclay/minify/min/lib/Minify/Cache/XCache.php',
|
||||
'Minify_Cache_ZendPlatform' => $vendorDir . '/mrclay/minify/min/lib/Minify/Cache/ZendPlatform.php',
|
||||
'Minify_ClosureCompiler' => $vendorDir . '/mrclay/minify/min/lib/Minify/ClosureCompiler.php',
|
||||
'Minify_ClosureCompiler_Exception' => $vendorDir . '/mrclay/minify/min/lib/Minify/ClosureCompiler.php',
|
||||
'Minify_CommentPreserver' => $vendorDir . '/mrclay/minify/min/lib/Minify/CommentPreserver.php',
|
||||
'Minify_Controller_Base' => $vendorDir . '/mrclay/minify/min/lib/Minify/Controller/Base.php',
|
||||
'Minify_Controller_Files' => $vendorDir . '/mrclay/minify/min/lib/Minify/Controller/Files.php',
|
||||
'Minify_Controller_Groups' => $vendorDir . '/mrclay/minify/min/lib/Minify/Controller/Groups.php',
|
||||
'Minify_Controller_MinApp' => $vendorDir . '/mrclay/minify/min/lib/Minify/Controller/MinApp.php',
|
||||
'Minify_Controller_Page' => $vendorDir . '/mrclay/minify/min/lib/Minify/Controller/Page.php',
|
||||
'Minify_Controller_Version1' => $vendorDir . '/mrclay/minify/min/lib/Minify/Controller/Version1.php',
|
||||
'Minify_DebugDetector' => $vendorDir . '/mrclay/minify/min/lib/Minify/DebugDetector.php',
|
||||
'Minify_HTML' => $vendorDir . '/mrclay/minify/min/lib/Minify/HTML.php',
|
||||
'Minify_HTML_Helper' => $vendorDir . '/mrclay/minify/min/lib/Minify/HTML/Helper.php',
|
||||
'Minify_ImportProcessor' => $vendorDir . '/mrclay/minify/min/lib/Minify/ImportProcessor.php',
|
||||
'Minify_JS_ClosureCompiler' => $vendorDir . '/mrclay/minify/min/lib/Minify/JS/ClosureCompiler.php',
|
||||
'Minify_JS_ClosureCompiler_Exception' => $vendorDir . '/mrclay/minify/min/lib/Minify/JS/ClosureCompiler.php',
|
||||
'Minify_Lines' => $vendorDir . '/mrclay/minify/min/lib/Minify/Lines.php',
|
||||
'Minify_Loader' => $vendorDir . '/mrclay/minify/min/lib/Minify/Loader.php',
|
||||
'Minify_Logger' => $vendorDir . '/mrclay/minify/min/lib/Minify/Logger.php',
|
||||
'Minify_Packer' => $vendorDir . '/mrclay/minify/min/lib/Minify/Packer.php',
|
||||
'Minify_Source' => $vendorDir . '/mrclay/minify/min/lib/Minify/Source.php',
|
||||
'Minify_YUICompressor' => $vendorDir . '/mrclay/minify/min/lib/Minify/YUICompressor.php',
|
||||
'Minify_YUI_CssCompressor' => $vendorDir . '/mrclay/minify/min/lib/Minify/YUI/CssCompressor.php',
|
||||
'MrClay\\Cli' => $vendorDir . '/mrclay/minify/min/lib/MrClay/Cli.php',
|
||||
'MrClay\\Cli\\Arg' => $vendorDir . '/mrclay/minify/min/lib/MrClay/Cli/Arg.php',
|
||||
'Parsedown' => $vendorDir . '/erusev/parsedown/Parsedown.php',
|
||||
'ParsedownExtra' => $vendorDir . '/erusev/parsedown-extra/ParsedownExtra.php',
|
||||
'Pimple\\Container' => $vendorDir . '/pimple/pimple/src/Pimple/Container.php',
|
||||
'Pimple\\ServiceProviderInterface' => $vendorDir . '/pimple/pimple/src/Pimple/ServiceProviderInterface.php',
|
||||
'Symfony\\Component\\Console\\Application' => $vendorDir . '/symfony/console/Symfony/Component/Console/Application.php',
|
||||
'Symfony\\Component\\Console\\Command\\Command' => $vendorDir . '/symfony/console/Symfony/Component/Console/Command/Command.php',
|
||||
'Symfony\\Component\\Console\\Command\\HelpCommand' => $vendorDir . '/symfony/console/Symfony/Component/Console/Command/HelpCommand.php',
|
||||
'Symfony\\Component\\Console\\Command\\ListCommand' => $vendorDir . '/symfony/console/Symfony/Component/Console/Command/ListCommand.php',
|
||||
'Symfony\\Component\\Console\\ConsoleEvents' => $vendorDir . '/symfony/console/Symfony/Component/Console/ConsoleEvents.php',
|
||||
'Symfony\\Component\\Console\\Descriptor\\ApplicationDescription' => $vendorDir . '/symfony/console/Symfony/Component/Console/Descriptor/ApplicationDescription.php',
|
||||
'Symfony\\Component\\Console\\Descriptor\\Descriptor' => $vendorDir . '/symfony/console/Symfony/Component/Console/Descriptor/Descriptor.php',
|
||||
'Symfony\\Component\\Console\\Descriptor\\DescriptorInterface' => $vendorDir . '/symfony/console/Symfony/Component/Console/Descriptor/DescriptorInterface.php',
|
||||
'Symfony\\Component\\Console\\Descriptor\\JsonDescriptor' => $vendorDir . '/symfony/console/Symfony/Component/Console/Descriptor/JsonDescriptor.php',
|
||||
'Symfony\\Component\\Console\\Descriptor\\MarkdownDescriptor' => $vendorDir . '/symfony/console/Symfony/Component/Console/Descriptor/MarkdownDescriptor.php',
|
||||
'Symfony\\Component\\Console\\Descriptor\\TextDescriptor' => $vendorDir . '/symfony/console/Symfony/Component/Console/Descriptor/TextDescriptor.php',
|
||||
'Symfony\\Component\\Console\\Descriptor\\XmlDescriptor' => $vendorDir . '/symfony/console/Symfony/Component/Console/Descriptor/XmlDescriptor.php',
|
||||
'Symfony\\Component\\Console\\Event\\ConsoleCommandEvent' => $vendorDir . '/symfony/console/Symfony/Component/Console/Event/ConsoleCommandEvent.php',
|
||||
'Symfony\\Component\\Console\\Event\\ConsoleEvent' => $vendorDir . '/symfony/console/Symfony/Component/Console/Event/ConsoleEvent.php',
|
||||
'Symfony\\Component\\Console\\Event\\ConsoleExceptionEvent' => $vendorDir . '/symfony/console/Symfony/Component/Console/Event/ConsoleExceptionEvent.php',
|
||||
'Symfony\\Component\\Console\\Event\\ConsoleTerminateEvent' => $vendorDir . '/symfony/console/Symfony/Component/Console/Event/ConsoleTerminateEvent.php',
|
||||
'Symfony\\Component\\Console\\Formatter\\OutputFormatter' => $vendorDir . '/symfony/console/Symfony/Component/Console/Formatter/OutputFormatter.php',
|
||||
'Symfony\\Component\\Console\\Formatter\\OutputFormatterInterface' => $vendorDir . '/symfony/console/Symfony/Component/Console/Formatter/OutputFormatterInterface.php',
|
||||
'Symfony\\Component\\Console\\Formatter\\OutputFormatterStyle' => $vendorDir . '/symfony/console/Symfony/Component/Console/Formatter/OutputFormatterStyle.php',
|
||||
'Symfony\\Component\\Console\\Formatter\\OutputFormatterStyleInterface' => $vendorDir . '/symfony/console/Symfony/Component/Console/Formatter/OutputFormatterStyleInterface.php',
|
||||
'Symfony\\Component\\Console\\Formatter\\OutputFormatterStyleStack' => $vendorDir . '/symfony/console/Symfony/Component/Console/Formatter/OutputFormatterStyleStack.php',
|
||||
'Symfony\\Component\\Console\\Helper\\DescriptorHelper' => $vendorDir . '/symfony/console/Symfony/Component/Console/Helper/DescriptorHelper.php',
|
||||
'Symfony\\Component\\Console\\Helper\\DialogHelper' => $vendorDir . '/symfony/console/Symfony/Component/Console/Helper/DialogHelper.php',
|
||||
'Symfony\\Component\\Console\\Helper\\FormatterHelper' => $vendorDir . '/symfony/console/Symfony/Component/Console/Helper/FormatterHelper.php',
|
||||
'Symfony\\Component\\Console\\Helper\\Helper' => $vendorDir . '/symfony/console/Symfony/Component/Console/Helper/Helper.php',
|
||||
'Symfony\\Component\\Console\\Helper\\HelperInterface' => $vendorDir . '/symfony/console/Symfony/Component/Console/Helper/HelperInterface.php',
|
||||
'Symfony\\Component\\Console\\Helper\\HelperSet' => $vendorDir . '/symfony/console/Symfony/Component/Console/Helper/HelperSet.php',
|
||||
'Symfony\\Component\\Console\\Helper\\InputAwareHelper' => $vendorDir . '/symfony/console/Symfony/Component/Console/Helper/InputAwareHelper.php',
|
||||
'Symfony\\Component\\Console\\Helper\\ProgressBar' => $vendorDir . '/symfony/console/Symfony/Component/Console/Helper/ProgressBar.php',
|
||||
'Symfony\\Component\\Console\\Helper\\ProgressHelper' => $vendorDir . '/symfony/console/Symfony/Component/Console/Helper/ProgressHelper.php',
|
||||
'Symfony\\Component\\Console\\Helper\\QuestionHelper' => $vendorDir . '/symfony/console/Symfony/Component/Console/Helper/QuestionHelper.php',
|
||||
'Symfony\\Component\\Console\\Helper\\Table' => $vendorDir . '/symfony/console/Symfony/Component/Console/Helper/Table.php',
|
||||
'Symfony\\Component\\Console\\Helper\\TableHelper' => $vendorDir . '/symfony/console/Symfony/Component/Console/Helper/TableHelper.php',
|
||||
'Symfony\\Component\\Console\\Helper\\TableSeparator' => $vendorDir . '/symfony/console/Symfony/Component/Console/Helper/TableSeparator.php',
|
||||
'Symfony\\Component\\Console\\Helper\\TableStyle' => $vendorDir . '/symfony/console/Symfony/Component/Console/Helper/TableStyle.php',
|
||||
'Symfony\\Component\\Console\\Input\\ArgvInput' => $vendorDir . '/symfony/console/Symfony/Component/Console/Input/ArgvInput.php',
|
||||
'Symfony\\Component\\Console\\Input\\ArrayInput' => $vendorDir . '/symfony/console/Symfony/Component/Console/Input/ArrayInput.php',
|
||||
'Symfony\\Component\\Console\\Input\\Input' => $vendorDir . '/symfony/console/Symfony/Component/Console/Input/Input.php',
|
||||
'Symfony\\Component\\Console\\Input\\InputArgument' => $vendorDir . '/symfony/console/Symfony/Component/Console/Input/InputArgument.php',
|
||||
'Symfony\\Component\\Console\\Input\\InputAwareInterface' => $vendorDir . '/symfony/console/Symfony/Component/Console/Input/InputAwareInterface.php',
|
||||
'Symfony\\Component\\Console\\Input\\InputDefinition' => $vendorDir . '/symfony/console/Symfony/Component/Console/Input/InputDefinition.php',
|
||||
'Symfony\\Component\\Console\\Input\\InputInterface' => $vendorDir . '/symfony/console/Symfony/Component/Console/Input/InputInterface.php',
|
||||
'Symfony\\Component\\Console\\Input\\InputOption' => $vendorDir . '/symfony/console/Symfony/Component/Console/Input/InputOption.php',
|
||||
'Symfony\\Component\\Console\\Input\\StringInput' => $vendorDir . '/symfony/console/Symfony/Component/Console/Input/StringInput.php',
|
||||
'Symfony\\Component\\Console\\Logger\\ConsoleLogger' => $vendorDir . '/symfony/console/Symfony/Component/Console/Logger/ConsoleLogger.php',
|
||||
'Symfony\\Component\\Console\\Output\\BufferedOutput' => $vendorDir . '/symfony/console/Symfony/Component/Console/Output/BufferedOutput.php',
|
||||
'Symfony\\Component\\Console\\Output\\ConsoleOutput' => $vendorDir . '/symfony/console/Symfony/Component/Console/Output/ConsoleOutput.php',
|
||||
'Symfony\\Component\\Console\\Output\\ConsoleOutputInterface' => $vendorDir . '/symfony/console/Symfony/Component/Console/Output/ConsoleOutputInterface.php',
|
||||
'Symfony\\Component\\Console\\Output\\NullOutput' => $vendorDir . '/symfony/console/Symfony/Component/Console/Output/NullOutput.php',
|
||||
'Symfony\\Component\\Console\\Output\\Output' => $vendorDir . '/symfony/console/Symfony/Component/Console/Output/Output.php',
|
||||
'Symfony\\Component\\Console\\Output\\OutputInterface' => $vendorDir . '/symfony/console/Symfony/Component/Console/Output/OutputInterface.php',
|
||||
'Symfony\\Component\\Console\\Output\\StreamOutput' => $vendorDir . '/symfony/console/Symfony/Component/Console/Output/StreamOutput.php',
|
||||
'Symfony\\Component\\Console\\Question\\ChoiceQuestion' => $vendorDir . '/symfony/console/Symfony/Component/Console/Question/ChoiceQuestion.php',
|
||||
'Symfony\\Component\\Console\\Question\\ConfirmationQuestion' => $vendorDir . '/symfony/console/Symfony/Component/Console/Question/ConfirmationQuestion.php',
|
||||
'Symfony\\Component\\Console\\Question\\Question' => $vendorDir . '/symfony/console/Symfony/Component/Console/Question/Question.php',
|
||||
'Symfony\\Component\\Console\\Shell' => $vendorDir . '/symfony/console/Symfony/Component/Console/Shell.php',
|
||||
'Symfony\\Component\\Console\\Tester\\ApplicationTester' => $vendorDir . '/symfony/console/Symfony/Component/Console/Tester/ApplicationTester.php',
|
||||
'Symfony\\Component\\Console\\Tester\\CommandTester' => $vendorDir . '/symfony/console/Symfony/Component/Console/Tester/CommandTester.php',
|
||||
'Symfony\\Component\\EventDispatcher\\ContainerAwareEventDispatcher' => $vendorDir . '/symfony/event-dispatcher/Symfony/Component/EventDispatcher/ContainerAwareEventDispatcher.php',
|
||||
'Symfony\\Component\\EventDispatcher\\Debug\\TraceableEventDispatcher' => $vendorDir . '/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcher.php',
|
||||
'Symfony\\Component\\EventDispatcher\\Debug\\TraceableEventDispatcherInterface' => $vendorDir . '/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcherInterface.php',
|
||||
'Symfony\\Component\\EventDispatcher\\Debug\\WrappedListener' => $vendorDir . '/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Debug/WrappedListener.php',
|
||||
'Symfony\\Component\\EventDispatcher\\DependencyInjection\\RegisterListenersPass' => $vendorDir . '/symfony/event-dispatcher/Symfony/Component/EventDispatcher/DependencyInjection/RegisterListenersPass.php',
|
||||
'Symfony\\Component\\EventDispatcher\\Event' => $vendorDir . '/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Event.php',
|
||||
'Symfony\\Component\\EventDispatcher\\EventDispatcher' => $vendorDir . '/symfony/event-dispatcher/Symfony/Component/EventDispatcher/EventDispatcher.php',
|
||||
'Symfony\\Component\\EventDispatcher\\EventDispatcherInterface' => $vendorDir . '/symfony/event-dispatcher/Symfony/Component/EventDispatcher/EventDispatcherInterface.php',
|
||||
'Symfony\\Component\\EventDispatcher\\EventSubscriberInterface' => $vendorDir . '/symfony/event-dispatcher/Symfony/Component/EventDispatcher/EventSubscriberInterface.php',
|
||||
'Symfony\\Component\\EventDispatcher\\GenericEvent' => $vendorDir . '/symfony/event-dispatcher/Symfony/Component/EventDispatcher/GenericEvent.php',
|
||||
'Symfony\\Component\\EventDispatcher\\ImmutableEventDispatcher' => $vendorDir . '/symfony/event-dispatcher/Symfony/Component/EventDispatcher/ImmutableEventDispatcher.php',
|
||||
'Symfony\\Component\\Yaml\\Dumper' => $vendorDir . '/symfony/yaml/Symfony/Component/Yaml/Dumper.php',
|
||||
'Symfony\\Component\\Yaml\\Escaper' => $vendorDir . '/symfony/yaml/Symfony/Component/Yaml/Escaper.php',
|
||||
'Symfony\\Component\\Yaml\\Exception\\DumpException' => $vendorDir . '/symfony/yaml/Symfony/Component/Yaml/Exception/DumpException.php',
|
||||
'Symfony\\Component\\Yaml\\Exception\\ExceptionInterface' => $vendorDir . '/symfony/yaml/Symfony/Component/Yaml/Exception/ExceptionInterface.php',
|
||||
'Symfony\\Component\\Yaml\\Exception\\ParseException' => $vendorDir . '/symfony/yaml/Symfony/Component/Yaml/Exception/ParseException.php',
|
||||
'Symfony\\Component\\Yaml\\Exception\\RuntimeException' => $vendorDir . '/symfony/yaml/Symfony/Component/Yaml/Exception/RuntimeException.php',
|
||||
'Symfony\\Component\\Yaml\\Inline' => $vendorDir . '/symfony/yaml/Symfony/Component/Yaml/Inline.php',
|
||||
'Symfony\\Component\\Yaml\\Parser' => $vendorDir . '/symfony/yaml/Symfony/Component/Yaml/Parser.php',
|
||||
'Symfony\\Component\\Yaml\\Unescaper' => $vendorDir . '/symfony/yaml/Symfony/Component/Yaml/Unescaper.php',
|
||||
'Symfony\\Component\\Yaml\\Yaml' => $vendorDir . '/symfony/yaml/Symfony/Component/Yaml/Yaml.php',
|
||||
'Tracy\\Bar' => $vendorDir . '/tracy/tracy/src/Tracy/Bar.php',
|
||||
'Tracy\\BlueScreen' => $vendorDir . '/tracy/tracy/src/Tracy/BlueScreen.php',
|
||||
'Tracy\\Debugger' => $vendorDir . '/tracy/tracy/src/Tracy/Debugger.php',
|
||||
'Tracy\\DefaultBarPanel' => $vendorDir . '/tracy/tracy/src/Tracy/DefaultBarPanel.php',
|
||||
'Tracy\\Dumper' => $vendorDir . '/tracy/tracy/src/Tracy/Dumper.php',
|
||||
'Tracy\\FireLogger' => $vendorDir . '/tracy/tracy/src/Tracy/FireLogger.php',
|
||||
'Tracy\\Helpers' => $vendorDir . '/tracy/tracy/src/Tracy/Helpers.php',
|
||||
'Tracy\\IBarPanel' => $vendorDir . '/tracy/tracy/src/Tracy/IBarPanel.php',
|
||||
'Tracy\\Logger' => $vendorDir . '/tracy/tracy/src/Tracy/Logger.php',
|
||||
'Tracy\\OutputDebugger' => $vendorDir . '/tracy/tracy/src/Tracy/OutputDebugger.php',
|
||||
'Twig_Autoloader' => $vendorDir . '/twig/twig/lib/Twig/Autoloader.php',
|
||||
'Twig_Compiler' => $vendorDir . '/twig/twig/lib/Twig/Compiler.php',
|
||||
'Twig_CompilerInterface' => $vendorDir . '/twig/twig/lib/Twig/CompilerInterface.php',
|
||||
'Twig_Environment' => $vendorDir . '/twig/twig/lib/Twig/Environment.php',
|
||||
'Twig_Error' => $vendorDir . '/twig/twig/lib/Twig/Error.php',
|
||||
'Twig_Error_Loader' => $vendorDir . '/twig/twig/lib/Twig/Error/Loader.php',
|
||||
'Twig_Error_Runtime' => $vendorDir . '/twig/twig/lib/Twig/Error/Runtime.php',
|
||||
'Twig_Error_Syntax' => $vendorDir . '/twig/twig/lib/Twig/Error/Syntax.php',
|
||||
'Twig_ExistsLoaderInterface' => $vendorDir . '/twig/twig/lib/Twig/ExistsLoaderInterface.php',
|
||||
'Twig_ExpressionParser' => $vendorDir . '/twig/twig/lib/Twig/ExpressionParser.php',
|
||||
'Twig_Extension' => $vendorDir . '/twig/twig/lib/Twig/Extension.php',
|
||||
'Twig_ExtensionInterface' => $vendorDir . '/twig/twig/lib/Twig/ExtensionInterface.php',
|
||||
'Twig_Extension_Core' => $vendorDir . '/twig/twig/lib/Twig/Extension/Core.php',
|
||||
'Twig_Extension_Debug' => $vendorDir . '/twig/twig/lib/Twig/Extension/Debug.php',
|
||||
'Twig_Extension_Escaper' => $vendorDir . '/twig/twig/lib/Twig/Extension/Escaper.php',
|
||||
'Twig_Extension_Optimizer' => $vendorDir . '/twig/twig/lib/Twig/Extension/Optimizer.php',
|
||||
'Twig_Extension_Sandbox' => $vendorDir . '/twig/twig/lib/Twig/Extension/Sandbox.php',
|
||||
'Twig_Extension_Staging' => $vendorDir . '/twig/twig/lib/Twig/Extension/Staging.php',
|
||||
'Twig_Extension_StringLoader' => $vendorDir . '/twig/twig/lib/Twig/Extension/StringLoader.php',
|
||||
'Twig_Filter' => $vendorDir . '/twig/twig/lib/Twig/Filter.php',
|
||||
'Twig_FilterCallableInterface' => $vendorDir . '/twig/twig/lib/Twig/FilterCallableInterface.php',
|
||||
'Twig_FilterInterface' => $vendorDir . '/twig/twig/lib/Twig/FilterInterface.php',
|
||||
'Twig_Filter_Function' => $vendorDir . '/twig/twig/lib/Twig/Filter/Function.php',
|
||||
'Twig_Filter_Method' => $vendorDir . '/twig/twig/lib/Twig/Filter/Method.php',
|
||||
'Twig_Filter_Node' => $vendorDir . '/twig/twig/lib/Twig/Filter/Node.php',
|
||||
'Twig_Function' => $vendorDir . '/twig/twig/lib/Twig/Function.php',
|
||||
'Twig_FunctionCallableInterface' => $vendorDir . '/twig/twig/lib/Twig/FunctionCallableInterface.php',
|
||||
'Twig_FunctionInterface' => $vendorDir . '/twig/twig/lib/Twig/FunctionInterface.php',
|
||||
'Twig_Function_Function' => $vendorDir . '/twig/twig/lib/Twig/Function/Function.php',
|
||||
'Twig_Function_Method' => $vendorDir . '/twig/twig/lib/Twig/Function/Method.php',
|
||||
'Twig_Function_Node' => $vendorDir . '/twig/twig/lib/Twig/Function/Node.php',
|
||||
'Twig_Lexer' => $vendorDir . '/twig/twig/lib/Twig/Lexer.php',
|
||||
'Twig_LexerInterface' => $vendorDir . '/twig/twig/lib/Twig/LexerInterface.php',
|
||||
'Twig_LoaderInterface' => $vendorDir . '/twig/twig/lib/Twig/LoaderInterface.php',
|
||||
'Twig_Loader_Array' => $vendorDir . '/twig/twig/lib/Twig/Loader/Array.php',
|
||||
'Twig_Loader_Chain' => $vendorDir . '/twig/twig/lib/Twig/Loader/Chain.php',
|
||||
'Twig_Loader_Filesystem' => $vendorDir . '/twig/twig/lib/Twig/Loader/Filesystem.php',
|
||||
'Twig_Loader_String' => $vendorDir . '/twig/twig/lib/Twig/Loader/String.php',
|
||||
'Twig_Markup' => $vendorDir . '/twig/twig/lib/Twig/Markup.php',
|
||||
'Twig_Node' => $vendorDir . '/twig/twig/lib/Twig/Node.php',
|
||||
'Twig_NodeInterface' => $vendorDir . '/twig/twig/lib/Twig/NodeInterface.php',
|
||||
'Twig_NodeOutputInterface' => $vendorDir . '/twig/twig/lib/Twig/NodeOutputInterface.php',
|
||||
'Twig_NodeTraverser' => $vendorDir . '/twig/twig/lib/Twig/NodeTraverser.php',
|
||||
'Twig_NodeVisitorInterface' => $vendorDir . '/twig/twig/lib/Twig/NodeVisitorInterface.php',
|
||||
'Twig_NodeVisitor_Escaper' => $vendorDir . '/twig/twig/lib/Twig/NodeVisitor/Escaper.php',
|
||||
'Twig_NodeVisitor_Optimizer' => $vendorDir . '/twig/twig/lib/Twig/NodeVisitor/Optimizer.php',
|
||||
'Twig_NodeVisitor_SafeAnalysis' => $vendorDir . '/twig/twig/lib/Twig/NodeVisitor/SafeAnalysis.php',
|
||||
'Twig_NodeVisitor_Sandbox' => $vendorDir . '/twig/twig/lib/Twig/NodeVisitor/Sandbox.php',
|
||||
'Twig_Node_AutoEscape' => $vendorDir . '/twig/twig/lib/Twig/Node/AutoEscape.php',
|
||||
'Twig_Node_Block' => $vendorDir . '/twig/twig/lib/Twig/Node/Block.php',
|
||||
'Twig_Node_BlockReference' => $vendorDir . '/twig/twig/lib/Twig/Node/BlockReference.php',
|
||||
'Twig_Node_Body' => $vendorDir . '/twig/twig/lib/Twig/Node/Body.php',
|
||||
'Twig_Node_Do' => $vendorDir . '/twig/twig/lib/Twig/Node/Do.php',
|
||||
'Twig_Node_Embed' => $vendorDir . '/twig/twig/lib/Twig/Node/Embed.php',
|
||||
'Twig_Node_Expression' => $vendorDir . '/twig/twig/lib/Twig/Node/Expression.php',
|
||||
'Twig_Node_Expression_Array' => $vendorDir . '/twig/twig/lib/Twig/Node/Expression/Array.php',
|
||||
'Twig_Node_Expression_AssignName' => $vendorDir . '/twig/twig/lib/Twig/Node/Expression/AssignName.php',
|
||||
'Twig_Node_Expression_Binary' => $vendorDir . '/twig/twig/lib/Twig/Node/Expression/Binary.php',
|
||||
'Twig_Node_Expression_Binary_Add' => $vendorDir . '/twig/twig/lib/Twig/Node/Expression/Binary/Add.php',
|
||||
'Twig_Node_Expression_Binary_And' => $vendorDir . '/twig/twig/lib/Twig/Node/Expression/Binary/And.php',
|
||||
'Twig_Node_Expression_Binary_BitwiseAnd' => $vendorDir . '/twig/twig/lib/Twig/Node/Expression/Binary/BitwiseAnd.php',
|
||||
'Twig_Node_Expression_Binary_BitwiseOr' => $vendorDir . '/twig/twig/lib/Twig/Node/Expression/Binary/BitwiseOr.php',
|
||||
'Twig_Node_Expression_Binary_BitwiseXor' => $vendorDir . '/twig/twig/lib/Twig/Node/Expression/Binary/BitwiseXor.php',
|
||||
'Twig_Node_Expression_Binary_Concat' => $vendorDir . '/twig/twig/lib/Twig/Node/Expression/Binary/Concat.php',
|
||||
'Twig_Node_Expression_Binary_Div' => $vendorDir . '/twig/twig/lib/Twig/Node/Expression/Binary/Div.php',
|
||||
'Twig_Node_Expression_Binary_EndsWith' => $vendorDir . '/twig/twig/lib/Twig/Node/Expression/Binary/EndsWith.php',
|
||||
'Twig_Node_Expression_Binary_Equal' => $vendorDir . '/twig/twig/lib/Twig/Node/Expression/Binary/Equal.php',
|
||||
'Twig_Node_Expression_Binary_FloorDiv' => $vendorDir . '/twig/twig/lib/Twig/Node/Expression/Binary/FloorDiv.php',
|
||||
'Twig_Node_Expression_Binary_Greater' => $vendorDir . '/twig/twig/lib/Twig/Node/Expression/Binary/Greater.php',
|
||||
'Twig_Node_Expression_Binary_GreaterEqual' => $vendorDir . '/twig/twig/lib/Twig/Node/Expression/Binary/GreaterEqual.php',
|
||||
'Twig_Node_Expression_Binary_In' => $vendorDir . '/twig/twig/lib/Twig/Node/Expression/Binary/In.php',
|
||||
'Twig_Node_Expression_Binary_Less' => $vendorDir . '/twig/twig/lib/Twig/Node/Expression/Binary/Less.php',
|
||||
'Twig_Node_Expression_Binary_LessEqual' => $vendorDir . '/twig/twig/lib/Twig/Node/Expression/Binary/LessEqual.php',
|
||||
'Twig_Node_Expression_Binary_Matches' => $vendorDir . '/twig/twig/lib/Twig/Node/Expression/Binary/Matches.php',
|
||||
'Twig_Node_Expression_Binary_Mod' => $vendorDir . '/twig/twig/lib/Twig/Node/Expression/Binary/Mod.php',
|
||||
'Twig_Node_Expression_Binary_Mul' => $vendorDir . '/twig/twig/lib/Twig/Node/Expression/Binary/Mul.php',
|
||||
'Twig_Node_Expression_Binary_NotEqual' => $vendorDir . '/twig/twig/lib/Twig/Node/Expression/Binary/NotEqual.php',
|
||||
'Twig_Node_Expression_Binary_NotIn' => $vendorDir . '/twig/twig/lib/Twig/Node/Expression/Binary/NotIn.php',
|
||||
'Twig_Node_Expression_Binary_Or' => $vendorDir . '/twig/twig/lib/Twig/Node/Expression/Binary/Or.php',
|
||||
'Twig_Node_Expression_Binary_Power' => $vendorDir . '/twig/twig/lib/Twig/Node/Expression/Binary/Power.php',
|
||||
'Twig_Node_Expression_Binary_Range' => $vendorDir . '/twig/twig/lib/Twig/Node/Expression/Binary/Range.php',
|
||||
'Twig_Node_Expression_Binary_StartsWith' => $vendorDir . '/twig/twig/lib/Twig/Node/Expression/Binary/StartsWith.php',
|
||||
'Twig_Node_Expression_Binary_Sub' => $vendorDir . '/twig/twig/lib/Twig/Node/Expression/Binary/Sub.php',
|
||||
'Twig_Node_Expression_BlockReference' => $vendorDir . '/twig/twig/lib/Twig/Node/Expression/BlockReference.php',
|
||||
'Twig_Node_Expression_Call' => $vendorDir . '/twig/twig/lib/Twig/Node/Expression/Call.php',
|
||||
'Twig_Node_Expression_Conditional' => $vendorDir . '/twig/twig/lib/Twig/Node/Expression/Conditional.php',
|
||||
'Twig_Node_Expression_Constant' => $vendorDir . '/twig/twig/lib/Twig/Node/Expression/Constant.php',
|
||||
'Twig_Node_Expression_ExtensionReference' => $vendorDir . '/twig/twig/lib/Twig/Node/Expression/ExtensionReference.php',
|
||||
'Twig_Node_Expression_Filter' => $vendorDir . '/twig/twig/lib/Twig/Node/Expression/Filter.php',
|
||||
'Twig_Node_Expression_Filter_Default' => $vendorDir . '/twig/twig/lib/Twig/Node/Expression/Filter/Default.php',
|
||||
'Twig_Node_Expression_Function' => $vendorDir . '/twig/twig/lib/Twig/Node/Expression/Function.php',
|
||||
'Twig_Node_Expression_GetAttr' => $vendorDir . '/twig/twig/lib/Twig/Node/Expression/GetAttr.php',
|
||||
'Twig_Node_Expression_MethodCall' => $vendorDir . '/twig/twig/lib/Twig/Node/Expression/MethodCall.php',
|
||||
'Twig_Node_Expression_Name' => $vendorDir . '/twig/twig/lib/Twig/Node/Expression/Name.php',
|
||||
'Twig_Node_Expression_Parent' => $vendorDir . '/twig/twig/lib/Twig/Node/Expression/Parent.php',
|
||||
'Twig_Node_Expression_TempName' => $vendorDir . '/twig/twig/lib/Twig/Node/Expression/TempName.php',
|
||||
'Twig_Node_Expression_Test' => $vendorDir . '/twig/twig/lib/Twig/Node/Expression/Test.php',
|
||||
'Twig_Node_Expression_Test_Constant' => $vendorDir . '/twig/twig/lib/Twig/Node/Expression/Test/Constant.php',
|
||||
'Twig_Node_Expression_Test_Defined' => $vendorDir . '/twig/twig/lib/Twig/Node/Expression/Test/Defined.php',
|
||||
'Twig_Node_Expression_Test_Divisibleby' => $vendorDir . '/twig/twig/lib/Twig/Node/Expression/Test/Divisibleby.php',
|
||||
'Twig_Node_Expression_Test_Even' => $vendorDir . '/twig/twig/lib/Twig/Node/Expression/Test/Even.php',
|
||||
'Twig_Node_Expression_Test_Null' => $vendorDir . '/twig/twig/lib/Twig/Node/Expression/Test/Null.php',
|
||||
'Twig_Node_Expression_Test_Odd' => $vendorDir . '/twig/twig/lib/Twig/Node/Expression/Test/Odd.php',
|
||||
'Twig_Node_Expression_Test_Sameas' => $vendorDir . '/twig/twig/lib/Twig/Node/Expression/Test/Sameas.php',
|
||||
'Twig_Node_Expression_Unary' => $vendorDir . '/twig/twig/lib/Twig/Node/Expression/Unary.php',
|
||||
'Twig_Node_Expression_Unary_Neg' => $vendorDir . '/twig/twig/lib/Twig/Node/Expression/Unary/Neg.php',
|
||||
'Twig_Node_Expression_Unary_Not' => $vendorDir . '/twig/twig/lib/Twig/Node/Expression/Unary/Not.php',
|
||||
'Twig_Node_Expression_Unary_Pos' => $vendorDir . '/twig/twig/lib/Twig/Node/Expression/Unary/Pos.php',
|
||||
'Twig_Node_Flush' => $vendorDir . '/twig/twig/lib/Twig/Node/Flush.php',
|
||||
'Twig_Node_For' => $vendorDir . '/twig/twig/lib/Twig/Node/For.php',
|
||||
'Twig_Node_ForLoop' => $vendorDir . '/twig/twig/lib/Twig/Node/ForLoop.php',
|
||||
'Twig_Node_If' => $vendorDir . '/twig/twig/lib/Twig/Node/If.php',
|
||||
'Twig_Node_Import' => $vendorDir . '/twig/twig/lib/Twig/Node/Import.php',
|
||||
'Twig_Node_Include' => $vendorDir . '/twig/twig/lib/Twig/Node/Include.php',
|
||||
'Twig_Node_Macro' => $vendorDir . '/twig/twig/lib/Twig/Node/Macro.php',
|
||||
'Twig_Node_Module' => $vendorDir . '/twig/twig/lib/Twig/Node/Module.php',
|
||||
'Twig_Node_Print' => $vendorDir . '/twig/twig/lib/Twig/Node/Print.php',
|
||||
'Twig_Node_Sandbox' => $vendorDir . '/twig/twig/lib/Twig/Node/Sandbox.php',
|
||||
'Twig_Node_SandboxedModule' => $vendorDir . '/twig/twig/lib/Twig/Node/SandboxedModule.php',
|
||||
'Twig_Node_SandboxedPrint' => $vendorDir . '/twig/twig/lib/Twig/Node/SandboxedPrint.php',
|
||||
'Twig_Node_Set' => $vendorDir . '/twig/twig/lib/Twig/Node/Set.php',
|
||||
'Twig_Node_SetTemp' => $vendorDir . '/twig/twig/lib/Twig/Node/SetTemp.php',
|
||||
'Twig_Node_Spaceless' => $vendorDir . '/twig/twig/lib/Twig/Node/Spaceless.php',
|
||||
'Twig_Node_Text' => $vendorDir . '/twig/twig/lib/Twig/Node/Text.php',
|
||||
'Twig_Parser' => $vendorDir . '/twig/twig/lib/Twig/Parser.php',
|
||||
'Twig_ParserInterface' => $vendorDir . '/twig/twig/lib/Twig/ParserInterface.php',
|
||||
'Twig_Sandbox_SecurityError' => $vendorDir . '/twig/twig/lib/Twig/Sandbox/SecurityError.php',
|
||||
'Twig_Sandbox_SecurityPolicy' => $vendorDir . '/twig/twig/lib/Twig/Sandbox/SecurityPolicy.php',
|
||||
'Twig_Sandbox_SecurityPolicyInterface' => $vendorDir . '/twig/twig/lib/Twig/Sandbox/SecurityPolicyInterface.php',
|
||||
'Twig_SimpleFilter' => $vendorDir . '/twig/twig/lib/Twig/SimpleFilter.php',
|
||||
'Twig_SimpleFunction' => $vendorDir . '/twig/twig/lib/Twig/SimpleFunction.php',
|
||||
'Twig_Template' => $vendorDir . '/twig/twig/lib/Twig/Template.php',
|
||||
'Twig_TemplateInterface' => $vendorDir . '/twig/twig/lib/Twig/TemplateInterface.php',
|
||||
'Twig_Test' => $vendorDir . '/twig/twig/lib/Twig/Test.php',
|
||||
'Twig_TestCallableInterface' => $vendorDir . '/twig/twig/lib/Twig/TestCallableInterface.php',
|
||||
'Twig_TestInterface' => $vendorDir . '/twig/twig/lib/Twig/TestInterface.php',
|
||||
'Twig_Test_Function' => $vendorDir . '/twig/twig/lib/Twig/Test/Function.php',
|
||||
'Twig_Test_IntegrationTestCase' => $vendorDir . '/twig/twig/lib/Twig/Test/IntegrationTestCase.php',
|
||||
'Twig_Test_Method' => $vendorDir . '/twig/twig/lib/Twig/Test/Method.php',
|
||||
'Twig_Test_Node' => $vendorDir . '/twig/twig/lib/Twig/Test/Node.php',
|
||||
'Twig_Test_NodeTestCase' => $vendorDir . '/twig/twig/lib/Twig/Test/NodeTestCase.php',
|
||||
'Twig_Token' => $vendorDir . '/twig/twig/lib/Twig/Token.php',
|
||||
'Twig_TokenParser' => $vendorDir . '/twig/twig/lib/Twig/TokenParser.php',
|
||||
'Twig_TokenParserBroker' => $vendorDir . '/twig/twig/lib/Twig/TokenParserBroker.php',
|
||||
'Twig_TokenParserBrokerInterface' => $vendorDir . '/twig/twig/lib/Twig/TokenParserBrokerInterface.php',
|
||||
'Twig_TokenParserInterface' => $vendorDir . '/twig/twig/lib/Twig/TokenParserInterface.php',
|
||||
'Twig_TokenParser_AutoEscape' => $vendorDir . '/twig/twig/lib/Twig/TokenParser/AutoEscape.php',
|
||||
'Twig_TokenParser_Block' => $vendorDir . '/twig/twig/lib/Twig/TokenParser/Block.php',
|
||||
'Twig_TokenParser_Do' => $vendorDir . '/twig/twig/lib/Twig/TokenParser/Do.php',
|
||||
'Twig_TokenParser_Embed' => $vendorDir . '/twig/twig/lib/Twig/TokenParser/Embed.php',
|
||||
'Twig_TokenParser_Extends' => $vendorDir . '/twig/twig/lib/Twig/TokenParser/Extends.php',
|
||||
'Twig_TokenParser_Filter' => $vendorDir . '/twig/twig/lib/Twig/TokenParser/Filter.php',
|
||||
'Twig_TokenParser_Flush' => $vendorDir . '/twig/twig/lib/Twig/TokenParser/Flush.php',
|
||||
'Twig_TokenParser_For' => $vendorDir . '/twig/twig/lib/Twig/TokenParser/For.php',
|
||||
'Twig_TokenParser_From' => $vendorDir . '/twig/twig/lib/Twig/TokenParser/From.php',
|
||||
'Twig_TokenParser_If' => $vendorDir . '/twig/twig/lib/Twig/TokenParser/If.php',
|
||||
'Twig_TokenParser_Import' => $vendorDir . '/twig/twig/lib/Twig/TokenParser/Import.php',
|
||||
'Twig_TokenParser_Include' => $vendorDir . '/twig/twig/lib/Twig/TokenParser/Include.php',
|
||||
'Twig_TokenParser_Macro' => $vendorDir . '/twig/twig/lib/Twig/TokenParser/Macro.php',
|
||||
'Twig_TokenParser_Sandbox' => $vendorDir . '/twig/twig/lib/Twig/TokenParser/Sandbox.php',
|
||||
'Twig_TokenParser_Set' => $vendorDir . '/twig/twig/lib/Twig/TokenParser/Set.php',
|
||||
'Twig_TokenParser_Spaceless' => $vendorDir . '/twig/twig/lib/Twig/TokenParser/Spaceless.php',
|
||||
'Twig_TokenParser_Use' => $vendorDir . '/twig/twig/lib/Twig/TokenParser/Use.php',
|
||||
'Twig_TokenStream' => $vendorDir . '/twig/twig/lib/Twig/TokenStream.php',
|
||||
);
|
||||
13
vendor/composer/autoload_files.php
vendored
13
vendor/composer/autoload_files.php
vendored
@@ -1,13 +0,0 @@
|
||||
<?php
|
||||
|
||||
// autoload_files.php @generated by Composer
|
||||
|
||||
$vendorDir = dirname(dirname(__FILE__));
|
||||
$baseDir = dirname($vendorDir);
|
||||
|
||||
return array(
|
||||
$vendorDir . '/ircmaxell/password-compat/lib/password.php',
|
||||
$vendorDir . '/donatj/phpuseragentparser/Source/UserAgentParser.php',
|
||||
$vendorDir . '/tracy/tracy/src/shortcuts.php',
|
||||
$baseDir . '/system/defines.php',
|
||||
);
|
||||
19
vendor/composer/autoload_namespaces.php
vendored
19
vendor/composer/autoload_namespaces.php
vendored
@@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
// autoload_namespaces.php @generated by Composer
|
||||
|
||||
$vendorDir = dirname(dirname(__FILE__));
|
||||
$baseDir = dirname($vendorDir);
|
||||
|
||||
return array(
|
||||
'Twig_' => array($vendorDir . '/twig/twig/lib'),
|
||||
'Symfony\\Component\\Yaml\\' => array($vendorDir . '/symfony/yaml'),
|
||||
'Symfony\\Component\\EventDispatcher\\' => array($vendorDir . '/symfony/event-dispatcher'),
|
||||
'Symfony\\Component\\Console\\' => array($vendorDir . '/symfony/console'),
|
||||
'Pimple' => array($vendorDir . '/pimple/pimple/src'),
|
||||
'ParsedownExtra' => array($vendorDir . '/erusev/parsedown-extra'),
|
||||
'Parsedown' => array($vendorDir . '/erusev/parsedown'),
|
||||
'Gregwar\\Image' => array($vendorDir . '/gregwar/image'),
|
||||
'Gregwar\\Cache' => array($vendorDir . '/gregwar/cache'),
|
||||
'Doctrine\\Common\\Cache\\' => array($vendorDir . '/doctrine/cache/lib'),
|
||||
);
|
||||
10
vendor/composer/autoload_psr4.php
vendored
10
vendor/composer/autoload_psr4.php
vendored
@@ -1,10 +0,0 @@
|
||||
<?php
|
||||
|
||||
// autoload_psr4.php @generated by Composer
|
||||
|
||||
$vendorDir = dirname(dirname(__FILE__));
|
||||
$baseDir = dirname($vendorDir);
|
||||
|
||||
return array(
|
||||
'Grav\\' => array($baseDir . '/system/src'),
|
||||
);
|
||||
55
vendor/composer/autoload_real.php
vendored
55
vendor/composer/autoload_real.php
vendored
@@ -1,55 +0,0 @@
|
||||
<?php
|
||||
|
||||
// autoload_real.php @generated by Composer
|
||||
|
||||
class ComposerAutoloaderInitec0ae3d965d9e7b8b1978169aa5cfad1
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
public static function loadClassLoader($class)
|
||||
{
|
||||
if ('Composer\Autoload\ClassLoader' === $class) {
|
||||
require __DIR__ . '/ClassLoader.php';
|
||||
}
|
||||
}
|
||||
|
||||
public static function getLoader()
|
||||
{
|
||||
if (null !== self::$loader) {
|
||||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInitec0ae3d965d9e7b8b1978169aa5cfad1', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInitec0ae3d965d9e7b8b1978169aa5cfad1', 'loadClassLoader'));
|
||||
|
||||
$map = require __DIR__ . '/autoload_namespaces.php';
|
||||
foreach ($map as $namespace => $path) {
|
||||
$loader->set($namespace, $path);
|
||||
}
|
||||
|
||||
$map = require __DIR__ . '/autoload_psr4.php';
|
||||
foreach ($map as $namespace => $path) {
|
||||
$loader->setPsr4($namespace, $path);
|
||||
}
|
||||
|
||||
$classMap = require __DIR__ . '/autoload_classmap.php';
|
||||
if ($classMap) {
|
||||
$loader->addClassMap($classMap);
|
||||
}
|
||||
|
||||
$loader->register(true);
|
||||
|
||||
$includeFiles = require __DIR__ . '/autoload_files.php';
|
||||
foreach ($includeFiles as $file) {
|
||||
composerRequireec0ae3d965d9e7b8b1978169aa5cfad1($file);
|
||||
}
|
||||
|
||||
return $loader;
|
||||
}
|
||||
}
|
||||
|
||||
function composerRequireec0ae3d965d9e7b8b1978169aa5cfad1($file)
|
||||
{
|
||||
require $file;
|
||||
}
|
||||
719
vendor/composer/installed.json
vendored
719
vendor/composer/installed.json
vendored
@@ -1,719 +0,0 @@
|
||||
[
|
||||
{
|
||||
"name": "erusev/parsedown",
|
||||
"version": "1.0.1",
|
||||
"version_normalized": "1.0.1.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/erusev/parsedown.git",
|
||||
"reference": "d24439ada0704948deef0d3eda2ea20fd8db1747"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/erusev/parsedown/zipball/d24439ada0704948deef0d3eda2ea20fd8db1747",
|
||||
"reference": "d24439ada0704948deef0d3eda2ea20fd8db1747",
|
||||
"shasum": ""
|
||||
},
|
||||
"time": "2014-05-21 20:20:46",
|
||||
"type": "library",
|
||||
"installation-source": "dist",
|
||||
"autoload": {
|
||||
"psr-0": {
|
||||
"Parsedown": ""
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Emanuil Rusev",
|
||||
"email": "hello@erusev.com",
|
||||
"homepage": "http://erusev.com"
|
||||
}
|
||||
],
|
||||
"description": "Parser for Markdown.",
|
||||
"homepage": "http://parsedown.org",
|
||||
"keywords": [
|
||||
"markdown",
|
||||
"parser"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "doctrine/cache",
|
||||
"version": "v1.3.0",
|
||||
"version_normalized": "1.3.0.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/doctrine/cache.git",
|
||||
"reference": "e16d7adf45664a50fa86f515b6d5e7f670130449"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/doctrine/cache/zipball/e16d7adf45664a50fa86f515b6d5e7f670130449",
|
||||
"reference": "e16d7adf45664a50fa86f515b6d5e7f670130449",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.2"
|
||||
},
|
||||
"conflict": {
|
||||
"doctrine/common": ">2.2,<2.4"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": ">=3.7",
|
||||
"satooshi/php-coveralls": "~0.6"
|
||||
},
|
||||
"time": "2013-10-25 19:04:14",
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.0.x-dev"
|
||||
}
|
||||
},
|
||||
"installation-source": "dist",
|
||||
"autoload": {
|
||||
"psr-0": {
|
||||
"Doctrine\\Common\\Cache\\": "lib/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Jonathan Wage",
|
||||
"email": "jonwage@gmail.com",
|
||||
"homepage": "http://www.jwage.com/",
|
||||
"role": "Creator"
|
||||
},
|
||||
{
|
||||
"name": "Guilherme Blanco",
|
||||
"email": "guilhermeblanco@gmail.com",
|
||||
"homepage": "http://www.instaclick.com"
|
||||
},
|
||||
{
|
||||
"name": "Roman Borschel",
|
||||
"email": "roman@code-factory.org"
|
||||
},
|
||||
{
|
||||
"name": "Benjamin Eberlei",
|
||||
"email": "kontakt@beberlei.de"
|
||||
},
|
||||
{
|
||||
"name": "Johannes Schmitt",
|
||||
"email": "schmittjoh@gmail.com",
|
||||
"homepage": "https://github.com/schmittjoh",
|
||||
"role": "Developer of wrapped JMSSerializerBundle"
|
||||
}
|
||||
],
|
||||
"description": "Caching library offering an object-oriented API for many cache backends",
|
||||
"homepage": "http://www.doctrine-project.org",
|
||||
"keywords": [
|
||||
"cache",
|
||||
"caching"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "pimple/pimple",
|
||||
"version": "v3.0.0",
|
||||
"version_normalized": "3.0.0.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/fabpot/Pimple.git",
|
||||
"reference": "876bf0899d01feacd2a2e83f04641e51350099ef"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/fabpot/Pimple/zipball/876bf0899d01feacd2a2e83f04641e51350099ef",
|
||||
"reference": "876bf0899d01feacd2a2e83f04641e51350099ef",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.0"
|
||||
},
|
||||
"time": "2014-07-24 09:48:15",
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "3.0.x-dev"
|
||||
}
|
||||
},
|
||||
"installation-source": "dist",
|
||||
"autoload": {
|
||||
"psr-0": {
|
||||
"Pimple": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Fabien Potencier",
|
||||
"email": "fabien@symfony.com"
|
||||
}
|
||||
],
|
||||
"description": "Pimple is a simple Dependency Injection Container for PHP 5.3",
|
||||
"homepage": "http://pimple.sensiolabs.org",
|
||||
"keywords": [
|
||||
"container",
|
||||
"dependency injection"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "symfony/yaml",
|
||||
"version": "v2.5.3",
|
||||
"version_normalized": "2.5.3.0",
|
||||
"target-dir": "Symfony/Component/Yaml",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/Yaml.git",
|
||||
"reference": "5a75366ae9ca8b4792cd0083e4ca4dff9fe96f1f"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/Yaml/zipball/5a75366ae9ca8b4792cd0083e4ca4dff9fe96f1f",
|
||||
"reference": "5a75366ae9ca8b4792cd0083e4ca4dff9fe96f1f",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.3"
|
||||
},
|
||||
"time": "2014-08-05 09:00:40",
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "2.5-dev"
|
||||
}
|
||||
},
|
||||
"installation-source": "dist",
|
||||
"autoload": {
|
||||
"psr-0": {
|
||||
"Symfony\\Component\\Yaml\\": ""
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Symfony Community",
|
||||
"homepage": "http://symfony.com/contributors"
|
||||
},
|
||||
{
|
||||
"name": "Fabien Potencier",
|
||||
"email": "fabien@symfony.com"
|
||||
}
|
||||
],
|
||||
"description": "Symfony Yaml Component",
|
||||
"homepage": "http://symfony.com"
|
||||
},
|
||||
{
|
||||
"name": "symfony/console",
|
||||
"version": "v2.5.3",
|
||||
"version_normalized": "2.5.3.0",
|
||||
"target-dir": "Symfony/Component/Console",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/Console.git",
|
||||
"reference": "cd2d1e4bac2206b337326b0140ff475fe9ad5f63"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/Console/zipball/cd2d1e4bac2206b337326b0140ff475fe9ad5f63",
|
||||
"reference": "cd2d1e4bac2206b337326b0140ff475fe9ad5f63",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.3"
|
||||
},
|
||||
"require-dev": {
|
||||
"psr/log": "~1.0",
|
||||
"symfony/event-dispatcher": "~2.1"
|
||||
},
|
||||
"suggest": {
|
||||
"psr/log": "For using the console logger",
|
||||
"symfony/event-dispatcher": ""
|
||||
},
|
||||
"time": "2014-08-05 09:00:40",
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "2.5-dev"
|
||||
}
|
||||
},
|
||||
"installation-source": "dist",
|
||||
"autoload": {
|
||||
"psr-0": {
|
||||
"Symfony\\Component\\Console\\": ""
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Symfony Community",
|
||||
"homepage": "http://symfony.com/contributors"
|
||||
},
|
||||
{
|
||||
"name": "Fabien Potencier",
|
||||
"email": "fabien@symfony.com"
|
||||
}
|
||||
],
|
||||
"description": "Symfony Console Component",
|
||||
"homepage": "http://symfony.com"
|
||||
},
|
||||
{
|
||||
"name": "symfony/event-dispatcher",
|
||||
"version": "v2.5.3",
|
||||
"version_normalized": "2.5.3.0",
|
||||
"target-dir": "Symfony/Component/EventDispatcher",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/EventDispatcher.git",
|
||||
"reference": "8faf5cc7e80fde74a650a36e60d32ce3c3e0457b"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/EventDispatcher/zipball/8faf5cc7e80fde74a650a36e60d32ce3c3e0457b",
|
||||
"reference": "8faf5cc7e80fde74a650a36e60d32ce3c3e0457b",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.3"
|
||||
},
|
||||
"require-dev": {
|
||||
"psr/log": "~1.0",
|
||||
"symfony/config": "~2.0",
|
||||
"symfony/dependency-injection": "~2.0",
|
||||
"symfony/stopwatch": "~2.2"
|
||||
},
|
||||
"suggest": {
|
||||
"symfony/dependency-injection": "",
|
||||
"symfony/http-kernel": ""
|
||||
},
|
||||
"time": "2014-07-28 13:20:46",
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "2.5-dev"
|
||||
}
|
||||
},
|
||||
"installation-source": "dist",
|
||||
"autoload": {
|
||||
"psr-0": {
|
||||
"Symfony\\Component\\EventDispatcher\\": ""
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Symfony Community",
|
||||
"homepage": "http://symfony.com/contributors"
|
||||
},
|
||||
{
|
||||
"name": "Fabien Potencier",
|
||||
"email": "fabien@symfony.com"
|
||||
}
|
||||
],
|
||||
"description": "Symfony EventDispatcher Component",
|
||||
"homepage": "http://symfony.com"
|
||||
},
|
||||
{
|
||||
"name": "gregwar/cache",
|
||||
"version": "v1.0.7",
|
||||
"version_normalized": "1.0.7.0",
|
||||
"target-dir": "Gregwar/Cache",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/Gregwar/Cache.git",
|
||||
"reference": "b2d0197c07cc1ccf7436e1ae7bf64f9948e02052"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/Gregwar/Cache/zipball/b2d0197c07cc1ccf7436e1ae7bf64f9948e02052",
|
||||
"reference": "b2d0197c07cc1ccf7436e1ae7bf64f9948e02052",
|
||||
"shasum": ""
|
||||
},
|
||||
"time": "2014-02-20 20:04:58",
|
||||
"type": "library",
|
||||
"installation-source": "dist",
|
||||
"autoload": {
|
||||
"psr-0": {
|
||||
"Gregwar\\Cache": ""
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Grégoire Passault",
|
||||
"email": "g.passault@gmail.com",
|
||||
"homepage": "http://www.gregwar.com/"
|
||||
}
|
||||
],
|
||||
"description": "A lightweight file-system cache system",
|
||||
"keywords": [
|
||||
"cache",
|
||||
"caching",
|
||||
"file-system",
|
||||
"system"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "gregwar/image",
|
||||
"version": "v2.0.17",
|
||||
"version_normalized": "2.0.17.0",
|
||||
"target-dir": "Gregwar/Image",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/Gregwar/Image.git",
|
||||
"reference": "a7bba10ed0e3004c098bb7fde3a3e5bcafca8a2c"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/Gregwar/Image/zipball/a7bba10ed0e3004c098bb7fde3a3e5bcafca8a2c",
|
||||
"reference": "a7bba10ed0e3004c098bb7fde3a3e5bcafca8a2c",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"ext-gd": "*",
|
||||
"gregwar/cache": "v1.0.7",
|
||||
"php": ">=5.3.0"
|
||||
},
|
||||
"time": "2014-02-20 22:20:45",
|
||||
"type": "library",
|
||||
"installation-source": "dist",
|
||||
"autoload": {
|
||||
"psr-0": {
|
||||
"Gregwar\\Image": ""
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Grégoire Passault",
|
||||
"email": "g.passault@gmail.com",
|
||||
"homepage": "http://www.gregwar.com/"
|
||||
}
|
||||
],
|
||||
"description": "Image handling",
|
||||
"homepage": "https://github.com/Gregwar/Image",
|
||||
"keywords": [
|
||||
"gd",
|
||||
"image"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "ircmaxell/password-compat",
|
||||
"version": "1.0.3",
|
||||
"version_normalized": "1.0.3.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/ircmaxell/password_compat.git",
|
||||
"reference": "1fc1521b5e9794ea77e4eca30717be9635f1d4f4"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/ircmaxell/password_compat/zipball/1fc1521b5e9794ea77e4eca30717be9635f1d4f4",
|
||||
"reference": "1fc1521b5e9794ea77e4eca30717be9635f1d4f4",
|
||||
"shasum": ""
|
||||
},
|
||||
"time": "2013-04-30 19:58:08",
|
||||
"type": "library",
|
||||
"installation-source": "dist",
|
||||
"autoload": {
|
||||
"files": [
|
||||
"lib/password.php"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Anthony Ferrara",
|
||||
"email": "ircmaxell@ircmaxell.com",
|
||||
"homepage": "http://blog.ircmaxell.com"
|
||||
}
|
||||
],
|
||||
"description": "A compatibility library for the proposed simplified password hashing algorithm: https://wiki.php.net/rfc/password_hash",
|
||||
"homepage": "https://github.com/ircmaxell/password_compat",
|
||||
"keywords": [
|
||||
"hashing",
|
||||
"password"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "twig/twig",
|
||||
"version": "v1.16.0",
|
||||
"version_normalized": "1.16.0.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/fabpot/Twig.git",
|
||||
"reference": "8ce37115802e257a984a82d38254884085060024"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/fabpot/Twig/zipball/8ce37115802e257a984a82d38254884085060024",
|
||||
"reference": "8ce37115802e257a984a82d38254884085060024",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.2.4"
|
||||
},
|
||||
"time": "2014-07-05 12:19:05",
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.16-dev"
|
||||
}
|
||||
},
|
||||
"installation-source": "source",
|
||||
"autoload": {
|
||||
"psr-0": {
|
||||
"Twig_": "lib/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"BSD-3-Clause"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Fabien Potencier",
|
||||
"email": "fabien@symfony.com",
|
||||
"homepage": "http://fabien.potencier.org",
|
||||
"role": "Lead Developer"
|
||||
},
|
||||
{
|
||||
"name": "Armin Ronacher",
|
||||
"email": "armin.ronacher@active-4.com",
|
||||
"role": "Project Founder"
|
||||
},
|
||||
{
|
||||
"name": "Twig Team",
|
||||
"homepage": "https://github.com/fabpot/Twig/graphs/contributors",
|
||||
"role": "Contributors"
|
||||
}
|
||||
],
|
||||
"description": "Twig, the flexible, fast, and secure template language for PHP",
|
||||
"homepage": "http://twig.sensiolabs.org",
|
||||
"keywords": [
|
||||
"templating"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "donatj/phpuseragentparser",
|
||||
"version": "dev-master",
|
||||
"version_normalized": "9999999-dev",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/donatj/PhpUserAgent.git",
|
||||
"reference": "abbd69a119f067e4afc3c4baf28d04646114a668"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/donatj/PhpUserAgent/zipball/abbd69a119f067e4afc3c4baf28d04646114a668",
|
||||
"reference": "abbd69a119f067e4afc3c4baf28d04646114a668",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"camspiers/json-pretty": "0.1.*"
|
||||
},
|
||||
"time": "2014-08-06 03:39:39",
|
||||
"type": "library",
|
||||
"installation-source": "source",
|
||||
"autoload": {
|
||||
"files": [
|
||||
"Source/UserAgentParser.php"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Jesse G. Donat",
|
||||
"email": "donatj@gmail.com",
|
||||
"homepage": "http://donatstudios.com",
|
||||
"role": "Developer"
|
||||
}
|
||||
],
|
||||
"description": "Simple, streamlined PHP user-agent parser",
|
||||
"homepage": "http://donatstudios.com/PHP-Parser-HTTP_USER_AGENT",
|
||||
"keywords": [
|
||||
"parser",
|
||||
"user agent",
|
||||
"useragent"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "tracy/tracy",
|
||||
"version": "v2.2.3",
|
||||
"version_normalized": "2.2.3.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/nette/tracy.git",
|
||||
"reference": "97889d2b8cfb7607cc370ca0ddb97c6f5b43deb9"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/nette/tracy/zipball/97889d2b8cfb7607cc370ca0ddb97c6f5b43deb9",
|
||||
"reference": "97889d2b8cfb7607cc370ca0ddb97c6f5b43deb9",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.1"
|
||||
},
|
||||
"require-dev": {
|
||||
"nette/tester": "~1.0"
|
||||
},
|
||||
"time": "2014-08-24 23:36:30",
|
||||
"type": "library",
|
||||
"installation-source": "dist",
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
"src/Tracy"
|
||||
],
|
||||
"files": [
|
||||
"src/shortcuts.php"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"BSD-3-Clause",
|
||||
"GPL-2.0",
|
||||
"GPL-3.0"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "David Grudl",
|
||||
"homepage": "http://davidgrudl.com"
|
||||
},
|
||||
{
|
||||
"name": "Nette Community",
|
||||
"homepage": "http://nette.org/contributors"
|
||||
}
|
||||
],
|
||||
"description": "Tracy: useful PHP debugger",
|
||||
"homepage": "http://tracy.nette.org",
|
||||
"keywords": [
|
||||
"debug",
|
||||
"debugger",
|
||||
"nette"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "erusev/parsedown-extra",
|
||||
"version": "dev-master",
|
||||
"version_normalized": "9999999-dev",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/erusev/parsedown-extra.git",
|
||||
"reference": "424e63fef5299f2a5a0464cd22a666b7a7b48657"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/erusev/parsedown-extra/zipball/424e63fef5299f2a5a0464cd22a666b7a7b48657",
|
||||
"reference": "424e63fef5299f2a5a0464cd22a666b7a7b48657",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"erusev/parsedown": "~1.0"
|
||||
},
|
||||
"time": "2014-08-25 10:49:57",
|
||||
"type": "library",
|
||||
"installation-source": "source",
|
||||
"autoload": {
|
||||
"psr-0": {
|
||||
"ParsedownExtra": ""
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Emanuil Rusev",
|
||||
"email": "hello@erusev.com",
|
||||
"homepage": "http://erusev.com"
|
||||
}
|
||||
],
|
||||
"description": "An extension of Parsedown that adds support for Markdown Extra.",
|
||||
"homepage": "https://github.com/erusev/parsedown-extra",
|
||||
"keywords": [
|
||||
"markdown",
|
||||
"markdown extra",
|
||||
"parsedown",
|
||||
"parser"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "mrclay/minify",
|
||||
"version": "dev-master",
|
||||
"version_normalized": "9999999-dev",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/rhukster/minify.git",
|
||||
"reference": "fdf68abf30ccd86a65f66fa6eb98434eb29bef74"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/rhukster/minify/zipball/fdf68abf30ccd86a65f66fa6eb98434eb29bef74",
|
||||
"reference": "fdf68abf30ccd86a65f66fa6eb98434eb29bef74",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"ext-pcre": "*",
|
||||
"php": ">=5.2.1"
|
||||
},
|
||||
"time": "2014-08-29 23:07:55",
|
||||
"type": "library",
|
||||
"installation-source": "source",
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
"min/lib/"
|
||||
]
|
||||
},
|
||||
"license": [
|
||||
"BSD-3-Clause"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Stephen Clay",
|
||||
"email": "steve@mrclay.org",
|
||||
"role": "Developer"
|
||||
}
|
||||
],
|
||||
"description": "Minify is a PHP5 app that helps you follow several rules for client-side performance. It combines multiple CSS or Javascript files, removes unnecessary whitespace and comments, and serves them with gzip encoding and optimal client-side cache headers",
|
||||
"homepage": "http://code.google.com/p/minify/",
|
||||
"support": {
|
||||
"email": "minify@googlegroups.com",
|
||||
"issues": "http://code.google.com/p/minify/issues/list",
|
||||
"wiki": "http://code.google.com/p/minify/w/list",
|
||||
"source": "https://github.com/rhukster/minify/tree/master"
|
||||
}
|
||||
}
|
||||
]
|
||||
19
vendor/doctrine/cache/LICENSE
vendored
19
vendor/doctrine/cache/LICENSE
vendored
@@ -1,19 +0,0 @@
|
||||
Copyright (c) 2006-2012 Doctrine Project
|
||||
|
||||
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.
|
||||
14
vendor/doctrine/cache/README.md
vendored
14
vendor/doctrine/cache/README.md
vendored
@@ -1,14 +0,0 @@
|
||||
# Doctrine Cache
|
||||
|
||||
Master: [](http://travis-ci.org/doctrine/cache) [](https://coveralls.io/r/doctrine/cache?branch=master)
|
||||
|
||||
[](https://packagist.org/packages/doctrine/cache) [](https://packagist.org/packages/doctrine/cache)
|
||||
|
||||
Cache component extracted from the Doctrine Common project.
|
||||
|
||||
## Changelog
|
||||
|
||||
### v1.2
|
||||
|
||||
* Added support for MongoDB as Cache Provider
|
||||
* Fix namespace version reset
|
||||
@@ -1,98 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\Common\Cache;
|
||||
|
||||
/**
|
||||
* APC cache provider.
|
||||
*
|
||||
* @link www.doctrine-project.org
|
||||
* @since 2.0
|
||||
* @author Benjamin Eberlei <kontakt@beberlei.de>
|
||||
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
|
||||
* @author Jonathan Wage <jonwage@gmail.com>
|
||||
* @author Roman Borschel <roman@code-factory.org>
|
||||
* @author David Abdemoulaie <dave@hobodave.com>
|
||||
*/
|
||||
class ApcCache extends CacheProvider
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doFetch($id)
|
||||
{
|
||||
return apc_fetch($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doContains($id)
|
||||
{
|
||||
return apc_exists($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doSave($id, $data, $lifeTime = 0)
|
||||
{
|
||||
return (bool) apc_store($id, $data, (int) $lifeTime);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doDelete($id)
|
||||
{
|
||||
return apc_delete($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doFlush()
|
||||
{
|
||||
return apc_clear_cache() && apc_clear_cache('user');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doGetStats()
|
||||
{
|
||||
$info = apc_cache_info();
|
||||
$sma = apc_sma_info();
|
||||
|
||||
// @TODO - Temporary fix @see https://github.com/krakjoe/apcu/pull/42
|
||||
if (PHP_VERSION_ID >= 50500) {
|
||||
$info['num_hits'] = isset($info['num_hits']) ? $info['num_hits'] : $info['nhits'];
|
||||
$info['num_misses'] = isset($info['num_misses']) ? $info['num_misses'] : $info['nmisses'];
|
||||
$info['start_time'] = isset($info['start_time']) ? $info['start_time'] : $info['stime'];
|
||||
}
|
||||
|
||||
return array(
|
||||
Cache::STATS_HITS => $info['num_hits'],
|
||||
Cache::STATS_MISSES => $info['num_misses'],
|
||||
Cache::STATS_UPTIME => $info['start_time'],
|
||||
Cache::STATS_MEMORY_USAGE => $info['mem_size'],
|
||||
Cache::STATS_MEMORY_AVAILABLE => $sma['avail_mem'],
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,93 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\Common\Cache;
|
||||
|
||||
/**
|
||||
* Array cache driver.
|
||||
*
|
||||
* @link www.doctrine-project.org
|
||||
* @since 2.0
|
||||
* @author Benjamin Eberlei <kontakt@beberlei.de>
|
||||
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
|
||||
* @author Jonathan Wage <jonwage@gmail.com>
|
||||
* @author Roman Borschel <roman@code-factory.org>
|
||||
* @author David Abdemoulaie <dave@hobodave.com>
|
||||
*/
|
||||
class ArrayCache extends CacheProvider
|
||||
{
|
||||
/**
|
||||
* @var array $data
|
||||
*/
|
||||
private $data = array();
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doFetch($id)
|
||||
{
|
||||
return (isset($this->data[$id])) ? $this->data[$id] : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doContains($id)
|
||||
{
|
||||
return isset($this->data[$id]);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doSave($id, $data, $lifeTime = 0)
|
||||
{
|
||||
$this->data[$id] = $data;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doDelete($id)
|
||||
{
|
||||
unset($this->data[$id]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doFlush()
|
||||
{
|
||||
$this->data = array();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doGetStats()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,111 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\Common\Cache;
|
||||
|
||||
/**
|
||||
* Interface for cache drivers.
|
||||
*
|
||||
* @link www.doctrine-project.org
|
||||
* @since 2.0
|
||||
* @author Benjamin Eberlei <kontakt@beberlei.de>
|
||||
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
|
||||
* @author Jonathan Wage <jonwage@gmail.com>
|
||||
* @author Roman Borschel <roman@code-factory.org>
|
||||
* @author Fabio B. Silva <fabio.bat.silva@gmail.com>
|
||||
*/
|
||||
interface Cache
|
||||
{
|
||||
const STATS_HITS = 'hits';
|
||||
const STATS_MISSES = 'misses';
|
||||
const STATS_UPTIME = 'uptime';
|
||||
const STATS_MEMORY_USAGE = 'memory_usage';
|
||||
const STATS_MEMORY_AVAILABLE = 'memory_available';
|
||||
/**
|
||||
* Only for backward compatibility (may be removed in next major release)
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
const STATS_MEMORY_AVAILIABLE = 'memory_available';
|
||||
|
||||
/**
|
||||
* Fetches an entry from the cache.
|
||||
*
|
||||
* @param string $id The id of the cache entry to fetch.
|
||||
*
|
||||
* @return mixed The cached data or FALSE, if no cache entry exists for the given id.
|
||||
*/
|
||||
function fetch($id);
|
||||
|
||||
/**
|
||||
* Tests if an entry exists in the cache.
|
||||
*
|
||||
* @param string $id The cache id of the entry to check for.
|
||||
*
|
||||
* @return boolean TRUE if a cache entry exists for the given cache id, FALSE otherwise.
|
||||
*/
|
||||
function contains($id);
|
||||
|
||||
/**
|
||||
* Puts data into the cache.
|
||||
*
|
||||
* @param string $id The cache id.
|
||||
* @param mixed $data The cache entry/data.
|
||||
* @param int $lifeTime The cache lifetime.
|
||||
* If != 0, sets a specific lifetime for this cache entry (0 => infinite lifeTime).
|
||||
*
|
||||
* @return boolean TRUE if the entry was successfully stored in the cache, FALSE otherwise.
|
||||
*/
|
||||
function save($id, $data, $lifeTime = 0);
|
||||
|
||||
/**
|
||||
* Deletes a cache entry.
|
||||
*
|
||||
* @param string $id The cache id.
|
||||
*
|
||||
* @return boolean TRUE if the cache entry was successfully deleted, FALSE otherwise.
|
||||
*/
|
||||
function delete($id);
|
||||
|
||||
/**
|
||||
* Retrieves cached information from the data store.
|
||||
*
|
||||
* The server's statistics array has the following values:
|
||||
*
|
||||
* - <b>hits</b>
|
||||
* Number of keys that have been requested and found present.
|
||||
*
|
||||
* - <b>misses</b>
|
||||
* Number of items that have been requested and not found.
|
||||
*
|
||||
* - <b>uptime</b>
|
||||
* Time that the server is running.
|
||||
*
|
||||
* - <b>memory_usage</b>
|
||||
* Memory used by this server to store items.
|
||||
*
|
||||
* - <b>memory_available</b>
|
||||
* Memory allowed to use for storage.
|
||||
*
|
||||
* @since 2.2
|
||||
*
|
||||
* @return array|null An associative array with server's statistics if available, NULL otherwise.
|
||||
*/
|
||||
function getStats();
|
||||
}
|
||||
@@ -1,241 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\Common\Cache;
|
||||
|
||||
/**
|
||||
* Base class for cache provider implementations.
|
||||
*
|
||||
* @since 2.2
|
||||
* @author Benjamin Eberlei <kontakt@beberlei.de>
|
||||
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
|
||||
* @author Jonathan Wage <jonwage@gmail.com>
|
||||
* @author Roman Borschel <roman@code-factory.org>
|
||||
* @author Fabio B. Silva <fabio.bat.silva@gmail.com>
|
||||
*/
|
||||
abstract class CacheProvider implements Cache
|
||||
{
|
||||
const DOCTRINE_NAMESPACE_CACHEKEY = 'DoctrineNamespaceCacheKey[%s]';
|
||||
|
||||
/**
|
||||
* The namespace to prefix all cache ids with.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $namespace = '';
|
||||
|
||||
/**
|
||||
* The namespace version.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $namespaceVersion;
|
||||
|
||||
/**
|
||||
* Sets the namespace to prefix all cache ids with.
|
||||
*
|
||||
* @param string $namespace
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setNamespace($namespace)
|
||||
{
|
||||
$this->namespace = (string) $namespace;
|
||||
$this->namespaceVersion = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the namespace that prefixes all cache ids.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getNamespace()
|
||||
{
|
||||
return $this->namespace;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fetch($id)
|
||||
{
|
||||
return $this->doFetch($this->getNamespacedId($id));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function contains($id)
|
||||
{
|
||||
return $this->doContains($this->getNamespacedId($id));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function save($id, $data, $lifeTime = 0)
|
||||
{
|
||||
return $this->doSave($this->getNamespacedId($id), $data, $lifeTime);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function delete($id)
|
||||
{
|
||||
return $this->doDelete($this->getNamespacedId($id));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getStats()
|
||||
{
|
||||
return $this->doGetStats();
|
||||
}
|
||||
|
||||
/**
|
||||
* Flushes all cache entries.
|
||||
*
|
||||
* @return boolean TRUE if the cache entries were successfully flushed, FALSE otherwise.
|
||||
*/
|
||||
public function flushAll()
|
||||
{
|
||||
return $this->doFlush();
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes all cache entries.
|
||||
*
|
||||
* @return boolean TRUE if the cache entries were successfully deleted, FALSE otherwise.
|
||||
*/
|
||||
public function deleteAll()
|
||||
{
|
||||
$namespaceCacheKey = $this->getNamespaceCacheKey();
|
||||
$namespaceVersion = $this->getNamespaceVersion() + 1;
|
||||
|
||||
$this->namespaceVersion = $namespaceVersion;
|
||||
|
||||
return $this->doSave($namespaceCacheKey, $namespaceVersion);
|
||||
}
|
||||
|
||||
/**
|
||||
* Prefixes the passed id with the configured namespace value.
|
||||
*
|
||||
* @param string $id The id to namespace.
|
||||
*
|
||||
* @return string The namespaced id.
|
||||
*/
|
||||
private function getNamespacedId($id)
|
||||
{
|
||||
$namespaceVersion = $this->getNamespaceVersion();
|
||||
|
||||
return sprintf('%s[%s][%s]', $this->namespace, $id, $namespaceVersion);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the namespace cache key.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function getNamespaceCacheKey()
|
||||
{
|
||||
return sprintf(self::DOCTRINE_NAMESPACE_CACHEKEY, $this->namespace);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the namespace version.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function getNamespaceVersion()
|
||||
{
|
||||
if (null !== $this->namespaceVersion) {
|
||||
return $this->namespaceVersion;
|
||||
}
|
||||
|
||||
$namespaceCacheKey = $this->getNamespaceCacheKey();
|
||||
$namespaceVersion = $this->doFetch($namespaceCacheKey);
|
||||
|
||||
if (false === $namespaceVersion) {
|
||||
$namespaceVersion = 1;
|
||||
|
||||
$this->doSave($namespaceCacheKey, $namespaceVersion);
|
||||
}
|
||||
|
||||
$this->namespaceVersion = $namespaceVersion;
|
||||
|
||||
return $this->namespaceVersion;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches an entry from the cache.
|
||||
*
|
||||
* @param string $id The id of the cache entry to fetch.
|
||||
*
|
||||
* @return string|bool The cached data or FALSE, if no cache entry exists for the given id.
|
||||
*/
|
||||
abstract protected function doFetch($id);
|
||||
|
||||
/**
|
||||
* Tests if an entry exists in the cache.
|
||||
*
|
||||
* @param string $id The cache id of the entry to check for.
|
||||
*
|
||||
* @return boolean TRUE if a cache entry exists for the given cache id, FALSE otherwise.
|
||||
*/
|
||||
abstract protected function doContains($id);
|
||||
|
||||
/**
|
||||
* Puts data into the cache.
|
||||
*
|
||||
* @param string $id The cache id.
|
||||
* @param string $data The cache entry/data.
|
||||
* @param int $lifeTime The lifetime. If != 0, sets a specific lifetime for this
|
||||
* cache entry (0 => infinite lifeTime).
|
||||
*
|
||||
* @return boolean TRUE if the entry was successfully stored in the cache, FALSE otherwise.
|
||||
*/
|
||||
abstract protected function doSave($id, $data, $lifeTime = 0);
|
||||
|
||||
/**
|
||||
* Deletes a cache entry.
|
||||
*
|
||||
* @param string $id The cache id.
|
||||
*
|
||||
* @return boolean TRUE if the cache entry was successfully deleted, FALSE otherwise.
|
||||
*/
|
||||
abstract protected function doDelete($id);
|
||||
|
||||
/**
|
||||
* Flushes all cache entries.
|
||||
*
|
||||
* @return boolean TRUE if the cache entry was successfully deleted, FALSE otherwise.
|
||||
*/
|
||||
abstract protected function doFlush();
|
||||
|
||||
/**
|
||||
* Retrieves cached information from the data store.
|
||||
*
|
||||
* @since 2.2
|
||||
*
|
||||
* @return array|null An associative array with server's statistics if available, NULL otherwise.
|
||||
*/
|
||||
abstract protected function doGetStats();
|
||||
}
|
||||
@@ -1,121 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\Common\Cache;
|
||||
|
||||
use \Couchbase;
|
||||
|
||||
/**
|
||||
* Couchbase cache provider.
|
||||
*
|
||||
* @link www.doctrine-project.org
|
||||
* @since 2.4
|
||||
* @author Michael Nitschinger <michael@nitschinger.at>
|
||||
*/
|
||||
class CouchbaseCache extends CacheProvider
|
||||
{
|
||||
/**
|
||||
* @var Couchbase|null
|
||||
*/
|
||||
private $couchbase;
|
||||
|
||||
/**
|
||||
* Sets the Couchbase instance to use.
|
||||
*
|
||||
* @param Couchbase $couchbase
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setCouchbase(Couchbase $couchbase)
|
||||
{
|
||||
$this->couchbase = $couchbase;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Couchbase instance used by the cache.
|
||||
*
|
||||
* @return Couchbase|null
|
||||
*/
|
||||
public function getCouchbase()
|
||||
{
|
||||
return $this->couchbase;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doFetch($id)
|
||||
{
|
||||
return $this->couchbase->get($id) ?: false;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doContains($id)
|
||||
{
|
||||
return (null !== $this->couchbase->get($id));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doSave($id, $data, $lifeTime = 0)
|
||||
{
|
||||
if ($lifeTime > 30 * 24 * 3600) {
|
||||
$lifeTime = time() + $lifeTime;
|
||||
}
|
||||
return $this->couchbase->set($id, $data, (int) $lifeTime);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doDelete($id)
|
||||
{
|
||||
return $this->couchbase->delete($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doFlush()
|
||||
{
|
||||
return $this->couchbase->flush();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doGetStats()
|
||||
{
|
||||
$stats = $this->couchbase->getStats();
|
||||
$servers = $this->couchbase->getServers();
|
||||
$server = explode(":", $servers[0]);
|
||||
$key = $server[0] . ":" . "11210";
|
||||
$stats = $stats[$key];
|
||||
return array(
|
||||
Cache::STATS_HITS => $stats['get_hits'],
|
||||
Cache::STATS_MISSES => $stats['get_misses'],
|
||||
Cache::STATS_UPTIME => $stats['uptime'],
|
||||
Cache::STATS_MEMORY_USAGE => $stats['bytes'],
|
||||
Cache::STATS_MEMORY_AVAILABLE => $stats['limit_maxbytes'],
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,158 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\Common\Cache;
|
||||
|
||||
/**
|
||||
* Base file cache driver.
|
||||
*
|
||||
* @since 2.3
|
||||
* @author Fabio B. Silva <fabio.bat.silva@gmail.com>
|
||||
*/
|
||||
abstract class FileCache extends CacheProvider
|
||||
{
|
||||
/**
|
||||
* The cache directory.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $directory;
|
||||
|
||||
/**
|
||||
* The cache file extension.
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
protected $extension;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $directory The cache directory.
|
||||
* @param string|null $extension The cache file extension.
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function __construct($directory, $extension = null)
|
||||
{
|
||||
if ( ! is_dir($directory) && ! @mkdir($directory, 0777, true)) {
|
||||
throw new \InvalidArgumentException(sprintf(
|
||||
'The directory "%s" does not exist and could not be created.',
|
||||
$directory
|
||||
));
|
||||
}
|
||||
|
||||
if ( ! is_writable($directory)) {
|
||||
throw new \InvalidArgumentException(sprintf(
|
||||
'The directory "%s" is not writable.',
|
||||
$directory
|
||||
));
|
||||
}
|
||||
|
||||
$this->directory = realpath($directory);
|
||||
$this->extension = $extension ?: $this->extension;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the cache directory.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDirectory()
|
||||
{
|
||||
return $this->directory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the cache file extension.
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getExtension()
|
||||
{
|
||||
return $this->extension;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $id
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getFilename($id)
|
||||
{
|
||||
$hash = hash('sha256', $id);
|
||||
$path = implode(str_split($hash, 16), DIRECTORY_SEPARATOR);
|
||||
$path = $this->directory . DIRECTORY_SEPARATOR . $path;
|
||||
$id = preg_replace('@[\\\/:"*?<>|]+@', '', $id);
|
||||
|
||||
return $path . DIRECTORY_SEPARATOR . $id . $this->extension;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doDelete($id)
|
||||
{
|
||||
return @unlink($this->getFilename($id));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doFlush()
|
||||
{
|
||||
foreach ($this->getIterator() as $name => $file) {
|
||||
@unlink($name);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doGetStats()
|
||||
{
|
||||
$usage = 0;
|
||||
foreach ($this->getIterator() as $name => $file) {
|
||||
$usage += $file->getSize();
|
||||
}
|
||||
|
||||
$free = disk_free_space($this->directory);
|
||||
|
||||
return array(
|
||||
Cache::STATS_HITS => null,
|
||||
Cache::STATS_MISSES => null,
|
||||
Cache::STATS_UPTIME => null,
|
||||
Cache::STATS_MEMORY_USAGE => $usage,
|
||||
Cache::STATS_MEMORY_AVAILABLE => $free,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Iterator
|
||||
*/
|
||||
private function getIterator()
|
||||
{
|
||||
$pattern = '/^.+\\' . $this->extension . '$/i';
|
||||
$iterator = new \RecursiveDirectoryIterator($this->directory);
|
||||
$iterator = new \RecursiveIteratorIterator($iterator);
|
||||
return new \RegexIterator($iterator, $pattern);
|
||||
}
|
||||
}
|
||||
@@ -1,113 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\Common\Cache;
|
||||
|
||||
/**
|
||||
* Filesystem cache driver.
|
||||
*
|
||||
* @since 2.3
|
||||
* @author Fabio B. Silva <fabio.bat.silva@gmail.com>
|
||||
*/
|
||||
class FilesystemCache extends FileCache
|
||||
{
|
||||
const EXTENSION = '.doctrinecache.data';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected $extension = self::EXTENSION;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doFetch($id)
|
||||
{
|
||||
$data = '';
|
||||
$lifetime = -1;
|
||||
$filename = $this->getFilename($id);
|
||||
|
||||
if ( ! is_file($filename)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$resource = fopen($filename, "r");
|
||||
|
||||
if (false !== ($line = fgets($resource))) {
|
||||
$lifetime = (integer) $line;
|
||||
}
|
||||
|
||||
if ($lifetime !== 0 && $lifetime < time()) {
|
||||
fclose($resource);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
while (false !== ($line = fgets($resource))) {
|
||||
$data .= $line;
|
||||
}
|
||||
|
||||
fclose($resource);
|
||||
|
||||
return unserialize($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doContains($id)
|
||||
{
|
||||
$lifetime = -1;
|
||||
$filename = $this->getFilename($id);
|
||||
|
||||
if ( ! is_file($filename)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$resource = fopen($filename, "r");
|
||||
|
||||
if (false !== ($line = fgets($resource))) {
|
||||
$lifetime = (integer) $line;
|
||||
}
|
||||
|
||||
fclose($resource);
|
||||
|
||||
return $lifetime === 0 || $lifetime > time();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doSave($id, $data, $lifeTime = 0)
|
||||
{
|
||||
if ($lifeTime > 0) {
|
||||
$lifeTime = time() + $lifeTime;
|
||||
}
|
||||
|
||||
$data = serialize($data);
|
||||
$filename = $this->getFilename($id);
|
||||
$filepath = pathinfo($filename, PATHINFO_DIRNAME);
|
||||
|
||||
if ( ! is_dir($filepath)) {
|
||||
mkdir($filepath, 0777, true);
|
||||
}
|
||||
|
||||
return file_put_contents($filename, $lifeTime . PHP_EOL . $data) !== false;
|
||||
}
|
||||
}
|
||||
@@ -1,121 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\Common\Cache;
|
||||
|
||||
use \Memcache;
|
||||
|
||||
/**
|
||||
* Memcache cache provider.
|
||||
*
|
||||
* @link www.doctrine-project.org
|
||||
* @since 2.0
|
||||
* @author Benjamin Eberlei <kontakt@beberlei.de>
|
||||
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
|
||||
* @author Jonathan Wage <jonwage@gmail.com>
|
||||
* @author Roman Borschel <roman@code-factory.org>
|
||||
* @author David Abdemoulaie <dave@hobodave.com>
|
||||
*/
|
||||
class MemcacheCache extends CacheProvider
|
||||
{
|
||||
/**
|
||||
* @var Memcache|null
|
||||
*/
|
||||
private $memcache;
|
||||
|
||||
/**
|
||||
* Sets the memcache instance to use.
|
||||
*
|
||||
* @param Memcache $memcache
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setMemcache(Memcache $memcache)
|
||||
{
|
||||
$this->memcache = $memcache;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the memcache instance used by the cache.
|
||||
*
|
||||
* @return Memcache|null
|
||||
*/
|
||||
public function getMemcache()
|
||||
{
|
||||
return $this->memcache;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doFetch($id)
|
||||
{
|
||||
return $this->memcache->get($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doContains($id)
|
||||
{
|
||||
return (bool) $this->memcache->get($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doSave($id, $data, $lifeTime = 0)
|
||||
{
|
||||
if ($lifeTime > 30 * 24 * 3600) {
|
||||
$lifeTime = time() + $lifeTime;
|
||||
}
|
||||
return $this->memcache->set($id, $data, 0, (int) $lifeTime);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doDelete($id)
|
||||
{
|
||||
return $this->memcache->delete($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doFlush()
|
||||
{
|
||||
return $this->memcache->flush();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doGetStats()
|
||||
{
|
||||
$stats = $this->memcache->getStats();
|
||||
return array(
|
||||
Cache::STATS_HITS => $stats['get_hits'],
|
||||
Cache::STATS_MISSES => $stats['get_misses'],
|
||||
Cache::STATS_UPTIME => $stats['uptime'],
|
||||
Cache::STATS_MEMORY_USAGE => $stats['bytes'],
|
||||
Cache::STATS_MEMORY_AVAILABLE => $stats['limit_maxbytes'],
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,124 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\Common\Cache;
|
||||
|
||||
use \Memcached;
|
||||
|
||||
/**
|
||||
* Memcached cache provider.
|
||||
*
|
||||
* @link www.doctrine-project.org
|
||||
* @since 2.2
|
||||
* @author Benjamin Eberlei <kontakt@beberlei.de>
|
||||
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
|
||||
* @author Jonathan Wage <jonwage@gmail.com>
|
||||
* @author Roman Borschel <roman@code-factory.org>
|
||||
* @author David Abdemoulaie <dave@hobodave.com>
|
||||
*/
|
||||
class MemcachedCache extends CacheProvider
|
||||
{
|
||||
/**
|
||||
* @var Memcached|null
|
||||
*/
|
||||
private $memcached;
|
||||
|
||||
/**
|
||||
* Sets the memcache instance to use.
|
||||
*
|
||||
* @param Memcached $memcached
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setMemcached(Memcached $memcached)
|
||||
{
|
||||
$this->memcached = $memcached;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the memcached instance used by the cache.
|
||||
*
|
||||
* @return Memcached|null
|
||||
*/
|
||||
public function getMemcached()
|
||||
{
|
||||
return $this->memcached;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doFetch($id)
|
||||
{
|
||||
return $this->memcached->get($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doContains($id)
|
||||
{
|
||||
return (false !== $this->memcached->get($id));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doSave($id, $data, $lifeTime = 0)
|
||||
{
|
||||
if ($lifeTime > 30 * 24 * 3600) {
|
||||
$lifeTime = time() + $lifeTime;
|
||||
}
|
||||
return $this->memcached->set($id, $data, (int) $lifeTime);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doDelete($id)
|
||||
{
|
||||
return $this->memcached->delete($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doFlush()
|
||||
{
|
||||
return $this->memcached->flush();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doGetStats()
|
||||
{
|
||||
$stats = $this->memcached->getStats();
|
||||
$servers = $this->memcached->getServerList();
|
||||
$key = $servers[0]['host'] . ':' . $servers[0]['port'];
|
||||
$stats = $stats[$key];
|
||||
return array(
|
||||
Cache::STATS_HITS => $stats['get_hits'],
|
||||
Cache::STATS_MISSES => $stats['get_misses'],
|
||||
Cache::STATS_UPTIME => $stats['uptime'],
|
||||
Cache::STATS_MEMORY_USAGE => $stats['bytes'],
|
||||
Cache::STATS_MEMORY_AVAILABLE => $stats['limit_maxbytes'],
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,191 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\Common\Cache;
|
||||
|
||||
use MongoBinData;
|
||||
use MongoCollection;
|
||||
use MongoDate;
|
||||
|
||||
/**
|
||||
* MongoDB cache provider.
|
||||
*
|
||||
* @since 1.1
|
||||
* @author Jeremy Mikola <jmikola@gmail.com>
|
||||
*/
|
||||
class MongoDBCache extends CacheProvider
|
||||
{
|
||||
/**
|
||||
* The data field will store the serialized PHP value.
|
||||
*/
|
||||
const DATA_FIELD = 'd';
|
||||
|
||||
/**
|
||||
* The expiration field will store a MongoDate value indicating when the
|
||||
* cache entry should expire.
|
||||
*
|
||||
* With MongoDB 2.2+, entries can be automatically deleted by MongoDB by
|
||||
* indexing this field wit the "expireAfterSeconds" option equal to zero.
|
||||
* This will direct MongoDB to regularly query for and delete any entries
|
||||
* whose date is older than the current time. Entries without a date value
|
||||
* in this field will be ignored.
|
||||
*
|
||||
* The cache provider will also check dates on its own, in case expired
|
||||
* entries are fetched before MongoDB's TTLMonitor pass can expire them.
|
||||
*
|
||||
* @see http://docs.mongodb.org/manual/tutorial/expire-data/
|
||||
*/
|
||||
const EXPIRATION_FIELD = 'e';
|
||||
|
||||
/**
|
||||
* @var MongoCollection
|
||||
*/
|
||||
private $collection;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* This provider will default to the write concern and read preference
|
||||
* options set on the MongoCollection instance (or inherited from MongoDB or
|
||||
* MongoClient). Using an unacknowledged write concern (< 1) may make the
|
||||
* return values of delete() and save() unreliable. Reading from secondaries
|
||||
* may make contain() and fetch() unreliable.
|
||||
*
|
||||
* @see http://www.php.net/manual/en/mongo.readpreferences.php
|
||||
* @see http://www.php.net/manual/en/mongo.writeconcerns.php
|
||||
* @param MongoCollection $collection
|
||||
*/
|
||||
public function __construct(MongoCollection $collection)
|
||||
{
|
||||
$this->collection = $collection;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doFetch($id)
|
||||
{
|
||||
$document = $this->collection->findOne(array('_id' => $id), array(self::DATA_FIELD, self::EXPIRATION_FIELD));
|
||||
|
||||
if ($document === null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($this->isExpired($document)) {
|
||||
$this->doDelete($id);
|
||||
return false;
|
||||
}
|
||||
|
||||
return unserialize($document[self::DATA_FIELD]->bin);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doContains($id)
|
||||
{
|
||||
$document = $this->collection->findOne(array('_id' => $id), array(self::EXPIRATION_FIELD));
|
||||
|
||||
if ($document === null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($this->isExpired($document)) {
|
||||
$this->doDelete($id);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doSave($id, $data, $lifeTime = 0)
|
||||
{
|
||||
$result = $this->collection->update(
|
||||
array('_id' => $id),
|
||||
array('$set' => array(
|
||||
self::EXPIRATION_FIELD => ($lifeTime > 0 ? new MongoDate(time() + $lifeTime) : null),
|
||||
self::DATA_FIELD => new MongoBinData(serialize($data), MongoBinData::BYTE_ARRAY),
|
||||
)),
|
||||
array('upsert' => true, 'multiple' => false)
|
||||
);
|
||||
|
||||
return isset($result['ok']) ? $result['ok'] == 1 : true;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doDelete($id)
|
||||
{
|
||||
$result = $this->collection->remove(array('_id' => $id));
|
||||
|
||||
return isset($result['n']) ? $result['n'] == 1 : true;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doFlush()
|
||||
{
|
||||
// Use remove() in lieu of drop() to maintain any collection indexes
|
||||
$result = $this->collection->remove();
|
||||
|
||||
return isset($result['ok']) ? $result['ok'] == 1 : true;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doGetStats()
|
||||
{
|
||||
$serverStatus = $this->collection->db->command(array(
|
||||
'serverStatus' => 1,
|
||||
'locks' => 0,
|
||||
'metrics' => 0,
|
||||
'recordStats' => 0,
|
||||
'repl' => 0,
|
||||
));
|
||||
|
||||
$collStats = $this->collection->db->command(array('collStats' => 1));
|
||||
|
||||
return array(
|
||||
Cache::STATS_HITS => null,
|
||||
Cache::STATS_MISSES => null,
|
||||
Cache::STATS_UPTIME => (isset($serverStatus['uptime']) ? (integer) $serverStatus['uptime'] : null),
|
||||
Cache::STATS_MEMORY_USAGE => (isset($collStats['size']) ? (integer) $collStats['size'] : null),
|
||||
Cache::STATS_MEMORY_AVAILABLE => null,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the document is expired.
|
||||
*
|
||||
* @param array $document
|
||||
* @return boolean
|
||||
*/
|
||||
private function isExpired(array $document)
|
||||
{
|
||||
return isset($document[self::EXPIRATION_FIELD]) &&
|
||||
$document[self::EXPIRATION_FIELD] instanceof MongoDate &&
|
||||
$document[self::EXPIRATION_FIELD]->sec < time();
|
||||
}
|
||||
}
|
||||
@@ -1,107 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\Common\Cache;
|
||||
|
||||
/**
|
||||
* Php file cache driver.
|
||||
*
|
||||
* @since 2.3
|
||||
* @author Fabio B. Silva <fabio.bat.silva@gmail.com>
|
||||
*/
|
||||
class PhpFileCache extends FileCache
|
||||
{
|
||||
const EXTENSION = '.doctrinecache.php';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected $extension = self::EXTENSION;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doFetch($id)
|
||||
{
|
||||
$filename = $this->getFilename($id);
|
||||
|
||||
if ( ! is_file($filename)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$value = include $filename;
|
||||
|
||||
if ($value['lifetime'] !== 0 && $value['lifetime'] < time()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $value['data'];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doContains($id)
|
||||
{
|
||||
$filename = $this->getFilename($id);
|
||||
|
||||
if ( ! is_file($filename)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$value = include $filename;
|
||||
|
||||
return $value['lifetime'] === 0 || $value['lifetime'] > time();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doSave($id, $data, $lifeTime = 0)
|
||||
{
|
||||
if ($lifeTime > 0) {
|
||||
$lifeTime = time() + $lifeTime;
|
||||
}
|
||||
|
||||
if (is_object($data) && ! method_exists($data, '__set_state')) {
|
||||
throw new \InvalidArgumentException(
|
||||
"Invalid argument given, PhpFileCache only allows objects that implement __set_state() " .
|
||||
"and fully support var_export(). You can use the FilesystemCache to save arbitrary object " .
|
||||
"graphs using serialize()/deserialize()."
|
||||
);
|
||||
}
|
||||
|
||||
$filename = $this->getFilename($id);
|
||||
$filepath = pathinfo($filename, PATHINFO_DIRNAME);
|
||||
|
||||
if ( ! is_dir($filepath)) {
|
||||
mkdir($filepath, 0777, true);
|
||||
}
|
||||
|
||||
$value = array(
|
||||
'lifetime' => $lifeTime,
|
||||
'data' => $data
|
||||
);
|
||||
|
||||
$value = var_export($value, true);
|
||||
$code = sprintf('<?php return %s;', $value);
|
||||
|
||||
return file_put_contents($filename, $code) !== false;
|
||||
}
|
||||
}
|
||||
@@ -1,131 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\Common\Cache;
|
||||
|
||||
use Redis;
|
||||
|
||||
/**
|
||||
* Redis cache provider.
|
||||
*
|
||||
* @link www.doctrine-project.org
|
||||
* @since 2.2
|
||||
* @author Osman Ungur <osmanungur@gmail.com>
|
||||
*/
|
||||
class RedisCache extends CacheProvider
|
||||
{
|
||||
/**
|
||||
* @var Redis|null
|
||||
*/
|
||||
private $redis;
|
||||
|
||||
/**
|
||||
* Sets the redis instance to use.
|
||||
*
|
||||
* @param Redis $redis
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setRedis(Redis $redis)
|
||||
{
|
||||
$redis->setOption(Redis::OPT_SERIALIZER, $this->getSerializerValue());
|
||||
$this->redis = $redis;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the redis instance used by the cache.
|
||||
*
|
||||
* @return Redis|null
|
||||
*/
|
||||
public function getRedis()
|
||||
{
|
||||
return $this->redis;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doFetch($id)
|
||||
{
|
||||
return $this->redis->get($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doContains($id)
|
||||
{
|
||||
return $this->redis->exists($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doSave($id, $data, $lifeTime = 0)
|
||||
{
|
||||
if ($lifeTime > 0) {
|
||||
return $this->redis->setex($id, $lifeTime, $data);
|
||||
}
|
||||
|
||||
return $this->redis->set($id, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doDelete($id)
|
||||
{
|
||||
return $this->redis->delete($id) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doFlush()
|
||||
{
|
||||
return $this->redis->flushDB();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doGetStats()
|
||||
{
|
||||
$info = $this->redis->info();
|
||||
return array(
|
||||
Cache::STATS_HITS => false,
|
||||
Cache::STATS_MISSES => false,
|
||||
Cache::STATS_UPTIME => $info['uptime_in_seconds'],
|
||||
Cache::STATS_MEMORY_USAGE => $info['used_memory'],
|
||||
Cache::STATS_MEMORY_AVAILABLE => false
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the serializer constant to use. If Redis is compiled with
|
||||
* igbinary support, that is used. Otherwise the default PHP serializer is
|
||||
* used.
|
||||
*
|
||||
* @return integer One of the Redis::SERIALIZER_* constants
|
||||
*/
|
||||
protected function getSerializerValue()
|
||||
{
|
||||
return defined('Redis::SERIALIZER_IGBINARY') ? Redis::SERIALIZER_IGBINARY : Redis::SERIALIZER_PHP;
|
||||
}
|
||||
}
|
||||
@@ -1,250 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\Common\Cache;
|
||||
|
||||
use Riak\Bucket;
|
||||
use Riak\Connection;
|
||||
use Riak\Input;
|
||||
use Riak\Exception;
|
||||
use Riak\Object;
|
||||
|
||||
/**
|
||||
* Riak cache provider.
|
||||
*
|
||||
* @link www.doctrine-project.org
|
||||
* @since 1.1
|
||||
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
|
||||
*/
|
||||
class RiakCache extends CacheProvider
|
||||
{
|
||||
const EXPIRES_HEADER = 'X-Riak-Meta-Expires';
|
||||
|
||||
/**
|
||||
* @var \Riak\Bucket
|
||||
*/
|
||||
private $bucket;
|
||||
|
||||
/**
|
||||
* Sets the riak bucket instance to use.
|
||||
*
|
||||
* @param \Riak\Bucket $bucket
|
||||
*/
|
||||
public function __construct(Bucket $bucket)
|
||||
{
|
||||
$this->bucket = $bucket;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doFetch($id)
|
||||
{
|
||||
try {
|
||||
$response = $this->bucket->get($id);
|
||||
|
||||
// No objects found
|
||||
if ( ! $response->hasObject()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check for attempted siblings
|
||||
$object = ($response->hasSiblings())
|
||||
? $this->resolveConflict($id, $response->getVClock(), $response->getObjectList())
|
||||
: $response->getFirstObject();
|
||||
|
||||
// Check for expired object
|
||||
if ($this->isExpired($object)) {
|
||||
$this->bucket->delete($object);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return unserialize($object->getContent());
|
||||
} catch (Exception\RiakException $e) {
|
||||
// Covers:
|
||||
// - Riak\ConnectionException
|
||||
// - Riak\CommunicationException
|
||||
// - Riak\UnexpectedResponseException
|
||||
// - Riak\NotFoundException
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doContains($id)
|
||||
{
|
||||
try {
|
||||
// We only need the HEAD, not the entire object
|
||||
$input = new Input\GetInput();
|
||||
|
||||
$input->setReturnHead(true);
|
||||
|
||||
$response = $this->bucket->get($id, $input);
|
||||
|
||||
// No objects found
|
||||
if ( ! $response->hasObject()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$object = $response->getFirstObject();
|
||||
|
||||
// Check for expired object
|
||||
if ($this->isExpired($object)) {
|
||||
$this->bucket->delete($object);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
} catch (Exception\RiakException $e) {
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doSave($id, $data, $lifeTime = 0)
|
||||
{
|
||||
try {
|
||||
$object = new Object($id);
|
||||
|
||||
$object->setContent(serialize($data));
|
||||
|
||||
if ($lifeTime > 0) {
|
||||
$object->addMetadata(self::EXPIRES_HEADER, (string) (time() + $lifeTime));
|
||||
}
|
||||
|
||||
$this->bucket->put($object);
|
||||
|
||||
return true;
|
||||
} catch (Exception\RiakException $e) {
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doDelete($id)
|
||||
{
|
||||
try {
|
||||
$this->bucket->delete($id);
|
||||
|
||||
return true;
|
||||
} catch (Exception\BadArgumentsException $e) {
|
||||
// Key did not exist on cluster already
|
||||
} catch (Exception\RiakException $e) {
|
||||
// Covers:
|
||||
// - Riak\Exception\ConnectionException
|
||||
// - Riak\Exception\CommunicationException
|
||||
// - Riak\Exception\UnexpectedResponseException
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doFlush()
|
||||
{
|
||||
try {
|
||||
$keyList = $this->bucket->getKeyList();
|
||||
|
||||
foreach ($keyList as $key) {
|
||||
$this->bucket->delete($key);
|
||||
}
|
||||
|
||||
return true;
|
||||
} catch (Exception\RiakException $e) {
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doGetStats()
|
||||
{
|
||||
// Only exposed through HTTP stats API, not Protocol Buffers API
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a given Riak Object have expired.
|
||||
*
|
||||
* @param \Riak\Object $object
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
private function isExpired(Object $object)
|
||||
{
|
||||
$metadataMap = $object->getMetadataMap();
|
||||
|
||||
return isset($metadataMap[self::EXPIRES_HEADER])
|
||||
&& $metadataMap[self::EXPIRES_HEADER] < time();
|
||||
}
|
||||
|
||||
/**
|
||||
* On-read conflict resolution. Applied approach here is last write wins.
|
||||
* Specific needs may override this method to apply alternate conflict resolutions.
|
||||
*
|
||||
* {@internal Riak does not attempt to resolve a write conflict, and store
|
||||
* it as sibling of conflicted one. By following this approach, it is up to
|
||||
* the next read to resolve the conflict. When this happens, your fetched
|
||||
* object will have a list of siblings (read as a list of objects).
|
||||
* In our specific case, we do not care about the intermediate ones since
|
||||
* they are all the same read from storage, and we do apply a last sibling
|
||||
* (last write) wins logic.
|
||||
* If by any means our resolution generates another conflict, it'll up to
|
||||
* next read to properly solve it.}
|
||||
*
|
||||
* @param string $id
|
||||
* @param string $vClock
|
||||
* @param array $objectList
|
||||
*
|
||||
* @return \Riak\Object
|
||||
*/
|
||||
protected function resolveConflict($id, $vClock, array $objectList)
|
||||
{
|
||||
// Our approach here is last-write wins
|
||||
$winner = $objectList[count($objectList)];
|
||||
|
||||
$putInput = new Input\PutInput();
|
||||
$putInput->setVClock($vClock);
|
||||
|
||||
$mergedObject = new Object($id);
|
||||
$mergedObject->setContent($winner->getContent());
|
||||
|
||||
$this->bucket->put($mergedObject, $putInput);
|
||||
|
||||
return $mergedObject;
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\Common\Cache;
|
||||
|
||||
class Version
|
||||
{
|
||||
const VERSION = '1.3.0';
|
||||
}
|
||||
@@ -1,91 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\Common\Cache;
|
||||
|
||||
/**
|
||||
* WinCache cache provider.
|
||||
*
|
||||
* @link www.doctrine-project.org
|
||||
* @since 2.2
|
||||
* @author Benjamin Eberlei <kontakt@beberlei.de>
|
||||
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
|
||||
* @author Jonathan Wage <jonwage@gmail.com>
|
||||
* @author Roman Borschel <roman@code-factory.org>
|
||||
* @author David Abdemoulaie <dave@hobodave.com>
|
||||
*/
|
||||
class WinCacheCache extends CacheProvider
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doFetch($id)
|
||||
{
|
||||
return wincache_ucache_get($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doContains($id)
|
||||
{
|
||||
return wincache_ucache_exists($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doSave($id, $data, $lifeTime = 0)
|
||||
{
|
||||
return (bool) wincache_ucache_set($id, $data, (int) $lifeTime);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doDelete($id)
|
||||
{
|
||||
return wincache_ucache_delete($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doFlush()
|
||||
{
|
||||
return wincache_ucache_clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doGetStats()
|
||||
{
|
||||
$info = wincache_ucache_info();
|
||||
$meminfo = wincache_ucache_meminfo();
|
||||
|
||||
return array(
|
||||
Cache::STATS_HITS => $info['total_hit_count'],
|
||||
Cache::STATS_MISSES => $info['total_miss_count'],
|
||||
Cache::STATS_UPTIME => $info['total_cache_uptime'],
|
||||
Cache::STATS_MEMORY_USAGE => $meminfo['memory_total'],
|
||||
Cache::STATS_MEMORY_AVAILABLE => $meminfo['memory_free'],
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,109 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\Common\Cache;
|
||||
|
||||
/**
|
||||
* Xcache cache driver.
|
||||
*
|
||||
* @link www.doctrine-project.org
|
||||
* @since 2.0
|
||||
* @author Benjamin Eberlei <kontakt@beberlei.de>
|
||||
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
|
||||
* @author Jonathan Wage <jonwage@gmail.com>
|
||||
* @author Roman Borschel <roman@code-factory.org>
|
||||
* @author David Abdemoulaie <dave@hobodave.com>
|
||||
*/
|
||||
class XcacheCache extends CacheProvider
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doFetch($id)
|
||||
{
|
||||
return $this->doContains($id) ? unserialize(xcache_get($id)) : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doContains($id)
|
||||
{
|
||||
return xcache_isset($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doSave($id, $data, $lifeTime = 0)
|
||||
{
|
||||
return xcache_set($id, serialize($data), (int) $lifeTime);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doDelete($id)
|
||||
{
|
||||
return xcache_unset($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doFlush()
|
||||
{
|
||||
$this->checkAuthorization();
|
||||
|
||||
xcache_clear_cache(XC_TYPE_VAR, 0);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks that xcache.admin.enable_auth is Off.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @throws \BadMethodCallException When xcache.admin.enable_auth is On.
|
||||
*/
|
||||
protected function checkAuthorization()
|
||||
{
|
||||
if (ini_get('xcache.admin.enable_auth')) {
|
||||
throw new \BadMethodCallException('To use all features of \Doctrine\Common\Cache\XcacheCache, you must set "xcache.admin.enable_auth" to "Off" in your php.ini.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doGetStats()
|
||||
{
|
||||
$this->checkAuthorization();
|
||||
|
||||
$info = xcache_info(XC_TYPE_VAR, 0);
|
||||
return array(
|
||||
Cache::STATS_HITS => $info['hits'],
|
||||
Cache::STATS_MISSES => $info['misses'],
|
||||
Cache::STATS_UPTIME => null,
|
||||
Cache::STATS_MEMORY_USAGE => $info['size'],
|
||||
Cache::STATS_MEMORY_AVAILABLE => $info['avail'],
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,83 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\Common\Cache;
|
||||
|
||||
/**
|
||||
* Zend Data Cache cache driver.
|
||||
*
|
||||
* @link www.doctrine-project.org
|
||||
* @since 2.0
|
||||
* @author Ralph Schindler <ralph.schindler@zend.com>
|
||||
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
|
||||
*/
|
||||
class ZendDataCache extends CacheProvider
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doFetch($id)
|
||||
{
|
||||
return zend_shm_cache_fetch($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doContains($id)
|
||||
{
|
||||
return (false !== zend_shm_cache_fetch($id));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doSave($id, $data, $lifeTime = 0)
|
||||
{
|
||||
return zend_shm_cache_store($id, $data, $lifeTime);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doDelete($id)
|
||||
{
|
||||
return zend_shm_cache_delete($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doFlush()
|
||||
{
|
||||
$namespace = $this->getNamespace();
|
||||
if (empty($namespace)) {
|
||||
return zend_shm_cache_clear();
|
||||
}
|
||||
return zend_shm_cache_clear($namespace);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doGetStats()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
22
vendor/donatj/phpuseragentparser/LICENSE.md
vendored
22
vendor/donatj/phpuseragentparser/LICENSE.md
vendored
@@ -1,22 +0,0 @@
|
||||
The MIT License
|
||||
===============
|
||||
|
||||
Copyright (c) 2013 Jesse G. Donat
|
||||
|
||||
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.
|
||||
110
vendor/donatj/phpuseragentparser/README.md
vendored
110
vendor/donatj/phpuseragentparser/README.md
vendored
@@ -1,110 +0,0 @@
|
||||
# PHP User Agent Parser
|
||||
|
||||
[](https://packagist.org/packages/donatj/phpuseragentparser) [](https://packagist.org/packages/donatj/phpuseragentparser) [](https://packagist.org/packages/donatj/phpuseragentparser) [](https://packagist.org/packages/donatj/phpuseragentparser)
|
||||
[](https://travis-ci.org/donatj/PhpUserAgent)
|
||||
[](http://hhvm.h4cc.de/package/donatj/phpuseragentparser) [](https://scrutinizer-ci.com/g/donatj/PhpUserAgent/?branch=master)
|
||||
|
||||
## What It Is
|
||||
|
||||
A simple, streamlined PHP user-agent parser!
|
||||
|
||||
Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php
|
||||
|
||||
|
||||
## Why Use This
|
||||
|
||||
You have your choice in user-agent parsers. This one detects **all modern browsers** in a very light, quick, understandable fashion.
|
||||
It is less than 150 lines of code, and consists of just two regular expressions!
|
||||
It can also correctly identify exotic versions of IE others fail on.
|
||||
|
||||
It offers 100% unit test coverage, is installable via Composer, and is very easy to use.
|
||||
|
||||
## What It Doesn't Do
|
||||
|
||||
### OS Versions
|
||||
|
||||
User-agent strings **are not** a reliable source of OS Version!
|
||||
|
||||
- Many agents simply don't send the information.
|
||||
- Others provide varying levels of accuracy.
|
||||
- Parsing Windows versions alone almost nearly doubles the size of the code.
|
||||
|
||||
I'm much more interested in keeping this thing *tiny* and accurate than adding niché features and would rather focus on things that can be **done well**.
|
||||
|
||||
All that said, there is the start of a [branch to do it](https://github.com/donatj/PhpUserAgent/tree/os_version_detection) I created for a client if you want to poke it, I update it from time to time, but frankly if you need to *reliably detect OS Version*, using user-agent isn't the way to do it. I'd go with JavaScript.
|
||||
|
||||
## Requirements
|
||||
|
||||
- PHP 5.3.0+
|
||||
|
||||
## Installing
|
||||
|
||||
PHP User Agent is available through Packagist via Composer.
|
||||
|
||||
```json
|
||||
{
|
||||
"require": {
|
||||
"donatj/phpuseragentparser": "*"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Sample Usage
|
||||
|
||||
```php
|
||||
$ua_info = parse_user_agent();
|
||||
/*
|
||||
array(
|
||||
'platform' => '[Detected Platform]',
|
||||
'browser' => '[Detected Browser]',
|
||||
'version' => '[Detected Browser Version]',
|
||||
);
|
||||
*/
|
||||
```
|
||||
|
||||
## Currently Detected Platforms
|
||||
|
||||
- Desktop
|
||||
- Windows
|
||||
- Linux
|
||||
- Macintosh
|
||||
- Chrome OS
|
||||
- Mobile
|
||||
- Android
|
||||
- iPhone
|
||||
- iPad
|
||||
- Windows Phone OS
|
||||
- Kindle
|
||||
- Kindle Fire
|
||||
- BlackBerry
|
||||
- Playbook
|
||||
- Console
|
||||
- Nintendo 3DS
|
||||
- Nintendo Wii
|
||||
- Nintendo WiiU
|
||||
- PlayStation 3
|
||||
- PlayStation 4
|
||||
- PlayStation Vita
|
||||
- Xbox 360
|
||||
- Xbox One
|
||||
|
||||
## Currently Detected Browsers
|
||||
|
||||
- Android Browser
|
||||
- BlackBerry Browser
|
||||
- Camino
|
||||
- Kindle / Silk
|
||||
- Firefox / Iceweasel
|
||||
- Safari
|
||||
- Internet Explorer
|
||||
- IEMobile
|
||||
- Chrome
|
||||
- Opera
|
||||
- Midori
|
||||
- Lynx
|
||||
- Wget
|
||||
- Curl
|
||||
|
||||
|
||||
|
||||
More information is available at [Donat Studios](http://donatstudios.com/PHP-Parser-HTTP_USER_AGENT).
|
||||
@@ -1,144 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Parses a user agent string into its important parts
|
||||
*
|
||||
* @author Jesse G. Donat <donatj@gmail.com>
|
||||
* @link https://github.com/donatj/PhpUserAgent
|
||||
* @link http://donatstudios.com/PHP-Parser-HTTP_USER_AGENT
|
||||
* @param string|null $u_agent User agent string to parse or null. Uses $_SERVER['HTTP_USER_AGENT'] on NULL
|
||||
* @throws InvalidArgumentException on not having a proper user agent to parse.
|
||||
* @return array an array with browser, version and platform keys
|
||||
*/
|
||||
function parse_user_agent( $u_agent = null ) {
|
||||
if( is_null($u_agent) ) {
|
||||
if( isset($_SERVER['HTTP_USER_AGENT']) ) {
|
||||
$u_agent = $_SERVER['HTTP_USER_AGENT'];
|
||||
} else {
|
||||
throw new \InvalidArgumentException('parse_user_agent requires a user agent');
|
||||
}
|
||||
}
|
||||
|
||||
$platform = null;
|
||||
$browser = null;
|
||||
$version = null;
|
||||
|
||||
$empty = array( 'platform' => $platform, 'browser' => $browser, 'version' => $version );
|
||||
|
||||
if( !$u_agent ) return $empty;
|
||||
|
||||
if( preg_match('/\((.*?)\)/im', $u_agent, $parent_matches) ) {
|
||||
|
||||
preg_match_all('/(?P<platform>BB\d+;|Android|CrOS|iPhone|iPad|Linux|Macintosh|Windows(\ Phone)?|Silk|linux-gnu|BlackBerry|PlayBook|Nintendo\ (WiiU?|3DS)|Xbox(\ One)?)
|
||||
(?:\ [^;]*)?
|
||||
(?:;|$)/imx', $parent_matches[1], $result, PREG_PATTERN_ORDER);
|
||||
|
||||
$priority = array( 'Android', 'Xbox One', 'Xbox' );
|
||||
$result['platform'] = array_unique($result['platform']);
|
||||
if( count($result['platform']) > 1 ) {
|
||||
if( $keys = array_intersect($priority, $result['platform']) ) {
|
||||
$platform = reset($keys);
|
||||
} else {
|
||||
$platform = $result['platform'][0];
|
||||
}
|
||||
} elseif( isset($result['platform'][0]) ) {
|
||||
$platform = $result['platform'][0];
|
||||
}
|
||||
}
|
||||
|
||||
if( $platform == 'linux-gnu' ) {
|
||||
$platform = 'Linux';
|
||||
} elseif( $platform == 'CrOS' ) {
|
||||
$platform = 'Chrome OS';
|
||||
}
|
||||
|
||||
preg_match_all('%(?P<browser>Camino|Kindle(\ Fire\ Build)?|Firefox|Iceweasel|Safari|MSIE|Trident/.*rv|AppleWebKit|Chrome|IEMobile|Opera|OPR|Silk|Lynx|Midori|Version|Wget|curl|NintendoBrowser|PLAYSTATION\ (\d|Vita)+)
|
||||
(?:\)?;?)
|
||||
(?:(?:[:/ ])(?P<version>[0-9A-Z.]+)|/(?:[A-Z]*))%ix',
|
||||
$u_agent, $result, PREG_PATTERN_ORDER);
|
||||
|
||||
|
||||
// If nothing matched, return null (to avoid undefined index errors)
|
||||
if( !isset($result['browser'][0]) || !isset($result['version'][0]) ) {
|
||||
return $empty;
|
||||
}
|
||||
|
||||
$browser = $result['browser'][0];
|
||||
$version = $result['version'][0];
|
||||
|
||||
$find = function ( $search, &$key ) use ( $result ) {
|
||||
$xkey = array_search(strtolower($search), array_map('strtolower', $result['browser']));
|
||||
if( $xkey !== false ) {
|
||||
$key = $xkey;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
$key = 0;
|
||||
if( $browser == 'Iceweasel' ) {
|
||||
$browser = 'Firefox';
|
||||
} elseif( $find('Playstation Vita', $key) ) {
|
||||
$platform = 'PlayStation Vita';
|
||||
$browser = 'Browser';
|
||||
} elseif( $find('Kindle Fire Build', $key) || $find('Silk', $key) ) {
|
||||
$browser = $result['browser'][$key] == 'Silk' ? 'Silk' : 'Kindle';
|
||||
$platform = 'Kindle Fire';
|
||||
if( !($version = $result['version'][$key]) || !is_numeric($version[0]) ) {
|
||||
$version = $result['version'][array_search('Version', $result['browser'])];
|
||||
}
|
||||
} elseif( $find('NintendoBrowser', $key) || $platform == 'Nintendo 3DS' ) {
|
||||
$browser = 'NintendoBrowser';
|
||||
$version = $result['version'][$key];
|
||||
} elseif( $find('Kindle', $key) ) {
|
||||
$browser = $result['browser'][$key];
|
||||
$platform = 'Kindle';
|
||||
$version = $result['version'][$key];
|
||||
} elseif( $find('OPR', $key) ) {
|
||||
$browser = 'Opera Next';
|
||||
$version = $result['version'][$key];
|
||||
} elseif( $find('Opera', $key) ) {
|
||||
$browser = 'Opera';
|
||||
$find('Version', $key);
|
||||
$version = $result['version'][$key];
|
||||
} elseif( $find('Midori', $key) ) {
|
||||
$browser = 'Midori';
|
||||
$version = $result['version'][$key];
|
||||
} elseif( $browser == 'MSIE' || strpos($browser, 'Trident') !== false ) {
|
||||
if( $find('IEMobile', $key) ) {
|
||||
$browser = 'IEMobile';
|
||||
} else {
|
||||
$browser = 'MSIE';
|
||||
$key = 0;
|
||||
}
|
||||
$version = $result['version'][$key];
|
||||
} elseif( $find('Chrome', $key) ) {
|
||||
$browser = 'Chrome';
|
||||
$version = $result['version'][$key];
|
||||
} elseif( $browser == 'AppleWebKit' ) {
|
||||
if( ($platform == 'Android' && !($key = 0)) ) {
|
||||
$browser = 'Android Browser';
|
||||
} elseif( strpos($platform, 'BB') === 0 ) {
|
||||
$browser = 'BlackBerry Browser';
|
||||
$platform = 'BlackBerry';
|
||||
} elseif( $platform == 'BlackBerry' || $platform == 'PlayBook' ) {
|
||||
$browser = 'BlackBerry Browser';
|
||||
} elseif( $find('Safari', $key) ) {
|
||||
$browser = 'Safari';
|
||||
}
|
||||
|
||||
$find('Version', $key);
|
||||
|
||||
$version = $result['version'][$key];
|
||||
} elseif( $key = preg_grep('/playstation \d/i', array_map('strtolower', $result['browser'])) ) {
|
||||
$key = reset($key);
|
||||
|
||||
$platform = 'PlayStation ' . preg_replace('/[^\d]/i', '', $key);
|
||||
$browser = 'NetFront';
|
||||
}
|
||||
|
||||
return array( 'platform' => $platform, 'browser' => $browser, 'version' => $version );
|
||||
|
||||
}
|
||||
20
vendor/erusev/parsedown-extra/LICENSE.txt
vendored
20
vendor/erusev/parsedown-extra/LICENSE.txt
vendored
@@ -1,20 +0,0 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2013 Emanuil Rusev, erusev.com
|
||||
|
||||
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.
|
||||
420
vendor/erusev/parsedown-extra/ParsedownExtra.php
vendored
420
vendor/erusev/parsedown-extra/ParsedownExtra.php
vendored
@@ -1,420 +0,0 @@
|
||||
<?php
|
||||
|
||||
#
|
||||
#
|
||||
# Parsedown Extra
|
||||
# https://github.com/erusev/parsedown-extra
|
||||
#
|
||||
# (c) Emanuil Rusev
|
||||
# http://erusev.com
|
||||
#
|
||||
# For the full license information, view the LICENSE file that was distributed
|
||||
# with this source code.
|
||||
#
|
||||
#
|
||||
|
||||
class ParsedownExtra extends Parsedown
|
||||
{
|
||||
#
|
||||
# ~
|
||||
|
||||
function __construct()
|
||||
{
|
||||
$this->BlockTypes[':'] []= 'DefinitionList';
|
||||
|
||||
$this->DefinitionTypes['*'] []= 'Abbreviation';
|
||||
|
||||
# identify footnote definitions before reference definitions
|
||||
array_unshift($this->DefinitionTypes['['], 'Footnote');
|
||||
|
||||
# identify footnote markers before before links
|
||||
array_unshift($this->SpanTypes['['], 'FootnoteMarker');
|
||||
}
|
||||
|
||||
#
|
||||
# ~
|
||||
|
||||
function text($text)
|
||||
{
|
||||
$markup = parent::text($text);
|
||||
|
||||
# merge consecutive dl elements
|
||||
|
||||
$markup = preg_replace('/<\/dl>\s+<dl>\s+/', '', $markup);
|
||||
|
||||
# add footnotes
|
||||
|
||||
if (isset($this->Definitions['Footnote']))
|
||||
{
|
||||
$Element = $this->buildFootnoteElement();
|
||||
|
||||
$markup .= "\n" . $this->element($Element);
|
||||
}
|
||||
|
||||
return $markup;
|
||||
}
|
||||
|
||||
#
|
||||
# Blocks
|
||||
#
|
||||
|
||||
#
|
||||
# Atx
|
||||
|
||||
protected function identifyAtx($Line)
|
||||
{
|
||||
$Block = parent::identifyAtx($Line);
|
||||
|
||||
if (preg_match('/[ ]*'.$this->attributesPattern.'[ ]*$/', $Block['element']['text'], $matches, PREG_OFFSET_CAPTURE))
|
||||
{
|
||||
$attributeString = $matches[1][0];
|
||||
|
||||
$Block['element']['attributes'] = $this->parseAttributes($attributeString);
|
||||
|
||||
$Block['element']['text'] = substr($Block['element']['text'], 0, $matches[0][1]);
|
||||
}
|
||||
|
||||
return $Block;
|
||||
}
|
||||
|
||||
#
|
||||
# Definition List
|
||||
|
||||
protected function identifyDefinitionList($Line, $Block)
|
||||
{
|
||||
if (isset($Block['type']))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$Element = array(
|
||||
'name' => 'dl',
|
||||
'handler' => 'elements',
|
||||
'text' => array(),
|
||||
);
|
||||
|
||||
$terms = explode("\n", $Block['element']['text']);
|
||||
|
||||
foreach ($terms as $term)
|
||||
{
|
||||
$Element['text'] []= array(
|
||||
'name' => 'dt',
|
||||
'handler' => 'line',
|
||||
'text' => $term,
|
||||
);
|
||||
}
|
||||
|
||||
$Element['text'] []= array(
|
||||
'name' => 'dd',
|
||||
'handler' => 'line',
|
||||
'text' => ltrim($Line['text'], ' :'),
|
||||
);
|
||||
|
||||
$Block['element'] = $Element;
|
||||
|
||||
return $Block;
|
||||
}
|
||||
|
||||
protected function addToDefinitionList($Line, array $Block)
|
||||
{
|
||||
if ($Line['text'][0] === ':')
|
||||
{
|
||||
$Block['element']['text'] []= array(
|
||||
'name' => 'dd',
|
||||
'handler' => 'line',
|
||||
'text' => ltrim($Line['text'], ' :'),
|
||||
);
|
||||
|
||||
return $Block;
|
||||
}
|
||||
|
||||
if ( ! isset($Block['interrupted']))
|
||||
{
|
||||
$Element = array_pop($Block['element']['text']);
|
||||
|
||||
$Element['text'] .= "\n" . chop($Line['text']);
|
||||
|
||||
$Block['element']['text'] []= $Element;
|
||||
|
||||
return $Block;
|
||||
}
|
||||
}
|
||||
|
||||
#
|
||||
# Setext
|
||||
|
||||
protected function identifySetext($Line, array $Block = null)
|
||||
{
|
||||
$Block = parent::identifySetext($Line, $Block);
|
||||
|
||||
if (preg_match('/[ ]*'.$this->attributesPattern.'[ ]*$/', $Block['element']['text'], $matches, PREG_OFFSET_CAPTURE))
|
||||
{
|
||||
$attributeString = $matches[1][0];
|
||||
|
||||
$Block['element']['attributes'] = $this->parseAttributes($attributeString);
|
||||
|
||||
$Block['element']['text'] = substr($Block['element']['text'], 0, $matches[0][1]);
|
||||
}
|
||||
|
||||
return $Block;
|
||||
}
|
||||
|
||||
#
|
||||
# Markup
|
||||
|
||||
protected function completeMarkup($Block)
|
||||
{
|
||||
$DOMDocument = new DOMDocument;
|
||||
|
||||
$DOMDocument->loadXML($Block['element'], LIBXML_NOERROR | LIBXML_NOWARNING);
|
||||
|
||||
if ($DOMDocument->documentElement === null)
|
||||
{
|
||||
return $Block;
|
||||
}
|
||||
|
||||
$result = $DOMDocument->documentElement->getAttribute('markdown');
|
||||
|
||||
if ($result !== '1')
|
||||
{
|
||||
return $Block;
|
||||
}
|
||||
|
||||
$DOMDocument->documentElement->removeAttribute('markdown');
|
||||
|
||||
$index = 0;
|
||||
$texts = array();
|
||||
|
||||
foreach ($DOMDocument->documentElement->childNodes as $Node)
|
||||
{
|
||||
if ($Node instanceof DOMText)
|
||||
{
|
||||
$texts [] = $this->text($Node->nodeValue);
|
||||
|
||||
# replaces the text of the node with a placeholder
|
||||
$Node->nodeValue = '\x1A'.$index ++;
|
||||
}
|
||||
}
|
||||
|
||||
$markup = $DOMDocument->saveXML($DOMDocument->documentElement);
|
||||
|
||||
foreach ($texts as $index => $text)
|
||||
{
|
||||
$markup = str_replace('\x1A'.$index, $text, $markup);
|
||||
}
|
||||
|
||||
$Block['element'] = $markup;
|
||||
|
||||
return $Block;
|
||||
}
|
||||
|
||||
#
|
||||
# Definitions
|
||||
#
|
||||
|
||||
#
|
||||
# Abbreviation
|
||||
|
||||
protected function identifyAbbreviation($Line)
|
||||
{
|
||||
if (preg_match('/^\*\[(.+?)\]:[ ]*(.+?)[ ]*$/', $Line['text'], $matches))
|
||||
{
|
||||
$Abbreviation = array(
|
||||
'id' => $matches[1],
|
||||
'data' => $matches[2],
|
||||
);
|
||||
|
||||
return $Abbreviation;
|
||||
}
|
||||
}
|
||||
|
||||
#
|
||||
# Footnote
|
||||
|
||||
protected function identifyFootnote($Line)
|
||||
{
|
||||
if (preg_match('/^\[\^(.+?)\]:[ ]?(.+)$/', $Line['text'], $matches))
|
||||
{
|
||||
$Footnote = array(
|
||||
'id' => $matches[1],
|
||||
'data' => array(
|
||||
'text' => $matches[2],
|
||||
'count' => null,
|
||||
'number' => null,
|
||||
),
|
||||
);
|
||||
|
||||
return $Footnote;
|
||||
}
|
||||
}
|
||||
|
||||
#
|
||||
# Spans
|
||||
#
|
||||
|
||||
#
|
||||
# Footnote Marker
|
||||
|
||||
protected function identifyFootnoteMarker($Excerpt)
|
||||
{
|
||||
if (preg_match('/^\[\^(.+?)\]/', $Excerpt['text'], $matches))
|
||||
{
|
||||
$name = $matches[1];
|
||||
|
||||
if ( ! isset($this->Definitions['Footnote'][$name]))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$this->Definitions['Footnote'][$name]['count'] ++;
|
||||
|
||||
if ( ! isset($this->Definitions['Footnote'][$name]['number']))
|
||||
{
|
||||
$this->Definitions['Footnote'][$name]['number'] = ++ $this->footnoteCount; # » &
|
||||
}
|
||||
|
||||
$Element = array(
|
||||
'name' => 'sup',
|
||||
'attributes' => array('id' => 'fnref'.$this->Definitions['Footnote'][$name]['count'].':'.$name),
|
||||
'handler' => 'element',
|
||||
'text' => array(
|
||||
'name' => 'a',
|
||||
'attributes' => array('href' => '#fn:'.$name, 'class' => 'footnote-ref'),
|
||||
'text' => $this->Definitions['Footnote'][$name]['number'],
|
||||
),
|
||||
);
|
||||
|
||||
return array(
|
||||
'extent' => strlen($matches[0]),
|
||||
'element' => $Element,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
private $footnoteCount = 0;
|
||||
|
||||
#
|
||||
# Link
|
||||
|
||||
protected function identifyLink($Excerpt)
|
||||
{
|
||||
$Span = parent::identifyLink($Excerpt);
|
||||
|
||||
$remainder = substr($Excerpt['text'], $Span['extent']);
|
||||
|
||||
if (preg_match('/^[ ]*'.$this->attributesPattern.'/', $remainder, $matches))
|
||||
{
|
||||
$Span['element']['attributes'] += $this->parseAttributes($matches[1]);
|
||||
|
||||
$Span['extent'] += strlen($matches[0]);
|
||||
}
|
||||
|
||||
return $Span;
|
||||
}
|
||||
|
||||
#
|
||||
# ~
|
||||
|
||||
protected function readPlainText($text)
|
||||
{
|
||||
$text = parent::readPlainText($text);
|
||||
|
||||
if (isset($this->Definitions['Abbreviation']))
|
||||
{
|
||||
foreach ($this->Definitions['Abbreviation'] as $abbreviation => $phrase)
|
||||
{
|
||||
$text = str_replace($abbreviation, '<abbr title="'.$phrase.'">'.$abbreviation.'</abbr>', $text);
|
||||
}
|
||||
}
|
||||
|
||||
return $text;
|
||||
}
|
||||
|
||||
#
|
||||
# ~
|
||||
#
|
||||
|
||||
protected function buildFootnoteElement()
|
||||
{
|
||||
$Element = array(
|
||||
'name' => 'div',
|
||||
'attributes' => array('class' => 'footnotes'),
|
||||
'handler' => 'elements',
|
||||
'text' => array(
|
||||
array(
|
||||
'name' => 'hr',
|
||||
),
|
||||
array(
|
||||
'name' => 'ol',
|
||||
'handler' => 'elements',
|
||||
'text' => array(),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
usort($this->Definitions['Footnote'], function($A, $B) {
|
||||
return $A['number'] - $B['number'];
|
||||
});
|
||||
|
||||
foreach ($this->Definitions['Footnote'] as $name => $Data)
|
||||
{
|
||||
if ( ! isset($Data['number']))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$text = $Data['text'];
|
||||
|
||||
foreach (range(1, $Data['count']) as $number)
|
||||
{
|
||||
$text .= ' <a href="#fnref'.$number.':'.$name.'" rev="footnote" class="footnote-backref">↩</a>';
|
||||
}
|
||||
|
||||
$Element['text'][1]['text'] []= array(
|
||||
'name' => 'li',
|
||||
'attributes' => array('id' => 'fn:'.$name),
|
||||
'handler' => 'elements',
|
||||
'text' => array(
|
||||
array(
|
||||
'name' => 'p',
|
||||
'text' => $text,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return $Element;
|
||||
}
|
||||
|
||||
#
|
||||
# Private
|
||||
#
|
||||
|
||||
private function parseAttributes($attributeString)
|
||||
{
|
||||
$Data = array();
|
||||
|
||||
$attributes = preg_split('/[ ]+/', $attributeString, - 1, PREG_SPLIT_NO_EMPTY);
|
||||
|
||||
foreach ($attributes as $attribute)
|
||||
{
|
||||
if ($attribute[0] === '#')
|
||||
{
|
||||
$Data['id'] = substr($attribute, 1);
|
||||
}
|
||||
else # "."
|
||||
{
|
||||
$classes []= substr($attribute, 1);
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($classes))
|
||||
{
|
||||
$Data['class'] = implode(' ', $classes);
|
||||
}
|
||||
|
||||
return $Data;
|
||||
}
|
||||
|
||||
private $attributesPattern = '{((?:[#.][-\w]+[ ]*)+)}';
|
||||
}
|
||||
17
vendor/erusev/parsedown-extra/README.md
vendored
17
vendor/erusev/parsedown-extra/README.md
vendored
@@ -1,17 +0,0 @@
|
||||
## Parsedown Extra
|
||||
|
||||
An extension of [Parsedown](http://parsedown.org) that adds support for [Markdown Extra](http://en.wikipedia.org/wiki/Markdown_Extra).
|
||||
|
||||
[[ demo ]](http://parsedown.org/demo?extra=1)
|
||||
|
||||
### Installation
|
||||
|
||||
Include both `Parsedown.php` and `ParsedownExtra.php` or install [the composer package](https://packagist.org/packages/erusev/parsedown-extra).
|
||||
|
||||
### Example
|
||||
|
||||
``` php
|
||||
$Instance = new ParsedownExtra();
|
||||
|
||||
echo $Instance->text('Hello _Parsedown Extra_!'); # prints: <p>Hello <em>Parsedown Extra</em>!</p>
|
||||
```
|
||||
20
vendor/erusev/parsedown/LICENSE.txt
vendored
20
vendor/erusev/parsedown/LICENSE.txt
vendored
@@ -1,20 +0,0 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2013 Emanuil Rusev, erusev.com
|
||||
|
||||
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.
|
||||
1402
vendor/erusev/parsedown/Parsedown.php
vendored
1402
vendor/erusev/parsedown/Parsedown.php
vendored
File diff suppressed because it is too large
Load Diff
40
vendor/erusev/parsedown/README.md
vendored
40
vendor/erusev/parsedown/README.md
vendored
@@ -1,40 +0,0 @@
|
||||
## Parsedown
|
||||
|
||||
Better [Markdown](http://en.wikipedia.org/wiki/Markdown) parser for PHP.
|
||||
|
||||
* [Demo](http://parsedown.org/demo)
|
||||
* [Test Suite](http://parsedown.org/tests/)
|
||||
|
||||
### Features
|
||||
|
||||
* [Fast](http://parsedown.org/speed)
|
||||
* [Consistent](http://parsedown.org/consistency)
|
||||
* [GitHub Flavored](https://help.github.com/articles/github-flavored-markdown)
|
||||
* [Tested](https://travis-ci.org/erusev/parsedown) in PHP 5.2, 5.3, 5.4, 5.5, 5.6 and [hhvm](http://www.hhvm.com/)
|
||||
* Extensible
|
||||
* [Markdown Extra extension](https://github.com/erusev/parsedown-extra) <sup>new</sup>
|
||||
|
||||
### Installation
|
||||
|
||||
Include `Parsedown.php` or install [the composer package](https://packagist.org/packages/erusev/parsedown).
|
||||
|
||||
### Example
|
||||
|
||||
``` php
|
||||
$Parsedown = new Parsedown();
|
||||
|
||||
echo $Parsedown->text('Hello _Parsedown_!'); # prints: <p>Hello <em>Parsedown</em>!</p>
|
||||
```
|
||||
|
||||
More examples in [the wiki](https://github.com/erusev/parsedown/wiki/Usage).
|
||||
|
||||
### Questions
|
||||
|
||||
**How does Parsedown work?**<br/>
|
||||
Parsedown recognises that the Markdown syntax is optimised for humans so it tries to read like one. It goes through text line by line. It looks at how lines start to identify blocks. It looks for special characters to identify inline elements.
|
||||
|
||||
**Why doesn’t Parsedown use namespaces?**<br/>
|
||||
Using namespaces would mean dropping support for PHP 5.2. Since Parsedown is a single class with an uncommon name, making this trade wouldn't make much sense.
|
||||
|
||||
**Who uses Parsedown?**<br/>
|
||||
[phpDocumentor](http://www.phpdoc.org/), [Bolt CMS](http://bolt.cm/), [RaspberryPi.org](http://www.raspberrypi.org/) and [more](https://www.versioneye.com/php/erusev:parsedown/references).
|
||||
291
vendor/gregwar/cache/Gregwar/Cache/Cache.php
vendored
291
vendor/gregwar/cache/Gregwar/Cache/Cache.php
vendored
@@ -1,291 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Gregwar\Cache;
|
||||
|
||||
/**
|
||||
* A cache system based on files
|
||||
*
|
||||
* @author Gregwar <g.passault@gmail.com>
|
||||
*/
|
||||
class Cache
|
||||
{
|
||||
/**
|
||||
* Cache directory
|
||||
*/
|
||||
protected $cacheDirectory;
|
||||
|
||||
/**
|
||||
* Use a different directory as actual cache
|
||||
*/
|
||||
protected $actualCacheDirectory = null;
|
||||
|
||||
/**
|
||||
* Prefix directories size
|
||||
*
|
||||
* For instance, if the file is helloworld.txt and the prefix size is
|
||||
* 5, the cache file will be: h/e/l/l/o/helloworld.txt
|
||||
*
|
||||
* This is useful to avoid reaching a too large number of files into the
|
||||
* cache system directories
|
||||
*/
|
||||
protected $prefixSize = 5;
|
||||
|
||||
/**
|
||||
* Constructs the cache system
|
||||
*/
|
||||
public function __construct($cacheDirectory = 'cache')
|
||||
{
|
||||
$this->cacheDirectory = $cacheDirectory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the cache directory
|
||||
*
|
||||
* @param $cacheDirectory the cache directory
|
||||
*/
|
||||
public function setCacheDirectory($cacheDirectory)
|
||||
{
|
||||
$this->cacheDirectory = $cacheDirectory;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the cache directory
|
||||
*
|
||||
* @return string the cache directory
|
||||
*/
|
||||
public function getCacheDirectory()
|
||||
{
|
||||
return $this->cacheDirectory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the actual cache directory
|
||||
*/
|
||||
public function setActualCacheDirectory($actualCacheDirectory = null)
|
||||
{
|
||||
$this->actualCacheDirectory = $actualCacheDirectory;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the actual cache directory
|
||||
*/
|
||||
public function getActualCacheDirectory()
|
||||
{
|
||||
return $this->actualCacheDirectory ?: $this->cacheDirectory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the prefix size
|
||||
*
|
||||
* @param $prefixSize the size of the prefix directories
|
||||
*/
|
||||
public function setPrefixSize($prefixSize)
|
||||
{
|
||||
$this->prefixSize = $prefixSize;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a directory
|
||||
*
|
||||
* @param $directory, the target directory
|
||||
*/
|
||||
protected function mkdir($directory)
|
||||
{
|
||||
if (!is_dir($directory)) {
|
||||
@mkdir($directory, 0755, true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the cache file name
|
||||
*
|
||||
* @param $filename, the name of the cache file
|
||||
* @param $actual get the actual file or the public file
|
||||
* @param $mkdir, a boolean to enable/disable the construction of the
|
||||
* cache file directory
|
||||
*/
|
||||
public function getCacheFile($filename, $actual = false, $mkdir = false)
|
||||
{
|
||||
$path = array();
|
||||
|
||||
// Getting the length of the filename before the extension
|
||||
$parts = explode('.', $filename);
|
||||
$len = strlen($parts[0]);
|
||||
|
||||
for ($i=0; $i<min($len, $this->prefixSize); $i++) {
|
||||
$path[] = $filename[$i];
|
||||
|
||||
}
|
||||
$path = implode('/', $path);
|
||||
|
||||
$actualDir = $this->getActualCacheDirectory() . '/' . $path;
|
||||
if ($mkdir && !is_dir($actualDir)) {
|
||||
mkdir($actualDir, 0755, true);
|
||||
}
|
||||
|
||||
$path .= '/' . $filename;
|
||||
|
||||
if ($actual) {
|
||||
return $this->getActualCacheDirectory() . '/' . $path;
|
||||
} else {
|
||||
return $this->getCacheDirectory() . '/' . $path;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks that the cache conditions are respected
|
||||
*
|
||||
* @param $cacheFile the cache file
|
||||
* @param $conditions an array of conditions to check
|
||||
*/
|
||||
protected function checkConditions($cacheFile, array $conditions = array())
|
||||
{
|
||||
// Implicit condition: the cache file should exist
|
||||
if (!file_exists($cacheFile)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach ($conditions as $type => $value) {
|
||||
switch ($type) {
|
||||
case 'maxage':
|
||||
case 'max-age':
|
||||
// Return false if the file is older than $value
|
||||
$age = time() - filectime($cacheFile);
|
||||
if ($age > $value) {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case 'younger-than':
|
||||
case 'youngerthan':
|
||||
// Return false if the file is older than the file $value, or the files $value
|
||||
$check = function($filename) use ($cacheFile) {
|
||||
return !file_exists($filename) || filectime($cacheFile) < filectime($filename);
|
||||
};
|
||||
|
||||
if (!is_array($value)) {
|
||||
if (!$this->isRemote($value) && $check($value)) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
foreach ($value as $file) {
|
||||
if (!$this->isRemote($file) && $check($file)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw new \Exception('Cache condition '.$type.' not supported');
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the targt filename exists in the cache and if the conditions
|
||||
* are respected
|
||||
*
|
||||
* @param $filename the filename
|
||||
* @param $conditions the conditions to respect
|
||||
*/
|
||||
public function exists($filename, array $conditions = array())
|
||||
{
|
||||
$cacheFile = $this->getCacheFile($filename, true);
|
||||
|
||||
return $this->checkConditions($cacheFile, $conditions);
|
||||
}
|
||||
|
||||
/**
|
||||
* Alias for exists
|
||||
*/
|
||||
public function check($filename, array $conditions = array())
|
||||
{
|
||||
return $this->exists($filename, $conditions);
|
||||
}
|
||||
|
||||
/**
|
||||
* Write data in the cache
|
||||
*/
|
||||
public function set($filename, $contents = '')
|
||||
{
|
||||
$cacheFile = $this->getCacheFile($filename, true, true);
|
||||
|
||||
file_put_contents($cacheFile, $contents);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Alias for set()
|
||||
*/
|
||||
public function write($filename, $contents = '')
|
||||
{
|
||||
return $this->set($filename, $contents);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get data from the cache
|
||||
*/
|
||||
public function get($filename, array $conditions = array())
|
||||
{
|
||||
if ($this->exists($filename, $conditions)) {
|
||||
return file_get_contents($this->getCacheFile($filename, true));
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this URL remote?
|
||||
*/
|
||||
protected function isRemote($file)
|
||||
{
|
||||
return preg_match('/^http(s{0,1}):\/\//', $file);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get or create the cache entry
|
||||
*
|
||||
* @param $filename the cache file name
|
||||
* @param $conditions an array of conditions about expiration
|
||||
* @param $function the closure to call if the file does not exists
|
||||
* @param $file returns the cache file or the file contents
|
||||
* @param $actual returns the actual cache file
|
||||
*/
|
||||
public function getOrCreate($filename, array $conditions = array(), \Closure $function, $file = false, $actual = false)
|
||||
{
|
||||
$cacheFile = $this->getCacheFile($filename, true, true);
|
||||
$data = null;
|
||||
|
||||
if ($this->check($filename, $conditions)) {
|
||||
$data = file_get_contents($cacheFile);
|
||||
} else {
|
||||
@unlink($cacheFile);
|
||||
$data = $function($cacheFile);
|
||||
|
||||
// Test if the closure wrote the file or if it returned the data
|
||||
if (!file_exists($cacheFile)) {
|
||||
$this->set($filename, $data);
|
||||
} else {
|
||||
$data = file_get_contents($cacheFile);
|
||||
}
|
||||
}
|
||||
|
||||
return $file ? $this->getCacheFile($filename, $actual) : $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Alias to getOrCreate with $file = true
|
||||
*/
|
||||
public function getOrCreateFile($filename, array $conditions = array(), \Closure $function, $actual = false)
|
||||
{
|
||||
return $this->getOrCreate($filename, $conditions, $function, true, $actual);
|
||||
}
|
||||
}
|
||||
@@ -1,86 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Gregwar\Cache;
|
||||
|
||||
/**
|
||||
* Garbage collect a directory, this will crawl a directory, lookng
|
||||
* for files older than X days and destroy them
|
||||
*
|
||||
* @author Gregwar <g.passault@gmail.com>
|
||||
*/
|
||||
class GarbageCollect
|
||||
{
|
||||
/**
|
||||
* Drops old files of a directory
|
||||
*
|
||||
* @param string $directory the name of the target directory
|
||||
* @param int $days the number of days to consider a file old
|
||||
* @param bool $verbose enable verbose output
|
||||
*
|
||||
* @return true if all the files/directories of a directory was wiped
|
||||
*/
|
||||
public static function dropOldFiles($directory, $days = 30, $verbose = false)
|
||||
{
|
||||
$allDropped = true;
|
||||
$now = time();
|
||||
|
||||
$dir = opendir($directory);
|
||||
|
||||
if (!$dir) {
|
||||
if ($verbose) {
|
||||
echo "! Unable to open $directory\n";
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
while ($file = readdir($dir)) {
|
||||
if ($file == '.' || $file == '..') {
|
||||
continue;
|
||||
}
|
||||
|
||||
$fullName = $directory.'/'.$file;
|
||||
|
||||
$old = $now-filemtime($fullName);
|
||||
|
||||
if (is_dir($fullName)) {
|
||||
// Directories are recursively crawled
|
||||
if (static::dropOldFiles($fullName, $days, $verbose)) {
|
||||
self::drop($fullName, $verbose);
|
||||
} else {
|
||||
$allDropped = false;
|
||||
}
|
||||
} else {
|
||||
if ($old > (24*60*60*$days)) {
|
||||
self::drop($fullName, $verbose);
|
||||
} else {
|
||||
$allDropped = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
closedir($dir);
|
||||
|
||||
return $allDropped;
|
||||
}
|
||||
|
||||
/**
|
||||
* Drops a file or an empty directory
|
||||
*
|
||||
* @param $file the file to be removed
|
||||
* @param $verbose the verbosity
|
||||
*/
|
||||
public static function drop($file, $verbose = false)
|
||||
{
|
||||
if (is_dir($file)) {
|
||||
@rmdir($file);
|
||||
} else {
|
||||
@unlink($file);
|
||||
}
|
||||
|
||||
if ($verbose) {
|
||||
echo "> Dropping $file...\n";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
19
vendor/gregwar/cache/Gregwar/Cache/LICENSE
vendored
19
vendor/gregwar/cache/Gregwar/Cache/LICENSE
vendored
@@ -1,19 +0,0 @@
|
||||
Copyright (c) <2013> Grégoire Passault
|
||||
|
||||
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.
|
||||
162
vendor/gregwar/cache/Gregwar/Cache/README.md
vendored
162
vendor/gregwar/cache/Gregwar/Cache/README.md
vendored
@@ -1,162 +0,0 @@
|
||||
Cache
|
||||
=====
|
||||
|
||||
This is a lightweight cache system based on file and directories.
|
||||
|
||||
Usage
|
||||
=====
|
||||
|
||||
Step 1: Install it
|
||||
------------------
|
||||
|
||||
Via composer:
|
||||
|
||||
```json
|
||||
{
|
||||
"require": {
|
||||
"gregwar/cache": "1.0.*"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Or with a clone of the repository:
|
||||
|
||||
```bash
|
||||
git clone https://github.com/Gregwar/Cache.git
|
||||
```
|
||||
|
||||
Or downloading it:
|
||||
|
||||
* [Download .zip](https://github.com/Gregwar/Cache/archive/master.zip)
|
||||
* [Download .tar.gz](https://github.com/Gregwar/Cache/archive/master.tar.gz)
|
||||
|
||||
Step 2: Setup the rights
|
||||
------------------------
|
||||
|
||||
You need your PHP script to have access to the cache directory, you can for instance
|
||||
create a `cache` directory with mode 777:
|
||||
|
||||
```
|
||||
mkdir cache
|
||||
chmod 777 cache
|
||||
```
|
||||
|
||||
Step 3: Access the cache
|
||||
------------------------
|
||||
|
||||
To access the cache, you can do like this:
|
||||
|
||||
```php
|
||||
<?php
|
||||
|
||||
include('vendor/autoload.php'); // If using composer
|
||||
|
||||
use Gregwar\Cache\Cache;
|
||||
|
||||
$cache = new Cache;
|
||||
$cache->setCacheDirectory('cache'); // This is the default
|
||||
|
||||
// If the cache exists, this will return it, else, the closure will be called
|
||||
// to create this image
|
||||
$data = $cache->getOrCreate('red-square.png', array(), function($filename) {
|
||||
$i = imagecreatetruecolor(100, 100);
|
||||
imagefill($i, 0, 0, 0xff0000);
|
||||
imagepng($i, $filename);
|
||||
});
|
||||
|
||||
header('Content-type: image/png');
|
||||
echo $data;
|
||||
```
|
||||
|
||||
This will render a red square. If the cache file (which will look like `cache/r/e/d/-/s/red-square.png')
|
||||
exists, it will be read, else, the closure will be called in order to create the cache file.
|
||||
|
||||
API
|
||||
===
|
||||
|
||||
You can use the following methods:
|
||||
|
||||
* `setCacheDirectory($directory)`: sets the cache directory (see below).
|
||||
* `setActualCacheDirectory($directory)`: sets the actual cache directory (see below).
|
||||
* `exists($filename, $conditions = array())`: check that the $filename file exists in the cache, checking
|
||||
the conditions (see below).
|
||||
* `check($filename, $conditions = array())`: alias for `exists`.
|
||||
* `getCacheFile($filename, $actual = false, $mkdir = false)`: gets the cache file. If the `$actual` flag
|
||||
is true, the actual cache file name will be returned (see below), if the `$mkdir` flag is true, the
|
||||
cache file directories tree will be created.
|
||||
* `set($filename, $contents)`: write contents to `$filename` cache file.
|
||||
* `write($filename, $contents)`: alias for `set()`
|
||||
* `get($filename, $conditions = array())`: if the cache file for `$filename` exists, contents will be
|
||||
returned, else, `NULL` will be returned.
|
||||
* `setPrefixSize($prefixSize)`: sets the prefix size for directories, default is 5. For instance, the
|
||||
cache file for `helloworld.txt`, will be `'h/e/l/l/o/helloworld.txt`.
|
||||
* `getOrCreate($filename, $conditions = array(), $function, $file = false)`: this will check if the `$filename`
|
||||
cache file exists and verifies `$conditions` (see below). If the cache file is OK, it will return its
|
||||
contents. Else, it will call the `$function`, passing it the target file, this function can write the
|
||||
file given in parameter or just return data. Then, cache data will be returned. If `$file` flag is set,
|
||||
the cache file name will be returned instead of file data.
|
||||
|
||||
Note: consider using an hash for the `$filename` cache file, to avoid special characters.
|
||||
|
||||
Conditions
|
||||
==========
|
||||
|
||||
You can use conditions to manage file expirations on the cache, there is two way of expiring:
|
||||
|
||||
* Using `max-age`, in seconds, to set the maximum age of the file
|
||||
* Using `younger-than`, by passing another file, this will compare the modification date
|
||||
and regenerate the cache if the given file is younger.
|
||||
|
||||
For instance, if you want to uppercase a file:
|
||||
|
||||
```php
|
||||
<?php
|
||||
|
||||
use Gregwar\Cache\Cache;
|
||||
|
||||
$cache = new Cache;
|
||||
|
||||
$data = $cache->getOrCreate('uppercase.txt',
|
||||
array(
|
||||
'younger-than' => 'original.txt'
|
||||
),
|
||||
function() {
|
||||
echo "Generating file...\n";
|
||||
return strtoupper(file_get_contents('original.txt'));
|
||||
});
|
||||
|
||||
echo $data;
|
||||
```
|
||||
|
||||
This will be create the `uppercase.txt` cache file by uppercasing the `original.txt` if the cache file
|
||||
does not exists or if the `original.txt` file is more recent than the cache file.
|
||||
|
||||
For instance:
|
||||
|
||||
```
|
||||
php uppercase.php # Will generate the cache file
|
||||
php uppercase.php # Will not generate the cache file
|
||||
touch original.txt # Sets the last modification time to now
|
||||
php uppercase.php # Will re-generate the cache file
|
||||
```
|
||||
|
||||
Cache directory and actual cache directory
|
||||
==========================================
|
||||
|
||||
In some cases, you'll want to get the cache file name. For instance, if you're caching
|
||||
images, you'll want to give a string like `cache/s/o/m/e/i/someimage.png` to put it into
|
||||
an `<img>` tag. This can be done by passing the `$file` argument to the `getOrCreate` to true,
|
||||
or directly using `getCacheFile` method (see above).
|
||||
|
||||
However, the visible `cache` directory of your users is not the same as the absolute path
|
||||
you want to access. To do that, you can set both the cache directory and the actual cache directory.
|
||||
|
||||
The cache directory is the prefix visible by the users (for instance: `cache/s/o/m/e/i/someimage.png`),
|
||||
and the actual cache directory is the prefix to use to actually access to the image (for instance:
|
||||
`/var/www/somesite/cache/s/o/m/e/i/someimage.png`). This way, the file will be accessed using absolute
|
||||
path and the cache file returned will directly be usable for your user's browsers.
|
||||
|
||||
License
|
||||
=======
|
||||
|
||||
This repository is under the MIT license, have a look at the `LICENCE` file.
|
||||
16
vendor/gregwar/cache/Gregwar/Cache/autoload.php
vendored
16
vendor/gregwar/cache/Gregwar/Cache/autoload.php
vendored
@@ -1,16 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Registers an autoload for all the classes in Gregwar\Cache
|
||||
*/
|
||||
spl_autoload_register(function ($className) {
|
||||
$namespace = 'Gregwar\\Cache';
|
||||
|
||||
if (strpos($className, $namespace) === 0) {
|
||||
$className = str_replace($namespace, '', $className);
|
||||
$fileName = __DIR__ . '/' . str_replace('\\', '/', $className) . '.php';
|
||||
if (file_exists($fileName)) {
|
||||
require($fileName);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -1,58 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Gregwar\Image\Adapter;
|
||||
|
||||
use Gregwar\Image\Source\Source;
|
||||
|
||||
/**
|
||||
* Base Adapter Implementation to handle Image information
|
||||
*/
|
||||
abstract class Adapter implements AdapterInterface
|
||||
{
|
||||
/**
|
||||
* @var Source
|
||||
*/
|
||||
protected $source;
|
||||
|
||||
/**
|
||||
* The image resource handler
|
||||
*/
|
||||
protected $resource;
|
||||
|
||||
public function __construct(){
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function setSource(Source $source)
|
||||
{
|
||||
$this->source = $source;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function getResource()
|
||||
{
|
||||
return $this->resource;
|
||||
}
|
||||
|
||||
/**
|
||||
* Does this adapter supports the given type ?
|
||||
*/
|
||||
protected function supports($type)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the image to true color
|
||||
*/
|
||||
protected function convertToTrueColor()
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,378 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Gregwar\Image\Adapter;
|
||||
|
||||
use Gregwar\Image\Image;
|
||||
use Gregwar\Image\Source\Source;
|
||||
|
||||
/**
|
||||
* all the functions / methods to work on images
|
||||
*
|
||||
* if changing anything please also add it to \Gregwar\Image\Image
|
||||
*
|
||||
* @author wodka <michael.schramm@gmail.com>
|
||||
*/
|
||||
interface AdapterInterface{
|
||||
/**
|
||||
* set the image source for the adapter
|
||||
*
|
||||
* @param Source $source
|
||||
* @return $this
|
||||
*/
|
||||
public function setSource(Source $source);
|
||||
|
||||
/**
|
||||
* get the raw resource
|
||||
*
|
||||
* @return resource
|
||||
*/
|
||||
public function getResource();
|
||||
|
||||
/**
|
||||
* Gets the name of the adapter
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName();
|
||||
|
||||
/**
|
||||
* Image width
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function width();
|
||||
|
||||
/**
|
||||
* Image height
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function height();
|
||||
|
||||
/**
|
||||
* Init the resource
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function init();
|
||||
|
||||
/**
|
||||
* Save the image as a gif
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function saveGif($file);
|
||||
|
||||
/**
|
||||
* Save the image as a png
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function savePng($file);
|
||||
|
||||
/**
|
||||
* Save the image as a jpeg
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function saveJpeg($file, $quality);
|
||||
|
||||
/**
|
||||
* Works as resize() excepts that the layout will be cropped
|
||||
*
|
||||
* @param int $width the width
|
||||
* @param int $height the height
|
||||
* @param int $background the background
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function cropResize($width = null, $height = null, $background=0xffffff);
|
||||
|
||||
|
||||
/**
|
||||
* Resize the image preserving scale. Can enlarge it.
|
||||
*
|
||||
* @param int $width the width
|
||||
* @param int $height the height
|
||||
* @param int $background the background
|
||||
* @param boolean $crop
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function scaleResize($width = null, $height = null, $background=0xffffff, $crop = false);
|
||||
|
||||
/**
|
||||
* Resizes the image. It will never be enlarged.
|
||||
*
|
||||
* @param int $width the width
|
||||
* @param int $height the height
|
||||
* @param int $background the background
|
||||
* @param boolean $force
|
||||
* @param boolean $rescale
|
||||
* @param boolean $crop
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function resize($width = null, $height = null, $background = 0xffffff, $force = false, $rescale = false, $crop = false);
|
||||
|
||||
/**
|
||||
* Crops the image
|
||||
*
|
||||
* @param int $x the top-left x position of the crop box
|
||||
* @param int $y the top-left y position of the crop box
|
||||
* @param int $width the width of the crop box
|
||||
* @param int $height the height of the crop box
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function crop($x, $y, $width, $height);
|
||||
|
||||
/**
|
||||
* enable progressive image loading
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function enableProgressive();
|
||||
|
||||
/**
|
||||
* Resizes the image forcing the destination to have exactly the
|
||||
* given width and the height
|
||||
*
|
||||
* @param int $width the width
|
||||
* @param int $height the height
|
||||
* @param int $background the background
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function forceResize($width = null, $height = null, $background = 0xffffff);
|
||||
|
||||
/**
|
||||
* Perform a zoom crop of the image to desired width and height
|
||||
*
|
||||
* @param integer $width Desired width
|
||||
* @param integer $height Desired height
|
||||
* @param int $background
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function zoomCrop($width, $height, $background = 0xffffff);
|
||||
|
||||
|
||||
/**
|
||||
* Fills the image background to $bg if the image is transparent
|
||||
*
|
||||
* @param int $background background color
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function fillBackground($background = 0xffffff);
|
||||
|
||||
|
||||
/**
|
||||
* Negates the image
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function negate();
|
||||
|
||||
/**
|
||||
* Changes the brightness of the image
|
||||
*
|
||||
* @param int $brightness the brightness
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function brightness($brightness);
|
||||
|
||||
/**
|
||||
* Contrasts the image
|
||||
*
|
||||
* @param int $contrast the contrast [-100, 100]
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function contrast($contrast);
|
||||
|
||||
/**
|
||||
* Apply a grayscale level effect on the image
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function grayscale();
|
||||
|
||||
/**
|
||||
* Emboss the image
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function emboss();
|
||||
|
||||
/**
|
||||
* Smooth the image
|
||||
*
|
||||
* @param int $p value between [-10,10]
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function smooth($p);
|
||||
|
||||
/**
|
||||
* Sharps the image
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function sharp();
|
||||
|
||||
/**
|
||||
* Edges the image
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function edge();
|
||||
|
||||
/**
|
||||
* Colorize the image
|
||||
*
|
||||
* @param int $red value in range [-255, 255]
|
||||
* @param int $green value in range [-255, 255]
|
||||
* @param int $blue value in range [-255, 255]
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function colorize($red, $green, $blue);
|
||||
|
||||
/**
|
||||
* apply sepia to the image
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function sepia();
|
||||
|
||||
/**
|
||||
* Merge with another image
|
||||
*
|
||||
* @param Image $other
|
||||
* @param int $x
|
||||
* @param int $y
|
||||
* @param int $width
|
||||
* @param int $height
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function merge(Image $other, $x = 0, $y = 0, $width = null, $height = null);
|
||||
|
||||
/**
|
||||
* Rotate the image
|
||||
*
|
||||
* @param float $angle
|
||||
* @param int $background
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function rotate($angle, $background = 0xffffff);
|
||||
|
||||
/**
|
||||
* Fills the image
|
||||
*
|
||||
* @param int $color
|
||||
* @param int $x
|
||||
* @param int $y
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function fill($color = 0xffffff, $x = 0, $y = 0);
|
||||
|
||||
/**
|
||||
* write text to the image
|
||||
*
|
||||
* @param string $font
|
||||
* @param string $text
|
||||
* @param int $x
|
||||
* @param int $y
|
||||
* @param int $size
|
||||
* @param int $angle
|
||||
* @param int $color
|
||||
* @param string $align
|
||||
*/
|
||||
public function write($font, $text, $x = 0, $y = 0, $size = 12, $angle = 0, $color = 0x000000, $align = 'left');
|
||||
|
||||
/**
|
||||
* Draws a rectangle
|
||||
*
|
||||
* @param int $x1
|
||||
* @param int $y1
|
||||
* @param int $x2
|
||||
* @param int $y2
|
||||
* @param int $color
|
||||
* @param bool $filled
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function rectangle($x1, $y1, $x2, $y2, $color, $filled = false);
|
||||
|
||||
/**
|
||||
* Draws a rounded rectangle
|
||||
*
|
||||
* @param int $x1
|
||||
* @param int $y1
|
||||
* @param int $x2
|
||||
* @param int $y2
|
||||
* @param int $radius
|
||||
* @param int $color
|
||||
* @param bool $filled
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function roundedRectangle($x1, $y1, $x2, $y2, $radius, $color, $filled = false);
|
||||
|
||||
/**
|
||||
* Draws a line
|
||||
*
|
||||
* @param int $x1
|
||||
* @param int $y1
|
||||
* @param int $x2
|
||||
* @param int $y2
|
||||
* @param int $color
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function line($x1, $y1, $x2, $y2, $color = 0x000000);
|
||||
|
||||
/**
|
||||
* Draws an ellipse
|
||||
*
|
||||
* @param int $cx
|
||||
* @param int $cy
|
||||
* @param int $width
|
||||
* @param int $height
|
||||
* @param int $color
|
||||
* @param bool $filled
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function ellipse($cx, $cy, $width, $height, $color = 0x000000, $filled = false);
|
||||
|
||||
/**
|
||||
* Draws a circle
|
||||
*
|
||||
* @param int $cx
|
||||
* @param int $cy
|
||||
* @param int $r
|
||||
* @param int $color
|
||||
* @param bool $filled
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function circle($cx, $cy, $r, $color = 0x000000, $filled = false);
|
||||
|
||||
/**
|
||||
* Draws a polygon
|
||||
*
|
||||
* @param array $points
|
||||
* @param int $color
|
||||
* @param bool $filled
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function polygon(array $points, $color, $filled = false);
|
||||
}
|
||||
@@ -1,275 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Gregwar\Image\Adapter;
|
||||
|
||||
abstract class Common extends Adapter
|
||||
{
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function zoomCrop($width, $height, $background = 'transparent')
|
||||
{
|
||||
// Calculate the different ratios
|
||||
$originalRatio = $this->width() / $this->height();
|
||||
$newRatio = $width / $height;
|
||||
|
||||
// Compare ratios
|
||||
if ($originalRatio > $newRatio) {
|
||||
// Original image is wider
|
||||
$newHeight = $height;
|
||||
$newWidth = (int) $height * $originalRatio;
|
||||
} else {
|
||||
// Equal width or smaller
|
||||
$newHeight = (int) $width / $originalRatio;
|
||||
$newWidth = $width;
|
||||
}
|
||||
|
||||
// Perform resize
|
||||
$this->resize($newWidth, $newHeight, $background, true);
|
||||
|
||||
// Calculate cropping area
|
||||
$xPos = (int) ($newWidth - $width) / 2;
|
||||
$yPos = (int) ($newHeight - $height) / 2;
|
||||
|
||||
// Crop image to reach desired size
|
||||
$this->crop($xPos, $yPos, $width, $height);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resizes the image forcing the destination to have exactly the
|
||||
* given width and the height
|
||||
*
|
||||
* @param int $w the width
|
||||
* @param int $h the height
|
||||
* @param int $bg the background
|
||||
*/
|
||||
public function forceResize($width = null, $height = null, $background = 'transparent')
|
||||
{
|
||||
return $this->resize($width, $height, $background, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function scaleResize($width = null, $height = null, $background='transparent', $crop = false)
|
||||
{
|
||||
return $this->resize($width, $height, $background, false, true, $crop);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function cropResize($width = null, $height = null, $background='transparent')
|
||||
{
|
||||
return $this->resize($width, $height, $background, false, false, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens the image
|
||||
*/
|
||||
abstract protected function openGif($file);
|
||||
abstract protected function openJpeg($file);
|
||||
abstract protected function openPng($file);
|
||||
|
||||
/**
|
||||
* Creates an image
|
||||
*/
|
||||
abstract protected function createImage($width, $height);
|
||||
|
||||
/**
|
||||
* Creating an image using $data
|
||||
*/
|
||||
abstract protected function createImageFromData($data);
|
||||
|
||||
/**
|
||||
* Loading image from $resource
|
||||
*/
|
||||
protected function loadResource($resource)
|
||||
{
|
||||
$this->resource = $resource;
|
||||
}
|
||||
|
||||
protected function loadFile($file, $type)
|
||||
{
|
||||
if (!$this->supports($type)) {
|
||||
throw new \RuntimeException('Type '.$type.' is not supported by GD');
|
||||
}
|
||||
|
||||
if ($type == 'jpeg') {
|
||||
$this->openJpeg($file);
|
||||
}
|
||||
|
||||
if ($type == 'gif') {
|
||||
$this->openGif($file);
|
||||
}
|
||||
|
||||
if ($type == 'png') {
|
||||
$this->openPng($file);
|
||||
}
|
||||
|
||||
if (false === $this->resource) {
|
||||
throw new \UnexpectedValueException('Unable to open file ('.$file.')');
|
||||
} else {
|
||||
$this->convertToTrueColor();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function init()
|
||||
{
|
||||
$source = $this->source;
|
||||
|
||||
if ($source instanceof \Gregwar\Image\Source\File) {
|
||||
$this->loadFile($source->getFile(), $source->guessType());
|
||||
} else if ($source instanceof \Gregwar\Image\Source\Create) {
|
||||
$this->createImage($source->getWidth(), $source->getHeight());
|
||||
} else if ($source instanceof \Gregwar\Image\Source\Data) {
|
||||
$this->createImageFromData($source->getData());
|
||||
} else if ($source instanceof \Gregwar\Image\Source\Resource) {
|
||||
$this->loadResource($source->getResource());
|
||||
} else {
|
||||
throw new \Exception('Unsupported image source type '.get_class($source));
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function resize($width = null, $height = null, $background = 'transparent', $force = false, $rescale = false, $crop = false)
|
||||
{
|
||||
$current_width = $this->width();
|
||||
$current_height = $this->height();
|
||||
$new_width = 0;
|
||||
$new_height = 0;
|
||||
$scale = 1.0;
|
||||
|
||||
if ($height === null && preg_match('#^(.+)%$#mUsi', $width, $matches)) {
|
||||
$width = round($current_width * ((float)$matches[1]/100.0));
|
||||
$height = round($current_height * ((float)$matches[1]/100.0));
|
||||
}
|
||||
|
||||
if (!$rescale && (!$force || $crop)) {
|
||||
if ($width!=null && $current_width>$width) {
|
||||
$scale = $current_width/$width;
|
||||
}
|
||||
|
||||
if ($height!=null && $current_height>$height) {
|
||||
if ($current_height/$height > $scale)
|
||||
$scale = $current_height/$height;
|
||||
}
|
||||
} else {
|
||||
if ($width!=null) {
|
||||
$scale = $current_width/$width;
|
||||
$new_width = $width;
|
||||
}
|
||||
|
||||
if ($height!=null) {
|
||||
if ($width!=null && $rescale) {
|
||||
$scale = max($scale,$current_height/$height);
|
||||
} else {
|
||||
$scale = $current_height/$height;
|
||||
}
|
||||
$new_height = $height;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$force || $width==null || $rescale) {
|
||||
$new_width = round($current_width/$scale);
|
||||
}
|
||||
|
||||
if (!$force || $height==null || $rescale) {
|
||||
$new_height = round($current_height/$scale);
|
||||
}
|
||||
|
||||
if ($width == null || $crop) {
|
||||
$width = $new_width;
|
||||
}
|
||||
|
||||
if ($height == null || $crop) {
|
||||
$height = $new_height;
|
||||
}
|
||||
|
||||
$this->doResize($background, $width, $height, $new_width, $new_height);
|
||||
}
|
||||
|
||||
/**
|
||||
* Trim background color arround the image
|
||||
*
|
||||
* @param int $bg the background
|
||||
*/
|
||||
protected function _trimColor($background='transparent')
|
||||
{
|
||||
$width = $this->width();
|
||||
$height = $this->height();
|
||||
|
||||
$b_top = 0;
|
||||
$b_lft = 0;
|
||||
$b_btm = $height - 1;
|
||||
$b_rt = $width - 1;
|
||||
|
||||
//top
|
||||
for(; $b_top < $height; ++$b_top) {
|
||||
for($x = 0; $x < $width; ++$x) {
|
||||
if ($this->getColor($x, $b_top) != $background) {
|
||||
break 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// bottom
|
||||
for(; $b_btm >= 0; --$b_btm) {
|
||||
for($x = 0; $x < $width; ++$x) {
|
||||
if ($this->getColor($x, $b_btm) != $background) {
|
||||
break 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// left
|
||||
for(; $b_lft < $width; ++$b_lft) {
|
||||
for($y = $b_top; $y <= $b_btm; ++$y) {
|
||||
if ($this->getColor($b_lft, $y) != $background) {
|
||||
break 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// right
|
||||
for(; $b_rt >= 0; --$b_rt) {
|
||||
for($y = $b_top; $y <= $b_btm; ++$y) {
|
||||
if ($this->getColor($b_rt, $y) != $background) {
|
||||
break 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$b_btm++;
|
||||
$b_rt++;
|
||||
|
||||
$this->crop($b_lft, $b_top, $b_rt - $b_lft, $b_btm - $b_top);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resizes the image to an image having size of $target_width, $target_height, using
|
||||
* $new_width and $new_height and padding with $bg color
|
||||
*/
|
||||
abstract protected function doResize($bg, $target_width, $target_height, $new_width, $new_height);
|
||||
|
||||
/**
|
||||
* Gets the color of the $x, $y pixel
|
||||
*/
|
||||
abstract protected function getColor($x, $y);
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function enableProgressive(){
|
||||
throw new \Exception('The Adapter '.$this->getName().' does not support Progressive Image loading');
|
||||
}
|
||||
}
|
||||
516
vendor/gregwar/image/Gregwar/Image/Adapter/GD.php
vendored
516
vendor/gregwar/image/Gregwar/Image/Adapter/GD.php
vendored
@@ -1,516 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Gregwar\Image\Adapter;
|
||||
|
||||
use Gregwar\Image\ImageColor;
|
||||
use Gregwar\Image\Image;
|
||||
|
||||
class GD extends Common
|
||||
{
|
||||
public static $gdTypes = array(
|
||||
'jpeg' => \IMG_JPG,
|
||||
'gif' => \IMG_GIF,
|
||||
'png' => \IMG_PNG,
|
||||
);
|
||||
|
||||
protected function loadResource($resource)
|
||||
{
|
||||
parent::loadResource($resource);
|
||||
imagesavealpha($this->resource, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the width and the height for writing some text
|
||||
*/
|
||||
public static function TTFBox($font, $text, $size, $angle = 0)
|
||||
{
|
||||
$box = imagettfbbox($size, $angle, $font, $text);
|
||||
|
||||
return array(
|
||||
'width' => abs($box[2] - $box[0]),
|
||||
'height' => abs($box[3] - $box[5])
|
||||
);
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
if (!(extension_loaded('gd') && function_exists('gd_info'))) {
|
||||
throw new \RuntimeException('You need to install GD PHP Extension to use this library');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return 'GD';
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function fillBackground($background = 0xffffff)
|
||||
{
|
||||
$w = $this->width();
|
||||
$h = $this->height();
|
||||
$n = imagecreatetruecolor($w, $h);
|
||||
imagefill($n, 0, 0, ImageColor::gdAllocate($this->resource, $background));
|
||||
imagecopyresampled($n, $this->resource, 0, 0, 0, 0, $w, $h, $w, $h);
|
||||
imagedestroy($this->resource);
|
||||
$this->resource = $n;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Do the image resize
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
protected function doResize($bg, $target_width, $target_height, $new_width, $new_height)
|
||||
{
|
||||
$width = $this->width();
|
||||
$height = $this->height();
|
||||
$n = imagecreatetruecolor($target_width, $target_height);
|
||||
|
||||
if ($bg != 'transparent') {
|
||||
imagefill($n, 0, 0, ImageColor::gdAllocate($this->resource, $bg));
|
||||
} else {
|
||||
imagealphablending($n, false);
|
||||
$color = ImageColor::gdAllocate($this->resource, 'transparent');
|
||||
|
||||
imagefill($n, 0, 0, $color);
|
||||
imagesavealpha($n, true);
|
||||
}
|
||||
|
||||
imagecopyresampled($n, $this->resource, ($target_width-$new_width)/2, ($target_height-$new_height)/2, 0, 0, $new_width, $new_height, $width, $height);
|
||||
imagedestroy($this->resource);
|
||||
|
||||
$this->resource = $n;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function crop($x, $y, $width, $height)
|
||||
{
|
||||
$destination = imagecreatetruecolor($width, $height);
|
||||
imagealphablending($destination, false);
|
||||
imagesavealpha($destination, true);
|
||||
imagecopy($destination, $this->resource, 0, 0, $x, $y, $this->width(), $this->height());
|
||||
imagedestroy($this->resource);
|
||||
$this->resource = $destination;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function negate()
|
||||
{
|
||||
imagefilter($this->resource, IMG_FILTER_NEGATE);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function brightness($brightness)
|
||||
{
|
||||
imagefilter($this->resource, IMG_FILTER_BRIGHTNESS, $brightness);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function contrast($contrast)
|
||||
{
|
||||
imagefilter($this->resource, IMG_FILTER_CONTRAST, $contrast);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function grayscale()
|
||||
{
|
||||
imagefilter($this->resource, IMG_FILTER_GRAYSCALE);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function emboss()
|
||||
{
|
||||
imagefilter($this->resource, IMG_FILTER_EMBOSS);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function smooth($p)
|
||||
{
|
||||
imagefilter($this->resource, IMG_FILTER_SMOOTH, $p);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function sharp()
|
||||
{
|
||||
imagefilter($this->resource, IMG_FILTER_MEAN_REMOVAL);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function edge()
|
||||
{
|
||||
imagefilter($this->resource, IMG_FILTER_EDGEDETECT);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function colorize($red, $green, $blue)
|
||||
{
|
||||
imagefilter($this->resource, IMG_FILTER_COLORIZE, $red, $green, $blue);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function sepia()
|
||||
{
|
||||
imagefilter($this->resource, IMG_FILTER_GRAYSCALE);
|
||||
imagefilter($this->resource, IMG_FILTER_COLORIZE, 100, 50, 0);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function merge(Image $other, $x = 0, $y = 0, $width = null, $height = null)
|
||||
{
|
||||
$other = clone $other;
|
||||
$other->init();
|
||||
$other->applyOperations();
|
||||
|
||||
imagealphablending($this->resource, true);
|
||||
|
||||
if (null == $width) {
|
||||
$width = $other->width();
|
||||
}
|
||||
|
||||
if (null == $height) {
|
||||
$height = $other->height();
|
||||
}
|
||||
|
||||
imagecopyresampled($this->resource, $other->getAdapter()->getResource(), $x, $y, 0, 0, $width, $height, $width, $height);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function rotate($angle, $background = 0xffffff)
|
||||
{
|
||||
$this->resource = imagerotate($this->resource, $angle, ImageColor::gdAllocate($this->resource, $background));
|
||||
imagealphablending($this->resource, true);
|
||||
imagesavealpha($this->resource, true);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function fill($color = 0xffffff, $x = 0, $y = 0)
|
||||
{
|
||||
imagealphablending($this->resource, false);
|
||||
imagefill($this->resource, $x, $y, ImageColor::gdAllocate($this->resource, $color));
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function write($font, $text, $x = 0, $y = 0, $size = 12, $angle = 0, $color = 0x000000, $align = 'left')
|
||||
{
|
||||
imagealphablending($this->resource, true);
|
||||
|
||||
if ($align != 'left') {
|
||||
$sim_size = self::TTFBox($font, $text, $size, $angle);
|
||||
|
||||
if ($align == 'center') {
|
||||
$x -= $sim_size['width'] / 2;
|
||||
}
|
||||
|
||||
if ($align == 'right') {
|
||||
$x -= $sim_size['width'];
|
||||
}
|
||||
}
|
||||
|
||||
imagettftext($this->resource, $size, $angle, $x, $y, ImageColor::gdAllocate($this->resource, $color), $font, $text);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function rectangle($x1, $y1, $x2, $y2, $color, $filled = false)
|
||||
{
|
||||
if ($filled) {
|
||||
imagefilledrectangle($this->resource, $x1, $y1, $x2, $y2, ImageColor::gdAllocate($this->resource, $color));
|
||||
} else {
|
||||
imagerectangle($this->resource, $x1, $y1, $x2, $y2, ImageColor::gdAllocate($this->resource, $color));
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function roundedRectangle($x1, $y1, $x2, $y2, $radius, $color, $filled = false) {
|
||||
if ($color) {
|
||||
$color = ImageColor::gdAllocate($this->resource, $color);
|
||||
}
|
||||
|
||||
if ($filled == true) {
|
||||
imagefilledrectangle($this->resource, $x1+$radius, $y1, $x2-$radius, $y2, $color);
|
||||
imagefilledrectangle($this->resource, $x1, $y1+$radius, $x1+$radius-1, $y2-$radius, $color);
|
||||
imagefilledrectangle($this->resource, $x2-$radius+1, $y1+$radius, $x2, $y2-$radius, $color);
|
||||
|
||||
imagefilledarc($this->resource,$x1+$radius, $y1+$radius, $radius*2, $radius*2, 180 , 270, $color, IMG_ARC_PIE);
|
||||
imagefilledarc($this->resource,$x2-$radius, $y1+$radius, $radius*2, $radius*2, 270 , 360, $color, IMG_ARC_PIE);
|
||||
imagefilledarc($this->resource,$x1+$radius, $y2-$radius, $radius*2, $radius*2, 90 , 180, $color, IMG_ARC_PIE);
|
||||
imagefilledarc($this->resource,$x2-$radius, $y2-$radius, $radius*2, $radius*2, 360 , 90, $color, IMG_ARC_PIE);
|
||||
} else {
|
||||
imageline($this->resource, $x1+$radius, $y1, $x2-$radius, $y1, $color);
|
||||
imageline($this->resource, $x1+$radius, $y2, $x2-$radius, $y2, $color);
|
||||
imageline($this->resource, $x1, $y1+$radius, $x1, $y2-$radius, $color);
|
||||
imageline($this->resource, $x2, $y1+$radius, $x2, $y2-$radius, $color);
|
||||
|
||||
imagearc($this->resource,$x1+$radius, $y1+$radius, $radius*2, $radius*2, 180 , 270, $color);
|
||||
imagearc($this->resource,$x2-$radius, $y1+$radius, $radius*2, $radius*2, 270 , 360, $color);
|
||||
imagearc($this->resource,$x1+$radius, $y2-$radius, $radius*2, $radius*2, 90 , 180, $color);
|
||||
imagearc($this->resource,$x2-$radius, $y2-$radius, $radius*2, $radius*2, 360 , 90, $color);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function line($x1, $y1, $x2, $y2, $color = 0x000000)
|
||||
{
|
||||
imageline($this->resource, $x1, $y1, $x2, $y2, ImageColor::gdAllocate($this->resource, $color));
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function ellipse($cx, $cy, $width, $height, $color = 0x000000, $filled = false)
|
||||
{
|
||||
if ($filled) {
|
||||
imagefilledellipse($this->resource, $cx, $cy, $width, $height, ImageColor::gdAllocate($this->resource, $color));
|
||||
} else {
|
||||
imageellipse($this->resource, $cx, $cy, $width, $height, ImageColor::gdAllocate($this->resource, $color));
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function circle($cx, $cy, $r, $color = 0x000000, $filled = false)
|
||||
{
|
||||
return $this->ellipse($cx, $cy, $r, $r, ImageColor::gdAllocate($this->resource, $color), $filled);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function polygon(array $points, $color, $filled = false)
|
||||
{
|
||||
if ($filled) {
|
||||
imagefilledpolygon($this->resource, $points, count($points)/2, ImageColor::gdAllocate($this->resource, $color));
|
||||
} else {
|
||||
imagepolygon($this->resource, $points, count($points)/2, ImageColor::gdAllocate($this->resource, $color));
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function width()
|
||||
{
|
||||
if (null === $this->resource) {
|
||||
$this->init();
|
||||
}
|
||||
|
||||
return imagesx($this->resource);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function height()
|
||||
{
|
||||
if (null === $this->resource) {
|
||||
$this->init();
|
||||
}
|
||||
|
||||
return imagesy($this->resource);
|
||||
}
|
||||
|
||||
protected function createImage($width, $height)
|
||||
{
|
||||
$this->resource = imagecreatetruecolor($width, $height);
|
||||
}
|
||||
|
||||
protected function createImageFromData($data)
|
||||
{
|
||||
$this->resource = @imagecreatefromstring($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the image to true color
|
||||
*/
|
||||
protected function convertToTrueColor()
|
||||
{
|
||||
if (!imageistruecolor($this->resource)) {
|
||||
if (function_exists('imagepalettetotruecolor')) {
|
||||
// Available in PHP 5.5
|
||||
imagepalettetotruecolor($this->resource);
|
||||
} else {
|
||||
$transparentIndex = imagecolortransparent($this->resource);
|
||||
|
||||
$w = $this->width();
|
||||
$h = $this->height();
|
||||
|
||||
$img = imagecreatetruecolor($w, $h);
|
||||
imagecopy($img, $this->resource, 0, 0, 0, 0, $w, $h);
|
||||
|
||||
if ($transparentIndex != -1) {
|
||||
$width = $this->width();
|
||||
$height = $this->height();
|
||||
|
||||
imagealphablending($img, false);
|
||||
imagesavealpha($img, true);
|
||||
|
||||
for ($x=0; $x<$width; $x++) {
|
||||
for ($y=0; $y<$height; $y++) {
|
||||
if (imagecolorat($this->resource, $x, $y) == $transparentIndex) {
|
||||
imagesetpixel($img, $x, $y, 127 << 24);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->resource = $img;
|
||||
}
|
||||
}
|
||||
|
||||
imagesavealpha($this->resource, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function saveGif($file)
|
||||
{
|
||||
$transColor = imagecolorallocatealpha($this->resource, 255, 255, 255, 127);
|
||||
imagecolortransparent($this->resource, $transColor);
|
||||
imagegif($this->resource, $file);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function savePng($file)
|
||||
{
|
||||
imagepng($this->resource, $file);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function saveJpeg($file, $quality)
|
||||
{
|
||||
imagejpeg($this->resource, $file, $quality);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Try to open the file using jpeg
|
||||
*
|
||||
*/
|
||||
protected function openJpeg($file)
|
||||
{
|
||||
$this->resource = @imagecreatefromjpeg($file);
|
||||
}
|
||||
|
||||
/**
|
||||
* Try to open the file using gif
|
||||
*/
|
||||
protected function openGif($file)
|
||||
{
|
||||
$this->resource = @imagecreatefromgif($file);
|
||||
}
|
||||
|
||||
/**
|
||||
* Try to open the file using PNG
|
||||
*/
|
||||
protected function openPng($file)
|
||||
{
|
||||
$this->resource = @imagecreatefrompng($file);
|
||||
}
|
||||
|
||||
/**
|
||||
* Does this adapter supports type ?
|
||||
*/
|
||||
protected function supports($type)
|
||||
{
|
||||
return (imagetypes() & self::$gdTypes[$type]);
|
||||
}
|
||||
|
||||
protected function getColor($x, $y)
|
||||
{
|
||||
return imagecolorat($this->resource, $x, $y);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function enableProgressive(){
|
||||
imageinterlace($this->resource, 1);
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -1,382 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Gregwar\Image\Adapter;
|
||||
|
||||
use Gregwar\Image\Image;
|
||||
|
||||
class Imagick extends Common{
|
||||
public function __construct(){
|
||||
throw new \Exception('Imagick is not supported right now');
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the name of the adapter
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName(){
|
||||
return 'ImageMagick';
|
||||
}
|
||||
|
||||
/**
|
||||
* Image width
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function width(){
|
||||
// TODO: Implement width() method.
|
||||
}
|
||||
|
||||
/**
|
||||
* Image height
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function height(){
|
||||
// TODO: Implement height() method.
|
||||
}
|
||||
|
||||
/**
|
||||
* Save the image as a gif
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function saveGif($file){
|
||||
// TODO: Implement saveGif() method.
|
||||
}
|
||||
|
||||
/**
|
||||
* Save the image as a png
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function savePng($file){
|
||||
// TODO: Implement savePng() method.
|
||||
}
|
||||
|
||||
/**
|
||||
* Save the image as a jpeg
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function saveJpeg($file, $quality){
|
||||
// TODO: Implement saveJpeg() method.
|
||||
}
|
||||
|
||||
/**
|
||||
* Crops the image
|
||||
*
|
||||
* @param int $x the top-left x position of the crop box
|
||||
* @param int $y the top-left y position of the crop box
|
||||
* @param int $width the width of the crop box
|
||||
* @param int $height the height of the crop box
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function crop($x, $y, $width, $height){
|
||||
// TODO: Implement crop() method.
|
||||
}
|
||||
|
||||
/**
|
||||
* Fills the image background to $bg if the image is transparent
|
||||
*
|
||||
* @param int $background background color
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function fillBackground($background = 0xffffff){
|
||||
// TODO: Implement fillBackground() method.
|
||||
}
|
||||
|
||||
/**
|
||||
* Negates the image
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function negate(){
|
||||
// TODO: Implement negate() method.
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes the brightness of the image
|
||||
*
|
||||
* @param int $brightness the brightness
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function brightness($brightness){
|
||||
// TODO: Implement brightness() method.
|
||||
}
|
||||
|
||||
/**
|
||||
* Contrasts the image
|
||||
*
|
||||
* @param int $contrast the contrast [-100, 100]
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function contrast($contrast){
|
||||
// TODO: Implement contrast() method.
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply a grayscale level effect on the image
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function grayscale(){
|
||||
// TODO: Implement grayscale() method.
|
||||
}
|
||||
|
||||
/**
|
||||
* Emboss the image
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function emboss(){
|
||||
// TODO: Implement emboss() method.
|
||||
}
|
||||
|
||||
/**
|
||||
* Smooth the image
|
||||
*
|
||||
* @param int $p value between [-10,10]
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function smooth($p){
|
||||
// TODO: Implement smooth() method.
|
||||
}
|
||||
|
||||
/**
|
||||
* Sharps the image
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function sharp(){
|
||||
// TODO: Implement sharp() method.
|
||||
}
|
||||
|
||||
/**
|
||||
* Edges the image
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function edge(){
|
||||
// TODO: Implement edge() method.
|
||||
}
|
||||
|
||||
/**
|
||||
* Colorize the image
|
||||
*
|
||||
* @param int $red value in range [-255, 255]
|
||||
* @param int $green value in range [-255, 255]
|
||||
* @param int $blue value in range [-255, 255]
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function colorize($red, $green, $blue){
|
||||
// TODO: Implement colorize() method.
|
||||
}
|
||||
|
||||
/**
|
||||
* apply sepia to the image
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function sepia(){
|
||||
// TODO: Implement sepia() method.
|
||||
}
|
||||
|
||||
/**
|
||||
* Merge with another image
|
||||
*
|
||||
* @param Image $other
|
||||
* @param int $x
|
||||
* @param int $y
|
||||
* @param int $width
|
||||
* @param int $height
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function merge(Image $other, $x = 0, $y = 0, $width = null, $height = null){
|
||||
// TODO: Implement merge() method.
|
||||
}
|
||||
|
||||
/**
|
||||
* Rotate the image
|
||||
*
|
||||
* @param float $angle
|
||||
* @param int $background
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function rotate($angle, $background = 0xffffff){
|
||||
// TODO: Implement rotate() method.
|
||||
}
|
||||
|
||||
/**
|
||||
* Fills the image
|
||||
*
|
||||
* @param int $color
|
||||
* @param int $x
|
||||
* @param int $y
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function fill($color = 0xffffff, $x = 0, $y = 0){
|
||||
// TODO: Implement fill() method.
|
||||
}
|
||||
|
||||
/**
|
||||
* write text to the image
|
||||
*
|
||||
* @param string $font
|
||||
* @param string $text
|
||||
* @param int $x
|
||||
* @param int $y
|
||||
* @param int $size
|
||||
* @param int $angle
|
||||
* @param int $color
|
||||
* @param string $align
|
||||
*/
|
||||
public function write($font, $text, $x = 0, $y = 0, $size = 12, $angle = 0, $color = 0x000000, $align = 'left'){
|
||||
// TODO: Implement write() method.
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws a rectangle
|
||||
*
|
||||
* @param int $x1
|
||||
* @param int $y1
|
||||
* @param int $x2
|
||||
* @param int $y2
|
||||
* @param int $color
|
||||
* @param bool $filled
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function rectangle($x1, $y1, $x2, $y2, $color, $filled = false){
|
||||
// TODO: Implement rectangle() method.
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws a rounded rectangle
|
||||
*
|
||||
* @param int $x1
|
||||
* @param int $y1
|
||||
* @param int $x2
|
||||
* @param int $y2
|
||||
* @param int $radius
|
||||
* @param int $color
|
||||
* @param bool $filled
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function roundedRectangle($x1, $y1, $x2, $y2, $radius, $color, $filled = false){
|
||||
// TODO: Implement roundedRectangle() method.
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws a line
|
||||
*
|
||||
* @param int $x1
|
||||
* @param int $y1
|
||||
* @param int $x2
|
||||
* @param int $y2
|
||||
* @param int $color
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function line($x1, $y1, $x2, $y2, $color = 0x000000){
|
||||
// TODO: Implement line() method.
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws an ellipse
|
||||
*
|
||||
* @param int $cx
|
||||
* @param int $cy
|
||||
* @param int $width
|
||||
* @param int $height
|
||||
* @param int $color
|
||||
* @param bool $filled
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function ellipse($cx, $cy, $width, $height, $color = 0x000000, $filled = false){
|
||||
// TODO: Implement ellipse() method.
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws a circle
|
||||
*
|
||||
* @param int $cx
|
||||
* @param int $cy
|
||||
* @param int $r
|
||||
* @param int $color
|
||||
* @param bool $filled
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function circle($cx, $cy, $r, $color = 0x000000, $filled = false){
|
||||
// TODO: Implement circle() method.
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws a polygon
|
||||
*
|
||||
* @param array $points
|
||||
* @param int $color
|
||||
* @param bool $filled
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function polygon(array $points, $color, $filled = false){
|
||||
// TODO: Implement polygon() method.
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens the image
|
||||
*/
|
||||
protected function openGif($file){
|
||||
// TODO: Implement openGif() method.
|
||||
}
|
||||
|
||||
protected function openJpeg($file){
|
||||
// TODO: Implement openJpeg() method.
|
||||
}
|
||||
|
||||
protected function openPng($file){
|
||||
// TODO: Implement openPng() method.
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an image
|
||||
*/
|
||||
protected function createImage($width, $height){
|
||||
// TODO: Implement createImage() method.
|
||||
}
|
||||
|
||||
/**
|
||||
* Creating an image using $data
|
||||
*/
|
||||
protected function createImageFromData($data){
|
||||
// TODO: Implement createImageFromData() method.
|
||||
}
|
||||
|
||||
/**
|
||||
* Resizes the image to an image having size of $target_width, $target_height, using
|
||||
* $new_width and $new_height and padding with $bg color
|
||||
*/
|
||||
protected function doResize($bg, $target_width, $target_height, $new_width, $new_height){
|
||||
// TODO: Implement doResize() method.
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the color of the $x, $y pixel
|
||||
*/
|
||||
protected function getColor($x, $y){
|
||||
// TODO: Implement getColor() method.
|
||||
}
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Gregwar\Image\Exceptions;
|
||||
|
||||
class GenerationError extends \Exception
|
||||
{
|
||||
public function __construct($newNewFile)
|
||||
{
|
||||
$this->newNewFile = $newNewFile;
|
||||
}
|
||||
|
||||
public function getNewFile()
|
||||
{
|
||||
return $this->newNewFile;
|
||||
}
|
||||
}
|
||||
@@ -1,83 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Gregwar\Image;
|
||||
|
||||
/**
|
||||
* Garbage collect a directory, this will crawl a directory, lookng
|
||||
* for files older than X days and destroy them
|
||||
*
|
||||
* @author Gregwar <g.passault@gmail.com>
|
||||
*/
|
||||
class GarbageCollect
|
||||
{
|
||||
/**
|
||||
* Drops old files of a directory
|
||||
*
|
||||
* @param string $directory the name of the target directory
|
||||
* @param int $days the number of days to consider a file old
|
||||
* @param bool $verbose enable verbose output
|
||||
*
|
||||
* @return true if all the files/directories of a directory was wiped
|
||||
*/
|
||||
public static function dropOldFiles($directory, $days = 30, $verbose = false)
|
||||
{
|
||||
$allDropped = true;
|
||||
$now = time();
|
||||
|
||||
$dir = opendir($directory);
|
||||
|
||||
if (!$dir) {
|
||||
if ($verbose) {
|
||||
echo "! Unable to open $directory\n";
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
while ($file = readdir($dir)) {
|
||||
if ($file == '.' || $file == '..') {
|
||||
continue;
|
||||
}
|
||||
|
||||
$fullName = $directory.'/'.$file;
|
||||
|
||||
$old = $now-filemtime($fullName);
|
||||
|
||||
if (is_dir($fullName)) {
|
||||
// Directories are recursively crawled
|
||||
if (static::dropOldFiles($fullName, $days, $verbose)) {
|
||||
self::drop($fullName, $verbose);
|
||||
} else {
|
||||
$allDropped = false;
|
||||
}
|
||||
} else {
|
||||
if ($old > (24*60*60*$days)) {
|
||||
self::drop($fullName, $verbose);
|
||||
} else {
|
||||
$allDropped = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
closedir($dir);
|
||||
|
||||
return $allDropped;
|
||||
}
|
||||
|
||||
/**
|
||||
* Drops a file or an empty directory
|
||||
*/
|
||||
public static function drop($file, $verbose = false)
|
||||
{
|
||||
if (is_dir($file)) {
|
||||
@rmdir($file);
|
||||
} else {
|
||||
@unlink($file);
|
||||
}
|
||||
|
||||
if ($verbose) {
|
||||
echo "> Dropping $file...\n";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
717
vendor/gregwar/image/Gregwar/Image/Image.php
vendored
717
vendor/gregwar/image/Gregwar/Image/Image.php
vendored
@@ -1,717 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Gregwar\Image;
|
||||
|
||||
use Gregwar\Image\Adapter\AdapterInterface;
|
||||
use Gregwar\Image\Exceptions\GenerationError;
|
||||
|
||||
/**
|
||||
* Images handling class
|
||||
*
|
||||
* @author Gregwar <g.passault@gmail.com>
|
||||
*
|
||||
* @method Image saveGif($file)
|
||||
* @method Image savePng($file)
|
||||
* @method Image saveJpeg($file, $quality)
|
||||
* @method Image cropResize($width = null, $height = null, $background=0xffffff)
|
||||
* @method Image scale($width = null, $height = null, $background=0xffffff, $crop = false)
|
||||
* @method Image ($width = null, $height = null, $background = 0xffffff, $force = false, $rescale = false, $crop = false)
|
||||
* @method Image crop($x, $y, $width, $height)
|
||||
* @method Image enableProgressive()
|
||||
* @method Image force($width = null, $height = null, $background = 0xffffff)
|
||||
* @method Image zoomCrop($width, $height, $background = 0xffffff)
|
||||
* @method Image fillBackground($background = 0xffffff)
|
||||
* @method Image negate()
|
||||
* @method Image brightness($brightness)
|
||||
* @method Image contrast($contrast)
|
||||
* @method Image grayscale()
|
||||
* @method Image emboss()
|
||||
* @method Image smooth($p)
|
||||
* @method Image sharp()
|
||||
* @method Image edge()
|
||||
* @method Image colorize($red, $green, $blue)
|
||||
* @method Image sepia()
|
||||
* @method Image merge(Image $other, $x = 0, $y = 0, $width = null, $height = null)
|
||||
* @method Image rotate($angle, $background = 0xffffff)
|
||||
* @method Image fill($color = 0xffffff, $x = 0, $y = 0)
|
||||
* @method Image write($font, $text, $x = 0, $y = 0, $size = 12, $angle = 0, $color = 0x000000, $align = 'left')
|
||||
* @method Image rectangle($x1, $y1, $x2, $y2, $color, $filled = false)
|
||||
* @method Image roundedRectangle($x1, $y1, $x2, $y2, $radius, $color, $filled = false)
|
||||
* @method Image line($x1, $y1, $x2, $y2, $color = 0x000000)
|
||||
* @method Image ellipse($cx, $cy, $width, $height, $color = 0x000000, $filled = false)
|
||||
* @method Image circle($cx, $cy, $r, $color = 0x000000, $filled = false)
|
||||
* @method Image polygon(array $points, $color, $filled = false)
|
||||
*/
|
||||
class Image
|
||||
{
|
||||
/**
|
||||
* Direcory to use for file caching
|
||||
*/
|
||||
protected $cacheDir = 'cache/images';
|
||||
|
||||
/**
|
||||
* Internal adapter
|
||||
*
|
||||
* @var AdapterInterface
|
||||
*/
|
||||
protected $adapter = null;
|
||||
|
||||
/**
|
||||
* Pretty name for the image
|
||||
*/
|
||||
protected $prettyName = '';
|
||||
protected $prettyPrefix;
|
||||
|
||||
/**
|
||||
* Transformations hash
|
||||
*/
|
||||
protected $hash = null;
|
||||
|
||||
/**
|
||||
* The image source
|
||||
*/
|
||||
protected $source = null;
|
||||
|
||||
/**
|
||||
* Force image caching, even if there is no operation applied
|
||||
*/
|
||||
protected $forceCache = true;
|
||||
|
||||
/**
|
||||
* Supported types
|
||||
*/
|
||||
public static $types = array(
|
||||
'jpg' => 'jpeg',
|
||||
'jpeg' => 'jpeg',
|
||||
'png' => 'png',
|
||||
'gif' => 'gif',
|
||||
);
|
||||
|
||||
/**
|
||||
* Fallback image
|
||||
*/
|
||||
protected $fallback;
|
||||
|
||||
/**
|
||||
* Use fallback image
|
||||
*/
|
||||
protected $useFallbackImage = true;
|
||||
|
||||
/**
|
||||
* Cache system
|
||||
*/
|
||||
protected $cache;
|
||||
|
||||
/**
|
||||
* Change the caching directory
|
||||
*/
|
||||
public function setCacheDir($cacheDir)
|
||||
{
|
||||
$this->cache->setCacheDirectory($cacheDir);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable or disable to force cache even if the file is unchanged
|
||||
*/
|
||||
public function setForceCache($forceCache = true)
|
||||
{
|
||||
$this->forceCache = $forceCache;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* The actual cache dir
|
||||
*/
|
||||
public function setActualCacheDir($actualCacheDir)
|
||||
{
|
||||
$this->cache->setActualCacheDirectory($actualCacheDir);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the pretty name of the image
|
||||
*/
|
||||
public function setPrettyName($name, $prefix = true)
|
||||
{
|
||||
$name = strtolower($name);
|
||||
$name = str_replace(' ', '-', $name);
|
||||
$this->prettyName = preg_replace('/([^a-z0-9\-]+)/m', '', $name);
|
||||
$this->prettyPrefix = $prefix;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Operations array
|
||||
*/
|
||||
protected $operations = array();
|
||||
|
||||
public function __construct($originalFile = null, $width = null, $height = null)
|
||||
{
|
||||
$this->cache = new \Gregwar\Cache\Cache;
|
||||
$this->cache->setCacheDirectory($this->cacheDir);
|
||||
|
||||
$this->setFallback(null);
|
||||
|
||||
if ($originalFile) {
|
||||
$this->source = new Source\File($originalFile);
|
||||
} else {
|
||||
$this->source = new Source\Create($width, $height);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the image data
|
||||
*/
|
||||
public function setData($data)
|
||||
{
|
||||
$this->source = new Source\Data($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the resource
|
||||
*/
|
||||
public function setResource($resource)
|
||||
{
|
||||
$this->source = new Source\Resource($resource);
|
||||
}
|
||||
|
||||
/**
|
||||
* Use the fallback image or not
|
||||
*/
|
||||
public function useFallback($useFallbackImage = true)
|
||||
{
|
||||
$this->useFallbackImage = $useFallbackImage;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the fallback image to use
|
||||
*/
|
||||
public function setFallback($fallback = null)
|
||||
{
|
||||
if ($fallback === null) {
|
||||
$this->fallback = __DIR__ . '/images/error.jpg';
|
||||
} else {
|
||||
$this->fallback = $fallback;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the fallack image path
|
||||
*/
|
||||
public function getFallback()
|
||||
{
|
||||
return $this->fallback;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the fallback into the cache dir
|
||||
*/
|
||||
public function getCacheFallback()
|
||||
{
|
||||
$fallback = $this->fallback;
|
||||
|
||||
return $this->cache->getOrCreateFile('fallback.jpg', array(), function($target) use ($fallback) {
|
||||
copy($fallback, $target);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @return AdapterInterface
|
||||
*/
|
||||
public function getAdapter()
|
||||
{
|
||||
if (null === $this->adapter) {
|
||||
// Defaults to GD
|
||||
$this->setAdapter('gd');
|
||||
}
|
||||
|
||||
return $this->adapter;
|
||||
}
|
||||
|
||||
public function setAdapter($adapter)
|
||||
{
|
||||
if ($adapter instanceof Adapter\Adapter) {
|
||||
$this->adapter = $adapter;
|
||||
} else {
|
||||
if (is_string($adapter)) {
|
||||
$adapter = strtolower($adapter);
|
||||
|
||||
switch ($adapter) {
|
||||
case 'gd':
|
||||
$this->adapter = new Adapter\GD();
|
||||
break;
|
||||
case 'imagemagick':
|
||||
case 'imagick':
|
||||
$this->adapter = new Adapter\Imagick();
|
||||
break;
|
||||
default:
|
||||
throw new \Exception('Unknown adapter: '.$adapter);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
throw new \Exception('Unable to load the given adapter (not string or Adapter)');
|
||||
}
|
||||
}
|
||||
|
||||
$this->adapter->setSource($this->source);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the file path
|
||||
*
|
||||
* @return mixed a string with the filen name, null if the image
|
||||
* does not depends on a file
|
||||
*/
|
||||
public function getFilePath()
|
||||
{
|
||||
if ($this->source instanceof Source\File) {
|
||||
return $this->source->getFile();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines the file only after instantiation
|
||||
*
|
||||
* @param string $originalFile the file path
|
||||
*/
|
||||
public function fromFile($originalFile)
|
||||
{
|
||||
$this->source = new Source\File($originalFile);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tells if the image is correct
|
||||
*/
|
||||
public function correct()
|
||||
{
|
||||
return $this->source->correct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Guess the file type
|
||||
*/
|
||||
public function guessType()
|
||||
{
|
||||
return $this->source->guessType();
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an operation
|
||||
*/
|
||||
protected function addOperation($method, $args)
|
||||
{
|
||||
$this->operations[] = array($method, $args);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generic function
|
||||
*/
|
||||
public function __call($methodName, $args)
|
||||
{
|
||||
$adapter = $this->getAdapter();
|
||||
$reflection = new \ReflectionClass(get_class($adapter));
|
||||
|
||||
if ($reflection->hasMethod($methodName)) {
|
||||
$method = $reflection->getMethod($methodName);
|
||||
|
||||
if ($method->getNumberOfRequiredParameters() > count($args)) {
|
||||
throw new \InvalidArgumentException('Not enough arguments given for '.$methodName);
|
||||
}
|
||||
|
||||
$this->addOperation($methodName, $args);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
throw new \BadFunctionCallException('Invalid method: '.$methodName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Serialization of operations
|
||||
*/
|
||||
public function serializeOperations()
|
||||
{
|
||||
$datas = array();
|
||||
|
||||
foreach ($this->operations as $operation) {
|
||||
$method = $operation[0];
|
||||
$args = $operation[1];
|
||||
|
||||
foreach ($args as &$arg) {
|
||||
if ($arg instanceof self) {
|
||||
$arg = $arg->getHash();
|
||||
}
|
||||
}
|
||||
|
||||
$datas[] = array($method, $args);
|
||||
}
|
||||
|
||||
return serialize($datas);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates the hash
|
||||
*/
|
||||
public function generateHash($type = 'guess', $quality = 80)
|
||||
{
|
||||
$inputInfos = $this->source->getInfos();
|
||||
|
||||
$datas = array(
|
||||
$inputInfos,
|
||||
$this->serializeOperations(),
|
||||
$type,
|
||||
$quality
|
||||
);
|
||||
|
||||
$this->hash = sha1(serialize($datas));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the hash
|
||||
*/
|
||||
public function getHash($type = 'guess', $quality = 80)
|
||||
{
|
||||
if (null === $this->hash) {
|
||||
$this->generateHash($type, $quality);
|
||||
}
|
||||
|
||||
return $this->hash;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the cache file name and generate it if it does not exists.
|
||||
* Note that if it exists, all the image computation process will
|
||||
* not be done.
|
||||
*
|
||||
* @param string $type the image type
|
||||
* @param int $quality the quality (for JPEG)
|
||||
*/
|
||||
public function cacheFile($type = 'jpg', $quality = 80, $actual = false)
|
||||
{
|
||||
if ($type == 'guess') {
|
||||
$type = $this->guessType();
|
||||
}
|
||||
|
||||
if (!count($this->operations) && $type == $this->guessType() && !$this->forceCache) {
|
||||
return $this->getFilename($this->getFilePath());
|
||||
}
|
||||
|
||||
// Computes the hash
|
||||
$this->hash = $this->getHash($type, $quality);
|
||||
|
||||
// Generates the cache file
|
||||
$cacheFile = '';
|
||||
|
||||
if (!$this->prettyName || $this->prettyPrefix) {
|
||||
$cacheFile .= $this->hash;
|
||||
}
|
||||
|
||||
if ($this->prettyPrefix) {
|
||||
$cacheFile .= '-';
|
||||
}
|
||||
|
||||
if ($this->prettyName) {
|
||||
$cacheFile .= $this->prettyName;
|
||||
}
|
||||
|
||||
$cacheFile .= '.'.$type;
|
||||
|
||||
// If the files does not exists, save it
|
||||
$image = $this;
|
||||
|
||||
// Target file should be younger than all the current image
|
||||
// dependencies
|
||||
$conditions = array(
|
||||
'younger-than' => $this->getDependencies()
|
||||
);
|
||||
|
||||
// The generating function
|
||||
$generate = function($target) use ($image, $type, $quality) {
|
||||
$result = $image->save($target, $type, $quality);
|
||||
|
||||
if ($result != $target) {
|
||||
throw new GenerationError($result);
|
||||
}
|
||||
};
|
||||
|
||||
// Asking the cache for the cacheFile
|
||||
try {
|
||||
$file = $this->cache->getOrCreateFile($cacheFile, $conditions, $generate, $actual);
|
||||
} catch (GenerationError $e) {
|
||||
$file = $e->getNewFile();
|
||||
}
|
||||
|
||||
if ($actual) {
|
||||
return $file;
|
||||
} else {
|
||||
return $this->getFilename($file);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get cache data (to render the image)
|
||||
*
|
||||
* @param string $type the image type
|
||||
* @param int $quality the quality (for JPEG)
|
||||
*/
|
||||
public function cacheData($type = 'jpg', $quality = 80)
|
||||
{
|
||||
return file_get_contents($this->cacheFile($type, $quality));
|
||||
}
|
||||
|
||||
/**
|
||||
* Hook to helps to extends and enhance this class
|
||||
*/
|
||||
protected function getFilename($filename)
|
||||
{
|
||||
return $filename;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates and output a jpeg cached file
|
||||
*/
|
||||
public function jpeg($quality = 80)
|
||||
{
|
||||
return $this->cacheFile('jpg', $quality);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates and output a gif cached file
|
||||
*/
|
||||
public function gif()
|
||||
{
|
||||
return $this->cacheFile('gif');
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates and output a png cached file
|
||||
*/
|
||||
public function png()
|
||||
{
|
||||
return $this->cacheFile('png');
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates and output an image using the same type as input
|
||||
*/
|
||||
public function guess($quality = 80)
|
||||
{
|
||||
return $this->cacheFile('guess', $quality);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all the files that this image depends on
|
||||
*
|
||||
* @return string[] this is an array of strings containing all the files that the
|
||||
* current Image depends on
|
||||
*/
|
||||
public function getDependencies()
|
||||
{
|
||||
$dependencies = array();
|
||||
|
||||
$file = $this->getFilePath();
|
||||
if ($file) {
|
||||
$dependencies[] = $file;
|
||||
}
|
||||
|
||||
foreach ($this->operations as $operation) {
|
||||
foreach ($operation[1] as $argument) {
|
||||
if ($argument instanceof self) {
|
||||
$dependencies = array_merge($dependencies, $argument->getDependencies());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $dependencies;
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies the operations
|
||||
*/
|
||||
public function applyOperations()
|
||||
{
|
||||
// Renders the effects
|
||||
foreach ($this->operations as $operation) {
|
||||
call_user_func_array(array($this->adapter, $operation[0]), $operation[1]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the adapter
|
||||
*/
|
||||
public function init()
|
||||
{
|
||||
$this->getAdapter()->init();
|
||||
}
|
||||
|
||||
/**
|
||||
* Save the file to a given output
|
||||
*/
|
||||
public function save($file, $type = 'guess', $quality = 80)
|
||||
{
|
||||
if ($file) {
|
||||
$directory = dirname($file);
|
||||
|
||||
if (!is_dir($directory)) {
|
||||
@mkdir($directory, 0777, true);
|
||||
}
|
||||
}
|
||||
|
||||
if (is_int($type)) {
|
||||
$quality = $type;
|
||||
$type = 'jpeg';
|
||||
}
|
||||
|
||||
if ($type == 'guess') {
|
||||
$type = $this->guessType();
|
||||
}
|
||||
|
||||
if (!isset(self::$types[$type])) {
|
||||
throw new \InvalidArgumentException('Given type ('.$type.') is not valid');
|
||||
}
|
||||
|
||||
$type = self::$types[$type];
|
||||
|
||||
try {
|
||||
$this->init();
|
||||
$this->applyOperations();
|
||||
|
||||
$success = false;
|
||||
|
||||
if (null == $file) {
|
||||
ob_start();
|
||||
}
|
||||
|
||||
if ($type == 'jpeg') {
|
||||
$success = $this->getAdapter()->saveJpeg($file, $quality);
|
||||
}
|
||||
|
||||
if ($type == 'gif') {
|
||||
$success = $this->getAdapter()->saveGif($file);
|
||||
}
|
||||
|
||||
if ($type == 'png') {
|
||||
$success = $this->getAdapter()->savePng($file);
|
||||
}
|
||||
|
||||
if (!$success) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return (null === $file ? ob_get_clean() : $file);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
if ($this->useFallbackImage) {
|
||||
return (null === $file ? file_get_contents($this->fallback) : $this->getCacheFallback());
|
||||
} else {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the contents of the image
|
||||
*/
|
||||
public function get($type = 'guess', $quality = 80)
|
||||
{
|
||||
return $this->save(null, $type, $quality);
|
||||
}
|
||||
|
||||
/* Image API */
|
||||
|
||||
/**
|
||||
* Image width
|
||||
*/
|
||||
public function width()
|
||||
{
|
||||
return $this->getAdapter()->width();
|
||||
}
|
||||
|
||||
/**
|
||||
* Image height
|
||||
*/
|
||||
public function height()
|
||||
{
|
||||
return $this->getAdapter()->height();
|
||||
}
|
||||
|
||||
/**
|
||||
* Tostring defaults to jpeg
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return $this->guess();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returning basic html code for this image
|
||||
*/
|
||||
public function html($title = '', $type = 'jpg', $quality = 80)
|
||||
{
|
||||
return '<img title="' . $title . '" src="' . $this->cacheFile($type, $quality) . '" />';
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Base64 inlinable representation
|
||||
*/
|
||||
public function inline($type = 'jpg', $quality = 80)
|
||||
{
|
||||
$mime = $type;
|
||||
if ($mime == 'jpg') {
|
||||
$mime = 'jpeg';
|
||||
}
|
||||
|
||||
return 'data:image/'.$mime.';base64,'.base64_encode(file_get_contents($this->cacheFile($type, $quality, true)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an instance, usefull for one-line chaining
|
||||
*/
|
||||
public static function open($file = '')
|
||||
{
|
||||
return new self($file);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an instance of a new resource
|
||||
*/
|
||||
public static function create($width, $height)
|
||||
{
|
||||
return new self(null, $width, $height);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an instance of image from its data
|
||||
*/
|
||||
public static function fromData($data)
|
||||
{
|
||||
$image = new self();
|
||||
$image->setData($data);
|
||||
|
||||
return $image;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an instance of image from resource
|
||||
*/
|
||||
public static function fromResource($resource)
|
||||
{
|
||||
$image = new self();
|
||||
$image->setResource($resource);
|
||||
|
||||
return $image;
|
||||
}
|
||||
}
|
||||
@@ -1,93 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Gregwar\Image;
|
||||
|
||||
/**
|
||||
* Color manipulation class
|
||||
*/
|
||||
class ImageColor
|
||||
{
|
||||
private static $colors = array(
|
||||
'black' => 0x000000,
|
||||
'silver' => 0xc0c0c0,
|
||||
'gray' => 0x808080,
|
||||
'teal' => 0x008080,
|
||||
'aqua' => 0x00ffff,
|
||||
'blue' => 0x0000ff,
|
||||
'navy' => 0x000080,
|
||||
'green' => 0x008000,
|
||||
'lime' => 0x00ff00,
|
||||
'white' => 0xffffff,
|
||||
'fuschia' => 0xff00ff,
|
||||
'purple' => 0x800080,
|
||||
'olive' => 0x808000,
|
||||
'yellow' => 0xffff00,
|
||||
'orange' => 0xffA500,
|
||||
'red' => 0xff0000,
|
||||
'maroon' => 0x800000,
|
||||
'transparent' => 0x7fffffff
|
||||
);
|
||||
|
||||
public static function gdAllocate($image, $color)
|
||||
{
|
||||
$colorRGBA = self::parse($color);
|
||||
|
||||
$b = ($colorRGBA)&0xff;
|
||||
$colorRGBA >>= 8;
|
||||
$g = ($colorRGBA)&0xff;
|
||||
$colorRGBA >>= 8;
|
||||
$r = ($colorRGBA)&0xff;
|
||||
$colorRGBA >>= 8;
|
||||
$a = ($colorRGBA)&0xff;
|
||||
|
||||
$c = imagecolorallocatealpha($image, $r, $g, $b, $a);
|
||||
|
||||
if ($color == 'transparent') {
|
||||
imagecolortransparent($image, $c);
|
||||
}
|
||||
|
||||
return $c;
|
||||
}
|
||||
|
||||
public static function parse($color)
|
||||
{
|
||||
// Direct color representation (ex: 0xff0000)
|
||||
if (!is_string($color) && is_numeric($color))
|
||||
return $color;
|
||||
|
||||
// Color name (ex: "red")
|
||||
if (isset(self::$colors[$color]))
|
||||
return self::$colors[$color];
|
||||
|
||||
if (is_string($color)) {
|
||||
$color_string = str_replace(' ', '', $color);
|
||||
|
||||
// Color string (ex: "ff0000", "#ff0000" or "0xfff")
|
||||
if (preg_match('/^(#|0x|)([0-9a-f]{3,6})/i', $color_string, $matches)) {
|
||||
$col = $matches[2];
|
||||
|
||||
if (strlen($col) == 6)
|
||||
return hexdec($col);
|
||||
|
||||
if (strlen($col) == 3) {
|
||||
$r = '';
|
||||
for ($i=0; $i<3; $i++)
|
||||
$r.= $col[$i].$col[$i];
|
||||
return hexdec($r);
|
||||
}
|
||||
}
|
||||
|
||||
// Colors like "rgb(255, 0, 0)"
|
||||
if (preg_match('/^rgb\(([0-9]+),([0-9]+),([0-9]+)\)/i', $color_string, $matches)) {
|
||||
$r = $matches[1];
|
||||
$g = $matches[2];
|
||||
$b = $matches[3];
|
||||
if ($r>=0 && $r<=0xff && $g>=0 && $g<=0xff && $b>=0 && $b<=0xff) {
|
||||
return ($r << 16) | ($g << 8) | ($b);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
throw new \InvalidArgumentException('Invalid color: '.$color);
|
||||
}
|
||||
}
|
||||
19
vendor/gregwar/image/Gregwar/Image/LICENSE
vendored
19
vendor/gregwar/image/Gregwar/Image/LICENSE
vendored
@@ -1,19 +0,0 @@
|
||||
Copyright (c) <2012-2013> Grégoire Passault
|
||||
|
||||
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.
|
||||
271
vendor/gregwar/image/Gregwar/Image/README.md
vendored
271
vendor/gregwar/image/Gregwar/Image/README.md
vendored
@@ -1,271 +0,0 @@
|
||||
Gregwar's Image class
|
||||
=====================
|
||||
|
||||
The `Gregwar\Image` class purpose is to provide a simple object-oriented images handling and caching API.
|
||||
|
||||
Usage
|
||||
=====
|
||||
|
||||
Basic handling
|
||||
--------------
|
||||
|
||||
Using methods chaining, you can open, transform and save a file in a single line:
|
||||
|
||||
```php
|
||||
<?php
|
||||
require_once('lib/Gregwar/Image.php');
|
||||
|
||||
use Gregwar\Image\Image;
|
||||
|
||||
Image::open('in.png')
|
||||
->resize(100, 100)
|
||||
->negate()
|
||||
->save('out.jpg');
|
||||
```
|
||||
|
||||
The methods available are:
|
||||
|
||||
* `resize($width, $height, $background)`: resizes the image, will preserve scale and never
|
||||
enlarge it
|
||||
|
||||
* `scaleResize($width, $height, $background)`: resizes the image, will preserve scale
|
||||
|
||||
* `forceResize($width, $height, $background)`: resizes the image, will force the image to
|
||||
be exactly $width by $height
|
||||
|
||||
* `cropResize($width, $height, $background)`: resizes the image preserving scale and croping
|
||||
the whitespaces
|
||||
|
||||
* `crop($x, $y, $w, $h)`: crops the image to a box located on coordinates $x,y and
|
||||
which size is $w by $h
|
||||
|
||||
* `negate()`: negates the image colors
|
||||
|
||||
* `brighness($b)`: applies a brightness effect to the image (from -255 to +255)
|
||||
|
||||
* `contrast($c)`: applies a contrast effect to the image (from -100 to +100)
|
||||
|
||||
* `grayscale()`: converts the image to grayscale
|
||||
|
||||
* `emboss()`: emboss the image
|
||||
|
||||
* `smooth($p)`: smooth the image
|
||||
|
||||
* `sharp()`: applies a mean removal filter on the image
|
||||
|
||||
* `edge()`: applies an edge effect on the image
|
||||
|
||||
* `colorize($red, $green, $blue)`: colorize the image (from -255 to +255 for each color)
|
||||
|
||||
* `sepia()`: applies a sepia effect
|
||||
|
||||
* `merge($image, $x, $y, $width, $height)`: merges two images
|
||||
|
||||
* `fill($color, $x, $y)`: fills the image with the given color
|
||||
|
||||
* `write($font, $text, $x, $y, $size, $angle, $color, $position)`: writes text over image, $position can be any of 'left', 'right', or 'center'
|
||||
|
||||
* `rectangle($x1, $y1, $x2, $y2, $color, $filled=false)`: draws a rectangle
|
||||
|
||||
* `rotate($angle, $background = 0xffffff)` : rotate the image to given angle
|
||||
|
||||
* `roundedRectangle($x1, $y1, $x2, $y2, $radius, $color, $filled=false)`: draws a rounded rectangle ($radius can be anything from 0)
|
||||
|
||||
* `line($x1, $y1, $x2, $y2, $color)`: draws a line
|
||||
|
||||
* `ellipse($cx, $cy, $width, $height, $color, $filled=false)`: draws an ellipse
|
||||
|
||||
* `circle($cx, $cy, $r, $color, $filled=false)`: draws a circle
|
||||
|
||||
* `zoomCrop($width, $height, $background)`: resize and crop the image to fit to given dimensions
|
||||
|
||||
* `fillBackground($bg=0xffffff)`: fills the background of a transparent image to the 'bg' color
|
||||
|
||||
* `html($title = '', $type = 'jpg')`: return the `<img ... />` tag with the cache image
|
||||
|
||||
* `inline($type = 'jpg')`: returns the HTML inlinable base64 string (see `demo/inline.php`)
|
||||
|
||||
You can also create image from scratch using:
|
||||
|
||||
```php
|
||||
<?php
|
||||
Image::create(200, 100);
|
||||
```
|
||||
|
||||
Where 200 is the width and 100 the height
|
||||
|
||||
Saving the image
|
||||
----------------
|
||||
|
||||
You can save the image to an explicit file using `save($file, $type = 'jpg', $quality = 80)`:
|
||||
|
||||
```php
|
||||
<?php
|
||||
// ...
|
||||
$image->save('output.jpg', 'jpg', 85);
|
||||
```
|
||||
|
||||
You can also get the contents of the image using `get($type = 'jpg', $quality = 80)`, which will return the binary contents of the image
|
||||
|
||||
Using cache
|
||||
-----------
|
||||
|
||||
Each operation above is not actually applied on the opened image, but added in an operations
|
||||
array. This operation array, the name, type and modification time of file are hashed using
|
||||
`sha1()` and the hash is used to look up for a cache file.
|
||||
|
||||
Once the cache directory configured, you can call the following methods:
|
||||
|
||||
* `jpeg($quality = 80)`: lookup or create a jpeg cache file on-the-fly
|
||||
|
||||
* `gif()`: lookup or create a gif cache file on-the-fly
|
||||
|
||||
* `png()`: lookup or create a png cache file on-the-fly
|
||||
|
||||
* `guess($quality = 80)`: guesses the type (use the same as input) and lookup or create a
|
||||
cache file on-the-fly
|
||||
|
||||
* `setPrettyName($prettyName, $prefix = true)`: sets a "pretty" name suffix for the file, if you want it to be more SEO-friendly.
|
||||
for instance, if you call it "Fancy Image", the cache will look like something/something-fancy-image.jpg.
|
||||
If `$prefix` is passed to `false` (default `true`), the pretty name won't have any hash prefix.
|
||||
|
||||
For instance:
|
||||
|
||||
```php
|
||||
<?php
|
||||
require_once('lib/Gregwar/Image.php');
|
||||
|
||||
use Gregwar\Image\Image;
|
||||
|
||||
echo Image::open('test.png')
|
||||
->sepia()
|
||||
->jpeg();
|
||||
|
||||
//Outputs: cache/images/1/8/6/9/c/86e4532dbd9c073075ef08e9751fc9bc0f4.jpg
|
||||
```
|
||||
|
||||
If the original file and operations do not change, the hashed value will be the same and the
|
||||
cache will not be generated again.
|
||||
|
||||
You can use this directly in an HTML document:
|
||||
|
||||
|
||||
```php
|
||||
<?php
|
||||
require_once('lib/Gregwar/Image.php');
|
||||
|
||||
use Gregwar\Image\Image;
|
||||
|
||||
// ...
|
||||
<img src="<?php echo Image::open('image.jpg')->resize(150, 150)->jpeg(); ?>" />
|
||||
// ...
|
||||
```
|
||||
|
||||
This is powerful since if you change the original image or any of your code the cached hash
|
||||
will change and the file will be regenerated.
|
||||
|
||||
Writing image
|
||||
-------------
|
||||
|
||||
You can also create your own image on-the-fly using drawing functions:
|
||||
|
||||
|
||||
```php
|
||||
<img src="<?php echo Image::create(300, 300)
|
||||
->fill(0xffaaaa) // Filling with a light red
|
||||
->rectangle(0xff3333, 0, 100, 300, 200, true) // Drawing a red rectangle
|
||||
// Writing "Hello $username !" on the picture using a custom TTF font file
|
||||
->write('./fonts/CaviarDreams.ttf', 'Hello '.$username.'!', 150, 150, 20, 0, 'white', 'center')
|
||||
->jpeg(); ?>" />
|
||||
```
|
||||
|
||||
Using fallback image
|
||||
--------------------
|
||||
|
||||
If the image file doesn't exists, you can configurate a fallback image that will be used
|
||||
by the class (note that this require the cache directory to be available).
|
||||
|
||||
A default "error" image which is used is in `images/error.jpg`, you can change it with:
|
||||
|
||||
```php
|
||||
<?php
|
||||
$img->setFallback('/path/to/my/fallback.jpg');
|
||||
```
|
||||
|
||||
Garbage Collect
|
||||
===============
|
||||
|
||||
To prevent the cache from growing forever, you can use the provided GarbageCollect class as below:
|
||||
|
||||
```php
|
||||
<?php
|
||||
// This could be a cron called each day @3:00AM for instance
|
||||
use Gregwar\Image\GarbageCollect;
|
||||
|
||||
// Removes all the files from ../cache that are more than 30 days
|
||||
// old. A verbose output will explain which files are deleted
|
||||
GarbageCollect::dropOldFiles(__DIR__.'/../cache', 30, true);
|
||||
|
||||
```
|
||||
|
||||
Using with composer
|
||||
===================
|
||||
|
||||
This repository is available with composer under the name `gregwar/image`, so simply add this to
|
||||
your requires :
|
||||
|
||||
```
|
||||
"requires": {
|
||||
...
|
||||
"gregwar/image": "dev-master"
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
And update your dependencies, you'll be able to use the composer autoloader to load the class
|
||||
|
||||
License
|
||||
=======
|
||||
|
||||
`Gregwar\Image` is under MIT License
|
||||
|
||||
Development
|
||||
===========
|
||||
|
||||
`Gregwar\Image` is using PHP metaprogramming paradigms so it make it easy to enhance.
|
||||
|
||||
Each function that handle the image is implemented in an *Adapter*, this is where
|
||||
all the specific actions take places.
|
||||
|
||||
The `Common` adapter is design to contain common abstract actions, while the
|
||||
specific adatpers (like `GD`) are designed to contain actions specific to the low
|
||||
level layer.
|
||||
|
||||
You can add your own methods by adding it in the corresponding adapter.
|
||||
|
||||
```php
|
||||
<?php
|
||||
// In the adapter
|
||||
private function myFilter()
|
||||
{
|
||||
$this->negate();
|
||||
$this->sepia();
|
||||
}
|
||||
```
|
||||
|
||||
Which could be usable on the Image
|
||||
|
||||
```php
|
||||
<?php
|
||||
$image->myFilter();
|
||||
```
|
||||
|
||||
You can also write your own adapter in your application, which could extend one of this repository,
|
||||
and uses it calling `setAdapter()`:
|
||||
|
||||
```php
|
||||
<?php
|
||||
$image->setAdapter(new MyCustomAdapter);
|
||||
```
|
||||
|
||||
Do not hesitate to fork this repository and customize it !
|
||||
@@ -1,38 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Gregwar\Image\Source;
|
||||
|
||||
/**
|
||||
* Creates a new image from scratch
|
||||
*/
|
||||
class Create extends Source
|
||||
{
|
||||
protected $width;
|
||||
protected $height;
|
||||
|
||||
public function __construct($width, $height)
|
||||
{
|
||||
$this->width = $width;
|
||||
$this->height = $height;
|
||||
}
|
||||
|
||||
public function getWidth()
|
||||
{
|
||||
return $this->width;
|
||||
}
|
||||
|
||||
public function getHeight()
|
||||
{
|
||||
return $this->height;
|
||||
}
|
||||
|
||||
public function getInfos()
|
||||
{
|
||||
return array($this->width, $this->height);
|
||||
}
|
||||
|
||||
public function correct()
|
||||
{
|
||||
return $this->width > 0 && $this->height > 0;
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Gregwar\Image\Source;
|
||||
|
||||
/**
|
||||
* Having image in some string
|
||||
*/
|
||||
class Data extends Source
|
||||
{
|
||||
protected $data;
|
||||
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
public function getData()
|
||||
{
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
public function getInfos()
|
||||
{
|
||||
return sha1($this->data);
|
||||
}
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Gregwar\Image\Source;
|
||||
|
||||
use Gregwar\Image\Image;
|
||||
|
||||
/**
|
||||
* Open an image from a file
|
||||
*/
|
||||
class File extends Source
|
||||
{
|
||||
protected $file;
|
||||
|
||||
public function __construct($file)
|
||||
{
|
||||
$this->file = $file;
|
||||
}
|
||||
|
||||
public function getFile()
|
||||
{
|
||||
return $this->file;
|
||||
}
|
||||
|
||||
public function correct()
|
||||
{
|
||||
return false !== @exif_imagetype($this->file);
|
||||
}
|
||||
|
||||
public function guessType()
|
||||
{
|
||||
if (function_exists('exif_imagetype')) {
|
||||
$type = @exif_imagetype($this->file);
|
||||
|
||||
if (false !== $type) {
|
||||
if ($type == IMAGETYPE_JPEG) {
|
||||
return 'jpeg';
|
||||
}
|
||||
|
||||
if ($type == IMAGETYPE_GIF) {
|
||||
return 'gif';
|
||||
}
|
||||
|
||||
if ($type == IMAGETYPE_PNG) {
|
||||
return 'png';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$parts = explode('.', $this->file);
|
||||
$ext = strtolower($parts[count($parts)-1]);
|
||||
|
||||
if (isset(Image::$types[$ext])) {
|
||||
return Image::$types[$ext];
|
||||
}
|
||||
|
||||
return 'jpeg';
|
||||
}
|
||||
|
||||
public function getInfos()
|
||||
{
|
||||
return $this->file;
|
||||
}
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Gregwar\Image\Source;
|
||||
|
||||
/**
|
||||
* Have the image directly in a specific resource
|
||||
*/
|
||||
class Resource extends Source
|
||||
{
|
||||
protected $resource;
|
||||
|
||||
public function __construct($resource)
|
||||
{
|
||||
$this->resource = $resource;
|
||||
}
|
||||
|
||||
public function getResource()
|
||||
{
|
||||
return $this->resource;
|
||||
}
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Gregwar\Image\Source;
|
||||
|
||||
/**
|
||||
* An Image source
|
||||
*/
|
||||
class Source
|
||||
{
|
||||
/**
|
||||
* Guess the type of the image
|
||||
*/
|
||||
public function guessType()
|
||||
{
|
||||
return 'jpeg';
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this image correct ?
|
||||
*/
|
||||
public function correct()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns information about images, these informations should
|
||||
* change only if the original image changed
|
||||
*/
|
||||
public function getInfos()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
21
vendor/gregwar/image/Gregwar/Image/autoload.php
vendored
21
vendor/gregwar/image/Gregwar/Image/autoload.php
vendored
@@ -1,21 +0,0 @@
|
||||
<?php
|
||||
|
||||
$vendors = __DIR__.'/vendor/autoload.php';
|
||||
if (file_exists($vendors)) {
|
||||
require($vendors);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers an autoload for all the classes in Gregwar\Image
|
||||
*/
|
||||
spl_autoload_register(function ($className) {
|
||||
$namespace = 'Gregwar\\Image';
|
||||
|
||||
if (strpos($className, $namespace) === 0) {
|
||||
$className = str_replace($namespace, '', $className);
|
||||
$fileName = __DIR__ . '/' . str_replace('\\', '/', $className) . '.php';
|
||||
if (file_exists($fileName)) {
|
||||
require($fileName);
|
||||
}
|
||||
}
|
||||
});
|
||||
BIN
vendor/gregwar/image/Gregwar/Image/images/error.jpg
vendored
BIN
vendor/gregwar/image/Gregwar/Image/images/error.jpg
vendored
Binary file not shown.
|
Before Width: | Height: | Size: 1.1 KiB |
7
vendor/ircmaxell/password-compat/LICENSE.md
vendored
7
vendor/ircmaxell/password-compat/LICENSE.md
vendored
@@ -1,7 +0,0 @@
|
||||
Copyright (c) 2012 Anthony Ferrara
|
||||
|
||||
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.
|
||||
75
vendor/ircmaxell/password-compat/README.md
vendored
75
vendor/ircmaxell/password-compat/README.md
vendored
@@ -1,75 +0,0 @@
|
||||
password_compat
|
||||
===============
|
||||
|
||||
[](https://travis-ci.org/ircmaxell/password_compat)
|
||||
|
||||
This library is intended to provide forward compatibility with the password_* functions being worked on for PHP 5.5.
|
||||
|
||||
See [the RFC](https://wiki.php.net/rfc/password_hash) for more detailed information.
|
||||
|
||||
|
||||
Requirements
|
||||
============
|
||||
|
||||
This library requires `PHP >= 5.3.7` OR a version that has the `$2y` fix backported into it (such as Debian provides).
|
||||
|
||||
The runtime checks have been removed due to this version issue. To see if password_compat is available for your system, run the included `version-test.php`. If it outputs "Pass", you can safely use the library. If not, you cannot.
|
||||
|
||||
If you attempt to use password-compat on an unsupported version, attempts to create or verify hashes will return `false`. You have been warned!
|
||||
|
||||
The reason for this is that PHP prior to 5.3.7 contains a security issue with its BCRYPT implementation. Therefore, it's highly recommended that you upgrade to a newer version of PHP prior to using this layer.
|
||||
|
||||
Installation
|
||||
============
|
||||
|
||||
To install, simply `require` the `password.php` file under `lib`.
|
||||
|
||||
You can also install it via `Composer` by using the [Packagist archive](http://packagist.org/packages/ircmaxell/password-compat).
|
||||
|
||||
Usage
|
||||
=====
|
||||
|
||||
**Creating Password Hashes**
|
||||
|
||||
To create a password hash from a password, simply use the `password_hash` function.
|
||||
|
||||
$hash = password_hash($password, PASSWORD_BCRYPT);
|
||||
|
||||
Note that the algorithm that we chose is `PASSWORD_BCRYPT`. That's the current strongest algorithm supported. This is the `BCRYPT` crypt algorithm. It produces a 60 character hash as the result.
|
||||
|
||||
`BCRYPT` also allows for you to define a `cost` parameter in the options array. This allows for you to change the CPU cost of the algorithm:
|
||||
|
||||
$hash = password_hash($password, PASSWORD_BCRYPT, ["cost" => 10]);
|
||||
|
||||
That's the same as the default. The cost can range from `4` to `31`. I would suggest that you use the highest cost that you can, while keeping response time reasonable (I target between 0.1 and 0.5 seconds for a hash, depending on use-case).
|
||||
|
||||
Another algorithm name is supported:
|
||||
|
||||
PASSWORD_DEFAULT
|
||||
|
||||
This will use the strongest algorithm available to PHP at the current time. Presently, this is the same as specifying `PASSWORD_BCRYPT`. But in future versions of PHP, it may be updated to use a stronger algorithm if one is introduced. It can also be changed if a problem is identified with the BCRYPT algorithm. Note that if you use this option, you are **strongly** encouraged to store it in a `VARCHAR(255)` column to avoid truncation issues if a future algorithm increases the length of the generated hash.
|
||||
|
||||
It is very important that you should check the return value of `password_hash` prior to storing it, because a `false` may be returned if it encountered an error.
|
||||
|
||||
**Verifying Password Hashes**
|
||||
|
||||
To verify a hash created by `password_hash`, simply call:
|
||||
|
||||
if (password_verify($password, $hash)) {
|
||||
/* Valid */
|
||||
} else {
|
||||
/* Invalid */
|
||||
}
|
||||
|
||||
That's all there is to it.
|
||||
|
||||
**Rehashing Passwords**
|
||||
|
||||
From time to time you may update your hashing parameters (algorithm, cost, etc). So a function to determine if rehashing is necessary is available:
|
||||
|
||||
if (password_verify($password, $hash)) {
|
||||
if (password_needs_rehash($hash, $algorithm, $options)) {
|
||||
$hash = password_hash($password, $algorithm, $options);
|
||||
/* Store new hash in db */
|
||||
}
|
||||
}
|
||||
222
vendor/ircmaxell/password-compat/lib/password.php
vendored
222
vendor/ircmaxell/password-compat/lib/password.php
vendored
@@ -1,222 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* A Compatibility library with PHP 5.5's simplified password hashing API.
|
||||
*
|
||||
* @author Anthony Ferrara <ircmaxell@php.net>
|
||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||
* @copyright 2012 The Authors
|
||||
*/
|
||||
|
||||
if (!defined('PASSWORD_BCRYPT')) {
|
||||
|
||||
define('PASSWORD_BCRYPT', 1);
|
||||
define('PASSWORD_DEFAULT', PASSWORD_BCRYPT);
|
||||
|
||||
/**
|
||||
* Hash the password using the specified algorithm
|
||||
*
|
||||
* @param string $password The password to hash
|
||||
* @param int $algo The algorithm to use (Defined by PASSWORD_* constants)
|
||||
* @param array $options The options for the algorithm to use
|
||||
*
|
||||
* @return string|false The hashed password, or false on error.
|
||||
*/
|
||||
function password_hash($password, $algo, array $options = array()) {
|
||||
if (!function_exists('crypt')) {
|
||||
trigger_error("Crypt must be loaded for password_hash to function", E_USER_WARNING);
|
||||
return null;
|
||||
}
|
||||
if (!is_string($password)) {
|
||||
trigger_error("password_hash(): Password must be a string", E_USER_WARNING);
|
||||
return null;
|
||||
}
|
||||
if (!is_int($algo)) {
|
||||
trigger_error("password_hash() expects parameter 2 to be long, " . gettype($algo) . " given", E_USER_WARNING);
|
||||
return null;
|
||||
}
|
||||
switch ($algo) {
|
||||
case PASSWORD_BCRYPT:
|
||||
// Note that this is a C constant, but not exposed to PHP, so we don't define it here.
|
||||
$cost = 10;
|
||||
if (isset($options['cost'])) {
|
||||
$cost = $options['cost'];
|
||||
if ($cost < 4 || $cost > 31) {
|
||||
trigger_error(sprintf("password_hash(): Invalid bcrypt cost parameter specified: %d", $cost), E_USER_WARNING);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
// The length of salt to generate
|
||||
$raw_salt_len = 16;
|
||||
// The length required in the final serialization
|
||||
$required_salt_len = 22;
|
||||
$hash_format = sprintf("$2y$%02d$", $cost);
|
||||
break;
|
||||
default:
|
||||
trigger_error(sprintf("password_hash(): Unknown password hashing algorithm: %s", $algo), E_USER_WARNING);
|
||||
return null;
|
||||
}
|
||||
if (isset($options['salt'])) {
|
||||
switch (gettype($options['salt'])) {
|
||||
case 'NULL':
|
||||
case 'boolean':
|
||||
case 'integer':
|
||||
case 'double':
|
||||
case 'string':
|
||||
$salt = (string) $options['salt'];
|
||||
break;
|
||||
case 'object':
|
||||
if (method_exists($options['salt'], '__tostring')) {
|
||||
$salt = (string) $options['salt'];
|
||||
break;
|
||||
}
|
||||
case 'array':
|
||||
case 'resource':
|
||||
default:
|
||||
trigger_error('password_hash(): Non-string salt parameter supplied', E_USER_WARNING);
|
||||
return null;
|
||||
}
|
||||
if (strlen($salt) < $required_salt_len) {
|
||||
trigger_error(sprintf("password_hash(): Provided salt is too short: %d expecting %d", strlen($salt), $required_salt_len), E_USER_WARNING);
|
||||
return null;
|
||||
} elseif (0 == preg_match('#^[a-zA-Z0-9./]+$#D', $salt)) {
|
||||
$salt = str_replace('+', '.', base64_encode($salt));
|
||||
}
|
||||
} else {
|
||||
$buffer = '';
|
||||
$buffer_valid = false;
|
||||
if (function_exists('mcrypt_create_iv') && !defined('PHALANGER')) {
|
||||
$buffer = mcrypt_create_iv($raw_salt_len, MCRYPT_DEV_URANDOM);
|
||||
if ($buffer) {
|
||||
$buffer_valid = true;
|
||||
}
|
||||
}
|
||||
if (!$buffer_valid && function_exists('openssl_random_pseudo_bytes')) {
|
||||
$buffer = openssl_random_pseudo_bytes($raw_salt_len);
|
||||
if ($buffer) {
|
||||
$buffer_valid = true;
|
||||
}
|
||||
}
|
||||
if (!$buffer_valid && is_readable('/dev/urandom')) {
|
||||
$f = fopen('/dev/urandom', 'r');
|
||||
$read = strlen($buffer);
|
||||
while ($read < $raw_salt_len) {
|
||||
$buffer .= fread($f, $raw_salt_len - $read);
|
||||
$read = strlen($buffer);
|
||||
}
|
||||
fclose($f);
|
||||
if ($read >= $raw_salt_len) {
|
||||
$buffer_valid = true;
|
||||
}
|
||||
}
|
||||
if (!$buffer_valid || strlen($buffer) < $raw_salt_len) {
|
||||
$bl = strlen($buffer);
|
||||
for ($i = 0; $i < $raw_salt_len; $i++) {
|
||||
if ($i < $bl) {
|
||||
$buffer[$i] = $buffer[$i] ^ chr(mt_rand(0, 255));
|
||||
} else {
|
||||
$buffer .= chr(mt_rand(0, 255));
|
||||
}
|
||||
}
|
||||
}
|
||||
$salt = str_replace('+', '.', base64_encode($buffer));
|
||||
}
|
||||
$salt = substr($salt, 0, $required_salt_len);
|
||||
|
||||
$hash = $hash_format . $salt;
|
||||
|
||||
$ret = crypt($password, $hash);
|
||||
|
||||
if (!is_string($ret) || strlen($ret) <= 13) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get information about the password hash. Returns an array of the information
|
||||
* that was used to generate the password hash.
|
||||
*
|
||||
* array(
|
||||
* 'algo' => 1,
|
||||
* 'algoName' => 'bcrypt',
|
||||
* 'options' => array(
|
||||
* 'cost' => 10,
|
||||
* ),
|
||||
* )
|
||||
*
|
||||
* @param string $hash The password hash to extract info from
|
||||
*
|
||||
* @return array The array of information about the hash.
|
||||
*/
|
||||
function password_get_info($hash) {
|
||||
$return = array(
|
||||
'algo' => 0,
|
||||
'algoName' => 'unknown',
|
||||
'options' => array(),
|
||||
);
|
||||
if (substr($hash, 0, 4) == '$2y$' && strlen($hash) == 60) {
|
||||
$return['algo'] = PASSWORD_BCRYPT;
|
||||
$return['algoName'] = 'bcrypt';
|
||||
list($cost) = sscanf($hash, "$2y$%d$");
|
||||
$return['options']['cost'] = $cost;
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the password hash needs to be rehashed according to the options provided
|
||||
*
|
||||
* If the answer is true, after validating the password using password_verify, rehash it.
|
||||
*
|
||||
* @param string $hash The hash to test
|
||||
* @param int $algo The algorithm used for new password hashes
|
||||
* @param array $options The options array passed to password_hash
|
||||
*
|
||||
* @return boolean True if the password needs to be rehashed.
|
||||
*/
|
||||
function password_needs_rehash($hash, $algo, array $options = array()) {
|
||||
$info = password_get_info($hash);
|
||||
if ($info['algo'] != $algo) {
|
||||
return true;
|
||||
}
|
||||
switch ($algo) {
|
||||
case PASSWORD_BCRYPT:
|
||||
$cost = isset($options['cost']) ? $options['cost'] : 10;
|
||||
if ($cost != $info['options']['cost']) {
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify a password against a hash using a timing attack resistant approach
|
||||
*
|
||||
* @param string $password The password to verify
|
||||
* @param string $hash The hash to verify against
|
||||
*
|
||||
* @return boolean If the password matches the hash
|
||||
*/
|
||||
function password_verify($password, $hash) {
|
||||
if (!function_exists('crypt')) {
|
||||
trigger_error("Crypt must be loaded for password_verify to function", E_USER_WARNING);
|
||||
return false;
|
||||
}
|
||||
$ret = crypt($password, $hash);
|
||||
if (!is_string($ret) || strlen($ret) != strlen($hash) || strlen($ret) <= 13) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$status = 0;
|
||||
for ($i = 0; $i < strlen($ret); $i++) {
|
||||
$status |= (ord($ret[$i]) ^ ord($hash[$i]));
|
||||
}
|
||||
|
||||
return $status === 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
141
vendor/mrclay/minify/HISTORY.txt
vendored
141
vendor/mrclay/minify/HISTORY.txt
vendored
@@ -1,141 +0,0 @@
|
||||
Minify Release History
|
||||
|
||||
(master)
|
||||
* Builder styled with Bootstrap (thanks to help from acidvertigo)
|
||||
|
||||
Version 2.2.0
|
||||
* Fix handling of RegEx in certain situations in JSMin
|
||||
* Thanks to Vovan-VE for reporting this
|
||||
* Update composer.json with support info
|
||||
* Add ability to set ClosureCompiler URL
|
||||
* Thanks Elan Ruusamäe for the pull request
|
||||
* Better report of temp directory errors
|
||||
* Also thanks to Elan Ruusamäe for anatoher pull request
|
||||
* Updated CSSmin and added Minify_CSSmin wrapper
|
||||
* Fix windows issue associated with long cache filenames
|
||||
* Fix issue with web-based tool
|
||||
* Fix bug in JSMin exceptions
|
||||
* Fix "about:blank" bug in CSS_UriRewriter
|
||||
* Cite is no longer a block element in HTML minification
|
||||
* Allow for definition of custom config locations outside of the min directory
|
||||
* Thanks Sam Bauers for the pull request
|
||||
* Allow option for overriding the maximum byte size POST limit for ClosureCompiler and other additions
|
||||
* Thanks Joscha Feth for the code
|
||||
* Fixes to file-relative URL identification in UriRewriter
|
||||
* Allow far-future expiration and file versioning with the "v" querystirng parameter in addition to existing method
|
||||
* Lots of general code tidy ups
|
||||
|
||||
Version 2.1.7
|
||||
* Fixes arbitrary file inclusion vulnerability on some systems
|
||||
* Thanks to Matt Mecham for reporting this
|
||||
|
||||
Version 2.1.6
|
||||
* JSMin fixes
|
||||
* Prevents some Closure Compiler API failures
|
||||
* Uses autoloading for all class loading
|
||||
* Multiple group support in HTML Helper
|
||||
* Cache adaptor for XCache
|
||||
* Allow setting stack-size in YUI Compressor wrapper
|
||||
* Adds jsCleanComments option to HTML minifier
|
||||
* Upgrades CSSmin
|
||||
* CLI script more portable
|
||||
* Adds composer.json
|
||||
|
||||
Version 2.1.5
|
||||
* Removed XSS vulnerability
|
||||
* Disabled builder bby default
|
||||
* command line tools to minify and rewrite URIs in CSS
|
||||
* upgrade (optional) JSMin+ library
|
||||
* more efficient JS minification when using CC/YUIC
|
||||
* Closure Compiler uses cURL when allow_url_fopen is off
|
||||
* Missing file notices when using groups
|
||||
|
||||
Version 2.1.4
|
||||
* Option to minify JS with Closure Compiler API w/ JSMin failover
|
||||
* Cookie/bookmarklet-based debug mode. No HTML editing!
|
||||
* Allows 1 file to be missing w/o complete failure
|
||||
* Combine multiple groups and files in single URI
|
||||
* More useful HTML helpers for writing versioned URIs
|
||||
* More detailed error logging, including minifier exceptions
|
||||
* Builder offers more helpful messages/PHP environment warnings
|
||||
* Bypass minification based on filename pattern. e.g. foo.min.js / foo-min.css
|
||||
* JSMin won't choke on common Closure compiler syntaxes (i+ ++j)
|
||||
* Better caching in IE6
|
||||
* Cache ids are influenced by group/file names
|
||||
* Debug mode for Javascript doesn't break on common XPath strings (Prototype 1.6)
|
||||
* Removed annoying maxFiles limit
|
||||
* mbstring.func_overload usage is safer
|
||||
|
||||
Version 2.1.3
|
||||
* HTTP fixes
|
||||
* ETag generation now valid (different when gzipped)
|
||||
* Vary header always sent when Accept-Encoding is sniffed
|
||||
* Cache-Control no longer has "must-revalidate" due to webkit bug
|
||||
See: http://mrclay.org/index.php/2009/02/24/safari-4-beta-cache-controlmust-revalidate-bug/
|
||||
* Dropped deflate encoding. Browser and proxy support could be buggy.
|
||||
See: http://stackoverflow.com/questions/883841/
|
||||
* File cache now works w/o setting $min_cachePath
|
||||
* Allow setting contentType in Minify_Source objects
|
||||
* No more 5.3 deprecation warnings: split() removed
|
||||
|
||||
Version 2.1.2
|
||||
* Javascript fixes
|
||||
* Debug mode no longer confused by "*/*" in strings/RegExps (jQuery)
|
||||
* quote characters inside RegExp literals no longer cause exception
|
||||
* files ending in single-line comments no longer cause code loss
|
||||
* CSS: data: URLs no longer mangled
|
||||
* Optional error logging to Firefox's FirePHP extension
|
||||
* Unit tests to check for common DOCUMENT_ROOT problems
|
||||
* DOCUMENT_ROOT no longer overwritten on IIS servers
|
||||
* Builder app doesn't fail on systems without gzdeflate()
|
||||
* APC caching class included
|
||||
|
||||
Version 2.1.1
|
||||
* Bug fix release
|
||||
* Detection and workarounds for zlib.output_compression and non-PHP encoding modules
|
||||
* Zlib not required (mod_rewrite, et.al., can still be used for encoding)
|
||||
* HTML : More IE conditional comments preserved
|
||||
* Minify_groupUri() utility fixed
|
||||
|
||||
Version 2.1.0
|
||||
* "min" default application for quick deployment
|
||||
* Minify URI Builder app & bookmarklet for quickly creating minify URIs
|
||||
* Relative URIs in CSS file are fixed automatically by default
|
||||
* "debug" mode for revealing original line #s in combined files
|
||||
* Better IIS support
|
||||
* Improved minifier classes:
|
||||
* JS: preserves IE conditional comments
|
||||
* CSS: smaller output, preserves more hacks and valid CSS syntax,
|
||||
shorter line lengths, other bug fixes
|
||||
* HTML: smaller output, shorter line lengths, other bug fixes
|
||||
* Default Cache-Control: max-age of 30 minutes
|
||||
* Conditional GETs supported even when max-age sent
|
||||
* Experimental memcache cache class (default is files)
|
||||
* Minify_Cache_File has flock()s (by default)
|
||||
* Workaround for Windows mtime reporting bug
|
||||
|
||||
Version 2.0.2 beta (2008-06-24)
|
||||
* Fast new cache system. Cached files served almost 3x as fast.
|
||||
* Dropped support of compress encoding (though HTTP_Encoder still supports it)
|
||||
|
||||
Version 2.0.1 (2008-05-31)
|
||||
* E_STRICT compliance (Cache_Lite_File).
|
||||
|
||||
Version 2.0.0 (2008-05-22)
|
||||
* Complete code overhaul. Minify is now a PEAR-style class and toolkit
|
||||
for building customized minifying file servers.
|
||||
* Content-Encoding: deflate/gzip/compress, based on request headers
|
||||
* Expanded CSS and HTML minifiers with test cases
|
||||
* Easily plug-in 3rd-party minifiers (like Packer)
|
||||
* Plug-able front end controller allows changing the way files are chosen
|
||||
* Compression & encoding modules lazy-loaded as needed (304 responses use
|
||||
use minimal code)
|
||||
* Separate utility classes for HTTP encoding and cache control
|
||||
|
||||
Version 1.0.1 (2007-05-05)
|
||||
* Fixed various problems resolving pathnames when hosted on an NFS mount.
|
||||
* Fixed 'undefined constant' notice.
|
||||
* Replaced old JSMin library with a much faster custom implementation.
|
||||
|
||||
Version 1.0.0 (2007-05-02)
|
||||
* First release.
|
||||
26
vendor/mrclay/minify/LICENSE.txt
vendored
26
vendor/mrclay/minify/LICENSE.txt
vendored
@@ -1,26 +0,0 @@
|
||||
Copyright (c) 2008 Ryan Grove <ryan@wonko.com>
|
||||
Copyright (c) 2008 Steve Clay <steve@mrclay.org>
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
* Neither the name of this project nor the names of its contributors may be
|
||||
used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
181
vendor/mrclay/minify/MIN.txt
vendored
181
vendor/mrclay/minify/MIN.txt
vendored
@@ -1,181 +0,0 @@
|
||||
The files in the /min/ directory represent the default Minify setup designed to ease
|
||||
integration with your site. This app will combine and minify your Javascript or
|
||||
CSS files and serve them with HTTP compression and cache headers.
|
||||
|
||||
|
||||
RECOMMENDED
|
||||
|
||||
It's recommended to edit /min/config.php to set $min_cachePath to a writeable
|
||||
(by PHP) directory on your system. This will improve performance.
|
||||
|
||||
|
||||
GETTING STARTED
|
||||
|
||||
The quickest way to get started is to use the Minify URI Builder application
|
||||
on your website: http://example.com/min/builder/
|
||||
|
||||
|
||||
MINIFYING A SINGLE FILE
|
||||
|
||||
Let's say you want to serve this file:
|
||||
http://example.com/wp-content/themes/default/default.css
|
||||
|
||||
Here's the "Minify URL" for this file:
|
||||
http://example.com/min/?f=wp-content/themes/default/default.css
|
||||
|
||||
In other words, the "f" argument is set to the file path from root without the
|
||||
initial "/". As CSS files may contain relative URIs, Minify will automatically
|
||||
"fix" these by rewriting them as root relative.
|
||||
|
||||
|
||||
COMBINING MULTIPLE FILES IN ONE DOWNLOAD
|
||||
|
||||
Separate the paths given to "f" with commas.
|
||||
|
||||
Let's say you have CSS files at these URLs:
|
||||
http://example.com/scripts/jquery-1.2.6.js
|
||||
http://example.com/scripts/site.js
|
||||
|
||||
You can combine these files through Minify by requesting this URL:
|
||||
http://example.com/min/?f=scripts/jquery-1.2.6.js,scripts/site.js
|
||||
|
||||
|
||||
SIMPLIFYING URLS WITH A BASE PATH
|
||||
|
||||
If you're combining files that share the same ancestor directory, you can use
|
||||
the "b" argument to set the base directory for the "f" argument. Do not include
|
||||
the leading or trailing "/" characters.
|
||||
|
||||
E.g., the following URLs will serve the exact same content:
|
||||
http://example.com/min/?f=scripts/jquery-1.2.6.js,scripts/site.js,scripts/home.js
|
||||
http://example.com/min/?b=scripts&f=jquery-1.2.6.js,site.js,home.js
|
||||
|
||||
|
||||
MINIFY URLS IN HTML
|
||||
|
||||
In HTML files, don't forget to replace any "&" characters with "&".
|
||||
|
||||
|
||||
SPECIFYING ALLOWED DIRECTORIES
|
||||
|
||||
By default, Minify will serve any *.css/*.js files within the DOCUMENT_ROOT. If
|
||||
you'd prefer to limit Minify's access to certain directories, set the
|
||||
$min_serveOptions['minApp']['allowDirs'] array in config.php. E.g. to limit
|
||||
to the /js and /themes/default directories, use:
|
||||
|
||||
$min_serveOptions['minApp']['allowDirs'] = array('//js', '//themes/default');
|
||||
|
||||
|
||||
GROUPS: NICER URLS
|
||||
|
||||
For nicer URLs, edit groupsConfig.php to pre-specify groups of files
|
||||
to be combined under preset keys. E.g., here's an example configuration in
|
||||
groupsConfig.php:
|
||||
|
||||
return array(
|
||||
'js' => array('//js/Class.js', '//js/email.js')
|
||||
);
|
||||
|
||||
This pre-selects the following files to be combined under the key "js":
|
||||
http://example.com/js/Class.js
|
||||
http://example.com/js/email.js
|
||||
|
||||
You can now serve these files with this simple URL:
|
||||
http://example.com/min/?g=js
|
||||
|
||||
|
||||
GROUPS: SPECIFYING FILES OUTSIDE THE DOC_ROOT
|
||||
|
||||
In the groupsConfig.php array, the "//" in the file paths is a shortcut for
|
||||
the DOCUMENT_ROOT, but you can also specify paths from the root of the filesystem
|
||||
or relative to the DOC_ROOT:
|
||||
|
||||
return array(
|
||||
'js' => array(
|
||||
'//js/file.js' // file within DOC_ROOT
|
||||
,'//../file.js' // file in parent directory of DOC_ROOT
|
||||
,'C:/Users/Steve/file.js' // file anywhere on filesystem
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
COMBINE MULTIPLE GROUPS AND FILES IN ONE URL
|
||||
|
||||
E.g.: http://example.com/min/?g=js&f=more/scripts.js
|
||||
|
||||
Separate group keys with commas:
|
||||
http://example.com/min/?g=baseCss,css1&f=moreStyles.css
|
||||
|
||||
|
||||
FAR-FUTURE EXPIRES HEADERS
|
||||
|
||||
Minify can send far-future (one year) Expires headers. To enable this you must
|
||||
add a number or the parameter "v" to the querystring (e.g. /min/?g=js&1234 or
|
||||
/min/?g=js&v=1234) and alter it whenever a source file is changed. If you have a
|
||||
build process you can use a build/source control revision number.
|
||||
|
||||
You can alternately use the utility function Minify_getUri() to get a "versioned"
|
||||
Minify URI for use in your HTML. E.g.:
|
||||
|
||||
<?php
|
||||
require $_SERVER['DOCUMENT_ROOT'] . '/min/utils.php';
|
||||
|
||||
$jsUri = Minify_getUri('js'); // a key in groupsConfig.php
|
||||
echo "<script src='{$jsUri}'></script>";
|
||||
|
||||
$cssUri = Minify_getUri(array(
|
||||
'//css/styles1.css'
|
||||
,'//css/styles2.css'
|
||||
)); // a list of files
|
||||
echo "<link rel=stylesheet href='{$cssUri}'>";
|
||||
|
||||
|
||||
STORING CONFIG FILES OUTSIDE THE MINIFY DIRECTORY
|
||||
|
||||
It is possible to store config files (min/config.php, min/config-test.php,
|
||||
min/groupsConfig.php) in a custom directory outside the Minify directory. This is
|
||||
useful if you wish to include Minify as an external dependency inside another
|
||||
project via SVN external or Git submodule inclusion.
|
||||
|
||||
For example, let's assume you have a Minify directory "min" in your site root. Then
|
||||
you could create a new directory called "min-configs" in the site root. Copy any
|
||||
config files you wish to modify to "min-configs", and modify as desired.
|
||||
|
||||
Then create a new file, for example "min.php" in your site root. The contents of
|
||||
this file could look like this:
|
||||
|
||||
<?php
|
||||
$customConfigDirectory = dirname(__FILE__) . '/min-configs';
|
||||
$min_customConfigPaths = array(
|
||||
'base' => $customConfigDirectory . '/config.php',
|
||||
'test' => $customConfigDirectory . '/config-test.php',
|
||||
'groups' => $customConfigDirectory . '/groupsConfig.php'
|
||||
);
|
||||
|
||||
include_once 'min/index.php';
|
||||
|
||||
You would then reference min.php in your JS and CSS links instead of min/index.php.
|
||||
|
||||
This method will affect those using the Minify_getUri() function. You will need
|
||||
to add options to calls to that function, e.g.:
|
||||
|
||||
<?php
|
||||
require $_SERVER['DOCUMENT_ROOT'] . '/min/utils.php';
|
||||
|
||||
$jsUri = Minify_getUri('//js/file.js', array('minAppUri' => '/min.php'));
|
||||
echo "<script src='{$jsUri}'></script>";
|
||||
|
||||
|
||||
DEBUG MODE
|
||||
|
||||
In debug mode, instead of compressing files, Minify sends combined files with
|
||||
comments prepended to each line to show the line number in the original source
|
||||
file. To enable this, set $min_allowDebugFlag to true in config.php and append
|
||||
"&debug=1" to your URIs. E.g. /min/?f=script1.js,script2.js&debug=1
|
||||
|
||||
Known issue: files with comment-like strings/regexps can cause problems in this mode.
|
||||
|
||||
|
||||
QUESTIONS?
|
||||
|
||||
http://groups.google.com/group/minify
|
||||
68
vendor/mrclay/minify/README.txt
vendored
68
vendor/mrclay/minify/README.txt
vendored
@@ -1,68 +0,0 @@
|
||||
WELCOME TO MINIFY!
|
||||
|
||||
Minify is an HTTP content server. It compresses sources of content
|
||||
(usually files), combines the result and serves it with appropriate
|
||||
HTTP headers. These headers can allow clients to perform conditional
|
||||
GETs (serving content only when clients do not have a valid cache)
|
||||
and tell clients to cache the file for a period of time.
|
||||
More info: http://code.google.com/p/minify/
|
||||
|
||||
|
||||
WORDPRESS USER?
|
||||
|
||||
These WP plugins integrate Minify into WordPress's style and script hooks to
|
||||
get you set up faster.
|
||||
http://wordpress.org/extend/plugins/bwp-minify/
|
||||
http://wordpress.org/extend/plugins/w3-total-cache/
|
||||
|
||||
|
||||
INSTALLATION
|
||||
|
||||
Place the /min/ directory as a child of your DOCUMENT_ROOT
|
||||
directory: i.e. you will have: /home/example/www/min
|
||||
|
||||
You can see verify that it is working by visiting these two URLs:
|
||||
http://example.org/min/?f=min/quick-test.js
|
||||
http://example.org/min/?f=min/quick-test.css
|
||||
|
||||
If your server supports mod_rewrite, this URL should also work:
|
||||
http://example.org/min/f=min/quick-test.js
|
||||
|
||||
CONFIGURATION & USAGE
|
||||
|
||||
See the MIN.txt file and http://code.google.com/p/minify/wiki/UserGuide
|
||||
|
||||
Minify also comes with a URI Builder application that can help you write URLs
|
||||
for use with Minify or configure groups of files. See here for details:
|
||||
http://code.google.com/p/minify/wiki/BuilderApp
|
||||
|
||||
The cookbook also provides some more advanced options for minification:
|
||||
http://code.google.com/p/minify/wiki/CookBook
|
||||
|
||||
UPGRADING
|
||||
|
||||
See UPGRADING.txt for instructions.
|
||||
|
||||
|
||||
UNIT TESTING:
|
||||
|
||||
1. Place the /min_unit_tests/ directory as a child of your DOCUMENT_ROOT
|
||||
directory: i.e. you will have: /home/example/www/min_unit_tests
|
||||
|
||||
2. To run unit tests, access: http://example.org/min_unit_tests/test_all.php
|
||||
|
||||
(If you wish, the other test_*.php files can be run to test individual
|
||||
components with more verbose output.)
|
||||
|
||||
3. Remove /min_unit_tests/ from your DOCUMENT_ROOT when you are done.
|
||||
|
||||
|
||||
FILE ENCODINGS
|
||||
|
||||
Minify *should* work fine with files encoded in UTF-8 or other 8-bit
|
||||
encodings like ISO 8859/Windows-1252. By default Minify appends
|
||||
";charset=utf-8" to the Content-Type headers it sends.
|
||||
|
||||
Leading UTF-8 BOMs are stripped from all sources to prevent
|
||||
duplication in output files, and files are converted to Unix newlines.
|
||||
|
||||
28
vendor/mrclay/minify/UPGRADING.txt
vendored
28
vendor/mrclay/minify/UPGRADING.txt
vendored
@@ -1,28 +0,0 @@
|
||||
Minify Upgrade Guide
|
||||
|
||||
UPGRADING FROM 2.1.*
|
||||
|
||||
1. Rename the following files:
|
||||
|
||||
/min/config.php --> /min/old_config.php
|
||||
/min/groupsConfig.php --> /min/old_groupsConfig.php
|
||||
|
||||
2. Overwrite all files in /min (and /min_unit_tests) with those from this zip.
|
||||
|
||||
3. Delete /min/groupsConfig.php
|
||||
|
||||
4. Rename /min/old_groupsConfig.php --> /min/groupsConfig.php
|
||||
|
||||
5. Merge your settings in old_config.php into config.php.
|
||||
|
||||
6. (optional) Delete /min/old_config.php.
|
||||
|
||||
|
||||
INSTALLING FRESH
|
||||
|
||||
See README.txt for instructions on installing this app for the first time.
|
||||
|
||||
|
||||
SUPPORT
|
||||
|
||||
Send a message to http://groups.google.com/group/minify
|
||||
779
vendor/mrclay/minify/min/lib/CSSmin.php
vendored
779
vendor/mrclay/minify/min/lib/CSSmin.php
vendored
@@ -1,779 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*!
|
||||
* cssmin.php 2.4.8-2
|
||||
* Author: Tubal Martin - http://tubalmartin.me/
|
||||
* Repo: https://github.com/tubalmartin/YUI-CSS-compressor-PHP-port
|
||||
*
|
||||
* This is a PHP port of the CSS minification tool distributed with YUICompressor,
|
||||
* itself a port of the cssmin utility by Isaac Schlueter - http://foohack.com/
|
||||
* Permission is hereby granted to use the PHP version under the same
|
||||
* conditions as the YUICompressor.
|
||||
*/
|
||||
|
||||
/*!
|
||||
* YUI Compressor
|
||||
* http://developer.yahoo.com/yui/compressor/
|
||||
* Author: Julien Lecomte - http://www.julienlecomte.net/
|
||||
* Copyright (c) 2013 Yahoo! Inc. All rights reserved.
|
||||
* The copyrights embodied in the content of this file are licensed
|
||||
* by Yahoo! Inc. under the BSD (revised) open source license.
|
||||
*/
|
||||
|
||||
class CSSmin
|
||||
{
|
||||
const NL = '___YUICSSMIN_PRESERVED_NL___';
|
||||
const TOKEN = '___YUICSSMIN_PRESERVED_TOKEN_';
|
||||
const COMMENT = '___YUICSSMIN_PRESERVE_CANDIDATE_COMMENT_';
|
||||
const CLASSCOLON = '___YUICSSMIN_PSEUDOCLASSCOLON___';
|
||||
const QUERY_FRACTION = '___YUICSSMIN_QUERY_FRACTION___';
|
||||
|
||||
private $comments;
|
||||
private $preserved_tokens;
|
||||
private $memory_limit;
|
||||
private $max_execution_time;
|
||||
private $pcre_backtrack_limit;
|
||||
private $pcre_recursion_limit;
|
||||
private $raise_php_limits;
|
||||
|
||||
/**
|
||||
* @param bool|int $raise_php_limits
|
||||
* If true, PHP settings will be raised if needed
|
||||
*/
|
||||
public function __construct($raise_php_limits = TRUE)
|
||||
{
|
||||
// Set suggested PHP limits
|
||||
$this->memory_limit = 128 * 1048576; // 128MB in bytes
|
||||
$this->max_execution_time = 60; // 1 min
|
||||
$this->pcre_backtrack_limit = 1000 * 1000;
|
||||
$this->pcre_recursion_limit = 500 * 1000;
|
||||
|
||||
$this->raise_php_limits = (bool) $raise_php_limits;
|
||||
}
|
||||
|
||||
/**
|
||||
* Minify a string of CSS
|
||||
* @param string $css
|
||||
* @param int|bool $linebreak_pos
|
||||
* @return string
|
||||
*/
|
||||
public function run($css = '', $linebreak_pos = FALSE)
|
||||
{
|
||||
if (empty($css)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if ($this->raise_php_limits) {
|
||||
$this->do_raise_php_limits();
|
||||
}
|
||||
|
||||
$this->comments = array();
|
||||
$this->preserved_tokens = array();
|
||||
|
||||
$start_index = 0;
|
||||
$length = strlen($css);
|
||||
|
||||
$css = $this->extract_data_urls($css);
|
||||
|
||||
// collect all comment blocks...
|
||||
while (($start_index = $this->index_of($css, '/*', $start_index)) >= 0) {
|
||||
$end_index = $this->index_of($css, '*/', $start_index + 2);
|
||||
if ($end_index < 0) {
|
||||
$end_index = $length;
|
||||
}
|
||||
$comment_found = $this->str_slice($css, $start_index + 2, $end_index);
|
||||
$this->comments[] = $comment_found;
|
||||
$comment_preserve_string = self::COMMENT . (count($this->comments) - 1) . '___';
|
||||
$css = $this->str_slice($css, 0, $start_index + 2) . $comment_preserve_string . $this->str_slice($css, $end_index);
|
||||
// Set correct start_index: Fixes issue #2528130
|
||||
$start_index = $end_index + 2 + strlen($comment_preserve_string) - strlen($comment_found);
|
||||
}
|
||||
|
||||
// preserve strings so their content doesn't get accidentally minified
|
||||
$css = preg_replace_callback('/(?:"(?:[^\\\\"]|\\\\.|\\\\)*")|'."(?:'(?:[^\\\\']|\\\\.|\\\\)*')/S", array($this, 'replace_string'), $css);
|
||||
|
||||
// Let's divide css code in chunks of 5.000 chars aprox.
|
||||
// Reason: PHP's PCRE functions like preg_replace have a "backtrack limit"
|
||||
// of 100.000 chars by default (php < 5.3.7) so if we're dealing with really
|
||||
// long strings and a (sub)pattern matches a number of chars greater than
|
||||
// the backtrack limit number (i.e. /(.*)/s) PCRE functions may fail silently
|
||||
// returning NULL and $css would be empty.
|
||||
$charset = '';
|
||||
$charset_regexp = '/(@charset)( [^;]+;)/i';
|
||||
$css_chunks = array();
|
||||
$css_chunk_length = 5000; // aprox size, not exact
|
||||
$start_index = 0;
|
||||
$i = $css_chunk_length; // save initial iterations
|
||||
$l = strlen($css);
|
||||
|
||||
|
||||
// if the number of characters is 25000 or less, do not chunk
|
||||
if ($l <= $css_chunk_length) {
|
||||
$css_chunks[] = $css;
|
||||
} else {
|
||||
// chunk css code securely
|
||||
while ($i < $l) {
|
||||
$i += 50; // save iterations
|
||||
if ($l - $start_index <= $css_chunk_length || $i >= $l) {
|
||||
$css_chunks[] = $this->str_slice($css, $start_index);
|
||||
break;
|
||||
}
|
||||
if ($css[$i - 1] === '}' && $i - $start_index > $css_chunk_length) {
|
||||
// If there are two ending curly braces }} separated or not by spaces,
|
||||
// join them in the same chunk (i.e. @media blocks)
|
||||
$next_chunk = substr($css, $i);
|
||||
if (preg_match('/^\s*\}/', $next_chunk)) {
|
||||
$i = $i + $this->index_of($next_chunk, '}') + 1;
|
||||
}
|
||||
|
||||
$css_chunks[] = $this->str_slice($css, $start_index, $i);
|
||||
$start_index = $i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Minify each chunk
|
||||
for ($i = 0, $n = count($css_chunks); $i < $n; $i++) {
|
||||
$css_chunks[$i] = $this->minify($css_chunks[$i], $linebreak_pos);
|
||||
// Keep the first @charset at-rule found
|
||||
if (empty($charset) && preg_match($charset_regexp, $css_chunks[$i], $matches)) {
|
||||
$charset = strtolower($matches[1]) . $matches[2];
|
||||
}
|
||||
// Delete all @charset at-rules
|
||||
$css_chunks[$i] = preg_replace($charset_regexp, '', $css_chunks[$i]);
|
||||
}
|
||||
|
||||
// Update the first chunk and push the charset to the top of the file.
|
||||
$css_chunks[0] = $charset . $css_chunks[0];
|
||||
|
||||
return implode('', $css_chunks);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the memory limit for this script
|
||||
* @param int|string $limit
|
||||
*/
|
||||
public function set_memory_limit($limit)
|
||||
{
|
||||
$this->memory_limit = $this->normalize_int($limit);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the maximum execution time for this script
|
||||
* @param int|string $seconds
|
||||
*/
|
||||
public function set_max_execution_time($seconds)
|
||||
{
|
||||
$this->max_execution_time = (int) $seconds;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the PCRE backtrack limit for this script
|
||||
* @param int $limit
|
||||
*/
|
||||
public function set_pcre_backtrack_limit($limit)
|
||||
{
|
||||
$this->pcre_backtrack_limit = (int) $limit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the PCRE recursion limit for this script
|
||||
* @param int $limit
|
||||
*/
|
||||
public function set_pcre_recursion_limit($limit)
|
||||
{
|
||||
$this->pcre_recursion_limit = (int) $limit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Try to configure PHP to use at least the suggested minimum settings
|
||||
*/
|
||||
private function do_raise_php_limits()
|
||||
{
|
||||
$php_limits = array(
|
||||
'memory_limit' => $this->memory_limit,
|
||||
'max_execution_time' => $this->max_execution_time,
|
||||
'pcre.backtrack_limit' => $this->pcre_backtrack_limit,
|
||||
'pcre.recursion_limit' => $this->pcre_recursion_limit
|
||||
);
|
||||
|
||||
// If current settings are higher respect them.
|
||||
foreach ($php_limits as $name => $suggested) {
|
||||
$current = $this->normalize_int(ini_get($name));
|
||||
// memory_limit exception: allow -1 for "no memory limit".
|
||||
if ($current > -1 && ($suggested == -1 || $current < $suggested)) {
|
||||
ini_set($name, $suggested);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Does bulk of the minification
|
||||
* @param string $css
|
||||
* @param int|bool $linebreak_pos
|
||||
* @return string
|
||||
*/
|
||||
private function minify($css, $linebreak_pos)
|
||||
{
|
||||
// strings are safe, now wrestle the comments
|
||||
for ($i = 0, $max = count($this->comments); $i < $max; $i++) {
|
||||
|
||||
$token = $this->comments[$i];
|
||||
$placeholder = '/' . self::COMMENT . $i . '___/';
|
||||
|
||||
// ! in the first position of the comment means preserve
|
||||
// so push to the preserved tokens keeping the !
|
||||
if (substr($token, 0, 1) === '!') {
|
||||
$this->preserved_tokens[] = $token;
|
||||
$token_tring = self::TOKEN . (count($this->preserved_tokens) - 1) . '___';
|
||||
$css = preg_replace($placeholder, $token_tring, $css, 1);
|
||||
// Preserve new lines for /*! important comments
|
||||
$css = preg_replace('/\s*[\n\r\f]+\s*(\/\*'. $token_tring .')/S', self::NL.'$1', $css);
|
||||
$css = preg_replace('/('. $token_tring .'\*\/)\s*[\n\r\f]+\s*/', '$1'.self::NL, $css);
|
||||
continue;
|
||||
}
|
||||
|
||||
// \ in the last position looks like hack for Mac/IE5
|
||||
// shorten that to /*\*/ and the next one to /**/
|
||||
if (substr($token, (strlen($token) - 1), 1) === '\\') {
|
||||
$this->preserved_tokens[] = '\\';
|
||||
$css = preg_replace($placeholder, self::TOKEN . (count($this->preserved_tokens) - 1) . '___', $css, 1);
|
||||
$i = $i + 1; // attn: advancing the loop
|
||||
$this->preserved_tokens[] = '';
|
||||
$css = preg_replace('/' . self::COMMENT . $i . '___/', self::TOKEN . (count($this->preserved_tokens) - 1) . '___', $css, 1);
|
||||
continue;
|
||||
}
|
||||
|
||||
// keep empty comments after child selectors (IE7 hack)
|
||||
// e.g. html >/**/ body
|
||||
if (strlen($token) === 0) {
|
||||
$start_index = $this->index_of($css, $this->str_slice($placeholder, 1, -1));
|
||||
if ($start_index > 2) {
|
||||
if (substr($css, $start_index - 3, 1) === '>') {
|
||||
$this->preserved_tokens[] = '';
|
||||
$css = preg_replace($placeholder, self::TOKEN . (count($this->preserved_tokens) - 1) . '___', $css, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// in all other cases kill the comment
|
||||
$css = preg_replace('/\/\*' . $this->str_slice($placeholder, 1, -1) . '\*\//', '', $css, 1);
|
||||
}
|
||||
|
||||
|
||||
// Normalize all whitespace strings to single spaces. Easier to work with that way.
|
||||
$css = preg_replace('/\s+/', ' ', $css);
|
||||
|
||||
// Fix IE7 issue on matrix filters which browser accept whitespaces between Matrix parameters
|
||||
$css = preg_replace_callback('/\s*filter\:\s*progid:DXImageTransform\.Microsoft\.Matrix\(([^\)]+)\)/', array($this, 'preserve_old_IE_specific_matrix_definition'), $css);
|
||||
|
||||
// Shorten & preserve calculations calc(...) since spaces are important
|
||||
$css = preg_replace_callback('/calc(\(((?:[^\(\)]+|(?1))*)\))/i', array($this, 'replace_calc'), $css);
|
||||
|
||||
// Replace positive sign from numbers preceded by : or a white-space before the leading space is removed
|
||||
// +1.2em to 1.2em, +.8px to .8px, +2% to 2%
|
||||
$css = preg_replace('/((?<!\\\\)\:|\s)\+(\.?\d+)/S', '$1$2', $css);
|
||||
|
||||
// Remove leading zeros from integer and float numbers preceded by : or a white-space
|
||||
// 000.6 to .6, -0.8 to -.8, 0050 to 50, -01.05 to -1.05
|
||||
$css = preg_replace('/((?<!\\\\)\:|\s)(\-?)0+(\.?\d+)/S', '$1$2$3', $css);
|
||||
|
||||
// Remove trailing zeros from float numbers preceded by : or a white-space
|
||||
// -6.0100em to -6.01em, .0100 to .01, 1.200px to 1.2px
|
||||
$css = preg_replace('/((?<!\\\\)\:|\s)(\-?)(\d?\.\d+?)0+([^\d])/S', '$1$2$3$4', $css);
|
||||
|
||||
// Remove trailing .0 -> -9.0 to -9
|
||||
$css = preg_replace('/((?<!\\\\)\:|\s)(\-?\d+)\.0([^\d])/S', '$1$2$3', $css);
|
||||
|
||||
// Replace 0 length numbers with 0
|
||||
$css = preg_replace('/((?<!\\\\)\:|\s)\-?\.?0+([^\d])/S', '${1}0$2', $css);
|
||||
|
||||
// Remove the spaces before the things that should not have spaces before them.
|
||||
// But, be careful not to turn "p :link {...}" into "p:link{...}"
|
||||
// Swap out any pseudo-class colons with the token, and then swap back.
|
||||
$css = preg_replace_callback('/(?:^|\})(?:(?:[^\{\:])+\:)+(?:[^\{]*\{)/', array($this, 'replace_colon'), $css);
|
||||
|
||||
// Remove spaces before the things that should not have spaces before them.
|
||||
$css = preg_replace('/\s+([\!\{\}\;\:\>\+\(\)\]\~\=,])/', '$1', $css);
|
||||
|
||||
// Restore spaces for !important
|
||||
$css = preg_replace('/\!important/i', ' !important', $css);
|
||||
|
||||
// bring back the colon
|
||||
$css = preg_replace('/' . self::CLASSCOLON . '/', ':', $css);
|
||||
|
||||
// retain space for special IE6 cases
|
||||
$css = preg_replace_callback('/\:first\-(line|letter)(\{|,)/i', array($this, 'lowercase_pseudo_first'), $css);
|
||||
|
||||
// no space after the end of a preserved comment
|
||||
$css = preg_replace('/\*\/ /', '*/', $css);
|
||||
|
||||
// lowercase some popular @directives
|
||||
$css = preg_replace_callback('/@(font-face|import|(?:-(?:atsc|khtml|moz|ms|o|wap|webkit)-)?keyframe|media|page|namespace)/i', array($this, 'lowercase_directives'), $css);
|
||||
|
||||
// lowercase some more common pseudo-elements
|
||||
$css = preg_replace_callback('/:(active|after|before|checked|disabled|empty|enabled|first-(?:child|of-type)|focus|hover|last-(?:child|of-type)|link|only-(?:child|of-type)|root|:selection|target|visited)/i', array($this, 'lowercase_pseudo_elements'), $css);
|
||||
|
||||
// lowercase some more common functions
|
||||
$css = preg_replace_callback('/:(lang|not|nth-child|nth-last-child|nth-last-of-type|nth-of-type|(?:-(?:moz|webkit)-)?any)\(/i', array($this, 'lowercase_common_functions'), $css);
|
||||
|
||||
// lower case some common function that can be values
|
||||
// NOTE: rgb() isn't useful as we replace with #hex later, as well as and() is already done for us
|
||||
$css = preg_replace_callback('/([:,\( ]\s*)(attr|color-stop|from|rgba|to|url|(?:-(?:atsc|khtml|moz|ms|o|wap|webkit)-)?(?:calc|max|min|(?:repeating-)?(?:linear|radial)-gradient)|-webkit-gradient)/iS', array($this, 'lowercase_common_functions_values'), $css);
|
||||
|
||||
// Put the space back in some cases, to support stuff like
|
||||
// @media screen and (-webkit-min-device-pixel-ratio:0){
|
||||
$css = preg_replace('/\band\(/i', 'and (', $css);
|
||||
|
||||
// Put the space back in for @support tag
|
||||
// @supports (display: flex) and @supports not (display: flex)
|
||||
$css = preg_replace('/\b(supports|not)\(/i', '$1 (', $css);
|
||||
|
||||
// Remove the spaces after the things that should not have spaces after them.
|
||||
$css = preg_replace('/([\!\{\}\:;\>\+\(\[\~\=,])\s+/S', '$1', $css);
|
||||
|
||||
// remove unnecessary semicolons
|
||||
$css = preg_replace('/;+\}/', '}', $css);
|
||||
|
||||
// Fix for issue: #2528146
|
||||
// Restore semicolon if the last property is prefixed with a `*` (lte IE7 hack)
|
||||
// to avoid issues on Symbian S60 3.x browsers.
|
||||
$css = preg_replace('/(\*[a-z0-9\-]+\s*\:[^;\}]+)(\})/', '$1;$2', $css);
|
||||
|
||||
// Replace 0 length units 0(px,em,%) with 0.
|
||||
$css = preg_replace('/(^|[^0-9])(?:0?\.)?0(?:em|ex|ch|rem|vw|vh|vm|vmin|cm|mm|in|px|pt|pc|%|deg|g?rad|m?s|k?hz)/iS', '${1}0', $css);
|
||||
|
||||
// 0% step in a keyframe? restore the % unit
|
||||
$css = preg_replace_callback('/(@[a-z\-]*?keyframes[^\{]*?\{)(.*?\}\s*\})/iS', array($this, 'replace_keyframe_zero'), $css);
|
||||
|
||||
// Replace 0 0; or 0 0 0; or 0 0 0 0; with 0.
|
||||
$css = preg_replace('/\:0(?: 0){1,3}(;|\}| \!)/', ':0$1', $css);
|
||||
|
||||
// Fix for issue: #2528142
|
||||
// Replace text-shadow:0; with text-shadow:0 0 0;
|
||||
$css = preg_replace('/(text-shadow\:0)(;|\}| \!)/i', '$1 0 0$2', $css);
|
||||
|
||||
// Replace background-position:0; with background-position:0 0;
|
||||
// same for transform-origin
|
||||
// Changing -webkit-mask-position: 0 0 to just a single 0 will result in the second parameter defaulting to 50% (center)
|
||||
$css = preg_replace('/(background\-position|webkit-mask-position|(?:webkit|moz|o|ms|)\-?transform\-origin)\:0(;|\}| \!)/iS', '$1:0 0$2', $css);
|
||||
|
||||
// Shorten colors from rgb(51,102,153) to #336699, rgb(100%,0%,0%) to #ff0000 (sRGB color space)
|
||||
// Shorten colors from hsl(0, 100%, 50%) to #ff0000 (sRGB color space)
|
||||
// This makes it more likely that it'll get further compressed in the next step.
|
||||
$css = preg_replace_callback('/rgb\s*\(\s*([0-9,\s\-\.\%]+)\s*\)(.{1})/i', array($this, 'rgb_to_hex'), $css);
|
||||
$css = preg_replace_callback('/hsl\s*\(\s*([0-9,\s\-\.\%]+)\s*\)(.{1})/i', array($this, 'hsl_to_hex'), $css);
|
||||
|
||||
// Shorten colors from #AABBCC to #ABC or short color name.
|
||||
$css = $this->compress_hex_colors($css);
|
||||
|
||||
// border: none to border:0, outline: none to outline:0
|
||||
$css = preg_replace('/(border\-?(?:top|right|bottom|left|)|outline)\:none(;|\}| \!)/iS', '$1:0$2', $css);
|
||||
|
||||
// shorter opacity IE filter
|
||||
$css = preg_replace('/progid\:DXImageTransform\.Microsoft\.Alpha\(Opacity\=/i', 'alpha(opacity=', $css);
|
||||
|
||||
// Find a fraction that is used for Opera's -o-device-pixel-ratio query
|
||||
// Add token to add the "\" back in later
|
||||
$css = preg_replace('/\(([a-z\-]+):([0-9]+)\/([0-9]+)\)/i', '($1:$2'. self::QUERY_FRACTION .'$3)', $css);
|
||||
|
||||
// Remove empty rules.
|
||||
$css = preg_replace('/[^\};\{\/]+\{\}/S', '', $css);
|
||||
|
||||
// Add "/" back to fix Opera -o-device-pixel-ratio query
|
||||
$css = preg_replace('/'. self::QUERY_FRACTION .'/', '/', $css);
|
||||
|
||||
// Replace multiple semi-colons in a row by a single one
|
||||
// See SF bug #1980989
|
||||
$css = preg_replace('/;;+/', ';', $css);
|
||||
|
||||
// Restore new lines for /*! important comments
|
||||
$css = preg_replace('/'. self::NL .'/', "\n", $css);
|
||||
|
||||
// Lowercase all uppercase properties
|
||||
$css = preg_replace_callback('/(\{|\;)([A-Z\-]+)(\:)/', array($this, 'lowercase_properties'), $css);
|
||||
|
||||
// Some source control tools don't like it when files containing lines longer
|
||||
// than, say 8000 characters, are checked in. The linebreak option is used in
|
||||
// that case to split long lines after a specific column.
|
||||
if ($linebreak_pos !== FALSE && (int) $linebreak_pos >= 0) {
|
||||
$linebreak_pos = (int) $linebreak_pos;
|
||||
$start_index = $i = 0;
|
||||
while ($i < strlen($css)) {
|
||||
$i++;
|
||||
if ($css[$i - 1] === '}' && $i - $start_index > $linebreak_pos) {
|
||||
$css = $this->str_slice($css, 0, $i) . "\n" . $this->str_slice($css, $i);
|
||||
$start_index = $i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// restore preserved comments and strings in reverse order
|
||||
for ($i = count($this->preserved_tokens) - 1; $i >= 0; $i--) {
|
||||
$css = preg_replace('/' . self::TOKEN . $i . '___/', $this->preserved_tokens[$i], $css, 1);
|
||||
}
|
||||
|
||||
// Trim the final string (for any leading or trailing white spaces)
|
||||
return trim($css);
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility method to replace all data urls with tokens before we start
|
||||
* compressing, to avoid performance issues running some of the subsequent
|
||||
* regexes against large strings chunks.
|
||||
*
|
||||
* @param string $css
|
||||
* @return string
|
||||
*/
|
||||
private function extract_data_urls($css)
|
||||
{
|
||||
// Leave data urls alone to increase parse performance.
|
||||
$max_index = strlen($css) - 1;
|
||||
$append_index = $index = $last_index = $offset = 0;
|
||||
$sb = array();
|
||||
$pattern = '/url\(\s*(["\']?)data\:/i';
|
||||
|
||||
// Since we need to account for non-base64 data urls, we need to handle
|
||||
// ' and ) being part of the data string. Hence switching to indexOf,
|
||||
// to determine whether or not we have matching string terminators and
|
||||
// handling sb appends directly, instead of using matcher.append* methods.
|
||||
|
||||
while (preg_match($pattern, $css, $m, 0, $offset)) {
|
||||
$index = $this->index_of($css, $m[0], $offset);
|
||||
$last_index = $index + strlen($m[0]);
|
||||
$start_index = $index + 4; // "url(".length()
|
||||
$end_index = $last_index - 1;
|
||||
$terminator = $m[1]; // ', " or empty (not quoted)
|
||||
$found_terminator = FALSE;
|
||||
|
||||
if (strlen($terminator) === 0) {
|
||||
$terminator = ')';
|
||||
}
|
||||
|
||||
while ($found_terminator === FALSE && $end_index+1 <= $max_index) {
|
||||
$end_index = $this->index_of($css, $terminator, $end_index + 1);
|
||||
|
||||
// endIndex == 0 doesn't really apply here
|
||||
if ($end_index > 0 && substr($css, $end_index - 1, 1) !== '\\') {
|
||||
$found_terminator = TRUE;
|
||||
if (')' != $terminator) {
|
||||
$end_index = $this->index_of($css, ')', $end_index);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Enough searching, start moving stuff over to the buffer
|
||||
$sb[] = $this->str_slice($css, $append_index, $index);
|
||||
|
||||
if ($found_terminator) {
|
||||
$token = $this->str_slice($css, $start_index, $end_index);
|
||||
$token = preg_replace('/\s+/', '', $token);
|
||||
$this->preserved_tokens[] = $token;
|
||||
|
||||
$preserver = 'url(' . self::TOKEN . (count($this->preserved_tokens) - 1) . '___)';
|
||||
$sb[] = $preserver;
|
||||
|
||||
$append_index = $end_index + 1;
|
||||
} else {
|
||||
// No end terminator found, re-add the whole match. Should we throw/warn here?
|
||||
$sb[] = $this->str_slice($css, $index, $last_index);
|
||||
$append_index = $last_index;
|
||||
}
|
||||
|
||||
$offset = $last_index;
|
||||
}
|
||||
|
||||
$sb[] = $this->str_slice($css, $append_index);
|
||||
|
||||
return implode('', $sb);
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility method to compress hex color values of the form #AABBCC to #ABC or short color name.
|
||||
*
|
||||
* DOES NOT compress CSS ID selectors which match the above pattern (which would break things).
|
||||
* e.g. #AddressForm { ... }
|
||||
*
|
||||
* DOES NOT compress IE filters, which have hex color values (which would break things).
|
||||
* e.g. filter: chroma(color="#FFFFFF");
|
||||
*
|
||||
* DOES NOT compress invalid hex values.
|
||||
* e.g. background-color: #aabbccdd
|
||||
*
|
||||
* @param string $css
|
||||
* @return string
|
||||
*/
|
||||
private function compress_hex_colors($css)
|
||||
{
|
||||
// Look for hex colors inside { ... } (to avoid IDs) and which don't have a =, or a " in front of them (to avoid filters)
|
||||
$pattern = '/(\=\s*?["\']?)?#([0-9a-f])([0-9a-f])([0-9a-f])([0-9a-f])([0-9a-f])([0-9a-f])(\}|[^0-9a-f{][^{]*?\})/iS';
|
||||
$_index = $index = $last_index = $offset = 0;
|
||||
$sb = array();
|
||||
// See: http://ajaxmin.codeplex.com/wikipage?title=CSS%20Colors
|
||||
$short_safe = array(
|
||||
'#808080' => 'gray',
|
||||
'#008000' => 'green',
|
||||
'#800000' => 'maroon',
|
||||
'#000080' => 'navy',
|
||||
'#808000' => 'olive',
|
||||
'#ffa500' => 'orange',
|
||||
'#800080' => 'purple',
|
||||
'#c0c0c0' => 'silver',
|
||||
'#008080' => 'teal',
|
||||
'#f00' => 'red'
|
||||
);
|
||||
|
||||
while (preg_match($pattern, $css, $m, 0, $offset)) {
|
||||
$index = $this->index_of($css, $m[0], $offset);
|
||||
$last_index = $index + strlen($m[0]);
|
||||
$is_filter = $m[1] !== null && $m[1] !== '';
|
||||
|
||||
$sb[] = $this->str_slice($css, $_index, $index);
|
||||
|
||||
if ($is_filter) {
|
||||
// Restore, maintain case, otherwise filter will break
|
||||
$sb[] = $m[1] . '#' . $m[2] . $m[3] . $m[4] . $m[5] . $m[6] . $m[7];
|
||||
} else {
|
||||
if (strtolower($m[2]) == strtolower($m[3]) &&
|
||||
strtolower($m[4]) == strtolower($m[5]) &&
|
||||
strtolower($m[6]) == strtolower($m[7])) {
|
||||
// Compress.
|
||||
$hex = '#' . strtolower($m[3] . $m[5] . $m[7]);
|
||||
} else {
|
||||
// Non compressible color, restore but lower case.
|
||||
$hex = '#' . strtolower($m[2] . $m[3] . $m[4] . $m[5] . $m[6] . $m[7]);
|
||||
}
|
||||
// replace Hex colors to short safe color names
|
||||
$sb[] = array_key_exists($hex, $short_safe) ? $short_safe[$hex] : $hex;
|
||||
}
|
||||
|
||||
$_index = $offset = $last_index - strlen($m[8]);
|
||||
}
|
||||
|
||||
$sb[] = $this->str_slice($css, $_index);
|
||||
|
||||
return implode('', $sb);
|
||||
}
|
||||
|
||||
/* CALLBACKS
|
||||
* ---------------------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private function replace_string($matches)
|
||||
{
|
||||
$match = $matches[0];
|
||||
$quote = substr($match, 0, 1);
|
||||
// Must use addcslashes in PHP to avoid parsing of backslashes
|
||||
$match = addcslashes($this->str_slice($match, 1, -1), '\\');
|
||||
|
||||
// maybe the string contains a comment-like substring?
|
||||
// one, maybe more? put'em back then
|
||||
if (($pos = $this->index_of($match, self::COMMENT)) >= 0) {
|
||||
for ($i = 0, $max = count($this->comments); $i < $max; $i++) {
|
||||
$match = preg_replace('/' . self::COMMENT . $i . '___/', $this->comments[$i], $match, 1);
|
||||
}
|
||||
}
|
||||
|
||||
// minify alpha opacity in filter strings
|
||||
$match = preg_replace('/progid\:DXImageTransform\.Microsoft\.Alpha\(Opacity\=/i', 'alpha(opacity=', $match);
|
||||
|
||||
$this->preserved_tokens[] = $match;
|
||||
return $quote . self::TOKEN . (count($this->preserved_tokens) - 1) . '___' . $quote;
|
||||
}
|
||||
|
||||
private function replace_colon($matches)
|
||||
{
|
||||
return preg_replace('/\:/', self::CLASSCOLON, $matches[0]);
|
||||
}
|
||||
|
||||
private function replace_calc($matches)
|
||||
{
|
||||
$this->preserved_tokens[] = trim(preg_replace('/\s*([\*\/\(\),])\s*/', '$1', $matches[2]));
|
||||
return 'calc('. self::TOKEN . (count($this->preserved_tokens) - 1) . '___' . ')';
|
||||
}
|
||||
|
||||
private function preserve_old_IE_specific_matrix_definition($matches)
|
||||
{
|
||||
$this->preserved_tokens[] = $matches[1];
|
||||
return 'filter:progid:DXImageTransform.Microsoft.Matrix(' . self::TOKEN . (count($this->preserved_tokens) - 1) . '___' . ')';
|
||||
}
|
||||
|
||||
private function replace_keyframe_zero($matches)
|
||||
{
|
||||
return $matches[1] . preg_replace('/0\s*,/', '0%,', preg_replace('/\s*0\s*\{/', '0%{', $matches[2]));
|
||||
}
|
||||
|
||||
private function rgb_to_hex($matches)
|
||||
{
|
||||
// Support for percentage values rgb(100%, 0%, 45%);
|
||||
if ($this->index_of($matches[1], '%') >= 0){
|
||||
$rgbcolors = explode(',', str_replace('%', '', $matches[1]));
|
||||
for ($i = 0; $i < count($rgbcolors); $i++) {
|
||||
$rgbcolors[$i] = $this->round_number(floatval($rgbcolors[$i]) * 2.55);
|
||||
}
|
||||
} else {
|
||||
$rgbcolors = explode(',', $matches[1]);
|
||||
}
|
||||
|
||||
// Values outside the sRGB color space should be clipped (0-255)
|
||||
for ($i = 0; $i < count($rgbcolors); $i++) {
|
||||
$rgbcolors[$i] = $this->clamp_number(intval($rgbcolors[$i], 10), 0, 255);
|
||||
$rgbcolors[$i] = sprintf("%02x", $rgbcolors[$i]);
|
||||
}
|
||||
|
||||
// Fix for issue #2528093
|
||||
if (!preg_match('/[\s\,\);\}]/', $matches[2])){
|
||||
$matches[2] = ' ' . $matches[2];
|
||||
}
|
||||
|
||||
return '#' . implode('', $rgbcolors) . $matches[2];
|
||||
}
|
||||
|
||||
private function hsl_to_hex($matches)
|
||||
{
|
||||
$values = explode(',', str_replace('%', '', $matches[1]));
|
||||
$h = floatval($values[0]);
|
||||
$s = floatval($values[1]);
|
||||
$l = floatval($values[2]);
|
||||
|
||||
// Wrap and clamp, then fraction!
|
||||
$h = ((($h % 360) + 360) % 360) / 360;
|
||||
$s = $this->clamp_number($s, 0, 100) / 100;
|
||||
$l = $this->clamp_number($l, 0, 100) / 100;
|
||||
|
||||
if ($s == 0) {
|
||||
$r = $g = $b = $this->round_number(255 * $l);
|
||||
} else {
|
||||
$v2 = $l < 0.5 ? $l * (1 + $s) : ($l + $s) - ($s * $l);
|
||||
$v1 = (2 * $l) - $v2;
|
||||
$r = $this->round_number(255 * $this->hue_to_rgb($v1, $v2, $h + (1/3)));
|
||||
$g = $this->round_number(255 * $this->hue_to_rgb($v1, $v2, $h));
|
||||
$b = $this->round_number(255 * $this->hue_to_rgb($v1, $v2, $h - (1/3)));
|
||||
}
|
||||
|
||||
return $this->rgb_to_hex(array('', $r.','.$g.','.$b, $matches[2]));
|
||||
}
|
||||
|
||||
private function lowercase_pseudo_first($matches)
|
||||
{
|
||||
return ':first-'. strtolower($matches[1]) .' '. $matches[2];
|
||||
}
|
||||
|
||||
private function lowercase_directives($matches)
|
||||
{
|
||||
return '@'. strtolower($matches[1]);
|
||||
}
|
||||
|
||||
private function lowercase_pseudo_elements($matches)
|
||||
{
|
||||
return ':'. strtolower($matches[1]);
|
||||
}
|
||||
|
||||
private function lowercase_common_functions($matches)
|
||||
{
|
||||
return ':'. strtolower($matches[1]) .'(';
|
||||
}
|
||||
|
||||
private function lowercase_common_functions_values($matches)
|
||||
{
|
||||
return $matches[1] . strtolower($matches[2]);
|
||||
}
|
||||
|
||||
private function lowercase_properties($matches)
|
||||
{
|
||||
return $matches[1].strtolower($matches[2]).$matches[3];
|
||||
}
|
||||
|
||||
/* HELPERS
|
||||
* ---------------------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private function hue_to_rgb($v1, $v2, $vh)
|
||||
{
|
||||
$vh = $vh < 0 ? $vh + 1 : ($vh > 1 ? $vh - 1 : $vh);
|
||||
if ($vh * 6 < 1) return $v1 + ($v2 - $v1) * 6 * $vh;
|
||||
if ($vh * 2 < 1) return $v2;
|
||||
if ($vh * 3 < 2) return $v1 + ($v2 - $v1) * ((2/3) - $vh) * 6;
|
||||
return $v1;
|
||||
}
|
||||
|
||||
private function round_number($n)
|
||||
{
|
||||
return intval(floor(floatval($n) + 0.5), 10);
|
||||
}
|
||||
|
||||
private function clamp_number($n, $min, $max)
|
||||
{
|
||||
return min(max($n, $min), $max);
|
||||
}
|
||||
|
||||
/**
|
||||
* PHP port of Javascript's "indexOf" function for strings only
|
||||
* Author: Tubal Martin http://blog.margenn.com
|
||||
*
|
||||
* @param string $haystack
|
||||
* @param string $needle
|
||||
* @param int $offset index (optional)
|
||||
* @return int
|
||||
*/
|
||||
private function index_of($haystack, $needle, $offset = 0)
|
||||
{
|
||||
$index = strpos($haystack, $needle, $offset);
|
||||
|
||||
return ($index !== FALSE) ? $index : -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* PHP port of Javascript's "slice" function for strings only
|
||||
* Author: Tubal Martin http://blog.margenn.com
|
||||
* Tests: http://margenn.com/tubal/str_slice/
|
||||
*
|
||||
* @param string $str
|
||||
* @param int $start index
|
||||
* @param int|bool $end index (optional)
|
||||
* @return string
|
||||
*/
|
||||
private function str_slice($str, $start = 0, $end = FALSE)
|
||||
{
|
||||
if ($end !== FALSE && ($start < 0 || $end <= 0)) {
|
||||
$max = strlen($str);
|
||||
|
||||
if ($start < 0) {
|
||||
if (($start = $max + $start) < 0) {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
if ($end < 0) {
|
||||
if (($end = $max + $end) < 0) {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
if ($end <= $start) {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
$slice = ($end === FALSE) ? substr($str, $start) : substr($str, $start, $end - $start);
|
||||
return ($slice === FALSE) ? '' : $slice;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert strings like "64M" or "30" to int values
|
||||
* @param mixed $size
|
||||
* @return int
|
||||
*/
|
||||
private function normalize_int($size)
|
||||
{
|
||||
if (is_string($size)) {
|
||||
switch (substr($size, -1)) {
|
||||
case 'M': case 'm': return $size * 1048576;
|
||||
case 'K': case 'k': return $size * 1024;
|
||||
case 'G': case 'g': return $size * 1073741824;
|
||||
}
|
||||
}
|
||||
|
||||
return (int) $size;
|
||||
}
|
||||
}
|
||||
121
vendor/mrclay/minify/min/lib/DooDigestAuth.php
vendored
121
vendor/mrclay/minify/min/lib/DooDigestAuth.php
vendored
@@ -1,121 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* DooDigestAuth class file.
|
||||
*
|
||||
* @author Leng Sheng Hong <darkredz@gmail.com>
|
||||
* @link http://www.doophp.com/
|
||||
* @copyright Copyright © 2009 Leng Sheng Hong
|
||||
* @license http://www.doophp.com/license
|
||||
*/
|
||||
|
||||
/**
|
||||
* Handles HTTP digest authentication
|
||||
*
|
||||
* <p>HTTP digest authentication can be used with the URI router.
|
||||
* HTTP digest is much more recommended over the use of HTTP Basic auth which doesn't provide any encryption.
|
||||
* If you are running PHP on Apache in CGI/FastCGI mode, you would need to
|
||||
* add the following line to your .htaccess for digest auth to work correctly.</p>
|
||||
* <code>RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]</code>
|
||||
*
|
||||
* <p>This class is tested under Apache 2.2 and Cherokee web server. It should work in both mod_php and cgi mode.</p>
|
||||
*
|
||||
* @author Leng Sheng Hong <darkredz@gmail.com>
|
||||
* @version $Id: DooDigestAuth.php 1000 2009-07-7 18:27:22
|
||||
* @package doo.auth
|
||||
* @since 1.0
|
||||
*/
|
||||
class DooDigestAuth{
|
||||
|
||||
/**
|
||||
* Authenticate against a list of username and passwords.
|
||||
*
|
||||
* <p>HTTP Digest Authentication doesn't work with PHP in CGI mode,
|
||||
* you have to add this into your .htaccess <code>RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]</code></p>
|
||||
*
|
||||
* @param string $realm Name of the authentication session
|
||||
* @param array $users An assoc array of username and password: array('uname1'=>'pwd1', 'uname2'=>'pwd2')
|
||||
* @param string $fail_msg Message to be displayed if the User cancel the login
|
||||
* @param string $fail_url URL to be redirect if the User cancel the login
|
||||
* @return string The username if login success.
|
||||
*/
|
||||
public static function http_auth($realm, $users, $fail_msg=NULL, $fail_url=NULL){
|
||||
$realm = "Restricted area - $realm";
|
||||
|
||||
//user => password
|
||||
//$users = array('admin' => '1234', 'guest' => 'guest');
|
||||
if(!empty($_SERVER['REDIRECT_HTTP_AUTHORIZATION']) && strpos($_SERVER['REDIRECT_HTTP_AUTHORIZATION'], 'Digest')===0){
|
||||
$_SERVER['PHP_AUTH_DIGEST'] = $_SERVER['REDIRECT_HTTP_AUTHORIZATION'];
|
||||
}
|
||||
|
||||
if (empty($_SERVER['PHP_AUTH_DIGEST'])) {
|
||||
header('WWW-Authenticate: Digest realm="'.$realm.
|
||||
'",qop="auth",nonce="'.uniqid().'",opaque="'.md5($realm).'"');
|
||||
header('HTTP/1.1 401 Unauthorized');
|
||||
if($fail_msg!=NULL)
|
||||
die($fail_msg);
|
||||
if($fail_url!=NULL)
|
||||
die("<script>window.location.href = '$fail_url'</script>");
|
||||
exit;
|
||||
}
|
||||
|
||||
// analyze the PHP_AUTH_DIGEST variable
|
||||
if (!($data = self::http_digest_parse($_SERVER['PHP_AUTH_DIGEST'])) || !isset($users[$data['username']])){
|
||||
header('WWW-Authenticate: Digest realm="'.$realm.
|
||||
'",qop="auth",nonce="'.uniqid().'",opaque="'.md5($realm).'"');
|
||||
header('HTTP/1.1 401 Unauthorized');
|
||||
if($fail_msg!=NULL)
|
||||
die($fail_msg);
|
||||
if($fail_url!=NULL)
|
||||
die("<script>window.location.href = '$fail_url'</script>");
|
||||
exit;
|
||||
}
|
||||
|
||||
// generate the valid response
|
||||
$A1 = md5($data['username'] . ':' . $realm . ':' . $users[$data['username']]);
|
||||
$A2 = md5($_SERVER['REQUEST_METHOD'].':'.$data['uri']);
|
||||
$valid_response = md5($A1.':'.$data['nonce'].':'.$data['nc'].':'.$data['cnonce'].':'.$data['qop'].':'.$A2);
|
||||
|
||||
if ($data['response'] != $valid_response){
|
||||
header('HTTP/1.1 401 Unauthorized');
|
||||
header('WWW-Authenticate: Digest realm="'.$realm.
|
||||
'",qop="auth",nonce="'.uniqid().'",opaque="'.md5($realm).'"');
|
||||
if($fail_msg!=NULL)
|
||||
die($fail_msg);
|
||||
if($fail_url!=NULL)
|
||||
die("<script>window.location.href = '$fail_url'</script>");
|
||||
exit;
|
||||
}
|
||||
|
||||
// ok, valid username & password
|
||||
return $data['username'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to parse the http auth header, works with IE.
|
||||
*
|
||||
* Internet Explorer returns a qop="xxxxxxxxxxx" in the header instead of qop=xxxxxxxxxxx as most browsers do.
|
||||
*
|
||||
* @param string $txt header string to parse
|
||||
* @return array An assoc array of the digest auth session
|
||||
*/
|
||||
private static function http_digest_parse($txt)
|
||||
{
|
||||
$res = preg_match("/username=\"([^\"]+)\"/i", $txt, $match);
|
||||
$data['username'] = (isset($match[1]))?$match[1]:null;
|
||||
$res = preg_match('/nonce=\"([^\"]+)\"/i', $txt, $match);
|
||||
$data['nonce'] = $match[1];
|
||||
$res = preg_match('/nc=([0-9]+)/i', $txt, $match);
|
||||
$data['nc'] = $match[1];
|
||||
$res = preg_match('/cnonce=\"([^\"]+)\"/i', $txt, $match);
|
||||
$data['cnonce'] = $match[1];
|
||||
$res = preg_match('/qop=([^,]+)/i', $txt, $match);
|
||||
$data['qop'] = str_replace('"','',$match[1]);
|
||||
$res = preg_match('/uri=\"([^\"]+)\"/i', $txt, $match);
|
||||
$data['uri'] = $match[1];
|
||||
$res = preg_match('/response=\"([^\"]+)\"/i', $txt, $match);
|
||||
$data['response'] = $match[1];
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
1370
vendor/mrclay/minify/min/lib/FirePHP.php
vendored
1370
vendor/mrclay/minify/min/lib/FirePHP.php
vendored
File diff suppressed because it is too large
Load Diff
366
vendor/mrclay/minify/min/lib/HTTP/ConditionalGet.php
vendored
366
vendor/mrclay/minify/min/lib/HTTP/ConditionalGet.php
vendored
@@ -1,366 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Class HTTP_ConditionalGet
|
||||
* @package Minify
|
||||
* @subpackage HTTP
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implement conditional GET via a timestamp or hash of content
|
||||
*
|
||||
* E.g. Content from DB with update time:
|
||||
* <code>
|
||||
* list($updateTime, $content) = getDbUpdateAndContent();
|
||||
* $cg = new HTTP_ConditionalGet(array(
|
||||
* 'lastModifiedTime' => $updateTime
|
||||
* ,'isPublic' => true
|
||||
* ));
|
||||
* $cg->sendHeaders();
|
||||
* if ($cg->cacheIsValid) {
|
||||
* exit();
|
||||
* }
|
||||
* echo $content;
|
||||
* </code>
|
||||
*
|
||||
* E.g. Shortcut for the above
|
||||
* <code>
|
||||
* HTTP_ConditionalGet::check($updateTime, true); // exits if client has cache
|
||||
* echo $content;
|
||||
* </code>
|
||||
*
|
||||
* E.g. Content from DB with no update time:
|
||||
* <code>
|
||||
* $content = getContentFromDB();
|
||||
* $cg = new HTTP_ConditionalGet(array(
|
||||
* 'contentHash' => md5($content)
|
||||
* ));
|
||||
* $cg->sendHeaders();
|
||||
* if ($cg->cacheIsValid) {
|
||||
* exit();
|
||||
* }
|
||||
* echo $content;
|
||||
* </code>
|
||||
*
|
||||
* E.g. Static content with some static includes:
|
||||
* <code>
|
||||
* // before content
|
||||
* $cg = new HTTP_ConditionalGet(array(
|
||||
* 'lastUpdateTime' => max(
|
||||
* filemtime(__FILE__)
|
||||
* ,filemtime('/path/to/header.inc')
|
||||
* ,filemtime('/path/to/footer.inc')
|
||||
* )
|
||||
* ));
|
||||
* $cg->sendHeaders();
|
||||
* if ($cg->cacheIsValid) {
|
||||
* exit();
|
||||
* }
|
||||
* </code>
|
||||
* @package Minify
|
||||
* @subpackage HTTP
|
||||
* @author Stephen Clay <steve@mrclay.org>
|
||||
*/
|
||||
class HTTP_ConditionalGet {
|
||||
|
||||
/**
|
||||
* Does the client have a valid copy of the requested resource?
|
||||
*
|
||||
* You'll want to check this after instantiating the object. If true, do
|
||||
* not send content, just call sendHeaders() if you haven't already.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $cacheIsValid = null;
|
||||
|
||||
/**
|
||||
* @param array $spec options
|
||||
*
|
||||
* 'isPublic': (bool) if false, the Cache-Control header will contain
|
||||
* "private", allowing only browser caching. (default false)
|
||||
*
|
||||
* 'lastModifiedTime': (int) if given, both ETag AND Last-Modified headers
|
||||
* will be sent with content. This is recommended.
|
||||
*
|
||||
* 'encoding': (string) if set, the header "Vary: Accept-Encoding" will
|
||||
* always be sent and a truncated version of the encoding will be appended
|
||||
* to the ETag. E.g. "pub123456;gz". This will also trigger a more lenient
|
||||
* checking of the client's If-None-Match header, as the encoding portion of
|
||||
* the ETag will be stripped before comparison.
|
||||
*
|
||||
* 'contentHash': (string) if given, only the ETag header can be sent with
|
||||
* content (only HTTP1.1 clients can conditionally GET). The given string
|
||||
* should be short with no quote characters and always change when the
|
||||
* resource changes (recommend md5()). This is not needed/used if
|
||||
* lastModifiedTime is given.
|
||||
*
|
||||
* 'eTag': (string) if given, this will be used as the ETag header rather
|
||||
* than values based on lastModifiedTime or contentHash. Also the encoding
|
||||
* string will not be appended to the given value as described above.
|
||||
*
|
||||
* 'invalidate': (bool) if true, the client cache will be considered invalid
|
||||
* without testing. Effectively this disables conditional GET.
|
||||
* (default false)
|
||||
*
|
||||
* 'maxAge': (int) if given, this will set the Cache-Control max-age in
|
||||
* seconds, and also set the Expires header to the equivalent GMT date.
|
||||
* After the max-age period has passed, the browser will again send a
|
||||
* conditional GET to revalidate its cache.
|
||||
*/
|
||||
public function __construct($spec)
|
||||
{
|
||||
$scope = (isset($spec['isPublic']) && $spec['isPublic'])
|
||||
? 'public'
|
||||
: 'private';
|
||||
$maxAge = 0;
|
||||
// backwards compatibility (can be removed later)
|
||||
if (isset($spec['setExpires'])
|
||||
&& is_numeric($spec['setExpires'])
|
||||
&& ! isset($spec['maxAge'])) {
|
||||
$spec['maxAge'] = $spec['setExpires'] - $_SERVER['REQUEST_TIME'];
|
||||
}
|
||||
if (isset($spec['maxAge'])) {
|
||||
$maxAge = $spec['maxAge'];
|
||||
$this->_headers['Expires'] = self::gmtDate(
|
||||
$_SERVER['REQUEST_TIME'] + $spec['maxAge']
|
||||
);
|
||||
}
|
||||
$etagAppend = '';
|
||||
if (isset($spec['encoding'])) {
|
||||
$this->_stripEtag = true;
|
||||
$this->_headers['Vary'] = 'Accept-Encoding';
|
||||
if ('' !== $spec['encoding']) {
|
||||
if (0 === strpos($spec['encoding'], 'x-')) {
|
||||
$spec['encoding'] = substr($spec['encoding'], 2);
|
||||
}
|
||||
$etagAppend = ';' . substr($spec['encoding'], 0, 2);
|
||||
}
|
||||
}
|
||||
if (isset($spec['lastModifiedTime'])) {
|
||||
$this->_setLastModified($spec['lastModifiedTime']);
|
||||
if (isset($spec['eTag'])) { // Use it
|
||||
$this->_setEtag($spec['eTag'], $scope);
|
||||
} else { // base both headers on time
|
||||
$this->_setEtag($spec['lastModifiedTime'] . $etagAppend, $scope);
|
||||
}
|
||||
} elseif (isset($spec['eTag'])) { // Use it
|
||||
$this->_setEtag($spec['eTag'], $scope);
|
||||
} elseif (isset($spec['contentHash'])) { // Use the hash as the ETag
|
||||
$this->_setEtag($spec['contentHash'] . $etagAppend, $scope);
|
||||
}
|
||||
$privacy = ($scope === 'private')
|
||||
? ', private'
|
||||
: '';
|
||||
$this->_headers['Cache-Control'] = "max-age={$maxAge}{$privacy}";
|
||||
// invalidate cache if disabled, otherwise check
|
||||
$this->cacheIsValid = (isset($spec['invalidate']) && $spec['invalidate'])
|
||||
? false
|
||||
: $this->_isCacheValid();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get array of output headers to be sent
|
||||
*
|
||||
* In the case of 304 responses, this array will only contain the response
|
||||
* code header: array('_responseCode' => 'HTTP/1.0 304 Not Modified')
|
||||
*
|
||||
* Otherwise something like:
|
||||
* <code>
|
||||
* array(
|
||||
* 'Cache-Control' => 'max-age=0, public'
|
||||
* ,'ETag' => '"foobar"'
|
||||
* )
|
||||
* </code>
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getHeaders()
|
||||
{
|
||||
return $this->_headers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the Content-Length header in bytes
|
||||
*
|
||||
* With most PHP configs, as long as you don't flush() output, this method
|
||||
* is not needed and PHP will buffer all output and set Content-Length for
|
||||
* you. Otherwise you'll want to call this to let the client know up front.
|
||||
*
|
||||
* @param int $bytes
|
||||
*
|
||||
* @return int copy of input $bytes
|
||||
*/
|
||||
public function setContentLength($bytes)
|
||||
{
|
||||
return $this->_headers['Content-Length'] = $bytes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send headers
|
||||
*
|
||||
* @see getHeaders()
|
||||
*
|
||||
* Note this doesn't "clear" the headers. Calling sendHeaders() will
|
||||
* call header() again (but probably have not effect) and getHeaders() will
|
||||
* still return the headers.
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
public function sendHeaders()
|
||||
{
|
||||
$headers = $this->_headers;
|
||||
if (array_key_exists('_responseCode', $headers)) {
|
||||
// FastCGI environments require 3rd arg to header() to be set
|
||||
list(, $code) = explode(' ', $headers['_responseCode'], 3);
|
||||
header($headers['_responseCode'], true, $code);
|
||||
unset($headers['_responseCode']);
|
||||
}
|
||||
foreach ($headers as $name => $val) {
|
||||
header($name . ': ' . $val);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Exit if the client's cache is valid for this resource
|
||||
*
|
||||
* This is a convenience method for common use of the class
|
||||
*
|
||||
* @param int $lastModifiedTime if given, both ETag AND Last-Modified headers
|
||||
* will be sent with content. This is recommended.
|
||||
*
|
||||
* @param bool $isPublic (default false) if true, the Cache-Control header
|
||||
* will contain "public", allowing proxies to cache the content. Otherwise
|
||||
* "private" will be sent, allowing only browser caching.
|
||||
*
|
||||
* @param array $options (default empty) additional options for constructor
|
||||
*/
|
||||
public static function check($lastModifiedTime = null, $isPublic = false, $options = array())
|
||||
{
|
||||
if (null !== $lastModifiedTime) {
|
||||
$options['lastModifiedTime'] = (int)$lastModifiedTime;
|
||||
}
|
||||
$options['isPublic'] = (bool)$isPublic;
|
||||
$cg = new HTTP_ConditionalGet($options);
|
||||
$cg->sendHeaders();
|
||||
if ($cg->cacheIsValid) {
|
||||
exit();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get a GMT formatted date for use in HTTP headers
|
||||
*
|
||||
* <code>
|
||||
* header('Expires: ' . HTTP_ConditionalGet::gmtdate($time));
|
||||
* </code>
|
||||
*
|
||||
* @param int $time unix timestamp
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function gmtDate($time)
|
||||
{
|
||||
return gmdate('D, d M Y H:i:s \G\M\T', $time);
|
||||
}
|
||||
|
||||
protected $_headers = array();
|
||||
protected $_lmTime = null;
|
||||
protected $_etag = null;
|
||||
protected $_stripEtag = false;
|
||||
|
||||
/**
|
||||
* @param string $hash
|
||||
*
|
||||
* @param string $scope
|
||||
*/
|
||||
protected function _setEtag($hash, $scope)
|
||||
{
|
||||
$this->_etag = '"' . substr($scope, 0, 3) . $hash . '"';
|
||||
$this->_headers['ETag'] = $this->_etag;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $time
|
||||
*/
|
||||
protected function _setLastModified($time)
|
||||
{
|
||||
$this->_lmTime = (int)$time;
|
||||
$this->_headers['Last-Modified'] = self::gmtDate($time);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine validity of client cache and queue 304 header if valid
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function _isCacheValid()
|
||||
{
|
||||
if (null === $this->_etag) {
|
||||
// lmTime is copied to ETag, so this condition implies that the
|
||||
// server sent neither ETag nor Last-Modified, so the client can't
|
||||
// possibly has a valid cache.
|
||||
return false;
|
||||
}
|
||||
$isValid = ($this->resourceMatchedEtag() || $this->resourceNotModified());
|
||||
if ($isValid) {
|
||||
$this->_headers['_responseCode'] = 'HTTP/1.0 304 Not Modified';
|
||||
}
|
||||
return $isValid;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function resourceMatchedEtag()
|
||||
{
|
||||
if (!isset($_SERVER['HTTP_IF_NONE_MATCH'])) {
|
||||
return false;
|
||||
}
|
||||
$clientEtagList = get_magic_quotes_gpc()
|
||||
? stripslashes($_SERVER['HTTP_IF_NONE_MATCH'])
|
||||
: $_SERVER['HTTP_IF_NONE_MATCH'];
|
||||
$clientEtags = explode(',', $clientEtagList);
|
||||
|
||||
$compareTo = $this->normalizeEtag($this->_etag);
|
||||
foreach ($clientEtags as $clientEtag) {
|
||||
if ($this->normalizeEtag($clientEtag) === $compareTo) {
|
||||
// respond with the client's matched ETag, even if it's not what
|
||||
// we would've sent by default
|
||||
$this->_headers['ETag'] = trim($clientEtag);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $etag
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function normalizeEtag($etag) {
|
||||
$etag = trim($etag);
|
||||
return $this->_stripEtag
|
||||
? preg_replace('/;\\w\\w"$/', '"', $etag)
|
||||
: $etag;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function resourceNotModified()
|
||||
{
|
||||
if (!isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])) {
|
||||
return false;
|
||||
}
|
||||
// strip off IE's extra data (semicolon)
|
||||
list($ifModifiedSince) = explode(';', $_SERVER['HTTP_IF_MODIFIED_SINCE'], 2);
|
||||
if (strtotime($ifModifiedSince) >= $this->_lmTime) {
|
||||
// Apache 2.2's behavior. If there was no ETag match, send the
|
||||
// non-encoded version of the ETag value.
|
||||
$this->_headers['ETag'] = $this->normalizeEtag($this->_etag);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
335
vendor/mrclay/minify/min/lib/HTTP/Encoder.php
vendored
335
vendor/mrclay/minify/min/lib/HTTP/Encoder.php
vendored
@@ -1,335 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Class HTTP_Encoder
|
||||
* @package Minify
|
||||
* @subpackage HTTP
|
||||
*/
|
||||
|
||||
/**
|
||||
* Encode and send gzipped/deflated content
|
||||
*
|
||||
* The "Vary: Accept-Encoding" header is sent. If the client allows encoding,
|
||||
* Content-Encoding and Content-Length are added.
|
||||
*
|
||||
* <code>
|
||||
* // Send a CSS file, compressed if possible
|
||||
* $he = new HTTP_Encoder(array(
|
||||
* 'content' => file_get_contents($cssFile)
|
||||
* ,'type' => 'text/css'
|
||||
* ));
|
||||
* $he->encode();
|
||||
* $he->sendAll();
|
||||
* </code>
|
||||
*
|
||||
* <code>
|
||||
* // Shortcut to encoding output
|
||||
* header('Content-Type: text/css'); // needed if not HTML
|
||||
* HTTP_Encoder::output($css);
|
||||
* </code>
|
||||
*
|
||||
* <code>
|
||||
* // Just sniff for the accepted encoding
|
||||
* $encoding = HTTP_Encoder::getAcceptedEncoding();
|
||||
* </code>
|
||||
*
|
||||
* For more control over headers, use getHeaders() and getData() and send your
|
||||
* own output.
|
||||
*
|
||||
* Note: If you don't need header mgmt, use PHP's native gzencode, gzdeflate,
|
||||
* and gzcompress functions for gzip, deflate, and compress-encoding
|
||||
* respectively.
|
||||
*
|
||||
* @package Minify
|
||||
* @subpackage HTTP
|
||||
* @author Stephen Clay <steve@mrclay.org>
|
||||
*/
|
||||
class HTTP_Encoder {
|
||||
|
||||
/**
|
||||
* Should the encoder allow HTTP encoding to IE6?
|
||||
*
|
||||
* If you have many IE6 users and the bandwidth savings is worth troubling
|
||||
* some of them, set this to true.
|
||||
*
|
||||
* By default, encoding is only offered to IE7+. When this is true,
|
||||
* getAcceptedEncoding() will return an encoding for IE6 if its user agent
|
||||
* string contains "SV1". This has been documented in many places as "safe",
|
||||
* but there seem to be remaining, intermittent encoding bugs in patched
|
||||
* IE6 on the wild web.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public static $encodeToIe6 = true;
|
||||
|
||||
|
||||
/**
|
||||
* Default compression level for zlib operations
|
||||
*
|
||||
* This level is used if encode() is not given a $compressionLevel
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public static $compressionLevel = 6;
|
||||
|
||||
|
||||
/**
|
||||
* Get an HTTP Encoder object
|
||||
*
|
||||
* @param array $spec options
|
||||
*
|
||||
* 'content': (string required) content to be encoded
|
||||
*
|
||||
* 'type': (string) if set, the Content-Type header will have this value.
|
||||
*
|
||||
* 'method: (string) only set this if you are forcing a particular encoding
|
||||
* method. If not set, the best method will be chosen by getAcceptedEncoding()
|
||||
* The available methods are 'gzip', 'deflate', 'compress', and '' (no
|
||||
* encoding)
|
||||
*/
|
||||
public function __construct($spec)
|
||||
{
|
||||
$this->_useMbStrlen = (function_exists('mb_strlen')
|
||||
&& (ini_get('mbstring.func_overload') !== '')
|
||||
&& ((int)ini_get('mbstring.func_overload') & 2));
|
||||
$this->_content = $spec['content'];
|
||||
$this->_headers['Content-Length'] = $this->_useMbStrlen
|
||||
? (string)mb_strlen($this->_content, '8bit')
|
||||
: (string)strlen($this->_content);
|
||||
if (isset($spec['type'])) {
|
||||
$this->_headers['Content-Type'] = $spec['type'];
|
||||
}
|
||||
if (isset($spec['method'])
|
||||
&& in_array($spec['method'], array('gzip', 'deflate', 'compress', '')))
|
||||
{
|
||||
$this->_encodeMethod = array($spec['method'], $spec['method']);
|
||||
} else {
|
||||
$this->_encodeMethod = self::getAcceptedEncoding();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get content in current form
|
||||
*
|
||||
* Call after encode() for encoded content.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getContent()
|
||||
{
|
||||
return $this->_content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get array of output headers to be sent
|
||||
*
|
||||
* E.g.
|
||||
* <code>
|
||||
* array(
|
||||
* 'Content-Length' => '615'
|
||||
* ,'Content-Encoding' => 'x-gzip'
|
||||
* ,'Vary' => 'Accept-Encoding'
|
||||
* )
|
||||
* </code>
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getHeaders()
|
||||
{
|
||||
return $this->_headers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send output headers
|
||||
*
|
||||
* You must call this before headers are sent and it probably cannot be
|
||||
* used in conjunction with zlib output buffering / mod_gzip. Errors are
|
||||
* not handled purposefully.
|
||||
*
|
||||
* @see getHeaders()
|
||||
*/
|
||||
public function sendHeaders()
|
||||
{
|
||||
foreach ($this->_headers as $name => $val) {
|
||||
header($name . ': ' . $val);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Send output headers and content
|
||||
*
|
||||
* A shortcut for sendHeaders() and echo getContent()
|
||||
*
|
||||
* You must call this before headers are sent and it probably cannot be
|
||||
* used in conjunction with zlib output buffering / mod_gzip. Errors are
|
||||
* not handled purposefully.
|
||||
*/
|
||||
public function sendAll()
|
||||
{
|
||||
$this->sendHeaders();
|
||||
echo $this->_content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine the client's best encoding method from the HTTP Accept-Encoding
|
||||
* header.
|
||||
*
|
||||
* If no Accept-Encoding header is set, or the browser is IE before v6 SP2,
|
||||
* this will return ('', ''), the "identity" encoding.
|
||||
*
|
||||
* A syntax-aware scan is done of the Accept-Encoding, so the method must
|
||||
* be non 0. The methods are favored in order of gzip, deflate, then
|
||||
* compress. Deflate is always smallest and generally faster, but is
|
||||
* rarely sent by servers, so client support could be buggier.
|
||||
*
|
||||
* @param bool $allowCompress allow the older compress encoding
|
||||
*
|
||||
* @param bool $allowDeflate allow the more recent deflate encoding
|
||||
*
|
||||
* @return array two values, 1st is the actual encoding method, 2nd is the
|
||||
* alias of that method to use in the Content-Encoding header (some browsers
|
||||
* call gzip "x-gzip" etc.)
|
||||
*/
|
||||
public static function getAcceptedEncoding($allowCompress = true, $allowDeflate = true)
|
||||
{
|
||||
// @link http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html
|
||||
|
||||
if (! isset($_SERVER['HTTP_ACCEPT_ENCODING'])
|
||||
|| self::isBuggyIe())
|
||||
{
|
||||
return array('', '');
|
||||
}
|
||||
$ae = $_SERVER['HTTP_ACCEPT_ENCODING'];
|
||||
// gzip checks (quick)
|
||||
if (0 === strpos($ae, 'gzip,') // most browsers
|
||||
|| 0 === strpos($ae, 'deflate, gzip,') // opera
|
||||
) {
|
||||
return array('gzip', 'gzip');
|
||||
}
|
||||
// gzip checks (slow)
|
||||
if (preg_match(
|
||||
'@(?:^|,)\\s*((?:x-)?gzip)\\s*(?:$|,|;\\s*q=(?:0\\.|1))@'
|
||||
,$ae
|
||||
,$m)) {
|
||||
return array('gzip', $m[1]);
|
||||
}
|
||||
if ($allowDeflate) {
|
||||
// deflate checks
|
||||
$aeRev = strrev($ae);
|
||||
if (0 === strpos($aeRev, 'etalfed ,') // ie, webkit
|
||||
|| 0 === strpos($aeRev, 'etalfed,') // gecko
|
||||
|| 0 === strpos($ae, 'deflate,') // opera
|
||||
// slow parsing
|
||||
|| preg_match(
|
||||
'@(?:^|,)\\s*deflate\\s*(?:$|,|;\\s*q=(?:0\\.|1))@', $ae)) {
|
||||
return array('deflate', 'deflate');
|
||||
}
|
||||
}
|
||||
if ($allowCompress && preg_match(
|
||||
'@(?:^|,)\\s*((?:x-)?compress)\\s*(?:$|,|;\\s*q=(?:0\\.|1))@'
|
||||
,$ae
|
||||
,$m)) {
|
||||
return array('compress', $m[1]);
|
||||
}
|
||||
return array('', '');
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode (compress) the content
|
||||
*
|
||||
* If the encode method is '' (none) or compression level is 0, or the 'zlib'
|
||||
* extension isn't loaded, we return false.
|
||||
*
|
||||
* Then the appropriate gz_* function is called to compress the content. If
|
||||
* this fails, false is returned.
|
||||
*
|
||||
* The header "Vary: Accept-Encoding" is added. If encoding is successful,
|
||||
* the Content-Length header is updated, and Content-Encoding is also added.
|
||||
*
|
||||
* @param int $compressionLevel given to zlib functions. If not given, the
|
||||
* class default will be used.
|
||||
*
|
||||
* @return bool success true if the content was actually compressed
|
||||
*/
|
||||
public function encode($compressionLevel = null)
|
||||
{
|
||||
if (! self::isBuggyIe()) {
|
||||
$this->_headers['Vary'] = 'Accept-Encoding';
|
||||
}
|
||||
if (null === $compressionLevel) {
|
||||
$compressionLevel = self::$compressionLevel;
|
||||
}
|
||||
if ('' === $this->_encodeMethod[0]
|
||||
|| ($compressionLevel == 0)
|
||||
|| !extension_loaded('zlib'))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if ($this->_encodeMethod[0] === 'deflate') {
|
||||
$encoded = gzdeflate($this->_content, $compressionLevel);
|
||||
} elseif ($this->_encodeMethod[0] === 'gzip') {
|
||||
$encoded = gzencode($this->_content, $compressionLevel);
|
||||
} else {
|
||||
$encoded = gzcompress($this->_content, $compressionLevel);
|
||||
}
|
||||
if (false === $encoded) {
|
||||
return false;
|
||||
}
|
||||
$this->_headers['Content-Length'] = $this->_useMbStrlen
|
||||
? (string)mb_strlen($encoded, '8bit')
|
||||
: (string)strlen($encoded);
|
||||
$this->_headers['Content-Encoding'] = $this->_encodeMethod[1];
|
||||
$this->_content = $encoded;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode and send appropriate headers and content
|
||||
*
|
||||
* This is a convenience method for common use of the class
|
||||
*
|
||||
* @param string $content
|
||||
*
|
||||
* @param int $compressionLevel given to zlib functions. If not given, the
|
||||
* class default will be used.
|
||||
*
|
||||
* @return bool success true if the content was actually compressed
|
||||
*/
|
||||
public static function output($content, $compressionLevel = null)
|
||||
{
|
||||
if (null === $compressionLevel) {
|
||||
$compressionLevel = self::$compressionLevel;
|
||||
}
|
||||
$he = new HTTP_Encoder(array('content' => $content));
|
||||
$ret = $he->encode($compressionLevel);
|
||||
$he->sendAll();
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is the browser an IE version earlier than 6 SP2?
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function isBuggyIe()
|
||||
{
|
||||
if (empty($_SERVER['HTTP_USER_AGENT'])) {
|
||||
return false;
|
||||
}
|
||||
$ua = $_SERVER['HTTP_USER_AGENT'];
|
||||
// quick escape for non-IEs
|
||||
if (0 !== strpos($ua, 'Mozilla/4.0 (compatible; MSIE ')
|
||||
|| false !== strpos($ua, 'Opera')) {
|
||||
return false;
|
||||
}
|
||||
// no regex = faaast
|
||||
$version = (float)substr($ua, 30);
|
||||
return self::$encodeToIe6
|
||||
? ($version < 6 || ($version == 6 && false === strpos($ua, 'SV1')))
|
||||
: ($version < 7);
|
||||
}
|
||||
|
||||
protected $_content = '';
|
||||
protected $_headers = array();
|
||||
protected $_encodeMethod = array('', '');
|
||||
protected $_useMbStrlen = false;
|
||||
}
|
||||
449
vendor/mrclay/minify/min/lib/JSMin.php
vendored
449
vendor/mrclay/minify/min/lib/JSMin.php
vendored
@@ -1,449 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* JSMin.php - modified PHP implementation of Douglas Crockford's JSMin.
|
||||
*
|
||||
* <code>
|
||||
* $minifiedJs = JSMin::minify($js);
|
||||
* </code>
|
||||
*
|
||||
* This is a modified port of jsmin.c. Improvements:
|
||||
*
|
||||
* Does not choke on some regexp literals containing quote characters. E.g. /'/
|
||||
*
|
||||
* Spaces are preserved after some add/sub operators, so they are not mistakenly
|
||||
* converted to post-inc/dec. E.g. a + ++b -> a+ ++b
|
||||
*
|
||||
* Preserves multi-line comments that begin with /*!
|
||||
*
|
||||
* PHP 5 or higher is required.
|
||||
*
|
||||
* Permission is hereby granted to use this version of the library under the
|
||||
* same terms as jsmin.c, which has the following license:
|
||||
*
|
||||
* --
|
||||
* Copyright (c) 2002 Douglas Crockford (www.crockford.com)
|
||||
*
|
||||
* 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 shall be used for Good, not Evil.
|
||||
*
|
||||
* 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.
|
||||
* --
|
||||
*
|
||||
* @package JSMin
|
||||
* @author Ryan Grove <ryan@wonko.com> (PHP port)
|
||||
* @author Steve Clay <steve@mrclay.org> (modifications + cleanup)
|
||||
* @author Andrea Giammarchi <http://www.3site.eu> (spaceBeforeRegExp)
|
||||
* @copyright 2002 Douglas Crockford <douglas@crockford.com> (jsmin.c)
|
||||
* @copyright 2008 Ryan Grove <ryan@wonko.com> (PHP port)
|
||||
* @license http://opensource.org/licenses/mit-license.php MIT License
|
||||
* @link http://code.google.com/p/jsmin-php/
|
||||
*/
|
||||
|
||||
class JSMin {
|
||||
const ORD_LF = 10;
|
||||
const ORD_SPACE = 32;
|
||||
const ACTION_KEEP_A = 1;
|
||||
const ACTION_DELETE_A = 2;
|
||||
const ACTION_DELETE_A_B = 3;
|
||||
|
||||
protected $a = "\n";
|
||||
protected $b = '';
|
||||
protected $input = '';
|
||||
protected $inputIndex = 0;
|
||||
protected $inputLength = 0;
|
||||
protected $lookAhead = null;
|
||||
protected $output = '';
|
||||
protected $lastByteOut = '';
|
||||
protected $keptComment = '';
|
||||
|
||||
/**
|
||||
* Minify Javascript.
|
||||
*
|
||||
* @param string $js Javascript to be minified
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function minify($js)
|
||||
{
|
||||
$jsmin = new JSMin($js);
|
||||
return $jsmin->min();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $input
|
||||
*/
|
||||
public function __construct($input)
|
||||
{
|
||||
$this->input = $input;
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform minification, return result
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function min()
|
||||
{
|
||||
if ($this->output !== '') { // min already run
|
||||
return $this->output;
|
||||
}
|
||||
|
||||
$mbIntEnc = null;
|
||||
if (function_exists('mb_strlen') && ((int)ini_get('mbstring.func_overload') & 2)) {
|
||||
$mbIntEnc = mb_internal_encoding();
|
||||
mb_internal_encoding('8bit');
|
||||
}
|
||||
$this->input = str_replace("\r\n", "\n", $this->input);
|
||||
$this->inputLength = strlen($this->input);
|
||||
|
||||
$this->action(self::ACTION_DELETE_A_B);
|
||||
|
||||
while ($this->a !== null) {
|
||||
// determine next command
|
||||
$command = self::ACTION_KEEP_A; // default
|
||||
if ($this->a === ' ') {
|
||||
if (($this->lastByteOut === '+' || $this->lastByteOut === '-')
|
||||
&& ($this->b === $this->lastByteOut)) {
|
||||
// Don't delete this space. If we do, the addition/subtraction
|
||||
// could be parsed as a post-increment
|
||||
} elseif (! $this->isAlphaNum($this->b)) {
|
||||
$command = self::ACTION_DELETE_A;
|
||||
}
|
||||
} elseif ($this->a === "\n") {
|
||||
if ($this->b === ' ') {
|
||||
$command = self::ACTION_DELETE_A_B;
|
||||
|
||||
// in case of mbstring.func_overload & 2, must check for null b,
|
||||
// otherwise mb_strpos will give WARNING
|
||||
} elseif ($this->b === null
|
||||
|| (false === strpos('{[(+-!~', $this->b)
|
||||
&& ! $this->isAlphaNum($this->b))) {
|
||||
$command = self::ACTION_DELETE_A;
|
||||
}
|
||||
} elseif (! $this->isAlphaNum($this->a)) {
|
||||
if ($this->b === ' '
|
||||
|| ($this->b === "\n"
|
||||
&& (false === strpos('}])+-"\'', $this->a)))) {
|
||||
$command = self::ACTION_DELETE_A_B;
|
||||
}
|
||||
}
|
||||
$this->action($command);
|
||||
}
|
||||
$this->output = trim($this->output);
|
||||
|
||||
if ($mbIntEnc !== null) {
|
||||
mb_internal_encoding($mbIntEnc);
|
||||
}
|
||||
return $this->output;
|
||||
}
|
||||
|
||||
/**
|
||||
* ACTION_KEEP_A = Output A. Copy B to A. Get the next B.
|
||||
* ACTION_DELETE_A = Copy B to A. Get the next B.
|
||||
* ACTION_DELETE_A_B = Get the next B.
|
||||
*
|
||||
* @param int $command
|
||||
* @throws JSMin_UnterminatedRegExpException|JSMin_UnterminatedStringException
|
||||
*/
|
||||
protected function action($command)
|
||||
{
|
||||
// make sure we don't compress "a + ++b" to "a+++b", etc.
|
||||
if ($command === self::ACTION_DELETE_A_B
|
||||
&& $this->b === ' '
|
||||
&& ($this->a === '+' || $this->a === '-')) {
|
||||
// Note: we're at an addition/substraction operator; the inputIndex
|
||||
// will certainly be a valid index
|
||||
if ($this->input[$this->inputIndex] === $this->a) {
|
||||
// This is "+ +" or "- -". Don't delete the space.
|
||||
$command = self::ACTION_KEEP_A;
|
||||
}
|
||||
}
|
||||
|
||||
switch ($command) {
|
||||
case self::ACTION_KEEP_A: // 1
|
||||
$this->output .= $this->a;
|
||||
|
||||
if ($this->keptComment) {
|
||||
$this->output = rtrim($this->output, "\n");
|
||||
$this->output .= $this->keptComment;
|
||||
$this->keptComment = '';
|
||||
}
|
||||
|
||||
$this->lastByteOut = $this->a;
|
||||
|
||||
// fallthrough intentional
|
||||
case self::ACTION_DELETE_A: // 2
|
||||
$this->a = $this->b;
|
||||
if ($this->a === "'" || $this->a === '"') { // string literal
|
||||
$str = $this->a; // in case needed for exception
|
||||
for(;;) {
|
||||
$this->output .= $this->a;
|
||||
$this->lastByteOut = $this->a;
|
||||
|
||||
$this->a = $this->get();
|
||||
if ($this->a === $this->b) { // end quote
|
||||
break;
|
||||
}
|
||||
if ($this->isEOF($this->a)) {
|
||||
$byte = $this->inputIndex - 1;
|
||||
throw new JSMin_UnterminatedStringException(
|
||||
"JSMin: Unterminated String at byte {$byte}: {$str}");
|
||||
}
|
||||
$str .= $this->a;
|
||||
if ($this->a === '\\') {
|
||||
$this->output .= $this->a;
|
||||
$this->lastByteOut = $this->a;
|
||||
|
||||
$this->a = $this->get();
|
||||
$str .= $this->a;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// fallthrough intentional
|
||||
case self::ACTION_DELETE_A_B: // 3
|
||||
$this->b = $this->next();
|
||||
if ($this->b === '/' && $this->isRegexpLiteral()) {
|
||||
$this->output .= $this->a . $this->b;
|
||||
$pattern = '/'; // keep entire pattern in case we need to report it in the exception
|
||||
for(;;) {
|
||||
$this->a = $this->get();
|
||||
$pattern .= $this->a;
|
||||
if ($this->a === '[') {
|
||||
for(;;) {
|
||||
$this->output .= $this->a;
|
||||
$this->a = $this->get();
|
||||
$pattern .= $this->a;
|
||||
if ($this->a === ']') {
|
||||
break;
|
||||
}
|
||||
if ($this->a === '\\') {
|
||||
$this->output .= $this->a;
|
||||
$this->a = $this->get();
|
||||
$pattern .= $this->a;
|
||||
}
|
||||
if ($this->isEOF($this->a)) {
|
||||
throw new JSMin_UnterminatedRegExpException(
|
||||
"JSMin: Unterminated set in RegExp at byte "
|
||||
. $this->inputIndex .": {$pattern}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->a === '/') { // end pattern
|
||||
break; // while (true)
|
||||
} elseif ($this->a === '\\') {
|
||||
$this->output .= $this->a;
|
||||
$this->a = $this->get();
|
||||
$pattern .= $this->a;
|
||||
} elseif ($this->isEOF($this->a)) {
|
||||
$byte = $this->inputIndex - 1;
|
||||
throw new JSMin_UnterminatedRegExpException(
|
||||
"JSMin: Unterminated RegExp at byte {$byte}: {$pattern}");
|
||||
}
|
||||
$this->output .= $this->a;
|
||||
$this->lastByteOut = $this->a;
|
||||
}
|
||||
$this->b = $this->next();
|
||||
}
|
||||
// end case ACTION_DELETE_A_B
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function isRegexpLiteral()
|
||||
{
|
||||
if (false !== strpos("(,=:[!&|?+-~*{;", $this->a)) {
|
||||
// we obviously aren't dividing
|
||||
return true;
|
||||
}
|
||||
|
||||
// we have to check for a preceding keyword, and we don't need to pattern
|
||||
// match over the whole output.
|
||||
$recentOutput = substr($this->output, -10);
|
||||
|
||||
// check if return/typeof directly precede a pattern without a space
|
||||
foreach (array('return', 'typeof') as $keyword) {
|
||||
if ($this->a !== substr($keyword, -1)) {
|
||||
// certainly wasn't keyword
|
||||
continue;
|
||||
}
|
||||
if (preg_match("~(^|[\\s\\S])" . substr($keyword, 0, -1) . "$~", $recentOutput, $m)) {
|
||||
if ($m[1] === '' || !$this->isAlphaNum($m[1])) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// check all keywords
|
||||
if ($this->a === ' ' || $this->a === "\n") {
|
||||
if (preg_match('~(^|[\\s\\S])(?:case|else|in|return|typeof)$~', $recentOutput, $m)) {
|
||||
if ($m[1] === '' || !$this->isAlphaNum($m[1])) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the next character from stdin. Watch out for lookahead. If the character is a control character,
|
||||
* translate it to a space or linefeed.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function get()
|
||||
{
|
||||
$c = $this->lookAhead;
|
||||
$this->lookAhead = null;
|
||||
if ($c === null) {
|
||||
// getc(stdin)
|
||||
if ($this->inputIndex < $this->inputLength) {
|
||||
$c = $this->input[$this->inputIndex];
|
||||
$this->inputIndex += 1;
|
||||
} else {
|
||||
$c = null;
|
||||
}
|
||||
}
|
||||
if (ord($c) >= self::ORD_SPACE || $c === "\n" || $c === null) {
|
||||
return $c;
|
||||
}
|
||||
if ($c === "\r") {
|
||||
return "\n";
|
||||
}
|
||||
return ' ';
|
||||
}
|
||||
|
||||
/**
|
||||
* Does $a indicate end of input?
|
||||
*
|
||||
* @param string $a
|
||||
* @return bool
|
||||
*/
|
||||
protected function isEOF($a)
|
||||
{
|
||||
return ord($a) <= self::ORD_LF;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get next char (without getting it). If is ctrl character, translate to a space or newline.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function peek()
|
||||
{
|
||||
$this->lookAhead = $this->get();
|
||||
return $this->lookAhead;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if the character is a letter, digit, underscore, dollar sign, or non-ASCII character.
|
||||
*
|
||||
* @param string $c
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function isAlphaNum($c)
|
||||
{
|
||||
return (preg_match('/^[a-z0-9A-Z_\\$\\\\]$/', $c) || ord($c) > 126);
|
||||
}
|
||||
|
||||
/**
|
||||
* Consume a single line comment from input (possibly retaining it)
|
||||
*/
|
||||
protected function consumeSingleLineComment()
|
||||
{
|
||||
$comment = '';
|
||||
while (true) {
|
||||
$get = $this->get();
|
||||
$comment .= $get;
|
||||
if (ord($get) <= self::ORD_LF) { // end of line reached
|
||||
// if IE conditional comment
|
||||
if (preg_match('/^\\/@(?:cc_on|if|elif|else|end)\\b/', $comment)) {
|
||||
$this->keptComment .= "/{$comment}";
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Consume a multiple line comment from input (possibly retaining it)
|
||||
*
|
||||
* @throws JSMin_UnterminatedCommentException
|
||||
*/
|
||||
protected function consumeMultipleLineComment()
|
||||
{
|
||||
$this->get();
|
||||
$comment = '';
|
||||
for(;;) {
|
||||
$get = $this->get();
|
||||
if ($get === '*') {
|
||||
if ($this->peek() === '/') { // end of comment reached
|
||||
$this->get();
|
||||
if (0 === strpos($comment, '!')) {
|
||||
// preserved by YUI Compressor
|
||||
if (!$this->keptComment) {
|
||||
// don't prepend a newline if two comments right after one another
|
||||
$this->keptComment = "\n";
|
||||
}
|
||||
$this->keptComment .= "/*!" . substr($comment, 1) . "*/\n";
|
||||
} else if (preg_match('/^@(?:cc_on|if|elif|else|end)\\b/', $comment)) {
|
||||
// IE conditional
|
||||
$this->keptComment .= "/*{$comment}*/";
|
||||
}
|
||||
return;
|
||||
}
|
||||
} elseif ($get === null) {
|
||||
throw new JSMin_UnterminatedCommentException(
|
||||
"JSMin: Unterminated comment at byte {$this->inputIndex}: /*{$comment}");
|
||||
}
|
||||
$comment .= $get;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the next character, skipping over comments. Some comments may be preserved.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function next()
|
||||
{
|
||||
$get = $this->get();
|
||||
if ($get === '/') {
|
||||
switch ($this->peek()) {
|
||||
case '/':
|
||||
$this->consumeSingleLineComment();
|
||||
$get = "\n";
|
||||
break;
|
||||
case '*':
|
||||
$this->consumeMultipleLineComment();
|
||||
$get = ' ';
|
||||
break;
|
||||
}
|
||||
}
|
||||
return $get;
|
||||
}
|
||||
}
|
||||
|
||||
class JSMin_UnterminatedStringException extends Exception {}
|
||||
class JSMin_UnterminatedCommentException extends Exception {}
|
||||
class JSMin_UnterminatedRegExpException extends Exception {}
|
||||
2086
vendor/mrclay/minify/min/lib/JSMinPlus.php
vendored
2086
vendor/mrclay/minify/min/lib/JSMinPlus.php
vendored
File diff suppressed because it is too large
Load Diff
608
vendor/mrclay/minify/min/lib/Minify.php
vendored
608
vendor/mrclay/minify/min/lib/Minify.php
vendored
@@ -1,608 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Class Minify
|
||||
* @package Minify
|
||||
*/
|
||||
|
||||
/**
|
||||
* Minify - Combines, minifies, and caches JavaScript and CSS files on demand.
|
||||
*
|
||||
* See README for usage instructions (for now).
|
||||
*
|
||||
* This library was inspired by {@link mailto:flashkot@mail.ru jscsscomp by Maxim Martynyuk}
|
||||
* and by the article {@link http://www.hunlock.com/blogs/Supercharged_Javascript "Supercharged JavaScript" by Patrick Hunlock}.
|
||||
*
|
||||
* Requires PHP 5.1.0.
|
||||
* Tested on PHP 5.1.6.
|
||||
*
|
||||
* @package Minify
|
||||
* @author Ryan Grove <ryan@wonko.com>
|
||||
* @author Stephen Clay <steve@mrclay.org>
|
||||
* @copyright 2008 Ryan Grove, Stephen Clay. All rights reserved.
|
||||
* @license http://opensource.org/licenses/bsd-license.php New BSD License
|
||||
* @link http://code.google.com/p/minify/
|
||||
*/
|
||||
class Minify {
|
||||
|
||||
const VERSION = '2.2.0';
|
||||
const TYPE_CSS = 'text/css';
|
||||
const TYPE_HTML = 'text/html';
|
||||
// there is some debate over the ideal JS Content-Type, but this is the
|
||||
// Apache default and what Yahoo! uses..
|
||||
const TYPE_JS = 'application/x-javascript';
|
||||
const URL_DEBUG = 'http://code.google.com/p/minify/wiki/Debugging';
|
||||
|
||||
/**
|
||||
* How many hours behind are the file modification times of uploaded files?
|
||||
*
|
||||
* If you upload files from Windows to a non-Windows server, Windows may report
|
||||
* incorrect mtimes for the files. Immediately after modifying and uploading a
|
||||
* file, use the touch command to update the mtime on the server. If the mtime
|
||||
* jumps ahead by a number of hours, set this variable to that number. If the mtime
|
||||
* moves back, this should not be needed.
|
||||
*
|
||||
* @var int $uploaderHoursBehind
|
||||
*/
|
||||
public static $uploaderHoursBehind = 0;
|
||||
|
||||
/**
|
||||
* If this string is not empty AND the serve() option 'bubbleCssImports' is
|
||||
* NOT set, then serve() will check CSS files for @import declarations that
|
||||
* appear too late in the combined stylesheet. If found, serve() will prepend
|
||||
* the output with this warning.
|
||||
*
|
||||
* @var string $importWarning
|
||||
*/
|
||||
public static $importWarning = "/* See http://code.google.com/p/minify/wiki/CommonProblems#@imports_can_appear_in_invalid_locations_in_combined_CSS_files */\n";
|
||||
|
||||
/**
|
||||
* Has the DOCUMENT_ROOT been set in user code?
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public static $isDocRootSet = false;
|
||||
|
||||
/**
|
||||
* Specify a cache object (with identical interface as Minify_Cache_File) or
|
||||
* a path to use with Minify_Cache_File.
|
||||
*
|
||||
* If not called, Minify will not use a cache and, for each 200 response, will
|
||||
* need to recombine files, minify and encode the output.
|
||||
*
|
||||
* @param mixed $cache object with identical interface as Minify_Cache_File or
|
||||
* a directory path, or null to disable caching. (default = '')
|
||||
*
|
||||
* @param bool $fileLocking (default = true) This only applies if the first
|
||||
* parameter is a string.
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
public static function setCache($cache = '', $fileLocking = true)
|
||||
{
|
||||
if (is_string($cache)) {
|
||||
self::$_cache = new Minify_Cache_File($cache, $fileLocking);
|
||||
} else {
|
||||
self::$_cache = $cache;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Serve a request for a minified file.
|
||||
*
|
||||
* Here are the available options and defaults in the base controller:
|
||||
*
|
||||
* 'isPublic' : send "public" instead of "private" in Cache-Control
|
||||
* headers, allowing shared caches to cache the output. (default true)
|
||||
*
|
||||
* 'quiet' : set to true to have serve() return an array rather than sending
|
||||
* any headers/output (default false)
|
||||
*
|
||||
* 'encodeOutput' : set to false to disable content encoding, and not send
|
||||
* the Vary header (default true)
|
||||
*
|
||||
* 'encodeMethod' : generally you should let this be determined by
|
||||
* HTTP_Encoder (leave null), but you can force a particular encoding
|
||||
* to be returned, by setting this to 'gzip' or '' (no encoding)
|
||||
*
|
||||
* 'encodeLevel' : level of encoding compression (0 to 9, default 9)
|
||||
*
|
||||
* 'contentTypeCharset' : appended to the Content-Type header sent. Set to a falsey
|
||||
* value to remove. (default 'utf-8')
|
||||
*
|
||||
* 'maxAge' : set this to the number of seconds the client should use its cache
|
||||
* before revalidating with the server. This sets Cache-Control: max-age and the
|
||||
* Expires header. Unlike the old 'setExpires' setting, this setting will NOT
|
||||
* prevent conditional GETs. Note this has nothing to do with server-side caching.
|
||||
*
|
||||
* 'rewriteCssUris' : If true, serve() will automatically set the 'currentDir'
|
||||
* minifier option to enable URI rewriting in CSS files (default true)
|
||||
*
|
||||
* 'bubbleCssImports' : If true, all @import declarations in combined CSS
|
||||
* files will be move to the top. Note this may alter effective CSS values
|
||||
* due to a change in order. (default false)
|
||||
*
|
||||
* 'debug' : set to true to minify all sources with the 'Lines' controller, which
|
||||
* eases the debugging of combined files. This also prevents 304 responses.
|
||||
* @see Minify_Lines::minify()
|
||||
*
|
||||
* 'minifiers' : to override Minify's default choice of minifier function for
|
||||
* a particular content-type, specify your callback under the key of the
|
||||
* content-type:
|
||||
* <code>
|
||||
* // call customCssMinifier($css) for all CSS minification
|
||||
* $options['minifiers'][Minify::TYPE_CSS] = 'customCssMinifier';
|
||||
*
|
||||
* // don't minify Javascript at all
|
||||
* $options['minifiers'][Minify::TYPE_JS] = '';
|
||||
* </code>
|
||||
*
|
||||
* 'minifierOptions' : to send options to the minifier function, specify your options
|
||||
* under the key of the content-type. E.g. To send the CSS minifier an option:
|
||||
* <code>
|
||||
* // give CSS minifier array('optionName' => 'optionValue') as 2nd argument
|
||||
* $options['minifierOptions'][Minify::TYPE_CSS]['optionName'] = 'optionValue';
|
||||
* </code>
|
||||
*
|
||||
* 'contentType' : (optional) this is only needed if your file extension is not
|
||||
* js/css/html. The given content-type will be sent regardless of source file
|
||||
* extension, so this should not be used in a Groups config with other
|
||||
* Javascript/CSS files.
|
||||
*
|
||||
* Any controller options are documented in that controller's setupSources() method.
|
||||
*
|
||||
* @param mixed $controller instance of subclass of Minify_Controller_Base or string
|
||||
* name of controller. E.g. 'Files'
|
||||
*
|
||||
* @param array $options controller/serve options
|
||||
*
|
||||
* @return null|array if the 'quiet' option is set to true, an array
|
||||
* with keys "success" (bool), "statusCode" (int), "content" (string), and
|
||||
* "headers" (array).
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function serve($controller, $options = array())
|
||||
{
|
||||
if (! self::$isDocRootSet && 0 === stripos(PHP_OS, 'win')) {
|
||||
self::setDocRoot();
|
||||
}
|
||||
|
||||
if (is_string($controller)) {
|
||||
// make $controller into object
|
||||
$class = 'Minify_Controller_' . $controller;
|
||||
$controller = new $class();
|
||||
/* @var Minify_Controller_Base $controller */
|
||||
}
|
||||
|
||||
// set up controller sources and mix remaining options with
|
||||
// controller defaults
|
||||
$options = $controller->setupSources($options);
|
||||
$options = $controller->analyzeSources($options);
|
||||
self::$_options = $controller->mixInDefaultOptions($options);
|
||||
|
||||
// check request validity
|
||||
if (! $controller->sources) {
|
||||
// invalid request!
|
||||
if (! self::$_options['quiet']) {
|
||||
self::_errorExit(self::$_options['badRequestHeader'], self::URL_DEBUG);
|
||||
} else {
|
||||
list(,$statusCode) = explode(' ', self::$_options['badRequestHeader']);
|
||||
return array(
|
||||
'success' => false
|
||||
,'statusCode' => (int)$statusCode
|
||||
,'content' => ''
|
||||
,'headers' => array()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
self::$_controller = $controller;
|
||||
|
||||
if (self::$_options['debug']) {
|
||||
self::_setupDebug($controller->sources);
|
||||
self::$_options['maxAge'] = 0;
|
||||
}
|
||||
|
||||
// determine encoding
|
||||
if (self::$_options['encodeOutput']) {
|
||||
$sendVary = true;
|
||||
if (self::$_options['encodeMethod'] !== null) {
|
||||
// controller specifically requested this
|
||||
$contentEncoding = self::$_options['encodeMethod'];
|
||||
} else {
|
||||
// sniff request header
|
||||
// depending on what the client accepts, $contentEncoding may be
|
||||
// 'x-gzip' while our internal encodeMethod is 'gzip'. Calling
|
||||
// getAcceptedEncoding(false, false) leaves out compress and deflate as options.
|
||||
list(self::$_options['encodeMethod'], $contentEncoding) = HTTP_Encoder::getAcceptedEncoding(false, false);
|
||||
$sendVary = ! HTTP_Encoder::isBuggyIe();
|
||||
}
|
||||
} else {
|
||||
self::$_options['encodeMethod'] = ''; // identity (no encoding)
|
||||
}
|
||||
|
||||
// check client cache
|
||||
$cgOptions = array(
|
||||
'lastModifiedTime' => self::$_options['lastModifiedTime']
|
||||
,'isPublic' => self::$_options['isPublic']
|
||||
,'encoding' => self::$_options['encodeMethod']
|
||||
);
|
||||
if (self::$_options['maxAge'] > 0) {
|
||||
$cgOptions['maxAge'] = self::$_options['maxAge'];
|
||||
} elseif (self::$_options['debug']) {
|
||||
$cgOptions['invalidate'] = true;
|
||||
}
|
||||
$cg = new HTTP_ConditionalGet($cgOptions);
|
||||
if ($cg->cacheIsValid) {
|
||||
// client's cache is valid
|
||||
if (! self::$_options['quiet']) {
|
||||
$cg->sendHeaders();
|
||||
return;
|
||||
} else {
|
||||
return array(
|
||||
'success' => true
|
||||
,'statusCode' => 304
|
||||
,'content' => ''
|
||||
,'headers' => $cg->getHeaders()
|
||||
);
|
||||
}
|
||||
} else {
|
||||
// client will need output
|
||||
$headers = $cg->getHeaders();
|
||||
unset($cg);
|
||||
}
|
||||
|
||||
if (self::$_options['contentType'] === self::TYPE_CSS
|
||||
&& self::$_options['rewriteCssUris']) {
|
||||
foreach($controller->sources as $key => $source) {
|
||||
if ($source->filepath
|
||||
&& !isset($source->minifyOptions['currentDir'])
|
||||
&& !isset($source->minifyOptions['prependRelativePath'])
|
||||
) {
|
||||
$source->minifyOptions['currentDir'] = dirname($source->filepath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// check server cache
|
||||
if (null !== self::$_cache && ! self::$_options['debug']) {
|
||||
// using cache
|
||||
// the goal is to use only the cache methods to sniff the length and
|
||||
// output the content, as they do not require ever loading the file into
|
||||
// memory.
|
||||
$cacheId = self::_getCacheId();
|
||||
$fullCacheId = (self::$_options['encodeMethod'])
|
||||
? $cacheId . '.gz'
|
||||
: $cacheId;
|
||||
// check cache for valid entry
|
||||
$cacheIsReady = self::$_cache->isValid($fullCacheId, self::$_options['lastModifiedTime']);
|
||||
if ($cacheIsReady) {
|
||||
$cacheContentLength = self::$_cache->getSize($fullCacheId);
|
||||
} else {
|
||||
// generate & cache content
|
||||
try {
|
||||
$content = self::_combineMinify();
|
||||
} catch (Exception $e) {
|
||||
self::$_controller->log($e->getMessage());
|
||||
if (! self::$_options['quiet']) {
|
||||
self::_errorExit(self::$_options['errorHeader'], self::URL_DEBUG);
|
||||
}
|
||||
throw $e;
|
||||
}
|
||||
self::$_cache->store($cacheId, $content);
|
||||
if (function_exists('gzencode') && self::$_options['encodeMethod']) {
|
||||
self::$_cache->store($cacheId . '.gz', gzencode($content, self::$_options['encodeLevel']));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// no cache
|
||||
$cacheIsReady = false;
|
||||
try {
|
||||
$content = self::_combineMinify();
|
||||
} catch (Exception $e) {
|
||||
self::$_controller->log($e->getMessage());
|
||||
if (! self::$_options['quiet']) {
|
||||
self::_errorExit(self::$_options['errorHeader'], self::URL_DEBUG);
|
||||
}
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
if (! $cacheIsReady && self::$_options['encodeMethod']) {
|
||||
// still need to encode
|
||||
$content = gzencode($content, self::$_options['encodeLevel']);
|
||||
}
|
||||
|
||||
// add headers
|
||||
$headers['Content-Length'] = $cacheIsReady
|
||||
? $cacheContentLength
|
||||
: ((function_exists('mb_strlen') && ((int)ini_get('mbstring.func_overload') & 2))
|
||||
? mb_strlen($content, '8bit')
|
||||
: strlen($content)
|
||||
);
|
||||
$headers['Content-Type'] = self::$_options['contentTypeCharset']
|
||||
? self::$_options['contentType'] . '; charset=' . self::$_options['contentTypeCharset']
|
||||
: self::$_options['contentType'];
|
||||
if (self::$_options['encodeMethod'] !== '') {
|
||||
$headers['Content-Encoding'] = $contentEncoding;
|
||||
}
|
||||
if (self::$_options['encodeOutput'] && $sendVary) {
|
||||
$headers['Vary'] = 'Accept-Encoding';
|
||||
}
|
||||
|
||||
if (! self::$_options['quiet']) {
|
||||
// output headers & content
|
||||
foreach ($headers as $name => $val) {
|
||||
header($name . ': ' . $val);
|
||||
}
|
||||
if ($cacheIsReady) {
|
||||
self::$_cache->display($fullCacheId);
|
||||
} else {
|
||||
echo $content;
|
||||
}
|
||||
} else {
|
||||
return array(
|
||||
'success' => true
|
||||
,'statusCode' => 200
|
||||
,'content' => $cacheIsReady
|
||||
? self::$_cache->fetch($fullCacheId)
|
||||
: $content
|
||||
,'headers' => $headers
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return combined minified content for a set of sources
|
||||
*
|
||||
* No internal caching will be used and the content will not be HTTP encoded.
|
||||
*
|
||||
* @param array $sources array of filepaths and/or Minify_Source objects
|
||||
*
|
||||
* @param array $options (optional) array of options for serve. By default
|
||||
* these are already set: quiet = true, encodeMethod = '', lastModifiedTime = 0.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function combine($sources, $options = array())
|
||||
{
|
||||
$cache = self::$_cache;
|
||||
self::$_cache = null;
|
||||
$options = array_merge(array(
|
||||
'files' => (array)$sources
|
||||
,'quiet' => true
|
||||
,'encodeMethod' => ''
|
||||
,'lastModifiedTime' => 0
|
||||
), $options);
|
||||
$out = self::serve('Files', $options);
|
||||
self::$_cache = $cache;
|
||||
return $out['content'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Set $_SERVER['DOCUMENT_ROOT']. On IIS, the value is created from SCRIPT_FILENAME and SCRIPT_NAME.
|
||||
*
|
||||
* @param string $docRoot value to use for DOCUMENT_ROOT
|
||||
*/
|
||||
public static function setDocRoot($docRoot = '')
|
||||
{
|
||||
self::$isDocRootSet = true;
|
||||
if ($docRoot) {
|
||||
$_SERVER['DOCUMENT_ROOT'] = $docRoot;
|
||||
} elseif (isset($_SERVER['SERVER_SOFTWARE'])
|
||||
&& 0 === strpos($_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS/')) {
|
||||
$_SERVER['DOCUMENT_ROOT'] = substr(
|
||||
$_SERVER['SCRIPT_FILENAME']
|
||||
,0
|
||||
,strlen($_SERVER['SCRIPT_FILENAME']) - strlen($_SERVER['SCRIPT_NAME']));
|
||||
$_SERVER['DOCUMENT_ROOT'] = rtrim($_SERVER['DOCUMENT_ROOT'], '\\');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Any Minify_Cache_* object or null (i.e. no server cache is used)
|
||||
*
|
||||
* @var Minify_Cache_File
|
||||
*/
|
||||
private static $_cache = null;
|
||||
|
||||
/**
|
||||
* Active controller for current request
|
||||
*
|
||||
* @var Minify_Controller_Base
|
||||
*/
|
||||
protected static $_controller = null;
|
||||
|
||||
/**
|
||||
* Options for current request
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected static $_options = null;
|
||||
|
||||
/**
|
||||
* @param string $header
|
||||
*
|
||||
* @param string $url
|
||||
*/
|
||||
protected static function _errorExit($header, $url)
|
||||
{
|
||||
$url = htmlspecialchars($url, ENT_QUOTES);
|
||||
list(,$h1) = explode(' ', $header, 2);
|
||||
$h1 = htmlspecialchars($h1);
|
||||
// FastCGI environments require 3rd arg to header() to be set
|
||||
list(, $code) = explode(' ', $header, 3);
|
||||
header($header, true, $code);
|
||||
header('Content-Type: text/html; charset=utf-8');
|
||||
echo "<h1>$h1</h1>";
|
||||
echo "<p>Please see <a href='$url'>$url</a>.</p>";
|
||||
exit();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set up sources to use Minify_Lines
|
||||
*
|
||||
* @param Minify_Source[] $sources Minify_Source instances
|
||||
*/
|
||||
protected static function _setupDebug($sources)
|
||||
{
|
||||
foreach ($sources as $source) {
|
||||
$source->minifier = array('Minify_Lines', 'minify');
|
||||
$id = $source->getId();
|
||||
$source->minifyOptions = array(
|
||||
'id' => (is_file($id) ? basename($id) : $id)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Combines sources and minifies the result.
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
protected static function _combineMinify()
|
||||
{
|
||||
$type = self::$_options['contentType']; // ease readability
|
||||
|
||||
// when combining scripts, make sure all statements separated and
|
||||
// trailing single line comment is terminated
|
||||
$implodeSeparator = ($type === self::TYPE_JS)
|
||||
? "\n;"
|
||||
: '';
|
||||
// allow the user to pass a particular array of options to each
|
||||
// minifier (designated by type). source objects may still override
|
||||
// these
|
||||
$defaultOptions = isset(self::$_options['minifierOptions'][$type])
|
||||
? self::$_options['minifierOptions'][$type]
|
||||
: array();
|
||||
// if minifier not set, default is no minification. source objects
|
||||
// may still override this
|
||||
$defaultMinifier = isset(self::$_options['minifiers'][$type])
|
||||
? self::$_options['minifiers'][$type]
|
||||
: false;
|
||||
|
||||
// process groups of sources with identical minifiers/options
|
||||
$content = array();
|
||||
$i = 0;
|
||||
$l = count(self::$_controller->sources);
|
||||
$groupToProcessTogether = array();
|
||||
$lastMinifier = null;
|
||||
$lastOptions = null;
|
||||
do {
|
||||
// get next source
|
||||
$source = null;
|
||||
if ($i < $l) {
|
||||
$source = self::$_controller->sources[$i];
|
||||
/* @var Minify_Source $source */
|
||||
$sourceContent = $source->getContent();
|
||||
|
||||
// allow the source to override our minifier and options
|
||||
$minifier = (null !== $source->minifier)
|
||||
? $source->minifier
|
||||
: $defaultMinifier;
|
||||
$options = (null !== $source->minifyOptions)
|
||||
? array_merge($defaultOptions, $source->minifyOptions)
|
||||
: $defaultOptions;
|
||||
}
|
||||
// do we need to process our group right now?
|
||||
if ($i > 0 // yes, we have at least the first group populated
|
||||
&& (
|
||||
! $source // yes, we ran out of sources
|
||||
|| $type === self::TYPE_CSS // yes, to process CSS individually (avoiding PCRE bugs/limits)
|
||||
|| $minifier !== $lastMinifier // yes, minifier changed
|
||||
|| $options !== $lastOptions) // yes, options changed
|
||||
)
|
||||
{
|
||||
// minify previous sources with last settings
|
||||
$imploded = implode($implodeSeparator, $groupToProcessTogether);
|
||||
$groupToProcessTogether = array();
|
||||
if ($lastMinifier) {
|
||||
try {
|
||||
$content[] = call_user_func($lastMinifier, $imploded, $lastOptions);
|
||||
} catch (Exception $e) {
|
||||
throw new Exception("Exception in minifier: " . $e->getMessage());
|
||||
}
|
||||
} else {
|
||||
$content[] = $imploded;
|
||||
}
|
||||
}
|
||||
// add content to the group
|
||||
if ($source) {
|
||||
$groupToProcessTogether[] = $sourceContent;
|
||||
$lastMinifier = $minifier;
|
||||
$lastOptions = $options;
|
||||
}
|
||||
$i++;
|
||||
} while ($source);
|
||||
|
||||
$content = implode($implodeSeparator, $content);
|
||||
|
||||
if ($type === self::TYPE_CSS && false !== strpos($content, '@import')) {
|
||||
$content = self::_handleCssImports($content);
|
||||
}
|
||||
|
||||
// do any post-processing (esp. for editing build URIs)
|
||||
if (self::$_options['postprocessorRequire']) {
|
||||
require_once self::$_options['postprocessorRequire'];
|
||||
}
|
||||
if (self::$_options['postprocessor']) {
|
||||
$content = call_user_func(self::$_options['postprocessor'], $content, $type);
|
||||
}
|
||||
return $content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a unique cache id for for this request.
|
||||
*
|
||||
* Any settings that could affect output are taken into consideration
|
||||
*
|
||||
* @param string $prefix
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected static function _getCacheId($prefix = 'minify')
|
||||
{
|
||||
$name = preg_replace('/[^a-zA-Z0-9\\.=_,]/', '', self::$_controller->selectionId);
|
||||
$name = preg_replace('/\\.+/', '.', $name);
|
||||
$name = substr($name, 0, 100 - 34 - strlen($prefix));
|
||||
$md5 = md5(serialize(array(
|
||||
Minify_Source::getDigest(self::$_controller->sources)
|
||||
,self::$_options['minifiers']
|
||||
,self::$_options['minifierOptions']
|
||||
,self::$_options['postprocessor']
|
||||
,self::$_options['bubbleCssImports']
|
||||
,self::VERSION
|
||||
)));
|
||||
return "{$prefix}_{$name}_{$md5}";
|
||||
}
|
||||
|
||||
/**
|
||||
* Bubble CSS @imports to the top or prepend a warning if an import is detected not at the top.
|
||||
*
|
||||
* @param string $css
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected static function _handleCssImports($css)
|
||||
{
|
||||
if (self::$_options['bubbleCssImports']) {
|
||||
// bubble CSS imports
|
||||
preg_match_all('/@import.*?;/', $css, $imports);
|
||||
$css = implode('', $imports[0]) . preg_replace('/@import.*?;/', '', $css);
|
||||
} else if ('' !== self::$importWarning) {
|
||||
// remove comments so we don't mistake { in a comment as a block
|
||||
$noCommentCss = preg_replace('@/\\*[\\s\\S]*?\\*/@', '', $css);
|
||||
$lastImportPos = strrpos($noCommentCss, '@import');
|
||||
$firstBlockPos = strpos($noCommentCss, '{');
|
||||
if (false !== $lastImportPos
|
||||
&& false !== $firstBlockPos
|
||||
&& $firstBlockPos < $lastImportPos
|
||||
) {
|
||||
// { appears before @import : prepend warning
|
||||
$css = self::$importWarning . $css;
|
||||
}
|
||||
}
|
||||
return $css;
|
||||
}
|
||||
}
|
||||
101
vendor/mrclay/minify/min/lib/Minify/Build.php
vendored
101
vendor/mrclay/minify/min/lib/Minify/Build.php
vendored
@@ -1,101 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Class Minify_Build
|
||||
* @package Minify
|
||||
*/
|
||||
|
||||
/**
|
||||
* Maintain a single last modification time for a group of Minify sources to
|
||||
* allow use of far off Expires headers in Minify.
|
||||
*
|
||||
* <code>
|
||||
* // in config file
|
||||
* $groupSources = array(
|
||||
* 'js' => array('file1.js', 'file2.js')
|
||||
* ,'css' => array('file1.css', 'file2.css', 'file3.css')
|
||||
* )
|
||||
*
|
||||
* // during HTML generation
|
||||
* $jsBuild = new Minify_Build($groupSources['js']);
|
||||
* $cssBuild = new Minify_Build($groupSources['css']);
|
||||
*
|
||||
* $script = "<script type='text/javascript' src='"
|
||||
* . $jsBuild->uri('/min.php/js') . "'></script>";
|
||||
* $link = "<link rel='stylesheet' type='text/css' href='"
|
||||
* . $cssBuild->uri('/min.php/css') . "'>";
|
||||
*
|
||||
* // in min.php
|
||||
* Minify::serve('Groups', array(
|
||||
* 'groups' => $groupSources
|
||||
* ,'setExpires' => (time() + 86400 * 365)
|
||||
* ));
|
||||
* </code>
|
||||
*
|
||||
* @package Minify
|
||||
* @author Stephen Clay <steve@mrclay.org>
|
||||
*/
|
||||
class Minify_Build {
|
||||
|
||||
/**
|
||||
* Last modification time of all files in the build
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $lastModified = 0;
|
||||
|
||||
/**
|
||||
* String to use as ampersand in uri(). Set this to '&' if
|
||||
* you are not HTML-escaping URIs.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public static $ampersand = '&';
|
||||
|
||||
/**
|
||||
* Get a time-stamped URI
|
||||
*
|
||||
* <code>
|
||||
* echo $b->uri('/site.js');
|
||||
* // outputs "/site.js?1678242"
|
||||
*
|
||||
* echo $b->uri('/scriptaculous.js?load=effects');
|
||||
* // outputs "/scriptaculous.js?load=effects&1678242"
|
||||
* </code>
|
||||
*
|
||||
* @param string $uri
|
||||
* @param boolean $forceAmpersand (default = false) Force the use of ampersand to
|
||||
* append the timestamp to the URI.
|
||||
* @return string
|
||||
*/
|
||||
public function uri($uri, $forceAmpersand = false) {
|
||||
$sep = ($forceAmpersand || strpos($uri, '?') !== false)
|
||||
? self::$ampersand
|
||||
: '?';
|
||||
return "{$uri}{$sep}{$this->lastModified}";
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a build object
|
||||
*
|
||||
* @param array $sources array of Minify_Source objects and/or file paths
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
public function __construct($sources)
|
||||
{
|
||||
$max = 0;
|
||||
foreach ((array)$sources as $source) {
|
||||
if ($source instanceof Minify_Source) {
|
||||
$max = max($max, $source->lastModified);
|
||||
} elseif (is_string($source)) {
|
||||
if (0 === strpos($source, '//')) {
|
||||
$source = $_SERVER['DOCUMENT_ROOT'] . substr($source, 1);
|
||||
}
|
||||
if (is_file($source)) {
|
||||
$max = max($max, filemtime($source));
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->lastModified = $max;
|
||||
}
|
||||
}
|
||||
99
vendor/mrclay/minify/min/lib/Minify/CSS.php
vendored
99
vendor/mrclay/minify/min/lib/Minify/CSS.php
vendored
@@ -1,99 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Class Minify_CSS
|
||||
* @package Minify
|
||||
*/
|
||||
|
||||
/**
|
||||
* Minify CSS
|
||||
*
|
||||
* This class uses Minify_CSS_Compressor and Minify_CSS_UriRewriter to
|
||||
* minify CSS and rewrite relative URIs.
|
||||
*
|
||||
* @package Minify
|
||||
* @author Stephen Clay <steve@mrclay.org>
|
||||
* @author http://code.google.com/u/1stvamp/ (Issue 64 patch)
|
||||
*/
|
||||
class Minify_CSS {
|
||||
|
||||
/**
|
||||
* Minify a CSS string
|
||||
*
|
||||
* @param string $css
|
||||
*
|
||||
* @param array $options available options:
|
||||
*
|
||||
* 'preserveComments': (default true) multi-line comments that begin
|
||||
* with "/*!" will be preserved with newlines before and after to
|
||||
* enhance readability.
|
||||
*
|
||||
* 'removeCharsets': (default true) remove all @charset at-rules
|
||||
*
|
||||
* 'prependRelativePath': (default null) if given, this string will be
|
||||
* prepended to all relative URIs in import/url declarations
|
||||
*
|
||||
* 'currentDir': (default null) if given, this is assumed to be the
|
||||
* directory of the current CSS file. Using this, minify will rewrite
|
||||
* all relative URIs in import/url declarations to correctly point to
|
||||
* the desired files. For this to work, the files *must* exist and be
|
||||
* visible by the PHP process.
|
||||
*
|
||||
* 'symlinks': (default = array()) If the CSS file is stored in
|
||||
* a symlink-ed directory, provide an array of link paths to
|
||||
* target paths, where the link paths are within the document root. Because
|
||||
* paths need to be normalized for this to work, use "//" to substitute
|
||||
* the doc root in the link paths (the array keys). E.g.:
|
||||
* <code>
|
||||
* array('//symlink' => '/real/target/path') // unix
|
||||
* array('//static' => 'D:\\staticStorage') // Windows
|
||||
* </code>
|
||||
*
|
||||
* 'docRoot': (default = $_SERVER['DOCUMENT_ROOT'])
|
||||
* see Minify_CSS_UriRewriter::rewrite
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function minify($css, $options = array())
|
||||
{
|
||||
$options = array_merge(array(
|
||||
'compress' => true,
|
||||
'removeCharsets' => true,
|
||||
'preserveComments' => true,
|
||||
'currentDir' => null,
|
||||
'docRoot' => $_SERVER['DOCUMENT_ROOT'],
|
||||
'prependRelativePath' => null,
|
||||
'symlinks' => array(),
|
||||
), $options);
|
||||
|
||||
if ($options['removeCharsets']) {
|
||||
$css = preg_replace('/@charset[^;]+;\\s*/', '', $css);
|
||||
}
|
||||
if ($options['compress']) {
|
||||
if (! $options['preserveComments']) {
|
||||
$css = Minify_CSS_Compressor::process($css, $options);
|
||||
} else {
|
||||
$css = Minify_CommentPreserver::process(
|
||||
$css
|
||||
,array('Minify_CSS_Compressor', 'process')
|
||||
,array($options)
|
||||
);
|
||||
}
|
||||
}
|
||||
if (! $options['currentDir'] && ! $options['prependRelativePath']) {
|
||||
return $css;
|
||||
}
|
||||
if ($options['currentDir']) {
|
||||
return Minify_CSS_UriRewriter::rewrite(
|
||||
$css
|
||||
,$options['currentDir']
|
||||
,$options['docRoot']
|
||||
,$options['symlinks']
|
||||
);
|
||||
} else {
|
||||
return Minify_CSS_UriRewriter::prepend(
|
||||
$css
|
||||
,$options['prependRelativePath']
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,249 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Class Minify_CSS_Compressor
|
||||
* @package Minify
|
||||
*/
|
||||
|
||||
/**
|
||||
* Compress CSS
|
||||
*
|
||||
* This is a heavy regex-based removal of whitespace, unnecessary
|
||||
* comments and tokens, and some CSS value minimization, where practical.
|
||||
* Many steps have been taken to avoid breaking comment-based hacks,
|
||||
* including the ie5/mac filter (and its inversion), but expect tricky
|
||||
* hacks involving comment tokens in 'content' value strings to break
|
||||
* minimization badly. A test suite is available.
|
||||
*
|
||||
* @package Minify
|
||||
* @author Stephen Clay <steve@mrclay.org>
|
||||
* @author http://code.google.com/u/1stvamp/ (Issue 64 patch)
|
||||
*/
|
||||
class Minify_CSS_Compressor {
|
||||
|
||||
/**
|
||||
* Minify a CSS string
|
||||
*
|
||||
* @param string $css
|
||||
*
|
||||
* @param array $options (currently ignored)
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function process($css, $options = array())
|
||||
{
|
||||
$obj = new Minify_CSS_Compressor($options);
|
||||
return $obj->_process($css);
|
||||
}
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $_options = null;
|
||||
|
||||
/**
|
||||
* Are we "in" a hack? I.e. are some browsers targetted until the next comment?
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $_inHack = false;
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param array $options (currently ignored)
|
||||
*/
|
||||
private function __construct($options) {
|
||||
$this->_options = $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Minify a CSS string
|
||||
*
|
||||
* @param string $css
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function _process($css)
|
||||
{
|
||||
$css = str_replace("\r\n", "\n", $css);
|
||||
|
||||
// preserve empty comment after '>'
|
||||
// http://www.webdevout.net/css-hacks#in_css-selectors
|
||||
$css = preg_replace('@>/\\*\\s*\\*/@', '>/*keep*/', $css);
|
||||
|
||||
// preserve empty comment between property and value
|
||||
// http://css-discuss.incutio.com/?page=BoxModelHack
|
||||
$css = preg_replace('@/\\*\\s*\\*/\\s*:@', '/*keep*/:', $css);
|
||||
$css = preg_replace('@:\\s*/\\*\\s*\\*/@', ':/*keep*/', $css);
|
||||
|
||||
// apply callback to all valid comments (and strip out surrounding ws
|
||||
$css = preg_replace_callback('@\\s*/\\*([\\s\\S]*?)\\*/\\s*@'
|
||||
,array($this, '_commentCB'), $css);
|
||||
|
||||
// remove ws around { } and last semicolon in declaration block
|
||||
$css = preg_replace('/\\s*{\\s*/', '{', $css);
|
||||
$css = preg_replace('/;?\\s*}\\s*/', '}', $css);
|
||||
|
||||
// remove ws surrounding semicolons
|
||||
$css = preg_replace('/\\s*;\\s*/', ';', $css);
|
||||
|
||||
// remove ws around urls
|
||||
$css = preg_replace('/
|
||||
url\\( # url(
|
||||
\\s*
|
||||
([^\\)]+?) # 1 = the URL (really just a bunch of non right parenthesis)
|
||||
\\s*
|
||||
\\) # )
|
||||
/x', 'url($1)', $css);
|
||||
|
||||
// remove ws between rules and colons
|
||||
$css = preg_replace('/
|
||||
\\s*
|
||||
([{;]) # 1 = beginning of block or rule separator
|
||||
\\s*
|
||||
([\\*_]?[\\w\\-]+) # 2 = property (and maybe IE filter)
|
||||
\\s*
|
||||
:
|
||||
\\s*
|
||||
(\\b|[#\'"-]) # 3 = first character of a value
|
||||
/x', '$1$2:$3', $css);
|
||||
|
||||
// remove ws in selectors
|
||||
$css = preg_replace_callback('/
|
||||
(?: # non-capture
|
||||
\\s*
|
||||
[^~>+,\\s]+ # selector part
|
||||
\\s*
|
||||
[,>+~] # combinators
|
||||
)+
|
||||
\\s*
|
||||
[^~>+,\\s]+ # selector part
|
||||
{ # open declaration block
|
||||
/x'
|
||||
,array($this, '_selectorsCB'), $css);
|
||||
|
||||
// minimize hex colors
|
||||
$css = preg_replace('/([^=])#([a-f\\d])\\2([a-f\\d])\\3([a-f\\d])\\4([\\s;\\}])/i'
|
||||
, '$1#$2$3$4$5', $css);
|
||||
|
||||
// remove spaces between font families
|
||||
$css = preg_replace_callback('/font-family:([^;}]+)([;}])/'
|
||||
,array($this, '_fontFamilyCB'), $css);
|
||||
|
||||
$css = preg_replace('/@import\\s+url/', '@import url', $css);
|
||||
|
||||
// replace any ws involving newlines with a single newline
|
||||
$css = preg_replace('/[ \\t]*\\n+\\s*/', "\n", $css);
|
||||
|
||||
// separate common descendent selectors w/ newlines (to limit line lengths)
|
||||
$css = preg_replace('/([\\w#\\.\\*]+)\\s+([\\w#\\.\\*]+){/', "$1\n$2{", $css);
|
||||
|
||||
// Use newline after 1st numeric value (to limit line lengths).
|
||||
$css = preg_replace('/
|
||||
((?:padding|margin|border|outline):\\d+(?:px|em)?) # 1 = prop : 1st numeric value
|
||||
\\s+
|
||||
/x'
|
||||
,"$1\n", $css);
|
||||
|
||||
// prevent triggering IE6 bug: http://www.crankygeek.com/ie6pebug/
|
||||
$css = preg_replace('/:first-l(etter|ine)\\{/', ':first-l$1 {', $css);
|
||||
|
||||
return trim($css);
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace what looks like a set of selectors
|
||||
*
|
||||
* @param array $m regex matches
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function _selectorsCB($m)
|
||||
{
|
||||
// remove ws around the combinators
|
||||
return preg_replace('/\\s*([,>+~])\\s*/', '$1', $m[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Process a comment and return a replacement
|
||||
*
|
||||
* @param array $m regex matches
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function _commentCB($m)
|
||||
{
|
||||
$hasSurroundingWs = (trim($m[0]) !== $m[1]);
|
||||
$m = $m[1];
|
||||
// $m is the comment content w/o the surrounding tokens,
|
||||
// but the return value will replace the entire comment.
|
||||
if ($m === 'keep') {
|
||||
return '/**/';
|
||||
}
|
||||
if ($m === '" "') {
|
||||
// component of http://tantek.com/CSS/Examples/midpass.html
|
||||
return '/*" "*/';
|
||||
}
|
||||
if (preg_match('@";\\}\\s*\\}/\\*\\s+@', $m)) {
|
||||
// component of http://tantek.com/CSS/Examples/midpass.html
|
||||
return '/*";}}/* */';
|
||||
}
|
||||
if ($this->_inHack) {
|
||||
// inversion: feeding only to one browser
|
||||
if (preg_match('@
|
||||
^/ # comment started like /*/
|
||||
\\s*
|
||||
(\\S[\\s\\S]+?) # has at least some non-ws content
|
||||
\\s*
|
||||
/\\* # ends like /*/ or /**/
|
||||
@x', $m, $n)) {
|
||||
// end hack mode after this comment, but preserve the hack and comment content
|
||||
$this->_inHack = false;
|
||||
return "/*/{$n[1]}/**/";
|
||||
}
|
||||
}
|
||||
if (substr($m, -1) === '\\') { // comment ends like \*/
|
||||
// begin hack mode and preserve hack
|
||||
$this->_inHack = true;
|
||||
return '/*\\*/';
|
||||
}
|
||||
if ($m !== '' && $m[0] === '/') { // comment looks like /*/ foo */
|
||||
// begin hack mode and preserve hack
|
||||
$this->_inHack = true;
|
||||
return '/*/*/';
|
||||
}
|
||||
if ($this->_inHack) {
|
||||
// a regular comment ends hack mode but should be preserved
|
||||
$this->_inHack = false;
|
||||
return '/**/';
|
||||
}
|
||||
// Issue 107: if there's any surrounding whitespace, it may be important, so
|
||||
// replace the comment with a single space
|
||||
return $hasSurroundingWs // remove all other comments
|
||||
? ' '
|
||||
: '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Process a font-family listing and return a replacement
|
||||
*
|
||||
* @param array $m regex matches
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function _fontFamilyCB($m)
|
||||
{
|
||||
// Issue 210: must not eliminate WS between words in unquoted families
|
||||
$pieces = preg_split('/(\'[^\']+\'|"[^"]+")/', $m[1], null, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
|
||||
$out = 'font-family:';
|
||||
while (null !== ($piece = array_shift($pieces))) {
|
||||
if ($piece[0] !== '"' && $piece[0] !== "'") {
|
||||
$piece = preg_replace('/\\s+/', ' ', $piece);
|
||||
$piece = preg_replace('/\\s?,\\s?/', ',', $piece);
|
||||
}
|
||||
$out .= $piece;
|
||||
}
|
||||
return $out . $m[2];
|
||||
}
|
||||
}
|
||||
@@ -1,307 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Class Minify_CSS_UriRewriter
|
||||
* @package Minify
|
||||
*/
|
||||
|
||||
/**
|
||||
* Rewrite file-relative URIs as root-relative in CSS files
|
||||
*
|
||||
* @package Minify
|
||||
* @author Stephen Clay <steve@mrclay.org>
|
||||
*/
|
||||
class Minify_CSS_UriRewriter {
|
||||
|
||||
/**
|
||||
* rewrite() and rewriteRelative() append debugging information here
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public static $debugText = '';
|
||||
|
||||
/**
|
||||
* In CSS content, rewrite file relative URIs as root relative
|
||||
*
|
||||
* @param string $css
|
||||
*
|
||||
* @param string $currentDir The directory of the current CSS file.
|
||||
*
|
||||
* @param string $docRoot The document root of the web site in which
|
||||
* the CSS file resides (default = $_SERVER['DOCUMENT_ROOT']).
|
||||
*
|
||||
* @param array $symlinks (default = array()) If the CSS file is stored in
|
||||
* a symlink-ed directory, provide an array of link paths to
|
||||
* target paths, where the link paths are within the document root. Because
|
||||
* paths need to be normalized for this to work, use "//" to substitute
|
||||
* the doc root in the link paths (the array keys). E.g.:
|
||||
* <code>
|
||||
* array('//symlink' => '/real/target/path') // unix
|
||||
* array('//static' => 'D:\\staticStorage') // Windows
|
||||
* </code>
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function rewrite($css, $currentDir, $docRoot = null, $symlinks = array())
|
||||
{
|
||||
self::$_docRoot = self::_realpath(
|
||||
$docRoot ? $docRoot : $_SERVER['DOCUMENT_ROOT']
|
||||
);
|
||||
self::$_currentDir = self::_realpath($currentDir);
|
||||
self::$_symlinks = array();
|
||||
|
||||
// normalize symlinks
|
||||
foreach ($symlinks as $link => $target) {
|
||||
$link = ($link === '//')
|
||||
? self::$_docRoot
|
||||
: str_replace('//', self::$_docRoot . '/', $link);
|
||||
$link = strtr($link, '/', DIRECTORY_SEPARATOR);
|
||||
self::$_symlinks[$link] = self::_realpath($target);
|
||||
}
|
||||
|
||||
self::$debugText .= "docRoot : " . self::$_docRoot . "\n"
|
||||
. "currentDir : " . self::$_currentDir . "\n";
|
||||
if (self::$_symlinks) {
|
||||
self::$debugText .= "symlinks : " . var_export(self::$_symlinks, 1) . "\n";
|
||||
}
|
||||
self::$debugText .= "\n";
|
||||
|
||||
$css = self::_trimUrls($css);
|
||||
|
||||
// rewrite
|
||||
$css = preg_replace_callback('/@import\\s+([\'"])(.*?)[\'"]/'
|
||||
,array(self::$className, '_processUriCB'), $css);
|
||||
$css = preg_replace_callback('/url\\(\\s*([\'"](.*?)[\'"]|[^\\)\\s]+)\\s*\\)/'
|
||||
,array(self::$className, '_processUriCB'), $css);
|
||||
|
||||
return $css;
|
||||
}
|
||||
|
||||
/**
|
||||
* In CSS content, prepend a path to relative URIs
|
||||
*
|
||||
* @param string $css
|
||||
*
|
||||
* @param string $path The path to prepend.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function prepend($css, $path)
|
||||
{
|
||||
self::$_prependPath = $path;
|
||||
|
||||
$css = self::_trimUrls($css);
|
||||
|
||||
// append
|
||||
$css = preg_replace_callback('/@import\\s+([\'"])(.*?)[\'"]/'
|
||||
,array(self::$className, '_processUriCB'), $css);
|
||||
$css = preg_replace_callback('/url\\(\\s*([\'"](.*?)[\'"]|[^\\)\\s]+)\\s*\\)/'
|
||||
,array(self::$className, '_processUriCB'), $css);
|
||||
|
||||
self::$_prependPath = null;
|
||||
return $css;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a root relative URI from a file relative URI
|
||||
*
|
||||
* <code>
|
||||
* Minify_CSS_UriRewriter::rewriteRelative(
|
||||
* '../img/hello.gif'
|
||||
* , '/home/user/www/css' // path of CSS file
|
||||
* , '/home/user/www' // doc root
|
||||
* );
|
||||
* // returns '/img/hello.gif'
|
||||
*
|
||||
* // example where static files are stored in a symlinked directory
|
||||
* Minify_CSS_UriRewriter::rewriteRelative(
|
||||
* 'hello.gif'
|
||||
* , '/var/staticFiles/theme'
|
||||
* , '/home/user/www'
|
||||
* , array('/home/user/www/static' => '/var/staticFiles')
|
||||
* );
|
||||
* // returns '/static/theme/hello.gif'
|
||||
* </code>
|
||||
*
|
||||
* @param string $uri file relative URI
|
||||
*
|
||||
* @param string $realCurrentDir realpath of the current file's directory.
|
||||
*
|
||||
* @param string $realDocRoot realpath of the site document root.
|
||||
*
|
||||
* @param array $symlinks (default = array()) If the file is stored in
|
||||
* a symlink-ed directory, provide an array of link paths to
|
||||
* real target paths, where the link paths "appear" to be within the document
|
||||
* root. E.g.:
|
||||
* <code>
|
||||
* array('/home/foo/www/not/real/path' => '/real/target/path') // unix
|
||||
* array('C:\\htdocs\\not\\real' => 'D:\\real\\target\\path') // Windows
|
||||
* </code>
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function rewriteRelative($uri, $realCurrentDir, $realDocRoot, $symlinks = array())
|
||||
{
|
||||
// prepend path with current dir separator (OS-independent)
|
||||
$path = strtr($realCurrentDir, '/', DIRECTORY_SEPARATOR)
|
||||
. DIRECTORY_SEPARATOR . strtr($uri, '/', DIRECTORY_SEPARATOR);
|
||||
|
||||
self::$debugText .= "file-relative URI : {$uri}\n"
|
||||
. "path prepended : {$path}\n";
|
||||
|
||||
// "unresolve" a symlink back to doc root
|
||||
foreach ($symlinks as $link => $target) {
|
||||
if (0 === strpos($path, $target)) {
|
||||
// replace $target with $link
|
||||
$path = $link . substr($path, strlen($target));
|
||||
|
||||
self::$debugText .= "symlink unresolved : {$path}\n";
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
// strip doc root
|
||||
$path = substr($path, strlen($realDocRoot));
|
||||
|
||||
self::$debugText .= "docroot stripped : {$path}\n";
|
||||
|
||||
// fix to root-relative URI
|
||||
$uri = strtr($path, '/\\', '//');
|
||||
$uri = self::removeDots($uri);
|
||||
|
||||
self::$debugText .= "traversals removed : {$uri}\n\n";
|
||||
|
||||
return $uri;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove instances of "./" and "../" where possible from a root-relative URI
|
||||
*
|
||||
* @param string $uri
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function removeDots($uri)
|
||||
{
|
||||
$uri = str_replace('/./', '/', $uri);
|
||||
// inspired by patch from Oleg Cherniy
|
||||
do {
|
||||
$uri = preg_replace('@/[^/]+/\\.\\./@', '/', $uri, 1, $changed);
|
||||
} while ($changed);
|
||||
return $uri;
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines which class to call as part of callbacks, change this
|
||||
* if you extend Minify_CSS_UriRewriter
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected static $className = 'Minify_CSS_UriRewriter';
|
||||
|
||||
/**
|
||||
* Get realpath with any trailing slash removed. If realpath() fails,
|
||||
* just remove the trailing slash.
|
||||
*
|
||||
* @param string $path
|
||||
*
|
||||
* @return mixed path with no trailing slash
|
||||
*/
|
||||
protected static function _realpath($path)
|
||||
{
|
||||
$realPath = realpath($path);
|
||||
if ($realPath !== false) {
|
||||
$path = $realPath;
|
||||
}
|
||||
return rtrim($path, '/\\');
|
||||
}
|
||||
|
||||
/**
|
||||
* Directory of this stylesheet
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private static $_currentDir = '';
|
||||
|
||||
/**
|
||||
* DOC_ROOT
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private static $_docRoot = '';
|
||||
|
||||
/**
|
||||
* directory replacements to map symlink targets back to their
|
||||
* source (within the document root) E.g. '/var/www/symlink' => '/var/realpath'
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private static $_symlinks = array();
|
||||
|
||||
/**
|
||||
* Path to prepend
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private static $_prependPath = null;
|
||||
|
||||
/**
|
||||
* @param string $css
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private static function _trimUrls($css)
|
||||
{
|
||||
return preg_replace('/
|
||||
url\\( # url(
|
||||
\\s*
|
||||
([^\\)]+?) # 1 = URI (assuming does not contain ")")
|
||||
\\s*
|
||||
\\) # )
|
||||
/x', 'url($1)', $css);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $m
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private static function _processUriCB($m)
|
||||
{
|
||||
// $m matched either '/@import\\s+([\'"])(.*?)[\'"]/' or '/url\\(\\s*([^\\)\\s]+)\\s*\\)/'
|
||||
$isImport = ($m[0][0] === '@');
|
||||
// determine URI and the quote character (if any)
|
||||
if ($isImport) {
|
||||
$quoteChar = $m[1];
|
||||
$uri = $m[2];
|
||||
} else {
|
||||
// $m[1] is either quoted or not
|
||||
$quoteChar = ($m[1][0] === "'" || $m[1][0] === '"')
|
||||
? $m[1][0]
|
||||
: '';
|
||||
$uri = ($quoteChar === '')
|
||||
? $m[1]
|
||||
: substr($m[1], 1, strlen($m[1]) - 2);
|
||||
}
|
||||
// if not root/scheme relative and not starts with scheme
|
||||
if (!preg_match('~^(/|[a-z]+\:)~', $uri)) {
|
||||
// URI is file-relative: rewrite depending on options
|
||||
if (self::$_prependPath === null) {
|
||||
$uri = self::rewriteRelative($uri, self::$_currentDir, self::$_docRoot, self::$_symlinks);
|
||||
} else {
|
||||
$uri = self::$_prependPath . $uri;
|
||||
if ($uri[0] === '/') {
|
||||
$root = '';
|
||||
$rootRelative = $uri;
|
||||
$uri = $root . self::removeDots($rootRelative);
|
||||
} elseif (preg_match('@^((https?\:)?//([^/]+))/@', $uri, $m) && (false !== strpos($m[3], '.'))) {
|
||||
$root = $m[1];
|
||||
$rootRelative = substr($uri, strlen($root));
|
||||
$uri = $root . self::removeDots($rootRelative);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $isImport
|
||||
? "@import {$quoteChar}{$uri}{$quoteChar}"
|
||||
: "url({$quoteChar}{$uri}{$quoteChar})";
|
||||
}
|
||||
}
|
||||
85
vendor/mrclay/minify/min/lib/Minify/CSSmin.php
vendored
85
vendor/mrclay/minify/min/lib/Minify/CSSmin.php
vendored
@@ -1,85 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Class Minify_CSSmin
|
||||
* @package Minify
|
||||
*/
|
||||
|
||||
/**
|
||||
* Wrapper for CSSmin
|
||||
*
|
||||
* This class uses CSSmin and Minify_CSS_UriRewriter to minify CSS and rewrite relative URIs.
|
||||
*
|
||||
* @package Minify
|
||||
* @author Stephen Clay <steve@mrclay.org>
|
||||
*/
|
||||
class Minify_CSSmin {
|
||||
|
||||
/**
|
||||
* Minify a CSS string
|
||||
*
|
||||
* @param string $css
|
||||
*
|
||||
* @param array $options available options:
|
||||
*
|
||||
* 'removeCharsets': (default true) remove all @charset at-rules
|
||||
*
|
||||
* 'prependRelativePath': (default null) if given, this string will be
|
||||
* prepended to all relative URIs in import/url declarations
|
||||
*
|
||||
* 'currentDir': (default null) if given, this is assumed to be the
|
||||
* directory of the current CSS file. Using this, minify will rewrite
|
||||
* all relative URIs in import/url declarations to correctly point to
|
||||
* the desired files. For this to work, the files *must* exist and be
|
||||
* visible by the PHP process.
|
||||
*
|
||||
* 'symlinks': (default = array()) If the CSS file is stored in
|
||||
* a symlink-ed directory, provide an array of link paths to
|
||||
* target paths, where the link paths are within the document root. Because
|
||||
* paths need to be normalized for this to work, use "//" to substitute
|
||||
* the doc root in the link paths (the array keys). E.g.:
|
||||
* <code>
|
||||
* array('//symlink' => '/real/target/path') // unix
|
||||
* array('//static' => 'D:\\staticStorage') // Windows
|
||||
* </code>
|
||||
*
|
||||
* 'docRoot': (default = $_SERVER['DOCUMENT_ROOT'])
|
||||
* see Minify_CSS_UriRewriter::rewrite
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function minify($css, $options = array())
|
||||
{
|
||||
$options = array_merge(array(
|
||||
'compress' => true,
|
||||
'removeCharsets' => true,
|
||||
'currentDir' => null,
|
||||
'docRoot' => $_SERVER['DOCUMENT_ROOT'],
|
||||
'prependRelativePath' => null,
|
||||
'symlinks' => array(),
|
||||
), $options);
|
||||
|
||||
if ($options['removeCharsets']) {
|
||||
$css = preg_replace('/@charset[^;]+;\\s*/', '', $css);
|
||||
}
|
||||
if ($options['compress']) {
|
||||
$obj = new CSSmin();
|
||||
$css = $obj->run($css);
|
||||
}
|
||||
if (! $options['currentDir'] && ! $options['prependRelativePath']) {
|
||||
return $css;
|
||||
}
|
||||
if ($options['currentDir']) {
|
||||
return Minify_CSS_UriRewriter::rewrite(
|
||||
$css
|
||||
,$options['currentDir']
|
||||
,$options['docRoot']
|
||||
,$options['symlinks']
|
||||
);
|
||||
} else {
|
||||
return Minify_CSS_UriRewriter::prepend(
|
||||
$css
|
||||
,$options['prependRelativePath']
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
133
vendor/mrclay/minify/min/lib/Minify/Cache/APC.php
vendored
133
vendor/mrclay/minify/min/lib/Minify/Cache/APC.php
vendored
@@ -1,133 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Class Minify_Cache_APC
|
||||
* @package Minify
|
||||
*/
|
||||
|
||||
/**
|
||||
* APC-based cache class for Minify
|
||||
*
|
||||
* <code>
|
||||
* Minify::setCache(new Minify_Cache_APC());
|
||||
* </code>
|
||||
*
|
||||
* @package Minify
|
||||
* @author Chris Edwards
|
||||
**/
|
||||
class Minify_Cache_APC {
|
||||
|
||||
/**
|
||||
* Create a Minify_Cache_APC object, to be passed to
|
||||
* Minify::setCache().
|
||||
*
|
||||
*
|
||||
* @param int $expire seconds until expiration (default = 0
|
||||
* meaning the item will not get an expiration date)
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
public function __construct($expire = 0)
|
||||
{
|
||||
$this->_exp = $expire;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write data to cache.
|
||||
*
|
||||
* @param string $id cache id
|
||||
*
|
||||
* @param string $data
|
||||
*
|
||||
* @return bool success
|
||||
*/
|
||||
public function store($id, $data)
|
||||
{
|
||||
return apc_store($id, "{$_SERVER['REQUEST_TIME']}|{$data}", $this->_exp);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the size of a cache entry
|
||||
*
|
||||
* @param string $id cache id
|
||||
*
|
||||
* @return int size in bytes
|
||||
*/
|
||||
public function getSize($id)
|
||||
{
|
||||
if (! $this->_fetch($id)) {
|
||||
return false;
|
||||
}
|
||||
return (function_exists('mb_strlen') && ((int)ini_get('mbstring.func_overload') & 2))
|
||||
? mb_strlen($this->_data, '8bit')
|
||||
: strlen($this->_data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Does a valid cache entry exist?
|
||||
*
|
||||
* @param string $id cache id
|
||||
*
|
||||
* @param int $srcMtime mtime of the original source file(s)
|
||||
*
|
||||
* @return bool exists
|
||||
*/
|
||||
public function isValid($id, $srcMtime)
|
||||
{
|
||||
return ($this->_fetch($id) && ($this->_lm >= $srcMtime));
|
||||
}
|
||||
|
||||
/**
|
||||
* Send the cached content to output
|
||||
*
|
||||
* @param string $id cache id
|
||||
*/
|
||||
public function display($id)
|
||||
{
|
||||
echo $this->_fetch($id)
|
||||
? $this->_data
|
||||
: '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the cached content
|
||||
*
|
||||
* @param string $id cache id
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function fetch($id)
|
||||
{
|
||||
return $this->_fetch($id)
|
||||
? $this->_data
|
||||
: '';
|
||||
}
|
||||
|
||||
private $_exp = null;
|
||||
|
||||
// cache of most recently fetched id
|
||||
private $_lm = null;
|
||||
private $_data = null;
|
||||
private $_id = null;
|
||||
|
||||
/**
|
||||
* Fetch data and timestamp from apc, store in instance
|
||||
*
|
||||
* @param string $id
|
||||
*
|
||||
* @return bool success
|
||||
*/
|
||||
private function _fetch($id)
|
||||
{
|
||||
if ($this->_id === $id) {
|
||||
return true;
|
||||
}
|
||||
$ret = apc_fetch($id);
|
||||
if (false === $ret) {
|
||||
$this->_id = null;
|
||||
return false;
|
||||
}
|
||||
list($this->_lm, $this->_data) = explode('|', $ret, 2);
|
||||
$this->_id = $id;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
197
vendor/mrclay/minify/min/lib/Minify/Cache/File.php
vendored
197
vendor/mrclay/minify/min/lib/Minify/Cache/File.php
vendored
@@ -1,197 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Class Minify_Cache_File
|
||||
* @package Minify
|
||||
*/
|
||||
|
||||
class Minify_Cache_File {
|
||||
|
||||
public function __construct($path = '', $fileLocking = false)
|
||||
{
|
||||
if (! $path) {
|
||||
$path = self::tmp();
|
||||
}
|
||||
$this->_locking = $fileLocking;
|
||||
$this->_path = $path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write data to cache.
|
||||
*
|
||||
* @param string $id cache id (e.g. a filename)
|
||||
*
|
||||
* @param string $data
|
||||
*
|
||||
* @return bool success
|
||||
*/
|
||||
public function store($id, $data)
|
||||
{
|
||||
$flag = $this->_locking
|
||||
? LOCK_EX
|
||||
: null;
|
||||
$file = $this->_path . '/' . $id;
|
||||
if (! @file_put_contents($file, $data, $flag)) {
|
||||
$this->_log("Minify_Cache_File: Write failed to '$file'");
|
||||
}
|
||||
// write control
|
||||
if ($data !== $this->fetch($id)) {
|
||||
@unlink($file);
|
||||
$this->_log("Minify_Cache_File: Post-write read failed for '$file'");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the size of a cache entry
|
||||
*
|
||||
* @param string $id cache id (e.g. a filename)
|
||||
*
|
||||
* @return int size in bytes
|
||||
*/
|
||||
public function getSize($id)
|
||||
{
|
||||
return filesize($this->_path . '/' . $id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Does a valid cache entry exist?
|
||||
*
|
||||
* @param string $id cache id (e.g. a filename)
|
||||
*
|
||||
* @param int $srcMtime mtime of the original source file(s)
|
||||
*
|
||||
* @return bool exists
|
||||
*/
|
||||
public function isValid($id, $srcMtime)
|
||||
{
|
||||
$file = $this->_path . '/' . $id;
|
||||
return (is_file($file) && (filemtime($file) >= $srcMtime));
|
||||
}
|
||||
|
||||
/**
|
||||
* Send the cached content to output
|
||||
*
|
||||
* @param string $id cache id (e.g. a filename)
|
||||
*/
|
||||
public function display($id)
|
||||
{
|
||||
if ($this->_locking) {
|
||||
$fp = fopen($this->_path . '/' . $id, 'rb');
|
||||
flock($fp, LOCK_SH);
|
||||
fpassthru($fp);
|
||||
flock($fp, LOCK_UN);
|
||||
fclose($fp);
|
||||
} else {
|
||||
readfile($this->_path . '/' . $id);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the cached content
|
||||
*
|
||||
* @param string $id cache id (e.g. a filename)
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function fetch($id)
|
||||
{
|
||||
if ($this->_locking) {
|
||||
$fp = fopen($this->_path . '/' . $id, 'rb');
|
||||
if (!$fp) {
|
||||
return false;
|
||||
}
|
||||
flock($fp, LOCK_SH);
|
||||
$ret = stream_get_contents($fp);
|
||||
flock($fp, LOCK_UN);
|
||||
fclose($fp);
|
||||
return $ret;
|
||||
} else {
|
||||
return file_get_contents($this->_path . '/' . $id);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the cache path used
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPath()
|
||||
{
|
||||
return $this->_path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a usable temp directory
|
||||
*
|
||||
* Adapted from Solar/Dir.php
|
||||
* @author Paul M. Jones <pmjones@solarphp.com>
|
||||
* @license http://opensource.org/licenses/bsd-license.php BSD
|
||||
* @link http://solarphp.com/trac/core/browser/trunk/Solar/Dir.php
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function tmp()
|
||||
{
|
||||
static $tmp = null;
|
||||
if (! $tmp) {
|
||||
$tmp = function_exists('sys_get_temp_dir')
|
||||
? sys_get_temp_dir()
|
||||
: self::_tmp();
|
||||
$tmp = rtrim($tmp, DIRECTORY_SEPARATOR);
|
||||
}
|
||||
return $tmp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the OS-specific directory for temporary files
|
||||
*
|
||||
* @author Paul M. Jones <pmjones@solarphp.com>
|
||||
* @license http://opensource.org/licenses/bsd-license.php BSD
|
||||
* @link http://solarphp.com/trac/core/browser/trunk/Solar/Dir.php
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected static function _tmp()
|
||||
{
|
||||
// non-Windows system?
|
||||
if (strtolower(substr(PHP_OS, 0, 3)) != 'win') {
|
||||
$tmp = empty($_ENV['TMPDIR']) ? getenv('TMPDIR') : $_ENV['TMPDIR'];
|
||||
if ($tmp) {
|
||||
return $tmp;
|
||||
} else {
|
||||
return '/tmp';
|
||||
}
|
||||
}
|
||||
// Windows 'TEMP'
|
||||
$tmp = empty($_ENV['TEMP']) ? getenv('TEMP') : $_ENV['TEMP'];
|
||||
if ($tmp) {
|
||||
return $tmp;
|
||||
}
|
||||
// Windows 'TMP'
|
||||
$tmp = empty($_ENV['TMP']) ? getenv('TMP') : $_ENV['TMP'];
|
||||
if ($tmp) {
|
||||
return $tmp;
|
||||
}
|
||||
// Windows 'windir'
|
||||
$tmp = empty($_ENV['windir']) ? getenv('windir') : $_ENV['windir'];
|
||||
if ($tmp) {
|
||||
return $tmp;
|
||||
}
|
||||
// final fallback for Windows
|
||||
return getenv('SystemRoot') . '\\temp';
|
||||
}
|
||||
|
||||
/**
|
||||
* Send message to the Minify logger
|
||||
* @param string $msg
|
||||
* @return null
|
||||
*/
|
||||
protected function _log($msg)
|
||||
{
|
||||
Minify_Logger::log($msg);
|
||||
}
|
||||
|
||||
private $_path = null;
|
||||
private $_locking = null;
|
||||
}
|
||||
@@ -1,140 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Class Minify_Cache_Memcache
|
||||
* @package Minify
|
||||
*/
|
||||
|
||||
/**
|
||||
* Memcache-based cache class for Minify
|
||||
*
|
||||
* <code>
|
||||
* // fall back to disk caching if memcache can't connect
|
||||
* $memcache = new Memcache;
|
||||
* if ($memcache->connect('localhost', 11211)) {
|
||||
* Minify::setCache(new Minify_Cache_Memcache($memcache));
|
||||
* } else {
|
||||
* Minify::setCache();
|
||||
* }
|
||||
* </code>
|
||||
**/
|
||||
class Minify_Cache_Memcache {
|
||||
|
||||
/**
|
||||
* Create a Minify_Cache_Memcache object, to be passed to
|
||||
* Minify::setCache().
|
||||
*
|
||||
* @param Memcache $memcache already-connected instance
|
||||
*
|
||||
* @param int $expire seconds until expiration (default = 0
|
||||
* meaning the item will not get an expiration date)
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
public function __construct($memcache, $expire = 0)
|
||||
{
|
||||
$this->_mc = $memcache;
|
||||
$this->_exp = $expire;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write data to cache.
|
||||
*
|
||||
* @param string $id cache id
|
||||
*
|
||||
* @param string $data
|
||||
*
|
||||
* @return bool success
|
||||
*/
|
||||
public function store($id, $data)
|
||||
{
|
||||
return $this->_mc->set($id, "{$_SERVER['REQUEST_TIME']}|{$data}", 0, $this->_exp);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the size of a cache entry
|
||||
*
|
||||
* @param string $id cache id
|
||||
*
|
||||
* @return int size in bytes
|
||||
*/
|
||||
public function getSize($id)
|
||||
{
|
||||
if (! $this->_fetch($id)) {
|
||||
return false;
|
||||
}
|
||||
return (function_exists('mb_strlen') && ((int)ini_get('mbstring.func_overload') & 2))
|
||||
? mb_strlen($this->_data, '8bit')
|
||||
: strlen($this->_data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Does a valid cache entry exist?
|
||||
*
|
||||
* @param string $id cache id
|
||||
*
|
||||
* @param int $srcMtime mtime of the original source file(s)
|
||||
*
|
||||
* @return bool exists
|
||||
*/
|
||||
public function isValid($id, $srcMtime)
|
||||
{
|
||||
return ($this->_fetch($id) && ($this->_lm >= $srcMtime));
|
||||
}
|
||||
|
||||
/**
|
||||
* Send the cached content to output
|
||||
*
|
||||
* @param string $id cache id
|
||||
*/
|
||||
public function display($id)
|
||||
{
|
||||
echo $this->_fetch($id)
|
||||
? $this->_data
|
||||
: '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the cached content
|
||||
*
|
||||
* @param string $id cache id
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function fetch($id)
|
||||
{
|
||||
return $this->_fetch($id)
|
||||
? $this->_data
|
||||
: '';
|
||||
}
|
||||
|
||||
private $_mc = null;
|
||||
private $_exp = null;
|
||||
|
||||
// cache of most recently fetched id
|
||||
private $_lm = null;
|
||||
private $_data = null;
|
||||
private $_id = null;
|
||||
|
||||
/**
|
||||
* Fetch data and timestamp from memcache, store in instance
|
||||
*
|
||||
* @param string $id
|
||||
*
|
||||
* @return bool success
|
||||
*/
|
||||
private function _fetch($id)
|
||||
{
|
||||
if ($this->_id === $id) {
|
||||
return true;
|
||||
}
|
||||
$ret = $this->_mc->get($id);
|
||||
if (false === $ret) {
|
||||
$this->_id = null;
|
||||
return false;
|
||||
}
|
||||
list($this->_lm, $this->_data) = explode('|', $ret, 2);
|
||||
$this->_id = $id;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
126
vendor/mrclay/minify/min/lib/Minify/Cache/XCache.php
vendored
126
vendor/mrclay/minify/min/lib/Minify/Cache/XCache.php
vendored
@@ -1,126 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Class Minify_Cache_XCache
|
||||
*
|
||||
* @link http://xcache.lighttpd.net/
|
||||
* @package Minify
|
||||
*/
|
||||
|
||||
/**
|
||||
* XCache-based cache class for Minify
|
||||
* {@see http://xcache.lighttpd.net/wiki/XcacheApi XCache API}
|
||||
*
|
||||
* <code>
|
||||
* Minify::setCache(new Minify_Cache_XCache());
|
||||
* </code>
|
||||
*
|
||||
* @package Minify
|
||||
* @author Elan Ruusamäe <glen@delfi.ee>
|
||||
**/
|
||||
class Minify_Cache_XCache {
|
||||
|
||||
/**
|
||||
* Create a Minify_Cache_XCache object, to be passed to
|
||||
* Minify::setCache().
|
||||
*
|
||||
* @param int $expire seconds until expiration (default = 0
|
||||
* meaning the item will not get an expiration date)
|
||||
*/
|
||||
public function __construct($expire = 0)
|
||||
{
|
||||
$this->_exp = $expire;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write data to cache.
|
||||
*
|
||||
* @param string $id cache id
|
||||
* @param string $data
|
||||
* @return bool success
|
||||
*/
|
||||
public function store($id, $data)
|
||||
{
|
||||
return xcache_set($id, "{$_SERVER['REQUEST_TIME']}|{$data}", $this->_exp);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the size of a cache entry
|
||||
*
|
||||
* @param string $id cache id
|
||||
* @return int size in bytes
|
||||
*/
|
||||
public function getSize($id)
|
||||
{
|
||||
if (! $this->_fetch($id)) {
|
||||
return false;
|
||||
}
|
||||
return (function_exists('mb_strlen') && ((int)ini_get('mbstring.func_overload') & 2))
|
||||
? mb_strlen($this->_data, '8bit')
|
||||
: strlen($this->_data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Does a valid cache entry exist?
|
||||
*
|
||||
* @param string $id cache id
|
||||
* @param int $srcMtime mtime of the original source file(s)
|
||||
* @return bool exists
|
||||
*/
|
||||
public function isValid($id, $srcMtime)
|
||||
{
|
||||
return ($this->_fetch($id) && ($this->_lm >= $srcMtime));
|
||||
}
|
||||
|
||||
/**
|
||||
* Send the cached content to output
|
||||
*
|
||||
* @param string $id cache id
|
||||
*/
|
||||
public function display($id)
|
||||
{
|
||||
echo $this->_fetch($id)
|
||||
? $this->_data
|
||||
: '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the cached content
|
||||
*
|
||||
* @param string $id cache id
|
||||
* @return string
|
||||
*/
|
||||
public function fetch($id)
|
||||
{
|
||||
return $this->_fetch($id)
|
||||
? $this->_data
|
||||
: '';
|
||||
}
|
||||
|
||||
private $_exp = null;
|
||||
|
||||
// cache of most recently fetched id
|
||||
private $_lm = null;
|
||||
private $_data = null;
|
||||
private $_id = null;
|
||||
|
||||
/**
|
||||
* Fetch data and timestamp from xcache, store in instance
|
||||
*
|
||||
* @param string $id
|
||||
* @return bool success
|
||||
*/
|
||||
private function _fetch($id)
|
||||
{
|
||||
if ($this->_id === $id) {
|
||||
return true;
|
||||
}
|
||||
$ret = xcache_get($id);
|
||||
if (false === $ret) {
|
||||
$this->_id = null;
|
||||
return false;
|
||||
}
|
||||
list($this->_lm, $this->_data) = explode('|', $ret, 2);
|
||||
$this->_id = $id;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,142 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Class Minify_Cache_ZendPlatform
|
||||
* @package Minify
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* ZendPlatform-based cache class for Minify
|
||||
*
|
||||
* Based on Minify_Cache_APC, uses output_cache_get/put (currently deprecated)
|
||||
*
|
||||
* <code>
|
||||
* Minify::setCache(new Minify_Cache_ZendPlatform());
|
||||
* </code>
|
||||
*
|
||||
* @package Minify
|
||||
* @author Patrick van Dissel
|
||||
*/
|
||||
class Minify_Cache_ZendPlatform {
|
||||
|
||||
|
||||
/**
|
||||
* Create a Minify_Cache_ZendPlatform object, to be passed to
|
||||
* Minify::setCache().
|
||||
*
|
||||
* @param int $expire seconds until expiration (default = 0
|
||||
* meaning the item will not get an expiration date)
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
public function __construct($expire = 0)
|
||||
{
|
||||
$this->_exp = $expire;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Write data to cache.
|
||||
*
|
||||
* @param string $id cache id
|
||||
*
|
||||
* @param string $data
|
||||
*
|
||||
* @return bool success
|
||||
*/
|
||||
public function store($id, $data)
|
||||
{
|
||||
return output_cache_put($id, "{$_SERVER['REQUEST_TIME']}|{$data}");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the size of a cache entry
|
||||
*
|
||||
* @param string $id cache id
|
||||
*
|
||||
* @return int size in bytes
|
||||
*/
|
||||
public function getSize($id)
|
||||
{
|
||||
return $this->_fetch($id)
|
||||
? strlen($this->_data)
|
||||
: false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Does a valid cache entry exist?
|
||||
*
|
||||
* @param string $id cache id
|
||||
*
|
||||
* @param int $srcMtime mtime of the original source file(s)
|
||||
*
|
||||
* @return bool exists
|
||||
*/
|
||||
public function isValid($id, $srcMtime)
|
||||
{
|
||||
$ret = ($this->_fetch($id) && ($this->_lm >= $srcMtime));
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Send the cached content to output
|
||||
*
|
||||
* @param string $id cache id
|
||||
*/
|
||||
public function display($id)
|
||||
{
|
||||
echo $this->_fetch($id)
|
||||
? $this->_data
|
||||
: '';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Fetch the cached content
|
||||
*
|
||||
* @param string $id cache id
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function fetch($id)
|
||||
{
|
||||
return $this->_fetch($id)
|
||||
? $this->_data
|
||||
: '';
|
||||
}
|
||||
|
||||
|
||||
private $_exp = null;
|
||||
|
||||
|
||||
// cache of most recently fetched id
|
||||
private $_lm = null;
|
||||
private $_data = null;
|
||||
private $_id = null;
|
||||
|
||||
|
||||
/**
|
||||
* Fetch data and timestamp from ZendPlatform, store in instance
|
||||
*
|
||||
* @param string $id
|
||||
*
|
||||
* @return bool success
|
||||
*/
|
||||
private function _fetch($id)
|
||||
{
|
||||
if ($this->_id === $id) {
|
||||
return true;
|
||||
}
|
||||
$ret = output_cache_get($id, $this->_exp);
|
||||
if (false === $ret) {
|
||||
$this->_id = null;
|
||||
return false;
|
||||
}
|
||||
list($this->_lm, $this->_data) = explode('|', $ret, 2);
|
||||
$this->_id = $id;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,139 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Class Minify_ClosureCompiler
|
||||
* @package Minify
|
||||
*/
|
||||
|
||||
/**
|
||||
* Compress Javascript using the Closure Compiler
|
||||
*
|
||||
* You must set $jarFile and $tempDir before calling the minify functions.
|
||||
* Also, depending on your shell's environment, you may need to specify
|
||||
* the full path to java in $javaExecutable or use putenv() to setup the
|
||||
* Java environment.
|
||||
*
|
||||
* <code>
|
||||
* Minify_ClosureCompiler::$jarFile = '/path/to/closure-compiler-20120123.jar';
|
||||
* Minify_ClosureCompiler::$tempDir = '/tmp';
|
||||
* $code = Minify_ClosureCompiler::minify(
|
||||
* $code,
|
||||
* array('compilation_level' => 'SIMPLE_OPTIMIZATIONS')
|
||||
* );
|
||||
*
|
||||
* --compilation_level WHITESPACE_ONLY, SIMPLE_OPTIMIZATIONS, ADVANCED_OPTIMIZATIONS
|
||||
*
|
||||
* </code>
|
||||
*
|
||||
* @todo unit tests, $options docs
|
||||
* @todo more options support (or should just passthru them all?)
|
||||
*
|
||||
* @package Minify
|
||||
* @author Stephen Clay <steve@mrclay.org>
|
||||
* @author Elan Ruusamäe <glen@delfi.ee>
|
||||
*/
|
||||
class Minify_ClosureCompiler {
|
||||
|
||||
const OPTION_CHARSET = 'charset';
|
||||
const OPTION_COMPILATION_LEVEL = 'compilation_level';
|
||||
|
||||
public static $isDebug = false;
|
||||
|
||||
/**
|
||||
* Filepath of the Closure Compiler jar file. This must be set before
|
||||
* calling minifyJs().
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public static $jarFile = null;
|
||||
|
||||
/**
|
||||
* Writable temp directory. This must be set before calling minifyJs().
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public static $tempDir = null;
|
||||
|
||||
/**
|
||||
* Filepath of "java" executable (may be needed if not in shell's PATH)
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public static $javaExecutable = 'java';
|
||||
|
||||
/**
|
||||
* Minify a Javascript string
|
||||
*
|
||||
* @param string $js
|
||||
*
|
||||
* @param array $options (verbose is ignored)
|
||||
*
|
||||
* @see https://code.google.com/p/closure-compiler/source/browse/trunk/README
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @throws Minify_ClosureCompiler_Exception
|
||||
*/
|
||||
public static function minify($js, $options = array())
|
||||
{
|
||||
self::_prepare();
|
||||
if (! ($tmpFile = tempnam(self::$tempDir, 'cc_'))) {
|
||||
throw new Minify_ClosureCompiler_Exception('Minify_ClosureCompiler : could not create temp file in "'.self::$tempDir.'".');
|
||||
}
|
||||
file_put_contents($tmpFile, $js);
|
||||
$cmd = self::_getCmd($options, $tmpFile);
|
||||
exec($cmd, $output, $result_code);
|
||||
unlink($tmpFile);
|
||||
if ($result_code != 0) {
|
||||
$message = 'Minify_ClosureCompiler : Closure Compiler execution failed.';
|
||||
if (self::$isDebug) {
|
||||
exec($cmd . ' 2>&1', $error);
|
||||
if ($error) {
|
||||
$message .= "\nReason:\n" . join("\n", $error);
|
||||
}
|
||||
}
|
||||
throw new Minify_ClosureCompiler_Exception($message);
|
||||
}
|
||||
return implode("\n", $output);
|
||||
}
|
||||
|
||||
private static function _getCmd($userOptions, $tmpFile)
|
||||
{
|
||||
$o = array_merge(
|
||||
array(
|
||||
self::OPTION_CHARSET => 'utf-8',
|
||||
self::OPTION_COMPILATION_LEVEL => 'SIMPLE_OPTIMIZATIONS',
|
||||
),
|
||||
$userOptions
|
||||
);
|
||||
$charsetOption = $o[self::OPTION_CHARSET];
|
||||
$cmd = self::$javaExecutable . ' -jar ' . escapeshellarg(self::$jarFile)
|
||||
. (preg_match('/^[\\da-zA-Z0-9\\-]+$/', $charsetOption)
|
||||
? " --charset {$charsetOption}"
|
||||
: '');
|
||||
|
||||
foreach (array(self::OPTION_COMPILATION_LEVEL) as $opt) {
|
||||
if ($o[$opt]) {
|
||||
$cmd .= " --{$opt} ". escapeshellarg($o[$opt]);
|
||||
}
|
||||
}
|
||||
return $cmd . ' ' . escapeshellarg($tmpFile);
|
||||
}
|
||||
|
||||
private static function _prepare()
|
||||
{
|
||||
if (! is_file(self::$jarFile)) {
|
||||
throw new Minify_ClosureCompiler_Exception('Minify_ClosureCompiler : $jarFile('.self::$jarFile.') is not a valid file.');
|
||||
}
|
||||
if (! is_readable(self::$jarFile)) {
|
||||
throw new Minify_ClosureCompiler_Exception('Minify_ClosureCompiler : $jarFile('.self::$jarFile.') is not readable.');
|
||||
}
|
||||
if (! is_dir(self::$tempDir)) {
|
||||
throw new Minify_ClosureCompiler_Exception('Minify_ClosureCompiler : $tempDir('.self::$tempDir.') is not a valid direcotry.');
|
||||
}
|
||||
if (! is_writable(self::$tempDir)) {
|
||||
throw new Minify_ClosureCompiler_Exception('Minify_ClosureCompiler : $tempDir('.self::$tempDir.') is not writable.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class Minify_ClosureCompiler_Exception extends Exception {}
|
||||
@@ -1,89 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Class Minify_CommentPreserver
|
||||
* @package Minify
|
||||
*/
|
||||
|
||||
/**
|
||||
* Process a string in pieces preserving C-style comments that begin with "/*!"
|
||||
*
|
||||
* @package Minify
|
||||
* @author Stephen Clay <steve@mrclay.org>
|
||||
*/
|
||||
class Minify_CommentPreserver {
|
||||
|
||||
/**
|
||||
* String to be prepended to each preserved comment
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public static $prepend = "\n";
|
||||
|
||||
/**
|
||||
* String to be appended to each preserved comment
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public static $append = "\n";
|
||||
|
||||
/**
|
||||
* Process a string outside of C-style comments that begin with "/*!"
|
||||
*
|
||||
* On each non-empty string outside these comments, the given processor
|
||||
* function will be called. The comments will be surrounded by
|
||||
* Minify_CommentPreserver::$preprend and Minify_CommentPreserver::$append.
|
||||
*
|
||||
* @param string $content
|
||||
* @param callback $processor function
|
||||
* @param array $args array of extra arguments to pass to the processor
|
||||
* function (default = array())
|
||||
* @return string
|
||||
*/
|
||||
public static function process($content, $processor, $args = array())
|
||||
{
|
||||
$ret = '';
|
||||
while (true) {
|
||||
list($beforeComment, $comment, $afterComment) = self::_nextComment($content);
|
||||
if ('' !== $beforeComment) {
|
||||
$callArgs = $args;
|
||||
array_unshift($callArgs, $beforeComment);
|
||||
$ret .= call_user_func_array($processor, $callArgs);
|
||||
}
|
||||
if (false === $comment) {
|
||||
break;
|
||||
}
|
||||
$ret .= $comment;
|
||||
$content = $afterComment;
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract comments that YUI Compressor preserves.
|
||||
*
|
||||
* @param string $in input
|
||||
*
|
||||
* @return array 3 elements are returned. If a YUI comment is found, the
|
||||
* 2nd element is the comment and the 1st and 3rd are the surrounding
|
||||
* strings. If no comment is found, the entire string is returned as the
|
||||
* 1st element and the other two are false.
|
||||
*/
|
||||
private static function _nextComment($in)
|
||||
{
|
||||
if (
|
||||
false === ($start = strpos($in, '/*!'))
|
||||
|| false === ($end = strpos($in, '*/', $start + 3))
|
||||
) {
|
||||
return array($in, false, false);
|
||||
}
|
||||
$ret = array(
|
||||
substr($in, 0, $start)
|
||||
,self::$prepend . '/*!' . substr($in, $start + 3, $end - $start - 1) . self::$append
|
||||
);
|
||||
$endChars = (strlen($in) - $end - 2);
|
||||
$ret[] = (0 === $endChars)
|
||||
? ''
|
||||
: substr($in, -$endChars);
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
@@ -1,222 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Class Minify_Controller_Base
|
||||
* @package Minify
|
||||
*/
|
||||
|
||||
/**
|
||||
* Base class for Minify controller
|
||||
*
|
||||
* The controller class validates a request and uses it to create sources
|
||||
* for minification and set options like contentType. It's also responsible
|
||||
* for loading minifier code upon request.
|
||||
*
|
||||
* @package Minify
|
||||
* @author Stephen Clay <steve@mrclay.org>
|
||||
*/
|
||||
abstract class Minify_Controller_Base {
|
||||
|
||||
/**
|
||||
* Setup controller sources and set an needed options for Minify::source
|
||||
*
|
||||
* You must override this method in your subclass controller to set
|
||||
* $this->sources. If the request is NOT valid, make sure $this->sources
|
||||
* is left an empty array. Then strip any controller-specific options from
|
||||
* $options and return it. To serve files, $this->sources must be an array of
|
||||
* Minify_Source objects.
|
||||
*
|
||||
* @param array $options controller and Minify options
|
||||
*
|
||||
* @return array $options Minify::serve options
|
||||
*/
|
||||
abstract public function setupSources($options);
|
||||
|
||||
/**
|
||||
* Get default Minify options for this controller.
|
||||
*
|
||||
* Override in subclass to change defaults
|
||||
*
|
||||
* @return array options for Minify
|
||||
*/
|
||||
public function getDefaultMinifyOptions() {
|
||||
return array(
|
||||
'isPublic' => true
|
||||
,'encodeOutput' => function_exists('gzdeflate')
|
||||
,'encodeMethod' => null // determine later
|
||||
,'encodeLevel' => 9
|
||||
,'minifierOptions' => array() // no minifier options
|
||||
,'contentTypeCharset' => 'utf-8'
|
||||
,'maxAge' => 1800 // 30 minutes
|
||||
,'rewriteCssUris' => true
|
||||
,'bubbleCssImports' => false
|
||||
,'quiet' => false // serve() will send headers and output
|
||||
,'debug' => false
|
||||
|
||||
// if you override these, the response codes MUST be directly after
|
||||
// the first space.
|
||||
,'badRequestHeader' => 'HTTP/1.0 400 Bad Request'
|
||||
,'errorHeader' => 'HTTP/1.0 500 Internal Server Error'
|
||||
|
||||
// callback function to see/modify content of all sources
|
||||
,'postprocessor' => null
|
||||
// file to require to load preprocessor
|
||||
,'postprocessorRequire' => null
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get default minifiers for this controller.
|
||||
*
|
||||
* Override in subclass to change defaults
|
||||
*
|
||||
* @return array minifier callbacks for common types
|
||||
*/
|
||||
public function getDefaultMinifers() {
|
||||
$ret[Minify::TYPE_JS] = array('JSMin', 'minify');
|
||||
$ret[Minify::TYPE_CSS] = array('Minify_CSS', 'minify');
|
||||
$ret[Minify::TYPE_HTML] = array('Minify_HTML', 'minify');
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is a user-given file within an allowable directory, existing,
|
||||
* and having an extension js/css/html/txt ?
|
||||
*
|
||||
* This is a convenience function for controllers that have to accept
|
||||
* user-given paths
|
||||
*
|
||||
* @param string $file full file path (already processed by realpath())
|
||||
*
|
||||
* @param array $safeDirs directories where files are safe to serve. Files can also
|
||||
* be in subdirectories of these directories.
|
||||
*
|
||||
* @return bool file is safe
|
||||
*
|
||||
* @deprecated use checkAllowDirs, checkNotHidden instead
|
||||
*/
|
||||
public static function _fileIsSafe($file, $safeDirs)
|
||||
{
|
||||
$pathOk = false;
|
||||
foreach ((array)$safeDirs as $safeDir) {
|
||||
if (strpos($file, $safeDir) === 0) {
|
||||
$pathOk = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
$base = basename($file);
|
||||
if (! $pathOk || ! is_file($file) || $base[0] === '.') {
|
||||
return false;
|
||||
}
|
||||
list($revExt) = explode('.', strrev($base));
|
||||
return in_array(strrev($revExt), array('js', 'css', 'html', 'txt'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @param array $allowDirs
|
||||
* @param string $uri
|
||||
* @return bool
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function checkAllowDirs($file, $allowDirs, $uri)
|
||||
{
|
||||
foreach ((array)$allowDirs as $allowDir) {
|
||||
if (strpos($file, $allowDir) === 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
throw new Exception("File '$file' is outside \$allowDirs. If the path is"
|
||||
. " resolved via an alias/symlink, look into the \$min_symlinks option."
|
||||
. " E.g. \$min_symlinks['/" . dirname($uri) . "'] = '" . dirname($file) . "';");
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function checkNotHidden($file)
|
||||
{
|
||||
$b = basename($file);
|
||||
if (0 === strpos($b, '.')) {
|
||||
throw new Exception("Filename '$b' starts with period (may be hidden)");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* instances of Minify_Source, which provide content and any individual minification needs.
|
||||
*
|
||||
* @var array
|
||||
*
|
||||
* @see Minify_Source
|
||||
*/
|
||||
public $sources = array();
|
||||
|
||||
/**
|
||||
* Short name to place inside cache id
|
||||
*
|
||||
* The setupSources() method may choose to set this, making it easier to
|
||||
* recognize a particular set of sources/settings in the cache folder. It
|
||||
* will be filtered and truncated to make the final cache id <= 250 bytes.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $selectionId = '';
|
||||
|
||||
/**
|
||||
* Mix in default controller options with user-given options
|
||||
*
|
||||
* @param array $options user options
|
||||
*
|
||||
* @return array mixed options
|
||||
*/
|
||||
public final function mixInDefaultOptions($options)
|
||||
{
|
||||
$ret = array_merge(
|
||||
$this->getDefaultMinifyOptions(), $options
|
||||
);
|
||||
if (! isset($options['minifiers'])) {
|
||||
$options['minifiers'] = array();
|
||||
}
|
||||
$ret['minifiers'] = array_merge(
|
||||
$this->getDefaultMinifers(), $options['minifiers']
|
||||
);
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Analyze sources (if there are any) and set $options 'contentType'
|
||||
* and 'lastModifiedTime' if they already aren't.
|
||||
*
|
||||
* @param array $options options for Minify
|
||||
*
|
||||
* @return array options for Minify
|
||||
*/
|
||||
public final function analyzeSources($options = array())
|
||||
{
|
||||
if ($this->sources) {
|
||||
if (! isset($options['contentType'])) {
|
||||
$options['contentType'] = Minify_Source::getContentType($this->sources);
|
||||
}
|
||||
// last modified is needed for caching, even if setExpires is set
|
||||
if (! isset($options['lastModifiedTime'])) {
|
||||
$max = 0;
|
||||
foreach ($this->sources as $source) {
|
||||
$max = max($source->lastModified, $max);
|
||||
}
|
||||
$options['lastModifiedTime'] = $max;
|
||||
}
|
||||
}
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send message to the Minify logger
|
||||
*
|
||||
* @param string $msg
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
public function log($msg) {
|
||||
Minify_Logger::log($msg);
|
||||
}
|
||||
}
|
||||
@@ -1,76 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Class Minify_Controller_Files
|
||||
* @package Minify
|
||||
*/
|
||||
|
||||
/**
|
||||
* Controller class for minifying a set of files
|
||||
*
|
||||
* E.g. the following would serve the minified Javascript for a site
|
||||
* <code>
|
||||
* Minify::serve('Files', array(
|
||||
* 'files' => array(
|
||||
* '//js/jquery.js'
|
||||
* ,'//js/plugins.js'
|
||||
* ,'/home/username/file.js'
|
||||
* )
|
||||
* ));
|
||||
* </code>
|
||||
*
|
||||
* As a shortcut, the controller will replace "//" at the beginning
|
||||
* of a filename with $_SERVER['DOCUMENT_ROOT'] . '/'.
|
||||
*
|
||||
* @package Minify
|
||||
* @author Stephen Clay <steve@mrclay.org>
|
||||
*/
|
||||
class Minify_Controller_Files extends Minify_Controller_Base {
|
||||
|
||||
/**
|
||||
* Set up file sources
|
||||
*
|
||||
* @param array $options controller and Minify options
|
||||
* @return array Minify options
|
||||
*
|
||||
* Controller options:
|
||||
*
|
||||
* 'files': (required) array of complete file paths, or a single path
|
||||
*/
|
||||
public function setupSources($options) {
|
||||
// strip controller options
|
||||
|
||||
$files = $options['files'];
|
||||
// if $files is a single object, casting will break it
|
||||
if (is_object($files)) {
|
||||
$files = array($files);
|
||||
} elseif (! is_array($files)) {
|
||||
$files = (array)$files;
|
||||
}
|
||||
unset($options['files']);
|
||||
|
||||
$sources = array();
|
||||
foreach ($files as $file) {
|
||||
if ($file instanceof Minify_Source) {
|
||||
$sources[] = $file;
|
||||
continue;
|
||||
}
|
||||
if (0 === strpos($file, '//')) {
|
||||
$file = $_SERVER['DOCUMENT_ROOT'] . substr($file, 1);
|
||||
}
|
||||
$realPath = realpath($file);
|
||||
if (is_file($realPath)) {
|
||||
$sources[] = new Minify_Source(array(
|
||||
'filepath' => $realPath
|
||||
));
|
||||
} else {
|
||||
$this->log("The path \"{$file}\" could not be found (or was not a file)");
|
||||
return $options;
|
||||
}
|
||||
}
|
||||
if ($sources) {
|
||||
$this->sources = $sources;
|
||||
}
|
||||
return $options;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,91 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Class Minify_Controller_Groups
|
||||
* @package Minify
|
||||
*/
|
||||
|
||||
/**
|
||||
* Controller class for serving predetermined groups of minimized sets, selected
|
||||
* by PATH_INFO
|
||||
*
|
||||
* <code>
|
||||
* Minify::serve('Groups', array(
|
||||
* 'groups' => array(
|
||||
* 'css' => array('//css/type.css', '//css/layout.css')
|
||||
* ,'js' => array('//js/jquery.js', '//js/site.js')
|
||||
* )
|
||||
* ));
|
||||
* </code>
|
||||
*
|
||||
* If the above code were placed in /serve.php, it would enable the URLs
|
||||
* /serve.php/js and /serve.php/css
|
||||
*
|
||||
* As a shortcut, the controller will replace "//" at the beginning
|
||||
* of a filename with $_SERVER['DOCUMENT_ROOT'] . '/'.
|
||||
*
|
||||
* @package Minify
|
||||
* @author Stephen Clay <steve@mrclay.org>
|
||||
*/
|
||||
class Minify_Controller_Groups extends Minify_Controller_Base {
|
||||
|
||||
/**
|
||||
* Set up groups of files as sources
|
||||
*
|
||||
* @param array $options controller and Minify options
|
||||
*
|
||||
* 'groups': (required) array mapping PATH_INFO strings to arrays
|
||||
* of complete file paths. @see Minify_Controller_Groups
|
||||
*
|
||||
* @return array Minify options
|
||||
*/
|
||||
public function setupSources($options) {
|
||||
// strip controller options
|
||||
$groups = $options['groups'];
|
||||
unset($options['groups']);
|
||||
|
||||
// mod_fcgid places PATH_INFO in ORIG_PATH_INFO
|
||||
$pi = isset($_SERVER['ORIG_PATH_INFO'])
|
||||
? substr($_SERVER['ORIG_PATH_INFO'], 1)
|
||||
: (isset($_SERVER['PATH_INFO'])
|
||||
? substr($_SERVER['PATH_INFO'], 1)
|
||||
: false
|
||||
);
|
||||
if (false === $pi || ! isset($groups[$pi])) {
|
||||
// no PATH_INFO or not a valid group
|
||||
$this->log("Missing PATH_INFO or no group set for \"$pi\"");
|
||||
return $options;
|
||||
}
|
||||
$sources = array();
|
||||
|
||||
$files = $groups[$pi];
|
||||
// if $files is a single object, casting will break it
|
||||
if (is_object($files)) {
|
||||
$files = array($files);
|
||||
} elseif (! is_array($files)) {
|
||||
$files = (array)$files;
|
||||
}
|
||||
foreach ($files as $file) {
|
||||
if ($file instanceof Minify_Source) {
|
||||
$sources[] = $file;
|
||||
continue;
|
||||
}
|
||||
if (0 === strpos($file, '//')) {
|
||||
$file = $_SERVER['DOCUMENT_ROOT'] . substr($file, 1);
|
||||
}
|
||||
$realPath = realpath($file);
|
||||
if (is_file($realPath)) {
|
||||
$sources[] = new Minify_Source(array(
|
||||
'filepath' => $realPath
|
||||
));
|
||||
} else {
|
||||
$this->log("The path \"{$file}\" could not be found (or was not a file)");
|
||||
return $options;
|
||||
}
|
||||
}
|
||||
if ($sources) {
|
||||
$this->sources = $sources;
|
||||
}
|
||||
return $options;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,238 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Class Minify_Controller_MinApp
|
||||
* @package Minify
|
||||
*/
|
||||
|
||||
/**
|
||||
* Controller class for requests to /min/index.php
|
||||
*
|
||||
* @package Minify
|
||||
* @author Stephen Clay <steve@mrclay.org>
|
||||
*/
|
||||
class Minify_Controller_MinApp extends Minify_Controller_Base {
|
||||
|
||||
/**
|
||||
* Set up groups of files as sources
|
||||
*
|
||||
* @param array $options controller and Minify options
|
||||
*
|
||||
* @return array Minify options
|
||||
*/
|
||||
public function setupSources($options) {
|
||||
// PHP insecure by default: realpath() and other FS functions can't handle null bytes.
|
||||
foreach (array('g', 'b', 'f') as $key) {
|
||||
if (isset($_GET[$key])) {
|
||||
$_GET[$key] = str_replace("\x00", '', (string)$_GET[$key]);
|
||||
}
|
||||
}
|
||||
|
||||
// filter controller options
|
||||
$cOptions = array_merge(
|
||||
array(
|
||||
'allowDirs' => '//'
|
||||
,'groupsOnly' => false
|
||||
,'groups' => array()
|
||||
,'noMinPattern' => '@[-\\.]min\\.(?:js|css)$@i' // matched against basename
|
||||
)
|
||||
,(isset($options['minApp']) ? $options['minApp'] : array())
|
||||
);
|
||||
unset($options['minApp']);
|
||||
$sources = array();
|
||||
$this->selectionId = '';
|
||||
$firstMissingResource = null;
|
||||
if (isset($_GET['g'])) {
|
||||
// add group(s)
|
||||
$this->selectionId .= 'g=' . $_GET['g'];
|
||||
$keys = explode(',', $_GET['g']);
|
||||
if ($keys != array_unique($keys)) {
|
||||
$this->log("Duplicate group key found.");
|
||||
return $options;
|
||||
}
|
||||
$keys = explode(',', $_GET['g']);
|
||||
foreach ($keys as $key) {
|
||||
if (! isset($cOptions['groups'][$key])) {
|
||||
$this->log("A group configuration for \"{$key}\" was not found");
|
||||
return $options;
|
||||
}
|
||||
$files = $cOptions['groups'][$key];
|
||||
// if $files is a single object, casting will break it
|
||||
if (is_object($files)) {
|
||||
$files = array($files);
|
||||
} elseif (! is_array($files)) {
|
||||
$files = (array)$files;
|
||||
}
|
||||
foreach ($files as $file) {
|
||||
if ($file instanceof Minify_Source) {
|
||||
$sources[] = $file;
|
||||
continue;
|
||||
}
|
||||
if (0 === strpos($file, '//')) {
|
||||
$file = $_SERVER['DOCUMENT_ROOT'] . substr($file, 1);
|
||||
}
|
||||
$realpath = realpath($file);
|
||||
if ($realpath && is_file($realpath)) {
|
||||
$sources[] = $this->_getFileSource($realpath, $cOptions);
|
||||
} else {
|
||||
$this->log("The path \"{$file}\" (realpath \"{$realpath}\") could not be found (or was not a file)");
|
||||
if (null === $firstMissingResource) {
|
||||
$firstMissingResource = basename($file);
|
||||
continue;
|
||||
} else {
|
||||
$secondMissingResource = basename($file);
|
||||
$this->log("More than one file was missing: '$firstMissingResource', '$secondMissingResource'");
|
||||
return $options;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($sources) {
|
||||
try {
|
||||
$this->checkType($sources[0]);
|
||||
} catch (Exception $e) {
|
||||
$this->log($e->getMessage());
|
||||
return $options;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (! $cOptions['groupsOnly'] && isset($_GET['f'])) {
|
||||
// try user files
|
||||
// The following restrictions are to limit the URLs that minify will
|
||||
// respond to.
|
||||
if (// verify at least one file, files are single comma separated,
|
||||
// and are all same extension
|
||||
! preg_match('/^[^,]+\\.(css|js)(?:,[^,]+\\.\\1)*$/', $_GET['f'], $m)
|
||||
// no "//"
|
||||
|| strpos($_GET['f'], '//') !== false
|
||||
// no "\"
|
||||
|| strpos($_GET['f'], '\\') !== false
|
||||
) {
|
||||
$this->log("GET param 'f' was invalid");
|
||||
return $options;
|
||||
}
|
||||
$ext = ".{$m[1]}";
|
||||
try {
|
||||
$this->checkType($m[1]);
|
||||
} catch (Exception $e) {
|
||||
$this->log($e->getMessage());
|
||||
return $options;
|
||||
}
|
||||
$files = explode(',', $_GET['f']);
|
||||
if ($files != array_unique($files)) {
|
||||
$this->log("Duplicate files were specified");
|
||||
return $options;
|
||||
}
|
||||
if (isset($_GET['b'])) {
|
||||
// check for validity
|
||||
if (preg_match('@^[^/]+(?:/[^/]+)*$@', $_GET['b'])
|
||||
&& false === strpos($_GET['b'], '..')
|
||||
&& $_GET['b'] !== '.') {
|
||||
// valid base
|
||||
$base = "/{$_GET['b']}/";
|
||||
} else {
|
||||
$this->log("GET param 'b' was invalid");
|
||||
return $options;
|
||||
}
|
||||
} else {
|
||||
$base = '/';
|
||||
}
|
||||
$allowDirs = array();
|
||||
foreach ((array)$cOptions['allowDirs'] as $allowDir) {
|
||||
$allowDirs[] = realpath(str_replace('//', $_SERVER['DOCUMENT_ROOT'] . '/', $allowDir));
|
||||
}
|
||||
$basenames = array(); // just for cache id
|
||||
foreach ($files as $file) {
|
||||
$uri = $base . $file;
|
||||
$path = $_SERVER['DOCUMENT_ROOT'] . $uri;
|
||||
$realpath = realpath($path);
|
||||
if (false === $realpath || ! is_file($realpath)) {
|
||||
$this->log("The path \"{$path}\" (realpath \"{$realpath}\") could not be found (or was not a file)");
|
||||
if (null === $firstMissingResource) {
|
||||
$firstMissingResource = $uri;
|
||||
continue;
|
||||
} else {
|
||||
$secondMissingResource = $uri;
|
||||
$this->log("More than one file was missing: '$firstMissingResource', '$secondMissingResource`'");
|
||||
return $options;
|
||||
}
|
||||
}
|
||||
try {
|
||||
parent::checkNotHidden($realpath);
|
||||
parent::checkAllowDirs($realpath, $allowDirs, $uri);
|
||||
} catch (Exception $e) {
|
||||
$this->log($e->getMessage());
|
||||
return $options;
|
||||
}
|
||||
$sources[] = $this->_getFileSource($realpath, $cOptions);
|
||||
$basenames[] = basename($realpath, $ext);
|
||||
}
|
||||
if ($this->selectionId) {
|
||||
$this->selectionId .= '_f=';
|
||||
}
|
||||
$this->selectionId .= implode(',', $basenames) . $ext;
|
||||
}
|
||||
if ($sources) {
|
||||
if (null !== $firstMissingResource) {
|
||||
array_unshift($sources, new Minify_Source(array(
|
||||
'id' => 'missingFile'
|
||||
// should not cause cache invalidation
|
||||
,'lastModified' => 0
|
||||
// due to caching, filename is unreliable.
|
||||
,'content' => "/* Minify: at least one missing file. See " . Minify::URL_DEBUG . " */\n"
|
||||
,'minifier' => ''
|
||||
)));
|
||||
}
|
||||
$this->sources = $sources;
|
||||
} else {
|
||||
$this->log("No sources to serve");
|
||||
}
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
*
|
||||
* @param array $cOptions
|
||||
*
|
||||
* @return Minify_Source
|
||||
*/
|
||||
protected function _getFileSource($file, $cOptions)
|
||||
{
|
||||
$spec['filepath'] = $file;
|
||||
if ($cOptions['noMinPattern'] && preg_match($cOptions['noMinPattern'], basename($file))) {
|
||||
if (preg_match('~\.css$~i', $file)) {
|
||||
$spec['minifyOptions']['compress'] = false;
|
||||
} else {
|
||||
$spec['minifier'] = '';
|
||||
}
|
||||
}
|
||||
return new Minify_Source($spec);
|
||||
}
|
||||
|
||||
protected $_type = null;
|
||||
|
||||
/**
|
||||
* Make sure that only source files of a single type are registered
|
||||
*
|
||||
* @param string $sourceOrExt
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public function checkType($sourceOrExt)
|
||||
{
|
||||
if ($sourceOrExt === 'js') {
|
||||
$type = Minify::TYPE_JS;
|
||||
} elseif ($sourceOrExt === 'css') {
|
||||
$type = Minify::TYPE_CSS;
|
||||
} elseif ($sourceOrExt->contentType !== null) {
|
||||
$type = $sourceOrExt->contentType;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
if ($this->_type === null) {
|
||||
$this->_type = $type;
|
||||
} elseif ($this->_type !== $type) {
|
||||
throw new Exception('Content-Type mismatch');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,68 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Class Minify_Controller_Page
|
||||
* @package Minify
|
||||
*/
|
||||
|
||||
/**
|
||||
* Controller class for serving a single HTML page
|
||||
*
|
||||
* @link http://code.google.com/p/minify/source/browse/trunk/web/examples/1/index.php#59
|
||||
* @package Minify
|
||||
* @author Stephen Clay <steve@mrclay.org>
|
||||
*/
|
||||
class Minify_Controller_Page extends Minify_Controller_Base {
|
||||
|
||||
/**
|
||||
* Set up source of HTML content
|
||||
*
|
||||
* @param array $options controller and Minify options
|
||||
* @return array Minify options
|
||||
*
|
||||
* Controller options:
|
||||
*
|
||||
* 'content': (required) HTML markup
|
||||
*
|
||||
* 'id': (required) id of page (string for use in server-side caching)
|
||||
*
|
||||
* 'lastModifiedTime': timestamp of when this content changed. This
|
||||
* is recommended to allow both server and client-side caching.
|
||||
*
|
||||
* 'minifyAll': should all CSS and Javascript blocks be individually
|
||||
* minified? (default false)
|
||||
*
|
||||
* @todo Add 'file' option to read HTML file.
|
||||
*/
|
||||
public function setupSources($options) {
|
||||
if (isset($options['file'])) {
|
||||
$sourceSpec = array(
|
||||
'filepath' => $options['file']
|
||||
);
|
||||
$f = $options['file'];
|
||||
} else {
|
||||
// strip controller options
|
||||
$sourceSpec = array(
|
||||
'content' => $options['content']
|
||||
,'id' => $options['id']
|
||||
);
|
||||
$f = $options['id'];
|
||||
unset($options['content'], $options['id']);
|
||||
}
|
||||
// something like "builder,index.php" or "directory,file.html"
|
||||
$this->selectionId = strtr(substr($f, 1 + strlen(dirname(dirname($f)))), '/\\', ',,');
|
||||
|
||||
if (isset($options['minifyAll'])) {
|
||||
// this will be the 2nd argument passed to Minify_HTML::minify()
|
||||
$sourceSpec['minifyOptions'] = array(
|
||||
'cssMinifier' => array('Minify_CSS', 'minify')
|
||||
,'jsMinifier' => array('JSMin', 'minify')
|
||||
);
|
||||
unset($options['minifyAll']);
|
||||
}
|
||||
$this->sources[] = new Minify_Source($sourceSpec);
|
||||
|
||||
$options['contentType'] = Minify::TYPE_HTML;
|
||||
return $options;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,119 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Class Minify_Controller_Version1
|
||||
* @package Minify
|
||||
*/
|
||||
|
||||
/**
|
||||
* Controller class for emulating version 1 of minify.php (mostly a proof-of-concept)
|
||||
*
|
||||
* <code>
|
||||
* Minify::serve('Version1');
|
||||
* </code>
|
||||
*
|
||||
* @package Minify
|
||||
* @author Stephen Clay <steve@mrclay.org>
|
||||
*/
|
||||
class Minify_Controller_Version1 extends Minify_Controller_Base {
|
||||
|
||||
/**
|
||||
* Set up groups of files as sources
|
||||
*
|
||||
* @param array $options controller and Minify options
|
||||
* @return array Minify options
|
||||
*
|
||||
*/
|
||||
public function setupSources($options) {
|
||||
// PHP insecure by default: realpath() and other FS functions can't handle null bytes.
|
||||
if (isset($_GET['files'])) {
|
||||
$_GET['files'] = str_replace("\x00", '', (string)$_GET['files']);
|
||||
}
|
||||
|
||||
self::_setupDefines();
|
||||
if (MINIFY_USE_CACHE) {
|
||||
$cacheDir = defined('MINIFY_CACHE_DIR')
|
||||
? MINIFY_CACHE_DIR
|
||||
: '';
|
||||
Minify::setCache($cacheDir);
|
||||
}
|
||||
$options['badRequestHeader'] = 'HTTP/1.0 404 Not Found';
|
||||
$options['contentTypeCharset'] = MINIFY_ENCODING;
|
||||
|
||||
// The following restrictions are to limit the URLs that minify will
|
||||
// respond to. Ideally there should be only one way to reference a file.
|
||||
if (! isset($_GET['files'])
|
||||
// verify at least one file, files are single comma separated,
|
||||
// and are all same extension
|
||||
|| ! preg_match('/^[^,]+\\.(css|js)(,[^,]+\\.\\1)*$/', $_GET['files'], $m)
|
||||
// no "//" (makes URL rewriting easier)
|
||||
|| strpos($_GET['files'], '//') !== false
|
||||
// no "\"
|
||||
|| strpos($_GET['files'], '\\') !== false
|
||||
// no "./"
|
||||
|| preg_match('/(?:^|[^\\.])\\.\\//', $_GET['files'])
|
||||
) {
|
||||
return $options;
|
||||
}
|
||||
|
||||
$files = explode(',', $_GET['files']);
|
||||
if (count($files) > MINIFY_MAX_FILES) {
|
||||
return $options;
|
||||
}
|
||||
|
||||
// strings for prepending to relative/absolute paths
|
||||
$prependRelPaths = dirname($_SERVER['SCRIPT_FILENAME'])
|
||||
. DIRECTORY_SEPARATOR;
|
||||
$prependAbsPaths = $_SERVER['DOCUMENT_ROOT'];
|
||||
|
||||
$goodFiles = array();
|
||||
$hasBadSource = false;
|
||||
|
||||
$allowDirs = isset($options['allowDirs'])
|
||||
? $options['allowDirs']
|
||||
: MINIFY_BASE_DIR;
|
||||
|
||||
foreach ($files as $file) {
|
||||
// prepend appropriate string for abs/rel paths
|
||||
$file = ($file[0] === '/' ? $prependAbsPaths : $prependRelPaths) . $file;
|
||||
// make sure a real file!
|
||||
$file = realpath($file);
|
||||
// don't allow unsafe or duplicate files
|
||||
if (parent::_fileIsSafe($file, $allowDirs)
|
||||
&& !in_array($file, $goodFiles))
|
||||
{
|
||||
$goodFiles[] = $file;
|
||||
$srcOptions = array(
|
||||
'filepath' => $file
|
||||
);
|
||||
$this->sources[] = new Minify_Source($srcOptions);
|
||||
} else {
|
||||
$hasBadSource = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ($hasBadSource) {
|
||||
$this->sources = array();
|
||||
}
|
||||
if (! MINIFY_REWRITE_CSS_URLS) {
|
||||
$options['rewriteCssUris'] = false;
|
||||
}
|
||||
return $options;
|
||||
}
|
||||
|
||||
private static function _setupDefines()
|
||||
{
|
||||
$defaults = array(
|
||||
'MINIFY_BASE_DIR' => realpath($_SERVER['DOCUMENT_ROOT'])
|
||||
,'MINIFY_ENCODING' => 'utf-8'
|
||||
,'MINIFY_MAX_FILES' => 16
|
||||
,'MINIFY_REWRITE_CSS_URLS' => true
|
||||
,'MINIFY_USE_CACHE' => true
|
||||
);
|
||||
foreach ($defaults as $const => $val) {
|
||||
if (! defined($const)) {
|
||||
define($const, $val);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Detect whether request should be debugged
|
||||
*
|
||||
* @package Minify
|
||||
* @author Stephen Clay <steve@mrclay.org>
|
||||
*/
|
||||
class Minify_DebugDetector {
|
||||
public static function shouldDebugRequest($cookie, $get, $requestUri)
|
||||
{
|
||||
if (isset($get['debug'])) {
|
||||
return true;
|
||||
}
|
||||
if (! empty($cookie['minifyDebug'])) {
|
||||
foreach (preg_split('/\\s+/', $cookie['minifyDebug']) as $debugUri) {
|
||||
$pattern = '@' . preg_quote($debugUri, '@') . '@i';
|
||||
$pattern = str_replace(array('\\*', '\\?'), array('.*', '.'), $pattern);
|
||||
if (preg_match($pattern, $requestUri)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
255
vendor/mrclay/minify/min/lib/Minify/HTML.php
vendored
255
vendor/mrclay/minify/min/lib/Minify/HTML.php
vendored
@@ -1,255 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Class Minify_HTML
|
||||
* @package Minify
|
||||
*/
|
||||
|
||||
/**
|
||||
* Compress HTML
|
||||
*
|
||||
* This is a heavy regex-based removal of whitespace, unnecessary comments and
|
||||
* tokens. IE conditional comments are preserved. There are also options to have
|
||||
* STYLE and SCRIPT blocks compressed by callback functions.
|
||||
*
|
||||
* A test suite is available.
|
||||
*
|
||||
* @package Minify
|
||||
* @author Stephen Clay <steve@mrclay.org>
|
||||
*/
|
||||
class Minify_HTML {
|
||||
/**
|
||||
* @var boolean
|
||||
*/
|
||||
protected $_jsCleanComments = true;
|
||||
|
||||
/**
|
||||
* "Minify" an HTML page
|
||||
*
|
||||
* @param string $html
|
||||
*
|
||||
* @param array $options
|
||||
*
|
||||
* 'cssMinifier' : (optional) callback function to process content of STYLE
|
||||
* elements.
|
||||
*
|
||||
* 'jsMinifier' : (optional) callback function to process content of SCRIPT
|
||||
* elements. Note: the type attribute is ignored.
|
||||
*
|
||||
* 'xhtml' : (optional boolean) should content be treated as XHTML1.0? If
|
||||
* unset, minify will sniff for an XHTML doctype.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function minify($html, $options = array()) {
|
||||
$min = new self($html, $options);
|
||||
return $min->process();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create a minifier object
|
||||
*
|
||||
* @param string $html
|
||||
*
|
||||
* @param array $options
|
||||
*
|
||||
* 'cssMinifier' : (optional) callback function to process content of STYLE
|
||||
* elements.
|
||||
*
|
||||
* 'jsMinifier' : (optional) callback function to process content of SCRIPT
|
||||
* elements. Note: the type attribute is ignored.
|
||||
*
|
||||
* 'jsCleanComments' : (optional) whether to remove HTML comments beginning and end of script block
|
||||
*
|
||||
* 'xhtml' : (optional boolean) should content be treated as XHTML1.0? If
|
||||
* unset, minify will sniff for an XHTML doctype.
|
||||
*/
|
||||
public function __construct($html, $options = array())
|
||||
{
|
||||
$this->_html = str_replace("\r\n", "\n", trim($html));
|
||||
if (isset($options['xhtml'])) {
|
||||
$this->_isXhtml = (bool)$options['xhtml'];
|
||||
}
|
||||
if (isset($options['cssMinifier'])) {
|
||||
$this->_cssMinifier = $options['cssMinifier'];
|
||||
}
|
||||
if (isset($options['jsMinifier'])) {
|
||||
$this->_jsMinifier = $options['jsMinifier'];
|
||||
}
|
||||
if (isset($options['jsCleanComments'])) {
|
||||
$this->_jsCleanComments = (bool)$options['jsCleanComments'];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Minify the markeup given in the constructor
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function process()
|
||||
{
|
||||
if ($this->_isXhtml === null) {
|
||||
$this->_isXhtml = (false !== strpos($this->_html, '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML'));
|
||||
}
|
||||
|
||||
$this->_replacementHash = 'MINIFYHTML' . md5($_SERVER['REQUEST_TIME']);
|
||||
$this->_placeholders = array();
|
||||
|
||||
// replace SCRIPTs (and minify) with placeholders
|
||||
$this->_html = preg_replace_callback(
|
||||
'/(\\s*)<script(\\b[^>]*?>)([\\s\\S]*?)<\\/script>(\\s*)/i'
|
||||
,array($this, '_removeScriptCB')
|
||||
,$this->_html);
|
||||
|
||||
// replace STYLEs (and minify) with placeholders
|
||||
$this->_html = preg_replace_callback(
|
||||
'/\\s*<style(\\b[^>]*>)([\\s\\S]*?)<\\/style>\\s*/i'
|
||||
,array($this, '_removeStyleCB')
|
||||
,$this->_html);
|
||||
|
||||
// remove HTML comments (not containing IE conditional comments).
|
||||
$this->_html = preg_replace_callback(
|
||||
'/<!--([\\s\\S]*?)-->/'
|
||||
,array($this, '_commentCB')
|
||||
,$this->_html);
|
||||
|
||||
// replace PREs with placeholders
|
||||
$this->_html = preg_replace_callback('/\\s*<pre(\\b[^>]*?>[\\s\\S]*?<\\/pre>)\\s*/i'
|
||||
,array($this, '_removePreCB')
|
||||
,$this->_html);
|
||||
|
||||
// replace TEXTAREAs with placeholders
|
||||
$this->_html = preg_replace_callback(
|
||||
'/\\s*<textarea(\\b[^>]*?>[\\s\\S]*?<\\/textarea>)\\s*/i'
|
||||
,array($this, '_removeTextareaCB')
|
||||
,$this->_html);
|
||||
|
||||
// trim each line.
|
||||
// @todo take into account attribute values that span multiple lines.
|
||||
$this->_html = preg_replace('/^\\s+|\\s+$/m', '', $this->_html);
|
||||
|
||||
// remove ws around block/undisplayed elements
|
||||
$this->_html = preg_replace('/\\s+(<\\/?(?:area|base(?:font)?|blockquote|body'
|
||||
.'|caption|center|col(?:group)?|dd|dir|div|dl|dt|fieldset|form'
|
||||
.'|frame(?:set)?|h[1-6]|head|hr|html|legend|li|link|map|menu|meta'
|
||||
.'|ol|opt(?:group|ion)|p|param|t(?:able|body|head|d|h||r|foot|itle)'
|
||||
.'|ul)\\b[^>]*>)/i', '$1', $this->_html);
|
||||
|
||||
// remove ws outside of all elements
|
||||
$this->_html = preg_replace(
|
||||
'/>(\\s(?:\\s*))?([^<]+)(\\s(?:\s*))?</'
|
||||
,'>$1$2$3<'
|
||||
,$this->_html);
|
||||
|
||||
// use newlines before 1st attribute in open tags (to limit line lengths)
|
||||
$this->_html = preg_replace('/(<[a-z\\-]+)\\s+([^>]+>)/i', "$1\n$2", $this->_html);
|
||||
|
||||
// fill placeholders
|
||||
$this->_html = str_replace(
|
||||
array_keys($this->_placeholders)
|
||||
,array_values($this->_placeholders)
|
||||
,$this->_html
|
||||
);
|
||||
// issue 229: multi-pass to catch scripts that didn't get replaced in textareas
|
||||
$this->_html = str_replace(
|
||||
array_keys($this->_placeholders)
|
||||
,array_values($this->_placeholders)
|
||||
,$this->_html
|
||||
);
|
||||
return $this->_html;
|
||||
}
|
||||
|
||||
protected function _commentCB($m)
|
||||
{
|
||||
return (0 === strpos($m[1], '[') || false !== strpos($m[1], '<!['))
|
||||
? $m[0]
|
||||
: '';
|
||||
}
|
||||
|
||||
protected function _reservePlace($content)
|
||||
{
|
||||
$placeholder = '%' . $this->_replacementHash . count($this->_placeholders) . '%';
|
||||
$this->_placeholders[$placeholder] = $content;
|
||||
return $placeholder;
|
||||
}
|
||||
|
||||
protected $_isXhtml = null;
|
||||
protected $_replacementHash = null;
|
||||
protected $_placeholders = array();
|
||||
protected $_cssMinifier = null;
|
||||
protected $_jsMinifier = null;
|
||||
|
||||
protected function _removePreCB($m)
|
||||
{
|
||||
return $this->_reservePlace("<pre{$m[1]}");
|
||||
}
|
||||
|
||||
protected function _removeTextareaCB($m)
|
||||
{
|
||||
return $this->_reservePlace("<textarea{$m[1]}");
|
||||
}
|
||||
|
||||
protected function _removeStyleCB($m)
|
||||
{
|
||||
$openStyle = "<style{$m[1]}";
|
||||
$css = $m[2];
|
||||
// remove HTML comments
|
||||
$css = preg_replace('/(?:^\\s*<!--|-->\\s*$)/', '', $css);
|
||||
|
||||
// remove CDATA section markers
|
||||
$css = $this->_removeCdata($css);
|
||||
|
||||
// minify
|
||||
$minifier = $this->_cssMinifier
|
||||
? $this->_cssMinifier
|
||||
: 'trim';
|
||||
$css = call_user_func($minifier, $css);
|
||||
|
||||
return $this->_reservePlace($this->_needsCdata($css)
|
||||
? "{$openStyle}/*<![CDATA[*/{$css}/*]]>*/</style>"
|
||||
: "{$openStyle}{$css}</style>"
|
||||
);
|
||||
}
|
||||
|
||||
protected function _removeScriptCB($m)
|
||||
{
|
||||
$openScript = "<script{$m[2]}";
|
||||
$js = $m[3];
|
||||
|
||||
// whitespace surrounding? preserve at least one space
|
||||
$ws1 = ($m[1] === '') ? '' : ' ';
|
||||
$ws2 = ($m[4] === '') ? '' : ' ';
|
||||
|
||||
// remove HTML comments (and ending "//" if present)
|
||||
if ($this->_jsCleanComments) {
|
||||
$js = preg_replace('/(?:^\\s*<!--\\s*|\\s*(?:\\/\\/)?\\s*-->\\s*$)/', '', $js);
|
||||
}
|
||||
|
||||
// remove CDATA section markers
|
||||
$js = $this->_removeCdata($js);
|
||||
|
||||
// minify
|
||||
$minifier = $this->_jsMinifier
|
||||
? $this->_jsMinifier
|
||||
: 'trim';
|
||||
$js = call_user_func($minifier, $js);
|
||||
|
||||
return $this->_reservePlace($this->_needsCdata($js)
|
||||
? "{$ws1}{$openScript}/*<![CDATA[*/{$js}/*]]>*/</script>{$ws2}"
|
||||
: "{$ws1}{$openScript}{$js}</script>{$ws2}"
|
||||
);
|
||||
}
|
||||
|
||||
protected function _removeCdata($str)
|
||||
{
|
||||
return (false !== strpos($str, '<![CDATA['))
|
||||
? str_replace(array('<![CDATA[', ']]>'), '', $str)
|
||||
: $str;
|
||||
}
|
||||
|
||||
protected function _needsCdata($str)
|
||||
{
|
||||
return ($this->_isXhtml && preg_match('/(?:[<&]|\\-\\-|\\]\\]>)/', $str));
|
||||
}
|
||||
}
|
||||
225
vendor/mrclay/minify/min/lib/Minify/HTML/Helper.php
vendored
225
vendor/mrclay/minify/min/lib/Minify/HTML/Helper.php
vendored
@@ -1,225 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Class Minify_HTML_Helper
|
||||
* @package Minify
|
||||
*/
|
||||
|
||||
/**
|
||||
* Helpers for writing Minfy URIs into HTML
|
||||
*
|
||||
* @package Minify
|
||||
* @author Stephen Clay <steve@mrclay.org>
|
||||
*/
|
||||
class Minify_HTML_Helper {
|
||||
public $rewriteWorks = true;
|
||||
public $minAppUri = '/min';
|
||||
public $groupsConfigFile = '';
|
||||
|
||||
/**
|
||||
* Get an HTML-escaped Minify URI for a group or set of files
|
||||
*
|
||||
* @param string|array $keyOrFiles a group key or array of filepaths/URIs
|
||||
* @param array $opts options:
|
||||
* 'farExpires' : (default true) append a modified timestamp for cache revving
|
||||
* 'debug' : (default false) append debug flag
|
||||
* 'charset' : (default 'UTF-8') for htmlspecialchars
|
||||
* 'minAppUri' : (default '/min') URI of min directory
|
||||
* 'rewriteWorks' : (default true) does mod_rewrite work in min app?
|
||||
* 'groupsConfigFile' : specify if different
|
||||
* @return string
|
||||
*/
|
||||
public static function getUri($keyOrFiles, $opts = array())
|
||||
{
|
||||
$opts = array_merge(array( // default options
|
||||
'farExpires' => true
|
||||
,'debug' => false
|
||||
,'charset' => 'UTF-8'
|
||||
,'minAppUri' => '/min'
|
||||
,'rewriteWorks' => true
|
||||
,'groupsConfigFile' => ''
|
||||
), $opts);
|
||||
$h = new self;
|
||||
$h->minAppUri = $opts['minAppUri'];
|
||||
$h->rewriteWorks = $opts['rewriteWorks'];
|
||||
$h->groupsConfigFile = $opts['groupsConfigFile'];
|
||||
if (is_array($keyOrFiles)) {
|
||||
$h->setFiles($keyOrFiles, $opts['farExpires']);
|
||||
} else {
|
||||
$h->setGroup($keyOrFiles, $opts['farExpires']);
|
||||
}
|
||||
$uri = $h->getRawUri($opts['farExpires'], $opts['debug']);
|
||||
return htmlspecialchars($uri, ENT_QUOTES, $opts['charset']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get non-HTML-escaped URI to minify the specified files
|
||||
*
|
||||
* @param bool $farExpires
|
||||
* @param bool $debug
|
||||
* @return string
|
||||
*/
|
||||
public function getRawUri($farExpires = true, $debug = false)
|
||||
{
|
||||
$path = rtrim($this->minAppUri, '/') . '/';
|
||||
if (! $this->rewriteWorks) {
|
||||
$path .= '?';
|
||||
}
|
||||
if (null === $this->_groupKey) {
|
||||
// @todo: implement shortest uri
|
||||
$path = self::_getShortestUri($this->_filePaths, $path);
|
||||
} else {
|
||||
$path .= "g=" . $this->_groupKey;
|
||||
}
|
||||
if ($debug) {
|
||||
$path .= "&debug";
|
||||
} elseif ($farExpires && $this->_lastModified) {
|
||||
$path .= "&" . $this->_lastModified;
|
||||
}
|
||||
return $path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the files that will comprise the URI we're building
|
||||
*
|
||||
* @param array $files
|
||||
* @param bool $checkLastModified
|
||||
*/
|
||||
public function setFiles($files, $checkLastModified = true)
|
||||
{
|
||||
$this->_groupKey = null;
|
||||
if ($checkLastModified) {
|
||||
$this->_lastModified = self::getLastModified($files);
|
||||
}
|
||||
// normalize paths like in /min/f=<paths>
|
||||
foreach ($files as $k => $file) {
|
||||
if (0 === strpos($file, '//')) {
|
||||
$file = substr($file, 2);
|
||||
} elseif (0 === strpos($file, '/')
|
||||
|| 1 === strpos($file, ':\\')) {
|
||||
$file = substr($file, strlen($_SERVER['DOCUMENT_ROOT']) + 1);
|
||||
}
|
||||
$file = strtr($file, '\\', '/');
|
||||
$files[$k] = $file;
|
||||
}
|
||||
$this->_filePaths = $files;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the group of files that will comprise the URI we're building
|
||||
*
|
||||
* @param string $key
|
||||
* @param bool $checkLastModified
|
||||
*/
|
||||
public function setGroup($key, $checkLastModified = true)
|
||||
{
|
||||
$this->_groupKey = $key;
|
||||
if ($checkLastModified) {
|
||||
if (! $this->groupsConfigFile) {
|
||||
$this->groupsConfigFile = dirname(dirname(dirname(dirname(__FILE__)))) . '/groupsConfig.php';
|
||||
}
|
||||
if (is_file($this->groupsConfigFile)) {
|
||||
$gc = (require $this->groupsConfigFile);
|
||||
$keys = explode(',', $key);
|
||||
foreach ($keys as $key) {
|
||||
if (isset($gc[$key])) {
|
||||
$this->_lastModified = self::getLastModified($gc[$key], $this->_lastModified);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the max(lastModified) of all files
|
||||
*
|
||||
* @param array|string $sources
|
||||
* @param int $lastModified
|
||||
* @return int
|
||||
*/
|
||||
public static function getLastModified($sources, $lastModified = 0)
|
||||
{
|
||||
$max = $lastModified;
|
||||
foreach ((array)$sources as $source) {
|
||||
if (is_object($source) && isset($source->lastModified)) {
|
||||
$max = max($max, $source->lastModified);
|
||||
} elseif (is_string($source)) {
|
||||
if (0 === strpos($source, '//')) {
|
||||
$source = $_SERVER['DOCUMENT_ROOT'] . substr($source, 1);
|
||||
}
|
||||
if (is_file($source)) {
|
||||
$max = max($max, filemtime($source));
|
||||
}
|
||||
}
|
||||
}
|
||||
return $max;
|
||||
}
|
||||
|
||||
protected $_groupKey = null; // if present, URI will be like g=...
|
||||
protected $_filePaths = array();
|
||||
protected $_lastModified = null;
|
||||
|
||||
|
||||
/**
|
||||
* In a given array of strings, find the character they all have at
|
||||
* a particular index
|
||||
*
|
||||
* @param array $arr array of strings
|
||||
* @param int $pos index to check
|
||||
* @return mixed a common char or '' if any do not match
|
||||
*/
|
||||
protected static function _getCommonCharAtPos($arr, $pos) {
|
||||
if (!isset($arr[0][$pos])) {
|
||||
return '';
|
||||
}
|
||||
$c = $arr[0][$pos];
|
||||
$l = count($arr);
|
||||
if ($l === 1) {
|
||||
return $c;
|
||||
}
|
||||
for ($i = 1; $i < $l; ++$i) {
|
||||
if ($arr[$i][$pos] !== $c) {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
return $c;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the shortest URI to minify the set of source files
|
||||
*
|
||||
* @param array $paths root-relative URIs of files
|
||||
* @param string $minRoot root-relative URI of the "min" application
|
||||
* @return string
|
||||
*/
|
||||
protected static function _getShortestUri($paths, $minRoot = '/min/') {
|
||||
$pos = 0;
|
||||
$base = '';
|
||||
while (true) {
|
||||
$c = self::_getCommonCharAtPos($paths, $pos);
|
||||
if ($c === '') {
|
||||
break;
|
||||
} else {
|
||||
$base .= $c;
|
||||
}
|
||||
++$pos;
|
||||
}
|
||||
$base = preg_replace('@[^/]+$@', '', $base);
|
||||
$uri = $minRoot . 'f=' . implode(',', $paths);
|
||||
|
||||
if (substr($base, -1) === '/') {
|
||||
// we have a base dir!
|
||||
$basedPaths = $paths;
|
||||
$l = count($paths);
|
||||
for ($i = 0; $i < $l; ++$i) {
|
||||
$basedPaths[$i] = substr($paths[$i], strlen($base));
|
||||
}
|
||||
$base = substr($base, 0, strlen($base) - 1);
|
||||
$bUri = $minRoot . 'b=' . $base . '&f=' . implode(',', $basedPaths);
|
||||
|
||||
$uri = strlen($uri) < strlen($bUri)
|
||||
? $uri
|
||||
: $bUri;
|
||||
}
|
||||
return $uri;
|
||||
}
|
||||
}
|
||||
@@ -1,216 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Class Minify_ImportProcessor
|
||||
* @package Minify
|
||||
*/
|
||||
|
||||
/**
|
||||
* Linearize a CSS/JS file by including content specified by CSS import
|
||||
* declarations. In CSS files, relative URIs are fixed.
|
||||
*
|
||||
* @imports will be processed regardless of where they appear in the source
|
||||
* files; i.e. @imports commented out or in string content will still be
|
||||
* processed!
|
||||
*
|
||||
* This has a unit test but should be considered "experimental".
|
||||
*
|
||||
* @package Minify
|
||||
* @author Stephen Clay <steve@mrclay.org>
|
||||
* @author Simon Schick <simonsimcity@gmail.com>
|
||||
*/
|
||||
class Minify_ImportProcessor {
|
||||
|
||||
public static $filesIncluded = array();
|
||||
|
||||
public static function process($file)
|
||||
{
|
||||
self::$filesIncluded = array();
|
||||
self::$_isCss = (strtolower(substr($file, -4)) === '.css');
|
||||
$obj = new Minify_ImportProcessor(dirname($file));
|
||||
return $obj->_getContent($file);
|
||||
}
|
||||
|
||||
// allows callback funcs to know the current directory
|
||||
private $_currentDir = null;
|
||||
|
||||
// allows callback funcs to know the directory of the file that inherits this one
|
||||
private $_previewsDir = null;
|
||||
|
||||
// allows _importCB to write the fetched content back to the obj
|
||||
private $_importedContent = '';
|
||||
|
||||
private static $_isCss = null;
|
||||
|
||||
/**
|
||||
* @param String $currentDir
|
||||
* @param String $previewsDir Is only used internally
|
||||
*/
|
||||
private function __construct($currentDir, $previewsDir = "")
|
||||
{
|
||||
$this->_currentDir = $currentDir;
|
||||
$this->_previewsDir = $previewsDir;
|
||||
}
|
||||
|
||||
private function _getContent($file, $is_imported = false)
|
||||
{
|
||||
$file = realpath($file);
|
||||
if (! $file
|
||||
|| in_array($file, self::$filesIncluded)
|
||||
|| false === ($content = @file_get_contents($file))
|
||||
) {
|
||||
// file missing, already included, or failed read
|
||||
return '';
|
||||
}
|
||||
self::$filesIncluded[] = realpath($file);
|
||||
$this->_currentDir = dirname($file);
|
||||
|
||||
// remove UTF-8 BOM if present
|
||||
if (pack("CCC",0xef,0xbb,0xbf) === substr($content, 0, 3)) {
|
||||
$content = substr($content, 3);
|
||||
}
|
||||
// ensure uniform EOLs
|
||||
$content = str_replace("\r\n", "\n", $content);
|
||||
|
||||
// process @imports
|
||||
$content = preg_replace_callback(
|
||||
'/
|
||||
@import\\s+
|
||||
(?:url\\(\\s*)? # maybe url(
|
||||
[\'"]? # maybe quote
|
||||
(.*?) # 1 = URI
|
||||
[\'"]? # maybe end quote
|
||||
(?:\\s*\\))? # maybe )
|
||||
([a-zA-Z,\\s]*)? # 2 = media list
|
||||
; # end token
|
||||
/x'
|
||||
,array($this, '_importCB')
|
||||
,$content
|
||||
);
|
||||
|
||||
// You only need to rework the import-path if the script is imported
|
||||
if (self::$_isCss && $is_imported) {
|
||||
// rewrite remaining relative URIs
|
||||
$content = preg_replace_callback(
|
||||
'/url\\(\\s*([^\\)\\s]+)\\s*\\)/'
|
||||
,array($this, '_urlCB')
|
||||
,$content
|
||||
);
|
||||
}
|
||||
|
||||
return $this->_importedContent . $content;
|
||||
}
|
||||
|
||||
private function _importCB($m)
|
||||
{
|
||||
$url = $m[1];
|
||||
$mediaList = preg_replace('/\\s+/', '', $m[2]);
|
||||
|
||||
if (strpos($url, '://') > 0) {
|
||||
// protocol, leave in place for CSS, comment for JS
|
||||
return self::$_isCss
|
||||
? $m[0]
|
||||
: "/* Minify_ImportProcessor will not include remote content */";
|
||||
}
|
||||
if ('/' === $url[0]) {
|
||||
// protocol-relative or root path
|
||||
$url = ltrim($url, '/');
|
||||
$file = realpath($_SERVER['DOCUMENT_ROOT']) . DIRECTORY_SEPARATOR
|
||||
. strtr($url, '/', DIRECTORY_SEPARATOR);
|
||||
} else {
|
||||
// relative to current path
|
||||
$file = $this->_currentDir . DIRECTORY_SEPARATOR
|
||||
. strtr($url, '/', DIRECTORY_SEPARATOR);
|
||||
}
|
||||
$obj = new Minify_ImportProcessor(dirname($file), $this->_currentDir);
|
||||
$content = $obj->_getContent($file, true);
|
||||
if ('' === $content) {
|
||||
// failed. leave in place for CSS, comment for JS
|
||||
return self::$_isCss
|
||||
? $m[0]
|
||||
: "/* Minify_ImportProcessor could not fetch '{$file}' */";
|
||||
}
|
||||
return (!self::$_isCss || preg_match('@(?:^$|\\ball\\b)@', $mediaList))
|
||||
? $content
|
||||
: "@media {$mediaList} {\n{$content}\n}\n";
|
||||
}
|
||||
|
||||
private function _urlCB($m)
|
||||
{
|
||||
// $m[1] is either quoted or not
|
||||
$quote = ($m[1][0] === "'" || $m[1][0] === '"')
|
||||
? $m[1][0]
|
||||
: '';
|
||||
$url = ($quote === '')
|
||||
? $m[1]
|
||||
: substr($m[1], 1, strlen($m[1]) - 2);
|
||||
if ('/' !== $url[0]) {
|
||||
if (strpos($url, '//') > 0) {
|
||||
// probably starts with protocol, do not alter
|
||||
} else {
|
||||
// prepend path with current dir separator (OS-independent)
|
||||
$path = $this->_currentDir
|
||||
. DIRECTORY_SEPARATOR . strtr($url, '/', DIRECTORY_SEPARATOR);
|
||||
// update the relative path by the directory of the file that imported this one
|
||||
$url = self::getPathDiff(realpath($this->_previewsDir), $path);
|
||||
}
|
||||
}
|
||||
return "url({$quote}{$url}{$quote})";
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $from
|
||||
* @param string $to
|
||||
* @param string $ps
|
||||
* @return string
|
||||
*/
|
||||
private function getPathDiff($from, $to, $ps = DIRECTORY_SEPARATOR)
|
||||
{
|
||||
$realFrom = $this->truepath($from);
|
||||
$realTo = $this->truepath($to);
|
||||
|
||||
$arFrom = explode($ps, rtrim($realFrom, $ps));
|
||||
$arTo = explode($ps, rtrim($realTo, $ps));
|
||||
while (count($arFrom) && count($arTo) && ($arFrom[0] == $arTo[0]))
|
||||
{
|
||||
array_shift($arFrom);
|
||||
array_shift($arTo);
|
||||
}
|
||||
return str_pad("", count($arFrom) * 3, '..' . $ps) . implode($ps, $arTo);
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is to replace PHP's extremely buggy realpath().
|
||||
* @param string $path The original path, can be relative etc.
|
||||
* @return string The resolved path, it might not exist.
|
||||
* @see http://stackoverflow.com/questions/4049856/replace-phps-realpath
|
||||
*/
|
||||
function truepath($path)
|
||||
{
|
||||
// whether $path is unix or not
|
||||
$unipath = strlen($path) == 0 || $path{0} != '/';
|
||||
// attempts to detect if path is relative in which case, add cwd
|
||||
if (strpos($path, ':') === false && $unipath)
|
||||
$path = $this->_currentDir . DIRECTORY_SEPARATOR . $path;
|
||||
|
||||
// resolve path parts (single dot, double dot and double delimiters)
|
||||
$path = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $path);
|
||||
$parts = array_filter(explode(DIRECTORY_SEPARATOR, $path), 'strlen');
|
||||
$absolutes = array();
|
||||
foreach ($parts as $part) {
|
||||
if ('.' == $part)
|
||||
continue;
|
||||
if ('..' == $part) {
|
||||
array_pop($absolutes);
|
||||
} else {
|
||||
$absolutes[] = $part;
|
||||
}
|
||||
}
|
||||
$path = implode(DIRECTORY_SEPARATOR, $absolutes);
|
||||
// resolve any symlinks
|
||||
if (file_exists($path) && linkinfo($path) > 0)
|
||||
$path = readlink($path);
|
||||
// put initial separator that could have been lost
|
||||
$path = !$unipath ? '/' . $path : $path;
|
||||
return $path;
|
||||
}
|
||||
}
|
||||
@@ -1,230 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Class Minify_JS_ClosureCompiler
|
||||
* @package Minify
|
||||
*/
|
||||
|
||||
/**
|
||||
* Minify Javascript using Google's Closure Compiler API
|
||||
*
|
||||
* @link http://code.google.com/closure/compiler/
|
||||
* @package Minify
|
||||
* @author Stephen Clay <steve@mrclay.org>
|
||||
*
|
||||
* @todo can use a stream wrapper to unit test this?
|
||||
*/
|
||||
class Minify_JS_ClosureCompiler {
|
||||
|
||||
/**
|
||||
* @var string The option key for the maximum POST byte size
|
||||
*/
|
||||
const OPTION_MAX_BYTES = 'maxBytes';
|
||||
|
||||
/**
|
||||
* @var string The option key for additional params. @see __construct
|
||||
*/
|
||||
const OPTION_ADDITIONAL_OPTIONS = 'additionalParams';
|
||||
|
||||
/**
|
||||
* @var string The option key for the fallback Minifier
|
||||
*/
|
||||
const OPTION_FALLBACK_FUNCTION = 'fallbackFunc';
|
||||
|
||||
/**
|
||||
* @var string The option key for the service URL
|
||||
*/
|
||||
const OPTION_COMPILER_URL = 'compilerUrl';
|
||||
|
||||
/**
|
||||
* @var int The default maximum POST byte size according to https://developers.google.com/closure/compiler/docs/api-ref
|
||||
*/
|
||||
const DEFAULT_MAX_BYTES = 200000;
|
||||
|
||||
/**
|
||||
* @var string[] $DEFAULT_OPTIONS The default options to pass to the compiler service
|
||||
*
|
||||
* @note This would be a constant if PHP allowed it
|
||||
*/
|
||||
private static $DEFAULT_OPTIONS = array(
|
||||
'output_format' => 'text',
|
||||
'compilation_level' => 'SIMPLE_OPTIMIZATIONS'
|
||||
);
|
||||
|
||||
/**
|
||||
* @var string $url URL of compiler server. defaults to Google's
|
||||
*/
|
||||
protected $serviceUrl = 'http://closure-compiler.appspot.com/compile';
|
||||
|
||||
/**
|
||||
* @var int $maxBytes The maximum JS size that can be sent to the compiler server in bytes
|
||||
*/
|
||||
protected $maxBytes = self::DEFAULT_MAX_BYTES;
|
||||
|
||||
/**
|
||||
* @var string[] $additionalOptions Additional options to pass to the compiler service
|
||||
*/
|
||||
protected $additionalOptions = array();
|
||||
|
||||
/**
|
||||
* @var callable Function to minify JS if service fails. Default is JSMin
|
||||
*/
|
||||
protected $fallbackMinifier = array('JSMin', 'minify');
|
||||
|
||||
/**
|
||||
* Minify JavaScript code via HTTP request to a Closure Compiler API
|
||||
*
|
||||
* @param string $js input code
|
||||
* @param array $options Options passed to __construct(). @see __construct
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function minify($js, array $options = array())
|
||||
{
|
||||
$obj = new self($options);
|
||||
return $obj->min($js);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $options Options with keys available below:
|
||||
*
|
||||
* fallbackFunc : (callable) function to minify if service unavailable. Default is JSMin.
|
||||
*
|
||||
* compilerUrl : (string) URL to closure compiler server
|
||||
*
|
||||
* maxBytes : (int) The maximum amount of bytes to be sent as js_code in the POST request.
|
||||
* Defaults to 200000.
|
||||
*
|
||||
* additionalParams : (string[]) Additional parameters to pass to the compiler server. Can be anything named
|
||||
* in https://developers.google.com/closure/compiler/docs/api-ref except for js_code and
|
||||
* output_info
|
||||
*/
|
||||
public function __construct(array $options = array())
|
||||
{
|
||||
if (isset($options[self::OPTION_FALLBACK_FUNCTION])) {
|
||||
$this->fallbackMinifier = $options[self::OPTION_FALLBACK_FUNCTION];
|
||||
}
|
||||
if (isset($options[self::OPTION_COMPILER_URL])) {
|
||||
$this->serviceUrl = $options[self::OPTION_COMPILER_URL];
|
||||
}
|
||||
if (isset($options[self::OPTION_ADDITIONAL_OPTIONS]) && is_array($options[self::OPTION_ADDITIONAL_OPTIONS])) {
|
||||
$this->additionalOptions = $options[self::OPTION_ADDITIONAL_OPTIONS];
|
||||
}
|
||||
if (isset($options[self::OPTION_MAX_BYTES])) {
|
||||
$this->maxBytes = (int) $options[self::OPTION_MAX_BYTES];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Call the service to perform the minification
|
||||
*
|
||||
* @param string $js JavaScript code
|
||||
* @return string
|
||||
* @throws Minify_JS_ClosureCompiler_Exception
|
||||
*/
|
||||
public function min($js)
|
||||
{
|
||||
$postBody = $this->buildPostBody($js);
|
||||
|
||||
if ($this->maxBytes > 0) {
|
||||
$bytes = (function_exists('mb_strlen') && ((int)ini_get('mbstring.func_overload') & 2))
|
||||
? mb_strlen($postBody, '8bit')
|
||||
: strlen($postBody);
|
||||
if ($bytes > $this->maxBytes) {
|
||||
throw new Minify_JS_ClosureCompiler_Exception(
|
||||
'POST content larger than ' . $this->maxBytes . ' bytes'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$response = $this->getResponse($postBody);
|
||||
|
||||
if (preg_match('/^Error\(\d\d?\):/', $response)) {
|
||||
if (is_callable($this->fallbackMinifier)) {
|
||||
// use fallback
|
||||
$response = "/* Received errors from Closure Compiler API:\n$response"
|
||||
. "\n(Using fallback minifier)\n*/\n";
|
||||
$response .= call_user_func($this->fallbackMinifier, $js);
|
||||
} else {
|
||||
throw new Minify_JS_ClosureCompiler_Exception($response);
|
||||
}
|
||||
}
|
||||
|
||||
if ($response === '') {
|
||||
$errors = $this->getResponse($this->buildPostBody($js, true));
|
||||
throw new Minify_JS_ClosureCompiler_Exception($errors);
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the response for a given POST body
|
||||
*
|
||||
* @param string $postBody
|
||||
* @return string
|
||||
* @throws Minify_JS_ClosureCompiler_Exception
|
||||
*/
|
||||
protected function getResponse($postBody)
|
||||
{
|
||||
$allowUrlFopen = preg_match('/1|yes|on|true/i', ini_get('allow_url_fopen'));
|
||||
|
||||
if ($allowUrlFopen) {
|
||||
$contents = file_get_contents($this->serviceUrl, false, stream_context_create(array(
|
||||
'http' => array(
|
||||
'method' => 'POST',
|
||||
'header' => "Content-type: application/x-www-form-urlencoded\r\nConnection: close\r\n",
|
||||
'content' => $postBody,
|
||||
'max_redirects' => 0,
|
||||
'timeout' => 15,
|
||||
)
|
||||
)));
|
||||
} elseif (defined('CURLOPT_POST')) {
|
||||
$ch = curl_init($this->serviceUrl);
|
||||
curl_setopt($ch, CURLOPT_POST, true);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-type: application/x-www-form-urlencoded'));
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $postBody);
|
||||
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
|
||||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 15);
|
||||
$contents = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
} else {
|
||||
throw new Minify_JS_ClosureCompiler_Exception(
|
||||
"Could not make HTTP request: allow_url_open is false and cURL not available"
|
||||
);
|
||||
}
|
||||
|
||||
if (false === $contents) {
|
||||
throw new Minify_JS_ClosureCompiler_Exception(
|
||||
"No HTTP response from server"
|
||||
);
|
||||
}
|
||||
|
||||
return trim($contents);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a POST request body
|
||||
*
|
||||
* @param string $js JavaScript code
|
||||
* @param bool $returnErrors
|
||||
* @return string
|
||||
*/
|
||||
protected function buildPostBody($js, $returnErrors = false)
|
||||
{
|
||||
return http_build_query(
|
||||
array_merge(
|
||||
self::$DEFAULT_OPTIONS,
|
||||
$this->additionalOptions,
|
||||
array(
|
||||
'js_code' => $js,
|
||||
'output_info' => ($returnErrors ? 'errors' : 'compiled_code')
|
||||
)
|
||||
),
|
||||
null,
|
||||
'&'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class Minify_JS_ClosureCompiler_Exception extends Exception {}
|
||||
143
vendor/mrclay/minify/min/lib/Minify/Lines.php
vendored
143
vendor/mrclay/minify/min/lib/Minify/Lines.php
vendored
@@ -1,143 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Class Minify_Lines
|
||||
* @package Minify
|
||||
*/
|
||||
|
||||
/**
|
||||
* Add line numbers in C-style comments for easier debugging of combined content
|
||||
*
|
||||
* @package Minify
|
||||
* @author Stephen Clay <steve@mrclay.org>
|
||||
* @author Adam Pedersen (Issue 55 fix)
|
||||
*/
|
||||
class Minify_Lines {
|
||||
|
||||
/**
|
||||
* Add line numbers in C-style comments
|
||||
*
|
||||
* This uses a very basic parser easily fooled by comment tokens inside
|
||||
* strings or regexes, but, otherwise, generally clean code will not be
|
||||
* mangled. URI rewriting can also be performed.
|
||||
*
|
||||
* @param string $content
|
||||
*
|
||||
* @param array $options available options:
|
||||
*
|
||||
* 'id': (optional) string to identify file. E.g. file name/path
|
||||
*
|
||||
* 'currentDir': (default null) if given, this is assumed to be the
|
||||
* directory of the current CSS file. Using this, minify will rewrite
|
||||
* all relative URIs in import/url declarations to correctly point to
|
||||
* the desired files, and prepend a comment with debugging information about
|
||||
* this process.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function minify($content, $options = array())
|
||||
{
|
||||
$id = (isset($options['id']) && $options['id'])
|
||||
? $options['id']
|
||||
: '';
|
||||
$content = str_replace("\r\n", "\n", $content);
|
||||
|
||||
// Hackily rewrite strings with XPath expressions that are
|
||||
// likely to throw off our dumb parser (for Prototype 1.6.1).
|
||||
$content = str_replace('"/*"', '"/"+"*"', $content);
|
||||
$content = preg_replace('@([\'"])(\\.?//?)\\*@', '$1$2$1+$1*', $content);
|
||||
|
||||
$lines = explode("\n", $content);
|
||||
$numLines = count($lines);
|
||||
// determine left padding
|
||||
$padTo = strlen((string) $numLines); // e.g. 103 lines = 3 digits
|
||||
$inComment = false;
|
||||
$i = 0;
|
||||
$newLines = array();
|
||||
while (null !== ($line = array_shift($lines))) {
|
||||
if (('' !== $id) && (0 == $i % 50)) {
|
||||
if ($inComment) {
|
||||
array_push($newLines, '', "/* {$id} *|", '');
|
||||
} else {
|
||||
array_push($newLines, '', "/* {$id} */", '');
|
||||
}
|
||||
}
|
||||
++$i;
|
||||
$newLines[] = self::_addNote($line, $i, $inComment, $padTo);
|
||||
$inComment = self::_eolInComment($line, $inComment);
|
||||
}
|
||||
$content = implode("\n", $newLines) . "\n";
|
||||
|
||||
// check for desired URI rewriting
|
||||
if (isset($options['currentDir'])) {
|
||||
Minify_CSS_UriRewriter::$debugText = '';
|
||||
$content = Minify_CSS_UriRewriter::rewrite(
|
||||
$content
|
||||
,$options['currentDir']
|
||||
,isset($options['docRoot']) ? $options['docRoot'] : $_SERVER['DOCUMENT_ROOT']
|
||||
,isset($options['symlinks']) ? $options['symlinks'] : array()
|
||||
);
|
||||
$content = "/* Minify_CSS_UriRewriter::\$debugText\n\n"
|
||||
. Minify_CSS_UriRewriter::$debugText . "*/\n"
|
||||
. $content;
|
||||
}
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is the parser within a C-style comment at the end of this line?
|
||||
*
|
||||
* @param string $line current line of code
|
||||
*
|
||||
* @param bool $inComment was the parser in a comment at the
|
||||
* beginning of the line?
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private static function _eolInComment($line, $inComment)
|
||||
{
|
||||
// crude way to avoid things like // */
|
||||
$line = preg_replace('~//.*?(\\*/|/\\*).*~', '', $line);
|
||||
|
||||
while (strlen($line)) {
|
||||
$search = $inComment
|
||||
? '*/'
|
||||
: '/*';
|
||||
$pos = strpos($line, $search);
|
||||
if (false === $pos) {
|
||||
return $inComment;
|
||||
} else {
|
||||
if ($pos == 0
|
||||
|| ($inComment
|
||||
? substr($line, $pos, 3)
|
||||
: substr($line, $pos-1, 3)) != '*/*')
|
||||
{
|
||||
$inComment = ! $inComment;
|
||||
}
|
||||
$line = substr($line, $pos + 2);
|
||||
}
|
||||
}
|
||||
return $inComment;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepend a comment (or note) to the given line
|
||||
*
|
||||
* @param string $line current line of code
|
||||
*
|
||||
* @param string $note content of note/comment
|
||||
*
|
||||
* @param bool $inComment was the parser in a comment at the
|
||||
* beginning of the line?
|
||||
*
|
||||
* @param int $padTo minimum width of comment
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private static function _addNote($line, $note, $inComment, $padTo)
|
||||
{
|
||||
return $inComment
|
||||
? '/* ' . str_pad($note, $padTo, ' ', STR_PAD_RIGHT) . ' *| ' . $line
|
||||
: '/* ' . str_pad($note, $padTo, ' ', STR_PAD_RIGHT) . ' */ ' . $line;
|
||||
}
|
||||
}
|
||||
28
vendor/mrclay/minify/min/lib/Minify/Loader.php
vendored
28
vendor/mrclay/minify/min/lib/Minify/Loader.php
vendored
@@ -1,28 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Class Minify_Loader
|
||||
* @package Minify
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class autoloader
|
||||
*
|
||||
* @package Minify
|
||||
* @author Stephen Clay <steve@mrclay.org>
|
||||
*/
|
||||
class Minify_Loader {
|
||||
public function loadClass($class)
|
||||
{
|
||||
$file = dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR;
|
||||
$file .= strtr($class, "\\_", DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR) . '.php';
|
||||
if (is_readable($file)) {
|
||||
require $file;
|
||||
}
|
||||
}
|
||||
|
||||
static public function register()
|
||||
{
|
||||
$inst = new self();
|
||||
spl_autoload_register(array($inst, 'loadClass'));
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user