| 437 | 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 | // +------------------------------------------------------------------------------------------------------+
 | 
        
           | 1293 | neiluj | 22 | // CVS : $Id: integrateur_wikini.admin.php,v 1.7 2007-04-06 08:40:13 neiluj Exp $
 | 
        
           | 437 | ddelon | 23 | /**
 | 
        
           |  |  | 24 | * Gestion des Wikini associé à un menu pour papyrus : lit et stocke les informations dans la
 | 
        
           |  |  | 25 | * champs gm_application_arguments de la table gen_menu
 | 
        
           |  |  | 26 | *
 | 
        
           |  |  | 27 | * Principe :
 | 
        
           |  |  | 28 | * Lecture arguments, decodage et affichage : Nom Wiki et Page Demarrage
 | 
        
           |  |  | 29 | * Affichage de l'ensemble des Wiki Disponible (avec leur page par Defaut)
 | 
        
           |  |  | 30 | * Choix d'un wiki
 | 
        
           |  |  | 31 | * Mise à jour
 | 
        
           |  |  | 32 | *
 | 
        
           |  |  | 33 | * TODO : gerer le defaut sur demmarage
 | 
        
           |  |  | 34 | *
 | 
        
           |  |  | 35 | *        ------------                   --------------
 | 
        
           |  |  | 36 | * Wiki : |          | Page Principale : |            |
 | 
        
           |  |  | 37 | *        ------------                   --------------
 | 
        
           |  |  | 38 | *
 | 
        
           |  |  | 39 | * Fragmenteur choix (selection uniquement)
 | 
        
           |  |  | 40 | *
 | 
        
           |  |  | 41 | * --------------------------------------
 | 
        
           | 1293 | neiluj | 42 | * | Nom Wiki         | Page Demmarage   |
 | 
        
           | 437 | ddelon | 43 | * --------------------------------------
 | 
        
           |  |  | 44 | * | Wikini_01        |                  |
 | 
        
           |  |  | 45 | * ---------------------------------------
 | 
        
           |  |  | 46 | * | Wikini_02        | ChatMot          |
 | 
        
           |  |  | 47 | * ---------------------------------------
 | 
        
           |  |  | 48 | *
 | 
        
           |  |  | 49 | * Valider - Annuler
 | 
        
           |  |  | 50 | *
 | 
        
           |  |  | 51 | *
 | 
        
           |  |  | 52 | *@package IntegrateurWikini
 | 
        
           |  |  | 53 | //Auteur original :
 | 
        
           |  |  | 54 | *@author        David Delon <david.delon@clapas.net>
 | 
        
           |  |  | 55 | *@copyright     Tela-Botanica 2000-2004
 | 
        
           | 1293 | neiluj | 56 | *@version       $Revision: 1.7 $ $Date: 2007-04-06 08:40:13 $
 | 
        
           | 437 | ddelon | 57 | // +------------------------------------------------------------------------------------------------------+
 | 
        
           |  |  | 58 | */
 | 
        
           |  |  | 59 |   | 
        
           | 438 | ddelon | 60 |   | 
        
           | 437 | ddelon | 61 | // +------------------------------------------------------------------------------------------------------+
 | 
        
           |  |  | 62 | // |                                            ENTÊTE du PROGRAMME                                       |
 | 
        
           |  |  | 63 | // +------------------------------------------------------------------------------------------------------+
 | 
        
           | 442 | ddelon | 64 | // TODO GEN_GER_STYLE !!!
 | 
        
           |  |  | 65 | //GEN_stockerStyleExterne('afficheur', AFFI_CHEMIN_STYLE.'afficheur.css');
 | 
        
           | 437 | ddelon | 66 | // +------------------------------------------------------------------------------------------------------+
 | 
        
           |  |  | 67 | // |                                                 CLASSE                                               |
 | 
        
           |  |  | 68 | // +------------------------------------------------------------------------------------------------------+
 | 
        
           |  |  | 69 |   | 
        
           |  |  | 70 | /** Inclusion du fichier de configuration de cette application.*/
 | 
        
           | 832 | florian | 71 | require_once 'configuration/adwi_configuration.inc.php';
 | 
        
           | 437 | ddelon | 72 |   | 
        
           |  |  | 73 |   | 
        
           |  |  | 74 | /** Inclusion de l'API de fonctions gérant les erreurs sql.*/
 | 
        
           |  |  | 75 | require_once ADWI_CHEMIN_BIBLIOTHEQUE_API.'debogage/BOG_sql.fonct.php';
 | 
        
           |  |  | 76 |   | 
        
           |  |  | 77 | require_once ADWI_CHEMIN_BIBLIOTHEQUE_API.'html/HTML_TableFragmenteur.php' ;
 | 
        
           |  |  | 78 |   | 
        
           |  |  | 79 | require_once ADWI_CHEMIN_BIBLIOTHEQUE.'adwi_wikini.fonct.php';
 | 
        
           |  |  | 80 |   | 
        
           |  |  | 81 | // Inclusion des fichiers de traduction de l'appli ADWI dePapyrus
 | 
        
           |  |  | 82 | if (file_exists(ADWI_CHEMIN_LANGUE.'adwi_langue_'.$GLOBALS['_GEN_commun']['i18n'].'.inc.php')) {
 | 
        
           |  |  | 83 |     /** Inclusion du fichier de traduction suite à la transaction avec le navigateur.*/
 | 
        
           |  |  | 84 |     require_once ADWI_CHEMIN_LANGUE.'adwi_langue_'.$GLOBALS['_GEN_commun']['i18n'].'.inc.php';
 | 
        
           |  |  | 85 | } else {
 | 
        
           |  |  | 86 |     /** Inclusion du fichier de traduction par défaut.*/
 | 
        
           |  |  | 87 |     require_once ADWI_CHEMIN_LANGUE.'adwi_langue_'.ADWI_I18N_DEFAUT.'.inc.php';
 | 
        
           |  |  | 88 | }
 | 
        
           |  |  | 89 |   | 
        
           |  |  | 90 |   | 
        
           |  |  | 91 | class Integrateur_Wikini_Admin {
 | 
        
           |  |  | 92 |   | 
        
           |  |  | 93 |     /** Fonction redigerContenu() - Affiche le formulaire de rédaction
 | 
        
           |  |  | 94 |     *
 | 
        
           |  |  | 95 |     *
 | 
        
           |  |  | 96 |     *   @return  string  Le HTML
 | 
        
           |  |  | 97 |     */
 | 
        
           |  |  | 98 |     function afficherContenuCorps()
 | 
        
           |  |  | 99 |     {
 | 
        
           | 438 | ddelon | 100 |   | 
        
           |  |  | 101 |   | 
        
           |  |  | 102 |         $res='';
 | 
        
           |  |  | 103 |   | 
        
           | 437 | ddelon | 104 | 	    $db = &$GLOBALS['_GEN_commun']['pear_db'] ;
 | 
        
           |  |  | 105 | 	    $url = $GLOBALS['_GEN_commun']['url'] ;
 | 
        
           |  |  | 106 | 	    $auth = &$GLOBALS['_GEN_commun']['pear_auth'] ;
 | 
        
           |  |  | 107 |   | 
        
           | 438 | ddelon | 108 | 	    $url_origine=$url;
 | 
        
           |  |  | 109 |   | 
        
           |  |  | 110 | 	    $url->addQueryString('adme_site_id',  $_GET['adme_site_id']);
 | 
        
           |  |  | 111 |         $url->addQueryString('adme_menu_id', $_GET['adme_menu_id']);
 | 
        
           |  |  | 112 |         $url->addQueryString('adme_action', $_GET['adme_action']);
 | 
        
           |  |  | 113 |   | 
        
           |  |  | 114 |   | 
        
           |  |  | 115 |         // Recherche parametres menu actif : ils ne sont pas present dans le contexte, quel dommage !
 | 
        
           |  |  | 116 |   | 
        
           |  |  | 117 |        $requete_menu =  'SELECT gen_menu.* '.
 | 
        
           |  |  | 118 |                         'FROM gen_menu '.
 | 
        
           |  |  | 119 |                         'WHERE gm_id_menu = '.$_GET['adme_menu_id'];
 | 
        
           |  |  | 120 |   | 
        
           |  |  | 121 |        $resultat_menu = $db->query($requete_menu);
 | 
        
           |  |  | 122 |        (DB::isError($resultat_menu))
 | 
        
           | 832 | florian | 123 |          ? die(BOG_afficherErreurSql(__FILE__, __LINE__, $resultat->getMessage(), $requete_menu))
 | 
        
           | 438 | ddelon | 124 |     	   : '';
 | 
        
           |  |  | 125 |              $info_menu = $resultat_menu->fetchRow(DB_FETCHMODE_OBJECT);
 | 
        
           |  |  | 126 |   | 
        
           |  |  | 127 |        $resultat_menu->free();
 | 
        
           |  |  | 128 |   | 
        
           |  |  | 129 | 		if (isset($info_menu->gm_application_arguments)) {
 | 
        
           |  |  | 130 |     		$arguments = explode(' ', $info_menu->gm_application_arguments);
 | 
        
           |  |  | 131 |   | 
        
           |  |  | 132 | 	    	for ($i = 0; $i < count($arguments); $i++) {
 | 
        
           |  |  | 133 | 	        	$attr = explode('=', $arguments[$i]);
 | 
        
           |  |  | 134 | 	        	if ($attr[0] != '') {
 | 
        
           |  |  | 135 | 	            	$info_application->$attr[0] = (isset($attr[1]) ? $attr[1] : '');
 | 
        
           |  |  | 136 | 	        	}
 | 
        
           |  |  | 137 | 	    	}
 | 
        
           |  |  | 138 | 		}
 | 
        
           |  |  | 139 |   | 
        
           |  |  | 140 |   | 
        
           | 437 | ddelon | 141 | 	    isset ($GLOBALS['action']) ? '' : $GLOBALS['action'] = '' ; // On déclare action si elle n'existe pas
 | 
        
           |  |  | 142 |   | 
        
           |  |  | 143 | 	    if (!$auth->getAuth()) {
 | 
        
           |  |  | 144 | 	        return 'Identifiez-vous' ;
 | 
        
           |  |  | 145 | 	    }
 | 
        
           | 438 | ddelon | 146 |   | 
        
           |  |  | 147 |   | 
        
           |  |  | 148 | 		//  Mise à jour ?
 | 
        
           |  |  | 149 | 		if (isset ($GLOBALS['action'])) {
 | 
        
           |  |  | 150 |   | 
        
           |  |  | 151 |   | 
        
           |  |  | 152 |     		$arguments_menu="";
 | 
        
           |  |  | 153 |     		if ((isset($_POST['code_alpha_wikini'])) && (!empty($_POST['code_alpha_wikini']))) {
 | 
        
           |  |  | 154 |   | 
        
           |  |  | 155 |     			$arguments_menu.="wikini=".($_POST['code_alpha_wikini'])." ";
 | 
        
           |  |  | 156 |   | 
        
           |  |  | 157 |     		}
 | 
        
           |  |  | 158 |   | 
        
           |  |  | 159 |     		if ((isset($_POST['page'])) && (!empty($_POST['page']))) {
 | 
        
           |  |  | 160 |   | 
        
           |  |  | 161 |     			$arguments_menu.="page=".($_POST['page'])." ";
 | 
        
           |  |  | 162 |   | 
        
           |  |  | 163 |     		}
 | 
        
           |  |  | 164 |   | 
        
           |  |  | 165 | 	    	$requete = "update gen_menu set  gm_application_arguments = '".$arguments_menu .
 | 
        
           |  |  | 166 |     	            "' where gm_id_menu =".$_GET['adme_menu_id'];
 | 
        
           |  |  | 167 |   | 
        
           |  |  | 168 |     		$resultat = $db->query ($requete) ;
 | 
        
           |  |  | 169 |     		if (DB::isError ($resultat)) {
 | 
        
           |  |  | 170 |         			trigger_error("Echec de la requete : $requete<br />".$resultat->getMessage(),E_USER_WARNING) ;
 | 
        
           |  |  | 171 |   | 
        
           |  |  | 172 | 	        }
 | 
        
           |  |  | 173 | 		}
 | 
        
           |  |  | 174 |   | 
        
           |  |  | 175 | 		// Affichage par defaut
 | 
        
           |  |  | 176 |   | 
        
           |  |  | 177 | 		// Formulaire Selection Wiki
 | 
        
           |  |  | 178 |   | 
        
           |  |  | 179 |         $formulaire =& new HTML_QuickForm('form_selection_wiki', 'post', str_replace('&', '&', $url->getUrl()));
 | 
        
           |  |  | 180 |   | 
        
           |  |  | 181 |   | 
        
           |  |  | 182 | 		$res .= "<h2>". ADWI_TITRE_SELECTION." ".$info_menu->gm_nom."</h2";
 | 
        
           |  |  | 183 |   | 
        
           |  |  | 184 | 		$squelette =& $formulaire->defaultRenderer();
 | 
        
           |  |  | 185 |   | 
        
           |  |  | 186 | 		$squelette->setGroupTemplate('<table>{content}</table>', 'id');
 | 
        
           |  |  | 187 |   | 
        
           |  |  | 188 | 		$squelette->setGroupElementTemplate('<tr><td>{element}<!-- BEGIN required --><!-- END required-->{label}</td></tr>', 'id');
 | 
        
           |  |  | 189 |   | 
        
           |  |  | 190 |   | 
        
           |  |  | 191 | 		$formulaire->addElement ('text', 'code_alpha_wikini', ADWI_NOM_WIKINI, array ('size' => 20));
 | 
        
           |  |  | 192 | 		$formulaire->addElement ('text', 'page', ADWI_PAGE_DEMARRAGE , array ('size' => 20));
 | 
        
           |  |  | 193 |   | 
        
           |  |  | 194 |   | 
        
           |  |  | 195 |   | 
        
           |  |  | 196 |         // on fait un groupe avec les boutons pour les mettres sur la même ligne
 | 
        
           |  |  | 197 |         $buttons[] = &HTML_QuickForm::createElement('button', 'retour', ADWI_RETOUR, array ("onclick" => "javascript:document.location.href='".str_replace ('&', '&', $url_origine->getURL())."'"));
 | 
        
           |  |  | 198 |         $buttons[] = &HTML_QuickForm::createElement('submit', 'valider', ADWI_VALIDER);
 | 
        
           |  |  | 199 |         $formulaire->addGroup($buttons, null, null, ' ');
 | 
        
           |  |  | 200 |   | 
        
           |  |  | 201 |   | 
        
           |  |  | 202 | 	    // Initialisation
 | 
        
           |  |  | 203 |   | 
        
           |  |  | 204 | 	    if ((isset($_GET['id_wikini'])) && (!empty($_GET['id_wikini']))) {
 | 
        
           |  |  | 205 |   | 
        
           |  |  | 206 | 	    	$requete = "select * from gen_wikini where gewi_id_wikini=".$_GET['id_wikini'] ;
 | 
        
           |  |  | 207 |     		$resultat = $db->query ($requete) ;
 | 
        
           |  |  | 208 |     		if (DB::isError ($resultat)) {
 | 
        
           |  |  | 209 |         		trigger_error("Echec de la requete : $requete<br />".$resultat->getMessage(), E_USER_WARNING) ;
 | 
        
           |  |  | 210 |         	return ;
 | 
        
           | 487 | ddelon | 211 |     		}
 | 
        
           | 438 | ddelon | 212 |   | 
        
           | 487 | ddelon | 213 | 	    	$info_wikini = $resultat->fetchRow (DB_FETCHMODE_OBJECT) ;
 | 
        
           |  |  | 214 | 		    $formulaire->setDefaults(array('code_alpha_wikini'=>$info_wikini->gewi_code_alpha_wikini)) ;
 | 
        
           |  |  | 215 | 		    $formulaire->setDefaults(array('page'=>$info_wikini->gewi_page)) ;
 | 
        
           |  |  | 216 | 		    $resultat->free();
 | 
        
           |  |  | 217 |   | 
        
           | 438 | ddelon | 218 | 	    }
 | 
        
           |  |  | 219 | 	    else {
 | 
        
           |  |  | 220 |   | 
        
           |  |  | 221 | 			if ((isset($info_application->wikini)) && (!empty($info_application->wikini))) {
 | 
        
           |  |  | 222 | 				$formulaire->setDefaults(array('code_alpha_wikini'=>$info_application->wikini)) ;
 | 
        
           |  |  | 223 | 			}
 | 
        
           |  |  | 224 |   | 
        
           |  |  | 225 |   | 
        
           |  |  | 226 |   | 
        
           |  |  | 227 |   | 
        
           |  |  | 228 | 			if ((isset($info_application->page)) && (!empty($info_application->page))) {
 | 
        
           |  |  | 229 | 				$formulaire->setDefaults(array('page'=>$info_application->page)) ;
 | 
        
           |  |  | 230 | 			}
 | 
        
           |  |  | 231 |   | 
        
           |  |  | 232 | 	    }
 | 
        
           |  |  | 233 | 	    $res .= $formulaire->toHTML() ;
 | 
        
           |  |  | 234 |   | 
        
           |  |  | 235 | 		$res .='<br/>';
 | 
        
           |  |  | 236 |   | 
        
           |  |  | 237 | 		$res .= "<h2>". ADWI_LISTE_WIKINI.": </h2";
 | 
        
           |  |  | 238 |   | 
        
           | 437 | ddelon | 239 | 	    // Comportement par défaut
 | 
        
           |  |  | 240 | 	    // requete sur la table gen_wikini pour affichage de la liste des Wikini
 | 
        
           | 438 | ddelon | 241 | 	    $requete = "select  gewi_id_wikini, gewi_code_alpha_wikini, gewi_page from gen_wikini" ;
 | 
        
           | 437 | ddelon | 242 |   | 
        
           |  |  | 243 | 	    $resultat = $db->query ($requete) ;
 | 
        
           |  |  | 244 | 	    if (DB::isError ($resultat)) {
 | 
        
           |  |  | 245 | 	        $GLOBALS['_GEN_commun']['debogage_erreur']->gererErreur(E_USER_WARNING, "Echec de la requete : $requete<br />".$resultat->getMessage(),
 | 
        
           |  |  | 246 | 	                                                                        __FILE__, __LINE__, 'admin_wikini')   ;
 | 
        
           |  |  | 247 | 	        return ;
 | 
        
           |  |  | 248 | 	    }
 | 
        
           |  |  | 249 |   | 
        
           | 438 | ddelon | 250 |   | 
        
           | 437 | ddelon | 251 | 	    $liste = new HTML_TableFragmenteur () ;
 | 
        
           | 438 | ddelon | 252 | 	    $liste->construireEntete(array (ADWI_NOM_WIKINI,ADWI_PAGE, ADWI_SELECTIONNER)) ;
 | 
        
           |  |  | 253 |   | 
        
           | 437 | ddelon | 254 | 	    $tableau_wikini = array() ;
 | 
        
           | 438 | ddelon | 255 |   | 
        
           | 437 | ddelon | 256 | 	    while ($ligne = $resultat->fetchRow()) {
 | 
        
           |  |  | 257 | 	        $url->addQueryString ('id_wikini', $ligne[0]) ;
 | 
        
           |  |  | 258 | 	        array_push ($tableau_wikini, array ($ligne[1]."\n",    // Première colonne, le nom de l'application
 | 
        
           | 438 | ddelon | 259 | 										        $ligne[2]."\n",    // Deuxieme colonne, la page par defaut
 | 
        
           |  |  | 260 | 	        								  '<a href="'.$url->getURL()."&action=validation".'">'.ADWI_CHOISIR.'</a>'."\n",
 | 
        
           | 437 | ddelon | 261 | 	                                            ));
 | 
        
           |  |  | 262 | 	    }
 | 
        
           |  |  | 263 | 	    $liste->construireListe($tableau_wikini) ;
 | 
        
           |  |  | 264 | 	    $res .= $liste->toHTML();
 | 
        
           |  |  | 265 | 	    return $res ;
 | 
        
           |  |  | 266 |   | 
        
           |  |  | 267 |     }
 | 
        
           |  |  | 268 |   | 
        
           |  |  | 269 | }// Fin de la classe
 | 
        
           |  |  | 270 |   | 
        
           |  |  | 271 | // +------------------------------------------------------------------------------------------------------+
 | 
        
           |  |  | 272 | // |                                            PIED du PROGRAMME                                         |
 | 
        
           |  |  | 273 | // +------------------------------------------------------------------------------------------------------+
 | 
        
           |  |  | 274 |   | 
        
           |  |  | 275 |   | 
        
           |  |  | 276 | /* +--Fin du code ----------------------------------------------------------------------------------------+
 | 
        
           |  |  | 277 | *
 | 
        
           |  |  | 278 | * $Log: not supported by cvs2svn $
 | 
        
           | 1081 | florian | 279 | * Revision 1.5  2006/04/28 12:41:26  florian
 | 
        
           |  |  | 280 | * corrections erreurs chemin
 | 
        
           |  |  | 281 | *
 | 
        
           | 832 | florian | 282 | * Revision 1.4  2005/09/30 07:48:35  ddelon
 | 
        
           |  |  | 283 | * Projet Wikini
 | 
        
           |  |  | 284 | *
 | 
        
           | 487 | ddelon | 285 | * Revision 1.3  2005/09/14 09:12:15  ddelon
 | 
        
           |  |  | 286 | * Integrateur Wikini et administration des Wikini
 | 
        
           |  |  | 287 | *
 | 
        
           | 442 | ddelon | 288 | * Revision 1.2  2005/09/06 08:35:36  ddelon
 | 
        
           |  |  | 289 | * Integrateur Wikini et administration des Wikini
 | 
        
           |  |  | 290 | *
 | 
        
           | 438 | ddelon | 291 | * Revision 1.1  2005/09/02 11:29:25  ddelon
 | 
        
           |  |  | 292 | * Integrateur Wikini et administration des Wikini
 | 
        
           | 437 | ddelon | 293 | *
 | 
        
           | 438 | ddelon | 294 | *
 | 
        
           | 437 | ddelon | 295 | * +-- Fin du code ----------------------------------------------------------------------------------------+
 | 
        
           |  |  | 296 | */
 | 
        
           |  |  | 297 | ?>
 |