source: trunk/spip/esqueleto-redcta/plugins/magusine/base/arty_init.php @ 80

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

el plugin completo

  • Property svn:executable set to *
File size: 2.0 KB
Line 
1<?php
2
3function arty_install($action){
4 switch ($action)
5 {  // La base est deja cree ?
6    case 'test':
7       // Verifier que le champ id_mon_plugin est present...
8       include_spip('base/abstract_sql');
9       $desc = spip_abstract_showtable("spip_arty_themeassoc", '', true);
10       return (isset($desc['field']['id']));
11       break;
12     // Installer la base
13     case 'install':
14       include_spip('base/create');  // definir la fonction
15       include_spip('base/tables_magusine'); // definir sa structure
16       creer_base();
17       // entre les gabarits dans la db
18       demarre_magusine();
19       break;
20     // Supprimer la base
21     case 'uninstall':
22     // liste des tables à supprimer
23       spip_query("DROP TABLE spip_arty_themeassoc");
24       break;
25  }
26}
27
28function demarre_magusine() {
29include_spip('inc/xml-parser');
30
31  $resultat=spip_query("SELECT * FROM spip_arty_themeassoc WHERE type='rubrique' AND id = 0");
32  if(!spip_num_rows($resultat)) {
33        spip_query("INSERT INTO spip_arty_themeassoc (theme, id, type) VALUES ('emilio', 0, 'rubrique')");
34  }
35 
36        $gabarits=array();
37        $ignore_liste=array(".","..",".DS_Store");
38        $rep = _DIR_PLUGIN_ARTY."definitions-gabarits";
39        $handle = opendir($rep);
40        while($fichier = readdir($handle)) {
41      if (!in_array($fichier, $ignore_liste) && eregi('^[a-zA-Z0-9_-]*\.xml$',$fichier)) {
42     
43        $p =& new xmlParser();
44                $p->parse(_DIR_PLUGIN_ARTY.'definitions-gabarits/'.$fichier);
45 
46                 foreach($p->output[0]['child'] as $ordre => $bloc) {
47                       
48                 $resultat = spip_query("SELECT * FROM spip_arty_gabarit_ordre WHERE nom='".$bloc['content']."' AND gabarit='".addslashes(ereg_replace("\.xml$", "", $fichier))."'");
49                       
50                        if (!spip_num_rows($resultat)) {
51                                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'])."')");
52                        }
53                 }
54                }
55} 
56}
57
58
59?>
60
Note: See TracBrowser for help on using the repository browser.