Rev 177 | Blame | Last modification | View Log | RSS feed
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<!-- template designed by Marco Von Ballmoos -->
<title>File Source for Config.php</title>
<meta http-equiv='Content-Type' content='text/html; charset=UTF-8'/>
<link rel="stylesheet" href="../media/stylesheet.css" />
</head>
<body>
<h1>Source for file Config.php</h1>
<p>Documentation is available at <a href="../Framework/_Config.php.html">Config.php</a></p>
<div class="src-code">
<div class="src-code"><ol><li><div class="src-line"><a name="a1"></a><span class="src-php"><?php</span></div></li>
<li><div class="src-line"><a name="a2"></a><span class="src-comm">// declare(encoding='UTF-8');</span></div></li>
<li><div class="src-line"><a name="a3"></a><span class="src-doc">/**</span></div></li>
<li><div class="src-line"><a name="a4"></a><span class="src-doc"> * Config permet de charger automatiquement les fichiers ini du Framework et de l'application.</span></div></li>
<li><div class="src-line"><a name="a5"></a><span class="src-doc"> * Elle offre l'accès en lecture seule aux paramètres de config.</span></div></li>
<li><div class="src-line"><a name="a6"></a><span class="src-doc"> * C'est une Singleton.</span></div></li>
<li><div class="src-line"><a name="a7"></a><span class="src-doc"> *</span></div></li>
<li><div class="src-line"><a name="a8"></a><span class="src-doc"> * PHP Version 5</span></div></li>
<li><div class="src-line"><a name="a9"></a><span class="src-doc"> *</span></div></li>
<li><div class="src-line"><a name="a10"></a><span class="src-doc"> * </span><span class="src-doc-coretag">@category</span><span class="src-doc"> PHP</span></div></li>
<li><div class="src-line"><a name="a11"></a><span class="src-doc"> * </span><span class="src-doc-coretag">@package</span><span class="src-doc"> Framework</span></div></li>
<li><div class="src-line"><a name="a12"></a><span class="src-doc"> * </span><span class="src-doc-coretag">@author</span><span class="src-doc"> Jean-Pascal MILCENT <jpm@tela-botanica.org></span></div></li>
<li><div class="src-line"><a name="a13"></a><span class="src-doc"> * </span><span class="src-doc-coretag">@copyright</span><span class="src-doc"> 2009 Tela-Botanica</span></div></li>
<li><div class="src-line"><a name="a14"></a><span class="src-doc"> * </span><span class="src-doc-coretag">@license</span><span class="src-doc"> GPL-v3 et CECILL-v2</span></div></li>
<li><div class="src-line"><a name="a15"></a><span class="src-doc"> * </span><span class="src-doc-coretag">@version</span><span class="src-doc"> SVN: <svn_id></span></div></li>
<li><div class="src-line"><a name="a16"></a><span class="src-doc"> * </span><span class="src-doc-coretag">@link</span><span class="src-doc"> /doc/framework/</span></div></li>
<li><div class="src-line"><a name="a17"></a><span class="src-doc"> */</span></div></li>
<li><div class="src-line"><a name="a18"></a> </div></li>
<li><div class="src-line"><a name="a19"></a><span class="src-key">class </span><a href="../Framework/Config.html">Config</a> <span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a20"></a> </div></li>
<li><div class="src-line"><a name="a21"></a> <span class="src-doc">/**</span></div></li>
<li><div class="src-line"><a name="a22"></a><span class="src-doc"> * instance de la classe pointant sur elle même (pour le pattern singleton)</span></div></li>
<li><div class="src-line"><a name="a23"></a><span class="src-doc"> */</span></div></li>
<li><div class="src-line"><a name="a24"></a> <span class="src-key">private </span><span class="src-key">static </span><span class="src-var">$instance </span>= <span class="src-id">null</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a25"></a> </div></li>
<li><div class="src-line"><a name="a26"></a> <span class="src-doc">/**</span></div></li>
<li><div class="src-line"><a name="a27"></a><span class="src-doc"> * paramètres de configuration</span></div></li>
<li><div class="src-line"><a name="a28"></a><span class="src-doc"> */</span></div></li>
<li><div class="src-line"><a name="a29"></a> <span class="src-key">private </span><span class="src-key">static </span><span class="src-var">$parametres </span>= <span class="src-key">array</span><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a30"></a> </div></li>
<li><div class="src-line"><a name="a31"></a> <span class="src-doc">/**</span></div></li>
<li><div class="src-line"><a name="a32"></a><span class="src-doc"> * Constructeur vide</span></div></li>
<li><div class="src-line"><a name="a33"></a><span class="src-doc"> */</span></div></li>
<li><div class="src-line"><a name="a34"></a> <span class="src-key">private </span><span class="src-key">function </span><span class="src-id">__construct</span><span class="src-sym">(</span><span class="src-sym">) </span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a35"></a> <span class="src-comm">// Définition de paramètres avant chargement du config.ini</span></div></li>
<li><div class="src-line"><a name="a36"></a> <span class="src-id">self</span><span class="src-sym">::</span><span class="src-var">$parametres </span>= <span class="src-key">array</span><span class="src-sym">(</span></div></li>
<li><div class="src-line"><a name="a37"></a> <span class="src-str">'fw_fichier_config' </span>=> <span class="src-str">'config%s.ini'</span><span class="src-sym">,</span></div></li>
<li><div class="src-line"><a name="a38"></a> <span class="src-str">'fw_chemin' </span>=> <span class="src-id">dirname</span><span class="src-sym">(</span>__FILE__<span class="src-sym">)</span>.<span class="src-id"><a href="../Framework/_autoload.inc.php.html#defineDS">DS</a></span></div></li>
<li><div class="src-line"><a name="a39"></a> <span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a40"></a> </div></li>
<li><div class="src-line"><a name="a41"></a> <span class="src-comm">// Chargement du fichier config.ini du Framework</span></div></li>
<li><div class="src-line"><a name="a42"></a> <span class="src-var">$existe </span>= <span class="src-id">self</span><span class="src-sym">::</span><span class="src-id">parserFichierIni</span><span class="src-sym">(</span><span class="src-id">self</span><span class="src-sym">::</span><span class="src-var">$parametres</span><span class="src-sym">[</span><span class="src-str">'fw_chemin'</span><span class="src-sym">]</span>.<span class="src-id">sprintf</span><span class="src-sym">(</span><span class="src-id">self</span><span class="src-sym">::</span><span class="src-var">$parametres</span><span class="src-sym">[</span><span class="src-str">'fw_fichier_config'</span><span class="src-sym">]</span><span class="src-sym">, </span><span class="src-str">''</span><span class="src-sym">))</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a43"></a> <span class="src-key">if </span><span class="src-sym">(</span><span class="src-var">$existe </span>=== <span class="src-id">false</span><span class="src-sym">) </span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a44"></a> <a href="http://www.php.net/trigger_error">trigger_error</a><span class="src-sym">(</span><span class="src-str">"Veuillez configurer le Framework en renommant le fichier config.defaut.ini en config.ini."</span><span class="src-sym">, </span><span class="src-id">E_USER_ERROR</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a45"></a> <span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a46"></a> </div></li>
<li><div class="src-line"><a name="a47"></a> <span class="src-comm">// Chargement du fichier config.ini par défaut de l'application</span></div></li>
<li><div class="src-line"><a name="a48"></a> <span class="src-var">$chemin_config_defaut_appli </span>= <span class="src-id">self</span><span class="src-sym">::</span><span class="src-var">$parametres</span><span class="src-sym">[</span><span class="src-str">'chemin_configurations'</span><span class="src-sym">]</span>.<span class="src-id">sprintf</span><span class="src-sym">(</span><span class="src-id">self</span><span class="src-sym">::</span><span class="src-var">$parametres</span><span class="src-sym">[</span><span class="src-str">'fw_fichier_config'</span><span class="src-sym">]</span><span class="src-sym">, </span><span class="src-str">''</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a49"></a> <span class="src-id">self</span><span class="src-sym">::</span><span class="src-id">parserFichierIni</span><span class="src-sym">(</span><span class="src-var">$chemin_config_defaut_appli</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a50"></a> </div></li>
<li><div class="src-line"><a name="a51"></a> <span class="src-comm">// Chargement des fichiers config.ini contextuels</span></div></li>
<li><div class="src-line"><a name="a52"></a> <span class="src-key">if </span><span class="src-sym">(</span><span class="src-id">PHP_SAPI </span>== <span class="src-str">'cli'</span><span class="src-sym">) </span><span class="src-sym">{</span><span class="src-comm">// mode console</span></div></li>
<li><div class="src-line"><a name="a53"></a> <span class="src-key">foreach </span><span class="src-sym">(</span><span class="src-var">$_SERVER</span><span class="src-sym">[</span><span class="src-str">'argv'</span><span class="src-sym">] </span><span class="src-key">as </span><span class="src-var">$cle </span>=> <span class="src-var">$valeur</span><span class="src-sym">) </span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a54"></a> <span class="src-key">if </span><span class="src-sym">(</span><span class="src-var">$valeur </span>== <span class="src-str">'-contexte'</span><span class="src-sym">) </span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a55"></a> <span class="src-id">chargerFichierContexte</span><span class="src-sym">(</span><span class="src-var">$_SERVER</span><span class="src-sym">[</span><span class="src-str">'argv'</span><span class="src-sym">]</span><span class="src-sym">[</span><span class="src-sym">(</span><span class="src-var">$cle</span>+<span class="src-num">1</span><span class="src-sym">)</span><span class="src-sym">]</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a56"></a> <span class="src-key">break</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a57"></a> <span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a58"></a> <span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a59"></a> <span class="src-sym">} </span><span class="src-key">else </span><span class="src-sym">{</span><span class="src-comm">// mode web</span></div></li>
<li><div class="src-line"><a name="a60"></a> <span class="src-comm">// Pour Papyrus</span></div></li>
<li><div class="src-line"><a name="a61"></a> <span class="src-key">if </span><span class="src-sym">(</span><a href="http://www.php.net/defined">defined</a><span class="src-sym">(</span><span class="src-str">'PAP_VERSION'</span><span class="src-sym">)) </span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a62"></a> <span class="src-id">self</span><span class="src-sym">::</span><span class="src-id">chargerFichierContexte</span><span class="src-sym">(</span><span class="src-str">'papyrus'</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a63"></a> <span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a64"></a> <span class="src-comm">// Via le fichie .ini par défaut de l'appli</span></div></li>
<li><div class="src-line"><a name="a65"></a> <span class="src-key">if </span><span class="src-sym">(</span><span class="src-id"><a href="../Framework/Config.html">Config</a></span><span class="src-sym">::</span><span class="src-id">existeValeur</span><span class="src-sym">(</span><span class="src-str">'info.contexte'</span><span class="src-sym">, </span><span class="src-id">self</span><span class="src-sym">::</span><span class="src-var">$parametres</span><span class="src-sym">)) </span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a66"></a> <span class="src-id">self</span><span class="src-sym">::</span><span class="src-id">chargerFichierContexte</span><span class="src-sym">(</span><span class="src-id"><a href="../Framework/Config.html">Config</a></span><span class="src-sym">::</span><a href="../Framework/Config.html#methodget">get</a><span class="src-sym">(</span><span class="src-str">'info.contexte'</span><span class="src-sym">))</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a67"></a> <span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a68"></a> </div></li>
<li><div class="src-line"><a name="a69"></a> <span class="src-comm">// Chargement du contexte présent dans le GET</span></div></li>
<li><div class="src-line"><a name="a70"></a> <span class="src-key">if </span><span class="src-sym">(</span>isset<span class="src-sym">(</span><span class="src-var">$_GET</span><span class="src-sym">[</span><span class="src-str">'contexte'</span><span class="src-sym">]</span><span class="src-sym">)) </span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a71"></a> <span class="src-id">self</span><span class="src-sym">::</span><span class="src-id">chargerFichierContexte</span><span class="src-sym">(</span><span class="src-var">$_GET</span><span class="src-sym">[</span><span class="src-str">'contexte'</span><span class="src-sym">]</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a72"></a> <span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a73"></a> </div></li>
<li><div class="src-line"><a name="a74"></a> <span class="src-comm">// Chargement du contexte présent dans le POST</span></div></li>
<li><div class="src-line"><a name="a75"></a> <span class="src-key">if </span><span class="src-sym">(</span>isset<span class="src-sym">(</span><span class="src-var">$_POST</span><span class="src-sym">[</span><span class="src-str">'contexte'</span><span class="src-sym">]</span><span class="src-sym">)) </span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a76"></a> <span class="src-id">self</span><span class="src-sym">::</span><span class="src-id">chargerFichierContexte</span><span class="src-sym">(</span><span class="src-var">$_POST</span><span class="src-sym">[</span><span class="src-str">'contexte'</span><span class="src-sym">]</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a77"></a> <span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a78"></a> <span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a79"></a> <span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a80"></a> </div></li>
<li><div class="src-line"><a name="a81"></a> <span class="src-doc">/**</span></div></li>
<li><div class="src-line"><a name="a82"></a><span class="src-doc"> * Charge le fichier de config correspondant au contexte</span></div></li>
<li><div class="src-line"><a name="a83"></a><span class="src-doc"> * </span><span class="src-doc-coretag">@param </span><span class="src-doc-type">string </span><span class="src-doc-var">$contexte </span><span class="src-doc">le contexte</span></div></li>
<li><div class="src-line"><a name="a84"></a><span class="src-doc"> */</span></div></li>
<li><div class="src-line"><a name="a85"></a> <span class="src-key">private </span><span class="src-key">static </span><span class="src-key">function </span><span class="src-id">chargerFichierContexte</span><span class="src-sym">(</span><span class="src-var">$contexte</span><span class="src-sym">) </span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a86"></a> <span class="src-var">$chemin_config_appli_contextuel </span>= <span class="src-id">self</span><span class="src-sym">::</span><span class="src-var">$parametres</span><span class="src-sym">[</span><span class="src-str">'chemin_configurations'</span><span class="src-sym">]</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a87"></a> <span class="src-var">$chemin_config_appli_contextuel </span>.= <span class="src-id">sprintf</span><span class="src-sym">(</span><span class="src-id">self</span><span class="src-sym">::</span><span class="src-var">$parametres</span><span class="src-sym">[</span><span class="src-str">'fw_fichier_config'</span><span class="src-sym">]</span><span class="src-sym">, </span><span class="src-str">'_'</span>.<span class="src-var">$contexte</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a88"></a> <span class="src-id">self</span><span class="src-sym">::</span><span class="src-id">parserFichierIni</span><span class="src-sym">(</span><span class="src-var">$chemin_config_appli_contextuel</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a89"></a> <span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a90"></a> </div></li>
<li><div class="src-line"><a name="a91"></a> <span class="src-doc">/**</span></div></li>
<li><div class="src-line"><a name="a92"></a><span class="src-doc"> * Parse le fichier ini donné en paramètre</span></div></li>
<li><div class="src-line"><a name="a93"></a><span class="src-doc"> * </span><span class="src-doc-coretag">@param </span><span class="src-doc-type">string </span><span class="src-doc-var">$fichier_ini </span><span class="src-doc">nom du fichier ini à parser</span></div></li>
<li><div class="src-line"><a name="a94"></a><span class="src-doc"> * </span><span class="src-doc-coretag">@return </span><span class="src-doc-type">array </span><span class="src-doc">tableau contenant les paramètres du fichier ini</span></div></li>
<li><div class="src-line"><a name="a95"></a><span class="src-doc"> */</span></div></li>
<li><div class="src-line"><a name="a96"></a> <span class="src-key">private </span><span class="src-key">static </span><span class="src-key">function </span><span class="src-id">parserFichierIni</span><span class="src-sym">(</span><span class="src-var">$fichier_ini</span><span class="src-sym">) </span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a97"></a> <span class="src-var">$retour </span>= <span class="src-id">false</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a98"></a> <span class="src-key">if </span><span class="src-sym">(</span><a href="http://www.php.net/file_exists">file_exists</a><span class="src-sym">(</span><span class="src-var">$fichier_ini</span><span class="src-sym">)) </span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a99"></a> <span class="src-var">$ini </span>= <a href="http://www.php.net/parse_ini_file">parse_ini_file</a><span class="src-sym">(</span><span class="src-var">$fichier_ini</span><span class="src-sym">, </span><span class="src-id">true</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a100"></a> <span class="src-var">$ini </span>= <span class="src-id">self</span><span class="src-sym">::</span><span class="src-id">analyserTableauIni</span><span class="src-sym">(</span><span class="src-var">$ini</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a101"></a> <span class="src-id">self</span><span class="src-sym">::</span><span class="src-id">fusionner</span><span class="src-sym">(</span><span class="src-var">$ini</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a102"></a> <span class="src-var">$retour </span>= <span class="src-id">true</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a103"></a> <span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a104"></a> <span class="src-key">return </span><span class="src-var">$retour</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a105"></a> <span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a106"></a> </div></li>
<li><div class="src-line"><a name="a107"></a> <span class="src-doc">/**</span></div></li>
<li><div class="src-line"><a name="a108"></a><span class="src-doc"> * fusionne un tableau de paramètres avec le tableau de paramètres global</span></div></li>
<li><div class="src-line"><a name="a109"></a><span class="src-doc"> * </span><span class="src-doc-coretag">@param </span><span class="src-doc-type">array </span><span class="src-doc-var">$ini </span><span class="src-doc">le tableau à fusionner</span></div></li>
<li><div class="src-line"><a name="a110"></a><span class="src-doc"> */</span></div></li>
<li><div class="src-line"><a name="a111"></a> <span class="src-key">private </span><span class="src-key">static </span><span class="src-key">function </span><span class="src-id">fusionner</span><span class="src-sym">(</span><span class="src-key">array </span><span class="src-var">$ini</span><span class="src-sym">) </span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a112"></a> <span class="src-id">self</span><span class="src-sym">::</span><span class="src-var">$parametres </span>= <span class="src-id">array_merge</span><span class="src-sym">(</span><span class="src-id">self</span><span class="src-sym">::</span><span class="src-var">$parametres</span><span class="src-sym">, </span><span class="src-var">$ini</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a113"></a> <span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a114"></a> </div></li>
<li><div class="src-line"><a name="a115"></a> <span class="src-doc">/**</span></div></li>
<li><div class="src-line"><a name="a116"></a><span class="src-doc"> * renvoie la valeur demandé grâce une chaine de paramètres</span></div></li>
<li><div class="src-line"><a name="a117"></a><span class="src-doc"> * </span><span class="src-doc-coretag">@param </span><span class="src-doc-type">string </span><span class="src-doc-var">$param </span><span class="src-doc">la chaine de paramètres</span></div></li>
<li><div class="src-line"><a name="a118"></a><span class="src-doc"> * </span><span class="src-doc-coretag">@param </span><span class="src-doc-type">array </span><span class="src-doc-var">$config </span><span class="src-doc">le tableau de paramètre</span></div></li>
<li><div class="src-line"><a name="a119"></a><span class="src-doc"> * </span><span class="src-doc-coretag">@return </span><span class="src-doc-type">string </span><span class="src-doc">la valeur de la chaine demandée</span></div></li>
<li><div class="src-line"><a name="a120"></a><span class="src-doc"> */</span></div></li>
<li><div class="src-line"><a name="a121"></a> <span class="src-key">private </span><span class="src-key">static </span><span class="src-key">function </span><span class="src-id">getValeur</span><span class="src-sym">(</span><span class="src-var">$param</span><span class="src-sym">, </span><span class="src-var">$config</span><span class="src-sym">) </span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a122"></a> <span class="src-key">if </span><span class="src-sym">(</span><span class="src-var">$param </span>=== <span class="src-id">null</span><span class="src-sym">) </span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a123"></a> <span class="src-key">return </span><span class="src-id">null</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a124"></a> <span class="src-sym">} </span><span class="src-key">else </span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a125"></a> <span class="src-key">if </span><span class="src-sym">(</span><a href="http://www.php.net/strpos">strpos</a><span class="src-sym">(</span><span class="src-var">$param</span><span class="src-sym">, </span><span class="src-str">'.'</span><span class="src-sym">) </span>!== <span class="src-id">false</span><span class="src-sym">) </span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a126"></a> <span class="src-var">$pieces </span>= <a href="http://www.php.net/explode">explode</a><span class="src-sym">(</span><span class="src-str">'.'</span><span class="src-sym">, </span><span class="src-var">$param</span><span class="src-sym">, </span><span class="src-num">2</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a127"></a> <span class="src-key">if </span><span class="src-sym">(</span><a href="http://www.php.net/strlen">strlen</a><span class="src-sym">(</span><span class="src-var">$pieces</span><span class="src-sym">[</span><span class="src-num">0</span><span class="src-sym">]</span><span class="src-sym">) </span>&& <a href="http://www.php.net/strlen">strlen</a><span class="src-sym">(</span><span class="src-var">$pieces</span><span class="src-sym">[</span><span class="src-num">1</span><span class="src-sym">]</span><span class="src-sym">)) </span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a128"></a> <span class="src-key">if </span><span class="src-sym">(</span>isset<span class="src-sym">(</span><span class="src-var">$config</span><span class="src-sym">[</span><span class="src-var">$pieces</span><span class="src-sym">[</span><span class="src-num">0</span><span class="src-sym">]]</span><span class="src-sym">)) </span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a129"></a> <span class="src-key">if </span><span class="src-sym">(</span><a href="http://www.php.net/is_array">is_array</a><span class="src-sym">(</span><span class="src-var">$config</span><span class="src-sym">[</span><span class="src-var">$pieces</span><span class="src-sym">[</span><span class="src-num">0</span><span class="src-sym">]]</span><span class="src-sym">)) </span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a130"></a> <span class="src-key">return </span><span class="src-id">self</span><span class="src-sym">::</span><span class="src-id">getValeur</span><span class="src-sym">(</span><span class="src-var">$pieces</span><span class="src-sym">[</span><span class="src-num">1</span><span class="src-sym">]</span><span class="src-sym">, </span><span class="src-var">$config</span><span class="src-sym">[</span><span class="src-var">$pieces</span><span class="src-sym">[</span><span class="src-num">0</span><span class="src-sym">]]</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a131"></a> <span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a132"></a> <span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a133"></a> <span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a134"></a> <span class="src-sym">} </span><span class="src-key">else </span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a135"></a> <span class="src-key">if </span><span class="src-sym">(</span>isset<span class="src-sym">(</span><span class="src-var">$config</span><span class="src-sym">[</span><span class="src-var">$param</span><span class="src-sym">]</span><span class="src-sym">)) </span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a136"></a> <span class="src-key">return </span><span class="src-var">$config</span><span class="src-sym">[</span><span class="src-var">$param</span><span class="src-sym">]</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a137"></a> <span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a138"></a> <span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a139"></a> <span class="src-key">return </span><span class="src-id">null</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a140"></a> <span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a141"></a> <span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a142"></a> </div></li>
<li><div class="src-line"><a name="a143"></a> <span class="src-doc">/**</span></div></li>
<li><div class="src-line"><a name="a144"></a><span class="src-doc"> * Teste si param existe dans le tableau config</span></div></li>
<li><div class="src-line"><a name="a145"></a><span class="src-doc"> * </span><span class="src-doc-coretag">@param </span><span class="src-doc-type">string </span><span class="src-doc-var">$param </span><span class="src-doc">nom du paramètre</span></div></li>
<li><div class="src-line"><a name="a146"></a><span class="src-doc"> * </span><span class="src-doc-coretag">@param </span><span class="src-doc-type">array </span><span class="src-doc">tableau de configuration</span></div></li>
<li><div class="src-line"><a name="a147"></a><span class="src-doc"> */</span></div></li>
<li><div class="src-line"><a name="a148"></a> <span class="src-key">private </span><span class="src-key">static </span><span class="src-key">function </span><span class="src-id">existeValeur</span><span class="src-sym">(</span><span class="src-var">$param</span><span class="src-sym">, </span><span class="src-var">$config</span><span class="src-sym">) </span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a149"></a> <span class="src-var">$retour </span>= <span class="src-id">false</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a150"></a> <span class="src-key">if </span><span class="src-sym">(</span><span class="src-id">self</span><span class="src-sym">::</span><span class="src-id">getValeur</span><span class="src-sym">(</span><span class="src-var">$param</span><span class="src-sym">, </span><span class="src-var">$config</span><span class="src-sym">) </span>!== <span class="src-id">null</span><span class="src-sym">) </span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a151"></a> <span class="src-var">$retour </span>= <span class="src-id">true</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a152"></a> <span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a153"></a> <span class="src-key">return </span><span class="src-var">$retour</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a154"></a> <span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a155"></a> </div></li>
<li><div class="src-line"><a name="a156"></a> <span class="src-doc">/**</span></div></li>
<li><div class="src-line"><a name="a157"></a><span class="src-doc"> * Vérifie si l'instance de classe à été crée, si non la crée</span></div></li>
<li><div class="src-line"><a name="a158"></a><span class="src-doc"> */</span></div></li>
<li><div class="src-line"><a name="a159"></a> <span class="src-key">private </span><span class="src-key">static </span><span class="src-key">function </span><span class="src-id">verifierCreationInstance</span><span class="src-sym">(</span><span class="src-sym">) </span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a160"></a> <span class="src-key">if </span><span class="src-sym">(</span><span class="src-key">empty</span><span class="src-sym">(</span><span class="src-id">self</span><span class="src-sym">::</span><span class="src-var">$instance</span><span class="src-sym">)) </span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a161"></a> <span class="src-id">self</span><span class="src-sym">::</span><span class="src-var">$instance </span>= <span class="src-key">new </span><span class="src-id">Config</span><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a162"></a> <span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a163"></a> <span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a164"></a> </div></li>
<li><div class="src-line"><a name="a165"></a> <span class="src-doc">/**</span></div></li>
<li><div class="src-line"><a name="a166"></a><span class="src-doc"> * analyse un tableau de paramètres</span></div></li>
<li><div class="src-line"><a name="a167"></a><span class="src-doc"> * </span><span class="src-doc-coretag">@param </span><span class="src-doc-type">array </span><span class="src-doc-var">$config </span><span class="src-doc">le tableau de paramètres</span></div></li>
<li><div class="src-line"><a name="a168"></a><span class="src-doc"> * </span><span class="src-doc-coretag">@return </span><span class="src-doc-type">array </span><span class="src-doc">le tableau analysé</span></div></li>
<li><div class="src-line"><a name="a169"></a><span class="src-doc"> */</span></div></li>
<li><div class="src-line"><a name="a170"></a> <span class="src-key">private </span><span class="src-key">static </span><span class="src-key">function </span><span class="src-id">analyserTableauIni</span><span class="src-sym">(</span><span class="src-var">$config </span>= <span class="src-key">array</span><span class="src-sym">(</span><span class="src-sym">)) </span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a171"></a> <span class="src-key">foreach </span><span class="src-sym">(</span><span class="src-var">$config </span><span class="src-key">as </span><span class="src-var">$cle </span>=> <span class="src-var">$valeur</span><span class="src-sym">) </span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a172"></a> <span class="src-key">if </span><span class="src-sym">(</span><a href="http://www.php.net/is_array">is_array</a><span class="src-sym">(</span><span class="src-var">$valeur</span><span class="src-sym">)) </span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a173"></a> <span class="src-var">$config</span><span class="src-sym">[</span><span class="src-var">$cle</span><span class="src-sym">] </span>= <span class="src-id">self</span><span class="src-sym">::</span><span class="src-id">analyserTableauIni</span><span class="src-sym">(</span><span class="src-var">$valeur</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a174"></a> <span class="src-sym">} </span><span class="src-key">else </span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a175"></a> <span class="src-id">self</span><span class="src-sym">::</span><span class="src-id">evaluerReferences</span><span class="src-sym">(</span><span class="src-var">$config</span><span class="src-sym">, </span><span class="src-var">$cle</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a176"></a> <span class="src-id">self</span><span class="src-sym">::</span><span class="src-id">evaluerPhp</span><span class="src-sym">(</span><span class="src-var">$config</span><span class="src-sym">, </span><span class="src-var">$cle</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a177"></a> <span class="src-id">self</span><span class="src-sym">::</span><span class="src-id">evaluerCle</span><span class="src-sym">(</span><span class="src-var">$config</span><span class="src-sym">, </span><span class="src-var">$cle</span><span class="src-sym">, </span><span class="src-var">$config</span><span class="src-sym">[</span><span class="src-var">$cle</span><span class="src-sym">]</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a178"></a> <span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a179"></a> <span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a180"></a> <span class="src-key">return </span><span class="src-var">$config</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a181"></a> <span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a182"></a> </div></li>
<li><div class="src-line"><a name="a183"></a> <span class="src-doc">/**</span></div></li>
<li><div class="src-line"><a name="a184"></a><span class="src-doc"> * dans le cas des chaine de configuration à sous clé (ex.: cle.souscle)</span></div></li>
<li><div class="src-line"><a name="a185"></a><span class="src-doc"> * evalue les valeurs correspondantes et crée les sous tableaux associés</span></div></li>
<li><div class="src-line"><a name="a186"></a><span class="src-doc"> * </span><span class="src-doc-coretag">@param </span><span class="src-doc-type">array </span><span class="src-doc-var">$config </span><span class="src-doc">tableau de configuration (par référence)</span></div></li>
<li><div class="src-line"><a name="a187"></a><span class="src-doc"> * </span><span class="src-doc-coretag">@param </span><span class="src-doc-type">string </span><span class="src-doc-var">$cle </span><span class="src-doc">la cle dans le tableau</span></div></li>
<li><div class="src-line"><a name="a188"></a><span class="src-doc"> * </span><span class="src-doc-coretag">@param </span><span class="src-doc-type">string </span><span class="src-doc-var">$valeur </span><span class="src-doc">la valeur à affecter</span></div></li>
<li><div class="src-line"><a name="a189"></a><span class="src-doc"> */</span></div></li>
<li><div class="src-line"><a name="a190"></a> <span class="src-key">private </span><span class="src-key">static </span><span class="src-key">function </span><span class="src-id">evaluerCle</span><span class="src-sym">(</span><span class="src-sym">&</span><span class="src-var">$config</span><span class="src-sym">, </span><span class="src-var">$cle</span><span class="src-sym">, </span><span class="src-var">$valeur</span><span class="src-sym">) </span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a191"></a> <span class="src-key">if </span><span class="src-sym">(</span><a href="http://www.php.net/strpos">strpos</a><span class="src-sym">(</span><span class="src-var">$cle</span><span class="src-sym">, </span><span class="src-str">'.'</span><span class="src-sym">) </span>!== <span class="src-id">false</span><span class="src-sym">) </span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a192"></a> unset<span class="src-sym">(</span><span class="src-var">$config</span><span class="src-sym">[</span><span class="src-var">$cle</span><span class="src-sym">]</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a193"></a> <span class="src-var">$pieces </span>= <a href="http://www.php.net/explode">explode</a><span class="src-sym">(</span><span class="src-str">'.'</span><span class="src-sym">, </span><span class="src-var">$cle</span><span class="src-sym">, </span><span class="src-num">2</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a194"></a> <span class="src-key">if </span><span class="src-sym">(</span><a href="http://www.php.net/strlen">strlen</a><span class="src-sym">(</span><span class="src-var">$pieces</span><span class="src-sym">[</span><span class="src-num">0</span><span class="src-sym">]</span><span class="src-sym">) </span>&& <a href="http://www.php.net/strlen">strlen</a><span class="src-sym">(</span><span class="src-var">$pieces</span><span class="src-sym">[</span><span class="src-num">1</span><span class="src-sym">]</span><span class="src-sym">)) </span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a195"></a> <span class="src-key">if </span><span class="src-sym">(</span><span class="src-sym">!</span>isset<span class="src-sym">(</span><span class="src-var">$config</span><span class="src-sym">[</span><span class="src-var">$pieces</span><span class="src-sym">[</span><span class="src-num">0</span><span class="src-sym">]]</span><span class="src-sym">)) </span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a196"></a> <span class="src-key">if </span><span class="src-sym">(</span><span class="src-var">$pieces</span><span class="src-sym">[</span><span class="src-num">0</span><span class="src-sym">] </span>=== <span class="src-str">'0' </span>&& <span class="src-sym">!</span><span class="src-key">empty</span><span class="src-sym">(</span><span class="src-var">$config</span><span class="src-sym">)) </span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a197"></a> <span class="src-comm">// convert the current values in $config into an array</span></div></li>
<li><div class="src-line"><a name="a198"></a> <span class="src-var">$config </span>= <span class="src-key">array</span><span class="src-sym">(</span><span class="src-var">$pieces</span><span class="src-sym">[</span><span class="src-num">0</span><span class="src-sym">] </span>=> <span class="src-var">$config</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a199"></a> <span class="src-sym">} </span><span class="src-key">else </span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a200"></a> <span class="src-var">$config</span><span class="src-sym">[</span><span class="src-var">$pieces</span><span class="src-sym">[</span><span class="src-num">0</span><span class="src-sym">]] </span>= <span class="src-key">array</span><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a201"></a> <span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a202"></a> <span class="src-sym">} </span><span class="src-key">elseif </span><span class="src-sym">(</span><span class="src-sym">!</span><a href="http://www.php.net/is_array">is_array</a><span class="src-sym">(</span><span class="src-var">$config</span><span class="src-sym">[</span><span class="src-var">$pieces</span><span class="src-sym">[</span><span class="src-num">0</span><span class="src-sym">]]</span><span class="src-sym">)) </span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a203"></a> throw <span class="src-key">new </span><span class="src-id">ErrorException</span><span class="src-sym">(</span><span class="src-str">"</span><span class="src-str">Ne peut pas créer de sous-clé pour '{<span class="src-var">$pieces</span><span class="src-sym">[</span><span class="src-num">0</span><span class="src-sym">]</span><span class="src-sym">}</span>' car la clé existe déjà</span><span class="src-str">"</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a204"></a> <span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a205"></a> <span class="src-var">$config</span><span class="src-sym">[</span><span class="src-var">$pieces</span><span class="src-sym">[</span><span class="src-num">0</span><span class="src-sym">]] </span>= <span class="src-id">self</span><span class="src-sym">::</span><span class="src-id">evaluerCle</span><span class="src-sym">(</span><span class="src-var">$config</span><span class="src-sym">[</span><span class="src-var">$pieces</span><span class="src-sym">[</span><span class="src-num">0</span><span class="src-sym">]]</span><span class="src-sym">, </span><span class="src-var">$pieces</span><span class="src-sym">[</span><span class="src-num">1</span><span class="src-sym">]</span><span class="src-sym">, </span><span class="src-var">$valeur</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a206"></a> <span class="src-sym">} </span><span class="src-key">else </span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a207"></a> throw <span class="src-key">new </span><span class="src-id">ErrorException</span><span class="src-sym">(</span><span class="src-str">"</span><span class="src-str">Clé invalide '<span class="src-var">$cle</span>'</span><span class="src-str">"</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a208"></a> <span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a209"></a> <span class="src-sym">} </span><span class="src-key">else </span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a210"></a> <span class="src-var">$config</span><span class="src-sym">[</span><span class="src-var">$cle</span><span class="src-sym">] </span>= <span class="src-var">$valeur</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a211"></a> <span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a212"></a> <span class="src-key">return </span><span class="src-var">$config</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a213"></a> <span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a214"></a> </div></li>
<li><div class="src-line"><a name="a215"></a> <span class="src-doc">/**</span></div></li>
<li><div class="src-line"><a name="a216"></a><span class="src-doc"> * Evalue les valeurs de références à une clé dans le tableau config (cas du ref:cle)</span></div></li>
<li><div class="src-line"><a name="a217"></a><span class="src-doc"> * </span><span class="src-doc-coretag">@param </span><span class="src-doc-type">array </span><span class="src-doc-var">$config </span><span class="src-doc">tableau de configuration</span></div></li>
<li><div class="src-line"><a name="a218"></a><span class="src-doc"> * </span><span class="src-doc-coretag">@param </span><span class="src-doc-type">string </span><span class="src-doc-var">$cle </span><span class="src-doc">la clé dont il faut évaluer les références</span></div></li>
<li><div class="src-line"><a name="a219"></a><span class="src-doc"> */</span></div></li>
<li><div class="src-line"><a name="a220"></a> <span class="src-key">private </span><span class="src-key">static </span><span class="src-key">function </span><span class="src-id">evaluerReferences</span><span class="src-sym">(</span><span class="src-sym">&</span><span class="src-var">$config</span><span class="src-sym">, </span><span class="src-var">$cle</span><span class="src-sym">) </span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a221"></a> <span class="src-key">if </span><span class="src-sym">(</span><a href="http://www.php.net/preg_match_all">preg_match_all</a><span class="src-sym">(</span><span class="src-str">'/{ref:([A-Za-z0-9_-]+)}/'</span><span class="src-sym">, </span><span class="src-var">$config</span><span class="src-sym">[</span><span class="src-var">$cle</span><span class="src-sym">]</span><span class="src-sym">, </span><span class="src-var">$correspondances</span><span class="src-sym">, </span><span class="src-id">PREG_SET_ORDER</span><span class="src-sym">)) </span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a222"></a> <span class="src-key">foreach </span><span class="src-sym">(</span><span class="src-var">$correspondances </span><span class="src-key">as </span><span class="src-var">$ref</span><span class="src-sym">) </span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a223"></a> <span class="src-var">$config</span><span class="src-sym">[</span><span class="src-var">$cle</span><span class="src-sym">] </span>= <a href="http://www.php.net/str_replace">str_replace</a><span class="src-sym">(</span><span class="src-var">$ref</span><span class="src-sym">[</span><span class="src-num">0</span><span class="src-sym">]</span><span class="src-sym">, </span><span class="src-id">self</span><span class="src-sym">::</span><span class="src-id">getValeur</span><span class="src-sym">(</span><span class="src-var">$ref</span><span class="src-sym">[</span><span class="src-num">1</span><span class="src-sym">]</span><span class="src-sym">, </span><span class="src-var">$config</span><span class="src-sym">)</span><span class="src-sym">, </span><span class="src-var">$config</span><span class="src-sym">[</span><span class="src-var">$cle</span><span
class="src-sym">]</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a224"></a> <span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a225"></a> <span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a226"></a> <span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a227"></a> </div></li>
<li><div class="src-line"><a name="a228"></a> <span class="src-doc">/**</span></div></li>
<li><div class="src-line"><a name="a229"></a><span class="src-doc"> * Evalue le code php contenu dans un clé tu tableau config</span></div></li>
<li><div class="src-line"><a name="a230"></a><span class="src-doc"> * </span><span class="src-doc-coretag">@param </span><span class="src-doc-type">array </span><span class="src-doc-var">$config </span><span class="src-doc">tableau de configuration (par référence)</span></div></li>
<li><div class="src-line"><a name="a231"></a><span class="src-doc"> * </span><span class="src-doc-coretag">@param </span><span class="src-doc-type">string </span><span class="src-doc-var">$cle </span><span class="src-doc">le clé du tableau dont il faut évaluer la valeur</span></div></li>
<li><div class="src-line"><a name="a232"></a><span class="src-doc"> */</span></div></li>
<li><div class="src-line"><a name="a233"></a> <span class="src-key">private </span><span class="src-key">static </span><span class="src-key">function </span><span class="src-id">evaluerPhp</span><span class="src-sym">(</span><span class="src-sym">&</span><span class="src-var">$config</span><span class="src-sym">, </span><span class="src-var">$cle</span><span class="src-sym">) </span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a234"></a> <span class="src-key">if </span><span class="src-sym">(</span><a href="http://www.php.net/preg_match">preg_match</a><span class="src-sym">(</span><span class="src-str">'/^php:(.+)$/'</span><span class="src-sym">, </span><span class="src-var">$config</span><span class="src-sym">[</span><span class="src-var">$cle</span><span class="src-sym">]</span><span class="src-sym">, </span><span class="src-var">$correspondances</span><span class="src-sym">)) </span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a235"></a> eval<span class="src-sym">(</span><span class="src-str">'$config["'</span>.<span class="src-var">$cle</span>.<span class="src-str">'"] = '</span>.<span class="src-var">$correspondances</span><span class="src-sym">[</span><span class="src-num">1</span><span class="src-sym">]</span>.<span class="src-str">';'</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a236"></a> <span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a237"></a> <span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a238"></a> </div></li>
<li><div class="src-line"><a name="a239"></a> <span class="src-doc">/**</span></div></li>
<li><div class="src-line"><a name="a240"></a><span class="src-doc"> * Charge un fichier ini dans le tableau des paramètres de l'appli</span></div></li>
<li><div class="src-line"><a name="a241"></a><span class="src-doc"> * </span><span class="src-doc-coretag">@param </span><span class="src-doc-type">string </span><span class="src-doc-var">$fichier_ini </span><span class="src-doc">le nom du fichier à charger</span></div></li>
<li><div class="src-line"><a name="a242"></a><span class="src-doc"> * </span><span class="src-doc-coretag">@return </span><span class="src-doc-type">array </span><span class="src-doc">le fichier ini parsé</span></div></li>
<li><div class="src-line"><a name="a243"></a><span class="src-doc"> */</span></div></li>
<li><div class="src-line"><a name="a244"></a> <span class="src-key">public </span><span class="src-key">static </span><span class="src-key">function </span><a href="../Framework/Config.html#methodcharger">charger</a><span class="src-sym">(</span><span class="src-var">$fichier_ini</span><span class="src-sym">) </span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a245"></a> <span class="src-id">self</span><span class="src-sym">::</span><span class="src-id">verifierCreationInstance</span><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a246"></a> <span class="src-key">return </span><span class="src-id">self</span><span class="src-sym">::</span><span class="src-id">parserFichierIni</span><span class="src-sym">(</span><span class="src-var">$fichier_ini</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a247"></a> <span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a248"></a> </div></li>
<li><div class="src-line"><a name="a249"></a> <span class="src-doc">/**</span></div></li>
<li><div class="src-line"><a name="a250"></a><span class="src-doc"> * Acesseur pour la valeur d'un paramètre</span></div></li>
<li><div class="src-line"><a name="a251"></a><span class="src-doc"> * </span><span class="src-doc-coretag">@param </span><span class="src-doc-type">string </span><span class="src-doc-var">$param </span><span class="src-doc">le nom du paramètre</span></div></li>
<li><div class="src-line"><a name="a252"></a><span class="src-doc"> * </span><span class="src-doc-coretag">@return </span><span class="src-doc-type">string </span><span class="src-doc">la valeur du paramètre</span></div></li>
<li><div class="src-line"><a name="a253"></a><span class="src-doc"> */</span></div></li>
<li><div class="src-line"><a name="a254"></a> <span class="src-key">public </span><span class="src-key">static </span><span class="src-key">function </span><a href="../Framework/Config.html#methodget">get</a><span class="src-sym">(</span><span class="src-var">$param </span>= <span class="src-id">null</span><span class="src-sym">) </span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a255"></a> <span class="src-id">self</span><span class="src-sym">::</span><span class="src-id">verifierCreationInstance</span><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a256"></a> <span class="src-key">return </span><span class="src-id">self</span><span class="src-sym">::</span><span class="src-id">getValeur</span><span class="src-sym">(</span><span class="src-var">$param</span><span class="src-sym">, </span><span class="src-id">self</span><span class="src-sym">::</span><span class="src-var">$parametres</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a257"></a> <span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a258"></a> </div></li>
<li><div class="src-line"><a name="a259"></a> <span class="src-doc">/**</span></div></li>
<li><div class="src-line"><a name="a260"></a><span class="src-doc"> * Vérifie si la valeur d'un paramètre existe</span></div></li>
<li><div class="src-line"><a name="a261"></a><span class="src-doc"> * </span><span class="src-doc-coretag">@param </span><span class="src-doc-type">string </span><span class="src-doc-var">$param </span><span class="src-doc">le nom du paramètre</span></div></li>
<li><div class="src-line"><a name="a262"></a><span class="src-doc"> * </span><span class="src-doc-coretag">@return </span><span class="src-doc-type">boolean </span><span class="src-doc">vrai si le paramètre existe, false sinon</span></div></li>
<li><div class="src-line"><a name="a263"></a><span class="src-doc"> */</span></div></li>
<li><div class="src-line"><a name="a264"></a> <span class="src-key">public </span><span class="src-key">static </span><span class="src-key">function </span><span class="src-id">existe</span><span class="src-sym">(</span><span class="src-var">$param</span><span class="src-sym">) </span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a265"></a> <span class="src-id">self</span><span class="src-sym">::</span><span class="src-id">verifierCreationInstance</span><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a266"></a> <span class="src-key">return </span><span class="src-id">self</span><span class="src-sym">::</span><span class="src-id">existeValeur</span><span class="src-sym">(</span><span class="src-var">$param</span><span class="src-sym">, </span><span class="src-id">self</span><span class="src-sym">::</span><span class="src-var">$parametres</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a267"></a> <span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a268"></a><span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a269"></a><span class="src-php">?></span></div></li>
</ol></div>
</div>
<p class="notes" id="credit">
Documentation generated on Thu, 04 Mar 2010 19:27:16 +0100 by <a href="http://www.phpdoc.org" target="_blank">phpDocumentor 1.4.3</a>
</p>
</body>
</html>