From f744bc5a628b3542fa33e8a7d852e797a09dc730 Mon Sep 17 00:00:00 2001 From: "vincent@cubedesigners.com" Date: Thu, 20 Dec 2012 13:30:42 +0000 Subject: [PATCH] --- inc/commons/class.common.tools.php | 60 +++++++++++++++---- inc/config.inc.php | 2 +- inc/ws/DAO/class.ws.dao.book.php | 8 ++- inc/ws/Metier/class.ws.book.parametres.php | 4 +- inc/ws/Util/html5/class.ws.html5.compiler.php | 5 +- 5 files changed, 61 insertions(+), 18 deletions(-) diff --git a/inc/commons/class.common.tools.php b/inc/commons/class.common.tools.php index ea454eea0..a9b9bb627 100644 --- a/inc/commons/class.common.tools.php +++ b/inc/commons/class.common.tools.php @@ -184,10 +184,12 @@ class commonTools { $res .= commonPage::bh(); $res.='
'; $res.=''; - $res.=''; - $res.=''; - $res.=''; - $res.=''; + $res.=''; + $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')) . '
' . __('Générer un favicon') . '
' . __('Veuillez charger une image carrée (dimensions optimales : 256x256 px)') . '
' . __('Bord arrondi') . '%Valeur
' . $core->typo->BoutonOK(__('Générer le favicon')) . '
'; $res.='
'; $res .= ''; @@ -291,38 +293,69 @@ class commonTools { $tmp = cubeFiles::tempdir(); mkdir($tmp, 0777, true); - $upload = $_FILES['file']['tmp_name']; + $upload = $tmp . '/upload.png'; + move_uploaded_file($_FILES['file']['tmp_name'], $upload); + + if (!isset($_POST['round']) || $_POST['round'] == 0) { + $round = $upload; + } else { + $dim = getimagesize($upload); + $w = $dim[0]; + $ra = round($w * ($_POST['round'] / 100)); + $round = $tmp . '/round.png'; + $im = new cubeCommandLine('convert'); + $im->setPath(CONVERTER_PATH); + $im->setArg(null, $upload); + $c = '\( +clone -alpha extract '; + $c.='-draw \'fill black polygon 0,0 0,' . $ra . ' ' . $ra . ',0 fill white circle ' . $ra . ',' . $ra . ' ' . $ra . ',0\' '; + $c.='\( +clone -flip \) -compose Multiply -composite '; + $c.='\( +clone -flop \) -compose Multiply -composite '; + $c.='\) -alpha off -compose CopyOpacity -composite '; + $im->setManualArg($c); + $im->setArg(null, $round); + $im->execute(); + } + + $png2icns = new cubeCommandLine('png2icns'); + $png2icns->setArg(null, $tmp . '/favicon.icns'); $icotool = new cubeCommandLine('icotool'); $icotool->setArg('c'); $icotool->setArg('o', $tmp . '/favicon.ico'); - $sizes = array(16, 32, 57, 64, 72, 114, 128, 144, 256); + $sizes = array(16, 32, 57, 64, 72, 114, 128, 144, 256, 512); $apple = array(144, 114, 72, 57); - + $icns = array(128, 256, 512); 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); } + $r = $tmp . '/ico-' . $s . '.png'; $it = new cubeImageTools(); - $it->loadImage($upload); + $it->loadImage($round); $it->resize($s, $s, 'crop', true, 'C', 'M', 'transparent'); $it->output('png', $r); if (in_array($s, $apple)) { continue; } $icotool->setArg(null, $r); + if (in_array($s, $icns)) { + $png2icns->setArg(null, $r); + } } $icotool->execute(); + $png2icns->execute(); rename($tmp . '/ico-16.png', $tmp . '/favicon.png'); foreach ($sizes as $s) { - if ($s == 16 || in_array($s, $apple)) { + if ($s == 16) { continue; } unlink($tmp . '/ico-' . $s . '.png'); @@ -341,6 +374,11 @@ class commonTools { $zip->execute(); cubeHTTP::downloadFile($tmpfile, 'favicon.zip'); + + // Clean ! + unlink($tmpfile); + unlink($round); + `rm -rf $tmp`; } public static function getDefaultLanguage() { diff --git a/inc/config.inc.php b/inc/config.inc.php index e1bb52ac6..920c82c89 100644 --- a/inc/config.inc.php +++ b/inc/config.inc.php @@ -10,7 +10,7 @@ define('SITE_PATH', WEBROOT . '/'); define('FONT_PATH', ROOT . '/fluidbook/fonts/'); define('FTPROOT', '/home/extranet/ftp/'); define('WINDOWS', false); -define('CONVERTER_PATH', '/bin:/usr/bin:/usr/local/bin:/home/extranet/www/fluidbook/tools:/usr/local/flex:/usr/local/secureSWF:/usr/local/scour:/home/extranet/node_modules/uglify-js/bin'); +define('CONVERTER_PATH', '/bin:/usr/bin:/usr/local/bin:/home/extranet/www/fluidbook/tools:/usr/local/flex:/usr/local/secureSWF:/usr/local/scour:/home/extranet/node_modules/uglify-js/bin:/usr/local/ImageMagick/bin'); define('MXMLC_PATH', '/usr/local/flex/bin/mxmlc'); define('MXMLC_PATH_3', '/usr/local/flex_sdk_3.6/bin/mxmlc'); define('AS3_SOURCES', '/home/as/sources/as/as3'); diff --git a/inc/ws/DAO/class.ws.dao.book.php b/inc/ws/DAO/class.ws.dao.book.php index 84956a743..0594a202b 100644 --- a/inc/ws/DAO/class.ws.dao.book.php +++ b/inc/ws/DAO/class.ws.dao.book.php @@ -1167,13 +1167,17 @@ class wsDAOBook extends commonDAO { $countryNames = array(); $iso = l10n::getISOcodes(); $chars = '()'; + $vuFlags = array(); foreach ($langs as $l) { list($mlang, $flag, $url) = explode(',', trim($l), 3); - $flex->addBitmap(cubeMedia::getFlagFile($flag), 'flag_' . $flag); + if (!isset($vuFlags[$flag])) { + $flex->addBitmap(cubeMedia::getFlagFile($flag), 'flag_' . $flag); + $vuFlags[$flag] = true; + } $n = cubeText::ucfirst($iso[$mlang]); $langNames[$mlang] = $n; $cn = cubeCountry::getCountryName($flag, $mlang); - $countryNames[$flag] = $cn; + $countryNames[$mlang . '_' . $flag] = $cn; $chars.=$n . $cn; } diff --git a/inc/ws/Metier/class.ws.book.parametres.php b/inc/ws/Metier/class.ws.book.parametres.php index 57249694e..43d5c8a01 100644 --- a/inc/ws/Metier/class.ws.book.parametres.php +++ b/inc/ws/Metier/class.ws.book.parametres.php @@ -267,10 +267,10 @@ class wsBookParametres extends wsParametres { $this->fields['mobilePlugins'] = array('type' => 'textarea', 'default' => '', 'editable' => true, 'label' => __('Plugin'), 'grade' => 5); $this->fields['mobileVideosPath'] = array('type' => 'text', 'default' => '', 'editable' => true, 'label' => __('Chemin vers les vidéos'), 'grade' => 5); - + $this->fields['mobileExtraXSpace'] = array('type' => 'integer', 'default' => '0', 'editable' => true, 'label' => __('Marge supplémentaire horizontale'), 'grade' => 3); $this->forms['mobile'] = array('label' => __('Version mobile'), - 'fieldsnames' => array('mobileLVersion', 'mobileVersion', '|', 'mobileTransitions', 'mobileTransitionDuration', '|', 'mobileIconVector', 'mobileServerConfig', 'mobilePlugins', '|', 'mobileVideosPath')); + 'fieldsnames' => array('mobileLVersion', 'mobileVersion', '|', 'mobileTransitions', 'mobileTransitionDuration', '|', 'mobileIconVector', 'mobileServerConfig', 'mobilePlugins', '|', 'mobileVideosPath', '|', 'mobileExtraXSpace')); $this->fields['phonegapId'] = array('type' => 'text', 'default' => 'com.fluidbook.phonegap.$id', 'editable' => true, 'label' => __("Identifiant de l'identifiant"), 'grade' => 5, 'hint' => __('De la forme') . ' com.fluidbook.phonegap.xxxxx'); $this->fields['phonegapVersion'] = array('type' => 'text', 'default' => '1.0.0', 'editable' => true, 'label' => __("Version de l'application"), 'grade' => 5, 'hint' => __('De la forme') . ' 1.2.3'); diff --git a/inc/ws/Util/html5/class.ws.html5.compiler.php b/inc/ws/Util/html5/class.ws.html5.compiler.php index 788fb01d9..2d47d3174 100644 --- a/inc/ws/Util/html5/class.ws.html5.compiler.php +++ b/inc/ws/Util/html5/class.ws.html5.compiler.php @@ -513,11 +513,12 @@ class wsHTML5Compiler { } protected function writePrint() { - $res = '
'; + $res=''; + /*$res .= '
'; for ($i = 1; $i <= $this->book->parametres->pages; $i++) { $res.='
'; } - $res.='
'; + $res.='
';*/ return $res; } -- 2.39.5