Refactor Appbox

This commit is contained in:
Romain Neutron
2012-02-21 16:01:55 +01:00
parent 80f22ca1fc
commit 375fd3d493
22 changed files with 77 additions and 73 deletions

View File

@@ -15,11 +15,11 @@
* @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com * @link www.phraseanet.com
*/ */
require_once __DIR__ . "/../../lib/bootstrap.php"; /* @var $Core \Alchemy\Phrasea\Core */
phrasea::headers(200, false, 'text/html', 'UTF-8', false); $Core = require_once __DIR__ . "/../../lib/bootstrap.php";
$appbox = appbox::get_instance($Core);
$request = http_request::getInstance(); $request = http_request::getInstance();
$appbox = appbox::get_instance();
$registry = $appbox->get_registry(); $registry = $appbox->get_registry();
$parm = $request->get_parms('action', 'position', 'test', 'renew', 'path', 'tests'); $parm = $request->get_parms('action', 'position', 'test', 'renew', 'path', 'tests');

View File

@@ -14,9 +14,9 @@
* @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com * @link www.phraseanet.com
*/ */
require_once __DIR__ . "/../../lib/bootstrap.php"; /* @var $Core \Alchemy\Phrasea\Core */
$Core = require_once __DIR__ . "/../../lib/bootstrap.php";
$appbox = appbox::get_instance(); $appbox = appbox::get_instance($Core);
$session = $appbox->get_session(); $session = $appbox->get_session();
$registry = $appbox->get_registry(); $registry = $appbox->get_registry();
$request = http_request::getInstance(); $request = http_request::getInstance();

View File

@@ -14,9 +14,9 @@
* @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com * @link www.phraseanet.com
*/ */
require_once __DIR__ . "/../../lib/bootstrap.php"; /* @var $Core \Alchemy\Phrasea\Core */
$Core = require_once __DIR__ . "/../../lib/bootstrap.php";
$appbox = appbox::get_instance(); $appbox = appbox::get_instance($Core);
$session = $appbox->get_session(); $session = $appbox->get_session();
$registry = $appbox->get_registry(); $registry = $appbox->get_registry();

View File

@@ -14,9 +14,9 @@
* @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com * @link www.phraseanet.com
*/ */
require_once __DIR__ . "/../../lib/bootstrap.php"; /* @var $Core \Alchemy\Phrasea\Core */
$Core = require_once __DIR__ . "/../../lib/bootstrap.php";
$appbox = appbox::get_instance(); $appbox = appbox::get_instance($Core);
$session = $appbox->get_session(); $session = $appbox->get_session();
$request = http_request::getInstance(); $request = http_request::getInstance();

View File

@@ -14,9 +14,9 @@
* @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com * @link www.phraseanet.com
*/ */
require_once __DIR__ . "/../../lib/bootstrap.php"; /* @var $Core \Alchemy\Phrasea\Core */
$Core = require_once __DIR__ . "/../../lib/bootstrap.php";
$appbox = appbox::get_instance(); $appbox = appbox::get_instance($Core);
$session = $appbox->get_session(); $session = $appbox->get_session();
$registry = $appbox->get_registry(); $registry = $appbox->get_registry();
$request = http_request::getInstance(); $request = http_request::getInstance();

View File

