From 12c1305d4d25bb7c17e7f7f30730a1450a5d20ee Mon Sep 17 00:00:00 2001 From: JcDenis Date: Mon, 16 Aug 2021 23:44:38 +0200 Subject: [PATCH] move to Franck style --- _admin.php | 29 +++++++++++++++-------------- _define.php | 5 +++-- _prepend.php | 9 +++++---- _public.php | 41 ++++++++++++++++++++++------------------- 4 files changed, 45 insertions(+), 39 deletions(-) diff --git a/_admin.php b/_admin.php index 022e4f6..bfa4d1f 100644 --- a/_admin.php +++ b/_admin.php @@ -10,29 +10,30 @@ # http://www.gnu.org/licenses/old-licenses/gpl-2.0.html # -- END LICENSE BLOCK ------------------------------------ -if (!defined('DC_CONTEXT_ADMIN')){return;} +if (!defined('DC_CONTEXT_ADMIN')) { + return; +} -$core->addBehavior('adminBlogPreferencesForm',array('adminSimplyFavicon','adminBlogPreferencesForm')); -$core->addBehavior('adminBeforeBlogSettingsUpdate',array('adminSimplyFavicon','adminBeforeBlogSettingsUpdate')); +$core->addBehavior('adminBlogPreferencesForm', ['adminSimplyFavicon', 'adminBlogPreferencesForm']); +$core->addBehavior('adminBeforeBlogSettingsUpdate', ['adminSimplyFavicon', 'adminBeforeBlogSettingsUpdate']); class adminSimplyFavicon { - public static function adminBlogPreferencesForm($core,$blog_settings) + public static function adminBlogPreferencesForm($core, $blog_settings) { echo - '
Favicon'. - '

'. - '

'. - __("You must place an image called favicon.png or .jpg or .ico into your blog's public directory."). - '

'. - '
'; + '

Favicon

' . + '

' . + '

' . + __("You must place an image called favicon.png or .jpg or .ico into your blog's public directory.") . + '

' . + '
'; } public static function adminBeforeBlogSettingsUpdate($blog_settings) { - $blog_settings->system->put('simply_favicon',!empty($_POST['simply_favicon'])); + $blog_settings->system->put('simply_favicon', !empty($_POST['simply_favicon'])); } } -?> \ No newline at end of file diff --git a/_define.php b/_define.php index e612ca7..5656aae 100644 --- a/_define.php +++ b/_define.php @@ -10,7 +10,9 @@ # http://www.gnu.org/licenses/old-licenses/gpl-2.0.html # -- END LICENSE BLOCK ------------------------------------ -if (!defined('DC_RC_PATH')){return;} +if (!defined('DC_RC_PATH')){ + return; +} $this->registerModule( /* Name */ "Simply favicon", @@ -19,4 +21,3 @@ $this->registerModule( /* Version */ '2021.08.15', /* Permissions */ 'admin' ); -?> diff --git a/_prepend.php b/_prepend.php index 607583e..f0b9b74 100644 --- a/_prepend.php +++ b/_prepend.php @@ -10,9 +10,10 @@ # http://www.gnu.org/licenses/old-licenses/gpl-2.0.html # -- END LICENSE BLOCK ------------------------------------ -if (!defined('DC_RC_PATH')){return;} +if (!defined('DC_RC_PATH')){ + return; +} -$__autoload['publicSimplyFavicon'] = dirname(__FILE__).'/_public.php'; +$__autoload['publicSimplyFavicon'] = dirname(__FILE__) . '/_public.php'; -$core->url->register('simplyFavicon','favicon','^favicon.(.*?)$',array('publicSimplyFavicon','simplyFaviconUrl')); -?> \ No newline at end of file +$core->url->register('simplyFavicon', 'favicon', '^favicon.(.*?)$', ['publicSimplyFavicon', 'simplyFaviconUrl']); diff --git a/_public.php b/_public.php index 2fa19dc..d9fe748 100644 --- a/_public.php +++ b/_public.php @@ -10,9 +10,11 @@ # http://www.gnu.org/licenses/old-licenses/gpl-2.0.html # -- END LICENSE BLOCK ------------------------------------ -if (!defined('DC_RC_PATH')){return;} +if (!defined('DC_RC_PATH')){ + return; +} -$core->addBehavior('publicHeadContent',array('publicSimplyFavicon','publicHeadContent')); +$core->addBehavior('publicHeadContent', ['publicSimplyFavicon','publicHeadContent']); class publicSimplyFavicon extends dcUrlHandlers { @@ -30,52 +32,53 @@ class publicSimplyFavicon extends dcUrlHandlers global $core; $mimetypes = self::$mimetypes; - $public_path = path::real(path::fullFromRoot((string) $core->blog->settings->public_path,DC_ROOT)).'/favicon.'; + $public_path = path::real(path::fullFromRoot((string) $core->blog->settings->public_path, DC_ROOT)) . '/favicon.'; if (!$core->blog->settings->system->simply_favicon || empty($arg) - || !array_key_exists($arg,$mimetypes) - || file_exists($public_path.'favicon'.$arg) + || !array_key_exists($arg, $mimetypes) + || file_exists($public_path . 'favicon' . $arg) ) { - throw new Exception ("Page not found",404); + throw new Exception ("Page not found", 404); } else { - header('Content-Type: '.$mimetypes[$arg].';'); - readfile($public_path.$arg); + header('Content-Type: ' . $mimetypes[$arg] . ';'); + readfile($public_path . $arg); exit; } } public static function publicHeadContent($core) { - if (!$core->blog->settings->system->simply_favicon){return;} + if (!$core->blog->settings->system->simply_favicon){ + return; + } $mimetypes = self::$mimetypes; - $public_path = path::real(path::fullFromRoot((string) $core->blog->settings->public_path,DC_ROOT)).'/favicon.'; - $public_url = $core->blog->url.$core->url->getBase('simplyFavicon').'.'; + $public_path = path::real(path::fullFromRoot((string) $core->blog->settings->public_path, DC_ROOT)) . '/favicon.'; + $public_url = $core->blog->url.$core->url->getBase('simplyFavicon') . '.'; // ico : IE6 - if (file_exists($public_path.'ico') && '?' != substr($core->blog->url,-1)) { + if (file_exists($public_path . 'ico') && '?' != substr($core->blog->url, -1)) { echo - ''."\n"; + '' . "\n"; } // png: apple and others - if (file_exists($public_path.'png')) { + if (file_exists($public_path . 'png')) { echo - ''."\n". - ''."\n"; + '' . "\n" . + '' . "\n"; } // all others else { foreach($mimetypes as $ext => $mime) { - if (file_exists($public_path.$ext)) { + if (file_exists($public_path . $ext)) { echo - ''."\n"; + '' . "\n"; break; } } } } } -?>