$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.='<tr><th colspan="2"><strong>' . __('Générer un favicon') . '</strong></th></tr>';
+ $res.='<tr><td>' . __('Veuillez charger une image carrée (dimensions optimales : 256x256 px)') . '</td>';
+ $res.='<td><input type="file" name="file" /></td></tr>';
+ $res.='<tr class="odd"><td>' . __('Bord arrondi') . '</td>';
+ $res.='<td><input type="number" name="round" value="0" size="5" />%</td><td>Valeur</td></tr>';
+ $res.='<tr><td class="right" colspan="2"><a href="#" class="submit">' . $core->typo->BoutonOK(__('Générer le favicon')) . '</a></td></td>';
$res.='</table>';
$res.='</form>';
$res .= '</div>';
$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');
$zip->execute();
cubeHTTP::downloadFile($tmpfile, 'favicon.zip');
+
+ // Clean !
+ unlink($tmpfile);
+ unlink($round);
+ `rm -rf $tmp`;
}
public static function getDefaultLanguage() {
$this->fields['mobilePlugins'] = array('type' => 'textarea', 'default' => '', 'editable' => true, 'label' => __('Plugin'), 'grade' => 5);\r
\r
$this->fields['mobileVideosPath'] = array('type' => 'text', 'default' => '', 'editable' => true, 'label' => __('Chemin vers les vidéos'), 'grade' => 5);\r
-\r
+ $this->fields['mobileExtraXSpace'] = array('type' => 'integer', 'default' => '0', 'editable' => true, 'label' => __('Marge supplémentaire horizontale'), 'grade' => 3);\r
\r
$this->forms['mobile'] = array('label' => __('Version mobile'),\r
- 'fieldsnames' => array('mobileLVersion', 'mobileVersion', '|', 'mobileTransitions', 'mobileTransitionDuration', '|', 'mobileIconVector', 'mobileServerConfig', 'mobilePlugins', '|', 'mobileVideosPath'));\r
+ 'fieldsnames' => array('mobileLVersion', 'mobileVersion', '|', 'mobileTransitions', 'mobileTransitionDuration', '|', 'mobileIconVector', 'mobileServerConfig', 'mobilePlugins', '|', 'mobileVideosPath', '|', 'mobileExtraXSpace'));\r
\r
$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');\r
$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');\r