diff --git a/.htaccess b/.htaccess index 5b415e2..d860b72 100644 --- a/.htaccess +++ b/.htaccess @@ -1,36 +1,36 @@ -# Active la compression GZIP - option Apache +# Racine du site DeltaCMS + + Require all denied + + - mod_gzip_on Yes - mod_gzip_dechunk Yes - mod_gzip_item_include file \.(html?|txt|css|js|php|pl)$ - mod_gzip_item_include handler ^cgi-script$ - mod_gzip_item_include mime ^text\.* - mod_gzip_item_include mime ^application/x-javascript.* - mod_gzip_item_exclude mime ^image\.* - mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.* + mod_gzip_on Yes + mod_gzip_dechunk Yes + mod_gzip_item_include file \.(html?|txt|css|js|php|woff)$ + mod_gzip_item_include handler ^cgi-script$ + mod_gzip_item_include mime ^text\.* + mod_gzip_item_include mime ^application/x-javascript.* + mod_gzip_item_exclude mime ^image\.* + mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.* -# Active la compression DEFLATE - option Apache - AddOutputFilterByType DEFLATE text/plain - AddOutputFilterByType DEFLATE text/html - AddOutputFilterByType DEFLATE text/xml - AddOutputFilterByType DEFLATE text/shtml - AddOutputFilterByType DEFLATE text/css - AddOutputFilterByType DEFLATE application/xml - AddOutputFilterByType DEFLATE application/xhtml+xml - AddOutputFilterByType DEFLATE application/rss+xml - AddOutputFilterByType DEFLATE application/javascript - AddOutputFilterByType DEFLATE application/x-javascript - - -# Bloque l'accès à la liste des fichiers -Options -Indexes - -# Désactive l'option de substitution automatique - - Options -MultiViews + AddOutputFilterByType DEFLATE text/plain + AddOutputFilterByType DEFLATE text/html + AddOutputFilterByType DEFLATE text/xml + AddOutputFilterByType DEFLATE text/shtml + AddOutputFilterByType DEFLATE text/css + AddOutputFilterByType DEFLATE font/woff + AddOutputFilterByType DEFLATE font/woff2 + AddOutputFilterByType DEFLATE application/font-woff + AddOutputFilterByType DEFLATE application/xml + AddOutputFilterByType DEFLATE application/xhtml+xml + AddOutputFilterByType DEFLATE application/rss+xml + AddOutputFilterByType DEFLATE application/javascript + AddOutputFilterByType DEFLATE application/x-javascript +Options -Indexes -MultiViews + # Attention, surtout ne rien modifier ci-dessous ! # URL rewriting \ No newline at end of file diff --git a/CHANGES.md b/CHANGES.md index f01b721..fcbed38 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,19 @@ # Changelog +## Version 4.3.04 de Deltacms +- Modifications : + - Fichiers .htaccess : Mise à jour vers Apache 2.4. Attention pour cette mise à jour vers la version Deltacms 4.3.04 + l'option "Préservez le fichier .htaccess racine", dans Configurer le site / onglet Configuration / bloc Mise à jour automatisée, + doit être décochée. Sinon vous devrez mettre en version Apache 2.4 votre .htaccess racine personnalisé, + - Fichiers robots.txt et sitemap.xml : suppression de la mise à jour automatique de ces fichiers, elle ne pourra plus se faire + que par un appui sur le bouton "Générer sitemap.xml et robots.txt" dans Configurer le site / onglet Référencement / bloc Paramètres, + - Blog : le lexique pour la langue d'administration est déporté dans un dossier 'lang', + - Blog : L'image d'illustration n'est plus obligatoire, + - Filemanager : les images au format webp sont autorisées, + - Agenda, Statislite : les dossiers d'installation de ces modules sont placés dans un dossier 'ressource' du module. +- Corrections : + - Form, Agenda : déplacement de l'initialisation de variables Javascript qui provoquait un décalage d'affichage dans la barre d'administration. + ## Version 4.3.03 de Deltacms - Modifications : - News : nouvelle option insérer des images ou des iframe sans marges. diff --git a/README.md b/README.md index cac3415..6d46d0f 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -# DeltaCMS 4.3.03 +# DeltaCMS 4.3.04 DeltaCMS est un CMS sans base de données (flat-file) qui permet de créer et gérer facilement un site web sans aucune connaissance en programmation. L'administration du site est bilingue anglais ou français, le site peut être rédigé dans une des principales langues européennes. diff --git a/core/class/.htaccess b/core/class/.htaccess index 3b355e3..b66e808 100644 --- a/core/class/.htaccess +++ b/core/class/.htaccess @@ -1,3 +1 @@ -# Bloque l'accès à la librairie -Order deny,allow -Deny from all \ No newline at end of file +Require all denied diff --git a/core/class/phpmailer/.htaccess b/core/class/phpmailer/.htaccess index 3b355e3..e69de29 100644 --- a/core/class/phpmailer/.htaccess +++ b/core/class/phpmailer/.htaccess @@ -1,3 +0,0 @@ -# Bloque l'accès à la librairie -Order deny,allow -Deny from all \ No newline at end of file diff --git a/core/core.php b/core/core.php index c3e027b..518ef62 100644 --- a/core/core.php +++ b/core/core.php @@ -48,7 +48,7 @@ class common { // Numéro de version const DELTA_UPDATE_URL = 'https://update.deltacms.fr/master/'; - const DELTA_VERSION = '4.3.03'; + const DELTA_VERSION = '4.3.04'; const DELTA_UPDATE_CHANNEL = "v4"; public static $actions = []; @@ -894,7 +894,7 @@ class common { /** - * Génère un fichier un fichier sitemap.xml + * Génère un fichier sitemap.xml * https://github.com/icamys/php-sitemap-generator * $command valeurs possible * all : génère un site map complet @@ -926,49 +926,54 @@ class common { $datetime = new DateTime(date('c')); $datetime->format(DateTime::ATOM); // Updated ISO8601 - foreach($this->getHierarchy(null, null, null) as $parentPageId => $childrenPageIds) { - // Exclure les barres et les pages non publiques et les pages masquées - if ($this->getData(['page',$parentPageId,'group']) !== 0 || - $this->getData(['page', $parentPageId, 'block']) === 'bar' ) { - continue; - } - // Page désactivée, traiter les sous-pages sans prendre en compte la page parente. - if ($this->getData(['page', $parentPageId, 'disable']) !== true ) { - // Cas de la page d'accueil ne pas dupliquer l'URL - $pageId = ($parentPageId !== $this->getData(['locale', 'homePageId'])) ? $parentPageId : ''; - $sitemap->addUrl ('/' . $pageId, $datetime); - } - // Articles du blog - if ($this->getData(['page', $parentPageId, 'moduleId']) === 'blog' && - !empty($this->getData(['module',$parentPageId])) ) { - foreach($this->getData(['module',$parentPageId,'posts']) as $articleId => $article) { - if($this->getData(['module',$parentPageId,'posts',$articleId,'state']) === true) { - $date = $this->getData(['module',$parentPageId,'posts',$articleId,'publishedOn']); - $sitemap->addUrl('/' . $parentPageId . '/' . $articleId , new DateTime("@{$date}",new DateTimeZone($timezone))); - } - } - } - // Sous-pages - foreach($childrenPageIds as $childKey) { - if ($this->getData(['page',$childKey,'group']) !== 0 || $this->getData(['page', $childKey, 'disable']) === true) { + if ($this->getData(['config','seo', 'robots']) === true) { + foreach($this->getHierarchy(null, null, null) as $parentPageId => $childrenPageIds) { + // Exclure les barres et les pages non publiques et les pages masquées + if ($this->getData(['page',$parentPageId,'group']) !== 0 || + $this->getData(['page', $parentPageId, 'block']) === 'bar' ) { continue; } - // Cas de la page d'accueil ne pas dupliquer l'URL - $pageId = ($childKey !== $this->getData(['locale', 'homePageId'])) ? $childKey : ''; - $sitemap->addUrl('/' . $childKey,$datetime); - - // La sous-page est un blog - if ($this->getData(['page', $childKey, 'moduleId']) === 'blog' && - !empty($this->getData(['module',$childKey])) ) { - foreach($this->getData(['module',$childKey,'posts']) as $articleId => $article) { - if($this->getData(['module',$childKey,'posts',$articleId,'state']) === true) { - $date = $this->getData(['module',$childKey,'posts',$articleId,'publishedOn']); - $sitemap->addUrl( '/' . $childKey . '/' . $articleId , new DateTime("@{$date}",new DateTimeZone($timezone))); + // Page désactivée, traiter les sous-pages sans prendre en compte la page parente. + if ($this->getData(['page', $parentPageId, 'disable']) !== true ) { + // Cas de la page d'accueil ne pas dupliquer l'URL + $pageId = ($parentPageId !== $this->getData(['locale', 'homePageId'])) ? $parentPageId : ''; + $sitemap->addUrl ('/' . $pageId, $datetime); + } + // Articles du blog + if ($this->getData(['page', $parentPageId, 'moduleId']) === 'blog' && + !empty($this->getData(['module',$parentPageId])) ) { + foreach($this->getData(['module',$parentPageId,'posts']) as $articleId => $article) { + if($this->getData(['module',$parentPageId,'posts',$articleId,'state']) === true) { + $date = $this->getData(['module',$parentPageId,'posts',$articleId,'publishedOn']); + $sitemap->addUrl('/' . $parentPageId . '/' . $articleId , new DateTime("@{$date}",new DateTimeZone($timezone))); } } } - } + // Sous-pages + foreach($childrenPageIds as $childKey) { + if ($this->getData(['page',$childKey,'group']) !== 0 || $this->getData(['page', $childKey, 'disable']) === true) { + continue; + } + // Cas de la page d'accueil ne pas dupliquer l'URL + $pageId = ($childKey !== $this->getData(['locale', 'homePageId'])) ? $childKey : ''; + $sitemap->addUrl('/' . $childKey,$datetime); + // La sous-page est un blog + if ($this->getData(['page', $childKey, 'moduleId']) === 'blog' && + !empty($this->getData(['module',$childKey])) ) { + foreach($this->getData(['module',$childKey,'posts']) as $articleId => $article) { + if($this->getData(['module',$childKey,'posts',$articleId,'state']) === true) { + $date = $this->getData(['module',$childKey,'posts',$articleId,'publishedOn']); + $sitemap->addUrl( '/' . $childKey . '/' . $articleId , new DateTime("@{$date}",new DateTimeZone($timezone))); + } + } + } + } + + } + } + else{ + $sitemap->addUrl ('/', $datetime); } // Flush all stored urls from memory to the disk and close all necessary tags. @@ -999,7 +1004,7 @@ class common { * Création d'une miniature * Fonction utilisée lors de la mise à jour d'une version 9 à une version 10 * @param string $src image source - * @param string $dets image destination + * @param string $dest image destination * @param integer $desired_width largeur demandée */ function makeThumb($src, $dest, $desired_width) { @@ -1021,6 +1026,9 @@ class common { case 'gif': $source_image = imagecreatefromgif($src); break; + case 'webp': + $source_image = imagecreatefromwebp($src); + break; } // Image valide if ($source_image) { @@ -1034,7 +1042,6 @@ class common { imagecopyresampled($virtual_image, $source_image, 0, 0, 0, 0, $desired_width, $desired_height, $width, $height); switch(mime_content_type($src) ) { case 'image/jpeg': - case 'image/jpg': return (imagejpeg($virtual_image, $dest)); break; case 'image/png': @@ -1043,6 +1050,9 @@ class common { case 'image/gif': return (imagegif($virtual_image, $dest)); break; + case 'image/webp': + return (imagewebp($virtual_image, $dest)); + break; } } else { return (false); @@ -1255,6 +1265,7 @@ class common { $blocks = []; if( null !== $this->getData(['page',$this->getUrl(0),'block'])) $blocks = explode('-',$this->getData(['page',$this->getUrl(0),'block'])); // Initialiser + $content = ""; $blockleft=$blockright=""; switch (sizeof($blocks)) { case 1 : // une colonne @@ -1369,8 +1380,7 @@ class common { /** * Affiche les crédits, conditions requis : - * La traduction est active et le site n'est pas en français. - * La fonction est activée. + * La traduction automatique est active et La fonction est activée. */ if ( $this->getData(['config', 'i18n', 'enable']) === true AND $this->getData(['config', 'i18n','scriptGoogle']) === true @@ -1920,40 +1930,27 @@ class common { echo $items; } - - /** * Affiche le meta titre */ - public function showMetaTitle() { - echo '' . $this->output['metaTitle'] . ''; - echo ''; - echo ''; - } - - /** - * Affiche la meta description - */ - public function showMetaDescription() { - echo ''; - echo ''; - } - - /** - * Affiche le meta type - */ - public function showMetaType() { - echo ''; - } - - /** - * Affiche la meta image (site screenshot) - */ - public function showMetaImage() { - echo ''; - } - + /** + * Affiche les balises title et meta name + */ + public function showMetaTitle() { + echo '' . $this->output['metaTitle'] . '' . PHP_EOL; + echo '' . PHP_EOL; + echo '' . PHP_EOL; + } + /** + * Affiche les balises meta property + */ + public function showMetaProperty() { + echo '' . PHP_EOL; + echo '' . PHP_EOL; + echo '' . PHP_EOL; + echo '' . PHP_EOL; + } /** * Affiche la notification diff --git a/core/include/update.inc.php b/core/include/update.inc.php index abbbc76..82b1692 100644 --- a/core/include/update.inc.php +++ b/core/include/update.inc.php @@ -60,8 +60,8 @@ if ($this->getData(['core', 'dataVersion']) < 4202) { $this->setData(['core', 'dataVersion', 4202]); } -if ($this->getData(['core', 'dataVersion']) < 4303) { +if ($this->getData(['core', 'dataVersion']) < 4304) { // Mise à jour - $this->setData(['core', 'dataVersion', 4303]); + $this->setData(['core', 'dataVersion', 4304]); } ?> diff --git a/core/layout/blank.php b/core/layout/blank.php index 5274f09..93ecc91 100644 --- a/core/layout/blank.php +++ b/core/layout/blank.php @@ -3,13 +3,15 @@ - showMetaTitle(); ?> - showMetaDescription(); ?> - showMetaType(); ?> - showMetaImage(); ?> - showFavicon(); ?> - showVendor(); ?> - showStyle(); ?> + showMetaTitle(); + $this->showMetaProperty(); + ?> + showFavicon(); + $this->showVendor(); + $this->showStyle(); + ?> diff --git a/core/layout/light.php b/core/layout/light.php index 742cae3..ff10cd8 100644 --- a/core/layout/light.php +++ b/core/layout/light.php @@ -3,13 +3,15 @@ - showMetaTitle(); ?> - showMetaDescription(); ?> - showMetaType(); ?> - showMetaImage(); ?> - showFavicon(); ?> - showVendor(); ?> - showStyle(); ?> + showMetaTitle(); + $this->showMetaProperty(); + ?> + showFavicon(); + $this->showVendor(); + $this->showStyle(); + ?> diff --git a/core/layout/main.php b/core/layout/main.php index b915ace..07785a8 100644 --- a/core/layout/main.php +++ b/core/layout/main.php @@ -7,12 +7,14 @@ if( $this->getInput('DELTA_I18N_SITE') !== '' && $this->getInput('DELTA_I18N_SIT - showMetaTitle(); ?> - showMetaDescription(); ?> - showMetaType(); ?> - showMetaImage(); ?> - showFavicon(); ?> - showVendor(); ?> + showMetaTitle(); + $this->showMetaProperty(); + ?> + showFavicon(); + $this->showVendor(); + ?> @@ -171,23 +173,23 @@ if( $this->getInput('DELTA_I18N_SITE') !== '' && $this->getInput('DELTA_I18N_SIT getData(['theme', 'header', 'position']) === 'hide' ? 'displayNone' : ''; $headerClass .= $this->getData(['theme', 'header', 'tinyHidden']) ? ' bannerDisplay ' : ''; - ?> -
> - getData(['theme','header','feature']) === 'wallpaper' ): ?> - getData(['theme', 'header', 'textHide']) === false - // Affiche toujours le titre de la bannière pour l'édition du thème - OR ($this->getUrl(0) === 'theme' AND $this->getUrl(1) === 'header') - ): ?> - getData(['locale', 'title']); ?> - -   - + ?> +
> + getData(['theme','header','feature']) === 'wallpaper' ): ?> + getData(['theme', 'header', 'textHide']) === false + // Affiche toujours le titre de la bannière pour l'édition du thème + OR ($this->getUrl(0) === 'theme' AND $this->getUrl(1) === 'header') + ): ?> + getData(['locale', 'title']); ?> -
- getData(['theme','header','featureContent']);?> -
+   + +
+ getData(['theme','header','featureContent']);?> +
+
getData(['theme','header','linkHomePage']) && $this->getData(['theme','header','feature']) === 'wallpaper' ) ? '' : ''; ?> diff --git a/core/module/config/config.php b/core/module/config/config.php index 56d0bcf..801c8ae 100644 --- a/core/module/config/config.php +++ b/core/module/config/config.php @@ -636,11 +636,11 @@ class config extends common { $this->setData(['core', 'baseUrl', helper::baseUrl(true,false) ]); } // Générer robots.txt et sitemap - $this->generateFiles(); + // $this->generateFiles(); // Valeurs en sortie $this->addOutput([ 'title' => $text[0], - 'view' => 'index', + 'redirect' => helper::baseUrl() . 'config', 'notification' => $text[1] , 'state' => true ]); diff --git a/core/module/install/ressource/.htaccess b/core/module/install/ressource/.htaccess index 85278f8..0cf3289 100644 --- a/core/module/install/ressource/.htaccess +++ b/core/module/install/ressource/.htaccess @@ -1,10 +1,3 @@ -# Bloque l'accès aux données - Order deny,allow - Deny from all +Require all denied -# Bloque l'accès htaccess - - Order deny,allow - Deny from all - \ No newline at end of file diff --git a/core/module/install/ressource/database_en/base/module.json b/core/module/install/ressource/database_en/base/module.json index aa71a7d..cc7b63a 100644 --- a/core/module/install/ressource/database_en/base/module.json +++ b/core/module/install/ressource/database_en/base/module.json @@ -5,7 +5,7 @@ "feeds": true, "feedsLabel": "Syndication RSS", "itemsperPage": 6, - "versionData": "6.2" + "versionData": "6.3" }, "texts": { "NoComment": "No comment yet", @@ -23,7 +23,8 @@ "Send": "Send", "TinymceMaxi": "You have reached the maximum of", "TinymceCara": "characters left", - "TinymceExceed": "You were about to exceed the maximum of " + "TinymceExceed": "You were about to exceed the maximum of ", + "ReadMore": "Read more" }, "posts": { "premier-article": { @@ -140,7 +141,7 @@ "logoUrl": "", "logoWidth": "40", "maxSizeUpload": "500000", - "versionData": "4.1", + "versionData": "4.2", "uploadJpg": true, "uploadPng": true, "uploadPdf": false, diff --git a/core/module/install/ressource/database_fr/base/module.json b/core/module/install/ressource/database_fr/base/module.json index 75a5337..c29732d 100644 --- a/core/module/install/ressource/database_fr/base/module.json +++ b/core/module/install/ressource/database_fr/base/module.json @@ -5,7 +5,7 @@ "feeds": true, "feedsLabel": "Syndication RSS", "itemsperPage": 4, - "versionData": "6.2" + "versionData": "6.3" }, "texts": { "NoComment": "Pas encore de commentaire", @@ -23,7 +23,8 @@ "Send": "Envoyer", "TinymceMaxi": "Vous avez atteint le maximum de", "TinymceCara": "caractères restants", - "TinymceExceed": "Vous alliez dépasser le maximum de " + "TinymceExceed": "Vous alliez dépasser le maximum de ", + "ReadMore": "Lire la suite" }, "posts": { "premier-article": { @@ -140,7 +141,7 @@ "logoUrl": "", "logoWidth": "40", "maxSizeUpload": "1000000", - "versionData": "4.1", + "versionData": "4.2", "uploadJpg": true, "uploadPng": true, "uploadPdf": false, diff --git a/core/module/install/ressource/defaultdata.php b/core/module/install/ressource/defaultdata.php index cfa6eff..96ec626 100644 --- a/core/module/install/ressource/defaultdata.php +++ b/core/module/install/ressource/defaultdata.php @@ -70,7 +70,7 @@ class init extends common { ] ], 'core' => [ - 'dataVersion' => 4303, + 'dataVersion' => 4304, 'lastBackup' => 0, 'lastClearTmp' => 0, 'lastAutoUpdate' => 0, diff --git a/core/module/page/page.php b/core/module/page/page.php index be7f2bd..d3a5ef0 100644 --- a/core/module/page/page.php +++ b/core/module/page/page.php @@ -223,7 +223,7 @@ class page extends common { } $this->setPage($pageId, '

'.$text[1].'

