move to Franck style
parent
72dbed6e5f
commit
12c1305d4d
29
_admin.php
29
_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
|
||||
'<fieldset><legend>Favicon</legend>'.
|
||||
'<p><label class="classic">'.
|
||||
form::checkbox('simply_favicon','1',(boolean) $blog_settings->system->simply_favicon).
|
||||
__('Enable "Simply favicon" extension').'</label></p>'.
|
||||
'<p class="form-note">'.
|
||||
__("You must place an image called favicon.png or .jpg or .ico into your blog's public directory.").
|
||||
'</p>'.
|
||||
'</fieldset>';
|
||||
'<div class="fieldset"><h4 id="simply_favicon_params">Favicon</h4>' .
|
||||
'<p><label class="classic">' .
|
||||
form::checkbox('simply_favicon', '1', (boolean) $blog_settings->system->simply_favicon) .
|
||||
__('Enable "Simply favicon" extension') . '</label></p>' .
|
||||
'<p class="form-note">' .
|
||||
__("You must place an image called favicon.png or .jpg or .ico into your blog's public directory.") .
|
||||
'</p>' .
|
||||
'</div>';
|
||||
}
|
||||
|
||||
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
|
||||
# -- 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'
|
||||
);
|
||||
?>
|
||||
|
|
|
@ -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'));
|
||||
?>
|
||||
$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
|
||||
# -- 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
|
||||
'<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
|
||||
if (file_exists($public_path.'png')) {
|
||||
if (file_exists($public_path . 'png')) {
|
||||
echo
|
||||
'<link rel="apple-touch-icon" href="'.$public_url.'png" />'."\n".
|
||||
'<link rel="icon" type="image/png" 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";
|
||||
}
|
||||
// all others
|
||||
else {
|
||||
foreach($mimetypes as $ext => $mime)
|
||||
{
|
||||
if (file_exists($public_path.$ext)) {
|
||||
if (file_exists($public_path . $ext)) {
|
||||
echo
|
||||
'<link rel="icon" type="'.$mime.'" href="'.$public_url.$ext.'" />'."\n";
|
||||
'<link rel="icon" type="' . $mime . '" href="' . $public_url . $ext . '" />' . "\n";
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
Loading…
Reference in New Issue