[*] BO #PSFV-94 : Added AdminPDFController
This commit is contained in:
@@ -121,7 +121,7 @@
|
||||
echo '</tr>';
|
||||
echo '</table>';
|
||||
*}
|
||||
{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}
|
||||
<div id="{$key}_{$id_lang}" style="margin-bottom:8px; display: {if $id_lang == $current_id_lang}block{else}none{/if}; float: left; vertical-align: top;">
|
||||
@@ -134,6 +134,19 @@
|
||||
<textarea rows="{$field['rows']}" cols="{$field['cols']|intval}" name="{$key}_{$id_lang}">{$value|replace:'\r\n':"\n"}</textarea>
|
||||
</div>
|
||||
{/foreach}
|
||||
{elseif $field['type'] == 'selectLang' }
|
||||
{foreach $languages as $language}
|
||||
<div id="{$key}_{$language.id_lang}" style="margin-bottom:8px; display: {if $language.id_lang == $current_id_lang}block{else}none{/if}; float: left; vertical-align: top;">
|
||||
<select name="{$key}_{$language.iso_code|upper}">
|
||||
{foreach $field['list'] AS $k => $v}
|
||||
<option value="{if isset($v.cast)}{$v.cast[$v[$field.identifier]]}{else}{$v[$field.identifier]}{/if}"
|
||||
{if $field['value'][$language.id_lang] == $v['name']} selected="selected"{/if}>
|
||||
{$v['name']}
|
||||
</option>
|
||||
{/foreach}
|
||||
</select>
|
||||
</div>
|
||||
{/foreach}
|
||||
{/if}
|
||||
{if count($languages) > 1}
|
||||
<div class="displayed_flag">
|
||||
@@ -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}
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
@@ -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]))
|
||||
|
||||
@@ -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 '</table>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Type = selectLang
|
||||
* @ TODO
|
||||
*/
|
||||
public function displayOptionTypeSelectLang($key, $field, $value)
|
||||
{
|
||||
$languages = Language::getLanguages(false);
|
||||
foreach ($languages as $language)
|
||||
{
|
||||
echo '<div id="'.$key.'_'.$language['id_lang'].'" style="margin-bottom:8px; display: '.($language['id_lang'] == $this->context->language->id ? 'block' : 'none').'; float: left; vertical-align: top;">';
|
||||
echo '<select name="'.$key.'_'.strtoupper($language['iso_code']).'">';
|
||||
foreach ($field['list'] as $k => $v)
|
||||
echo '<option value="'.(isset($v['cast']) ? $v['cast']($v[$field['identifier']]) : $v[$field['identifier']]).'"'.((htmlentities(Tools::getValue($key.'_'.strtoupper($language['iso_code']), (Configuration::get($key.'_'.strtoupper($language['iso_code'])) ? Configuration::get($key.'_'.strtoupper($language['iso_code'])) : '')), ENT_COMPAT, 'UTF-8') == $v[$field['identifier']]) ? ' selected="selected"' : '').'>'.$v['name'].'</option>';
|
||||
echo '</select>';
|
||||
echo '</div>';
|
||||
}
|
||||
$this->displayFlags($languages, $this->context->language->id, $key, $key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Type = price
|
||||
* @ TODO
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2011 PrestaShop
|
||||
* 2007-2011 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
@@ -20,48 +20,53 @@
|
||||
*
|
||||
* @author PrestaShop SA <contact@prestashop.com>
|
||||
* @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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user