Subversion Repositories Applications.bazar

Compare Revisions

No changes between revisions

Ignore whitespace Rev 469 → Rev 470

/tags/v3.1-blanche-neige/upload/vide.txt
--- v3.1-blanche-neige/bazar.php (revision 0)
+++ v3.1-blanche-neige/bazar.php (revision 470)
@@ -0,0 +1,518 @@
+<?php
+/*vim: set expandtab tabstop=4 shiftwidth=4: */
+// +------------------------------------------------------------------------------------------------------+
+// | PHP version 4.1 |
+// +------------------------------------------------------------------------------------------------------+
+// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org) |
+// +------------------------------------------------------------------------------------------------------+
+// | This library is free software; you can redistribute it and/or |
+// | modify it under the terms of the GNU Lesser General Public |
+// | License as published by the Free Software Foundation; either |
+// | version 2.1 of the License, or (at your option) any later version. |
+// | |
+// | This library is distributed in the hope that it will be useful, |
+// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
+// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
+// | Lesser General Public License for more details. |
+// | |
+// | You should have received a copy of the GNU Lesser General Public |
+// | License along with this library; if not, write to the Free Software |
+// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
+// +------------------------------------------------------------------------------------------------------+
+// CVS : $Id: bazar.php,v 1.49.2.4 2008-02-04 13:10:15 alexandre_tb Exp $
+/**
+*
+*@package bazar
+//Auteur original :
+*@author Alexandre GRANIER <alexandre@tela-botanica.org>
+*@author Florian Schmitt <florian@ecole-et-nature.org>
+//Autres auteurs :
+*@copyright Tela-Botanica 2000-2004
+*@version $Revision: 1.49.2.4 $ $Date: 2008-02-04 13:10:15 $
+// +------------------------------------------------------------------------------------------------------+
+*/
+
+// +------------------------------------------------------------------------------------------------------+
+// | ENTETE du PROGRAMME |
+// +------------------------------------------------------------------------------------------------------+
+
+//error_reporting(E_ALL);
+require_once PAP_CHEMIN_API_PEAR.'DB.php' ;
+require_once PAP_CHEMIN_API_PEAR.'Auth.php' ;
+require_once 'configuration/baz_config.inc.php'; //fichier de configuration de Bazar
+require_once 'bibliotheque/bazar.class.php';
+require_once 'bibliotheque/bazar.fonct.php'; //fichier des fonctions de Bazar
+
+if (defined('PAP_VERSION')) { //si on est dans Papyrus
+ GEN_stockerStyleExterne( 'bazar_interne', 'client/bazar/bazar.interne.css');
+}
+
+//**********************************************************************************************************
+//initialisation des paramêtres papyrus
+//**********************************************************************************************************
+//si un parametre est précisé dans le gestionnaire de menus papyrus, on le prends en compte
+
+//parametre action pour lancer directement l'action indiquée
+if (!isset($_GET[BAZ_VARIABLE_ACTION])and(isset($GLOBALS['_GEN_commun']['info_application']->action))) {
+ $_GET[BAZ_VARIABLE_ACTION]=$GLOBALS['_GEN_commun']['info_application']->action;
+}
+
+//parametre vue pour afficher directement une vue
+if (!isset($_GET[BAZ_VARIABLE_VOIR])and(isset($GLOBALS['_GEN_commun']['info_application']->vue))) {
+ $_GET[BAZ_VARIABLE_VOIR]=$GLOBALS['_GEN_commun']['info_application']->vue;
+}
+
+// Si le parametre vue est vide on le positionne a 1
+if (!isset($_GET[BAZ_VARIABLE_VOIR])) {
+ $_GET[BAZ_VARIABLE_VOIR] = BAZ_VOIR_CONSULTER;
+}
+
+if(!isset($GLOBALS['_BAZAR_']['mois']))
+{
+ $GLOBALS['mois'] = array (1 => BAZ_JANVIER, 2 => BAZ_FEVRIER, 3 => BAZ_MARS, 4 => BAZ_AVRIL, 5 => BAZ_MAI, 6 => BAZ_JUIN,
+ 7 => BAZ_JUILLET, 8 => BAZ_AOUT, 9 => BAZ_SEPTEMBRE, 10 => BAZ_OCTOBRE, 11 =>BAZ_NOVEMBRE,
+ 12 => BAZ_DECEMBRE) ;
+}
+
+//parametre voir_menu pour afficher le menu ou pas (par défaut, il l'affiche)
+if ((isset($GLOBALS['_GEN_commun']['info_application']->voir_menu))and($GLOBALS['_GEN_commun']['info_application']->voir_menu==0)) {
+ $GLOBALS['_BAZAR_']['affiche_menu']=0;
+}
+else $GLOBALS['_BAZAR_']['affiche_menu']=1;
+
+//parametre categorie_nature pour préciser quels types de fiches sont montrees (par défaut, il affiche les id_menu=0)
+if (isset($GLOBALS['_GEN_commun']['info_application']->categorie_nature)) {
+ $GLOBALS['_BAZAR_']['categorie_nature']=$GLOBALS['_GEN_commun']['info_application']->categorie_nature;
+}
+elseif (isset($_REQUEST['categorie_nature'])) {
+ $GLOBALS['_BAZAR_']['categorie_nature']=$_REQUEST['categorie_nature'];
+}
+else $GLOBALS['_BAZAR_']['categorie_nature']=0;
+
+//parametre id_nature pour afficher un certain type de fiche (par défaut, tous les types de fiches)
+if (isset($GLOBALS['_GEN_commun']['info_application']->id_nature)) {
+ $GLOBALS['_BAZAR_']['id_typeannonce']=$GLOBALS['_GEN_commun']['info_application']->id_nature;
+}
+elseif (!isset($GLOBALS['_BAZAR_']['typeannonce'])) $GLOBALS['_BAZAR_']['typeannonce']='toutes';
+
+
+//**********************************************************************************************************
+//initialisation de la variable globale de bazar
+//**********************************************************************************************************
+$GLOBALS['id_user']=$GLOBALS['AUTH']->getAuthData(BAZ_CHAMPS_ID);
+
+//Recuperer les eventuelles variables passees en GET ou en POST
+if (isset($_REQUEST['id_fiche'])) {
+ $GLOBALS['_BAZAR_']['id_fiche'] = $_REQUEST['id_fiche'];
+ // récupération du type d'annonce à partir de la fiche
+ $requete = 'select bf_ce_nature from bazar_fiche where bf_id_fiche='.$_REQUEST['id_fiche'] ;
+ $resultat = $GLOBALS['_BAZAR_']['db']->query ($requete) ;
+ if (DB::isError($resultat)) {
+ die ($resultat->getMessage().$resultat->getDebugInfo()) ;
+ }
+ $ligne = $resultat->fetchRow(DB_FETCHMODE_OBJECT) ;
+ $GLOBALS['_BAZAR_']['id_typeannonce'] = $ligne->bf_ce_nature ;
+ $resultat->free();
+}
+
+if (isset($_REQUEST['typeannonce']) && $_REQUEST['typeannonce'] != '1,2,3,4') {
+
+ $GLOBALS['_BAZAR_']['id_typeannonce'] = $_REQUEST['typeannonce'];
+}
+else
+{
+ $GLOBALS['_BAZAR_']['id_typeannonce'] = 'toutes' ;
+}
+
+if (isset($_REQUEST['liste31'])) {
+
+ if($_REQUEST['liste31'] == "0")
+ {
+ $GLOBALS['_BAZAR_']['id_typeannonce']= 'toutes' ;
+ }
+ else
+ {
+ $GLOBALS['_BAZAR_']['id_typeannonce']= $_REQUEST['liste31'];
+ }
+}
+else
+{
+ $GLOBALS['_BAZAR_']['id_typeannonce'] = 'toutes' ;
+}
+
+if ((isset($GLOBALS['_BAZAR_']['id_typeannonce']))and($GLOBALS['_BAZAR_']['id_typeannonce']!='toutes')) {
+
+ $typeAnnonce = false;
+
+ $requete = 'SELECT bn_label_nature, bn_condition, bn_template, bn_commentaire, bn_appropriation, bn_image_titre, bn_image_logo '.
+ 'FROM bazar_nature ';
+ if (isset($GLOBALS['_BAZAR_']['id_typeannonce']) && !empty($GLOBALS['_BAZAR_']['id_typeannonce']) && isset($GLOBALS['_BAZAR_']['id_typeannonce']) != 'toutes') {
+ $requete .= 'WHERE bn_id_nature = '.$GLOBALS['_BAZAR_']['id_typeannonce'];
+ $typeAnnonce = true;
+ }
+ if (isset($GLOBALS['_BAZAR_']['langue'])) {
+ if (!$typeAnnonce) {
+ $requete .= ' WHERE ';
+ } else {
+ $requete .= ' AND ';
+ }
+ $requete .= 'bn_ce_i18n like "'.$GLOBALS['_BAZAR_']['langue'].'%"';
+ }
+ $resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
+ if (DB::isError($resultat)) {
+ die ($resultat->getMessage().$resultat->getDebugInfo()) ;
+ }
+ $ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC);
+ $GLOBALS['_BAZAR_']['typeannonce']=$ligne['bn_label_nature'];
+ $GLOBALS['_BAZAR_']['condition']=$ligne['bn_condition'];
+ $GLOBALS['_BAZAR_']['template']=$ligne['bn_template'];
+ $GLOBALS['_BAZAR_']['commentaire']=$ligne['bn_commentaire'];
+ $GLOBALS['_BAZAR_']['appropriation']=$ligne['bn_appropriation'];
+ $GLOBALS['_BAZAR_']['image_titre']=$ligne['bn_image_titre'];
+ $GLOBALS['_BAZAR_']['image_logo']=$ligne['bn_image_logo'];
+}
+else
+{
+ $requete = 'SELECT bn_label_nature, bn_condition, bn_template, bn_commentaire, bn_appropriation, bn_image_titre, bn_image_logo '.
+ 'FROM bazar_nature ';
+ $requete .= 'WHERE bn_id_nature = 1';
+ $typeAnnonce = true;
+
+ if (isset($GLOBALS['_BAZAR_']['langue'])) {
+ if (!$typeAnnonce) {
+ $requete .= ' WHERE ';
+ } else {
+ $requete .= ' AND ';
+ }
+ $requete .= 'bn_ce_i18n like "'.$GLOBALS['_BAZAR_']['langue'].'%"';
+ }
+ $resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
+ if (DB::isError($resultat)) {
+ die ($resultat->getMessage().$resultat->getDebugInfo()) ;
+ }
+ $ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC);
+ $GLOBALS['_BAZAR_']['typeannonce']= 'toutes' ;
+ $GLOBALS['_BAZAR_']['condition']=$ligne['bn_condition'];
+ $GLOBALS['_BAZAR_']['template']=$ligne['bn_template'];
+ $GLOBALS['_BAZAR_']['commentaire']=$ligne['bn_commentaire'];
+ $GLOBALS['_BAZAR_']['appropriation']=$ligne['bn_appropriation'];
+ $GLOBALS['_BAZAR_']['image_titre']=$ligne['bn_image_titre'];
+ $GLOBALS['_BAZAR_']['image_logo']=$ligne['bn_image_logo'];
+}
+
+if (!isset($GLOBALS['_BAZAR_']['id_typeannonce'])) $GLOBALS['_BAZAR_']['id_typeannonce'] = 'toutes' ;
+
+// +------------------------------------------------------------------------------------------------------+
+// | LISTE de FONCTIONS |
+// +------------------------------------------------------------------------------------------------------+
+if ($GLOBALS['_BAZAR_']['affiche_menu']) {
+ //---------------le menu de l'appli-----------
+ function afficherContenuNavigation () {
+ $res ='<ul class="onglets" id="BAZ_menu">'."\n";
+
+ // Gestion de la vue par défaut
+ if (!isset($_GET[BAZ_VARIABLE_VOIR])) {
+ $_GET[BAZ_VARIABLE_VOIR] = BAZ_VOIR_DEFAUT;
+ }
+
+ //partie consultation d'annonces
+ if (strstr(BAZ_VOIR_AFFICHER, strval(BAZ_VOIR_CONSULTER))) {
+ $GLOBALS['_BAZAR_']['url']->addQueryString(BAZ_VARIABLE_VOIR, BAZ_VOIR_CONSULTER);
+ $res .= '<li id="consulter"';
+ if ((isset($_GET[BAZ_VARIABLE_VOIR]) && $_GET[BAZ_VARIABLE_VOIR] == BAZ_VOIR_CONSULTER)) { $res .=' class="menu_actif" '; } else { $res .=' class="menu_inactif" '; }
+ $res .='><a href="'.$GLOBALS['_BAZAR_']['url']->getURL().'">'.BAZ_CONSULTER.'</a>'."\n".'</li>'."\n";
+ }
+
+ // Mes fiches
+ if (strstr(BAZ_VOIR_AFFICHER, strval(BAZ_VOIR_MES_FICHES))) {
+ $GLOBALS['_BAZAR_']['url']->addQueryString(BAZ_VARIABLE_VOIR, BAZ_VOIR_MES_FICHES);
+ $res .= '<li id="mes_fiches"';
+ if (isset($_GET[BAZ_VARIABLE_VOIR]) && $_GET[BAZ_VARIABLE_VOIR] == BAZ_VOIR_MES_FICHES) { $res .=' class="menu_actif" '; } else { $res .=' class="menu_inactif" '; }
+ $res .= '><a href="'.$GLOBALS['_BAZAR_']['url']->getURL().'">'.BAZ_VOIR_VOS_ANNONCES.'</a>'."\n".'</li>'."\n";
+ }
+
+ //partie abonnement aux annonces
+ if (strstr(BAZ_VOIR_AFFICHER, strval(BAZ_VOIR_S_ABONNER))) {
+ $GLOBALS['_BAZAR_']['url']->addQueryString(BAZ_VARIABLE_VOIR, BAZ_VOIR_S_ABONNER);
+ $res .= '<li id="inscrire"';
+ if (isset($_GET[BAZ_VARIABLE_VOIR]) && $_GET[BAZ_VARIABLE_VOIR]==BAZ_VOIR_S_ABONNER) { $res .=' class="menu_actif" '; } else { $res .=' class="menu_inactif" '; }
+ $res .= '><a href="'.$GLOBALS['_BAZAR_']['url']->getURL().'">'.BAZ_S_ABONNER.'</a></li>'."\n" ;
+ }
+
+ //partie saisie d'annonces
+ if (strstr(BAZ_VOIR_AFFICHER, strval(BAZ_VOIR_SAISIR))) {
+ $GLOBALS['_BAZAR_']['url']->addQueryString(BAZ_VARIABLE_VOIR, BAZ_VOIR_SAISIR);
+ $res .= '<li id="deposer"';
+ if (isset($_GET[BAZ_VARIABLE_VOIR]) && ($_GET[BAZ_VARIABLE_VOIR]==BAZ_VOIR_SAISIR )) { $res .=' class="menu_actif" '; } else { $res .=' class="menu_inactif" '; }
+ $res .='><a href="'.$GLOBALS['_BAZAR_']['url']->getURL().'">'.BAZ_SAISIR.'</a>'."\n".'</li>'."\n";
+ }
+
+ //choix des administrateurs
+ $utilisateur = new Administrateur_bazar($GLOBALS['AUTH']) ;
+ $est_admin=0;
+ if ($GLOBALS['AUTH']->getAuth()) {
+ $requete='SELECT bn_id_nature FROM bazar_nature';
+ $resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
+ if (DB::isError($resultat)) {
+ die ($resultat->getMessage().$resultat->getDebugInfo()) ;
+ }
+ while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
+ if ($utilisateur->isAdmin ($ligne['bn_id_nature'])) {
+ $est_admin=1;
+ }
+ }
+ if ($est_admin || $utilisateur->isSuperAdmin()) {
+ //partie administrer
+ if (strstr(BAZ_VOIR_AFFICHER, strval(BAZ_VOIR_ADMIN))) {
+ $GLOBALS['_BAZAR_']['url']->addQueryString(BAZ_VARIABLE_VOIR, BAZ_VOIR_ADMIN);
+ $res .= '<li id="administrer"';
+ if (isset($_GET[BAZ_VARIABLE_VOIR]) && $_GET[BAZ_VARIABLE_VOIR]==BAZ_VOIR_ADMIN) { $res .=' class="menu_actif" '; } else { $res .=' class="menu_inactif" '; }
+ $res .='><a href="'.$GLOBALS['_BAZAR_']['url']->getURL().'">'.BAZ_ADMINISTRER.'</a></li>'."\n";
+ }
+
+ if ($utilisateur->isSuperAdmin()) {
+ if (strstr(BAZ_VOIR_AFFICHER, strval(BAZ_VOIR_GESTION_DROITS))) {
+ $GLOBALS['_BAZAR_']['url']->addQueryString(BAZ_VARIABLE_VOIR, BAZ_VOIR_GESTION_DROITS);
+ $res .= '<li id="gerer"';
+ if (isset($_GET[BAZ_VARIABLE_VOIR]) && $_GET[BAZ_VARIABLE_VOIR]==BAZ_VOIR_GESTION_DROITS) { $res .=' class="menu_actif" '; } else { $res .=' class="menu_inactif" '; }
+ $res .='><a href="'.$GLOBALS['_BAZAR_']['url']->getURL().'">'.BAZ_GESTION_DES_DROITS.'</a></li>'."\n" ;
+ }
+ }
+ }
+ }
+ // Au final, on place dans l url, l action courante
+ if (isset($_GET[BAZ_VARIABLE_VOIR])) $GLOBALS['_BAZAR_']['url']->addQueryString(BAZ_VARIABLE_VOIR, $_GET[BAZ_VARIABLE_VOIR]);
+ $res.= '</ul>'."\n";
+ return $res ;
+ }
+}
+
+function afficherContenuCorps() {
+
+ $res = '';
+ $res.='<h1 id="titre_bazar">'.$GLOBALS['_GEN_commun']['info_menu']->gm_titre.'</h1>'."\n";
+
+ // La resolution des actions ci-dessous AVANT l afichage des vues afin
+ // d afficher des vues correctes
+
+ if (isset($_GET[BAZ_VARIABLE_ACTION])) {
+
+ if (($_GET[BAZ_VARIABLE_ACTION]!=BAZ_ACTION_NOUVEAU_V)and($_GET[BAZ_VARIABLE_ACTION]!=BAZ_ACTION_MODIFIER_V)) unset($_SESSION['formulaire_annonce_valide']);
+ switch ($_GET[BAZ_VARIABLE_ACTION]) {
+ case BAZ_ACTION_VOIR_VOS_ANNONCES : $res .= mes_fiches(); break;
+ case BAZ_ANNONCES_A_VALIDER : $res .= fiches_a_valider(); break;
+ case BAZ_ADMINISTRER_ANNONCES : $res .= baz_administrer_annonces(); break;
+ case BAZ_SUPPRIMER_FICHE : $res .= baz_suppression().baz_liste('',$GLOBALS['id_user'],''); break;
+ case BAZ_VOIR_FICHE : $res .= baz_voir_fiche(1); break;
+ case BAZ_ACTION_NOUVEAU_V : $res .= baz_formulaire(BAZ_ACTION_NOUVEAU_V).mes_fiches(); break;
+ case BAZ_ACTION_SUPPRESSION : $res .= baz_suppression(); unset ($_GET['action']); break;
+ case BAZ_ACTION_PUBLIER : publier_fiche(1) ; break;
+ case BAZ_ACTION_PAS_PUBLIER : publier_fiche(0) ;$res .= fiches_a_valider(); break;
+ case BAZ_S_INSCRIRE : $res .= baz_s_inscrire(); break;
+ case BAZ_VOIR_FLUX_RSS : header('Content-type: text/xml; charset=UTF-8');include("bazarRSS.php");exit(0);break;
+ case BAZ_ACTION_POST_VALIDATION : $res .= baz_post_validation();break;
+ }
+ }
+ if (isset ($_GET[BAZ_VARIABLE_VOIR])) {
+
+ switch ($_GET[BAZ_VARIABLE_VOIR]) {
+ case BAZ_VOIR_CONSULTER:
+ if (isset ($_GET[BAZ_VARIABLE_ACTION]) && $_GET[BAZ_VARIABLE_ACTION] != BAZ_VOIR_TOUTES_ANNONCES) {
+ $res .= baz_formulaire($_GET[BAZ_VARIABLE_ACTION]) ;
+ if ($_GET[BAZ_VARIABLE_ACTION] == BAZ_ACTION_MODIFIER_V) $res .= baz_voir_fiche(1);
+ } else $res .= baz_liste($GLOBALS['_BAZAR_']['id_typeannonce']);
+ break;
+ case BAZ_VOIR_MES_FICHES :
+ if (isset ($_GET[BAZ_VARIABLE_ACTION])) $res .= baz_formulaire($_GET[BAZ_VARIABLE_ACTION]) ; else $res .= mes_fiches();
+ break;
+ case BAZ_VOIR_S_ABONNER : $res .= baz_s_inscrire();
+ break;
+ case BAZ_VOIR_SAISIR :
+ if (isset ($_GET[BAZ_VARIABLE_ACTION])) $res .= baz_formulaire($_GET[BAZ_VARIABLE_ACTION]) ; else $res .= baz_formulaire(BAZ_DEPOSER_ANNONCE);
+ break;
+ case BAZ_VOIR_ADMIN:
+ if (isset($_GET[BAZ_VARIABLE_ACTION])) $res .= baz_formulaire($_GET[BAZ_VARIABLE_ACTION]) ; else $res .= fiches_a_valider();
+ break;
+ case BAZ_VOIR_GESTION_DROITS: $res .= baz_gestion_droits();
+ break;
+ default :
+ $res .= baz_liste($GLOBALS['_BAZAR_']['id_typeannonce']);
+ }
+ }
+ return $res ;
+}
+
+
+/* +--Fin du code ----------------------------------------------------------------------------------------+
+*
+* $Log: not supported by cvs2svn $
+* Revision 1.49.2.3 2008-01-29 09:43:19 alexandre_tb
+* Utilisation d un redirection pour eviter que les formulaires soient valides 2 fois
+*
+* Revision 1.49.2.2 2008-01-11 14:07:39 alexandre_tb
+* Remplacement de la variable action ecrite en dur par la constante BAZ_VARIABLE_ACTION
+*
+* Revision 1.49.2.1 2007-12-04 09:01:17 alexandre_tb
+* suppression de vieux code commenté.
+*
+* Revision 1.49 2007-10-24 13:26:02 alexandre_tb
+* bug : double saisie d url
+*
+* Revision 1.48 2007-10-17 08:24:59 alexandre_tb
+* correction multilinguisme
+*
+* Revision 1.47 2007-10-01 12:13:53 alexandre_tb
+* bug, affichage vue / action pour la vue "administrer"
+*
+* Revision 1.46 2007-09-28 14:29:13 jp_milcent
+* Ajout de la gestion de l'affichage des vues ou pas.
+*
+* Revision 1.45 2007-09-18 14:24:01 alexandre_tb
+* onglet administrer
+*
+* Revision 1.44 2007-09-06 15:39:28 alexandre_tb
+* fixation d une valeur par defaut a la variable vue pour
+* eviter un ecran vide si pas de parametres dans le menu
+*
+* Revision 1.43 2007-08-27 12:26:04 alexandre_tb
+* Mise en place de l action BAZ_VOIR_ADMIN
+*
+* Revision 1.42 2007-07-05 08:29:24 alexandre_tb
+* modification du charset iso-8859-1 vers utf8 lors l'envoie des entetes xml.
+*
+* Revision 1.41 2007-07-04 10:05:12 alexandre_tb
+* ajout d une variable $_GET['vue'] en complement de la variable action.
+* Elle correspond aux 6 vues du bazar (consulter, mes fiches, s'abonner, saisir, administrer, gestion des droits)
+*
+* Revision 1.40 2007/04/11 08:30:12 neiluj
+* remise en état du CVS...
+*
+* Revision 1.35.2.2 2007/03/07 16:53:17 jp_milcent
+* Suppression du query string "action" et non pas "nature"
+*
+* Revision 1.35.2.1 2007/02/15 13:42:16 jp_milcent
+* Utilisation de IN à la place du = dans les requêtes traitant les catégories de fiches.
+* Permet d'utiliser la syntaxe 1,2,3 dans la configuration de categorie_nature.
+*
+* Revision 1.35 2006/10/05 08:53:50 florian
+* amelioration moteur de recherche, correction de bugs
+*
+* Revision 1.34 2006/09/04 15:25:12 alexandre_tb
+* ajout d'un id dans la balise HTML du titre
+*
+* Revision 1.33 2006/06/21 15:41:42 alexandre_tb
+* rétablissement du menu mes fiches
+*
+* Revision 1.32 2006/06/21 15:40:15 alexandre_tb
+* rétablissement du menu mes fiches
+*
+* Revision 1.31 2006/05/19 13:54:32 florian
+* stabilisation du moteur de recherche, corrections bugs, lien recherche avancee
+*
+* Revision 1.30 2006/04/28 12:46:14 florian
+* integration des liens vers annuaire
+*
+* Revision 1.29 2006/04/24 10:16:22 alexandre_tb
+* ajout de la globale filtre.
+* elle remplace (à terme) catégorie nature
+*
+* Revision 1.28 2006/03/29 13:05:41 alexandre_tb
+* utilisation de la classe Administrateur_bazar
+*
+* Revision 1.27 2006/02/07 11:08:36 alexandre_tb
+* utilisation de la classe Utilisateur_bazar pour la vérification des droits
+*
+* Revision 1.26 2006/02/06 09:33:53 alexandre_tb
+* modification de l'affichage lors de la saisie de fiche
+*
+* Revision 1.25 2006/01/30 17:25:38 alexandre_tb
+* correction de bugs
+*
+* Revision 1.24 2006/01/26 11:06:43 alexandre_tb
+* ajout d'une requete pour recupere l'id_nature si un id_fiche est passé dans l'url
+*
+* Revision 1.23 2006/01/17 10:07:36 alexandre_tb
+* en cours
+*
+* Revision 1.22 2006/01/16 15:11:28 alexandre_tb
+* simplification code
+*
+* Revision 1.21 2006/01/13 14:12:52 florian
+* utilisation des temlates dans la table bazar_nature
+*
+* Revision 1.20 2006/01/05 16:28:25 alexandre_tb
+* prise en chage des checkbox, reste la mise à jour à gérer
+*
+* Revision 1.19 2006/01/03 10:19:31 florian
+* Mise à jour pour accepter des parametres dans papyrus: faire apparaitre ou non le menu, afficher qu'un type de fiches, définir l'action par défaut...
+*
+* Revision 1.18 2005/12/02 10:57:03 florian
+* MAJ pour paramétrage dans gestion de menus papyrus
+*
+* Revision 1.17 2005/12/01 16:05:41 florian
+* changement des chemins pour appli Pear
+*
+* Revision 1.16 2005/12/01 15:31:30 florian
+* correction bug modifs et saisies
+*
+* Revision 1.15 2005/11/30 13:58:45 florian
+* ajouts graphisme (logos, boutons), changement structure SQL bazar_fiche
+*
+* Revision 1.14 2005/11/24 16:17:13 florian
+* corrections bugs, ajout des cases à cocher
+*
+* Revision 1.13 2005/11/14 16:04:54 florian
+* maj bug affichage flux
+*
+* Revision 1.12 2005/11/07 17:05:46 florian
+* amélioration validation conditions de saisie, ajout des règles spécifiques de saisie des formulaires
+*
+* Revision 1.11 2005/10/21 16:15:04 florian
+* mise a jour appropriation
+*
+* Revision 1.10 2005/10/12 17:20:33 ddelon
+* Reorganisation calendrier + applette
+*
+* Revision 1.9 2005/10/12 13:35:07 florian
+* amélioration de l'interface de bazar, de manière a simplifier les consultations, et à harmoniser par rapport aux Ressources
+*
+* Revision 1.8 2005/09/30 13:00:05 ddelon
+* Fiche bazar generique
+*
+* Revision 1.7 2005/09/30 12:34:44 ddelon
+* petite modification pour integration bazar dans papyrus
+*
+* Revision 1.6 2005/09/30 12:22:54 florian
+* Ajouts commentaires pour fiche, modifications graphiques, maj SQL
+*
+* Revision 1.4 2005/07/21 19:03:12 florian
+* nouveautés bazar: templates fiches, correction de bugs, ...
+*
+* Revision 1.2 2005/02/22 15:33:32 florian
+* integration dans Papyrus
+*
+* Revision 1.1.1.1 2005/02/17 18:05:11 florian
+* Import initial de Bazar
+*
+* Revision 1.1.1.1 2005/02/17 11:09:50 florian
+* Import initial
+*
+* Revision 1.1.1.1 2005/02/16 18:06:35 florian
+* import de la nouvelle version
+*
+* Revision 1.3 2004/07/05 15:10:14 florian
+* changement interface de saisie
+*
+* Revision 1.2 2004/07/01 10:13:41 florian
+* modif Florian
+*
+* Revision 1.1 2004/06/23 09:58:32 alex
+* version initiale
+*
+* Revision 1.1 2004/06/18 09:00:07 alex
+* version initiale
+*
+*
+* +-- Fin du code ----------------------------------------------------------------------------------------+
+*/
+?>
/tags/v3.1-blanche-neige/bazar.head.php
New file
0,0 → 1,14
<?php
include_once 'configuration/baz_config.inc.php'; //fichier de configuration de Bazar
 
$requete = 'SELECT bn_id_nature, bn_label_nature FROM bazar_nature' ;
$resultat = $GLOBALS['_BAZAR_']['db']->query ($requete) ;
if (DB::isError($resultat)) {
die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ;
}
echo '<link rel="alternate" type="application/rss+xml" title="'.BAZ_TOUTES_LES_ANNONCES.'" href="http://'.$_SERVER['HTTP_HOST'].'/bazar/bazarRSS.php" />'."\n";
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
echo '<link rel="alternate" type="application/rss+xml" title="'.$ligne['bn_label_nature'].'" href="http://'.$_SERVER['HTTP_HOST'].'/bazar/bazarRSS.php?annonce='.$ligne['bn_label_nature'].'" />'."\n";
}
 
?>
/tags/v3.1-blanche-neige/jrest/.htaccess
New file
0,0 → 1,4
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^.*$ /bazar_bp/jrest/index.php/
/tags/v3.1-blanche-neige/jrest/JRest.php
New file
0,0 → 1,302
<?php
// In : utf8 url_encoded (get et post)
// Out : utf8
 
// TODO : gerer les retours : dans ce controleur : code retour et envoi ...
class JRest {
 
/** Parsed configuration file */
private $config;
 
/** The HTTP request method used. */
private $method = 'GET';
 
/** The HTTP request data sent (if any). */
private $requestData = NULL;
 
/** Array of strings to convert into the HTTP response. */
private $output = array();
 
/** Nom resource. */
private $resource = NULL;
 
/** Identifiant unique resource. */
private $uid = NULL;
 
/**
* Constructor. Parses the configuration file "JRest.ini", grabs any request data sent, records the HTTP
* request method used and parses the request URL to find out the requested resource
* @param str iniFile Configuration file to use
*/
public function JRest($iniFile = 'jrest.ini.php') {
$this->config = parse_ini_file($iniFile, TRUE);
if (isset($_SERVER['REQUEST_URI']) && isset($_SERVER['REQUEST_METHOD']) && isset($_SERVER['QUERY_STRING'])) {
if (isset($_SERVER['CONTENT_LENGTH']) && $_SERVER['CONTENT_LENGTH'] > 0) {
$this->requestData = '';
$httpContent = fopen('php://input', 'r');
while ($data = fread($httpContent, 1024)) {
$this->requestData .= $data;
}
fclose($httpContent);
}
if (strlen($_SERVER['QUERY_STRING']) == 0) {
$len = strlen($_SERVER['REQUEST_URI']);
} else {
$len = -(strlen($_SERVER['QUERY_STRING']) + 1);
}
$urlString = substr($_SERVER['REQUEST_URI'], strlen($this->config['settings']['baseURL']), $len);
 
$urlParts = explode('/', $urlString);
 
if (isset($urlParts[0])) $this->resource = $urlParts[0];
if (count($urlParts) > 1 && $urlParts[1] != '') {
array_shift($urlParts);
foreach ($urlParts as $uid) {
if ($uid != '') {
$this->uid[] = urldecode($uid);
}
}
}
 
$this->method = $_SERVER['REQUEST_METHOD'];
} else {
trigger_error('I require the server variables REQUEST_URI, REQUEST_METHOD and QUERY_STRING to work.', E_USER_ERROR);
}
}
 
/**
* Execute the request.
*/
function exec() {
switch ($this->method) {
case 'GET':
$this->get();
break;
case 'POST':
$this->post();
break;
case 'DELETE':
$this->delete();
break;
case 'PUT':
$this->add();
break;
}
}
 
/**
* Execute a GET request. A GET request fetches a list of resource when no resource name is given, a list of element
* when a resource name is given, or a resource element when a resource and resource unique identifier are given. It does not change the
* database contents.
*/
private function get() {
if ($this->resource) {
$resource_file = 'services/'.ucfirst($this->resource).'.php';
$resource_class = ucfirst($this->resource);
if (file_exists($resource_file)) {
include_once $resource_file;
if (class_exists($resource_class)) {
$service = new $resource_class($this->config);
if ($this->uid) { // get a resource element
if (method_exists($service, 'getElement')) {
$service->getElement($this->uid);
}
} elseif (method_exists($service, 'getRessource')) { // get all elements of a ressource
$service->getRessource();
}
}
}
} else { // get resources
// include set.jrest.php, instanticiation et appel
}
}
 
private function post() {
$pairs = array();
// Récupération des paramètres passés dans le contenu de la requête HTTP (= POST)
if ($this->requestData) {
$pairs = $this->parseRequestData();
}
 
// Ajout des informations concernant l'upload de fichier passées dans la variable $_FILE
if(isset($_FILES)) {
foreach ($_FILES as $v) {
$pairs[$v['name']] = $v;
}
 
// Ne pas effacer cette ligne ! Elle est indispensable pour les services du Carnet en ligne
// qui n'utilisent que le tableau pairs dans les posts
$pairs = array_merge($pairs, $_POST);
}
 
// gestion du contenu du post
if(isset($_POST))
{
// Safari ne sait pas envoyer des DELETE avec gwt...
// Nous utilisons le parametre "action" passé dans le POST qui doit contenir DELETE pour lancer la supression
if ($pairs['action'] == 'DELETE') {
$this->delete();
return;
}
 
if (count($pairs) != 0) {
if ($this->uid) { // get a resource element
$resource_file = 'services/'.ucfirst($this->resource).'.php';
$resource_class = ucfirst($this->resource);
if (file_exists($resource_file)) {
include_once $resource_file;
if (class_exists($resource_class)) {
$service = new $resource_class($this->config);
if (method_exists($service,'updateElement')) { // Update element
// TODO : a voir le retour ...
if ($service->updateElement($this->uid, $pairs)) {
$this->created();
}
}
}
}
} else { // get all elements of a ressource
$this->add($pairs);
}
} else {
$this->lengthRequired();
}
}
}
 
private function delete() {
$resource_file = 'services/'.ucfirst($this->resource).'.php';
$resource_class = ucfirst($this->resource);
if (file_exists($resource_file)) {
include_once $resource_file;
if (class_exists($resource_class)) {
$service = new $resource_class($this->config);
if ($this->uid) { // get a resource element
if (method_exists($service, 'deleteElement')) { // Delete element
if ($service->deleteElement($this->uid)) {
$this->noContent();
}
}
}
}
}
}
 
private function add($pairs = null) {
if (is_null($pairs)) {
$pairs = array();
// Récupération des paramètres passés dans le contenu de la requête HTTP (= POST)
// FIXME : vérifier que l'on récupère bien les données passées par PUT
if ($this->requestData) {
$pairs = $this->parseRequestData();
}
}
 
if (count($pairs) != 0) {
$resource_file = 'services/'.ucfirst($this->resource).'.php';
$resource_class = ucfirst($this->resource);
if (file_exists($resource_file)) {
include_once $resource_file;
if (class_exists($resource_class)) {
$service = new $resource_class($this->config);
if (method_exists($service,'createElement')) { // Create a new element
if ($service->createElement($pairs)) {
$this->created();
}
}
}
}
} else {
$this->lengthRequired();
}
}
 
/**
* Parse the HTTP request data.
* @return str[] Array of name value pairs
*/
private function parseRequestData() {
$values = array();
$pairs = explode('&', $this->requestData);
foreach ($pairs as $pair) {
$parts = explode('=', $pair);
if (isset($parts[0]) && isset($parts[1])) {
$parts[1] = rtrim(urldecode($parts[1]));
$values[$parts[0]] = $parts[1];
}
}
return $values;
}
 
/**
* Send a HTTP 201 response header.
*/
private function created($url = FALSE) {
header('HTTP/1.0 201 Created');
if ($url) {
header('Location: '.$url);
}
}
 
/**
* Send a HTTP 204 response header.
*/
private function noContent() {
header('HTTP/1.0 204 No Content');
}
 
/**
* Send a HTTP 400 response header.
*/
private function badRequest() {
header('HTTP/1.0 400 Bad Request');
}
 
/**
* Send a HTTP 401 response header.
*/
private function unauthorized($realm = 'JRest') {
if (!isset($_SERVER['PHP_AUTH_USER']) || !isset($_SERVER['PHP_AUTH_PW'])) {
header('WWW-Authenticate: Basic realm="'.$realm.'"');
}
header('HTTP/1.0 401 Unauthorized');
}
 
/**
* Send a HTTP 404 response header.
*/
private function notFound() {
header('HTTP/1.0 404 Not Found');
}
 
/**
* Send a HTTP 405 response header.
*/
private function methodNotAllowed($allowed = 'GET, HEAD') {
header('HTTP/1.0 405 Method Not Allowed');
header('Allow: '.$allowed);
}
 
/**
* Send a HTTP 406 response header.
*/
private function notAcceptable() {
header('HTTP/1.0 406 Not Acceptable');
echo join(', ', array_keys($this->config['renderers']));
}
 
/**
* Send a HTTP 411 response header.
*/
private function lengthRequired() {
header('HTTP/1.0 411 Length Required');
}
 
/**
* Send a HTTP 500 response header.
*/
private function internalServerError() {
header('HTTP/1.0 500 Internal Server Error');
}
}
?>
/tags/v3.1-blanche-neige/jrest/index.php
New file
0,0 → 1,38
<?php
 
// Decommenter ces lignes si version de php < 5
//require_once 'lib/JSON.php';
 
// Lazy require
// TODO : voir si on ne peut pas dépacer ces inclusions directement dans les services.
//require_once 'lib/DBAccessor.php';
//require_once 'lib/SpreadsheetProductor.php';
//require_once 'lib/PDFProductor.php';
//require 'JRest.php';
 
/**
* La fonction __autoload() charge dynamiquement les classes trouvées dans le code.
*
* Cette fonction est appelée par php5 quand il trouve une instanciation de classe dans le code.
*
*@param string le nom de la classe appelée.
*@return void le fichier contenant la classe doit être inclu par la fonction.
*/
function __autoload($classe)
{
if (class_exists($classe)) {
return null;
}
 
$chemins = array('', 'services/', 'services/include/', 'lib/');
foreach ($chemins as $chemin) {
$chemin = $chemin.$classe.'.php';
if (file_exists($chemin)) {
require_once $chemin;
}
}
}
 
$jRest =& new JRest();
$jRest->exec();
?>
/tags/v3.1-blanche-neige/jrest/util/phpMyEdit.class.php
New file
0,0 → 1,3312
<?php
 
/*
* phpMyEdit - instant MySQL table editor and code generator
*
* phpMyEdit.class.php - main table editor class definition file
* ____________________________________________________________
*
* Copyright (c) 1999-2002 John McCreesh <jpmcc@users.sourceforge.net>
* Copyright (c) 2001-2002 Jim Kraai <jkraai@users.sourceforge.net>
* Versions 5.0 and higher developed by Ondrej Jombik <nepto@php.net>
* Copyright (c) 2002-2006 Platon Group, http://platon.sk/
* All rights reserved.
*
* See README file for more information about this software.
* See COPYING file for license information.
*
* Download the latest version from
* http://platon.sk/projects/phpMyEdit/
*/
 
/* $Platon: phpMyEdit/phpMyEdit.class.php,v 1.188 2006-09-08 16:30:31 michal Exp $ */
 
/* This is a generic table editing program. The table and fields to be
edited are defined in the calling program.
 
This program works in three passes.
* Pass 1 (the last part of the program) displays the selected MySQL
table in a scrolling table on the screen. Radio buttons are used to
select a record for editing or deletion. If the user chooses Add,
Change, Copy, View or Delete buttons.
* Pass 2 starts, displaying the selected record. If the user chooses
the Save button from this screen.
* Pass 3 processes the update and the display returns to the
original table view (Pass 1).
*/
 
class phpMyEdit_timer /* {{{ */
{
var $startTime;
var $started;
 
function phpMyEdit_timer($start = true)
{
$this->started = false;
if ($start) {
$this->start();
}
}
 
function start()
{
$startMtime = explode(' ', microtime());
$this->startTime = (double) $startMtime[0] + (double) $startMtime[1];
$this->started = true;
}
 
function end($iterations = 1)
{
// get the time, check whether the timer was started later
$endMtime = explode(' ', microtime());
if ($this->started) {
$endTime = (double)($endMtime[0])+(double)($endMtime[1]);
$dur = $endTime - $this->startTime;
$avg = 1000 * $dur / $iterations;
$avg = round(1000 * $avg) / 1000;
return $avg;
} else {
return 'phpMyEdit_timer ERROR: timer not started';
}
}
} /* }}} */
 
if (! function_exists('array_search')) { /* {{{ */
function array_search($needle, $haystack)
{
foreach ($haystack as $key => $value) {
if ($needle == $value)
return $key;
}
return false;
}
} /* }}} */
 
if (! function_exists('realpath')) { /* {{{ */
function realpath($path)
{
return $path;
}
} /* }}} */
 
class phpMyEdit
{
// Class variables {{{
 
// Database handling
var $hn; // hostname
var $un; // user name
var $pw; // password
var $tb; // table
var $db; // database
var $dbp; // database with point
var $dbh; // database handle
var $close_dbh; // if database handle should be closed
 
// Record manipulation
var $key; // name of field which is the unique key
var $key_num; // number of field which is the unique key
var $key_type; // type of key field (int/real/string/date etc.)
var $key_delim; // character used for key value quoting
var $rec; // number of record selected for editing
var $inc; // number of records to display
var $fm; // first record to display
var $fl; // is the filter row displayed (boolean)
var $fds; // sql field names
var $fdn; // sql field names => $k
var $num_fds; // number of fields
var $options; // options for users: ACDFVPI
var $fdd; // field definitions
var $qfn; // value of all filters used during the last pass
var $sfn; // sort field number (- = descending sort order)
var $cur_tab; // current selected tab
 
// Operation
var $navop; // navigation buttons/operations
var $sw; // filter display/hide/clear button
var $operation; // operation to do: Add, Change, Delete
var $saveadd;
var $moreadd;
var $canceladd;
var $savechange;
var $morechange;
var $cancelchange;
var $savecopy;
var $cancelcopy;
var $savedelete;
var $canceldelete;
var $cancelview;
 
// Additional features
var $labels; // multilingual labels
var $cgi; // CGI variable features array
var $js; // JS configuration array
var $dhtml; // DHTML configuration array
var $url; // URL array
var $message; // informational message to print
var $notify; // change notification e-mail adresses
var $logtable; // name of optional logtable
var $navigation; // navigation style
var $tabs; // TAB names
var $timer = null; // phpMyEdit_timer object
 
// Predefined variables
var $comp_ops = array('<'=>'<','<='=>'<=','='=>'=','>='=>'>=','>'=>'>');
var $sql_aggrs = array(
'sum' => 'Total',
'avg' => 'Average',
'min' => 'Minimum',
'max' => 'Maximum',
'count' => 'Count');
var $page_types = array(
'L' => 'list',
'F' => 'filter',
'A' => 'add',
'V' => 'view',
'C' => 'change',
'P' => 'copy',
'D' => 'delete'
);
var $default_buttons = array(
'L' => array('<<','<','add','view','change','copy','delete','>','>>','goto','goto_combo'),
'F' => array('<<','<','add','view','change','copy','delete','>','>>','goto','goto_combo'),
'A' => array('save','more','cancel'),
'C' => array('save','more','cancel'),
'P' => array('save', 'cancel'),
'D' => array('save','cancel'),
'V' => array('change','cancel')
);
// }}}
 
/*
* column specific functions
*/
 
function col_has_sql($k) { return isset($this->fdd[$k]['sql']); }
function col_has_sqlw($k) { return isset($this->fdd[$k]['sqlw']) && !$this->virtual($k); }
function col_has_values($k) { return isset($this->fdd[$k]['values']) || isset($this->fdd[$k]['values2']); }
function col_has_php($k) { return isset($this->fdd[$k]['php']); }
function col_has_URL($k) { return isset($this->fdd[$k]['URL'])
|| isset($this->fdd[$k]['URLprefix']) || isset($this->fdd[$k]['URLpostfix']); }
function col_has_multiple($k)
{ return $this->col_has_multiple_select($k) || $this->col_has_checkboxes($k); }
function col_has_multiple_select($k)
{ return $this->fdd[$k]['select'] == 'M' && ! $this->fdd[$k]['values']['table']; }
function col_has_checkboxes($k)
{ return $this->fdd[$k]['select'] == 'C' && ! $this->fdd[$k]['values']['table']; }
function col_has_radio_buttons($k)
{ return $this->fdd[$k]['select'] == 'O' && ! $this->fdd[$k]['values']['table']; }
function col_has_datemask($k)
{ return isset($this->fdd[$k]['datemask']) || isset($this->fdd[$k]['strftimemask']); }
 
/*
* functions for indicating whether navigation style is enabled
*/
 
function nav_buttons() { return stristr($this->navigation, 'B'); }
function nav_text_links() { return stristr($this->navigation, 'T'); }
function nav_graphic_links() { return stristr($this->navigation, 'G'); }
function nav_up() { return (stristr($this->navigation, 'U') && !($this->buttons[$this->page_type]['up'] === false)); }
function nav_down() { return (stristr($this->navigation, 'D') && !($this->buttons[$this->page_type]['down'] === false)); }
 
/*
* functions for indicating whether operations are enabled
*/
 
function add_enabled() { return stristr($this->options, 'A'); }
function change_enabled() { return stristr($this->options, 'C'); }
function delete_enabled() { return stristr($this->options, 'D'); }
function filter_enabled() { return stristr($this->options, 'F'); }
function view_enabled() { return stristr($this->options, 'V'); }
function copy_enabled() { return stristr($this->options, 'P') && $this->add_enabled(); }
function tabs_enabled() { return $this->display['tabs'] && count($this->tabs) > 0; }
function hidden($k) { return stristr($this->fdd[$k]['input'],'H'); }
function password($k) { return stristr($this->fdd[$k]['input'],'W'); }
function readonly($k) { return stristr($this->fdd[$k]['input'],'R') || $this->virtual($k); }
function virtual($k) { return stristr($this->fdd[$k]['input'],'V') && $this->col_has_sql($k); }
 
function add_operation() { return $this->operation == $this->labels['Add'] && $this->add_enabled(); }
function change_operation() { return $this->operation == $this->labels['Change'] && $this->change_enabled(); }
function copy_operation() { return $this->operation == $this->labels['Copy'] && $this->copy_enabled(); }
function delete_operation() { return $this->operation == $this->labels['Delete'] && $this->delete_enabled(); }
function view_operation() { return $this->operation == $this->labels['View'] && $this->view_enabled(); }
function filter_operation() { return $this->fl && $this->filter_enabled() && $this->list_operation(); }
function list_operation() { /* covers also filtering page */ return ! $this->change_operation()
&& ! $this->add_operation() && ! $this->copy_operation()
&& ! $this->delete_operation() && ! $this->view_operation(); }
function next_operation() { return ($this->navop == $this->labels['Next']) || ($this->navop == '>'); }
function prev_operation() { return ($this->navop == $this->labels['Prev']) || ($this->navop == '<'); }
function first_operation() { return ($this->navop == $this->labels['First']) || ($this->navop == '<<'); }
function last_operation() { return ($this->navop == $this->labels['Last']) || ($this->navop == '>>'); }
function clear_operation() { return $this->sw == $this->labels['Clear']; }
 
function add_canceled() { return $this->canceladd == $this->labels['Cancel']; }
function view_canceled() { return $this->cancelview == $this->labels['Cancel']; }
function change_canceled() { return $this->cancelchange == $this->labels['Cancel']; }
function copy_canceled() { return $this->cancelcopy == $this->labels['Cancel']; }
function delete_canceled() { return $this->canceldelete == $this->labels['Cancel']; }
 
function is_values2($k, $val = 'X') /* {{{ */
{
return $val === null ||
(isset($this->fdd[$k]['values2']) && !isset($this->fdd[$k]['values']['table']));
} /* }}} */
 
function processed($k) /* {{{ */
{
if ($this->virtual($k)) {
return false;
}
$options = @$this->fdd[$k]['options'];
if (! isset($options)) {
return true;
}
return
($this->saveadd == $this->labels['Save'] && stristr($options, 'A')) ||
($this->moreadd == $this->labels['More'] && stristr($options, 'A')) ||
($this->savechange == $this->labels['Save'] && stristr($options, 'C')) ||
($this->morechange == $this->labels['Apply'] && stristr($options, 'C')) ||
($this->savecopy == $this->labels['Save'] && stristr($options, 'P')) ||
($this->savedelete == $this->labels['Save'] && stristr($options, 'D'));
} /* }}} */
 
function displayed($k) /* {{{ */
{
if (is_numeric($k)) {
$k = $this->fds[$k];
}
$options = @$this->fdd[$k]['options'];
if (! isset($options)) {
return true;
}
return
($this->add_operation() && stristr($options, 'A')) ||
($this->view_operation() && stristr($options, 'V')) ||
($this->change_operation() && stristr($options, 'C')) ||
($this->copy_operation() && stristr($options, 'P')) ||
($this->delete_operation() && stristr($options, 'D')) ||
($this->filter_operation() && stristr($options, 'F')) ||
($this->list_operation() && stristr($options, 'L'));
} /* }}} */
function debug_var($name, $val) /* {{{ */
{
if (is_array($val) || is_object($val)) {
echo "<pre>$name\n";
ob_start();
//print_r($val);
var_dump($val);
$content = ob_get_contents();
ob_end_clean();
echo htmlspecialchars($content);
echo "</pre>\n";
} else {
echo 'debug_var()::<i>',htmlspecialchars($name),'</i>';
echo '::<b>',htmlspecialchars($val),'</b>::',"<br />\n";
}
} /* }}} */
 
function myquery($qry, $line = 0, $debug = 0) /* {{{ */
{
global $debug_query;
if ($debug_query || $debug) {
$line = intval($line);
echo '<h4>MySQL query at line ',$line,'</h4>',htmlspecialchars($qry),'<hr />',"\n";
}
if (isset($this->db)) {
$ret = @mysql_db_query($this->db, $qry, $this->dbh);
} else {
$ret = @mysql_query($qry, $this->dbh);
}
if (! $ret) {
echo '<h4>MySQL error ',mysql_errno($this->dbh),'</h4>';
echo htmlspecialchars(mysql_error($this->dbh)),'<hr />',"\n";
}
return $ret;
} /* }}} */
 
function make_language_labels($language) /* {{{ */
{
// just try the first language and variant
// this isn't content-negotiation rfc compliant
$language = strtoupper($language);
 
// try the full language w/ variant
$file = $this->dir['lang'].'PME.lang.'.$language.'.inc';
 
if (! file_exists($file)) {
// try the language w/o variant
$file = $this->dir['lang'].'PME.lang.'.substr($language,0,2).'.inc';
}
if (! file_exists($file)) {
// default to classical English
$file = $this->dir['lang'].'PME.lang.EN.inc';
}
$ret = @include($file);
if (! is_array($ret)) {
return $ret;
}
$small = array(
'Search' => 'v',
'Hide' => '^',
'Clear' => 'X',
'Query' => htmlspecialchars('>'));
if ((!$this->nav_text_links() && !$this->nav_graphic_links())
|| !isset($ret['Search']) || !isset($ret['Query'])
|| !isset($ret['Hide']) || !isset($ret['Clear'])) {
foreach ($small as $key => $val) {
$ret[$key] = $val;
}
}
return $ret;
} /* }}} */
 
function set_values($field_num, $prepend = null, $append = null, $strict = false) /* {{{ */
{
return (array) $prepend + (array) $this->fdd[$field_num]['values2']
+ (isset($this->fdd[$field_num]['values']['table']) || $strict
? $this->set_values_from_table($field_num, $strict)
: array())
+ (array) $append;
} /* }}} */
 
function set_values_from_table($field_num, $strict = false) /* {{{ */
{
$db = &$this->fdd[$field_num]['values']['db'];
$table = &$this->fdd[$field_num]['values']['table'];
$key = &$this->fdd[$field_num]['values']['column'];
$desc = &$this->fdd[$field_num]['values']['description'];
$dbp = isset($db) ? "$db." : $this->dbp;
$qparts['type'] = 'select';
if ($table) {
$qparts['select'] = 'DISTINCT '.$table.'.'.$key;
if ($desc && is_array($desc) && is_array($desc['columns'])) {
$qparts['select'] .= ',CONCAT('; // )
$num_cols = sizeof($desc['columns']);
if (isset($desc['divs'][-1])) {
$qparts['select'] .= '"'.addslashes($desc['divs'][-1]).'",';
}
foreach ($desc['columns'] as $key => $val) {
if ($val) {
$qparts['select'] .= 'IFNULL('.$val.',"")';
if ($desc['divs'][$key]) {
$qparts['select'] .= ',"'.addslashes($desc['divs'][$key]).'"';
}
$qparts['select'] .= ',';
}
}
$qparts['select']{strlen($qparts['select']) - 1} = ')';
$qparts['select'] .= ' AS PMEalias'.$field_num;
$qparts['orderby'] = 'PMEalias'.$field_num;
} else if ($desc && is_array($desc)) {
// TODO
} else if ($desc) {
$qparts['select'] .= ','.$table.'.'.$desc;
$qparts['orderby'] = $desc;
} else if ($key) {
$qparts['orderby'] = $key;
}
$qparts['from'] = "$dbp$table";
$ar = array(
'table' => $table,
'column' => $column,
'description' => $desc);
$qparts['where'] = $this->substituteVars($this->fdd[$field_num]['values']['filters'], $ar);
if ($this->fdd[$field_num]['values']['orderby']) {
$qparts['orderby'] = $this->substituteVars($this->fdd[$field_num]['values']['orderby'], $ar);
}
} else { /* simple value extraction */
$key = &$this->fds[$field_num];
$this->virtual($field_num) && $key = $this->fqn($field_num);
$qparts['select'] = 'DISTINCT '.$key.' AS PMEkey';
$qparts['orderby'] = 'PMEkey';
$qparts['from'] = $this->dbp.$this->tb;
}
$values = array();
$res = $this->myquery($this->get_SQL_query($qparts), __LINE__);
while ($row = @mysql_fetch_array($res, MYSQL_NUM)) {
$values[$row[0]] = $desc ? $row[1] : $row[0];
}
return $values;
} /* }}} */
 
function fqn($field, $dont_desc = false, $dont_cols = false) /* {{{ */
{
is_numeric($field) || $field = array_search($field, $this->fds);
// if read SQL expression exists use it
if ($this->col_has_sql($field))
return $this->fdd[$field]['sql'];
// on copy/change always use simple key retrieving
if ($this->add_operation()
|| $this->copy_operation()
|| $this->change_operation()) {
$ret = 'PMEtable0.'.$this->fds[$field];
} else {
if ($this->fdd[$this->fds[$field]]['values']['description'] && ! $dont_desc) {
$desc = &$this->fdd[$this->fds[$field]]['values']['description'];
if (is_array($desc) && is_array($desc['columns'])) {
$ret = 'CONCAT('; // )
$num_cols = sizeof($desc['columns']);
if (isset($desc['divs'][-1])) {
$ret .= '"'.addslashes($desc['divs'][-1]).'",';
}
foreach ($desc['columns'] as $key => $val) {
if ($val) {
$ret .= 'PMEjoin'.$field.'.'.$val;
if ($desc['divs'][$key]) {
$ret .= ',"'.addslashes($desc['divs'][$key]).'"';
}
$ret .= ',';
}
}
$ret{strlen($ret) - 1} = ')';
} else if (is_array($desc)) {
// TODO
} else {
$ret = 'PMEjoin'.$field.'.'.$this->fdd[$this->fds[$field]]['values']['description'];
}
// TODO: remove me
} elseif (0 && $this->fdd[$this->fds[$field]]['values']['column'] && ! $dont_cols) {
$ret = 'PMEjoin'.$field.'.'.$this->fdd[$this->fds[$field]]['values']['column'];
} else {
$ret = 'PMEtable0.'.$this->fds[$field];
}
// TODO: not neccessary, remove me!
if (is_array($this->fdd[$this->fds[$field]]['values2'])) {
}
}
return $ret;
} /* }}} */
 
function get_SQL_query($parts) /* {{{ */
{
foreach ($parts as $k => $v) {
$parts[$k] = trim($parts[$k]);
}
switch ($parts['type']) {
case 'select':
$ret = 'SELECT ';
if ($parts['DISTINCT'])
$ret .= 'DISTINCT ';
$ret .= $parts['select'];
$ret .= ' FROM '.$parts['from'];
if ($parts['where'] != '')
$ret .= ' WHERE '.$parts['where'];
if ($parts['groupby'] != '')
$ret .= ' GROUP BY '.$parts['groupby'];
if ($parts['having'] != '')
$ret .= ' HAVING '.$parts['having'];
if ($parts['orderby'] != '')
$ret .= ' ORDER BY '.$parts['orderby'];
if ($parts['limit'] != '')
$ret .= ' LIMIT '.$parts['limit'];
if ($parts['procedure'] != '')
$ret .= ' PROCEDURE '.$parts['procedure'];
break;
case 'update':
$ret = 'UPDATE '.$parts['table'];
$ret .= ' SET '.$parts['fields'];
if ($parts['where'] != '')
$ret .= ' WHERE '.$parts['where'];
break;
case 'insert':
$ret = 'INSERT INTO '.$parts['table'];
$ret .= ' VALUES '.$parts['values'];
break;
case 'delete':
$ret = 'DELETE FROM '.$parts['table'];
if ($parts['where'] != '')
$ret .= ' WHERE '.$parts['where'];
break;
default:
die('unknown query type');
break;
}
return $ret;
} /* }}} */
 
function get_SQL_column_list() /* {{{ */
{
$fields = array();
for ($k = 0; $k < $this->num_fds; $k++) {
if (! $this->displayed[$k] && $k != $this->key_num) {
continue;
}
$fields[] = $this->fqn($k).' AS qf'.$k;
if ($this->col_has_values($k)) {
$fields[] = $this->fqn($k, true, true).' AS qf'.$k.'_idx';
}
if ($this->col_has_datemask($k)) {
$fields[] = 'UNIX_TIMESTAMP('.$this->fqn($k).') AS qf'.$k.'_timestamp';
}
}
return join(',', $fields);
} /* }}} */
 
function get_SQL_join_clause() /* {{{ */
{
$main_table = 'PMEtable0';
$join_clause = $this->tb." AS $main_table";
for ($k = 0, $numfds = sizeof($this->fds); $k < $numfds; $k++) {
$main_column = $this->fds[$k];
if($this->fdd[$main_column]['values']['db']) {
$dbp = $this->fdd[$main_column]['values']['db'].'.';
} else {
$dbp = $this->dbp;
}
$table = @$this->fdd[$main_column]['values']['table'];
$join_column = @$this->fdd[$main_column]['values']['column'];
$join_desc = @$this->fdd[$main_column]['values']['description'];
if ($join_desc != '' && $join_column != '') {
$join_table = 'PMEjoin'.$k;
$ar = array(
'main_table' => $main_table,
'main_column' => $main_column,
'join_table' => $join_table,
'join_column' => $join_column,
'join_description' => $join_desc);
$join_clause .= " LEFT OUTER JOIN $dbp$table AS $join_table ON (";
$join_clause .= isset($this->fdd[$main_column]['values']['join'])
? $this->substituteVars($this->fdd[$main_column]['values']['join'], $ar)
: "$join_table.$join_column = $main_table.$main_column";
if (isset($this->fdd[$main_column]['values']['filters'])) {
$join_clause .= ' AND ';
$join_clause .= $this->substituteVars($this->fdd[$main_column]['values']['filters'], $ar);
}
$join_clause .= ')';
}
}
return $join_clause;
} /* }}} */
 
function get_SQL_where_from_query_opts($qp = null, $text = 0) /* {{{ */
{
if ($qp == null) {
$qp = $this->query_opts;
}
$where = array();
foreach ($qp as $field => $ov) {
if (is_numeric($field)) {
$tmp_where = array();
foreach ($ov as $field2 => $ov2) {
$tmp_where[] = sprintf('%s %s %s', $field2, $ov2['oper'], $ov2['value']);
}
$where[] = '('.join(' OR ', $tmp_where).')';
} else {
if (is_array($ov['value'])) {
$tmp_ov_val = '';
foreach ($ov['value'] as $ov_val) {
strlen($tmp_ov_val) > 0 && $tmp_ov_val .= ' OR ';
$tmp_ov_val .= sprintf('FIND_IN_SET("%s",%s)', $ov_val, $field);
}
$where[] = "($tmp_ov_val)";
} else {
$where[] = sprintf('%s %s %s', $field, $ov['oper'], $ov['value']);
}
}
}
// Add any coder specified filters
if (! $text && $this->filters) {
$where[] = '('.$this->filters.')';
}
if (count($where) > 0) {
if ($text) {
return str_replace('%', '*', join(' AND ',$where));
} else {
return join(' AND ',$where);
}
}
return ''; /* empty string */
} /* }}} */
 
function gather_query_opts() /* {{{ */
{
$this->query_opts = array();
$this->prev_qfn = $this->qfn;
$this->qfn = '';
if ($this->clear_operation()) {
return;
}
// gathers query options into an array, $this->query_opts
$qo = array();
for ($k = 0; $k < $this->num_fds; $k++) {
$l = 'qf'.$k;
$lc = 'qf'.$k.'_comp';
$li = 'qf'.$k.'_id';
$m = $this->get_sys_cgi_var($l);
$mc = $this->get_sys_cgi_var($lc);
$mi = $this->get_sys_cgi_var($li);
if (! isset($m) && ! isset($mi)) {
continue;
}
if (is_array($m) || is_array($mi)) {
if (is_array($mi)) {
$m = $mi;
$l = $li;
}
if (in_array('*', $m)) {
continue;
}
if ($this->col_has_values($k) && $this->col_has_multiple($k)) {
foreach (array_keys($m) as $key) {
$m[$key] = addslashes($m[$key]);
}
$qo[$this->fqn($k)] = array('value' => $m);
} else {
$qf_op = '';
foreach (array_keys($m) as $key) {
if ($qf_op == '') {
$qf_op = 'IN';
$qf_val = '"'.addslashes($m[$key]).'"';
$afilter = ' IN ("'.addslashes($m[$key]).'"'; // )
} else {
$afilter = $afilter.',"'.addslashes($m[$key]).'"';
$qf_val .= ',"'.addslashes($m[$key]).'"';
}
$this->qfn .= '&'.$this->cgi['prefix']['sys'].$l.'['.rawurlencode($key).']='.rawurlencode($m[$key]);
}
$afilter = $afilter.')';
// XXX: $dont_desc and $dont_cols hack
$dont_desc = isset($this->fdd[$k]['values']['description']);
$dont_cols = isset($this->fdd[$k]['values']['column']);
$qo[$this->fqn($k, $dont_desc, $dont_cols)] =
array('oper' => $qf_op, 'value' => "($qf_val)"); // )
}
} else if (isset($mi)) {
if ($mi == '*') {
continue;
}
if ($this->fdd[$k]['select'] != 'M' && $this->fdd[$k]['select'] != 'D' && $mi == '') {
continue;
}
$afilter = addslashes($mi);
$qo[$this->fqn($k, true, true)] = array('oper' => '=', 'value' => "'$afilter'");
$this->qfn .= '&'.$this->cgi['prefix']['sys'].$li.'='.rawurlencode($mi);
} else if (isset($m)) {
if ($m == '*') {
continue;
}
if ($this->fdd[$k]['select'] != 'M' && $this->fdd[$k]['select'] != 'D' && $m == '') {
continue;
}
$afilter = addslashes($m);
if ($this->fdd[$k]['select'] == 'N') {
$mc = in_array($mc, $this->comp_ops) ? $mc : '=';
$qo[$this->fqn($k)] = array('oper' => $mc, 'value' => "'$afilter'");
$this->qfn .= '&'.$this->cgi['prefix']['sys'].$l .'='.rawurlencode($m);
$this->qfn .= '&'.$this->cgi['prefix']['sys'].$lc.'='.rawurlencode($mc);
} else {
$afilter = '%'.str_replace('*', '%', $afilter).'%';
$ids = array();
$ar = array();
$ar[$this->fqn($k)] = array('oper' => 'LIKE', 'value' => "'$afilter'");
if (is_array($this->fdd[$k]['values2'])) {
foreach ($this->fdd[$k]['values2'] as $key => $val) {
if (strlen($m) > 0 && stristr($val, $m)) {
$ids[] = '"'.addslashes($key).'"';
}
}
if (count($ids) > 0) {
$ar[$this->fqn($k, true, true)]
= array('oper' => 'IN', 'value' => '('.join(',', $ids).')');
}
}
$qo[] = $ar;
$this->qfn .= '&'.$this->cgi['prefix']['sys'].$l.'='.rawurlencode($m);
}
}
}
$this->query_opts = $qo;
} /* }}} */
 
/*
* Create JavaScripts
*/
 
function form_begin() /* {{{ */
{
$page_name = htmlspecialchars($this->page_name);
if ($this->add_operation() || $this->change_operation() || $this->copy_operation()
|| $this->view_operation() || $this->delete_operation()) {
$field_to_tab = array();
for ($tab = $k = $this->cur_tab = 0; $k < $this->num_fds; $k++) {
if (isset($this->fdd[$k]['tab'])) {
if ($tab == 0 && $k > 0) {
$this->tabs[0] = 'PMEtab0';
$this->cur_tab = 1;
$tab++;
}
if (is_array($this->fdd[$k]['tab'])) {
$this->tabs[$tab] = @$this->fdd[$k]['tab']['name'];
$this->fdd[$k]['tab']['default'] && $this->cur_tab = $tab;
} else {
$this->tabs[$tab] = @$this->fdd[$k]['tab'];
}
$tab++;
}
$field_to_tab[$k] = max(0, $tab - 1);
}
if (preg_match('/^'.$this->dhtml['prefix'].'tab(\d+)$/', $this->get_sys_cgi_var('cur_tab'), $parts)) {
$this->cur_tab = $parts[1];
}
if ($this->tabs_enabled()) {
// initial TAB styles
echo '<style type="text/css" media="screen">',"\n";
for ($i = 0; $i < count($this->tabs); $i++) {
echo ' #'.$this->dhtml['prefix'].'tab',$i,' { display: ';
echo (($i == $this->cur_tab || $this->tabs[$i] == 'PMEtab0' ) ? 'block' : 'none') ,'; }',"\n";
}
echo '</style>',"\n";
// TAB javascripts
echo '<script type="text/javascript"><!--',"\n\n";
$css_class_name1 = $this->getCSSclass('tab', $position);
$css_class_name2 = $this->getCSSclass('tab-selected', $position);
echo 'var '.$this->js['prefix'].'cur_tab = "'.$this->dhtml['prefix'].'tab',$this->cur_tab,'";
 
function '.$this->js['prefix'].'show_tab(tab_name)
{';
if ($this->nav_up()) {
echo '
document.getElementById('.$this->js['prefix'].'cur_tab+"_up_label").className = "',$css_class_name1,'";
document.getElementById('.$this->js['prefix'].'cur_tab+"_up_link").className = "',$css_class_name1,'";
document.getElementById(tab_name+"_up_label").className = "',$css_class_name2,'";
document.getElementById(tab_name+"_up_link").className = "',$css_class_name2,'";';
}
if ($this->nav_down()) {
echo '
document.getElementById('.$this->js['prefix'].'cur_tab+"_down_label").className = "',$css_class_name1,'";
document.getElementById('.$this->js['prefix'].'cur_tab+"_down_link").className = "',$css_class_name1,'";
document.getElementById(tab_name+"_down_label").className = "',$css_class_name2,'";
document.getElementById(tab_name+"_down_link").className = "',$css_class_name2,'";';
}
echo '
document.getElementById('.$this->js['prefix'].'cur_tab).style.display = "none";
document.getElementById(tab_name).style.display = "block";
'.$this->js['prefix'].'cur_tab = tab_name;
document.'.$this->cgi['prefix']['sys'].'form.'.$this->cgi['prefix']['sys'].'cur_tab.value = tab_name;
}',"\n\n";
echo '// --></script>', "\n";
}
}
 
if ($this->add_operation() || $this->change_operation() || $this->copy_operation()) {
$first_required = true;
for ($k = 0; $k < $this->num_fds; $k++) {
if ($this->displayed[$k] && ! $this->readonly($k) && ! $this->hidden($k)
&& ($this->fdd[$k]['js']['required'] || isset($this->fdd[$k]['js']['regexp']))) {
if ($first_required) {
$first_required = false;
echo '<script type="text/javascript"><!--',"\n";
echo '
function '.$this->js['prefix'].'trim(str)
{
while (str.substring(0, 1) == " "
|| str.substring(0, 1) == "\\n"
|| str.substring(0, 1) == "\\r")
{
str = str.substring(1, str.length);
}
while (str.substring(str.length - 1, str.length) == " "
|| str.substring(str.length - 1, str.length) == "\\n"
|| str.substring(str.length - 1, str.length) == "\\r")
{
str = str.substring(0, str.length - 1);
}
return str;
}
 
function '.$this->js['prefix'].'form_control(theForm)
{',"\n";
}
if ($this->col_has_values($k)) {
$condition = 'theForm.'.$this->cgi['prefix']['data'].$this->fds[$k].'.selectedIndex == -1';
$multiple = $this->col_has_multiple_select($k);
} else {
$condition = '';
$multiple = false;
if ($this->fdd[$k]['js']['required']) {
$condition = $this->js['prefix'].'trim(theForm.'.$this->cgi['prefix']['data'].$this->fds[$k].'.value) == ""';
}
if (isset($this->fdd[$k]['js']['regexp'])) {
$condition .= (strlen($condition) > 0 ? ' || ' : '');
$condition .= sprintf('!(%s.test('.$this->js['prefix'].'trim(theForm.%s.value)))',
$this->fdd[$k]['js']['regexp'], $this->cgi['prefix']['data'].$this->fds[$k]);
}
}
 
/* Multiple selects have their name like ``name[]''.
It is not possible to work with them directly, because
theForm.name[].something will result into JavaScript
syntax error. Following search algorithm is provided
as a workaround for this.
*/
if ($multiple) {
echo '
multiple_select = null;
for (i = 0; i < theForm.length; i++) {
if (theForm.elements[i].name == "',$this->cgi['prefix']['data'].$this->fds[$k],'[]") {
multiple_select = theForm.elements[i];
break;
}
}
if (multiple_select != null && multiple_select.selectedIndex == -1) {';
} else {
echo '
if (',$condition,') {';
}
echo '
alert("';
if (isset($this->fdd[$k]['js']['hint'])) {
echo htmlspecialchars($this->fdd[$k]['js']['hint']);
} else {
echo $this->labels['Please enter'],' ',$this->fdd[$k]['name'],'.';
}
echo '");';
if ($this->tabs_enabled() && $field_to_tab[$k] >= $this->cur_tab) {
echo '
'.$this->js['prefix'].'show_tab("'.$this->dhtml['prefix'].'tab',$field_to_tab[$k],'");';
}
echo '
theForm.',$this->cgi['prefix']['data'].$this->fds[$k],'.focus();
return false;
}',"\n";
}
}
if (! $first_required) {
echo '
return true;
}',"\n\n";
echo '// --></script>', "\n";
}
}
 
if ($this->filter_operation()) {
echo '<script type="text/javascript"><!--',"\n";
echo '
function '.$this->js['prefix'].'filter_handler(theForm, theEvent)
{
var pressed_key = null;
if (theEvent.which) {
pressed_key = theEvent.which;
} else {
pressed_key = theEvent.keyCode;
}
if (pressed_key == 13) { // enter pressed
theForm.submit();
return false;
}
return true;
}',"\n\n";
echo '// --></script>', "\n";
}
 
if ($this->display['form']) {
echo '<form class="',$this->getCSSclass('form'),'" method="post"';
echo ' action="',$page_name,'" name="'.$this->cgi['prefix']['sys'].'form">',"\n";
}
return true;
} /* }}} */
 
function form_end() /* {{{ */
{
if ($this->display['form']) {
echo '</form>',"\n";
}
} /* }}} */
 
function display_tab_labels($position) /* {{{ */
{
if (! is_array($this->tabs)) {
return false;
}
echo '<table summary="labels" class="',$this->getCSSclass('tab', $position),'">',"\n";
echo '<tr class="',$this->getCSSclass('tab', $position),'">',"\n";
for ($i = ($this->tabs[0] == 'PMEtab0' ? 1 : 0); $i < count($this->tabs); $i++) {
$css_class_name = $this->getCSSclass($i != $this->cur_tab ? 'tab' : 'tab-selected', $position);
echo '<td class="',$css_class_name,'" id="'.$this->dhtml['prefix'].'tab',$i,'_',$position,'_label">';
echo '<a class="',$css_class_name,'" id="'.$this->dhtml['prefix'].'tab',$i,'_',$position,'_link';
echo '" href="javascript:'.$this->js['prefix'].'show_tab(\''.$this->dhtml['prefix'].'tab',$i,'\')">';
echo $this->tabs[$i],'</a></td>',"\n";
}
echo '<td class="',$this->getCSSclass('tab-end', $position),'">&nbsp;</td>',"\n";
echo '</tr>',"\n";
echo '</table>',"\n";
} /* }}} */
 
/*
* Display functions
*/
 
function display_add_record() /* {{{ */
{
for ($tab = 0, $k = 0; $k < $this->num_fds; $k++) {
if (isset($this->fdd[$k]['tab']) && $this->tabs_enabled() && $k > 0) {
$tab++;
echo '</table>',"\n";
echo '</div>',"\n";
echo '<div id="'.$this->dhtml['prefix'].'tab',$tab,'">',"\n";
echo '<table class="',$this->getCSSclass('main'),'" summary="',$this->tb,'">',"\n";
}
if (! $this->displayed[$k]) {
continue;
}
if ($this->hidden($k)) {
echo $this->htmlHiddenData($this->fds[$k], $this->fdd[$k]['default']);
continue;
}
$css_postfix = @$this->fdd[$k]['css']['postfix'];
$css_class_name = $this->getCSSclass('input', null, 'next', $css_postfix);
$escape = isset($this->fdd[$k]['escape']) ? $this->fdd[$k]['escape'] : true;
echo '<tr class="',$this->getCSSclass('row', null, true, $css_postfix),'">',"\n";
echo '<td class="',$this->getCSSclass('key', null, true, $css_postfix),'">';
echo $this->fdd[$k]['name'],'</td>',"\n";
echo '<td class="',$this->getCSSclass('value', null, true, $css_postfix),'"';
echo $this->getColAttributes($k),">\n";
if ($this->col_has_values($k)) {
$vals = $this->set_values($k);
$selected = @$this->fdd[$k]['default'];
$multiple = $this->col_has_multiple($k);
$readonly = $this->readonly($k);
$strip_tags = true;
//$escape = true;
if ($this->col_has_checkboxes($k) || $this->col_has_radio_buttons($k)) {
echo $this->htmlRadioCheck($this->cgi['prefix']['data'].$this->fds[$k],
$css_class_name, $vals, $selected, $multiple, $readonly,
$strip_tags, $escape);
} else {
echo $this->htmlSelect($this->cgi['prefix']['data'].$this->fds[$k],
$css_class_name, $vals, $selected, $multiple, $readonly,
$strip_tags, $escape);
}
} elseif (isset ($this->fdd[$k]['textarea'])) {
echo '<textarea class="',$css_class_name,'" name="',$this->cgi['prefix']['data'].$this->fds[$k],'"';
echo ($this->readonly($k) ? ' disabled="disabled"' : '');
if (intval($this->fdd[$k]['textarea']['rows']) > 0) {
echo ' rows="',$this->fdd[$k]['textarea']['rows'],'"';
}
if (intval($this->fdd[$k]['textarea']['cols']) > 0) {
echo ' cols="',$this->fdd[$k]['textarea']['cols'],'"';
}
if (isset($this->fdd[$k]['textarea']['wrap'])) {
echo ' wrap="',$this->fdd[$k]['textarea']['wrap'],'"';
} else {
echo ' wrap="virtual"';
}
echo '>';
if($escape) echo htmlspecialchars($this->fdd[$k]['default']);
else echo $this->fdd[$k]['default'];
echo '</textarea>',"\n";
} elseif ($this->col_has_php($k)) {
echo include($this->fdd[$k]['php']);
} else {
// Simple edit box required
$size_ml_props = '';
$maxlen = intval($this->fdd[$k]['maxlen']);
$size = isset($this->fdd[$k]['size']) ? $this->fdd[$k]['size'] : min($maxlen, 60);
$size && $size_ml_props .= ' size="'.$size.'"';
$maxlen && $size_ml_props .= ' maxlength="'.$maxlen.'"';
echo '<input class="',$css_class_name,'" ';
echo ($this->password($k) ? 'type="password"' : 'type="text"');
echo ($this->readonly($k) ? ' disabled="disabled"' : '');
echo ' name="',$this->cgi['prefix']['data'].$this->fds[$k],'"';
echo $size_ml_props,' value="';
if($escape) echo htmlspecialchars($this->fdd[$k]['default']);
else echo $this->fdd[$k]['default'];
echo '" />';
}
echo '</td>',"\n";
if ($this->guidance) {
$css_class_name = $this->getCSSclass('help', null, true, $css_postfix);
$cell_value = $this->fdd[$k]['help'] ? $this->fdd[$k]['help'] : '&nbsp;';
echo '<td class="',$css_class_name,'">',$cell_value,'</td>',"\n";
}
echo '</tr>',"\n";
}
} /* }}} */
 
function display_copy_change_delete_record() /* {{{ */
{
/*
* For delete or change: SQL SELECT to retrieve the selected record
*/
 
$qparts['type'] = 'select';
$qparts['select'] = $this->get_SQL_column_list();
$qparts['from'] = $this->get_SQL_join_clause();
$qparts['where'] = '('.$this->fqn($this->key).'='
.$this->key_delim.$this->rec.$this->key_delim.')';
 
$res = $this->myquery($this->get_SQL_query($qparts),__LINE__);
if (! ($row = @mysql_fetch_array($res, MYSQL_ASSOC))) {
return false;
}
for ($tab = 0, $k = 0; $k < $this->num_fds; $k++) {
if (isset($this->fdd[$k]['tab']) && $this->tabs_enabled() && $k > 0) {
$tab++;
echo '</table>',"\n";
echo '</div>',"\n";
echo '<div id="'.$this->dhtml['prefix'].'tab',$tab,'">',"\n";
echo '<table class="',$this->getCSSclass('main'),'" summary="',$this->tb,'">',"\n";
}
if (! $this->displayed[$k]) {
continue;
}
if ($this->copy_operation() || $this->change_operation()) {
if ($this->hidden($k)) {
if ($k != $this->key_num) {
echo $this->htmlHiddenData($this->fds[$k], $row["qf$k"]);
}
continue;
}
$css_postfix = @$this->fdd[$k]['css']['postfix'];
echo '<tr class="',$this->getCSSclass('row', null, 'next', $css_postfix),'">',"\n";
echo '<td class="',$this->getCSSclass('key', null, true, $css_postfix),'">';
echo $this->fdd[$k]['name'],'</td>',"\n";
/* There are two possibilities of readonly fields handling:
1. Display plain text for readonly timestamps, dates and URLs.
2. Display disabled input field
In all cases particular readonly field will NOT be saved. */
if ($this->readonly($k) && ($this->col_has_datemask($k) || $this->col_has_URL($k))) {
echo $this->display_delete_field($row, $k);
} elseif ($this->password($k)) {
echo $this->display_password_field($row, $k);
} else {
echo $this->display_change_field($row, $k);
}
if ($this->guidance) {
$css_class_name = $this->getCSSclass('help', null, true, $css_postfix);
$cell_value = $this->fdd[$k]['help'] ? $this->fdd[$k]['help'] : '&nbsp;';
echo '<td class="',$css_class_name,'">',$cell_value,'</td>',"\n";
}
echo '</tr>',"\n";
} elseif ($this->delete_operation() || $this->view_operation()) {
$css_postfix = @$this->fdd[$k]['css']['postfix'];
echo '<tr class="',$this->getCSSclass('row', null, 'next', $css_postfix),'">',"\n";
echo '<td class="',$this->getCSSclass('key', null, true, $css_postfix),'">';
echo $this->fdd[$k]['name'],'</td>',"\n";
if ($this->password($k)) {
echo '<td class="',$this->getCSSclass('value', null, true, $css_postfix),'"';
echo $this->getColAttributes($k),'>',$this->labels['hidden'],'</td>',"\n";
} else {
$this->display_delete_field($row, $k);
}
if ($this->guidance) {
$css_class_name = $this->getCSSclass('help', null, true, $css_postfix);
$cell_value = $this->fdd[$k]['help'] ? $this->fdd[$k]['help'] : '&nbsp;';
echo '<td class="',$css_class_name,'">',$cell_value,'</td>',"\n";
}
echo '</tr>',"\n";
}
}
} /* }}} */
 
function display_change_field($row, $k) /* {{{ */
{
$css_postfix = @$this->fdd[$k]['css']['postfix'];
$css_class_name = $this->getCSSclass('input', null, true, $css_postfix);
$escape = isset($this->fdd[$k]['escape']) ? $this->fdd[$k]['escape'] : true;
echo '<td class="',$this->getCSSclass('value', null, true, $css_postfix),'"';
echo $this->getColAttributes($k),">\n";
if ($this->col_has_values($k)) {
$vals = $this->set_values($k);
$multiple = $this->col_has_multiple($k);
$readonly = $this->readonly($k);
$strip_tags = true;
//$escape = true;
if ($this->col_has_checkboxes($k) || $this->col_has_radio_buttons($k)) {
echo $this->htmlRadioCheck($this->cgi['prefix']['data'].$this->fds[$k],
$css_class_name, $vals, $row["qf$k"], $multiple, $readonly,
$strip_tags, $escape);
} else {
echo $this->htmlSelect($this->cgi['prefix']['data'].$this->fds[$k],
$css_class_name, $vals, $row["qf$k"], $multiple, $readonly,
$strip_tags, $escape);
}
} elseif (isset($this->fdd[$k]['textarea'])) {
echo '<textarea class="',$css_class_name,'" name="',$this->cgi['prefix']['data'].$this->fds[$k],'"';
echo ($this->readonly($k) ? ' disabled="disabled"' : '');
if (intval($this->fdd[$k]['textarea']['rows']) > 0) {
echo ' rows="',$this->fdd[$k]['textarea']['rows'],'"';
}
if (intval($this->fdd[$k]['textarea']['cols']) > 0) {
echo ' cols="',$this->fdd[$k]['textarea']['cols'],'"';
}
if (isset($this->fdd[$k]['textarea']['wrap'])) {
echo ' wrap="',$this->fdd[$k]['textarea']['wrap'],'"';
} else {
echo ' wrap="virtual"';
}
echo '>';
if($escape) echo htmlspecialchars($row["qf$k"]);
else echo $row["qf$k"];
echo '</textarea>',"\n";
} elseif ($this->col_has_php($k)) {
echo include($this->fdd[$k]['php']);
} else {
$size_ml_props = '';
$maxlen = intval($this->fdd[$k]['maxlen']);
$size = isset($this->fdd[$k]['size']) ? $this->fdd[$k]['size'] : min($maxlen, 60);
$size && $size_ml_props .= ' size="'.$size.'"';
$maxlen && $size_ml_props .= ' maxlength="'.$maxlen.'"';
echo '<input class="',$css_class_name,'" type="text" ';
echo ($this->readonly($k) ? 'disabled="disabled" ' : '');
echo 'name="',$this->cgi['prefix']['data'].$this->fds[$k],'" value="';
if($escape) echo htmlspecialchars($row["qf$k"]);
else echo $row["qf$k"];
echo '" />',"\n";
}
echo '</td>',"\n";
} /* }}} */
 
function display_password_field($row, $k) /* {{{ */
{
$css_postfix = @$this->fdd[$k]['css']['postfix'];
echo '<td class="',$this->getCSSclass('value', null, true, $css_postfix),'"';
echo $this->getColAttributes($k),">\n";
$size_ml_props = '';
$maxlen = intval($this->fdd[$k]['maxlen']);
$size = isset($this->fdd[$k]['size']) ? $this->fdd[$k]['size'] : min($maxlen, 60);
$size && $size_ml_props .= ' size="'.$size.'"';
$maxlen && $size_ml_props .= ' maxlength="'.$maxlen.'"';
echo '<input class="',$this->getCSSclass('value', null, true, $css_postfix),'" type="password" ';
echo ($this->readonly($k) ? 'disabled="disabled" ' : '');
echo 'name="',$this->cgi['prefix']['data'].$this->fds[$k],'" value="';
echo htmlspecialchars($row["qf$k"]),'" ',$size_ml_props,' />',"\n";
echo '</td>',"\n";
} /* }}} */
 
function display_delete_field($row, $k) /* {{{ */
{
$css_postfix = @$this->fdd[$k]['css']['postfix'];
$css_class_name = $this->getCSSclass('value', null, true, $css_postfix);
echo '<td class="',$css_class_name,'"',$this->getColAttributes($k),">\n";
echo $this->cellDisplay($k, $row, $css_class_name);
echo '</td>',"\n";
} /* }}} */
 
/**
* Returns CSS class name
*/
function getCSSclass($name, $position = null, $divider = null, $postfix = null) /* {{{ */
{
static $div_idx = -1;
$elements = array($this->css['prefix'], $name);
if ($this->page_type && $this->css['page_type']) {
if ($this->page_type != 'L' && $this->page_type != 'F') {
$elements[] = $this->page_types[$this->page_type];
}
}
if ($position && $this->css['position']) {
$elements[] = $position;
}
if ($divider && $this->css['divider']) {
if ($divider === 'next') {
$div_idx++;
if ($this->css['divider'] > 0 && $div_idx >= $this->css['divider']) {
$div_idx = 0;
}
}
$elements[] = $div_idx;
}
if ($postfix) {
$elements[] = $postfix;
}
return join($this->css['separator'], $elements);
} /* }}} */
 
/**
* Returns field cell HTML attributes
*/
function getColAttributes($k) /* {{{ */
{
$colattrs = '';
if (isset($this->fdd[$k]['colattrs'])) {
$colattrs .= ' ';
$colattrs .= trim($this->fdd[$k]['colattrs']);
}
if (isset($this->fdd[$k]['nowrap'])) {
$colattrs .= ' nowrap';
}
return $colattrs;
} /* }}} */
 
/**
* Substitutes variables in string
* (this is very simple but secure eval() replacement)
*/
function substituteVars($str, $subst_ar) /* {{{ */
{
$array = preg_split('/(\\$\w+)/', $str, -1, PREG_SPLIT_DELIM_CAPTURE);
$count = count($array);
for ($i = 1; $i < $count; $i += 2) {
$key = substr($array[$i], 1);
if (isset($subst_ar[$key])) {
$array[$i] = $subst_ar[$key];
}
}
return join('', $array);
} /* }}} */
 
/**
* Print URL
*/
function urlDisplay($k, $link_val, $disp_val, $css, $key) /* {{{ */
{
$escape = isset($this->fdd[$k]['escape']) ? $this->fdd[$k]['escape'] : true;
$ret = '';
$name = $this->fds[$k];
$page = $this->page_name;
$url = $this->cgi['prefix']['sys'].'rec'.'='.$key.'&'.$this->cgi['prefix']['sys'].'fm'
.'='.$this->fm.'&'.$this->cgi['prefix']['sys'].'fl'.'='.$this->fl;
$url .= '&'.$this->cgi['prefix']['sys'].'qfn'.'='.rawurlencode($this->qfn).$this->qfn;
$url .= '&'.$this->get_sfn_cgi_vars().$this->cgi['persist'];
$ar = array(
'key' => $key,
'name' => $name,
'link' => $link_val,
'value' => $disp_val,
'css' => $css,
'page' => $page,
'url' => $url
);
$urllink = isset($this->fdd[$k]['URL'])
? $this->substituteVars($this->fdd[$k]['URL'], $ar)
: $link_val;
$urldisp = isset($this->fdd[$k]['URLdisp'])
? $this->substituteVars($this->fdd[$k]['URLdisp'], $ar)
: $disp_val;
$target = isset($this->fdd[$k]['URLtarget'])
? 'target="'.htmlspecialchars($this->fdd[$k]['URLtarget']).'" '
: '';
$prefix_found = false;
$postfix_found = false;
$prefix_ar = @$this->fdd[$k]['URLprefix'];
$postfix_ar = @$this->fdd[$k]['URLpostfix'];
is_array($prefix_ar) || $prefix_ar = array($prefix_ar);
is_array($postfix_ar) || $postfix_ar = array($postfix_ar);
foreach ($prefix_ar as $prefix) {
if (! strncmp($prefix, $urllink, strlen($prefix))) {
$prefix_found = true;
break;
}
}
foreach ($postfix_ar as $postfix) {
if (! strncmp($postfix, $urllink, strlen($postfix))) {
$postfix_found = true;
break;
}
}
$prefix_found || $urllink = array_shift($prefix_ar).$urllink;
$postfix_found || $urllink = $urllink.array_shift($postfix_ar);
if (strlen($urllink) <= 0 || strlen($urldisp) <= 0) {
$ret = '&nbsp;';
} else {
if ($escape) {
$urldisp = htmlspecialchars($urldisp);
}
$urllink = htmlspecialchars($urllink);
$ret = '<a '.$target.'class="'.$css.'" href="'.$urllink.'">'.$urldisp.'</a>';
}
return $ret;
} /* }}} */
 
function cellDisplay($k, $row, $css) /* {{{ */
{
$escape = isset($this->fdd[$k]['escape']) ? $this->fdd[$k]['escape'] : true;
$key_rec = $row['qf'.$this->key_num];
if (@$this->fdd[$k]['datemask']) {
$value = intval($row["qf$k".'_timestamp']);
$value = $value ? @date($this->fdd[$k]['datemask'], $value) : '';
} else if (@$this->fdd[$k]['strftimemask']) {
$value = intval($row["qf$k".'_timestamp']);
$value = $value ? @strftime($this->fdd[$k]['strftimemask'], $value) : '';
} else if ($this->is_values2($k, $row["qf$k"])) {
$value = $row['qf'.$k.'_idx'];
if ($this->fdd[$k]['select'] == 'M') {
$value_ar = explode(',', $value);
$value_ar2 = array();
foreach ($value_ar as $value_key) {
if (isset($this->fdd[$k]['values2'][$value_key])) {
$value_ar2[$value_key] = $this->fdd[$k]['values2'][$value_key];
$escape = false;
}
}
$value = join(', ', $value_ar2);
} else {
if (isset($this->fdd[$k]['values2'][$value])) {
$value = $this->fdd[$k]['values2'][$value];
$escape = false;
}
}
} elseif (isset($this->fdd[$k]['values2'][$row["qf$k"]])) {
$value = $this->fdd[$k]['values2'][$row["qf$k"]];
} else {
$value = $row["qf$k"];
}
$original_value = $value;
if (@$this->fdd[$k]['strip_tags']) {
$value = strip_tags($value);
}
if ($num_ar = @$this->fdd[$k]['number_format']) {
if (! is_array($num_ar)) {
$num_ar = array($num_ar);
}
if (count($num_ar) == 1) {
list($nbDec) = $num_ar;
$value = number_format($value, $nbDec);
} else if (count($num_ar) == 3) {
list($nbDec, $decPoint, $thSep) = $num_ar;
$value = number_format($value, $nbDec, $decPoint, $thSep);
}
}
if (intval($this->fdd[$k]['trimlen']) > 0 && strlen($value) > $this->fdd[$k]['trimlen']) {
$value = ereg_replace("[\r\n\t ]+",' ',$value);
$value = substr($value, 0, $this->fdd[$k]['trimlen'] - 3).'...';
}
if (@$this->fdd[$k]['mask']) {
$value = sprintf($this->fdd[$k]['mask'], $value);
}
if ($this->col_has_php($k)) {
return include($this->fdd[$k]['php']);
}
if ($this->col_has_URL($k)) {
return $this->urlDisplay($k, $original_value, $value, $css, $key_rec);
}
if (strlen($value) <= 0) {
return '&nbsp;';
}
if ($escape) {
$value = htmlspecialchars($value);
}
return nl2br($value);
} /* }}} */
 
/**
* Creates HTML submit input element
*
* @param name element name
* @param label key in the language hash used as label
* @param css_class_name CSS class name
* @param js_validation if add JavaScript validation subroutine to button
* @param disabled if mark the button as disabled
* @param js any extra text in tags
*/
function htmlSubmit($name, $label, $css_class_name, $js_validation = true, $disabled = false, $js = NULL) /* {{{ */
{
// Note that <input disabled> isn't valid HTML, but most browsers support it
if($disabled == -1) return;
$markdisabled = $disabled ? ' disabled="disabled"' : '';
$ret = '<input'.$markdisabled.' type="submit" class="'.$css_class_name
.'" name="'.$this->cgi['prefix']['sys'].ltrim($markdisabled).$name
.'" value="'.(isset($this->labels[$label]) ? $this->labels[$label] : $label);
if ($js_validation) {
$ret .= '" onclick="return '.$this->js['prefix'].'form_control(this.form);';
}
$ret .='"';
if(isset($js)) $ret .= ' '.$js;
$ret .= ' />';
return $ret;
} /* }}} */
 
/**
* Creates HTML hidden input element
*
* @param name element name
* @param value value
*/
 
function htmlHiddenSys($name, $value) /* {{{ */
{
return $this->htmlHidden($this->cgi['prefix']['sys'].$name, $value);
} /* }}} */
 
function htmlHiddenData($name, $value) /* {{{ */
{
return $this->htmlHidden($this->cgi['prefix']['data'].$name, $value);
} /* }}} */
 
function htmlHidden($name, $value) /* {{{ */
{
return '<input type="hidden" name="'.htmlspecialchars($name)
.'" value="'.htmlspecialchars($value).'" />'."\n";
} /* }}} */
 
/**
* Creates HTML select element (tag)
*
* @param name element name
* @param css CSS class name
* @param kv_array key => value array
* @param selected selected key (it can be single string, array of
* keys or multiple values separated by comma)
* @param multiple bool for multiple selection
* @param readonly bool for readonly/disabled selection
* @param strip_tags bool for stripping tags from values
* @param escape bool for HTML escaping values
* @param js string to be in the <select >, ususally onchange='..';
*/
function htmlSelect($name, $css, $kv_array, $selected = null, /* ...) {{{ */
/* booleans: */ $multiple = false, $readonly = false, $strip_tags = false, $escape = true, $js = NULL)
{
$ret = '<select class="'.htmlspecialchars($css).'" name="'.htmlspecialchars($name);
if ($multiple) {
$ret .= '[]" multiple size="'.$this->multiple;
if (! is_array($selected) && $selected !== null) {
$selected = explode(',', $selected);
}
}
$ret .= '"'.($readonly ? ' disabled="disabled"' : '').$js.'>'."\n";
if (! is_array($selected)) {
$selected = $selected === null ? array() : array($selected);
}
$found = false;
foreach ($kv_array as $key => $value) {
$ret .= '<option value="'.htmlspecialchars($key).'"';
if ((! $found || $multiple) && in_array((string) $key, $selected, 1)
|| (count($selected) == 0 && ! $found && ! $multiple)) {
$ret .= ' selected="selected"';
$found = true;
}
$strip_tags && $value = strip_tags($value);
$escape && $value = htmlspecialchars($value);
$ret .= '>'.$value.'</option>'."\n";
}
$ret .= '</select>';
return $ret;
} /* }}} */
 
/**
* Creates HTML checkboxes or radio buttons
*
* @param name element name
* @param css CSS class name
* @param kv_array key => value array
* @param selected selected key (it can be single string, array of
* keys or multiple values separated by comma)
* @param multiple bool for multiple selection (checkboxes)
* @param readonly bool for readonly/disabled selection
* @param strip_tags bool for stripping tags from values
* @param escape bool for HTML escaping values
* @param js string to be in the <select >, ususally onchange='..';
*/
function htmlRadioCheck($name, $css, $kv_array, $selected = null, /* ...) {{{ */
/* booleans: */ $multiple = false, $readonly = false, $strip_tags = false, $escape = true, $js = NULL)
{
$ret = '';
if ($multiple) {
if (! is_array($selected) && $selected !== null) {
$selected = explode(',', $selected);
}
}
if (! is_array($selected)) {
$selected = $selected === null ? array() : array($selected);
}
$found = false;
foreach ($kv_array as $key => $value) {
$ret .= '<input type="'.($multiple ? 'checkbox' : 'radio').'" name="';
$ret .= htmlspecialchars($name).'[]" value="'.htmlspecialchars($key).'"';
if ((! $found || $multiple) && in_array((string) $key, $selected, 1)
|| (count($selected) == 0 && ! $found && ! $multiple)) {
$ret .= ' checked';
$found = true;
}
if ($readonly) {
$ret .= ' disabled="disabled"';
}
$strip_tags && $value = strip_tags($value);
$escape && $value = htmlspecialchars($value);
$ret .= '>'.$value.'<br>'."\n";
}
return $ret;
} /* }}} */
 
/**
* Returns original variables HTML code for use in forms or links.
*
* @param mixed $origvars string or array of original varaibles
* @param string $method type of method ("POST" or "GET")
* @param mixed $default_value default value of variables
* if null, empty values will be skipped
* @return get HTML code of original varaibles
*/
function get_origvars_html($origvars, $method = 'post', $default_value = '') /* {{{ */
{
$ret = '';
$method = strtoupper($method);
if ($method == 'POST') {
if (! is_array($origvars)) {
$new_origvars = array();
foreach (explode('&', $origvars) as $param) {
$parts = explode('=', $param, 2);
if (! isset($parts[1])) {
$parts[1] = $default_value;
}
if (strlen($parts[0]) <= 0) {
continue;
}
$new_origvars[$parts[0]] = $parts[1];
}
$origvars =& $new_origvars;
}
foreach ($origvars as $key => $val) {
if (strlen($val) <= 0 && $default_value === null) {
continue;
}
$key = rawurldecode($key);
$val = rawurldecode($val);
$ret .= $this->htmlHidden($key, $val);
}
} else if (! strncmp('GET', $method, 3)) {
if (! is_array($origvars)) {
$ret .= $origvars;
} else {
foreach ($origvars as $key => $val) {
if (strlen($val) <= 0 && $default_value === null) {
continue;
}
$ret == '' || $ret .= '&amp;';
$ret .= htmlspecialchars(rawurlencode($key));
$ret .= '=';
$ret .= htmlspecialchars(rawurlencode($val));
}
}
if ($method[strlen($method) - 1] == '+') {
$ret = "?$ret";
}
} else {
trigger_error('Unsupported Platon::get_origvars_html() method: '
.$method, E_USER_ERROR);
}
return $ret;
} /* }}} */
 
function get_sfn_cgi_vars($alternative_sfn = null) /* {{{ */
{
if ($alternative_sfn === null) { // FAST! (cached return value)
static $ret = null;
$ret == null && $ret = $this->get_sfn_cgi_vars($this->sfn);
return $ret;
}
$ret = '';
$i = 0;
foreach ($alternative_sfn as $val) {
$ret != '' && $ret .= '&';
$ret .= rawurlencode($this->cgi['prefix']['sys'].'sfn')."[$i]=".rawurlencode($val);
$i++;
}
return $ret;
} /* }}} */
 
function get_default_cgi_prefix($type) /* {{{ */
{
switch ($type) {
case 'operation': return 'PME_op_';
case 'sys': return 'PME_sys_';
case 'data': return 'PME_data_';
}
return '';
} /* }}} */
 
function get_sys_cgi_var($name, $default_value = null) /* {{{ */
{
if (isset($this)) {
return $this->get_cgi_var($this->cgi['prefix']['sys'].$name, $default_value);
}
return phpMyEdit::get_cgi_var(phpMyEdit::get_default_cgi_prefix('sys').$name, $default_value);
} /* }}} */
 
function get_data_cgi_var($name, $default_value = null) /* {{{ */
{
if (isset($this)) {
return $this->get_cgi_var($this->cgi['prefix']['data'].$name, $default_value);
}
return phpMyEdit::get_cgi_var(phpMyEdit::get_default_cgi_prefix('data').$name, $default_value);
} /* }}} */
 
function get_cgi_var($name, $default_value = null) /* {{{ */
{
if (isset($this) && isset($this->cgi['overwrite'][$name])) {
return $this->cgi['overwrite'][$name];
}
 
static $magic_quotes_gpc = null;
if ($magic_quotes_gpc === null) {
$magic_quotes_gpc = get_magic_quotes_gpc();
}
$var = @$_GET[$name];
if (! isset($var)) {
$var = @$_POST[$name];
}
if (isset($var)) {
if ($magic_quotes_gpc) {
if (is_array($var)) {
foreach (array_keys($var) as $key) {
$var[$key] = stripslashes($var[$key]);
}
} else {
$var = stripslashes($var);
}
}
} else {
$var = @$default_value;
}
if (isset($this) && $var === null && isset($this->cgi['append'][$name])) {
return $this->cgi['append'][$name];
}
return $var;
} /* }}} */
 
function get_server_var($name) /* {{{ */
{
if (isset($_SERVER[$name])) {
return $_SERVER[$name];
}
global $HTTP_SERVER_VARS;
if (isset($HTTP_SERVER_VARS[$name])) {
return $HTTP_SERVER_VARS[$name];
}
global $$name;
if (isset($$name)) {
return $$name;
}
return null;
} /* }}} */
 
/*
* Debug functions
*/
 
function print_get_vars ($miss = 'No GET variables found') // debug only /* {{{ */
{
// we parse form GET variables
if (is_array($_GET)) {
echo "<p> Variables per GET ";
foreach ($_GET as $k => $v) {
if (is_array($v)) {
foreach ($v as $akey => $aval) {
// $_GET[$k][$akey] = strip_tags($aval);
// $$k[$akey] = strip_tags($aval);
echo "$k\[$akey\]=$aval ";
}
} else {
// $_GET[$k] = strip_tags($val);
// $$k = strip_tags($val);
echo "$k=$v ";
}
}
echo '</p>';
} else {
echo '<p>';
echo $miss;
echo '</p>';
}
} /* }}} */
 
function print_post_vars($miss = 'No POST variables found') // debug only /* {{{ */
{
global $_POST;
// we parse form POST variables
if (is_array($_POST)) {
echo "<p>Variables per POST ";
foreach ($_POST as $k => $v) {
if (is_array($v)) {
foreach ($v as $akey => $aval) {
// $_POST[$k][$akey] = strip_tags($aval);
// $$k[$akey] = strip_tags($aval);
echo "$k\[$akey\]=$aval ";
}
} else {
// $_POST[$k] = strip_tags($val);
// $$k = strip_tags($val);
echo "$k=$v ";
}
}
echo '</p>';
} else {
echo '<p>';
echo $miss;
echo '</p>';
}
} /* }}} */
 
function print_vars ($miss = 'Current instance variables') // debug only /* {{{ */
{
echo "$miss ";
echo 'page_name=',$this->page_name,' ';
echo 'hn=',$this->hn,' ';
echo 'un=',$this->un,' ';
echo 'pw=',$this->pw,' ';
echo 'db=',$this->db,' ';
echo 'dbp=',$this->dbp,' ';
echo 'dbh=',$this->dbh,' ';
echo 'tb=',$this->tb,' ';
echo 'key=',$this->key,' ';
echo 'key_type=',$this->key_type,' ';
echo 'inc=',$this->inc,' ';
echo 'options=',$this->options,' ';
echo 'fdd=',$this->fdd,' ';
echo 'fl=',$this->fl,' ';
echo 'fm=',$this->fm,' ';
echo 'sfn=',htmlspecialchars($this->get_sfn_cgi_vars()),' ';
echo 'qfn=',$this->qfn,' ';
echo 'sw=',$this->sw,' ';
echo 'rec=',$this->rec,' ';
echo 'navop=',$this->navop,' ';
echo 'saveadd=',$this->saveadd,' ';
echo 'moreadd=',$this->moreadd,' ';
echo 'canceladd=',$this->canceladd,' ';
echo 'savechange=',$this->savechange,' ';
echo 'morechange=',$this->morechange,' ';
echo 'cancelchange=',$this->cancelchange,' ';
echo 'savecopy=',$this->savecopy,' ';
echo 'cancelcopy=',$this->cancelcopy,' ';
echo 'savedelete=',$this->savedelete,' ';
echo 'canceldelete=',$this->canceldelete,' ';
echo 'cancelview=',$this->cancelview,' ';
echo 'operation=',$this->operation,' ';
echo "\n";
} /* }}} */
 
/*
* Display buttons at top and bottom of page
*/
function display_list_table_buttons($position, $listall = false) /* {{{ */
{
if (($but_str = $this->display_buttons($position)) === null)
return;
if($position == 'down') echo '<hr class="'.$this->getCSSclass('hr', 'down').'" />'."\n";
echo '<table summary="navigation" class="',$this->getCSSclass('navigation', $position),'">',"\n";
echo '<tr class="',$this->getCSSclass('navigation', $position),'">',"\n";
echo '<td class="',$this->getCSSclass('buttons', $position),'">',"\n";
echo $but_str,'</td>',"\n";
// Message is now written here
if (strlen(@$this->message) > 0) {
echo '<td class="',$this->getCSSclass('message', $position),'">',$this->message,'</td>',"\n";
}
if($this->display['num_pages'] || $this->display['num_records'])
echo '<td class="',$this->getCSSclass('stats', $position),'">',"\n";
if($this->display['num_pages']) {
if ($listall) {
echo $this->labels['Page'],':&nbsp;1&nbsp;',$this->labels['of'],'&nbsp;1';
} else {
$current_page = intval($this->fm / $this->inc) + 1;
$total_pages = max(1, ceil($this->total_recs / abs($this->inc)));
echo $this->labels['Page'],':&nbsp;',$current_page;
echo '&nbsp;',$this->labels['of'],'&nbsp;',$total_pages;
}
}
if($this->display['num_records'])
echo '&nbsp; ',$this->labels['Records'],':&nbsp;',$this->total_recs;
if($this->display['num_pages'] || $this->display['num_records']) echo '</td>';
echo '</tr></table>',"\n";
if($position == 'up') echo '<hr class="'.$this->getCSSclass('hr', 'up').'" />'."\n";
} /* }}} */
 
/*
* Display buttons at top and bottom of page
*/
function display_record_buttons($position) /* {{{ */
{
if (($but_str = $this->display_buttons($position)) === null)
return;
if ($position == 'down') {
if ($this->tabs_enabled()) $this->display_tab_labels('down');
echo '<hr class="',$this->getCSSclass('hr', 'down'),'" />',"\n";
}
echo '<table summary="navigation" class="',$this->getCSSclass('navigation', $position),'">',"\n";
echo '<tr class="',$this->getCSSclass('navigation', $position),'">',"\n";
echo '<td class="',$this->getCSSclass('buttons', $position),'">',"\n";
echo $but_str,'</td>',"\n";
// Message is now written here
//echo '</td>',"\n";
if (strlen(@$this->message) > 0) {
echo '<td class="',$this->getCSSclass('message', $position),'">',$this->message,'</td>',"\n";
}
echo '</tr></table>',"\n";
if ($position == 'up') {
if ($this->tabs_enabled()) $this->display_tab_labels('up');
echo '<hr class="',$this->getCSSclass('hr', 'up'),'" />',"\n";
}
} /* }}} */
 
function display_buttons($position) /* {{{ */
{
$nav_fnc = 'nav_'.$position;
if(! $this->$nav_fnc())
return;
$buttons = (is_array($this->buttons[$this->page_type][$position]))
? $this->buttons[$this->page_type][$position]
: $this->default_buttons[$this->page_type];
foreach ($buttons as $name) {
$ret .= $this->display_button($name, $position)."\n";
}
return $ret;
} /* }}} */
 
function display_button($name, $position = 'up') /* {{{ */
{
if (is_array($name)) {
if (isset($name['code'])) return $name['code'];
return $this->htmlSubmit($name['name'], $name['value'], $name['css'], $name['disabled'], $name['js']);
}
$disabled = 1; // show disabled by default
if ($name[0] == '+') { $name = substr($name, 1); $disabled = 0; } // always show disabled as enabled
if ($name[0] == '-') { $name = substr($name, 1); $disabled = -1; } // don't show disabled
if ($name == 'cancel') {
return $this->htmlSubmit('cancel'.$this->page_types[$this->page_type], 'Cancel',
$this->getCSSclass('cancel', $position), false);
}
if (in_array($name, array('add','view','change','copy','delete'))) {
$enabled_fnc = $name.'_enabled';
$enabled = $this->$enabled_fnc();
if ($name != 'add' && ! $this->total_recs && strstr('LF', $this->page_type))
$enabled = false;
return $this->htmlSubmit('operation', ucfirst($name),
$this->getCSSclass($name, $position), false, $enabled ? 0 : $disabled);
}
if ($name == 'savedelete') {
$enabled = $this->delete_enabled();
$js = 'onclick="return confirm(\''.$this->labels['Delete'].' ?\');"';
return $this->htmlSubmit('savedelete', 'Delete',
$this->getCSSclass('save', $position), false, $enabled ? 0 : $disabled, $js);
}
if (in_array($name, array('save','more'))) {
$validation = true; // if js validation
if ($this->page_type == 'D' && $name == 'save' ) { $value = 'Delete'; $validation = false; }
elseif ($this->page_type == 'C' && $name == 'more' ) { $value = 'Apply'; }
else $value = ucfirst($name);
return $this->htmlSubmit($name.$this->page_types[$this->page_type], $value,
$this->getCSSclass($name, $position), $validation);
}
$listall = $this->inc <= 0;
if ($listall) {
$disabledprev = true;
$disablednext = true;
$total_pages = 1;
$current_page = 1;
} else {
$disabledprev = $this->fm <= 0;
$disablednext = $this->fm + $this->inc >= $this->total_recs;
$total_pages = max(1, ceil($this->total_recs / abs($this->inc)));
$current_page = ceil($this->fm / abs($this->inc)); // must + 1
}
$disabledfirst = $disabledprev;
$disabledlast = $disablednext;
// some statistics first
if ($name == 'total_pages') return $total_pages;
if ($name == 'current_page') return ($current_page+1);
if ($name == 'total_recs') return ($this->total_recs);
// now some goto buttons/dropdowns/inputs...
if ($name == 'goto_text') {
$ret = '<input type="text" class="'.$this->getCSSclass('gotopn', $position).'"';
$ret .= ' name="'.$this->cgi['prefix']['sys'].'navpn'.$position.'" value="'.($current_page+1).'"';
$ret .= ' size="'.(strlen($total_pages)+1).'" maxlength="'.(strlen($total_pages)+1).'"';
// TODO some js here.... on enter submit, on click erase ?...
$ret .=' oneypress="return PE_filter_handler(this.form, event);" />';
return $ret;
}
if ($name == 'goto_combo') {
$disabledgoto = !($listall || ($disablednext && $disabledprev)) ? '' : ' disabled';
if ($disablegoto != '' && $disabled < 0) return;
$kv_array = array();
for ($i = 0; $i < $total_pages; $i++) {
$kv_array[$this->inc * $i] = $i + 1;
}
// TODO: add onchange="return this.form.submit();" DONE ???
return $this->htmlSelect($this->cgi['prefix']['sys'].ltrim($disabledgoto).'navfm'.$position,
$this->getCSSclass('goto', $position), $kv_array, (string)$this->fm, false, $disabledgoto,
false, true, 'onchange="return this.form.submit();"');
}
if ($name == 'goto') {
return $this->htmlSubmit('navop', 'Go to', $this->getCSSclass('goto', $position),
false, ($listall || ($disablednext && $disabledprev)) ? $disabled : 0);
}
if (in_array($name, array('first','prev','next','last','<<','<','>','>>'))) {
$disabled_var = 'disabled'.$name;
$name2 = $name;
if (strlen($name) <= 2) {
$nav_values = array('<<' => 'first', '<' => 'prev', '>' => 'next', '>>' => 'last');
$disabled_var = 'disabled'.$nav_values[$name];
$name2 = $nav_values[$name];
}
return $this->htmlSubmit('navop', ucfirst($name),
$this->getCSSclass($name2, $position), false, $$disabled_var ? $disabled : 0);
}
if(isset($this->labels[$name])) return $this->labels[$name];
return $name;
} /* }}} */
 
function number_of_recs() /* {{{ */
{
$count_parts = array(
'type' => 'select',
'select' => 'count(*)',
'from' => $this->get_SQL_join_clause(),
'where' => $this->get_SQL_where_from_query_opts());
$res = $this->myquery($this->get_SQL_query($count_parts), __LINE__);
$row = @mysql_fetch_array($res, MYSQL_NUM);
$this->total_recs = $row[0];
} /* }}} */
 
/*
* Table Page Listing
*/
function list_table() /* {{{ */
{
if ($this->fm == '') {
$this->fm = 0;
}
$this->fm = $this->navfm;
if ($this->prev_operation()) {
$this->fm = $this->fm - $this->inc;
if ($this->fm < 0) {
$this->fm = 0;
}
}
if ($this->first_operation()) {
$this->fm = 0;
} // last operation must be performed below, after retrieving total_recs
if ($this->next_operation()) {
$this->fm += $this->inc;
}
$this->number_of_recs();
if ($this->last_operation() || $this->fm > $this->total_recs) { // if goto_text is badly set
$this->fm = (int)(($this->total_recs - 1)/$this->inc)*$this->inc;
}
// If sort sequence has changed, restart listing
$this->qfn != $this->prev_qfn && $this->fm = 0;
if (0) { // DEBUG
echo 'qfn vs. prev_qfn comparsion ';
echo '[<b>',htmlspecialchars($this->qfn),'</b>]';
echo '[<b>',htmlspecialchars($this->prev_qfn),'</b>]<br />';
echo 'comparsion <u>',($this->qfn == $this->prev_qfn ? 'proved' : 'failed'),'</u>';
echo '<hr />';
}
/*
* If user is allowed to Change/Delete records, we need an extra column
* to allow users to select a record
*/
$select_recs = $this->key != '' &&
($this->change_enabled() || $this->delete_enabled() || $this->view_enabled());
// Are we doing a listall?
$listall = $this->inc <= 0;
/*
* Display the MySQL table in an HTML table
*/
$this->form_begin();
echo $this->get_origvars_html($this->get_sfn_cgi_vars());
echo $this->htmlHiddenSys('fl', $this->fl);
// Display buttons at top and/or bottom of page.
$this->display_list_table_buttons('up', $listall);
if ($this->cgi['persist'] != '') {
echo $this->get_origvars_html($this->cgi['persist']);
}
if (! $this->filter_operation()) {
echo $this->get_origvars_html($this->qfn);
}
echo $this->htmlHiddenSys('qfn', $this->qfn);
echo $this->htmlHiddenSys('fm', $this->fm);
echo '<table class="',$this->getCSSclass('main'),'" summary="',$this->tb,'">',"\n";
echo '<tr class="',$this->getCSSclass('header'),'">',"\n";
/*
* System (navigation, selection) columns counting
*/
$sys_cols = 0;
$sys_cols += intval($this->filter_enabled() || $select_recs);
if ($sys_cols > 0) {
$sys_cols += intval($this->nav_buttons()
&& ($this->nav_text_links() || $this->nav_graphic_links()));
}
/*
* We need an initial column(s) (sys columns)
* if we have filters, Changes or Deletes enabled
*/
if ($sys_cols) {
echo '<th class="',$this->getCSSclass('header'),'" colspan="',$sys_cols,'">';
if ($this->filter_enabled()) {
if ($this->filter_operation()) {
echo $this->htmlSubmit('sw', 'Hide', $this->getCSSclass('hide'), false);
echo $this->htmlSubmit('sw', 'Clear', $this->getCSSclass('clear'), false);
} else {
echo $this->htmlSubmit('sw', 'Search', $this->getCSSclass('search'), false);
}
} else {
echo '&nbsp;';
}
echo '</th>',"\n";
}
for ($k = 0; $k < $this->num_fds; $k++) {
$fd = $this->fds[$k];
if (! $this->displayed[$k]) {
continue;
}
$css_postfix = @$this->fdd[$k]['css']['postfix'];
$css_class_name = $this->getCSSclass('header', null, null, $css_postfix);
$fdn = $this->fdd[$fd]['name'];
if (! $this->fdd[$fd]['sort'] || $this->password($fd)) {
echo '<th class="',$css_class_name,'">',$fdn,'</th>',"\n";
} else {
// Clicking on the current sort field reverses the sort order
$new_sfn = $this->sfn;
array_unshift($new_sfn, in_array("$k", $new_sfn, 1) ? "-$k" : $k);
echo '<th class="',$css_class_name,'">';
echo '<a class="',$css_class_name,'" href="';
echo htmlspecialchars($this->page_name.'?'.$this->cgi['prefix']['sys'].'fm'.'=0'
.'&'.$this->cgi['prefix']['sys'].'fl'.'='.$this->fl
.'&'.$this->cgi['prefix']['sys'].'qfn'.'='.rawurlencode($this->qfn).$this->qfn
.'&'.$this->get_sfn_cgi_vars($new_sfn).$this->cgi['persist']);
echo '">',$fdn,'</a></th>',"\n";
}
}
echo '</tr>',"\n";
 
/*
* Prepare the SQL Query from the data definition file
*/
$qparts['type'] = 'select';
$qparts['select'] = $this->get_SQL_column_list();
// Even if the key field isn't displayed, we still need its value
if ($select_recs) {
if (!in_array ($this->key, $this->fds)) {
$qparts['select'] .= ','.$this->fqn($this->key);
}
}
$qparts['from'] = $this->get_SQL_join_clause();
$qparts['where'] = $this->get_SQL_where_from_query_opts();
// build up the ORDER BY clause
if (isset($this->sfn)) {
$sort_fields = array();
$sort_fields_w = array();
foreach ($this->sfn as $field) {
if ($field[0] == '-') {
$field = substr($field, 1);
$desc = true;
} else {
$field = $field;
$desc = false;
}
$sort_field = $this->fqn($field);
$sort_field_w = $this->fdd[$field]['name'];
$this->col_has_sql($field) && $sort_field_w .= ' (sql)';
if ($desc) {
$sort_field .= ' DESC';
$sort_field_w .= ' '.$this->labels['descending'];
} else {
$sort_field_w .= ' '.$this->labels['ascending'];
}
$sort_fields[] = $sort_field;
$sort_fields_w[] = $sort_field_w;
}
if (count($sort_fields) > 0) {
$qparts['orderby'] = join(',', $sort_fields);
}
}
$qparts['limit'] = $listall ? '' : $this->fm.','.$this->inc;
 
/*
* Main list_table() query
*
* Each row of the HTML table is one record from the SQL query. We must
* perform this query before filter printing, because we want to use
* mysql_field_len() function. We will also fetch the first row to get
* the field names.
*/
$query = $this->get_SQL_query($qparts);
$res = $this->myquery($query, __LINE__);
if ($res == false) {
$this->error('invalid SQL query', $query);
return false;
}
$row = @mysql_fetch_array($res, MYSQL_ASSOC);
 
/* FILTER {{{
*
* Draw the filter and fill it with any data typed in last pass and stored
* in the array parameter keyword 'filter'. Prepare the SQL WHERE clause.
*/
if ($this->filter_operation()) {
// Filter row retrieval
$fields = false;
$filter_row = $row;
if (! is_array($filter_row)) {
unset($qparts['where']);
$query = $this->get_SQL_query($qparts);
$res = $this->myquery($query, __LINE__);
if ($res == false) {
$this->error('invalid SQL query', $query);
return false;
}
$filter_row = @mysql_fetch_array($res, MYSQL_ASSOC);
}
/* Variable $fields is used to get index of particular field in
result. That index can be passed in example to mysql_field_len()
function. Use field names as indexes to $fields array. */
if (is_array($filter_row)) {
$fields = array_flip(array_keys($filter_row));
}
if ($fields != false) {
$css_class_name = $this->getCSSclass('filter');
echo '<tr class="',$css_class_name,'">',"\n";
echo '<td class="',$css_class_name,'" colspan="',$sys_cols,'">';
echo $this->htmlSubmit('filter', 'Query', $this->getCSSclass('query'), false);
echo '</td>', "\n";
for ($k = 0; $k < $this->num_fds; $k++) {
if (! $this->displayed[$k]) {
continue;
}
$css_postfix = @$this->fdd[$k]['css']['postfix'];
$css_class_name = $this->getCSSclass('filter', null, null, $css_postfix);
$this->field_name = $this->fds[$k];
$fd = $this->field_name;
$this->field = $this->fdd[$fd];
$l = 'qf'.$k;
$lc = 'qf'.$k.'_comp';
$li = 'qf'.$k.'_id';
if ($this->clear_operation()) {
$m = null;
$mc = null;
$mi = null;
} else {
$m = $this->get_sys_cgi_var($l);
$mc = $this->get_sys_cgi_var($lc);
$mi = $this->get_sys_cgi_var($li);
}
echo '<td class="',$css_class_name,'">';
if ($this->password($k)) {
echo '&nbsp;';
} else if ($this->fdd[$fd]['select'] == 'D' || $this->fdd[$fd]['select'] == 'M') {
// Multiple fields processing
// Default size is 2 and array required for values.
$from_table = ! $this->col_has_values($k) || isset($this->fdd[$k]['values']['table']);
$vals = $this->set_values($k, array('*' => '*'), null, $from_table);
$selected = $mi;
$multiple = $this->col_has_multiple_select($k);
$multiple |= $this->fdd[$fd]['select'] == 'M';
$readonly = false;
$strip_tags = true;
$escape = true;
echo $this->htmlSelect($this->cgi['prefix']['sys'].$l.'_id', $css_class_name,
$vals, $selected, $multiple, $readonly, $strip_tags, $escape);
} elseif ($this->fdd[$fd]['select'] == 'N' || $this->fdd[$fd]['select'] == 'T') {
$size_ml_props = '';
$maxlen = intval($this->fdd[$k]['maxlen']);
$maxlen > 0 || $maxlen = intval(@mysql_field_len($res, $fields["qf$k"]));
$size = isset($this->fdd[$k]['size']) ? $this->fdd[$k]['size']
: ($maxlen < 30 ? min($maxlen, 8) : 12);
$size && $size_ml_props .= ' size="'.$size.'"';
$maxlen && $size_ml_props .= ' maxlength="'.$maxlen.'"';
if ($this->fdd[$fd]['select'] == 'N') {
$mc = in_array($mc, $this->comp_ops) ? $mc : '=';
echo $this->htmlSelect($this->cgi['prefix']['sys'].$l.'_comp',
$css_class_name, $this->comp_ops, $mc);
}
echo '<input class="',$css_class_name,'" value="',htmlspecialchars(@$m);
echo '" type="text" name="'.$this->cgi['prefix']['sys'].'qf'.$k.'"',$size_ml_props;
echo ' onkeypress="return '.$this->js['prefix'].'filter_handler(this.form, event);" />';
} else {
echo '&nbsp;';
}
echo '</td>',"\n";
}
echo '</tr>',"\n";
}
} // }}}
/*
* Display sorting sequence
*/
if ($qparts['orderby'] && $this->display['sort']) {
$css_class_name = $this->getCSSclass('sortinfo');
echo '<tr class="',$css_class_name,'">',"\n";
echo '<td class="',$css_class_name,'" colspan="',$sys_cols,'">';
echo '<a class="',$css_class_name,'" href="';
echo htmlspecialchars($this->page_name
.'?'.$this->cgi['prefix']['sys'].'fl'.'='.$this->fl
.'&'.$this->cgi['prefix']['sys'].'fm'.'='.$this->fm
.'&'.$this->cgi['prefix']['sys'].'qfn'.'='.rawurlencode($this->qfn)
.$this->qfn.$this->cgi['persist']);
echo '">',$this->labels['Clear'],'</a></td>',"\n";
echo '<td class="',$css_class_name,'" colspan="',$this->num_fields_displayed,'">';
echo $this->labels['Sorted By'],': ',join(', ', $sort_fields_w),'</td></tr>',"\n";
}
 
/*
* Display the current query
*/
$text_query = $this->get_SQL_where_from_query_opts(null, true);
if ($text_query != '' && $this->display['query']) {
$css_class_name = $this->getCSSclass('queryinfo');
echo '<tr class="',$css_class_name,'">',"\n";
echo '<td class="',$css_class_name,'" colspan="',$sys_cols,'">';
echo '<a class="',$css_class_name,'" href="';
echo htmlspecialchars($this->get_server_var('PHP_SELF')
.'?'.$this->cgi['prefix']['sys'].'fl'.'='.$this->fl
.'&'.$this->cgi['prefix']['sys'].'fm'.'='.$this->fm
.'&'.$this->cgi['prefix']['sys'].'qfn'.'='.rawurlencode($this->qfn)
.'&'.$this->get_sfn_cgi_vars().$this->cgi['persist']);
echo '">',$this->labels['Clear'],'</a></td>',"\n";
echo '<td class="',$css_class_name,'" colspan="',$this->num_fields_displayed,'">';
echo $this->labels['Current Query'],': ',htmlspecialchars($text_query),'</td></tr>',"\n";
}
 
if ($this->nav_text_links() || $this->nav_graphic_links()) {
$qstrparts = array();
strlen($this->fl) > 0 && $qstrparts[] = $this->cgi['prefix']['sys'].'fl'.'='.$this->fl;
strlen($this->fm) > 0 && $qstrparts[] = $this->cgi['prefix']['sys'].'fm'.'='.$this->fm;
count($this->sfn) > 0 && $qstrparts[] = $this->get_sfn_cgi_vars();
strlen($this->cgi['persist']) > 0 && $qstrparts[] = $this->cgi['persist'];
$qpview = $qstrparts;
$qpcopy = $qstrparts;
$qpchange = $qstrparts;
$qpdelete = $qstrparts;
$qp_prefix = $this->cgi['prefix']['sys'].'operation'.'='.$this->cgi['prefix']['operation'];
$qpview[] = $qp_prefix.'View';
$qpcopy[] = $qp_prefix.'Copy';
$qpchange[] = $qp_prefix.'Change';
$qpdelete[] = $qp_prefix.'Delete';
$qpviewStr = htmlspecialchars($this->page_name.'?'.join('&',$qpview).$this->qfn);
$qpcopyStr = htmlspecialchars($this->page_name.'?'.join('&',$qpcopy).$this->qfn);
$qpchangeStr = htmlspecialchars($this->page_name.'?'.join('&',$qpchange).$this->qfn);
$qpdeleteStr = htmlspecialchars($this->page_name.'?'.join('&',$qpdelete).$this->qfn);
}
 
$fetched = true;
$first = true;
$rowCount = 0;
while ((!$fetched && ($row = @mysql_fetch_array($res, MYSQL_ASSOC)) != false)
|| ($fetched && $row != false)) {
$fetched = false;
echo '<tr class="',$this->getCSSclass('row', null, 'next'),'">',"\n";
if ($sys_cols) { /* {{{ */
$key_rec = $row['qf'.$this->key_num];
$queryAppend = htmlspecialchars('&'.$this->cgi['prefix']['sys'].'rec'.'='.$key_rec);
$viewQuery = $qpviewStr . $queryAppend;
$copyQuery = $qpcopyStr . $queryAppend;
$changeQuery = $qpchangeStr . $queryAppend;
$deleteQuery = $qpdeleteStr . $queryAppend;
$viewTitle = htmlspecialchars($this->labels['View']);
$changeTitle = htmlspecialchars($this->labels['Change']);
$copyTitle = htmlspecialchars($this->labels['Copy']);
$deleteTitle = htmlspecialchars($this->labels['Delete']);
$css_class_name = $this->getCSSclass('navigation', null, true);
if ($select_recs) {
if (! $this->nav_buttons() || $sys_cols > 1) {
echo '<td class="',$css_class_name,'">';
}
if ($this->nav_graphic_links()) {
$printed_out = false;
if ($this->view_enabled()) {
$printed_out = true;
echo '<a class="',$css_class_name,'" href="',$viewQuery,'"><img class="';
echo $css_class_name,'" src="',$this->url['images'];
echo 'pme-view.png" height="15" width="16" border="0" ';
echo 'alt="',$viewTitle,'" title="',$viewTitle,'" /></a>';
}
if ($this->change_enabled()) {
$printed_out && print('&nbsp;');
$printed_out = true;
echo '<a class="',$css_class_name,'" href="',$changeQuery,'"><img class="';
echo $css_class_name,'" src="',$this->url['images'];
echo 'pme-change.png" height="15" width="16" border="0" ';
echo 'alt="',$changeTitle,'" title="',$changeTitle,'" /></a>';
}
if ($this->copy_enabled()) {
$printed_out && print('&nbsp;');
$printed_out = true;
echo '<a class="',$css_class_name,'" href="',$copyQuery,'"><img class="';
echo $css_class_name,'" src="',$this->url['images'];
echo 'pme-copy.png" height="15" width="16" border="0" ';
echo 'alt="',$copyTitle,'" title="',$copyTitle,'" /></a>';
}
if ($this->delete_enabled()) {
$printed_out && print('&nbsp;');
$printed_out = true;
echo '<a class="',$css_class_name,'" href="',$deleteQuery,'"><img class="';
echo $css_class_name,'" src="',$this->url['images'];
echo 'pme-delete.png" height="15" width="16" border="0" ';
echo 'alt="',$deleteTitle,'" title="',$deleteTitle,'" /></a>';
}
}
if ($this->nav_text_links()) {
if ($this->nav_graphic_links()) {
echo '<br class="',$css_class_name,'">';
}
$printed_out = false;
if ($this->view_enabled()) {
$printed_out = true;
echo '<a href="',$viewQuery,'" title="',$viewTitle,'" class="',$css_class_name,'">V</a>';
}
if ($this->change_enabled()) {
$printed_out && print('&nbsp;');
$printed_out = true;
echo '<a href="',$changeQuery,'" title="',$changeTitle,'" class="',$css_class_name,'">C</a>';
}
if ($this->copy_enabled()) {
$printed_out && print('&nbsp;');
$printed_out = true;
echo '<a href="',$copyQuery,'" title="',$copyTitle,'" class="',$css_class_name,'">P</a>';
}
if ($this->delete_enabled()) {
$printed_out && print('&nbsp;');
$printed_out = true;
echo '<a href="',$deleteQuery,'" title="',$deleteTitle,'" class="',$css_class_name,'">D</a>';
}
}
if (! $this->nav_buttons() || $sys_cols > 1) {
echo '</td>',"\n";
}
if ($this->nav_buttons()) {
echo '<td class="',$css_class_name,'"><input class="',$css_class_name;
echo '" type="radio" name="'.$this->cgi['prefix']['sys'].'rec';
echo '" value="',htmlspecialchars($key_rec),'"';
if (($this->rec == '' && $first) || ($this->rec == $key_rec)) {
echo ' checked';
$first = false;
}
echo ' /></td>',"\n";
}
} elseif ($this->filter_enabled()) {
echo '<td class="',$css_class_name,'" colspan=',$sys_cols,'>&nbsp;</td>',"\n";
}
} /* }}} */
for ($k = 0; $k < $this->num_fds; $k++) { /* {{{ */
$fd = $this->fds[$k];
if (! $this->displayed[$k]) {
continue;
}
$css_postfix = @$this->fdd[$k]['css']['postfix'];
$css_class_name = $this->getCSSclass('cell', null, true, $css_postfix);
if ($this->password($k)) {
echo '<td class="',$css_class_name,'">',$this->labels['hidden'],'</td>',"\n";
continue;
}
echo '<td class="',$css_class_name,'"',$this->getColAttributes($fd),'>';
echo $this->cellDisplay($k, $row, $css_class_name);
echo '</td>',"\n";
} /* }}} */
echo '</tr>',"\n";
}
 
/*
* Display and accumulate column aggregation info, do totalling query
* XXX this feature does not work yet!!!
*/
// aggregates listing (if any)
if ($$var_to_total) {
// do the aggregate query if necessary
//if ($vars_to_total) {
$qp = array();
$qp['type'] = 'select';
$qp['select'] = $aggr_from_clause;
$qp['from'] = $this->get_SQL_join_clause();
$qp['where'] = $this->get_SQL_where_from_query_opts();
$tot_query = $this->get_SQL_query($qp);
$totals_result = $this->myquery($tot_query,__LINE__);
$tot_row = @mysql_fetch_array($totals_result, MYSQL_ASSOC);
//}
$qp_aggr = $qp;
echo "\n",'<tr class="TODO-class">',"\n",'<td class="TODO-class">&nbsp;</td>',"\n";
/*
echo '<td>';
echo printarray($qp_aggr);
echo printarray($vars_to_total);
echo '</td>';
echo '<td colspan="'.($this->num_fds-1).'">'.$var_to_total.' '.$$var_to_total.'</td>';
*/
// display the results
for ($k=0;$k<$this->num_fds;$k++) {
$fd = $this->fds[$k];
if (stristr($this->fdd[$fd]['options'],'L') or !isset($this->fdd[$fd]['options'])) {
echo '<td>';
$aggr_var = 'qf'.$k.'_aggr';
$$aggr_var = $this->get_sys_cgi_var($aggr_var);
if ($$aggr_var) {
echo $this->sql_aggrs[$$aggr_var],': ',$tot_row[$aggr_var];
} else {
echo '&nbsp;';
}
echo '</td>',"\n";
}
}
echo '</tr>',"\n";
}
echo '</table>',"\n"; // end of table rows listing
$this->display_list_table_buttons('down', $listall);
$this->form_end();
} /* }}} */
 
function display_record() /* {{{ */
{
// PRE Triggers
$ret = true;
if ($this->change_operation()) {
$ret &= $this->exec_triggers_simple('update', 'pre');
// if PRE update fails, then back to view operation
if (! $ret) {
$this->operation = $this->labels['View'];
$ret = true;
}
}
if ($this->add_operation() || $this->copy_operation()) {
$ret &= $this->exec_triggers_simple('insert', 'pre');
}
if ($this->view_operation()) {
$ret &= $this->exec_triggers_simple('select', 'pre');
}
if ($this->delete_operation()) {
$ret &= $this->exec_triggers_simple('delete', 'pre');
}
// if PRE insert/view/delete fail, then back to the list
if ($ret == false) {
$this->operation = '';
$this->list_table();
return;
}
$this->form_begin();
if ($this->cgi['persist'] != '') {
echo $this->get_origvars_html($this->cgi['persist']);
}
echo $this->get_origvars_html($this->get_sfn_cgi_vars());
echo $this->get_origvars_html($this->qfn);
echo $this->htmlHiddenSys('cur_tab', $this->dhtml['prefix'].'tab'.$this->cur_tab);
echo $this->htmlHiddenSys('qfn', $this->qfn);
echo $this->htmlHiddenSys('rec', $this->copy_operation() ? '' : $this->rec);
echo $this->htmlHiddenSys('fm', $this->fm);
echo $this->htmlHiddenSys('fl', $this->fl);
$this->display_record_buttons('up');
if ($this->tabs_enabled()) {
echo '<div id="'.$this->dhtml['prefix'].'tab0">',"\n";
}
echo '<table class="',$this->getCSSclass('main'),'" summary="',$this->tb,'">',"\n";
if ($this->add_operation()) {
$this->display_add_record();
} else {
$this->display_copy_change_delete_record();
}
echo '</table>',"\n";
if ($this->tabs_enabled()) {
echo '</div>',"\n";
}
$this->display_record_buttons('down');
 
$this->form_end();
} /* }}} */
 
/*
* Action functions
*/
 
function do_add_record() /* {{{ */
{
// Preparing query
$query = '';
$key_col_val = '';
$newvals = array();
for ($k = 0; $k < $this->num_fds; $k++) {
if ($this->processed($k)) {
$fd = $this->fds[$k];
if ($this->readonly($k)) {
$fn = (string) @$this->fdd[$k]['default'];
} else {
$fn = $this->get_data_cgi_var($fd);
}
if ($fd == $this->key) {
$key_col_val = $fn;
}
$newvals[$fd] = is_array($fn) ? join(',',$fn) : $fn;
}
}
// Creating array of changed keys ($changed)
$changed = array_keys($newvals);
// Before trigger, newvals can be efectively changed
if ($this->exec_triggers('insert', 'before', $oldvals, $changed, $newvals) == false) {
return false;
}
// Real query (no additional query in this method)
foreach ($newvals as $fd => $val) {
if ($fd == '') continue;
if ($this->col_has_sqlw($this->fdn[$fd])) {
$val_as = addslashes($val);
$val_qas = '"'.addslashes($val).'"';
$value = $this->substituteVars(
$this->fdd[$this->fdn[$fd]]['sqlw'], array(
'val_qas' => $val_qas,
'val_as' => $val_as,
'val' => $val
));
} else {
$value = "'".addslashes($val)."'";
}
if ($query == '') {
$query = 'INSERT INTO `'.$this->tb.'` (`'.$fd.'`'; // )
$query2 = ') VALUES ('.$value.'';
} else {
$query .= ', `'.$fd.'`';
$query2 .= ', '.$value.'';
}
}
$query .= $query2.')';
$res = $this->myquery($query, __LINE__);
$this->message = @mysql_affected_rows($this->dbh).' '.$this->labels['record added'];
if (! $res) {
return false;
}
$this->rec = mysql_insert_id($this->dbh);
// Notify list
if (@$this->notify['insert'] || @$this->notify['all']) {
$this->email_notify(false, $newvals);
}
// Note change in log table
if ($this->logtable) {
$query = sprintf('INSERT INTO %s'
.' (updated, user, host, operation, tab, rowkey, col, oldval, newval)'
.' VALUES (NOW(), "%s", "%s", "insert", "%s", "%s", "", "", "%s")',
$this->logtable, addslashes($this->get_server_var('REMOTE_USER')),
addslashes($this->get_server_var('REMOTE_ADDR')), addslashes($this->tb),
addslashes($key_col_val), addslashes(serialize($newvals)));
$this->myquery($query, __LINE__);
}
// After trigger
if ($this->exec_triggers('insert', 'after', $oldvals, $changed, $newvals) == false) {
return false;
}
return true;
} /* }}} */
 
function do_change_record() /* {{{ */
{
// Preparing queries
$query_real = '';
$query_oldrec = '';
$newvals = array();
$oldvals = array();
$changed = array();
// Prepare query to retrieve oldvals
for ($k = 0; $k < $this->num_fds; $k++) {
if ($this->processed($k) && !$this->readonly($k)) {
$fd = $this->fds[$k];
$fn = $this->get_data_cgi_var($fd);
$newvals[$this->fds[$k]] = is_array($fn) ? join(',',$fn) : $fn;
if ($query_oldrec == '') {
$query_oldrec = 'SELECT '.$fd;
} else {
$query_oldrec .= ','.$fd;
}
}
}
$where_part = " WHERE (".$this->key.'='.$this->key_delim.$this->rec.$this->key_delim.')';
$query_newrec = $query_oldrec.' FROM ' . $this->tb;
$query_oldrec .= ' FROM ' . $this->tb . $where_part;
// Additional query (must go before real query)
$res = $this->myquery($query_oldrec, __LINE__);
$oldvals = @mysql_fetch_array($res, MYSQL_ASSOC);
@mysql_free_result($res);
// Creating array of changed keys ($changed)
foreach ($newvals as $fd => $value) {
if ($value != $oldvals[$fd])
$changed[] = $fd;
}
// Before trigger
if ($this->exec_triggers('update', 'before', $oldvals, $changed, $newvals) == false) {
return false;
}
// Build the real query respecting changes to the newvals array
foreach ($newvals as $fd => $val) {
if ($fd == '') continue;
if ($this->col_has_sqlw($this->fdn[$fd])) {
$val_as = addslashes($val);
$val_qas = '"'.addslashes($val).'"';
$value = $this->substituteVars(
$this->fdd[$this->fdn[$fd]]['sqlw'], array(
'val_qas' => $val_qas,
'val_as' => $val_as,
'val' => $val
));
} else {
$value = "'".addslashes($val)."'";
}
if ($query_real == '') {
$query_real = 'UPDATE '.$this->tb.' SET '.$fd.'='.$value;
} else {
$query_real .= ','.$fd.'='.$value;
}
}
$query_real .= $where_part;
// Real query
$res = $this->myquery($query_real, __LINE__);
$this->message = @mysql_affected_rows($this->dbh).' '.$this->labels['record changed'];
if (! $res) {
return false;
}
// Another additional query (must go after real query)
if (in_array($this->key, $changed)) {
$this->rec = $newvals[$this->key]; // key has changed
}
$query_newrec .= ' WHERE ('.$this->key.'='.$this->key_delim.$this->rec.$this->key_delim.')';
$res = $this->myquery($query_newrec, __LINE__);
$newvals = @mysql_fetch_array($res, MYSQL_ASSOC);
@mysql_free_result($res);
// Creating array of changed keys ($changed)
$changed = array();
foreach ($newvals as $fd => $value) {
if ($value != $oldvals[$fd])
$changed[] = $fd;
}
// Notify list
if (@$this->notify['update'] || @$this->notify['all']) {
if (count($changed) > 0) {
$this->email_notify($oldvals, $newvals);
}
}
// Note change in log table
if ($this->logtable) {
foreach ($changed as $key) {
$qry = sprintf('INSERT INTO %s'
.' (updated, user, host, operation, tab, rowkey, col, oldval, newval)'
.' VALUES (NOW(), "%s", "%s", "update", "%s", "%s", "%s", "%s", "%s")',
$this->logtable, addslashes($this->get_server_var('REMOTE_USER')),
addslashes($this->get_server_var('REMOTE_ADDR')), addslashes($this->tb),
addslashes($this->rec), addslashes($key),
addslashes($oldvals[$key]), addslashes($newvals[$key]));
$this->myquery($qry, __LINE__);
}
}
// After trigger
if ($this->exec_triggers('update', 'after', $oldvals, $changed, $newvals) == false) {
return false;
}
return true;
} /* }}} */
 
function do_delete_record() /* {{{ */
{
// Additional query
$query = 'SELECT * FROM '.$this->tb.' WHERE ('.$this->key.' = '
.$this->key_delim.$this->rec.$this->key_delim.')'; // )
$res = $this->myquery($query, __LINE__);
$oldvals = @mysql_fetch_array($res, MYSQL_ASSOC);
@mysql_free_result($res);
// Creating array of changed keys ($changed)
$changed = array_keys($oldvals);
$newvals = array();
// Before trigger
if ($this->exec_triggers('delete', 'before', $oldvals, $changed, $newvals) == false) {
return false;
}
// Real query
$query = 'DELETE FROM '.$this->tb.' WHERE ('.$this->key.' = '
.$this->key_delim.$this->rec.$this->key_delim.')'; // )
$res = $this->myquery($query, __LINE__);
$this->message = @mysql_affected_rows($this->dbh).' '.$this->labels['record deleted'];
if (! $res) {
return false;
}
// Notify list
if (@$this->notify['delete'] || @$this->notify['all']) {
$this->email_notify($oldvals, false);
}
// Note change in log table
if ($this->logtable) {
$query = sprintf('INSERT INTO %s'
.' (updated, user, host, operation, tab, rowkey, col, oldval, newval)'
.' VALUES (NOW(), "%s", "%s", "delete", "%s", "%s", "%s", "%s", "")',
$this->logtable, addslashes($this->get_server_var('REMOTE_USER')),
addslashes($this->get_server_var('REMOTE_ADDR')), addslashes($this->tb),
addslashes($this->rec), addslashes($key), addslashes(serialize($oldvals)));
$this->myquery($query, __LINE__);
}
// After trigger
if ($this->exec_triggers('delete', 'after', $oldvals, $changed, $newvals) == false) {
return false;
}
return true;
} /* }}} */
 
function email_notify($old_vals, $new_vals) /* {{{ */
{
if (! function_exists('mail')) {
return false;
}
if ($old_vals != false && $new_vals != false) {
$action = 'update';
$subject = 'Record updated in';
$body = 'An item with '.$this->fdd[$this->key]['name'].' = '
.$this->key_delim.$this->rec.$this->key_delim .' was updated in';
$vals = $new_vals;
} elseif ($new_vals != false) {
$action = 'insert';
$subject = 'Record added to';
$body = 'A new item was added into';
$vals = $new_vals;
} elseif ($old_vals != false) {
$action = 'delete';
$subject = 'Record deleted from';
$body = 'An item was deleted from';
$vals = $old_vals;
} else {
return false;
}
$addr = $this->get_server_var('REMOTE_ADDR');
$user = $this->get_server_var('REMOTE_USER');
$body = 'This notification e-mail was automatically generated by phpMyEdit.'."\n\n".$body;
$body .= ' table '.$this->tb.' in MySQL database '.$this->db.' on '.$this->page_name;
$body .= ' by '.($user == '' ? 'unknown user' : "user $user").' from '.$addr;
$body .= ' at '.date('d/M/Y H:i').' with the following fields:'."\n\n";
$i = 1;
foreach ($vals as $k => $text) {
$name = isset($this->fdd[$k]['name~'])
? $this->fdd[$k]['name~'] : $this->fdd[$k]['name'];
if ($action == 'update') {
if ($old_vals[$k] == $new_vals[$k]) {
continue;
}
$body .= sprintf("[%02s] %s (%s)\n WAS: %s\n IS: %s\n",
$i, $name, $k, $old_vals[$k], $new_vals[$k]);
} else {
$body .= sprintf('[%02s] %s (%s): %s'."\n", $i, $name, $k, $text);
}
$i++;
}
$body .= "\n--\r\n"; // \r is needed for signature separating
$body .= "phpMyEdit\ninstant MySQL table editor and code generator\n";
$body .= "http://platon.sk/projects/phpMyEdit/\n\n";
$subject = @$this->notify['prefix'].$subject.' '.$this->dbp.$this->tb;
$subject = trim($subject); // just for sure
$wrap_w = intval(@$this->notify['wrap']);
$wrap_w > 0 || $wrap_w = 72;
$from = (string) @$this->notify['from'];
$from != '' || $from = 'webmaster@'.strtolower($this->get_server_var('SERVER_NAME'));
$headers = 'From: '.$from."\n".'X-Mailer: PHP/'.phpversion().' (phpMyEdit)';
$body = wordwrap($body, $wrap_w, "\n", 1);
$emails = (array) $this->notify[$action] + (array) $this->notify['all'];
foreach ($emails as $email) {
if (! empty($email)) {
mail(trim($email), $subject, $body, $headers);
}
}
return true;
} /* }}} */
 
/*
* Apply triggers function
* Run a (set of) trigger(s). $trigger can be an Array or a filename
* Break and return false as soon as a trigger return false
* we need a reference on $newvals to be able to change value before insert/update
*/
function exec_triggers($op, $step, $oldvals, &$changed, &$newvals) /* {{{ */
{
if (! isset($this->triggers[$op][$step])) {
return true;
}
$ret = true;
$trig = $this->triggers[$op][$step];
if (is_array($trig)) {
ksort($trig);
for ($t = reset($trig); $t !== false && $ret != false; $t = next($trig)) {
$ret = include($t);
}
} else {
$ret = include($trig);
}
return $ret;
} /* }}} */
 
function exec_triggers_simple($op, $step) /* {{{ */
{
$oldvals = $newvals = $changed = array();
return $this->exec_triggers($op, $step, $oldvals, $changed, $newvals);
} /* }}} */
/*
* Recreate functions
*/
function recreate_fdd($default_page_type = 'L') /* {{{ */
{
// TODO: one level deeper browsing
$this->page_type = $default_page_type;
$this->filter_operation() && $this->page_type = 'F';
$this->view_operation() && $this->page_type = 'V';
if ($this->add_operation()
|| $this->saveadd == $this->labels['Save']
|| $this->moreadd == $this->labels['More']) {
$this->page_type = 'A';
}
if ($this->change_operation()
|| $this->savechange == $this->labels['Save']
|| $this->morechange == $this->labels['Apply']) {
$this->page_type = 'C';
}
if ($this->copy_operation() || $this->savecopy == $this->labels['Save']) {
$this->page_type = 'P';
}
if ($this->delete_operation() || $this->savedelete == $this->labels['Delete']) {
$this->page_type = 'D';
}
// Restore backups (if exists)
foreach (array_keys($this->fdd) as $column) {
foreach (array_keys($this->fdd[$column]) as $col_option) {
if ($col_option[strlen($col_option) - 1] != '~')
continue;
 
$this->fdd[$column][substr($col_option, 0, strlen($col_option) - 1)]
= $this->fdd[$column][$col_option];
unset($this->fdd[$column][$col_option]);
}
}
foreach (array_keys($this->fdd) as $column) {
foreach (array_keys($this->fdd[$column]) as $col_option) {
if (! strchr($col_option, '|')) {
continue;
}
$col_ar = explode('|', $col_option, 2);
if (! stristr($col_ar[1], $this->page_type)) {
continue;
}
// Make field backups
$this->fdd[$column][$col_ar[0] .'~'] = $this->fdd[$column][$col_ar[0]];
$this->fdd[$column][$col_option.'~'] = $this->fdd[$column][$col_option];
// Set particular field
$this->fdd[$column][$col_ar[0]] = $this->fdd[$column][$col_option];
unset($this->fdd[$column][$col_option]);
}
}
} /* }}} */
 
function recreate_displayed() /* {{{ */
{
$field_num = 0;
$num_fields_displayed = 0;
$this->fds = array();
$this->fdn = array();
$this->displayed = array();
$this->guidance = false;
foreach (array_keys($this->fdd) as $key) {
if (preg_match('/^\d+$/', $key)) { // skipping numeric keys
continue;
}
$this->fds[$field_num] = $key;
$this->fdn[$key] = $field_num;
/* We must use here displayed() function, because displayed[] array
is not created yet. We will simultaneously create that array as well. */
if ($this->displayed[$field_num] = $this->displayed($field_num)) {
$num_fields_displayed++;
}
if (is_array(@$this->fdd[$key]['values']) && ! isset($this->fdd[$key]['values']['table'])) {
foreach ($this->fdd[$key]['values'] as $val) {
$this->fdd[$key]['values2'][$val] = $val;
}
unset($this->fdd[$key]['values']);
}
isset($this->fdd[$key]['help']) && $this->guidance = true;
$this->fdd[$field_num] = $this->fdd[$key];
$field_num++;
}
$this->num_fds = $field_num;
$this->num_fields_displayed = $num_fields_displayed;
$this->key_num = array_search($this->key, $this->fds);
/* Adds first displayed column into sorting fields by replacing last
array entry. Also remove duplicite values and change column names to
their particular field numbers.
 
Note that entries like [0]=>'9' [1]=>'-9' are correct and they will
have desirable sorting behaviour. So there is no need to remove them.
*/
$this->sfn = array_unique($this->sfn);
$check_ar = array();
foreach ($this->sfn as $key => $val) {
if (preg_match('/^[-]?\d+$/', $val)) { // skipping numeric keys
$val = abs($val);
if (in_array($val, $check_ar) || $this->password($val)) {
unset($this->sfn[$key]);
} else {
$check_ar[] = $val;
}
continue;
}
if ($val[0] == '-') {
$val = substr($val, 1);
$minus = '-';
} else {
$minus = '';
}
if (($val = array_search($val, $this->fds)) === false || $this->password($val)) {
unset($this->sfn[$key]);
} else {
$val = intval($val);
if (in_array($val, $check_ar)) {
unset($this->sfn[$key]);
} else {
$this->sfn[$key] = $minus.$val;
$check_ar[] = $val;
}
}
}
$this->sfn = array_unique($this->sfn);
return true;
} /* }}} */
 
function backward_compatibility() /* {{{ */
{
foreach (array_keys($this->fdd) as $column) {
// move ['required'] to ['js']['required']
if (! isset($this->fdd[$column]['js']['required']) && isset($this->fdd[$column]['required'])) {
$this->fdd[$column]['js']['required'] = $this->fdd[$column]['required'];
}
// move 'HWR' flags from ['options'] into ['input']
if (isset($this->fdd[$column]['options'])) {
stristr($this->fdd[$column]['options'], 'H') && $this->fdd[$column]['input'] .= 'H';
stristr($this->fdd[$column]['options'], 'W') && $this->fdd[$column]['input'] .= 'W';
stristr($this->fdd[$column]['options'], 'R') && $this->fdd[$column]['input'] .= 'R';
}
}
} /* }}} */
 
/*
* Error handling function
*/
function error($message, $additional_info = '') /* {{{ */
{
echo '<h1>phpMyEdit error: ',htmlspecialchars($message),'</h1>',"\n";
if ($additional_info != '') {
echo '<hr />',htmlspecialchars($additional_info);
}
return false;
} /* }}} */
 
/*
* Database connection function
*/
function connect() /* {{{ */
{
if (isset($this->dbh)) {
return true;
}
if (!isset($this->db)) {
$this->error('no database defined');
return false;
}
if (!isset ($this->tb)) {
$this->error('no table defined');
return false;
}
$this->dbh = @ini_get('allow_persistent')
? @mysql_pconnect($this->hn, $this->un, $this->pw)
: @mysql_connect($this->hn, $this->un, $this->pw);
if (!$this->dbh) {
$this->error('could not connect to MySQL');
return false;
}
return true;
} /* }}} */
 
/*
* Database disconnection function
*/
function disconnect() /* {{{ */
{
if ($this->close_dbh) {
@mysql_close($this->dbh);
$this->dbh = null;
}
} /* }}} */
 
/*
* The workhorse
*/
function execute() /* {{{ */
{
// DEBUG - uncomment to enable
/*
//phpinfo();
$this->print_get_vars();
$this->print_post_vars();
$this->print_vars();
echo "<pre>query opts:\n";
echo print_r($this->query_opts);
echo "</pre>\n";
echo "<pre>get vars:\n";
echo print_r($this->get_opts);
echo "</pre>\n";
*/
 
// Let's do explicit quoting - it's safer
set_magic_quotes_runtime(0);
// Checking if language file inclusion was successful
if (! is_array($this->labels)) {
$this->error('could not locate language files', 'searched path: '.$this->dir['lang']);
return false;
}
// Database connection
if ($this->connect() == false) {
return false;
}
 
/*
* ======================================================================
* Pass 3: process any updates generated if the user has selected
* a save or cancel button during Pass 2
* ======================================================================
*/
// Cancel button - Cancel Triggers
if ($this->add_canceled() || $this->copy_canceled()) {
$this->exec_triggers_simple('insert', 'cancel');
}
if ($this->view_canceled()) {
$this->exec_triggers_simple('select', 'cancel');
}
if ($this->change_canceled()) {
$this->exec_triggers_simple('update', 'cancel');
}
if ($this->delete_canceled()) {
$this->exec_triggers_simple('delete', 'cancel');
}
// Save/More Button - database operations
if ($this->saveadd == $this->labels['Save'] || $this->savecopy == $this->labels['Save']) {
$this->add_enabled() && $this->do_add_record();
unset($this->saveadd);
unset($this->savecopy);
$this->recreate_fdd();
}
elseif ($this->moreadd == $this->labels['More']) {
$this->add_enabled() && $this->do_add_record();
$this->operation = $this->labels['Add']; // to force add operation
$this->recreate_fdd();
$this->recreate_displayed();
$this->backward_compatibility();
}
elseif ($this->savechange == $this->labels['Save']) {
$this->change_enabled() && $this->do_change_record();
unset($this->savechange);
$this->recreate_fdd();
}
elseif ($this->morechange == $this->labels['Apply']) {
$this->change_enabled() && $this->do_change_record();
$this->operation = $this->labels['Change']; // to force change operation
$this->recreate_fdd();
$this->recreate_displayed();
$this->backward_compatibility();
}
elseif ($this->savedelete == $this->labels['Delete']) {
$this->delete_enabled() && $this->do_delete_record();
unset($this->savedelete);
$this->recreate_fdd();
}
 
/*
* ======================================================================
* Pass 2: display an input/edit/confirmation screen if the user has
* selected an editing button on Pass 1 through this page
* ======================================================================
*/
if ($this->add_operation()
|| $this->change_operation() || $this->delete_operation()
|| $this->view_operation() || $this->copy_operation()) {
$this->display_record();
}
 
/*
* ======================================================================
* Pass 1 and Pass 3: display the MySQL table in a scrolling window on
* the screen (skip this step in 'Add More' mode)
* ======================================================================
*/
else {
$this->list_table();
}
 
$this->disconnect();
if ($this->display['time'] && $this->timer != null) {
echo $this->timer->end(),' miliseconds';
}
} /* }}} */
 
/*
* Class constructor
*/
function phpMyEdit($opts) /* {{{ */
{
// Set desirable error reporting level
$error_reporting = error_reporting(E_ALL & ~E_NOTICE);
// Database handle variables
if (isset($opts['dbh'])) {
$this->close_dbh = false;
$this->dbh = $opts['dbh'];
$this->dbp = '';
} else {
$this->close_dbh = true;
$this->dbh = null;
$this->dbp = $opts['db'].'.';
$this->hn = $opts['hn'];
$this->un = $opts['un'];
$this->pw = $opts['pw'];
$this->db = $opts['db'];
}
$this->tb = $opts['tb'];
// Other variables
$this->key = $opts['key'];
$this->key_type = $opts['key_type'];
$this->inc = $opts['inc'];
$this->options = $opts['options'];
$this->fdd = $opts['fdd'];
$this->multiple = intval($opts['multiple']);
$this->multiple <= 0 && $this->multiple = 2;
$this->filters = @$opts['filters'];
$this->triggers = @$opts['triggers'];
$this->notify = @$opts['notify'];
$this->logtable = @$opts['logtable'];
$this->page_name = @$opts['page_name'];
if (! isset($this->page_name)) {
$this->page_name = basename($this->get_server_var('PHP_SELF'));
isset($this->page_name) || $this->page_name = $this->tb;
}
$this->display['query'] = @$opts['display']['query'];
$this->display['sort'] = @$opts['display']['sort'];
$this->display['time'] = @$opts['display']['time'];
if ($this->display['time']) {
$this->timer = new phpMyEdit_timer();
}
$this->display['tabs'] = isset($opts['display']['tabs'])
? $opts['display']['tabs'] : true;
$this->display['form'] = isset($opts['display']['form'])
? $opts['display']['form'] : true;
$this->display['num_records'] = isset($opts['display']['num_records'])
? $opts['display']['num_records'] : true;
$this->display['num_pages'] = isset($opts['display']['num_pages'])
? $opts['display']['num_pages'] : true;
// Creating directory variables
$this->dir['root'] = dirname(realpath(__FILE__))
. (strlen(dirname(realpath(__FILE__))) > 0 ? '/' : '');
$this->dir['lang'] = $this->dir['root'].'lang/';
// Creating URL variables
$this->url['images'] = 'images/';
isset($opts['url']['images']) && $this->url['images'] = $opts['url']['images'];
// CSS classes policy
$this->css = @$opts['css'];
!isset($this->css['separator']) && $this->css['separator'] = '-';
!isset($this->css['prefix']) && $this->css['prefix'] = 'pme';
!isset($this->css['page_type']) && $this->css['page_type'] = false;
!isset($this->css['position']) && $this->css['position'] = false;
!isset($this->css['divider']) && $this->css['divider'] = 2;
$this->css['divider'] = intval(@$this->css['divider']);
// JS overall configuration
$this->js = @$opts['js'];
!isset($this->js['prefix']) && $this->js['prefix'] = 'PME_js_';
// DHTML overall configuration
$this->dhtml = @$opts['dhtml'];
!isset($this->dhtml['prefix']) && $this->dhtml['prefix'] = 'PME_dhtml_';
// Navigation
$this->navigation = @$opts['navigation'];
if (! $this->nav_buttons() && ! $this->nav_text_links() && ! $this->nav_graphic_links()) {
$this->navigation .= 'B'; // buttons are default
}
if (! $this->nav_up() && ! $this->nav_down()) {
$this->navigation .= 'D'; // down position is default
}
$this->buttons = $opts['buttons'];
// Language labels (must go after navigation)
$this->labels = $this->make_language_labels(isset($opts['language'])
? $opts['language'] : $this->get_server_var('HTTP_ACCEPT_LANGUAGE'));
// CGI variables
$this->cgi = @$opts['cgi'];
$this->cgi['persist'] = '';
if (@is_array($opts['cgi']['persist'])) {
foreach ($opts['cgi']['persist'] as $key => $val) {
if (is_array($val)) {
foreach($val as $key2 => $val2) {
$this->cgi['persist'] .= '&'.rawurlencode($key)
.'['.rawurlencode($key2).']='.rawurlencode($val2);
}
} else {
$this->cgi['persist'] .= '&'.rawurlencode($key).'='.rawurlencode($val);
}
}
}
foreach (array('operation', 'sys', 'data') as $type) {
if (! isset($this->cgi['prefix'][$type])) {
$this->cgi['prefix'][$type] = $this->get_default_cgi_prefix($type);
}
}
// Sorting variables
$this->sfn = $this->get_sys_cgi_var('sfn');
isset($this->sfn) || $this->sfn = array();
is_array($this->sfn) || $this->sfn = array($this->sfn);
isset($opts['sort_field']) || $opts['sort_field'] = array();
is_array($opts['sort_field']) || $opts['sort_field'] = array($opts['sort_field']);
$this->sfn = array_merge($this->sfn, $opts['sort_field']);
// Form variables all around
$this->fl = intval($this->get_sys_cgi_var('fl'));
$this->fm = intval($this->get_sys_cgi_var('fm'));
// $old_page = ceil($this->fm / abs($this->inc)) + 1;
$this->qfn = $this->get_sys_cgi_var('qfn');
$this->sw = $this->get_sys_cgi_var('sw');
$this->rec = $this->get_sys_cgi_var('rec', '');
$this->navop = $this->get_sys_cgi_var('navop');
$navfmup = $this->get_sys_cgi_var('navfmup');
$navfmdown = $this->get_sys_cgi_var('navfmdown');
$navpnup = $this->get_sys_cgi_var('navpnup');
$navpndown = $this->get_sys_cgi_var('navpndown');
if($navfmdown!=NULL && $navfmdown != $this->fm) $this->navfm = $navfmdown;
elseif($navfmup!=NULL && $navfmup != $this->fm) $this->navfm = $navfmup;
elseif($navpndown!=NULL && ($navpndown-1)*$this->inc != $this->fm) $this->navfm = ($navpndown-1)*$this->inc;
elseif($navpnup!=NULL && ($navpnup-1)*$this->inc != $this->fm) $this->navfm = ($navpnup-1)*$this->inc;
else $this->navfm = $this->fm;
$this->operation = $this->get_sys_cgi_var('operation');
$oper_prefix_len = strlen($this->cgi['prefix']['operation']);
if (! strncmp($this->cgi['prefix']['operation'], $this->operation, $oper_prefix_len)) {
$this->operation = $this->labels[substr($this->operation, $oper_prefix_len)];
}
$this->saveadd = $this->get_sys_cgi_var('saveadd');
$this->moreadd = $this->get_sys_cgi_var('moreadd');
$this->canceladd = $this->get_sys_cgi_var('canceladd');
$this->savechange = $this->get_sys_cgi_var('savechange');
$this->morechange = $this->get_sys_cgi_var('morechange');
$this->cancelchange = $this->get_sys_cgi_var('cancelchange');
$this->savecopy = $this->get_sys_cgi_var('savecopy');
$this->cancelcopy = $this->get_sys_cgi_var('cancelcopy');
$this->savedelete = $this->get_sys_cgi_var('savedelete');
$this->canceldelete = $this->get_sys_cgi_var('canceldelete');
$this->cancelview = $this->get_sys_cgi_var('cancelview');
// Filter setting
if (isset($this->sw)) {
$this->sw == $this->labels['Search'] && $this->fl = 1;
$this->sw == $this->labels['Hide'] && $this->fl = 0;
//$this->sw == $this->labels['Clear'] && $this->fl = 0;
}
// TAB names
$this->tabs = array();
// Setting key_delim according to key_type
if ($this->key_type == 'real') {
/* If 'real' key_type does not work,
try change MySQL datatype from float to double */
$this->rec = doubleval($this->rec);
$this->key_delim = '';
} elseif ($this->key_type == 'int') {
$this->rec = intval($this->rec);
$this->key_delim = '';
} else {
$this->key_delim = '"';
// $this->rec remains unmodified
}
// Specific $fdd modifications depending on performed action
$this->recreate_fdd();
// Extract SQL Field Names and number of fields
$this->recreate_displayed();
// Issue backward compatibility
$this->backward_compatibility();
// Gathering query options
$this->gather_query_opts();
// Call to action
!isset($opts['execute']) && $opts['execute'] = 1;
$opts['execute'] && $this->execute();
// Restore original error reporting level
error_reporting($error_reporting);
} /* }}} */
 
}
 
/* Modeline for ViM {{{
* vim:set ts=4:
* vim600:fdm=marker fdl=0 fdc=0:
* }}} */
 
?>
/tags/v3.1-blanche-neige/jrest/util/extensions/phpMyEdit-calpopup.class.php
New file
0,0 → 1,357
<?php
 
/*
* phpMyEdit - instant MySQL table editor and code generator
*
* extensions/phpMyEdit-calpopup.class.php - phpMyEdit calendar popup extension
* ____________________________________________________________
*
* Contribution of Adam Hammond <php@pixolet.co.uk>, London, UK
* Copyright (c) 2003-2006 Platon Group, http://platon.sk/
* All rights reserved.
*
* See README file for more information about this software.
* See COPYING file for license information.
*
* Download the latest version from
* http://platon.sk/projects/phpMyEdit/
*/
/* $Platon: phpMyEdit/extensions/phpMyEdit-calpopup.class.php,v 1.9 2006-01-22 21:44:17 nepto Exp $ */
 
/*
OVERVIEW
--------
 
NOTE...This extension will not work with the CVS version of PME
 
calPopup extends the standard phpMyEdit class to allow
a calendar popup helper to be put on any text field.
This extension uses the free jsCalendar code from
http://dynarch.com/mishoo/calendar.epl website.
REQUIREMENTS
------------
 
The requirement is a properly installed jsCalendar script.
All browsers supported by jsCalendar are supported by this
extension.
 
USAGE
-----
 
This extension enables the display of a popup calendar selection
against selected fields.
In order to use it, you should:
 
1. Load the jsCalendar scripts in the <head>...</head> section of
your phpMyEdit calling program, substituting the correct paths:
 
<script type="text/javascript" src="js/calendar.js"></script>
<script type="text/javascript" src="js/lang/calendar-en.js"></script>
<script type="text/javascript" src="js/calendar-setup.js"></script>
 
2. Choose your preferred jsCalendar CSS file (see jsCalendar
documentation) and add the following in the <head>...</head>
section of your phpMyEdit calling program, substituting the
correct path:
<link rel="stylesheet" type="text/css" media="screen"
href="css/calendar-system.css">
 
NOTE: To avoid an unwanted side effect in the CSS style
produced by phpMyEditSetup.php, add a 'width:auto' property
into the '.calendar table' entry in your selected jsCalendar
style sheet.
 
3. Call to phpMyEdit-calPopup.class.php instead
of phpMyEdit.class.php.
 
Example:
 
require_once 'extensions/phpMyEdit-calpopup.class.php';
new phpMyEdit_calpopup($opts);
 
4. Add 'calendar' parameter to the field definitions where you
want a calendar popup in your phpMyEdit calling program.
 
Example:
 
$opts['fdd']['col_name'] = array(
'name' => 'Column',
'select' => 'T',
'options' => 'ACPVD',
'required' => true,
'calendar' => true
);
 
This is will display a button next to the field which pops up
a calendar when clicked. If that field has a 'strftimemask'
parameter set, it will use this for the date format.
For more advanced usage, you can set the 'calendar' parameter
to an array of valid jsCalendar Calendar.setup options
(see jSCalendar document for details). Note that not all
of these options make sense to use in phpMyEdit, and some
of them will actively break the function.
Example:
$opts['fdd']['col_name'] = array(
'name' => 'Column',
'select' => 'T',
'options' => 'ACPVD',
'required' => true,
'calendar' => array(
'ifFormat' => '%Y/%m/%d', // defaults to the ['strftimemask']
'firstDay' => 1, // 0 = Sunday, 1 = Monday
'singleClick' => true, // single or double click to close
'weekNumbers' => true, // Show week numbers
'showsTime' => false, // Show time as well as date
'timeFormat' => '24', // 12 or 24 hour clock
'label' => '...', // button label (used by phpMyEdit)
'date' => '2003-12-19 10:00' // Initial date/time for popup
// (see notes below)
)
);
 
NOTES
-----
 
1. The popup will normally set the initial value to the current
field value or to current date/time. 'date' option will always
override this, even if there is a current date/time value
in the field. If you want a default value only if the field
is currently empty, use the phpMyEdit 'default' option.
 
2. Only the options listed above may be set by the user, any other
options will be ignored.
 
SEARCH KEYWORD
--------------
 
Search for "CalPopup" string in this source code,
to find all extension related modifications.
*/
 
require_once dirname(__FILE__).'/../phpMyEdit.class.php';
 
class phpMyEdit_calpopup extends phpMyEdit
{
/* CalPopup mod start */
 
/* Array for collecting list of fields with calendar popups */
var $calendars;
 
/* Array of valid options for passing to Calendar.setup */
var $valid_opts = array(
'button','ifFormat','singleClick','firstDay',
'weekNumbers','showsTime','timeFormat','date'
);
 
/**
* Checks to see if the calendar parameter is set on the field
*
* @param k current field name
* @param curval current value of field (set to null for default)
*
* If the calendar parameter is set on the field, this function displays
* the button. It then pushes the Calendar.setup parameters into an array,
* including the user specified ones in the calling program is they exist.
* This array is then added to the $calendars array indexed by the field
* name. This allows for multiple fields with calendar popups.
*/
function CalPopup_helper($k, $curval) /* {{{ */
{
if (@$this->fdd[$k]['calendar']) {
$cal_ar['ifFormat'] = '%Y-%m-%d %H:%M';
$cal_ar['showsTime'] = true;
$cal_ar['singleClick'] = false;
if (isset($curval)) {
if (substr($curval, 0, 4) != '0000')
$cal_ar['date'] = $curval;
}
if (isset($this->fdd[$k]['strftimemask'])) {
$cal_ar['ifFormat'] = $this->fdd[$k]['strftimemask'];
}
if (is_array($this->fdd[$k]['calendar'])) {
foreach($this->fdd[$k]['calendar'] as $ck => $cv) {
$cal_ar[$ck] = $cv;
}
}
$cal_ar['button'] = 'pme_calpopup_button_'.$this->fds[$k];
$this->calendars[$this->fds[$k]] = $cal_ar;
$label = @$this->fdd[$k]['calendar']['label'];
strlen($label) || $label = '...';
echo '<button id="',$cal_ar['button'],'">',$label,'</button>';
}
} /* }}} */
 
/* CalPopup mod end */
 
function display_add_record() /* {{{ */
{
for ($tab = 0, $k = 0; $k < $this->num_fds; $k++) {
if (isset($this->fdd[$k]['tab']) && $this->tabs_enabled() && $k > 0) {
$tab++;
echo '</table>',"\n";
echo '</div>',"\n";
echo '<div id="phpMyEdit_tab',$tab,'">',"\n";
echo '<table class="',$this->getCSSclass('main'),'" summary="',$this->tb,'">',"\n";
}
if (! $this->displayed[$k]) {
continue;
}
if ($this->hidden($k)) {
echo $this->htmlHidden($this->fds[$k], $row["qf$k"]);
continue;
}
$css_postfix = @$this->fdd[$k]['css']['postfix'];
$css_class_name = $this->getCSSclass('input', null, 'next', $css_postfix);
echo '<tr class="',$this->getCSSclass('row', null, true, $css_postfix),'">',"\n";
echo '<td class="',$this->getCSSclass('key', null, true, $css_postfix),'">',$this->fdd[$k]['name'],'</td>',"\n";
echo '<td class="',$this->getCSSclass('value', null, true, $css_postfix),'"';
echo $this->getColAttributes($k),">\n";
if ($this->col_has_values($k)) {
$vals = $this->set_values($k);
$selected = @$this->fdd[$k]['default'];
$multiple = $this->col_has_multiple_select($k);
$readonly = $this->readonly($k);
$strip_tags = true;
$escape = true;
echo $this->htmlSelect($this->fds[$k], $css_class_name, $vals, $selected,
$multiple, $readonly, $strip_tags, $escape);
} elseif (isset ($this->fdd[$k]['textarea'])) {
echo '<textarea class="',$css_class_name,'" name="',$this->fds[$k],'"';
echo ($this->readonly($k) ? ' disabled' : '');
if (intval($this->fdd[$k]['textarea']['rows']) > 0) {
echo ' rows="',$this->fdd[$k]['textarea']['rows'],'"';
}
if (intval($this->fdd[$k]['textarea']['cols']) > 0) {
echo ' cols="',$this->fdd[$k]['textarea']['cols'],'"';
}
if (isset($this->fdd[$k]['textarea']['wrap'])) {
echo ' wrap="',$this->fdd[$k]['textarea']['wrap'],'"';
} else {
echo ' wrap="virtual"';
}
echo '>',htmlspecialchars($this->fdd[$k]['default']),'</textarea>',"\n";
} else {
// Simple edit box required
$size_ml_props = '';
$maxlen = intval($this->fdd[$k]['maxlen']);
$size = isset($this->fdd[$k]['size']) ? $this->fdd[$k]['size'] : min($maxlen, 60);
$size && $size_ml_props .= ' size="'.$size.'"';
$maxlen && $size_ml_props .= ' maxlength="'.$maxlen.'"';
 
/* CalPopup mod start */
if (@$this->fdd[$k]['calendar']) {
$size_ml_props .= ' id="pme_calpopup_input_'.$this->fds[$k].'"';
}
/* CalPopup mod end */
 
echo '<input class="',$css_class_name,'" type="text" ';
echo ($this->readonly($k) ? 'disabled ' : ''),' name="',$this->fds[$k],'"';
echo $size_ml_props,' value="';
echo htmlspecialchars($this->fdd[$k]['default']),'">';
 
/* CalPopup mod start */
/* Call CalPopup helper function */
$this->CalPopup_helper($k, null);
/* CalPopup mod end */
}
echo '</td>',"\n";
if ($this->guidance) {
$css_class_name = $this->getCSSclass('help', null, true, $css_postfix);
$cell_value = $this->fdd[$k]['help'] ? $this->fdd[$k]['help'] : '&nbsp;';
echo '<td class="',$css_class_name,'">',$cell_value,'</td>',"\n";
}
echo '</tr>',"\n";
}
} /* }}} */
 
function display_change_field($row, $k) /* {{{ */
{
$css_postfix = @$this->fdd[$k]['css']['postfix'];
$css_class_name = $this->getCSSclass('input', null, true, $css_postfix);
echo '<td class="',$this->getCSSclass('value', null, true, $css_postfix),'"';
echo $this->getColAttributes($k),">\n";
if ($this->col_has_values($k)) {
$vals = $this->set_values($k);
$multiple = $this->col_has_multiple_select($k);
$readonly = $this->readonly($k);
$strip_tags = true;
$escape = true;
echo $this->htmlSelect($this->fds[$k], $css_class_name, $vals, $row["qf$k"],
$multiple, $readonly, $strip_tags, $escape);
} elseif (isset($this->fdd[$k]['textarea'])) {
echo '<textarea class="',$css_class_name,'" name="',$this->fds[$k],'"';
echo ($this->readonly($k) ? ' disabled' : '');
if (intval($this->fdd[$k]['textarea']['rows']) > 0) {
echo ' rows="',$this->fdd[$k]['textarea']['rows'],'"';
}
if (intval($this->fdd[$k]['textarea']['cols']) > 0) {
echo ' cols="',$this->fdd[$k]['textarea']['cols'],'"';
}
if (isset($this->fdd[$k]['textarea']['wrap'])) {
echo ' wrap="',$this->fdd[$k]['textarea']['wrap'],'"';
} else {
echo ' wrap="virtual"';
}
echo '>',htmlspecialchars($row["qf$k"]),'</textarea>',"\n";
} else {
$size_ml_props = '';
$maxlen = intval($this->fdd[$k]['maxlen']);
$size = isset($this->fdd[$k]['size']) ? $this->fdd[$k]['size'] : min($maxlen, 60);
$size && $size_ml_props .= ' size="'.$size.'"';
$maxlen && $size_ml_props .= ' maxlength="'.$maxlen.'"';
 
/* CalPopup mod start */
if (@$this->fdd[$k]['calendar']) {
$size_ml_props .= ' id="pme_calpopup_input_'.$this->fds[$k].'"';
}
/* CalPopup mod end */
 
echo '<input class="',$css_class_name,'" type="text" ';
echo ($this->readonly($k) ? 'disabled ' : ''),'name="',$this->fds[$k],'" value="';
echo htmlspecialchars($row["qf$k"]),'" ',$size_ml_props,'>',"\n";
 
/* CalPopup mod start */
/* Call CalPopup helper function */
$this->CalPopup_helper($k, htmlspecialchars($row["qf$k"]));
/* CalPopup mod end */
}
echo '</td>',"\n";
} /* }}} */
 
function form_end() /* {{{ */
{
if ($this->display['form']) {
echo '</form>',"\n";
/* CalPopup mod start */
/* Add script calls to the end of the form for all fields
with calendar popups. */
if (isset($this->calendars)) {
echo '<script type="text/javascript"><!--',"\n";
foreach($this->calendars as $ck => $cv) {
echo 'Calendar.setup({',"\n";
foreach ($cv as $ck1 => $cv1) {
if (in_array($ck1, $this->valid_opts)) {
echo "\t",str_pad($ck1, 15),' : "',$cv1,'",',"\n";
}
}
echo "\t",str_pad('inputField', 15),' : "pme_calpopup_input_',$ck,'"',"\n";
echo '});',"\n";
};
echo '// --></script>',"\n";
};
 
/* CalPopup mod end */
};
} /* }}} */
}
 
?>
/tags/v3.1-blanche-neige/jrest/util/extensions/phpMyEdit-messages.class.php
New file
0,0 → 1,329
<?php
 
/*
* phpMyEdit - instant MySQL table editor and code generator
*
* extensions/phpMyEdit-messages.class.php - phpMyEdit messages extension
* ____________________________________________________________
*
* Developed by Ondrej Jombik <nepto@platon.sk>
* Copyright (c) 2002-2006 Platon Group, http://platon.sk/
* All rights reserved.
*
* See README file for more information about this software.
* See COPYING file for license information.
*
* Download the latest version from
* http://platon.sk/projects/phpMyEdit/
*/
 
/* $Platon: phpMyEdit/extensions/phpMyEdit-messages.class.php,v 1.15 2006-06-17 11:14:54 nepto Exp $ */
 
/* This extension is part of phpMyEzin: Content Management System project,
where it handles discussion messages for particular articles. It depends on
some phpMyEzin characteristics, thus extension should not and cannot be used
outside this project. However there are planned some improvements for future
to make this extension handle any kind of tree-structured data. */
 
require_once dirname(__FILE__).'/../phpMyEdit.class.php';
 
class phpMyEdit_messages extends phpMyEdit
{
function phpMyEdit_messages($opts) /* {{{ */
{
$execute = 1;
isset($opts['execute']) && $execute = $opts['execute'];
$opts['execute'] = 0;
parent::phpMyEdit($opts);
$this->tb2 = $opts['tb2'];
$this->format_date = $opts['format_date'];
/* Preserved article ID in CGI environment. */
/* TODO: change to $this->article_id or something like this */
global $ezin_admin_article;
$ezin_admin_article = $this->get_data_cgi_var('article_id');
 
$execute && $this->execute();
} /* }}} */
 
function list_table() /* {{{ */
{
$ezin_admin_article_change_up = $this->get_sys_cgi_var('ezin_admin_article_change_up');
$ezin_admin_article_change_down = $this->get_sys_cgi_var('ezin_admin_article_change_down');
if (isset($ezin_admin_article_change_up)) {
$ezin_admin_article = $this->get_sys_cgi_var('ezin_admin_article_up');
} elseif (isset($ezin_admin_article_change_down)) {
$ezin_admin_article = $this->get_sys_cgi_var('ezin_admin_article_down');
}
!isset($ezin_admin_article) && $ezin_admin_article = $this->get_data_cgi_var('article_id');
$ezin_admin_article = intval($ezin_admin_article);
$query = sprintf('SELECT article_id, count(id) AS messages FROM %s'
.' GROUP BY article_id HAVING article_id = %d',
$this->tb, intval($ezin_admin_article));
if (($result = $this->myquery($query)) == false) {
return false;
}
$row = @mysql_fetch_array($result, MYSQL_ASSOC);
//$ezin_admin_article = intval($row['article_id']);
$ezin_admin_msgcount = intval($row['messages']);
@mysql_free_result($result);
 
echo '<form class="',$this->getCSSclass('form');
echo '" action="',$page_name,'" method="POST">',"\n";
 
if ($this->nav_up() || $ezin_admin_article <= 0) {
$this->message_nav_buttons($ezin_admin_article, $ezin_admin_msgcount, 'up');
echo '<hr class="',$this->getCSSclass('hr', 'up'),'">',"\n";
}
 
if ($ezin_admin_article > 0) {
echo '<table class="',$this->getCSSclass('main'),'" summary="',$this->tb,'">',"\n";
echo '<tr class="',$this->getCSSclass('header'),'">',"\n";
foreach (array('ID', 'Subject', ' ', 'Author', 'Date & Time', 'IP addresses') as $str) {
echo '<th class="',$this->getCSSclass('header'),'">';
echo Platon::htmlspecialchars2($str),'</th>',"\n";
}
echo '</tr>',"\n";
echo '<tr class="',$this->getCSSclass('header'),'">',"\n";
echo '<th class="',$this->getCSSclass('header'),'" colspan="6">';
echo 'Valid messages</td></tr>',"\n";
$message_ids = $this->message_process($ezin_admin_article, 0, 0);
$count_message_ids = count($message_ids);
if ($count_message_ids == 0) {
echo '<tr class="',$this->getCSSclass('row', null, 'next'),'">',"\n";
echo '<td class="',$this->getCSSclass('cell', null, true),'" colspan="6">',"\n";
echo '<i>There are no valid messages for this article.</i>';
echo '</td></tr>',"\n";
}
$query = sprintf('SELECT id, parent, article_id, author,'
.' email, homepage, subject, datetime, ip'
.' FROM %s WHERE article_id = %d ORDER BY datetime ASC',
$this->tb, intval($ezin_admin_article));
if (($result = $this->myquery($query)) == false) {
return false;
}
$all_ids = array();
$parents = array();
for ($i = 0; ($row = @mysql_fetch_array($result, MYSQL_ASSOC)); $i++) {
$all_ids[] = $row['id'];
$parents[$row['id']] = $row['parent'];
}
@mysql_free_result($result);
$all_ids = array_diff($all_ids, $message_ids);
echo '<tr class="',$this->getCSSclass('header'),'">',"\n";
echo '<th class="',$this->getCSSclass('header'),'" colspan="6">';
echo 'Invalid messages</td></tr>',"\n";
if (count($all_ids) > 0) {
/* To force buttons */
$count_message_ids = -1;
while (count($all_ids) > 0) {
//echo "<p>all_ids: "; var_dump($all_ids);echo '<br>';
$sub_ids = $this->message_process($ezin_admin_article,
$parents[array_shift($all_ids)], 0, true);
$all_ids = array_diff($all_ids, $sub_ids);
}
} else {
echo '<tr class="',$this->getCSSclass('row', null, 'next'),'">',"\n";
echo '<td class="',$this->getCSSclass('cell', null, true),'" colspan="6">',"\n";
echo '<i>There are no invalid messages for this article.</i>';
echo '</td></tr>',"\n";
}
echo '</table>';
}
if ($this->nav_down() && $ezin_admin_article > 0) {
echo '<hr class="',$this->getCSSclass('hr', 'down'),'">',"\n";
$this->message_nav_buttons($ezin_admin_article, $ezin_admin_msgcount, 'down');
}
echo $this->htmlHiddenData('article_id', $ezin_admin_article);
echo '</form>',"\n";
} /* }}} */
 
function message_process($article_id, $id, $level = 0, $parent = true) /* {{{ */
{
$id = intval($id);
$level = intval($level);
$query = sprintf('SELECT id, parent, article_id, author,'
.' email, homepage, subject, datetime, ip'
.' FROM %s WHERE %s = %d AND article_id = %d'
.' ORDER BY datetime ASC', $this->tb,
$parent == true ? 'parent' : 'id', intval($id), intval($article_id));
if (($result = $this->myquery($query)) == false) {
return false;
}
 
$ar = array();
$ar_out = array();
for ($i = 0; ($row = @mysql_fetch_array($result, MYSQL_ASSOC)); $i++) {
$ar[$i] = $row;
$ar_out[] = $row['id'];
}
$checked = ! $level && $parent ? ' checked' : '';
for ($i = 0; $i < count($ar); $i++) {
echo '<tr class="',$this->getCSSclass('row', null, 'next'),'">',"\n";
$css_class_name = $this->getCSSclass('cell', null, true);
$css_class_name2 = $this->getCSSclass('navigation', null, true);
echo '<td class="',$css_class_name,'">',$ar[$i]['id'],'</td>',"\n";
echo '<td class="',$css_class_name,'">';
for ($j = 0; $j < $level; $j++) {
echo '&nbsp;&nbsp;&nbsp;';
}
echo htmlspecialchars($ar[$i]['subject']);
echo '</td>',"\n";
echo '<td class="',$css_class_name2,'">';
echo '<input',$checked,' class="',$css_class_name2,'"';
echo ' type="radio" ','name="',$this->cgi['prefix']['sys'],'rec"';
echo ' value="',$ar[$i]['id'],'" class="link"></td>',"\n";
echo '<td class="',$css_class_name,'">',htmlspecialchars($ar[$i]['author']), '</td>';
echo '<td class="',$css_class_name,'">',htmlspecialchars($ar[$i]['datetime']),'</td>';
// TODO: do resolving
echo '<td class="',$css_class_name,'"><small>';
// this shoud be global IP-adress-deliminator
$output = false;
$ar_ip = preg_split('|([ ]*[ \\/,;]+[ ]*)|', $ar[$i]['ip'], -1, PREG_SPLIT_DELIM_CAPTURE);
foreach ($ar_ip as $ip) {
if (strlen($output) > 0) {
$output = true;
}
$ip = htmlspecialchars($ip);
if (preg_match('/^(\d{1,3}\.){3}\d{1,3}$/', $ip)) {
echo '<a class="',$css_class_name,'" target="_blank" href="http://',$ip,'">';
echo '<small>',$ip,'</small></a>';
} else {
echo $ip;
}
}
if (! $output) {
echo '&nbsp;';
}
echo '</small></td>',"\n";
echo '</tr>',"\n";
if ($parent) {
$ar_out = array_merge($ar_out, $this->message_process(
$article_id, $ar[$i]['id'], $level + 1));
}
strlen($checked) && $checked = '';
}
return $ar_out;
} /* }}} */
 
function message_nav_buttons($article_id, $messages_count, $position) /* {{{ */
{
echo '<table class="',$this->getCSSclass('navigation', $position),'">',"\n";
echo '<tr class="',$this->getCSSclass('navigation', $position),'">',"\n";
echo '<td class="',$this->getCSSclass('buttons', $position),'">',"\n";
$this->print_article_select($article_id, 0, $position);
echo '</td>',"\n";
echo '<td class="',$this->getCSSclass('buttons2', $position),'">',"\n";
if ($article_id > 0) {
if ($this->add_enabled()) {
echo $this->htmlSubmit('operation', 'Add', $this->getCSSclass('add', $position), false, false);
}
if ($this->view_enabled()) {
echo '&nbsp;';
echo $this->htmlSubmit('operation', 'View', $this->getCSSclass('view', $position),
false, $messages_count <= 0);
}
if ($this->change_enabled()) {
echo '&nbsp;';
echo $this->htmlSubmit('operation', 'Change', $this->getCSSclass('change', $position),
false, $messages_count <= 0);
}
if ($this->delete_enabled()) {
echo '&nbsp;';
echo $this->htmlSubmit('operation', 'Delete', $this->getCSSclass('delete', $position),
false, $messages_count <= 0);
}
}
echo '</td></tr></table>',"\n";
} /* }}} */
 
function display_record_buttons() /* {{{ */
{
echo '<table class="',$this->getCSSclass('navigation', $position),'">',"\n";
echo '<tr class="',$this->getCSSclass('navigation', $position),'">',"\n";
echo '<td class="',$this->getCSSclass('buttons', $position),'">',"\n";
$this->print_article_select($article_id, 1, $position);
echo '</td>',"\n";
if (strlen(@$this->message) > 0) {
echo '<td class="',$this->getCSSclass('message', $position),'">',$this->message,'</td>',"\n";
}
echo '<td class="',$this->getCSSclass('buttons2', $position),'">',"\n";
if ($this->change_operation()) {
echo $this->htmlSubmit('savechange', 'Save', $this->getCSSclass('save', $position), true), '&nbsp;';
echo $this->htmlSubmit('morechange', 'Apply', $this->getCSSclass('more', $position), true), '&nbsp;';
echo $this->htmlSubmit('cancelchange', 'Cancel', $this->getCSSclass('cancel', $position), false);
} elseif ($this->add_operation()) {
echo $this->htmlSubmit('saveadd', 'Save', $this->getCSSclass('save', $position), true), '&nbsp;';
echo $this->htmlSubmit('moreadd', 'More', $this->getCSSclass('more', $position), true), '&nbsp;';
echo $this->htmlSubmit('canceladd', 'Cancel', $this->getCSSclass('cancel', $position), false);
} elseif ($this->delete_operation()) {
echo $this->htmlSubmit('savedelete', 'Delete', $this->getCSSclass('save', $position), false), '&nbsp;';
echo $this->htmlSubmit('canceldelete', 'Cancel', $this->getCSSclass('cancel', $position), false);
} elseif ($this->view_operation()) {
if ($this->change_enabled()) {
echo $this->htmlSubmit('operation', 'Change', $this->getCSSclass('save', $position), false), '&nbsp;';
}
echo $this->htmlSubmit('cancelview', 'Cancel', $this->getCSSclass('cancel', $position), false);
}
// Message is now written here
echo '</td>',"\n";
echo '</tr></table>',"\n";
} /* }}} */
 
function print_article_select($selected_id, $disabled, $position) /* {{{ */
{
if ($selected_id <= 0) {
$rec = intval($this->get_sys_cgi_var('rec'));
if ($rec > 0) {
$query = sprintf('SELECT article_id FROM %s WHERE id = %d',
$this->tb, $rec);
$result = $this->myquery($query);
if ($result != false) {
$row = @mysql_fetch_array($result, MYSQL_NUM);
$selected_id = $row[0];
}
@mysql_free_result($result);
}
}
static $articles = null;
if ($articles == null) {
$articles = array();
$query = 'SELECT id, title, atitle, UNIX_TIMESTAMP(datetime) AS date'
.' FROM '.$this->tb2
.' ORDER BY date DESC';
if (($result = $this->myquery($query)) == false) {
return false;
}
for ($k = 0; ($row = @mysql_fetch_array($result, MYSQL_ASSOC)); $k++) {
$articles[] = $row;
}
@mysql_free_result($result);
}
echo '<select',($disabled ? ' disabled' : ''),' name="';
echo $this->cgi['prefix']['sys'].'ezin_admin_article_',$position,'" size="1">',"\n";
echo '<option value="0">-- Choose article --</option>',"\n";
foreach ($articles as $row) {
$row['title'] = empty($row['title']) ? $row['atitle'] : $row['title'];
$row['title'] = Platon::pretty_substr(strip_tags($row['title']), 40);
echo '<option'.($selected_id == $row['id'] ? ' selected' : '');
echo ' value="',$row['id'],'">',$row['title'];
if ($row['date'] > 0) {
printf(' [%d] (%s)', $row['id'], date($this->format_date, $row['date']));
}
echo '</option>',"\n";
}
echo '</select>',"\n";
if (! $disabled) {
echo $this->htmlSubmit('ezin_admin_article_change_'.$position, ' &gt; ', $this->get_sys_cgi_var('change', $position)), '&nbsp;', "\n";
}
return true;
} /* }}} */
 
}
 
/* Modeline for ViM {{{
* vim:set ts=4:
* vim600:fdm=marker fdl=0 fdc=0:
* }}} */
 
?>
/tags/v3.1-blanche-neige/jrest/util/extensions/phpMyEdit-report.class.php
New file
0,0 → 1,319
<?php
 
/*
* phpMyEdit - instant MySQL table editor and code generator
*
* extensions/phpMyEdit-report.class.php - phpMyEdit report extension
* ____________________________________________________________
*
* Developed by Ondrej Jombik <nepto@platon.sk>
* Copyright (c) 2002-2006 Platon Group, http://platon.sk/
* All rights reserved.
*
* See README file for more information about this software.
* See COPYING file for license information.
*
* Download the latest version from
* http://platon.sk/projects/phpMyEdit/
*/
 
/* $Platon: phpMyEdit/extensions/phpMyEdit-report.class.php,v 1.12 2006-01-22 21:44:23 nepto Exp $ */
 
/* Extension TODO:
 
- allow user to enable/disable particular field in reporting (maybe 'X' flag
for indicating that field is forbidden is good idea)
- support for ['help'] in select fields screen
- make extension's option for selecting "Select fields" link or button
*/
 
require_once dirname(__FILE__).'/../phpMyEdit.class.php';
 
class phpMyEdit_report extends phpMyEdit
{
 
function phpMyEdit_report($opts) /* {{{ */
{
$opts['options'] = 'L';
$execute = 1;
isset($opts['execute']) && $execute = $opts['execute'];
$opts['execute'] = 0;
parent::phpMyEdit($opts);
$execute && $this->execute();
} /* }}} */
 
function make_language_labels($language) /* {{{ */
{
$ret = parent::make_language_labels($language);
strlen($ret['Make report']) <= 0 && $ret['Make report'] = 'Make report';
strlen($ret['Select fields']) <= 0 && $ret['Select fields'] = 'Select fields';
strlen($ret['Records per screen']) <= 0 && $ret['Records per screen'] = 'Records per screen';
return $ret;
} /* }}} */
 
function get_cgi_cookie_var($name, $default_value = null) /* {{{ */
{
$ret = $this->get_cgi_var($name, null);
if ($ret === null) {
global $HTTP_COOKIE_VARS;
$ret = @$HTTP_COOKIE_VARS[$name.'_'.$this->tb.'_cookie'];
if (! isset($ret)) {
$ret = $default_value;
}
}
return $ret;
} /* }}} */
 
function display_list_table_buttons($total_recs, $position) /* {{{ */
{ /* This is mostly copy/paste from core class. */
$listall = $this->inc <= 0; // Are we doing a listall?
echo '<table class="',$this->getCSSclass('navigation', $position),'">',"\n";
echo '<tr class="',$this->getCSSclass('navigation', $position),'">',"\n";
echo '<td class="',$this->getCSSclass('buttons', $position),'">',"\n";
echo '<input class="',$this->getCSSclass('fields-select', $position);
echo '" type="submit" name="fields_select" value="',$this->labels['Select fields'],'">&nbsp;';
// Note that <input disabled isn't valid HTML, but most browsers support it
$disabled = ($this->fm > 0 && ! $listall) ? '' : ' disabled';
echo '<input',$disabled,' class="',$this->getCSSclass('prev', $position);
echo '" type="submit" name="',ltrim($disabled),'prev" value="',$this->labels['Prev'],'">&nbsp;';
$disabled = ($this->fm + $this->inc < $total_recs && ! $listall) ? '' : ' disabled';
echo '<input',$disabled,' class="',$this->getCSSclass('next', $position);
echo '" type="submit" name="',ltrim($disabled),'next" value="',$this->labels['Next'],'">';
// Message is now written here
echo '</td>',"\n";
if (strlen(@$this->message) > 0) {
echo '<td class="',$this->getCSSclass('message', $position),'">',$this->message,'</td>',"\n";
}
// Display page and records statistics
echo '<td class="',$this->getCSSclass('stats', $position),'">',"\n";
if ($listall) {
echo $this->labels['Page'],':&nbsp;1&nbsp;',$this->labels['of'],'&nbsp;1';
} else {
echo $this->labels['Page'],':&nbsp;',($this->fm / $this->inc) + 1;
echo '&nbsp;',$this->labels['of'],'&nbsp;',max(1, ceil($total_recs / abs($this->inc)));
}
echo '&nbsp; ',$this->labels['Records'],':&nbsp;',$total_recs;
echo '</td></tr></table>',"\n";
} /* }}} */
 
function display_report_selection_buttons($position) /* {{{ */
{
echo '<table class="',$this->getCSSclass('navigation', $position),'">',"\n";
echo '<tr class="',$this->getCSSclass('navigation', $position),'">',"\n";
echo '<td class="',$this->getCSSclass('buttons', $position),'">',"\n";
echo '<input class="',$this->getCSSclass('make-report', $position);
echo '" type="submit" name="prepare_filter" value="',$this->labels['Make report'],'">',"\n";
echo '</td></tr></table>',"\n";
} /* }}} */
 
function get_select_fields_link() /* {{{ */
{
$link = '<a href="'.htmlspecialchars($this->page_name).'?fields_select=1';
for ($i = 0; $i < count($table_cols); $i++) {
$varname = 'qf'.$i;
$value = $this->get_cgi_cookie_var($varname);
if (! empty($value)) {
$link .= htmlspecialchars(
'&'.rawurlencode($varname).
'='.rawurlencode($value));
}
}
$link .= htmlspecialchars($this->cgi['persist']);
$link .= '">'.$this->labels['Select fields'].'</a>';
return $link;
} /* }}} */
 
function execute() /* {{{ */
{
global $HTTP_GET_VARS;
global $HTTP_POST_VARS;
 
/*
* Extracting field names
*/
 
$table_cols = array();
$all_table_cols = array();
 
if ($this->connect() == false) {
return false;
}
$query_parts = array(
'type' => 'select',
'select' => '*',
'from' => $this->tb,
'limit' => '1');
$result = $this->myquery($this->get_SQL_query($query_parts), __LINE__);
$all_table_cols = array_keys(@mysql_fetch_array($result, MYSQL_ASSOC));
if (count($all_table_cols) <= 0) {
$this->error('database fetch error');
return false;
}
foreach (array_keys($this->fdd) as $field_name) {
if (preg_match('/^\d*$/', $field_name))
continue;
if (($idx = array_search($field_name, $all_table_cols)) !== false)
$table_cols[$field_name] = mysql_field_len($result, $idx);
}
@mysql_free_result($result);
unset($all_table_cols);
 
/*
* Preparing variables
*/
 
$fields_select = $this->get_cgi_var('fields_select');
$filter = $this->get_cgi_var('filter');
$prepare_filter = $this->get_cgi_var('prepare_filter');
$this->inc = intval($this->get_cgi_cookie_var('inc'));
$force_select = true;
$none_displayed = true;
$expire_time = time() + (3600 * 24 * 30 * 12 * 5); // five years
$headers_sent = @headers_sent();
 
foreach (array_merge(array('@inc'), array_keys($table_cols)) as $col) {
$varname = ($col[0] == '@' ? substr($col, 1) : 'have_'.$col);
if (isset($HTTP_POST_VARS[$varname]) || isset($HTTP_GET_VARS[$varname])) {
$value = $HTTP_POST_VARS[$varname];
if (isset($HTTP_GET_VARS[$varname])) {
$value = $HTTP_GET_VARS[$varname];
}
if ($varname != 'inc' && ! empty($value)) {
$force_select = false;
}
$headers_sent || setcookie($varname.'_'.$this->tb.'_cookie', $value, $expire_time);
$this->cgi['persist'] .= '&'.urlencode($varname);
$this->cgi['persist'] .= '='.urlencode($value);
} else {
$headers_sent || setcookie($varname.'_'.$this->tb.'_cookie', '', time() - 10000);
}
}
 
$i = -1;
foreach (array_keys($this->fdd) as $key) {
$i++;
if (preg_match('/^\d*$/', $key))
continue;
$varname = 'have_'.$key;
$value = @$this->get_cgi_cookie_var($varname, '');
$options = @$value ? 'LV' : '';
$this->fdd[$i]['options'] = $options;
$this->fdd[$key]['options'] = $options;
$this->displayed[$i] = @$value ? true : false;
$value && $none_displayed = false;
}
 
/*
* Redirecting when neccessary
* (hackity hack with unregistering/unchecking fields)
*/
 
if ($prepare_filter && ! $headers_sent) {
$this->execute_redirect();
exit;
}
 
/*
* Check if field selection report screen has to be displayed
*/
 
if (isset($fields_select) || $force_select || $none_displayed) {
$this->execute_report_screen($table_cols);
return true;
}
 
if (0) {
$this->message .= $this->get_select_fields_link();
}
 
// parent class call
return parent::execute();
} /* }}} */
 
function execute_redirect() /* {{{ */
{
global $HTTP_SERVER_VARS;
global $HTTP_GET_VARS;
global $HTTP_POST_VARS;
$redirect_url = 'http://'.$HTTP_SERVER_VARS['HTTP_HOST'].$HTTP_SERVER_VARS['SCRIPT_NAME'];
$delim = '?';
foreach ($HTTP_POST_VARS + $HTTP_GET_VARS as $cgi_var_name => $cgi_var_value) {
$cgi_var_name == 'prepare_filter' && $cgi_var_name = 'filter';
$redirect_url .= $delim;
$redirect_url .= rawurlencode($cgi_var_name).'='.rawurlencode($cgi_var_value);
$delim == '?' && $delim = '&';
}
$redirect_url .= $this->cgi['persist'];
header('Location: '.$redirect_url);
exit;
} /* }}} */
 
function execute_report_screen($table_cols) /* {{{ */
{
echo '<form class="',$this->getCSSclass('form'),'" action="';
echo htmlspecialchars($this->page_name),'" method="POST">',"\n";
if ($this->nav_up()) {
$this->display_report_selection_buttons('up');
echo '<hr class="',$this->getCSSclass('hr', 'up'),'">',"\n";
}
echo '<table class="',$this->getCSSclass('main'),'" summary="',$this->tb,'">',"\n";
 
$i = 0;
foreach ($table_cols as $key => $val) {
$css_postfix = @$this->fdd[$key]['css']['postfix'];
$css_class_name = $this->getCSSclass('input', null, true, $css_postfix);
$varname = 'have_'.$key;
$value = $this->get_cgi_cookie_var($varname);
$checked = @$value ? ' checked' : '';
echo '<tr class="',$this->getCSSclass('row', null, 'next', $css_postfix),'">',"\n";
echo '<td class="',$this->getCSSclass('key', null, true, $css_postfix),'">';
echo $this->fdd[$i]['name'],'</td>',"\n";
echo '<td class="',$this->getCSSclass('check', null, true, $css_postfix),'">';
echo '<input class="',$css_class_name,'" type="checkbox" name="';
echo htmlspecialchars($varname),'"',$checked,'>';
echo '</td>',"\n";
echo '<td class="',$this->getCSSclass('value', null, true, $css_postfix),'"';
echo $this->getColAttributes($key),">\n";
$varname = 'qf'.$i;
$value = $this->get_cgi_cookie_var($varname);
if ($this->fdd[$key]['select'] == 'D' || $this->fdd[$key]['select'] == 'M') {
$from_table = ! $this->col_has_values($key) || isset($this->fdd[$key]['values']['table']);
$selected = $value;
$value = $this->set_values($key, array('*' => '*'), null, $from_table);
$multiple = $this->col_has_multiple_select($key);
$multiple |= $this->fdd[$key]['select'] == 'M';
$readonly = false;
$strip_tags = true;
$escape = true;
echo $this->htmlSelect($varname.'_id', $css_class_name, $value, $selected,
$multiple, $readonly, $strip_tags, $escape);
} else {
echo '<input class="',$css_class_name,'" type=text name="';
echo htmlspecialchars($varname),'" value="',htmlspecialchars($value),'" size="';
echo min(40, $val),'" maxlength="',min(40, max(10, $val)),'">';
}
echo '</td>',"\n",'</tr>',"\n";
$i++;
}
echo '<tr class="',$this->getCSSclass('row', null, 'next', $css_postfix),'">',"\n";
echo '<td class="',$this->getCSSclass('key', null, true, $css_postfix),'" colspan="2">';
echo $this->labels['Records per screen'],'</td>';
echo '<td class="',$this->getCSSclass('value', null, true, $css_postfix),'">';
echo '<input class="',$css_class_name,'" type="text" name="inc" value="',$this->inc.'">';
echo '</td></tr>',"\n";
echo '</table>',"\n";
if ($this->nav_down()) {
echo '<hr class="',$this->getCSSclass('hr', 'down'),'">',"\n";
$this->display_report_selection_buttons('down');
}
echo '</form>';
} /* }}} */
 
}
 
/* Modeline for ViM {{{
* vim:set ts=4:
* vim600:fdm=marker fdl=0 fdc=0:
* }}} */
 
?>
/tags/v3.1-blanche-neige/jrest/util/extensions/phpMyEdit-htmlarea.class.php
New file
0,0 → 1,209
<?php
 
/*
* phpMyEdit - instant MySQL table editor and code generator
*
* extensions/phpMyEdit-htmlarea.class.php - phpMyEdit htmlArea extension
* ____________________________________________________________
*
* Contribution of Ezudin Kurtowich <ekurtovic@ieee.org>, Sarajevo
* Copyright (c) 2003-2006 Platon Group, http://platon.sk/
* All rights reserved.
*
* See README file for more information about this software.
* See COPYING file for license information.
*
* Download the latest version from
* http://platon.sk/projects/phpMyEdit/
*/
 
/* $Platon: phpMyEdit/extensions/phpMyEdit-htmlarea.class.php,v 1.10 2006-01-22 21:44:18 nepto Exp $ */
 
/*
OVERVIEW
--------
 
NOTE...This extension will not work with the CVS version of PME. It has
been replaced by the mce_cal extension.
htmlArea is a free WYSIWYG textarea replacement from
http://www.interactivetools.com/ website.
 
REQUIREMENTS
------------
The extension requires a properly installed htmlArea script
as described on the http://www.interactivetools.com/ site.
 
USAGE
-----
 
This extension enables WYSIWYG editing of a textarea field.
In order to use it, you should:
1. Load htmlArea script in the <head>...</head> section of your
phpMyEdit calling program as described in the htmlarea manual.
NOTE: To avoid an unwanted side effect in css style produced
by phpMyEditSetup.php, delete 'table-width:100%' property.
 
2. Call to phpMyEdit-htmlarea.class.php instead
of phpMyEdit.class.php.
 
Example:
 
require_once 'extensions/phpMyEdit-htmlarea.class.php';
new phpMyEdit_htmlarea($opts);
 
3. Add 'html'=>true parameter to the textarea field definition
in your phpMyEdit calling program.
 
Example:
$opts['fdd']['col_name'] = array(
'name' => 'Column',
'select' => 'T',
'options' => 'ACPVD',
'required' => true,
'textarea' => array(
'html' => true,
'rows' => 11,
'cols' => 81)
);
 
SEARCH KEYWORD
--------------
 
Search for "htmlArea" string in this source code,
to find all extension related modifications.
*/
 
require_once dirname(__FILE__).'/../phpMyEdit.class.php';
 
class phpMyEdit_htmlarea extends phpMyEdit
{
 
/*
* Display functions overriding
*/
 
function display_add_record() /* {{{ */
{
for ($k = 0; $k < $this->num_fds; $k++) {
if ($this->hidden($k)) {
echo $this->htmlHidden($this->fds[$k], $row["qf$k"]);
continue;
}
if (! $this->displayed[$k]) {
continue;
}
$css_postfix = @$this->fdd[$k]['css']['postfix'];
$css_class_name = $this->getCSSclass('input', null, 'next', $css_postfix);
echo '<tr class="',$this->getCSSclass('row', null, true, $css_postfix),'">',"\n";
echo '<td class="',$this->getCSSclass('key', null, true, $css_postfix),'">',$this->fdd[$k]['name'],'</td>',"\n";
echo '<td class="',$this->getCSSclass('value', null, true, $css_postfix),'">'."\n";
if ($this->col_has_values($k)) {
$vals = $this->set_values($k);
$selected = @$this->fdd[$k]['default'];
$multiple = $this->fdd[$k]['select'] == 'M' && ! $this->fdd[$k]['values']['table'];
$readonly = $this->readonly($k);
echo $this->htmlSelect($this->fds[$k], $css_class_name, $vals, $selected, $multiple,$readonly);
} elseif (isset ($this->fdd[$k]['textarea'])) {
echo '<textarea class="',$css_class_name,'" name="'.$this->fds[$k].'"';
echo ($this->readonly($k) ? ' disabled' : '');
if (intval($this->fdd[$k]['textarea']['rows']) > 0) {
echo ' rows="',$this->fdd[$k]['textarea']['rows'],'"';
}
if (intval($this->fdd[$k]['textarea']['cols']) > 0) {
echo ' cols="',$this->fdd[$k]['textarea']['cols'],'"';
}
if (isset($this->fdd[$k]['textarea']['wrap'])) {
echo ' wrap="',$this->fdd[$k]['textarea']['wrap'],'"';
} else {
echo ' wrap="virtual"';
}
echo '>',htmlspecialchars($this->fdd[$k]['default']),'</textarea>',"\n";
 
// EK htmlArea code modification is here
if (isset($this->fdd[$k]['textarea']['html'])) {
echo '<script type="text/javascript" language="javascript1.2"><!--',"\n";
echo 'editor_generate("',$this->fds[$k],'");',"\n";
echo '// --></script>';
}
} else {
// Simple edit box required
$size_ml_props = '';
$maxlen = intval($this->fdd[$k]['maxlen']);
//$maxlen > 0 || $maxlen = 300;
$size = min($maxlen, 60);
$size && $size_ml_props .= ' size="'.$size.'"';
$maxlen && $size_ml_props .= ' maxlength="'.$maxlen.'"';
echo '<input class="',$css_class_name,'" type="text" ';
echo ($this->readonly($k) ? 'disabled ' : ''),' name="',$this->fds[$k],'"';
echo $size_ml_props,' value="';
echo htmlspecialchars($this->fdd[$k]['default']),'">';
}
echo '</td>',"\n";
if ($this->guidance) {
$css_class_name = $this->getCSSclass('help', null, true, $css_postfix);
$cell_value = $this->fdd[$k]['help'] ? $this->fdd[$k]['help'] : '&nbsp;';
echo '<td class="',$css_class_name,'">',$cell_value,'</td>',"\n";
}
echo '</tr>',"\n";
}
} /* }}} */
 
function display_change_field($row, $k) /* {{{ */
{
$css_postfix = @$this->fdd[$k]['css']['postfix'];
$css_class_name = $this->getCSSclass('input', null, true, $css_postfix);
echo '<td class="',$this->getCSSclass('value', null, true, $css_postfix),'">',"\n";
if ($this->col_has_values($k)) {
$vals = $this->set_values($k);
$multiple = $this->fdd[$k]['select'] == 'M' && ! $this->fdd[$k]['values']['table'];
$readonly = $this->readonly($k);
echo $this->htmlSelect($this->fds[$k], $css_class_name, $vals, $row["qf$k"], $multiple, $readonly);
} elseif (isset($this->fdd[$k]['textarea'])) {
echo '<textarea class="',$css_class_name,'" name="'.$this->fds[$k].'"';
echo ($this->readonly($k) ? ' disabled' : '');
if (intval($this->fdd[$k]['textarea']['rows']) > 0) {
echo ' rows="',$this->fdd[$k]['textarea']['rows'],'"';
}
if (intval($this->fdd[$k]['textarea']['cols']) > 0) {
echo ' cols="',$this->fdd[$k]['textarea']['cols'],'"';
}
if (isset($this->fdd[$k]['textarea']['wrap'])) {
echo ' wrap="',$this->fdd[$k]['textarea']['wrap'],'"';
} else {
echo ' wrap="virtual"';
}
echo '>',htmlspecialchars($row["qf$k"]),'</textarea>',"\n";
 
// EK htmlArea code modification is here
if (isset($this->fdd[$k]['textarea']['html'])) {
echo '<script type="text/javascript" language="javascript1.2"><!--',"\n";
echo 'editor_generate("',$this->fds[$k],'");',"\n";
echo '// --></script>';
}
} else {
$size_ml_props = '';
$maxlen = intval($this->fdd[$k]['maxlen']);
//$maxlen > 0 || $maxlen = 300;
$size = min($maxlen, 60);
$size && $size_ml_props .= ' size="'.$size.'"';
$maxlen && $size_ml_props .= ' maxlength="'.$maxlen.'"';
echo '<input class="',$css_class_name,'" type="text" ';
echo ($this->readonly($k) ? 'disabled ' : ''),'name="',$this->fds[$k],'" value="';
echo htmlspecialchars($row["qf$k"]),'" ',$size_ml_props,'>',"\n";
}
echo '</td>',"\n";
} /* }}} */
 
}
 
/* Modeline for ViM {{{
* vim:set ts=4:
* vim600:fdm=marker fdl=0 fdc=0:
* }}} */
 
?>
/tags/v3.1-blanche-neige/jrest/util/extensions/phpMyEdit-slide.class.php
New file
0,0 → 1,144
<?php
 
/*
* phpMyEdit - instant MySQL table editor and code generator
*
* extensions/phpMyEdit-slide.class.php - slide show extension for phpMyEdit
* ____________________________________________________________
*
* Developed by Ondrej Jombik <nepto@platon.sk>
* Copyright (c) 2002-2006 Platon Group, http://platon.sk/
* All rights reserved.
*
* See README file for more information about this software.
* See COPYING file for license information.
*
* Download the latest version from
* http://platon.sk/projects/phpMyEdit/
*/
 
/* $Platon: phpMyEdit/extensions/phpMyEdit-slide.class.php,v 1.10 2006-01-22 21:44:24 nepto Exp $ */
 
/*
* Coding elapsed time: from 8:30 to 10:30 at 30th October 2002
* with heavy patching phpMyEdit core class.
*
* Music used: E-Type (Campione, This is the Way and others)
*/
 
require_once dirname(__FILE__).'/../phpMyEdit.class.php';
 
class phpMyEdit_slide extends phpMyEdit
{
// Extension options array
var $ext;
 
function phpMyEdit_slide($opts) /* {{{ */
{
$execute = 1;
isset($opts['execute']) && $execute = $opts['execute'];
$opts['execute'] = 0;
parent::phpMyEdit($opts);
 
$this->ext = $opts['ext'];
 
$execute && $this->execute($opts);
} /* }}} */
 
function display_record_buttons() /* {{{ */
{
// TODO: classify this table and cells
echo '<table border=0 cellpadding=0 cellspacing=0 width="100%" style="border:0;padding:0;">';
echo '<tr><td align=left style="text-align:left;border:0;padding:0;" nowrap>' . "\n";
if ($this->change_operation()) {
echo '<input type="submit" name="savechange" value="'.$this->labels['Save'].'" />'."\n";
echo '<input type="submit" name="morechange" value="'.$this->labels['Apply'].'" />'."\n";
echo '<input type="button" name="cancel" value="'.$this->labels['Cancel'].'" onClick="form.submit();" />'."\n";
echo '<input type="hidden" name="rec_change" value="1">';
} elseif ($this->view_operation()) {
if ($this->change_enabled()) {
echo '<input type="submit" name="operation" value="'.$this->labels['Change'].'" />'."\n";
}
echo '<input type="submit" name="cancel" value="'.$this->labels['Cancel'].'" />'."\n";
}
 
if (! $this->ext['prev_disable']) {
$disabled = $this->ext['prev'] ? '' : ' disabled';
echo '<input'.$disabled.' type="submit" name="'.ltrim($disabled).'prev" value="'
.$this->labels['Prev'].'">&nbsp;';
echo '<input type="hidden" name="rec_prev" value="'.$this->ext['prev'].'">';
}
if (! $this->ext['next_disable']) {
$disabled = $this->ext['next'] ? '' : ' disabled';
echo '<input'.$disabled.' type="submit" name="'.ltrim($disabled).'next" value="'
.$this->labels['Next'].'">';
echo '<input type="hidden" name="rec_next" value="'.$this->ext['next'].'">';
}
echo '</td></tr></table>'."\n";
} /* }}} */
 
function execute($opts) /* {{{ */
{
if ($this->get_cgi_var('rec_change')
&& ($this->next_operation() || $this->prev_operation())) {
$this->operation = $this->labels['Change'];
}
if (! $this->change_operation()) {
$this->operation = $this->labels['View'];
}
if ($this->prev_operation()) {
! $this->ext['prev_disabled'] && $this->rec = $this->get_cgi_var('rec_prev');
$this->prev = '';
}
if ($this->next_operation()) {
! $this->ext['next_disabled'] && $this->rec = $this->get_cgi_var('rec_next');
$this->next = '';
}
if (! $this->rec) {
$this->rec = $this->ext['rec'];
}
 
if (! $this->rec
|| (! $this->ext['prev_disable'] && ! $this->ext['prev'])
|| (! $this->ext['next_disable'] && ! $this->ext['next'])) {
if ($this->connect() == false) {
return false;
}
$query_parts = array(
'type' => 'select',
// XXX FIXME - simplify query
'select' => 'PMEtable0.'.$this->key,
'from' => $this->get_SQL_join_clause(),
'where' => $this->get_SQL_where_from_query_opts());
// TODO: order by clausule according to default sort order options
$res = $this->myquery($this->get_SQL_query($query_parts), __LINE__);
$ids = array();
while (($row = @mysql_fetch_array($res, MYSQL_NUM)) !== false) {
$ids[] = $row[0];
}
@mysql_free_result($res);
if ($this->rec) {
$idx = array_search($this->rec, $ids);
$idx === false && $idx = 0;
} else {
$idx = 0;
}
 
$this->rec = $ids[$idx];
! $this->ext['prev'] && $this->ext['prev'] = $ids[$idx - 1];
! $this->ext['next'] && $this->ext['next'] = $ids[$idx + 1];
}
$this->recreate_fdd();
$this->recreate_displayed();
parent::execute();
} /* }}} */
 
}
 
/* Modeline for ViM {{{
* vim:set ts=4:
* vim600:fdm=marker fdl=0 fdc=0:
* }}} */
 
?>
/tags/v3.1-blanche-neige/jrest/util/extensions/phpMyEdit-mce-cal.class.php
New file
0,0 → 1,509
<?php
 
/*
* phpMyEdit - instant MySQL table editor and code generator
*
* extensions/phpMyEdit-mce-cal.class.php - phpMyEdit html area & calendar popup extension
* ____________________________________________________________
*
* Contribution of Adam Hammond <php@pixolet.co.uk>, London, UK
* Contribution of Ezudin Kurtowich <ekurtovic@ieee.org>, Sarajevo
* Copyright (c) 2003-2006 Platon Group, http://platon.sk/
* All rights reserved.
*
* Updated 28th Jul 2005
*
* Updated to use TinyMCE instead of HTMLArea
* Updated to handle multiple tabs and to use PME prefixes.
* Updated to include sub-form patch
*
*
*
* See README file for more information about this software.
* See COPYING file for license information.
*
* Download the latest version from
* http://platon.sk/projects/phpMyEdit/
*/
 
/* $Platon: phpMyEdit/extensions/phpMyEdit-mce-cal.class.php,v 1.6 2006-09-16 18:43:47 nepto Exp $ */
/*
OVERVIEW
--------
 
mce_cal extends the standard phpMyEdit class to allow
a calendar popup helper to be put on any text field and for any textarea
field to turned into an HTML editor.
This extension uses the free jsCalendar from http://dynarch.com/mishoo
and the TinyMCE code from http://tinymce.moxiecode.com/
REQUIREMENTS
------------
 
The requirement is a properly installed jsCalendar and TinyMCE script.
All browsers supported by these scripts are supported by this
extension. Note that version 1.44 or later for TinyMCE is required.
USAGE
-----
 
For both features:
1. Call to phpMyEdit-mce-cal.class.php instead
of phpMyEdit.class.php.
 
Example:
 
require_once 'extensions/phpMyEdit-mce-cal.class.php';
new phpMyEdit_mce_cal($opts);
 
 
 
HTML TextArea
 
This enables WYSIWYG editing of a textarea field.
In order to use it, you should:
 
1. Load TinyMCE script in the <head>...</head> section of your
phpMyEdit calling program as described in the htmlarea manual.
 
<!-- tinyMCE -->
<script language="javascript" type="text/javascript" src="js/<path to TinyMCE>"></script>
<script language="javascript" type="text/javascript">
tinyMCE.init({
mode : "specific_textareas",
auto_reset_designmode : true
});
</script>
<!-- /tinyMCE -->
 
where 'js/<path to TinyMCE>' is the path to the javascript code
 
NOTES:
A. The PME implementation uses the "specific_textareas" mode - this
must always be set
 
B. Due to a bug in Mozilla, if any of the textareas being used as HTML
editors are in tabs and are initially hidden, the width and height
need to be specified in the tinyMCE initialization and
'auto_reset_designmode' must be set to 'true':
tinyMCE.init({
mode : "specific_textareas",
auto_reset_designmode : true,
width: "800",
height: "200"
});
 
2. Add 'html'=>true parameter to the textarea field definition
in your phpMyEdit calling program.
 
Example:
 
$opts['fdd']['col_name'] = array(
'name' => 'Column',
'select' => 'T',
'options' => 'ACPVD',
'required' => true,
'textarea' => array(
'html' => true,
'rows' => 11,
'cols' => 81)
);
 
3. It is also possible to have multiple text area formats on the same
form. This is done by specifying a text tag for the textarea:
 
$opts['fdd']['col_name'] = array(
'name' => 'Column',
'select' => 'T',
'options' => 'ACPVD',
'required' => true,
'textarea' => array(
'html' => 'format1',
'rows' => 11,
'cols' => 81)
);
 
You then need to initialize TinyMCE in the header to recognize all of
the tags used in the textareas.
EXAMPLE
In the following, two formats of tinyMCE editor are defined.
 
This example is the default, and will be used for any fields where
'html' is set to true.
 
tinyMCE.init({
mode : "specific_textareas",
auto_reset_designmode : true
});
 
This second example has an extra parameter, 'textarea_trigger', which is
set to the text tag given to the textarea in PME with 'mce_' prepended
to it.
 
tinyMCE.init({
mode : "specific_textareas",
auto_reset_designmode : true,
textarea_trigger : "mce_format1",
theme : "advanced",
width: "800",
height: "200",
plugins : "table,save,advhr,advimage,advlink,emotions,iespell,insertdatetime,preview,zoom,flash,searchreplace,print",
theme_advanced_buttons1_add_before : "save,separator",
theme_advanced_buttons1_add : "fontselect,fontsizeselect",
theme_advanced_buttons2_add : "separator,insertdate,inserttime,preview,zoom,separator,forecolor,backcolor",
theme_advanced_buttons2_add_before: "cut,copy,paste,separator,search,replace,separator",
theme_advanced_buttons3_add_before : "tablecontrols,separator",
theme_advanced_buttons3_add : "emotions,iespell,flash,advhr,separator,print",
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "left",
theme_advanced_path_location : "bottom",
content_css : "example_full.css",
plugin_insertdate_dateFormat : "%Y-%m-%d",
plugin_insertdate_timeFormat : "%H:%M:%S",
extended_valid_elements : "a[name|href|target|title|onclick],img[class|src|border=0|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name],hr[class|width|size|noshade],font[face|size|color|style],span[class|align|style]"
});
So:
'html' => 'format1' maps to textarea_trigger : "mce_format1"
'html' => 'foo' maps to textarea_trigger : "mce_foo"
'html' => 'bar' maps to textarea_trigger : "mce_bar"
 
You can initialize TinyMCE as many times as you need to give you as many
editor formats as you need.
 
CALENDAR
 
This extension enables the display of a popup calendar selection
against selected fields.
In order to use it, you should:
 
1. Load the jsCalendar scripts in the <head>...</head> section of
your phpMyEdit calling program, substituting the correct paths:
 
<script type="text/javascript" src="js/jscalendar/calendar.js"></script>
<script type="text/javascript" src="js/jscalendar/lang/calendar-en.js"></script>
<script type="text/javascript" src="js/jscalendar/calendar-setup.js"></script>
 
2. Choose your preferred jsCalendar CSS file (see jsCalendar
documentation) and add the following in the <head>...</head>
section of your phpMyEdit calling program, substituting the
correct path:
<link rel="stylesheet" type="text/css" media="screen"
href="js/jscalendar/calendar-system.css">
 
3. Add 'calendar' parameter to the field definitions where you
want a calendar popup in your phpMyEdit calling program.
 
Example:
 
$opts['fdd']['col_name'] = array(
'name' => 'Column',
'select' => 'T',
'options' => 'ACPVD',
'required' => true,
'calendar' => true
);
 
This is will display a button next to the field which pops up
a calendar when clicked. If that field has a 'strftimemask'
parameter set, it will use this for the date format.
For more advanced usage, you can set the 'calendar' parameter
to an array of valid jsCalendar Calendar.setup options
(see jSCalendar document for details). Note that not all
of these options make sense to use in phpMyEdit, and some
of them will actively break the function.
Example:
$opts['fdd']['col_name'] = array(
'name' => 'Column',
'select' => 'T',
'options' => 'ACPVD',
'required' => true,
'calendar' => array(
'ifFormat' => '%Y/%m/%d', // defaults to the ['strftimemask']
'firstDay' => 1, // 0 = Sunday, 1 = Monday
'singleClick' => true, // single or double click to close
'weekNumbers' => true, // Show week numbers
'showsTime' => false, // Show time as well as date
'timeFormat' => '24', // 12 or 24 hour clock
'button' => true, // Display button (rather then clickable area)
'label' => '...', // button label (used by phpMyEdit)
'date' => '2003-12-19 10:00' // Initial date/time for popup
// (see notes below)
)
);
 
NOTES
-----
 
1. The popup will normally set the initial value to the current
field value or to current date/time. 'date' option will always
override this, even if there is a current date/time value
in the field. If you want a default value only if the field
is currently empty, use the phpMyEdit 'default' option.
 
2. Only the options listed above may be set by the user, any other
options will be ignored.
3. The 'label' option can contain HTML markup which will be displayed as
the button/clickable area to pull up the calendar
 
SEARCH KEYWORD
--------------
 
Search for "htmlcal" string in this source code,
to find all extension related modifications.
*/
 
require_once dirname(__FILE__).'/../phpMyEdit.class.php';
 
class phpMyEdit_mce_cal extends phpMyEdit
{
/* calendar mod start */
 
var $calendars; // Array for collecting list of fields with calendar popups
/* Array of valid options for passing to Calendar.setup */
var $valid_opts = array(
'button','ifFormat','singleClick','firstDay',
'weekNumbers','showsTime','timeFormat','date'
);
 
/**
* Checks to see if the calendar parameter is set on the field
*
* @param k current field name
* @param curval current value of field (set to null for default)
*
* If the calendar parameter is set on the field, this function displays
* the button. It then pushes the Calendar.setup parameters into an array,
* including the user specified ones in the calling program is they exist.
* This array is then added to the $calendars array indexed by the field
* name. This allows for multiple fields with calendar popups.
*/
function calPopup_helper($k, $curval) /* {{{ */
{
if (@$this->fdd[$k]['calendar']) {
$cal_ar['ifFormat'] = '%Y-%m-%d %H:%M';
$cal_ar['showsTime'] = true;
$cal_ar['singleClick'] = false;
if (isset($curval)) {
if (substr($curval, 0, 4) != '0000')
$cal_ar['date'] = $curval;
}
if (isset($this->fdd[$k]['strftimemask'])) {
$cal_ar['ifFormat'] = $this->fdd[$k]['strftimemask'];
}
if (is_array($this->fdd[$k]['calendar'])) {
foreach($this->fdd[$k]['calendar'] as $ck => $cv) {
$cal_ar[$ck] = $cv;
}
}
$cal_ar['button'] = $this->dhtml['prefix'].'calbutton_'.$this->fds[$k];
$this->calendars[$this->fds[$k]] = $cal_ar;
 
$label = @$this->fdd[$k]['calendar']['label'];
strlen($label) || $label = '...';
 
$do_button = true;
if (isset($this->fdd[$k]['calendar']['button'])) {
$do_button = $this->fdd[$k]['calendar']['button'];
};
 
if ($do_button) {
echo '<button id="',$cal_ar['button'],'">',$label,'</button>';
} else {
echo '<span style="cursor: pointer" id="',$cal_ar['button'],'">',$label,'</span>';
}
}
} /* }}} */
 
/* calendar mod end */
 
function display_add_record() /* {{{ */
{
for ($tab = 0, $k = 0; $k < $this->num_fds; $k++) {
if (isset($this->fdd[$k]['tab']) && $this->tabs_enabled() && $k > 0) {
$tab++;
echo '</table>',"\n";
echo '</div>',"\n";
echo '<div id="'.$this->dhtml['prefix'].'tab',$tab,'">',"\n";
echo '<table class="',$this->getCSSclass('main'),'" summary="',$this->tb,'">',"\n";
}
if (! $this->displayed[$k]) {
continue;
}
if ($this->hidden($k)) {
echo $this->htmlHiddenData($this->fds[$k], $this->fdd[$k]['default']);
continue;
}
$css_postfix = @$this->fdd[$k]['css']['postfix'];
$css_class_name = $this->getCSSclass('input', null, 'next', $css_postfix);
echo '<tr class="',$this->getCSSclass('row', null, true, $css_postfix),'">',"\n";
echo '<td class="',$this->getCSSclass('key', null, true, $css_postfix),'">';
echo $this->fdd[$k]['name'],'</td>',"\n";
echo '<td class="',$this->getCSSclass('value', null, true, $css_postfix),'"';
echo $this->getColAttributes($k),">\n";
if ($this->col_has_values($k)) {
$vals = $this->set_values($k);
$selected = @$this->fdd[$k]['default'];
$multiple = $this->col_has_multiple_select($k);
$readonly = $this->readonly($k);
$strip_tags = true;
$escape = true;
echo $this->htmlSelect($this->cgi['prefix']['data'].$this->fds[$k], $css_class_name,
$vals, $selected, $multiple, $readonly, $strip_tags, $escape);
} elseif (isset ($this->fdd[$k]['textarea'])) {
echo '<textarea class="',$css_class_name,'" name="',$this->cgi['prefix']['data'].$this->fds[$k],'"';
echo ($this->readonly($k) ? ' disabled' : '');
if (intval($this->fdd[$k]['textarea']['rows']) > 0) {
echo ' rows="',$this->fdd[$k]['textarea']['rows'],'"';
}
if (intval($this->fdd[$k]['textarea']['cols']) > 0) {
echo ' cols="',$this->fdd[$k]['textarea']['cols'],'"';
}
if (isset($this->fdd[$k]['textarea']['wrap'])) {
echo ' wrap="',$this->fdd[$k]['textarea']['wrap'],'"';
} else {
echo ' wrap="virtual"';
};
// mce mod start
if (isset($this->fdd[$k]['textarea']['html'])) {
$mce_tag = 'editable';
if (is_string($this->fdd[$k]['textarea']['html'])) {
$mce_tag = $this->fdd[$k]['textarea']['html'];
};
echo ' mce_'.$mce_tag.'=true ';
};
// mce mod end
echo '>',htmlspecialchars($this->fdd[$k]['default']),'</textarea>',"\n";
} else {
// Simple edit box required
$size_ml_props = '';
$maxlen = intval($this->fdd[$k]['maxlen']);
$size = isset($this->fdd[$k]['size']) ? $this->fdd[$k]['size'] : min($maxlen, 60);
$size && $size_ml_props .= ' size="'.$size.'"';
$maxlen && $size_ml_props .= ' maxlength="'.$maxlen.'"';
echo '<input class="',$css_class_name,'" ';
echo ($this->password($k) ? 'type="password"' : 'type="text"');
echo ($this->readonly($k) ? ' disabled' : '');
/* calendar mod start */
echo ' id="',$this->dhtml['prefix'].'fld_'.$this->fds[$k],'"';
/* calendar mod end */
echo ' name="',$this->cgi['prefix']['data'].$this->fds[$k],'"';
echo $size_ml_props,' value="';
echo htmlspecialchars($this->fdd[$k]['default']),'">';
/* calendar mod start */
/* Call htmlcal helper function */
$this->calPopup_helper($k, null);
/* calendar mod end */
}
echo '</td>',"\n";
if ($this->guidance) {
$css_class_name = $this->getCSSclass('help', null, true, $css_postfix);
$cell_value = $this->fdd[$k]['help'] ? $this->fdd[$k]['help'] : '&nbsp;';
echo '<td class="',$css_class_name,'">',$cell_value,'</td>',"\n";
}
echo '</tr>',"\n";
}
} /* }}} */
 
function display_change_field($row, $k) /* {{{ */
{
$css_postfix = @$this->fdd[$k]['css']['postfix'];
$css_class_name = $this->getCSSclass('input', null, true, $css_postfix);
echo '<td class="',$this->getCSSclass('value', null, true, $css_postfix),'"';
echo $this->getColAttributes($k),">\n";
if ($this->col_has_values($k)) {
$vals = $this->set_values($k);
$multiple = $this->col_has_multiple_select($k);
$readonly = $this->readonly($k);
$strip_tags = true;
$escape = true;
echo $this->htmlSelect($this->cgi['prefix']['data'].$this->fds[$k], $css_class_name,
$vals, $row["qf$k"], $multiple, $readonly, $strip_tags, $escape);
} elseif (isset($this->fdd[$k]['textarea'])) {
echo '<textarea class="',$css_class_name,'" name="',$this->cgi['prefix']['data'].$this->fds[$k],'"';
echo ($this->readonly($k) ? ' disabled' : '');
if (intval($this->fdd[$k]['textarea']['rows']) > 0) {
echo ' rows="',$this->fdd[$k]['textarea']['rows'],'"';
}
if (intval($this->fdd[$k]['textarea']['cols']) > 0) {
echo ' cols="',$this->fdd[$k]['textarea']['cols'],'"';
}
if (isset($this->fdd[$k]['textarea']['wrap'])) {
echo ' wrap="',$this->fdd[$k]['textarea']['wrap'],'"';
} else {
echo ' wrap="virtual"';
};
// mce mod start
if (isset($this->fdd[$k]['textarea']['html'])) {
$mce_tag = 'editable';
if (is_string($this->fdd[$k]['textarea']['html'])) {
$mce_tag = $this->fdd[$k]['textarea']['html'];
};
echo ' mce_'.$mce_tag.'=true ';
};
// mce mod end
echo '>',htmlspecialchars($row["qf$k"]),'</textarea>',"\n";
} else {
$size_ml_props = '';
$maxlen = intval($this->fdd[$k]['maxlen']);
$size = isset($this->fdd[$k]['size']) ? $this->fdd[$k]['size'] : min($maxlen, 60);
$size && $size_ml_props .= ' size="'.$size.'"';
$maxlen && $size_ml_props .= ' maxlength="'.$maxlen.'"';
echo '<input class="',$css_class_name,'" type="text" ';
echo ($this->readonly($k) ? 'disabled ' : '');
/* calendar mod start */
echo ' id="',$this->dhtml['prefix'].'fld_'.$this->fds[$k],'"';
/* calendar mod end */
echo 'name="',$this->cgi['prefix']['data'].$this->fds[$k],'" value="';
echo htmlspecialchars($row["qf$k"]),'" ',$size_ml_props,'>',"\n";
/* calendar mod start */
/* Call calPopup helper function */
$this->calPopup_helper($k, htmlspecialchars($row["qf$k"]));
/* calendar mod end */
}
echo '</td>',"\n";
} /* }}} */
 
function form_end() /* {{{ */
{
if ($this->display['form']) {
echo '</form>',"\n";
 
/* calendar mod start */
 
/* Add script calls to the end of the form for all fields
with calendar popups. */
if (isset($this->calendars)) {
echo '<script type="text/javascript"><!--',"\n";
foreach($this->calendars as $ck => $cv) {
echo 'Calendar.setup({',"\n";
foreach ($cv as $ck1 => $cv1) {
if (in_array($ck1, $this->valid_opts)) {
echo "\t",str_pad($ck1, 15),' : "',$cv1,'",',"\n";
}
}
echo "\t",str_pad('inputField', 15),' : "',$this->dhtml['prefix'].'fld_'.$ck,'"',"\n";
echo '});',"\n";
};
echo '// -->',"\n";
echo '</script>',"\n";
};
/* calendar mod end */
};
} /* }}} */
 
}
 
?>
/tags/v3.1-blanche-neige/jrest/util/lang/PME.lang.EL.inc
New file
0,0 → 1,64
<?php
 
/*
* phpMyEdit language file
*
* language: greek
* encoding: iso-8859-7
* date: 2005-08-03
* author: Alexandros Vellis <avel@users.sourceforge.net>
*/
 
/* $Id$ */
 
return Array(
'Add' =>'Ðñüóèåóç',
'Copy' =>'ÁíôéãñáöÞ',
'Change' =>'ÁëëáãÞ',
'Delete' =>'ÄéáãñáöÞ',
'View' =>'ÅìöÜíéóç',
'Prev' =>'Ðñïçãïýìåíï',
'Next' =>'Åðüìåíï',
'First' =>'Ðñþôï',
'Last' =>'Ôåëåõôáßï',
'Go to' =>'ÐÞãáéíå óå',
'Page' =>'Óåëßäá',
'Records' =>'ÅããñáöÝò',
'Save' =>'ÁðïèÞêåõóç',
'More' =>'Ðåñéóóüôåñá',
'Apply' =>'ÕðïâïëÞ',
'Cancel' =>'Áêýñùóç',
'Search' =>'ÁíáæÞôçóç',
'Hide' =>'Êñýøå',
'Clear' =>'ÊáèÜñéóå',
'Query' =>'Åðåñþôçìá',
'Current Query' =>'ÔñÝ÷ïí Åðåñþôçìá',
'Sorted By' =>'Ôáîéíüìçóç Ìå',
'ascending' =>'áýîïõóá',
'descending' =>'öèßíïõóá',
'hidden' =>'êñõììÝíï',
'of' =>'áðü',
'record added' =>'ç åããñáöÞ ðñïóôÝèçêå',
'record changed' =>'ç åããñáöÞ Üëëáîå',
'record deleted' =>'ç åããñáöÞ äéáãñÜöçêå',
'Please enter' =>'Ðáñáêáëþ åéóÜãåôå',
'months' => Array(
'01'=>'ÉáíïõÜñéïò',
'02'=>'ÖåâñïõÜñéïò',
'03'=>'ÌÜñôéïò',
'04'=>'Áðñßëéïò',
'05'=>'ÌÜéïò',
'06'=>'Éïýíéïò',
'07'=>'Éïýëéïò',
'08'=>'Áýãïõóôïò',
'09'=>'ÓåðôÝìâñéïò',
'10'=>'Ïêôþâñéïò',
'11'=>'ÍïÝìâñéïò',
'12'=>'ÄåêÝìâñéïò'),
// phpMyEdit-report
'Make report' => 'Äçìéïõñãßá áíáöïñÜò',
'Select fields' => 'ÅðéëïãÞ ðåäßùí',
'Records per screen' => 'ÅããñáöÝò áíÜ ïèüíç',
);
 
?>
/tags/v3.1-blanche-neige/jrest/util/lang/PME.lang.EN.inc
New file
0,0 → 1,64
<?php
 
/*
* phpMyEdit language file
*
* language: english
* encoding: iso-8859-1
* date: 2000, 2001, 2003-05-01
* author: John McCreesh <jpmcc@users.sourceforge.net>
*/
 
/* $Platon: phpMyEdit/lang/PME.lang.EN.inc,v 1.11 2004-12-27 20:14:29 nepto Exp $ */
 
return Array(
'Add' =>'Add',
'Copy' =>'Copy',
'Change' =>'Change',
'Delete' =>'Delete',
'View' =>'View',
'Prev' =>'Prev',
'Next' =>'Next',
'First' =>'First',
'Last' =>'Last',
'Go to' =>'Go to',
'Page' =>'Page',
'Records' =>'Records',
'Save' =>'Save',
'More' =>'More',
'Apply' =>'Apply',
'Cancel' =>'Cancel',
'Search' =>'Search',
'Hide' =>'Hide',
'Clear' =>'Clear',
'Query' =>'Query',
'Current Query' =>'Current Query',
'Sorted By' =>'Sorted By',
'ascending' =>'ascending',
'descending' =>'descending',
'hidden' =>'hidden',
'of' =>'of',
'record added' =>'record added',
'record changed' =>'record changed',
'record deleted' =>'record deleted',
'Please enter' =>'Please enter',
'months' => Array(
'01'=>'January',
'02'=>'February',
'03'=>'March',
'04'=>'April',
'05'=>'May',
'06'=>'June',
'07'=>'July',
'08'=>'August',
'09'=>'September',
'10'=>'October',
'11'=>'November',
'12'=>'December'),
// phpMyEdit-report
'Make report' => 'Make report',
'Select fields' => 'Select fields',
'Records per screen' => 'Records per screen',
);
 
?>
/tags/v3.1-blanche-neige/jrest/util/lang/PME.lang.FR.inc
New file
0,0 → 1,67
<?php
 
/*
* phpMyEdit language file
*
* language: french (standard)
* encoding: iso-8859-1
* date: 2002-02, 2002-11-07, 2002-12-29
* authors:
* Dario <dartar@users.sourceforge.net>
* Kaid <kaid@fr.st>
* hbernard <hbernard@gynov.org>
*/
 
/* $Platon: phpMyEdit/lang/PME.lang.FR.inc,v 1.15 2004-12-27 20:14:29 nepto Exp $ */
 
return Array(
'Add' =>'Ajouter',
'Copy' =>'Copier',
'Change' =>'Modifier',
'Delete' =>'Supprimer',
'View' =>'Afficher',
'Prev' =>'Précédent',
'Next' =>'Suivant',
'First' =>'Début',
'Last' =>'Fin',
'Go to' =>'Aller à ',
'Page' =>'Page',
'Records' =>'Enregistrements',
'Save' =>'Enregistrer',
'More' =>'Enregistrer et continuer',
'Apply' =>'Appliquer',
'Cancel' =>'Annuler',
'Search' =>'Rechercher',
'Hide' =>'Cacher',
'Clear' =>'Vider',
'Query' =>'Requête',
'Current Query' =>'Requête courante',
'Sorted By' =>'Tri',
'ascending' =>'croissant',
'descending' =>'décroissant',
'hidden' =>'caché',
'of' =>'/', // untranslated
'record added' =>'Enregistrement ajouté',
'record changed'=>'Enregistrement modifié',
'record deleted'=>'Enregistrement supprimé',
'Please enter' =>'Entrez s\'il vous plaît',
'months' => Array(
'01'=>'Janvier',
'02'=>'Février',
'03'=>'Mars',
'04'=>'Avril',
'05'=>'Mai',
'06'=>'Juin',
'07'=>'Juillet',
'08'=>'Août',
'09'=>'Septembre',
'10'=>'Octobre',
'11'=>'Novembre',
'12'=>'Décembre'),
// phpMyEdit-report
'Make report' => 'Make report',
'Select fields' => 'Select fields',
'Records per screen' => 'Records per screen',
);
 
?>
/tags/v3.1-blanche-neige/jrest/util/lang/PME.lang.ES.inc
New file
0,0 → 1,66
<?php
 
/*
* phpMyEdit language file
*
* language: spanish
* encoding: iso-8859-1
* date: 2003-02, 2003-04-22, 2004-04-04
* authors:
* Jorge Nadal <jornamon@ya.com>
* Eduardo Diaz <ediaz@pk25.com>
*/
 
/* $Platon: phpMyEdit/lang/PME.lang.ES.inc,v 1.6 2004-12-27 20:14:29 nepto Exp $ */
 
return Array(
'Add' =>'Agregar',
'Copy' =>'Copiar',
'Change' =>'Cambiar',
'Delete' =>'Suprimir',
'View' =>'Visualizar',
'Prev' =>'Anterior',
'Next' =>'Siguiente',
'First' =>'Primero',
'Last' =>'Último',
'Go to' =>'Ir a',
'Page' =>'Página',
'Records' =>'Registros',
'Save' =>'Grabar',
'More' =>'Más',
'Apply' =>'Aplicar',
'Cancel' =>'Cancelar',
'Search' =>'Buscar',
'Hide' =>'Ocultar',
'Clear' =>'Limpiar',
'Query' =>'Consultar',
'Current Query' =>'Consulta actual',
'Sorted By' =>'Ordenado por',
'ascending' =>'ascendente',
'descending' =>'descendente',
'hidden' =>'oculto',
'of' =>'de',
'record added' =>'Registro añadido',
'record changed'=>'Registro cambiado',
'record deleted'=>'Registro borrado',
'Please enter' =>'Por favor introduzca ',
'months' => Array(
'01'=>'Enero',
'02'=>'Febrero',
'03'=>'Marzo',
'04'=>'Abril',
'05'=>'Mayo',
'06'=>'Junio',
'07'=>'Julio',
'08'=>'Agosto',
'09'=>'Septiembre',
'10'=>'Octubre',
'11'=>'Noviembre',
'12'=>'Diciembre'),
// phpMyEdit-report
'Make report' => 'Realizar Informe',
'Select fields' => 'Seleccionar campos',
'Records per screen' => 'Registros por pantalla',
);
 
?>
/tags/v3.1-blanche-neige/jrest/util/lang/PME.lang.ES-AR.inc
New file
0,0 → 1,59
<?php
 
/*
* phpMyEdit language file
*
* language: spanish (argentinian)
* encoding: iso-8859-1
* date: 2003-02-28, 2004-02-15
* author: Mariano Vassallo <mvassallo@ciudad.com.ar>
*/
 
/* $Platon: phpMyEdit/lang/PME.lang.ES-AR.inc,v 1.5 2004-12-27 20:14:29 nepto Exp $ */
 
return Array(
'Add' =>'Agregar',
'Copy' =>'Copiar',
'Change' =>'Cambiar',
'Delete' =>'Suprimir',
'View' =>'Visualización',
'Prev' =>'Anterior',
'Next' =>'Siguiente',
'First' =>'Primero',
'Last' =>'Ultimo',
'Go to' =>'Ir a',
'Page' =>'Paginación',
'Records' =>'Registros',
'Save' =>'Grabar',
'More' =>'Más',
'Apply' =>'Aplicar',
'Cancel' =>'Cancelar',
'Search' =>'Buscar',
'Hide' =>'Ocultar',
'Clear' =>'Limpiar',
'Query' =>'Consulta',
'of' =>'/', // intentionaly untranslated. Alternatve: "de"
'record added' =>'registro añadido',
'record changed'=>'registro cambiado',
'record deleted'=>'registro borrado',
'Please enter' =>'Por favor introduzca ',
'months' => Array(
'01'=>'Enero',
'02'=>'Febrero',
'03'=>'Marzo',
'04'=>'Abril',
'05'=>'Mayo',
'06'=>'Junio',
'07'=>'Julio',
'08'=>'Agosto',
'09'=>'Septiembre',
'10'=>'Octubre',
'11'=>'Noviembre',
'12'=>'Diciembre'),
// phpMyEdit-report
'Make report' => 'Hacer reporte',
'Select fields' => 'Seleccionar campos',
'Records per screen' => 'Registros por pantalla',
);
 
?>
/tags/v3.1-blanche-neige/jrest/util/lang/PME.lang.SE.inc
New file
0,0 → 1,73
<?php
 
/*
* phpMyEdit language file
*
* language: swedish
* encoding: iso-8859-1
* date: 2004-01-21, 2004-02-07
* authors:
* Björn Hammarbäck <bjorn@hammarback.se>
* Stefan Lindmark <stefan@lindmark.net>
*/
 
/* $Platon: phpMyEdit/lang/PME.lang.SE.inc,v 1.4 2004-12-27 20:14:29 nepto Exp $ */
 
/*
* å = &aring;
* ä = &auml;
* ö = &ouml;
* Ä = &Auml;
*/
 
return Array(
'Add' =>'Lägg till',
'Copy' =>'Kopiera',
'Change' =>'Ändra',
'Delete' =>'Ta bort',
'View' =>'Visa detaljer',
'Prev' =>'Föregående',
'Next' =>'Nästa',
'First' =>'Första',
'Last' =>'Sista',
'Go to' =>'Gå till sida',
'Page' =>'Sida',
'Records' =>'Poster',
'Save' =>'Spara',
'More' =>'Mer',
'Apply' =>'Verkställ',
'Cancel' =>'Avbryt',
'Search' =>'Sök',
'Hide' =>'Dölj',
'Clear' =>'Rensa',
'Query' =>'Sök',
'Current Query' =>'Nuvarande fråga',
'Sorted By' =>'Sorterad efter',
'ascending' =>'stigande',
'descending' =>'fallande',
'hidden' =>'gömd',
'of' =>'av',
'record added' =>'post adderad',
'record changed' =>'post ändrad',
'record deleted' =>'post borttagen',
'Please enter' =>'Fyll i fältet',
'months' => Array(
'01'=>'Januari',
'02'=>'Februari',
'03'=>'Mars',
'04'=>'April',
'05'=>'Maj',
'06'=>'Juni',
'07'=>'Juli',
'08'=>'Augusti',
'09'=>'September',
'10'=>'Oktober',
'11'=>'November',
'12'=>'December'),
// phpMyEdit-report
'Make report' => 'Skapa rapport',
'Select fields' => 'Välj fält',
'Records per screen' => 'Poster per skärm',
);
?>
/tags/v3.1-blanche-neige/jrest/util/lang/PME.lang.ET.inc
New file
0,0 → 1,64
<?php
 
/*
* phpMyEdit language file
*
* language: estonian
* encoding: any latin
* date: 2005-09-13
* author: Alexia Death <alexiadeath@hotmail.com>
*/
 
/* $Platon: phpMyEdit/lang/PME.lang.ET.inc,v 1.1 2005-09-14 13:40:19 nepto Exp $ */
 
return Array(
'Add' =>'Lisa',
'Copy' =>'Kopeeri',
'Change' =>'Muuda',
'Delete' =>'Kustuta',
'View' =>'Vaata',
'Prev' =>'Eelmine',
'Next' =>htmlentities('Järgmine'),
'First' =>'Esimene',
'Last' =>'Viimane',
'Go to' =>'Positsioon',
'Page' =>'Leht',
'Records' =>'Kirjed',
'Save' =>'Salvesta',
'More' =>htmlentities('Järgneb...'),
'Apply' =>'Rakenda muutused',
'Cancel' =>htmlentities('Tühista'),
'Search' =>'Otsi',
'Hide' =>'Peida',
'Clear' =>htmlentities('Tühjenda väljad'),
'Query' =>htmlentities('Päring'),
'Current Query' =>htmlentities('Hetke päring'),
'Sorted By' =>htmlentities('Sorteermisjärjekord'),
'ascending' =>'kahanevalt',
'descending' =>'kasvavalt',
'hidden' =>'peidetud',
'of' =>'/',
'record added' =>'kirje lisatud',
'record changed' =>'kirje muudetud',
'record deleted' =>'kirje kustutatud',
'Please enter' =>'Palun sisesta',
'months' => Array(
'01'=>'Jaanuar',
'02'=>'Veebruar',
'03'=>htmlentities('Märts'),
'04'=>'Aprill',
'05'=>'Mai',
'06'=>'Juuni',
'07'=>'Juuli',
'08'=>'August',
'09'=>'September',
'10'=>'Oktoober',
'11'=>'November',
'12'=>'Detsember'),
// phpMyEdit-report
'Make report' => 'Koosta raport',
'Select fields' => htmlentities('Vali väljad'),
'Records per screen' => 'Kirjeid lehe kohta',
);
 
?>
/tags/v3.1-blanche-neige/jrest/util/lang/PME.lang.EU.inc
New file
0,0 → 1,64
<?php
 
/*
* phpMyEdit language file
*
* language: basque
* encoding: iso-8859-1
* date: 2004-05-11
* author: Ibon Igartua <ibon@zuhar.net>
*/
 
/* $Platon: phpMyEdit/lang/PME.lang.EU.inc,v 1.1 2004-05-17 10:53:06 nepto Exp $ */
 
return Array(
'Add' =>'Gehitu',
'Copy' =>'Kopiatu',
'Change' =>'Aldatu',
'Delete' =>'Ezabatu',
'View' =>'Ikusi',
'Prev' =>'Aurrekoa',
'Next' =>'Hurrengoa',
'First' =>'Lehena',
'Last' =>'Azkena',
'Go to' =>'Joan',
'Page' =>'Orrialdea',
'Records' =>'Erregistroak',
'Save' =>'Gorde',
'More' =>'Gehiago',
'Apply' =>'Aplikatu',
'Cancel' =>'Utzi',
'Search' =>'Bilatu',
'Hide' =>'Ezkutatu',
'Clear' =>'Garbitu',
'Query' =>'Kontsulta',
'Current Query' =>'Uneko Kontsulta',
'Sorted By' =>'Orden Irizpidea',
'ascending' =>'gorantz',
'descending' =>'beherantz',
'hidden' =>'ezkutukoa',
'of' =>'-',
'record added' =>'erregistroa gehituta',
'record changed'=>'erregistroa aldatuta',
'record deleted'=>'erregistroa ezabatuta',
'Please enter' =>'Mesedez, sartu ezazu ',
'months' => Array(
'01'=>'urtarrila',
'02'=>'otsaila',
'03'=>'martxoa',
'04'=>'apirila',
'05'=>'maiatza',
'06'=>'ekaina',
'07'=>'uztaila',
'08'=>'abuztua',
'09'=>'iraila',
'10'=>'urria',
'11'=>'azaroa',
'12'=>'abendua'),
// phpMyEdit-report
'Make report' => 'Txostena sortu',
'Select fields' => 'Eremuak aukertau',
'Records per screen' => 'Erregistroak orrialdeko',
);
 
?>
/tags/v3.1-blanche-neige/jrest/util/lang/PME.lang.NL.inc
New file
0,0 → 1,68
<?php
 
/*
* phpMyEdit language file
*
* language: dutch (standard)
* encoding: iso-8859-1
* date: 2002-09-21, 2002-12-17, 2006-01-05
* authors:
* Paul Barends <pbarends@xs4all.nl>
* Erwin Janszen <Erwin.Janszen@mail.ing.nl>
* URL:
* http://platon.sk/projects/bug_view_advanced_page.php?f_bug_id=197
*/
 
/* $Platon: phpMyEdit/lang/PME.lang.NL.inc,v 1.16 2006-01-05 04:45:22 nepto Exp $ */
 
return Array(
'Add' =>'Toevoegen',
'Copy' =>'Kopiëren',
'Change' =>'Bewerken',
'Delete' =>'Wissen',
'View' =>'Details',
'Prev' =>'Vorige',
'Next' =>'Volgende',
'First' =>'Eerste',
'Last' =>'Laatste',
'Go to' =>'Ga naar',
'Page' =>'Pagina',
'Records' =>'Rijen',
'Save' =>'Bewaren',
'More' =>'Meer',
'Apply' =>'Toepassen',
'Cancel' =>'Annuleren',
'Search' =>'Zoeken',
'Hide' =>'Verbergen',
'Clear' =>'Schonen', // 'Leeg maken',
'Query' =>'Selecteer', // 'Selectie maken',
'Current Query' =>'Huidige selectie',
'Sorted By' =>'Gesorteerd op',
'ascending' =>'oplopend',
'descending' =>'aflopend',
'hidden' =>'verborgen',
'of' =>'van',
'record added' =>'rij toegevoegd',
'record changed' =>'rij aangepast',
'record deleted' =>'rij gewist',
'Please enter' =>'Voer a.u.b. in:',
'months' => Array(
'01'=>'januari',
'02'=>'februari',
'03'=>'maart',
'04'=>'april',
'05'=>'mei',
'06'=>'juni',
'07'=>'juli',
'08'=>'augustus',
'09'=>'september',
'10'=>'october',
'11'=>'november',
'12'=>'december'),
// phpMyEdit-report
'Make report' => 'Maak rapport',
'Select fields' => 'Selecteer velden',
'Records per screen' => 'Rij per scherm',
);
 
?>
/tags/v3.1-blanche-neige/jrest/util/lang/PME.lang.PL.inc
New file
0,0 → 1,60
<?php
 
/*
* phpMyEdit language file
*
* language: polish
* encoding: iso-8859-2
* date: 2002-10-01, 2003-06-30
* author: Piotr Walesiuk <p.walesiuk@bos.com.pl>
*/
 
/* $Platon: phpMyEdit/lang/PME.lang.PL.inc,v 1.9 2004-12-27 20:14:29 nepto Exp $ */
 
return Array(
'Add' =>'Dodaj',
'Copy' =>'Kopiuj',
'Change' =>'Zmieñ',
'Delete' =>'Usuñ',
'View' =>'Poka¿',
'Prev' =>'Wstecz',
'Next' =>'Dalej',
'First' =>'First', // untranslated
'Last' =>'Last', // untranslated
'Go to' =>'Go to', // untranslated
'Page' =>'Strona',
'Records' =>'Rekordy',
'Save' =>'Zapisz',
'More' =>'Wiêcej',
'Apply' =>'Zastosuj',
'Cancel' =>'Anuluj',
'Search' =>'Szukaj',
'Hide' =>'Ukryj',
'Clear' =>'Wyczy¶æ',
'Query' =>'Zapytanie',
'Current Query' =>'Aktualne zapytanie',
'Sorted By' =>'Posortowane wed³ug',
'ascending' =>'rosn±co',
'descending' =>'malej±co',
'hidden' =>'ukryte',
'of' =>'z',
'record added' =>'rekord dodany',
'record changed'=>'rekord zmieniony',
'record deleted'=>'rekord usuniêty',
'Please enter' =>'Proszê wprowadziæ',
'months' => Array(
'01'=>'Styczeñ',
'02'=>'Luty',
'03'=>'Marzec',
'04'=>'Kwiecieñ',
'05'=>'Maj',
'06'=>'Czerwiec',
'07'=>'Lipiec',
'08'=>'Sierpieñ',
'09'=>'Wrzesieñ',
'10'=>'Pa¼dziernik',
'11'=>'Listopad',
'12'=>'Grudzieñ')
);
 
?>
/tags/v3.1-blanche-neige/jrest/util/lang/PME.lang.CZ.inc
New file
0,0 → 1,64
<?php
 
/*
* phpMyEdit language file
*
* language: czech
* encoding: iso-8859-2
* date: 2005-04-26
* author: Jan Cinert <ion_lord@seznam.cz>
*/
 
/* $Platon: phpMyEdit/lang/PME.lang.CZ.inc,v 1.1 2005-04-26 13:15:38 nepto Exp $ */
 
return Array(
'Add' =>'Pøidat',
'Copy' =>'Kopírovat',
'Change' =>'Zmìnit',
'Delete' =>'Smazat',
'View' =>'Zobrazit',
'Prev' =>'Pøedcházející',
'Next' =>'Následující',
'First' =>'První',
'Last' =>'Poslední',
'Go to' =>'Otevøít',
'Page' =>'Stránka',
'Records' =>'Záznamù',
'Save' =>'Ulo¾it',
'More' =>'Více',
'Apply' =>'Pou¾ít',
'Cancel' =>'Zru¹it',
'Search' =>'Hledat',
'Hide' =>'Skrýt',
'Clear' =>'Smazat',
'Query' =>'Dotaz',
'Current Query' =>'Stávající dotaz',
'Sorted By' =>'Uspoøádané podle',
'ascending' =>'vzestupnì',
'descending' =>'sestupnì',
'hidden' =>'skrytý',
'of' =>'z',
'record added' =>'pøidaný záznam',
'record changed'=>'zmìnìný záznam',
'record deleted'=>'smazaný záznam',
'Please enter' =>'Zadejte prosím',
'months' => Array(
'01'=>'Leden',
'02'=>'Únor',
'03'=>'Bøezen',
'04'=>'Duben',
'05'=>'Kvìten',
'06'=>'Èerve',
'07'=>'Èervenec',
'08'=>'Srpen',
'09'=>'Záøí',
'10'=>'Øíjen',
'11'=>'Listopad',
'12'=>'Prosinec'),
// phpMyEdit-report
'Make report' => 'Vytvoøit zprávu',
'Select fields' => 'Vybrat pole',
'Records per screen' => 'Poèet záznamù na stránce',
);
 
?>
/tags/v3.1-blanche-neige/jrest/util/lang/PME.lang.IT.inc
New file
0,0 → 1,66
<?php
 
/*
* phpMyEdit language file
*
* language: italian (standard)
* encoding: iso-8859-1
* date: 2002-02, 2002-11-07, 2003-04-13, 2004-03-31
* authors:
* Dario <dartar@users.sourceforge.net>
* Keatch <raffaele.spangaro@eurika.net>
*/
 
/* $Platon: phpMyEdit/lang/PME.lang.IT.inc,v 1.15 2004-12-27 20:14:29 nepto Exp $ */
 
return Array(
'Add' =>'Aggiungi',
'Copy' =>'Copia',
'Change' =>'Modifica',
'Delete' =>'Cancella',
'View' =>'Visualizza',
'Prev' =>'Precedente',
'Next' =>'Seguente',
'First' =>'Prima',
'Last' =>'Ultima',
'Go to' =>'Vai a',
'Page' =>'Pagina',
'Records' =>'Voci',
'Save' =>'Salva',
'More' =>'Salva & Continua',
'Apply' =>'Applica',
'Cancel' =>'Annulla',
'Search' =>'Cerca',
'Hide' =>'Nascondi',
'Clear' =>'Svuota',
'Query' =>'Chiedi',
'Current Query' =>'Richiesta Corrente',
'Sorted By' =>'Ordinato per',
'ascending' =>'crescente',
'descending' =>'decrescente',
'hidden' =>'nascosto',
'of' =>'/',
'record added' =>'voce aggiunta',
'record changed'=>'voce modificata',
'record deleted'=>'voce eliminata',
'Please enter' =>'Si prega di riempire il campo: ',
'months' => Array(
'01'=>'Gennaio',
'02'=>'Febbraio',
'03'=>'Marzo',
'04'=>'Aprile',
'05'=>'Maggio',
'06'=>'Giugno',
'07'=>'Luglio',
'08'=>'Agosto',
'09'=>'Settembre',
'10'=>'Ottobre',
'11'=>'Novembre',
'12'=>'Dicembre'),
// phpMyEdit-report
'Make report' => 'Genera report',
'Select fields' => 'Seleziona campi',
'Records per screen' => 'Record per schermata',
);
 
?>
/tags/v3.1-blanche-neige/jrest/util/lang/PME.lang.SK.inc
New file
0,0 → 1,64
<?php
 
/*
* phpMyEdit language file
*
* language: slovak
* encoding: iso-8859-2
* date: 2002-02-02, 2003-05-01
* author: Ondrej Jombik <nepto@php.net>
*/
 
/* $Platon: phpMyEdit/lang/PME.lang.SK.inc,v 1.12 2004-12-27 20:14:29 nepto Exp $ */
 
return Array(
'Add' =>'Prida»',
'Copy' =>'Kopírova»',
'Change' =>'Zmeni»',
'Delete' =>'Zmaza»',
'View' =>'Pozrie»',
'Prev' =>'Predchádzajúci',
'Next' =>'Ïal¹í',
'First' =>'Prvý',
'Last' =>'Posledný',
'Go to' =>'Choï na',
'Page' =>'Stránka',
'Records' =>'Záznamov',
'Save' =>'Ulo¾i»',
'More' =>'Viac',
'Apply' =>'Pou¾i»',
'Cancel' =>'Storno',
'Search' =>'Hµada»',
'Hide' =>'Skry»',
'Clear' =>'Zru¹i»',
'Query' =>'Vyhµada»',
'Current Query' =>'Aktuálny dotaz',
'Sorted By' =>'Usporiadané podµa',
'ascending' =>'vzostupne',
'descending' =>'zostupne',
'hidden' =>'skryté',
'of' =>'z',
'record added' =>'záznam pridaný',
'record changed'=>'záznam zmenený',
'record deleted'=>'záznam zmazaný',
'Please enter' =>'Prosím zadajte',
'months' => Array(
'01'=>'Január',
'02'=>'Február',
'03'=>'Marec',
'04'=>'Apríl',
'05'=>'Máj',
'06'=>'Jún',
'07'=>'Júl',
'08'=>'August',
'09'=>'September',
'10'=>'Október',
'11'=>'November',
'12'=>'December'),
// phpMyEdit-report
'Make report' => 'Vytvori» report',
'Select fields' => 'Vybra» ståpce',
'Records per screen' => 'Poèet záznamov na stránke',
);
 
?>
/tags/v3.1-blanche-neige/jrest/util/lang/PME.lang.RO.inc
New file
0,0 → 1,64
<?php
 
/*
* phpMyEdit language file
*
* language: romanian
* encoding: iso-8859-1
* date: 2004-12-23
* author: Sebastian Proksch <sproksch@yahoo.com>
*/
 
/* $Platon: phpMyEdit/lang/PME.lang.RO.inc,v 1.2 2004-12-27 20:14:29 nepto Exp $ */
 
return Array(
'Add' =>'Adauga',
'Copy' =>'Copiaza',
'Change' =>'Modifica',
'Delete' =>'Sterge',
'View' =>'Vizualizeaza',
'Prev' =>'Precedentul',
'Next' =>'Urmatorul',
'First' =>'First', // untranslated
'Last' =>'Last', // untranslated
'Go to' =>'Go to', // untranslated
'Page' =>'Pagina',
'Records' =>'Inregistrari',
'Save' =>'Salveaza',
'More' =>'Mai mult',
'Apply' =>'Aplica',
'Cancel' =>'Anuleaza',
'Search' =>'Cauta',
'Hide' =>'Ascunde',
'Clear' =>'Anuleaza tot',
'Query' =>'Interogare',
'Current Query' =>'Interogarea curenta',
'Sorted By' =>'Sortat dupa',
'ascending' =>'crescator',
'descending' =>'descrescator',
'hidden' =>'ascuns',
'of' =>'din',
'record added' =>'inregistrare adaugata',
'record changed'=>'inregistrare modificata',
'record deleted'=>'inregistrare stearsa',
'Please enter' =>'Introduceti va rog',
'months' => Array(
'01'=>'Ianuarie',
'02'=>'Februarie',
'03'=>'Martie',
'04'=>'Aprilie',
'05'=>'Mai',
'06'=>'Iunie',
'07'=>'Iulie',
'08'=>'August',
'09'=>'Septembrie',
'10'=>'Octombrie',
'11'=>'Noiembrie',
'12'=>'Decembrie'),
// phpMyEdit-report // untranslated
'Make report' => 'Make report',
'Select fields' => 'Select fields',
'Records per screen' => 'Records per screen',
);
 
?>
/tags/v3.1-blanche-neige/jrest/util/lang/PME.lang.ZH.inc
New file
0,0 → 1,66
<?php
 
/*
* phpMyEdit language file
*
* language: chinese (traditional)
* encoding: big5
* date: 2003-06-26, 2004-10-17
* authors:
* Pao-Hsi Huang <doggy@miniasp.com>
* Manix Sio <manixsio@gmail.com>
*/
 
/* $Platon: phpMyEdit/lang/PME.lang.ZH.inc,v 1.5 2004-12-27 20:14:29 nepto Exp $ */
 
return Array(
'Add' =>'·s¼W',
'Copy' =>'½Æ»s',
'Change' =>'Åܧó',
'Delete' =>'§R°£',
'View' =>'À˵ø',
'Prev' =>'¤W¤@­¶',
'Next' =>'¤U¤@­¶',
'First' =>'²Ä¤@­¶',
'Last' =>'³Ì¥½¤@­¶',
'Go to' =>'«e©¹',
'Page' =>'­¶¼Æ',
'Records' =>'¸ê®Æµ§¼Æ',
'Save' =>'Àx¦s',
'More' =>'Àx¦s«áÄ~Äò·s¼W',
'Apply' =>'®M¥Î',
'Cancel' =>'¨ú®ø',
'Search' =>'·j´M',
'Hide' =>'ÁôÂÃ',
'Clear' =>'²M°£',
'Query' =>'¬d¸ß',
'Current Query' =>'¥Ø«e¬d¸ß±ø¥ó',
'Sorted By' =>'±Æ§Ç¨Ì¾Ú',
'ascending' =>'¤É¾­±Æ§Ç',
'descending' =>'­°¾­±Æ§Ç',
'hidden' =>'ÁôÂÃ',
'of' =>'Á`¦@­¶¼Æ',
'record added' =>'µ§¸ê®Æ³Q·s¼W',
'record changed' =>'µ§¸ê®Æ³Q§ó·s',
'record deleted' =>'µ§¸ê®Æ³Q§R°£',
'Please enter' =>'½Ð¿é¤J',
'months' => Array(
'01'=>'¤@¤ë',
'02'=>'¤G¤ë',
'03'=>'¤T¤ë',
'04'=>'¥|¤ë',
'05'=>'¤­¤ë',
'06'=>'¤»¤ë',
'07'=>'¤C¤ë',
'08'=>'¤K¤ë',
'09'=>'¤E¤ë',
'10'=>'¤Q¤ë',
'11'=>'¤Q¤@¤ë',
'12'=>'¤Q¤G¤ë'),
// phpMyEdit-report
'Make report' => '²£¥Í³øªí',
'Select fields' => '¿ï¨úÄæ¦ì',
'Records per screen' => '¨C­¶µ§¼Æ',
);
 
?>
/tags/v3.1-blanche-neige/jrest/util/lang/PME.lang.PT.inc
New file
0,0 → 1,67
<?php
 
/*
* phpMyEdit language file
*
* language: portuguese (standard)
* encoding: iso-8859-1
* date: 2002-02
* author: unknown
*
* last_edit: 2006-05-23 by Sérgio Sanches <ssanches@dcc.online.pt>
* last_edit_purpose: full translation and correction
*/
 
/* $Platon: phpMyEdit/lang/PME.lang.PT.inc,v 1.6 2006-05-29 08:18:04 nepto Exp $ */
 
return Array(
'Add' =>'Adicionar',
'Copy' =>'Copiar',
'Change' =>'Mudar',
'Delete' =>'Apagar',
'View' =>'Ver',
'Prev' =>'Anterior',
'Next' =>'Seguinte',
'First' =>'Primeiro',
'Last' =>'Último',
'Go to' =>'Ir para',
'Page' =>'Página',
'Records' =>'Registos',
'Save' =>'Guardar',
'More' =>'Mais',
'Apply' =>'Aplicar',
'Cancel' =>'Cancelar',
'Search' =>'Procurar',
'Hide' =>'Esconder',
'Clear' =>'Limpar',
'Query' =>'Pesquisa',
'Current Query' =>'Pesquisa Actual',
'Sorted By' =>'Ordenado Por',
'ascending' =>'ascendente',
'descending' =>'descendente',
'hidden' =>'escondido',
'of' =>'de',
'record added' =>'registo adicionado',
'record changed' =>'registo alterado',
'record deleted' =>'registo apagado',
'Please enter' =>'Por favor introduza ',
'months' => Array(
'01'=>'Janeiro',
'02'=>'Fevereiro',
'03'=>'Março',
'04'=>'Abril',
'05'=>'Maio',
'06'=>'Junho',
'07'=>'Julho',
'08'=>'Agosto',
'09'=>'Setembro',
'10'=>'Outubro',
'11'=>'Novembro',
'12'=>'Dezembro'),
// phpMyEdit-report
'Make report' => 'Criar relatório',
'Select fields' => 'Escolher campos',
'Records per screen' => 'Registos por ecran',
);
 
?>
/tags/v3.1-blanche-neige/jrest/util/lang/PME.lang.CA.inc
New file
0,0 → 1,64
<?php
 
/*
* phpMyEdit language file
*
* language: català
* encoding: iso-8859-1
* date: 2006-04-06
* author: Josep Maria Faura <j.m.faura@telefonica.net>
*/
 
/* $Platon: phpMyEdit/lang/PME.lang.CA.inc,v 1.2 2006-04-11 10:30:46 nepto Exp $ */
 
return Array(
'Add' =>'Afegir',
'Copy' =>'Copiar',
'Change' =>'Modificar',
'Delete' =>'Suprimir',
'View' =>'Visualitzar',
'Prev' =>'Anterior',
'Next' =>'Següent',
'First' =>'Primer',
'Last' =>'Últim',
'Go to' =>'Ves a',
'Page' =>'Pàgina',
'Records' =>'Registres',
'Save' =>'Salvar',
'More' =>'Més',
'Apply' =>'Aplicar',
'Cancel' =>'Cancel·lar',
'Search' =>'Cercar',
'Hide' =>'Amagar',
'Clear' =>'Netejar',
'Query' =>'Consultar',
'Current Query' =>'Consulta actual',
'Sorted By' =>'Ordenat per',
'ascending' =>'ascendent',
'descending' =>'descendent',
'hidden' =>'amagat',
'of' =>'de',
'record added' =>'Registre afegit',
'record changed'=>'Registre modificat',
'record deleted'=>'Registre esborrat',
'Please enter' =>'Sisplau introdueixi ',
'months' => Array(
'01'=>'Gener',
'02'=>'Febrer',
'03'=>'Març',
'04'=>'Abril',
'05'=>'Maig',
'06'=>'Juny',
'07'=>'Juliol',
'08'=>'Agost',
'09'=>'Septembre',
'10'=>'Octubre',
'11'=>'Novembre',
'12'=>'Desembre'),
// phpMyEdit-report
'Make report' => 'Construir informe',
'Select fields' => 'Seleccionar camps',
'Records per screen' => 'Registres per pantalla',
);
 
?>
/tags/v3.1-blanche-neige/jrest/util/lang/PME.lang.PT-BR.inc
New file
0,0 → 1,64
<?php
 
/*
* phpMyEdit language file
*
* language: portuguese (brazilian)
* encoding: iso-8859-1
* date: 2002-12-23, 2003-01-14, 2003-05-17, 2004-01-21
* author: Roberto Cohen <roberto.cohen@fireman.com.br>
*/
 
/* $Platon: phpMyEdit/lang/PME.lang.PT-BR.inc,v 1.8 2004-12-27 20:14:29 nepto Exp $ */
 
return Array(
'Add' =>'Adiciona',
'Copy' =>'Copia',
'Change' =>'Edita',
'Delete' =>'Remove',
'View' =>'Visualiza',
'Prev' =>'Anterior',
'Next' =>'Próximo',
'First' =>'Primeiro',
'Last' =>'Último',
'Go to' =>'Vai para',
'Page' =>'Página',
'Records' =>'Registros',
'Save' =>'Salva',
'More' =>'Mais',
'Apply' =>'Aplica',
'Cancel' =>'Cancela',
'Search' =>'Pesquisa',
'Hide' =>'Esconde',
'Clear' =>'Limpa',
'Query' =>'Resultado',
'Current Query' =>'Resultado atual',
'Sorted By' =>'Ordernado por',
'ascending' =>'crescente',
'descending' =>'descendente',
'hidden' =>'escondido',
'of' =>'de',
'record added' =>'registro adicionado',
'record changed'=>'registro editado',
'record deleted'=>'registro removido',
'Please enter' =>'Por favor, entre',
'months' => Array(
'01'=>'Janeiro',
'02'=>'Fevereiro',
'03'=>'Março',
'04'=>'Abril',
'05'=>'Maio',
'06'=>'Junho',
'07'=>'Julho',
'08'=>'Agosto',
'09'=>'Setembro',
'10'=>'Outubro',
'11'=>'Novembro',
'12'=>'Dezembro'),
// phpMyEdit-report
'Gerar relatório' => 'Make report',
'Selecionar campos' => 'Select fields',
'Registros por tela' => 'Records per screen',
);
 
?>
/tags/v3.1-blanche-neige/jrest/util/lang/PME.lang.TR.inc
New file
0,0 → 1,66
<?php
 
/*
* phpMyEdit language file
*
* language: turkish
* encoding: iso-8859-9
* date: 2003-10-24, 2005-11-13
* authors:
* Nuri Akman <nuri.akman@hazine.gov.tr>
* Kadan Kongar <kagan.kongar@tsrsb.org.tr>
*/
 
/* $Platon: phpMyEdit/lang/PME.lang.TR.inc,v 1.4 2005-11-14 03:15:04 nepto Exp $ */
 
return Array(
'Add' =>'Ekle',
'Copy' =>'Kopyala',
'Change' =>'Deðiþtir',
'Delete' =>'Sil',
'View' =>'Bak',
'Prev' =>'Önceki',
'Next' =>'Sonraki',
'First' =>'Ýlk',
'Last' =>'Son',
'Go to' =>'Git',
'Page' =>'Sayfa',
'Records' =>'Kayýt',
'Save' =>'Kaydet',
'More' =>'Devamý',
'Apply' =>'Uygula',
'Cancel' =>'Ýptal',
'Search' =>'Ara',
'Hide' =>'Gizle',
'Clear' =>'Temizle',
'Query' =>'Sorgu',
'Current Query' =>'Aktif Sorgu',
'Sorted By' =>'Sýralama',
'ascending' =>'artan',
'descending' =>'azalan',
'hidden' =>'gizli',
'of' =>' / ',
'record added' =>'kayýt eklendi',
'record changed' =>'kayýt deðiþtirildi',
'record deleted' =>'kayýt silindi',
'Please enter' =>'Lütfen giriniz :',
'months' => Array(
'01'=>'Ocak',
'02'=>'Þubat',
'03'=>'Mart',
'04'=>'Nisan',
'05'=>'Mayýs',
'06'=>'Haziran',
'07'=>'Temmuz',
'08'=>'Auðustos',
'09'=>'Eylül',
'10'=>'Ekim',
'11'=>'Kasým',
'12'=>'Aralýk'),
// phpMyEdit-report
'Make report' => 'Rapor hazýrla',
'Select fields' => 'Alanlarý seçiniz',
'Records per screen' => 'Sayfa baþýna kayýt',
);
 
?>
/tags/v3.1-blanche-neige/jrest/util/lang/PME.lang.RU.inc
New file
0,0 → 1,64
<?php
 
/*
* phpMyEdit language file
*
* language: russian
* encoding: windows-1251
* date: 2002-11-23
* author: Lev Zabudkin <zabudkin@mail.ru>
*/
 
/* $Platon: phpMyEdit/lang/PME.lang.RU.inc,v 1.11 2004-12-27 20:14:29 nepto Exp $ */
 
return Array(
'Add' =>'Äîáàâèòü',
'Copy' =>'Êîïèðîâàòü',
'Change' =>'Èçìåíèòü',
'Delete' =>'Óäàëèòü',
'View' =>'Ïðîñìîòð',
'Prev' =>'<<',
'Next' =>'>>',
'First' =>'I<',
'Last' =>'>I',
'Go to' =>'Ïåðåéòè',
'Page' =>'Ñòð.',
'Records' =>'Çàïèñåé',
'Save' =>'Ñîõðàíèòü',
'More' =>'Áîëüøå',
'Apply' =>'Ïðèìåíèòü',
'Cancel' =>'Îòìåíà',
'Search' =>'Ïîèñê',
'Hide' =>'Ñêðûòü',
'Clear' =>'Î÷èñòèòü',
'Query' =>'Çàïðîñ',
'Current Query' =>'Òåêóùèé çàïðîñ',
'Sorted By' =>'Îòñîðòèðîâàíî ïî',
'ascending' =>'- âîçðàñòàíèþ',
'descending' =>'- óáûâàíèþ',
'hidden' =>'ñêðûòî',
'of' =>'èç',
'record added' =>'çàïèñü äîáàâëåíà',
'record changed'=>'çàïèñü îáíîâëåíà',
'record deleted'=>'çàïèñü óäàëåíà',
'Please enter' =>'Ïîæàëóéñòà ââåäèòå',
'months' => Array(
'01'=>'ßíâàðü',
'02'=>'Ôåâðàëü',
'03'=>'Ìàðò',
'04'=>'Àïðåëü',
'05'=>'Ìàé',
'06'=>'Èþíü',
'07'=>'Èþëü',
'08'=>'Àâãóñò',
'09'=>'Ñåíòÿáðü',
'10'=>'Îêòÿáðü',
'11'=>'Íîÿáðü',
'12'=>'Äåêàáðü'),
// phpMyEdit-report
'Make report' => 'Ñîçäàòü îò÷åò',
'Select fields' => 'Âûáðàòü ïîëÿ',
'Records per screen' => 'Çàïèñåé íà ýêðàíå',
);
 
?>
/tags/v3.1-blanche-neige/jrest/util/lang/PME.lang.EN-US.inc
New file
0,0 → 1,64
<?php
 
/*
* phpMyEdit language file
*
* language: english (United States)
* encoding: iso-8859-1
* date: 2002-02, 2003-05-01
* author: Jim Kraai <jkraai@users.sourceforge.net>
*/
 
/* $Platon: phpMyEdit/lang/PME.lang.EN-US.inc,v 1.10 2004-12-27 20:14:29 nepto Exp $ */
 
return Array(
'Add' =>'Add',
'Copy' =>'Copy',
'Change' =>'Change',
'Delete' =>'Delete',
'View' =>'View',
'Prev' =>'Prev',
'Next' =>'Next',
'First' =>'First',
'Last' =>'Last',
'Go to' =>'Go to',
'Page' =>'Page',
'Records' =>'Records',
'Save' =>'Save',
'More' =>'More',
'Apply' =>'Apply',
'Cancel' =>'Cancel',
'Search' =>'Search',
'Hide' =>'Hide',
'Clear' =>'Clear',
'Query' =>'Query',
'Current Query' =>'Current Query',
'Sorted By' =>'Sorted By',
'ascending' =>'ascending',
'descending' =>'descending',
'hidden' =>'hidden',
'of' =>'of',
'record added' =>'record added',
'record changed' =>'record changed',
'record deleted' =>'record deleted',
'Please enter' =>'Please enter',
'months' => Array(
'01'=>'January',
'02'=>'February',
'03'=>'March',
'04'=>'April',
'05'=>'May',
'06'=>'June',
'07'=>'July',
'08'=>'August',
'09'=>'September',
'10'=>'October',
'11'=>'November',
'12'=>'December'),
// phpMyEdit-report
'Make report' => 'Make report',
'Select fields' => 'Select fields',
'Records per screen' => 'Records per screen',
);
 
?>
/tags/v3.1-blanche-neige/jrest/util/lang/PME.lang.DE.inc
New file
0,0 → 1,67
<?php
 
/*
* phpMyEdit language file
*
* language: german (standard)
* encoding: iso-8859-1
* date: 2002-07
* authors:
* Christof Brandstetter <fellz@users.sourceforge.net>
* Gerd Xhonneux, http://xsite.xhonneux.com
* info: http://makeashorterlink.com/?O116223C2
*/
 
/* $Platon: phpMyEdit/lang/PME.lang.DE.inc,v 1.14 2004-12-27 20:14:29 nepto Exp $ */
 
return Array(
'Add' =>'Hinzufügen',
'Copy' =>'Kopieren',
'Change' =>'Ändern',
'Delete' =>'Löschen',
'View' =>'Anzeigen',
'Prev' =>'Zurück',
'Next' =>'Weiter',
'First' =>'First', // untranslated
'Last' =>'Last', // untranslated
'Go to' =>'Go to', // untranslated
'Page' =>'Seite',
'Records' =>'Datensätze',
'Save' =>'Speichern',
'More' =>'Speichern, weiteren Datensatz hinzufügen',
'Apply' =>'Anwenden',
'Cancel' =>'Abbrechen',
'Search' =>'Suche',
'Hide' =>'Verstecken',
'Clear' =>'Löschen',
'Query' =>'Abfrage',
'Current Query' =>'Aktuelle Abfrage',
'Sorted By' =>'Sortiert nach',
'ascending' =>'aufsteigend',
'descending' =>'absteigend',
'hidden' =>'versteckt',
'of' =>'von',
'record added' =>'Datensatz hinzugefügt',
'record changed'=>'Datensatz geändert',
'record deleted'=>'Datensatz gelöscht',
'Please enter' =>'Bitte füllen sie dieses Feld aus:',
'months' => Array(
'01'=>'Januar',
'02'=>'Februar',
'03'=>'März',
'04'=>'April',
'05'=>'Mai',
'06'=>'Juni',
'07'=>'Juli',
'08'=>'August',
'09'=>'September',
'10'=>'Oktober',
'11'=>'November',
'12'=>'Dezember'),
// phpMyEdit-report
'Make report' => 'Make report',
'Select fields' => 'Select fields',
'Records per screen' => 'Records per screen',
);
 
?>
/tags/v3.1-blanche-neige/jrest/util/lang/PME.lang.ZH-SG.inc
New file
0,0 → 1,64
<?php
 
/*
* phpMyEdit language file
*
* language: chinese (Singapore)
* encoding: utf-8
* date: 2003-07-03
* author: Juraj Benadik <gastan at gastan.sk>
*/
 
/* $Platon: phpMyEdit/lang/PME.lang.ZH-SG.inc,v 1.4 2004-12-27 20:14:29 nepto Exp $ */
 
return Array(
'Add' =>'添加',
'Copy' =>'复制',
'Change' =>'更改',
'Delete' =>'删除',
'View' =>'查看',
'Prev' =>'上页',
'Next' =>'下页',
'First' =>'First', // untranslated
'Last' =>'Last', // untranslated
'Go to' =>'Go to', // untranslated
'Page' =>'页',
'Records' =>'记录',
'Save' =>'保存',
'More' =>'更多',
'Apply' =>'应用',
'Cancel' =>'取消',
'Search' =>'搜寻',
'Hide' =>'隐藏',
'Clear' =>'清除',
'Query' =>'查询',
'Current Query' =>'当前 查询',
'Sorted By' =>'排序方式',
'ascending' =>'上升',
'descending' =>'递减',
'hidden' =>'隐藏的',
'of' =>'总',
'record added' =>'记录添加',
'record changed' =>'记录更改',
'record deleted' =>'记录删除',
'Please enter' =>'请进入',
'months' => Array(
'01'=>'一月',
'02'=>'二月',
'03'=>'三月',
'04'=>'四月',
'05'=>'五月',
'06'=>'六月',
'07'=>'七月',
'08'=>'八月',
'09'=>'九月',
'10'=>'十月',
'11'=>'十一月',
'12'=>'十二月'),
// phpMyEdit-report
'Make report' => 'Make report',
'Select fields' => 'Select fields',
'Records per screen' => 'Records per screen',
);
 
?>
/tags/v3.1-blanche-neige/jrest/util/lang/PME.lang.ES-MX.inc
New file
0,0 → 1,64
<?php
 
/*
* phpMyEdit language file
*
* language: spanish (mexican)
* encoding: iso-8859-1
* date: 2003-04-30
* author: unknown
*/
 
/* $Platon: phpMyEdit/lang/PME.lang.ES-MX.inc,v 1.3 2004-12-27 20:14:29 nepto Exp $ */
 
return Array(
'Add' =>'Agregar',
'Copy' =>'Copiar',
'Change' =>'Cambiar',
'Delete' =>'Suprimir',
'View' =>'Ver',
'Prev' =>'Anterior',
'Next' =>'Siguiente',
'First' =>'First', // untranslated
'Last' =>'Last', // untranslated
'Go to' =>'Go to', // untranslated
'Page' =>'Página',
'Records' =>'Registros',
'Save' =>'Guardar',
'More' =>'Más',
'Apply' =>'Aplicar',
'Cancel' =>'Cancelar',
'Search' =>'Buscar',
'Hide' =>'Ocultar',
'Clear' =>'Limpiar',
'Query' =>'Consulta SQL',
'Current Query' =>'Consulta actual',
'Sorted By' =>'Ordenado por',
'ascending' =>'ascendente',
'descending' =>'descendente',
'hidden' =>'oculto',
'of' =>'de',
'record added' =>'registro agregado',
'record changed'=>'registro cambiado',
'record deleted'=>'registro borrado',
'Please enter' =>'Por favor introduzca ',
'months' => Array(
'01'=>'Enero',
'02'=>'Febrero',
'03'=>'Marzoa',
'04'=>'Abril',
'05'=>'Mayo',
'06'=>'Junio',
'07'=>'Julio',
'08'=>'Agosto',
'09'=>'Septiembre',
'10'=>'Octubre',
'11'=>'Noviembre',
'12'=>'Diciembre'),
// phpMyEdit-report
'Make report' => 'Make report',
'Select fields' => 'Select fields',
'Records per screen' => 'Records per screen',
);
 
?>
/tags/v3.1-blanche-neige/jrest/util/lang/PME.lang.DK.inc
New file
0,0 → 1,64
<?php
 
/*
* phpMyEdit language file
*
* language: danish
* encoding: iso-8859-1
* date: 2003-03-19
* author: Henrik Nielsen <kontakt@innovapage.dk>
*/
 
/* $Platon: phpMyEdit/lang/PME.lang.DK.inc,v 1.5 2004-12-27 20:14:29 nepto Exp $ */
 
return Array(
'Add' =>'Tilføj',
'Copy' =>'Kopier',
'Change' =>'Ret',
'Delete' =>'Slet',
'View' =>'Se',
'Prev' =>'Tilbage',
'Next' =>'Næste',
'First' =>'First', // untranslated
'Last' =>'Last', // untranslated
'Go to' =>'Go to', // untranslated
'Page' =>'Side',
'Records' =>'Rækker',
'Save' =>'Gem',
'More' =>'Mere',
'Apply' =>'Tilføj',
'Cancel' =>'Fortryd',
'Search' =>'Søg',
'Hide' =>'Skjul',
'Clear' =>'Tøm',
'Query' =>'Søg',
'Current Query' =>'Current Query', // untranslated
'Sorted By' =>'Sorted By', // untranslated
'ascending' =>'ascending', // untranslated
'descending' =>'descending', // untranslated
'hidden' =>'hidden', // untranslated
'of' =>'af',
'record added' =>'række tilføjet',
'record changed' =>'række ændret',
'record deleted' =>'række slettet',
'Please enter' =>'Indtast venligst',
'months' => Array(
'01'=>'Januar',
'02'=>'Februar',
'03'=>'Marts',
'04'=>'April',
'05'=>'Maj',
'06'=>'Juni',
'07'=>'Juli',
'08'=>'August',
'09'=>'September',
'10'=>'Oktober',
'11'=>'November',
'12'=>'December'),
// phpMyEdit-report
'Make report' => 'Make report',
'Select fields' => 'Select fields',
'Records per screen' => 'Records per screen',
);
?>
/tags/v3.1-blanche-neige/jrest/util/images/pme-delete.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/tags/v3.1-blanche-neige/jrest/util/images/pme-delete.png
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/tags/v3.1-blanche-neige/jrest/util/images/pme-change.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/tags/v3.1-blanche-neige/jrest/util/images/pme-change.png
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/tags/v3.1-blanche-neige/jrest/util/images/pme-copy.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/tags/v3.1-blanche-neige/jrest/util/images/pme-copy.png
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/tags/v3.1-blanche-neige/jrest/util/images/pme-view.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/tags/v3.1-blanche-neige/jrest/util/images/pme-view.png
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/tags/v3.1-blanche-neige/jrest/util/images/alt/pme-delete.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/tags/v3.1-blanche-neige/jrest/util/images/alt/pme-delete.png
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/tags/v3.1-blanche-neige/jrest/util/images/alt/pme-change.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/tags/v3.1-blanche-neige/jrest/util/images/alt/pme-change.png
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/tags/v3.1-blanche-neige/jrest/util/images/alt/pme-copy.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/tags/v3.1-blanche-neige/jrest/util/images/alt/pme-copy.png
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/tags/v3.1-blanche-neige/jrest/util/images/alt/pme-view.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/tags/v3.1-blanche-neige/jrest/util/images/alt/pme-view.png
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/tags/v3.1-blanche-neige/jrest/util/cel_inventory.php
New file
0,0 → 1,252
<style type="text/css">
hr.pme-hr { border: 0px solid; padding: 0px; margin: 0px; border-top-width: 1px; height: 1px; }
table.pme-main { border: #004d9c 1px solid; border-collapse: collapse; border-spacing: 0px; width: 100%; }
table.pme-navigation { border: #004d9c 0px solid; border-collapse: collapse; border-spacing: 0px; width: 100%; }
th.pme-header { border: #004d9c 1px solid; padding: 4px; background: #add8e6; }
td.pme-key-0, td.pme-value-0, td.pme-help-0, td.pme-navigation-0, td.pme-cell-0,
td.pme-key-1, td.pme-value-1, td.pme-help-0, td.pme-navigation-1, td.pme-cell-1,
td.pme-sortinfo, td.pme-filter { border: #004d9c 1px solid; padding: 3px; }
td.pme-buttons { text-align: left; }
td.pme-message { text-align: center; }
td.pme-stats { text-align: right; }
</style><?php
 
/*
* IMPORTANT NOTE: This generated file contains only a subset of huge amount
* of options that can be used with phpMyEdit. To get information about all
* features offered by phpMyEdit, check official documentation. It is available
* online and also for download on phpMyEdit project management page:
*
* http://platon.sk/projects/main_page.php?project_id=5
*
* This file was generated by:
*
* phpMyEdit version: 5.6
* phpMyEdit.class.php core class: 1.188
* phpMyEditSetup.php script: 1.48
* generating setup script: 1.48
*/
 
// MySQL host name, user name, password, database, and table
$opts['hn'] = 'localhost';
$opts['un'] = 'root';
$opts['pw'] = '';
$opts['db'] = 'cel';
$opts['tb'] = 'cel_inventory';
 
// Name of field which is the unique key
$opts['key'] = 'id';
 
// Type of key field (int/real/string/date etc.)
$opts['key_type'] = 'int';
 
// Sorting field(s)
$opts['sort_field'] = array('id');
 
// Number of records to display on the screen
// Value of -1 lists all records in a table
$opts['inc'] = 15;
 
// Options you wish to give the users
// A - add, C - change, P - copy, V - view, D - delete,
// F - filter, I - initial sort suppressed
$opts['options'] = 'ACPVDF';
 
// Number of lines to display on multiple selection filters
$opts['multiple'] = '4';
 
// Navigation style: B - buttons (default), T - text links, G - graphic links
// Buttons position: U - up, D - down (default)
$opts['navigation'] = 'TB';
 
// Display special page elements
$opts['display'] = array(
'form' => true,
'query' => true,
'sort' => true,
'time' => true,
'tabs' => true
);
 
// Set default prefixes for variables
$opts['js']['prefix'] = 'PME_js_';
$opts['dhtml']['prefix'] = 'PME_dhtml_';
$opts['cgi']['prefix']['operation'] = 'PME_op_';
$opts['cgi']['prefix']['sys'] = 'PME_sys_';
$opts['cgi']['prefix']['data'] = 'PME_data_';
 
/* Get the user's default language and use it if possible or you can
specify particular one you want to use. Refer to official documentation
for list of available languages. */
$opts['language'] = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
 
/* Table-level filter capability. If set, it is included in the WHERE clause
of any generated SELECT statement in SQL query. This gives you ability to
work only with subset of data from table.
 
$opts['filters'] = "column1 like '%11%' AND column2<17";
$opts['filters'] = "section_id = 9";
$opts['filters'] = "PMEtable0.sessions_count > 200";
*/
 
/* Field definitions
Fields will be displayed left to right on the screen in the order in which they
appear in generated list. Here are some most used field options documented.
 
['name'] is the title used for column headings, etc.;
['maxlen'] maximum length to display add/edit/search input boxes
['trimlen'] maximum length of string content to display in row listing
['width'] is an optional display width specification for the column
e.g. ['width'] = '100px';
['mask'] a string that is used by sprintf() to format field output
['sort'] true or false; means the users may sort the display on this column
['strip_tags'] true or false; whether to strip tags from content
['nowrap'] true or false; whether this field should get a NOWRAP
['select'] T - text, N - numeric, D - drop-down, M - multiple selection
['options'] optional parameter to control whether a field is displayed
L - list, F - filter, A - add, C - change, P - copy, D - delete, V - view
Another flags are:
R - indicates that a field is read only
W - indicates that a field is a password field
H - indicates that a field is to be hidden and marked as hidden
['URL'] is used to make a field 'clickable' in the display
e.g.: 'mailto:$value', 'http://$value' or '$page?stuff';
['URLtarget'] HTML target link specification (for example: _blank)
['textarea']['rows'] and/or ['textarea']['cols']
specifies a textarea is to be used to give multi-line input
e.g. ['textarea']['rows'] = 5; ['textarea']['cols'] = 10
['values'] restricts user input to the specified constants,
e.g. ['values'] = array('A','B','C') or ['values'] = range(1,99)
['values']['table'] and ['values']['column'] restricts user input
to the values found in the specified column of another table
['values']['description'] = 'desc_column'
The optional ['values']['description'] field allows the value(s) displayed
to the user to be different to those in the ['values']['column'] field.
This is useful for giving more meaning to column values. Multiple
descriptions fields are also possible. Check documentation for this.
*/
 
$opts['fdd']['id'] = array(
'name' => 'ID',
'select' => 'T',
'options' => 'AVCPDR', // auto increment
'maxlen' => 20,
'default' => '0',
'sort' => true
);
$opts['fdd']['identifiant'] = array(
'name' => 'Identifiant',
'select' => 'T',
'maxlen' => 128,
'sort' => true
);
$opts['fdd']['ordre'] = array(
'name' => 'Ordre',
'select' => 'T',
'maxlen' => 20,
'sort' => true
);
$opts['fdd']['nom_sel'] = array(
'name' => 'Nom sel',
'select' => 'T',
'maxlen' => 255,
'sort' => true
);
$opts['fdd']['num_nom_sel'] = array(
'name' => 'Num nom sel',
'select' => 'T',
'maxlen' => 11,
'sort' => true
);
$opts['fdd']['nom_ret'] = array(
'name' => 'Nom ret',
'select' => 'T',
'maxlen' => 255,
'sort' => true
);
$opts['fdd']['num_nom_ret'] = array(
'name' => 'Num nom ret',
'select' => 'T',
'maxlen' => 11,
'sort' => true
);
$opts['fdd']['num_taxon'] = array(
'name' => 'Num taxon',
'select' => 'T',
'maxlen' => 11,
'sort' => true
);
$opts['fdd']['famille'] = array(
'name' => 'Famille',
'select' => 'T',
'maxlen' => 255,
'sort' => true
);
$opts['fdd']['location'] = array(
'name' => 'Location',
'select' => 'T',
'maxlen' => 50,
'sort' => true
);
$opts['fdd']['id_location'] = array(
'name' => 'ID location',
'select' => 'T',
'maxlen' => 10,
'sort' => true
);
$opts['fdd']['date_observation'] = array(
'name' => 'Date observation',
'select' => 'T',
'maxlen' => 19,
'sort' => true
);
$opts['fdd']['station'] = array(
'name' => 'Station',
'select' => 'T',
'maxlen' => 255,
'sort' => true
);
$opts['fdd']['milieu'] = array(
'name' => 'Milieu',
'select' => 'T',
'maxlen' => 255,
'sort' => true
);
$opts['fdd']['commentaire'] = array(
'name' => 'Commentaire',
'select' => 'T',
'maxlen' => 1024,
'sort' => true
);
$opts['fdd']['transmission'] = array(
'name' => 'Transmission',
'select' => 'T',
'maxlen' => 4,
'sort' => true
);
$opts['fdd']['date_creation'] = array(
'name' => 'Date creation',
'select' => 'T',
'maxlen' => 19,
'sort' => true
);
$opts['fdd']['date_modification'] = array(
'name' => 'Date modification',
'select' => 'T',
'maxlen' => 19,
'sort' => true
);
$opts['fdd']['date_transmission'] = array(
'name' => 'Date transmission',
'select' => 'T',
'maxlen' => 19,
'sort' => true
);
 
// Now important call to phpMyEdit
require_once 'phpMyEdit.class.php';
new phpMyEdit($opts);
 
?>
 
/tags/v3.1-blanche-neige/jrest/util/phpMyEditSetup.php
New file
0,0 → 1,569
<?php
 
/*
* phpMyEdit - instant MySQL table editor and code generator
*
* phpMyEditSetup.php - interactive table configuration utility (setup)
* ____________________________________________________________
*
* Copyright (c) 1999-2002 John McCreesh <jpmcc@users.sourceforge.net>
* Copyright (c) 2001-2002 Jim Kraai <jkraai@users.sourceforge.net>
* Versions 5.0 and higher developed by Ondrej Jombik <nepto@php.net>
* Copyright (c) 2002-2006 Platon Group, http://platon.sk/
* All rights reserved.
*
* See README file for more information about this software.
* See COPYING file for license information.
*
* Download the latest version from
* http://platon.sk/projects/phpMyEdit/
*/
 
/* $Platon: phpMyEdit/phpMyEditSetup.php,v 1.48 2006-09-09 07:38:54 nepto Exp $ */
 
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<title>phpMyEdit Setup</title>
<style type="text/css">
<!--
body { font-family: "Verdana", "Arial", "Sans-Serif"; text-align: left }
h1 { color: #004d9c; font-size: 13pt; font-weight: bold }
h2 { color: #004d9c; font-size: 11pt; font-weight: bold }
h3 { color: #004d9c; font-size: 11pt; }
p { color: #004d9c; font-size: 9pt; }
table { border: 1px solid #004d9c; border-collapse: collapse; border-spacing: 0px; }
td { border: 1px solid; padding: 3px; color: #004d9c; font-size: 9pt; }
hr
{
height: 1px;
background-color: #000000;
color: #000000;
border: solid #000000 0;
padding: 0;
margin: 0;
border-top-width: 1px;
}
-->
</style>
</head>
<body bgcolor="white">
 
<?php
 
if (! defined('PHP_EOL')) {
define('PHP_EOL', strtoupper(substr(PHP_OS, 0, 3) == 'WIN') ? "\r\n"
: strtoupper(substr(PHP_OS, 0, 3) == 'MAC') ? "\r" : "\n");
}
 
$hn = @$_POST['hn'];
$un = @$_POST['un'];
$pw = @$_POST['pw'];
if(strlen($_POST['db'])>0) $db = @$_POST['db'];
if(strlen($_POST['tb'])>0) $tb = @$_POST['tb'];
$id = @$_POST['id'];
$submit = @$_POST['submit'];
$options = @$_POST['options'];
$baseFilename = @$_POST['baseFilename'];
$pageTitle = @$_POST['pageTitle'];
$pageHeader = @$_POST['pageHeader'];
$HTMLissues = @$_POST['HTMLissues'];
$CSSstylesheet = @$_POST['CSSstylesheet'];
 
$phpExtension = '.php';
if (isset($baseFilename) && $baseFilename != '') {
$phpFile = $baseFilename.$phpExtension;
//$contentFile = $baseFilename.'Content.inc';
$contentFile = $baseFilename.'.php';
} elseif (isset($tb)) {
$phpFile = $tb.$phpExtension;
//$contentFile = $tb.'Content.inc';
$contentFile = $tb.'.php';
} else {
$phpFile = 'index'.$phpExtension;
//$contentFile = 'Content.inc';
$contentFile = 'phpMyEdit-content.php';
}
 
$buffer = '';
 
function echo_html($x)
{
echo htmlspecialchars($x),PHP_EOL;
}
 
function echo_buffer($x)
{
global $buffer;
$buffer .= $x.PHP_EOL;
}
 
#:#####################################:#
#:# Function: check_constraints #:#
#:# Parameters: tb=table name #:#
#:# fd=field name #:#
#:# return: lookup default for #:#
#:# said constraint #:#
#:# or null if no #:#
#:# constraint is found. #:#
#:# Contributed by Wade Ryan, #:#
#:# 20060906 #:#
#:#####################################:#
function check_constraints($tb,$fd)
{
$query = "show create table $tb";
$result = mysql_query($query);
$tableDef = preg_split('/\n/',mysql_result($result,0,1));
 
$constraint_arg="";
while (list($key,$val) = each($tableDef)) {
$words=preg_split("/[\s'`()]+/", $val);
if ($words[1] == "CONSTRAINT" && $words[6]=="REFERENCES") {
if ($words[5]==$fd) {
$constraint_arg=" 'values' => array(\n".
" 'table' => '$words[7]',\n".
" 'column' => '$words[8]'\n".
" ),\n";
}
 
}
}
return $constraint_arg;
}
 
function get_versions()
{
$ret_ar = array();
$dirname = dirname(__FILE__);
foreach (array(
'current' => __FILE__,
'setup' => "$dirname/phpMyEditSetup.php",
'core' => "$dirname/phpMyEdit.class.php",
'version' => "$dirname/doc/VERSION")
as $type => $file) {
if (@file_exists($file) && @is_readable($file)) {
if (($f = fopen($file, 'r')) == false) {
continue;
}
$str = trim(fread($f, 4096));
if (strpos($str, ' ') === false && strlen($str) < 10) {
$ret_ar[$type] = $str;
} else if (preg_match('|\$'.'Platon:\s+\S+,v\s+(\d+.\d+)\s+|', $str, $matches)) {
$ret_ar[$type] = $matches[1];
}
fclose($f);
}
}
return $ret_ar;
}
 
 
$self = basename($_SERVER['PHP_SELF']);
$dbl = @mysql_pconnect($hn, $un, $pw);
 
if ((!$dbl) or empty($submit)) {
echo '<h1>Please log in to your MySQL database</h1>';
if (!empty($submit)) {
echo '<h2>Sorry - login failed - please try again</h2>'.PHP_EOL;
}
if (! isset($hn)) {
$hn = 'localhost';
}
echo '
<form action="'.htmlspecialchars($self).'" method="POST">
<table border="1" cellpadding="1" cellspacing="0" summary="Login form">
<tr>
<td>Hostname:</td>
<td><input type="text" name="hn" value="'.htmlspecialchars($hn).'"></td>
</tr><tr>
<td>Username:</td>
<td><input type="text" name="un" value="'.htmlspecialchars($un).'"></td>
</tr><tr>
<td>Password:</td>
<td><input type="password" name="pw" value="'.htmlspecialchars($pw).'"></td>
</tr><tr>
<td>Database:</td>
<td><input type="text" name="db" value="'.htmlspecialchars($db).'"></td>
</tr><tr>
<td>Table:</td>
<td><input type="text" name="tb" value="'.htmlspecialchars($tb).'"></td>
</tr>
</table><br>
<input type="submit" name="submit" value="Submit">
</form>'.PHP_EOL;
} else if (! isset($db)) {
$dbs = @mysql_list_dbs($dbl);
$num_dbs = @mysql_num_rows($dbs);
echo '<h1>Please select a database</h1>
<form action="'.htmlspecialchars($self).'" method="POST">
<input type="hidden" name="hn" value="'.htmlspecialchars($hn).'">
<input type="hidden" name="un" value="'.htmlspecialchars($un).'">
<input type="hidden" name="pw" value="'.htmlspecialchars($pw).'">
<table border="1" cellpadding="1" cellspacing="1" summary="Database selection">'.PHP_EOL;
for ($i = 0; $i < $num_dbs; $i++) {
$db = @mysql_db_name($dbs, $i);
$checked = ! strcasecmp($un, $db) ? ' checked' : '';
$db = htmlspecialchars($db);
echo '<tr><td><input'.$checked.' type="radio" name="db" value="'.$db.'"></td><td>'.$db.'</td></tr>'.PHP_EOL;
}
echo '</table><br>
<input type="submit" name="submit" value="Submit">
<input type="submit" name="cancel" value="Cancel">
</form>'.PHP_EOL;
} else if (!isset($tb)) {
echo '<h1>Please select a table from database: '.htmlspecialchars($db).'</h1>
<form action="'.htmlspecialchars($self).'" method="POST">
<input type="hidden" name="hn" value="'.htmlspecialchars($hn).'">
<input type="hidden" name="un" value="'.htmlspecialchars($un).'">
<input type="hidden" name="pw" value="'.htmlspecialchars($pw).'">
<input type="hidden" name="db" value="'.htmlspecialchars($db).'">
<table border="1" cellpadding="1" cellspacing="1" summary="Table selection">'.PHP_EOL;
$tbs = @mysql_list_tables($db, $dbl);
$num_tbs = @mysql_num_rows($tbs);
for ($j = 0; $j < $num_tbs; $j++) {
$tb = @mysql_tablename($tbs, $j);
$tb = htmlspecialchars($tb);
$checked = $j == 0 ? ' checked' : '';
echo '<tr><td><input'.$checked.' type="radio" name="tb" value="'.$tb.'"></td><td>'.$tb.'</td></tr>'.PHP_EOL;
}
echo '</table><br>
<input type="submit" name="submit" value="Submit">
<input type="submit" name="cancel" value="Cancel">
</form>'.PHP_EOL;
} else if (!isset($id)) {
echo ' <h1>Please select an identifier from table: '.htmlspecialchars($tb).'</h1>
<p>
This field will be used in change, view, copy and delete operations.<br>
The field should be numeric and must uniquely identify a record.
</p>
<p>
Please note, that there were problems reported by phpMyEdit users
regarding using MySQL reserved word as unique key name (the example for
this is "key" name). Thus we recommend you to use another name
of unique key. Usage of "id" or "ID" should be safe and good idea.
</p>
<form action="'.htmlspecialchars($self).'" method="POST">
<input type="hidden" name="hn" value="'.htmlspecialchars($hn).'">
<input type="hidden" name="un" value="'.htmlspecialchars($un).'">
<input type="hidden" name="pw" value="'.htmlspecialchars($pw).'">
<input type="hidden" name="db" value="'.htmlspecialchars($db).'">
<input type="hidden" name="tb" value="'.htmlspecialchars($tb).'">
<table border="1" cellpadding="1" cellspacing="1" summary="Key selection">'.PHP_EOL;
// <tr><td><input type="radio" name="id" value="">
// <td><i>None</i></td><td><i>No id field required</i></td></tr>
@mysql_select_db($db);
$tb_desc = @mysql_query("DESCRIBE $tb");
$fds = @mysql_list_fields($db,$tb,$dbl);
for ($j = 0; ($fd = @mysql_field_name($fds, $j)) != false; $j++) {
$ff = @mysql_field_flags($fds, $j);
strlen($ff) <= 0 && $ff = '---';
$checked = stristr($ff, 'primary_key') ? ' checked' : '';
echo '<tr><td><input',$checked,' type="radio" name="id" value="',htmlspecialchars($fd),'"></td>';
echo '<td>',htmlspecialchars($fd),'</td>';
echo '<td>',htmlspecialchars($ff),'</td>';
$r = @mysql_fetch_array($tb_desc, $j);
}
echo '</table><br>
<input type="submit" name="submit" value="Submit">
<input type="submit" name="cancel" value="Cancel">
</form>'.PHP_EOL;
 
} else if (!isset($options)) {
echo '<h1>Please select additional options</h1>
<form action="'.htmlspecialchars($self).'" method="POST">
<input type="hidden" name="hn" value="'.htmlspecialchars($hn).'">
<input type="hidden" name="un" value="'.htmlspecialchars($un).'">
<input type="hidden" name="pw" value="'.htmlspecialchars($pw).'">
<input type="hidden" name="db" value="'.htmlspecialchars($db).'">
<input type="hidden" name="tb" value="'.htmlspecialchars($tb).'">
<input type="hidden" name="id" value="'.htmlspecialchars($id).'">
<table border="1" cellpadding="1" cellspacing="1" summary="Additional options">
<tr><td>Base filename</td><td><input type="text" name=baseFilename value ="'.htmlspecialchars($tb).'"></td></tr>
<tr><td>Page title</td><td><input type="text" name=pageTitle value ="'.htmlspecialchars($tb).'"></td></tr>
<tr><td>Page header</td><td><input type="checkbox" name=pageHeader></td></tr>
<tr><td>HTML header &amp; footer</td><td><input type="checkbox" name=HTMLissues></td></tr>
<tr><td>CSS basic stylesheet</td><td><input checked type="checkbox" name=CSSstylesheet></td></tr>
</table><br>
<input type="submit" name="submit" value="Submit">
<input type="submit" name="cancel" value="Cancel">
<input type="hidden" name="options" value="1">
</form>'.PHP_EOL;
} else {
echo '<h1>Here is your phpMyEdit calling program</h1>'.PHP_EOL;
echo '<h2>You may now copy and paste it into your PHP editor</h2>'.PHP_EOL;
if ($pageHeader) {
echo_buffer('<h3>'.$pageTitle.'</h3>');
}
$versions = '';
$versions_ar = get_versions();
foreach (array(
'version' => 'phpMyEdit version:',
'core' => 'phpMyEdit.class.php core class:',
'setup' => 'phpMyEditSetup.php script:',
'current' => 'generating setup script:')
as $type => $desc) {
$version = isset($versions_ar[$type]) ? $versions_ar[$type] : 'unknown';
$versions .= sprintf("\n * %36s %s", $desc, $version);
}
echo_buffer("<?php
 
/*
* IMPORTANT NOTE: This generated file contains only a subset of huge amount
* of options that can be used with phpMyEdit. To get information about all
* features offered by phpMyEdit, check official documentation. It is available
* online and also for download on phpMyEdit project management page:
*
* http://platon.sk/projects/main_page.php?project_id=5
*
* This file was generated by:
*$versions
*/
 
// MySQL host name, user name, password, database, and table
\$opts['hn'] = '$hn';
\$opts['un'] = '$un';
\$opts['pw'] = '$pw';
\$opts['db'] = '$db';
\$opts['tb'] = '$tb';
 
// Name of field which is the unique key
\$opts['key'] = '$id';
 
// Type of key field (int/real/string/date etc.)");
 
if ($id == '') {
echo_buffer("\$opts['key_type'] = '';");
} else {
$fds = @mysql_list_fields($db,$tb,$dbl);
for ($j = 0; ($fd = @mysql_field_name($fds, $j)) != ''; $j++) {
if ($fd == $id) {
echo_buffer("\$opts['key_type'] = '".@mysql_field_type($fds, $j)."';");
break;
}
}
}
echo_buffer("
// Sorting field(s)
\$opts['sort_field'] = array('$id');
 
// Number of records to display on the screen
// Value of -1 lists all records in a table
\$opts['inc'] = 15;
 
// Options you wish to give the users
// A - add, C - change, P - copy, V - view, D - delete,
// F - filter, I - initial sort suppressed
\$opts['options'] = 'ACPVDF';
 
// Number of lines to display on multiple selection filters
\$opts['multiple'] = '4';
 
// Navigation style: B - buttons (default), T - text links, G - graphic links
// Buttons position: U - up, D - down (default)
\$opts['navigation'] = 'DB';
 
// Display special page elements
\$opts['display'] = array(
'form' => true,
'query' => true,
'sort' => true,
'time' => true,
'tabs' => true
);
 
// Set default prefixes for variables
\$opts['js']['prefix'] = 'PME_js_';
\$opts['dhtml']['prefix'] = 'PME_dhtml_';
\$opts['cgi']['prefix']['operation'] = 'PME_op_';
\$opts['cgi']['prefix']['sys'] = 'PME_sys_';
\$opts['cgi']['prefix']['data'] = 'PME_data_';
 
/* Get the user's default language and use it if possible or you can
specify particular one you want to use. Refer to official documentation
for list of available languages. */
\$opts['language'] = \$_SERVER['HTTP_ACCEPT_LANGUAGE'];
 
/* Table-level filter capability. If set, it is included in the WHERE clause
of any generated SELECT statement in SQL query. This gives you ability to
work only with subset of data from table.
 
\$opts['filters'] = \"column1 like '%11%' AND column2<17\";
\$opts['filters'] = \"section_id = 9\";
\$opts['filters'] = \"PMEtable0.sessions_count > 200\";
*/
 
/* Field definitions
Fields will be displayed left to right on the screen in the order in which they
appear in generated list. Here are some most used field options documented.
 
['name'] is the title used for column headings, etc.;
['maxlen'] maximum length to display add/edit/search input boxes
['trimlen'] maximum length of string content to display in row listing
['width'] is an optional display width specification for the column
e.g. ['width'] = '100px';
['mask'] a string that is used by sprintf() to format field output
['sort'] true or false; means the users may sort the display on this column
['strip_tags'] true or false; whether to strip tags from content
['nowrap'] true or false; whether this field should get a NOWRAP
['select'] T - text, N - numeric, D - drop-down, M - multiple selection
['options'] optional parameter to control whether a field is displayed
L - list, F - filter, A - add, C - change, P - copy, D - delete, V - view
Another flags are:
R - indicates that a field is read only
W - indicates that a field is a password field
H - indicates that a field is to be hidden and marked as hidden
['URL'] is used to make a field 'clickable' in the display
e.g.: 'mailto:\$value', 'http://\$value' or '\$page?stuff';
['URLtarget'] HTML target link specification (for example: _blank)
['textarea']['rows'] and/or ['textarea']['cols']
specifies a textarea is to be used to give multi-line input
e.g. ['textarea']['rows'] = 5; ['textarea']['cols'] = 10
['values'] restricts user input to the specified constants,
e.g. ['values'] = array('A','B','C') or ['values'] = range(1,99)
['values']['table'] and ['values']['column'] restricts user input
to the values found in the specified column of another table
['values']['description'] = 'desc_column'
The optional ['values']['description'] field allows the value(s) displayed
to the user to be different to those in the ['values']['column'] field.
This is useful for giving more meaning to column values. Multiple
descriptions fields are also possible. Check documentation for this.
*/
");
 
@mysql_select_db($db);
$tb_desc = @mysql_query("DESCRIBE $tb");
$fds = @mysql_list_fields($db, $tb, $dbl);
$num_fds = @mysql_num_fields($fds);
$ts_cnt = 0;
for ($k = 0; $k < $num_fds; $k++) {
$fd = mysql_field_name($fds,$k);
$fm = mysql_fetch_field($fds,$k);
$fn = strtr($fd, '_-.', ' ');
$fn = preg_replace('/(^| +)id( +|$)/', '\\1ID\\2', $fn); // uppercase IDs
$fn = ucfirst($fn);
$row = @mysql_fetch_array($tb_desc);
echo_buffer('$opts[\'fdd\'][\''.$fd.'\'] = array('); // )
echo_buffer(" 'name' => '".str_replace('\'','\\\'',$fn)."',");
$auto_increment = strstr($row[5], 'auto_increment') ? 1 : 0;
if (substr($row[1],0,3) == 'set') {
echo_buffer(" 'select' => 'M',");
} else {
echo_buffer(" 'select' => 'T',");
}
if ($auto_increment) {
echo_buffer(" 'options' => 'AVCPDR', // auto increment");
}
// timestamps are read-only
else if (@mysql_field_type($fds, $k) == 'timestamp') {
if ($ts_cnt > 0) {
echo_buffer(" 'options' => 'AVCPD',");
} else { // first timestamp
echo_buffer(" 'options' => 'AVCPDR', // updated automatically (MySQL feature)");
}
$ts_cnt++;
}
echo_buffer(" 'maxlen' => ".@mysql_field_len($fds,$k).',');
// blobs -> textarea
if (@mysql_field_type($fds,$k) == 'blob') {
echo_buffer(" 'textarea' => array(");
echo_buffer(" 'rows' => 5,");
echo_buffer(" 'cols' => 50),");
}
// SETs and ENUMs get special treatment
if ((substr($row[1],0,3) == 'set' || substr($row[1],0,4) == 'enum')
&& ! (($pos = strpos($row[1], '(')) === false)) {
$indent = str_repeat(' ', 18);
$outstr = substr($row[1], $pos + 2, -2);
$outstr = explode("','", $outstr);
$outstr = str_replace("''", "'", $outstr);
$outstr = str_replace('"', '\\"', $outstr);
$outstr = implode('",'.PHP_EOL.$indent.'"', $outstr);
echo_buffer(" 'values' => array(".PHP_EOL.$indent.'"'.$outstr.'"),');
}
// automatic support for Default values
if ($row[4] != '' && $row[4] != 'NULL') {
echo_buffer(" 'default' => '".$row[4]."',");
} else if ($auto_increment) {
echo_buffer(" 'default' => '0',");
}
// check for table constraints
$outstr = check_constraints($tb, $fd);
if ($outstr != '') {
echo_buffer($outstr);
}
echo_buffer(" 'sort' => true");
//echo_buffer(" 'nowrap' => false,");
echo_buffer(');');
}
 
echo_buffer("
// Now important call to phpMyEdit
require_once 'phpMyEdit.class.php';
new phpMyEdit(\$opts);
 
?>
");
 
$css_directive = <<<END
<style type="text/css">
hr.pme-hr { border: 0px solid; padding: 0px; margin: 0px; border-top-width: 1px; height: 1px; }
table.pme-main { border: #004d9c 1px solid; border-collapse: collapse; border-spacing: 0px; width: 100%; }
table.pme-navigation { border: #004d9c 0px solid; border-collapse: collapse; border-spacing: 0px; width: 100%; }
th.pme-header { border: #004d9c 1px solid; padding: 4px; background: #add8e6; }
td.pme-key-0, td.pme-value-0, td.pme-help-0, td.pme-navigation-0, td.pme-cell-0,
td.pme-key-1, td.pme-value-1, td.pme-help-0, td.pme-navigation-1, td.pme-cell-1,
td.pme-sortinfo, td.pme-filter { border: #004d9c 1px solid; padding: 3px; }
td.pme-buttons { text-align: left; }
td.pme-message { text-align: center; }
td.pme-stats { text-align: right; }
</style>
END;
if (! $CSSstylesheet) {
$css_directive = '';
}
 
if ($HTMLissues) {
$buffer = <<<END
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>$pageTitle</title>
$css_directive
</head>
<body>
$buffer
</body>
</html>
END;
} else if ($CSSstylesheet) {
$buffer = $css_directive . $buffer;
}
// write the content include file
echo 'Trying to write content file to: <b>'.'./'.$contentFile.'</b><br>'.PHP_EOL;
$filehandle = @fopen('./'.$contentFile, 'w+');
if ($filehandle) {
fwrite($filehandle, $buffer);
flush($filehandle);
fclose($filehandle);
echo 'phpMyEdit content file written successfully<br>';
} else {
echo 'phpMyEdit content file was NOT written due to inssufficient privileges.<br>';
echo 'Please copy and paste content listed below to <i>'.'./'.$contentFile.'</i> file.';
}
echo '<br><hr>';
echo '<pre>';
echo_html($buffer);
echo '</pre><hr>'.PHP_EOL;
}
 
?>
 
</body>
</html>
 
/tags/v3.1-blanche-neige/jrest/.directory
New file
0,0 → 1,5
[Dolphin]
Timestamp=2010,5,25,17,12,16
 
[Settings]
ShowDotFiles=true
/tags/v3.1-blanche-neige/jrest/services/Resume.php
New file
0,0 → 1,49
<?php
/**
* PHP Version 5
*
* @category PHP
* @package papyrus_bp
* @author aurelien <aurelien@tela-botanica.org>
* @copyright 2010 Tela-Botanica
* @license http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL
* @version SVN: <svn_id>
* @link /doc/papyrus_bp/
*/
 
Class Resume extends JRestService {
 
public function getElement($uid){
 
$id_utilisateur = $uid[0];
$mail_utilisateur = $uid[1];
 
$sql= 'SELECT bf_id_fiche, bf_titre, bf_date_maj_fiche FROM bazar_fiche'.
' WHERE bf_ce_utilisateur = '.$id_utilisateur.
' AND bf_statut_fiche = 1'.
' ORDER BY bf_date_maj_fiche DESC '.
' LIMIT 0,5';
 
$fiches = $projets = $this->bdd->query($sql)->fetchAll();
 
$resume = array();
 
$resume['titre'] = 'Mes derniers événements publiés';
$resume['lien_appli'] = '<a href="http://www.tela-botanica.org/page:evenements" > Consulter tous les évenements </a>';
 
if(!$fiches) {
$resume['message'] = 'Aucune fiche saisie pour le moment';
} else {
foreach($fiches as $fiche) {
$cible_lien = 'http://www.tela-botanica.org/page:evenements?vue=1&action=8&id_fiche='.$fiche['bf_id_fiche'];
$date_pub = ' publiée le '.$fiche['bf_date_maj_fiche'];
 
$resume_item = array('element' => htmlspecialchars($fiche['bf_titre']).$date_pub, 'lien' => $cible_lien);
$resume['elements'][] = $resume_item;
}
}
 
$this->envoyer($resume);
}
}
?>
/tags/v3.1-blanche-neige/jrest/services/JRestService.php
New file
0,0 → 1,238
<?php
/**
* Classe mère abstraite contenant les méthodes génériques des services.
* Encodage en entrée : utf8
* Encodage en sortie : utf8
*
* @author Jean-Pascal MILCENT <jpm@tela-botanica.org>
* @license GPL v3 <http://www.gnu.org/licenses/gpl.txt>
* @license CECILL v2 <http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt>
* @version $Id$
* @copyright 2009
*/
abstract class JRestService {
 
public $config;
protected $bdd;
protected $log = array();
protected $messages = array();
protected $debug = array();
protected $distinct = false;
protected $orderby = null;
protected $formatRetour = 'objet';
protected $start = 0;
protected $limit = 150;
 
public function __construct($config, $demarrer_session = true) {
// Tableau contenant la config de Jrest
$this->config = $config;
 
// Connection à la base de données
$this->bdd = $this->connecterPDO($this->config, 'appli');
 
// Nettoyage du $_GET (sécurité)
if (isset($_GET)) {
$get_params = array('orderby', 'distinct', 'start', 'limit', 'formatRetour');
foreach ($get_params as $get) {
$verifier = array('NULL', "\n", "\r", "\\", "'", '"', "\x00", "\x1a", ';');
$_GET[$get] = str_replace($verifier, '', $_GET[$get]);
if (isset($_GET[$get]) && $_GET[$get] != '') {
$this->$get = $_GET[$get];
} else {
$_GET[$get] = null;
}
}
}
}
 
/**
* Méthode appelée quand aucun paramètre n'est passé dans l'url et avec une requête de type GET.
*/
public function getRessource() {
$this->getElement(array());
}
 
protected function envoyer($donnees = null, $mime = 'text/html', $encodage = 'utf-8', $json = true) {
// Traitements des messages d'erreurs et données
if (count($this->messages) != 0) {
header('HTTP/1.1 500 Internal Server Error');
$mime = 'text/html';
$encodage = 'utf-8';
$json = true;
$sortie = $this->messages;
} else {
$sortie = $donnees;
if (is_null($donnees)) {
$sortie = 'OK';
}
}
 
// Gestion de l'envoie du déboguage
$this->envoyerDebogage();
 
// Encodage au format et JSON et envoie sur la sortie standard
$contenu = $json ? json_encode($sortie) : $sortie;
$this->envoyerContenu($encodage, $mime, $contenu);
}
 
protected function envoyerDebogage() {
if (!is_array($this->debug)) {
$this->debug[] = $this->debug;
}
if (count($this->debug) != 0) {
foreach ($this->debug as $cle => $val) {
if (is_array($val)) {
$this->debug[$cle] = print_r($val, true);
}
}
header('X-DebugJrest-Data:'.json_encode($this->debug));
}
}
 
protected function envoyerContenu($encodage, $mime, $contenu) {
header("Content-Type: $mime; charset=$encodage");
print $contenu;
}
 
private function connecterPDO($config, $base = 'database') {
$cfg = $config[$base];
$dsn = $cfg['phptype'].':dbname='.$cfg['database'].';host='.$cfg['hostspec'];
try {
$PDO = new PDO($dsn, $cfg['username'], $cfg['password']);
} catch (PDOException $e) {
echo 'La connexion à la base de donnée via PDO a échouée : ' . $e->getMessage();
}
// Passe en UTF-8 la connexion à la BDD
$PDO->exec("SET NAMES 'utf8'");
// Affiche les erreurs détectées par PDO (sinon mode silencieux => aucune erreur affiché)
$PDO->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
return $PDO;
}
 
protected function getTxt($id) {
$sortie = '';
switch ($id) {
case 'sql_erreur' : $sortie = 'Requête echec. Fichier : "%s". Ligne : "%s". Message : %s'; break;
default : $sortie = $id;
}
return $sortie;
}
 
protected function traiterParametresUrl($params_attendu, $params, $pourBDD = true) {
$sortie = array();
foreach ($params_attendu as $num => $nom) {
if (isset($params[$num]) && $params[$num] != '*') {
if ($pourBDD) {
$params[$num] = $this->bdd->quote($params[$num]);
}
$sortie[$nom] = $params[$num];
}
}
return $sortie;
}
 
protected function traiterParametresPost($params) {
$sortie = array();
foreach ($params as $cle => $valeur) {
$sortie[$cle] = $this->bdd->quote($valeur);
}
return $sortie;
}
 
protected function getIdentification(&$params) {
// Initialisation des variables
$utilisateur = array(0, session_id());
 
// L'id utilisateur est soit passé par le POST soit dans l'url
if (is_array($params) && isset($params['cmhl_ce_modifier_par'])) {
$utilisateur[0] = $params['cmhl_ce_modifier_par'];
unset($params['cmhl_ce_modifier_par']);
} else if (is_string($params)) {
$utilisateur[0] = $params;
}
 
return $utilisateur;
}
 
protected function etreAutorise($id_utilisateur) {
$autorisation = false;
if (($_SESSION['coel_utilisateur'] != '') && $_SESSION['coel_utilisateur']['id'] != $id_utilisateur) {
$this->messages[] = 'Accès interdit.';
} else if ($_SESSION['coel_utilisateur'] == '') {
$this->messages[] = 'Veuillez vous identifiez pour accéder à cette fonction.';
} else {
$autorisation = true;
}
return $autorisation;
}
 
private function gererIdentificationPermanente() {
// Pour maintenir l'utilisateur tjrs réellement identifié nous sommes obligé de recréer une SESSION et de le recharger depuis la bdd
if ($this->getUtilisateur() == ''
&& isset($_COOKIE['coel_login'])
&& ($utilisateur = $this->chargerUtilisateur($_COOKIE['coel_login'], $_COOKIE['coel_mot_de_passe']))) {
$this->setUtilisateur($utilisateur, $_COOKIE['coel_permanence']);
}
}
 
protected function getUtilisateur() {
return (isset($_SESSION['coel_utilisateur']) ? $_SESSION['coel_utilisateur'] : '');
}
 
/**
* Méthode prenant en paramètre un chemin de fichier squelette et un tableau associatif de données,
* en extrait les variables, charge le squelette et retourne le résultat des deux combinés.
*
* @param String $fichier le chemin du fichier du squelette
* @param Array $donnees un tableau associatif contenant les variables a injecter dans le squelette.
*
* @return boolean false si le squelette n'existe pas, sinon la chaine résultat.
*/
public static function traiterSquelettePhp($fichier, Array $donnees = array()) {
$sortie = false;
if (file_exists($fichier)) {
// Extraction des variables du tableau de données
extract($donnees);
// Démarage de la bufferisation de sortie
ob_start();
// Si les tags courts sont activés
if ((bool) @ini_get('short_open_tag') === true) {
// Simple inclusion du squelette
include $fichier;
} else {
// Sinon, remplacement des tags courts par la syntaxe classique avec echo
$html_et_code_php = self::traiterTagsCourts($fichier);
// Pour évaluer du php mélangé dans du html il est nécessaire de fermer la balise php ouverte par eval
$html_et_code_php = '?>'.$html_et_code_php;
// Interprétation du html et du php dans le buffer
echo eval($html_et_code_php);
}
// Récupèration du contenu du buffer
$sortie = ob_get_contents();
// Suppression du buffer
@ob_end_clean();
} else {
$msg = "Le fichier du squelette '$fichier' n'existe pas.";
trigger_error($msg, E_USER_WARNING);
}
// Retourne le contenu
return $sortie;
}
 
/**
* Fonction chargeant le contenu du squelette et remplaçant les tags court php (<?= ...) par un tag long avec echo.
*
* @param String $chemin_squelette le chemin du fichier du squelette
*
* @return string le contenu du fichier du squelette php avec les tags courts remplacés.
*/
private static function traiterTagsCourts($chemin_squelette) {
$contenu = file_get_contents($chemin_squelette);
// Remplacement de tags courts par un tag long avec echo
$contenu = str_replace('<?=', '<?php echo ', $contenu);
// Ajout systématique d'un point virgule avant la fermeture php
$contenu = preg_replace("/;*\s*\?>/", "; ?>", $contenu);
return $contenu;
}
}
?>
/tags/v3.1-blanche-neige/jrest/services/squelettes/rss1.tpl.xml
New file
0,0 → 1,45
<?php echo '<?xml version="1.0" encoding="UTF-8"?>'."\n";?>
 
<!DOCTYPE rdf:RDF [
<!ENTITY % HTMLlat1 PUBLIC
"-//W3C//ENTITIES Latin 1 for XHTML//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml-lat1.ent">
%HTMLlat1;
]>
 
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns="http://purl.org/rss/1.0/">
 
<channel rdf:about="<?=$guid?>">
<title><?=$titre?></title>
<link><?=$lien_coel?></link>
<description><?=$description?></description>
<dc:publisher><?=$editeur?></dc:publisher>
<dc:date><?=$date_maj_W3C?></dc:date>
<?php if (isset($items)) : ?>
<items>
<rdf:Seq>
<?php foreach ($items as $item) : ?>
<rdf:li resource="<?=$item['guid']?>" />
<?php endforeach; ?>
</rdf:Seq>
</items>
<?php endif; ?>
 
</channel>
<?php if (isset($items)) : ?>
<?php foreach ($items as $item) : ?>
<item rdf:about="<?=$item['guid']?>">
<title><?=$item['titre']?></title>
<link><?=$item['lien']?></link>
<description><?=$item['description_encodee']?></description>
<dc:date><?=$item['date_maj_W3C']?></dc:date>
</item>
<?php endforeach; ?>
<?php endif; ?>
</rdf:RDF>
/tags/v3.1-blanche-neige/jrest/services/squelettes/rss2.tpl.xml
New file
0,0 → 1,22
<?php echo '<?xml version="1.0" encoding="UTF-8"?>'."\n";?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title><?=$titre?></title>
<link><?=$lien_coel?></link>
<atom:link href="<?=$lien_service?>" rel="self" type="application/rss+xml" />
<description><?=$description?></description>
<?php if (isset($items)) : ?>
<?php foreach ($items as $item) : ?>
<item>
<guid><?=$item['guid']?></guid>
<title><?=$item['titre']?></title>
<link><?=$item['lien']?></link>
<description><?=$item['description_encodee']?></description>
<pubDate><?=$item['date_maj_RSS']?></pubDate>
</item>
<?php endforeach; ?>
<?php endif; ?>
</channel>
</rss>
/tags/v3.1-blanche-neige/jrest/services/squelettes/diff.tpl.html
New file
0,0 → 1,36
<table style="border:1px solid black;border-collapse:collapse;" summary="Différences entre les données du <?=$date_ancienne?> et du <?=$date_nouvelle?>.">
<caption style="text-align:left;font-weight:bold;">Différences</caption>
<thead style="border:1px solid black;">
<tr>
<th rowspan="2" style="border:1px dotted;">Champ</th>
<th rowspan="2" style="border:1px dotted;">Type</th>
<th <?=(($etat == 'M') ? 'colspan="2"' : '');?> style="border:1px dotted;">Valeur</th>
</tr>
<tr>
<?php if ($etat == 'M') : ?>
<th style="border:1px dotted;">Ancienne (<?=$date_ancienne?>)</th>
<?php endif; ?>
<th style="border:1px dotted;">Nouvelle (<?=$date_nouvelle?>)</th>
</tr>
</thead>
<tbody>
<?php foreach ($differences as $champ => $diff) : ?>
<?php if ($diff['type'] == 'A') :
$couleur = CFC;
elseif ($diff['type'] == 'M') :
$couleur = FFC;
elseif ($diff['type'] == 'S') :
$couleur = F99;
endif; ?>
<tr style="background-color:#<?=$couleur?>;">
<td style="border:1px dotted;"><?=$champ?></td>
<td style="text-align:center;border:1px dotted;"><?=$diff['type_txt']?></td>
<?php if ($etat == 'M') : ?>
<td style="border:1px dotted;"><?=$diff['ancien']?></td>
<?php endif; ?>
<td style="border:1px dotted;"><?=$diff['nouveau']?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
/tags/v3.1-blanche-neige/jrest/services/squelettes/atom.tpl.xml
New file
0,0 → 1,33
<?php echo '<?xml version="1.0" encoding="UTF-8"?>'."\n";?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title><?=$titre?></title>
<link href="<?=$lien_coel?>" rel="alternate" type="text/html" hreflang="fr" />
<link href="<?=$lien_service?>" rel="self" type="application/atom+xml"/>
<updated><?=$date_maj_ATOM?></updated>
<author>
<name><?=$editeur?></name>
</author>
<id><?=$guid?></id>
<rights>Copyright (c) <?=$annee_courante?>, <?=$editeur?></rights>
<generator uri="<?=$lien_coel?>" version="<?=$generateur_version?>"><?=$generateur?></generator>
 
<?php if (isset($items)) : ?>
<?php foreach ($items as $item) : ?>
<entry>
<id><?=$item['lien']?></id>
<title><?=$item['titre']?></title>
<link href="<?=$item['lien']?>"/>
<updated><?=$item['date_maj_ATOM']?></updated>
<author><name><?=$item['modifier_par']?></name></author>
<content type="xhtml" xml:lang="fr">
<div xmlns="http://www.w3.org/1999/xhtml">
<?=$item['description'];?>
</div>
</content>
</entry>
<?php endforeach; ?>
<?php endif; ?>
 
</feed>
/tags/v3.1-blanche-neige/jrest/services/.directory
New file
0,0 → 1,5
[Dolphin]
Timestamp=2010,5,25,17,11,22
 
[Settings]
ShowDotFiles=true
/tags/v3.1-blanche-neige/jrest/lib/DBAccessor.php
New file
0,0 → 1,34
<?php
require_once 'JrestService.php';
 
class DBAccessor extends JrestService {
public function connectDB($config, $base = 'database') {
require_once 'DB.php';
$dsn = $config[$base];
 
$DB =& DB::connect($dsn);
if (DB::isError($DB)) {
die($DB->getMessage());
}
$DB->query("SET NAMES 'utf8'");
return $DB;
}
public function connecterPDO($config, $base = 'database') {
$cfg = $config[$base];
$dsn = $cfg['phptype'].':dbname='.$cfg['database'].';host='.$cfg['hostspec'];
try {
$PDO = new PDO($dsn, $cfg['username'], $cfg['password']);
} catch (PDOException $e) {
echo 'La connexion à la base de donnée via PDO a échouée : ' . $e->getMessage();
}
// Passe en UTF-8 la connexion à la BDD
$PDO->exec("SET NAMES 'utf8'");
// Affiche les erreurs détectées par PDO (sinon mode silencieux => aucune erreur affiché)
$PDO->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
return $PDO;
}
}
?>
/tags/v3.1-blanche-neige/jrest/lib/JrestService.php
New file
0,0 → 1,72
<?php
/**
* PHP Version 5
*
* @category PHP
* @package jrest
* @author aurelien <aurelien@tela-botanica.org>
* @copyright 2009 Tela-Botanica
* @license http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL
* @version $$id$$
* @link /doc/jrest/
*/
 
class JrestService {
 
protected $config;
protected $script_time;
protected $max_exec_time;
 
public function JrestService($config) {
$this->config = config;
$this->script_time = microtime(true);
$this->max_exec_time = ini_get('max_execution_time');
}
 
public function isAdmin($id) {
$admins = $this->config['jrest_admin']['admin'];
$admin_tab = split(',',$admins);
 
if (in_array($id,$admin_tab)) {
return true;
} else {
return false;
}
}
 
public function controleUtilisateur($id) {
if ($_SESSION['user']['name'] == '') {
//cas de la session temporaire, on ne fait rien de particulier
} else {
if (!$this->isAdmin($_SESSION['user']['name']) && $_SESSION['user']['name'] != $id) {
// cas d'usurpation d'identité
print 'Accès interdit';
exit();
}
}
}
 
public function logger($index,$chaine) {
if(!class_exists('Log')) {
include_once('Log.php');
Log::getInstance();
}
 
Log::setCheminLog($this->config['log']['cheminlog']);
Log::setTimeZone($this->config['log']['timezone']);
Log::setTailleMax($this->config['log']['taillemax']);
 
Log::ajouterEntree($index,$chaine);
}
 
public function verifierOuRelancerExecution() {
 
if((microtime(true) - $this->script_time) > ($this->max_exec_time - 5)*100) {
set_time_limit(2);
$this->logger('JRestService','Durée du script augmentée :'.microtime(true).' - '.$this->script_time.'.) > ('.$this->max_exec_time.' - 5)*1000000');
return true;
}
return false;
}
}
?>
/tags/v3.1-blanche-neige/jrest/lib/JSON.php
New file
0,0 → 1,806
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
 
/**
* Converts to and from JSON format.
*
* JSON (JavaScript Object Notation) is a lightweight data-interchange
* format. It is easy for humans to read and write. It is easy for machines
* to parse and generate. It is based on a subset of the JavaScript
* Programming Language, Standard ECMA-262 3rd Edition - December 1999.
* This feature can also be found in Python. JSON is a text format that is
* completely language independent but uses conventions that are familiar
* to programmers of the C-family of languages, including C, C++, C#, Java,
* JavaScript, Perl, TCL, and many others. These properties make JSON an
* ideal data-interchange language.
*
* This package provides a simple encoder and decoder for JSON notation. It
* is intended for use with client-side Javascript applications that make
* use of HTTPRequest to perform server communication functions - data can
* be encoded into JSON notation for use in a client-side javascript, or
* decoded from incoming Javascript requests. JSON format is native to
* Javascript, and can be directly eval()'ed with no further parsing
* overhead
*
* All strings should be in ASCII or UTF-8 format!
*
* LICENSE: Redistribution and use in source and binary forms, with or
* without modification, are permitted provided that the following
* conditions are met: Redistributions of source code must retain the
* above copyright notice, this list of conditions and the following
* disclaimer. Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
* NO EVENT SHALL CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGE.
*
* @category
* @package Services_JSON
* @author Michal Migurski <mike-json@teczno.com>
* @author Matt Knapp <mdknapp[at]gmail[dot]com>
* @author Brett Stimmerman <brettstimmerman[at]gmail[dot]com>
* @copyright 2005 Michal Migurski
* @version CVS: $Id$
* @license http://www.opensource.org/licenses/bsd-license.php
* @link http://pear.php.net/pepr/pepr-proposal-show.php?id=198
*/
 
/**
* Marker constant for Services_JSON::decode(), used to flag stack state
*/
define('SERVICES_JSON_SLICE', 1);
 
/**
* Marker constant for Services_JSON::decode(), used to flag stack state
*/
define('SERVICES_JSON_IN_STR', 2);
 
/**
* Marker constant for Services_JSON::decode(), used to flag stack state
*/
define('SERVICES_JSON_IN_ARR', 3);
 
/**
* Marker constant for Services_JSON::decode(), used to flag stack state
*/
define('SERVICES_JSON_IN_OBJ', 4);
 
/**
* Marker constant for Services_JSON::decode(), used to flag stack state
*/
define('SERVICES_JSON_IN_CMT', 5);
 
/**
* Behavior switch for Services_JSON::decode()
*/
define('SERVICES_JSON_LOOSE_TYPE', 16);
 
/**
* Behavior switch for Services_JSON::decode()
*/
define('SERVICES_JSON_SUPPRESS_ERRORS', 32);
 
/**
* Converts to and from JSON format.
*
* Brief example of use:
*
* <code>
* // create a new instance of Services_JSON
* $json = new Services_JSON();
*
* // convert a complexe value to JSON notation, and send it to the browser
* $value = array('foo', 'bar', array(1, 2, 'baz'), array(3, array(4)));
* $output = $json->encode($value);
*
* print($output);
* // prints: ["foo","bar",[1,2,"baz"],[3,[4]]]
*
* // accept incoming POST data, assumed to be in JSON notation
* $input = file_get_contents('php://input', 1000000);
* $value = $json->decode($input);
* </code>
*/
class Services_JSON
{
/**
* constructs a new JSON instance
*
* @param int $use object behavior flags; combine with boolean-OR
*
* possible values:
* - SERVICES_JSON_LOOSE_TYPE: loose typing.
* "{...}" syntax creates associative arrays
* instead of objects in decode().
* - SERVICES_JSON_SUPPRESS_ERRORS: error suppression.
* Values which can't be encoded (e.g. resources)
* appear as NULL instead of throwing errors.
* By default, a deeply-nested resource will
* bubble up with an error, so all return values
* from encode() should be checked with isError()
*/
function Services_JSON($use = 0)
{
$this->use = $use;
}
 
/**
* convert a string from one UTF-16 char to one UTF-8 char
*
* Normally should be handled by mb_convert_encoding, but
* provides a slower PHP-only method for installations
* that lack the multibye string extension.
*
* @param string $utf16 UTF-16 character
* @return string UTF-8 character
* @access private
*/
function utf162utf8($utf16)
{
// oh please oh please oh please oh please oh please
if(function_exists('mb_convert_encoding')) {
return mb_convert_encoding($utf16, 'UTF-8', 'UTF-16');
}
 
$bytes = (ord($utf16{0}) << 8) | ord($utf16{1});
 
switch(true) {
case ((0x7F & $bytes) == $bytes):
// this case should never be reached, because we are in ASCII range
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
return chr(0x7F & $bytes);
 
case (0x07FF & $bytes) == $bytes:
// return a 2-byte UTF-8 character
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
return chr(0xC0 | (($bytes >> 6) & 0x1F))
. chr(0x80 | ($bytes & 0x3F));
 
case (0xFFFF & $bytes) == $bytes:
// return a 3-byte UTF-8 character
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
return chr(0xE0 | (($bytes >> 12) & 0x0F))
. chr(0x80 | (($bytes >> 6) & 0x3F))
. chr(0x80 | ($bytes & 0x3F));
}
 
// ignoring UTF-32 for now, sorry
return '';
}
 
/**
* convert a string from one UTF-8 char to one UTF-16 char
*
* Normally should be handled by mb_convert_encoding, but
* provides a slower PHP-only method for installations
* that lack the multibye string extension.
*
* @param string $utf8 UTF-8 character
* @return string UTF-16 character
* @access private
*/
function utf82utf16($utf8)
{
// oh please oh please oh please oh please oh please
if(function_exists('mb_convert_encoding')) {
return mb_convert_encoding($utf8, 'UTF-16', 'UTF-8');
}
 
switch(strlen($utf8)) {
case 1:
// this case should never be reached, because we are in ASCII range
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
return $utf8;
 
case 2:
// return a UTF-16 character from a 2-byte UTF-8 char
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
return chr(0x07 & (ord($utf8{0}) >> 2))
. chr((0xC0 & (ord($utf8{0}) << 6))
| (0x3F & ord($utf8{1})));
 
case 3:
// return a UTF-16 character from a 3-byte UTF-8 char
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
return chr((0xF0 & (ord($utf8{0}) << 4))
| (0x0F & (ord($utf8{1}) >> 2)))
. chr((0xC0 & (ord($utf8{1}) << 6))
| (0x7F & ord($utf8{2})));
}
 
// ignoring UTF-32 for now, sorry
return '';
}
 
/**
* encodes an arbitrary variable into JSON format
*
* @param mixed $var any number, boolean, string, array, or object to be encoded.
* see argument 1 to Services_JSON() above for array-parsing behavior.
* if var is a strng, note that encode() always expects it
* to be in ASCII or UTF-8 format!
*
* @return mixed JSON string representation of input var or an error if a problem occurs
* @access public
*/
function encode($var)
{
switch (gettype($var)) {
case 'boolean':
return $var ? 'true' : 'false';
 
case 'NULL':
return 'null';
 
case 'integer':
return (int) $var;
 
case 'double':
case 'float':
return (float) $var;
 
case 'string':
// STRINGS ARE EXPECTED TO BE IN ASCII OR UTF-8 FORMAT
$ascii = '';
$strlen_var = strlen($var);
 
/*
* Iterate over every character in the string,
* escaping with a slash or encoding to UTF-8 where necessary
*/
for ($c = 0; $c < $strlen_var; ++$c) {
 
$ord_var_c = ord($var{$c});
 
switch (true) {
case $ord_var_c == 0x08:
$ascii .= '\b';
break;
case $ord_var_c == 0x09:
$ascii .= '\t';
break;
case $ord_var_c == 0x0A:
$ascii .= '\n';
break;
case $ord_var_c == 0x0C:
$ascii .= '\f';
break;
case $ord_var_c == 0x0D:
$ascii .= '\r';
break;
 
case $ord_var_c == 0x22:
case $ord_var_c == 0x2F:
case $ord_var_c == 0x5C:
// double quote, slash, slosh
$ascii .= '\\'.$var{$c};
break;
 
case (($ord_var_c >= 0x20) && ($ord_var_c <= 0x7F)):
// characters U-00000000 - U-0000007F (same as ASCII)
$ascii .= $var{$c};
break;
 
case (($ord_var_c & 0xE0) == 0xC0):
// characters U-00000080 - U-000007FF, mask 110XXXXX
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
$char = pack('C*', $ord_var_c, ord($var{$c + 1}));
$c += 1;
$utf16 = $this->utf82utf16($char);
$ascii .= sprintf('\u%04s', bin2hex($utf16));
break;
 
case (($ord_var_c & 0xF0) == 0xE0):
// characters U-00000800 - U-0000FFFF, mask 1110XXXX
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
$char = pack('C*', $ord_var_c,
ord($var{$c + 1}),
ord($var{$c + 2}));
$c += 2;
$utf16 = $this->utf82utf16($char);
$ascii .= sprintf('\u%04s', bin2hex($utf16));
break;
 
case (($ord_var_c & 0xF8) == 0xF0):
// characters U-00010000 - U-001FFFFF, mask 11110XXX
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
$char = pack('C*', $ord_var_c,
ord($var{$c + 1}),
ord($var{$c + 2}),
ord($var{$c + 3}));
$c += 3;
$utf16 = $this->utf82utf16($char);
$ascii .= sprintf('\u%04s', bin2hex($utf16));
break;
 
case (($ord_var_c & 0xFC) == 0xF8):
// characters U-00200000 - U-03FFFFFF, mask 111110XX
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
$char = pack('C*', $ord_var_c,
ord($var{$c + 1}),
ord($var{$c + 2}),
ord($var{$c + 3}),
ord($var{$c + 4}));
$c += 4;
$utf16 = $this->utf82utf16($char);
$ascii .= sprintf('\u%04s', bin2hex($utf16));
break;
 
case (($ord_var_c & 0xFE) == 0xFC):
// characters U-04000000 - U-7FFFFFFF, mask 1111110X
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
$char = pack('C*', $ord_var_c,
ord($var{$c + 1}),
ord($var{$c + 2}),
ord($var{$c + 3}),
ord($var{$c + 4}),
ord($var{$c + 5}));
$c += 5;
$utf16 = $this->utf82utf16($char);
$ascii .= sprintf('\u%04s', bin2hex($utf16));
break;
}
}
 
return '"'.$ascii.'"';
 
case 'array':
/*
* As per JSON spec if any array key is not an integer
* we must treat the the whole array as an object. We
* also try to catch a sparsely populated associative
* array with numeric keys here because some JS engines
* will create an array with empty indexes up to
* max_index which can cause memory issues and because
* the keys, which may be relevant, will be remapped
* otherwise.
*
* As per the ECMA and JSON specification an object may
* have any string as a property. Unfortunately due to
* a hole in the ECMA specification if the key is a
* ECMA reserved word or starts with a digit the
* parameter is only accessible using ECMAScript's
* bracket notation.
*/
 
// treat as a JSON object
if (is_array($var) && count($var) && (array_keys($var) !== range(0, sizeof($var) - 1))) {
$properties = array_map(array($this, 'name_value'),
array_keys($var),
array_values($var));
 
foreach($properties as $property) {
if(Services_JSON::isError($property)) {
return $property;
}
}
 
return '{' . join(',', $properties) . '}';
}
 
// treat it like a regular array
$elements = array_map(array($this, 'encode'), $var);
 
foreach($elements as $element) {
if(Services_JSON::isError($element)) {
return $element;
}
}
 
return '[' . join(',', $elements) . ']';
 
case 'object':
$vars = get_object_vars($var);
 
$properties = array_map(array($this, 'name_value'),
array_keys($vars),
array_values($vars));
 
foreach($properties as $property) {
if(Services_JSON::isError($property)) {
return $property;
}
}
 
return '{' . join(',', $properties) . '}';
 
default:
return ($this->use & SERVICES_JSON_SUPPRESS_ERRORS)
? 'null'
: new Services_JSON_Error(gettype($var)." can not be encoded as JSON string");
}
}
 
/**
* array-walking function for use in generating JSON-formatted name-value pairs
*
* @param string $name name of key to use
* @param mixed $value reference to an array element to be encoded
*
* @return string JSON-formatted name-value pair, like '"name":value'
* @access private
*/
function name_value($name, $value)
{
$encoded_value = $this->encode($value);
 
if(Services_JSON::isError($encoded_value)) {
return $encoded_value;
}
 
return $this->encode(strval($name)) . ':' . $encoded_value;
}
 
/**
* reduce a string by removing leading and trailing comments and whitespace
*
* @param $str string string value to strip of comments and whitespace
*
* @return string string value stripped of comments and whitespace
* @access private
*/
function reduce_string($str)
{
$str = preg_replace(array(
 
// eliminate single line comments in '// ...' form
'#^\s*//(.+)$#m',
 
// eliminate multi-line comments in '/* ... */' form, at start of string
'#^\s*/\*(.+)\*/#Us',
 
// eliminate multi-line comments in '/* ... */' form, at end of string
'#/\*(.+)\*/\s*$#Us'
 
), '', $str);
 
// eliminate extraneous space
return trim($str);
}
 
/**
* decodes a JSON string into appropriate variable
*
* @param string $str JSON-formatted string
*
* @return mixed number, boolean, string, array, or object
* corresponding to given JSON input string.
* See argument 1 to Services_JSON() above for object-output behavior.
* Note that decode() always returns strings
* in ASCII or UTF-8 format!
* @access public
*/
function decode($str)
{
$str = $this->reduce_string($str);
 
switch (strtolower($str)) {
case 'true':
return true;
 
case 'false':
return false;
 
case 'null':
return null;
 
default:
$m = array();
 
if (is_numeric($str)) {
// Lookie-loo, it's a number
 
// This would work on its own, but I'm trying to be
// good about returning integers where appropriate:
// return (float)$str;
 
// Return float or int, as appropriate
return ((float)$str == (integer)$str)
? (integer)$str
: (float)$str;
 
} elseif (preg_match('/^("|\').*(\1)$/s', $str, $m) && $m[1] == $m[2]) {
// STRINGS RETURNED IN UTF-8 FORMAT
$delim = substr($str, 0, 1);
$chrs = substr($str, 1, -1);
$utf8 = '';
$strlen_chrs = strlen($chrs);
 
for ($c = 0; $c < $strlen_chrs; ++$c) {
 
$substr_chrs_c_2 = substr($chrs, $c, 2);
$ord_chrs_c = ord($chrs{$c});
 
switch (true) {
case $substr_chrs_c_2 == '\b':
$utf8 .= chr(0x08);
++$c;
break;
case $substr_chrs_c_2 == '\t':
$utf8 .= chr(0x09);
++$c;
break;
case $substr_chrs_c_2 == '\n':
$utf8 .= chr(0x0A);
++$c;
break;
case $substr_chrs_c_2 == '\f':
$utf8 .= chr(0x0C);
++$c;
break;
case $substr_chrs_c_2 == '\r':
$utf8 .= chr(0x0D);
++$c;
break;
 
case $substr_chrs_c_2 == '\\"':
case $substr_chrs_c_2 == '\\\'':
case $substr_chrs_c_2 == '\\\\':
case $substr_chrs_c_2 == '\\/':
if (($delim == '"' && $substr_chrs_c_2 != '\\\'') ||
($delim == "'" && $substr_chrs_c_2 != '\\"')) {
$utf8 .= $chrs{++$c};
}
break;
 
case preg_match('/\\\u[0-9A-F]{4}/i', substr($chrs, $c, 6)):
// single, escaped unicode character
$utf16 = chr(hexdec(substr($chrs, ($c + 2), 2)))
. chr(hexdec(substr($chrs, ($c + 4), 2)));
$utf8 .= $this->utf162utf8($utf16);
$c += 5;
break;
 
case ($ord_chrs_c >= 0x20) && ($ord_chrs_c <= 0x7F):
$utf8 .= $chrs{$c};
break;
 
case ($ord_chrs_c & 0xE0) == 0xC0:
// characters U-00000080 - U-000007FF, mask 110XXXXX
//see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
$utf8 .= substr($chrs, $c, 2);
++$c;
break;
 
case ($ord_chrs_c & 0xF0) == 0xE0:
// characters U-00000800 - U-0000FFFF, mask 1110XXXX
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
$utf8 .= substr($chrs, $c, 3);
$c += 2;
break;
 
case ($ord_chrs_c & 0xF8) == 0xF0:
// characters U-00010000 - U-001FFFFF, mask 11110XXX
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
$utf8 .= substr($chrs, $c, 4);
$c += 3;
break;
 
case ($ord_chrs_c & 0xFC) == 0xF8:
// characters U-00200000 - U-03FFFFFF, mask 111110XX
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
$utf8 .= substr($chrs, $c, 5);
$c += 4;
break;
 
case ($ord_chrs_c & 0xFE) == 0xFC:
// characters U-04000000 - U-7FFFFFFF, mask 1111110X
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
$utf8 .= substr($chrs, $c, 6);
$c += 5;
break;
 
}
 
}
 
return $utf8;
 
} elseif (preg_match('/^\[.*\]$/s', $str) || preg_match('/^\{.*\}$/s', $str)) {
// array, or object notation
 
if ($str{0} == '[') {
$stk = array(SERVICES_JSON_IN_ARR);
$arr = array();
} else {
if ($this->use & SERVICES_JSON_LOOSE_TYPE) {
$stk = array(SERVICES_JSON_IN_OBJ);
$obj = array();
} else {
$stk = array(SERVICES_JSON_IN_OBJ);
$obj = new stdClass();
}
}
 
array_push($stk, array('what' => SERVICES_JSON_SLICE,
'where' => 0,
'delim' => false));
 
$chrs = substr($str, 1, -1);
$chrs = $this->reduce_string($chrs);
 
if ($chrs == '') {
if (reset($stk) == SERVICES_JSON_IN_ARR) {
return $arr;
 
} else {
return $obj;
 
}
}
 
//print("\nparsing {$chrs}\n");
 
$strlen_chrs = strlen($chrs);
 
for ($c = 0; $c <= $strlen_chrs; ++$c) {
 
$top = end($stk);
$substr_chrs_c_2 = substr($chrs, $c, 2);
 
if (($c == $strlen_chrs) || (($chrs{$c} == ',') && ($top['what'] == SERVICES_JSON_SLICE))) {
// found a comma that is not inside a string, array, etc.,
// OR we've reached the end of the character list
$slice = substr($chrs, $top['where'], ($c - $top['where']));
array_push($stk, array('what' => SERVICES_JSON_SLICE, 'where' => ($c + 1), 'delim' => false));
//print("Found split at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
 
if (reset($stk) == SERVICES_JSON_IN_ARR) {
// we are in an array, so just push an element onto the stack
array_push($arr, $this->decode($slice));
 
} elseif (reset($stk) == SERVICES_JSON_IN_OBJ) {
// we are in an object, so figure
// out the property name and set an
// element in an associative array,
// for now
$parts = array();
if (preg_match('/^\s*(["\'].*[^\\\]["\'])\s*:\s*(\S.*),?$/Uis', $slice, $parts)) {
// "name":value pair
$key = $this->decode($parts[1]);
$val = $this->decode($parts[2]);
 
if ($this->use & SERVICES_JSON_LOOSE_TYPE) {
$obj[$key] = $val;
} else {
$obj->$key = $val;
}
} elseif (preg_match('/^\s*(\w+)\s*:\s*(\S.*),?$/Uis', $slice, $parts)) {
// name:value pair, where name is unquoted
$key = $parts[1];
$val = $this->decode($parts[2]);
 
if ($this->use & SERVICES_JSON_LOOSE_TYPE) {
$obj[$key] = $val;
} else {
$obj->$key = $val;
}
}
 
}
 
} elseif ((($chrs{$c} == '"') || ($chrs{$c} == "'")) && ($top['what'] != SERVICES_JSON_IN_STR)) {
// found a quote, and we are not inside a string
array_push($stk, array('what' => SERVICES_JSON_IN_STR, 'where' => $c, 'delim' => $chrs{$c}));
//print("Found start of string at {$c}\n");
 
} elseif (($chrs{$c} == $top['delim']) &&
($top['what'] == SERVICES_JSON_IN_STR) &&
((strlen(substr($chrs, 0, $c)) - strlen(rtrim(substr($chrs, 0, $c), '\\'))) % 2 != 1)) {
// found a quote, we're in a string, and it's not escaped
// we know that it's not escaped becase there is _not_ an
// odd number of backslashes at the end of the string so far
array_pop($stk);
//print("Found end of string at {$c}: ".substr($chrs, $top['where'], (1 + 1 + $c - $top['where']))."\n");
 
} elseif (($chrs{$c} == '[') &&
in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) {
// found a left-bracket, and we are in an array, object, or slice
array_push($stk, array('what' => SERVICES_JSON_IN_ARR, 'where' => $c, 'delim' => false));
//print("Found start of array at {$c}\n");
 
} elseif (($chrs{$c} == ']') && ($top['what'] == SERVICES_JSON_IN_ARR)) {
// found a right-bracket, and we're in an array
array_pop($stk);
//print("Found end of array at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
 
} elseif (($chrs{$c} == '{') &&
in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) {
// found a left-brace, and we are in an array, object, or slice
array_push($stk, array('what' => SERVICES_JSON_IN_OBJ, 'where' => $c, 'delim' => false));
//print("Found start of object at {$c}\n");
 
} elseif (($chrs{$c} == '}') && ($top['what'] == SERVICES_JSON_IN_OBJ)) {
// found a right-brace, and we're in an object
array_pop($stk);
//print("Found end of object at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
 
} elseif (($substr_chrs_c_2 == '/*') &&
in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) {
// found a comment start, and we are in an array, object, or slice
array_push($stk, array('what' => SERVICES_JSON_IN_CMT, 'where' => $c, 'delim' => false));
$c++;
//print("Found start of comment at {$c}\n");
 
} elseif (($substr_chrs_c_2 == '*/') && ($top['what'] == SERVICES_JSON_IN_CMT)) {
// found a comment end, and we're in one now
array_pop($stk);
$c++;
 
for ($i = $top['where']; $i <= $c; ++$i)
$chrs = substr_replace($chrs, ' ', $i, 1);
 
//print("Found end of comment at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
 
}
 
}
 
if (reset($stk) == SERVICES_JSON_IN_ARR) {
return $arr;
 
} elseif (reset($stk) == SERVICES_JSON_IN_OBJ) {
return $obj;
 
}
 
}
}
}
 
/**
* @todo Ultimately, this should just call PEAR::isError()
*/
function isError($data, $code = null)
{
if (class_exists('pear')) {
return PEAR::isError($data, $code);
} elseif (is_object($data) && (get_class($data) == 'services_json_error' ||
is_subclass_of($data, 'services_json_error'))) {
return true;
}
 
return false;
}
}
 
if (class_exists('PEAR_Error')) {
 
class Services_JSON_Error extends PEAR_Error
{
function Services_JSON_Error($message = 'unknown error', $code = null,
$mode = null, $options = null, $userinfo = null)
{
parent::PEAR_Error($message, $code, $mode, $options, $userinfo);
}
}
 
} else {
 
/**
* @todo Ultimately, this class shall be descended from PEAR_Error
*/
class Services_JSON_Error
{
function Services_JSON_Error($message = 'unknown error', $code = null,
$mode = null, $options = null, $userinfo = null)
{
 
}
}
 
}
?>
/tags/v3.1-blanche-neige/jrest/lib/PDF.php
New file
0,0 → 1,3001
<?php
/**
* File_PDF::
*
* The File_PDF:: class provides a PHP-only implementation of a PDF library.
* No external libs or PHP extensions are required.
*
* Based on the FPDF class by Olivier Plathey (http://www.fpdf.org).
*
* Copyright 2001-2003 Olivier Plathey <olivier@fpdf.org>
* Copyright 2003-2007 The Horde Project (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (LGPL). If you
* did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
*
* $Horde: framework/File_PDF/PDF.php,v 1.48 2007/01/05 13:12:21 jan Exp $
*
* @author Olivier Plathey <olivier@fpdf.org>
* @author Marko Djukic <marko@oblo.com>
* @author Jan Schneider <jan@horde.org>
* @package File_PDF
* @category Fileformats
*/
class File_PDF {
 
/**
* Current page number.
*
* @var integer
*/
var $_page = 0;
 
/**
* Current object number.
*
* @var integer
*/
var $_n = 2;
 
/**
* Array of object offsets.
*
* @var array
*/
var $_offsets = array();
 
/**
* Buffer holding in-memory PDF.
*
* @var string
*/
var $_buffer = '';
 
/**
* Array containing the pages.
*
* @var array
*/
var $_pages = array();
 
/**
* Current document state.
* 0 - initial state
* 1 - document opened
* 2 - page opened
* 3 - document closed
*
* @var integer
*/
var $_state = 0;
 
/**
* Flag indicating if PDF file is to be compressed or not.
*
* @var boolean
*/
var $_compress;
 
/**
* The default page orientation.
*
* @var string
*/
var $_default_orientation;
 
/**
* The current page orientation.
*
* @var string
*/
var $_current_orientation;
 
/**
* Array indicating orientation changes.
*
* @var array
*/
var $_orientation_changes = array();
 
/**
* Current width of page format in points.
*
* @var float
*/
var $fwPt;
 
/**
* Current height of page format in points.
*
* @var float
*/
var $fhPt;
 
/**
* Current width of page format in user units.
*
* @var float
*/
var $fw;
 
/**
* Current height of page format in user units.
*
* @var float
*/
var $fh;
 
/**
* Current width of page in points.
*
* @var float
*/
var $wPt;
 
/**
* Current height of page in points.
*
* @var float
*/
var $hPt;
 
/**
* Current width of page in user units
*
* @var float
*/
var $w;
 
/**
* Current height of page in user units
*
* @var float
*/
var $h;
 
/**
* Scale factor (number of points in user units).
*
* @var float
*/
var $_scale;
 
/**
* Left page margin size.
*
* @var float
*/
var $_left_margin;
 
/**
* Top page margin size.
*
* @var float
*/
var $_top_margin;
 
/**
* Right page margin size.
*
* @var float
*/
var $_right_margin;
 
/**
* Break page margin size, the bottom margin which triggers a page break.
*
* @var float
*/
var $_break_margin;
 
/**
* Cell margin size.
*
* @var float
*/
var $_cell_margin;
 
/**
* The current horizontal position for cell positioning.
* Value is set in user units and is calculated from the top left corner
* as origin.
*
* @var float
*/
var $x;
 
/**
* The current vertical position for cell positioning.
* Value is set in user units and is calculated from the top left corner
* as origin.
*
* @var float
*/
var $y;
 
/**
* The height of the last cell printed.
*
* @var float
*/
var $_last_height;
 
/**
* Line width in user units.
*
* @var float
*/
var $_line_width;
 
/**
* An array of standard font names.
*
* @var array
*/
var $_core_fonts = array('courier' => 'Courier',
'courierB' => 'Courier-Bold',
'courierI' => 'Courier-Oblique',
'courierBI' => 'Courier-BoldOblique',
'helvetica' => 'Helvetica',
'helveticaB' => 'Helvetica-Bold',
'helveticaI' => 'Helvetica-Oblique',
'helveticaBI' => 'Helvetica-BoldOblique',
'times' => 'Times-Roman',
'timesB' => 'Times-Bold',
'timesI' => 'Times-Italic',
'timesBI' => 'Times-BoldItalic',
'symbol' => 'Symbol',
'zapfdingbats' => 'ZapfDingbats');
 
/**
* An array of used fonts.
*
* @var array
*/
var $_fonts = array();
 
/**
* An array of font files.
*
* @var array
*/
var $_font_files = array();
 
/**
* An array of encoding differences.
*
* @var array
*/
var $_diffs = array();
 
/**
* An array of used images.
*
* @var array
*/
var $_images = array();
 
/**
* An array of links in pages.
*
* @var array
*/
var $_page_links;
 
/**
* An array of internal links.
*
* @var array
*/
var $_links = array();
 
/**
* Current font family.
*
* @var string
*/
var $_font_family = '';
 
/**
* Current font style.
*
* @var string
*/
var $_font_style = '';
 
/**
* Underlining flag.
*
* @var boolean
*/
var $_underline = false;
 
/**
* An array containing current font info.
*
* @var array
*/
var $_current_font;
 
/**
* Current font size in points.
*
* @var float
*/
var $_font_size_pt = 12;
 
/**
* Current font size in user units.
*
* @var float
*/
var $_font_size;
 
/**
* Commands for filling color.
*
* @var string
*/
var $_fill_color = '0 g';
 
/**
* Commands for text color.
*
* @var string
*/
var $_text_color = '0 g';
 
/**
* Whether text color is different from fill color.
*
* @var boolean
*/
var $_color_flag = false;
 
/**
* Commands for drawing color.
*
* @var string
*/
var $_draw_color = '0 G';
 
/**
* Word spacing.
*
* @var integer
*/
var $_word_spacing = 0;
 
/**
* Automatic page breaking.
*
* @var boolean
*/
var $_auto_page_break;
 
/**
* Threshold used to trigger page breaks.
*
* @var float
*/
var $_page_break_trigger;
 
/**
* Flag set when processing footer.
*
* @var boolean
*/
var $_in_footer = false;
 
/**
* Zoom display mode.
*
* @var string
*/
var $_zoom_mode;
 
/**
* Layout display mode.
*
* @var string
*/
var $_layout_mode;
 
/**
* An array containing the document info, consisting of:
* - title
* - subject
* - author
* - keywords
* - creator
*
* @var array
*/
var $_info = array();
 
/**
* Alias for total number of pages.
*
* @var string
*/
var $_alias_nb_pages = '{nb}';
 
/**
* Attempts to return a conrete PDF instance. It allows to set up the page
* format, the orientation and the units of measurement used in all the
* methods (except for the font sizes).
*
* Example:<pre>
* $pdf = &File_PDF::factory(array('orientation' => 'P',
* 'unit' => 'mm',
* 'format' => 'A4'));</pre>
*
* @param array $params A hash with parameters for the created PDF object.
* Possible parameters are:
* orientation - Default page orientation. Possible
* values are (case insensitive):
* <pre>
* - P or Portrait (default)
* - L or Landscape
* </pre>
* unit - User measure units. Possible values values
* are:
* <pre>
* - pt: point
* - mm: millimeter (default)
* - cm: centimeter
* - in: inch
* </pre>
* A point equals 1/72 of inch, that is to say about
* 0.35 mm (an inch being 2.54 cm). This is a very
* common unit in typography; font sizes are
* expressed in that unit.
* format - The format used for pages. It can be
* either one of the following values (case
* insensitive):
* <pre>
* - A3
* - A4 (default)
* - A5
* - Letter
* - Legal
* </pre>
* or a custom format in the form of a two-element
* array containing the width and the height
* (expressed in the unit given by the unit
* parameter).
* @param string $class The concrete class name to return an instance of.
* Defaults to File_PDF.
*/
function &factory($params = array(), $class = 'File_PDF')
{
/* Check for PHP locale-related bug. */
if (1.1 == 1) {
$error = File_PDF::raiseError('Do not alter the locale before including the class file.');
return $error;
}
 
/* Default parameters. */
$defaults = array('orientation' => 'P', 'unit' => 'mm', 'format' => 'A4');
 
/* Backward compatibility with old method signature. */
/* Should be removed a few versions later. */
if (!is_array($params)) {
$class = 'File_PDF';
$params = $defaults;
$names = array_keys($defaults);
for ($i = 0; $i < func_num_args(); $i++) {
$params[$names[$i]] = func_get_arg($i);
}
} else {
$params = array_merge($defaults, $params);
}
 
/* Create the PDF object. */
$pdf = &new $class();
 
/* Scale factor. */
if ($params['unit'] == 'pt') {
$pdf->_scale = 1;
} elseif ($params['unit'] == 'mm') {
$pdf->_scale = 72 / 25.4;
} elseif ($params['unit'] == 'cm') {
$pdf->_scale = 72 / 2.54;
} elseif ($params['unit'] == 'in') {
$pdf->_scale = 72;
} else {
$error = File_PDF::raiseError(sprintf('Incorrect units: %s', $params['unit']));
return $error;
}
/* Page format. */
if (is_string($params['format'])) {
$params['format'] = strtolower($params['format']);
if ($params['format'] == 'a3') {
$params['format'] = array(841.89, 1190.55);
} elseif ($params['format'] == 'a4') {
$params['format'] = array(595.28, 841.89);
} elseif ($params['format'] == 'a5') {
$params['format'] = array(420.94, 595.28);
} elseif ($params['format'] == 'letter') {
$params['format'] = array(612, 792);
} elseif ($params['format'] == 'legal') {
$params['format'] = array(612, 1008);
} else {
$error = File_PDF::raiseError(sprintf('Unknown page format: %s', $params['format']));
return $error;
}
$pdf->fwPt = $params['format'][0];
$pdf->fhPt = $params['format'][1];
} else {
$pdf->fwPt = $params['format'][0] * $pdf->_scale;
$pdf->fhPt = $params['format'][1] * $pdf->_scale;
}
$pdf->fw = $pdf->fwPt / $pdf->_scale;
$pdf->fh = $pdf->fhPt / $pdf->_scale;
 
/* Page orientation. */
$params['orientation'] = strtolower($params['orientation']);
if ($params['orientation'] == 'p' || $params['orientation'] == 'portrait') {
$pdf->_default_orientation = 'P';
$pdf->wPt = $pdf->fwPt;
$pdf->hPt = $pdf->fhPt;
} elseif ($params['orientation'] == 'l' || $params['orientation'] == 'landscape') {
$pdf->_default_orientation = 'L';
$pdf->wPt = $pdf->fhPt;
$pdf->hPt = $pdf->fwPt;
} else {
$error = File_PDF::raiseError(sprintf('Incorrect orientation: %s', $params['orientation']));
return $error;
}
$pdf->_current_orientation = $pdf->_default_orientation;
$pdf->w = $pdf->wPt / $pdf->_scale;
$pdf->h = $pdf->hPt / $pdf->_scale;
 
/* Page margins (1 cm) */
$margin = 28.35 / $pdf->_scale;
$pdf->setMargins($margin, $margin);
 
/* Interior cell margin (1 mm) */
$pdf->_cell_margin = $margin / 10;
 
/* Line width (0.2 mm) */
$pdf->_line_width = .567 / $pdf->_scale;
 
/* Automatic page break */
$pdf->setAutoPageBreak(true, 2 * $margin);
 
/* Full width display mode */
$pdf->setDisplayMode('fullwidth');
 
/* Compression */
$pdf->setCompression(true);
 
return $pdf;
}
 
/**
* Returns a PEAR_Error object. Wraps around PEAR::raiseError() to
* avoid having to include PEAR.php unless an error occurs.
*
* @param mixed $error The error message.
*
* @return object PEAR_Error
*/
function raiseError($error)
{
require_once 'PEAR.php';
return PEAR::raiseError($error);
}
 
/**
* Defines the left, top and right margins. By default, they equal 1 cm.
* Call this method to change them.
*
* @param float $left Left margin.
* @param float $top Top margin.
* @param float $right Right margin. If not specified default to the value
* of the left one.
*
* @see File_PDF::setAutoPageBreak
* @see File_PDF::setLeftMargin
* @see File_PDF::setRightMargin
* @see File_PDF::setTopMargin
*/
function setMargins($left, $top, $right = null)
{
/* Set left and top margins. */
$this->_left_margin = $left;
$this->_top_margin = $top;
/* If no right margin set default to same as left. */
$this->_right_margin = (is_null($right) ? $left : $right);
}
 
/**
* Defines the left margin. The method can be called before creating the
* first page.
* If the current abscissa gets out of page, it is brought back to the
* margin.
*
* @param float $margin The margin.
*
* @see File_PDF::setAutoPageBreak
* @see File_PDF::setMargins
* @see File_PDF::setRightMargin
* @see File_PDF::setTopMargin
*/
function setLeftMargin($margin)
{
$this->_left_margin = $margin;
/* If there is a current page and the current X position is less than
* margin set the X position to the margin value. */
if ($this->_page > 0 && $this->x < $margin) {
$this->x = $margin;
}
}
 
/**
* Defines the top margin. The method can be called before creating the
* first page.
*
* @param float $margin The margin.
*/
function setTopMargin($margin)
{
$this->_top_margin = $margin;
}
 
/**
* Defines the right margin. The method can be called before creating the
* first page.
*
* @param float $margin The margin.
*/
function setRightMargin($margin)
{
$this->_right_margin = $margin;
}
 
/**
* Returns the actual page width.
*
* @since File_PDF 0.2.0
* @since Horde 3.2
*
* @return float The page width.
*/
function getPageWidth()
{
return ($this->w - $this->_right_margin - $this->_left_margin);
}
 
/**
* Returns the actual page height.
*
* @since File_PDF 0.2.0
* @since Horde 3.2
*
* @return float The page height.
*/
function getPageHeight()
{
return ($this->h - $this->_top_margin - $this->_break_margin);
}
 
/**
* Enables or disables the automatic page breaking mode. When enabling,
* the second parameter is the distance from the bottom of the page that
* defines the triggering limit. By default, the mode is on and the margin
* is 2 cm.
*
* @param boolean auto Boolean indicating if mode should be on or off.
* @param float $margin Distance from the bottom of the page.
*/
function setAutoPageBreak($auto, $margin = 0)
{
$this->_auto_page_break = $auto;
$this->_break_margin = $margin;
$this->_page_break_trigger = $this->h - $margin;
}
 
/**
* Defines the way the document is to be displayed by the viewer. The zoom
* level can be set: pages can be displayed entirely on screen, occupy the
* full width of the window, use real size, be scaled by a specific
* zooming factor or use viewer default (configured in the Preferences
* menu of Acrobat). The page layout can be specified too: single at once,
* continuous display, two columns or viewer default.
* By default, documents use the full width mode with continuous display.
*
* @param mixed $zoom The zoom to use. It can be one of the
* following string values:
* - fullpage: entire page on screen
* - fullwidth: maximum width of window
* - real: uses real size (100% zoom)
* - default: uses viewer default mode
* or a number indicating the zooming factor.
* @param string layout The page layout. Possible values are:
* - single: one page at once
* - continuous: pages in continuously
* - two: two pages on two columns
* - default: uses viewer default mode
* Default value is continuous.
*/
function setDisplayMode($zoom, $layout = 'continuous')
{
$zoom = strtolower($zoom);
if ($zoom == 'fullpage' || $zoom == 'fullwidth' || $zoom == 'real'
|| $zoom == 'default' || !is_string($zoom)) {
$this->_zoom_mode = $zoom;
} elseif ($zoom == 'zoom') {
$this->_zoom_mode = $layout;
} else {
return $this->raiseError(sprintf('Incorrect zoom display mode: %s', $zoom));
}
 
$layout = strtolower($layout);
if ($layout == 'single' || $layout == 'continuous' || $layout == 'two'
|| $layout == 'default') {
$this->_layout_mode = $layout;
} elseif ($zoom != 'zoom') {
return $this->raiseError(sprintf('Incorrect layout display mode: %s', $layout));
}
}
 
/**
* Activates or deactivates page compression. When activated, the internal
* representation of each page is compressed, which leads to a compression
* ratio of about 2 for the resulting document.
* Compression is on by default.
* Note: the Zlib extension is required for this feature. If not present,
* compression will be turned off.
*
* @param boolean $compress Boolean indicating if compression must be
* enabled or not.
*/
function setCompression($compress)
{
/* If no gzcompress function is available then default to false. */
$this->_compress = (function_exists('gzcompress') ? $compress : false);
}
 
/**
* Set the info to a document. Possible info settings are:
* - title
* - subject
* - author
* - keywords
* - creator
*
* @param mixed $info If passed as an array then the complete hash
* containing the info to be inserted into the
* document. Otherwise the name of setting to be set.
* @param string $value The value of the setting.
*/
function setInfo($info, $value = '')
{
if (is_array($info)) {
$this->_info = $info;
} else {
$this->_info[$info] = $value;
}
}
 
/**
* Defines an alias for the total number of pages. It will be substituted
* as the document is closed.
*
* Example:
* class My_File_PDF extends File_PDF {
* function footer()
* {
* // Go to 1.5 cm from bottom
* $this->setY(-15);
* // Select Arial italic 8
* $this->setFont('Arial', 'I', 8);
* // Print current and total page numbers
* $this->cell(0, 10, 'Page ' . $this->getPageNo() . '/{nb}', 0,
* 0, 'C');
* }
* }
* $pdf = &My_File_PDF::factory();
* $pdf->aliasNbPages();
*
* @param string $alias The alias. Default value: {nb}.
*
* @see File_PDF::getPageNo
* @see File_PDF::footer
*/
function aliasNbPages($alias = '{nb}')
{
$this->_alias_nb_pages = $alias;
}
 
/**
* This method begins the generation of the PDF document; it must be
* called before any output commands. No page is created by this method,
* therefore it is necessary to call File_PDF::addPage.
*
* @see File_PDF::addPage
* @see File_PDF::close
*/
function open()
{
$this->_beginDoc();
}
 
/**
* Terminates the PDF document. It is not necessary to call this method
* explicitly because File_PDF::output does it automatically.
* If the document contains no page, File_PDF::addPage is called to prevent
* from getting an invalid document.
*
* @see File_PDF::open
* @see File_PDF::output
*/
function close()
{
/* Terminate document */
if ($this->_page == 0) {
$this->addPage();
}
/* Page footer */
$this->_in_footer = true;
$this->footer();
$this->_in_footer = false;
/* Close page */
$this->_endPage();
/* Close document */
$this->_endDoc();
}
 
/**
* Adds a new page to the document. If a page is already present, the
* File_PDF::footer method is called first to output the footer. Then the
* page is added, the current position set to the top-left corner according
* to the left and top margins, and File_PDF::header is called to display
* the header.
* The font which was set before calling is automatically restored. There
* is no need to call File_PDF::setFont again if you want to continue with
* the same font. The same is true for colors and line width.
* The origin of the coordinate system is at the top-left corner and
* increasing ordinates go downwards.
*
* @param string $orientation Page orientation. Possible values
* are (case insensitive):
* - P or Portrait
* - L or Landscape
* The default value is the one passed to the
* constructor.
*
* @see File_PDF::PDF
* @see File_PDF::header
* @see File_PDF::footer
* @see File_PDF::setMargins
*/
function addPage($orientation = '')
{
/* For good measure make sure this is called. */
$this->_beginDoc();
 
/* Save style settings so that they are not overridden by footer(). */
$lw = $this->_line_width;
$dc = $this->_draw_color;
$fc = $this->_fill_color;
$tc = $this->_text_color;
$cf = $this->_color_flag;
if ($this->_page > 0) {
/* Page footer. */
$this->_in_footer = true;
$this->footer();
$this->_in_footer = false;
/* Close page. */
$this->_endPage();
}
/* Start new page. */
$this->_beginPage($orientation);
/* Set line cap style to square. */
$this->_out('2 J');
/* Set line width. */
$this->_line_width = $lw;
$this->_out(sprintf('%.2f w', $lw * $this->_scale));
/* Set font for the beginning of the page. */
$font_family = null;
if ($this->_font_family) {
$font_family = $this->_font_family;
$font_style = $this->_font_style . ($this->_underline ? 'U' : '');
$font_size = $this->_font_size_pt;
$this->setFont($font_family, $font_style, $font_size);
}
/* Set colors. */
$this->_fill_color = $fc;
/* Check if fill color has been set before this page. */
if ($this->_fill_color != '0 g') {
$this->_out($this->_fill_color);
}
$this->_draw_color = $dc;
/* Check if draw color has been set before this page. */
if ($this->_draw_color != '0 G') {
$this->_out($this->_draw_color);
}
$this->_text_color = $tc;
$this->_color_flag = $cf;
/* Page header. */
$this->header();
/* Restore line width. */
if ($this->_line_width != $lw) {
$this->_line_width = $lw;
$this->_out(sprintf('%.2f w', $lw * $this->_scale));
}
/* Make sure the font is set for this page as it was before the
* header. */
if ($font_family) {
$this->setFont($font_family, $font_style, $font_size, true);
}
/* Restore colors. */
if ($this->_draw_color != $dc) {
$this->_draw_color = $dc;
$this->_out($dc);
}
if ($this->_fill_color != $fc) {
$this->_fill_color = $fc;
$this->_out($fc);
}
$this->_text_color = $tc;
$this->_color_flag = $cf;
}
 
/**
* This method is used to render the page header. It is automatically
* called by File_PDF::addPage and should not be called directly by the
* application. The implementation in File_PDF:: is empty, so you have to
* subclass it and override the method if you want a specific processing.
*
* Example:
*
* class My_File_PDF extends File_PDF {
* function header()
* {
* // Select Arial bold 15
* $this->setFont('Arial', 'B', 15);
* // Move to the right
* $this->cell(80);
* // Framed title
* $this->cell(30, 10, 'Title', 1, 0, 'C');
* // Line break
* $this->newLine(20);
* }
* }
*
* @see File_PDF::footer
*/
function header()
{
/* To be implemented in your own inherited class. */
}
 
/**
* This method is used to render the page footer. It is automatically
* called by File_PDF::addPage and File_PDF::close and should not be called
* directly by the application. The implementation in File_PDF:: is empty,
* so you have to subclass it and override the method if you want a specific
* processing.
*
* Example:
*
* class My_File_PDF extends File_PDF {
* function footer()
* {
* // Go to 1.5 cm from bottom
* $this->setY(-15);
* // Select Arial italic 8
* $this->setFont('Arial', 'I', 8);
* // Print centered page number
* $this->cell(0, 10, 'Page ' . $this->getPageNo(), 0, 0, 'C');
* }
* }
*
* @see File_PDF::header
*/
function footer()
{
/* To be implemented in your own inherited class. */
}
 
/**
* Returns the current page number.
*
* @return integer
*
* @see File_PDF::aliasNbPages
*/
function getPageNo()
{
return $this->_page;
}
 
/**
* Sets the fill color.
*
* Depending on the colorspace called, the number of color component
* parameters required can be either 1, 3 or 4. The method can be called
* before the first page is created and the color is retained from page to
* page.
*
* @param string $cs Indicates the colorspace which can be either 'rgb',
* 'cmyk' or 'gray'. Defaults to 'rgb'.
* @param float $c1 First color component, floating point value between 0
* and 1. Required for gray, rgb and cmyk.
* @param float $c2 Second color component, floating point value between
* 0 and 1. Required for rgb and cmyk.
* @param float $c3 Third color component, floating point value between
* 0 and 1. Required for rgb and cmyk.
* @param float $c4 Fourth color component, floating point value between
* 0 and 1. Required for cmyk.
*
* @see File_PDF::setTextColor
* @see File_PDF::setDrawColor
* @see File_PDF::rect
* @see File_PDF::cell
* @see File_PDF::multiCell
*/
function setFillColor($cs = 'rgb', $c1, $c2 = 0, $c3 = 0, $c4 = 0)
{
$cs = strtolower($cs);
if ($cs == 'rgb') {
$this->_fill_color = sprintf('%.3f %.3f %.3f rg', $c1, $c2, $c3);
} elseif ($cs == 'cmyk') {
$this->_fill_color = sprintf('%.3f %.3f %.3f %.3f k', $c1, $c2, $c3, $c4);
} else {
$this->_fill_color = sprintf('%.3f g', $c1);
}
if ($this->_page > 0) {
$this->_out($this->_fill_color);
}
$this->_color_flag = $this->_fill_color != $this->_text_color;
}
 
/**
* Sets the text color.
*
* Depending on the colorspace called, the number of color component
* parameters required can be either 1, 3 or 4. The method can be called
* before the first page is created and the color is retained from page to
* page.
*
* @param string $cs Indicates the colorspace which can be either 'rgb',
* 'cmyk' or 'gray'. Defaults to 'rgb'.
* @param float $c1 First color component, floating point value between 0
* and 1. Required for gray, rgb and cmyk.
* @param float $c2 Second color component, floating point value between
* 0 and 1. Required for rgb and cmyk.
* @param float $c3 Third color component, floating point value between
* 0 and 1. Required for rgb and cmyk.
* @param float $c4 Fourth color component, floating point value between
* 0 and 1. Required for cmyk.
*
* @since File_PDF 0.2.0
* @since Horde 3.2
* @see File_PDF::setFillColor
* @see File_PDF::setDrawColor
* @see File_PDF::rect
* @see File_PDF::cell
* @see File_PDF::multiCell
*/
function setTextColor($cs = 'rgb', $c1, $c2 = 0, $c3 = 0, $c4 = 0)
{
$cs = strtolower($cs);
if ($cs == 'rgb') {
$this->_text_color = sprintf('%.3f %.3f %.3f rg', $c1, $c2, $c3);
} elseif ($cs == 'cmyk') {
$this->_text_color = sprintf('%.3f %.3f %.3f %.3f k', $c1, $c2, $c3, $c4);
} else {
$this->_text_color = sprintf('%.3f g', $c1);
}
if ($this->_page > 0) {
$this->_out($this->_text_color);
}
$this->_color_flag = $this->_fill_color != $this->_text_color;
}
 
/**
* Sets the draw color, used when drawing lines. Depending on the
* colorspace called, the number of color component parameters required
* can be either 1, 3 or 4. The method can be called before the first page
* is created and the color is retained from page to page.
*
* @param string $cs Indicates the colorspace which can be either 'rgb',
* 'cmyk' or 'gray'. Defaults to 'rgb'.
* @param float $c1 First color component, floating point value between 0
* and 1. Required for gray, rgb and cmyk.
* @param float $c2 Second color component, floating point value between
* 0 and 1. Required for rgb and cmyk.
* @param float $c3 Third color component, floating point value between 0
* and 1. Required for rgb and cmyk.
* @param float $c4 Fourth color component, floating point value between
* 0 and 1. Required for cmyk.
*
* @see File_PDF::setFillColor
* @see File_PDF::line
* @see File_PDF::rect
* @see File_PDF::cell
* @see File_PDF::multiCell
*/
function setDrawColor($cs = 'rgb', $c1, $c2 = 0, $c3 = 0, $c4 = 0)
{
$cs = strtolower($cs);
if ($cs == 'rgb') {
$this->_draw_color = sprintf('%.3f %.3f %.3f RG', $c1, $c2, $c3);
} elseif ($cs == 'cmyk') {
$this->_draw_color = sprintf('%.3f %.3f %.3f %.3f K', $c1, $c2, $c3, $c4);
} else {
$this->_draw_color = sprintf('%.3f G', $c1);
}
if ($this->_page > 0) {
$this->_out($this->_draw_color);
}
}
 
/**
* Returns the length of a text string. A font must be selected.
*
* @param string $text The text whose length is to be computed.
* @param boolean $pt Boolean to indicate if the width should be returned
* in points or user units. Default is 'false'.
*
* @return float
*/
function getStringWidth($text, $pt = false)
{
$text = (string)$text;
$width = 0;
$length = strlen($text);
for ($i = 0; $i < $length; $i++) {
$width += $this->_current_font['cw'][$text{$i}];
}
 
/* Adjust for word spacing. */
$width += $this->_word_spacing * substr_count($text, ' ') * $this->_current_font['cw'][' '];
 
if ($pt) {
return $width * $this->_font_size_pt / 1000;
} else {
return $width * $this->_font_size / 1000;
}
}
 
/**
* Defines the line width. By default, the value equals 0.2 mm. The method
* can be called before the first page is created and the value is
* retained from page to page.
*
* @param float $width The width.
*
* @see File_PDF::line
* @see File_PDF::rect
* @see File_PDF::cell
* @see File_PDF::multiCell
*/
function setLineWidth($width)
{
$this->_line_width = $width;
if ($this->_page > 0) {
$this->_out(sprintf('%.2f w', $width * $this->_scale));
}
}
 
/**
* Draws a line between two points.
*
* All coordinates can be negative to provide values from the right or
* bottom edge of the page (since File_PDF 0.2.0, Horde 3.2).
*
* @param float $x1 Abscissa of first point.
* @param float $y1 Ordinate of first point.
* @param float $x2 Abscissa of second point.
* @param float $y2 Ordinate of second point.
*
* @see File_PDF::setLineWidth
* @see File_PDF::setDrawColor.
*/
function line($x1, $y1, $x2, $y2)
{
if ($x1 < 0) {
$x1 += $this->w;
}
if ($y1 < 0) {
$y1 += $this->h;
}
if ($x2 < 0) {
$x2 += $this->w;
}
if ($y2 < 0) {
$y2 += $this->h;
}
 
$this->_out(sprintf('%.2f %.2f m %.2f %.2f l S', $x1 * $this->_scale, ($this->h - $y1) * $this->_scale, $x2 * $this->_scale, ($this->h - $y2) * $this->_scale));
}
 
/**
* Outputs a rectangle. It can be drawn (border only), filled (with no
* border) or both.
*
* All coordinates can be negative to provide values from the right or
* bottom edge of the page (since File_PDF 0.2.0, Horde 3.2).
*
* @param float $x Abscissa of upper-left corner.
* @param float $y Ordinate of upper-left corner.
* @param float $width Width.
* @param float $height Height.
* @param float $style Style of rendering. Possible values are:
* - D or empty string: draw (default)
* - F: fill
* - DF or FD: draw and fill
*
* @see File_PDF::setLineWidth
* @see File_PDF::setDrawColor
* @see File_PDF::setFillColor
*/
function rect($x, $y, $width, $height, $style = '')
{
if ($x < 0) {
$x += $this->w;
}
if ($y < 0) {
$y += $this->h;
}
 
$style = strtoupper($style);
if ($style == 'F') {
$op = 'f';
} elseif ($style == 'FD' || $style == 'DF') {
$op = 'B';
} else {
$op = 'S';
}
 
$x = $this->_toPt($x);
$y = $this->_toPt($y);
$width = $this->_toPt($width);
$height = $this->_toPt($height);
 
$this->_out(sprintf('%.2f %.2f %.2f %.2f re %s', $x, $this->hPt - $y, $width, -$height, $op));
}
 
/**
* Outputs a circle. It can be drawn (border only), filled (with no
* border) or both.
*
* All coordinates can be negative to provide values from the right or
* bottom edge of the page (since File_PDF 0.2.0, Horde 3.2).
*
* @param float $x Abscissa of the center of the circle.
* @param float $y Ordinate of the center of the circle.
* @param float $r Circle radius.
* @param string $style Style of rendering. Possible values are:
* - D or empty string: draw (default)
* - F: fill
* - DF or FD: draw and fill
*/
function circle($x, $y, $r, $style = '')
{
if ($x < 0) {
$x += $this->w;
}
if ($y < 0) {
$y += $this->h;
}
 
$style = strtolower($style);
if ($style == 'f') {
$op = 'f'; // Style is fill only.
} elseif ($style == 'fd' || $style == 'df') {
$op = 'B'; // Style is fill and stroke.
} else {
$op = 'S'; // Style is stroke only.
}
 
$x = $this->_toPt($x);
$y = $this->_toPt($y);
$r = $this->_toPt($r);
 
/* Invert the y scale. */
$y = $this->hPt - $y;
/* Length of the Bezier control. */
$b = $r * 0.552;
 
/* Move from the given origin and set the current point
* to the start of the first Bezier curve. */
$c = sprintf('%.2f %.2f m', $x - $r, $y);
$x = $x - $r;
/* First circle quarter. */
$c .= sprintf(' %.2f %.2f %.2f %.2f %.2f %.2f c',
$x, $y + $b, // First control point.
$x + $r - $b, $y + $r, // Second control point.
$x + $r, $y + $r); // Final point.
/* Set x/y to the final point. */
$x = $x + $r;
$y = $y + $r;
/* Second circle quarter. */
$c .= sprintf(' %.2f %.2f %.2f %.2f %.2f %.2f c',
$x + $b, $y,
$x + $r, $y - $r + $b,
$x + $r, $y - $r);
/* Set x/y to the final point. */
$x = $x + $r;
$y = $y - $r;
/* Third circle quarter. */
$c .= sprintf(' %.2f %.2f %.2f %.2f %.2f %.2f c',
$x, $y - $b,
$x - $r + $b, $y - $r,
$x - $r, $y - $r);
/* Set x/y to the final point. */
$x = $x - $r;
$y = $y - $r;
/* Fourth circle quarter. */
$c .= sprintf(' %.2f %.2f %.2f %.2f %.2f %.2f c %s',
$x - $b, $y,
$x - $r, $y + $r - $b,
$x - $r, $y + $r,
$op);
/* Output the whole string. */
$this->_out($c);
}
 
/**
* Imports a TrueType or Type1 font and makes it available. It is
* necessary to generate a font definition file first with the
* makefont.php utility.
* The location of the definition file (and the font file itself when
* embedding) must be found at the full path name included.
*
* Example:
* $pdf->addFont('Comic', 'I');
* is equivalent to:
* $pdf->addFont('Comic', 'I', 'comici.php');
*
* @param string $family Font family. The name can be chosen arbitrarily.
* If it is a standard family name, it will
* override the corresponding font.
* @param string $style Font style. Possible values are (case
* insensitive):
* - empty string: regular (default)
* - B: bold
* - I: italic
* - BI or IB: bold italic
* @param string $file The font definition file. By default, the name is
* built from the family and style, in lower case
* with no space.
*
* @see File_PDF::setFont
*/
function addFont($family, $style = '', $file = '')
{
$family = strtolower($family);
if ($family == 'arial') {
$family = 'helvetica';
}
 
$style = strtoupper($style);
if ($style == 'IB') {
$style = 'BI';
}
if (isset($this->_fonts[$family . $style])) {
return $this->raiseError(sprintf('Font already added: %s %s', $family, $style));
}
if ($file == '') {
$file = str_replace(' ', '', $family) . strtolower($style) . '.php';
}
include($file);
if (!isset($name)) {
return $this->raiseError('Could not include font definition file.');
}
$i = count($this->_fonts) + 1;
$this->_fonts[$family . $style] = array('i' => $i, 'type' => $type, 'name' => $name, 'desc' => $desc, 'up' => $up, 'ut' => $ut, 'cw' => $cw, 'enc' => $enc, 'file' => $file);
if ($diff) {
/* Search existing encodings. */
$d = 0;
$nb = count($this->_diffs);
for ($i = 1; $i <= $nb; $i++) {
if ($this->_diffs[$i] == $diff) {
$d = $i;
break;
}
}
if ($d == 0) {
$d = $nb + 1;
$this->_diffs[$d] = $diff;
}
$this->_fonts[$family.$style]['diff'] = $d;
}
if ($file) {
if ($type == 'TrueType') {
$this->_font_files[$file] = array('length1' => $originalsize);
} else {
$this->_font_files[$file] = array('length1' => $size1, 'length2' => $size2);
}
}
}
 
/**
* Sets the font used to print character strings. It is mandatory to call
* this method at least once before printing text or the resulting
* document would not be valid. The font can be either a standard one or a
* font added via the File_PDF::addFont method. Standard fonts use Windows
* encoding cp1252 (Western Europe).
* The method can be called before the first page is created and the font
* is retained from page to page.
* If you just wish to change the current font size, it is simpler to call
* File_PDF::setFontSize.
*
* @param string $family Family font. It can be either a name defined by
* File_PDF::addFont or one of the standard families
* (case insensitive):
* - Courier (fixed-width)
* - Helvetica or Arial (sans serif)
* - Times (serif)
* - Symbol (symbolic)
* - ZapfDingbats (symbolic)
* It is also possible to pass an empty string. In
* that case, the current family is retained.
* @param string $style Font style. Possible values are (case
* insensitive):
* - empty string: regular
* - B: bold
* - I: italic
* - U: underline
* or any combination. The default value is regular.
* Bold and italic styles do not apply to Symbol and
* ZapfDingbats.
* @param integer $size Font size in points. The default value is the
* current size. If no size has been specified since
* the beginning of the document, the value taken
* is 12.
* @param boolean $force Force the setting of the font. Each new page will
* require a new call to File_PDF::setFont and
* settings this to true will make sure that the
* checks for same font calls will be skipped.
*
* @see File_PDF::addFont
* @see File_PDF::setFontSize
* @see File_PDF::cell
* @see File_PDF::multiCell
* @see File_PDF::Write
*/
function setFont($family, $style = '', $size = null, $force = false)
{
$family = strtolower($family);
if ($family == 'arial') {
/* Use helvetica instead of arial. */
$family = 'helvetica';
} elseif ($family == 'symbol' || $family == 'zapfdingbats') {
/* These two fonts do not have styles available. */
$style = '';
}
 
$style = strtoupper($style);
 
/* Underline is handled separately, if specified in the style var
* remove it from the style and set the underline flag. */
if (strpos($style, 'U') !== false) {
$this->_underline = true;
$style = str_replace('U', '', $style);
} else {
$this->_underline = false;
}
 
if ($style == 'IB') {
$style = 'BI';
}
 
/* If no size specified, use current size. */
if (is_null($size)) {
$size = $this->_font_size_pt;
}
 
/* If font requested is already the current font and no force setting
* of the font is requested (eg. when adding a new page) don't bother
* with the rest of the function and simply return. */
if ($this->_font_family == $family && $this->_font_style == $style &&
$this->_font_size_pt == $size && !$force) {
return;
}
 
/* Set the font key. */
$fontkey = $family . $style;
 
/* Test if already cached. */
if (!isset($this->_fonts[$fontkey])) {
/* Get the character width definition file. */
$font_widths = &File_PDF::_getFontFile($fontkey);
if (is_a($font_widths, 'PEAR_Error')) {
return $font_widths;
}
 
$i = count($this->_fonts) + 1;
$this->_fonts[$fontkey] = array(
'i' => $i,
'type' => 'core',
'name' => $this->_core_fonts[$fontkey],
'up' => -100,
'ut' => 50,
'cw' => $font_widths[$fontkey]);
}
 
/* Store font information as current font. */
$this->_font_family = $family;
$this->_font_style = $style;
$this->_font_size_pt = $size;
$this->_font_size = $size / $this->_scale;
$this->_current_font = &$this->_fonts[$fontkey];
 
/* Output font information if at least one page has been defined. */
if ($this->_page > 0) {
$this->_out(sprintf('BT /F%d %.2f Tf ET', $this->_current_font['i'], $this->_font_size_pt));
}
}
 
/**
* Defines the size of the current font.
*
* @param float $size The size (in points).
*
* @see File_PDF::setFont
*/
function setFontSize($size)
{
/* If the font size is already the current font size, just return. */
if ($this->_font_size_pt == $size) {
return;
}
/* Set the current font size, both in points and scaled to user
* units. */
$this->_font_size_pt = $size;
$this->_font_size = $size / $this->_scale;
 
/* Output font information if at least one page has been defined. */
if ($this->_page > 0) {
$this->_out(sprintf('BT /F%d %.2f Tf ET', $this->_current_font['i'], $this->_font_size_pt));
}
}
 
/**
* Defines the style of the current font.
*
* @param string $style The font style.
*
* @see File_PDF::setFont
* @since File_PDF 0.2.0
* @since Horde 3.2
*/
function setFontStyle($style)
{
$this->setFont($this->_font_family, $style);
}
 
/**
* Creates a new internal link and returns its identifier. An internal
* link is a clickable area which directs to another place within the
* document.
* The identifier can then be passed to File_PDF::cell, File_PDF::write,
* File_PDF::image or File_PDF::link. The destination is defined with
* File_PDF::setLink.
*
* @see File_PDF::cell
* @see File_PDF::Write
* @see File_PDF::image
* @see File_PDF::Link
* @see File_PDF::SetLink
*/
function addLink()
{
$n = count($this->_links) + 1;
$this->_links[$n] = array(0, 0);
return $n;
}
 
/**
* Defines the page and position a link points to.
*
* @param integer $link The link identifier returned by File_PDF::addLink.
* @param float $y Ordinate of target position; -1 indicates the
* current position. The default value is 0 (top of
* page).
* @param integer $page Number of target page; -1 indicates the current
* page. This is the default value.
*
* @see File_PDF::addLink
*/
function setLink($link, $y = 0, $page = -1)
{
if ($y == -1) {
$y = $this->y;
}
if ($page == -1) {
$page = $this->_page;
}
$this->_links[$link] = array($page, $y);
}
 
/**
* Puts a link on a rectangular area of the page. Text or image links are
* generally put via File_PDF::cell, File_PDF::Write or File_PDF::image,
* but this method can be useful for instance to define a clickable area
* inside an image.
*
* All coordinates can be negative to provide values from the right or
* bottom edge of the page (since File_PDF 0.2.0, Horde 3.2).
*
* @param float $x Abscissa of the upper-left corner of the rectangle.
* @param float $y Ordinate of the upper-left corner of the rectangle.
* @param float $width Width of the rectangle.
* @param float $height Height of the rectangle.
* @param mixed $link URL or identifier returned by File_PDF::addLink.
*
* @see File_PDF::addLink
* @see File_PDF::cell
* @see File_PDF::Write
* @see File_PDF::image
*/
function link($x, $y, $width, $height, $link)
{
if ($x < 0) {
$x += $this->w;
}
if ($y < 0) {
$y += $this->h;
}
 
/* Set up the coordinates with correct scaling in pt. */
$x = $this->_toPt($x);
$y = $this->hPt - $this->_toPt($y);
$width = $this->_toPt($width);
$height = $this->_toPt($height);
 
/* Save link to page links array. */
$this->_link($x, $y, $width, $height, $link);
}
 
/**
* Prints a character string. The origin is on the left of the first
* character, on the baseline. This method allows to place a string
* precisely on the page, but it is usually easier to use File_PDF::cell,
* File_PDF::multiCell or File_PDF::Write which are the standard methods to
* print text.
*
* All coordinates can be negative to provide values from the right or
* bottom edge of the page (since File_PDF 0.2.0, Horde 3.2).
*
* @param float $x Abscissa of the origin.
* @param float $y Ordinate of the origin.
* @param string $text String to print.
*
* @see File_PDF::setFont
* @see File_PDF::cell
* @see File_PDF::multiCell
* @see File_PDF::Write
*/
function text($x, $y, $text)
{
if ($x < 0) {
$x += $this->w;
}
if ($y < 0) {
$y += $this->h;
}
 
/* Scale coordinates into points and set correct Y position. */
$x = $this->_toPt($x);
$y = $this->hPt - $this->_toPt($y);
 
/* Escape any potentially harmful characters. */
$text = $this->_escape($text);
 
$out = sprintf('BT %.2f %.2f Td (%s) Tj ET', $x, $y, $text);
if ($this->_underline && $text != '') {
$out .= ' ' . $this->_doUnderline($x, $y, $text);
}
if ($this->_color_flag) {
$out = sprintf('q %s %s Q', $this->_text_color, $out);
}
$this->_out($out);
}
 
/**
* Whenever a page break condition is met, the method is called, and the
* break is issued or not depending on the returned value. The default
* implementation returns a value according to the mode selected by
* File_PDF:setAutoPageBreak.
* This method is called automatically and should not be called directly
* by the application.
*
* @return boolean
*
* @see File_PDF::setAutoPageBreak.
*/
function acceptPageBreak()
{
return $this->_auto_page_break;
}
 
/**
* Prints a cell (rectangular area) with optional borders, background
* color and character string. The upper-left corner of the cell
* corresponds to the current position. The text can be aligned or
* centered. After the call, the current position moves to the right or to
* the next line. It is possible to put a link on the text.
* If automatic page breaking is enabled and the cell goes beyond the
* limit, a page break is done before outputting.
*
* @param float $width Cell width. If 0, the cell extends up to the right
* margin.
* @param float $height Cell height. Default value: 0.
* @param string $text String to print. Default value: empty.
* @param mixed $border Indicates if borders must be drawn around the
* cell. The value can be either a number:
* - 0: no border (default)
* - 1: frame
* or a string containing some or all of the
* following characters (in any order):
* - L: left
* - T: top
* - R: right
* - B: bottom
* @param integer $ln Indicates where the current position should go
* after the call. Possible values are:
* - 0: to the right (default)
* - 1: to the beginning of the next line
* - 2: below
* Putting 1 is equivalent to putting 0 and calling
* File_PDF::newLine just after.
* @param string $align Allows to center or align the text. Possible
* values are:
* - L or empty string: left (default)
* - C: center
* - R: right
* @param integer $fill Indicates if the cell fill type. Possible values
* are:
* - 0: transparent (default)
* - 1: painted
* @param string $link URL or identifier returned by
* File_PDF:addLink.
*
* @see File_PDF::setFont
* @see File_PDF::setDrawColor
* @see File_PDF::setFillColor
* @see File_PDF::setLineWidth
* @see File_PDF::addLink
* @see File_PDF::newLine
* @see File_PDF::multiCell
* @see File_PDF::Write
* @see File_PDF::setAutoPageBreak
*/
function cell($width, $height = 0, $text = '', $border = 0, $ln = 0,
$align = '', $fill = 0, $link = '')
{
$k = $this->_scale;
if ($this->y + $height > $this->_page_break_trigger &&
!$this->_in_footer && $this->AcceptPageBreak()) {
$x = $this->x;
$ws = $this->_word_spacing;
if ($ws > 0) {
$this->_word_spacing = 0;
$this->_out('0 Tw');
}
$this->addPage($this->_current_orientation);
$this->x = $x;
if ($ws > 0) {
$this->_word_spacing = $ws;
$this->_out(sprintf('%.3f Tw', $ws * $k));
}
}
if ($width == 0) {
$width = $this->w - $this->_right_margin - $this->x;
}
$s = '';
if ($fill == 1 || $border == 1) {
if ($fill == 1) {
$op = ($border == 1) ? 'B' : 'f';
} else {
$op = 'S';
}
$s = sprintf('%.2f %.2f %.2f %.2f re %s ', $this->x * $k, ($this->h - $this->y) * $k, $width * $k, -$height * $k, $op);
}
if (is_string($border)) {
if (strpos($border, 'L') !== false) {
$s .= sprintf('%.2f %.2f m %.2f %.2f l S ', $this->x * $k, ($this->h - $this->y) * $k, $this->x * $k, ($this->h - ($this->y + $height)) * $k);
}
if (strpos($border, 'T') !== false) {
$s .= sprintf('%.2f %.2f m %.2f %.2f l S ', $this->x * $k, ($this->h - $this->y) * $k, ($this->x + $width) * $k, ($this->h - $this->y) * $k);
}
if (strpos($border, 'R') !== false) {
$s .= sprintf('%.2f %.2f m %.2f %.2f l S ', ($this->x + $width) * $k, ($this->h - $this->y) * $k, ($this->x + $width) * $k, ($this->h - ($this->y + $height)) * $k);
}
if (strpos($border, 'B') !== false) {
$s .= sprintf('%.2f %.2f m %.2f %.2f l S ', $this->x * $k, ($this->h - ($this->y + $height)) * $k, ($this->x + $width) * $k, ($this->h - ($this->y + $height)) * $k);
}
}
if ($text != '') {
if ($align == 'R') {
$dx = $width - $this->_cell_margin - $this->getStringWidth($text);
} elseif ($align == 'C') {
$dx = ($width - $this->getStringWidth($text)) / 2;
} else {
$dx = $this->_cell_margin;
}
if ($this->_color_flag) {
$s .= 'q ' . $this->_text_color . ' ';
}
$text = str_replace(')', '\\)', str_replace('(', '\\(', str_replace('\\', '\\\\', $text)));
$test2 = ((.5 * $height) + (.3 * $this->_font_size));
$test1 = $this->fhPt - (($this->y + $test2) * $k);
$s .= sprintf('BT %.2f %.2f Td (%s) Tj ET', ($this->x + $dx) * $k, ($this->h - ($this->y + .5 * $height + .3 * $this->_font_size)) * $k, $text);
if ($this->_underline) {
$s .= ' ' . $this->_doUnderline($this->x + $dx, $this->y + .5 * $height + .3 * $this->_font_size, $text);
}
if ($this->_color_flag) {
$s .= ' Q';
}
if ($link) {
$this->link($this->x + $dx, $this->y + .5 * $height-.5 * $this->_font_size, $this->getStringWidth($text), $this->_font_size, $link);
}
}
if ($s) {
$this->_out($s);
}
$this->_last_height = $height;
if ($ln > 0) {
/* Go to next line. */
$this->y += $height;
if ($ln == 1) {
$this->x = $this->_left_margin;
}
} else {
$this->x += $width;
}
}
 
/**
* This method allows printing text with line breaks. They can be
* automatic (as soon as the text reaches the right border of the cell) or
* explicit (via the \n character). As many cells as necessary are output,
* one below the other.
* Text can be aligned, centered or justified. The cell block can be
* framed and the background painted.
*
* @param float $width Width of cells. If 0, they extend up to the right
* margin of the page.
* @param float $height Height of cells.
* @param string $text String to print.
* @param mixed $border Indicates if borders must be drawn around the cell
* block. The value can be either a number:
* - 0: no border (default)
* - 1: frame
* or a string containing some or all of the
* following characters (in any order):
* - L: left
* - T: top
* - R: right
* - B: bottom
* @param string $align Sets the text alignment. Possible values are:
* - L: left alignment
* - C: center
* - R: right alignment
* - J: justification (default value)
* @param integer $fill Indicates if the cell background must:
* - 0: transparent (default)
* - 1: painted
*
* @see File_PDF::setFont
* @see File_PDF::setDrawColor
* @see File_PDF::setFillColor
* @see File_PDF::setLineWidth
* @see File_PDF::cell
* @see File_PDF::write
* @see File_PDF::setAutoPageBreak
*/
function multiCell($width, $height, $text, $border = 0, $align = 'J',
$fill = 0)
{
$cw = &$this->_current_font['cw'];
if ($width == 0) {
$width = $this->w - $this->_right_margin - $this->x;
}
$wmax = ($width-2 * $this->_cell_margin) * 1000 / $this->_font_size;
$s = str_replace("\r", '', $text);
$nb = strlen($s);
if ($nb > 0 && $s[$nb-1] == "\n") {
$nb--;
}
$b = 0;
if ($border) {
if ($border == 1) {
$border = 'LTRB';
$b = 'LRT';
$b2 = 'LR';
} else {
$b2 = '';
if (strpos($border, 'L') !== false) {
$b2 .= 'L';
}
if (strpos($border, 'R') !== false) {
$b2 .= 'R';
}
$b = (strpos($border, 'T') !== false) ? $b2 . 'T' : $b2;
}
}
$sep = -1;
$i = 0;
$j = 0;
$l = 0;
$ns = 0;
$nl = 1;
while ($i < $nb) {
/* Get next character. */
$c = $s[$i];
if ($c == "\n") {
/* Explicit line break. */
if ($this->_word_spacing > 0) {
$this->_word_spacing = 0;
$this->_out('0 Tw');
}
$this->cell($width, $height, substr($s, $j, $i-$j), $b, 2, $align, $fill);
$i++;
$sep = -1;
$j = $i;
$l = 0;
$ns = 0;
$nl++;
if ($border && $nl == 2) {
$b = $b2;
}
continue;
}
if ($c == ' ') {
$sep = $i;
$ls = $l;
$ns++;
}
$l += $cw[$c];
if ($l > $wmax) {
/* Automatic line break. */
if ($sep == -1) {
if ($i == $j) {
$i++;
}
if ($this->_word_spacing > 0) {
$this->_word_spacing = 0;
$this->_out('0 Tw');
}
$this->cell($width, $height, substr($s, $j, $i - $j), $b, 2, $align, $fill);
} else {
if ($align == 'J') {
$this->_word_spacing = ($ns>1) ? ($wmax - $ls)/1000 * $this->_font_size / ($ns - 1) : 0;
$this->_out(sprintf('%.3f Tw', $this->_word_spacing * $this->_scale));
}
$this->cell($width, $height, substr($s, $j, $sep - $j), $b, 2, $align, $fill);
$i = $sep + 1;
}
$sep = -1;
$j = $i;
$l = 0;
$ns = 0;
$nl++;
if ($border && $nl == 2) {
$b = $b2;
}
} else {
$i++;
}
}
/* Last chunk. */
if ($this->_word_spacing > 0) {
$this->_word_spacing = 0;
$this->_out('0 Tw');
}
if ($border && strpos($border, 'B') !== false) {
$b .= 'B';
}
$this->cell($width, $height, substr($s, $j, $i), $b, 2, $align, $fill);
$this->x = $this->_left_margin;
}
 
/**
* This method prints text from the current position. When the right
* margin is reached (or the \n character is met) a line break occurs and
* text continues from the left margin. Upon method exit, the current
* position is left just at the end of the text.
* It is possible to put a link on the text.
*
* Example:
* //Begin with regular font
* $pdf->setFont('Arial','',14);
* $pdf->write(5,'Visit ');
* //Then put a blue underlined link
* $pdf->setTextColor(0,0,255);
* $pdf->setFont('','U');
* $pdf->write(5,'www.fpdf.org','http://www.fpdf.org');
*
* @param float $height Line height.
* @param string $text String to print.
* @param mixed $link URL or identifier returned by AddLink().
*
* @see File_PDF::setFont
* @see File_PDF::addLink
* @see File_PDF::multiCell
* @see File_PDF::setAutoPageBreak
*/
function write($height, $text, $link = '')
{
$cw = &$this->_current_font['cw'];
$width = $this->w - $this->_right_margin - $this->x;
$wmax = ($width - 2 * $this->_cell_margin) * 1000 / $this->_font_size;
$s = str_replace("\r", '', $text);
$nb = strlen($s);
$sep = -1;
$i = 0;
$j = 0;
$l = 0;
$nl = 1;
while ($i < $nb) {
/* Get next character. */
$c = $s{$i};
if ($c == "\n") {
/* Explicit line break. */
$this->cell($width, $height, substr($s, $j, $i - $j), 0, 2, '', 0, $link);
$i++;
$sep = -1;
$j = $i;
$l = 0;
if ($nl == 1) {
$this->x = $this->_left_margin;
$width = $this->w - $this->_right_margin - $this->x;
$wmax = ($width - 2 * $this->_cell_margin) * 1000 / $this->_font_size;
}
$nl++;
continue;
}
if ($c == ' ') {
$sep = $i;
$ls = $l;
}
$l += (isset($cw[$c]) ? $cw[$c] : 0);
if ($l > $wmax) {
/* Automatic line break. */
if ($sep == -1) {
if ($this->x > $this->_left_margin) {
/* Move to next line. */
$this->x = $this->_left_margin;
$this->y += $height;
$width = $this->w - $this->_right_margin - $this->x;
$wmax = ($width - 2 * $this->_cell_margin) * 1000 / $this->_font_size;
$i++;
$nl++;
continue;
}
if ($i == $j) {
$i++;
}
$this->cell($width, $height, substr($s, $j, $i - $j), 0, 2, '', 0, $link);
} else {
$this->cell($width, $height, substr($s, $j, $sep - $j), 0, 2, '', 0, $link);
$i = $sep + 1;
}
$sep = -1;
$j = $i;
$l = 0;
if ($nl == 1) {
$this->x = $this->_left_margin;
$width = $this->w - $this->_right_margin - $this->x;
$wmax = ($width - 2 * $this->_cell_margin) * 1000 / $this->_font_size;
}
$nl++;
} else {
$i++;
}
}
/* Last chunk. */
if ($i != $j) {
$this->cell($l / 1000 * $this->_font_size, $height, substr($s, $j, $i), 0, 0, '', 0, $link);
}
}
 
/**
* Writes text at an angle.
*
* All coordinates can be negative to provide values from the right or
* bottom edge of the page (since File_PDF 0.2.0, Horde 3.2).
*
* @param integer $x X coordinate.
* @param integer $y Y coordinate.
* @param string $text Text to write.
* @param float $text_angle Angle to rotate (Eg. 90 = bottom to top).
* @param float $font_angle Rotate characters as well as text.
*
* @see File_PDF::setFont
*/
function writeRotated($x, $y, $text, $text_angle, $font_angle = 0)
{
if ($x < 0) {
$x += $this->w;
}
if ($y < 0) {
$y += $this->h;
}
 
/* Escape text. */
$text = $this->_escape($text);
 
$font_angle += 90 + $text_angle;
$text_angle *= M_PI / 180;
$font_angle *= M_PI / 180;
 
$text_dx = cos($text_angle);
$text_dy = sin($text_angle);
$font_dx = cos($font_angle);
$font_dy = sin($font_angle);
 
$s= sprintf('BT %.2f %.2f %.2f %.2f %.2f %.2f Tm (%s) Tj ET',
$text_dx, $text_dy, $font_dx, $font_dy,
$x * $this->_scale, ($this->h-$y) * $this->_scale, $text);
 
if ($this->_draw_color) {
$s = 'q ' . $this->_draw_color . ' ' . $s . ' Q';
}
$this->_out($s);
}
 
/**
* Prints an image in the page. The upper-left corner and at least one of
* the dimensions must be specified; the height or the width can be
* calculated automatically in order to keep the image proportions.
* Supported formats are JPEG and PNG.
*
* All coordinates can be negative to provide values from the right or
* bottom edge of the page (since File_PDF 0.2.0, Horde 3.2).
*
* For JPEG, all flavors are allowed:
* - gray scales
* - true colors (24 bits)
* - CMYK (32 bits)
*
* For PNG, are allowed:
* - gray scales on at most 8 bits (256 levels)
* - indexed colors
* - true colors (24 bits)
* but are not supported:
* - Interlacing
* - Alpha channel
*
* If a transparent color is defined, it will be taken into account (but
* will be only interpreted by Acrobat 4 and above).
* The format can be specified explicitly or inferred from the file
* extension.
* It is possible to put a link on the image.
*
* Remark: if an image is used several times, only one copy will be
* embedded in the file.
*
* @param string $file Name of the file containing the image.
* @param float $x Abscissa of the upper-left corner.
* @param float $y Ordinate of the upper-left corner.
* @param float $width Width of the image in the page. If equal to zero,
* it is automatically calculated to keep the
* original proportions.
* @param float $height Height of the image in the page. If not specified
* or equal to zero, it is automatically calculated
* to keep the original proportions.
* @param string $type Image format. Possible values are (case
* insensitive) : JPG, JPEG, PNG. If not specified,
* the type is inferred from the file extension.
* @param mixed $link URL or identifier returned by File_PDF::addLink.
*
* @see File_PDF::addLink
*/
function image($file, $x, $y, $width = 0, $height = 0, $type = '',
$link = '')
{
if ($x < 0) {
$x += $this->w;
}
if ($y < 0) {
$y += $this->h;
}
 
if (!isset($this->_images[$file])) {
/* First use of image, get some file info. */
if ($type == '') {
$pos = strrpos($file, '.');
if ($pos === false) {
return $this->raiseError(sprintf('Image file has no extension and no type was specified: %s', $file));
}
$type = substr($file, $pos + 1);
}
$type = strtolower($type);
$mqr = get_magic_quotes_runtime();
set_magic_quotes_runtime(0);
if ($type == 'jpg' || $type == 'jpeg') {
$info = $this->_parseJPG($file);
} elseif ($type == 'png') {
$info = $this->_parsePNG($file);
} else {
return $this->raiseError(sprintf('Unsupported image file type: %s', $type));
}
if (is_a($info, 'PEAR_Error')) {
return $info;
}
set_magic_quotes_runtime($mqr);
$info['i'] = count($this->_images) + 1;
$this->_images[$file] = $info;
} else {
$info = $this->_images[$file];
}
 
/* Make sure all vars are converted to pt scale. */
$x = $this->_toPt($x);
$y = $this->_toPt($y);
$width = $this->_toPt($width);
$height = $this->_toPt($height);
 
/* If not specified do automatic width and height calculations. */
if (empty($width) && empty($height)) {
$width = $info['w'];
$height = $info['h'];
} elseif (empty($width)) {
$width = $height * $info['w'] / $info['h'];
} elseif (empty($height)) {
$height = $width * $info['h'] / $info['w'];
}
 
$this->_out(sprintf('q %.2f 0 0 %.2f %.2f %.2f cm /I%d Do Q', $width, $height, $x, $this->hPt - ($y + $height), $info['i']));
 
/* Set any link if requested. */
if ($link) {
$this->_link($x, $y, $width, $height, $link);
}
}
 
/**
* Performs a line break. The current abscissa goes back to the left
* margin and the ordinate increases by the amount passed in parameter.
*
* @param float $height The height of the break. By default, the value
* equals the height of the last printed cell.
*
* @see File_PDF::cell
*/
function newLine($height = '')
{
$this->x = $this->_left_margin;
if (is_string($height)) {
$this->y += $this->_last_height;
} else {
$this->y += $height;
}
}
 
/**
* Returns the abscissa of the current position in user units.
*
* @return float
*
* @see File_PDF::setX
* @see File_PDF::getY
* @see File_PDF::setY
*/
function getX()
{
return $this->x;
}
 
/**
* Defines the abscissa of the current position. If the passed value is
* negative, it is relative to the right of the page.
*
* @param float $x The value of the abscissa.
*
* @see File_PDF::getX
* @see File_PDF::getY
* @see File_PDF::setY
* @see File_PDF::setXY
*/
function setX($x)
{
if ($x >= 0) {
/* Absolute value. */
$this->x = $x;
} else {
/* Negative, so relative to right edge of the page. */
$this->x = $this->w + $x;
}
}
 
/**
* Returns the ordinate of the current position in user units.
*
* @return float
*
* @see File_PDF::setY
* @see File_PDF::getX
* @see File_PDF::setX
*/
function getY()
{
return $this->y;
}
 
/**
* Defines the ordinate of the current position. If the passed value is
* negative, it is relative to the bottom of the page.
*
* @param float $y The value of the ordinate.
*
* @see File_PDF::getX
* @see File_PDF::getY
* @see File_PDF::setY
* @see File_PDF::setXY
*/
function setY($y)
{
if ($y >= 0) {
/* Absolute value. */
$this->y = $y;
} else {
/* Negative, so relative to bottom edge of the page. */
$this->y = $this->h + $y;
}
}
 
/**
* Defines the abscissa and ordinate of the current position. If the
* passed values are negative, they are relative respectively to the right
* and bottom of the page.
*
* @param float $x The value of the abscissa.
* @param float $y The value of the ordinate.
*
* @see File_PDF::setX
* @see File_PDF::setY
*/
function setXY($x, $y)
{
$this->setY($y);
$this->setX($x);
}
 
/**
* Returns the raw PDF file.
*
* @see File_PDF::output
*/
function getOutput()
{
/* Check whether file has been closed. */
if ($this->_state < 3) {
$this->close();
}
 
return $this->_buffer;
}
 
/**
* Function to output the buffered data to the browser.
*
* @param string $filename The filename for the output file.
* @param boolean $inline True if inline, false if attachment.
*/
function output($filename = 'unknown.pdf', $inline = false)
{
/* Check whether file has been closed. */
if ($this->_state < 3) {
$this->close();
}
 
/* Check if headers have been sent. */
if (headers_sent()) {
return $this->raiseError('Unable to send PDF file, some data has already been output to browser.');
}
 
/* If HTTP_Download is not available return a PEAR_Error. */
if (!include_once 'HTTP/Download.php') {
return $this->raiseError('Missing PEAR package HTTP_Download.');
}
 
/* Params for the output. */
$disposition = !$inline ? HTTP_DOWNLOAD_ATTACHMENT : HTTP_DOWNLOAD_INLINE;
$params = array('data' => $this->_buffer,
'contenttype' => 'application/pdf',
'contentdisposition' => array($disposition, $filename));
/* Output the file. */
return HTTP_Download::staticSend($params);
}
 
/**
* Function to save the PDF file somewhere local to the server.
*
* @param string $filename The filename for the output file.
*/
function save($filename = 'unknown.pdf')
{
/* Check whether file has been closed. */
if ($this->_state < 3) {
$this->close();
}
 
$f = fopen($filename, 'wb');
if (!$f) {
return $this->raiseError(sprintf('Unable to save PDF file: %s', $filename));
}
fwrite($f, $this->_buffer, strlen($this->_buffer));
fclose($f);
}
 
function _toPt($val)
{
return $val * $this->_scale;
}
 
function &_getFontFile($fontkey, $path = '')
{
static $font_widths;
 
if (!isset($font_widths[$fontkey])) {
if (!empty($path)) {
$file = $path . strtolower($fontkey) . '.php';
} else {
$file = 'File/PDF/fonts/' . strtolower($fontkey) . '.php';
}
include $file;
if (!isset($font_widths[$fontkey])) {
return $this->raiseError(sprintf('Could not include font metric file: %s', $file));
}
}
 
return $font_widths;
}
 
function _link($x, $y, $width, $height, $link)
{
/* Save link to page links array. */
$this->_page_links[$this->_page][] = array($x, $y, $width, $height, $link);
}
 
function _beginDoc()
{
/* Start document, but only if not yet started. */
if ($this->_state < 1) {
$this->_state = 1;
$this->_out('%PDF-1.3');
}
}
 
function _putPages()
{
$nb = $this->_page;
if (!empty($this->_alias_nb_pages)) {
/* Replace number of pages. */
for ($n = 1; $n <= $nb; $n++) {
$this->_pages[$n] = str_replace($this->_alias_nb_pages, $nb, $this->_pages[$n]);
}
}
if ($this->_default_orientation == 'P') {
$wPt = $this->fwPt;
$hPt = $this->fhPt;
} else {
$wPt = $this->fhPt;
$hPt = $this->fwPt;
}
$filter = ($this->_compress) ? '/Filter /FlateDecode ' : '';
for ($n = 1; $n <= $nb; $n++) {
/* Page */
$this->_newobj();
$this->_out('<</Type /Page');
$this->_out('/Parent 1 0 R');
if (isset($this->_orientation_changes[$n])) {
$this->_out(sprintf('/MediaBox [0 0 %.2f %.2f]', $hPt, $wPt));
}
$this->_out('/Resources 2 0 R');
if (isset($this->_page_links[$n])) {
/* Links */
$annots = '/Annots [';
foreach ($this->_page_links[$n] as $pl) {
$rect = sprintf('%.2f %.2f %.2f %.2f', $pl[0], $pl[1], $pl[0] + $pl[2], $pl[1] - $pl[3]);
$annots .= '<</Type /Annot /Subtype /Link /Rect [' . $rect . '] /Border [0 0 0] ';
if (is_string($pl[4])) {
$annots .= '/A <</S /URI /URI ' . $this->_textString($pl[4]) . '>>>>';
} else {
$l = $this->_links[$pl[4]];
$height = isset($this->_orientation_changes[$l[0]]) ? $wPt : $hPt;
$annots .= sprintf('/Dest [%d 0 R /XYZ 0 %.2f null]>>', 1 + 2 * $l[0], $height - $l[1] * $this->_scale);
}
}
$this->_out($annots.']');
}
$this->_out('/Contents ' . ($this->_n + 1) . ' 0 R>>');
$this->_out('endobj');
/* Page content */
$p = ($this->_compress) ? gzcompress($this->_pages[$n]) : $this->_pages[$n];
$this->_newobj();
$this->_out('<<' . $filter . '/Length ' . strlen($p) . '>>');
$this->_putStream($p);
$this->_out('endobj');
}
/* Pages root */
$this->_offsets[1] = strlen($this->_buffer);
$this->_out('1 0 obj');
$this->_out('<</Type /Pages');
$kids = '/Kids [';
for ($i = 0; $i < $nb; $i++) {
$kids .= (3 + 2 * $i) . ' 0 R ';
}
$this->_out($kids . ']');
$this->_out('/Count ' . $nb);
$this->_out(sprintf('/MediaBox [0 0 %.2f %.2f]', $wPt, $hPt));
$this->_out('>>');
$this->_out('endobj');
}
 
function _putFonts()
{
$nf = $this->_n;
foreach ($this->_diffs as $diff) {
/* Encodings */
$this->_newobj();
$this->_out('<</Type /Encoding /BaseEncoding /WinAnsiEncoding /Differences [' . $diff . ']>>');
$this->_out('endobj');
}
$mqr = get_magic_quotes_runtime();
set_magic_quotes_runtime(0);
foreach ($this->_font_files as $file => $info) {
/* Font file embedding. */
$this->_newobj();
$this->_font_files[$file]['n'] = $this->_n;
$size = filesize($file);
if (!$size) {
return $this->raiseError('Font file not found.');
}
$this->_out('<</Length ' . $size);
if (substr($file, -2) == '.z') {
$this->_out('/Filter /FlateDecode');
}
$this->_out('/Length1 ' . $info['length1']);
if (isset($info['length2'])) {
$this->_out('/Length2 ' . $info['length2'] . ' /Length3 0');
}
$this->_out('>>');
$f = fopen($file, 'rb');
$this->_putStream(fread($f, $size));
fclose($f);
$this->_out('endobj');
}
set_magic_quotes_runtime($mqr);
foreach ($this->_fonts as $k => $font) {
/* Font objects */
$this->_newobj();
$this->_fonts[$k]['n'] = $this->_n;
$name = $font['name'];
$this->_out('<</Type /Font');
$this->_out('/BaseFont /' . $name);
if ($font['type'] == 'core') {
/* Standard font. */
$this->_out('/Subtype /Type1');
if ($name != 'Symbol' && $name != 'ZapfDingbats') {
$this->_out('/Encoding /WinAnsiEncoding');
}
} else {
/* Additional font. */
$this->_out('/Subtype /' . $font['type']);
$this->_out('/FirstChar 32');
$this->_out('/LastChar 255');
$this->_out('/Widths ' . ($this->_n + 1) . ' 0 R');
$this->_out('/FontDescriptor ' . ($this->_n + 2) . ' 0 R');
if ($font['enc']) {
if (isset($font['diff'])) {
$this->_out('/Encoding ' . ($nf + $font['diff']).' 0 R');
} else {
$this->_out('/Encoding /WinAnsiEncoding');
}
}
}
$this->_out('>>');
$this->_out('endobj');
if ($font['type'] != 'core') {
/* Widths. */
$this->_newobj();
$cw = &$font['cw'];
$s = '[';
for ($i = 32; $i <= 255; $i++) {
$s .= $cw[chr($i)] . ' ';
}
$this->_out($s . ']');
$this->_out('endobj');
/* Descriptor. */
$this->_newobj();
$s = '<</Type /FontDescriptor /FontName /' . $name;
foreach ($font['desc'] as $k => $v) {
$s .= ' /' . $k . ' ' . $v;
}
$file = $font['file'];
if ($file) {
$s .= ' /FontFile' . ($font['type'] == 'Type1' ? '' : '2') . ' ' . $this->_font_files[$file]['n'] . ' 0 R';
}
$this->_out($s . '>>');
$this->_out('endobj');
}
}
}
 
function _putImages()
{
$filter = ($this->_compress) ? '/Filter /FlateDecode ' : '';
foreach ($this->_images as $file => $info) {
$this->_newobj();
$this->_images[$file]['n'] = $this->_n;
$this->_out('<</Type /XObject');
$this->_out('/Subtype /Image');
$this->_out('/Width ' . $info['w']);
$this->_out('/Height ' . $info['h']);
if ($info['cs'] == 'Indexed') {
$this->_out('/ColorSpace [/Indexed /DeviceRGB ' . (strlen($info['pal'])/3 - 1) . ' ' . ($this->_n + 1).' 0 R]');
} else {
$this->_out('/ColorSpace /' . $info['cs']);
if ($info['cs'] == 'DeviceCMYK') {
$this->_out('/Decode [1 0 1 0 1 0 1 0]');
}
}
$this->_out('/BitsPerComponent ' . $info['bpc']);
$this->_out('/Filter /' . $info['f']);
if (isset($info['parms'])) {
$this->_out($info['parms']);
}
if (isset($info['trns']) && is_array($info['trns'])) {
$trns = '';
$i_max = count($info['trns']);
for ($i = 0; $i < $i_max; $i++) {
$trns .= $info['trns'][$i] . ' ' . $info['trns'][$i].' ';
}
$this->_out('/Mask [' . $trns . ']');
}
$this->_out('/Length ' . strlen($info['data']) . '>>');
$this->_putStream($info['data']);
$this->_out('endobj');
 
/* Palette. */
if ($info['cs'] == 'Indexed') {
$this->_newobj();
$pal = ($this->_compress) ? gzcompress($info['pal']) : $info['pal'];
$this->_out('<<' . $filter . '/Length ' . strlen($pal) . '>>');
$this->_putStream($pal);
$this->_out('endobj');
}
}
}
 
function _putResources()
{
$this->_putFonts();
$this->_putImages();
/* Resource dictionary */
$this->_offsets[2] = strlen($this->_buffer);
$this->_out('2 0 obj');
$this->_out('<</ProcSet [/PDF /Text /ImageB /ImageC /ImageI]');
$this->_out('/Font <<');
foreach ($this->_fonts as $font) {
$this->_out('/F' . $font['i'] . ' ' . $font['n'] . ' 0 R');
}
$this->_out('>>');
if (count($this->_images)) {
$this->_out('/XObject <<');
foreach ($this->_images as $image) {
$this->_out('/I' . $image['i'] . ' ' . $image['n'] . ' 0 R');
}
$this->_out('>>');
}
$this->_out('>>');
$this->_out('endobj');
}
 
function _putInfo()
{
$this->_out('/Producer ' . $this->_textString('Horde PDF'));
if (!empty($this->_info['title'])) {
$this->_out('/Title ' . $this->_textString($this->_info['title']));
}
if (!empty($this->_info['subject'])) {
$this->_out('/Subject ' . $this->_textString($this->_info['subject']));
}
if (!empty($this->_info['author'])) {
$this->_out('/Author ' . $this->_textString($this->_info['author']));
}
if (!empty($this->keywords)) {
$this->_out('/Keywords ' . $this->_textString($this->keywords));
}
if (!empty($this->creator)) {
$this->_out('/Creator ' . $this->_textString($this->creator));
}
$this->_out('/CreationDate ' . $this->_textString('D:' . date('YmdHis')));
}
 
function _putCatalog()
{
$this->_out('/Type /Catalog');
$this->_out('/Pages 1 0 R');
if ($this->_zoom_mode == 'fullpage') {
$this->_out('/OpenAction [3 0 R /Fit]');
} elseif ($this->_zoom_mode == 'fullwidth') {
$this->_out('/OpenAction [3 0 R /FitH null]');
} elseif ($this->_zoom_mode == 'real') {
$this->_out('/OpenAction [3 0 R /XYZ null null 1]');
} elseif (!is_string($this->_zoom_mode)) {
$this->_out('/OpenAction [3 0 R /XYZ null null ' . ($this->_zoom_mode / 100).']');
}
if ($this->_layout_mode == 'single') {
$this->_out('/PageLayout /SinglePage');
} elseif ($this->_layout_mode == 'continuous') {
$this->_out('/PageLayout /OneColumn');
} elseif ($this->_layout_mode == 'two') {
$this->_out('/PageLayout /TwoColumnLeft');
}
}
 
function _putTrailer()
{
$this->_out('/Size ' . ($this->_n + 1));
$this->_out('/Root ' . $this->_n . ' 0 R');
$this->_out('/Info ' . ($this->_n - 1) . ' 0 R');
}
 
function _endDoc()
{
$this->_putPages();
$this->_putResources();
/* Info */
$this->_newobj();
$this->_out('<<');
$this->_putInfo();
$this->_out('>>');
$this->_out('endobj');
/* Catalog */
$this->_newobj();
$this->_out('<<');
$this->_putCatalog();
$this->_out('>>');
$this->_out('endobj');
/* Cross-ref */
$o = strlen($this->_buffer);
$this->_out('xref');
$this->_out('0 ' . ($this->_n + 1));
$this->_out('0000000000 65535 f ');
for ($i = 1; $i <= $this->_n; $i++) {
$this->_out(sprintf('%010d 00000 n ', $this->_offsets[$i]));
}
/* Trailer */
$this->_out('trailer');
$this->_out('<<');
$this->_putTrailer();
$this->_out('>>');
$this->_out('startxref');
$this->_out($o);
$this->_out('%%EOF');
$this->_state = 3;
}
 
function _beginPage($orientation)
{
$this->_page++;
$this->_pages[$this->_page] = '';
$this->_state = 2;
$this->x = $this->_left_margin;
$this->y = $this->_top_margin;
$this->_last_height = 0;
/* Page orientation */
if (!$orientation) {
$orientation = $this->_default_orientation;
} else {
$orientation = strtoupper($orientation[0]);
if ($orientation != $this->_default_orientation) {
$this->_orientation_changes[$this->_page] = true;
}
}
if ($orientation != $this->_current_orientation) {
/* Change orientation */
if ($orientation == 'P') {
$this->wPt = $this->fwPt;
$this->hPt = $this->fhPt;
$this->w = $this->fw;
$this->h = $this->fh;
} else {
$this->wPt = $this->fhPt;
$this->hPt = $this->fwPt;
$this->w = $this->fh;
$this->h = $this->fw;
}
$this->_page_break_trigger = $this->h - $this->_break_margin;
$this->_current_orientation = $orientation;
}
}
 
function _endPage()
{
/* End of page contents */
$this->_state = 1;
}
 
function _newobj()
{
/* Begin a new object */
$this->_n++;
$this->_offsets[$this->_n] = strlen($this->_buffer);
$this->_out($this->_n . ' 0 obj');
}
 
function _doUnderline($x, $y, $text)
{
/* Set the rectangle width according to text width. */
$width = $this->getStringWidth($text, true);
 
/* Set rectangle position and height, using underline position and
* thickness settings scaled by the font size. */
$y = $y + ($this->_current_font['up'] * $this->_font_size_pt / 1000);
$height = -$this->_current_font['ut'] * $this->_font_size_pt / 1000;
 
return sprintf('%.2f %.2f %.2f %.2f re f', $x, $y, $width, $height);
}
 
function _parseJPG($file)
{
/* Extract info from a JPEG file. */
$img = @getimagesize($file);
if (!$img) {
return $this->raiseError(sprintf('Missing or incorrect image file: %s', $file));
}
if ($img[2] != 2) {
return $this->raiseError(sprintf('Not a JPEG file: %s', $file));
}
if (!isset($img['channels']) || $img['channels'] == 3) {
$colspace = 'DeviceRGB';
} elseif ($img['channels'] == 4) {
$colspace = 'DeviceCMYK';
} else {
$colspace = 'DeviceGray';
}
$bpc = isset($img['bits']) ? $img['bits'] : 8;
 
/* Read whole file. */
$f = fopen($file, 'rb');
$data = fread($f, filesize($file));
fclose($f);
 
return array('w' => $img[0], 'h' => $img[1], 'cs' => $colspace, 'bpc' => $bpc, 'f' => 'DCTDecode', 'data' => $data);
}
 
function _parsePNG($file)
{
/* Extract info from a PNG file. */
$f = fopen($file, 'rb');
if (!$f) {
return $this->raiseError(sprintf('Unable to open image file: %s', $file));
}
 
/* Check signature. */
if (fread($f, 8) != chr(137) . 'PNG' . chr(13) . chr(10) . chr(26) . chr(10)) {
return $this->raiseError(sprintf('Not a PNG file: %s', $file));
}
 
/* Read header chunk. */
fread($f, 4);
if (fread($f, 4) != 'IHDR') {
return $this->raiseError(sprintf('Incorrect PNG file: %s', $file));
}
$width = $this->_freadInt($f);
$height = $this->_freadInt($f);
$bpc = ord(fread($f, 1));
if ($bpc > 8) {
return $this->raiseError(sprintf('16-bit depth not supported: %s', $file));
}
$ct = ord(fread($f, 1));
if ($ct == 0) {
$colspace = 'DeviceGray';
} elseif ($ct == 2) {
$colspace = 'DeviceRGB';
} elseif ($ct == 3) {
$colspace = 'Indexed';
} else {
return $this->raiseError(sprintf('Alpha channel not supported: %s', $file));
}
if (ord(fread($f, 1)) != 0) {
return $this->raiseError(sprintf('Unknown compression method: %s', $file));
}
if (ord(fread($f, 1)) != 0) {
return $this->raiseError(sprintf('Unknown filter method: %s', $file));
}
if (ord(fread($f, 1)) != 0) {
return $this->raiseError(sprintf('Interlacing not supported: %s', $file));
}
fread($f, 4);
$parms = '/DecodeParms <</Predictor 15 /Colors ' . ($ct == 2 ? 3 : 1).' /BitsPerComponent ' . $bpc . ' /Columns ' . $width.'>>';
/* Scan chunks looking for palette, transparency and image data. */
$pal = '';
$trns = '';
$data = '';
do {
$n = $this->_freadInt($f);
$type = fread($f, 4);
if ($type == 'PLTE') {
/* Read palette */
$pal = fread($f, $n);
fread($f, 4);
} elseif ($type == 'tRNS') {
/* Read transparency info */
$t = fread($f, $n);
if ($ct == 0) {
$trns = array(ord(substr($t, 1, 1)));
} elseif ($ct == 2) {
$trns = array(ord(substr($t, 1, 1)), ord(substr($t, 3, 1)), ord(substr($t, 5, 1)));
} else {
$pos = strpos($t, chr(0));
if (is_int($pos)) {
$trns = array($pos);
}
}
fread($f, 4);
} elseif ($type == 'IDAT') {
/* Read image data block */
$data .= fread($f, $n);
fread($f, 4);
} elseif ($type == 'IEND') {
break;
} else {
fread($f, $n + 4);
}
} while ($n);
 
if ($colspace == 'Indexed' && empty($pal)) {
return $this->raiseError(sprintf('Missing palette in: %s', $file));
}
fclose($f);
 
return array('w' => $width, 'h' => $height, 'cs' => $colspace, 'bpc' => $bpc, 'f' => 'FlateDecode', 'parms' => $parms, 'pal' => $pal, 'trns' => $trns, 'data' => $data);
}
 
function _freadInt($f)
{
/* Read a 4-byte integer from file. */
$i = ord(fread($f, 1)) << 24;
$i += ord(fread($f, 1)) << 16;
$i += ord(fread($f, 1)) << 8;
$i += ord(fread($f, 1));
return $i;
}
 
function _textString($s)
{
/* Format a text string */
return '(' . $this->_escape($s) . ')';
}
 
function _escape($s)
{
/* Add \ before \, ( and ) */
return str_replace(array(')','(','\\'),
array('\\)','\\(','\\\\'),
$s);
}
 
function _putStream($s)
{
$this->_out('stream');
$this->_out($s);
$this->_out('endstream');
}
 
function _out($s)
{
/* Add a line to the document. */
if ($this->_state == 2) {
$this->_pages[$this->_page] .= $s . "\n";
} else {
$this->_buffer .= $s . "\n";
}
}
 
}
/tags/v3.1-blanche-neige/jrest/lib/SpreadsheetProductor.php
New file
0,0 → 1,15
<?php
 
 
Class SpreadsheetProductor {
function initSpreadsheet() {
require_once("Spreadsheet/Excel/Writer.php");
}
}
 
 
?>
/tags/v3.1-blanche-neige/jrest/lib/PDFProductor.php
New file
0,0 → 1,14
<?php
 
 
Class PDFProductor {
function initPDF() {
require_once("PDF.php");
}
}
 
 
?>
/tags/v3.1-blanche-neige/jrest/lib/WdHTMLParser.php
New file
0,0 → 1,144
<?php
/**
*
* @author Olivier Laviale
* @see http://www.weirdog.com/blog/php/un-parser-html-des-plus-leger.html
*
*/
class WdHTMLParser {
private $encoding;
private $matches;
private $escaped;
private $opened = array();
public $malformed;
 
public function parse($html, $namespace=NULL, $encoding='utf-8') {
$this->malformed = false;
$this->encoding = $encoding;
// we take care of escaping comments and processing options. they will not be parsed
// and will end as text nodes
$html = $this->escapeSpecials($html);
// in order to create a tree, we first need to split the HTML using the markups,
// creating a nice flat array of texts and opening and closing markups.
//
// the array can be read as follows :
//
// i+0 => some text
// i+1 => '/' for closing markups, nothing otherwise
// i+2 => the markup it self, without the '<' '>'
//
// note that i+2 might end with a '/' indicating an auto-closing markup
$this->matches = preg_split('#<(/?)' . $namespace . '([^>]*)>#', $html, -1, PREG_SPLIT_DELIM_CAPTURE);
// the flat representation is now ready, we can create our tree
$tree = $this->buildTree();
 
// if comments or processing options where escaped, we can
// safely unescape them now
if ($this->escaped) {
$tree = $this->unescapeSpecials($tree);
}
return $tree;
}
private function escapeSpecials($html) {
// here we escape comments
$html = preg_replace_callback('#<\!--.+-->#sU', array($this, 'escapeSpecials_callback'), $html);
 
// and processing options
$html = preg_replace_callback('#<\?.+\?>#sU', array($this, 'escapeSpecials_callback'), $html);
return $html;
}
private function escapeSpecials_callback($m) {
$this->escaped = true;
$text = $m[0];
$text = str_replace(array('<', '>'), array("\x01", "\x02"), $text);
return $text;
}
 
private function unescapeSpecials($tree) {
return is_array($tree) ? array_map(array($this, 'unescapeSpecials'), $tree) : str_replace(array("\x01", "\x02"), array('<', '>'), $tree);
}
 
private function buildTree() {
$nodes = array();
$i = 0;
$text = NULL;
while (($value = array_shift($this->matches)) !== NULL) {
switch ($i++ % 3) {
case 0:
// if the trimed value is not empty we preserve the value,
// otherwise we discard it.
if (trim($value)){
$nodes[] = $value;
}
break;
case 1:
$closing = ($value == '/');
break;
case 2:
if (substr($value, -1, 1) == '/') {
// auto closing
$nodes[] = $this->parseMarkup(substr($value, 0, -1));
} else if ($closing) {
// closing markup
$open = array_pop($this->opened);
if ($value != $open) {
$this->error($value, $open);
}
 
return $nodes;
} else {
// this is an open markup with possible children
$node = $this->parseMarkup($value);
// push the markup name into the opened markups
$this->opened[] = $node['name'];
// create the node and parse its children
$node['children'] = $this->buildTree($this->matches);
$nodes[] = $node;
}
break;
}
}
return $nodes;
}
public function parseMarkup($markup) {
// get markup's name
preg_match('#^[^\s]+#', $markup, $matches);
$name = $matches[0];
 
// get markup's arguments
preg_match_all('#\s+([^=]+)\s*=\s*"([^"]+)"#', $markup, $matches, PREG_SET_ORDER);
// transform the matches into a nice key/value array
$args = array();
foreach ($matches as $m) {
// we unescape the html entities of the argument's value
$args[$m[1]] = html_entity_decode($m[2], ENT_QUOTES, $this->encoding);
}
 
return array('name' => $name, 'args' => $args);
}
public function error($markup, $expected) {
$this->malformed = true;
printf('unexpected closing markup "%s", should be "%s"', $markup, $expected);
}
}
 
?>
/tags/v3.1-blanche-neige/jrest/lib/Writer.php
New file
0,0 → 1,104
<?php
/*
* Module written/ported by Xavier Noguer <xnoguer@rezebra.com>
*
* PERL Spreadsheet::WriteExcel module.
*
* The author of the Spreadsheet::WriteExcel module is John McNamara
* <jmcnamara@cpan.org>
*
* I _DO_ maintain this code, and John McNamara has nothing to do with the
* porting of this code to PHP. Any questions directly related to this
* class library should be directed to me.
*
* License Information:
*
* Spreadsheet_Excel_Writer: A library for generating Excel Spreadsheets
* Copyright (c) 2002-2003 Xavier Noguer xnoguer@rezebra.com
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
 
require_once 'PEAR.php';
require_once 'Spreadsheet/Excel/Writer/Workbook.php';
 
/**
* Class for writing Excel Spreadsheets. This class should change COMPLETELY.
*
* @author Xavier Noguer <xnoguer@rezebra.com>
* @category FileFormats
* @package Spreadsheet_Excel_Writer
*/
 
class Spreadsheet_Excel_Writer extends Spreadsheet_Excel_Writer_Workbook
{
/**
* The constructor. It just creates a Workbook
*
* @param string $filename The optional filename for the Workbook.
* @return Spreadsheet_Excel_Writer_Workbook The Workbook created
*/
function Spreadsheet_Excel_Writer($filename = '')
{
$this->_filename = $filename;
$this->Spreadsheet_Excel_Writer_Workbook($filename);
}
 
/**
* Send HTTP headers for the Excel file.
*
* @param string $filename The filename to use for HTTP headers
* @access public
*/
function send($filename)
{
header("Content-type: application/vnd.ms-excel");
header("Content-Disposition: attachment; filename=\"$filename\"");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0,pre-check=0");
header("Pragma: public");
}
 
/**
* Utility function for writing formulas
* Converts a cell's coordinates to the A1 format.
*
* @access public
* @static
* @param integer $row Row for the cell to convert (0-indexed).
* @param integer $col Column for the cell to convert (0-indexed).
* @return string The cell identifier in A1 format
*/
function rowcolToCell($row, $col)
{
if ($col > 255) { //maximum column value exceeded
return new PEAR_Error("Maximum column value exceeded: $col");
}
 
$int = (int)($col / 26);
$frac = $col % 26;
$chr1 = '';
 
if ($int > 0) {
$chr1 = chr(ord('A') + $int - 1);
}
 
$chr2 = chr(ord('A') + $frac);
$row++;
 
return $chr1 . $chr2 . $row;
}
}
?>
/tags/v3.1-blanche-neige/jrest/lib/Log.php
New file
0,0 → 1,195
<?php
//declare(encoding='UTF-8');
/**
* Classe permettant de logger des messages dans les fichier situés dans le dossier de log
*
* PHP Version 5
*
* @category PHP
* @package Framework
* @author aurelien <aurelien@tela-botanica.org>
* @copyright 2009 Tela-Botanica
* @license http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL
* @version SVN: <svn_id>
* @link /doc/framework/
*/
 
class Log {
 
/**
* Tableau associatif stockant les descripteurs de fichiers
*/
private static $fichiersLog = array();
 
/**
* Chemin de base du dossier log de l'application
*/
private static $cheminLogs = '';
 
/**
* Booleen indiquant si l'on peut correctement écrire dans les fichiers de logs
*/
private static $droitLogger = true;
 
/**
* Zone horaire (pour éviter des avertissements dans les dates)
*/
private static $timeZone = '';
 
/**
* Taille maximum d'un fichier de log avant que celui ne soit archivé (en octets)
*/
private static $tailleMax = 10000;
 
/**
* séparateur de chemin
*/
private static $sd = DIRECTORY_SEPARATOR;
 
/**
* Extension des fichiers de log
*/
private static $ext = '.log';
 
/**
* La classe registre se contient elle-même, (pour le pattern singleton)
*/
private static $log;
 
/**
* Constructeur par défaut, privé, car on accède à la classe par le getInstance
*/
private function __construct() {
 
self::$sd = $sd;
// gestion de la timezone pour éviter des erreurs
if(function_exists("date_default_timezone_set") and function_exists("date_default_timezone_get")) {
date_default_timezone_set(self::$timeZone);
}
 
if(!is_dir(self::$cheminLogs) || !is_writable(self::$cheminLogs)) {
self::desactiverEcriture();
}
}
 
public static function setCheminLog($nouveauCheminLogs) {
self::$cheminLogs = $nouveauCheminLogs;
}
 
public static function getCheminLog() {
return self::$cheminLogs;
}
 
public static function setTimeZone($NouvelleTimeZone) {
self::$timeZone = $NouvelleTimeZone;
}
 
public static function setTailleMax($nouvelleTailleMax) {
self::$tailleMax = $nouvelleTailleMax;
}
 
/**
* Fonction qui renvoie l'instance de classe en assurant son unicité, c'est l'unique méthode qui doit être
* utilisée pour récupérer l'objet Registre
* @return Log le gestionnaire de log en cours
*/
public static function getInstance() {
if (self::$log instanceof Log) {
return self::$log;
}
self::$log = new Log();
return self::$log;
}
 
/**
* Ajoute une entrée au log spécifié par le paramètre $nomFichier
* @param string $nomFichier le nom du fichier dans lequel écrire
*/
public static function ajouterEntree($nomFichier,$entree,$mode='a+') {
if(self::$droitLogger) {
$date = "\n"."\n".date('d m Y H:i')."\n" ;
 
// si le fichier est déjà dans le tableau et qu'on peut y écrire
if(self::verifierOuvrirFichier($nomFichier,$mode)) {
// on y écrit le message de log
fwrite(self::$fichiersLog[$nomFichier],$date.$entree);
// on vérifie si le fichier ne dépasse pas la taille maximale
self::verifierTailleFichierOuArchiver($nomFichier);
} else {
// sinon on interdit l'écriture
self::desactiverEcriture($nomFichier);
}
}
}
 
/**
* Vide un fichier log indiqué
* @param string $nomFichier le nom du fichier à vider
*/
public static function viderLog($nomFichier) {
ajouterEntree($nomFichier,'','w');
}
 
/**
* Vérifie la présence d'un fichier dans le tableau, ses droits d'écriture,
* l'ouvre si nécessaire
* @param string $nomFichier le nom du fichier dont on doit vérifier la présence
* @return boolean true si le fichier est ouvert ou maintenant accessible, false sinon
*/
public static function verifierOuvrirFichier($nomFichier,$mode) {
// le fichier est il déjà ouvert ?
if(in_array($nomFichier,self::$fichiersLog)) {
// si oui peut on y écrire ?
if(is_writable(self::$cheminLogs.$nomFichier.self::$ext)) {
// si oui on renvoie le descripteur
return true;
}
return false;
} else {
// sinon on l'ouvre
$fp = @fopen(self::$cheminLogs.$nomFichier.self::$ext,$mode);
// si l'ouverture a réussi et si le fichier a les droits d'écriture
if($fp && is_writable(self::$cheminLogs.$nomFichier.self::$ext)) {
// si oui on renvoie le descripteur qu'on ajoute au tableau
self::$fichiersLog[$nomFichier] = $fp;
return true;
}
return false;
}
}
 
/**
* Vérifie la taille d'un fichier donné et si celle ci est trop importante
* archive le fichier de log
* @param string $nomFichier nom du fichier à vérifier
*/
private static function verifierTailleFichierOuArchiver($nomFichier) {
if(filesize(self::$cheminLogs.$nomFichier.self::$ext) > self::$tailleMax) {
rename(self::$cheminLogs.$nomFichier.self::$ext,self::$cheminLogs.$nomFichier.date('d_m_Y_H:i').self::$ext);
self::ajouterEntree($nomFichier,'');
}
}
 
/**
* Désactive l'écriture du log et envoie un message au gestionnaire d'erreurs
* @param string $nomFichier le nom du fichier qui a causé l'erreur
*/
private static function desactiverEcriture($nomFichier = '') {
self::$droitLogger = false;
if($nomFichier != '') {
$fichierDossier = 'fichier '.$nomFichier ;
} else {
$fichierDossier = 'dossier des logs';
}
}
 
/**
* destructeur de classe, ferme les descripteurs ouverts
*/
public function __destruct() {
foreach(self::$fichiersLog as $nomFichier => $fp) {
fclose($fp);
}
}
}
?>
/tags/v3.1-blanche-neige/jrest/lib/Spreadsheet/Excel/Writer.php
New file
0,0 → 1,75
<?php
/*
* Module written/ported by Xavier Noguer <xnoguer@rezebra.com>
*
* PERL Spreadsheet::WriteExcel module.
*
* The author of the Spreadsheet::WriteExcel module is John McNamara
* <jmcnamara@cpan.org>
*
* I _DO_ maintain this code, and John McNamara has nothing to do with the
* porting of this code to PHP. Any questions directly related to this
* class library should be directed to me.
*
* License Information:
*
* Spreadsheet_Excel_Writer: A library for generating Excel Spreadsheets
* Copyright (c) 2002-2003 Xavier Noguer xnoguer@rezebra.com
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
 
require_once('PEAR.php');
require_once('Writer/Workbook.php');
 
/**
* Class for writing Excel Spreadsheets. This class should change COMPLETELY.
*
* @author Xavier Noguer <xnoguer@rezebra.com>
* @category FileFormats
* @package Spreadsheet_Excel_Writer
*/
 
class Spreadsheet_Excel_Writer extends Spreadsheet_Excel_Writer_Workbook
{
/**
* The constructor. It just creates a Workbook
*
* @param string $filename The optional filename for the Workbook.
* @return Spreadsheet_Excel_Writer_Workbook The Workbook created
*/
function Spreadsheet_Excel_Writer($filename = '')
{
$this->_filename = $filename;
$this->Spreadsheet_Excel_Writer_Workbook($filename);
}
 
/**
* Send HTTP headers for the Excel file.
*
* @param string $filename The filename to use for HTTP headers
* @access public
*/
function send($filename)
{
header("Content-type: application/vnd.ms-excel");
header("Content-Disposition: attachment; filename=$filename");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0,pre-check=0");
header("Pragma: public");
}
 
}
?>
/tags/v3.1-blanche-neige/jrest/lib/Spreadsheet/Excel/Writer/BIFFwriter.php
New file
0,0 → 1,235
<?php
/*
* Module written/ported by Xavier Noguer <xnoguer@rezebra.com>
*
* The majority of this is _NOT_ my code. I simply ported it from the
* PERL Spreadsheet::WriteExcel module.
*
* The author of the Spreadsheet::WriteExcel module is John McNamara
* <jmcnamara@cpan.org>
*
* I _DO_ maintain this code, and John McNamara has nothing to do with the
* porting of this code to PHP. Any questions directly related to this
* class library should be directed to me.
*
* License Information:
*
* Spreadsheet_Excel_Writer: A library for generating Excel Spreadsheets
* Copyright (c) 2002-2003 Xavier Noguer xnoguer@rezebra.com
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
 
require_once('PEAR.php');
 
/**
* Class for writing Excel BIFF records.
*
* From "MICROSOFT EXCEL BINARY FILE FORMAT" by Mark O'Brien (Microsoft Corporation):
*
* BIFF (BInary File Format) is the file format in which Excel documents are
* saved on disk. A BIFF file is a complete description of an Excel document.
* BIFF files consist of sequences of variable-length records. There are many
* different types of BIFF records. For example, one record type describes a
* formula entered into a cell; one describes the size and location of a
* window into a document; another describes a picture format.
*
* @author Xavier Noguer <xnoguer@rezebra.com>
* @category FileFormats
* @package Spreadsheet_Excel_Writer
*/
 
class Spreadsheet_Excel_Writer_BIFFwriter extends PEAR
{
/**
* The BIFF/Excel version (5).
* @var integer
*/
var $_BIFF_version = 0x0500;
 
/**
* The byte order of this architecture. 0 => little endian, 1 => big endian
* @var integer
*/
var $_byte_order;
 
/**
* The string containing the data of the BIFF stream
* @var string
*/
var $_data;
 
/**
* The size of the data in bytes. Should be the same as strlen($this->_data)
* @var integer
*/
var $_datasize;
 
/**
* The maximun length for a BIFF record. See _addContinue()
* @var integer
* @see _addContinue()
*/
var $_limit;
/**
* Constructor
*
* @access public
*/
function Spreadsheet_Excel_Writer_BIFFwriter()
{
$this->_byte_order = '';
$this->_data = '';
$this->_datasize = 0;
$this->_limit = 2080;
// Set the byte order
$this->_setByteOrder();
}
 
/**
* Determine the byte order and store it as class data to avoid
* recalculating it for each call to new().
*
* @access private
*/
function _setByteOrder()
{
if ($this->_byte_order == '')
{
// Check if "pack" gives the required IEEE 64bit float
$teststr = pack("d", 1.2345);
$number = pack("C8", 0x8D, 0x97, 0x6E, 0x12, 0x83, 0xC0, 0xF3, 0x3F);
if ($number == $teststr) {
$byte_order = 0; // Little Endian
}
elseif ($number == strrev($teststr)){
$byte_order = 1; // Big Endian
}
else {
// Give up. I'll fix this in a later version.
$this->raiseError("Required floating point format not supported ".
"on this platform.");
}
}
$this->_byte_order = $byte_order;
}
 
/**
* General storage function
*
* @param string $data binary data to prepend
* @access private
*/
function _prepend($data)
{
if (strlen($data) > $this->_limit) {
$data = $this->_addContinue($data);
}
$this->_data = $data.$this->_data;
$this->_datasize += strlen($data);
}
 
/**
* General storage function
*
* @param string $data binary data to append
* @access private
*/
function _append($data)
{
if (strlen($data) > $this->_limit) {
$data = $this->_addContinue($data);
}
$this->_data = $this->_data.$data;
$this->_datasize += strlen($data);
}
 
/**
* Writes Excel BOF record to indicate the beginning of a stream or
* sub-stream in the BIFF file.
*
* @param integer $type type of BIFF file to write: 0x0005 Workbook, 0x0010 Worksheet.
* @access private
*/
function _storeBof($type)
{
$record = 0x0809; // Record identifier
$length = 0x0008; // Number of bytes to follow
$version = $this->_BIFF_version;
// According to the SDK $build and $year should be set to zero.
// However, this throws a warning in Excel 5. So, use these
// magic numbers.
$build = 0x096C;
$year = 0x07C9;
$header = pack("vv", $record, $length);
$data = pack("vvvv", $version, $type, $build, $year);
$this->_prepend($header.$data);
}
 
/**
* Writes Excel EOF record to indicate the end of a BIFF stream.
*
* @access private
*/
function _storeEof()
{
$record = 0x000A; // Record identifier
$length = 0x0000; // Number of bytes to follow
$header = pack("vv", $record, $length);
$this->_append($header);
}
 
/**
* Excel limits the size of BIFF records. In Excel 5 the limit is 2084 bytes. In
* Excel 97 the limit is 8228 bytes. Records that are longer than these limits
* must be split up into CONTINUE blocks.
*
* This function takes a long BIFF record and inserts CONTINUE records as
* necessary.
*
* @param string $data The original binary data to be written
* @return string A very convenient string of continue blocks
* @access private
*/
function _addContinue($data)
{
$limit = $this->_limit;
$record = 0x003C; // Record identifier
// The first 2080/8224 bytes remain intact. However, we have to change
// the length field of the record.
$tmp = substr($data, 0, 2).pack("v", $limit-4).substr($data, 4, $limit - 4);
$header = pack("vv", $record, $limit); // Headers for continue records
// Retrieve chunks of 2080/8224 bytes +4 for the header.
for($i = $limit; $i < strlen($data) - $limit; $i += $limit)
{
$tmp .= $header;
$tmp .= substr($data, $i, $limit);
}
// Retrieve the last chunk of data
$header = pack("vv", $record, strlen($data) - $i);
$tmp .= $header;
$tmp .= substr($data,$i,strlen($data) - $i);
return($tmp);
}
}
?>
/tags/v3.1-blanche-neige/jrest/lib/Spreadsheet/Excel/Writer/Format.php
New file
0,0 → 1,940
<?php
/*
* Module written/ported by Xavier Noguer <xnoguer@rezebra.com>
*
* The majority of this is _NOT_ my code. I simply ported it from the
* PERL Spreadsheet::WriteExcel module.
*
* The author of the Spreadsheet::WriteExcel module is John McNamara
* <jmcnamara@cpan.org>
*
* I _DO_ maintain this code, and John McNamara has nothing to do with the
* porting of this code to PHP. Any questions directly related to this
* class library should be directed to me.
*
* License Information:
*
* Spreadsheet_Excel_Writer: A library for generating Excel Spreadsheets
* Copyright (c) 2002-2003 Xavier Noguer xnoguer@rezebra.com
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
 
require_once('PEAR.php');
 
/**
* Class for generating Excel XF records (formats)
*
* @author Xavier Noguer <xnoguer@rezebra.com>
* @category FileFormats
* @package Spreadsheet_Excel_Writer
*/
 
class Spreadsheet_Excel_Writer_Format extends PEAR
{
/**
* The index given by the workbook when creating a new format.
* @var integer
*/
var $_xf_index;
 
/**
* Index to the FONT record.
* @var integer
*/
var $font_index;
 
/**
* The font name (ASCII).
* @var string
*/
var $_font_name;
 
/**
* Height of font (1/20 of a point)
* @var integer
*/
var $_size;
 
/**
* Bold style
* @var integer
*/
var $_bold;
 
/**
* Bit specifiying if the font is italic.
* @var integer
*/
var $_italic;
 
/**
* Index to the cell's color
* @var integer
*/
var $_color;
 
/**
* The text underline property
* @var integer
*/
var $_underline;
 
/**
* Bit specifiying if the font has strikeout.
* @var integer
*/
var $_font_strikeout;
 
/**
* Bit specifiying if the font has outline.
* @var integer
*/
var $_font_outline;
 
/**
* Bit specifiying if the font has shadow.
* @var integer
*/
var $_font_shadow;
 
/**
* 2 bytes specifiying the script type for the font.
* @var integer
*/
var $_font_script;
 
/**
* Byte specifiying the font family.
* @var integer
*/
var $_font_family;
 
/**
* Byte specifiying the font charset.
* @var integer
*/
var $_font_charset;
 
/**
* An index (2 bytes) to a FORMAT record (number format).
* @var integer
*/
var $_num_format;
 
/**
* Bit specifying if formulas are hidden.
* @var integer
*/
var $_hidden;
 
/**
* Bit specifying if the cell is locked.
* @var integer
*/
var $_locked;
 
/**
* The three bits specifying the text horizontal alignment.
* @var integer
*/
var $_text_h_align;
 
/**
* Bit specifying if the text is wrapped at the right border.
* @var integer
*/
var $_text_wrap;
 
/**
* The three bits specifying the text vertical alignment.
* @var integer
*/
var $_text_v_align;
 
/**
* 1 bit, apparently not used.
* @var integer
*/
var $_text_justlast;
 
/**
* The two bits specifying the text rotation.
* @var integer
*/
var $_rotation;
 
/**
* The cell's foreground color.
* @var integer
*/
var $_fg_color;
 
/**
* The cell's background color.
* @var integer
*/
var $_bg_color;
 
/**
* The cell's background fill pattern.
* @var integer
*/
var $_pattern;
 
/**
* Style of the bottom border of the cell
* @var integer
*/
var $_bottom;
 
/**
* Color of the bottom border of the cell.
* @var integer
*/
var $_bottom_color;
 
/**
* Style of the top border of the cell
* @var integer
*/
var $_top;
 
/**
* Color of the top border of the cell.
* @var integer
*/
var $_top_color;
 
/**
* Style of the left border of the cell
* @var integer
*/
var $_left;
 
/**
* Color of the left border of the cell.
* @var integer
*/
var $_left_color;
 
/**
* Style of the right border of the cell
* @var integer
*/
var $_right;
 
/**
* Color of the right border of the cell.
* @var integer
*/
var $_right_color;
 
/**
* Constructor
*
* @access public
* @param integer $index the XF index for the format.
* @param array $properties array with properties to be set on initialization.
*/
function Spreadsheet_Excel_Writer_Format($index = 0,$properties = array())
{
$this->_xf_index = $index;
$this->font_index = 0;
$this->_font_name = 'Arial';
$this->_size = 10;
$this->_bold = 0x0190;
$this->_italic = 0;
$this->_color = 0x7FFF;
$this->_underline = 0;
$this->_font_strikeout = 0;
$this->_font_outline = 0;
$this->_font_shadow = 0;
$this->_font_script = 0;
$this->_font_family = 0;
$this->_font_charset = 0;
$this->_num_format = 0;
$this->_hidden = 0;
$this->_locked = 1;
 
$this->_text_h_align = 0;
$this->_text_wrap = 0;
$this->_text_v_align = 2;
$this->_text_justlast = 0;
$this->_rotation = 0;
 
$this->_fg_color = 0x40;
$this->_bg_color = 0x41;
 
$this->_pattern = 0;
$this->_bottom = 0;
$this->_top = 0;
$this->_left = 0;
$this->_right = 0;
$this->_bottom_color = 0x40;
$this->_top_color = 0x40;
$this->_left_color = 0x40;
$this->_right_color = 0x40;
// Set properties passed to Spreadsheet_Excel_Writer_Workbook::addFormat()
foreach($properties as $property => $value)
{
if(method_exists($this,'set'.ucwords($property)))
{
$method_name = 'set'.ucwords($property);
$this->$method_name($value);
}
}
}
 
 
/**
* Generate an Excel BIFF XF record (style or cell).
*
* @param string $style The type of the XF record ('style' or 'cell').
* @return string The XF record
*/
function getXf($style)
{
// Set the type of the XF record and some of the attributes.
if ($style == "style") {
$style = 0xFFF5;
}
else {
$style = $this->_locked;
$style |= $this->_hidden << 1;
}
// Flags to indicate if attributes have been set.
$atr_num = ($this->_num_format != 0)?1:0;
$atr_fnt = ($this->font_index != 0)?1:0;
$atr_alc = ($this->_text_wrap)?1:0;
$atr_bdr = ($this->_bottom ||
$this->_top ||
$this->_left ||
$this->_right)?1:0;
$atr_pat = (($this->_fg_color != 0x40) ||
($this->_bg_color != 0x41) ||
$this->_pattern)?1:0;
$atr_prot = 0;
// Zero the default border colour if the border has not been set.
if ($this->_bottom == 0) {
$this->_bottom_color = 0;
}
if ($this->_top == 0) {
$this->_top_color = 0;
}
if ($this->_right == 0) {
$this->_right_color = 0;
}
if ($this->_left == 0) {
$this->_left_color = 0;
}
$record = 0x00E0; // Record identifier
$length = 0x0010; // Number of bytes to follow
$ifnt = $this->font_index; // Index to FONT record
$ifmt = $this->_num_format; // Index to FORMAT record
$align = $this->_text_h_align; // Alignment
$align |= $this->_text_wrap << 3;
$align |= $this->_text_v_align << 4;
$align |= $this->_text_justlast << 7;
$align |= $this->_rotation << 8;
$align |= $atr_num << 10;
$align |= $atr_fnt << 11;
$align |= $atr_alc << 12;
$align |= $atr_bdr << 13;
$align |= $atr_pat << 14;
$align |= $atr_prot << 15;
$icv = $this->_fg_color; // fg and bg pattern colors
$icv |= $this->_bg_color << 7;
$fill = $this->_pattern; // Fill and border line style
$fill |= $this->_bottom << 6;
$fill |= $this->_bottom_color << 9;
$border1 = $this->_top; // Border line style and color
$border1 |= $this->_left << 3;
$border1 |= $this->_right << 6;
$border1 |= $this->_top_color << 9;
$border2 = $this->_left_color; // Border color
$border2 |= $this->_right_color << 7;
$header = pack("vv", $record, $length);
$data = pack("vvvvvvvv", $ifnt, $ifmt, $style, $align,
$icv, $fill,
$border1, $border2);
return($header.$data);
}
/**
* Generate an Excel BIFF FONT record.
*
* @return string The FONT record
*/
function getFont()
{
$dyHeight = $this->_size * 20; // Height of font (1/20 of a point)
$icv = $this->_color; // Index to color palette
$bls = $this->_bold; // Bold style
$sss = $this->_font_script; // Superscript/subscript
$uls = $this->_underline; // Underline
$bFamily = $this->_font_family; // Font family
$bCharSet = $this->_font_charset; // Character set
$rgch = $this->_font_name; // Font name
$cch = strlen($rgch); // Length of font name
$record = 0x31; // Record identifier
$length = 0x0F + $cch; // Record length
$reserved = 0x00; // Reserved
$grbit = 0x00; // Font attributes
if ($this->_italic) {
$grbit |= 0x02;
}
if ($this->_font_strikeout) {
$grbit |= 0x08;
}
if ($this->_font_outline) {
$grbit |= 0x10;
}
if ($this->_font_shadow) {
$grbit |= 0x20;
}
$header = pack("vv", $record, $length);
$data = pack("vvvvvCCCCC", $dyHeight, $grbit, $icv, $bls,
$sss, $uls, $bFamily,
$bCharSet, $reserved, $cch);
return($header . $data. $this->_font_name);
}
/**
* Returns a unique hash key for a font.
* Used by Spreadsheet_Excel_Writer_Workbook::_storeAllFonts()
*
* The elements that form the key are arranged to increase the probability of
* generating a unique key. Elements that hold a large range of numbers
* (eg. _color) are placed between two binary elements such as _italic
*
* @return string A key for this font
*/
function getFontKey()
{
$key = "$this->_font_name$this->_size";
$key .= "$this->_font_script$this->_underline";
$key .= "$this->_font_strikeout$this->_bold$this->_font_outline";
$key .= "$this->_font_family$this->_font_charset";
$key .= "$this->_font_shadow$this->_color$this->_italic";
$key = str_replace(" ","_",$key);
return ($key);
}
/**
* Returns the index used by Spreadsheet_Excel_Writer_Worksheet::_XF()
*
* @return integer The index for the XF record
*/
function getXfIndex()
{
return($this->_xf_index);
}
/**
* Used in conjunction with the set_xxx_color methods to convert a color
* string into a number. Color range is 0..63 but we will restrict it
* to 8..63 to comply with Gnumeric. Colors 0..7 are repeated in 8..15.
*
* @access private
* @param string $name_color name of the color (i.e.: 'blue', 'red', etc..). Optional.
* @return integer The color index
*/
function _getColor($name_color = '')
{
$colors = array(
'aqua' => 0x0F,
'cyan' => 0x0F,
'black' => 0x08,
'blue' => 0x0C,
'brown' => 0x10,
'magenta' => 0x0E,
'fuchsia' => 0x0E,
'gray' => 0x17,
'grey' => 0x17,
'green' => 0x11,
'lime' => 0x0B,
'navy' => 0x12,
'orange' => 0x35,
'purple' => 0x14,
'red' => 0x0A,
'silver' => 0x16,
'white' => 0x09,
'yellow' => 0x0D
);
// Return the default color, 0x7FFF, if undef,
if($name_color == '') {
return(0x7FFF);
}
// or the color string converted to an integer,
if(isset($colors[$name_color])) {
return($colors[$name_color]);
}
// or the default color if string is unrecognised,
if(preg_match("/\D/",$name_color)) {
return(0x7FFF);
}
// or an index < 8 mapped into the correct range,
if($name_color < 8) {
return($name_color + 8);
}
// or the default color if arg is outside range,
if($name_color > 63) {
return(0x7FFF);
}
// or an integer in the valid range
return($name_color);
}
/**
* Set cell alignment.
*
* @access public
* @param string $location alignment for the cell ('left', 'right', etc...).
*/
function setAlign($location)
{
if (preg_match("/\d/",$location)) {
return; // Ignore numbers
}
$location = strtolower($location);
if ($location == 'left') {
$this->_text_h_align = 1;
}
if ($location == 'centre') {
$this->_text_h_align = 2;
}
if ($location == 'center') {
$this->_text_h_align = 2;
}
if ($location == 'right') {
$this->_text_h_align = 3;
}
if ($location == 'fill') {
$this->_text_h_align = 4;
}
if ($location == 'justify') {
$this->_text_h_align = 5;
}
if ($location == 'merge') {
$this->_text_h_align = 6;
}
if ($location == 'equal_space') { // For T.K.
$this->_text_h_align = 7;
}
if ($location == 'top') {
$this->_text_v_align = 0;
}
if ($location == 'vcentre') {
$this->_text_v_align = 1;
}
if ($location == 'vcenter') {
$this->_text_v_align = 1;
}
if ($location == 'bottom') {
$this->_text_v_align = 2;
}
if ($location == 'vjustify') {
$this->_text_v_align = 3;
}
if ($location == 'vequal_space') { // For T.K.
$this->_text_v_align = 4;
}
}
/**
* This is an alias for the unintuitive setAlign('merge')
*
* @access public
*/
function setMerge()
{
$this->setAlign('merge');
}
/**
* Sets the boldness of the text.
* Bold has a range 100..1000.
* 0 (400) is normal. 1 (700) is bold.
*
* @access public
* @param integer $weight Weight for the text, 0 maps to 400 (normal text),
1 maps to 700 (bold text). Valid range is: 100-1000.
It's Optional, default is 1 (bold).
*/
function setBold($weight = 1)
{
if($weight == 1) {
$weight = 0x2BC; // Bold text
}
if($weight == 0) {
$weight = 0x190; // Normal text
}
if($weight < 0x064) {
$weight = 0x190; // Lower bound
}
if($weight > 0x3E8) {
$weight = 0x190; // Upper bound
}
$this->_bold = $weight;
}
/************************************
* FUNCTIONS FOR SETTING CELLS BORDERS
*/
/**
* Sets the width for the bottom border of the cell
*
* @access public
* @param integer $style style of the cell border. 1 => thin, 2 => thick.
*/
function setBottom($style)
{
$this->_bottom = $style;
}
/**
* Sets the width for the top border of the cell
*
* @access public
* @param integer $style style of the cell top border. 1 => thin, 2 => thick.
*/
function setTop($style)
{
$this->_top = $style;
}
/**
* Sets the width for the left border of the cell
*
* @access public
* @param integer $style style of the cell left border. 1 => thin, 2 => thick.
*/
function setLeft($style)
{
$this->_left = $style;
}
/**
* Sets the width for the right border of the cell
*
* @access public
* @param integer $style style of the cell right border. 1 => thin, 2 => thick.
*/
function setRight($style)
{
$this->_right = $style;
}
/**
* Set cells borders to the same style
*
* @access public
* @param integer $style style to apply for all cell borders. 1 => thin, 2 => thick.
*/
function setBorder($style)
{
$this->setBottom($style);
$this->setTop($style);
$this->setLeft($style);
$this->setRight($style);
}
/*******************************************
* FUNCTIONS FOR SETTING CELLS BORDERS COLORS
*/
/**
* Sets all the cell's borders to the same color
*
* @access public
* @param mixed $color The color we are setting. Either a string (like 'blue'),
* or an integer (range is [8...63]).
*/
function setBorderColor($color)
{
$this->setBottomColor($color);
$this->setTopColor($color);
$this->setLeftColor($color);
$this->setRightColor($color);
}
/**
* Sets the cell's bottom border color
*
* @access public
* @param mixed $color either a string (like 'blue'), or an integer (range is [8...63]).
*/
function setBottomColor($color)
{
$value = $this->_getColor($color);
$this->_bottom_color = $value;
}
/**
* Sets the cell's top border color
*
* @access public
* @param mixed $color either a string (like 'blue'), or an integer (range is [8...63]).
*/
function setTopColor($color)
{
$value = $this->_getColor($color);
$this->_top_color = $value;
}
/**
* Sets the cell's left border color
*
* @access public
* @param mixed $color either a string (like 'blue'), or an integer (range is [8...63]).
*/
function setLeftColor($color)
{
$value = $this->_getColor($color);
$this->_left_color = $value;
}
/**
* Sets the cell's right border color
*
* @access public
* @param mixed $color either a string (like 'blue'), or an integer (range is [8...63]).
*/
function setRightColor($color)
{
$value = $this->_getColor($color);
$this->_right_color = $value;
}
/**
* Sets the cell's foreground color
*
* @access public
* @param mixed $color either a string (like 'blue'), or an integer (range is [8...63]).
*/
function setFgColor($color)
{
$value = $this->_getColor($color);
$this->_fg_color = $value;
}
/**
* Sets the cell's background color
*
* @access public
* @param mixed $color either a string (like 'blue'), or an integer (range is [8...63]).
*/
function setBgColor($color)
{
$value = $this->_getColor($color);
$this->_bg_color = $value;
}
/**
* Sets the cell's color
*
* @access public
* @param mixed $color either a string (like 'blue'), or an integer (range is [8...63]).
*/
function setColor($color)
{
$value = $this->_getColor($color);
$this->_color = $value;
}
/**
* Sets the fill pattern attribute of a cell
*
* @access public
* @param integer $arg Optional. Defaults to 1. Meaningful values are: 0-18,
* 0 meaning no background.
*/
function setPattern($arg = 1)
{
$this->_pattern = $arg;
}
/**
* Sets the underline of the text
*
* @access public
* @param integer $underline The value for underline. Possible values are:
* 1 => underline, 2 => double underline.
*/
function setUnderline($underline)
{
$this->_underline = $underline;
}
/**
* Sets the font style as italic
*
* @access public
*/
function setItalic()
{
$this->_italic = 1;
}
 
/**
* Sets the font size
*
* @access public
* @param integer $size The font size (in pixels I think).
*/
function setSize($size)
{
$this->_size = $size;
}
/**
* Sets text wrapping
*
* @access public
*/
function setTextWrap()
{
$this->_text_wrap = 1;
}
 
/**
* Sets the orientation of the text
*
* @access public
* @param integer $angle The rotation angle for the text (clockwise). Possible
values are: 0, 90, 270 and -1 for stacking top-to-bottom.
*/
function setTextRotation($angle)
{
switch ($angle)
{
case 0:
$this->_rotation = 0;
break;
case 90:
$this->_rotation = 3;
break;
case 270:
$this->_rotation = 2;
break;
case -1:
$this->_rotation = 1;
break;
default :
$this->raiseError("Invalid value for angle.".
" Possible values are: 0, 90, 270 and -1 ".
"for stacking top-to-bottom.");
$this->_rotation = 0;
break;
}
}
 
/**
* Sets the numeric format.
* It can be date, time, currency, etc...
*
* @access public
* @param integer $num_format The numeric format.
*/
function setNumFormat($num_format)
{
$this->_num_format = $num_format;
}
 
/**
* Sets font as strikeout.
*
* @access public
*/
function setStrikeOut()
{
$this->_font_strikeout = 1;
}
 
/**
* Sets outlining for a font.
*
* @access public
*/
function setOutLine()
{
$this->_font_outline = 1;
}
 
/**
* Sets font as shadow.
*
* @access public
*/
function setShadow()
{
$this->_font_shadow = 1;
}
 
/**
* Sets the script type of the text
*
* @access public
* @param integer $script The value for script type. Possible values are:
* 1 => superscript, 2 => subscript.
*/
function setScript($script)
{
$this->_font_script = $script;
}
 
/**
* Unlocks a cell. Useful for unprotecting particular cells of a protected sheet.
*
* @access public
*/
function setUnLocked()
{
$this->_locked = 0;
}
}
?>
/tags/v3.1-blanche-neige/jrest/lib/Spreadsheet/Excel/Writer/Worksheet.php
New file
0,0 → 1,3095
<?php
/*
* Module written/ported by Xavier Noguer <xnoguer@rezebra.com>
*
* The majority of this is _NOT_ my code. I simply ported it from the
* PERL Spreadsheet::WriteExcel module.
*
* The author of the Spreadsheet::WriteExcel module is John McNamara
* <jmcnamara@cpan.org>
*
* I _DO_ maintain this code, and John McNamara has nothing to do with the
* porting of this code to PHP. Any questions directly related to this
* class library should be directed to me.
*
* License Information:
*
* Spreadsheet_Excel_Writer: A library for generating Excel Spreadsheets
* Copyright (c) 2002-2003 Xavier Noguer xnoguer@rezebra.com
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
 
require_once('Parser.php');
require_once('BIFFwriter.php');
 
/**
* Class for generating Excel Spreadsheets
*
* @author Xavier Noguer <xnoguer@rezebra.com>
* @category FileFormats
* @package Spreadsheet_Excel_Writer
*/
 
class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwriter
{
/**
* Name of the Worksheet
* @var string
*/
var $name;
 
/**
* Index for the Worksheet
* @var integer
*/
var $index;
 
/**
* Reference to the (default) Format object for URLs
* @var object Format
*/
var $_url_format;
 
/**
* Reference to the parser used for parsing formulas
* @var object Format
*/
var $_parser;
 
/**
* Filehandle to the temporary file for storing data
* @var resource
*/
var $_filehandle;
 
/**
* Boolean indicating if we are using a temporary file for storing data
* @var bool
*/
var $_using_tmpfile;
 
/**
* Maximum number of rows for an Excel spreadsheet (BIFF5)
* @var integer
*/
var $_xls_rowmax;
 
/**
* Maximum number of columns for an Excel spreadsheet (BIFF5)
* @var integer
*/
var $_xls_colmax;
 
/**
* Maximum number of characters for a string (LABEL record in BIFF5)
* @var integer
*/
var $_xls_strmax;
 
/**
* First row for the DIMENSIONS record
* @var integer
* @see storeDimensions()
*/
var $_dim_rowmin;
 
/**
* Last row for the DIMENSIONS record
* @var integer
* @see storeDimensions()
*/
var $_dim_rowmax;
 
/**
* First column for the DIMENSIONS record
* @var integer
* @see storeDimensions()
*/
var $_dim_colmin;
 
/**
* Last column for the DIMENSIONS record
* @var integer
* @see storeDimensions()
*/
var $_dim_colmax;
 
/**
* Array containing format information for columns
* @var array
*/
var $_colinfo;
 
/**
* Array containing the selected area for the worksheet
* @var array
*/
var $_selection;
 
/**
* Array containing the panes for the worksheet
* @var array
*/
var $_panes;
 
/**
* The active pane for the worksheet
* @var integer
*/
var $_active_pane;
 
/**
* Bit specifying if panes are frozen
* @var integer
*/
var $_frozen;
 
/**
* Bit specifying if the worksheet is selected
* @var integer
*/
var $selected;
 
/**
* The paper size (for printing) (DOCUMENT!!!)
* @var integer
*/
var $_paper_size;
 
/**
* Bit specifying paper orientation (for printing). 0 => landscape, 1 => portrait
* @var integer
*/
var $_orientation;
 
/**
* The page header caption
* @var string
*/
var $_header;
 
/**
* The page footer caption
* @var string
*/
var $_footer;
 
/**
* The horizontal centering value for the page
* @var integer
*/
var $_hcenter;
 
/**
* The vertical centering value for the page
* @var integer
*/
var $_vcenter;
 
/**
* The margin for the header
* @var float
*/
var $_margin_head;
 
/**
* The margin for the footer
* @var float
*/
var $_margin_foot;
 
/**
* The left margin for the worksheet in inches
* @var float
*/
var $_margin_left;
 
/**
* The right margin for the worksheet in inches
* @var float
*/
var $_margin_right;
 
/**
* The top margin for the worksheet in inches
* @var float
*/
var $_margin_top;
 
/**
* The bottom margin for the worksheet in inches
* @var float
*/
var $_margin_bottom;
 
/**
* First row to reapeat on each printed page
* @var integer
*/
var $title_rowmin;
 
/**
* Last row to reapeat on each printed page
* @var integer
*/
var $title_rowmax;
 
/**
* First column to reapeat on each printed page
* @var integer
*/
var $title_colmin;
 
/**
* First row of the area to print
* @var integer
*/
var $print_rowmin;
 
/**
* Last row to of the area to print
* @var integer
*/
var $print_rowmax;
 
/**
* First column of the area to print
* @var integer
*/
var $print_colmin;
 
/**
* Last column of the area to print
* @var integer
*/
var $print_colmax;
 
/**
* Constructor
*
* @param string $name The name of the new worksheet
* @param integer $index The index of the new worksheet
* @param mixed &$activesheet The current activesheet of the workbook we belong to
* @param mixed &$firstsheet The first worksheet in the workbook we belong to
* @param mixed &$url_format The default format for hyperlinks
* @param mixed &$parser The formula parser created for the Workbook
*/
function Spreadsheet_Excel_Writer_Worksheet($name, $index, &$activesheet,
&$firstsheet, &$url_format,
&$parser)
{
// It needs to call its parent's constructor explicitly
$this->Spreadsheet_Excel_Writer_BIFFwriter();
$rowmax = 65536; // 16384 in Excel 5
$colmax = 256;
$this->name = $name;
$this->index = $index;
$this->activesheet = &$activesheet;
$this->firstsheet = &$firstsheet;
$this->_url_format = &$url_format;
$this->_parser = &$parser;
//$this->ext_sheets = array();
$this->_filehandle = "";
$this->_using_tmpfile = true;
//$this->fileclosed = 0;
//$this->offset = 0;
$this->_xls_rowmax = $rowmax;
$this->_xls_colmax = $colmax;
$this->_xls_strmax = 255;
$this->_dim_rowmin = $rowmax + 1;
$this->_dim_rowmax = 0;
$this->_dim_colmin = $colmax + 1;
$this->_dim_colmax = 0;
$this->_colinfo = array();
$this->_selection = array(0,0,0,0);
$this->_panes = array();
$this->_active_pane = 3;
$this->_frozen = 0;
$this->selected = 0;
$this->_paper_size = 0x0;
$this->_orientation = 0x1;
$this->_header = '';
$this->_footer = '';
$this->_hcenter = 0;
$this->_vcenter = 0;
$this->_margin_head = 0.50;
$this->_margin_foot = 0.50;
$this->_margin_left = 0.75;
$this->_margin_right = 0.75;
$this->_margin_top = 1.00;
$this->_margin_bottom = 1.00;
$this->title_rowmin = NULL;
$this->title_rowmax = NULL;
$this->title_colmin = NULL;
$this->title_colmax = NULL;
$this->print_rowmin = NULL;
$this->print_rowmax = NULL;
$this->print_colmin = NULL;
$this->print_colmax = NULL;
$this->_print_gridlines = 1;
$this->_print_headers = 0;
$this->_fit_page = 0;
$this->_fit_width = 0;
$this->_fit_height = 0;
$this->_hbreaks = array();
$this->_vbreaks = array();
$this->_protect = 0;
$this->_password = NULL;
$this->col_sizes = array();
$this->row_sizes = array();
$this->_zoom = 100;
$this->_print_scale = 100;
$this->_initialize();
}
/**
* Open a tmp file to store the majority of the Worksheet data. If this fails,
* for example due to write permissions, store the data in memory. This can be
* slow for large files.
*
* @access private
*/
function _initialize()
{
// Open tmp file for storing Worksheet data
$fh = tmpfile();
if ( $fh) {
// Store filehandle
$this->_filehandle = $fh;
}
else {
// If tmpfile() fails store data in memory
$this->_using_tmpfile = false;
}
}
/**
* Add data to the beginning of the workbook (note the reverse order)
* and to the end of the workbook.
*
* @access public
* @see Spreadsheet_Excel_Writer_Workbook::storeWorkbook()
* @param array $sheetnames The array of sheetnames from the Workbook this
* worksheet belongs to
*/
function close($sheetnames)
{
$num_sheets = count($sheetnames);
/***********************************************
* Prepend in reverse order!!
*/
// Prepend the sheet dimensions
$this->storeDimensions();
// Prepend the sheet password
$this->_storePassword();
// Prepend the sheet protection
$this->_storeProtect();
// Prepend the page setup
$this->_storeSetup();
// Prepend the bottom margin
$this->_storeMarginBottom();
// Prepend the top margin
$this->_storeMarginTop();
// Prepend the right margin
$this->_storeMarginRight();
// Prepend the left margin
$this->_storeMarginLeft();
// Prepend the page vertical centering
$this->_storeVcenter();
// Prepend the page horizontal centering
$this->_storeHcenter();
// Prepend the page footer
$this->_storeFooter();
// Prepend the page header
$this->_storeHeader();
// Prepend the vertical page breaks
$this->_storeVbreak();
// Prepend the horizontal page breaks
$this->_storeHbreak();
// Prepend WSBOOL
$this->_storeWsbool();
// Prepend GRIDSET
$this->_storeGridset();
// Prepend PRINTGRIDLINES
$this->_storePrintGridlines();
// Prepend PRINTHEADERS
$this->_storePrintHeaders();
// Prepend EXTERNSHEET references
for ($i = $num_sheets; $i > 0; $i--)
{
$sheetname = $sheetnames[$i-1];
$this->_storeExternsheet($sheetname);
}
// Prepend the EXTERNCOUNT of external references.
$this->_storeExterncount($num_sheets);
// Prepend the COLINFO records if they exist
if (!empty($this->_colinfo))
{
for($i=0; $i < count($this->_colinfo); $i++) {
$this->_storeColinfo($this->_colinfo[$i]);
}
$this->_storeDefcol();
}
// Prepend the BOF record
$this->_storeBof(0x0010);
/*
* End of prepend. Read upwards from here.
***********************************************/
// Append
$this->_storeWindow2();
$this->_storeZoom();
if (!empty($this->_panes)) {
$this->_storePanes($this->_panes);
}
$this->_storeSelection($this->_selection);
$this->_storeEof();
}
/**
* Retrieve the worksheet name.
* This is usefull when creating worksheets without a name.
*
* @access public
* @return string The worksheet's name
*/
function getName()
{
return $this->name;
}
/**
* Retrieves data from memory in one chunk, or from disk in $buffer
* sized chunks.
*
* @return string The data
*/
function getData()
{
$buffer = 4096;
// Return data stored in memory
if (isset($this->_data))
{
$tmp = $this->_data;
unset($this->_data);
$fh = $this->_filehandle;
if ($this->_using_tmpfile) {
fseek($fh, 0);
}
return($tmp);
}
// Return data stored on disk
if ($this->_using_tmpfile)
{
if ($tmp = fread($this->_filehandle, $buffer)) {
return($tmp);
}
}
// No data to return
return('');
}
/**
* Set this worksheet as a selected worksheet,
* i.e. the worksheet has its tab highlighted.
*
* @access public
*/
function select()
{
$this->selected = 1;
}
/**
* Set this worksheet as the active worksheet,
* i.e. the worksheet that is displayed when the workbook is opened.
* Also set it as selected.
*
* @access public
*/
function activate()
{
$this->selected = 1;
$this->activesheet = $this->index;
}
/**
* Set this worksheet as the first visible sheet.
* This is necessary when there are a large number of worksheets and the
* activated worksheet is not visible on the screen.
*
* @access public
*/
function setFirstSheet()
{
$this->firstsheet = $this->index;
}
/**
* Set the worksheet protection flag
* to prevent accidental modification and to
* hide formulas if the locked and hidden format properties have been set.
*
* @access public
* @param string $password The password to use for protecting the sheet.
*/
function protect($password)
{
$this->_protect = 1;
$this->_password = $this->_encodePassword($password);
}
/**
* Set the width of a single column or a range of columns.
*
* @access public
* @param integer $firstcol first column on the range
* @param integer $lastcol last column on the range
* @param integer $width width to set
* @param mixed $format The optional XF format to apply to the columns
* @param integer $hidden The optional hidden atribute
*/
function setColumn($firstcol, $lastcol, $width, $format = 0, $hidden = 0)
{
$this->_colinfo[] = array($firstcol, $lastcol, $width, &$format, $hidden);
// Set width to zero if column is hidden
$width = ($hidden) ? 0 : $width;
for($col = $firstcol; $col <= $lastcol; $col++) {
$this->col_sizes[$col] = $width;
}
}
/**
* Set which cell or cells are selected in a worksheet
*
* @access public
* @param integer $first_row first row in the selected quadrant
* @param integer $first_column first column in the selected quadrant
* @param integer $last_row last row in the selected quadrant
* @param integer $last_column last column in the selected quadrant
*/
function setSelection($first_row,$first_column,$last_row,$last_column)
{
$this->_selection = array($first_row,$first_column,$last_row,$last_column);
}
/**
* Set panes and mark them as frozen.
*
* @access public
* @param array $panes This is the only parameter received and is composed of the following:
* 0 => Vertical split position,
* 1 => Horizontal split position
* 2 => Top row visible
* 3 => Leftmost column visible
* 4 => Active pane
*/
function freezePanes($panes)
{
$this->_frozen = 1;
$this->_panes = $panes;
}
/**
* Set panes and mark them as unfrozen.
*
* @access public
* @param array $panes This is the only parameter received and is composed of the following:
* 0 => Vertical split position,
* 1 => Horizontal split position
* 2 => Top row visible
* 3 => Leftmost column visible
* 4 => Active pane
*/
function thawPanes($panes)
{
$this->_frozen = 0;
$this->_panes = $panes;
}
/**
* Set the page orientation as portrait.
*
* @access public
*/
function setPortrait()
{
$this->_orientation = 1;
}
/**
* Set the page orientation as landscape.
*
* @access public
*/
function setLandscape()
{
$this->_orientation = 0;
}
/**
* Set the paper type. Ex. 1 = US Letter, 9 = A4
*
* @access public
* @param integer $size The type of paper size to use
*/
function setPaper($size = 0)
{
$this->_paper_size = $size;
}
/**
* Set the page header caption and optional margin.
*
* @access public
* @param string $string The header text
* @param float $margin optional head margin in inches.
*/
function setHeader($string,$margin = 0.50)
{
if (strlen($string) >= 255) {
//carp 'Header string must be less than 255 characters';
return;
}
$this->_header = $string;
$this->_margin_head = $margin;
}
/**
* Set the page footer caption and optional margin.
*
* @access public
* @param string $string The footer text
* @param float $margin optional foot margin in inches.
*/
function setFooter($string,$margin = 0.50)
{
if (strlen($string) >= 255) {
//carp 'Footer string must be less than 255 characters';
return;
}
$this->_footer = $string;
$this->_margin_foot = $margin;
}
/**
* Center the page horinzontally.
*
* @access public
* @param integer $center the optional value for centering. Defaults to 1 (center).
*/
function centerHorizontally($center = 1)
{
$this->_hcenter = $center;
}
/**
* Center the page vertically.
*
* @access public
* @param integer $center the optional value for centering. Defaults to 1 (center).
*/
function centerVertically($center = 1)
{
$this->_vcenter = $center;
}
/**
* Set all the page margins to the same value in inches.
*
* @access public
* @param float $margin The margin to set in inches
*/
function setMargins($margin)
{
$this->setMarginLeft($margin);
$this->setMarginRight($margin);
$this->setMarginTop($margin);
$this->setMarginBottom($margin);
}
/**
* Set the left and right margins to the same value in inches.
*
* @access public
* @param float $margin The margin to set in inches
*/
function setMargins_LR($margin)
{
$this->setMarginLeft($margin);
$this->setMarginRight($margin);
}
/**
* Set the top and bottom margins to the same value in inches.
*
* @access public
* @param float $margin The margin to set in inches
*/
function setMargins_TB($margin)
{
$this->setMarginTop($margin);
$this->setMarginBottom($margin);
}
/**
* Set the left margin in inches.
*
* @access public
* @param float $margin The margin to set in inches
*/
function setMarginLeft($margin = 0.75)
{
$this->_margin_left = $margin;
}
/**
* Set the right margin in inches.
*
* @access public
* @param float $margin The margin to set in inches
*/
function setMarginRight($margin = 0.75)
{
$this->_margin_right = $margin;
}
/**
* Set the top margin in inches.
*
* @access public
* @param float $margin The margin to set in inches
*/
function setMarginTop($margin = 1.00)
{
$this->_margin_top = $margin;
}
/**
* Set the bottom margin in inches.
*
* @access public
* @param float $margin The margin to set in inches
*/
function setMarginBottom($margin = 1.00)
{
$this->_margin_bottom = $margin;
}
/**
* Set the rows to repeat at the top of each printed page.
*
* @access public
* @param integer $first_row First row to repeat
* @param integer $last_row Last row to repeat. Optional.
*/
function repeatRows($first_row, $last_row = NULL)
{
$this->title_rowmin = $first_row;
if (isset($last_row)) { //Second row is optional
$this->title_rowmax = $last_row;
}
else {
$this->title_rowmax = $first_row;
}
}
/**
* Set the columns to repeat at the left hand side of each printed page.
*
* @access public
* @param integer $first_col First column to repeat
* @param integer $last_col Last column to repeat. Optional.
*/
function repeatColumns($first_col, $last_col = NULL)
{
$this->title_colmin = $first_col;
if (isset($last_col)) { // Second col is optional
$this->title_colmax = $last_col;
}
else {
$this->title_colmax = $first_col;
}
}
/**
* Set the area of each worksheet that will be printed.
*
* @access public
* @param integer $first_row First row of the area to print
* @param integer $first_col First column of the area to print
* @param integer $last_row Last row of the area to print
* @param integer $last_col Last column of the area to print
*/
function printArea($first_row, $first_col, $last_row, $last_col)
{
$this->print_rowmin = $first_row;
$this->print_colmin = $first_col;
$this->print_rowmax = $last_row;
$this->print_colmax = $last_col;
}
/**
* Set the option to hide gridlines on the printed page.
*
* @access public
*/
function hideGridlines()
{
$this->_print_gridlines = 0;
}
/**
* Set the option to print the row and column headers on the printed page.
*
* @access public
* @param integer $print Whether to print the headers or not. Defaults to 1 (print).
*/
function printRowColHeaders($print = 1)
{
$this->_print_headers = $print;
}
/**
* Set the vertical and horizontal number of pages that will define the maximum area printed.
* It doesn't seem to work with OpenOffice.
*
* @access public
* @param integer $width Maximun width of printed area in pages
* @param integer $height Maximun heigth of printed area in pages
* @see setPrintScale()
*/
function fitToPages($width, $height)
{
$this->_fit_page = 1;
$this->_fit_width = $width;
$this->_fit_height = $height;
}
/**
* Store the horizontal page breaks on a worksheet (for printing).
* The breaks represent the row after which the break is inserted.
*
* @access public
* @param array $breaks Array containing the horizontal page breaks
*/
function setHPagebreaks($breaks)
{
foreach($breaks as $break) {
array_push($this->_hbreaks,$break);
}
}
/**
* Store the vertical page breaks on a worksheet (for printing).
* The breaks represent the column after which the break is inserted.
*
* @access public
* @param array $breaks Array containing the vertical page breaks
*/
function setVPagebreaks($breaks)
{
foreach($breaks as $break) {
array_push($this->_vbreaks,$break);
}
}
/**
* Set the worksheet zoom factor.
*
* @access public
* @param integer $scale The zoom factor
*/
function setZoom($scale = 100)
{
// Confine the scale to Excel's range
if ($scale < 10 or $scale > 400)
{
$this->raiseError("Zoom factor $scale outside range: 10 <= zoom <= 400");
$scale = 100;
}
$this->_zoom = floor($scale);
}
/**
* Set the scale factor for the printed page.
* It turns off the "fit to page" option
*
* @access public
* @param integer $scale The optional scale factor. Defaults to 100
*/
function setPrintScale($scale = 100)
{
// Confine the scale to Excel's range
if ($scale < 10 or $scale > 400)
{
$this->raiseError("Print scale $scale outside range: 10 <= zoom <= 400");
$scale = 100;
}
// Turn off "fit to page" option
$this->_fit_page = 0;
$this->_print_scale = floor($scale);
}
/**
* Map to the appropriate write method acording to the token recieved.
*
* @access public
* @param integer $row The row of the cell we are writing to
* @param integer $col The column of the cell we are writing to
* @param mixed $token What we are writing
* @param mixed $format The optional format to apply to the cell
*/
function write($row, $col, $token, $format = 0)
{
// Check for a cell reference in A1 notation and substitute row and column
/*if ($_[0] =~ /^\D/) {
@_ = $this->_substituteCellref(@_);
}*/
// Match number
if (preg_match("/^([+-]?)(?=\d|\.\d)\d*(\.\d*)?([Ee]([+-]?\d+))?$/",$token)) {
return $this->writeNumber($row,$col,$token,$format);
}
// Match http or ftp URL
elseif (preg_match("/^[fh]tt?p:\/\//",$token)) {
return $this->writeUrl($row, $col, $token, $format);
}
// Match mailto:
elseif (preg_match("/^mailto:/",$token)) {
return $this->writeUrl($row, $col, $token, $format);
}
// Match internal or external sheet link
elseif (preg_match("/^(?:in|ex)ternal:/",$token)) {
return $this->writeUrl($row, $col, $token, $format);
}
// Match formula
elseif (preg_match("/^=/",$token)) {
return $this->writeFormula($row, $col, $token, $format);
}
// Match formula
elseif (preg_match("/^@/",$token)) {
return $this->writeFormula($row, $col, $token, $format);
}
// Match blank
elseif ($token == '') {
return $this->writeBlank($row,$col,$format);
}
// Default: match string
else {
return $this->writeString($row,$col,$token,$format);
}
}
/**
* Write an array of values as a row
*
* @access public
* @param
* @return
*/
 
function writeRow($row, $col, $val, $format=0)
{
if (is_array($val)) {
foreach($val as $v) {
if (is_array($v)) {
$this->writeCol($row, $col, $v, $format);
} else {
$this->write($row, $col, $v, $format);
}
$col++;
}
} else {
$retval = new PEAR_Error('$val needs to be an array');
}
return($retval);
}
/**
* Write an array of values as a column
*
* @access public
* @param
* @return
*/
function writeCol($row, $col, $val, $format=0)
{
if (is_array($val)) {
foreach($val as $v) {
$this->write($row, $col, $v, $format);
$row++;
}
} else {
$retval = new PEAR_Error('$val needs to be an array');
}
return($retval);
}
/**
* Returns an index to the XF record in the workbook
*
* @access private
* @param mixed &$format The optional XF format
* @return integer The XF record index
*/
function _XF(&$format)
{
if ($format != 0) {
return($format->getXfIndex());
}
else {
return(0x0F);
}
}
/******************************************************************************
*******************************************************************************
*
* Internal methods
*/
/**
* Store Worksheet data in memory using the parent's class append() or to a
* temporary file, the default.
*
* @access private
* @param string $data The binary data to append
*/
function _append($data)
{
if ($this->_using_tmpfile)
{
// Add CONTINUE records if necessary
if (strlen($data) > $this->_limit) {
$data = $this->_addContinue($data);
}
fwrite($this->_filehandle,$data);
$this->_datasize += strlen($data);
}
else {
parent::_append($data);
}
}
/**
* Substitute an Excel cell reference in A1 notation for zero based row and
* column values in an argument list.
*
* Ex: ("A4", "Hello") is converted to (3, 0, "Hello").
*
* @access private
* @param string $cell The cell reference. Or range of cells.
* @return array
*/
function _substituteCellref($cell)
{
$cell = strtoupper($cell);
// Convert a column range: 'A:A' or 'B:G'
if (preg_match("/([A-I]?[A-Z]):([A-I]?[A-Z])/",$cell,$match)) {
list($no_use, $col1) = $this->_cellToRowcol($match[1] .'1'); // Add a dummy row
list($no_use, $col2) = $this->_cellToRowcol($match[2] .'1'); // Add a dummy row
return(array($col1, $col2));
}
// Convert a cell range: 'A1:B7'
if (preg_match("/\$?([A-I]?[A-Z]\$?\d+):\$?([A-I]?[A-Z]\$?\d+)/",$cell,$match)) {
list($row1, $col1) = $this->_cellToRowcol($match[1]);
list($row2, $col2) = $this->_cellToRowcol($match[2]);
return(array($row1, $col1, $row2, $col2));
}
// Convert a cell reference: 'A1' or 'AD2000'
if (preg_match("/\$?([A-I]?[A-Z]\$?\d+)/",$cell)) {
list($row1, $col1) = $this->_cellToRowcol($match[1]);
return(array($row1, $col1));
}
// TODO use real error codes
$this->raiseError("Unknown cell reference $cell", 0, PEAR_ERROR_DIE);
}
/**
* Convert an Excel cell reference in A1 notation to a zero based row and column
* reference; converts C1 to (0, 2).
*
* @access private
* @param string $cell The cell reference.
* @return array containing (row, column)
*/
function _cellToRowcol($cell)
{
preg_match("/\$?([A-I]?[A-Z])\$?(\d+)/",$cell,$match);
$col = $match[1];
$row = $match[2];
// Convert base26 column string to number
$chars = split('', $col);
$expn = 0;
$col = 0;
while ($chars) {
$char = array_pop($chars); // LS char first
$col += (ord($char) -ord('A') +1) * pow(26,$expn);
$expn++;
}
// Convert 1-index to zero-index
$row--;
$col--;
return(array($row, $col));
}
/**
* Based on the algorithm provided by Daniel Rentz of OpenOffice.
*
* @access private
* @param string $plaintext The password to be encoded in plaintext.
* @return string The encoded password
*/
function _encodePassword($plaintext)
{
$password = 0x0000;
$i = 1; // char position
// split the plain text password in its component characters
$chars = preg_split('//', $plaintext, -1, PREG_SPLIT_NO_EMPTY);
foreach($chars as $char)
{
$value = ord($char) << $i; // shifted ASCII value
$rotated_bits = $value >> 15; // rotated bits beyond bit 15
$value &= 0x7fff; // first 15 bits
$password ^= ($value | $rotated_bits);
$i++;
}
$password ^= strlen($plaintext);
$password ^= 0xCE4B;
 
return($password);
}
 
/******************************************************************************
*******************************************************************************
*
* BIFF RECORDS
*/
/**
* Write a double to the specified row and column (zero indexed).
* An integer can be written as a double. Excel will display an
* integer. $format is optional.
*
* Returns 0 : normal termination
* -2 : row or column out of range
*
* @access public
* @param integer $row Zero indexed row
* @param integer $col Zero indexed column
* @param float $num The number to write
* @param mixed $format The optional XF format
* @return integer
*/
function writeNumber($row, $col, $num, $format = 0)
{
$record = 0x0203; // Record identifier
$length = 0x000E; // Number of bytes to follow
$xf = $this->_XF($format); // The cell format
// Check that row and col are valid and store max and min values
if ($row >= $this->_xls_rowmax)
{
return(-2);
}
if ($col >= $this->_xls_colmax)
{
return(-2);
}
if ($row < $this->_dim_rowmin)
{
$this->_dim_rowmin = $row;
}
if ($row > $this->_dim_rowmax)
{
$this->_dim_rowmax = $row;
}
if ($col < $this->_dim_colmin)
{
$this->_dim_colmin = $col;
}
if ($col > $this->_dim_colmax)
{
$this->_dim_colmax = $col;
}
$header = pack("vv", $record, $length);
$data = pack("vvv", $row, $col, $xf);
$xl_double = pack("d", $num);
if ($this->_byte_order) // if it's Big Endian
{
$xl_double = strrev($xl_double);
}
$this->_append($header.$data.$xl_double);
return(0);
}
/**
* Write a string to the specified row and column (zero indexed).
* NOTE: there is an Excel 5 defined limit of 255 characters.
* $format is optional.
* Returns 0 : normal termination
* -2 : row or column out of range
* -3 : long string truncated to 255 chars
*
* @access public
* @param integer $row Zero indexed row
* @param integer $col Zero indexed column
* @param string $str The string to write
* @param mixed $format The XF format for the cell
* @return integer
*/
function writeString($row, $col, $str, $format = 0)
{
$strlen = strlen($str);
$record = 0x0204; // Record identifier
$length = 0x0008 + $strlen; // Bytes to follow
$xf = $this->_XF($format); // The cell format
$str_error = 0;
// Check that row and col are valid and store max and min values
if ($row >= $this->_xls_rowmax)
{
return(-2);
}
if ($col >= $this->_xls_colmax)
{
return(-2);
}
if ($row < $this->_dim_rowmin)
{
$this->_dim_rowmin = $row;
}
if ($row > $this->_dim_rowmax)
{
$this->_dim_rowmax = $row;
}
if ($col < $this->_dim_colmin)
{
$this->_dim_colmin = $col;
}
if ($col > $this->_dim_colmax)
{
$this->_dim_colmax = $col;
}
if ($strlen > $this->_xls_strmax) // LABEL must be < 255 chars
{
$str = substr($str, 0, $this->_xls_strmax);
$length = 0x0008 + $this->_xls_strmax;
$strlen = $this->_xls_strmax;
$str_error = -3;
}
$header = pack("vv", $record, $length);
$data = pack("vvvv", $row, $col, $xf, $strlen);
$this->_append($header.$data.$str);
return($str_error);
}
 
/**
* Writes a note associated with the cell given by the row and column.
* NOTE records don't have a length limit.
*
* @access public
* @param integer $row Zero indexed row
* @param integer $col Zero indexed column
* @param string $note The note to write
*/
function writeNote($row, $col, $note)
{
$note_length = strlen($note);
$record = 0x001C; // Record identifier
$max_length = 2048; // Maximun length for a NOTE record
//$length = 0x0006 + $note_length; // Bytes to follow
 
// Check that row and col are valid and store max and min values
if ($row >= $this->_xls_rowmax)
{
return(-2);
}
if ($col >= $this->_xls_colmax)
{
return(-2);
}
if ($row < $this->_dim_rowmin)
{
$this->_dim_rowmin = $row;
}
if ($row > $this->_dim_rowmax)
{
$this->_dim_rowmax = $row;
}
if ($col < $this->_dim_colmin)
{
$this->_dim_colmin = $col;
}
if ($col > $this->_dim_colmax)
{
$this->_dim_colmax = $col;
}
// Length for this record is no more than 2048 + 6
$length = 0x0006 + min($note_length, 2048);
$header = pack("vv", $record, $length);
$data = pack("vvv", $row, $col, $note_length);
$this->_append($header.$data.substr($note, 0, 2048));
 
for($i = $max_length; $i < $note_length; $i += $max_length)
{
$chunk = substr($note, $i, $max_length);
$length = 0x0006 + strlen($chunk);
$header = pack("vv", $record, $length);
$data = pack("vvv", -1, 0, strlen($chunk));
$this->_append($header.$data.$chunk);
}
return(0);
}
 
/**
* Write a blank cell to the specified row and column (zero indexed).
* A blank cell is used to specify formatting without adding a string
* or a number.
*
* A blank cell without a format serves no purpose. Therefore, we don't write
* a BLANK record unless a format is specified.
*
* Returns 0 : normal termination (including no format)
* -1 : insufficient number of arguments
* -2 : row or column out of range
*
* @access public
* @param integer $row Zero indexed row
* @param integer $col Zero indexed column
* @param mixed $format The XF format
*/
function writeBlank($row, $col, $format)
{
// Don't write a blank cell unless it has a format
if ($format == 0)
{
return(0);
}
$record = 0x0201; // Record identifier
$length = 0x0006; // Number of bytes to follow
$xf = $this->_XF($format); // The cell format
// Check that row and col are valid and store max and min values
if ($row >= $this->_xls_rowmax)
{
return(-2);
}
if ($col >= $this->_xls_colmax)
{
return(-2);
}
if ($row < $this->_dim_rowmin)
{
$this->_dim_rowmin = $row;
}
if ($row > $this->_dim_rowmax)
{
$this->_dim_rowmax = $row;
}
if ($col < $this->_dim_colmin)
{
$this->_dim_colmin = $col;
}
if ($col > $this->_dim_colmax)
{
$this->_dim_colmax = $col;
}
$header = pack("vv", $record, $length);
$data = pack("vvv", $row, $col, $xf);
$this->_append($header.$data);
return 0;
}
 
/**
* Write a formula to the specified row and column (zero indexed).
* The textual representation of the formula is passed to the parser in
* Parser.php which returns a packed binary string.
*
* Returns 0 : normal termination
* -1 : formula errors (bad formula)
* -2 : row or column out of range
*
* @access public
* @param integer $row Zero indexed row
* @param integer $col Zero indexed column
* @param string $formula The formula text string
* @param mixed $format The optional XF format
* @return integer
*/
function writeFormula($row, $col, $formula, $format = 0)
{
$record = 0x0006; // Record identifier
// Excel normally stores the last calculated value of the formula in $num.
// Clearly we are not in a position to calculate this a priori. Instead
// we set $num to zero and set the option flags in $grbit to ensure
// automatic calculation of the formula when the file is opened.
//
$xf = $this->_XF($format); // The cell format
$num = 0x00; // Current value of formula
$grbit = 0x03; // Option flags
$chn = 0x0000; // Must be zero
// Check that row and col are valid and store max and min values
if ($row >= $this->_xls_rowmax)
{
return(-2);
}
if ($col >= $this->_xls_colmax)
{
return(-2);
}
if ($row < $this->_dim_rowmin)
{
$this->_dim_rowmin = $row;
}
if ($row > $this->_dim_rowmax)
{
$this->_dim_rowmax = $row;
}
if ($col < $this->_dim_colmin)
{
$this->_dim_colmin = $col;
}
if ($col > $this->_dim_colmax)
{
$this->_dim_colmax = $col;
}
// Strip the '=' or '@' sign at the beginning of the formula string
if (preg_match("/^=/",$formula)) {
$formula = preg_replace("/(^=)/","",$formula);
}
elseif (preg_match("/^@/",$formula)) {
$formula = preg_replace("/(^@)/","",$formula);
}
else
{
// Error handling
$this->writeString($row, $col, 'Unrecognised character for formula');
return -1;
}
// Parse the formula using the parser in Parser.php
$error = $this->_parser->parse($formula);
if ($this->isError($error))
{
$this->writeString($row, $col, $error->getMessage());
return -1;
}
$formula = $this->_parser->toReversePolish();
if ($this->isError($formula))
{
$this->writeString($row, $col, $formula->getMessage());
return -1;
}
$formlen = strlen($formula); // Length of the binary string
$length = 0x16 + $formlen; // Length of the record data
$header = pack("vv", $record, $length);
$data = pack("vvvdvVv", $row, $col, $xf, $num,
$grbit, $chn, $formlen);
$this->_append($header.$data.$formula);
return 0;
}
/**
* Write a hyperlink.
* This is comprised of two elements: the visible label and
* the invisible link. The visible label is the same as the link unless an
* alternative string is specified. The label is written using the
* writeString() method. Therefore the 255 characters string limit applies.
* $string and $format are optional.
*
* The hyperlink can be to a http, ftp, mail, internal sheet (not yet), or external
* directory url.
*
* Returns 0 : normal termination
* -2 : row or column out of range
* -3 : long string truncated to 255 chars
*
* @access public
* @param integer $row Row
* @param integer $col Column
* @param string $url URL string
* @param string $string Alternative label
* @param mixed $format The cell format
* @return integer
*/
function writeUrl($row, $col, $url, $string = '', $format = 0)
{
// Add start row and col to arg list
return($this->_writeUrl_range($row, $col, $row, $col, $url, $string, $format));
}
/**
* This is the more general form of writeUrl(). It allows a hyperlink to be
* written to a range of cells. This function also decides the type of hyperlink
* to be written. These are either, Web (http, ftp, mailto), Internal
* (Sheet1!A1) or external ('c:\temp\foo.xls#Sheet1!A1').
*
* @access private
* @see writeUrl()
* @param integer $row1 Start row
* @param integer $col1 Start column
* @param integer $row2 End row
* @param integer $col2 End column
* @param string $url URL string
* @param string $string Alternative label
* @param mixed $format The cell format
* @return integer
*/
function _writeUrl_range($row1, $col1, $row2, $col2, $url, $string = '', $format = 0)
{
// Check for internal/external sheet links or default to web link
if (preg_match('[^internal:]', $url)) {
return($this->_writeUrlInternal($row1, $col1, $row2, $col2, $url, $string, $format));
}
if (preg_match('[^external:]', $url)) {
return($this->_writeUrlExternal($row1, $col1, $row2, $col2, $url, $string, $format));
}
return($this->_writeUrlWeb($row1, $col1, $row2, $col2, $url, $string, $format));
}
/**
* Used to write http, ftp and mailto hyperlinks.
* The link type ($options) is 0x03 is the same as absolute dir ref without
* sheet. However it is differentiated by the $unknown2 data stream.
*
* @access private
* @see writeUrl()
* @param integer $row1 Start row
* @param integer $col1 Start column
* @param integer $row2 End row
* @param integer $col2 End column
* @param string $url URL string
* @param string $str Alternative label
* @param mixed $format The cell format
* @return integer
*/
function _writeUrlWeb($row1, $col1, $row2, $col2, $url, $str, $format = 0)
{
$record = 0x01B8; // Record identifier
$length = 0x00000; // Bytes to follow
if ($format == 0) {
$format = $this->_url_format;
}
// Write the visible label using the writeString() method.
if ($str == '') {
$str = $url;
}
$str_error = $this->writeString($row1, $col1, $str, $format);
if (($str_error == -2) or ($str_error == -3)) {
return $str_error;
}
// Pack the undocumented parts of the hyperlink stream
$unknown1 = pack("H*", "D0C9EA79F9BACE118C8200AA004BA90B02000000");
$unknown2 = pack("H*", "E0C9EA79F9BACE118C8200AA004BA90B");
// Pack the option flags
$options = pack("V", 0x03);
// Convert URL to a null terminated wchar string
$url = join("\0", preg_split("''", $url, -1, PREG_SPLIT_NO_EMPTY));
$url = $url . "\0\0\0";
// Pack the length of the URL
$url_len = pack("V", strlen($url));
// Calculate the data length
$length = 0x34 + strlen($url);
// Pack the header data
$header = pack("vv", $record, $length);
$data = pack("vvvv", $row1, $row2, $col1, $col2);
// Write the packed data
$this->_append( $header. $data.
$unknown1. $options.
$unknown2. $url_len. $url);
return($str_error);
}
/**
* Used to write internal reference hyperlinks such as "Sheet1!A1".
*
* @access private
* @see writeUrl()
* @param integer $row1 Start row
* @param integer $col1 Start column
* @param integer $row2 End row
* @param integer $col2 End column
* @param string $url URL string
* @param string $str Alternative label
* @param mixed $format The cell format
* @return integer
*/
function _writeUrlInternal($row1, $col1, $row2, $col2, $url, $str, $format = 0)
{
$record = 0x01B8; // Record identifier
$length = 0x00000; // Bytes to follow
if ($format == 0) {
$format = $this->_url_format;
}
// Strip URL type
$url = preg_replace('s[^internal:]', '', $url);
// Write the visible label
if ($str == '') {
$str = $url;
}
$str_error = $this->writeString($row1, $col1, $str, $format);
if (($str_error == -2) or ($str_error == -3)) {
return $str_error;
}
// Pack the undocumented parts of the hyperlink stream
$unknown1 = pack("H*", "D0C9EA79F9BACE118C8200AA004BA90B02000000");
// Pack the option flags
$options = pack("V", 0x08);
// Convert the URL type and to a null terminated wchar string
$url = join("\0", preg_split("''", $url, -1, PREG_SPLIT_NO_EMPTY));
$url = $url . "\0\0\0";
// Pack the length of the URL as chars (not wchars)
$url_len = pack("V", floor(strlen($url)/2));
// Calculate the data length
$length = 0x24 + strlen($url);
// Pack the header data
$header = pack("vv", $record, $length);
$data = pack("vvvv", $row1, $row2, $col1, $col2);
// Write the packed data
$this->_append($header. $data.
$unknown1. $options.
$url_len. $url);
return($str_error);
}
/**
* Write links to external directory names such as 'c:\foo.xls',
* c:\foo.xls#Sheet1!A1', '../../foo.xls'. and '../../foo.xls#Sheet1!A1'.
*
* Note: Excel writes some relative links with the $dir_long string. We ignore
* these cases for the sake of simpler code.
*
* @access private
* @see writeUrl()
* @param integer $row1 Start row
* @param integer $col1 Start column
* @param integer $row2 End row
* @param integer $col2 End column
* @param string $url URL string
* @param string $str Alternative label
* @param mixed $format The cell format
* @return integer
*/
function _writeUrlExternal($row1, $col1, $row2, $col2, $url, $str, $format = 0)
{
// Network drives are different. We will handle them separately
// MS/Novell network drives and shares start with \\
if (preg_match('[^external:\\\\]', $url)) {
return; //($this->_writeUrlExternal_net($row1, $col1, $row2, $col2, $url, $str, $format));
}
$record = 0x01B8; // Record identifier
$length = 0x00000; // Bytes to follow
if ($format == 0) {
$format = $this->_url_format;
}
// Strip URL type and change Unix dir separator to Dos style (if needed)
//
$url = preg_replace('[^external:]', '', $url);
$url = preg_replace('[/]', "\\", $url);
// Write the visible label
if ($str == '') {
$str = preg_replace('[\#]', ' - ', $url);
}
$str_error = $this->writeString($row1, $col1, $str, $format);
if (($str_error == -2) or ($str_error == -3)) {
return $str_error;
}
// Determine if the link is relative or absolute:
// relative if link contains no dir separator, "somefile.xls"
// relative if link starts with up-dir, "..\..\somefile.xls"
// otherwise, absolute
$absolute = 0x02; // Bit mask
if (!preg_match('[\\]', $url)) {
$absolute = 0x00;
}
if (preg_match('[^\.\.\\]', $url)) {
$absolute = 0x00;
}
// Determine if the link contains a sheet reference and change some of the
// parameters accordingly.
// Split the dir name and sheet name (if it exists)
list($dir_long , $sheet) = split('/\#/', $url);
$link_type = 0x01 | $absolute;
if (isset($sheet)) {
$link_type |= 0x08;
$sheet_len = pack("V", strlen($sheet) + 0x01);
$sheet = join("\0", split('', $sheet));
$sheet .= "\0\0\0";
}
else {
$sheet_len = '';
$sheet = '';
}
// Pack the link type
$link_type = pack("V", $link_type);
// Calculate the up-level dir count e.g.. (..\..\..\ == 3)
$up_count = preg_match_all("/\.\.\\/", $dir_long, $useless);
$up_count = pack("v", $up_count);
// Store the short dos dir name (null terminated)
$dir_short = preg_replace('/\.\.\\/', '', $dir_long) . "\0";
// Store the long dir name as a wchar string (non-null terminated)
$dir_long = join("\0", split('', $dir_long));
$dir_long = $dir_long . "\0";
// Pack the lengths of the dir strings
$dir_short_len = pack("V", strlen($dir_short) );
$dir_long_len = pack("V", strlen($dir_long) );
$stream_len = pack("V", strlen($dir_long) + 0x06);
// Pack the undocumented parts of the hyperlink stream
$unknown1 = pack("H*",'D0C9EA79F9BACE118C8200AA004BA90B02000000' );
$unknown2 = pack("H*",'0303000000000000C000000000000046' );
$unknown3 = pack("H*",'FFFFADDE000000000000000000000000000000000000000');
$unknown4 = pack("v", 0x03 );
// Pack the main data stream
$data = pack("vvvv", $row1, $row2, $col1, $col2) .
$unknown1 .
$link_type .
$unknown2 .
$up_count .
$dir_short_len.
$dir_short .
$unknown3 .
$stream_len .
$dir_long_len .
$unknown4 .
$dir_long .
$sheet_len .
$sheet ;
// Pack the header data
$length = strlen($data);
$header = pack("vv", $record, $length);
// Write the packed data
$this->_append($header. $data);
return($str_error);
}
/**
* This method is used to set the height and format for a row.
*
* @access public
* @param integer $row The row to set
* @param integer $height Height we are giving to the row.
* Use NULL to set XF without setting height
* @param mixed $format XF format we are giving to the row
*/
function setRow($row, $height, $format = 0)
{
$record = 0x0208; // Record identifier
$length = 0x0010; // Number of bytes to follow
$colMic = 0x0000; // First defined column
$colMac = 0x0000; // Last defined column
$irwMac = 0x0000; // Used by Excel to optimise loading
$reserved = 0x0000; // Reserved
$grbit = 0x01C0; // Option flags. (monkey) see $1 do
$ixfe = $this->_XF($format); // XF index
// Use setRow($row, NULL, $XF) to set XF format without setting height
if ($height != NULL) {
$miyRw = $height * 20; // row height
}
else {
$miyRw = 0xff; // default row height is 256
}
$header = pack("vv", $record, $length);
$data = pack("vvvvvvvv", $row, $colMic, $colMac, $miyRw,
$irwMac,$reserved, $grbit, $ixfe);
$this->_append($header.$data);
}
/**
* Writes Excel DIMENSIONS to define the area in which there is data.
*
* @access private
*/
function storeDimensions()
{
$record = 0x0000; // Record identifier
$length = 0x000A; // Number of bytes to follow
$row_min = $this->_dim_rowmin; // First row
$row_max = $this->_dim_rowmax; // Last row plus 1
$col_min = $this->_dim_colmin; // First column
$col_max = $this->_dim_colmax; // Last column plus 1
$reserved = 0x0000; // Reserved by Excel
$header = pack("vv", $record, $length);
$data = pack("vvvvv", $row_min, $row_max,
$col_min, $col_max, $reserved);
$this->_prepend($header.$data);
}
/**
* Write BIFF record Window2.
*
* @access private
*/
function _storeWindow2()
{
$record = 0x023E; // Record identifier
$length = 0x000A; // Number of bytes to follow
$grbit = 0x00B6; // Option flags
$rwTop = 0x0000; // Top row visible in window
$colLeft = 0x0000; // Leftmost column visible in window
$rgbHdr = 0x00000000; // Row/column heading and gridline color
// The options flags that comprise $grbit
$fDspFmla = 0; // 0 - bit
$fDspGrid = 1; // 1
$fDspRwCol = 1; // 2
$fFrozen = $this->_frozen; // 3
$fDspZeros = 1; // 4
$fDefaultHdr = 1; // 5
$fArabic = 0; // 6
$fDspGuts = 1; // 7
$fFrozenNoSplit = 0; // 0 - bit
$fSelected = $this->selected; // 1
$fPaged = 1; // 2
$grbit = $fDspFmla;
$grbit |= $fDspGrid << 1;
$grbit |= $fDspRwCol << 2;
$grbit |= $fFrozen << 3;
$grbit |= $fDspZeros << 4;
$grbit |= $fDefaultHdr << 5;
$grbit |= $fArabic << 6;
$grbit |= $fDspGuts << 7;
$grbit |= $fFrozenNoSplit << 8;
$grbit |= $fSelected << 9;
$grbit |= $fPaged << 10;
$header = pack("vv", $record, $length);
$data = pack("vvvV", $grbit, $rwTop, $colLeft, $rgbHdr);
$this->_append($header.$data);
}
/**
* Write BIFF record DEFCOLWIDTH if COLINFO records are in use.
*
* @access private
*/
function _storeDefcol()
{
$record = 0x0055; // Record identifier
$length = 0x0002; // Number of bytes to follow
$colwidth = 0x0008; // Default column width
$header = pack("vv", $record, $length);
$data = pack("v", $colwidth);
$this->_prepend($header.$data);
}
/**
* Write BIFF record COLINFO to define column widths
*
* Note: The SDK says the record length is 0x0B but Excel writes a 0x0C
* length record.
*
* @access private
* @param array $col_array This is the only parameter received and is composed of the following:
* 0 => First formatted column,
* 1 => Last formatted column,
* 2 => Col width (8.43 is Excel default),
* 3 => The optional XF format of the column,
* 4 => Option flags.
*/
function _storeColinfo($col_array)
{
if (isset($col_array[0])) {
$colFirst = $col_array[0];
}
if (isset($col_array[1])) {
$colLast = $col_array[1];
}
if (isset($col_array[2])) {
$coldx = $col_array[2];
}
else {
$coldx = 8.43;
}
if (isset($col_array[3])) {
$format = $col_array[3];
}
else {
$format = 0;
}
if (isset($col_array[4])) {
$grbit = $col_array[4];
}
else {
$grbit = 0;
}
$record = 0x007D; // Record identifier
$length = 0x000B; // Number of bytes to follow
$coldx += 0.72; // Fudge. Excel subtracts 0.72 !?
$coldx *= 256; // Convert to units of 1/256 of a char
$ixfe = $this->_XF($format);
$reserved = 0x00; // Reserved
$header = pack("vv", $record, $length);
$data = pack("vvvvvC", $colFirst, $colLast, $coldx,
$ixfe, $grbit, $reserved);
$this->_prepend($header.$data);
}
/**
* Write BIFF record SELECTION.
*
* @access private
* @param array $array array containing ($rwFirst,$colFirst,$rwLast,$colLast)
* @see setSelection()
*/
function _storeSelection($array)
{
list($rwFirst,$colFirst,$rwLast,$colLast) = $array;
$record = 0x001D; // Record identifier
$length = 0x000F; // Number of bytes to follow
$pnn = $this->_active_pane; // Pane position
$rwAct = $rwFirst; // Active row
$colAct = $colFirst; // Active column
$irefAct = 0; // Active cell ref
$cref = 1; // Number of refs
if (!isset($rwLast)) {
$rwLast = $rwFirst; // Last row in reference
}
if (!isset($colLast)) {
$colLast = $colFirst; // Last col in reference
}
// Swap last row/col for first row/col as necessary
if ($rwFirst > $rwLast)
{
list($rwFirst, $rwLast) = array($rwLast, $rwFirst);
}
if ($colFirst > $colLast)
{
list($colFirst, $colLast) = array($colLast, $colFirst);
}
$header = pack("vv", $record, $length);
$data = pack("CvvvvvvCC", $pnn, $rwAct, $colAct,
$irefAct, $cref,
$rwFirst, $rwLast,
$colFirst, $colLast);
$this->_append($header.$data);
}
/**
* Write BIFF record EXTERNCOUNT to indicate the number of external sheet
* references in a worksheet.
*
* Excel only stores references to external sheets that are used in formulas.
* For simplicity we store references to all the sheets in the workbook
* regardless of whether they are used or not. This reduces the overall
* complexity and eliminates the need for a two way dialogue between the formula
* parser the worksheet objects.
*
* @access private
* @param integer $count The number of external sheet references in this worksheet
*/
function _storeExterncount($count)
{
$record = 0x0016; // Record identifier
$length = 0x0002; // Number of bytes to follow
$header = pack("vv", $record, $length);
$data = pack("v", $count);
$this->_prepend($header.$data);
}
/**
* Writes the Excel BIFF EXTERNSHEET record. These references are used by
* formulas. A formula references a sheet name via an index. Since we store a
* reference to all of the external worksheets the EXTERNSHEET index is the same
* as the worksheet index.
*
* @access private
* @param string $sheetname The name of a external worksheet
*/
function _storeExternsheet($sheetname)
{
$record = 0x0017; // Record identifier
// References to the current sheet are encoded differently to references to
// external sheets.
//
if ($this->name == $sheetname) {
$sheetname = '';
$length = 0x02; // The following 2 bytes
$cch = 1; // The following byte
$rgch = 0x02; // Self reference
}
else {
$length = 0x02 + strlen($sheetname);
$cch = strlen($sheetname);
$rgch = 0x03; // Reference to a sheet in the current workbook
}
$header = pack("vv", $record, $length);
$data = pack("CC", $cch, $rgch);
$this->_prepend($header.$data.$sheetname);
}
/**
* Writes the Excel BIFF PANE record.
* The panes can either be frozen or thawed (unfrozen).
* Frozen panes are specified in terms of an integer number of rows and columns.
* Thawed panes are specified in terms of Excel's units for rows and columns.
*
* @access private
* @param array $panes This is the only parameter received and is composed of the following:
* 0 => Vertical split position,
* 1 => Horizontal split position
* 2 => Top row visible
* 3 => Leftmost column visible
* 4 => Active pane
*/
function _storePanes($panes)
{
$y = $panes[0];
$x = $panes[1];
$rwTop = $panes[2];
$colLeft = $panes[3];
if (count($panes) > 4) { // if Active pane was received
$pnnAct = $panes[4];
}
else {
$pnnAct = NULL;
}
$record = 0x0041; // Record identifier
$length = 0x000A; // Number of bytes to follow
// Code specific to frozen or thawed panes.
if ($this->_frozen)
{
// Set default values for $rwTop and $colLeft
if (!isset($rwTop)) {
$rwTop = $y;
}
if (!isset($colLeft)) {
$colLeft = $x;
}
}
else
{
// Set default values for $rwTop and $colLeft
if (!isset($rwTop)) {
$rwTop = 0;
}
if (!isset($colLeft)) {
$colLeft = 0;
}
// Convert Excel's row and column units to the internal units.
// The default row height is 12.75
// The default column width is 8.43
// The following slope and intersection values were interpolated.
//
$y = 20*$y + 255;
$x = 113.879*$x + 390;
}
// Determine which pane should be active. There is also the undocumented
// option to override this should it be necessary: may be removed later.
//
if (!isset($pnnAct))
{
if ($x != 0 and $y != 0)
$pnnAct = 0; // Bottom right
if ($x != 0 and $y == 0)
$pnnAct = 1; // Top right
if ($x == 0 and $y != 0)
$pnnAct = 2; // Bottom left
if ($x == 0 and $y == 0)
$pnnAct = 3; // Top left
}
$this->_active_pane = $pnnAct; // Used in _storeSelection
$header = pack("vv", $record, $length);
$data = pack("vvvvv", $x, $y, $rwTop, $colLeft, $pnnAct);
$this->_append($header.$data);
}
/**
* Store the page setup SETUP BIFF record.
*
* @access private
*/
function _storeSetup()
{
$record = 0x00A1; // Record identifier
$length = 0x0022; // Number of bytes to follow
$iPaperSize = $this->_paper_size; // Paper size
$iScale = $this->_print_scale; // Print scaling factor
$iPageStart = 0x01; // Starting page number
$iFitWidth = $this->_fit_width; // Fit to number of pages wide
$iFitHeight = $this->_fit_height; // Fit to number of pages high
$grbit = 0x00; // Option flags
$iRes = 0x0258; // Print resolution
$iVRes = 0x0258; // Vertical print resolution
$numHdr = $this->_margin_head; // Header Margin
$numFtr = $this->_margin_foot; // Footer Margin
$iCopies = 0x01; // Number of copies
$fLeftToRight = 0x0; // Print over then down
$fLandscape = $this->_orientation; // Page orientation
$fNoPls = 0x0; // Setup not read from printer
$fNoColor = 0x0; // Print black and white
$fDraft = 0x0; // Print draft quality
$fNotes = 0x0; // Print notes
$fNoOrient = 0x0; // Orientation not set
$fUsePage = 0x0; // Use custom starting page
$grbit = $fLeftToRight;
$grbit |= $fLandscape << 1;
$grbit |= $fNoPls << 2;
$grbit |= $fNoColor << 3;
$grbit |= $fDraft << 4;
$grbit |= $fNotes << 5;
$grbit |= $fNoOrient << 6;
$grbit |= $fUsePage << 7;
$numHdr = pack("d", $numHdr);
$numFtr = pack("d", $numFtr);
if ($this->_byte_order) // if it's Big Endian
{
$numHdr = strrev($numHdr);
$numFtr = strrev($numFtr);
}
$header = pack("vv", $record, $length);
$data1 = pack("vvvvvvvv", $iPaperSize,
$iScale,
$iPageStart,
$iFitWidth,
$iFitHeight,
$grbit,
$iRes,
$iVRes);
$data2 = $numHdr.$numFtr;
$data3 = pack("v", $iCopies);
$this->_prepend($header.$data1.$data2.$data3);
}
/**
* Store the header caption BIFF record.
*
* @access private
*/
function _storeHeader()
{
$record = 0x0014; // Record identifier
$str = $this->_header; // header string
$cch = strlen($str); // Length of header string
$length = 1 + $cch; // Bytes to follow
$header = pack("vv", $record, $length);
$data = pack("C", $cch);
$this->_append($header.$data.$str);
}
/**
* Store the footer caption BIFF record.
*
* @access private
*/
function _storeFooter()
{
$record = 0x0015; // Record identifier
$str = $this->_footer; // Footer string
$cch = strlen($str); // Length of footer string
$length = 1 + $cch; // Bytes to follow
$header = pack("vv", $record, $length);
$data = pack("C", $cch);
$this->_append($header.$data.$str);
}
/**
* Store the horizontal centering HCENTER BIFF record.
*
* @access private
*/
function _storeHcenter()
{
$record = 0x0083; // Record identifier
$length = 0x0002; // Bytes to follow
$fHCenter = $this->_hcenter; // Horizontal centering
$header = pack("vv", $record, $length);
$data = pack("v", $fHCenter);
$this->_append($header.$data);
}
/**
* Store the vertical centering VCENTER BIFF record.
*
* @access private
*/
function _storeVcenter()
{
$record = 0x0084; // Record identifier
$length = 0x0002; // Bytes to follow
$fVCenter = $this->_vcenter; // Horizontal centering
$header = pack("vv", $record, $length);
$data = pack("v", $fVCenter);
$this->_append($header.$data);
}
/**
* Store the LEFTMARGIN BIFF record.
*
* @access private
*/
function _storeMarginLeft()
{
$record = 0x0026; // Record identifier
$length = 0x0008; // Bytes to follow
$margin = $this->_margin_left; // Margin in inches
$header = pack("vv", $record, $length);
$data = pack("d", $margin);
if ($this->_byte_order) // if it's Big Endian
{
$data = strrev($data);
}
$this->_append($header.$data);
}
/**
* Store the RIGHTMARGIN BIFF record.
*
* @access private
*/
function _storeMarginRight()
{
$record = 0x0027; // Record identifier
$length = 0x0008; // Bytes to follow
$margin = $this->_margin_right; // Margin in inches
$header = pack("vv", $record, $length);
$data = pack("d", $margin);
if ($this->_byte_order) // if it's Big Endian
{
$data = strrev($data);
}
$this->_append($header.$data);
}
/**
* Store the TOPMARGIN BIFF record.
*
* @access private
*/
function _storeMarginTop()
{
$record = 0x0028; // Record identifier
$length = 0x0008; // Bytes to follow
$margin = $this->_margin_top; // Margin in inches
$header = pack("vv", $record, $length);
$data = pack("d", $margin);
if ($this->_byte_order) // if it's Big Endian
{
$data = strrev($data);
}
$this->_append($header.$data);
}
/**
* Store the BOTTOMMARGIN BIFF record.
*
* @access private
*/
function _storeMarginBottom()
{
$record = 0x0029; // Record identifier
$length = 0x0008; // Bytes to follow
$margin = $this->_margin_bottom; // Margin in inches
$header = pack("vv", $record, $length);
$data = pack("d", $margin);
if ($this->_byte_order) // if it's Big Endian
{
$data = strrev($data);
}
$this->_append($header.$data);
}
 
/**
* Merges the area given by its arguments.
* This is an Excel97/2000 method. It is required to perform more complicated
* merging than the normal setAlign('merge').
*
* @access public
* @param integer $first_row First row of the area to merge
* @param integer $first_col First column of the area to merge
* @param integer $last_row Last row of the area to merge
* @param integer $last_col Last column of the area to merge
*/
function mergeCells($first_row, $first_col, $last_row, $last_col)
{
$record = 0x00E5; // Record identifier
$length = 0x000A; // Bytes to follow
$cref = 1; // Number of refs
 
// Swap last row/col for first row/col as necessary
if ($first_row > $last_row) {
list($first_row, $last_row) = array($last_row, $first_row);
}
if ($first_col > $last_col) {
list($first_col, $last_col) = array($last_col, $first_col);
}
$header = pack("vv", $record, $length);
$data = pack("vvvvv", $cref, $first_row, $last_row,
$first_col, $last_col);
$this->_append($header.$data);
}
 
/**
* Write the PRINTHEADERS BIFF record.
*
* @access private
*/
function _storePrintHeaders()
{
$record = 0x002a; // Record identifier
$length = 0x0002; // Bytes to follow
$fPrintRwCol = $this->_print_headers; // Boolean flag
$header = pack("vv", $record, $length);
$data = pack("v", $fPrintRwCol);
$this->_prepend($header.$data);
}
/**
* Write the PRINTGRIDLINES BIFF record. Must be used in conjunction with the
* GRIDSET record.
*
* @access private
*/
function _storePrintGridlines()
{
$record = 0x002b; // Record identifier
$length = 0x0002; // Bytes to follow
$fPrintGrid = $this->_print_gridlines; // Boolean flag
$header = pack("vv", $record, $length);
$data = pack("v", $fPrintGrid);
$this->_prepend($header.$data);
}
/**
* Write the GRIDSET BIFF record. Must be used in conjunction with the
* PRINTGRIDLINES record.
*
* @access private
*/
function _storeGridset()
{
$record = 0x0082; // Record identifier
$length = 0x0002; // Bytes to follow
$fGridSet = !($this->_print_gridlines); // Boolean flag
$header = pack("vv", $record, $length);
$data = pack("v", $fGridSet);
$this->_prepend($header.$data);
}
/**
* Write the WSBOOL BIFF record, mainly for fit-to-page. Used in conjunction
* with the SETUP record.
*
* @access private
*/
function _storeWsbool()
{
$record = 0x0081; // Record identifier
$length = 0x0002; // Bytes to follow
// The only option that is of interest is the flag for fit to page. So we
// set all the options in one go.
//
if ($this->_fit_page) {
$grbit = 0x05c1;
}
else {
$grbit = 0x04c1;
}
$header = pack("vv", $record, $length);
$data = pack("v", $grbit);
$this->_prepend($header.$data);
}
/**
* Write the HORIZONTALPAGEBREAKS BIFF record.
*
* @access private
*/
function _storeHbreak()
{
// Return if the user hasn't specified pagebreaks
if (empty($this->_hbreaks)) {
return;
}
// Sort and filter array of page breaks
$breaks = $this->_hbreaks;
sort($breaks,SORT_NUMERIC);
if ($breaks[0] == 0) { // don't use first break if it's 0
array_shift($breaks);
}
$record = 0x001b; // Record identifier
$cbrk = count($breaks); // Number of page breaks
$length = ($cbrk + 1) * 2; // Bytes to follow
$header = pack("vv", $record, $length);
$data = pack("v", $cbrk);
// Append each page break
foreach($breaks as $break) {
$data .= pack("v", $break);
}
$this->_prepend($header.$data);
}
/**
* Write the VERTICALPAGEBREAKS BIFF record.
*
* @access private
*/
function _storeVbreak()
{
// Return if the user hasn't specified pagebreaks
if (empty($this->_vbreaks)) {
return;
}
// 1000 vertical pagebreaks appears to be an internal Excel 5 limit.
// It is slightly higher in Excel 97/200, approx. 1026
$breaks = array_slice($this->_vbreaks,0,1000);
// Sort and filter array of page breaks
sort($breaks,SORT_NUMERIC);
if ($breaks[0] == 0) { // don't use first break if it's 0
array_shift($breaks);
}
$record = 0x001a; // Record identifier
$cbrk = count($breaks); // Number of page breaks
$length = ($cbrk + 1) * 2; // Bytes to follow
$header = pack("vv", $record, $length);
$data = pack("v", $cbrk);
// Append each page break
foreach ($breaks as $break) {
$data .= pack("v", $break);
}
$this->_prepend($header.$data);
}
/**
* Set the Biff PROTECT record to indicate that the worksheet is protected.
*
* @access private
*/
function _storeProtect()
{
// Exit unless sheet protection has been specified
if ($this->_protect == 0) {
return;
}
$record = 0x0012; // Record identifier
$length = 0x0002; // Bytes to follow
$fLock = $this->_protect; // Worksheet is protected
$header = pack("vv", $record, $length);
$data = pack("v", $fLock);
$this->_prepend($header.$data);
}
/**
* Write the worksheet PASSWORD record.
*
* @access private
*/
function _storePassword()
{
// Exit unless sheet protection and password have been specified
if (($this->_protect == 0) or (!isset($this->_password))) {
return;
}
$record = 0x0013; // Record identifier
$length = 0x0002; // Bytes to follow
$wPassword = $this->_password; // Encoded password
$header = pack("vv", $record, $length);
$data = pack("v", $wPassword);
$this->_prepend($header.$data);
}
 
/**
* Insert a 24bit bitmap image in a worksheet.
*
* @access public
* @param integer $row The row we are going to insert the bitmap into
* @param integer $col The column we are going to insert the bitmap into
* @param string $bitmap The bitmap filename
* @param integer $x The horizontal position (offset) of the image inside the cell.
* @param integer $y The vertical position (offset) of the image inside the cell.
* @param integer $scale_x The horizontal scale
* @param integer $scale_y The vertical scale
*/
function insertBitmap($row, $col, $bitmap, $x = 0, $y = 0, $scale_x = 1, $scale_y = 1)
{
$bitmap_array = $this->_processBitmap($bitmap);
if ($this->isError($bitmap_array))
{
$this->writeString($row, $col, $bitmap_array->getMessage());
return;
}
list($width, $height, $size, $data) = $bitmap_array; //$this->_processBitmap($bitmap);
// Scale the frame of the image.
$width *= $scale_x;
$height *= $scale_y;
// Calculate the vertices of the image and write the OBJ record
$this->_positionImage($col, $row, $x, $y, $width, $height);
// Write the IMDATA record to store the bitmap data
$record = 0x007f;
$length = 8 + $size;
$cf = 0x09;
$env = 0x01;
$lcb = $size;
$header = pack("vvvvV", $record, $length, $cf, $env, $lcb);
$this->_append($header.$data);
}
/**
* Calculate the vertices that define the position of the image as required by
* the OBJ record.
*
* +------------+------------+
* | A | B |
* +-----+------------+------------+
* | |(x1,y1) | |
* | 1 |(A1)._______|______ |
* | | | | |
* | | | | |
* +-----+----| BITMAP |-----+
* | | | | |
* | 2 | |______________. |
* | | | (B2)|
* | | | (x2,y2)|
* +---- +------------+------------+
*
* Example of a bitmap that covers some of the area from cell A1 to cell B2.
*
* Based on the width and height of the bitmap we need to calculate 8 vars:
* $col_start, $row_start, $col_end, $row_end, $x1, $y1, $x2, $y2.
* The width and height of the cells are also variable and have to be taken into
* account.
* The values of $col_start and $row_start are passed in from the calling
* function. The values of $col_end and $row_end are calculated by subtracting
* the width and height of the bitmap from the width and height of the
* underlying cells.
* The vertices are expressed as a percentage of the underlying cell width as
* follows (rhs values are in pixels):
*
* x1 = X / W *1024
* y1 = Y / H *256
* x2 = (X-1) / W *1024
* y2 = (Y-1) / H *256
*
* Where: X is distance from the left side of the underlying cell
* Y is distance from the top of the underlying cell
* W is the width of the cell
* H is the height of the cell
*
* @access private
* @note the SDK incorrectly states that the height should be expressed as a
* percentage of 1024.
* @param integer $col_start Col containing upper left corner of object
* @param integer $row_start Row containing top left corner of object
* @param integer $x1 Distance to left side of object
* @param integer $y1 Distance to top of object
* @param integer $width Width of image frame
* @param integer $height Height of image frame
*/
function _positionImage($col_start, $row_start, $x1, $y1, $width, $height)
{
// Initialise end cell to the same as the start cell
$col_end = $col_start; // Col containing lower right corner of object
$row_end = $row_start; // Row containing bottom right corner of object
// Zero the specified offset if greater than the cell dimensions
if ($x1 >= $this->_sizeCol($col_start))
{
$x1 = 0;
}
if ($y1 >= $this->_sizeRow($row_start))
{
$y1 = 0;
}
$width = $width + $x1 -1;
$height = $height + $y1 -1;
// Subtract the underlying cell widths to find the end cell of the image
while ($width >= $this->_sizeCol($col_end)) {
$width -= $this->_sizeCol($col_end);
$col_end++;
}
// Subtract the underlying cell heights to find the end cell of the image
while ($height >= $this->_sizeRow($row_end)) {
$height -= $this->_sizeRow($row_end);
$row_end++;
}
// Bitmap isn't allowed to start or finish in a hidden cell, i.e. a cell
// with zero eight or width.
//
if ($this->_sizeCol($col_start) == 0)
return;
if ($this->_sizeCol($col_end) == 0)
return;
if ($this->_sizeRow($row_start) == 0)
return;
if ($this->_sizeRow($row_end) == 0)
return;
// Convert the pixel values to the percentage value expected by Excel
$x1 = $x1 / $this->_sizeCol($col_start) * 1024;
$y1 = $y1 / $this->_sizeRow($row_start) * 256;
$x2 = $width / $this->_sizeCol($col_end) * 1024; // Distance to right side of object
$y2 = $height / $this->_sizeRow($row_end) * 256; // Distance to bottom of object
$this->_storeObjPicture( $col_start, $x1,
$row_start, $y1,
$col_end, $x2,
$row_end, $y2
);
}
/**
* Convert the width of a cell from user's units to pixels. By interpolation
* the relationship is: y = 7x +5. If the width hasn't been set by the user we
* use the default value. If the col is hidden we use a value of zero.
*
* @access private
* @param integer $col The column
* @return integer The width in pixels
*/
function _sizeCol($col)
{
// Look up the cell value to see if it has been changed
if (isset($this->col_sizes[$col])) {
if ($this->col_sizes[$col] == 0) {
return(0);
}
else {
return(floor(7 * $this->col_sizes[$col] + 5));
}
}
else {
return(64);
}
}
/**
* Convert the height of a cell from user's units to pixels. By interpolation
* the relationship is: y = 4/3x. If the height hasn't been set by the user we
* use the default value. If the row is hidden we use a value of zero. (Not
* possible to hide row yet).
*
* @access private
* @param integer $row The row
* @return integer The width in pixels
*/
function _sizeRow($row)
{
// Look up the cell value to see if it has been changed
if (isset($this->row_sizes[$row])) {
if ($this->row_sizes[$row] == 0) {
return(0);
}
else {
return(floor(4/3 * $this->row_sizes[$row]));
}
}
else {
return(17);
}
}
/**
* Store the OBJ record that precedes an IMDATA record. This could be generalise
* to support other Excel objects.
*
* @access private
* @param integer $colL Column containing upper left corner of object
* @param integer $dxL Distance from left side of cell
* @param integer $rwT Row containing top left corner of object
* @param integer $dyT Distance from top of cell
* @param integer $colR Column containing lower right corner of object
* @param integer $dxR Distance from right of cell
* @param integer $rwB Row containing bottom right corner of object
* @param integer $dyB Distance from bottom of cell
*/
function _storeObjPicture($colL,$dxL,$rwT,$dyT,$colR,$dxR,$rwB,$dyB)
{
$record = 0x005d; // Record identifier
$length = 0x003c; // Bytes to follow
$cObj = 0x0001; // Count of objects in file (set to 1)
$OT = 0x0008; // Object type. 8 = Picture
$id = 0x0001; // Object ID
$grbit = 0x0614; // Option flags
$cbMacro = 0x0000; // Length of FMLA structure
$Reserved1 = 0x0000; // Reserved
$Reserved2 = 0x0000; // Reserved
$icvBack = 0x09; // Background colour
$icvFore = 0x09; // Foreground colour
$fls = 0x00; // Fill pattern
$fAuto = 0x00; // Automatic fill
$icv = 0x08; // Line colour
$lns = 0xff; // Line style
$lnw = 0x01; // Line weight
$fAutoB = 0x00; // Automatic border
$frs = 0x0000; // Frame style
$cf = 0x0009; // Image format, 9 = bitmap
$Reserved3 = 0x0000; // Reserved
$cbPictFmla = 0x0000; // Length of FMLA structure
$Reserved4 = 0x0000; // Reserved
$grbit2 = 0x0001; // Option flags
$Reserved5 = 0x0000; // Reserved
$header = pack("vv", $record, $length);
$data = pack("V", $cObj);
$data .= pack("v", $OT);
$data .= pack("v", $id);
$data .= pack("v", $grbit);
$data .= pack("v", $colL);
$data .= pack("v", $dxL);
$data .= pack("v", $rwT);
$data .= pack("v", $dyT);
$data .= pack("v", $colR);
$data .= pack("v", $dxR);
$data .= pack("v", $rwB);
$data .= pack("v", $dyB);
$data .= pack("v", $cbMacro);
$data .= pack("V", $Reserved1);
$data .= pack("v", $Reserved2);
$data .= pack("C", $icvBack);
$data .= pack("C", $icvFore);
$data .= pack("C", $fls);
$data .= pack("C", $fAuto);
$data .= pack("C", $icv);
$data .= pack("C", $lns);
$data .= pack("C", $lnw);
$data .= pack("C", $fAutoB);
$data .= pack("v", $frs);
$data .= pack("V", $cf);
$data .= pack("v", $Reserved3);
$data .= pack("v", $cbPictFmla);
$data .= pack("v", $Reserved4);
$data .= pack("v", $grbit2);
$data .= pack("V", $Reserved5);
$this->_append($header.$data);
}
/**
* Convert a 24 bit bitmap into the modified internal format used by Windows.
* This is described in BITMAPCOREHEADER and BITMAPCOREINFO structures in the
* MSDN library.
*
* @access private
* @param string $bitmap The bitmap to process
* @return array Array with data and properties of the bitmap
*/
function _processBitmap($bitmap)
{
// Open file.
$bmp_fd = @fopen($bitmap,"rb");
if (!$bmp_fd) {
return($this->raiseError("Couldn't import $bitmap"));
}
// Slurp the file into a string.
$data = fread($bmp_fd, filesize($bitmap));
// Check that the file is big enough to be a bitmap.
if (strlen($data) <= 0x36) {
return($this->raiseError("$bitmap doesn't contain enough data.\n"));
}
// The first 2 bytes are used to identify the bitmap.
$identity = unpack("A2", $data);
if ($identity[''] != "BM") {
return($this->raiseError("$bitmap doesn't appear to be a valid bitmap image.\n"));
}
// Remove bitmap data: ID.
$data = substr($data, 2);
// Read and remove the bitmap size. This is more reliable than reading
// the data size at offset 0x22.
//
$size_array = unpack("V", substr($data, 0, 4));
$size = $size_array[''];
$data = substr($data, 4);
$size -= 0x36; // Subtract size of bitmap header.
$size += 0x0C; // Add size of BIFF header.
// Remove bitmap data: reserved, offset, header length.
$data = substr($data, 12);
// Read and remove the bitmap width and height. Verify the sizes.
$width_and_height = unpack("V2", substr($data, 0, 8));
$width = $width_and_height[1];
$height = $width_and_height[2];
$data = substr($data, 8);
if ($width > 0xFFFF) {
return($this->raiseError("$bitmap: largest image width supported is 65k.\n"));
}
if ($height > 0xFFFF) {
return($this->raiseError("$bitmap: largest image height supported is 65k.\n"));
}
// Read and remove the bitmap planes and bpp data. Verify them.
$planes_and_bitcount = unpack("v2", substr($data, 0, 4));
$data = substr($data, 4);
if ($planes_and_bitcount[2] != 24) { // Bitcount
return($this->raiseError("$bitmap isn't a 24bit true color bitmap.\n"));
}
if ($planes_and_bitcount[1] != 1) {
return($this->raiseError("$bitmap: only 1 plane nupported in bitmap image.\n"));
}
// Read and remove the bitmap compression. Verify compression.
$compression = unpack("V", substr($data, 0, 4));
$data = substr($data, 4);
//$compression = 0;
if ($compression[""] != 0) {
return($this->raiseError("$bitmap: compression not supported in bitmap image.\n"));
}
// Remove bitmap data: data size, hres, vres, colours, imp. colours.
$data = substr($data, 20);
// Add the BITMAPCOREHEADER data
$header = pack("Vvvvv", 0x000c, $width, $height, 0x01, 0x18);
$data = $header . $data;
return (array($width, $height, $size, $data));
}
/**
* Store the window zoom factor. This should be a reduced fraction but for
* simplicity we will store all fractions with a numerator of 100.
*
* @access private
*/
function _storeZoom()
{
// If scale is 100 we don't need to write a record
if ($this->_zoom == 100) {
return;
}
$record = 0x00A0; // Record identifier
$length = 0x0004; // Bytes to follow
$header = pack("vv", $record, $length);
$data = pack("vv", $this->_zoom, 100);
$this->_append($header.$data);
}
}
?>
/tags/v3.1-blanche-neige/jrest/lib/Spreadsheet/Excel/Writer/OLEwriter.php
New file
0,0 → 1,428
<?php
/*
* Module written/ported by Xavier Noguer <xnoguer@rezebra.com>
*
* The majority of this is _NOT_ my code. I simply ported it from the
* PERL Spreadsheet::WriteExcel module.
*
* The author of the Spreadsheet::WriteExcel module is John McNamara
* <jmcnamara@cpan.org>
*
* I _DO_ maintain this code, and John McNamara has nothing to do with the
* porting of this code to PHP. Any questions directly related to this
* class library should be directed to me.
*
* License Information:
*
* Spreadsheet_Excel_Writer: A library for generating Excel Spreadsheets
* Copyright (c) 2002-2003 Xavier Noguer xnoguer@rezebra.com
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
 
require_once('PEAR.php');
 
/**
* Class for creating OLE streams for Excel Spreadsheets
*
* @author Xavier Noguer <xnoguer@rezebra.com>
* @category FileFormats
* @package Spreadsheet_Excel_Writer
*/
 
class Spreadsheet_Excel_Writer_OLEwriter extends PEAR
{
/**
* Filename for the OLE stream
* @var string
* @see _initialize()
*/
var $_OLEfilename;
 
/**
* Filehandle for the OLE stream
* @var resource
*/
var $_filehandle;
 
/**
* Name of the temporal file in case OLE stream goes to stdout
* @var string
*/
var $_tmp_filename;
 
/**
* Variable for preventing closing two times
* @var integer
*/
var $_fileclosed;
 
/**
* Size of the data to be written to the OLE stream
* @var integer
*/
var $_biffsize;
 
/**
* Real data size to be written to the OLE stream
* @var integer
*/
var $_booksize;
 
/**
* Number of big blocks in the OLE stream
* @var integer
*/
var $_big_blocks;
 
/**
* Number of list blocks in the OLE stream
* @var integer
*/
var $_list_blocks;
 
/**
* Number of big blocks in the OLE stream
* @var integer
*/
var $_root_start;
 
/**
* Constructor for the OLEwriter class
*
* @param string $OLEfilename the name of the file for the OLE stream
*/
function Spreadsheet_Excel_Writer_OLEwriter($OLEfilename)
{
$this->_OLEfilename = $OLEfilename;
$this->_filehandle = "";
$this->_tmp_filename = "";
$this->_fileclosed = 0;
$this->_biff_only = 0;
//$this->_size_allowed = 0;
$this->_biffsize = 0;
$this->_booksize = 0;
$this->_big_blocks = 0;
$this->_list_blocks = 0;
$this->_root_start = 0;
//$this->_block_count = 4;
$this->_initialize();
}
 
/**
* Check for a valid filename and store the filehandle.
* Filehandle "-" writes to STDOUT
*
* @access private
*/
function _initialize()
{
$OLEfile = $this->_OLEfilename;
if(($OLEfile == '-') or ($OLEfile == ''))
{
$this->_tmp_filename = tempnam("/tmp", "OLEwriter");
$fh = fopen($this->_tmp_filename,"wb");
if ($fh == false) {
$this->raiseError("Can't create temporary file.");
}
}
else
{
// Create a new file, open for writing (in binmode)
$fh = fopen($OLEfile,"wb");
if ($fh == false) {
$this->raiseError("Can't open $OLEfile. It may be in use or protected.");
}
}
// Store filehandle
$this->_filehandle = $fh;
}
 
 
/**
* Set the size of the data to be written to the OLE stream.
* The maximun size comes from this:
* $big_blocks = (109 depot block x (128 -1 marker word)
* - (1 x end words)) = 13842
* $maxsize = $big_blocks * 512 bytes = 7087104
*
* @access public
* @see Spreadsheet_Excel_Writer_Workbook::store_OLE_file()
* @param integer $biffsize The size of the data to be written to the OLE stream
* @return integer 1 for success
*/
function setSize($biffsize)
{
$maxsize = 7087104; // TODO: extend max size
if ($biffsize > $maxsize) {
$this->raiseError("Maximum file size, $maxsize, exceeded.");
}
$this->_biffsize = $biffsize;
// Set the min file size to 4k to avoid having to use small blocks
if ($biffsize > 4096) {
$this->_booksize = $biffsize;
}
else {
$this->_booksize = 4096;
}
//$this->_size_allowed = 1;
return(1);
}
 
 
/**
* Calculate various sizes needed for the OLE stream
*
* @access private
*/
function _calculateSizes()
{
$datasize = $this->_booksize;
if ($datasize % 512 == 0) {
$this->_big_blocks = $datasize/512;
}
else {
$this->_big_blocks = floor($datasize/512) + 1;
}
// There are 127 list blocks and 1 marker blocks for each big block
// depot + 1 end of chain block
$this->_list_blocks = floor(($this->_big_blocks)/127) + 1;
$this->_root_start = $this->_big_blocks;
}
 
/**
* Write root entry, big block list and close the filehandle.
* This routine is used to explicitly close the open filehandle without
* having to wait for DESTROY.
*
* @access public
* @see Spreadsheet_Excel_Writer_Workbook::store_OLE_file()
*/
function close()
{
//return if not $this->{_size_allowed};
$this->_writePadding();
$this->_writePropertyStorage();
$this->_writeBigBlockDepot();
// Close the filehandle
fclose($this->_filehandle);
if(($this->_OLEfilename == '-') or ($this->_OLEfilename == ''))
{
$fh = fopen($this->_tmp_filename, "rb");
if ($fh == false) {
$this->raiseError("Can't read temporary file.");
}
fpassthru($fh);
@unlink($this->_tmp_filename);
}
$this->_fileclosed = 1;
}
 
 
/**
* Write BIFF data to OLE file.
*
* @param string $data string of bytes to be written
*/
function write($data)
{
fwrite($this->_filehandle,$data,strlen($data));
}
 
 
/**
* Write OLE header block.
*/
function writeHeader()
{
$this->_calculateSizes();
$root_start = $this->_root_start;
$num_lists = $this->_list_blocks;
$id = pack("nnnn", 0xD0CF, 0x11E0, 0xA1B1, 0x1AE1);
$unknown1 = pack("VVVV", 0x00, 0x00, 0x00, 0x00);
$unknown2 = pack("vv", 0x3E, 0x03);
$unknown3 = pack("v", -2);
$unknown4 = pack("v", 0x09);
$unknown5 = pack("VVV", 0x06, 0x00, 0x00);
$num_bbd_blocks = pack("V", $num_lists);
$root_startblock = pack("V", $root_start);
$unknown6 = pack("VV", 0x00, 0x1000);
$sbd_startblock = pack("V", -2);
$unknown7 = pack("VVV", 0x00, -2 ,0x00);
$unused = pack("V", -1);
fwrite($this->_filehandle,$id);
fwrite($this->_filehandle,$unknown1);
fwrite($this->_filehandle,$unknown2);
fwrite($this->_filehandle,$unknown3);
fwrite($this->_filehandle,$unknown4);
fwrite($this->_filehandle,$unknown5);
fwrite($this->_filehandle,$num_bbd_blocks);
fwrite($this->_filehandle,$root_startblock);
fwrite($this->_filehandle,$unknown6);
fwrite($this->_filehandle,$sbd_startblock);
fwrite($this->_filehandle,$unknown7);
for($i=1; $i <= $num_lists; $i++)
{
$root_start++;
fwrite($this->_filehandle,pack("V",$root_start));
}
for($i = $num_lists; $i <=108; $i++)
{
fwrite($this->_filehandle,$unused);
}
}
 
 
/**
* Write big block depot.
*
* @access private
*/
function _writeBigBlockDepot()
{
$num_blocks = $this->_big_blocks;
$num_lists = $this->_list_blocks;
$total_blocks = $num_lists *128;
$used_blocks = $num_blocks + $num_lists +2;
$marker = pack("V", -3);
$end_of_chain = pack("V", -2);
$unused = pack("V", -1);
for($i=1; $i < $num_blocks; $i++)
{
fwrite($this->_filehandle,pack("V",$i));
}
fwrite($this->_filehandle,$end_of_chain);
fwrite($this->_filehandle,$end_of_chain);
for($i=0; $i < $num_lists; $i++)
{
fwrite($this->_filehandle,$marker);
}
for($i=$used_blocks; $i <= $total_blocks; $i++)
{
fwrite($this->_filehandle,$unused);
}
}
 
/**
* Write property storage. TODO: add summary sheets
*
* @access private
*/
function _writePropertyStorage()
{
//$rootsize = -2;
/*************** name type dir start size */
$this->_writePps("Root Entry", 0x05, 1, -2, 0x00);
$this->_writePps("Book", 0x02, -1, 0x00, $this->_booksize);
$this->_writePps('', 0x00, -1, 0x00, 0x0000);
$this->_writePps('', 0x00, -1, 0x00, 0x0000);
}
 
/**
* Write property sheet in property storage
*
* @param string $name name of the property storage.
* @param integer $type type of the property storage.
* @param integer $dir dir of the property storage.
* @param integer $start start of the property storage.
* @param integer $size size of the property storage.
* @access private
*/
function _writePps($name,$type,$dir,$start,$size)
{
$length = 0;
$rawname = '';
if ($name != '')
{
$name = $name . "\0";
for($i=0;$i<strlen($name);$i++)
{
// Simulate a Unicode string
$rawname .= pack("H*",dechex(ord($name{$i}))).pack("C",0);
}
$length = strlen($name) * 2;
}
$zero = pack("C", 0);
$pps_sizeofname = pack("v", $length); // 0x40
$pps_type = pack("v", $type); // 0x42
$pps_prev = pack("V", -1); // 0x44
$pps_next = pack("V", -1); // 0x48
$pps_dir = pack("V", $dir); // 0x4c
$unknown1 = pack("V", 0);
$pps_ts1s = pack("V", 0); // 0x64
$pps_ts1d = pack("V", 0); // 0x68
$pps_ts2s = pack("V", 0); // 0x6c
$pps_ts2d = pack("V", 0); // 0x70
$pps_sb = pack("V", $start); // 0x74
$pps_size = pack("V", $size); // 0x78
fwrite($this->_filehandle,$rawname);
for($i=0; $i < (64 -$length); $i++) {
fwrite($this->_filehandle,$zero);
}
fwrite($this->_filehandle,$pps_sizeofname);
fwrite($this->_filehandle,$pps_type);
fwrite($this->_filehandle,$pps_prev);
fwrite($this->_filehandle,$pps_next);
fwrite($this->_filehandle,$pps_dir);
for($i=0; $i < 5; $i++) {
fwrite($this->_filehandle,$unknown1);
}
fwrite($this->_filehandle,$pps_ts1s);
fwrite($this->_filehandle,$pps_ts1d);
fwrite($this->_filehandle,$pps_ts2d);
fwrite($this->_filehandle,$pps_ts2d);
fwrite($this->_filehandle,$pps_sb);
fwrite($this->_filehandle,$pps_size);
fwrite($this->_filehandle,$unknown1);
}
 
/**
* Pad the end of the file
*
* @access private
*/
function _writePadding()
{
$biffsize = $this->_biffsize;
if ($biffsize < 4096) {
$min_size = 4096;
}
else {
$min_size = 512;
}
if ($biffsize % $min_size != 0)
{
$padding = $min_size - ($biffsize % $min_size);
for($i=0; $i < $padding; $i++) {
fwrite($this->_filehandle,"\0");
}
}
}
}
?>
/tags/v3.1-blanche-neige/jrest/lib/Spreadsheet/Excel/Writer/Parser.php
New file
0,0 → 1,1551
<?php
/**
* Class for parsing Excel formulas
*
* License Information:
*
* Spreadsheet_Excel_Writer: A library for generating Excel Spreadsheets
* Copyright (c) 2002-2003 Xavier Noguer xnoguer@rezebra.com
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
 
/**
* @const SPREADSHEET_EXCEL_WRITER_ADD token identifier for character "+"
*/
define('SPREADSHEET_EXCEL_WRITER_ADD',"+");
 
/**
* @const SPREADSHEET_EXCEL_WRITER_SUB token identifier for character "-"
*/
define('SPREADSHEET_EXCEL_WRITER_SUB',"-");
 
/**
* @const SPREADSHEET_EXCEL_WRITER_MUL token identifier for character "*"
*/
define('SPREADSHEET_EXCEL_WRITER_MUL',"*");
 
/**
* @const SPREADSHEET_EXCEL_WRITER_DIV token identifier for character "/"
*/
define('SPREADSHEET_EXCEL_WRITER_DIV',"/");
 
/**
* @const SPREADSHEET_EXCEL_WRITER_OPEN token identifier for character "("
*/
define('SPREADSHEET_EXCEL_WRITER_OPEN',"(");
 
/**
* @const SPREADSHEET_EXCEL_WRITER_CLOSE token identifier for character ")"
*/
define('SPREADSHEET_EXCEL_WRITER_CLOSE',")");
 
/**
* @const SPREADSHEET_EXCEL_WRITER_COMA token identifier for character ","
*/
define('SPREADSHEET_EXCEL_WRITER_COMA',",");
 
/**
* @const SPREADSHEET_EXCEL_WRITER_GT token identifier for character ">"
*/
define('SPREADSHEET_EXCEL_WRITER_GT',">");
 
/**
* @const SPREADSHEET_EXCEL_WRITER_LT token identifier for character "<"
*/
define('SPREADSHEET_EXCEL_WRITER_LT',"<");
 
/**
* @const SPREADSHEET_EXCEL_WRITER_LE token identifier for character "<="
*/
define('SPREADSHEET_EXCEL_WRITER_LE',"<=");
 
/**
* @const SPREADSHEET_EXCEL_WRITER_GE token identifier for character ">="
*/
define('SPREADSHEET_EXCEL_WRITER_GE',">=");
 
/**
* @const SPREADSHEET_EXCEL_WRITER_EQ token identifier for character "="
*/
define('SPREADSHEET_EXCEL_WRITER_EQ',"=");
 
/**
* @const SPREADSHEET_EXCEL_WRITER_NE token identifier for character "<>"
*/
define('SPREADSHEET_EXCEL_WRITER_NE',"<>");
 
 
require_once('PEAR.php');
 
/**
* Class for parsing Excel formulas
*
* @author Xavier Noguer <xnoguer@rezebra.com>
* @category FileFormats
* @package Spreadsheet_Excel_Writer
*/
 
class Spreadsheet_Excel_Writer_Parser extends PEAR
{
/**
* The index of the character we are currently looking at
* @var integer
*/
var $_current_char;
 
/**
* The token we are working on.
* @var string
*/
var $_current_token;
 
/**
* The formula to parse
* @var string
*/
var $_formula;
 
/**
* The character ahead of the current char
* @var string
*/
var $_lookahead;
 
/**
* The parse tree to be generated
* @var string
*/
var $_parse_tree;
 
/**
* The byte order. 1 => big endian, 0 => little endian.
* @var integer
*/
var $_byte_order;
 
/**
* Number of arguments for the current function
* @var integer
*/
var $_func_args;
 
/**
* Array of external sheets
* @var array
*/
var $_ext_sheets;
 
/**
* The class constructor
*
* @param integer $byte_order The byte order (Little endian or Big endian) of the architecture
(optional). 1 => big endian, 0 (default) => little endian.
*/
function Spreadsheet_Excel_Writer_Parser($byte_order = 0)
{
$this->_current_char = 0;
$this->_current_token = ''; // The token we are working on.
$this->_formula = ""; // The formula to parse.
$this->_lookahead = ''; // The character ahead of the current char.
$this->_parse_tree = ''; // The parse tree to be generated.
$this->_initializeHashes(); // Initialize the hashes: ptg's and function's ptg's
$this->_byte_order = $byte_order; // Little Endian or Big Endian
$this->_func_args = 0; // Number of arguments for the current function
$this->_ext_sheets = array();
}
/**
* Initialize the ptg and function hashes.
*
* @access private
*/
function _initializeHashes()
{
// The Excel ptg indices
$this->ptg = array(
'ptgExp' => 0x01,
'ptgTbl' => 0x02,
'ptgAdd' => 0x03,
'ptgSub' => 0x04,
'ptgMul' => 0x05,
'ptgDiv' => 0x06,
'ptgPower' => 0x07,
'ptgConcat' => 0x08,
'ptgLT' => 0x09,
'ptgLE' => 0x0A,
'ptgEQ' => 0x0B,
'ptgGE' => 0x0C,
'ptgGT' => 0x0D,
'ptgNE' => 0x0E,
'ptgIsect' => 0x0F,
'ptgUnion' => 0x10,
'ptgRange' => 0x11,
'ptgUplus' => 0x12,
'ptgUminus' => 0x13,
'ptgPercent' => 0x14,
'ptgParen' => 0x15,
'ptgMissArg' => 0x16,
'ptgStr' => 0x17,
'ptgAttr' => 0x19,
'ptgSheet' => 0x1A,
'ptgEndSheet' => 0x1B,
'ptgErr' => 0x1C,
'ptgBool' => 0x1D,
'ptgInt' => 0x1E,
'ptgNum' => 0x1F,
'ptgArray' => 0x20,
'ptgFunc' => 0x21,
'ptgFuncVar' => 0x22,
'ptgName' => 0x23,
'ptgRef' => 0x24,
'ptgArea' => 0x25,
'ptgMemArea' => 0x26,
'ptgMemErr' => 0x27,
'ptgMemNoMem' => 0x28,
'ptgMemFunc' => 0x29,
'ptgRefErr' => 0x2A,
'ptgAreaErr' => 0x2B,
'ptgRefN' => 0x2C,
'ptgAreaN' => 0x2D,
'ptgMemAreaN' => 0x2E,
'ptgMemNoMemN' => 0x2F,
'ptgNameX' => 0x39,
'ptgRef3d' => 0x3A,
'ptgArea3d' => 0x3B,
'ptgRefErr3d' => 0x3C,
'ptgAreaErr3d' => 0x3D,
'ptgArrayV' => 0x40,
'ptgFuncV' => 0x41,
'ptgFuncVarV' => 0x42,
'ptgNameV' => 0x43,
'ptgRefV' => 0x44,
'ptgAreaV' => 0x45,
'ptgMemAreaV' => 0x46,
'ptgMemErrV' => 0x47,
'ptgMemNoMemV' => 0x48,
'ptgMemFuncV' => 0x49,
'ptgRefErrV' => 0x4A,
'ptgAreaErrV' => 0x4B,
'ptgRefNV' => 0x4C,
'ptgAreaNV' => 0x4D,
'ptgMemAreaNV' => 0x4E,
'ptgMemNoMemN' => 0x4F,
'ptgFuncCEV' => 0x58,
'ptgNameXV' => 0x59,
'ptgRef3dV' => 0x5A,
'ptgArea3dV' => 0x5B,
'ptgRefErr3dV' => 0x5C,
'ptgAreaErr3d' => 0x5D,
'ptgArrayA' => 0x60,
'ptgFuncA' => 0x61,
'ptgFuncVarA' => 0x62,
'ptgNameA' => 0x63,
'ptgRefA' => 0x64,
'ptgAreaA' => 0x65,
'ptgMemAreaA' => 0x66,
'ptgMemErrA' => 0x67,
'ptgMemNoMemA' => 0x68,
'ptgMemFuncA' => 0x69,
'ptgRefErrA' => 0x6A,
'ptgAreaErrA' => 0x6B,
'ptgRefNA' => 0x6C,
'ptgAreaNA' => 0x6D,
'ptgMemAreaNA' => 0x6E,
'ptgMemNoMemN' => 0x6F,
'ptgFuncCEA' => 0x78,
'ptgNameXA' => 0x79,
'ptgRef3dA' => 0x7A,
'ptgArea3dA' => 0x7B,
'ptgRefErr3dA' => 0x7C,
'ptgAreaErr3d' => 0x7D
);
// Thanks to Michael Meeks and Gnumeric for the initial arg values.
//
// The following hash was generated by "function_locale.pl" in the distro.
// Refer to function_locale.pl for non-English function names.
//
// The array elements are as follow:
// ptg: The Excel function ptg code.
// args: The number of arguments that the function takes:
// >=0 is a fixed number of arguments.
// -1 is a variable number of arguments.
// class: The reference, value or array class of the function args.
// vol: The function is volatile.
//
$this->_functions = array(
// function ptg args class vol
'COUNT' => array( 0, -1, 0, 0 ),
'IF' => array( 1, -1, 1, 0 ),
'ISNA' => array( 2, 1, 1, 0 ),
'ISERROR' => array( 3, 1, 1, 0 ),
'SUM' => array( 4, -1, 0, 0 ),
'AVERAGE' => array( 5, -1, 0, 0 ),
'MIN' => array( 6, -1, 0, 0 ),
'MAX' => array( 7, -1, 0, 0 ),
'ROW' => array( 8, -1, 0, 0 ),
'COLUMN' => array( 9, -1, 0, 0 ),
'NA' => array( 10, 0, 0, 0 ),
'NPV' => array( 11, -1, 1, 0 ),
'STDEV' => array( 12, -1, 0, 0 ),
'DOLLAR' => array( 13, -1, 1, 0 ),
'FIXED' => array( 14, -1, 1, 0 ),
'SIN' => array( 15, 1, 1, 0 ),
'COS' => array( 16, 1, 1, 0 ),
'TAN' => array( 17, 1, 1, 0 ),
'ATAN' => array( 18, 1, 1, 0 ),
'PI' => array( 19, 0, 1, 0 ),
'SQRT' => array( 20, 1, 1, 0 ),
'EXP' => array( 21, 1, 1, 0 ),
'LN' => array( 22, 1, 1, 0 ),
'LOG10' => array( 23, 1, 1, 0 ),
'ABS' => array( 24, 1, 1, 0 ),
'INT' => array( 25, 1, 1, 0 ),
'SIGN' => array( 26, 1, 1, 0 ),
'ROUND' => array( 27, 2, 1, 0 ),
'LOOKUP' => array( 28, -1, 0, 0 ),
'INDEX' => array( 29, -1, 0, 1 ),
'REPT' => array( 30, 2, 1, 0 ),
'MID' => array( 31, 3, 1, 0 ),
'LEN' => array( 32, 1, 1, 0 ),
'VALUE' => array( 33, 1, 1, 0 ),
'TRUE' => array( 34, 0, 1, 0 ),
'FALSE' => array( 35, 0, 1, 0 ),
'AND' => array( 36, -1, 0, 0 ),
'OR' => array( 37, -1, 0, 0 ),
'NOT' => array( 38, 1, 1, 0 ),
'MOD' => array( 39, 2, 1, 0 ),
'DCOUNT' => array( 40, 3, 0, 0 ),
'DSUM' => array( 41, 3, 0, 0 ),
'DAVERAGE' => array( 42, 3, 0, 0 ),
'DMIN' => array( 43, 3, 0, 0 ),
'DMAX' => array( 44, 3, 0, 0 ),
'DSTDEV' => array( 45, 3, 0, 0 ),
'VAR' => array( 46, -1, 0, 0 ),
'DVAR' => array( 47, 3, 0, 0 ),
'TEXT' => array( 48, 2, 1, 0 ),
'LINEST' => array( 49, -1, 0, 0 ),
'TREND' => array( 50, -1, 0, 0 ),
'LOGEST' => array( 51, -1, 0, 0 ),
'GROWTH' => array( 52, -1, 0, 0 ),
'PV' => array( 56, -1, 1, 0 ),
'FV' => array( 57, -1, 1, 0 ),
'NPER' => array( 58, -1, 1, 0 ),
'PMT' => array( 59, -1, 1, 0 ),
'RATE' => array( 60, -1, 1, 0 ),
'MIRR' => array( 61, 3, 0, 0 ),
'IRR' => array( 62, -1, 0, 0 ),
'RAND' => array( 63, 0, 1, 1 ),
'MATCH' => array( 64, -1, 0, 0 ),
'DATE' => array( 65, 3, 1, 0 ),
'TIME' => array( 66, 3, 1, 0 ),
'DAY' => array( 67, 1, 1, 0 ),
'MONTH' => array( 68, 1, 1, 0 ),
'YEAR' => array( 69, 1, 1, 0 ),
'WEEKDAY' => array( 70, -1, 1, 0 ),
'HOUR' => array( 71, 1, 1, 0 ),
'MINUTE' => array( 72, 1, 1, 0 ),
'SECOND' => array( 73, 1, 1, 0 ),
'NOW' => array( 74, 0, 1, 1 ),
'AREAS' => array( 75, 1, 0, 1 ),
'ROWS' => array( 76, 1, 0, 1 ),
'COLUMNS' => array( 77, 1, 0, 1 ),
'OFFSET' => array( 78, -1, 0, 1 ),
'SEARCH' => array( 82, -1, 1, 0 ),
'TRANSPOSE' => array( 83, 1, 1, 0 ),
'TYPE' => array( 86, 1, 1, 0 ),
'ATAN2' => array( 97, 2, 1, 0 ),
'ASIN' => array( 98, 1, 1, 0 ),
'ACOS' => array( 99, 1, 1, 0 ),
'CHOOSE' => array( 100, -1, 1, 0 ),
'HLOOKUP' => array( 101, -1, 0, 0 ),
'VLOOKUP' => array( 102, -1, 0, 0 ),
'ISREF' => array( 105, 1, 0, 0 ),
'LOG' => array( 109, -1, 1, 0 ),
'CHAR' => array( 111, 1, 1, 0 ),
'LOWER' => array( 112, 1, 1, 0 ),
'UPPER' => array( 113, 1, 1, 0 ),
'PROPER' => array( 114, 1, 1, 0 ),
'LEFT' => array( 115, -1, 1, 0 ),
'RIGHT' => array( 116, -1, 1, 0 ),
'EXACT' => array( 117, 2, 1, 0 ),
'TRIM' => array( 118, 1, 1, 0 ),
'REPLACE' => array( 119, 4, 1, 0 ),
'SUBSTITUTE' => array( 120, -1, 1, 0 ),
'CODE' => array( 121, 1, 1, 0 ),
'FIND' => array( 124, -1, 1, 0 ),
'CELL' => array( 125, -1, 0, 1 ),
'ISERR' => array( 126, 1, 1, 0 ),
'ISTEXT' => array( 127, 1, 1, 0 ),
'ISNUMBER' => array( 128, 1, 1, 0 ),
'ISBLANK' => array( 129, 1, 1, 0 ),
'T' => array( 130, 1, 0, 0 ),
'N' => array( 131, 1, 0, 0 ),
'DATEVALUE' => array( 140, 1, 1, 0 ),
'TIMEVALUE' => array( 141, 1, 1, 0 ),
'SLN' => array( 142, 3, 1, 0 ),
'SYD' => array( 143, 4, 1, 0 ),
'DDB' => array( 144, -1, 1, 0 ),
'INDIRECT' => array( 148, -1, 1, 1 ),
'CALL' => array( 150, -1, 1, 0 ),
'CLEAN' => array( 162, 1, 1, 0 ),
'MDETERM' => array( 163, 1, 2, 0 ),
'MINVERSE' => array( 164, 1, 2, 0 ),
'MMULT' => array( 165, 2, 2, 0 ),
'IPMT' => array( 167, -1, 1, 0 ),
'PPMT' => array( 168, -1, 1, 0 ),
'COUNTA' => array( 169, -1, 0, 0 ),
'PRODUCT' => array( 183, -1, 0, 0 ),
'FACT' => array( 184, 1, 1, 0 ),
'DPRODUCT' => array( 189, 3, 0, 0 ),
'ISNONTEXT' => array( 190, 1, 1, 0 ),
'STDEVP' => array( 193, -1, 0, 0 ),
'VARP' => array( 194, -1, 0, 0 ),
'DSTDEVP' => array( 195, 3, 0, 0 ),
'DVARP' => array( 196, 3, 0, 0 ),
'TRUNC' => array( 197, -1, 1, 0 ),
'ISLOGICAL' => array( 198, 1, 1, 0 ),
'DCOUNTA' => array( 199, 3, 0, 0 ),
'ROUNDUP' => array( 212, 2, 1, 0 ),
'ROUNDDOWN' => array( 213, 2, 1, 0 ),
'RANK' => array( 216, -1, 0, 0 ),
'ADDRESS' => array( 219, -1, 1, 0 ),
'DAYS360' => array( 220, -1, 1, 0 ),
'TODAY' => array( 221, 0, 1, 1 ),
'VDB' => array( 222, -1, 1, 0 ),
'MEDIAN' => array( 227, -1, 0, 0 ),
'SUMPRODUCT' => array( 228, -1, 2, 0 ),
'SINH' => array( 229, 1, 1, 0 ),
'COSH' => array( 230, 1, 1, 0 ),
'TANH' => array( 231, 1, 1, 0 ),
'ASINH' => array( 232, 1, 1, 0 ),
'ACOSH' => array( 233, 1, 1, 0 ),
'ATANH' => array( 234, 1, 1, 0 ),
'DGET' => array( 235, 3, 0, 0 ),
'INFO' => array( 244, 1, 1, 1 ),
'DB' => array( 247, -1, 1, 0 ),
'FREQUENCY' => array( 252, 2, 0, 0 ),
'ERROR.TYPE' => array( 261, 1, 1, 0 ),
'REGISTER.ID' => array( 267, -1, 1, 0 ),
'AVEDEV' => array( 269, -1, 0, 0 ),
'BETADIST' => array( 270, -1, 1, 0 ),
'GAMMALN' => array( 271, 1, 1, 0 ),
'BETAINV' => array( 272, -1, 1, 0 ),
'BINOMDIST' => array( 273, 4, 1, 0 ),
'CHIDIST' => array( 274, 2, 1, 0 ),
'CHIINV' => array( 275, 2, 1, 0 ),
'COMBIN' => array( 276, 2, 1, 0 ),
'CONFIDENCE' => array( 277, 3, 1, 0 ),
'CRITBINOM' => array( 278, 3, 1, 0 ),
'EVEN' => array( 279, 1, 1, 0 ),
'EXPONDIST' => array( 280, 3, 1, 0 ),
'FDIST' => array( 281, 3, 1, 0 ),
'FINV' => array( 282, 3, 1, 0 ),
'FISHER' => array( 283, 1, 1, 0 ),
'FISHERINV' => array( 284, 1, 1, 0 ),
'FLOOR' => array( 285, 2, 1, 0 ),
'GAMMADIST' => array( 286, 4, 1, 0 ),
'GAMMAINV' => array( 287, 3, 1, 0 ),
'CEILING' => array( 288, 2, 1, 0 ),
'HYPGEOMDIST' => array( 289, 4, 1, 0 ),
'LOGNORMDIST' => array( 290, 3, 1, 0 ),
'LOGINV' => array( 291, 3, 1, 0 ),
'NEGBINOMDIST' => array( 292, 3, 1, 0 ),
'NORMDIST' => array( 293, 4, 1, 0 ),
'NORMSDIST' => array( 294, 1, 1, 0 ),
'NORMINV' => array( 295, 3, 1, 0 ),
'NORMSINV' => array( 296, 1, 1, 0 ),
'STANDARDIZE' => array( 297, 3, 1, 0 ),
'ODD' => array( 298, 1, 1, 0 ),
'PERMUT' => array( 299, 2, 1, 0 ),
'POISSON' => array( 300, 3, 1, 0 ),
'TDIST' => array( 301, 3, 1, 0 ),
'WEIBULL' => array( 302, 4, 1, 0 ),
'SUMXMY2' => array( 303, 2, 2, 0 ),
'SUMX2MY2' => array( 304, 2, 2, 0 ),
'SUMX2PY2' => array( 305, 2, 2, 0 ),
'CHITEST' => array( 306, 2, 2, 0 ),
'CORREL' => array( 307, 2, 2, 0 ),
'COVAR' => array( 308, 2, 2, 0 ),
'FORECAST' => array( 309, 3, 2, 0 ),
'FTEST' => array( 310, 2, 2, 0 ),
'INTERCEPT' => array( 311, 2, 2, 0 ),
'PEARSON' => array( 312, 2, 2, 0 ),
'RSQ' => array( 313, 2, 2, 0 ),
'STEYX' => array( 314, 2, 2, 0 ),
'SLOPE' => array( 315, 2, 2, 0 ),
'TTEST' => array( 316, 4, 2, 0 ),
'PROB' => array( 317, -1, 2, 0 ),
'DEVSQ' => array( 318, -1, 0, 0 ),
'GEOMEAN' => array( 319, -1, 0, 0 ),
'HARMEAN' => array( 320, -1, 0, 0 ),
'SUMSQ' => array( 321, -1, 0, 0 ),
'KURT' => array( 322, -1, 0, 0 ),
'SKEW' => array( 323, -1, 0, 0 ),
'ZTEST' => array( 324, -1, 0, 0 ),
'LARGE' => array( 325, 2, 0, 0 ),
'SMALL' => array( 326, 2, 0, 0 ),
'QUARTILE' => array( 327, 2, 0, 0 ),
'PERCENTILE' => array( 328, 2, 0, 0 ),
'PERCENTRANK' => array( 329, -1, 0, 0 ),
'MODE' => array( 330, -1, 2, 0 ),
'TRIMMEAN' => array( 331, 2, 0, 0 ),
'TINV' => array( 332, 2, 1, 0 ),
'CONCATENATE' => array( 336, -1, 1, 0 ),
'POWER' => array( 337, 2, 1, 0 ),
'RADIANS' => array( 342, 1, 1, 0 ),
'DEGREES' => array( 343, 1, 1, 0 ),
'SUBTOTAL' => array( 344, -1, 0, 0 ),
'SUMIF' => array( 345, -1, 0, 0 ),
'COUNTIF' => array( 346, 2, 0, 0 ),
'COUNTBLANK' => array( 347, 1, 0, 0 ),
'ROMAN' => array( 354, -1, 1, 0 )
);
}
/**
* Convert a token to the proper ptg value.
*
* @access private
* @param mixed $token The token to convert.
*/
function _convert($token)
{
if (preg_match("/^\"[^\"]{0,255}\"$/", $token))
{
return $this->_convertString($token);
}
elseif (is_numeric($token))
{
return $this->_convertNumber($token);
}
// match references like A1 or $A$1
elseif(preg_match('/^\$?([A-I]?[A-Z])\$?(\d+)$/',$token))
{
return($this->_convertRef2d($token));
}
// match external references like Sheet1:Sheet2!A1
elseif (preg_match("/^[A-Za-z0-9_]+(\:[A-Za-z0-9_]+)?\![A-I]?[A-Z](\d+)$/",$token))
{
return $this->_convertRef3d($token);
}
// match ranges like A1:B2
elseif(preg_match("/^(\$)?[A-I]?[A-Z](\$)?(\d+)\:(\$)?[A-I]?[A-Z](\$)?(\d+)$/",$token))
{
return($this->_convertRange2d($token));
}
// match ranges like A1..B2
elseif(preg_match("/^(\$)?[A-I]?[A-Z](\$)?(\d+)\.\.(\$)?[A-I]?[A-Z](\$)?(\d+)$/",$token))
{
return($this->_convertRange2d($token));
}
// match external ranges like Sheet1:Sheet2!A1:B2
elseif (preg_match("/^[A-Za-z0-9_]+(\:[A-Za-z0-9_]+)?\!([A-I]?[A-Z])?(\d+)\:([A-I]?[A-Z])?(\d+)$/",$token))
{
return $this->_convertRange3d($token);
}
elseif(isset($this->ptg[$token])) // operators (including parentheses)
{
return(pack("C", $this->ptg[$token]));
}
elseif(preg_match("/[A-Z0-9\xc0-\xdc\.]+/",$token))
{
return($this->_convertFunction($token,$this->_func_args));
}
// if it's an argument, ignore the token (the argument remains)
elseif($token == 'arg')
{
$this->_func_args++;
return('');
}
// TODO: use real error codes
$this->raiseError("Unknown token $token", 0, PEAR_ERROR_DIE);
}
/**
* Convert a number token to ptgInt or ptgNum
*
* @access private
* @param mixed $num an integer or double for conversion to its ptg value
*/
function _convertNumber($num)
{
// Integer in the range 0..2**16-1
if ((preg_match("/^\d+$/",$num)) and ($num <= 65535)) {
return(pack("Cv", $this->ptg['ptgInt'], $num));
}
else // A float
{
if($this->_byte_order) // if it's Big Endian
{
$num = strrev($num);
}
return(pack("Cd", $this->ptg['ptgNum'], $num));
}
}
/**
* Convert a string token to ptgStr
*
* @access private
* @param string $string A string for conversion to its ptg value
*/
function _convertString($string)
{
// chop away beggining and ending quotes
$string = substr($string, 1, strlen($string) - 2);
return pack("CC", $this->ptg['ptgStr'], strlen($string)).$string;
}
/**
* Convert a function to a ptgFunc or ptgFuncVarV depending on the number of
* args that it takes.
*
* @access private
* @param string $token The name of the function for convertion to ptg value.
* @param integer $num_args The number of arguments the function recieves.
*/
function _convertFunction($token, $num_args)
{
$this->_func_args = 0; // re initialize the number of arguments
$args = $this->_functions[$token][1];
$volatile = $this->_functions[$token][3];
// Fixed number of args eg. TIME($i,$j,$k).
if ($args >= 0) {
return(pack("Cv", $this->ptg['ptgFuncV'], $this->_functions[$token][0]));
}
// Variable number of args eg. SUM($i,$j,$k, ..).
if ($args == -1) {
return(pack("CCv", $this->ptg['ptgFuncVarV'], $num_args, $this->_functions[$token][0]));
}
}
/**
* Convert an Excel range such as A1:D4 to a ptgRefV.
*
* @access private
* @param string $range An Excel range in the A1:A2 or A1..A2 format.
*/
function _convertRange2d($range)
{
$class = 2; // as far as I know, this is magick.
// Split the range into 2 cell refs
if(preg_match("/^([A-I]?[A-Z])(\d+)\:([A-I]?[A-Z])(\d+)$/",$range)) {
list($cell1, $cell2) = split(':', $range);
}
elseif(preg_match("/^([A-I]?[A-Z])(\d+)\.\.([A-I]?[A-Z])(\d+)$/",$range)) {
list($cell1, $cell2) = split('\.\.', $range);
}
else {
// TODO: use real error codes
$this->raiseError("Unknown range separator", 0, PEAR_ERROR_DIE);
}
// Convert the cell references
$cell_array1 = $this->_cellToPackedRowcol($cell1);
if($this->isError($cell_array1)) {
return($cell_array1);
}
list($row1, $col1) = $cell_array1; //$this->_cellToPackedRowcol($cell1);
$cell_array2 = $this->_cellToPackedRowcol($cell2);
if($this->isError($cell_array2)) {
return($cell_array2);
}
list($row2, $col2) = $cell_array2; //$this->_cellToPackedRowcol($cell2);
// The ptg value depends on the class of the ptg.
if ($class == 0) {
$ptgArea = pack("C", $this->ptg['ptgArea']);
}
elseif ($class == 1) {
$ptgArea = pack("C", $this->ptg['ptgAreaV']);
}
elseif ($class == 2) {
$ptgArea = pack("C", $this->ptg['ptgAreaA']);
}
else {
// TODO: use real error codes
$this->raiseError("Unknown class $class", 0, PEAR_ERROR_DIE);
}
return($ptgArea . $row1 . $row2 . $col1. $col2);
}
/**
* Convert an Excel 3d range such as "Sheet1!A1:D4" or "Sheet1:Sheet2!A1:D4" to
* a ptgArea3dV.
*
* @access private
* @param string $token An Excel range in the Sheet1!A1:A2 format.
*/
function _convertRange3d($token)
{
$class = 2; // as far as I know, this is magick.
// Split the ref at the ! symbol
list($ext_ref, $range) = split('!', $token);
// Convert the external reference part
$ext_ref = $this->_packExtRef($ext_ref);
if ($this->isError($ext_ref)) {
return $ext_ref;
}
// Split the range into 2 cell refs
list($cell1, $cell2) = split(':', $range);
// Convert the cell references
if (preg_match("/^(\$)?[A-I]?[A-Z](\$)?(\d+)$/", $cell1))
{
$cell_array1 = $this->_cellToPackedRowcol($cell1);
if (PEAR::isError($cell_array1)) {
return $cell_array1;
}
list($row1, $col1) = $cell_array1;
$cell_array2 = $this->_cellToPackedRowcol($cell2);
if (PEAR::isError($cell_array2)) {
return $cell_array2;
}
list($row2, $col2) = $cell_array2;
}
else { // It's a columns range (like 26:27)
$cells_array = $this->_rangeToPackedRange($cell1.':'.$cell2);
if (PEAR::isError($cells_array)) {
return $cells_array;
}
list($row1, $col1, $row2, $col2) = $cells_array;
}
// The ptg value depends on the class of the ptg.
if ($class == 0) {
$ptgArea = pack("C", $this->ptg['ptgArea3d']);
}
elseif ($class == 1) {
$ptgArea = pack("C", $this->ptg['ptgArea3dV']);
}
elseif ($class == 2) {
$ptgArea = pack("C", $this->ptg['ptgArea3dA']);
}
else {
$this->raiseError("Unknown class $class", 0, PEAR_ERROR_DIE);
}
return $ptgArea . $ext_ref . $row1 . $row2 . $col1. $col2;
}
 
/**
* Convert an Excel reference such as A1, $B2, C$3 or $D$4 to a ptgRefV.
*
* @access private
* @param string $cell An Excel cell reference
* @return string The cell in packed() format with the corresponding ptg
*/
function _convertRef2d($cell)
{
$class = 2; // as far as I know, this is magick.
// Convert the cell reference
$cell_array = $this->_cellToPackedRowcol($cell);
if($this->isError($cell_array)) {
return($cell_array);
}
list($row, $col) = $cell_array;
// The ptg value depends on the class of the ptg.
if ($class == 0) {
$ptgRef = pack("C", $this->ptg['ptgRef']);
}
elseif ($class == 1) {
$ptgRef = pack("C", $this->ptg['ptgRefV']);
}
elseif ($class == 2) {
$ptgRef = pack("C", $this->ptg['ptgRefA']);
}
else {
// TODO: use real error codes
$this->raiseError("Unknown class $class", 0, PEAR_ERROR_DIE);
}
return($ptgRef.$row.$col);
}
/**
* Convert an Excel 3d reference such as "Sheet1!A1" or "Sheet1:Sheet2!A1" to a
* ptgRef3dV.
*
* @access private
* @param string $cell An Excel cell reference
* @return string The cell in packed() format with the corresponding ptg
*/
function _convertRef3d($cell)
{
$class = 2; // as far as I know, this is magick.
// Split the ref at the ! symbol
list($ext_ref, $cell) = split('!', $cell);
// Convert the external reference part
$ext_ref = $this->_packExtRef($ext_ref);
if ($this->isError($ext_ref)) {
return $ext_ref;
}
// Convert the cell reference part
list($row, $col) = $this->_cellToPackedRowcol($cell);
// The ptg value depends on the class of the ptg.
if ($class == 0) {
$ptgRef = pack("C", $this->ptg['ptgRef3d']);
}
elseif ($class == 1) {
$ptgRef = pack("C", $this->ptg['ptgRef3dV']);
}
elseif ($class == 2) {
$ptgRef = pack("C", $this->ptg['ptgRef3dA']);
}
else {
$this->raiseError("Unknown class $class", 0, PEAR_ERROR_DIE);
}
 
return $ptgRef . $ext_ref. $row . $col;
}
 
/**
* Convert the sheet name part of an external reference, for example "Sheet1" or
* "Sheet1:Sheet2", to a packed structure.
*
* @access private
* @param string $ext_ref The name of the external reference
* @return string The reference index in packed() format
*/
function _packExtRef($ext_ref)
{
$ext_ref = preg_replace("/^'/", '', $ext_ref); // Remove leading ' if any.
$ext_ref = preg_replace("/'$/", '', $ext_ref); // Remove trailing ' if any.
// Check if there is a sheet range eg., Sheet1:Sheet2.
if (preg_match("/:/", $ext_ref))
{
list($sheet_name1, $sheet_name2) = split(':', $ext_ref);
$sheet1 = $this->_getSheetIndex($sheet_name1);
if ($sheet1 == -1) {
return $this->raiseError("Unknown sheet name $sheet_name1 in formula");
}
$sheet2 = $this->_getSheetIndex($sheet_name2);
if ($sheet2 == -1) {
return $this->raiseError("Unknown sheet name $sheet_name2 in formula");
}
// Reverse max and min sheet numbers if necessary
if ($sheet1 > $sheet2) {
list($sheet1, $sheet2) = array($sheet2, $sheet1);
}
}
else // Single sheet name only.
{
$sheet1 = $this->_getSheetIndex($ext_ref);
if ($sheet1 == -1) {
return $this->raiseError("Unknown sheet name $ext_ref in formula");
}
$sheet2 = $sheet1;
}
// References are stored relative to 0xFFFF.
$offset = -1 - $sheet1;
 
return pack('vdvv', $offset, 0x00, $sheet1, $sheet2);
}
 
/**
* Look up the index that corresponds to an external sheet name. The hash of
* sheet names is updated by the addworksheet() method of the
* Spreadsheet_Excel_Writer_Workbook class.
*
* @access private
* @return integer
*/
function _getSheetIndex($sheet_name)
{
if (!isset($this->_ext_sheets[$sheet_name])) {
return -1;
}
else {
return $this->_ext_sheets[$sheet_name];
}
}
 
/**
* This method is used to update the array of sheet names. It is
* called by the addWorksheet() method of the Spreadsheet_Excel_Writer_Workbook class.
*
* @access private
* @param string $name The name of the worksheet being added
* @param integer $index The index of the worksheet being added
*/
function setExtSheet($name, $index)
{
$this->_ext_sheets[$name] = $index;
}
 
/**
* pack() row and column into the required 3 byte format.
*
* @access private
* @param string $cell The Excel cell reference to be packed
* @return array Array containing the row and column in packed() format
*/
function _cellToPackedRowcol($cell)
{
list($row, $col, $row_rel, $col_rel) = $this->_cellToRowcol($cell);
if ($col >= 256) {
return($this->raiseError("Column in: $cell greater than 255"));
}
if ($row >= 16384) {
return($this->raiseError("Row in: $cell greater than 16384 "));
}
// Set the high bits to indicate if row or col are relative.
$row |= $col_rel << 14;
$row |= $row_rel << 15;
$row = pack('v', $row);
$col = pack('C', $col);
return(array($row, $col));
}
/**
* pack() row range into the required 3 byte format.
* Just using maximun col/rows, which is probably not the correct solution
*
* @access private
* @param string $range The Excel range to be packed
* @return array Array containing (row1,col1,row2,col2) in packed() format
*/
function _rangeToPackedRange($range)
{
preg_match('/(\$)?(\d+)\:(\$)?(\d+)/', $range, $match);
// return absolute rows if there is a $ in the ref
$row1_rel = empty($match[1]) ? 1 : 0;
$row1 = $match[2];
$row2_rel = empty($match[3]) ? 1 : 0;
$row2 = $match[4];
// Convert 1-index to zero-index
$row1--;
$row2--;
// Trick poor inocent Excel
$col1 = 0;
$col2 = 16383; // maximum possible value for Excel 5 (change this!!!)
 
//list($row, $col, $row_rel, $col_rel) = $this->_cellToRowcol($cell);
if (($row1 >= 16384) or ($row2 >= 16384)) {
return new PEAR_Error("Row in: $range greater than 16384 ");
}
// Set the high bits to indicate if rows are relative.
$row1 |= $row1_rel << 14;
$row2 |= $row2_rel << 15;
$row1 = pack('v', $row1);
$row2 = pack('v', $row2);
$col1 = pack('C', $col1);
$col2 = pack('C', $col2);
return array($row1, $col1, $row2, $col2);
}
 
/**
* Convert an Excel cell reference such as A1 or $B2 or C$3 or $D$4 to a zero
* indexed row and column number. Also returns two (0,1) values to indicate
* whether the row or column are relative references.
*
* @access private
* @param string $cell The Excel cell reference in A1 format.
* @return array
*/
function _cellToRowcol($cell)
{
preg_match('/(\$)?([A-I]?[A-Z])(\$)?(\d+)/',$cell,$match);
// return absolute column if there is a $ in the ref
$col_rel = empty($match[1]) ? 1 : 0;
$col_ref = $match[2];
$row_rel = empty($match[3]) ? 1 : 0;
$row = $match[4];
// Convert base26 column string to a number.
$expn = strlen($col_ref) - 1;
$col = 0;
for($i=0; $i < strlen($col_ref); $i++)
{
$col += (ord($col_ref{$i}) - ord('A') + 1) * pow(26, $expn);
$expn--;
}
// Convert 1-index to zero-index
$row--;
$col--;
return(array($row, $col, $row_rel, $col_rel));
}
/**
* Advance to the next valid token.
*
* @access private
*/
function _advance()
{
$i = $this->_current_char;
// eat up white spaces
if($i < strlen($this->_formula))
{
while($this->_formula{$i} == " ") {
$i++;
}
if($i < strlen($this->_formula) - 1) {
$this->_lookahead = $this->_formula{$i+1};
}
$token = "";
}
while($i < strlen($this->_formula))
{
$token .= $this->_formula{$i};
if($this->_match($token) != '')
{
if($i < strlen($this->_formula) - 1) {
$this->_lookahead = $this->_formula{$i+1};
}
$this->_current_char = $i + 1;
$this->_current_token = $token;
return(1);
}
if ($i < strlen($this->_formula) - 2) {
$this->_lookahead = $this->_formula{$i+2};
}
// if we run out of characters _lookahead becomes empty
else {
$this->_lookahead = '';
}
$i++;
}
//die("Lexical error ".$this->_current_char);
}
/**
* Checks if it's a valid token.
*
* @access private
* @param mixed $token The token to check.
* @return mixed The checked token or false on failure
*/
function _match($token)
{
switch($token)
{
case SPREADSHEET_EXCEL_WRITER_ADD:
return($token);
break;
case SPREADSHEET_EXCEL_WRITER_SUB:
return($token);
break;
case SPREADSHEET_EXCEL_WRITER_MUL:
return($token);
break;
case SPREADSHEET_EXCEL_WRITER_DIV:
return($token);
break;
case SPREADSHEET_EXCEL_WRITER_OPEN:
return($token);
break;
case SPREADSHEET_EXCEL_WRITER_CLOSE:
return($token);
break;
case SPREADSHEET_EXCEL_WRITER_COMA:
return($token);
break;
case SPREADSHEET_EXCEL_WRITER_GT:
if ($this->_lookahead == '=') { // it's a GE token
break;
}
return($token);
break;
case SPREADSHEET_EXCEL_WRITER_LT:
// it's a LE or a NE token
if (($this->_lookahead == '=') or ($this->_lookahead == '>')) {
break;
}
return($token);
break;
case SPREADSHEET_EXCEL_WRITER_GE:
return($token);
break;
case SPREADSHEET_EXCEL_WRITER_LE:
return($token);
break;
case SPREADSHEET_EXCEL_WRITER_EQ:
return($token);
break;
case SPREADSHEET_EXCEL_WRITER_NE:
return($token);
break;
default:
// if it's a reference
if (preg_match('/^\$?[A-I]?[A-Z]\$?[0-9]+$/',$token) and
!ereg("[0-9]",$this->_lookahead) and
($this->_lookahead != ':') and ($this->_lookahead != '.') and
($this->_lookahead != '!'))
{
return $token;
}
// If it's an external reference (Sheet1!A1 or Sheet1:Sheet2!A1)
elseif (preg_match("/^[A-Za-z0-9_]+(\:[A-Za-z0-9_]+)?\![A-I]?[A-Z][0-9]+$/",$token) and
!ereg("[0-9]",$this->_lookahead) and
($this->_lookahead != ':') and ($this->_lookahead != '.'))
{
return $token;
}
// if it's a range (A1:A2)
elseif (preg_match("/^(\$)?[A-I]?[A-Z](\$)?[0-9]+:(\$)?[A-I]?[A-Z](\$)?[0-9]+$/",$token) and
!ereg("[0-9]",$this->_lookahead))
{
return $token;
}
// if it's a range (A1..A2)
elseif (preg_match("/^(\$)?[A-I]?[A-Z](\$)?[0-9]+\.\.(\$)?[A-I]?[A-Z](\$)?[0-9]+$/",$token) and
!ereg("[0-9]",$this->_lookahead))
{
return $token;
}
// If it's an external range
elseif (preg_match("/^[A-Za-z0-9_]+(\:[A-Za-z0-9_]+)?\!([A-I]?[A-Z])?[0-9]+:([A-I]?[A-Z])?[0-9]+$/",$token) and
!ereg("[0-9]",$this->_lookahead))
{
return $token;
}
// If it's a number (check that it's not a sheet name or range)
elseif (is_numeric($token) and !is_numeric($token.$this->_lookahead) and
($this->_lookahead != '!') and (($this->_lookahead != ':')))
{
return $token;
}
// If it's a string (of maximum 255 characters)
elseif(ereg("^\"[^\"]{0,255}\"$",$token))
{
return($token);
}
// if it's a function call
elseif(eregi("^[A-Z0-9\xc0-\xdc\.]+$",$token) and ($this->_lookahead == "("))
{
return($token);
}
return '';
}
}
/**
* The parsing method. It parses a formula.
*
* @access public
* @param string $formula The formula to parse, without the initial equal sign (=).
*/
function parse($formula)
{
$this->_current_char = 0;
$this->_formula = $formula;
$this->_lookahead = $formula{1};
$this->_advance();
$this->_parse_tree = $this->_condition();
if ($this->isError($this->_parse_tree)) {
return $this->_parse_tree;
}
}
/**
* It parses a condition. It assumes the following rule:
* Cond -> Expr [(">" | "<") Expr]
*
* @access private
* @return mixed The parsed ptg'd tree
*/
function _condition()
{
$result = $this->_expression();
if($this->isError($result)) {
return $result;
}
if ($this->_current_token == SPREADSHEET_EXCEL_WRITER_LT)
{
$this->_advance();
$result2 = $this->_expression();
if($this->isError($result2)) {
return $result2;
}
$result = $this->_createTree('ptgLT', $result, $result2);
}
elseif ($this->_current_token == SPREADSHEET_EXCEL_WRITER_GT)
{
$this->_advance();
$result2 = $this->_expression();
if($this->isError($result2)) {
return $result2;
}
$result = $this->_createTree('ptgGT', $result, $result2);
}
elseif ($this->_current_token == SPREADSHEET_EXCEL_WRITER_LE)
{
$this->_advance();
$result2 = $this->_expression();
if($this->isError($result2)) {
return $result2;
}
$result = $this->_createTree('ptgLE', $result, $result2);
}
elseif ($this->_current_token == SPREADSHEET_EXCEL_WRITER_GE)
{
$this->_advance();
$result2 = $this->_expression();
if($this->isError($result2)) {
return $result2;
}
$result = $this->_createTree('ptgGE', $result, $result2);
}
elseif ($this->_current_token == SPREADSHEET_EXCEL_WRITER_EQ)
{
$this->_advance();
$result2 = $this->_expression();
if($this->isError($result2)) {
return $result2;
}
$result = $this->_createTree('ptgEQ', $result, $result2);
}
elseif ($this->_current_token == SPREADSHEET_EXCEL_WRITER_NE)
{
$this->_advance();
$result2 = $this->_expression();
if($this->isError($result2)) {
return $result2;
}
$result = $this->_createTree('ptgNE', $result, $result2);
}
return $result;
}
/**
* It parses a expression. It assumes the following rule:
* Expr -> Term [("+" | "-") Term]
*
* @access private
* @return mixed The parsed ptg'd tree
*/
function _expression()
{
// If it's a string return a string node
if (ereg("^\"[^\"]{0,255}\"$", $this->_current_token))
{
$result = $this->_createTree($this->_current_token, '', '');
$this->_advance();
return($result);
}
$result = $this->_term();
if($this->isError($result)) {
return($result);
}
while (($this->_current_token == SPREADSHEET_EXCEL_WRITER_ADD) or
($this->_current_token == SPREADSHEET_EXCEL_WRITER_SUB))
{
if ($this->_current_token == SPREADSHEET_EXCEL_WRITER_ADD)
{
$this->_advance();
$result2 = $this->_term();
if($this->isError($result2)) {
return($result2);
}
$result = $this->_createTree('ptgAdd', $result, $result2);
}
else
{
$this->_advance();
$result2 = $this->_term();
if($this->isError($result2)) {
return($result2);
}
$result = $this->_createTree('ptgSub', $result, $result2);
}
}
return($result);
}
/**
* This function just introduces a ptgParen element in the tree, so that Excel
* doesn't get confused when working with a parenthesized formula afterwards.
*
* @access private
* @see _fact()
* @return mixed The parsed ptg'd tree
*/
function _parenthesizedExpression()
{
$result = $this->_createTree('ptgParen', $this->_expression(), '');
return($result);
}
/**
* It parses a term. It assumes the following rule:
* Term -> Fact [("*" | "/") Fact]
*
* @access private
* @return mixed The parsed ptg'd tree
*/
function _term()
{
$result = $this->_fact();
if($this->isError($result)) {
return($result);
}
while (($this->_current_token == SPREADSHEET_EXCEL_WRITER_MUL) or
($this->_current_token == SPREADSHEET_EXCEL_WRITER_DIV))
{
if ($this->_current_token == SPREADSHEET_EXCEL_WRITER_MUL)
{
$this->_advance();
$result2 = $this->_fact();
if($this->isError($result2)) {
return($result2);
}
$result = $this->_createTree('ptgMul', $result, $result2);
}
else
{
$this->_advance();
$result2 = $this->_fact();
if($this->isError($result2)) {
return($result2);
}
$result = $this->_createTree('ptgDiv', $result, $result2);
}
}
return($result);
}
/**
* It parses a factor. It assumes the following rule:
* Fact -> ( Expr )
* | CellRef
* | CellRange
* | Number
* | Function
*
* @access private
* @return mixed The parsed ptg'd tree
*/
function _fact()
{
if ($this->_current_token == SPREADSHEET_EXCEL_WRITER_OPEN)
{
$this->_advance(); // eat the "("
$result = $this->_parenthesizedExpression();
if ($this->_current_token != SPREADSHEET_EXCEL_WRITER_CLOSE) {
return($this->raiseError("')' token expected."));
}
$this->_advance(); // eat the ")"
return $result;
}
// if it's a reference
if (preg_match('/^\$?[A-I]?[A-Z]\$?[0-9]+$/',$this->_current_token))
{
$result = $this->_createTree($this->_current_token, '', '');
$this->_advance();
return $result;
}
// If it's an external reference (Sheet1!A1 or Sheet1:Sheet2!A1)
elseif (preg_match("/^[A-Za-z0-9_]+(\:[A-Za-z0-9_]+)?\![A-I]?[A-Z][0-9]+$/",$this->_current_token))
{
$result = $this->_createTree($this->_current_token, '', '');
$this->_advance();
return $result;
}
// if it's a range
elseif (preg_match("/^(\$)?[A-I]?[A-Z](\$)?[0-9]+:(\$)?[A-I]?[A-Z](\$)?[0-9]+$/",$this->_current_token) or
preg_match("/^(\$)?[A-I]?[A-Z](\$)?[0-9]+\.\.(\$)?[A-I]?[A-Z](\$)?[0-9]+$/",$this->_current_token))
{
$result = $this->_current_token;
$this->_advance();
return $result;
}
// If it's an external range (Sheet1!A1:B2)
elseif (preg_match("/^[A-Za-z0-9_]+(\:[A-Za-z0-9_]+)?\!([A-I]?[A-Z])?[0-9]+:([A-I]?[A-Z])?[0-9]+$/",$this->_current_token))
{
$result = $this->_current_token;
$this->_advance();
return($result);
}
elseif (is_numeric($this->_current_token))
{
$result = $this->_createTree($this->_current_token, '', '');
$this->_advance();
return($result);
}
// if it's a function call
elseif (eregi("^[A-Z0-9\xc0-\xdc\.]+$",$this->_current_token))
{
$result = $this->_func();
return($result);
}
return($this->raiseError("Sintactic error: ".$this->_current_token.", lookahead: ".
$this->_lookahead.", current char: ".$this->_current_char));
}
/**
* It parses a function call. It assumes the following rule:
* Func -> ( Expr [,Expr]* )
*
* @access private
*/
function _func()
{
$num_args = 0; // number of arguments received
$function = $this->_current_token;
$this->_advance();
$this->_advance(); // eat the "("
while($this->_current_token != ')')
{
if($num_args > 0)
{
if($this->_current_token == SPREADSHEET_EXCEL_WRITER_COMA) {
$this->_advance(); // eat the ","
}
else {
return new PEAR_Error("Sintactic error: coma expected in ".
"function $function, {$num_args}º arg");
}
$result2 = $this->_condition();
if($this->isError($result2)) {
return($result2);
}
$result = $this->_createTree('arg', $result, $result2);
}
else // first argument
{
$result2 = $this->_condition();
if($this->isError($result2)) {
return($result2);
}
$result = $this->_createTree('arg', '', $result2);
}
$num_args++;
}
$args = $this->_functions[$function][1];
// If fixed number of args eg. TIME($i,$j,$k). Check that the number of args is valid.
if (($args >= 0) and ($args != $num_args))
{
return($this->raiseError("Incorrect number of arguments in function $function() "));
}
$result = $this->_createTree($function, $result, '');
$this->_advance(); // eat the ")"
return($result);
}
/**
* Creates a tree. In fact an array which may have one or two arrays (sub-trees)
* as elements.
*
* @access private
* @param mixed $value The value of this node.
* @param mixed $left The left array (sub-tree) or a final node.
* @param mixed $right The right array (sub-tree) or a final node.
*/
function _createTree($value, $left, $right)
{
return(array('value' => $value, 'left' => $left, 'right' => $right));
}
/**
* Builds a string containing the tree in reverse polish notation (What you
* would use in a HP calculator stack).
* The following tree:
*
* +
* / \
* 2 3
*
* produces: "23+"
*
* The following tree:
*
* +
* / \
* 3 *
* / \
* 6 A1
*
* produces: "36A1*+"
*
* In fact all operands, functions, references, etc... are written as ptg's
*
* @access public
* @param array $tree The optional tree to convert.
* @return string The tree in reverse polish notation
*/
function toReversePolish($tree = array())
{
$polish = ""; // the string we are going to return
if (empty($tree)) // If it's the first call use _parse_tree
{
$tree = $this->_parse_tree;
}
if (is_array($tree['left']))
{
$converted_tree = $this->toReversePolish($tree['left']);
if($this->isError($converted_tree)) {
return($converted_tree);
}
$polish .= $converted_tree;
}
elseif($tree['left'] != '') // It's a final node
{
$converted_tree = $this->_convert($tree['left']);
if($this->isError($converted_tree)) {
return($converted_tree);
}
$polish .= $converted_tree;
}
if (is_array($tree['right']))
{
$converted_tree = $this->toReversePolish($tree['right']);
if($this->isError($converted_tree)) {
return($converted_tree);
}
$polish .= $converted_tree;
}
elseif($tree['right'] != '') // It's a final node
{
$converted_tree = $this->_convert($tree['right']);
if($this->isError($converted_tree)) {
return($converted_tree);
}
$polish .= $converted_tree;
}
$converted_tree = $this->_convert($tree['value']);
if($this->isError($converted_tree)) {
return($converted_tree);
}
$polish .= $converted_tree;
return($polish);
}
}
?>
/tags/v3.1-blanche-neige/jrest/lib/Spreadsheet/Excel/Writer/Workbook.php
New file
0,0 → 1,1042
<?php
/*
* Module written/ported by Xavier Noguer <xnoguer@rezebra.com>
*
* The majority of this is _NOT_ my code. I simply ported it from the
* PERL Spreadsheet::WriteExcel module.
*
* The author of the Spreadsheet::WriteExcel module is John McNamara
* <jmcnamara@cpan.org>
*
* I _DO_ maintain this code, and John McNamara has nothing to do with the
* porting of this code to PHP. Any questions directly related to this
* class library should be directed to me.
*
* License Information:
*
* Spreadsheet_Excel_Writer: A library for generating Excel Spreadsheets
* Copyright (c) 2002-2003 Xavier Noguer xnoguer@rezebra.com
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
 
require_once('Format.php');
require_once('OLEwriter.php');
require_once('BIFFwriter.php');
require_once('Worksheet.php');
require_once('Parser.php');
 
/**
* Class for generating Excel Spreadsheets
*
* @author Xavier Noguer <xnoguer@rezebra.com>
* @category FileFormats
* @package Spreadsheet_Excel_Writer
*/
 
class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwriter
{
/**
* Filename for the Workbook
* @var string
*/
var $_filename;
 
/**
* Formula parser
* @var object Parser
*/
var $_parser;
 
/**
* Flag for 1904 date system
* @var integer
*/
var $_1904;
 
/**
* The active worksheet of the workbook (0 indexed)
* @var integer
*/
var $_activesheet;
 
/**
* 1st displayed worksheet in the workbook (0 indexed)
* @var integer
*/
var $_firstsheet;
 
/**
* Number of workbook tabs selected
* @var integer
*/
var $_selected;
 
/**
* Index for creating adding new formats to the workbook
* @var integer
*/
var $_xf_index;
 
/**
* Flag for preventing close from being called twice.
* @var integer
* @see close()
*/
var $_fileclosed;
 
/**
* The BIFF file size for the workbook.
* @var integer
* @see _calcSheetOffsets()
*/
var $_biffsize;
 
/**
* The default sheetname for all sheets created.
* @var string
*/
var $_sheetname;
 
/**
* The default XF format.
* @var object Format
*/
var $_tmp_format;
 
/**
* Array containing references to all of this workbook's worksheets
* @var array
*/
var $_worksheets;
 
/**
* Array of sheetnames for creating the EXTERNSHEET records
* @var array
*/
var $_sheetnames;
 
/**
* Array containing references to all of this workbook's formats
* @var array
*/
var $_formats;
 
/**
* Array containing the colour palette
* @var array
*/
var $_palette;
 
/**
* The default format for URLs.
* @var object Format
*/
var $_url_format;
 
/**
* Class constructor
*
* @param string filename for storing the workbook. "-" for writing to stdout.
* @access public
*/
function Spreadsheet_Excel_Writer_Workbook($filename)
{
// It needs to call its parent's constructor explicitly
$this->Spreadsheet_Excel_Writer_BIFFwriter();
$this->_filename = $filename;
$this->_parser =& new Spreadsheet_Excel_Writer_Parser($this->_byte_order);
$this->_1904 = 0;
$this->_activesheet = 0;
$this->_firstsheet = 0;
$this->_selected = 0;
$this->_xf_index = 16; // 15 style XF's and 1 cell XF.
$this->_fileclosed = 0;
$this->_biffsize = 0;
$this->_sheetname = "Sheet";
$this->_tmp_format =& new Spreadsheet_Excel_Writer_Format();
$this->_worksheets = array();
$this->_sheetnames = array();
$this->_formats = array();
$this->_palette = array();
// Add the default format for hyperlinks
$this->_url_format =& $this->addFormat(array('color' => 'blue', 'underline' => 1));
$this->_setPaletteXl97();
}
/**
* Calls finalization methods.
* This method should always be the last one to be called on every workbook
*
* @access public
*/
function close()
{
if ($this->_fileclosed) { // Prevent close() from being called twice.
return;
}
$this->_storeWorkbook();
$this->_fileclosed = 1;
}
/**
* An accessor for the _worksheets[] array
* Returns an array of the worksheet objects in a workbook
* It actually calls to worksheets()
*
* @access public
* @see worksheets()
* @return array
*/
function sheets()
{
return $this->worksheets();
}
/**
* An accessor for the _worksheets[] array.
* Returns an array of the worksheet objects in a workbook
*
* @access public
* @return array
*/
function worksheets()
{
return($this->_worksheets);
}
/**
* Add a new worksheet to the Excel workbook.
* If no name is given the name of the worksheet will be Sheeti$i, with
* $i in [1..].
*
* @access public
* @param string $name the optional name of the worksheet
* @return &Spreadsheet_Excel_Writer_Worksheet reference to a worksheet object
*/
function &addWorksheet($name = '')
{
$index = count($this->_worksheets);
$sheetname = $this->_sheetname;
if($name == '') {
$name = $sheetname.($index+1);
}
// Check that sheetname is <= 31 chars (Excel limit).
if(strlen($name) > 31) {
$this->raiseError("Sheetname $name must be <= 31 chars");
}
// Check that the worksheet name doesn't already exist: a fatal Excel error.
for($i=0; $i < count($this->_worksheets); $i++)
{
if($name == $this->_worksheets[$i]->getName()) {
$this->raiseError("Worksheet '$name' already exists");
}
}
$worksheet = new Spreadsheet_Excel_Writer_Worksheet($name,$index,$this->_activesheet,
$this->_firstsheet,$this->_url_format,
$this->_parser);
 
$this->_worksheets[$index] = &$worksheet; // Store ref for iterator
$this->_sheetnames[$index] = $name; // Store EXTERNSHEET names
$this->_parser->setExtSheet($name, $index); // Register worksheet name with parser
return($worksheet);
}
/**
* Add a new format to the Excel workbook.
* Also, pass any properties to the Format constructor.
*
* @access public
* @param array $properties array with properties for initializing the format.
* @return &Spreadsheet_Excel_Writer_Format reference to an Excel Format
*/
function &addFormat($properties = array())
{
$format = new Spreadsheet_Excel_Writer_Format($this->_xf_index,$properties);
$this->_xf_index += 1;
$this->_formats[] = &$format;
return($format);
}
/**
* Change the RGB components of the elements in the colour palette.
*
* @access public
* @param integer $index colour index
* @param integer $red red RGB value [0-255]
* @param integer $green green RGB value [0-255]
* @param integer $blue blue RGB value [0-255]
* @return integer The palette index for the custom color
*/
function setCustomColor($index,$red,$green,$blue)
{
// Match a HTML #xxyyzz style parameter
/*if (defined $_[1] and $_[1] =~ /^#(\w\w)(\w\w)(\w\w)/ ) {
@_ = ($_[0], hex $1, hex $2, hex $3);
}*/
// Check that the colour index is the right range
if ($index < 8 or $index > 64) {
// TODO: assign real error codes
$this->raiseError("Color index $index outside range: 8 <= index <= 64",0,PEAR_ERROR_DIE);
}
// Check that the colour components are in the right range
if ( ($red < 0 or $red > 255) or
($green < 0 or $green > 255) or
($blue < 0 or $blue > 255) )
{
$this->raiseError("Color component outside range: 0 <= color <= 255");
}
$index -= 8; // Adjust colour index (wingless dragonfly)
// Set the RGB value
$this->_palette[$index] = array($red, $green, $blue, 0);
return($index + 8);
}
/**
* Sets the colour palette to the Excel 97+ default.
*
* @access private
*/
function _setPaletteXl97()
{
$this->_palette = array(
array(0x00, 0x00, 0x00, 0x00), // 8
array(0xff, 0xff, 0xff, 0x00), // 9
array(0xff, 0x00, 0x00, 0x00), // 10
array(0x00, 0xff, 0x00, 0x00), // 11
array(0x00, 0x00, 0xff, 0x00), // 12
array(0xff, 0xff, 0x00, 0x00), // 13
array(0xff, 0x00, 0xff, 0x00), // 14
array(0x00, 0xff, 0xff, 0x00), // 15
array(0x80, 0x00, 0x00, 0x00), // 16
array(0x00, 0x80, 0x00, 0x00), // 17
array(0x00, 0x00, 0x80, 0x00), // 18
array(0x80, 0x80, 0x00, 0x00), // 19
array(0x80, 0x00, 0x80, 0x00), // 20
array(0x00, 0x80, 0x80, 0x00), // 21
array(0xc0, 0xc0, 0xc0, 0x00), // 22
array(0x80, 0x80, 0x80, 0x00), // 23
array(0x99, 0x99, 0xff, 0x00), // 24
array(0x99, 0x33, 0x66, 0x00), // 25
array(0xff, 0xff, 0xcc, 0x00), // 26
array(0xcc, 0xff, 0xff, 0x00), // 27
array(0x66, 0x00, 0x66, 0x00), // 28
array(0xff, 0x80, 0x80, 0x00), // 29
array(0x00, 0x66, 0xcc, 0x00), // 30
array(0xcc, 0xcc, 0xff, 0x00), // 31
array(0x00, 0x00, 0x80, 0x00), // 32
array(0xff, 0x00, 0xff, 0x00), // 33
array(0xff, 0xff, 0x00, 0x00), // 34
array(0x00, 0xff, 0xff, 0x00), // 35
array(0x80, 0x00, 0x80, 0x00), // 36
array(0x80, 0x00, 0x00, 0x00), // 37
array(0x00, 0x80, 0x80, 0x00), // 38
array(0x00, 0x00, 0xff, 0x00), // 39
array(0x00, 0xcc, 0xff, 0x00), // 40
array(0xcc, 0xff, 0xff, 0x00), // 41
array(0xcc, 0xff, 0xcc, 0x00), // 42
array(0xff, 0xff, 0x99, 0x00), // 43
array(0x99, 0xcc, 0xff, 0x00), // 44
array(0xff, 0x99, 0xcc, 0x00), // 45
array(0xcc, 0x99, 0xff, 0x00), // 46
array(0xff, 0xcc, 0x99, 0x00), // 47
array(0x33, 0x66, 0xff, 0x00), // 48
array(0x33, 0xcc, 0xcc, 0x00), // 49
array(0x99, 0xcc, 0x00, 0x00), // 50
array(0xff, 0xcc, 0x00, 0x00), // 51
array(0xff, 0x99, 0x00, 0x00), // 52
array(0xff, 0x66, 0x00, 0x00), // 53
array(0x66, 0x66, 0x99, 0x00), // 54
array(0x96, 0x96, 0x96, 0x00), // 55
array(0x00, 0x33, 0x66, 0x00), // 56
array(0x33, 0x99, 0x66, 0x00), // 57
array(0x00, 0x33, 0x00, 0x00), // 58
array(0x33, 0x33, 0x00, 0x00), // 59
array(0x99, 0x33, 0x00, 0x00), // 60
array(0x99, 0x33, 0x66, 0x00), // 61
array(0x33, 0x33, 0x99, 0x00), // 62
array(0x33, 0x33, 0x33, 0x00), // 63
);
}
/**
* Assemble worksheets into a workbook and send the BIFF data to an OLE
* storage.
*
* @access private
*/
function _storeWorkbook()
{
// Ensure that at least one worksheet has been selected.
if ($this->_activesheet == 0)
{
$this->_worksheets[0]->selected = 1;
}
// Calculate the number of selected worksheet tabs and call the finalization
// methods for each worksheet
for($i=0; $i < count($this->_worksheets); $i++)
{
if($this->_worksheets[$i]->selected) {
$this->_selected++;
}
$this->_worksheets[$i]->close($this->_sheetnames);
}
// Add Workbook globals
$this->_storeBof(0x0005);
$this->_storeExterns(); // For print area and repeat rows
$this->_storeNames(); // For print area and repeat rows
$this->_storeWindow1();
$this->_store1904();
$this->_storeAllFonts();
$this->_storeAllNumFormats();
$this->_storeAllXfs();
$this->_storeAllStyles();
$this->_storePalette();
$this->_calcSheetOffsets();
// Add BOUNDSHEET records
for($i=0; $i < count($this->_worksheets); $i++) {
$this->_storeBoundsheet($this->_worksheets[$i]->name,$this->_worksheets[$i]->offset);
}
// End Workbook globals
$this->_storeEof();
// Store the workbook in an OLE container
$this->_storeOLEFile();
}
/**
* Store the workbook in an OLE container if the total size of the workbook data
* is less than ~ 7MB.
*
* @access private
*/
function _storeOLEFile()
{
$OLE = new Spreadsheet_Excel_Writer_OLEwriter($this->_filename);
$this->_tmp_filename = $OLE->_tmp_filename;
// Write Worksheet data if data <~ 7MB
if ($OLE->setSize($this->_biffsize))
{
$OLE->writeHeader();
$OLE->write($this->_data);
foreach($this->_worksheets as $sheet)
{
while ($tmp = $sheet->getData()) {
$OLE->write($tmp);
}
}
}
$OLE->close();
}
/**
* Calculate offsets for Worksheet BOF records.
*
* @access private
*/
function _calcSheetOffsets()
{
$BOF = 11;
$EOF = 4;
$offset = $this->_datasize;
for($i=0; $i < count($this->_worksheets); $i++) {
$offset += $BOF + strlen($this->_worksheets[$i]->name);
}
$offset += $EOF;
for($i=0; $i < count($this->_worksheets); $i++) {
$this->_worksheets[$i]->offset = $offset;
$offset += $this->_worksheets[$i]->_datasize;
}
$this->_biffsize = $offset;
}
/**
* Store the Excel FONT records.
*
* @access private
*/
function _storeAllFonts()
{
// tmp_format is added by the constructor. We use this to write the default XF's
$format = $this->_tmp_format;
$font = $format->getFont();
// Note: Fonts are 0-indexed. According to the SDK there is no index 4,
// so the following fonts are 0, 1, 2, 3, 5
//
for($i=1; $i <= 5; $i++){
$this->_append($font);
}
// Iterate through the XF objects and write a FONT record if it isn't the
// same as the default FONT and if it hasn't already been used.
//
$fonts = array();
$index = 6; // The first user defined FONT
$key = $format->getFontKey(); // The default font from _tmp_format
$fonts[$key] = 0; // Index of the default font
for($i=0; $i < count($this->_formats); $i++) {
$key = $this->_formats[$i]->getFontKey();
if (isset($fonts[$key])) {
// FONT has already been used
$this->_formats[$i]->font_index = $fonts[$key];
}
else {
// Add a new FONT record
$fonts[$key] = $index;
$this->_formats[$i]->font_index = $index;
$index++;
$font = $this->_formats[$i]->getFont();
$this->_append($font);
}
}
}
/**
* Store user defined numerical formats i.e. FORMAT records
*
* @access private
*/
function _storeAllNumFormats()
{
// Leaning num_format syndrome
$hash_num_formats = array();
$num_formats = array();
$index = 164;
// Iterate through the XF objects and write a FORMAT record if it isn't a
// built-in format type and if the FORMAT string hasn't already been used.
//
for($i=0; $i < count($this->_formats); $i++)
{
$num_format = $this->_formats[$i]->_num_format;
// Check if $num_format is an index to a built-in format.
// Also check for a string of zeros, which is a valid format string
// but would evaluate to zero.
//
if (!preg_match("/^0+\d/",$num_format))
{
if (preg_match("/^\d+$/",$num_format)) { // built-in format
continue;
}
}
if (isset($hash_num_formats[$num_format])) {
// FORMAT has already been used
$this->_formats[$i]->_num_format = $hash_num_formats[$num_format];
}
else{
// Add a new FORMAT
$hash_num_formats[$num_format] = $index;
$this->_formats[$i]->_num_format = $index;
array_push($num_formats,$num_format);
$index++;
}
}
// Write the new FORMAT records starting from 0xA4
$index = 164;
foreach ($num_formats as $num_format) {
$this->_storeNumFormat($num_format,$index);
$index++;
}
}
/**
* Write all XF records.
*
* @access private
*/
function _storeAllXfs()
{
// _tmp_format is added by the constructor. We use this to write the default XF's
// The default font index is 0
//
$format = $this->_tmp_format;
for ($i=0; $i <= 14; $i++) {
$xf = $format->getXf('style'); // Style XF
$this->_append($xf);
}
$xf = $format->getXf('cell'); // Cell XF
$this->_append($xf);
// User defined XFs
for($i=0; $i < count($this->_formats); $i++) {
$xf = $this->_formats[$i]->getXf('cell');
$this->_append($xf);
}
}
/**
* Write all STYLE records.
*
* @access private
*/
function _storeAllStyles()
{
$this->_storeStyle();
}
/**
* Write the EXTERNCOUNT and EXTERNSHEET records. These are used as indexes for
* the NAME records.
*
* @access private
*/
function _storeExterns()
{
// Create EXTERNCOUNT with number of worksheets
$this->_storeExterncount(count($this->_worksheets));
// Create EXTERNSHEET for each worksheet
foreach ($this->_sheetnames as $sheetname) {
$this->_storeExternsheet($sheetname);
}
}
/**
* Write the NAME record to define the print area and the repeat rows and cols.
*
* @access private
*/
function _storeNames()
{
// Create the print area NAME records
foreach ($this->_worksheets as $worksheet) {
// Write a Name record if the print area has been defined
if (isset($worksheet->print_rowmin))
{
$this->_storeNameShort(
$worksheet->index,
0x06, // NAME type
$worksheet->print_rowmin,
$worksheet->print_rowmax,
$worksheet->print_colmin,
$worksheet->print_colmax
);
}
}
// Create the print title NAME records
foreach ($this->_worksheets as $worksheet)
{
$rowmin = $worksheet->title_rowmin;
$rowmax = $worksheet->title_rowmax;
$colmin = $worksheet->title_colmin;
$colmax = $worksheet->title_colmax;
// Determine if row + col, row, col or nothing has been defined
// and write the appropriate record
//
if (isset($rowmin) and isset($colmin)) {
// Row and column titles have been defined.
// Row title has been defined.
$this->_storeNameLong(
$worksheet->index,
0x07, // NAME type
$rowmin,
$rowmax,
$colmin,
$colmax
);
}
elseif (isset($rowmin)) {
// Row title has been defined.
$this->_storeNameShort(
$worksheet->index,
0x07, // NAME type
$rowmin,
$rowmax,
0x00,
0xff
);
}
elseif (isset($colmin)) {
// Column title has been defined.
$this->_storeNameShort(
$worksheet->index,
0x07, // NAME type
0x0000,
0x3fff,
$colmin,
$colmax
);
}
else {
// Print title hasn't been defined.
}
}
}
/******************************************************************************
*
* BIFF RECORDS
*
*/
/**
* Write Excel BIFF WINDOW1 record.
*
* @access private
*/
function _storeWindow1()
{
$record = 0x003D; // Record identifier
$length = 0x0012; // Number of bytes to follow
$xWn = 0x0000; // Horizontal position of window
$yWn = 0x0000; // Vertical position of window
$dxWn = 0x25BC; // Width of window
$dyWn = 0x1572; // Height of window
$grbit = 0x0038; // Option flags
$ctabsel = $this->_selected; // Number of workbook tabs selected
$wTabRatio = 0x0258; // Tab to scrollbar ratio
$itabFirst = $this->_firstsheet; // 1st displayed worksheet
$itabCur = $this->_activesheet; // Active worksheet
$header = pack("vv", $record, $length);
$data = pack("vvvvvvvvv", $xWn, $yWn, $dxWn, $dyWn,
$grbit,
$itabCur, $itabFirst,
$ctabsel, $wTabRatio);
$this->_append($header.$data);
}
/**
* Writes Excel BIFF BOUNDSHEET record.
*
* @param string $sheetname Worksheet name
* @param integer $offset Location of worksheet BOF
* @access private
*/
function _storeBoundsheet($sheetname,$offset)
{
$record = 0x0085; // Record identifier
$length = 0x07 + strlen($sheetname); // Number of bytes to follow
$grbit = 0x0000; // Sheet identifier
$cch = strlen($sheetname); // Length of sheet name
$header = pack("vv", $record, $length);
$data = pack("VvC", $offset, $grbit, $cch);
$this->_append($header.$data.$sheetname);
}
/**
* Write Excel BIFF STYLE records.
*
* @access private
*/
function _storeStyle()
{
$record = 0x0293; // Record identifier
$length = 0x0004; // Bytes to follow
$ixfe = 0x8000; // Index to style XF
$BuiltIn = 0x00; // Built-in style
$iLevel = 0xff; // Outline style level
$header = pack("vv", $record, $length);
$data = pack("vCC", $ixfe, $BuiltIn, $iLevel);
$this->_append($header.$data);
}
/**
* Writes Excel FORMAT record for non "built-in" numerical formats.
*
* @param string $format Custom format string
* @param integer $ifmt Format index code
* @access private
*/
function _storeNumFormat($format,$ifmt)
{
$record = 0x041E; // Record identifier
$length = 0x03 + strlen($format); // Number of bytes to follow
$cch = strlen($format); // Length of format string
$header = pack("vv", $record, $length);
$data = pack("vC", $ifmt, $cch);
$this->_append($header.$data.$format);
}
/**
* Write Excel 1904 record to indicate the date system in use.
*
* @access private
*/
function _store1904()
{
$record = 0x0022; // Record identifier
$length = 0x0002; // Bytes to follow
$f1904 = $this->_1904; // Flag for 1904 date system
$header = pack("vv", $record, $length);
$data = pack("v", $f1904);
$this->_append($header.$data);
}
/**
* Write BIFF record EXTERNCOUNT to indicate the number of external sheet
* references in the workbook.
*
* Excel only stores references to external sheets that are used in NAME.
* The workbook NAME record is required to define the print area and the repeat
* rows and columns.
*
* A similar method is used in Worksheet.php for a slightly different purpose.
*
* @param integer $cxals Number of external references
* @access private
*/
function _storeExterncount($cxals)
{
$record = 0x0016; // Record identifier
$length = 0x0002; // Number of bytes to follow
$header = pack("vv", $record, $length);
$data = pack("v", $cxals);
$this->_append($header.$data);
}
/**
* Writes the Excel BIFF EXTERNSHEET record. These references are used by
* formulas. NAME record is required to define the print area and the repeat
* rows and columns.
*
* A similar method is used in Worksheet.php for a slightly different purpose.
*
* @param string $sheetname Worksheet name
* @access private
*/
function _storeExternsheet($sheetname)
{
$record = 0x0017; // Record identifier
$length = 0x02 + strlen($sheetname); // Number of bytes to follow
$cch = strlen($sheetname); // Length of sheet name
$rgch = 0x03; // Filename encoding
$header = pack("vv", $record, $length);
$data = pack("CC", $cch, $rgch);
$this->_append($header.$data.$sheetname);
}
/**
* Store the NAME record in the short format that is used for storing the print
* area, repeat rows only and repeat columns only.
*
* @param integer $index Sheet index
* @param integer $type Built-in name type
* @param integer $rowmin Start row
* @param integer $rowmax End row
* @param integer $colmin Start colum
* @param integer $colmax End column
* @access private
*/
function _storeNameShort($index,$type,$rowmin,$rowmax,$colmin,$colmax)
{
$record = 0x0018; // Record identifier
$length = 0x0024; // Number of bytes to follow
$grbit = 0x0020; // Option flags
$chKey = 0x00; // Keyboard shortcut
$cch = 0x01; // Length of text name
$cce = 0x0015; // Length of text definition
$ixals = $index + 1; // Sheet index
$itab = $ixals; // Equal to ixals
$cchCustMenu = 0x00; // Length of cust menu text
$cchDescription = 0x00; // Length of description text
$cchHelptopic = 0x00; // Length of help topic text
$cchStatustext = 0x00; // Length of status bar text
$rgch = $type; // Built-in name type
$unknown03 = 0x3b;
$unknown04 = 0xffff-$index;
$unknown05 = 0x0000;
$unknown06 = 0x0000;
$unknown07 = 0x1087;
$unknown08 = 0x8005;
$header = pack("vv", $record, $length);
$data = pack("v", $grbit);
$data .= pack("C", $chKey);
$data .= pack("C", $cch);
$data .= pack("v", $cce);
$data .= pack("v", $ixals);
$data .= pack("v", $itab);
$data .= pack("C", $cchCustMenu);
$data .= pack("C", $cchDescription);
$data .= pack("C", $cchHelptopic);
$data .= pack("C", $cchStatustext);
$data .= pack("C", $rgch);
$data .= pack("C", $unknown03);
$data .= pack("v", $unknown04);
$data .= pack("v", $unknown05);
$data .= pack("v", $unknown06);
$data .= pack("v", $unknown07);
$data .= pack("v", $unknown08);
$data .= pack("v", $index);
$data .= pack("v", $index);
$data .= pack("v", $rowmin);
$data .= pack("v", $rowmax);
$data .= pack("C", $colmin);
$data .= pack("C", $colmax);
$this->_append($header.$data);
}
/**
* Store the NAME record in the long format that is used for storing the repeat
* rows and columns when both are specified. This shares a lot of code with
* _storeNameShort() but we use a separate method to keep the code clean.
* Code abstraction for reuse can be carried too far, and I should know. ;-)
*
* @param integer $index Sheet index
* @param integer $type Built-in name type
* @param integer $rowmin Start row
* @param integer $rowmax End row
* @param integer $colmin Start colum
* @param integer $colmax End column
* @access private
*/
function _storeNameLong($index,$type,$rowmin,$rowmax,$colmin,$colmax)
{
$record = 0x0018; // Record identifier
$length = 0x003d; // Number of bytes to follow
$grbit = 0x0020; // Option flags
$chKey = 0x00; // Keyboard shortcut
$cch = 0x01; // Length of text name
$cce = 0x002e; // Length of text definition
$ixals = $index + 1; // Sheet index
$itab = $ixals; // Equal to ixals
$cchCustMenu = 0x00; // Length of cust menu text
$cchDescription = 0x00; // Length of description text
$cchHelptopic = 0x00; // Length of help topic text
$cchStatustext = 0x00; // Length of status bar text
$rgch = $type; // Built-in name type
$unknown01 = 0x29;
$unknown02 = 0x002b;
$unknown03 = 0x3b;
$unknown04 = 0xffff-$index;
$unknown05 = 0x0000;
$unknown06 = 0x0000;
$unknown07 = 0x1087;
$unknown08 = 0x8008;
$header = pack("vv", $record, $length);
$data = pack("v", $grbit);
$data .= pack("C", $chKey);
$data .= pack("C", $cch);
$data .= pack("v", $cce);
$data .= pack("v", $ixals);
$data .= pack("v", $itab);
$data .= pack("C", $cchCustMenu);
$data .= pack("C", $cchDescription);
$data .= pack("C", $cchHelptopic);
$data .= pack("C", $cchStatustext);
$data .= pack("C", $rgch);
$data .= pack("C", $unknown01);
$data .= pack("v", $unknown02);
// Column definition
$data .= pack("C", $unknown03);
$data .= pack("v", $unknown04);
$data .= pack("v", $unknown05);
$data .= pack("v", $unknown06);
$data .= pack("v", $unknown07);
$data .= pack("v", $unknown08);
$data .= pack("v", $index);
$data .= pack("v", $index);
$data .= pack("v", 0x0000);
$data .= pack("v", 0x3fff);
$data .= pack("C", $colmin);
$data .= pack("C", $colmax);
// Row definition
$data .= pack("C", $unknown03);
$data .= pack("v", $unknown04);
$data .= pack("v", $unknown05);
$data .= pack("v", $unknown06);
$data .= pack("v", $unknown07);
$data .= pack("v", $unknown08);
$data .= pack("v", $index);
$data .= pack("v", $index);
$data .= pack("v", $rowmin);
$data .= pack("v", $rowmax);
$data .= pack("C", 0x00);
$data .= pack("C", 0xff);
// End of data
$data .= pack("C", 0x10);
$this->_append($header.$data);
}
/**
* Stores the PALETTE biff record.
*
* @access private
*/
function _storePalette()
{
$aref = $this->_palette;
$record = 0x0092; // Record identifier
$length = 2 + 4 * count($aref); // Number of bytes to follow
$ccv = count($aref); // Number of RGB values to follow
$data = ''; // The RGB data
// Pack the RGB data
foreach($aref as $color)
{
foreach($color as $byte) {
$data .= pack("C",$byte);
}
}
$header = pack("vvv", $record, $length, $ccv);
$this->_append($header.$data);
}
}
?>
/tags/v3.1-blanche-neige/jrest/lib/DB.php
New file
0,0 → 1,1114
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 foldmethod=marker: */
// +----------------------------------------------------------------------+
// | PHP Version 4 |
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2004 The PHP Group |
// +----------------------------------------------------------------------+
// | This source file is subject to version 2.02 of the PHP license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available at through the world-wide-web at |
// | http://www.php.net/license/2_02.txt. |
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// | Authors: Stig Bakken <ssb@php.net> |
// | Tomas V.V.Cox <cox@idecnet.com> |
// | Maintainer: Daniel Convissor <danielc@php.net> |
// +----------------------------------------------------------------------+
//
// $Id$
//
// Database independent query interface.
 
 
require_once 'PEAR.php';
 
// {{{ constants
// {{{ error codes
 
/*
* The method mapErrorCode in each DB_dbtype implementation maps
* native error codes to one of these.
*
* If you add an error code here, make sure you also add a textual
* version of it in DB::errorMessage().
*/
define('DB_OK', 1);
define('DB_ERROR', -1);
define('DB_ERROR_SYNTAX', -2);
define('DB_ERROR_CONSTRAINT', -3);
define('DB_ERROR_NOT_FOUND', -4);
define('DB_ERROR_ALREADY_EXISTS', -5);
define('DB_ERROR_UNSUPPORTED', -6);
define('DB_ERROR_MISMATCH', -7);
define('DB_ERROR_INVALID', -8);
define('DB_ERROR_NOT_CAPABLE', -9);
define('DB_ERROR_TRUNCATED', -10);
define('DB_ERROR_INVALID_NUMBER', -11);
define('DB_ERROR_INVALID_DATE', -12);
define('DB_ERROR_DIVZERO', -13);
define('DB_ERROR_NODBSELECTED', -14);
define('DB_ERROR_CANNOT_CREATE', -15);
define('DB_ERROR_CANNOT_DELETE', -16);
define('DB_ERROR_CANNOT_DROP', -17);
define('DB_ERROR_NOSUCHTABLE', -18);
define('DB_ERROR_NOSUCHFIELD', -19);
define('DB_ERROR_NEED_MORE_DATA', -20);
define('DB_ERROR_NOT_LOCKED', -21);
define('DB_ERROR_VALUE_COUNT_ON_ROW', -22);
define('DB_ERROR_INVALID_DSN', -23);
define('DB_ERROR_CONNECT_FAILED', -24);
define('DB_ERROR_EXTENSION_NOT_FOUND',-25);
define('DB_ERROR_ACCESS_VIOLATION', -26);
define('DB_ERROR_NOSUCHDB', -27);
define('DB_ERROR_CONSTRAINT_NOT_NULL',-29);
 
 
// }}}
// {{{ prepared statement-related
 
 
/*
* These constants are used when storing information about prepared
* statements (using the "prepare" method in DB_dbtype).
*
* The prepare/execute model in DB is mostly borrowed from the ODBC
* extension, in a query the "?" character means a scalar parameter.
* There are two extensions though, a "&" character means an opaque
* parameter. An opaque parameter is simply a file name, the real
* data are in that file (useful for putting uploaded files into your
* database and such). The "!" char means a parameter that must be
* left as it is.
* They modify the quote behavoir:
* DB_PARAM_SCALAR (?) => 'original string quoted'
* DB_PARAM_OPAQUE (&) => 'string from file quoted'
* DB_PARAM_MISC (!) => original string
*/
define('DB_PARAM_SCALAR', 1);
define('DB_PARAM_OPAQUE', 2);
define('DB_PARAM_MISC', 3);
 
 
// }}}
// {{{ binary data-related
 
 
/*
* These constants define different ways of returning binary data
* from queries. Again, this model has been borrowed from the ODBC
* extension.
*
* DB_BINMODE_PASSTHRU sends the data directly through to the browser
* when data is fetched from the database.
* DB_BINMODE_RETURN lets you return data as usual.
* DB_BINMODE_CONVERT returns data as well, only it is converted to
* hex format, for example the string "123" would become "313233".
*/
define('DB_BINMODE_PASSTHRU', 1);
define('DB_BINMODE_RETURN', 2);
define('DB_BINMODE_CONVERT', 3);
 
 
// }}}
// {{{ fetch modes
 
 
/**
* This is a special constant that tells DB the user hasn't specified
* any particular get mode, so the default should be used.
*/
define('DB_FETCHMODE_DEFAULT', 0);
 
/**
* Column data indexed by numbers, ordered from 0 and up
*/
define('DB_FETCHMODE_ORDERED', 1);
 
/**
* Column data indexed by column names
*/
define('DB_FETCHMODE_ASSOC', 2);
 
/**
* Column data as object properties
*/
define('DB_FETCHMODE_OBJECT', 3);
 
/**
* For multi-dimensional results: normally the first level of arrays
* is the row number, and the second level indexed by column number or name.
* DB_FETCHMODE_FLIPPED switches this order, so the first level of arrays
* is the column name, and the second level the row number.
*/
define('DB_FETCHMODE_FLIPPED', 4);
 
/* for compatibility */
define('DB_GETMODE_ORDERED', DB_FETCHMODE_ORDERED);
define('DB_GETMODE_ASSOC', DB_FETCHMODE_ASSOC);
define('DB_GETMODE_FLIPPED', DB_FETCHMODE_FLIPPED);
 
 
// }}}
// {{{ tableInfo() && autoPrepare()-related
 
 
/**
* these are constants for the tableInfo-function
* they are bitwised or'ed. so if there are more constants to be defined
* in the future, adjust DB_TABLEINFO_FULL accordingly
*/
define('DB_TABLEINFO_ORDER', 1);
define('DB_TABLEINFO_ORDERTABLE', 2);
define('DB_TABLEINFO_FULL', 3);
 
/*
* Used by autoPrepare()
*/
define('DB_AUTOQUERY_INSERT', 1);
define('DB_AUTOQUERY_UPDATE', 2);
 
 
// }}}
// {{{ portability modes
 
 
/**
* Portability: turn off all portability features.
* @see DB_common::setOption()
*/
define('DB_PORTABILITY_NONE', 0);
 
/**
* Portability: convert names of tables and fields to lower case
* when using the get*(), fetch*() and tableInfo() methods.
* @see DB_common::setOption()
*/
define('DB_PORTABILITY_LOWERCASE', 1);
 
/**
* Portability: right trim the data output by get*() and fetch*().
* @see DB_common::setOption()
*/
define('DB_PORTABILITY_RTRIM', 2);
 
/**
* Portability: force reporting the number of rows deleted.
* @see DB_common::setOption()
*/
define('DB_PORTABILITY_DELETE_COUNT', 4);
 
/**
* Portability: enable hack that makes numRows() work in Oracle.
* @see DB_common::setOption()
*/
define('DB_PORTABILITY_NUMROWS', 8);
 
/**
* Portability: makes certain error messages in certain drivers compatible
* with those from other DBMS's.
*
* + mysql, mysqli: change unique/primary key constraints
* DB_ERROR_ALREADY_EXISTS -> DB_ERROR_CONSTRAINT
*
* + odbc(access): MS's ODBC driver reports 'no such field' as code
* 07001, which means 'too few parameters.' When this option is on
* that code gets mapped to DB_ERROR_NOSUCHFIELD.
*
* @see DB_common::setOption()
*/
define('DB_PORTABILITY_ERRORS', 16);
 
/**
* Portability: convert null values to empty strings in data output by
* get*() and fetch*().
* @see DB_common::setOption()
*/
define('DB_PORTABILITY_NULL_TO_EMPTY', 32);
 
/**
* Portability: turn on all portability features.
* @see DB_common::setOption()
*/
define('DB_PORTABILITY_ALL', 63);
 
// }}}
 
 
// }}}
// {{{ class DB
 
/**
* The main "DB" class is simply a container class with some static
* methods for creating DB objects as well as some utility functions
* common to all parts of DB.
*
* The object model of DB is as follows (indentation means inheritance):
*
* DB The main DB class. This is simply a utility class
* with some "static" methods for creating DB objects as
* well as common utility functions for other DB classes.
*
* DB_common The base for each DB implementation. Provides default
* | implementations (in OO lingo virtual methods) for
* | the actual DB implementations as well as a bunch of
* | query utility functions.
* |
* +-DB_mysql The DB implementation for MySQL. Inherits DB_common.
* When calling DB::factory or DB::connect for MySQL
* connections, the object returned is an instance of this
* class.
*
* @package DB
* @author Stig Bakken <ssb@php.net>
* @author Tomas V.V.Cox <cox@idecnet.com>
* @since PHP 4.0
* @version $Id$
* @category Database
*/
class DB
{
// {{{ &factory()
 
/**
* Create a new DB object for the specified database type.
*
* Allows creation of a DB_<driver> object from which the object's
* methods can be utilized without actually connecting to a database.
*
* @param string $type database type, for example "mysql"
* @param array $options associative array of option names and values
*
* @return object a new DB object. On error, an error object.
*
* @see DB_common::setOption()
* @access public
*/
function &factory($type, $options = false)
{
if (!is_array($options)) {
$options = array('persistent' => $options);
}
 
if (isset($options['debug']) && $options['debug'] >= 2) {
// expose php errors with sufficient debug level
include_once "DB/{$type}.php";
} else {
@include_once "DB/{$type}.php";
}
 
$classname = "DB_${type}";
 
if (!class_exists($classname)) {
$tmp = PEAR::raiseError(null, DB_ERROR_NOT_FOUND, null, null,
"Unable to include the DB/{$type}.php file",
'DB_Error', true);
return $tmp;
}
 
@$obj =& new $classname;
 
foreach ($options as $option => $value) {
$test = $obj->setOption($option, $value);
if (DB::isError($test)) {
return $test;
}
}
 
return $obj;
}
 
// }}}
// {{{ &connect()
 
/**
* Create a new DB object and connect to the specified database.
*
* Example 1.
* <code> <?php
* require_once 'DB.php';
*
* $dsn = 'mysql://user:password@host/database'
* $options = array(
* 'debug' => 2,
* 'portability' => DB_PORTABILITY_ALL,
* );
*
* $dbh =& DB::connect($dsn, $options);
* if (DB::isError($dbh)) {
* die($dbh->getMessage());
* }
* ?></code>
*
* @param mixed $dsn string "data source name" or an array in the
* format returned by DB::parseDSN()
*
* @param array $options an associative array of option names and
* their values
*
* @return object a newly created DB connection object, or a DB
* error object on error
*
* @see DB::parseDSN(), DB_common::setOption(), DB::isError()
* @access public
*/
function &connect($dsn, $options = array())
{
$dsninfo = DB::parseDSN($dsn);
$type = $dsninfo['phptype'];
 
if (!is_array($options)) {
/*
* For backwards compatibility. $options used to be boolean,
* indicating whether the connection should be persistent.
*/
$options = array('persistent' => $options);
}
 
if (isset($options['debug']) && $options['debug'] >= 2) {
// expose php errors with sufficient debug level
include_once "DB/${type}.php";
} else {
@include_once "DB/${type}.php";
}
 
$classname = "DB_${type}";
if (!class_exists($classname)) {
$tmp = PEAR::raiseError(null, DB_ERROR_NOT_FOUND, null, null,
"Unable to include the DB/{$type}.php file for `$dsn'",
'DB_Error', true);
return $tmp;
}
 
@$obj =& new $classname;
 
foreach ($options as $option => $value) {
$test = $obj->setOption($option, $value);
if (DB::isError($test)) {
return $test;
}
}
 
$err = $obj->connect($dsninfo, $obj->getOption('persistent'));
if (DB::isError($err)) {
$err->addUserInfo($dsn);
return $err;
}
 
return $obj;
}
 
// }}}
// {{{ apiVersion()
 
/**
* Return the DB API version
*
* @return int the DB API version number
*
* @access public
*/
function apiVersion()
{
return 2;
}
 
// }}}
// {{{ isError()
 
/**
* Tell whether a result code from a DB method is an error
*
* @param int $value result code
*
* @return bool whether $value is an error
*
* @access public
*/
function isError($value)
{
return is_a($value, 'DB_Error');
}
 
// }}}
// {{{ isConnection()
 
/**
* Tell whether a value is a DB connection
*
* @param mixed $value value to test
*
* @return bool whether $value is a DB connection
*
* @access public
*/
function isConnection($value)
{
return (is_object($value) &&
is_subclass_of($value, 'db_common') &&
method_exists($value, 'simpleQuery'));
}
 
// }}}
// {{{ isManip()
 
/**
* Tell whether a query is a data manipulation query (insert,
* update or delete) or a data definition query (create, drop,
* alter, grant, revoke).
*
* @access public
*
* @param string $query the query
*
* @return boolean whether $query is a data manipulation query
*/
function isManip($query)
{
$manips = 'INSERT|UPDATE|DELETE|LOAD DATA|'.'REPLACE|CREATE|DROP|'.
'ALTER|GRANT|REVOKE|'.'LOCK|UNLOCK';
if (preg_match('/^\s*"?('.$manips.')\s+/i', $query)) {
return true;
}
return false;
}
 
// }}}
// {{{ errorMessage()
 
/**
* Return a textual error message for a DB error code
*
* @param integer $value error code
*
* @return string error message, or false if the error code was
* not recognized
*/
function errorMessage($value)
{
static $errorMessages;
if (!isset($errorMessages)) {
$errorMessages = array(
DB_ERROR => 'unknown error',
DB_ERROR_ALREADY_EXISTS => 'already exists',
DB_ERROR_CANNOT_CREATE => 'can not create',
DB_ERROR_CANNOT_DELETE => 'can not delete',
DB_ERROR_CANNOT_DROP => 'can not drop',
DB_ERROR_CONSTRAINT => 'constraint violation',
DB_ERROR_CONSTRAINT_NOT_NULL=> 'null value violates not-null constraint',
DB_ERROR_DIVZERO => 'division by zero',
DB_ERROR_INVALID => 'invalid',
DB_ERROR_INVALID_DATE => 'invalid date or time',
DB_ERROR_INVALID_NUMBER => 'invalid number',
DB_ERROR_MISMATCH => 'mismatch',
DB_ERROR_NODBSELECTED => 'no database selected',
DB_ERROR_NOSUCHFIELD => 'no such field',
DB_ERROR_NOSUCHTABLE => 'no such table',
DB_ERROR_NOT_CAPABLE => 'DB backend not capable',
DB_ERROR_NOT_FOUND => 'not found',
DB_ERROR_NOT_LOCKED => 'not locked',
DB_ERROR_SYNTAX => 'syntax error',
DB_ERROR_UNSUPPORTED => 'not supported',
DB_ERROR_VALUE_COUNT_ON_ROW => 'value count on row',
DB_ERROR_INVALID_DSN => 'invalid DSN',
DB_ERROR_CONNECT_FAILED => 'connect failed',
DB_OK => 'no error',
DB_ERROR_NEED_MORE_DATA => 'insufficient data supplied',
DB_ERROR_EXTENSION_NOT_FOUND=> 'extension not found',
DB_ERROR_NOSUCHDB => 'no such database',
DB_ERROR_ACCESS_VIOLATION => 'insufficient permissions',
DB_ERROR_TRUNCATED => 'truncated'
);
}
 
if (DB::isError($value)) {
$value = $value->getCode();
}
 
return isset($errorMessages[$value]) ? $errorMessages[$value] : $errorMessages[DB_ERROR];
}
 
// }}}
// {{{ parseDSN()
 
/**
* Parse a data source name.
*
* Additional keys can be added by appending a URI query string to the
* end of the DSN.
*
* The format of the supplied DSN is in its fullest form:
* <code>
* phptype(dbsyntax)://username:password@protocol+hostspec/database?option=8&another=true
* </code>
*
* Most variations are allowed:
* <code>
* phptype://username:password@protocol+hostspec:110//usr/db_file.db?mode=0644
* phptype://username:password@hostspec/database_name
* phptype://username:password@hostspec
* phptype://username@hostspec
* phptype://hostspec/database
* phptype://hostspec
* phptype(dbsyntax)
* phptype
* </code>
*
* @param string $dsn Data Source Name to be parsed
*
* @return array an associative array with the following keys:
* + phptype: Database backend used in PHP (mysql, odbc etc.)
* + dbsyntax: Database used with regards to SQL syntax etc.
* + protocol: Communication protocol to use (tcp, unix etc.)
* + hostspec: Host specification (hostname[:port])
* + database: Database to use on the DBMS server
* + username: User name for login
* + password: Password for login
*
* @author Tomas V.V.Cox <cox@idecnet.com>
*/
function parseDSN($dsn)
{
$parsed = array(
'phptype' => false,
'dbsyntax' => false,
'username' => false,
'password' => false,
'protocol' => false,
'hostspec' => false,
'port' => false,
'socket' => false,
'database' => false,
);
 
if (is_array($dsn)) {
$dsn = array_merge($parsed, $dsn);
if (!$dsn['dbsyntax']) {
$dsn['dbsyntax'] = $dsn['phptype'];
}
return $dsn;
}
 
// Find phptype and dbsyntax
if (($pos = strpos($dsn, '://')) !== false) {
$str = substr($dsn, 0, $pos);
$dsn = substr($dsn, $pos + 3);
} else {
$str = $dsn;
$dsn = null;
}
 
// Get phptype and dbsyntax
// $str => phptype(dbsyntax)
if (preg_match('|^(.+?)\((.*?)\)$|', $str, $arr)) {
$parsed['phptype'] = $arr[1];
$parsed['dbsyntax'] = !$arr[2] ? $arr[1] : $arr[2];
} else {
$parsed['phptype'] = $str;
$parsed['dbsyntax'] = $str;
}
 
if (!count($dsn)) {
return $parsed;
}
 
// Get (if found): username and password
// $dsn => username:password@protocol+hostspec/database
if (($at = strrpos($dsn,'@')) !== false) {
$str = substr($dsn, 0, $at);
$dsn = substr($dsn, $at + 1);
if (($pos = strpos($str, ':')) !== false) {
$parsed['username'] = rawurldecode(substr($str, 0, $pos));
$parsed['password'] = rawurldecode(substr($str, $pos + 1));
} else {
$parsed['username'] = rawurldecode($str);
}
}
 
// Find protocol and hostspec
 
// $dsn => proto(proto_opts)/database
if (preg_match('|^([^(]+)\((.*?)\)/?(.*?)$|', $dsn, $match)) {
$proto = $match[1];
$proto_opts = $match[2] ? $match[2] : false;
$dsn = $match[3];
 
// $dsn => protocol+hostspec/database (old format)
} else {
if (strpos($dsn, '+') !== false) {
list($proto, $dsn) = explode('+', $dsn, 2);
}
if (strpos($dsn, '/') !== false) {
list($proto_opts, $dsn) = explode('/', $dsn, 2);
} else {
$proto_opts = $dsn;
$dsn = null;
}
}
 
// process the different protocol options
$parsed['protocol'] = (!empty($proto)) ? $proto : 'tcp';
$proto_opts = rawurldecode($proto_opts);
if ($parsed['protocol'] == 'tcp') {
if (strpos($proto_opts, ':') !== false) {
list($parsed['hostspec'], $parsed['port']) = explode(':', $proto_opts);
} else {
$parsed['hostspec'] = $proto_opts;
}
} elseif ($parsed['protocol'] == 'unix') {
$parsed['socket'] = $proto_opts;
}
 
// Get dabase if any
// $dsn => database
if ($dsn) {
// /database
if (($pos = strpos($dsn, '?')) === false) {
$parsed['database'] = $dsn;
// /database?param1=value1&param2=value2
} else {
$parsed['database'] = substr($dsn, 0, $pos);
$dsn = substr($dsn, $pos + 1);
if (strpos($dsn, '&') !== false) {
$opts = explode('&', $dsn);
} else { // database?param1=value1
$opts = array($dsn);
}
foreach ($opts as $opt) {
list($key, $value) = explode('=', $opt);
if (!isset($parsed[$key])) {
// don't allow params overwrite
$parsed[$key] = rawurldecode($value);
}
}
}
}
 
return $parsed;
}
 
// }}}
// {{{ assertExtension()
 
/**
* Load a PHP database extension if it is not loaded already.
*
* @access public
*
* @param string $name the base name of the extension (without the .so or
* .dll suffix)
*
* @return boolean true if the extension was already or successfully
* loaded, false if it could not be loaded
*/
function assertExtension($name)
{
if (!extension_loaded($name)) {
$dlext = OS_WINDOWS ? '.dll' : '.so';
$dlprefix = OS_WINDOWS ? 'php_' : '';
@dl($dlprefix . $name . $dlext);
return extension_loaded($name);
}
return true;
}
// }}}
}
 
// }}}
// {{{ class DB_Error
 
/**
* DB_Error implements a class for reporting portable database error
* messages.
*
* @package DB
* @author Stig Bakken <ssb@php.net>
*/
class DB_Error extends PEAR_Error
{
// {{{ constructor
 
/**
* DB_Error constructor.
*
* @param mixed $code DB error code, or string with error message.
* @param integer $mode what "error mode" to operate in
* @param integer $level what error level to use for $mode & PEAR_ERROR_TRIGGER
* @param mixed $debuginfo additional debug info, such as the last query
*
* @access public
*
* @see PEAR_Error
*/
function DB_Error($code = DB_ERROR, $mode = PEAR_ERROR_RETURN,
$level = E_USER_NOTICE, $debuginfo = null)
{
if (is_int($code)) {
$this->PEAR_Error('DB Error: ' . DB::errorMessage($code), $code, $mode, $level, $debuginfo);
} else {
$this->PEAR_Error("DB Error: $code", DB_ERROR, $mode, $level, $debuginfo);
}
}
// }}}
}
 
// }}}
// {{{ class DB_result
 
/**
* This class implements a wrapper for a DB result set.
* A new instance of this class will be returned by the DB implementation
* after processing a query that returns data.
*
* @package DB
* @author Stig Bakken <ssb@php.net>
*/
class DB_result
{
// {{{ properties
 
var $dbh;
var $result;
var $row_counter = null;
 
/**
* for limit queries, the row to start fetching
* @var integer
*/
var $limit_from = null;
 
/**
* for limit queries, the number of rows to fetch
* @var integer
*/
var $limit_count = null;
 
// }}}
// {{{ constructor
 
/**
* DB_result constructor.
* @param resource &$dbh DB object reference
* @param resource $result result resource id
* @param array $options assoc array with optional result options
*/
function DB_result(&$dbh, $result, $options = array())
{
$this->dbh = &$dbh;
$this->result = $result;
foreach ($options as $key => $value) {
$this->setOption($key, $value);
}
$this->limit_type = $dbh->features['limit'];
$this->autofree = $dbh->options['autofree'];
$this->fetchmode = $dbh->fetchmode;
$this->fetchmode_object_class = $dbh->fetchmode_object_class;
}
 
function setOption($key, $value = null)
{
switch ($key) {
case 'limit_from':
$this->limit_from = $value; break;
case 'limit_count':
$this->limit_count = $value; break;
}
}
 
// }}}
// {{{ fetchRow()
 
/**
* Fetch a row of data and return it by reference into an array.
*
* The type of array returned can be controlled either by setting this
* method's <var>$fetchmode</var> parameter or by changing the default
* fetch mode setFetchMode() before calling this method.
*
* There are two options for standardizing the information returned
* from databases, ensuring their values are consistent when changing
* DBMS's. These portability options can be turned on when creating a
* new DB object or by using setOption().
*
* + <samp>DB_PORTABILITY_LOWERCASE</samp>
* convert names of fields to lower case
*
* + <samp>DB_PORTABILITY_RTRIM</samp>
* right trim the data
*
* @param int $fetchmode how the resulting array should be indexed
* @param int $rownum the row number to fetch
*
* @return array a row of data, null on no more rows or PEAR_Error
* object on error
*
* @see DB_common::setOption(), DB_common::setFetchMode()
* @access public
*/
function &fetchRow($fetchmode = DB_FETCHMODE_DEFAULT, $rownum=null)
{
if ($fetchmode === DB_FETCHMODE_DEFAULT) {
$fetchmode = $this->fetchmode;
}
if ($fetchmode === DB_FETCHMODE_OBJECT) {
$fetchmode = DB_FETCHMODE_ASSOC;
$object_class = $this->fetchmode_object_class;
}
if ($this->limit_from !== null) {
if ($this->row_counter === null) {
$this->row_counter = $this->limit_from;
// Skip rows
if ($this->limit_type == false) {
$i = 0;
while ($i++ < $this->limit_from) {
$this->dbh->fetchInto($this->result, $arr, $fetchmode);
}
}
}
if ($this->row_counter >= (
$this->limit_from + $this->limit_count))
{
if ($this->autofree) {
$this->free();
}
$tmp = null;
return $tmp;
}
if ($this->limit_type == 'emulate') {
$rownum = $this->row_counter;
}
$this->row_counter++;
}
$res = $this->dbh->fetchInto($this->result, $arr, $fetchmode, $rownum);
if ($res === DB_OK) {
if (isset($object_class)) {
// default mode specified in DB_common::fetchmode_object_class property
if ($object_class == 'stdClass') {
$arr = (object) $arr;
} else {
$arr = &new $object_class($arr);
}
}
return $arr;
}
if ($res == null && $this->autofree) {
$this->free();
}
return $res;
}
 
// }}}
// {{{ fetchInto()
 
/**
* Fetch a row of data into an array which is passed by reference.
*
* The type of array returned can be controlled either by setting this
* method's <var>$fetchmode</var> parameter or by changing the default
* fetch mode setFetchMode() before calling this method.
*
* There are two options for standardizing the information returned
* from databases, ensuring their values are consistent when changing
* DBMS's. These portability options can be turned on when creating a
* new DB object or by using setOption().
*
* + <samp>DB_PORTABILITY_LOWERCASE</samp>
* convert names of fields to lower case
*
* + <samp>DB_PORTABILITY_RTRIM</samp>
* right trim the data
*
* @param array &$arr (reference) array where data from the row
* should be placed
* @param int $fetchmode how the resulting array should be indexed
* @param int $rownum the row number to fetch
*
* @return mixed DB_OK on success, null on no more rows or
* a DB_Error object on error
*
* @see DB_common::setOption(), DB_common::setFetchMode()
* @access public
*/
function fetchInto(&$arr, $fetchmode = DB_FETCHMODE_DEFAULT, $rownum=null)
{
if ($fetchmode === DB_FETCHMODE_DEFAULT) {
$fetchmode = $this->fetchmode;
}
if ($fetchmode === DB_FETCHMODE_OBJECT) {
$fetchmode = DB_FETCHMODE_ASSOC;
$object_class = $this->fetchmode_object_class;
}
if ($this->limit_from !== null) {
if ($this->row_counter === null) {
$this->row_counter = $this->limit_from;
// Skip rows
if ($this->limit_type == false) {
$i = 0;
while ($i++ < $this->limit_from) {
$this->dbh->fetchInto($this->result, $arr, $fetchmode);
}
}
}
if ($this->row_counter >= (
$this->limit_from + $this->limit_count))
{
if ($this->autofree) {
$this->free();
}
return null;
}
if ($this->limit_type == 'emulate') {
$rownum = $this->row_counter;
}
 
$this->row_counter++;
}
$res = $this->dbh->fetchInto($this->result, $arr, $fetchmode, $rownum);
if ($res === DB_OK) {
if (isset($object_class)) {
// default mode specified in DB_common::fetchmode_object_class property
if ($object_class == 'stdClass') {
$arr = (object) $arr;
} else {
$arr = new $object_class($arr);
}
}
return DB_OK;
}
if ($res == null && $this->autofree) {
$this->free();
}
return $res;
}
 
// }}}
// {{{ numCols()
 
/**
* Get the the number of columns in a result set.
*
* @return int the number of columns, or a DB error
*
* @access public
*/
function numCols()
{
return $this->dbh->numCols($this->result);
}
 
// }}}
// {{{ numRows()
 
/**
* Get the number of rows in a result set.
*
* @return int the number of rows, or a DB error
*
* @access public
*/
function numRows()
{
return $this->dbh->numRows($this->result);
}
 
// }}}
// {{{ nextResult()
 
/**
* Get the next result if a batch of queries was executed.
*
* @return bool true if a new result is available or false if not.
*
* @access public
*/
function nextResult()
{
return $this->dbh->nextResult($this->result);
}
 
// }}}
// {{{ free()
 
/**
* Frees the resources allocated for this result set.
* @return int error code
*
* @access public
*/
function free()
{
$err = $this->dbh->freeResult($this->result);
if (DB::isError($err)) {
return $err;
}
$this->result = false;
return true;
}
 
// }}}
// {{{ tableInfo()
 
/**
* @deprecated
* @internal
* @see DB_common::tableInfo()
*/
function tableInfo($mode = null)
{
if (is_string($mode)) {
return $this->dbh->raiseError(DB_ERROR_NEED_MORE_DATA);
}
return $this->dbh->tableInfo($this, $mode);
}
 
// }}}
// {{{ getRowCounter()
 
/**
* returns the actual row number
* @return integer
*/
function getRowCounter()
{
return $this->row_counter;
}
// }}}
}
 
// }}}
// {{{ class DB_row
 
/**
* Pear DB Row Object
* @see DB_common::setFetchMode()
*/
class DB_row
{
// {{{ constructor
 
/**
* constructor
*
* @param resource row data as array
*/
function DB_row(&$arr)
{
foreach ($arr as $key => $value) {
$this->$key = &$arr[$key];
}
}
 
// }}}
}
 
// }}}
 
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
*/
 
?>
/tags/v3.1-blanche-neige/jrest/lib/PEAR.php
New file
0,0 → 1,971
<?php
//
// +----------------------------------------------------------------------+
// | PEAR, the PHP Extension and Application Repository |
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2004 The PHP Group |
// +----------------------------------------------------------------------+
// | This source file is subject to version 2.0 of the PHP license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available through the world-wide-web at the following url: |
// | http://www.php.net/license/3_0.txt. |
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// | Authors: Sterling Hughes <sterling@php.net> |
// | Stig Bakken <ssb@php.net> |
// | Tomas V.V.Cox <cox@idecnet.com> |
// +----------------------------------------------------------------------+
//
// $Id$
//
 
define('PEAR_ERROR_RETURN', 1);
define('PEAR_ERROR_PRINT', 2);
define('PEAR_ERROR_TRIGGER', 4);
define('PEAR_ERROR_DIE', 8);
define('PEAR_ERROR_CALLBACK', 16);
define('PEAR_ERROR_EXCEPTION', 32);
define('PEAR_ZE2', (function_exists('version_compare') &&
version_compare(zend_version(), "2-dev", "ge")));
 
if (substr(PHP_OS, 0, 3) == 'WIN') {
define('OS_WINDOWS', true);
define('OS_UNIX', false);
define('PEAR_OS', 'Windows');
} else {
define('OS_WINDOWS', false);
define('OS_UNIX', true);
define('PEAR_OS', 'Unix'); // blatant assumption
}
 
// instant backwards compatibility
if (!defined('PATH_SEPARATOR')) {
if (OS_WINDOWS) {
define('PATH_SEPARATOR', ';');
} else {
define('PATH_SEPARATOR', ':');
}
}
 
$GLOBALS['_PEAR_default_error_mode'] = PEAR_ERROR_RETURN;
$GLOBALS['_PEAR_default_error_options'] = E_USER_NOTICE;
$GLOBALS['_PEAR_destructor_object_list'] = array();
$GLOBALS['_PEAR_shutdown_funcs'] = array();
$GLOBALS['_PEAR_error_handler_stack'] = array();
 
ini_set('track_errors', true);
 
/**
* Base class for other PEAR classes. Provides rudimentary
* emulation of destructors.
*
* If you want a destructor in your class, inherit PEAR and make a
* destructor method called _yourclassname (same name as the
* constructor, but with a "_" prefix). Also, in your constructor you
* have to call the PEAR constructor: $this->PEAR();.
* The destructor method will be called without parameters. Note that
* at in some SAPI implementations (such as Apache), any output during
* the request shutdown (in which destructors are called) seems to be
* discarded. If you need to get any debug information from your
* destructor, use error_log(), syslog() or something similar.
*
* IMPORTANT! To use the emulated destructors you need to create the
* objects by reference: $obj =& new PEAR_child;
*
* @since PHP 4.0.2
* @author Stig Bakken <ssb@php.net>
* @see http://pear.php.net/manual/
*/
class PEAR
{
// {{{ properties
 
/**
* Whether to enable internal debug messages.
*
* @var bool
* @access private
*/
var $_debug = false;
 
/**
* Default error mode for this object.
*
* @var int
* @access private
*/
var $_default_error_mode = null;
 
/**
* Default error options used for this object when error mode
* is PEAR_ERROR_TRIGGER.
*
* @var int
* @access private
*/
var $_default_error_options = null;
 
/**
* Default error handler (callback) for this object, if error mode is
* PEAR_ERROR_CALLBACK.
*
* @var string
* @access private
*/
var $_default_error_handler = '';
 
/**
* Which class to use for error objects.
*
* @var string
* @access private
*/
var $_error_class = 'PEAR_Error';
 
/**
* An array of expected errors.
*
* @var array
* @access private
*/
var $_expected_errors = array();
 
// }}}
 
// {{{ constructor
 
/**
* Constructor. Registers this object in
* $_PEAR_destructor_object_list for destructor emulation if a
* destructor object exists.
*
* @param string $error_class (optional) which class to use for
* error objects, defaults to PEAR_Error.
* @access public
* @return void
*/
function PEAR($error_class = null)
{
$classname = get_class($this);
if ($this->_debug) {
print "PEAR constructor called, class=$classname\n";
}
if ($error_class !== null) {
$this->_error_class = $error_class;
}
while ($classname) {
$destructor = "_$classname";
if (method_exists($this, $destructor)) {
global $_PEAR_destructor_object_list;
$_PEAR_destructor_object_list[] = &$this;
break;
} else {
$classname = get_parent_class($classname);
}
}
}
 
// }}}
// {{{ destructor
 
/**
* Destructor (the emulated type of...). Does nothing right now,
* but is included for forward compatibility, so subclass
* destructors should always call it.
*
* See the note in the class desciption about output from
* destructors.
*
* @access public
* @return void
*/
function _PEAR() {
if ($this->_debug) {
printf("PEAR destructor called, class=%s\n", get_class($this));
}
}
 
// }}}
// {{{ getStaticProperty()
 
/**
* If you have a class that's mostly/entirely static, and you need static
* properties, you can use this method to simulate them. Eg. in your method(s)
* do this: $myVar = &PEAR::getStaticProperty('myVar');
* You MUST use a reference, or they will not persist!
*
* @access public
* @param string $class The calling classname, to prevent clashes
* @param string $var The variable to retrieve.
* @return mixed A reference to the variable. If not set it will be
* auto initialised to NULL.
*/
function &getStaticProperty($class, $var)
{
static $properties;
return $properties[$class][$var];
}
 
// }}}
// {{{ registerShutdownFunc()
 
/**
* Use this function to register a shutdown method for static
* classes.
*
* @access public
* @param mixed $func The function name (or array of class/method) to call
* @param mixed $args The arguments to pass to the function
* @return void
*/
function registerShutdownFunc($func, $args = array())
{
$GLOBALS['_PEAR_shutdown_funcs'][] = array($func, $args);
}
 
// }}}
// {{{ isError()
 
/**
* Tell whether a value is a PEAR error.
*
* @param mixed $data the value to test
* @param int $code if $data is an error object, return true
* only if $code is a string and
* $obj->getMessage() == $code or
* $code is an integer and $obj->getCode() == $code
* @access public
* @return bool true if parameter is an error
*/
 
function isError($data, $code = null)
{
if (is_a($data, 'PEAR_Error')) {
if (is_null($code)) {
return true;
} elseif (is_string($code)) {
return $data->getMessage() == $code;
} else {
return $data->getCode() == $code;
}
}
return false;
}
 
// }}}
// {{{ setErrorHandling()
 
/**
* Sets how errors generated by this object should be handled.
* Can be invoked both in objects and statically. If called
* statically, setErrorHandling sets the default behaviour for all
* PEAR objects. If called in an object, setErrorHandling sets
* the default behaviour for that object.
*
* @param int $mode
* One of PEAR_ERROR_RETURN, PEAR_ERROR_PRINT,
* PEAR_ERROR_TRIGGER, PEAR_ERROR_DIE,
* PEAR_ERROR_CALLBACK or PEAR_ERROR_EXCEPTION.
*
* @param mixed $options
* When $mode is PEAR_ERROR_TRIGGER, this is the error level (one
* of E_USER_NOTICE, E_USER_WARNING or E_USER_ERROR).
*
* When $mode is PEAR_ERROR_CALLBACK, this parameter is expected
* to be the callback function or method. A callback
* function is a string with the name of the function, a
* callback method is an array of two elements: the element
* at index 0 is the object, and the element at index 1 is
* the name of the method to call in the object.
*
* When $mode is PEAR_ERROR_PRINT or PEAR_ERROR_DIE, this is
* a printf format string used when printing the error
* message.
*
* @access public
* @return void
* @see PEAR_ERROR_RETURN
* @see PEAR_ERROR_PRINT
* @see PEAR_ERROR_TRIGGER
* @see PEAR_ERROR_DIE
* @see PEAR_ERROR_CALLBACK
* @see PEAR_ERROR_EXCEPTION
*
* @since PHP 4.0.5
*/
 
function setErrorHandling($mode = null, $options = null)
{
if (isset($this) && is_a($this, 'PEAR')) {
$setmode = &$this->_default_error_mode;
$setoptions = &$this->_default_error_options;
} else {
$setmode = &$GLOBALS['_PEAR_default_error_mode'];
$setoptions = &$GLOBALS['_PEAR_default_error_options'];
}
 
switch ($mode) {
case PEAR_ERROR_RETURN:
case PEAR_ERROR_PRINT:
case PEAR_ERROR_TRIGGER:
case PEAR_ERROR_DIE:
case PEAR_ERROR_EXCEPTION:
case null:
$setmode = $mode;
$setoptions = $options;
break;
 
case PEAR_ERROR_CALLBACK:
$setmode = $mode;
// class/object method callback
if (is_callable($options)) {
$setoptions = $options;
} else {
trigger_error("invalid error callback", E_USER_WARNING);
}
break;
 
default:
trigger_error("invalid error mode", E_USER_WARNING);
break;
}
}
 
// }}}
// {{{ expectError()
 
/**
* This method is used to tell which errors you expect to get.
* Expected errors are always returned with error mode
* PEAR_ERROR_RETURN. Expected error codes are stored in a stack,
* and this method pushes a new element onto it. The list of
* expected errors are in effect until they are popped off the
* stack with the popExpect() method.
*
* Note that this method can not be called statically
*
* @param mixed $code a single error code or an array of error codes to expect
*
* @return int the new depth of the "expected errors" stack
* @access public
*/
function expectError($code = '*')
{
if (is_array($code)) {
array_push($this->_expected_errors, $code);
} else {
array_push($this->_expected_errors, array($code));
}
return sizeof($this->_expected_errors);
}
 
// }}}
// {{{ popExpect()
 
/**
* This method pops one element off the expected error codes
* stack.
*
* @return array the list of error codes that were popped
*/
function popExpect()
{
return array_pop($this->_expected_errors);
}
 
// }}}
// {{{ _checkDelExpect()
 
/**
* This method checks unsets an error code if available
*
* @param mixed error code
* @return bool true if the error code was unset, false otherwise
* @access private
* @since PHP 4.3.0
*/
function _checkDelExpect($error_code)
{
$deleted = false;
 
foreach ($this->_expected_errors AS $key => $error_array) {
if (in_array($error_code, $error_array)) {
unset($this->_expected_errors[$key][array_search($error_code, $error_array)]);
$deleted = true;
}
 
// clean up empty arrays
if (0 == count($this->_expected_errors[$key])) {
unset($this->_expected_errors[$key]);
}
}
return $deleted;
}
 
// }}}
// {{{ delExpect()
 
/**
* This method deletes all occurences of the specified element from
* the expected error codes stack.
*
* @param mixed $error_code error code that should be deleted
* @return mixed list of error codes that were deleted or error
* @access public
* @since PHP 4.3.0
*/
function delExpect($error_code)
{
$deleted = false;
 
if ((is_array($error_code) && (0 != count($error_code)))) {
// $error_code is a non-empty array here;
// we walk through it trying to unset all
// values
foreach($error_code as $key => $error) {
if ($this->_checkDelExpect($error)) {
$deleted = true;
} else {
$deleted = false;
}
}
return $deleted ? true : PEAR::raiseError("The expected error you submitted does not exist"); // IMPROVE ME
} elseif (!empty($error_code)) {
// $error_code comes alone, trying to unset it
if ($this->_checkDelExpect($error_code)) {
return true;
} else {
return PEAR::raiseError("The expected error you submitted does not exist"); // IMPROVE ME
}
} else {
// $error_code is empty
return PEAR::raiseError("The expected error you submitted is empty"); // IMPROVE ME
}
}
 
// }}}
// {{{ raiseError()
 
/**
* This method is a wrapper that returns an instance of the
* configured error class with this object's default error
* handling applied. If the $mode and $options parameters are not
* specified, the object's defaults are used.
*
* @param mixed $message a text error message or a PEAR error object
*
* @param int $code a numeric error code (it is up to your class
* to define these if you want to use codes)
*
* @param int $mode One of PEAR_ERROR_RETURN, PEAR_ERROR_PRINT,
* PEAR_ERROR_TRIGGER, PEAR_ERROR_DIE,
* PEAR_ERROR_CALLBACK, PEAR_ERROR_EXCEPTION.
*
* @param mixed $options If $mode is PEAR_ERROR_TRIGGER, this parameter
* specifies the PHP-internal error level (one of
* E_USER_NOTICE, E_USER_WARNING or E_USER_ERROR).
* If $mode is PEAR_ERROR_CALLBACK, this
* parameter specifies the callback function or
* method. In other error modes this parameter
* is ignored.
*
* @param string $userinfo If you need to pass along for example debug
* information, this parameter is meant for that.
*
* @param string $error_class The returned error object will be
* instantiated from this class, if specified.
*
* @param bool $skipmsg If true, raiseError will only pass error codes,
* the error message parameter will be dropped.
*
* @access public
* @return object a PEAR error object
* @see PEAR::setErrorHandling
* @since PHP 4.0.5
*/
function raiseError($message = null,
$code = null,
$mode = null,
$options = null,
$userinfo = null,
$error_class = null,
$skipmsg = false)
{
// The error is yet a PEAR error object
if (is_object($message)) {
$code = $message->getCode();
$userinfo = $message->getUserInfo();
$error_class = $message->getType();
$message->error_message_prefix = '';
$message = $message->getMessage();
}
 
if (isset($this) && isset($this->_expected_errors) && sizeof($this->_expected_errors) > 0 && sizeof($exp = end($this->_expected_errors))) {
if ($exp[0] == "*" ||
(is_int(reset($exp)) && in_array($code, $exp)) ||
(is_string(reset($exp)) && in_array($message, $exp))) {
$mode = PEAR_ERROR_RETURN;
}
}
// No mode given, try global ones
if ($mode === null) {
// Class error handler
if (isset($this) && isset($this->_default_error_mode)) {
$mode = $this->_default_error_mode;
$options = $this->_default_error_options;
// Global error handler
} elseif (isset($GLOBALS['_PEAR_default_error_mode'])) {
$mode = $GLOBALS['_PEAR_default_error_mode'];
$options = $GLOBALS['_PEAR_default_error_options'];
}
}
 
if ($error_class !== null) {
$ec = $error_class;
} elseif (isset($this) && isset($this->_error_class)) {
$ec = $this->_error_class;
} else {
$ec = 'PEAR_Error';
}
if ($skipmsg) {
return new $ec($code, $mode, $options, $userinfo);
} else {
return new $ec($message, $code, $mode, $options, $userinfo);
}
}
 
// }}}
// {{{ throwError()
 
/**
* Simpler form of raiseError with fewer options. In most cases
* message, code and userinfo are enough.
*
* @param string $message
*
*/
function throwError($message = null,
$code = null,
$userinfo = null)
{
if (isset($this) && is_subclass_of($this, 'PEAR_Error')) {
return $this->raiseError($message, $code, null, null, $userinfo);
} else {
return PEAR::raiseError($message, $code, null, null, $userinfo);
}
}
 
// }}}
// {{{ pushErrorHandling()
 
/**
* Push a new error handler on top of the error handler options stack. With this
* you can easily override the actual error handler for some code and restore
* it later with popErrorHandling.
*
* @param mixed $mode (same as setErrorHandling)
* @param mixed $options (same as setErrorHandling)
*
* @return bool Always true
*
* @see PEAR::setErrorHandling
*/
function pushErrorHandling($mode, $options = null)
{
$stack = &$GLOBALS['_PEAR_error_handler_stack'];
if (isset($this) && is_a($this, 'PEAR')) {
$def_mode = &$this->_default_error_mode;
$def_options = &$this->_default_error_options;
} else {
$def_mode = &$GLOBALS['_PEAR_default_error_mode'];
$def_options = &$GLOBALS['_PEAR_default_error_options'];
}
$stack[] = array($def_mode, $def_options);
 
if (isset($this) && is_a($this, 'PEAR')) {
$this->setErrorHandling($mode, $options);
} else {
PEAR::setErrorHandling($mode, $options);
}
$stack[] = array($mode, $options);
return true;
}
 
// }}}
// {{{ popErrorHandling()
 
/**
* Pop the last error handler used
*
* @return bool Always true
*
* @see PEAR::pushErrorHandling
*/
function popErrorHandling()
{
$stack = &$GLOBALS['_PEAR_error_handler_stack'];
array_pop($stack);
list($mode, $options) = $stack[sizeof($stack) - 1];
array_pop($stack);
if (isset($this) && is_a($this, 'PEAR')) {
$this->setErrorHandling($mode, $options);
} else {
PEAR::setErrorHandling($mode, $options);
}
return true;
}
 
// }}}
// {{{ loadExtension()
 
/**
* OS independant PHP extension load. Remember to take care
* on the correct extension name for case sensitive OSes.
*
* @param string $ext The extension name
* @return bool Success or not on the dl() call
*/
function loadExtension($ext)
{
if (!extension_loaded($ext)) {
// if either returns true dl() will produce a FATAL error, stop that
if ((ini_get('enable_dl') != 1) || (ini_get('safe_mode') == 1)) {
return false;
}
if (OS_WINDOWS) {
$suffix = '.dll';
} elseif (PHP_OS == 'HP-UX') {
$suffix = '.sl';
} elseif (PHP_OS == 'AIX') {
$suffix = '.a';
} elseif (PHP_OS == 'OSX') {
$suffix = '.bundle';
} else {
$suffix = '.so';
}
return @dl('php_'.$ext.$suffix) || @dl($ext.$suffix);
}
return true;
}
 
// }}}
}
 
// {{{ _PEAR_call_destructors()
 
function _PEAR_call_destructors()
{
global $_PEAR_destructor_object_list;
if (is_array($_PEAR_destructor_object_list) &&
sizeof($_PEAR_destructor_object_list))
{
reset($_PEAR_destructor_object_list);
while (list($k, $objref) = each($_PEAR_destructor_object_list)) {
$classname = get_class($objref);
while ($classname) {
$destructor = "_$classname";
if (method_exists($objref, $destructor)) {
$objref->$destructor();
break;
} else {
$classname = get_parent_class($classname);
}
}
}
// Empty the object list to ensure that destructors are
// not called more than once.
$_PEAR_destructor_object_list = array();
}
 
// Now call the shutdown functions
if (is_array($GLOBALS['_PEAR_shutdown_funcs']) AND !empty($GLOBALS['_PEAR_shutdown_funcs'])) {
foreach ($GLOBALS['_PEAR_shutdown_funcs'] as $value) {
call_user_func_array($value[0], $value[1]);
}
}
}
 
// }}}
 
class PEAR_Error
{
// {{{ properties
 
var $error_message_prefix = '';
var $mode = PEAR_ERROR_RETURN;
var $level = E_USER_NOTICE;
var $code = -1;
var $message = '';
var $userinfo = '';
var $backtrace = null;
 
// }}}
// {{{ constructor
 
/**
* PEAR_Error constructor
*
* @param string $message message
*
* @param int $code (optional) error code
*
* @param int $mode (optional) error mode, one of: PEAR_ERROR_RETURN,
* PEAR_ERROR_PRINT, PEAR_ERROR_DIE, PEAR_ERROR_TRIGGER,
* PEAR_ERROR_CALLBACK or PEAR_ERROR_EXCEPTION
*
* @param mixed $options (optional) error level, _OR_ in the case of
* PEAR_ERROR_CALLBACK, the callback function or object/method
* tuple.
*
* @param string $userinfo (optional) additional user/debug info
*
* @access public
*
*/
function PEAR_Error($message = 'unknown error', $code = null,
$mode = null, $options = null, $userinfo = null)
{
if ($mode === null) {
$mode = PEAR_ERROR_RETURN;
}
$this->message = $message;
$this->code = $code;
$this->mode = $mode;
$this->userinfo = $userinfo;
if (function_exists("debug_backtrace")) {
$this->backtrace = debug_backtrace();
}
if ($mode & PEAR_ERROR_CALLBACK) {
$this->level = E_USER_NOTICE;
$this->callback = $options;
} else {
if ($options === null) {
$options = E_USER_NOTICE;
}
$this->level = $options;
$this->callback = null;
}
if ($this->mode & PEAR_ERROR_PRINT) {
if (is_null($options) || is_int($options)) {
$format = "%s";
} else {
$format = $options;
}
printf($format, $this->getMessage());
}
if ($this->mode & PEAR_ERROR_TRIGGER) {
trigger_error($this->getMessage(), $this->level);
}
if ($this->mode & PEAR_ERROR_DIE) {
$msg = $this->getMessage();
if (is_null($options) || is_int($options)) {
$format = "%s";
if (substr($msg, -1) != "\n") {
$msg .= "\n";
}
} else {
$format = $options;
}
die(sprintf($format, $msg));
}
if ($this->mode & PEAR_ERROR_CALLBACK) {
if (is_callable($this->callback)) {
call_user_func($this->callback, $this);
}
}
if (PEAR_ZE2 && $this->mode & PEAR_ERROR_EXCEPTION) {
eval('throw $this;');
}
}
 
// }}}
// {{{ getMode()
 
/**
* Get the error mode from an error object.
*
* @return int error mode
* @access public
*/
function getMode() {
return $this->mode;
}
 
// }}}
// {{{ getCallback()
 
/**
* Get the callback function/method from an error object.
*
* @return mixed callback function or object/method array
* @access public
*/
function getCallback() {
return $this->callback;
}
 
// }}}
// {{{ getMessage()
 
 
/**
* Get the error message from an error object.
*
* @return string full error message
* @access public
*/
function getMessage()
{
return ($this->error_message_prefix . $this->message);
}
 
 
// }}}
// {{{ getCode()
 
/**
* Get error code from an error object
*
* @return int error code
* @access public
*/
function getCode()
{
return $this->code;
}
 
// }}}
// {{{ getType()
 
/**
* Get the name of this error/exception.
*
* @return string error/exception name (type)
* @access public
*/
function getType()
{
return get_class($this);
}
 
// }}}
// {{{ getUserInfo()
 
/**
* Get additional user-supplied information.
*
* @return string user-supplied information
* @access public
*/
function getUserInfo()
{
return $this->userinfo;
}
 
// }}}
// {{{ getDebugInfo()
 
/**
* Get additional debug information supplied by the application.
*
* @return string debug information
* @access public
*/
function getDebugInfo()
{
return $this->getUserInfo();
}
 
// }}}
// {{{ getBacktrace()
 
/**
* Get the call backtrace from where the error was generated.
* Supported with PHP 4.3.0 or newer.
*
* @param int $frame (optional) what frame to fetch
* @return array Backtrace, or NULL if not available.
* @access public
*/
function getBacktrace($frame = null)
{
if ($frame === null) {
return $this->backtrace;
}
return $this->backtrace[$frame];
}
 
// }}}
// {{{ addUserInfo()
 
function addUserInfo($info)
{
if (empty($this->userinfo)) {
$this->userinfo = $info;
} else {
$this->userinfo .= " ** $info";
}
}
 
// }}}
// {{{ toString()
 
/**
* Make a string representation of this object.
*
* @return string a string with an object summary
* @access public
*/
function toString() {
$modes = array();
$levels = array(E_USER_NOTICE => 'notice',
E_USER_WARNING => 'warning',
E_USER_ERROR => 'error');
if ($this->mode & PEAR_ERROR_CALLBACK) {
if (is_array($this->callback)) {
$callback = get_class($this->callback[0]) . '::' .
$this->callback[1];
} else {
$callback = $this->callback;
}
return sprintf('[%s: message="%s" code=%d mode=callback '.
'callback=%s prefix="%s" info="%s"]',
get_class($this), $this->message, $this->code,
$callback, $this->error_message_prefix,
$this->userinfo);
}
if ($this->mode & PEAR_ERROR_PRINT) {
$modes[] = 'print';
}
if ($this->mode & PEAR_ERROR_TRIGGER) {
$modes[] = 'trigger';
}
if ($this->mode & PEAR_ERROR_DIE) {
$modes[] = 'die';
}
if ($this->mode & PEAR_ERROR_RETURN) {
$modes[] = 'return';
}
return sprintf('[%s: message="%s" code=%d mode=%s level=%s '.
'prefix="%s" info="%s"]',
get_class($this), $this->message, $this->code,
implode("|", $modes), $levels[$this->level],
$this->error_message_prefix,
$this->userinfo);
}
 
// }}}
}
 
register_shutdown_function("_PEAR_call_destructors");
 
/*
* Local Variables:
* mode: php
* tab-width: 4
* c-basic-offset: 4
* End:
*/
?>
/tags/v3.1-blanche-neige/jrest/lib/File/PDF/fonts/courier.php
New file
0,0 → 1,10
<?php
/**
* @package File_PDF
*/
for ($i = 0; $i <= 255; $i++) {
$font_widths['courier'][chr($i)] = 600;
}
$font_widths['courierB'] = $font_widths['courier'];
$font_widths['courierI'] = $font_widths['courier'];
$font_widths['courierBI'] = $font_widths['courier'];
/tags/v3.1-blanche-neige/jrest/lib/File/PDF/fonts/timesi.php
New file
0,0 → 1,272
<?php
/**
* @package File_PDF
*/
$font_widths['timesI'] = array(
chr(0) => 250,
chr(1) => 250,
chr(2) => 250,
chr(3) => 250,
chr(4) => 250,
chr(5) => 250,
chr(6) => 250,
chr(7) => 250,
chr(8) => 250,
chr(9) => 250,
chr(10) => 250,
chr(11) => 250,
chr(12) => 250,
chr(13) => 250,
chr(14) => 250,
chr(15) => 250,
chr(16) => 250,
chr(17) => 250,
chr(18) => 250,
chr(19) => 250,
chr(20) => 250,
chr(21) => 250,
chr(22) => 250,
chr(23) => 250,
chr(24) => 250,
chr(25) => 250,
chr(26) => 250,
chr(27) => 250,
chr(28) => 250,
chr(29) => 250,
chr(30) => 250,
chr(31) => 250,
' ' => 250,
'!' => 333,
'"' => 420,
'#' => 500,
'$' => 500,
'%' => 833,
'&' => 778,
'\'' => 214,
'(' => 333,
')' => 333,
'*' => 500,
'+' => 675,
',' => 250,
'-' => 333,
'.' => 250,
'/' => 278,
'0' => 500,
'1' => 500,
'2' => 500,
'3' => 500,
'4' => 500,
'5' => 500,
'6' => 500,
'7' => 500,
'8' => 500,
'9' => 500,
':' => 333,
';' => 333,
'<' => 675,
'=' => 675,
'>' => 675,
'?' => 500,
'@' => 920,
'A' => 611,
'B' => 611,
'C' => 667,
'D' => 722,
'E' => 611,
'F' => 611,
'G' => 722,
'H' => 722,
'I' => 333,
'J' => 444,
'K' => 667,
'L' => 556,
'M' => 833,
'N' => 667,
'O' => 722,
'P' => 611,
'Q' => 722,
'R' => 611,
'S' => 500,
'T' => 556,
'U' => 722,
'V' => 611,
'W' => 833,
'X' => 611,
'Y' => 556,
'Z' => 556,
'[' => 389,
'\\' => 278,
']' => 389,
'^' => 422,
'_' => 500,
'`' => 333,
'a' => 500,
'b' => 500,
'c' => 444,
'd' => 500,
'e' => 444,
'f' => 278,
'g' => 500,
'h' => 500,
'i' => 278,
'j' => 278,
'k' => 444,
'l' => 278,
'm' => 722,
'n' => 500,
'o' => 500,
'p' => 500,
'q' => 500,
'r' => 389,
's' => 389,
't' => 278,
'u' => 500,
'v' => 444,
'w' => 667,
'x' => 444,
'y' => 444,
'z' => 389,
'{' => 400,
'|' => 275,
'}' => 400,
'~' => 541,
chr(127) => 350,
chr(128) => 500,
chr(129) => 350,
chr(130) => 333,
chr(131) => 500,
chr(132) => 556,
chr(133) => 889,
chr(134) => 500,
chr(135) => 500,
chr(136) => 333,
chr(137) => 1000,
chr(138) => 500,
chr(139) => 333,
chr(140) => 944,
chr(141) => 350,
chr(142) => 556,
chr(143) => 350,
chr(144) => 350,
chr(145) => 333,
chr(146) => 333,
chr(147) => 556,
chr(148) => 556,
chr(149) => 350,
chr(150) => 500,
chr(151) => 889,
chr(152) => 333,
chr(153) => 980,
chr(154) => 389,
chr(155) => 333,
chr(156) => 667,
chr(157) => 350,
chr(158) => 389,
chr(159) => 556,
chr(160) => 250,
chr(161) => 389,
chr(162) => 500,
chr(163) => 500,
chr(164) => 500,
chr(165) => 500,
chr(166) => 275,
chr(167) => 500,
chr(168) => 333,
chr(169) => 760,
chr(170) => 276,
chr(171) => 500,
chr(172) => 675,
chr(173) => 333,
chr(174) => 760,
chr(175) => 333,
chr(176) => 400,
chr(177) => 675,
chr(178) => 300,
chr(179) => 300,
chr(180) => 333,
chr(181) => 500,
chr(182) => 523,
chr(183) => 250,
chr(184) => 333,
chr(185) => 300,
chr(186) => 310,
chr(187) => 500,
chr(188) => 750,
chr(189) => 750,
chr(190) => 750,
chr(191) => 500,
chr(192) => 611,
chr(193) => 611,
chr(194) => 611,
chr(195) => 611,
chr(196) => 611,
chr(197) => 611,
chr(198) => 889,
chr(199) => 667,
chr(200) => 611,
chr(201) => 611,
chr(202) => 611,
chr(203) => 611,
chr(204) => 333,
chr(205) => 333,
chr(206) => 333,
chr(207) => 333,
chr(208) => 722,
chr(209) => 667,
chr(210) => 722,
chr(211) => 722,
chr(212) => 722,
chr(213) => 722,
chr(214) => 722,
chr(215) => 675,
chr(216) => 722,
chr(217) => 722,
chr(218) => 722,
chr(219) => 722,
chr(220) => 722,
chr(221) => 556,
chr(222) => 611,
chr(223) => 500,
chr(224) => 500,
chr(225) => 500,
chr(226) => 500,
chr(227) => 500,
chr(228) => 500,
chr(229) => 500,
chr(230) => 667,
chr(231) => 444,
chr(232) => 444,
chr(233) => 444,
chr(234) => 444,
chr(235) => 444,
chr(236) => 278,
chr(237) => 278,
chr(238) => 278,
chr(239) => 278,
chr(240) => 500,
chr(241) => 500,
chr(242) => 500,
chr(243) => 500,
chr(244) => 500,
chr(245) => 500,
chr(246) => 500,
chr(247) => 675,
chr(248) => 500,
chr(249) => 500,
chr(250) => 500,
chr(251) => 500,
chr(252) => 500,
chr(253) => 444,
chr(254) => 500,
chr(255) => 444);
/tags/v3.1-blanche-neige/jrest/lib/File/PDF/fonts/timesbi.php
New file
0,0 → 1,272
<?php
/**
* @package File_PDF
*/
$font_widths['timesBI'] = array(
chr(0) => 250,
chr(1) => 250,
chr(2) => 250,
chr(3) => 250,
chr(4) => 250,
chr(5) => 250,
chr(6) => 250,
chr(7) => 250,
chr(8) => 250,
chr(9) => 250,
chr(10) => 250,
chr(11) => 250,
chr(12) => 250,
chr(13) => 250,
chr(14) => 250,
chr(15) => 250,
chr(16) => 250,
chr(17) => 250,
chr(18) => 250,
chr(19) => 250,
chr(20) => 250,
chr(21) => 250,
chr(22) => 250,
chr(23) => 250,
chr(24) => 250,
chr(25) => 250,
chr(26) => 250,
chr(27) => 250,
chr(28) => 250,
chr(29) => 250,
chr(30) => 250,
chr(31) => 250,
' ' => 250,
'!' => 389,
'"' => 555,
'#' => 500,
'$' => 500,
'%' => 833,
'&' => 778,
'\'' => 278,
'(' => 333,
')' => 333,
'*' => 500,
'+' => 570,
',' => 250,
'-' => 333,
'.' => 250,
'/' => 278,
'0' => 500,
'1' => 500,
'2' => 500,
'3' => 500,
'4' => 500,
'5' => 500,
'6' => 500,
'7' => 500,
'8' => 500,
'9' => 500,
':' => 333,
';' => 333,
'<' => 570,
'=' => 570,
'>' => 570,
'?' => 500,
'@' => 832,
'A' => 667,
'B' => 667,
'C' => 667,
'D' => 722,
'E' => 667,
'F' => 667,
'G' => 722,
'H' => 778,
'I' => 389,
'J' => 500,
'K' => 667,
'L' => 611,
'M' => 889,
'N' => 722,
'O' => 722,
'P' => 611,
'Q' => 722,
'R' => 667,
'S' => 556,
'T' => 611,
'U' => 722,
'V' => 667,
'W' => 889,
'X' => 667,
'Y' => 611,
'Z' => 611,
'[' => 333,
'\\' => 278,
']' => 333,
'^' => 570,
'_' => 500,
'`' => 333,
'a' => 500,
'b' => 500,
'c' => 444,
'd' => 500,
'e' => 444,
'f' => 333,
'g' => 500,
'h' => 556,
'i' => 278,
'j' => 278,
'k' => 500,
'l' => 278,
'm' => 778,
'n' => 556,
'o' => 500,
'p' => 500,
'q' => 500,
'r' => 389,
's' => 389,
't' => 278,
'u' => 556,
'v' => 444,
'w' => 667,
'x' => 500,
'y' => 444,
'z' => 389,
'{' => 348,
'|' => 220,
'}' => 348,
'~' => 570,
chr(127) => 350,
chr(128) => 500,
chr(129) => 350,
chr(130) => 333,
chr(131) => 500,
chr(132) => 500,
chr(133) => 1000,
chr(134) => 500,
chr(135) => 500,
chr(136) => 333,
chr(137) => 1000,
chr(138) => 556,
chr(139) => 333,
chr(140) => 944,
chr(141) => 350,
chr(142) => 611,
chr(143) => 350,
chr(144) => 350,
chr(145) => 333,
chr(146) => 333,
chr(147) => 500,
chr(148) => 500,
chr(149) => 350,
chr(150) => 500,
chr(151) => 1000,
chr(152) => 333,
chr(153) => 1000,
chr(154) => 389,
chr(155) => 333,
chr(156) => 722,
chr(157) => 350,
chr(158) => 389,
chr(159) => 611,
chr(160) => 250,
chr(161) => 389,
chr(162) => 500,
chr(163) => 500,
chr(164) => 500,
chr(165) => 500,
chr(166) => 220,
chr(167) => 500,
chr(168) => 333,
chr(169) => 747,
chr(170) => 266,
chr(171) => 500,
chr(172) => 606,
chr(173) => 333,
chr(174) => 747,
chr(175) => 333,
chr(176) => 400,
chr(177) => 570,
chr(178) => 300,
chr(179) => 300,
chr(180) => 333,
chr(181) => 576,
chr(182) => 500,
chr(183) => 250,
chr(184) => 333,
chr(185) => 300,
chr(186) => 300,
chr(187) => 500,
chr(188) => 750,
chr(189) => 750,
chr(190) => 750,
chr(191) => 500,
chr(192) => 667,
chr(193) => 667,
chr(194) => 667,
chr(195) => 667,
chr(196) => 667,
chr(197) => 667,
chr(198) => 944,
chr(199) => 667,
chr(200) => 667,
chr(201) => 667,
chr(202) => 667,
chr(203) => 667,
chr(204) => 389,
chr(205) => 389,
chr(206) => 389,
chr(207) => 389,
chr(208) => 722,
chr(209) => 722,
chr(210) => 722,
chr(211) => 722,
chr(212) => 722,
chr(213) => 722,
chr(214) => 722,
chr(215) => 570,
chr(216) => 722,
chr(217) => 722,
chr(218) => 722,
chr(219) => 722,
chr(220) => 722,
chr(221) => 611,
chr(222) => 611,
chr(223) => 500,
chr(224) => 500,
chr(225) => 500,
chr(226) => 500,
chr(227) => 500,
chr(228) => 500,
chr(229) => 500,
chr(230) => 722,
chr(231) => 444,
chr(232) => 444,
chr(233) => 444,
chr(234) => 444,
chr(235) => 444,
chr(236) => 278,
chr(237) => 278,
chr(238) => 278,
chr(239) => 278,
chr(240) => 500,
chr(241) => 556,
chr(242) => 500,
chr(243) => 500,
chr(244) => 500,
chr(245) => 500,
chr(246) => 500,
chr(247) => 570,
chr(248) => 500,
chr(249) => 556,
chr(250) => 556,
chr(251) => 556,
chr(252) => 556,
chr(253) => 444,
chr(254) => 500,
chr(255) => 444);
/tags/v3.1-blanche-neige/jrest/lib/File/PDF/fonts/zapfdingbats.php
New file
0,0 → 1,272
<?php
/**
* @package File_PDF
*/
$font_widths['zapfdingbats'] = array(
chr(0) => 0,
chr(1) => 0,
chr(2) => 0,
chr(3) => 0,
chr(4) => 0,
chr(5) => 0,
chr(6) => 0,
chr(7) => 0,
chr(8) => 0,
chr(9) => 0,
chr(10) => 0,
chr(11) => 0,
chr(12) => 0,
chr(13) => 0,
chr(14) => 0,
chr(15) => 0,
chr(16) => 0,
chr(17) => 0,
chr(18) => 0,
chr(19) => 0,
chr(20) => 0,
chr(21) => 0,
chr(22) => 0,
chr(23) => 0,
chr(24) => 0,
chr(25) => 0,
chr(26) => 0,
chr(27) => 0,
chr(28) => 0,
chr(29) => 0,
chr(30) => 0,
chr(31) => 0,
' ' => 278,
'!' => 974,
'"' => 961,
'#' => 974,
'$' => 980,
'%' => 719,
'&' => 789,
'\'' => 790,
'(' => 791,
')' => 690,
'*' => 960,
'+' => 939,
',' => 549,
'-' => 855,
'.' => 911,
'/' => 933,
'0' => 911,
'1' => 945,
'2' => 974,
'3' => 755,
'4' => 846,
'5' => 762,
'6' => 761,
'7' => 571,
'8' => 677,
'9' => 763,
':' => 760,
';' => 759,
'<' => 754,
'=' => 494,
'>' => 552,
'?' => 537,
'@' => 577,
'A' => 692,
'B' => 786,
'C' => 788,
'D' => 788,
'E' => 790,
'F' => 793,
'G' => 794,
'H' => 816,
'I' => 823,
'J' => 789,
'K' => 841,
'L' => 823,
'M' => 833,
'N' => 816,
'O' => 831,
'P' => 923,
'Q' => 744,
'R' => 723,
'S' => 749,
'T' => 790,
'U' => 792,
'V' => 695,
'W' => 776,
'X' => 768,
'Y' => 792,
'Z' => 759,
'[' => 707,
'\\' => 708,
']' => 682,
'^' => 701,
'_' => 826,
'`' => 815,
'a' => 789,
'b' => 789,
'c' => 707,
'd' => 687,
'e' => 696,
'f' => 689,
'g' => 786,
'h' => 787,
'i' => 713,
'j' => 791,
'k' => 785,
'l' => 791,
'm' => 873,
'n' => 761,
'o' => 762,
'p' => 762,
'q' => 759,
'r' => 759,
's' => 892,
't' => 892,
'u' => 788,
'v' => 784,
'w' => 438,
'x' => 138,
'y' => 277,
'z' => 415,
'{' => 392,
'|' => 392,
'}' => 668,
'~' => 668,
chr(127) => 0,
chr(128) => 390,
chr(129) => 390,
chr(130) => 317,
chr(131) => 317,
chr(132) => 276,
chr(133) => 276,
chr(134) => 509,
chr(135) => 509,
chr(136) => 410,
chr(137) => 410,
chr(138) => 234,
chr(139) => 234,
chr(140) => 334,
chr(141) => 334,
chr(142) => 0,
chr(143) => 0,
chr(144) => 0,
chr(145) => 0,
chr(146) => 0,
chr(147) => 0,
chr(148) => 0,
chr(149) => 0,
chr(150) => 0,
chr(151) => 0,
chr(152) => 0,
chr(153) => 0,
chr(154) => 0,
chr(155) => 0,
chr(156) => 0,
chr(157) => 0,
chr(158) => 0,
chr(159) => 0,
chr(160) => 0,
chr(161) => 732,
chr(162) => 544,
chr(163) => 544,
chr(164) => 910,
chr(165) => 667,
chr(166) => 760,
chr(167) => 760,
chr(168) => 776,
chr(169) => 595,
chr(170) => 694,
chr(171) => 626,
chr(172) => 788,
chr(173) => 788,
chr(174) => 788,
chr(175) => 788,
chr(176) => 788,
chr(177) => 788,
chr(178) => 788,
chr(179) => 788,
chr(180) => 788,
chr(181) => 788,
chr(182) => 788,
chr(183) => 788,
chr(184) => 788,
chr(185) => 788,
chr(186) => 788,
chr(187) => 788,
chr(188) => 788,
chr(189) => 788,
chr(190) => 788,
chr(191) => 788,
chr(192) => 788,
chr(193) => 788,
chr(194) => 788,
chr(195) => 788,
chr(196) => 788,
chr(197) => 788,
chr(198) => 788,
chr(199) => 788,
chr(200) => 788,
chr(201) => 788,
chr(202) => 788,
chr(203) => 788,
chr(204) => 788,
chr(205) => 788,
chr(206) => 788,
chr(207) => 788,
chr(208) => 788,
chr(209) => 788,
chr(210) => 788,
chr(211) => 788,
chr(212) => 894,
chr(213) => 838,
chr(214) => 1016,
chr(215) => 458,
chr(216) => 748,
chr(217) => 924,
chr(218) => 748,
chr(219) => 918,
chr(220) => 927,
chr(221) => 928,
chr(222) => 928,
chr(223) => 834,
chr(224) => 873,
chr(225) => 828,
chr(226) => 924,
chr(227) => 924,
chr(228) => 917,
chr(229) => 930,
chr(230) => 931,
chr(231) => 463,
chr(232) => 883,
chr(233) => 836,
chr(234) => 836,
chr(235) => 867,
chr(236) => 867,
chr(237) => 696,
chr(238) => 696,
chr(239) => 874,
chr(240) => 0,
chr(241) => 874,
chr(242) => 760,
chr(243) => 946,
chr(244) => 771,
chr(245) => 865,
chr(246) => 771,
chr(247) => 888,
chr(248) => 967,
chr(249) => 888,
chr(250) => 831,
chr(251) => 873,
chr(252) => 927,
chr(253) => 970,
chr(254) => 918,
chr(255) => 0);
/tags/v3.1-blanche-neige/jrest/lib/File/PDF/fonts/helveticai.php
New file
0,0 → 1,272
<?php
/**
* @package File_PDF
*/
$font_widths['helveticaI'] = array(
chr(0) => 278,
chr(1) => 278,
chr(2) => 278,
chr(3) => 278,
chr(4) => 278,
chr(5) => 278,
chr(6) => 278,
chr(7) => 278,
chr(8) => 278,
chr(9) => 278,
chr(10) => 278,
chr(11) => 278,
chr(12) => 278,
chr(13) => 278,
chr(14) => 278,
chr(15) => 278,
chr(16) => 278,
chr(17) => 278,
chr(18) => 278,
chr(19) => 278,
chr(20) => 278,
chr(21) => 278,
chr(22) => 278,
chr(23) => 278,
chr(24) => 278,
chr(25) => 278,
chr(26) => 278,
chr(27) => 278,
chr(28) => 278,
chr(29) => 278,
chr(30) => 278,
chr(31) => 278,
' ' => 278,
'!' => 278,
'"' => 355,
'#' => 556,
'$' => 556,
'%' => 889,
'&' => 667,
'\'' => 191,
'(' => 333,
')' => 333,
'*' => 389,
'+' => 584,
',' => 278,
'-' => 333,
'.' => 278,
'/' => 278,
'0' => 556,
'1' => 556,
'2' => 556,
'3' => 556,
'4' => 556,
'5' => 556,
'6' => 556,
'7' => 556,
'8' => 556,
'9' => 556,
':' => 278,
';' => 278,
'<' => 584,
'=' => 584,
'>' => 584,
'?' => 556,
'@' => 1015,
'A' => 667,
'B' => 667,
'C' => 722,
'D' => 722,
'E' => 667,
'F' => 611,
'G' => 778,
'H' => 722,
'I' => 278,
'J' => 500,
'K' => 667,
'L' => 556,
'M' => 833,
'N' => 722,
'O' => 778,
'P' => 667,
'Q' => 778,
'R' => 722,
'S' => 667,
'T' => 611,
'U' => 722,
'V' => 667,
'W' => 944,
'X' => 667,
'Y' => 667,
'Z' => 611,
'[' => 278,
'\\' => 278,
']' => 278,
'^' => 469,
'_' => 556,
'`' => 333,
'a' => 556,
'b' => 556,
'c' => 500,
'd' => 556,
'e' => 556,
'f' => 278,
'g' => 556,
'h' => 556,
'i' => 222,
'j' => 222,
'k' => 500,
'l' => 222,
'm' => 833,
'n' => 556,
'o' => 556,
'p' => 556,
'q' => 556,
'r' => 333,
's' => 500,
't' => 278,
'u' => 556,
'v' => 500,
'w' => 722,
'x' => 500,
'y' => 500,
'z' => 500,
'{' => 334,
'|' => 260,
'}' => 334,
'~' => 584,
chr(127) => 350,
chr(128) => 556,
chr(129) => 350,
chr(130) => 222,
chr(131) => 556,
chr(132) => 333,
chr(133) => 1000,
chr(134) => 556,
chr(135) => 556,
chr(136) => 333,
chr(137) => 1000,
chr(138) => 667,
chr(139) => 333,
chr(140) => 1000,
chr(141) => 350,
chr(142) => 611,
chr(143) => 350,
chr(144) => 350,
chr(145) => 222,
chr(146) => 222,
chr(147) => 333,
chr(148) => 333,
chr(149) => 350,
chr(150) => 556,
chr(151) => 1000,
chr(152) => 333,
chr(153) => 1000,
chr(154) => 500,
chr(155) => 333,
chr(156) => 944,
chr(157) => 350,
chr(158) => 500,
chr(159) => 667,
chr(160) => 278,
chr(161) => 333,
chr(162) => 556,
chr(163) => 556,
chr(164) => 556,
chr(165) => 556,
chr(166) => 260,
chr(167) => 556,
chr(168) => 333,
chr(169) => 737,
chr(170) => 370,
chr(171) => 556,
chr(172) => 584,
chr(173) => 333,
chr(174) => 737,
chr(175) => 333,
chr(176) => 400,
chr(177) => 584,
chr(178) => 333,
chr(179) => 333,
chr(180) => 333,
chr(181) => 556,
chr(182) => 537,
chr(183) => 278,
chr(184) => 333,
chr(185) => 333,
chr(186) => 365,
chr(187) => 556,
chr(188) => 834,
chr(189) => 834,
chr(190) => 834,
chr(191) => 611,
chr(192) => 667,
chr(193) => 667,
chr(194) => 667,
chr(195) => 667,
chr(196) => 667,
chr(197) => 667,
chr(198) => 1000,
chr(199) => 722,
chr(200) => 667,
chr(201) => 667,
chr(202) => 667,
chr(203) => 667,
chr(204) => 278,
chr(205) => 278,
chr(206) => 278,
chr(207) => 278,
chr(208) => 722,
chr(209) => 722,
chr(210) => 778,
chr(211) => 778,
chr(212) => 778,
chr(213) => 778,
chr(214) => 778,
chr(215) => 584,
chr(216) => 778,
chr(217) => 722,
chr(218) => 722,
chr(219) => 722,
chr(220) => 722,
chr(221) => 667,
chr(222) => 667,
chr(223) => 611,
chr(224) => 556,
chr(225) => 556,
chr(226) => 556,
chr(227) => 556,
chr(228) => 556,
chr(229) => 556,
chr(230) => 889,
chr(231) => 500,
chr(232) => 556,
chr(233) => 556,
chr(234) => 556,
chr(235) => 556,
chr(236) => 278,
chr(237) => 278,
chr(238) => 278,
chr(239) => 278,
chr(240) => 556,
chr(241) => 556,
chr(242) => 556,
chr(243) => 556,
chr(244) => 556,
chr(245) => 556,
chr(246) => 556,
chr(247) => 584,
chr(248) => 611,
chr(249) => 556,
chr(250) => 556,
chr(251) => 556,
chr(252) => 556,
chr(253) => 500,
chr(254) => 556,
chr(255) => 500);
/tags/v3.1-blanche-neige/jrest/lib/File/PDF/fonts/helveticabi.php
New file
0,0 → 1,272
<?php
/**
* @package File_PDF
*/
$font_widths['helveticaBI'] = array(
chr(0) => 278,
chr(1) => 278,
chr(2) => 278,
chr(3) => 278,
chr(4) => 278,
chr(5) => 278,
chr(6) => 278,
chr(7) => 278,
chr(8) => 278,
chr(9) => 278,
chr(10) => 278,
chr(11) => 278,
chr(12) => 278,
chr(13) => 278,
chr(14) => 278,
chr(15) => 278,
chr(16) => 278,
chr(17) => 278,
chr(18) => 278,
chr(19) => 278,
chr(20) => 278,
chr(21) => 278,
chr(22) => 278,
chr(23) => 278,
chr(24) => 278,
chr(25) => 278,
chr(26) => 278,
chr(27) => 278,
chr(28) => 278,
chr(29) => 278,
chr(30) => 278,
chr(31) => 278,
' ' => 278,
'!' => 333,
'"' => 474,
'#' => 556,
'$' => 556,
'%' => 889,
'&' => 722,
'\'' => 238,
'(' => 333,
')' => 333,
'*' => 389,
'+' => 584,
',' => 278,
'-' => 333,
'.' => 278,
'/' => 278,
'0' => 556,
'1' => 556,
'2' => 556,
'3' => 556,
'4' => 556,
'5' => 556,
'6' => 556,
'7' => 556,
'8' => 556,
'9' => 556,
':' => 333,
';' => 333,
'<' => 584,
'=' => 584,
'>' => 584,
'?' => 611,
'@' => 975,
'A' => 722,
'B' => 722,
'C' => 722,
'D' => 722,
'E' => 667,
'F' => 611,
'G' => 778,
'H' => 722,
'I' => 278,
'J' => 556,
'K' => 722,
'L' => 611,
'M' => 833,
'N' => 722,
'O' => 778,
'P' => 667,
'Q' => 778,
'R' => 722,
'S' => 667,
'T' => 611,
'U' => 722,
'V' => 667,
'W' => 944,
'X' => 667,
'Y' => 667,
'Z' => 611,
'[' => 333,
'\\' => 278,
']' => 333,
'^' => 584,
'_' => 556,
'`' => 333,
'a' => 556,
'b' => 611,
'c' => 556,
'd' => 611,
'e' => 556,
'f' => 333,
'g' => 611,
'h' => 611,
'i' => 278,
'j' => 278,
'k' => 556,
'l' => 278,
'm' => 889,
'n' => 611,
'o' => 611,
'p' => 611,
'q' => 611,
'r' => 389,
's' => 556,
't' => 333,
'u' => 611,
'v' => 556,
'w' => 778,
'x' => 556,
'y' => 556,
'z' => 500,
'{' => 389,
'|' => 280,
'}' => 389,
'~' => 584,
chr(127) => 350,
chr(128) => 556,
chr(129) => 350,
chr(130) => 278,
chr(131) => 556,
chr(132) => 500,
chr(133) => 1000,
chr(134) => 556,
chr(135) => 556,
chr(136) => 333,
chr(137) => 1000,
chr(138) => 667,
chr(139) => 333,
chr(140) => 1000,
chr(141) => 350,
chr(142) => 611,
chr(143) => 350,
chr(144) => 350,
chr(145) => 278,
chr(146) => 278,
chr(147) => 500,
chr(148) => 500,
chr(149) => 350,
chr(150) => 556,
chr(151) => 1000,
chr(152) => 333,
chr(153) => 1000,
chr(154) => 556,
chr(155) => 333,
chr(156) => 944,
chr(157) => 350,
chr(158) => 500,
chr(159) => 667,
chr(160) => 278,
chr(161) => 333,
chr(162) => 556,
chr(163) => 556,
chr(164) => 556,
chr(165) => 556,
chr(166) => 280,
chr(167) => 556,
chr(168) => 333,
chr(169) => 737,
chr(170) => 370,
chr(171) => 556,
chr(172) => 584,
chr(173) => 333,
chr(174) => 737,
chr(175) => 333,
chr(176) => 400,
chr(177) => 584,
chr(178) => 333,
chr(179) => 333,
chr(180) => 333,
chr(181) => 611,
chr(182) => 556,
chr(183) => 278,
chr(184) => 333,
chr(185) => 333,
chr(186) => 365,
chr(187) => 556,
chr(188) => 834,
chr(189) => 834,
chr(190) => 834,
chr(191) => 611,
chr(192) => 722,
chr(193) => 722,
chr(194) => 722,
chr(195) => 722,
chr(196) => 722,
chr(197) => 722,
chr(198) => 1000,
chr(199) => 722,
chr(200) => 667,
chr(201) => 667,
chr(202) => 667,
chr(203) => 667,
chr(204) => 278,
chr(205) => 278,
chr(206) => 278,
chr(207) => 278,
chr(208) => 722,
chr(209) => 722,
chr(210) => 778,
chr(211) => 778,
chr(212) => 778,
chr(213) => 778,
chr(214) => 778,
chr(215) => 584,
chr(216) => 778,
chr(217) => 722,
chr(218) => 722,
chr(219) => 722,
chr(220) => 722,
chr(221) => 667,
chr(222) => 667,
chr(223) => 611,
chr(224) => 556,
chr(225) => 556,
chr(226) => 556,
chr(227) => 556,
chr(228) => 556,
chr(229) => 556,
chr(230) => 889,
chr(231) => 556,
chr(232) => 556,
chr(233) => 556,
chr(234) => 556,
chr(235) => 556,
chr(236) => 278,
chr(237) => 278,
chr(238) => 278,
chr(239) => 278,
chr(240) => 611,
chr(241) => 611,
chr(242) => 611,
chr(243) => 611,
chr(244) => 611,
chr(245) => 611,
chr(246) => 611,
chr(247) => 584,
chr(248) => 611,
chr(249) => 611,
chr(250) => 611,
chr(251) => 611,
chr(252) => 611,
chr(253) => 556,
chr(254) => 611,
chr(255) => 556);
/tags/v3.1-blanche-neige/jrest/lib/File/PDF/fonts/times.php
New file
0,0 → 1,272
<?php
/**
* @package File_PDF
*/
$font_widths['times'] = array(
chr(0) => 250,
chr(1) => 250,
chr(2) => 250,
chr(3) => 250,
chr(4) => 250,
chr(5) => 250,
chr(6) => 250,
chr(7) => 250,
chr(8) => 250,
chr(9) => 250,
chr(10) => 250,
chr(11) => 250,
chr(12) => 250,
chr(13) => 250,
chr(14) => 250,
chr(15) => 250,
chr(16) => 250,
chr(17) => 250,
chr(18) => 250,
chr(19) => 250,
chr(20) => 250,
chr(21) => 250,
chr(22) => 250,
chr(23) => 250,
chr(24) => 250,
chr(25) => 250,
chr(26) => 250,
chr(27) => 250,
chr(28) => 250,
chr(29) => 250,
chr(30) => 250,
chr(31) => 250,
' ' => 250,
'!' => 333,
'"' => 408,
'#' => 500,
'$' => 500,
'%' => 833,
'&' => 778,
'\'' => 180,
'(' => 333,
')' => 333,
'*' => 500,
'+' => 564,
',' => 250,
'-' => 333,
'.' => 250,
'/' => 278,
'0' => 500,
'1' => 500,
'2' => 500,
'3' => 500,
'4' => 500,
'5' => 500,
'6' => 500,
'7' => 500,
'8' => 500,
'9' => 500,
':' => 278,
';' => 278,
'<' => 564,
'=' => 564,
'>' => 564,
'?' => 444,
'@' => 921,
'A' => 722,
'B' => 667,
'C' => 667,
'D' => 722,
'E' => 611,
'F' => 556,
'G' => 722,
'H' => 722,
'I' => 333,
'J' => 389,
'K' => 722,
'L' => 611,
'M' => 889,
'N' => 722,
'O' => 722,
'P' => 556,
'Q' => 722,
'R' => 667,
'S' => 556,
'T' => 611,
'U' => 722,
'V' => 722,
'W' => 944,
'X' => 722,
'Y' => 722,
'Z' => 611,
'[' => 333,
'\\' => 278,
']' => 333,
'^' => 469,
'_' => 500,
'`' => 333,
'a' => 444,
'b' => 500,
'c' => 444,
'd' => 500,
'e' => 444,
'f' => 333,
'g' => 500,
'h' => 500,
'i' => 278,
'j' => 278,
'k' => 500,
'l' => 278,
'm' => 778,
'n' => 500,
'o' => 500,
'p' => 500,
'q' => 500,
'r' => 333,
's' => 389,
't' => 278,
'u' => 500,
'v' => 500,
'w' => 722,
'x' => 500,
'y' => 500,
'z' => 444,
'{' => 480,
'|' => 200,
'}' => 480,
'~' => 541,
chr(127) => 350,
chr(128) => 500,
chr(129) => 350,
chr(130) => 333,
chr(131) => 500,
chr(132) => 444,
chr(133) => 1000,
chr(134) => 500,
chr(135) => 500,
chr(136) => 333,
chr(137) => 1000,
chr(138) => 556,
chr(139) => 333,
chr(140) => 889,
chr(141) => 350,
chr(142) => 611,
chr(143) => 350,
chr(144) => 350,
chr(145) => 333,
chr(146) => 333,
chr(147) => 444,
chr(148) => 444,
chr(149) => 350,
chr(150) => 500,
chr(151) => 1000,
chr(152) => 333,
chr(153) => 980,
chr(154) => 389,
chr(155) => 333,
chr(156) => 722,
chr(157) => 350,
chr(158) => 444,
chr(159) => 722,
chr(160) => 250,
chr(161) => 333,
chr(162) => 500,
chr(163) => 500,
chr(164) => 500,
chr(165) => 500,
chr(166) => 200,
chr(167) => 500,
chr(168) => 333,
chr(169) => 760,
chr(170) => 276,
chr(171) => 500,
chr(172) => 564,
chr(173) => 333,
chr(174) => 760,
chr(175) => 333,
chr(176) => 400,
chr(177) => 564,
chr(178) => 300,
chr(179) => 300,
chr(180) => 333,
chr(181) => 500,
chr(182) => 453,
chr(183) => 250,
chr(184) => 333,
chr(185) => 300,
chr(186) => 310,
chr(187) => 500,
chr(188) => 750,
chr(189) => 750,
chr(190) => 750,
chr(191) => 444,
chr(192) => 722,
chr(193) => 722,
chr(194) => 722,
chr(195) => 722,
chr(196) => 722,
chr(197) => 722,
chr(198) => 889,
chr(199) => 667,
chr(200) => 611,
chr(201) => 611,
chr(202) => 611,
chr(203) => 611,
chr(204) => 333,
chr(205) => 333,
chr(206) => 333,
chr(207) => 333,
chr(208) => 722,
chr(209) => 722,
chr(210) => 722,
chr(211) => 722,
chr(212) => 722,
chr(213) => 722,
chr(214) => 722,
chr(215) => 564,
chr(216) => 722,
chr(217) => 722,
chr(218) => 722,
chr(219) => 722,
chr(220) => 722,
chr(221) => 722,
chr(222) => 556,
chr(223) => 500,
chr(224) => 444,
chr(225) => 444,
chr(226) => 444,
chr(227) => 444,
chr(228) => 444,
chr(229) => 444,
chr(230) => 667,
chr(231) => 444,
chr(232) => 444,
chr(233) => 444,
chr(234) => 444,
chr(235) => 444,
chr(236) => 278,
chr(237) => 278,
chr(238) => 278,
chr(239) => 278,
chr(240) => 500,
chr(241) => 500,
chr(242) => 500,
chr(243) => 500,
chr(244) => 500,
chr(245) => 500,
chr(246) => 500,
chr(247) => 564,
chr(248) => 500,
chr(249) => 500,
chr(250) => 500,
chr(251) => 500,
chr(252) => 500,
chr(253) => 500,
chr(254) => 500,
chr(255) => 500);
/tags/v3.1-blanche-neige/jrest/lib/File/PDF/fonts/timesb.php
New file
0,0 → 1,272
<?php
/**
* @package File_PDF
*/
$font_widths['timesB'] = array(
chr(0) => 250,
chr(1) => 250,
chr(2) => 250,
chr(3) => 250,
chr(4) => 250,
chr(5) => 250,
chr(6) => 250,
chr(7) => 250,
chr(8) => 250,
chr(9) => 250,
chr(10) => 250,
chr(11) => 250,
chr(12) => 250,
chr(13) => 250,
chr(14) => 250,
chr(15) => 250,
chr(16) => 250,
chr(17) => 250,
chr(18) => 250,
chr(19) => 250,
chr(20) => 250,
chr(21) => 250,
chr(22) => 250,
chr(23) => 250,
chr(24) => 250,
chr(25) => 250,
chr(26) => 250,
chr(27) => 250,
chr(28) => 250,
chr(29) => 250,
chr(30) => 250,
chr(31) => 250,
' ' => 250,
'!' => 333,
'"' => 555,
'#' => 500,
'$' => 500,
'%' => 1000,
'&' => 833,
'\'' => 278,
'(' => 333,
')' => 333,
'*' => 500,
'+' => 570,
',' => 250,
'-' => 333,
'.' => 250,
'/' => 278,
'0' => 500,
'1' => 500,
'2' => 500,
'3' => 500,
'4' => 500,
'5' => 500,
'6' => 500,
'7' => 500,
'8' => 500,
'9' => 500,
':' => 333,
';' => 333,
'<' => 570,
'=' => 570,
'>' => 570,
'?' => 500,
'@' => 930,
'A' => 722,
'B' => 667,
'C' => 722,
'D' => 722,
'E' => 667,
'F' => 611,
'G' => 778,
'H' => 778,
'I' => 389,
'J' => 500,
'K' => 778,
'L' => 667,
'M' => 944,
'N' => 722,
'O' => 778,
'P' => 611,
'Q' => 778,
'R' => 722,
'S' => 556,
'T' => 667,
'U' => 722,
'V' => 722,
'W' => 1000,
'X' => 722,
'Y' => 722,
'Z' => 667,
'[' => 333,
'\\' => 278,
']' => 333,
'^' => 581,
'_' => 500,
'`' => 333,
'a' => 500,
'b' => 556,
'c' => 444,
'd' => 556,
'e' => 444,
'f' => 333,
'g' => 500,
'h' => 556,
'i' => 278,
'j' => 333,
'k' => 556,
'l' => 278,
'm' => 833,
'n' => 556,
'o' => 500,
'p' => 556,
'q' => 556,
'r' => 444,
's' => 389,
't' => 333,
'u' => 556,
'v' => 500,
'w' => 722,
'x' => 500,
'y' => 500,
'z' => 444,
'{' => 394,
'|' => 220,
'}' => 394,
'~' => 520,
chr(127) => 350,
chr(128) => 500,
chr(129) => 350,
chr(130) => 333,
chr(131) => 500,
chr(132) => 500,
chr(133) => 1000,
chr(134) => 500,
chr(135) => 500,
chr(136) => 333,
chr(137) => 1000,
chr(138) => 556,
chr(139) => 333,
chr(140) => 1000,
chr(141) => 350,
chr(142) => 667,
chr(143) => 350,
chr(144) => 350,
chr(145) => 333,
chr(146) => 333,
chr(147) => 500,
chr(148) => 500,
chr(149) => 350,
chr(150) => 500,
chr(151) => 1000,
chr(152) => 333,
chr(153) => 1000,
chr(154) => 389,
chr(155) => 333,
chr(156) => 722,
chr(157) => 350,
chr(158) => 444,
chr(159) => 722,
chr(160) => 250,
chr(161) => 333,
chr(162) => 500,
chr(163) => 500,
chr(164) => 500,
chr(165) => 500,
chr(166) => 220,
chr(167) => 500,
chr(168) => 333,
chr(169) => 747,
chr(170) => 300,
chr(171) => 500,
chr(172) => 570,
chr(173) => 333,
chr(174) => 747,
chr(175) => 333,
chr(176) => 400,
chr(177) => 570,
chr(178) => 300,
chr(179) => 300,
chr(180) => 333,
chr(181) => 556,
chr(182) => 540,
chr(183) => 250,
chr(184) => 333,
chr(185) => 300,
chr(186) => 330,
chr(187) => 500,
chr(188) => 750,
chr(189) => 750,
chr(190) => 750,
chr(191) => 500,
chr(192) => 722,
chr(193) => 722,
chr(194) => 722,
chr(195) => 722,
chr(196) => 722,
chr(197) => 722,
chr(198) => 1000,
chr(199) => 722,
chr(200) => 667,
chr(201) => 667,
chr(202) => 667,
chr(203) => 667,
chr(204) => 389,
chr(205) => 389,
chr(206) => 389,
chr(207) => 389,
chr(208) => 722,
chr(209) => 722,
chr(210) => 778,
chr(211) => 778,
chr(212) => 778,
chr(213) => 778,
chr(214) => 778,
chr(215) => 570,
chr(216) => 778,
chr(217) => 722,
chr(218) => 722,
chr(219) => 722,
chr(220) => 722,
chr(221) => 722,
chr(222) => 611,
chr(223) => 556,
chr(224) => 500,
chr(225) => 500,
chr(226) => 500,
chr(227) => 500,
chr(228) => 500,
chr(229) => 500,
chr(230) => 722,
chr(231) => 444,
chr(232) => 444,
chr(233) => 444,
chr(234) => 444,
chr(235) => 444,
chr(236) => 278,
chr(237) => 278,
chr(238) => 278,
chr(239) => 278,
chr(240) => 500,
chr(241) => 556,
chr(242) => 500,
chr(243) => 500,
chr(244) => 500,
chr(245) => 500,
chr(246) => 500,
chr(247) => 570,
chr(248) => 500,
chr(249) => 556,
chr(250) => 556,
chr(251) => 556,
chr(252) => 556,
chr(253) => 500,
chr(254) => 556,
chr(255) => 500);
/tags/v3.1-blanche-neige/jrest/lib/File/PDF/fonts/helvetica.php
New file
0,0 → 1,272
<?php
/**
* @package File_PDF
*/
$font_widths['helvetica'] = array(
chr(0) => 278,
chr(1) => 278,
chr(2) => 278,
chr(3) => 278,
chr(4) => 278,
chr(5) => 278,
chr(6) => 278,
chr(7) => 278,
chr(8) => 278,
chr(9) => 278,
chr(10) => 278,
chr(11) => 278,
chr(12) => 278,
chr(13) => 278,
chr(14) => 278,
chr(15) => 278,
chr(16) => 278,
chr(17) => 278,
chr(18) => 278,
chr(19) => 278,
chr(20) => 278,
chr(21) => 278,
chr(22) => 278,
chr(23) => 278,
chr(24) => 278,
chr(25) => 278,
chr(26) => 278,
chr(27) => 278,
chr(28) => 278,
chr(29) => 278,
chr(30) => 278,
chr(31) => 278,
' ' => 278,
'!' => 278,
'"' => 355,
'#' => 556,
'$' => 556,
'%' => 889,
'&' => 667,
'\'' => 191,
'(' => 333,
')' => 333,
'*' => 389,
'+' => 584,
',' => 278,
'-' => 333,
'.' => 278,
'/' => 278,
'0' => 556,
'1' => 556,
'2' => 556,
'3' => 556,
'4' => 556,
'5' => 556,
'6' => 556,
'7' => 556,
'8' => 556,
'9' => 556,
':' => 278,
';' => 278,
'<' => 584,
'=' => 584,
'>' => 584,
'?' => 556,
'@' => 1015,
'A' => 667,
'B' => 667,
'C' => 722,
'D' => 722,
'E' => 667,
'F' => 611,
'G' => 778,
'H' => 722,
'I' => 278,
'J' => 500,
'K' => 667,
'L' => 556,
'M' => 833,
'N' => 722,
'O' => 778,
'P' => 667,
'Q' => 778,
'R' => 722,
'S' => 667,
'T' => 611,
'U' => 722,
'V' => 667,
'W' => 944,
'X' => 667,
'Y' => 667,
'Z' => 611,
'[' => 278,
'\\' => 278,
']' => 278,
'^' => 469,
'_' => 556,
'`' => 333,
'a' => 556,
'b' => 556,
'c' => 500,
'd' => 556,
'e' => 556,
'f' => 278,
'g' => 556,
'h' => 556,
'i' => 222,
'j' => 222,
'k' => 500,
'l' => 222,
'm' => 833,
'n' => 556,
'o' => 556,
'p' => 556,
'q' => 556,
'r' => 333,
's' => 500,
't' => 278,
'u' => 556,
'v' => 500,
'w' => 722,
'x' => 500,
'y' => 500,
'z' => 500,
'{' => 334,
'|' => 260,
'}' => 334,
'~' => 584,
chr(127) => 350,
chr(128) => 556,
chr(129) => 350,
chr(130) => 222,
chr(131) => 556,
chr(132) => 333,
chr(133) => 1000,
chr(134) => 556,
chr(135) => 556,
chr(136) => 333,
chr(137) => 1000,
chr(138) => 667,
chr(139) => 333,
chr(140) => 1000,
chr(141) => 350,
chr(142) => 611,
chr(143) => 350,
chr(144) => 350,
chr(145) => 222,
chr(146) => 222,
chr(147) => 333,
chr(148) => 333,
chr(149) => 350,
chr(150) => 556,
chr(151) => 1000,
chr(152) => 333,
chr(153) => 1000,
chr(154) => 500,
chr(155) => 333,
chr(156) => 944,
chr(157) => 350,
chr(158) => 500,
chr(159) => 667,
chr(160) => 278,
chr(161) => 333,
chr(162) => 556,
chr(163) => 556,
chr(164) => 556,
chr(165) => 556,
chr(166) => 260,
chr(167) => 556,
chr(168) => 333,
chr(169) => 737,
chr(170) => 370,
chr(171) => 556,
chr(172) => 584,
chr(173) => 333,
chr(174) => 737,
chr(175) => 333,
chr(176) => 400,
chr(177) => 584,
chr(178) => 333,
chr(179) => 333,
chr(180) => 333,
chr(181) => 556,
chr(182) => 537,
chr(183) => 278,
chr(184) => 333,
chr(185) => 333,
chr(186) => 365,
chr(187) => 556,
chr(188) => 834,
chr(189) => 834,
chr(190) => 834,
chr(191) => 611,
chr(192) => 667,
chr(193) => 667,
chr(194) => 667,
chr(195) => 667,
chr(196) => 667,
chr(197) => 667,
chr(198) => 1000,
chr(199) => 722,
chr(200) => 667,
chr(201) => 667,
chr(202) => 667,
chr(203) => 667,
chr(204) => 278,
chr(205) => 278,
chr(206) => 278,
chr(207) => 278,
chr(208) => 722,
chr(209) => 722,
chr(210) => 778,
chr(211) => 778,
chr(212) => 778,
chr(213) => 778,
chr(214) => 778,
chr(215) => 584,
chr(216) => 778,
chr(217) => 722,
chr(218) => 722,
chr(219) => 722,
chr(220) => 722,
chr(221) => 667,
chr(222) => 667,
chr(223) => 611,
chr(224) => 556,
chr(225) => 556,
chr(226) => 556,
chr(227) => 556,
chr(228) => 556,
chr(229) => 556,
chr(230) => 889,
chr(231) => 500,
chr(232) => 556,
chr(233) => 556,
chr(234) => 556,
chr(235) => 556,
chr(236) => 278,
chr(237) => 278,
chr(238) => 278,
chr(239) => 278,
chr(240) => 556,
chr(241) => 556,
chr(242) => 556,
chr(243) => 556,
chr(244) => 556,
chr(245) => 556,
chr(246) => 556,
chr(247) => 584,
chr(248) => 611,
chr(249) => 556,
chr(250) => 556,
chr(251) => 556,
chr(252) => 556,
chr(253) => 500,
chr(254) => 556,
chr(255) => 500);
/tags/v3.1-blanche-neige/jrest/lib/File/PDF/fonts/symbol.php
New file
0,0 → 1,272
<?php
/**
* @package File_PDF
*/
$font_widths['symbol'] = array(
chr(0) => 250,
chr(1) => 250,
chr(2) => 250,
chr(3) => 250,
chr(4) => 250,
chr(5) => 250,
chr(6) => 250,
chr(7) => 250,
chr(8) => 250,
chr(9) => 250,
chr(10) => 250,
chr(11) => 250,
chr(12) => 250,
chr(13) => 250,
chr(14) => 250,
chr(15) => 250,
chr(16) => 250,
chr(17) => 250,
chr(18) => 250,
chr(19) => 250,
chr(20) => 250,
chr(21) => 250,
chr(22) => 250,
chr(23) => 250,
chr(24) => 250,
chr(25) => 250,
chr(26) => 250,
chr(27) => 250,
chr(28) => 250,
chr(29) => 250,
chr(30) => 250,
chr(31) => 250,
' ' => 250,
'!' => 333,
'"' => 713,
'#' => 500,
'$' => 549,
'%' => 833,
'&' => 778,
'\'' => 439,
'(' => 333,
')' => 333,
'*' => 500,
'+' => 549,
',' => 250,
'-' => 549,
'.' => 250,
'/' => 278,
'0' => 500,
'1' => 500,
'2' => 500,
'3' => 500,
'4' => 500,
'5' => 500,
'6' => 500,
'7' => 500,
'8' => 500,
'9' => 500,
':' => 278,
';' => 278,
'<' => 549,
'=' => 549,
'>' => 549,
'?' => 444,
'@' => 549,
'A' => 722,
'B' => 667,
'C' => 722,
'D' => 612,
'E' => 611,
'F' => 763,
'G' => 603,
'H' => 722,
'I' => 333,
'J' => 631,
'K' => 722,
'L' => 686,
'M' => 889,
'N' => 722,
'O' => 722,
'P' => 768,
'Q' => 741,
'R' => 556,
'S' => 592,
'T' => 611,
'U' => 690,
'V' => 439,
'W' => 768,
'X' => 645,
'Y' => 795,
'Z' => 611,
'[' => 333,
'\\' => 863,
']' => 333,
'^' => 658,
'_' => 500,
'`' => 500,
'a' => 631,
'b' => 549,
'c' => 549,
'd' => 494,
'e' => 439,
'f' => 521,
'g' => 411,
'h' => 603,
'i' => 329,
'j' => 603,
'k' => 549,
'l' => 549,
'm' => 576,
'n' => 521,
'o' => 549,
'p' => 549,
'q' => 521,
'r' => 549,
's' => 603,
't' => 439,
'u' => 576,
'v' => 713,
'w' => 686,
'x' => 493,
'y' => 686,
'z' => 494,
'{' => 480,
'|' => 200,
'}' => 480,
'~' => 549,
chr(127) => 0,
chr(128) => 0,
chr(129) => 0,
chr(130) => 0,
chr(131) => 0,
chr(132) => 0,
chr(133) => 0,
chr(134) => 0,
chr(135) => 0,
chr(136) => 0,
chr(137) => 0,
chr(138) => 0,
chr(139) => 0,
chr(140) => 0,
chr(141) => 0,
chr(142) => 0,
chr(143) => 0,
chr(144) => 0,
chr(145) => 0,
chr(146) => 0,
chr(147) => 0,
chr(148) => 0,
chr(149) => 0,
chr(150) => 0,
chr(151) => 0,
chr(152) => 0,
chr(153) => 0,
chr(154) => 0,
chr(155) => 0,
chr(156) => 0,
chr(157) => 0,
chr(158) => 0,
chr(159) => 0,
chr(160) => 750,
chr(161) => 620,
chr(162) => 247,
chr(163) => 549,
chr(164) => 167,
chr(165) => 713,
chr(166) => 500,
chr(167) => 753,
chr(168) => 753,
chr(169) => 753,
chr(170) => 753,
chr(171) => 1042,
chr(172) => 987,
chr(173) => 603,
chr(174) => 987,
chr(175) => 603,
chr(176) => 400,
chr(177) => 549,
chr(178) => 411,
chr(179) => 549,
chr(180) => 549,
chr(181) => 713,
chr(182) => 494,
chr(183) => 460,
chr(184) => 549,
chr(185) => 549,
chr(186) => 549,
chr(187) => 549,
chr(188) => 1000,
chr(189) => 603,
chr(190) => 1000,
chr(191) => 658,
chr(192) => 823,
chr(193) => 686,
chr(194) => 795,
chr(195) => 987,
chr(196) => 768,
chr(197) => 768,
chr(198) => 823,
chr(199) => 768,
chr(200) => 768,
chr(201) => 713,
chr(202) => 713,
chr(203) => 713,
chr(204) => 713,
chr(205) => 713,
chr(206) => 713,
chr(207) => 713,
chr(208) => 768,
chr(209) => 713,
chr(210) => 790,
chr(211) => 790,
chr(212) => 890,
chr(213) => 823,
chr(214) => 549,
chr(215) => 250,
chr(216) => 713,
chr(217) => 603,
chr(218) => 603,
chr(219) => 1042,
chr(220) => 987,
chr(221) => 603,
chr(222) => 987,
chr(223) => 603,
chr(224) => 494,
chr(225) => 329,
chr(226) => 790,
chr(227) => 790,
chr(228) => 786,
chr(229) => 713,
chr(230) => 384,
chr(231) => 384,
chr(232) => 384,
chr(233) => 384,
chr(234) => 384,
chr(235) => 384,
chr(236) => 494,
chr(237) => 494,
chr(238) => 494,
chr(239) => 494,
chr(240) => 0,
chr(241) => 329,
chr(242) => 274,
chr(243) => 686,
chr(244) => 686,
chr(245) => 686,
chr(246) => 384,
chr(247) => 384,
chr(248) => 384,
chr(249) => 384,
chr(250) => 384,
chr(251) => 384,
chr(252) => 494,
chr(253) => 494,
chr(254) => 494,
chr(255) => 0);
/tags/v3.1-blanche-neige/jrest/lib/File/PDF/fonts/helveticab.php
New file
0,0 → 1,272
<?php
/**
* @package File_PDF
*/
$font_widths['helveticaB'] = array(
chr(0) => 278,
chr(1) => 278,
chr(2) => 278,
chr(3) => 278,
chr(4) => 278,
chr(5) => 278,
chr(6) => 278,
chr(7) => 278,
chr(8) => 278,
chr(9) => 278,
chr(10) => 278,
chr(11) => 278,
chr(12) => 278,
chr(13) => 278,
chr(14) => 278,
chr(15) => 278,
chr(16) => 278,
chr(17) => 278,
chr(18) => 278,
chr(19) => 278,
chr(20) => 278,
chr(21) => 278,
chr(22) => 278,
chr(23) => 278,
chr(24) => 278,
chr(25) => 278,
chr(26) => 278,
chr(27) => 278,
chr(28) => 278,
chr(29) => 278,
chr(30) => 278,
chr(31) => 278,
' ' => 278,
'!' => 333,
'"' => 474,
'#' => 556,
'$' => 556,
'%' => 889,
'&' => 722,
'\'' => 238,
'(' => 333,
')' => 333,
'*' => 389,
'+' => 584,
',' => 278,
'-' => 333,
'.' => 278,
'/' => 278,
'0' => 556,
'1' => 556,
'2' => 556,
'3' => 556,
'4' => 556,
'5' => 556,
'6' => 556,
'7' => 556,
'8' => 556,
'9' => 556,
':' => 333,
';' => 333,
'<' => 584,
'=' => 584,
'>' => 584,
'?' => 611,
'@' => 975,
'A' => 722,
'B' => 722,
'C' => 722,
'D' => 722,
'E' => 667,
'F' => 611,
'G' => 778,
'H' => 722,
'I' => 278,
'J' => 556,
'K' => 722,
'L' => 611,
'M' => 833,
'N' => 722,
'O' => 778,
'P' => 667,
'Q' => 778,
'R' => 722,
'S' => 667,
'T' => 611,
'U' => 722,
'V' => 667,
'W' => 944,
'X' => 667,
'Y' => 667,
'Z' => 611,
'[' => 333,
'\\' => 278,
']' => 333,
'^' => 584,
'_' => 556,
'`' => 333,
'a' => 556,
'b' => 611,
'c' => 556,
'd' => 611,
'e' => 556,
'f' => 333,
'g' => 611,
'h' => 611,
'i' => 278,
'j' => 278,
'k' => 556,
'l' => 278,
'm' => 889,
'n' => 611,
'o' => 611,
'p' => 611,
'q' => 611,
'r' => 389,
's' => 556,
't' => 333,
'u' => 611,
'v' => 556,
'w' => 778,
'x' => 556,
'y' => 556,
'z' => 500,
'{' => 389,
'|' => 280,
'}' => 389,
'~' => 584,
chr(127) => 350,
chr(128) => 556,
chr(129) => 350,
chr(130) => 278,
chr(131) => 556,
chr(132) => 500,
chr(133) => 1000,
chr(134) => 556,
chr(135) => 556,
chr(136) => 333,
chr(137) => 1000,
chr(138) => 667,
chr(139) => 333,
chr(140) => 1000,
chr(141) => 350,
chr(142) => 611,
chr(143) => 350,
chr(144) => 350,
chr(145) => 278,
chr(146) => 278,
chr(147) => 500,
chr(148) => 500,
chr(149) => 350,
chr(150) => 556,
chr(151) => 1000,
chr(152) => 333,
chr(153) => 1000,
chr(154) => 556,
chr(155) => 333,
chr(156) => 944,
chr(157) => 350,
chr(158) => 500,
chr(159) => 667,
chr(160) => 278,
chr(161) => 333,
chr(162) => 556,
chr(163) => 556,
chr(164) => 556,
chr(165) => 556,
chr(166) => 280,
chr(167) => 556,
chr(168) => 333,
chr(169) => 737,
chr(170) => 370,
chr(171) => 556,
chr(172) => 584,
chr(173) => 333,
chr(174) => 737,
chr(175) => 333,
chr(176) => 400,
chr(177) => 584,
chr(178) => 333,
chr(179) => 333,
chr(180) => 333,
chr(181) => 611,
chr(182) => 556,
chr(183) => 278,
chr(184) => 333,
chr(185) => 333,
chr(186) => 365,
chr(187) => 556,
chr(188) => 834,
chr(189) => 834,
chr(190) => 834,
chr(191) => 611,
chr(192) => 722,
chr(193) => 722,
chr(194) => 722,
chr(195) => 722,
chr(196) => 722,
chr(197) => 722,
chr(198) => 1000,
chr(199) => 722,
chr(200) => 667,
chr(201) => 667,
chr(202) => 667,
chr(203) => 667,
chr(204) => 278,
chr(205) => 278,
chr(206) => 278,
chr(207) => 278,
chr(208) => 722,
chr(209) => 722,
chr(210) => 778,
chr(211) => 778,
chr(212) => 778,
chr(213) => 778,
chr(214) => 778,
chr(215) => 584,
chr(216) => 778,
chr(217) => 722,
chr(218) => 722,
chr(219) => 722,
chr(220) => 722,
chr(221) => 667,
chr(222) => 667,
chr(223) => 611,
chr(224) => 556,
chr(225) => 556,
chr(226) => 556,
chr(227) => 556,
chr(228) => 556,
chr(229) => 556,
chr(230) => 889,
chr(231) => 556,
chr(232) => 556,
chr(233) => 556,
chr(234) => 556,
chr(235) => 556,
chr(236) => 278,
chr(237) => 278,
chr(238) => 278,
chr(239) => 278,
chr(240) => 611,
chr(241) => 611,
chr(242) => 611,
chr(243) => 611,
chr(244) => 611,
chr(245) => 611,
chr(246) => 611,
chr(247) => 584,
chr(248) => 611,
chr(249) => 611,
chr(250) => 611,
chr(251) => 611,
chr(252) => 611,
chr(253) => 556,
chr(254) => 611,
chr(255) => 556);
/tags/v3.1-blanche-neige/jrest/lib/HTTP/HTTP/Header.php
New file
0,0 → 1,531
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
 
/**
* HTTP::Header
*
* PHP versions 4 and 5
*
* @category HTTP
* @package HTTP_Header
* @author Wolfram Kriesing <wk@visionp.de>
* @author Davey Shafik <davey@php.net>
* @author Michael Wallner <mike@php.net>
* @copyright 2003-2005 The Authors
* @license BSD, revised
* @version CVS: $Id$
* @link http://pear.php.net/package/HTTP_Header
*/
 
/**
* Requires HTTP
*/
require_once 'HTTP.php';
 
/**#@+
* Information Codes
*/
define('HTTP_HEADER_STATUS_100', '100 Continue');
define('HTTP_HEADER_STATUS_101', '101 Switching Protocols');
define('HTTP_HEADER_STATUS_102', '102 Processing');
define('HTTP_HEADER_STATUS_INFORMATIONAL',1);
/**#@-*/
 
/**#+
* Success Codes
*/
define('HTTP_HEADER_STATUS_200', '200 OK');
define('HTTP_HEADER_STATUS_201', '201 Created');
define('HTTP_HEADER_STATUS_202', '202 Accepted');
define('HTTP_HEADER_STATUS_203', '203 Non-Authoritative Information');
define('HTTP_HEADER_STATUS_204', '204 No Content');
define('HTTP_HEADER_STATUS_205', '205 Reset Content');
define('HTTP_HEADER_STATUS_206', '206 Partial Content');
define('HTTP_HEADER_STATUS_207', '207 Multi-Status');
define('HTTP_HEADER_STATUS_SUCCESSFUL',2);
/**#@-*/
 
/**#@+
* Redirection Codes
*/
define('HTTP_HEADER_STATUS_300', '300 Multiple Choices');
define('HTTP_HEADER_STATUS_301', '301 Moved Permanently');
define('HTTP_HEADER_STATUS_302', '302 Found');
define('HTTP_HEADER_STATUS_303', '303 See Other');
define('HTTP_HEADER_STATUS_304', '304 Not Modified');
define('HTTP_HEADER_STATUS_305', '305 Use Proxy');
define('HTTP_HEADER_STATUS_306', '306 (Unused)');
define('HTTP_HEADER_STATUS_307', '307 Temporary Redirect');
define('HTTP_HEADER_STATUS_REDIRECT',3);
/**#@-*/
 
/**#@+
* Error Codes
*/
define('HTTP_HEADER_STATUS_400', '400 Bad Request');
define('HTTP_HEADER_STATUS_401', '401 Unauthorized');
define('HTTP_HEADER_STATUS_402', '402 Payment Granted');
define('HTTP_HEADER_STATUS_403', '403 Forbidden');
define('HTTP_HEADER_STATUS_404', '404 File Not Found');
define('HTTP_HEADER_STATUS_405', '405 Method Not Allowed');
define('HTTP_HEADER_STATUS_406', '406 Not Acceptable');
define('HTTP_HEADER_STATUS_407', '407 Proxy Authentication Required');
define('HTTP_HEADER_STATUS_408', '408 Request Time-out');
define('HTTP_HEADER_STATUS_409', '409 Conflict');
define('HTTP_HEADER_STATUS_410', '410 Gone');
define('HTTP_HEADER_STATUS_411', '411 Length Required');
define('HTTP_HEADER_STATUS_412', '412 Precondition Failed');
define('HTTP_HEADER_STATUS_413', '413 Request Entity Too Large');
define('HTTP_HEADER_STATUS_414', '414 Request-URI Too Large');
define('HTTP_HEADER_STATUS_415', '415 Unsupported Media Type');
define('HTTP_HEADER_STATUS_416', '416 Requested range not satisfiable');
define('HTTP_HEADER_STATUS_417', '417 Expectation Failed');
define('HTTP_HEADER_STATUS_422', '422 Unprocessable Entity');
define('HTTP_HEADER_STATUS_423', '423 Locked');
define('HTTP_HEADER_STATUS_424', '424 Failed Dependency');
define('HTTP_HEADER_STATUS_CLIENT_ERROR',4);
/**#@-*/
 
/**#@+
* Server Errors
*/
define('HTTP_HEADER_STATUS_500', '500 Internal Server Error');
define('HTTP_HEADER_STATUS_501', '501 Not Implemented');
define('HTTP_HEADER_STATUS_502', '502 Bad Gateway');
define('HTTP_HEADER_STATUS_503', '503 Service Unavailable');
define('HTTP_HEADER_STATUS_504', '504 Gateway Time-out');
define('HTTP_HEADER_STATUS_505', '505 HTTP Version not supported');
define('HTTP_HEADER_STATUS_507', '507 Insufficient Storage');
define('HTTP_HEADER_STATUS_SERVER_ERROR',5);
/**#@-*/
 
/**
* HTTP_Header
*
* @package HTTP_Header
* @category HTTP
* @access public
* @version $Revision$
*/
class HTTP_Header extends HTTP
{
/**
* Default Headers
*
* The values that are set as default, are the same as PHP sends by default.
*
* @var array
* @access private
*/
var $_headers = array(
'content-type' => 'text/html',
'pragma' => 'no-cache',
'cache-control' => 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0'
);
 
/**
* HTTP version
*
* @var string
* @access private
*/
var $_httpVersion = '1.0';
 
/**
* Constructor
*
* Sets HTTP version.
*
* @access public
* @return object HTTP_Header
*/
function HTTP_Header()
{
if (isset($_SERVER['SERVER_PROTOCOL'])) {
$this->setHttpVersion(substr($_SERVER['SERVER_PROTOCOL'], -3));
}
}
/**
* Set HTTP version
*
* @access public
* @return bool Returns true on success or false if version doesn't
* match 1.0 or 1.1 (note: 1 will result in 1.0)
* @param mixed $version HTTP version, either 1.0 or 1.1
*/
function setHttpVersion($version)
{
$version = round((float) $version, 1);
if ($version < 1.0 || $version > 1.1) {
return false;
}
$this->_httpVersion = sprintf('%0.1f', $version);
return true;
}
/**
* Get HTTP version
*
* @access public
* @return string
*/
function getHttpVersion()
{
return $this->_httpVersion;
}
/**
* Set Header
*
* The default value for the Last-Modified header will be current
* date and atime if $value is omitted.
*
* @access public
* @return bool Returns true on success or false if $key was empty or
* $value was not of an scalar type.
* @param string $key The name of the header.
* @param string $value The value of the header. (NULL to unset header)
*/
function setHeader($key, $value = null)
{
if (empty($key) || (isset($value) && !is_scalar($value))) {
return false;
}
$key = strToLower($key);
if ($key == 'last-modified') {
if (!isset($value)) {
$value = HTTP::Date(time());
} elseif (is_numeric($value)) {
$value = HTTP::Date($value);
}
}
if (isset($value)) {
$this->_headers[$key] = $value;
} else {
unset($this->_headers[$key]);
}
return true;
}
 
/**
* Get Header
*
* If $key is omitted, all stored headers will be returned.
*
* @access public
* @return mixed Returns string value of the requested header,
* array values of all headers or false if header $key
* is not set.
* @param string $key The name of the header to fetch.
*/
function getHeader($key = null)
{
if (!isset($key)) {
return $this->_headers;
}
$key = strToLower($key);
if (!isset($this->_headers[$key])) {
return false;
}
return $this->_headers[$key];
}
 
/**
* Send Headers
*
* Send out the header that you set via setHeader().
*
* @access public
* @return bool Returns true on success or false if headers are already
* sent.
* @param array $keys Headers to (not) send, see $include.
* @param array $include If true only $keys matching headers will be
* sent, if false only header not matching $keys will be
* sent.
*/
function sendHeaders($keys = array(), $include = true)
{
if (headers_sent()) {
return false;
}
if (count($keys)) {
array_change_key_case($keys, CASE_LOWER);
foreach ($this->_headers as $key => $value) {
if ($include ? in_array($key, $keys) : !in_array($key, $keys)) {
header($key .': '. $value);
}
}
} else {
foreach ($this->_headers as $header => $value) {
header($header .': '. $value);
}
}
return true;
}
 
/**
* Send Satus Code
*
* Send out the given HTTP-Status code. Use this for example when you
* want to tell the client this page is cached, then you would call
* sendStatusCode(304).
*
* @see HTTP_Header_Cache::exitIfCached()
*
* @access public
* @return bool Returns true on success or false if headers are already
* sent.
* @param int $code The status code to send, i.e. 404, 304, 200, etc.
*/
function sendStatusCode($code)
{
if (headers_sent()) {
return false;
}
if ($code == (int) $code && defined('HTTP_HEADER_STATUS_'. $code)) {
$code = constant('HTTP_HEADER_STATUS_'. $code);
}
if (strncasecmp(PHP_SAPI, 'cgi', 3)) {
header('HTTP/'. $this->_httpVersion .' '. $code);
} else {
header('Status: '. $code);
}
return true;
}
 
/**
* Date to Timestamp
*
* Converts dates like
* Mon, 31 Mar 2003 15:26:34 GMT
* Tue, 15 Nov 1994 12:45:26 GMT
* into a timestamp, strtotime() didn't do it in older versions.
*
* @deprecated Use PHPs strtotime() instead.
* @access public
* @return mixed Returns int unix timestamp or false if the date doesn't
* seem to be a valid GMT date.
* @param string $date The GMT date.
*/
function dateToTimestamp($date)
{
static $months = array(
null => 0, 'Jan' => 1, 'Feb' => 2, 'Mar' => 3, 'Apr' => 4,
'May' => 5, 'Jun' => 6, 'Jul' => 7, 'Aug' => 8, 'Sep' => 9,
'Oct' => 10, 'Nov' => 11, 'Dec' => 12
);
if (-1 < $timestamp = strToTime($date)) {
return $timestamp;
}
if (!preg_match('~[^,]*,\s(\d+)\s(\w+)\s(\d+)\s(\d+):(\d+):(\d+).*~',
$date, $m)) {
return false;
}
// [0] => Mon, 31 Mar 2003 15:42:55 GMT
// [1] => 31 [2] => Mar [3] => 2003 [4] => 15 [5] => 42 [6] => 55
return mktime($m[4], $m[5], $m[6], $months[$m[2]], $m[1], $m[3]);
}
 
/**
* Redirect
*
* This function redirects the client. This is done by issuing a Location
* header and exiting. Additionally to HTTP::redirect() you can also add
* parameters to the url.
*
* If you dont need parameters to be added, simply use HTTP::redirect()
* otherwise use HTTP_Header::redirect().
*
* @see HTTP::redirect()
* @author Wolfram Kriesing <wk@visionp.de>
* @access public
* @return void
* @param string $url The URL to redirect to, if none is given it
* redirects to the current page.
* @param array $param Array of query string parameters to add; usually
* a set of key => value pairs; if an array entry consists
* only of an value it is used as key and the respective
* value is fetched from $GLOBALS[$value]
* @param bool $session Whether the session name/id should be added
*/
function redirect($url = null, $param = array(), $session = false)
{
if (!isset($url)) {
$url = $_SERVER['PHP_SELF'];
}
$qs = array();
 
if ($session) {
$qs[] = session_name() .'='. session_id();
}
 
if (is_array($param) && count($param)) {
if (count($param)) {
foreach ($param as $key => $val) {
if (is_string($key)) {
$qs[] = urlencode($key) .'='. urlencode($val);
} else {
$qs[] = urlencode($val) .'='. urlencode(@$GLOBALS[$val]);
}
}
}
}
if ($qstr = implode('&', $qs)) {
$purl = parse_url($url);
$url .= (isset($purl['query']) ? '&' : '?') . $qstr;
}
 
parent::redirect($url);
}
 
/**#@+
* @author Davey Shafik <davey@php.net>
* @param int $http_code HTTP Code to check
* @access public
*/
 
/**
* Return HTTP Status Code Type
*
* @return int|false
*/
function getStatusType($http_code)
{
if(is_int($http_code) && defined('HTTP_HEADER_STATUS_' .$http_code) || defined($http_code)) {
$type = substr($http_code,0,1);
switch ($type) {
case HTTP_HEADER_STATUS_INFORMATIONAL:
case HTTP_HEADER_STATUS_SUCCESSFUL:
case HTTP_HEADER_STATUS_REDIRECT:
case HTTP_HEADER_STATUS_CLIENT_ERROR:
case HTTP_HEADER_STATUS_SERVER_ERROR:
return $type;
break;
default:
return false;
break;
}
} else {
return false;
}
}
 
/**
* Return Status Code Message
*
* @return string|false
*/
function getStatusText($http_code)
{
if ($this->getStatusType($http_code)) {
if (is_int($http_code) && defined('HTTP_HEADER_STATUS_' .$http_code)) {
return substr(constant('HTTP_HEADER_STATUS_' .$http_code),4);
} else {
return substr($http_code,4);
}
} else {
return false;
}
}
 
/**
* Checks if HTTP Status code is Information (1xx)
*
* @return boolean
*/
function isInformational($http_code)
{
if ($status_type = $this->getStatusType($http_code)) {
return $status_type{0} == HTTP_HEADER_STATUS_INFORMATIONAL;
} else {
return false;
}
}
 
/**
* Checks if HTTP Status code is Successful (2xx)
*
* @return boolean
*/
function isSuccessful($http_code)
{
if ($status_type = $this->getStatusType($http_code)) {
return $status_type{0} == HTTP_HEADER_STATUS_SUCCESSFUL;
} else {
return false;
}
}
 
/**
* Checks if HTTP Status code is a Redirect (3xx)
*
* @return boolean
*/
function isRedirect($http_code)
{
if ($status_type = $this->getStatusType($http_code)) {
return $status_type{0} == HTTP_HEADER_STATUS_REDIRECT;
} else {
return false;
}
}
 
/**
* Checks if HTTP Status code is a Client Error (4xx)
*
* @return boolean
*/
function isClientError($http_code)
{
if ($status_type = $this->getStatusType($http_code)) {
return $status_type{0} == HTTP_HEADER_STATUS_CLIENT_ERROR;
} else {
return false;
}
}
 
/**
* Checks if HTTP Status code is Server Error (5xx)
*
* @return boolean
*/
function isServerError($http_code)
{
if ($status_type = $this->getStatusType($http_code)) {
return $status_type{0} == HTTP_HEADER_STATUS_SERVER_ERROR;
} else {
return false;
}
}
 
/**
* Checks if HTTP Status code is Server OR Client Error (4xx or 5xx)
*
* @return boolean
*/
function isError($http_code)
{
if ($status_type = $this->getStatusType($http_code)) {
return (($status_type == HTTP_HEADER_STATUS_CLIENT_ERROR) || ($status_type == HTTP_HEADER_STATUS_SERVER_ERROR)) ? true : false;
} else {
return false;
}
}
/**#@-*/
}
?>
/tags/v3.1-blanche-neige/jrest/lib/HTTP/Download.php
New file
0,0 → 1,1034
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
 
/**
* HTTP::Download
*
* PHP versions 4 and 5
*
* @category HTTP
* @package HTTP_Download
* @author Michael Wallner <mike@php.net>
* @copyright 2003-2005 Michael Wallner
* @license BSD, revised
* @version CVS: $Id$
* @link http://pear.php.net/package/HTTP_Download
*/
 
// {{{ includes
/**
* Requires PEAR
*/
require_once 'PEAR.php';
 
/**
* Requires HTTP_Header
*/
require_once 'HTTP/Header.php';
// }}}
 
// {{{ constants
/**#@+ Use with HTTP_Download::setContentDisposition() **/
/**
* Send data as attachment
*/
define('HTTP_DOWNLOAD_ATTACHMENT', 'attachment');
/**
* Send data inline
*/
define('HTTP_DOWNLOAD_INLINE', 'inline');
/**#@-**/
 
/**#@+ Use with HTTP_Download::sendArchive() **/
/**
* Send as uncompressed tar archive
*/
define('HTTP_DOWNLOAD_TAR', 'TAR');
/**
* Send as gzipped tar archive
*/
define('HTTP_DOWNLOAD_TGZ', 'TGZ');
/**
* Send as bzip2 compressed tar archive
*/
define('HTTP_DOWNLOAD_BZ2', 'BZ2');
/**
* Send as zip archive
*/
define('HTTP_DOWNLOAD_ZIP', 'ZIP');
/**#@-**/
 
/**#@+
* Error constants
*/
define('HTTP_DOWNLOAD_E_HEADERS_SENT', -1);
define('HTTP_DOWNLOAD_E_NO_EXT_ZLIB', -2);
define('HTTP_DOWNLOAD_E_NO_EXT_MMAGIC', -3);
define('HTTP_DOWNLOAD_E_INVALID_FILE', -4);
define('HTTP_DOWNLOAD_E_INVALID_PARAM', -5);
define('HTTP_DOWNLOAD_E_INVALID_RESOURCE', -6);
define('HTTP_DOWNLOAD_E_INVALID_REQUEST', -7);
define('HTTP_DOWNLOAD_E_INVALID_CONTENT_TYPE', -8);
define('HTTP_DOWNLOAD_E_INVALID_ARCHIVE_TYPE', -9);
/**#@-**/
// }}}
 
/**
* Send HTTP Downloads/Responses.
*
* With this package you can handle (hidden) downloads.
* It supports partial downloads, resuming and sending
* raw data ie. from database BLOBs.
*
* <i>ATTENTION:</i>
* You shouldn't use this package together with ob_gzhandler or
* zlib.output_compression enabled in your php.ini, especially
* if you want to send already gzipped data!
*
* @access public
* @version $Revision$
*/
class HTTP_Download
{
// {{{ protected member variables
/**
* Path to file for download
*
* @see HTTP_Download::setFile()
* @access protected
* @var string
*/
var $file = '';
/**
* Data for download
*
* @see HTTP_Download::setData()
* @access protected
* @var string
*/
var $data = null;
/**
* Resource handle for download
*
* @see HTTP_Download::setResource()
* @access protected
* @var int
*/
var $handle = null;
/**
* Whether to gzip the download
*
* @access protected
* @var bool
*/
var $gzip = false;
/**
* Whether to allow caching of the download on the clients side
*
* @access protected
* @var bool
*/
var $cache = true;
/**
* Size of download
*
* @access protected
* @var int
*/
var $size = 0;
/**
* Last modified
*
* @access protected
* @var int
*/
var $lastModified = 0;
/**
* HTTP headers
*
* @access protected
* @var array
*/
var $headers = array(
'Content-Type' => 'application/x-octetstream',
'Pragma' => 'cache',
'Cache-Control' => 'public, must-revalidate, max-age=0',
'Accept-Ranges' => 'bytes',
'X-Sent-By' => 'PEAR::HTTP::Download'
);
/**
* HTTP_Header
*
* @access protected
* @var object
*/
var $HTTP = null;
/**
* ETag
*
* @access protected
* @var string
*/
var $etag = '';
/**
* Buffer Size
*
* @access protected
* @var int
*/
var $bufferSize = 2097152;
/**
* Throttle Delay
*
* @access protected
* @var float
*/
var $throttleDelay = 0;
/**
* Sent Bytes
*
* @access public
* @var int
*/
var $sentBytes = 0;
// }}}
// {{{ constructor
/**
* Constructor
*
* Set supplied parameters.
*
* @access public
* @param array $params associative array of parameters
*
* <b>one of:</b>
* o 'file' => path to file for download
* o 'data' => raw data for download
* o 'resource' => resource handle for download
* <br/>
* <b>and any of:</b>
* o 'cache' => whether to allow cs caching
* o 'gzip' => whether to gzip the download
* o 'lastmodified' => unix timestamp
* o 'contenttype' => content type of download
* o 'contentdisposition' => content disposition
* o 'buffersize' => amount of bytes to buffer
* o 'throttledelay' => amount of secs to sleep
* o 'cachecontrol' => cache privacy and validity
*
* <br />
* 'Content-Disposition' is not HTTP compliant, but most browsers
* follow this header, so it was borrowed from MIME standard.
*
* It looks like this: <br />
* "Content-Disposition: attachment; filename=example.tgz".
*
* @see HTTP_Download::setContentDisposition()
*/
function HTTP_Download($params = array())
{
$this->HTTP = &new HTTP_Header;
$this->setParams($params);
}
// }}}
// {{{ public methods
/**
* Set parameters
*
* Set supplied parameters through its accessor methods.
*
* @access public
* @return mixed Returns true on success or PEAR_Error on failure.
* @param array $params associative array of parameters
*
* @see HTTP_Download::HTTP_Download()
*/
function setParams($params)
{
foreach((array) $params as $param => $value){
$method = 'set'. $param;
if (!method_exists($this, $method)) {
return PEAR::raiseError(
"Method '$method' doesn't exist.",
HTTP_DOWNLOAD_E_INVALID_PARAM
);
}
$e = call_user_func_array(array(&$this, $method), (array) $value);
if (PEAR::isError($e)) {
return $e;
}
}
return true;
}
/**
* Set path to file for download
*
* The Last-Modified header will be set to files filemtime(), actually.
* Returns PEAR_Error (HTTP_DOWNLOAD_E_INVALID_FILE) if file doesn't exist.
* Sends HTTP 404 status if $send_404 is set to true.
*
* @access public
* @return mixed Returns true on success or PEAR_Error on failure.
* @param string $file path to file for download
* @param bool $send_404 whether to send HTTP/404 if
* the file wasn't found
*/
function setFile($file, $send_404 = true)
{
$file = realpath($file);
if (!is_file($file)) {
if ($send_404) {
$this->HTTP->sendStatusCode(404);
}
return PEAR::raiseError(
"File '$file' not found.",
HTTP_DOWNLOAD_E_INVALID_FILE
);
}
$this->setLastModified(filemtime($file));
$this->file = $file;
$this->size = filesize($file);
return true;
}
/**
* Set data for download
*
* Set $data to null if you want to unset this.
*
* @access public
* @return void
* @param $data raw data to send
*/
function setData($data = null)
{
$this->data = $data;
$this->size = strlen($data);
}
/**
* Set resource for download
*
* The resource handle supplied will be closed after sending the download.
* Returns a PEAR_Error (HTTP_DOWNLOAD_E_INVALID_RESOURCE) if $handle
* is no valid resource. Set $handle to null if you want to unset this.
*
* @access public
* @return mixed Returns true on success or PEAR_Error on failure.
* @param int $handle resource handle
*/
function setResource($handle = null)
{
if (!isset($handle)) {
$this->handle = null;
$this->size = 0;
return true;
}
if (is_resource($handle)) {
$this->handle = $handle;
$filestats = fstat($handle);
$this->size = $filestats['size'];
return true;
}
 
return PEAR::raiseError(
"Handle '$handle' is no valid resource.",
HTTP_DOWNLOAD_E_INVALID_RESOURCE
);
}
/**
* Whether to gzip the download
*
* Returns a PEAR_Error (HTTP_DOWNLOAD_E_NO_EXT_ZLIB)
* if ext/zlib is not available/loadable.
*
* @access public
* @return mixed Returns true on success or PEAR_Error on failure.
* @param bool $gzip whether to gzip the download
*/
function setGzip($gzip = false)
{
if ($gzip && !PEAR::loadExtension('zlib')){
return PEAR::raiseError(
'GZIP compression (ext/zlib) not available.',
HTTP_DOWNLOAD_E_NO_EXT_ZLIB
);
}
$this->gzip = (bool) $gzip;
return true;
}
 
/**
* Whether to allow caching
*
* If set to true (default) we'll send some headers that are commonly
* used for caching purposes like ETag, Cache-Control and Last-Modified.
*
* If caching is disabled, we'll send the download no matter if it
* would actually be cached at the client side.
*
* @access public
* @return void
* @param bool $cache whether to allow caching
*/
function setCache($cache = true)
{
$this->cache = (bool) $cache;
}
/**
* Whether to allow proxies to cache
*
* If set to 'private' proxies shouldn't cache the response.
* This setting defaults to 'public' and affects only cached responses.
*
* @access public
* @return bool
* @param string $cache private or public
* @param int $maxage maximum age of the client cache entry
*/
function setCacheControl($cache = 'public', $maxage = 0)
{
switch ($cache = strToLower($cache))
{
case 'private':
case 'public':
$this->headers['Cache-Control'] =
$cache .', must-revalidate, max-age='. abs($maxage);
return true;
break;
}
return false;
}
/**
* Set ETag
*
* Sets a user-defined ETag for cache-validation. The ETag is usually
* generated by HTTP_Download through its payload information.
*
* @access public
* @return void
* @param string $etag Entity tag used for strong cache validation.
*/
function setETag($etag = null)
{
$this->etag = (string) $etag;
}
/**
* Set Size of Buffer
*
* The amount of bytes specified as buffer size is the maximum amount
* of data read at once from resources or files. The default size is 2M
* (2097152 bytes). Be aware that if you enable gzip compression and
* you set a very low buffer size that the actual file size may grow
* due to added gzip headers for each sent chunk of the specified size.
*
* Returns PEAR_Error (HTTP_DOWNLOAD_E_INVALID_PARAM) if $size is not
* greater than 0 bytes.
*
* @access public
* @return mixed Returns true on success or PEAR_Error on failure.
* @param int $bytes Amount of bytes to use as buffer.
*/
function setBufferSize($bytes = 2097152)
{
if (0 >= $bytes) {
return PEAR::raiseError(
'Buffer size must be greater than 0 bytes ('. $bytes .' given)',
HTTP_DOWNLOAD_E_INVALID_PARAM);
}
$this->bufferSize = abs($bytes);
return true;
}
/**
* Set Throttle Delay
*
* Set the amount of seconds to sleep after each chunck that has been
* sent. One can implement some sort of throttle through adjusting the
* buffer size and the throttle delay. With the following settings
* HTTP_Download will sleep a second after each 25 K of data sent.
*
* <code>
* Array(
* 'throttledelay' => 1,
* 'buffersize' => 1024 * 25,
* )
* </code>
*
* Just be aware that if gzipp'ing is enabled, decreasing the chunk size
* too much leads to proportionally increased network traffic due to added
* gzip header and bottom bytes around each chunk.
*
* @access public
* @return void
* @param float $seconds Amount of seconds to sleep after each
* chunk that has been sent.
*/
function setThrottleDelay($seconds = 0)
{
$this->throttleDelay = abs($seconds) * 1000;
}
/**
* Set "Last-Modified"
*
* This is usually determined by filemtime() in HTTP_Download::setFile()
* If you set raw data for download with HTTP_Download::setData() and you
* want do send an appropiate "Last-Modified" header, you should call this
* method.
*
* @access public
* @return void
* @param int unix timestamp
*/
function setLastModified($last_modified)
{
$this->lastModified = $this->headers['Last-Modified'] = (int) $last_modified;
}
/**
* Set Content-Disposition header
*
* @see HTTP_Download::HTTP_Download
*
* @access public
* @return void
* @param string $disposition whether to send the download
* inline or as attachment
* @param string $file_name the filename to display in
* the browser's download window
*
* <b>Example:</b>
* <code>
* $HTTP_Download->setContentDisposition(
* HTTP_DOWNLOAD_ATTACHMENT,
* 'download.tgz'
* );
* </code>
*/
function setContentDisposition( $disposition = HTTP_DOWNLOAD_ATTACHMENT,
$file_name = null)
{
$cd = $disposition;
if (isset($file_name)) {
$cd .= '; filename="' . $file_name . '"';
} elseif ($this->file) {
$cd .= '; filename="' . basename($this->file) . '"';
}
$this->headers['Content-Disposition'] = $cd;
}
/**
* Set content type of the download
*
* Default content type of the download will be 'application/x-octetstream'.
* Returns PEAR_Error (HTTP_DOWNLOAD_E_INVALID_CONTENT_TYPE) if
* $content_type doesn't seem to be valid.
*
* @access public
* @return mixed Returns true on success or PEAR_Error on failure.
* @param string $content_type content type of file for download
*/
function setContentType($content_type = 'application/x-octetstream')
{
if (!preg_match('/^[a-z]+\w*\/[a-z]+[\w.;= -]*$/', $content_type)) {
return PEAR::raiseError(
"Invalid content type '$content_type' supplied.",
HTTP_DOWNLOAD_E_INVALID_CONTENT_TYPE
);
}
$this->headers['Content-Type'] = $content_type;
return true;
}
/**
* Guess content type of file
*
* First we try to use PEAR::MIME_Type, if installed, to detect the content
* type, else we check if ext/mime_magic is loaded and properly configured.
*
* Returns PEAR_Error if:
* o if PEAR::MIME_Type failed to detect a proper content type
* (HTTP_DOWNLOAD_E_INVALID_CONTENT_TYPE)
* o ext/magic.mime is not installed, or not properly configured
* (HTTP_DOWNLOAD_E_NO_EXT_MMAGIC)
* o mime_content_type() couldn't guess content type or returned
* a content type considered to be bogus by setContentType()
* (HTTP_DOWNLOAD_E_INVALID_CONTENT_TYPE)
*
* @access public
* @return mixed Returns true on success or PEAR_Error on failure.
*/
function guessContentType()
{
if (class_exists('MIME_Type') || @include_once 'MIME/Type.php') {
if (PEAR::isError($mime_type = MIME_Type::autoDetect($this->file))) {
return PEAR::raiseError($mime_type->getMessage(),
HTTP_DOWNLOAD_E_INVALID_CONTENT_TYPE);
}
return $this->setContentType($mime_type);
}
if (!function_exists('mime_content_type')) {
return PEAR::raiseError(
'This feature requires ext/mime_magic!',
HTTP_DOWNLOAD_E_NO_EXT_MMAGIC
);
}
if (!is_file(ini_get('mime_magic.magicfile'))) {
return PEAR::raiseError(
'ext/mime_magic is loaded but not properly configured!',
HTTP_DOWNLOAD_E_NO_EXT_MMAGIC
);
}
if (!$content_type = @mime_content_type($this->file)) {
return PEAR::raiseError(
'Couldn\'t guess content type with mime_content_type().',
HTTP_DOWNLOAD_E_INVALID_CONTENT_TYPE
);
}
return $this->setContentType($content_type);
}
 
/**
* Send
*
* Returns PEAR_Error if:
* o HTTP headers were already sent (HTTP_DOWNLOAD_E_HEADERS_SENT)
* o HTTP Range was invalid (HTTP_DOWNLOAD_E_INVALID_REQUEST)
*
* @access public
* @return mixed Returns true on success or PEAR_Error on failure.
* @param bool $autoSetContentDisposition Whether to set the
* Content-Disposition header if it isn't already.
*/
function send($autoSetContentDisposition = true)
{
if (headers_sent()) {
return PEAR::raiseError(
'Headers already sent.',
HTTP_DOWNLOAD_E_HEADERS_SENT
);
}
if (!ini_get('safe_mode')) {
@set_time_limit(0);
}
if ($autoSetContentDisposition &&
!isset($this->headers['Content-Disposition'])) {
$this->setContentDisposition();
}
if ($this->cache) {
$this->headers['ETag'] = $this->generateETag();
if ($this->isCached()) {
$this->HTTP->sendStatusCode(304);
$this->sendHeaders();
return true;
}
} else {
unset($this->headers['Last-Modified']);
}
if (ob_get_level()) {
while (@ob_end_clean());
}
if ($this->gzip) {
@ob_start('ob_gzhandler');
} else {
ob_start();
}
$this->sentBytes = 0;
if ($this->isRangeRequest()) {
$this->HTTP->sendStatusCode(206);
$chunks = $this->getChunks();
} else {
$this->HTTP->sendStatusCode(200);
$chunks = array(array(0, $this->size));
if (!$this->gzip && count(ob_list_handlers()) < 2) {
$this->headers['Content-Length'] = $this->size;
}
}
 
if (PEAR::isError($e = $this->sendChunks($chunks))) {
ob_end_clean();
$this->HTTP->sendStatusCode(416);
return $e;
}
ob_end_flush();
flush();
return true;
}
 
/**
* Static send
*
* @see HTTP_Download::HTTP_Download()
* @see HTTP_Download::send()
*
* @static
* @access public
* @return mixed Returns true on success or PEAR_Error on failure.
* @param array $params associative array of parameters
* @param bool $guess whether HTTP_Download::guessContentType()
* should be called
*/
function staticSend($params, $guess = false)
{
$d = &new HTTP_Download();
$e = $d->setParams($params);
if (PEAR::isError($e)) {
return $e;
}
if ($guess) {
$e = $d->guessContentType();
if (PEAR::isError($e)) {
return $e;
}
}
return $d->send();
}
/**
* Send a bunch of files or directories as an archive
*
* Example:
* <code>
* require_once 'HTTP/Download.php';
* HTTP_Download::sendArchive(
* 'myArchive.tgz',
* '/var/ftp/pub/mike',
* HTTP_DOWNLOAD_TGZ,
* '',
* '/var/ftp/pub'
* );
* </code>
*
* @see Archive_Tar::createModify()
* @deprecated use HTTP_Download_Archive::send()
* @static
* @access public
* @return mixed Returns true on success or PEAR_Error on failure.
* @param string $name name the sent archive should have
* @param mixed $files files/directories
* @param string $type archive type
* @param string $add_path path that should be prepended to the files
* @param string $strip_path path that should be stripped from the files
*/
function sendArchive( $name,
$files,
$type = HTTP_DOWNLOAD_TGZ,
$add_path = '',
$strip_path = '')
{
require_once 'HTTP/Download/Archive.php';
return HTTP_Download_Archive::send($name, $files, $type,
$add_path, $strip_path);
}
// }}}
// {{{ protected methods
/**
* Generate ETag
*
* @access protected
* @return string
*/
function generateETag()
{
if (!$this->etag) {
if ($this->data) {
$md5 = md5($this->data);
} else {
$fst = is_resource($this->handle) ?
fstat($this->handle) : stat($this->file);
$md5 = md5($fst['mtime'] .'='. $fst['ino'] .'='. $fst['size']);
}
$this->etag = '"' . $md5 . '-' . crc32($md5) . '"';
}
return $this->etag;
}
/**
* Send multiple chunks
*
* @access protected
* @return mixed Returns true on success or PEAR_Error on failure.
* @param array $chunks
*/
function sendChunks($chunks)
{
if (count($chunks) == 1) {
return $this->sendChunk(current($chunks));
}
 
$bound = uniqid('HTTP_DOWNLOAD-', true);
$cType = $this->headers['Content-Type'];
$this->headers['Content-Type'] =
'multipart/byteranges; boundary=' . $bound;
$this->sendHeaders();
foreach ($chunks as $chunk){
if (PEAR::isError($e = $this->sendChunk($chunk, $cType, $bound))) {
return $e;
}
}
#echo "\r\n--$bound--\r\n";
return true;
}
/**
* Send chunk of data
*
* @access protected
* @return mixed Returns true on success or PEAR_Error on failure.
* @param array $chunk start and end offset of the chunk to send
* @param string $cType actual content type
* @param string $bound boundary for multipart/byteranges
*/
function sendChunk($chunk, $cType = null, $bound = null)
{
list($offset, $lastbyte) = $chunk;
$length = ($lastbyte - $offset) + 1;
if ($length < 1) {
return PEAR::raiseError(
"Error processing range request: $offset-$lastbyte/$length",
HTTP_DOWNLOAD_E_INVALID_REQUEST
);
}
$range = $offset . '-' . $lastbyte . '/' . $this->size;
if (isset($cType, $bound)) {
echo "\r\n--$bound\r\n",
"Content-Type: $cType\r\n",
"Content-Range: bytes $range\r\n\r\n";
} else {
if ($this->isRangeRequest()) {
$this->headers['Content-Length'] = $length;
$this->headers['Content-Range'] = 'bytes '. $range;
}
$this->sendHeaders();
}
 
if ($this->data) {
while (($length -= $this->bufferSize) > 0) {
$this->flush(substr($this->data, $offset, $this->bufferSize));
$this->throttleDelay and $this->sleep();
$offset += $this->bufferSize;
}
if ($length) {
$this->flush(substr($this->data, $offset, $this->bufferSize + $length));
}
} else {
if (!is_resource($this->handle)) {
$this->handle = fopen($this->file, 'rb');
}
fseek($this->handle, $offset);
while (($length -= $this->bufferSize) > 0) {
$this->flush(fread($this->handle, $this->bufferSize));
$this->throttleDelay and $this->sleep();
}
if ($length) {
$this->flush(fread($this->handle, $this->bufferSize + $length));
}
}
return true;
}
/**
* Get chunks to send
*
* @access protected
* @return array
*/
function getChunks()
{
$parts = array();
foreach (explode(',', $this->getRanges()) as $chunk){
list($o, $e) = explode('-', $chunk);
if ($e >= $this->size || (empty($e) && $e !== 0 && $e !== '0')) {
$e = $this->size - 1;
}
if (empty($o) && $o !== 0 && $o !== '0') {
$o = $this->size - $e;
$e = $this->size - 1;
}
$parts[] = array($o, $e);
}
return $parts;
}
/**
* Check if range is requested
*
* @access protected
* @return bool
*/
function isRangeRequest()
{
if (!isset($_SERVER['HTTP_RANGE'])) {
return false;
}
return $this->isValidRange();
}
/**
* Get range request
*
* @access protected
* @return array
*/
function getRanges()
{
return preg_match('/^bytes=((\d*-\d*,? ?)+)$/',
@$_SERVER['HTTP_RANGE'], $matches) ? $matches[1] : array();
}
/**
* Check if entity is cached
*
* @access protected
* @return bool
*/
function isCached()
{
return (
(isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) &&
$this->lastModified == strtotime(current($a = explode(
';', $_SERVER['HTTP_IF_MODIFIED_SINCE'])))) ||
(isset($_SERVER['HTTP_IF_NONE_MATCH']) &&
$this->compareAsterisk('HTTP_IF_NONE_MATCH', $this->etag))
);
}
/**
* Check if entity hasn't changed
*
* @access protected
* @return bool
*/
function isValidRange()
{
if (isset($_SERVER['HTTP_IF_MATCH']) &&
!$this->compareAsterisk('HTTP_IF_MATCH', $this->etag)) {
return false;
}
if (isset($_SERVER['HTTP_IF_RANGE']) &&
$_SERVER['HTTP_IF_RANGE'] !== $this->etag &&
strtotime($_SERVER['HTTP_IF_RANGE']) !== $this->lastModified) {
return false;
}
if (isset($_SERVER['HTTP_IF_UNMODIFIED_SINCE'])) {
$lm = current($a = explode(';', $_SERVER['HTTP_IF_UNMODIFIED_SINCE']));
if (strtotime($lm) !== $this->lastModified) {
return false;
}
}
if (isset($_SERVER['HTTP_UNLESS_MODIFIED_SINCE'])) {
$lm = current($a = explode(';', $_SERVER['HTTP_UNLESS_MODIFIED_SINCE']));
if (strtotime($lm) !== $this->lastModified) {
return false;
}
}
return true;
}
/**
* Compare against an asterisk or check for equality
*
* @access protected
* @return bool
* @param string key for the $_SERVER array
* @param string string to compare
*/
function compareAsterisk($svar, $compare)
{
foreach (array_map('trim', explode(',', $_SERVER[$svar])) as $request) {
if ($request === '*' || $request === $compare) {
return true;
}
}
return false;
}
/**
* Send HTTP headers
*
* @access protected
* @return void
*/
function sendHeaders()
{
foreach ($this->headers as $header => $value) {
$this->HTTP->setHeader($header, $value);
}
$this->HTTP->sendHeaders();
/* NSAPI won't output anything if we did this */
if (strncasecmp(PHP_SAPI, 'nsapi', 5)) {
ob_flush();
flush();
}
}
/**
* Flush
*
* @access protected
* @return void
* @param string $data
*/
function flush($data = '')
{
if ($dlen = strlen($data)) {
$this->sentBytes += $dlen;
echo $data;
}
ob_flush();
flush();
}
/**
* Sleep
*
* @access protected
* @return void
*/
function sleep()
{
if (OS_WINDOWS) {
com_message_pump($this->throttleDelay);
} else {
usleep($this->throttleDelay * 1000);
}
}
// }}}
}
?>
/tags/v3.1-blanche-neige/jrest/lib/DB/mysql.php
New file
0,0 → 1,916
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 foldmethod=marker: */
// +----------------------------------------------------------------------+
// | PHP Version 4 |
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2004 The PHP Group |
// +----------------------------------------------------------------------+
// | This source file is subject to version 2.02 of the PHP license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available at through the world-wide-web at |
// | http://www.php.net/license/2_02.txt. |
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// | Author: Stig Bakken <ssb@php.net> |
// | Maintainer: Daniel Convissor <danielc@php.net> |
// +----------------------------------------------------------------------+
//
// $Id$
 
 
// XXX legend:
//
// XXX ERRORMSG: The error message from the mysql function should
// be registered here.
//
// TODO/wishlist:
// longReadlen
// binmode
 
 
require_once 'DB/common.php';
 
/**
* Database independent query interface definition for PHP's MySQL
* extension.
*
* This is for MySQL versions 4.0 and below.
*
* @package DB
* @version $Id$
* @category Database
* @author Stig Bakken <ssb@php.net>
*/
class DB_mysql extends DB_common
{
// {{{ properties
 
var $connection;
var $phptype, $dbsyntax;
var $prepare_tokens = array();
var $prepare_types = array();
var $num_rows = array();
var $transaction_opcount = 0;
var $autocommit = true;
var $fetchmode = DB_FETCHMODE_ORDERED; /* Default fetch mode */
var $_db = false;
 
// }}}
// {{{ constructor
 
/**
* DB_mysql constructor.
*
* @access public
*/
function DB_mysql()
{
$this->DB_common();
$this->phptype = 'mysql';
$this->dbsyntax = 'mysql';
$this->features = array(
'prepare' => false,
'pconnect' => true,
'transactions' => true,
'limit' => 'alter'
);
$this->errorcode_map = array(
1004 => DB_ERROR_CANNOT_CREATE,
1005 => DB_ERROR_CANNOT_CREATE,
1006 => DB_ERROR_CANNOT_CREATE,
1007 => DB_ERROR_ALREADY_EXISTS,
1008 => DB_ERROR_CANNOT_DROP,
1022 => DB_ERROR_ALREADY_EXISTS,
1046 => DB_ERROR_NODBSELECTED,
1048 => DB_ERROR_CONSTRAINT,
1050 => DB_ERROR_ALREADY_EXISTS,
1051 => DB_ERROR_NOSUCHTABLE,
1054 => DB_ERROR_NOSUCHFIELD,
1062 => DB_ERROR_ALREADY_EXISTS,
1064 => DB_ERROR_SYNTAX,
1100 => DB_ERROR_NOT_LOCKED,
1136 => DB_ERROR_VALUE_COUNT_ON_ROW,
1146 => DB_ERROR_NOSUCHTABLE,
1216 => DB_ERROR_CONSTRAINT,
1217 => DB_ERROR_CONSTRAINT,
);
}
 
// }}}
// {{{ connect()
 
/**
* Connect to a database and log in as the specified user.
*
* @param $dsn the data source name (see DB::parseDSN for syntax)
* @param $persistent (optional) whether the connection should
* be persistent
* @access public
* @return int DB_OK on success, a DB error on failure
*/
function connect($dsninfo, $persistent = false)
{
if (!DB::assertExtension('mysql')) {
return $this->raiseError(DB_ERROR_EXTENSION_NOT_FOUND);
}
$this->dsn = $dsninfo;
if ($dsninfo['protocol'] && $dsninfo['protocol'] == 'unix') {
$dbhost = ':' . $dsninfo['socket'];
} else {
$dbhost = $dsninfo['hostspec'] ? $dsninfo['hostspec'] : 'localhost';
if ($dsninfo['port']) {
$dbhost .= ':' . $dsninfo['port'];
}
}
 
$connect_function = $persistent ? 'mysql_pconnect' : 'mysql_connect';
 
if ($dbhost && $dsninfo['username'] && isset($dsninfo['password'])) {
$conn = @$connect_function($dbhost, $dsninfo['username'],
$dsninfo['password']);
} elseif ($dbhost && $dsninfo['username']) {
$conn = @$connect_function($dbhost, $dsninfo['username']);
} elseif ($dbhost) {
$conn = @$connect_function($dbhost);
} else {
$conn = false;
}
if (!$conn) {
if (($err = @mysql_error()) != '') {
return $this->raiseError(DB_ERROR_CONNECT_FAILED, null, null,
null, $err);
} elseif (empty($php_errormsg)) {
return $this->raiseError(DB_ERROR_CONNECT_FAILED);
} else {
return $this->raiseError(DB_ERROR_CONNECT_FAILED, null, null,
null, $php_errormsg);
}
}
 
if ($dsninfo['database']) {
if (!@mysql_select_db($dsninfo['database'], $conn)) {
switch(mysql_errno($conn)) {
case 1049:
return $this->raiseError(DB_ERROR_NOSUCHDB, null, null,
null, @mysql_error($conn));
case 1044:
return $this->raiseError(DB_ERROR_ACCESS_VIOLATION, null, null,
null, @mysql_error($conn));
default:
return $this->raiseError(DB_ERROR, null, null,
null, @mysql_error($conn));
}
}
// fix to allow calls to different databases in the same script
$this->_db = $dsninfo['database'];
}
 
$this->connection = $conn;
return DB_OK;
}
 
// }}}
// {{{ disconnect()
 
/**
* Log out and disconnect from the database.
*
* @access public
*
* @return bool true on success, false if not connected.
*/
function disconnect()
{
$ret = @mysql_close($this->connection);
$this->connection = null;
return $ret;
}
 
// }}}
// {{{ simpleQuery()
 
/**
* Send a query to MySQL and return the results as a MySQL resource
* identifier.
*
* @param the SQL query
*
* @access public
*
* @return mixed returns a valid MySQL result for successful SELECT
* queries, DB_OK for other successful queries. A DB error is
* returned on failure.
*/
function simpleQuery($query)
{
$ismanip = DB::isManip($query);
$this->last_query = $query;
$query = $this->modifyQuery($query);
if ($this->_db) {
if (!@mysql_select_db($this->_db, $this->connection)) {
return $this->mysqlRaiseError(DB_ERROR_NODBSELECTED);
}
}
if (!$this->autocommit && $ismanip) {
if ($this->transaction_opcount == 0) {
$result = @mysql_query('SET AUTOCOMMIT=0', $this->connection);
$result = @mysql_query('BEGIN', $this->connection);
if (!$result) {
return $this->mysqlRaiseError();
}
}
$this->transaction_opcount++;
}
$result = @mysql_query($query, $this->connection);
if (!$result) {
return $this->mysqlRaiseError();
}
if (is_resource($result)) {
$numrows = $this->numrows($result);
if (is_object($numrows)) {
return $numrows;
}
$this->num_rows[(int)$result] = $numrows;
return $result;
}
return DB_OK;
}
 
// }}}
// {{{ nextResult()
 
/**
* Move the internal mysql result pointer to the next available result
*
* This method has not been implemented yet.
*
* @param a valid sql result resource
*
* @access public
*
* @return false
*/
function nextResult($result)
{
return false;
}
 
// }}}
// {{{ fetchInto()
 
/**
* Fetch a row and insert the data into an existing array.
*
* Formating of the array and the data therein are configurable.
* See DB_result::fetchInto() for more information.
*
* @param resource $result query result identifier
* @param array $arr (reference) array where data from the row
* should be placed
* @param int $fetchmode how the resulting array should be indexed
* @param int $rownum the row number to fetch
*
* @return mixed DB_OK on success, null when end of result set is
* reached or on failure
*
* @see DB_result::fetchInto()
* @access private
*/
function fetchInto($result, &$arr, $fetchmode, $rownum=null)
{
if ($rownum !== null) {
if (!@mysql_data_seek($result, $rownum)) {
return null;
}
}
if ($fetchmode & DB_FETCHMODE_ASSOC) {
$arr = @mysql_fetch_array($result, MYSQL_ASSOC);
if ($this->options['portability'] & DB_PORTABILITY_LOWERCASE && $arr) {
$arr = array_change_key_case($arr, CASE_LOWER);
}
} else {
$arr = @mysql_fetch_row($result);
}
if (!$arr) {
// See: http://bugs.php.net/bug.php?id=22328
// for why we can't check errors on fetching
return null;
/*
$errno = @mysql_errno($this->connection);
if (!$errno) {
return null;
}
return $this->mysqlRaiseError($errno);
*/
}
if ($this->options['portability'] & DB_PORTABILITY_RTRIM) {
/*
* Even though this DBMS already trims output, we do this because
* a field might have intentional whitespace at the end that
* gets removed by DB_PORTABILITY_RTRIM under another driver.
*/
$this->_rtrimArrayValues($arr);
}
if ($this->options['portability'] & DB_PORTABILITY_NULL_TO_EMPTY) {
$this->_convertNullArrayValuesToEmpty($arr);
}
return DB_OK;
}
 
// }}}
// {{{ freeResult()
 
/**
* Free the internal resources associated with $result.
*
* @param $result MySQL result identifier
*
* @access public
*
* @return bool true on success, false if $result is invalid
*/
function freeResult($result)
{
unset($this->num_rows[(int)$result]);
return @mysql_free_result($result);
}
 
// }}}
// {{{ numCols()
 
/**
* Get the number of columns in a result set.
*
* @param $result MySQL result identifier
*
* @access public
*
* @return int the number of columns per row in $result
*/
function numCols($result)
{
$cols = @mysql_num_fields($result);
 
if (!$cols) {
return $this->mysqlRaiseError();
}
 
return $cols;
}
 
// }}}
// {{{ numRows()
 
/**
* Get the number of rows in a result set.
*
* @param $result MySQL result identifier
*
* @access public
*
* @return int the number of rows in $result
*/
function numRows($result)
{
$rows = @mysql_num_rows($result);
if ($rows === null) {
return $this->mysqlRaiseError();
}
return $rows;
}
 
// }}}
// {{{ autoCommit()
 
/**
* Enable/disable automatic commits
*/
function autoCommit($onoff = false)
{
// XXX if $this->transaction_opcount > 0, we should probably
// issue a warning here.
$this->autocommit = $onoff ? true : false;
return DB_OK;
}
 
// }}}
// {{{ commit()
 
/**
* Commit the current transaction.
*/
function commit()
{
if ($this->transaction_opcount > 0) {
if ($this->_db) {
if (!@mysql_select_db($this->_db, $this->connection)) {
return $this->mysqlRaiseError(DB_ERROR_NODBSELECTED);
}
}
$result = @mysql_query('COMMIT', $this->connection);
$result = @mysql_query('SET AUTOCOMMIT=1', $this->connection);
$this->transaction_opcount = 0;
if (!$result) {
return $this->mysqlRaiseError();
}
}
return DB_OK;
}
 
// }}}
// {{{ rollback()
 
/**
* Roll back (undo) the current transaction.
*/
function rollback()
{
if ($this->transaction_opcount > 0) {
if ($this->_db) {
if (!@mysql_select_db($this->_db, $this->connection)) {
return $this->mysqlRaiseError(DB_ERROR_NODBSELECTED);
}
}
$result = @mysql_query('ROLLBACK', $this->connection);
$result = @mysql_query('SET AUTOCOMMIT=1', $this->connection);
$this->transaction_opcount = 0;
if (!$result) {
return $this->mysqlRaiseError();
}
}
return DB_OK;
}
 
// }}}
// {{{ affectedRows()
 
/**
* Gets the number of rows affected by the data manipulation
* query. For other queries, this function returns 0.
*
* @return number of rows affected by the last query
*/
function affectedRows()
{
if (DB::isManip($this->last_query)) {
return @mysql_affected_rows($this->connection);
} else {
return 0;
}
}
 
// }}}
// {{{ errorNative()
 
/**
* Get the native error code of the last error (if any) that
* occured on the current connection.
*
* @access public
*
* @return int native MySQL error code
*/
function errorNative()
{
return @mysql_errno($this->connection);
}
 
// }}}
// {{{ nextId()
 
/**
* Returns the next free id in a sequence
*
* @param string $seq_name name of the sequence
* @param boolean $ondemand when true, the seqence is automatically
* created if it does not exist
*
* @return int the next id number in the sequence. DB_Error if problem.
*
* @internal
* @see DB_common::nextID()
* @access public
*/
function nextId($seq_name, $ondemand = true)
{
$seqname = $this->getSequenceName($seq_name);
do {
$repeat = 0;
$this->pushErrorHandling(PEAR_ERROR_RETURN);
$result = $this->query("UPDATE ${seqname} ".
'SET id=LAST_INSERT_ID(id+1)');
$this->popErrorHandling();
if ($result === DB_OK) {
/** COMMON CASE **/
$id = @mysql_insert_id($this->connection);
if ($id != 0) {
return $id;
}
/** EMPTY SEQ TABLE **/
// Sequence table must be empty for some reason, so fill it and return 1
// Obtain a user-level lock
$result = $this->getOne("SELECT GET_LOCK('${seqname}_lock',10)");
if (DB::isError($result)) {
return $this->raiseError($result);
}
if ($result == 0) {
// Failed to get the lock, bail with a DB_ERROR_NOT_LOCKED error
return $this->mysqlRaiseError(DB_ERROR_NOT_LOCKED);
}
 
// add the default value
$result = $this->query("REPLACE INTO ${seqname} (id) VALUES (0)");
if (DB::isError($result)) {
return $this->raiseError($result);
}
 
// Release the lock
$result = $this->getOne("SELECT RELEASE_LOCK('${seqname}_lock')");
if (DB::isError($result)) {
return $this->raiseError($result);
}
// We know what the result will be, so no need to try again
return 1;
 
/** ONDEMAND TABLE CREATION **/
} elseif ($ondemand && DB::isError($result) &&
$result->getCode() == DB_ERROR_NOSUCHTABLE)
{
$result = $this->createSequence($seq_name);
if (DB::isError($result)) {
return $this->raiseError($result);
} else {
$repeat = 1;
}
 
/** BACKWARDS COMPAT **/
} elseif (DB::isError($result) &&
$result->getCode() == DB_ERROR_ALREADY_EXISTS)
{
// see _BCsequence() comment
$result = $this->_BCsequence($seqname);
if (DB::isError($result)) {
return $this->raiseError($result);
}
$repeat = 1;
}
} while ($repeat);
 
return $this->raiseError($result);
}
 
// }}}
// {{{ createSequence()
 
/**
* Creates a new sequence
*
* @param string $seq_name name of the new sequence
*
* @return int DB_OK on success. A DB_Error object is returned if
* problems arise.
*
* @internal
* @see DB_common::createSequence()
* @access public
*/
function createSequence($seq_name)
{
$seqname = $this->getSequenceName($seq_name);
$res = $this->query("CREATE TABLE ${seqname} ".
'(id INTEGER UNSIGNED AUTO_INCREMENT NOT NULL,'.
' PRIMARY KEY(id))');
if (DB::isError($res)) {
return $res;
}
// insert yields value 1, nextId call will generate ID 2
$res = $this->query("INSERT INTO ${seqname} (id) VALUES (0)");
if (DB::isError($res)) {
return $res;
}
// so reset to zero
return $this->query("UPDATE ${seqname} SET id = 0;");
}
 
// }}}
// {{{ dropSequence()
 
/**
* Deletes a sequence
*
* @param string $seq_name name of the sequence to be deleted
*
* @return int DB_OK on success. DB_Error if problems.
*
* @internal
* @see DB_common::dropSequence()
* @access public
*/
function dropSequence($seq_name)
{
return $this->query('DROP TABLE ' . $this->getSequenceName($seq_name));
}
 
// }}}
// {{{ _BCsequence()
 
/**
* Backwards compatibility with old sequence emulation implementation
* (clean up the dupes)
*
* @param string $seqname The sequence name to clean up
* @return mixed DB_Error or true
*/
function _BCsequence($seqname)
{
// Obtain a user-level lock... this will release any previous
// application locks, but unlike LOCK TABLES, it does not abort
// the current transaction and is much less frequently used.
$result = $this->getOne("SELECT GET_LOCK('${seqname}_lock',10)");
if (DB::isError($result)) {
return $result;
}
if ($result == 0) {
// Failed to get the lock, can't do the conversion, bail
// with a DB_ERROR_NOT_LOCKED error
return $this->mysqlRaiseError(DB_ERROR_NOT_LOCKED);
}
 
$highest_id = $this->getOne("SELECT MAX(id) FROM ${seqname}");
if (DB::isError($highest_id)) {
return $highest_id;
}
// This should kill all rows except the highest
// We should probably do something if $highest_id isn't
// numeric, but I'm at a loss as how to handle that...
$result = $this->query("DELETE FROM ${seqname} WHERE id <> $highest_id");
if (DB::isError($result)) {
return $result;
}
 
// If another thread has been waiting for this lock,
// it will go thru the above procedure, but will have no
// real effect
$result = $this->getOne("SELECT RELEASE_LOCK('${seqname}_lock')");
if (DB::isError($result)) {
return $result;
}
return true;
}
 
// }}}
// {{{ quoteIdentifier()
 
/**
* Quote a string so it can be safely used as a table or column name
*
* Quoting style depends on which database driver is being used.
*
* MySQL can't handle the backtick character (<kbd>`</kbd>) in
* table or column names.
*
* @param string $str identifier name to be quoted
*
* @return string quoted identifier string
*
* @since 1.6.0
* @access public
* @internal
*/
function quoteIdentifier($str)
{
return '`' . $str . '`';
}
 
// }}}
// {{{ quote()
 
/**
* @deprecated Deprecated in release 1.6.0
* @internal
*/
function quote($str) {
return $this->quoteSmart($str);
}
 
// }}}
// {{{ escapeSimple()
 
/**
* Escape a string according to the current DBMS's standards
*
* @param string $str the string to be escaped
*
* @return string the escaped string
*
* @internal
*/
function escapeSimple($str) {
if (function_exists('mysql_real_escape_string')) {
return @mysql_real_escape_string($str, $this->connection);
} else {
return @mysql_escape_string($str);
}
}
 
// }}}
// {{{ modifyQuery()
 
function modifyQuery($query)
{
if ($this->options['portability'] & DB_PORTABILITY_DELETE_COUNT) {
// "DELETE FROM table" gives 0 affected rows in MySQL.
// This little hack lets you know how many rows were deleted.
if (preg_match('/^\s*DELETE\s+FROM\s+(\S+)\s*$/i', $query)) {
$query = preg_replace('/^\s*DELETE\s+FROM\s+(\S+)\s*$/',
'DELETE FROM \1 WHERE 1=1', $query);
}
}
return $query;
}
 
// }}}
// {{{ modifyLimitQuery()
 
function modifyLimitQuery($query, $from, $count, $params = array())
{
if (DB::isManip($query)) {
return $query . " LIMIT $count";
} else {
return $query . " LIMIT $from, $count";
}
}
 
// }}}
// {{{ mysqlRaiseError()
 
/**
* Gather information about an error, then use that info to create a
* DB error object and finally return that object.
*
* @param integer $errno PEAR error number (usually a DB constant) if
* manually raising an error
* @return object DB error object
* @see DB_common::errorCode()
* @see DB_common::raiseError()
*/
function mysqlRaiseError($errno = null)
{
if ($errno === null) {
if ($this->options['portability'] & DB_PORTABILITY_ERRORS) {
$this->errorcode_map[1022] = DB_ERROR_CONSTRAINT;
$this->errorcode_map[1048] = DB_ERROR_CONSTRAINT_NOT_NULL;
$this->errorcode_map[1062] = DB_ERROR_CONSTRAINT;
} else {
// Doing this in case mode changes during runtime.
$this->errorcode_map[1022] = DB_ERROR_ALREADY_EXISTS;
$this->errorcode_map[1048] = DB_ERROR_CONSTRAINT;
$this->errorcode_map[1062] = DB_ERROR_ALREADY_EXISTS;
}
$errno = $this->errorCode(mysql_errno($this->connection));
}
return $this->raiseError($errno, null, null, null,
@mysql_errno($this->connection) . ' ** ' .
@mysql_error($this->connection));
}
 
// }}}
// {{{ tableInfo()
 
/**
* Returns information about a table or a result set.
*
* @param object|string $result DB_result object from a query or a
* string containing the name of a table
* @param int $mode a valid tableInfo mode
* @return array an associative array with the information requested
* or an error object if something is wrong
* @access public
* @internal
* @see DB_common::tableInfo()
*/
function tableInfo($result, $mode = null) {
if (isset($result->result)) {
/*
* Probably received a result object.
* Extract the result resource identifier.
*/
$id = $result->result;
$got_string = false;
} elseif (is_string($result)) {
/*
* Probably received a table name.
* Create a result resource identifier.
*/
$id = @mysql_list_fields($this->dsn['database'],
$result, $this->connection);
$got_string = true;
} else {
/*
* Probably received a result resource identifier.
* Copy it.
* Deprecated. Here for compatibility only.
*/
$id = $result;
$got_string = false;
}
 
if (!is_resource($id)) {
return $this->mysqlRaiseError(DB_ERROR_NEED_MORE_DATA);
}
 
if ($this->options['portability'] & DB_PORTABILITY_LOWERCASE) {
$case_func = 'strtolower';
} else {
$case_func = 'strval';
}
 
$count = @mysql_num_fields($id);
 
// made this IF due to performance (one if is faster than $count if's)
if (!$mode) {
for ($i=0; $i<$count; $i++) {
$res[$i]['table'] = $case_func(@mysql_field_table($id, $i));
$res[$i]['name'] = $case_func(@mysql_field_name($id, $i));
$res[$i]['type'] = @mysql_field_type($id, $i);
$res[$i]['len'] = @mysql_field_len($id, $i);
$res[$i]['flags'] = @mysql_field_flags($id, $i);
}
} else { // full
$res['num_fields']= $count;
 
for ($i=0; $i<$count; $i++) {
$res[$i]['table'] = $case_func(@mysql_field_table($id, $i));
$res[$i]['name'] = $case_func(@mysql_field_name($id, $i));
$res[$i]['type'] = @mysql_field_type($id, $i);
$res[$i]['len'] = @mysql_field_len($id, $i);
$res[$i]['flags'] = @mysql_field_flags($id, $i);
 
if ($mode & DB_TABLEINFO_ORDER) {
$res['order'][$res[$i]['name']] = $i;
}
if ($mode & DB_TABLEINFO_ORDERTABLE) {
$res['ordertable'][$res[$i]['table']][$res[$i]['name']] = $i;
}
}
}
 
// free the result only if we were called on a table
if ($got_string) {
@mysql_free_result($id);
}
return $res;
}
 
// }}}
// {{{ getSpecialQuery()
 
/**
* Returns the query needed to get some backend info
* @param string $type What kind of info you want to retrieve
* @return string The SQL query string
*/
function getSpecialQuery($type)
{
switch ($type) {
case 'tables':
return 'SHOW TABLES';
case 'views':
return DB_ERROR_NOT_CAPABLE;
case 'users':
$sql = 'select distinct User from user';
if ($this->dsn['database'] != 'mysql') {
$dsn = $this->dsn;
$dsn['database'] = 'mysql';
if (DB::isError($db = DB::connect($dsn))) {
return $db;
}
$sql = $db->getCol($sql);
$db->disconnect();
// XXX Fixme the mysql driver should take care of this
if (!@mysql_select_db($this->dsn['database'], $this->connection)) {
return $this->mysqlRaiseError(DB_ERROR_NODBSELECTED);
}
}
return $sql;
case 'databases':
return 'SHOW DATABASES';
default:
return null;
}
}
 
// }}}
 
}
 
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
*/
 
?>
/tags/v3.1-blanche-neige/jrest/lib/DB/common.php
New file
0,0 → 1,2040
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 foldmethod=marker: */
// +----------------------------------------------------------------------+
// | PHP Version 4 |
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2004 The PHP Group |
// +----------------------------------------------------------------------+
// | This source file is subject to version 2.02 of the PHP license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available at through the world-wide-web at |
// | http://www.php.net/license/2_02.txt. |
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// | Author: Stig Bakken <ssb@php.net> |
// | Tomas V.V.Cox <cox@idecnet.com> |
// | Maintainer: Daniel Convissor <danielc@php.net> |
// +----------------------------------------------------------------------+
//
// $Id$
 
require_once 'PEAR.php';
 
/**
* DB_common is a base class for DB implementations, and must be
* inherited by all such
*
* @package DB
* @version $Id$
* @category Database
* @author Stig Bakken <ssb@php.net>
* @author Tomas V.V.Cox <cox@idecnet.com>
*/
class DB_common extends PEAR
{
// {{{ properties
 
/**
* assoc of capabilities for this DB implementation
* $features['limit'] => 'emulate' => emulate with fetch row by number
* 'alter' => alter the query
* false => skip rows
* @var array
*/
var $features = array();
 
/**
* assoc mapping native error codes to DB ones
* @var array
*/
var $errorcode_map = array();
 
/**
* DB type (mysql, oci8, odbc etc.)
* @var string
*/
var $phptype;
 
/**
* @var string
*/
var $prepare_tokens;
 
/**
* @var string
*/
var $prepare_types;
 
/**
* @var string
*/
var $prepared_queries;
 
/**
* @var integer
*/
var $prepare_maxstmt = 0;
 
/**
* @var string
*/
var $last_query = '';
 
/**
* @var integer
*/
var $fetchmode = DB_FETCHMODE_ORDERED;
 
/**
* @var string
*/
var $fetchmode_object_class = 'stdClass';
 
/**
* Run-time configuration options.
*
* The 'optimize' option has been deprecated. Use the 'portability'
* option instead.
*
* @see DB_common::setOption()
* @var array
*/
var $options = array(
'persistent' => false,
'ssl' => false,
'debug' => 0,
'seqname_format' => '%s_seq',
'autofree' => false,
'portability' => DB_PORTABILITY_NONE,
'optimize' => 'performance', // Deprecated. Use 'portability'.
);
 
/**
* DB handle
* @var resource
*/
var $dbh;
 
// }}}
// {{{ toString()
 
/**
* String conversation
*
* @return string
* @access private
*/
function toString()
{
$info = strtolower(get_class($this));
$info .= ': (phptype=' . $this->phptype .
', dbsyntax=' . $this->dbsyntax .
')';
 
if ($this->connection) {
$info .= ' [connected]';
}
 
return $info;
}
 
// }}}
// {{{ constructor
 
/**
* Constructor
*/
function DB_common()
{
$this->PEAR('DB_Error');
}
 
// }}}
// {{{ quoteString()
 
/**
* DEPRECATED: Quotes a string so it can be safely used within string
* delimiters in a query
*
* @return string quoted string
*
* @see DB_common::quoteSmart(), DB_common::escapeSimple()
* @deprecated Deprecated in release 1.2 or lower
* @internal
*/
function quoteString($string)
{
$string = $this->quote($string);
if ($string{0} == "'") {
return substr($string, 1, -1);
}
return $string;
}
 
// }}}
// {{{ quote()
 
/**
* DEPRECATED: Quotes a string so it can be safely used in a query
*
* @param string $string the input string to quote
*
* @return string The NULL string or the string quotes
* in magic_quote_sybase style
*
* @see DB_common::quoteSmart(), DB_common::escapeSimple()
* @deprecated Deprecated in release 1.6.0
* @internal
*/
function quote($string = null)
{
return ($string === null) ? 'NULL' : "'".str_replace("'", "''", $string)."'";
}
 
// }}}
// {{{ quoteIdentifier()
 
/**
* Quote a string so it can be safely used as a table or column name
*
* Delimiting style depends on which database driver is being used.
*
* NOTE: just because you CAN use delimited identifiers doesn't mean
* you SHOULD use them. In general, they end up causing way more
* problems than they solve.
*
* Portability is broken by using the following characters inside
* delimited identifiers:
* + backtick (<kbd>`</kbd>) -- due to MySQL
* + double quote (<kbd>"</kbd>) -- due to Oracle
* + brackets (<kbd>[</kbd> or <kbd>]</kbd>) -- due to Access
*
* Delimited identifiers are known to generally work correctly under
* the following drivers:
* + mssql
* + mysql
* + mysqli
* + oci8
* + odbc(access)
* + odbc(db2)
* + pgsql
* + sqlite
* + sybase
*
* InterBase doesn't seem to be able to use delimited identifiers
* via PHP 4. They work fine under PHP 5.
*
* @param string $str identifier name to be quoted
*
* @return string quoted identifier string
*
* @since 1.6.0
* @access public
*/
function quoteIdentifier($str)
{
return '"' . str_replace('"', '""', $str) . '"';
}
 
// }}}
// {{{ quoteSmart()
 
/**
* Format input so it can be safely used in a query
*
* The output depends on the PHP data type of input and the database
* type being used.
*
* @param mixed $in data to be quoted
*
* @return mixed the format of the results depends on the input's
* PHP type:
*
* <ul>
* <li>
* <kbd>input</kbd> -> <samp>returns</samp>
* </li>
* <li>
* <kbd>null</kbd> -> the string <samp>NULL</samp>
* </li>
* <li>
* <kbd>integer</kbd> or <kbd>double</kbd> -> the unquoted number
* </li>
* <li>
* &type.bool; -> output depends on the driver in use
* Most drivers return integers: <samp>1</samp> if
* <kbd>true</kbd> or <samp>0</samp> if
* <kbd>false</kbd>.
* Some return strings: <samp>TRUE</samp> if
* <kbd>true</kbd> or <samp>FALSE</samp> if
* <kbd>false</kbd>.
* Finally one returns strings: <samp>T</samp> if
* <kbd>true</kbd> or <samp>F</samp> if
* <kbd>false</kbd>. Here is a list of each DBMS,
* the values returned and the suggested column type:
* <ul>
* <li>
* <kbd>dbase</kbd> -> <samp>T/F</samp>
* (<kbd>Logical</kbd>)
* </li>
* <li>
* <kbd>fbase</kbd> -> <samp>TRUE/FALSE</samp>
* (<kbd>BOOLEAN</kbd>)
* </li>
* <li>
* <kbd>ibase</kbd> -> <samp>1/0</samp>
* (<kbd>SMALLINT</kbd>) [1]
* </li>
* <li>
* <kbd>ifx</kbd> -> <samp>1/0</samp>
* (<kbd>SMALLINT</kbd>) [1]
* </li>
* <li>
* <kbd>msql</kbd> -> <samp>1/0</samp>
* (<kbd>INTEGER</kbd>)
* </li>
* <li>
* <kbd>mssql</kbd> -> <samp>1/0</samp>
* (<kbd>BIT</kbd>)
* </li>
* <li>
* <kbd>mysql</kbd> -> <samp>1/0</samp>
* (<kbd>TINYINT(1)</kbd>)
* </li>
* <li>
* <kbd>mysqli</kbd> -> <samp>1/0</samp>
* (<kbd>TINYINT(1)</kbd>)
* </li>
* <li>
* <kbd>oci8</kbd> -> <samp>1/0</samp>
* (<kbd>NUMBER(1)</kbd>)
* </li>
* <li>
* <kbd>odbc</kbd> -> <samp>1/0</samp>
* (<kbd>SMALLINT</kbd>) [1]
* </li>
* <li>
* <kbd>pgsql</kbd> -> <samp>TRUE/FALSE</samp>
* (<kbd>BOOLEAN</kbd>)
* </li>
* <li>
* <kbd>sqlite</kbd> -> <samp>1/0</samp>
* (<kbd>INTEGER</kbd>)
* </li>
* <li>
* <kbd>sybase</kbd> -> <samp>1/0</samp>
* (<kbd>TINYINT(1)</kbd>)
* </li>
* </ul>
* [1] Accommodate the lowest common denominator because not all
* versions of have <kbd>BOOLEAN</kbd>.
* </li>
* <li>
* other (including strings and numeric strings) ->
* the data with single quotes escaped by preceeding
* single quotes, backslashes are escaped by preceeding
* backslashes, then the whole string is encapsulated
* between single quotes
* </li>
* </ul>
*
* @since 1.6.0
* @see DB_common::escapeSimple()
* @access public
*/
function quoteSmart($in)
{
if (is_int($in) || is_double($in)) {
return $in;
} elseif (is_bool($in)) {
return $in ? 1 : 0;
} elseif (is_null($in)) {
return 'NULL';
} else {
return "'" . $this->escapeSimple($in) . "'";
}
}
 
// }}}
// {{{ escapeSimple()
 
/**
* Escape a string according to the current DBMS's standards
*
* In SQLite, this makes things safe for inserts/updates, but may
* cause problems when performing text comparisons against columns
* containing binary data. See the
* {@link http://php.net/sqlite_escape_string PHP manual} for more info.
*
* @param string $str the string to be escaped
*
* @return string the escaped string
*
* @since 1.6.0
* @see DB_common::quoteSmart()
* @access public
*/
function escapeSimple($str) {
return str_replace("'", "''", $str);
}
 
// }}}
// {{{ provides()
 
/**
* Tell whether a DB implementation or its backend extension
* supports a given feature
*
* @param array $feature name of the feature (see the DB class doc)
* @return bool whether this DB implementation supports $feature
* @access public
*/
function provides($feature)
{
return $this->features[$feature];
}
 
// }}}
// {{{ errorCode()
 
/**
* Map native error codes to DB's portable ones
*
* Requires that the DB implementation's constructor fills
* in the <var>$errorcode_map</var> property.
*
* @param mixed $nativecode the native error code, as returned by the
* backend database extension (string or integer)
*
* @return int a portable DB error code, or DB_ERROR if this DB
* implementation has no mapping for the given error code.
*
* @access public
*/
function errorCode($nativecode)
{
if (isset($this->errorcode_map[$nativecode])) {
return $this->errorcode_map[$nativecode];
}
// Fall back to DB_ERROR if there was no mapping.
return DB_ERROR;
}
 
// }}}
// {{{ errorMessage()
 
/**
* Map a DB error code to a textual message. This is actually
* just a wrapper for DB::errorMessage()
*
* @param integer $dbcode the DB error code
*
* @return string the corresponding error message, of false
* if the error code was unknown
*
* @access public
*/
function errorMessage($dbcode)
{
return DB::errorMessage($this->errorcode_map[$dbcode]);
}
 
// }}}
// {{{ raiseError()
 
/**
* Communicate an error and invoke error callbacks, etc
*
* Basically a wrapper for PEAR::raiseError without the message string.
*
* @param mixed integer error code, or a PEAR error object (all
* other parameters are ignored if this parameter is
* an object
*
* @param int error mode, see PEAR_Error docs
*
* @param mixed If error mode is PEAR_ERROR_TRIGGER, this is the
* error level (E_USER_NOTICE etc). If error mode is
* PEAR_ERROR_CALLBACK, this is the callback function,
* either as a function name, or as an array of an
* object and method name. For other error modes this
* parameter is ignored.
*
* @param string Extra debug information. Defaults to the last
* query and native error code.
*
* @param mixed Native error code, integer or string depending the
* backend.
*
* @return object a PEAR error object
*
* @access public
* @see PEAR_Error
*/
function &raiseError($code = DB_ERROR, $mode = null, $options = null,
$userinfo = null, $nativecode = null)
{
// The error is yet a DB error object
if (is_object($code)) {
// because we the static PEAR::raiseError, our global
// handler should be used if it is set
if ($mode === null && !empty($this->_default_error_mode)) {
$mode = $this->_default_error_mode;
$options = $this->_default_error_options;
}
$tmp = PEAR::raiseError($code, null, $mode, $options, null, null, true);
return $tmp;
}
 
if ($userinfo === null) {
$userinfo = $this->last_query;
}
 
if ($nativecode) {
$userinfo .= ' [nativecode=' . trim($nativecode) . ']';
}
 
$tmp = PEAR::raiseError(null, $code, $mode, $options, $userinfo,
'DB_Error', true);
return $tmp;
}
 
// }}}
// {{{ setFetchMode()
 
/**
* Sets which fetch mode should be used by default on queries
* on this connection
*
* @param integer $fetchmode DB_FETCHMODE_ORDERED or
* DB_FETCHMODE_ASSOC, possibly bit-wise OR'ed with
* DB_FETCHMODE_FLIPPED.
*
* @param string $object_class The class of the object
* to be returned by the fetch methods when
* the DB_FETCHMODE_OBJECT mode is selected.
* If no class is specified by default a cast
* to object from the assoc array row will be done.
* There is also the posibility to use and extend the
* 'DB_row' class.
*
* @see DB_FETCHMODE_ORDERED
* @see DB_FETCHMODE_ASSOC
* @see DB_FETCHMODE_FLIPPED
* @see DB_FETCHMODE_OBJECT
* @see DB_row::DB_row()
* @access public
*/
function setFetchMode($fetchmode, $object_class = 'stdClass')
{
switch ($fetchmode) {
case DB_FETCHMODE_OBJECT:
$this->fetchmode_object_class = $object_class;
case DB_FETCHMODE_ORDERED:
case DB_FETCHMODE_ASSOC:
$this->fetchmode = $fetchmode;
break;
default:
return $this->raiseError('invalid fetchmode mode');
}
}
 
// }}}
// {{{ setOption()
 
/**
* Set run-time configuration options for PEAR DB
*
* Options, their data types, default values and description:
* <ul>
* <li>
* <var>autofree</var> <kbd>boolean</kbd> = <samp>false</samp>
* <br />should results be freed automatically when there are no
* more rows?
* </li><li>
* <var>debug</var> <kbd>integer</kbd> = <samp>0</samp>
* <br />debug level
* </li><li>
* <var>persistent</var> <kbd>boolean</kbd> = <samp>false</samp>
* <br />should the connection be persistent?
* </li><li>
* <var>portability</var> <kbd>integer</kbd> = <samp>DB_PORTABILITY_NONE</samp>
* <br />portability mode constant (see below)
* </li><li>
* <var>seqname_format</var> <kbd>string</kbd> = <samp>%s_seq</samp>
* <br />the sprintf() format string used on sequence names. This
* format is applied to sequence names passed to
* createSequence(), nextID() and dropSequence().
* </li><li>
* <var>ssl</var> <kbd>boolean</kbd> = <samp>false</samp>
* <br />use ssl to connect?
* </li>
* </ul>
*
* -----------------------------------------
*
* PORTABILITY MODES
*
* These modes are bitwised, so they can be combined using <kbd>|</kbd>
* and removed using <kbd>^</kbd>. See the examples section below on how
* to do this.
*
* <samp>DB_PORTABILITY_NONE</samp>
* turn off all portability features
*
* This mode gets automatically turned on if the deprecated
* <var>optimize</var> option gets set to <samp>performance</samp>.
*
*
* <samp>DB_PORTABILITY_LOWERCASE</samp>
* convert names of tables and fields to lower case when using
* <kbd>get*()</kbd>, <kbd>fetch*()</kbd> and <kbd>tableInfo()</kbd>
*
* This mode gets automatically turned on in the following databases
* if the deprecated option <var>optimize</var> gets set to
* <samp>portability</samp>:
* + oci8
*
*
* <samp>DB_PORTABILITY_RTRIM</samp>
* right trim the data output by <kbd>get*()</kbd> <kbd>fetch*()</kbd>
*
*
* <samp>DB_PORTABILITY_DELETE_COUNT</samp>
* force reporting the number of rows deleted
*
* Some DBMS's don't count the number of rows deleted when performing
* simple <kbd>DELETE FROM tablename</kbd> queries. This portability
* mode tricks such DBMS's into telling the count by adding
* <samp>WHERE 1=1</samp> to the end of <kbd>DELETE</kbd> queries.
*
* This mode gets automatically turned on in the following databases
* if the deprecated option <var>optimize</var> gets set to
* <samp>portability</samp>:
* + fbsql
* + mysql
* + mysqli
* + sqlite
*
*
* <samp>DB_PORTABILITY_NUMROWS</samp>
* enable hack that makes <kbd>numRows()</kbd> work in Oracle
*
* This mode gets automatically turned on in the following databases
* if the deprecated option <var>optimize</var> gets set to
* <samp>portability</samp>:
* + oci8
*
*
* <samp>DB_PORTABILITY_ERRORS</samp>
* makes certain error messages in certain drivers compatible
* with those from other DBMS's
*
* + mysql, mysqli: change unique/primary key constraints
* DB_ERROR_ALREADY_EXISTS -> DB_ERROR_CONSTRAINT
*
* + odbc(access): MS's ODBC driver reports 'no such field' as code
* 07001, which means 'too few parameters.' When this option is on
* that code gets mapped to DB_ERROR_NOSUCHFIELD.
* DB_ERROR_MISMATCH -> DB_ERROR_NOSUCHFIELD
*
*
* <samp>DB_PORTABILITY_NULL_TO_EMPTY</samp>
* convert null values to empty strings in data output by get*() and
* fetch*(). Needed because Oracle considers empty strings to be null,
* while most other DBMS's know the difference between empty and null.
*
*
* <samp>DB_PORTABILITY_ALL</samp>
* turn on all portability features
*
* -----------------------------------------
*
* Example 1. Simple setOption() example
* <code> <?php
* $dbh->setOption('autofree', true);
* ?></code>
*
* Example 2. Portability for lowercasing and trimming
* <code> <?php
* $dbh->setOption('portability',
* DB_PORTABILITY_LOWERCASE | DB_PORTABILITY_RTRIM);
* ?></code>
*
* Example 3. All portability options except trimming
* <code> <?php
* $dbh->setOption('portability',
* DB_PORTABILITY_ALL ^ DB_PORTABILITY_RTRIM);
* ?></code>
*
* @param string $option option name
* @param mixed $value value for the option
*
* @return int DB_OK on success. DB_Error object on failure.
*
* @see DB_common::$options
*/
function setOption($option, $value)
{
if (isset($this->options[$option])) {
$this->options[$option] = $value;
 
/*
* Backwards compatibility check for the deprecated 'optimize'
* option. Done here in case settings change after connecting.
*/
if ($option == 'optimize') {
if ($value == 'portability') {
switch ($this->phptype) {
case 'oci8':
$this->options['portability'] =
DB_PORTABILITY_LOWERCASE |
DB_PORTABILITY_NUMROWS;
break;
case 'fbsql':
case 'mysql':
case 'mysqli':
case 'sqlite':
$this->options['portability'] =
DB_PORTABILITY_DELETE_COUNT;
break;
}
} else {
$this->options['portability'] = DB_PORTABILITY_NONE;
}
}
 
return DB_OK;
}
return $this->raiseError("unknown option $option");
}
 
// }}}
// {{{ getOption()
 
/**
* Returns the value of an option
*
* @param string $option option name
*
* @return mixed the option value
*/
function getOption($option)
{
if (isset($this->options[$option])) {
return $this->options[$option];
}
return $this->raiseError("unknown option $option");
}
 
// }}}
// {{{ prepare()
 
/**
* Prepares a query for multiple execution with execute()
*
* Creates a query that can be run multiple times. Each time it is run,
* the placeholders, if any, will be replaced by the contents of
* execute()'s $data argument.
*
* Three types of placeholders can be used:
* + <kbd>?</kbd> scalar value (i.e. strings, integers). The system
* will automatically quote and escape the data.
* + <kbd>!</kbd> value is inserted 'as is'
* + <kbd>&</kbd> requires a file name. The file's contents get
* inserted into the query (i.e. saving binary
* data in a db)
*
* Example 1.
* <code> <?php
* $sth = $dbh->prepare('INSERT INTO tbl (a, b, c) VALUES (?, !, &)');
* $data = array(
* "John's text",
* "'it''s good'",
* 'filename.txt'
* );
* $res = $dbh->execute($sth, $data);
* ?></code>
*
* Use backslashes to escape placeholder characters if you don't want
* them to be interpreted as placeholders:
* <pre>
* "UPDATE foo SET col=? WHERE col='over \& under'"
* </pre>
*
* With some database backends, this is emulated.
*
* {@internal ibase and oci8 have their own prepare() methods.}}
*
* @param string $query query to be prepared
*
* @return mixed DB statement resource on success. DB_Error on failure.
*
* @see DB_common::execute()
* @access public
*/
function prepare($query)
{
$tokens = preg_split('/((?<!\\\)[&?!])/', $query, -1,
PREG_SPLIT_DELIM_CAPTURE);
$token = 0;
$types = array();
$newtokens = array();
 
foreach ($tokens as $val) {
switch ($val) {
case '?':
$types[$token++] = DB_PARAM_SCALAR;
break;
case '&':
$types[$token++] = DB_PARAM_OPAQUE;
break;
case '!':
$types[$token++] = DB_PARAM_MISC;
break;
default:
$newtokens[] = preg_replace('/\\\([&?!])/', "\\1", $val);
}
}
 
$this->prepare_tokens[] = &$newtokens;
end($this->prepare_tokens);
 
$k = key($this->prepare_tokens);
$this->prepare_types[$k] = $types;
$this->prepared_queries[$k] = implode(' ', $newtokens);
 
return $k;
}
 
// }}}
// {{{ autoPrepare()
 
/**
* Automaticaly generate an insert or update query and pass it to prepare()
*
* @param string $table name of the table
* @param array $table_fields ordered array containing the fields names
* @param int $mode type of query to make (DB_AUTOQUERY_INSERT or DB_AUTOQUERY_UPDATE)
* @param string $where in case of update queries, this string will be put after the sql WHERE statement
* @return resource handle for the query
* @see DB_common::prepare(), DB_common::buildManipSQL()
* @access public
*/
function autoPrepare($table, $table_fields, $mode = DB_AUTOQUERY_INSERT, $where = false)
{
$query = $this->buildManipSQL($table, $table_fields, $mode, $where);
return $this->prepare($query);
}
 
// }}}
// {{{ autoExecute()
 
/**
* Automaticaly generate an insert or update query and call prepare()
* and execute() with it
*
* @param string $table name of the table
* @param array $fields_values assoc ($key=>$value) where $key is a field name and $value its value
* @param int $mode type of query to make (DB_AUTOQUERY_INSERT or DB_AUTOQUERY_UPDATE)
* @param string $where in case of update queries, this string will be put after the sql WHERE statement
* @return mixed a new DB_Result or a DB_Error when fail
* @see DB_common::autoPrepare(), DB_common::buildManipSQL()
* @access public
*/
function autoExecute($table, $fields_values, $mode = DB_AUTOQUERY_INSERT, $where = false)
{
$sth = $this->autoPrepare($table, array_keys($fields_values), $mode, $where);
$ret =& $this->execute($sth, array_values($fields_values));
$this->freePrepared($sth);
return $ret;
 
}
 
// }}}
// {{{ buildManipSQL()
 
/**
* Make automaticaly an sql query for prepare()
*
* Example : buildManipSQL('table_sql', array('field1', 'field2', 'field3'), DB_AUTOQUERY_INSERT)
* will return the string : INSERT INTO table_sql (field1,field2,field3) VALUES (?,?,?)
* NB : - This belongs more to a SQL Builder class, but this is a simple facility
* - Be carefull ! If you don't give a $where param with an UPDATE query, all
* the records of the table will be updated !
*
* @param string $table name of the table
* @param array $table_fields ordered array containing the fields names
* @param int $mode type of query to make (DB_AUTOQUERY_INSERT or DB_AUTOQUERY_UPDATE)
* @param string $where in case of update queries, this string will be put after the sql WHERE statement
* @return string sql query for prepare()
* @access public
*/
function buildManipSQL($table, $table_fields, $mode, $where = false)
{
if (count($table_fields) == 0) {
$this->raiseError(DB_ERROR_NEED_MORE_DATA);
}
$first = true;
switch ($mode) {
case DB_AUTOQUERY_INSERT:
$values = '';
$names = '';
foreach ($table_fields as $value) {
if ($first) {
$first = false;
} else {
$names .= ',';
$values .= ',';
}
$names .= $value;
$values .= '?';
}
return "INSERT INTO $table ($names) VALUES ($values)";
case DB_AUTOQUERY_UPDATE:
$set = '';
foreach ($table_fields as $value) {
if ($first) {
$first = false;
} else {
$set .= ',';
}
$set .= "$value = ?";
}
$sql = "UPDATE $table SET $set";
if ($where) {
$sql .= " WHERE $where";
}
return $sql;
default:
$this->raiseError(DB_ERROR_SYNTAX);
}
}
 
// }}}
// {{{ execute()
 
/**
* Executes a DB statement prepared with prepare()
*
* Example 1.
* <code> <?php
* $sth = $dbh->prepare('INSERT INTO tbl (a, b, c) VALUES (?, !, &)');
* $data = array(
* "John's text",
* "'it''s good'",
* 'filename.txt'
* );
* $res =& $dbh->execute($sth, $data);
* ?></code>
*
* @param resource $stmt a DB statement resource returned from prepare()
* @param mixed $data array, string or numeric data to be used in
* execution of the statement. Quantity of items
* passed must match quantity of placeholders in
* query: meaning 1 placeholder for non-array
* parameters or 1 placeholder per array element.
*
* @return object a new DB_Result or a DB_Error when fail
*
* {@internal ibase and oci8 have their own execute() methods.}}
*
* @see DB_common::prepare()
* @access public
*/
function &execute($stmt, $data = array())
{
$realquery = $this->executeEmulateQuery($stmt, $data);
if (DB::isError($realquery)) {
return $realquery;
}
$result = $this->simpleQuery($realquery);
 
if (DB::isError($result) || $result === DB_OK) {
return $result;
} else {
$tmp =& new DB_result($this, $result);
return $tmp;
}
}
 
// }}}
// {{{ executeEmulateQuery()
 
/**
* Emulates the execute statement, when not supported
*
* @param resource $stmt a DB statement resource returned from execute()
* @param mixed $data array, string or numeric data to be used in
* execution of the statement. Quantity of items
* passed must match quantity of placeholders in
* query: meaning 1 placeholder for non-array
* parameters or 1 placeholder per array element.
*
* @return mixed a string containing the real query run when emulating
* prepare/execute. A DB error code is returned on failure.
*
* @see DB_common::execute()
* @access private
*/
function executeEmulateQuery($stmt, $data = array())
{
if (!is_array($data)) {
$data = array($data);
}
 
if (count($this->prepare_types[$stmt]) != count($data)) {
$this->last_query = $this->prepared_queries[$stmt];
return $this->raiseError(DB_ERROR_MISMATCH);
}
 
$realquery = $this->prepare_tokens[$stmt][0];
 
$i = 0;
foreach ($data as $value) {
if ($this->prepare_types[$stmt][$i] == DB_PARAM_SCALAR) {
$realquery .= $this->quoteSmart($value);
} elseif ($this->prepare_types[$stmt][$i] == DB_PARAM_OPAQUE) {
$fp = @fopen($value, 'rb');
if (!$fp) {
return $this->raiseError(DB_ERROR_ACCESS_VIOLATION);
}
$realquery .= $this->quoteSmart(fread($fp, filesize($value)));
fclose($fp);
} else {
$realquery .= $value;
}
 
$realquery .= $this->prepare_tokens[$stmt][++$i];
}
 
return $realquery;
}
 
// }}}
// {{{ executeMultiple()
 
/**
* This function does several execute() calls on the same
* statement handle
*
* $data must be an array indexed numerically
* from 0, one execute call is done for every "row" in the array.
*
* If an error occurs during execute(), executeMultiple() does not
* execute the unfinished rows, but rather returns that error.
*
* @param resource $stmt query handle from prepare()
* @param array $data numeric array containing the
* data to insert into the query
*
* @return mixed DB_OK or DB_Error
*
* @see DB_common::prepare(), DB_common::execute()
* @access public
*/
function executeMultiple($stmt, $data)
{
foreach ($data as $value) {
$res =& $this->execute($stmt, $value);
if (DB::isError($res)) {
return $res;
}
}
return DB_OK;
}
 
// }}}
// {{{ freePrepared()
 
/**
* Free the resource used in a prepared query
*
* @param $stmt The resurce returned by the prepare() function
* @see DB_common::prepare()
*/
function freePrepared($stmt)
{
// Free the internal prepared vars
if (isset($this->prepare_tokens[$stmt])) {
unset($this->prepare_tokens[$stmt]);
unset($this->prepare_types[$stmt]);
unset($this->prepared_queries[$stmt]);
return true;
}
return false;
}
 
// }}}
// {{{ modifyQuery()
 
/**
* This method is used by backends to alter queries for various
* reasons
*
* It is defined here to assure that all implementations
* have this method defined.
*
* @param string $query query to modify
*
* @return the new (modified) query
*
* @access private
*/
function modifyQuery($query) {
return $query;
}
 
// }}}
// {{{ modifyLimitQuery()
 
/**
* This method is used by backends to alter limited queries
*
* @param string $query query to modify
* @param integer $from the row to start to fetching
* @param integer $count the numbers of rows to fetch
*
* @return the new (modified) query
*
* @access private
*/
function modifyLimitQuery($query, $from, $count, $params = array())
{
return $query;
}
 
// }}}
// {{{ query()
 
/**
* Send a query to the database and return any results with a
* DB_result object
*
* The query string can be either a normal statement to be sent directly
* to the server OR if <var>$params</var> are passed the query can have
* placeholders and it will be passed through prepare() and execute().
*
* @param string $query the SQL query or the statement to prepare
* @param mixed $params array, string or numeric data to be used in
* execution of the statement. Quantity of items
* passed must match quantity of placeholders in
* query: meaning 1 placeholder for non-array
* parameters or 1 placeholder per array element.
*
* @return mixed a DB_result object or DB_OK on success, a DB
* error on failure
*
* @see DB_result, DB_common::prepare(), DB_common::execute()
* @access public
*/
function &query($query, $params = array())
{
if (sizeof($params) > 0) {
$sth = $this->prepare($query);
if (DB::isError($sth)) {
return $sth;
}
$ret =& $this->execute($sth, $params);
$this->freePrepared($sth);
return $ret;
} else {
$result = $this->simpleQuery($query);
if (DB::isError($result) || $result === DB_OK) {
return $result;
} else {
$tmp =& new DB_result($this, $result);
return $tmp;
}
}
}
 
// }}}
// {{{ limitQuery()
 
/**
* Generates a limited query
*
* @param string $query query
* @param integer $from the row to start to fetching
* @param integer $count the numbers of rows to fetch
* @param mixed $params array, string or numeric data to be used in
* execution of the statement. Quantity of items
* passed must match quantity of placeholders in
* query: meaning 1 placeholder for non-array
* parameters or 1 placeholder per array element.
*
* @return mixed a DB_Result object, DB_OK or a DB_Error
*
* @access public
*/
function &limitQuery($query, $from, $count, $params = array())
{
$query = $this->modifyLimitQuery($query, $from, $count, $params);
if (DB::isError($query)){
return $query;
}
$result =& $this->query($query, $params);
if (is_a($result, 'DB_result')) {
$result->setOption('limit_from', $from);
$result->setOption('limit_count', $count);
}
return $result;
}
 
// }}}
// {{{ getOne()
 
/**
* Fetch the first column of the first row of data returned from
* a query
*
* Takes care of doing the query and freeing the results when finished.
*
* @param string $query the SQL query
* @param mixed $params array, string or numeric data to be used in
* execution of the statement. Quantity of items
* passed must match quantity of placeholders in
* query: meaning 1 placeholder for non-array
* parameters or 1 placeholder per array element.
*
* @return mixed the returned value of the query. DB_Error on failure.
*
* @access public
*/
function &getOne($query, $params = array())
{
settype($params, 'array');
if (sizeof($params) > 0) {
$sth = $this->prepare($query);
if (DB::isError($sth)) {
return $sth;
}
$res =& $this->execute($sth, $params);
$this->freePrepared($sth);
} else {
$res =& $this->query($query);
}
 
if (DB::isError($res)) {
return $res;
}
 
$err = $res->fetchInto($row, DB_FETCHMODE_ORDERED);
$res->free();
 
if ($err !== DB_OK) {
return $err;
}
 
return $row[0];
}
 
// }}}
// {{{ getRow()
 
/**
* Fetch the first row of data returned from a query
*
* Takes care of doing the query and freeing the results when finished.
*
* @param string $query the SQL query
* @param array $params array to be used in execution of the statement.
* Quantity of array elements must match quantity
* of placeholders in query. This function does
* NOT support scalars.
* @param int $fetchmode the fetch mode to use
*
* @return array the first row of results as an array indexed from
* 0, or a DB error code.
*
* @access public
*/
function &getRow($query,
$params = array(),
$fetchmode = DB_FETCHMODE_DEFAULT)
{
// compat check, the params and fetchmode parameters used to
// have the opposite order
if (!is_array($params)) {
if (is_array($fetchmode)) {
if ($params === null) {
$tmp = DB_FETCHMODE_DEFAULT;
} else {
$tmp = $params;
}
$params = $fetchmode;
$fetchmode = $tmp;
} elseif ($params !== null) {
$fetchmode = $params;
$params = array();
}
}
 
if (sizeof($params) > 0) {
$sth = $this->prepare($query);
if (DB::isError($sth)) {
return $sth;
}
$res =& $this->execute($sth, $params);
$this->freePrepared($sth);
} else {
$res =& $this->query($query);
}
 
if (DB::isError($res)) {
return $res;
}
 
$err = $res->fetchInto($row, $fetchmode);
 
$res->free();
 
if ($err !== DB_OK) {
return $err;
}
 
return $row;
}
 
// }}}
// {{{ getCol()
 
/**
* Fetch a single column from a result set and return it as an
* indexed array
*
* @param string $query the SQL query
* @param mixed $col which column to return (integer [column number,
* starting at 0] or string [column name])
* @param mixed $params array, string or numeric data to be used in
* execution of the statement. Quantity of items
* passed must match quantity of placeholders in
* query: meaning 1 placeholder for non-array
* parameters or 1 placeholder per array element.
*
* @return array an indexed array with the data from the first
* row at index 0, or a DB error code
*
* @see DB_common::query()
* @access public
*/
function &getCol($query, $col = 0, $params = array())
{
settype($params, 'array');
if (sizeof($params) > 0) {
$sth = $this->prepare($query);
 
if (DB::isError($sth)) {
return $sth;
}
 
$res =& $this->execute($sth, $params);
$this->freePrepared($sth);
} else {
$res =& $this->query($query);
}
 
if (DB::isError($res)) {
return $res;
}
 
$fetchmode = is_int($col) ? DB_FETCHMODE_ORDERED : DB_FETCHMODE_ASSOC;
 
if (!is_array($row = $res->fetchRow($fetchmode))) {
$ret = array();
} else {
if (!array_key_exists($col, $row)) {
$ret =& $this->raiseError(DB_ERROR_NOSUCHFIELD);
} else {
$ret = array($row[$col]);
while (is_array($row = $res->fetchRow($fetchmode))) {
$ret[] = $row[$col];
}
}
}
 
$res->free();
 
if (DB::isError($row)) {
$ret = $row;
}
 
return $ret;
}
 
// }}}
// {{{ getAssoc()
 
/**
* Fetch the entire result set of a query and return it as an
* associative array using the first column as the key
*
* If the result set contains more than two columns, the value
* will be an array of the values from column 2-n. If the result
* set contains only two columns, the returned value will be a
* scalar with the value of the second column (unless forced to an
* array with the $force_array parameter). A DB error code is
* returned on errors. If the result set contains fewer than two
* columns, a DB_ERROR_TRUNCATED error is returned.
*
* For example, if the table "mytable" contains:
*
* <pre>
* ID TEXT DATE
* --------------------------------
* 1 'one' 944679408
* 2 'two' 944679408
* 3 'three' 944679408
* </pre>
*
* Then the call getAssoc('SELECT id,text FROM mytable') returns:
* <pre>
* array(
* '1' => 'one',
* '2' => 'two',
* '3' => 'three',
* )
* </pre>
*
* ...while the call getAssoc('SELECT id,text,date FROM mytable') returns:
* <pre>
* array(
* '1' => array('one', '944679408'),
* '2' => array('two', '944679408'),
* '3' => array('three', '944679408')
* )
* </pre>
*
* If the more than one row occurs with the same value in the
* first column, the last row overwrites all previous ones by
* default. Use the $group parameter if you don't want to
* overwrite like this. Example:
*
* <pre>
* getAssoc('SELECT category,id,name FROM mytable', false, null,
* DB_FETCHMODE_ASSOC, true) returns:
*
* array(
* '1' => array(array('id' => '4', 'name' => 'number four'),
* array('id' => '6', 'name' => 'number six')
* ),
* '9' => array(array('id' => '4', 'name' => 'number four'),
* array('id' => '6', 'name' => 'number six')
* )
* )
* </pre>
*
* Keep in mind that database functions in PHP usually return string
* values for results regardless of the database's internal type.
*
* @param string $query the SQL query
* @param boolean $force_array used only when the query returns
* exactly two columns. If true, the values
* of the returned array will be one-element
* arrays instead of scalars.
* @param mixed $params array, string or numeric data to be used in
* execution of the statement. Quantity of items
* passed must match quantity of placeholders in
* query: meaning 1 placeholder for non-array
* parameters or 1 placeholder per array element.
* @param int $fetchmode the fetch mode to use
* @param boolean $group if true, the values of the returned array
* is wrapped in another array. If the same
* key value (in the first column) repeats
* itself, the values will be appended to
* this array instead of overwriting the
* existing values.
*
* @return array associative array with results from the query.
* DB Error on failure.
*
* @access public
*/
function &getAssoc($query, $force_array = false, $params = array(),
$fetchmode = DB_FETCHMODE_DEFAULT, $group = false)
{
settype($params, 'array');
if (sizeof($params) > 0) {
$sth = $this->prepare($query);
 
if (DB::isError($sth)) {
return $sth;
}
 
$res =& $this->execute($sth, $params);
$this->freePrepared($sth);
} else {
$res =& $this->query($query);
}
 
if (DB::isError($res)) {
return $res;
}
if ($fetchmode == DB_FETCHMODE_DEFAULT) {
$fetchmode = $this->fetchmode;
}
$cols = $res->numCols();
 
if ($cols < 2) {
$tmp =& $this->raiseError(DB_ERROR_TRUNCATED);
return $tmp;
}
 
$results = array();
 
if ($cols > 2 || $force_array) {
// return array values
// XXX this part can be optimized
if ($fetchmode == DB_FETCHMODE_ASSOC) {
while (is_array($row = $res->fetchRow(DB_FETCHMODE_ASSOC))) {
reset($row);
$key = current($row);
unset($row[key($row)]);
if ($group) {
$results[$key][] = $row;
} else {
$results[$key] = $row;
}
}
} elseif ($fetchmode == DB_FETCHMODE_OBJECT) {
while ($row = $res->fetchRow(DB_FETCHMODE_OBJECT)) {
$arr = get_object_vars($row);
$key = current($arr);
if ($group) {
$results[$key][] = $row;
} else {
$results[$key] = $row;
}
}
} else {
while (is_array($row = $res->fetchRow(DB_FETCHMODE_ORDERED))) {
// we shift away the first element to get
// indices running from 0 again
$key = array_shift($row);
if ($group) {
$results[$key][] = $row;
} else {
$results[$key] = $row;
}
}
}
if (DB::isError($row)) {
$results = $row;
}
} else {
// return scalar values
while (is_array($row = $res->fetchRow(DB_FETCHMODE_ORDERED))) {
if ($group) {
$results[$row[0]][] = $row[1];
} else {
$results[$row[0]] = $row[1];
}
}
if (DB::isError($row)) {
$results = $row;
}
}
 
$res->free();
 
return $results;
}
 
// }}}
// {{{ getAll()
 
/**
* Fetch all the rows returned from a query
*
* @param string $query the SQL query
* @param array $params array to be used in execution of the statement.
* Quantity of array elements must match quantity
* of placeholders in query. This function does
* NOT support scalars.
* @param int $fetchmode the fetch mode to use
*
* @return array an nested array. DB error on failure.
*
* @access public
*/
function &getAll($query,
$params = array(),
$fetchmode = DB_FETCHMODE_DEFAULT)
{
// compat check, the params and fetchmode parameters used to
// have the opposite order
if (!is_array($params)) {
if (is_array($fetchmode)) {
if ($params === null) {
$tmp = DB_FETCHMODE_DEFAULT;
} else {
$tmp = $params;
}
$params = $fetchmode;
$fetchmode = $tmp;
} elseif ($params !== null) {
$fetchmode = $params;
$params = array();
}
}
 
if (sizeof($params) > 0) {
$sth = $this->prepare($query);
 
if (DB::isError($sth)) {
return $sth;
}
 
$res =& $this->execute($sth, $params);
$this->freePrepared($sth);
} else {
$res =& $this->query($query);
}
 
if (DB::isError($res) || $res === DB_OK) {
return $res;
}
 
$results = array();
while (DB_OK === $res->fetchInto($row, $fetchmode)) {
if ($fetchmode & DB_FETCHMODE_FLIPPED) {
foreach ($row as $key => $val) {
$results[$key][] = $val;
}
} else {
$results[] = $row;
}
}
 
$res->free();
 
if (DB::isError($row)) {
$tmp =& $this->raiseError($row);
return $tmp;
}
return $results;
}
 
// }}}
// {{{ autoCommit()
 
/**
* enable automatic Commit
*
* @param boolean $onoff
* @return mixed DB_Error
*
* @access public
*/
function autoCommit($onoff=false)
{
return $this->raiseError(DB_ERROR_NOT_CAPABLE);
}
 
// }}}
// {{{ commit()
 
/**
* starts a Commit
*
* @return mixed DB_Error
*
* @access public
*/
function commit()
{
return $this->raiseError(DB_ERROR_NOT_CAPABLE);
}
 
// }}}
// {{{ rollback()
 
/**
* starts a rollback
*
* @return mixed DB_Error
*
* @access public
*/
function rollback()
{
return $this->raiseError(DB_ERROR_NOT_CAPABLE);
}
 
// }}}
// {{{ numRows()
 
/**
* Returns the number of rows in a result object
*
* @param object DB_Result the result object to check
*
* @return mixed DB_Error or the number of rows
*
* @access public
*/
function numRows($result)
{
return $this->raiseError(DB_ERROR_NOT_CAPABLE);
}
 
// }}}
// {{{ affectedRows()
 
/**
* Returns the affected rows of a query
*
* @return mixed DB_Error or number of rows
*
* @access public
*/
function affectedRows()
{
return $this->raiseError(DB_ERROR_NOT_CAPABLE);
}
 
// }}}
// {{{ errorNative()
 
/**
* Returns an errormessage, provides by the database
*
* @return mixed DB_Error or message
*
* @access public
*/
function errorNative()
{
return $this->raiseError(DB_ERROR_NOT_CAPABLE);
}
 
// }}}
// {{{ getSequenceName()
 
/**
* Generate the name used inside the database for a sequence
*
* The createSequence() docblock contains notes about storing sequence
* names.
*
* @param string $sqn the sequence's public name
*
* @return string the sequence's name in the backend
*
* @see DB_common::createSequence(), DB_common::dropSequence(),
* DB_common::nextID(), DB_common::setOption()
* @access private
*/
function getSequenceName($sqn)
{
return sprintf($this->getOption('seqname_format'),
preg_replace('/[^a-z0-9_.]/i', '_', $sqn));
}
 
// }}}
// {{{ nextId()
 
/**
* Returns the next free id in a sequence
*
* @param string $seq_name name of the sequence
* @param boolean $ondemand when true, the seqence is automatically
* created if it does not exist
*
* @return int the next id number in the sequence. DB_Error if problem.
*
* @see DB_common::createSequence(), DB_common::dropSequence(),
* DB_common::getSequenceName()
* @access public
*/
function nextId($seq_name, $ondemand = true)
{
return $this->raiseError(DB_ERROR_NOT_CAPABLE);
}
 
// }}}
// {{{ createSequence()
 
/**
* Creates a new sequence
*
* The name of a given sequence is determined by passing the string
* provided in the <var>$seq_name</var> argument through PHP's sprintf()
* function using the value from the <var>seqname_format</var> option as
* the sprintf()'s format argument.
*
* <var>seqname_format</var> is set via setOption().
*
* @param string $seq_name name of the new sequence
*
* @return int DB_OK on success. A DB_Error object is returned if
* problems arise.
*
* @see DB_common::dropSequence(), DB_common::getSequenceName(),
* DB_common::nextID()
* @access public
*/
function createSequence($seq_name)
{
return $this->raiseError(DB_ERROR_NOT_CAPABLE);
}
 
// }}}
// {{{ dropSequence()
 
/**
* Deletes a sequence
*
* @param string $seq_name name of the sequence to be deleted
*
* @return int DB_OK on success. DB_Error if problems.
*
* @see DB_common::createSequence(), DB_common::getSequenceName(),
* DB_common::nextID()
* @access public
*/
function dropSequence($seq_name)
{
return $this->raiseError(DB_ERROR_NOT_CAPABLE);
}
 
// }}}
// {{{ tableInfo()
 
/**
* Returns information about a table or a result set
*
* The format of the resulting array depends on which <var>$mode</var>
* you select. The sample output below is based on this query:
* <pre>
* SELECT tblFoo.fldID, tblFoo.fldPhone, tblBar.fldId
* FROM tblFoo
* JOIN tblBar ON tblFoo.fldId = tblBar.fldId
* </pre>
*
* <ul>
* <li>
*
* <kbd>null</kbd> (default)
* <pre>
* [0] => Array (
* [table] => tblFoo
* [name] => fldId
* [type] => int
* [len] => 11
* [flags] => primary_key not_null
* )
* [1] => Array (
* [table] => tblFoo
* [name] => fldPhone
* [type] => string
* [len] => 20
* [flags] =>
* )
* [2] => Array (
* [table] => tblBar
* [name] => fldId
* [type] => int
* [len] => 11
* [flags] => primary_key not_null
* )
* </pre>
*
* </li><li>
*
* <kbd>DB_TABLEINFO_ORDER</kbd>
*
* <p>In addition to the information found in the default output,
* a notation of the number of columns is provided by the
* <samp>num_fields</samp> element while the <samp>order</samp>
* element provides an array with the column names as the keys and
* their location index number (corresponding to the keys in the
* the default output) as the values.</p>
*
* <p>If a result set has identical field names, the last one is
* used.</p>
*
* <pre>
* [num_fields] => 3
* [order] => Array (
* [fldId] => 2
* [fldTrans] => 1
* )
* </pre>
*
* </li><li>
*
* <kbd>DB_TABLEINFO_ORDERTABLE</kbd>
*
* <p>Similar to <kbd>DB_TABLEINFO_ORDER</kbd> but adds more
* dimensions to the array in which the table names are keys and
* the field names are sub-keys. This is helpful for queries that
* join tables which have identical field names.</p>
*
* <pre>
* [num_fields] => 3
* [ordertable] => Array (
* [tblFoo] => Array (
* [fldId] => 0
* [fldPhone] => 1
* )
* [tblBar] => Array (
* [fldId] => 2
* )
* )
* </pre>
*
* </li>
* </ul>
*
* The <samp>flags</samp> element contains a space separated list
* of extra information about the field. This data is inconsistent
* between DBMS's due to the way each DBMS works.
* + <samp>primary_key</samp>
* + <samp>unique_key</samp>
* + <samp>multiple_key</samp>
* + <samp>not_null</samp>
*
* Most DBMS's only provide the <samp>table</samp> and <samp>flags</samp>
* elements if <var>$result</var> is a table name. The following DBMS's
* provide full information from queries:
* + fbsql
* + mysql
*
* If the 'portability' option has <samp>DB_PORTABILITY_LOWERCASE</samp>
* turned on, the names of tables and fields will be lowercased.
*
* @param object|string $result DB_result object from a query or a
* string containing the name of a table.
* While this also accepts a query result
* resource identifier, this behavior is
* deprecated.
* @param int $mode either unused or one of the tableInfo modes:
* <kbd>DB_TABLEINFO_ORDERTABLE</kbd>,
* <kbd>DB_TABLEINFO_ORDER</kbd> or
* <kbd>DB_TABLEINFO_FULL</kbd> (which does both).
* These are bitwise, so the first two can be
* combined using <kbd>|</kbd>.
* @return array an associative array with the information requested.
* If something goes wrong an error object is returned.
*
* @see DB_common::setOption()
* @access public
*/
function tableInfo($result, $mode = null)
{
/*
* If the DB_<driver> class has a tableInfo() method, that one
* overrides this one. But, if the driver doesn't have one,
* this method runs and tells users about that fact.
*/
return $this->raiseError(DB_ERROR_NOT_CAPABLE);
}
 
// }}}
// {{{ getTables()
 
/**
* @deprecated Deprecated in release 1.2 or lower
*/
function getTables()
{
return $this->getListOf('tables');
}
 
// }}}
// {{{ getListOf()
 
/**
* list internal DB info
* valid values for $type are db dependent,
* often: databases, users, view, functions
*
* @param string $type type of requested info
*
* @return mixed DB_Error or the requested data
*
* @access public
*/
function getListOf($type)
{
$sql = $this->getSpecialQuery($type);
if ($sql === null) { // No support
return $this->raiseError(DB_ERROR_UNSUPPORTED);
} elseif (is_int($sql) || DB::isError($sql)) { // Previous error
return $this->raiseError($sql);
} elseif (is_array($sql)) { // Already the result
return $sql;
}
return $this->getCol($sql); // Launch this query
}
 
// }}}
// {{{ getSpecialQuery()
 
/**
* Returns the query needed to get some backend info
*
* @param string $type What kind of info you want to retrieve
*
* @return string The SQL query string
*
* @access public
*/
function getSpecialQuery($type)
{
return $this->raiseError(DB_ERROR_UNSUPPORTED);
}
 
// }}}
// {{{ _rtrimArrayValues()
 
/**
* Right trim all strings in an array
*
* @param array $array the array to be trimmed (passed by reference)
* @return void
* @access private
*/
function _rtrimArrayValues(&$array)
{
foreach ($array as $key => $value) {
if (is_string($value)) {
$array[$key] = rtrim($value);
}
}
}
 
// }}}
// {{{ _convertNullArrayValuesToEmpty()
 
/**
* Convert all null values in an array to empty strings
*
* @param array $array the array to be de-nullified (passed by reference)
* @return void
* @access private
*/
function _convertNullArrayValuesToEmpty(&$array)
{
foreach ($array as $key => $value) {
if (is_null($value)) {
$array[$key] = '';
}
}
}
 
// }}}
}
 
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
*/
 
?>
/tags/v3.1-blanche-neige/jrest/lib/zip.php
New file
0,0 → 1,190
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
*
* @version $Id: zip.lib.php 10240 2007-04-01 11:02:46Z cybot_tm $
*/
 
/**
* Zip file creation class.
* Makes zip files.
*
* Based on :
*
* http://www.zend.com/codex.php?id=535&single=1
* By Eric Mueller <eric@themepark.com>
*
* http://www.zend.com/codex.php?id=470&single=1
* by Denis125 <webmaster@atlant.ru>
*
* a patch from Peter Listiak <mlady@users.sourceforge.net> for last modified
* date and time of the compressed file
*
* Official ZIP file format: http://www.pkware.com/appnote.txt
*
* @access public
*/
class zipfile
{
/**
* Array to store compressed data
*
* @var array $datasec
*/
var $datasec = array();
 
/**
* Central directory
*
* @var array $ctrl_dir
*/
var $ctrl_dir = array();
 
/**
* End of central directory record
*
* @var string $eof_ctrl_dir
*/
var $eof_ctrl_dir = "\x50\x4b\x05\x06\x00\x00\x00\x00";
 
/**
* Last offset position
*
* @var integer $old_offset
*/
var $old_offset = 0;
 
 
/**
* Converts an Unix timestamp to a four byte DOS date and time format (date
* in high two bytes, time in low two bytes allowing magnitude comparison).
*
* @param integer the current Unix timestamp
*
* @return integer the current date in a four byte DOS format
*
* @access private
*/
function unix2DosTime($unixtime = 0) {
$timearray = ($unixtime == 0) ? getdate() : getdate($unixtime);
 
if ($timearray['year'] < 1980) {
$timearray['year'] = 1980;
$timearray['mon'] = 1;
$timearray['mday'] = 1;
$timearray['hours'] = 0;
$timearray['minutes'] = 0;
$timearray['seconds'] = 0;
} // end if
 
return (($timearray['year'] - 1980) << 25) | ($timearray['mon'] << 21) | ($timearray['mday'] << 16) |
($timearray['hours'] << 11) | ($timearray['minutes'] << 5) | ($timearray['seconds'] >> 1);
} // end of the 'unix2DosTime()' method
 
 
/**
* Adds "file" to archive
*
* @param string file contents
* @param string name of the file in the archive (may contains the path)
* @param integer the current timestamp
*
* @access public
*/
function addFile($data, $name, $time = 0)
{
$name = str_replace('\\', '/', $name);
 
$dtime = dechex($this->unix2DosTime($time));
$hexdtime = '\x' . $dtime[6] . $dtime[7]
. '\x' . $dtime[4] . $dtime[5]
. '\x' . $dtime[2] . $dtime[3]
. '\x' . $dtime[0] . $dtime[1];
eval('$hexdtime = "' . $hexdtime . '";');
 
$fr = "\x50\x4b\x03\x04";
$fr .= "\x14\x00"; // ver needed to extract
$fr .= "\x00\x00"; // gen purpose bit flag
$fr .= "\x08\x00"; // compression method
$fr .= $hexdtime; // last mod time and date
 
// "local file header" segment
$unc_len = strlen($data);
$crc = crc32($data);
$zdata = gzcompress($data);
$zdata = substr(substr($zdata, 0, strlen($zdata) - 4), 2); // fix crc bug
$c_len = strlen($zdata);
$fr .= pack('V', $crc); // crc32
$fr .= pack('V', $c_len); // compressed filesize
$fr .= pack('V', $unc_len); // uncompressed filesize
$fr .= pack('v', strlen($name)); // length of filename
$fr .= pack('v', 0); // extra field length
$fr .= $name;
 
// "file data" segment
$fr .= $zdata;
 
// "data descriptor" segment (optional but necessary if archive is not
// served as file)
// nijel(2004-10-19): this seems not to be needed at all and causes
// problems in some cases (bug #1037737)
//$fr .= pack('V', $crc); // crc32
//$fr .= pack('V', $c_len); // compressed filesize
//$fr .= pack('V', $unc_len); // uncompressed filesize
 
// add this entry to array
$this -> datasec[] = $fr;
 
// now add to central directory record
$cdrec = "\x50\x4b\x01\x02";
$cdrec .= "\x00\x00"; // version made by
$cdrec .= "\x14\x00"; // version needed to extract
$cdrec .= "\x00\x00"; // gen purpose bit flag
$cdrec .= "\x08\x00"; // compression method
$cdrec .= $hexdtime; // last mod time & date
$cdrec .= pack('V', $crc); // crc32
$cdrec .= pack('V', $c_len); // compressed filesize
$cdrec .= pack('V', $unc_len); // uncompressed filesize
$cdrec .= pack('v', strlen($name)); // length of filename
$cdrec .= pack('v', 0); // extra field length
$cdrec .= pack('v', 0); // file comment length
$cdrec .= pack('v', 0); // disk number start
$cdrec .= pack('v', 0); // internal file attributes
$cdrec .= pack('V', 32); // external file attributes - 'archive' bit set
 
$cdrec .= pack('V', $this -> old_offset); // relative offset of local header
$this -> old_offset += strlen($fr);
 
$cdrec .= $name;
 
// optional extra field, file comment goes here
// save to central directory
$this -> ctrl_dir[] = $cdrec;
} // end of the 'addFile()' method
 
 
/**
* Dumps out file
*
* @return string the zipped file
*
* @access public
*/
function file()
{
$data = implode('', $this -> datasec);
$ctrldir = implode('', $this -> ctrl_dir);
 
return
$data .
$ctrldir .
$this -> eof_ctrl_dir .
pack('v', sizeof($this -> ctrl_dir)) . // total # of entries "on this disk"
pack('v', sizeof($this -> ctrl_dir)) . // total # of entries overall
pack('V', strlen($ctrldir)) . // size of central dir
pack('V', strlen($data)) . // offset to start of central dir
"\x00\x00"; // .zip file comment length
} // end of the 'file()' method
 
} // end of the 'zipfile' class
?>
/tags/v3.1-blanche-neige/jrest
New file
Property changes:
Added: svn:ignore
+jrest.ini.php
/tags/v3.1-blanche-neige/bazar.interne.css
New file
0,0 → 1,361
/*
+----------------------------------------------------------------------------+
| bazar.css |
+----------------------------------------------------------------------------+
| Copyright (c) 2005 Tela Botanica |
+----------------------------------------------------------------------------+
| Feuille de style interne spécifique a l'application Bazar |
+----------------------------------------------------------------------------+
| Auteur : Jean-Pascal MILCENT <jpm@tela-botanica.org> |
+----------------------------------------------------------------------------+
*/
 
/**
Spécifique à téla mais cette modif est mise ici
pour qu'en cas de problème le css ne soit modifié que dans les
pages contenant bazar
**/
#actualites #zone-droite {
overflow:visible;
}
 
#formulaire input, #formulaire textarea, #formulaire select {
border:1px solid #000;
background-color:#fefffe;}
input[type ^="submit"]:hover{
background-color:#b0cdfc;}
.enligne {
padding:0;
margin:0;
display:inline;
list-style:none;
list-style-type:none;
background:#FFF;}
 
/*-------------Les fiches Bazar-------------------------------------------------*/
.BAZ_cadre_fiche{
max-width:600px;
width:auto;
height:auto;
padding:10px;
border: 1px solid #7B9C35;}
.BAZ_cadre_map {
padding:0;
height:250px;
width:400px;
overflow:auto;}
 
 
.BAZ_cadre_map .BAZ_cadre_fiche{
padding:0 2px 2px 2px;}
.BAZ_cadre_map .BAZ_fiche_titre, .BAZ_cadre_map .BAZ_fiche{
font-size:13px;
}
.BAZ_fiche_titre_expo, .BAZ_fiche_titre_sortie, .BAZ_fiche_titre_formation, .BAZ_fiche_titre_evenement {
text-transform:none;}
#map{
min-height:600px;}
#fiche_image{
float:left;
height:150px;
width:210px;
margin:0 10px 0 0}
#fiche_image, .BAZ_cadre_fiche{
background-color:#fefffe;
-moz-border-radius:10px;}
#fiche_titre {
background:transparent;
border-bottom:1px solid black;
color:#1A4881;}
.bulle_bas{
height:0;}
.BAZ_infos_fiche{
margin:0;
padding:0;
font-size:10px;
color:gray;}
.centrer {
clear:both;
margin:0 auto;}
.BAZ_rubrique {
padding: 5px 0;}
.BAZ_label {
text-align:left;
color: #3A3633;}
.rubrique_bulle {
width:90px;
text-align:left;
font: bold 15px arial, sans-serif;
color: #000;}
.BAZ_texte{
font-weight:bold;}
.description ul{
margin:0;}
.infos {
width:70%;
float:left;
min-height:120px;
font: bold 15px arial, sans-serif;
color:#B1BB7E;
line-height:25px;}
.bazar_checkbox {
float:left;
width:170px;
font:10px arial, sans-serif;
border:0;}
.lien_wikini{
margin:0;
padding:10px 5px;
border:2px solid #DBE8C8;
-moz-border-radius:10px;
background:#3082AA;}
div.lien_wikini a{
padding-left:100px;
color:#FFF;}
#bazar_commentaire {
max-width: 600 px;
width: auto;
}
 
#BAZ_bas_page, #BAZ_bas_page .rubrique{
font-size:10px;
text-decoration:none;
color:gray;}
#BAZ_bas_page .rubrique{
display:inline;
clear:both;}
 
#formation_qualifiante {
float:right;
margin:0 -15px 0 5px;
height:190px;
width:30px;
background:url(images/BAZ_formation_qualifiante.gif) bottom right no-repeat;}
#formation_diplomante {
float:right;
margin:0 -15px 0 5px;
height:190px;
width:30px;
background:url(images/BAZ_formation_diplomante.gif) bottom right no-repeat;}
#formation_continue {
float:right;
margin:0 -15px 0 5px;
height:190px;
width:30px;
background:url(images/BAZ_formation_continue.gif) bottom right no-repeat;}
 
.table_bazar{
width:300px;
margin:2em 0 0 0;}
#table_bazar{
border-spacing:0;
text-align:center;
border: 1px solid black;}
#table_bazar th{
color:white;
background-color:#598ac4;
padding:0 5px;
text-align:center;
border-bottom: 1px dotted grey;
border-left: 1px dotted grey;}
#table_bazar td {
padding:2px;
text-align:left;
border-bottom: 1px dotted grey;
border-left: 1px dotted grey;}
#table_bazar .ligne_paire{
background-color:#c8ddff;}
.table_bazar #col2, .table_bazar #col3, #laius_abonnement{
display:none;}
.table_bazar #col1,.table_bazar #col4{
width:150px;}
 
.BAZ_actions_fiche ul{
list-style-type:none;}
.BAZ_actions_fiche a{
display:block;
text-align:center;
width:200px;
border: 1px solid black;
padding:3px;
font-size:14px;
background:#fefffe;}
.BAZ_actions_fiche a:hover{
background-color:#b0cdfc;}
#bf_description_description {font-weight:normal;}
/* CALENDRIER */
#cal_entete{
display:block;
background:transparent url(/client/bazar/images/cal_titre_fond-grey.png) repeat-x;
margin:10px 0;
height:31px;
min-width:300px;
border-left: 2px solid #C3C0AD;
border-right: 2px solid #C3C0AD;
position: relative;
}
#cal_titre{
position:absolute;
background:transparent;
top:0;
margin-top: 10px;
right:20px;
width:182px;}
#cal_navigation{
display:block;
position:absolute;
background:transparent;
top:10px;
left:20px;}
#cal_precedent_lien, #cal_suivant_lien{
display:block;
position:absolute;
top:2px;
background:transparent;}
#cal_suivant_lien img, #cal_precedent_lien img{
display:block;
border:0;}
#cal_precedent_lien:hover, #cal_suivant_lien:hover, #cal_mois_courrant:hover{
background-color:#b0cdfc;}
#cal_precedent_lien{
left:15px;}
#cal_mois_courrant{
display:block;
position:absolute;
top:4px;
left:40px;
width:110px;
padding:2px 25px;
background-color:#fff;
border:1px inset #113054;
text-align:center;
text-transform:uppercase;
font: bold 14px 'Arial narrow', arial, sans-serif;}
#cal_suivant_lien{
left:205px;}
.calendrier{
font: bold 16px 'Arial narrow', Arial, sans-serif;
border-collapse:separate;
border-spacing:2px;
width:960px; /* pour éviter que le calcul des largeurs des colonnes n'aboutisse à des valeurs différentes et que "dimanche" soit plus fin */
}
/* Problème de la couleur entre les cellules...
.calendrier tbody{
background:white url(/client/bazar/images/cal_img_fond.jpg) 2px 40px repeat-y;}*/
.calendrier th, .calendrier_applette th {
color:white;
background-color:#C3C0AD;
border: 1px solid #113054;
text-align:center;}
.calendrier th {
height:20px;
width:14%;
border-width:2px;}
.calendrier td {
height:83px;
width:14%;
border:2px solid #4c4c4c;
vertical-align:top;
text-align:left;
-moz-border-radius:3px;}
.cal_samedi, .cal_dimanche{
background-color:#fff9e7;}
.cal_j{
display:block;
float:right;
padding:2px;}
.cal_jc{
background-color:#c4d9fb;}
.cal_ma{
background-color:#eaeaec;}
.cal_evenemt_liste{
font: normal 10px Arial, sans-serif;
list-style-type:none;
margin:20px 0 0 0;
padding:0;}
.cal_evenemt_liste li{
background:transparent url(/client/bazar/images/cal_pastille.png) top left no-repeat !important;
display:block;
padding-bottom: 10px;
padding-top: 2px;
margin-left: 5px;
}
 
.cal_evenemt_liste li a {
padding-left: 20px;
padding-bottom: 5px;
}
 
.cal_evenemt_liste .nature_1{
background:transparent url(/client/bazar/images/drapeau_bleu.png) top left no-repeat !important;}
.filtre_1{
background-color:#7CCCFF;}
.cal_evenemt_liste .nature_2{
background:transparent url(/client/bazar/images/drapeau_vert.png) top left no-repeat !important;}
.filtre_2{
background-color:#7ACD69;}
.cal_evenemt_liste .nature_3{
background:transparent url(/client/bazar/images/drapeau_orange.png) top left no-repeat !important;}
.filtre_3{
background-color:#FFAA5D;}
.cal_evenemt_liste .nature_4{
background:transparent url(/client/bazar/images/drapeau_rose.png) top left no-repeat !important;}
.filtre_4{
background-color:#FF81EA;}
.cal_evenemt{
margin:0 0 0 0px;
padding:0;}
/* Pour la biblioth�que JS DomToolTip */
div.niceTitle {
background-color: #333333;
color: #FFFFFF;
font-weight: bold;
font-size: 13px;
font-family: "Trebuchet MS", sans-serif;
width: 250px;
left: 0;
top: 0;
padding: 4px;
position: absolute;
text-align: left;
z-index: 20;
-moz-border-radius: 0 10px 10px 10px;
filter: progid:DXImageTransform.Microsoft.Alpha(opacity=87);
-moz-opacity: .87;
-khtml-opacity: .87;
opacity: .87;}
div.niceTitle .contents {
margin: 0;
padding: 0 3px;
filter: progid:DXImageTransform.Microsoft.Alpha(opacity=100);
-moz-opacity: 1;
-khtml-opacity: 1;
opacity: 1;}
div.niceTitle p {
width: 250px;
color: #D17E62;
font-size: 9px;
padding: 3px 0 0 0;
margin: 0;
text-align: left;
-moz-opacity: 1;}
.bouton_valider {
color:#7B9C35;
font-size: 14px;
width: 208px;
background-color:#FFFFFF;
border:1px solid;
border-color: #000000;
}
 
#label_validite {
padding-right: 7px;
}
 
#date_validite {
width: 100px;
}
/tags/v3.1-blanche-neige/bazar.desinscription.inc.php
New file
0,0 → 1,71
<?php
/*vim: set expandtab tabstop=4 shiftwidth=4: */
// +------------------------------------------------------------------------------------------------------+
// | PHP version 4.1 |
// +------------------------------------------------------------------------------------------------------+
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org) |
// +------------------------------------------------------------------------------------------------------+
// | This library is free software; you can redistribute it and/or |
// | modify it under the terms of the GNU Lesser General Public |
// | License as published by the Free Software Foundation; either |
// | version 2.1 of the License, or (at your option) any later version. |
// | |
// | This library is distributed in the hope that it will be useful, |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
// | Lesser General Public License for more details. |
// | |
// | You should have received a copy of the GNU Lesser General Public |
// | License along with this library; if not, write to the Free Software |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
// +------------------------------------------------------------------------------------------------------+
// CVS : $Id: bazar.desinscription.inc.php,v 1.3 2007-04-11 08:30:12 neiluj Exp $
/**
*
*@package bazar
//Auteur original :
*@author Alexandre GRANIER <alexandre@tela-botanica.org>
*@author Florian Schmitt <florian@ecole-et-nature.org>
//Autres auteurs :
*@copyright Tela-Botanica 2000-2005
*@version $Revision: 1.3 $
// +------------------------------------------------------------------------------------------------------+
*/
/* Ce programme est appelé depuis inscription.php et
* se situe dans la fonction afficherContenuCorps()
*/
// +------------------------------------------------------------------------------------------------------+
// | LES CONSTANTES DES ACTIONS DE BAZAR |
// +------------------------------------------------------------------------------------------------------+
 
// +------------------------------------------------------------------------------------------------------+
// | ENTETE du PROGRAMME |
// +------------------------------------------------------------------------------------------------------+
 
// Suppression des entrée dans bazar_droits
$requete = 'DELETE FROM bazar_droits WHERE bd_id_utilisateur='.$id_utilisateur ;
$resultat = $GLOBALS['ins_db']->query($requete) ;
 
if (DB::isError($resultat)) {
echo 'Erreur dans la requete sur bazar_droits<br />'.$requete.'<br />'.$resultat->getMessage() ;
}
// +------------------------------------------------------------------------------------------------------+
// | LISTE de FONCTIONS |
// +------------------------------------------------------------------------------------------------------+
 
/* +--Fin du code ----------------------------------------------------------------------------------------+
*
* $Log: bazar.desinscription.inc.php,v $
* Revision 1.3 2007-04-11 08:30:12 neiluj
* remise en état du CVS...
*
* Revision 1.1.4.1 2007/03/07 16:53:45 jp_milcent
* Mise en majuscule des mots réservés par SQL
*
* Revision 1.1 2005/09/29 16:14:17 alexandre_tb
* version initiale
*
*
* +-- Fin du code ----------------------------------------------------------------------------------------+
*/
?>
/tags/v3.1-blanche-neige/bazar_calendrier.applette.php
New file
0,0 → 1,79
<?php
/*vim: set expandtab tabstop=4 shiftwidth=4: */
// Copyright (C) 1999-2004 Tela Botanica (accueil@tela-botanica.org)
//
// Ce logiciel est un programme informatique servant � g�rer du contenu et des
// applications web.
// Ce logiciel est r�gi par la licence CeCILL soumise au droit fran�ais et
// respectant les principes de diffusion des logiciels libres. Vous pouvez
// utiliser, modifier et/ou redistribuer ce programme sous les conditions
// de la licence CeCILL telle que diffus�e par le CEA, le CNRS et l'INRIA
// sur le site "http://www.cecill.info".
 
// En contrepartie de l'accessibilit� au code source et des droits de copie,
// de modification et de redistribution accord�s par cette licence, il n'est
// offert aux utilisateurs qu'une garantie limit�e. Pour les m�mes raisons,
// seule une responsabilit� restreinte p�se sur l'auteur du programme, le
// titulaire des droits patrimoniaux et les conc�dants successifs.
 
// A cet �gard l'attention de l'utilisateur est attir�e sur les risques
// associ�s au chargement, � l'utilisation, � la modification et/ou au
// d�veloppement et � la reproduction du logiciel par l'utilisateur �tant
// donn� sa sp�cificit� de logiciel libre, qui peut le rendre complexe �
// manipuler et qui le r�serve donc � des d�veloppeurs et des professionnels
// avertis poss�dant des connaissances informatiques approfondies. Les
// utilisateurs sont donc invit�s � charger et tester l'ad�quation du
// logiciel � leurs besoins dans des conditions permettant d'assurer la
// s�curit� de leurs syst�mes et ou de leurs donn�es et, plus g�n�ralement,
// � l'utiliser et l'exploiter dans les m�mes conditions de s�curit�.
 
// Le fait que vous puissiez acc�der � cet en-t�te signifie que vous avez
// pris connaissance de la licence CeCILL, et que vous en avez accept� les
// termes.
// ----
// CVS : $Id: bazar_calendrier.applette.php,v 1.1 2007-06-25 12:37:09 alexandre_tb Exp $
/**
* bazar_calendrier : programme affichant les evenements du bazar sous forme de Calendrier
*
*
*@package Bazar
//Auteur original :
*@author David DELON <david.delon@clapas.net>
*@version $Revision: 1.1 $ $Date: 2007-06-25 12:37:09 $
// +------------------------------------------------------------------------------------------------------+
*/
 
if (!defined('BAZ_VOIR_FICHE')) {
define ('BAZ_VOIR_FICHE', 8);
}
 
include_once 'configuration/baz_config.inc.php'; //fichier de configuration de Bazar
include_once 'bibliotheque/bazar.fonct.php'; //fichier des fonctions de Bazar
 
include_once 'bibliotheque/bazar.fonct.cal.php'; //fichier des fonctions de Bazar
 
 
 
$GLOBALS['_CAL_']['nom_fonction'] = 'afficherCalendrier';
$GLOBALS['_GEN_commun']['info_applette_nom_fonction'] = $GLOBALS['_CAL_']['nom_fonction'];
// Balise : CLIENT_BAZAR_CALENDRIER
$GLOBALS['_GEN_commun']['info_applette_balise'] = '(?:<!-- '.$GLOBALS['_GEN_commun']['balise_prefixe_client'].'(BAZAR_CALENDRIER) -->|'.
'\{\{[Bb]azarCalendrier' .
'(?:\s*' .
'(?:' .
'(template="[^"]*")|' .
')' .
')+' .
'\s*\}\})';
function afficherCalendrier($arguments) {
if (defined('PAP_VERSION')) {
GEN_stockerFichierScript('domLib', '/api/js/domtooltip/domLib.js');
GEN_stockerFichierScript('domTT', '/api/js/domtooltip/domTT.js');
}
 
return GestionAffichageCalendrier($arguments, 'calendrier_applette');
}
?>
/tags/v3.1-blanche-neige/bazar.calendrier.php
New file
0,0 → 1,62
<?php
/*vim: set expandtab tabstop=4 shiftwidth=4: */
// Copyright (C) 1999-2004 Tela Botanica (accueil@tela-botanica.org)
//
// Ce logiciel est un programme informatique servant à gérer du contenu et des
// applications web.
// Ce logiciel est régi par la licence CeCILL soumise au droit français et
// respectant les principes de diffusion des logiciels libres. Vous pouvez
// utiliser, modifier et/ou redistribuer ce programme sous les conditions
// de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA
// sur le site "http://www.cecill.info".
 
// En contrepartie de l'accessibilité au code source et des droits de copie,
// de modification et de redistribution accordés par cette licence, il n'est
// offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons,
// seule une responsabilité restreinte pèse sur l'auteur du programme, le
// titulaire des droits patrimoniaux et les concédants successifs.
 
// A cet égard l'attention de l'utilisateur est attirée sur les risques
// associés au chargement, à l'utilisation, à la modification et/ou au
// développement et à la reproduction du logiciel par l'utilisateur étant
// donné sa spécificité de logiciel libre, qui peut le rendre complexe à
// manipuler et qui le réserve donc à des développeurs et des professionnels
// avertis possédant des connaissances informatiques approfondies. Les
// utilisateurs sont donc invités à charger et tester l'adéquation du
// logiciel à leurs besoins dans des conditions permettant d'assurer la
// sécurité de leurs systèmes et ou de leurs données et, plus généralement,
// à l'utiliser et l'exploiter dans les mêmes conditions de sécurité.
 
// Le fait que vous puissiez accéder à cet en-tête signifie que vous avez
// pris connaissance de la licence CeCILL, et que vous en avez accepté les
// termes.
// ----
// CVS : $Id: bazar.calendrier.php,v 1.10 2007/04/11 08:30:12 neiluj Exp $
/**
* bazar_calendrier : programme affichant les evenements du bazar sous forme de Calendrier
*
*
*@package Bazar
//Auteur original :
*@author David DELON <david.delon@clapas.net>
*@version $Revision: 1.10 $ $Date: 2007/04/11 08:30:12 $
// +------------------------------------------------------------------------------------------------------+
*/
if (!defined('BAZ_VOIR_FICHE')) {
define ('BAZ_VOIR_FICHE', 8);
}
include_once 'configuration/baz_config.inc.php'; //fichier de configuration de Bazar
include_once 'bibliotheque/bazar.fonct.php'; //fichier des fonctions de Bazar
 
 
include_once 'bibliotheque/bazar.fonct.cal.php'; //fichier des fonctions de Bazar
 
 
function afficherContenuCorps() {
return GestionAffichageCalendrier('calendrier');
}
?>
/tags/v3.1-blanche-neige/template_moteur_recherche.txt
New file
0,0 → 1,6
echo $formtemplate->toHTML();
if (!isset($_REQUEST['recherche_effectuee'])) { ?>
<p class="zone_info">Pr&eacute;cisez vos crit&egrave;res de recherche et appuyez sur le bouton "Rechercher" pour consulter les fiches.
</p>
{{Syndication titre="Derni&egrave;res actualités" url="http://www.tela-botanica.org/papyrus.php?menu=441&action=18" nb="10" nouvellefenetre="0" formatdate="jma" template="synd_liste_evenement.tpl.html"}}
<?php } ?>
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/tags/v3.1-blanche-neige/index.php
New file
0,0 → 1,69
<?php
/*vim: set expandtab tabstop=4 shiftwidth=4: */
// +------------------------------------------------------------------------------------------------------+
// | PHP version 4.1 |
// +------------------------------------------------------------------------------------------------------+
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org) |
// +------------------------------------------------------------------------------------------------------+
// | This library is free software; you can redistribute it and/or |
// | modify it under the terms of the GNU Lesser General Public |
// | License as published by the Free Software Foundation; either |
// | version 2.1 of the License, or (at your option) any later version. |
// | |
// | This library is distributed in the hope that it will be useful, |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
// | Lesser General Public License for more details. |
// | |
// | You should have received a copy of the GNU Lesser General Public |
// | License along with this library; if not, write to the Free Software |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
// +------------------------------------------------------------------------------------------------------+
// CVS : $Id: index.php,v 1.5 2005/11/30 13:58:45 florian Exp $
/**
* Index
*
* Première page chargée du répertoire de l'appli bazar. Sert à tester l'appli
*
*@package bazar
//Auteur original :
*@author Alexandre GRANIER <alexandre@tela-botanica.org>
*@author Florian SCHMITT <florian@ecole-et-nature.org>
//Autres auteurs :
*@copyright Tela-Botanica 2000-2004
*@version $Revision: 1.5 $ $Date: 2005/11/30 13:58:45 $
// +------------------------------------------------------------------------------------------------------+
*/
 
// +------------------------------------------------------------------------------------------------------+
// | CORPS du PROGRAMME |
// +------------------------------------------------------------------------------------------------------+
 
include "bazar.php";
echo afficherContenuCorps();
 
/* +--Fin du code ----------------------------------------------------------------------------------------+
*
* $Log: index.php,v $
* Revision 1.5 2005/11/30 13:58:45 florian
* ajouts graphisme (logos, boutons), changement structure SQL bazar_fiche
*
* Revision 1.4 2005/07/21 19:03:12 florian
* nouveautés bazar: templates fiches, correction de bugs, ...
*
* Revision 1.2 2005/02/22 15:34:04 florian
* integration dans Papyrus
*
* Revision 1.1.1.1 2005/02/17 18:05:11 florian
* Import initial de Bazar
*
* Revision 1.1.1.1 2005/02/17 11:09:50 florian
* Import initial
*
* Revision 1.1.1.1 2005/02/16 18:06:35 florian
* import de la nouvelle version
*
*
* +-- Fin du code ----------------------------------------------------------------------------------------+
*/
?>
/tags/v3.1-blanche-neige/bazar.fonct.php
New file
0,0 → 1,1841
<?php
/*vim: set expandtab tabstop=4 shiftwidth=4: */
// +------------------------------------------------------------------------------------------------------+
// | PHP version 4.1 |
// +------------------------------------------------------------------------------------------------------+
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org) |
// +------------------------------------------------------------------------------------------------------+
// | This library is free software; you can redistribute it and/or |
// | modify it under the terms of the GNU Lesser General Public |
// | License as published by the Free Software Foundation; either |
// | version 2.1 of the License, or (at your option) any later version. |
// | |
// | This library is distributed in the hope that it will be useful, |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
// | Lesser General Public License for more details. |
// | |
// | You should have received a copy of the GNU Lesser General Public |
// | License along with this library; if not, write to the Free Software |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
// +------------------------------------------------------------------------------------------------------+
// CVS : $Id: bazar.fonct.php,v 1.79 2008-10-29 10:41:48 alexandre_tb Exp $
/**
*
* Fonctions du module bazar
*
*
*@package bazar
//Auteur original :
*@author Alexandre Granier <alexandre@tela-botanica.org>
*@author Florian Schmitt <florian@ecole-et-nature.org>
//Autres auteurs :
*@copyright Tela-Botanica 2000-2004
*@version $Revision: 1.79 $ $Date: 2008-10-29 10:41:48 $
// +------------------------------------------------------------------------------------------------------+
*/
 
// +------------------------------------------------------------------------------------------------------+
// | ENTETE du PROGRAMME |
// +------------------------------------------------------------------------------------------------------+
require_once PAP_CHEMIN_API_PEAR.'HTML/QuickForm.php' ;
require_once PAP_CHEMIN_API_PEAR.'HTML/QuickForm/checkbox.php' ;
require_once PAP_CHEMIN_API_PEAR.'HTML/QuickForm/textarea.php' ;
require_once PAP_CHEMIN_API_PEAR.'HTML/Table.php' ;
require_once GEN_CHEMIN_API.'formulaire/formulaire.fonct.inc.php';
require_once 'bazar.fonct.rss.php';
 
 
/** fiches_a_valider () - Renvoie les annonces restant a valider par un administrateur
*
* @return string HTML
*/
function fiches_a_valider() {
 
if ($GLOBALS['AUTH']->getAuth()) {
// Pour les administrateurs d'une rubrique, on affiche les fiches a valider de cette rubrique
// On effectue une requete sur le bazar pour voir les fiches a administrer
$GLOBALS['_BAZAR_']['url']->addQueryString(BAZ_VARIABLE_VOIR, BAZ_VOIR_ADMIN);
$res= '<h2>'.BAZ_ANNONCES_A_ADMINISTRER.'</h2><br />'."\n";
$requete = 'SELECT * FROM bazar_fiche, bazar_nature WHERE bf_statut_fiche=0 AND ' .
'bn_id_nature=bf_ce_nature AND bn_ce_id_menu IN ('.$GLOBALS['_BAZAR_']['categorie_nature'].') ' ;
if (isset($GLOBALS['_BAZAR_']['langue'])) {
$requete .= ' and bn_ce_i18n like "'.$GLOBALS['_BAZAR_']['langue'].'%" ';
}
$requete .= 'ORDER BY bf_date_maj_fiche DESC' ;
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
die ('Echec de la requete<br />'.$resultat->getMessage().'<br />'.$resultat->getDebugInfo()) ;
}
if ($resultat->numRows() != 0) {
$tableAttr = array('id' => 'table_bazar') ;
$table = new HTML_Table($tableAttr) ;
$entete = array (BAZ_TITREANNONCE ,BAZ_ANNONCEUR, BAZ_TYPEANNONCE, BAZ_PUBLIER, BAZ_SUPPRIMER) ;
$table->addRow($entete) ;
$table->setRowType (0, 'th') ;
// On affiche une ligne par proposition
while ($ligne = $resultat->fetchRow (DB_FETCHMODE_ASSOC)) {
//Requete pour trouver le nom et prenom de l'annonceur
$requetenomprenom = 'SELECT '.BAZ_CHAMPS_PRENOM.', '.BAZ_CHAMPS_NOM.' FROM '.BAZ_ANNUAIRE.
' WHERE '.BAZ_CHAMPS_ID.'='.$ligne['bf_ce_utilisateur'] ;
$resultatnomprenom = $GLOBALS['_BAZAR_']['db']->query ($requetenomprenom) ;
if (DB::isError($resultatnomprenom)) {
echo ("Echec de la requete<br />".$resultatnomprenom->getMessage()."<br />".$resultatnomprenom->getDebugInfo()) ;
}
while ($lignenomprenom = $resultatnomprenom->fetchRow (DB_FETCHMODE_ASSOC)) {
$annonceur=$lignenomprenom[BAZ_CHAMPS_PRENOM]." ".$lignenomprenom[BAZ_CHAMPS_NOM];
}
$lien_voir=$GLOBALS['_BAZAR_']['url'];
$lien_voir->addQueryString(BAZ_VARIABLE_ACTION, BAZ_VOIR_FICHE);
$lien_voir->addQueryString('id_fiche', $ligne['bf_id_fiche']);
$lien_voir->addQueryString('typeannonce', $ligne['bn_id_nature']);
// Nettoyage de l'url
// NOTE (jpm - 23 mai 2007): pour être compatible avec PHP5 il faut utiliser tjrs $GLOBALS['_BAZAR_']['url'] car en php4 on
// copie bien une variable mais pas en php5, cela reste une référence...
$GLOBALS['_BAZAR_']['url']->removeQueryString('action');
$GLOBALS['_BAZAR_']['url']->removeQueryString('id_fiche');
$GLOBALS['_BAZAR_']['url']->removeQueryString('typeannonce');
$GLOBALS['_BAZAR_']['url']->addQueryString('id_fiche', $ligne['bf_id_fiche']);
$GLOBALS['_BAZAR_']['url']->addQueryString('typeannonce', $ligne['bn_id_nature']);
$GLOBALS['_BAZAR_']['url']->addQueryString(BAZ_VARIABLE_ACTION, BAZ_VOIR_FICHE);
$lien_voir = $GLOBALS['_BAZAR_']['url']->getURL();
$GLOBALS['_BAZAR_']['url']->removeQueryString(BAZ_VARIABLE_ACTION);
 
$GLOBALS['_BAZAR_']['url']->addQueryString(BAZ_VARIABLE_ACTION, BAZ_ACTION_PUBLIER);
$lien_publie_oui = $GLOBALS['_BAZAR_']['url']->getURL();
$GLOBALS['_BAZAR_']['url']->removeQueryString(BAZ_VARIABLE_ACTION);
$GLOBALS['_BAZAR_']['url']->addQueryString(BAZ_VARIABLE_ACTION, BAZ_ACTION_PAS_PUBLIER);
$lien_publie_non = $GLOBALS['_BAZAR_']['url']->getURL();
$GLOBALS['_BAZAR_']['url']->removeQueryString(BAZ_VARIABLE_ACTION);
$GLOBALS['_BAZAR_']['url']->addQueryString(BAZ_VARIABLE_ACTION, BAZ_ACTION_SUPPRESSION);
$lien_supprimer = $GLOBALS['_BAZAR_']['url']->getURL();
$GLOBALS['_BAZAR_']['url']->removeQueryString(BAZ_VARIABLE_ACTION);
$GLOBALS['_BAZAR_']['url']->removeQueryString('id_fiche');
$GLOBALS['_BAZAR_']['url']->removeQueryString('typeannonce');
$table->addRow (array(
'<a href="'.$lien_voir.'">'.$ligne['bf_titre'].'</a>'."\n", // col 1 : le nom
$annonceur."\n", // col 2 : annonceur
$ligne['bn_label_nature']."\n", // col 3 : type annonce
"<a href=\"".$lien_publie_oui."\">".BAZ_OUI."</a> / \n".
"<a href=\"".$lien_publie_non."\">".BAZ_NON."</a>", // col 4 : publier ou pas
"<a href=\"".$lien_supprimer."\"".
" onclick=\"javascript:return confirm('".BAZ_CONFIRMATION_SUPPRESSION."');\">".BAZ_SUPPRIMER."</a>\n")) ; // col 5 : supprimer
}
$table->altRowAttributes(1, array("class" => "ligne_impaire"), array("class" => "ligne_paire"));
$table->updateColAttributes(1, array("align" => "center"));
$table->updateColAttributes(2, array("align" => "center"));
$table->updateColAttributes(3, array("align" => "center"));
$table->updateColAttributes(4, array("align" => "center"));
$res .= $table->toHTML() ;
}
else {
$res .= '<p class="zone_info">'.BAZ_PAS_DE_FICHE_A_VALIDER.'</p>'."\n" ;
}
$GLOBALS['_BAZAR_']['url']->addQueryString(BAZ_VARIABLE_ACTION, BAZ_VOIR_TOUTES_ANNONCES);
//$res .= '<br /><ul style="clear:both;"><li><a href="'.$GLOBALS['_BAZAR_']['url']->getURL().'" title="'.BAZ_CONSULTER_FICHES_VALIDEES.'">'.BAZ_CONSULTER_FICHES_VALIDEES.'</a></li></ul>';
 
// Nettoyage de l'url
$GLOBALS['_BAZAR_']['url']->removeQueryString(BAZ_VARIABLE_ACTION);
$GLOBALS['_BAZAR_']['url']->removeQueryString('id_fiche');
$GLOBALS['_BAZAR_']['url']->removeQueryString('typeannonce');
// Les autres fiches, deja validees
$res .= '<h2>'.BAZ_TOUTES_LES_FICHES.'</h2>'."\n";
$requete = 'SELECT * FROM bazar_fiche, bazar_nature WHERE bf_statut_fiche=1 AND ' .
'bn_id_nature=bf_ce_nature AND bn_ce_id_menu IN ('.$GLOBALS['_BAZAR_']['categorie_nature'].') ';
if (isset($GLOBALS['_BAZAR_']['langue'])) {
$requete .= ' and bn_ce_i18n like "'.$GLOBALS['_BAZAR_']['langue'].'%" ';
}
$requete .= 'ORDER BY bf_date_maj_fiche DESC' ;
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
die ('Echec de la requete<br />'.$resultat->getMessage().'<br />'.$resultat->getDebugInfo()) ;
}
if ($resultat->numRows() != 0) {
$tableAttr = array('id' => 'table_bazar') ;
$table = new HTML_Table($tableAttr) ;
$entete = array (BAZ_TITREANNONCE ,BAZ_ANNONCEUR, BAZ_TYPEANNONCE, BAZ_PUBLIER, BAZ_SUPPRIMER) ;
$table->addRow($entete) ;
$table->setRowType (0, 'th') ;
// On affiche une ligne par proposition
while ($ligne = $resultat->fetchRow (DB_FETCHMODE_ASSOC)) {
//Requete pour trouver le nom et prenom de l'annonceur
$requetenomprenom = 'SELECT '.BAZ_CHAMPS_PRENOM.', '.BAZ_CHAMPS_NOM.' FROM '.BAZ_ANNUAIRE.
' WHERE '.BAZ_CHAMPS_ID.'='.$ligne['bf_ce_utilisateur'] ;
$resultatnomprenom = $GLOBALS['_BAZAR_']['db']->query ($requetenomprenom) ;
if (DB::isError($resultatnomprenom)) {
echo ("Echec de la requete<br />".$resultatnomprenom->getMessage()."<br />".$resultatnomprenom->getDebugInfo()) ;
}
while ($lignenomprenom = $resultatnomprenom->fetchRow (DB_FETCHMODE_ASSOC)) {
$annonceur=$lignenomprenom[BAZ_CHAMPS_PRENOM]." ".$lignenomprenom[BAZ_CHAMPS_NOM];
}
$lien_voir=$GLOBALS['_BAZAR_']['url'];
$lien_voir->addQueryString(BAZ_VARIABLE_ACTION, BAZ_VOIR_FICHE);
$lien_voir->addQueryString('id_fiche', $ligne['bf_id_fiche']);
$lien_voir->addQueryString('typeannonce', $ligne['bn_id_nature']);
// Nettoyage de l'url
// NOTE (jpm - 23 mai 2007): pour être compatible avec PHP5 il faut utiliser tjrs $GLOBALS['_BAZAR_']['url'] car en php4 on
// copie bien une variable mais pas en php5, cela reste une référence...
$GLOBALS['_BAZAR_']['url']->removeQueryString(BAZ_VARIABLE_ACTION);
$GLOBALS['_BAZAR_']['url']->removeQueryString('id_fiche');
$GLOBALS['_BAZAR_']['url']->removeQueryString('typeannonce');
$GLOBALS['_BAZAR_']['url']->addQueryString('id_fiche', $ligne['bf_id_fiche']);
$GLOBALS['_BAZAR_']['url']->addQueryString('typeannonce', $ligne['bn_id_nature']);
$GLOBALS['_BAZAR_']['url']->addQueryString(BAZ_VARIABLE_ACTION, BAZ_VOIR_FICHE);
$lien_voir = $GLOBALS['_BAZAR_']['url']->getURL();
$GLOBALS['_BAZAR_']['url']->removeQueryString(BAZ_VARIABLE_ACTION);
 
$GLOBALS['_BAZAR_']['url']->addQueryString(BAZ_VARIABLE_ACTION, BAZ_ACTION_PUBLIER);
$lien_publie_oui = $GLOBALS['_BAZAR_']['url']->getURL();
$GLOBALS['_BAZAR_']['url']->removeQueryString(BAZ_VARIABLE_ACTION);
$GLOBALS['_BAZAR_']['url']->addQueryString(BAZ_VARIABLE_ACTION, BAZ_ACTION_PAS_PUBLIER);
$lien_publie_non = $GLOBALS['_BAZAR_']['url']->getURL();
$GLOBALS['_BAZAR_']['url']->removeQueryString(BAZ_VARIABLE_ACTION);
$GLOBALS['_BAZAR_']['url']->addQueryString(BAZ_VARIABLE_ACTION, BAZ_ACTION_SUPPRESSION);
$lien_supprimer = $GLOBALS['_BAZAR_']['url']->getURL();
$GLOBALS['_BAZAR_']['url']->removeQueryString(BAZ_VARIABLE_ACTION);
$GLOBALS['_BAZAR_']['url']->removeQueryString('id_fiche');
$GLOBALS['_BAZAR_']['url']->removeQueryString('typeannonce');
$table->addRow (array(
'<a href="'.$lien_voir.'">'.$ligne['bf_titre'].'</a>'."\n", // col 1 : le nom
$annonceur."\n", // col 2 : annonceur
$ligne['bn_label_nature']."\n", // col 3 : type annonce
"<a href=\"".$lien_publie_oui."\">".BAZ_OUI."</a> / \n".
"<a href=\"".$lien_publie_non."\">".BAZ_NON."</a>", // col 4 : publier ou pas
"<a href=\"".$lien_supprimer."\"".
" onclick=\"javascript:return confirm('".BAZ_CONFIRMATION_SUPPRESSION."');\">".BAZ_SUPPRIMER."</a>\n")) ; // col 5 : supprimer
}
$table->altRowAttributes(1, array("class" => "ligne_impaire"), array("class" => "ligne_paire"));
$table->updateColAttributes(1, array("align" => "center"));
$table->updateColAttributes(2, array("align" => "center"));
$table->updateColAttributes(3, array("align" => "center"));
$table->updateColAttributes(4, array("align" => "center"));
$res .= $table->toHTML() ;
}
$GLOBALS['_BAZAR_']['url']->removeQueryString(BAZ_VARIABLE_VOIR);
return $res;
}
}
 
 
/** mes_fiches () - Renvoie les fiches bazar d'un utilisateur
*
* @return string HTML
*/
function mes_fiches() {
$res= '<h2>'.BAZ_VOS_ANNONCES.'</h2><br />'."\n";
if ($GLOBALS['AUTH']->getAuth()) {
// requete pour voir si l'utilisateur a des fiches a son nom, classees par date de MAJ et nature d'annonce
$requete = 'SELECT * FROM bazar_fiche, bazar_nature WHERE bf_ce_utilisateur='. $GLOBALS['id_user'].
' AND bn_id_nature=bf_ce_nature AND bn_ce_id_menu IN ('.$GLOBALS['_BAZAR_']['categorie_nature'].') ';
if (isset($GLOBALS['_BAZAR_']['langue'])) $requete .= ' and bn_ce_i18n like "'.$GLOBALS['_BAZAR_']['langue'].'%" ';
$requete .= ' ORDER BY bf_date_maj_fiche DESC,bf_ce_nature ASC';
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
die ('Echec de la requete<br />'.$resultat->getMessage().'<br />'.$resultat->getDebugInfo()) ;
}
if ($resultat->numRows() != 0) {
$tableAttr = array('id' => 'table_bazar') ;
$table = new HTML_Table($tableAttr) ;
$entete = array (BAZ_TITREANNONCE , BAZ_TYPEANNONCE, BAZ_ETATPUBLICATION, BAZ_MODIFIER, BAZ_SUPPRIMER, 'Dupliquer') ;
$table->addRow($entete) ;
$table->setRowType (0, "th") ;
// On affiche une ligne par proposition
while ($ligne = $resultat->fetchRow (DB_FETCHMODE_ASSOC)) {
if ($ligne['bf_statut_fiche']==1) $publiee=BAZ_PUBLIEE;
elseif ($ligne['bf_statut_fiche']==0) $publiee=BAZ_ENCOURSDEVALIDATION;
else $publiee=BAZ_REJETEE;
$lien_voir = $GLOBALS['_BAZAR_']['url'];
$lien_voir->addQueryString(BAZ_VARIABLE_ACTION, BAZ_VOIR_FICHE);
$lien_voir->addQueryString('id_fiche', $ligne['bf_id_fiche']);
$lien_voir->addQueryString('typeannonce', $ligne['bn_id_nature']);
$lien_voir_url=$lien_voir->getURL();
$lien_modifier = $GLOBALS['_BAZAR_']['url'];
$lien_modifier->addQueryString(BAZ_VARIABLE_ACTION, BAZ_ACTION_MODIFIER);
$lien_modifier->addQueryString('id_fiche', $ligne['bf_id_fiche']);
$lien_modifier->addQueryString('typeannonce', $ligne['bn_id_nature']);
$lien_modifier_url=$lien_modifier->getURL();
$lien_supprimer = $GLOBALS['_BAZAR_']['url'];
$lien_supprimer->addQueryString(BAZ_VARIABLE_ACTION, BAZ_ACTION_SUPPRESSION);
$lien_supprimer->addQueryString('id_fiche', $ligne['bf_id_fiche']);
$lien_supprimer->addQueryString('typeannonce', $ligne['bn_id_nature']);
$lien_supprimer_url=$lien_supprimer->getURL();
$lien_dupliquer = $GLOBALS['_BAZAR_']['url'];
$lien_dupliquer->addQueryString(BAZ_VARIABLE_ACTION, BAZ_ACTION_NOUVEAU);
$lien_dupliquer->addQueryString(BAZ_VARIABLE_ID_FICHE, $ligne['bf_id_fiche']);
$lien_dupliquer->addQueryString(BAZ_VARIABLE_DUPLICATION, 1);
$lien_dupliquer=$lien_dupliquer->getURL();
$GLOBALS['_BAZAR_']['url']->removeQueryString(BAZ_VARIABLE_DUPLICATION);
$table->addRow (array(
'<a href="'.$lien_voir_url.'">'.$ligne['bf_titre'].'</a>'."\n", // col 1 : le nom
$ligne['bn_label_nature']."\n", // col 2: type annonce
$publiee."\n", // col 3 : publiee ou non
'<a href="'.$lien_modifier_url.'">'.BAZ_MODIFIER.'</a>'."\n", // col 4 : modifier
'<a href="'.$lien_supprimer_url.'" onclick="javascript:return '.
'confirm(\''.BAZ_CONFIRMATION_SUPPRESSION.'\');" >'.BAZ_SUPPRIMER.'</a>'."\n", // col 5 : supprimer
'<a href="'.$lien_dupliquer.'">Dupliquer</a>'."\n")) ;
}
$table->altRowAttributes(1, array("class" => "ligne_impaire"), array("class" => "ligne_paire"));
$table->updateColAttributes(1, array("align" => "left"));
$table->updateColAttributes(2, array("align" => "center"));
$table->updateColAttributes(3, array("align" => "center"));
$table->updateColAttributes(4, array("align" => "center"));
$res .= $table->toHTML() ;
}
else {
$res .= '<p class="zone_info">'.BAZ_PAS_DE_FICHE.'</p>'."\n" ;
}
$GLOBALS['_BAZAR_']['url']->addQueryString(BAZ_VARIABLE_VOIR, BAZ_VOIR_SAISIR);
$GLOBALS['_BAZAR_']['url']->removeQueryString('id_fiche');
$GLOBALS['_BAZAR_']['url']->removeQueryString('typeannonce');
$GLOBALS['_BAZAR_']['url']->removeQueryString(BAZ_VARIABLE_ACTION);
$res .= '<br /><ul id="liste_liens"><li id="lien_saisir"><a href="'.$GLOBALS['_BAZAR_']['url']->getURL().'" title="'.BAZ_SAISIR_UNE_NOUVELLE_FICHE.'">'.BAZ_SAISIR_UNE_NOUVELLE_FICHE.'</a></li></ul>';
}
else {
include_once BAZ_CHEMIN_APPLI.'bibliotheque/bazarTemplate.class.php';
$modele = new bazarTemplate($GLOBALS['_BAZAR_']['db']);
$res .= $modele->getTemplate(BAZ_TEMPLATE_MESSAGE_LOGIN, $GLOBALS['_BAZAR_']['langue'], $GLOBALS['_BAZAR_']['categorie_nature']);
}
return $res;
}
 
/** baz_gestion_droits() interface de gestion des droits
*
* return string le code HTML
*/
function baz_gestion_droits() {
 
if ($GLOBALS['AUTH']->getAuth()) {
$lien_formulaire=$GLOBALS['_BAZAR_']['url'];
$lien_formulaire->addQueryString(BAZ_VARIABLE_ACTION, BAZ_GERER_DROITS);
 
//contruction du squelette du formulaire
$formtemplate = new HTML_QuickForm('formulaire', 'post', preg_replace ('/&amp;/', '&', $lien_formulaire->getURL()) );
$squelette =& $formtemplate->defaultRenderer();
$squelette->setFormTemplate("\n".'<form {attributes}>'."\n".'<table style="border:0;">'."\n".'{content}'."\n".'</table>'."\n".'</form>'."\n");
$squelette->setElementTemplate( '<tr>'."\n".'<td style="font-size:12px;width:150px;text-align:right;">'."\n".'{label} :</td>'."\n".'<td style="text-align:left;padding:5px;"> '."\n".'{element}'."\n".
'<!-- BEGIN required --><span class="symbole_obligatoire">*</span><!-- END required -->'."\n".
'<!-- BEGIN error --><span class="erreur">{error}</span><!-- END error -->'."\n".
'</td>'."\n".'</tr>'."\n");
$squelette->setElementTemplate( '<tr>'."\n".'<td colspan="2" class="liste_a_cocher"><strong>{label}&nbsp;{element}</strong>'."\n".
'<!-- BEGIN required --><span class="symbole_obligatoire">&nbsp;*</span><!-- END required -->'."\n".'</td>'."\n".'</tr>'."\n", 'accept_condition');
$squelette->setElementTemplate( '<tr><td colspan="2" class="bouton">{label}{element}</td></tr>'."\n", 'valider');
$squelette->setRequiredNoteTemplate("\n".'<tr>'."\n".'<td colspan="2" class="symbole_obligatoire">* {requiredNote}</td></tr>'."\n");
//Traduction de champs requis
$formtemplate->setRequiredNote(BAZ_CHAMPS_REQUIS) ;
$formtemplate->setJsWarnings(BAZ_ERREUR_SAISIE,BAZ_VEUILLEZ_CORRIGER);
//Initialisation de la variable personne
if ( isset($_POST['personnes']) ) {
$personne=$_POST['personnes'];
}
else $personne=0;
//Cas ou les droits ont etes changes
if (isset($_GET['pers'])) {
$personne=$_GET['pers'];
//CAS DES DROITS POUR UN TYPE D'ANNONCE: On efface tous les droits de la personne pour ce type d'annonce
if (isset($_GET['idtypeannonce'])) {
$requete = 'DELETE FROM bazar_droits WHERE bd_id_utilisateur='.$_GET['pers'].
' AND bd_id_nature_offre='.$_GET['idtypeannonce'];
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
die ($resultat->getMessage().$resultat->getDebugInfo()) ;
}
}
//CAS DU SUPER ADMIN: On efface tous les droits de la personne en general
else {
$requete = 'DELETE FROM bazar_droits WHERE bd_id_utilisateur='.$_GET['pers'];
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
die ($resultat->getMessage().$resultat->getDebugInfo()) ;
}
}
if ($_GET['droits']=='superadmin') {
$requete = 'INSERT INTO bazar_droits VALUES ('.$_GET['pers'].',0,0)';
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
die ($resultat->getMessage().$resultat->getDebugInfo()) ;
}
}
elseif ($_GET['droits']=='redacteur') {
$requete = 'INSERT INTO bazar_droits VALUES ('.$_GET['pers'].','.$_GET['idtypeannonce'].',1)';
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
die ($resultat->getMessage().$resultat->getDebugInfo()) ;
}
}
elseif ($_GET['droits']=='admin') {
$requete = 'INSERT INTO bazar_droits VALUES ('.$_GET['pers'].','.$_GET['idtypeannonce'].',2)';
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
die ($resultat->getMessage().$resultat->getDebugInfo()) ;
}
}
}
//requete pour obtenir l'id, le nom et prenom des personnes inscrites a l'annuaire sauf soi meme
$requete = 'SELECT '.BAZ_CHAMPS_ID.', '.BAZ_CHAMPS_NOM.', '.BAZ_CHAMPS_PRENOM.' FROM '.BAZ_ANNUAIRE.
' WHERE '.BAZ_CHAMPS_ID." != ".$GLOBALS['id_user'].' ORDER BY '.BAZ_CHAMPS_NOM.' ASC';
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
echo ($resultat->getMessage().$resultat->getDebugInfo()) ;
}
$res='<h2>'.BAZ_GESTION_DES_DROITS.'</h2><br />'."\n";
$res.=BAZ_DESCRIPTION_GESTION_DES_DROITS.'<br /><br />'."\n";
$personnes_select[0]=BAZ_SELECTION;
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
$personnes_select[$ligne[BAZ_CHAMPS_ID]] = $ligne[BAZ_CHAMPS_NOM]." ".$ligne[BAZ_CHAMPS_PRENOM] ;
}
$java=array ('style'=>'width:250px;','onchange'=>'this.form.submit();');
$formtemplate->addElement ('select', 'personnes', BAZ_LABEL_CHOIX_PERSONNE, $personnes_select, $java) ;
$defauts=array ('personnes'=>$personne);
$formtemplate->setDefaults($defauts);
$res.= $formtemplate->toHTML().'<br />'."\n" ;
if ($personne!=0) {
//cas du super utilisateur
$utilisateur = new Utilisateur_bazar($personne) ;
if ($utilisateur->isSuperAdmin()) {
$res.= '<br />'.BAZ_EST_SUPERADMINISTRATEUR.'<br /><br />'."\n";
$lien_enlever_superadmin=$GLOBALS['_BAZAR_']['url'];
$lien_enlever_superadmin->addQueryString(BAZ_VARIABLE_ACTION, BAZ_GERER_DROITS);
$lien_enlever_superadmin->addQueryString('pers', $personne);
$lien_enlever_superadmin->addQueryString('droits', 'aucun');
$res.= '<a href='.$lien_enlever_superadmin->getURL().'>'.BAZ_CHANGER_SUPERADMINISTRATEUR.'</a><br />'."\n";
}
else {
$lien_passer_superadmin=$GLOBALS['_BAZAR_']['url'];
$lien_passer_superadmin->addQueryString(BAZ_VARIABLE_ACTION, BAZ_GERER_DROITS);
$lien_passer_superadmin->addQueryString('pers', $personne);
$lien_passer_superadmin->addQueryString('droits', 'superadmin');
$res.= '<a href='.$lien_passer_superadmin->getURL().'>'.BAZ_PASSER_SUPERADMINISTRATEUR.'</a><br />'."\n";
//on cherche les differentes rubriques d'annonces
$requete = 'SELECT bn_id_nature, bn_label_nature, bn_image_titre FROM bazar_nature';
if (isset($GLOBALS['_BAZAR_']['langue'])) $requete .= ' where bn_ce_i18n like "'.$GLOBALS['_BAZAR_']['langue'].'%"';
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
die ($resultat->getMessage().$resultat->getDebugInfo()) ;
}
$res.='<br /><b>'.BAZ_DROITS_PAR_TYPE.'</b><br /><br />';
$table = new HTML_Table(array ('width' => '100%', 'class' => 'table_bazar')) ;
$table->addRow(array ('<strong>'.BAZ_TYPE_ANNONCES.'</strong>',
'<strong>'.BAZ_DROITS_ACTUELS.'</strong>',
'<strong>'.BAZ_PASSER_EN.'</strong>',
'<strong>'.BAZ_OU_PASSER_EN.'</strong>')) ;
$table->setRowType (0, 'th') ;
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
$lien_aucun_droit=$GLOBALS['_BAZAR_']['url'];
$lien_aucun_droit->addQueryString(BAZ_VARIABLE_ACTION, BAZ_GERER_DROITS);
$lien_aucun_droit->addQueryString('pers', $personne);
$lien_aucun_droit->addQueryString('droits', 'aucun');
$lien_aucun_droit->addQueryString('idtypeannonce', $ligne["bn_id_nature"]);
$lien_passer_redacteur=$GLOBALS['_BAZAR_']['url'];
$lien_passer_redacteur->addQueryString(BAZ_VARIABLE_ACTION, BAZ_GERER_DROITS);
$lien_passer_redacteur->addQueryString('pers', $personne);
$lien_passer_redacteur->addQueryString('droits', 'redacteur');
$lien_passer_redacteur->addQueryString('idtypeannonce', $ligne["bn_id_nature"]);
$lien_passer_admin=$GLOBALS['_BAZAR_']['url'];
$lien_passer_admin->addQueryString(BAZ_VARIABLE_ACTION, BAZ_GERER_DROITS);
$lien_passer_admin->addQueryString('pers', $personne);
$lien_passer_admin->addQueryString('droits', 'admin');
$lien_passer_admin->addQueryString('idtypeannonce', $ligne["bn_id_nature"]);
if (isset($ligne['bn_image_titre'])) {
$titre='&nbsp;<img src="client/bazar/images/'.$ligne['bn_image_titre'].'" alt="'.$ligne['bn_label_nature'].'" />'."\n";
} else {
$titre='<strong>&nbsp;'.$ligne['bn_label_nature'].'</strong>'."\n";
}
if ($utilisateur->isAdmin($ligne['bn_id_nature'])) {
$table->addRow(array($titre,
BAZ_DROIT_ADMIN,
'<a href='.$lien_aucun_droit->getURL().'>'.BAZ_AUCUN_DROIT.'</a>',
'<a href='.$lien_passer_redacteur->getURL().'>'.BAZ_LABEL_REDACTEUR.'</a>'));
}
elseif ($utilisateur->isRedacteur($ligne['bn_id_nature'])) {
$table->addRow(array($titre,
BAZ_LABEL_REDACTEUR,
'<a href='.$lien_aucun_droit->getURL().'>'.BAZ_AUCUN_DROIT.'</a>',
'<a href='.$lien_passer_admin->getURL().'>'.BAZ_DROIT_ADMIN.'</a>'));
}
else {
$table->addRow(array($titre,
BAZ_AUCUN_DROIT,
'<a href='.$lien_passer_redacteur->getURL().'>'.BAZ_LABEL_REDACTEUR.'</a>',
'<a href='.$lien_passer_admin->getURL().'>'.BAZ_DROIT_ADMIN.'</a>'));
}
}
$table->altRowAttributes(1, array('class' => 'ligne_impaire'), array('class' => 'ligne_paire'));
$table->updateColAttributes(0, array('align' => 'left'));
$table->updateColAttributes(1, array('align' => 'left'));
$table->updateColAttributes(2, array('align' => 'left'));
$table->updateColAttributes(3, array('align' => 'left'));
$res.=$table->toHTML() ;
}
}
 
// Nettoyage de l'url
$GLOBALS['_BAZAR_']['url']->removeQueryString(BAZ_VARIABLE_ACTION);
$GLOBALS['_BAZAR_']['url']->removeQueryString('pers');
$GLOBALS['_BAZAR_']['url']->removeQueryString('droits');
$GLOBALS['_BAZAR_']['url']->removeQueryString('idtypeannonce');
 
return $res;
}
}
 
/** baz_formulaire() - Renvoie le menu pour les saisies et modification des annonces
*
* @param string choix du formulaire a afficher (soit formulaire personnalise de
* l'annonce, soit choix du type d'annonce)
*
* @return string HTML
*/
function baz_formulaire($mode) {
$res = '';
if ($GLOBALS['AUTH']->getAuth()) {
$lien_formulaire=$GLOBALS['_BAZAR_']['url'];
//Definir le lien du formulaire en fonction du mode de formulaire choisi
if ($mode == BAZ_DEPOSER_ANNONCE) {
$lien_formulaire->addQueryString(BAZ_VARIABLE_ACTION, BAZ_ACTION_NOUVEAU);
if (isset($GLOBALS['_BAZAR_']['id_typeannonce']) && $GLOBALS['_BAZAR_']['id_typeannonce'] != 'toutes') {
$mode = BAZ_ACTION_NOUVEAU ;
}
}
if ($mode == BAZ_ACTION_NOUVEAU) {
if ((!isset($_POST['accept_condition']))and($GLOBALS['_BAZAR_']['condition']!=NULL)) {
$lien_formulaire->addQueryString(BAZ_VARIABLE_ACTION, BAZ_ACTION_NOUVEAU);
} else {
$lien_formulaire->addQueryString(BAZ_VARIABLE_ACTION, BAZ_ACTION_NOUVEAU_V);
}
}
if ($mode == BAZ_ACTION_MODIFIER) {
if (!isset($_POST['accept_condition'])and($GLOBALS['_BAZAR_']['condition']!=NULL)) {
$lien_formulaire->addQueryString(BAZ_VARIABLE_ACTION, BAZ_ACTION_MODIFIER);
} else {
$lien_formulaire->addQueryString(BAZ_VARIABLE_ACTION, BAZ_ACTION_MODIFIER_V);
if (isset ($_SESSION['_BAZAR_']['fichier'])) unset($_SESSION['_BAZAR_']['fichier']) ;
if (isset ($_SESSION['_BAZAR_']['image'])) unset($_SESSION['_BAZAR_']['image']);
if (isset ($_SESSION['_BAZAR_']['lien'])) unset($_SESSION['_BAZAR_']['lien']);
}
$lien_formulaire->addQueryString('id_fiche', $GLOBALS['_BAZAR_']['id_fiche']);
}
if ($mode == BAZ_ACTION_MODIFIER_V) {
$lien_formulaire->addQueryString(BAZ_VARIABLE_ACTION, BAZ_ACTION_MODIFIER_V);
$lien_formulaire->addQueryString('id_fiche', $GLOBALS['_BAZAR_']['id_fiche']);
}
//contruction du squelette du formulaire
$formtemplate = new HTML_QuickForm('formulaire', 'post', preg_replace ('/&amp;/', '&', $lien_formulaire->getURL()) );
$squelette =& $formtemplate->defaultRenderer();
$squelette->setFormTemplate("\n".'<form {attributes}>'."\n".'<table style="border:0;width:100%;">'."\n".'{content}'."\n".'</table>'."\n".'</form>'."\n");
$squelette->setElementTemplate( '<tr>'."\n".'<td>'."\n".'{label}'.
'<!-- BEGIN required --><span class="symbole_obligatoire">&nbsp;*</span><!-- END required -->'."\n".
' </td>'."\n".'<td style="text-align:left;padding:5px;"> '."\n".'{element}'."\n".
'<!-- BEGIN error --><span class="erreur">{error}</span><!-- END error -->'."\n".
'</td>'."\n".'</tr>'."\n");
$squelette->setElementTemplate( '<tr>'."\n".'<td colspan="2" class="liste_a_cocher"><strong>{label}&nbsp;{element}</strong>'."\n".
'<!-- BEGIN required --><span class="symbole_obligatoire">&nbsp;*</span><!-- END required -->'."\n".'</td>'."\n".'</tr>'."\n", 'accept_condition');
$squelette->setElementTemplate( '<tr><td colspan="2" class="bouton">{label}{element}</td></tr>'."\n", 'valider');
$squelette->setRequiredNoteTemplate("\n".'<tr>'."\n".'<td colspan="2" class="symbole_obligatoire">* {requiredNote}</td></tr>'."\n");
//Traduction de champs requis
$formtemplate->setRequiredNote(BAZ_CHAMPS_REQUIS) ;
$formtemplate->setJsWarnings(BAZ_ERREUR_SAISIE,BAZ_VEUILLEZ_CORRIGER);
//------------------------------------------------------------------------------------------------
//AFFICHAGE DU FORMULAIRE GENERAL DE CHOIX DU TYPE D'ANNONCE
//------------------------------------------------------------------------------------------------
if ($mode == BAZ_DEPOSER_ANNONCE) {
$res = '';
//requete pour obtenir le nom et la description des types d'annonce
$requete = 'SELECT * FROM bazar_nature WHERE bn_ce_id_menu IN ('.$GLOBALS['_BAZAR_']['categorie_nature'].') ';
if (isset($GLOBALS['_BAZAR_']['langue'])) {
$requete .= ' and bn_ce_i18n like "'.$GLOBALS['_BAZAR_']['langue'].'%" ';
}
$requete .= 'ORDER BY bn_label_nature ASC';
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
return ($resultat->getMessage().$resultat->getDebugInfo()) ;
}
//$res.='<h2>'.BAZ_DEPOSE_UNE_NOUVELLE_ANNONCE.'</h2>'."\n";
include_once BAZ_CHEMIN_APPLI.'bibliotheque/bazarTemplate.class.php';
$modele = new bazarTemplate($GLOBALS['_BAZAR_']['db']);
$res .= $modele->getTemplate(BAZ_TEMPLATE_FORMULAIRE_ACCUEIL, $GLOBALS['_BAZAR_']['langue'], $GLOBALS['_BAZAR_']['categorie_nature']);
if ($resultat->numRows()==1) {
$ligne = $resultat->fetchRow (DB_FETCHMODE_ASSOC);
$GLOBALS['_BAZAR_']['id_typeannonce']=$ligne['bn_id_nature'];
$GLOBALS['_BAZAR_']['typeannonce']=$ligne['bn_label_nature'];
$GLOBALS['_BAZAR_']['condition']=$ligne['bn_condition'];
$GLOBALS['_BAZAR_']['template']=$ligne['bn_template'];
$GLOBALS['_BAZAR_']['commentaire']=$ligne['bn_commentaire'];
$GLOBALS['_BAZAR_']['appropriation']=$ligne['bn_appropriation'];
$GLOBALS['_BAZAR_']['image_titre']=$ligne['bn_image_titre'];
$GLOBALS['_BAZAR_']['image_logo']=$ligne['bn_image_logo'];
$mode = BAZ_ACTION_NOUVEAU;
$lien_formulaire->addQueryString(BAZ_VARIABLE_ACTION, BAZ_ACTION_NOUVEAU_V);
} else {
//$res.='<br />'.BAZ_CHOIX_TYPEANNONCE.'<br /><br />'."\n";
while ($ligne = $resultat->fetchRow (DB_FETCHMODE_ASSOC)) {
$utilisateur = new Administrateur_bazar($GLOBALS['AUTH']);
if (($utilisateur->isRedacteur($ligne['bn_id_nature'])) || ($utilisateur->isAdmin($ligne['bn_id_nature']))
|| ($utilisateur->isSuperAdmin() || !BAZ_RESTREINDRE_DEPOT)) {
if ($ligne['bn_image_titre']!='') {
$titre='&nbsp;<img src="client/bazar/images/'.$ligne['bn_image_titre'].'" alt="'.
$ligne['bn_label_nature'].'" />'.'<br />'."\n";
} else {
$titre='<h3>'.$ligne['bn_label_nature'].' : </h3>'."\n";
}
$formtemplate->addElement('radio', 'typeannonce', '',
$titre.$ligne['bn_description'].'<br /><br />'."\n",
$ligne['bn_id_nature'], array("id" => 'select'.$ligne['bn_id_nature'],
"style" => 'float:left;'));
$formtemplate->addRule('typeannonce', 'Il faut choisir un type de fiche', 'required', '', 'client') ;
}
}
$squelette->setElementTemplate( '<div class="listechoix">'."\n".'{element}'."\n".'</div>'."\n");
//Mettre les annonces en choix par defaut
$formtemplate->setdefaults(array('typeannonce'=>'1'));
// Bouton d annulation
$lien_formulaire->removeQueryString('action');
$buttons[] = &HTML_QuickForm::createElement('link', 'annuler', BAZ_ANNULER,
preg_replace ("/&amp;/", "&", $lien_formulaire->getURL()), BAZ_ANNULER); // Le preg_replace contourne un pb de QuickForm et Net_URL
// qui remplacent deux fois les & par des &amp;
//Bouton de validation du formulaire // ce qui fait échouer le lien
$buttons[] = &HTML_QuickForm::createElement('submit', 'valider', BAZ_VALIDER);
$formtemplate->addGroup($buttons, null, null, '&nbsp;');
//Affichage a l'ecran
$res.= $formtemplate->toHTML()."\n";
}
}
//------------------------------------------------------------------------------------------------
//AFFICHAGE DU FORMULAIRE CORRESPONDANT AU TYPE DE L'ANNONCE CHOISI PAR L'UTILISATEUR
//------------------------------------------------------------------------------------------------
if ($mode == BAZ_ACTION_NOUVEAU) {
$utilisateur = new Administrateur_bazar($GLOBALS['AUTH']);
if ($utilisateur->isRedacteur($GLOBALS['_BAZAR_']['id_typeannonce']) ||
$utilisateur->isAdmin($GLOBALS['_BAZAR_']['id_typeannonce'])||
$utilisateur->isSuperAdmin()) {
$lien_formulaire->addQueryString(BAZ_VARIABLE_ACTION, BAZ_ACTION_NOUVEAU_V);
$formtemplate->updateAttributes(array('action' => str_replace('&amp;', '&', $lien_formulaire->getURL())));
// Appel du modele
include_once BAZ_CHEMIN_APPLI.'bibliotheque/bazarTemplate.class.php';
$modele = new bazarTemplate($GLOBALS['_BAZAR_']['db']);
$html = $modele->getTemplate(BAZ_TEMPLATE_FORMULAIRE, $GLOBALS['_BAZAR_']['langue'],$GLOBALS['_BAZAR_']['categorie_nature']);
if (!PEAR::isError($html)) {
if (isset($_GET[BAZ_VARIABLE_DUPLICATION])) {
$res = str_replace ('{FORMULAIRE}', baz_afficher_formulaire_annonce('duplication',$formtemplate), $html);
} else {
$res = str_replace ('{FORMULAIRE}', baz_afficher_formulaire_annonce('insertion',$formtemplate), $html);
}
} else {
if (isset($_GET[BAZ_VARIABLE_DUPLICATION])) {
$res = baz_afficher_formulaire_annonce('duplication',$formtemplate);
} else {
$res = baz_afficher_formulaire_annonce('insertion',$formtemplate);
}
}
} else {
// Pas de droit pour deposer un annonce
return '<div>Pas de droits suffisants</div>';
}
}
//------------------------------------------------------------------------------------------------
//CAS DE LA MODIFICATION D'UNE ANNONCE (FORMULAIRE DE MODIFICATION)
//------------------------------------------------------------------------------------------------
if ($mode == BAZ_ACTION_MODIFIER) {
$res=baz_afficher_formulaire_annonce('modification',$formtemplate);
}
// Nettoyage de l'url avant les return : apparement inutile sinon pose pb (url applette deconnexion et moteur de recherche) [jpm le 17 mars 2008]
//$GLOBALS['_BAZAR_']['url']->removeQueryString(BAZ_VARIABLE_ACTION);
//$GLOBALS['_BAZAR_']['url']->removeQueryString('id_fiche');
//------------------------------------------------------------------------------------------------
//CAS DE L'INSCRIPTION D'UNE ANNONCE
//------------------------------------------------------------------------------------------------
if ($mode == BAZ_ACTION_NOUVEAU_V) {
if ($formtemplate->validate() && !isset($_SESSION['formulaire_annonce_valide'])) {
//$formtemplate->process('baz_insertion', false) ;
$id_fiche = baz_insertion ($formtemplate->getSubmitValues());
// Redirection vers mes_fiches pour eviter la revalidation du formulaire
$GLOBALS['_BAZAR_']['url']->addQueryString (BAZ_VARIABLE_ACTION, BAZ_ACTION_POST_VALIDATION);
$GLOBALS['_BAZAR_']['url']->addQueryString (BAZ_VARIABLE_ID_FICHE, $id_fiche);
header ('Location: '.str_replace ('&amp;', '&', $GLOBALS['_BAZAR_']['url']->getURL())) ;
exit();
}
}
//------------------------------------------------------------------------------------------------
//CAS DE LA MODIFICATION D'UNE ANNONCE (VALIDATION ET MAJ)
//------------------------------------------------------------------------------------------------
if ($mode == BAZ_ACTION_MODIFIER_V) {
if ($formtemplate->validate()) {
$formtemplate->process('baz_mise_a_jour', false) ;
// Redirection vers mes_fiches pour eviter la revalidation du formulaire
$GLOBALS['_BAZAR_']['url']->addQueryString (BAZ_VARIABLE_VOIR, BAZ_VOIR_MES_FICHES);
header ('Location: '.str_replace ('&amp;', '&', $GLOBALS['_BAZAR_']['url']->getURL())) ;
exit();
}
}
} else {
include_once BAZ_CHEMIN_APPLI.'bibliotheque/bazarTemplate.class.php';
$modele = new bazarTemplate($GLOBALS['_BAZAR_']['db']);
$res .= $modele->getTemplate(BAZ_TEMPLATE_MESSAGE_LOGIN, $GLOBALS['_BAZAR_']['langue'], $GLOBALS['_BAZAR_']['categorie_nature']);
}
 
return $res;
}
 
/** baz_afficher_formulaire_annonce() - Genere le formulaire de saisie d'une annonce
*
* @param string type de formulaire: insertion ou modification
* @param mixed objet quickform du formulaire
*
* @return string code HTML avec formulaire
*/
function baz_afficher_formulaire_annonce($mode='insertion',$formtemplate) {
if ($mode=='modification' || $mode == 'duplication') {
//initialisation de la variable globale id_fiche
$GLOBALS['_BAZAR_']['id_fiche'] = $_REQUEST[BAZ_VARIABLE_ID_FICHE];
//suppression eventuelle d'une url, d'un fichier ou d'une image
if (isset($_GET['id_url'])) {
baz_suppression_url($_GET['id_url']);
}
if (isset($_GET['id_fichier'])) {
baz_suppression_fichier($_GET['id_fichier']);
}
if (isset($_GET['image'])) {
baz_suppression_image($GLOBALS['_BAZAR_']['id_fiche']);
}
}
$res = '';
//titre de la rubrique
if (!BAZ_UTILISE_TEMPLATE) $res= '<h2>'.BAZ_TITRE_SAISIE_ANNONCE.'&nbsp;'.$GLOBALS['_BAZAR_']['typeannonce'].'</h2><br />'."\n";
if (($GLOBALS['_BAZAR_']['condition']!='')AND(!isset($_POST['accept_condition']))AND(!isset($_GET['url'])OR(!isset($_GET['fichier']))OR(!isset($_GET['image'])))) {
require_once PAP_CHEMIN_API_PEAR.'HTML/QuickForm/html.php';
$conditions= new HTML_QuickForm_html('<tr><td colspan="2" style="padding:5px; margin:5px; width: 90%; background: #C1CBA7;">'.$GLOBALS['_BAZAR_']['condition'].'</td>'."\n".'</tr>'."\n");
$formtemplate->addElement($conditions);
$formtemplate->addElement('checkbox', 'accept_condition',BAZ_ACCEPTE_CONDITIONS) ;
$formtemplate->addElement('hidden', 'typeannonce', $GLOBALS['_BAZAR_']['id_typeannonce']);
$formtemplate->addRule('accept_condition', BAZ_ACCEPTE_CONDITIONS_REQUIS, 'required', '', 'client') ;
$formtemplate->addElement('submit', 'valider', BAZ_VALIDER);
}
//affichage du formulaire si conditions acceptees
else {
//Parcours du fichier de templates, pour mettre les valeurs des champs
$tableau=baz_valeurs_template($GLOBALS['_BAZAR_']['template']);
if ($mode=='modification' || $mode == 'duplication') {
//Ajout des valeurs par defaut
$valeurs_par_defaut = baz_valeurs_fiche($GLOBALS['_BAZAR_']['id_fiche']) ;
for ($i=0; $i<count($tableau); $i++) {
if (isset($ligne[$tableau[$i]['nom_bdd']])) {
$type = $tableau[$i]['type'];
$valeur = $ligne[$tableau[$i]['nom_bdd']];
} else {
$type = $tableau[$i]['type'];
$valeur = '';
}
/*
$element = Bazar_element::factory($type, $tableau[$i]);
if (!PEAR::isError($element)) {
if (method_exists($element, 'toForm'))$res .= $element->toForm($valeur);
}
*/
if ( $tableau[$i]['type']=='liste' || $tableau[$i]['type']=='checkbox') {
$def=$tableau[$i]['type'].$tableau[$i]['nom_bdd'];
}
elseif ( $tableau[$i]['type']=='texte' || $tableau[$i]['type']=='textelong' || $tableau[$i]['type']=='listedatedeb'
|| $tableau[$i]['type']=='listedatefin' || $tableau[$i]['type']=='champs_cache'
|| $tableau[$i]['type']=='labelhtml' ) {
$def=$tableau[$i]['nom_bdd'];
} elseif ($tableau[$i]['type']=='carte_google') {
$def = 'carte_google';
$valeurs_par_defaut[$def] = array ('latitude' => $valeurs_par_defaut['bf_latitude'], 'longitude' => $valeurs_par_defaut['bf_longitude']);
}
// certain type n ont pas de valeur par defaut (labelhtml par exemple)
// on teste l existence de $valeur_par_defaut[$def] avant de le passer en parametre
$tableau[$i]['type']($formtemplate, $tableau[$i]['nom_bdd'], $tableau[$i]['label'], $tableau[$i]['limite1'],
$tableau[$i]['limite2'],
isset ($valeurs_par_defaut[$def]) ? $valeurs_par_defaut[$def] : '',
$tableau[$i]['table_source'], $tableau[$i]['obligatoire']) ;
if ($tableau[$i]['type']=='carte_google') {
include_once GEN_CHEMIN_API.'formulaire/formulaire.fonct.google.php';
GEN_stockerCodeScript($script);
// On ajoute l attribut load a la balise body
GEN_AttributsBody('onload', 'load()');
}
}
}
else {
for ($i=0; $i<count($tableau); $i++) {
$tableau[$i]['type']($formtemplate, $tableau[$i]['nom_bdd'], $tableau[$i]['label'], $tableau[$i]['limite1'],
$tableau[$i]['limite2'], $tableau[$i]['defaut'], $tableau[$i]['table_source'], $tableau[$i]['obligatoire']) ;
if ($tableau[$i]['type'] == 'carte_google') {
include_once GEN_CHEMIN_API.'formulaire/formulaire.fonct.google.php';
GEN_stockerCodeScript($script);
// On ajoute l attribut load a la balise body
GEN_AttributsBody('onload', 'load()');
}
}
}
$formtemplate->addElement('hidden', 'typeannonce', $GLOBALS['_BAZAR_']['id_typeannonce']);
// Un champs cache pour la duplication
if ($mode == 'duplication') $formtemplate->addElement('hidden', 'fiche_dupliquee', $GLOBALS['_BAZAR_']['id_fiche']);
// Bouton d annulation
$attr = $formtemplate->getAttributes();
$lien_formulaire = new Net_URL($attr[BAZ_VARIABLE_ACTION]);
$lien_formulaire->addQueryString(BAZ_VARIABLE_ACTION, BAZ_ACTION_VOIR_VOS_ANNONCES);
$buttons[] = &HTML_QuickForm::createElement('link', 'annuler', BAZ_ANNULER,
preg_replace ("/&amp;/", "&", $lien_formulaire->getURL()), BAZ_ANNULER); // Le preg_replace contourne un pb de QuickForm et Net_URL
// qui remplacent deux fois les & par des &amp;
//Bouton de validation du formulaire // ce qui fait échouer le lien
$buttons[] = &HTML_QuickForm::createElement('submit', 'valider', BAZ_VALIDER);
$formtemplate->addGroup($buttons, null, null, '&nbsp;');
}
 
//Affichage a l'ecran
$res .= $formtemplate->toHTML()."\n";
return $res;
}
 
 
/** requete_bazar_fiche() - preparer la requete d'insertion ou de MAJ de la table bazar_fiche a partir du template
*
* @global mixed L'objet contenant les valeurs issues de la saisie du formulaire
* @return void
*/
function requete_bazar_fiche($valeur) {
$requete=NULL;
//l'annonce est directement publiée pour les admins
$utilisateur = new Administrateur_bazar($GLOBALS['AUTH']);
if ($utilisateur->isAdmin($GLOBALS['_BAZAR_']['id_typeannonce']) ||
$utilisateur->isSuperAdmin()) {
$requete.='bf_statut_fiche=1, ';
}
else {
$requete.='bf_statut_fiche="'.BAZ_ETAT_VALIDATION.'", ';
}
$tableau=baz_valeurs_template($GLOBALS['_BAZAR_']['template']);
for ($i=0; $i<count($tableau); $i++) {
//cas des checkbox et des listes
if ($tableau[$i]['type']=='checkbox' || $tableau[$i]['type']=='liste') {
//on supprime les anciennes valeurs de la table bazar_fiche_valeur_liste
$requetesuppression='DELETE FROM bazar_fiche_valeur_liste WHERE bfvl_ce_fiche='.$GLOBALS['_BAZAR_']['id_fiche'].' AND bfvl_ce_liste='.$tableau[$i]['nom_bdd'];
$resultat = $GLOBALS['_BAZAR_']['db']->query($requetesuppression) ;
if (DB::isError($resultat)) {
die ($resultat->getMessage().$resultat->getDebugInfo()) ;
}
if (isset($valeur[$tableau[$i]['type'].$tableau[$i]['nom_bdd']]) && ($valeur[$tableau[$i]['type'].$tableau[$i]['nom_bdd']]!=0)) {
//on insere les nouvelles valeurs
$requeteinsertion='INSERT INTO bazar_fiche_valeur_liste (bfvl_ce_fiche, bfvl_ce_liste, bfvl_valeur) VALUES ';
//pour les checkbox, les différentes valeurs sont dans un tableau
if (is_array($valeur[$tableau[$i]['type'].$tableau[$i]['nom_bdd']])) {
$nb=0;
while (list($cle, $val) = each($valeur[$tableau[$i]['type'].$tableau[$i]['nom_bdd']])) {
if ($nb>0) $requeteinsertion .= ', ';
$requeteinsertion .= '('.$GLOBALS['_BAZAR_']['id_fiche'].', '.$tableau[$i]['nom_bdd'].', '.$cle.') ';
$nb++;
}
}
//pour les listes, une insertion de la valeur suffit
else {
$requeteinsertion .= '('.$GLOBALS['_BAZAR_']['id_fiche'].', '.$tableau[$i]['nom_bdd'].', '.$valeur[$tableau[$i]['type'].$tableau[$i]['nom_bdd']].')';
}
$resultat = $GLOBALS['_BAZAR_']['db']->query($requeteinsertion) ;
if (DB::isError($resultat)) {
die ($resultat->getMessage().$resultat->getDebugInfo()) ;
}
}
}
//cas des fichiers
elseif ($tableau[$i]['type']=='fichier') {
if ((isset($valeur['texte_fichier'.$tableau[$i]['nom_bdd']]) && $valeur['texte_fichier'.$tableau[$i]['nom_bdd']]!='')
|| isset($_POST['fiche_dupliquee'])){
baz_insertion_fichier($valeur['texte_fichier'.$tableau[$i]['nom_bdd']], $GLOBALS['_BAZAR_']['id_fiche'], 'fichier'.$tableau[$i]['nom_bdd']);
}
}
//cas des urls
// On affine les criteres pour l insertion d une url
// il faut que le lien soit saisie, different de http:// ET que le texte du lien soit saisie aussi
// et ce afin d eviter d avoir des liens vides
elseif ($tableau[$i]['type']=='url') {
if ((isset($valeur['url_lien'.$tableau[$i]['nom_bdd']]) &&
$valeur['url_lien'.$tableau[$i]['nom_bdd']]!='http://'
&& isset($valeur['url_texte'.$tableau[$i]['nom_bdd']]) &&
strlen ($valeur['url_texte'.$tableau[$i]['nom_bdd']])) || isset($_POST['fiche_dupliquee'])) {
baz_insertion_url($valeur['url_lien'.$tableau[$i]['nom_bdd']], $valeur['url_texte'.$tableau[$i]['nom_bdd']], $GLOBALS['_BAZAR_']['id_fiche']);
}
}
//cas des images
elseif ($tableau[$i]['type']=='image') {
if (isset($_FILES['image']['name']) && $_FILES['image']['name']!='') {
$requete .= baz_insertion_image($GLOBALS['_BAZAR_']['id_fiche']);
}
}
//cas des dates
elseif ( $tableau[$i]['type']=='listedatedeb' || $tableau[$i]['type']=='listedatefin' ) {
// On construit la date selon le format YYYY-mm-dd
$date = $valeur[$tableau[$i]['nom_bdd']]['Y'].'-'.$valeur[$tableau[$i]['nom_bdd']]['m'].'-'.$valeur[$tableau[$i]['nom_bdd']]['d'] ;
// si la date de fin evenement est anterieure a la date de debut, on met la date de debut
// pour eviter les incoherence
if ($tableau[$i]['nom_bdd'] == 'bf_date_fin_evenement' &&
mktime(0,0,0, $valeur['bf_date_debut_evenement']['m'], $valeur['bf_date_debut_evenement']['d'], $valeur['bf_date_debut_evenement']['Y']) >
mktime(0,0,0, $valeur['bf_date_fin_evenement']['m'], $valeur['bf_date_fin_evenement']['d'], $valeur['bf_date_fin_evenement']['Y'])) {
$val = $valeur['bf_date_debut_evenement']['Y'].'-'.$valeur['bf_date_debut_evenement']['m'].'-'.$valeur['bf_date_debut_evenement']['d'] ;
} else {
$val = $valeur[$tableau[$i]['nom_bdd']]['Y'].'-'.$valeur[$tableau[$i]['nom_bdd']]['m'].'-'.$valeur[$tableau[$i]['nom_bdd']]['d'] ;
}
$requete .= $tableau[$i]['nom_bdd'].'="'.$val.'", ' ;
}
//cas des champs texte
elseif ( $tableau[$i]['type']=='texte' || $tableau[$i]['type']=='textelong' || $tableau[$i]['type']=='champs_cache' || $tableau[$i]['type']=='champs_mail' ) {
//on mets les slashes pour les saisies dans les champs texte et textearea
$val=addslashes($valeur[$tableau[$i]['nom_bdd']]) ;
$requete .= $tableau[$i]['nom_bdd'].'="'.$val.'", ' ;
}
//cas des wikinis
elseif ( $tableau[$i]['type']=='wikini' && $_REQUEST[BAZ_VARIABLE_ACTION]==BAZ_ACTION_NOUVEAU_V ) {
//on appelle les pages des apis et de l'integrateur wikini
include_once PAP_CHEMIN_RACINE.'api/sql/SQL_manipulation.fonct.php';
include_once PAP_CHEMIN_RACINE.'client/integrateur_wikini/configuration/adwi_configuration.inc.php' ;
include_once PAP_CHEMIN_RACINE.'client/integrateur_wikini/bibliotheque/adwi_wikini.fonct.php' ;
//génération du titre du wiki, sous la forme id-titre du projet
$titre=baz_titre_wiki($valeur["bf_titre"]);
//création du wiki
$valeur=array ("action"=> "nouveau_v", "code_alpha_wikini"=>$titre, "page"=>"AccueiL", "bdd_hote"=> "",
"bdd_nom"=> "", "bdd_utilisateur"=> "", "bdd_mdp" => "", "table_prefix"=> "", "chemin" => "wikini/".$titre, "valider"=> "Valider");
$val = insertion($valeur, $GLOBALS['_BAZAR_']['db']);
}
// Cas de la carte google
elseif ($tableau[$i]['type'] == 'carte_google') {
$requete .= 'bf_latitude="'.$valeur['latitude'].'", bf_longitude="'.$valeur['longitude'].'",';
}
}
$requete.=' bf_date_maj_fiche=NOW()';
return $requete;
}
 
/** baz_insertion() - inserer une nouvelle fiche
*
* @array Le tableau des valeurs a inserer
* @integer Valeur de l'identifiant de la fiche
* @return void
*/
function baz_insertion($valeur) {
// =========== Insertion d'une nouvelle fiche ===================
//requete d'insertion dans bazar_fiche
$GLOBALS['_BAZAR_']['id_fiche'] = baz_nextid('bazar_fiche', 'bf_id_fiche', $GLOBALS['_BAZAR_']['db']) ;
$requete = 'INSERT INTO bazar_fiche SET bf_id_fiche='.$GLOBALS['_BAZAR_']['id_fiche'].','.
'bf_ce_utilisateur='.$GLOBALS['id_user'].', bf_ce_nature='.$GLOBALS['_BAZAR_']['id_typeannonce'].','.
'bf_date_creation_fiche=NOW(),';
if (!isset($_REQUEST['bf_date_debut_validite_fiche'])) {
$requete .= 'bf_date_debut_validite_fiche=now(), bf_date_fin_validite_fiche="0000-00-00", ' ;
}
$requete .=requete_bazar_fiche(&$valeur) ;
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
return ($resultat->getMessage().$resultat->getDebugInfo()) ;
}
// Envoie d un mail aux administrateurs
$utilisateur = new Administrateur_bazar($GLOBALS['AUTH']);
if (!$utilisateur->isAdmin($GLOBALS['_BAZAR_']['id_typeannonce']) || !$utilisateur->isSuperAdmin()) {
bazar::notifier();
}
// On redirige
return $GLOBALS['_BAZAR_']['id_fiche'];
}
 
 
/** baz_insertion_url() - inserer un lien URL a une fiche
*
* @global string L'url du lien
* @global string Le texte du lien
* @global integer L'identifiant de la fiche
* @return void
*/
function baz_insertion_url($url_lien, $url_texte, $idfiche) {
if (isset ($_POST['fiche_dupliquee'])) {
$id_url = baz_nextId('bazar_url', 'bu_id_url', $GLOBALS['_BAZAR_']['db']) ;
$requete = 'insert into bazar_url select '.$id_url.','.$idfiche.',bu_url, bu_descriptif_url '.
' from bazar_url where bu_ce_fiche="'.$_POST['fiche_dupliquee'].'"';
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
die ($resultat->getMessage().$resultat->getDebugInfo()) ;
}
return;
}
//requete d'insertion dans bazar_url
if (!isset($_SESSION['_BAZAR_']['lien'])) {
$id_url = baz_nextId('bazar_url', 'bu_id_url', $GLOBALS['_BAZAR_']['db']) ;
$requete = 'INSERT INTO bazar_url SET bu_id_url='.$id_url.', bu_ce_fiche='.$idfiche.', '.
'bu_url="'.$url_lien.'", bu_descriptif_url="'.addslashes($url_texte).'"';
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
return $resultat->getMessage().$resultat->getDebugInfo() ;
}
$_SESSION['_BAZAR_']['lien'] = 1;
return;
}
}
 
 
/** baz_insertion_fichier() - inserer un fichier a une fiche
*
* @global string Le label du fichier
* @global string La description du fichier
* @global integer L'identifiant de la fiche
* @return void
*/
function baz_insertion_fichier($fichier_description, $idfiche, $nom_fichier='fichier_joint') {
//verification de la presence de ce fichier
// En cas de duplication on ajoute simplement une ligne dans la base de donnee
// pour chaque fichier associe a la fiche d origine
if (isset ($_POST['fiche_dupliquee'])) {
$id_fichier_joint = baz_nextId('bazar_fichier_joint', 'bfj_id_fichier', $GLOBALS['_BAZAR_']['db']) ;
$requete = 'insert into bazar_fichier_joint select '.$id_fichier_joint.','.$idfiche.',bfj_description,bfj_fichier '.
' from bazar_fichier_joint where bfj_ce_fiche="'.$_POST['fiche_dupliquee'].'"';
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
die ($resultat->getMessage().$resultat->getDebugInfo()) ;
}
return;
}
$requete = 'SELECT bfj_id_fichier FROM bazar_fichier_joint WHERE bfj_fichier="'.$_FILES[$nom_fichier]['name'].'"';
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
die ($resultat->getMessage().$resultat->getDebugInfo()) ;
}
if (!isset ($_SESSION['_BAZAR_']['fichier'])) {
if ($resultat->numRows()==0) {
$chemin_destination=BAZ_CHEMIN_APPLI.'upload/'.$_FILES[$nom_fichier]['name'];
move_uploaded_file($_FILES[$nom_fichier]['tmp_name'], $chemin_destination);
chmod ($chemin_destination, 0755);
}
$id_fichier_joint = baz_nextId('bazar_fichier_joint', 'bfj_id_fichier', $GLOBALS['_BAZAR_']['db']) ;
$requete = 'INSERT INTO bazar_fichier_joint SET bfj_id_fichier='.$id_fichier_joint.', bfj_ce_fiche='.$idfiche.
', bfj_description="'.addslashes($fichier_description).'", bfj_fichier="'.$_FILES[$nom_fichier]['name'].'"';
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
return $resultat->getMessage().$resultat->getDebugInfo() ;
}
}
$_SESSION['_BAZAR_']['fichier'] = 1;
return;
}
 
 
/** baz_insertion_image() - inserer une image a une fiche
*
* @global integer L'identifiant de la fiche
* @return string requete SQL
*/
function baz_insertion_image($idfiche) {
 
//verification de la presence de ce fichier
$requete = 'SELECT bf_id_fiche FROM bazar_fiche WHERE bf_url_image="'.$_FILES['image']['name'].'" AND bf_id_fiche!='.$idfiche;
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
die ($resultat->getMessage().$resultat->getDebugInfo()) ;
}
if ($resultat->numRows()==0) {
$chemin_destination=BAZ_CHEMIN_APPLI.'upload/'.$_FILES['image']['name'];
move_uploaded_file($_FILES['image']['tmp_name'], $chemin_destination);
chmod ($chemin_destination, 0755);
}
$_SESSION['_BAZAR_']['image'] = 1;
return 'bf_url_image="'.$_FILES['image']['name'].'", ' ;
}
 
 
/** baz_mise_a_jour() - Mettre a jour une fiche
*
* @global Le contenu du formulaire de saisie de l'annonce
* @return void
*/
function baz_mise_a_jour($valeur) {
//MAJ de bazar_fiche
$requete = 'UPDATE bazar_fiche SET '.requete_bazar_fiche(&$valeur,$GLOBALS['_BAZAR_']['id_typeannonce']);
$requete.= ' WHERE bf_id_fiche='.$GLOBALS['_BAZAR_']['id_fiche'];
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
return ($resultat->getMessage().$resultat->getDebugInfo()) ;
}
// Envoie d un mail aux administrateurs
$utilisateur = new Administrateur_bazar($GLOBALS['AUTH']);
if (!$utilisateur->isAdmin($GLOBALS['_BAZAR_']['id_typeannonce']) || !$utilisateur->isSuperAdmin()) {
bazar::notifier(BAZAR_NOTIFICATION_MODIFICATION_FICHE);
}
return;
}
 
/** baz_post_validation ()
*
* Cette fonction renvoie une page qui invite l utilisateur a :
* - saisir une nouvelle fiche a partir de celle qu il vient de saisir (pour changer de date)
* - retour a la liste de ces fiches
* - saisir une nouvelle fiche
*
*/
function baz_post_validation() {
$lien_duplication = clone $GLOBALS['_BAZAR_']['url'];
$lien_nouvelle_fiche = clone $GLOBALS['_BAZAR_']['url'];
$lien_mes_fiches = clone $GLOBALS['_BAZAR_']['url'];
$lien_visualiser_fiche = clone $GLOBALS['_BAZAR_']['url'];
$lien_duplication->addQueryString(BAZ_VARIABLE_ID_FICHE, $_GET[BAZ_VARIABLE_ID_FICHE]);
$lien_duplication->addQueryString(BAZ_VARIABLE_DUPLICATION, 1);
$lien_duplication->addQueryString(BAZ_VARIABLE_ACTION, BAZ_ACTION_NOUVEAU);
$lien_duplication = $lien_duplication->getURL();
$lien_nouvelle_fiche->addQueryString(BAZ_VARIABLE_ACTION, BAZ_DEPOSER_ANNONCE);
$lien_nouvelle_fiche->addQueryString(BAZ_VARIABLE_CATEGORIE_NATURE, $GLOBALS['_BAZAR_']['categorie_nature']);
$lien_nouvelle_fiche = $lien_nouvelle_fiche->getURL();
$lien_mes_fiches->addQueryString(BAZ_VARIABLE_VOIR, BAZ_VOIR_MES_FICHES);
$lien_mes_fiches = $lien_mes_fiches->getURL();
$lien_visualiser_fiche->addQueryString(BAZ_VARIABLE_VOIR, BAZ_GERER_DROITS);
$lien_visualiser_fiche->addQueryString(BAZ_VARIABLE_ACTION, BAZ_VOIR_FICHE);
$lien_visualiser_fiche->addQueryString(BAZ_VARIABLE_ID_FICHE, $_GET[BAZ_VARIABLE_ID_FICHE]);
$lien_visualiser_fiche = $lien_visualiser_fiche->getUrl() ;
ob_start();
if (file_exists(BAZ_CHEMIN_SQUELETTE.'baz_post_validation.tpl.html')) {
include_once BAZ_CHEMIN_SQUELETTE.'baz_post_validation.tpl.html';
}
$res = ob_get_contents();
ob_end_clean();
return $res ;
}
/** baz_suppression() - Supprime une fiche
*
* @global L'identifiant de la fiche a supprimer
* @return void
*/
function baz_suppression() {
 
if ($GLOBALS['AUTH']->getAuth()) {
$valeurs = baz_valeurs_fiche($_GET['id_fiche']);
//suppression des wikinis associes
//génération du titre du wiki, sous la forme id-titre du projet
$titre=baz_titre_wiki($valeurs["bf_titre"]);
$requete = 'SELECT gewi_id_wikini FROM gen_wikini WHERE gewi_code_alpha_wikini = "'.$titre.'"';
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if ($resultat->numRows()>0) {
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
$id_wikini=$ligne['gewi_id_wikini'];
}
include_once PAP_CHEMIN_RACINE.'api/sql/SQL_manipulation.fonct.php';
include_once PAP_CHEMIN_RACINE.'client/integrateur_wikini/configuration/adwi_configuration.inc.php' ;
include_once PAP_CHEMIN_RACINE.'client/integrateur_wikini/bibliotheque/adwi_wikini.fonct.php' ;
adwi_supprimer_wikini($id_wikini, $GLOBALS['_BAZAR_']['db']);
}
// suppression des valeurs des listes et des cases à cocher
$requete = 'DELETE FROM bazar_fiche_valeur_liste WHERE bfvl_ce_fiche='.$_GET['id_fiche'];
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
return ($resultat->getMessage().$resultat->getDebugInfo()) ;
}
//suppression des urls associes
$requete = 'SELECT bu_id_url FROM bazar_url WHERE bu_ce_fiche = '.$_GET['id_fiche'];
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
return ('Echec de la requete<br />'.$resultat->getMessage().'<br />'.$resultat->getDebugInfo().'<br />'."\n") ;
}
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
baz_suppression_url($ligne['bu_id_url']);
}
//suppression des fichiers associes
$requete = 'SELECT bfj_id_fichier FROM bazar_fichier_joint WHERE bfj_ce_fiche = '.$_GET['id_fiche'];
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
return ('Echec de la requete<br />'.$resultat->getMessage().'<br />'.$resultat->getDebugInfo().'<br />'."\n") ;
}
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
baz_suppression_fichier($ligne['bfj_id_fichier']);
}
//suppression dans bazar_fiche
$requete = 'DELETE FROM bazar_fiche WHERE bf_id_fiche = '.$_GET['id_fiche'];
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
return ('Echec de la requete<br />'.$resultat->getMessage().'<br />'.$resultat->getDebugInfo().'<br />'."\n") ;
}
// Redirection vers Mes fiches
$GLOBALS['_BAZAR_']['url']->addQueryString(BAZ_VARIABLE_VOIR, BAZ_VOIR_MES_FICHES);
$GLOBALS['_BAZAR_']['url']->removeQueryString('id_fiche');
header ('Location:'.$GLOBALS['_BAZAR_']['url']->getURL());
exit;
return ;
}
}
 
 
/** baz_suppression_url() - Supprimer un lien d'une fiche
*
* @global integer L'identifiant du lien
* @return void
*/
function baz_suppression_url($id_url) {
if ($GLOBALS['AUTH']->getAuth()) {
//suppression dans bazar_url
$requete = 'DELETE FROM bazar_url WHERE bu_id_url = '.$id_url;
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
die ('Echec de la requete<br />'.$resultat->getMessage().'<br />'.$resultat->getDebugInfo()) ;
}
return;
}
}
 
 
/** baz_suppression_fichier() - Supprimer un fichier d'une fiche
*
* @global integer L'identifiant du fichier
* @return void
*/
function baz_suppression_fichier($id_fichier) {
if ($GLOBALS['AUTH']->getAuth()) {
//verification de l'utilisation du fichier joint pour une autre annonce
$requete = 'SELECT bfj_fichier FROM bazar_fichier_joint WHERE bfj_id_fichier='.$id_fichier;
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
$ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC);
$requete = 'SELECT bfj_fichier FROM bazar_fichier_joint WHERE bfj_fichier="'.$ligne['bfj_fichier'].'"';
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
//si le fichier n'est que utilise dans cette fiche, on le supprime, on le laisse sinon
if ($resultat->numRows()==1) {
$ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC);
unlink(BAZ_CHEMIN_APPLI.'upload/'.$ligne['bfj_fichier']);
}
//suppression dans la table bazar_fichier
$requete = 'DELETE FROM bazar_fichier_joint WHERE bfj_id_fichier = '.$id_fichier;
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
die ('Echec de la requete<br />'.$resultat->getMessage().'<br />'.$resultat->getDebugInfo()) ;
}
return;
}
}
 
 
/** baz_suppression_image() - Supprimer une image d'une fiche
*
* @global integer L'identifiant de la fiche
* @return void
*/
function baz_suppression_image($id_fiche) {
if ($GLOBALS['AUTH']->getAuth()) {
//verification de l'utilisation de l'image pour une autre annonce
$requete = 'SELECT bf_url_image FROM bazar_fiche WHERE bf_id_fiche='.$id_fiche;
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
$ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC);
$requete = 'SELECT bf_url_image FROM bazar_fiche WHERE bf_url_image="'.$ligne['bf_url_image'].'"';
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
//si le fichier n'est que utilise dans cette fiche, on le supprime, on le laisse sinon
if ($resultat->numRows()==1) {
$ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC);
unlink(BAZ_CHEMIN_APPLI.'upload/'.$ligne['bf_url_image']);
}
//suppression dans la table bazar_fiche
$requete = 'UPDATE bazar_fiche SET bf_url_image=NULL WHERE bf_id_fiche = '.$id_fiche;
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
die ('Echec de la requete<br />'.$resultat->getMessage().'<br />'.$resultat->getDebugInfo()) ;
}
return;
}
}
 
 
/** publier_fiche () - Publie ou non dans les fichiers XML la fiche bazar d'un utilisateur
*
* @global boolean Valide: oui ou non
* @return void
*/
function publier_fiche($valid) {
if (isset($_GET['id_fiche'])) $GLOBALS['_BAZAR_']['id_fiche']=$_GET['id_fiche'];
if (isset($_GET['typeannonce'])) $typeannonce=$_GET['typeannonce'];
if ($valid==0) {
$requete = 'UPDATE bazar_fiche SET bf_statut_fiche=2 WHERE bf_id_fiche="'.$GLOBALS['_BAZAR_']['id_fiche'].'"' ;
}
else {
$requete = 'UPDATE bazar_fiche SET bf_statut_fiche=1 WHERE bf_id_fiche="'.$GLOBALS['_BAZAR_']['id_fiche'].'"' ;
}
// ====================Mise a jour de la table bazar_fiche====================
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
die ($resultat->getMessage().$resultat->getDebugInfo()) ;
}
unset ($resultat) ;
//TODO envoie mail annonceur
return;
}
 
 
/** baz_s_inscrire() affiche le formulaire qui permet de s'inscrire pour recevoir des annonces d'un type
*
* @return string le code HTML
*/
function baz_s_inscrire() {
$res= '<h2>'.BAZ_S_INSCRIRE_AUX_ANNONCES.'</h2>'."\n";
if (isset($_GET['inscrip'])) {
//cas d'une desinscription
if ($_GET['inscrip']==0) {
$requete='DELETE FROM bazar_abonnement WHERE ba_id_utilisateur='.$GLOBALS['id_user'].' AND ba_id_rubrique='.$_GET['idtypeannonce'];
}
//cas d'une inscription
else {
$requete='INSERT INTO bazar_abonnement VALUES ('.$GLOBALS['id_user'].', '.$_GET['idtypeannonce'].')';
}
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
die ($resultat->getMessage().$resultat->getDebugInfo()) ;
}
}
if ($GLOBALS['AUTH']->getAuth()) {
$res .= '<p id="laius_abonnement">'.BAZ_LAIUS_S_ABONNER.'</p>'."\n";
//requete pour obtenir l'id et le label des types d'annonces
$requete = 'SELECT bn_id_nature, bn_label_nature, bn_image_titre '.
'FROM bazar_nature WHERE 1'; /*bn_ce_id_menu='.$GLOBALS['_BAZAR_']['categorie_nature'];*/
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
die ($resultat->getMessage().$resultat->getDebugInfo()) ;
}
// Nettoyage de l url
$GLOBALS['_BAZAR_']['url']->removeQueryString(BAZ_VARIABLE_VOIR);
$table = new HTML_Table(array ('width' => '100%', 'class' => 'table_bazar'));
$table->addRow(array(BAZ_TYPE_ANNONCES,/* BAZ_STATUT, BAZ_PASSER_EN, */ BAZ_RSS));
$table->setRowType(0, 'th');
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
/*
$tab_parametres_GET = explode ("&", $_SERVER["argv"][0]) ;
foreach ($tab_parametres_GET as $cle_param => $valeur_param) {
$tab_valeur = explode ('=', $valeur_param) ;
$GLOBALS['_BAZAR_']['url']->addQueryString($tab_valeur[0], $tab_valeur[1]);
}
*/
$lien_s_abonner=$GLOBALS['_BAZAR_']['url'];
$lien_s_abonner->addQueryString('action', BAZ_S_INSCRIRE);
$lien_s_abonner->addQueryString('annonce', $ligne['bn_id_nature']);
$lien_s_abonner->addQueryString('inscrip', 1);
$lien_se_desabonner=$GLOBALS['_BAZAR_']['url'];
$lien_se_desabonner->addQueryString('action', BAZ_S_INSCRIRE);
$lien_se_desabonner->addQueryString('annonce', $ligne['bn_id_nature']);
$lien_se_desabonner->addQueryString('inscrip', 0);
$lien_RSS=$GLOBALS['_BAZAR_']['url'];
$lien_RSS->addQueryString('action', BAZ_VOIR_FLUX_RSS);
//requete pour savoir si la personne est inscrite a ce type d'annonce
$requete = 'SELECT ba_id_utilisateur '.
'FROM bazar_abonnement '.
'WHERE ba_id_utilisateur='.$GLOBALS['id_user'].' AND ba_id_rubrique='.$ligne['bn_id_nature'];
$resultat2 = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat2)) {
die ($resultat2->getMessage().$resultat2->getDebugInfo()) ;
}
if (isset($ligne['bn_image_titre'])) {$titre='&nbsp;<img src="client/bazar/images/'.$ligne['bn_image_titre'].'" alt="'.$ligne['bn_label_nature'].'" />'."\n";}
else {$titre='<strong>&nbsp;'.$ligne['bn_label_nature'].'</strong>'."\n";}
if ($resultat2->numRows()>0) {
//$lien_RSS->addQueryString('annonce', $ligne['bn_id_nature']);
$table->addRow(array($titre,
/* BAZ_ABONNE,
'<a href='.$lien_se_desabonner->getURL().'>'.BAZ_SE_DESABONNER.'</a>', */
'<a href="'.$lien_RSS->getURL().'"><img src="client/bazar/images/BAZ_rss.png" alt="'.BAZ_RSS.'"></a>'));
$lien_RSS->removeQueryString('annonce');
}
else {
$lien_RSS->removeQueryString('inscrip');
$table->addRow(array($titre,
/* BAZ_PAS_ABONNE,
'<a href='.$lien_s_abonner->getURL().'>'.BAZ_S_ABONNER.'</a>', */
'<a href="'.$lien_RSS->getURL().'"><img src="client/bazar/images/BAZ_rss.png" alt="'.BAZ_RSS.'" /></a>'));
}
}
$table->altRowAttributes(1, array('class' => 'ligne_impaire'), array('class' => 'ligne_paire'));
$table->updateColAttributes(0, array('class' => 'col1'));
$table->updateColAttributes(1, array('class' => 'col2'));
$res.=$table->toHTML() ;
}
else {
$res .= '<p class="zone_info">'.BAZ_IDENTIFIEZ_VOUS_POUR_SAISIR.'</p>'."\n" ;
$res .= '<form id="form_connexion" style="clear:both;" class="form_identification" action="' ;
$GLOBALS['_BAZAR_']['url']->addQueryString('action', BAZ_S_INSCRIRE);
$res .= $GLOBALS['_BAZAR_']['url']->getURL();
$res .= '" method="post">
<fieldset>
<legend>Identifiez vous</legend>
<label for="username">Courriel : </label>
<input type="text" id="username" name="username" maxlength="80" tabindex="1" value="courriel" />
<label for="password">Mot de passe : </label>
<input type="password" id="password" name="password" maxlength="80" tabindex="2" value="mot de passe" />
<input type="submit" id="connexion" name="connexion" tabindex="3" value="ok" />
</fieldset>
</form>';
}
// Nettoyage de l'url
$GLOBALS['_BAZAR_']['url']->removeQueryString(BAZ_VARIABLE_ACTION);
$GLOBALS['_BAZAR_']['url']->removeQueryString('idtypeannonce');
$GLOBALS['_BAZAR_']['url']->removeQueryString('inscrip');
return $res;
}
 
 
/** baz_valeurs_fiche() - Renvoie un tableau avec les valeurs par defaut du formulaire d'inscription
*
* @param integer Identifiant de la fiche
*
* @return array Valeurs enregistrees pour cette fiche
*/
function baz_valeurs_fiche($idfiche) {
$requete = 'SELECT * FROM bazar_fiche WHERE bf_id_fiche='.$idfiche;
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
die ($resultat->getMessage().'<br />'.$resultat->getDebugInfo()) ;
}
$ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC) ;
$valeurs_fiche = array() ;
$tableau = baz_valeurs_template($GLOBALS['_BAZAR_']['template']);
for ($i=0; $i<count($tableau); $i++) {
if ($tableau[$i]['type']=='liste' || $tableau[$i]['type']=='checkbox') {
$requete = 'SELECT bfvl_valeur FROM bazar_fiche_valeur_liste WHERE bfvl_ce_fiche='.$idfiche.
' AND bfvl_ce_liste='.$tableau[$i]['nom_bdd'];
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError ($resultat)) {
die ($resultat->getMessage().'<br />'.$resultat->getDebugInfo()) ;
}
$nb=0;$val='';
while ($result = $resultat->fetchRow()) {
if ($nb>0) $val .= ', ';
$val .= $result[0];
$nb++;
}
$valeurs_fiche[$tableau[$i]['type'].$tableau[$i]['nom_bdd']] = $val;
}
elseif ($tableau[$i]['type']=='champs_cache' || $tableau[$i]['type']=='texte' || $tableau[$i]['type']=='textelong' || $tableau[$i]['type']=='listedatedeb' || $tableau[$i]['type']=='listedatefin') {
$valeurs_fiche[$tableau[$i]['nom_bdd']] = stripslashes($ligne[$tableau[$i]['nom_bdd']]);
} elseif ($tableau[$i]['type']=='carte_google') {
$valeurs_fiche['bf_latitude'] = $ligne['bf_latitude'];
$valeurs_fiche['bf_longitude'] = $ligne['bf_longitude'];
}
}
return $valeurs_fiche;
}
 
/** function baz_nextId () Renvoie le prochain identifiant numerique libre d'une table
*
* @param string Nom de la table
* @param string Nom du champs identifiant
* @param mixed Objet DB de PEAR pour la connexion a la base de donnees
*
* return integer Le prochain numero d'identifiant disponible
*/
function baz_nextId($table, $colonne_identifiant, $bdd) {
$requete = 'SELECT MAX('.$colonne_identifiant.') AS maxi FROM '.$table;
$resultat = $bdd->query($requete) ;
if (DB::isError($resultat)) {
die (__FILE__ . __LINE__ . $resultat->getMessage() . $requete);
return $bdd->raiseError($resultat) ;
}
if ($resultat->numRows() > 1) {
return $bdd->raiseError('<br />La table '.$table.' a un identifiant non unique<br />') ;
}
$ligne = $resultat->fetchRow(DB_FETCHMODE_OBJECT) ;
return $ligne->maxi + 1 ;
}
 
/** function baz_titre_wiki () Renvoie la chaine de caractere sous une forme compatible avec wikini
*
* @param string mot à transformer (enlever accents, espaces)
*
* return string mot transformé
*/
function baz_titre_wiki($nom) {
$titre=trim($nom);
for ($j = 0; $j < strlen ($titre); $j++) {
if (!preg_match ('/[a-zA-Z0-9]/', $titre[$j])) {
$titre[$j] = '_' ;
}
}
return $titre;
}
 
/* +--Fin du code ----------------------------------------------------------------------------------------+
*
* $Log: not supported by cvs2svn $
* Revision 1.78 2008-09-17 14:08:45 alexandre_tb
* merge depuis aha
*
* Revision 1.77 2008-03-17 11:02:59 jp_milcent
* Ajout de l'authentification nécessaire pour déposer des commentaires.
* Corrections sur la gestion des paramêtres dans les urls (compatibilité applette Identification et Moteur de Recherche).
*
* Revision 1.76 2007-12-14 09:56:02 alexandre_tb
* Fusion avec la livraison AHA : 14 decembre 2007
*
* Revision 1.75 2007-12-04 09:07:21 alexandre_tb
* Fusion avec la livraison AHA : 4 déc 2007
*
* Revision 1.74 2007-10-25 09:41:31 alexandre_tb
* mise en place de variable de session pour eviter que les formulaires soit valider 2 fois, pour les url, fichiers et image
*
* Revision 1.73 2007-10-24 13:27:00 alexandre_tb
* bug : double saisie d url
* suppression de warning sur variable
*
* Revision 1.72 2007-10-22 10:09:21 florian
* correction template
*
* Revision 1.71 2007-10-22 09:18:39 alexandre_tb
* prise en compte de la langue dans les requetes sur bazar_nature
*
* Revision 1.70 2007-10-10 13:26:36 alexandre_tb
* utilisation de la classe Administrateur_bazar a la place de niveau_droit
* suppression de fonction niveau_droit
*
* Revision 1.69 2007-09-18 07:39:42 alexandre_tb
* correction d un bug lors d une insertion
*
* Revision 1.68 2007-08-27 12:31:31 alexandre_tb
* mise en place de modele
*
* Revision 1.67 2007-07-04 10:01:30 alexandre_tb
* mise en place de divers templates :
* - mail pour admin (sujet et corps)
* - modele carte_google
* ajout de lignes dans bazar_template
*
* Revision 1.66 2007-06-25 12:15:06 alexandre_tb
* merge from narmer
*
* Revision 1.65 2007-06-25 08:31:17 alexandre_tb
* utilisation de la bibliotheque generale api/formulaire/formulaire.fonct.inc.php a la place de bazar.fonct.formulaire.php
*
* Revision 1.64 2007-06-04 15:25:39 alexandre_tb
* ajout de la carto google
*
* Revision 1.63 2007/04/11 08:30:12 neiluj
* remise en état du CVS...
*
* Revision 1.57.2.12 2007/03/16 14:49:24 alexandre_tb
* si la date de debut d evenement est superieure a la date de fin alors on met
* la meme date dans les deux champs (coherence)
*
* Revision 1.57.2.11 2007/03/07 17:40:57 jp_milcent
* Ajout d'id sur les colonnes et gestion par les CSS des styles du tableau des abonnements.
*
* Revision 1.57.2.10 2007/03/07 17:20:19 jp_milcent
* Ajout du nettoyage systématique des URLs.
*
* Revision 1.57.2.9 2007/03/06 16:23:24 jp_milcent
* Nettoyage de l'url pour la gestion des droits.
*
* Revision 1.57.2.8 2007/03/05 14:33:44 jp_milcent
* Suppression de l'appel à Mes_Fiches dans la fonction baz_formulaire
*
* Revision 1.57.2.7 2007/03/05 10:28:03 alexandre_tb
* correction d un commentaire
*
* Revision 1.57.2.6 2007/02/15 13:42:16 jp_milcent
* Utilisation de IN à la place du = dans les requêtes traitant les catégories de fiches.
* Permet d'utiliser la syntaxe 1,2,3 dans la configuration de categorie_nature.
*
* Revision 1.57.2.5 2007/02/12 16:16:31 alexandre_tb
* suppression du style clear:both dans les attribut du formulaire d identification
*
* Revision 1.57.2.4 2007/02/01 16:19:30 alexandre_tb
* correction erreur de requete sur insertion bazar_fiche
*
* Revision 1.57.2.3 2007/02/01 16:11:05 alexandre_tb
* correction erreur de requete sur insertion bazar_fiche
*
* Revision 1.57.2.2 2007/01/22 16:05:39 alexandre_tb
* insertion de la date du jour dans bf_date_debut_validite_fiche quand il n'y a pas ce champs dans le formulaire (évite le 0000-00-00)
*
* Revision 1.57.2.1 2006/12/13 13:23:03 alexandre_tb
* Remplacement de l appel d une constante par un appel direct. -> warning
*
* Revision 1.58 2006/12/13 13:20:16 alexandre_tb
* Remplacement de l appel d une constante par un appel direct. -> warning
*
* Revision 1.57 2006/10/05 08:53:50 florian
* amelioration moteur de recherche, correction de bugs
*
* Revision 1.56 2006/09/28 15:41:36 alexandre_tb
* Le formulaire pour se logguer dans l'action saisir reste sur l'action saisir après
*
* Revision 1.55 2006/09/21 14:19:39 florian
* amélioration des fonctions liés au wikini
*
* Revision 1.54 2006/09/14 15:11:23 alexandre_tb
* suppression temporaire de la gestion des wikinis
*
* Revision 1.53 2006/07/25 13:24:44 florian
* correction bug image
*
* Revision 1.52 2006/07/25 13:05:00 alexandre_tb
* Remplacement d un die par un echo
*
* Revision 1.51 2006/07/18 14:17:32 alexandre_tb
* Ajout d'un formulaire d identification
*
* Revision 1.50 2006/06/21 08:37:59 alexandre_tb
* Correction de bug, d'un appel constant (....) qui ne fonctionnais plus.
*
* Revision 1.49 2006/06/02 09:29:07 florian
* debut d'integration de wikini
*
* Revision 1.48 2006/05/19 13:54:11 florian
* stabilisation du moteur de recherche, corrections bugs, lien recherche avancee
*
* Revision 1.47 2006/04/28 12:46:14 florian
* integration des liens vers annuaire
*
* Revision 1.46 2006/03/29 13:04:35 alexandre_tb
* utilisation de la classe Administrateur_bazar
*
* Revision 1.45 2006/03/24 09:28:02 alexandre_tb
* utilisation de la variable globale $GLOBALS['_BAZAR_']['categorie_nature']
*
* Revision 1.44 2006/03/14 17:10:21 florian
* ajout des fonctions de syndication, changement du moteur de recherche
*
* Revision 1.43 2006/03/02 20:36:52 florian
* les entrees du formulaire de saisir ne sont plus dans les constantes mias dans des tables qui gerent le multilinguisme.
*
* Revision 1.42 2006/03/01 16:23:22 florian
* modifs textes fr et correction bug "undefined index"
*
* Revision 1.41 2006/03/01 16:05:51 florian
* ajout des fichiers joints
*
* Revision 1.40 2006/02/06 09:33:00 alexandre_tb
* correction de bug
*
* Revision 1.39 2006/01/30 17:25:38 alexandre_tb
* correction de bugs
*
* Revision 1.38 2006/01/30 10:27:04 florian
* - ajout des entrées de formulaire fichier, url, et image
* - correction bug d'affichage du mode de saisie
*
* Revision 1.37 2006/01/24 14:11:11 alexandre_tb
* correction de bug sur l'ajout d'une image et d'un fichier
*
* Revision 1.36 2006/01/19 17:42:11 florian
* ajout des cases à cocher pré-cochées pour les maj
*
* Revision 1.35 2006/01/18 11:06:51 florian
* correction erreur saisie date
*
* Revision 1.34 2006/01/18 10:53:28 florian
* corrections bugs affichage fiche
*
* Revision 1.33 2006/01/18 10:07:34 florian
* recodage de l'insertion et de la maj des données relatives aux listes et checkbox dans des formulaires
*
* Revision 1.32 2006/01/18 10:03:36 florian
* recodage de l'insertion et de la maj des données relatives aux listes et checkbox dans des formulaires
*
* Revision 1.31 2006/01/17 10:07:08 alexandre_tb
* en cours
*
* Revision 1.30 2006/01/16 09:42:57 alexandre_tb
* en cours
*
* Revision 1.29 2006/01/13 14:12:51 florian
* utilisation des temlates dans la table bazar_nature
*
* Revision 1.28 2006/01/05 16:28:24 alexandre_tb
* prise en chage des checkbox, reste la mise à jour à gérer
*
* Revision 1.27 2006/01/04 15:30:56 alexandre_tb
* mise en forme du code
*
* Revision 1.26 2006/01/03 10:19:31 florian
* Mise à jour pour accepter des parametres dans papyrus: faire apparaitre ou non le menu, afficher qu'un type de fiches, définir l'action par défaut...
*
* Revision 1.25 2005/12/20 14:49:35 ddelon
* Fusion Head vers Livraison
*
* Revision 1.24 2005/12/16 15:44:40 alexandre_tb
* ajout de l'option restreindre dépôt
*
* Revision 1.23 2005/12/01 17:03:34 florian
* changement des chemins pour appli Pear
*
* Revision 1.22 2005/12/01 16:05:41 florian
* changement des chemins pour appli Pear
*
* Revision 1.21 2005/12/01 15:31:30 florian
* correction bug modifs et saisies
*
* Revision 1.20 2005/11/30 13:58:45 florian
* ajouts graphisme (logos, boutons), changement structure SQL bazar_fiche
*
* Revision 1.19 2005/11/24 16:17:13 florian
* corrections bugs, ajout des cases à cocher
*
* Revision 1.18 2005/11/18 16:03:23 florian
* correction bug html entites
*
* Revision 1.17 2005/11/17 18:48:02 florian
* corrections bugs + amélioration de l'application d'inscription
*
* Revision 1.16 2005/11/07 17:30:36 florian
* ajout controle sur les listes pour la saisie
*
* Revision 1.15 2005/11/07 17:05:45 florian
* amélioration validation conditions de saisie, ajout des règles spécifiques de saisie des formulaires
*
* Revision 1.14 2005/11/07 08:48:02 florian
* correction pb guillemets pour saisie et modif de fiche
*
* Revision 1.13 2005/10/21 16:15:04 florian
* mise a jour appropriation
*
* Revision 1.11 2005/10/12 17:20:33 ddelon
* Reorganisation calendrier + applette
*
* Revision 1.10 2005/10/12 15:14:06 florian
* amélioration de l'interface de bazar, de manière a simplifier les consultations, et à harmoniser par rapport aux Ressources
*
* Revision 1.9 2005/10/10 16:22:52 alexandre_tb
* Correction de bug. Lorsqu'on revient en arrière après avoir validé un formulaire.
*
* Revision 1.8 2005/09/30 13:50:07 alexandre_tb
* correction bug date parution ressource
*
* Revision 1.7 2005/09/30 13:15:58 ddelon
* compatibilité php5
*
* Revision 1.6 2005/09/30 13:00:05 ddelon
* Fiche bazar generique
*
* Revision 1.5 2005/09/30 12:22:54 florian
* Ajouts commentaires pour fiche, modifications graphiques, maj SQL
*
* Revision 1.3 2005/07/21 19:03:12 florian
* nouveautés bazar: templates fiches, correction de bugs, ...
*
* Revision 1.1.1.1 2005/02/17 18:05:11 florian
* Import initial de Bazar
*
* Revision 1.1.1.1 2005/02/17 11:09:50 florian
* Import initial
*
* Revision 1.1.1.1 2005/02/16 18:06:35 florian
* import de la nouvelle version
*
* Revision 1.10 2004/07/08 17:25:25 florian
* ajout commentaires + petits debuggages
*
* Revision 1.8 2004/07/07 14:30:19 florian
* débogage RSS
*
* Revision 1.7 2004/07/06 16:22:01 florian
* débogage modification + MAJ flux RSS
*
* Revision 1.6 2004/07/06 09:28:26 florian
* changement interface de modification
*
* Revision 1.5 2004/07/05 15:10:23 florian
* changement interface de saisie
*
* Revision 1.4 2004/07/02 14:51:14 florian
* ajouts divers pour faire fonctionner l'insertion de fiches
*
* Revision 1.3 2004/07/01 16:37:42 florian
* ajout de fonctions pour les templates
*
* Revision 1.2 2004/07/01 13:00:13 florian
* modif Florian
*
* Revision 1.1 2004/06/23 09:58:32 alex
* version initiale
*
* Revision 1.1 2004/06/18 09:00:37 alex
* version initiale
*
*
* +-- Fin du code ----------------------------------------------------------------------------------------+
*/
 
?>
/tags/v3.1-blanche-neige/bazar.inscription.inc.php
New file
0,0 → 1,89
<?php
/*vim: set expandtab tabstop=4 shiftwidth=4: */
// +------------------------------------------------------------------------------------------------------+
// | PHP version 4.1 |
// +------------------------------------------------------------------------------------------------------+
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org) |
// +------------------------------------------------------------------------------------------------------+
// | This library is free software; you can redistribute it and/or |
// | modify it under the terms of the GNU Lesser General Public |
// | License as published by the Free Software Foundation; either |
// | version 2.1 of the License, or (at your option) any later version. |
// | |
// | This library is distributed in the hope that it will be useful, |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
// | Lesser General Public License for more details. |
// | |
// | You should have received a copy of the GNU Lesser General Public |
// | License along with this library; if not, write to the Free Software |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
// +------------------------------------------------------------------------------------------------------+
// CVS : $Id: bazar.inscription.inc.php,v 1.8 2007-07-04 10:06:21 alexandre_tb Exp $
/**
*
*@package bazar
//Auteur original :
*@author Alexandre GRANIER <alexandre@tela-botanica.org>
*@author Florian Schmitt <florian@ecole-et-nature.org>
//Autres auteurs :
*@copyright Tela-Botanica 2000-2005
*@version $Revision: 1.8 $
// +------------------------------------------------------------------------------------------------------+
*/
 
// RAPPEL : On se situe dans la fonction afficherContenuCorps() de inscription.php
 
// requete pour récupérer l'ensemble des type d'annonces
if (!file_exists (INS_CHEMIN_APPLI.'../bazar/bazar.inscription.local.php')) {
$requete = 'SELECT bn_id_nature FROM bazar_nature WHERE 1' ;
$resultat = $GLOBALS['ins_db']->query ($requete);
$SQL = '' ;
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_OBJECT)) {
$SQL .= '('.$id_utilisateur.', '.$ligne->bn_id_nature.', 1),' ;
}
$SQL = substr ($SQL, 0, strlen ($SQL) - 1) ;
$requete = 'INSERT INTO bazar_droits VALUES '.$SQL;
$resultat = $GLOBALS['ins_db']->query($requete);
if (DB::isError($resultat)) {
$msg = $resultat->getMessage().$resultat->getDebugInfo() ;
}
unset($resultat) ;
} else {
include_once INS_CHEMIN_APPLI.'../bazar/bazar.inscription.local.php';
}
/* +--Fin du code ----------------------------------------------------------------------------------------+
*
* $Log: bazar.inscription.inc.php,v $
* Revision 1.8 2007-07-04 10:06:21 alexandre_tb
* ajout d un appel a bazar.inscription.local.php s il existe, pour personnaliser les actions lors d une inscription.
*
* Revision 1.7 2007-06-01 13:51:09 alexandre_tb
* suppression de l echo en cas d erreur
* mise en place de $msg pour recuperer les erreurs
*
* Revision 1.6 2007/04/11 08:30:12 neiluj
* remise en état du CVS...
*
* Revision 1.4.2.1 2007/03/07 16:50:42 jp_milcent
* Mise en majuscule des mots réservés par SQL
*
* Revision 1.4 2006/12/01 13:23:17 florian
* integration annuaire backoffice
*
* Revision 1.3 2006/04/28 16:10:17 florian
* inscrit d'office tous les utilisateurs en rédacteur de fiches
*
* Revision 1.2 2006/03/29 13:06:07 alexandre_tb
* Code initial
*
* Revision 1.1 2005/09/29 16:14:17 alexandre_tb
* version initiale
*
*
* +-- Fin du code ----------------------------------------------------------------------------------------+
*/
?>
/tags/v3.1-blanche-neige/squelettes/baz_cal.tpl.html
New file
0,0 → 1,14
<!-- ENTETE DU CALENDRIER -->
<div class="navi">
<a href="<?= $prev ; ?>" id="navi_ant"> &lt;&lt; </a>
&nbsp;&nbsp;
<a href="<?= $cur; ?>">
<?= $fr_month[(date('n',$curStamp))]; ?>
&nbsp;
<?= date('Y',$curStamp); ?>
</a>
&nbsp;&nbsp;
<a href="<?= $next ;?>" id="navi_post"> &gt;&gt; </a>
</div>
<br></br>
<!-- FIN ENTETE CALENDRIER -->
/tags/v3.1-blanche-neige/squelettes/baz_post_validation.tpl.html
New file
0,0 → 1,9
<p>Votre fiche a bien &eacute;t&eacute; enregistr&eacute;e. Un mod&eacute;rateur a &eacute;t&eacute; averti. Attention votre &eacute;v&egrave;nement ne sera peut &ecirc;tre pas publi&eacute; imm&eacute;diatement. Selon le nombre de fiches propos&eacute;es chaque semaine, les mod&eacute;rateurs effectuent un choix de publication par ordre de priorit&eacute; en fonction de la date &agrave; laquelle les &eacute;v&egrave;nements d&eacute;marrent. <br />
En attendant, vous pouvez :
<ul>
<li><a href="<?php echo $lien_duplication; ?>">Dupliquer cette fiche</a> pour proposer par exemple le m&ecirc;me &eacute;v&egrave;nement &agrave; une autre date</li>
<li><a href="<?php echo $lien_nouvelle_fiche; ?>">Saisir une nouvelle fiche</a></li>
<li><a href="<?php echo $lien_mes_fiches; ?>">Retourner &agrave; ma liste de fiches</a></li>
<li><a href="<?php echo $lien_visualiser_fiche; ?>">Visualiser la fiche cr&eacute;&eacute;e</a></li>
</ul>
</p>
/tags/v3.1-blanche-neige/langues/baz_langue_es.inc.php
New file
0,0 → 1,136
<?php
/*vim: set expandtab tabstop=4 shiftwidth=4: */
// +------------------------------------------------------------------------------------------------------+
// | PHP version 4.1 |
// +------------------------------------------------------------------------------------------------------+
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org) |
// +------------------------------------------------------------------------------------------------------+
// | This library is free software; you can redistribute it and/or |
// | modify it under the terms of the GNU Lesser General Public |
// | License as published by the Free Software Foundation; either |
// | version 2.1 of the License, or (at your option) any later version. |
// | |
// | This library is distributed in the hope that it will be useful, |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
// | Lesser General Public License for more details. |
// | |
// | You should have received a copy of the GNU Lesser General Public |
// | License along with this library; if not, write to the Free Software |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
// +------------------------------------------------------------------------------------------------------+
// CVS : $Id: baz_langue_es.inc.php,v 1.1 2007-10-23 14:30:06 alexandre_tb Exp $
/**
* Fichier de traduction en anglais de l'application Bazar
*
*@package bazar
//Auteur original :
*@author Alexandre GRANIER <alexandre@tela-botanica.org>
*@author Florian Schmitt <florian@ecole-et-nature.org>
//Autres auteurs :
*@author Aucun
*@copyright Tela-Botanica 2000-2008
*@version $Revision: 1.1 $ $Date: 2007-10-23 14:30:06 $
// +------------------------------------------------------------------------------------------------------+
*/
 
define ('BAZ_CONSULTER', 'Buscar');
define ('BAZ_VOIR_VOS_ANNONCES', 'Sus fichas');
define ('BAZ_S_ABONNER', 'validar');
define ('BAZ_SAISIR', 'escrivir');
define ('BAZ_ADMINISTRER', 'administrar');
define ('BAZ_GESTION_DES_DROITS', 'Derechos');
 
define ('BAZ_TOUTES_LES_ANNONCES', 'Todas las fichas');
define ('BAZ_TYPEANNONCE', 'Tipo de fichas');
define ('BAZ_TOUS_TYPES_FICHES', 'Todos tipos de fichas');
define ('BAZ_VALIDE', 'validación');
define ('BAZ_FICHES_PAS_VALIDEES', 'fichas no validadas');
define ('BAZ_FICHES_VALIDEES', 'fichas validadas');
define ('BAZ_LES_DEUX', 'Los dos');
define ('BAZ_MOT_CLE', 'Password');
define ('BAZ_RECHERCHER', 'Buscar');
 
define ('BAZ_MODIFIER', 'Actualisar');
define ('BAZ_SUPPRIMER', 'Cancelar');
define ('BAZ_SUIVANT', 'Siguiente');
define ('BAZ_PRECEDENT', 'precedente');
define ('BAZ_ANNULER', 'Cancelar');
define ('BAZ_VALIDER', 'Ok');
 
define ('BAZ_IL_Y_A', 'Hay');
define ('BAZ_FICHES_CORRESPONDANTES', ' resultados por su busqueda');
define ('BAZ_VOS_ANNONCES', 'sus fichas');
define ('BAZ_PUBLIEE', 'Publicada');
define ('BAZ_SAISIR_UNE_NOUVELLE_FICHE', 'Escrivir una nueva ficha');
 
define ('BAZ_LE', 'El');
define ('BAZ_NB_VUS', 'Se visitó esta página');
define ('BAZ_FOIS', ' veces');
define ('BAZ_DU', 'desde');
define ('BAZ_AU', 'hasta');
define ('BAZ_DATE_CREATION', 'creado el ');
define ('BAZ_DATE_MAJ', 'puesta al día');
define ('BAZ_FICHE_NUMERO', 'ficha numero ');
define ('BAZ_ECRITE', ' escrita por ');
 
define ('BAZ_INVALIDER_LA_FICHE', 'No publicar');
define ('BAZ_MODIFIER_LA_FICHE', 'Modificar');
define ('BAZ_SUPPRIMER_LA_FICHE', 'Cancelar');
 
define ('BAZ_S_INSCRIRE_AUX_ANNONCES', 'Registrar');
define ('BAZ_LAIUS_S_ABONNER', 'Suscribirse');
define ('BAZ_PAS_ABONNE', 'No registrado');
define ('BAZ_SE_DESABONNER', 'retirarse');
define ('BAZ_ABONNE', 'Registrado');
 
define ('BAZ_URL_LIEN', 'URL');
define ('BAZ_URL_TEXTE', 'exto del vínculo');
define ('BAZ_FICHIER_DESCRIPTION', 'descripción del fichero');
define ('BAZ_FICHIER_JOINT', 'Eligir un fichiero');
define ('BAZ_IMAGE_VALIDE_REQUIS', 'Invalidar imagen');
 
define ('BAZ_IDENTIFIEZ_VOUS_POUR_SAISIR', 'Please, log in');
 
define ('BAZ_ANNONCES_A_ADMINISTRER', 'fichas que deben administrarse');
define ('BAZ_OUI', 'Si');
define ('BAZ_NON', 'No');
define ('BAZ_TOUTES_LES_FICHES', 'Todas fichas');
define ('BAZ_DESCRIPTION_GESTION_DES_DROITS', 'Derechos');
define ('BAZ_LABEL_CHOIX_PERSONNE', 'Eligir alguien');
define ('BAZ_SELECTION', 'Seleccionar');
define ('BAZ_PASSER_SUPERADMINISTRATEUR', 'Change to super admin');
define ('BAZ_DROITS_PAR_TYPE', 'Derechos por categoria');
define ('BAZ_LABEL_REDACTEUR', 'Redactor');
define ('BAZ_AUCUN_DROIT', 'No derechos');
define ('BAZ_DROIT_ADMIN', 'Admin');
 
define ('BAZ_JANVIER','Enero');
define ('BAZ_FEVRIER','Febrero');
define ('BAZ_MARS','marzo');
define ('BAZ_AVRIL','Abril');
define ('BAZ_MAI','Mayo');
define ('BAZ_JUIN','Junio');
define ('BAZ_JUILLET','Julio');
define ('BAZ_AOUT','Agosto');
define ('BAZ_SEPTEMBRE','Setiembr');
define ('BAZ_OCTOBRE','Octubre');
define ('BAZ_NOVEMBRE','noviembre');
define ('BAZ_DECEMBRE','Deciembre');
 
define ('BAZ_LUNDI','lunes');
define ('BAZ_MARDI','Martes');
define ('BAZ_MERCREDI','Miercoles');
define ('BAZ_JEUDI','Jueves');
define ('BAZ_VENDREDI','viernes');
define ('BAZ_SAMEDI','Sabado');
define ('BAZ_DIMANCHE','Domingo');
 
define ('BAZ_LUNDI_COURT','Lun');
define ('BAZ_MARDI_COURT','Mar');
define ('BAZ_MERCREDI_COURT','Mier');
define ('BAZ_JEUDI_COURT','Jue');
define ('BAZ_VENDREDI_COURT','Vie');
define ('BAZ_SAMEDI_COURT','Sab');
define ('BAZ_DIMANCHE_COURT','Dom');
?>
/tags/v3.1-blanche-neige/langues/baz_langue_fr.inc.php
New file
0,0 → 1,666
<?php
/*vim: set expandtab tabstop=4 shiftwidth=4: */
// +------------------------------------------------------------------------------------------------------+
// | PHP version 4.1 |
// +------------------------------------------------------------------------------------------------------+
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org) |
// +------------------------------------------------------------------------------------------------------+
// | This library is free software; you can redistribute it and/or |
// | modify it under the terms of the GNU Lesser General Public |
// | License as published by the Free Software Foundation; either |
// | version 2.1 of the License, or (at your option) any later version. |
// | |
// | This library is distributed in the hope that it will be useful, |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
// | Lesser General Public License for more details. |
// | |
// | You should have received a copy of the GNU Lesser General Public |
// | License along with this library; if not, write to the Free Software |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
// +------------------------------------------------------------------------------------------------------+
// CVS : $Id: baz_langue_fr.inc.php,v 1.61.2.5 2008-03-17 14:02:51 jp_milcent Exp $
/**
* Fichier de traduction en français de l'application Bazar
*
*@package bazar
//Auteur original :
*@author Alexandre GRANIER <alexandre@tela-botanica.org>
*@author Florian Schmitt <florian@ecole-et-nature.org>
//Autres auteurs :
*@author Aucun
*@copyright Tela-Botanica 2000-2004
*@version $Revision: 1.61.2.5 $ $Date: 2008-03-17 14:02:51 $
// +------------------------------------------------------------------------------------------------------+
*/
 
if (file_exists(BAZ_CHEMIN_APPLI.'langues/baz_langue_fr.local.php')) {
include_once BAZ_CHEMIN_APPLI.'langues/baz_langue_fr.local.php' ;
}
 
define ('BAZ_TITREAPPLI','Gestionnaire de fiches (Bazar) ');
define ('BAZ_DESCRIPTIONAPPLI','D&eacute;couvrez Bazar, une application de gestion de fiches class&eacute;es, consultables en ligne ou par flux RSS, grandement personnalisable.');
define ('BAZ_MOTS_CLES','Bazar, fiches, flux, rss, nouveaut&eacute;, information, gestionnaire, xml, syndication, info, application, php, dynamique, mise, aacute; , jour ');
if (!defined ('BAZ_TOUTES_LES_ANNONCES')) define ('BAZ_TOUTES_LES_ANNONCES', 'Consulter les fiches');
define ('BAZ_CONSULTER_FICHES_VALIDEES', 'Consulter les fiches valid&eacute;es');
define ('BAZ_TOUTES_LES_ANNONCES_DE_TYPE', 'Consulter toutes les fiches de type:');
define ('BAZ_TOUS_TYPES_FICHES', 'Tous types de fiches');
if (!defined ('BAZ_TOUS_LES_EMETTEURS')) define ('BAZ_TOUS_LES_EMETTEURS', 'Tous les emetteurs');
define ('BAZ_ENTRER_VOS_CRITERES_DE_RECHERCHE','Pr&eacute;cisez vos critères de recherche et appuyez sur le bouton "Rechercher" pour consulter les fiches.');
define ('BAZ_MODIFIE_RSS','Modifi&eacute;: ' );
define ('BAZ_NOM', 'Nom') ;
define ('BAZ_PRENOM', 'Pr&eacute;nom') ;
define ('BAZ_TOUS', 'Tous');
define ('BAZ_TOUTES', 'Toutes');
define ('BAZ_MOT_CLE', 'Mots cl&eacute;s');
if (!defined ('BAZ_EMETTEUR')) define ('BAZ_EMETTEUR', '&Eacute;metteur');
define ('BAZ_NATURE', 'Nature de la fiche' );
define ('BAZ_STATUT', 'Statut' );
define ('BAZ_DATE_CREATION', 'Date de cr&eacute;ation' );
define ('BAZ_DATE_MAJ', 'Date de mise &agrave; jour' );
define ('BAZ_URL_IMAGE', 'Image' );
define ('BAZ_LANGUES_PARLES', 'Langues parl&eacute;s :') ;
define ('BAZ_EMAIL', 'E-mail :') ;
define ('BAZ_MOT_DE_PASSE', 'Mot de passe') ;
define ('BAZ_TITREANNONCE', 'Titre de la fiche') ;
if (!defined ('BAZ_TYPEANNONCE')) define ('BAZ_TYPEANNONCE', 'Type de fiche') ;
define ('BAZ_ANNONCEUR', 'Annonceur') ;
define ('BAZ_REPETE_MOT_DE_PASSE', 'R&eacute;p&eacute;ter le mot de passe :') ;
define ('BAZ_OUI', 'Oui') ;
define ('BAZ_NON', 'Non') ;
define ('BAZ_ANNULER', 'Annuler') ;
define ('BAZ_RETOUR', 'Retour') ;
define ('BAZ_RETABLIR', 'R&eacute;tablir') ;
define ('BAZ_VALIDER', 'Valider') ;
define ('BAZ_PUBLIER', 'Valider la publication') ;
define ('BAZ_ETATPUBLICATION', 'Etat de publication') ;
define ('BAZ_ENCOURSDEVALIDATION', 'En attente de validation');
define ('BAZ_REJETEE', 'Rejet&eacute;e');
define ('BAZ_PUBLIEE', 'Publi&eacute;e') ;
define ('BAZ_PAS_DE_FICHE', '<br />Vous n\'avez pas encore d&eacute;pos&eacute; de fiches.') ;
define ('BAZ_PAS_DE_FICHE_A_VALIDER', 'Pas de fiche &agrave; valider pour l\'instant.');
define ('BAZ_VOS_ANNONCES', 'Vos fiches d&eacute;pos&eacute;es') ;
define ('BAZ_ANNONCES_A_ADMINISTRER', 'Les fiches &agrave; valider') ;
define ('BAZ_MOTS_DE_PASSE_DIFFERENTS', 'Les mots de passe sont diff&eacute;rents !') ;
define ('BAZ_EMAIL_REQUIS', 'Vous devez saisir un email.') ;
define ('BAZ_MOT_DE_PASSE_REQUIS', 'Vous devez saisir un mot de passe.') ;
define ('BAZ_MAIL_INCORRECT', 'L\'email doit avoir une forme correcte, utilisateur@domaine.ext') ;
define ('BAZ_MAIL_DOUBLE', 'Cet email est d&eacute;j&agrave utilis&eacute; par quelqu\'un d\'autre') ;
define ('BAZ_NOTE_REQUIS', 'Indique les champs requis') ;
define ('BAZ_ERREUR_SAISIE', 'Erreur de saisie ') ;
define ('BAZ_VEUILLEZ_CORRIGER', 'Veuillez corriger') ;
define ('BAZ_VOIR_LA_FICHE', 'Voir la fiche');
define ('BAZ_MODIFIER', 'Modifier') ;
define ('BAZ_MODIFIER_LA_FICHE', 'Modifier la fiche') ;
define ('BAZ_SUPPRIMER', 'Supprimer') ;
define ('BAZ_SELECTION', '--S&eacute;lectionnez ici--');
define ('BAZ_DROITS_PAR_TYPE', 'Droits par type de fiches:');
define ('BAZ_TITRE_SAISIE_ANNONCE', 'Entrer une fiche de type: ');
define ('BAZ_ACCUEIL','Accueil');
define ('BAZ_SORTIRDELAPPLI','Quittez l\'application Bazar');
define ('BAZ_DEPOSE_UNE_NOUVELLE_ANNONCE', 'Saisir une fiche') ;
define ('BAZ_CHOIX_TYPEANNONCE', 'Choisissez le type de fiche que vous souhaitez d&eacute;poser:') ;
if (!defined('BAZ_GESTION_DES_DROITS')) define ('BAZ_GESTION_DES_DROITS', 'Gestion des droits');
define ('BAZ_DESCRIPTION_GESTION_DES_DROITS', 'Veuillez choisir un utilisateur dans la liste d&eacute;roulante ci-dessous pour administrer ses droits.');
define ('BAZ_LABEL_CHOIX_PERSONNE', 'Choix de la personne dans l\'annuaire: ');
define ('BAZ_CONFIRMATION_SUPPRESSION', 'Etes-vous s&ucirc;r de vouloir supprimer cette fiche ?') ;
define ('BAZ_NON_VALIDE', 'Non valide') ;
define ('BAZ_VALIDE', 'Valide') ;
define ('BAZ_VALIDER_LA_FICHE', 'Valider la fiche') ;
define ('BAZ_PRECEDENT', 'Pr&eacute;c&eacute;dent') ;
define ('BAZ_SUIVANT', 'Suivant') ;
define ('BAZ_PAS_DE_FICHE_CRIT', 'Pas de fiche correspondant &agrave; vos crit&egrave;res.') ;
define ('BAZ_TEXTE_IMG_ALTERNATIF', 'Image de la fiche');
define ('BAZ_NUM_FICHE', 'Num&eacute;ro de fiche');
define ('BAZ_ADMIN_ANNONCES', 'Modifier les types de fiches');
define ('BAZ_RECHERCHER_DES_ANNONCES', 'Rechercher des fiches');
define ('BAZ_RECHERCHE_AVANCEE', 'Recherche avanc&eacute;e >>');
define ('BAZ_RECHERCHE_DE_BASE','<< Recherche simple');
define ('BAZ_DESCRIPTION_RECHERCHE', 'En pr&eacute;cisant, ci dessus, le type de fiche cherch&eacute;, vous pourrez obtenir des fonctions de recherche avanc&eacute;.');
define ('BAZ_PAS_D_ANNONCES', 'Pas de fiches trouv&eacute;es.');
if (!defined ('BAZ_S_INSCRIRE_AUX_ANNONCES')) define ('BAZ_S_INSCRIRE_AUX_ANNONCES', 'S\'abonner &agrave; un type de fiche');
define ('BAZ_ABONNE', 'Abonn&eacute;');
define ('BAZ_PAS_ABONNE', 'Pas abonn&eacute;');
define ('BAZ_S_ABONNER', 'S\'abonner');
if (!defined ('BAZ_LAIUS_S_ABONNER')) define ('BAZ_LAIUS_S_ABONNER', '');
define ('BAZ_SE_DESABONNER', 'Se d&eacute;sabonner');
define ('BAZ_RSS', 'Flux RSS');
define ('BAZ_DERNIERE_ACTU', 'Derni&egrave;res actualit&eacute;s');
if (!defined ('BAZ_DERNIERES_FICHES')) define ('BAZ_DERNIERES_FICHES', 'Les derni&egrave;res fiches enregistr&eacute;es');
define ('BAZ_PROCHAINS_EVENEMENTS','Les prochains &eacute;v&eacute;nements');
define ('BAZ_A_MODERER',' &agrave; mod&eacute;rer');
define ('BAZ_CONSULTER','Consulter');
define ('BAZ_SAISIR','Saisir');
define ('BAZ_ADMINISTRER','Administrer');
define ('BAZ_FICHE_ECRITE','Fiche &eacute;crite par : ');
define ('BAZ_NB_VUS','Cette fiche a &eacute;t&eacute; consult&eacute;e ');
define ('BAZ_FOIS', ' fois depuis sa cr&eacute;ation.');
define ('BAZ_LES_COMMENTAIRES', 'Les commentaires sur cette fiche');
define ('BAZ_PAS_DE_COMMENTAIRES', 'Pas de commentaires post&eacute;s pour l\'instant, identifiez vous pour poster le premier !');
define ('BAZ_IL_Y_A', 'Il y a ');
define ('BAZ_COMMENTAIRE', 'commentaire : ');
define ('BAZ_COMMENTAIRES', 'commentaires : ');
define ('BAZ_COMMENTAIRE_AUTH', 'Identifiez vous pour ajouter le votre !');
define ('BAZ_ENTREZ_VOTRE_NOM', 'Entrez votre nom : ');
define ('BAZ_ENTREZ_VOTRE_COMMENTAIRE', 'Entrez votre commentaire : ');
define ('BAZ_ENVOYER','Envoyer');
define ('BAZ_NOM_REQUIS', 'Le champs nom ne doit pas rester vide');
define ('BAZ_COMMENTAIRE_REQUIS', 'Le champs commentaire ne doit pas rester vide');
define ('BAZ_LES_STRUCTURES_POSSEDANT_UNE_RESSOURCE', 'Les structures possédant cette ressource');
define ('BAZ_FICHES_PAS_VALIDEES','Fiches non valid&eacute;es');
define ('BAZ_FICHES_VALIDEES','Fiches valid&eacute;es');
define ('BAZ_LES_DEUX','Toutes les fiches');
define ('BAZ_VOIR_VOS_ANNONCES', 'Vos fiches');
define ('BAZ_RECHERCHER','Rechercher');
define ('BAZ_SAISIR_UNE_NOUVELLE_FICHE','Saisir une nouvelle fiche');
define ('BAZ_POUR_CHANGER_IMAGE','Pour changer d\'image, il suffit d\'en saisir une autre ci dessous.');
define ('BAZ_CONFIRMATION_SUPPRESSION_LIEN', 'Etes-vous s&ucirc;r de vouloir supprimer ce lien ?') ;
define ('BAZ_CONFIRMATION_SUPPRESSION_FICHIER', 'Etes-vous s&ucirc;r de vouloir supprimer ce fichier ?') ;
define ('BAZ_CONFIRMATION_SUPPRESSION_IMAGE', 'Etes-vous s&ucirc;r de vouloir supprimer cette image ?') ;
define ('BAZ_VALIDER_PUBLICATION', 'Valider la publication');
define ('BAZ_ENTRER_PROJET', 'ENTRER SUR L\'ESPACE DU PROJET');
define ('BAZ_GOOGLE_MSG', '<br />Si l\'&eacute;v&egrave;nement est bien situ&eacute; vous pouvez valider la fiche<br />');
define ('BAZ_SUPPRIMER_LA_FICHE', 'Supprimer la fiche');
define ('BAZ_INVALIDER_LA_FICHE', 'Invalider la fiche');
define ('BAZ_TOUTES_LES_FICHES', 'Toutes les fiches');
define ('BAZ_FICHE_INEXISTANTE', 'La fiche demand&eacute;e n\'existe pas') ;
 
define ('BAZ_LATITUDE', 'Latitude');
define ('BAZ_LONGITUDE', 'Longitude');
define ('BAZ_VERIFIER_MON_ADRESSE', 'V&eacute;rifier mon adresse avec la carte');
 
 
//================Textes pour les libellés======================================
define ('BAZ_ANNONCES','annonces');
define ('BAZ_PUBLICATIONS','publications');
define ('BAZ_EVENEMENTS','&eacute;v&egrave;nements');
define ('BAZ_FORMATIONS','formations');
define ('BAZ_SEJOURS','s&eacute;jours');
define ('BAZ_EMPLOIS','emplois');
define ('BAZ_RESS_HUMAINES','Ressources humaines');
define ('BAZ_RESS_DOCS','Ressources documentaires');
define ('BAZ_RESS_PHYSIQUES','Ressources physiques');
define ('BAZ_RESS_FINANCIERES','Ressources financi&egrave;res');
define ('BAZ_JEUX','jeux');
define ('BAZ_PETITES_ANNONCES','petites annonces');
define ('BAZ_BREVES','br&egrave;ves');
define('BAZ_COMPTES_RENDUS','comptes rendus');
define ('BAZ_REALISATION','r&eacute;alisation');
define ('BAZ_PERSONNES_EXPERTES','personnes expertes');
define ('BAZ_THEMATIQUE','th&eacute;matique');
define ('BAZ_THEMATIQUE_REQUIS','la thematique est requise');
define ('BAZ_SITE_INTERNET','site internet');
define ('BAZ_ADRESSE_CONTACT','Adresse du contact');
define ('BAZ_MAIL_CONTACT','Mail du contact');
define ('BAZ_MAIL_CONTACT_REQUIS','Le mail du contact est requis');
 
//================Textes pour les formations====================================
define ('BAZ_TITRE_FORMATION','Intitul&eacute; de la formation');
define ('BAZ_TITRE_FORMATION_REQUIS','L\'intitul&eacute; de la formation est obligatoire, veuillez le saisir');
define ('BAZ_SI_MODULE','Si plusieurs modules de formation');
define ('BAZ_NUMERO_MODULE','Num&eacute;ro de module');
define ('BAZ_NB_TOTAL_MODULE','Nombre total de modules');
define ('BAZ_TYPE_FORMATION','Type de la formation');
define ('BAZ_TYPE_FORMATION_REQUIS','Le type de la formation est obligatoire, veuillez le saisir');
define ('BAZ_SI_DIPLOMANTE','Si la formation est diplomante');
define ('BAZ_DIPLOME_PREPARE', 'Dipl&ograve;me pr&eacute;par&eacute;');
define ('BAZ_NIVEAU', 'Niveau');
define ('BAZ_SI_QUALIFIANTE', 'Si la formation est qualifiante');
define ('BAZ_QUALIF_PREPAREE', 'Qualification pr&eacute;par&eacute;e');
define ('BAZ_OBJECTIFS', 'Objectifs');
define ('BAZ_OBJECTIFS_REQUIS', 'Entrer les objectifs est obligatoire, veuillez les saisir');
define ('BAZ_CONTENU', 'Contenu');
define ('BAZ_PUBLIC', 'Publics');
define ('BAZ_PUBLIC_REQUIS', 'Publics');
define ('BAZ_CONDITIONS_ACCES', 'Conditions d\'acc&egrave;s');
define ('BAZ_DATE_DEBUT_FORMATION', 'Date de d&eacute;but de la formation');
define ('BAZ_DATE_FIN_FORMATION', 'Date de fin de la formation');
define ('BAZ_DATE_FIN_INSCRIPTION', 'Date limite d\'inscription');
define ('BAZ_CP_LIEU_EVENEMENT', 'Code postal du lieu de l\'&eacute;v&eacute;nement');
define ('BAZ_TARIF_INDIVIDUEL', 'Tarif individuel (en euros)');
define ('BAZ_TARIF_ENTREPRISE', 'Tarif entreprise (en euros)');
define ('BAZ_TARIF_OPCA', 'Tarif OPCA (en euros)');
define ('BAZ_NUM_AGREMENT', 'Num&eacute;ro d\'agr&eacute;ement de la structure');
define ('BAZ_NUM_AGREMENT_REQUIS', 'Le num&eacute;ro d\'agr&eacute;ement de la structure est obligatoire, veuillez le saisir');
define ('BAZ_ANNONCE_REQUIS','Le corps de l\'annonce est requis');
define ('BAZ_PRENOM_CONTACT', 'Pr&eacute;nom');
define ('BAZ_PRENOM_CONTACT_REQUIS', 'Le pr&eacute;nom de la personne contact est obligatoire, veuillez le saisir');
define ('BAZ_NOM_CONTACT', 'Nom');
define ('BAZ_NOM_CONTACT_REQUIS', 'Le nom de la personne contact est obligatoire, veuillez le saisir');
define ('BAZ_MAIL', 'Adresse &eacute;lectronique');
define ('BAZ_TELEPHONE', 'T&eacute;l&eacute;phone');
define ('BAZ_TELEPHONE_REQUIS', 'Le t&eacute;l&eacute;phone du contact est obligatoire, veuillez le saisir');
define ('BAZ_INTERVENANTS', 'Les intervenants');
define ('BAZ_INFOS_COMPLEMENTAIRE', 'Informations compl&eacute;mentaires');
define ('BAZ_COORDONNEES_CONTACT', 'Coordonn&eacute;es de la personne contact<br />');
define ('BAZ_DUREE_DE_PARUTION', '<strong>Dur&eacute;e de parution:</strong> la date de d&eacute;but de parution indique le moment ou la fiche devient visible sur le site, et la date de fin de parution, le moment o&ugrave; elle disparait.<br />');
define ('BAZ_LIGNE_HORIZONTALE', '<hr />');
define ('BAZ_CHAMPS_REQUIS', ': champs requis');
define ('BAZ_PAR', 'par');
define ('BAZ_CHAMPS_INDISPENSABLES_CLASSES', 'Champs indispensables pour les classes<br />');
define ('BAZ_ECRIT_LE',', &eacute;crit le ');
define ('BAZ_FICHES_CORRESPONDANTES', 'fiches correspondantes &agrave; votre recherche') ;
define ('BAZ_FICHE_CORRESPONDANTE', 'fiche correspondante à votre recherche') ;
define ('BAZ_RECHERCHE_FICHE', 'rechercher des fiches') ;
 
//================Le formulaire ================================================
define ('BAZ_AJOUTER_CHAMPS_DE_BASE', 'Ajouter les informations de base pour la fiche');
define ('BAZ_PAYS', 'Pays');
define ('BAZ_PAYS_REQUIS', 'Le champs pays est requis!');
define ('BAZ_ORGANISME', 'Organisme');
define ('BAZ_CONTACT', 'Contact');
define ('BAZ_REGION', 'R&eacute;gion');
define ('BAZ_REGION_REQUIS', 'Le champs r&eacute;gion est requis!');
define ('BAZ_DEPARTEMENT', 'D&eacute;partement') ;
define ('BAZ_DEPARTEMENT_REQUIS', 'Le champs d&eacute;partement est requis!');
define ('BAZ_LICENCE', 'Type de licence') ;
define ('BAZ_LICENCE_REQUIS', 'Le type de licence est requis!') ;
define ('BAZ_TITRE', 'Titre') ;
define ('BAZ_TITRE_REQUIS', 'Un titre de fiche est requis!') ;
define ('BAZ_DESCRIPTION', 'Description') ;
define ('BAZ_DESCRIPTION_REQUIS', 'Une description de la fiche est requise!!') ;
define ('BAZ_DATEDEBVALID', 'D&eacute;but de parution' );
define ('BAZ_DATEDEBVALID_REQUIS', 'La date de d&eacute;but de parution est requise!!') ;
define ('BAZ_DATEFINVALID', 'Fin de parution' );
define ('BAZ_DATEFINVALID_REQUIS', 'La date de fin de parution est requise!!') ;
define ('BAZ_DU', 'du') ;
define ('BAZ_AU', 'au') ;
define ('BAZ_LE', 'Le') ;
define ('BAZ_DATE_DEBUT_EVENEMENT', 'D&eacute;but de l\'&eacute;venement' );
define ('BAZ_DATE_DEBUT_EVENEMENT_REQUIS', 'La date de d&eacute;but de l\'&eacute;venement est requise!!') ;
define ('BAZ_DATE_FIN_EVENEMENT', 'Fin de l\'&eacute;venement' );
define ('BAZ_DATE_FIN_EVENEMENT_REQUIS', 'La date de fin de l\'&eacute;venement est requise!!') ;
define ('BAZ_LIEU_EVENEMENT', 'Lieu de l\'&eacute;venement' );
define ('BAZ_LIEU_EVENEMENT_REQUIS', 'Le lieu de l\'&eacute;venement est requis!!') ;
define ('BAZ_PAS_UNE_IMAGE', 'Ce fichier n\'est pas une image.' );
define ('BAZ_AJOUTER_IMAGE', 'Pour l\'instant, pas d\'image associ&eacute;e &agrave; la fiche, vous pouvez en ajouter une ci-dessous.' );
define ('BAZ_IMAGE', 'Image pour la fiche (facultatif)' );
define ('BAZ_IMAGE_VALIDE_REQUIS', 'Le fichier image n\'est pas valide.') ;
 
//================Textes pour les parutions=====================================
define ('BAZ_CODE', 'Code ISBN ou ISSN (s\'il existe)' );
define ('BAZ_NOM_AUTEUR', 'Auteur' );
define ('BAZ_NOM_AUTEUR_REQUIS', 'L\'auteur est requis');
define ('BAZ_EDITEUR', 'Editeur');
define ('BAZ_TYPE_PARUTION', 'Type de parution');
define ('BAZ_ANNONCE','Annonce');
define ('BAZ_CAPACITE_ACCUEIL', 'Capacit&eacute; d\'accueil' );
define ('BAZ_CAPACITE_ACCUEIL_REQUIS', 'La capacit&eacute; d\'accueil est requise!!') ;
define ('BAZ_NB_ANIMATEURS', 'Nombre d\'animateurs' );
define ('BAZ_NB_ANIMATEURS_REQUIS', 'Le nombre d\'animateurs est requis!!') ;
define ('BAZ_TARIF', 'Tarif (en euros)' );
define ('BAZ_TARIF_REQUIS', 'Le tarif est requis!!') ;
define ('BAZ_LISTE_TRANCHES_AGES', 'Tranches d\'&agrave;ges' );
define ('BAZ_LISTE_TRANCHES_AGES_REQUIS', 'Les tranches d\'&agrave;ges sont requises!!') ;
define ('BAZ_LISTE_URL', 'Liens associ&eacute;s &agrave; l\'annonce: ');
define ('BAZ_PAS_URL', 'Pour l\'instant, pas de lien associ&eacute; &agrave; la fiche, vous pouvez en ajouter ci-dessous.');
define ('BAZ_AJOUTER_URL', 'Ajouter un lien (URL) &agrave la fiche');
define ('BAZ_LIEN', 'Lien' );
define ('BAZ_LIEN_INTERNET', 'Liens Internet' );
define ('BAZ_URL_LIEN', 'Adresse du lien (URL)' );
define ('BAZ_URL_LIEN_REQUIS', 'L\'adresse du lien (URL) est requise!!') ;
define ('BAZ_URL_TEXTE', 'Texte du lien' );
define ('BAZ_URL_TEXTE_REQUIS', 'Le texte du lien est requis!!') ;
define ('BAZ_AJOUTER_FICHIER_JOINT','Ajouter un fichier joint &agrave la fiche');
define ('BAZ_FICHIER_JOINT', 'Fichier joint' );
define ('BAZ_LISTE_FICHIERS_JOINTS', 'Fichiers associ&eacute;s &agrave; la fiche ');
define ('BAZ_PAS_DE_FICHIERS_JOINTS', 'Pour l\'instant, pas de fichier associ&eacute; &agrave; la fiche, vous pouvez en ajouter ci-dessous.');
define ('BAZ_FICHIER','Fichier');
define ('BAZ_FICHIER_JOINT_REQUIS', 'Le fichier joint est requis!!') ;
define ('BAZ_FICHIER_DESCRIPTION', 'Description du fichier' );
define ('BAZ_FICHIER_TEXTE_REQUIS', 'Le texte du fichier est requis!!') ;
define ('BAZ_FICHIER_LABEL', 'Label du fichier') ;
define ('BAZ_FICHIER_LABEL_REQUIS', 'Le label du fichier est requis!!') ;
define ('BAZ_FICHIER_EXISTANT', 'Il existe d&eacute;j&agrave; un fichier du même nom sur le site.<br />Votre fiche a &eacute;t&eacute; associ&eacute;e avec le fichier existant d&eacute;j&agrave;.');
define ('BAZ_ACCEPTE_CONDITIONS', 'J\'accepte les conditions de saisie de la fiche');
define ('BAZ_ACCEPTE_CONDITIONS_REQUIS', 'Vous devez accepter les conditions de saisie de la fiche');
 
//================Textes pour les emplois=======================================
define ('BAZ_INTITULE_POSTE', 'Intitul&eacute; du poste');
define ('BAZ_INTITULE_POSTE_REQUIS', 'L\'intitul&eacute; du poste est requis');
define ('BAZ_DESCRIPTION_STRUCTURE', 'Description de la structure qui embauche');
define ('BAZ_DESCRIPTION_STRUCTURE_REQUIS', 'La description de la structure qui embauche est requise');
define ('BAZ_CP_LIEU_TRAVAIL', 'Code postal du lieu de travail');
define ('BAZ_LIEU_TRAVAIL', 'Lieu de travail');
define ('BAZ_MISSIONS', 'Missions du poste');
define ('BAZ_PROFIL', 'Profil du poste');
define ('BAZ_PROFIL_REQUIS', 'Le profil du poste est requis');
define ('BAZ_NIVEAU_DIPLOME_DEMANDE', 'Niveau de diplome demand&eacute;');
define ('BAZ_ELEGIBILITE', 'Elegibilit&eacute; (CES, Emploi jeune,...)');
define ('BAZ_TYPE_CONTRAT', 'Type de contrat');
define ('BAZ_TYPE_CONTRAT_REQUIS', 'Type de contrat requis');
define ('BAZ_FORME_CANDIDATURE', 'Moyen de candidature (envois de CV par mail, lettre manucrite,...)');
define ('BAZ_INDICE_SALAIRE', 'Indice salaire');
define ('BAZ_SALAIRE_BRUT_MENSUEL', 'Salaire brut mensuel');
define ('BAZ_SALAIRE_BRUT_MENSUEL_REQUIS', 'Le salaire brut mensuel est requis');
define ('BAZ_ECHEANCE_CANDIDATURE', 'Date d\'&eacute;ch&eacute;ance de candidature');
define ('BAZ_DATE_DEBUT_EMBAUCHE', 'Date de d&eacute;but d\'embauche');
 
//================Textes pour les ressources=======================================
define ('BAZ_THEME','Th&egrave;me');
define ('BAZ_THEME_REQUIS','Le th&egrave;me est requis');
define ('BAZ_TRANCHES_AGES','Tranches d\'&acirc;ge');
define ('BAZ_TRANCHES_AGES_REQUIS','les tranches d\'&acirc; soTRUCTUREnt requises');
define ('BAZ_PERIODE', 'P&eacute;riode');
define ('BAZ_PERIODE_REQUIS', 'P&eacute;riode requise');
define ('BAZ_NIVEAU_SCOLAIRE', 'Niveau scolaire');
define ('BAZ_DATE_DEBUT_SEJOUR', 'Date de d&eacute;but du s&eacute;jour');
define ('BAZ_DATE_DEBUT_SEJOUR_REQUIS', 'Date de d&eacute;but du s&eacute;jour requise');
define ('BAZ_DATE_FIN_SEJOUR', 'Date de fin du s&eacute;jour');
define ('BAZ_DATE_FIN_SEJOUR_REQUIS', 'Date de fin du s&eacute;jour requise');
define ('BAZ_LIEU', 'Lieu');
define ('BAZ_LIEU_REQUIS', 'Lieu requis');
define ('BAZ_MILIEU_DOMINANT', 'Milieu dominant');
define ('BAZ_HEBERGEMENT', 'H&eacute;bergement');
define ('BAZ_HEBERGEMENT_REQUIS', 'H&eacute;bergement requis');
define ('BAZ_NOMBRE_PLACES', 'Nombre de places');
define ('BAZ_NOMBRE_PLACES_REQUIS', 'Nombre de places requis');
define ('BAZ_NOMBRE_ANIMS', 'Nombre d\'animateurs');
define ('BAZ_NOMBRE_ANIMS_REQUIS', 'Nombre d\'animateurs requis');
define ('BAZ_QUALIF_ANIMS', 'Qualification des animateurs');
define ('BAZ_QUALIF_ANIMS_REQUIS', 'Qualification des animateurs requise');
define ('BAZ_AGREMENTS', 'Agr&eacute;ments');
define ('BAZ_ACTIVITES_DOMINANTES', 'Activit&eacute;s dominantes (en 3 mots cl&eacute;s)');
define ('BAZ_ACTIVITES_DOMINANTES_REQUIS', 'Activit&eacute;s dominantes requises');
define ('BAZ_PRECISION_PRIX', 'Pr&eacute;cision sur le prix');
define ('BAZ_PRECISION_PRIX_REQUIS', 'Pr&eacute;cision sur le prix requise');
define ('BAZ_VOYAGE_COMPRIS', 'Voyage compris');
define ('BAZ_VOYAGE_COMPRIS_REQUIS', 'Voyage compris requis');
define ('BAZ_AIDES_POSSIBLES', 'Aides possibles');
define ('BAZ_CHOISIR', 'Choisir...');
define ('BAZ_CHOISIR_OBLIGATOIRE', 'Il faut choisir une option dans la liste ');
define ('BAZ_INDIFFERENT','Indiff&eacute;rent');
 
define ('BAZ_COORDONNEES','Coordonn&eacute;es');
define ('BAZ_ANNEE_PARUTION','Ann&eacute;e de parution');
define ('BAZ_LANGUE','Langue');
define ('BAZ_THEMES','Thèmes');
define ('BAZ_PAS_D_APPROPRIATION','Aucune structure ne s\'est appropri&eacute; cette ressource pour l\'instant.');
define ('BAZ_STRUCTURE_POSSEDANT', 'structure poss&eacute;dant cette ressource.');
define ('BAZ_STRUCTURES_POSSEDANT', 'structures poss&eacute;dant cette ressource.');
define ('BAZ_SI_POSSEDE_RESSOURCE', 'Si vous poss&egrave;dez cette ressource dans votre structure:');
define ('BAZ_POSSEDE_DEJA_RESSOURCE', 'Vous poss&egrave;dez cette ressource.');
define ('BAZ_CLIQUER_POUR_VOUS_ENLEVER', 'cliquez ici pour vous enlever de la liste.');
define ('BAZ_IL_FAUT_ETRE_STRUCTURE', 'Seules les structures identifi&eacute;es peuvent s\'approprier cette ressource.');
define ('BAZ_IL_FAUT_ETRE_IDENTIFIE_STRUCTURE', 'En vous identifiant ou ou vous inscrivant en tant que structure, vous pouvez vous associer cette ressource.');
define ('BAZ_CLIQUER_POUR_APPARAITRE', 'cliquez ici pour appaitre dans la liste.');
define ('BAZ_NON_PRECISE','Non pr&eacute;cis&eacute;');
 
 
define ('BAZ_IDENTIFIEZ_VOUS_POUR_SAISIR', 'Pour saisir des fiches, voir vos fiches ou s\'abonner:<br /> veuillez vous identifier ou vous inscrire.');
define ('BAZ_EST_SUPERADMINISTRATEUR', 'Cette personne est un super-administrateur.<br />Il peut modifier le droits des utilisateurs et administrer toutes les rubriques de fiches.');
define ('BAZ_CHANGER_SUPERADMINISTRATEUR', 'Changer ses droits de super-administrateur pour en faire un utilisateur sans pouvoir');
define ('BAZ_AUCUN_DROIT', 'utilisateur sans pouvoir');
define ('BAZ_LABEL_REDACTEUR', 'r&eacute;dacteur');
define ('BAZ_DROIT_ADMIN', 'administrateur');
define ('BAZ_PASSER_SUPERADMINISTRATEUR', 'Passer la personne en super administrateur');
define ('BAZ_ENLEVER_DROIT', 'Passer en utilisateur sans pouvoir');
define ('BAZ_TYPE_ANNONCES', 'Types de fiche');
define ('BAZ_DROITS_ACTUELS', 'Droits actuels');
define ('BAZ_PASSER_EN', 'Passer en');
define ('BAZ_OU_PASSER_EN', 'ou passer en');
 
 
define ('BAZ_CHECKBOX_SUPERADMIN', 'Super administrateur : ');
define ('BAZ_RADIO_AUCUN', 'aucun &nbsp;');
define ('BAZ_RADIO_REDACTEUR', 'r&eacute;dacteur &nbsp;');
define ('BAZ_RADIO_ADMINISTRATEUR', 'administrateur &nbsp;');
 
//================Textes pour les sejours==================================
define ('BAZ_TITRE_SEJOUR','Titre du s&eacute;jour');
define ('BAZ_TITRE_SEJOUR_REQUIS','Le titre du s&eacute;jour est obligatoire, veuillez le saisir');
define ('BAZ_MAX_60_CAR', '(maximum 60 caractères)');
 
// ================ Texte pour les structures =============================
define ('BAZ_FICHE_STRUCTURE', 'Fiche structure') ;
define ('BAZ_NOM_STRUCTURE', 'Nom de la structure');
define ('BAZ_NOM_STRUCTURE_REQUIS', 'Le nom de la structure est requis');
define ('BAZ_RAISON_SOCIALE', 'Raison sociale');
define ('BAZ_RAISON_SOCIALE_REQUIS', 'Raison sociale requise');
define ('BAZ_OBJET', 'Objet');
define ('BAZ_OBJET_REQUIS', 'Objet requis');
define ('BAZ_ACTIONS', 'Actions');
define ('BAZ_PRODUCTIONS', 'Productions');
define ('BAZ_RESEAUX', 'Réseaux');
define ('BAZ_ADRESSE', 'Adresse');
define ('BAZ_ADRESSE_REQUIS', 'Adresse requise');
define ('BAZ_FAX', 'Fax');
//define ('BAZ_DERNIERES_FICHES', 'Derni&egrave;res fiches enregistr&eacute;es');
define ('BAZ_FICHE_NUMERO', 'Fiches n&deg;');
define ('BAZ_ECRITE', '&nbsp;&eacute;crite par&nbsp;');
 
//================ Administration de Bazar ================================
define ('BAZ_CONFIG', 'Configuration du bazar');
define ('BAZ_ENREGISTRER_ET_QUITTER', 'Enregistrer et quitter');
 
//================ Calendrier Bazar =======================================
 
define ('BAZ_LUNDI','Lundi');
define ('BAZ_MARDI','Mardi');
define ('BAZ_MERCREDI','Mercredi');
define ('BAZ_JEUDI','Jeudi');
define ('BAZ_VENDREDI','Vendredi');
define ('BAZ_SAMEDI','Samedi');
define ('BAZ_DIMANCHE','Dimanche');
 
define ('BAZ_LUNDI_COURT','Lun');
define ('BAZ_MARDI_COURT','Mar');
define ('BAZ_MERCREDI_COURT','Mer');
define ('BAZ_JEUDI_COURT','Jeu');
define ('BAZ_VENDREDI_COURT','Ven');
define ('BAZ_SAMEDI_COURT','Sam');
define ('BAZ_DIMANCHE_COURT','Dim');
 
define ('BAZ_JANVIER','Janvier');
define ('BAZ_FEVRIER','F&eacute;vrier');
define ('BAZ_MARS','Mars');
define ('BAZ_AVRIL','Avril');
define ('BAZ_MAI','Mai');
define ('BAZ_JUIN','Juin');
define ('BAZ_JUILLET','Juillet');
define ('BAZ_AOUT','Ao&ucirc;t');
define ('BAZ_SEPTEMBRE','Septembre');
define ('BAZ_OCTOBRE','Octobre');
define ('BAZ_NOVEMBRE','Novembre');
define ('BAZ_DECEMBRE','D&eacute;cembre');
 
/* +--Fin du code ----------------------------------------------------------------------------------------+
*
* $Log: not supported by cvs2svn $
* Revision 1.61.2.4 2008-02-08 08:19:32 alexandre_tb
* modification d un label
*
* Revision 1.61.2.3 2008-01-29 09:39:39 alexandre_tb
* utilisation d entite
*
* Revision 1.61.2.2 2007-12-04 09:08:06 alexandre_tb
* modification de label
*
* Revision 1.61.2.1 2007-11-21 10:01:22 alexandre_tb
* encodage
*
* Revision 1.61 2007-10-10 13:27:40 alexandre_tb
* correction encodage
*
* Revision 1.60 2007-10-01 12:05:07 alexandre_tb
* orthographe
*
* Revision 1.59 2007-09-28 14:07:01 jp_milcent
* Correction pour le numéro d'une page.
*
* Revision 1.58 2007-08-28 09:41:47 alexandre_tb
* correction orthographe
*
* Revision 1.57 2007-08-27 12:29:09 alexandre_tb
* quelques constantes rendus modifiable, avec if defined ...
*
* Revision 1.56 2007-07-02 13:46:45 alexandre_tb
* nouveaux labels
*
* Revision 1.55 2007-06-25 12:15:06 alexandre_tb
* merge from narmer
*
* Revision 1.54 2007-06-25 09:57:51 alexandre_tb
* nouveaux labels
*
* Revision 1.53 2007-06-04 15:26:42 alexandre_tb
* nouveaux labels
*
* Revision 1.52 2007/04/20 12:47:42 florian
* correction bugs suite au merge
*
* Revision 1.51 2007/04/20 09:57:21 florian
* correction bugs suite au merge
*
* Revision 1.50 2007/04/11 08:30:12 neiluj
* remise en état du CVS...
*
* Revision 1.42.2.2 2007/03/07 17:20:47 jp_milcent
* Ajout d'une majuscule accentuée.
*
* Revision 1.42.2.1 2007/01/29 10:54:25 alexandre_tb
* Mise en place de la constante BAZ_DERNIERES_FICHES pour remplacer le label en francais dans baz_liste
*
* Revision 1.42 2006/10/05 08:53:50 florian
* amelioration moteur de recherche, correction de bugs
*
* Revision 1.41 2006/09/21 14:19:39 florian
* amélioration des fonctions liés au wikini
*
* Revision 1.40 2006/07/19 12:50:00 alexandre_tb
* Un accent
*
* Revision 1.39 2006/06/29 10:30:26 florian
* correction de BAZ_MOT_CLE
*
* Revision 1.38 2006/05/19 13:53:45 florian
* stabilisation du moteur de recherche, corrections bugs, lien recherche avancee
*
* Revision 1.37 2006/04/28 12:46:14 florian
* integration des liens vers annuaire
*
* Revision 1.36 2006/03/14 17:10:21 florian
* ajout des fonctions de syndication, changement du moteur de recherche
*
* Revision 1.35 2006/03/02 20:36:52 florian
* les entrees du formulaire de saisir ne sont plus dans les constantes mias dans des tables qui gerent le multilinguisme.
*
* Revision 1.34 2006/03/01 16:23:22 florian
* modifs textes fr et correction bug "undefined index"
*
* Revision 1.33 2006/03/01 16:00:17 florian
* ajout de certains mots par rapport aux formulaires de saisie de ressources
*
* Revision 1.32 2006/02/09 18:00:17 florian
* ajout des trois mots, je sais c'est peu de choses!!
*
* Revision 1.31 2006/01/18 10:53:28 florian
* corrections bugs affichage fiche
*
* Revision 1.30 2006/01/05 16:28:25 alexandre_tb
* prise en chage des checkbox, reste la mise à jour à gérer
*
* Revision 1.29 2006/01/04 15:31:46 alexandre_tb
* ajout de label
*
* Revision 1.28 2006/01/03 10:19:31 florian
* Mise à jour pour accepter des parametres dans papyrus: faire apparaitre ou non le menu, afficher qu'un type de fiches, définir l'action par défaut...
*
* Revision 1.27 2006/01/02 13:24:23 alexandre_tb
* ajout de label
*
* Revision 1.26 2005/11/30 13:58:45 florian
* ajouts graphisme (logos, boutons), changement structure SQL bazar_fiche
*
* Revision 1.25 2005/11/24 16:17:13 florian
* corrections bugs, ajout des cases à cocher
*
* Revision 1.24 2005/11/08 16:09:26 florian
* modifs séjours
*
* Revision 1.23 2005/11/08 16:06:41 florian
* modifs séjours
*
* Revision 1.22 2005/11/07 17:30:36 florian
* ajout controle sur les listes pour la saisie
*
* Revision 1.21 2005/11/07 17:05:46 florian
* amélioration validation conditions de saisie, ajout des règles spécifiques de saisie des formulaires
*
* Revision 1.20 2005/11/04 17:13:49 florian
* ajout des textes et du formulaire pour les annonces
*
* Revision 1.19 2005/10/31 17:10:56 ddelon
* Reintegration des commits mysterieusement disparus
*
* Revision 1.18 2005/10/24 09:42:21 florian
* mise a jour appropriation
*
* Revision 1.17 2005/10/21 16:15:04 florian
* mise a jour appropriation
*
* Revision 1.13 2005/10/13 14:43:42 florian
* corrections pb accents
*
* Revision 1.12 2005/10/12 16:28:37 florian
* corrections fautes orthographes
*
* Revision 1.11 2005/10/12 16:27:22 florian
* ajout textes des Ressources
*
* Revision 1.10 2005/10/12 16:17:37 florian
* corrections pb accents
*
* Revision 1.9 2005/10/12 16:12:34 florian
* corrections pb accents
*
* Revision 1.8 2005/10/12 15:31:43 florian
* corrections pb accents
*
* Revision 1.7 2005/10/10 16:22:06 alexandre_tb
* Modification de label pour les rendre plus générique
*
* Revision 1.6 2005/09/30 23:04:31 ddelon
* calendrier bazar
*
* Revision 1.5 2005/09/30 12:22:54 florian
* Ajouts commentaires pour fiche, modifications graphiques, maj SQL
*
* Revision 1.3 2005/07/21 19:03:12 florian
* nouveautés bazar: templates fiches, correction de bugs, ...
*
* Revision 1.1.1.1 2005/02/17 18:05:11 florian
* Import initial de Bazar
*
* Revision 1.1.1.1 2005/02/17 11:09:50 florian
* Import initial
*
* Revision 1.1.1.1 2005/02/16 18:06:35 florian
* import de la nouvelle version
*
* Revision 1.6 2004/07/06 16:21:50 florian
* d&eacute;buggage modification + MAJ flux RSS
*
* Revision 1.5 2004/07/05 15:13:53 florian
* changement interface de saisie
*
* Revision 1.4 2004/07/02 14:51:41 florian
* ajouts de labels divers
*
* Revision 1.3 2004/07/01 16:37:14 florian
* ajout de labels
*
* Revision 1.2 2004/07/01 13:00:24 florian
* modif Florian
*
* Revision 1.1 2004/06/23 09:58:32 alex
* version initiale
*
* Revision 1.1 2004/06/18 09:00:46 alex
* version initiale
*
*
* +-- Fin du code ----------------------------------------------------------------------------------------+
*/
?>
/tags/v3.1-blanche-neige/langues/baz_langue_hu.inc.php
New file
0,0 → 1,136
<?php
/*vim: set expandtab tabstop=4 shiftwidth=4: */
// +------------------------------------------------------------------------------------------------------+
// | PHP version 4.1 |
// +------------------------------------------------------------------------------------------------------+
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org) |
// +------------------------------------------------------------------------------------------------------+
// | This library is free software; you can redistribute it and/or |
// | modify it under the terms of the GNU Lesser General Public |
// | License as published by the Free Software Foundation; either |
// | version 2.1 of the License, or (at your option) any later version. |
// | |
// | This library is distributed in the hope that it will be useful, |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
// | Lesser General Public License for more details. |
// | |
// | You should have received a copy of the GNU Lesser General Public |
// | License along with this library; if not, write to the Free Software |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
// +------------------------------------------------------------------------------------------------------+
// CVS : $Id: baz_langue_hu.inc.php,v 1.1 2007-10-23 14:30:06 alexandre_tb Exp $
/**
* Fichier de traduction en anglais de l'application Bazar
*
*@package bazar
//Auteur original :
*@author Alexandre GRANIER <alexandre@tela-botanica.org>
*@author Florian Schmitt <florian@ecole-et-nature.org>
//Autres auteurs :
*@author Aucun
*@copyright Tela-Botanica 2000-2008
*@version $Revision: 1.1 $ $Date: 2007-10-23 14:30:06 $
// +------------------------------------------------------------------------------------------------------+
*/
 
define ('BAZ_CONSULTER', 'Kereses');
define ('BAZ_VOIR_VOS_ANNONCES', 'Irt Oldala');
define ('BAZ_S_ABONNER', 'Regisztrál');
define ('BAZ_SAISIR', 'Irjon egy oldalt');
define ('BAZ_ADMINISTRER', 'Rendezze');
define ('BAZ_GESTION_DES_DROITS', 'Jobb');
 
define ('BAZ_TOUTES_LES_ANNONCES', 'Minden oldal');
define ('BAZ_TYPEANNONCE', 'Oldal tipusa');
define ('BAZ_TOUS_TYPES_FICHES', 'Minden tipusu oldal');
define ('BAZ_VALIDE', 'Jóváhagyás');
define ('BAZ_FICHES_PAS_VALIDEES', 'Nem ellenorzott');
define ('BAZ_FICHES_VALIDEES', 'Ellenorzott');
define ('BAZ_LES_DEUX', 'Ketto egyutt');
define ('BAZ_MOT_CLE', 'Kulcsszavak');
define ('BAZ_RECHERCHER', 'Keresés');
 
define ('BAZ_MODIFIER', 'Frissít');
define ('BAZ_SUPPRIMER', 'Töröl');
define ('BAZ_SUIVANT', 'Kovetkezo');
define ('BAZ_PRECEDENT', 'Elözõ');
define ('BAZ_ANNULER', 'Töröl');
define ('BAZ_VALIDER', 'Ok');
 
define ('BAZ_IL_Y_A', '');
define ('BAZ_FICHES_CORRESPONDANTES', ' keresés eredmemnyei');
define ('BAZ_VOS_ANNONCES', 'Oldala');
define ('BAZ_PUBLIEE', 'Editált');
define ('BAZ_SAISIR_UNE_NOUVELLE_FICHE', 'irj uj oldalt');
 
define ('BAZ_LE', 'A');
define ('BAZ_NB_VUS', 'Ez az oldalmeglátogatott');
define ('BAZ_FOIS', ' Hányszor');
define ('BAZ_DU', 'Kitõl');
define ('BAZ_AU', 'Kinek');
define ('BAZ_DATE_CREATION', 'Létrehozott a');
define ('BAZ_DATE_MAJ', 'Frissités');
define ('BAZ_FICHE_NUMERO', 'Oldal szám');
define ('BAZ_ECRITE', ' Valaki írta ');
 
define ('BAZ_INVALIDER_LA_FICHE', 'Nem editált');
define ('BAZ_MODIFIER_LA_FICHE', 'Módosítás');
define ('BAZ_SUPPRIMER_LA_FICHE', 'Törlés');
 
define ('BAZ_S_INSCRIRE_AUX_ANNONCES', 'Regisztrált');
define ('BAZ_LAIUS_S_ABONNER', '');
define ('BAZ_PAS_ABONNE', 'Nem regisztrált');
define ('BAZ_SE_DESABONNER', 'Nem regisztrált');
define ('BAZ_ABONNE', 'Regisztrált');
 
define ('BAZ_URL_LIEN', 'URL');
define ('BAZ_URL_TEXTE', 'A link szövege');
define ('BAZ_FICHIER_DESCRIPTION', 'Fijle leírása');
define ('BAZ_FICHIER_JOINT', 'Válassz egy fijlt');
define ('BAZ_IMAGE_VALIDE_REQUIS', 'Érvénytelen kép');
define ('BAZ_IDENTIFIEZ_VOUS_POUR_SAISIR', 'Please, log in');
 
define ('BAZ_ANNONCES_A_ADMINISTRER', 'Adminisztrativ oldalak');
define ('BAZ_OUI', 'Igen');
define ('BAZ_NON', 'Nem');
define ('BAZ_TOUTES_LES_FICHES', 'Minden oldal');
 
define ('BAZ_DESCRIPTION_GESTION_DES_DROITS', '');
define ('BAZ_LABEL_CHOIX_PERSONNE', 'Válassz valakit');
define ('BAZ_SELECTION', 'Válassz...');
define ('BAZ_PASSER_SUPERADMINISTRATEUR', 'Változtass, hogy kiemelt adminisztrátorlegyél');
define ('BAZ_DROITS_PAR_TYPE', 'Tipusonkénti jog');
define ('BAZ_LABEL_REDACTEUR', 'Iró');
define ('BAZ_AUCUN_DROIT', 'Nem jogosult');
define ('BAZ_DROIT_ADMIN', 'Admin');
 
define ('BAZ_JANVIER','Január');
define ('BAZ_FEVRIER','Február');
define ('BAZ_MARS','Március');
define ('BAZ_AVRIL','Április');
define ('BAZ_MAI','Május');
define ('BAZ_JUIN','Június');
define ('BAZ_JUILLET','Július');
define ('BAZ_AOUT','Augusztus');
define ('BAZ_SEPTEMBRE','Szeptember');
define ('BAZ_OCTOBRE','Október');
define ('BAZ_NOVEMBRE','November');
define ('BAZ_DECEMBRE','December');
 
define ('BAZ_LUNDI','Hétfõ');
define ('BAZ_MARDI','Kedd');
define ('BAZ_MERCREDI','Szerda');
define ('BAZ_JEUDI','Csütörtök');
define ('BAZ_VENDREDI','Péntek');
define ('BAZ_SAMEDI','Szombat');
define ('BAZ_DIMANCHE','Vasárnap');
 
define ('BAZ_LUNDI_COURT','Hét');
define ('BAZ_MARDI_COURT','Ked');
define ('BAZ_MERCREDI_COURT','Szer');
define ('BAZ_JEUDI_COURT','Csut');
define ('BAZ_VENDREDI_COURT','Pén');
define ('BAZ_SAMEDI_COURT','Szo');
define ('BAZ_DIMANCHE_COURT','Vas');
?>
/tags/v3.1-blanche-neige/langues/baz_langue_it.inc.php
New file
0,0 → 1,136
<?php
/*vim: set expandtab tabstop=4 shiftwidth=4: */
// +------------------------------------------------------------------------------------------------------+
// | PHP version 4.1 |
// +------------------------------------------------------------------------------------------------------+
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org) |
// +------------------------------------------------------------------------------------------------------+
// | This library is free software; you can redistribute it and/or |
// | modify it under the terms of the GNU Lesser General Public |
// | License as published by the Free Software Foundation; either |
// | version 2.1 of the License, or (at your option) any later version. |
// | |
// | This library is distributed in the hope that it will be useful, |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
// | Lesser General Public License for more details. |
// | |
// | You should have received a copy of the GNU Lesser General Public |
// | License along with this library; if not, write to the Free Software |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
// +------------------------------------------------------------------------------------------------------+
// CVS : $Id: baz_langue_it.inc.php,v 1.1 2007-10-23 14:30:06 alexandre_tb Exp $
/**
* Fichier de traduction en anglais de l'application Bazar
*
*@package bazar
//Auteur original :
*@author Alexandre GRANIER <alexandre@tela-botanica.org>
*@author Florian Schmitt <florian@ecole-et-nature.org>
//Autres auteurs :
*@author Aucun
*@copyright Tela-Botanica 2000-2008
*@version $Revision: 1.1 $ $Date: 2007-10-23 14:30:06 $
// +------------------------------------------------------------------------------------------------------+
*/
 
define ('BAZ_CONSULTER', 'Ricerca');
define ('BAZ_VOIR_VOS_ANNONCES', 'I vostri strati');
define ('BAZ_S_ABONNER', 'Registrarsi');
define ('BAZ_SAISIR', 'Scrivere');
define ('BAZ_ADMINISTRER', 'Dirigere');
define ('BAZ_GESTION_DES_DROITS', 'Diritti');
 
define ('BAZ_TOUTES_LES_ANNONCES', 'Tutte le schede');
define ('BAZ_TYPEANNONCE', 'Tipo di scheda');
define ('BAZ_TOUS_TYPES_FICHES', 'Qualsiasi tipo di schede');
define ('BAZ_VALIDE', 'Convalida');
define ('BAZ_FICHES_PAS_VALIDEES', 'Schede non convalidate');
define ('BAZ_FICHES_VALIDEES', 'Schede convalidate');
define ('BAZ_LES_DEUX', 'I due');
define ('BAZ_MOT_CLE', 'Parole chiave');
define ('BAZ_RECHERCHER', 'Cercare');
 
define ('BAZ_MODIFIER', 'Modificare');
define ('BAZ_SUPPRIMER', 'distruggere');
define ('BAZ_SUIVANT', 'secondo');
define ('BAZ_PRECEDENT', 'precedente');
define ('BAZ_ANNULER', 'annuler');
define ('BAZ_VALIDER', 'Ok');
 
define ('BAZ_IL_Y_A', 'C\'è');
define ('BAZ_FICHES_CORRESPONDANTES', ' risultati alla vostra richiesta');
define ('BAZ_VOS_ANNONCES', 'le vostre schede');
define ('BAZ_PUBLIEE', 'pubblicare');
define ('BAZ_SAISIR_UNE_NOUVELLE_FICHE', 'afferrare');
 
define ('BAZ_LE', 'Il');
define ('BAZ_NB_VUS', 'Questa pagina è stata visitata ');
define ('BAZ_FOIS', ' volta');
define ('BAZ_DU', 'da allora');
define ('BAZ_AU', 'a');
define ('BAZ_DATE_CREATION', 'creata il');
define ('BAZ_DATE_MAJ', 'Aggiornamento');
define ('BAZ_FICHE_NUMERO', 'numero di scheda ');
define ('BAZ_ECRITE', ' scritta da');
 
define ('BAZ_INVALIDER_LA_FICHE', 'Non convalidare');
define ('BAZ_MODIFIER_LA_FICHE', 'Modificare');
define ('BAZ_SUPPRIMER_LA_FICHE', 'Destrugere');
 
define ('BAZ_S_INSCRIRE_AUX_ANNONCES', 'apparire');
define ('BAZ_LAIUS_S_ABONNER', 'sottoscriversi');
define ('BAZ_PAS_ABONNE', 'non sottoscritto');
define ('BAZ_SE_DESABONNER', 'annullare la sua sottoscrizione');
define ('BAZ_ABONNE', 'abbonato');
 
define ('BAZ_URL_LIEN', 'URL');
define ('BAZ_URL_TEXTE', 'testo del legame');
define ('BAZ_FICHIER_DESCRIPTION', 'Descrizione dell\'archivio');
define ('BAZ_FICHIER_JOINT', 'Scegliete un archivio');
define ('BAZ_IMAGE_VALIDE_REQUIS', 'invalidare l\'immagine');
define ('BAZ_IDENTIFIEZ_VOUS_POUR_SAISIR', 'Please, log in');
 
define ('BAZ_ANNONCES_A_ADMINISTRER', 'schede da dirigere');
define ('BAZ_OUI', 'Si');
define ('BAZ_NON', 'No');
define ('BAZ_TOUTES_LES_FICHES', 'Tutte le schede');
 
define ('BAZ_DESCRIPTION_GESTION_DES_DROITS', 'Gestione dei diritti');
define ('BAZ_LABEL_CHOIX_PERSONNE', 'scegliete qualcuno');
define ('BAZ_SELECTION', 'scegliete...');
define ('BAZ_PASSER_SUPERADMINISTRATEUR', 'diventare super amministratore');
define ('BAZ_DROITS_PAR_TYPE', 'diritti per tipo di sheda');
define ('BAZ_LABEL_REDACTEUR', 'autore');
define ('BAZ_AUCUN_DROIT', 'senza diritti');
define ('BAZ_DROIT_ADMIN', 'Admin');
 
define ('BAZ_JANVIER','Gennaio');
define ('BAZ_FEVRIER','Febbraio');
define ('BAZ_MARS','Marzo ');
define ('BAZ_AVRIL','Aprile');
define ('BAZ_MAI','Maggio');
define ('BAZ_JUIN','Giugno');
define ('BAZ_JUILLET','Luglio');
define ('BAZ_AOUT','Agosto');
define ('BAZ_SEPTEMBRE','Settembre');
define ('BAZ_OCTOBRE','Ottobre');
define ('BAZ_NOVEMBRE','Novembre');
define ('BAZ_DECEMBRE','Dicembre');
 
define ('BAZ_LUNDI','Lunedì');
define ('BAZ_MARDI','Martedì ');
define ('BAZ_MERCREDI','Mercoledì');
define ('BAZ_JEUDI','Giovedì ');
define ('BAZ_VENDREDI','Venerdì');
define ('BAZ_SAMEDI','Sabato');
define ('BAZ_DIMANCHE','Domenica');
 
define ('BAZ_LUNDI_COURT','Lun');
define ('BAZ_MARDI_COURT','Mar');
define ('BAZ_MERCREDI_COURT','Mer');
define ('BAZ_JEUDI_COURT','Gio');
define ('BAZ_VENDREDI_COURT','Ven');
define ('BAZ_SAMEDI_COURT','Sab');
define ('BAZ_DIMANCHE_COURT','Dom');
?>
/tags/v3.1-blanche-neige/langues/baz_langue_fr.admin.inc.php
New file
0,0 → 1,55
<?php
//vim: set expandtab tabstop=4 shiftwidth=4:
 
// Copyright (C) 1999-2004 Tela Botanica (accueil@tela-botanica.org)
//
// Ce logiciel est un programme informatique servant à gérer du contenu et des
// applications web.
// Ce logiciel est régi par la licence CeCILL soumise au droit français et
// respectant les principes de diffusion des logiciels libres. Vous pouvez
// utiliser, modifier et/ou redistribuer ce programme sous les conditions
// de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA
// sur le site "http://www.cecill.info".
 
// En contrepartie de l'accessibilité au code source et des droits de copie,
// de modification et de redistribution accordés par cette licence, il n'est
// offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons,
// seule une responsabilité restreinte pèse sur l'auteur du programme, le
// titulaire des droits patrimoniaux et les concédants successifs.
 
// A cet égard l'attention de l'utilisateur est attirée sur les risques
// associés au chargement, à l'utilisation, à la modification et/ou au
// développement et à la reproduction du logiciel par l'utilisateur étant
// donné sa spécificité de logiciel libre, qui peut le rendre complexe à
// manipuler et qui le réserve donc à des développeurs et des professionnels
// avertis possédant des connaissances informatiques approfondies. Les
// utilisateurs sont donc invités à charger et tester l'adéquation du
// logiciel à leurs besoins dans des conditions permettant d'assurer la
// sécurité de leurs systèmes et ou de leurs données et, plus généralement,
// à l'utiliser et l'exploiter dans les mêmes conditions de sécurité.
 
// Le fait que vous puissiez accéder à cet en-tête signifie que vous avez
// pris connaissance de la licence CeCILL, et que vous en avez accepté les
// termes.
// ----
// CVS : $Id: baz_langue_fr.admin.inc.php,v 1.1 2007-02-02 14:01:53 alexandre_tb Exp $
 
/**
* Papyrus : Programme d'administration du bazar
*
* Fichier de de langue
*@package Bazar
//Auteur original :
*@author Alexandre Granier <alexandre@tela-botanica.org>
*@copyright Tela-Botanica 2000-2007
*@version $Revision: 1.1 $
// +------------------------------------------------------------------------------------------------------+
*/
 
 
/* +--Fin du code ---------------------------------------------------------------------------------------+
* $Log: not supported by cvs2svn $
* +--Fin du code ----------------------------------------------------------------------------------------+
*/
?>
/tags/v3.1-blanche-neige/langues/baz_langue_en.inc.php
New file
0,0 → 1,137
<?php
/*vim: set expandtab tabstop=4 shiftwidth=4: */
// +------------------------------------------------------------------------------------------------------+
// | PHP version 4.1 |
// +------------------------------------------------------------------------------------------------------+
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org) |
// +------------------------------------------------------------------------------------------------------+
// | This library is free software; you can redistribute it and/or |
// | modify it under the terms of the GNU Lesser General Public |
// | License as published by the Free Software Foundation; either |
// | version 2.1 of the License, or (at your option) any later version. |
// | |
// | This library is distributed in the hope that it will be useful, |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
// | Lesser General Public License for more details. |
// | |
// | You should have received a copy of the GNU Lesser General Public |
// | License along with this library; if not, write to the Free Software |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
// +------------------------------------------------------------------------------------------------------+
// CVS : $Id: baz_langue_en.inc.php,v 1.4 2007-10-23 14:30:23 alexandre_tb Exp $
/**
* Fichier de traduction en anglais de l'application Bazar
*
*@package bazar
//Auteur original :
*@author Alexandre GRANIER <alexandre@tela-botanica.org>
*@author Florian Schmitt <florian@ecole-et-nature.org>
//Autres auteurs :
*@author Aucun
*@copyright Tela-Botanica 2000-2008
*@version $Revision: 1.4 $ $Date: 2007-10-23 14:30:23 $
// +------------------------------------------------------------------------------------------------------+
*/
 
define ('BAZ_CONSULTER', 'Search');
define ('BAZ_VOIR_VOS_ANNONCES', 'Your sheets');
define ('BAZ_S_ABONNER', 'Register');
define ('BAZ_SAISIR', 'Write sheet');
define ('BAZ_ADMINISTRER', 'Administrate');
define ('BAZ_GESTION_DES_DROITS', 'Rights');
 
define ('BAZ_TOUTES_LES_ANNONCES', 'All sheets');
define ('BAZ_TYPEANNONCE', 'Type of sheet');
define ('BAZ_TOUS_TYPES_FICHES', 'All types of sheets');
define ('BAZ_VALIDE', 'Confirmation');
define ('BAZ_FICHES_PAS_VALIDEES', 'Unchecked');
define ('BAZ_FICHES_VALIDEES', 'Checked');
define ('BAZ_LES_DEUX', 'Both');
define ('BAZ_MOT_CLE', 'Keywords');
define ('BAZ_RECHERCHER', 'Search');
 
define ('BAZ_CHOISIR', 'Chose...');
define ('BAZ_MODIFIER', 'Update');
define ('BAZ_SUPPRIMER', 'Delete');
define ('BAZ_SUIVANT', 'Next');
define ('BAZ_PRECEDENT', 'Previous');
define ('BAZ_ANNULER', 'Cancel');
define ('BAZ_VALIDER', 'Ok');
 
define ('BAZ_IL_Y_A', '');
define ('BAZ_FICHES_CORRESPONDANTES', ' results match your query');
define ('BAZ_VOS_ANNONCES', 'Your sheets');
define ('BAZ_PUBLIEE', 'Edited');
define ('BAZ_SAISIR_UNE_NOUVELLE_FICHE', 'Write a new sheet');
 
define ('BAZ_LE', 'The');
define ('BAZ_NB_VUS', 'This page has been visited ');
define ('BAZ_FOIS', ' times');
define ('BAZ_DU', 'From');
define ('BAZ_AU', 'To');
define ('BAZ_DATE_CREATION', 'Created on ');
define ('BAZ_DATE_MAJ', 'Updated');
define ('BAZ_FICHE_NUMERO', 'Sheet number ');
define ('BAZ_ECRITE', ' Written by ');
 
define ('BAZ_INVALIDER_LA_FICHE', 'Unedit');
define ('BAZ_MODIFIER_LA_FICHE', 'Modify');
define ('BAZ_SUPPRIMER_LA_FICHE', 'Delete');
 
define ('BAZ_S_INSCRIRE_AUX_ANNONCES', 'Register');
define ('BAZ_LAIUS_S_ABONNER', '');
define ('BAZ_PAS_ABONNE', 'Not registered');
define ('BAZ_SE_DESABONNER', 'Unregisterd');
define ('BAZ_ABONNE', 'Registered');
 
define ('BAZ_URL_LIEN', 'URL');
define ('BAZ_URL_TEXTE', 'Text of the link');
define ('BAZ_FICHIER_DESCRIPTION', 'File description');
define ('BAZ_FICHIER_JOINT', 'Choose a file');
define ('BAZ_IMAGE_VALIDE_REQUIS', 'Invalid image');
 
define ('BAZ_ANNONCES_A_ADMINISTRER', 'Sheets to manage');
define ('BAZ_OUI', 'Yes');
define ('BAZ_NON', 'No');
define ('BAZ_TOUTES_LES_FICHES', 'All sheets');
define ('BAZ_IDENTIFIEZ_VOUS_POUR_SAISIR', 'Please, log in');
 
define ('BAZ_DESCRIPTION_GESTION_DES_DROITS', '');
define ('BAZ_LABEL_CHOIX_PERSONNE', 'Choose someone');
define ('BAZ_SELECTION', 'Select...');
define ('BAZ_PASSER_SUPERADMINISTRATEUR', 'Change to super admin');
define ('BAZ_DROITS_PAR_TYPE', 'Rights by type of sheet');
define ('BAZ_LABEL_REDACTEUR', 'Writer');
define ('BAZ_AUCUN_DROIT', 'No right');
define ('BAZ_DROIT_ADMIN', 'Admin');
 
define ('BAZ_JANVIER','January');
define ('BAZ_FEVRIER','February');
define ('BAZ_MARS','March');
define ('BAZ_AVRIL','April');
define ('BAZ_MAI','May');
define ('BAZ_JUIN','June');
define ('BAZ_JUILLET','July');
define ('BAZ_AOUT','August');
define ('BAZ_SEPTEMBRE','September');
define ('BAZ_OCTOBRE','October');
define ('BAZ_NOVEMBRE','November');
define ('BAZ_DECEMBRE','December');
 
define ('BAZ_LUNDI','Monday');
define ('BAZ_MARDI','Tuesday');
define ('BAZ_MERCREDI','Wednesday');
define ('BAZ_JEUDI','Thursday');
define ('BAZ_VENDREDI','Friday');
define ('BAZ_SAMEDI','Saturday');
define ('BAZ_DIMANCHE','Sunday');
 
define ('BAZ_LUNDI_COURT','Mon');
define ('BAZ_MARDI_COURT','Tue');
define ('BAZ_MERCREDI_COURT','Wed');
define ('BAZ_JEUDI_COURT','Thu');
define ('BAZ_VENDREDI_COURT','Fri');
define ('BAZ_SAMEDI_COURT','Sat');
define ('BAZ_DIMANCHE_COURT','Sun');
?>
/tags/v3.1-blanche-neige/patch-bazar-RSS-bugSuperAdmin.patch
New file
0,0 → 1,122
Index: bibliotheque/bazar.fonct.rss.php
===================================================================
--- bibliotheque/bazar.fonct.rss.php (révision 464)
+++ bibliotheque/bazar.fonct.rss.php (révision 465)
@@ -392,7 +392,7 @@
$res .= '<br />'."\n".'<div class="BAZ_cadre_fiche BAZ_cadre_fiche_'.$GLOBALS['_BAZAR_']['class'].'">'."\n";
$res .= '<h2 class="BAZ_titre BAZ_titre_'.$GLOBALS['_BAZAR_']['class'].'">'.BAZ_LES_STRUCTURES_POSSEDANT_UNE_RESSOURCE.'</h2>'."\n";
$requete = 'SELECT '.BAZ_CHAMPS_ID.', '.BAZ_CHAMPS_NOM.' FROM bazar_appropriation,'.BAZ_ANNUAIRE.' WHERE ba_ce_id_fiche='.$GLOBALS['_BAZAR_']['id_fiche'].' AND ba_ce_id_structure='.BAZ_CHAMPS_ID.' ORDER BY '.BAZ_CHAMPS_NOM.' ASC';
- $resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
+ $resultat = $GLOBALS['_BAZAR_']['db']->query($requete . ' -- ' . __FILE__ . ':' . __LINE__) ;
if (DB::isError ($resultat)) {
return $resultat->getMessage().'<br />'.$resultat->getDebugInfo();
}
@@ -640,18 +640,17 @@
function gen_RSS($typeannonce='', $nbitem='', $emetteur='', $valide=1, $requeteSQL='', $requeteSQLFrom = '', $requeteWhereListe = '', $categorie_nature='', $order = '') {
// generation de la requete MySQL personnalisee
- $req_where=0;
$requete = 'SELECT DISTINCT bf_id_fiche, bf_titre, bf_date_debut_validite_fiche, bf_description,bf_date_debut_evenement, bn_label_nature, bf_date_creation_fiche, bf_ce_utilisateur '.
'FROM bazar_fiche, bazar_nature '.$requeteSQLFrom.' WHERE '.$requeteWhereListe;
+
+ $where_cond = array();
if ($valide!=2) {
- $requete .= 'bf_statut_fiche='.$valide;
- $req_where=1;
+ $where_cond[] = 'bf_statut_fiche='.$valide;
}
$nomflux=html_entity_decode(BAZ_DERNIERE_ACTU);
if (!is_array ($typeannonce) && $typeannonce!='' and $typeannonce!='toutes') {
- if ($req_where==1) {$requete .= ' AND ';}
- $requete .= 'bf_ce_nature='.$typeannonce.' and bf_ce_nature=bn_id_nature ';;
- $req_where=1;
+ $where_cond[] = 'bf_ce_nature='.$typeannonce;
+ $where_cond[] = ' bf_ce_nature=bn_id_nature';
//le nom du flux devient le type d'annonce
$requete_nom_flux = 'select bn_label_nature from bazar_nature where bn_id_nature = '.$typeannonce;
$nomflux = $GLOBALS['_BAZAR_']['db']->getOne($requete_nom_flux) ;
@@ -659,38 +658,24 @@
// cas où on veut toutes les annonces
if ($typeannonce == 'toutes') {
- if ($req_where==1) {$requete .= ' AND ';}
- $requete .= 'bf_ce_nature IN (1,2,3,4' ;
- $chaine = '';
- $requete .= ') and bf_ce_nature=bn_id_nature ';
+ $where_cond[] = 'bf_ce_nature IN (1,2,3,4)';
+ $where_cond[] = 'bf_ce_nature=bn_id_nature';
}
// Cas ou il y plusieurs type d annonce demande
- if (is_array ($typeannonce)) {
- if ($req_where==1) {$requete .= ' AND ';}
- $requete .= 'bf_ce_nature IN (' ;
- $chaine = '';
- foreach ($typeannonce as $valeur) $chaine .= '"'.$valeur.'",' ;
- $requete .= substr ($chaine, 0, strlen ($chaine)-1) ;
- $requete .= ') and bf_ce_nature=bn_id_nature ';
+ if (is_array($typeannonce) && ! empty($typeannonce)) {
+ $where_cond[] = 'bf_ce_nature IN (' . '"' . implode('","', $typeannonce) . '"' . ')';
+ $where_cond[] = 'bf_ce_nature=bn_id_nature';
}
- $utilisateur = new Administrateur_bazar ($GLOBALS['AUTH']) ;
- if ($utilisateur->isSuperAdmin()) {
- $req_where=1;
- } else {
- if ($req_where==1) {
- $requete .= ' AND ';
- }
+ // useless ?
+ // $utilisateur = new Administrateur_bazar ($GLOBALS['AUTH']) ;
- }
+ $where_cond[] = 'bf_date_debut_evenement >= NOW()';
+ $where_cond[] = 'bn_id_nature=bf_ce_nature';
- $requete .= 'bf_date_debut_evenement >= NOW() AND bn_id_nature=bf_ce_nature';
-
if ($emetteur!='' && $emetteur!='tous') {
- if ($req_where==1) {$requete .= ' AND ';}
- $requete .= 'bf_ce_utilisateur='.$emetteur;
- $req_where=1;
+ $where_cond[] = 'bf_ce_utilisateur='.$emetteur;
//requete pour afficher le nom de la structure
$requetenom = 'SELECT '.BAZ_CHAMPS_NOM.', '.BAZ_CHAMPS_PRENOM.' FROM '.
BAZ_ANNUAIRE.' WHERE '.BAZ_CHAMPS_ID.'='.$emetteur;
@@ -701,26 +686,25 @@
$ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC);
$nomflux .= ' ('.$ligne[BAZ_CHAMPS_NOM].' '.$ligne[BAZ_CHAMPS_PRENOM].')';
}
- if ($requeteSQL!='') {
- if ($req_where==1) {$requete .= ' AND ';}
- $requete .= '('.$requeteSQL.')';
- $req_where=1;
+ if ($requeteSQL) {
+ $where_cond[] = $requeteSQL;
}
+
if ($categorie_nature!='') {
- if ($req_where==1) {$requete .= ' AND ';}
- $requete .= 'bn_ce_id_menu IN ('.$categorie_nature.') and bf_ce_nature=bn_id_nature ';
- $req_where=1;
+ $where_cond[] = 'bn_ce_id_menu IN ('.$categorie_nature.')';
+ $where_cond[] = 'bf_ce_nature=bn_id_nature';
}
if (isset($_REQUEST['departement'])) {
- if ($req_where==1) {$requete .= ' AND ';}
- $requete .= ' bf_cp_lieu_evenement LIKE "'.$_REQUEST['departement'].'%" ';
+ $where_cond[] = 'bf_cp_lieu_evenement LIKE "'.$_REQUEST['departement'].'%"';
}
+
+ $requete .= implode(' AND ', $where_cond);
$requete .= ' ORDER BY bf_date_debut_evenement ASC ';
if ($nbitem!='') {$requete .= ' LIMIT 0,'.$nbitem;}
- $resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
+ $resultat = $GLOBALS['_BAZAR_']['db']->query($requete . ' -- ' . __FILE__ . ':' . __LINE__) ;
//mail('aurelien@tela-botanica.org','requete',$requete);
/tags/v3.1-blanche-neige/images/BAZ_cadre_bas.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/tags/v3.1-blanche-neige/images/BAZ_cadre_bas.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/tags/v3.1-blanche-neige/images/cal_titre_fond-grey.png
Cannot display: file marked as a binary type.
svn:mime-type = image/png
/tags/v3.1-blanche-neige/images/cal_titre_fond-grey.png
New file
Property changes:
Added: svn:mime-type
+image/png
\ No newline at end of property
/tags/v3.1-blanche-neige/images/drapeau_vert.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/tags/v3.1-blanche-neige/images/drapeau_vert.png
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/tags/v3.1-blanche-neige/images/Bandeau-fiche-Ekotheque.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/tags/v3.1-blanche-neige/images/Bandeau-fiche-Ekotheque.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/tags/v3.1-blanche-neige/images/Puce-etoile-contact.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/tags/v3.1-blanche-neige/images/Puce-etoile-contact.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/tags/v3.1-blanche-neige/images/Logo_Evenements.jpg
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/tags/v3.1-blanche-neige/images/Logo_Evenements.jpg
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/tags/v3.1-blanche-neige/images/BAZ_formation_diplomante.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/tags/v3.1-blanche-neige/images/BAZ_formation_diplomante.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/tags/v3.1-blanche-neige/images/Bandeau-fiche-Actualites.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/tags/v3.1-blanche-neige/images/Bandeau-fiche-Actualites.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/tags/v3.1-blanche-neige/images/drapeau_bleu.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/tags/v3.1-blanche-neige/images/drapeau_bleu.png
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/tags/v3.1-blanche-neige/images/Puce-outils-2.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/tags/v3.1-blanche-neige/images/Puce-outils-2.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/tags/v3.1-blanche-neige/images/Puce-outils.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/tags/v3.1-blanche-neige/images/Puce-outils.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/tags/v3.1-blanche-neige/images/Projets-actif.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/tags/v3.1-blanche-neige/images/Projets-actif.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/tags/v3.1-blanche-neige/images/Puce-etoile-jaune.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/tags/v3.1-blanche-neige/images/Puce-etoile-jaune.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/tags/v3.1-blanche-neige/images/cal_img_fond.jpg
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/tags/v3.1-blanche-neige/images/cal_img_fond.jpg
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/tags/v3.1-blanche-neige/images/BAZ_formation_qualifiante.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/tags/v3.1-blanche-neige/images/BAZ_formation_qualifiante.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/tags/v3.1-blanche-neige/images/Logo_Formations.jpg
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/tags/v3.1-blanche-neige/images/Logo_Formations.jpg
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/tags/v3.1-blanche-neige/images/cal.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/tags/v3.1-blanche-neige/images/cal.png
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/tags/v3.1-blanche-neige/images/BAZ_mail.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/tags/v3.1-blanche-neige/images/BAZ_mail.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/tags/v3.1-blanche-neige/images/Titre_Emplois.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/tags/v3.1-blanche-neige/images/Titre_Emplois.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/tags/v3.1-blanche-neige/images/BAZ_telephone.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/tags/v3.1-blanche-neige/images/BAZ_telephone.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/tags/v3.1-blanche-neige/images/Titre_Evenements.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/tags/v3.1-blanche-neige/images/Titre_Evenements.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/tags/v3.1-blanche-neige/images/BAZ_encadre_barre.jpg
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/tags/v3.1-blanche-neige/images/BAZ_encadre_barre.jpg
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/tags/v3.1-blanche-neige/images/cal_titre.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/tags/v3.1-blanche-neige/images/cal_titre.png
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/tags/v3.1-blanche-neige/images/drapeau_rose.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/tags/v3.1-blanche-neige/images/drapeau_rose.png
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/tags/v3.1-blanche-neige/images/Titre_Formations.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/tags/v3.1-blanche-neige/images/Titre_Formations.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/tags/v3.1-blanche-neige/images/BAZ_cadre_haut.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/tags/v3.1-blanche-neige/images/BAZ_cadre_haut.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/tags/v3.1-blanche-neige/images/Puce-documents.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/tags/v3.1-blanche-neige/images/Puce-documents.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/tags/v3.1-blanche-neige/images/Titre_Parutions.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/tags/v3.1-blanche-neige/images/Titre_Parutions.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/tags/v3.1-blanche-neige/images/Zone-image.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/tags/v3.1-blanche-neige/images/Zone-image.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/tags/v3.1-blanche-neige/images/cal_titre_fond.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/tags/v3.1-blanche-neige/images/cal_titre_fond.png
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/tags/v3.1-blanche-neige/images/drapeau_orange.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/tags/v3.1-blanche-neige/images/drapeau_orange.png
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/tags/v3.1-blanche-neige/images/Puce-site.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/tags/v3.1-blanche-neige/images/Puce-site.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/tags/v3.1-blanche-neige/images/BAZ_formation_continue.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/tags/v3.1-blanche-neige/images/BAZ_formation_continue.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/tags/v3.1-blanche-neige/images/Logo_Annonces.jpg
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/tags/v3.1-blanche-neige/images/Logo_Annonces.jpg
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/tags/v3.1-blanche-neige/images/Bandeau-fiche-Projets.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/tags/v3.1-blanche-neige/images/Bandeau-fiche-Projets.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/tags/v3.1-blanche-neige/images/Titre_Sejours.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/tags/v3.1-blanche-neige/images/Titre_Sejours.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/tags/v3.1-blanche-neige/images/Logo_Emplois.jpg
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/tags/v3.1-blanche-neige/images/Logo_Emplois.jpg
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/tags/v3.1-blanche-neige/images/Puce-personnes.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/tags/v3.1-blanche-neige/images/Puce-personnes.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/tags/v3.1-blanche-neige/images/cal_precedent.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/tags/v3.1-blanche-neige/images/cal_precedent.png
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/tags/v3.1-blanche-neige/images/Titre_Annonces.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/tags/v3.1-blanche-neige/images/Titre_Annonces.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/tags/v3.1-blanche-neige/images/cal_pastille.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/tags/v3.1-blanche-neige/images/cal_pastille.png
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/tags/v3.1-blanche-neige/images/Logo_Parutions.jpg
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/tags/v3.1-blanche-neige/images/Logo_Parutions.jpg
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/tags/v3.1-blanche-neige/images/BAZ_rss.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/tags/v3.1-blanche-neige/images/BAZ_rss.png
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/tags/v3.1-blanche-neige/images/cal_px_infobulle.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/tags/v3.1-blanche-neige/images/cal_px_infobulle.png
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/tags/v3.1-blanche-neige/images/Logo_Sejours.jpg
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/tags/v3.1-blanche-neige/images/Logo_Sejours.jpg
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/tags/v3.1-blanche-neige/images/cal_suivant.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/tags/v3.1-blanche-neige/images/cal_suivant.png
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/tags/v3.1-blanche-neige/images/BAZ_encadre_haut.jpg
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/tags/v3.1-blanche-neige/images/BAZ_encadre_haut.jpg
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/tags/v3.1-blanche-neige/images/BAZ_Enfants.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/tags/v3.1-blanche-neige/images/BAZ_Enfants.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/tags/v3.1-blanche-neige/images/Puce-groupe-travail.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/tags/v3.1-blanche-neige/images/Puce-groupe-travail.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/tags/v3.1-blanche-neige/images/BAZ_encadre.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/tags/v3.1-blanche-neige/images/BAZ_encadre.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/tags/v3.1-blanche-neige/images/BAZ_encadre_bas.jpg
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/tags/v3.1-blanche-neige/images/BAZ_encadre_bas.jpg
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/tags/v3.1-blanche-neige/configuration/baz_config.defaut.inc.php
New file
0,0 → 1,385
<?php
/*vim: set expandtab tabstop=4 shiftwidth=4: */
// +------------------------------------------------------------------------------------------------------+
// | PHP version 4.1 |
// +------------------------------------------------------------------------------------------------------+
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org) |
// +------------------------------------------------------------------------------------------------------+
// | This library is free software; you can redistribute it and/or |
// | modify it under the terms of the GNU Lesser General Public |
// | License as published by the Free Software Foundation; either |
// | version 2.1 of the License, or (at your option) any later version. |
// | |
// | This library is distributed in the hope that it will be useful, |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
// | Lesser General Public License for more details. |
// | |
// | You should have received a copy of the GNU Lesser General Public |
// | License along with this library; if not, write to the Free Software |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
// +------------------------------------------------------------------------------------------------------+
// CVS : $Id: baz_config.inc.php,v 1.41 2008-10-29 15:45:08 alexandre_tb Exp $
/**
* Fichier de configuration du bazar
*
* A éditer de façon spécifique à chaque déploiement
*
*@package bazar
//Auteur original :
*@author Alexandre GRANIER <alexandre@tela-botanica.org>
*@author Florian SCHMITT <florian@ecole-et-nature.org>
//Autres auteurs :
*@copyright Tela-Botanica 2000-2004
*@version $Revision: 1.41 $ $Date: 2008-10-29 15:45:08 $
// +------------------------------------------------------------------------------------------------------+
*/
 
// +------------------------------------------------------------------------------------------------------+
// | LES CONSTANTES DES ACTIONS DE BAZAR |
// +------------------------------------------------------------------------------------------------------+
 
define ('BAZ_VOIR_TOUTES_ANNONCES', 1) ;
define ('BAZ_ACTION_VOIR_VOS_ANNONCES', 2);
define ('BAZ_DEPOSER_ANNONCE', 3) ;
define ('BAZ_ANNONCES_A_VALIDER', 4) ;
define ('BAZ_GERER_DROITS', 5) ;
define ('BAZ_ADMINISTRER_ANNONCES', 6) ;
define ('BAZ_MODIFIER_FICHE', 7) ;
if (!defined('BAZ_VOIR_FICHE')) define ('BAZ_VOIR_FICHE', 8) ;
define ('BAZ_SUPPRIMER_FICHE', 9) ;
define ('BAZ_ACTION_NOUVEAU', 10) ;
define ('BAZ_ACTION_NOUVEAU_V', 11) ;
define ('BAZ_ACTION_MODIFIER', 12) ;
define ('BAZ_ACTION_MODIFIER_V', 13) ;
define ('BAZ_ACTION_SUPPRESSION', 14) ;
define ('BAZ_ACTION_PUBLIER', 15) ;
define ('BAZ_ACTION_PAS_PUBLIER', 16) ;
define ('BAZ_S_INSCRIRE', 17);
define ('BAZ_VOIR_FLUX_RSS', 18);
define ('BAZ_ACTION_POST_VALIDATION', 19); // Cette action correspond a la page apres le depot
// d une fiche et propose de dupliquer la fiche ou
// de sortir
 
// Constante des noms des variables
define ('BAZ_VARIABLE_VOIR', 'vue');
define ('BAZ_VARIABLE_ACTION', 'action');
define ('BAZ_VARIABLE_ID_FICHE', 'id_fiche');
define ('BAZ_VARIABLE_DUPLICATION', 'duplication');
define ('BAZ_VARIABLE_CATEGORIE_NATURE', 'categorie_nature');
 
/** Indique les onglets de vues à afficher.*/
define ('BAZ_VOIR_AFFICHER', '1,2,3,4,5,6');// Indiquer les numéros des vues à afficher séparées par des virgules.
/** Permet d'indiquer la vue par défaut si la variable vue n'est pas défini dans l'url ou dans les paramêtre du menu Papyrus.*/
define ('BAZ_VOIR_DEFAUT', '2');// Par défaut 2 : Mes Fiches
define ('BAZ_VOIR_CONSULTER', 1);
define ('BAZ_VOIR_MES_FICHES', 2);
define ('BAZ_VOIR_S_ABONNER', 3);
define ('BAZ_VOIR_SAISIR', 4);
define ('BAZ_VOIR_ADMIN', 5);
define ('BAZ_VOIR_GESTION_DROITS', 6);
 
 
//==================================== LES FLUX RSS==================================
// Constantes liées aux flux RSS
//==================================================================================
 
define('BAZ_CREER_FICHIERS_XML',0); //0n ne cree pas le fichier XML dans rss/; 1=cree le fichier XML dans rss/
define('BAZ_RSS_NOMSITE','Educ-Envir.org'); //Nom du site indiqué dans les flux rss
define('BAZ_RSS_ADRESSESITE','http://educ-envir.org'); //Adresse Internet du site indiqué dans les flux rss
define('BAZ_RSS_DESCRIPTIONSITE','Educ-Envir.org, pour mutualiser l\'information en éducation à l\'environnement.'); //Description du site indiquée dans les flux rss
define('BAZ_RSS_LOGOSITE','http://ecole-et-nature.org/images/Logo_REN-Site.png'); //Logo du site indiqué dans les flux rss
define('BAZ_RSS_MANAGINGEDITOR', 'nom@domaine.tld') ; //Managing editor du site
define('BAZ_RSS_WEBMASTER', 'nom@domaine.tld') ; //Mail Webmaster du site
define('BAZ_RSS_CATEGORIE', 'Education a l\'environnement'); //catégorie du flux RSS
 
 
//==================================== PARAMETRAGE =================================
// Pour régler certaines fonctionnalité de l'application
//==================================================================================
 
define ('BAZ_ETAT_VALIDATION', 0);
//Valeur par défaut d'état de la fiche annonce après saisie
//Mettre 0 pour 'en attente de validation d'un administrateur'
//Mettre 1 pour 'directement validée en ligne'
 
define ('BAZ_TAILLE_MAX_FICHIER', 2000*1024);
//Valeur maximale en octets pour la taille d'un fichier joint à télécharger
 
define ('BAZ_TYPE_AFFICHAGE_LISTE', 'jma');
 
 
define ('BAZ_ANNUAIRE','gen_annuaire'); //Table annuaire
define ('BAZ_CHAMPS_ID','ga_id_administrateur'); //Champs index sur la table annuaire
define ('BAZ_CHAMPS_NOM','ga_nom'); //Champs nom sur la table annuaire
define ('BAZ_CHAMPS_PRENOM','ga_prenom'); //Champs prenom sur la table annuaire
define ('BAZ_CHAMPS_EST_STRUCTURE','a_est_structure'); //Champs indiquant si c'est une structure qui est identifiée
define ('BAZ_CHAMPS_EMAIL','ga_mail'); //Champs prenom sur la table annuaire
define ('BAZ_CHAMPS_MOT_DE_PASSE', 'ga_mot_de_passe');
define ('BAZ_CHAMPS_NOM_WIKI','a_nom_wikini'); //Champs nom wikini sur la table annuaire
 
 
if (!defined ('PAP_VERSION')) {
//================================ BASE DE DONNEES =================================
define ('BAZ_PROTOCOLE', 'mysql') ;
define ('BAZ_UTILISATEUR', '') ;
define ('BAZ_MOT_DE_PASSE_DB', '') ;
define ('BAZ_HOTE', 'localhost') ;
define ('BAZ_BASE', '') ;
define ('BAZ_TYPE_ENCODAGE','MD5');
 
// Formation du dsn
$dsn = BAZ_PROTOCOLE.'://'.BAZ_UTILISATEUR.':'.BAZ_MOT_DE_PASSE_DB.'@'.BAZ_HOTE.'/'.BAZ_BASE;
 
/** Pour les inclusions de bibliotheques PEAR, mieux vaux
* utiliser celle sur le serveur, sinon utiliser la fonction set_init_path
*/
 
 
include_once 'DB.php'; //appel de la librairie DB de PEAR
/** Variable globale contenant l'objet d'accès à la base de donnée */
$GLOBALS['ins_db'] =& DB::connect($dsn);
 
//=============================== AUTHENTIFICATION =================================
include_once 'Auth.php'; //appel de la librairie Auth de PEAR
/** Nom de la session PHP */
define ('BAZ_NOM_SESSION','');
/** Durée de la session PHP */
define ('BAZ_DUREE_SESSION',3600*12);
/** Tableau des parametres de l'authentification */
$params = array(
'dsn' => $dsn,
'table' => BAZ_ANNUAIRE,
'usernamecol' => BAZ__CHAMPS_MAIL,
'passwordcol' => BAZ_CHAMPS_MOT_DE_PASSE
);
/** Variable globale contenant l'objet d'authentification de l'application, un objet AUTH*/
$GLOBALS['AUTH']= &new Auth($GLOBALS['ins_db'], $params );
$GLOBALS['AUTH']->setSessionname(INS_NOM_SESSION);
$GLOBALS['AUTH']->setExpire(INS_DUREE_SESSION);
$GLOBALS['AUTH']->setShowLogin(false);
} else {
$GLOBALS['_BAZAR_']['db'] =& $GLOBALS['_GEN_commun']['pear_db'];
$GLOBALS['AUTH'] =& $GLOBALS['_GEN_commun']['pear_auth'];
}
 
/** Réglage des droits pour déposer des annonces */
// Mettre à true pour limiter le dépot aux rédacteurs
define ('BAZ_RESTREINDRE_DEPOT', 0) ;
 
/** Réglage de l'affichage de la liste deroulante pour la saisie des dates */
// Mettre à true pour afficher une liste deroulante vide pour la saisie des dates
define ('BAZ_DATE_VIDE', 0);
 
/** Réglage de l'URL de l'annuaire */
// Mettre l'URL correspondant à l'annuaire
define ('BAZ_URL_ANNUAIRE', '/page:annuaire');
 
// Mettre à true pour faire apparaitre un champs texte déroulant dans le formulaire
// de recherche des fiches, pour choisir les émetteurs
define ('BAZ_RECHERCHE_PAR_EMETTEUR', 1) ;
 
$GLOBALS['_BAZAR_']['url'] = $GLOBALS['_GEN_commun']['url'];
 
if(!defined(PAP_CHEMIN_RACINE)) {
define(PAP_CHEMIN_RACINE, '');
define('BAZ_CHEMIN_APPLI', PAP_CHEMIN_RACINE.'');
} else {
 
//BAZ_CHEMIN_APPLI : chemin vers l'application bazar METTRE UN SLASH (/) A LA FIN!!!!
define('BAZ_CHEMIN_APPLI', PAP_CHEMIN_RACINE.'client/bazar/');
}
 
/**Choix de l'affichage (true) ou pas (false) de l'email du rédacteur dans la fiche.*/
define('BAZ_FICHE_REDACTEUR_MAIL', true);// true ou false
 
//==================================== LES LANGUES ==================================
// Constantes liées à l'utilisation des langues
//==================================================================================
$GLOBALS['_BAZAR_']['langue'] = 'fr-FR';
define ('BAZ_LANGUE_PAR_DEFAUT', 'fr') ; //Indique un code langue par défaut
define ('BAZ_VAR_URL_LANGUE', 'lang') ; //Nom de la variable GET qui sera passée dans l'URL (Laisser vide pour les sites monolingues)
//code pour l'inclusion des langues NE PAS MODIFIER
if (BAZ_VAR_URL_LANGUE != '' && isset (${BAZ_VAR_URL_LANGUE})) {
include_once BAZ_CHEMIN_APPLI.'langues/baz_langue_'.${BAZ_VAR_URL_LANGUE}.'.inc.php';
} else {
include_once BAZ_CHEMIN_APPLI.'langues/baz_langue_'.BAZ_LANGUE_PAR_DEFAUT.'.inc.php';
}
 
// Option concernant la division des resultats en pages
define ('BAZ_NOMBRE_RES_PAR_PAGE', 30);
define ('BAZ_MODE_DIVISION', 'Jumping'); // 'Jumping' ou 'Sliding' voir http://pear.php.net/manual/fr/package.html.pager.compare.php
define ('BAZ_DELTA', 12); // Le nombre de page à afficher avant le 'next';
 
/** Réglage de l'affichage du formulaire de recherche avancee */
// Mettre à true pour afficher automatiquement le formulaire de recherche avancee, à false pour avoir un lien afficher la recherche avancee
define ('BAZ_MOTEUR_RECHERCHE_AVANCEE', 1);
 
/** Réglage de l'utilisation ou non des templates */
// Mettre à true pour afficher les pages incluses dans la base bazar_template, à false sinon
define ('BAZ_UTILISE_TEMPLATE', 1);
 
 
/** Mettre a 0 pour le pas proposer de filtre dans le moteur de recherche */
define ('BAZ_AFFICHER_FILTRE_MOTEUR', 1);
 
// Mettre ici le type d'annonce qui va s'afficher dans les calendriers.
// Il est possible d'indiquer plusieurs identifiant de nature de fiche (bn_id_nature) en séparant les nombre par des
// virgules : '1,2,3'
define ('BAZ_NUM_ANNONCE_CALENDRIER', 3);
 
define ('BAZ_CHEMIN_SQUELETTE', BAZ_CHEMIN_APPLI.'squelettes'.GEN_SEP);
define ('BAZ_SQUELETTE_DEFAUT', 'baz_cal.tpl.html');
 
define ('BAZ_GOOGLE_KEY', ''); // Indiquer ici la cle google necessaire pour l appli bazar.carte_google.php
 
if (defined ('BAZ_GOOGLE_KEY')) {
define ('BAZ_GOOGLE_CENTRE_LAT', '43.444943');
define ('BAZ_GOOGLE_CENTRE_LON', '3.537598');
define ('BAZ_GOOGLE_ALTITUDE', '8'); // de 1 a 15
define ('BAZ_GOOGLE_IMAGE_LARGEUR', 600); // en pixel
define ('BAZ_GOOGLE_IMAGE_HAUTEUR', 450);
define ('BAZ_GOOGLE_MAXIMISE_TAILLE', false); // Si a true, la carte essaie de s etendre sur toute la largeur disponible
define ('BAZ_GOOGLE_FOND_KML', '');
}
 
 
// Gestion des droits
 
// droit minimun pour pouvoir deposer une fiche, pour que le formulaire soit presente
$GLOBALS['droit_depot'] = '3' ;
 
/* +--Fin du code ----------------------------------------------------------------------------------------+
*
* $Log: not supported by cvs2svn $
* Revision 1.40 2008-10-27 16:52:38 aperonnet
* correction de fautes d'orthographe
*
* Revision 1.39 2008-09-17 14:08:45 alexandre_tb
* merge depuis aha
*
* Revision 1.38 2008-02-08 08:44:05 alexandre_tb
* ajout du bloc de configuration si installation hors de papyrus
*
* Revision 1.37 2007-12-14 09:53:23 alexandre_tb
* Fusion avec la livraison AHA : 14 decembre 2007
*
* Revision 1.36 2007-10-01 12:03:19 alexandre_tb
* constantes liees a la cartographie google des fiches
*
* Revision 1.35 2007-09-28 14:29:13 jp_milcent
* Ajout de la gestion de l'affichage des vues ou pas.
*
* Revision 1.34 2007-09-28 13:40:50 jp_milcent
* Précision sur la constante BAZ_FICHE_REDACTEUR_MAIL.
*
* Revision 1.33 2007-09-28 13:39:15 jp_milcent
* Ajout d'une constante permettant de configurer l'affichage ou pas du courriel du rédacteur d'une fiche.
*
* Revision 1.32 2007-09-18 07:38:58 alexandre_tb
* ajout de la constante BAZ_AFFICHER_FILTRE_MOTEUR pour enlever le choix du type de fiche dans le moteur de recherche.
*
* Revision 1.31 2007-08-27 12:29:48 alexandre_tb
* ajout de la constante BAZ_GOOGLE_KEY
*
* Revision 1.30 2007-07-04 10:04:40 alexandre_tb
* ajout d une variable $_GET['vue'] en complement de la variable action.
* Elle correspond aux 6 vues du bazar (consulter, mes fiches, s'abonner, saisir, administrer, gestion des droits)
*
* Revision 1.29 2007-06-25 09:57:37 alexandre_tb
* ajout de constante sur le chemin par defaut des squelettes
*
* Revision 1.28 2007/04/20 09:57:21 florian
* correction bugs suite au merge
*
* Revision 1.27 2007/04/11 08:30:12 neiluj
* remise en état du CVS...
*
* Revision 1.21.2.1 2007/02/15 13:43:54 jp_milcent
* Ajout de commentaire pour la constante utilisée par le Calendrier.
*
* Revision 1.21 2006/10/05 08:53:50 florian
* amelioration moteur de recherche, correction de bugs
*
* Revision 1.20 2006/07/04 13:59:01 alexandre_tb
* Ajout de la constante BAZ_NUM_ANNONCE_CALENDRIER dans le fichier de conf. Elle indique le type d'annonce que le calendrier doit afficher
*
* Revision 1.19 2006/06/21 15:40:15 alexandre_tb
* rétablissement du menu mes fiches
*
* Revision 1.18 2006/06/02 09:29:30 florian
* ajout constante nom wikini
*
* Revision 1.17 2006/05/19 13:53:57 florian
* stabilisation du moteur de recherche, corrections bugs, lien recherche avancee
*
* Revision 1.16 2006/05/17 09:48:48 alexandre_tb
* Ajout des constantes pour le découpage en page
*
* Revision 1.15 2006/04/28 12:46:14 florian
* integration des liens vers annuaire
*
* Revision 1.14 2006/03/24 09:23:30 alexandre_tb
* ajout de la variable globale $GLOBALS['_BAZAR_']['filtre']
*
* Revision 1.13 2006/03/14 17:10:21 florian
* ajout des fonctions de syndication, changement du moteur de recherche
*
* Revision 1.12 2006/02/07 13:57:41 alexandre_tb
* ajout de la constante pour masquer la liste des émetteurs
*
* Revision 1.11 2006/01/18 10:03:36 florian
* recodage de l'insertion et de la maj des données relatives aux listes et checkbox dans des formulaires
*
* Revision 1.10 2006/01/03 10:19:31 florian
* Mise à jour pour accepter des parametres dans papyrus: faire apparaitre ou non le menu, afficher qu'un type de fiches, définir l'action par défaut...
*
* Revision 1.9 2005/12/16 15:47:54 alexandre_tb
* ajout de l'option restreindre dépôt
*
* Revision 1.8 2005/10/24 09:42:21 florian
* mise a jour appropriation
*
* Revision 1.7 2005/10/21 16:15:04 florian
* mise a jour appropriation
*
* Revision 1.6 2005/09/30 12:22:54 florian
* Ajouts commentaires pour fiche, modifications graphiques, maj SQL
*
* Revision 1.4 2005/07/21 19:03:12 florian
* nouveautés bazar: templates fiches, correction de bugs, ...
*
* Revision 1.2 2005/02/22 15:34:17 florian
* integration dans Papyrus
*
* Revision 1.1.1.1 2005/02/17 18:05:11 florian
* Import initial de Bazar
*
* Revision 1.1.1.1 2005/02/17 11:09:50 florian
* Import initial
*
* Revision 1.1.1.1 2005/02/16 18:06:35 florian
* import de la nouvelle version
*
* Revision 1.5 2004/07/08 12:15:32 florian
* ajout constantes pour flux RSS
*
* Revision 1.4 2004/07/06 16:21:54 florian
* débuggage modification + MAJ flux RSS
*
* Revision 1.3 2004/07/02 14:50:47 florian
* ajout configuration de l'etat de l'annonce (visible,masquée,...)
*
* Revision 1.2 2004/07/01 10:13:30 florian
* modif Florian
*
* Revision 1.1 2004/06/23 09:58:32 alex
* version initiale
*
* Revision 1.1 2004/06/18 09:00:41 alex
* version initiale
*
*
* +-- Fin du code ----------------------------------------------------------------------------------------+
*/
?>
/tags/v3.1-blanche-neige/configuration/bazar.admin.config.defaut.php
New file
0,0 → 1,71
<?php
//vim: set expandtab tabstop=4 shiftwidth=4:
 
// Copyright (C) 1999-2004 Tela Botanica (accueil@tela-botanica.org)
//
// Ce logiciel est un programme informatique servant à gérer du contenu et des
// applications web.
// Ce logiciel est régi par la licence CeCILL soumise au droit français et
// respectant les principes de diffusion des logiciels libres. Vous pouvez
// utiliser, modifier et/ou redistribuer ce programme sous les conditions
// de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA
// sur le site "http://www.cecill.info".
 
// En contrepartie de l'accessibilité au code source et des droits de copie,
// de modification et de redistribution accordés par cette licence, il n'est
// offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons,
// seule une responsabilité restreinte pèse sur l'auteur du programme, le
// titulaire des droits patrimoniaux et les concédants successifs.
 
// A cet égard l'attention de l'utilisateur est attirée sur les risques
// associés au chargement, à l'utilisation, à la modification et/ou au
// développement et à la reproduction du logiciel par l'utilisateur étant
// donné sa spécificité de logiciel libre, qui peut le rendre complexe à
// manipuler et qui le réserve donc à des développeurs et des professionnels
// avertis possédant des connaissances informatiques approfondies. Les
// utilisateurs sont donc invités à charger et tester l'adéquation du
// logiciel à leurs besoins dans des conditions permettant d'assurer la
// sécurité de leurs systèmes et ou de leurs données et, plus généralement,
// à l'utiliser et l'exploiter dans les mêmes conditions de sécurité.
 
// Le fait que vous puissiez accéder à cet en-tête signifie que vous avez
// pris connaissance de la licence CeCILL, et que vous en avez accepté les
// termes.
// ----
// CVS : $Id: bazar.admin.config.php,v 1.1 2007-02-02 14:01:20 alexandre_tb Exp $
 
/**
* Papyrus : Programme d'administration du bazar
*
* Fichier de configuration
*@package Bazar
//Auteur original :
*@author Alexandre Granier <alexandre@tela-botanica.org>
*@copyright Tela-Botanica 2000-2007
*@version $Revision: 1.1 $
// +------------------------------------------------------------------------------------------------------+
*/
// +------------------------------------------------------------------------------------------------------+
// | ENTÊTE du PROGRAMME |
// +------------------------------------------------------------------------------------------------------+
 
// BAZ_CHEMIN_APPLI : chemin vers l'application bazar METTRE UN SLASH (/) A LA FIN!!!!
define('BAZ_CHEMIN_APPLI', PAP_CHEMIN_RACINE.'client/bazar/');
 
 
// Variable action
define ('BAZ_VARIABLE_ACTION', 'action');
 
// +------------------------------------------------------------------------------------------------------+
// | CONSTANTES D ACTION |
// +------------------------------------------------------------------------------------------------------+
 
define ('BAZ_ACTION_VOIR_TEMPLATE', 1);
 
 
/* +--Fin du code ---------------------------------------------------------------------------------------+
* $Log: not supported by cvs2svn $
* +--Fin du code ----------------------------------------------------------------------------------------+
*/
?>
/tags/v3.1-blanche-neige/bazar.calendrier.applette.php
New file
0,0 → 1,67
<?php
/*vim: set expandtab tabstop=4 shiftwidth=4: */
// Copyright (C) 1999-2004 Tela Botanica (accueil@tela-botanica.org)
//
// Ce logiciel est un programme informatique servant à gérer du contenu et des
// applications web.
// Ce logiciel est régi par la licence CeCILL soumise au droit français et
// respectant les principes de diffusion des logiciels libres. Vous pouvez
// utiliser, modifier et/ou redistribuer ce programme sous les conditions
// de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA
// sur le site "http://www.cecill.info".
 
// En contrepartie de l'accessibilité au code source et des droits de copie,
// de modification et de redistribution accordés par cette licence, il n'est
// offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons,
// seule une responsabilité restreinte pèse sur l'auteur du programme, le
// titulaire des droits patrimoniaux et les concédants successifs.
 
// A cet égard l'attention de l'utilisateur est attirée sur les risques
// associés au chargement, à l'utilisation, à la modification et/ou au
// développement et à la reproduction du logiciel par l'utilisateur étant
// donné sa spécificité de logiciel libre, qui peut le rendre complexe à
// manipuler et qui le réserve donc à des développeurs et des professionnels
// avertis possédant des connaissances informatiques approfondies. Les
// utilisateurs sont donc invités à charger et tester l'adéquation du
// logiciel à leurs besoins dans des conditions permettant d'assurer la
// sécurité de leurs systèmes et ou de leurs données et, plus généralement,
// à l'utiliser et l'exploiter dans les mêmes conditions de sécurité.
 
// Le fait que vous puissiez accéder à cet en-tête signifie que vous avez
// pris connaissance de la licence CeCILL, et que vous en avez accepté les
// termes.
// ----
// CVS : $Id: bazar.calendrier.applette.php,v 1.7 2007/02/15 18:16:45 jp_milcent Exp $
/**
* bazar_calendrier : programme affichant les evenements du bazar sous forme de Calendrier
*
*
*@package Bazar
//Auteur original :
*@author David DELON <david.delon@clapas.net>
*@version $Revision: 1.7 $ $Date: 2007/02/15 18:16:45 $
// +------------------------------------------------------------------------------------------------------+
*/
 
if (!defined('BAZ_VOIR_FICHE')) {
define ('BAZ_VOIR_FICHE', 8);
}
 
include_once 'configuration/baz_config.inc.php'; //fichier de configuration de Bazar
include_once 'bibliotheque/bazar.fonct.php'; //fichier des fonctions de Bazar
include_once 'bibliotheque/bazar.fonct.cal.php'; //fichier des fonctions de Bazar
 
$GLOBALS['_CAL_']['nom_fonction'] = 'afficherCalendrier';
$_GEN_commun['info_applette_nom_fonction'] = $GLOBALS['_CAL_']['nom_fonction'];
// Balise : CLIENT_BAZAR_CALENDRIER
$_GEN_commun['info_applette_balise'] = 'BAZAR_CALENDRIER';
 
 
function afficherCalendrier() {
 
return GestionAffichageCalendrier('calendrier_applette');
}
?>
/tags/v3.1-blanche-neige/documentation/bazar_v0.24.sql
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/tags/v3.1-blanche-neige/documentation/bazar_v0.24.sql
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/tags/v3.1-blanche-neige/documentation/doc_mise_a_jour.txt
New file
0,0 → 1,17
Pour mettre à jour le bazar:
 
- Mettre en place les tables manquantes (bazar_template)
- Ajouter tous les templates manquants (il doit y en avoir 8)
- Mettre à jour l'api de papyrus notament XML_Util
- vérifier la concordance entre bt_categorie_nature et bn_ce_id_menu
- dans papyrus, vérifier les arguments passés au menu en particulier l'argument "vue"
qui remplace dans la plupart des cas l'argument "action" (vue=1 pour consulter etc. voir baz_config.inc.php)
- puis vérfifier le fichier de configuration, ajouter les constantes qu'il pourrait manquer
notament BAZ_UTILISE_TEMPLATE qu'il faut mettre à 1, BAZ_AFFICHER_FILTRE_MOTEUR qui peut valoir 0 ou 1
- les constantes BAZ_VOIR_* vers le debut
- vérifier la version de papyrus, en particulier pour les flux RSS qui ont beaucoup évolué
- envoyer les fichiers de bazar, sauf le fichier de conf et le fichier de style css. - envoyer les fichiers de bazar, sauf le fichier de conf.
- Ajout du 28-09-2007 (jpm) : BAZ_VOIR_AFFICHER indique les vues (=onglets) que l'on veut afficher, par défaut toutes les vues sont affichées -> remplace l'utilisation des CSS pour cacher les onglets
- Ajout du 28-09-2007 (jpm) : BAZ_VOIR_DEFAUT permet d'indiquer la vue par défaut.
- Ajout du 28-09-2007 (jpm) : BAZ_FICHE_REDACTEUR_MAIL permet d'afficher ou pas le mail du rédacteur d'une fiche lors de la consultation de la fiche.
/tags/v3.1-blanche-neige/documentation/balises.txt
New file
0,0 → 1,2
Affichage calendrier :
CLIENT_BAZAR_CALENDRIER
/tags/v3.1-blanche-neige/bazar.admin.php
New file
0,0 → 1,172
<?php
//vim: set expandtab tabstop=4 shiftwidth=4:
 
// Copyright (C) 1999-2004 Tela Botanica (accueil@tela-botanica.org)
//
// Ce logiciel est un programme informatique servant à gérer du contenu et des
// applications web.
// Ce logiciel est régi par la licence CeCILL soumise au droit français et
// respectant les principes de diffusion des logiciels libres. Vous pouvez
// utiliser, modifier et/ou redistribuer ce programme sous les conditions
// de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA
// sur le site "http://www.cecill.info".
 
// En contrepartie de l'accessibilité au code source et des droits de copie,
// de modification et de redistribution accordés par cette licence, il n'est
// offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons,
// seule une responsabilité restreinte pèse sur l'auteur du programme, le
// titulaire des droits patrimoniaux et les concédants successifs.
 
// A cet égard l'attention de l'utilisateur est attirée sur les risques
// associés au chargement, à l'utilisation, à la modification et/ou au
// développement et à la reproduction du logiciel par l'utilisateur étant
// donné sa spécificité de logiciel libre, qui peut le rendre complexe à
// manipuler et qui le réserve donc à des développeurs et des professionnels
// avertis possédant des connaissances informatiques approfondies. Les
// utilisateurs sont donc invités à charger et tester l'adéquation du
// logiciel à leurs besoins dans des conditions permettant d'assurer la
// sécurité de leurs systèmes et ou de leurs données et, plus généralement,
// à l'utiliser et l'exploiter dans les mêmes conditions de sécurité.
 
// Le fait que vous puissiez accéder à cet en-tête signifie que vous avez
// pris connaissance de la licence CeCILL, et que vous en avez accepté les
// termes.
// ----
// CVS : $Id: bazar.admin.php,v 1.2 2007/04/20 09:57:21 florian Exp $
 
/**
* Papyrus : Programme d'administration du bazar
*
* La page contient l'appel aux fonctions de l'application de vérification de l'installation puis
* l'appel du fichier réalisant l'initialisation. Enfin, l'appel du fichier réalisant le rendu et
* retournant la page au navigateur client.
*
*@package Bazar
//Auteur original :
*@author Florian SCHMITT <florian.schmitt@laposte.net>
*@copyright Tela-Botanica 2000-2007
*@version $Revision: 1.2 $
// +------------------------------------------------------------------------------------------------------+
*/
// +------------------------------------------------------------------------------------------------------+
// | ENTÊTE du PROGRAMME |
// +------------------------------------------------------------------------------------------------------+
 
include_once 'configuration/baz_config.inc.php'; //fichier de configuration de Bazar
//appel du fichier de constantes des langues
include_once 'langues/baz_langue_'.$GLOBALS['_GEN_commun']['i18n'].'.inc.php';
 
 
// +------------------------------------------------------------------------------------------------------+
// | CLASSE |
// +------------------------------------------------------------------------------------------------------+
 
class Bazar_Admin {
var $objet_pear_auth;
var $objet_pear_db;
var $objet_pear_url;
var $sortie_xhtml;
/** Fonction redigerContenu() - Affiche le formulaire de r?action
*
*
* @return string Le HTML
*/
function afficherContenuCorps()
{
//-------------------------------------------------------------------------------------------------------------------
// Initialisation des attributs
$this->objet_pear_auth = $GLOBALS['_GEN_commun']['pear_auth'];
$this->objet_pear_db = $GLOBALS['_GEN_commun']['pear_db'];
$this->objet_pear_url = $GLOBALS['_GEN_commun']['url'];
$this->sortie_xhtml = '<h1>'.BAZ_CONFIG.'</h1>'."\n";
//-------------------------------------------------------------------------------------------------------------------
// Gestion des boutons de l'interface
if (isset($_POST['afficheur_annuler'])) {
return false;
} else if (isset($_POST['afficheur_enregistrer_quitter'])) {
$requete = 'UPDATE gen_menu SET gm_application_arguments="num_questionnaire='.$_POST['num_questionnaire'].
'||mail_questionnaire='.$_POST['mail_questionnaire'].'||texte_questionnaire_envoye='.$_POST['texte_questionnaire_envoye'].'" WHERE gm_id_menu='.$_GET['adme_menu_id'];
$resultat = $this->objet_pear_db->query($requete) ;
if (DB::isError($resultat)) {
die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ;
}
return false;
}
//--------------------------------------------------------------------------------------------------------------
// Gestion des valeurs par defauts, en fonctions des donnees sauvees dans le menu
$requete = 'SELECT gm_application_arguments FROM gen_menu WHERE gm_id_menu='.$_GET['adme_menu_id'];
$resultat = $this->objet_pear_db->query($requete) ;
//echo $requete;
if (DB::isError($resultat)) {
die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ;
}
$valeurs_par_defaut = array();
if ($resultat->numRows()>0) {
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_OBJECT)) {
$arguments = explode('||', $ligne->gm_application_arguments);
for ($i = 0; $i < count($arguments); $i++) {
$attr = explode('=', $arguments[$i], 2);
if ($attr[0] != '') {
$info_application->$attr[0] = (isset($attr[1]) ? $attr[1] : '');
}
}
}
//valeurs par defaut enregistrees dans la table
if (isset($info_application)) {
$valeurs_par_defaut['num_questionnaire']=$info_application->num_questionnaire;
$valeurs_par_defaut['mail_questionnaire']=$info_application->mail_questionnaire;
$valeurs_par_defaut['texte_questionnaire_envoye']=$info_application->texte_questionnaire_envoye;
}
} else {
//valeurs par defaut pour afficher une carto des structures
$valeurs_par_defaut['num_questionnaire']='';
$valeurs_par_defaut['mail_questionnaire']='';
$valeurs_par_defaut['texte_questionnaire_envoye']='';
}
//--------------------------------------------------------------------------------------------------------------
// Gestion du questionnaire
$this->objet_pear_url->addQueryString('adme_site_id', $_GET['adme_site_id']);
$this->objet_pear_url->addQueryString('adme_menu_id', $_GET['adme_menu_id']);
$this->objet_pear_url->addQueryString('adme_action', 'administrer');
$form =& new HTML_QuickForm('form_param_bazar', 'post', str_replace('&amp;', '&', $this->objet_pear_url->getUrl()));
$squelette =& $form->defaultRenderer();
$squelette->setFormTemplate("\n".'<form {attributes}>'."\n".'{content}'."\n".'</form>'."\n");
$squelette->setElementTemplate( '<p>'."\n".
'<label style="width:100px;padding:5px;text-align:right;">{label}'.
'<!-- BEGIN required --><span class="symbole_obligatoire">*</span><!-- END required -->'."\n".
'<!-- BEGIN error --><span class="erreur">{error}</span><!-- END error -->'."\n".
' : </label>'."\n".'{element}'."\n".
'</p>'."\n" );
$form->addElement('text', 'mail_questionnaire', QUESTIONNAIRE_MAIL);
$liste_bouton_debut = '<ul class="liste_bouton">'."\n";
$form->addElement('html', $liste_bouton_debut);
$form->addElement('submit', 'afficheur_enregistrer_quitter', BAZ_ENREGISTRER_ET_QUITTER);
$form->addElement('submit', 'afficheur_annuler', BAZ_ANNULER);
$liste_bouton_fin = '</ul>'."\n";
$form->addElement('html', $liste_bouton_fin);
$form->setDefaults($valeurs_par_defaut);
$this->sortie_xhtml .= $form->toHTML()."\n";
return $this->sortie_xhtml;
}
 
}// Fin de la classe
 
// +------------------------------------------------------------------------------------------------------+
// | PIED du PROGRAMME |
// +------------------------------------------------------------------------------------------------------+
/* +--Fin du code ---------------------------------------------------------------------------------------+
* $Log: bazar.admin.php,v $
* Revision 1.2 2007/04/20 09:57:21 florian
* correction bugs suite au merge
*
* Revision 1.1 2007/02/02 14:02:08 alexandre_tb
* version initiale vide pour le moment
*
* +--Fin du code ----------------------------------------------------------------------------------------+
*/
?>
/tags/v3.1-blanche-neige/bibliotheque/bazar.fonct.cal.php
New file
0,0 → 1,511
<?php
/*vim: set expandtab tabstop=4 shiftwidth=4: */
// +------------------------------------------------------------------------------------------------------+
// | PHP version 4.1 |
// +------------------------------------------------------------------------------------------------------+
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org) |
// +------------------------------------------------------------------------------------------------------+
// | This library is free software; you can redistribute it and/or |
// | modify it under the terms of the GNU Lesser General Public |
// | License as published by the Free Software Foundation; either |
// | version 2.1 of the License, or (at your option) any later version. |
// | |
// | This library is distributed in the hope that it will be useful, |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
// | Lesser General Public License for more details. |
// | |
// | You should have received a copy of the GNU Lesser General Public |
// | License along with this library; if not, write to the Free Software |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
// +------------------------------------------------------------------------------------------------------+
// CVS : $Id: bazar.fonct.cal.php,v 1.29 2008-10-29 10:38:51 alexandre_tb Exp $
/**
*
* Fonctions calendrier du module bazar
*
* TODO : ajouter la gestion du multilinguisme
*
*@package bazar
//Auteur original :
*@author David Delon <david.delon@clapas.net>
//Autres auteurs :
*@copyright Tela-Botanica 2000-2004
*@version $Revision: 1.29 $ $Date: 2008-10-29 10:38:51 $
// +------------------------------------------------------------------------------------------------------+
*/
 
// +------------------------------------------------------------------------------------------------------+
// | ENTETE du PROGRAMME |
// +------------------------------------------------------------------------------------------------------+
 
require_once PAP_CHEMIN_RACINE.'api/pear/Calendar/Month/Weekdays.php';
require_once PAP_CHEMIN_RACINE.'api/pear/Calendar/Day.php';
require_once PAP_CHEMIN_RACINE.'api/pear/Calendar/Decorator.php';
 
// +------------------------------------------------------------------------------------------------------+
// | LISTE de FONCTIONS |
// +------------------------------------------------------------------------------------------------------+
 
// Classe Utilitaire pour Calendrier
class DiaryEvent extends Calendar_Decorator {
var $entry = array();
function DiaryEvent($calendar)
{
Calendar_Decorator::Calendar_Decorator($calendar);
}
function setEntry($entry)
{
$this->entry[] = $entry;
}
function getEntry()
{
return $this->entry;
}
}
 
 
// $type : calendrier
// $type : calendrier_appplette
function GestionAffichageCalendrier($arguments = array(), $type = 'calendrier') {
$script = '';
// recuperation des arguments de l applette
$balise = isset ($arguments[0]) ? $arguments[0] : '';
$tab_arguments = $arguments;
if (is_string ($tab_arguments)) {
$tab_arguments = substr($tab_arguments, 1);
} else {
unset($tab_arguments[0]);
}
if (is_array($tab_arguments)) {
foreach($tab_arguments as $argument) {
if ($argument != '') {
$tab_parametres = explode('=', $argument, 2);
if (is_array($tab_parametres)) {
$options[$tab_parametres[0]] =
(isset($tab_parametres[1])? trim($tab_parametres[1], '"') : '') ;
}
}
}
}
if (!isset($options['template'])) {
$options['template'] = BAZ_CHEMIN_SQUELETTE.BAZ_SQUELETTE_DEFAUT;
} else {
if (file_exists(BAZ_CHEMIN_SQUELETTE.$options['template'])) {
$options['template'] = BAZ_CHEMIN_SQUELETTE.$options['template'];
}
}
$retour = '';
 
$url = $GLOBALS['_GEN_commun']['url'] ;
$db =& $GLOBALS['_GEN_commun']['pear_db'] ;
$auth =& $GLOBALS['_GEN_commun']['pear_auth'] ;
// Nettoyage de l'url de la query string
$chaine_url = $url->getQueryString();
$tab_params = explode('&amp;', $chaine_url);
if (count($tab_params) == 0) {
$tab_params = explode('&', $chaine_url);
}
foreach ($tab_params as $param) {
$tab_parametre = explode('=', $param);
// note d'Aurélien, si on nettoie l'URL on perd la vue en cours
//$url->removeQueryString($tab_parametre[0]);
}
if (!isset($_GET['y'])) {
$_GET['y'] = date('Y');
}
if (!isset($_GET['m'])) {
$_GET['m'] = date('m');
}
// Construction Mois en Cours
$month = new Calendar_Month_Weekdays($_GET['y'],$_GET['m']);
 
$curStamp = $month->getTimeStamp();
$url->addQueryString('y', date('Y',$curStamp));
$url->addQueryString('m', date('n',$curStamp));
$url->addQueryString('d', date('j',$curStamp));
$cur = $url->getUrl();
 
// Gestion de l'affichage du filtre des natures d'évènements
$cal_num_annonce = BAZ_NUM_ANNONCE_CALENDRIER;
$ficnat_id = null;
if (isset($_GET['ficnat']) && $_GET['ficnat'] != '*') {
$ficnat_id = $_GET['ficnat'];
$url->addQueryString('ficnat', $_GET['ficnat']);
$cal_num_annonce = $_GET['ficnat'];
}
 
// Gestion de l'affichage des titres des évènements
if (isset($_GET['ctt']) && $_GET['ctt'] == '1') {
$url->addQueryString('tt', '0');
if (isset($_GET['tt']) && $_GET['tt'] == '0') {
$url->addQueryString('tt', '1');
}
$tc_lien = $url->getUrl();
} else {
$url->addQueryString('tt', '0');
if (isset($_GET['tt']) && $_GET['tt'] == '0') {
$url->addQueryString('tt', '1');
}
$url->addQueryString('ctt', '1');
$tc_lien = $url->getUrl();
}
$url->removeQueryString('ctt');
$url->removeQueryString('tt');
$tc_txt = 'Afficher les titres complets des évènements';
if (isset($_GET['tt']) && $_GET['tt'] == '0') {
$tc_txt = 'Tronquer les titres des évènements';
$url->addQueryString('tt', $_GET['tt']);
}
 
// Gestion des champs cachés pour le formulaire de filtre
// Attention à la position dans le fichier...
$ficnat_chps_cache = $url->querystring;
unset($ficnat_chps_cache['ficnat']);
// Navigation
$prevStamp = $month->prevMonth(true);
$url->addQueryString('y', date('Y',$prevStamp));
$url->addQueryString('m', date('n',$prevStamp));
$url->addQueryString('d', date('j',$prevStamp));
$prev = $url->getUrl();
$nextStamp = $month->nextMonth(true);
$url->addQueryString('y', date('Y',$nextStamp));
$url->addQueryString('m', date('n',$nextStamp));
$url->addQueryString('d', date('j',$nextStamp));
$next = $url->getUrl();
// Suppression du paramêtre de troncage des titres
$url->removeQueryString('tt');
$fr_month = array( "1"=>BAZ_JANVIER,"2"=>BAZ_FEVRIER,"3"=>BAZ_MARS,"4"=>BAZ_AVRIL,"5"=>BAZ_MAI,"6"=>BAZ_JUIN,
"7"=>BAZ_JUILLET,"8"=>BAZ_AOUT,"9"=>BAZ_SEPTEMBRE,"10"=>BAZ_OCTOBRE,"11"=>BAZ_NOVEMBRE,"12"=>BAZ_DECEMBRE);
 
// Récupération des infos sur les natures des fiches pour le filtre
$requete_nature_fiche = 'SELECT DISTINCT bn_id_nature, bn_ce_i18n, bn_label_nature '.
'FROM bazar_nature '.
'WHERE bn_id_nature IN ('.BAZ_NUM_ANNONCE_CALENDRIER.') ';
$resultat_nature_fiche = $db->query($requete_nature_fiche);
(DB::isError($resultat_nature_fiche)) ? trigger_error(BOG_afficherErreurSql(__FILE__, __LINE__, $resultat_nature_fiche->getMessage(), $requete_nature_fiche), E_USER_WARNING) : '';
// Ajout du javascript et des styles du bazar
if (defined('PAP_VERSION')) { //si on est dans Papyrus
GEN_stockerStyleExterne( 'bazar_interne', 'client/bazar/bazar.interne.css');
GEN_stockerFichierScript('domLib', '/api/js/domtooltip/domLib.js');
GEN_stockerFichierScript('domTT', '/api/js/domtooltip/domTT.js');
// DomToolTip
$script = 'var domTT_styleClass = "niceTitle";'."\n";
$script .= 'function nicetitleDecorator(el) {'."\n";
$script .= ' var result = el.title;'."\n";
$script .= ' result = result.replace(new RegExp("\n", "g"), "<br />");'."\n";
$script .= ' //if (el.href) {'."\n";
$script .= ' //result += "<p>" + el.href + "<\/p>";'."\n";
$script .= ' //}'."\n";
$script .= ' return result;'."\n";
$script .= '}'."\n";
$script .= 'domTT_replaceTitles(nicetitleDecorator);'."\n";
GEN_stockerCodeScript('var domTT_styleClass = "niceTitle";'."\n");
}
// Titre
if ($type == 'calendrier') {
$retour .= '<div id="cal_entete">'."\n";
$retour .= '<span class="cal_navigation">'."\n";
$retour .= '<a id="cal_precedent_lien" href="'.$prev.'" title="Allez au mois précédent"><img id="cal_precedent_img" src="client/bazar/images/cal_precedent.png" alt="&lt;&lt;"/></a>'."\n";
$retour .= '&nbsp;&nbsp;'."\n";
$retour .= '<span id="cal_encadre_mois_courrant"><a id="cal_mois_courrant" href="'.$cur.'">';
$retour .= $fr_month[(date('n',$curStamp))];
$retour .= '&nbsp;';
$retour .= (date('Y',$curStamp));
$retour .= '</a></span>'."\n";
$retour .= '&nbsp;&nbsp;'."\n";
$retour .= '<a id="cal_suivant_lien" href="'.$next.'" title="Allez au mois suivant"><img id="cal_suivant_img" src="client/bazar/images/cal_suivant.png" alt="&gt;&gt;"/></a>'."\n";
$retour .= '</span>'."\n";
$retour .= '<h1 id="cal_titre"><img id="cal_titre_img" src="client/bazar/images/cal_titre.png" alt="Calendrier"/></h1>'."\n";
$retour .= '</div>'."\n";
$retour .= '<form action="'.$tc_lien.'" method="get">'."\n";
$retour .= '<a href="'.$tc_lien.'">'.$tc_txt.'</a>'."\n";
$retour .= '<fieldset>'."\n";
$retour .= '<legend>'.'Filtrer : '.'</legend>'."\n";
$retour .= '<select id="ficnat" name="ficnat" class="filtre_'.((!is_null($ficnat_id)) ? $ficnat_id: 'tous').'" onchange="javascript:this.form.submit();">'."\n";
$retour .= '<option id="filtre_tous" value="*" ';
if (isset($_GET['ficnat']) && '*' == $_GET['ficnat']) {
$retour .= 'selected="selected" ';
}
$retour .= '>'.'Tout afficher'.'</option>';
while ($ligne_nature_fiche = $resultat_nature_fiche->fetchRow(DB_FETCHMODE_OBJECT)) {
$opt = '<option class="filtre_'.$ligne_nature_fiche->bn_id_nature.'" value="'.$ligne_nature_fiche->bn_id_nature.'" ';
if (isset($_GET['ficnat']) && $ligne_nature_fiche->bn_id_nature == $_GET['ficnat']) {
$opt .= 'selected="selected" ';
}
$opt .= '>';
$retour .= $opt.$ligne_nature_fiche->bn_label_nature.'</option>'."\n";
}
$retour .= '</select>'."\n";
$retour .= '<input id="ficnat_ok" type="submit" value="'.'OK'.'" onload="javascript:this.setAttribute(\'style\', \'display:none;\')"/>'."\n";
$script_ok = 'if (document.getElementById(\'ficnat_ok\')) {'.
' document.getElementById(\'ficnat_ok\').style.display = \'none\';'.
'}';
$retour.= '<script type="text/javascript">//<![CDATA['."\n".$script_ok.'//]]></script>'."\n";
foreach ($ficnat_chps_cache as $cle => $val) {
$retour .= '<input id="'.$cle.'" name="'.$cle.'" type="hidden" value="'.$val.'" />'."\n";
}
$retour .= '</fieldset>'."\n";
$retour .= '</form>'."\n";
} else {
// Appel du template
ob_start();
include $options['template'];
$retour .= ob_get_contents();
ob_end_clean();
}
// Vue Mois calendrier ou vue applette
if ((!isset($_GET['id_fiche']) && $type == 'calendrier') || ($type == 'calendrier_applette')){
// trigger_error('ICI', E_USER_NOTICE);
// Recherche evenement de la periode selectionnée
$ts_jour_fin_mois = $month->nextMonth('timestamp');
$ts_jour_debut_mois = $month->thisMonth('timestamp');;
$requete_evenements = "SELECT DISTINCT bf_id_fiche, bf_titre, bf_lieu_evenement, ".
" DAY(bf_date_debut_evenement) AS bf_jour_debut_evenement, bf_date_debut_evenement, ".
" bf_date_fin_evenement, bf_description, bn_id_nature ".
"FROM bazar_fiche, bazar_nature ".
"WHERE bf_date_debut_evenement < '".date('Y-m-d', $ts_jour_fin_mois)."' ".
"AND bf_date_fin_evenement >= '".date('Y-m-d', $ts_jour_debut_mois)."' ".
"AND bf_ce_nature = bn_id_nature ".
"AND bn_id_nature IN (".$cal_num_annonce.") ".
"AND bf_statut_fiche = 1 ".
"ORDER BY bf_jour_debut_evenement";
$resultat_evenement = $db->query($requete_evenements);
(DB::isError($resultat_evenement)) ? trigger_error(BOG_afficherErreurSql(__FILE__, __LINE__, $resultat_evenement->getMessage(), $requete_evenements), E_USER_WARNING) : '';
 
$selection = array();
$evenements = array();
$annee = date('Y', $curStamp);
$mois = date('m', $curStamp);
$tablo_jours = array();
while ($ligne_evenements = $resultat_evenement->fetchRow(DB_FETCHMODE_OBJECT)) {
list($annee_debut, $mois_debut, $jour_debut) = explode('-', $ligne_evenements->bf_date_debut_evenement);
list($annee_fin, $mois_fin, $jour_fin) = explode('-', $ligne_evenements->bf_date_fin_evenement);
$Calendrier = new Calendar($annee_debut, $mois_debut, $jour_debut);
$ts_jour_suivant = $Calendrier->thisDay('timestamp');
$ts_jour_fin = mktime(0,0,0,$mois_fin, $jour_fin, $annee_fin);
$naviguer = true;
while ($naviguer && ($ts_jour_suivant <= $ts_jour_fin)) {
// Si le jours suivant est inferieur a la date de fin du mois courrant, on continue...
if ($ts_jour_suivant < $ts_jour_fin_mois) {
$cle_j = date('Y-m-d', $ts_jour_suivant);
if (!isset($tablo_jours[$cle_j])) {
$tablo_jours[$cle_j]['Calendar_Day'] = new Calendar_Day(date('Y', $ts_jour_suivant),date('m', $ts_jour_suivant), date('d', $ts_jour_suivant));
$tablo_jours[$cle_j]['Diary_Event'] = new DiaryEvent($tablo_jours[$cle_j]['Calendar_Day']);
}
$tablo_jours[$cle_j]['Diary_Event']->setEntry($ligne_evenements);
$ts_jour_suivant = $Calendrier->nextDay('timestamp');
//echo "ici$ts_jour_suivant-";
$Calendrier->setTimestamp($ts_jour_suivant);
//echo "la".$Calendrier->thisDay('timestamp')."-";
} else {
$naviguer = false;
}
}
}
// Add the decorator to the selection
foreach ($tablo_jours as $jour) {
$selection[] = $jour['Diary_Event'];
}
// Affichage Calendrier
$month->build($selection);
if ($type == 'calendrier') {
$retour.= '<table class="calendrier">'.
'<colgroup>'.
'<col class="cal_lundi"/>'.
'<col class="cal_mardi"/>'.
'<col class="cal_mercredi"/>'.
'<col class="cal_jeudi"/>'.
'<col class="cal_vendredi"/>'.
'<col class="cal_samedi"/>'.
'<col class="cal_dimanche"/>'.
'</colgroup>'.
'<thead>'.
"<tr>
<th> ". BAZ_LUNDI ."</th>
<th> ". BAZ_MARDI ."</th>
<th> ". BAZ_MERCREDI ."</th>
<th> ". BAZ_JEUDI ."</th>
<th> ". BAZ_VENDREDI ."</th>
<th> ". BAZ_SAMEDI ."</th>
<th> ". BAZ_DIMANCHE ."</th>
</tr>
".'</thead>'.'<tbody>';
} else {
$retour.= '<table class="calendrier_applette">'.
'<colgroup>'.
'<col class="cal_lundi"/>'.
'<col class="cal_mardi"/>'.
'<col class="cal_mercredi"/>'.
'<col class="cal_jeudi"/>'.
'<col class="cal_vendredi"/>'.
'<col class="cal_samedi"/>'.
'<col class="cal_dimanche"/>'.
'</colgroup>'.
'<thead>'.
"<tr>
<th> ". BAZ_LUNDI_COURT ."</th>
<th> ". BAZ_MARDI_COURT ."</th>
<th> ". BAZ_MERCREDI_COURT ."</th>
<th> ". BAZ_JEUDI_COURT ."</th>
<th> ". BAZ_VENDREDI_COURT ."</th>
<th> ". BAZ_SAMEDI_COURT ."</th>
<th> ". BAZ_DIMANCHE_COURT ."</th>
</tr>
".'</thead>'.'<tbody>';
}
$todayStamp=time();
$today_ymd=date('Ymd',$todayStamp);
 
// Other month : mois
while ($day = $month->fetch() ) {
$dayStamp = $day->thisDay(true);
$day_ymd = date('Ymd',$dayStamp);
if ( $day->isEmpty() ) {
$class = "cal_ma other_month";
} else {
if (($day_ymd < $today_ymd)) {
$class= "cal_mp previous_month";
} else {
if ($day_ymd == $today_ymd) {
$class= "cal_jc current_day";
} else {
$class="cal_mc current_month";
}
}
}
$url->addQueryString ('y', date('Y',$dayStamp));
$url->addQueryString ('m', date('n',$dayStamp));
$url->addQueryString ('d', date('j',$dayStamp));
$link = $url->getUrl();
// isFirst() to find start of week
if ($day->isFirst()) {
$retour.= ( "<tr>\n" );
}
if ($type == 'calendrier') {
$retour.= "<td class=\"".$class."\">".'<span class="cal_j">'.$day->thisDay().'</span>'."\n";
if ($day->isSelected() ) {
$evenements = $day->getEntry();
$evenements_nbre = count($evenements);
$evenemt_xhtml = '';
while ($ligne_evenement = array_pop($evenements)) {
 
$id_fiches = array();
$id_fiches[] = $ligne_evenement->bf_id_fiche;
$url->addQueryString ('id_fiches',$id_fiches);
 
$lien_voir = new Net_Url(BAZ_URL_BASE_APPLI);
$lien_voir->addQueryString(BAZ_VARIABLE_ACTION, BAZ_VOIR_FICHE);
$lien_voir->addQueryString('id_fiche', $ligne_evenement->bf_id_fiche);
$lien_voir->addQueryString('typeannonce', $ligne_evenement->bn_id_nature);
$link=$lien_voir->getURL();
if (!isset($_GET['tt']) || (isset($_GET['tt']) && $_GET['tt'] == '1')) {
$titre_taille = strlen($ligne_evenement->bf_titre);
$titre = ($titre_taille > 20)?substr($ligne_evenement->bf_titre, 0, 20).'...':$ligne_evenement->bf_titre;
} else {
$titre = $ligne_evenement->bf_titre;
}
$evenemt_xhtml .= '<li class="tooltip nature_'.$ligne_evenement->bn_id_nature.'" title="'.str_replace('"', '\'', $ligne_evenement->bf_titre).'"><a class="cal_evenemt" href="'.$link.'">'.$titre.'</a></li>'."\n";
$url->removeQueryString ('id_fiches');
}
if ($evenements_nbre > 0) {
$retour .= '<ul class="cal_evenemt_liste">';
$retour .= $evenemt_xhtml;
$retour .= '</ul>';
}
}
} else {
$lien_date= "<td class=\"".$class."\">".$day->thisDay();
if ($day->isSelected() ) {
$evenements = $day->getEntry();
$id_fiches = array();
$info_fiches = null;
while ($ligne_evenement = array_pop($evenements)) {
$id_fiches[] = $ligne_evenement->bf_id_fiche;
$info_fiches .= '&rArr; '.str_replace('"', '\'', $ligne_evenement->bf_titre)."\n";
}
$url->addQueryString('id_fiches', $id_fiches);
$link = $url->getUrl();
$lien_date = '<td class="'.$class.'"><a href="'.$link.'" class="tooltip" title="'.$info_fiches.'">'.$day->thisDay()."</a>\n";
$url->removeQueryString('id_fiches');
}
$retour .= $lien_date;
}
$retour.= ( "</td>\n" );
// isLast() to find end of week
if ( $day->isLast() ) {
$retour.= ( "</tr>\n" );
}
}
$retour.= "</tbody></table>";
}
$retour.= '<script type="text/javascript">//<![CDATA['."\n".$script.'//]]></script>'."\n";
// Vue detail
if ((isset($_GET['id_fiches']))) {
// Ajout d'un titre pour la page avec la date
$jours = array ('dimanche', 'lundi', 'mardi', 'mercredi', 'jeudi', 'vendredi', 'samedi') ;
$mois = array ('janvier', 'février', 'mars', 'avril', 'mai', 'juin', 'juillet', 'août', 'septembre',
'octobre', 'novembre', 'décembre') ;
$timestamp = strtotime ($_GET['y'].'/'.$_GET['m'].'/'.$_GET['d']) ;
$GLOBALS['_PAPYRUS_']['rendu']['CONTENU_NAVIGATION'] = '';
$GLOBALS['_PAPYRUS_']['rendu']['CONTENU_TETE'] = '';
$GLOBALS['_PAPYRUS_']['rendu']['CONTENU_CORPS'] = '<h1>'.$jours[date('w', $timestamp)].
' '.$_GET['d'].' '.$mois[$_GET['m']-1].' '.$_GET['y'].'</h1>' ;
$GLOBALS['_PAPYRUS_']['rendu']['CONTENU_CORPS'] .= baz_voir_fiches(1,$_GET['id_fiches'] );
 
$GLOBALS['_GEN_commun']['info_menu'] = '';
// Un lien pour retourner au calendrier
$url->removeQueryString('id_fiches');
$url->removeQueryString('y');
$url->removeQueryString('m');
$url->removeQueryString('d');
$GLOBALS['_PAPYRUS_']['rendu']['CONTENU_PIED'] = '<div class="retour"><a href="'.$url->getURL().'">Retour au calendrier</a></div>';
}
 
// Nettoyage de l'url
$url->removeQueryString('id_fiches');
$url->removeQueryString('y');
$url->removeQueryString('m');
$url->removeQueryString('d');
return $retour;
}
?>
/tags/v3.1-blanche-neige/bibliotheque/elements/champs_mail.php
New file
0,0 → 1,71
<?php
/*vim: set expandtab tabstop=4 shiftwidth=4: */
// +------------------------------------------------------------------------------------------------------+
// | PHP version 4.1 |
// +------------------------------------------------------------------------------------------------------+
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org) |
// +------------------------------------------------------------------------------------------------------+
// | This library is free software; you can redistribute it and/or |
// | modify it under the terms of the GNU Lesser General Public |
// | License as published by the Free Software Foundation; either |
// | version 2.1 of the License, or (at your option) any later version. |
// | |
// | This library is distributed in the hope that it will be useful, |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
// | Lesser General Public License for more details. |
// | |
// | You should have received a copy of the GNU Lesser General Public |
// | License along with this library; if not, write to the Free Software |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
// +------------------------------------------------------------------------------------------------------+
// CVS : $Id: champs_mail.php,v 1.2 2008-09-17 14:18:12 alexandre_tb Exp $
/**
*
*@package bazar
//Auteur original :
*@author Alexandre GRANIER <alexandre@tela-botanica.org>
//Autres auteurs :
*@copyright Tela-Botanica 2000-2008
*@version $Revision: 1.2 $
// +------------------------------------------------------------------------------------------------------+
*/
 
include_once PAP_CHEMIN_API_PEAR.'PEAR.php';
 
 
class Bazar_champs_mail extends PEAR {
var $option = array();
function Bazar_champs_mail($options) {
$this->options = $options;
}
function toHTML($valeur) {
$html = '';
$val = $this->options['nom_bdd'];
if (!in_array($val, array ('bf_titre', 'bf_description'))) {
$html .= '<div class="BAZ_rubrique BAZ_rubrique_'.$GLOBALS['_BAZAR_']['class'].'">'."\n".
'<span class="BAZ_label" id="'.$this->options['nom_bdd'].'_rubrique">'.$this->options['label'].' :</span>'."\n";
$html .= '<span class="BAZ_texte BAZ_texte_'.$GLOBALS['_BAZAR_']['class'].'" id="'.$this->options['nom_bdd'].'_description"> '.
'<a href="mailto:'.$valeur.'">'.
nl2br($valeur).'</a></span>'."\n".'</div>'."\n";
}
return $html;
}
}
 
/* +--Fin du code ----------------------------------------------------------------------------------------+
*
* $Log: champs_mail.php,v $
* Revision 1.2 2008-09-17 14:18:12 alexandre_tb
* fusion avec aha
*
* Revision 1.1.2.1 2008-04-16 12:35:25 alexandre_tb
* version initiale
*
*
* +-- Fin du code ----------------------------------------------------------------------------------------+
*/
?>
/tags/v3.1-blanche-neige/bibliotheque/elements/liste.php
New file
0,0 → 1,85
<?php
/*vim: set expandtab tabstop=4 shiftwidth=4: */
// +------------------------------------------------------------------------------------------------------+
// | PHP version 4.1 |
// +------------------------------------------------------------------------------------------------------+
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org) |
// +------------------------------------------------------------------------------------------------------+
// | This library is free software; you can redistribute it and/or |
// | modify it under the terms of the GNU Lesser General Public |
// | License as published by the Free Software Foundation; either |
// | version 2.1 of the License, or (at your option) any later version. |
// | |
// | This library is distributed in the hope that it will be useful, |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
// | Lesser General Public License for more details. |
// | |
// | You should have received a copy of the GNU Lesser General Public |
// | License along with this library; if not, write to the Free Software |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
// +------------------------------------------------------------------------------------------------------+
// CVS : $Id: liste.php,v 1.2 2008-09-17 14:18:12 alexandre_tb Exp $
/**
*
*@package bazar
//Auteur original :
*@author Alexandre GRANIER <alexandre@tela-botanica.org>
//Autres auteurs :
*@copyright Tela-Botanica 2000-2008
*@version $Revision: 1.2 $
// +------------------------------------------------------------------------------------------------------+
*/
 
include_once PAP_CHEMIN_API_PEAR.'PEAR.php';
 
 
class Bazar_liste extends PEAR {
var $option = array();
function Bazar_liste($options) {
$this->options = $options;
}
function toHTML($valeur) {
$html = '';
$val = $this->options['nom_bdd'];
//pour les champs renseignes par une liste, on va chercher le label de la liste, plutot que l'id
$requete = 'SELECT blv_label FROM bazar_fiche_valeur_liste, bazar_liste_valeurs WHERE bfvl_ce_fiche='.
$GLOBALS['_BAZAR_']['id_fiche'].' AND bfvl_ce_liste='.$this->options['nom_bdd'].
' AND bfvl_valeur=blv_valeur AND blv_ce_liste='.$this->options['nom_bdd'].
' AND blv_ce_i18n="'.$GLOBALS['_BAZAR_']['langue'].'"';
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError ($resultat)) {
return ($resultat->getMessage().'<br />'.$resultat->getDebugInfo()) ;
}
$val='';$nb=0;
while ($tab = $resultat->fetchRow()) {
if ($nb>0) $val .= ', ';
$val .= $tab[0];
$nb++;
}
if ($val != '' and $val != BAZ_CHOISIR and $val != BAZ_NON_PRECISE) {
$html .= '<div class="BAZ_rubrique BAZ_rubrique_'.$GLOBALS['_BAZAR_']['class'].'">'.
"\n".'<span class="BAZ_label" id="rubrique_'.$this->options['nom_bdd'].'">'.$this->options['label'].' : </span>'."\n";
$html .= '<span class="BAZ_texte BAZ_texte_'.$GLOBALS['_BAZAR_']['class'].'" id="description_'.$this->options['nom_bdd'].
'"> '.$val.'</span>'."\n".'</div>'."\n";
}
return $html;
}
}
 
/* +--Fin du code ----------------------------------------------------------------------------------------+
*
* $Log: liste.php,v $
* Revision 1.2 2008-09-17 14:18:12 alexandre_tb
* fusion avec aha
*
* Revision 1.1.2.1 2008-04-16 12:35:25 alexandre_tb
* version initiale
*
*
* +-- Fin du code ----------------------------------------------------------------------------------------+
*/
?>
/tags/v3.1-blanche-neige/bibliotheque/elements/labelhtml.php
New file
0,0 → 1,68
<?php
/*vim: set expandtab tabstop=4 shiftwidth=4: */
// +------------------------------------------------------------------------------------------------------+
// | PHP version 4.1 |
// +------------------------------------------------------------------------------------------------------+
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org) |
// +------------------------------------------------------------------------------------------------------+
// | This library is free software; you can redistribute it and/or |
// | modify it under the terms of the GNU Lesser General Public |
// | License as published by the Free Software Foundation; either |
// | version 2.1 of the License, or (at your option) any later version. |
// | |
// | This library is distributed in the hope that it will be useful, |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
// | Lesser General Public License for more details. |
// | |
// | You should have received a copy of the GNU Lesser General Public |
// | License along with this library; if not, write to the Free Software |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
// +------------------------------------------------------------------------------------------------------+
// CVS : $Id: labelhtml.php,v 1.2 2008-09-17 14:18:12 alexandre_tb Exp $
/**
*
*@package bazar
//Auteur original :
*@author Alexandre GRANIER <alexandre@tela-botanica.org>
//Autres auteurs :
*@copyright Tela-Botanica 2000-2008
*@version $Revision: 1.2 $
// +------------------------------------------------------------------------------------------------------+
*/
 
include_once PAP_CHEMIN_API_PEAR.'PEAR.php';
 
 
class Bazar_labelhtml extends PEAR {
var $option = array();
function Bazar_labelhtml($options) {
$this->options = $options;
}
function toHTML($valeur) {
$html = '';
$val = $this->options['nom_bdd'];
// On ecrit le label uniquement si le champs obligatoire est a 1
if ($this->options['obligatoire'] == 1) $res .= '<div class="BAZ_label BAZ_rubrique_'.$GLOBALS['_BAZAR_']['class'].'">'.
$this->options['label'].'</div>'."\n";
 
return $html;
}
}
 
/* +--Fin du code ----------------------------------------------------------------------------------------+
*
* $Log: labelhtml.php,v $
* Revision 1.2 2008-09-17 14:18:12 alexandre_tb
* fusion avec aha
*
* Revision 1.1.2.1 2008-04-16 12:35:25 alexandre_tb
* version initiale
*
*
* +-- Fin du code ----------------------------------------------------------------------------------------+
*/
?>
/tags/v3.1-blanche-neige/bibliotheque/elements/checkbox.php
New file
0,0 → 1,85
<?php
/*vim: set expandtab tabstop=4 shiftwidth=4: */
// +------------------------------------------------------------------------------------------------------+
// | PHP version 4.1 |
// +------------------------------------------------------------------------------------------------------+
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org) |
// +------------------------------------------------------------------------------------------------------+
// | This library is free software; you can redistribute it and/or |
// | modify it under the terms of the GNU Lesser General Public |
// | License as published by the Free Software Foundation; either |
// | version 2.1 of the License, or (at your option) any later version. |
// | |
// | This library is distributed in the hope that it will be useful, |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
// | Lesser General Public License for more details. |
// | |
// | You should have received a copy of the GNU Lesser General Public |
// | License along with this library; if not, write to the Free Software |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
// +------------------------------------------------------------------------------------------------------+
// CVS : $Id: checkbox.php,v 1.2 2008-09-17 14:18:12 alexandre_tb Exp $
/**
*
*@package bazar
//Auteur original :
*@author Alexandre GRANIER <alexandre@tela-botanica.org>
//Autres auteurs :
*@copyright Tela-Botanica 2000-2008
*@version $Revision: 1.2 $
// +------------------------------------------------------------------------------------------------------+
*/
 
include_once PAP_CHEMIN_API_PEAR.'PEAR.php';
 
 
class Bazar_checkbox extends PEAR {
var $option = array();
function Bazar_checkbox($options) {
$this->options = $options;
}
function toHTML($valeur) {
$html = '';
$val = $this->options['nom_bdd'];
//pour les champs renseignes par une liste, on va chercher le label de la liste, plutot que l'id
$requete = 'SELECT blv_label FROM bazar_fiche_valeur_liste, bazar_liste_valeurs WHERE bfvl_ce_fiche='.
$GLOBALS['_BAZAR_']['id_fiche'].' AND bfvl_ce_liste='.$this->options['nom_bdd'].
' AND bfvl_valeur=blv_valeur AND blv_ce_liste='.$this->options['nom_bdd'].
' AND blv_ce_i18n="'.$GLOBALS['_BAZAR_']['langue'].'"';
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError ($resultat)) {
return ($resultat->getMessage().'<br />'.$resultat->getDebugInfo()) ;
}
$val='';$nb=0;
while ($tab = $resultat->fetchRow()) {
if ($nb>0) $val .= ', ';
$val .= $tab[0];
$nb++;
}
if ($val != '' and $val != BAZ_CHOISIR and $val != BAZ_NON_PRECISE) {
$html .= '<div class="BAZ_rubrique BAZ_rubrique_'.$GLOBALS['_BAZAR_']['class'].'">'.
"\n".'<span class="BAZ_label" id="rubrique_'.$this->options['nom_bdd'].'">'.$this->options['label'].' : </span>'."\n";
$html .= '<span class="BAZ_texte BAZ_texte_'.$GLOBALS['_BAZAR_']['class'].'" id="description_'.$this->options['nom_bdd'].
'"> '.$val.'</span>'."\n".'</div>'."\n";
}
return $html;
}
}
 
/* +--Fin du code ----------------------------------------------------------------------------------------+
*
* $Log: checkbox.php,v $
* Revision 1.2 2008-09-17 14:18:12 alexandre_tb
* fusion avec aha
*
* Revision 1.1.2.1 2008-04-16 12:35:25 alexandre_tb
* version initiale
*
*
* +-- Fin du code ----------------------------------------------------------------------------------------+
*/
?>
/tags/v3.1-blanche-neige/bibliotheque/elements/boutonsradio.php
New file
0,0 → 1,69
<?php
/**
* PHP Version 5
*
* @category PHP
* @package bazar_bp
* @author aurelien <aurelien@tela-botanica.org>
* @copyright 2009 Tela-Botanica
* @license http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL
* @version SVN: <svn_id>
* @link /doc/bazar_bp/
*/
 
include_once PAP_CHEMIN_API_PEAR.'PEAR.php';
 
 
class Bazar_radio extends PEAR {
var $option = array();
function Bazar_radio($options) {
$this->options = $options;
}
function toHTML($valeur) {
$html = '';
$val = $this->options['nom_bdd'];
//pour les champs renseignes par une liste, on va chercher le label de la liste, plutot que l'id
$requete = 'SELECT blv_label FROM bazar_fiche_valeur_liste, bazar_liste_valeurs WHERE bfvl_ce_fiche='.
$GLOBALS['_BAZAR_']['id_fiche'].' AND bfvl_ce_liste='.$this->options['nom_bdd'].
' AND bfvl_valeur=blv_valeur AND blv_ce_liste='.$this->options['nom_bdd'].
' AND blv_ce_i18n="'.$GLOBALS['_BAZAR_']['langue'].'"';
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError ($resultat)) {
return ($resultat->getMessage().'<br />'.$resultat->getDebugInfo()) ;
}
$val='';$nb=0;
while ($tab = $resultat->fetchRow()) {
if ($nb>0) $val .= ', ';
$val .= $tab[0];
$nb++;
}
if ($val != '' and $val != BAZ_CHOISIR and $val != BAZ_NON_PRECISE) {
$html .= '<div class="BAZ_rubrique BAZ_rubrique_'.$GLOBALS['_BAZAR_']['class'].'">'.
"\n".'<span class="BAZ_label" id="rubrique_'.$this->options['nom_bdd'].'">'.$this->options['label'].' : </span>'."\n";
$html .= '<span class="BAZ_texte BAZ_texte_'.$GLOBALS['_BAZAR_']['class'].'" id="description_'.$this->options['nom_bdd'].
'"> '.$val.'</span>'."\n".'</div>'."\n";
}
return $html;
}
}
 
/* +--Fin du code ----------------------------------------------------------------------------------------+
*
* $Log: not supported by cvs2svn $
* Revision 1.2 2008-09-17 14:18:12 alexandre_tb
* fusion avec aha
*
* Revision 1.1.2.1 2008-04-16 12:35:25 alexandre_tb
* version initiale
*
*
* +-- Fin du code ----------------------------------------------------------------------------------------+
*/
?>
 
?>
/tags/v3.1-blanche-neige/bibliotheque/elements/listedatedeb.php
New file
0,0 → 1,102
<?php
/*vim: set expandtab tabstop=4 shiftwidth=4: */
// +------------------------------------------------------------------------------------------------------+
// | PHP version 4.1 |
// +------------------------------------------------------------------------------------------------------+
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org) |
// +------------------------------------------------------------------------------------------------------+
// | This library is free software; you can redistribute it and/or |
// | modify it under the terms of the GNU Lesser General Public |
// | License as published by the Free Software Foundation; either |
// | version 2.1 of the License, or (at your option) any later version. |
// | |
// | This library is distributed in the hope that it will be useful, |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
// | Lesser General Public License for more details. |
// | |
// | You should have received a copy of the GNU Lesser General Public |
// | License along with this library; if not, write to the Free Software |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
// +------------------------------------------------------------------------------------------------------+
// CVS : $Id: listedatedeb.php,v 1.2 2008-09-17 14:18:12 alexandre_tb Exp $
/**
*
*@package bazar
//Auteur original :
*@author Alexandre GRANIER <alexandre@tela-botanica.org>
//Autres auteurs :
*@copyright Tela-Botanica 2000-2008
*@version $Revision: 1.2 $
// +------------------------------------------------------------------------------------------------------+
*/
 
include_once PAP_CHEMIN_API_PEAR.'PEAR.php';
 
 
class Bazar_listedatedeb extends PEAR {
var $option = array();
function Bazar_listedatedeb($options) {
$this->options = $options;
}
function toHTML($valeur) {
$html = '';
$val = $this->options['nom_bdd'];
 
if (!in_array($val, array ('bf_date_debut_validite_fiche', 'bf_date_fin_validite_fiche'))) {
if ($valeur != '' && $valeur != '0000-00-00') {
// Petit test pour afficher la date de debut et de fin d evenement
if ($val == 'bf_date_debut_evenement' || $val == 'bf_date_fin_evenement') {
if ($GLOBALS['_BAZAR_']['ligne_resultat']['bf_date_debut_evenement'] == $GLOBALS['_BAZAR_']['ligne_resultat']['bf_date_fin_evenement']) {
if ($val == 'bf_date_debut_evenement') return;
$html .= '<div class="BAZ_rubrique BAZ_rubrique_'.$GLOBALS['_BAZAR_']['class'].'">'."\n".
'<span class="BAZ_label" id="'.$this->options['nom_bdd'].'_rubrique">'.BAZ_LE.' : </span>'."\n";
$html .= '<span class="BAZ_texte BAZ_texte_'.$GLOBALS['_BAZAR_']['class'].'" id="'.$this->options['nom_bdd'].
'_description"> '.strftime('%d.%m.%Y',strtotime($GLOBALS['_BAZAR_']['ligne_resultat']['bf_date_debut_evenement'])).'</span>'.
"\n".'</div>'."\n";
continue;
} else {
if ($val == 'bf_date_debut_evenement') {
$html .= '<div class="BAZ_rubrique BAZ_rubrique_'.$GLOBALS['_BAZAR_']['class'].'">'."\n".
'<span class="BAZ_label" id="'.$this->options['nom_bdd'].'_rubrique">';
$html .= BAZ_DU;
$html .= '</span>'."\n".'<span class="BAZ_texte BAZ_texte_'.$GLOBALS['_BAZAR_']['class'].'" id="'.
$this->options['nom_bdd'].'_description"> '.strftime('%d.%m.%Y',strtotime($valeur)).'</span>'."\n";
} else {
$html .= '<span class="BAZ_label" id="'.$this->options['nom_bdd'].'_rubrique">'.BAZ_AU;
$html .= '</span>'."\n".'<span class="BAZ_texte BAZ_texte_'.$GLOBALS['_BAZAR_']['class'].'" id="'.
$this->options['nom_bdd'].'_description"> '.strftime('%d.%m.%Y',strtotime($valeur)).
'</span>'."\n".'</div>'."\n";
}
return $html;
}
}
$html .= '<div class="BAZ_rubrique BAZ_rubrique_'.$GLOBALS['_BAZAR_']['class'].'">'."\n".
'<span class="BAZ_label" id="'.$this->options['nom_bdd'].'_rubrique">'.$this->options['label'].' : </span>'."\n";
$html .= '<span class="BAZ_texte BAZ_texte_'.$GLOBALS['_BAZAR_']['class'].'" id="'.$this->options['nom_bdd'].
'_description"> '.strftime('%d.%m.%Y',strtotime($valeur)).'</span>'."\n".'</div>'."\n";
}
}
return $html;
}
}
 
/* +--Fin du code ----------------------------------------------------------------------------------------+
*
* $Log: listedatedeb.php,v $
* Revision 1.2 2008-09-17 14:18:12 alexandre_tb
* fusion avec aha
*
* Revision 1.1.2.1 2008-04-16 12:35:25 alexandre_tb
* version initiale
*
*
* +-- Fin du code ----------------------------------------------------------------------------------------+
*/
?>
/tags/v3.1-blanche-neige/bibliotheque/elements/texte.php
New file
0,0 → 1,83
<?php
/*vim: set expandtab tabstop=4 shiftwidth=4: */
// +------------------------------------------------------------------------------------------------------+
// | PHP version 4.1 |
// +------------------------------------------------------------------------------------------------------+
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org) |
// +------------------------------------------------------------------------------------------------------+
// | This library is free software; you can redistribute it and/or |
// | modify it under the terms of the GNU Lesser General Public |
// | License as published by the Free Software Foundation; either |
// | version 2.1 of the License, or (at your option) any later version. |
// | |
// | This library is distributed in the hope that it will be useful, |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
// | Lesser General Public License for more details. |
// | |
// | You should have received a copy of the GNU Lesser General Public |
// | License along with this library; if not, write to the Free Software |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
// +------------------------------------------------------------------------------------------------------+
// CVS : $Id: texte.php,v 1.3 2008-10-29 10:36:44 alexandre_tb Exp $
/**
*
*@package bazar
//Auteur original :
*@author Alexandre GRANIER <alexandre@tela-botanica.org>
//Autres auteurs :
*@copyright Tela-Botanica 2000-2008
*@version $Revision: 1.3 $
// +------------------------------------------------------------------------------------------------------+
*/
 
include_once PAP_CHEMIN_API_PEAR.'PEAR.php';
 
 
class Bazar_texte extends PEAR {
var $option = array();
function Bazar_texte($options) {
$this->options = $options;
}
function toHTML($valeur) {
if ($valeur == '') return ;
$html = '';
$val = $this->options['nom_bdd'];
//if (!in_array($val, array ('bf_titre', 'bf_description'))) {
$html .= '<div class="BAZ_rubrique BAZ_rubrique_'.$GLOBALS['_BAZAR_']['class'].'">'."\n".
'<span class="BAZ_label" id="'.$this->options['nom_bdd'].'_rubrique">'.$this->options['label'].' : </span>'."\n";
$html .= '<span class="BAZ_texte BAZ_texte_'.$GLOBALS['_BAZAR_']['class'].'" id="'.$this->options['nom_bdd'].'_description"> '.
nl2br($valeur).'</span>'."\n".'</div>'."\n";
//}
return $html;
}
function toForm($valeur_defaut = '') {
if ($valeur_defaut != '') $this->option['defaut'] = $valeur_defaut;
 
$html = $this->options['label'].'<input type="text" size="'.$this->option['limite1'].
'" maxlength="'.$this->option['limite2'].'" id="'.$this->option['nom_bdd'].
'" value="'.$this->option['defaut'].'" />';
return $html;
}
}
 
/* +--Fin du code ----------------------------------------------------------------------------------------+
*
* $Log: texte.php,v $
* Revision 1.3 2008-10-29 10:36:44 alexandre_tb
* l'element texte s affiche meme pour le titre et la description
*
* Revision 1.2 2008-09-17 14:18:12 alexandre_tb
* fusion avec aha
*
* Revision 1.1.2.1 2008-04-16 12:35:25 alexandre_tb
* version initiale
*
*
* +-- Fin du code ----------------------------------------------------------------------------------------+
*/
?>
/tags/v3.1-blanche-neige/bibliotheque/elements/textelong.php
New file
0,0 → 1,73
<?php
/*vim: set expandtab tabstop=4 shiftwidth=4: */
// +------------------------------------------------------------------------------------------------------+
// | PHP version 4.1 |
// +------------------------------------------------------------------------------------------------------+
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org) |
// +------------------------------------------------------------------------------------------------------+
// | This library is free software; you can redistribute it and/or |
// | modify it under the terms of the GNU Lesser General Public |
// | License as published by the Free Software Foundation; either |
// | version 2.1 of the License, or (at your option) any later version. |
// | |
// | This library is distributed in the hope that it will be useful, |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
// | Lesser General Public License for more details. |
// | |
// | You should have received a copy of the GNU Lesser General Public |
// | License along with this library; if not, write to the Free Software |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
// +------------------------------------------------------------------------------------------------------+
// CVS : $Id: textelong.php,v 1.3 2008-10-29 10:35:40 alexandre_tb Exp $
/**
*
*@package bazar
//Auteur original :
*@author Alexandre GRANIER <alexandre@tela-botanica.org>
//Autres auteurs :
*@copyright Tela-Botanica 2000-2008
*@version $Revision: 1.3 $
// +------------------------------------------------------------------------------------------------------+
*/
 
include_once PAP_CHEMIN_API_PEAR.'PEAR.php';
 
 
class Bazar_textelong extends PEAR {
var $option = array();
function Bazar_textelong($options) {
$this->options = $options;
}
function toHTML($valeur) {
$html = '';
$val = $this->options['nom_bdd'];
//if (!in_array($val, array ('bf_titre', 'bf_description'))) {
$html .= '<div class="BAZ_rubrique BAZ_rubrique_'.$GLOBALS['_BAZAR_']['class'].'">'."\n".
'<span class="BAZ_label" id="'.$this->options['nom_bdd'].'_rubrique">'.$this->options['label'].' : </span>'."\n";
$html .= '<span class="BAZ_texte BAZ_texte_'.$GLOBALS['_BAZAR_']['class'].'" id="'.$this->options['nom_bdd'].'_description"> '.
nl2br($valeur).'</span>'."\n".'</div>'."\n";
//}
return $html;
}
}
 
/* +--Fin du code ----------------------------------------------------------------------------------------+
*
* $Log: textelong.php,v $
* Revision 1.3 2008-10-29 10:35:40 alexandre_tb
* l'element textlong s affiche meme pour le titre et la description
*
* Revision 1.2 2008-09-17 14:18:12 alexandre_tb
* fusion avec aha
*
* Revision 1.1.2.1 2008-04-16 12:35:25 alexandre_tb
* version initiale
*
*
* +-- Fin du code ----------------------------------------------------------------------------------------+
*/
?>
/tags/v3.1-blanche-neige/bibliotheque/elements/carte_google.php
New file
0,0 → 1,104
<?php
/*vim: set expandtab tabstop=4 shiftwidth=4: */
// +------------------------------------------------------------------------------------------------------+
// | PHP version 4.1 |
// +------------------------------------------------------------------------------------------------------+
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org) |
// +------------------------------------------------------------------------------------------------------+
// | This library is free software; you can redistribute it and/or |
// | modify it under the terms of the GNU Lesser General Public |
// | License as published by the Free Software Foundation; either |
// | version 2.1 of the License, or (at your option) any later version. |
// | |
// | This library is distributed in the hope that it will be useful, |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
// | Lesser General Public License for more details. |
// | |
// | You should have received a copy of the GNU Lesser General Public |
// | License along with this library; if not, write to the Free Software |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
// +------------------------------------------------------------------------------------------------------+
// CVS : $Id: carte_google.php,v 1.1.2.1 2008-04-16 12:35:25 alexandre_tb Exp $
/**
*
*@package bazar
//Auteur original :
*@author Alexandre GRANIER <alexandre@tela-botanica.org>
//Autres auteurs :
*@copyright Tela-Botanica 2000-2008
*@version $Revision: 1.1.2.1 $
// +------------------------------------------------------------------------------------------------------+
*/
 
include_once PAP_CHEMIN_API_PEAR.'PEAR.php';
 
 
class Bazar_carte_google extends PEAR {
var $option = array();
function Bazar_carte_google($options) {
unset ($options['nom_bdd']); // fout la merde avec google maps v2
$this->options = $options;
}
function toHTML($valeur) {
if ($GLOBALS['pas_de_carte']) return;
$html = '';
$val = $this->options['nom_bdd'];
$script = '
// Variables globales
// cette fonction peut déjà être présente
if (typeof(addListener) != \'function\') {
// fonction portable pour ajout de listeners
function addListener(element, baseName, handler)
{
if (element.addEventListener) {
element.addEventListener(baseName, handler, false) ;
} else if (element.attachEvent) {
element.attachEvent(\'on\'+baseName, handler) ;
}
}
}
var map = null;
addListener(window,\'load\',loadMap) ;
var geocoder = null;
var lat = document.getElementById("latitude");
var lon = document.getElementById("longitude");
function loadMap() {
var point = new google.maps.LatLng('.$GLOBALS['_BAZAR_']['ligne_resultat']['bf_latitude'].', '.$GLOBALS['_BAZAR_']['ligne_resultat']['bf_longitude'].');
var optionsGoogleMapsv3 = {
// On centre la carte sur le languedoc roussillon
center: point,
zoom: 7,
mapTypeId: google.maps.MapTypeId.G_HYBRID_MAP,
mapTypeControl: true,
scaleControl: true
};
map = new google.maps.Map(document.getElementById("map"), optionsGoogleMapsv3);
 
marker = new google.maps.Marker({
position: point,
map: map
});
};' ;
GEN_stockerCodeScript($script);
//GEN_stockerFichierScript('googleMapScript', $this->options['nom_bdd']);
GEN_stockerFichierScript('googleMapScript', "http://maps.googleapis.com/maps/api/js?sensor=false&key=".BAZ_GOOGLE_KEY);
// On ajoute l attribut load a la balise body
//GEN_AttributsBody('onload', 'load()');
$html = '<div id="map" style="width: 400px; height: 300px"></div>';
return $html;
}
}
 
/* +--Fin du code ----------------------------------------------------------------------------------------+
*
* $Log: not supported by cvs2svn $
*
* +-- Fin du code ----------------------------------------------------------------------------------------+
*/
?>
/tags/v3.1-blanche-neige/bibliotheque/elements/listedatefin.php
New file
0,0 → 1,102
<?php
/*vim: set expandtab tabstop=4 shiftwidth=4: */
// +------------------------------------------------------------------------------------------------------+
// | PHP version 4.1 |
// +------------------------------------------------------------------------------------------------------+
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org) |
// +------------------------------------------------------------------------------------------------------+
// | This library is free software; you can redistribute it and/or |
// | modify it under the terms of the GNU Lesser General Public |
// | License as published by the Free Software Foundation; either |
// | version 2.1 of the License, or (at your option) any later version. |
// | |
// | This library is distributed in the hope that it will be useful, |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
// | Lesser General Public License for more details. |
// | |
// | You should have received a copy of the GNU Lesser General Public |
// | License along with this library; if not, write to the Free Software |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
// +------------------------------------------------------------------------------------------------------+
// CVS : $Id: listedatefin.php,v 1.2 2008-09-17 14:18:12 alexandre_tb Exp $
/**
*
*@package bazar
//Auteur original :
*@author Alexandre GRANIER <alexandre@tela-botanica.org>
//Autres auteurs :
*@copyright Tela-Botanica 2000-2008
*@version $Revision: 1.2 $
// +------------------------------------------------------------------------------------------------------+
*/
 
include_once PAP_CHEMIN_API_PEAR.'PEAR.php';
 
 
class Bazar_listedatefin extends PEAR {
var $option = array();
function Bazar_listedatefin($options) {
$this->options = $options;
}
function toHTML($valeur) {
$html = '';
$val = $this->options['nom_bdd'];
 
if (!in_array($val, array ('bf_date_debut_validite_fiche', 'bf_date_fin_validite_fiche'))) {
if ($valeur != '' && $valeur != '0000-00-00') {
// Petit test pour afficher la date de debut et de fin d evenement
if ($val == 'bf_date_debut_evenement' || $val == 'bf_date_fin_evenement') {
if ($GLOBALS['_BAZAR_']['ligne_resultat']['bf_date_debut_evenement'] == $GLOBALS['_BAZAR_']['ligne_resultat']['bf_date_fin_evenement']) {
if ($val == 'bf_date_debut_evenement') continue;
$html .= '<div class="BAZ_rubrique BAZ_rubrique_'.$GLOBALS['_BAZAR_']['class'].'">'."\n".
'<span class="BAZ_label" id="'.$this->options['nom_bdd'].'_rubrique">'.BAZ_LE.' : </span>'."\n";
$html .= '<span class="BAZ_texte BAZ_texte_'.$GLOBALS['_BAZAR_']['class'].'" id="'.$this->options['nom_bdd'].
'_description"> '.strftime('%d.%m.%Y',strtotime($GLOBALS['_BAZAR_']['ligne_resultat']['bf_date_debut_evenement'])).'</span>'.
"\n".'</div>'."\n";
return $html;
} else {
if ($val == 'bf_date_debut_evenement') {
$html .= '<div class="BAZ_rubrique BAZ_rubrique_'.$GLOBALS['_BAZAR_']['class'].'">'."\n".
'<span class="BAZ_label" id="'.$this->options['nom_bdd'].'_rubrique">';
$html .= BAZ_DU;
$html .= '</span>'."\n".'<span class="BAZ_texte BAZ_texte_'.$GLOBALS['_BAZAR_']['class'].'" id="'.
$this->options['nom_bdd'].'_description"> '.strftime('%d.%m.%Y',strtotime($valeur)).'</span>'."\n";
} else {
$html .= '<span class="BAZ_label" id="'.$this->options['nom_bdd'].'_rubrique">'.BAZ_AU;
$html .= '</span>'."\n".'<span class="BAZ_texte BAZ_texte_'.$GLOBALS['_BAZAR_']['class'].'" id="'.
$this->options['nom_bdd'].'_description"> '.strftime('%d.%m.%Y',strtotime($valeur)).
'</span>'."\n".'</div>'."\n";
}
return $html;
}
}
$html .= '<div class="BAZ_rubrique BAZ_rubrique_'.$GLOBALS['_BAZAR_']['class'].'">'."\n".
'<span class="BAZ_label" id="'.$this->options['nom_bdd'].'_rubrique">'.$this->options['label'].' : </span>'."\n";
$html .= '<span class="BAZ_texte BAZ_texte_'.$GLOBALS['_BAZAR_']['class'].'" id="'.$this->options['nom_bdd'].
'_description"> '.strftime('%d.%m.%Y',strtotime($valeur)).'</span>'."\n".'</div>'."\n";
}
}
return $html;
}
}
 
/* +--Fin du code ----------------------------------------------------------------------------------------+
*
* $Log: listedatefin.php,v $
* Revision 1.2 2008-09-17 14:18:12 alexandre_tb
* fusion avec aha
*
* Revision 1.1.2.1 2008-04-16 12:35:25 alexandre_tb
* version initiale
*
*
* +-- Fin du code ----------------------------------------------------------------------------------------+
*/
?>
/tags/v3.1-blanche-neige/bibliotheque/bazar.fonct.php
New file
0,0 → 1,1838
<?php
/*vim: set expandtab tabstop=4 shiftwidth=4: */
// +------------------------------------------------------------------------------------------------------+
// | PHP version 4.1 |
// +------------------------------------------------------------------------------------------------------+
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org) |
// +------------------------------------------------------------------------------------------------------+
// | This library is free software; you can redistribute it and/or |
// | modify it under the terms of the GNU Lesser General Public |
// | License as published by the Free Software Foundation; either |
// | version 2.1 of the License, or (at your option) any later version. |
// | |
// | This library is distributed in the hope that it will be useful, |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
// | Lesser General Public License for more details. |
// | |
// | You should have received a copy of the GNU Lesser General Public |
// | License along with this library; if not, write to the Free Software |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
// +------------------------------------------------------------------------------------------------------+
// CVS : $Id: bazar.fonct.php,v 1.74.2.13 2008-08-27 13:21:40 alexandre_tb Exp $
/**
*
* Fonctions du module bazar
*
*
*@package bazar
//Auteur original :
*@author Alexandre Granier <alexandre@tela-botanica.org>
*@author Florian Schmitt <florian@ecole-et-nature.org>
//Autres auteurs :
*@copyright Tela-Botanica 2000-2004
*@version $Revision: 1.74.2.13 $ $Date: 2008-08-27 13:21:40 $
// +------------------------------------------------------------------------------------------------------+
*/
 
// +------------------------------------------------------------------------------------------------------+
// | ENTETE du PROGRAMME |
// +------------------------------------------------------------------------------------------------------+
require_once PAP_CHEMIN_API_PEAR.'HTML/QuickForm.php' ;
require_once PAP_CHEMIN_API_PEAR.'HTML/QuickForm/checkbox.php' ;
require_once PAP_CHEMIN_API_PEAR.'HTML/QuickForm/textarea.php' ;
require_once PAP_CHEMIN_API_PEAR.'HTML/Table.php' ;
require_once GEN_CHEMIN_API.'formulaire/formulaire.fonct.inc.php';
require_once 'bazar.fonct.rss.php';
 
 
/** fiches_a_valider () - Renvoie les annonces restant a valider par un administrateur
*
* @return string HTML
*/
function fiches_a_valider() {
 
$utilisateur = new Administrateur_bazar($GLOBALS['AUTH']);
// sortie anticipée en cas d'accès non autorisé
// ceci limite l'accès au supers admins
// TODO: voir si l'on ne pourrait afficher que les fiches
// des catégories dont la personne est admin
// des catégories dont la personne est admin, ce qui permettrait un accès plus fin
if(!$utilisateur->isSuperAdmin()) {
return;
}
 
// Pour les administrateurs d'une rubrique, on affiche les fiches a valider de cette rubrique
// On effectue une requete sur le bazar pour voir les fiches a administrer
$GLOBALS['_BAZAR_']['url']->addQueryString(BAZ_VARIABLE_VOIR, BAZ_VOIR_ADMIN);
$res= '<h2>'.BAZ_ANNONCES_A_ADMINISTRER.'</h2><br />'."\n";
$requete = 'SELECT * FROM bazar_fiche, bazar_nature WHERE bf_statut_fiche=0 AND ' .
'bn_id_nature=bf_ce_nature ' ;
if (isset($GLOBALS['_BAZAR_']['langue'])) {
$requete .= ' and bn_ce_i18n like "'.$GLOBALS['_BAZAR_']['langue'].'%" ';
}
$requete .= 'ORDER BY bf_date_maj_fiche DESC' ;
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
die ('Echec de la requete<br />'.$resultat->getMessage().'<br />'.$resultat->getDebugInfo()) ;
}
if ($resultat->numRows() != 0) {
$tableAttr = array('id' => 'table_bazar') ;
$table = new HTML_Table($tableAttr) ;
$entete = array (BAZ_TITREANNONCE ,BAZ_ANNONCEUR, BAZ_TYPEANNONCE, BAZ_PUBLIER, BAZ_SUPPRIMER, BAZ_DATE_DEBUT_EVENEMENT) ;
$table->addRow($entete) ;
$table->setRowType (0, 'th') ;
// On affiche une ligne par proposition
while ($ligne = $resultat->fetchRow (DB_FETCHMODE_ASSOC)) {
//Requete pour trouver le nom et prenom de l'annonceur
$requetenomprenom = 'SELECT '.BAZ_CHAMPS_PRENOM.', '.BAZ_CHAMPS_NOM.' FROM '.BAZ_ANNUAIRE.
' WHERE '.BAZ_CHAMPS_ID.'='.$ligne['bf_ce_utilisateur'] ;
$resultatnomprenom = $GLOBALS['_BAZAR_']['db']->query ($requetenomprenom) ;
if (DB::isError($resultatnomprenom)) {
echo ("Echec de la requete<br />".$resultatnomprenom->getMessage()."<br />".$resultatnomprenom->getDebugInfo()) ;
}
while ($lignenomprenom = $resultatnomprenom->fetchRow (DB_FETCHMODE_ASSOC)) {
$annonceur=$lignenomprenom[BAZ_CHAMPS_PRENOM]." ".$lignenomprenom[BAZ_CHAMPS_NOM];
}
$lien_voir=$GLOBALS['_BAZAR_']['url'];
$lien_voir->addQueryString(BAZ_VARIABLE_ACTION, BAZ_VOIR_FICHE);
$lien_voir->addQueryString('id_fiche', $ligne['bf_id_fiche']);
$lien_voir->addQueryString('typeannonce', $ligne['bn_id_nature']);
// Nettoyage de l'url
// NOTE (jpm - 23 mai 2007): pour être compatible avec PHP5 il faut utiliser tjrs $GLOBALS['_BAZAR_']['url'] car en php4 on
// copie bien une variable mais pas en php5, cela reste une référence...
$GLOBALS['_BAZAR_']['url']->removeQueryString(BAZ_VARIABLE_ACTION);
$GLOBALS['_BAZAR_']['url']->removeQueryString('id_fiche');
$GLOBALS['_BAZAR_']['url']->removeQueryString('typeannonce');
$GLOBALS['_BAZAR_']['url']->addQueryString('id_fiche', $ligne['bf_id_fiche']);
$GLOBALS['_BAZAR_']['url']->addQueryString('typeannonce', $ligne['bn_id_nature']);
$GLOBALS['_BAZAR_']['url']->addQueryString(BAZ_VARIABLE_ACTION, BAZ_VOIR_FICHE);
$lien_voir = $GLOBALS['_BAZAR_']['url']->getURL();
$GLOBALS['_BAZAR_']['url']->removeQueryString(BAZ_VARIABLE_ACTION);
 
$GLOBALS['_BAZAR_']['url']->addQueryString(BAZ_VARIABLE_ACTION, BAZ_ACTION_PUBLIER);
$lien_publie_oui = $GLOBALS['_BAZAR_']['url']->getURL();
$GLOBALS['_BAZAR_']['url']->removeQueryString(BAZ_VARIABLE_ACTION);
$GLOBALS['_BAZAR_']['url']->addQueryString(BAZ_VARIABLE_ACTION, BAZ_ACTION_PAS_PUBLIER);
$lien_publie_non = $GLOBALS['_BAZAR_']['url']->getURL();
$GLOBALS['_BAZAR_']['url']->removeQueryString(BAZ_VARIABLE_ACTION);
$GLOBALS['_BAZAR_']['url']->addQueryString(BAZ_VARIABLE_ACTION, BAZ_ACTION_SUPPRESSION);
$lien_supprimer = $GLOBALS['_BAZAR_']['url']->getURL();
$GLOBALS['_BAZAR_']['url']->removeQueryString(BAZ_VARIABLE_ACTION);
$GLOBALS['_BAZAR_']['url']->removeQueryString('id_fiche');
$GLOBALS['_BAZAR_']['url']->removeQueryString('typeannonce');
$table->addRow (array(
'<a href="'.$lien_voir.'">'.$ligne['bf_titre'].'</a>'."\n", // col 1 : le nom
$annonceur."\n", // col 2 : annonceur
$ligne['bn_label_nature']."\n", // col 3 : type annonce
"<a href=\"".$lien_publie_oui."\">".BAZ_OUI."</a> / \n".
"<a href=\"".$lien_publie_non."\">".BAZ_NON."</a>", // col 4 : publier ou pas
"<a href=\"".$lien_supprimer."\"".
" onclick=\"javascript:return confirm('".BAZ_CONFIRMATION_SUPPRESSION."');\">".BAZ_SUPPRIMER."</a>\n", // col 5 : supprimer
date('d', strtotime($ligne['bf_date_debut_evenement'])).' '.$GLOBALS['mois'][date('n', strtotime ($ligne['bf_date_debut_evenement']))].' '.date('Y', strtotime ($ligne['bf_date_debut_evenement'])) // col 6 date début d'évenement
)) ;
}
$table->altRowAttributes(1, array("class" => "ligne_impaire"), array("class" => "ligne_paire"));
$table->updateColAttributes(1, array("align" => "center"));
$table->updateColAttributes(2, array("align" => "center"));
$table->updateColAttributes(3, array("align" => "center"));
$table->updateColAttributes(4, array("align" => "center"));
$table->updateColAttributes(5, array("align" => "center"));
$res .= $table->toHTML() ;
}
else {
$res .= '<p class="zone_info">'.BAZ_PAS_DE_FICHE_A_VALIDER.'</p>'."\n" ;
}
$GLOBALS['_BAZAR_']['url']->addQueryString(BAZ_VARIABLE_ACTION, BAZ_VOIR_TOUTES_ANNONCES);
// Nettoyage de l'url
$GLOBALS['_BAZAR_']['url']->removeQueryString(BAZ_VARIABLE_ACTION);
$GLOBALS['_BAZAR_']['url']->removeQueryString('id_fiche');
$GLOBALS['_BAZAR_']['url']->removeQueryString('typeannonce');
// Les autres fiches, deja validees
$res .= '<h2>'.BAZ_TOUTES_LES_FICHES.'</h2>'."\n";
$requete = 'SELECT * FROM bazar_fiche, bazar_nature WHERE bf_statut_fiche=1 AND ' .
'bn_id_nature=bf_ce_nature AND bn_ce_id_menu IN ('.$GLOBALS['_BAZAR_']['categorie_nature'].') ';
if (isset($GLOBALS['_BAZAR_']['langue'])) {
$requete .= ' and bn_ce_i18n like "'.$GLOBALS['_BAZAR_']['langue'].'%" ';
}
$requete .= 'ORDER BY bf_date_maj_fiche DESC' ;
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
die ('Echec de la requete<br />'.$resultat->getMessage().'<br />'.$resultat->getDebugInfo()) ;
}
if ($resultat->numRows() != 0) {
$tableAttr = array('id' => 'table_bazar') ;
$table = new HTML_Table($tableAttr) ;
$entete = array (BAZ_TITREANNONCE ,BAZ_ANNONCEUR, BAZ_TYPEANNONCE, BAZ_PUBLIER, BAZ_SUPPRIMER, BAZ_DATE_DEBUT_EVENEMENT, BAZ_DATE_CREATION) ;
$table->addRow($entete) ;
$table->setRowType (0, 'th') ;
// On affiche une ligne par proposition
while ($ligne = $resultat->fetchRow (DB_FETCHMODE_ASSOC)) {
//Requete pour trouver le nom et prenom de l'annonceur
$requetenomprenom = 'SELECT '.BAZ_CHAMPS_PRENOM.', '.BAZ_CHAMPS_NOM.' FROM '.BAZ_ANNUAIRE.
' WHERE '.BAZ_CHAMPS_ID.'='.$ligne['bf_ce_utilisateur'] ;
$resultatnomprenom = $GLOBALS['_BAZAR_']['db']->query ($requetenomprenom) ;
if (DB::isError($resultatnomprenom)) {
echo ("Echec de la requete<br />".$resultatnomprenom->getMessage()."<br />".$resultatnomprenom->getDebugInfo()) ;
}
while ($lignenomprenom = $resultatnomprenom->fetchRow (DB_FETCHMODE_ASSOC)) {
$annonceur=$lignenomprenom[BAZ_CHAMPS_PRENOM]." ".$lignenomprenom[BAZ_CHAMPS_NOM];
}
$lien_voir=$GLOBALS['_BAZAR_']['url'];
$lien_voir->addQueryString(BAZ_VARIABLE_ACTION, BAZ_VOIR_FICHE);
$lien_voir->addQueryString('id_fiche', $ligne['bf_id_fiche']);
$lien_voir->addQueryString('typeannonce', $ligne['bn_id_nature']);
// Nettoyage de l'url
// NOTE (jpm - 23 mai 2007): pour être compatible avec PHP5 il faut utiliser tjrs $GLOBALS['_BAZAR_']['url'] car en php4 on
// copie bien une variable mais pas en php5, cela reste une référence...
$GLOBALS['_BAZAR_']['url']->removeQueryString(BAZ_VARIABLE_ACTION);
$GLOBALS['_BAZAR_']['url']->removeQueryString('id_fiche');
$GLOBALS['_BAZAR_']['url']->removeQueryString('typeannonce');
$GLOBALS['_BAZAR_']['url']->addQueryString('id_fiche', $ligne['bf_id_fiche']);
$GLOBALS['_BAZAR_']['url']->addQueryString('typeannonce', $ligne['bn_id_nature']);
$GLOBALS['_BAZAR_']['url']->addQueryString(BAZ_VARIABLE_ACTION, BAZ_VOIR_FICHE);
$lien_voir = $GLOBALS['_BAZAR_']['url']->getURL();
$GLOBALS['_BAZAR_']['url']->removeQueryString(BAZ_VARIABLE_ACTION);
 
$GLOBALS['_BAZAR_']['url']->addQueryString(BAZ_VARIABLE_ACTION, BAZ_ACTION_PUBLIER);
$lien_publie_oui = $GLOBALS['_BAZAR_']['url']->getURL();
$GLOBALS['_BAZAR_']['url']->removeQueryString(BAZ_VARIABLE_ACTION);
$GLOBALS['_BAZAR_']['url']->addQueryString(BAZ_VARIABLE_ACTION, BAZ_ACTION_PAS_PUBLIER);
$lien_publie_non = $GLOBALS['_BAZAR_']['url']->getURL();
$GLOBALS['_BAZAR_']['url']->removeQueryString(BAZ_VARIABLE_ACTION);
$GLOBALS['_BAZAR_']['url']->addQueryString(BAZ_VARIABLE_ACTION, BAZ_ACTION_SUPPRESSION);
$lien_supprimer = $GLOBALS['_BAZAR_']['url']->getURL();
$GLOBALS['_BAZAR_']['url']->removeQueryString(BAZ_VARIABLE_ACTION);
$GLOBALS['_BAZAR_']['url']->removeQueryString('id_fiche');
$GLOBALS['_BAZAR_']['url']->removeQueryString('typeannonce');
$table->addRow (array(
'<a href="'.$lien_voir.'">'.$ligne['bf_titre'].'</a>'."\n", // col 1 : le nom
$annonceur."\n", // col 2 : annonceur
$ligne['bn_label_nature']."\n", // col 3 : type annonce
"<a href=\"".$lien_publie_oui."\">".BAZ_OUI."</a> / \n".
"<a href=\"".$lien_publie_non."\">".BAZ_NON."</a>", // col 4 : publier ou pas
"<a href=\"".$lien_supprimer."\"".
" onclick=\"javascript:return confirm('".BAZ_CONFIRMATION_SUPPRESSION."');\">".BAZ_SUPPRIMER."</a>\n", // col 5 : supprimer
date('d', strtotime($ligne['bf_date_debut_evenement'])).' '.$GLOBALS['mois'][date('n', strtotime ($ligne['bf_date_debut_evenement']))].' '.date('Y', strtotime ($ligne['bf_date_debut_evenement'])), // col 6 date début d'évenement
date('d', strtotime($ligne['bf_date_creation_fiche'])).' '.$GLOBALS['mois'][date('n', strtotime ($ligne['bf_date_creation_fiche']))].' '.date('Y', strtotime ($ligne['bf_date_creation_fiche'])) // col 7 date de création
)) ;
}
$table->altRowAttributes(1, array("class" => "ligne_impaire"), array("class" => "ligne_paire"));
$table->updateColAttributes(1, array("align" => "center"));
$table->updateColAttributes(2, array("align" => "center"));
$table->updateColAttributes(3, array("align" => "center"));
$table->updateColAttributes(4, array("align" => "center"));
$res .= $table->toHTML() ;
}
$GLOBALS['_BAZAR_']['url']->removeQueryString(BAZ_VARIABLE_VOIR);
return $res;
}
 
 
/** mes_fiches () - Renvoie les fiches bazar d'un utilisateur
*
* @return string HTML
*/
function mes_fiches() {
$res= '<h2>'.BAZ_VOS_ANNONCES.'</h2><br />'."\n";
if ($GLOBALS['AUTH']->getAuth()) {
// requete pour voir si l'utilisateur a des fiches a son nom, classees par date de MAJ et nature d'annonce
$requete = 'SELECT * FROM bazar_fiche, bazar_nature WHERE bf_ce_utilisateur='. $GLOBALS['id_user'].
' AND bn_id_nature=bf_ce_nature ';
if (isset($GLOBALS['_BAZAR_']['langue'])) $requete .= ' and bn_ce_i18n like "'.$GLOBALS['_BAZAR_']['langue'].'%" ';
$requete .= ' ORDER BY bf_date_maj_fiche DESC,bf_ce_nature ASC';
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
die ('Echec de la requete<br />'.$resultat->getMessage().'<br />'.$resultat->getDebugInfo()) ;
}
if ($resultat->numRows() != 0) {
$tableAttr = array('id' => 'table_bazar') ;
$table = new HTML_Table($tableAttr) ;
$entete = array (BAZ_TITREANNONCE , BAZ_TYPEANNONCE, BAZ_ETATPUBLICATION, BAZ_MODIFIER, BAZ_SUPPRIMER, 'Dupliquer') ;
$table->addRow($entete) ;
$table->setRowType (0, "th") ;
// On affiche une ligne par proposition
while ($ligne = $resultat->fetchRow (DB_FETCHMODE_ASSOC)) {
if ($ligne['bf_statut_fiche']==1) $publiee=BAZ_PUBLIEE;
elseif ($ligne['bf_statut_fiche']==0) $publiee=BAZ_ENCOURSDEVALIDATION;
else $publiee=BAZ_REJETEE;
$lien_voir = $GLOBALS['_BAZAR_']['url'];
$lien_voir->addQueryString(BAZ_VARIABLE_ACTION, BAZ_VOIR_FICHE);
$lien_voir->addQueryString('id_fiche', $ligne['bf_id_fiche']);
$lien_voir->addQueryString('typeannonce', $ligne['bn_id_nature']);
$lien_voir_url=$lien_voir->getURL();
$lien_modifier = $GLOBALS['_BAZAR_']['url'];
$lien_modifier->addQueryString(BAZ_VARIABLE_ACTION, BAZ_ACTION_MODIFIER);
$lien_modifier->addQueryString('id_fiche', $ligne['bf_id_fiche']);
$lien_modifier->addQueryString('typeannonce', $ligne['bn_id_nature']);
$lien_modifier_url=$lien_modifier->getURL();
$lien_supprimer = $GLOBALS['_BAZAR_']['url'];
$lien_supprimer->addQueryString(BAZ_VARIABLE_ACTION, BAZ_ACTION_SUPPRESSION);
$lien_supprimer->addQueryString('id_fiche', $ligne['bf_id_fiche']);
$lien_supprimer->addQueryString('typeannonce', $ligne['bn_id_nature']);
$lien_supprimer_url=$lien_supprimer->getURL();
$lien_dupliquer = $GLOBALS['_BAZAR_']['url'];
$lien_dupliquer->addQueryString(BAZ_VARIABLE_ACTION, BAZ_ACTION_NOUVEAU);
$lien_dupliquer->addQueryString(BAZ_VARIABLE_ID_FICHE, $ligne['bf_id_fiche']);
$lien_dupliquer->addQueryString(BAZ_VARIABLE_DUPLICATION, 1);
$lien_dupliquer=$lien_dupliquer->getURL();
$GLOBALS['_BAZAR_']['url']->removeQueryString(BAZ_VARIABLE_DUPLICATION);
$table->addRow (array(
'<a href="'.$lien_voir_url.'">'.$ligne['bf_titre'].'</a>'."\n", // col 1 : le nom
$ligne['bn_label_nature']."\n", // col 2: type annonce
$publiee."\n", // col 3 : publiee ou non
'<a href="'.$lien_modifier_url.'">'.BAZ_MODIFIER.'</a>'."\n", // col 4 : modifier
'<a href="'.$lien_supprimer_url.'" onclick="javascript:return '.
'confirm(\''.BAZ_CONFIRMATION_SUPPRESSION.'\');" >'.BAZ_SUPPRIMER.'</a>'."\n", // col 5 : supprimer
'<a href="'.$lien_dupliquer.'">Dupliquer</a>'."\n")) ;
}
$table->altRowAttributes(1, array("class" => "ligne_impaire"), array("class" => "ligne_paire"));
$table->updateColAttributes(1, array("align" => "left"));
$table->updateColAttributes(2, array("align" => "center"));
$table->updateColAttributes(3, array("align" => "center"));
$table->updateColAttributes(4, array("align" => "center"));
$res .= $table->toHTML() ;
}
else {
$res .= '<p class="zone_info">'.BAZ_PAS_DE_FICHE.'</p>'."\n" ;
}
$GLOBALS['_BAZAR_']['url']->addQueryString(BAZ_VARIABLE_VOIR, BAZ_VOIR_SAISIR);
$GLOBALS['_BAZAR_']['url']->removeQueryString('id_fiche');
$GLOBALS['_BAZAR_']['url']->removeQueryString('typeannonce');
$GLOBALS['_BAZAR_']['url']->removeQueryString(BAZ_VARIABLE_ACTION);
$res .= '<br /><ul id="liste_liens"><li id="lien_saisir"><a href="'.$GLOBALS['_BAZAR_']['url']->getURL().'" title="'.BAZ_SAISIR_UNE_NOUVELLE_FICHE.'">'.BAZ_SAISIR_UNE_NOUVELLE_FICHE.'</a></li></ul>';
}
else {
include_once BAZ_CHEMIN_APPLI.'bibliotheque/bazarTemplate.class.php';
$modele = new bazarTemplate($GLOBALS['_BAZAR_']['db']);
$res .= $modele->getTemplate(BAZ_TEMPLATE_MESSAGE_LOGIN, $GLOBALS['_BAZAR_']['langue'], $GLOBALS['_BAZAR_']['categorie_nature']);
}
return $res;
}
 
 
/** baz_gestion_droits() interface de gestion des droits
*
* return string le code HTML
*/
function baz_gestion_droits() {
$lien_formulaire=$GLOBALS['_BAZAR_']['url'];
$lien_formulaire->addQueryString(BAZ_VARIABLE_ACTION, BAZ_GERER_DROITS);
 
//contruction du squelette du formulaire
$formtemplate = new HTML_QuickForm('formulaire', 'post', preg_replace ('/&amp;/', '&', $lien_formulaire->getURL()) );
$squelette =& $formtemplate->defaultRenderer();
$squelette->setFormTemplate("\n".'<form {attributes}>'."\n".'<table style="border:0;">'."\n".'{content}'."\n".'</table>'."\n".'</form>'."\n");
$squelette->setElementTemplate( '<tr>'."\n".'<td style="font-size:12px;width:150px;text-align:right;">'."\n".'{label} :</td>'."\n".'<td style="text-align:left;padding:5px;"> '."\n".'{element}'."\n".
'<!-- BEGIN required --><span class="symbole_obligatoire">*</span><!-- END required -->'."\n".
'<!-- BEGIN error --><span class="erreur">{error}</span><!-- END error -->'."\n".
'</td>'."\n".'</tr>'."\n");
$squelette->setElementTemplate( '<tr>'."\n".'<td colspan="2" class="liste_a_cocher"><strong>{label}&nbsp;{element}</strong>'."\n".
'<!-- BEGIN required --><span class="symbole_obligatoire">&nbsp;*</span><!-- END required -->'."\n".'</td>'."\n".'</tr>'."\n", 'accept_condition');
$squelette->setElementTemplate( '<tr><td colspan="2" class="bouton">{label}{element}</td></tr>'."\n", 'valider');
$squelette->setRequiredNoteTemplate("\n".'<tr>'."\n".'<td colspan="2" class="symbole_obligatoire">* {requiredNote}</td></tr>'."\n");
//Traduction de champs requis
$formtemplate->setRequiredNote(BAZ_CHAMPS_REQUIS) ;
$formtemplate->setJsWarnings(BAZ_ERREUR_SAISIE,BAZ_VEUILLEZ_CORRIGER);
//Initialisation de la variable personne
if ( isset($_POST['personnes']) ) {
$personne=$_POST['personnes'];
}
else $personne=0;
//Cas ou les droits ont etes changes
if (isset($_GET['pers'])) {
$personne=$_GET['pers'];
//CAS DES DROITS POUR UN TYPE D'ANNONCE: On efface tous les droits de la personne pour ce type d'annonce
if (isset($_GET['idtypeannonce'])) {
$requete = 'DELETE FROM bazar_droits WHERE bd_id_utilisateur='.$_GET['pers'].
' AND bd_id_nature_offre='.$_GET['idtypeannonce'];
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
die ($resultat->getMessage().$resultat->getDebugInfo()) ;
}
}
//CAS DU SUPER ADMIN: On efface tous les droits de la personne en general
else {
$requete = 'DELETE FROM bazar_droits WHERE bd_id_utilisateur='.$_GET['pers'];
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
die ($resultat->getMessage().$resultat->getDebugInfo()) ;
}
}
if ($_GET['droits']=='superadmin') {
$requete = 'INSERT INTO bazar_droits VALUES ('.$_GET['pers'].',0,0)';
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
die ($resultat->getMessage().$resultat->getDebugInfo()) ;
}
}
elseif ($_GET['droits']=='redacteur') {
$requete = 'INSERT INTO bazar_droits VALUES ('.$_GET['pers'].','.$_GET['idtypeannonce'].',1)';
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
die ($resultat->getMessage().$resultat->getDebugInfo()) ;
}
}
elseif ($_GET['droits']=='admin') {
$requete = 'INSERT INTO bazar_droits VALUES ('.$_GET['pers'].','.$_GET['idtypeannonce'].',2)';
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
die ($resultat->getMessage().$resultat->getDebugInfo()) ;
}
}
}
//requete pour obtenir l'id, le nom et prenom des personnes inscrites a l'annuaire sauf soi meme
$requete = 'SELECT '.BAZ_CHAMPS_ID.', '.BAZ_CHAMPS_NOM.', '.BAZ_CHAMPS_PRENOM.' FROM '.BAZ_ANNUAIRE.
' WHERE '.BAZ_CHAMPS_ID." != ".$GLOBALS['id_user'].' ORDER BY '.BAZ_CHAMPS_NOM.' ASC';
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
die($resultat->getMessage().$resultat->getDebugInfo()) ;
}
$res='<h2>'.BAZ_GESTION_DES_DROITS.'</h2><br />'."\n";
$res.=BAZ_DESCRIPTION_GESTION_DES_DROITS.'<br /><br />'."\n";
$personnes_select[0]=BAZ_SELECTION;
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
$personnes_select[$ligne[BAZ_CHAMPS_ID]] = $ligne[BAZ_CHAMPS_NOM]." ".$ligne[BAZ_CHAMPS_PRENOM] ;
}
$java=array ('style'=>'width:250px;','onchange'=>'this.form.submit();');
$formtemplate->addElement ('select', 'personnes', BAZ_LABEL_CHOIX_PERSONNE, $personnes_select, $java) ;
$defauts=array ('personnes'=>$personne);
$formtemplate->setDefaults($defauts);
$res.= $formtemplate->toHTML().'<br />'."\n" ;
if ($personne!=0) {
//cas du super utilisateur
$utilisateur = new Utilisateur_bazar($personne) ;
if ($utilisateur->isSuperAdmin()) {
$res.= '<br />'.BAZ_EST_SUPERADMINISTRATEUR.'<br /><br />'."\n";
$lien_enlever_superadmin=$GLOBALS['_BAZAR_']['url'];
$lien_enlever_superadmin->addQueryString(BAZ_VARIABLE_ACTION, BAZ_GERER_DROITS);
$lien_enlever_superadmin->addQueryString('pers', $personne);
$lien_enlever_superadmin->addQueryString('droits', 'aucun');
$res.= '<a href='.$lien_enlever_superadmin->getURL().'>'.BAZ_CHANGER_SUPERADMINISTRATEUR.'</a><br />'."\n";
}
else {
$lien_passer_superadmin=$GLOBALS['_BAZAR_']['url'];
$lien_passer_superadmin->addQueryString(BAZ_VARIABLE_ACTION, BAZ_GERER_DROITS);
$lien_passer_superadmin->addQueryString('pers', $personne);
$lien_passer_superadmin->addQueryString('droits', 'superadmin');
$res.= '<a href='.$lien_passer_superadmin->getURL().'>'.BAZ_PASSER_SUPERADMINISTRATEUR.'</a><br />'."\n";
//on cherche les differentes rubriques d'annonces
$requete = 'SELECT bn_id_nature, bn_label_nature, bn_image_titre FROM bazar_nature';
if (isset($GLOBALS['_BAZAR_']['langue'])) $requete .= ' where bn_ce_i18n like "'.$GLOBALS['_BAZAR_']['langue'].'%"';
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
die ($resultat->getMessage().$resultat->getDebugInfo()) ;
}
$res.='<br /><b>'.BAZ_DROITS_PAR_TYPE.'</b><br /><br />';
$table = new HTML_Table(array ('width' => '100%', 'class' => 'table_bazar')) ;
$table->addRow(array ('<strong>'.BAZ_TYPE_ANNONCES.'</strong>',
'<strong>'.BAZ_DROITS_ACTUELS.'</strong>',
'<strong>'.BAZ_PASSER_EN.'</strong>',
'<strong>'.BAZ_OU_PASSER_EN.'</strong>')) ;
$table->setRowType (0, 'th') ;
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
$lien_aucun_droit=$GLOBALS['_BAZAR_']['url'];
$lien_aucun_droit->addQueryString(BAZ_VARIABLE_ACTION, BAZ_GERER_DROITS);
$lien_aucun_droit->addQueryString('pers', $personne);
$lien_aucun_droit->addQueryString('droits', 'aucun');
$lien_aucun_droit->addQueryString('idtypeannonce', $ligne["bn_id_nature"]);
$lien_passer_redacteur=$GLOBALS['_BAZAR_']['url'];
$lien_passer_redacteur->addQueryString(BAZ_VARIABLE_ACTION, BAZ_GERER_DROITS);
$lien_passer_redacteur->addQueryString('pers', $personne);
$lien_passer_redacteur->addQueryString('droits', 'redacteur');
$lien_passer_redacteur->addQueryString('idtypeannonce', $ligne["bn_id_nature"]);
$lien_passer_admin=$GLOBALS['_BAZAR_']['url'];
$lien_passer_admin->addQueryString(BAZ_VARIABLE_ACTION, BAZ_GERER_DROITS);
$lien_passer_admin->addQueryString('pers', $personne);
$lien_passer_admin->addQueryString('droits', 'admin');
$lien_passer_admin->addQueryString('idtypeannonce', $ligne["bn_id_nature"]);
if (isset($ligne['bn_image_titre'])) {
$titre='&nbsp;<img src="client/bazar/images/'.$ligne['bn_image_titre'].'" alt="'.$ligne['bn_label_nature'].'" />'."\n";
} else {
$titre='<strong>&nbsp;'.$ligne['bn_label_nature'].'</strong>'."\n";
}
if ($utilisateur->isAdmin($ligne['bn_id_nature'])) {
$table->addRow(array($titre,
BAZ_DROIT_ADMIN,
'<a href='.$lien_aucun_droit->getURL().'>'.BAZ_AUCUN_DROIT.'</a>',
'<a href='.$lien_passer_redacteur->getURL().'>'.BAZ_LABEL_REDACTEUR.'</a>'));
}
elseif ($utilisateur->isRedacteur($ligne['bn_id_nature'])) {
$table->addRow(array($titre,
BAZ_LABEL_REDACTEUR,
'<a href='.$lien_aucun_droit->getURL().'>'.BAZ_AUCUN_DROIT.'</a>',
'<a href='.$lien_passer_admin->getURL().'>'.BAZ_DROIT_ADMIN.'</a>'));
}
else {
$table->addRow(array($titre,
BAZ_AUCUN_DROIT,
'<a href='.$lien_passer_redacteur->getURL().'>'.BAZ_LABEL_REDACTEUR.'</a>',
'<a href='.$lien_passer_admin->getURL().'>'.BAZ_DROIT_ADMIN.'</a>'));
}
}
$table->altRowAttributes(1, array('class' => 'ligne_impaire'), array('class' => 'ligne_paire'));
$table->updateColAttributes(0, array('align' => 'left'));
$table->updateColAttributes(1, array('align' => 'left'));
$table->updateColAttributes(2, array('align' => 'left'));
$table->updateColAttributes(3, array('align' => 'left'));
$res.=$table->toHTML() ;
}
}
 
// Nettoyage de l'url
$GLOBALS['_BAZAR_']['url']->removeQueryString(BAZ_VARIABLE_ACTION);
$GLOBALS['_BAZAR_']['url']->removeQueryString('pers');
$GLOBALS['_BAZAR_']['url']->removeQueryString('droits');
$GLOBALS['_BAZAR_']['url']->removeQueryString('idtypeannonce');
 
return $res;
}
 
/** baz_formulaire() - Renvoie le menu pour les saisies et modification des annonces
*
* @param string choix du formulaire a afficher (soit formulaire personnalise de
* l'annonce, soit choix du type d'annonce)
*
* @return string HTML
*/
function baz_formulaire($mode) {
$res = '';
if ($GLOBALS['AUTH']->getAuth()) {
$lien_formulaire=$GLOBALS['_BAZAR_']['url'];
//Definir le lien du formulaire en fonction du mode de formulaire choisi
if ($mode == BAZ_DEPOSER_ANNONCE) {
$lien_formulaire->addQueryString(BAZ_VARIABLE_ACTION, BAZ_ACTION_NOUVEAU);
if (isset($GLOBALS['_BAZAR_']['id_typeannonce']) && $GLOBALS['_BAZAR_']['id_typeannonce'] != 'toutes') {
$mode = BAZ_ACTION_NOUVEAU ;
}
}
if ($mode == BAZ_ACTION_NOUVEAU) {
if ((!isset($_POST['accept_condition']))and($GLOBALS['_BAZAR_']['condition']!=NULL)) {
$lien_formulaire->addQueryString(BAZ_VARIABLE_ACTION, BAZ_ACTION_NOUVEAU);
} else {
$lien_formulaire->addQueryString(BAZ_VARIABLE_ACTION, BAZ_ACTION_NOUVEAU_V);
}
}
if ($mode == BAZ_ACTION_MODIFIER) {
if (!isset($_POST['accept_condition'])and($GLOBALS['_BAZAR_']['condition']!=NULL)) {
$lien_formulaire->addQueryString(BAZ_VARIABLE_ACTION, BAZ_ACTION_MODIFIER);
} else {
$lien_formulaire->addQueryString(BAZ_VARIABLE_ACTION, BAZ_ACTION_MODIFIER_V);
if (isset ($_SESSION['_BAZAR_']['fichier'])) unset($_SESSION['_BAZAR_']['fichier']) ;
if (isset ($_SESSION['_BAZAR_']['image'])) unset($_SESSION['_BAZAR_']['image']);
if (isset ($_SESSION['_BAZAR_']['lien'])) unset($_SESSION['_BAZAR_']['lien']);
}
$lien_formulaire->addQueryString('id_fiche', $GLOBALS['_BAZAR_']['id_fiche']);
}
if ($mode == BAZ_ACTION_MODIFIER_V) {
$lien_formulaire->addQueryString(BAZ_VARIABLE_ACTION, BAZ_ACTION_MODIFIER_V);
$lien_formulaire->addQueryString('id_fiche', $GLOBALS['_BAZAR_']['id_fiche']);
}
//contruction du squelette du formulaire
$formtemplate = new HTML_QuickForm('formulaire', 'post', preg_replace ('/&amp;/', '&', $lien_formulaire->getURL()) );
$squelette =& $formtemplate->defaultRenderer();
$squelette->setFormTemplate("\n".'<form {attributes}>'."\n".'<table style="border:0;width:100%;">'."\n".'{content}'."\n".'</table>'."\n".'</form>'."\n");
$squelette->setElementTemplate( '<tr>'."\n".'<td>'."\n".'{label}'.
'<!-- BEGIN required --><span class="symbole_obligatoire">&nbsp;*</span><!-- END required -->'."\n".
' </td>'."\n".'<td style="text-align:left;padding:5px;"> '."\n".'{element}'."\n".
'<!-- BEGIN error --><span class="erreur">{error}</span><!-- END error -->'."\n".
'</td>'."\n".'</tr>'."\n");
$squelette->setElementTemplate( '<tr>'."\n".'<td colspan="2" class="liste_a_cocher"><strong>{label}&nbsp;{element}</strong>'."\n".
'<!-- BEGIN required --><span class="symbole_obligatoire">&nbsp;*</span><!-- END required -->'."\n".'</td>'."\n".'</tr>'."\n", 'accept_condition');
$squelette->setElementTemplate( '<tr><td colspan="2" class="bouton">{label}{element}</td></tr>'."\n", 'valider');
$squelette->setRequiredNoteTemplate("\n".'<tr>'."\n".'<td colspan="2" class="symbole_obligatoire">* {requiredNote}</td></tr>'."\n");
//Traduction de champs requis
$formtemplate->setRequiredNote(BAZ_CHAMPS_REQUIS) ;
$formtemplate->setJsWarnings(BAZ_ERREUR_SAISIE,BAZ_VEUILLEZ_CORRIGER);
//------------------------------------------------------------------------------------------------
//AFFICHAGE DU FORMULAIRE GENERAL DE CHOIX DU TYPE D'ANNONCE
//------------------------------------------------------------------------------------------------
if ($mode == BAZ_DEPOSER_ANNONCE) {
$res = '';
//requete pour obtenir le nom et la description des types d'annonce
$requete = 'SELECT * FROM bazar_nature WHERE bn_ce_id_menu IN ('.$GLOBALS['_BAZAR_']['categorie_nature'].') ';
if (isset($GLOBALS['_BAZAR_']['langue'])) {
$requete .= ' and bn_ce_i18n like "'.$GLOBALS['_BAZAR_']['langue'].'%" ';
}
$requete .= 'ORDER BY bn_label_nature ASC';
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
return ($resultat->getMessage().$resultat->getDebugInfo()) ;
}
//$res.='<h2>'.BAZ_DEPOSE_UNE_NOUVELLE_ANNONCE.'</h2>'."\n";
include_once BAZ_CHEMIN_APPLI.'bibliotheque/bazarTemplate.class.php';
$modele = new bazarTemplate($GLOBALS['_BAZAR_']['db']);
$res .= $modele->getTemplate(BAZ_TEMPLATE_FORMULAIRE_ACCUEIL, $GLOBALS['_BAZAR_']['langue'], $GLOBALS['_BAZAR_']['categorie_nature']);
if ($resultat->numRows()==1) {
$ligne = $resultat->fetchRow (DB_FETCHMODE_ASSOC);
$GLOBALS['_BAZAR_']['id_typeannonce']=$ligne['bn_id_nature'];
$GLOBALS['_BAZAR_']['typeannonce']=$ligne['bn_label_nature'];
$GLOBALS['_BAZAR_']['condition']=$ligne['bn_condition'];
$GLOBALS['_BAZAR_']['template']=$ligne['bn_template'];
$GLOBALS['_BAZAR_']['commentaire']=$ligne['bn_commentaire'];
$GLOBALS['_BAZAR_']['appropriation']=$ligne['bn_appropriation'];
$GLOBALS['_BAZAR_']['image_titre']=$ligne['bn_image_titre'];
$GLOBALS['_BAZAR_']['image_logo']=$ligne['bn_image_logo'];
$mode = BAZ_ACTION_NOUVEAU;
$lien_formulaire->addQueryString(BAZ_VARIABLE_ACTION, BAZ_ACTION_NOUVEAU_V);
} else {
//$res.='<br />'.BAZ_CHOIX_TYPEANNONCE.'<br /><br />'."\n";
while ($ligne = $resultat->fetchRow (DB_FETCHMODE_ASSOC)) {
$utilisateur = new Administrateur_bazar($GLOBALS['AUTH']);
if (($utilisateur->isRedacteur($ligne['bn_id_nature'])) || ($utilisateur->isAdmin($ligne['bn_id_nature']))
|| ($utilisateur->isSuperAdmin() || !BAZ_RESTREINDRE_DEPOT)) {
if ($ligne['bn_image_titre']!='') {
$titre='&nbsp;<img src="client/bazar/images/'.$ligne['bn_image_titre'].'" alt="'.
$ligne['bn_label_nature'].'" />'.'<br />'."\n";
} else {
$titre='<h3>'.$ligne['bn_label_nature'].' : </h3>'."\n";
}
$formtemplate->addElement('radio', 'typeannonce', '',
$titre.$ligne['bn_description'].'<br /><br />'."\n",
$ligne['bn_id_nature'], array("id" => 'select'.$ligne['bn_id_nature'],
"style" => 'float:left;'));
$formtemplate->addRule('typeannonce', 'Il faut choisir un type de fiche', 'required', '', 'client') ;
}
}
$squelette->setElementTemplate( '<div class="listechoix">'."\n".'{element}'."\n".'</div>'."\n");
//Mettre les annonces en choix par defaut
$formtemplate->setdefaults(array('typeannonce'=>'1'));
// Bouton d annulation
$lien_formulaire->removeQueryString('action');
$buttons[] = &HTML_QuickForm::createElement('link', 'annuler', BAZ_ANNULER,
preg_replace ("/&amp;/", "&", $lien_formulaire->getURL()), BAZ_ANNULER); // Le preg_replace contourne un pb de QuickForm et Net_URL
// qui remplacent deux fois les & par des &amp;
//Bouton de validation du formulaire // ce qui fait échouer le lien
$buttons[] = &HTML_QuickForm::createElement('submit', 'valider', BAZ_VALIDER);
$formtemplate->addGroup($buttons, null, null, '&nbsp;');
//Affichage a l'ecran
$res.= $formtemplate->toHTML()."\n";
}
}
//------------------------------------------------------------------------------------------------
//AFFICHAGE DU FORMULAIRE CORRESPONDANT AU TYPE DE L'ANNONCE CHOISI PAR L'UTILISATEUR
//------------------------------------------------------------------------------------------------
if ($mode == BAZ_ACTION_NOUVEAU) {
$utilisateur = new Administrateur_bazar($GLOBALS['AUTH']);
if ($utilisateur->isRedacteur($GLOBALS['_BAZAR_']['id_typeannonce']) ||
$utilisateur->isAdmin($GLOBALS['_BAZAR_']['id_typeannonce'])||
$utilisateur->isSuperAdmin()) {
$lien_formulaire->addQueryString(BAZ_VARIABLE_ACTION, BAZ_ACTION_NOUVEAU_V);
$formtemplate->updateAttributes(array('action' => str_replace('&amp;', '&', $lien_formulaire->getURL())));
// Appel du modele
include_once BAZ_CHEMIN_APPLI.'bibliotheque/bazarTemplate.class.php';
$modele = new bazarTemplate($GLOBALS['_BAZAR_']['db']);
$html = $modele->getTemplate(BAZ_TEMPLATE_FORMULAIRE, $GLOBALS['_BAZAR_']['langue'],$GLOBALS['_BAZAR_']['categorie_nature']);
if (!PEAR::isError($html)) {
if (isset($_GET[BAZ_VARIABLE_DUPLICATION])) {
$res = str_replace ('{FORMULAIRE}', baz_afficher_formulaire_annonce('duplication',$formtemplate), $html);
} else {
$res = str_replace ('{FORMULAIRE}', baz_afficher_formulaire_annonce('insertion',$formtemplate), $html);
}
} else {
if (isset($_GET[BAZ_VARIABLE_DUPLICATION])) {
$res = baz_afficher_formulaire_annonce('duplication',$formtemplate);
} else {
$res = baz_afficher_formulaire_annonce('insertion',$formtemplate);
}
}
} else {
// Pas de droit pour deposer un annonce
return '<div>Pas de droits suffisants</div>';
}
}
//------------------------------------------------------------------------------------------------
//CAS DE LA MODIFICATION D'UNE ANNONCE (FORMULAIRE DE MODIFICATION)
//------------------------------------------------------------------------------------------------
if ($mode == BAZ_ACTION_MODIFIER) {
$res=baz_afficher_formulaire_annonce('modification',$formtemplate);
}
// Nettoyage de l'url avant les return : apparement inutile sinon pose pb (url applette deconnexion et moteur de recherche) [jpm le 17 mars 2008]
$GLOBALS['_BAZAR_']['url']->removeQueryString(BAZ_VARIABLE_ACTION);
$GLOBALS['_BAZAR_']['url']->removeQueryString('id_fiche');
//------------------------------------------------------------------------------------------------
//CAS DE L'INSCRIPTION D'UNE ANNONCE
//------------------------------------------------------------------------------------------------
if ($mode == BAZ_ACTION_NOUVEAU_V) {
if ($formtemplate->validate() && !isset($_SESSION['formulaire_annonce_valide'])) {
//$formtemplate->process('baz_insertion', false) ;
$id_fiche = baz_insertion ($formtemplate->getSubmitValues());
// Redirection vers mes_fiches pour eviter la revalidation du formulaire
$GLOBALS['_BAZAR_']['url']->addQueryString (BAZ_VARIABLE_ACTION, BAZ_ACTION_POST_VALIDATION);
$GLOBALS['_BAZAR_']['url']->addQueryString (BAZ_VARIABLE_ID_FICHE, $id_fiche);
header ('Location: '.str_replace ('&amp;', '&', $GLOBALS['_BAZAR_']['url']->getURL())) ;
exit();
}
}
//------------------------------------------------------------------------------------------------
//CAS DE LA MODIFICATION D'UNE ANNONCE (VALIDATION ET MAJ)
//------------------------------------------------------------------------------------------------
if ($mode == BAZ_ACTION_MODIFIER_V) {
if ($formtemplate->validate()) {
$formtemplate->process('baz_mise_a_jour', false) ;
$id_fiche = $GLOBALS['_BAZAR_']['id_fiche'] ;
// Redirection vers la fiche modifiée
$GLOBALS['_BAZAR_']['url']->addQueryString (BAZ_VARIABLE_VOIR, BAZ_GERER_DROITS);
$GLOBALS['_BAZAR_']['url']->addQueryString (BAZ_VARIABLE_ACTION, BAZ_VOIR_FICHE);
$GLOBALS['_BAZAR_']['url']->addQueryString (BAZ_VARIABLE_ID_FICHE,$id_fiche);
header ('Location: '.str_replace ('&amp;', '&', $GLOBALS['_BAZAR_']['url']->getURL())) ;
exit();
}
}
} else {
include_once BAZ_CHEMIN_APPLI.'bibliotheque/bazarTemplate.class.php';
$modele = new bazarTemplate($GLOBALS['_BAZAR_']['db']);
$res .= $modele->getTemplate(BAZ_TEMPLATE_MESSAGE_LOGIN, $GLOBALS['_BAZAR_']['langue'], $GLOBALS['_BAZAR_']['categorie_nature']);
}
 
return $res;
}
 
/** baz_afficher_formulaire_annonce() - Genere le formulaire de saisie d'une annonce
*
* @param string type de formulaire: insertion ou modification
* @param mixed objet quickform du formulaire
*
* @return string code HTML avec formulaire
*/
function baz_afficher_formulaire_annonce($mode='insertion',$formtemplate) {
if ($mode=='modification' || $mode == 'duplication') {
//initialisation de la variable globale id_fiche
$GLOBALS['_BAZAR_']['id_fiche'] = $_REQUEST[BAZ_VARIABLE_ID_FICHE];
//suppression eventuelle d'une url, d'un fichier ou d'une image
if (isset($_GET['id_url'])) {
baz_suppression_url($_GET['id_url']);
}
if (isset($_GET['id_fichier'])) {
baz_suppression_fichier($_GET['id_fichier']);
}
if (isset($_GET['image'])) {
baz_suppression_image($GLOBALS['_BAZAR_']['id_fiche']);
}
}
$res = '';
//titre de la rubrique
if (!BAZ_UTILISE_TEMPLATE) $res= '<h2>'.BAZ_TITRE_SAISIE_ANNONCE.'&nbsp;'.$GLOBALS['_BAZAR_']['typeannonce'].'</h2><br />'."\n";
if (($GLOBALS['_BAZAR_']['condition']!='')AND(!isset($_POST['accept_condition']))AND(!isset($_GET['url'])OR(!isset($_GET['fichier']))OR(!isset($_GET['image'])))) {
require_once PAP_CHEMIN_API_PEAR.'HTML/QuickForm/html.php';
$conditions= new HTML_QuickForm_html('<tr><td colspan="2" style="padding:5px; margin:5px; width: 90%; background: #C1CBA7;">'.$GLOBALS['_BAZAR_']['condition'].'</td>'."\n".'</tr>'."\n");
$formtemplate->addElement($conditions);
$formtemplate->addElement('checkbox', 'accept_condition',BAZ_ACCEPTE_CONDITIONS) ;
$formtemplate->addElement('hidden', 'typeannonce', $GLOBALS['_BAZAR_']['id_typeannonce']);
$formtemplate->addRule('accept_condition', BAZ_ACCEPTE_CONDITIONS_REQUIS, 'required', '', 'client') ;
$formtemplate->addElement('submit', 'valider', BAZ_VALIDER);
}
//affichage du formulaire si conditions acceptees
else {
//Parcours du fichier de templates, pour mettre les valeurs des champs
$tableau=baz_valeurs_template($GLOBALS['_BAZAR_']['template']);
if ($mode=='modification' || $mode == 'duplication') {
//Ajout des valeurs par defaut
$valeurs_par_defaut = baz_valeurs_fiche($GLOBALS['_BAZAR_']['id_fiche']) ;
for ($i=0; $i<count($tableau); $i++) {
if (isset($ligne[$tableau[$i]['nom_bdd']])) {
$type = $tableau[$i]['type'];
$valeur = $ligne[$tableau[$i]['nom_bdd']];
} else {
$type = $tableau[$i]['type'];
$valeur = '';
}
/*
$element = Bazar_element::factory($type, $tableau[$i]);
if (!PEAR::isError($element)) {
if (method_exists($element, 'toForm'))$res .= $element->toForm($valeur);
}
*/
if ( $tableau[$i]['type']=='liste' || $tableau[$i]['type']=='checkbox') {
$def=$tableau[$i]['type'].$tableau[$i]['nom_bdd'];
}
elseif ( $tableau[$i]['type']=='texte' || $tableau[$i]['type']=='textelong' || $tableau[$i]['type']=='listedatedeb'
|| $tableau[$i]['type']=='listedatefin' || $tableau[$i]['type']=='champs_cache'
|| $tableau[$i]['type']=='labelhtml' ) {
$def=$tableau[$i]['nom_bdd'];
} elseif ($tableau[$i]['type']=='carte_google') {
$def = 'carte_google';
$valeurs_par_defaut[$def] = array ('latitude' => $valeurs_par_defaut['bf_latitude'], 'longitude' => $valeurs_par_defaut['bf_longitude']);
}
// certain type n ont pas de valeur par defaut (labelhtml par exemple)
// on teste l existence de $valeur_par_defaut[$def] avant de le passer en parametre
if($tableau[$i]['type'] != null) {
$tableau[$i]['type']($formtemplate, $tableau[$i]['nom_bdd'], $tableau[$i]['label'], $tableau[$i]['limite1'],
$tableau[$i]['limite2'],
isset ($valeurs_par_defaut[$def]) ? $valeurs_par_defaut[$def] : '',
$tableau[$i]['table_source'], $tableau[$i]['obligatoire']) ;
}
if ($tableau[$i]['type']=='carte_google') {
include_once 'bazar.fonct.google.php';
GEN_stockerCodeScript($script);
// On ajoute l attribut load a la balise body
GEN_AttributsBody('onload', 'load()');
}
}
}
else {
for ($i=0; $i<count($tableau); $i++) {
if($tableau[$i]['type'] != null) {
$tableau[$i]['type']($formtemplate, $tableau[$i]['nom_bdd'], $tableau[$i]['label'], $tableau[$i]['limite1'],$tableau[$i]['limite2'], $tableau[$i]['defaut'], $tableau[$i]['table_source'], $tableau[$i]['obligatoire']) ;
}
if ($tableau[$i]['type'] == 'carte_google') {
include_once 'bazar.fonct.google.php';
GEN_stockerCodeScript($script);
// On ajoute l attribut load a la balise body
GEN_AttributsBody('onload', 'load()');
}
}
}
$formtemplate->addElement('hidden', 'typeannonce', $GLOBALS['_BAZAR_']['id_typeannonce']);
// Un champs cache pour la duplication
if ($mode == 'duplication') $formtemplate->addElement('hidden', 'fiche_dupliquee', $GLOBALS['_BAZAR_']['id_fiche']);
// Bouton d annulation
$attr = $formtemplate->getAttributes();
$lien_formulaire = new Net_URL($attr[BAZ_VARIABLE_ACTION]);
$lien_formulaire->addQueryString(BAZ_VARIABLE_ACTION, BAZ_ACTION_VOIR_VOS_ANNONCES);
$buttons[] = &HTML_QuickForm::createElement('link', 'annuler', BAZ_ANNULER,
preg_replace ("/&amp;/", "&", $lien_formulaire->getURL()), BAZ_ANNULER); // Le preg_replace contourne un pb de QuickForm et Net_URL
// qui remplacent deux fois les & par des &amp;
//Bouton de validation du formulaire // ce qui fait échouer le lien
$buttons[] = &HTML_QuickForm::createElement('submit', 'valider', BAZ_VALIDER);
$formtemplate->addGroup($buttons, null, null, '&nbsp;');
}
 
//Affichage a l'ecran
$res .= $formtemplate->toHTML()."\n";
return $res;
}
 
 
/** requete_bazar_fiche() - preparer la requete d'insertion ou de MAJ de la table bazar_fiche a partir du template
*
* @global mixed L'objet contenant les valeurs issues de la saisie du formulaire
* @return void
*/
function requete_bazar_fiche($valeur) {
$requete=NULL;
//l'annonce est directement publiée pour les admins
$utilisateur = new Administrateur_bazar($GLOBALS['AUTH']);
if ($utilisateur->isAdmin($GLOBALS['_BAZAR_']['id_typeannonce']) ||
$utilisateur->isSuperAdmin()) {
$requete.='bf_statut_fiche=1, ';
}
else {
$requete.='bf_statut_fiche="'.BAZ_ETAT_VALIDATION.'", ';
}
$tableau=baz_valeurs_template($GLOBALS['_BAZAR_']['template']);
for ($i=0; $i<count($tableau); $i++) {
//cas des checkbox et des listes
if ($tableau[$i]['type']=='checkbox' || $tableau[$i]['type']=='liste') {
//on supprime les anciennes valeurs de la table bazar_fiche_valeur_liste
$requetesuppression='DELETE FROM bazar_fiche_valeur_liste WHERE bfvl_ce_fiche='.$GLOBALS['_BAZAR_']['id_fiche'].' AND bfvl_ce_liste='.$tableau[$i]['nom_bdd'];
$resultat = $GLOBALS['_BAZAR_']['db']->query($requetesuppression) ;
if (DB::isError($resultat)) {
die ($resultat->getMessage().$resultat->getDebugInfo()) ;
}
if (isset($valeur[$tableau[$i]['type'].$tableau[$i]['nom_bdd']]) && ($valeur[$tableau[$i]['type'].$tableau[$i]['nom_bdd']]!=0)) {
//on insere les nouvelles valeurs
$requeteinsertion='INSERT INTO bazar_fiche_valeur_liste (bfvl_ce_fiche, bfvl_ce_liste, bfvl_valeur) VALUES ';
//pour les checkbox, les différentes valeurs sont dans un tableau
if (is_array($valeur[$tableau[$i]['type'].$tableau[$i]['nom_bdd']])) {
$nb=0;
while (list($cle, $val) = each($valeur[$tableau[$i]['type'].$tableau[$i]['nom_bdd']])) {
if ($nb>0) $requeteinsertion .= ', ';
$requeteinsertion .= '('.$GLOBALS['_BAZAR_']['id_fiche'].', '.$tableau[$i]['nom_bdd'].', '.$cle.') ';
$nb++;
}
}
//pour les listes, une insertion de la valeur suffit
else {
$requeteinsertion .= '('.$GLOBALS['_BAZAR_']['id_fiche'].', '.$tableau[$i]['nom_bdd'].', '.$valeur[$tableau[$i]['type'].$tableau[$i]['nom_bdd']].')';
}
$resultat = $GLOBALS['_BAZAR_']['db']->query($requeteinsertion) ;
if (DB::isError($resultat)) {
die ($resultat->getMessage().$resultat->getDebugInfo()) ;
}
}
}
//cas des fichiers
elseif ($tableau[$i]['type']=='fichier') {
if (isset($valeur['texte_fichier'.$tableau[$i]['nom_bdd']]) && $valeur['texte_fichier'.$tableau[$i]['nom_bdd']]!='') {
baz_insertion_fichier($valeur['texte_fichier'.$tableau[$i]['nom_bdd']], $GLOBALS['_BAZAR_']['id_fiche'], 'fichier'.$tableau[$i]['nom_bdd']);
}
}
//cas des urls
// On affine les criteres pour l insertion d une url
// il faut que le lien soit saisie, different de http:// ET que le texte du lien soit saisie aussi
// et ce afin d eviter d avoir des liens vides
elseif ($tableau[$i]['type']=='url') {
if (isset($valeur['url_lien'.$tableau[$i]['nom_bdd']]) &&
$valeur['url_lien'.$tableau[$i]['nom_bdd']]!='http://'
&& isset($valeur['url_texte'.$tableau[$i]['nom_bdd']]) &&
strlen ($valeur['url_texte'.$tableau[$i]['nom_bdd']])) {
baz_insertion_url($valeur['url_lien'.$tableau[$i]['nom_bdd']], $valeur['url_texte'.$tableau[$i]['nom_bdd']], $GLOBALS['_BAZAR_']['id_fiche']);
}
}
//cas des images
elseif ($tableau[$i]['type']=='image') {
if (isset($_FILES['image']['name']) && $_FILES['image']['name']!='') {
$requete .= baz_insertion_image($GLOBALS['_BAZAR_']['id_fiche']);
}
}
//cas des dates
elseif ( $tableau[$i]['type']=='listedatedeb' || $tableau[$i]['type']=='listedatefin' ) {
// On construit la date selon le format YYYY-mm-dd
$date = $valeur[$tableau[$i]['nom_bdd']]['Y'].'-'.$valeur[$tableau[$i]['nom_bdd']]['m'].'-'.$valeur[$tableau[$i]['nom_bdd']]['d'] ;
// si la date de fin evenement est anterieure a la date de debut, on met la date de debut
// pour eviter les incoherence
if ($tableau[$i]['nom_bdd'] == 'bf_date_fin_evenement' &&
mktime(0,0,0, $valeur['bf_date_debut_evenement']['m'], $valeur['bf_date_debut_evenement']['d'], $valeur['bf_date_debut_evenement']['Y']) >
mktime(0,0,0, $valeur['bf_date_fin_evenement']['m'], $valeur['bf_date_fin_evenement']['d'], $valeur['bf_date_fin_evenement']['Y'])) {
$val = $valeur['bf_date_debut_evenement']['Y'].'-'.$valeur['bf_date_debut_evenement']['m'].'-'.$valeur['bf_date_debut_evenement']['d'] ;
} else {
$val = $valeur[$tableau[$i]['nom_bdd']]['Y'].'-'.$valeur[$tableau[$i]['nom_bdd']]['m'].'-'.$valeur[$tableau[$i]['nom_bdd']]['d'] ;
}
$requete .= $tableau[$i]['nom_bdd'].'="'.$val.'", ' ;
}
//cas des champs texte
elseif ( $tableau[$i]['type']=='texte' || $tableau[$i]['type']=='textelong' || $tableau[$i]['type']=='champs_cache' || $tableau[$i]['type']=='champs_mail' ) {
//on mets les slashes pour les saisies dans les champs texte et textearea
$val=addslashes($valeur[$tableau[$i]['nom_bdd']]) ;
$requete .= $tableau[$i]['nom_bdd'].'="'.$val.'", ' ;
}
//cas des wikinis
elseif ( $tableau[$i]['type']=='wikini' && $_REQUEST[BAZ_VARIABLE_ACTION]==BAZ_ACTION_NOUVEAU_V ) {
//on appelle les pages des apis et de l'integrateur wikini
include_once PAP_CHEMIN_RACINE.'api/sql/SQL_manipulation.fonct.php';
include_once PAP_CHEMIN_RACINE.'client/integrateur_wikini/configuration/adwi_configuration.inc.php' ;
include_once PAP_CHEMIN_RACINE.'client/integrateur_wikini/bibliotheque/adwi_wikini.fonct.php' ;
//génération du titre du wiki, sous la forme id-titre du projet
$titre=baz_titre_wiki($valeur["bf_titre"]);
//création du wiki
$valeur=array ("action"=> "nouveau_v", "code_alpha_wikini"=>$titre, "page"=>"AccueiL", "bdd_hote"=> "",
"bdd_nom"=> "", "bdd_utilisateur"=> "", "bdd_mdp" => "", "table_prefix"=> "", "chemin" => "wikini/".$titre, "valider"=> "Valider");
$val = insertion($valeur, $GLOBALS['_BAZAR_']['db']);
}
// Cas de la carte google
elseif ($tableau[$i]['type'] == 'carte_google') {
$requete .= 'bf_latitude="'.$valeur['latitude'].'", bf_longitude="'.$valeur['longitude'].'",';
}
}
$requete.=' bf_date_maj_fiche=NOW()';
/*if($utilisateur->isSuperAdmin()) {
$requete.=', bf_date_debut_validite_fiche=NOW()';
}*/
return $requete;
}
 
/** baz_insertion() - inserer une nouvelle fiche
*
* @array Le tableau des valeurs a inserer
* @integer Valeur de l'identifiant de la fiche
* @return void
*/
function baz_insertion($valeur) {
// =========== Insertion d'une nouvelle fiche ===================
// dans le cas où on traite le type d'évenements, on le récupère dans la globale id_typeannonce
if (isset($valeur['liste31']) && $valeur['liste31'] != '') {
$GLOBALS['_BAZAR_']['id_typeannonce'] = $valeur['liste31'] ;
}
//requete d'insertion dans bazar_fiche
$GLOBALS['_BAZAR_']['id_fiche'] = baz_nextid('bazar_fiche', 'bf_id_fiche', $GLOBALS['_BAZAR_']['db']) ;
$requete = 'INSERT INTO bazar_fiche SET bf_id_fiche='.$GLOBALS['_BAZAR_']['id_fiche'].','.
'bf_ce_utilisateur='.$GLOBALS['id_user'].', bf_ce_nature='.$GLOBALS['_BAZAR_']['id_typeannonce'].','.
'bf_date_creation_fiche=NOW() , '.requete_bazar_fiche($valeur);
if (!isset($_REQUEST['bf_date_debut_validite_fiche'])) {
$requete .= ', bf_date_debut_validite_fiche=now(), bf_date_fin_validite_fiche="0000-00-00" ' ;
}
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
die($resultat->getMessage().$resultat->getDebugInfo()) ;
}
// Envoie d un mail aux administrateurs
$utilisateur = new Administrateur_bazar($GLOBALS['AUTH']);
if (!$utilisateur->isAdmin($GLOBALS['_BAZAR_']['id_typeannonce']) && !$utilisateur->isSuperAdmin()) {
bazar::notifier(BAZAR_NOTIFICATION_NOUVELLE_FICHE);
}
// On redirige
return $GLOBALS['_BAZAR_']['id_fiche'];
}
 
 
/** baz_insertion_url() - inserer un lien URL a une fiche
*
* @global string L'url du lien
* @global string Le texte du lien
* @global integer L'identifiant de la fiche
* @return void
*/
function baz_insertion_url($url_lien, $url_texte, $idfiche) {
//requete d'insertion dans bazar_url
if (!isset($_SESSION['_BAZAR_']['lien'])) {
$id_url = baz_nextId('bazar_url', 'bu_id_url', $GLOBALS['_BAZAR_']['db']) ;
$requete = 'INSERT INTO bazar_url SET bu_id_url='.$id_url.', bu_ce_fiche='.$idfiche.', '.
'bu_url="'.$url_lien.'", bu_descriptif_url="'.addslashes($url_texte).'"';
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
return $resultat->getMessage().$resultat->getDebugInfo() ;
}
$_SESSION['_BAZAR_']['lien'] = 1;
return;
}
}
 
 
/** baz_insertion_fichier() - inserer un fichier a une fiche
*
* @global string Le label du fichier
* @global string La description du fichier
* @global integer L'identifiant de la fiche
* @return void
*/
function baz_insertion_fichier($fichier_description, $idfiche, $nom_fichier='fichier_joint') {
//verification de la presence de ce fichier
$requete = 'SELECT bfj_id_fichier FROM bazar_fichier_joint WHERE bfj_fichier="'.$_FILES[$nom_fichier]['name'].'"';
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
die ($resultat->getMessage().$resultat->getDebugInfo()) ;
}
if (!isset ($_SESSION['_BAZAR_']['fichier'])) {
if ($resultat->numRows()==0) {
$chemin_destination=BAZ_CHEMIN_APPLI.'upload/'.$_FILES[$nom_fichier]['name'];
move_uploaded_file($_FILES[$nom_fichier]['tmp_name'], $chemin_destination);
chmod ($chemin_destination, 0755);
}
$id_fichier_joint = baz_nextId('bazar_fichier_joint', 'bfj_id_fichier', $GLOBALS['_BAZAR_']['db']) ;
$requete = 'INSERT INTO bazar_fichier_joint SET bfj_id_fichier='.$id_fichier_joint.', bfj_ce_fiche='.$idfiche.
', bfj_description="'.addslashes($fichier_description).'", bfj_fichier="'.$_FILES[$nom_fichier]['name'].'"';
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
return $resultat->getMessage().$resultat->getDebugInfo() ;
}
}
$_SESSION['_BAZAR_']['fichier'] = 1;
return;
}
 
 
/** baz_insertion_image() - inserer une image a une fiche
*
* @global integer L'identifiant de la fiche
* @return string requete SQL
*/
function baz_insertion_image($idfiche) {
//verification de la presence de ce fichier
$requete = 'SELECT bf_id_fiche FROM bazar_fiche WHERE bf_url_image="'.$_FILES['image']['name'].'" AND bf_id_fiche!='.$idfiche;
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
die ($resultat->getMessage().$resultat->getDebugInfo()) ;
}
if ($resultat->numRows()==0) {
$chemin_destination=BAZ_CHEMIN_APPLI.'upload/'.$_FILES['image']['name'];
move_uploaded_file($_FILES['image']['tmp_name'], $chemin_destination);
chmod ($chemin_destination, 0755);
}
$_SESSION['_BAZAR_']['image'] = 1;
return 'bf_url_image="'.$_FILES['image']['name'].'", ' ;
}
 
 
/** baz_mise_a_jour() - Mettre a jour une fiche
*
* @global Le contenu du formulaire de saisie de l'annonce
* @return void
*/
function baz_mise_a_jour($valeur) {
if (isset($valeur['liste31']) && $valeur['liste31'] != '') {
$GLOBALS['_BAZAR_']['id_typeannonce'] = $valeur['liste31'] ;
}
 
//MAJ de bazar_fiche
$requete = 'UPDATE bazar_fiche SET '.requete_bazar_fiche(&$valeur);
if (isset($valeur['liste31']) && $valeur['liste31'] != '') {
$requete .= ' ,bf_ce_nature = '.$GLOBALS['_BAZAR_']['id_typeannonce'] ;
}
$requete.= ' WHERE bf_id_fiche='.$GLOBALS['_BAZAR_']['id_fiche'];
 
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
die ($resultat->getMessage().$resultat->getDebugInfo()) ;
}
// Envoie d un mail aux administrateurs
$utilisateur = new Administrateur_bazar($GLOBALS['AUTH']);
if (!$utilisateur->isAdmin($GLOBALS['_BAZAR_']['id_typeannonce']) || !$utilisateur->isSuperAdmin()) {
bazar::notifier(BAZAR_NOTIFICATION_MODIFICATION_FICHE);
}
return;
}
 
function baz_post_validation() {
$lien_duplication = clone $GLOBALS['_BAZAR_']['url'];
$lien_nouvelle_fiche = clone $GLOBALS['_BAZAR_']['url'];
$lien_mes_fiches = clone $GLOBALS['_BAZAR_']['url'];
$lien_visualiser_fiche = clone $GLOBALS['_BAZAR_']['url'];
$lien_duplication->addQueryString(BAZ_VARIABLE_ID_FICHE, $_GET[BAZ_VARIABLE_ID_FICHE]);
$lien_duplication->addQueryString(BAZ_VARIABLE_DUPLICATION, 1);
$lien_duplication->addQueryString(BAZ_VARIABLE_ACTION, BAZ_ACTION_NOUVEAU);
$lien_duplication = $lien_duplication->getURL();
$lien_nouvelle_fiche->addQueryString(BAZ_VARIABLE_ACTION, BAZ_DEPOSER_ANNONCE);
$lien_nouvelle_fiche->addQueryString(BAZ_VARIABLE_CATEGORIE_NATURE, $GLOBALS['_BAZAR_']['categorie_nature']);
$lien_nouvelle_fiche = $lien_nouvelle_fiche->getURL();
$lien_mes_fiches->addQueryString(BAZ_VARIABLE_VOIR, BAZ_VOIR_MES_FICHES);
$lien_mes_fiches = $lien_mes_fiches->getURL();
$lien_visualiser_fiche->addQueryString(BAZ_VARIABLE_VOIR, BAZ_GERER_DROITS);
$lien_visualiser_fiche->addQueryString(BAZ_VARIABLE_ACTION, BAZ_VOIR_FICHE);
$lien_visualiser_fiche->addQueryString(BAZ_VARIABLE_ID_FICHE, $_GET[BAZ_VARIABLE_ID_FICHE]);
$lien_visualiser_fiche = $lien_visualiser_fiche->getUrl() ;
ob_start();
if (file_exists(BAZ_CHEMIN_SQUELETTE.'baz_post_validation.tpl.html')) {
include_once BAZ_CHEMIN_SQUELETTE.'baz_post_validation.tpl.html';
}
$res = ob_get_contents();
ob_end_clean();
return $res ;
}
 
/** baz_suppression() - Supprime une fiche
*
* @global L'identifiant de la fiche a supprimer
* @return void
*/
function baz_suppression() {
if ($GLOBALS['AUTH']->getAuth()) {
$valeurs=baz_valeurs_fiche($_GET['id_fiche']);
//suppression des wikinis associes
//génération du titre du wiki, sous la forme id-titre du projet
$titre=baz_titre_wiki($valeurs["bf_titre"]);
$requete = 'SELECT gewi_id_wikini FROM gen_wikini WHERE gewi_code_alpha_wikini = "'.$titre.'"';
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if ($resultat->numRows()>0) {
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
$id_wikini=$ligne['gewi_id_wikini'];
}
include_once PAP_CHEMIN_RACINE.'api/sql/SQL_manipulation.fonct.php';
include_once PAP_CHEMIN_RACINE.'client/integrateur_wikini/configuration/adwi_configuration.inc.php' ;
include_once PAP_CHEMIN_RACINE.'client/integrateur_wikini/bibliotheque/adwi_wikini.fonct.php' ;
adwi_supprimer_wikini($id_wikini, $GLOBALS['_BAZAR_']['db']);
}
// suppression des valeurs des listes et des cases à cocher
$requete = 'DELETE FROM bazar_fiche_valeur_liste WHERE bfvl_ce_fiche='.$_GET['id_fiche'];
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
die ($resultat->getMessage().$resultat->getDebugInfo()) ;
}
//suppression des urls associes
$requete = 'delete FROM bazar_url WHERE bu_ce_fiche = '.$_GET['id_fiche'];
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
return ('Echec de la requete<br />'.$resultat->getMessage().'<br />'.$resultat->getDebugInfo().'<br />'."\n") ;
}
//suppression des fichiers associes
$requete = 'SELECT bfj_id_fichier FROM bazar_fichier_joint WHERE bfj_ce_fiche = '.$_GET['id_fiche'];
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
return ('Echec de la requete<br />'.$resultat->getMessage().'<br />'.$resultat->getDebugInfo().'<br />'."\n") ;
}
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
baz_suppression_fichier($ligne['bfj_id_fichier']);
}
//suppression dans bazar_fiche
$requete = 'DELETE FROM bazar_fiche WHERE bf_id_fiche = '.$_GET['id_fiche'];
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
die ('Echec de la requete<br />'.$resultat->getMessage().'<br />'.$resultat->getDebugInfo().'<br />'."\n") ;
}
return ;
}
}
 
 
/** baz_suppression_url() - Supprimer un lien d'une fiche
*
* @global integer L'identifiant du lien
* @return void
*/
function baz_suppression_url($id_url) {
if ($GLOBALS['AUTH']->getAuth()) {
//suppression dans bazar_url
$requete = 'DELETE FROM bazar_url WHERE bu_id_url = '.$id_url;
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
die ('Echec de la requete<br />'.$resultat->getMessage().'<br />'.$resultat->getDebugInfo()) ;
}
return;
}
}
 
 
/** baz_suppression_fichier() - Supprimer un fichier d'une fiche
*
* @global integer L'identifiant du fichier
* @return void
*/
function baz_suppression_fichier($id_fichier) {
if ($GLOBALS['AUTH']->getAuth()) {
//verification de l'utilisation du fichier joint pour une autre annonce
$requete = 'SELECT bfj_fichier FROM bazar_fichier_joint WHERE bfj_id_fichier='.$id_fichier;
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
$ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC);
$requete = 'SELECT bfj_fichier FROM bazar_fichier_joint WHERE bfj_fichier="'.$ligne['bfj_fichier'].'"';
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
//si le fichier n'est que utilise dans cette fiche, on le supprime, on le laisse sinon
if ($resultat->numRows()==1) {
$ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC);
unlink(BAZ_CHEMIN_APPLI.'upload/'.$ligne['bfj_fichier']);
}
//suppression dans la table bazar_fichier
$requete = 'DELETE FROM bazar_fichier_joint WHERE bfj_id_fichier = '.$id_fichier;
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
return ('Echec de la requete<br />'.$resultat->getMessage().'<br />'.$resultat->getDebugInfo()) ;
}
return;
}
}
 
 
/** baz_suppression_image() - Supprimer une image d'une fiche
*
* @global integer L'identifiant de la fiche
* @return void
*/
function baz_suppression_image($id_fiche) {
if ($GLOBALS['AUTH']->getAuth()) {
//verification de l'utilisation de l'image pour une autre annonce
$requete = 'SELECT bf_url_image FROM bazar_fiche WHERE bf_id_fiche='.$id_fiche;
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
$ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC);
$requete = 'SELECT bf_url_image FROM bazar_fiche WHERE bf_url_image="'.$ligne['bf_url_image'].'"';
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
//si le fichier n'est que utilise dans cette fiche, on le supprime, on le laisse sinon
if ($resultat->numRows()==1) {
$ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC);
unlink(BAZ_CHEMIN_APPLI.'upload/'.$ligne['bf_url_image']);
}
//suppression dans la table bazar_fiche
$requete = 'UPDATE bazar_fiche SET bf_url_image=NULL WHERE bf_id_fiche = '.$id_fiche;
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
die ('Echec de la requete<br />'.$resultat->getMessage().'<br />'.$resultat->getDebugInfo()) ;
}
return;
}
}
 
 
/** publier_fiche () - Publie ou non dans les fichiers XML la fiche bazar d'un utilisateur
*
* @global boolean Valide: oui ou non
* @return void
*/
function publier_fiche($valid) {
 
$utilisateur = new Administrateur_bazar($GLOBALS['AUTH']);
// sortie anticipée en cas d'accès non autorisé
// ceci limite l'accès au supers admins
// TODO: voir si l'on ne pourrait valider que les fiches
// des catégories dont la personne est admin, ce qui permettrait un accès plus fin
if(!$utilisateur->isSuperAdmin()) {
return;
}
 
if (isset($_GET['id_fiche'])) $GLOBALS['_BAZAR_']['id_fiche']=$_GET['id_fiche'];
if (isset($_GET['typeannonce'])) $typeannonce=$_GET['typeannonce'];
if(isset($_POST['date_validite']) && date('Y-m-d', strtotime($_POST['date_validite']))) {
$date_validite = '"'.date('Y-m-d', strtotime($_POST['date_validite'])).'"';
} else {
$date_validite = 'now()';
}
if ($valid==0) {
$requete = 'UPDATE bazar_fiche SET bf_statut_fiche=2 ';
if(isset($_POST['date_validite']) && date('Y-m-d', strtotime($_POST['date_validite']))) {
$requete .= ', bf_date_debut_validite_fiche='.$date_validite.' ';
}
$requete .= 'WHERE bf_id_fiche="'.$GLOBALS['_BAZAR_']['id_fiche'].'"' ;
}
else {
$requete .= 'UPDATE bazar_fiche SET bf_date_debut_validite_fiche='.$date_validite.' , bf_statut_fiche=1 WHERE bf_id_fiche="'.$GLOBALS['_BAZAR_']['id_fiche'].'"' ;
}
// ====================Mise a jour de la table bazar_fiche====================
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
die ($resultat->getMessage().$resultat->getDebugInfo()) ;
}
unset ($resultat) ;
//TODO envoie mail annonceur
return;
}
 
 
/** baz_s_inscrire() affiche le formulaire qui permet de s'inscrire pour recevoir des annonces d'un type
*
* @return string le code HTML
*/
function baz_s_inscrire() {
$res= '<h2>'.BAZ_S_INSCRIRE_AUX_ANNONCES.'</h2>'."\n";
$res .= '<p id="laius_abonnement">'.BAZ_LAIUS_S_ABONNER.'</p>'."\n";
//requete pour obtenir l'id et le label des types d'annonces
$requete = 'SELECT bn_id_nature, bn_label_nature, bn_image_titre '.
'FROM bazar_nature WHERE 1';
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
return ($resultat->getMessage().$resultat->getDebugInfo()) ;
}
// Nettoyage de l url
$GLOBALS['_BAZAR_']['url']->removeQueryString(BAZ_VARIABLE_VOIR);
$table = new HTML_Table(array ('class' => 'table_bazar'));
$table->addRow(array(BAZ_TYPE_ANNONCES, BAZ_RSS));
$table->setRowType(0, 'th');
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
$lien_RSS=$GLOBALS['_BAZAR_']['url'];
$lien_RSS->addQueryString(BAZ_VARIABLE_ACTION, BAZ_VOIR_FLUX_RSS);
$lien_RSS->addQueryString('annonce', $ligne[bn_id_nature]);
if (isset($ligne['bn_image_titre'])) {$titre='&nbsp;<img src="client/bazar/images/'.$ligne['bn_image_titre'].'" alt="'.$ligne['bn_label_nature'].'" />'."\n";}
else {$titre='<strong>&nbsp;'.$ligne['bn_label_nature'].'</strong>'."\n";}
 
$table->addRow(array($titre,
'<a href="'.$lien_RSS->getURL().'"><img src="client/bazar/images/BAZ_rss.png" alt="'.BAZ_RSS.'"></a>'));
$lien_RSS->removeQueryString('annonce');
}
$table->altRowAttributes(1, array('class' => 'ligne_impaire'), array('class' => 'ligne_paire'));
$table->updateColAttributes(0, array('class' => 'col1'));
$table->updateColAttributes(1, array('class' => 'col2'));
$res.=$table->toHTML() ;
 
// Nettoyage de l'url
$GLOBALS['_BAZAR_']['url']->removeQueryString(BAZ_VARIABLE_ACTION);
$GLOBALS['_BAZAR_']['url']->removeQueryString('idtypeannonce');
return $res;
}
 
 
/** baz_valeurs_fiche() - Renvoie un tableau avec les valeurs par defaut du formulaire d'inscription
*
* @param integer Identifiant de la fiche
*
* @return array Valeurs enregistrees pour cette fiche
*/
function baz_valeurs_fiche($idfiche) {
$requete = 'SELECT * FROM bazar_fiche WHERE bf_id_fiche='.$idfiche;
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
die ($resultat->getMessage().'<br />'.$resultat->getDebugInfo()) ;
}
$ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC) ;
$valeurs_fiche = array() ;
$tableau = baz_valeurs_template($GLOBALS['_BAZAR_']['template']);
for ($i=0; $i<count($tableau); $i++) {
if ($tableau[$i]['type']=='liste' || $tableau[$i]['type']=='checkbox') {
$requete = 'SELECT bfvl_valeur FROM bazar_fiche_valeur_liste WHERE bfvl_ce_fiche='.$idfiche.
' AND bfvl_ce_liste='.$tableau[$i]['nom_bdd'];
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError ($resultat)) {
die ($resultat->getMessage().'<br />'.$resultat->getDebugInfo()) ;
}
$nb=0;$val='';
while ($result = $resultat->fetchRow()) {
if ($nb>0) $val .= ', ';
$val .= $result[0];
$nb++;
}
$valeurs_fiche[$tableau[$i]['type'].$tableau[$i]['nom_bdd']] = $val;
}
elseif ($tableau[$i]['type']=='champs_cache' || $tableau[$i]['type']=='texte' || $tableau[$i]['type']=='textelong' || $tableau[$i]['type']=='listedatedeb' || $tableau[$i]['type']=='listedatefin') {
$valeurs_fiche[$tableau[$i]['nom_bdd']] = stripslashes($ligne[$tableau[$i]['nom_bdd']]);
} elseif ($tableau[$i]['type']=='carte_google') {
$valeurs_fiche['bf_latitude'] = $ligne['bf_latitude'];
$valeurs_fiche['bf_longitude'] = $ligne['bf_longitude'];
}
}
return $valeurs_fiche;
}
 
function baz_valeur_champs($nom_champs,$id_fiche) {
 
$requete = 'SELECT blv_label FROM bazar_fiche_valeur_liste, bazar_liste_valeurs WHERE bfvl_ce_fiche='.
$id_fiche.' AND bfvl_ce_liste='.$nom_champs.
' AND bfvl_valeur=blv_valeur AND blv_ce_liste='.$nom_champs.
' AND blv_ce_i18n="'.$GLOBALS['_BAZAR_']['langue'].'"';
 
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError ($resultat)) {
return ($resultat->getMessage().'<br />'.$resultat->getDebugInfo()) ;
}
else {
$res = '';
while($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
if($ligne['blv_label'] != 'Autre') {
$res .= $ligne['blv_label'].', ';
}
}
$res = rtrim($res,', ');
 
return $res;
}
}
 
/** function baz_nextId () Renvoie le prochain identifiant numerique libre d'une table
*
* @param string Nom de la table
* @param string Nom du champs identifiant
* @param mixed Objet DB de PEAR pour la connexion a la base de donnees
*
* return integer Le prochain numero d'identifiant disponible
*/
function baz_nextId($table, $colonne_identifiant, $bdd) {
$requete = 'SELECT MAX('.$colonne_identifiant.') AS maxi FROM '.$table;
$resultat = $bdd->query($requete) ;
if (DB::isError($resultat)) {
die (__FILE__ . __LINE__ . $resultat->getMessage() . $requete);
return $bdd->raiseError($resultat) ;
}
if ($resultat->numRows() > 1) {
return $bdd->raiseError('<br />La table '.$table.' a un identifiant non unique<br />') ;
}
$ligne = $resultat->fetchRow(DB_FETCHMODE_OBJECT) ;
return $ligne->maxi + 1 ;
}
 
/** function baz_titre_wiki () Renvoie la chaine de caractere sous une forme compatible avec wikini
*
* @param string mot à transformer (enlever accents, espaces)
*
* return string mot transformé
*/
function baz_titre_wiki($nom) {
$titre=trim($nom);
for ($j = 0; $j < strlen ($titre); $j++) {
if (!preg_match ('/[a-zA-Z0-9]/', $titre[$j])) {
$titre[$j] = '_' ;
}
}
return $titre;
}
 
/* +--Fin du code ----------------------------------------------------------------------------------------+
*
* $Log: not supported by cvs2svn $
* Revision 1.74.2.12 2008-04-16 12:38:17 alexandre_tb
* verification des droits avant de permettre l ajout d une nouvelle fiche
*
* Revision 1.74.2.11 2008-03-17 11:03:02 jp_milcent
* Ajout de l'authentification nécessaire pour déposer des commentaires.
* Corrections sur la gestion des paramêtres dans les urls (compatibilité applette Identification et Moteur de Recherche).
*
* Revision 1.74.2.10 2008-02-01 17:20:18 florian
* suppression du lien annuler pour la sélection des fiches, pas de valeur par défaut pour la sélection, et sélectionner un type de fiche devient obligatoire.
*
* Revision 1.74.2.9 2008-02-01 16:23:29 florian
* ajout champs_mail, décommenter les traductions des javascripts
*
* Revision 1.74.2.8 2008-02-01 09:56:56 alexandre_tb
* reglage du pb de double saisie de fiche,
* ajout d un exit apres le header location
*
* Revision 1.74.2.7 2008-01-29 14:35:22 alexandre_tb
* suppression de l identification pour l abonnement au fluxRSS
*
* Revision 1.74.2.6 2008-01-29 09:55:07 alexandre_tb
* suppression de l identification pour l abonnement au fluxRSS
*
* Revision 1.74.2.5 2008-01-29 09:35:36 alexandre_tb
* remplacement des variables action par une constante
* Utilisation d un redirection pour eviter que les formulaires soient valides 2 fois
* simplification de la suppression d un lien associe a une liste
*
* Revision 1.74.2.4 2008-01-11 14:10:12 alexandre_tb
* Remplacement de la variable action ecrite en dur par la constante BAZ_VARIABLE_ACTION
*
* Revision 1.74.2.3 2007-12-14 09:55:05 alexandre_tb
* suppression de style dans le formulaire
*
* Revision 1.74.2.2 2007-12-06 15:36:07 alexandre_tb
* appel de la fonction GEN_AttributsBody dans le composant carte_google
*
* Revision 1.74.2.1 2007-12-04 09:00:08 alexandre_tb
* corrections importantes sur baz_s_inscrire, simplification de l'application qui ne fonctionnait pas.
*
* Revision 1.74 2007-10-25 09:41:31 alexandre_tb
* mise en place de variable de session pour eviter que les formulaires soit valider 2 fois, pour les url, fichiers et image
*
* Revision 1.73 2007-10-24 13:27:00 alexandre_tb
* bug : double saisie d url
* suppression de warning sur variable
*
* Revision 1.72 2007-10-22 10:09:21 florian
* correction template
*
* Revision 1.71 2007-10-22 09:18:39 alexandre_tb
* prise en compte de la langue dans les requetes sur bazar_nature
*
* Revision 1.70 2007-10-10 13:26:36 alexandre_tb
* utilisation de la classe Administrateur_bazar a la place de niveau_droit
* suppression de fonction niveau_droit
*
* Revision 1.69 2007-09-18 07:39:42 alexandre_tb
* correction d un bug lors d une insertion
*
* Revision 1.68 2007-08-27 12:31:31 alexandre_tb
* mise en place de modele
*
* Revision 1.67 2007-07-04 10:01:30 alexandre_tb
* mise en place de divers templates :
* - mail pour admin (sujet et corps)
* - modele carte_google
* ajout de lignes dans bazar_template
*
* Revision 1.66 2007-06-25 12:15:06 alexandre_tb
* merge from narmer
*
* Revision 1.65 2007-06-25 08:31:17 alexandre_tb
* utilisation de la bibliotheque generale api/formulaire/formulaire.fonct.inc.php a la place de bazar.fonct.formulaire.php
*
* Revision 1.64 2007-06-04 15:25:39 alexandre_tb
* ajout de la carto google
*
* Revision 1.63 2007/04/11 08:30:12 neiluj
* remise en état du CVS...
*
* Revision 1.57.2.12 2007/03/16 14:49:24 alexandre_tb
* si la date de debut d evenement est superieure a la date de fin alors on met
* la meme date dans les deux champs (coherence)
*
* Revision 1.57.2.11 2007/03/07 17:40:57 jp_milcent
* Ajout d'id sur les colonnes et gestion par les CSS des styles du tableau des abonnements.
*
* Revision 1.57.2.10 2007/03/07 17:20:19 jp_milcent
* Ajout du nettoyage systématique des URLs.
*
* Revision 1.57.2.9 2007/03/06 16:23:24 jp_milcent
* Nettoyage de l'url pour la gestion des droits.
*
* Revision 1.57.2.8 2007/03/05 14:33:44 jp_milcent
* Suppression de l'appel à Mes_Fiches dans la fonction baz_formulaire
*
* Revision 1.57.2.7 2007/03/05 10:28:03 alexandre_tb
* correction d un commentaire
*
* Revision 1.57.2.6 2007/02/15 13:42:16 jp_milcent
* Utilisation de IN à la place du = dans les requêtes traitant les catégories de fiches.
* Permet d'utiliser la syntaxe 1,2,3 dans la configuration de categorie_nature.
*
* Revision 1.57.2.5 2007/02/12 16:16:31 alexandre_tb
* suppression du style clear:both dans les attribut du formulaire d identification
*
* Revision 1.57.2.4 2007/02/01 16:19:30 alexandre_tb
* correction erreur de requete sur insertion bazar_fiche
*
* Revision 1.57.2.3 2007/02/01 16:11:05 alexandre_tb
* correction erreur de requete sur insertion bazar_fiche
*
* Revision 1.57.2.2 2007/01/22 16:05:39 alexandre_tb
* insertion de la date du jour dans bf_date_debut_validite_fiche quand il n'y a pas ce champs dans le formulaire (évite le 0000-00-00)
*
* Revision 1.57.2.1 2006/12/13 13:23:03 alexandre_tb
* Remplacement de l appel d une constante par un appel direct. -> warning
*
* Revision 1.58 2006/12/13 13:20:16 alexandre_tb
* Remplacement de l appel d une constante par un appel direct. -> warning
*
* Revision 1.57 2006/10/05 08:53:50 florian
* amelioration moteur de recherche, correction de bugs
*
* Revision 1.56 2006/09/28 15:41:36 alexandre_tb
* Le formulaire pour se logguer dans l'action saisir reste sur l'action saisir après
*
* Revision 1.55 2006/09/21 14:19:39 florian
* amélioration des fonctions liés au wikini
*
* Revision 1.54 2006/09/14 15:11:23 alexandre_tb
* suppression temporaire de la gestion des wikinis
*
* Revision 1.53 2006/07/25 13:24:44 florian
* correction bug image
*
* Revision 1.52 2006/07/25 13:05:00 alexandre_tb
* Remplacement d un die par un echo
*
* Revision 1.51 2006/07/18 14:17:32 alexandre_tb
* Ajout d'un formulaire d identification
*
* Revision 1.50 2006/06/21 08:37:59 alexandre_tb
* Correction de bug, d'un appel constant (....) qui ne fonctionnais plus.
*
* Revision 1.49 2006/06/02 09:29:07 florian
* debut d'integration de wikini
*
* Revision 1.48 2006/05/19 13:54:11 florian
* stabilisation du moteur de recherche, corrections bugs, lien recherche avancee
*
* Revision 1.47 2006/04/28 12:46:14 florian
* integration des liens vers annuaire
*
* Revision 1.46 2006/03/29 13:04:35 alexandre_tb
* utilisation de la classe Administrateur_bazar
*
* Revision 1.45 2006/03/24 09:28:02 alexandre_tb
* utilisation de la variable globale $GLOBALS['_BAZAR_']['categorie_nature']
*
* Revision 1.44 2006/03/14 17:10:21 florian
* ajout des fonctions de syndication, changement du moteur de recherche
*
* Revision 1.43 2006/03/02 20:36:52 florian
* les entrees du formulaire de saisir ne sont plus dans les constantes mias dans des tables qui gerent le multilinguisme.
*
* Revision 1.42 2006/03/01 16:23:22 florian
* modifs textes fr et correction bug "undefined index"
*
* Revision 1.41 2006/03/01 16:05:51 florian
* ajout des fichiers joints
*
* Revision 1.40 2006/02/06 09:33:00 alexandre_tb
* correction de bug
*
* Revision 1.39 2006/01/30 17:25:38 alexandre_tb
* correction de bugs
*
* Revision 1.38 2006/01/30 10:27:04 florian
* - ajout des entrées de formulaire fichier, url, et image
* - correction bug d'affichage du mode de saisie
*
* Revision 1.37 2006/01/24 14:11:11 alexandre_tb
* correction de bug sur l'ajout d'une image et d'un fichier
*
* Revision 1.36 2006/01/19 17:42:11 florian
* ajout des cases à cocher pré-cochées pour les maj
*
* Revision 1.35 2006/01/18 11:06:51 florian
* correction erreur saisie date
*
* Revision 1.34 2006/01/18 10:53:28 florian
* corrections bugs affichage fiche
*
* Revision 1.33 2006/01/18 10:07:34 florian
* recodage de l'insertion et de la maj des données relatives aux listes et checkbox dans des formulaires
*
* Revision 1.32 2006/01/18 10:03:36 florian
* recodage de l'insertion et de la maj des données relatives aux listes et checkbox dans des formulaires
*
* Revision 1.31 2006/01/17 10:07:08 alexandre_tb
* en cours
*
* Revision 1.30 2006/01/16 09:42:57 alexandre_tb
* en cours
*
* Revision 1.29 2006/01/13 14:12:51 florian
* utilisation des temlates dans la table bazar_nature
*
* Revision 1.28 2006/01/05 16:28:24 alexandre_tb
* prise en chage des checkbox, reste la mise à jour à gérer
*
* Revision 1.27 2006/01/04 15:30:56 alexandre_tb
* mise en forme du code
*
* Revision 1.26 2006/01/03 10:19:31 florian
* Mise à jour pour accepter des parametres dans papyrus: faire apparaitre ou non le menu, afficher qu'un type de fiches, définir l'action par défaut...
*
* Revision 1.25 2005/12/20 14:49:35 ddelon
* Fusion Head vers Livraison
*
* Revision 1.24 2005/12/16 15:44:40 alexandre_tb
* ajout de l'option restreindre dépôt
*
* Revision 1.23 2005/12/01 17:03:34 florian
* changement des chemins pour appli Pear
*
* Revision 1.22 2005/12/01 16:05:41 florian
* changement des chemins pour appli Pear
*
* Revision 1.21 2005/12/01 15:31:30 florian
* correction bug modifs et saisies
*
* Revision 1.20 2005/11/30 13:58:45 florian
* ajouts graphisme (logos, boutons), changement structure SQL bazar_fiche
*
* Revision 1.19 2005/11/24 16:17:13 florian
* corrections bugs, ajout des cases à cocher
*
* Revision 1.18 2005/11/18 16:03:23 florian
* correction bug html entites
*
* Revision 1.17 2005/11/17 18:48:02 florian
* corrections bugs + amélioration de l'application d'inscription
*
* Revision 1.16 2005/11/07 17:30:36 florian
* ajout controle sur les listes pour la saisie
*
* Revision 1.15 2005/11/07 17:05:45 florian
* amélioration validation conditions de saisie, ajout des règles spécifiques de saisie des formulaires
*
* Revision 1.14 2005/11/07 08:48:02 florian
* correction pb guillemets pour saisie et modif de fiche
*
* Revision 1.13 2005/10/21 16:15:04 florian
* mise a jour appropriation
*
* Revision 1.11 2005/10/12 17:20:33 ddelon
* Reorganisation calendrier + applette
*
* Revision 1.10 2005/10/12 15:14:06 florian
* amélioration de l'interface de bazar, de manière a simplifier les consultations, et à harmoniser par rapport aux Ressources
*
* Revision 1.9 2005/10/10 16:22:52 alexandre_tb
* Correction de bug. Lorsqu'on revient en arrière après avoir validé un formulaire.
*
* Revision 1.8 2005/09/30 13:50:07 alexandre_tb
* correction bug date parution ressource
*
* Revision 1.7 2005/09/30 13:15:58 ddelon
* compatibilité php5
*
* Revision 1.6 2005/09/30 13:00:05 ddelon
* Fiche bazar generique
*
* Revision 1.5 2005/09/30 12:22:54 florian
* Ajouts commentaires pour fiche, modifications graphiques, maj SQL
*
* Revision 1.3 2005/07/21 19:03:12 florian
* nouveautés bazar: templates fiches, correction de bugs, ...
*
* Revision 1.1.1.1 2005/02/17 18:05:11 florian
* Import initial de Bazar
*
* Revision 1.1.1.1 2005/02/17 11:09:50 florian
* Import initial
*
* Revision 1.1.1.1 2005/02/16 18:06:35 florian
* import de la nouvelle version
*
* Revision 1.10 2004/07/08 17:25:25 florian
* ajout commentaires + petits debuggages
*
* Revision 1.8 2004/07/07 14:30:19 florian
* débogage RSS
*
* Revision 1.7 2004/07/06 16:22:01 florian
* débogage modification + MAJ flux RSS
*
* Revision 1.6 2004/07/06 09:28:26 florian
* changement interface de modification
*
* Revision 1.5 2004/07/05 15:10:23 florian
* changement interface de saisie
*
* Revision 1.4 2004/07/02 14:51:14 florian
* ajouts divers pour faire fonctionner l'insertion de fiches
*
* Revision 1.3 2004/07/01 16:37:42 florian
* ajout de fonctions pour les templates
*
* Revision 1.2 2004/07/01 13:00:13 florian
* modif Florian
*
* Revision 1.1 2004/06/23 09:58:32 alex
* version initiale
*
* Revision 1.1 2004/06/18 09:00:37 alex
* version initiale
*
*
* +-- Fin du code ----------------------------------------------------------------------------------------+
*/
 
?>
/tags/v3.1-blanche-neige/bibliotheque/bazar.fonct.formulaire.php
New file
0,0 → 1,566
<?php
/*vim: set expandtab tabstop=4 shiftwidth=4: */
// +------------------------------------------------------------------------------------------------------+
// | PHP version 4.1 |
// +------------------------------------------------------------------------------------------------------+
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org) |
// +------------------------------------------------------------------------------------------------------+
// | This library is free software; you can redistribute it and/or |
// | modify it under the terms of the GNU Lesser General Public |
// | License as published by the Free Software Foundation; either |
// | version 2.1 of the License, or (at your option) any later version. |
// | |
// | This library is distributed in the hope that it will be useful, |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
// | Lesser General Public License for more details. |
// | |
// | You should have received a copy of the GNU Lesser General Public |
// | License along with this library; if not, write to the Free Software |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
// +------------------------------------------------------------------------------------------------------+
// CVS : $Id: bazar.fonct.formulaire.php,v 1.26 2007-06-04 15:24:31 alexandre_tb Exp $
/**
* Formulaire
*
* Les fonctions de mise en page des formulaire
*
*@package bazar
//Auteur original :
*@author Florian SCHMITT <florian@ecole-et-nature.org>
//Autres auteurs :
*@author Aleandre GRANIER <alexandre@tela-botanica.org>
*@copyright Tela-Botanica 2000-2004
*@version $Revision: 1.26 $ $Date: 2007-06-04 15:24:31 $
// +------------------------------------------------------------------------------------------------------+
*/
 
require_once 'bazar.fonct.formulaire.controles.php';
 
//-------------------FONCTIONS DE MISE EN PAGE DES FORMULAIRES
 
/** liste() - Ajoute un élément de type liste au formulaire
*
* @param mixed L'objet QuickForm du formulaire
* @param int identifiant de la liste sur bazar_liste
* @param string label à afficher dans le formulaire
* @param string première restriction de la taille des champs du formulaire
* @param string deuxième restriction de la taille des champs du formulaire
* @param string valeur par défaut du formulaire
* @param string table source pour les valeurs de la liste
* @param string ce champs est il obligatoire? (required)
* @param boolean sommes nous dans le moteur de recherche?
* @return void
*/
function liste(&$formtemplate, $id_liste , $label, $limite1, $limite2, $defaut, $source, $obligatoire, $dans_moteur_de_recherche=0) {
$requete = 'SELECT * FROM bazar_liste_valeurs WHERE blv_ce_liste='.$id_liste.' AND blv_ce_i18n="'.$GLOBALS['_BAZAR_']['langue'].'"';
$resultat = & $GLOBALS['_BAZAR_']['db'] -> query($requete) ;
if (DB::isError ($resultat)) {
die ($resultat->getMessage().$resultat->getDebugInfo()) ;
}
if ($dans_moteur_de_recherche==0) {
$select[0]=BAZ_CHOISIR;
}
else {
$select[0]=BAZ_INDIFFERENT;
}
while ($ligne = $resultat->fetchRow()) {
$select[$ligne[1]] = $ligne[2] ;
}
$option=array('style'=>'width: '.$limite1.'px;', 'id' => 'liste'.$id_liste);
require_once PAP_CHEMIN_API_PEAR.'HTML/QuickForm/select.php';
$select= new HTML_QuickForm_select('liste'.$id_liste, $label, $select, $option);
$select->setSize($limite2);
$select->setMultiple(0);
$select->setSelected($defaut);
$formtemplate->addElement($select) ;
if (($dans_moteur_de_recherche==0) && isset($obligatoire) && ($obligatoire==1)) {
$formtemplate->addRule('liste'.$id_liste, BAZ_CHOISIR_OBLIGATOIRE.' '.$label , 'nonzero', '', 'client') ;
$formtemplate->addRule('liste'.$id_liste, $label.' obligatoire', 'required', '', 'client') ;}
}
 
 
/** checkbox() - Ajoute un élément de type checkbox au formulaire
*
* @param mixed L'objet QuickForm du formulaire
* @param int identifiant de la liste sur bazar_liste
* @param string label à afficher dans le formulaire
* @param string première restriction de la taille des champs du formulaire
* @param string deuxième restriction de la taille des champs du formulaire
* @param string valeur par défaut du formulaire
* @param string table source pour les valeurs de la liste
* @param string ce champs est il obligatoire? (required)
* @return void
*/
function checkbox(&$formtemplate, $id_liste , $label, $limite1, $limite2, $defaut, $source, $obligatoire, $dans_moteur_de_recherche=0) {
$requete = 'SELECT * FROM bazar_liste_valeurs WHERE blv_ce_liste='.$id_liste.' AND blv_ce_i18n="'.$GLOBALS['_BAZAR_']['langue'].'" ORDER BY blv_label';
$resultat = & $GLOBALS['_BAZAR_']['db'] -> query($requete) ;
if (DB::isError ($resultat)) {
die ($resultat->getMessage().$resultat->getDebugInfo()) ;
}
require_once PAP_CHEMIN_API_PEAR.'HTML/QuickForm/checkbox.php' ;
$i=0;
if (isset($defaut)) $tab=split(', ', $defaut);
while ($ligne = $resultat->fetchRow()) {
if ($i==0) $labelchkbox=$label ; else $labelchkbox='&nbsp;';
$checkbox[$i]= & HTML_Quickform::createElement('checkbox', $ligne[1], $labelchkbox, $ligne[2],
array ('style'=>'display:inline;margin:2px;')) ;
foreach ($tab as $val) {
if ($ligne[1]==$val) $checkbox[$i]->setChecked(1);
}
$i++;
}
$squelette_checkbox =& $formtemplate->defaultRenderer();
$squelette_checkbox->setElementTemplate( '<tr><td colspan="2" style="text-align:left;">'."\n".'<fieldset class="bazar_fieldset">'."\n".'<legend>{label}'.
'<!-- BEGIN required --><span class="symbole_obligatoire">&nbsp;*</span><!-- END required -->'."\n".
'</legend>'."\n".'{element}'."\n".'</fieldset> '."\n".'</td></tr>'."\n", 'checkbox'.$id_liste);
$squelette_checkbox->setGroupElementTemplate( "\n".'<div class="bazar_checkbox">'."\n".'{element}'."\n".'</div>'."\n", 'checkbox'.$id_liste);
$formtemplate->addGroup($checkbox, 'checkbox'.$id_liste, $label, "\n");
if (($dans_moteur_de_recherche==0) && isset($obligatoire) && ($obligatoire==1)) {
$formtemplate->addGroupRule('checkbox'.$id_liste, $label.' obligatoire', 'required', null, 1, 'client');
}
}
 
 
/** listedatedeb() - Ajoute un élément de type date sous forme de liste au formulaire pour designer une date de début
*
* @param mixed L'objet QuickForm du formulaire
* @param string nom de la table dans la base de donnée
* @param string label à afficher dans le formulaire
* @param string première restriction de la taille des champs du formulaire
* @param string deuxième restriction de la taille des champs du formulaire
* @param string valeur par défaut du formulaire
* @param string table source pour les valeurs de la date
* @param string ce champs est il obligatoire? (required)
* @return void
*/
function listedatedeb(&$formtemplate, $nom_bdd , $label, $limite1, $limite2, $defaut, $source, $obligatoire, $dans_moteur_de_recherche=0) {
$optiondate = array('language' => BAZ_LANGUE_PAR_DEFAUT,
'minYear' => date('Y')-4,
'maxYear'=> (date('Y')+10),
'format' => 'd m Y',
'addEmptyOption' => BAZ_DATE_VIDE,
);
$formtemplate->addElement('date', $nom_bdd, $label, $optiondate) ;
//gestion des valeurs par défaut (date du jour)
if (isset($defaut) && $defaut!='') {
$tableau_date = explode ('-', $defaut);
$formtemplate->setDefaults(array($nom_bdd => array ('d'=> $tableau_date[2], 'm'=> $tableau_date[1], 'Y'=> $tableau_date[0])));
}
else {
$defauts=array($nom_bdd => array ('d'=>date('d'), 'm'=>date('m'), 'Y'=>date('Y')));
$formtemplate->setDefaults($defauts);
}
//gestion du champs obligatoire
if (($dans_moteur_de_recherche==0) && isset($obligatoire) && ($obligatoire==1)) {
$formtemplate->addRule($nom_bdd, $label.' obligatoire', 'required', '', 'client') ;
}
}
 
/** listedatefin() - Ajoute un élément de type date sous forme de liste au formulaire pour designer une date de fin
*
* @param mixed L'objet QuickForm du formulaire
* @param string nom de la table dans la base de donnée
* @param string label à afficher dans le formulaire
* @param string première restriction de la taille des champs du formulaire
* @param string deuxième restriction de la taille des champs du formulaire
* @param string valeur par défaut du formulaire
* @param string table source pour les valeurs de la date
* @param string ce champs est il obligatoire? (required)
* @return void
*/
function listedatefin(&$formtemplate, $nom_bdd , $label, $limite1, $limite2, $defaut, $source, $obligatoire, $dans_moteur_de_recherche=0) {
listedatedeb($formtemplate, $nom_bdd , $label, $limite1, $limite2, $defaut, $source, $obligatoire, $dans_moteur_de_recherche);
}
 
 
/** texte() - Ajoute un élément de type texte au formulaire
*
* @param mixed L'objet QuickForm du formulaire
* @param string nom de la table dans la base de donnée
* @param string label à afficher dans le formulaire
* @param string première restriction de la taille des champs du formulaire
* @param string deuxième restriction de la taille des champs du formulaire
* @param string valeur par défaut du formulaire
* @param string table source pour les valeurs du texte (inutile)
* @param string ce champs est il obligatoire? (required)
* @return void
*/
function texte(&$formtemplate, $nom_bdd , $label, $limite1, $limite2, $defaut, $source, $obligatoire, $dans_moteur_de_recherche=0) {
$option=array('size'=>$limite1,'maxlength'=>$limite2, 'id' => $nom_bdd);
$formtemplate->addElement('text', $nom_bdd, $label, $option) ;
//gestion des valeurs par défaut
$defauts=array($nom_bdd=>$defaut);
$formtemplate->setDefaults($defauts);
$formtemplate->applyFilter($nom_bdd, 'addslashes') ;
//gestion du champs obligatoire
if (($dans_moteur_de_recherche==0) && isset($obligatoire) && ($obligatoire==1)) {
$formtemplate->addRule($nom_bdd, $label.' obligatoire', 'required', '', 'client') ;
}
}
 
 
/** textelong() - Ajoute un élément de type textearea au formulaire
*
* @param mixed L'objet QuickForm du formulaire
* @param string nom de la table dans la base de donnée
* @param string label à afficher dans le formulaire
* @param string taille des colonnes de l'élément
* @param string taille des lignes de l'élément
* @param string valeur par défaut du formulaire
* @param string table source pour les valeurs du texte (inutile)
* @param string ce champs est il obligatoire? (required)
* @return void
*/
function textelong(&$formtemplate, $nom_bdd , $label, $limite1, $limite2, $defaut, $source, $obligatoire, $dans_moteur_de_recherche=0) {
$formtexte= new HTML_QuickForm_textarea($nom_bdd, $label, array('style'=>'white-space: normal;', 'id' => $nom_bdd));
$formtexte->setCols($limite1);
$formtexte->setRows($limite2);
$formtemplate->addElement($formtexte) ;
//gestion des valeurs par défaut
$defauts=array($nom_bdd=>$defaut);
$formtemplate->setDefaults($defauts);
$formtemplate->applyFilter($nom_bdd, 'addslashes') ;
//gestion du champs obligatoire
if (($dans_moteur_de_recherche==0) && isset($obligatoire) && ($obligatoire==1)) {
$formtemplate->addRule($nom_bdd, $label.' obligatoire', 'required', '', 'client') ;
}
}
 
/** url() - Ajoute un élément de type url internet au formulaire
*
* @param mixed L'objet QuickForm du formulaire
* @param string numero du champs input du formulaire (pour le différencier d'autres champs du meme type dans ce formulaire)
* @param string label à afficher dans le formulaire
* @param string taille des colonnes de l'élément
* @param string taille des lignes de l'élément
* @param string valeur par défaut du formulaire
* @param string table source pour les valeurs du texte (inutile)
* @param string ce champs est il obligatoire? (required)
* @return void
*/
function url(&$formtemplate, $nom_bdd , $label, $limite1, $limite2, $defaut, $source, $obligatoire, $dans_moteur_de_recherche=0) {
//recherche des URLs deja entrees dans la base
$html_url= '';
if (isset($GLOBALS['_BAZAR_']["id_fiche"])) {
$requete = 'SELECT bu_id_url, bu_url, bu_descriptif_url FROM bazar_url WHERE bu_ce_fiche='.$GLOBALS['_BAZAR_']["id_fiche"];
$resultat = & $GLOBALS['_BAZAR_']['db'] -> query($requete) ;
if (DB::isError ($resultat)) {
die ($GLOBALS['_BAZAR_']['db']->getMessage().$GLOBALS['_BAZAR_']['db']->getDebugInfo()) ;
}
if ($resultat->numRows()>0) {
$html_url= '<tr>'."\n".'<td colspan="2">'."\n".'<strong>'.BAZ_LISTE_URL.'</strong>'."\n";
$tableAttr = array("class" => "bazar_table") ;
$table = new HTML_Table($tableAttr) ;
$entete = array (BAZ_LIEN , BAZ_SUPPRIMER) ;
$table->addRow($entete) ;
$table->setRowType(0, "th") ;
$lien_supprimer=$GLOBALS['_BAZAR_']['url'];
$lien_supprimer->addQueryString('action', $_GET['action']);
$lien_supprimer->addQueryString('id_fiche', $GLOBALS['_BAZAR_']["id_fiche"]);
$lien_supprimer->addQueryString('typeannonce', $_REQUEST['typeannonce']);
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_OBJECT)) {
$lien_supprimer->addQueryString('id_url', $ligne->bu_id_url);
$table->addRow (array(
'<a href="'.$ligne->bu_url.'" target="_blank"> '.$ligne->bu_descriptif_url.'</a>', // col 1 : le lien
'<a href="'.$lien_supprimer->getURL().'" onclick="javascript:return confirm(\''.BAZ_CONFIRMATION_SUPPRESSION_LIEN.'\');" >'.BAZ_SUPPRIMER.'</a>'."\n")) ; // col 2 : supprimer
$lien_supprimer->removeQueryString('id_url');
}
 
// Nettoyage de l'url
$lien_supprimer->removeQueryString('action');
$lien_supprimer->removeQueryString('id_fiche');
$lien_supprimer->removeQueryString('typeannonce');
$table->altRowAttributes(1, array("class" => "ligne_impaire"), array("class" => "ligne_paire"));
$table->updateColAttributes(1, array("align" => "center"));
$html_url.= $table->toHTML()."\n".'</td>'."\n".'</tr>'."\n" ;
}
}
$html ='<tr>'."\n".'<td colspan="2">'."\n".'<h4>'.$label.'</h4>'."\n".'</td>'."\n".'</tr>'."\n";
$formtemplate->addElement('html', $html) ;
if ($html_url!='') $formtemplate->addElement('html', $html_url) ;
$formtemplate->addElement('text', 'url_lien'.$nom_bdd, BAZ_URL_LIEN) ;
$formtemplate->addElement('text', 'url_texte'.$nom_bdd, BAZ_URL_TEXTE) ;
//gestion du champs obligatoire
if (($dans_moteur_de_recherche==0) && isset($obligatoire) && ($obligatoire==1)) {
$formtemplate->addRule('url_lien'.$nom_bdd, BAZ_URL_LIEN_REQUIS, 'required', '', 'client') ;
$formtemplate->addRule('url_texte'.$nom_bdd, BAZ_URL_TEXTE_REQUIS, 'required', '', 'client') ;
}
}
 
/** fichier() - Ajoute un élément de type fichier au formulaire
*
* @param mixed L'objet QuickForm du formulaire
* @param string numero du champs input du formulaire (pour le différencier d'autres champs du meme type dans ce formulaire)
* @param string label à afficher dans le formulaire
* @param string taille des colonnes de l'élément
* @param string taille des lignes de l'élément
* @param string valeur par défaut du formulaire
* @param string table source pour les valeurs du texte (inutile)
* @param string ce champs est il obligatoire? (required)
* @return void
*/
function fichier(&$formtemplate, $nom_bdd , $label, $limite1, $limite2, $defaut, $source, $obligatoire, $dans_moteur_de_recherche=0) {
//AJOUTER DES FICHIERS JOINTS
$html_fichier= '';
if (isset($GLOBALS['_BAZAR_']["id_fiche"])) {
$requete = 'SELECT * FROM bazar_fichier_joint WHERE bfj_ce_fiche='.$GLOBALS['_BAZAR_']["id_fiche"];
$resultat = & $GLOBALS['_BAZAR_']['db'] -> query($requete) ;
if (DB::isError ($resultat)) {
die ($GLOBALS['_BAZAR_']['db']->getMessage().$GLOBALS['_BAZAR_']['db']->getDebugInfo()) ;
}
if ($resultat->numRows()>0) {
$html_fichier = '<tr>'."\n".'<td colspan="2">'."\n".'<strong>'.BAZ_LISTE_FICHIERS_JOINTS.'</strong>'."\n";
$tableAttr = array("class" => "bazar_table") ;
$table = new HTML_Table($tableAttr) ;
$entete = array (BAZ_FICHIER , BAZ_SUPPRIMER) ;
$table->addRow($entete) ;
$table->setRowType(0, "th") ;
$lien_supprimer=$GLOBALS['_BAZAR_']['url'];
$lien_supprimer->addQueryString('action', $_GET['action']);
$lien_supprimer->addQueryString('id_fiche', $GLOBALS['_BAZAR_']["id_fiche"]);
$lien_supprimer->addQueryString('typeannonce', $_REQUEST['typeannonce']);
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_OBJECT)) {
$lien_supprimer->addQueryString('id_fichier', $ligne->bfj_id_fichier);
$table->addRow(array('<a href="client/bazar/upload/'.$ligne->bfj_fichier.'"> '.$ligne->bfj_description.'</a>', // col 1 : le fichier et sa description
'<a href="'.$lien_supprimer->getURL().'" onclick="javascript:return confirm(\''.BAZ_CONFIRMATION_SUPPRESSION_FICHIER.'\');" >'.BAZ_SUPPRIMER.'</a>'."\n")) ; // col 2 : supprimer
$lien_supprimer->removeQueryString('id_fichier');
}
$table->altRowAttributes(1, array("class" => "ligne_impaire"), array("class" => "ligne_paire"));
$table->updateColAttributes(1, array("align" => "center"));
$html_fichier .= $table->toHTML()."\n".'</td>'."\n".'</tr>'."\n" ;
}
}
$html ='<tr>'."\n".'<td colspan="2">'."\n".'<h4>'.$label.'</h4>'."\n".'</td>'."\n".'</tr>'."\n";
$formtemplate->addElement('html', $html) ;
if ($html_fichier!='') $formtemplate->addElement('html', $html_fichier) ;
$formtemplate->addElement('text', 'texte_fichier'.$nom_bdd, BAZ_FICHIER_DESCRIPTION) ;
$formtemplate->addElement('file', 'fichier'.$nom_bdd, BAZ_FICHIER_JOINT) ;
$formtemplate->addRule('image', BAZ_IMAGE_VALIDE_REQUIS, '', '', 'client') ; //a completer pour checker l'image
$formtemplate->setMaxFileSize($limite1);
//gestion du champs obligatoire
if (($dans_moteur_de_recherche==0) && isset($obligatoire) && ($obligatoire==1)) {
$formtemplate->addRule('texte_fichier'.$nom_bdd, BAZ_FICHIER_LABEL_REQUIS, 'required', '', 'client') ;
$formtemplate->addRule('fichier'.$nom_bdd, BAZ_FICHIER_JOINT_REQUIS, 'required', '', 'client') ;
}
}
 
/** image() - Ajoute un élément de type image au formulaire
*
* @param mixed L'objet QuickForm du formulaire
* @param string numero du champs input du formulaire (pour le différencier d'autres champs du meme type dans ce formulaire)
* @param string label à afficher dans le formulaire
* @param string taille maximum du fichier colonnes de l'élément
* @param string taille des lignes de l'élément
* @param string valeur par défaut du formulaire
* @param string table source pour les valeurs du texte (inutile)
* @param string ce champs est il obligatoire? (required)
* @return void
*/
function image(&$formtemplate, $nom_bdd , $label, $limite1, $limite2, $defaut, $source, $obligatoire, $dans_moteur_de_recherche=0) {
//AJOUTER UNE IMAGE
$html_image= '';
if (isset($GLOBALS['_BAZAR_']["id_fiche"])) {
$requete = 'SELECT bf_url_image FROM bazar_fiche WHERE bf_id_fiche='.$GLOBALS['_BAZAR_']['id_fiche'];
$resultat = & $GLOBALS['_BAZAR_']['db'] -> query($requete) ;
if (DB::isError ($resultat)) {
die ($GLOBALS['_BAZAR_']['db']->getMessage().$GLOBALS['_BAZAR_']['db']->getDebugInfo()) ;
}
if ($resultat->numRows()>0) {
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_OBJECT)) {
$image=$ligne->bf_url_image;
}
if ($image!=NULL) {
$lien_supprimer=$GLOBALS['_BAZAR_']['url'];
$lien_supprimer->addQueryString('action', $_GET['action']);
$lien_supprimer->addQueryString('id_fiche', $GLOBALS['_BAZAR_']["id_fiche"]);
$lien_supprimer->addQueryString('typeannonce', $_REQUEST['typeannonce']);
$lien_supprimer->addQueryString('image', 1);
$html_image = '<tr>'."\n".
'<td>'."\n".'<img src="client/bazar/upload/'.$image.'" alt="'.BAZ_TEXTE_IMG_ALTERNATIF.'" width="130" height="130" />'."\n".'</td>'."\n".
'<td>'."\n".'<a href="'.$lien_supprimer->getURL().'" onclick="javascript:return confirm(\''.BAZ_CONFIRMATION_SUPPRESSION_IMAGE.'\');" >'.BAZ_SUPPRIMER.'</a><br /><br />'."\n".
'<strong>'.BAZ_POUR_CHANGER_IMAGE.'</strong><br />'."\n".'</td>'."\n".'</tr>'."\n";
}
}
}
$html ='<tr>'."\n".'<td colspan="2">'."\n".'<h4>'.$label.'</h4>'."\n".'</td>'."\n".'</tr>'."\n";
$formtemplate->addElement('html', $html) ;
if ($html_image!='') $formtemplate->addElement('html', $html_image) ;
$formtemplate->addElement('file', 'image', BAZ_IMAGE) ;
//TODO: controler si c'est une image
$formtemplate->setMaxFileSize($limite1);
//gestion du champs obligatoire
if (($dans_moteur_de_recherche==0) && isset($obligatoire) && ($obligatoire==1)) {
$formtemplate->addRule('image', BAZ_IMAGE_VALIDE_REQUIS, 'required', '', 'client') ;
}
}
 
/** wikini() - Ajoute un wikini au formulaire
*
* @param mixed L'objet QuickForm du formulaire
* @param string numero du champs input du formulaire (pour le différencier d'autres champs du meme type dans ce formulaire)
* @param string label à afficher dans le formulaire
* @param string taille maximum du fichier colonnes de l'élément
* @param string taille des lignes de l'élément
* @param string valeur par défaut du formulaire
* @param string table source pour les valeurs du texte (inutile)
* @param string ce champs est il obligatoire? (required)
* @return void
*/
function wikini(&$formtemplate, $nom_bdd , $label, $limite1, $limite2, $defaut, $source, $obligatoire, $dans_moteur_de_recherche=0) {
return;
}
 
/** labelhtml() - Ajoute un élément de type textearea au formulaire
*
* @param mixed L'objet QuickForm du formulaire
* @param string nom de la table dans la base de donnée (pas utilisé)
* @param string label à afficher dans le formulaire
* @param string taille des colonnes de l'élément (pas utilisé)
* @param string taille des lignes de l'élément (pas utilisé)
* @param string valeur par défaut du formulaire (pas utilisé)
* @param string table source pour les valeurs du texte (pas utilisé)
* @param string ce champs est il obligatoire? (required) (pas utilisé)
* @return void
*/
function labelhtml(&$formtemplate, $nom_bdd , $label, $limite1, $limite2, $defaut, $source, $obligatoire, $dans_moteur_de_recherche=0) {
require_once PAP_CHEMIN_API_PEAR.'HTML/QuickForm/html.php';
$formhtml= new HTML_QuickForm_html('<tr>'."\n".'<td colspan="2" style="text-align:left;">'."\n".$label."\n".'</td>'."\n".'</tr>'."\n");
$formtemplate->addElement($formhtml) ;
}
 
/** carte_google() - Ajoute un élément de carte google au formulaire
*
* @param mixed L'objet QuickForm du formulaire
* @param string l url vers la script google
* @param string label à afficher dans le formulaire
* @param string première restriction de la taille des champs du formulaire
* @param string deuxième restriction de la taille des champs du formulaire
* @param string valeur par défaut du formulaire
* @param string table source pour les valeurs de la liste
* @param string ce champs est il obligatoire? (required)
* @param boolean sommes nous dans le moteur de recherche?
* @return void
*/
function carte_google(&$formtemplate, $url_google_script , $label, $limite1, $limite2, $defaut, $source, $obligatoire, $dans_moteur_de_recherche=0) {
if (is_array ($defaut)) {
$formtemplate->setDefaults(array('latitude' => $defaut['latitude'], 'longitude' => $defaut['longitude']));
}
GEN_stockerFichierScript('googleMapScript', $url_google_script);
$formtemplate->addElement('button', 'chercher_sur_carte', 'Vérifier mon adresse avec la carte', array("onclick" => "showAddress();"));
$formtemplate->addElement('text', 'latitude', 'Latitude', array('id' => 'latitude', 'size' => 6, 'readonly' => 'readonly'));
$formtemplate->addElement('text', 'longitude', 'longitude', array('id' => 'longitude', 'size' => 6, 'readonly' => 'readonly'));
$formtemplate->addElement('html', '<tr><td colspan="2" ><div id="map" style="width: 600px; height: 450px"></div></td></tr>');
include_once BAZ_CHEMIN_APPLI.'bibliotheque/bazar.fonct.google.php';
GEN_stockerCodeScript($script);
}
 
/* +--Fin du code ----------------------------------------------------------------------------------------+
*
* $Log: bazar.fonct.formulaire.php,v $
* Revision 1.26 2007-06-04 15:24:31 alexandre_tb
* ajout du type carte_google
*
* Revision 1.25 2007/04/11 08:30:12 neiluj
* remise en état du CVS...
*
* Revision 1.22.2.3 2007/03/16 14:48:32 alexandre_tb
* on peut maintenant saisir une date par défaut
* et 0000-00-00 pour des champs vide
*
* Revision 1.22.2.2 2007/03/07 17:20:19 jp_milcent
* Ajout du nettoyage systématique des URLs.
*
* Revision 1.22.2.1 2007/01/17 16:01:37 alexandre_tb
* les dates ne s'affichent pas si elles sont vides.
* les champs dates propose 4 années avant l'année actuelle
*
* Revision 1.22 2006/06/02 09:29:07 florian
* debut d'integration de wikini
*
* Revision 1.21 2006/05/19 13:54:11 florian
* stabilisation du moteur de recherche, corrections bugs, lien recherche avancee
*
* Revision 1.20 2006/04/28 12:46:14 florian
* integration des liens vers annuaire
*
* Revision 1.19 2006/03/02 20:36:52 florian
* les entrees du formulaire de saisir ne sont plus dans les constantes mias dans des tables qui gerent le multilinguisme.
*
* Revision 1.18 2006/03/01 16:01:46 florian
* correction bug déclaration variable $html
*
* Revision 1.17 2006/01/30 10:27:03 florian
* - ajout des entrées de formulaire fichier, url, et image
* - correction bug d'affichage du mode de saisie
*
* Revision 1.16 2006/01/24 14:11:44 alexandre_tb
* ajout du paramètre emptyOptionValue dans les champs de date
*
* Revision 1.15 2006/01/23 16:57:03 alexandre_tb
* correction d'un notice
*
* Revision 1.14 2006/01/19 17:42:11 florian
* ajout des cases à cocher pré-cochées pour les maj
*
* Revision 1.13 2006/01/13 14:12:51 florian
* utilisation des temlates dans la table bazar_nature
*
* Revision 1.12 2006/01/05 16:28:24 alexandre_tb
* prise en chage des checkbox, reste la mise à jour à gérer
*
* Revision 1.11 2006/01/02 13:24:07 alexandre_tb
* correction de bug d'un mauvais retour en erreur
*
* Revision 1.10 2005/12/01 16:05:41 florian
* changement des chemins pour appli Pear
*
* Revision 1.9 2005/11/24 16:17:13 florian
* corrections bugs, ajout des cases à cocher
*
* Revision 1.8 2005/11/18 16:03:23 florian
* correction bug html entites
*
* Revision 1.7 2005/11/07 17:51:06 florian
* correction bug liste
*
* Revision 1.6 2005/11/07 17:30:36 florian
* ajout controle sur les listes pour la saisie
*
* Revision 1.5 2005/11/07 17:05:45 florian
* amélioration validation conditions de saisie, ajout des règles spécifiques de saisie des formulaires
*
* Revision 1.4 2005/10/25 13:53:02 alexandre_tb
* ajout d'un filtre dans les formulaire texte et textelong
*
* Revision 1.3 2005/07/21 19:03:12 florian
* nouveautés bazar: templates fiches, correction de bugs, ...
*
* Revision 1.1.1.1 2005/02/17 18:05:11 florian
* Import initial de Bazar
*
* Revision 1.1.1.1 2005/02/17 11:09:50 florian
* Import initial
*
* Revision 1.1.1.1 2005/02/16 18:06:35 florian
* import de la nouvelle version
*
* Revision 1.4 2004/07/08 11:17:59 alex
* ajout de commentaires et d'entete
*
*
* +-- Fin du code ----------------------------------------------------------------------------------------+
*/
?>
/tags/v3.1-blanche-neige/bibliotheque/bazar.abonnement.inc.php
New file
0,0 → 1,71
<?php
/*vim: set expandtab tabstop=4 shiftwidth=4: */
// +------------------------------------------------------------------------------------------------------+
// | PHP version 4.1 |
// +------------------------------------------------------------------------------------------------------+
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org) |
// +------------------------------------------------------------------------------------------------------+
// | This library is free software; you can redistribute it and/or |
// | modify it under the terms of the GNU Lesser General Public |
// | License as published by the Free Software Foundation; either |
// | version 2.1 of the License, or (at your option) any later version. |
// | |
// | This library is distributed in the hope that it will be useful, |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
// | Lesser General Public License for more details. |
// | |
// | You should have received a copy of the GNU Lesser General Public |
// | License along with this library; if not, write to the Free Software |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
// +------------------------------------------------------------------------------------------------------+
// CVS : $Id$
/**
* Fonctions d'abonnement a afficher dans la fiche du bottin
*
*
*@package inscription
//Auteur original :
*@author Florian Schmitt <florian@ecole-et-nature.org>
//Autres auteurs :
*
*@copyright Outils-Reseaux 2006-2010
*@version $Revision$ $Date$
*@version $Revision$ $Date$
// +------------------------------------------------------------------------------------------------------+
*/
 
// +------------------------------------------------------------------------------------------------------+
// | ENTETE du PROGRAMME |
// +------------------------------------------------------------------------------------------------------+
 
include_once PAP_CHEMIN_RACINE.'client/bazar/configuration/baz_config.inc.php' ;
include_once PAP_CHEMIN_RACINE.'client/bazar/bibliotheque/bazar.fonct.php' ;
 
// +------------------------------------------------------------------------------------------------------+
// | LISTE de FONCTIONS |
// +------------------------------------------------------------------------------------------------------+
$GLOBALS['id_user']=$id;
if (isset($_GET[BAZ_VARIABLE_ACTION]) && $_GET[BAZ_VARIABLE_ACTION]==BAZ_VOIR_FLUX_RSS) {
header('Content-type: text/xml; charset=ISO-8859-1');
include(PAP_CHEMIN_RACINE.'client/bazar/bazarRSS.php');exit(0);break;
} else {
$abonnement = baz_s_inscrire();
}
 
//-- Fin du code source ------------------------------------------------------------
/*
* $Log$
* Revision 1.3 2008-09-17 14:08:45 alexandre_tb
* merge depuis aha
*
* Revision 1.2 2006-10-05 08:53:50 florian
* amelioration moteur de recherche, correction de bugs
*
* Revision 1.1 2006/04/28 12:46:14 florian
* integration des liens vers annuaire
*
*
*/
?>
/tags/v3.1-blanche-neige/bibliotheque/bazar.fonct.rss.php
New file
0,0 → 1,1723
<?php
/*vim: set expandtab tabstop=4 shiftwidth=4: */
// +------------------------------------------------------------------------------------------------------+
// | PHP version 4.1 |
// +------------------------------------------------------------------------------------------------------+
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org) |
// +------------------------------------------------------------------------------------------------------+
// | This library is free software; you can redistribute it and/or |
// | modify it under the terms of the GNU Lesser General Public |
// | License as published by the Free Software Foundation; either |
// | version 2.1 of the License, or (at your option) any later version. |
// | |
// | This library is distributed in the hope that it will be useful, |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
// | Lesser General Public License for more details. |
// | |
// | You should have received a copy of the GNU Lesser General Public |
// | License along with this library; if not, write to the Free Software |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
// +------------------------------------------------------------------------------------------------------+
// CVS : $Id: bazar.fonct.rss.php,v 1.99.2.14 2008-11-19 09:30:18 aperonnet Exp $
/**
*
*@package bazar
//Auteur original :
*@author Alexandre GRANIER <alexandre@tela-botanica.org>
*@author Florian Schmitt <florian@ecole-et-nature.org>
//Autres auteurs :
*@copyright Tela-Botanica 2000-2006
*@version $Revision: 1.99.2.14 $
// +------------------------------------------------------------------------------------------------------+
*/
 
// +------------------------------------------------------------------------------------------------------+
// | ENTETE du PROGRAMME |
// +------------------------------------------------------------------------------------------------------+
 
require_once BAZ_CHEMIN_APPLI.'bibliotheque/bazar.class.php';
require_once BAZ_CHEMIN_APPLI.'bibliotheque/bazar.fonct.php';
 
 
/** baz_valeur_template() - Renvoi des valeurs inscrite dans le fichier de template
*
* @param string valeur du template de bazar_nature
*
* @return mixed tableau contenant les champs du fichier template
*/
function baz_valeurs_template($valeur_template) {
 
//Parcours du fichier de templates, pour mettre les champs specifiques
$tableau= array();
$nblignes=0;
$chaine = explode ("\n", $valeur_template);
//array_pop($chaine);
foreach ($chaine as $ligne) {
$souschaine = explode ("***", $ligne) ;
$tableau[$nblignes]['type'] = trim($souschaine[0]) ;
if (isset($souschaine[1])) {$tableau[$nblignes]['nom_bdd'] = trim($souschaine[1]);}
else {$tableau[$nblignes]['nom_bdd'] ='';}
if (isset($souschaine[2])) $tableau[$nblignes]['label'] = trim($souschaine[2]);
else {$tableau[$nblignes]['label'] ='';}
if (isset($souschaine[3])) $tableau[$nblignes]['limite1'] = trim($souschaine[3]);
else {$tableau[$nblignes]['limite1'] ='';}
if (isset($souschaine[4])) $tableau[$nblignes]['limite2'] = trim($souschaine[4]);
else {$tableau[$nblignes]['limite2'] ='';}
if (isset($souschaine[5])) $tableau[$nblignes]['defaut'] = trim($souschaine[5]);
else {$tableau[$nblignes]['defaut'] ='';}
if (isset($souschaine[6])) $tableau[$nblignes]['table_source'] = trim($souschaine[6]);
else {$tableau[$nblignes]['table_source'] ='';}
if (isset($souschaine[7])) $tableau[$nblignes]['id_source'] = trim($souschaine[7]);
else {$tableau[$nblignes]['id_source'] ='';}
if (isset($souschaine[8])) $tableau[$nblignes]['obligatoire'] = trim($souschaine[8]);
else {$tableau[$nblignes]['obligatoire'] ='';}
if (isset($souschaine[9])) $tableau[$nblignes]['recherche'] = trim($souschaine[9]);
else {$tableau[$nblignes]['recherche'] ='';}
 
 
// traitement des cases à cocher, dans ce cas la, on a une table de jointure entre la table
// de liste et la table bazar_fiche (elle porte un nom du genre bazar_ont_***)
// dans le template, à la place d'un nom de champs dans 'nom_bdd', on a un nom de table
// et 2 noms de champs séparés par un virgule ex : bazar_ont_theme,bot_id_theme,bot_id_fiche
 
if (isset($tableau[$nblignes]['nom_bdd']) && preg_match('/,/', $tableau[$nblignes]['nom_bdd'])) {
$tableau_info_jointe = explode (',', $tableau[$nblignes]['nom_bdd']) ;
$tableau[$nblignes]['table_jointe'] = $tableau_info_jointe[0] ;
$tableau[$nblignes]['champs_id_fiche'] = $tableau_info_jointe[1] ;
$tableau[$nblignes]['champs_id_table_jointe'] = $tableau_info_jointe[2] ;
}
$nblignes++;
}
 
return $tableau;
}
 
/** baz_voir_fiches() - Permet de visualiser en detail une liste de fiche au format XHTML
*
* @global boolean Rajoute des informations internes a l'application (date de modification, lien vers la page de départ de l'appli)
* @global integer Tableau d(Identifiant des fiches a afficher
*
* @return string HTML
*/
function baz_voir_fiches($danslappli, $idfiches=array()) {
 
$res='';
foreach($idfiches as $idfiche) {
$res.=baz_voir_fiche($danslappli, $idfiche);
}
 
return $res;
}
 
 
/** baz_voir_fiche() - Permet de visualiser en detail une fiche au format XHTML
*
* @global boolean Rajoute des informations internes a l'application (date de modification, lien vers la page de depart de l'appli) si a 1
* @global integer Identifiant de la fiche a afficher
*
* @return string HTML
*/
function baz_voir_fiche($danslappli, $idfiche='') {
 
$res='';
if (isset($_GET['id_fiche'])) $GLOBALS['_BAZAR_']['id_fiche'] = $_GET['id_fiche'];
if ($idfiche != '') $GLOBALS['_BAZAR_']['id_fiche'] = $idfiche;
$url = $GLOBALS['_BAZAR_']['url'];
$url->addQueryString(BAZ_VARIABLE_ACTION, BAZ_VOIR_FICHE);
$url->addQueryString('id_fiche', $GLOBALS['_BAZAR_']['id_fiche']);
$url = preg_replace ('/&amp;/', '&', $url->getURL()) ;
 
//cas ou la fiche a ete validee
if (isset($_GET['publiee'])) {
publier_fiche($_GET['publiee']);
}
 
//cas on une structure s'approprie une ressource
if (isset($_GET['appropriation'])) {
if ($_GET['appropriation']==1) {
$requete = 'INSERT INTO bazar_appropriation VALUES ('.$GLOBALS['_BAZAR_']['id_fiche'].', '.$GLOBALS['AUTH']->getAuthData(BAZ_CHAMPS_ID).')';
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
}
elseif ($_GET['appropriation']==0) {
$requete = 'DELETE FROM bazar_appropriation WHERE ba_ce_id_fiche='.$GLOBALS['_BAZAR_']['id_fiche'].' AND ba_ce_id_structure='.$GLOBALS['AUTH']->getAuthData(BAZ_CHAMPS_ID);
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
}
}
 
//cas ou un commentaire a ete entre
if (isset($_POST['Nom'])) {
$requete = 'INSERT INTO bazar_commentaires VALUES ('.
baz_nextid('bazar_commentaires', 'bc_id_commentaire', $GLOBALS['_BAZAR_']['db']).
', '.$GLOBALS['_BAZAR_']['id_fiche'].', "'.$_POST['Nom'].'", "'.$_POST['Commentaire'].
'", NOW() )';
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
}
//cas ou un commentaire va etre supprime
elseif (isset($_GET['id_commentaire'])) {
$requete = 'DELETE FROM bazar_commentaires WHERE bc_id_commentaire='.$_GET['id_commentaire'].' LIMIT 1';
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
}
else {
if (isset($_GET[BAZ_VARIABLE_ACTION])) {
if ($_GET[BAZ_VARIABLE_ACTION]==BAZ_VOIR_FICHE) {
//sinon on met a jour le nb de visites pour la fiche, puisque c'est une simple consultation
$requete = 'UPDATE bazar_fiche SET bf_nb_consultations=bf_nb_consultations+1 WHERE bf_id_fiche='.$GLOBALS['_BAZAR_']['id_fiche'];
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
}
}
}
 
$requete = 'SELECT * FROM bazar_fiche,bazar_nature WHERE bf_ce_nature=bn_id_nature and bf_id_fiche='.$GLOBALS['_BAZAR_']['id_fiche'];
 
if (isset($GLOBALS['_BAZAR_']['langue'])) $requete .= ' and bn_ce_i18n like "'.$GLOBALS['_BAZAR_']['langue'].'"';
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
$res = '<div class="'.BAZ_classe_erreur.'">'.BAZ_FICHE_INEXISTANTE.'</div> \n' ;
return res ;
}
$ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC) ;
$GLOBALS['_BAZAR_']['ligne_resultat'] = $ligne;
if (!isset($GLOBALS['_BAZAR_']['typeannonce'])) $GLOBALS['_BAZAR_']['typeannonce'] = $ligne['bf_ce_nature'];
if (!isset($GLOBALS['_BAZAR_']['fiche_valide'])) $GLOBALS['_BAZAR_']['fiche_valide'] = $ligne['bf_statut_fiche'];
//on verifie si l'utilisateur est administrateur
$est_admin=0;
 
// Si on vient de l applette calendrier, $GLOBALS['_BAZAR_']['id_typeannonce'] est vide ...
// mais on dispose de la constante BAZ_NUM_ANNONCE_CALENDRIER
if (!isset($GLOBALS['_BAZAR_']['id_typeannonce']) && defined('BAZ_NUM_ANNONCE_CALENDRIER')) $GLOBALS['_BAZAR_']['id_typeannonce'] = BAZ_NUM_ANNONCE_CALENDRIER;
 
if (!isset($GLOBALS['_BAZAR_']['template'])) $GLOBALS['_BAZAR_']['template'] = $ligne['bn_template'];
if (!isset($GLOBALS['_BAZAR_']['commentaire'])) $GLOBALS['_BAZAR_']['commentaire'] = $ligne['bn_commentaire'];
if (!isset($GLOBALS['_BAZAR_']['class'])) $GLOBALS['_BAZAR_']['class'] = $ligne['bn_label_class'];
 
$utilisateur = new Administrateur_bazar ($GLOBALS['AUTH']);
if ($utilisateur->isAdmin($ligne['bn_id_nature']) || $utilisateur->isSuperAdmin()) {
$est_admin=1;
}
 
//debut de la fiche
$res .= '<div class="BAZ_cadre_fiche BAZ_cadre_fiche_'.$GLOBALS['_BAZAR_']['class'].'">'."\n";
//affiche le titre sous forme d'image
if (isset ($GLOBALS['_BAZAR_']['image_titre']) && $GLOBALS['_BAZAR_']['image_titre']!='') {
$res .= '<img class="BAZ_img_titre" src="client/bazar/images/'.$GLOBALS['_BAZAR_']['image_titre'].'" alt="'.$ligne['bn_label_nature'].'" />'.'<br />'."\n";
}
//affiche le texte sinon
else {
$res .= '<h1 class="BAZ_titre BAZ_titre_'.$GLOBALS['_BAZAR_']['class'].'">'.$ligne['bn_label_nature'].'</h1>'."\n";
}
$GLOBALS['_BAZAR_']['annonceur'] = $ligne['bf_ce_utilisateur'] ;
//si le template existe, on genere le template
if ((file_exists(BAZ_CHEMIN_APPLI.'templates/'.$GLOBALS['_BAZAR_']['typeannonce'].'-fiche.php'))) {
include_once(BAZ_CHEMIN_APPLI.'templates/'.$GLOBALS['_BAZAR_']['typeannonce'].'-fiche.php');
$res .=genere_fiche($ligne);
}
//on affiche ligne par ligne sinon
else {
// Le titre
$res .= '<h1 class="BAZ_fiche_titre BAZ_fiche_titre_'.$GLOBALS['_BAZAR_']['class'].'">'.$ligne['bf_titre'].'</h1>'."\n";
// cas d'une image personalisee
if (isset($ligne['bf_url_image'])) {
$res .= '<div class="BAZ_fiche_image BAZ_fiche_image_'.$GLOBALS['_BAZAR_']['class'].'">'."\n";
$res .= '<img class="BAZ_image" src="client/bazar/upload/'.$ligne['bf_url_image'].'" border=0 alt="'.BAZ_TEXTE_IMG_ALTERNATIF.'" />'."\n";
$res .= '</div>'."\n";
}
//cas d'une image par defaut
elseif (isset ($GLOBALS['_BAZAR_']['image_logo']) && $GLOBALS['_BAZAR_']['image_logo']!='') {
$res .= '<div class="BAZ_fiche_image BAZ_fiche_image_'.$GLOBALS['_BAZAR_']['class'].'">'."\n";
$res .= '<img class="BAZ_image" src="client/bazar/images/'.$GLOBALS['_BAZAR_']['image_logo'].'" border=0 alt="'.BAZ_TEXTE_IMG_ALTERNATIF.'" width="130" height="130" />'."\n";
$res .= '</div>'."\n";
}
 
//$res .= '<div class="BAZ_description BAZ_description_'.$GLOBALS['_BAZAR_']['class'].'">'.nl2br($ligne['bf_description']).'</div>'."\n";
$tableau=baz_valeurs_template($GLOBALS['_BAZAR_']['template']);
 
/** Boucle d affichage des resultats
*
*/
 
// Le parametre pas_de_carte permet a l element de type cartegoogle
// de ne pas renvoyer la carte lors de l affichage d une fiche (par exemple dans les fiches du calendrier)
$danslappli == 1 ? $GLOBALS['pas_de_carte'] = 0 : $GLOBALS['pas_de_carte'] = 1;
for ($i=0; $i < count($tableau); $i++) {
if (isset($ligne[$tableau[$i]['nom_bdd']])) {
$type = $tableau[$i]['type'];
$valeur = $ligne[$tableau[$i]['nom_bdd']];
 
} else {
$type = $tableau[$i]['type'];
$valeur = '';
}
 
$element = Bazar_element::factory($type, $tableau[$i]);
if (!PEAR::isError($element)) {
$res .= $element->toHTML($valeur);
} else {
 
}
if ( $tableau[$i]['type']=='wikini' ) {
$res .= '<div class="BAZ_lien_wikini BAZ_lien_wikini_'.$GLOBALS['_BAZAR_']['class'].'"><a href="wikini/'.genere_nom_wiki2($ligne["bf_titre"], TRUE).'">'.BAZ_ENTRER_PROJET.'</a></div>'."\n";
}
}
//afficher les liens pour l'annonce
$requete = 'SELECT bu_url, bu_descriptif_url FROM bazar_url WHERE bu_ce_fiche='.$GLOBALS['_BAZAR_']['id_fiche'];
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
die ($resultat->getMessage().$resultat->getDebugInfo()) ;
}
if ($resultat->numRows()>0) {
$res .= '<span class="BAZ_label BAZ_label_'.$GLOBALS['_BAZAR_']['class'].'">'.BAZ_LIEN_INTERNET.':</span>'."\n";
$res .= '<span class="BAZ_description BAZ_description_'.$GLOBALS['_BAZAR_']['class'].'">'."\n";
$res .= '<ul class="BAZ_liste BAZ_liste_'.$GLOBALS['_BAZAR_']['class'].'">'."\n";
while ($ligne1 = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
$res .= '<li class="BAZ_liste_lien BAZ_liste_lien_'.$GLOBALS['_BAZAR_']['class'].'"><a href="'.$ligne1['bu_url'].'" class="BAZ_lien" target="_blank">'.$ligne1['bu_descriptif_url'].'</a></li>'."\n";
}
$res .= '</ul></span>'."\n";
}
 
//afficher les fichiers pour l'annonce
$requete = 'SELECT bfj_description, bfj_fichier FROM bazar_fichier_joint WHERE bfj_ce_fiche='.$GLOBALS['_BAZAR_']['id_fiche'];
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
die ($resultat->getMessage().$resultat->getDebugInfo()) ;
}
if ($resultat->numRows()>0) {
$res .= '<span class="BAZ_label BAZ_label_'.$GLOBALS['_BAZAR_']['class'].'">'.BAZ_LISTE_FICHIERS_JOINTS.':</span>'."\n";
$res .= '<span class="BAZ_description BAZ_description_'.$GLOBALS['_BAZAR_']['class'].'">'."\n";
$res .= '<ul class="BAZ_liste BAZ_liste_'.$GLOBALS['_BAZAR_']['class'].'">'."\n";
while ($ligne2 = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
$res .= '<li class="BAZ_liste_fichier BAZ_liste_fichier_'.$GLOBALS['_BAZAR_']['class'].'"><a href="client/bazar/upload/'.$ligne2['bfj_fichier'].'">'.$ligne2['bfj_description'].'</a></li>'."\n";
}
$res .= '</ul></span>'."\n";
}
$res .= '<div class="BAZ_bulle_corps BAZ_bulle_corps_'.$GLOBALS['_BAZAR_']['class'].'">'."\n";
$res .= '<div class="BAZ_infos_fiche BAZ_infos_fiche_'.$GLOBALS['_BAZAR_']['class'].'">'."\n";
$res .= '<span class="BAZ_nb_vues BAZ_nb_vues_'.$GLOBALS['_BAZAR_']['class'].'">'.BAZ_NB_VUS.$ligne['bf_nb_consultations'].BAZ_FOIS.'</span><br />'."\n";
 
//affichage du redacteur de la fiche
$requete = 'SELECT '.BAZ_CHAMPS_NOM.', '.BAZ_CHAMPS_PRENOM.', '.BAZ_CHAMPS_EMAIL.
' FROM '.BAZ_ANNUAIRE.' WHERE '.BAZ_CHAMPS_ID.'='.$ligne['bf_ce_utilisateur'];
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
if (DB::isError($resultat)) {
$res = '<div class="'.BAZ_classe_erreur.'">'.BAZ_FICHE_INEXISTANTE.'</div>' ;
return $res ;
}
}
while ($redacteur = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
$res .= '<span class="BAZ_fiche_ecrite">'.BAZ_FICHE_NUMERO.$GLOBALS['_BAZAR_']['id_fiche'].BAZ_ECRITE;
if (!defined('BAZ_FICHE_REDACTEUR_MAIL') || BAZ_FICHE_REDACTEUR_MAIL) {
$res .= '<a href="mailto:'.$redacteur[BAZ_CHAMPS_EMAIL].'">'.$redacteur[BAZ_CHAMPS_PRENOM].' '.$redacteur[BAZ_CHAMPS_NOM].'</a>';
} else {
$res .= $redacteur[BAZ_CHAMPS_PRENOM].' '.$redacteur[BAZ_CHAMPS_NOM];
}
$res .= '<br /></span>'."\n";
}
 
//informations complementaires (id fiche, etat publication,... )
if ($danslappli==1) {
if ($GLOBALS['_BAZAR_']['fiche_valide']==1 && $GLOBALS['_BAZAR_']['appropriation']!=1) {
if ($ligne['bf_date_debut_validite_fiche'] != '0000-00-00' && $ligne['bf_date_fin_validite_fiche'] != '0000-00-00') {
$res .= '<span class="BAZ_rubrique BAZ_rubrique_'.$GLOBALS['_BAZAR_']['class'].'">'.BAZ_PUBLIEE.':</span> '.BAZ_DU.
' '.strftime('%d.%m.%Y',strtotime($ligne['bf_date_debut_validite_fiche'])).' '.
BAZ_AU.' '.strftime('%d.%m.%Y',strtotime($ligne['bf_date_fin_validite_fiche'])).'<br />'."\n";
}
}
elseif ($GLOBALS['_BAZAR_']['appropriation']!=1 || $GLOBALS['_BAZAR_']['fiche_valide']!=1) {
$res .= '<span class="BAZ_rubrique BAZ_rubrique_'.$GLOBALS['_BAZAR_']['class'].'">'.BAZ_PUBLIEE.':</span> '.BAZ_NON.'<br />'."\n";
}
//affichage des infos et du lien pour la mise a jour de la fiche
if ( $est_admin || $GLOBALS['_BAZAR_']['annonceur']==$GLOBALS['AUTH']->getAuthData(BAZ_CHAMPS_ID) ) {
$res .= '<span class="BAZ_rubrique BAZ_rubrique_'.$GLOBALS['_BAZAR_']['class'].'" id="date_creation">'.BAZ_DATE_CREATION.'</span> '.strftime('%d.%m.%Y %H:%M',strtotime($ligne['bf_date_creation_fiche']))."\n";
$res .= '<span class="BAZ_rubrique BAZ_rubrique_'.$GLOBALS['_BAZAR_']['class'].'" id="date_mise_a_jour">'.BAZ_DATE_MAJ.'</span> '.strftime('%d.%m.%Y %H:%M',strtotime($ligne['bf_date_maj_fiche']))."\n";
}
$res .= '</div>'."\n";
 
if ( $est_admin || $GLOBALS['_BAZAR_']['annonceur']==$GLOBALS['AUTH']->getAuthData(BAZ_CHAMPS_ID) ) {
$res .= '<div class="BAZ_actions_fiche BAZ_actions_fiche_'.$GLOBALS['_BAZAR_']['class'].'">'."\n";
$res .= '<ul>'."\n";
if ( $est_admin ) {
$lien_publie = &$GLOBALS['_BAZAR_']['url'];
$lien_publie->addQueryString(BAZ_VARIABLE_ACTION, BAZ_VOIR_FICHE);
$lien_publie->addQueryString('id_fiche', $GLOBALS['_BAZAR_']['id_fiche']);
$lien_publie->addQueryString('typeannonce', $ligne['bf_ce_nature']);
 
if ($GLOBALS['_BAZAR_']['fiche_valide']==0||$GLOBALS['_BAZAR_']['fiche_valide']==2) {
$lien_publie->addQueryString('publiee', 1);
$label_publie=BAZ_VALIDER_LA_FICHE;
$class_publie='_valider';
$res .= '<form method="post" action="'.$lien_publie->getURL().'" ><li><label class="BAZ_label" id="label_validite" for="date_validite"> Date de validité :</label><input id="date_validite" name="date_validite" type="text" value="'.$ligne['bf_date_debut_validite_fiche'].'" /></li> <li><input class="bouton_valider" type="submit" value="Valider la fiche" /></li></form>';
} elseif ($GLOBALS['_BAZAR_']['fiche_valide']==1) {
$lien_publie->addQueryString('publiee', 1);
$res .= '<form method="post" action="'.$lien_publie->getURL().'" ><li><label class="BAZ_label" id="label_validite" for="date_validite"> Date de validité :</label><input id="date_validite" name="date_validite" type="text" value="'.$ligne['bf_date_debut_validite_fiche'].'" /> <input type="submit" class="bouton_valider" value="Modifier" /></form>';
$lien_publie->removeQueryString('publiee');
$lien_publie->addQueryString('publiee', 0);
$label_publie=BAZ_INVALIDER_LA_FICHE;
$class_publie='_invalider';
$res .= '<li class="BAZ_liste'.$class_publie.'"><a href="'.$lien_publie->getURL().'">'.$label_publie.'</a></li>'."\n";
}
}
$lien_modifier=$GLOBALS['_BAZAR_']['url'];
$lien_modifier->addQueryString(BAZ_VARIABLE_ACTION, BAZ_ACTION_MODIFIER);
$lien_modifier->addQueryString('id_fiche', $GLOBALS['_BAZAR_']['id_fiche']);
$lien_modifier->addQueryString('typeannonce', $ligne['bf_ce_nature']);
$res .= '<li class="BAZ_liste_modifier"><a href="'.$lien_modifier->getURL().'" id="modifier_fiche">'.BAZ_MODIFIER_LA_FICHE.'</a></li>'."\n";
$lien_supprimer=$GLOBALS['_BAZAR_']['url'];
$lien_supprimer->addQueryString(BAZ_VARIABLE_ACTION, BAZ_ACTION_SUPPRESSION);
$lien_supprimer->addQueryString('id_fiche', $GLOBALS['_BAZAR_']['id_fiche']);
$lien_supprimer->addQueryString('typeannonce', $ligne['bf_ce_nature']);
$res .= '<li class="BAZ_liste_supprimer"><a href="'.$lien_supprimer->getURL().'" id="supprimer_fiche">'.BAZ_SUPPRIMER_LA_FICHE.'</a></li>'."\n";
$res .= '</ul>'."\n";
$res .= '</div>'."\n";
}
}
$res .= '</div>'."\n";
$res .= '</div>'."\n";
 
}
 
// Nous vérifions comment est appelé la fonction
if ($danslappli == 0) {
$lien_voir=$GLOBALS['_BAZAR_']['url'];
$lien_voir->addQueryString(BAZ_VARIABLE_VOIR, BAZ_VOIR_CONSULTER);
$lien_voir->addQueryString('id_fiche', $GLOBALS['_BAZAR_']['id_fiche']);
$lien_voir->addQueryString(BAZ_VARIABLE_ACTION, BAZ_VOIR_FICHE);
 
$res .= '<div class="BAZ_lien_fiche"><a href="'.str_replace('carte_','',$lien_voir->getURL()).'" class="BAZ_lien">'.BAZ_VOIR_LA_FICHE.'</a></div>'."\n";
$res .= '</div>'."\n";
} else if ($danslappli == 1 ) {
 
// Ajout des appropriations, s'il le faut
if ($GLOBALS['_BAZAR_']['appropriation'] == 1) {
$res .= '<br />'."\n".'<div class="BAZ_cadre_fiche BAZ_cadre_fiche_'.$GLOBALS['_BAZAR_']['class'].'">'."\n";
$res .= '<h2 class="BAZ_titre BAZ_titre_'.$GLOBALS['_BAZAR_']['class'].'">'.BAZ_LES_STRUCTURES_POSSEDANT_UNE_RESSOURCE.'</h2>'."\n";
$requete = 'SELECT '.BAZ_CHAMPS_ID.', '.BAZ_CHAMPS_NOM.' FROM bazar_appropriation,'.BAZ_ANNUAIRE.' WHERE ba_ce_id_fiche='.$GLOBALS['_BAZAR_']['id_fiche'].' AND ba_ce_id_structure='.BAZ_CHAMPS_ID.' ORDER BY '.BAZ_CHAMPS_NOM.' ASC';
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete . ' -- ' . __FILE__ . ':' . __LINE__) ;
if (DB::isError ($resultat)) {
return $resultat->getMessage().'<br />'.$resultat->getDebugInfo();
}
$possede_ressource=0;
if ($resultat->numRows()>0) {
$res .= BAZ_IL_Y_A.$resultat->numRows().' ';
if ($resultat->numRows()==1) $res .= BAZ_STRUCTURE_POSSEDANT.'<br />'."\n";
else $res .= BAZ_STRUCTURES_POSSEDANT.'<br />'."\n";
$res .= '<ul>'."\n";
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
$res .= '<li><a href="'.BAZ_URL_ANNUAIRE.'&amp;voir_fiche='.$ligne[BAZ_CHAMPS_ID].'" onclick="javascript:window.open(this.href);return false;">'.$ligne[BAZ_CHAMPS_NOM].'</a></li>'."\n";
if ($GLOBALS['AUTH']->getAuth() && $GLOBALS['AUTH']->getAuthData(BAZ_CHAMPS_ID)==$ligne[BAZ_CHAMPS_ID]) $possede_ressource=1;
}
$res .= '</ul><br />'."\n";
}
else $res .= BAZ_PAS_D_APPROPRIATION.'<br /><br />'."\n";
$res .='<p class="BAZ_bulle_corps BAZ_bulle_corps_'.$GLOBALS['_BAZAR_']['class'].'">'."\n";
$lien_appropriation = $GLOBALS['_BAZAR_']['url'];
$lien_appropriation->addQueryString(BAZ_VARIABLE_ACTION, BAZ_VOIR_FICHE);
$lien_appropriation->addQueryString('id_fiche', $GLOBALS['_BAZAR_']['id_fiche']);
if ($possede_ressource) {
$lien_appropriation->addQueryString('appropriation', 0);
$res .= BAZ_POSSEDE_DEJA_RESSOURCE.'<br />'."\n".'<a href="'.$lien_appropriation->getURL().'">'.BAZ_CLIQUER_POUR_VOUS_ENLEVER.'</a>'."\n";
$lien_appropriation->removeQueryString('appropriation');
}
elseif ($GLOBALS['AUTH']->getAuth() && $GLOBALS['AUTH']->getAuthData(BAZ_CHAMPS_EST_STRUCTURE)) {
$lien_appropriation->addQueryString('appropriation', 1);
$res .= BAZ_SI_POSSEDE_RESSOURCE.'<br />'."\n".'<a href="'.$lien_appropriation->getURL().'">'.BAZ_CLIQUER_POUR_APPARAITRE.'</a>'."\n";
$lien_appropriation->removeQueryString('appropriation');
}
elseif ($GLOBALS['AUTH']->getAuth() && !$GLOBALS['AUTH']->getAuthData(BAZ_CHAMPS_EST_STRUCTURE)) {
$res .= BAZ_IL_FAUT_ETRE_STRUCTURE."\n";
}
elseif (!$GLOBALS['AUTH']->getAuth()) {
$res .= BAZ_IL_FAUT_ETRE_IDENTIFIE_STRUCTURE."\n";
}
$res .='</p>'."\n";
$res .= '</div>'."\n";
}
 
// Ajout des commentaires, s'il le faut
//if ($GLOBALS['_BAZAR_']['commentaire'] == 1) {
$res .= '<br />'."\n".'<div class="BAZ_cadre_fiche BAZ_cadre_fiche_'.$GLOBALS['_BAZAR_']['class'].'">'."\n";
$res .= '<h2 class="BAZ_titre BAZ_titre_'.$GLOBALS['_BAZAR_']['class'].'">'.BAZ_LES_COMMENTAIRES.'</h2>'."\n";
$requete = 'SELECT * FROM bazar_commentaires WHERE bc_ce_id_fiche='.$GLOBALS['_BAZAR_']['id_fiche'].' ORDER BY bc_date ASC';
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError ($resultat)) {
return $resultat->getMessage().'<br />'.$resultat->getDebugInfo();
}
if ($resultat->numRows() > 0) {
// Titre avec nombre de commentaires
$res .= '<p>'.BAZ_IL_Y_A.$resultat->numRows().' ';
// Ajout du "s" ou pas
$res .= ($resultat->numRows() == 1) ? BAZ_COMMENTAIRE : BAZ_COMMENTAIRES;
$res .= '</p>'."\n";
 
// Info pour ajotuer ces commentaires si on n'est pas identifié
if (!$GLOBALS['AUTH']->getAuth()) {
$res .= '<p class="information">'.BAZ_COMMENTAIRE_AUTH.'</p>';
}
 
// Affichages des commentaires
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
$res .= '<p class="BAZ_bulle_corps BAZ_bulle_corps_'.$GLOBALS['_BAZAR_']['class'].'">'."\n";
// Affichage du commentaire
$res .= $ligne['bc_commentaire'].'<br />'."\n";
$res .= '<span class="BAZ_commentaire_admin">'.BAZ_PAR.' : <strong>'.$ligne['bc_nom'].'</strong>'.BAZ_ECRIT_LE.strftime('%d.%m.%Y %H:%M',strtotime($ligne['bc_date']));
// Pour les identifies seulement, administrateurs de la rubrique ou superadmins
if ($est_admin == 1) {
$url_comment= $GLOBALS['_BAZAR_']['url'];
$url_comment->addQueryString(BAZ_VARIABLE_ACTION, BAZ_VOIR_FICHE);
$url_comment->addQueryString('id_fiche', $GLOBALS['_BAZAR_']['id_fiche']);
$url_comment->addQueryString('id_commentaire', $ligne['bc_id_commentaire']);
$res .= '&nbsp;&nbsp;<a href="'.$url_comment->getURL().'">'.BAZ_SUPPRIMER.'</a>'."\n";
}
$res .= '</span>'."\n";
$res .= '</p>'."\n";
}
} else {
$res .= BAZ_PAS_DE_COMMENTAIRES.'<br /><br />'."\n";
}
//}
 
//formulaire des commentaires
if ($GLOBALS['AUTH']->getAuth()) {
$form_commentaire = new HTML_QuickForm('bazar_commentaire', 'post', $url);
$squelette =& $form_commentaire->defaultRenderer();
$squelette->setFormTemplate("\n".'<form {attributes}>'."\n".'{content}'."\n".'</form>'."\n");
$squelette->setElementTemplate( '<label style="width:200px;">{label}'.
'<!-- BEGIN required --><span class="symbole_obligatoire">&nbsp;*</span><!-- END required -->'."\n".
'</label><br />'."\n".'{element}<br />'."\n");
$squelette->setRequiredNoteTemplate("\n".'<span class="symbole_obligatoire"> *{requiredNote}</span>'."\n");
$option=array('style'=>'width:300px;border:1px solid #000;', 'maxlength'=>100);
$form_commentaire->addElement('text', 'Nom', BAZ_ENTREZ_VOTRE_NOM, $option);
$option=array('style'=>'width:95%;height:100px;white-space: pre;padding:3px;border:1px solid #000;');
require_once PAP_CHEMIN_API_PEAR.'HTML/QuickForm/textarea.php';
$formtexte= new HTML_QuickForm_textarea('Commentaire', BAZ_ENTREZ_VOTRE_COMMENTAIRE, $option);
$form_commentaire->addElement($formtexte) ;
$option=array('style'=>'border:1px solid #000;');
$form_commentaire->addElement('submit', 'Envoyer', BAZ_ENVOYER, $option);
$form_commentaire->addRule('Nom', BAZ_NOM_REQUIS, 'required', '', 'client') ;
$form_commentaire->addRule('Commentaire', BAZ_COMMENTAIRE_REQUIS, 'required', '', 'client') ;
$form_commentaire->setRequiredNote(BAZ_CHAMPS_REQUIS) ;
$res .= $form_commentaire->toHTML();
}
$res .= '</div>'."\n";
}
 
// Nettoyage de l'url avant les return : apparement inutile sinon pose pb dans Papyrus (url applette deconnexion et moteur de recherche) [jpm le 17 mars 2008]
//$GLOBALS['_BAZAR_']['url']->removeQueryString(BAZ_VARIABLE_ACTION);
//$GLOBALS['_BAZAR_']['url']->removeQueryString('id_fiche');
$GLOBALS['_BAZAR_']['url']->removeQueryString('id_commentaire');
$GLOBALS['_BAZAR_']['url']->removeQueryString('typeannonce');
 
return $res ;
}
 
// merci PHP 5 ...
function mb_str_split2($str, $length = 1) {
 
if ($length < 1) return FALSE;
 
$result = array();
 
for ($i = 0; $i < strlen($str); $i += $length) {
$result[] = substr($str, $i, $length);
}
 
return $result;
}
 
function remove_accents2( $string )
{
$string = htmlentities($string);
return preg_replace("/&([a-z])[a-z]+;/i","$1",$string);
}
 
function genere_nom_wiki2($nom, $spaces = FALSE)
{
// traitement des accents
$nom = remove_accents2($nom);
 
$temp = mb_str_split2($nom);
 
$count = 0;
$final = NULL;
foreach($temp as $letter)
{
if(preg_match('/([[:space:]]|[[:punct:]])/', $letter))
{
$final .= ($spaces ? '_' : '');
} elseif(preg_match ('/[a-zA-Z0-9]/', $letter)) {
$final .= (($count == 0 || $count == (strlen($nom) - 1)) ? strtoupper($letter) : strtolower($letter));
}
$count++;
}
 
// vérifions que le retour n'est pas uniquement un underscore
if(preg_match('/^[[:punct:]]+$/', $final)) return FALSE;
 
// sinon retour du nom formaté
return($final);
}
 
 
/** RSSversHTML () transforme un flux RSS (en XML) en page HTML
*
* On passe en paramètre le contenu du flux RSS, on affiche ou non la description,
* et on choisit de format de la date à l'affichage. On a en sortie du code HTML à afficher
*
* @param string le contenu du flux RSS
* @param boolean afficher ou non la description
* @param string choisir le format de date: jmah (12/02/2004 12h34) jmh (12/02 12h34) jma (12/02/2004) jm (12/02) ou rien
*
* @return string le code HTML
*/
function RSSversHTML($rss, $voirdesc, $formatdate, $affichenb) {
 
if ($rss!='') {
$rawitems='';$title='';$url='';$cat='';$date='';
$res='';
if( eregi('<item>(.*)</item>', $rss, $rawitems ) ) {
$items = explode('<item>', $rawitems[0]);
$res.='<ul id="BAZ_liste_fiche">'."\n";
for( $i = 0; $i < count($items)-1; $i++ ) {
eregi('<title>(.*)</title>',$items[$i+1], $title );
eregi('<link>(.*)</link>',$items[$i+1], $url );
eregi('<description>(.*)</description>',$items[$i+1], $cat);
eregi('<pubDate>(.*)</pubDate>',$items[$i+1], $date);
$res.='<li>';
if ($formatdate=='jm') {$res.=strftime('%d.%m',strtotime($date[1])).': ';}
if ($formatdate=='jma') {$res.=strftime('%d.%m.%Y',strtotime($date[1])).': ';}
if ($formatdate=='jmh') {$res.=strftime('%d.%m %H:%M',strtotime($date[1])).': ';}
if ($formatdate=='jmah') {$res.=strftime('%d.%m.%Y %H:%M',strtotime($date[1])).': ';}
$res.='<a href="'.preg_replace ('/&amp;/', '&', $url[1]).'">'.$title[1].'</a>';
if ($voirdesc) {$res.=$cat[1];}
// Ajout du bouton supprimer pour les superadministrateur
$utilisateur = new Administrateur_bazar($GLOBALS['AUTH']);
if (($GLOBALS['AUTH']->getAuth() && $utilisateur->isSuperAdmin())and($url[1]!='#')) {
$mon_url = preg_replace ('/&amp;/', '&', $url[1]) ;
$url_suppr = new Net_URL(preg_replace ('/&amp;/', '&', $mon_url)) ;
$url_suppr->addQueryString(BAZ_VARIABLE_ACTION, BAZ_ACTION_SUPPRESSION) ;
$res .= ' ( <a href="'.$url_suppr->getURL().
'" onclick="javascript:return confirm(\''.BAZ_SUPPRIMER.' ?\');">'.
BAZ_SUPPRIMER.'</a> )'."\n" ;
}
$res.='</li>'."\n";
}
$res.='</ul>'."\n";
if ($affichenb==1) {
//une annonce trouvee, on accorde au singulier
if (((count($items)-1)==1)and($title!=BAZ_PAS_D_ANNONCES)) {
$res = '<br /><h4>'.BAZ_IL_Y_A.' 1 '.BAZ_FICHE_CORRESPONDANTE.'</h4><br />'."\n".$res;
}
//plusieures annonces trouvees, on accorde au pluriel
else {
$res = '<br /><h4>'.BAZ_IL_Y_A.(count($items)-1).' '.BAZ_FICHES_CORRESPONDANTES.'</h4><br />'."\n".$res;
}
}
//cas des fiches pas trouvées
if (((count($items)-1)==1)and($title[1]==BAZ_PAS_D_ANNONCES)) {
$res = '<br /><h4>'.BAZ_PAS_D_ANNONCES.'</h4><br />'."\n";
}
}
}
else $res = BAZ_PAS_D_ANNONCES;
 
// Nettoyage de l'url
$GLOBALS['_BAZAR_']['url']->removeQueryString(BAZ_VARIABLE_ACTION);
 
return $res;
}
 
/** gen_RSS() - generer un fichier de flux RSS par type d'annonce
*
* @param string Le type de l'annonce (laisser vide pour tout type d'annonce)
* @param integer Le nombre d'annonces a regrouper dans le fichier XML (laisser vide pour toutes)
* @param integer L'identifiant de l'emetteur (laisser vide pour tous)
* @param integer L'etat de validation de l'annonce (laisser 1 pour les annonces validees, 0 pour les non-validees)
* @param string La requete SQL personnalisee
* @param integer La categorie des fiches bazar
*
* @return string Le code du flux RSS
*/
function gen_RSS($typeannonce='', $nbitem='', $emetteur='', $valide=1, $requeteSQL='', $requeteSQLFrom = '', $requeteWhereListe = '', $categorie_nature='', $order = '') {
// generation de la requete MySQL personnalisee
 
$requete = 'SELECT DISTINCT bf_id_fiche, bf_titre, bf_date_debut_validite_fiche, bf_description,bf_date_debut_evenement, bn_label_nature, bf_date_creation_fiche, bf_ce_utilisateur '.
'FROM bazar_fiche, bazar_nature '.$requeteSQLFrom.' WHERE '.$requeteWhereListe;
 
$where_cond = array();
if ($valide!=2) {
$where_cond[] = 'bf_statut_fiche='.$valide;
}
$nomflux=html_entity_decode(BAZ_DERNIERE_ACTU);
if (!is_array ($typeannonce) && $typeannonce!='' and $typeannonce!='toutes') {
$where_cond[] = 'bf_ce_nature='.$typeannonce;
$where_cond[] = ' bf_ce_nature=bn_id_nature';
//le nom du flux devient le type d'annonce
$requete_nom_flux = 'select bn_label_nature from bazar_nature where bn_id_nature = '.$typeannonce;
$nomflux = $GLOBALS['_BAZAR_']['db']->getOne($requete_nom_flux) ;
}
 
// cas où on veut toutes les annonces
if ($typeannonce == 'toutes') {
$where_cond[] = 'bf_ce_nature IN (1,2,3,4)';
$where_cond[] = 'bf_ce_nature=bn_id_nature';
}
 
// Cas ou il y plusieurs type d annonce demande
if (is_array($typeannonce) && ! empty($typeannonce)) {
$where_cond[] = 'bf_ce_nature IN (' . '"' . implode('","', $typeannonce) . '"' . ')';
$where_cond[] = 'bf_ce_nature=bn_id_nature';
}
 
// useless ?
// $utilisateur = new Administrateur_bazar ($GLOBALS['AUTH']) ;
 
$where_cond[] = 'bf_date_debut_evenement >= NOW()';
$where_cond[] = 'bn_id_nature=bf_ce_nature';
 
if ($emetteur!='' && $emetteur!='tous') {
$where_cond[] = 'bf_ce_utilisateur='.$emetteur;
//requete pour afficher le nom de la structure
$requetenom = 'SELECT '.BAZ_CHAMPS_NOM.', '.BAZ_CHAMPS_PRENOM.' FROM '.
BAZ_ANNUAIRE.' WHERE '.BAZ_CHAMPS_ID.'='.$emetteur;
$resultat = $GLOBALS['_BAZAR_']['db']->query($requetenom) ;
if (DB::isError($resultat)) {
die ($resultat->getMessage().$resultat->getDebugInfo()) ;
}
$ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC);
$nomflux .= ' ('.$ligne[BAZ_CHAMPS_NOM].' '.$ligne[BAZ_CHAMPS_PRENOM].')';
}
if ($requeteSQL) {
$where_cond[] = $requeteSQL;
}
 
if ($categorie_nature!='') {
$where_cond[] = 'bn_ce_id_menu IN ('.$categorie_nature.')';
$where_cond[] = 'bf_ce_nature=bn_id_nature';
}
 
if (isset($_REQUEST['departement'])) {
$where_cond[] = 'bf_cp_lieu_evenement LIKE "'.$_REQUEST['departement'].'%"';
}
 
 
$requete .= implode(' AND ', $where_cond);
$requete .= ' ORDER BY bf_date_debut_evenement ASC ';
 
if ($nbitem!='') {$requete .= ' LIMIT 0,'.$nbitem;}
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete . ' -- ' . __FILE__ . ':' . __LINE__) ;
 
if (DB::isError($resultat)) {
die ($resultat->getMessage().$resultat->getDebugInfo()) ;
}
 
include_once PAP_CHEMIN_API_PEAR . 'XML/Util.php' ;
 
// passage en utf-8 --julien
// --
 
// setlocale() pour avoir les formats de date valides (w3c) --julien
setlocale(LC_TIME, "C");
 
$xml = XML_Util::getXMLDeclaration('1.0', 'UTF-8', 'yes') ;
$xml .= "\r\n ";
$xml .= XML_Util::createStartElement ('rss', array('version' => '2.0')) ;
$xml .= "\r\n ";
$xml .= XML_Util::createStartElement ('channel');
$xml .= "\r\n ";
$xml .= XML_Util::createTag ('title', null, utf8_encode(html_entity_decode($nomflux)));
$xml .= "\r\n ";
$xml .= XML_Util::createTag ('link', null, utf8_encode(html_entity_decode(BAZ_RSS_ADRESSESITE)));
$xml .= "\r\n ";
$xml .= XML_Util::createTag ('description', null, utf8_encode(html_entity_decode(BAZ_RSS_DESCRIPTIONSITE)));
$xml .= "\r\n ";
$xml .= XML_Util::createTag ('language', null, 'fr-FR');
$xml .= "\r\n ";
$xml .= XML_Util::createTag ('copyright', null, 'Copyright (c) '. date('Y') .' '. BAZ_RSS_NOMSITE);
$xml .= "\r\n ";
$xml .= XML_Util::createTag ('lastBuildDate', null, strftime('%a, %d %b %Y %H:%M:%S GMT'));
$xml .= "\r\n ";
$xml .= XML_Util::createTag ('docs', null, 'http://www.stervinou.com/projets/rss/');
$xml .= "\r\n ";
$xml .= XML_Util::createTag ('category', null, BAZ_RSS_CATEGORIE);
$xml .= "\r\n ";
$xml .= XML_Util::createTag ('managingEditor', null, BAZ_RSS_MANAGINGEDITOR);
$xml .= "\r\n ";
$xml .= XML_Util::createTag ('webMaster', null, BAZ_RSS_WEBMASTER);
$xml .= "\r\n ";
$xml .= XML_Util::createTag ('ttl', null, '60');
$xml .= "\r\n ";
$xml .= XML_Util::createStartElement ('image');
$xml .= "\r\n ";
$xml .= XML_Util::createTag ('title', null, BAZ_RSS_NOMSITE);
$xml .= "\r\n ";
$xml .= XML_Util::createTag ('url', null, BAZ_RSS_LOGOSITE);
$xml .= "\r\n ";
$xml .= XML_Util::createTag ('link', null, BAZ_RSS_ADRESSESITE);
$xml .= "\r\n ";
$xml .= XML_Util::createEndElement ('image');
if ($resultat->numRows() > 0) {
// Creation des items : titre + lien + description + date de publication
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
 
$requetenom = 'SELECT '.BAZ_CHAMPS_NOM.', '.BAZ_CHAMPS_PRENOM.' FROM '.
BAZ_ANNUAIRE.' WHERE '.BAZ_CHAMPS_ID.'='.$ligne['bf_ce_utilisateur'];
$res = $GLOBALS['_BAZAR_']['db']->query($requetenom) ;
if (DB::isError($res)) {
die ($res->getMessage().$res->getDebugInfo()) ;
}
 
$nomprenom = $res->fetchRow(DB_FETCHMODE_ASSOC);
 
$xml .= "\r\n ";
$xml .= XML_Util::createStartElement ('item');
$xml .= "\r\n ";
$xml .= XML_Util::createTag('title', null, transformerTxtPourRss($ligne['bf_titre']));
$xml .= "\r\n ";
$lien=$GLOBALS['_BAZAR_']['url'];
$lien->addQueryString(BAZ_VARIABLE_ACTION, BAZ_VOIR_FICHE);
$lien->addQueryString('id_fiche', $ligne['bf_id_fiche']);
$xml .= XML_Util::createTag ('link', null, $lien->getURL());
$xml .= "\r\n ";
$xml .= XML_Util::createTag ('guid', null, $lien->getURL());
$xml .= "\r\n ";
$xml .= XML_Util::createTag ('category', null, transformerTxtPourRss($ligne['bn_label_nature']));
$xml .= "\r\n ";
$xml .= XML_Util::createTag ('author', null, transformerTxtPourRss($nomprenom[BAZ_CHAMPS_NOM].' '.$nomprenom[BAZ_CHAMPS_PRENOM]));
$xml .= "\r\n ";
$xml .= XML_Util::createStartElement ('description');
$xml .= "\r\n ";
if ($_GET[BAZ_VARIABLE_ACTION] != BAZ_VOIR_TOUTES_ANNONCES) {
$xml .= XML_Util::createCDataSection(transformerTxtPourRss($ligne['bf_description']));
}
$xml .= "\r\n ";
$xml .= XML_Util::createEndElement ('description');
$xml .= "\r\n ";
/*if ($ligne['bf_date_debut_validite_fiche'] != '0000-00-00' &&
$ligne['bf_date_debut_validite_fiche']>$ligne['bf_date_creation_fiche']) {
$date_pub = $ligne['bf_date_debut_validite_fiche'];
} else $date_pub = $ligne['bf_date_creation_fiche'] ;*/
$date_pub = $ligne['bf_date_debut_evenement'] ;
$xml .= XML_Util::createTag ('pubDate', null, strftime('%a, %d %b %Y %H:%M:%S GMT',strtotime($date_pub)));
$xml .= "\r\n ";
$xml .= XML_Util::createEndElement ('item');
}
}
else {//pas d'annonces
$xml .= "\r\n ";
$xml .= XML_Util::createStartElement ('item');
$xml .= "\r\n ";
$xml .= XML_Util::createTag ('title', null, utf8_encode(html_entity_decode(BAZ_PAS_D_ANNONCES)));
$xml .= "\r\n ";
$xml .= XML_Util::createTag ('link', null, utf8_encode(html_entity_decode($GLOBALS['_BAZAR_']['url']->getUrl())));
$xml .= "\r\n ";
$xml .= XML_Util::createTag ('guid', null, utf8_encode(html_entity_decode($GLOBALS['_BAZAR_']['url']->getUrl())));
$xml .= "\r\n ";
$xml .= XML_Util::createTag ('description', null, utf8_encode(html_entity_decode(BAZ_PAS_D_ANNONCES)));
$xml .= "\r\n ";
$xml .= XML_Util::createTag ('pubDate', null, strftime('%a, %d %b %Y %H:%M:%S GMT',time()));
$xml .= "\r\n ";
$xml .= XML_Util::createEndElement ('item');
}
$xml .= "\r\n ";
$xml .= XML_Util::createEndElement ('channel');
$xml .= "\r\n ";
$xml .= XML_Util::createEndElement('rss') ;
// Truc copiédepuis l'applette syndication de Papyrus qui semble empêcher les flux de foirer dans Foudroiseau
$xml = supprimerXmlDangereux($xml);
 
// Nettoyage de l'url
$GLOBALS['_BAZAR_']['url']->removeQueryString(BAZ_VARIABLE_ACTION);
$GLOBALS['_BAZAR_']['url']->removeQueryString('id_fiche');
 
return $xml;
}
 
function supprimerXmlDangereux($xml)
{
$ret = "";
$encours;
if (empty($xml))
{
return $ret;
}
 
$lg = strlen($xml);
for ($i=0; $i < $lg; $i++)
{
$encours = ord($xml{$i});
if (($encours == 0x9) ||
($encours == 0xA) ||
($encours == 0xD) ||
(($encours >= 0x20) && ($encours <= 0xD7FF)) ||
(($encours >= 0xE000) && ($encours <= 0xFFFD)) ||
(($encours >= 0x10000) && ($encours <= 0x10FFFF)))
{
$ret .= chr($encours);
}
else
{
$ret .= " ";
}
}
return $ret;
}
 
/** baz_liste() Formate la liste de toutes les annonces actuelles
*
* @return string le code HTML a afficher
*/
function baz_liste($typeannonce='toutes') {
 
if(isset($_REQUEST['liste31']) && !empty($_REQUEST['liste31'])) {
 
if($_REQUEST['liste31'] != "0")
{
$GLOBALS['_BAZAR_']['categorie_nature'] = $_REQUEST['liste31'] ;
}
else
{
$GLOBALS['_BAZAR_']['categorie_nature'] = 'toutes' ;
}
}
 
//pour les super-administrateurs, on peut voir les annonces non validees
//on verifie si l'utilisateur est administrateur
$utilisateur = new Administrateur_bazar($GLOBALS['AUTH']) ;
 
//creation du lien pour le formulaire de recherche
$GLOBALS['_BAZAR_']['url']->addQueryString(BAZ_VARIABLE_ACTION, BAZ_VOIR_TOUTES_ANNONCES);
if (isset($_REQUEST['recherche_avancee'])) $GLOBALS['_BAZAR_']['url']->addQueryString ('recherche_avancee', $_REQUEST['recherche_avancee']);
$lien_formulaire = preg_replace ('/&amp;/', '&', $GLOBALS['_BAZAR_']['url']->getURL()) ;
$formtemplate = new HTML_QuickForm('formulaire', 'post', $lien_formulaire) ;
$squelette =& $formtemplate->defaultRenderer();
$squelette->setFormTemplate("\n".'<form {attributes}>'."\n".'<table>'."\n".'{content}'."\n".'</table>'."\n".'</form>'."\n");
$squelette->setElementTemplate( '<tr>'."\n".'<td>'."\n".'{label}'.
'<!-- BEGIN required --><span class="symbole_obligatoire">&nbsp;*</span><!-- END required -->'."\n".
' :</td>'."\n".'<td style="text-align:left;padding:5px;"> '."\n".'{element}'."\n".
'<!-- BEGIN error --><span class="erreur">{error}</span><!-- END error -->'."\n".
'</td>'."\n".'</tr>'."\n");
$squelette->setElementTemplate( '<tr>'."\n".'<td colspan="2" class="liste_a_cocher"><strong>{label}&nbsp;{element}</strong>'."\n".
'<!-- BEGIN required --><span class="symbole_obligatoire">&nbsp;*</span><!-- END required -->'."\n".'</td>'."\n".'</tr>'."\n", 'accept_condition');
$squelette->setElementTemplate( '<tr><td colspan="2">{label}{element}</td></tr>'."\n", 'rechercher');
 
$squelette->setRequiredNoteTemplate("\n".'<tr>'."\n".'<td colspan="2" class="symbole_obligatoire">* {requiredNote}</td></tr>'."\n");
//Traduction de champs requis
$formtemplate->setRequiredNote(BAZ_CHAMPS_REQUIS) ;
$formtemplate->setJsWarnings(BAZ_ERREUR_SAISIE,BAZ_VEUILLEZ_CORRIGER);
//GEN_stockerFichierScript('jquery', 'http://code.jquery.com/jquery-latest.js');
GEN_stockerFichierScript('jquery_date_picker', 'api/js/jquery/ui.datepicker.js');
GEN_stockerFichierScript('jquery_date_picker_fr', 'api/js/jquery/ui.datepicker-fr.js');
GEN_stockerStyleExterne( 'jquery_date_picker_style', 'api/js/jquery/ui.datepicker.css');
$formtemplate->addElement('html', '<tr><td>Dates: &nbsp;</td><td>'.bazar::getFiltrePlageDeDate().'</td></tr>');
 
//cas du formulaire de recherche proposant de chercher parmis tous les types d'annonces
//requete pour obtenir l'id et le label des types d'annonces
$requete = 'SELECT bn_id_nature, bn_label_nature '.
'FROM bazar_nature' ;
 
$suite = false;
 
if(isset($GLOBALS['_BAZAR_']['categorie_nature']) && !empty($GLOBALS['_BAZAR_']['categorie_nature']) && $GLOBALS['_BAZAR_']['categorie_nature'] != 'toutes') {
$requete .= ' WHERE bn_ce_id_menu IN ('.$GLOBALS['_BAZAR_']['categorie_nature'].') ';
$suite = true;
}
 
if (isset($GLOBALS['_BAZAR_']['langue'])) {
if($suite) {
$requete .= 'AND';
} else {
$requete .= ' WHERE';
}
$requete .= ' bn_ce_i18n like "'.$GLOBALS['_BAZAR_']['langue'].'%" ';
//'ORDER BY bn_label_nature ASC';
}
 
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
return ($resultat->getMessage().$resultat->getDebugInfo()) ;
}
//on recupere le nb de types de fiches, pour plus tard
$nb_type_de_fiches=$resultat->numRows();
$type_annonce_select['toutes']=BAZ_TOUS_TYPES_FICHES;
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
$type_annonce_select[$ligne['bn_id_nature']] = $ligne['bn_label_nature'];
$tableau_typeannonces[] = $ligne['bn_id_nature'] ;
}
if ($nb_type_de_fiches>1 && $GLOBALS['_BAZAR_']['typeannonce']=='toutes' && BAZ_AFFICHER_FILTRE_MOTEUR) {
$res= '';
$option=array('onchange' => 'javascript:this.form.submit();');
$formtemplate->addElement ('select', 'nature', BAZ_TYPEANNONCE, $type_annonce_select, $option) ;
if (isset($_REQUEST['nature'])) {
$defauts=array('nature'=>$_REQUEST['nature']);
$formtemplate->setDefaults($defauts);
}
}
//cas du type d'annonces predefini
else {
if ($nb_type_de_fiches==1 && key($type_annonce_select) != 'toutes') {
$GLOBALS['_BAZAR_']['typeannonce']=end($type_annonce_select);
$GLOBALS['_BAZAR_']['id_typeannonce']=key($type_annonce_select);
}
 
$res = '<h2 class="bazar_titre2">'.BAZ_RECHERCHE_FICHE.'</h2>'."\n";
}
 
//requete pour obtenir l'id, le nom et prenom de toutes les personnes ayant depose une fiche
// dans le but de construire l'element de formulaire select avec les noms des emetteurs de fiche
if (BAZ_RECHERCHE_PAR_EMETTEUR && ($utilisateur->isAdmin(1) || $utilisateur->isSuperAdmin())) {
$requete = 'SELECT DISTINCT '.BAZ_CHAMPS_ID.', '.BAZ_CHAMPS_NOM.', '.BAZ_CHAMPS_PRENOM.' '.
'FROM bazar_fiche,'.BAZ_ANNUAIRE.' WHERE ' ;
 
$requete .= ' bf_date_debut_validite_fiche<=NOW() AND';
$requete .= ' bf_ce_utilisateur='.BAZ_CHAMPS_ID.' ';
 
if (!isset($_REQUEST['nature'])) {
if (isset($GLOBALS['_BAZAR_']['id_typeannonce']) && $GLOBALS['_BAZAR_']['id_typeannonce'] != 'toutes') {
$requete .= 'AND bf_ce_nature="'.$GLOBALS['_BAZAR_']['id_typeannonce'].'" ';
}
}
else {
if ($_REQUEST['nature']!='toutes') {
$requete .= 'AND bf_ce_nature='.$_REQUEST['nature'].' ';
}
}
 
$requete .= 'ORDER BY '.BAZ_CHAMPS_NOM.' ASC';
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
 
if (DB::isError($resultat)) {
die ($resultat->getMessage().$resultat->getDebugInfo()) ;
}
$personnes_select['tous']=BAZ_TOUS_LES_EMETTEURS;
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
$personnes_select[$ligne[BAZ_CHAMPS_ID]] = $ligne[BAZ_CHAMPS_NOM]." ".$ligne[BAZ_CHAMPS_PRENOM] ;
}
$option=array('style'=>'border:1px solid #000;width: 200px;font:12px Myriad, Arial, sans-serif;');
$formtemplate->addElement ('select', 'personnes', BAZ_EMETTEUR, $personnes_select, $option) ;
} else {
$formtemplate->addElement ('hidden', 'personnes', 'tous') ;
}
 
if ($utilisateur->isSuperAdmin()) {
$option=array('style'=>'border:1px solid #000;width: 200px;font:12px Myriad, Arial, sans-serif;');
$valide_select[0] = BAZ_FICHES_VALIDEES;
$valide_select[1] = BAZ_FICHES_PAS_VALIDEES;
$valide_select[2] = BAZ_LES_DEUX;
$formtemplate->addElement ('select', 'valides', BAZ_VALIDE, $valide_select, $option) ;
$defauts=array('valides'=>0);
$formtemplate->setDefaults($defauts);
 
}
 
//champs texte pour entrer les mots cles
$option=array('maxlength'=>60,'style'=>'border:1px solid #000;width:200px;font:12px Myriad, Arial, sans-serif;');
$formtemplate->addElement('text', 'recherche_mots_cles', BAZ_MOT_CLE, $option) ;
 
//option cachee pour savoir si le formulaire a ete appele deja
$formtemplate->addElement('hidden', 'recherche_effectuee', 1) ;
 
// Ajout des options si un type de fiche a ete choisie
if ( (isset($_REQUEST['nature']) && $_REQUEST['nature'] != 'toutes') || (isset($GLOBALS['_BAZAR_']['categorie_nature']) && $nb_type_de_fiches==1)) {
if ( BAZ_MOTEUR_RECHERCHE_AVANCEE || ( isset($_REQUEST['recherche_avancee'])&&$_REQUEST['recherche_avancee']==1) ) {
if ($GLOBALS['_BAZAR_']['categorie_nature'] != '') {
$champs_requete = '' ;
if (!isset($_REQUEST['nature']) || $_REQUEST['nature'] == '') {
$_REQUEST['nature'] = $tableau_typeannonces[0];
}
}
// Recuperation du template
$requete = 'SELECT bn_template FROM bazar_nature WHERE bn_id_nature = '.$_REQUEST['nature'];
$resultat = $GLOBALS['_BAZAR_']['db']->getOne($requete) ;
if (DB::isError($resultat)) {
return ($resultat->getMessage().'<br />'.$resultat->getDebugInfo()) ;
}
 
if (isset($_REQUEST['recherche_avancee']) && $_REQUEST['recherche_avancee']==1) {
foreach(array_merge($_POST, $_GET) as $cle => $valeur) $GLOBALS['_BAZAR_']['url']->addQueryString($cle, $valeur);
$GLOBALS['_BAZAR_']['url']->addQueryString('recherche_avancee', '0');
$lien_recherche_de_base = '<a href="'.$GLOBALS['_BAZAR_']['url']->getURL().'">'.BAZ_RECHERCHE_DE_BASE.'</a><br />';
//lien recherche de base
labelhtml($formtemplate,'',$lien_recherche_de_base,'','','','','');
}
 
$tableau = baz_valeurs_template($resultat) ;
for ($i=0; $i<count($tableau); $i++) {
if (($tableau[$i]['type'] == 'liste' || $tableau[$i]['type'] == 'checkbox' || $tableau[$i]['type'] == 'labelhtml') && $tableau[$i]['recherche'] == 1) {
$tableau[$i]['type']($formtemplate, $tableau[$i]['nom_bdd'], $tableau[$i]['label'], $tableau[$i]['limite1'],
$tableau[$i]['limite2'], $tableau[$i]['defaut'], $tableau[$i]['table_source'], $tableau[$i]['obligatoire'], 1, 'bazar') ;
}
}
}
else {
$url_rech_avance = $GLOBALS['_BAZAR_']['url'];
foreach(array_merge($_POST, $_GET) as $cle => $valeur) $url_rech_avance->addQueryString($cle, $valeur);
$url_rech_avance->addQueryString('recherche_avancee', '1');
$lien_recherche_avancee = '<a href="'.$url_rech_avance->getURL().'">'.BAZ_RECHERCHE_AVANCEE.'</a><br />';
unset ($url_rech_avance);
}
}
 
//lien recherche avancee
if (isset($lien_recherche_avancee)) {
labelhtml($formtemplate,'',$lien_recherche_avancee,'','','','','');
}
 
//Bouton de validation du formulaire
$option=array('style'=>'border:1px solid #000;width:100px;font:12px Myriad, Arial, sans-serif;','class'=>'baz_rech');
$formtemplate->addElement('submit', 'rechercher', BAZ_RECHERCHER, $option);
 
//affichage du formulaire
//$res.=$formtemplate->toHTML()."\n";
 
 
// Ajout de la table bazar_fiche_liste_valeur dans le from de la requete
$case_coche = false ;
$nb_jointures=0;
$requeteFrom = '' ;
$requeteWhere = '';
if ($GLOBALS['_BAZAR_']['id_typeannonce'] != 'toutes') {
$requeteWhere .= 'bn_id_nature='.$GLOBALS['_BAZAR_']['id_typeannonce'].' AND ' ;
}
$requeteWhere .= ' bn_id_nature=bf_ce_nature AND ' ;
if (isset($GLOBALS['_BAZAR_']['langue'])) {
$requeteWhere .= ' bn_ce_i18n like "'.$GLOBALS['_BAZAR_']['langue'].'%" and ';
}
$requeteWhereListe = '' ;
 
if ( isset($tableau) ) {
for ($i = 0; $i < count ($tableau); $i++) {
if ($tableau[$i]['type'] == 'checkbox' || $tableau[$i]['type'] == 'liste') {
$nb_jointures++;
$nom_liste = $tableau[$i]['type'].$tableau[$i]['nom_bdd'] ;
if (isset($_REQUEST[$nom_liste]) && is_array($_REQUEST[$nom_liste])) {
$case_coche = true;
$requeteFrom .= ', bazar_fiche_valeur_liste as bfvl'.($nb_jointures) ;
$requeteWhereListe .= ' bfvl'.$nb_jointures.'.bfvl_ce_liste='.$tableau[$i]['nom_bdd'].' AND ' ; // Numéro de la liste
$requeteWhere .= ' bfvl'.($nb_jointures).'.bfvl_ce_fiche=bf_id_fiche AND ';
$requeteWhereListe .= ' bfvl'.$nb_jointures.'.bfvl_valeur IN (' ;
$chaine = '';
//var_dump($_REQUEST[$nom_liste]);
foreach ($_REQUEST[$nom_liste] as $cle =>$valeur) {
if ($valeur == 1) {
$chaine .= '"'.$cle.'",' ;
}
}
$requeteWhereListe .= substr ($chaine, 0, strlen ($chaine)-1) ;
$requeteWhereListe .= ') AND ';
} else {
if (isset ($_REQUEST[$nom_liste]) && $_REQUEST[$nom_liste]!=0) {
$requeteFrom .= ', bazar_fiche_valeur_liste as bfvl'.($nb_jointures) ;
$requeteWhereListe .= ' bfvl'.$nb_jointures.'.bfvl_ce_liste='.$tableau[$i]['nom_bdd'].' AND ' ; // Numéro de la liste
$requeteWhereListe .= ' bfvl'.$nb_jointures.'.bfvl_valeur='.$_REQUEST[$nom_liste].' AND ';
$requeteWhere .= ' bfvl'.($nb_jointures).'.bfvl_ce_fiche=bf_id_fiche AND ';
$case_coche = true;
}
}
}
}
}
if ($case_coche) {
$requeteWhere .= $requeteWhereListe;
}
if (isset($_REQUEST['liste31']) && $_REQUEST['liste31'] != '0' && $_REQUEST['nature']!='toutes') {
$requeteWhere = 'bf_ce_nature="'.$_REQUEST['nature'].'" AND '.$requeteWhere;
}
 
/*if (BAZ_UTILISE_TEMPLATE) {
// Appel du template n 1
include_once BAZ_CHEMIN_APPLI.'bibliotheque/bazarTemplate.class.php' ;
 
$template = new bazarTemplate ($GLOBALS['_BAZAR_']['db']) ;
$chaine = $template->getTemplate(1, $GLOBALS['_BAZAR_']['langue'], $GLOBALS['_BAZAR_']['categorie_nature']);
if (bazarTemplate::isError ($chaine)) return $chaine->getMessage() ;
ob_start();
eval ($chaine) ;
$res .= ob_get_contents();
ob_end_clean() ;
 
} else {*/
$res .= $formtemplate->toHTML();
if (!isset($_REQUEST['recherche_effectuee'])) {
$res .= '<p class="zone_info">'.BAZ_ENTRER_VOS_CRITERES_DE_RECHERCHE.'</p>'."\n";
 
$requete = 'SELECT DISTINCT bf_id_fiche, '.BAZ_CHAMPS_PRENOM.', '.BAZ_CHAMPS_NOM.', bf_titre, bf_date_debut_validite_fiche, bf_date_debut_evenement, bf_description, bn_label_nature, bf_date_creation_fiche
FROM bazar_fiche, bazar_nature, '.BAZ_ANNUAIRE.'
WHERE bn_id_nature=bn_id_nature
AND bf_ce_utilisateur = '.BAZ_CHAMPS_ID.'
AND bf_statut_fiche = 1
AND bf_date_debut_evenement >= NOW()
GROUP BY bf_titre
ORDER BY bf_date_debut_evenement ASC
LIMIT 0 , 12';
 
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete);
if (DB::isError($resultat)) {
return ($resultat->getMessage().$resultat->getDebugInfo()) ;
}
if($resultat->numRows() != 0) {
$res .= '<h2>'.BAZ_PROCHAINS_EVENEMENTS.'</h2>';
 
$res .= '<ul class="liste_rss">';
while($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
$GLOBALS['_BAZAR_']['url']->addQueryString(BAZ_VARIABLE_ACTION, BAZ_VOIR_FICHE);
$GLOBALS['_BAZAR_']['url']->addQueryString('id_fiche', $ligne['bf_id_fiche']);
 
$res .= '<div class="menu_titre">
<h1 class="intituler_rubrique"><a class="lien_rss" href="'.$GLOBALS['_BAZAR_']['url']->getURL() .'" alt="lire la fiche"> '.$ligne['bf_titre'].'</a></h1>
<p class="date">'.baz_valeur_champs(31,$ligne['bf_id_fiche']).' début le '.$GLOBALS['jours'][date ('w', strtotime ($ligne['bf_date_debut_evenement']))].' '.date('d', strtotime($ligne['bf_date_debut_evenement'])).
' '.$GLOBALS['mois'][date('n', strtotime ($ligne['bf_date_debut_evenement']))].' '.date ('Y', strtotime ($ligne['bf_date_debut_evenement'])).' par '.$ligne[BAZ_CHAMPS_PRENOM].' '.$ligne[BAZ_CHAMPS_NOM].' </p>
<p class="descriptif_contenu">'.substr($ligne['bf_description'], 0, 400).'</p>
</div>
<hr />';
 
}
$res .= '</ul>';
}
}
//}
 
//affichage des resultats de la recherche si le formulaire a ete envoye
$requeteSQL='';
if (isset($_REQUEST['recherche_effectuee'])) {
//preparation de la requete pour trouver les mots cles
if (($_REQUEST['recherche_mots_cles']!='')and($_REQUEST['recherche_mots_cles']!=BAZ_MOT_CLE)) {
//decoupage des mots cles
$recherche = split(' ', $_REQUEST['recherche_mots_cles']) ;
$nbmots=count($recherche);
 
$requeteSQL='';
if (isset($GLOBALS['_BAZAR_']['categorie_nature']))
{
$tableau=baz_valeurs_template($GLOBALS['_BAZAR_']['template']);
}
for ($i=0; $i<$nbmots; $i++) {
for ($j=0; $j<count($tableau); $j++) {
if ( $tableau[$j]['type']=='texte' || $tableau[$j]['type']=='textelong') {
//if ($i>0) $requeteSQL.=' OR ';
$requeteSQL.= $tableau[$j]['nom_bdd'].' LIKE "%'.$recherche[$i].'%" or ';
}
}
}
$requeteSQL = substr($requeteSQL, 0, count($requeteSQL) - 4);
 
}
if (!isset($_REQUEST['nature'])) {
if (!isset ($GLOBALS['_BAZAR_']['id_nature'])) $typedefiches = $tableau_typeannonces;
else $typedefiches = $GLOBALS['_BAZAR_']['id_nature'] ;
} else {
$typedefiches = $_REQUEST['nature'] ;
if ($typedefiches == 'toutes') $typedefiches = $tableau_typeannonces ;
}
 
$valides = 1 ;
 
if ($typeannonce!='toutes') $typedefiches=$typeannonce;
if (isset($_REQUEST['valides'])) {$valides=$_REQUEST['valides'];}
else {$valides=1;}
//generation de la liste de flux a afficher
if (!isset($_REQUEST['personnes'])) {
$_REQUEST['personnes']='tous';
}
 
if($_SERVER['REMOTE_ADDR'] == '162.38.234.9') {
if (isset($_REQUEST['departement'])) {
$requeteWhere = ' bf_cp_lieu_evenement LIKE "'.$_REQUEST['departement'].'%" AND ';
}
}
 
if ((isset($_REQUEST['date_debut']) && $_REQUEST['date_debut'] != '') || (isset($_REQUEST['date_fin']) && $_REQUEST['date_fin'] != '')) {
 
if (isset($_REQUEST['date_debut']) && $_REQUEST['date_debut'] != '' && isset($_REQUEST['date_fin']) && $_REQUEST['date_fin'] != '') {
$requeteWhere .= ' (bf_date_debut_evenement >="'.date('Y-m-d', strtotime($_REQUEST['date_debut'])).'"
and bf_date_fin_evenement <="'.date('Y-m-d', strtotime($_REQUEST['date_fin'])).'") AND ';
}
else {
if (isset($_REQUEST['date_debut']) && $_REQUEST['date_debut'] != '') {
$requeteWhere .= ' (bf_date_debut_evenement >="'.date('Y-m-d', strtotime($_REQUEST['date_debut'])).'"
) AND ';
}
 
if(isset($_REQUEST['date_fin']) && $_REQUEST['date_fin'] != '') {
$requeteWhere .= ' (bf_date_fin_evenement >="'.date('Y-m-d', strtotime($_REQUEST['date_fin'])).'"
) AND ';
}
}
}
else {
$requeteWhere .= '(bf_date_fin_evenement >= NOW() AND (bf_date_fin_evenement >= NOW() OR bf_date_fin_evenement="0000-00-00")) AND ' ;
}
 
$res .= baz_liste_pagine_HTML($typedefiches, '', $_REQUEST['personnes'], $valides, $requeteSQL, $requeteFrom, $requeteWhere);
}
 
// Nettoyage de l'url
$GLOBALS['_BAZAR_']['url']->removeQueryString(BAZ_VARIABLE_ACTION);
$GLOBALS['_BAZAR_']['url']->removeQueryString('annonce');
$GLOBALS['_BAZAR_']['url']->removeQueryString('categorie_nature');
$GLOBALS['_BAZAR_']['url']->removeQueryString('recherche_avancee');
 
return $res;
}
 
/**
* Cette fonction renvoie du HTML
*/
function baz_liste_pagine_HTML($typeannonce, $nbitem, $emetteur, $valide, $requeteSQL = '', $requeteFrom = '', $requeteWhere = '') {
 
$utilisateur = new Administrateur_bazar ($GLOBALS['AUTH']) ;
// generation de la requete MySQL personnalisee
$req_where=0;
$requete = 'SELECT * '.
'FROM bazar_fiche, bazar_nature '.$requeteFrom.' WHERE '.$requeteWhere;
 
if($utilisateur->isSuperAdmin()) {
if ($valide!=2) {
if ($req_where==1) {$requete .= ' AND ';}
if($valide == 0) {
$req_where=1;
$requete .= 'bf_statut_fiche=1';
}
else {
$req_where=1;
$requete .= 'bf_statut_fiche=0';
}
 
} else {
$requete .= '1 ' ;
}
}
else
{
if($requeteWhere == 1) {
$requete = ' AND ' ;
}
 
$requete .= 'bf_statut_fiche=1';
}
 
$requete .= ' AND bn_id_nature=bf_ce_nature ';
 
if ($emetteur!='' && $emetteur!='tous') {
if ($req_where==1) {$requete .= ' AND ';}
$requete .= 'bf_ce_utilisateur='.$emetteur;
$req_where=1;
}
if ($requeteSQL!='') {
$requete .= ' AND ';
$requete .= '('.$requeteSQL.')';
$req_where=1;
}
$requete .= ' ORDER BY bf_date_debut_evenement DESC, bf_date_debut_validite_fiche DESC, bf_date_fin_validite_fiche DESC, bf_date_maj_fiche DESC';
if ($nbitem!='') {$requete .= ' LIMIT 0,'.$nbitem;}
 
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
return $resultat->getMessage().'<br /><br />'.$resultat->getDebugInfo() ;
}
 
$res = '<br /><h4>'.BAZ_IL_Y_A.($resultat->numRows()).' '.BAZ_FICHES_CORRESPONDANTES.'</h4><br />'."\n";
//$res .= 'requete: '. $requete. '<br />';
 
$GLOBALS['_BAZAR_']['url']->addQueryString(BAZ_VARIABLE_ACTION, BAZ_VOIR_FICHE);
 
$donnees = array();
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
$GLOBALS['_BAZAR_']['url']->addQueryString('id_fiche', $ligne['bf_id_fiche']) ;
array_push ($donnees, $ligne);
}
 
// Mise en place du Pager
include_once PAP_CHEMIN_API_PEAR.'Pager/Pager.php';
$params = array(
'mode' => BAZ_MODE_DIVISION,
'perPage' => BAZ_NOMBRE_RES_PAR_PAGE,
'delta' => BAZ_DELTA,
'httpMethod' => 'GET',
'extraVars' => array_merge($_POST, $_GET),
'altNext' => BAZ_SUIVANT,
'altPrev' => BAZ_PRECEDENT,
'nextImg' => BAZ_SUIVANT,
'prevImg' => BAZ_PRECEDENT,
'itemData' => $donnees
);
$pager = & Pager::factory($params);
$data = $pager->getPageData();
$links = $pager->getLinks();
 
if (BAZ_UTILISE_TEMPLATE) {
//Appel du template n 2
include_once BAZ_CHEMIN_APPLI.'bibliotheque/bazarTemplate.class.php' ;
$template = new bazarTemplate ($GLOBALS['_BAZAR_']['db']) ;
$chaine = $template->getTemplate(2, $GLOBALS['_BAZAR_']['langue'], $GLOBALS['_BAZAR_']['categorie_nature']);
if (bazarTemplate::isError ($chaine)) return $chaine->getMessage() ;
ob_start();
eval ($chaine) ;
$res .= ob_get_contents();
ob_end_clean() ;
} else {
$res .= '<ul>' ;
$res .= '<div class="bazar_numero">'.$pager->links.'</div>'."\n";
foreach ($data as $valeur) {
$res .='<li class="BAZ_'.$valeur['bn_label_class'].'">'."\n";
$GLOBALS['_BAZAR_']['url']->addQueryString('id_fiche', $valeur['bf_id_fiche']) ;
if ($utilisateur->isSuperAdmin() || $GLOBALS['id_user']==$valeur['bf_ce_utilisateur']) {
$GLOBALS['_BAZAR_']['url']->addQueryString(BAZ_VARIABLE_ACTION, BAZ_ACTION_MODIFIER);
$GLOBALS['_BAZAR_']['url']->addQueryString('typeannonce', $valeur['bf_ce_nature']);
$GLOBALS['_BAZAR_']['url']->removeQueryString('personnes');
$GLOBALS['_BAZAR_']['url']->removeQueryString('recherche_effectuee');
$res .= '<a href="'.$GLOBALS['_BAZAR_']['url']->getURL().'">('.BAZ_MODIFIER.')</a>&nbsp;'."\n";
$GLOBALS['_BAZAR_']['url']->removeQueryString(BAZ_VARIABLE_ACTION);
$GLOBALS['_BAZAR_']['url']->addQueryString(BAZ_VARIABLE_ACTION, BAZ_ACTION_SUPPRESSION);
$res .='<a href="'.$GLOBALS['_BAZAR_']['url']->getURL().'" onclick="javascript:return confirm(\''.BAZ_SUPPRIMER.'\');">('.BAZ_SUPPRIMER.')</a>&nbsp;'."\n";
$GLOBALS['_BAZAR_']['url']->removeQueryString(BAZ_VARIABLE_ACTION);
}
$GLOBALS['_BAZAR_']['url']->addQueryString(BAZ_VARIABLE_ACTION, BAZ_VOIR_FICHE) ;
$res .= '<a href="'.$GLOBALS['_BAZAR_']['url']->getURL().'">'.$valeur['bf_titre'].'</a>'."\n";
$res .='</li>'."\n";
}
$res .= '</ul>'."\n".'<div class="bazar_numero">'.$pager->links.'</div>'."\n";
}
 
 
// Nettoyage de l'url
$GLOBALS['_BAZAR_']['url']->removeQueryString(BAZ_VARIABLE_ACTION);
$GLOBALS['_BAZAR_']['url']->removeQueryString('id_fiche');
$GLOBALS['_BAZAR_']['url']->removeQueryString('typeannonce');
$GLOBALS['_BAZAR_']['url']->removeQueryString('recherche_avancee');
 
return $res ;
}
 
function transformerTxtPourRss($txt) {
$txt_utf8 = encoderEnUtf8($txt);
$txt_utf8 = remplacerEsperluettesIsoleesParEntiteHtml($txt_utf8);
$txt_utf8 = remplacerCaracteresAsciiInvisibles($txt_utf8);
$txt_utf8 = remplacerCaracteresCp1252Problematiques($txt_utf8);
return $txt_utf8;
 
}
 
function encoderEnUtf8($txtEnIso88591) {
$txtEnUtf8 = utf8_encode($txtEnIso88591);
return $txtEnUtf8;
}
 
function remplacerEsperluettesIsoleesParEntiteHtml($txtEnUtf8) {
$txtEnUtf8 = preg_replace('/ \x{0026} /u', ' &#38; ', $txtEnUtf8);// Remplacement des & isolés
return $txtEnUtf8;
}
 
function remplacerCaracteresAsciiInvisibles($txtEnUtf8) {
$ascii_remplacements = array (
'\x00' => '', // NUL : Null (nul)
'\x01' => '', // SOH : Start of Header (début d'en-tête)
'\x02' => '', // STX : Start of Text (début du texte)
'\x03' => '', // ETX : End of Text (fin du texte)
'\x04' => '', // EOT : End of Transmission (fin de transmission)
'\x05' => '', // ENQ : Enquiry (End of Line) (demande, fin de ligne)
'\x06' => '', // ACK : Acknowledge (accusé de réception)
'\x07' => '', // BEL : Bell (caractère d'appel)
'\x08' => '', // BS : Backspace (espacement arrière)
'\x09' => ' ', // HT : Horizontal Tab (tabulation horizontale)
'\x0A' => '', // LF : Line Feed (saut de ligne)
'\x0B' => '', // VT : Vertical Tab (tabulation verticale)
'\x0C' => '', // FF : Form Feed (saut de page)
'\x0D' => '', // CR : Carriage Return (retour chariot)
'\x0E' => '', // SO : Shift Out (fin d'extension)
'\x0F' => '', // SI : Shift In (démarrage d'extension)
'\x10' => '', // DLE : Data Link Escape
'\x11' => '', // DC1 : Device Control 1 à 4 (DC1 et DC3 sont généralement utilisés pour coder XON et XOFF dans un canal de communication duplex)
'\x12' => '', // DC2 :
'\x13' => '', // DC3 :
'\x14' => '', // DC4 :
'\x15' => '', // NAK : Negative Acknowledge (accusé de réception négatif)
'\x16' => '', // SYN : Synchronous Idle
'\x17' => '', // ETB : End of Transmission Block (fin du bloc de transmission)
'\x18' => '', // CAN : Cancel (annulation)
'\x19' => '', // EM : End of Medium (fin de support)
'\x1A' => '', // SUB : Substitute (substitution)
'\x1B' => '', // ESC : Escape (échappement)
'\x1C' => '', // FS : File Separator (séparateur de fichier)
'\x1D' => '', // GS : Group Separator (séparateur de groupe)
'\x1E' => '', // RS : Record Separator (séparateur d'enregistrement)
'\x1F' => '', // US : Unit Separator (séparateur d'unité)
'\x92' => '', // Apostrophes de Windows qui puduk
'\x20' => ' '); // SP : Espace (Space en anglais)
$txtEnUtf8 = strtr($txtEnUtf8, $ascii_remplacements);
return $txtEnUtf8;
}
 
function remplacerCaracteresCp1252Problematiques($txtEnUtf8) {
$cp1252_remplacements = array (
'\xc2\x80' => '\xe2\x82\xac', // EURO SIGN
'\xc2\x82' => '\xe2\x80\x9a', // SINGLE LOW-9 QUOTATION MARK
'\xc2\x83' => '\xc6\x92', // LATIN SMALL LETTER F WITH HOOK
'\xc2\x84' => '\xe2\x80\x9e', // DOUBLE LOW-9 QUOTATION MARK
'\xc2\x85' => '\xe2\x80\xa6', // HORIZONTAL ELLIPSIS
'\xc2\x86' => '\xe2\x80\xa0', // DAGGER
'\xc2\x87' => '\xe2\x80\xa1', // DOUBLE DAGGER
'\xc2\x88' => '\xcb\x86', // MODIFIER LETTER CIRCUMFLEX ACCENT
'\xc2\x89' => '\xe2\x80\xb0', // PER MILLE SIGN
'\xc2\x8a' => '\xc5\xa0', // LATIN CAPITAL LETTER S WITH CARON
'\xc2\x8b' => '\xe2\x80\xb9', // SINGLE LEFT-POINTING ANGLE QUOTATION
'\xc2\x8c' => '\xc5\x92', // LATIN CAPITAL LIGATURE OE
'\xc2\x8e' => '\xc5\xbd', // LATIN CAPITAL LETTER Z WITH CARON
'\xc2\x91' => '\xe2\x80\x98', // LEFT SINGLE QUOTATION MARK
'\xc2\x92' => '\xe2\x80\x99', // RIGHT SINGLE QUOTATION MARK
'\xc2\x93' => '\xe2\x80\x9c', // LEFT DOUBLE QUOTATION MARK
'\xc2\x94' => '\xe2\x80\x9d', // RIGHT DOUBLE QUOTATION MARK
'\xc2\x95' => '\xe2\x80\xa2', // BULLET
'\xc2\x96' => '\xe2\x80\x93', // EN DASH
'\xc2\x97' => '\xe2\x80\x94', // EM DASH
'\xc2\x98' => '\xcb\x9c', // SMALL TILDE
'\xc2\x99' => '\xe2\x84\xa2', // TRADE MARK SIGN
'\xc2\x9a' => '\xc5\xa1', // LATIN SMALL LETTER S WITH CARON
'\xc2\x9b' => '\xe2\x80\xba', // SINGLE RIGHT-POINTING ANGLE QUOTATION*/
'\xc2\x9c' => '\xc5\x93', // LATIN SMALL LIGATURE OE
'\xc2\x9e' => '\xc5\xbe', // LATIN SMALL LETTER Z WITH CARON
'\xc2\x9f' => '\xc5\xb8'); // LATIN CAPITAL LETTER Y WITH DIAERESIS*/
$txtEnUtf8 = strtr($txtEnUtf8, $cp1252_remplacements);
return $txtEnUtf8;
}
 
function subtext($text, $offset = 500) {
preg_match('!.{0,'.$offset.'}\s!si', $text, $match);
return $match[0].'...';
}
 
/* +--Fin du code ----------------------------------------------------------------------------------------+
*
* $Log: not supported by cvs2svn $
* Revision 1.99.2.13 2008-04-16 12:39:56 alexandre_tb
* simplification du code en utilisant la classe Bazar_element
*
* Revision 1.99.2.12 2008-03-17 14:02:53 jp_milcent
* Ajout d'un message demandant de s'identifiez pour poser des commentaires.
* Amélioration du XHTML (me prévenir en cas de pb).
*
* Revision 1.99.2.11 2008-03-17 11:03:02 jp_milcent
* Ajout de l'authentification nécessaire pour déposer des commentaires.
* Corrections sur la gestion des paramêtres dans les urls (compatibilité applette Identification et Moteur de Recherche).
*
* Revision 1.99.2.10 2008-02-04 13:03:09 alexandre_tb
* ajout d un class css dans les h2
*
* Revision 1.99.2.9 2008-02-01 16:24:10 florian
* ajout champs_mail, décommenter les traductions des javascripts
*
* Revision 1.99.2.8 2008-01-29 09:35:37 alexandre_tb
* remplacement des variables action par une constante
* Utilisation d un redirection pour eviter que les formulaires soient valides 2 fois
* simplification de la suppression d un lien associe a une liste
*
* Revision 1.99.2.7 2008-01-11 14:09:17 alexandre_tb
* Remplacement de la variable action ecrite en dur par la constante BAZ_VARIABLE_ACTION
*
* Revision 1.99.2.6 2007-12-14 15:55:38 alexandre_tb
* les commentaires peuvent maintenant apparaitre dans le moteur de recherche et dans les fiches, il faut mettre a 1 respectivement le champs recherche et obligatoire
*
* Revision 1.99.2.5 2007-12-10 12:57:34 jp_milcent
* Correction du problèmes des & non remplacées par des &amp;
*
* Revision 1.99.2.4 2007-12-04 08:58:26 alexandre_tb
* modification de styles dans les formulaires
*
* Revision 1.99.2.3 2007-12-03 15:16:21 jp_milcent
* Correction problème de la div mystère!
*
* Revision 1.99.2.2 2007-11-30 15:02:50 alexandre_tb
* simplification du code et correction du bug (les fiches de la carto n affichent pas la bonne nature
*
* Revision 1.99.2.1 2007-11-30 14:14:36 jp_milcent
* Ajout d'un décodage des apostrophes de type RIGHT SINGLE QUOTATION MARK.
*
* Revision 1.99 2007-11-05 10:17:19 alexandre_tb
* correction bug: retrait inorportun de la variable menu dans la globale URL
*
* Revision 1.98 2007-10-24 13:27:45 alexandre_tb
* bug d'affichage multiple lorsqu'il y a +sieurs langues
*
* Revision 1.97 2007-10-24 08:56:27 alexandre_tb
* bug d'affichage multiple lorsqu'il y a +sieurs langues
*
* Revision 1.96 2007-10-22 10:09:21 florian
* correction template
*
* Revision 1.95 2007-10-22 09:22:02 alexandre_tb
* prise en compte de la langue dans les requetes sur bazar_nature
*
* Revision 1.94 2007-10-10 13:26:00 alexandre_tb
* utilisation de la classe Administrateur_bazar a la place de niveau_droit
*
* Revision 1.93 2007-10-01 11:59:51 alexandre_tb
* cosmetique d affichage de la date de l evenement
*
* Revision 1.92 2007-09-28 15:02:43 jp_milcent
* Suppression d'une div fermante jamais ouverte!
*
* Revision 1.91 2007-09-28 14:43:29 jp_milcent
* Correction bogue sur la gestion du mail des rédacteurs.
*
* Revision 1.90 2007-09-28 13:39:15 jp_milcent
* Ajout d'une constante permettant de configurer l'affichage ou pas du courriel du rédacteur d'une fiche.
*
* Revision 1.89 2007-09-18 07:38:43 alexandre_tb
* ajout de la constante BAZ_AFFICHER_FILTRE_MOTEUR pour enlever le choix du type de fiche dans le moteur de recherche.
*
* Revision 1.88 2007-08-27 12:32:14 alexandre_tb
* suppression de un notice
*
* Revision 1.87 2007-07-05 08:27:35 alexandre_tb
* dans le flux ajout utf8_encode pour la description et le titre des flux
*
* indentation du code, et correction bug lorsque plusieurs catégories nature étaient demandé lors de consultation de fiche.
*
* Revision 1.86 2007-07-04 10:02:42 alexandre_tb
* deplacement d une balise <ul> dans la liste des resultats pour conformite xhtml
*
* Revision 1.85 2007-06-25 12:15:06 alexandre_tb
* merge from narmer
*
* Revision 1.84 2007-06-25 09:56:55 alexandre_tb
* correction de bug
*
* Revision 1.83 2007-06-04 15:26:02 alexandre_tb
* remplacement d un die en return
*
* Revision 1.82 2007/04/20 12:47:42 florian
* correction bugs suite au merge
*
* Revision 1.81 2007/04/20 09:59:41 florian
* et un echo en moins!
*
* Revision 1.80 2007/04/20 09:57:21 florian
* correction bugs suite au merge
*
* Revision 1.79 2007/04/19 14:57:41 alexandre_tb
* merge
*
* Revision 1.77 2007/04/04 15:15:22 neiluj
* débug pour nom wiki
*
* Revision 1.76 2007/04/04 15:09:59 florian
* modif class fichiers
*
* Revision 1.75 2007/04/04 08:51:01 florian
* gestion des classes spécifiques pour habiller par CSS les fiches bazar
*
* Revision 1.74 2007/03/28 15:54:32 florian
* correction de bugs
*
* Revision 1.73 2007/03/28 10:01:47 florian
* ajout de la constante BAZ_UTILISE_TEMPLATE, pour utiliser ou non les templates pour l'affichage du moteur de recherche
*
* Revision 1.72 2007/03/28 08:51:22 neiluj
* passage des flux RSS en UTF-8
* ajout de l'indentation du code
* Vérification validation w3c = OK
*
* Revision 1.71 2007/03/19 15:17:37 alexandre_tb
* correction de la requete de recherche
*
* Revision 1.70 2007/03/08 15:12:13 jp_milcent
* Fusion avec la livraison Menes : 08 mars 2007
*
* Revision 1.60.2.11 2007/03/07 17:20:19 jp_milcent
* Ajout du nettoyage systématique des URLs.
*
* Revision 1.60.2.10 2007/03/06 09:41:15 alexandre_tb
* backport de corrections de bugs de la branche principale
*
* Revision 1.69 2007/03/06 09:39:00 alexandre_tb
* correction de bug sur les jointures et sur les flux rss
*
* Revision 1.68 2007/03/05 10:27:06 alexandre_tb
* ajout d identifiant dans les span qui affiche le detail d une fiche.
* ajout d un modele pour les fiches -> du code a ete deplace dans
* bazar_template
*
* Revision 1.67 2007/02/28 10:18:56 alexandre_tb
* backport de bug depuis la 1.60 de menes
*
* Revision 1.60.2.9 2007/02/27 15:32:40 alexandre_tb
* utilisation de la fonction xmlEntities pour transformer les &amp; en &#...;
* fixe les plantages des flux rss lorsque des guillemets ou des esperluettes étaient présents
*
* Revision 1.60.2.8 2007/02/27 15:11:00 alexandre_tb
* correction d une jointure dans la requete pour les flux rss
* utilisation de la librairie XML_Util de pear pour generer le flux RSS -> plus clair
*
* Revision 1.60.2.7 2007/02/15 17:39:00 jp_milcent
* Remise dans le code d'un bogue...
* A corriger!
*
* Revision 1.60.2.6 2007/02/15 13:42:16 jp_milcent
* Utilisation de IN à la place du = dans les requêtes traitant les catégories de fiches.
* Permet d'utiliser la syntaxe 1,2,3 dans la configuration de categorie_nature.
*
* Revision 1.64 2007/02/02 14:00:41 alexandre_tb
* mise en place d'un template pour l'affichage du moteur de recherche
*
* Revision 1.60.2.5 2007/02/02 13:46:54 alexandre_tb
* correction bug sur une date
*
* Revision 1.60.2.4 2007/01/30 15:45:01 alexandre_tb
* affichage de la date de création e la fiche lorsque la date de début de validité n'est plus bonne
*
* Revision 1.60.2.3 2007/01/29 10:53:46 alexandre_tb
* Mise en place de la constante BAZ_DERNIERES_FICHES pour remplacer le label en francais dans baz_liste
*
* Revision 1.63 2007/01/18 14:37:34 alexandre_tb
* backport
* les dates ne s'affichent pas si elles sont vides.
* les champs dates propose 4 années avant l'année actuelle
*
* Revision 1.60.2.2 2007/01/17 16:01:27 alexandre_tb
* les dates ne s'affichent pas si elles sont vides.
* les champs dates propose 4 années avant l'année actuelle
*
* Revision 1.60.2.1 2007/01/05 14:41:49 alexandre_tb
* backport ordre d affichage des dernieres news et suppression de la taille des images uploadees
*
* Revision 1.60 2006/10/05 08:53:50 florian
* amelioration moteur de recherche, correction de bugs
*
* Revision 1.59 2006/09/21 14:19:39 florian
* amélioration des fonctions liés au wikini
*
* Revision 1.58 2006/09/15 12:31:40 alexandre_tb
* correction du nom du flux RSS.
*
* Revision 1.57 2006/07/25 13:22:27 alexandre_tb
* réorganisation du code, sans grand changement
*
* Revision 1.56 2006/07/18 14:13:35 alexandre_tb
* Ajout d identifiant HTML
*
* Revision 1.55 2006/07/04 14:29:18 alexandre_tb
* Ajout du bouton supprimer pour les administrateurs
*
* Revision 1.54 2006/07/03 09:51:21 alexandre_tb
* correction du bug recherche sur fiches validés et invalidés.
*
* Revision 1.53 2006/06/29 10:29:51 florian
* correction bug moteur de recherche
*
* Revision 1.52 2006/06/02 09:29:07 florian
* debut d'integration de wikini
*
* Revision 1.51 2006/05/23 15:41:27 alexandre_tb
* ajout de la numérotation des pages en haut et en bas ds résultats et ajout d'une div class=bazar_numero pour les entourer
*
* Revision 1.50 2006/05/22 09:55:12 alexandre_tb
* ajout de la variable recherche_avancee dans l'action du formulaire
*
* Revision 1.49 2006/05/19 13:54:11 florian
* stabilisation du moteur de recherche, corrections bugs, lien recherche avancee
*
* Revision 1.48 2006/05/17 09:50:13 alexandre_tb
* Ajout du moteur de recherche évolué et du découpage par page
*
* +-- Fin du code ----------------------------------------------------------------------------------------+
*/
?>
/tags/v3.1-blanche-neige/bibliotheque/bazarTemplate.class.php
New file
0,0 → 1,87
<?php
/*vim: set expandtab tabstop=4 shiftwidth=4: */
// +------------------------------------------------------------------------------------------------------+
// | PHP version 4.1 |
// +------------------------------------------------------------------------------------------------------+
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org) |
// +------------------------------------------------------------------------------------------------------+
// | This library is free software; you can redistribute it and/or |
// | modify it under the terms of the GNU General Public |
// | License as published by the Free Software Foundation; either |
// | version 2.1 of the License, or (at your option) any later version. |
// | |
// | This library is distributed in the hope that it will be useful, |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
// | General Public License for more details. |
// | |
// | You should have received a copy of the GNU General Public |
// | License along with this library; if not, write to the Free Software |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
// +------------------------------------------------------------------------------------------------------+
 
// CVS : $Id: bazarTemplate.class.php,v 1.7 2008-10-29 15:44:02 alexandre_tb Exp $
 
/**
* Application projet
*
* La classe d acces aux templates du bazar
*
*@package bazar
//Auteur original :
*@author Alexandre Granier <alexandre@tela-botanica.org>
//Autres auteurs :
*@author Aucun
*@copyright Tela-Botanica 2000-2004
*@version $Revision: 1.7 $
// +------------------------------------------------------------------------------------------------------+
*/
 
// +------------------------------------------------------------------------------------------------------+
// | ENTETE du PROGRAMME |
// +------------------------------------------------------------------------------------------------------+
 
include_once PAP_CHEMIN_API_PEAR.'PEAR.php' ;
 
// +------------------------------------------------------------------------------------------------------+
// | CONSTANTE DES TEMPLATES |
// +------------------------------------------------------------------------------------------------------+
 
define ('BAZ_TEMPLATE_CONSULTER', 1); // Squelette de l onglet "consulter"
define ('BAZ_TEMPLATE_LISTE_DES_FICHES', 2); // Modele de la liste des fiches
 
define ('BAZ_TEMPLATE_MAIL_NOUVELLE_FICHE_SUJET', 3); // Modele du mail pour prevenir les admins d une nouvelle fiche (sujet)
define ('BAZ_TEMPLATE_MAIL_NOUVELLE_FICHE_CORPS', 4); // Modele du mail pour prevenir les admins d une nouvelle fiche (corps)
 
define ('BAZ_TEMPLATE_MESSAGE_LOGIN', 5); // Modele du message lorsque l utilisateur n est pas logue
 
define ('BAZ_TEMPLATE_ACCUEIL_CARTE_GOOGLE', 6); // Modele de la page d accueil de l appli bazar.carte_google.php
define ('BAZ_TEMPLATE_FORMULAIRE_ACCUEIL', 7); // Modele, de la page saisie formulaire ou l'on choisit le type de fiche a saisir
 
define ('BAZ_TEMPLATE_FORMULAIRE', 8); // Modele du formulaire (different de celui ci-dessus)
 
define ('BAZ_TEMPLATE_MAIL_MODIFIER_FICHE_SUJET', 9); // Modele du mail pour prevenir les admins d une modification de fiche (sujet)
define ('BAZ_TEMPLATE_MAIL_MODIFIER_FICHE_CORPS', 10); // Modele du mail pour prevenir les admins d une modification de fiche (corps)
 
class bazarTemplate extends PEAR {
 
 
var $_db ;
function bazarTemplate(&$objetDB) {
$this->_db = $objetDB ;
}
function getTemplate ($id_template, $lang='fr-FR', $categorie_nature = 'toutes') {
$requete = 'select bt_template from bazar_template where bt_id_template='.$id_template.
' and bt_id_i18n like "'.$lang.'%" ' ;
$resultat = $this->_db->query($requete) ;
if (DB::isError($resultat)) return $this->raiseError ($resultat->getMessage().'<br />'.$resultat->getDebugInfo()) ;
if ($resultat->numRows() == 0) return $this->raiseError ('Aucun template avec l\'identifiant: '.$id_template.
' et la langue: '.$lang.'<br />'.$requete) ;
$ligne = $resultat->fetchRow (DB_FETCHMODE_OBJECT) ;
 
return $ligne->bt_template ;
}
}
?>
/tags/v3.1-blanche-neige/bibliotheque/bazar.fonct.formulaire.controles.php
New file
0,0 → 1,51
<?php
/*vim: set expandtab tabstop=4 shiftwidth=4: */
// +------------------------------------------------------------------------------------------------------+
// | PHP version 4.1 |
// +------------------------------------------------------------------------------------------------------+
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org) |
// +------------------------------------------------------------------------------------------------------+
// | This library is free software; you can redistribute it and/or |
// | modify it under the terms of the GNU Lesser General Public |
// | License as published by the Free Software Foundation; either |
// | version 2.1 of the License, or (at your option) any later version. |
// | |
// | This library is distributed in the hope that it will be useful, |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
// | Lesser General Public License for more details. |
// | |
// | You should have received a copy of the GNU Lesser General Public |
// | License along with this library; if not, write to the Free Software |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
// +------------------------------------------------------------------------------------------------------+
// CVS : $Id: bazar.fonct.formulaire.controles.php,v 1.1 2005-11-07 17:05:45 florian Exp $
/**
* Formulaire controles
*
* Les fonctions de controles de saisie des formulaires
*
*@package bazar
//Auteur original :
*@author Florian SCHMITT <florian@ecole-et-nature.org>
*@copyright Tela-Botanica 2000-2004
*@version $Revision: 1.1 $ $Date: 2005-11-07 17:05:45 $
// +------------------------------------------------------------------------------------------------------+
*/
 
//-------------------FONCTIONS DE MISE EN PAGE DES FORMULAIRES
 
/** liste_choisir() - Teste si une valeur à été choisie pour une liste
*
*
*/
function liste_choisir($element_name,$element_value) {
if ($element_value == 0) {
return false;
}
else {
return true;
}
}
 
?>
/tags/v3.1-blanche-neige/bibliotheque/bazar.fonct.google.php
New file
0,0 → 1,162
<?php
/*vim: set expandtab tabstop=4 shiftwidth=4: */
// +------------------------------------------------------------------------------------------------------+
// | PHP version 4.1 |
// +------------------------------------------------------------------------------------------------------+
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org) |
// +------------------------------------------------------------------------------------------------------+
// | This library is free software; you can redistribute it and/or |
// | modify it under the terms of the GNU Lesser General Public |
// | License as published by the Free Software Foundation; either |
// | version 2.1 of the License, or (at your option) any later version. |
// | |
// | This library is distributed in the hope that it will be useful, |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
// | Lesser General Public License for more details. |
// | |
// | You should have received a copy of the GNU Lesser General Public |
// | License along with this library; if not, write to the Free Software |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
// +------------------------------------------------------------------------------------------------------+
// CVS : $Id: bazar.fonct.google.php,v 1.1 2007-06-04 15:24:00 alexandre_tb Exp $
/**
* Formulaire
*
* Les fonctions et script specifique a un carto google
*
*@package bazar
//Auteur original :
*@author Aleandre GRANIER <alexandre@tela-botanica.org>
*@copyright Tela-Botanica 2000-2007
*@version $Revision: 1.1 $
// +------------------------------------------------------------------------------------------------------+
*/
 
$script = '
// Variables globales
var map = null;
var geocoder = null;
var marker = null;
var flat = null;
var flon = null;
 
// cette fonction peut d�j� �tre pr�sente
// fonction portable pour ajout de listeners
function addListener(element, baseName, handler)
{
if (element.addEventListener) {
element.addEventListener(baseName, handler, false) ;
} else if (element.attachEvent) {
element.attachEvent(\'on\'+baseName, handler) ;
}
}
addListener(window,\'load\',loadMap) ;
function loadMap() {
flat = document.getElementById("latitude");
flon = document.getElementById("longitude");
 
var optionsGoogleMapsv3 = {
// On centre la carte sur le languedoc roussillon
center: new google.maps.LatLng(43.84245116699036, 3.768310546875),
zoom: 7,
mapTypeId: google.maps.MapTypeId.G_HYBRID_MAP,
mapTypeControl: true,
scaleControl: true
};
map = new google.maps.Map(document.getElementById("map"), optionsGoogleMapsv3);
 
google.maps.event.addListener(map, "click", function(event) {
if (marker != null) {
marker.setMap(null);
marker = null;
}
// On ajoute un marqueur a l endroit du clic et on place les coordonnees dans les champs latitude et longitude
marker = event.overlay;
marker = new google.maps.Marker({
position: event.latLng,
draggable: true,
map: map
});
google.maps.event.addListener(marker, "dragend", function () {
coordMarker = marker.getPosition() ;
flat.value = coordMarker.lat();
flon.value = coordMarker.lng();
});
setLatLonForm(marker);
});';
if ($formtemplate->getElementValue ('latitude') != '' && $formtemplate->getElementValue('longitude') != '') {
$script .= '
point = new google.maps.LatLng('.$formtemplate->getElementValue('latitude').', '.$formtemplate->getElementValue('longitude').');
marker = new google.maps.Marker({
position: point,
draggable: true,
map: map
});
google.maps.event.addListener(marker, "dragend", function () {
coordMarker = marker.getPosition() ;
flat.value = coordMarker.lat();
flon.value = coordMarker.lng();
});
map.setCenter(point);
' ;
}
$script .= 'geocoder = new google.maps.Geocoder();
};
function showAddress() {
var adresse = document.getElementById("bf_adresse").value;
var ville = "";
if (document.getElementById("bf_ville")) {
ville = document.getElementById("bf_ville").value ;
}
var cp = document.getElementById("bf_cp_lieu_evenement").value ;
var pays;
if (document.getElementById("liste30")) {
var selectIndex = document.getElementById("liste30").selectedIndex;
pays = document.getElementById("liste30").options[selectIndex].text ;
} else {
pays = document.getElementById("bf_pays").value;
}
var address = adresse + \' \' + \' \' + cp + \' \' + ville + \' \' +pays ;
if (geocoder) {
geocoder.geocode({
address: address
}, function(result, status) {
if (status != google.maps.GeocoderStatus.OK) {
alert(address + " not found");
} else {
marker.setMap(null);
marker = null;
//map.setCenter(point, 13);
map.fitBounds(result[0].geometry.viewport);
marker = new google.maps.Marker({
position: result[0].geometry.location,
draggable: true,
map: map
});
google.maps.event.addListener(marker, "dragend", function () {
coordMarker = marker.getPosition() ;
flat.value = coordMarker.lat();
flon.value = coordMarker.lng();
});
setLatLonForm(marker);
//marker.openInfoWindowHtml(address+ "'.BAZ_GOOGLE_MSG.'");
}
});
}
}
function setLatLonForm(marker) {
coordMarker = marker.getPosition() ;
flat.value = coordMarker.lat();
flon.value = coordMarker.lng();
}
';
 
 
 
/*
* +--Fin du code ----------------------------------------------------------------------------------------+
*
* $Log: not supported by cvs2svn $
* +-- Fin du code ----------------------------------------------------------------------------------------+
*/
/tags/v3.1-blanche-neige/bibliotheque/bazar.class.php
New file
0,0 → 1,479
<?php
/*vim: set expandtab tabstop=4 shiftwidth=4: */
// +------------------------------------------------------------------------------------------------------+
// | PHP version 4.1 |
// +------------------------------------------------------------------------------------------------------+
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org) |
// +------------------------------------------------------------------------------------------------------+
// | This library is free software; you can redistribute it and/or |
// | modify it under the terms of the GNU Lesser General Public |
// | License as published by the Free Software Foundation; either |
// | version 2.1 of the License, or (at your option) any later version. |
// | |
// | This library is distributed in the hope that it will be useful, |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
// | Lesser General Public License for more details. |
// | |
// | You should have received a copy of the GNU Lesser General Public |
// | License along with this library; if not, write to the Free Software |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
// +------------------------------------------------------------------------------------------------------+
// CVS : $Id: bazar.class.php,v 1.10 2008-09-17 14:08:45 alexandre_tb Exp $
/**
*
*@package bazar
//Auteur original :
*@author Alexandre GRANIER <alexandre@tela-botanica.org>
*@author Florian Schmitt <florian@ecole-et-nature.org>
*@copyright Tela-Botanica 2000-2004
*@version $Revision: 1.10 $
// +------------------------------------------------------------------------------------------------------+
*/
 
// +------------------------------------------------------------------------------------------------------+
// | LES CONSTANTES DES NIVEAUX DE DROIT |
// +------------------------------------------------------------------------------------------------------+
 
define ('BAZ_DROIT_SUPER_ADMINISTRATEUR', 0);
define ('BAZ_DROIT_ADMINISTRATEUR', 2);
define ('BAZ_DROIT_REDACTEUR', 1);
 
// +------------------------------------------------------------------------------------------------------+
// | ENTETE du PROGRAMME |
// +------------------------------------------------------------------------------------------------------+
 
include_once PAP_CHEMIN_API_PEAR.'PEAR.php';
include_once BAZ_CHEMIN_APPLI.'bibliotheque/bazarTemplate.class.php';
 
class Administrateur_bazar {
 
var $_auth ;
/**
* Identifiant de l'utilisateur
*/
var $_id_utilisateur ;
 
/**
* Vaut true si l'utilisateur est un administrateur
*/
var $_isSuperAdmin ;
/** Constructeur
*
* @param object Un objet authentification
* @return void
*
*/
function Administrateur_bazar (&$AUTH) {
$this->_auth = $AUTH ;
if ($AUTH->getAuth())$this->_id_utilisateur = $this->_auth->getAuthData(BAZ_CHAMPS_ID) ;
}
/** isSuperAdmin () - Renvoie true si l'utilisateur est un super administrateur
*
*/
function isSuperAdmin() {
if(empty($this->_id_utilisateur))
return FALSE;
// On court-circuite si la question a d�j� �t� pos� pour ne pas refaire la requete
if (isset ($this->_isSuperAdmin)) return $this->_isSuperAdmin ;
// On court-circuite si l'utilisateur n'est pas loggu�
if (!$this->_auth->getAuth()) return false ;
// Sinon on interroge la base
$requete = 'SELECT bd_niveau_droit FROM bazar_droits WHERE bd_id_utilisateur='.
$this->_id_utilisateur.
' AND bd_niveau_droit=0';
 
$resultat = $GLOBALS['_BAZAR_']['db']->query ($requete) ;
if (DB::isError($resultat)) {
return ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ;
}
if ($resultat->numRows() != 0) {
$this->_isSuperAdmin = true ;
} else {
$this->_isSuperAdmin = false ;
}
return $this->_isSuperAdmin;
}
/** isAdmin () - Renvoie true si l'utilisateur est administrateur du type de fiche sp�cifi�
*
* @param interger type_annonce Le type de l'annonce
*
*/
function isAdmin($id_nature) {
// on court-circuite si l'utilisateur n'est pas loggu�
if (!$this->_auth->getAuth()) return false ;
return $this->_requeteDroit ($id_nature, 2) ;
}
/** isRedacteur() - Renvoie true si l'utilisateur est redacteur du type de fiche specifie
*
*/
function isRedacteur($id_nature) {
if (isset($GLOBALS['droit_depot']) && $GLOBALS['droit_depot'] == 3) return true;
return $this->_requeteDroit ($id_nature, 1) ;
}
/** _requeteDroit() - fait une requete sur la table bazar_droit
*
*/
function _requeteDroit ($id_nature, $niveau) {
if(empty($this->_id_utilisateur))
return false;
$requete = 'SELECT bd_niveau_droit FROM bazar_droits WHERE bd_id_utilisateur='
.$this->_id_utilisateur.
' AND bd_id_nature_offre="'.$id_nature.'"and bd_niveau_droit='.$niveau;
$resultat = $GLOBALS['_BAZAR_']['db']->query ($requete) ;
if (DB::isError($resultat)) {
return ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ;
}
if ($resultat->numRows() != 0) {
return true ;
}
return false ;
}
}
 
class Utilisateur_bazar extends Administrateur_bazar {
function Utilisateur_bazar($id_utilisateur) {
$this->_id_utilisateur = $id_utilisateur ;
}
function isAdmin($id_nature) {
return $this->_requeteDroit ($id_nature, 2) ;
}
/** isSuperAdmin () - Renvoie true si l'utilisateur est un super administrateur
*
*/
function isSuperAdmin() {
if(empty($this->_id_utilisateur))
return false;
// On court-circuite si la question a d�j� �t� pos� pour ne pas refaire la requete
if (isset ($this->_isSuperAdmin)) return $this->_isSuperAdmin ;
// Sinon on interroge la base
$requete = 'SELECT bd_niveau_droit FROM bazar_droits WHERE bd_id_utilisateur='.
$this->_id_utilisateur.
' AND bd_niveau_droit=0';
 
$resultat = $GLOBALS['_BAZAR_']['db']->query ($requete) ;
if (DB::isError($resultat)) {
return ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ;
}
if ($resultat->numRows() != 0) {
$this->_isSuperAdmin = true ;
} else {
$this->_isSuperAdmin = false ;
}
return $this->_isSuperAdmin;
}
}
 
 
 
define ('BAZAR_NOTIFICATION_NOUVELLE_FICHE', 1);
define ('BAZAR_NOTIFICATION_MODIFICATION_FICHE', 2);
 
 
class bazar extends PEAR {
/**
* getMailAdmin Renvoie un tableau de mail des administrateurs du type
* de fiche passe en parametre
*
* @global DB Un objet DB de PEAR $GLOBALS['_BAZAR_']['db']
* @param integer L identifiant de la nature
*/
function getMailAdmin($id_nature) {
$requete = 'select '.BAZ_CHAMPS_EMAIL.' from '.BAZ_ANNUAIRE.', bazar_droits ' .
'where bd_id_nature_offre="'.$id_nature.'" and bd_niveau_droit="'.BAZ_DROIT_ADMINISTRATEUR.'"' .
' and '.BAZ_CHAMPS_ID.'= bd_id_utilisateur';
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete);
if (DB::isError($resultat)) $this->raiseError();
$tableau_mail = array();
if ($resultat->numRows() == 0) return false;
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
array_push ($tableau_mail, $ligne[BAZ_CHAMPS_EMAIL]) ;
}
return $tableau_mail;
}
/**
* getMailAdmin Renvoie un tableau de mail des super administrateurs
*
* @global DB Un objet DB de PEAR $GLOBALS['_BAZAR_']['db']
*/
function getMailSuperAdmin() {
$requete = 'select '.BAZ_CHAMPS_EMAIL.' from '.BAZ_ANNUAIRE.', bazar_droits ' .
'where bd_niveau_droit="'.BAZ_DROIT_SUPER_ADMINISTRATEUR.'"' .
' and '.BAZ_CHAMPS_ID.'= bd_id_utilisateur';
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete);
if (DB::isError($resultat)) $this->raiseError();
$tableau_mail = array();
if ($resultat->numRows() == 0) return false;
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
array_push ($tableau_mail, $ligne[BAZ_CHAMPS_EMAIL]) ;
}
return $tableau_mail;
}
/**
* notifier() envoie un message aux administrateurs
*
* par defaut lors du depot ou de la modification d une fiche
*/
function notifier($type = BAZAR_NOTIFICATION_NOUVELLE_FICHE) {
switch ($type) {
case BAZAR_NOTIFICATION_NOUVELLE_FICHE :
$id_sujet = BAZ_TEMPLATE_MAIL_NOUVELLE_FICHE_SUJET;
$id_corps = BAZ_TEMPLATE_MAIL_NOUVELLE_FICHE_CORPS;
break ;
case BAZAR_NOTIFICATION_MODIFICATION_FICHE :
$id_sujet = BAZ_TEMPLATE_MAIL_MODIFIER_FICHE_SUJET;
$id_corps = BAZ_TEMPLATE_MAIL_MODIFIER_FICHE_CORPS;
break;
}
$template = new bazarTemplate($GLOBALS['_BAZAR_']['db']);
 
$sujet = html_entity_decode($template->getTemplate($id_sujet, $GLOBALS['_BAZAR_']['langue'], $GLOBALS['_BAZAR_']['id_typeannonce']));
$corps = html_entity_decode($template->getTemplate($id_corps, $GLOBALS['_BAZAR_']['langue'], $GLOBALS['_BAZAR_']['id_typeannonce']));
$corps.= $GLOBALS['_BAZAR_']['id_fiche'].'&typeannonce='.$GLOBALS['_BAZAR_']['id_typeannonce'] ;
$mails = bazar::getMailSuperAdmin($GLOBALS['_BAZAR_']['id_typeannonce']);
if (is_array ($mails)) {
foreach ($mails as $mail) {
mail ($mail, $sujet, $corps);
}
}
}
/** Effectue une requete sur bazar_nature pour remplir diverses
* globales
*
* @global string la globale de langue (ex fr-FR)
* @global int $GLOBALS['_BAZAR_']['id_typeannonce']
*
* @return mixed true ou PEAR_Error
*/
function chargeNature() {
$requete = 'SELECT bn_label_nature, bn_condition, bn_template, bn_commentaire, bn_appropriation, bn_image_titre, bn_image_logo';
$requete .= ' FROM bazar_nature WHERE bn_id_nature = '.$GLOBALS['_BAZAR_']['id_typeannonce'];
if (isset($GLOBALS['_BAZAR_']['langue'])) {
$requete .= ' and bn_ce_i18n like "'.$GLOBALS['_BAZAR_']['langue'].'%"';
}
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
if (DB::isError($resultat)) {
return $resultat->getMessage().$resultat->getDebugInfo() ;
}
$ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC);
$GLOBALS['_BAZAR_']['typeannonce']=$ligne['bn_label_nature'];
$GLOBALS['_BAZAR_']['condition']=$ligne['bn_condition'];
$GLOBALS['_BAZAR_']['template']=$ligne['bn_template'];
$GLOBALS['_BAZAR_']['commentaire']=$ligne['bn_commentaire'];
$GLOBALS['_BAZAR_']['appropriation']=$ligne['bn_appropriation'];
$GLOBALS['_BAZAR_']['image_titre']=$ligne['bn_image_titre'];
$GLOBALS['_BAZAR_']['image_logo']=$ligne['bn_image_logo'];
return true;
}
/** Renvoie un element de formulaire de type select ou radio
* au vue de filtrer les resultats du bazar
* @global mixed $GLOBALS['_BAZAR_']['db'] identifiant de connexion a la bd
*
* @return string html
*/
function getFiltre($numero_liste, $multiple = false, $type = 'select') {
$type == 'select' ? $balise = 'select' : $balise = 'radio' ;
// chargement du template
$tableau_template = baz_valeurs_template($GLOBALS['_BAZAR_']['template']);
$html_filtre = '<select name="bazar_filtre_'.$numero_liste.'" onchange="javascript:this.form.submit();">'."\n";
// Requete dans bazar_liste_valeurs
$requete = 'select blv_valeur, blv_label from bazar_liste_valeurs where blv_ce_liste="'.$numero_liste.'"';
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete);
if (DB::isError($resultat)) {
return $resultat->getMessage().$resultat->getDebugInfo() ;
}
$html_filtre .= '<option id="filtre_tous" value="*" ';
if (isset($_POST['bazar_filtre_'.$numero_liste]) && '*' == $_POST['bazar_filtre_'.$numero_liste]) {
$html_filtre .= 'selected="selected" ';
}
$html_filtre .= '>'.'Tous les événements'.'</option>';
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_OBJECT)) {
$html_filtre .= '<option class="filtre_'.$ligne->blv_valeur.'" value="'.$ligne->blv_valeur.'"';
if (isset($_POST['bazar_filtre_'.$numero_liste]) && $ligne->blv_valeur == $_POST['bazar_filtre_'.$numero_liste]) {
$html_filtre .= 'selected="selected" ';
}
$html_filtre .= '>'.$ligne->blv_label.'</option>'."\n";
}
$html_filtre .= '</select>'."\n";
$resultat->free();
return $html_filtre;
}
function getFiltrePlageDeDate () {
if (isset ($_POST['date_debut'])) {
$defaut_debut = $_POST['date_debut'];
} else {
$defaut_debut = '';
}
if (isset ($_POST['date_fin'])) {
$defaut_fin = $_POST['date_fin'];
} else {
$defaut_fin = '';
}
 
$formulaire_filtre = 'du <input type="text" readonly size="10" name="date_debut" class="inputDate" id="date_debut" value="'.$defaut_debut.'" />';
$formulaire_filtre .= ' au <input type="text" readonly size="10" name="date_fin" class="inputDate" id="date_fin" value="'.$defaut_fin.'" />';
$formulaire_filtre .= "\n".'<script language="javascript" type="text/javascript">' ."\n".
'
if (typeof(addListener) != \'function\') {
// fonction portable pour ajout de listeners
function addListener(element, baseName, handler)
{
if (element.addEventListener) {
element.addEventListener(baseName, handler, false) ;
} else if (element.attachEvent) {
element.attachEvent(\'on\'+baseName, handler) ;
}
}
}
function verifDate()
{
if (document.getElementById("date_debut") != null && document.getElementById("date_fin") != null) {
this.form.submit() ;
}
}
var calDateFin = document.getElementById("date_fin") ;
addListener(calDateFin,\'change\',verifDate) ;
var calDateDeb = document.getElementById("date_debut") ;
addListener(calDateDeb,\'change\',verifDate) ;
$(document).ready(function() { $(\'#date_debut, #date_fin\').datepicker($.extend({}, $.datepicker.regional["fr-FR"],{
dateFormat:\'dd-mm-yy\',
buttonImage: "client/bazar/images/cal.png",
showOn: "both",
beforeShow: customRange,
buttonImageOnly: true'."\n".
'}));})' ."\n".
'function customRange(input) { return {minDate: (input.id == "date_fin" ? $("#date_debut").datepicker("getDate") : null),
maxDate: (input.id == "date_debut" ? $("#date_fin").datepicker("getDate") : null)};}' ."\n".
'</script>';
 
return $formulaire_filtre;
}
/** Renvoie le formulaire d un filtre
* utile dans la carte google ou dans le calendrier
*
* @param string le template avec des filtres ecrits comme {filtre liste="12"}
* @global mixed $GLOBALS['_BAZAR_']['url']
* @return string html
*/
function getFormulaireFiltre($template) {
if (preg_match_all ('/{filtre liste="([0-9]+)"}/', $template, $subpattern)) {
$formulaire_filtre = '<form action="'.$GLOBALS['_BAZAR_']['url']->getURL().'" method="post">'."\n";
$formulaire_filtre .= '<fieldset><legend>Filtrer : </legend>';
for ($i = 0; $i <count($subpattern[1]); $i++) {
$formulaire_filtre .= bazar::getFiltre($subpattern[1][$i]) ;
}
$formulaire_filtre .= bazar::getFiltrePlageDeDate();
$formulaire_filtre .= '<input type="submit" value="Filtrer" />';
$formulaire_filtre .= '</fieldset>';
$formulaire_filtre .= '</form>'."\n";
$html = preg_replace ('/{filtre liste="([0-9]+)"}/', $formulaire_filtre, $template);
}
return $html;
}
}
 
class Bazar_element {
function &factory($type, $options = false)
{
if (file_exists (BAZ_CHEMIN_APPLI."bibliotheque/elements/{$type}.php")) include_once BAZ_CHEMIN_APPLI."bibliotheque/elements/{$type}.php";
else return PEAR::raiseError("Impossible d inclure le fichier /{$type}.php", "Impossible d inclure le fichier ".
BAZ_CHEMIN_APPLI."bibliotheque/elements/{$type}.php<br />", null, null,
"Impossible d inclure le fichier /{$type}.php"
, 'PEAR_Error', true);;
$classname = "Bazar_{$type}";
 
if (!class_exists($classname)) {
$tmp = PEAR::raiseError(null, -2, null, null,
"la classe $classname n'existe pas"
, 'PEAR_Error', true);
return $tmp;
}
 
@$obj =& new $classname($options);
 
return $obj;
}
}
 
/* +--Fin du code ----------------------------------------------------------------------------------------+
*
* $Log: bazar.class.php,v $
* Revision 1.10 2008-09-17 14:08:45 alexandre_tb
* merge depuis aha
*
* Revision 1.9 2007-10-10 13:27:06 alexandre_tb
* encodage et remplacement de die en return
*
* Revision 1.8 2007-10-01 10:35:14 alexandre_tb
* petit hack pour tester la presence de $GLOBALS['droit_depot'] qui indique le niveau de droit minimum pour pouvoir deposer une fiche.
*
* Revision 1.7 2007-07-04 09:59:09 alexandre_tb
* ajout de la classe bazar, premices d une structuration du code
*
* Revision 1.6 2007/04/20 09:58:06 neiluj
* correction bug $this->_id_utilisateur
*
* Revision 1.5 2007/04/11 08:30:12 neiluj
* remise en état du CVS...
*
* Revision 1.3.2.1 2007/03/07 16:49:21 jp_milcent
* Mise en majuscule de select
*
* Revision 1.3 2006/03/29 13:05:12 alexandre_tb
* ajout de la classe Administrateur_bazar
*
* Revision 1.2 2006/02/09 11:06:12 alexandre_tb
* changement dans les id des droit
* 0 => super administrateur
* 1 => redacteur
* 2 => administrateur
*
* Revision 1.1 2006/02/07 11:08:06 alexandre_tb
* version initiale
*
* +-- Fin du code ----------------------------------------------------------------------------------------+
*/
?>
/tags/v3.1-blanche-neige/bazarRSS.php
New file
0,0 → 1,115
<?php
/*vim: set expandtab tabstop=4 shiftwidth=4: */
// +------------------------------------------------------------------------------------------------------+
// | PHP version 4.1 |
// +------------------------------------------------------------------------------------------------------+
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org) |
// +------------------------------------------------------------------------------------------------------+
// | This library is free software; you can redistribute it and/or |
// | modify it under the terms of the GNU Lesser General Public |
// | License as published by the Free Software Foundation; either |
// | version 2.1 of the License, or (at your option) any later version. |
// | |
// | This library is distributed in the hope that it will be useful, |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
// | Lesser General Public License for more details. |
// | |
// | You should have received a copy of the GNU Lesser General Public |
// | License along with this library; if not, write to the Free Software |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
// +------------------------------------------------------------------------------------------------------+
// CVS : $Id: bazarRSS.php,v 1.7 2007/04/11 08:30:12 neiluj Exp $
/**
* Générateur de flux RSS à partir du bazar
*
*@package bazar
//Auteur original :
*@author Florian SCHMITT <florian@ecole-et-nature.org>
*@author Alexandre Granier <alexandre@tela-botanica.org>
*
*@copyright Tela-Botanica 2000-2004
*@version $Revision: 1.7 $
// +------------------------------------------------------------------------------------------------------+
*/
 
// +------------------------------------------------------------------------------------------------------+
// | ENTETE du PROGRAMME |
// +------------------------------------------------------------------------------------------------------+
 
include_once 'configuration/baz_config.inc.php'; //fichier de configuration de Bazar
include_once 'bibliotheque/bazar.fonct.rss.php'; //fichier des fonctions RSS de Bazar
 
// +------------------------------------------------------------------------------------------------------+
// | CORPS DU PROGRAMME |
// +------------------------------------------------------------------------------------------------------+
 
if (isset($_GET['annonce'])) {
$annonce=$_GET['annonce'];
}
else {
$annonce='';
}
 
if (isset($_GET['categorie_nature'])) {
$categorie_nature=$_GET['categorie_nature'];
}
else {
$categorie_nature='';
}
 
if (isset($_GET['nbitem'])) {
$nbitem=$_GET['nbitem'];
}
else {
$nbitem='';
}
 
if (isset($_GET['emetteur'])) {
$emetteur=$_GET['emetteur'];
}
else {
$emetteur='';
}
 
if (isset($_GET['valide'])) {
$valide=$_GET['valide'];
}
else {
$valide=1;
}
 
$requeteSQL='';
 
echo html_entity_decode(gen_RSS($annonce, $nbitem, $emetteur, $valide, $requeteSQL, '', '', $categorie_nature));
 
 
/* +--Fin du code ----------------------------------------------------------------------------------------+
*
* $Log: bazarRSS.php,v $
* Revision 1.7 2007/04/11 08:30:12 neiluj
* remise en état du CVS...
*
* Revision 1.4 2006/05/19 13:54:32 florian
* stabilisation du moteur de recherche, corrections bugs, lien recherche avancee
*
* Revision 1.3 2005/07/21 19:03:12 florian
* nouveautés bazar: templates fiches, correction de bugs, ...
*
* Revision 1.1.1.1 2005/02/17 18:05:11 florian
* Import initial de Bazar
*
* Revision 1.1.1.1 2005/02/17 11:09:50 florian
* Import initial
*
* Revision 1.1.1.1 2005/02/16 18:06:35 florian
* import de la nouvelle version
*
* Revision 1.3 2004/07/08 15:06:48 alex
* modification de la date
*
*
* +-- Fin du code ----------------------------------------------------------------------------------------+
*/
 
?>
/tags/v3.1-blanche-neige/bazar.carte_google.php
New file
0,0 → 1,282
<?php
/*vim: set expandtab tabstop=4 shiftwidth=4: */
// +------------------------------------------------------------------------------------------------------+
// | PHP version 4.1 |
// +------------------------------------------------------------------------------------------------------+
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org) |
// +------------------------------------------------------------------------------------------------------+
// | This library is free software; you can redistribute it and/or |
// | modify it under the terms of the GNU Lesser General Public |
// | License as published by the Free Software Foundation; either |
// | version 2.1 of the License, or (at your option) any later version. |
// | |
// | This library is distributed in the hope that it will be useful, |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
// | Lesser General Public License for more details. |
// | |
// | You should have received a copy of the GNU Lesser General Public |
// | License along with this library; if not, write to the Free Software |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
// +------------------------------------------------------------------------------------------------------+
// CVS : $Id: bazar.carte_google.php,v 1.9 2008-10-29 15:51:36 alexandre_tb Exp $
/**
*
*@package bazar
//Auteur original :
*@author Alexandre GRANIER <alexandre@tela-botanica.org>
//Autres auteurs :
*@copyright Tela-Satanica 2000-2007
*@version $Revision: 1.9 $
// +------------------------------------------------------------------------------------------------------+
*/
 
// +------------------------------------------------------------------------------------------------------+
// | ENTETE du PROGRAMME |
// +------------------------------------------------------------------------------------------------------+
 
 
include_once 'configuration/baz_config.inc.php';
include_once BAZ_CHEMIN_APPLI.'bibliotheque/bazar.fonct.php';
// Inclusion d'une classe personnalise si elle existe
 
// Le fichier de script de google map
GEN_stockerFichierScript('googleMapScript', 'http://maps.google.com/maps?file=api&amp;v=2&amp;key='.BAZ_GOOGLE_KEY);
 
// Le fichier jquery pour le date picker
//GEN_stockerFichierScript('jquery', 'api/js/jquery/jquery.js');
//GEN_stockerFichierScript('jquery', 'http://code.jquery.com/jquery-latest.js');
GEN_stockerFichierScript('jquery_date_picker', 'api/js/jquery/ui.datepicker.js');
GEN_stockerFichierScript('jquery_date_picker_fr', 'api/js/jquery/ui.datepicker-fr.js');
 
GEN_stockerStyleExterne( 'jquery_date_picker_style', 'api/js/jquery/ui.datepicker.css');
 
 
if (defined('PAP_VERSION')) { //si on est dans Papyrus
GEN_stockerStyleExterne( 'bazar_interne', 'client/bazar/bazar.interne.css');
}
$GLOBALS['_BAZAR_']['id_typeannonce']=$GLOBALS['_GEN_commun']['info_application']->id_nature;
$GLOBALS['_BAZAR_']['categorie_nature']=$GLOBALS['_GEN_commun']['info_application']->categorie_nature;
// requete sur le bazar pour recuperer les evenements
 
$requete_where = '';
foreach ($_POST as $cle => $valeur) {
if (preg_match ('/bazar_filtre_([0-9]+)/', $cle, $sousmotif)) {
$variable = $sousmotif[0] ;
if ($_POST[$variable] != '*') {
$requete_where = ' and bfvl_ce_liste="'.$sousmotif[1].'" and bfvl_valeur="'.$_POST[$variable].'" ';
} else {
$requete_where = ' and bfvl_ce_liste="'.$sousmotif[1].'" ';
}
} else {
}
}
 
if (isset($_POST['date_debut']) && $_POST['date_debut'] != '') {
$requete_date = '((bf_date_debut_evenement <= "'.date('Y-m-d', strtotime($_POST['date_fin'])).'" and bf_date_debut_evenement >="'.date('Y-m-d', strtotime($_POST['date_debut'])).'" )' .
' or (bf_date_fin_evenement >="'.date('Y-m-d', strtotime($_POST['date_debut'])).'" and bf_date_fin_evenement <="'.date('Y-m-d', strtotime($_POST['date_fin'])).'")' .
' or bf_date_debut_evenement <= "'.date('Y-m-d', strtotime($_POST['date_debut'])).'" and bf_date_fin_evenement >= "'.date('Y-m-d', strtotime($_POST['date_fin'])).'") ';
} else {
$requete_date = '((bf_date_debut_validite_fiche <= now( ) AND bf_date_fin_validite_fiche >= now( ))
OR (bf_date_fin_validite_fiche = "0000-00-00" AND date_add( bf_date_fin_evenement, INTERVAL 15 DAY ) > now( )) )';
}
 
$requete = 'SELECT blv_label,blv_valeur, bazar_fiche.*'.
' FROM bazar_fiche, bazar_fiche_valeur_liste , bazar_liste_valeurs'.
' WHERE bf_statut_fiche =1 and bf_id_fiche=bfvl_ce_fiche'.
' and bfvl_ce_liste=blv_ce_liste and bfvl_ce_liste=31 and bfvl_valeur=blv_valeur '.$requete_where.' and '.
$requete_date;
$resultat = $GLOBALS['_BAZAR_']['db']->query ($requete);
 
if (DB::isError($resultat)) {
return BOG_afficherErreurSql(__FILE__, __LINE__, $resultat->getMessage().'<br />'.$resultat->getDebugInfo(), $requete);echo $requete;
}
 
// Le code complique avec ces 2 tableaux sert
// a ne pas mettre 2 points aux memes coordonnees
// car dans ce cas la seul le second serait visible
 
$donnees = array();
 
if ($resultat->numRows() != 0) {
$script_marker = '';
$couleur_drapeau = array ( 1 => 'bleu', 2 => 'vert', 3 => 'orange', 4 => 'rose');
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
if ($ligne['bf_latitude'] == 0 && $ligne['bf_longitude'] == 0) continue;
$cle = $ligne['bf_latitude'].'-'.$ligne['bf_longitude'];
$donnees[$cle][] = $ligne;
}
foreach ($donnees as $valeur) {
// cas un : une seule entree pour le point de coordonnees
if (count ($valeur) == 1) {
$chaine = $valeur[0];
$script_marker .= 'var icon = new GIcon(G_DEFAULT_ICON);
icon.image = "client/bazar/images/drapeau_'.$couleur_drapeau[$chaine['blv_valeur']].'.png";'."\n".'
icon.shadow = "http://www.google.com/mapfiles/shadow50.png";
icon.iconSize = new GSize(16, 16);
icon.shadowSize = new GSize(16, 16);
icon.iconAnchor = new GPoint(6, 16);
icon.infoWindowAnchor = new GPoint(5, 1);'."\n";
$script_marker .= "\t".'point = new GLatLng('.$chaine['bf_latitude'].','.$chaine['bf_longitude'].');'."\n"
."\t".'map.addOverlay(createMarker(point, \''.'<div class="BAZ_cadre_map">'.
preg_replace ('/\n/', '', str_replace ("\r\n", '',
str_replace ("'", "\'", baz_voir_fiche(0, $chaine['bf_id_fiche'])))).'</div>\',icon));'."\n";
} else { // Cas 2 plusieurs entrees
$tableau_id = array();
foreach ($valeur as $val) {
array_push ($tableau_id, $val['bf_id_fiche']);
}
$script_marker .= 'var icon = new GIcon();
icon.image = "http://www.tela-botanica.org/client/bazar/images/drapeau_'.$couleur_drapeau[$chaine['blv_valeur']].'.png";
icon.shadow = "http://www.google.com/mapfiles/shadow50.png";
icon.iconSize = new GSize(16, 16);
icon.shadowSize = new GSize(37, 34);
icon.iconAnchor = new GPoint(6, 34);
icon.infoWindowAnchor = new GPoint(5, 1);';
$script_marker .= "\t".'point = new GLatLng('.$val['bf_latitude'].','.$val['bf_longitude'].');'."\n"
."\t".'map.addOverlay(createMarker(point, \''.'<div class="BAZ_cadre_map">'.
preg_replace ('/\n/', '', str_replace ("\r\n", '',
str_replace ("'", "\'", baz_voir_fiches(0, $tableau_id)))).'</div>\', icon));'."\n";
}
}
} else {
$script_marker = '';
}
 
$script = ' // Variables globales
var map = null;
// cette fonction peut déjà être présente
if (typeof(addListener) != \'function\') {
// fonction portable pour ajout de listeners
function addListener(element, baseName, handler)
{
if (element.addEventListener) {
element.addEventListener(baseName, handler, false) ;
} else if (element.attachEvent) {
element.attachEvent(\'on\'+baseName, handler) ;
}
}
}
addListener(window,\'load\',loadMap) ;';
if (BAZ_GOOGLE_MAXIMISE_TAILLE) $script .= '
// Pour gerer la taille
var winW = 630, winH = 560;
var deltaH = 220;
var deltaW = 270;
 
function setWinHW() {
if (window.innerHeight) {
winW = window.innerWidth - deltaW;
winH = window.innerHeight - deltaH;
} else {
winW = document.documentElement.offsetWidth - 20 - deltaW;
winH = document.documentElement.offsetHeight - 20 - deltaH ;
}
 
var me = document.getElementById("map");
if (me != null) {
me.style.width= \'\' + winW + \'px\';
me.style.height= \'\' + winH + \'px\';
}
}
 
window.onresize = function () {
setWinHW();
if (map) map.checkResize();
}';
$script .= '
function createMarker(point, chaine, icon) {
 
var marker = new GMarker(point, icon);
GEvent.addListener(marker, "click", function() {
marker.openInfoWindowHtml(chaine);
});
return marker;
}
function loadMap() {';
if (BAZ_GOOGLE_MAXIMISE_TAILLE) $script .= '
setWinHW();';
$script .= '
if (GBrowserIsCompatible()) {
map = new GMap2(document.getElementById("map"));
map.addControl(new GSmallMapControl());
map.addControl(new GMapTypeControl());
map.addControl(new GScaleControl());
map.enableContinuousZoom();
// On centre la carte sur le languedoc roussillon
center = new GLatLng('.BAZ_GOOGLE_CENTRE_LAT.', '.BAZ_GOOGLE_CENTRE_LON.');
map.setCenter(center, '.BAZ_GOOGLE_ALTITUDE.');
map.setMapType(G_HYBRID_MAP);' ;
if (BAZ_GOOGLE_FOND_KML != '') {
$script .= 'var geoXml = new GGeoXml("'.BAZ_GOOGLE_FOND_KML.'");';
}
$script .= $script_marker;
if (BAZ_GOOGLE_FOND_KML != '') {
$script .= 'map.addOverlay(geoXml);';
}
$script .= '
}
};
';
 
GEN_stockerCodeScript($script);
// On ajoute l attribut load a la balise body
//GEN_AttributsBody('onload', 'load()');
 
 
function afficherContenuCorps() {
include_once BAZ_CHEMIN_APPLI.'bibliotheque/bazarTemplate.class.php';
$modele = new bazarTemplate($GLOBALS['_BAZAR_']['db']);
$html = $modele->getTemplate(BAZ_TEMPLATE_ACCUEIL_CARTE_GOOGLE, $GLOBALS['_BAZAR_']['langue'], $GLOBALS['_BAZAR_']['categorie_nature']);
if (PEAR::isError($html)) return $html->getMessage();
// nettoyage url
$GLOBALS['_BAZAR_']['url']->removeQueryString(BAZ_VARIABLE_ID_FICHE) ;
$GLOBALS['_BAZAR_']['url']->removeQueryString(BAZ_VARIABLE_ACTION) ;
$html = bazar::getFormulaireFiltre($html) ;
$res = str_replace ('{CARTE}', '<div id="map" style="width: '.BAZ_GOOGLE_IMAGE_LARGEUR.
'px; height: '.BAZ_GOOGLE_IMAGE_HAUTEUR.'px"></div>', $html);
 
return $res;
}
 
 
/* +--Fin du code ----------------------------------------------------------------------------------------+
*
* $Log: not supported by cvs2svn $
* Revision 1.5.2.3 2008-01-29 09:41:11 alexandre_tb
* utilisation des constantes BAZ_GOOGLE_FOND_KML
*
* Revision 1.5.2.2 2007-12-14 09:57:15 alexandre_tb
* utilisation des constantes de la carte google
*
* Revision 1.5.2.1 2007-12-04 16:19:32 jp_milcent
* Ajout de la prise en charge de l'applette body_attributs
*
* Revision 1.5 2007-10-01 12:07:03 alexandre_tb
* utilisation de constantes du fichier de conf pour centrer la carte
*
* Revision 1.4 2007-08-27 12:27:34 alexandre_tb
* mise en place d un icone personnalise
* et de l affichage de plusieurs donnees sur un meme point
*
* Revision 1.3 2007-07-04 10:08:41 alexandre_tb
* Appel du template carte_google
*
* Revision 1.2 2007-06-13 10:02:47 alexandre_tb
* le carte s adapte a la taille du conteneur
*
* Revision 1.1 2007-06-04 15:26:57 alexandre_tb
* version initiale
*
* +-- Fin du code ----------------------------------------------------------------------------------------+
*/
/tags/v3.1-blanche-neige
New file
Property changes:
Added: svn:ignore
+.project
+.settings
+.buildpath