release 1.6 for dotclear 2.24

This commit is contained in:
Jean-Christian Denis 2022-12-14 23:35:40 +01:00
parent 266817b030
commit b4df311f19
Signed by: JcDenis
GPG key ID: 1B5B8C5B90B6C951
13 changed files with 566 additions and 568 deletions

View file

@ -1,37 +1,38 @@
v1.5 - 16-09-2021 Pierre Van Glabeke 1.6 - 2022.12.14
* Update to dotclear 2.24
1.5 - 2021.09.16 Pierre Van Glabeke
* champs rallongés * champs rallongés
v1.4 - 15-09-2021 - Pierre Van Glabeke 1.4 - 2021.09.15 - Pierre Van Glabeke
* correction bug affichage dc2.19 * correction bug affichage dc2.19
* dc2.19 requis * dc2.19 requis
v1.3 - 21-01-2018 - Pierre Van Glabeke 1.3 - 2018.01.21 - Pierre Van Glabeke
* modif setting * modif setting
* modif index * modif index
* modif localisation * modif localisation
v1.2 - 12-06-2016 - Pierre Van Glabeke 1.2 - 2.16.06.12 - Pierre Van Glabeke
* ajout code sécu resources.php * ajout code sécu resources.php
* modif intitulé dans admin * modif intitulé dans admin
v1.1 - 05-03-2015 - Pierre Van Glabeke 1.1 - 2.15.03.05 - Pierre Van Glabeke
* compatibilité dc2.7 * compatibilité dc2.7
* cosmétique dc2.6 * cosmétique dc2.6
* localisation * localisation
* aide intégrée * aide intégrée
* version effectuée depuis la v1.0.1 présente sur DA * version effectuée depuis la v1.0.1 présente sur DA
2010-07-15 Gaetan Guillard <gaetan@bistroduweb.com> 0.x - 2010.07.15 Gaetan Guillard <gaetan@bistroduweb.com>
* v1.0.1 - Corrections for compatibility with Dotclear 2.2 * v1.0.1 - Corrections for compatibility with Dotclear 2.2
2008-10-18 Oleksandr Syenchuk <sacha@xn--phnix-csa.net> 0.x - 2008.10.18 Oleksandr Syenchuk <sacha@xn--phnix-csa.net>
* v2008.10 - Removed theme parameter from URL * v2008.10 - Removed theme parameter from URL
0.x - 2008.08.21 Oleksandr Syenchuk <sacha@xn--phnix-csa.net>
2008-08-21 Oleksandr Syenchuk <sacha@xn--phnix-csa.net>
* Excluded themes can not be selected by user. * Excluded themes can not be selected by user.
0.x - 2008.04.21 Oleksandr Syenchuk <sacha@xn--phnix-csa.net>
2008-04-21 Oleksandr Syenchuk <sacha@xn--phnix-csa.net>
* Dotclear r1790 compatibility, see * Dotclear r1790 compatibility, see
http://dev.dotclear.net/2.0/changeset/1790 http://dev.dotclear.net/2.0/changeset/1790

View file

