[*] BO : #PSFV-94 - added AdminMetaController
This commit is contained in:
@@ -124,42 +124,48 @@
|
|||||||
{if isset($input.hint)}<span class="hint" name="help_box">{$input.hint}<span class="hint-pointer"> </span></span>{/if}
|
{if isset($input.hint)}<span class="hint" name="help_box">{$input.hint}<span class="hint-pointer"> </span></span>{/if}
|
||||||
{/if}
|
{/if}
|
||||||
{elseif $input.type == 'select'}
|
{elseif $input.type == 'select'}
|
||||||
<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.query) && !$input.options.query && isset($input.empty_message)}
|
||||||
{if isset($input.options.default)}
|
{$input.empty_message}
|
||||||
<option value="{$input.options.default.value}">{$input.options.default.label}</option>
|
{$input.required = false}
|
||||||
{/if}
|
{$input.p = null}
|
||||||
{if isset($input.options.optiongroup)}
|
{else}
|
||||||
{foreach $input.options.optiongroup.query AS $optiongroup}
|
<select name="{$input.name}" id="{$input.name}" {if isset($input.multiple)}multiple="multiple" {/if}{if isset($input.onchange)}onchange="{$input.onchange}"{/if}>
|
||||||
<optgroup label="{$optiongroup[$input.options.optiongroup.label]}">
|
{if isset($input.options.default)}
|
||||||
{foreach $optiongroup[$input.options.options.query] as $option}
|
<option value="{$input.options.default.value}">{$input.options.default.label}</option>
|
||||||
<option value="{$option[$input.options.options.id]}"
|
{/if}
|
||||||
{if isset($input.multiple)}
|
{if isset($input.options.optiongroup)}
|
||||||
{foreach $fields_value[$input.name] as $field_value}
|
{foreach $input.options.optiongroup.query AS $optiongroup}
|
||||||
{if $field_value == $option[$input.options.options.id]}selected="selected"{/if}
|
<optgroup label="{$optiongroup[$input.options.optiongroup.label]}">
|
||||||
{/foreach}
|
{foreach $optiongroup[$input.options.options.query] as $option}
|
||||||
{else}
|
<option value="{$option[$input.options.options.id]}"
|
||||||
{if $fields_value[$input.name] == $option[$input.options.options.id]}selected="selected"{/if}
|
{if isset($input.multiple)}
|
||||||
{/if}
|
{foreach $fields_value[$input.name] as $field_value}
|
||||||
>{$option[$input.options.options.name]|escape:'htmlall':'UTF-8'}</option>
|
{if $field_value == $option[$input.options.options.id]}selected="selected"{/if}
|
||||||
{/foreach}
|
{/foreach}
|
||||||
</optgroup>
|
{else}
|
||||||
{/foreach}
|
{if $fields_value[$input.name] == $option[$input.options.options.id]}selected="selected"{/if}
|
||||||
{else}
|
{/if}
|
||||||
{foreach $input.options.query AS $option}
|
>{$option[$input.options.options.name]|escape:'htmlall':'UTF-8'}</option>
|
||||||
<option value="{$option[$input.options.id]}"
|
|
||||||
{if isset($input.multiple)}
|
|
||||||
{foreach $fields_value[$input.name] as $field_value}
|
|
||||||
{$field_value}
|
|
||||||
{if $field_value == $option[$input.options.id]}selected="selected"{/if}
|
|
||||||
{/foreach}
|
{/foreach}
|
||||||
{else}
|
</optgroup>
|
||||||
{if $fields_value[$input.name] == $option[$input.options.id]}selected="selected"{/if}
|
{/foreach}
|
||||||
{/if}
|
{else}
|
||||||
>{$option[$input.options.name]|escape:'htmlall':'UTF-8'}</option>
|
{foreach $input.options.query AS $option}
|
||||||
{/foreach}
|
<option value="{$option[$input.options.id]}"
|
||||||
{/if}
|
{if isset($input.multiple)}
|
||||||
</select>
|
{foreach $fields_value[$input.name] as $field_value}
|
||||||
|
{$field_value}
|
||||||
|
{if $field_value == $option[$input.options.id]}selected="selected"{/if}
|
||||||
|
{/foreach}
|
||||||
|
{else}
|
||||||
|
{if $fields_value[$input.name] == $option[$input.options.id]}selected="selected"{/if}
|
||||||
|
{/if}
|
||||||
|
>{$option[$input.options.name]|escape:'htmlall':'UTF-8'}</option>
|
||||||
|
{/foreach}
|
||||||
|
{/if}
|
||||||
|
</select>
|
||||||
{if isset($input.hint)}<span class="hint" name="help_box">{$input.hint}<span class="hint-pointer"> </span></span>{/if}
|
{if isset($input.hint)}<span class="hint" name="help_box">{$input.hint}<span class="hint-pointer"> </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();
|
||||||
|
foreach ($files as $file)
|
||||||
|
$pages[] = array('page' => $file);
|
||||||
|
|
||||||
if (!($meta = $this->loadObject(true)))
|
$this->fields_form = array(
|
||||||
return;
|
'legend' => array(
|
||||||
$files = Meta::getPages(true, ($meta->page ? $meta->page : false));
|
'title' => $this->l('Meta-Tags'),
|
||||||
echo '
|
'image' => '../img/admin/metatags.gif'
|
||||||
<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.'" />' : '').'
|
'input' => array(
|
||||||
<fieldset><legend><img src="../img/admin/metatags.gif" />'.$this->l('Meta-Tags').'</legend>
|
array(
|
||||||
<label>'.$this->l('Page:').' </label>
|
'type' => 'hidden',
|
||||||
<div class="margin-form">';
|
'name' => 'id_meta',
|
||||||
if (!sizeof($files))
|
),
|
||||||
echo '<p>'.$this->l('There is no page available!').'</p>';
|
array(
|
||||||
else
|
'type' => 'select',
|
||||||
{
|
'label' => $this->l('Page:'),
|
||||||
echo '
|
'name' => 'page',
|
||||||
<select name="page">';
|
'options' => array(
|
||||||
foreach ($files as $file)
|
'query' => $pages,
|
||||||
{
|
'id' => 'page',
|
||||||
echo '<option value="'.$file.'"';
|
'name' => 'page',
|
||||||
echo $meta->page == $file? ' selected="selected"' : '' ;
|
),
|
||||||
echo'>'.$file.'</option>';
|
'p' => $this->l('Name of the related page'),
|
||||||
}
|
'required' => true,
|
||||||
echo '
|
'empty_message' => '<p>'.$this->l('There is no page available!').'</p>',
|
||||||
</select><sup> *</sup>
|
'size' => 30
|
||||||
<p class="clear">'.$this->l('Name of the related page').'</p>';
|
),
|
||||||
}
|
array(
|
||||||
echo '
|
'type' => 'text',
|
||||||
</div>
|
'label' => $this->l('Page\'s title:'),
|
||||||
<label>'.$this->l('Page\'s title:').' </label>
|
'name' => 'title',
|
||||||
<div class="margin-form">';
|
'lang' => true,
|
||||||
foreach ($this->_languages as $language)
|
'attributeLang' => 'title',
|
||||||
echo '
|
'hint' => $this->l('Invalid characters:').' <>;=#{}',
|
||||||
<div id="title_'.$language['id_lang'].'" style="display: '.($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none').'; float: left;">
|
'p' => $this->l('Title of this 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').'" />
|
'size' => 30
|
||||||
<span class="hint" name="help_box">'.$this->l('Invalid characters:').' <>;=#{}<span class="hint-pointer"> </span></span>
|
),
|
||||||
<p class="clear">'.$this->l('Title of this page').'</p>
|
array(
|
||||||
</div>';
|
'type' => 'text',
|
||||||
$this->displayFlags($this->_languages, $this->_defaultFormLanguage, 'title¤description¤keywords¤url_rewrite', 'title');
|
'label' => $this->l('Meta description:'),
|
||||||
echo ' </div>
|
'name' => 'description',
|
||||||
<div style="clear:both;"> </div>
|
'lang' => true,
|
||||||
<label>'.$this->l('Meta description:').' </label>
|
'attributeLang' => 'description',
|
||||||
<div class="margin-form">';
|
'hint' => $this->l('Invalid characters:').' <>;=#{}',
|
||||||
foreach ($this->_languages as $language)
|
'p' => $this->l('A short description'),
|
||||||
echo '
|
'size' => 50
|
||||||
<div id="description_'.$language['id_lang'].'" style="display: '.($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none').'; float: left;">
|
),
|
||||||
<input size="50" type="text" name="description_'.$language['id_lang'].'" value="'.htmlentities($this->getFieldValue($meta, 'description', (int)($language['id_lang'])), ENT_COMPAT, 'UTF-8').'" />
|
array(
|
||||||
<span class="hint" name="help_box">'.$this->l('Invalid characters:').' <>;=#{}<span class="hint-pointer"> </span></span>
|
'type' => 'text',
|
||||||
<p class="clear">'.$this->l('A short description').'</p>
|
'label' => $this->l('Meta keywords:'),
|
||||||
</div>';
|
'name' => 'keywords',
|
||||||
$this->displayFlags($this->_languages, $this->_defaultFormLanguage, 'title¤description¤keywords¤url_rewrite', 'description');
|
'lang' => true,
|
||||||
echo ' </div>
|
'attributeLang' => 'keywords',
|
||||||
<div style="clear:both;"> </div>
|
'hint' => $this->l('Invalid characters:').' <>;=#{}',
|
||||||
<label>'.$this->l('Meta keywords:').' </label>
|
'p' => $this->l('List of keywords'),
|
||||||
<div class="margin-form">';
|
'size' => 50
|
||||||
foreach ($this->_languages as $language)
|
),
|
||||||
echo '
|
array(
|
||||||
<div id="keywords_'.$language['id_lang'].'" style="display: '.($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none').'; float: left;">
|
'type' => 'text',
|
||||||
<input size="50" type="text" name="keywords_'.$language['id_lang'].'" value="'.htmlentities($this->getFieldValue($meta, 'keywords', (int)($language['id_lang'])), ENT_COMPAT, 'UTF-8').'" />
|
'label' => $this->l('Rewritten URL:'),
|
||||||
<span class="hint" name="help_box">'.$this->l('Invalid characters:').' <>;=#{}<span class="hint-pointer"> </span></span>
|
'name' => 'url_rewrite',
|
||||||
<p class="clear">'.$this->l('List of keywords').'</p>
|
'lang' => true,
|
||||||
</div>';
|
'attributeLang' => 'url_rewrite',
|
||||||
$this->displayFlags($this->_languages, $this->_defaultFormLanguage, 'title¤description¤keywords¤url_rewrite', 'keywords');
|
'hint' => $this->l('Invalid characters:').' <>;=#{}',
|
||||||
echo ' </div>
|
'p' => $this->l('Example : "contacts" for http://mysite.com/shop/contacts to redirect to http://mysite.com/shop/contact-form.php'),
|
||||||
<div style="clear:both;"> </div>
|
'size' => 50
|
||||||
<label>'.$this->l('Rewritten URL:').' </label>
|
),
|
||||||
<div class="margin-form">';
|
),
|
||||||
foreach ($this->_languages as $language)
|
'submit' => array(
|
||||||
echo '
|
'title' => $this->l(' Save '),
|
||||||
<div id="url_rewrite_'.$language['id_lang'].'" style="display: '.($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none').'; float: left;">
|
'class' => 'button'
|
||||||
<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').'" />
|
)
|
||||||
<span class="hint" name="help_box">'.$this->l('Invalid characters:').' <>;=#{}<span class="hint-pointer"> </span></span>
|
);
|
||||||
<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>
|
return parent::initForm();
|
||||||
</div>';
|
|
||||||
$this->displayFlags($this->_languages, $this->_defaultFormLanguage, 'title¤description¤keywords¤url_rewrite', 'url_rewrite');
|
|
||||||
echo ' </div>
|
|
||||||
<div style="clear:both;"> </div>
|
|
||||||
<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>';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function postProcess()
|
public function postProcess()
|
||||||
Reference in New Issue
Block a user