release 1.6 for dotclear 2.24

master
Jean-Christian Paul 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
v1.4 - 15-09-2021 - Pierre Van Glabeke
1.4 - 2021.09.15 - Pierre Van Glabeke
* correction bug affichage dc2.19
* dc2.19 requis
v1.3 - 21-01-2018 - Pierre Van Glabeke
1.3 - 2018.01.21 - Pierre Van Glabeke
* modif setting
* modif index
* 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
* modif intitulé dans admin
v1.1 - 05-03-2015 - Pierre Van Glabeke
1.1 - 2.15.03.05 - Pierre Van Glabeke
* compatibilité dc2.7
* cosmétique dc2.6
* localisation
* aide intégrée
* 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
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
2008-08-21 Oleksandr Syenchuk <sacha@xn--phnix-csa.net>
0.x - 2008.08.21 Oleksandr Syenchuk <sacha@xn--phnix-csa.net>
* Excluded themes can not be selected by user.
2008-04-21 Oleksandr Syenchuk <sacha@xn--phnix-csa.net>
0.x - 2008.04.21 Oleksandr Syenchuk <sacha@xn--phnix-csa.net>
* Dotclear r1790 compatibility, see
http://dev.dotclear.net/2.0/changeset/1790

23
LICENSE
View File

@ -1,12 +1,12 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
GNU GENERAL PUBLIC LICENSE
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
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
@ -56,7 +56,7 @@ patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
@ -255,7 +255,7 @@ make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
@ -277,9 +277,9 @@ YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
@ -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
the "copyright" line and a pointer to where the full notice is found.
{description}
Copyright (C) {year} {fullname}
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
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
@ -329,7 +329,7 @@ necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`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
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
library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License.

View File

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

View File

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

View File

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

13
dcstore.xml 100644
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,49 +1,48 @@
<?php /* -*- tab-width: 5; indent-tabs-mode: t; c-basic-offset: 5 -*- */
/***************************************************************\
* This is 'Arlequin', a plugin for Dotclear 2 *
* *
* Copyright (c) 2007,2015 *
* Oleksandr Syenchuk and contributors. *
* *
* This is an open source software, distributed under the GNU *
* General Public License (version 2) terms and conditions. *
* *
* You should have received a copy of the GNU General Public *
* License along with 'Arlequin' (see COPYING.txt); *
* if not, write to the Free Software Foundation, Inc., *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
\***************************************************************/
<?php
/**
* @brief arlequin, a plugin for Dotclear 2
*
* @package Dotclear
* @subpackage Plugin
*
* @author Oleksandr Syenchuk, Pierre Van Glabeke and contributors
*
* @copyright Jean-Crhistian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
if (!defined('DC_CONTEXT_ADMIN')) {
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(
'name'=>__('Model name'), // Nom du modèle prédéfini, éventuellement
// traduit dans un fichier de langue
's_html'=>'[HTML code]', // Code HTML du sélecteur de thème
'e_html'=>'[HTML code]', // Code HTML d'un item pouvant être sélectionné
'a_html'=>'[HTML code]' // Code HTML d'un item actif (thème sélectionné)
'name'=>__('Model name'), // Nom du modèle prédéfini, éventuellement
// traduit dans un fichier de langue
's_html'=>'[HTML code]', // Code HTML du sélecteur de thème
'e_html'=>'[HTML code]', // Code HTML d'un item pouvant être sélectionné
'a_html'=>'[HTML code]' // Code HTML d'un item actif (thème sélectionné)
);
//*/
$mt_models[] = array(
'name'=>__('Bullets list'),
's_html'=>'<ul>%2$s</ul>',
'e_html'=>'<li><a href="%1$s%2$s%3$s">%4$s</a></li>',
'a_html'=>'<li><strong>%4$s</strong></li>'
);
$mt_models[] = [
'name' => __('Bullets list'),
's_html' => '<ul>%2$s</ul>',
'e_html' => '<li><a href="%1$s%2$s%3$s">%4$s</a></li>',
'a_html' => '<li><strong>%4$s</strong></li>',
];
$mt_models[] = array(
'name'=>__('Scrolled list'),
's_html'=>
'<form action="%1$s" method="post">'."\n".
'<p><select name="theme">'."\n".
'%2$s'."\n".
'</select>'."\n".
'<input type="submit" value="'.__('ok').'"/></p>'."\n".
'</form>',
'e_html'=>'<option value="%3$s">%4$s</option>',
'a_html'=>'<option value="%3$s" selected="selected" disabled="disabled">%4$s ('.__('active theme').')</option>'
);
$mt_models[] = [
'name' => __('Scrolled list'),
's_html' => '<form action="%1$s" method="post">' . "\n" .
'<p><select name="theme">' . "\n" .
'%2$s' . "\n" .
'</select>' . "\n" .
'<input type="submit" value="' . __('ok') . '"/></p>' . "\n" .
'</form>',
'e_html' => '<option value="%3$s">%4$s</option>',
'a_html' => '<option value="%3$s" selected="selected" disabled="disabled">%4$s (' . __('active theme') . ')</option>',
];

209
index.php
View File

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

View File

@ -1,20 +1,17 @@
<?php
/***************************************************************\
* This is 'Arlequin', a plugin for Dotclear 2 *
* *
* Copyright (c) 2007,2010 *
* Oleksandr Syenchuk and contributors. *
* *
* This is an open source software, distributed under the GNU *
* General Public License (version 2) terms and conditions. *
* *
* You should have received a copy of the GNU General Public *
* License along with 'Arlequin' (see COPYING.txt); *
* if not, write to the Free Software Foundation, Inc., *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
\***************************************************************/
if (!defined('DC_RC_PATH')){return;}
if (!isset($__resources['help']['arlequin']))
{
$__resources['help']['arlequin'] = dirname(__FILE__).'/help/arlequin.html';
}
/**
* @brief arlequin, a plugin for Dotclear 2
*
* @package Dotclear
* @subpackage Plugin
*
* @author Oleksandr Syenchuk, Pierre Van Glabeke and contributors
*
* @copyright Jean-Crhistian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
if (!defined('DC_RC_PATH')) {
return;
}
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 ""
msgstr ""
"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"
"PO-Revision-Date: 2018-01-22T17:11:42+00:00\n"
"Last-Translator: brol\n"
"PO-Revision-Date: 2022-12-14T22:24:43+00:00\n"
"Last-Translator: Jean-Crhistian Denis\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
#: _widgets.php:26
msgid "Theme switcher"
msgstr "Sélecteur de thème"
#: _widgets.php:27
msgid "Choose a theme"
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"
msgstr "Nom du modèle"
#: models.php:32
msgid "Bullets list"
msgstr "Liste à puces"
#: models.php:39
msgid "Scrolled list"
msgstr "Liste déroulante"
#: models.php:48
msgid "active theme"
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 '/'):"
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"
msgstr "Arlequin - configuration du sélecteur de thème"

View File

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