X-Git-Url: http://git.cyclocoop.org/?p=velocampus%2Fweb%2Fwww.git;a=blobdiff_plain;f=www%2Fecrire%2Finc%2Fjoindre.php;fp=www%2Fecrire%2Finc%2Fjoindre.php;h=80012975d53ba4484f7a767cace821d4e592033a;hp=0000000000000000000000000000000000000000;hb=80b4d3e85f78d402ed2e73f8f5d1bf4c19962eed;hpb=aaf970bf4cdaf76689ecc10609048e18d073820c diff --git a/www/ecrire/inc/joindre.php b/www/ecrire/inc/joindre.php new file mode 100644 index 0000000..8001297 --- /dev/null +++ b/www/ecrire/inc/joindre.php @@ -0,0 +1,217 @@ +".$res."\n"; + $att = " enctype='multipart/form-data' class='form_upload'"; + $args = (intval($v['id']) .'/' .intval($v['id_document']) . "/".$v['mode'].'/'.$v['type']); + $script = $v['script']; + + // si espace prive, $v a une signification speciale (pas clair) + if (test_espace_prive()) + return redirige_action_post('joindre', $args, $script, $v['args'], $res, $att); + else return generer_action_auteur('joindre', $args, $script, $res, "$att method='post'"); +} + +// http://doc.spip.org/@joindre_formulaire +function joindre_formulaire(&$v) { + global $spip_lang_right; + $depliable = false; + + $mode = $v['mode']; + $vignette_de_doc = ($mode == 'vignette' AND $v['id_document']>0); + $distant = (($mode == 'document' OR $mode == 'choix') AND $v['type']); + + # indiquer un choix d'upload FTP + $dir_ftp = ''; + if (test_espace_prive() + AND ($mode == 'document' OR $mode == 'choix') # si c'est pour un document + AND !$vignette_de_doc # pas pour une vignette (NB: la ligne precedente suffit, mais si on la supprime il faut conserver ce test-ci) + AND $GLOBALS['flag_upload']) { + if ($dir = determine_upload('documents')) { + // quels sont les docs accessibles en ftp ? + $l = texte_upload_manuel($dir, $mode); + // s'il n'y en a pas, on affiche un message d'aide + // en mode document, mais pas en mode image + if ($l OR ($mode == 'document' OR $mode=='choix')) + $dir_ftp = afficher_transferer_upload($l, $dir); + } + } + + // Add the redirect url when uploading via iframe + + $iframe = ""; + if($v['iframe_script']) + $iframe = "\n"; + + // Un menu depliant si on a une possibilite supplementaire + + if ($dir_ftp OR $distant OR $vignette_de_doc) { + $bloc = "ftp_". $mode .'_'. intval($v['id_document']); + + if ($vignette_de_doc) + $debut = bouton_block_depliable($v['intitule'],false,$bloc); + else + $debut = $v['intitule']; + + $milieu = debut_block_depliable(false,$bloc); + $fin = "\n\t" . fin_block(); + $v['titre'] = bouton_block_depliable($v['titre'],false,$bloc); + + } else + $debut = $milieu = $fin = ''; + + // Lien document distant, jamais en mode image + if ($distant) { + $distant = "
\n
" . + "\n\t\"\"\n" . + "
\n\t" . + "\n\t
" . + "\n
"; + } + + $res = "" + . ($v['ancre'] + ? "\n\t\t" + : '' + ) + . "\n\t\t
"; + + if ($vignette_de_doc) + $res = $milieu . $res; + else + $res = $res . $milieu; + + return "$iframe$debut$res$dir_ftp$distant$fin"; +} + + +// +// Retourner le code HTML d'utilisation de fichiers envoyes +// + +// http://doc.spip.org/@texte_upload_manuel +function texte_upload_manuel($dir, $mode = 'document') { + $fichiers = preg_files($dir); + $exts = array(); + $dirs = array(); + $texte_upload = array(); + + // en mode "charger une image", ne proposer que les inclus + $inclus = ($mode == 'document' OR $mode =='choix') + ? '' + : " AND inclus='image'"; + + foreach ($fichiers as $f) { + $f = preg_replace(",^$dir,",'',$f); + if (preg_match(",\.([^.]+)$,", $f, $match)) { + $ext = strtolower($match[1]); + if (!isset($exts[$ext])) { + include_spip('inc/ajouter_documents'); + $ext = corriger_extension($ext); + if (sql_fetsel('extension', 'spip_types_documents', $a = "extension='$ext'" . $inclus)) + $exts[$ext] = 'oui'; + else $exts[$ext] = 'non'; + } + + $k = 2*substr_count($f,'/'); + $n = strrpos($f, "/"); + if ($n === false) + $lefichier = $f; + else { + $lefichier = substr($f, $n+1, strlen($f)); + $ledossier = substr($f, 0, $n); + if (!in_array($ledossier, $dirs)) { + $texte_upload[] = "\n"; + $dirs[]= $ledossier; + } + } + + if ($exts[$ext] == 'oui') + $texte_upload[] = "\n"; + } + } + + $texte = join('', $texte_upload); + if (count($texte_upload)>1) { + $texte = "\n" . $texte; + } + + return $texte; +} + + +// http://doc.spip.org/@afficher_transferer_upload +function afficher_transferer_upload($texte_upload, $dir) +{ + $doc = array('upload' => '' . joli_repertoire($dir) . ''); + if (!$texte_upload) { + return "\n
" . + _T('info_installer_ftp', $doc) . + aide("ins_upload") . + "
"; + } + else { return + "\n
" + ." :
\n" . + "\n" . + "\n
" . + "
\n"; + } +} +?>