source: trunk/spip/esqueleto-redcta/plugins/cfg/inc/compat_cfg.php @ 152

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

se agregaron svn_update y cfg para el 2.0

File size: 7.0 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 */
9
10if (!defined("_ECRIRE_INC_VERSION")) return;
11
12define('_COMPAT_CFG_192', true);
13
14
15if (version_compare($GLOBALS['spip_version_code'], '11216', '<')
16        && !function_exists('balise_ACTION_FORMULAIRE_dist')) {
17                function balise_ACTION_FORMULAIRE_dist($p){
18                        $p->code="''";
19                        $p->interdire_scripts = false;
20                        return $p;
21                }
22}
23
24/* fichier de compatibilite vers spip 1.9.2 */
25if (version_compare($GLOBALS['spip_version_code'], '1.9300', '<')
26        AND $f = charger_fonction('compat_cfg', 'inc'))
27                $f();
28
29
30## ceci n'est pas l'original du plugin compat mais la copie pour CFG
31
32// En termes de distribution ce fichier PEUT etre recopie dans chaque plugin
33// qui desire en avoir une version autonome (voire forkee), A CONDITION DE
34// RENOMMER le fichier et ses deux fonctions ; c'est un peu lourd a maintenir
35// mais c'est le prix a payer pour l'independance des plugins entre eux :-(
36
37// la version commune a tous est developpee sur
38// svn://zone.spip.org/spip-zone/_dev_/compat/
39
40
41function inc_compat_cfg_dist($quoi = NULL) {
42        if (!function_exists($f = 'compat_cfg_defs')) $f .= '_dist';
43        $defs = $f();
44
45        include_spip('base/abstract_sql');
46       
47        if (is_string($quoi))
48                $quoi = array($quoi);
49        else if (is_null($quoi))
50                $quoi = array_keys($defs);
51
52        foreach ($quoi as $d) {
53                if (!function_exists($d)
54                AND isset($defs[$d])) {
55                        eval ("function $d".$defs[$d]);
56                }
57        }
58}
59
60function compat_cfg_defs_dist() {
61        $defs = array(
62               
63                'push' => 
64                        '($array, $val) {
65                                if($array == \'\' OR !array_push($array, $val)) return \'\';
66                                return $array;
67                        }',
68                       
69                'et' => 
70                        '($code, $arg) {
71                                return ((($code) AND ($arg)) ?\' \' :\'\');
72                        }',
73               
74                'ou' => 
75                        '($code, $arg) {
76                                return ((($code) OR ($arg)) ?\' \' :\'\');
77                        }',
78               
79                'xou' => 
80                        '($code, $arg) {
81                                return ((($code) XOR ($arg)) ?\' \' :\'\');
82                        }',
83               
84                'non' => 
85                        '($code) {
86                                return (($code) ?\'\' :\' \');
87                        }',
88                       
89                'oui' => 
90                        '($code) {
91                                return (($code) ?\' \' :\'\');
92                        }',
93               
94                'sql_fetch' => 
95                        '(
96                                $res,
97                                $serveur=\'\'
98                        ) {
99                                return spip_fetch_array($res);
100                        }',
101               
102                'sql_query' => 
103                        '($res, $serveur=\'\') {
104                                return spip_query($res);
105                        }',     
106               
107                // n'existe pas en 1.9.2
108                'sql_alter' => 
109                        '($res, $serveur=\'\') {
110                                return spip_query(\'ALTER \' . $res);
111                        }',     
112                               
113                // n'existe pas en 1.9.2
114                // on cree la requete directement
115                'sql_delete' => 
116                        '($table, $where=\'\', $serveur=\'\') {
117                                if (!is_array($table)) $table = array($table);
118                                if (!is_array($where)) $where = array($where);
119                                $query = \'DELETE FROM \'
120                                                . implode(\',\', $table)
121                                                . \' WHERE \'
122                                                . implode(\' AND \', $where);
123                                return spip_query($query);
124                        }',
125                       
126                // sql_quote : _q directement
127                'sql_quote' => 
128                        '(
129                                $val,
130                                $serveur=\'\'
131                        ) {
132                                return _q($val);
133                        }',     
134                                               
135                'sql_select' => 
136                        '(
137                                $select = array(),
138                                $from = array(),
139                                $where = array(),
140                                $groupby = array(),
141                                $orderby = array(),
142                                $limit = \'\',
143                                $having = array(),
144                                $serveur=\'\'
145                        ) {
146                                return spip_abstract_select(
147                                        $select,
148                                        $from,
149                                        $where,
150                                        $groupby,
151                                        $orderby,
152                                        $limit,
153                                        $sousrequete = \'\',
154                                        $having,
155                                        $table = \'\',
156                                        $id = \'\',
157                                        $serveur);
158                        }',
159               
160                'sql_fetsel' =>
161                        '(
162                                $select = array(),
163                                $from = array(),
164                                $where = array(),
165                                $groupby = array(),
166                                $orderby = array(),
167                                $limit = \'\',
168                                $having = array(),
169                                $serveur=\'\'
170                        ) {
171                                return sql_fetch(sql_select(
172                                        $select,
173                                        $from,
174                                        $where,
175                                        $groupby,
176                                        $orderby,
177                                        $limit,
178                                        $having,
179                                        $serveur                               
180                                ));
181                        }',     
182                       
183                'sql_getfetsel' =>
184                        '(
185                                $select,
186                                $from = array(),
187                                $where = array(),
188                                $groupby = array(),
189                                $orderby = array(),
190                                $limit = \'\',
191                                $having = array(),
192                                $serveur=\'\'
193                        ) {
194                                $r = sql_fetsel(
195                                        $select,
196                                        $from,
197                                        $where,
198                                        $groupby,
199                                        $orderby,
200                                        $limit,
201                                        $having,
202                                        $serveur                               
203                                );
204                                return $r ? $r[$select] : NULL;
205                        }',
206                                       
207                'sql_allfetsel' =>
208                        '(
209                                $select,
210                                $from = array(),
211                                $where = array(),
212                                $groupby = array(),
213                                $orderby = array(),
214                                $limit = \'\',
215                                $having = array(),
216                                $serveur=\'\'
217                        ) {
218                                $q = sql_select(
219                                        $select,
220                                        $from,
221                                        $where,
222                                        $groupby,
223                                        $orderby,
224                                        $limit,
225                                        $having,
226                                        $serveur                               
227                                );
228                                if (!$q) return array();
229                                $res = array();
230                                while ($r = sql_fetch($q)) $res[] = $r;
231                                return $res;
232                        }',                             
233               
234                // n'existe pas en 1.9.2
235                // on cree la requete directement
236                'sql_update' => 
237                        '(
238                                $table,
239                                $champs,
240                                $where=\'\',
241                                $desc=array(),
242                                $serveur=\'\'
243                        ) {
244                                if (!is_array($table))  $table = array($table);
245                                if (!is_array($champs)) $champs = array($champs);
246                                if (!is_array($where))  $where = array($where);
247
248                                $query = $r = \'\';
249                                foreach ($champs as $champ => $val)
250                                        $r .= \',\' . $champ . "=$val";
251                                if ($r = substr($r, 1))
252                                        $query = \'UPDATE \'
253                                                        . implode(\',\', $table)
254                                                        . \' SET \' . $r
255                                                        . (empty($where) ? \'\' :\' WHERE \' . implode(\' AND \', $where));
256                                if ($query)
257                                        return spip_query($query);
258                        }',
259
260                'sql_updateq' => 
261                        '(
262                                $table,
263                                $champs,
264                                $where=\'\',
265                                $desc=array(),
266                                $serveur=\'\'
267                        ) {
268                                if (!is_array($champs)) $exp = array($champs);
269                               
270                                foreach ($champs as $k => $val) {
271                                        $champs[$k] = sql_quote($val);
272                                }
273                               
274                                return sql_update(                             
275                                        $table,
276                                        $champs,
277                                        $where,
278                                        $desc,
279                                        $serveur
280                                );
281                        }',     
282                       
283               
284                // n'existe pas en 1.9.2
285                // on cree la requete directement
286                'sql_insertq' => 
287                        '(
288                                $table,
289                                $champs
290                        ) {
291                                if (!is_array($champs)) $exp = array($champs);
292                               
293                                foreach ($champs as $k => $val) {
294                                        $champs[$k] = sql_quote($val);
295                                }
296                               
297                                $query = "INSERT INTO $table (".implode(",", array_keys($champs)).") VALUES (".implode(",", $champs).")";
298                                return sql_query($query);
299                        }',
300               
301                'sql_showtable' => '($table, $serveur=\'\') {
302                        include_spip("base/abstract_sql");
303                        return spip_abstract_showtable($table, \'mysql\', true);
304                }',
305               
306
307                'sql_count' => 
308                        '(
309                                $res,
310                                $serveur=\'\'
311                        ) {
312                                return spip_mysql_count($res);
313                        }',
314               
315
316                'sql_countsel' => 
317                        '(
318                                $from = array(),
319                                $where = array(),
320                                $groupby = array(),
321                                $limit = \'\',
322                                $having = array(),
323                                $serveur=\'\'
324                        ) {
325                                return(sql_getfetsel(\'COUNT(*)\', $from, $where, $groupby, \'\', $limit, $having, $serveur));
326                        }',
327                                       
328                'sql_selectdb' => 
329                        '(
330                                $res,
331                                $serveur=\'\'
332                        ) {
333                                $GLOBALS[\'spip_mysql_db\'] = mysql_select_db($res);
334                                return $GLOBALS[\'spip_mysql_db\'];
335                        }'
336
337        );
338        return $defs;
339}
340
341?>
Note: See TracBrowser for help on using the repository browser.