', self::$i18n); // Met à jour le site map - $this->createSitemap('all'); + // $this->createSitemap('all'); // Valeurs en sortie $this->addOutput([ 'redirect' => helper::baseUrl() . $pageId, @@ -365,7 +365,7 @@ class page extends common { } $this->deleteData(['module', $url[0]]); // Met à jour le site map - $this->createSitemap('all'); + // $this->createSitemap('all'); // Met à jour 'config', 'statislite', 'enable' si aucume page utilise le module Statislite $inPages = helper::arrayCollumn($this->getData(['page']),'moduleId', 'SORT_DESC'); $statislite = 'off'; @@ -567,7 +567,7 @@ class page extends common { } } // Met à jour le site map - $this->createSitemap('all'); + // $this->createSitemap('all'); // Redirection vers la configuration if($this->getInput('pageEditModuleRedirect', helper::FILTER_BOOLEAN)) { // Valeurs en sortie diff --git a/core/module/user/ressource/.htaccess b/core/module/user/ressource/.htaccess index e8a0ad3..ddb984a 100644 --- a/core/module/user/ressource/.htaccess +++ b/core/module/user/ressource/.htaccess @@ -1,8 +1,4 @@ -# Bloque l'accès aux données -Order deny,allow -Deny from all -# Sauf l'accès au modèle csv - -Order Allow,Deny - Allow from all - \ No newline at end of file +Require all denied + +Require all granted + diff --git a/core/vendor/filemanager/UploadHandler.php b/core/vendor/filemanager/UploadHandler.php index b9874fa..1133e71 100644 --- a/core/vendor/filemanager/UploadHandler.php +++ b/core/vendor/filemanager/UploadHandler.php @@ -41,6 +41,7 @@ class UploadHandler const IMAGETYPE_GIF = 1; const IMAGETYPE_JPEG = 2; const IMAGETYPE_PNG = 3; + const IMAGETYPE_WEBP = 4; protected $image_objects = array(); @@ -508,7 +509,7 @@ class UploadHandler $index, $content_range) { // Add missing file extension for known image types: if (strpos($name, '.') === false && - preg_match('/^image\/(gif|jpe?g|png)/', $type, $matches)) { + preg_match('/^image\/(gif|jpe?g|png|webp)/', $type, $matches)) { $name .= '.'.$matches[1]; } if ($this->options['correct_image_extensions']) { @@ -522,6 +523,9 @@ class UploadHandler case self::IMAGETYPE_GIF: $extensions = array('gif'); break; + case self::IMAGETYPE_WEBP: + $extensions = array('webp'); + break; } // Adjust incorrect image file extensions: if (!empty($extensions)) { @@ -734,6 +738,12 @@ class UploadHandler $image_quality = isset($options['png_quality']) ? $options['png_quality'] : 9; break; + case 'webp': + $src_func = 'imagecreatefromwebp'; + $write_func = 'imagewebp'; + $image_quality = isset($options['webp_quality']) ? + $options['webp_quality'] : 75; + break; default: return false; } @@ -1083,6 +1093,9 @@ class UploadHandler if (bin2hex(@$data[0]).substr($data, 1, 4) === '89PNG') { return self::IMAGETYPE_PNG; } + if ($data === 'RIFF') { + return self::IMAGETYPE_WEBP; + } return false; } diff --git a/core/vendor/filemanager/config/.htaccess b/core/vendor/filemanager/config/.htaccess index 14249c5..b66e808 100644 --- a/core/vendor/filemanager/config/.htaccess +++ b/core/vendor/filemanager/config/.htaccess @@ -1 +1 @@ -Deny from all \ No newline at end of file +Require all denied diff --git a/core/vendor/filemanager/config/config.php b/core/vendor/filemanager/config/config.php index 7da0bcb..4a47fdb 100644 --- a/core/vendor/filemanager/config/config.php +++ b/core/vendor/filemanager/config/config.php @@ -466,7 +466,7 @@ $config = array( //********************** //Allowed extensions (lowercase insert) //********************** - 'ext_img' => array( 'jpg', 'jpeg', 'png', 'gif', 'bmp', 'tiff','svg', 'ico' ), //Images + 'ext_img' => array( 'jpg', 'jpeg', 'png', 'gif', 'bmp', 'tiff','svg', 'ico', 'webp' ), //Images 'ext_file' => array( 'doc', 'docx', 'rtf', 'pdf', 'xls', 'xlsx', 'txt', 'csv', 'html', 'xhtml', 'psd', 'sql', 'log', 'fla', 'xml', 'ade', 'adp', 'mdb', 'accdb', 'ppt', 'pptx', 'odt', 'ots', 'ott', 'odb', 'odg', 'otp', 'otg', 'odf', 'ods', 'odp', 'css', 'ai', 'kmz','dwg', 'dxf', 'hpgl', 'plt', 'spl', 'step', 'stp', 'iges', 'igs', 'sat', 'cgm', 'ics', 'gpx', 'kml', 'ttf', 'eot', 'woff', 'otf', 'woff2', ''), //Files 'ext_video' => array( 'mov', 'mpeg', 'm4v', 'mp4', 'avi', 'mpg', 'wma', "flv", "webm" ), //Video 'ext_music' => array( 'mp3', 'mpga', 'm4a', 'ac3', 'aiff', 'mid', 'ogg', 'wav' ), //Audio diff --git a/core/vendor/filemanager/include/mime_type_lib.php b/core/vendor/filemanager/include/mime_type_lib.php index 182f645..47b70d9 100644 --- a/core/vendor/filemanager/include/mime_type_lib.php +++ b/core/vendor/filemanager/include/mime_type_lib.php @@ -133,6 +133,8 @@ $mime_types = array( "audio/x-ms-wax" => "wax", "image/vnd.wap.wbmp" => "wbmp", "application/vnd.wap.wbxml" => "wbxml", + "video/webm" => "webm", + "image/webp" => "webp", "video/x-ms-wm" => "wm", "audio/x-ms-wma" => "wma", "text/vnd.wap.wml" => "wml", diff --git a/core/vendor/filemanager/include/php_image_magician.php b/core/vendor/filemanager/include/php_image_magician.php index 5bdb9d6..9ec8e00 100644 --- a/core/vendor/filemanager/include/php_image_magician.php +++ b/core/vendor/filemanager/include/php_image_magician.php @@ -162,88 +162,87 @@ class imageLib { - private $fileName; - private $image; - protected $imageResized; - private $widthOriginal; # Always be the original width - private $heightOriginal; - private $width; # Current width (width after resize) - private $height; - private $imageSize; - private $fileExtension; + private $fileName; + private $image; + protected $imageResized; + private $widthOriginal; # Always be the original width + private $heightOriginal; + private $width; # Current width (width after resize) + private $height; + private $imageSize; + private $fileExtension; - private $debug = true; - private $errorArray = array(); + private $debug = true; + private $errorArray = array(); - private $forceStretch = true; - private $aggresiveSharpening = false; + private $forceStretch = true; + private $aggresiveSharpening = false; - private $transparentArray = array( '.png', '.gif' ); - private $keepTransparency = true; - private $fillColorArray = array( 'r' => 255, 'g' => 255, 'b' => 255 ); + private $transparentArray = array( '.png', '.gif' ); + private $keepTransparency = true; + private $fillColorArray = array( 'r' => 255, 'g' => 255, 'b' => 255 ); - private $sharpenArray = array( 'jpg' ); + private $sharpenArray = array( 'jpg' ); - private $psdReaderPath; - private $filterOverlayPath; + private $psdReaderPath; + private $filterOverlayPath; - private $isInterlace; + private $isInterlace; - private $captionBoxPositionArray = array(); + private $captionBoxPositionArray = array(); - private $fontDir = 'fonts'; + private $fontDir = 'fonts'; - private $cropFromTopPercent = 10; + private $cropFromTopPercent = 10; ## -------------------------------------------------------- - function __construct($fileName) - # Author: Jarrod Oberto - # Date: 27-02-08 - # Purpose: Constructor - # Param in: $fileName: File name and path. - # Param out: n/a - # Reference: - # Notes: - # - { - if ( ! $this->testGDInstalled()) - { - if ($this->debug) - { - throw new Exception('The GD Library is not installed.'); - } - else - { - throw new Exception(); - } - }; + function __construct($fileName) + # Author: Jarrod Oberto + # Date: 27-02-08 + # Purpose: Constructor + # Param in: $fileName: File name and path. + # Param out: n/a + # Reference: + # Notes: + # + { + if ( ! $this->testGDInstalled()) + { + if ($this->debug) + { + throw new Exception('The GD Library is not installed.'); + } + else + { + throw new Exception(); + } + }; - $this->initialise(); + $this->initialise(); - // *** Save the image file name. Only store this incase you want to display it - $this->fileName = $fileName; - $this->fileExtension = fix_strtolower(strrchr($fileName, '.')); + // *** Save the image file name. Only store this incase you want to display it + $this->fileName = $fileName; + $this->fileExtension = fix_strtolower(strrchr($fileName, '.')); - // *** Open up the file - $this->image = $this->openImage($fileName); + // *** Open up the file + $this->image = $this->openImage($fileName); + + // *** Assign here so we don't modify the original + $this->imageResized = $this->image; + + // *** If file is an image + if ($this->testIsImage($this->image)) + { + // *** Get width and height + $this->width = imagesx($this->image); + $this->widthOriginal = imagesx($this->image); + $this->height = imagesy($this->image); + $this->heightOriginal = imagesy($this->image); - // *** Assign here so we don't modify the original - $this->imageResized = $this->image; - - // *** If file is an image - if ($this->testIsImage($this->image)) - { - // *** Get width and height - $this->width = imagesx($this->image); - $this->widthOriginal = imagesx($this->image); - $this->height = imagesy($this->image); - $this->heightOriginal = imagesy($this->image); - - - /* Added 15-09-08 + /* Added 15-09-08 * Get the filesize using this build in method. * Stores an array of size * @@ -252,725 +251,725 @@ class imageLib { * $this->imageSize[3] = width x height * */ - $this->imageSize = getimagesize($this->fileName); + $this->imageSize = getimagesize($this->fileName); - } - else - { - $this->errorArray[] = 'File is not an image'; - } - } + } + else + { + $this->errorArray[] = 'File is not an image'; + } + } ## -------------------------------------------------------- - private function initialise() - { + private function initialise() + { - $this->psdReaderPath = dirname(__FILE__) . '/classPhpPsdReader.php'; - $this->filterOverlayPath = dirname(__FILE__) . '/filters'; + $this->psdReaderPath = dirname(__FILE__) . '/classPhpPsdReader.php'; + $this->filterOverlayPath = dirname(__FILE__) . '/filters'; - // *** Set if image should be interlaced or not. - $this->isInterlace = false; - } + // *** Set if image should be interlaced or not. + $this->isInterlace = false; + } - /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-*-*-*-*-*-*-*-*-*- + /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-*-*-*-*-*-*-*-*-*- Resize *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-*-*-*-*-*-*-*-*-*/ - public function resizeImage($newWidth, $newHeight, $option = 0, $sharpen = false, $autoRotate = false) - # Author: Jarrod Oberto - # Date: 27-02-08 - # Purpose: Resizes the image - # Param in: $newWidth: - # $newHeight: - # $option: 0 / exact = defined size; - # 1 / portrait = keep aspect set height; - # 2 / landscape = keep aspect set width; - # 3 / auto = auto; - # 4 / crop= resize and crop; - # - # $option can also be an array containing options for - # cropping. E.G., array('crop', 'r') - # - # This array only applies to 'crop' and the 'r' refers to - # "crop right". Other value include; tl, t, tr, l, m (default), - # r, bl, b, br, or you can specify your own co-ords (which - # isn't recommended. - # - # $sharpen: true: sharpen (jpg only); - # false: don't sharpen - # Param out: n/a - # Reference: - # Notes: To clarify the $option input: - # 0 = The exact height and width dimensions you set. - # 1 = Whatever height is passed in will be the height that - # is set. The width will be calculated and set automatically - # to a the value that keeps the original aspect ratio. - # 2 = The same but based on the width. We try make the image the - # biggest size we can while stil fitting inside the box size - # 3 = Depending whether the image is landscape or portrait, this - # will automatically determine whether to resize via - # dimension 1,2 or 0 - # 4 = Will resize and then crop the image for best fit - # - # forceStretch can be applied to options 1,2,3 and 4 - # - { + public function resizeImage($newWidth, $newHeight, $option = 0, $sharpen = false, $autoRotate = false) + # Author: Jarrod Oberto + # Date: 27-02-08 + # Purpose: Resizes the image + # Param in: $newWidth: + # $newHeight: + # $option: 0 / exact = defined size; + # 1 / portrait = keep aspect set height; + # 2 / landscape = keep aspect set width; + # 3 / auto = auto; + # 4 / crop= resize and crop; + # + # $option can also be an array containing options for + # cropping. E.G., array('crop', 'r') + # + # This array only applies to 'crop' and the 'r' refers to + # "crop right". Other value include; tl, t, tr, l, m (default), + # r, bl, b, br, or you can specify your own co-ords (which + # isn't recommended. + # + # $sharpen: true: sharpen (jpg only); + # false: don't sharpen + # Param out: n/a + # Reference: + # Notes: To clarify the $option input: + # 0 = The exact height and width dimensions you set. + # 1 = Whatever height is passed in will be the height that + # is set. The width will be calculated and set automatically + # to a the value that keeps the original aspect ratio. + # 2 = The same but based on the width. We try make the image the + # biggest size we can while stil fitting inside the box size + # 3 = Depending whether the image is landscape or portrait, this + # will automatically determine whether to resize via + # dimension 1,2 or 0 + # 4 = Will resize and then crop the image for best fit + # + # forceStretch can be applied to options 1,2,3 and 4 + # + { - // *** We can pass in an array of options to change the crop position - $cropPos = 'm'; - if (is_array($option) && fix_strtolower($option[0]) == 'crop') - { - $cropPos = $option[1]; # get the crop option - } - else - { - if (strpos($option, '-') !== false) - { - // *** Or pass in a hyphen seperated option - $optionPiecesArray = explode('-', $option); - $cropPos = end($optionPiecesArray); - } - } + // *** We can pass in an array of options to change the crop position + $cropPos = 'm'; + if (is_array($option) && fix_strtolower($option[0]) == 'crop') + { + $cropPos = $option[1]; # get the crop option + } + else + { + if (strpos($option, '-') !== false) + { + // *** Or pass in a hyphen seperated option + $optionPiecesArray = explode('-', $option); + $cropPos = end($optionPiecesArray); + } + } - // *** Check the option is valid - $option = $this->prepOption($option); + // *** Check the option is valid + $option = $this->prepOption($option); - // *** Make sure the file passed in is valid - if ( ! $this->image) - { - if ($this->debug) - { - throw new Exception('file ' . $this->getFileName() . ' is missing or invalid'); - } - else - { - throw new Exception(); - } - }; + // *** Make sure the file passed in is valid + if ( ! $this->image) + { + if ($this->debug) + { + throw new Exception('file ' . $this->getFileName() . ' is missing or invalid'); + } + else + { + throw new Exception(); + } + }; - // *** Get optimal width and height - based on $option - $dimensionsArray = $this->getDimensions($newWidth, $newHeight, $option); + // *** Get optimal width and height - based on $option + $dimensionsArray = $this->getDimensions($newWidth, $newHeight, $option); - $optimalWidth = $dimensionsArray['optimalWidth']; - $optimalHeight = $dimensionsArray['optimalHeight']; + $optimalWidth = $dimensionsArray['optimalWidth']; + $optimalHeight = $dimensionsArray['optimalHeight']; - // *** Resample - create image canvas of x, y size - $this->imageResized = imagecreatetruecolor((int)$optimalWidth, (int)$optimalHeight); - $this->keepTransparancy($optimalWidth, $optimalHeight, $this->imageResized); - imagecopyresampled($this->imageResized, $this->image, 0, 0, 0, 0, (int)$optimalWidth, (int)$optimalHeight, (int)$this->width, (int)$this->height); + // *** Resample - create image canvas of x, y size + $this->imageResized = imagecreatetruecolor($optimalWidth, $optimalHeight); + $this->keepTransparancy($optimalWidth, $optimalHeight, $this->imageResized); + imagecopyresampled($this->imageResized, $this->image, 0, 0, 0, 0, $optimalWidth, $optimalHeight, $this->width, $this->height); - // *** If '4', then crop too - if ($option == 4 || $option == 'crop') - { + // *** If '4', then crop too + if ($option == 4 || $option == 'crop') + { - if (($optimalWidth >= $newWidth && $optimalHeight >= $newHeight)) - { - $this->crop($optimalWidth, $optimalHeight, $newWidth, $newHeight, $cropPos); - } - } + if (($optimalWidth >= $newWidth && $optimalHeight >= $newHeight)) + { + $this->crop($optimalWidth, $optimalHeight, $newWidth, $newHeight, $cropPos); + } + } - // *** If Rotate. - if ($autoRotate) - { + // *** If Rotate. + if ($autoRotate) + { - $exifData = $this->getExif(false); - if (count($exifData) > 0) - { + $exifData = $this->getExif(false); + if (count($exifData) > 0) + { - switch ($exifData['orientation']) - { - case 8: - $this->imageResized = imagerotate($this->imageResized, 90, 0); - break; - case 3: - $this->imageResized = imagerotate($this->imageResized, 180, 0); - break; - case 6: - $this->imageResized = imagerotate($this->imageResized, -90, 0); - break; - } - } - } + switch ($exifData['orientation']) + { + case 8: + $this->imageResized = imagerotate($this->imageResized, 90, 0); + break; + case 3: + $this->imageResized = imagerotate($this->imageResized, 180, 0); + break; + case 6: + $this->imageResized = imagerotate($this->imageResized, -90, 0); + break; + } + } + } - // *** Sharpen image (if jpg and the user wishes to do so) - if ($sharpen && in_array($this->fileExtension, $this->sharpenArray)) - { + // *** Sharpen image (if jpg and the user wishes to do so) + if ($sharpen && in_array($this->fileExtension, $this->sharpenArray)) + { - // *** Sharpen - $this->sharpen(); - } - } + // *** Sharpen + $this->sharpen(); + } + } ## -------------------------------------------------------- - public function cropImage($newWidth, $newHeight, $cropPos = 'm') - # Author: Jarrod Oberto - # Date: 08-09-11 - # Purpose: Crops the image - # Param in: $newWidth: crop with - # $newHeight: crop height - # $cropPos: Can be any of the following: - # tl, t, tr, l, m, r, bl, b, br, auto - # Or: - # a custom position such as '30x50' - # Param out: n/a - # Reference: - # Notes: - # - { + public function cropImage($newWidth, $newHeight, $cropPos = 'm') + # Author: Jarrod Oberto + # Date: 08-09-11 + # Purpose: Crops the image + # Param in: $newWidth: crop with + # $newHeight: crop height + # $cropPos: Can be any of the following: + # tl, t, tr, l, m, r, bl, b, br, auto + # Or: + # a custom position such as '30x50' + # Param out: n/a + # Reference: + # Notes: + # + { - // *** Make sure the file passed in is valid - if ( ! $this->image) - { - if ($this->debug) - { - throw new Exception('file ' . $this->getFileName() . ' is missing or invalid'); - } - else - { - throw new Exception(); - } - }; + // *** Make sure the file passed in is valid + if ( ! $this->image) + { + if ($this->debug) + { + throw new Exception('file ' . $this->getFileName() . ' is missing or invalid'); + } + else + { + throw new Exception(); + } + }; - $this->imageResized = $this->image; - $this->crop($this->width, $this->height, $newWidth, $newHeight, $cropPos); + $this->imageResized = $this->image; + $this->crop($this->width, $this->height, $newWidth, $newHeight, $cropPos); - } + } ## -------------------------------------------------------- - private function keepTransparancy($width, $height, $im) - # Author: Jarrod Oberto - # Date: 08-04-11 - # Purpose: Keep transparency for png and gif image - # Param in: - # Param out: n/a - # Reference: - # Notes: - # - { - // *** If PNG, perform some transparency retention actions (gif untested) - if (in_array($this->fileExtension, $this->transparentArray) && $this->keepTransparency) - { - imagealphablending($im, false); - imagesavealpha($im, true); - $transparent = imagecolorallocatealpha($im, 255, 255, 255, 127); - imagefilledrectangle($im, 0, 0, (int)$width, (int)$height, (int)$transparent); - } - else - { - $color = imagecolorallocate($im, $this->fillColorArray['r'], $this->fillColorArray['g'], $this->fillColorArray['b']); - imagefilledrectangle($im, 0, 0, (int)$width, (int)$height, (int)$color); - } - } + private function keepTransparancy($width, $height, $im) + # Author: Jarrod Oberto + # Date: 08-04-11 + # Purpose: Keep transparency for png and gif image + # Param in: + # Param out: n/a + # Reference: + # Notes: + # + { + // *** If PNG, perform some transparency retention actions (gif untested) + if (in_array($this->fileExtension, $this->transparentArray) && $this->keepTransparency) + { + imagealphablending($im, false); + imagesavealpha($im, true); + $transparent = imagecolorallocatealpha($im, 255, 255, 255, 127); + imagefilledrectangle($im, 0, 0, $width, $height, $transparent); + } + else + { + $color = imagecolorallocate($im, $this->fillColorArray['r'], $this->fillColorArray['g'], $this->fillColorArray['b']); + imagefilledrectangle($im, 0, 0, $width, $height, $color); + } + } ## -------------------------------------------------------- - private function crop($optimalWidth, $optimalHeight, $newWidth, $newHeight, $cropPos) - # Author: Jarrod Oberto - # Date: 15-09-08 - # Purpose: Crops the image - # Param in: $newWidth: - # $newHeight: - # Param out: n/a - # Reference: - # Notes: - # - { + private function crop($optimalWidth, $optimalHeight, $newWidth, $newHeight, $cropPos) + # Author: Jarrod Oberto + # Date: 15-09-08 + # Purpose: Crops the image + # Param in: $newWidth: + # $newHeight: + # Param out: n/a + # Reference: + # Notes: + # + { - // *** Get cropping co-ordinates - $cropArray = $this->getCropPlacing($optimalWidth, $optimalHeight, $newWidth, $newHeight, $cropPos); - $cropStartX = $cropArray['x']; - $cropStartY = $cropArray['y']; + // *** Get cropping co-ordinates + $cropArray = $this->getCropPlacing($optimalWidth, $optimalHeight, $newWidth, $newHeight, $cropPos); + $cropStartX = $cropArray['x']; + $cropStartY = $cropArray['y']; - // *** Crop this bad boy - $crop = imagecreatetruecolor($newWidth, $newHeight); - $this->keepTransparancy($optimalWidth, $optimalHeight, $crop); - imagecopyresampled($crop, $this->imageResized, 0, 0, (int) $cropStartX,(int) $cropStartY, (int) $newWidth, (int) $newHeight, (int) $newWidth, (int) $newHeight); + // *** Crop this bad boy + $crop = imagecreatetruecolor($newWidth, $newHeight); + $this->keepTransparancy($optimalWidth, $optimalHeight, $crop); + imagecopyresampled($crop, $this->imageResized, 0, 0, $cropStartX, $cropStartY, $newWidth, $newHeight, $newWidth, $newHeight); - $this->imageResized = $crop; + $this->imageResized = $crop; - // *** Set new width and height to our variables - $this->width = $newWidth; - $this->height = $newHeight; + // *** Set new width and height to our variables + $this->width = $newWidth; + $this->height = $newHeight; - } + } ## -------------------------------------------------------- - private function getCropPlacing($optimalWidth, $optimalHeight, $newWidth, $newHeight, $pos = 'm') - # - # Author: Jarrod Oberto - # Date: July 11 - # Purpose: Set the cropping area. - # Params in: - # Params out: (array) the crop x and y co-ordinates. - # Notes: When specifying the exact pixel crop position (eg 10x15), be - # very careful as it's easy to crop out of the image leaving - # black borders. - # - { - $pos = fix_strtolower($pos); + private function getCropPlacing($optimalWidth, $optimalHeight, $newWidth, $newHeight, $pos = 'm') + # + # Author: Jarrod Oberto + # Date: July 11 + # Purpose: Set the cropping area. + # Params in: + # Params out: (array) the crop x and y co-ordinates. + # Notes: When specifying the exact pixel crop position (eg 10x15), be + # very careful as it's easy to crop out of the image leaving + # black borders. + # + { + $pos = fix_strtolower($pos); - // *** If co-ords have been entered - if (strstr($pos, 'x')) - { - $pos = str_replace(' ', '', $pos); + // *** If co-ords have been entered + if (strstr($pos, 'x')) + { + $pos = str_replace(' ', '', $pos); - $xyArray = explode('x', $pos); - list($cropStartX, $cropStartY) = $xyArray; + $xyArray = explode('x', $pos); + list($cropStartX, $cropStartY) = $xyArray; - } - else - { + } + else + { - switch ($pos) - { - case 'tl': - $cropStartX = 0; - $cropStartY = 0; - break; + switch ($pos) + { + case 'tl': + $cropStartX = 0; + $cropStartY = 0; + break; - case 't': - $cropStartX = ($optimalWidth / 2) - ($newWidth / 2); - $cropStartY = 0; - break; + case 't': + $cropStartX = ($optimalWidth / 2) - ($newWidth / 2); + $cropStartY = 0; + break; - case 'tr': - $cropStartX = $optimalWidth - $newWidth; - $cropStartY = 0; - break; + case 'tr': + $cropStartX = $optimalWidth - $newWidth; + $cropStartY = 0; + break; - case 'l': - $cropStartX = 0; - $cropStartY = ($optimalHeight / 2) - ($newHeight / 2); - break; + case 'l': + $cropStartX = 0; + $cropStartY = ($optimalHeight / 2) - ($newHeight / 2); + break; - case 'm': - $cropStartX = ($optimalWidth / 2) - ($newWidth / 2); - $cropStartY = ($optimalHeight / 2) - ($newHeight / 2); - break; + case 'm': + $cropStartX = ($optimalWidth / 2) - ($newWidth / 2); + $cropStartY = ($optimalHeight / 2) - ($newHeight / 2); + break; - case 'r': - $cropStartX = $optimalWidth - $newWidth; - $cropStartY = ($optimalHeight / 2) - ($newHeight / 2); - break; + case 'r': + $cropStartX = $optimalWidth - $newWidth; + $cropStartY = ($optimalHeight / 2) - ($newHeight / 2); + break; - case 'bl': - $cropStartX = 0; - $cropStartY = $optimalHeight - $newHeight; - break; + case 'bl': + $cropStartX = 0; + $cropStartY = $optimalHeight - $newHeight; + break; - case 'b': - $cropStartX = ($optimalWidth / 2) - ($newWidth / 2); - $cropStartY = $optimalHeight - $newHeight; - break; + case 'b': + $cropStartX = ($optimalWidth / 2) - ($newWidth / 2); + $cropStartY = $optimalHeight - $newHeight; + break; - case 'br': - $cropStartX = $optimalWidth - $newWidth; - $cropStartY = $optimalHeight - $newHeight; - break; + case 'br': + $cropStartX = $optimalWidth - $newWidth; + $cropStartY = $optimalHeight - $newHeight; + break; - case 'auto': - // *** If image is a portrait crop from top, not center. v1.5 - if ($optimalHeight > $optimalWidth) - { - $cropStartX = ($optimalWidth / 2) - ($newWidth / 2); - $cropStartY = ($this->cropFromTopPercent / 100) * $optimalHeight; - } - else - { + case 'auto': + // *** If image is a portrait crop from top, not center. v1.5 + if ($optimalHeight > $optimalWidth) + { + $cropStartX = ($optimalWidth / 2) - ($newWidth / 2); + $cropStartY = ($this->cropFromTopPercent / 100) * $optimalHeight; + } + else + { - // *** Else crop from the center - $cropStartX = ($optimalWidth / 2) - ($newWidth / 2); - $cropStartY = ($optimalHeight / 2) - ($newHeight / 2); - } - break; + // *** Else crop from the center + $cropStartX = ($optimalWidth / 2) - ($newWidth / 2); + $cropStartY = ($optimalHeight / 2) - ($newHeight / 2); + } + break; - default: - // *** Default to center - $cropStartX = ($optimalWidth / 2) - ($newWidth / 2); - $cropStartY = ($optimalHeight / 2) - ($newHeight / 2); - break; - } - } + default: + // *** Default to center + $cropStartX = ($optimalWidth / 2) - ($newWidth / 2); + $cropStartY = ($optimalHeight / 2) - ($newHeight / 2); + break; + } + } - return array( 'x' => $cropStartX, 'y' => $cropStartY ); - } + return array( 'x' => $cropStartX, 'y' => $cropStartY ); + } ## -------------------------------------------------------- - private function getDimensions($newWidth, $newHeight, $option) - # Author: Jarrod Oberto - # Date: 17-11-09 - # Purpose: Get new image dimensions based on user specificaions - # Param in: $newWidth: - # $newHeight: - # Param out: Array of new width and height values - # Reference: - # Notes: If $option = 3 then this function is call recursivly - # - # To clarify the $option input: - # 0 = The exact height and width dimensions you set. - # 1 = Whatever height is passed in will be the height that - # is set. The width will be calculated and set automatically - # to a the value that keeps the original aspect ratio. - # 2 = The same but based on the width. - # 3 = Depending whether the image is landscape or portrait, this - # will automatically determine whether to resize via - # dimension 1,2 or 0. - # 4 = Resize the image as much as possible, then crop the - # remainder. - { + private function getDimensions($newWidth, $newHeight, $option) + # Author: Jarrod Oberto + # Date: 17-11-09 + # Purpose: Get new image dimensions based on user specificaions + # Param in: $newWidth: + # $newHeight: + # Param out: Array of new width and height values + # Reference: + # Notes: If $option = 3 then this function is call recursivly + # + # To clarify the $option input: + # 0 = The exact height and width dimensions you set. + # 1 = Whatever height is passed in will be the height that + # is set. The width will be calculated and set automatically + # to a the value that keeps the original aspect ratio. + # 2 = The same but based on the width. + # 3 = Depending whether the image is landscape or portrait, this + # will automatically determine whether to resize via + # dimension 1,2 or 0. + # 4 = Resize the image as much as possible, then crop the + # remainder. + { - switch (strval($option)) - { - case '0': - case 'exact': - $optimalWidth = $newWidth; - $optimalHeight = $newHeight; - break; - case '1': - case 'portrait': - $dimensionsArray = $this->getSizeByFixedHeight($newWidth, $newHeight); - $optimalWidth = $dimensionsArray['optimalWidth']; - $optimalHeight = $dimensionsArray['optimalHeight']; - break; - case '2': - case 'landscape': - $dimensionsArray = $this->getSizeByFixedWidth($newWidth, $newHeight); - $optimalWidth = $dimensionsArray['optimalWidth']; - $optimalHeight = $dimensionsArray['optimalHeight']; - break; - case '3': - case 'auto': - $dimensionsArray = $this->getSizeByAuto($newWidth, $newHeight); - $optimalWidth = $dimensionsArray['optimalWidth']; - $optimalHeight = $dimensionsArray['optimalHeight']; - break; - case '4': - case 'crop': - $dimensionsArray = $this->getOptimalCrop($newWidth, $newHeight); - $optimalWidth = $dimensionsArray['optimalWidth']; - $optimalHeight = $dimensionsArray['optimalHeight']; - break; - } + switch (strval($option)) + { + case '0': + case 'exact': + $optimalWidth = $newWidth; + $optimalHeight = $newHeight; + break; + case '1': + case 'portrait': + $dimensionsArray = $this->getSizeByFixedHeight($newWidth, $newHeight); + $optimalWidth = $dimensionsArray['optimalWidth']; + $optimalHeight = $dimensionsArray['optimalHeight']; + break; + case '2': + case 'landscape': + $dimensionsArray = $this->getSizeByFixedWidth($newWidth, $newHeight); + $optimalWidth = $dimensionsArray['optimalWidth']; + $optimalHeight = $dimensionsArray['optimalHeight']; + break; + case '3': + case 'auto': + $dimensionsArray = $this->getSizeByAuto($newWidth, $newHeight); + $optimalWidth = $dimensionsArray['optimalWidth']; + $optimalHeight = $dimensionsArray['optimalHeight']; + break; + case '4': + case 'crop': + $dimensionsArray = $this->getOptimalCrop($newWidth, $newHeight); + $optimalWidth = $dimensionsArray['optimalWidth']; + $optimalHeight = $dimensionsArray['optimalHeight']; + break; + } - return array( 'optimalWidth' => $optimalWidth, 'optimalHeight' => $optimalHeight ); - } + return array( 'optimalWidth' => $optimalWidth, 'optimalHeight' => $optimalHeight ); + } ## -------------------------------------------------------- - private function getSizeByFixedHeight($newWidth, $newHeight) - { - // *** If forcing is off... - if ( ! $this->forceStretch) - { + private function getSizeByFixedHeight($newWidth, $newHeight) + { + // *** If forcing is off... + if ( ! $this->forceStretch) + { - // *** ...check if actual height is less than target height - if ($this->height < $newHeight) - { - return array( 'optimalWidth' => $this->width, 'optimalHeight' => $this->height ); - } - } + // *** ...check if actual height is less than target height + if ($this->height < $newHeight) + { + return array( 'optimalWidth' => $this->width, 'optimalHeight' => $this->height ); + } + } - $ratio = $this->width / $this->height; + $ratio = $this->width / $this->height; - $newWidth = $newHeight * $ratio; + $newWidth = $newHeight * $ratio; - //return $newWidth; - return array( 'optimalWidth' => $newWidth, 'optimalHeight' => $newHeight ); - } + //return $newWidth; + return array( 'optimalWidth' => $newWidth, 'optimalHeight' => $newHeight ); + } ## -------------------------------------------------------- - private function getSizeByFixedWidth($newWidth, $newHeight) - { - // *** If forcing is off... - if ( ! $this->forceStretch) - { + private function getSizeByFixedWidth($newWidth, $newHeight) + { + // *** If forcing is off... + if ( ! $this->forceStretch) + { - // *** ...check if actual width is less than target width - if ($this->width < $newWidth) - { - return array( 'optimalWidth' => $this->width, 'optimalHeight' => $this->height ); - } - } + // *** ...check if actual width is less than target width + if ($this->width < $newWidth) + { + return array( 'optimalWidth' => $this->width, 'optimalHeight' => $this->height ); + } + } - $ratio = $this->height / $this->width; + $ratio = $this->height / $this->width; - $newHeight = $newWidth * $ratio; + $newHeight = $newWidth * $ratio; - //return $newHeight; - return array( 'optimalWidth' => $newWidth, 'optimalHeight' => $newHeight ); - } + //return $newHeight; + return array( 'optimalWidth' => $newWidth, 'optimalHeight' => $newHeight ); + } ## -------------------------------------------------------- - private function getSizeByAuto($newWidth, $newHeight) - # Author: Jarrod Oberto - # Date: 19-08-08 - # Purpose: Depending on the height, choose to resize by 0, 1, or 2 - # Param in: The new height and new width - # Notes: - # - { - // *** If forcing is off... - if ( ! $this->forceStretch) - { + private function getSizeByAuto($newWidth, $newHeight) + # Author: Jarrod Oberto + # Date: 19-08-08 + # Purpose: Depending on the height, choose to resize by 0, 1, or 2 + # Param in: The new height and new width + # Notes: + # + { + // *** If forcing is off... + if ( ! $this->forceStretch) + { - // *** ...check if actual size is less than target size - if ($this->width < $newWidth && $this->height < $newHeight) - { - return array( 'optimalWidth' => $this->width, 'optimalHeight' => $this->height ); - } - } + // *** ...check if actual size is less than target size + if ($this->width < $newWidth && $this->height < $newHeight) + { + return array( 'optimalWidth' => $this->width, 'optimalHeight' => $this->height ); + } + } - if ($this->height < $this->width) - // *** Image to be resized is wider (landscape) - { - //$optimalWidth = $newWidth; - //$optimalHeight= $this->getSizeByFixedWidth($newWidth); + if ($this->height < $this->width) + // *** Image to be resized is wider (landscape) + { + //$optimalWidth = $newWidth; + //$optimalHeight= $this->getSizeByFixedWidth($newWidth); - $dimensionsArray = $this->getSizeByFixedWidth($newWidth, $newHeight); - $optimalWidth = $dimensionsArray['optimalWidth']; - $optimalHeight = $dimensionsArray['optimalHeight']; - } - elseif ($this->height > $this->width) - // *** Image to be resized is taller (portrait) - { - //$optimalWidth = $this->getSizeByFixedHeight($newHeight); - //$optimalHeight= $newHeight; + $dimensionsArray = $this->getSizeByFixedWidth($newWidth, $newHeight); + $optimalWidth = $dimensionsArray['optimalWidth']; + $optimalHeight = $dimensionsArray['optimalHeight']; + } + elseif ($this->height > $this->width) + // *** Image to be resized is taller (portrait) + { + //$optimalWidth = $this->getSizeByFixedHeight($newHeight); + //$optimalHeight= $newHeight; - $dimensionsArray = $this->getSizeByFixedHeight($newWidth, $newHeight); - $optimalWidth = $dimensionsArray['optimalWidth']; - $optimalHeight = $dimensionsArray['optimalHeight']; - } - else - // *** Image to be resizerd is a square - { + $dimensionsArray = $this->getSizeByFixedHeight($newWidth, $newHeight); + $optimalWidth = $dimensionsArray['optimalWidth']; + $optimalHeight = $dimensionsArray['optimalHeight']; + } + else + // *** Image to be resizerd is a square + { - if ($newHeight < $newWidth) - { - //$optimalWidth = $newWidth; - //$optimalHeight= $this->getSizeByFixedWidth($newWidth); - $dimensionsArray = $this->getSizeByFixedWidth($newWidth, $newHeight); - $optimalWidth = $dimensionsArray['optimalWidth']; - $optimalHeight = $dimensionsArray['optimalHeight']; - } - else - { - if ($newHeight > $newWidth) - { - //$optimalWidth = $this->getSizeByFixedHeight($newHeight); - //$optimalHeight= $newHeight; - $dimensionsArray = $this->getSizeByFixedHeight($newWidth, $newHeight); - $optimalWidth = $dimensionsArray['optimalWidth']; - $optimalHeight = $dimensionsArray['optimalHeight']; - } - else - { - // *** Sqaure being resized to a square - $optimalWidth = $newWidth; - $optimalHeight = $newHeight; - } - } - } + if ($newHeight < $newWidth) + { + //$optimalWidth = $newWidth; + //$optimalHeight= $this->getSizeByFixedWidth($newWidth); + $dimensionsArray = $this->getSizeByFixedWidth($newWidth, $newHeight); + $optimalWidth = $dimensionsArray['optimalWidth']; + $optimalHeight = $dimensionsArray['optimalHeight']; + } + else + { + if ($newHeight > $newWidth) + { + //$optimalWidth = $this->getSizeByFixedHeight($newHeight); + //$optimalHeight= $newHeight; + $dimensionsArray = $this->getSizeByFixedHeight($newWidth, $newHeight); + $optimalWidth = $dimensionsArray['optimalWidth']; + $optimalHeight = $dimensionsArray['optimalHeight']; + } + else + { + // *** Sqaure being resized to a square + $optimalWidth = $newWidth; + $optimalHeight = $newHeight; + } + } + } - return array( 'optimalWidth' => $optimalWidth, 'optimalHeight' => $optimalHeight ); - } + return array( 'optimalWidth' => $optimalWidth, 'optimalHeight' => $optimalHeight ); + } ## -------------------------------------------------------- - private function getOptimalCrop($newWidth, $newHeight) - # Author: Jarrod Oberto - # Date: 17-11-09 - # Purpose: Get optimal crop dimensions - # Param in: width and height as requested by user (fig 3) - # Param out: Array of optimal width and height (fig 2) - # Reference: - # Notes: The optimal width and height return are not the same as the - # same as the width and height passed in. For example: - # - # - # |-----------------| |------------| |-------| - # | | => |**| |**| => | | - # | | |**| |**| | | - # | | |------------| |-------| - # |-----------------| - # original optimal crop - # size size size - # Fig 1 2 3 - # - # 300 x 250 150 x 125 150 x 100 - # - # The optimal size is the smallest size (that is closest to the crop size) - # while retaining proportion/ratio. - # - # The crop size is the optimal size that has been cropped on one axis to - # make the image the exact size specified by the user. - # - # * represent cropped area - # - { + private function getOptimalCrop($newWidth, $newHeight) + # Author: Jarrod Oberto + # Date: 17-11-09 + # Purpose: Get optimal crop dimensions + # Param in: width and height as requested by user (fig 3) + # Param out: Array of optimal width and height (fig 2) + # Reference: + # Notes: The optimal width and height return are not the same as the + # same as the width and height passed in. For example: + # + # + # |-----------------| |------------| |-------| + # | | => |**| |**| => | | + # | | |**| |**| | | + # | | |------------| |-------| + # |-----------------| + # original optimal crop + # size size size + # Fig 1 2 3 + # + # 300 x 250 150 x 125 150 x 100 + # + # The optimal size is the smallest size (that is closest to the crop size) + # while retaining proportion/ratio. + # + # The crop size is the optimal size that has been cropped on one axis to + # make the image the exact size specified by the user. + # + # * represent cropped area + # + { - // *** If forcing is off... - if ( ! $this->forceStretch) - { + // *** If forcing is off... + if ( ! $this->forceStretch) + { - // *** ...check if actual size is less than target size - if ($this->width < $newWidth && $this->height < $newHeight) - { - return array( 'optimalWidth' => $this->width, 'optimalHeight' => $this->height ); - } - } + // *** ...check if actual size is less than target size + if ($this->width < $newWidth && $this->height < $newHeight) + { + return array( 'optimalWidth' => $this->width, 'optimalHeight' => $this->height ); + } + } - $heightRatio = $this->height / $newHeight; - $widthRatio = $this->width / $newWidth; + $heightRatio = $this->height / $newHeight; + $widthRatio = $this->width / $newWidth; - if ($heightRatio < $widthRatio) - { - $optimalRatio = $heightRatio; - } - else - { - $optimalRatio = $widthRatio; - } + if ($heightRatio < $widthRatio) + { + $optimalRatio = $heightRatio; + } + else + { + $optimalRatio = $widthRatio; + } - $optimalHeight = round($this->height / $optimalRatio); - $optimalWidth = round($this->width / $optimalRatio); + $optimalHeight = round($this->height / $optimalRatio); + $optimalWidth = round($this->width / $optimalRatio); - return array( 'optimalWidth' => $optimalWidth, 'optimalHeight' => $optimalHeight ); - } + return array( 'optimalWidth' => $optimalWidth, 'optimalHeight' => $optimalHeight ); + } ## -------------------------------------------------------- - private function sharpen() - # Author: Jarrod Oberto - # Date: 08 04 2011 - # Purpose: Sharpen image - # Param in: n/a - # Param out: n/a - # Reference: - # Notes: - # Credit: Incorporates Joe Lencioni (August 6, 2008) code - { + private function sharpen() + # Author: Jarrod Oberto + # Date: 08 04 2011 + # Purpose: Sharpen image + # Param in: n/a + # Param out: n/a + # Reference: + # Notes: + # Credit: Incorporates Joe Lencioni (August 6, 2008) code + { - if (version_compare(PHP_VERSION, '5.1.0') >= 0) - { + if (version_compare(PHP_VERSION, '5.1.0') >= 0) + { - // *** - if ($this->aggresiveSharpening) - { # A more aggressive sharpening solution + // *** + if ($this->aggresiveSharpening) + { # A more aggressive sharpening solution - $sharpenMatrix = array( array( -1, -1, -1 ), - array( -1, 16, -1 ), - array( -1, -1, -1 ) ); - $divisor = 8; - $offset = 0; + $sharpenMatrix = array( array( -1, -1, -1 ), + array( -1, 16, -1 ), + array( -1, -1, -1 ) ); + $divisor = 8; + $offset = 0; - imageconvolution($this->imageResized, $sharpenMatrix, $divisor, $offset); - } - else # More subtle and personally more desirable - { - $sharpness = $this->findSharp($this->widthOriginal, $this->width); + imageconvolution($this->imageResized, $sharpenMatrix, $divisor, $offset); + } + else # More subtle and personally more desirable + { + $sharpness = $this->findSharp($this->widthOriginal, $this->width); - $sharpenMatrix = array( - array( -1, -2, -1 ), - array( -2, $sharpness + 12, -2 ), //Lessen the effect of a filter by increasing the value in the center cell - array( -1, -2, -1 ) - ); - $divisor = $sharpness; // adjusts brightness - $offset = 0; - imageconvolution($this->imageResized, $sharpenMatrix, $divisor, $offset); - } - } - else - { - if ($this->debug) - { - throw new Exception('Sharpening required PHP 5.1.0 or greater.'); - } - } - } + $sharpenMatrix = array( + array( -1, -2, -1 ), + array( -2, $sharpness + 12, -2 ), //Lessen the effect of a filter by increasing the value in the center cell + array( -1, -2, -1 ) + ); + $divisor = $sharpness; // adjusts brightness + $offset = 0; + imageconvolution($this->imageResized, $sharpenMatrix, $divisor, $offset); + } + } + else + { + if ($this->debug) + { + throw new Exception('Sharpening required PHP 5.1.0 or greater.'); + } + } + } - ## -------------------------------------------------------- + ## -------------------------------------------------------- - private function sharpen2($level) - { - $sharpenMatrix = array( - array( $level, $level, $level ), - array( $level, (8 * $level) + 1, $level ), //Lessen the effect of a filter by increasing the value in the center cell - array( $level, $level, $level ) - ); + private function sharpen2($level) + { + $sharpenMatrix = array( + array( $level, $level, $level ), + array( $level, (8 * $level) + 1, $level ), //Lessen the effect of a filter by increasing the value in the center cell + array( $level, $level, $level ) + ); - } + } ## -------------------------------------------------------- - private function findSharp($orig, $final) - # Author: Ryan Rud (http://adryrun.com) - # Purpose: Find optimal sharpness - # Param in: n/a - # Param out: n/a - # Reference: - # Notes: - # - { - $final = $final * (750.0 / $orig); - $a = 52; - $b = -0.27810650887573124; - $c = .00047337278106508946; + private function findSharp($orig, $final) + # Author: Ryan Rud (http://adryrun.com) + # Purpose: Find optimal sharpness + # Param in: n/a + # Param out: n/a + # Reference: + # Notes: + # + { + $final = $final * (750.0 / $orig); + $a = 52; + $b = -0.27810650887573124; + $c = .00047337278106508946; - $result = $a + $b * $final + $c * $final * $final; + $result = $a + $b * $final + $c * $final * $final; - return max(round($result), 0); - } + return max(round($result), 0); + } ## -------------------------------------------------------- - private function prepOption($option) - # Author: Jarrod Oberto - # Purpose: Prep option like change the passed in option to lowercase - # Param in: (str/int) $option: eg. 'exact', 'crop'. 0, 4 - # Param out: lowercase string - # Reference: - # Notes: - # - { - if (is_array($option)) - { - if (fix_strtolower($option[0]) == 'crop' && count($option) == 2) - { - return 'crop'; - } - else - { - throw new Exception('Crop resize option array is badly formatted.'); - } - } - else - { - if (strpos($option, 'crop') !== false) - { - return 'crop'; - } - } + private function prepOption($option) + # Author: Jarrod Oberto + # Purpose: Prep option like change the passed in option to lowercase + # Param in: (str/int) $option: eg. 'exact', 'crop'. 0, 4 + # Param out: lowercase string + # Reference: + # Notes: + # + { + if (is_array($option)) + { + if (fix_strtolower($option[0]) == 'crop' && count($option) == 2) + { + return 'crop'; + } + else + { + throw new Exception('Crop resize option array is badly formatted.'); + } + } + else + { + if (strpos($option, 'crop') !== false) + { + return 'crop'; + } + } - if (is_string($option)) - { - return fix_strtolower($option); - } + if (is_string($option)) + { + return fix_strtolower($option); + } - return $option; - } + return $option; + } - /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-*-*-*-*-*-*-*-*-*- + /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-*-*-*-*-*-*-*-*-*- Presets *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-*-*-*-*-*-*-*-*-*/ @@ -981,2605 +980,2625 @@ class imageLib { # - public function borderPreset($preset) - { - switch ($preset) - { + public function borderPreset($preset) + { + switch ($preset) + { - case 'simple': - $this->addBorder(7, '#fff'); - $this->addBorder(6, '#f2f1f0'); - $this->addBorder(2, '#fff'); - $this->addBorder(1, '#ccc'); - break; - default: - break; - } + case 'simple': + $this->addBorder(7, '#fff'); + $this->addBorder(6, '#f2f1f0'); + $this->addBorder(2, '#fff'); + $this->addBorder(1, '#ccc'); + break; + default: + break; + } - } + } - /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-*-*-*-*-*-*-*-*-*- + /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-*-*-*-*-*-*-*-*-*- Draw border *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-*-*-*-*-*-*-*-*-*/ - public function addBorder($thickness = 1, $rgbArray = array( 255, 255, 255 )) - # Author: Jarrod Oberto - # Date: 05-05-11 - # Purpose: Add a border to the image - # Param in: - # Param out: - # Reference: - # Notes: This border is added to the INSIDE of the image - # - { - if ($this->imageResized) - { + public function addBorder($thickness = 1, $rgbArray = array( 255, 255, 255 )) + # Author: Jarrod Oberto + # Date: 05-05-11 + # Purpose: Add a border to the image + # Param in: + # Param out: + # Reference: + # Notes: This border is added to the INSIDE of the image + # + { + if ($this->imageResized) + { - $rgbArray = $this->formatColor($rgbArray); - $r = $rgbArray['r']; - $g = $rgbArray['g']; - $b = $rgbArray['b']; + $rgbArray = $this->formatColor($rgbArray); + $r = $rgbArray['r']; + $g = $rgbArray['g']; + $b = $rgbArray['b']; - $x1 = 0; - $y1 = 0; - $x2 = ImageSX($this->imageResized) - 1; - $y2 = ImageSY($this->imageResized) - 1; + $x1 = 0; + $y1 = 0; + $x2 = ImageSX($this->imageResized) - 1; + $y2 = ImageSY($this->imageResized) - 1; - $rgbArray = ImageColorAllocate($this->imageResized, $r, $g, $b); + $rgbArray = ImageColorAllocate($this->imageResized, $r, $g, $b); - for ($i = 0; $i < $thickness; $i++) - { - ImageRectangle($this->imageResized, $x1++, $y1++, $x2--, $y2--, $rgbArray); - } - } - } + for ($i = 0; $i < $thickness; $i++) + { + ImageRectangle($this->imageResized, $x1++, $y1++, $x2--, $y2--, $rgbArray); + } + } + } - /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-*-*-*-*-*-*-*-*-*- + /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-*-*-*-*-*-*-*-*-*- Gray Scale *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-*-*-*-*-*-*-*-*-*/ - public function greyScale() - # Author: Jarrod Oberto - # Date: 07-05-2011 - # Purpose: Make image greyscale - # Param in: n/a - # Param out: - # Reference: - # Notes: - # - { - if ($this->imageResized) - { - imagefilter($this->imageResized, IMG_FILTER_GRAYSCALE); - } + public function greyScale() + # Author: Jarrod Oberto + # Date: 07-05-2011 + # Purpose: Make image greyscale + # Param in: n/a + # Param out: + # Reference: + # Notes: + # + { + if ($this->imageResized) + { + imagefilter($this->imageResized, IMG_FILTER_GRAYSCALE); + } - } + } - ## -------------------------------------------------------- + ## -------------------------------------------------------- - public function greyScaleEnhanced() - # Author: Jarrod Oberto - # Date: 07-05-2011 - # Purpose: Make image greyscale - # Param in: n/a - # Param out: - # Reference: - # Notes: - # - { - if ($this->imageResized) - { - imagefilter($this->imageResized, IMG_FILTER_GRAYSCALE); - imagefilter($this->imageResized, IMG_FILTER_CONTRAST, -15); - imagefilter($this->imageResized, IMG_FILTER_BRIGHTNESS, 2); - $this->sharpen($this->width); - } - } + public function greyScaleEnhanced() + # Author: Jarrod Oberto + # Date: 07-05-2011 + # Purpose: Make image greyscale + # Param in: n/a + # Param out: + # Reference: + # Notes: + # + { + if ($this->imageResized) + { + imagefilter($this->imageResized, IMG_FILTER_GRAYSCALE); + imagefilter($this->imageResized, IMG_FILTER_CONTRAST, -15); + imagefilter($this->imageResized, IMG_FILTER_BRIGHTNESS, 2); + $this->sharpen($this->width); + } + } - ## -------------------------------------------------------- + ## -------------------------------------------------------- - public function greyScaleDramatic() - # Alias of gd_filter_monopin - { - $this->gd_filter_monopin(); - } + public function greyScaleDramatic() + # Alias of gd_filter_monopin + { + $this->gd_filter_monopin(); + } - /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-*-*-*-*-*-*-*-*-*- + /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-*-*-*-*-*-*-*-*-*- Black 'n White *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-*-*-*-*-*-*-*-*-*/ - public function blackAndWhite() - # Author: Jarrod Oberto - # Date: 07-05-2011 - # Purpose: Make image black and white - # Param in: n/a - # Param out: - # Reference: - # Notes: - # - { - if ($this->imageResized) - { + public function blackAndWhite() + # Author: Jarrod Oberto + # Date: 07-05-2011 + # Purpose: Make image black and white + # Param in: n/a + # Param out: + # Reference: + # Notes: + # + { + if ($this->imageResized) + { - imagefilter($this->imageResized, IMG_FILTER_GRAYSCALE); - imagefilter($this->imageResized, IMG_FILTER_CONTRAST, -1000); - } + imagefilter($this->imageResized, IMG_FILTER_GRAYSCALE); + imagefilter($this->imageResized, IMG_FILTER_CONTRAST, -1000); + } - } + } - /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-*-*-*-*-*-*-*-*-*- + /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-*-*-*-*-*-*-*-*-*- Negative *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-*-*-*-*-*-*-*-*-*/ - public function negative() - # Author: Jarrod Oberto - # Date: 07-05-2011 - # Purpose: Make image negative - # Param in: n/a - # Param out: - # Reference: - # Notes: - # - { - if ($this->imageResized) - { + public function negative() + # Author: Jarrod Oberto + # Date: 07-05-2011 + # Purpose: Make image negative + # Param in: n/a + # Param out: + # Reference: + # Notes: + # + { + if ($this->imageResized) + { - imagefilter($this->imageResized, IMG_FILTER_NEGATE); - } + imagefilter($this->imageResized, IMG_FILTER_NEGATE); + } - } + } - /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-*-*-*-*-*-*-*-*-*- + /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-*-*-*-*-*-*-*-*-*- Sepia *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-*-*-*-*-*-*-*-*-*/ - public function sepia() - # Author: Jarrod Oberto - # Date: 07-05-2011 - # Purpose: Make image sepia - # Param in: n/a - # Param out: - # Reference: - # Notes: - # - { - if ($this->imageResized) - { - imagefilter($this->imageResized, IMG_FILTER_GRAYSCALE); - imagefilter($this->imageResized, IMG_FILTER_BRIGHTNESS, -10); - imagefilter($this->imageResized, IMG_FILTER_CONTRAST, -20); - imagefilter($this->imageResized, IMG_FILTER_COLORIZE, 60, 30, -15); - } - } + public function sepia() + # Author: Jarrod Oberto + # Date: 07-05-2011 + # Purpose: Make image sepia + # Param in: n/a + # Param out: + # Reference: + # Notes: + # + { + if ($this->imageResized) + { + imagefilter($this->imageResized, IMG_FILTER_GRAYSCALE); + imagefilter($this->imageResized, IMG_FILTER_BRIGHTNESS, -10); + imagefilter($this->imageResized, IMG_FILTER_CONTRAST, -20); + imagefilter($this->imageResized, IMG_FILTER_COLORIZE, 60, 30, -15); + } + } - ## -------------------------------------------------------- + ## -------------------------------------------------------- - public function sepia2() + public function sepia2() - { - if ($this->imageResized) - { + { + if ($this->imageResized) + { - $total = imagecolorstotal($this->imageResized); - for ($i = 0; $i < $total; $i++) - { - $index = imagecolorsforindex($this->imageResized, $i); - $red = ($index["red"] * 0.393 + $index["green"] * 0.769 + $index["blue"] * 0.189) / 1.351; - $green = ($index["red"] * 0.349 + $index["green"] * 0.686 + $index["blue"] * 0.168) / 1.203; - $blue = ($index["red"] * 0.272 + $index["green"] * 0.534 + $index["blue"] * 0.131) / 2.140; - imagecolorset($this->imageResized, $i, $red, $green, $blue); - } + $total = imagecolorstotal($this->imageResized); + for ($i = 0; $i < $total; $i++) + { + $index = imagecolorsforindex($this->imageResized, $i); + $red = ($index["red"] * 0.393 + $index["green"] * 0.769 + $index["blue"] * 0.189) / 1.351; + $green = ($index["red"] * 0.349 + $index["green"] * 0.686 + $index["blue"] * 0.168) / 1.203; + $blue = ($index["red"] * 0.272 + $index["green"] * 0.534 + $index["blue"] * 0.131) / 2.140; + imagecolorset($this->imageResized, $i, $red, $green, $blue); + } - } - } + } + } - /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-*-*-*-*-*-*-*-*-*- + /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-*-*-*-*-*-*-*-*-*- Vintage *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-*-*-*-*-*-*-*-*-*/ - public function vintage() - # Alias of gd_filter_monopin - { - $this->gd_filter_vintage(); - } + public function vintage() + # Alias of gd_filter_monopin + { + $this->gd_filter_vintage(); + } - /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-*-*-*-*-*-*-*-*-*- + /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-*-*-*-*-*-*-*-*-*- Presets By Marc Hibbins *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-*-*-*-*-*-*-*-*-*/ - /** Apply 'Monopin' preset */ - public function gd_filter_monopin() - { + /** Apply 'Monopin' preset */ + public function gd_filter_monopin() + { - if ($this->imageResized) - { - imagefilter($this->imageResized, IMG_FILTER_GRAYSCALE); - imagefilter($this->imageResized, IMG_FILTER_BRIGHTNESS, -15); - imagefilter($this->imageResized, IMG_FILTER_CONTRAST, -15); - $this->imageResized = $this->gd_apply_overlay($this->imageResized, 'vignette', 100); - } - } + if ($this->imageResized) + { + imagefilter($this->imageResized, IMG_FILTER_GRAYSCALE); + imagefilter($this->imageResized, IMG_FILTER_BRIGHTNESS, -15); + imagefilter($this->imageResized, IMG_FILTER_CONTRAST, -15); + $this->imageResized = $this->gd_apply_overlay($this->imageResized, 'vignette', 100); + } + } - ## -------------------------------------------------------- + ## -------------------------------------------------------- - public function gd_filter_vintage() - { - if ($this->imageResized) - { - $this->imageResized = $this->gd_apply_overlay($this->imageResized, 'vignette', 45); - imagefilter($this->imageResized, IMG_FILTER_BRIGHTNESS, 20); - imagefilter($this->imageResized, IMG_FILTER_CONTRAST, -35); - imagefilter($this->imageResized, IMG_FILTER_COLORIZE, 60, -10, 35); - imagefilter($this->imageResized, IMG_FILTER_SMOOTH, 7); - $this->imageResized = $this->gd_apply_overlay($this->imageResized, 'scratch', 10); - } - } + public function gd_filter_vintage() + { + if ($this->imageResized) + { + $this->imageResized = $this->gd_apply_overlay($this->imageResized, 'vignette', 45); + imagefilter($this->imageResized, IMG_FILTER_BRIGHTNESS, 20); + imagefilter($this->imageResized, IMG_FILTER_CONTRAST, -35); + imagefilter($this->imageResized, IMG_FILTER_COLORIZE, 60, -10, 35); + imagefilter($this->imageResized, IMG_FILTER_SMOOTH, 7); + $this->imageResized = $this->gd_apply_overlay($this->imageResized, 'scratch', 10); + } + } - ## -------------------------------------------------------- + ## -------------------------------------------------------- - /** Apply a PNG overlay */ - private function gd_apply_overlay($im, $type, $amount) - # - # Original Author: Marc Hibbins - # License: Attribution-ShareAlike 3.0 - # Purpose: - # Params in: - # Params out: - # Notes: - # - { - $width = imagesx($im); - $height = imagesy($im); - $filter = imagecreatetruecolor($width, $height); + /** Apply a PNG overlay */ + private function gd_apply_overlay($im, $type, $amount) + # + # Original Author: Marc Hibbins + # License: Attribution-ShareAlike 3.0 + # Purpose: + # Params in: + # Params out: + # Notes: + # + { + $width = imagesx($im); + $height = imagesy($im); + $filter = imagecreatetruecolor($width, $height); - imagealphablending($filter, false); - imagesavealpha($filter, true); + imagealphablending($filter, false); + imagesavealpha($filter, true); - $transparent = imagecolorallocatealpha($filter, 255, 255, 255, 127); - imagefilledrectangle($filter, 0, 0, $width, $height, $transparent); + $transparent = imagecolorallocatealpha($filter, 255, 255, 255, 127); + imagefilledrectangle($filter, 0, 0, $width, $height, $transparent); - // *** Resize overlay - $overlay = $this->filterOverlayPath . '/' . $type . '.png'; - $png = imagecreatefrompng($overlay); - imagecopyresampled($filter, $png, 0, 0, 0, 0, $width, $height, imagesx($png), imagesy($png)); + // *** Resize overlay + $overlay = $this->filterOverlayPath . '/' . $type . '.png'; + $png = imagecreatefrompng($overlay); + imagecopyresampled($filter, $png, 0, 0, 0, 0, $width, $height, imagesx($png), imagesy($png)); - $comp = imagecreatetruecolor($width, $height); - imagecopy($comp, $im, 0, 0, 0, 0, $width, $height); - imagecopy($comp, $filter, 0, 0, 0, 0, $width, $height); - imagecopymerge($im, $comp, 0, 0, 0, 0, $width, $height, $amount); + $comp = imagecreatetruecolor($width, $height); + imagecopy($comp, $im, 0, 0, 0, 0, $width, $height); + imagecopy($comp, $filter, 0, 0, 0, 0, $width, $height); + imagecopymerge($im, $comp, 0, 0, 0, 0, $width, $height, $amount); - imagedestroy($comp); + imagedestroy($comp); - return $im; - } + return $im; + } - /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-*-*-*-*-*-*-*-*-*- + /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-*-*-*-*-*-*-*-*-*- Colorise *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-*-*-*-*-*-*-*-*-*/ - public function image_colorize($rgb) - { - imageTrueColorToPalette($this->imageResized, true, 256); - $numColors = imageColorsTotal($this->imageResized); + public function image_colorize($rgb) + { + imageTrueColorToPalette($this->imageResized, true, 256); + $numColors = imageColorsTotal($this->imageResized); - for ($x = 0; $x < $numColors; $x++) - { - list($r, $g, $b) = array_values(imageColorsForIndex($this->imageResized, $x)); + for ($x = 0; $x < $numColors; $x++) + { + list($r, $g, $b) = array_values(imageColorsForIndex($this->imageResized, $x)); - // calculate grayscale in percent - $grayscale = ($r + $g + $b) / 3 / 0xff; + // calculate grayscale in percent + $grayscale = ($r + $g + $b) / 3 / 0xff; - imageColorSet($this->imageResized, $x, - $grayscale * $rgb[0], - $grayscale * $rgb[1], - $grayscale * $rgb[2] - ); + imageColorSet($this->imageResized, $x, + $grayscale * $rgb[0], + $grayscale * $rgb[1], + $grayscale * $rgb[2] + ); - } + } - return true; - } + return true; + } - /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-*-*-*-*-*-*-*-*-*- + /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-*-*-*-*-*-*-*-*-*- Reflection *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-*-*-*-*-*-*-*-*-*/ - public function addReflection($reflectionHeight = 50, $startingTransparency = 30, $inside = false, $bgColor = '#fff', $stretch = false, $divider = 0) - { + public function addReflection($reflectionHeight = 50, $startingTransparency = 30, $inside = false, $bgColor = '#fff', $stretch = false, $divider = 0) + { - // *** Convert color - $rgbArray = $this->formatColor($bgColor); - $r = $rgbArray['r']; - $g = $rgbArray['g']; - $b = $rgbArray['b']; + // *** Convert color + $rgbArray = $this->formatColor($bgColor); + $r = $rgbArray['r']; + $g = $rgbArray['g']; + $b = $rgbArray['b']; - $im = $this->imageResized; - $li = imagecreatetruecolor($this->width, 1); + $im = $this->imageResized; + $li = imagecreatetruecolor($this->width, 1); - $bgc = imagecolorallocate($li, $r, $g, $b); - imagefilledrectangle($li, 0, 0, $this->width, 1, $bgc); + $bgc = imagecolorallocate($li, $r, $g, $b); + imagefilledrectangle($li, 0, 0, $this->width, 1, $bgc); - $bg = imagecreatetruecolor($this->width, $reflectionHeight); - $wh = imagecolorallocate($im, 255, 255, 255); + $bg = imagecreatetruecolor($this->width, $reflectionHeight); + $wh = imagecolorallocate($im, 255, 255, 255); - $im = imagerotate($im, -180, $wh); - imagecopyresampled($bg, $im, 0, 0, 0, 0, $this->width, $this->height, $this->width, $this->height); + $im = imagerotate($im, -180, $wh); + imagecopyresampled($bg, $im, 0, 0, 0, 0, $this->width, $this->height, $this->width, $this->height); - $im = $bg; + $im = $bg; - $bg = imagecreatetruecolor($this->width, $reflectionHeight); + $bg = imagecreatetruecolor($this->width, $reflectionHeight); - for ($x = 0; $x < $this->width; $x++) - { - imagecopy($bg, $im, $x, 0, $this->width - $x - 1, 0, 1, $reflectionHeight); - } - $im = $bg; + for ($x = 0; $x < $this->width; $x++) + { + imagecopy($bg, $im, $x, 0, $this->width - $x - 1, 0, 1, $reflectionHeight); + } + $im = $bg; - $transaprencyAmount = $this->invertTransparency($startingTransparency, 100); + $transaprencyAmount = $this->invertTransparency($startingTransparency, 100); - // *** Fade - if ($stretch) - { - $step = 100 / ($reflectionHeight + $startingTransparency); - } - else - { - $step = 100 / $reflectionHeight; - } - for ($i = 0; $i <= $reflectionHeight; $i++) - { + // *** Fade + if ($stretch) + { + $step = 100 / ($reflectionHeight + $startingTransparency); + } + else + { + $step = 100 / $reflectionHeight; + } + for ($i = 0; $i <= $reflectionHeight; $i++) + { - if ($startingTransparency > 100) - { - $startingTransparency = 100; - } - if ($startingTransparency < 1) - { - $startingTransparency = 1; - } - imagecopymerge($bg, $li, 0, $i, 0, 0, $this->width, 1, $startingTransparency); - $startingTransparency += $step; - } + if ($startingTransparency > 100) + { + $startingTransparency = 100; + } + if ($startingTransparency < 1) + { + $startingTransparency = 1; + } + imagecopymerge($bg, $li, 0, $i, 0, 0, $this->width, 1, $startingTransparency); + $startingTransparency += $step; + } - // *** Apply fade - imagecopymerge($im, $li, 0, 0, 0, 0, $this->width, $divider, 100); // Divider + // *** Apply fade + imagecopymerge($im, $li, 0, 0, 0, 0, $this->width, $divider, 100); // Divider - // *** width, height of reflection. - $x = imagesx($im); - $y = imagesy($im); + // *** width, height of reflection. + $x = imagesx($im); + $y = imagesy($im); - // *** Determines if the reflection should be displayed inside or outside the image - if ($inside) - { + // *** Determines if the reflection should be displayed inside or outside the image + if ($inside) + { - // Create new blank image with sizes. - $final = imagecreatetruecolor($this->width, $this->height); + // Create new blank image with sizes. + $final = imagecreatetruecolor($this->width, $this->height); - imagecopymerge($final, $this->imageResized, 0, 0, 0, $reflectionHeight, $this->width, $this->height - $reflectionHeight, 100); - imagecopymerge($final, $im, 0, $this->height - $reflectionHeight, 0, 0, $x, $y, 100); + imagecopymerge($final, $this->imageResized, 0, 0, 0, $reflectionHeight, $this->width, $this->height - $reflectionHeight, 100); + imagecopymerge($final, $im, 0, $this->height - $reflectionHeight, 0, 0, $x, $y, 100); - } - else - { + } + else + { - // Create new blank image with sizes. - $final = imagecreatetruecolor($this->width, $this->height + $y); + // Create new blank image with sizes. + $final = imagecreatetruecolor($this->width, $this->height + $y); - imagecopymerge($final, $this->imageResized, 0, 0, 0, 0, $this->width, $this->height, 100); - imagecopymerge($final, $im, 0, $this->height, 0, 0, $x, $y, 100); - } + imagecopymerge($final, $this->imageResized, 0, 0, 0, 0, $this->width, $this->height, 100); + imagecopymerge($final, $im, 0, $this->height, 0, 0, $x, $y, 100); + } - $this->imageResized = $final; + $this->imageResized = $final; - imagedestroy($li); - imagedestroy($im); - } + imagedestroy($li); + imagedestroy($im); + } - /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-*-*-*-*-*-*-*-*-*- + /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-*-*-*-*-*-*-*-*-*- Rotate *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-*-*-*-*-*-*-*-*-*/ - public function rotate($value = 90, $bgColor = 'transparent') - # Author: Jarrod Oberto - # Date: 07-05-2011 - # Purpose: Rotate image - # Param in: (mixed) $degrees: (int) number of degress to rotate image - # (str) param "left": rotate left - # (str) param "right": rotate right - # (str) param "upside": upside-down image - # Param out: - # Reference: - # Notes: The default direction of imageRotate() is counter clockwise. - # - { - if ($this->imageResized) - { + public function rotate($value = 90, $bgColor = 'transparent') + # Author: Jarrod Oberto + # Date: 07-05-2011 + # Purpose: Rotate image + # Param in: (mixed) $degrees: (int) number of degress to rotate image + # (str) param "left": rotate left + # (str) param "right": rotate right + # (str) param "upside": upside-down image + # Param out: + # Reference: + # Notes: The default direction of imageRotate() is counter clockwise. + # + { + if ($this->imageResized) + { - if (is_integer($value)) - { - $degrees = $value; - } + if (is_integer($value)) + { + $degrees = $value; + } - // *** Convert color - $rgbArray = $this->formatColor($bgColor); - $r = $rgbArray['r']; - $g = $rgbArray['g']; - $b = $rgbArray['b']; - if (isset($rgbArray['a'])) - { - $a = $rgbArray['a']; - } + // *** Convert color + $rgbArray = $this->formatColor($bgColor); + $r = $rgbArray['r']; + $g = $rgbArray['g']; + $b = $rgbArray['b']; + if (isset($rgbArray['a'])) + { + $a = $rgbArray['a']; + } - if (is_string($value)) - { + if (is_string($value)) + { - $value = fix_strtolower($value); + $value = fix_strtolower($value); - switch ($value) - { - case 'left': - $degrees = 90; - break; - case 'right': - $degrees = 270; - break; - case 'upside': - $degrees = 180; - break; - default: - break; - } + switch ($value) + { + case 'left': + $degrees = 90; + break; + case 'right': + $degrees = 270; + break; + case 'upside': + $degrees = 180; + break; + default: + break; + } - } + } - // *** The default direction of imageRotate() is counter clockwise - // * This makes it clockwise - $degrees = 360 - $degrees; + // *** The default direction of imageRotate() is counter clockwise + // * This makes it clockwise + $degrees = 360 - $degrees; - // *** Create background color - $bg = ImageColorAllocateAlpha($this->imageResized, $r, $g, $b, $a); + // *** Create background color + $bg = ImageColorAllocateAlpha($this->imageResized, $r, $g, $b, $a); - // *** Fill with background - ImageFill($this->imageResized, 0, 0, $bg); + // *** Fill with background + ImageFill($this->imageResized, 0, 0, $bg); - // *** Rotate - $this->imageResized = imagerotate($this->imageResized, $degrees, $bg); // Rotate 45 degrees and allocated the transparent colour as the one to make transparent (obviously) + // *** Rotate + $this->imageResized = imagerotate($this->imageResized, $degrees, $bg); // Rotate 45 degrees and allocated the transparent colour as the one to make transparent (obviously) - // Ensure alpha transparency - ImageSaveAlpha($this->imageResized, true); + // Ensure alpha transparency + ImageSaveAlpha($this->imageResized, true); - } - } + } + } - /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-*-*-*-*-*-*-*-*-*- + /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-*-*-*-*-*-*-*-*-*- Round corners *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-*-*-*-*-*-*-*-*-*/ - public function roundCorners($radius = 5, $bgColor = 'transparent') - # Author: Jarrod Oberto - # Date: 19-05-2011 - # Purpose: Create rounded corners on your image - # Param in: (int) radius = the amount of curvature - # (mixed) $bgColor = the corner background color - # Param out: n/a - # Reference: - # Notes: - # - { + public function roundCorners($radius = 5, $bgColor = 'transparent') + # Author: Jarrod Oberto + # Date: 19-05-2011 + # Purpose: Create rounded corners on your image + # Param in: (int) radius = the amount of curvature + # (mixed) $bgColor = the corner background color + # Param out: n/a + # Reference: + # Notes: + # + { - // *** Check if the user wants transparency - $isTransparent = false; - if ( ! is_array($bgColor)) - { - if (fix_strtolower($bgColor) == 'transparent') - { - $isTransparent = true; - } - } + // *** Check if the user wants transparency + $isTransparent = false; + if ( ! is_array($bgColor)) + { + if (fix_strtolower($bgColor) == 'transparent') + { + $isTransparent = true; + } + } - // *** If we use transparency, we need to color our curved mask with a unique color - if ($isTransparent) - { - $bgColor = $this->findUnusedGreen(); - } + // *** If we use transparency, we need to color our curved mask with a unique color + if ($isTransparent) + { + $bgColor = $this->findUnusedGreen(); + } - // *** Convert color - $rgbArray = $this->formatColor($bgColor); - $r = $rgbArray['r']; - $g = $rgbArray['g']; - $b = $rgbArray['b']; - if (isset($rgbArray['a'])) - { - $a = $rgbArray['a']; - } + // *** Convert color + $rgbArray = $this->formatColor($bgColor); + $r = $rgbArray['r']; + $g = $rgbArray['g']; + $b = $rgbArray['b']; + if (isset($rgbArray['a'])) + { + $a = $rgbArray['a']; + } - // *** Create top-left corner mask (square) - $cornerImg = imagecreatetruecolor($radius, $radius); - //$cornerImg = imagecreate($radius, $radius); + // *** Create top-left corner mask (square) + $cornerImg = imagecreatetruecolor($radius, $radius); + //$cornerImg = imagecreate($radius, $radius); - //imagealphablending($cornerImg, true); - //imagesavealpha($cornerImg, true); + //imagealphablending($cornerImg, true); + //imagesavealpha($cornerImg, true); - //imagealphablending($this->imageResized, false); - //imagesavealpha($this->imageResized, true); + //imagealphablending($this->imageResized, false); + //imagesavealpha($this->imageResized, true); - // *** Give it a color - $maskColor = imagecolorallocate($cornerImg, 0, 0, 0); + // *** Give it a color + $maskColor = imagecolorallocate($cornerImg, 0, 0, 0); - // *** Replace the mask color (black) to transparent - imagecolortransparent($cornerImg, $maskColor); + // *** Replace the mask color (black) to transparent + imagecolortransparent($cornerImg, $maskColor); - // *** Create the image background color - $imagebgColor = imagecolorallocate($cornerImg, $r, $g, $b); + // *** Create the image background color + $imagebgColor = imagecolorallocate($cornerImg, $r, $g, $b); - // *** Fill the corner area to the user defined color - imagefill($cornerImg, 0, 0, $imagebgColor); + // *** Fill the corner area to the user defined color + imagefill($cornerImg, 0, 0, $imagebgColor); - imagefilledellipse($cornerImg, $radius, $radius, $radius * 2, $radius * 2, $maskColor); + imagefilledellipse($cornerImg, $radius, $radius, $radius * 2, $radius * 2, $maskColor); - // *** Map to top left corner - imagecopymerge($this->imageResized, $cornerImg, 0, 0, 0, 0, $radius, $radius, 100); #tl + // *** Map to top left corner + imagecopymerge($this->imageResized, $cornerImg, 0, 0, 0, 0, $radius, $radius, 100); #tl - // *** Map rounded corner to other corners by rotating and applying the mask - $cornerImg = imagerotate($cornerImg, 90, 0); - imagecopymerge($this->imageResized, $cornerImg, 0, $this->height - $radius, 0, 0, $radius, $radius, 100); #bl + // *** Map rounded corner to other corners by rotating and applying the mask + $cornerImg = imagerotate($cornerImg, 90, 0); + imagecopymerge($this->imageResized, $cornerImg, 0, $this->height - $radius, 0, 0, $radius, $radius, 100); #bl - $cornerImg = imagerotate($cornerImg, 90, 0); - imagecopymerge($this->imageResized, $cornerImg, $this->width - $radius, $this->height - $radius, 0, 0, $radius, $radius, 100); #br + $cornerImg = imagerotate($cornerImg, 90, 0); + imagecopymerge($this->imageResized, $cornerImg, $this->width - $radius, $this->height - $radius, 0, 0, $radius, $radius, 100); #br - $cornerImg = imagerotate($cornerImg, 90, 0); - imagecopymerge($this->imageResized, $cornerImg, $this->width - $radius, 0, 0, 0, $radius, $radius, 100); #tr + $cornerImg = imagerotate($cornerImg, 90, 0); + imagecopymerge($this->imageResized, $cornerImg, $this->width - $radius, 0, 0, 0, $radius, $radius, 100); #tr - // *** If corners are to be transparent, we fill our chromakey color as transparent. - if ($isTransparent) - { - //imagecolortransparent($this->imageResized, $imagebgColor); - $this->imageResized = $this->transparentImage($this->imageResized); - imagesavealpha($this->imageResized, true); - } + // *** If corners are to be transparent, we fill our chromakey color as transparent. + if ($isTransparent) + { + //imagecolortransparent($this->imageResized, $imagebgColor); + $this->imageResized = $this->transparentImage($this->imageResized); + imagesavealpha($this->imageResized, true); + } - } + } - /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-*-*-*-*-*-*-*-*-*- + /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-*-*-*-*-*-*-*-*-*- Shadow *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-*-*-*-*-*-*-*-*-*/ - public function addShadow($shadowAngle = 45, $blur = 15, $bgColor = 'transparent') - # - # Author: Jarrod Oberto (Adapted from Pascal Naidon) - # Ref: http://www.les-stooges.org/pascal/webdesign/vignettes/index.php?la=en - # Purpose: Add a drop shadow to your image - # Params in: (int) $angle: the angle of the shadow - # (int) $blur: the blur distance - # (mixed) $bgColor: the color of the background - # Params out: - # Notes: - # - { - // *** A higher number results in a smoother shadow - define('STEPS', $blur * 2); + public function addShadow($shadowAngle = 45, $blur = 15, $bgColor = 'transparent') + # + # Author: Jarrod Oberto (Adapted from Pascal Naidon) + # Ref: http://www.les-stooges.org/pascal/webdesign/vignettes/index.php?la=en + # Purpose: Add a drop shadow to your image + # Params in: (int) $angle: the angle of the shadow + # (int) $blur: the blur distance + # (mixed) $bgColor: the color of the background + # Params out: + # Notes: + # + { + // *** A higher number results in a smoother shadow + define('STEPS', $blur * 2); - // *** Set the shadow distance - $shadowDistance = $blur * 0.25; + // *** Set the shadow distance + $shadowDistance = $blur * 0.25; - // *** Set blur width and height - $blurWidth = $blurHeight = $blur; + // *** Set blur width and height + $blurWidth = $blurHeight = $blur; - if ($shadowAngle == 0) - { - $distWidth = 0; - $distHeight = 0; - } - else - { - $distWidth = $shadowDistance * cos(deg2rad($shadowAngle)); - $distHeight = $shadowDistance * sin(deg2rad($shadowAngle)); - } + if ($shadowAngle == 0) + { + $distWidth = 0; + $distHeight = 0; + } + else + { + $distWidth = $shadowDistance * cos(deg2rad($shadowAngle)); + $distHeight = $shadowDistance * sin(deg2rad($shadowAngle)); + } - // *** Convert color - if (fix_strtolower($bgColor) != 'transparent') - { - $rgbArray = $this->formatColor($bgColor); - $r0 = $rgbArray['r']; - $g0 = $rgbArray['g']; - $b0 = $rgbArray['b']; - } + // *** Convert color + if (fix_strtolower($bgColor) != 'transparent') + { + $rgbArray = $this->formatColor($bgColor); + $r0 = $rgbArray['r']; + $g0 = $rgbArray['g']; + $b0 = $rgbArray['b']; + } - $image = $this->imageResized; - $width = $this->width; - $height = $this->height; + $image = $this->imageResized; + $width = $this->width; + $height = $this->height; - $newImage = imagecreatetruecolor($width, $height); - imagecopyresampled($newImage, $image, 0, 0, 0, 0, $width, $height, $width, $height); + $newImage = imagecreatetruecolor($width, $height); + imagecopyresampled($newImage, $image, 0, 0, 0, 0, $width, $height, $width, $height); - // *** RGB - $rgb = imagecreatetruecolor($width + $blurWidth, $height + $blurHeight); - $colour = imagecolorallocate($rgb, 0, 0, 0); - imagefilledrectangle($rgb, 0, 0, $width + $blurWidth, $height + $blurHeight, $colour); - $colour = imagecolorallocate($rgb, 255, 255, 255); - //imagefilledrectangle($rgb, $blurWidth*0.5-$distWidth, $blurHeight*0.5-$distHeight, $width+$blurWidth*0.5-$distWidth, $height+$blurWidth*0.5-$distHeight, $colour); - imagefilledrectangle($rgb, $blurWidth * 0.5 - $distWidth, $blurHeight * 0.5 - $distHeight, $width + $blurWidth * 0.5 - $distWidth, $height + $blurWidth * 0.5 - $distHeight, $colour); - //imagecopymerge($rgb, $newImage, 1+$blurWidth*0.5-$distWidth, 1+$blurHeight*0.5-$distHeight, 0,0, $width, $height, 100); - imagecopymerge($rgb, $newImage, $blurWidth * 0.5 - $distWidth, $blurHeight * 0.5 - $distHeight, 0, 0, $width + $blurWidth, $height + $blurHeight, 100); + // *** RGB + $rgb = imagecreatetruecolor($width + $blurWidth, $height + $blurHeight); + $colour = imagecolorallocate($rgb, 0, 0, 0); + imagefilledrectangle($rgb, 0, 0, $width + $blurWidth, $height + $blurHeight, $colour); + $colour = imagecolorallocate($rgb, 255, 255, 255); + //imagefilledrectangle($rgb, $blurWidth*0.5-$distWidth, $blurHeight*0.5-$distHeight, $width+$blurWidth*0.5-$distWidth, $height+$blurWidth*0.5-$distHeight, $colour); + imagefilledrectangle($rgb, $blurWidth * 0.5 - $distWidth, $blurHeight * 0.5 - $distHeight, $width + $blurWidth * 0.5 - $distWidth, $height + $blurWidth * 0.5 - $distHeight, $colour); + //imagecopymerge($rgb, $newImage, 1+$blurWidth*0.5-$distWidth, 1+$blurHeight*0.5-$distHeight, 0,0, $width, $height, 100); + imagecopymerge($rgb, $newImage, $blurWidth * 0.5 - $distWidth, $blurHeight * 0.5 - $distHeight, 0, 0, $width + $blurWidth, $height + $blurHeight, 100); - // *** Shadow (alpha) - $shadow = imagecreatetruecolor($width + $blurWidth, $height + $blurHeight); - imagealphablending($shadow, false); - $colour = imagecolorallocate($shadow, 0, 0, 0); - imagefilledrectangle($shadow, 0, 0, $width + $blurWidth, $height + $blurHeight, $colour); + // *** Shadow (alpha) + $shadow = imagecreatetruecolor($width + $blurWidth, $height + $blurHeight); + imagealphablending($shadow, false); + $colour = imagecolorallocate($shadow, 0, 0, 0); + imagefilledrectangle($shadow, 0, 0, $width + $blurWidth, $height + $blurHeight, $colour); - for ($i = 0; $i <= STEPS; $i++) - { + for ($i = 0; $i <= STEPS; $i++) + { - $t = ((1.0 * $i) / STEPS); - $intensity = 255 * $t * $t; + $t = ((1.0 * $i) / STEPS); + $intensity = 255 * $t * $t; - $colour = imagecolorallocate($shadow, $intensity, $intensity, $intensity); - $points = array( - $blurWidth * $t, $blurHeight, // Point 1 (x, y) - $blurWidth, $blurHeight * $t, // Point 2 (x, y) - $width, $blurHeight * $t, // Point 3 (x, y) - $width + $blurWidth * (1 - $t), $blurHeight, // Point 4 (x, y) - $width + $blurWidth * (1 - $t), $height, // Point 5 (x, y) - $width, $height + $blurHeight * (1 - $t), // Point 6 (x, y) - $blurWidth, $height + $blurHeight * (1 - $t), // Point 7 (x, y) - $blurWidth * $t, $height // Point 8 (x, y) - ); - imagepolygon($shadow, $points, 8, $colour); - } + $colour = imagecolorallocate($shadow, $intensity, $intensity, $intensity); + $points = array( + $blurWidth * $t, $blurHeight, // Point 1 (x, y) + $blurWidth, $blurHeight * $t, // Point 2 (x, y) + $width, $blurHeight * $t, // Point 3 (x, y) + $width + $blurWidth * (1 - $t), $blurHeight, // Point 4 (x, y) + $width + $blurWidth * (1 - $t), $height, // Point 5 (x, y) + $width, $height + $blurHeight * (1 - $t), // Point 6 (x, y) + $blurWidth, $height + $blurHeight * (1 - $t), // Point 7 (x, y) + $blurWidth * $t, $height // Point 8 (x, y) + ); + imagepolygon($shadow, $points, 8, $colour); + } - for ($i = 0; $i <= STEPS; $i++) - { + for ($i = 0; $i <= STEPS; $i++) + { - $t = ((1.0 * $i) / STEPS); - $intensity = 255 * $t * $t; + $t = ((1.0 * $i) / STEPS); + $intensity = 255 * $t * $t; - $colour = imagecolorallocate($shadow, $intensity, $intensity, $intensity); - imagefilledarc($shadow, $blurWidth - 1, $blurHeight - 1, 2 * (1 - $t) * $blurWidth, 2 * (1 - $t) * $blurHeight, 180, 268, $colour, IMG_ARC_PIE); - imagefilledarc($shadow, $width, $blurHeight - 1, 2 * (1 - $t) * $blurWidth, 2 * (1 - $t) * $blurHeight, 270, 358, $colour, IMG_ARC_PIE); - imagefilledarc($shadow, $width, $height, 2 * (1 - $t) * $blurWidth, 2 * (1 - $t) * $blurHeight, 0, 90, $colour, IMG_ARC_PIE); - imagefilledarc($shadow, $blurWidth - 1, $height, 2 * (1 - $t) * $blurWidth, 2 * (1 - $t) * $blurHeight, 90, 180, $colour, IMG_ARC_PIE); - } + $colour = imagecolorallocate($shadow, $intensity, $intensity, $intensity); + imagefilledarc($shadow, $blurWidth - 1, $blurHeight - 1, 2 * (1 - $t) * $blurWidth, 2 * (1 - $t) * $blurHeight, 180, 268, $colour, IMG_ARC_PIE); + imagefilledarc($shadow, $width, $blurHeight - 1, 2 * (1 - $t) * $blurWidth, 2 * (1 - $t) * $blurHeight, 270, 358, $colour, IMG_ARC_PIE); + imagefilledarc($shadow, $width, $height, 2 * (1 - $t) * $blurWidth, 2 * (1 - $t) * $blurHeight, 0, 90, $colour, IMG_ARC_PIE); + imagefilledarc($shadow, $blurWidth - 1, $height, 2 * (1 - $t) * $blurWidth, 2 * (1 - $t) * $blurHeight, 90, 180, $colour, IMG_ARC_PIE); + } - $colour = imagecolorallocate($shadow, 255, 255, 255); - imagefilledrectangle($shadow, $blurWidth, $blurHeight, $width, $height, $colour); - imagefilledrectangle($shadow, $blurWidth * 0.5 - $distWidth, $blurHeight * 0.5 - $distHeight, $width + $blurWidth * 0.5 - 1 - $distWidth, $height + $blurHeight * 0.5 - 1 - $distHeight, $colour); + $colour = imagecolorallocate($shadow, 255, 255, 255); + imagefilledrectangle($shadow, $blurWidth, $blurHeight, $width, $height, $colour); + imagefilledrectangle($shadow, $blurWidth * 0.5 - $distWidth, $blurHeight * 0.5 - $distHeight, $width + $blurWidth * 0.5 - 1 - $distWidth, $height + $blurHeight * 0.5 - 1 - $distHeight, $colour); - // *** The magic - imagealphablending($rgb, false); + // *** The magic + imagealphablending($rgb, false); - for ($theX = 0; $theX < imagesx($rgb); $theX++) - { - for ($theY = 0; $theY < imagesy($rgb); $theY++) - { + for ($theX = 0; $theX < imagesx($rgb); $theX++) + { + for ($theY = 0; $theY < imagesy($rgb); $theY++) + { - // *** Get the RGB values for every pixel of the RGB image - $colArray = imagecolorat($rgb, $theX, $theY); - $r = ($colArray >> 16) & 0xFF; - $g = ($colArray >> 8) & 0xFF; - $b = $colArray & 0xFF; + // *** Get the RGB values for every pixel of the RGB image + $colArray = imagecolorat($rgb, $theX, $theY); + $r = ($colArray >> 16) & 0xFF; + $g = ($colArray >> 8) & 0xFF; + $b = $colArray & 0xFF; - // *** Get the alpha value for every pixel of the shadow image - $colArray = imagecolorat($shadow, $theX, $theY); - $a = $colArray & 0xFF; - $a = 127 - floor($a / 2); - $t = $a / 128.0; + // *** Get the alpha value for every pixel of the shadow image + $colArray = imagecolorat($shadow, $theX, $theY); + $a = $colArray & 0xFF; + $a = 127 - floor($a / 2); + $t = $a / 128.0; - // *** Create color - if (fix_strtolower($bgColor) == 'transparent') - { - $myColour = imagecolorallocatealpha($rgb, $r, $g, $b, $a); - } - else - { - $myColour = imagecolorallocate($rgb, $r * (1.0 - $t) + $r0 * $t, $g * (1.0 - $t) + $g0 * $t, $b * (1.0 - $t) + $b0 * $t); - } + // *** Create color + if (fix_strtolower($bgColor) == 'transparent') + { + $myColour = imagecolorallocatealpha($rgb, $r, $g, $b, $a); + } + else + { + $myColour = imagecolorallocate($rgb, $r * (1.0 - $t) + $r0 * $t, $g * (1.0 - $t) + $g0 * $t, $b * (1.0 - $t) + $b0 * $t); + } - // *** Add color to new rgb image - imagesetpixel($rgb, $theX, $theY, $myColour); - } - } + // *** Add color to new rgb image + imagesetpixel($rgb, $theX, $theY, $myColour); + } + } - imagealphablending($rgb, true); - imagesavealpha($rgb, true); + imagealphablending($rgb, true); + imagesavealpha($rgb, true); - $this->imageResized = $rgb; + $this->imageResized = $rgb; - imagedestroy($image); - imagedestroy($newImage); - imagedestroy($shadow); - } + imagedestroy($image); + imagedestroy($newImage); + imagedestroy($shadow); + } - /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-*-*-*-*-*-*-*-*-*- + /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-*-*-*-*-*-*-*-*-*- Add Caption Box *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-*-*-*-*-*-*-*-*-*/ - public function addCaptionBox($side = 'b', $thickness = 50, $padding = 0, $bgColor = '#000', $transaprencyAmount = 30) - # - # Author: Jarrod Oberto - # Date: 26 May 2011 - # Purpose: Add a caption box - # Params in: (str) $side: the side to add the caption box (t, r, b, or l). - # (int) $thickness: how thick you want the caption box to be. - # (mixed) $bgColor: The color of the caption box. - # (int) $transaprencyAmount: The amount of transparency to be - # applied. - # Params out: n/a - # Notes: - # - { - $side = fix_strtolower($side); + public function addCaptionBox($side = 'b', $thickness = 50, $padding = 0, $bgColor = '#000', $transaprencyAmount = 30) + # + # Author: Jarrod Oberto + # Date: 26 May 2011 + # Purpose: Add a caption box + # Params in: (str) $side: the side to add the caption box (t, r, b, or l). + # (int) $thickness: how thick you want the caption box to be. + # (mixed) $bgColor: The color of the caption box. + # (int) $transaprencyAmount: The amount of transparency to be + # applied. + # Params out: n/a + # Notes: + # + { + $side = fix_strtolower($side); - // *** Convert color - $rgbArray = $this->formatColor($bgColor); - $r = $rgbArray['r']; - $g = $rgbArray['g']; - $b = $rgbArray['b']; + // *** Convert color + $rgbArray = $this->formatColor($bgColor); + $r = $rgbArray['r']; + $g = $rgbArray['g']; + $b = $rgbArray['b']; - $positionArray = $this->calculateCaptionBoxPosition($side, $thickness, $padding); + $positionArray = $this->calculateCaptionBoxPosition($side, $thickness, $padding); - // *** Store incase we want to use method addTextToCaptionBox() - $this->captionBoxPositionArray = $positionArray; + // *** Store incase we want to use method addTextToCaptionBox() + $this->captionBoxPositionArray = $positionArray; - $transaprencyAmount = $this->invertTransparency($transaprencyAmount, 127, false); - $transparent = imagecolorallocatealpha($this->imageResized, $r, $g, $b, $transaprencyAmount); - imagefilledrectangle($this->imageResized, $positionArray['x1'], $positionArray['y1'], $positionArray['x2'], $positionArray['y2'], $transparent); - } + $transaprencyAmount = $this->invertTransparency($transaprencyAmount, 127, false); + $transparent = imagecolorallocatealpha($this->imageResized, $r, $g, $b, $transaprencyAmount); + imagefilledrectangle($this->imageResized, $positionArray['x1'], $positionArray['y1'], $positionArray['x2'], $positionArray['y2'], $transparent); + } - ## -------------------------------------------------------- + ## -------------------------------------------------------- - public function addTextToCaptionBox($text, $fontColor = '#fff', $fontSize = 12, $angle = 0, $font = null) - # - # Author: Jarrod Oberto - # Date: 03 Aug 11 - # Purpose: Simplify adding text to a caption box by automatically - # locating the center of the caption box - # Params in: The usually text paams (less a couple) - # Params out: n/a - # Notes: - # - { + public function addTextToCaptionBox($text, $fontColor = '#fff', $fontSize = 12, $angle = 0, $font = null) + # + # Author: Jarrod Oberto + # Date: 03 Aug 11 + # Purpose: Simplify adding text to a caption box by automatically + # locating the center of the caption box + # Params in: The usually text paams (less a couple) + # Params out: n/a + # Notes: + # + { - // *** Get the caption box measurements - if (count($this->captionBoxPositionArray) == 4) - { - $x1 = $this->captionBoxPositionArray['x1']; - $x2 = $this->captionBoxPositionArray['x2']; - $y1 = $this->captionBoxPositionArray['y1']; - $y2 = $this->captionBoxPositionArray['y2']; - } - else - { - if ($this->debug) - { - throw new Exception('No caption box found.'); - } - else - { - return false; - } - } + // *** Get the caption box measurements + if (count($this->captionBoxPositionArray) == 4) + { + $x1 = $this->captionBoxPositionArray['x1']; + $x2 = $this->captionBoxPositionArray['x2']; + $y1 = $this->captionBoxPositionArray['y1']; + $y2 = $this->captionBoxPositionArray['y2']; + } + else + { + if ($this->debug) + { + throw new Exception('No caption box found.'); + } + else + { + return false; + } + } - // *** Get text font - $font = $this->getTextFont($font); + // *** Get text font + $font = $this->getTextFont($font); - // *** Get text size - $textSizeArray = $this->getTextSize($fontSize, $angle, $font, $text); - $textWidth = $textSizeArray['width']; - $textHeight = $textSizeArray['height']; + // *** Get text size + $textSizeArray = $this->getTextSize($fontSize, $angle, $font, $text); + $textWidth = $textSizeArray['width']; + $textHeight = $textSizeArray['height']; - // *** Find the width/height middle points - $boxXMiddle = (($x2 - $x1) / 2); - $boxYMiddle = (($y2 - $y1) / 2); + // *** Find the width/height middle points + $boxXMiddle = (($x2 - $x1) / 2); + $boxYMiddle = (($y2 - $y1) / 2); - // *** Box middle - half the text width/height - $xPos = ($x1 + $boxXMiddle) - ($textWidth / 2); - $yPos = ($y1 + $boxYMiddle) - ($textHeight / 2); + // *** Box middle - half the text width/height + $xPos = ($x1 + $boxXMiddle) - ($textWidth / 2); + $yPos = ($y1 + $boxYMiddle) - ($textHeight / 2); - $pos = $xPos . 'x' . $yPos; + $pos = $xPos . 'x' . $yPos; - $this->addText($text, $pos, $padding = 0, $fontColor, $fontSize, $angle, $font); + $this->addText($text, $pos, $padding = 0, $fontColor, $fontSize, $angle, $font); - } + } - ## -------------------------------------------------------- + ## -------------------------------------------------------- - private function calculateCaptionBoxPosition($side, $thickness, $padding) - { - $positionArray = array(); + private function calculateCaptionBoxPosition($side, $thickness, $padding) + { + $positionArray = array(); - switch ($side) - { - case 't': - $positionArray['x1'] = 0; - $positionArray['y1'] = $padding; - $positionArray['x2'] = $this->width; - $positionArray['y2'] = $thickness + $padding; - break; - case 'r': - $positionArray['x1'] = $this->width - $thickness - $padding; - $positionArray['y1'] = 0; - $positionArray['x2'] = $this->width - $padding; - $positionArray['y2'] = $this->height; - break; - case 'b': - $positionArray['x1'] = 0; - $positionArray['y1'] = $this->height - $thickness - $padding; - $positionArray['x2'] = $this->width; - $positionArray['y2'] = $this->height - $padding; - break; - case 'l': - $positionArray['x1'] = $padding; - $positionArray['y1'] = 0; - $positionArray['x2'] = $thickness + $padding; - $positionArray['y2'] = $this->height; - break; + switch ($side) + { + case 't': + $positionArray['x1'] = 0; + $positionArray['y1'] = $padding; + $positionArray['x2'] = $this->width; + $positionArray['y2'] = $thickness + $padding; + break; + case 'r': + $positionArray['x1'] = $this->width - $thickness - $padding; + $positionArray['y1'] = 0; + $positionArray['x2'] = $this->width - $padding; + $positionArray['y2'] = $this->height; + break; + case 'b': + $positionArray['x1'] = 0; + $positionArray['y1'] = $this->height - $thickness - $padding; + $positionArray['x2'] = $this->width; + $positionArray['y2'] = $this->height - $padding; + break; + case 'l': + $positionArray['x1'] = $padding; + $positionArray['y1'] = 0; + $positionArray['x2'] = $thickness + $padding; + $positionArray['y2'] = $this->height; + break; - default: - break; - } + default: + break; + } - return $positionArray; + return $positionArray; - } + } - /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-*-*-*-*-*-*-*-*-*- + /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-*-*-*-*-*-*-*-*-*- Get EXIF Data *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-*-*-*-*-*-*-*-*-*/ - public function getExif($debug = false) - # Author: Jarrod Oberto - # Date: 07-05-2011 - # Purpose: Get image EXIF data - # Param in: n/a - # Param out: An associate array of EXIF data - # Reference: - # Notes: - # 23 May 13 : added orientation flag -jco - # - { + public function getExif($debug = false) + # Author: Jarrod Oberto + # Date: 07-05-2011 + # Purpose: Get image EXIF data + # Param in: n/a + # Param out: An associate array of EXIF data + # Reference: + # Notes: + # 23 May 13 : added orientation flag -jco + # + { - if ( ! $this->debug || ! $debug) - { - $debug = false; - } + if ( ! $this->debug || ! $debug) + { + $debug = false; + } - // *** Check all is good - check the EXIF library exists and the file exists, too. - if ( ! $this->testEXIFInstalled()) - { - if ($debug) - { - throw new Exception('The EXIF Library is not installed.'); - } - else - { - return array(); - } - }; - if ( ! file_exists($this->fileName)) - { - if ($debug) - { - throw new Exception('Image not found.'); - } - else - { - return array(); - } - }; - if ($this->fileExtension != '.jpg') - { - if ($debug) - { - throw new Exception('Metadata not supported for this image type.'); - } - else - { - return array(); - } - }; - $exifData = exif_read_data($this->fileName, 'IFD0'); + // *** Check all is good - check the EXIF library exists and the file exists, too. + if ( ! $this->testEXIFInstalled()) + { + if ($debug) + { + throw new Exception('The EXIF Library is not installed.'); + } + else + { + return array(); + } + }; + if ( ! file_exists($this->fileName)) + { + if ($debug) + { + throw new Exception('Image not found.'); + } + else + { + return array(); + } + }; + if ($this->fileExtension != '.jpg') + { + if ($debug) + { + throw new Exception('Metadata not supported for this image type.'); + } + else + { + return array(); + } + }; + $exifData = exif_read_data($this->fileName, 'IFD0'); - // *** Format the apperture value - $ev = $exifData['ApertureValue']; - $apPeicesArray = explode('/', $ev); - if (count($apPeicesArray) == 2) - { - $apertureValue = round($apPeicesArray[0] / $apPeicesArray[1], 2, PHP_ROUND_HALF_DOWN) . ' EV'; - } - else - { - $apertureValue = ''; - } + // *** Format the apperture value + $ev = $exifData['ApertureValue']; + $apPeicesArray = explode('/', $ev); + if (count($apPeicesArray) == 2) + { + $apertureValue = round($apPeicesArray[0] / $apPeicesArray[1], 2, PHP_ROUND_HALF_DOWN) . ' EV'; + } + else + { + $apertureValue = ''; + } - // *** Format the focal length - $focalLength = $exifData['FocalLength']; - $flPeicesArray = explode('/', $focalLength); - if (count($flPeicesArray) == 2) - { - $focalLength = $flPeicesArray[0] / $flPeicesArray[1] . '.0 mm'; - } - else - { - $focalLength = ''; - } + // *** Format the focal length + $focalLength = $exifData['FocalLength']; + $flPeicesArray = explode('/', $focalLength); + if (count($flPeicesArray) == 2) + { + $focalLength = $flPeicesArray[0] / $flPeicesArray[1] . '.0 mm'; + } + else + { + $focalLength = ''; + } - // *** Format fNumber - $fNumber = $exifData['FNumber']; - $fnPeicesArray = explode('/', $fNumber); - if (count($fnPeicesArray) == 2) - { - $fNumber = $fnPeicesArray[0] / $fnPeicesArray[1]; - } - else - { - $fNumber = ''; - } + // *** Format fNumber + $fNumber = $exifData['FNumber']; + $fnPeicesArray = explode('/', $fNumber); + if (count($fnPeicesArray) == 2) + { + $fNumber = $fnPeicesArray[0] / $fnPeicesArray[1]; + } + else + { + $fNumber = ''; + } - // *** Resolve ExposureProgram - if (isset($exifData['ExposureProgram'])) - { - $ep = $exifData['ExposureProgram']; - } - if (isset($ep)) - { - $ep = $this->resolveExposureProgram($ep); - } + // *** Resolve ExposureProgram + if (isset($exifData['ExposureProgram'])) + { + $ep = $exifData['ExposureProgram']; + } + if (isset($ep)) + { + $ep = $this->resolveExposureProgram($ep); + } - // *** Resolve MeteringMode - $mm = $exifData['MeteringMode']; - $mm = $this->resolveMeteringMode($mm); + // *** Resolve MeteringMode + $mm = $exifData['MeteringMode']; + $mm = $this->resolveMeteringMode($mm); - // *** Resolve Flash - $flash = $exifData['Flash']; - $flash = $this->resolveFlash($flash); + // *** Resolve Flash + $flash = $exifData['Flash']; + $flash = $this->resolveFlash($flash); - if (isset($exifData['Make'])) - { - $exifDataArray['make'] = $exifData['Make']; - } - else - { - $exifDataArray['make'] = ''; - } + if (isset($exifData['Make'])) + { + $exifDataArray['make'] = $exifData['Make']; + } + else + { + $exifDataArray['make'] = ''; + } - if (isset($exifData['Model'])) - { - $exifDataArray['model'] = $exifData['Model']; - } - else - { - $exifDataArray['model'] = ''; - } + if (isset($exifData['Model'])) + { + $exifDataArray['model'] = $exifData['Model']; + } + else + { + $exifDataArray['model'] = ''; + } - if (isset($exifData['DateTime'])) - { - $exifDataArray['date'] = $exifData['DateTime']; - } - else - { - $exifDataArray['date'] = ''; - } + if (isset($exifData['DateTime'])) + { + $exifDataArray['date'] = $exifData['DateTime']; + } + else + { + $exifDataArray['date'] = ''; + } - if (isset($exifData['ExposureTime'])) - { - $exifDataArray['exposure time'] = $exifData['ExposureTime'] . ' sec.'; - } - else - { - $exifDataArray['exposure time'] = ''; - } + if (isset($exifData['ExposureTime'])) + { + $exifDataArray['exposure time'] = $exifData['ExposureTime'] . ' sec.'; + } + else + { + $exifDataArray['exposure time'] = ''; + } - if ($apertureValue != '') - { - $exifDataArray['aperture value'] = $apertureValue; - } - else - { - $exifDataArray['aperture value'] = ''; - } + if ($apertureValue != '') + { + $exifDataArray['aperture value'] = $apertureValue; + } + else + { + $exifDataArray['aperture value'] = ''; + } - if (isset($exifData['COMPUTED']['ApertureFNumber'])) - { - $exifDataArray['f-stop'] = $exifData['COMPUTED']['ApertureFNumber']; - } - else - { - $exifDataArray['f-stop'] = ''; - } + if (isset($exifData['COMPUTED']['ApertureFNumber'])) + { + $exifDataArray['f-stop'] = $exifData['COMPUTED']['ApertureFNumber']; + } + else + { + $exifDataArray['f-stop'] = ''; + } - if (isset($exifData['FNumber'])) - { - $exifDataArray['fnumber'] = $exifData['FNumber']; - } - else - { - $exifDataArray['fnumber'] = ''; - } + if (isset($exifData['FNumber'])) + { + $exifDataArray['fnumber'] = $exifData['FNumber']; + } + else + { + $exifDataArray['fnumber'] = ''; + } - if ($fNumber != '') - { - $exifDataArray['fnumber value'] = $fNumber; - } - else - { - $exifDataArray['fnumber value'] = ''; - } + if ($fNumber != '') + { + $exifDataArray['fnumber value'] = $fNumber; + } + else + { + $exifDataArray['fnumber value'] = ''; + } - if (isset($exifData['ISOSpeedRatings'])) - { - $exifDataArray['iso'] = $exifData['ISOSpeedRatings']; - } - else - { - $exifDataArray['iso'] = ''; - } + if (isset($exifData['ISOSpeedRatings'])) + { + $exifDataArray['iso'] = $exifData['ISOSpeedRatings']; + } + else + { + $exifDataArray['iso'] = ''; + } - if ($focalLength != '') - { - $exifDataArray['focal length'] = $focalLength; - } - else - { - $exifDataArray['focal length'] = ''; - } + if ($focalLength != '') + { + $exifDataArray['focal length'] = $focalLength; + } + else + { + $exifDataArray['focal length'] = ''; + } - if (isset($ep)) - { - $exifDataArray['exposure program'] = $ep; - } - else - { - $exifDataArray['exposure program'] = ''; - } + if (isset($ep)) + { + $exifDataArray['exposure program'] = $ep; + } + else + { + $exifDataArray['exposure program'] = ''; + } - if ($mm != '') - { - $exifDataArray['metering mode'] = $mm; - } - else - { - $exifDataArray['metering mode'] = ''; - } + if ($mm != '') + { + $exifDataArray['metering mode'] = $mm; + } + else + { + $exifDataArray['metering mode'] = ''; + } - if ($flash != '') - { - $exifDataArray['flash status'] = $flash; - } - else - { - $exifDataArray['flash status'] = ''; - } + if ($flash != '') + { + $exifDataArray['flash status'] = $flash; + } + else + { + $exifDataArray['flash status'] = ''; + } - if (isset($exifData['Artist'])) - { - $exifDataArray['creator'] = $exifData['Artist']; - } - else - { - $exifDataArray['creator'] = ''; - } + if (isset($exifData['Artist'])) + { + $exifDataArray['creator'] = $exifData['Artist']; + } + else + { + $exifDataArray['creator'] = ''; + } - if (isset($exifData['Copyright'])) - { - $exifDataArray['copyright'] = $exifData['Copyright']; - } - else - { - $exifDataArray['copyright'] = ''; - } + if (isset($exifData['Copyright'])) + { + $exifDataArray['copyright'] = $exifData['Copyright']; + } + else + { + $exifDataArray['copyright'] = ''; + } - // *** Orientation - if (isset($exifData['Orientation'])) - { - $exifDataArray['orientation'] = $exifData['Orientation']; - } - else - { - $exifDataArray['orientation'] = ''; - } + // *** Orientation + if (isset($exifData['Orientation'])) + { + $exifDataArray['orientation'] = $exifData['Orientation']; + } + else + { + $exifDataArray['orientation'] = ''; + } - return $exifDataArray; - } + return $exifDataArray; + } - ## -------------------------------------------------------- + ## -------------------------------------------------------- - private function resolveExposureProgram($ep) - { - switch ($ep) - { - case 0: - $ep = ''; - break; - case 1: - $ep = 'manual'; - break; - case 2: - $ep = 'normal program'; - break; - case 3: - $ep = 'aperture priority'; - break; - case 4: - $ep = 'shutter priority'; - break; - case 5: - $ep = 'creative program'; - break; - case 6: - $ep = 'action program'; - break; - case 7: - $ep = 'portrait mode'; - break; - case 8: - $ep = 'landscape mode'; - break; + private function resolveExposureProgram($ep) + { + switch ($ep) + { + case 0: + $ep = ''; + break; + case 1: + $ep = 'manual'; + break; + case 2: + $ep = 'normal program'; + break; + case 3: + $ep = 'aperture priority'; + break; + case 4: + $ep = 'shutter priority'; + break; + case 5: + $ep = 'creative program'; + break; + case 6: + $ep = 'action program'; + break; + case 7: + $ep = 'portrait mode'; + break; + case 8: + $ep = 'landscape mode'; + break; - default: - break; - } + default: + break; + } - return $ep; - } + return $ep; + } - ## -------------------------------------------------------- + ## -------------------------------------------------------- - private function resolveMeteringMode($mm) - { - switch ($mm) - { - case 0: - $mm = 'unknown'; - break; - case 1: - $mm = 'average'; - break; - case 2: - $mm = 'center weighted average'; - break; - case 3: - $mm = 'spot'; - break; - case 4: - $mm = 'multi spot'; - break; - case 5: - $mm = 'pattern'; - break; - case 6: - $mm = 'partial'; - break; - case 255: - $mm = 'other'; - break; + private function resolveMeteringMode($mm) + { + switch ($mm) + { + case 0: + $mm = 'unknown'; + break; + case 1: + $mm = 'average'; + break; + case 2: + $mm = 'center weighted average'; + break; + case 3: + $mm = 'spot'; + break; + case 4: + $mm = 'multi spot'; + break; + case 5: + $mm = 'pattern'; + break; + case 6: + $mm = 'partial'; + break; + case 255: + $mm = 'other'; + break; - default: - break; - } + default: + break; + } - return $mm; - } + return $mm; + } - ## -------------------------------------------------------- + ## -------------------------------------------------------- - private function resolveFlash($flash) - { - switch ($flash) - { - case 0: - $flash = 'flash did not fire'; - break; - case 1: - $flash = 'flash fired'; - break; - case 5: - $flash = 'strobe return light not detected'; - break; - case 7: - $flash = 'strobe return light detected'; - break; - case 9: - $flash = 'flash fired, compulsory flash mode'; - break; - case 13: - $flash = 'flash fired, compulsory flash mode, return light not detected'; - break; - case 15: - $flash = 'flash fired, compulsory flash mode, return light detected'; - break; - case 16: - $flash = 'flash did not fire, compulsory flash mode'; - break; - case 24: - $flash = 'flash did not fire, auto mode'; - break; - case 25: - $flash = 'flash fired, auto mode'; - break; - case 29: - $flash = 'flash fired, auto mode, return light not detected'; - break; - case 31: - $flash = 'flash fired, auto mode, return light detected'; - break; - case 32: - $flash = 'no flash function'; - break; - case 65: - $flash = 'flash fired, red-eye reduction mode'; - break; - case 69: - $flash = 'flash fired, red-eye reduction mode, return light not detected'; - break; - case 71: - $flash = 'flash fired, red-eye reduction mode, return light detected'; - break; - case 73: - $flash = 'flash fired, compulsory flash mode, red-eye reduction mode'; - break; - case 77: - $flash = 'flash fired, compulsory flash mode, red-eye reduction mode, return light not detected'; - break; - case 79: - $flash = 'flash fired, compulsory flash mode, red-eye reduction mode, return light detected'; - break; - case 89: - $flash = 'flash fired, auto mode, red-eye reduction mode'; - break; - case 93: - $flash = 'flash fired, auto mode, return light not detected, red-eye reduction mode'; - break; - case 95: - $flash = 'flash fired, auto mode, return light detected, red-eye reduction mode'; - break; + private function resolveFlash($flash) + { + switch ($flash) + { + case 0: + $flash = 'flash did not fire'; + break; + case 1: + $flash = 'flash fired'; + break; + case 5: + $flash = 'strobe return light not detected'; + break; + case 7: + $flash = 'strobe return light detected'; + break; + case 9: + $flash = 'flash fired, compulsory flash mode'; + break; + case 13: + $flash = 'flash fired, compulsory flash mode, return light not detected'; + break; + case 15: + $flash = 'flash fired, compulsory flash mode, return light detected'; + break; + case 16: + $flash = 'flash did not fire, compulsory flash mode'; + break; + case 24: + $flash = 'flash did not fire, auto mode'; + break; + case 25: + $flash = 'flash fired, auto mode'; + break; + case 29: + $flash = 'flash fired, auto mode, return light not detected'; + break; + case 31: + $flash = 'flash fired, auto mode, return light detected'; + break; + case 32: + $flash = 'no flash function'; + break; + case 65: + $flash = 'flash fired, red-eye reduction mode'; + break; + case 69: + $flash = 'flash fired, red-eye reduction mode, return light not detected'; + break; + case 71: + $flash = 'flash fired, red-eye reduction mode, return light detected'; + break; + case 73: + $flash = 'flash fired, compulsory flash mode, red-eye reduction mode'; + break; + case 77: + $flash = 'flash fired, compulsory flash mode, red-eye reduction mode, return light not detected'; + break; + case 79: + $flash = 'flash fired, compulsory flash mode, red-eye reduction mode, return light detected'; + break; + case 89: + $flash = 'flash fired, auto mode, red-eye reduction mode'; + break; + case 93: + $flash = 'flash fired, auto mode, return light not detected, red-eye reduction mode'; + break; + case 95: + $flash = 'flash fired, auto mode, return light detected, red-eye reduction mode'; + break; - default: - break; - } + default: + break; + } - return $flash; + return $flash; - } + } - /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-*-*-*-*-*-*-*-*-*- + /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-*-*-*-*-*-*-*-*-*- Get IPTC Data *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-*-*-*-*-*-*-*-*-*/ - /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-*-*-*-*-*-*-*-*-*- + /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-*-*-*-*-*-*-*-*-*- Write IPTC Data *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-*-*-*-*-*-*-*-*-*/ - public function writeIPTCcaption($value) - # Caption - { - $this->writeIPTC(120, $value); - } + public function writeIPTCcaption($value) + # Caption + { + $this->writeIPTC(120, $value); + } - ## -------------------------------------------------------- + ## -------------------------------------------------------- - public function writeIPTCwriter($value) - { - //$this->writeIPTC(65, $value); - } + public function writeIPTCwriter($value) + { + //$this->writeIPTC(65, $value); + } - ## -------------------------------------------------------- + ## -------------------------------------------------------- - private function writeIPTC($dat, $value) - { + private function writeIPTC($dat, $value) + { - # LIMIT TO JPG + # LIMIT TO JPG - $caption_block = $this->iptc_maketag(2, $dat, $value); - $image_string = iptcembed($caption_block, $this->fileName); - file_put_contents('iptc.jpg', $image_string); - } + $caption_block = $this->iptc_maketag(2, $dat, $value); + $image_string = iptcembed($caption_block, $this->fileName); + file_put_contents('iptc.jpg', $image_string); + } ## -------------------------------------------------------- - private function iptc_maketag($rec, $dat, $val) - # Author: Thies C. Arntzen - # Purpose: Function to format the new IPTC text - # Param in: $rec: Application record. (We’re working with #2) - # $dat: Index. (120 for caption, 118 for contact. See the IPTC IIM - # specification: - # http://www.iptc.org/std/IIM/4.1/specification/IIMV4.1.pdf - # $val: Value/data/text. Make sure this is within the length - # constraints of the IPTC IIM specification - # Ref: http://blog.peterhaza.no/working-with-image-meta-data-in-exif-and-iptc-headers-from-php/ - # http://php.net/manual/en/function.iptcembed.php - # - { - $len = strlen($val); - if ($len < 0x8000) - { - return chr(0x1c) . chr($rec) . chr($dat) . - chr($len >> 8) . - chr($len & 0xff) . - $val; - } - else - { - return chr(0x1c) . chr($rec) . chr($dat) . - chr(0x80) . chr(0x04) . - chr(($len >> 24) & 0xff) . - chr(($len >> 16) & 0xff) . - chr(($len >> 8) & 0xff) . - chr(($len) & 0xff) . - $val; - } - } + private function iptc_maketag($rec, $dat, $val) + # Author: Thies C. Arntzen + # Purpose: Function to format the new IPTC text + # Param in: $rec: Application record. (We’re working with #2) + # $dat: Index. (120 for caption, 118 for contact. See the IPTC IIM + # specification: + # http://www.iptc.org/std/IIM/4.1/specification/IIMV4.1.pdf + # $val: Value/data/text. Make sure this is within the length + # constraints of the IPTC IIM specification + # Ref: http://blog.peterhaza.no/working-with-image-meta-data-in-exif-and-iptc-headers-from-php/ + # http://php.net/manual/en/function.iptcembed.php + # + { + $len = strlen($val); + if ($len < 0x8000) + { + return chr(0x1c) . chr($rec) . chr($dat) . + chr($len >> 8) . + chr($len & 0xff) . + $val; + } + else + { + return chr(0x1c) . chr($rec) . chr($dat) . + chr(0x80) . chr(0x04) . + chr(($len >> 24) & 0xff) . + chr(($len >> 16) & 0xff) . + chr(($len >> 8) & 0xff) . + chr(($len) & 0xff) . + $val; + } + } - /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-*-*-*-*-*-*-*-*-*- + /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-*-*-*-*-*-*-*-*-*- Write XMP Data *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-*-*-*-*-*-*-*-*-*/ - //http://xmpphptoolkit.sourceforge.net/ + //http://xmpphptoolkit.sourceforge.net/ - /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-*-*-*-*-*-*-*-*-*- + /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-*-*-*-*-*-*-*-*-*- Add Text *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-*-*-*-*-*-*-*-*-*/ - public function addText($text, $pos = '20x20', $padding = 0, $fontColor = '#fff', $fontSize = 12, $angle = 0, $font = null) - # Author: Jarrod Oberto - # Date: 18-11-09 - # Purpose: Add text to an image - # Param in: - # Param out: - # Reference: http://php.net/manual/en/function.imagettftext.php - # Notes: Make sure you supply the font. - # - { + public function addText($text, $pos = '20x20', $padding = 0, $fontColor = '#fff', $fontSize = 12, $angle = 0, $font = null) + # Author: Jarrod Oberto + # Date: 18-11-09 + # Purpose: Add text to an image + # Param in: + # Param out: + # Reference: http://php.net/manual/en/function.imagettftext.php + # Notes: Make sure you supply the font. + # + { - // *** Convert color - $rgbArray = $this->formatColor($fontColor); - $r = $rgbArray['r']; - $g = $rgbArray['g']; - $b = $rgbArray['b']; + // *** Convert color + $rgbArray = $this->formatColor($fontColor); + $r = $rgbArray['r']; + $g = $rgbArray['g']; + $b = $rgbArray['b']; - // *** Get text font - $font = $this->getTextFont($font); + // *** Get text font + $font = $this->getTextFont($font); - // *** Get text size - $textSizeArray = $this->getTextSize($fontSize, $angle, $font, $text); - $textWidth = $textSizeArray['width']; - $textHeight = $textSizeArray['height']; + // *** Get text size + $textSizeArray = $this->getTextSize($fontSize, $angle, $font, $text); + $textWidth = $textSizeArray['width']; + $textHeight = $textSizeArray['height']; - // *** Find co-ords to place text - $posArray = $this->calculatePosition($pos, $padding, $textWidth, $textHeight, false); - $x = $posArray['width']; - $y = $posArray['height']; + // *** Find co-ords to place text + $posArray = $this->calculatePosition($pos, $padding, $textWidth, $textHeight, false); + $x = $posArray['width']; + $y = $posArray['height']; - $fontColor = imagecolorallocate($this->imageResized, $r, $g, $b); + $fontColor = imagecolorallocate($this->imageResized, $r, $g, $b); - // *** Add text - imagettftext($this->imageResized, $fontSize, $angle, $x, $y, $fontColor, $font, $text); - } + // *** Add text + imagettftext($this->imageResized, $fontSize, $angle, $x, $y, $fontColor, $font, $text); + } - ## -------------------------------------------------------- + ## -------------------------------------------------------- - private function getTextFont($font) - { - // *** Font path (shou - $fontPath = dirname(__FILE__) . '/' . $this->fontDir; + private function getTextFont($font) + { + // *** Font path (shou + $fontPath = dirname(__FILE__) . '/' . $this->fontDir; - // *** The below is/may be needed depending on your version (see ref) - putenv('GDFONTPATH=' . realpath('.')); + // *** The below is/may be needed depending on your version (see ref) + putenv('GDFONTPATH=' . realpath('.')); - // *** Check if the passed in font exsits... - if ($font == null || ! file_exists($font)) - { + // *** Check if the passed in font exsits... + if ($font == null || ! file_exists($font)) + { - // *** ...If not, default to this font. - $font = $fontPath . '/arimo.ttf'; + // *** ...If not, default to this font. + $font = $fontPath . '/arimo.ttf'; - // *** Check our default font exists... - if ( ! file_exists($font)) - { + // *** Check our default font exists... + if ( ! file_exists($font)) + { - // *** If not, return false - if ($this->debug) - { - throw new Exception('Font not found'); - } - else - { - return false; - } - } - } + // *** If not, return false + if ($this->debug) + { + throw new Exception('Font not found'); + } + else + { + return false; + } + } + } - return $font; + return $font; - } + } - ## -------------------------------------------------------- + ## -------------------------------------------------------- - private function getTextSize($fontSize, $angle, $font, $text) - { + private function getTextSize($fontSize, $angle, $font, $text) + { - // *** Define box (so we can get the width) - $box = @imageTTFBbox($fontSize, $angle, $font, $text); + // *** Define box (so we can get the width) + $box = @imageTTFBbox($fontSize, $angle, $font, $text); - // *** Get width of text from dimensions - $textWidth = abs($box[4] - $box[0]); + // *** Get width of text from dimensions + $textWidth = abs($box[4] - $box[0]); - // *** Get height of text from dimensions (should also be same as $fontSize) - $textHeight = abs($box[5] - $box[1]); + // *** Get height of text from dimensions (should also be same as $fontSize) + $textHeight = abs($box[5] - $box[1]); - return array( 'height' => $textHeight, 'width' => $textWidth ); - } + return array( 'height' => $textHeight, 'width' => $textWidth ); + } - /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-*-*-*-*-*-*-*-*-*- + /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-*-*-*-*-*-*-*-*-*- Add Watermark *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-*-*-*-*-*-*-*-*-*/ - public function addWatermark($watermarkImage, $pos, $padding = 0, $opacity = 0) - # Author: Jarrod Oberto - # Date: 18-11-09 - # Purpose: Add watermark image - # Param in: (str) $watermark: The watermark image - # (str) $pos: Could be a pre-determined position such as: - # tl = top left, - # t = top (middle), - # tr = top right, - # l = left, - # m = middle, - # r = right, - # bl = bottom left, - # b = bottom (middle), - # br = bottom right - # Or, it could be a co-ordinate position such as: 50x100 - # - # (int) $padding: If using a pre-determined position you can - # adjust the padding from the edges by passing an amount - # in pixels. If using co-ordinates, this value is ignored. - # Param out: - # Reference: http://www.php.net/manual/en/image.examples-watermark.php - # Notes: Based on example in reference. - # - # - { + public function addWatermark($watermarkImage, $pos, $padding = 0, $opacity = 0) + # Author: Jarrod Oberto + # Date: 18-11-09 + # Purpose: Add watermark image + # Param in: (str) $watermark: The watermark image + # (str) $pos: Could be a pre-determined position such as: + # tl = top left, + # t = top (middle), + # tr = top right, + # l = left, + # m = middle, + # r = right, + # bl = bottom left, + # b = bottom (middle), + # br = bottom right + # Or, it could be a co-ordinate position such as: 50x100 + # + # (int) $padding: If using a pre-determined position you can + # adjust the padding from the edges by passing an amount + # in pixels. If using co-ordinates, this value is ignored. + # Param out: + # Reference: http://www.php.net/manual/en/image.examples-watermark.php + # Notes: Based on example in reference. + # + # + { - // Load the stamp and the photo to apply the watermark to - $stamp = $this->openImage($watermarkImage); # stamp - $im = $this->imageResized; # photo + // Load the stamp and the photo to apply the watermark to + $stamp = $this->openImage($watermarkImage); # stamp + $im = $this->imageResized; # photo - // *** Get stamps width and height - $sx = imagesx($stamp); - $sy = imagesy($stamp); + // *** Get stamps width and height + $sx = imagesx($stamp); + $sy = imagesy($stamp); - // *** Find co-ords to place image - $posArray = $this->calculatePosition($pos, $padding, $sx, $sy); - $x = $posArray['width']; - $y = $posArray['height']; + // *** Find co-ords to place image + $posArray = $this->calculatePosition($pos, $padding, $sx, $sy); + $x = $posArray['width']; + $y = $posArray['height']; - // *** Set watermark opacity - if (fix_strtolower(strrchr($watermarkImage, '.')) == '.png') - { + // *** Set watermark opacity + if (fix_strtolower(strrchr($watermarkImage, '.')) == '.png') + { - $opacity = $this->invertTransparency($opacity, 100); - $this->filterOpacity($stamp, $opacity); - } + $opacity = $this->invertTransparency($opacity, 100); + $this->filterOpacity($stamp, $opacity); + } - // Copy the watermark image onto our photo - imagecopy($im, $stamp, $x, $y, 0, 0, imagesx($stamp), imagesy($stamp)); + // Copy the watermark image onto our photo + imagecopy($im, $stamp, $x, $y, 0, 0, imagesx($stamp), imagesy($stamp)); - } + } - ## -------------------------------------------------------- + ## -------------------------------------------------------- - private function calculatePosition($pos, $padding, $assetWidth, $assetHeight, $upperLeft = true) - # - # Author: Jarrod Oberto - # Date: 08-05-11 - # Purpose: Calculate the x, y pixel cordinates of the asset to place - # Params in: (str) $pos: Either something like: "tl", "l", "br" or an - # exact position like: "100x50" - # (int) $padding: The amount of padding from the edge. Only - # used for the predefined $pos. - # (int) $assetWidth: The width of the asset to add to the image - # (int) $assetHeight: The height of the asset to add to the image - # (bol) $upperLeft: if true, the asset will be positioned based - # on the upper left x, y coords. If false, it means you're - # using the lower left as the basepoint and this will - # convert it to the upper left position - # Params out: - # NOTE: this is done from the UPPER left corner!! But will convert lower - # left basepoints to upper left if $upperleft is set to false - # - # - { - $pos = fix_strtolower($pos); + private function calculatePosition($pos, $padding, $assetWidth, $assetHeight, $upperLeft = true) + # + # Author: Jarrod Oberto + # Date: 08-05-11 + # Purpose: Calculate the x, y pixel cordinates of the asset to place + # Params in: (str) $pos: Either something like: "tl", "l", "br" or an + # exact position like: "100x50" + # (int) $padding: The amount of padding from the edge. Only + # used for the predefined $pos. + # (int) $assetWidth: The width of the asset to add to the image + # (int) $assetHeight: The height of the asset to add to the image + # (bol) $upperLeft: if true, the asset will be positioned based + # on the upper left x, y coords. If false, it means you're + # using the lower left as the basepoint and this will + # convert it to the upper left position + # Params out: + # NOTE: this is done from the UPPER left corner!! But will convert lower + # left basepoints to upper left if $upperleft is set to false + # + # + { + $pos = fix_strtolower($pos); - // *** If co-ords have been entered - if (strstr($pos, 'x')) - { - $pos = str_replace(' ', '', $pos); + // *** If co-ords have been entered + if (strstr($pos, 'x')) + { + $pos = str_replace(' ', '', $pos); - $xyArray = explode('x', $pos); - list($width, $height) = $xyArray; + $xyArray = explode('x', $pos); + list($width, $height) = $xyArray; - } - else - { + } + else + { - switch ($pos) - { - case 'tl': - $width = 0 + $padding; - $height = 0 + $padding; - break; + switch ($pos) + { + case 'tl': + $width = 0 + $padding; + $height = 0 + $padding; + break; - case 't': - $width = ($this->width / 2) - ($assetWidth / 2); - $height = 0 + $padding; - break; + case 't': + $width = ($this->width / 2) - ($assetWidth / 2); + $height = 0 + $padding; + break; - case 'tr': - $width = $this->width - $assetWidth - $padding; - $height = 0 + $padding;; - break; + case 'tr': + $width = $this->width - $assetWidth - $padding; + $height = 0 + $padding;; + break; - case 'l': - $width = 0 + $padding; - $height = ($this->height / 2) - ($assetHeight / 2); - break; + case 'l': + $width = 0 + $padding; + $height = ($this->height / 2) - ($assetHeight / 2); + break; - case 'm': - $width = ($this->width / 2) - ($assetWidth / 2); - $height = ($this->height / 2) - ($assetHeight / 2); - break; + case 'm': + $width = ($this->width / 2) - ($assetWidth / 2); + $height = ($this->height / 2) - ($assetHeight / 2); + break; - case 'r': - $width = $this->width - $assetWidth - $padding; - $height = ($this->height / 2) - ($assetHeight / 2); - break; + case 'r': + $width = $this->width - $assetWidth - $padding; + $height = ($this->height / 2) - ($assetHeight / 2); + break; - case 'bl': - $width = 0 + $padding; - $height = $this->height - $assetHeight - $padding; - break; + case 'bl': + $width = 0 + $padding; + $height = $this->height - $assetHeight - $padding; + break; - case 'b': - $width = ($this->width / 2) - ($assetWidth / 2); - $height = $this->height - $assetHeight - $padding; - break; + case 'b': + $width = ($this->width / 2) - ($assetWidth / 2); + $height = $this->height - $assetHeight - $padding; + break; - case 'br': - $width = $this->width - $assetWidth - $padding; - $height = $this->height - $assetHeight - $padding; - break; + case 'br': + $width = $this->width - $assetWidth - $padding; + $height = $this->height - $assetHeight - $padding; + break; - default: - $width = 0; - $height = 0; - break; - } - } + default: + $width = 0; + $height = 0; + break; + } + } - if ( ! $upperLeft) - { - $height = $height + $assetHeight; - } + if ( ! $upperLeft) + { + $height = $height + $assetHeight; + } - return array( 'width' => $width, 'height' => $height ); - } + return array( 'width' => $width, 'height' => $height ); + } - ## -------------------------------------------------------- + ## -------------------------------------------------------- - private function filterOpacity(&$img, $opacity = 75) - # - # Author: aiden dot mail at freemail dot hu - # Author date: 29-03-08 08:16 - # Date added: 08-05-11 - # Purpose: Change opacity of image - # Params in: $img: Image resource id - # (int) $opacity: the opacity amount: 0-100, 100 being not opaque. - # Params out: (bool) true on success, else false - # Ref: http://www.php.net/manual/en/function.imagefilter.php#82162 - # Notes: png only - # - { + private function filterOpacity(&$img, $opacity = 75) + # + # Author: aiden dot mail at freemail dot hu + # Author date: 29-03-08 08:16 + # Date added: 08-05-11 + # Purpose: Change opacity of image + # Params in: $img: Image resource id + # (int) $opacity: the opacity amount: 0-100, 100 being not opaque. + # Params out: (bool) true on success, else false + # Ref: http://www.php.net/manual/en/function.imagefilter.php#82162 + # Notes: png only + # + { - if ( ! isset($opacity)) - { - return false; - } + if ( ! isset($opacity)) + { + return false; + } - if ($opacity == 100) - { - return true; - } + if ($opacity == 100) + { + return true; + } - $opacity /= 100; + $opacity /= 100; - //get image width and height - $w = imagesx($img); - $h = imagesy($img); + //get image width and height + $w = imagesx($img); + $h = imagesy($img); - //turn alpha blending off - imagealphablending($img, false); + //turn alpha blending off + imagealphablending($img, false); - //find the most opaque pixel in the image (the one with the smallest alpha value) - $minalpha = 127; - for ($x = 0; $x < $w; $x++) - { - for ($y = 0; $y < $h; $y++) - { - $alpha = (imagecolorat($img, $x, $y) >> 24) & 0xFF; - if ($alpha < $minalpha) - { - $minalpha = $alpha; - } - } - } + //find the most opaque pixel in the image (the one with the smallest alpha value) + $minalpha = 127; + for ($x = 0; $x < $w; $x++) + { + for ($y = 0; $y < $h; $y++) + { + $alpha = (imagecolorat($img, $x, $y) >> 24) & 0xFF; + if ($alpha < $minalpha) + { + $minalpha = $alpha; + } + } + } - //loop through image pixels and modify alpha for each - for ($x = 0; $x < $w; $x++) - { - for ($y = 0; $y < $h; $y++) - { - //get current alpha value (represents the TANSPARENCY!) - $colorxy = imagecolorat($img, $x, $y); - $alpha = ($colorxy >> 24) & 0xFF; - //calculate new alpha - if ($minalpha !== 127) - { - $alpha = 127 + 127 * $opacity * ($alpha - 127) / (127 - $minalpha); - } - else - { - $alpha += 127 * $opacity; - } - //get the color index with new alpha - $alphacolorxy = imagecolorallocatealpha($img, ($colorxy >> 16) & 0xFF, ($colorxy >> 8) & 0xFF, $colorxy & 0xFF, $alpha); - //set pixel with the new color + opacity - if ( ! imagesetpixel($img, $x, $y, $alphacolorxy)) - { + //loop through image pixels and modify alpha for each + for ($x = 0; $x < $w; $x++) + { + for ($y = 0; $y < $h; $y++) + { + //get current alpha value (represents the TANSPARENCY!) + $colorxy = imagecolorat($img, $x, $y); + $alpha = ($colorxy >> 24) & 0xFF; + //calculate new alpha + if ($minalpha !== 127) + { + $alpha = 127 + 127 * $opacity * ($alpha - 127) / (127 - $minalpha); + } + else + { + $alpha += 127 * $opacity; + } + //get the color index with new alpha + $alphacolorxy = imagecolorallocatealpha($img, ($colorxy >> 16) & 0xFF, ($colorxy >> 8) & 0xFF, $colorxy & 0xFF, $alpha); + //set pixel with the new color + opacity + if ( ! imagesetpixel($img, $x, $y, $alphacolorxy)) + { - return false; - } - } - } + return false; + } + } + } - return true; - } + return true; + } ## -------------------------------------------------------- - private function openImage($file) - # Author: Jarrod Oberto - # Date: 27-02-08 - # Purpose: - # Param in: - # Param out: n/a - # Reference: - # Notes: - # - { + private function openImage($file) + # Author: Jarrod Oberto + # Date: 27-02-08 + # Purpose: + # Param in: + # Param out: n/a + # Reference: + # Notes: + # + { - if ( ! file_exists($file) && ! $this->checkStringStartsWith('http://', $file) && ! $this->checkStringStartsWith('https://', $file) ) - { - if ($this->debug) - { - throw new Exception('Image not found.'); - } - else - { - throw new Exception(); - } - }; + if ( ! file_exists($file) && ! $this->checkStringStartsWith('http://', $file) && ! $this->checkStringStartsWith('https://', $file) ) + { + if ($this->debug) + { + throw new Exception('Image not found.'); + } + else + { + throw new Exception(); + } + }; - // *** Get extension / image type - $extension = mime_content_type($file); - $extension = fix_strtolower($extension); - $extension = str_replace('image/', '', $extension); - switch ($extension) - { - case 'jpg': - case 'jpeg': - $img = @imagecreatefromjpeg($file); - break; - case 'gif': - $img = @imagecreatefromgif($file); - break; - case 'png': - $img = @imagecreatefrompng($file); - break; - case 'bmp': - $img = @$this->imagecreatefrombmp($file); - break; - case 'psd': - case 'vnd.adobe.photoshop': - $img = @$this->imagecreatefrompsd($file); - break; + // *** Get extension / image type + $extension = mime_content_type($file); + $extension = fix_strtolower($extension); + $extension = str_replace('image/', '', $extension); + switch ($extension) + { + case 'jpg': + case 'jpeg': + $img = @imagecreatefromjpeg($file); + break; + case 'webp': + $img = @imagecreatefromwebp($file); + break; + case 'gif': + $img = @imagecreatefromgif($file); + break; + case 'png': + $img = @imagecreatefrompng($file); + break; + case 'bmp': + case 'x-ms-bmp': + $img = @$this->imagecreatefrombmp($file); + break; + case 'psd': + case 'vnd.adobe.photoshop': + $img = @$this->imagecreatefrompsd($file); + break; - // ... etc + // ... etc - default: - $img = false; - break; - } + default: + $img = false; + break; + } - return $img; - } + return $img; + } ## -------------------------------------------------------- - public function reset() - # - # Author: Jarrod Oberto - # Date: 30-08-11 - # Purpose: Reset the resource (allow further editing) - # Params in: - # Params out: - # Notes: - # - { - $this->__construct($this->fileName); - } + public function reset() + # + # Author: Jarrod Oberto + # Date: 30-08-11 + # Purpose: Reset the resource (allow further editing) + # Params in: + # Params out: + # Notes: + # + { + $this->__construct($this->fileName); + } ## -------------------------------------------------------- - public function saveImage($savePath, $imageQuality = "100") - # Author: Jarrod Oberto - # Date: 27-02-08 - # Purpose: Saves the image - # Param in: $savePath: Where to save the image including filename: - # $imageQuality: image quality you want the image saved at 0-100 - # Param out: n/a - # Reference: - # Notes: * gif doesn't have a quality parameter - # * jpg has a quality setting 0-100 (100 being the best) - # * png has a quality setting 0-9 (0 being the best) - # - # * bmp files have no native support for bmp files. We use a - # third party class to save as bmp. - { + public function saveImage($savePath, $imageQuality = "100") + # Author: Jarrod Oberto + # Date: 27-02-08 + # Purpose: Saves the image + # Param in: $savePath: Where to save the image including filename: + # $imageQuality: image quality you want the image saved at 0-100 + # Param out: n/a + # Reference: + # Notes: * gif doesn't have a quality parameter + # * jpg has a quality setting 0-100 (100 being the best) + # * webp has a quality setting 0-100 (100 being the best) + # * png has a quality setting 0-9 (0 being the best) + # + # * bmp files have no native support for bmp files. We use a + # third party class to save as bmp. + { - // *** Perform a check or two. - if ( ! is_resource($this->imageResized) && !($this->imageResized instanceof \GdImage)) - { - if ($this->debug) - { - throw new Exception('saveImage: This is not a resource.'); - } - else - { - throw new Exception(); - } - } - $fileInfoArray = pathInfo($savePath); - clearstatcache(); - if ( ! is_writable($fileInfoArray['dirname'])) - { - if ($this->debug) - { - throw new Exception('The path is not writable. Please check your permissions.'); - } - else - { - throw new Exception(); - } - } + // *** Perform a check or two. + if (! is_resource($this->imageResized) && ! $this->imageResized instanceof \GdImage) + { + if ($this->debug) + { + throw new Exception('saveImage: This is not a resource.'); + } + else + { + throw new Exception(); + } + } + $fileInfoArray = pathInfo($savePath); + clearstatcache(); + if ( ! is_writable($fileInfoArray['dirname'])) + { + if ($this->debug) + { + throw new Exception('The path is not writable. Please check your permissions.'); + } + else + { + throw new Exception(); + } + } - // *** Get extension - $extension = strrchr($savePath, '.'); - $extension = fix_strtolower($extension); + // *** Get extension + $extension = strrchr($savePath, '.'); + $extension = fix_strtolower($extension); - $error = ''; + $error = ''; - switch ($extension) - { - case '.jpg': - case '.jpeg': - $this->checkInterlaceImage($this->isInterlace); - if (imagetypes() & IMG_JPG) - { - imagejpeg($this->imageResized, $savePath, $imageQuality); - } - else - { - $error = 'jpg'; - } - break; + switch ($extension) + { + case '.jpg': + case '.jpeg': + $this->checkInterlaceImage($this->isInterlace); + if (imagetypes() & IMG_JPG) + { + imagejpeg($this->imageResized, $savePath, $imageQuality); + } + else + { + $error = 'jpg'; + } + break; - case '.gif': - $this->checkInterlaceImage($this->isInterlace); - if (imagetypes() & IMG_GIF) - { - imagegif($this->imageResized, $savePath); - } - else - { - $error = 'gif'; - } - break; + case '.webp': + if (imagetypes() & IMG_WEBP) + { + imagewebp($this->imageResized, $savePath, $imageQuality); + } + else + { + $error = 'webp'; + } + break; - case '.png': - // *** Scale quality from 0-100 to 0-9 - $scaleQuality = round(($imageQuality / 100) * 9); + case '.gif': + $this->checkInterlaceImage($this->isInterlace); + if (imagetypes() & IMG_GIF) + { + imagegif($this->imageResized, $savePath); + } + else + { + $error = 'gif'; + } + break; - // *** Invert qualit setting as 0 is best, not 9 - $invertScaleQuality = 9 - $scaleQuality; + case '.png': + // *** Scale quality from 0-100 to 0-9 + $scaleQuality = round(($imageQuality / 100) * 9); - $this->checkInterlaceImage($this->isInterlace); - if (imagetypes() & IMG_PNG) - { - imagepng($this->imageResized, $savePath, $invertScaleQuality); - } - else - { - $error = 'png'; - } - break; + // *** Invert qualit setting as 0 is best, not 9 + $invertScaleQuality = 9 - $scaleQuality; - case '.bmp': - file_put_contents($savePath, $this->GD2BMPstring($this->imageResized)); - break; + $this->checkInterlaceImage($this->isInterlace); + if (imagetypes() & IMG_PNG) + { + imagepng($this->imageResized, $savePath, $invertScaleQuality); + } + else + { + $error = 'png'; + } + break; + + case '.bmp': + file_put_contents($savePath, $this->GD2BMPstring($this->imageResized)); + break; - // ... etc + // ... etc - default: - // *** No extension - No save. - $this->errorArray[] = 'This file type (' . $extension . ') is not supported. File not saved.'; - break; - } + default: + // *** No extension - No save. + $this->errorArray[] = 'This file type (' . $extension . ') is not supported. File not saved.'; + break; + } - //imagedestroy($this->imageResized); + //imagedestroy($this->imageResized); - // *** Display error if a file type is not supported. - if ($error != '') - { - $this->errorArray[] = $error . ' support is NOT enabled. File not saved.'; - } - } + // *** Display error if a file type is not supported. + if ($error != '') + { + $this->errorArray[] = $error . ' support is NOT enabled. File not saved.'; + } + } ## -------------------------------------------------------- - public function displayImage($fileType = 'jpg', $imageQuality = "100") - # Author: Jarrod Oberto - # Date: 18-11-09 - # Purpose: Display images directly to the browser - # Param in: The image type you want to display - # Param out: - # Reference: - # Notes: - # - { + public function displayImage($fileType = 'jpg', $imageQuality = "100") + # Author: Jarrod Oberto + # Date: 18-11-09 + # Purpose: Display images directly to the browser + # Param in: The image type you want to display + # Param out: + # Reference: + # Notes: + # + { - if ( ! is_resource($this->imageResized) && ! $this->imageResized instanceof \GdImage) - { - if ($this->debug) - { - throw new Exception('saveImage: This is not a resource.'); - } - else - { - throw new Exception(); - } - } + if (! is_resource($this->imageResized) && ! $this->imageResized instanceof \GdImage) + { + if ($this->debug) + { + throw new Exception('saveImage: This is not a resource.'); + } + else + { + throw new Exception(); + } + } - switch ($fileType) - { - case 'jpg': - case 'jpeg': - header('Content-type: image/jpeg'); - imagejpeg($this->imageResized, '', $imageQuality); - break; - case 'gif': - header('Content-type: image/gif'); - imagegif($this->imageResized); - break; - case 'png': - header('Content-type: image/png'); + switch ($fileType) + { + case 'jpg': + case 'jpeg': + header('Content-type: image/jpeg'); + imagejpeg($this->imageResized, '', $imageQuality); + break; + case 'webp': + header('Content-type: image/webp'); + imagewebp($this->imageResized, '', $imageQuality); + break; + case 'gif': + header('Content-type: image/gif'); + imagegif($this->imageResized); + break; + case 'png': + header('Content-type: image/png'); - // *** Scale quality from 0-100 to 0-9 - $scaleQuality = round(($imageQuality / 100) * 9); + // *** Scale quality from 0-100 to 0-9 + $scaleQuality = round(($imageQuality / 100) * 9); - // *** Invert qualit setting as 0 is best, not 9 - $invertScaleQuality = 9 - $scaleQuality; + // *** Invert qualit setting as 0 is best, not 9 + $invertScaleQuality = 9 - $scaleQuality; - imagepng($this->imageResized, '', $invertScaleQuality); - break; - case 'bmp': - echo 'bmp file format is not supported.'; - break; + imagepng($this->imageResized, '', $invertScaleQuality); + break; + case 'bmp': + echo 'bmp file format is not supported.'; + break; - // ... etc + // ... etc - default: - // *** No extension - No save. - break; - } + default: + // *** No extension - No save. + break; + } - //imagedestroy($this->imageResized); - } + //imagedestroy($this->imageResized); + } ## -------------------------------------------------------- - public function setTransparency($bool) - # Sep 2011 - { - $this->keepTransparency = $bool; - } + public function setTransparency($bool) + # Sep 2011 + { + $this->keepTransparency = $bool; + } ## -------------------------------------------------------- - public function setFillColor($value) - # Sep 2011 - # Param in: (mixed) $value: (array) Could be an array of RGB - # (str) Could be hex #ffffff or #fff, fff, ffffff - # - # If the keepTransparency is set to false, then no transparency is to be used. - # This is ideal when you want to save as jpg. - # - # this method allows you to set the background color to use instead of - # transparency. - # - { - $colorArray = $this->formatColor($value); - $this->fillColorArray = $colorArray; - } + public function setFillColor($value) + # Sep 2011 + # Param in: (mixed) $value: (array) Could be an array of RGB + # (str) Could be hex #ffffff or #fff, fff, ffffff + # + # If the keepTransparency is set to false, then no transparency is to be used. + # This is ideal when you want to save as jpg. + # + # this method allows you to set the background color to use instead of + # transparency. + # + { + $colorArray = $this->formatColor($value); + $this->fillColorArray = $colorArray; + } ## -------------------------------------------------------- - public function setCropFromTop($value) - # Sep 2011 - { - $this->cropFromTopPercent = $value; - } + public function setCropFromTop($value) + # Sep 2011 + { + $this->cropFromTopPercent = $value; + } ## -------------------------------------------------------- - public function testGDInstalled() - # Author: Jarrod Oberto - # Date: 27-02-08 - # Purpose: Test to see if GD is installed - # Param in: n/a - # Param out: (bool) True is gd extension loaded otherwise false - # Reference: - # Notes: - # - { - if (extension_loaded('gd') && function_exists('gd_info')) - { - $gdInstalled = true; - } - else - { - $gdInstalled = false; - } + public function testGDInstalled() + # Author: Jarrod Oberto + # Date: 27-02-08 + # Purpose: Test to see if GD is installed + # Param in: n/a + # Param out: (bool) True is gd extension loaded otherwise false + # Reference: + # Notes: + # + { + if (extension_loaded('gd') && function_exists('gd_info')) + { + $gdInstalled = true; + } + else + { + $gdInstalled = false; + } - return $gdInstalled; - } + return $gdInstalled; + } ## -------------------------------------------------------- - public function testEXIFInstalled() - # Author: Jarrod Oberto - # Date: 08-05-11 - # Purpose: Test to see if EXIF is installed - # Param in: n/a - # Param out: (bool) True is exif extension loaded otherwise false - # Reference: - # Notes: - # - { - if (extension_loaded('exif')) - { - $exifInstalled = true; - } - else - { - $exifInstalled = false; - } + public function testEXIFInstalled() + # Author: Jarrod Oberto + # Date: 08-05-11 + # Purpose: Test to see if EXIF is installed + # Param in: n/a + # Param out: (bool) True is exif extension loaded otherwise false + # Reference: + # Notes: + # + { + if (extension_loaded('exif')) + { + $exifInstalled = true; + } + else + { + $exifInstalled = false; + } - return $exifInstalled; - } + return $exifInstalled; + } ## -------------------------------------------------------- - public function testIsImage($image) - # Author: Jarrod Oberto - # Date: 27-02-08 - # Purpose: Test if file is an image - # Param in: n/a - # Param out: n/a - # Reference: - # Notes: - # - { - if ($image) - { - $fileIsImage = true; - } - else - { - $fileIsImage = false; - } + public function testIsImage($image) + # Author: Jarrod Oberto + # Date: 27-02-08 + # Purpose: Test if file is an image + # Param in: n/a + # Param out: n/a + # Reference: + # Notes: + # + { + if ($image) + { + $fileIsImage = true; + } + else + { + $fileIsImage = false; + } - return $fileIsImage; - } + return $fileIsImage; + } ## -------------------------------------------------------- - public function testFunct() - # Author: Jarrod Oberto - # Date: 27-02-08 - # Purpose: Test Function - # Param in: n/a - # Param out: n/a - # Reference: - # Notes: - # - { - echo $this->height; - } + public function testFunct() + # Author: Jarrod Oberto + # Date: 27-02-08 + # Purpose: Test Function + # Param in: n/a + # Param out: n/a + # Reference: + # Notes: + # + { + echo $this->height; + } ## -------------------------------------------------------- - public function setForceStretch($value) - # Author: Jarrod Oberto - # Date: 23-12-10 - # Purpose: - # Param in: (bool) $value - # Param out: n/a - # Reference: - # Notes: - # - { - $this->forceStretch = $value; - } + public function setForceStretch($value) + # Author: Jarrod Oberto + # Date: 23-12-10 + # Purpose: + # Param in: (bool) $value + # Param out: n/a + # Reference: + # Notes: + # + { + $this->forceStretch = $value; + } ## -------------------------------------------------------- - public function setFile($fileName) - # Author: Jarrod Oberto - # Date: 28-02-08 - # Purpose: - # Param in: n/a - # Param out: n/a - # Reference: - # Notes: - # - { - self::__construct($fileName); - } + public function setFile($fileName) + # Author: Jarrod Oberto + # Date: 28-02-08 + # Purpose: + # Param in: n/a + # Param out: n/a + # Reference: + # Notes: + # + { + self::__construct($fileName); + } ## -------------------------------------------------------- - public function getFileName() - # Author: Jarrod Oberto - # Date: 10-09-08 - # Purpose: - # Param in: n/a - # Param out: n/a - # Reference: - # Notes: - # - { - return $this->fileName; - } + public function getFileName() + # Author: Jarrod Oberto + # Date: 10-09-08 + # Purpose: + # Param in: n/a + # Param out: n/a + # Reference: + # Notes: + # + { + return $this->fileName; + } ## -------------------------------------------------------- - public function getHeight() - { - return $this->height; - } + public function getHeight() + { + return $this->height; + } ## -------------------------------------------------------- - public function getWidth() - { - return $this->width; - } + public function getWidth() + { + return $this->width; + } ## -------------------------------------------------------- - public function getOriginalHeight() - { - return $this->heightOriginal; - } + public function getOriginalHeight() + { + return $this->heightOriginal; + } ## -------------------------------------------------------- - public function getOriginalWidth() - { - return $this->widthOriginal; - } + public function getOriginalWidth() + { + return $this->widthOriginal; + } ## -------------------------------------------------------- - public function getErrors() - # Author: Jarrod Oberto - # Date: 19-11-09 - # Purpose: Returns the error array - # Param in: n/a - # Param out: Array of errors - # Reference: - # Notes: - # - { - return $this->errorArray; - } + public function getErrors() + # Author: Jarrod Oberto + # Date: 19-11-09 + # Purpose: Returns the error array + # Param in: n/a + # Param out: Array of errors + # Reference: + # Notes: + # + { + return $this->errorArray; + } ## -------------------------------------------------------- - private function checkInterlaceImage($isEnabled) - # jpg will use progressive (they don't use interace) - { - if ($isEnabled) - { - imageinterlace($this->imageResized, $isEnabled); - } - } + private function checkInterlaceImage($isEnabled) + # jpg will use progressive (they don't use interace) + { + if ($isEnabled) + { + imageinterlace($this->imageResized, $isEnabled); + } + } ## -------------------------------------------------------- - protected function formatColor($value) - # Author: Jarrod Oberto - # Date: 09-05-11 - # Purpose: Determine color method passed in and return color as RGB - # Param in: (mixed) $value: (array) Could be an array of RGB - # (str) Could be hex #ffffff or #fff, fff, ffffff - # Param out: - # Reference: - # Notes: - # - { - $rgbArray = array(); + protected function formatColor($value) + # Author: Jarrod Oberto + # Date: 09-05-11 + # Purpose: Determine color method passed in and return color as RGB + # Param in: (mixed) $value: (array) Could be an array of RGB + # (str) Could be hex #ffffff or #fff, fff, ffffff + # Param out: + # Reference: + # Notes: + # + { + $rgbArray = array(); - // *** If it's an array it should be R, G, B - if (is_array($value)) - { + // *** If it's an array it should be R, G, B + if (is_array($value)) + { - if (key($value) == 0 && count($value) == 3) - { + if (key($value) == 0 && count($value) == 3) + { - $rgbArray['r'] = $value[0]; - $rgbArray['g'] = $value[1]; - $rgbArray['b'] = $value[2]; + $rgbArray['r'] = $value[0]; + $rgbArray['g'] = $value[1]; + $rgbArray['b'] = $value[2]; - } - else - { - $rgbArray = $value; - } - } - else - { - if (fix_strtolower($value) == 'transparent') - { + } + else + { + $rgbArray = $value; + } + } + else + { + if (fix_strtolower($value) == 'transparent') + { - $rgbArray = array( - 'r' => 255, - 'g' => 255, - 'b' => 255, - 'a' => 127 - ); + $rgbArray = array( + 'r' => 255, + 'g' => 255, + 'b' => 255, + 'a' => 127 + ); - } - else - { + } + else + { - // *** ...Else it should be hex. Let's make it RGB - $rgbArray = $this->hex2dec($value); - } - } + // *** ...Else it should be hex. Let's make it RGB + $rgbArray = $this->hex2dec($value); + } + } - return $rgbArray; - } + return $rgbArray; + } - ## -------------------------------------------------------- + ## -------------------------------------------------------- - function hex2dec($hex) - # Purpose: Convert #hex color to RGB - { - $color = str_replace('#', '', $hex); + function hex2dec($hex) + # Purpose: Convert #hex color to RGB + { + $color = str_replace('#', '', $hex); - if (strlen($color) == 3) - { - $color = $color . $color; - } + if (strlen($color) == 3) + { + $color = $color . $color; + } - $rgb = array( - 'r' => hexdec(substr($color, 0, 2)), - 'g' => hexdec(substr($color, 2, 2)), - 'b' => hexdec(substr($color, 4, 2)), - 'a' => 0 - ); + $rgb = array( + 'r' => hexdec(substr($color, 0, 2)), + 'g' => hexdec(substr($color, 2, 2)), + 'b' => hexdec(substr($color, 4, 2)), + 'a' => 0 + ); - return $rgb; - } + return $rgb; + } - ## -------------------------------------------------------- + ## -------------------------------------------------------- - private function createImageColor($colorArray) - { - $r = $colorArray['r']; - $g = $colorArray['g']; - $b = $colorArray['b']; + private function createImageColor($colorArray) + { + $r = $colorArray['r']; + $g = $colorArray['g']; + $b = $colorArray['b']; - return imagecolorallocate($this->imageResized, $r, $g, $b); - } + return imagecolorallocate($this->imageResized, $r, $g, $b); + } - ## -------------------------------------------------------- + ## -------------------------------------------------------- - private function testColorExists($colorArray) - { - $r = $colorArray['r']; - $g = $colorArray['g']; - $b = $colorArray['b']; + private function testColorExists($colorArray) + { + $r = $colorArray['r']; + $g = $colorArray['g']; + $b = $colorArray['b']; - if (imagecolorexact($this->imageResized, $r, $g, $b) == -1) - { - return false; - } - else - { - return true; - } - } + if (imagecolorexact($this->imageResized, $r, $g, $b) == -1) + { + return false; + } + else + { + return true; + } + } - ## -------------------------------------------------------- + ## -------------------------------------------------------- - private function findUnusedGreen() - # Purpose: We find a green color suitable to use like green-screen effect. - # Therefore, the color must not exist in the image. - { - $green = 255; + private function findUnusedGreen() + # Purpose: We find a green color suitable to use like green-screen effect. + # Therefore, the color must not exist in the image. + { + $green = 255; - do - { + do + { - $greenChroma = array( 0, $green, 0 ); - $colorArray = $this->formatColor($greenChroma); - $match = $this->testColorExists($colorArray); - $green--; + $greenChroma = array( 0, $green, 0 ); + $colorArray = $this->formatColor($greenChroma); + $match = $this->testColorExists($colorArray); + $green--; - } while ($match == false && $green > 0); + } while ($match == false && $green > 0); - // *** If no match, just bite the bullet and use green value of 255 - if ( ! $match) - { - $greenChroma = array( 0, $green, 0 ); - } + // *** If no match, just bite the bullet and use green value of 255 + if ( ! $match) + { + $greenChroma = array( 0, $green, 0 ); + } - return $greenChroma; - } + return $greenChroma; + } - ## -------------------------------------------------------- + ## -------------------------------------------------------- - private function findUnusedBlue() - # Purpose: We find a green color suitable to use like green-screen effect. - # Therefore, the color must not exist in the image. - { - $blue = 255; + private function findUnusedBlue() + # Purpose: We find a green color suitable to use like green-screen effect. + # Therefore, the color must not exist in the image. + { + $blue = 255; - do - { + do + { - $blueChroma = array( 0, 0, $blue ); - $colorArray = $this->formatColor($blueChroma); - $match = $this->testColorExists($colorArray); - $blue--; + $blueChroma = array( 0, 0, $blue ); + $colorArray = $this->formatColor($blueChroma); + $match = $this->testColorExists($colorArray); + $blue--; - } while ($match == false && $blue > 0); + } while ($match == false && $blue > 0); - // *** If no match, just bite the bullet and use blue value of 255 - if ( ! $match) - { - $blueChroma = array( 0, 0, $blue ); - } + // *** If no match, just bite the bullet and use blue value of 255 + if ( ! $match) + { + $blueChroma = array( 0, 0, $blue ); + } - return $blueChroma; - } + return $blueChroma; + } - ## -------------------------------------------------------- + ## -------------------------------------------------------- - private function invertTransparency($value, $originalMax, $invert = true) - # Purpose: This does two things: - # 1) Convert the range from 0-127 to 0-100 - # 2) Inverts value to 100 is not transparent while 0 is fully - # transparent (like Photoshop) - { - // *** Test max range - if ($value > $originalMax) - { - $value = $originalMax; - } + private function invertTransparency($value, $originalMax, $invert = true) + # Purpose: This does two things: + # 1) Convert the range from 0-127 to 0-100 + # 2) Inverts value to 100 is not transparent while 0 is fully + # transparent (like Photoshop) + { + // *** Test max range + if ($value > $originalMax) + { + $value = $originalMax; + } - // *** Test min range - if ($value < 0) - { - $value = 0; - } + // *** Test min range + if ($value < 0) + { + $value = 0; + } - if ($invert) - { - return $originalMax - (($value / 100) * $originalMax); - } - else - { - return ($value / 100) * $originalMax; - } - } + if ($invert) + { + return $originalMax - (($value / 100) * $originalMax); + } + else + { + return ($value / 100) * $originalMax; + } + } - ## -------------------------------------------------------- + ## -------------------------------------------------------- - private function transparentImage($src) - { - // *** making images with white bg transparent - $r1 = 0; - $g1 = 255; - $b1 = 0; - for ($x = 0; $x < imagesx($src); ++$x) - { - for ($y = 0; $y < imagesy($src); ++$y) - { - $color = imagecolorat($src, $x, $y); - $r = ($color >> 16) & 0xFF; - $g = ($color >> 8) & 0xFF; - $b = $color & 0xFF; - for ($i = 0; $i < 270; $i++) - { - //if ($r . $g . $b == ($r1 + $i) . ($g1 + $i) . ($b1 + $i)) { - if ($r == 0 && $g == 255 && $b == 0) - { - //if ($g == 255) { - $trans_colour = imagecolorallocatealpha($src, 0, 0, 0, 127); - imagefill($src, $x, $y, $trans_colour); - } - } - } - } + private function transparentImage($src) + { + // *** making images with white bg transparent + $r1 = 0; + $g1 = 255; + $b1 = 0; + for ($x = 0; $x < imagesx($src); ++$x) + { + for ($y = 0; $y < imagesy($src); ++$y) + { + $color = imagecolorat($src, $x, $y); + $r = ($color >> 16) & 0xFF; + $g = ($color >> 8) & 0xFF; + $b = $color & 0xFF; + for ($i = 0; $i < 270; $i++) + { + //if ($r . $g . $b == ($r1 + $i) . ($g1 + $i) . ($b1 + $i)) { + if ($r == 0 && $g == 255 && $b == 0) + { + //if ($g == 255) { + $trans_colour = imagecolorallocatealpha($src, 0, 0, 0, 127); + imagefill($src, $x, $y, $trans_colour); + } + } + } + } - return $src; - } + return $src; + } - ## -------------------------------------------------------- + ## -------------------------------------------------------- - function checkStringStartsWith($needle, $haystack) - # Check if a string starts with a specific pattern - { - return (substr($haystack, 0, strlen($needle)) == $needle); - } + function checkStringStartsWith($needle, $haystack) + # Check if a string starts with a specific pattern + { + return (substr($haystack, 0, strlen($needle)) == $needle); + } - /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-*-*-*-*-*-*-*-*-*- + /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-*-*-*-*-*-*-*-*-*- BMP SUPPORT (SAVING) - James Heinrich *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-*-*-*-*-*-*-*-*-*/ - private function GD2BMPstring(&$gd_image) - # Author: James Heinrich - # Purpose: Save file as type bmp - # Param in: The image canvas (passed as ref) - # Param out: - # Reference: - # Notes: This code was stripped out of two external files - # (phpthumb.bmp.php,phpthumb.functions.php) and added below to - # avoid dependancies. - # - { - $imageX = ImageSX($gd_image); - $imageY = ImageSY($gd_image); + private function GD2BMPstring(&$gd_image) + # Author: James Heinrich + # Purpose: Save file as type bmp + # Param in: The image canvas (passed as ref) + # Param out: + # Reference: + # Notes: This code was stripped out of two external files + # (phpthumb.bmp.php,phpthumb.functions.php) and added below to + # avoid dependancies. + # + { + $imageX = ImageSX($gd_image); + $imageY = ImageSY($gd_image); - $BMP = ''; - for ($y = ($imageY - 1); $y >= 0; $y--) - { - $thisline = ''; - for ($x = 0; $x < $imageX; $x++) - { - $argb = $this->GetPixelColor($gd_image, $x, $y); - $thisline .= chr($argb['blue']) . chr($argb['green']) . chr($argb['red']); - } - while (strlen($thisline) % 4) - { - $thisline .= "\x00"; - } - $BMP .= $thisline; - } + $BMP = ''; + for ($y = ($imageY - 1); $y >= 0; $y--) + { + $thisline = ''; + for ($x = 0; $x < $imageX; $x++) + { + $argb = $this->GetPixelColor($gd_image, $x, $y); + $thisline .= chr($argb['blue']) . chr($argb['green']) . chr($argb['red']); + } + while (strlen($thisline) % 4) + { + $thisline .= "\x00"; + } + $BMP .= $thisline; + } - $bmpSize = strlen($BMP) + 14 + 40; - // BITMAPFILEHEADER [14 bytes] - http://msdn.microsoft.com/library/en-us/gdi/bitmaps_62uq.asp - $BITMAPFILEHEADER = 'BM'; // WORD bfType; - $BITMAPFILEHEADER .= $this->LittleEndian2String($bmpSize, 4); // DWORD bfSize; - $BITMAPFILEHEADER .= $this->LittleEndian2String(0, 2); // WORD bfReserved1; - $BITMAPFILEHEADER .= $this->LittleEndian2String(0, 2); // WORD bfReserved2; - $BITMAPFILEHEADER .= $this->LittleEndian2String(54, 4); // DWORD bfOffBits; + $bmpSize = strlen($BMP) + 14 + 40; + // BITMAPFILEHEADER [14 bytes] - http://msdn.microsoft.com/library/en-us/gdi/bitmaps_62uq.asp + $BITMAPFILEHEADER = 'BM'; // WORD bfType; + $BITMAPFILEHEADER .= $this->LittleEndian2String($bmpSize, 4); // DWORD bfSize; + $BITMAPFILEHEADER .= $this->LittleEndian2String(0, 2); // WORD bfReserved1; + $BITMAPFILEHEADER .= $this->LittleEndian2String(0, 2); // WORD bfReserved2; + $BITMAPFILEHEADER .= $this->LittleEndian2String(54, 4); // DWORD bfOffBits; - // BITMAPINFOHEADER - [40 bytes] http://msdn.microsoft.com/library/en-us/gdi/bitmaps_1rw2.asp - $BITMAPINFOHEADER = $this->LittleEndian2String(40, 4); // DWORD biSize; - $BITMAPINFOHEADER .= $this->LittleEndian2String($imageX, 4); // LONG biWidth; - $BITMAPINFOHEADER .= $this->LittleEndian2String($imageY, 4); // LONG biHeight; - $BITMAPINFOHEADER .= $this->LittleEndian2String(1, 2); // WORD biPlanes; - $BITMAPINFOHEADER .= $this->LittleEndian2String(24, 2); // WORD biBitCount; - $BITMAPINFOHEADER .= $this->LittleEndian2String(0, 4); // DWORD biCompression; - $BITMAPINFOHEADER .= $this->LittleEndian2String(0, 4); // DWORD biSizeImage; - $BITMAPINFOHEADER .= $this->LittleEndian2String(2835, 4); // LONG biXPelsPerMeter; - $BITMAPINFOHEADER .= $this->LittleEndian2String(2835, 4); // LONG biYPelsPerMeter; - $BITMAPINFOHEADER .= $this->LittleEndian2String(0, 4); // DWORD biClrUsed; - $BITMAPINFOHEADER .= $this->LittleEndian2String(0, 4); // DWORD biClrImportant; + // BITMAPINFOHEADER - [40 bytes] http://msdn.microsoft.com/library/en-us/gdi/bitmaps_1rw2.asp + $BITMAPINFOHEADER = $this->LittleEndian2String(40, 4); // DWORD biSize; + $BITMAPINFOHEADER .= $this->LittleEndian2String($imageX, 4); // LONG biWidth; + $BITMAPINFOHEADER .= $this->LittleEndian2String($imageY, 4); // LONG biHeight; + $BITMAPINFOHEADER .= $this->LittleEndian2String(1, 2); // WORD biPlanes; + $BITMAPINFOHEADER .= $this->LittleEndian2String(24, 2); // WORD biBitCount; + $BITMAPINFOHEADER .= $this->LittleEndian2String(0, 4); // DWORD biCompression; + $BITMAPINFOHEADER .= $this->LittleEndian2String(0, 4); // DWORD biSizeImage; + $BITMAPINFOHEADER .= $this->LittleEndian2String(2835, 4); // LONG biXPelsPerMeter; + $BITMAPINFOHEADER .= $this->LittleEndian2String(2835, 4); // LONG biYPelsPerMeter; + $BITMAPINFOHEADER .= $this->LittleEndian2String(0, 4); // DWORD biClrUsed; + $BITMAPINFOHEADER .= $this->LittleEndian2String(0, 4); // DWORD biClrImportant; - return $BITMAPFILEHEADER . $BITMAPINFOHEADER . $BMP; - } + return $BITMAPFILEHEADER . $BITMAPINFOHEADER . $BMP; + } ## -------------------------------------------------------- - private function GetPixelColor(&$img, $x, $y) - # Author: James Heinrich - # Purpose: - # Param in: - # Param out: - # Reference: - # Notes: - # - { - if ( ! is_resource($img) && ! $img instanceof \GdImage) - { - return false; - } + private function GetPixelColor(&$img, $x, $y) + # Author: James Heinrich + # Purpose: + # Param in: + # Param out: + # Reference: + # Notes: + # + { + if (! is_resource($img) && ! $img instanceof \GdImage) + { + return false; + } - return @ImageColorsForIndex($img, @ImageColorAt($img, $x, $y)); - } + return @ImageColorsForIndex($img, @ImageColorAt($img, $x, $y)); + } ## -------------------------------------------------------- - private function LittleEndian2String($number, $minbytes = 1) - # Author: James Heinrich - # Purpose: BMP SUPPORT (SAVING) - # Param in: - # Param out: - # Reference: - # Notes: - # - { - $intstring = ''; - while ($number > 0) - { - $intstring = $intstring . chr($number & 255); - $number >>= 8; - } + private function LittleEndian2String($number, $minbytes = 1) + # Author: James Heinrich + # Purpose: BMP SUPPORT (SAVING) + # Param in: + # Param out: + # Reference: + # Notes: + # + { + $intstring = ''; + while ($number > 0) + { + $intstring = $intstring . chr($number & 255); + $number >>= 8; + } - return str_pad($intstring, $minbytes, "\x00", STR_PAD_RIGHT); - } + return str_pad($intstring, $minbytes, "\x00", STR_PAD_RIGHT); + } - /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-*-*-*-*-*-*-*-*-*- + /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-*-*-*-*-*-*-*-*-*- BMP SUPPORT (READING) *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-*-*-*-*-*-*-*-*-*/ - private function ImageCreateFromBMP($filename) - # Author: DHKold - # Date: The 15th of June 2005 - # Version: 2.0B - # Purpose: To create an image from a BMP file. - # Param in: BMP file to open. - # Param out: Return a resource like the other ImageCreateFrom functions - # Reference: http://us3.php.net/manual/en/function.imagecreate.php#53879 - # Bug fix: Author: domelca at terra dot es - # Date: 06 March 2008 - # Fix: Correct 16bit BMP support - # Notes: - # - { + private function ImageCreateFromBMP($filename) + # Author: DHKold + # Date: The 15th of June 2005 + # Version: 2.0B + # Purpose: To create an image from a BMP file. + # Param in: BMP file to open. + # Param out: Return a resource like the other ImageCreateFrom functions + # Reference: http://us3.php.net/manual/en/function.imagecreate.php#53879 + # Bug fix: Author: domelca at terra dot es + # Date: 06 March 2008 + # Fix: Correct 16bit BMP support + # Notes: + # + { - //Ouverture du fichier en mode binaire - if ( ! $f1 = fopen($filename, "rb")) - { - return false; - } + //Ouverture du fichier en mode binaire + if ( ! $f1 = fopen($filename, "rb")) + { + return false; + } - //1 : Chargement des ent�tes FICHIER - $FILE = unpack("vfile_type/Vfile_size/Vreserved/Vbitmap_offset", fread($f1, 14)); - if ($FILE['file_type'] != 19778) - { - return false; - } + //1 : Chargement des ent�tes FICHIER + $FILE = unpack("vfile_type/Vfile_size/Vreserved/Vbitmap_offset", fread($f1, 14)); + if ($FILE['file_type'] != 19778) + { + return false; + } - //2 : Chargement des ent�tes BMP - $BMP = unpack('Vheader_size/Vwidth/Vheight/vplanes/vbits_per_pixel' . - '/Vcompression/Vsize_bitmap/Vhoriz_resolution' . - '/Vvert_resolution/Vcolors_used/Vcolors_important', fread($f1, 40)); - $BMP['colors'] = pow(2, $BMP['bits_per_pixel']); + //2 : Chargement des ent�tes BMP + $BMP = unpack('Vheader_size/Vwidth/Vheight/vplanes/vbits_per_pixel' . + '/Vcompression/Vsize_bitmap/Vhoriz_resolution' . + '/Vvert_resolution/Vcolors_used/Vcolors_important', fread($f1, 40)); + $BMP['colors'] = pow(2, $BMP['bits_per_pixel']); - if ($BMP['size_bitmap'] == 0) - { - $BMP['size_bitmap'] = $FILE['file_size'] - $FILE['bitmap_offset']; - } + if ($BMP['size_bitmap'] == 0) + { + $BMP['size_bitmap'] = $FILE['file_size'] - $FILE['bitmap_offset']; + } - $BMP['bytes_per_pixel'] = $BMP['bits_per_pixel'] / 8; - $BMP['bytes_per_pixel2'] = ceil($BMP['bytes_per_pixel']); - $BMP['decal'] = ($BMP['width'] * $BMP['bytes_per_pixel'] / 4); - $BMP['decal'] -= floor($BMP['width'] * $BMP['bytes_per_pixel'] / 4); - $BMP['decal'] = 4 - (4 * $BMP['decal']); + $BMP['bytes_per_pixel'] = $BMP['bits_per_pixel'] / 8; + $BMP['bytes_per_pixel2'] = ceil($BMP['bytes_per_pixel']); + $BMP['decal'] = ($BMP['width'] * $BMP['bytes_per_pixel'] / 4); + $BMP['decal'] -= floor($BMP['width'] * $BMP['bytes_per_pixel'] / 4); + $BMP['decal'] = 4 - (4 * $BMP['decal']); - if ($BMP['decal'] == 4) - { - $BMP['decal'] = 0; - } + if ($BMP['decal'] == 4) + { + $BMP['decal'] = 0; + } - //3 : Chargement des couleurs de la palette - $PALETTE = array(); - if ($BMP['colors'] < 16777216) - { - $PALETTE = unpack('V' . $BMP['colors'], fread($f1, $BMP['colors'] * 4)); - } + //3 : Chargement des couleurs de la palette + $PALETTE = array(); + if ($BMP['colors'] < 16777216) + { + $PALETTE = unpack('V' . $BMP['colors'], fread($f1, $BMP['colors'] * 4)); + } - //4 : Cr�ation de l'image - $IMG = fread($f1, $BMP['size_bitmap']); - $VIDE = chr(0); + //4 : Cr�ation de l'image + $IMG = fread($f1, $BMP['size_bitmap']); + $VIDE = chr(0); - $res = imagecreatetruecolor($BMP['width'], $BMP['height']); - $P = 0; - $Y = $BMP['height'] - 1; - while ($Y >= 0) - { - $X = 0; - while ($X < $BMP['width']) - { - if ($BMP['bits_per_pixel'] == 24) - { - $COLOR = unpack("V", substr($IMG, $P, 3) . $VIDE); - } - elseif ($BMP['bits_per_pixel'] == 16) - { + $res = imagecreatetruecolor($BMP['width'], $BMP['height']); + $P = 0; + $Y = $BMP['height'] - 1; + while ($Y >= 0) + { + $X = 0; + while ($X < $BMP['width']) + { + if ($BMP['bits_per_pixel'] == 24) + { + $COLOR = unpack("V", substr($IMG, $P, 3) . $VIDE); + } + elseif ($BMP['bits_per_pixel'] == 16) + { - /* + /* * BMP 16bit fix * ================= * @@ -3591,138 +3610,138 @@ class imageLib { * */ - // *** Original code (don't work) - //$COLOR = unpack("n",substr($IMG,$P,2)); - //$COLOR[1] = $PALETTE[$COLOR[1]+1]; + // *** Original code (don't work) + //$COLOR = unpack("n",substr($IMG,$P,2)); + //$COLOR[1] = $PALETTE[$COLOR[1]+1]; - $COLOR = unpack("v", substr($IMG, $P, 2)); - $blue = ($COLOR[1] & 0x001f) << 3; - $green = ($COLOR[1] & 0x07e0) >> 3; - $red = ($COLOR[1] & 0xf800) >> 8; - $COLOR[1] = $red * 65536 + $green * 256 + $blue; + $COLOR = unpack("v", substr($IMG, $P, 2)); + $blue = ($COLOR[1] & 0x001f) << 3; + $green = ($COLOR[1] & 0x07e0) >> 3; + $red = ($COLOR[1] & 0xf800) >> 8; + $COLOR[1] = $red * 65536 + $green * 256 + $blue; - } - elseif ($BMP['bits_per_pixel'] == 8) - { - $COLOR = unpack("n", $VIDE . substr($IMG, $P, 1)); - $COLOR[1] = $PALETTE[ $COLOR[1] + 1 ]; - } - elseif ($BMP['bits_per_pixel'] == 4) - { - $COLOR = unpack("n", $VIDE . substr($IMG, floor($P), 1)); - if (($P * 2) % 2 == 0) - { - $COLOR[1] = ($COLOR[1] >> 4); - } - else - { - $COLOR[1] = ($COLOR[1] & 0x0F); - } - $COLOR[1] = $PALETTE[ $COLOR[1] + 1 ]; - } - elseif ($BMP['bits_per_pixel'] == 1) - { - $COLOR = unpack("n", $VIDE . substr($IMG, floor($P), 1)); - if (($P * 8) % 8 == 0) - { - $COLOR[1] = $COLOR[1] >> 7; - } - elseif (($P * 8) % 8 == 1) - { - $COLOR[1] = ($COLOR[1] & 0x40) >> 6; - } - elseif (($P * 8) % 8 == 2) - { - $COLOR[1] = ($COLOR[1] & 0x20) >> 5; - } - elseif (($P * 8) % 8 == 3) - { - $COLOR[1] = ($COLOR[1] & 0x10) >> 4; - } - elseif (($P * 8) % 8 == 4) - { - $COLOR[1] = ($COLOR[1] & 0x8) >> 3; - } - elseif (($P * 8) % 8 == 5) - { - $COLOR[1] = ($COLOR[1] & 0x4) >> 2; - } - elseif (($P * 8) % 8 == 6) - { - $COLOR[1] = ($COLOR[1] & 0x2) >> 1; - } - elseif (($P * 8) % 8 == 7) - { - $COLOR[1] = ($COLOR[1] & 0x1); - } - $COLOR[1] = $PALETTE[ $COLOR[1] + 1 ]; - } - else - { - return false; - } + } + elseif ($BMP['bits_per_pixel'] == 8) + { + $COLOR = unpack("n", $VIDE . substr($IMG, $P, 1)); + $COLOR[1] = $PALETTE[ $COLOR[1] + 1 ]; + } + elseif ($BMP['bits_per_pixel'] == 4) + { + $COLOR = unpack("n", $VIDE . substr($IMG, floor($P), 1)); + if (($P * 2) % 2 == 0) + { + $COLOR[1] = ($COLOR[1] >> 4); + } + else + { + $COLOR[1] = ($COLOR[1] & 0x0F); + } + $COLOR[1] = $PALETTE[ $COLOR[1] + 1 ]; + } + elseif ($BMP['bits_per_pixel'] == 1) + { + $COLOR = unpack("n", $VIDE . substr($IMG, floor($P), 1)); + if (($P * 8) % 8 == 0) + { + $COLOR[1] = $COLOR[1] >> 7; + } + elseif (($P * 8) % 8 == 1) + { + $COLOR[1] = ($COLOR[1] & 0x40) >> 6; + } + elseif (($P * 8) % 8 == 2) + { + $COLOR[1] = ($COLOR[1] & 0x20) >> 5; + } + elseif (($P * 8) % 8 == 3) + { + $COLOR[1] = ($COLOR[1] & 0x10) >> 4; + } + elseif (($P * 8) % 8 == 4) + { + $COLOR[1] = ($COLOR[1] & 0x8) >> 3; + } + elseif (($P * 8) % 8 == 5) + { + $COLOR[1] = ($COLOR[1] & 0x4) >> 2; + } + elseif (($P * 8) % 8 == 6) + { + $COLOR[1] = ($COLOR[1] & 0x2) >> 1; + } + elseif (($P * 8) % 8 == 7) + { + $COLOR[1] = ($COLOR[1] & 0x1); + } + $COLOR[1] = $PALETTE[ $COLOR[1] + 1 ]; + } + else + { + return false; + } - imagesetpixel($res, $X, $Y, $COLOR[1]); - $X++; - $P += $BMP['bytes_per_pixel']; - } + imagesetpixel($res, $X, $Y, $COLOR[1]); + $X++; + $P += $BMP['bytes_per_pixel']; + } - $Y--; - $P += $BMP['decal']; - } - //Fermeture du fichier - fclose($f1); + $Y--; + $P += $BMP['decal']; + } + //Fermeture du fichier + fclose($f1); - return $res; - } + return $res; + } - /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-*-*-*-*-*-*-*-*-*- + /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-*-*-*-*-*-*-*-*-*- PSD SUPPORT (READING) *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-*-*-*-*-*-*-*-*-*/ - private function imagecreatefrompsd($fileName) - # Author: Tim de Koning - # Version: 1.3 - # Purpose: To create an image from a PSD file. - # Param in: PSD file to open. - # Param out: Return a resource like the other ImageCreateFrom functions - # Reference: http://www.kingsquare.nl/phppsdreader - # Notes: - # - { - if (file_exists($this->psdReaderPath)) - { + private function imagecreatefrompsd($fileName) + # Author: Tim de Koning + # Version: 1.3 + # Purpose: To create an image from a PSD file. + # Param in: PSD file to open. + # Param out: Return a resource like the other ImageCreateFrom functions + # Reference: http://www.kingsquare.nl/phppsdreader + # Notes: + # + { + if (file_exists($this->psdReaderPath)) + { - include_once($this->psdReaderPath); + include_once($this->psdReaderPath); - $psdReader = new PhpPsdReader($fileName); + $psdReader = new PhpPsdReader($fileName); - if (isset($psdReader->infoArray['error'])) - { - return ''; - } - else - { - return $psdReader->getImage(); - } - } - else - { - return false; - } - } + if (isset($psdReader->infoArray['error'])) + { + return ''; + } + else + { + return $psdReader->getImage(); + } + } + else + { + return false; + } + } ## -------------------------------------------------------- - public function __destruct() - { - if (is_resource($this->imageResized) || $this->imageResized instanceof \GdImage) - { - imagedestroy($this->imageResized); - } - } + public function __destruct() + { + if (is_resource($this->imageResized) || $this->imageResized instanceof \GdImage) + { + imagedestroy($this->imageResized); + } + } ## -------------------------------------------------------- diff --git a/module/agenda/agenda.php b/module/agenda/agenda.php index 91d337c..8f294f7 100644 --- a/module/agenda/agenda.php +++ b/module/agenda/agenda.php @@ -36,7 +36,7 @@ class agenda extends common { 'index' => self::GROUP_VISITOR ]; - const VERSION = '5.1'; + const VERSION = '5.2'; const REALNAME = 'Agenda'; const DELETE = true; const UPDATE = '4.1'; @@ -136,14 +136,14 @@ class agenda extends common { * Appelée par les fonctions index et config */ private function update() { - - // Initialisation ou mise à jour vers la version 4.7 + + // Mise à jour vers la version 4.7 if (version_compare($this->getData(['module', $this->getUrl(0), 'config', 'versionData']), '4.7', '<') ) { if(! is_dir(self::DATAMODULE.'data/'.$this->getUrl(0).'_affiche')) mkdir(self::DATAMODULE.'data/'.$this->getUrl(0).'_affiche'); $this->setData(['module', $this->getUrl(0), 'config', 'versionData','4.7']); } - // Initialisation ou mise à jour vers la version 5.0 + // Mise à jour vers la version 5.0 if (version_compare($this->getData(['module', $this->getUrl(0), 'config', 'versionData']), '5.0', '<') ) { $this->setData(['module', $this->getUrl(0), 'texts',[ 'configTextButtonBack' => 'Retour', @@ -154,10 +154,14 @@ class agenda extends common { $this->setData(['module', $this->getUrl(0), 'config', 'versionData','5.0']); } - // Initialisation ou mise à jour vers la version 5.1 - if (version_compare($this->getData(['module', $this->getUrl(0), 'config', 'versionData']), '5.1', '<') ) { - $this->setData(['module', $this->getUrl(0), 'config', 'versionData','5.1']); - } + // Mise à jour vers la version 5.2 + if (version_compare($this->getData(['module', $this->getUrl(0), 'config', 'versionData']), '5.2', '<') ) { + // Mise à jour des .htaccess avec Apache2.4 + copy( './module/agenda/ressource/data/agenda/module/adresses/.htaccess', './site/data/agenda/module/adresses/.htaccess'); + copy( './module/agenda/ressource/data/agenda/module/data/.htaccess', './site/data/agenda/module/data/.htaccess'); + copy( './module/agenda/ressource/file/source/agenda/adresses/.htaccess', './site/file/source/agenda/adresses/.htaccess'); + $this->setData(['module', $this->getUrl(0), 'config', 'versionData','5.2']); + } } /** @@ -775,26 +779,12 @@ class agenda extends common { self::$time_unix_deb = $date->getTimestamp(); $date->setTime(18, 00); self::$time_unix_fin = $date->getTimestamp(); - // Passage de la langue d'administration à Tinymce et à flatpickr - $lang_admin = 'fr_FR'; - $lang_flatpickr = 'fr'; - if( $this->getData(['config', 'i18n', 'langAdmin']) ==='en'){ - $lang_admin = 'en_GB'; - $lang_flatpickr = 'default'; - } - ?> - - addOutput([ 'showBarEditButton' => true, 'showPageContent' => false, 'vendor' => [ - 'flatpickr', - 'tinymce', + 'flatpickr' ], 'view' => 'creation' ]); @@ -911,26 +901,13 @@ class agenda extends common { } $this->limite_groupes(); if( $this->getUser('group') >= self::$evenement['groupe_mod']){ - // Passage de la langue d'administration à Tinymce et à flatpickr - $lang_admin = 'fr_FR'; - $lang_flatpickr = 'fr'; - if( $this->getData(['config', 'i18n', 'langAdmin']) ==='en'){ - $lang_admin = 'en_GB'; - $lang_flatpickr = 'default'; - } - ?> - - addOutput([ 'showBarEditButton' => true, 'showPageContent' => false, 'vendor' => [ - 'flatpickr', - 'tinymce' + 'flatpickr' ], 'view' => 'edition' ]); @@ -948,7 +925,7 @@ class agenda extends common { /** - * Newname utilisé par la version 9 pour inscrire le nouveau nom de page dans le json du module + * Newname utilisé pour inscrire le nouveau nom de page dans le json du module */ public function newname() { $this->setData(['module',$this->getUrl(0),'name',$this->getUrl(0)]); @@ -973,8 +950,10 @@ class agenda extends common { } // Mise à jour des données de module - $this->update(); - + if (null !== $this->getData(['module', $this->getUrl(0), 'config', 'versionData']) + && version_compare($this->getData(['module', $this->getUrl(0), 'config', 'versionData']), '5.2', '<')){ + $this->update(); + } //Pour récupération des données ajax jquery date ou id $url = $_SERVER['REQUEST_URI']; if (strpos($url,'/da:') !== false){ @@ -1005,24 +984,22 @@ class agenda extends common { 'droit_creation' => 2, 'droit_limite' => true, 'maxiWidth' => '800', - 'versionData' => $this->getData(['module', $this->getUrl(0), 'config', 'versionData']) + 'versionData' => self::VERSION ], 'categories' => [ 'valCategories' => false ] ]]); - //Création des dossiers de sauvegarde de l'agenda - if(! is_dir(self::DATAMODULE.'data')) mkdir(self::DATAMODULE.'data',0770,true); + // Upload des ressources puis création des dossiers de sauvegarde de l'agenda + $this->custom_copy('./module/agenda/ressource/data', self::DATA_DIR); + $this->custom_copy('./module/agenda/ressource/file', self::FILE_DIR); + if(! is_dir(self::DATAMODULE.'data/'.$this->getUrl(0)))mkdir(self::DATAMODULE.'data/'.$this->getUrl(0)); if(! is_dir(self::DATAMODULE.'data/'.$this->getUrl(0).'_sauve'))mkdir(self::DATAMODULE.'data/'.$this->getUrl(0).'_sauve'); if(! is_dir(self::DATAMODULE.'data/'.$this->getUrl(0).'_visible')) mkdir(self::DATAMODULE.'data/'.$this->getUrl(0).'_visible'); if(! is_dir(self::DATAMODULE.'data/'.$this->getUrl(0).'_affiche')) mkdir(self::DATAMODULE.'data/'.$this->getUrl(0).'_affiche'); if(! is_dir(self::DATAMODULE.'data/'.$this->getUrl(0))) mkdir(self::DATAMODULE.'data/'.$this->getUrl(0)); - if(! is_dir(self::DATAFILE.'ics')) mkdir(self::DATAFILE.'ics'); if(! is_dir(self::DATAFILE.'categories')) mkdir(self::DATAFILE.'categories'); - if(! is_dir(self::DATAMODULE.'ics')) mkdir(self::DATAMODULE.'ics'); - if(! is_dir(self::DATAMODULE.'adresses')) mkdir(self::DATAMODULE.'adresses'); - $this->addOutput([ 'notification' => $text[0], diff --git a/module/agenda/ressource/data/agenda/module/adresses/.htaccess b/module/agenda/ressource/data/agenda/module/adresses/.htaccess new file mode 100644 index 0000000..50a6262 --- /dev/null +++ b/module/agenda/ressource/data/agenda/module/adresses/.htaccess @@ -0,0 +1,7 @@ +# Bloque l'accès aux données + + Require all denied + + + Require all denied + \ No newline at end of file diff --git a/site/data/agenda/module/categories/categories.json b/module/agenda/ressource/data/agenda/module/categories/categories.json similarity index 100% rename from site/data/agenda/module/categories/categories.json rename to module/agenda/ressource/data/agenda/module/categories/categories.json diff --git a/module/agenda/ressource/data/agenda/module/data/.htaccess b/module/agenda/ressource/data/agenda/module/data/.htaccess new file mode 100644 index 0000000..cee53b2 --- /dev/null +++ b/module/agenda/ressource/data/agenda/module/data/.htaccess @@ -0,0 +1,3 @@ + + Require all granted + \ No newline at end of file diff --git a/site/data/agenda/module/ics/jours_feries_metropole.ics b/module/agenda/ressource/data/agenda/module/ics/jours_feries_metropole.ics similarity index 100% rename from site/data/agenda/module/ics/jours_feries_metropole.ics rename to module/agenda/ressource/data/agenda/module/ics/jours_feries_metropole.ics diff --git a/module/agenda/ressource/file/source/agenda/adresses/.htaccess b/module/agenda/ressource/file/source/agenda/adresses/.htaccess new file mode 100644 index 0000000..50a6262 --- /dev/null +++ b/module/agenda/ressource/file/source/agenda/adresses/.htaccess @@ -0,0 +1,7 @@ +# Bloque l'accès aux données + + Require all denied + + + Require all denied + \ No newline at end of file diff --git a/module/agenda/ressource/file/source/agenda/ics/jours_feries_metropole.ics b/module/agenda/ressource/file/source/agenda/ics/jours_feries_metropole.ics new file mode 100644 index 0000000..fc358df --- /dev/null +++ b/module/agenda/ressource/file/source/agenda/ics/jours_feries_metropole.ics @@ -0,0 +1,733 @@ +BEGIN:VCALENDAR +VERSION:2.0 +X-WR-CALNAME:Jours fériés Métropole +NAME:Jours fériés Métropole +PRODID:Etalab +BEGIN:VEVENT +DTSTART;VALUE=DATE:20250529 +DTSTAMP:20200101T000000Z +SUMMARY:Ascension +UID:d1d8e2e240ae715d149c11145638a06d +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20150508 +DTSTAMP:20200101T000000Z +SUMMARY:8 mai +UID:81b412b83868ed02ea1a8024c4c8a357 +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20220508 +DTSTAMP:20200101T000000Z +SUMMARY:8 mai +UID:00fd28dc3058aa5389abadb6a02b8b5b +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20250714 +DTSTAMP:20200101T000000Z +SUMMARY:14 juillet +UID:93686d52c729aca3c401065e490d98fd +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20160516 +DTSTAMP:20200101T000000Z +SUMMARY:Lundi de Pentecôte +UID:a4b1c3723d5d877d7265deb24faaa8d8 +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20150714 +DTSTAMP:20200101T000000Z +SUMMARY:14 juillet +UID:de8342ff2afa7031a581237cc35cdbf0 +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20180714 +DTSTAMP:20200101T000000Z +SUMMARY:14 juillet +UID:95d3fe478e70603ed092aba9bb14cc03 +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20221225 +DTSTAMP:20200101T000000Z +SUMMARY:Jour de Noël +UID:8cbfd34c58535adf9152928830f16b56 +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20210501 +DTSTAMP:20200101T000000Z +SUMMARY:1er mai +UID:eb4f4cd6ccfb42abd6190130b4f80c77 +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20210524 +DTSTAMP:20200101T000000Z +SUMMARY:Lundi de Pentecôte +UID:29bd64b591fb6044b6579673f13d241a +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20220714 +DTSTAMP:20200101T000000Z +SUMMARY:14 juillet +UID:526c2a579f44a21fa277f3faed7f155b +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20160328 +DTSTAMP:20200101T000000Z +SUMMARY:Lundi de Pâques +UID:60bb00b126ff132ace83b1a77bdd4775 +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20250501 +DTSTAMP:20200101T000000Z +SUMMARY:1er mai +UID:81a277f6a2065fa3d9379df5559941de +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20211101 +DTSTAMP:20200101T000000Z +SUMMARY:Toussaint +UID:ddf94e83421783ed9b68791012d4ffcc +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20161101 +DTSTAMP:20200101T000000Z +SUMMARY:Toussaint +UID:242cd3a4e72710ea57ed35e76497783b +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20151101 +DTSTAMP:20200101T000000Z +SUMMARY:Toussaint +UID:f96ae94fa61bb2f3c671ba8a0e127c65 +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20171225 +DTSTAMP:20200101T000000Z +SUMMARY:Jour de Noël +UID:dae23dc0b21d6334b5654044a52d95e1 +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20171111 +DTSTAMP:20200101T000000Z +SUMMARY:11 novembre +UID:6b06d7c6e368c2bb47895630c9ac618f +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20230501 +DTSTAMP:20200101T000000Z +SUMMARY:1er mai +UID:512be151b9a03e408a8ee80371bdb5d5 +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20230101 +DTSTAMP:20200101T000000Z +SUMMARY:1er janvier +UID:5ec1ea7aeb0fcd5593fcc8b2de69ce6e +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20220101 +DTSTAMP:20200101T000000Z +SUMMARY:1er janvier +UID:2c17ae593ff7e9e3c8585e30a3183279 +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20230518 +DTSTAMP:20200101T000000Z +SUMMARY:Ascension +UID:4a8d93da3ec625969c13c4820b24f514 +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20201101 +DTSTAMP:20200101T000000Z +SUMMARY:Toussaint +UID:fe6c71c56021b2d7e573e1cd6cde074d +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20210714 +DTSTAMP:20200101T000000Z +SUMMARY:14 juillet +UID:5d769cd717fe2027b11077cca08ce35d +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20180521 +DTSTAMP:20200101T000000Z +SUMMARY:Lundi de Pentecôte +UID:9c332de8829db3bdaab01f1190f15663 +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20211225 +DTSTAMP:20200101T000000Z +SUMMARY:Jour de Noël +UID:0e4218e8cf22ab9abf21febe9456e20c +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20241101 +DTSTAMP:20200101T000000Z +SUMMARY:Toussaint +UID:dd267dce0232b504133231c68f19c9ae +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20160815 +DTSTAMP:20200101T000000Z +SUMMARY:Assomption +UID:f5144d62904c585628142166f2a2e695 +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20180501 +DTSTAMP:20200101T000000Z +SUMMARY:1er mai +UID:3c43707735a4d4a214466edf8e6fcbe6 +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20150815 +DTSTAMP:20200101T000000Z +SUMMARY:Assomption +UID:1edff23fc91c41ad446abf064725fc70 +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20200601 +DTSTAMP:20200101T000000Z +SUMMARY:Lundi de Pentecôte +UID:2b10299dd0366c510b07bd9a4ff048b1 +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20200714 +DTSTAMP:20200101T000000Z +SUMMARY:14 juillet +UID:856f2701d117a9b188086541706c7964 +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20231225 +DTSTAMP:20200101T000000Z +SUMMARY:Jour de Noël +UID:367624e227aac3812528f241349a7c96 +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20241225 +DTSTAMP:20200101T000000Z +SUMMARY:Jour de Noël +UID:a2ad4bde5f021604f088ac8ff9dd8fd0 +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20150101 +DTSTAMP:20200101T000000Z +SUMMARY:1er janvier +UID:7b836334425862ddb4bf47b488d0fd03 +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20190530 +DTSTAMP:20200101T000000Z +SUMMARY:Ascension +UID:d9a96a99fbedf3bb211eccd97f155fd4 +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20170815 +DTSTAMP:20200101T000000Z +SUMMARY:Assomption +UID:f768ecc87a5cd7be120b87f25d9233bc +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20190714 +DTSTAMP:20200101T000000Z +SUMMARY:14 juillet +UID:0840d81f66979ceec8c1d332f4012d01 +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20160508 +DTSTAMP:20200101T000000Z +SUMMARY:8 mai +UID:bc90b2144ad8e4a8f40d6174ba41fba0 +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20150525 +DTSTAMP:20200101T000000Z +SUMMARY:Lundi de Pentecôte +UID:b99c07d06dc0e712f70888f4b78d413a +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20240520 +DTSTAMP:20200101T000000Z +SUMMARY:Lundi de Pentecôte +UID:0f00afe53d71e95961a45b42cda9ace8 +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20181111 +DTSTAMP:20200101T000000Z +SUMMARY:11 novembre +UID:6a18fa390a60e5a32d0b6898ca0fedf1 +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20150501 +DTSTAMP:20200101T000000Z +SUMMARY:1er mai +UID:848a71f1f9793e72415143c5847e2b9d +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20240509 +DTSTAMP:20200101T000000Z +SUMMARY:Ascension +UID:b4016e3b941132ba6672d2f6fe1fe608 +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20230529 +DTSTAMP:20200101T000000Z +SUMMARY:Lundi de Pentecôte +UID:c708f3ba4561a574d917b8301fb62e13 +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20201111 +DTSTAMP:20200101T000000Z +SUMMARY:11 novembre +UID:840d3b553f7c5745c66e526a5120296a +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20240101 +DTSTAMP:20200101T000000Z +SUMMARY:1er janvier +UID:f4574587958b1848a827cefd81923521 +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20220501 +DTSTAMP:20200101T000000Z +SUMMARY:1er mai +UID:2b200c0a320d6c3c9376ec32ac5209bd +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20220606 +DTSTAMP:20200101T000000Z +SUMMARY:Lundi de Pentecôte +UID:47ecd83655fb3d9f3f466ed71b30edf5 +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20240501 +DTSTAMP:20200101T000000Z +SUMMARY:1er mai +UID:c6b6e5340de7a9d4382f02f409f70198 +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20180815 +DTSTAMP:20200101T000000Z +SUMMARY:Assomption +UID:72478cfa7389b0e74e289cd5548c52d8 +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20170605 +DTSTAMP:20200101T000000Z +SUMMARY:Lundi de Pentecôte +UID:24d76b93707f517fd9742a53297eb15d +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20250508 +DTSTAMP:20200101T000000Z +SUMMARY:8 mai +UID:a6590e8f64c1f8d2ec22a7f66a39f5db +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20240401 +DTSTAMP:20200101T000000Z +SUMMARY:Lundi de Pâques +UID:89aa3606f0cf255cd22be993f739c289 +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20201225 +DTSTAMP:20200101T000000Z +SUMMARY:Jour de Noël +UID:58eb1d45cb1e4020902c9d7f48a6aca3 +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20240815 +DTSTAMP:20200101T000000Z +SUMMARY:Assomption +UID:a5532e6257cf41e64b6c8f4f8e4f62f9 +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20180402 +DTSTAMP:20200101T000000Z +SUMMARY:Lundi de Pâques +UID:53aef7b2068f87bb46c4d87b76d3f62f +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20251111 +DTSTAMP:20200101T000000Z +SUMMARY:11 novembre +UID:d4fcc714c308a93c9d80b65b84e297ba +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20251101 +DTSTAMP:20200101T000000Z +SUMMARY:Toussaint +UID:fca336a73b4976ab496d4afe93449e61 +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20191225 +DTSTAMP:20200101T000000Z +SUMMARY:Jour de Noël +UID:94dc7bca0d98b843c0a464dfaba404fa +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20220418 +DTSTAMP:20200101T000000Z +SUMMARY:Lundi de Pâques +UID:fd293a74887a0208fd4b2f996922d146 +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20210513 +DTSTAMP:20200101T000000Z +SUMMARY:Ascension +UID:71f318271fab7c933b84c9f4c1c2791d +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20170501 +DTSTAMP:20200101T000000Z +SUMMARY:1er mai +UID:1d3c47ada506eafb4f0b1045343412e3 +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20230410 +DTSTAMP:20200101T000000Z +SUMMARY:Lundi de Pâques +UID:7a6a65c90bf078e3ea7d1038166dd061 +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20251225 +DTSTAMP:20200101T000000Z +SUMMARY:Jour de Noël +UID:7adc4181e295ea370f71a6f017f77e4e +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20170525 +DTSTAMP:20200101T000000Z +SUMMARY:Ascension +UID:f3265f5ca615c3fb59694612cd7077ef +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20191101 +DTSTAMP:20200101T000000Z +SUMMARY:Toussaint +UID:546de5f95d01851e99635413b7328543 +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20210508 +DTSTAMP:20200101T000000Z +SUMMARY:8 mai +UID:147d0831ff1a762a404fcd1c62527fcb +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20210101 +DTSTAMP:20200101T000000Z +SUMMARY:1er janvier +UID:77c4d1dce03d48cf722cc0d46d126876 +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20210405 +DTSTAMP:20200101T000000Z +SUMMARY:Lundi de Pâques +UID:7ce5538a440f5b760fc61beeb005e279 +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20151111 +DTSTAMP:20200101T000000Z +SUMMARY:11 novembre +UID:82e5c9d47a87040e405295cb9de85b3a +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20171101 +DTSTAMP:20200101T000000Z +SUMMARY:Toussaint +UID:0d4171e346dd06e288c5ca5d4c2694c3 +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20180101 +DTSTAMP:20200101T000000Z +SUMMARY:1er janvier +UID:b9a8a659021921221508c443a9385582 +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20200501 +DTSTAMP:20200101T000000Z +SUMMARY:1er mai +UID:9cdedd9a4810fc24e452a4bfe84ce2bd +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20220815 +DTSTAMP:20200101T000000Z +SUMMARY:Assomption +UID:877bb3d4bec9c9e2202194eb67265250 +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20200413 +DTSTAMP:20200101T000000Z +SUMMARY:Lundi de Pâques +UID:ee8b94a34f43dc3f00cf575ac9a3401b +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20151225 +DTSTAMP:20200101T000000Z +SUMMARY:Jour de Noël +UID:c976c51152f0dd8144b46562cec06f22 +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20240714 +DTSTAMP:20200101T000000Z +SUMMARY:14 juillet +UID:fbf4c942a1bc6d8e18c69cfb477e89e2 +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20161111 +DTSTAMP:20200101T000000Z +SUMMARY:11 novembre +UID:89198e369802ebc60ae2d36128ad4dcf +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20200101 +DTSTAMP:20200101T000000Z +SUMMARY:1er janvier +UID:ff83f977fea539750d3a7c076a799767 +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20150406 +DTSTAMP:20200101T000000Z +SUMMARY:Lundi de Pâques +UID:b53416352327943804f0ec1d6a684947 +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20250815 +DTSTAMP:20200101T000000Z +SUMMARY:Assomption +UID:c3cf1311f57118aab4bc96248df024e1 +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20230714 +DTSTAMP:20200101T000000Z +SUMMARY:14 juillet +UID:c097697da80859a33dae16c90daff383 +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20250609 +DTSTAMP:20200101T000000Z +SUMMARY:Lundi de Pentecôte +UID:e7bec9699cfe0509ab2b5a1bc92e308d +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20200521 +DTSTAMP:20200101T000000Z +SUMMARY:Ascension +UID:357ace601bea837565327c9d3dab7d77 +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20170714 +DTSTAMP:20200101T000000Z +SUMMARY:14 juillet +UID:29eeecbea86fbfd359d9551084be1df0 +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20200815 +DTSTAMP:20200101T000000Z +SUMMARY:Assomption +UID:4bb974b056c03fff8d2c6f158355d452 +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20211111 +DTSTAMP:20200101T000000Z +SUMMARY:11 novembre +UID:de39555c83e7530d261e49864323ede7 +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20241111 +DTSTAMP:20200101T000000Z +SUMMARY:11 novembre +UID:c2e9351248275761ab92e2fff42a1b76 +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20190422 +DTSTAMP:20200101T000000Z +SUMMARY:Lundi de Pâques +UID:b378b5d243d0ad3f0b835eb70ad0a4ed +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20200508 +DTSTAMP:20200101T000000Z +SUMMARY:8 mai +UID:474b26ed4a97afacbaf2f015b1e5dcea +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20160501 +DTSTAMP:20200101T000000Z +SUMMARY:1er mai +UID:4ee79fba95cf1048678f65b0580687e0 +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20250421 +DTSTAMP:20200101T000000Z +SUMMARY:Lundi de Pâques +UID:4702b0a28f8c0b3d92c583d2c5d39ea7 +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20250101 +DTSTAMP:20200101T000000Z +SUMMARY:1er janvier +UID:22adedd30f8f6d6232db4a1d4d0bfce4 +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20190501 +DTSTAMP:20200101T000000Z +SUMMARY:1er mai +UID:eda3a7ef23063dcbf65fbdc298fbb3ec +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20231101 +DTSTAMP:20200101T000000Z +SUMMARY:Toussaint +UID:824ab1768b09b7eb077f74a116793836 +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20150514 +DTSTAMP:20200101T000000Z +SUMMARY:Ascension +UID:9bb62e903fe599f23bd5e24acd310c2f +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20170508 +DTSTAMP:20200101T000000Z +SUMMARY:8 mai +UID:db81d5a8de54d7cecd057d0d43a4a87d +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20210815 +DTSTAMP:20200101T000000Z +SUMMARY:Assomption +UID:0caa48853dd06d031dcf0a78f9def079 +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20231111 +DTSTAMP:20200101T000000Z +SUMMARY:11 novembre +UID:a7ad613a417360a84394ce679ff84484 +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20180510 +DTSTAMP:20200101T000000Z +SUMMARY:Ascension +UID:e1eec9f61c8b0877be2cf39c81fad25f +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20170417 +DTSTAMP:20200101T000000Z +SUMMARY:Lundi de Pâques +UID:2930e6b4bad7f7d369382aa65929684d +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20190610 +DTSTAMP:20200101T000000Z +SUMMARY:Lundi de Pentecôte +UID:a19d90214f28b0dfad0a0b2eb04b1069 +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20220526 +DTSTAMP:20200101T000000Z +SUMMARY:Ascension +UID:b59a0a0e8b147c3c6a105703da32e16d +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20230815 +DTSTAMP:20200101T000000Z +SUMMARY:Assomption +UID:b940bf2c89a7a6429d8aca19cd27da24 +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20190508 +DTSTAMP:20200101T000000Z +SUMMARY:8 mai +UID:737601a775f06ef776cb8111eecb1df1 +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20190101 +DTSTAMP:20200101T000000Z +SUMMARY:1er janvier +UID:af04912c51afa4711116ca03058202ab +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20181101 +DTSTAMP:20200101T000000Z +SUMMARY:Toussaint +UID:2d978c43c970d71323573948a7720349 +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20191111 +DTSTAMP:20200101T000000Z +SUMMARY:11 novembre +UID:f610cb4feff3c50245a2f136f9e5af3f +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20221111 +DTSTAMP:20200101T000000Z +SUMMARY:11 novembre +UID:9fbcdbeb6181e8cb00b78e8cd9145318 +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20170101 +DTSTAMP:20200101T000000Z +SUMMARY:1er janvier +UID:dfadc3cee0b9aa21cc89477447b097b5 +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20160714 +DTSTAMP:20200101T000000Z +SUMMARY:14 juillet +UID:c6cff5af72cbabefdcb9330e2e6d13c6 +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20230508 +DTSTAMP:20200101T000000Z +SUMMARY:8 mai +UID:47ee8f7c375e59fcb5508beb5188a072 +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20240508 +DTSTAMP:20200101T000000Z +SUMMARY:8 mai +UID:c0b9c2c8b3364fcc6c61a20725b4aee3 +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20161225 +DTSTAMP:20200101T000000Z +SUMMARY:Jour de Noël +UID:83ac83d92caaca8a08a6dab0024d5227 +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20160505 +DTSTAMP:20200101T000000Z +SUMMARY:Ascension +UID:338b07bf80ee8ccff3e3f2eb09388a3a +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20190815 +DTSTAMP:20200101T000000Z +SUMMARY:Assomption +UID:ff9d7c093b8d971133c5c444e93c0f6f +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20181225 +DTSTAMP:20200101T000000Z +SUMMARY:Jour de Noël +UID:dfdeebebc2a52cad2747a1cffedfaa77 +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20221101 +DTSTAMP:20200101T000000Z +SUMMARY:Toussaint +UID:0d73b395edba6d3dd8eaf1a7554dd8bb +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20160101 +DTSTAMP:20200101T000000Z +SUMMARY:1er janvier +UID:46df3293d93419db1f69ac30aabfdfd1 +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20180508 +DTSTAMP:20200101T000000Z +SUMMARY:8 mai +UID:4b40a5a01999a2bf2a8a40bbc22fb2f3 +END:VEVENT +METHOD:PUBLISH +END:VCALENDAR diff --git a/module/agenda/view/creation/creation.php b/module/agenda/view/creation/creation.php index 5274739..6762b68 100644 --- a/module/agenda/view/creation/creation.php +++ b/module/agenda/view/creation/creation.php @@ -63,6 +63,28 @@ switch ($val) { break; } ?> + +getData(['config', 'i18n', 'langAdmin']) ==='en'){ + $lang_admin = 'en_GB'; + $lang_flatpickr = 'default'; +} +?> + + +'; +echo ''; +echo ''; +?> +
diff --git a/module/agenda/view/edition/edition.php b/module/agenda/view/edition/edition.php index 2788227..b57cb7a 100644 --- a/module/agenda/view/edition/edition.php +++ b/module/agenda/view/edition/edition.php @@ -55,6 +55,28 @@ switch ($val) { break; } ?> + +getData(['config', 'i18n', 'langAdmin']) ==='en'){ + $lang_admin = 'en_GB'; + $lang_flatpickr = 'default'; +} +?> + + +'; +echo ''; +echo ''; +?> + getUser('group') >= $module::$evenement['groupe_mod'] ){ if( $this->getUser('group') >= 2){ diff --git a/module/blog/blog.php b/module/blog/blog.php index bad255a..8466aaf 100644 --- a/module/blog/blog.php +++ b/module/blog/blog.php @@ -18,7 +18,7 @@ class blog extends common { - const VERSION = '6.2'; + const VERSION = '6.3'; const REALNAME = 'Blog'; const DELETE = true; const UPDATE = '0.0'; @@ -61,70 +61,9 @@ class blog extends common { public static $pages; - public static $states = [ - false => 'Brouillon', - true => 'Publié' - ]; - public static $states_en = [ - false => 'Draft', - true => 'Published' - ]; - public static $pictureSizes = [ - '20' => 'Très petite', - '30' => 'Petite', - '40' => 'Grande', - '50' => 'Très Grande', - '100' => 'Pleine largeur', - ]; - public static $pictureSizes_en = [ - '20' => 'Very small', - '30' => 'Small', - '40' => 'Large', - '50' => 'Very large', - '100' => 'Full width', - ]; - public static $picturePositions_en = [ - 'left' => 'Left', - 'right' => 'Right', - ]; - public static $picturePositions = [ - 'left' => 'à gauche', - 'right' => 'à droite', - ]; - // Nombre d'objets par page - public static $ItemsList = [ - 4 => '4 articles', - 8 => '8 articles', - 12 => '12 articles', - 16 => '16 articles', - 22 => '22 articles' - ]; - - //Paramètre longueur maximale des commentaires en nb de caractères - public static $commentLength = [ - '500' => '500', - '1000' => '1000', - '2000' => '2000', - '5000' => '5000', - '10000' => '10000' - ]; - - // Permissions d'un article - public static $articleConsent = [ - self::EDIT_ALL => 'Tous les groupes', - self::EDIT_GROUP => 'Groupe du propriétaire', - self::EDIT_OWNER => 'Propriétaire' - ]; - public static $articleConsent_en = [ - self::EDIT_ALL => 'All groups', - self::EDIT_GROUP => 'Owner\'s group', - self::EDIT_OWNER => 'Owner' - ]; - public static $users = []; - /** * Mise à jour du module * Appelée par les fonctions index et config @@ -179,9 +118,10 @@ class blog extends common { } $this->setData(['module', $this->getUrl(0), 'config', 'versionData','6.0']); } - // Version 6.2 - if (version_compare($this->getData(['module', $this->getUrl(0), 'config', 'versionData']), '6.2', '<') ) { - $this->setData(['module', $this->getUrl(0), 'config', 'versionData','6.2']); + // Version 6.3 + if (version_compare($this->getData(['module', $this->getUrl(0), 'config', 'versionData']), '6.3', '<') ) { + $this->setData(['module', $this->getUrl(0), 'texts', 'ReadMore', 'Lire la suite']); + $this->setData(['module', $this->getUrl(0), 'config', 'versionData','6.3']); } } @@ -255,20 +195,9 @@ class blog extends common { */ public function texts() { // Lexique - $text = []; - $val = $this->getData(['config', 'i18n', 'langAdmin']); - switch ($val) { - case 'fr' : - $text[0] = ''; - $text[1] = 'Textes enregistrés'; - $text[2] = 'Textes visibles par un visiteur'; - break; - case 'en' : - $text[0] = ''; - $text[1] = ''; - $text[2] = 'Texts visible to a visitor'; - break; - } + $param = 'blog'; + include('./module/blog/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_blog.php'); + // Soumission du formulaire if($this->isPost()) { $this->setData(['module', $this->getUrl(0), 'texts',[ @@ -288,18 +217,18 @@ class blog extends common { 'TinymceMaxi' => $this->getInput('blogTextsTinymceMaxi',helper::FILTER_STRING_SHORT), 'TinymceCara' => $this->getInput('blogTextsTinymceCara',helper::FILTER_STRING_SHORT), 'TinymceExceed' => $this->getInput('blogTextsTinymceExceed',helper::FILTER_STRING_SHORT), - + 'ReadMore' => $this->getInput('blogTextsReadMore',helper::FILTER_STRING_SHORT) ]]); $this->addOutput([ 'redirect' => helper::baseUrl() . $this->getUrl(0) . '/config', - 'notification' => $text[1], + 'notification' => $text['blog']['texts'][1], 'state' => true ]); } $this->addOutput([ - 'title' => $text[2], + 'title' => $text['blog']['texts'][2], 'view' => 'texts', ]); } @@ -308,18 +237,9 @@ class blog extends common { */ public function add() { // Lexique - $text = []; - $val = $this->getData(['config', 'i18n', 'langAdmin']); - switch ($val) { - case 'fr' : - $text[0] = 'Nouvel article créé'; - $text[1] = 'Nouvel article'; - break; - case 'en' : - $text[0] = 'New article created'; - $text[1] = 'New article'; - break; - } + $param = 'blog'; + include('./module/blog/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_blog.php'); + // Soumission du formulaire if($this->isPost()) { // Modification de l'userId @@ -340,7 +260,7 @@ class blog extends common { $articleId, [ 'comment' => $this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(2), 'comment']), 'content' => $this->getInput('blogAddContent', null), - 'picture' => $this->getInput('blogAddPicture', helper::FILTER_STRING_SHORT, true), + 'picture' => $this->getInput('blogAddPicture', helper::FILTER_STRING_SHORT), 'hidePicture' => $this->getInput('blogAddHidePicture', helper::FILTER_BOOLEAN), 'pictureSize' => $this->getInput('blogAddPictureSize', helper::FILTER_STRING_SHORT), 'picturePosition' => $this->getInput('blogAddPicturePosition', helper::FILTER_STRING_SHORT), @@ -359,7 +279,7 @@ class blog extends common { // Valeurs en sortie $this->addOutput([ 'redirect' => helper::baseUrl() . $this->getUrl(0) . '/config', - 'notification' => $text[0], + 'notification' => $text['blog']['add'][0], 'state' => true ]); } @@ -371,12 +291,8 @@ class blog extends common { } unset($userFirstname); // Passage de la langue d'administration à Tinymce et flatpickr - $lang_admin = 'fr_FR'; - $lang_flatpickr = 'fr'; - if( $this->getData(['config', 'i18n', 'langAdmin']) ==='en'){ - $lang_admin = 'en_GB'; - $lang_flatpickr = 'default'; - } + $lang_admin = $text['blog']['add'][2]; + $lang_flatpickr = $text['blog']['add'][3]; ?> '; echo ''; @@ -51,7 +48,8 @@ if( function_exists('datefmt_create') && function_exists('datefmt_create') && ex
getData(['module', $this->getUrl(0), 'posts', $this->getUrl(1), 'pictureSize']) === null ? '100' : $this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(1), 'pictureSize']); ?> - getData(['module', $this->getUrl(0), 'posts', $this->getUrl(1), 'hidePicture']) == false) { + getData(['module', $this->getUrl(0), 'posts', $this->getUrl(1), 'hidePicture']) === false + && $this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(1), 'picture']) !=='' ) { echo '' . $this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(1), 'picture']) . ''; diff --git a/module/blog/view/comment/comment.php b/module/blog/view/comment/comment.php index 3bc9080..3aac5db 100644 --- a/module/blog/view/comment/comment.php +++ b/module/blog/view/comment/comment.php @@ -1,23 +1,7 @@ getData(['config', 'i18n', 'langAdmin']); -switch ($val) { - case 'fr' : - $text[0] = 'Retour'; - $text[1] = 'Date'; - $text[2] = 'Contenu'; - $text[3] = 'Auteur'; - $text[4] = 'Aucun commentaire.'; - break; - case 'en' : - $text[0] = 'Return'; - $text[1] = 'Date'; - $text[2] = 'Content'; - $text[3] = 'Author'; - $text[4] = 'No comments'; - break; -} +$param = 'blog_view'; +include('./module/blog/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_blog.php'); ?>
@@ -25,7 +9,7 @@ switch ($val) { 'class' => 'buttonGrey', 'href' => helper::baseUrl() . $this->getUrl(0) . '/config', 'ico' => 'left', - 'value' => $text[0] + 'value' => $text['blog_view']['comment'][0] ]); ?>
@@ -35,9 +19,9 @@ switch ($val) {
- + '; ?>
- + diff --git a/module/blog/view/config/config.js.php b/module/blog/view/config/config.js.php index 711d3ac..f95c3c4 100644 --- a/module/blog/view/config/config.js.php +++ b/module/blog/view/config/config.js.php @@ -18,14 +18,7 @@ */ $(".blogConfigDelete").on("click", function() { var _this = $(this); - var text=""; - getData(['config', 'i18n', 'langAdmin' ]) === 'fr'){ - echo 'text = "Êtes-vous sûr de vouloir supprimer cet article ?";' ; - } - else{ - echo 'text = "Are you sure you want to delete this article ?";' ; - } ?> - return core.confirm(text, function() { + return core.confirm(textConfirm, function() { $(location).attr("href", _this.attr("href")); }); }); \ No newline at end of file diff --git a/module/blog/view/config/config.php b/module/blog/view/config/config.php index c3c8b07..a115041 100644 --- a/module/blog/view/config/config.php +++ b/module/blog/view/config/config.php @@ -1,93 +1,59 @@ getData(['config', 'i18n', 'langAdmin']); -switch ($val) { - case 'fr' : - $text[0] = 'Retour'; - $text[1] = 'Article'; - $text[2] = 'Enregistrer'; - $text[3] = 'Paramètres du module'; - $text[4] = 'Lien du flux RSS'; - $text[5] = 'Texte de l\'étiquette'; - $text[6] = 'Articles par page'; - $text[7] = 'Titre'; - $text[8] = 'Date de publication'; - $text[9] = 'Etat'; - $text[10] = 'Commentaires'; - $text[11] = 'Aucun article.'; - $text[12] = 'Version n°'; - $text[13] = 'Textes'; - break; - case 'en' : - $text[0] = 'Back'; - $text[1] = 'Article'; - $text[2] = 'Save'; - $text[3] = 'Module settings'; - $text[4] = 'RSS feed link'; - $text[5] = 'Label text'; - $text[6] = 'Articles per page'; - $text[7] = 'Title'; - $text[8] = 'Date published'; - $text[9] = 'Status'; - $text[10] = 'Comments'; - $text[11] = 'No article'; - $text[12] = 'Version No.'; - $text[13] = 'Texts'; - break; -} -?> - +$param = 'blog_view'; +include('./module/blog/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_blog.php'); + +echo template::formOpen('blogConfig'); ?>
'buttonGrey', 'href' => helper::baseUrl() . 'page/edit/' . $this->getUrl(0), 'posts', 'ico' => 'left', - 'value' => $text[0] + 'value' => $text['blog_view']['config'][0] ]); ?>
helper::baseUrl() . $this->getUrl(0) . '/texts', 'ico' => '', - 'value' => $text[13] + 'value' => $text['blog_view']['config'][13] ]); ?>
helper::baseUrl() . $this->getUrl(0) . '/add', 'ico' => 'plus', - 'value' => $text[1] + 'value' => $text['blog_view']['config'][1] ]); ?>
$text[2] + 'value' => $text['blog_view']['config'][2] ]); ?>
-

