mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-10 03:23:19 +00:00
fix build & add loader classes
This commit is contained in:
@@ -363,37 +363,12 @@ class Core extends \Pimple
|
||||
*/
|
||||
public static function initAutoloads($debug = false)
|
||||
{
|
||||
require_once __DIR__ . '/../../vendor/symfony/src/Symfony/Component/ClassLoader/UniversalClassLoader.php';
|
||||
|
||||
// require_once __DIR__ . '/../../vendor/symfony/src/Symfony/Component/ClassLoader/UniversalClassLoader.php';
|
||||
require_once __DIR__ . '/Loader/Autoloader.php';
|
||||
require_once __DIR__ . '/Loader/CacheAutoloader.php';
|
||||
|
||||
// require_once __DIR__ . '/../../vendor/Twig/lib/Twig/Autoloader.php';
|
||||
// require_once __DIR__ . '/../../vendor/Twig-extensions/lib/Twig/Extensions/Autoloader.php';
|
||||
//
|
||||
// \Twig_Autoloader::register();
|
||||
// \Twig_Extensions_Autoloader::register();
|
||||
|
||||
|
||||
// if ($debug === false)
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// $loader = new Loader\CacheAutoloader('class_');
|
||||
// }
|
||||
// catch (\Exception $e)
|
||||
// {
|
||||
// $loader = new Loader\Autoloader();
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
$loader = new Loader\Autoloader();
|
||||
$loader->register();
|
||||
$loader = new \Symfony\Component\ClassLoader\UniversalClassLoader();
|
||||
// }
|
||||
|
||||
$loader->registerPrefixes(array('Twig_' => realpath(__DIR__ . '/../../vendor/Twig/lib')));
|
||||
$loader->registerPrefixes(array('Twig' => realpath(__DIR__ . '/../../vendor/Twig/lib')));
|
||||
$loader->registerPrefixes(array('Twig_Extensions' => realpath(__DIR__ . '/../../vendor/Twig-extensions/lib')));
|
||||
|
||||
$loader->registerNamespaces(array(
|
||||
|
70
lib/Alchemy/Phrasea/Loader/ApcAutoloader.php
Normal file
70
lib/Alchemy/Phrasea/Loader/ApcAutoloader.php
Normal file
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2010 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Alchemy\Phrasea\Loader;
|
||||
|
||||
use Alchemy\Phrasea\Loader\LoaderStrategy as CacheStrategy;
|
||||
|
||||
/**
|
||||
*
|
||||
* @package
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
Class ApcAutoloader extends Autoloader implements CacheStrategy
|
||||
{
|
||||
|
||||
private $prefix;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $prefix A prefix to create a namespace in APC
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function __construct($prefix)
|
||||
{
|
||||
if (!$this->isAvailable())
|
||||
{
|
||||
throw new \Exception("Apc cache is not enable");
|
||||
}
|
||||
|
||||
$this->prefix = $prefix;
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds a file by class name while caching lookups to APC.
|
||||
*
|
||||
* @param string $class A class name to resolve to file
|
||||
*/
|
||||
public function findFile($class)
|
||||
{
|
||||
var_dump(__CLASS__ . " find : " . $class);
|
||||
if (false === $file = apc_fetch($this->prefix . $class))
|
||||
{
|
||||
apc_store($this->prefix . $class, $file = parent::findFile($class));
|
||||
}
|
||||
|
||||
return $file;
|
||||
}
|
||||
|
||||
public function isAvailable()
|
||||
{
|
||||
return extension_loaded('apc');
|
||||
}
|
||||
|
||||
public function register($prepend = false)
|
||||
{
|
||||
spl_autoload_register(array($this, 'loadClass'), true, $prepend);
|
||||
}
|
||||
|
||||
}
|
45
lib/Alchemy/Phrasea/Loader/Autoloader.php
Normal file
45
lib/Alchemy/Phrasea/Loader/Autoloader.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2010 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Alchemy\Phrasea\Loader;
|
||||
|
||||
require_once __DIR__ . "/../../../vendor/symfony/src/Symfony/Component/ClassLoader/UniversalClassLoader.php";
|
||||
|
||||
use Symfony\Component\ClassLoader\UniversalClassLoader;
|
||||
|
||||
/**
|
||||
*
|
||||
* @package
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
class Autoloader extends UniversalClassLoader
|
||||
{
|
||||
|
||||
public function findFile($class)
|
||||
{
|
||||
if (file_exists(__DIR__ . '/../../../../config/classes/' . str_replace('_', '/', $class) . '.class.php'))
|
||||
{
|
||||
$file = __DIR__ . '/../../../../config/classes/' . str_replace('_', '/', $class) . '.class.php';
|
||||
}
|
||||
elseif (file_exists(__DIR__ . '/../../../classes/' . str_replace('_', '/', $class) . '.class.php'))
|
||||
{
|
||||
$file = __DIR__ . '/../../../classes/' . str_replace('_', '/', $class) . '.class.php';
|
||||
}
|
||||
else
|
||||
{
|
||||
$file = parent::findFile($class);
|
||||
}
|
||||
|
||||
return $file;
|
||||
}
|
||||
|
||||
}
|
58
lib/Alchemy/Phrasea/Loader/CacheAutoloader.php
Normal file
58
lib/Alchemy/Phrasea/Loader/CacheAutoloader.php
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2010 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Alchemy\Phrasea\Loader;
|
||||
|
||||
require_once __DIR__ . '/Autoloader.php';
|
||||
require_once __DIR__ . '/LoaderStrategy.php';
|
||||
require_once __DIR__ . '/ApcAutoloader.php';
|
||||
require_once __DIR__ . '/XcacheAutoloader.php';
|
||||
|
||||
/**
|
||||
*
|
||||
* @package
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
class CacheAutoloader extends Autoloader
|
||||
{
|
||||
|
||||
private $cacheStrategies = array(
|
||||
'\Alchemy\Phrasea\Loader\ApcAutoloader',
|
||||
'\Alchemy\Phrasea\Loader\XcacheAutoloader',
|
||||
);
|
||||
private $cache;
|
||||
|
||||
public function __construct($prefix)
|
||||
{
|
||||
foreach ($this->cacheStrategies as $className)
|
||||
{
|
||||
$method = new $className($prefix);
|
||||
|
||||
if ($method instanceof LoaderStrategy && $method->isAvailable())
|
||||
{
|
||||
$this->cache = $method;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (null === $this->cache)
|
||||
{
|
||||
throw new Exception('No Cache available');
|
||||
}
|
||||
}
|
||||
|
||||
public function register($prepend = false)
|
||||
{
|
||||
$this->cache->register($prepend);
|
||||
}
|
||||
|
||||
}
|
24
lib/Alchemy/Phrasea/Loader/LoaderStrategy.php
Normal file
24
lib/Alchemy/Phrasea/Loader/LoaderStrategy.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2010 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace Alchemy\Phrasea\Loader;
|
||||
/**
|
||||
*
|
||||
* @package
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
|
||||
interface LoaderStrategy
|
||||
{
|
||||
public function isAvailable();
|
||||
|
||||
public function register();
|
||||
}
|
69
lib/Alchemy/Phrasea/Loader/XcacheAutoloader.php
Normal file
69
lib/Alchemy/Phrasea/Loader/XcacheAutoloader.php
Normal file
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2010 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Alchemy\Phrasea\Loader;
|
||||
|
||||
use Alchemy\Phrasea\Loader\LoaderStrategy as CacheStrategy;
|
||||
|
||||
/**
|
||||
*
|
||||
* @package
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
Class XcacheAutoloader extends Autoloader implements CacheStrategy
|
||||
{
|
||||
|
||||
private $prefix;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $prefix A prefix to create a namespace in APC
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function __construct($prefix)
|
||||
{
|
||||
if (!$this->isAvailable())
|
||||
{
|
||||
throw new \Exception("Xcache cache is not enable");
|
||||
}
|
||||
|
||||
$this->prefix = $prefix;
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds a file by class name while caching lookups to APC.
|
||||
*
|
||||
* @param string $class A class name to resolve to file
|
||||
*/
|
||||
public function findFile($class)
|
||||
{
|
||||
if (false === $file = xcache_get($this->prefix . $class))
|
||||
{
|
||||
xcache_set($this->prefix . $class, $file = parent::findFile($class));
|
||||
}
|
||||
|
||||
return $file;
|
||||
}
|
||||
|
||||
public function isAvailable()
|
||||
{
|
||||
return extension_loaded('xcache');
|
||||
}
|
||||
|
||||
public function register($prepend = false)
|
||||
{
|
||||
spl_autoload_register(array($this, 'loadClass'), true, $prepend);
|
||||
}
|
||||
|
||||
}
|
@@ -54,20 +54,6 @@ class patch_360 implements patchInterface
|
||||
|
||||
function apply(base &$appbox)
|
||||
{
|
||||
// $Core = bootstrap::getCore();
|
||||
//
|
||||
// $sql = 'SELECT ssel_id, name FROM ssel';
|
||||
//
|
||||
// $stmt = $appbox->get_connection()->prepare($sql);
|
||||
// $stmt->execute();
|
||||
// $rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
// $stmt->closeCursor();
|
||||
|
||||
|
||||
$stmt = $appbox->get_connection()->prepare($sql);
|
||||
$stmt->execute();
|
||||
$stmt->closeCursor();
|
||||
|
||||
$sql = 'INSERT INTO StoryWZ
|
||||
(
|
||||
SELECT null as id, sbas_id, rid as record_id, usr_id, date as created
|
||||
|
Reference in New Issue
Block a user