Skip to content
Snippets Groups Projects
bootstrap_db.php 3.4 KiB
Newer Older
<?php
/**
 * Copyright (c) 2012, Agence Française Informatique (AFI). All rights reserved.
 *
 * BOKEH is free software; you can redistribute it and/or modify
 * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
 * the Free Software Foundation.
 *
 * There are special exceptions to the terms and conditions of the AGPL as it
 * is applied to this software (see README file).
 *
 * BOKEH is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
 *
 * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
 * along with BOKEH; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
 */

Ghislain Loas's avatar
Ghislain Loas committed
chdir(realpath(__DIR__) . '/../');
Sebastien ANDRE's avatar
Sebastien ANDRE committed
error_reporting(E_ALL);
ini_set('display_startup_errors', 1);
ini_set('display_errors', 1);
ini_set('memory_limit', '3072M');
date_default_timezone_set('Europe/Paris');

set_include_path(getcwd() . '/library'
                 . PATH_SEPARATOR . getcwd() . '/library/digital_resources'
                 . PATH_SEPARATOR . getcwd() . '/library/templates'
                 . PATH_SEPARATOR . getcwd() . '/library/Class'
                 . PATH_SEPARATOR . getcwd() . '/library/ZendAfi'
                 . PATH_SEPARATOR . getcwd() . '/library/storm/src'
                 . PATH_SEPARATOR . getcwd() . '/library/storm/tests'
                 . PATH_SEPARATOR . getcwd() . '/library/storm/zf/library'
                 . PATH_SEPARATOR . getcwd() . '/application/modules'
                 . PATH_SEPARATOR . getcwd() . '/tests'
                 . PATH_SEPARATOR . getcwd()
                 . PATH_SEPARATOR . get_include_path());

//echo 'PATHS = ' . get_include_path() . "\n";
// Includes de base
include_once 'local.php';
include_once 'fonctions/fonctions.php';
require_once 'Zend/Loader.php';
require_once 'library/startup.php';

Ghislain Loas's avatar
Ghislain Loas committed
$path = __DIR__;
$parts = explode(DIRECTORY_SEPARATOR, $path);
$parts = array_reverse($parts);

defineConstant('BASE_URL', '/' . $parts[1]);
defineConstant('URL_IMG', BASE_URL . '/public/opac/skins/original/images/');
defineConstant('URL_SHARED_IMG', BASE_URL . '/public/opac/images/');

$_SERVER['SERVER_NAME'] = 'localhost';
$_SERVER['SERVER_PORT'] = '80';
$_SERVER['REMOTE_ADDR'] = '127.0.0.1';
$_SERVER['HTTP_HOST'] = 'localhost';

setupOpac();

Class_ICal_Autoloader::getInstance()->ensureAutoload();

(new Storm_Cache)->getCache()->setOption('caching', true);

$db_cache = Zend_Cache::factory('Core',
                                'File',
                                ['lifetime' => 300 ,
                                 'automatic_serialization' => true],
                                ['cache_dir' => PATH_TEMP]);

Zend_Db_Table_Abstract::setDefaultMetadataCache($db_cache);

Storm_Cache::setSeed('local');

$cfg = new Zend_Config(Zend_Registry::get('cfg')->toArray(), true);
$cfg->amber = new Zend_Config(['deploy' => false]);

Zend_Registry::set('cfg', $cfg);
$translate = Zend_Registry::get('translate');
$translate->addTranslation(LANG_DIR . 'ro.mo', 'ro');
$translate->addTranslation(LANG_DIR . 'en.mo', 'en');
$translate->addTranslation(LANG_DIR . 'es.mo', 'es');
$translate->addTranslation(LANG_DIR . 'fr.mo', 'fr');
$translate->setLocale('fr');

register_shutdown_function(fn() => TestSpeedTrap::printSpeedTrappedTests());