| 598 | ddelon | 1 | <?php
 | 
        
           |  |  | 2 | /*vim: set expandtab tabstop=4 shiftwidth=4: */
 | 
        
           |  |  | 3 | // +------------------------------------------------------------------------------------------------------+
 | 
        
           |  |  | 4 | // | PHP version 4.1                                                                                      |
 | 
        
           |  |  | 5 | // +------------------------------------------------------------------------------------------------------+
 | 
        
           |  |  | 6 | // | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org)                                         |
 | 
        
           |  |  | 7 | // +------------------------------------------------------------------------------------------------------+
 | 
        
           |  |  | 8 | // | This library is free software; you can redistribute it and/or                                        |
 | 
        
           |  |  | 9 | // | modify it under the terms of the GNU Lesser General Public                                           |
 | 
        
           |  |  | 10 | // | License as published by the Free Software Foundation; either                                         |
 | 
        
           |  |  | 11 | // | version 2.1 of the License, or (at your option) any later version.                                   |
 | 
        
           |  |  | 12 | // |                                                                                                      |
 | 
        
           |  |  | 13 | // | This library is distributed in the hope that it will be useful,                                      |
 | 
        
           |  |  | 14 | // | but WITHOUT ANY WARRANTY; without even the implied warranty of                                       |
 | 
        
           |  |  | 15 | // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU                                    |
 | 
        
           |  |  | 16 | // | Lesser General Public License for more details.                                                      |
 | 
        
           |  |  | 17 | // |                                                                                                      |
 | 
        
           |  |  | 18 | // | You should have received a copy of the GNU Lesser General Public                                     |
 | 
        
           |  |  | 19 | // | License along with this library; if not, write to the Free Software                                  |
 | 
        
           |  |  | 20 | // | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                            |
 | 
        
           |  |  | 21 | // +------------------------------------------------------------------------------------------------------+
 | 
        
           | 954 | florian | 22 | // CVS : $Id: iw_admin_wikini.fonct.php,v 1.5 2006-09-21 14:18:06 florian Exp $
 | 
        
           | 598 | ddelon | 23 | /**
 | 
        
           |  |  | 24 | * Application gérant les Wikini associe à Papyrus
 | 
        
           |  |  | 25 | *
 | 
        
           |  |  | 26 | * Cette application permet de gérer les parametre des wikini associés à l'ensemble d'un papyrus
 | 
        
           |  |  | 27 | * TODO : Gestion mise a jour wakka.config.php !!!!!
 | 
        
           |  |  | 28 | * TODO : afficher les utilisations par les menus.
 | 
        
           |  |  | 29 | * TODO : synchronisation FTP ? .... : creation, suppression, liste (renommer ???)
 | 
        
           |  |  | 30 | * TODO : chemin vers le wikini ... (non, calcul en fonction du code alpha) , mais controles ? Pas dans un
 | 
        
           |  |  | 31 | * premier temps ...
 | 
        
           |  |  | 32 | * TODO : installation des wikini (tables présentes etc, et gestion ... (suppression ...)
 | 
        
           | 954 | florian | 33 | * TODO : un wiki par défaut pour chaque papyrus, ce wiki sert de modèle
 | 
        
           | 598 | ddelon | 34 | *
 | 
        
           |  |  | 35 | *@package Admin_Wikini
 | 
        
           |  |  | 36 | //Auteur original :
 | 
        
           |  |  | 37 | *@author        David Delon <david.delon@clapas.net>
 | 
        
           |  |  | 38 | *@copyright     Tela-Botanica 2000-2005
 | 
        
           | 954 | florian | 39 | *@version       $Revision: 1.5 $
 | 
        
           | 598 | ddelon | 40 | // +------------------------------------------------------------------------------------------------------+
 | 
        
           |  |  | 41 | */
 | 
        
           |  |  | 42 |   | 
        
           |  |  | 43 |   | 
        
           |  |  | 44 | // +------------------------------------------------------------------------------------------------------+
 | 
        
           |  |  | 45 | // |                                            ENTÊTE du PROGRAMME                                       |
 | 
        
           |  |  | 46 | // +------------------------------------------------------------------------------------------------------+
 | 
        
           |  |  | 47 | /** Inclusion du fichier de configuration de cette application.*/
 | 
        
           | 857 | florian | 48 | require_once PAP_CHEMIN_RACINE.'client/integrateur_wikini/configuration/adwi_configuration.inc.php';
 | 
        
           | 598 | ddelon | 49 |   | 
        
           |  |  | 50 | //Utilisation de la bibliothèque PEAR NET_URL
 | 
        
           |  |  | 51 |   | 
        
           |  |  | 52 | /** Inclusion de la bibliothèque PEAR de conception de formulaire.*/
 | 
        
           |  |  | 53 | require_once ADWI_CHEMIN_BIBLIOTHEQUE_PEAR.'HTML/QuickForm.php';
 | 
        
           |  |  | 54 | require_once ADWI_CHEMIN_BIBLIOTHEQUE_PEAR.'HTML/QuickForm/select.php';
 | 
        
           |  |  | 55 |   | 
        
           |  |  | 56 | /** Inclusion de l'API de fonctions gérant les erreurs sql.*/
 | 
        
           |  |  | 57 | require_once ADWI_CHEMIN_BIBLIOTHEQUE_API.'debogage/BOG_sql.fonct.php';
 | 
        
           |  |  | 58 |   | 
        
           |  |  | 59 | /** Inclusion des fonctions de manipulation du sql.
 | 
        
           |  |  | 60 | * Permet la récupération d'un nouvel identifiant d'une table.*/
 | 
        
           |  |  | 61 | require_once ADWI_CHEMIN_BIBLIOTHEQUE_API.'sql/SQL_manipulation.fonct.php';
 | 
        
           |  |  | 62 |   | 
        
           |  |  | 63 | require_once ADWI_CHEMIN_BIBLIOTHEQUE_API.'html/HTML_TableFragmenteur.php' ;
 | 
        
           |  |  | 64 |   | 
        
           |  |  | 65 | require_once ADWI_CHEMIN_BIBLIOTHEQUE.'adwi_wikini.fonct.php';
 | 
        
           |  |  | 66 |   | 
        
           |  |  | 67 | require_once ADWI_CHEMIN_BIBLIOTHEQUE.'adwi_HTML_formulaireWikini.class.php' ;
 | 
        
           |  |  | 68 |   | 
        
           |  |  | 69 |   | 
        
           |  |  | 70 | // Inclusion des fichiers de traduction de l'appli ADME dePapyrus
 | 
        
           |  |  | 71 | if (file_exists(ADWI_CHEMIN_LANGUE.'adwi_langue_'.$GLOBALS['_GEN_commun']['i18n'].'.inc.php')) {
 | 
        
           |  |  | 72 |     /** Inclusion du fichier de traduction suite à la transaction avec le navigateur.*/
 | 
        
           |  |  | 73 |     require_once ADWI_CHEMIN_LANGUE.'adwi_langue_'.$GLOBALS['_GEN_commun']['i18n'].'.inc.php';
 | 
        
           |  |  | 74 | } else {
 | 
        
           |  |  | 75 |     /** Inclusion du fichier de traduction par défaut.*/
 | 
        
           |  |  | 76 |     require_once ADWI_CHEMIN_LANGUE.'adwi_langue_'.ADWI_I18N_DEFAUT.'.inc.php';
 | 
        
           |  |  | 77 | }
 | 
        
           |  |  | 78 |   | 
        
           |  |  | 79 |   | 
        
           |  |  | 80 | // +------------------------------------------------------------------------------------------------------+
 | 
        
           |  |  | 81 | // |                                            CORPS du PROGRAMME                                        |
 | 
        
           |  |  | 82 | // +------------------------------------------------------------------------------------------------------+
 | 
        
           |  |  | 83 |   | 
        
           |  |  | 84 | function admin_afficherContenuCorpsHTML() {
 | 
        
           |  |  | 85 | 	return admin_afficherContenuCorps();
 | 
        
           |  |  | 86 | }
 | 
        
           |  |  | 87 |   | 
        
           |  |  | 88 | function admin_afficherContenuCorps()
 | 
        
           |  |  | 89 | {
 | 
        
           |  |  | 90 | /* Gestion de Deux "écrans" et des actions associées : liste des Wikini en base de donnees et ajout-modification
 | 
        
           |  |  | 91 |  * d'un Wikini
 | 
        
           |  |  | 92 |  */
 | 
        
           |  |  | 93 |     $db = &$GLOBALS['_GEN_commun']['pear_db'] ;
 | 
        
           |  |  | 94 |     $url = $GLOBALS['_GEN_commun']['url'] ;
 | 
        
           |  |  | 95 |     $auth = &$GLOBALS['_GEN_commun']['pear_auth'] ;
 | 
        
           |  |  | 96 |   | 
        
           |  |  | 97 |     isset ($GLOBALS['action']) ? '' : $GLOBALS['action'] = '' ; // On déclare action si elle n'existe pas
 | 
        
           |  |  | 98 |   | 
        
           |  |  | 99 |     if (!$auth->getAuth()) {
 | 
        
           |  |  | 100 |         return 'Identifiez-vous' ;
 | 
        
           |  |  | 101 |     }
 | 
        
           |  |  | 102 |   | 
        
           |  |  | 103 |     // Le lien pour une nouvelle entrée
 | 
        
           |  |  | 104 |     $res = '<a href="'.$url->getURL().'&action=nouveau">'.ADWI_AJOUTER.'</a>'."\n<br />" ;
 | 
        
           |  |  | 105 |   | 
        
           |  |  | 106 |   | 
        
           |  |  | 107 |     // traitement de la suppression
 | 
        
           |  |  | 108 |     if (isset ($GLOBALS['action']) && $GLOBALS['action'] == 'supprimer') adwi_supprimer_wikini($GLOBALS['id_wikini'], $db) ;
 | 
        
           |  |  | 109 |   | 
        
           |  |  | 110 |     // traitement de l'ajout et de la modification de la ligne selectionnée
 | 
        
           |  |  | 111 |   | 
        
           |  |  | 112 |     if (isset ($GLOBALS['action']) || isset ($GLOBALS['id_wikini'])) {
 | 
        
           |  |  | 113 |   | 
        
           |  |  | 114 |         $formulaire = new HTML_formulaireWikini('formulaire_wikini', '', str_replace ('&', '&', $url->getURL())) ;
 | 
        
           |  |  | 115 |         $formulaire->construitFormulaire($url) ;
 | 
        
           |  |  | 116 |   | 
        
           |  |  | 117 |         // C'est une demande d'ajout : Affichage du masque de saisie et ajout d'un champs caché avec action=nouveau_v
 | 
        
           |  |  | 118 |   | 
        
           |  |  | 119 |         if ($GLOBALS['action'] == 'nouveau') {
 | 
        
           |  |  | 120 |             $formulaire->addElement ('hidden', 'action', 'nouveau_v') ;
 | 
        
           |  |  | 121 |             return $formulaire->toHTML() ;
 | 
        
           |  |  | 122 |         }
 | 
        
           |  |  | 123 |   | 
        
           |  |  | 124 |         // C'est une demande de modification : Affichage du masque de saisie et ajout d'un champs caché avec action=modifier_v
 | 
        
           |  |  | 125 |   | 
        
           |  |  | 126 |         if (isset ($GLOBALS['id_wikini']) && $GLOBALS['action'] != 'modifier_v' && $GLOBALS['action'] != 'supprimer') {
 | 
        
           |  |  | 127 |             $formulaire->addElement ('hidden', 'action', 'modifier_v') ;
 | 
        
           |  |  | 128 |             $formulaire->addElement ('hidden', 'id_wikini', $GLOBALS['id_wikini']) ;
 | 
        
           |  |  | 129 |             $formulaire->setDefaults(adwi_valeurs_par_defaut($GLOBALS['id_wikini'], $db)) ;
 | 
        
           |  |  | 130 |             return $formulaire->toHTML() ;
 | 
        
           |  |  | 131 |         }
 | 
        
           |  |  | 132 |   | 
        
           |  |  | 133 |         // Enregistrement de la modification et retour à la liste
 | 
        
           |  |  | 134 |   | 
        
           |  |  | 135 |         if ($GLOBALS['action'] == 'modifier_v') {
 | 
        
           |  |  | 136 |             if ($formulaire->validate()) {
 | 
        
           |  |  | 137 |                 mise_a_jour ($formulaire->getSubmitValues(), $db) ;
 | 
        
           |  |  | 138 |             }
 | 
        
           |  |  | 139 |         }
 | 
        
           |  |  | 140 |   | 
        
           |  |  | 141 |         // Enregistrement de l'ajout et retour à la liste
 | 
        
           |  |  | 142 |   | 
        
           |  |  | 143 |         if ($GLOBALS['action'] == 'nouveau_v') {
 | 
        
           |  |  | 144 |             if ($formulaire->validate()) {
 | 
        
           |  |  | 145 |                 insertion ($formulaire->getSubmitValues(), $db) ;
 | 
        
           |  |  | 146 |             }
 | 
        
           |  |  | 147 |         }
 | 
        
           |  |  | 148 |   | 
        
           |  |  | 149 |     }
 | 
        
           |  |  | 150 |   | 
        
           |  |  | 151 |   | 
        
           |  |  | 152 |     // Comportement par défaut
 | 
        
           |  |  | 153 |     // requete sur la table gen_wikini pour affichage de la liste des Wikini
 | 
        
           |  |  | 154 |     $requete = "select  gewi_id_wikini, gewi_code_alpha_wikini, gewi_page from gen_wikini" ;
 | 
        
           |  |  | 155 |     $resultat = $db->query ($requete) ;
 | 
        
           |  |  | 156 |     if (DB::isError ($resultat)) {
 | 
        
           |  |  | 157 |         $GLOBALS['_GEN_commun']['debogage_erreur']->gererErreur(E_USER_WARNING, "Echec de la requete : $requete<br />".$resultat->getMessage(),
 | 
        
           |  |  | 158 |                                                                         __FILE__, __LINE__, 'admin_wikini')   ;
 | 
        
           |  |  | 159 |         return ;
 | 
        
           |  |  | 160 |     }
 | 
        
           |  |  | 161 |     $liste = new HTML_TableFragmenteur () ;
 | 
        
           |  |  | 162 |     $liste->construireEntete(array (ADWI_NOM_WIKINI, ADWI_PAGE, ADWI_MODIFIER, ADWI_SUPPRIMER,ADWI_VISITER)) ;
 | 
        
           |  |  | 163 |     $tableau_wikini = array() ;
 | 
        
           |  |  | 164 |     while ($ligne = $resultat->fetchRow()) {
 | 
        
           |  |  | 165 |         $url->addQueryString ('id_wikini', $ligne[0]) ;
 | 
        
           |  |  | 166 |         array_push ($tableau_wikini, array ($ligne[1]."\n",    // Première colonne, le nom de l'application
 | 
        
           |  |  | 167 |         									$ligne[2]."\n",    // Deuxieme colonne, la page par defaut
 | 
        
           |  |  | 168 |         								  '<a href="'.$url->getURL().'">'.ADWI_MODIFIER.'</a>'."\n",
 | 
        
           |  |  | 169 |                                           '<a href="'.$url->getURL().'&action=supprimer" onclick="javascript:return confirm (\''.ADWI_SUPPRIMER.' ?\');">'.ADWI_SUPPRIMER.'</a>'."\n",
 | 
        
           |  |  | 170 |                                           '<a href="'.ADWI_CHEMIN_WIKINI.$ligne[1].'">'.ADWI_VISITER.'</a>'."\n"
 | 
        
           |  |  | 171 |                                             ));
 | 
        
           |  |  | 172 |     }
 | 
        
           |  |  | 173 |     $liste->construireListe($tableau_wikini) ;
 | 
        
           |  |  | 174 |     $res .= $liste->toHTML();
 | 
        
           |  |  | 175 |     return $res ;
 | 
        
           |  |  | 176 | }
 | 
        
           |  |  | 177 |   | 
        
           |  |  | 178 |   | 
        
           |  |  | 179 |   | 
        
           |  |  | 180 |   | 
        
           |  |  | 181 | // +------------------------------------------------------------------------------------------------------+
 | 
        
           |  |  | 182 | // |                                            PIED du PROGRAMME                                         |
 | 
        
           |  |  | 183 | // +------------------------------------------------------------------------------------------------------+
 | 
        
           |  |  | 184 |   | 
        
           |  |  | 185 |   | 
        
           |  |  | 186 |   | 
        
           |  |  | 187 | /* +--Fin du code ----------------------------------------------------------------------------------------+
 | 
        
           |  |  | 188 | *
 | 
        
           |  |  | 189 | * $Log: not supported by cvs2svn $
 | 
        
           | 954 | florian | 190 | * Revision 1.4  2006/06/02 09:12:16  florian
 | 
        
           |  |  | 191 | * ajout constante chemin
 | 
        
           |  |  | 192 | *
 | 
        
           | 857 | florian | 193 | * Revision 1.3  2006/05/10 16:02:49  ddelon
 | 
        
           |  |  | 194 | * Finition multilinguise et schizo flo
 | 
        
           |  |  | 195 | *
 | 
        
           | 841 | ddelon | 196 | * Revision 1.2  2006/04/28 12:41:26  florian
 | 
        
           |  |  | 197 | * corrections erreurs chemin
 | 
        
           |  |  | 198 | *
 | 
        
           | 832 | florian | 199 | * Revision 1.1  2005/11/14 10:14:30  ddelon
 | 
        
           |  |  | 200 | * Projets Wikini
 | 
        
           |  |  | 201 | *
 | 
        
           | 598 | ddelon | 202 | * Revision 1.7  2005/10/21 20:55:06  ddelon
 | 
        
           |  |  | 203 | * todo wikini
 | 
        
           |  |  | 204 | *
 | 
        
           |  |  | 205 | * Revision 1.6  2005/09/30 07:48:35  ddelon
 | 
        
           |  |  | 206 | * Projet Wikini
 | 
        
           |  |  | 207 | *
 | 
        
           |  |  | 208 | * Revision 1.5  2005/09/09 09:37:17  ddelon
 | 
        
           |  |  | 209 | * Integrateur Wikini et administration des Wikini
 | 
        
           |  |  | 210 | *
 | 
        
           |  |  | 211 | * Revision 1.4  2005/09/06 08:35:36  ddelon
 | 
        
           |  |  | 212 | * Integrateur Wikini et administration des Wikini
 | 
        
           |  |  | 213 | *
 | 
        
           |  |  | 214 | * Revision 1.3  2005/09/02 11:29:25  ddelon
 | 
        
           |  |  | 215 | * Integrateur Wikini et administration des Wikini
 | 
        
           |  |  | 216 | *
 | 
        
           |  |  | 217 | * Revision 1.2  2005/08/31 17:34:52  ddelon
 | 
        
           |  |  | 218 | * Integrateur Wikini et administration des Wikini
 | 
        
           |  |  | 219 | *
 | 
        
           |  |  | 220 | * Revision 1.1  2005/08/25 08:59:12  ddelon
 | 
        
           |  |  | 221 | * Integrateur Wikini et administration des Wikini
 | 
        
           |  |  | 222 | *
 | 
        
           |  |  | 223 | * Revision 1.4  2005/03/09 10:46:17  jpm
 | 
        
           |  |  | 224 | * Changement d'un nom de fichier.
 | 
        
           |  |  | 225 | *
 | 
        
           |  |  | 226 | * Revision 1.3  2005/03/09 10:40:26  alex
 | 
        
           |  |  | 227 | * version initiale
 | 
        
           |  |  | 228 | *
 | 
        
           |  |  | 229 | * Revision 1.2  2005/02/28 10:32:59  jpm
 | 
        
           |  |  | 230 | * Changement de nom de dossier.
 | 
        
           |  |  | 231 | *
 | 
        
           |  |  | 232 | * Revision 1.1  2004/12/13 18:07:19  alex
 | 
        
           |  |  | 233 | * version initiale
 | 
        
           |  |  | 234 | *
 | 
        
           |  |  | 235 | *
 | 
        
           |  |  | 236 | * +-- Fin du code ----------------------------------------------------------------------------------------+
 | 
        
           |  |  | 237 | */
 | 
        
           |  |  | 238 | ?>
 |