]> _ Git - cubeextranet.git/commitdiff
(no commit message)
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Fri, 3 Feb 2012 11:10:09 +0000 (11:10 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Fri, 3 Feb 2012 11:10:09 +0000 (11:10 +0000)
inc/extranet/Controlleur/_common.php
inc/extranet/Controlleur/class.extranet.ajax.php
inc/extranet/Controlleur/class.extranet.tools.php [new file with mode: 0644]
inc/extranet/Controlleur/class.extranet.url.php
inc/extranet/prepend.php
inc/ws/Controlleur/class.ws.url.php

index 33ca1215282c5967952dc02380c135c7011e768f..ef0ec3b9af6c460128ed0d237c750016986f2593 100644 (file)
@@ -4,5 +4,6 @@ $__autoload['extranetAjax'] = dirname(__FILE__) . '/class.extranet.ajax.php';
 $__autoload['extranetUrl'] = dirname(__FILE__) . '/class.extranet.url.php';\r
 $__autoload['extranetDroits'] = dirname(__FILE__) . '/class.extranet.droits.php';\r
 $__autoload['extranetPageChiffres'] = dirname(__FILE__) . '/class.extranet.page.chiffres.php';\r
+$__autoload['extranetTools'] = dirname(__FILE__) . '/class.extranet.tools.php';\r
 \r
 ?>
\ No newline at end of file
index 50a53ae133ab5cd18c81a3bb8f3ccaece44f593a..6b8f2b02e58987db556d7cea7f69acbde6020cd8 100644 (file)
@@ -568,6 +568,10 @@ class extranetAjax {
        public static function chargesDetails($args, &$x) {\r
                commonAjax::form('', sprintf(__("Détails des charges de l'année %s"), date('Y')), extranetPageChiffres::chargesDetails($args), '', 3, 'liste');\r
        }\r
+       \r
+       public static function makeFavicon($args,&$x){\r
+               $x->addRedirection(extranetTools::makeFavicon());\r
+       }\r
 \r
 }\r
 \r
diff --git a/inc/extranet/Controlleur/class.extranet.tools.php b/inc/extranet/Controlleur/class.extranet.tools.php
new file mode 100644 (file)
index 0000000..6edacc5
--- /dev/null
@@ -0,0 +1,108 @@
+<?php
+
+class extranetTools {
+
+       public static function hub($args) {
+               global $core;
+               $args = cubePage::getArgs($args);
+
+               $function = array_shift($args);
+
+               if (!isset($_GET['light'])) {
+                       echo commonPage::header($args);
+               }
+
+               $cb = array('extranetTools', $function);
+               if (is_callable($cb)) {
+                       echo call_user_func($cb, $args);
+               }
+
+               if (!isset($_GET['light'])) {
+                       echo commonPage::footer();
+               }
+       }
+
+       public static function favicon($args) {
+               global $core;
+               $res = commonPage::barre();
+               $res .= commonPage::tMain();
+               $res .= commonPage::bh();
+               $res.='<form action="' . SITE_PATH . 'tools/makeFavicon" method="post" class="notajax" enctype="multipart/form-data">';
+               $res.='<table class="liste">';
+               $res.='<tr><th><strong>' . __('Générer un favicon') . '</strong></th></tr>';
+               $res.='<tr><td>' . __('Veuillez charger une image carrée (dimensions optimales : 256x256 px)') . '</td></tr>';
+               $res.='<tr class="odd"><td><input type="file" name="file" /></td></tr>';
+               $res.='<tr><td class="right"><a href="#" class="submit">' . $core->typo->BoutonOK(__('Générer le favicon')) . '</a></td></td>';
+               $res.='</table>';
+               $res.='</form>';
+               $res .= '</div>';
+               $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');
+       }
+
+}
+
+?>
index d655dea721aa9035a645c143a7964f1846a74340..fadc330ea3fa0252768e788b13b3cff09703a0d1 100644 (file)
@@ -1595,6 +1595,8 @@ class extranetUrl {
                return $res;\r
        }\r
 \r
+\r
+\r
 }\r
 \r
 ?>
\ No newline at end of file
index 2f04b3dd5165829e6285fe783d7c51e2b233a0a9..1a966f652725d3fd52a722ffbdee077605a3bbc7 100644 (file)
@@ -1,4 +1,5 @@
 <?php
 
 $core->url->register('cleanDownload', 'cleanDownload', '^cleanDownload$', array('extranetUrl', 'cleanDownload'));
+$core->url->register('tools', 'tools', '^tools(.*)$', array('extranetTools', 'hub'));
 ?>
index 4225d0d3f02cf89a1247a2bbe7435aa28ba1de68..69d9888631fd823776006b483a97fe040cd61410 100644 (file)
@@ -1478,10 +1478,6 @@ html{height:100%}' . "\n";
 \r
                commonDroits::min(3);\r
 \r
-               $res = commonPage::barre();\r
-               $res .= commonPage::tMain(null, false);\r
-\r
-               $res .= commonPage::bh();\r
 \r
                $demande_id = $args[1];\r
                $revendeur_id = $args[2];\r
@@ -1529,7 +1525,6 @@ html{height:100%}' . "\n";
                $res .= commonPage::bMain();\r
                return $res;\r
        }\r
-\r
 }\r
 \r
 ?>
\ No newline at end of file