From bb99a4c05e4c77bfbbcbe89233733412b565fc2d Mon Sep 17 00:00:00 2001 From: rMalie Date: Wed, 7 Mar 2012 10:06:16 +0000 Subject: [PATCH] // Theme can now be selected on AdminThemes page --- .../themes/helpers/options/options.tpl | 49 ++-- .../template/helpers/options/options.tpl | 228 +++++++++--------- controllers/admin/AdminThemesController.php | 31 +++ 3 files changed, 179 insertions(+), 129 deletions(-) diff --git a/admin-dev/themes/default/template/controllers/themes/helpers/options/options.tpl b/admin-dev/themes/default/template/controllers/themes/helpers/options/options.tpl index 404fd4e3f..20b0377c3 100644 --- a/admin-dev/themes/default/template/controllers/themes/helpers/options/options.tpl +++ b/admin-dev/themes/default/template/controllers/themes/helpers/options/options.tpl @@ -24,20 +24,37 @@ * International Registered Trademark & Property of PrestaShop SA *} {extends file="helpers/options/options.tpl"} -{block name="after"} -

-
- + +{block name="field"} + {if $field['type'] == 'theme'} + {if $field['can_display_themes']} + {foreach $field.themes as $theme} +
+ {$theme->name}
+ {$theme->directory}
+ id == $field['id_theme']}checked="checked"{/if} /> +
+ {/foreach} + {/if} + {else} + {$smarty.block.parent} + {/if} +{/block} + +{block name="after"} +

+
+ {/block} diff --git a/admin-dev/themes/default/template/helpers/options/options.tpl b/admin-dev/themes/default/template/helpers/options/options.tpl index bc96aaf79..ff8445c6b 100644 --- a/admin-dev/themes/default/template/helpers/options/options.tpl +++ b/admin-dev/themes/default/template/helpers/options/options.tpl @@ -73,128 +73,130 @@ {foreach $categoryData['fields'] AS $key => $field} - {if $field['type'] == 'hidden'} - - {else} -
- {if isset($field['title'])} - - {/if} - {block name="start_field_block"} -
- {/block} - {if $field['type'] == 'select'} - {if $field['list']} - - {else if isset($input.empty_message)} - {$input.empty_message} + {block name="field"} + {if $field['type'] == 'hidden'} + + {else} +
+ {if isset($field['title'])} + {/if} - {elseif $field['type'] == 'bool'} - - - - - - - {elseif $field['type'] == 'radio'} - {foreach $field['choices'] AS $k => $v} - -
- {/foreach} -
- {*{elseif $field['type'] == 'checkbox'} - {foreach $field['choices'] AS $k => $v} - -
- {/foreach} -
- *} - {elseif $field['type'] == 'text'} - - {if isset($field['suffix'])} {$field['suffix']|strval}{/if} - {elseif $field['type'] == 'password'} - - {if isset($field['suffix'])} {$field['suffix']|strval}{/if} - {elseif $field['type'] == 'textarea'} - - {elseif $field['type'] == 'file'} - {if isset($field['thumb']) && $field['thumb']} - {$field['title']}
- {/if} - - {elseif $field['type'] == 'price'} - {$currency_left_sign}{$currency_right_sign} {l s='(tax excl.)'} - {elseif $field['type'] == 'textLang' || $field['type'] == 'textareaLang' || $field['type'] == 'selectLang'} - {if $field['type'] == 'textLang'} - {foreach $field['languages'] AS $id_lang => $value} -
- -
- {/foreach} - {elseif $field['type'] == 'textareaLang'} - {foreach $field['languages'] AS $id_lang => $value} -
- -
- {/foreach} - {elseif $field['type'] == 'selectLang'} - {foreach $languages as $language} -
- + {foreach $field['list'] AS $k => $option} + {/foreach} -
+ {else if isset($input.empty_message)} + {$input.empty_message} + {/if} + {elseif $field['type'] == 'bool'} + + + + + + + {elseif $field['type'] == 'radio'} + {foreach $field['choices'] AS $k => $v} + +
{/foreach} - {/if} - {if count($languages) > 1} -
- -
-
- {l s='Choose language:'}

