Source for file Config.php
Documentation is available at Config.php
// vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4 fdm=marker encoding=utf8 :
* Pxxo - build self-supported and interoperable Web graphical components
* Copyright (c) 2008, Nicolas Thouvenin
* 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 the author 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 REGENTS 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 REGENTS AND 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.
* @copyright Copyright (c) 2008 Nicolas Thouvenin
* @license http://opensource.org/licenses/bsd-license.php
define('PXXO_ZEND_PATH', realpath(rtrim(dirname(__FILE__
),DIRECTORY_SEPARATOR).
DIRECTORY_SEPARATOR.
'..'.
DIRECTORY_SEPARATOR.
'..'.
DIRECTORY_SEPARATOR.
'ZendFramework'));
$include_path =
ini_get('include_path');
require_once 'Zend/Registry.php';
require_once 'Zend/Locale.php';
* Classe de configuration
* Permet de stocker des parametres de maniere unique.
* tout en les rendant disponnible partout
* @copyright Copyright (c) 2008 Nicolas Thouvenin
* @license http://opensource.org/licenses/bsd-license.php
* Chemin physique de la racine de l'application
* Nom physique (UNIX) de l'application
* Courriel de l'application
* Version de l'application
* Charset de l'application
* Langue par defaut de l'application
* l'URL du serveur de l'application sans le chemin et l'éventuel script terminal
* exemple: http://localhost
* Chemin dans l'URL vers la racine de l'application
* exemple: /monapplication
* URL complete vers la racine de l'application (concaténation de url_host et url_root)
* exemple: http://localhost/monapplication
* Nom du script pointant vers le point d'entré de l'application
* Paramètre GET du point d'entré de l'application
* exemple : action=monaction¶m=bidon
* Filtre appliqué sur url_query permettant de ne conserver que les paramètres du point d'entrée de l'application
* exemple : si les paramètres de l'url sont action=home&article=1&monparam=bidon
* et que url_query_filter vaut /^(action|article)/ (c'est une expression régulière)
* les paramètres conservés dans url_query seront action=home&article=1
* Par défaut on ne laisse passer aucun paramètres dans l'url.
* URL complète du point d'entré de l'application (concaténation de url_base et url_script)
* exemple : http://localhost/monapplication/article3.php?action=monaction¶m=bidon
* Nom de la première classe Pxxo mère de toute les autres
* Tableau contenant les arguments à donner au constructeur de la classe "class_core"
* Préfix communn à toutes les classes Pxxo
* Liste des chemins (genre include_path) pour trouver les classes Pxxo
* Chemin Physique vers le réperoire de cache
* Niveau de debug 0 désactivé, 1 : code HTML non "compressé et report de toutes les erreurs PHP, 2 : active la trace pxxo, 3 : active le profiler
* Le mode Session est-il activé
* Les sessions sont-elle activé automatiquement
* Utilisation ou non du controller
* Nom du theme par defaut pour les objects Pxxo_Pago_Action
* Liste des chemins d'accès aux thèmes
* chemin vers un répertoire physique ou seront généré les resources
* url correspondant à au répertoire physique
* @var string active la modification de Pxxo_Config via des requetes GET ou POST
* @var array liste des variables potentiellement modifiable via des requetes GET ou POST
* @var int Spécifie où les messages d'erreur doivent aller. (cf. http://fr.php.net/error_log)
* @var string La destination dépend du type (cf. http://fr.php.net/error_log)
* @var string Les en-têtes supplémentaires (cf. http://fr.php.net/error_log)
* Vérification de la cohérence des valeurs de la configuration
if (isset
($_REQUEST[$p])) $this->$p =
$_REQUEST[$p];
// Détéction des chemins par défaut
if (empty($this->path) && isset
($_SERVER['SCRIPT_FILENAME']))
if (empty($this->path) && isset
($_SERVER['PHP_SELF']))
if (isset
($_ENV['TMP'])) $this->temp_path =
$_ENV['TMP'];
elseif (isset
($_ENV['TMPDIR'])) $this->temp_path =
$_ENV['TMPDIR'];
elseif (isset
($_ENV['TEMP'])) $this->temp_path =
$_ENV['TEMP'];
$include_path =
ini_get('include_path');
// Les chemins déduits sont-ils des répertoires ? Et pour certain peut-on écrire dedans ?
trigger_error(sprintf('invalid Pxxo_Config parameter : `temp_path`(%s) is not writable by the web server',
trigger_error(sprintf('invalid Pxxo_Config parameter : `cache_path` (%s) is not writable by the web server',
trigger_error(sprintf('invalid Pxxo_Config parameter : `resources_path` (%s) is not writable by the web server',
// Detection et decomposition des elements de l'URI
if (!isset
($this->url_host) && isset
($_SERVER['HTTP_HOST']))
$this->url_host =
'http'.
(!isset
($_SERVER['HTTPS'])||
strtolower($_SERVER['HTTPS'])!=
'on'?
'':
's').
'://'.
(isset
($_SERVER["HTTP_X_FORWARDED_HOST"]) ?
$_SERVER['HTTP_X_FORWARDED_HOST'] :
$_SERVER['HTTP_HOST']);
$this->url_query = isset
($_SERVER['QUERY_STRING']) ?
$_SERVER['QUERY_STRING'] :
'';
// Filtrage des paramètres de l'url
$url_query_tmp =
array();
unset
($url_query_tmp[$key]);
require_once 'PHP/Compat/Function/http_build_query.php'; // for php4 compatibility
// rebuild the modified url
$this->url_query =
''; // when no url_query_filter is defined, do not forward any GET parameters
if (!empty($this->session_path)) {
mkdir($this->session_path);
if (is_dir($this->session_path))
//session_cache_limiter('must-revalidate'); // trop dur d'imposer cela à tout le monde
$this->locale =
new Zend_Locale(Zend_Locale::BROWSER);
* Enregistre la classe courante comme classe de référence
$o =
new ReflectionClass('Pxxo_Config');
$vars =
$o->getProperties();
Zend_Registry::set($var->getName(), $this->{$var->getName()});
* Renvoit un paramètre de la configuration de référence
public static function get($name)
if (Zend_Registry::isRegistered($name)) {
return Zend_Registry::get($name);
* Renvoit un paramètre (non standard) de la configuration de référence
public function __get($name)
return Zend_Registry::get($name);
* Fixe un paramètre de la configuration de référence
public static function set($name, &$value)
return Zend_Registry::set($name, $value);
* Fixe un paramètre (non standard) de la configuration de référence
public function __set($name, $value)
return Zend_Registry::set($name, $value);
Documentation generated on Thu, 13 Mar 2008 22:03:13 +0100 by phpDocumentor 1.4.1