source: trunk/spip/esqueleto-redcta/plugins/cfg/depots/meta.php @ 273

Last change on this file since 273 was 152, checked in by guille, 15 years ago

se agregaron svn_update y cfg para el 2.0

File size: 2.1 KB
Line 
1<?php
2
3/*
4 * Plugin CFG pour SPIP
5 * (c) toggg 2007, distribue sous licence GNU/GPL
6 * Documentation et contact: http://www.spip-contrib.net/
7 *
8 * classe cfg_classic: storage a plat (classique) dans spip_meta
9 */
10
11if (!defined("_ECRIRE_INC_VERSION")) return;
12
13// cfg_meta retrouve et met a jour les donnees a plat dans spip_meta
14class cfg_depot_meta
15{
16        var $champs = array();
17        var $champs_id = array();
18        var $val = array();
19        var $param = array();
20        var $messages = array('message_ok'=>array(), 'message_erreur'=>array(), 'erreurs'=>array());
21       
22        // version du depot
23        var $version = 2;
24       
25        function cfg_depot_meta($params=array())
26        {
27                foreach ($params as $o=>$v) {
28                        $this->$o = $v;
29                }       
30        }
31       
32        // recuperer les valeurs.
33        // unserialize : si la valeur est deserialisable, elle est retournee deserialisee
34        // permet a #CONFIG d'obtenir une valeur non deserialisee...
35        function lire($unserialize=true)
36        {
37        $val = array();
38        if ($this->champs) {
39                        foreach ($this->champs as $name => $def) {
40                                // pour compat cfg, si la meta est deserialisable, la retourner deserialisee
41                                if ($unserialize && ($a = @unserialize($GLOBALS['meta'][$name])))
42                                        $val[$name] = $a;
43                                else {
44                                        $val[$name] = $GLOBALS['meta'][$name];
45                                }
46                        }
47                // si pas d'argument, retourner comme le core serialize($GLOBALS['meta'])
48                } else {
49                        $val = serialize($GLOBALS['meta']);
50                }
51            return array(true, $val);
52        }
53
54
55        // ecrit chaque enregistrement de meta pour chaque champ
56        function ecrire()
57        {
58                foreach ($this->champs as $name => $def) {
59                        ecrire_meta($name, $this->val[$name]);
60            }
61            if (defined('_COMPAT_CFG_192')) ecrire_metas();
62            return array(true, $this->val);
63        }
64       
65       
66        // supprime chaque enregistrement de meta pour chaque champ
67        function effacer(){
68                foreach ($this->champs as $name => $def) {
69                        if (!$this->val[$name]) {
70                            effacer_meta($name);
71                        }
72            }
73            if (defined('_COMPAT_CFG_192')) ecrire_metas();
74            return array(true, $this->val);                     
75        }
76       
77       
78        // charger les arguments de lire_config(meta::nom)
79        // $args = 'nom'; ici
80        function charger_args($args){
81                if ($args) $this->champs = array($args=>true);
82                return true;   
83        }
84}
85?>
Note: See TracBrowser for help on using the repository browser.