[*] BO : #PSFV-94 - added AdminMetaController

This commit is contained in:
tDidierjean
2011-10-21 15:47:50 +00:00
parent d2aaf4cbd8
commit b89cecf58b
2 changed files with 125 additions and 122 deletions
+6
View File
@@ -124,6 +124,11 @@
{if isset($input.hint)}<span class="hint" name="help_box">{$input.hint}<span class="hint-pointer">&nbsp;</span></span>{/if} {if isset($input.hint)}<span class="hint" name="help_box">{$input.hint}<span class="hint-pointer">&nbsp;</span></span>{/if}
{/if} {/if}
{elseif $input.type == 'select'} {elseif $input.type == 'select'}
{if isset($input.options.query) && !$input.options.query && isset($input.empty_message)}
{$input.empty_message}
{$input.required = false}
{$input.p = null}
{else}
<select name="{$input.name}" id="{$input.name}" {if isset($input.multiple)}multiple="multiple" {/if}{if isset($input.onchange)}onchange="{$input.onchange}"{/if}> <select name="{$input.name}" id="{$input.name}" {if isset($input.multiple)}multiple="multiple" {/if}{if isset($input.onchange)}onchange="{$input.onchange}"{/if}>
{if isset($input.options.default)} {if isset($input.options.default)}
<option value="{$input.options.default.value}">{$input.options.default.label}</option> <option value="{$input.options.default.value}">{$input.options.default.label}</option>
@@ -160,6 +165,7 @@
{/if} {/if}
</select> </select>
{if isset($input.hint)}<span class="hint" name="help_box">{$input.hint}<span class="hint-pointer">&nbsp;</span></span>{/if} {if isset($input.hint)}<span class="hint" name="help_box">{$input.hint}<span class="hint-pointer">&nbsp;</span></span>{/if}
{/if}
{elseif $input.type == 'radio'} {elseif $input.type == 'radio'}
{foreach $input.values as $value} {foreach $input.values as $value}
<input type="radio" <input type="radio"
@@ -25,18 +25,20 @@
* International Registered Trademark & Property of PrestaShop SA * International Registered Trademark & Property of PrestaShop SA
*/ */
class AdminMeta extends AdminTab class AdminMetaControllerCore extends AdminController
{ {
public $table = 'meta'; public $table = 'meta';
public $className = 'Meta'; public $className = 'Meta';
public $lang = true; public $lang = true;
public $edit = true;
public $delete = true;
public function __construct() public function __construct()
{ {
parent::__construct(); parent::__construct();
$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( $this->fieldsDisplay = array(
'id_meta' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25), 'id_meta' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25),
'page' => array('title' => $this->l('Page'), 'width' => 120), 'page' => array('title' => $this->l('Page'), 'width' => 120),
@@ -45,13 +47,14 @@ class AdminMeta extends AdminTab
); );
$this->_group = 'GROUP BY a.id_meta'; $this->_group = 'GROUP BY a.id_meta';
$this->optionsList = array( $this->options = array(
'general' => array( 'general' => array(
'title' => $this->l('URLs Setup'), 'title' => $this->l('URLs Setup'),
'fields' => array( 'fields' => array(
'PS_REWRITING_SETTINGS' => array('title' => $this->l('Friendly URL'), 'desc' => $this->l('Enable only if your server allows URL rewriting (recommended)').'<p class="hint clear" style="display: block;">'.$this->l('If you turn on this feature, you must').' <a href="?tab=AdminGenerator&token='.Tools::getAdminToken('AdminGenerator'.(int)(Tab::getIdFromClassName('AdminGenerator')).(int)$this->context->employee->id).'">'.$this->l('generate a .htaccess file').'</a></p><div class="clear"></div>', 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool'), 'PS_REWRITING_SETTINGS' => array('title' => $this->l('Friendly URL'), 'desc' => $this->l('Enable only if your server allows URL rewriting (recommended)').'<p class="hint clear" style="display: block;">'.$this->l('If you turn on this feature, you must').' <a href="?tab=AdminGenerator&token='.Tools::getAdminToken('AdminGenerator'.(int)(Tab::getIdFromClassName('AdminGenerator')).(int)$this->context->employee->id).'">'.$this->l('generate a .htaccess file').'</a></p><div class="clear"></div>', 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool'),
'PS_CANONICAL_REDIRECT' => array('title' => $this->l('Automatically redirect to Canonical url'), 'desc' => $this->l('Recommended but your theme must be compliant'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool'), 'PS_CANONICAL_REDIRECT' => array('title' => $this->l('Automatically redirect to Canonical url'), 'desc' => $this->l('Recommended but your theme must be compliant'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool'),
), ),
'submit' => array()
), ),
'routes' => array( 'routes' => array(
'title' => $this->l('Schema of URLs'), 'title' => $this->l('Schema of URLs'),
@@ -70,6 +73,7 @@ class AdminMeta extends AdminTab
$this->addFieldRoute('cms_rule', $this->l('Route to CMS page')); $this->addFieldRoute('cms_rule', $this->l('Route to CMS page'));
$this->addFieldRoute('cms_category_rule', $this->l('Route to CMS category')); $this->addFieldRoute('cms_category_rule', $this->l('Route to CMS category'));
$this->addFieldRoute('module', $this->l('Route to modules')); $this->addFieldRoute('module', $this->l('Route to modules'));
$this->options['routes']['submit'] = array();
} }
} }
@@ -79,7 +83,7 @@ class AdminMeta extends AdminTab
foreach (Dispatcher::getInstance()->default_routes[$routeID]['keywords'] as $keyword => $data) foreach (Dispatcher::getInstance()->default_routes[$routeID]['keywords'] as $keyword => $data)
$keywords[] = ((isset($data['param'])) ? '<span class="red">'.$keyword.'*</span>' : $keyword); $keywords[] = ((isset($data['param'])) ? '<span class="red">'.$keyword.'*</span>' : $keyword);
$this->optionsList['routes']['fields']['PS_ROUTE_'.$routeID] = array( $this->options['routes']['fields']['PS_ROUTE_'.$routeID] = array(
'title' => $title, 'title' => $title,
'desc' => sprintf($this->l('Keywords: %s'), implode(', ', $keywords)), 'desc' => sprintf($this->l('Keywords: %s'), implode(', ', $keywords)),
'validation' => 'isString', 'validation' => 'isString',
@@ -89,91 +93,84 @@ class AdminMeta extends AdminTab
); );
} }
public function displayForm($isMainTab = true) public function initForm()
{ {
parent::displayForm(); $files = Meta::getPages(true, ($this->object->page ? $this->object->page : false));
$pages = array();
if (!($meta = $this->loadObject(true)))
return;
$files = Meta::getPages(true, ($meta->page ? $meta->page : false));
echo '
<form action="'.self::$currentIndex.'&token='.$this->token.'&submitAdd'.$this->table.'=1" method="post">
'.($meta->id ? '<input type="hidden" name="id_'.$this->table.'" value="'.$meta->id.'" />' : '').'
<fieldset><legend><img src="../img/admin/metatags.gif" />'.$this->l('Meta-Tags').'</legend>
<label>'.$this->l('Page:').' </label>
<div class="margin-form">';
if (!sizeof($files))
echo '<p>'.$this->l('There is no page available!').'</p>';
else
{
echo '
<select name="page">';
foreach ($files as $file) foreach ($files as $file)
{ $pages[] = array('page' => $file);
echo '<option value="'.$file.'"';
echo $meta->page == $file? ' selected="selected"' : '' ; $this->fields_form = array(
echo'>'.$file.'</option>'; 'legend' => array(
} 'title' => $this->l('Meta-Tags'),
echo ' 'image' => '../img/admin/metatags.gif'
</select><sup> *</sup> ),
<p class="clear">'.$this->l('Name of the related page').'</p>'; 'input' => array(
} array(
echo ' 'type' => 'hidden',
</div> 'name' => 'id_meta',
<label>'.$this->l('Page\'s title:').' </label> ),
<div class="margin-form">'; array(
foreach ($this->_languages as $language) 'type' => 'select',
echo ' 'label' => $this->l('Page:'),
<div id="title_'.$language['id_lang'].'" style="display: '.($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none').'; float: left;"> 'name' => 'page',
<input size="33" type="text" name="title_'.$language['id_lang'].'" value="'.htmlentities($this->getFieldValue($meta, 'title', (int)($language['id_lang'])), ENT_COMPAT, 'UTF-8').'" /> 'options' => array(
<span class="hint" name="help_box">'.$this->l('Invalid characters:').' <>;=#{}<span class="hint-pointer">&nbsp;</span></span> 'query' => $pages,
<p class="clear">'.$this->l('Title of this page').'</p> 'id' => 'page',
</div>'; 'name' => 'page',
$this->displayFlags($this->_languages, $this->_defaultFormLanguage, 'title¤description¤keywords¤url_rewrite', 'title'); ),
echo ' </div> 'p' => $this->l('Name of the related page'),
<div style="clear:both;">&nbsp;</div> 'required' => true,
<label>'.$this->l('Meta description:').' </label> 'empty_message' => '<p>'.$this->l('There is no page available!').'</p>',
<div class="margin-form">'; 'size' => 30
foreach ($this->_languages as $language) ),
echo ' array(
<div id="description_'.$language['id_lang'].'" style="display: '.($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none').'; float: left;"> 'type' => 'text',
<input size="50" type="text" name="description_'.$language['id_lang'].'" value="'.htmlentities($this->getFieldValue($meta, 'description', (int)($language['id_lang'])), ENT_COMPAT, 'UTF-8').'" /> 'label' => $this->l('Page\'s title:'),
<span class="hint" name="help_box">'.$this->l('Invalid characters:').' <>;=#{}<span class="hint-pointer">&nbsp;</span></span> 'name' => 'title',
<p class="clear">'.$this->l('A short description').'</p> 'lang' => true,
</div>'; 'attributeLang' => 'title',
$this->displayFlags($this->_languages, $this->_defaultFormLanguage, 'title¤description¤keywords¤url_rewrite', 'description'); 'hint' => $this->l('Invalid characters:').' <>;=#{}',
echo ' </div> 'p' => $this->l('Title of this page'),
<div style="clear:both;">&nbsp;</div> 'size' => 30
<label>'.$this->l('Meta keywords:').' </label> ),
<div class="margin-form">'; array(
foreach ($this->_languages as $language) 'type' => 'text',
echo ' 'label' => $this->l('Meta description:'),
<div id="keywords_'.$language['id_lang'].'" style="display: '.($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none').'; float: left;"> 'name' => 'description',
<input size="50" type="text" name="keywords_'.$language['id_lang'].'" value="'.htmlentities($this->getFieldValue($meta, 'keywords', (int)($language['id_lang'])), ENT_COMPAT, 'UTF-8').'" /> 'lang' => true,
<span class="hint" name="help_box">'.$this->l('Invalid characters:').' <>;=#{}<span class="hint-pointer">&nbsp;</span></span> 'attributeLang' => 'description',
<p class="clear">'.$this->l('List of keywords').'</p> 'hint' => $this->l('Invalid characters:').' <>;=#{}',
</div>'; 'p' => $this->l('A short description'),
$this->displayFlags($this->_languages, $this->_defaultFormLanguage, 'title¤description¤keywords¤url_rewrite', 'keywords'); 'size' => 50
echo ' </div> ),
<div style="clear:both;">&nbsp;</div> array(
<label>'.$this->l('Rewritten URL:').' </label> 'type' => 'text',
<div class="margin-form">'; 'label' => $this->l('Meta keywords:'),
foreach ($this->_languages as $language) 'name' => 'keywords',
echo ' 'lang' => true,
<div id="url_rewrite_'.$language['id_lang'].'" style="display: '.($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none').'; float: left;"> 'attributeLang' => 'keywords',
<input style="width:300px" type="text" name="url_rewrite_'.$language['id_lang'].'" value="'.htmlentities($this->getFieldValue($meta, 'url_rewrite', (int)($language['id_lang'])), ENT_COMPAT, 'UTF-8').'" /> 'hint' => $this->l('Invalid characters:').' <>;=#{}',
<span class="hint" name="help_box">'.$this->l('Invalid characters:').' <>;=#{}<span class="hint-pointer">&nbsp;</span></span> 'p' => $this->l('List of keywords'),
<p class="clear" style="width:300px">'.$this->l('Example : "contacts" for http://mysite.com/shop/contacts to redirect to http://mysite.com/shop/contact-form.php').'</p> 'size' => 50
</div>'; ),
$this->displayFlags($this->_languages, $this->_defaultFormLanguage, 'title¤description¤keywords¤url_rewrite', 'url_rewrite'); array(
echo ' </div> 'type' => 'text',
<div style="clear:both;">&nbsp;</div> 'label' => $this->l('Rewritten URL:'),
<div class="margin-form"> 'name' => 'url_rewrite',
<input type="submit" value="'.$this->l(' Save ').'" name="submitAdd'.$this->table.'" class="button" /> 'lang' => true,
</div> 'attributeLang' => 'url_rewrite',
<div class="small"><sup>*</sup> '.$this->l('Required field').'</div> 'hint' => $this->l('Invalid characters:').' <>;=#{}',
</fieldset> 'p' => $this->l('Example : "contacts" for http://mysite.com/shop/contacts to redirect to http://mysite.com/shop/contact-form.php'),
</form>'; 'size' => 50
),
),
'submit' => array(
'title' => $this->l(' Save '),
'class' => 'button'
)
);
return parent::initForm();
} }
public function postProcess() public function postProcess()