- {foreach $languages as $language} - {$language.name} +
+ {*{elseif $field['type'] == 'checkbox'} + {foreach $field['choices'] AS $k => $v} + +
+ {/foreach} +
+ *} + {elseif $field['type'] == 'text'} + + {if isset($field['suffix'])} {$field['suffix']|strval}{/if} + {elseif $field['type'] == 'password'} + + {if isset($field['suffix'])} {$field['suffix']|strval}{/if} + {elseif $field['type'] == 'textarea'} + + {elseif $field['type'] == 'file'} + {if isset($field['thumb']) && $field['thumb']} + {$field['title']}
+ {/if} + + {elseif $field['type'] == 'price'} + {$currency_left_sign}{$currency_right_sign} {l s='(tax excl.)'} + {elseif $field['type'] == 'textLang' || $field['type'] == 'textareaLang' || $field['type'] == 'selectLang'} + {if $field['type'] == 'textLang'} + {foreach $field['languages'] AS $id_lang => $value} +
+ +
{/foreach} + {elseif $field['type'] == 'textareaLang'} + {foreach $field['languages'] AS $id_lang => $value} +
+ +
+ {/foreach} + {elseif $field['type'] == 'selectLang'} + {foreach $languages as $language} +
+ +
+ {/foreach} + {/if} + {if count($languages) > 1} +
+ +
+
+ {l s='Choose language:'}

+ {foreach $languages as $language} + {$language.name} + {/foreach} +
+ {/if} +
+ {/if} + {if ($field['multishop_default'])} +
+
{/if} -
- {/if} - {if ($field['multishop_default'])} -
- + {if isset($field['required']) && $field['required'] && $field['type'] != 'radio'} + * + {/if} + {if isset($field['hint'])}{$field['hint']} {/if} + {if isset($field['desc'])}

{$field['desc']}

{/if} + {if $field['is_invisible']}

{l s='You can\'t change the value of this configuration field in this shop context'}

{/if}
+ {block name="end_field_block"} +
+
+ {/block} {/if} - {if isset($field['required']) && $field['required'] && $field['type'] != 'radio'} - * - {/if} - {if isset($field['hint'])}{$field['hint']} {/if} - {if isset($field['desc'])}

{$field['desc']}

{/if} - {if $field['is_invisible']}

{l s='You can\'t change the value of this configuration field in this shop context'}

{/if} -
- {block name="end_field_block"} -
-
- {/block} - {/if} + {/block} {/foreach} {if isset($categoryData['submit'])}
diff --git a/controllers/admin/AdminThemesController.php b/controllers/admin/AdminThemesController.php index d58ffbaf5..524a92159 100644 --- a/controllers/admin/AdminThemesController.php +++ b/controllers/admin/AdminThemesController.php @@ -97,7 +97,21 @@ class AdminThemesControllerCore extends AdminController { parent::init(); + $this->can_display_themes = (!Shop::isFeatureActive() || Shop::getContext() == Shop::CONTEXT_SHOP) ? true : false; + $this->options = array( + 'theme' => array( + 'title' => sprintf($this->l('Select theme for shop %s'), $this->context->shop->name), + 'description' => (!$this->can_display_themes) ? $this->l('You must select a shop in top list if you want to select a theme') : '', + 'fields' => array( + 'theme_for_shop' => array( + 'type' => 'theme', + 'themes' => Theme::getThemes(), + 'id_theme' => $this->context->shop->id_theme, + 'can_display_themes' => $this->can_display_themes, + ), + ), + ), 'appearance' => array( 'title' => $this->l('Appearance'), 'icon' => 'email', @@ -581,6 +595,23 @@ class AdminThemesControllerCore extends AdminController Configuration::updateGlobalValue('PS_FAVICON', 'favicon.ico'); } + /** + * Update theme for current shop + */ + public function updateOptionThemeForShop() + { + if (!$this->can_display_themes) + return; + + $id_theme = (int)Tools::getValue('id_theme'); + if ($id_theme && $this->context->shop->id_theme != $id_theme) + { + $this->context->shop->id_theme = $id_theme; + $this->context->shop->update(); + $this->redirect_after = self::$currentIndex.'&token='.$this->token; + } + } + protected function uploadIco($name, $dest) { if (isset($_FILES[$name]['tmp_name']) && !empty($_FILES[$name]['tmp_name']))