[*] BO : #PSFV-94 - added AdminContactsController, fix flags display for option lists

git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@9424 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
tDidierjean committed 2011-10-18 14:00:27 +00:00
1 parent 463d94914d
commit 730e5e4d96
8 files changed
+179 -142

No files matched your search

-124
View File
@@ -1,124 +0,0 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision: 7300 $
* @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_.'/../classes/AdminTab.php');
class AdminContacts extends AdminTab
{
public function __construct()
{
$this->table = 'contact';
$this->className = 'Contact';
$this->lang = true;
$this->edit = true;
$this->delete = true;
$this->fieldsDisplay = array(
'id_contact' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25),
'name' => array('title' => $this->l('Title'), 'width' => 130),
'email' => array('title' => $this->l('E-mail address'), 'width' => 130),
'description' => array('title' => $this->l('Description'), 'width' => 150),
);
$this->optionsList = array(
'general' => array(
'title' => $this->l('Contact options'),
'fields' => array(
'PS_CUSTOMER_SERVICE_FILE_UPLOAD' => array('title' => $this->l('Allow file upload'), 'desc' => $this->l('Allow customers to upload file using contact page'), 'cast' => 'intval', 'type' => 'select', 'identifier' => 'value', 'list' => array(
'0' => array('value' => 0, 'name' => $this->l('No')),
'1' => array('value' => 1, 'name' => $this->l('Yes'))
)),
'PS_CUSTOMER_SERVICE_SIGNATURE' => array('title' => $this->l('Pre-defined message'), 'desc' => $this->l('Please fill the message that appears by default when you answer a thread on the customer service page'), 'cast' => 'pSQL', 'type' => 'textareaLang', 'identifier' => 'value', 'cols' => 40, 'rows' => 8),
),
),
);
parent::__construct();
}
public function displayForm($isMainTab = true)
{
parent::displayForm();
if (!($obj = $this->loadObject(true)))
return;
echo '
<form action="'.self::$currentIndex.'&submitAdd'.$this->table.'=1&token='.$this->token.'" method="post">
'.($obj->id ? '<input type="hidden" name="id_'.$this->table.'" value="'.$obj->id.'" />' : '').'
<fieldset><legend><img src="../img/admin/contact.gif" />'.$this->l('Contacts').'</legend>
<label>'.$this->l('Title:').' </label>
<div class="margin-form">';
foreach ($this->_languages as $language)
echo '
<div id="name_'.$language['id_lang'].'" style="display: '.($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none').'; float: left;">
<input size="33" type="text" name="name_'.$language['id_lang'].'" value="'.htmlentities($this->getFieldValue($obj, 'name', (int)($language['id_lang'])), ENT_COMPAT, 'UTF-8').'" /><sup> *</sup>
</div>';
$this->displayFlags($this->_languages, $this->_defaultFormLanguage, 'name¤description', 'name');
echo ' <p style="clear: both">'.$this->l('Contact name, e.g., Technical Support').'</p>
</div>
<label>'.$this->l('E-mail address').'</label>
<div class="margin-form">
<input type="text" size="33" name="email" value="'.htmlentities($this->getFieldValue($obj, 'email'), ENT_COMPAT, 'UTF-8').'" />
<p style="clear: both">'.$this->l('E-mails will be sent to this address').'</p>
</div>
<label>'.$this->l('Save in Customer Service?').'</label>
<div class="margin-form">
<input type="radio" name="customer_service" id="customer_service_on" value="1" '.($this->getFieldValue($obj, 'customer_service') ? 'checked="checked" ' : '').'/>
<label class="t" for="customer_service_on"> <img src="../img/admin/enabled.gif" alt="'.$this->l('Enabled').'" title="'.$this->l('Enabled').'" /></label>
<input type="radio" name="customer_service" id="customer_service_off" value="0" '.(!$this->getFieldValue($obj, 'customer_service') ? 'checked="checked" ' : '').'/>
<label class="t" for="customer_service_off"> <img src="../img/admin/disabled.gif" alt="'.$this->l('Disabled').'" title="'.$this->l('Disabled').'" /></label>
<p>'.$this->l('The messages will be saved in the Customer Service tab').'</p>
</div><div class="clear">&nbsp;</div>
<label>'.$this->l('Description').'</label>
<div class="margin-form">';
foreach ($this->_languages as $language)
echo '
<div id="description_'.$language['id_lang'].'" style="display: '.($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none').'; float: left;">
<textarea name="description_'.$language['id_lang'].'" cols="36" rows="5">'.htmlentities($this->getFieldValue($obj, 'description', (int)($language['id_lang'])), ENT_COMPAT, 'UTF-8').'</textarea>
</div>';
$this->displayFlags($this->_languages, $this->_defaultFormLanguage, 'name¤description', 'description');
echo '
<p style="clear: both">'.$this->l('Additional information about this contact').'</p>
</div>';
if (Shop::isMultiShopActivated())
{
echo '<label>'.$this->l('Shop association:').'</label><div class="margin-form">';
$this->displayAssoShop();
echo '</div>';
}
echo '
<div class="margin-form">
<input type="submit" value="'.$this->l(' Save ').'" name="submitAdd'.$this->table.'" class="button" />
</div>
<div class="small"><sup>*</sup> '.$this->l('Required field').'</div>
</fieldset>
</form>';
}
}
+1 -5
View File
@@ -24,10 +24,6 @@
* International Registered Trademark & Property of PrestaShop SA * International Registered Trademark & Property of PrestaShop SA
*} *}
<br /> <br />
<script type="text/javascript">
id_language = Number({$id_lang});
</script>
<form action="{$current}&submitOptions{$table}=1&token={$token}" method="post" enctype="multipart/form-data"> <form action="{$current}&submitOptions{$table}=1&token={$token}" method="post" enctype="multipart/form-data">
{foreach $optionsList AS $category => $categoryData} {foreach $optionsList AS $category => $categoryData}
{if isset($categoryData['top'])}{$categoryData['top']}{/if} {if isset($categoryData['top'])}{$categoryData['top']}{/if}
@@ -123,7 +119,7 @@
{$field['flags']} {$field['flags']}
{elseif $field['type'] == 'textareaLang'} {elseif $field['type'] == 'textareaLang'}
{foreach $field['languages'] AS $id_lang => $value} {foreach $field['languages'] AS $id_lang => $value}
<div id="{$key}_{$id_lang}" style="display: {if $id_lang == $current_id_lang}'block'{else}'none'{/if}; float: left;">'; <div id="{$key}_{$id_lang}" style="display: {if $id_lang == $current_id_lang}block{else}none{/if}; float: left;">
<textarea rows="{$field['rows']}" cols="{$field['cols']|intval}" name="{$key}_{$id_lang}">{$value|replace:'\r\n':"\n"}</textarea> <textarea rows="{$field['rows']}" cols="{$field['cols']|intval}" name="{$key}_{$id_lang}">{$value|replace:'\r\n':"\n"}</textarea>
</div> </div>
{/foreach} {/foreach}
+1 -4
View File
@@ -1784,9 +1784,7 @@ class AdminControllerCore extends Controller
$languages = Language::getLanguages(false); $languages = Language::getLanguages(false);
foreach ($this->options as $option_list) foreach ($this->options as $category => $category_data)
{
foreach ($option_list as $category => $category_data)
{ {
$fields = $category_data['fields']; $fields = $category_data['fields'];
@@ -1868,7 +1866,6 @@ class AdminControllerCore extends Controller
} }
} }
} }
}
if (count($this->_errors) <= 0) if (count($this->_errors) <= 0)
Tools::redirectAdmin(self::$currentIndex.'&conf=6&token='.$token); Tools::redirectAdmin(self::$currentIndex.'&conf=6&token='.$token);
+32
View File
@@ -235,5 +235,37 @@ class HelperCore
return str_replace('"', '&quot;', ($addslashes ? addslashes($str) : stripslashes($str))); return str_replace('"', '&quot;', ($addslashes ? addslashes($str) : stripslashes($str)));
} }
/**
* Display flags in forms for translations
*
* @param array $languages All languages available
* @param integer $default_language Default language id
* @param string $ids Multilingual div ids in form
* @param string $id Current div id]
* @param boolean $return define the return way : false for a display, true for a return
* @param boolean $use_vars_instead_of_ids use an js vars instead of ids seperate by "¤"
*/
public function displayFlags($languages, $default_language, $ids, $id, $return = false, $use_vars_instead_of_ids = false)
{
if (count($languages) == 1)
return false;
$output = '
<div class="displayed_flag">
<img src="../img/l/'.$default_language.'.jpg" class="pointer" id="language_current_'.$id.'" onclick="toggleLanguageFlags(this);" alt="" />
</div>
<div id="languages_'.$id.'" class="language_flags">
'.$this->l('Choose language:').'<br /><br />';
foreach ($languages as $language)
if($use_vars_instead_of_ids)
$output .= '<img src="../img/l/'.(int)($language['id_lang']).'.jpg" class="pointer" alt="'.$language['name'].'" title="'.$language['name'].'" onclick="changeLanguage(\''.$id.'\', '.$ids.', '.$language['id_lang'].', \''.$language['iso_code'].'\');" /> ';
else
$output .= '<img src="../img/l/'.(int)($language['id_lang']).'.jpg" class="pointer" alt="'.$language['name'].'" title="'.$language['name'].'" onclick="changeLanguage(\''.$id.'\', \''.$ids.'\', '.$language['id_lang'].', \''.$language['iso_code'].'\');" /> ';
$output .= '</div>';
if ($return)
return $output;
echo $output;
}
} }
+1 -3
View File
@@ -51,7 +51,6 @@ class AdminBackupControllerCore extends AdminController
); );
$this->options = array( $this->options = array(
'options_general' => array(
'general' => array( 'general' => array(
'title' => $this->l('Backup options'), 'title' => $this->l('Backup options'),
'fields' => array( 'fields' => array(
@@ -61,7 +60,6 @@ class AdminBackupControllerCore extends AdminController
'desc' => $this->l('Select this option to instruct the backup file to drop your tables prior to restoring the backed up data').'<br />(ie. "DROP TABLE IF EXISTS")', 'cast' => 'intval', 'type' => 'bool'), 'desc' => $this->l('Select this option to instruct the backup file to drop your tables prior to restoring the backed up data').'<br />(ie. "DROP TABLE IF EXISTS")', 'cast' => 'intval', 'type' => 'bool'),
), ),
), ),
),
); );
$this->identifier = 'filename'; $this->identifier = 'filename';
} }
@@ -123,7 +121,7 @@ class AdminBackupControllerCore extends AdminController
$helper = new HelperOptions(); $helper = new HelperOptions();
$helper->id = $this->id; $helper->id = $this->id;
$helper->currentIndex = self::$currentIndex; $helper->currentIndex = self::$currentIndex;
$this->content .= $helper->generateOptions($this->options['options_general']); $this->content .= $helper->generateOptions($this->options);
} }
} }
@@ -0,0 +1,142 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision: 7300 $
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
class AdminContactsControllerCore extends AdminController
{
public function __construct()
{
$this->table = 'contact';
$this->className = 'Contact';
$this->lang = true;
$this->addRowAction('edit');
$this->addRowAction('delete');
$this->bulk_actions = array('delete' => array('text' => $this->l('Delete selected'), 'confirm' => $this->l('Delete selected items?')));
$this->fieldsDisplay = array(
'id_contact' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25),
'name' => array('title' => $this->l('Title'), 'width' => 130),
'email' => array('title' => $this->l('E-mail address'), 'width' => 130),
'description' => array('title' => $this->l('Description'), 'width' => 150),
);
$this->options = array(
'general' => array(
'title' => $this->l('Contact options'),
'fields' => array(
'PS_CUSTOMER_SERVICE_FILE_UPLOAD' => array('title' => $this->l('Allow file upload'), 'desc' => $this->l('Allow customers to upload file using contact page'), 'cast' => 'intval', 'type' => 'select', 'identifier' => 'value', 'list' => array(
'0' => array('value' => 0, 'name' => $this->l('No')),
'1' => array('value' => 1, 'name' => $this->l('Yes'))
)),
'PS_CUSTOMER_SERVICE_SIGNATURE' => array('title' => $this->l('Pre-defined message'), 'desc' => $this->l('Please fill the message that appears by default when you answer a thread on the customer service page'), 'cast' => 'pSQL', 'type' => 'textareaLang', 'identifier' => 'value', 'cols' => 40, 'rows' => 8),
),
),
);
$this->fields_form = array(
'legend' => array(
'title' => $this->l('Contacts'),
'image' => '../img/admin/contact.gif'
),
'input' => array(
array(
'type' => 'text',
'label' => $this->l('Title:'),
'name' => 'name',
'size' => 33,
'required' => true,
'lang' => true,
'attributeLang' => 'name',
'p' => $this->l('Contact name, e.g., Technical Support'),
),
array(
'type' => 'text',
'label' => $this->l('E-mail address'),
'name' => 'email',
'size' => 33,
'required' => false,
'p' => $this->l('E-mails will be sent to this address'),
),
array(
'type' => 'radio',
'label' => $this->l('Save in Customer Service?'),
'name' => 'customer_service',
'required' => false,
'class' => 't',
'is_bool' => true,
'p' => $this->l('The messages will be saved in the Customer Service tab'),
'values' => array(
array(
'id' => 'customer_service_on',
'value' => 1,
'label' => $this->l('Enabled')
),
array(
'id' => 'customer_service_off',
'value' => 0,
'label' => $this->l('Disabled')
)
),
),
array(
'type' => 'textarea',
'label' => $this->l('Description'),
'name' => 'description',
'required' => false,
'lang' => true,
'attributeLang' => 'description',
'cols' => 36,
'rows' => 5,
'p' => $this->l('Additional information about this contact'),
),
),
'submit' => array(
'title' => $this->l(' Save '),
'class' => 'button'
)
);
parent::__construct();
}
public function initContent()
{
if ($this->display != 'edit')
$this->display = 'list';
parent::initContent();
if ($this->display == 'list')
{
$helper = new HelperOptions();
$helper->id = $this->id;
$helper->currentIndex = self::$currentIndex;
$this->content .= $helper->generateOptions($this->options);
}
}
}
+1 -3
View File
@@ -47,7 +47,6 @@ class AdminImagesController extends AdminController
); );
$this->options = array( $this->options = array(
'options_image_pref' => array(
'images' => array( 'images' => array(
'title' => $this->l('Images'), 'title' => $this->l('Images'),
'icon' => 'tab-orders', 'icon' => 'tab-orders',
@@ -61,7 +60,6 @@ class AdminImagesController extends AdminController
'PS_JPEG_QUALITY' => array('title' => $this->l('JPEG quality'), 'desc' => $this->l('Ranges from 0 (worst quality, smallest file) to 100 (best quality, biggest file)'), 'validation' => 'isUnsignedId', 'required' => true, 'cast' => 'intval', 'type' => 'text'), 'PS_JPEG_QUALITY' => array('title' => $this->l('JPEG quality'), 'desc' => $this->l('Ranges from 0 (worst quality, smallest file) to 100 (best quality, biggest file)'), 'validation' => 'isUnsignedId', 'required' => true, 'cast' => 'intval', 'type' => 'text'),
'PS_PNG_QUALITY' => array('title' => $this->l('PNG quality'), 'desc' => $this->l('Ranges from 9 (worst quality, smallest file) to 0 (best quality, biggest file)'), 'validation' => 'isUnsignedId', 'required' => true, 'cast' => 'intval', 'type' => 'text'), 'PS_PNG_QUALITY' => array('title' => $this->l('PNG quality'), 'desc' => $this->l('Ranges from 9 (worst quality, smallest file) to 0 (best quality, biggest file)'), 'validation' => 'isUnsignedId', 'required' => true, 'cast' => 'intval', 'type' => 'text'),
), ),
),
) )
); );
@@ -537,7 +535,7 @@ class AdminImagesController extends AdminController
$helper = new HelperOptions(); $helper = new HelperOptions();
$helper->id = $this->id; $helper->id = $this->id;
$helper->currentIndex = self::$currentIndex; $helper->currentIndex = self::$currentIndex;
$this->content .= $helper->generateOptions($this->options['options_image_pref']); $this->content .= $helper->generateOptions($this->options);
$this->initRegenerate(); $this->initRegenerate();
$this->initMoveImages(); $this->initMoveImages();
+1 -3
View File
@@ -214,7 +214,6 @@ class AdminStoresControllerCore extends AdminController
); );
$this->options = array( $this->options = array(
'option_store_pref' => array(
'general' => array( 'general' => array(
'title' => $this->l('Parameters'), 'title' => $this->l('Parameters'),
'fields' => array( 'fields' => array(
@@ -252,7 +251,6 @@ class AdminStoresControllerCore extends AdminController
) )
) )
) )
)
); );
parent::__construct(); parent::__construct();
@@ -371,7 +369,7 @@ class AdminStoresControllerCore extends AdminController
$helper->id = $this->id; $helper->id = $this->id;
$helper->currentIndex = self::$currentIndex; $helper->currentIndex = self::$currentIndex;
$this->content .= $helper->generateOptions($this->options['option_store_pref']); $this->content .= $helper->generateOptions($this->options);
} }
} }