linea21-core
[ class tree: linea21-core ] [ index: linea21-core ] [ all elements ]

Source for file class.config_file.php

Documentation is available at class.config_file.php

  1. <?php
  2. /**
  3.  * @package linea21.core
  4.  * @subpackage config_files
  5.  * @author linea21 <info@linea21.com>
  6.  * @version $id SVN
  7.  * @access public
  8.  * @license http://opensource.org/licenses/gpl-3.0.html
  9.  *  Configuration Management
  10.  */
  11.  
  12. include_once('system/afiles/class.afiles.php');
  13. include_once('../lib/lib_common.php');
  14.  
  15. class config_file {
  16.  
  17.   var $file_release = "define_release"// fichier define_release
  18.   var $file_db = "define_db";  // fichier define_db
  19.   var $section_theme = "theme";  // section theme dans le fichier de configuration define_release
  20.   var $config_path = '../config/';
  21.   var $ini_path = '../config/';
  22.   var $backup_config_path = '../tmp/backup/config/';
  23.   var $authorized_release_sections//sections authorisées dans le fichier release
  24.   var $authorized_db_sections//sections authorisées dans le fichier db
  25.   var $authorized_theme_sections//sections authorisées dans le fichier release
  26.   var $config_extension = ".ini";
  27.   var $php_extension = ".php";
  28.   var $db_params;
  29.   var $release_params;
  30.   var $a_file;
  31.   var $theme_settings='THEME_SETTINGS';
  32.   var $theme_public='THEME_PUBLIC';
  33.   var $theme_list_public='THEME_LIST_PUBLIC';
  34.   var $theme_admin='THEME_ADMIN';
  35.   var $theme_list_admin='THEME_LIST_ADMIN';
  36.   protected $dispatcher = null;
  37.  
  38.   /**
  39.    * config_file::__construct()
  40.    * constructeur de classe
  41.    * @access public
  42.    * @return void 
  43.    */
  44.   function __construct()
  45.   {
  46.     $this->a_file=new afiles;
  47.     $this->authorized_release_sections=$GLOBALS['authorized_release_sections'];
  48.     $this->authorized_db_sections=$GLOBALS['authorized_db_sections'];
  49.     $this->authorized_theme_sections=$GLOBALS['authorized_theme_sections'];
  50.     $this->dispatcher = $GLOBALS['dispatcher'];
  51.  
  52.     //charge les paramètres et les place en constante globale par define
  53.     $this->loadReleaseParams();
  54.     $this->loadDbParams();
  55.   }
  56.  
  57.   /**
  58.    * config_file::setParams()
  59.    * modifie le tableau de cache interne avec le paramètre $content
  60.    * @access public
  61.    * @param string $file_name 
  62.    * @param array $content 
  63.    * @return void 
  64.    */
  65.   function setParams($file_name,$content)
  66.   {
  67.       // Notify the beginning of the current method
  68.       $this->dispatcher->notify(new sfEvent($this'config.set_params'array('filename' => $file_name'content' => $content)));
  69.       
  70.     if($file_name == $this->file_release)$this->setReleaseParams($content);
  71.     else if($file_name == $this->section_theme$this->setThemeParams($content);
  72.     else $this->setDbParams($content);
  73.   }
  74.  
  75.   /**
  76.    * config_file::loadReleaseParams()
  77.    * charge les paramètres dans le tableau $release_params
  78.    * @access public
  79.    * @return void 
  80.    */
  81.   function loadReleaseParams({
  82.       
  83.       // Notify the beginning of the current method
  84.       $this->dispatcher->notify(new sfEvent($this'config.load_release_params'));
  85.       
  86.     //charge les paramètres release dans un tableau $release_params
  87.     $this->release_params=$this->parseConfig($this->file_release);
  88.   }
  89.   /**
  90.    * config_file::loadDbParams()
  91.    * charge les paramètres dans le tableau $db_params
  92.    * @access public
  93.    * @return void 
  94.    */
  95.   function loadDbParams()
  96.   {
  97.       // Notify the beginning of the current method
  98.       $this->dispatcher->notify(new sfEvent($this'config.load_db_params'));
  99.       
  100.     //charge les paramètres dans un tableau $db_params
  101.     $this->db_params=$this->parseConfig($this->file_db);
  102.   }
  103.  
  104.   /**
  105.    * config_file::setReleaseParams()
  106.    * modifie le tableau $release_params avec les entrées du tableau $content
  107.    * @access public
  108.    * @return void 
  109.    * @param array $content 
  110.    */
  111.   function setReleaseParams($content{
  112.       
  113.       // Notify the beginning of the current method
  114.       $this->dispatcher->notify(new sfEvent($this'config.set_release_params'));
  115.       
  116.     //charge les paramètres release dans un tableau $release_params
  117.     $this->setPostParams($this->file_release,$content);
  118.   }
  119.   /**
  120.    * config_file::setThemeParams()
  121.    * modifie le tableau $release_params avec les entrées du tableau $content
  122.    * @access public
  123.    * @return void 
  124.    * @param array $content 
  125.    */
  126.   function setThemeParams($content{
  127.       
  128.       // Notify the beginning of the current method
  129.       $this->dispatcher->notify(new sfEvent($this'config.set_theme_params'));
  130.       
  131.     //charge les paramètres release dans un tableau $release_params
  132.     $this->setPostParams($this->section_theme,$content);
  133.   }
  134.   /**
  135.    * config_file::setDbParams()
  136.    * modifie le tableau $db_params avec les entrées du tableau $content
  137.    * @access public
  138.    * @return void 
  139.    * @param array $content 
  140.    */
  141.   function setDbParams($content)
  142.   {
  143.       // Notify the beginning of the current method
  144.       $this->dispatcher->notify(new sfEvent($this'config.set_db_params'));
  145.       
  146.     //charge les paramètres dans un tableau $db_params
  147.     $this->setPostParams($this->file_db,$content);
  148.   }
  149.  
  150.   /**
  151.    * config_file::writeReleaseParams()
  152.    * écrit dans le fichier ini les paramètres du tableau $release_params
  153.    * @access public
  154.    * @return boolean 
  155.    */
  156.   function writeReleaseParams({
  157.       
  158.       // Notify the beginning of the current method
  159.       $this->dispatcher->notify(new sfEvent($this'config.write_release_params'));
  160.       
  161.     //écrit les paramètres $release_params vers les fichiers release  ini et php
  162.     if($this->backupParams($this->file_release)){
  163.       //on écrit les params après avoir fait le backup
  164.       if($this->a_file->mkini($this->release_params$this->ini_path.$this->file_release.$this->config_extension))
  165.       return true;
  166.     }
  167.     return false;
  168.   }
  169.   /**
  170.    * config_file::writedBParams()
  171.    * écrit dans le fichier ini les paramètres du tableau $db_params
  172.    * @access public
  173.    * @return boolean 
  174.    */
  175.   function writeDbParams({
  176.       
  177.       // Notify the beginning of the current method
  178.       $this->dispatcher->notify(new sfEvent($this'config.write_db_params'));
  179.       
  180.     //écrit les paramètres $db_params vers les fichier db ini et php
  181.     if($this->backupParams($this->file_db)){
  182.       //on écrit les params après avoir fait le backup
  183.       if($this->a_file->mkini($this->db_params$this->ini_path.$this->file_db.$this->config_extension))
  184.       return true;
  185.     }
  186.     return false;
  187.     //TODO : alert les paramètres db n'ont pas pu être écrit.
  188.   }
  189.  
  190.   /**
  191.    * config_file::backupParams()
  192.    * sauvegarde le fichier $file_name dans le répertoire de backup
  193.    * @access public
  194.    * @param string $file_name 
  195.    * @return boolean 
  196.    */
  197.   function backupParams($file_name)
  198.   {
  199.       // Notify the beginning of the current method
  200.       $this->dispatcher->notify(new sfEvent($this'config.backup_params'array('filename' => $file_name)));
  201.       
  202.     SureCreateDir($this->backup_config_path.$this->config_extension0755);
  203.     if ($this->a_file->cp($this->ini_path.$file_name.$this->config_extension,$this->backup_config_path)) return true;
  204.     else return false;
  205.   }
  206.  
  207.   /**
  208.    * config_file::writePhpParams()
  209.    * écrit le fichier php $file_name dans le répertoire de config
  210.    * @access public
  211.    *  méthode dépréciée
  212.    * @param string $file_name 
  213.    * @return boolean 
  214.    */
  215.   function writePhpParams($file_name)
  216.   {
  217.       // Notify the beginning of the current method
  218.       $this->dispatcher->notify(new sfEvent($this'config.write_php_params'array('filename' => $file_name)));
  219.       
  220.     $content=$this->generateHeader($file_name);
  221.     $content.=$this->generateBody($file_name);
  222.     $content.=$this->generateFooter($file_name);
  223.     //on écrit le contenu dans le fichier php
  224.     if($this->a_file->mkfile($content,$this->config_path.$file_name.$this->php_extension)) return true;
  225.     else return false;
  226.   }
  227.   /**
  228.    * config_file::parseConfig()
  229.    * retourne un tableau contenant les paramètres du fichier ini $file_name
  230.    * @access public
  231.    * @param string $file_name 
  232.    * @return array 
  233.    */
  234.   function parseConfig($file_name$whithsection true)
  235.   {
  236.       // Notify the beginning of the current method
  237.       $this->dispatcher->notify(new sfEvent($this'config.parse_config'array('filename' => $file_name)));
  238.       
  239.     //parse_ini_file
  240.     return $this->a_file->parse_ini($this->ini_path.$file_name.$this->config_extension$whithsection);
  241.  
  242.   }
  243.   /**
  244.    * config_file::setPostParams()
  245.    * insère les données différentes contenues dans $post_params dans le tableau correspondant au paramètre release ou db
  246.    * @access public
  247.    * @param string $file_name 
  248.    * @param array $post_params 
  249.    * @return void 
  250.    */
  251.   function setPostParams($file_name,$post_params)
  252.   {
  253.       
  254.       // Filter data event + return value
  255.       $r $this->dispatcher->filter(new sfEvent($this'config.set_params'array('data' => $post_params))$post_params);
  256.       $post_params $r->getReturnValue();
  257.       
  258.     //parse du tableau des paramètres
  259.     // ajoute les paramètres de post
  260.     if($file_name == $this->file_release || $file_name == $this->section_theme)
  261.     {
  262.       foreach ($post_params as $key => $value)
  263.       {
  264.         foreach ($this->release_params as $section => $existing_params)
  265.         {
  266.           foreach ($existing_params as $existing_param => $existing_value)
  267.           {
  268.             // la clé existe dans le tableau de cache release_params, on insère la valeur dans ce tableau
  269.             if($existing_param == $key$this->release_params[$section][$key]=$this->strip_ini_char($value);
  270.           }
  271.         }
  272.       }
  273.     }
  274.     if($file_name == $this->file_db)
  275.     {
  276.       foreach ($post_params as $key => $value)
  277.       {
  278.         foreach ($this->db_params as $section => $existing_params)
  279.         {
  280.           foreach ($existing_params as $existing_param => $existing_value)
  281.           {
  282.             // la clé existe dans le tableau de cache db_params, on insère la valeur dans ce tableau
  283.             if($existing_param == $key$this->db_params[$section][$key]=$this->strip_ini_char($value);
  284.           }
  285.         }
  286.       }
  287.     }
  288.   }
  289.   /**
  290.    * config_file::generateBody()
  291.    * génère le contenu d'un fichier php de configuration à parti du $file_name
  292.    * @access private
  293.    * @param string $file_name 
  294.    * @return string 
  295.    */
  296.   function generateBody($file_name)
  297.   {
  298.       
  299.     $out '';
  300.  
  301.     if($file_name == $this->file_release$content=$this->release_params;
  302.     else $content=$this->db_params;
  303.  
  304.     if (!is_array($content))
  305.     return false;
  306.  
  307.     foreach ($content as $key => $ini)
  308.     {
  309.       if (is_array($ini))
  310.       {
  311.         $out .= "\n\n//    ".$key." /////// \n\n";
  312.  
  313.         foreach ($ini as $var => $value)
  314.         {
  315.           $out .= "define('".$var."',\t\t".$this->a_file->quote_ini($value).");\n";
  316.         }
  317.       }
  318.       else
  319.       {
  320.         $out .= "define('".$key."',\t\t".$this->a_file->quote_ini($ini).");\n";
  321.       }
  322.     }
  323.     
  324.     // Filter data event + return value
  325.     $r $this->dispatcher->filter(new sfEvent($this'config.generate_body'array('filename' => $file_name'content' => $out))$out);
  326.     $out $r->getReturnValue();
  327.  
  328.     return $out;
  329.   }
  330.   /**
  331.    * config_file::generateHeader()
  332.    * génère l'en tête d'un fichier php de configuration à parti du $file_name
  333.    * @access private
  334.    * @param string $file_name 
  335.    * @return string 
  336.    */
  337.   function generateHeader($file_name)
  338.   {
  339.     $ret.="<?php \n";
  340.     $ret.="// Linea 21 - PHP ".$file_name."\n";
  341.     $ret.="// last_modify    : ".date("d-m-Y")."\n";
  342.     $ret.="// GPL 3\n";
  343.     $ret.="// http://opensource.org/licenses/gpl-3.0.html\n\n";
  344.     $ret.="// BE CAREFULL THIS FILE IS SYSTEM FILE : use interface or ".$file_name.$this->config_extension." FOR CONFIGURATION";
  345.     
  346.     // Filter data event + return value
  347.     $r $this->dispatcher->filter(new sfEvent($this'config.generate_header'array('filename' => $file_name'content' => $ret))$ret);
  348.     $ret $r->getReturnValue();
  349.     
  350.     return $ret;
  351.   }
  352.   /**
  353.    * config_file::generateFooter()
  354.    * génère le pied d'un fichier php de configuration à parti du $file_name
  355.    * @access private
  356.    * @param string $file_name 
  357.    * @return string 
  358.    */
  359.   function generateFooter($file_name)
  360.   {
  361.     $s "?> \n";
  362.     
  363.     // Filter data event + return value
  364.     $r $this->dispatcher->filter(new sfEvent($this'config.generate_footer'array('filename' => $file_name'content' => $s))$s);
  365.     $s $r->getReturnValue();
  366.     
  367.     return $s;
  368.   }
  369.  
  370.   /**
  371.    * config_file::getReleaseParams()
  372.    * génère le corps html d'un fichier de configuration pour affichage
  373.    * @access public
  374.    * @param string $updatable : champ texte modifiable
  375.    * @param string $hidden : présence d'input type hidden
  376.    * @return string 
  377.    */
  378.   function getReleaseParams($updatable false$hidden false{
  379.  
  380.       // Notify the beginning of the current method
  381.       $this->dispatcher->notify(new sfEvent($this'config.get_release_params'));
  382.       
  383.     return $this->getAllParams($this->file_release,$updatable$hidden);
  384.   }
  385.   /**
  386.    * config_file::getDbParams()
  387.    * génère le corps html d'un fichier de configuration pour affichage
  388.    * @access public
  389.    * @param string $updatable : champ texte modifiable
  390.    * @param string $hidden : présence d'input type hidden
  391.    * @return string 
  392.    */
  393.   function getDbParams($updatable false$hidden false{
  394.  
  395.       // Notify the beginning of the current method
  396.       $this->dispatcher->notify(new sfEvent($this'config.get_db_params'));
  397.       
  398.     return $this->getAllParams($this->file_db,$updatable$hidden);
  399.   }
  400.   /**
  401.    * config_file::getAllParams()
  402.    * génère le corps html d'un fichier de configuration pour affichage
  403.    * @access private
  404.    * @param string $updatable : champ texte modifiable
  405.    * @param string $hidden : présence d'input type hidden
  406.    * @param string $file_name 
  407.    * @return string 
  408.    */
  409.   function getAllParams($file_name$updatable false$hidden false)
  410.   {
  411.       // Notify the beginning of the current method
  412.       $this->dispatcher->notify(new sfEvent($this'config.get_all_params'array('filename' => $file_name)));
  413.       
  414.     $out '';
  415.     $authorized_sections=array();
  416.  
  417.     include('../languages/' U_L '/lang_system.'CHARSET .'.php');
  418.  
  419.     if($file_name == $this->file_release{
  420.       // le tableau de cache à utiliser est celui de realease
  421.       $content=$this->release_params;
  422.       //initialisation des sections à afficher/mdofier
  423.       $authorized_sections=$this->authorized_release_sections;
  424.     }
  425.     else if($file_name == $this->section_theme)
  426.     {
  427.       // le tableau de cache à utiliser est celui de realease
  428.       $content=$this->release_params;
  429.       $authorized_sections=$this->authorized_theme_sections;
  430.     }
  431.     else
  432.     {
  433.       // le tableau de cache à utiliser est celui de db
  434.       $content=$this->db_params;
  435.       //initialisation des sections à afficher/mdofier
  436.       $authorized_sections=$this->authorized_db_sections;
  437.     }
  438.  
  439.     if (!is_array($content))
  440.     return false;
  441.  
  442.     foreach ($content as $key => $ini)
  443.     {
  444.  
  445.       if (is_array($ini))
  446.       {
  447.         if((in_array($key,$authorized_sections)))
  448.         {
  449.  
  450.           if(isset($GLOBALS['lang']['system'][$key])) $label='<abbr title="'.$GLOBALS['lang']['system'][$key].'">'.$key.'</abbr>';
  451.           else $label=$key;
  452.  
  453.           $out .= "\n<br style='clear:both' />\n";
  454.           $out .= "\n<h2>".$label."</h2>\n";
  455.           if(!$updatable$out .="<dl>\n";
  456.           //génération d'un bloc
  457.           foreach ($ini as $var => $value)
  458.           {
  459.             $label='';
  460.             if(isset($GLOBALS['lang']['system'][$var])) $label='<abbr title="'.$GLOBALS['lang']['system'][$var].'">'.$var.'</abbr>';
  461.             else $label=$var;
  462.             if(!$updatable)    {
  463.               $out .="<dt>".$label;
  464.               if($hidden$out .= "<input name=\"".$var."\" id=\"".$var."\" value=\"".$value."\" type=\"hidden\"  />\n";
  465.               if($var !='LANGUAGE'{
  466.                   if($var=='DB_PASS'{
  467.                     $out .= "</dt><dd>".preg_replace("/[a-zA-Z0-9_]/""•"$value)."</dd>\n";
  468.                   else {
  469.                   $out .= "</dt><dd>".$value."</dd>\n";
  470.                   }
  471.               else {
  472.                 $out .="</dt><dd>".culture::getInstance()->getCultureInfo($value'Language')."</dd>\n";
  473.               }
  474.  
  475.             }
  476.             else {
  477.               if($var=='DB_PASS'{
  478.                   $out .= "<p><label for=\"".$var."\">".$label."</label><input name=\"".$var."\" id=\"".$var."\" value=\"".$value."\" type=\"password\" class=\"textfield\" /></p>\n";
  479.               }
  480.               elseif($var !='LANGUAGE'{
  481.                 $out .= "<p><label for=\"".$var."\">".$label."</label><input name=\"".$var."\" id=\"".$var."\" value=\"".$value."\" type=\"text\" class=\"textfield\" /></p>\n";
  482.               else {
  483.                 $out .= "<p><label for=\"".$var."\">".$label."</label>".CultureSelectBox($var$value)."</p>\n";
  484.               }
  485.  
  486.             }
  487.           }
  488.           if(!$updatable$out .="</dl>";
  489.         }
  490.       }
  491.       else
  492.       {
  493.         if(!$updatable && $hidden$out .= "<input name=\"".$key."\" id=\"".$key."\" value=\"".$ini."\" type=\"hidden\"  />\n";
  494.         if(!$updatable)    $out .="<dt>".$key."</dt><dd>".$ini."</dd>\n";
  495.         else $out .= "<p><label for=\"".$key."\">".$key."</label><input name=\"".$key."\" id=\"".$key."\" value=\"".$ini."\" type=\"text\" class=\"textfield\" /></p>\n";
  496.       }
  497.     }
  498.     return $out;
  499.  
  500.   }
  501.   /**
  502.    * config_file::getThemeParams()
  503.    * génère le corps html d'un fichier de configuration pour affichage
  504.    * @access public
  505.    * @param string $updatable : champ texte modifiable
  506.    * @param string $hidden : présence d'input type hidden
  507.    * @return string 
  508.    */
  509.   function getThemeParams($updatable false$hidden false{
  510.  
  511.       // Notify the beginning of the current method
  512.       $this->dispatcher->notify(new sfEvent($this'config.get_theme_params'));
  513.       
  514.     $out '';
  515.     $authorized_sections=array();
  516.  
  517.     include('../languages/' U_L '/lang_system.'CHARSET .'.php');
  518.  
  519.     $content=$this->release_params;
  520.     $authorized_sections=$this->authorized_theme_sections;
  521.  
  522.     $theme_public=$content[$this->theme_settings][$this->theme_public];
  523.     $theme_admin=$content[$this->theme_settings][$this->theme_admin];
  524.  
  525.     if(isset($GLOBALS['lang']['system'][$this->theme_public])) $label='<abbr title="'.$GLOBALS['lang']['system'][$this->theme_public].'">'.$this->theme_public.'</abbr>';
  526.     else $label=$this->theme_public;
  527.  
  528.     $out .= "\n<h2 style=\"clear:both;\">".$label."</h2>\n";
  529.     $out .=$this->getOneThemeParams($updatable$hiddentrue,$theme_public,$this->theme_public,$this->theme_public"public");
  530.  
  531.     $public_themes getThemes('public');
  532.  
  533.     foreach ($public_themes as $key => $value)
  534.     {
  535.       if($value != $theme_public)
  536.       $out .=$this->getOneThemeParams($updatable$hiddenfalse,$value,$this->theme_list_public,$this->theme_public"public");
  537.     }
  538.  
  539.     if(isset($GLOBALS['lang']['system'][$this->theme_admin])) $label='<abbr title="'.$GLOBALS['lang']['system'][$this->theme_admin].'">'.$this->theme_admin.'</abbr>';
  540.     else $label=$this->theme_admin;
  541.  
  542.     $out .= "\n<h2 style=\"clear:both;\">".$label."</h2>\n";
  543.  
  544.     $out .=$this->getOneThemeParams($updatable$hiddentrue,$theme_admin,$this->theme_admin,$this->theme_admin"admin");
  545.  
  546.     $admin_themes getThemes('admin');
  547.  
  548.     foreach ($admin_themes as $key => $value)
  549.     {
  550.       if($value != $theme_admin)
  551.       $out .=$this->getOneThemeParams($updatable$hiddenfalse,$value,$this->theme_list_admin,$this->theme_admin"admin");
  552.     }
  553.  
  554.     $out .= "\n<br style=\"clear:both;\" />\n";
  555.     return $out;
  556.   }
  557.  
  558.  
  559.   /**
  560.    * config_file::getOneThemeParams()
  561.    * génère le corps html d'un fichier de configuration pour affichage
  562.    * @access private
  563.    * @param string $updatable 
  564.    * @param string $hidden 
  565.    * @param string $selected 
  566.    * @param string $value 
  567.    * @param string $field_name 
  568.    * @param string $radio_name 
  569.    * @return string 
  570.    */
  571.   function getOneThemeParams($updatable false$hidden false$selected=false,$value,$field_name,$radio_name$type{
  572.  
  573.       // Notify the beginning of the current method
  574.       $this->dispatcher->notify(new sfEvent($this'config.get_one_theme_params'));
  575.       
  576.     include('../languages/' U_L '/lang_system.'CHARSET .'.php');
  577.  
  578.     $selected_pattern='';
  579.     $checked_pattern='';
  580.     $hidden_pattern='';
  581.     $updatable_pattern='';
  582.     $info loadThemeInfo($type$value);
  583.  
  584.     if ($selected)
  585.     {
  586.       $selected_pattern='_selected';
  587.       $checked_pattern='checked="checked"';
  588.     }
  589.     if(!$updatable)$hidden_pattern='style="display:none;"';
  590.     else $updatable_pattern="onclick=\"javascript:document.getElementById('".$type.$value."').checked='checked';\"";
  591.     $out '';
  592.     $out .="<div class=\"config_theme" $selected_pattern"\">\n";
  593.     $out .="<img src=\"../templates/" .$type"/" .$value"/preview.png\" style=\"width:250px;height:160px;\" alt=\"" .$value"\" id=\"img_" .$type."-".$value"\" ".$updatable_pattern."/>\n";
  594.  
  595.     $out .= '<input type="radio" name="' .$radio_name'" id="' .$type.'-'.$value'" value="' .$value'" ' .$checked_pattern' ' .$hidden_pattern' />';
  596.     $out .=    '<label for="' .$type.'-'.$value'" class="autowidth">' $value '</label>';
  597.     $out .= '<div class="themeinfo"><em>'._t('theme','name').'</em> : '.$info['name'].'<br />'.END_LINE;
  598.     $out .= '<em>'._t('theme','author').'</em> : <a href="'.$info['homepage'].'">'.$info['author'].'</a><br />'.END_LINE;
  599.     $out .= '<em>'._t('theme','version').'</em> : '.$info['version'].' | ';
  600.     $out .= '<em>'._t('theme','compatibility').'</em> : '.$info['compatibility'].'<br />'.END_LINE;
  601.     $out .= '<em>'._t('theme','description').'</em> : '.$info['description'].'<br />'.END_LINE;
  602.     $out .= '</div>';
  603.     $out .="</div>";
  604.     return $out;
  605.   }
  606.  
  607.   /**
  608.    * config_file::strip_ini_char
  609.    * suppression des caractères interdits dans un fichier ini
  610.    * @access private
  611.    * @param string $content 
  612.    * @return string 
  613.    */
  614.   function strip_ini_char($content)
  615.   {
  616.     $ret='';
  617.     // on remplace les caractères "[]; par '(),
  618.     $ret=strtr($content"\"[];""'(),");
  619.     if (get_magic_quotes_gpc()) $ret=stripslashes($ret);
  620.     return $ret;
  621.   }
  622.  
  623.   /**
  624.    * config_file::initializeIniParams()
  625.    * charge les paramètres des fichiers ini et les place en constante globale par define
  626.    * @access public
  627.    * @param void 
  628.    * @return void 
  629.    */
  630.   function initializeIniParams()
  631.   {
  632.  
  633.       // Notify the beginning of the current method
  634.       $this->dispatcher->notify(new sfEvent($this'config.init_ini'));
  635.       
  636.     foreach ($this->release_params as $section => $existing_params)
  637.     {
  638.       foreach ($existing_params as $existing_param => $existing_value)
  639.       {
  640.         if(!defined($existing_param))
  641.         {
  642.           if(is_numeric($existing_value))
  643.           {
  644.             $existing_value=$this->convert_type($existing_value);
  645.           }
  646.           define($existing_param,$existing_value);
  647.         }
  648.       }
  649.     }
  650.     foreach ($this->db_params as $section => $existing_params)
  651.     {
  652.       foreach ($existing_params as $existing_param => $existing_value)
  653.       {
  654.         if(!defined($existing_param))
  655.         {
  656.           if(is_numeric($existing_value))
  657.           {
  658.             $existing_value=$this->convert_type($existing_value);
  659.           }
  660.           define($existing_param,$existing_value);
  661.         }
  662.       }
  663.     }
  664.   }
  665.  
  666.   /**
  667.    * config_file::convert_type()
  668.    * conversion d'une variable en entier ou en float selon son contenu
  669.    * @param unknown_type $var 
  670.    * @return int or float
  671.    */
  672.   function convert_type$var )
  673.   {
  674.     ifis_numeric$var ) )
  675.     {
  676.       if(float)$var != (int)$var )
  677.       {
  678.         return (float)$var;
  679.       }
  680.       else
  681.       {
  682.         return (int)$var;
  683.       }
  684.     }
  685.     if$var == "true" )    return true;
  686.     if$var == "false" )    return false;
  687.     return $var;
  688.   }
  689.   /**
  690.    * config_file::getPhpInfo()
  691.    * Retourne un string contenant les informations php en html
  692.    * @access public
  693.    * @return string 
  694.    */
  695.   function getPhpInfo({
  696.     ob_start();
  697.     phpinfo();
  698.     $info ob_get_contents();
  699.     ob_end_clean();
  700.     return preg_replace('%^.*<body>(.*)</body>.*$%ms''$1'$info);
  701.   }
  702. }
  703.  
  704. ?>

Documentation generated on Mon, 08 Apr 2013 18:12:18 +0200 by phpDocumentor 1.4.1