From e9274e5b43de8898613f7ac776a79d3d1b0fc8d5 Mon Sep 17 00:00:00 2001 From: JcDenis Date: Thu, 19 Aug 2021 23:33:19 +0200 Subject: [PATCH] update license and minor fix --- CHANGELOG.md | 5 ++ README.md | 31 ++++++++++++ _admin.php | 43 ++++++++-------- _define.php | 19 ++++---- _prepend.php | 9 ++-- _public.php | 135 ++++++++++++++++++++++++++------------------------- 6 files changed, 141 insertions(+), 101 deletions(-) create mode 100644 CHANGELOG.md create mode 100644 README.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..54c58d0 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,5 @@ +simplyFavicon 2021.08.18 + * update license + +simplyFavicon 2011.04.08 + * first version \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..4c0b9f9 --- /dev/null +++ b/README.md @@ -0,0 +1,31 @@ +# README + +## WHAT IS simplyFavicon ? + +simplyFavicon is a plugin for the open-source +web publishing software called Dotclear. + +. + +## REQUIREMENTS + + simplyFavicon requires: + + * Administrator permissions + * Dotclear 2.18 + * A readable public directory. + +## USAGE + +First install simplyFavicon, manualy from a zip package or from +Dotaddict repository. (See Dotclear's documentation to know how do this) + +Add un file called ''favicon.xxx'' where xxx could be ico, jpg, png, +on your blog public root directory and +simplyFavicon add required code to public page to show favicon on browser. + +## MORE + + * License : GNU GPL v2 + * Source & contribution : [GitHub Page](https://github.com/JcDenis/simplyFavicon) + * Packages & details: [Dotaddict Page](https://plugins.dotaddict.org/dc2/details/simplyFavicon) \ No newline at end of file diff --git a/_admin.php b/_admin.php index bfa4d1f..fe9b773 100644 --- a/_admin.php +++ b/_admin.php @@ -1,17 +1,18 @@ addBehavior('adminBlogPreferencesForm', ['adminSimplyFavicon', 'adminBlogPreferencesForm']); @@ -19,21 +20,21 @@ $core->addBehavior('adminBeforeBlogSettingsUpdate', ['adminSimplyFavicon', 'admi class adminSimplyFavicon { - 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.") . - '

' . - '
'; - } - - public static function adminBeforeBlogSettingsUpdate($blog_settings) - { - $blog_settings->system->put('simply_favicon', !empty($_POST['simply_favicon'])); - } -} + 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.") . + '

' . + '
'; + } + + public static function adminBeforeBlogSettingsUpdate($blog_settings) + { + $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 218d682..5fb087e 100644 --- a/_define.php +++ b/_define.php @@ -1,23 +1,24 @@ registerModule( - /* Name */ "Simply favicon", - /* Description*/ "Multi-agents favicon", - /* Author */ "JC Denis", - /* Version */ '2021.08.16', - /* Permissions */ 'admin' -); + "Simply favicon", + "Multi-agents favicon", + "Jean-Christian Denis", + '2021.08.18', + 'admin' +); \ No newline at end of file diff --git a/_prepend.php b/_prepend.php index f0b9b74..31ae496 100644 --- a/_prepend.php +++ b/_prepend.php @@ -1,19 +1,20 @@ url->register('simplyFavicon', 'favicon', '^favicon.(.*?)$', ['publicSimplyFavicon', 'simplyFaviconUrl']); +$core->url->register('simplyFavicon', 'favicon', '^favicon.(.*?)$', ['publicSimplyFavicon', 'simplyFaviconUrl']); \ No newline at end of file diff --git a/_public.php b/_public.php index 45677c4..06cd122 100644 --- a/_public.php +++ b/_public.php @@ -1,84 +1,85 @@ addBehavior('publicHeadContent', ['publicSimplyFavicon','publicHeadContent']); +$core->addBehavior('publicHeadContent', ['publicSimplyFavicon', 'publicHeadContent']); class publicSimplyFavicon extends dcUrlHandlers { - public static $mimetypes = array( - 'ico' => 'image/x-icon', - 'png' => 'image/png', - 'bmp' => 'image/bmp', - 'gif' => 'image/gif', - 'jpg' => 'image/jpeg', - 'mng' => 'video/x-mng' - ); - - public static function simplyFaviconUrl($arg) - { - global $core; - - $mimetypes = self::$mimetypes; - $public_path = path::real(path::fullFromRoot($core->blog->settings->system->public_path, DC_ROOT)) . '/favicon.'; + public static $mimetypes = array( + 'ico' => 'image/x-icon', + 'png' => 'image/png', + 'bmp' => 'image/bmp', + 'gif' => 'image/gif', + 'jpg' => 'image/jpeg', + 'mng' => 'video/x-mng' + ); + + public static function simplyFaviconUrl($arg) + { + global $core; + + $mimetypes = self::$mimetypes; + $public_path = path::real(path::fullFromRoot($core->blog->settings->system->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) - ) { - throw new Exception ("Page not found", 404); - } - else { - header('Content-Type: ' . $mimetypes[$arg] . ';'); - readfile($public_path . $arg); - exit; - } - } - - public static function publicHeadContent($core) - { - if (!$core->blog->settings->system->simply_favicon){ - return; - } - - $mimetypes = self::$mimetypes; - $public_path = path::real(path::fullFromRoot($core->blog->settings->system->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)) { - echo - '' . "\n"; - } - // png: apple and others - if (file_exists($public_path . 'png')) { - echo - '' . "\n" . - '' . "\n"; - } - // all others - else { - foreach($mimetypes as $ext => $mime) - { - if (file_exists($public_path . $ext)) { - echo - '' . "\n"; - break; - } - } - } - } -} + if (!$core->blog->settings->system->simply_favicon + || empty($arg) + || !array_key_exists($arg, $mimetypes) + || file_exists($public_path . 'favicon' . $arg) + ) { + throw new Exception ("Page not found", 404); + } + else { + header('Content-Type: ' . $mimetypes[$arg] . ';'); + readfile($public_path . $arg); + exit; + } + } + + public static function publicHeadContent($core) + { + if (!$core->blog->settings->system->simply_favicon){ + return; + } + + $mimetypes = self::$mimetypes; + $public_path = path::real(path::fullFromRoot($core->blog->settings->system->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)) { + echo + '' . "\n"; + } + // png: apple and others + if (file_exists($public_path . 'png')) { + echo + '' . "\n" . + '' . "\n"; + } + // all others + else { + foreach($mimetypes as $ext => $mime) + { + if (file_exists($public_path . $ext)) { + echo + '' . "\n"; + break; + } + } + } + } +} \ No newline at end of file