fix PSR12 CS
This commit is contained in:
parent
254562e384
commit
f26464ca9f
4 changed files with 47 additions and 52 deletions
11
_admin.php
11
_admin.php
|
@ -1,16 +1,15 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* @brief simplyFavicon, a plugin for Dotclear 2
|
* @brief simplyFavicon, a plugin for Dotclear 2
|
||||||
*
|
*
|
||||||
* @package Dotclear
|
* @package Dotclear
|
||||||
* @subpackage Plugin
|
* @subpackage Plugin
|
||||||
*
|
*
|
||||||
* @author Jean-Christian Denis
|
* @author Jean-Christian Denis
|
||||||
*
|
*
|
||||||
* @copyright Jean-Christian Denis
|
* @copyright Jean-Christian Denis
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('DC_CONTEXT_ADMIN')) {
|
if (!defined('DC_CONTEXT_ADMIN')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -25,7 +24,7 @@ class adminSimplyFavicon
|
||||||
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', (bool) $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.") .
|
||||||
|
@ -37,4 +36,4 @@ class adminSimplyFavicon
|
||||||
{
|
{
|
||||||
$blog_settings->system->put('simply_favicon', !empty($_POST['simply_favicon']));
|
$blog_settings->system->put('simply_favicon', !empty($_POST['simply_favicon']));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
29
_define.php
29
_define.php
|
@ -1,34 +1,33 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* @brief simplyFavicon, a plugin for Dotclear 2
|
* @brief simplyFavicon, a plugin for Dotclear 2
|
||||||
*
|
*
|
||||||
* @package Dotclear
|
* @package Dotclear
|
||||||
* @subpackage Plugin
|
* @subpackage Plugin
|
||||||
*
|
*
|
||||||
* @author Jean-Christian Denis
|
* @author Jean-Christian Denis
|
||||||
*
|
*
|
||||||
* @copyright Jean-Christian Denis
|
* @copyright Jean-Christian Denis
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
*/
|
*/
|
||||||
|
if (!defined('DC_RC_PATH')) {
|
||||||
if (!defined('DC_RC_PATH')){
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->registerModule(
|
$this->registerModule(
|
||||||
"Simply favicon",
|
'Simply favicon',
|
||||||
"Multi-agents favicon",
|
'Multi-agents favicon',
|
||||||
"Jean-Christian Denis",
|
'Jean-Christian Denis',
|
||||||
'2021.09.02.1',
|
'2021.09.02.1',
|
||||||
[
|
[
|
||||||
'requires' => [['core', '2.19']],
|
'requires' => [['core', '2.19']],
|
||||||
'permissions' => 'admin',
|
'permissions' => 'admin',
|
||||||
'type' => 'plugin',
|
'type' => 'plugin',
|
||||||
'support' => 'https://github.com/JcDenis/simplyFavicon',
|
'support' => 'https://github.com/JcDenis/simplyFavicon',
|
||||||
'details' => 'http://plugins.dotaddict.org/dc2/details/simplyFavicon',
|
'details' => 'http://plugins.dotaddict.org/dc2/details/simplyFavicon',
|
||||||
'repository' => 'https://raw.githubusercontent.com/JcDenis/simplyFavicon/master/dcstore.xml',
|
'repository' => 'https://raw.githubusercontent.com/JcDenis/simplyFavicon/master/dcstore.xml',
|
||||||
'settings' => [
|
'settings' => [
|
||||||
'blog' => '#params.simply_favicon_params'
|
'blog' => '#params.simply_favicon_params'
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
11
_prepend.php
11
_prepend.php
|
@ -1,20 +1,19 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* @brief simplyFavicon, a plugin for Dotclear 2
|
* @brief simplyFavicon, a plugin for Dotclear 2
|
||||||
*
|
*
|
||||||
* @package Dotclear
|
* @package Dotclear
|
||||||
* @subpackage Plugin
|
* @subpackage Plugin
|
||||||
*
|
*
|
||||||
* @author Jean-Christian Denis
|
* @author Jean-Christian Denis
|
||||||
*
|
*
|
||||||
* @copyright Jean-Christian Denis
|
* @copyright Jean-Christian Denis
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
*/
|
*/
|
||||||
|
if (!defined('DC_RC_PATH')) {
|
||||||
if (!defined('DC_RC_PATH')){
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$__autoload['publicSimplyFavicon'] = dirname(__FILE__) . '/_public.php';
|
$__autoload['publicSimplyFavicon'] = dirname(__FILE__) . '/_public.php';
|
||||||
|
|
||||||
$core->url->register('simplyFavicon', 'favicon', '^favicon.(.*?)$', ['publicSimplyFavicon', 'simplyFaviconUrl']);
|
$core->url->register('simplyFavicon', 'favicon', '^favicon.(.*?)$', ['publicSimplyFavicon', 'simplyFaviconUrl']);
|
||||||
|
|
48
_public.php
48
_public.php
|
@ -1,17 +1,16 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* @brief simplyFavicon, a plugin for Dotclear 2
|
* @brief simplyFavicon, a plugin for Dotclear 2
|
||||||
*
|
*
|
||||||
* @package Dotclear
|
* @package Dotclear
|
||||||
* @subpackage Plugin
|
* @subpackage Plugin
|
||||||
*
|
*
|
||||||
* @author Jean-Christian Denis
|
* @author Jean-Christian Denis
|
||||||
*
|
*
|
||||||
* @copyright Jean-Christian Denis
|
* @copyright Jean-Christian Denis
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
*/
|
*/
|
||||||
|
if (!defined('DC_RC_PATH')) {
|
||||||
if (!defined('DC_RC_PATH')){
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,67 +18,66 @@ $core->addBehavior('publicHeadContent', ['publicSimplyFavicon', 'publicHeadConte
|
||||||
|
|
||||||
class publicSimplyFavicon extends dcUrlHandlers
|
class publicSimplyFavicon extends dcUrlHandlers
|
||||||
{
|
{
|
||||||
public static $mimetypes = array(
|
public static $mimetypes = [
|
||||||
'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 {
|
|
||||||
header('Content-Type: ' . $mimetypes[$arg] . ';');
|
|
||||||
readfile($public_path . $arg);
|
|
||||||
exit;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
header('Content-Type: ' . $mimetypes[$arg] . ';');
|
||||||
|
readfile($public_path . $arg);
|
||||||
|
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 a new issue