[ Index ] |
|
Code source de SPIP 1.9.2c |
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 et determine_upload 16 include_spip('base/abstract_sql'); 17 18 // 19 // Construire un formulaire pour telecharger un fichier 20 // 21 22 // http://doc.spip.org/@inc_joindre_dist 23 function inc_joindre_dist($script, $args, $id=0, $intitule='', $mode='', $type='', $ancre='', $id_document=0,$iframe_script='') { 24 global $spip_lang_right; 25 $vignette_de_doc = ($mode == 'vignette' AND $id_document>0); 26 $distant = ($mode == 'document' AND $type); 27 if ($intitule) $intitule = "<span>$intitule</span><br />"; 28 29 $dir_ftp = ''; 30 if (!_DIR_RESTREINT AND !$vignette_de_doc AND $GLOBALS['flag_upload']) { 31 if($dir = determine_upload()) { 32 // quels sont les docs accessibles en ftp ? 33 $l = texte_upload_manuel($dir, '', $mode); 34 // s'il n'y en a pas, on affiche un message d'aide 35 // en mode document, mais pas en mode vignette 36 if ($l OR ($mode == 'document')) 37 $dir_ftp = afficher_transferer_upload($l, $dir); 38 } 39 } 40 41 // Add the redirect url when uploading via iframe 42 43 $iframe = ""; 44 if($iframe_script) 45 $iframe = "<input type='hidden' name='iframe_redirect' value='".rawurlencode($iframe_script)."' />\n"; 46 47 // Un menu depliant si on a une possibilite supplementaire 48 49 if ($dir_ftp OR $distant OR $vignette_de_doc) { 50 $bloc = "ftp_$mode" .'_'. intval($id_document); 51 $debut = "\n\t<div style='float:".$GLOBALS['spip_lang_left'].";position:relative'>" 52 . bouton_block_invisible($bloc) ."</div>\n"; 53 $milieu = debut_block_invisible($bloc); 54 $fin = "\n\t" . fin_block(); 55 56 } else $debut = $milieu = $fin = ''; 57 58 // Lien document distant, jamais en mode image 59 if ($distant) { 60 $distant = "<br />\n<div style='border: 1px #303030 solid; padding: 4px; color: #505050;'>" . 61 "\n\t<img src='"._DIR_IMG_PACK.'attachment.gif' . 62 "' style='float: $spip_lang_right;' alt=\"\" />\n" . 63 _T('info_referencer_doc_distant') . 64 "<br />\n\t<input name='url' class='fondo' value='http://' />" . 65 "\n\t<div align='$spip_lang_right'><input name='sousaction2' type='submit' value='". 66 _T('bouton_choisir'). 67 "' class='fondo' /></div>" . 68 "\n</div>"; 69 } 70 71 $res = "<input name='fichier' type='file' class='forml spip_xx-small' size='15' />" 72 . "\n\t\t<input type='hidden' name='ancre' value='$ancre' />" 73 . "\n\t\t<div align='$spip_lang_right'><input name='sousaction1' type='submit' value='" 74 . _T('bouton_telecharger') 75 . "' class='fondo' /></div>"; 76 77 if ($vignette_de_doc) 78 $res = $milieu . $res; 79 else 80 $res = $res . $milieu; 81 82 return generer_action_auteur('joindre', 83 (intval($id) .'/' .intval($id_document) . "/$mode/$type"), 84 (_DIR_RESTREINT)?$script:generer_url_ecrire($script, $args, true), 85 "$iframe$debut$intitule$res$dir_ftp$distant$fin", 86 " method='post' enctype='multipart/form-data' class='form_upload'"); 87 } 88 89 90 // 91 // Retourner le code HTML d'utilisation de fichiers envoyes 92 // 93 94 // http://doc.spip.org/@texte_upload_manuel 95 function texte_upload_manuel($dir, $inclus = '', $mode = 'document') { 96 $fichiers = preg_files($dir); 97 $exts = array(); 98 $dirs = array(); 99 $texte_upload = array(); 100 foreach ($fichiers as $f) { 101 $f = preg_replace(",^$dir,",'',$f); 102 if (ereg("\.([^.]+)$", $f, $match)) { 103 $ext = strtolower($match[1]); 104 if (!isset($exts[$ext])) { 105 if ($ext == 'jpeg') $ext = 'jpg'; # cf. corriger_extension dans inc/getdocument 106 if (spip_abstract_fetsel('extension', 'spip_types_documents', "extension='$ext'" . (!$inclus ? '': " AND inclus='$inclus'"))) 107 $exts[$ext] = 'oui'; 108 else $exts[$ext] = 'non'; 109 } 110 111 $k = 2*substr_count($f,'/'); 112 $n = strrpos($f, "/"); 113 if ($n === false) 114 $lefichier = $f; 115 else { 116 $lefichier = substr($f, $n+1, strlen($f)); 117 $ledossier = substr($f, 0, $n); 118 if (!in_array($ledossier, $dirs)) { 119 $texte_upload[] = "\n<option value=\"$ledossier\">" 120 . str_repeat(" ",$k) 121 ._T('tout_dossier_upload', array('upload' => $ledossier)) 122 ."</option>"; 123 $dirs[]= $ledossier; 124 } 125 } 126 127 if ($exts[$ext] == 'oui') 128 $texte_upload[] = "\n<option value=\"$f\">" . 129 str_repeat(" ",$k+2) . 130 $lefichier . 131 "</option>"; 132 } 133 } 134 135 $texte = join('', $texte_upload); 136 137 if ($mode == "document" AND count($texte_upload)>1) { 138 $texte = "\n<option value=\"/\" style='font-weight: bold;'>" 139 ._T('info_installer_tous_documents') 140 ."</option>" . $texte; 141 } 142 143 return $texte; 144 } 145 146 147 // http://doc.spip.org/@afficher_transferer_upload 148 function afficher_transferer_upload($texte_upload, $dir) 149 { 150 $doc = array('upload' => '<b>' . joli_repertoire($dir) . '</b>'); 151 if (!$texte_upload) { 152 return "\n<div style='border: 1px #303030 solid; padding: 4px; color: #505050;'>" . 153 _T('info_installer_ftp', $doc) . 154 aide("ins_upload") . 155 "</div>"; 156 } 157 else { return 158 "\n<div style='color: #505050;'>" 159 ._T('info_selectionner_fichier', $doc) 160 ." :<br />\n" . 161 "\n<select name='chemin' size='1' class='fondl'>" . 162 $texte_upload . 163 "\n</select>" . 164 "\n<div align='". 165 $GLOBALS['spip_lang_right'] . 166 "'><input name='sousaction3' type='submit' value='" . 167 _T('bouton_choisir'). 168 "' class='fondo' /></div>" . 169 "</div>\n"; 170 } 171 } 172 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Wed Nov 21 10:20:27 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |