X-Git-Url: http://git.cyclocoop.org/?p=velocampus%2Fweb%2Fwww.git;a=blobdiff_plain;f=www%2Fplugins%2Fauto%2Fcfg%2Fdepots%2Fmeta.php;fp=www%2Fplugins%2Fauto%2Fcfg%2Fdepots%2Fmeta.php;h=29df92871132d86721ffe6878e327476afb2cff4;hp=0000000000000000000000000000000000000000;hb=80b4d3e85f78d402ed2e73f8f5d1bf4c19962eed;hpb=aaf970bf4cdaf76689ecc10609048e18d073820c diff --git a/www/plugins/auto/cfg/depots/meta.php b/www/plugins/auto/cfg/depots/meta.php new file mode 100644 index 0000000..29df928 --- /dev/null +++ b/www/plugins/auto/cfg/depots/meta.php @@ -0,0 +1,144 @@ +array(), 'message_erreur'=>array(), 'erreurs'=>array()); + + /** + * version du depot + * @var int + */ + var $version = 2; + + /** + * + * @param Array $params + */ + function cfg_depot_meta($params=array()) + { + foreach ($params as $o=>$v) { + $this->$o = $v; + } + } + + + /** + * recuperer les valeurs. + * + * unserialize : si la valeur est deserialisable, elle est retournee deserialisee + * permet a #CONFIG d'obtenir une valeur non deserialisee... + * + * @param boolean $unserialize + * @return Array + */ + function lire($unserialize=true) + { + $val = array(); + if ($this->champs) { + foreach ($this->champs as $name => $def) { + // pour compat cfg, si la meta est deserialisable, la retourner deserialisee + if ($unserialize && ($a = @unserialize($GLOBALS['meta'][$name]))) + $val[$name] = $a; + else { + $val[$name] = $GLOBALS['meta'][$name]; + } + } + // si pas d'argument, retourner comme le core serialize($GLOBALS['meta']) + } else { + $val = serialize($GLOBALS['meta']); + } + return array(true, $val); + } + + + /** + * ecrit chaque enregistrement de meta pour chaque champ + * + * @return Array + */ + function ecrire() + { + foreach ($this->champs as $name => $def) { + ecrire_meta($name, $this->val[$name]); + } + if (defined('_COMPAT_CFG_192')) ecrire_metas(); + return array(true, $this->val); + } + + + /** + * supprime chaque enregistrement de meta pour chaque champ + * + * @return Array + */ + function effacer(){ + foreach ($this->champs as $name => $def) { + if (!$this->val[$name]) { + effacer_meta($name); + } + } + if (defined('_COMPAT_CFG_192')) ecrire_metas(); + return array(true, $this->val); + } + + + /** + * charger les arguments de lire_config(meta::nom) + * + * @param string $args # $args = 'nom'; ici + * @return boolean + */ + function charger_args($args){ + if ($args) $this->champs = array($args=>true); + return true; + } +} +?>