[ Index ]
 

Code source de SPIP Agora 1.4

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

title

Body

[fermer]

/Agora1-4/ecrire/ -> inc_mots.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  // Ce fichier ne sera execute qu'une fois
  20  if (defined("_ECRIRE_INC_MOTS"))
  21      return;
  22  
  23  define("_ECRIRE_INC_MOTS", "1");
  24  
  25  require_once("PEAR.php");
  26  require_once (dirname(__FILE__). "/include/bd/inc_groupe_mot_factory.php");
  27  
  28  $GLOBALS['flag_mots_ressemblants'] = $GLOBALS['flag_levenshtein'];
  29  
  30  function mots_ressemblants ($mot, $table_mots, $table_ids = '') {
  31      $lim = 2;
  32      $nb = 0;
  33      $opt = 1000000;
  34      $mot_opt = '';
  35      $mot = strtolower(trim($mot));
  36      $len = strlen($mot);
  37  
  38      if (!$table_mots)
  39          return '';
  40  
  41      while (!$nb AND $lim < 10) {
  42          reset ($table_mots);
  43  
  44          if ($table_ids)
  45              reset ($table_ids);
  46  
  47          while (list(, $val) = each($table_mots)) {
  48              if ($table_ids)
  49                  list(, $id) = each($table_ids);
  50              else
  51                  $id = $val;
  52  
  53              $val2 = trim($val);
  54              if ($val2) {
  55                  if (!($m = $distance[$id])) {
  56                      $val2 = strtolower($val2);
  57                      $len2 = strlen($val2);
  58  
  59                      if (substr($val2, 0, $len) == $mot)
  60                          $m = -1;
  61                      else if ($len2 > $len)
  62                          $m = levenshtein($val2, $mot) + $len - $len2;
  63                      else
  64                          $m = levenshtein($val2, $mot);
  65                      $distance[$id] = $m;
  66                  }
  67                  if ($m <= $lim) {
  68                      $selection[$id] = $m;
  69  
  70                      if ($m < $opt) {
  71                          $opt = $m;
  72                          $mot_opt = $val;
  73                      }
  74                      $nb++;
  75                  }
  76              }
  77          }
  78          $lim += 2;
  79      }
  80  
  81      if (!$nb)
  82          return '';
  83  
  84      reset ($selection);
  85  
  86      if ($opt != -1) {
  87          $moy = 1;
  88  
  89          while (list(, $val) = each($selection))
  90              $moy *= $val;
  91  
  92          if ($moy)
  93              $moy = pow($moy, 1.0 / $nb);
  94          $lim = ($opt + $moy) / 2;
  95      }
  96      else
  97          $lim = -1;
  98  
  99      reset ($selection);
 100  
 101      while (list($key, $val) = each($selection)) {
 102          if ($val <= $lim) {
 103              $result[] = $key;
 104          }
 105      }
 106  
 107      return $result;
 108  }
 109  
 110  /*
 111   * Affiche la liste des mots-cles associes a l'objet
 112   * specifie, plus le formulaire d'ajout de mot-cle
 113   */
 114  
 115  function formulaire_mots ($table, $id_objet, $nouv_mot, $supp_mot, 
 116                          $cherche_mot, $flag_editable, $id_javascript = 0) {
 117      global $flag_mots_ressemblants;
 118      global $connect_statut;
 119      global $connect_profil;
 120      global $spip_lang_rtl;
 121      global $delete_nodes;
 122      global $verif_granularite;
 123      global $id_table;
 124  
 125      $select_groupe = $GLOBALS['select_groupe'];
 126  
 127      if ($table == 'articles') {
 128          $authorization = &recuperer_instance_authorization('gererMotCleArticle', 
 129                                                              $GLOBALS['connect_id_auteur'],
 130                                                              array('id_article' => $id_objet));
 131  
 132          if (!$authorization->isAuthorizedAction())
 133              return;
 134               
 135          $id_table = 'id_article';
 136          $url_base = "articles.php?id_article=$id_objet";
 137      }
 138      /******* Ajout MAPPING guillaume.grason@diplomatie.gouv.fr *******/
 139      else if ($table == 'articles_map') {
 140          $authorization = &recuperer_instance_authorization('gererMotCleArticle', 
 141                                                              $GLOBALS['connect_id_auteur'], 
 142                                                              array('id_article' => $id_objet));
 143          if(!$authorization->isAuthorizedAction()) return;
 144          $id_table = 'id_article';
 145          $url_base = "mapping_articles.php?id_article=$id_objet";
 146          $table = 'articles';
 147      }
 148      /******* Fin Ajout MAPPING guillaume.grason@diplomatie.gouv.fr *******/
 149      else if ($table == 'breves') {
 150          $id_table = 'id_breve';
 151          $url_base = "breves_voir.php?id_breve=$id_objet";
 152      }
 153      else if ($table == 'rubriques') {
 154          $id_table = 'id_rubrique';
 155          $url_base = "naviguer.php?coll=$id_objet";
 156      }
 157      else if ($table == 'syndic') {
 158          $id_table = 'id_syndic';
 159          $url_base = "sites.php?id_syndic=$id_objet";
 160      }
 161      else if ($table == 'visiteurs') {
 162          global $auteur_session;
 163          $id_table = 'id_auteur';
 164          $auteurMetier = &recuperer_instance_auteur();
 165          $loadOK = $auteurMetier->load($auteur_session['id_auteur']);
 166  
 167          if (PEAR::isError($loadOK)) {
 168              die ($loadOK->getMessage());
 169          }
 170          $connect_profil = $auteurMetier->getProfil();
 171          $table = 'auteurs';
 172      }
 173      else if ($table == 'auteurs') {
 174          $authorization = &recuperer_instance_authorization('gererMotCleAuteur', 
 175                                                              $GLOBALS['connect_id_auteur'],
 176                                                              array('id_auteur' => $id_objet));
 177  
 178          if (!$authorization->isAuthorizedAction())
 179              return;
 180        
 181          $id_table = 'id_auteur';
 182          $url_base = "auteurs_edit.php?id_auteur=$id_objet";
 183      }
 184      else if ($table == 'cm_gabarit') {
 185          global $id_newsletter;
 186          $table = 'cm';
 187          $id_table = 'id_groupe';
 188          $url_base = "newsletter_admin_groups.php?id_newsletter=$id_newsletter&id_groupe=$id_objet";
 189      }
 190      else if ($table == 'cm_specifique') {
 191          global $id_newsletter;
 192          global $id_post;
 193          $table = 'cm';
 194          $id_table = 'id_groupe';
 195          $url_base = "post_admin_groups.php?id_post=$id_post&id_newsletter=$id_newsletter&id_groupe=$id_objet";
 196      }
 197  
 198      if ($verif_granularite == 'oui') {
 199          include  ('verif_mot_granularite.php');
 200          if (!$pas_changement_granularite) {
 201              unset ($nouv_mot);
 202          }
 203      }
 204  
 205      $motMetier = &recuperer_instance_mot();
 206      $allMots = $motMetier->getAllFromMotsAndAnotherTable($table, $id_table, $id_objet);
 207  
 208      if (PEAR::isError($allMots)) {
 209          die ($allMots->getMessage());
 210      }
 211  
 212      /**
 213       * Gestion du brouteur de mots clefs
 214       */
 215  
 216      $nombre_mots = sizeOf($allMots);
 217      $groupeMotMetier = &recuperer_instance_groupe_mot();
 218      $allGroupeMot = $groupeMotMetier->getAllForTableAndProfil($table, "'oui'", $connect_profil);
 219  
 220      if (PEAR::isError($allGroupeMot)) {
 221          die ($allGroupeMot->getMessage());
 222      }
 223  
 224      $nombre_groupes = sizeOf($allGroupeMot);
 225  
 226      if (!$nombre_mots AND (!$nombre_groupes OR !$flag_editable))
 227          return;
 228  
 229      // Affiche la boite des mots-cles
 230      echo "<a name='mots'></a>";
 231      debut_cadre_enfonce ("mot-cle-24.gif");
 232  
 233      echo "<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=3 WIDTH=100% BACKGROUND=''><TR><TD BGCOLOR='#EEEECC'>\n";
 234  
 235      if ($flag_editable) {
 236          if ($nouv_mot . $cherche_mot . $supp_mot)
 237              echo bouton_block_visible("lesmots" . $id_javascript);
 238          else
 239              echo bouton_block_invisible("lesmots" . $id_javascript);
 240      }
 241  
 242      echo "<B>" . _T('titre_mots_cles'). "</B>";
 243      echo aide("artmots");
 244      echo "</td></tr></TABLE>\n";
 245  
 246      //////////////////////////////////////////////////////
 247      // Recherche de mot-cle
 248      //
 249      if ($nouv_mot)
 250          $nouveaux_mots[] = $nouv_mot;
 251  
 252      $tous_les_mots = split(" *[,;] *", $cherche_mot);
 253  
 254      while ((list(, $cherche_mot) = each($tous_les_mots)) AND $cherche_mot) {
 255          echo "<P ALIGN='left'>";
 256          $motMetier = &recuperer_instance_mot();
 257          $allMots = $motMetier->getAllMotsForGroupeId($select_groupe);
 258  
 259          if (PEAR::isError($allMots)) {
 260              die ($allMots->getmesage());
 261          }
 262  
 263          unset ($table_mots);
 264          unset ($table_ids);
 265  
 266          while (list(, $motMetier) = each($allMots)) {
 267              $table_ids[] = $motMetier->getMotId();
 268              $table_mots[] = $motMetier->getTitre();
 269          }
 270  
 271          $resultat = mots_ressemblants($cherche_mot, $table_mots, $table_ids);
 272          debut_boite_info();
 273  
 274          if (!$resultat) {
 275              echo "<B>" . _T('info_non_resultat', array('cherche_mot' => $cherche_mot)). "</B><BR>\n";
 276          }
 277          else if (count($resultat) == 1) {
 278              list(, $nouv_mot) = each($resultat);
 279              $nouveaux_mots[] = $nouv_mot;
 280              echo "<B>" . _T('info_mot_cle_ajoute'). " ";
 281  
 282              if ($table == 'articles')
 283                  echo _T('info_l_article');
 284              else if ($table == 'breves')
 285                  echo _T('info_la_breve');
 286              else if ($table == 'rubriques')
 287                  echo _T('info_la_rubrique');
 288  
 289              echo " : </B><BR>";
 290              $motMetier = &recuperer_instance_mot();
 291              $loadOK = $motMetier->load($nouv_mot);
 292  
 293              if (PEAR::isError($loadOK)) {
 294                  die ($loadOK->getMessage());
 295              }
 296  
 297              echo "<UL>";
 298  
 299              if (PEAR::isError($loadOK)) {
 300                  die ($loadOK->getMessage());
 301              }
 302              else {
 303                  $id_mot = $motMetier->getMotId();
 304                  $titre_mot = $motMetier->getTitre();
 305                  $type_mot = $motMetier->getType();
 306                  $descriptif_mot = $motMetier->getDescriptif();
 307  
 308                  echo "<LI><FONT FACE='Verdana,Arial,Helvetica,sans-serif' SIZE=2><B><FONT SIZE=3>$titre_mot</FONT></B>";
 309                  echo "</FONT>\n";
 310              }
 311              echo "</UL>";
 312          }
 313          else if (count($resultat) < 16) {
 314              reset ($resultat);
 315              unset ($les_mots);
 316  
 317              while (list(, $id_mot) = each($resultat))
 318                  $les_mots[] = $id_mot;
 319              if ($les_mots) {
 320                  $les_mots = join(',', $les_mots);
 321                  echo "<B>" . _T('info_plusieurs_mots_trouves', array('cherche_mot' => $cherche_mot)). "</B><BR>";
 322  
 323                  $motMetier = &recuperer_instance_mot();
 324                  $allMots = $motMetier->getAllMotsForMotId($les_mots, "titre");
 325  
 326                  if (PEAR::isError($allMots)) {
 327                      die ($allMots->getmesage());
 328                  }
 329  
 330                  echo "<UL>";
 331  
 332                  while (list(, $motMetier) = each($allMots)) {
 333                      $id_mot = $motMetier->getMotId();
 334                      $titre_mot = $motMetier->getTitre();
 335                      $type_mot = $motMetier->getType();
 336                      $descriptif_mot = $motMetier->getDescriptif();
 337                      echo "<LI><FONT FACE='Verdana,Arial,Helvetica,sans-serif' SIZE=2><B><FONT SIZE=3>$titre_mot</FONT></B>";
 338  
 339                      if ($type_mot)
 340                          echo " ($type_mot)";
 341  
 342                      echo " | <A HREF=\"$url_base&nouv_mot=$id_mot\">" . _T('info_ajouter_mot'). "</A>";
 343  
 344                      if (strlen($descriptif_mot) > 1) {
 345                          echo "<BR><FONT SIZE=1>" . propre(couper($descriptif_mot, 100)). "</FONT>\n";
 346                      }
 347                      echo "</FONT><p>\n";
 348                  }
 349                  echo "</UL>";
 350              }
 351          }
 352          else {
 353              echo "<B>" . _T('info_trop_resultat', array('cherche_mot' => $cherche_mot)). "<BR>";
 354          }
 355  
 356          fin_boite_info();
 357          echo "<P>";
 358      }
 359  
 360      //////////////////////////////////////////////////////
 361      // Appliquer les modifications sur les mots-cles
 362      //
 363  
 364      if ($delete_nodes && $flag_editable) {
 365          $motMetier = &recuperer_instance_mot();
 366          $unlinkMots = explode(',', $delete_nodes);
 367          while (list(, $motId) = each($unlinkMots)) {
 368              $deletMotTableOK = $motMetier->deleteMotTable($table, $id_table, $id_objet, $motId);
 369              if (PEAR::isError($deletMotTableOK)) {
 370                  die ($deletMotTableOK->getMessage());
 371              }
 372          }
 373      }
 374  
 375      if ($nouveaux_mots && $flag_editable) {
 376          while ((list(, $nouv_mot) = each($nouveaux_mots))AND $nouv_mot != 'x') {
 377              $motMetier = &recuperer_instance_mot();
 378              $monBoolean = $motMetier->exist($table, $id_table, $nouv_mot, $id_objet);
 379  
 380              if (PEAR::isError($monBoolean)) {
 381                  die ($monBoolean->getMessage());
 382              }
 383              if ($monBoolean == false) {
 384                  $motMetier = &recuperer_instance_mot();
 385                  $addMotOK = $motMetier->addMot($table, $id_table, $nouv_mot, $id_objet);
 386                  if (PEAR::isError($addMotOK)) {
 387                      die ($addMotOK->getMessage());
 388                  }
 389              }
 390          }
 391      }
 392  
 393      if ($supp_mot && $flag_editable) {
 394          $motMetier = &recuperer_instance_mot();
 395          $deleteMotTableOK = $motMetier->deleteMotTable($table, $id_table, $id_objet, $supp_mot);
 396          if (PEAR::isError($deleteMotTableOK)) {
 397              die ($deleteMotTableOK->getMessage());
 398          }
 399      }
 400  
 401      //
 402      // Afficher les mots-cles
 403      //
 404  
 405      $motMetier = &recuperer_instance_mot();
 406      $types = $motMetier->getAllTypes();
 407  
 408      if (PEAR::isError($types)) {
 409          die ($types->getMessage());
 410      }
 411  
 412      $plusieurs_types = (sizeOf($types) > 1);
 413  
 414      unset ($les_mots);
 415  
 416      $motMetier = &recuperer_instance_mot();
 417      $allMots = $motMetier->getAllFromMotsAndAnotherTable($table, $id_table, $id_objet, true);
 418  
 419      if (PEAR::isError($allMots)) {
 420          die ($allMots->getMessage());
 421      }
 422  
 423      echo "<table border=0 cellspacing=0 cellpadding=2 width=100% background=''>\n";
 424  
 425      $ifond = 0;
 426  
 427      while (list(, $motMetier) = each($allMots)) {
 428          $id_mot = $motMetier->getMotId();
 429          // pour l'arborescence de mot-cles
 430          // On affiche le chemin du mot-cle en cours
 431          $titre_mot    = $motMetier->getTitre();
 432          $chemin_mot = $motMetier->getCheminMot();
 433          $type_mot    = $motMetier->getType();
 434          $descriptif_mot = $motMetier->getDescriptif();
 435          $id_groupe    = $motMetier->getGroupeId();
 436  
 437          $groupeMotMetier = &recuperer_instance_groupe_mot();
 438          $loadOK        = $groupeMotMetier->load($id_groupe);
 439  
 440          if (PEAR::isError($loadOK)) {
 441              die ($loadOK->getMessage());
 442          }
 443          else {
 444              $id_groupe = $groupeMotMetier->getGroupeId();
 445              $titre_groupe = entites_html($groupeMotMetier->getTitre());
 446              $unseul = $groupeMotMetier->getUnSeul();
 447              $obligatoire = $groupeMotMetier->getObligatoire();
 448              $profilMetier = &recuperer_instance_profil();
 449              $monProfilComite = $profilMetier->getProfilForIntitule('item_redacteur_en_chef');
 450              $monProfilMinirezo = $profilMetier->getProfilForIntitule('item_webmestre');
 451  
 452              $flag_groupe = ($flag_editable AND $groupeMotMetier->isManagedByProfil($connect_profil));
 453          }
 454  
 455          $groupes_vus[$id_groupe] = true;
 456          $id_groupes_vus[] = $id_groupe;
 457  
 458          if ($ifond == 0) {
 459              $ifond = 1;
 460              $couleur = "#FFFFFF";
 461          }
 462          else {
 463              $ifond = 0;
 464              $couleur = "#EDF3FE";
 465          }
 466  
 467          $url = "mots_edit.php?id_mot=$id_mot&redirect=" . rawurlencode($url_base . '#mots');
 468  
 469          echo "<TR WIDTH=\"100%\">";
 470          echo "<TD BGCOLOR='$couleur'>";
 471          echo "<A HREF='$url'><img src='img_pack/petite-cle.gif' alt='' width='23' height='12' border='0'></A>";
 472          echo "</TD>";
 473          echo "<TD BGCOLOR='$couleur' width='100%' CLASS='arial2'>";
 474  
 475          // Changer
 476          // ICI CHOIX D'UN MOT CLE UNIQUE D'UN GROUPE AVEC UN MOT DEJA AFFECTE DU GROUPE        
 477          if ($unseul == "oui" AND $flag_groupe) {
 478              echo "<form action='$url_base#mots' method='post' style='margin:0px; padding: 0px'>";
 479              echo "<INPUT TYPE='Hidden' NAME='$id_table' VALUE='$id_objet'>";
 480  
 481              if ($table == 'rubriques')
 482                  echo "<INPUT TYPE='Hidden' NAME='coll' VALUE='$id_objet'>";
 483  
 484              if ($table == 'cm') {
 485                  global $id_newsletter;
 486                  echo "<INPUT TYPE='Hidden' NAME='id_newsletter' VALUE='$id_newsletter'>";
 487                  global $id_post;
 488                  echo "<INPUT TYPE='Hidden' NAME='id_post' VALUE='$id_post'>";
 489              }
 490  
 491              echo "<select name='nouv_mot' CLASS='fondl' STYLE='font-size:10px; width:150px'>";
 492  
 493              $groupeMotMetier2 = &recuperer_instance_groupe_mot();
 494              $groupeMotMetier2->setGroupeId($id_groupe);
 495              $offset = '&nbsp;&nbsp;';
 496              $rootNodes = &$groupeMotMetier2->getMotArbre();
 497  
 498              while (list(, $rootNode) = each($rootNodes)) {
 499                  while (list(, $node) = each($rootNode)) {
 500                      $le_mot = $node->id;
 501                      $le_titre_mot = $node->name;
 502  
 503                      for ($i = 1; $i < $node->level; $i++) {
 504                          $le_titre_mot = $offset . $le_titre_mot;
 505                      }
 506  
 507                      if ($le_mot == $id_mot)
 508                          $selected = "SELECTED";
 509                      else
 510                          $selected = "";
 511                      echo "<option value='$le_mot' $selected> $le_titre_mot";
 512                  }
 513              }
 514  
 515              echo "</select>";
 516              echo "<INPUT TYPE='Hidden' NAME='supp_mot' VALUE='$id_mot'>";
 517              echo "<INPUT TYPE='submit' NAME='Choisir' VALUE='" . _T('bouton_changer'). "' CLASS='fondo' style='font-size: 10px';>";
 518              echo "</form>";
 519          }
 520          else {
 521              echo "$chemin_mot<A HREF='$url'>$titre_mot</A>";
 522          }
 523  
 524          echo "</TD>";
 525  
 526          echo "<TD ALIGN='right' BGCOLOR='$couleur' ALIGN='right' CLASS='arial2'>";
 527          echo "$type_mot";
 528          echo "</TD>";
 529  
 530          if ($flag_editable) {
 531              echo "<TD BGCOLOR='$couleur' ALIGN='right' CLASS='arial1'>";
 532  
 533              if ($flag_groupe)
 534                  echo "<A HREF=\"$url_base&supp_mot=$id_mot#mots\">" . _T('info_retirer_mot'). "&nbsp;" .
 535                      "<img src='img_pack/croix-rouge.gif' alt='X' width='7' height='7' border='0' align='middle'></A>";
 536              else
 537                  echo "&nbsp;";
 538              echo "</TD>\n";
 539          }
 540  
 541          echo "</TR>\n";
 542  
 543          $les_mots[] = $id_mot;
 544      }
 545  
 546      echo "<tr><td></td>\n<td></td>\n<td><img src='img_pack/rien.gif' width=100 height=1></td>\n" .
 547          "<td><img src='img_pack/rien.gif' width=90 height=1></td>\n</tr>\n";
 548      echo "</TABLE>\n";
 549  
 550      /**
 551       * Gestion du brouteur de mots cles
 552       */
 553  
 554      $nb_mots_meta = lire_meta('_nb_limite_kw_selecteur');
 555      $motMetier = &recuperer_instance_mot();
 556      $nombre_mots_affectables = $motMetier->howManyMotForType($table);
 557  
 558      if (PEAR::isError($nombre_mots_affectables)) {
 559          die ($nombre_mots_affectables->getMessage());
 560      }
 561  
 562      if ($nb_mots_meta < $nombre_mots_affectables) {
 563          $form_mot = "<FORM ACTION='" . $_SERVER['PHP_SELF']. "' METHOD='get' STYLE='margin:1px;' name='affectationBrouteur'>\n" 
 564                      ."<input type='HIDDEN' name='coll' value='" . $_GET['coll']. "' >\n" 
 565                      ."<input type='hidden' name='url_post_check' value='$url'>\n" 
 566                      ."<input type='hidden' name='verif_granularite' value='oui'>\n" 
 567                      ."<input type='hidden' name='table' value='$table'>\n" 
 568                      ."<input type='hidden' name='id_table' value='$id_table'>\n" 
 569                      ."<input type='hidden' name='id_objet' value='$id_objet'>\n" 
 570                      ."<input type='hidden' name='$id_table' value='$id_objet'>\n" 
 571                      ."<input type='hidden' name='nouv_mot' value=''>\n" 
 572                      ."<input type='hidden' name='Choisir' value='Choisir'>\n" ."</FORM>\n";
 573          echo $form_mot;
 574          echo "<a href=\"#\" onclick=\"window.open('brouteur_select_mot.php?table=" . $table . "')\">" . _T('utiliser_brouteur_mots_cles'). "</a>";
 575  
 576          // nouv_mot
 577          echo fin_block();
 578          fin_cadre_enfonce();
 579          return;
 580      }
 581      /**
 582       * Fin de Gestion du brouteur de mot cles
 583       */
 584  
 585      if ($les_mots) {
 586          $nombre_mots_associes = count($les_mots);
 587          $les_mots_array = $les_mots;
 588          $les_mots = join($les_mots, ",");
 589      }
 590  
 591      if ($id_groupes_vus)
 592          $id_groupes_vus = join($id_groupes_vus, ",");
 593      else
 594          $id_groupes_vus = "0";
 595  
 596      $groupeMotMetier = &recuperer_instance_groupe_mot();
 597      $allGroupeMot = $groupeMotMetier->getAllForTableAndStatutAndObligatoryAndIdGroupe(
 598                          $table, "'oui'", $connect_profil, "'oui'", $id_groupes_vus);
 599  
 600      if (PEAR::isError($allGroupeMot)) {
 601          die ($allGroupeMot->getMessage());
 602      }
 603  
 604      $nb_groupes = sizeOf($allGroupeMot);
 605  
 606      //
 607      // Afficher le formulaire d'ajout de mots-cles
 608      //
 609  
 610      if ($flag_editable) {
 611          if ($nouveaux_mots . $cherche_mot . $supp_mot)
 612              echo debut_block_visible("lesmots" . $id_javascript);
 613          else if ($nb_groupes > 0) {
 614              echo debut_block_visible("lesmots" . $id_javascript);
 615              // vilain hack pour redresser un triangle
 616              $couche_a_redresser = $GLOBALS['numero_block']['lesmots' . $id_javascript];
 617              if (test_layer())
 618                  echo "<script type='text/javascript'><!--
 619                  triangle = MM_findObj('triangle' + $couche_a_redresser);
 620                  if (triangle) triangle.src = 'img_pack/deplierbas$spip_lang_rtl.gif';
 621                  //--></script>";
 622          }
 623          else
 624              echo debut_block_invisible("lesmots" . $id_javascript);
 625  
 626          // un menu par type de mot : mais une seule case "recherche"
 627          if ($table == 'articles')
 628              $url = 'articles.php';
 629          else if ($table == 'breves')
 630              $url = 'breves_voir.php';
 631          else if ($table == 'rubriques')
 632              $url = 'naviguer.php';
 633          else if ($table == 'auteurs')
 634              $url = 'auteurs_edit.php';
 635  
 636          $case_recherche = false;
 637  
 638          // Choix du mot cle d'un groupe pour ajout
 639          //Passage par une page intermediaire pour verification pas de changement de granularite
 640          $form_mot = "<FORM ACTION='$url_base' METHOD='get' STYLE='margin:1px;'>\n" 
 641                      ."<input type='hidden' name='url_post_check' value='$url'>\n" 
 642                      ."<input type='hidden' name='verif_granularite' value='oui'>\n"
 643                      ."<input type='hidden' name='table' value='$table'>\n"
 644                      ."<input type='hidden' name='id_table' value='$id_table'>\n"
 645                      ."<input type='hidden' name='id_objet' value='$id_objet'>\n"
 646                      ."<input type='hidden' name='$id_table' value='$id_objet'>\n";
 647  
 648          if ($table == 'rubriques')
 649              $form_mot .= "<INPUT TYPE='Hidden' NAME='coll' VALUE='$id_objet'>\n";
 650  
 651          if ($table == 'cm') {
 652              global $id_newsletter;
 653              $form_mot .= "<INPUT TYPE='Hidden' NAME='id_newsletter' VALUE='$id_newsletter'>\n";
 654              global $id_post;
 655              $form_mot .= "<INPUT TYPE='Hidden' NAME='id_post' VALUE='$id_post'>\n";
 656          }
 657  
 658          $message_ajouter_mot = "<FONT FACE='Verdana,Arial,Helvetica,sans-serif' SIZE=2><B>"
 659                                  ._T('titre_ajouter_mot_cle'). " &nbsp; </B></FONT>\n";
 660          echo "<DIV align='right'>";
 661  
 662          //////
 663  
 664          if ($nombre_mots_associes > 3) {
 665              echo "<div align='right' class='arial1'>";
 666              echo "<a href=\"$url_base&supp_mot=-1#mots\">" . _T('info_retirer_mots'). "</a>";
 667              echo "</div><br />\n";
 668          }
 669  
 670          if ($table == 'rubriques')
 671              $form_mot .= "<INPUT TYPE='Hidden' NAME='coll' VALUE='$id_objet'>";
 672  
 673          $message_ajouter_mot = "<FONT FACE='Verdana,Arial,Sans,sans-serif' SIZE=2><B>"
 674                                  ._T('titre_ajouter_mot_cle'). "</B></FONT> &nbsp;\n";
 675          echo "<table border='0' align='right' style='white-space: nowrap'>\n";
 676  
 677          $groupeMotMetier = &recuperer_instance_groupe_mot();
 678          $allGroupeMot = $groupeMotMetier->getAllForTableAndStatutAndUnSeulAndIdGroupe(
 679                              $table, "'oui'", $connect_profil, "'oui'", $id_groupes_vus);
 680  
 681          if (PEAR::isError($allGroupeMot)) {
 682              die ($allGroupeMot->getMessage());
 683          }
 684  
 685          // Afficher un menu par groupe de mots
 686  
 687          while (list(, $groupeMotMetier) = each($allGroupeMot)) {
 688              $id_groupe        = $groupeMotMetier->getGroupeId();
 689              $titre_groupe    = entites_html($groupeMotMetier->getTitre());
 690              $unseul            = $groupeMotMetier->getUnSeul();
 691              $obligatoire    = $groupeMotMetier->getObligatoire();
 692              $articles        = $groupeMotMetier->getArticles();
 693              $breves            = $groupeMotMetier->getBreves();
 694              $rubriques        = $groupeMotMetier->getRubriques();
 695              $syndic            = $groupeMotMetier->getSyndic();
 696              $motMetier        = &recuperer_instance_mot();
 697              $mots            = $motMetier->getAllForGroupIdAndMotId($id_groupe, $les_mots);
 698  
 699              if (PEAR::isError($mots)) {
 700                  die ($mots->getMessage());
 701              }
 702              if (sizeOf($mots) > 0) {
 703                  if (sizeOf($mots) > 50 AND $flag_mots_ressemblants) {
 704                      echo "\n<tr>";
 705                      echo $form_mot;
 706                      echo "\n<td>";
 707                      echo $message_ajouter_mot;
 708                      $message_ajouter_mot = "";
 709                      echo "</td>\n<td>";
 710  
 711                      if ($obligatoire == "oui" AND !$groupes_vus[$id_groupe])
 712                          echo "<INPUT TYPE='text' NAME='cherche_mot' CLASS='fondl' STYLE='width: 200px; background-color:#f3b590;' VALUE=\"$titre_groupe\" SIZE='20'>\n";
 713                      else if ($unseul == "oui")
 714                          echo "<INPUT TYPE='text' NAME='cherche_mot' CLASS='fondl' STYLE='width: 200px; background-color:#cccccc;' VALUE=\"$titre_groupe\" SIZE='20'>\n";
 715                      else
 716                          echo "<INPUT TYPE='text' NAME='cherche_mot' CLASS='fondl' STYLE='width: 200px; ' VALUE=\"$titre_groupe\" SIZE='20'>\n";
 717  
 718                      echo "</td>\n<td>";
 719                      echo "<INPUT TYPE='hidden' NAME='select_groupe'  VALUE='$id_groupe'>\n";
 720  
 721                      echo " <INPUT TYPE='submit' NAME='Chercher' VALUE='"._T('bouton_chercher'). "' CLASS='fondo' STYLE='font-size:10px'>\n";
 722                      echo "</td>\n</FORM>\n";
 723                      echo "</tr>\n";
 724                  }
 725                  else {
 726                      echo "\n<tr>";
 727                      echo "\n<td>";
 728                      echo $form_mot;
 729                      echo $message_ajouter_mot;
 730                      $message_ajouter_mot = "";
 731                      echo "</td>\n<td>";
 732  
 733                      if ($obligatoire == "oui" AND !$groupes_vus[$id_groupe])
 734                          echo "<SELECT NAME='nouv_mot' SIZE='1' STYLE='width: 200px; background-color:#f3b590;' CLASS='fondl'>\n";
 735                      else if ($unseul == "oui")
 736                          echo "<SELECT NAME='nouv_mot' SIZE='1' STYLE='width: 200px; background-color:#cccccc;' CLASS='fondl'>\n";
 737                      else
 738                          echo "<SELECT NAME='nouv_mot' SIZE='1' STYLE='width: 200px; ' CLASS='fondl'>\n";
 739  
 740                      $ifond == 0;
 741                      echo "<OPTION VALUE='x' style='font-variant: small-caps;'>$titre_groupe";
 742                      //Gestion arbo
 743                      $offset = '&nbsp;&nbsp;';
 744                      $rootNodes = &$groupeMotMetier->getMotArbre();
 745  
 746                      while (list(, $rootNode) = each($rootNodes)) {
 747                          while (list(, $node) = each($rootNode)) {
 748                              $id_mot = $node->id;
 749                              $titre_mot = $node->name;
 750                              $texte_option = entites_html(couper($titre_mot . ' ', 50));
 751  
 752                              for ($i = 1; $i < $node->level; $i++) {
 753                                  $texte_option = $offset . $texte_option;
 754                              }
 755  
 756                              echo "\n<OPTION VALUE=\"$id_mot\">";
 757                              echo "&nbsp;&nbsp;&nbsp;";
 758                              echo $texte_option;
 759                          }
 760                      }
 761  
 762                      echo "</SELECT>\n";
 763                      echo "</td>\n<td>";
 764                      echo " &nbsp; <INPUT TYPE='submit' NAME='Choisir' VALUE='"._T('bouton_choisir'). "' CLASS='fondo'>";
 765                      echo "</td></FORM>\n";
 766                      echo "</tr>\n";
 767                  }
 768              }
 769          }
 770          echo "</table>";
 771          echo fin_block();
 772      }
 773      fin_cadre_enfonce();
 774  }
 775  ?>


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