[ Index ]
 

Code source de SPIP Agora 1.4

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/Agora1-4/ecrire/ -> mots_edit.php (source)

   1  <?php
   2  /*****************************************************
   3  * This file is part of Agora, web based content management system.
   4  *
   5  * Agora is free software; you can redistribute it and/or modify
   6  * it under the terms of the GNU General Public License as published by
   7  * the Free Software Foundation; version 2 of the License.
   8  *
   9  * Agora is distributed in the hope that it will be useful,
  10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12  * GNU General Public License for more details (file "COPYING").
  13  *
  14  * Copyright © Arnaud Martin, Antoine Pitrou et Philippe Rivière.
  15  * List of authors detailed in "copyright_fr.html" file.
  16  * E-mail : agora@sig.premier-ministre.gouv.fr
  17  * Web site : http://www.agora.gouv.fr
  18  *****************************************************/
  19  /** Gestion des mots-clés
  20   * @version     $Id$
  21   */
  22  
  23  ###
  24  # Includes
  25  ###
  26  include ("inc.php");
  27  
  28  include_ecrire ("inc_logos.php");
  29  include_ecrire ("inc_sites.php");
  30  
  31  require_once(dirname(__FILE__). "/include/bd/inc_groupe_mot_factory.php");
  32  require_once(dirname(__FILE__). "/include/bd/inc_article_list_factory.php");
  33  require_once(dirname(__FILE__). "/include/bd/inc_breve_list_factory.php");
  34  require_once(dirname(__FILE__). "/include/bd/inc_rubrique_list_factory.php");
  35  require_once(dirname(__FILE__). "/include/bd/inc_syndic_list_factory.php");
  36  
  37  function mySel ($varaut, $variable) {
  38      $retour = " VALUE=\"$varaut\"";
  39  
  40      if ($variable == $varaut) {
  41          $retour .= " SELECTED";
  42      }
  43  
  44      return $retour;
  45  }
  46  
  47  //
  48  // modifications mot
  49  //
  50  
  51  $authorization = &recuperer_instance_authorization('modifierMotCle', $GLOBALS['connect_id_auteur']);
  52  
  53  if (!$authorization->isAuthorizedAction()) {
  54      echo _T('avis_acces_interdit');
  55      exit;
  56  }
  57  else {
  58      $authorization = &recuperer_instance_authorization('supprimerMotCle', $GLOBALS['connect_id_auteur']);
  59  
  60      if ($authorization->isAuthorizedAction())
  61          if ($supp_mot) {
  62              $motMetier = &recuperer_instance_mot();
  63              $deleteOK = $motMetier->delete($supp_mot);
  64  
  65              if (PEAR::isError($deleteOK)) {
  66                  die($deleteOK->getMessage());
  67              }
  68  
  69              $motMetier = &recuperer_instance_mot();
  70              $deleteMotTableOK = $motMetier->deleteMotTable('articles', 'id_mot', $supp_mot);
  71              if (PEAR::isError($deleteMotTableOK)) {
  72                  die($deleteMotTableOK->getMessage());
  73              }
  74          }
  75  
  76      if ($titre_mot) {
  77          $authorization = &recuperer_instance_authorization('creerMotCle', $GLOBALS['connect_id_auteur']);
  78  
  79          if ($authorization->isAuthorizedAction()) {
  80              if ($new == 'oui' && $id_groupe) {
  81                  $motMetier = &recuperer_instance_mot();
  82                  $motMetier->setGroupeId($id_groupe);
  83  
  84                  if ($id_mot_subnode == 'root') {
  85                      $createOK = $motMetier->create();
  86                  }
  87                  else {
  88                      $createOK = $motMetier->create($id_mot_subnode);
  89                  }
  90  
  91                  if (PEAR::isError($createOK)) {
  92                      die($createOK->getMessage());
  93                  }
  94  
  95                  $id_mot = $motMetier->getMotId();
  96  
  97                  // ajouter le mot a l'article
  98                  if (settype($ajouter_id_article, 'integer')AND ($ajouter_id_article > 0)) {
  99                      $motMetier = &recuperer_instance_mot();
 100                      $addMotOK = $motMetier->addMot('articles', 'id_article', $id_mot, $ajouter_id_article);
 101                      if (PEAR::isError($addMotOK)) {
 102                          die($addMotOK->getMessage());
 103                      }
 104                  }
 105              }
 106          }
 107  
 108          $authorization = &recuperer_instance_authorization('modifierMotCle', $GLOBALS['connect_id_auteur']);
 109          if ($authorization->isAuthorizedAction()) {
 110              $groupeMotMetier = &recuperer_instance_groupe_mot();
 111              $loadOK = $groupeMotMetier->load($id_groupe);
 112  
 113              if (!PEAR::isError($loadOK)) {
 114                  $type = $groupeMotMetier->getTitre();
 115              }
 116  
 117              $motMetier = &recuperer_instance_mot();
 118              $loadOK = $motMetier->load($id_mot);
 119  
 120              if (PEAR::isError($loadOK)) {
 121                  die($loadOK->getMessage());
 122              }
 123  
 124              // -- MODIFICATION d'un mot existant
 125              else {
 126                  $id_groupe_bckp = $motMetier->getGroupeId();
 127                  $motMetier->setTitre($titre_mot);
 128                  $motMetier->setTexte($texte);
 129                  $motMetier->setDescriptif($descriptif);
 130                  $motMetier->setType($type);
 131                  $motMetier->setGroupeId($id_groupe);
 132  
 133                  // On interdit le changement de groupe pour les mots faisant partie d'une chaîne
 134                  if ($motMetier->getEnfantIds(
 135                          $motMetier->getMotId()) || $motMetier->getParentId($motMetier->getMotId())) {
 136                      $motMetier->setGroupeId($id_groupe_bckp);
 137                  }
 138  
 139                  // recoller les champs du extra
 140                  if ($champs_extra) {
 141                      include_ecrire ("inc_extra.php");
 142                      $add_extra = extra_recup_saisie("mots");
 143                  }
 144                  else
 145                      $add_extra = '';
 146  
 147                  $motMetier->setExtra($add_extra);
 148                  $updateOK = $motMetier->update();
 149                  if (PEAR::isError($updateOK)) {
 150                      die($updateOK->getMessage());
 151                  }
 152              }
 153              if (lire_meta('activer_moteur') == 'oui') {
 154                  include_ecrire ("inc_index.php");
 155                  indexer_mot($id_mot);
 156              }
 157          }
 158      }
 159      else if ($new == 'oui') {
 160          $titre_mot = filtrer_entites(_T('texte_nouveau_mot'));
 161      }
 162  }
 163  
 164  //
 165  // redirection ou affichage
 166  //
 167  if ($redirect_ok == 'oui' && $redirect) {
 168      @header("Location: " . rawurldecode($redirect));
 169      exit;
 170  }
 171  
 172  //
 173  // Recupere les donnees
 174  //
 175  //
 176  if ($id_mot) {
 177      $motMetier = &recuperer_instance_mot();
 178      $loadOK = $motMetier->load($id_mot);
 179      if (PEAR::isError($loadOK)) {
 180          die($loadOK->getMessage());
 181      }
 182      else {
 183          $id_mot = $motMetier->getMotId();
 184          $titre_mot = $motMetier->getTitre();
 185          $descriptif = $motMetier->getDescriptif();
 186          $texte = $motMetier->getTexte();
 187          $type = $motMetier->getType();
 188          $extra = $motMetier->getExtra();
 189          $id_groupe = $motMetier->getGroupeId();
 190      }
 191  }
 192  debut_page("&laquo; $titre_mot &raquo;", "documents", "mots");
 193  debut_gauche();
 194  
 195  //////////////////////////////////////////////////////
 196  // Boite "voir en ligne"
 197  //
 198  
 199  debut_boite_info();
 200  echo "<CENTER>";
 201  echo "<FONT FACE='Verdana,Arial,Sans,sans-serif' SIZE=1><B>" . _T('titre_gauche_mots_edit'). "</B></FONT>";
 202  echo "<BR><FONT FACE='Verdana,Arial,Sans,sans-serif' SIZE=6><B>$id_mot</B></FONT>";
 203  echo "</CENTER>";
 204  
 205  icone_horizontale(_T('icone_voir_en_ligne'), "../spip_redirect.php?id_mot=$id_mot&recalcul=oui", "racine-24.gif",
 206                    "rien.gif");
 207  
 208  fin_boite_info();
 209  
 210  echo "<p><center>";
 211  
 212  if ($new == 'oui') {
 213      $adresse_retour = "mots_edit.php?redirect=$redirect&redirect_ok=oui&supp_mot=$id_mot";
 214  }
 215  else {
 216      $adresse_retour = "mots_edit.php?redirect=$redirect&redirect_ok=oui";
 217  }
 218  
 219  echo "</center>";
 220  
 221  //////////////////////////////////////////////////////
 222  // Logos du mot-clef
 223  //
 224  
 225  $arton = "moton$id_mot";
 226  $artoff = "motoff$id_mot";
 227  
 228  //-----------MODIFICATION CLEVER AGE elebescond@clever-age.com----------
 229  $authorization = &recuperer_instance_authorization('modifierMotCle', $GLOBALS['connect_id_auteur']);
 230  
 231  if ($id_mot > 0 AND $authorization->isAuthorizedAction())
 232      /*
 233  if ($id_mot > 0 AND $connect_statut == 'minirezo')
 234      */
 235      //-----------Fin MODIFICATION CLEVER AGE elebescond@clever-age.com----------
 236      afficher_boite_logo($arton, $artoff, _T('logo_mot_cle'). aide("breveslogo"), _T('logo_survol'));
 237  
 238  //
 239  // Afficher les boutons de creation d'article et de breve
 240  //
 241  debut_raccourcis();
 242  
 243  icone_horizontale(_T('icone_voir_tous_mots_cles'), "mots_tous.php", "mot-cle-24.gif", "rien.gif");
 244  
 245  //-----------MODIFICATION CLEVER AGE elebescond@clever-age.com----------
 246  $authorization = &recuperer_instance_authorization('creerMotCle', $GLOBALS['connect_id_auteur']);
 247  
 248  if ($authorization->isAuthorizedAction())
 249      icone_horizontale(_T('icone_creation_mots_cles'),
 250                        "mots_edit.php?new=oui&redirect=mots_tous.php&id_groupe=$id_groupe",
 251                        "mot-cle-24.gif",
 252                        "creer.gif");
 253  
 254  fin_raccourcis();
 255  
 256  debut_droite();
 257  
 258  debut_cadre_relief("mot-cle-24.gif");
 259  
 260  echo "\n<table cellpadding=0 cellspacing=0 border=0 width='100%'>";
 261  echo "<tr width='100%'>";
 262  echo "<td width='100%' valign='top'>";
 263  gros_titre($titre_mot);
 264  
 265  if ($descriptif) {
 266      echo "<p><div align='left' border: 1px dashed #aaaaaa;'>";
 267      echo "<font size=2 face='Verdana,Arial,Sans,sans-serif'>";
 268      echo "<b>" . _T('info_descriptif'). "</b> ";
 269      echo propre($descriptif);
 270      echo "&nbsp; ";
 271      echo "</font>";
 272      echo "</div>";
 273  }
 274  
 275  echo "</td>";
 276  echo "</tr></table>\n";
 277  
 278  if (strlen($texte) > 0) {
 279      echo "<FONT FACE='Verdana,Arial,Sans,sans-serif'>";
 280      echo "<P>" . propre($texte);
 281      echo "</FONT>";
 282  }
 283  
 284  if ($champs_extra AND $extra) {
 285      include_ecrire ("inc_extra.php");
 286      extra_affichage($extra, "mots");
 287  }
 288  
 289  if ($id_mot) {
 290      echo "<p>";
 291      $profilMetier = &recuperer_instance_profil();
 292      $monProfil = $profilMetier->getProfilForIntitule('item_webmestre');
 293  
 294      if ($connect_profil >= $monProfil->getPoids())
 295          $aff_articles = "'prepa','prop','publie','refuse'";
 296      else
 297          $aff_articles = "'prop','publie'";
 298  
 299      $rubriqueList = recuperer_instance_list_rubriques();
 300      $queryParams = array();
 301      $queryParams[] = $id_mot;
 302      $rubriqueList->displayHTMLList(_T('info_rubriques_liees_mot'), RUBRIQUES_BY_LINK, $queryParams);
 303      $articleList = recuperer_instance_list_articles();
 304      $queryParams = array();
 305      $queryParams[] = $id_mot;
 306      $affArtParam = $aff_articles;
 307      $queryParams[] = $affArtParam;
 308      $articleList->displayHTMLList(_T('info_articles_lies_mot'), ARTICLES_BY_KEYWORD, $queryParams);
 309      $breveList = recuperer_instance_list_breves();
 310      $queryParams = array();
 311      $queryParams[] = $id_mot;
 312      $breveList->displayHTMLList(_T('info_breves_liees_mot'), BREVES_BY_LIEN, $queryParams, true, 0, 10);
 313  
 314      // ----------Modifications Clever Age | elebescond@clever-age.com-------------------
 315      $syndicList = &recuperer_instance_list_syndics();
 316      $queryParams = array();
 317      $queryParams[] = $id_mot;
 318      $syndicList->displayHTMLList(_T('info_sites_lies_mot'), SYNDICS_MOT_BY_MOT_ID, $queryParams, 0, 10);
 319  }
 320  
 321  fin_cadre_relief();
 322  //----------------Zone de modifications Clever Age elebescond@clever-age.com----------
 323  $authorization1 = &recuperer_instance_authorization('creerMotCle', $GLOBALS['connect_id_auteur']);
 324  $authorization2 = &recuperer_instance_authorization('modifierMotCle', $GLOBALS['connect_id_auteur']);
 325  
 326  if (($new == 'oui' AND $authorization1->isAuthorizedAction())OR $authorization2->isAuthorizedAction()) {
 327      /*
 328      if ($connect_statut =="minirezo") {
 329      */
 330      // ----------Fin modification CA-------------------------
 331      echo "<P>";
 332      debut_cadre_formulaire();
 333  
 334      echo "<FORM ACTION='mots_edit.php' METHOD='post'>";
 335      echo "<div class='serif'>";
 336  
 337      if ($id_mot) {
 338          echo "<INPUT TYPE='Hidden' NAME='id_mot' VALUE='$id_mot'>\n";
 339      }
 340      else if ($new == 'oui') {
 341          echo "<INPUT TYPE='Hidden' NAME='new' VALUE='oui'>\n";
 342      }
 343  
 344      echo "<INPUT TYPE='Hidden' NAME='id_groupe' VALUE='" . $id_groupe . "'>\n";
 345      echo "<INPUT TYPE='Hidden' NAME='redirect' VALUE=\"$redirect\">\n";
 346      echo "<INPUT TYPE='Hidden' NAME='redirect_ok' VALUE='oui'>\n";
 347      echo "<INPUT TYPE='Hidden' NAME='ajouter_id_article' VALUE=\"$ajouter_id_article\">\n";
 348  
 349      $titre_mot = entites_html($titre_mot);
 350      $descriptif = entites_html($descriptif);
 351      $texte = entites_html($texte);
 352  
 353      echo "<B>" . _T('info_titre_mot_cle'). "</B> " . _T('info_obligatoire_02');
 354      echo aide("mots");
 355  
 356      echo "<BR><INPUT TYPE='text' NAME='titre_mot' CLASS='formo' VALUE=\"$titre_mot\" SIZE='40'>";
 357  
 358      //------ Gestion de l'arborescence de mots clés
 359      //------ ATTENTION, QUE FAIRE SI LES MOTS CLES SONT CREES DEPUIS UN RACCOURCI CREER ET ATTACHER UN MOT CLE??
 360      //------ Ci dessous, code SPIP original commenté
 361      /*----- Changements fonctionnels :
 362      - Choix de la position dans l'arbo du groupe du mot clé
 363      - Possiblité de déplacer le mot clé (si modif et pas création) à la racine d'un autre groupe
 364      */
 365      // dans le groupe...
 366      $groupeMotMetier = &recuperer_instance_groupe_mot();
 367      $allGroupeMot = $groupeMotMetier->getAllGroupe('titre');
 368  
 369      if (PEAR::isError($allGroupeMot)) {
 370          die($allGroupeMot->getMessage());
 371      }
 372  
 373      if (sizeOf($allGroupeMot) > 1) {
 374          debut_cadre_relief("groupe-mot-24.gif");
 375          echo _T('info_dans_groupe'). "</label>\n";
 376          echo aide("motsgroupes");
 377          $editable = '';
 378  
 379          if (is_object($motMetier)) {
 380              if ($motMetier->getEnfantIds($motMetier->getMotId()) || $motMetier->getParentId($motMetier->getMotId())) {
 381                  $editable = 'disabled';
 382              }
 383          }
 384  
 385          echo " &nbsp; <SELECT NAME='id_groupe' class='fondl' $editable >\n";
 386  
 387          while (list(, $groupeMotMetier) = each($allGroupeMot)) {
 388              $titre_groupe = entites_html($groupeMotMetier->getTitre());
 389              echo "<OPTION" . mySel($groupeMotMetier->getGroupeId(), $id_groupe). ">$titre_groupe</OPTION>\n";
 390          }
 391  
 392          echo "</SELECT>";
 393          fin_cadre_relief();
 394      }
 395      else {
 396          unset($groupeMotMetier);
 397          list(, $groupeMotMetier) = each($allGroupeMot);
 398          if (!$groupeMotMetier) {
 399              // il faut creer un groupe de mots (cas d'un mot cree depuis articles.php)
 400              $groupeMotMetier = &recuperer_instance_groupe_mot();
 401              $groupeMotMetier->setTitre('(Mots sans groupe...)');
 402              $groupeMotMetier->setUnSeul('non');
 403              $groupeMotMetier->setObligatoire('non');
 404              $groupeMotMetier->setArticles('oui');
 405              $groupeMotMetier->setBreves('oui');
 406              $groupeMotMetier->setRubriques('non');
 407              $groupeMotMetier->setSyndic('oui');
 408              $profilMetier = &recuperer_instance_profil();
 409              $groupeMotMetier->setProfils($profilMetier->getSumOfPoids());
 410              $groupeMotMetier->setforum('oui');
 411              $createOK = $groupeMotMetier->create();
 412              if (PEAR::isError($createOK)) {
 413                  die($createOK->getMessage());
 414              }
 415          //$row_groupes['id_groupe'] = $groupeMotMetier->getGroupeId();
 416          }
 417      }
 418      //}
 419  
 420      $groupeMotMetier = &recuperer_instance_groupe_mot();
 421      $allGroupeMot = $groupeMotMetier->getAllGroupe('titre');
 422  
 423      if (PEAR::isError($allGroupeMot)) {
 424          die($allGroupeMot->getMessage());
 425      }
 426  
 427      // Gestion du positionnement du mot dans l'arborescence du groupe en cours
 428  
 429      // Attention, ne pas oublier de gérer la création de mots clés
 430      // sans spécification de groupe (ex: créer un mot clé et l'attacher à cet article !
 431      if ($id_groupe) {
 432          $groupeMotMetier->setGroupeId($id_groupe);
 433          $nb_mots_groupe = $groupeMotMetier->howManyInGroup();
 434          if ($nb_mots_groupe > 0) {
 435              if ($new == 'oui') {
 436                  $cadre_groupe_mot = true;
 437                  debut_cadre_relief("groupe-mot-24.gif");
 438                  echo _T('info_dans_arbo');
 439                  // Attention corriger l'aide également!
 440                  echo aide("motsgroupes");
 441                  echo ' &nbsp; ';
 442                  echo $groupeMotMetier->htmlSelect();
 443                  echo '<br>';
 444              }
 445          }
 446          else {
 447              echo '<input type="hidden" name="id_mot_subnode" value="root">';
 448          }
 449      }
 450  
 451      if ($cadre_groupe_mot) {
 452          fin_cadre_relief();
 453      }
 454  
 455      //-----Fin de la gestion arbo mot clé
 456  
 457      if ($options == 'avancees' OR $descriptif) {
 458          echo "<B>" . _T('texte_descriptif_rapide'). "</B><BR>";
 459          echo "<TEXTAREA NAME='descriptif' CLASS='forml' ROWS='4' COLS='40' wrap=soft>";
 460          echo $descriptif;
 461          echo "</TEXTAREA><P>\n";
 462      }
 463      else
 464          echo "<INPUT TYPE='hidden' NAME='descriptif' VALUE=\"$descriptif\">";
 465  
 466      if ($options == 'avancees' OR $texte) {
 467          echo "<B>" . _T('info_texte_explicatif'). "</B><BR>";
 468          echo "<TEXTAREA NAME='texte' ROWS='8' CLASS='forml' COLS='40' wrap=soft>";
 469          echo $texte;
 470          echo "</TEXTAREA><P>\n";
 471      }
 472      else
 473          echo "<INPUT TYPE='hidden' NAME='texte' VALUE=\"$texte\">";
 474  
 475      if ($champs_extra) {
 476          include_ecrire ("inc_extra.php");
 477          extra_saisie($extra, 'mots', $id_groupe);
 478      }
 479  
 480      echo "<DIV align='right'><INPUT TYPE='submit' NAME='Valider' VALUE='" . _T(
 481                                                                                  'bouton_valider'). "' CLASS='fondo'></div>";
 482  
 483      echo "</div>";
 484      echo "</FORM>";
 485  
 486      fin_cadre_formulaire();
 487  }
 488  
 489  fin_page();
 490  ?>


Généré le : Sat Feb 24 14:40:03 2007 par Balluche grâce à PHPXref 0.7