@ -1,7 +1,7 @@
GNU GENERAL PUBLIC LICENSE GNU GENERAL PUBLIC LICENSE
Version 2, June 1991 Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc., <http://fsf.org/> Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed. of this license document, but changing it is not allowed.
@ -290,8 +290,8 @@ to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found. the "copyright" line and a pointer to where the full notice is found.
{description} <one line to give the program's name and a brief idea of what it does.>
Copyright (C) {year} {fullname} Copyright (C) <year> <name of author>
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -329,7 +329,7 @@ necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker. `Gnomovision' (which makes passes at compilers) written by James Hacker.
{signature of Ty Coon}, 1 April 1989 <signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice Ty Coon, President of Vice
This General Public License does not permit incorporating your program into This General Public License does not permit incorporating your program into
@ -337,4 +337,3 @@ proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Lesser General library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. Public License instead of this License.

View file

@ -1,2 +1,47 @@
# Arlequin # README
Permettre aux visiteurs de choisir un thème
[![Release](https://img.shields.io/github/v/release/JcDenis/arlequin)](https://github.com/JcDenis/arlequin/releases)
[![Date](https://img.shields.io/github/release-date/JcDenis/arlequin)](https://github.com/JcDenis/arlequin/releases)
[![Issues](https://img.shields.io/github/issues/JcDenis/arlequin)](https://github.com/JcDenis/arlequin/issues)
[![Dotclear](https://img.shields.io/badge/dotclear-v2.24-blue.svg)](https://fr.dotclear.org/download)
[![Dotaddict](https://img.shields.io/badge/dotaddict-official-green.svg)](https://plugins.dotaddict.org/dc2/details/arlequin)
[![License](https://img.shields.io/github/license/JcDenis/arlequin)](https://github.com/JcDenis/arlequin/blob/master/LICENSE)
## WHAT IS ARLEQUIN ?
_arlequin_ is a plugin for the open-source
web publishing software called Dotclear.
It allows visitors to select a theme on your blog.
## REQUIREMENTS
_arlequin_ requires:
* content admin permissions to manage theme and public menu
* Dotclear 2.24
## USAGE
First install _arlequin_, manualy from a zip package or from
Dotaddict repository. (See Dotclear's documentation to know how do this)
You can manage _arlequin_ from blog admin sidebar menu
''Arlequin'' on sidebar or you can add dashboard icon,
you should also add widget to allow visitor to select a theme.
## LINKS
* License : [GNU GPL v2](https://www.gnu.org/licenses/old-licenses/lgpl-2.0.html)
* Source & contribution : [GitHub Page](https://github.com/JcDenis/arlequin)
* Packages & details : [Dotaddict Page](https://plugins.dotaddict.org/dc2/details/arlequin)
* Discuss and help : [Dotclear Forum](http://forum.dotclear.org/viewtopic.php?id=48345)
## CONTRIBUTORS
* Oleksandr Syenchuk (author)
* Gaetan Guillard
* Pierre Van Glabeke
* Jean-Christian Denis
You are welcome to contribute to this code.

View file

@ -1,36 +1,44 @@
<?php /* -*- tab-width: 5; indent-tabs-mode: t; c-basic-offset: 5 -*- */ <?php
/***************************************************************\ /**
* This is 'Arlequin', a plugin for Dotclear 2 * * @brief arlequin, a plugin for Dotclear 2
* * *
* Copyright (c) 2007,2015 * * @package Dotclear
* Oleksandr Syenchuk and contributors. * * @subpackage Plugin
* * *
* This is an open source software, distributed under the GNU * * @author Oleksandr Syenchuk, Pierre Van Glabeke and contributors
* General Public License (version 2) terms and conditions. * *
* * * @copyright Jean-Crhistian Denis
* You should have received a copy of the GNU General Public * * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
* License along with 'Arlequin' (see COPYING.txt); * */
* if not, write to the Free Software Foundation, Inc., * if (!defined('DC_CONTEXT_ADMIN')) {
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * return;
\***************************************************************/
if (!defined('DC_CONTEXT_ADMIN')) { return; }
$_menu['Blog']->addItem(__('Arlequin'),'plugin.php?p=arlequin',
'index.php?pf=arlequin/icon.png',
preg_match('/plugin.php\?p=arlequin(&.*)?$/',$_SERVER['REQUEST_URI']),
$core->auth->check('contentadmin',$core->blog->id));
require dirname(__FILE__).'/_widgets.php';
$core->addBehavior('adminDashboardFavorites','arlequinDashboardFavorites');
function arlequinDashboardFavorites($core,$favs)
{
$favs->register('arlequin', array(
'title' => __('Arlequin'),
'url' => 'plugin.php?p=arlequin',
'small-icon' => 'index.php?pf=arlequin/icon.png',
'large-icon' => 'index.php?pf=arlequin/icon-big.png',
'permissions' => 'usage,contentadmin'
));
} }
require __DIR__ . '/_widgets.php';
// Admin sidebar menu
dcCore::app()->menu[dcAdmin::MENU_BLOG]->addItem(
__('Arlequin'),
dcCore::app()->adminurl->get('admin.plugin.' . basename(__DIR__)),
dcPage::getPF(basename(__DIR__) . '/icon.png'),
preg_match(
'/' . preg_quote(dcCore::app()->adminurl->get('admin.plugin.' . basename(__DIR__))) . '(&.*)?$/',
$_SERVER['REQUEST_URI']
),
dcCore::app()->auth->check(dcCore::app()->auth->makePermissions([
dcAuth::PERMISSION_CONTENT_ADMIN,
]), dcCore::app()->blog->id)
);
// Admin dashbaord favorite
dcCore::app()->addBehavior('adminDashboardFavoritesV2', function ($favs) {
$favs->register(basename(__DIR__), [
'title' => __('Arlequin'),
'url' => dcCore::app()->adminurl->get('admin.plugin.' . basename(__DIR__)),
'small-icon' => dcPage::getPF(basename(__DIR__) . '/icon.png'),
'large-icon' => dcPage::getPF(basename(__DIR__) . '/icon-big.png'),
'permissions' => dcCore::app()->auth->makePermissions([
dcAuth::PERMISSION_CONTENT_ADMIN,
]),
]);
});

View file

@ -1,30 +1,32 @@
<?php /* -*- tab-width: 5; indent-tabs-mode: t; c-basic-offset: 5 -*- */ <?php
/***************************************************************\ /**
* This is 'Arlequin', a plugin for Dotclear 2 * * @brief arlequin, a plugin for Dotclear 2
* * *
* Copyright (c) 2007,2015 * * @package Dotclear
* Oleksandr Syenchuk and contributors. * * @subpackage Plugin
* * *
* This is an open source software, distributed under the GNU * * @author Oleksandr Syenchuk, Pierre Van Glabeke and contributors
* General Public License (version 2) terms and conditions. * *
* * * @copyright Jean-Crhistian Denis
* You should have received a copy of the GNU General Public * * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
* License along with 'Arlequin' (see COPYING.txt); * */
* if not, write to the Free Software Foundation, Inc., * if (!defined('DC_RC_PATH')) {
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * return;
\***************************************************************/ }
if (!defined('DC_RC_PATH')) { return; }
$this->registerModule( $this->registerModule(
'Arlequin', 'Arlequin',
'Allows visitors choose a theme', 'Allows visitors choose a theme',
'Oleksandr Syenchuk, Pierre Van Glabeke', 'Oleksandr Syenchuk, Pierre Van Glabeke and contributors',
'1.5', '1.6',
[ [
'requires' => [['core', '2.19']], 'requires' => [['core', '2.24']],
'permissions' => 'contentadmin', 'permissions' => dcCore::app()->auth->makePermissions([
dcAuth::PERMISSION_CONTENT_ADMIN,
]),
'type' => 'plugin', 'type' => 'plugin',
'support' => 'http://forum.dotclear.org/viewtopic.php?id=48345', 'support' => 'http://forum.dotclear.org/viewtopic.php?id=48345',
'details' => 'http://plugins.dotaddict.org/dc2/details/arlequin' 'details' => 'https://plugins.dotaddict.org/dc2/details/' . basename(__DIR__),
'repository' => 'https://raw.githubusercontent.com/JcDenis/' . basename(__DIR__) . '/master/dcstore.xml',
] ]
); );

View file

@ -1,76 +1,70 @@
<?php /* -*- tab-width: 5; indent-tabs-mode: t; c-basic-offset: 5 -*- */ <?php
/***************************************************************\ /**
* This is 'Arlequin', a plugin for Dotclear 2 * * @brief arlequin, a plugin for Dotclear 2
* * *
* Copyright (c) 2007,2015 * * @package Dotclear
* Oleksandr Syenchuk and contributors. * * @subpackage Plugin
* * *
* This is an open source software, distributed under the GNU * * @author Oleksandr Syenchuk, Pierre Van Glabeke and contributors
* General Public License (version 2) terms and conditions. * *
* * * @copyright Jean-Crhistian Denis
* You should have received a copy of the GNU General Public * * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
* License along with 'Arlequin' (see COPYING.txt); * */
* if not, write to the Free Software Foundation, Inc., * if (!defined('DC_RC_PATH')) {
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * return;
\***************************************************************/ }
if (!defined('DC_RC_PATH')) { return; }
require dirname(__FILE__).'/_widgets.php'; require __DIR__ . '/_widgets.php';
/** @doc publicArlequinEngine::init();
Arlequin public interface dcCore::app()->addBehavior('publicBeforeDocumentV2', ['publicArlequinEngine','adjustCache']);
*/ dcCore::app()->tpl->addValue('themesList', ['publicArlequinInterface','template']);
publicArlequinEngine::trigger($core->blog);
$core->addBehavior('publicBeforeDocument',array('publicArlequinEngine','adjustCache'));
$core->tpl->addValue('themesList',array('publicArlequinInterface','template'));
class publicArlequinEngine class publicArlequinEngine
{ {
public static $cookie_theme; public static $cookie_theme;
public static $cookie_upddt; public static $cookie_upddt;
public static function trigger($blog) public static function init()
{ {
$cname = base_convert($blog->uid,16,36); $cname = base_convert(dcCore::app()->blog->uid, 16, 36);
self::$cookie_theme = 'dc_theme_'.$cname; self::$cookie_theme = 'dc_theme_' . $cname;
self::$cookie_upddt = 'dc_user_upddt_'.$cname; self::$cookie_upddt = 'dc_user_upddt_' . $cname;
if (!empty($_REQUEST['theme'])) { if (!empty($_REQUEST['theme'])) {
# Set cookie for 365 days # Set cookie for 365 days
setcookie(self::$cookie_theme,$_REQUEST['theme'],time()+31536000,'/'); setcookie(self::$cookie_theme, $_REQUEST['theme'], time() + 31536000, '/');
setcookie(self::$cookie_upddt,time(),time()+31536000,'/'); setcookie(self::$cookie_upddt, (string) time(), time() + 31536000, '/');
# Redirect if needed # Redirect if needed
if (isset($_GET['theme'])) { if (isset($_GET['theme'])) {
$p = '/(\?|&)theme(=.*)?$/'; $p = '/(\?|&)theme(=.*)?$/';
http::redirect(preg_replace($p,'',http::getSelfURI())); http::redirect(preg_replace($p, '', http::getSelfURI()));
} }
# Switch theme # Switch theme
self::switchTheme($blog,$_REQUEST['theme']); self::switchTheme($_REQUEST['theme']);
} } elseif (!empty($_COOKIE[self::$cookie_theme])) {
elseif (!empty($_COOKIE[self::$cookie_theme])) { self::switchTheme($_COOKIE[self::$cookie_theme]);
self::switchTheme($blog,$_COOKIE[self::$cookie_theme]);
} }
} }
public static function adjustCache($core) public static function adjustCache()
{ {
if (!empty($_COOKIE[self::$cookie_upddt])) { if (!empty($_COOKIE[self::$cookie_upddt])) {
$GLOBALS['mod_ts'][] = (integer) $_COOKIE[self::$cookie_upddt]; dcCore::app()->cache['mod_ts'][] = (int) $_COOKIE[self::$cookie_upddt];
} }
} }
public static function switchTheme($blog,$theme) public static function switchTheme($theme)
{ {
if ($blog->settings->arlequinMulti->mt_exclude) { if (dcCore::app()->blog->settings->arlequinMulti->mt_exclude) {
if (in_array($theme,explode('/',$blog->settings->arlequinMulti->mt_exclude))) { if (in_array($theme, explode('/', dcCore::app()->blog->settings->arlequinMulti->mt_exclude))) {
return; return;
} }
} }
$GLOBALS['__theme'] = $blog->settings->system->theme = $theme; dcCore::app()->public->theme = dcCore::app()->blog->settings->system->theme = $theme;
} }
} }
@ -86,22 +80,18 @@ class publicArlequinInterface
return '<?php echo publicArlequinInterface::getHTML(); ?>'; return '<?php echo publicArlequinInterface::getHTML(); ?>';
} }
public static function getHTML($w=false) public static function getHTML($w = false)
{ {
global $core; if ($w->offline) {
if ($w->offline)
return;
$cfg = @unserialize($core->blog->settings->arlequinMulti->get('mt_cfg'));
if (($w->homeonly == 1 && $core->url->type != 'default') ||
($w->homeonly == 2 && $core->url->type == 'default')) {
return; return;
} }
if ($cfg === false || if (!$w->checkHomeOnly(dcCore::app()->url->type)) {
($names = self::getNames()) === false) { return;
}
$cfg = @unserialize(dcCore::app()->blog->settings->arlequinMulti->get('mt_cfg'));
if ($cfg === false || ($names = self::getNames()) === false) {
return; return;
} }
@ -110,23 +100,20 @@ class publicArlequinInterface
$s_url = $e_url = http::getSelfURI(); $s_url = $e_url = http::getSelfURI();
# If theme setting is already present in URL, we will replace its value # If theme setting is already present in URL, we will replace its value
$replace = preg_match('/(\\?|&)theme\\=[^&]*/',$e_url); $replace = preg_match('/(\\?|&)theme\\=[^&]*/', $e_url);
# URI extension to send theme setting by query string # URI extension to send theme setting by query string
if ($replace) { if ($replace) {
$ext = ''; $ext = '';
} } elseif (strpos($e_url, '?') === false) {
elseif (strpos($e_url,'?') === false) {
$ext = '?theme='; $ext = '?theme=';
} } else {
else { $ext = (substr($e_url, -1) == '?' ? '' : '&amp;') . 'theme=';
$ext = (substr($e_url,-1) == '?' ? '' : '&amp;').'theme=';
} }
$res = ''; $res = '';
foreach ($names as $k=>$v) foreach ($names as $k => $v) {
{ if ($k == dcCore::app()->public->theme) {
if ($k == $GLOBALS['__theme']) {
$format = $cfg['a_html']; $format = $cfg['a_html'];
} else { } else {
$format = $cfg['e_html']; $format = $cfg['e_html'];
@ -135,18 +122,22 @@ class publicArlequinInterface
if ($replace) { if ($replace) {
$e_url = preg_replace( $e_url = preg_replace(
'/(\\?|&)(theme\\=)([^&]*)/', '/(\\?|&)(theme\\=)([^&]*)/',
'$1${2}'.addcslashes($k,'$\\'), '$1${2}' . addcslashes($k, '$\\'),
$e_url); $e_url
);
$val = ''; $val = '';
} } else {
else {
$val = html::escapeHTML(rawurlencode($k)); $val = html::escapeHTML(rawurlencode($k));
} }
$res .= sprintf($format, $res .= sprintf(
$e_url,$ext,$val, $format,
$e_url,
$ext,
$val,
html::escapeHTML($v['name']), html::escapeHTML($v['name']),
html::escapeHTML($v['desc']), html::escapeHTML($v['desc']),
html::escapeHTML($k)); html::escapeHTML($k)
);
} }
# Nothing to display # Nothing to display
@ -154,15 +145,15 @@ class publicArlequinInterface
return; return;
} }
$res = sprintf($cfg['s_html'],$s_url,$res); $res = sprintf($cfg['s_html'], $s_url, $res);
if ($w) { if ($w) {
return $w->renderDiv(
$res = $w->content_only,
($w->title ? $w->renderTitle(html::escapeHTML($w->title)) : ''). 'arlequin ' . $w->class,
$res; '',
($w->title ? $w->renderTitle(html::escapeHTML($w->title)) : '') . $res
return $w->renderDiv($w->content_only,'arlequin '.$w->class,'',$res); );
} }
return $res; return $res;
@ -170,15 +161,13 @@ class publicArlequinInterface
public static function getNames() public static function getNames()
{ {
global $core; $mt_exclude = dcCore::app()->blog->settings->arlequinMulti->mt_exclude;
$exclude = [];
$mt_exclude = $core->blog->settings->arlequinMulti->mt_exclude;
$exclude = array();
if (!empty($mt_exclude)) { if (!empty($mt_exclude)) {
$exclude = array_flip(explode('/',$core->blog->settings->arlequinMulti->mt_exclude)); $exclude = array_flip(explode('/', dcCore::app()->blog->settings->arlequinMulti->mt_exclude));
} }
$names = array_diff_key($core->themes->getModules(),$exclude); $names = array_diff_key(dcCore::app()->themes->getModules(), $exclude);
return empty($names) ? false : $names; return empty($names) ? false : $names;
} }

View file

@ -1,73 +1,66 @@
<?php /* -*- tab-width: 5; indent-tabs-mode: t; c-basic-offset: 5 -*- */ <?php
/***************************************************************\ /**
* This is 'Arlequin', a plugin for Dotclear 2 * * @brief arlequin, a plugin for Dotclear 2
* * *
* Copyright (c) 2007-2015 * * @package Dotclear
* Oleksandr Syenchuk and contributors. * * @subpackage Plugin
* * *
* This is an open source software, distributed under the GNU * * @author Oleksandr Syenchuk, Pierre Van Glabeke and contributors
* General Public License (version 2) terms and conditions. * *
* * * @copyright Jean-Crhistian Denis
* You should have received a copy of the GNU General Public * * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
* License along with 'Arlequin' (see COPYING.txt); * */
* if not, write to the Free Software Foundation, Inc., * if (!defined('DC_RC_PATH')) {
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * return;
\***************************************************************/ }
if (!defined('DC_RC_PATH')) { return; }
$core->addBehavior('initWidgets',array('adminArlequin','initWidgets')); dcCore::app()->addBehavior('initWidgets', ['adminArlequin','initWidgets']);
class adminArlequin class adminArlequin
{ {
public static $initialized = false;
public static function initWidgets($w) public static function initWidgets($w)
{ {
$w->create('arlequin',__('Arlequin'),array('publicArlequinInterface','arlequinWidget'), $w->create(
'arlequin',
__('Arlequin'),
['publicArlequinInterface','arlequinWidget'],
null, null,
__('Theme switcher')); __('Theme switcher')
$w->arlequin->setting('title',__('Title:'),__('Choose a theme'));
$w->arlequin->setting('homeonly',__('Display on:'),0,'combo',
array(
__('All pages') => 0,
__('Home page only') => 1,
__('Except on home page') => 2
) )
); ->addTitle(__('Choose a theme'))
$w->arlequin->setting('content_only',__('Content only'),0,'check'); ->addHomeOnly()
$w->arlequin->setting('class',__('CSS class:'),''); ->addContentOnly()
$w->arlequin->setting('offline',__('Offline'),0,'check'); ->addClass()
->addOffline();
} }
public static function getDefaults() public static function getDefaults()
{ {
return array( return [
'e_html'=>'<li><a href="%1$s%2$s%3$s">%4$s</a></li>', 'e_html' => '<li><a href="%1$s%2$s%3$s">%4$s</a></li>',
'a_html'=>'<li><strong>%4$s</strong></li>', 'a_html' => '<li><strong>%4$s</strong></li>',
's_html'=>'<ul>%2$s</ul>'); 's_html' => '<ul>%2$s</ul>',
];
} }
public static function loadSettings($settings,&$initialized) public static function loadSettings($settings)
{ {
global $core; self::$initialized = false;
$initialized = false;
$mt_cfg = @unserialize($settings->arlequinMulti->get('mt_cfg')); $mt_cfg = @unserialize($settings->arlequinMulti->get('mt_cfg'));
$mt_exclude = $settings->arlequinMulti->get('mt_exclude'); $mt_exclude = $settings->arlequinMulti->get('mt_exclude');
// Paramètres corrompus ou inexistants // Paramètres corrompus ou inexistants
if ($mt_cfg === false || if ($mt_cfg === false || $mt_exclude === null || !(isset($mt_cfg['e_html']) && isset($mt_cfg['a_html']) && isset($mt_cfg['s_html']))) {
$mt_exclude === null ||
!(isset($mt_cfg['e_html']) &&
isset($mt_cfg['a_html']) &&
isset($mt_cfg['s_html'])))
{
$mt_cfg = adminArlequin::getDefaults(); $mt_cfg = adminArlequin::getDefaults();
$settings->addNameSpace('arlequinMulti'); $settings->addNamespace('arlequinMulti');
$settings->arlequinMulti->put('mt_cfg',serialize($mt_cfg),'string','Arlequin configuration'); $settings->arlequinMulti->put('mt_cfg', serialize($mt_cfg), 'string', 'Arlequin configuration');
$settings->arlequinMulti->put('mt_exclude','customCSS','string','Excluded themes'); $settings->arlequinMulti->put('mt_exclude', 'customCSS', 'string', 'Excluded themes');
$initialized = true; self::$initialized = true;
$core->blog->triggerBlog(); dcCore::app()->blog->triggerBlog();
} }
return array($mt_cfg,$mt_exclude); return [$mt_cfg,$mt_exclude];
} }
} }

13
dcstore.xml Normal file
View file

@ -0,0 +1,13 @@
<?xml version="1.0"?>
<modules xmlns:da="http://dotaddict.org/da/">
<module id="arlequin">
<name>Arlequin</name>
<version>1.6</version>
<author>Oleksandr Syenchuk, Pierre Van Glabeke and contributors</author>
<desc>Allows visitors choose a theme</desc>
<file>https://github.com/JcDenis/arlequin/releases/download/v1.6/plugin-arlequin.zip</file>
<da:dcmin>2.24</da:dcmin>
<da:details>https://plugins.dotaddict.org/dc2/details/arlequin</da:details>
<da:support>http://forum.dotclear.org/viewtopic.php?id=48345</da:support>
</module>
</modules>

View file

@ -1,22 +1,22 @@
<?php /* -*- tab-width: 5; indent-tabs-mode: t; c-basic-offset: 5 -*- */ <?php
/***************************************************************\ /**
* This is 'Arlequin', a plugin for Dotclear 2 * * @brief arlequin, a plugin for Dotclear 2
* * *
* Copyright (c) 2007,2015 * * @package Dotclear
* Oleksandr Syenchuk and contributors. * * @subpackage Plugin
* * *
* This is an open source software, distributed under the GNU * * @author Oleksandr Syenchuk, Pierre Van Glabeke and contributors
* General Public License (version 2) terms and conditions. * *
* * * @copyright Jean-Crhistian Denis
* You should have received a copy of the GNU General Public * * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
* License along with 'Arlequin' (see COPYING.txt); * */
* if not, write to the Free Software Foundation, Inc., * if (!defined('DC_CONTEXT_ADMIN')) {
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * return;
\***************************************************************/ }
$mt_models = array(); $mt_models = [];
/** Syntaxe pour ajouter vos propres modèles prédéfinis : /* Syntaxe pour ajouter vos propres modèles prédéfinis :
$mt_models[] = array( $mt_models[] = array(
'name'=>__('Model name'), // Nom du modèle prédéfini, éventuellement 'name'=>__('Model name'), // Nom du modèle prédéfini, éventuellement
@ -28,22 +28,21 @@ $mt_models[] = array(
//*/ //*/
$mt_models[] = array( $mt_models[] = [
'name'=>__('Bullets list'), 'name' => __('Bullets list'),
's_html'=>'<ul>%2$s</ul>', 's_html' => '<ul>%2$s</ul>',
'e_html'=>'<li><a href="%1$s%2$s%3$s">%4$s</a></li>', 'e_html' => '<li><a href="%1$s%2$s%3$s">%4$s</a></li>',
'a_html'=>'<li><strong>%4$s</strong></li>' 'a_html' => '<li><strong>%4$s</strong></li>',
); ];
$mt_models[] = array( $mt_models[] = [
'name'=>__('Scrolled list'), 'name' => __('Scrolled list'),
's_html'=> 's_html' => '<form action="%1$s" method="post">' . "\n" .
'<form action="%1$s" method="post">'."\n". '<p><select name="theme">' . "\n" .
'<p><select name="theme">'."\n". '%2$s' . "\n" .
'%2$s'."\n". '</select>' . "\n" .
'</select>'."\n". '<input type="submit" value="' . __('ok') . '"/></p>' . "\n" .
'<input type="submit" value="'.__('ok').'"/></p>'."\n".
'</form>', '</form>',
'e_html'=>'<option value="%3$s">%4$s</option>', 'e_html' => '<option value="%3$s">%4$s</option>',
'a_html'=>'<option value="%3$s" selected="selected" disabled="disabled">%4$s ('.__('active theme').')</option>' 'a_html' => '<option value="%3$s" selected="selected" disabled="disabled">%4$s (' . __('active theme') . ')</option>',
); ];

189
index.php
View file

@ -1,141 +1,114 @@
<?php /* -*- tab-width: 5; indent-tabs-mode: t; c-basic-offset: 5 -*- */ <?php
/***************************************************************\ /**
* This is 'Arlequin', a plugin for Dotclear 2 * * @brief arlequin, a plugin for Dotclear 2
* * *
* Copyright (c) 2007,2015 * * @package Dotclear
* Oleksandr Syenchuk and contributors. * * @subpackage Plugin
* * *
* This is an open source software, distributed under the GNU * * @author Oleksandr Syenchuk, Pierre Van Glabeke and contributors
* General Public License (version 2) terms and conditions. * *
* * * @copyright Jean-Crhistian Denis
* You should have received a copy of the GNU General Public * * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
* License along with 'Arlequin' (see COPYING.txt); * */
* if not, write to the Free Software Foundation, Inc., * if (!defined('DC_CONTEXT_ADMIN')) {
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * return;
\***************************************************************/ }
if (!defined('DC_CONTEXT_ADMIN')) { return; }
$page_title = __('Arlequin'); $mt_models = [];
try try {
{ include __DIR__ . '/inc/models.php';
include dirname(__FILE__).'/models.php';
$messages = array(); // Initialisation
dcCore::app()->blog->settings->addNamespace('arlequinMulti');
[$mt_cfg, $mt_exclude] = adminArlequin::loadSettings(dcCore::app()->blog->settings);
if (adminArlequin::$initialized) {
dcAdminNotices::AddSuccessNotice(__('Settings have been reinitialized.'));
}
/* Initialisation // Enregistrement des données depuis les formulaires
--------------------------------------------------- */ if (isset($_POST['mt_action_config'])) {
$core->blog->settings->addNameSpace('arlequinMulti');
list($mt_cfg,$mt_exclude) =
adminArlequin::loadSettings ($core->blog->settings,$initialized);
/* Enregistrement des données depuis les formulaires
--------------------------------------------------- */
if (isset($_POST['mt_action_config']))
{
$mt_cfg['e_html'] = $_POST['e_html']; $mt_cfg['e_html'] = $_POST['e_html'];
$mt_cfg['a_html'] = $_POST['a_html']; $mt_cfg['a_html'] = $_POST['a_html'];
$mt_cfg['s_html'] = $_POST['s_html']; $mt_cfg['s_html'] = $_POST['s_html'];
$mt_exclude = $_POST['mt_exclude']; $mt_exclude = $_POST['mt_exclude'];
} }
/* Traitement des requêtes // Traitement des requêtes
--------------------------------------------------- */ if (isset($_POST['mt_action_config'])) {
dcCore::app()->blog->settings->arlequinMulti->put('mt_cfg', serialize($mt_cfg));
if (isset($_POST['mt_action_config'])) dcCore::app()->blog->settings->arlequinMulti->put('mt_exclude', $mt_exclude);
{ dcAdminNotices::AddSuccessNotice(__('System settings have been updated.'));
$core->blog->settings->arlequinMulti->put('mt_cfg',serialize($mt_cfg)); dcCore::app()->blog->triggerBlog();
$core->blog->settings->arlequinMulti->put('mt_exclude',$mt_exclude); dcCore::app()->adminurl->redirect('admin.plugin.' . basename(__DIR__), ['config' => 1]);
$messages[] = __('Settings have been successfully updated.');
$core->blog->triggerBlog();
http::redirect($p_url.'&config=1');
} }
if (isset($_POST['mt_action_restore'])) if (isset($_POST['mt_action_restore'])) {
{ dcCore::app()->blog->settings->arlequinMulti->drop('mt_cfg');
$core->blog->settings->arlequinMulti->drop('mt_cfg'); dcCore::app()->blog->settings->arlequinMulti->drop('mt_exclude');
$core->blog->settings->arlequinMulti->drop('mt_exclude'); dcAdminNotices::AddSuccessNotice(__('Settings have been reinitialized.'));
$core->blog->triggerBlog(); dcCore::app()->blog->triggerBlog();
http::redirect($p_url.'&restore=1'); dcCore::app()->adminurl->redirect('admin.plugin.' . basename(__DIR__), ['restore' => 1]);
} }
} } catch (Exception $e) {
catch (Exception $e) dcCore::app()->error->add($e->getMessage());
{
$core->error->add($e->getMessage());
}
/* DISPLAY
--------------------------------------------------- */
if ($initialized) {
$messages[] = __('Settings have been reinitialized.');
} }
// Headers // Headers
$jsModels = '';
$jsModels = ''; $cslashes = "\n\"\'"; $cslashes = "\n\"\'";
foreach ($mt_models as $m) foreach ($mt_models as $m) { // @phpstan-ignore-line
{ $jsModels .= "\t" .
$jsModels .= "\t". 'arlequin.addModel(' .
'arlequin.addModel('. '"' . html::escapeJS($m['name']) . '",' .
'"'.html::escapeJS($m['name']).'",'. '"' . addcslashes($m['s_html'], $cslashes) . '",' .
'"'.addcslashes($m['s_html'],$cslashes).'",'. '"' . addcslashes($m['e_html'], $cslashes) . '",' .
'"'.addcslashes($m['e_html'],$cslashes).'",'. '"' . addcslashes($m['a_html'], $cslashes) . '"' .
'"'.addcslashes($m['a_html'],$cslashes).'"'.
");\n"; ");\n";
} }
// DISPLAY
echo ' echo '
<html><head> <html><head><title>' . __('Arlequin') . '</title>' .
<title>'.$page_title.'</title>'. dcPage::jsLoad(dcPage::getPF(basename(__DIR__) . '/js/models.js')) . '
dcPage::jsLoad('index.php?pf=arlequin/js/models.js').'
<script type="text/javascript"> <script type="text/javascript">
//<![CDATA[ //<![CDATA[
arlequin.msg.predefined_models = "'.html::escapeJS(__('Predefined models')).'"; arlequin.msg.predefined_models = "' . html::escapeJS(__('Predefined models')) . '";
arlequin.msg.select_model = "'.html::escapeJS(__('Select a model')).'"; arlequin.msg.select_model = "' . html::escapeJS(__('Select a model')) . '";
arlequin.msg.user_defined = "'.html::escapeJS(__('User defined')).'"; arlequin.msg.user_defined = "' . html::escapeJS(__('User defined')) . '";
$(function() { $(function() {
arlequin.addDefault(); arlequin.addDefault();
'.$jsModels.' ' . $jsModels . '
}); });
//]]> //]]>
</script> </script>
</head><body>'. </head><body>' .
dcPage::breadcrumb( dcPage::breadcrumb([
array( html::escapeHTML(dcCore::app()->blog->name) => '',
html::escapeHTML($core->blog->name) => '', '<span class="page-title">' . __('Arlequin') . '</span>' => '',
'<span class="page-title">'.$page_title.'</span>' => '' ]) .
)); dcPage::notices() . '
// Messages <form action="' . dcCore::app()->adminurl->get('admin.plugin.' . basename(__DIR__)) . '" method="post">
if (!empty($_GET['config'])) { <h4>' . __('Switcher display format') . '</h4>
dcPage::success(__('Settings have been successfully updated.'));
}
if (!empty($_GET['restore'])) {
dcPage::success(__('Settings have been reinitialized.'));
}
echo
'<form action="'.$p_url.'" method="post">
<div class="fieldset two-cols"><h4>'.__('Switcher display format').'</h4>
<div id="models"></div> <div id="models"></div>
<p class="col"><label for="s_html">'.__('Switcher HTML code:').'</label> '.
form::textArea('s_html',50,10,html::escapeHTML($mt_cfg['s_html'])).'</p>
<div class="col">
<p><label>'.__('Item HTML code:').' '.
form::field('e_html',50,'200',html::escapeHTML($mt_cfg['e_html'])).'</label></p>
<p><label>'.__('Active item HTML code:').' '.
form::field('a_html',50,'200',html::escapeHTML($mt_cfg['a_html'])).'</label></p>
</div><br class="clear" />
<p><label>'.__('Excluded themes (separated by slashs \'/\'):').' '. <div class="two-boxes odd">
form::field(array('mt_exclude'),50,'200',html::escapeHTML($mt_exclude)).'</label></p> <p><label for="s_html">' . __('Switcher HTML code:') . '</label> ' .
<p class="info">'.__('The names to be taken into account are those of the theme files.').'</p> form::textArea('s_html', 50, 10, html::escapeHTML($mt_cfg['s_html'])) . '</p>
</div><div class="two-boxes even">
<p><label for="e_html">' . __('Item HTML code:') . '</label> ' .
form::field('e_html', 50, 200, html::escapeHTML($mt_cfg['e_html'])) . '</p>
<p><label for="a_html">' . __('Active item HTML code:') . '</label> ' .
form::field('a_html', 50, 200, html::escapeHTML($mt_cfg['a_html'])) . '</p>
</div><div class="two-boxes odd">
<p><label for="mt_exclude">' . __("Excluded themes (separated by slashs '/'):") . '</label> ' .
form::field('mt_exclude', 50, 200, html::escapeHTML($mt_exclude)) . '</p>
<p class="info">' . __('The names to be taken into account are those of the theme files.') . '</p>
</div> </div>
<p><input type="submit" name="mt_action_config" value="'.__('Save').'" /> <p>
<input type="submit" name="mt_action_restore" value="'.__('Restore defaults').'" />'. <input type="submit" name="mt_action_config" value="' . __('Save') . '" />
(is_callable(array($core,'formNonce')) ? $core->formNonce() : '').'</p> <input type="submit" name="mt_action_restore" value="' . __('Restore defaults') . '" />' .
dcCore::app()->formNonce() . '</p>
</form>'; </form>';
dcPage::helpBlock('arlequin'); ?> dcPage::helpBlock('arlequin'); ?>

View file

@ -1,20 +1,17 @@
<?php <?php
/***************************************************************\ /**
* This is 'Arlequin', a plugin for Dotclear 2 * * @brief arlequin, a plugin for Dotclear 2
* * *
* Copyright (c) 2007,2010 * * @package Dotclear
* Oleksandr Syenchuk and contributors. * * @subpackage Plugin
* * *
* This is an open source software, distributed under the GNU * * @author Oleksandr Syenchuk, Pierre Van Glabeke and contributors
* General Public License (version 2) terms and conditions. * *
* * * @copyright Jean-Crhistian Denis
* You should have received a copy of the GNU General Public * * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
* License along with 'Arlequin' (see COPYING.txt); * */
* if not, write to the Free Software Foundation, Inc., * if (!defined('DC_RC_PATH')) {
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * return;
\***************************************************************/
if (!defined('DC_RC_PATH')){return;}
if (!isset($__resources['help']['arlequin']))
{
$__resources['help']['arlequin'] = dirname(__FILE__).'/help/arlequin.html';
} }
dcCore::app()->resources['help']['arlequin'] = __DIR__ . '/help/arlequin.html';

View file

@ -1,84 +1,66 @@
# Language: Français
# Module: arlequin - 1.3
# Date: 2018-01-22 17:11:42
# Translated with translater 2017.05.10
msgid "" msgid ""
msgstr "" msgstr ""
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
"Project-Id-Version: arlequin 1.3\n" "Project-Id-Version: arlequin 1.5\n"
"POT-Creation-Date: \n" "POT-Creation-Date: \n"
"PO-Revision-Date: 2018-01-22T17:11:42+00:00\n" "PO-Revision-Date: 2022-12-14T22:24:43+00:00\n"
"Last-Translator: brol\n" "Last-Translator: Jean-Crhistian Denis\n"
"Language-Team: \n" "Language-Team: \n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n"
#: _widgets.php:26
msgid "Theme switcher" msgid "Theme switcher"
msgstr "Sélecteur de thème" msgstr "Sélecteur de thème"
#: _widgets.php:27
msgid "Choose a theme" msgid "Choose a theme"
msgstr "Choisissez un thème" msgstr "Choisissez un thème"
#: index.php:72
#: index.php:116
msgid "Settings have been reinitialized."
msgstr "Les paramètres ont été réinitialisés."
#: index.php:95
msgid "Predefined models"
msgstr "Modèles prédéfinis"
#: index.php:96
msgid "Select a model"
msgstr "Sélectionnez un modèle"
#: index.php:121
msgid "Switcher display format"
msgstr "Format d'affichage du sélecteur"
#: index.php:123
msgid "Switcher HTML code:"
msgstr "Code HTML du sélecteur :"
#: index.php:126
msgid "Item HTML code:"
msgstr "Code HTML d'un item :"
#: index.php:128
msgid "Active item HTML code:"
msgstr "Code HTML d'un item actif :"
#: index.php:134
msgid "The names to be taken into account are those of the theme files."
msgstr "Les noms à prendre en compte sont ceux des dossiers de thème."
#: index.php:137
msgid "Restore defaults"
msgstr "Réinitialiser les paramètres"
#: models.php:22
msgid "Model name" msgid "Model name"
msgstr "Nom du modèle" msgstr "Nom du modèle"
#: models.php:32
msgid "Bullets list" msgid "Bullets list"
msgstr "Liste à puces" msgstr "Liste à puces"
#: models.php:39
msgid "Scrolled list" msgid "Scrolled list"
msgstr "Liste déroulante" msgstr "Liste déroulante"
#: models.php:48
msgid "active theme" msgid "active theme"
msgstr "thème actif" msgstr "thème actif"
msgid "Settings have been reinitialized."
msgstr "Les paramètres ont été réinitialisés."
msgid "System settings have been updated."
msgstr "Les paramètres on tété mis à jour."
msgid "Predefined models"
msgstr "Modèles prédéfinis"
msgid "Select a model"
msgstr "Sélectionnez un modèle"
msgid "Switcher display format"
msgstr "Format d'affichage du sélecteur"
msgid "Switcher HTML code:"
msgstr "Code HTML du sélecteur :"
msgid "Item HTML code:"
msgstr "Code HTML d'un item :"
msgid "Active item HTML code:"
msgstr "Code HTML d'un item actif :"
msgid "Excluded themes (separated by slashs '/'):" msgid "Excluded themes (separated by slashs '/'):"
msgstr "Thèmes exclus (séparés par des slashs \"/\") :" msgstr "Thèmes exclus (séparés par des slashs \"/\") :"
msgid "The names to be taken into account are those of the theme files."
msgstr "Les noms à prendre en compte sont ceux des dossiers de thème."
msgid "Restore defaults"
msgstr "Réinitialiser les paramètres"
msgid "Arlequin - theme switcher configuration" msgid "Arlequin - theme switcher configuration"
msgstr "Arlequin - configuration du sélecteur de thème" msgstr "Arlequin - configuration du sélecteur de thème"

View file

@ -1,20 +1,17 @@
<?php <?php
/***************************************************************\ /**
* This is 'Arlequin', a plugin for Dotclear 2 * * @brief arlequin, a plugin for Dotclear 2
* * *
* Copyright (c) 2007,2010 * * @package Dotclear
* Oleksandr Syenchuk and contributors. * * @subpackage Plugin
* * *
* This is an open source software, distributed under the GNU * * @author Oleksandr Syenchuk, Pierre Van Glabeke and contributors
* General Public License (version 2) terms and conditions. * *
* * * @copyright Jean-Crhistian Denis
* You should have received a copy of the GNU General Public * * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
* License along with 'Arlequin' (see COPYING.txt); * */
* if not, write to the Free Software Foundation, Inc., * if (!defined('DC_RC_PATH')) {
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * return;
\***************************************************************/
if (!defined('DC_RC_PATH')){return;}
if (!isset($__resources['help']['arlequin']))
{
$__resources['help']['arlequin'] = dirname(__FILE__).'/help/arlequin.html';
} }
dcCore::app()->resources['help']['arlequin'] = __DIR__ . '/help/arlequin.html';