From 3cd5819227e3b4dc280cb5b6be7a583c67618de1 Mon Sep 17 00:00:00 2001 From: "vincent@cubedesigners.com" Date: Fri, 3 Feb 2012 11:10:09 +0000 Subject: [PATCH] --- inc/extranet/Controlleur/_common.php | 1 + .../Controlleur/class.extranet.ajax.php | 4 + .../Controlleur/class.extranet.tools.php | 108 ++++++++++++++++++ .../Controlleur/class.extranet.url.php | 2 + inc/extranet/prepend.php | 1 + inc/ws/Controlleur/class.ws.url.php | 5 - 6 files changed, 116 insertions(+), 5 deletions(-) create mode 100644 inc/extranet/Controlleur/class.extranet.tools.php diff --git a/inc/extranet/Controlleur/_common.php b/inc/extranet/Controlleur/_common.php index 33ca12152..ef0ec3b9a 100644 --- a/inc/extranet/Controlleur/_common.php +++ b/inc/extranet/Controlleur/_common.php @@ -4,5 +4,6 @@ $__autoload['extranetAjax'] = dirname(__FILE__) . '/class.extranet.ajax.php'; $__autoload['extranetUrl'] = dirname(__FILE__) . '/class.extranet.url.php'; $__autoload['extranetDroits'] = dirname(__FILE__) . '/class.extranet.droits.php'; $__autoload['extranetPageChiffres'] = dirname(__FILE__) . '/class.extranet.page.chiffres.php'; +$__autoload['extranetTools'] = dirname(__FILE__) . '/class.extranet.tools.php'; ?> \ No newline at end of file diff --git a/inc/extranet/Controlleur/class.extranet.ajax.php b/inc/extranet/Controlleur/class.extranet.ajax.php index 50a53ae13..6b8f2b02e 100644 --- a/inc/extranet/Controlleur/class.extranet.ajax.php +++ b/inc/extranet/Controlleur/class.extranet.ajax.php @@ -568,6 +568,10 @@ class extranetAjax { public static function chargesDetails($args, &$x) { commonAjax::form('', sprintf(__("Détails des charges de l'année %s"), date('Y')), extranetPageChiffres::chargesDetails($args), '', 3, 'liste'); } + + public static function makeFavicon($args,&$x){ + $x->addRedirection(extranetTools::makeFavicon()); + } } diff --git a/inc/extranet/Controlleur/class.extranet.tools.php b/inc/extranet/Controlleur/class.extranet.tools.php new file mode 100644 index 000000000..6edacc5d9 --- /dev/null +++ b/inc/extranet/Controlleur/class.extranet.tools.php @@ -0,0 +1,108 @@ +'; + $res.=''; + $res.=''; + $res.=''; + $res.=''; + $res.=''; + $res.='
' . __('Générer un favicon') . '
' . __('Veuillez charger une image carrée (dimensions optimales : 256x256 px)') . '
' . $core->typo->BoutonOK(__('Générer le favicon')) . '
'; + $res.=''; + $res .= ''; + $res .= commonPage::bf(); + $res .= commonPage::bMain(); + return $res; + } + + public static function makeFavicon() { + + $tmp = cubeFiles::tempdir(); + mkdir($tmp, 0777, true); + + + + $upload=$_FILES['file']['tmp_name']; + + $icotool = new cubeCommandLine('icotool'); + $icotool->setArg('c'); + $icotool->setArg('o', $tmp . '/favicon.ico'); + + $sizes = array(256, 128, 114, 72, 64, 57, 32, 16); + $apple = array(114, 72, 57); + + + foreach ($sizes as $s) { + if (in_array($s, $apple)) { + $r = $tmp . '/favicon-ios-' . $s . '.png'; + } else { + $r = $tmp . '/ico-' . $s . '.png'; + } + $it = new cubeImageTools(); + $it->loadImage($upload); + $it->resize($s, $s, 'crop', true, 'C', 'M', 'transparent'); + $it->output('png', $r); + if (in_array($s, $apple)) { + continue; + } + $icotool->setArg(null, $r); + } + + $icotool->execute(); + + rename($tmp . '/ico-16.png', $tmp.'/favicon.png'); + + foreach ($sizes as $s) { + if ($s == 16 || in_array($s, $apple)) { + continue; + } + unlink($tmp . '/ico-' . $s . '.png'); + } + + $tmpfile = cubeFiles::tempnam().'.zip'; + + $zip = new cubeCommandLine('zip'); + $zip->cd($tmp); + $zip->setArg(null, $tmpfile); + $zip->setArg('0'); + $zip->setArg('u'); + $zip->setArg('r'); + $zip->setArg('X'); + $zip->setArg(null, '.'); + $zip->execute(); + + fb($zip->commande); + fb($zip->output); + + cubeHTTP::downloadFile($tmpfile, 'favicon.zip'); + } + +} + +?> diff --git a/inc/extranet/Controlleur/class.extranet.url.php b/inc/extranet/Controlleur/class.extranet.url.php index d655dea72..fadc330ea 100644 --- a/inc/extranet/Controlleur/class.extranet.url.php +++ b/inc/extranet/Controlleur/class.extranet.url.php @@ -1595,6 +1595,8 @@ class extranetUrl { return $res; } + + } ?> \ No newline at end of file diff --git a/inc/extranet/prepend.php b/inc/extranet/prepend.php index 2f04b3dd5..1a966f652 100644 --- a/inc/extranet/prepend.php +++ b/inc/extranet/prepend.php @@ -1,4 +1,5 @@ url->register('cleanDownload', 'cleanDownload', '^cleanDownload$', array('extranetUrl', 'cleanDownload')); +$core->url->register('tools', 'tools', '^tools(.*)$', array('extranetTools', 'hub')); ?> diff --git a/inc/ws/Controlleur/class.ws.url.php b/inc/ws/Controlleur/class.ws.url.php index 4225d0d3f..69d988863 100644 --- a/inc/ws/Controlleur/class.ws.url.php +++ b/inc/ws/Controlleur/class.ws.url.php @@ -1478,10 +1478,6 @@ html{height:100%}' . "\n"; commonDroits::min(3); - $res = commonPage::barre(); - $res .= commonPage::tMain(null, false); - - $res .= commonPage::bh(); $demande_id = $args[1]; $revendeur_id = $args[2]; @@ -1529,7 +1525,6 @@ html{height:100%}' . "\n"; $res .= commonPage::bMain(); return $res; } - } ?> \ No newline at end of file -- 2.39.5