Skip to content
Extraits de code Groupes Projets
Valider 946f865c rédigé par esj's avatar esj
Parcourir les fichiers

[7782] en un peu plus rationnel.

parent 4282677b
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -148,6 +148,14 @@ function spip_action_joindre3($path, $mode, $type, $id, $id_document,$hash, $red ...@@ -148,6 +148,14 @@ function spip_action_joindre3($path, $mode, $type, $id, $id_document,$hash, $red
return $ajouter_documents($files, $mode, $type, $id, $id_document, $hash, $redirect, $actifs, $iframe_redirect); return $ajouter_documents($files, $mode, $type, $id, $id_document, $hash, $redirect, $actifs, $iframe_redirect);
} }
#-----------------------------------------------------------------------
// sous-actions suite a l'envoi d'un Zip:
// la fonction ajouter_documents standard a construit un formulaire
// qui renvoie sur une des 3 sous-actions qui suivent.
// On recharge ajouter_document sans l'appeler, car son fichier doit
// contenir les acolytes qui nous interessent (pas bien beau)
// Zip avec confirmation "tel quel" // Zip avec confirmation "tel quel"
// http://doc.spip.org/@spip_action_joindre5 // http://doc.spip.org/@spip_action_joindre5
...@@ -158,12 +166,10 @@ function spip_action_joindre5($path, $mode, $type, $id, $id_document,$hash, $red ...@@ -158,12 +166,10 @@ function spip_action_joindre5($path, $mode, $type, $id, $id_document,$hash, $red
if (!$pos) { if (!$pos) {
$pos = strpos($path, '/zip_'); $pos = strpos($path, '/zip_');
} }
return $ajouter_documents($path, substr($path, $pos+5), $type, $id, $mode, $id_document, $actifs); return ajouter_un_document($path, substr($path, $pos+5), $type, $id, $mode, $id_document, $actifs);
} }
// Zip a deballer. // Zip a deballer.
// Pas tres beau: on charge une fonction pas appelee mais dont le fichier
// contient les acolytes qui nous interessent.
// http://doc.spip.org/@spip_action_joindre6 // http://doc.spip.org/@spip_action_joindre6
function spip_action_joindre6($path, $mode, $type, $id, $id_document,$hash, $redirect, &$actifs, $iframe_redirect) function spip_action_joindre6($path, $mode, $type, $id, $id_document,$hash, $redirect, &$actifs, $iframe_redirect)
...@@ -185,4 +191,5 @@ function spip_action_joindre4($path, $mode, $type, $id, $id_document,$hash, $red ...@@ -185,4 +191,5 @@ function spip_action_joindre4($path, $mode, $type, $id, $id_document,$hash, $red
return spip_action_joindre5($path, $mode, $type, $id, $id_document,$hash, $redirect, $actifs); return spip_action_joindre5($path, $mode, $type, $id, $id_document,$hash, $redirect, $actifs);
} }
?> ?>
...@@ -330,4 +330,174 @@ function joindre_deballes($path, $mode, $type, $id, $id_document,$hash, $redirec ...@@ -330,4 +330,174 @@ function joindre_deballes($path, $mode, $type, $id, $id_document,$hash, $redirec
effacer_repertoire_temporaire(_tmp_dir); effacer_repertoire_temporaire(_tmp_dir);
return $x; return $x;
} }
//
// Convertit le type numerique retourne par getimagesize() en extension fichier
//
// http://doc.spip.org/@decoder_type_image
function decoder_type_image($type, $strict = false) {
switch ($type) {
case 1:
return "gif";
case 2:
return "jpg";
case 3:
return "png";
case 4:
return $strict ? "" : "swf";
case 5:
return "psd";
case 6:
return "bmp";
case 7:
case 8:
return "tif";
default:
return "";
}
}
// http://doc.spip.org/@traite_svg
function traite_svg($file)
{
global $connect_statut;
$texte = spip_file_get_contents($file);
// Securite si pas guru: virer les scripts et les references externes
// Trop expeditif, a ameliorer
$var_auth = charger_fonction('auth', 'inc');
$var_auth();
if ($connect_statut != '0minirezo') {
include_spip('inc/texte');
$new = trim(safehtml($texte));
// petit bug safehtml
if (substr($new,0,2) == ']>') $new = ltrim(substr($new,2));
if ($new != $texte) ecrire_fichier($file, $texte = $new);
}
$width = $height = 150;
if (preg_match(',<svg[^>]+>,', $texte, $s)) {
$s = $s[0];
if (preg_match(',\WviewBox\s*=\s*.\s*(\d+)\s+(\d+)\s+(\d+)\s+(\d+),i', $s, $r)){
$width = $r[3];
$height = $r[4];
} else {
// si la taille est en centimetre, estimer le pixel a 1/64 de cm
if (preg_match(',\Wwidth\s*=\s*.(\d+)([^"\']*),i', $s, $r)){
if ($r[2] != '%') {
$width = $r[1];
if ($r[2] == 'cm') $width <<=6;
}
}
if (preg_match(',\Wheight\s*=\s*.(\d+)([^"\']*),i', $s, $r)){
if ($r[2] != '%') {
$height = $r[1];
if ($r[2] == 'cm') $height <<=6;
}
}
}
}
return array($width, $height);
}
//
// Corrige l'extension du fichier dans quelques cas particuliers
// (a passer dans ecrire/base/typedoc)
//
// http://doc.spip.org/@corriger_extension
function corriger_extension($ext) {
switch ($ext) {
case 'htm':
return 'html';
case 'jpeg':
return 'jpg';
case 'tiff':
return 'tif';
default:
return $ext;
}
}
// Afficher un formulaire de choix: decompacter et/ou garder tel quel.
// Passer ca en squelette un de ces jours.
// http://doc.spip.org/@liste_archive_jointe
function liste_archive_jointe($valables, $mode, $type, $id, $id_document, $hash, $redirect, $zip, $iframe_redirect)
{
$arg = (intval($id) .'/' .intval($id_document) . "/$mode/$type");
$texte =
"<div><input type='radio' checked='checked' name='sousaction5' value='5'>" .
_T('upload_zip_telquel').
"</div>".
"<div><input type='radio' name='sousaction5' value='6'>".
_T('upload_zip_decompacter').
"</div>".
"<ol><li><tt>" .
join("</tt></li>\n<li><tt>", $valables) .
"</tt></li></ol>".
"<div>&nbsp;</div>" .
"<div><input type='checkbox' name='sousaction4' value='4'>".
_T('les_deux').
"</div>".
"<div style='text-align: right;'><input class='fondo' style='font-size: 9px;' type='submit' value='".
_T('bouton_valider').
"'></div>";
echo "<p>build form $iframe_redirect</p>";
$action = construire_upload($texte, array(
'redirect' => $redirect,
'iframe_redirect' => $iframe_redirect,
'hash' => $hash,
'chemin' => $zip,
'arg' => $arg));
if(_request("iframe")=="iframe") {
echo "<div class='upload_answer upload_zip_list'><p>" .
_T('upload_fichier_zip_texte') .
"</p><p>" .
_T('upload_fichier_zip_texte2') .
"</p>" .
$action.
"</div>";
exit;
}
minipres(_T('upload_fichier_zip'),
"<p>" .
_T('upload_fichier_zip_texte') .
"</p><p>" .
_T('upload_fichier_zip_texte2') .
"</p>" .
$action);
// a tout de suite en joindre4, joindre5, ou joindre6
}
// Reconstruit un generer_action_auteur
// http://doc.spip.org/@construire_upload
function construire_upload($corps, $args, $enctype='')
{
$res = "";
foreach($args as $k => $v)
if ($v)
$res .= "\n<input type='hidden' name='$k' value='$v' />";
# ici enlever $action pour uploader directemet dans l'espace prive (UPLOAD_DIRECT)
return "\n<form method='post' action='" . generer_url_action('joindre') .
"'" .
(!$enctype ? '' : " enctype='$enctype'") .
"
>\n" .
"<div>" .
"\n<input type='hidden' name='action' value='joindre' />" .
$res . $corps . "</div></form>";
}
?> ?>
...@@ -186,173 +186,4 @@ function callback_deballe_fichier($p_event, &$p_header) { ...@@ -186,173 +186,4 @@ function callback_deballe_fichier($p_event, &$p_header) {
} }
} }
// http://doc.spip.org/@traite_svg
function traite_svg($file)
{
global $connect_statut;
$texte = spip_file_get_contents($file);
// Securite si pas guru: virer les scripts et les references externes
// Trop expeditif, a ameliorer
$var_auth = charger_fonction('auth', 'inc');
$var_auth();
if ($connect_statut != '0minirezo') {
include_spip('inc/texte');
$new = trim(safehtml($texte));
// petit bug safehtml
if (substr($new,0,2) == ']>') $new = ltrim(substr($new,2));
if ($new != $texte) ecrire_fichier($file, $texte = $new);
}
$width = $height = 150;
if (preg_match(',<svg[^>]+>,', $texte, $s)) {
$s = $s[0];
if (preg_match(',\WviewBox\s*=\s*.\s*(\d+)\s+(\d+)\s+(\d+)\s+(\d+),i', $s, $r)){
$width = $r[3];
$height = $r[4];
} else {
// si la taille est en centimetre, estimer le pixel a 1/64 de cm
if (preg_match(',\Wwidth\s*=\s*.(\d+)([^"\']*),i', $s, $r)){
if ($r[2] != '%') {
$width = $r[1];
if ($r[2] == 'cm') $width <<=6;
}
}
if (preg_match(',\Wheight\s*=\s*.(\d+)([^"\']*),i', $s, $r)){
if ($r[2] != '%') {
$height = $r[1];
if ($r[2] == 'cm') $height <<=6;
}
}
}
}
return array($width, $height);
}
// Afficher un formulaire de choix: decompacter et/ou garder tel quel.
// Passer ca en squelette un de ces jours.
// http://doc.spip.org/@liste_archive_jointe
function liste_archive_jointe($valables, $mode, $type, $id, $id_document, $hash, $redirect, $zip, $iframe_redirect)
{
$arg = (intval($id) .'/' .intval($id_document) . "/$mode/$type");
$texte =
"<div><input type='radio' checked='checked' name='sousaction5' value='5'>" .
_T('upload_zip_telquel').
"</div>".
"<div><input type='radio' name='sousaction5' value='6'>".
_T('upload_zip_decompacter').
"</div>".
"<ol><li><tt>" .
join("</tt></li>\n<li><tt>", $valables) .
"</tt></li></ol>".
"<div>&nbsp;</div>" .
"<div><input type='checkbox' name='sousaction4' value='4'>".
_T('les_deux').
"</div>".
"<div style='text-align: right;'><input class='fondo' style='font-size: 9px;' type='submit' value='".
_T('bouton_valider').
"'></div>";
echo "<p>build form $iframe_redirect</p>";
$action = construire_upload($texte, array(
'redirect' => $redirect,
'iframe_redirect' => $iframe_redirect,
'hash' => $hash,
'chemin' => $zip,
'arg' => $arg));
if(_request("iframe")=="iframe") {
echo "<div class='upload_answer upload_zip_list'><p>" .
_T('upload_fichier_zip_texte') .
"</p><p>" .
_T('upload_fichier_zip_texte2') .
"</p>" .
$action.
"</div>";
exit;
}
minipres(_T('upload_fichier_zip'),
"<p>" .
_T('upload_fichier_zip_texte') .
"</p><p>" .
_T('upload_fichier_zip_texte2') .
"</p>" .
$action);
// a tout de suite en joindre4, joindre5, ou joindre6
}
// Reconstruit un generer_action_auteur
// http://doc.spip.org/@construire_upload
function construire_upload($corps, $args, $enctype='')
{
$res = "";
foreach($args as $k => $v)
if ($v)
$res .= "\n<input type='hidden' name='$k' value='$v' />";
# ici enlever $action pour uploader directemet dans l'espace prive (UPLOAD_DIRECT)
return "\n<form method='post' action='" . generer_url_action('joindre') .
"'" .
(!$enctype ? '' : " enctype='$enctype'") .
"
>\n" .
"<div>" .
"\n<input type='hidden' name='action' value='joindre' />" .
$res . $corps . "</div></form>";
}
//
// Convertit le type numerique retourne par getimagesize() en extension fichier
//
// http://doc.spip.org/@decoder_type_image
function decoder_type_image($type, $strict = false) {
switch ($type) {
case 1:
return "gif";
case 2:
return "jpg";
case 3:
return "png";
case 4:
return $strict ? "" : "swf";
case 5:
return "psd";
case 6:
return "bmp";
case 7:
case 8:
return "tif";
default:
return "";
}
}
//
// Corrige l'extension du fichier dans quelques cas particuliers
// (a passer dans ecrire/base/typedoc)
//
// http://doc.spip.org/@corriger_extension
function corriger_extension($ext) {
switch ($ext) {
case 'htm':
return 'html';
case 'jpeg':
return 'jpg';
case 'tiff':
return 'tif';
default:
return $ext;
}
}
?> ?>
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter