update license and minor fix
parent
9ebc2c4f8f
commit
e9274e5b43
|
@ -0,0 +1,5 @@
|
||||||
|
simplyFavicon 2021.08.18
|
||||||
|
* update license
|
||||||
|
|
||||||
|
simplyFavicon 2011.04.08
|
||||||
|
* first version
|
|
@ -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)
|
39
_admin.php
39
_admin.php
|
@ -1,17 +1,18 @@
|
||||||
<?php
|
<?php
|
||||||
# -- BEGIN LICENSE BLOCK ----------------------------------
|
# -- BEGIN LICENSE BLOCK ----------------------------------
|
||||||
|
#
|
||||||
# This file is part of simplyFavicon, a plugin for Dotclear 2.
|
# This file is part of simplyFavicon, a plugin for Dotclear 2.
|
||||||
#
|
#
|
||||||
# Copyright (c) 2009-2011 JC Denis and contributors
|
# Copyright (c) 2009-2021 Jean-Christian Denis and contributors
|
||||||
# jcdenis@gdwd.com
|
|
||||||
#
|
#
|
||||||
# Licensed under the GPL version 2.0 license.
|
# Licensed under the GPL version 2.0 license.
|
||||||
# A copy of this license is available in LICENSE file or at
|
# A copy of this license is available in LICENSE file or at
|
||||||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||||
|
#
|
||||||
# -- END LICENSE BLOCK ------------------------------------
|
# -- END LICENSE BLOCK ------------------------------------
|
||||||
|
|
||||||
if (!defined('DC_CONTEXT_ADMIN')) {
|
if (!defined('DC_CONTEXT_ADMIN')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$core->addBehavior('adminBlogPreferencesForm', ['adminSimplyFavicon', 'adminBlogPreferencesForm']);
|
$core->addBehavior('adminBlogPreferencesForm', ['adminSimplyFavicon', 'adminBlogPreferencesForm']);
|
||||||
|
@ -19,21 +20,21 @@ $core->addBehavior('adminBeforeBlogSettingsUpdate', ['adminSimplyFavicon', 'admi
|
||||||
|
|
||||||
class adminSimplyFavicon
|
class adminSimplyFavicon
|
||||||
{
|
{
|
||||||
public static function adminBlogPreferencesForm($core, $blog_settings)
|
public static function adminBlogPreferencesForm($core, $blog_settings)
|
||||||
{
|
{
|
||||||
echo
|
echo
|
||||||
'<div class="fieldset"><h4 id="simply_favicon_params">Favicon</h4>' .
|
'<div class="fieldset"><h4 id="simply_favicon_params">Favicon</h4>' .
|
||||||
'<p><label class="classic">' .
|
'<p><label class="classic">' .
|
||||||
form::checkbox('simply_favicon', '1', (boolean) $blog_settings->system->simply_favicon) .
|
form::checkbox('simply_favicon', '1', (boolean) $blog_settings->system->simply_favicon) .
|
||||||
__('Enable "Simply favicon" extension') . '</label></p>' .
|
__('Enable "Simply favicon" extension') . '</label></p>' .
|
||||||
'<p class="form-note">' .
|
'<p class="form-note">' .
|
||||||
__("You must place an image called favicon.png or .jpg or .ico into your blog's public directory.") .
|
__("You must place an image called favicon.png or .jpg or .ico into your blog's public directory.") .
|
||||||
'</p>' .
|
'</p>' .
|
||||||
'</div>';
|
'</div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function adminBeforeBlogSettingsUpdate($blog_settings)
|
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']));
|
||||||
}
|
}
|
||||||
}
|
}
|
17
_define.php
17
_define.php
|
@ -1,23 +1,24 @@
|
||||||
<?php
|
<?php
|
||||||
# -- BEGIN LICENSE BLOCK ----------------------------------
|
# -- BEGIN LICENSE BLOCK ----------------------------------
|
||||||
|
#
|
||||||
# This file is part of simplyFavicon, a plugin for Dotclear 2.
|
# This file is part of simplyFavicon, a plugin for Dotclear 2.
|
||||||
#
|
#
|
||||||
# Copyright (c) 2009-2011 JC Denis and contributors
|
# Copyright (c) 2009-2021 Jean-Christian Denis and contributors
|
||||||
# jcdenis@gdwd.com
|
|
||||||
#
|
#
|
||||||
# Licensed under the GPL version 2.0 license.
|
# Licensed under the GPL version 2.0 license.
|
||||||
# A copy of this license is available in LICENSE file or at
|
# A copy of this license is available in LICENSE file or at
|
||||||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||||
|
#
|
||||||
# -- END LICENSE BLOCK ------------------------------------
|
# -- END LICENSE BLOCK ------------------------------------
|
||||||
|
|
||||||
if (!defined('DC_RC_PATH')){
|
if (!defined('DC_RC_PATH')){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->registerModule(
|
$this->registerModule(
|
||||||
/* Name */ "Simply favicon",
|
"Simply favicon",
|
||||||
/* Description*/ "Multi-agents favicon",
|
"Multi-agents favicon",
|
||||||
/* Author */ "JC Denis",
|
"Jean-Christian Denis",
|
||||||
/* Version */ '2021.08.16',
|
'2021.08.18',
|
||||||
/* Permissions */ 'admin'
|
'admin'
|
||||||
);
|
);
|
|
@ -1,17 +1,18 @@
|
||||||
<?php
|
<?php
|
||||||
# -- BEGIN LICENSE BLOCK ----------------------------------
|
# -- BEGIN LICENSE BLOCK ----------------------------------
|
||||||
|
#
|
||||||
# This file is part of simplyFavicon, a plugin for Dotclear 2.
|
# This file is part of simplyFavicon, a plugin for Dotclear 2.
|
||||||
#
|
#
|
||||||
# Copyright (c) 2009-2011 JC Denis and contributors
|
# Copyright (c) 2009-2021 Jean-Christian Denis and contributors
|
||||||
# jcdenis@gdwd.com
|
|
||||||
#
|
#
|
||||||
# Licensed under the GPL version 2.0 license.
|
# Licensed under the GPL version 2.0 license.
|
||||||
# A copy of this license is available in LICENSE file or at
|
# A copy of this license is available in LICENSE file or at
|
||||||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||||
|
#
|
||||||
# -- END LICENSE BLOCK ------------------------------------
|
# -- END LICENSE BLOCK ------------------------------------
|
||||||
|
|
||||||
if (!defined('DC_RC_PATH')){
|
if (!defined('DC_RC_PATH')){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$__autoload['publicSimplyFavicon'] = dirname(__FILE__) . '/_public.php';
|
$__autoload['publicSimplyFavicon'] = dirname(__FILE__) . '/_public.php';
|
||||||
|
|
123
_public.php
123
_public.php
|
@ -1,84 +1,85 @@
|
||||||
<?php
|
<?php
|
||||||
# -- BEGIN LICENSE BLOCK ----------------------------------
|
# -- BEGIN LICENSE BLOCK ----------------------------------
|
||||||
|
#
|
||||||
# This file is part of simplyFavicon, a plugin for Dotclear 2.
|
# This file is part of simplyFavicon, a plugin for Dotclear 2.
|
||||||
#
|
#
|
||||||
# Copyright (c) 2009-2011 JC Denis and contributors
|
# Copyright (c) 2009-2021 Jean-Christian Denis and contributors
|
||||||
# jcdenis@gdwd.com
|
|
||||||
#
|
#
|
||||||
# Licensed under the GPL version 2.0 license.
|
# Licensed under the GPL version 2.0 license.
|
||||||
# A copy of this license is available in LICENSE file or at
|
# A copy of this license is available in LICENSE file or at
|
||||||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||||
|
#
|
||||||
# -- END LICENSE BLOCK ------------------------------------
|
# -- END LICENSE BLOCK ------------------------------------
|
||||||
|
|
||||||
if (!defined('DC_RC_PATH')){
|
if (!defined('DC_RC_PATH')){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$core->addBehavior('publicHeadContent', ['publicSimplyFavicon','publicHeadContent']);
|
$core->addBehavior('publicHeadContent', ['publicSimplyFavicon', 'publicHeadContent']);
|
||||||
|
|
||||||
class publicSimplyFavicon extends dcUrlHandlers
|
class publicSimplyFavicon extends dcUrlHandlers
|
||||||
{
|
{
|
||||||
public static $mimetypes = array(
|
public static $mimetypes = array(
|
||||||
'ico' => 'image/x-icon',
|
'ico' => 'image/x-icon',
|
||||||
'png' => 'image/png',
|
'png' => 'image/png',
|
||||||
'bmp' => 'image/bmp',
|
'bmp' => 'image/bmp',
|
||||||
'gif' => 'image/gif',
|
'gif' => 'image/gif',
|
||||||
'jpg' => 'image/jpeg',
|
'jpg' => 'image/jpeg',
|
||||||
'mng' => 'video/x-mng'
|
'mng' => 'video/x-mng'
|
||||||
);
|
);
|
||||||
|
|
||||||
public static function simplyFaviconUrl($arg)
|
public static function simplyFaviconUrl($arg)
|
||||||
{
|
{
|
||||||
global $core;
|
global $core;
|
||||||
|
|
||||||
$mimetypes = self::$mimetypes;
|
$mimetypes = self::$mimetypes;
|
||||||
$public_path = path::real(path::fullFromRoot($core->blog->settings->system->public_path, DC_ROOT)) . '/favicon.';
|
$public_path = path::real(path::fullFromRoot($core->blog->settings->system->public_path, DC_ROOT)) . '/favicon.';
|
||||||
|
|
||||||
if (!$core->blog->settings->system->simply_favicon
|
if (!$core->blog->settings->system->simply_favicon
|
||||||
|| empty($arg)
|
|| empty($arg)
|
||||||
|| !array_key_exists($arg, $mimetypes)
|
|| !array_key_exists($arg, $mimetypes)
|
||||||
|| file_exists($public_path . 'favicon' . $arg)
|
|| file_exists($public_path . 'favicon' . $arg)
|
||||||
) {
|
) {
|
||||||
throw new Exception ("Page not found", 404);
|
throw new Exception ("Page not found", 404);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
header('Content-Type: ' . $mimetypes[$arg] . ';');
|
header('Content-Type: ' . $mimetypes[$arg] . ';');
|
||||||
readfile($public_path . $arg);
|
readfile($public_path . $arg);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function publicHeadContent($core)
|
public static function publicHeadContent($core)
|
||||||
{
|
{
|
||||||
if (!$core->blog->settings->system->simply_favicon){
|
if (!$core->blog->settings->system->simply_favicon){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$mimetypes = self::$mimetypes;
|
$mimetypes = self::$mimetypes;
|
||||||
$public_path = path::real(path::fullFromRoot($core->blog->settings->system->public_path, DC_ROOT)) . '/favicon.';
|
$public_path = path::real(path::fullFromRoot($core->blog->settings->system->public_path, DC_ROOT)) . '/favicon.';
|
||||||
$public_url = $core->blog->url.$core->url->getBase('simplyFavicon') . '.';
|
$public_url = $core->blog->url.$core->url->getBase('simplyFavicon') . '.';
|
||||||
|
|
||||||
// ico : IE6
|
// 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
|
echo
|
||||||
'<link rel="SHORTCUT ICON" type="image/x-icon" href="' . $public_url . 'ico" />' . "\n";
|
'<link rel="SHORTCUT ICON" type="image/x-icon" href="' . $public_url . 'ico" />' . "\n";
|
||||||
}
|
}
|
||||||
// png: apple and others
|
// png: apple and others
|
||||||
if (file_exists($public_path . 'png')) {
|
if (file_exists($public_path . 'png')) {
|
||||||
echo
|
echo
|
||||||
'<link rel="apple-touch-icon" href="' . $public_url . 'png" />' . "\n" .
|
'<link rel="apple-touch-icon" href="' . $public_url . 'png" />' . "\n" .
|
||||||
'<link rel="icon" type="image/png" href="' . $public_url . 'png" />' . "\n";
|
'<link rel="icon" type="image/png" href="' . $public_url . 'png" />' . "\n";
|
||||||
}
|
}
|
||||||
// all others
|
// all others
|
||||||
else {
|
else {
|
||||||
foreach($mimetypes as $ext => $mime)
|
foreach($mimetypes as $ext => $mime)
|
||||||
{
|
{
|
||||||
if (file_exists($public_path . $ext)) {
|
if (file_exists($public_path . $ext)) {
|
||||||
echo
|
echo
|
||||||
'<link rel="icon" type="' . $mime . '" href="' . $public_url . $ext . '" />' . "\n";
|
'<link rel="icon" type="' . $mime . '" href="' . $public_url . $ext . '" />' . "\n";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue