diff --git a/admin-dev/themes/template/options.tpl b/admin-dev/themes/template/options.tpl
index 2cdb05b77..d970fed67 100644
--- a/admin-dev/themes/template/options.tpl
+++ b/admin-dev/themes/template/options.tpl
@@ -121,7 +121,7 @@
echo '';
echo '';
*}
- {elseif $field['type'] == 'textLang' || $field['type'] == 'textareaLang'}
+ {elseif $field['type'] == 'textLang' || $field['type'] == 'textareaLang' || $field['type'] == 'selectLang'}
{if $field['type'] == 'textLang'}
{foreach $field['languages'] AS $id_lang => $value}
@@ -134,6 +134,19 @@
{/foreach}
+ {elseif $field['type'] == 'selectLang' }
+ {foreach $languages as $language}
+
+
+
+ {/foreach}
{/if}
{if count($languages) > 1}
@@ -149,7 +162,7 @@
class="pointer"
alt="{$language.name}"
title="{$language.name}"
- onclick="changeLanguage('{$key}', '{$key}', {$language.id_lang}, '{$language.iso_code}');" />
+ onclick="changeLanguage('{$key}', '{if isset($custom_key)}{$custom_key}{else}{$key}{/if}', {$language.id_lang}, '{$language.iso_code}');" />
{/foreach}
{/if}
diff --git a/classes/AdminController.php b/classes/AdminController.php
index b02f87074..eabb5818a 100644
--- a/classes/AdminController.php
+++ b/classes/AdminController.php
@@ -2006,6 +2006,19 @@ EOF;
{
$fields = $category_data['fields'];
+ foreach ($fields as $field => $values)
+ if (isset($values['type']) && $values['type'] == 'selectLang')
+ {
+ foreach ($languages as $lang)
+ if (Tools::getValue($field.'_'.strtoupper($lang['iso_code'])))
+ $fields[$field.'_'.strtoupper($lang['iso_code'])] = array(
+ 'type' => 'select',
+ 'cast' => 'strval',
+ 'identifier' => 'mode',
+ 'list' => $values['list']
+ );
+ }
+
/* Check required fields */
foreach ($fields as $field => $values)
if (isset($values['required']) && $values['required'] && !isset($_POST['configUseDefault'][$field]))
diff --git a/classes/HelperOptions.php b/classes/HelperOptions.php
index 974f7fb65..ff1c5223b 100644
--- a/classes/HelperOptions.php
+++ b/classes/HelperOptions.php
@@ -54,6 +54,7 @@ class HelperOptionsCore extends Helper
$tab = Tab::getTab($this->context->language->id, $this->id);
if (!isset($languages))
$languages = Language::getLanguages(false);
+
foreach ($option_list as $category => $category_data)
{
if (!isset($category_data['image']))
@@ -99,7 +100,10 @@ class HelperOptionsCore extends Helper
$value = Tools::safeOutput(Tools::getValue($key.'_'.$language['id_lang'], Configuration::get($key, $language['id_lang'])));
elseif ($field['type'] == 'textareaLang')
$value = Configuration::get($key, $language['id_lang']);
+ elseif ($field['type'] == 'selectLang')
+ $value = Configuration::get($key, $language['id_lang']);
$field['languages'][$language['id_lang']] = $value;
+ $field['value'][$language['id_lang']] = $this->getOptionValue($key.'_'.strtoupper($language['iso_code']), $field);
}
}
@@ -157,25 +161,6 @@ class HelperOptionsCore extends Helper
echo '';
}
- /**
- * Type = selectLang
- * @ TODO
- */
- public function displayOptionTypeSelectLang($key, $field, $value)
- {
- $languages = Language::getLanguages(false);
- foreach ($languages as $language)
- {
- echo '';
- echo '';
- echo '
';
- }
- $this->displayFlags($languages, $this->context->language->id, $key, $key);
- }
-
/**
* Type = price
* @ TODO
diff --git a/admin-dev/tabs/AdminPDF.php b/controllers/admin/AdminPDFController.php
similarity index 56%
rename from admin-dev/tabs/AdminPDF.php
rename to controllers/admin/AdminPDFController.php
index a4d7f9b9c..f57f15141 100644
--- a/admin-dev/tabs/AdminPDF.php
+++ b/controllers/admin/AdminPDFController.php
@@ -1,6 +1,6 @@
* @copyright 2007-2011 PrestaShop SA
-* @version Release: $Revision: 6844 $
+* @version Release: $Revision: 7465 $
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
-include_once(_PS_ADMIN_DIR_.'/tabs/AdminPreferences.php');
-
-class AdminPDF extends AdminPreferences
+class AdminPDFControllerCore extends AdminController
{
+ private $encoding_list = array();
+
+ private $font_list = array();
+
public function __construct()
{
$this->className = 'Configuration';
$this->table = 'configuration';
-
- parent::__construct();
-
- /* Collect all font files and build array for combo box */
- $fontFiles = scandir(_PS_FPDF_PATH_.'font');
- $fontList = array();
- $arr = array();
-
- foreach ($fontFiles AS $file)
- if (substr($file, -4) == '.php' AND $file != 'index.php' AND substr($file, -6) != 'bi.php' AND substr($file, -5) != 'b.php' AND substr($file, -5) != 'i.php')
- {
- $arr['mode'] = substr($file, 0, -4);
- $arr['name'] = substr($file, 0, -4);
- array_push($fontList, $arr);
- }
+ $this->lang = true;
+ $this->context = Context::getContext();
/* Collect all encoding map files and build array for combo box */
- $encodingFiles = scandir(_PS_FPDF_PATH_.'font/makefont');
- $encodingList = array();
+ $encoding_files = scandir(_PS_FPDF_PATH_.'font/makefont');
$arr = array();
- foreach ($encodingFiles AS $file)
+
+ foreach ($encoding_files as $file)
if (substr($file, -4) == '.map')
{
$arr['mode'] = substr($file, 0, -4);
$arr['name'] = substr($file, 0, -4);
- array_push($encodingList, $arr);
+ array_push($this->encoding_list, $arr);
}
- $this->optionsList = array(
+ /* Collect all font files and build array for combo box */
+ $font_files = scandir(_PS_FPDF_PATH_.'font');
+ $arr = array();
+
+ foreach ($font_files as $file)
+ if (substr($file, -4) == '.php' &&
+ $file != 'index.php' &&
+ substr($file, -6) != 'bi.php' &&
+ substr($file, -5) != 'b.php' &&
+ substr($file, -5) != 'i.php')
+ {
+ $arr['mode'] = substr($file, 0, -4);
+ $arr['name'] = substr($file, 0, -4);
+ array_push($this->font_list, $arr);
+ }
+
+ $this->options = array(
'PDF' => array(
'title' => $this->l('PDF settings for the current language:').' '.$this->context->language->name,
'icon' => 'pdf',
@@ -72,40 +77,24 @@ class AdminPDF extends AdminPreferences
'desc' => $this->l('Encoding for PDF invoice'),
'type' => 'selectLang',
'cast' => 'strval',
- 'identifier' => 'mode',
- 'list' => $encodingList),
+ 'identifier' => 'mode',
+ 'list' => $this->encoding_list
+ ),
'PS_PDF_FONT' => array(
'title' => $this->l('Font:'),
'desc' => $this->l('Font for PDF invoice'),
'type' => 'selectLang',
'cast' => 'strval',
- 'identifier' => 'mode',
- 'list' => $fontList),
+ 'identifier' => 'mode',
+ 'list' => $this->font_list
+ )
),
- ),
+ 'submit' => array()
+ )
);
- }
- public function postProcess()
- {
- if (isset($_POST['submitPDF'.$this->table]))
- {
- // @todo automatize selectLang post process
- $fieldLangPDF = array();
- $languages = Language::getLanguages(false);
- foreach ($this->optionsList['PDF']['fields'] as $field => $fieldvalue)
- foreach ($languages as $lang)
- if (Tools::getValue($field.'_'.strtoupper($lang['iso_code'])))
- $this->optionsList['PDF']['fields'][$field.'_'.strtoupper($lang['iso_code'])] = array('type' => 'select', 'cast' => 'strval', 'identifier' => 'mode', 'list' => $fieldvalue['list']);
+ $this->context->smarty->assign('custom_key', 'PS_PDF_ENCODING¤PS_PDF_FONT');
- parent::postProcess();
- }
- }
-
- public function display()
- {
- if (!Validate::isLoadedObject($this->context->language))
- die(Tools::displayError());
- $this->displayOptionsList();
+ parent::__construct();
}
}