]> _ Git - cubeextranet.git/commitdiff
(no commit message)
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Tue, 13 Nov 2012 19:00:24 +0000 (19:00 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Tue, 13 Nov 2012 19:00:24 +0000 (19:00 +0000)
.htaccess
inc/commons/class.common.tools.php
inc/commons/class.common.url.php
inc/ws/Metier/class.ws.theme.parametres.php
inc/ws/Util/packager/class.ws.packager.phonegap.php

index 32dcb4bc4fa74b68ca115763a77f83d6e752a7f3..05044698fc3e5759d02b96590de02e0b813278fa 100644 (file)
--- a/.htaccess
+++ b/.htaccess
@@ -31,7 +31,7 @@ AddCharset UTF-8 log
        #RewriteRule ^docs - [L]\r
 \r
        RewriteRule ^ajax/supprimeFichier/([0-9]+)/(.*)$ index.php/ajax/supprimeFichier/$1/$2 [L]\r
-       RewriteRule ^telecharger/([0-9]+)/(.*)$ index.php/telecharger/$1/$2 [L]\r
+       RewriteRule ^telecharger/([0-9a-fA-F]+)/([0-9]+)/(.*)$ index.php/telecharger/$1/$2/$3 [L]\r
        RewriteRule ^([-_a-zA-Z0-9/]+)$ index.php/$1 [L]\r
 \r
        RewriteRule ^viewer/([0-9]+)_([0-9a-fA-F]+)_([0-9]+)/index.html$ viewer/$1_$2_$3/index [L]\r
index f7b816c44e7f02c90f671c66f64e3f3e3f436d9f..dce745e8e262f48b86c39e41584bb0f80864d851 100644 (file)
@@ -297,8 +297,8 @@ class commonTools {
                $icotool->setArg('c');
                $icotool->setArg('o', $tmp . '/favicon.ico');
 
-               $sizes = array(16, 32, 57, 64, 72, 114, 128, 256);
-               $apple = array(114, 72, 57);
+               $sizes = array(16, 32, 57, 64, 72, 114, 128, 144, 256);
+               $apple = array(144, 114, 72, 57);
 
 
                foreach ($sizes as $s) {
index 7eb914ddc5796b234a3c74510d1b14eb127a3877..05e972468013c6d740b044fea9c66072cc3e65d3 100644 (file)
@@ -425,11 +425,12 @@ class commonUrl {
                global $core;\r
                $ext = files::getExtension($fichier->relPath);\r
 \r
-               if ($ext == 'ipa' && (stristr($_SERVER['HTTP_USER_AGENT'], 'iphone') || stristr($_SERVER['HTTP_USER_AGENT'], 'ipad') || stristr($_SERVER['HTTP_USER_AGENT'], 'ipod') )) {\r
-                       return '<a href="itms-services://?action=download-manifest&url=' . self::manifestFromIpa($fichier) . '">' . $core->typo->Telecharger('Installer') . '</a>';\r
-               } else {\r
-                       return '<a href="' . SITE_PATH . 'telecharger/' . $fichier->relPath . '">' . $core->typo->Telecharger('Télécharger') . '</a>';\r
+               $res = '';\r
+               if ($ext == 'ipa') {\r
+                       $res.='<a href="itms-services://?action=download-manifest&url=' . self::manifestFromIpa($fichier) . '">' . $core->typo->Telecharger('Installer') . '</a> ';\r
                }\r
+               $res.= '<a href="' . SITE_PATH . 'telecharger/' . self::hashFile($fichier->relPath) . '/' . $fichier->relPath . '">' . $core->typo->Telecharger('Télécharger') . '</a>';\r
+               return $res;\r
        }\r
 \r
        public static function manifestFromIpa($fichier) {\r
@@ -451,11 +452,12 @@ class commonUrl {
                        $plist = new CFPropertyList\CFPropertyList($tmp);\r
 \r
                        $infos = $plist->toArray();\r
-                       fb($infos);\r
+\r
+\r
                        $bundle = $infos['CFBundleIdentifier'];\r
                        $appName = $infos['CFBundleDisplayName'];\r
                        $version = $infos['CFBundleVersion'];\r
-                       $ipaURL = 'http://' . $_SERVER['HTTP_HOST'] . '/telecharger/' . $fichier->relPath;\r
+                       $ipaURL = 'http://' . $_SERVER['HTTP_HOST'] . '/telecharger/' . self::hashFile($fichier->relPath . '//') . '/' . $fichier->relPath;\r
 \r
                        $xml = '<?xml version="1.0" encoding="UTF-8"?>\r
 <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">\r
@@ -496,15 +498,28 @@ class commonUrl {
                return $res;\r
        }\r
 \r
+       public static function hashFile($path) {\r
+               $path = trim($path, '/');\r
+               fb($path);\r
+               return sha1('!!//' . $path . '||--');\r
+       }\r
+\r
        public static function telecharger($args) {\r
-               commonDroits::min(array('extranet' => 0, 'ws' => 1));\r
+\r
 \r
                array_shift($args);\r
+               $hash = array_shift($args);\r
                $path = implode('/', $args);\r
                $utilisateur_id = array_shift($args);\r
-               commonDroits::telecharger($utilisateur_id);\r
-               $dir = md5($path . (rand(1, 235548684) * 50.5));\r
                $nom = array_pop($args);\r
+\r
+               $verihash = self::hashFile($path);\r
+               if ($hash != $verihash) {\r
+                       return;\r
+               }\r
+\r
+               $dir = md5($path . (rand(1, 235548684) * 50.5));\r
+\r
                @mkdir(ROOT . '/cache/download/' . $dir, 0755, true);\r
                copy(FTPROOT . $path, ROOT . '/cache/download/' . $dir . '/' . $nom);\r
 \r
@@ -573,7 +588,7 @@ class commonUrl {
                                        $body = 'Tous les fichiers de ' . $client->prenom . ' ' . $client->nom . ' : http://' . $_SERVER['HTTP_HOST'] . '/fichiers/' . $client->utilisateur_id . "\n\n";\r
                                        $body .= 'Fichiers chargés : ' . "\n";\r
                                        foreach ($_SESSION['files_uploaded'] as $f) {\r
-                                               $body .= ' - http://' . $_SERVER['HTTP_HOST'] . '/telecharger/' . $f . "\n";\r
+                                               $body .= ' - http://' . $_SERVER['HTTP_HOST'] . '/telecharger/' . commonUrl::hashFile($f) . '/' . $f . "\n";\r
                                        }\r
                                        $body .= "\n" . RAPPEL . " : \n";\r
                                        $body .= ' - Adresse : http://' . $_SERVER['HTTP_HOST'] . '/' . "\n";\r
index a41f265f95c4fcb7138cd1d6919df1cfc5c4a559..2df61748aeeb0d2884eaccf7d0ef421a20a15805 100644 (file)
@@ -210,9 +210,21 @@ class wsThemeParametres extends wsParametres {
                        'fileFilter' => $imageFilter,\r
                        'uploadURL' => SITE_PATH . 'flash/uploadThemeFile/?theme_id=' . $this->parent->theme_id . '&amp;type=ico',\r
                        'hint' => __('Image PNG de 256x256'));\r
+               $this->fields['iosicon'] = array('type' => 'file', 'default' => '', 'editable' => true,\r
+                       'label' => __('Icone (pour application iOS)'),\r
+                       'path' => $themeRoot,\r
+                       'fileFilter' => $imageFilter,\r
+                       'uploadURL' => SITE_PATH . 'flash/uploadThemeFile/?theme_id=' . $this->parent->theme_id . '&amp;type=ico',\r
+                       'hint' => __('Image PNG de 1024x1024'));\r
+               $this->fields['androidicon'] = array('type' => 'file', 'default' => '', 'editable' => true,\r
+                       'label' => __('Icone (pour application Android)'),\r
+                       'path' => $themeRoot,\r
+                       'fileFilter' => $imageFilter,\r
+                       'uploadURL' => SITE_PATH . 'flash/uploadThemeFile/?theme_id=' . $this->parent->theme_id . '&amp;type=ico',\r
+                       'hint' => __('Image PNG de 1024x1024'));\r
 \r
                $this->forms['logo'] = array('label' => __('Personnalisation du logo'),\r
-                       'fieldsnames' => array('logo', 'favicon'));\r
+                       'fieldsnames' => array('logo', '|', 'favicon', 'iosicon', 'androidicon'));\r
                /* Loader */\r
                $this->fields['logoLoader'] = array('type' => 'file', 'default' => 'logoLoader.png', 'editable' => true,\r
                        'label' => __('Logo affiché au chargement'),\r
index c99c431319d4ed358ebdb077a62fe36bda1df1b2..41711cb9ebb92e25e067e5a78460ea91a12b7f50 100644 (file)
@@ -39,18 +39,16 @@ class wsPackagerPhonegap extends wsPackager {
 
 
                        if ($this->makeResources) {
-                               if ($this->os == 'ios') {
-                                       $this->resources = $vdir . '/Resources';
-                                       $this->makeIOSResources();
-                               } elseif ($this->os == 'android') {
-                                       $this->resources = $vdir . '/Resources';
-                                       $this->makeAndroidResources();
+                               if ($os == 'ios') {
+                                       $this->makeIOSResources($vdir . '/Resources');
+                               } elseif ($os == 'android') {
+                                       $this->makeAndroidResources($vdir . '/Resources');
                                }
                        }
                }
        }
 
-       protected function makeAndroidResources() {
+       protected function makeAndroidResources($resources) {
                $icons = array('drawable' => 96,
                        'drawable-hdpi' => 72,
                        'drawable-ldpi' => 36,
@@ -66,16 +64,16 @@ class wsPackagerPhonegap extends wsPackager {
                        'drawable-xhdpi' => '1280x1920');
 
                foreach ($icons as $dir => $size) {
-                       $d = $this->resources . '/' . $dir;
+                       $d = $resources . '/' . $dir;
                        if (!file_exists($d)) {
                                mkdir($d, 0777, true);
                        }
 
-                       $this->_makeIcon($size, 'icon', $d);
+                       $this->_makeIcon($size, 'icon', $d, 'android');
                }
 
                foreach ($splashs as $dir => $size) {
-                       $d = $this->resources . '/' . $dir;
+                       $d = $resources . '/' . $dir;
                        if (!file_exists($d)) {
                                mkdir($d, 0777, true);
                        }
@@ -92,55 +90,54 @@ class wsPackagerPhonegap extends wsPackager {
                }
        }
 
-       protected function makeIOSResources() {
+       protected function makeIOSResources($resources) {
                $splashs = array('320x480' => 'Default~iphone', '640x960' => 'Default@2x~iphone', '1024x748' => 'Default-Landscape~ipad', '768x1004' => 'Default-Portrait~ipad', '2048x1496' => 'Default-Landscape@2x~ipad', '1536x2008' => 'Default-Portrait@2x~ipad', '640x1136' => 'Default-568h@2x~iphone');
                $icons = array(57 => 'icon', 72 => 'icon-72', 114 => 'icon@2x', 144 => 'icon-72@2x');
 
-               if (!file_exists($this->resources . '/splash')) {
-                       mkdir($this->resources . '/splash', 0777, true);
+               if (!file_exists($resources . '/splash')) {
+                       mkdir($resources . '/splash', 0777, true);
                }
                if (!file_exists($this->resources . '/icons')) {
-                       mkdir($this->resources . '/icons', 0777, true);
+                       mkdir($resources . '/icons', 0777, true);
                }
 
                foreach ($splashs as $size => $name) {
                        list($width, $height) = explode('x', $size);
-                       $this->_makeSplash($width, $height, $name);
+                       $this->_makeSplash($width, $height, $name, $resources . '/icons');
                }
                foreach ($icons as $size => $name) {
-                       $this->_makeIcon($size, $name);
+                       $this->_makeIcon($size, $name, $resources . '/icons', 'ios');
                }
        }
 
-       protected function _makeSplash($width, $height, $name, $dir = null) {
+       protected function _makeSplash($width, $height, $name, $dir) {
                $im = imagecreatetruecolor($width, $height);
                // Draw Background
                $back = imagecolorhexallocate($im, $this->theme->parametres->backgroundColor);
                imagefill($im, 0, 0, $back);
                // Draw image
 
-               if (is_null($dir)) {
-                       $dir = $this->resources . '/splash';
-               }
 
                $this->_drawBackImage($im, $width, $height);
                imagepng($im, $dir . '/' . $name . '.png');
        }
 
-       protected function _makeIcon($size, $name, $dir = null) {
-               if ($this->theme->parametres->favicon != '') {
+       protected function _makeIcon($size, $name, $dir, $os = '') {
+
+               $os = strtolower($os);
+               $icoos = $os.'icon';
+
+               if (isset($this->theme->parametres->$icoos) && $this->theme->parametres->$icoos != '') {
+                       $base = $this->themeRoot . '/' . $this->theme->parametres->$icoos;
+               } elseif ($this->theme->parametres->favicon != '') {
                        $base = $this->themeRoot . '/' . $this->theme->parametres->favicon;
                } else {
                        $base = WS_COMPILE_ASSETS . '/_ico/phonegap.png';
                }
 
-               if (is_null($dir)) {
-                       $dir = $this->resources . '/icons';
-               }
-
-               $it = new imageTools();
+               $it = new cubeImageTools();
                $it->loadImage($base);
-               $it->resize($size, $size, 'ratio');
+               $it->resize($size, $size, 'ratio',false,'C','M','transparent');
                $it->output('png', $dir . '/' . $name . '.png');
        }