diff --git a/CHANGELOG.md b/CHANGELOG.md index 1fe98da..20ef90b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 +0.x - 2010.07.15 Gaetan Guillard * v1.0.1 - Corrections for compatibility with Dotclear 2.2 -2008-10-18 Oleksandr Syenchuk +0.x - 2008.10.18 Oleksandr Syenchuk * v2008.10 - Removed theme parameter from URL - -2008-08-21 Oleksandr Syenchuk +0.x - 2008.08.21 Oleksandr Syenchuk * Excluded themes can not be selected by user. - -2008-04-21 Oleksandr Syenchuk +0.x - 2008.04.21 Oleksandr Syenchuk * Dotclear r1790 compatibility, see http://dev.dotclear.net/2.0/changeset/1790 diff --git a/LICENSE b/LICENSE index 8cdb845..d511905 100644 --- a/LICENSE +++ b/LICENSE @@ -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., + 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} + + Copyright (C) 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 + , 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. - diff --git a/README.md b/README.md index 01eeef0..f8aea30 100644 --- a/README.md +++ b/README.md @@ -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. \ No newline at end of file diff --git a/_admin.php b/_admin.php index 6a1b1aa..ea6f4e7 100644 --- a/_admin.php +++ b/_admin.php @@ -1,36 +1,44 @@ -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' - )); -} \ No newline at end of file +// 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, + ]), + ]); +}); diff --git a/_define.php b/_define.php index a94cb57..6033e91 100644 --- a/_define.php +++ b/_define.php @@ -1,30 +1,32 @@ -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', ] ); diff --git a/_public.php b/_public.php index a22516a..482cfe2 100644 --- a/_public.php +++ b/_public.php @@ -1,185 +1,174 @@ -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 ''; - } - - 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 ''; + } - 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) == '?' ? '' : '&').'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; - } -} \ No newline at end of file + # 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) == '?' ? '' : '&') . '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; + } +} diff --git a/_widgets.php b/_widgets.php index 0f0573e..45931d7 100644 --- a/_widgets.php +++ b/_widgets.php @@ -1,73 +1,66 @@ -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'=>'
  • %4$s
  • ', - 'a_html'=>'
  • %4$s
  • ', - 's_html'=>'
      %2$s
    '); - } - - 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); - } -} \ No newline at end of file + 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' => '
  • %4$s
  • ', + 'a_html' => '
  • %4$s
  • ', + 's_html' => '
      %2$s
    ', + ]; + } + + 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]; + } +} diff --git a/dcstore.xml b/dcstore.xml new file mode 100644 index 0000000..252e491 --- /dev/null +++ b/dcstore.xml @@ -0,0 +1,13 @@ + + + + Arlequin + 1.6 + Oleksandr Syenchuk, Pierre Van Glabeke and contributors + Allows visitors choose a theme + https://github.com/JcDenis/arlequin/releases/download/v1.6/plugin-arlequin.zip + 2.24 + https://plugins.dotaddict.org/dc2/details/arlequin + http://forum.dotclear.org/viewtopic.php?id=48345 + + diff --git a/inc/models.php b/inc/models.php index 3696041..5802be4 100644 --- a/inc/models.php +++ b/inc/models.php @@ -1,49 +1,48 @@ -__('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'=>'
      %2$s
    ', - 'e_html'=>'
  • %4$s
  • ', - 'a_html'=>'
  • %4$s
  • ' -); +$mt_models[] = [ + 'name' => __('Bullets list'), + 's_html' => '
      %2$s
    ', + 'e_html' => '
  • %4$s
  • ', + 'a_html' => '
  • %4$s
  • ', +]; -$mt_models[] = array( - 'name'=>__('Scrolled list'), - 's_html'=> - '
    '."\n". - '

    '."\n". - '

    '."\n". - '
    ', - 'e_html'=>'', - 'a_html'=>'' -); \ No newline at end of file +$mt_models[] = [ + 'name' => __('Scrolled list'), + 's_html' => '
    ' . "\n" . + '

    ' . "\n" . + '

    ' . "\n" . + '
    ', + 'e_html' => '', + 'a_html' => '', +]; diff --git a/index.php b/index.php index 4efe512..66d99c2 100644 --- a/index.php +++ b/index.php @@ -1,141 +1,114 @@ -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()); +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 ' - -'.$page_title.''. -dcPage::jsLoad('index.php?pf=arlequin/js/models.js').' +' . __('Arlequin') . '' . +dcPage::jsLoad(dcPage::getPF(basename(__DIR__) . '/js/models.js')) . ' -'. -dcPage::breadcrumb( - array( - html::escapeHTML($core->blog->name) => '', - ''.$page_title.'' => '' - )); +' . +dcPage::breadcrumb([ + html::escapeHTML(dcCore::app()->blog->name) => '', + '' . __('Arlequin') . '' => '', +]) . +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 - '
    -

    '.__('Switcher display format').'

    + +

    ' . __('Switcher display format') . '

    -

    '. - form::textArea('s_html',50,10,html::escapeHTML($mt_cfg['s_html'])).'

    -
    -

    -

    -

    -

    -

    '.__('The names to be taken into account are those of the theme files.').'

    +
    +

    ' . + form::textArea('s_html', 50, 10, html::escapeHTML($mt_cfg['s_html'])) . '

    +
    +

    ' . + form::field('e_html', 50, 200, html::escapeHTML($mt_cfg['e_html'])) . '

    +

    ' . + form::field('a_html', 50, 200, html::escapeHTML($mt_cfg['a_html'])) . '

    +
    +

    ' . + form::field('mt_exclude', 50, 200, html::escapeHTML($mt_exclude)) . '

    +

    ' . __('The names to be taken into account are those of the theme files.') . '

    -

    - '. - (is_callable(array($core,'formNonce')) ? $core->formNonce() : '').'

    +

    + + ' . + dcCore::app()->formNonce() . '

    '; dcPage::helpBlock('arlequin'); ?> diff --git a/locales/en/resources.php b/locales/en/resources.php index ba8fea0..b889956 100644 --- a/locales/en/resources.php +++ b/locales/en/resources.php @@ -1,20 +1,17 @@ resources['help']['arlequin'] = __DIR__ . '/help/arlequin.html'; diff --git a/locales/fr/main.po b/locales/fr/main.po index 68b5444..855a613 100644 --- a/locales/fr/main.po +++ b/locales/fr/main.po @@ -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" diff --git a/locales/fr/resources.php b/locales/fr/resources.php index ba8fea0..b889956 100644 --- a/locales/fr/resources.php +++ b/locales/fr/resources.php @@ -1,20 +1,17 @@ resources['help']['arlequin'] = __DIR__ . '/help/arlequin.html';