[ Index ]
 

Code source de SPIP 1.9.2c

Accédez au Source d'autres logiciels libres

title

Body

[fermer]

/ecrire/inc/ -> tourner.php (source)

   1  <?php
   2  
   3  /***************************************************************************\
   4   *  SPIP, Systeme de publication pour l'internet                           *
   5   *                                                                         *
   6   *  Copyright (c) 2001-2007                                                *
   7   *  Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James  *
   8   *                                                                         *
   9   *  Ce programme est un logiciel libre distribue sous licence GNU/GPL.     *
  10   *  Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne.   *
  11  \***************************************************************************/
  12  
  13  if (!defined("_ECRIRE_INC_VERSION")) return;
  14  
  15  include_spip('inc/actions'); // *action_auteur
  16  include_spip('inc/documents');
  17  include_spip('inc/filtres');
  18  
  19  // http://doc.spip.org/@inc_tourner_dist
  20  function inc_tourner_dist($id_document, $document, $script, $flag, $type)
  21  {
  22      global $spip_lang_right;
  23  
  24      if (!$document) {
  25          // retour d'Ajax
  26          $document = spip_fetch_array(spip_query("SELECT * FROM spip_documents WHERE id_document = " . intval($id_document)));
  27      }
  28  
  29      if (preg_match('/^\w+$/',$type)) { // securite
  30          $id = spip_fetch_array(spip_query("SELECT id_$type FROM spip_documents_$type" . "s WHERE id_document = " . intval($id_document)), SPIP_NUM);
  31          $id = $id[0];
  32      } else $id = 0; // le hash sera inutilisable
  33  
  34      $titre = $document['titre'];
  35      $id_vignette = $document['id_vignette'];
  36      $fichier = entites_html($document['fichier']);
  37  
  38      if (isset($document['url']))
  39          $url = $document['url'];
  40      else {
  41          charger_generer_url();
  42          $url = generer_url_document($id_document);
  43      }
  44  
  45      $res = '';
  46  
  47      // Indiquer les documents manquants avec un panneau de warning
  48  
  49      if ($document['distant'] != 'oui') {
  50          if (!@file_exists(_DIR_RACINE.$document['fichier'])) {
  51              $c = _T('fichier_introuvable',
  52                      array('fichier'=>basename($document['fichier'])));
  53              $res = "<img src='" . _DIR_IMG_PACK . "warning-24.gif'"
  54                  ."\n\tstyle='float: right;'\n\talt=\"$c\"\n\ttitle=\"$c\" />";
  55          } else     if ($flag)
  56              $res = boutons_rotateurs($document, $type, $id, $id_document,$script,  $id_vignette);
  57  
  58          $boite = '';
  59  
  60      } else {
  61      // Signaler les documents distants par une icone de trombone
  62          $boite = "\n<img src='"._DIR_IMG_PACK.'attachment.gif'."'\n\t style='float: $spip_lang_right;'\n\talt=\"$fichier\"\n\ttitle=\"$fichier\" />\n";
  63      }
  64  
  65      $res .= "<div style='text-align: center;'>";
  66      $res .= document_et_vignette($document, $url, true);
  67      $res .= "</div>\n";
  68  
  69      $res .= "<div style='text-align: center; color: 333333;' class='verdana1 spip_x-small'>&lt;doc"
  70      .  $id_document
  71      . "&gt;</div>";
  72  
  73      if ($boite) return "$boite<div>$res</div>";
  74  
  75      return ajax_action_greffe("tourner-$id_document", $res);
  76  }
  77  
  78  // http://doc.spip.org/@boutons_rotateurs
  79  function boutons_rotateurs($document, $type, $id, $id_document, $script, $id_vignette) {
  80      global $spip_lang_right;
  81      static $ftype = array(1 => 'jpg', 2 => 'png', 3 => 'gif');
  82  
  83      $process = $GLOBALS['meta']['image_process'];
  84  
  85      // bloc rotation de l'image
  86      // si c'est une image, qu'on sait la faire tourner, qu'elle
  87      // n'est pas distante, qu'elle est bien presente dans IMG/
  88      // qu'elle n'a pas de vignette perso ; et qu'on a la bibli !
  89      if ($document['distant']!='oui' AND !$id_vignette
  90      AND isset($ftype[$document['id_type']])
  91      AND strstr($GLOBALS['meta']['formats_graphiques'],
  92             $ftype[$document['id_type']])
  93      AND ($process == 'imagick'
  94          OR $process == 'gd2'
  95          OR $process == 'convert'
  96          OR $process == 'netpbm')
  97      AND @file_exists(_DIR_RACINE.$document['fichier'])
  98      ) {
  99  
 100        return "\n<div class='verdana1' style='float: $spip_lang_right; text-align: $spip_lang_right;'>" .
 101  
 102          bouton_tourner_document($id, $id_document, $script, -90, $type, 'tourner-gauche.gif', _T('image_tourner_gauche')) .
 103  
 104          bouton_tourner_document($id, $id_document, $script,  90, $type, 'tourner-droite.gif', _T('image_tourner_droite')) .
 105  
 106          bouton_tourner_document($id, $id_document, $script, 180, $type, 'tourner-180.gif', _T('image_tourner_180')) .
 107          "</div>\n";
 108      }
 109  }
 110  
 111  // http://doc.spip.org/@bouton_tourner_document
 112  function bouton_tourner_document($id, $id_document, $script, $rot, $type, $img, $title)
 113  {
 114    return ajax_action_auteur("tourner",
 115                  "$id_document-$rot",
 116                  $script,
 117                  "show_docs=$id_document&id_$type=$id#tourner-$id_document",
 118                  array(http_img_pack($img, $title, ''),
 119                    " class='bouton_rotation'"),
 120                  "&id_document=$id_document&id=$id&type=$type");
 121  }
 122  ?>


Généré le : Wed Nov 21 10:20:27 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics