4 * Plugin générique de configuration pour SPIP
10 * @copyright (c) toggg 2007
11 * @link http://www.spip-contrib.net/
12 * @version $Id: compat_cfg.php 36744 2010-03-29 02:31:19Z gilles.vincent@gmail.com $
15 if (!defined("_ECRIRE_INC_VERSION")) return;
18 * CFG doit-il être compatible SPIP 1.9.2 ?
21 define('_COMPAT_CFG_192', true);
23 if (version_compare($GLOBALS['spip_version_code'], '11216', '<')
24 && !function_exists('balise_ACTION_FORMULAIRE_dist')) {
25 function balise_ACTION_FORMULAIRE_dist($p){
27 $p->interdire_scripts
= false;
32 /* fichier de compatibilite vers spip 1.9.2 */
33 if (version_compare($GLOBALS['spip_version_code'], '1.9300', '<')
34 AND $f = charger_fonction('compat_cfg', 'inc'))
38 * Gestion de la compatibilité avec SPIP 1.9.2
40 * <b>ceci n'est pas l'original du plugin compat mais la copie pour CFG</b>
42 * En termes de distribution ce fichier PEUT etre recopie dans chaque plugin
43 * qui desire en avoir une version autonome (voire forkee), A CONDITION DE
44 * RENOMMER le fichier et ses deux fonctions ; c'est un peu lourd a maintenir
45 * mais c'est le prix a payer pour l'independance des plugins entre eux :-(
47 * la version commune a tous est developpee sur
48 * {@link http://zone.spip.org/spip-zone/browser/_dev_/compat/ svn://zone.spip.org/spip-zone/_dev_/compat/}
52 function inc_compat_cfg_dist($quoi = NULL) {
53 if (!function_exists($f = 'compat_cfg_defs')) $f .= '_dist';
56 include_spip('base/abstract_sql');
60 else if (is_null($quoi))
61 $quoi = array_keys($defs);
63 foreach ($quoi as $d) {
64 if (!function_exists($d)
65 AND isset($defs[$d])) {
66 eval ("function $d".$defs[$d]);
72 * Calcule le tableau de compatibilité des fonctions non définies sous SPIP2.0
73 * (fournit leur arbre syntaxique manipulé par le compilo)
77 function compat_cfg_defs_dist() {
79 // on fait au plus simple pour le journal
81 '($phrase, $opt = array()) {
82 return spip_log($phrase, \'journal\');
87 if($array == \'\' OR !array_push($array, $val)) return \'\';
93 return ((($code) AND ($arg)) ?\' \' :\'\');
98 return ((($code) OR ($arg)) ?\' \' :\'\');
103 return ((($code) XOR ($arg)) ?\' \' :\'\');
108 return (($code) ?\'\' :\' \');
113 return (($code) ?\' \' :\'\');
121 return spip_fetch_array($res);
125 '($res, $serveur=\'\') {
126 return spip_query($res);
129 // n'existe pas en 1.9.2
131 '($res, $serveur=\'\') {
132 return spip_query(\'ALTER \' . $res);
135 // n'existe pas en 1.9.2
136 // on cree la requete directement
138 '($table, $where=\'\', $serveur=\'\') {
139 if (!is_array($table)) $table = array($table);
140 if (!is_array($where)) $where = array($where);
141 $query = \'DELETE FROM \'
142 . implode(\',\', $table)
144 . implode(\' AND \', $where);
145 return spip_query($query);
148 // sql_quote : _q directement
168 return spip_abstract_select(
193 return sql_fetch(sql_select(
226 return $r ? $r[$select] : NULL;
250 if (!$q) return array();
252 while ($r = sql_fetch($q)) $res[] = $r;
256 // n'existe pas en 1.9.2
257 // on cree la requete directement
266 if (!is_array($table)) $table = array($table);
267 if (!is_array($champs)) $champs = array($champs);
268 if (!is_array($where)) $where = array($where);
271 foreach ($champs as $champ => $val)
272 $r .= \',\' . $champ . "=$val";
273 if ($r = substr($r, 1))
275 . implode(\',\', $table)
277 . (empty($where) ? \'\' :\' WHERE \' . implode(\' AND \', $where));
279 return spip_query($query);
290 if (!is_array($champs)) $exp = array($champs);
292 foreach ($champs as $k => $val) {
293 $champs[$k] = sql_quote($val);
306 // n'existe pas en 1.9.2
307 // on cree la requete directement
313 if (!is_array($champs)) $exp = array($champs);
315 foreach ($champs as $k => $val) {
316 $champs[$k] = sql_quote($val);
319 $query = "INSERT INTO $table (".implode(",", array_keys($champs)).") VALUES (".implode(",", $champs).")";
320 return sql_query($query);
323 'sql_showtable' => '($table, $serveur=\'\') {
324 include_spip("base/abstract_sql");
325 return spip_abstract_showtable($table, \'mysql\', true);
334 return spip_mysql_count($res);
347 return(sql_getfetsel(\'COUNT(*)\', $from, $where, $groupby, \'\', $limit, $having, $serveur));
355 $GLOBALS[\'spip_mysql_db\'] = mysql_select_db($res);
356 return $GLOBALS[\'spip_mysql_db\'];