From 128303194f469004bc3fff48a101c9cea01d643c Mon Sep 17 00:00:00 2001 From: brol Date: Wed, 22 Apr 2015 15:29:49 +0200 Subject: [PATCH] v1.1 --- CHANGELOG | 21 ++++ _admin.php | 36 +++++++ _define.php | 31 ++++++ _public.php | 185 ++++++++++++++++++++++++++++++++++ _widgets.php | 73 ++++++++++++++ icon-big.png | Bin 0 -> 5582 bytes icon.png | Bin 0 -> 867 bytes index.php | 141 ++++++++++++++++++++++++++ js/models.js | 82 +++++++++++++++ locales/en/help/arlequin.html | 55 ++++++++++ locales/en/resources.php | 20 ++++ locales/fr/help/arlequin.html | 57 +++++++++++ locales/fr/main.po | 91 +++++++++++++++++ locales/fr/resources.php | 20 ++++ models.php | 49 +++++++++ 15 files changed, 861 insertions(+) create mode 100644 CHANGELOG create mode 100644 _admin.php create mode 100644 _define.php create mode 100644 _public.php create mode 100644 _widgets.php create mode 100644 icon-big.png create mode 100644 icon.png create mode 100644 index.php create mode 100644 js/models.js create mode 100644 locales/en/help/arlequin.html create mode 100644 locales/en/resources.php create mode 100644 locales/fr/help/arlequin.html create mode 100644 locales/fr/main.po create mode 100644 locales/fr/resources.php create mode 100644 models.php diff --git a/CHANGELOG b/CHANGELOG new file mode 100644 index 0000000..c7376d5 --- /dev/null +++ b/CHANGELOG @@ -0,0 +1,21 @@ +v1.1 - 05-03-2015 - 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 +* v1.0.1 - Corrections for compatibility with Dotclear 2.2 + +2008-10-18 Oleksandr Syenchuk +* v2008.10 - Removed theme parameter from URL + + +2008-08-21 Oleksandr Syenchuk +* Excluded themes can not be selected by user. + + +2008-04-21 Oleksandr Syenchuk +* Dotclear r1790 compatibility, see + http://dev.dotclear.net/2.0/changeset/1790 diff --git a/_admin.php b/_admin.php new file mode 100644 index 0000000..cc92945 --- /dev/null +++ b/_admin.php @@ -0,0 +1,36 @@ +addItem(__('Theme switcher'),'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' => __('Theme switcher'), + '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 diff --git a/_define.php b/_define.php new file mode 100644 index 0000000..2e6c394 --- /dev/null +++ b/_define.php @@ -0,0 +1,31 @@ +registerModule( + /* Name */ 'Arlequin', + /* Description*/ 'Allows visitors choose a theme', + /* Author */ 'Oleksandr Syenchuk, Pierre Van Glabeke', + /* Version */ '1.1', + /* Properties */ + array( + 'permissions' => 'contentadmin', + 'type' => 'plugin', + 'dc_min' => '2.7', + 'support' => 'http://forum.dotclear.org/viewtopic.php?id=48345', + 'details' => 'http://plugins.dotaddict.org/dc2/details/arlequin' + ) +); \ No newline at end of file diff --git a/_public.php b/_public.php new file mode 100644 index 0000000..6db862e --- /dev/null +++ b/_public.php @@ -0,0 +1,185 @@ +blog); +$core->addBehavior('publicBeforeDocument',array('publicArlequinEngine','adjustCache')); +$core->tpl->addValue('themesList',array('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->multitheme->mt_exclude) { + if (in_array($theme,explode('/',$blog->settings->multitheme->mt_exclude))) { + return; + } + } + + $GLOBALS['__theme'] = $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; + + if ($w->offline) + return; + + $cfg = @unserialize($core->blog->settings->multitheme->get('mt_cfg')); + + 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; + } + + $res = sprintf($cfg['s_html'],$s_url,$res); + + if ($w) { + + $res = + ($w->title ? $w->renderTitle(html::escapeHTML($w->title)) : ''). + $res; + + return $w->renderDiv($w->content_only,'arlequin '.$w->class,'',$res); + } + + return $res; + } + + public static function getNames() + { + global $core; + + $mt_exclude = $core->blog->settings->multitheme->mt_exclude; + $exclude = array(); + if (!empty($mt_exclude)) { + $exclude = array_flip(explode('/',$core->blog->settings->multitheme->mt_exclude)); + } + + $names = array_diff_key($core->themes->getModules(),$exclude); + + return empty($names) ? false : $names; + } +} \ No newline at end of file diff --git a/_widgets.php b/_widgets.php new file mode 100644 index 0000000..3edb122 --- /dev/null +++ b/_widgets.php @@ -0,0 +1,73 @@ +addBehavior('initWidgets',array('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->multitheme->get('mt_cfg')); + $mt_exclude = $settings->multitheme->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('multitheme'); + $settings->multitheme->put('mt_cfg',serialize($mt_cfg),'string','Arlequin configuration'); + $settings->multitheme->put('mt_exclude','customCSS','string','Excluded themes'); + $initialized = true; + $core->blog->triggerBlog(); + } + + return array($mt_cfg,$mt_exclude); + } +} \ No newline at end of file diff --git a/icon-big.png b/icon-big.png new file mode 100644 index 0000000000000000000000000000000000000000..e9ed51420d23b0666fef2308a9a7c275b64cfa0d GIT binary patch literal 5582 zcmYjVc{o)2|37nPHHNVp+ss&#lo3hUW++?A6iMnbvfegQiO8HGTewt`5YtWFsZ^uL z61T%p5^-;eRz&Dh#y*(kH$C5fe&>14InQ~X^E~JCIq&ytdB3umyF8Tex_AHpl)OB* z?UCQHlr_mmp|*A+8%hyFDCNTnb5chfDs;ZD1z#B zEHo-&Pef>V;)$0LjsT#^^4iAmPxx?1ER(qiJTU;Gt&P@-paXd#0KjooDFA@5{fY#r zkbAQH3%yxH00Iu(s72?}p)S)sdQHcrz9VOKsSwHItb_cmK%VBS3F})A9=x_PH8q`G znhqhGnVB8us*xijBgxe6+;zQ-Y_vJHZ+1zsKsq};`0OFwDWu#fX>n|uPlUIzyQMK@RJ2Tc49}LULOixc&nh2e1 zZFRNUyLWFAtLh%;^jf$)7Zu3J*yiRanH~&b#VspotSYw2=ouSn)&Md+8=bYE6DlwP z`wVC2#(go{w{O2(R;G{Hwd?gqI-e5#fJ)=~0?3KYw7toQ4@=`N11kT@Yj&{=q`xFa zUb}I_kR2Xgxuw_oC*9)%!pZ7oclUa*>**A1Lhydg+wRc2K`T<3)%AE|vScQAc%E3dCRSWSO^S|?kW z?02}j;kUD2KQ){T>HX|(DX*KBTA0CTHXAm1egEc7V@-ASFdZ`a=Xx``m>pP1X?rqtOJp*dRL4hQxbTwPGmFG6$j)wbk$48*IWov0;?{9eJGpV5UI(sy9N!njw1(8<~ zZ3S^dgEAL5P}(jWS#rqm9sId5d3h#lcxmtOo=UmRy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1hZX<; literal 0 HcmV?d00001 diff --git a/index.php b/index.php new file mode 100644 index 0000000..3d910f7 --- /dev/null +++ b/index.php @@ -0,0 +1,141 @@ +blog->settings->addNameSpace('multitheme'); + 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->multitheme->put('mt_cfg',serialize($mt_cfg)); + $core->blog->settings->multitheme->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->multitheme->drop('mt_cfg'); + $core->blog->settings->multitheme->drop('mt_exclude'); + $core->blog->triggerBlog(); + http::redirect($p_url.'&restore=1'); + } +} +catch (Exception $e) +{ + $core->error->add($e->getMessage()); +} + +/* DISPLAY +--------------------------------------------------- */ + +if ($initialized) { + $messages[] = __('Settings have been reinitialized.'); +} + +// 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"; +} + +echo ' + +'.$page_title.''. +dcPage::jsLoad('index.php?pf=arlequin/js/models.js').' + +'. +dcPage::breadcrumb( + array( + html::escapeHTML($core->blog->name) => '', + ''.$page_title.'' => '' + )); + +// 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').'

    +
    +

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

    +
    +

    +

    +

    + +

    +
    +

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

    +
    '; + +dcPage::helpBlock('arlequin'); ?> + \ No newline at end of file diff --git a/js/models.js b/js/models.js new file mode 100644 index 0000000..e7576c9 --- /dev/null +++ b/js/models.js @@ -0,0 +1,82 @@ +/* -*- tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/***************************************************************\ + * 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 'Arlequin' (see COPYING.txt); * + * if not, write to the Free Software Foundation, Inc., * + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * +\***************************************************************/ + +var arlequin = { + msg : { + predefined_models : 'Generic models', + select_model : 'Select a generic model:', + user_defined : 'User defined' + }, + + models : Array(), + + addModel : function(model_name, s_html, e_html, a_html) { + model = new Array(model_name,s_html,e_html,a_html); + arlequin.models.push(model); + }, + + addDefault : function() { + arlequin.addModel(arlequin.msg.user_defined, + $("#s_html").val(), + $("#e_html").val(), + $("#a_html").val()); + }, + + drawInterface : function() { + if (!arlequin.models.length) { + return; + } + + res = ''; + res += '

    '+arlequin.msg.select_model+' '; + res += ''; + res += '

    '; + + return res; + }, + + selectModel : function(id) { + if (!arlequin.models[id]) { return; } + + $("#s_html").val(arlequin.models[id][1]); + $("#e_html").val(arlequin.models[id][2]); + $("#a_html").val(arlequin.models[id][3]); + } +}; + + +$(function() { + if (!document.getElementById || !document.getElementById('models')) { return; } + + var c = $('#models'); + c.html('

    '+ + arlequin.msg.predefined_models+'

    '); + + $('#model-control').click(function() { + c.html(arlequin.drawInterface()); + + $('#mt_model').change(function() { + arlequin.selectModel(this.value); + }); + + return false; + }); +}); \ No newline at end of file diff --git a/locales/en/help/arlequin.html b/locales/en/help/arlequin.html new file mode 100644 index 0000000..d1b684d --- /dev/null +++ b/locales/en/help/arlequin.html @@ -0,0 +1,55 @@ + + + + Aide Arlequin + + +

    Inserting the theme selector in the blog interface

    + +
    +
    With a widget
    +
    The easiest way is to use the Theme Selector + widget that displays a list of available themes.
    + +
    In the template file
    +
    The switch can also be integrated into the blog interface by editing your + template file. Simply add the {{tpl:themesList}} instruction in + the desired location.
    +
    + +

    Understanding Models

    +

    Arlequin is notable for its flexible configuration, due to the concept of + models that create their own interfaces for the theme selector.

    +

    The information needed to operate the theme selector contained in variables + of the form %n$s where n is an integer + denoting a variable.

    +

    Here is the list of variables that you can use:

    +
    +
    In switcher HTML code
    +
    + + + + +
    VariableMeaning
    %1$sCurrent page URL
    %2$sItems HTML code
    + +
    In items HTML code
    +
    + + + + + + + + +
    VariableMeaning
    %1$sCurrent page URL
    %2$sA suffix to send theme setting through URL, e.g. "&theme="
    %3$sTheme identifier only to be used in a URL
    %4$sTheme name
    %5$sTheme description
    %6$sTheme identifier
    +
    + +

    Add your own predefined templates

    +

    If you are the administrator of a platform of blogs, you can change the + predefined templates by editing the file plugins/arlequin/models.php.

    +

    Suggestion: some interesting models can be created in + association with JavaScript or CSS property, changing your themes.

    + + \ No newline at end of file diff --git a/locales/en/resources.php b/locales/en/resources.php new file mode 100644 index 0000000..d976353 --- /dev/null +++ b/locales/en/resources.php @@ -0,0 +1,20 @@ + + + + Aide Arlequin + + +

    Insertion du sélecteur de thème dans l'interface du blog

    + +
    +
    Avec un widget
    +
    Le plus simple est d'utiliser le widget + Sélecteur de thème qui affiche la liste des thèmes disponibles.
    + +
    Dans le fichier template
    +
    Le sélecteur peut aussi être intégré dans l'interface du blog en éditant + directement votre fichier template. Il suffit pour cela d'ajouter l'instruction + {{tpl:themesList}} à l'endroit voulu.
    +
    + +

    Comprendre les modèles

    +

    Arlequin est remarquable pour sa souplesse de configuration, due à la notion + de modèles qui permettent de créer ses propres interfaces pour le + sélecteur de thème.

    +

    Les informations nécessaires au fonctionnement du sélecteur de thème sont + contenues dans des variables de la forme %n$sn + est un entier désignant une variable.

    +

    Voici la liste des variables que vous pouvez utiliser :

    +
    +
    Dans le code HTML du sélecteur
    +
    + + + + +
    VariableSignification
    %1$sL'adresse URL de la page courante
    %2$sLe code HTML des items
    + +
    Dans le code HTML des items
    +
    + + + + + + + + +
    VariableSignification
    %1$sL'adresse URL de la page courante
    %2$sUn suffixe pour envoyer le paramètre du thème à travers + l'URL, p. ex. "&theme="
    %3$sL'identifiant du thème à utiliser uniquement dans une URL
    %4$sLe nom du thème
    %5$sLa description du thème
    %6$sL'identifiant du thème
    +
    + +

    Ajouter ses propres modèles prédéfinis

    +

    Si vous êtes l'administrateur d'une plate-forme de blogs, vous pouvez modifier + les modèles prédéfinis en éditant le fichier plugins/arlequin/models.php.

    +

    Conseil : des modèles assez intéressants peuvent être créés + en association avec du JavaScript ou avec des propriétés CSS, en modifiant vos thèmes.

    + + \ No newline at end of file diff --git a/locales/fr/main.po b/locales/fr/main.po new file mode 100644 index 0000000..90c4ffe --- /dev/null +++ b/locales/fr/main.po @@ -0,0 +1,91 @@ +msgid "" +msgstr "" +"Content-Type: text/plain; charset=UTF-8\n" +"Project-Id-Version: Dotclear 2 Arlequin v1.1 module\n" +"POT-Creation-Date: \n" +"PO-Revision-Date: 2009-10-20 21:01+0100\n" +"Last-Translator: brol \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Poedit-Language: French\n" +"X-Poedit-KeywordsList: __\n" +"X-Poedit-Basepath: ../..\n" +"X-Poedit-SearchPath-0: .\n" + +#: 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" + +#: forms.php:22 +msgid "Switcher display format" +msgstr "Format d'affichage du sélecteur" + +#: forms.php:24 +msgid "Switcher HTML code:" +msgstr "Code HTML du sélecteur :" + +#: forms.php:27 +msgid "Item HTML code:" +msgstr "Code HTML d'un item :" + +#: forms.php:29 +msgid "Active item HTML code:" +msgstr "Code HTML d'un item actif :" + +#: forms.php:35 +msgid "Excluded themes (separated by slashs '/'):" +msgstr "Thèmes exclus (séparés par des slashs \"/\") :" + +#: forms.php:38 +msgid "Update" +msgstr "Mettre à jour" + +#: forms.php:39 +msgid "Restore defaults" +msgstr "Réinitialiser les paramètres" + +#: _admin.php:18 +#: _admin.php:29 +msgid "Theme switcher" +msgstr "Sélecteur de thème" + +#: _admin.php:32 +msgid "Choose a theme" +msgstr "Choisissez un thème" + +#: index.php:51 +msgid "Settings have been successfully updated." +msgstr "Les paramètres ont été mis à jour avec succès." + +#: index.php:71 +msgid "Settings have been reinitialized." +msgstr "Les paramètres ont été réinitialisés." + +#: index.php:18 +msgid "Arlequin - theme switcher configuration" +msgstr "Arlequin - configuration du sélecteur de thème" + +#: 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:97 +msgid "User defined" +msgstr "Défini par l'utilisateur" + +msgid "Allows visitors choose a theme" +msgstr "Permettre aux visiteurs de choisir un thème" + diff --git a/locales/fr/resources.php b/locales/fr/resources.php new file mode 100644 index 0000000..d976353 --- /dev/null +++ b/locales/fr/resources.php @@ -0,0 +1,20 @@ +__('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[] = array( + 'name'=>__('Scrolled list'), + 's_html'=> + '
    '."\n". + '

    '."\n". + '

    '."\n". + '
    ', + 'e_html'=>'', + 'a_html'=>'' +); \ No newline at end of file