+

- $this->getData(['module', $this->getUrl(0), 'config', 'feeds']), ]); ?>
$text[5], + 'label' => $text['blog_view']['config'][5], 'value' => $this->getData(['module', $this->getUrl(0), 'config', 'feedsLabel']) ]); ?>
- $text[6], + $text['blog_view']['config'][6], 'selected' => $this->getData(['module', $this->getUrl(0),'config', 'itemsperPage']) ]); ?>
@@ -97,12 +63,15 @@ switch ($val) {
- + - + -
+
+ diff --git a/module/blog/view/edit/edit.php b/module/blog/view/edit/edit.php index 5932b0d..72d24c3 100644 --- a/module/blog/view/edit/edit.php +++ b/module/blog/view/edit/edit.php @@ -1,82 +1,22 @@ getData(['config', 'i18n', 'langAdmin']); -switch ($val) { - case 'fr' : - $text[0] = 'Retour'; - $text[1] = 'Enregistrer en brouillon'; - $text[2] = 'Publier'; - $text[3] = 'Informations générales'; - $text[4] = 'Titre'; - $text[5] = 'Taille optimale de l\'image de couverture : '; - $text[6] = 'Image de couverture'; - $text[7] = 'Largeur de l\'image'; - $text[8] = 'Position'; - $text[9] = 'Le texte de l\'article est adapté autour de l\'image'; - $text[10] = 'Masquer l\'image dans l\'article'; - $text[11] = 'Options de publication'; - $text[12] = 'Auteur'; - $text[13] = 'L\'article n\'est visible qu\'après la date de publication prévue.'; - $text[14] = 'Date de publication'; - $text[15] = 'Edition / Suppression'; - $text[16] = 'Les utilisateurs des groupes supérieurs accèdent à l\'article sans restriction'; - $text[17] = 'Commentaires'; - $text[18] = 'Fermer les commentaires'; - $text[19] = 'Approbation par un modérateur'; - $text[20] = 'Choix du nombre maximum de caractères pour chaque commentaire de l\'article, mise en forme html comprise.'; - $text[21] = 'Caractères par commentaire'; - $text[22] = 'Notification par email'; - $text[23] = 'Editeurs = éditeurs + administrateurs
Membres = membres + éditeurs + administrateurs'; - $pictureSizes = $module::$pictureSizes; - $picturePositions = $module::$picturePositions; - $articleConsent = $module::$articleConsent; - break; - case 'en' : - $text[0] = 'Back'; - $text[1] = 'Save as draft'; - $text[2] = 'Publish'; - $text[3] = 'General information'; - $text[4] = 'Title'; - $text[5] = 'Optimal size of cover image : '; - $text[6] = 'Cover image'; - $text[7] = 'Width of image'; - $text[8] = 'Position'; - $text[9] = 'The text of the article is adapted around the image'; - $text[10] = 'Hide image in article'; - $text[11] = 'Publication options'; - $text[12] = 'Author'; - $text[13] = 'The article is not visible until after the scheduled publication date'; - $text[14] = 'Date of publication'; - $text[15] = 'Edit / Delete'; - $text[16] = 'Users in higher groups have unrestricted access to the article'; - $text[17] = 'Comments'; - $text[18] = 'Close comments'; - $text[19] = 'Moderator approval'; - $text[20] = 'Choice of the maximum number of characters for each comment in the article, including html formatting.'; - $text[21] = 'Characters per comment'; - $text[22] = 'Email notification'; - $text[23] = 'Editors = editors + administrators
Members = members + editors + administrators'; - $pictureSizes = $module::$pictureSizes_en; - $picturePositions = $module::$picturePositions_en; - $articleConsent = $module::$articleConsent_en; - break; -} -?> - +$param = 'blog_view'; +include('./module/blog/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_blog.php'); + +echo template::formOpen('blogEditForm'); ?>
'buttonGrey', 'href' => helper::baseUrl() . $this->getUrl(0) . '/config', 'ico' => 'left', - 'value' => $text[0] + 'value' => $text['blog_view']['edit'][0] ]); ?>
true, - 'value' => $text[1] + 'value' => $text['blog_view']['edit'][1] ]); ?> true @@ -84,7 +24,7 @@ switch ($val) {
$text[2], + 'value' => $text['blog_view']['edit'][2], 'uniqueSubmission' => true, ]); ?>
@@ -92,43 +32,43 @@ switch ($val) {
-

+

$text[4], + 'label' => $text['blog_view']['edit'][4], 'value' => $this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(2), 'title']) ]); ?>
- getData(['theme', 'site', 'width']) !== '100%' ) $help = $text[5] . ((int) substr($this->getData(['theme', 'site', 'width']), 0, -2) - (20 * 2)) . ' x 350 pixels.'; + getData(['theme', 'site', 'width']) !== '100%' ) $help = $text['blog_view']['edit'][5] . ((int) substr($this->getData(['theme', 'site', 'width']), 0, -2) - (20 * 2)) . ' x 350 pixels.'; echo template::file('blogEditPicture', [ 'help' => $help, - 'label' => $text[6], + 'label' => $text['blog_view']['edit'][6], 'type' => 1, 'value' => $this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(2), 'picture']) ]); ?>
$text[7], + 'label' => $text['blog_view']['edit'][7], 'selected' => $this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(2), 'pictureSize']) ]); ?>
$text[8], + 'label' => $text['blog_view']['edit'][8], 'selected' => $this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(2), 'picturePosition']), - 'help' => $text[9] + 'help' => $text['blog_view']['edit'][9] ]); ?>
- $this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(2), 'hidePicture']) ]); ?>
@@ -143,27 +83,27 @@ switch ($val) {
-

+

$text[12], + 'label' => $text['blog_view']['edit'][12], 'selected' => $this->getUser('id'), 'disabled' => $this->getUser('group') !== self::GROUP_ADMIN ? true : false ]); ?>
$text[13], - 'label' => $text[14], + 'help' => $text['blog_view']['edit'][13], + 'label' => $text['blog_view']['edit'][14], 'value' => $this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(2), 'publishedOn']) ]); ?>
$text[15], + 'label' => $text['blog_view']['edit'][15], 'selected' => is_numeric($this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(2), 'editConsent'])) ? $module::EDIT_GROUP : $this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(2), 'editConsent']), - 'help' => $text[16] + 'help' => $text['blog_view']['edit'][16] ]); ?>
@@ -173,23 +113,23 @@ switch ($val) {
-

+

- $this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(2), 'commentClose']) ]); ?>
- $this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(2), 'commentApproved']), '' ]); ?>
- $text[20], - 'label' => $text[21], + $text['blog_view']['edit'][20], + 'label' => $text['blog_view']['edit'][21], 'selected' => $this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(2), 'commentMaxlength']) ]); ?>
@@ -197,14 +137,14 @@ switch ($val) {
- $this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(2), 'commentNotification']), ]); ?>
- $this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(2), 'commentGroupNotification']), - 'help' => $text[23] + 'help' => $text['blog_view']['edit'][23] ]); ?>
diff --git a/module/blog/view/index/index.php b/module/blog/view/index/index.php index 221d4d2..433b18b 100644 --- a/module/blog/view/index/index.php +++ b/module/blog/view/index/index.php @@ -1,17 +1,7 @@ getData(['config', 'i18n', 'langAdmin']); -switch ($val) { - case 'fr' : - $text[0] = 'Lire la suite'; - $text[1] = 'Aucun article'; - break; - case 'en' : - $text[0] = 'Read more'; - $text[1] = 'No article'; - break; -} +$param = 'blog_view'; +include('./module/blog/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_blog.php'); // Pour les dates suivant la langue de rédaction du site if( function_exists('datefmt_create') && function_exists('datefmt_create') && extension_loaded('intl') ){ $zone = 'Europe/Paris'; @@ -29,24 +19,28 @@ if($module::$articles): ?>
$article): ?>
-
- - makeThumb( self::FILE_DIR . 'source/' . $article['picture'], - self::FILE_DIR . 'thumb/' . $thumb, - self::THUMBS_WIDTH); - } - ?> - - <?php echo $article['picture']; ?> - - -
-
+ getData(['module', $this->getUrl(0), 'posts', $articleId, 'picture']) !=='' ){ ?> +
+ + makeThumb( self::FILE_DIR . 'source/' . $article['picture'], + self::FILE_DIR . 'thumb/' . $thumb, + self::THUMBS_WIDTH); + } + ?> + + <?php echo $article['picture']; ?> + + +
+
@@ -90,5 +84,5 @@ if($module::$articles): ?>
- + diff --git a/module/blog/view/texts/texts.php b/module/blog/view/texts/texts.php index 555f0e2..eb99a96 100644 --- a/module/blog/view/texts/texts.php +++ b/module/blog/view/texts/texts.php @@ -1,55 +1,9 @@ getData(['config', 'i18n', 'langAdmin']); -switch ($val) { - case 'fr' : - $text[0] = 'Retour'; - $text[1] = 'Adapter ces textes dans la langue de vos visiteurs'; - $text[2] = 'Enregistrer'; - $text[3] = 'Pas encore de commentaire'; - $text[4] = 'Ecrire un commentaire'; - $text[5] = 'Nom'; - $text[6] = 'Commentaire avec maximum'; - $text[7] = 'caractères'; - $text[8] = 'commentaire'; - $text[9] = 'Commentaire déposé'; - $text[10] = 'Commentaire déposé en attente d\'approbation'; - $text[11] = 'Cet article ne reçoit pas de commentaire'; - $text[13] = 'Connexion'; - $text[15] ='Editer'; - $text[16] ='Annuler'; - $text[17] ='Envoyer'; - $text[18] ='Vous avez atteint le maximum de'; - $text[19] ='caractères restants'; - $text[20] ='Vous alliez dépasser le maximum de '; - $text[25] ='Version n°'; - break; - case 'en' : - $text[0] = 'Back'; - $text[1] = 'Adapt these texts into the language of your visitors'; - $text[2] = 'Save'; - $text[3] = 'No comment yet'; - $text[4] = 'Write a comment'; - $text[5] = 'Name'; - $text[6] = 'Comment with maximum'; - $text[7] = 'characters'; - $text[8] = 'comment'; - $text[9] = 'Comment filed'; - $text[10] = 'Comment submitted pending approval'; - $text[11] = 'This article does not receive comments'; - $text[13] = 'Login'; - $text[15] = 'Edit'; - $text[16] = 'Cancel'; - $text[17] = 'Send'; - $text[18] = 'You have reached the maximum of'; - $text[19] = 'characters left'; - $text[20] = 'You were about to exceed the maximum of '; - $text[25] = 'Version no.'; - break; -} -?> -getData(['config', 'i18n', 'langAdmin']) . '/lex_blog.php'); + +// drapeau pour la langue d'origine ou la langue en traduction rédigée if( $this->getInput('DELTA_I18N_SITE') === '' || $this->getInput('DELTA_I18N_SITE')=== null || $this->getInput('DELTA_I18N_SITE') === 'base'){ $flag = $this->getData(['config', 'i18n', 'langBase']); } @@ -64,35 +18,35 @@ else{ 'class' => 'buttonGrey', 'href' => helper::baseUrl() . $this->getUrl(0). '/config', 'ico' => 'left', - 'value' => $text[0] + 'value' => $text['blog_view']['texts'][0] ]); ?>
$text[2] + 'value' => $text['blog_view']['texts'][2] ]); ?>
-

