source: trunk/spip/2.1/extensions/magusine-portage2.1/base/arty_init.php @ 756

Last change on this file since 756 was 756, checked in by guillermoacedo@…, 14 years ago

se agrego la correccion de magusine para 2.1 basica

  • Property svn:executable set to *
File size: 2.4 KB
Line 
1<?php
2/***************************************************************************\
3 Plugin   : magusine
4 Licence  : GPL
5 Auteurs  : Stéphane Noël, Philippe Vanderlinden
6 Infos    : http://www.spip-contrib.net/Le-plugin-Magusine
7            http://www.magunews.net/spip.php?rubrique645
8
9 $LastChangedRevision: 12345 $
10 $LastChangedBy: bubu $
11 $LastChangedDate: 2008-03-21 15:50:47 +0100 (ven, 21 mar 2008) $
12 \***************************************************************************/
13
14function arty_install($action){
15        switch ($action)
16        {  // La base est deja cree ?
17                case 'test':
18                        // Verifier que le champ id_mon_plugin est present...
19                        include_spip('base/abstract_sql');
20                        $desc = sql_showtable("spip_arty_themeassoc", false, '', true);
21                        return (isset($desc['field']['id']));
22                        break;
23                        // Installer la base
24                case 'install':
25                        include_spip('base/create');  // definir la fonction
26                        include_spip('base/tables_magusine'); // definir sa structure
27                        creer_base();
28                        // entre les gabarits dans la db
29                        demarre_magusine();
30                        break;
31                        // Supprimer la base
32                case 'uninstall':
33                        // liste des tables à supprimer
34                        spip_query("DROP TABLE spip_arty_themeassoc");
35                        break;
36        }
37}
38
39function demarre_magusine() {
40        include_spip('inc/xml-parser');
41
42        $resultat=spip_query("SELECT * FROM spip_arty_themeassoc WHERE type='rubrique' AND id = 0");
43        if(!spip_mysql_count($resultat)) {
44                spip_query("INSERT INTO spip_arty_themeassoc (theme, id, type) VALUES ('emilio', 0, 'rubrique')");
45        }
46
47        $gabarits=array();
48        $ignore_liste=array(".","..",".DS_Store");
49        $rep = _DIR_PLUGIN_ARTY."definitions-gabarits";
50        $handle = opendir($rep);
51        while($fichier = readdir($handle)) {
52                if (!in_array($fichier, $ignore_liste) && eregi('^[a-zA-Z0-9_-]*\.xml$',$fichier)) {
53
54                        $p =& new xmlParser();
55                        $p->parse(_DIR_PLUGIN_ARTY.'definitions-gabarits/'.$fichier);
56
57                 foreach($p->output[0]['child'] as $ordre => $bloc) {
58
59                        $resultat = spip_query("SELECT * FROM spip_arty_gabarit_ordre WHERE nom='".$bloc['content']."' AND gabarit='".addslashes(ereg_replace("\.xml$", "", $fichier))."'");
60
61                        if (!spip_mysql_count($resultat)) {
62                                spip_query("INSERT INTO spip_arty_gabarit_ordre (nom, ordre, conteneur ,gabarit, param) VALUES ('".$bloc['content']."', $ordre, ".addslashes($bloc['attrs']['STATUT'])." , '".addslashes(ereg_replace("\.xml$", "", $fichier))."', '".addslashes($bloc['attrs']['PARAMDEFAUT'])."')");
63                        }
64                 }
65                }
66        }
67}
68
69
70?>
71
Note: See TracBrowser for help on using the repository browser.