Merge branch 'ticket-10393-guide-achat' into develop
This commit is contained in:
commit
77ae796785
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2011 PrestaShop
|
||||
* 2007-2011 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
@ -104,7 +104,7 @@ class BlockCms extends Module
|
||||
}
|
||||
|
||||
public function getBlockCMS($id_cms_block)
|
||||
{
|
||||
{
|
||||
$cmsBlocks = Db::getInstance()->ExecuteS('
|
||||
SELECT cb.`id_cms_category`, cb.`location`, cb.`display_store`, cbl.id_lang, cbl.name
|
||||
FROM `'._DB_PREFIX_.'cms_block` cb
|
||||
@ -168,7 +168,7 @@ class BlockCms extends Module
|
||||
elseif (!$ids[0])
|
||||
{
|
||||
$query = Db::getInstance()->getRow('
|
||||
SELECT cl.`meta_title`, cl.`link_rewrite`
|
||||
SELECT cl.`meta_title`, cl.`link_rewrite`
|
||||
FROM `'._DB_PREFIX_.'cms_lang` cl
|
||||
INNER JOIN `'._DB_PREFIX_.'cms` c ON (cl.`id_cms` = c.`id_cms`)
|
||||
WHERE cl.`id_cms` = '.(int)$ids[1].' AND c.`active` = 1
|
||||
@ -204,7 +204,7 @@ class BlockCms extends Module
|
||||
|
||||
$content[$key]['cms'] = Db::getInstance()->ExecuteS('
|
||||
SELECT cl.`id_cms`, cl.`meta_title`, cl.`link_rewrite`
|
||||
FROM `'._DB_PREFIX_.'cms_block_page` bcp
|
||||
FROM `'._DB_PREFIX_.'cms_block_page` bcp
|
||||
INNER JOIN `'._DB_PREFIX_.'cms_lang` cl ON (bcp.`id_cms` = cl.`id_cms`)
|
||||
INNER JOIN `'._DB_PREFIX_.'cms` c ON (bcp.`id_cms` = c.`id_cms`)
|
||||
WHERE bcp.`id_cms_block` = '.(int)$cmsCategory['id_cms_block'].' AND cl.`id_lang` = '.(int)$cookie->id_lang.' AND bcp.`is_category` = 0 AND c.`active` = 1
|
||||
@ -222,7 +222,7 @@ class BlockCms extends Module
|
||||
|
||||
$content[$key]['categories'] = Db::getInstance()->ExecuteS('
|
||||
SELECT bcp.`id_cms`, cl.`name`, cl.`link_rewrite`
|
||||
FROM `'._DB_PREFIX_.'cms_block_page` bcp
|
||||
FROM `'._DB_PREFIX_.'cms_block_page` bcp
|
||||
INNER JOIN `'._DB_PREFIX_.'cms_category_lang` cl ON (bcp.`id_cms` = cl.`id_cms_category`)
|
||||
WHERE bcp.`id_cms_block` = '.(int)$cmsCategory['id_cms_block'].'
|
||||
AND cl.`id_lang` = '.(int)$cookie->id_lang.'
|
||||
@ -257,7 +257,7 @@ class BlockCms extends Module
|
||||
{
|
||||
unset($title['categories'], $title['name'], $title['category_link'], $title['category_name']);
|
||||
$titles[$key] = $title;
|
||||
}
|
||||
}
|
||||
return $titles;
|
||||
}
|
||||
|
||||
@ -350,7 +350,7 @@ class BlockCms extends Module
|
||||
<img src="../img/admin/up.gif" alt="'.$this->l('Up').'" title="'.$this->l('Up').'" /></a>
|
||||
</td>
|
||||
<td width="10%" class="center">
|
||||
<a href="'.$currentIndex.'&configure='.$this->name.'&token='.Tools::getAdminTokenLite('AdminModules').'&editBlockCMS&id_cms_block='.(int)($cms_block['id_cms_block']).'" title="'.$this->l('Edit').'"><img src="'._PS_ADMIN_IMG_.'edit.gif" alt="" /></a>
|
||||
<a href="'.$currentIndex.'&configure='.$this->name.'&token='.Tools::getAdminTokenLite('AdminModules').'&editBlockCMS&id_cms_block='.(int)($cms_block['id_cms_block']).'" title="'.$this->l('Edit').'"><img src="'._PS_ADMIN_IMG_.'edit.gif" alt="" /></a>
|
||||
<a href="'.$currentIndex.'&configure='.$this->name.'&token='.Tools::getAdminTokenLite('AdminModules').'&deleteBlockCMS&id_cms_block='.(int)($cms_block['id_cms_block']).'" title="'.$this->l('Delete').'"><img src="'._PS_ADMIN_IMG_.'delete.gif" alt="" /></a>
|
||||
</td>
|
||||
</tr>';
|
||||
@ -393,7 +393,7 @@ class BlockCms extends Module
|
||||
<img src="../img/admin/up.gif" alt="'.$this->l('Up').'" title="'.$this->l('Up').'" /></a>
|
||||
</td>
|
||||
<td width="10%" class="center">
|
||||
<a href="'.$currentIndex.'&configure='.$this->name.'&token='.Tools::getAdminTokenLite('AdminModules').'&editBlockCMS&id_cms_block='.(int)($cms_block['id_cms_block']).'" title="'.$this->l('Edit').'"><img src="'._PS_ADMIN_IMG_.'edit.gif" alt="" /></a>
|
||||
<a href="'.$currentIndex.'&configure='.$this->name.'&token='.Tools::getAdminTokenLite('AdminModules').'&editBlockCMS&id_cms_block='.(int)($cms_block['id_cms_block']).'" title="'.$this->l('Edit').'"><img src="'._PS_ADMIN_IMG_.'edit.gif" alt="" /></a>
|
||||
<a href="'.$currentIndex.'&configure='.$this->name.'&token='.Tools::getAdminTokenLite('AdminModules').'&deleteBlockCMS&id_cms_block='.(int)($cms_block['id_cms_block']).'" title="'.$this->l('Delete').'"><img src="'._PS_ADMIN_IMG_.'delete.gif" alt="" /></a>
|
||||
</td>
|
||||
</tr>';
|
||||
@ -546,8 +546,8 @@ class BlockCms extends Module
|
||||
|
||||
private function changePosition()
|
||||
{
|
||||
if (!Validate::isInt(Tools::getValue('position')) OR
|
||||
(Tools::getValue('location') != self::LEFT_COLUMN AND Tools::getValue('location') != self::RIGHT_COLUMN) OR
|
||||
if (!Validate::isInt(Tools::getValue('position')) OR
|
||||
(Tools::getValue('location') != self::LEFT_COLUMN AND Tools::getValue('location') != self::RIGHT_COLUMN) OR
|
||||
(Tools::getValue('way') != 0 AND Tools::getValue('way') != 1))
|
||||
Tools::displayError();
|
||||
|
||||
@ -586,21 +586,21 @@ class BlockCms extends Module
|
||||
if (Tools::isSubmit('submitBlockCMS'))
|
||||
{
|
||||
$position = Db::getInstance()->getValue('
|
||||
SELECT COUNT(*)
|
||||
FROM `'._DB_PREFIX_.'cms_block`
|
||||
SELECT COUNT(*)
|
||||
FROM `'._DB_PREFIX_.'cms_block`
|
||||
WHERE `location` = '.(int)Tools::getValue('block_location'));
|
||||
$languages = Language::getLanguages(false);
|
||||
if (Tools::isSubmit('addBlockCMS'))
|
||||
{
|
||||
Db::getInstance()->Execute('
|
||||
INSERT INTO `'._DB_PREFIX_.'cms_block` (`id_cms_category`, `location`, `position`, `display_store`)
|
||||
VALUES('.(int)Tools::getValue('id_category').', '.(int)Tools::getValue('block_location').',
|
||||
INSERT INTO `'._DB_PREFIX_.'cms_block` (`id_cms_category`, `location`, `position`, `display_store`)
|
||||
VALUES('.(int)Tools::getValue('id_category').', '.(int)Tools::getValue('block_location').',
|
||||
'.(int)$position.', '.(int)Tools::getValue('PS_STORES_DISPLAY_CMS').')');
|
||||
$id_cms_block = Db::getInstance()->Insert_ID();
|
||||
foreach ($languages as $language)
|
||||
Db::getInstance()->Execute('
|
||||
INSERT INTO `'._DB_PREFIX_.'cms_block_lang` (`id_cms_block`, `id_lang`, `name`)
|
||||
VALUES('.(int)$id_cms_block.', '.(int)$language['id_lang'].',
|
||||
INSERT INTO `'._DB_PREFIX_.'cms_block_lang` (`id_cms_block`, `id_lang`, `name`)
|
||||
VALUES('.(int)$id_cms_block.', '.(int)$language['id_lang'].',
|
||||
"'.pSQL(Tools::getValue('block_name_'.$language['id_lang'])).'")');
|
||||
|
||||
Db::getInstance()->Execute('
|
||||
@ -612,19 +612,19 @@ class BlockCms extends Module
|
||||
$id_cms_block = Tools::getvalue('id_cms_block');
|
||||
|
||||
$old_block = Db::getInstance()->ExecuteS('
|
||||
SELECT `location`, `position`
|
||||
FROM `'._DB_PREFIX_.'cms_block`
|
||||
SELECT `location`, `position`
|
||||
FROM `'._DB_PREFIX_.'cms_block`
|
||||
WHERE `id_cms_block` = '.(int)$id_cms_block);
|
||||
|
||||
$location_change = ($old_block[0]['location'] != (int)Tools::getvalue('block_location'));
|
||||
Db::getInstance()->Execute('
|
||||
DELETE FROM `'._DB_PREFIX_.'cms_block_page`
|
||||
DELETE FROM `'._DB_PREFIX_.'cms_block_page`
|
||||
WHERE `id_cms_block` = '.(int)$id_cms_block);
|
||||
|
||||
if ($location_change == true)
|
||||
Db::getInstance()->Execute('
|
||||
UPDATE `'._DB_PREFIX_.'cms_block`
|
||||
SET `position` = (`position` - 1) WHERE `position` > '.(int)$old_block[0]['position'].'
|
||||
UPDATE `'._DB_PREFIX_.'cms_block`
|
||||
SET `position` = (`position` - 1) WHERE `position` > '.(int)$old_block[0]['position'].'
|
||||
AND `location` = '.(int)$old_block[0]['location']);
|
||||
|
||||
Db::getInstance()->Execute('
|
||||
@ -640,9 +640,9 @@ class BlockCms extends Module
|
||||
|
||||
foreach ($languages as $language)
|
||||
Db::getInstance()->Execute('
|
||||
UPDATE `'._DB_PREFIX_.'cms_block_lang`
|
||||
SET `name` = "'.pSQL(Tools::getValue('block_name_'.$language['id_lang'])).'"
|
||||
WHERE `id_cms_block` = '.(int)$id_cms_block.'
|
||||
UPDATE `'._DB_PREFIX_.'cms_block_lang`
|
||||
SET `name` = "'.pSQL(Tools::getValue('block_name_'.$language['id_lang'])).'"
|
||||
WHERE `id_cms_block` = '.(int)$id_cms_block.'
|
||||
AND `id_lang`= '.(int)$language['id_lang']);
|
||||
}
|
||||
$cmsBoxes = Tools::getValue('cmsBox');
|
||||
@ -651,7 +651,7 @@ class BlockCms extends Module
|
||||
{
|
||||
$cms_properties = explode('_', $cmsBox);
|
||||
Db::getInstance()->Execute('
|
||||
INSERT INTO `'._DB_PREFIX_.'cms_block_page` (`id_cms_block`, `id_cms`, `is_category`)
|
||||
INSERT INTO `'._DB_PREFIX_.'cms_block_page` (`id_cms_block`, `id_cms`, `is_category`)
|
||||
VALUES('.(int)$id_cms_block.', '.(int)$cms_properties[1].', '.(int)$cms_properties[0].')');
|
||||
}
|
||||
if (Tools::isSubmit('addBlockCMS'))
|
||||
@ -665,17 +665,17 @@ class BlockCms extends Module
|
||||
if (sizeof($old_block))
|
||||
{
|
||||
Db::getInstance()->Execute('
|
||||
UPDATE `'._DB_PREFIX_.'cms_block`
|
||||
SET `position` = (`position` - 1)
|
||||
WHERE `position` > '.(int)$old_block[0]['position'].'
|
||||
UPDATE `'._DB_PREFIX_.'cms_block`
|
||||
SET `position` = (`position` - 1)
|
||||
WHERE `position` > '.(int)$old_block[0]['position'].'
|
||||
AND `location` = '.(int)$old_block[0]['location']);
|
||||
|
||||
Db::getInstance()->Execute('
|
||||
DELETE FROM `'._DB_PREFIX_.'cms_block`
|
||||
DELETE FROM `'._DB_PREFIX_.'cms_block`
|
||||
WHERE `id_cms_block` = '.(int)(Tools::getValue('id_cms_block')));
|
||||
|
||||
Db::getInstance()->Execute('
|
||||
DELETE FROM `'._DB_PREFIX_.'cms_block_page`
|
||||
DELETE FROM `'._DB_PREFIX_.'cms_block_page`
|
||||
WHERE `id_cms_block` = '.(int)(Tools::getValue('id_cms_block')));
|
||||
|
||||
Tools::redirectAdmin($currentIndex.'&configure='.$this->name.'&token='.Tools::getAdminTokenLite('AdminModules').'&deleteBlockCMSConfirmation');
|
||||
|
@ -97,29 +97,43 @@ class BlockLinkMulti1 extends Module
|
||||
// $result[$i]['url'] = ($link['url'] == ''? '': ((!$admin && substr($link['url'], 0, 4) != 'http') ? substr(__PS_BASE_URI__, 0, -1).$link['url'] : $link['url']));
|
||||
$i++;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function addLink()
|
||||
{
|
||||
/* Url registration */
|
||||
if (!Db::getInstance()->Execute('INSERT INTO '._DB_PREFIX_.'blocklinkmulti1 VALUES (\'\', \''.pSQL(isset($_POST['url']) && !empty($_POST['url'])? $_POST['url']: '').'\', '.((isset($_POST['newWindow']) AND $_POST['newWindow']) == 'on' ? 1 : 0).')') OR !$lastId = mysql_insert_id())
|
||||
return false;
|
||||
/* Multilingual text */
|
||||
$languages = Language::getLanguages();
|
||||
if (!$languages) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$defaultLanguage = intval(Configuration::get('PS_LANG_DEFAULT'));
|
||||
if (!$languages)
|
||||
return false;
|
||||
foreach ($languages AS $language)
|
||||
if (!empty($_POST['text_'.$language['id_lang']]))
|
||||
{
|
||||
if (!Db::getInstance()->Execute('INSERT INTO '._DB_PREFIX_.'blocklinkmulti1_lang VALUES ('.intval($lastId).', '.intval($language['id_lang']).', \''.pSQL($_POST['text_'.$language['id_lang']]).'\')'))
|
||||
return false;
|
||||
}
|
||||
else
|
||||
if (!Db::getInstance()->Execute('INSERT INTO '._DB_PREFIX_.'blocklinkmulti1_lang VALUES ('.intval($lastId).', '.intval($language['id_lang']).', \''.pSQL($_POST['text_'.$defaultLanguage]).'\')'))
|
||||
return false;
|
||||
|
||||
Db::getInstance()->Execute('INSERT INTO '._DB_PREFIX_.'blocklinkmulti1 VALUES (\'\', \''.
|
||||
pSQL(isset($_POST['url']) && !empty($_POST['url'])? $_POST['url']: '').'\', '.
|
||||
((isset($_POST['newWindow']) AND $_POST['newWindow']) == 'on' ? 1 : 0).')');
|
||||
|
||||
/* Url registration */
|
||||
if (!$lastId = mysql_insert_id()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Multilingual text */
|
||||
foreach ($languages AS $language) {
|
||||
if (empty($_POST['text_'.$language['id_lang']])) {
|
||||
$text = $_POST['text_'.$defaultLanguage];
|
||||
$url = $_POST['url_'.$defaultLanguage];
|
||||
} else {
|
||||
$text = $_POST['text_'.$language['id_lang']];
|
||||
$url = $_POST['url_'.$language['id_lang']];
|
||||
}
|
||||
|
||||
if (!Db::getInstance()->Execute('INSERT INTO '._DB_PREFIX_.'blocklinkmulti1_lang VALUES ('.
|
||||
intval($lastId).', '.intval($language['id_lang']).', \''.pSQL($text).'\', \''.pSQL($url).'\')')) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -130,21 +144,21 @@ class BlockLinkMulti1 extends Module
|
||||
$defaultLanguage = intval(Configuration::get('PS_LANG_DEFAULT'));
|
||||
if (!$languages)
|
||||
return false;
|
||||
foreach ($languages AS $language)
|
||||
foreach ($languages AS $language)
|
||||
if (!empty($_POST['text_'.$language['id_lang']])
|
||||
&& !empty($_POST['url_'.$language['id_lang']]))
|
||||
{
|
||||
if (!Db::getInstance()->Execute('UPDATE '._DB_PREFIX_.'blocklinkmulti1_lang
|
||||
SET
|
||||
if (!Db::getInstance()->Execute('UPDATE '._DB_PREFIX_.'blocklinkmulti1_lang
|
||||
SET
|
||||
`text` = \''.pSQL($_POST['text_'.$language['id_lang']]).'\' ,
|
||||
`url` = \''.pSQL($_POST['url_'.$language['id_lang']]).'\'
|
||||
`url` = \''.pSQL($_POST['url_'.$language['id_lang']]).'\'
|
||||
WHERE `id_link`='.intval($_POST['id']).' AND `id_lang`='.$language['id_lang']
|
||||
))
|
||||
return false;
|
||||
}
|
||||
else
|
||||
if (!Db::getInstance()->Execute('UPDATE '._DB_PREFIX_.'blocklinkmulti1_lang SET `text`=\''.pSQL($_POST['text_'.$defaultLanguage]).'\' WHERE `id_link`='.intval($_POST['id']).' AND `id_lang`='.$language['id_lang']))
|
||||
return false;
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -270,7 +284,7 @@ class BlockLinkMulti1 extends Module
|
||||
$this->_html .= $this->displayFlags($languages, $defaultLanguage, $divLangName, 'url', true);
|
||||
$this->_html .= '
|
||||
<div class="clear"></div>
|
||||
</div>
|
||||
</div>
|
||||
<label>'.$this->l('Open in a new window:').'</label>
|
||||
<div class="margin-form"><input type="checkbox" name="newWindow" id="newWindow" '.(($this->error AND isset($_POST['newWindow'])) ? 'checked="checked"' : '').' /></div>
|
||||
<div class="margin-form">
|
||||
@ -319,7 +333,7 @@ class BlockLinkMulti1 extends Module
|
||||
$links = $this->getLinks(true);
|
||||
|
||||
global $currentIndex, $cookie, $adminObj;
|
||||
$languages = Language::getLanguages(FALSE);
|
||||
$languages = Language::getLanguages(FALSE);
|
||||
if ($links)
|
||||
{
|
||||
$this->_html .= '
|
||||
@ -331,7 +345,7 @@ class BlockLinkMulti1 extends Module
|
||||
{
|
||||
$this->_html .= '
|
||||
links['.$link['id'].'] = new Array();
|
||||
links['.$link['id'].']["newWindow"] = '.$link['newWindow'].'
|
||||
links['.$link['id'].']["newWindow"] = '.$link['newWindow'].'
|
||||
';
|
||||
foreach ($languages AS $language) {
|
||||
$this->_html.= '
|
||||
|
@ -48,8 +48,18 @@ class Privatesales_Family_Menu extends Module {
|
||||
}
|
||||
}
|
||||
|
||||
// Purchase Guide
|
||||
$purchaseguide = array();
|
||||
if (count($menus) > 0) {
|
||||
foreach ($menus as $m) {
|
||||
$purchaseguide[$m['id_category_family']] = Module::hookExec('topMenuLink',
|
||||
array('id_category_family' => $m['id_category_family']));
|
||||
}
|
||||
}
|
||||
|
||||
$smarty->assign(array(
|
||||
'menus' => $menus
|
||||
'menus' => $menus,
|
||||
'purchaseguide' => $purchaseguide,
|
||||
));
|
||||
return $this->display(__FILE__, 'menu.tpl');
|
||||
}
|
||||
|
@ -16,8 +16,11 @@ class AdminGuide extends AdminTab
|
||||
'en' => 'guide',
|
||||
);
|
||||
|
||||
$str_rewrite_rules = 'RewriteRule ^%s/([0-9]+)\-[a-zA-Z0-9-]*$ '.__PS_BASE_URI__.'modules/'.$module_name.'/page.php?id_guide_post=$1 [QSA,L]'."\n";
|
||||
|
||||
$str_rewrite_rules =
|
||||
"RewriteRule ^guide$ ".__PS_BASE_URI__."modules/purchaseguide/rubrique.php [QSA,L]". "\n" .
|
||||
"RewriteRule ^guide/([0-9]+)\-([a-zA-Z0-9-]*)$ ".__PS_BASE_URI__."modules/purchaseguide/rubrique.php?cid=$1 [QSA,L]". "\n" .
|
||||
"RewriteRule ^guide/([0-9]+)\-([a-zA-Z0-9-]*)/([0-9]+)\-([a-zA-Z0-9-]*)$ ".__PS_BASE_URI__."modules/purchaseguide/rubrique.php?cid=$1&sid=$3 [QSA,L]". "\n" .
|
||||
"RewriteRule ^guide/([0-9]+)\-([a-zA-Z0-9-]*)/([0-9]+)\-([a-zA-Z0-9-]*)/([0-9]+)\-([a-zA-Z0-9-]*)$ ".__PS_BASE_URI__."modules/purchaseguide/post.php?cid=$1&sid=$3&id=$5 [QSA,L]";
|
||||
|
||||
if(count($langs) > 1) {
|
||||
$rewrite_rules = '';
|
||||
@ -41,7 +44,7 @@ class AdminGuide extends AdminTab
|
||||
|
||||
$smarty->assign('rewrite_rules', htmlentities($rewrite_rules));
|
||||
|
||||
echo $smarty->fetch(__DIR__.'/templates/home_adminguide.tpl');
|
||||
echo $smarty->fetch(__DIR__.'/views/templates/admin/home_adminguide.tpl');
|
||||
}
|
||||
}
|
||||
}
|
@ -14,6 +14,7 @@ class AdminGuideCategories extends AdminTab
|
||||
public function __construct()
|
||||
{
|
||||
global $cookie;
|
||||
|
||||
$this->maxImageBytes = (Configuration::get('PS_LIMIT_UPLOAD_IMAGE_VALUE') * 1000000);
|
||||
|
||||
$this->table = 'guide_category';
|
||||
@ -23,61 +24,216 @@ class AdminGuideCategories extends AdminTab
|
||||
$this->delete = true;
|
||||
$this->view = true;
|
||||
|
||||
|
||||
$this->fieldsDisplay = array(
|
||||
'id_guide_category' => array(
|
||||
'title' => $this->l('ID'),
|
||||
'align' => 'center',
|
||||
'title' => $this->l('ID'),
|
||||
'align' => 'center',
|
||||
'width' => 30
|
||||
),
|
||||
),
|
||||
'name' => array(
|
||||
'title' => $this->l('Title'),
|
||||
'title' => $this->l('Title'),
|
||||
'width' => 100
|
||||
),
|
||||
),
|
||||
'description' => array(
|
||||
'title' => $this->l('Description'),
|
||||
'width' => 500,
|
||||
'maxlength' => 90,
|
||||
'title' => $this->l('Description'),
|
||||
'width' => 500,
|
||||
'maxlength' => 90,
|
||||
'orderby' => false
|
||||
),
|
||||
'position' => array(
|
||||
'title' => $this->l('Position'),
|
||||
'width' => 40,
|
||||
'filter_key' => 'position',
|
||||
'align' => 'center',
|
||||
'position' => 'position'
|
||||
),
|
||||
),
|
||||
'position' => array(
|
||||
'title' => $this->l('Position'),
|
||||
'width' => 40,
|
||||
'filter_key' => 'position',
|
||||
'align' => 'center',
|
||||
'position' => 'position'
|
||||
),
|
||||
'active' => array(
|
||||
'title' => $this->l('Displayed'),
|
||||
'active' => 'status',
|
||||
'align' => 'center',
|
||||
'type' => 'bool',
|
||||
'title' => $this->l('Displayed'),
|
||||
'active' => 'status',
|
||||
'align' => 'center',
|
||||
'type' => 'bool',
|
||||
'orderby' => false
|
||||
)
|
||||
);
|
||||
)
|
||||
);
|
||||
|
||||
if (isset($_GET['delete'.$this->table])) {
|
||||
self::$current_category = new GuideCategory(
|
||||
(int)(Tools::getValue('id_guide_category_parent', 0))
|
||||
);
|
||||
self::$current_category = new GuideCategory((int)(Tools::getValue('id_guide_category_parent', 0)));
|
||||
}
|
||||
else {
|
||||
self::$current_category = new GuideCategory(
|
||||
(int)(
|
||||
Tools::getValue('id_guide_category',
|
||||
Tools::getValue('id_guide_category_parent', 0))
|
||||
)
|
||||
);
|
||||
self::$current_category = new GuideCategory((int)(Tools::getValue('id_guide_category', Tools::getValue('id_guide_category_parent', 0))));
|
||||
}
|
||||
|
||||
$this->_select = 'position ';
|
||||
$this->_filter = 'AND a.`id_parent` = '.(int)(self::$current_category->id);
|
||||
$this->_orderBy = 'position';
|
||||
$this->_orderWay = 'DESC';
|
||||
$this->_select = 'position ';
|
||||
$this->identifiersDnd['id_guide_category'] = 'id_guide_category';
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function postProcess()
|
||||
{
|
||||
if (isset($_GET['delete'.$this->table]) || Tools::getValue('submitDel'.$this->table)) {
|
||||
$this->postProcessDelete();
|
||||
return;
|
||||
}
|
||||
|
||||
if (self::$current_category->id != 0) {
|
||||
$this->noLink = true;
|
||||
}
|
||||
|
||||
parent::postProcess();
|
||||
}
|
||||
|
||||
protected function afterUpdate()
|
||||
{
|
||||
return $this->afterAdd();
|
||||
}
|
||||
|
||||
protected function afterAdd()
|
||||
{
|
||||
if (isset($_FILES['image']['tmp_name']) && $_FILES['image']['tmp_name'] != NULL) {
|
||||
$object = $this->loadObject();
|
||||
$error = checkImage($_FILES['image'], $this->maxImageSize);
|
||||
if ($error) {
|
||||
$this->_errors[] = $error;
|
||||
return false;
|
||||
}
|
||||
|
||||
$tmpName = tempnam(_PS_TMP_IMG_DIR_, 'PS');
|
||||
|
||||
if (!$tmpName OR !move_uploaded_file($_FILES['image']['tmp_name'], $tmpName)) {
|
||||
$this->_errors[] = Tools::displayError('An error occurred during the image upload');
|
||||
return false;
|
||||
}
|
||||
|
||||
$new_path = $object->getImageFilePath();
|
||||
|
||||
if (file_exists($new_path)) {
|
||||
@unlink($new_path);
|
||||
}
|
||||
|
||||
if (!imageResize($tmpName, $new_path, self::IMG_WIDTH, self::IMG_HEIGHT)) {
|
||||
$this->_errors[] = Tools::displayError('An error occurred while copying image.');
|
||||
return false;
|
||||
}
|
||||
|
||||
@unlink($tmpName);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private function postProcessDelete()
|
||||
{
|
||||
global $currentIndex;
|
||||
|
||||
if ($this->tabAccess['delete'] === '1')
|
||||
{
|
||||
if (isset($_GET['delete'.$this->table])) {
|
||||
$object = $this->loadObject();
|
||||
|
||||
if (Validate::isLoadedObject($object)) {
|
||||
$result = $object->delete();
|
||||
|
||||
if (!$result) {
|
||||
if ($object->getDeleteError()==1) {
|
||||
$this->_errors[] = Tools::displayError($this->l('The category has at least one sub category'));
|
||||
}
|
||||
else if ($object->getDeleteError()==2) {
|
||||
$this->_errors[] = Tools::displayError($this->l('The category contains at least one page'));
|
||||
}
|
||||
else {
|
||||
$this->_errors[] = Tools::displayError('An error occurred during deletion.');
|
||||
}
|
||||
}
|
||||
else {
|
||||
Tools::redirectAdmin($currentIndex.'&id_guide_category_parent='.self::$current_category->id.'&conf=1&token='.$this->token);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$this->_errors[] = Tools::displayError('An error occurred while deleting object.').' <b>'.$this->table.'</b> '.Tools::displayError('(cannot load object)');
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
elseif (Tools::getValue('submitDel'.$this->table)) {
|
||||
$object = new GuideCategory();
|
||||
$result = $object->deleteSelection(Tools::getValue($this->table.'Box'));
|
||||
|
||||
if (!$result) {
|
||||
if ($object->getDeleteError()==1) {
|
||||
$this->_errors[] = Tools::displayError($this->l('One of the selected categories has at least one sub category'));
|
||||
}
|
||||
elseif ($object->getDeleteError()==2) {
|
||||
$this->_errors[] = Tools::displayError($this->l('One of the selected categories contains at least one page'));
|
||||
}
|
||||
else {
|
||||
$this->_errors[] = Tools::displayError('An error occurred while deleting selection.');
|
||||
}
|
||||
}
|
||||
else {
|
||||
Tools::redirectAdmin($currentIndex.'&id_guide_category_parent='.self::$current_category->id.'&conf=1&token='.$this->token);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected function _displayEditLink($token = NULL, $id)
|
||||
{
|
||||
global $currentIndex;
|
||||
|
||||
$_cacheLang['Edit'] = $this->l('Edit');
|
||||
|
||||
echo '
|
||||
<a href="'.$currentIndex.'&'.$this->identifier.'='.$id.'&update'.$this->table.
|
||||
'&token='.($token!=NULL ? $token : $this->token).
|
||||
(self::$current_category->id==0 ? '' : '&id_guide_category_parent='.self::$current_category->id).'">
|
||||
<img src="../img/admin/edit.gif" alt="" title="'.$_cacheLang['Edit'].'" /></a>';
|
||||
}
|
||||
|
||||
protected function _displayDeleteLink($token = NULL, $id)
|
||||
{
|
||||
global $currentIndex;
|
||||
|
||||
$_cacheLang['Delete'] = $this->l('Delete');
|
||||
$_cacheLang['DeleteItem'] = $this->l('Delete item #', __CLASS__, TRUE, FALSE);
|
||||
|
||||
echo '
|
||||
<a href="'.$currentIndex.'&'.$this->identifier.'='.$id.'&delete'.$this->table.'&token='.($token!=NULL ? $token : $this->token).'&id_guide_category_parent='.self::$current_category->id.'" onclick="return confirm(\''.$_cacheLang['DeleteItem'].$id.' ?'.
|
||||
(!is_null($this->specificConfirmDelete) ? '\r'.$this->specificConfirmDelete : '').'\');">
|
||||
<img src="../img/admin/delete.gif" alt="'.$_cacheLang['Delete'].'" title="'.$_cacheLang['Delete'].'" /></a>';
|
||||
}
|
||||
|
||||
protected function _displayViewLink($token = NULL, $id)
|
||||
{
|
||||
$category = new GuideCategory($id);
|
||||
if ($category->id_parent != 0) {
|
||||
$this->_displayPostLink($token, $id);
|
||||
}
|
||||
|
||||
global $currentIndex;
|
||||
|
||||
$_cacheLang['View'] = $this->l('View');
|
||||
|
||||
echo '
|
||||
<a href="'._PS_BASE_URL_SSL_.'/modules/purchaseguide/post.php?cid='.$id.'" target="_blank">
|
||||
<img src="../img/admin/details.gif" alt="'.$_cacheLang['View'].'" title="'.$_cacheLang['View'].'" /></a>';
|
||||
}
|
||||
|
||||
protected function _displayPostLink($token = NULL, $id)
|
||||
{
|
||||
$_cacheLang['Post'] = $this->l('View Post');
|
||||
|
||||
$currentIndex = '?tab=AdminGuidePosts';
|
||||
$token = Tools::getAdminTokenLite('AdminGuidePosts');
|
||||
|
||||
echo '
|
||||
<a href="'.$currentIndex.'&'.$this->identifier.'='.$id.
|
||||
'&token='.($token!=NULL ? $token : $this->token).'">
|
||||
<img src="../img/admin/arrow-right.png" alt="" title="'.$_cacheLang['Post'].'" /></a>';
|
||||
}
|
||||
|
||||
public static function getCurrentCategory()
|
||||
{
|
||||
@ -89,9 +245,9 @@ class AdminGuideCategories extends AdminTab
|
||||
global $currentIndex, $cookie, $smarty;
|
||||
parent::displayForm();
|
||||
|
||||
if (!($obj = $this->loadObject(true)))
|
||||
return;
|
||||
|
||||
if (!($obj = $this->loadObject(true))) {
|
||||
return;
|
||||
}
|
||||
|
||||
$langs = Language::getLanguages(false);
|
||||
|
||||
@ -105,28 +261,28 @@ class AdminGuideCategories extends AdminTab
|
||||
'options_map' => ['id_guide_category', 'name', 'level'],
|
||||
'empty_option' => ['value'=>'0', 'label'=>$this->l('No parent category')],
|
||||
'initial_value' => $obj->id_parent?$obj->id_parent:self::$current_category->id
|
||||
),
|
||||
),
|
||||
'id_category_family' => array(
|
||||
'title' => $this->l('Famille'),
|
||||
'type' => 'select',
|
||||
'options_raw' => GuideCategory::findFamiliesTree($cookie->id_lang),
|
||||
'options_map' => ['id_category_family', 'name', 'level'],
|
||||
'initial_value' => $obj->id_category_family
|
||||
),
|
||||
),
|
||||
'name' => array(
|
||||
'title' => $this->l('Title'),
|
||||
'title' => $this->l('Title'),
|
||||
'type' => 'text',
|
||||
'required' => true,
|
||||
'translatable' => true,
|
||||
'attrs' => [
|
||||
'onkeyup' => 'copy2friendlyURL();'
|
||||
]
|
||||
),
|
||||
]
|
||||
),
|
||||
'description' => array(
|
||||
'title' => $this->l('Description'),
|
||||
'type' => 'textarea',
|
||||
'translatable' => true,
|
||||
),
|
||||
),
|
||||
'image' => array(
|
||||
'title' => $this->l('Image'),
|
||||
'type' => 'file',
|
||||
@ -135,29 +291,29 @@ class AdminGuideCategories extends AdminTab
|
||||
'allowed_format' => 'JPEG',
|
||||
'html_file' => "img",
|
||||
'path' => $obj->getImageFileUrl().'?rand='.time()
|
||||
]
|
||||
),
|
||||
]
|
||||
),
|
||||
'active' => array(
|
||||
'title' => $this->l('Displayed'),
|
||||
'type' => 'yesno',
|
||||
'required' => true,
|
||||
),
|
||||
),
|
||||
'link_rewrite' => array(
|
||||
'title' => $this->l('Simplified URL'),
|
||||
'title' => $this->l('Simplified URL'),
|
||||
'type' => 'text',
|
||||
'required' => true,
|
||||
),
|
||||
),
|
||||
'meta_title' => array(
|
||||
'title' => $this->l('Title (META)'),
|
||||
'title' => $this->l('Title (META)'),
|
||||
'type' => 'text',
|
||||
'translatable' => true,
|
||||
),
|
||||
),
|
||||
'meta_description' => array(
|
||||
'title' => $this->l('Description (META)'),
|
||||
'title' => $this->l('Description (META)'),
|
||||
'type' => 'textarea',
|
||||
'translatable' => true,
|
||||
),
|
||||
);
|
||||
),
|
||||
);
|
||||
|
||||
$form->setTitle($this->l('Purchase guide category'));
|
||||
$form->setFields($this->fieldsForm);
|
||||
@ -191,31 +347,32 @@ class AdminGuideCategories extends AdminTab
|
||||
public function displayList()
|
||||
{
|
||||
global $currentIndex;
|
||||
|
||||
|
||||
$this->displayTop();
|
||||
|
||||
if ($this->edit AND (!isset($this->noAdd) OR !$this->noAdd))
|
||||
if ($this->edit AND (!isset($this->noAdd) OR !$this->noAdd)) {
|
||||
echo '<br /><a href="'.$currentIndex.'&id_guide_category_parent='.self::$current_category->id.'&add'.$this->table.'&token='.$this->token.'"><img src="../img/admin/add.gif" border="0" /> '.$this->l('Add new').'</a><br /><br />';
|
||||
}
|
||||
|
||||
// Append when we get a syntax error in SQL query
|
||||
if ($this->_list === false)
|
||||
{
|
||||
if ($this->_list === false) {
|
||||
$this->displayWarning($this->l('Bad SQL query'));
|
||||
return false;
|
||||
}
|
||||
|
||||
// Display list header (filtering, pagination and column names)
|
||||
$this->displayListHeader();
|
||||
if (!sizeof($this->_list))
|
||||
if (!sizeof($this->_list)) {
|
||||
echo '<tr><td class="center" colspan="'.(sizeof($this->fieldsDisplay) + 2).'">'.$this->l('No items found').'</td></tr>';
|
||||
}
|
||||
|
||||
$this->_orderBy = 'position';
|
||||
|
||||
// Show the content of the table
|
||||
$this->displayListContent();
|
||||
|
||||
// Close list table and submit button
|
||||
$this->displayListFooter();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -228,137 +385,4 @@ class AdminGuideCategories extends AdminTab
|
||||
$this->displayRequiredFields();
|
||||
$this->includeSubTab('display');
|
||||
}
|
||||
|
||||
protected function _displayEditLink($token = NULL, $id)
|
||||
{
|
||||
global $currentIndex;
|
||||
|
||||
$_cacheLang['Edit'] = $this->l('Edit');
|
||||
|
||||
echo '
|
||||
<a href="'.$currentIndex.'&'.$this->identifier.'='.$id.'&update'.$this->table.'&token='.($token!=NULL ? $token : $this->token).'&id_guide_category_parent='.self::$current_category->id.'">
|
||||
<img src="../img/admin/edit.gif" alt="" title="'.$_cacheLang['Edit'].'" /></a>';
|
||||
}
|
||||
|
||||
protected function _displayDeleteLink($token = NULL, $id)
|
||||
{
|
||||
global $currentIndex;
|
||||
|
||||
$_cacheLang['Delete'] = $this->l('Delete');
|
||||
$_cacheLang['DeleteItem'] = $this->l('Delete item #', __CLASS__, TRUE, FALSE);
|
||||
|
||||
echo '
|
||||
<a href="'.$currentIndex.'&'.$this->identifier.'='.$id.'&delete'.$this->table.'&token='.($token!=NULL ? $token : $this->token).'&id_guide_category_parent='.self::$current_category->id.'" onclick="return confirm(\''.$_cacheLang['DeleteItem'].$id.' ?'.
|
||||
(!is_null($this->specificConfirmDelete) ? '\r'.$this->specificConfirmDelete : '').'\');">
|
||||
<img src="../img/admin/delete.gif" alt="'.$_cacheLang['Delete'].'" title="'.$_cacheLang['Delete'].'" /></a>';
|
||||
}
|
||||
|
||||
|
||||
public function postProcess()
|
||||
{
|
||||
if (isset($_GET['delete'.$this->table]) ||
|
||||
Tools::getValue('submitDel'.$this->table)) {
|
||||
$this->postProcessDelete();
|
||||
return;
|
||||
}
|
||||
|
||||
parent::postProcess();
|
||||
}
|
||||
|
||||
|
||||
protected function afterUpdate()
|
||||
{
|
||||
return $this->afterAdd();
|
||||
}
|
||||
|
||||
|
||||
protected function afterAdd()
|
||||
{
|
||||
if (isset($_FILES['image']['tmp_name']) &&
|
||||
$_FILES['image']['tmp_name'] != NULL) {
|
||||
|
||||
$object = $this->loadObject();
|
||||
$error = checkImage( $_FILES['image'], $this->maxImageSize);
|
||||
if ($error) {
|
||||
$this->_errors[] = $error;
|
||||
return false;
|
||||
}
|
||||
|
||||
$tmpName = tempnam(_PS_TMP_IMG_DIR_, 'PS');
|
||||
|
||||
if (!$tmpName OR !move_uploaded_file($_FILES['image']['tmp_name'], $tmpName)) {
|
||||
$this->_errors[] = Tools::displayError('An error occurred during the image upload');
|
||||
return false;
|
||||
}
|
||||
|
||||
$new_path = $object->getImageFilePath();
|
||||
|
||||
if (file_exists($new_path)) {
|
||||
@unlink($new_path);
|
||||
}
|
||||
if (!imageResize($tmpName, $new_path, self::IMG_WIDTH, self::IMG_HEIGHT)) {
|
||||
$this->_errors[] = Tools::displayError('An error occurred while copying image.');
|
||||
return false;
|
||||
}
|
||||
|
||||
@unlink($tmpName);
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private function postProcessDelete()
|
||||
{
|
||||
global $currentIndex;
|
||||
|
||||
if ($this->tabAccess['delete'] === '1')
|
||||
{
|
||||
if (isset($_GET['delete'.$this->table])) {
|
||||
$object = $this->loadObject();
|
||||
|
||||
if (Validate::isLoadedObject($object)) {
|
||||
$result = $object->delete();
|
||||
|
||||
if (!$result) {
|
||||
if ($object->getDeleteError()==1) {
|
||||
$this->_errors[] = Tools::displayError($this->l('The category has at least one sub category'));
|
||||
}
|
||||
else if ($object->getDeleteError()==2) {
|
||||
$this->_errors[] = Tools::displayError($this->l('The category contains at least one page'));
|
||||
}
|
||||
else {
|
||||
$this->_errors[] = Tools::displayError('An error occurred during deletion.');
|
||||
}
|
||||
}
|
||||
else {
|
||||
Tools::redirectAdmin($currentIndex.'&id_guide_category_parent='.self::$current_category->id.'&conf=1&token='.$this->token);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$this->_errors[] = Tools::displayError('An error occurred while deleting object.').' <b>'.$this->table.'</b> '.Tools::displayError('(cannot load object)');
|
||||
}
|
||||
return;
|
||||
}
|
||||
elseif (Tools::getValue('submitDel'.$this->table)) {
|
||||
$object = new GuideCategory();
|
||||
$result = $object->deleteSelection(Tools::getValue($this->table.'Box'));
|
||||
|
||||
if (!$result) {
|
||||
if ($object->getDeleteError()==1) {
|
||||
$this->_errors[] = Tools::displayError($this->l('One of the selected categories has at least one sub category'));
|
||||
}
|
||||
elseif ($object->getDeleteError()==2) {
|
||||
$this->_errors[] = Tools::displayError($this->l('One of the selected categories contains at least one page'));
|
||||
}
|
||||
else {
|
||||
$this->_errors[] = Tools::displayError('An error occurred while deleting selection.');
|
||||
}
|
||||
}
|
||||
else {
|
||||
Tools::redirectAdmin($currentIndex.'&id_guide_category_parent='.self::$current_category->id.'&conf=1&token='.$this->token);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,6 @@ require_once(__DIR__.'/classes/GuidePost.php');
|
||||
require_once(__DIR__.'/classes/GuideCategory.php');
|
||||
require_once(__DIR__.'/classes/FormBuilder.php');
|
||||
|
||||
|
||||
class AdminGuidePosts extends AdminTab
|
||||
{
|
||||
public function __construct()
|
||||
@ -18,62 +17,108 @@ class AdminGuidePosts extends AdminTab
|
||||
$this->view = true;
|
||||
$this->delete = true;
|
||||
|
||||
$this->fieldsDisplay = array(
|
||||
'id_guide_post' => array(
|
||||
'title' => $this->l('ID'),
|
||||
'align' => 'center',
|
||||
'width' => 25
|
||||
),
|
||||
'name' => array(
|
||||
'title' => $this->l('Category'),
|
||||
'width' => 200,
|
||||
),
|
||||
'link_rewrite' => array(
|
||||
'title' => $this->l('URL'),
|
||||
'width' => 200
|
||||
),
|
||||
'meta_title' => array(
|
||||
'title' => $this->l('Title'),
|
||||
'width' => 300
|
||||
),
|
||||
'position' => array(
|
||||
'title' => $this->l('Position'),
|
||||
'width' => 40,
|
||||
'filter_key' => 'position',
|
||||
'align' => 'center',
|
||||
'position' => 'position'
|
||||
),
|
||||
'active' => array(
|
||||
'title' => $this->l('Enabled'),
|
||||
'width' => 25,
|
||||
'align' => 'center',
|
||||
'active' => 'status',
|
||||
'type' => 'bool',
|
||||
'orderby' => false
|
||||
)
|
||||
);
|
||||
$this->_select = 'a.position, gcl.name, a.id_guide_category ';
|
||||
|
||||
$this->_join = '
|
||||
LEFT JOIN `'._DB_PREFIX_.'guide_category` gc
|
||||
ON gc.`id_guide_category` = a.`id_guide_category`
|
||||
LEFT JOIN `'._DB_PREFIX_.'guide_category_lang` gcl
|
||||
ON (gcl.`id_guide_category` = gc.`id_guide_category` AND gcl.`id_lang` = '.(int)($cookie->id_lang).')';
|
||||
|
||||
$this->_orderBy = 'position';
|
||||
$this->_orderWay = 'ASC';
|
||||
$this->identifiersDnd['id_guide_post'] = 'id_guide_post';
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
protected function _displayViewLink($token = null, $id)
|
||||
{
|
||||
$_cacheLang['View'] = $this->l('View');
|
||||
|
||||
echo '
|
||||
<a href="'._PS_BASE_URL_SSL_.'/modules/purchaseguide/post.php?pid='.$id.'" target="_blank">
|
||||
<img src="../img/admin/details.gif" alt="'.$_cacheLang['View'].'" title="'.$_cacheLang['View'].'" /></a>';
|
||||
}
|
||||
|
||||
public function postProcess()
|
||||
{
|
||||
global $cookie, $currentIndex;
|
||||
|
||||
$this->fieldsDisplay = array(
|
||||
'id_guide_post' => array(
|
||||
'title' => $this->l('ID'),
|
||||
'align' => 'center',
|
||||
'width' => 25
|
||||
),
|
||||
'name' => array(
|
||||
'title' => $this->l('Category'),
|
||||
'width' => 200,
|
||||
),
|
||||
'link_rewrite' => array(
|
||||
'title' => $this->l('URL'),
|
||||
'width' => 200
|
||||
),
|
||||
'meta_title' => array(
|
||||
'title' => $this->l('Title'),
|
||||
'width' => 300
|
||||
),
|
||||
'active' => array(
|
||||
'title' => $this->l('Enabled'),
|
||||
'width' => 25,
|
||||
'align' => 'center',
|
||||
'active' => 'status',
|
||||
'type' => 'bool',
|
||||
'orderby' => false
|
||||
)
|
||||
);
|
||||
$this->_select = 'a.`position`, gcl.`name`, a.`id_guide_category` ';
|
||||
$this->_join = '
|
||||
LEFT JOIN `'._DB_PREFIX_.'guide_category` gc
|
||||
ON gc.`id_guide_category` = a.`id_guide_category`
|
||||
LEFT JOIN `'._DB_PREFIX_.'guide_category_lang` gcl
|
||||
ON (gcl.`id_guide_category` = gc.`id_guide_category` AND gcl.`id_lang` = '.(int)($cookie->id_lang).')';
|
||||
|
||||
if (Tools::getIsset('id_guide_category')) {
|
||||
$this->fieldsDisplay['position'] = array(
|
||||
'title' => $this->l('Position'),
|
||||
'width' => 40,
|
||||
'filter_key' => 'position',
|
||||
'align' => 'center',
|
||||
'position' => 'position'
|
||||
);
|
||||
$this->_where = ' AND a.`id_guide_category`='.(int)Tools::getValue('id_guide_category');
|
||||
$currentIndex.= '&id_guide_category='.(int)Tools::getValue('id_guide_category');
|
||||
}
|
||||
|
||||
parent::postProcess();
|
||||
}
|
||||
|
||||
public function displayTop()
|
||||
{
|
||||
global $cookie;
|
||||
|
||||
$id_guide_category = Tools::getValue('id_guide_category', 0);
|
||||
if ($id_guide_category == 0) {
|
||||
|
||||
} else {
|
||||
$category = new GuideCategory($id_guide_category);
|
||||
|
||||
$currentIndex = '?tab=AdminGuideCategories';
|
||||
$token = Tools::getAdminTokenLite('AdminGuideCategories');
|
||||
|
||||
echo '<a href="'.$currentIndex.'&token='.$token.'&id_guide_category='.$category->id_parent.
|
||||
'"><img src="../img/admin/arrow2.gif" /> '.$this->l('back to').' '.
|
||||
$category->name[$cookie->id_lang].'</a><br /><br />';
|
||||
|
||||
echo $this->l('Current category').' : '.$category->name[$cookie->id_lang].'<br /><br />';
|
||||
}
|
||||
}
|
||||
|
||||
public function displayList()
|
||||
{
|
||||
$this->_orderBy = 'position';
|
||||
parent::displayList();
|
||||
}
|
||||
|
||||
public function displayForm($token = NULL)
|
||||
{
|
||||
global $currentIndex, $cookie, $smarty;
|
||||
parent::displayForm();
|
||||
|
||||
if (!($obj = $this->loadObject(true)))
|
||||
return;
|
||||
if (!($obj = $this->loadObject(true))) {
|
||||
return;
|
||||
}
|
||||
|
||||
$langs = Language::getLanguages(false);
|
||||
|
||||
@ -86,9 +131,9 @@ class AdminGuidePosts extends AdminTab
|
||||
'options_raw' => GuideCategory::findCategoriesTree($cookie->id_lang),
|
||||
'options_map' => ['id_guide_category', 'name', 'level'],
|
||||
'initial_value' => $obj->id_guide_category
|
||||
),
|
||||
),
|
||||
'meta_title' => array(
|
||||
'title' => $this->l('Title (META)'),
|
||||
'title' => $this->l('Title (META)'),
|
||||
'type' => 'text',
|
||||
'translatable' => true,
|
||||
'attrs' => [
|
||||
@ -96,12 +141,12 @@ class AdminGuidePosts extends AdminTab
|
||||
]
|
||||
),
|
||||
'meta_description' => array(
|
||||
'title' => $this->l('Description (META)'),
|
||||
'title' => $this->l('Description (META)'),
|
||||
'type' => 'textarea',
|
||||
'translatable' => true,
|
||||
),
|
||||
'link_rewrite' => array(
|
||||
'title' => $this->l('Simplified URL'),
|
||||
'title' => $this->l('Simplified URL'),
|
||||
'type' => 'text',
|
||||
'required' => true,
|
||||
),
|
||||
@ -121,33 +166,5 @@ class AdminGuidePosts extends AdminTab
|
||||
$form->setFields($this->fieldsForm);
|
||||
$form->setSubmitButton($this->l('Save'));
|
||||
$form->display($smarty, $langs, $obj);
|
||||
|
||||
}
|
||||
|
||||
public function postProcess()
|
||||
{
|
||||
global $cookie, $currentIndex;
|
||||
|
||||
$link = new Link();
|
||||
|
||||
if (Tools::isSubmit('viewguide_post') AND ($id_guide_post = (int)(Tools::getValue('id_guide_post'))) AND $guide_post = new GuidePost($id_guide_post, (int)($cookie->id_lang)) AND Validate::isLoadedObject($guide_post))
|
||||
{
|
||||
$redir = $link->getGuideLink($guide_post, null, null,
|
||||
$cookie->id_lang);
|
||||
|
||||
if (!$guide_post->active)
|
||||
{
|
||||
$admin_dir = dirname($_SERVER['PHP_SELF']);
|
||||
$admin_dir = substr($admin_dir, strrpos($admin_dir,'/') + 1);
|
||||
$redir .= '?adtoken='.Tools::encrypt('PreviewGuidePost'.$guide_post->id).'&ad='.$admin_dir;
|
||||
}
|
||||
|
||||
Tools::redirectAdmin($redir);
|
||||
}
|
||||
else {
|
||||
parent::postProcess();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
if (!defined('FORM_DIR')) {
|
||||
define('FORM_DIR', __DIR__.'/../templates/form/');
|
||||
define('FORM_DIR', __DIR__.'/../views/templates/admin/form/');
|
||||
}
|
||||
|
||||
class FormBuilder
|
||||
@ -31,7 +31,7 @@ class FormBuilder
|
||||
|
||||
public function setSubmitButton($title)
|
||||
{
|
||||
$this->submit_button_title = $title;
|
||||
$this->submit_button_title = $title;
|
||||
}
|
||||
|
||||
public function setFields($fields)
|
||||
@ -56,7 +56,7 @@ class FormBuilder
|
||||
'module_dir' => _MODULE_DIR_,
|
||||
'button_submit' => [
|
||||
'name' => $this->submitName($this->form_action),
|
||||
'value' => $this->submit_button_title
|
||||
'value' => $this->submit_button_title
|
||||
]
|
||||
];
|
||||
$smarty->assign($smarty_params);
|
||||
@ -124,8 +124,8 @@ class FormBuilder
|
||||
$html_attrs = '';
|
||||
foreach($field['attrs'] as $key => $value) {
|
||||
$html_attrs .= " $key = \"".$value."\"";
|
||||
}
|
||||
$field['html_attrs'] = $html_attrs;
|
||||
}
|
||||
$field['html_attrs'] = $html_attrs;
|
||||
}
|
||||
}
|
||||
|
||||
@ -168,11 +168,11 @@ class FormBuilder
|
||||
foreach ($langs as $lang) {
|
||||
$val = $this->getFieldValue($obj, $key, $field['initial_value'], $lang['id_lang']);
|
||||
$value[$lang['id_lang']] = htmlentities(
|
||||
$val,
|
||||
ENT_COMPAT,
|
||||
$val,
|
||||
ENT_COMPAT,
|
||||
'UTF-8'
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
$field['value'] = $this->getFieldValue($obj, $key, $field['initial_value'], null);
|
||||
|
@ -2,63 +2,81 @@
|
||||
|
||||
class GuideCategory extends ObjectModel
|
||||
{
|
||||
public $id;
|
||||
public $id_guide_category;
|
||||
public $name;
|
||||
public $active = 1;
|
||||
public $description;
|
||||
public $id_parent;
|
||||
public $id_category_family;
|
||||
public $position;
|
||||
public $level_depth;
|
||||
public $link_rewrite;
|
||||
public $meta_title;
|
||||
public $meta_keywords;
|
||||
public $meta_description;
|
||||
public $id;
|
||||
public $id_guide_category;
|
||||
public $name;
|
||||
public $active = 1;
|
||||
public $description;
|
||||
public $id_parent;
|
||||
public $id_category_family;
|
||||
public $position;
|
||||
public $level_depth;
|
||||
public $link_rewrite;
|
||||
public $meta_title;
|
||||
public $meta_keywords;
|
||||
public $meta_description;
|
||||
|
||||
protected $table = 'guide_category';
|
||||
protected $identifier = 'id_guide_category';
|
||||
protected $table = 'guide_category';
|
||||
protected $identifier = 'id_guide_category';
|
||||
|
||||
protected $tables = array ('guide_category', 'guide_category_lang');
|
||||
protected $tables = array (
|
||||
'guide_category',
|
||||
'guide_category_lang',
|
||||
);
|
||||
|
||||
protected $fieldsRequired = array('id_parent', 'active');
|
||||
protected $fieldsSize = array('id_parent' => 10, 'active' => 1);
|
||||
protected $fieldsValidate = array('active' => 'isBool', 'id_parent' => 'isUnsignedInt');
|
||||
protected $fieldsRequiredLang = array('name', 'link_rewrite');
|
||||
protected $fieldsSizeLang = array(
|
||||
'name' => 64,
|
||||
'link_rewrite' => 64,
|
||||
'meta_title' => 128,
|
||||
'meta_description' => 255,
|
||||
protected $fieldsRequired = array(
|
||||
'id_parent',
|
||||
'active'
|
||||
);
|
||||
protected $fieldsSize = array(
|
||||
'id_parent' => 10,
|
||||
'active' => 1
|
||||
);
|
||||
protected $fieldsValidate = array(
|
||||
'active' => 'isBool',
|
||||
'id_parent' => 'isUnsignedInt'
|
||||
);
|
||||
protected $fieldsRequiredLang = array(
|
||||
'name',
|
||||
'link_rewrite'
|
||||
);
|
||||
protected $fieldsSizeLang = array(
|
||||
'name' => 64,
|
||||
'link_rewrite' => 64,
|
||||
'meta_title' => 128,
|
||||
'meta_description' => 255,
|
||||
'meta_keywords' => 255
|
||||
);
|
||||
);
|
||||
protected $fieldsValidateLang = array(
|
||||
'name' => 'isCatalogName',
|
||||
'link_rewrite' => 'isLinkRewrite',
|
||||
'name' => 'isCatalogName',
|
||||
'link_rewrite' => 'isLinkRewrite',
|
||||
'description' => 'isCleanHtml',
|
||||
'meta_title' => 'isGenericName',
|
||||
'meta_description' => 'isGenericName',
|
||||
'meta_title' => 'isGenericName',
|
||||
'meta_description' => 'isGenericName',
|
||||
'meta_keywords' => 'isGenericName'
|
||||
);
|
||||
);
|
||||
|
||||
private $error;
|
||||
|
||||
public function getFields()
|
||||
{
|
||||
parent::validateFields();
|
||||
if (isset($this->id))
|
||||
$fields['id_guide_category'] = (int)($this->id);
|
||||
|
||||
if (isset($this->id)) {
|
||||
$fields['id_guide_category'] = (int)($this->id);
|
||||
}
|
||||
$fields['id_category_family'] = (int)($this->id_category_family);
|
||||
$fields['active'] = (int)($this->active);
|
||||
$fields['id_parent'] = (int)($this->id_parent);
|
||||
$fields['position'] = (int)($this->position);
|
||||
$fields['level_depth'] = (int)($this->level_depth);
|
||||
|
||||
return $fields;
|
||||
}
|
||||
|
||||
public static function getSubPath()
|
||||
{
|
||||
return 'modules/purchaseguide/img';
|
||||
return 'img/purchaseguide';
|
||||
}
|
||||
|
||||
public function getImageFilePath()
|
||||
@ -66,6 +84,7 @@ class GuideCategory extends ObjectModel
|
||||
if ($this->id) {
|
||||
return _PS_ROOT_DIR_.'/'.self::getSubPath().'/'.$this->id.'.jpg';
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
@ -74,6 +93,7 @@ class GuideCategory extends ObjectModel
|
||||
if ($this->id) {
|
||||
return __PS_BASE_URI__.self::getSubPath().'/'.$this->id.'.jpg';
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
@ -90,15 +110,12 @@ class GuideCategory extends ObjectModel
|
||||
$sql .= " AND a.`id_guide_category` <> '".intval($exclude_id)."'";
|
||||
}
|
||||
$rows = array();
|
||||
self::findRecursiveData(
|
||||
$rows,
|
||||
$sql,
|
||||
array(
|
||||
'id_parent' => 0,
|
||||
'identifier' => 'id_guide_category',
|
||||
'level' => -1
|
||||
)
|
||||
);
|
||||
self::findRecursiveData($rows, $sql, array(
|
||||
'id_parent' => 0,
|
||||
'identifier' => 'id_guide_category',
|
||||
'level' => -1
|
||||
));
|
||||
|
||||
return $rows;
|
||||
}
|
||||
|
||||
@ -115,24 +132,17 @@ class GuideCategory extends ObjectModel
|
||||
$sql .= " AND a.`id_category_family` <> '".intval($exclude_id)."'";
|
||||
}
|
||||
$rows = array();
|
||||
self::findRecursiveData(
|
||||
$rows,
|
||||
$sql,
|
||||
array(
|
||||
'id_parent' => 0,
|
||||
'identifier' => 'id_category_family',
|
||||
'level' => -1
|
||||
)
|
||||
);
|
||||
self::findRecursiveData($rows, $sql, array(
|
||||
'id_parent' => 0,
|
||||
'identifier' => 'id_category_family',
|
||||
'level' => -1
|
||||
));
|
||||
|
||||
return $rows;
|
||||
}
|
||||
|
||||
|
||||
private static function findRecursiveData(
|
||||
&$rows,
|
||||
$sql,
|
||||
array $params
|
||||
)
|
||||
private static function findRecursiveData(&$rows, $sql, array $params)
|
||||
{
|
||||
$level = $params['level'];
|
||||
$level++;
|
||||
@ -141,27 +151,25 @@ class GuideCategory extends ObjectModel
|
||||
foreach($resuts as &$row) {
|
||||
$row['level'] = $level;
|
||||
$rows[] = $row;
|
||||
self::findRecursiveData(
|
||||
$rows,
|
||||
$sql,
|
||||
array(
|
||||
'id_parent' => $row[$params['identifier']],
|
||||
'identifier' => $params['identifier'],
|
||||
'level' => $level
|
||||
)
|
||||
);
|
||||
self::findRecursiveData($rows, $sql, array(
|
||||
'id_parent' => $row[$params['identifier']],
|
||||
'identifier' => $params['identifier'],
|
||||
'level' => $level
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/////
|
||||
// Check then return multilingual fields for database interaction
|
||||
//
|
||||
// @return array Multilingual fields
|
||||
///
|
||||
|
||||
public function getTranslationsFieldsChild()
|
||||
{
|
||||
parent::validateFieldsLang();
|
||||
return parent::getTranslationsFields(array('name', 'description', 'link_rewrite', 'meta_title', 'meta_keywords', 'meta_description'));
|
||||
return parent::getTranslationsFields(array(
|
||||
'name',
|
||||
'description',
|
||||
'link_rewrite',
|
||||
'meta_title',
|
||||
'meta_keywords',
|
||||
'meta_description'
|
||||
));
|
||||
}
|
||||
|
||||
public function add($autodate = true, $nullValues = false)
|
||||
@ -172,21 +180,22 @@ class GuideCategory extends ObjectModel
|
||||
|
||||
public function update($autodate = true, $nullValues = false)
|
||||
{
|
||||
$this->position = self::cleanupPositions((int)$this->id_parent);
|
||||
return parent::update($autodate, $nullValues);
|
||||
$this->position = self::getLastPosition((int)$this->id_parent);
|
||||
$ret = parent::update($autodate, $nullValues);
|
||||
$this->cleanupPositions((int)$this->id_parent);
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public function delete()
|
||||
{
|
||||
if ($this->getNbSubCategories($this->id)) {
|
||||
$this->error = 1;
|
||||
return FALSE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
if ($this->getNbPosts($this->id)) {
|
||||
$this->error = 2;
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!parent::delete()) {
|
||||
@ -203,11 +212,11 @@ class GuideCategory extends ObjectModel
|
||||
|
||||
public function deleteSelection($selection)
|
||||
{
|
||||
if (!is_array($selection) OR !Validate::isTableOrIdentifier($this->identifier) OR !Validate::isTableOrIdentifier($this->table))
|
||||
die(Tools::displayError());
|
||||
if (!is_array($selection) OR !Validate::isTableOrIdentifier($this->identifier) OR !Validate::isTableOrIdentifier($this->table)) {
|
||||
die(Tools::displayError());
|
||||
}
|
||||
$result = true;
|
||||
foreach ($selection AS $id)
|
||||
{
|
||||
foreach ($selection AS $id) {
|
||||
$this->id = (int)($id);
|
||||
$result2 = $this->delete();
|
||||
$result = $result && $this->delete();
|
||||
@ -221,28 +230,33 @@ class GuideCategory extends ObjectModel
|
||||
}
|
||||
|
||||
public function updatePosition($way, $position)
|
||||
{
|
||||
{
|
||||
if (!$res = Db::getInstance()->ExecuteS('
|
||||
SELECT cp.`id_guide_category`, cp.`position`, cp.`id_parent`
|
||||
SELECT cp.`id_guide_category`, cp.`position`, cp.`id_parent`
|
||||
FROM `'._DB_PREFIX_.'guide_category` cp
|
||||
WHERE cp.`id_parent` = '.(int)$this->id_parent.'
|
||||
WHERE cp.`id_parent` = '.(int)$this->id_parent.'
|
||||
ORDER BY cp.`position` ASC'
|
||||
))
|
||||
return false;
|
||||
)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach ($res AS $category)
|
||||
if ((int)($category['id_guide_category']) == (int)($this->id))
|
||||
$movedCategory = $category;
|
||||
foreach ($res AS $category) {
|
||||
if ((int)($category['id_guide_category']) == (int)($this->id)) {
|
||||
$movedCategory = $category;
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($movedCategory) || !isset($position)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!isset($movedCategory) || !isset($position))
|
||||
return false;
|
||||
// < and > statements rather than BETWEEN operator
|
||||
// since BETWEEN is treated differently according to databases
|
||||
return (Db::getInstance()->Execute('
|
||||
UPDATE `'._DB_PREFIX_.'guide_category`
|
||||
SET `position`= `position` '.($way ? '- 1' : '+ 1').'
|
||||
WHERE `position`
|
||||
'.($way
|
||||
WHERE `position`
|
||||
'.($way
|
||||
? '> '.(int)($movedCategory['position']).' AND `position` <= '.(int)($position)
|
||||
: '< '.(int)($movedCategory['position']).' AND `position` >= '.(int)($position)).'
|
||||
AND `id_parent`='.(int)($movedCategory['id_parent']))
|
||||
@ -252,14 +266,33 @@ class GuideCategory extends ObjectModel
|
||||
WHERE `id_parent` = '.(int)($movedCategory['id_parent']).'
|
||||
AND `id_guide_category`='.(int)($movedCategory['id_guide_category'])));
|
||||
}
|
||||
|
||||
|
||||
private function cleanupPositions($id_parent)
|
||||
{
|
||||
$result = Db::getInstance()->ExecuteS('
|
||||
SELECT `id_guide_category`
|
||||
FROM `'._DB_PREFIX_.'guide_category`
|
||||
WHERE `id_parent` = '.(int)($id_parent).'
|
||||
ORDER BY `position`');
|
||||
$position = 0;
|
||||
foreach ($result as $row) {
|
||||
$position++;
|
||||
$sql = '
|
||||
UPDATE `'._DB_PREFIX_.'guide_category`
|
||||
SET `position` = '.(int)($position).'
|
||||
WHERE `id_parent` = '.(int)($id_parent).'
|
||||
AND `id_guide_category` = '.(int)($row['id_guide_category']);
|
||||
Db::getInstance()->Execute($sql);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function getLastPosition($id_parent)
|
||||
{
|
||||
return (Db::getInstance()->getValue('SELECT MAX(position)+1 FROM `'._DB_PREFIX_.'guide_category` WHERE `id_parent` = '.(int)($id_parent)));
|
||||
return (Db::getInstance()->getValue('SELECT MAX(position)+1 FROM `'._DB_PREFIX_.
|
||||
'guide_category` WHERE `id_parent` = '.(int)($id_parent)));
|
||||
}
|
||||
|
||||
|
||||
private function getNbSubCategories($id_guide_category)
|
||||
{
|
||||
$sql = 'SELECT COUNT(*)
|
||||
@ -268,35 +301,127 @@ class GuideCategory extends ObjectModel
|
||||
return Db::getInstance()->getValue($sql);
|
||||
}
|
||||
|
||||
|
||||
private function getNbPosts($id_guide_category)
|
||||
{
|
||||
$sql = 'SELECT COUNT(*)
|
||||
FROM `'._DB_PREFIX_.'guide_post`
|
||||
WHERE `id_guide_category` = '.intval($id_guide_category);
|
||||
return Db::getInstance()->getValue($sql);
|
||||
return Db::getInstance()->getValue($sql);
|
||||
}
|
||||
|
||||
|
||||
private function cleanupPositions($id_parent)
|
||||
|
||||
|
||||
|
||||
public function findByCategoryFamily($id, $id_lang)
|
||||
{
|
||||
$sql = 'SELECT `id_guide_category`
|
||||
FROM `'._DB_PREFIX_.'guide_category`
|
||||
WHERE `id_parent` = '.intval($id_parent).'
|
||||
ORDER BY `position` ASC';
|
||||
$rows = Db::getInstance()->ExecuteS($sql);
|
||||
|
||||
$position = 1;
|
||||
foreach($rows as $row) {
|
||||
$sql = 'UPDATE `'._DB_PREFIX_.'guide_category`
|
||||
SET `position` = '.$position.'
|
||||
WHERE `id_guide_category` = '.$row['id_guide_category'];
|
||||
Db::getInstance()->Execute($sql);
|
||||
$position++;
|
||||
}
|
||||
return $position;
|
||||
$sql = "SELECT gc.*, gcl.name FROM `"._DB_PREFIX_."guide_category` gc, `"._DB_PREFIX_."guide_category_lang` gcl
|
||||
WHERE gc.id_guide_category=gcl.id_guide_category AND gcl.id_lang=".$id_lang.
|
||||
" AND gc.id_category_family=".$id;
|
||||
$row = Db::getInstance()->getRow($sql);
|
||||
|
||||
return $row;
|
||||
}
|
||||
|
||||
public function getLinkRewrite($id_lang)
|
||||
{
|
||||
if ($this->id) {
|
||||
return $this->id.'-'.$this->link_rewrite[$id_lang];
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Parent category
|
||||
* @param int $id_category
|
||||
* @param int $id_lang
|
||||
* @return array
|
||||
*/
|
||||
public function getCategoryLang($id_category, $id_lang)
|
||||
{
|
||||
$sql = "SELECT gc.*, gcl.name, gcl.link_rewrite
|
||||
FROM `"._DB_PREFIX_."guide_category` gc, `"._DB_PREFIX_."guide_category_lang` gcl
|
||||
WHERE gc.id_guide_category=gcl.id_guide_category AND gcl.id_lang=".$id_lang.
|
||||
" AND gc.id_guide_category=".$id_category;
|
||||
$result = Db::getInstance()->getRow($sql);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function getAutoCategoryLang($id_category, $id_lang)
|
||||
{
|
||||
$sql = "SELECT * FROM ps_guide_category gc, ps_guide_category_lang gcl
|
||||
WHERE gc.active=1 AND gc.id_guide_category=gcl.id_guide_category
|
||||
AND gc.id_parent=".$id_category." AND gcl.id_lang=".$id_lang.
|
||||
" ORDER BY position ASC";
|
||||
$result = Db::getInstance()->getRow($sql);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gest All main categories
|
||||
* @param int $id_lang
|
||||
* @return array
|
||||
*/
|
||||
public static function getRoot($id_lang, $active = 1)
|
||||
{
|
||||
$sql = "SELECT gc.id_guide_category, gcl.name, gcl.link_rewrite, gcl.meta_title,
|
||||
gcl.meta_description, gcl.meta_keywords
|
||||
FROM ps_guide_category gc, ps_guide_category_lang gcl
|
||||
WHERE ".($active==1?' gc.active=1 ':' 1 ')." AND gc.id_guide_category=gcl.id_guide_category
|
||||
AND gc.id_parent=0 AND gcl.id_lang=".$id_lang;
|
||||
$result = Db::getInstance()->ExecuteS($sql);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get category with children
|
||||
* @param int $id_lang
|
||||
* @param int $active
|
||||
* @return array
|
||||
*/
|
||||
public function getTree($id_lang, $active = 1)
|
||||
{
|
||||
return $this->recurseData(0, $id_lang, $active);
|
||||
}
|
||||
|
||||
/**
|
||||
* Recurse data
|
||||
* @param int $id_category
|
||||
* @param int $id_lang
|
||||
* @param int $active
|
||||
* @return array
|
||||
*/
|
||||
protected function recurseData($id_category, $id_lang, $active = 1)
|
||||
{
|
||||
$data = array();
|
||||
$sql = "SELECT gc.*, gcl.name, gcl.link_rewrite
|
||||
FROM `"._DB_PREFIX_."guide_category` gc, `"._DB_PREFIX_."guide_category_lang` gcl
|
||||
WHERE gc.id_guide_category=gcl.id_guide_category AND gcl.id_lang=".$id_lang.
|
||||
($active==1?' AND gc.active=1 ':'')." AND gc.id_parent=".$id_category.
|
||||
" ORDER BY position ASC";
|
||||
$result = Db::getInstance()->ExecuteS($sql);
|
||||
if (count($result) > 0) {
|
||||
foreach ($result as $c) {
|
||||
$rewrite = 'guide/';
|
||||
if ($c['id_parent'] != 0) {
|
||||
$parent = $this->getCategoryLang($c['id_parent'], $id_lang);
|
||||
$rewrite.= $parent['link_rewrite'].'/';
|
||||
}
|
||||
$rewrite.= $c['id_guide_category'].'-'.$c['link_rewrite'];
|
||||
|
||||
$item = array(
|
||||
'id_guide_category' => $c['id_guide_category'],
|
||||
'name' => $c['name'],
|
||||
'rewrite' => $rewrite,
|
||||
'children' => $this->recurseData($c['id_guide_category'], $id_lang),
|
||||
);
|
||||
$data[] = $item;
|
||||
}
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
class GuidePost extends ObjectModel
|
||||
{
|
||||
public $id;
|
||||
@ -13,27 +12,49 @@ class GuidePost extends ObjectModel
|
||||
public $content;
|
||||
public $link_rewrite;
|
||||
|
||||
protected $fieldsValidate = array('id_guide_category' => 'isUnsignedInt');
|
||||
protected $fieldsRequiredLang = array('meta_title', 'link_rewrite');
|
||||
protected $fieldsSizeLang = array('meta_description' => 255, 'meta_keywords' => 255, 'meta_title' => 128, 'link_rewrite' => 128, 'content' => 3999999999999);
|
||||
protected $fieldsValidateLang = array('meta_description' => 'isGenericName', 'meta_keywords' => 'isGenericName', 'meta_title' => 'isGenericName', 'link_rewrite' => 'isLinkRewrite', 'content' => 'isString');
|
||||
protected $fieldsValidate = array(
|
||||
'id_guide_category' => 'isUnsignedInt'
|
||||
);
|
||||
|
||||
protected $fieldsRequiredLang = array(
|
||||
'meta_title',
|
||||
'link_rewrite',
|
||||
);
|
||||
|
||||
protected $fieldsSizeLang = array(
|
||||
'meta_description' => 255,
|
||||
'meta_keywords' => 255,
|
||||
'meta_title' => 128,
|
||||
'link_rewrite' => 128,
|
||||
'content' => 3999999999999,
|
||||
);
|
||||
|
||||
protected $fieldsValidateLang = array(
|
||||
'meta_description' => 'isGenericName',
|
||||
'meta_keywords' => 'isGenericName',
|
||||
'meta_title' => 'isGenericName',
|
||||
'link_rewrite' => 'isLinkRewrite',
|
||||
'content' => 'isString',
|
||||
);
|
||||
|
||||
protected $table = 'guide_post';
|
||||
protected $identifier = 'id_guide_post';
|
||||
|
||||
protected $webserviceParameters = array(
|
||||
protected $webserviceParameters = array(
|
||||
'objectNodeName' => 'content',
|
||||
'objectsNodeName' => 'content_management_system',
|
||||
);
|
||||
|
||||
public function getFields()
|
||||
{
|
||||
public function getFields()
|
||||
{
|
||||
parent::validateFields();
|
||||
|
||||
$fields['id_guide_post'] = (int)($this->id);
|
||||
$fields['id_guide_category'] = (int)($this->id_guide_category);
|
||||
$fields['position'] = (int)($this->position);
|
||||
$fields['active'] = (int)($this->active);
|
||||
return $fields;
|
||||
|
||||
return $fields;
|
||||
}
|
||||
|
||||
public function getTranslationsFieldsChild()
|
||||
@ -67,9 +88,9 @@ class GuidePost extends ObjectModel
|
||||
public function updatePosition($way, $position)
|
||||
{
|
||||
if (!$res = Db::getInstance()->ExecuteS('
|
||||
SELECT cp.`id_guide_post`, cp.`position`, cp.`id_guide_category`
|
||||
SELECT cp.`id_guide_post`, cp.`position`, cp.`id_guide_category`
|
||||
FROM `'._DB_PREFIX_.'guide_post` cp
|
||||
WHERE cp.`id_guide_category` = '.(int)$this->id_guide_category.'
|
||||
WHERE cp.`id_guide_category` = '.(int)$this->id_guide_category.'
|
||||
ORDER BY cp.`position` ASC'
|
||||
))
|
||||
return false;
|
||||
@ -86,8 +107,8 @@ class GuidePost extends ObjectModel
|
||||
return (Db::getInstance()->Execute('
|
||||
UPDATE `'._DB_PREFIX_.'guide_post`
|
||||
SET `position`= `position` '.($way ? '- 1' : '+ 1').'
|
||||
WHERE `position`
|
||||
'.($way
|
||||
WHERE `position`
|
||||
'.($way
|
||||
? '> '.(int)($movedPost['position']).' AND `position` <= '.(int)($position)
|
||||
: '< '.(int)($movedPost['position']).' AND `position` >= '.(int)($position)).'
|
||||
AND `id_guide_category`='.(int)($movedPost['id_guide_category']))
|
||||
@ -145,5 +166,58 @@ class GuidePost extends ObjectModel
|
||||
}
|
||||
return $position;
|
||||
}
|
||||
|
||||
public function getLinkRewrite()
|
||||
{
|
||||
if ($this->id) {
|
||||
return $this->id.'-'.$this->link_rewrite[2];
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
|
||||
public function getUrlRewriteFull(){}
|
||||
|
||||
/**
|
||||
* Get Post With one language
|
||||
* @param int $id_category
|
||||
* @param int $id_lang
|
||||
* @return array
|
||||
*/
|
||||
public function getPostLang($id_post, $id_lang, $id_category = null)
|
||||
{
|
||||
$sql = "SELECT * FROM ps_guide_post gp, ps_guide_post_lang gpl
|
||||
WHERE gp.active=1 AND gp.id_guide_post=gpl.id_guide_post
|
||||
".($id_category===null?"":" AND gp.id_guide_category=".$id_category).
|
||||
"AND gp.id_guide_post=".$id_post." AND gpl.id_lang=".$id_lang;
|
||||
$result = Db::getInstance()->getRow($sql);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
public function getAutoPostLang($id_category, $id_lang)
|
||||
{
|
||||
$sql = "SELECT * FROM ps_guide_post gp, ps_guide_post_lang gpl
|
||||
WHERE gp.active=1 AND gp.id_guide_post=gpl.id_guide_post
|
||||
AND gp.id_guide_category=".$id_category.
|
||||
" AND gpl.id_lang=".$id_lang." ORDER BY position ASC";
|
||||
$result = Db::getInstance()->getRow($sql);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function findByCategory($id_category, $id_lang)
|
||||
{
|
||||
$sql = "SELECT * FROM ps_guide_post gp, ps_guide_post_lang gpl
|
||||
WHERE gp.active=1 AND gp.id_guide_post=gpl.id_guide_post
|
||||
AND gp.id_guide_category=".$id_category.
|
||||
" AND gpl.id_lang=".$id_lang." ORDER BY position ASC";
|
||||
$result = Db::getInstance()->ExecuteS($sql);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,47 @@
|
||||
<?php
|
||||
require_once(__DIR__.'/../../classes/GuideCategory.php');
|
||||
|
||||
class CategoryController extends FrontController
|
||||
{
|
||||
public function preProcess()
|
||||
{
|
||||
parent::preProcess();
|
||||
|
||||
$id_lang = self::$cookie->id_lang;
|
||||
$categories = array();
|
||||
|
||||
// Get main categories
|
||||
$catResult = GuideCategory::getRoot($id_lang);
|
||||
if (count($catResult) > 0) {
|
||||
foreach ($catResult as $c) {
|
||||
$categories[] = $c;
|
||||
}
|
||||
}
|
||||
|
||||
self::$smarty->assign(array(
|
||||
'path' => 'Guide',
|
||||
'categories' => $categories,
|
||||
));
|
||||
|
||||
$metaTags = Tools::completeMetaTags(array(
|
||||
'meta_description' => "Guide d'achat",
|
||||
'meta_keywords' => "Guide d'achat",
|
||||
), "Guide d'achat");
|
||||
self::$smarty->assign($metaTags);
|
||||
}
|
||||
|
||||
// displayContent
|
||||
public function displayContent()
|
||||
{
|
||||
parent::displayContent();
|
||||
|
||||
if (is_file(_PS_THEME_DIR_ . 'modules/purchaseguide/views/front/category.tpl')) {
|
||||
$tplFile = _PS_THEME_DIR_ . 'modules/purchaseguide/views/front/category.tpl';
|
||||
}
|
||||
else {
|
||||
$tplFile = _PS_MODULE_DIR_ . 'purchaseguide/views/templates/front/category.tpl';
|
||||
}
|
||||
|
||||
self::$smarty->display($tplFile);
|
||||
}
|
||||
}
|
134
modules/purchaseguide/controllers/front/PostController.php
Normal file
134
modules/purchaseguide/controllers/front/PostController.php
Normal file
@ -0,0 +1,134 @@
|
||||
<?php
|
||||
require_once(__DIR__.'/../../classes/GuideCategory.php');
|
||||
require_once(__DIR__.'/../../classes/GuidePost.php');
|
||||
|
||||
class PostController extends FrontController
|
||||
{
|
||||
public function canonicalRedirection() {}
|
||||
|
||||
public function preProcess()
|
||||
{
|
||||
parent::preProcess();
|
||||
|
||||
$id_lang = self::$cookie->id_lang;
|
||||
|
||||
$id_category = Tools::getValue('cid', 0);
|
||||
$id_post = Tools::getValue('pid', 0);
|
||||
$content = null;
|
||||
|
||||
// @todo, si on vient de l'admin, voir les post ???
|
||||
|
||||
// Start form post
|
||||
$postModel = new GuidePost();
|
||||
if ($id_post != 0) {
|
||||
$content = $postModel->getPostLang($id_post, $id_lang);
|
||||
$id_category = $content['id_guide_category'];
|
||||
}
|
||||
|
||||
// Categories
|
||||
if ($id_category == 0) {
|
||||
Tools::display404Error('404.php');
|
||||
}
|
||||
else {
|
||||
// Category
|
||||
$categoryModel = new GuideCategory();
|
||||
$category = $categoryModel->getCategoryLang($id_category, $id_lang);
|
||||
|
||||
// Get Parent category
|
||||
$isSubCategory = false;
|
||||
if ($category['id_parent'] != 0) {
|
||||
$isSubCategory = true;
|
||||
}
|
||||
|
||||
if ($isSubCategory) {
|
||||
// Get Parent category
|
||||
$parentCategory = $categoryModel->getCategoryLang($category['id_parent'], $id_lang);
|
||||
}
|
||||
else {
|
||||
$parentCategory = $category;
|
||||
// Auto Select category
|
||||
$category = $categoryModel->getAutoCategoryLang($id_category, $id_lang);
|
||||
}
|
||||
}
|
||||
|
||||
// Post
|
||||
if ($content === null) {
|
||||
if ($id_post != 0) {
|
||||
$content = $postModel->getPostLang($id_post, $id_lang, $category['id_guide_category']);
|
||||
}
|
||||
// Auto Select Post
|
||||
else {
|
||||
$content = $postModel->getAutoPostLang($category['id_guide_category'], $id_lang);
|
||||
}
|
||||
}
|
||||
|
||||
// Liste des Posts
|
||||
$postList = $postModel->findByCategory($category['id_guide_category'], $id_lang);
|
||||
|
||||
$parentCategoryModel = new GuideCategory($parentCategory['id_guide_category']);
|
||||
$parentCategoryLink = $parentCategoryModel->getLinkRewrite($id_lang);
|
||||
|
||||
$categoryModel = new GuideCategory($category['id_guide_category']);
|
||||
$categoryLink = $categoryModel->getLinkRewrite($id_lang);
|
||||
|
||||
$pipe = " > ";
|
||||
|
||||
$path = '<a href="'.Tools::getShopDomainSsl(true).'/guide">Guide</a>';
|
||||
|
||||
if ($parentCategoryModel !== null) {
|
||||
$path.= '<span class="navigation-pipe">'.$pipe.'</span>'.
|
||||
'<a href="'.Tools::getShopDomainSsl(true).'/guide/'.$parentCategoryLink.'">'
|
||||
.htmlentities($parentCategoryModel->name[$id_lang], ENT_NOQUOTES, 'UTF-8').'</a>';
|
||||
}
|
||||
|
||||
if ($categoryModel !== null) {
|
||||
$path.= '<span class="navigation-pipe">'.$pipe.'</span>'.
|
||||
'<a href="'.Tools::getShopDomainSsl(true).'/guide/'.$parentCategoryModel->link_rewrite[$id_lang].'/'.$categoryLink.'">'.
|
||||
htmlentities($categoryModel->name[$id_lang], ENT_NOQUOTES, 'UTF-8').'</a>';
|
||||
|
||||
$path.= '<span class="navigation-pipe">'.$pipe.'</span>'.
|
||||
'<span>'.$content['meta_title'].'</span>';
|
||||
}
|
||||
|
||||
self::$smarty->assign(array(
|
||||
'path' => $path,
|
||||
'id_category' => $id_category,
|
||||
'categoryTitle' => $parentCategory['name'],
|
||||
'categoryLink' => $parentCategoryLink,
|
||||
'categoryRewrite' => $parentCategory['link_rewrite'],
|
||||
|
||||
'subcategoryTitle' => $category['name'],
|
||||
'subcategoryContent' => $category['description'],
|
||||
'subcategoryImg' => $categoryModel->getImageFileUrl(),
|
||||
'subcategoryLink' => $categoryLink,
|
||||
'subcategoryRewrite' => $category['link_rewrite'],
|
||||
|
||||
'postList' => $postList,
|
||||
'postTitle' => $content['meta_title'],
|
||||
'postContent' => $content['content'],
|
||||
'postLink' => '',
|
||||
|
||||
'id_guide_post_select' => $content['id_guide_post'],
|
||||
));
|
||||
|
||||
$metaTags = Tools::completeMetaTags(array(
|
||||
'meta_description' => $content['meta_description'],
|
||||
'meta_keywords' => $content['meta_keywords'],
|
||||
), $content['meta_title']);
|
||||
self::$smarty->assign($metaTags);
|
||||
}
|
||||
|
||||
public function displayContent()
|
||||
{
|
||||
parent::displayContent();
|
||||
|
||||
if (is_file(_PS_THEME_DIR_ . 'modules/purchaseguide/views/front/content.tpl')) {
|
||||
$tplFile = _PS_THEME_DIR_ . 'modules/purchaseguide/views/front/content.tpl';
|
||||
}
|
||||
else {
|
||||
$tplFile = _PS_MODULE_DIR_ . 'purchaseguide/views/templates/front/content.tpl';
|
||||
}
|
||||
|
||||
self::$smarty->display($tplFile);
|
||||
}
|
||||
}
|
6
modules/purchaseguide/post.php
Normal file
6
modules/purchaseguide/post.php
Normal file
@ -0,0 +1,6 @@
|
||||
<?php
|
||||
require_once dirname(__FILE__).'/../../config/config.inc.php';
|
||||
require_once dirname(__FILE__).'/controllers/front/PostController.php';
|
||||
|
||||
$controller = new PostController();
|
||||
$controller->run();
|
@ -1,12 +1,14 @@
|
||||
<?php
|
||||
if (!defined('_PS_VERSION_'))
|
||||
exit;
|
||||
if (!defined('_PS_VERSION_')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
require_once(__DIR__.'/classes/GuideCategory.php');
|
||||
|
||||
class PurchaseGuide extends Module
|
||||
class PurchaseGuide extends Module
|
||||
{
|
||||
public function __construct() {
|
||||
public function __construct()
|
||||
{
|
||||
$this->name = 'purchaseguide';
|
||||
$this->tab = 'front_office_features';
|
||||
$this->author = 'Antadis';
|
||||
@ -18,22 +20,24 @@ class PurchaseGuide extends Module
|
||||
}
|
||||
|
||||
|
||||
public function install()
|
||||
public function install()
|
||||
{
|
||||
if(!parent::install()
|
||||
|| !$this->installTabs()
|
||||
|| !$this->createTables()
|
||||
|| !$this->installImageAddon()
|
||||
) {
|
||||
$this->uninstall();
|
||||
return FALSE;
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
$this->registerHook('leftColumn');
|
||||
$this->registerHook('TopMenuLink');
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public function uninstall()
|
||||
public function uninstall()
|
||||
{
|
||||
$this->uninstallTabs();
|
||||
$this->dropTables();
|
||||
@ -239,4 +243,56 @@ class PurchaseGuide extends Module
|
||||
');
|
||||
}
|
||||
|
||||
public function hookTopMenuLink($params)
|
||||
{
|
||||
global $cookie, $smarty;
|
||||
|
||||
$id_category_family = $params['id_category_family'];
|
||||
$rewrite = '';
|
||||
|
||||
$loadedCategory = GuideCategory::findByCategoryFamily($id_category_family, $cookie->id_lang);
|
||||
if (!empty($loadedCategory)) {
|
||||
$link_rewrite = '';
|
||||
$category = new GuideCategory($loadedCategory['id_guide_category']);
|
||||
$rewrite = 'guide/'.$category->getLinkRewrite($cookie->id_lang);
|
||||
}
|
||||
|
||||
$smarty->assign(array(
|
||||
'link_rewrite' => $rewrite,
|
||||
));
|
||||
|
||||
return $this->display(dirname(__FILE__), '/views/templates/hook/topmenulink.tpl');
|
||||
}
|
||||
|
||||
public function hookLeftColumn($params)
|
||||
{
|
||||
global $cookie, $smarty, $site_version, $page_name;
|
||||
|
||||
if (!in_array($page_name, array('rubrique', 'post'))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$id_category = Tools::getValue('cid', 0);
|
||||
|
||||
// Récup de l'arbre en fonction des catégories
|
||||
$model = new GuideCategory($id_category);
|
||||
|
||||
if ($model->id_parent == 0) {
|
||||
$id_main_category = $id_category;
|
||||
$id_child_category = 0;
|
||||
} else {
|
||||
$mainCategory = $model->getCategoryLang($model->id_parent, $cookie->id_lang);
|
||||
$id_main_category = $mainCategory['id_guide_category'];
|
||||
$id_child_category = $id_category;
|
||||
}
|
||||
$tree = $model->getTree($cookie->id_lang);
|
||||
|
||||
$smarty->assign(array(
|
||||
'id_guide_category_select_main' => $id_main_category,
|
||||
'id_guide_category_select_child' => $id_child_category,
|
||||
'menu' => $tree,
|
||||
));
|
||||
|
||||
return $this->display(__FILE__, '/views/templates/hook/leftcolumn.tpl');
|
||||
}
|
||||
}
|
||||
|
6
modules/purchaseguide/rubrique.php
Normal file
6
modules/purchaseguide/rubrique.php
Normal file
@ -0,0 +1,6 @@
|
||||
<?php
|
||||
require_once dirname(__FILE__).'/../../config/config.inc.php';
|
||||
require_once dirname(__FILE__).'/controllers/front/CategoryController.php';
|
||||
|
||||
$controller = new CategoryController();
|
||||
$controller->run();
|
@ -19,7 +19,7 @@
|
||||
{/if}
|
||||
|
||||
{if $input.max_size}
|
||||
File size'} :
|
||||
{l s='File size'} :
|
||||
{$input.max_size} {l s='max'}.
|
||||
{/if}
|
||||
</p>
|
@ -3,7 +3,7 @@
|
||||
<fieldset>
|
||||
<legend><img src="../img/admin/tab-tools.gif" alt="" />{l s='URL Rewriting settings'}</legend>
|
||||
|
||||
<p>{l s='Add the following text to the custom rewriting rules (Tools > Generators'} :</p>
|
||||
<p>{l s='Add the following text to the custom rewriting rules (Tools > Generators)'} :</p>
|
||||
<p> </p>
|
||||
<textarea style="width: 850px; height: 120px;" readonly="true">{$rewrite_rules}</textarea>
|
||||
</fieldset>
|
6
modules/purchaseguide/img/index.php → modules/purchaseguide/views/templates/admin/index.php
Normal file → Executable file
6
modules/purchaseguide/img/index.php → modules/purchaseguide/views/templates/admin/index.php
Normal file → Executable file
@ -24,13 +24,13 @@
|
||||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
|
||||
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
|
||||
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
|
||||
|
||||
|
||||
header("Cache-Control: no-store, no-cache, must-revalidate");
|
||||
header("Cache-Control: post-check=0, pre-check=0", false);
|
||||
header("Pragma: no-cache");
|
||||
|
||||
|
||||
header("Location: ../");
|
||||
exit;
|
17
modules/purchaseguide/views/templates/front/category.tpl
Normal file
17
modules/purchaseguide/views/templates/front/category.tpl
Normal file
@ -0,0 +1,17 @@
|
||||
{include file="$tpl_dir./breadcrumb.tpl"}
|
||||
|
||||
<h1>Guide d'achat</h1>
|
||||
<div class="rte{if $content_only} content_only{/if}">
|
||||
|
||||
<div class="row">
|
||||
{foreach from=$categories item=c}
|
||||
<div class="guide-content-category">
|
||||
<a href="guide/{$c.id_guide_category}-{$c.link_rewrite}">
|
||||
<img alt="{if $c.meta_title==''}{$c.name}{else}{$c.meta_title}{/if}" src="./img/purchaseguide/{$c.id_guide_category}.jpg">
|
||||
<div class="guide-content-category-title"><h4>{$c.name}</h4></div>
|
||||
</a>
|
||||
</div>
|
||||
{/foreach}
|
||||
</div>
|
||||
|
||||
</div>
|
38
modules/purchaseguide/views/templates/front/content.tpl
Normal file
38
modules/purchaseguide/views/templates/front/content.tpl
Normal file
@ -0,0 +1,38 @@
|
||||
{include file="$tpl_dir./breadcrumb.tpl"}
|
||||
|
||||
<h1>Guide d'achat - {$categoryTitle}</h1>
|
||||
<div class="content-guide rte{if $content_only} content_only{/if}">
|
||||
|
||||
{if $subcategoryTitle !== null}
|
||||
<div class="guide-intro">
|
||||
<div class="guide-intro-left">
|
||||
<h2>{$subcategoryTitle}</h2>
|
||||
<div>
|
||||
<p>{$subcategoryContent}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="guide-intro-right">
|
||||
<img alt="" src="{$subcategoryImg}"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="guide-content">
|
||||
<div class="guide-content-menu">
|
||||
<ul>
|
||||
{foreach from=$postList item=p}
|
||||
<li{if $p.id_guide_post==$id_guide_post_select} class="selected"{/if}>
|
||||
<a href="{$base_dir_ssl}guide/{$categoryRewrite}/{$subcategoryRewrite}/{$p.id_guide_post}-{$p.link_rewrite}">{$p.meta_title}</a>
|
||||
</li>
|
||||
{/foreach}
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="guide-content-txt">
|
||||
<h3 class="title">{$postTitle}</h3>
|
||||
<p>{$postContent}</p>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
</div>
|
36
modules/purchaseguide/views/templates/front/index.php
Executable file
36
modules/purchaseguide/views/templates/front/index.php
Executable file
@ -0,0 +1,36 @@
|
||||
<?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: 7233 $
|
||||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
|
||||
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
|
||||
|
||||
header("Cache-Control: no-store, no-cache, must-revalidate");
|
||||
header("Cache-Control: post-check=0, pre-check=0", false);
|
||||
header("Pragma: no-cache");
|
||||
|
||||
header("Location: ../");
|
||||
exit;
|
26
modules/purchaseguide/views/templates/hook/leftcolumn.tpl
Normal file
26
modules/purchaseguide/views/templates/hook/leftcolumn.tpl
Normal file
@ -0,0 +1,26 @@
|
||||
<div class="block-guide">
|
||||
<h4>Guide d'achat</h4>
|
||||
{foreach from=$menu item=c}
|
||||
<h5><a{if $c.id_guide_category==$id_guide_category_select_main} class="selected"{/if} href="{$base_dir_ssl}{$c.rewrite}">
|
||||
{$c.name}</a></h5>
|
||||
{if $c.children|@count > 0}
|
||||
<ul class="block_content">
|
||||
{foreach from=$c.children item=children name=loopChild}
|
||||
{assign var="class" value=""}
|
||||
{if $id_guide_category_select_child==0
|
||||
&& $c.id_guide_category==$id_guide_category_select_main
|
||||
&& $smarty.foreach.loopChild.first}
|
||||
{assign var="class" value="selected"}
|
||||
{/if}
|
||||
{if $children.id_guide_category==$id_guide_category_select_child}
|
||||
{assign var="class" value="selected"}
|
||||
{/if}
|
||||
<li class="{$class}">
|
||||
<a href="{$base_dir_ssl}{$children.rewrite}"{if $children.meta_title!=''} alt="{$children.meta_title}"{/if}>
|
||||
{$children.name}</a>
|
||||
</li>
|
||||
{/foreach}
|
||||
</ul>
|
||||
{/if}
|
||||
{/foreach}
|
||||
</div>
|
@ -0,0 +1,4 @@
|
||||
{if $link_rewrite != ''}
|
||||
<span>Besoin d'aide ?</span><br/>
|
||||
<span>Consultez notre <a href="{$base_dir_ssl}{$link_rewrite}">Guide d'achat</a></span>
|
||||
{/if}
|
36
modules/purchaseguide/views/templates/index.php
Executable file
36
modules/purchaseguide/views/templates/index.php
Executable file
@ -0,0 +1,36 @@
|
||||
<?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: 7233 $
|
||||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
|
||||
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
|
||||
|
||||
header("Cache-Control: no-store, no-cache, must-revalidate");
|
||||
header("Cache-Control: post-check=0, pre-check=0", false);
|
||||
header("Pragma: no-cache");
|
||||
|
||||
header("Location: ../");
|
||||
exit;
|
@ -406,6 +406,8 @@ class FrontController extends FrontControllerCore {
|
||||
'module-ant_support_form-support',
|
||||
'module-paypal-express_checkout-payment',
|
||||
'module-paymentinfo-manage',
|
||||
'module-purchaseguide-category', 'rubrique',
|
||||
'module-purchaseguide-post', 'post',
|
||||
);
|
||||
|
||||
$displayRight = array(
|
||||
|
@ -1853,7 +1853,7 @@ body#page-404 .footer_links {
|
||||
/** SUBMENU **/
|
||||
.container_submenu {
|
||||
border-top: 4px solid #70bc2c;
|
||||
height: 380px;
|
||||
height: 400px;
|
||||
left: 0;
|
||||
position: absolute;
|
||||
overflow: hidden;
|
||||
@ -1901,6 +1901,23 @@ li.active .container_submenu .content_submenu {
|
||||
animation-name: slideInDown;
|
||||
padding: 0 15px;
|
||||
}
|
||||
.container_submenu .content_footer {
|
||||
display: block;
|
||||
width: 100%;
|
||||
margin: 0 auto;
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
background-color: #fff;
|
||||
padding:15px 0;
|
||||
color: #666666;
|
||||
font-size: 14px;
|
||||
font-weight: bold;
|
||||
}
|
||||
.container_submenu .content_footer a,
|
||||
.container_submenu .content_footer a:hover,
|
||||
.container_submenu .content_footer a:visited {
|
||||
color: #ec15ac;
|
||||
}
|
||||
.submenu {
|
||||
width: 965px;
|
||||
margin: 0 auto;
|
||||
@ -7556,3 +7573,117 @@ div.addresses ul.address.item {
|
||||
.ant_support{
|
||||
padding:0px!important;
|
||||
}
|
||||
.block-guide {
|
||||
margin-bottom: 20px;
|
||||
background: #f6f6f6;
|
||||
background: #fff;
|
||||
padding: 10px 20px;
|
||||
-webkit-box-sizing: border-box;
|
||||
-moz-box-sizing: border-box;
|
||||
box-sizing: border-box;
|
||||
background: #fff;
|
||||
-moz-box-shadow: 2px 2px 5px #cccccc;
|
||||
-webkit-box-shadow: 2px 2px 5px #CCC;
|
||||
-ms-box-shadow: 2px 2px 5px #cccccc;
|
||||
-o-box-shadow: 2px 2px 5px #cccccc;
|
||||
box-shadow: 2px 2px 5px #ccc;
|
||||
color: #1e1633;
|
||||
}
|
||||
.block-guide ul {
|
||||
margin: 0px;
|
||||
list-style: none outside;
|
||||
margin-left: 5px;
|
||||
}
|
||||
.block-guide h5 {
|
||||
margin-top: 10px;
|
||||
}
|
||||
.block-guide h5 a {
|
||||
font-style: normal;
|
||||
font-weight: bold;
|
||||
font-size: 14px;
|
||||
line-height: 1.5em;
|
||||
color: #000;
|
||||
}
|
||||
.block-guide h5 a.selected {
|
||||
color: #796dc7;
|
||||
}
|
||||
|
||||
.block-guide ul li a {
|
||||
margin: 0 0 0 10px;
|
||||
color: #000;
|
||||
}
|
||||
.block-guide ul li.selected a {
|
||||
color: #796dc7;
|
||||
}
|
||||
.guide-intro {}
|
||||
.guide-intro-left {
|
||||
width: 430px;
|
||||
float: left;
|
||||
color: #1e1633;
|
||||
background: #fff;
|
||||
font-size: 26px;
|
||||
text-transform: none;
|
||||
line-height: 1.5em;
|
||||
font-weight: normal;
|
||||
text-align: left;
|
||||
margin: 0px 5px 20px 0px;
|
||||
min-height: 180px;
|
||||
padding: 10px 0px 0px 20px;
|
||||
-moz-box-shadow: 2px 2px 5px #cccccc;
|
||||
-webkit-box-shadow: 2px 2px 5px #cccccc;
|
||||
-ms-box-shadow: 2px 2px 5px #cccccc;
|
||||
-o-box-shadow: 2px 2px 5px #cccccc;
|
||||
box-shadow: 2px 2px 5px #cccccc;
|
||||
}
|
||||
.guide-intro-right {}
|
||||
.guide-content {
|
||||
clear: both;
|
||||
}
|
||||
.guide-content-menu {
|
||||
width: 160px;
|
||||
float: left;
|
||||
background: #fff;
|
||||
font-size: 26px;
|
||||
text-transform: none;
|
||||
line-height: 1.5em;
|
||||
font-weight: normal;
|
||||
text-align: left;
|
||||
margin: 0px 5px 0px 0px;
|
||||
padding: 10px 0px 10px 0px;
|
||||
-moz-box-shadow: 2px 2px 5px #cccccc;
|
||||
-webkit-box-shadow: 2px 2px 5px #cccccc;
|
||||
-ms-box-shadow: 2px 2px 5px #cccccc;
|
||||
-o-box-shadow: 2px 2px 5px #cccccc;
|
||||
box-shadow: 2px 2px 5px #cccccc;
|
||||
}
|
||||
.guide-content-category {
|
||||
width:50%;
|
||||
float:left;
|
||||
text-align:center;
|
||||
}
|
||||
.guide-content-category-title {
|
||||
clear:both;
|
||||
}
|
||||
.guide-content-category-title h4 {
|
||||
text-transform: uppercase;
|
||||
font-style: normal;
|
||||
font-weight: bold;
|
||||
}
|
||||
.guide-content ul {
|
||||
margin: 0px;
|
||||
list-style: none outside;
|
||||
}
|
||||
.guide-content ul li a {
|
||||
color: #000;
|
||||
}
|
||||
.guide-content ul li.selected a {
|
||||
font-weight: bold;
|
||||
color: #796dc7;
|
||||
}
|
||||
.guide-content-txt {
|
||||
width:580px;
|
||||
float: right;
|
||||
padding: 0 5px;
|
||||
}
|
||||
|
||||
|
||||
|
@ -53,12 +53,19 @@
|
||||
{/foreach}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="content_footer">
|
||||
{$purchaseguide[$menu.id_category_family]}
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
{/if}
|
||||
</li>
|
||||
{/foreach}
|
||||
</ul>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -5335,3 +5335,126 @@ body#order-detail table#order-product tbody tr.item tr.title span.quantity{
|
||||
font-size: 16px;
|
||||
font-family: Georgia;
|
||||
}
|
||||
|
||||
.block-guide {
|
||||
margin-bottom: 20px;
|
||||
background: #f6f6f6;
|
||||
background: #fff;
|
||||
padding: 10px 20px;
|
||||
-webkit-box-sizing: border-box;
|
||||
-moz-box-sizing: border-box;
|
||||
box-sizing: border-box;
|
||||
background: #fff;
|
||||
-moz-box-shadow: 2px 2px 5px #cccccc;
|
||||
-webkit-box-shadow: 2px 2px 5px #CCC;
|
||||
-ms-box-shadow: 2px 2px 5px #cccccc;
|
||||
-o-box-shadow: 2px 2px 5px #cccccc;
|
||||
box-shadow: 2px 2px 5px #ccc;
|
||||
color: #1e1633;
|
||||
}
|
||||
.block-guide ul {
|
||||
margin: 0px;
|
||||
list-style: none outside;
|
||||
margin-left: 5px;
|
||||
}
|
||||
.block-guide h5 {
|
||||
margin-top: 10px;
|
||||
}
|
||||
.block-guide h5 a {
|
||||
font-style: normal;
|
||||
font-weight: bold;
|
||||
font-size: 14px;
|
||||
line-height: 1.5em;
|
||||
color: #000;
|
||||
}
|
||||
.block-guide h5 a.selected {
|
||||
color: #796dc7;
|
||||
}
|
||||
|
||||
.block-guide ul li a {
|
||||
margin: 0 0 0 10px;
|
||||
color: #000;
|
||||
}
|
||||
.block-guide ul li.selected a {
|
||||
color: #796dc7;
|
||||
}
|
||||
.guide-intro {}
|
||||
.guide-intro-left {
|
||||
color: #1e1633;
|
||||
background: #fff;
|
||||
text-transform: none;
|
||||
line-height: 1.5em;
|
||||
font-weight: normal;
|
||||
margin: 0 0 5px 0;
|
||||
/*adding: 10px 0px 0px 20px;*/
|
||||
-moz-box-shadow: 2px 2px 5px #cccccc;
|
||||
-webkit-box-shadow: 2px 2px 5px #cccccc;
|
||||
-ms-box-shadow: 2px 2px 5px #cccccc;
|
||||
-o-box-shadow: 2px 2px 5px #cccccc;
|
||||
box-shadow: 2px 2px 5px #cccccc;
|
||||
}
|
||||
.guide-intro-left div {
|
||||
margin: 5px;
|
||||
font-size: 13px;
|
||||
}
|
||||
.guide-intro-left h2 {
|
||||
text-align: left;
|
||||
}
|
||||
.guide-content h3 {
|
||||
font-size: 13px;
|
||||
}
|
||||
.guide-content-menu {
|
||||
background: #fff;
|
||||
font-size: 13px;
|
||||
text-transform: none;
|
||||
line-height: 1.5em;
|
||||
font-weight: normal;
|
||||
text-align: left;
|
||||
padding: 10px 0px 10px 0px;
|
||||
-moz-box-shadow: 2px 2px 5px #cccccc;
|
||||
-webkit-box-shadow: 2px 2px 5px #cccccc;
|
||||
-ms-box-shadow: 2px 2px 5px #cccccc;
|
||||
-o-box-shadow: 2px 2px 5px #cccccc;
|
||||
box-shadow: 2px 2px 5px #cccccc;
|
||||
}
|
||||
.guide-content-category {
|
||||
text-align:center;
|
||||
}
|
||||
.guide-content ul {
|
||||
display: block;
|
||||
list-style: none outside;
|
||||
margin: 5px;
|
||||
}
|
||||
.guide-content ul li a {
|
||||
color: #000;
|
||||
}
|
||||
.guide-content ul li.selected a {
|
||||
font-weight: bold;
|
||||
color: #796dc7;
|
||||
}
|
||||
.guide-content-txt {
|
||||
margin: 5px 0;
|
||||
padding: 0 5px;
|
||||
}
|
||||
|
||||
.guide-content-txt div{
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.container_submenu .content_footer {
|
||||
display: block;
|
||||
width: 100%;
|
||||
margin: 0 auto;
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
background-color: #fff;
|
||||
padding:15px 0;
|
||||
color: #666666;
|
||||
font-size: 14px;
|
||||
font-weight: bold;
|
||||
}
|
||||
.container_submenu .content_footer a,
|
||||
.container_submenu .content_footer a:hover,
|
||||
.container_submenu .content_footer a:visited {
|
||||
color: #ec15ac;
|
||||
}
|
||||
|
@ -0,0 +1,17 @@
|
||||
{include file="$tpl_dir./breadcrumb.tpl"}
|
||||
|
||||
<h1 class="title"><span>Guide d'achat</span></h1>
|
||||
<div class="rte{if $content_only} content_only{/if}">
|
||||
|
||||
<div class="row">
|
||||
{foreach from=$categories item=c}
|
||||
<div class="guide-content-category">
|
||||
<a href="guide/{$c.id_guide_category}-{$c.link_rewrite}">
|
||||
<img alt="{$c.name}" src="./img/purchaseguide/{$c.id_guide_category}.jpg">
|
||||
<div style="clear:both;"><span>{$c.meta_title}</span></div>
|
||||
</a>
|
||||
</div>
|
||||
{/foreach}
|
||||
</div>
|
||||
|
||||
</div>
|
@ -0,0 +1,35 @@
|
||||
{include file="$tpl_dir./breadcrumb.tpl"}
|
||||
|
||||
<h1 class="title"><span>Guide d'achat - {$categoryTitle}</span></h1>
|
||||
<div class="content-guide rte{if $content_only} content_only{/if}">
|
||||
|
||||
{if $subcategoryTitle !== null}
|
||||
<div class="guide-intro">
|
||||
<div class="guide-intro-left">
|
||||
<h2 class="title">{$subcategoryTitle}</h2>
|
||||
<div>
|
||||
<p>{$subcategoryContent}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="guide-content">
|
||||
<div class="guide-content-menu">
|
||||
<ul>
|
||||
{foreach from=$postList item=p}
|
||||
<li{if $p.id_guide_post==$id_guide_post_select} class="selected"{/if}>
|
||||
<a href="{$base_dir_ssl}guide/{$categoryRewrite}/{$subcategoryRewrite}/{$p.id_guide_post}-{$p.link_rewrite}">{$p.meta_title}</a>
|
||||
</li>
|
||||
{/foreach}
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="guide-content-txt">
|
||||
<h4>{$postTitle}</h4>
|
||||
<div>{$postContent}</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
</div>
|
Loading…
Reference in New Issue
Block a user