Commit 49efed40 authored by chealer's avatar chealer

[ENH] change switch_theme module to new module style (modules-doc).

[FIX] notice (assign_by_ref on value)
[FIX] TPL: correct order for truncation and replacement
parent 60be9c05
......@@ -2844,6 +2844,7 @@ modules/mod-func-logged_users.php -text
modules/mod-func-menupage.php -text
modules/mod-func-quick_edit.php -text
modules/mod-func-switch_lang.php -text
modules/mod-func-switch_theme.php -text
modules/mod-groups_emulation.php -text
modules/mod-last_actions.php -text
modules/mod-last_articles.php -text
......@@ -2879,7 +2880,6 @@ modules/mod-semantic_links.php -text
modules/mod-shoutbox.php -text
modules/mod-since_last_visit.php -text
modules/mod-since_last_visit_new.php -text
modules/mod-switch_theme.php -text
modules/mod-terminology.php -text
modules/mod-top_active_blogs.php -text
modules/mod-top_articles.php -text
......
<?php
//this script may only be included - so its better to die if called directly.
if (strpos($_SERVER["SCRIPT_NAME"],basename(__FILE__)) !== false) {
header("location: index.php");
exit;
}
function module_switch_theme_info() {
return array(
'name' => tra('Switch theme'),
'description' => tra('Enables to quickly change the theme.'),
'prefs' => array( 'feature_userPreferences', 'change_theme' ),
'params' => array()
);
}
function module_switch_theme( $mod_reference, $module_params ) {
global $prefs, $user, $tikilib, $smarty;
if ( isset($_COOKIE['tiki-theme']) && !($prefs['feature_userPreferences'] == 'y' && $user && $prefs['change_theme'] == 'y') ){
$style = $_COOKIE['tiki-theme'];
}
if ( isset($_COOKIE['tiki-theme-option']) && !($prefs['feature_userPreferences'] == 'y' && $user && $prefs['change_theme'] == 'y') ){
$style_option = $_COOKIE['tiki-theme-option'];
}
$smarty->assign('styleslist',$tikilib->list_styles());
$smarty->assign( "style_options", $tikilib->list_style_options());
$smarty->clear_assign('tpl_module_title'); // TPL sets dynamic default title
}
\ No newline at end of file
<?php
//this script may only be included - so its better to die if called directly.
if (strpos($_SERVER["SCRIPT_NAME"],basename(__FILE__)) !== false) {
header("location: index.php");
exit;
}
global $prefs, $user, $tikilib, $smarty;
if ( isset($_COOKIE['tiki-theme']) && !($prefs['feature_userPreferences'] == 'y' && $user && $prefs['change_theme'] == 'y') ){
$style = $_COOKIE['tiki-theme'];
}
if ( isset($_COOKIE['tiki-theme-option']) && !($prefs['feature_userPreferences'] == 'y' && $user && $prefs['change_theme'] == 'y') ){
$style_option = $_COOKIE['tiki-theme-option'];
}
$smarty->assign('styleslist',$tikilib->list_styles());
$smarty->assign_by_ref( "style_options", $tikilib->list_style_options());
/* $styleName not found anywhere - TODO delete this if safe
if ( isset($style) ) {
$smarty->assign('styleName', ereg_replace($tikidomain."/", "", $style));
}
if ( isset($style_option) ) {
$smarty->assign('styleNameOption', ereg_replace($tikidomain."/", "", $style_option));
}*/
{* $Id$ *}
{if empty($group_style)}
{if !isset($tpl_module_title)}
{capture assign=tpl_module_title}{tr}Theme{/tr}: <em>{$prefs.style|truncate:15|replace:'.css':''|ucwords}</em>{/capture}
{capture assign=tpl_module_title}{tr}Theme{/tr}: <em>{$prefs.style|replace:'.css':''|truncate:15|ucwords}</em>{/capture}
{/if}
{tikimodule error=$module_params.error title=$tpl_module_title name="switch_theme" flip=$module_params.flip decorations=$module_params.decorations nobox=$module_params.nobox notitle=$module_params.notitle}
{if $prefs.change_theme ne 'n'}
<form method="get" action="tiki-switch_theme.php">
<select name="theme" size="1" onchange="this.form.submit();">
<option value="" style="font-style:italic;border-bottom:1px dashed #666;">{tr}Site default{/tr}</option>
{section name=ix loop=$styleslist}
{if count($prefs.available_styles) == 0 || empty($prefs.available_styles[0]) || in_array($styleslist[ix], $prefs.available_styles)}
<option value="{$styleslist[ix]|escape}" {if $prefs.style eq $styleslist[ix]}selected="selected"{/if}>{$styleslist[ix]|truncate:15|replace:'.css':''|ucwords}</option>
<option value="{$styleslist[ix]|escape}" {if $prefs.style eq $styleslist[ix]}selected="selected"{/if}>{$styleslist[ix]|replace:'.css':''|truncate:15|ucwords}</option>
{/if}
{/section}
</select>{if $style_options}
</select>
{if $style_options}
<select name="theme-option" onchange="this.form.submit();">
{*<option value="" style="font-style:italic;border-bottom:1px dashed #666;">{tr}Site default{/tr}</option>*}
{section name=ix loop=$style_options}
<option value="{$style_options[ix]|escape}"{if $prefs.style_option eq $style_options[ix]} selected="selected"{/if}>{$style_options[ix]|truncate:15|replace:'.css':''|ucwords}</option>
<option value="{$style_options[ix]|escape}"{if $prefs.style_option eq $style_options[ix]} selected="selected"{/if}>{$style_options[ix]|replace:'.css':''|truncate:15|ucwords}</option>
{/section}
</select>{/if}
</select>
{/if}
<noscript>
<button type="submit">{tr}Switch{/tr}</button>
</noscript>
</form>
{else}
{tr}This feature is disabled{/tr}
{/if}
{/tikimodule}
{/if}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment