2021-08-16 20:36:26 +00:00
|
|
|
<?php
|
2021-09-02 21:01:31 +00:00
|
|
|
/**
|
|
|
|
* @brief simplyFavicon, a plugin for Dotclear 2
|
2021-11-06 01:23:40 +00:00
|
|
|
*
|
2021-09-02 21:01:31 +00:00
|
|
|
* @package Dotclear
|
|
|
|
* @subpackage Plugin
|
2021-11-06 01:23:40 +00:00
|
|
|
*
|
2021-09-02 21:01:31 +00:00
|
|
|
* @author Jean-Christian Denis
|
2021-11-06 01:23:40 +00:00
|
|
|
*
|
2021-09-02 21:01:31 +00:00
|
|
|
* @copyright Jean-Christian Denis
|
|
|
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
|
|
|
*/
|
2021-08-16 21:44:38 +00:00
|
|
|
if (!defined('DC_CONTEXT_ADMIN')) {
|
2021-08-19 21:33:19 +00:00
|
|
|
return;
|
2021-08-16 21:44:38 +00:00
|
|
|
}
|
2021-08-16 20:36:26 +00:00
|
|
|
|
2022-11-14 22:02:42 +00:00
|
|
|
dcCore::app()->addBehavior('adminBlogPreferencesFormV2', ['adminSimplyFavicon', 'adminBlogPreferencesForm']);
|
|
|
|
dcCore::app()->addBehavior('adminBeforeBlogSettingsUpdate', ['adminSimplyFavicon', 'adminBeforeBlogSettingsUpdate']);
|
2021-08-16 20:36:26 +00:00
|
|
|
|
|
|
|
class adminSimplyFavicon
|
|
|
|
{
|
2021-11-06 09:19:13 +00:00
|
|
|
public static $extensions = ['ico', 'png', 'bmp', 'gif', 'jpg', 'mng'];
|
|
|
|
|
2022-11-14 22:02:42 +00:00
|
|
|
public static function adminBlogPreferencesForm($blog_settings)
|
2021-08-19 21:33:19 +00:00
|
|
|
{
|
2021-11-06 09:19:13 +00:00
|
|
|
$exists = [];
|
|
|
|
$path = path::fullFromRoot((string) $blog_settings->system->public_path, DC_ROOT);
|
|
|
|
foreach (self::$extensions as $ext) {
|
|
|
|
if (file_exists($path . '/favicon.' . $ext)) {
|
|
|
|
$exists[] = sprintf('<li title="%s">%s</li>', $path . '/favicon.' . $ext, 'favicon.' . $ext);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-08-19 21:33:19 +00:00
|
|
|
echo
|
2021-11-06 09:19:13 +00:00
|
|
|
'<div class="fieldset clear"><h4 id="simply_favicon_params">Favicon</h4>' .
|
|
|
|
'<div class="two-cols"><div class="col">' .
|
2021-08-19 21:33:19 +00:00
|
|
|
'<p><label class="classic">' .
|
2021-11-06 01:23:40 +00:00
|
|
|
form::checkbox('simply_favicon', '1', (bool) $blog_settings->system->simply_favicon) .
|
2021-08-19 21:33:19 +00:00
|
|
|
__('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.") .
|
2021-11-06 09:19:13 +00:00
|
|
|
'</p></div><div class="col">' .
|
|
|
|
(
|
|
|
|
empty($exists) ?
|
|
|
|
'<p>' . __('There are no favicon in blog public directory') . '</p>' :
|
|
|
|
'<p>' . __('Current favicons:') . '</p><ul class="nice">' . implode($exists) . '</ul>'
|
|
|
|
) .
|
|
|
|
'</div></div><br class="clear" /></div>';
|
2021-08-19 21:33:19 +00:00
|
|
|
}
|
2021-09-02 21:01:31 +00:00
|
|
|
|
2021-08-19 21:33:19 +00:00
|
|
|
public static function adminBeforeBlogSettingsUpdate($blog_settings)
|
|
|
|
{
|
|
|
|
$blog_settings->system->put('simply_favicon', !empty($_POST['simply_favicon']));
|
|
|
|
}
|
2021-11-06 01:23:40 +00:00
|
|
|
}
|