+

$text[3], + 'label' => $text['blog_view']['texts'][3], 'value' => $this->getData(['module', $this->getUrl(0), 'texts', 'NoComment']) ]); ?>
$text[4], + 'label' => $text['blog_view']['texts'][4], 'value' => $this->getData(['module', $this->getUrl(0), 'texts', 'Write']) ]); ?>
$text[5], + 'label' => $text['blog_view']['texts'][5], 'value' => $this->getData(['module', $this->getUrl(0), 'texts', 'Name']) ]); ?>
@@ -100,19 +54,19 @@ else{
$text[6], + 'label' => $text['blog_view']['texts'][6], 'value' => $this->getData(['module', $this->getUrl(0), 'texts', 'Maxi']) ]); ?>
$text[7], + 'label' => $text['blog_view']['texts'][7], 'value' => $this->getData(['module', $this->getUrl(0), 'texts', 'Cara']) ]); ?>
$text[8], + 'label' => $text['blog_view']['texts'][8], 'value' => $this->getData(['module', $this->getUrl(0), 'texts', 'Comment']) ]); ?>
@@ -120,19 +74,19 @@ else{
$text[9], + 'label' => $text['blog_view']['texts'][9], 'value' => $this->getData(['module', $this->getUrl(0), 'texts', 'CommentOK']) ]); ?>
$text[10], + 'label' => $text['blog_view']['texts'][10], 'value' => $this->getData(['module', $this->getUrl(0), 'texts', 'Waiting']) ]); ?>
$text[11], + 'label' => $text['blog_view']['texts'][11], 'value' => $this->getData(['module', $this->getUrl(0), 'texts', 'ArticleNoComment']) ]); ?>
@@ -140,19 +94,19 @@ else{
$text[13], + 'label' => $text['blog_view']['texts'][13], 'value' => $this->getData(['module', $this->getUrl(0), 'texts', 'Connection']) ]); ?>
$text[15], + 'label' => $text['blog_view']['texts'][15], 'value' => $this->getData(['module', $this->getUrl(0), 'texts', 'Edit']) ]); ?>
$text[16], + 'label' => $text['blog_view']['texts'][16], 'value' => $this->getData(['module', $this->getUrl(0), 'texts', 'Cancel']) ]); ?>
@@ -160,19 +114,19 @@ else{
$text[17], + 'label' => $text['blog_view']['texts'][17], 'value' => $this->getData(['module', $this->getUrl(0), 'texts', 'Send']) ]); ?>
$text[18], + 'label' => $text['blog_view']['texts'][18], 'value' => $this->getData(['module', $this->getUrl(0), 'texts', 'TinymceMaxi']) ]); ?>
$text[19], + 'label' => $text['blog_view']['texts'][19], 'value' => $this->getData(['module', $this->getUrl(0), 'texts', 'TinymceCara']) ]); ?>
@@ -180,16 +134,22 @@ else{
$text[20], + 'label' => $text['blog_view']['texts'][20], 'value' => $this->getData(['module', $this->getUrl(0), 'texts', 'TinymceExceed']) ]); ?> -
+
+
+ $text['blog_view']['texts'][26], + 'value' => $this->getData(['module', $this->getUrl(0), 'texts', 'ReadMore']) + ]); ?> +
-
+
diff --git a/module/form/form.php b/module/form/form.php index 65e1eed..b2aeea3 100644 --- a/module/form/form.php +++ b/module/form/form.php @@ -18,7 +18,7 @@ class form extends common { - const VERSION = '4.1'; + const VERSION = '4.2'; const REALNAME = 'Formulaire'; const DELETE = true; const UPDATE = '0.0'; @@ -115,6 +115,9 @@ class form extends common { $this->setData(['module', $this->getUrl(0), 'config', 'uploadTxt',false]); $this->setData(['module', $this->getUrl(0), 'config', 'versionData','4.1']); } + if( version_compare($this->getData(['module', $this->getUrl(0), 'config', 'versionData']), '4.1', '<') ){ + $this->setData(['module', $this->getUrl(0), 'config', 'versionData', '4.2']); + } } @@ -654,16 +657,7 @@ class form extends common { $sent = false; $redirect = helper::baseUrl() . $this->getUrl(0); } - // Passage de la langue d'administration à flatpickr - $lang_flatpickr = 'fr'; - if( $this->getData(['config', 'i18n', 'langAdmin']) ==='en'){ - $lang_flatpickr = 'default'; - } - ?> - - addOutput([ 'notification' => ($sent === true ? $text[3] : $notice), @@ -674,16 +668,7 @@ class form extends common { ], ]); } - // Passage de la langue d'administration à flatpickr - $lang_flatpickr = 'fr'; - if( $this->getData(['config', 'i18n', 'langAdmin']) ==='en'){ - $lang_flatpickr = 'default'; - } - ?> - - addOutput([ 'showBarEditButton' => true, diff --git a/module/form/view/index/index.js.php b/module/form/view/index/index.js.php index b01fc0a..1cae99c 100644 --- a/module/form/view/index/index.js.php +++ b/module/form/view/index/index.js.php @@ -15,6 +15,15 @@ */ +/* Passage de la langue d'administration à flatpickr */ +getData(['config', 'i18n', 'langAdmin']) ==='en'){ + $lang_flatpickr = 'default'; +} +?> +var lang_flatpickr = ""; + $( "#formFileReset" ).click(function() { $( "#fileToUpload" ).val(''); }); diff --git a/module/form/view/index/index.php b/module/form/view/index/index.php index 7224d79..16a5bfd 100644 --- a/module/form/view/index/index.php +++ b/module/form/view/index/index.php @@ -57,19 +57,17 @@ switch ($val) { $this->getData([ 'module', $this->getUrl(0), 'draft', 'checkbox']) ]); ?> - - -
-

