phpDocumentor lodel
[ class tree: lodel ] [ index: lodel ] [ all elements ]

Source for file optionfunc.php

Documentation is available at optionfunc.php

  1. <?php
  2. /**
  3.  * Fichier utilitaire de gestion des options
  4.  *
  5.  * PHP versions 4 et 5
  6.  *
  7.  * LODEL - Logiciel d'Edition ELectronique.
  8.  *
  9.  * Copyright (c) 2001-2002, Ghislain Picard, Marin Dacos
  10.  * Copyright (c) 2003, Ghislain Picard, Marin Dacos, Luc Santeramo, Nicolas Nutten, Anne Gentil-Beccot
  11.  * Copyright (c) 2004, Ghislain Picard, Marin Dacos, Luc Santeramo, Anne Gentil-Beccot, Bruno Cénou
  12.  * Copyright (c) 2005, Ghislain Picard, Marin Dacos, Luc Santeramo, Gautier Poupeau, Jean Lamy, Bruno Cénou
  13.  * Copyright (c) 2006, Marin Dacos, Luc Santeramo, Bruno Cénou, Jean Lamy, Mikaël Cixous, Sophie Malafosse
  14.  *
  15.  * Home page: http://www.lodel.org
  16.  *
  17.  * E-Mail: lodel@lodel.org
  18.  *
  19.  * All Rights Reserved
  20.  *
  21.  * This program is free software; you can redistribute it and/or modify
  22.  * it under the terms of the GNU General Public License as published by
  23.  * the Free Software Foundation; either version 2 of the License, or
  24.  * (at your option) any later version.
  25.  *
  26.  * This program is distributed in the hope that it will be useful,
  27.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  28.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  29.  * GNU General Public License for more details.
  30.  *
  31.  * You should have received a copy of the GNU General Public License
  32.  * along with this program; if not, write to the Free Software
  33.  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  34.  *
  35.  * @author Ghislain Picard
  36.  * @author Jean Lamy
  37.  * @copyright 2005, Ghislain Picard, Marin Dacos, Luc Santeramo, Gautier Poupeau, Jean Lamy, Bruno Cénou
  38.  * @copyright 2006, Marin Dacos, Luc Santeramo, Bruno Cénou, Jean Lamy, Mikaël Cixous, Sophie Malafosse
  39.  * @licence http://www.gnu.org/copyleft/gpl.html
  40.  * @version CVS:$Id:
  41.  * @package lodel
  42.  */
  43.  
  44. /**
  45.  * Mise en cache des options (table Option) dans un fichier
  46.  *
  47.  * En plus de créer le fichier de cache des options, un tableau de ces options est aussi créé
  48.  * Tableau de la forme [groupname.optionname][value]
  49.  *
  50.  * Si la fonction est appelée sans argument, le fichier n'est pas écrit et le tableau est de la forme [groupname][optionname][value] : utilisé pour passer les options dans le $context
  51.  * @param string $optionsfile le nom du fichier cache des options
  52.  * @return array le tableau des options
  53.  */
  54.  
  55. require_once 'func.php';
  56. function cacheOptionsInFile($optionsfile='')
  57. {
  58.     global $db;
  59.     do {
  60.         $sql lq("SELECT id,idparent,name FROM #_TP_optiongroups WHERE status > 0 AND idparent ".sql_in_array($ids)." ORDER BY rank");
  61.         $result $db->execute($sqlor dberror();
  62.         $ids array ();
  63.         $i 1;
  64.         $l 1;
  65.         while (!$result->EOF{
  66.             $id $result->fields['id'];
  67.             $name $result->fields['name'];
  68.             $idparent $result->fields['idparent'];
  69.             $ids[$id;
  70.             if ($idparent)
  71.                 $name $parent[$idparent].".".$name;
  72.             #$d = $rank[$id] = $rank[$idparent]+($i*1.0)/$l;
  73.             $arr[$id$name;
  74.             $parent[$id$name;
  75.             $l *= 100;
  76.             $i ++;
  77.             $result->moveNext();
  78.         }
  79.     }    while ($ids);
  80.  
  81.     if (!empty($optionsfile)) {
  82.         $sql lq("SELECT id, idgroup, name, value, defaultvalue FROM #_TP_options "." WHERE status > 0 ORDER BY rank");
  83.     else // pas les username et passwd dans le context
  84.         $sql lq("SELECT id, idgroup, name, value, defaultvalue FROM #_TP_options "." WHERE status > 0 AND type !='passwd' AND type !='username' ORDER BY rank");
  85.     }
  86.  
  87.     $result $db->execute($sqlor dberror();
  88.     $txt "<"."?php\n\$options_cache=array(\n";
  89.     while (!$result->EOF)    {
  90.         $id $result->fields['id'];
  91.         $name $result->fields['name'];
  92.         $idgroup $result->fields['idgroup'];
  93.         $value $result->fields['value'$result->fields['value'$result->fields['defaultvalue'];
  94.         if (!empty($optionsfile)) {
  95.             $optname $arr[$idgroup].".".$name;
  96.             clean_request_variable($value);
  97.             $txt .= "'".$optname."'=>'".addslashes($value)."',\n";
  98.             $options_cache[$optnameaddslashes($value);
  99.         else {
  100.             $optname $name;
  101.             clean_request_variable($value);
  102.             $txt .= "'".$optname."'=>'".addslashes($value)."',\n";
  103.             $papa $arr[$idgroup];
  104.             $options_cache[$papa][$optnameaddslashes($value);
  105.         }
  106.         $result->MoveNext();
  107.     }
  108.     $txt .= ");?".">";
  109.     #echo "<textarea cols=100 rows=10>$txt</textarea>";
  110.     if (!empty($optionsfile)) $ret writefile($optionsfile$txt)}
  111.     return $options_cache
  112. }
  113. ?>

Documentation generated on Wed, 19 Sep 2007 05:07:26 +0200 by phpDocumentor 1.4.0a2