@@ -14,8 +14,9 @@
* @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com * @link www.phraseanet.com
*/ */
require_once __DIR__ . "/../../lib/bootstrap.php"; /* @var $Core \Alchemy\Phrasea\Core */
$appbox = appbox::get_instance(); $Core = require_once __DIR__ . "/../../lib/bootstrap.php";
$appbox = appbox::get_instance($Core);
$session = $appbox->get_session(); $session = $appbox->get_session();
$usr_id = $session->get_usr_id(); $usr_id = $session->get_usr_id();
$registry = $appbox->get_registry(); $registry = $appbox->get_registry();
@@ -53,7 +54,7 @@ phrasea::headers();
$checks = phrasea::is_scheduler_started(); $checks = phrasea::is_scheduler_started();
if ($checks !== true) if ($checks !== true)
{ {
$appbox = appbox::get_instance(); $appbox = appbox::get_instance(\bootstrap::getCore());
$upgrader = new Setup_Upgrade($appbox); $upgrader = new Setup_Upgrade($appbox);
$advices = $appbox->forceUpgrade($upgrader); $advices = $appbox->forceUpgrade($upgrader);
@@ -116,7 +117,7 @@ phrasea::headers();
$data_template = new system_file($registry->get('GV_RootPath') . 'lib/conf.d/data_templates/' . $parm['new_data_template'] . '.xml'); $data_template = new system_file($registry->get('GV_RootPath') . 'lib/conf.d/data_templates/' . $parm['new_data_template'] . '.xml');
$connbas = new connection_pdo('databox_creation', $hostname, $port, $user, $password, $parm['new_dbname']); $connbas = new connection_pdo('databox_creation', $hostname, $port, $user, $password, $parm['new_dbname'], array(), $appbox->get_registry());
try try
{ {
@@ -151,7 +152,7 @@ phrasea::headers();
try try
{ {
$data_template = new system_file($registry->get('GV_RootPath') . 'lib/conf.d/data_templates/' . $parm['new_data_template'] . '.xml'); $data_template = new system_file($registry->get('GV_RootPath') . 'lib/conf.d/data_templates/' . $parm['new_data_template'] . '.xml');
$connbas = new connection_pdo('databox_creation', $parm['new_hostname'], $parm['new_port'], $parm['new_user'], $parm['new_password'], $parm['new_dbname']); $connbas = new connection_pdo('databox_creation', $parm['new_hostname'], $parm['new_port'], $parm['new_user'], $parm['new_password'], $parm['new_dbname'], array(), $appbox->get_registry());
$base = databox::create($appbox, $connbas, $data_template, $registry); $base = databox::create($appbox, $connbas, $data_template, $registry);
$base->registerAdmin($user_obj); $base->registerAdmin($user_obj);
$createBase = $sbas_id = $base->get_sbas_id(); $createBase = $sbas_id = $base->get_sbas_id();

View File

@@ -15,9 +15,9 @@
* @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com * @link www.phraseanet.com
*/ */
require_once __DIR__ . "/../../lib/bootstrap.php"; /* @var $Core \Alchemy\Phrasea\Core */
$Core = require_once __DIR__ . "/../../lib/bootstrap.php";
$appbox = appbox::get_instance(); $appbox = appbox::get_instance($Core);
$session = $appbox->get_session(); $session = $appbox->get_session();
$request = http_request::getInstance(); $request = http_request::getInstance();

View File

@@ -14,11 +14,13 @@
* @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com * @link www.phraseanet.com
*/ */
require_once __DIR__ . "/../../lib/bootstrap.php"; /* @var $Core \Alchemy\Phrasea\Core */
$Core = require_once __DIR__ . "/../../lib/bootstrap.php";
$appbox = appbox::get_instance($Core);
$request = http_request::getInstance(); $request = http_request::getInstance();
$parm = $request->get_parms("u"); $parm = $request->get_parms("u");
$appbox = appbox::get_instance(); $appbox = appbox::get_instance(\bootstrap::getCore());
$user = User_Adapter::getInstance($parm['u'], $appbox); $user = User_Adapter::getInstance($parm['u'], $appbox);
phrasea::headers(); phrasea::headers();

View File

@@ -14,8 +14,9 @@
* @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com * @link www.phraseanet.com
*/ */
require_once("../../lib/bootstrap.php"); /* @var $Core \Alchemy\Phrasea\Core */
$appbox = appbox::get_instance(); $Core = require_once __DIR__ . "/../../lib/bootstrap.php";
$appbox = appbox::get_instance($Core);
$session = $appbox->get_session(); $session = $appbox->get_session();
$registry = $appbox->get_registry(); $registry = $appbox->get_registry();
require($registry->get('GV_RootPath') . "lib/classes/deprecated/countries.php"); require($registry->get('GV_RootPath') . "lib/classes/deprecated/countries.php");

View File

@@ -15,8 +15,9 @@
* @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com * @link www.phraseanet.com
*/ */
require_once __DIR__ . "/../../lib/bootstrap.php"; /* @var $Core \Alchemy\Phrasea\Core */
$appbox = appbox::get_instance(); $Core = require_once __DIR__ . "/../../lib/bootstrap.php";
$appbox = appbox::get_instance($Core);
$session = $appbox->get_session(); $session = $appbox->get_session();
$usr_id = $session->get_usr_id(); $usr_id = $session->get_usr_id();

View File

@@ -15,8 +15,9 @@
* @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com * @link www.phraseanet.com
*/ */
require_once __DIR__ . "/../../lib/bootstrap.php"; /* @var $Core \Alchemy\Phrasea\Core */
$appbox = appbox::get_instance(); $Core = require_once __DIR__ . "/../../lib/bootstrap.php";
$appbox = appbox::get_instance($Core);
$session = $appbox->get_session(); $session = $appbox->get_session();
phrasea::headers(); phrasea::headers();

View File

@@ -14,9 +14,10 @@
* @package * @package
* @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com * @link www.phraseanet.com
*/
require_once __DIR__ . "/../../lib/bootstrap.php"; /* @var $Core \Alchemy\Phrasea\Core */
$appbox = appbox::get_instance(); $Core = require_once __DIR__ . "/../../lib/bootstrap.php";
$appbox = appbox::get_instance($Core);
$session = $appbox->get_session(); $session = $appbox->get_session();
$request = http_request::getInstance(); $request = http_request::getInstance();

View File

@@ -15,9 +15,9 @@
* @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com * @link www.phraseanet.com
*/ */
require_once __DIR__ . "/../../lib/bootstrap.php"; /* @var $Core \Alchemy\Phrasea\Core */
$Core = require_once __DIR__ . "/../../lib/bootstrap.php";
$appbox = appbox::get_instance(); $appbox = appbox::get_instance($Core);
$session = $appbox->get_session(); $session = $appbox->get_session();
$registry = $appbox->get_registry(); $registry = $appbox->get_registry();
$request = http_request::getInstance(); $request = http_request::getInstance();

View File

@@ -15,8 +15,9 @@
* @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com * @link www.phraseanet.com
*/ */
require_once __DIR__ . "/../../lib/bootstrap.php"; /* @var $Core \Alchemy\Phrasea\Core */
$appbox = appbox::get_instance(); $Core = require_once __DIR__ . "/../../lib/bootstrap.php";
$appbox = appbox::get_instance($Core);
$session = $appbox->get_session(); $session = $appbox->get_session();
?> ?>
<style type="text/css"> <style type="text/css">

View File

@@ -15,8 +15,9 @@
* @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com * @link www.phraseanet.com
*/ */
require_once __DIR__ . "/../../lib/bootstrap.php"; /* @var $Core \Alchemy\Phrasea\Core */
$appbox = appbox::get_instance(); $Core = require_once __DIR__ . "/../../lib/bootstrap.php";
$appbox = appbox::get_instance($Core);
$session = $appbox->get_session(); $session = $appbox->get_session();
$request = http_request::getInstance(); $request = http_request::getInstance();

View File

@@ -15,9 +15,9 @@
* @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com * @link www.phraseanet.com
*/ */
require_once __DIR__ . "/../../lib/bootstrap.php"; /* @var $Core \Alchemy\Phrasea\Core */
$Core = require_once __DIR__ . "/../../lib/bootstrap.php";
$appbox = appbox::get_instance(); $appbox = appbox::get_instance($Core);
$session = $appbox->get_session(); $session = $appbox->get_session();
$registry = $appbox->get_registry(); $registry = $appbox->get_registry();
@@ -37,15 +37,11 @@ if (!$user->is_admin())
$cache_flushed = false; $cache_flushed = false;
if ($parm['flush_cache'] && $registry->get('GV_cache_server_type') !== 'nocache') if ($parm['flush_cache'])
{ {
$cache = $appbox->get_cache()->flush(); $Core = \bootstrap::getCore();
$Core['CacheService']->flushAll();
if ($cache->ping())
{
if ($cache->flush() === true)
$cache_flushed = true; $cache_flushed = true;
}
} }
?> ?>
<html lang="<?php echo $session->get_I18n(); ?>"> <html lang="<?php echo $session->get_I18n(); ?>">
@@ -318,11 +314,7 @@ if ($parm['flush_cache'] && $registry->get('GV_cache_server_type') !== 'nocache'
setup::check_cache_opcode(); setup::check_cache_opcode();
setup::check_cache_memcache(); setup::check_cache_memcache();
if ($registry->get('GV_cache_server_type') !== 'nocache') if ($Core->getCache()->isServer())
{
$cache = cache_adapter::get_instance($registry);
if ($cache->ping())
{ {
?> ?>
<form method="post" action="sitestruct.php"> <form method="post" action="sitestruct.php">
@@ -331,7 +323,6 @@ if ($parm['flush_cache'] && $registry->get('GV_cache_server_type') !== 'nocache'
</form> </form>
<?php <?php
} }
}
?> ?>
<?php <?php
setup::check_sphinx_search(); setup::check_sphinx_search();

View File

@@ -15,9 +15,9 @@
* @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com * @link www.phraseanet.com
*/ */
require_once __DIR__ . "/../../lib/bootstrap.php"; /* @var $Core \Alchemy\Phrasea\Core */
$Core = require_once __DIR__ . "/../../lib/bootstrap.php";
$appbox = appbox::get_instance(); $appbox = appbox::get_instance($Core);
$session = $appbox->get_session(); $session = $appbox->get_session();
$request = http_request::getInstance(); $request = http_request::getInstance();

View File

@@ -15,8 +15,9 @@
* @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com * @link www.phraseanet.com
*/ */
require_once __DIR__ . "/../../lib/bootstrap.php"; /* @var $Core \Alchemy\Phrasea\Core */
$appbox = appbox::get_instance(); $Core = require_once __DIR__ . "/../../lib/bootstrap.php";
$appbox = appbox::get_instance($Core);
$session = $appbox->get_session(); $session = $appbox->get_session();
$request = http_request::getInstance(); $request = http_request::getInstance();

View File

@@ -14,8 +14,9 @@
* @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com * @link www.phraseanet.com
*/ */
require_once __DIR__ . "/../../lib/bootstrap.php"; /* @var $Core \Alchemy\Phrasea\Core */
$appbox = appbox::get_instance(); $Core = require_once __DIR__ . "/../../lib/bootstrap.php";
$appbox = appbox::get_instance($Core);
$session = $appbox->get_session(); $session = $appbox->get_session();
$request = http_request::getInstance(); $request = http_request::getInstance();

View File

@@ -14,9 +14,9 @@
* @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com * @link www.phraseanet.com
*/ */
require_once __DIR__ . "/../../lib/bootstrap.php"; /* @var $Core \Alchemy\Phrasea\Core */
$appbox = appbox::get_instance(); $Core = require_once __DIR__ . "/../../lib/bootstrap.php";
$session = $appbox->get_session(); $appbox = appbox::get_instance($Core);
$request = http_request::getInstance(); $request = http_request::getInstance();
$parm = $request->get_parms('act' // NEWTASK or SAVETASK $parm = $request->get_parms('act' // NEWTASK or SAVETASK

View File

@@ -14,9 +14,9 @@
* @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com * @link www.phraseanet.com
*/ */
require_once __DIR__ . "/../../lib/bootstrap.php"; /* @var $Core \Alchemy\Phrasea\Core */
$Core = require_once __DIR__ . "/../../lib/bootstrap.php";
$appbox = appbox::get_instance(); $appbox = appbox::get_instance($Core);
$session = $appbox->get_session(); $session = $appbox->get_session();
$request = http_request::getInstance(); $request = http_request::getInstance();

View File

@@ -14,8 +14,10 @@
* @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com * @link www.phraseanet.com
*/ */
require_once __DIR__ . "/../../lib/bootstrap.php";
$appbox = appbox::get_instance(); /* @var $Core \Alchemy\Phrasea\Core */
$Core = require_once __DIR__ . "/../../lib/bootstrap.php";
$appbox = appbox::get_instance($Core);
$session = $appbox->get_session(); $session = $appbox->get_session();
$request = http_request::getInstance(); $request = http_request::getInstance();