+

+ getData(['module', $this->getUrl(0), 'config', 'captcha'])): ?>
diff --git a/module/news/ressource/defaultdata.php b/module/news/ressource/defaultdata.php index 031c056..3e6e845 100644 --- a/module/news/ressource/defaultdata.php +++ b/module/news/ressource/defaultdata.php @@ -8,7 +8,8 @@ class init extends news { 'height' => -1, 'versionData' => self::VERSION, 'hiddeTitle' => false, - 'sameHeight' => false + 'sameHeight' => false, + 'noMargin' => true ]; public static $defaultTheme = [ diff --git a/site/data/statislite/module/filtres_primaires/liste_bot.txt b/module/statislite/ressource/filtres_primaires/liste_bot.txt similarity index 100% rename from site/data/statislite/module/filtres_primaires/liste_bot.txt rename to module/statislite/ressource/filtres_primaires/liste_bot.txt diff --git a/module/statislite/ressource/tmp/.htaccess b/module/statislite/ressource/tmp/.htaccess new file mode 100644 index 0000000..cee53b2 --- /dev/null +++ b/module/statislite/ressource/tmp/.htaccess @@ -0,0 +1,3 @@ + + Require all granted + \ No newline at end of file diff --git a/module/statislite/statislite.php b/module/statislite/statislite.php index 82f90cc..046e120 100644 --- a/module/statislite/statislite.php +++ b/module/statislite/statislite.php @@ -31,7 +31,7 @@ class statislite extends common { 'conversionTime' => self::GROUP_VISITOR ]; - const VERSION = '4.3'; + const VERSION = '4.4'; const REALNAME = 'Statislite'; const DELETE = true; const UPDATE = '2.6'; @@ -82,9 +82,12 @@ class statislite extends common { */ private function update() { - // Installation ou mise à jour vers la version 4.3 - if (version_compare($this->getData(['module', $this->getUrl(0), 'config', 'versionData']), '4.3', '<') ) { - $this->setData(['module', $this->getUrl(0), 'config', 'versionData','4.3']); + // Installation ou mise à jour vers la version 4.4 + if (version_compare($this->getData(['module', $this->getUrl(0), 'config', 'versionData']), '4.4', '<') ) { + if( file_exists("./site/data/statislite/module/json/.htaccess") ) unlink("./site/data/statislite/module/json/.htaccess"); + if( file_exists("./site/data/statislite/module/json_sauve/.htaccess") ) unlink("./site/data/statislite/module/json_sauve/.htaccess"); + copy('./module/statislite/ressource/tmp/.htaccess', self::DATAMODULE.'/tmp/.htaccess'); + $this->setData(['module', $this->getUrl(0), 'config', 'versionData','4.4']); } } @@ -94,16 +97,7 @@ class statislite extends common { public function config() { // Lexique include('./module/statislite/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_statislite.php'); - - // Mise à jour des données de module s'il existe - if( null !== $this->getData(['module', $this->getUrl(0), 'config', 'versionData']) ) $this->update(); - - // Installation des ressources à la création de la page - if( $this->getData(['module', $this->getUrl(0), 'config', 'config']) !== true){ - // Copie des fichiers de module/statislite/ressource/ vers self::DATAMODULE - $this->custom_copy('./module/statislite/ressource', self::DATAMODULE); - } - + // Détection d'un changement de nom de la page statistique pour mettre à jour listeQS if( is_file( self::$fichiers_json.'filtre_primaire.json')){ $json = file_get_contents(self::$fichiers_json.'filtre_primaire.json'); @@ -445,8 +439,14 @@ class statislite extends common { // Lexique include('./module/statislite/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_statislite.php'); - // Si le module n'existe pas, on le crée avec des valeurs par défaut et on demande une validation de la configuration + // Si le module n'existe pas, copie des ressources, on le crée avec des valeurs par défaut et on demande une validation de la configuration if( $this->getData(['module', $this->getUrl(0), 'config', 'config']) !== true){ + // Copie des fichiers de module/statislite/ressource/ vers self::DATAMODULE + if( !is_dir( self::DATAMODULE)) mkdir( self::DATAMODULE, 0755, true); + $this->custom_copy('./module/statislite/ressource', self::DATAMODULE); + if( !is_dir( self::DATAMODULE.'/json' )) mkdir( self::DATAMODULE.'/json', 0755); + if( !is_dir( self::DATAMODULE.'/json_sauve' ))mkdir( self::DATAMODULE.'/json_sauve', 0755); + $this->setData(['module', $this->getUrl(0), 'config',[ 'timeVisiteMini' => '30', 'timePageMini' => '5', diff --git a/site/backup/.htaccess b/site/backup/.htaccess index acb8905..b66e808 100644 --- a/site/backup/.htaccess +++ b/site/backup/.htaccess @@ -1,3 +1 @@ -# Bloque l'accès aux sauvegardes -Order deny,allow -Deny from all +Require all denied diff --git a/site/data/.htaccess b/site/data/.htaccess index db3789a..c29c7e2 100644 --- a/site/data/.htaccess +++ b/site/data/.htaccess @@ -1,5 +1,3 @@ -# Bloque l'accès aux données - - Order deny,allow - Deny from all - \ No newline at end of file + +Require all denied + diff --git a/site/data/agenda/module/adresses/.htaccess b/site/data/agenda/module/adresses/.htaccess deleted file mode 100644 index 52b1d8d..0000000 --- a/site/data/agenda/module/adresses/.htaccess +++ /dev/null @@ -1,14 +0,0 @@ -# Bloque l'accès aux données - - Order deny,allow - Deny from all - - - Order deny,allow - Deny from all - -# Bloque l'accès htaccess - - Order deny,allow - Deny from all - \ No newline at end of file diff --git a/site/data/agenda/module/data/.htaccess b/site/data/agenda/module/data/.htaccess deleted file mode 100644 index a9d3a94..0000000 --- a/site/data/agenda/module/data/.htaccess +++ /dev/null @@ -1,4 +0,0 @@ -# Autorise l'accès aux fichiers json par les scripts js - - allow from all - \ No newline at end of file diff --git a/site/data/statislite/module/json/.htaccess b/site/data/statislite/module/json/.htaccess deleted file mode 100644 index 85278f8..0000000 --- a/site/data/statislite/module/json/.htaccess +++ /dev/null @@ -1,10 +0,0 @@ -# Bloque l'accès aux données - - Order deny,allow - Deny from all - -# Bloque l'accès htaccess - - Order deny,allow - Deny from all - \ No newline at end of file diff --git a/site/data/statislite/module/json_sauve/.htaccess b/site/data/statislite/module/json_sauve/.htaccess deleted file mode 100644 index 85278f8..0000000 --- a/site/data/statislite/module/json_sauve/.htaccess +++ /dev/null @@ -1,10 +0,0 @@ -# Bloque l'accès aux données - - Order deny,allow - Deny from all - -# Bloque l'accès htaccess - - Order deny,allow - Deny from all - \ No newline at end of file diff --git a/site/data/statislite/module/tmp/.htaccess b/site/data/statislite/module/tmp/.htaccess deleted file mode 100644 index a71a0e5..0000000 --- a/site/data/statislite/module/tmp/.htaccess +++ /dev/null @@ -1,4 +0,0 @@ -# Autorise l'accès de sessionInvalide.json. et robots.json - - allow from all - \ No newline at end of file diff --git a/site/file/source/agenda/adresses/.htaccess b/site/file/source/agenda/adresses/.htaccess deleted file mode 100644 index 52b1d8d..0000000 --- a/site/file/source/agenda/adresses/.htaccess +++ /dev/null @@ -1,14 +0,0 @@ -# Bloque l'accès aux données - - Order deny,allow - Deny from all - - - Order deny,allow - Deny from all - -# Bloque l'accès htaccess - - Order deny,allow - Deny from all - \ No newline at end of file diff --git a/site/tmp/.htaccess b/site/tmp/.htaccess index fdb15e1..980f334 100644 --- a/site/tmp/.htaccess +++ b/site/tmp/.htaccess @@ -1,8 +1,4 @@ -# Bloque l'accès aux données temporaires -Order deny,allow -Deny from all -# Sauf l'accès aux images pour le captcha +Require all denied -Order Allow,Deny - Allow from all +Require all granted