move to Franck style
This commit is contained in:
parent
72dbed6e5f
commit
12c1305d4d
4 changed files with 45 additions and 39 deletions
29
_admin.php
29
_admin.php
|
@ -10,29 +10,30 @@
|
||||||
# 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')){return;}
|
if (!defined('DC_CONTEXT_ADMIN')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$core->addBehavior('adminBlogPreferencesForm',array('adminSimplyFavicon','adminBlogPreferencesForm'));
|
$core->addBehavior('adminBlogPreferencesForm', ['adminSimplyFavicon', 'adminBlogPreferencesForm']);
|
||||||
$core->addBehavior('adminBeforeBlogSettingsUpdate',array('adminSimplyFavicon','adminBeforeBlogSettingsUpdate'));
|
$core->addBehavior('adminBeforeBlogSettingsUpdate', ['adminSimplyFavicon', 'adminBeforeBlogSettingsUpdate']);
|
||||||
|
|
||||||
class adminSimplyFavicon
|
class adminSimplyFavicon
|
||||||
{
|
{
|
||||||
public static function adminBlogPreferencesForm($core,$blog_settings)
|
public static function adminBlogPreferencesForm($core, $blog_settings)
|
||||||
{
|
{
|
||||||
echo
|
echo
|
||||||
'<fieldset><legend>Favicon</legend>'.
|
'<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>' .
|
||||||
'</fieldset>';
|
'</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']));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
|
|
@ -10,7 +10,9 @@
|
||||||
# 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')){return;}
|
if (!defined('DC_RC_PATH')){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$this->registerModule(
|
$this->registerModule(
|
||||||
/* Name */ "Simply favicon",
|
/* Name */ "Simply favicon",
|
||||||
|
@ -19,4 +21,3 @@ $this->registerModule(
|
||||||
/* Version */ '2021.08.15',
|
/* Version */ '2021.08.15',
|
||||||
/* Permissions */ 'admin'
|
/* Permissions */ 'admin'
|
||||||
);
|
);
|
||||||
?>
|
|
||||||
|
|
|
@ -10,9 +10,10 @@
|
||||||
# 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')){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'));
|
$core->url->register('simplyFavicon', 'favicon', '^favicon.(.*?)$', ['publicSimplyFavicon', 'simplyFaviconUrl']);
|
||||||
?>
|
|
||||||
|
|
41
_public.php
41
_public.php
|
@ -10,9 +10,11 @@
|
||||||
# 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')){return;}
|
if (!defined('DC_RC_PATH')){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$core->addBehavior('publicHeadContent',array('publicSimplyFavicon','publicHeadContent'));
|
$core->addBehavior('publicHeadContent', ['publicSimplyFavicon','publicHeadContent']);
|
||||||
|
|
||||||
class publicSimplyFavicon extends dcUrlHandlers
|
class publicSimplyFavicon extends dcUrlHandlers
|
||||||
{
|
{
|
||||||
|
@ -30,52 +32,53 @@ class publicSimplyFavicon extends dcUrlHandlers
|
||||||
global $core;
|
global $core;
|
||||||
|
|
||||||
$mimetypes = self::$mimetypes;
|
$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
|
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){return;}
|
if (!$core->blog->settings->system->simply_favicon){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$mimetypes = self::$mimetypes;
|
$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.';
|
||||||
$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 a new issue