Front integration

This commit is contained in:
Michael RICOIS 2017-11-06 10:26:53 +01:00
parent cc35d92d83
commit 3eab7df2ef
12 changed files with 171 additions and 82 deletions

View File

@ -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');

View 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();

View File

@ -26,33 +26,35 @@ class GuideCategory extends ObjectModel
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,
'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;
}
@ -66,6 +68,7 @@ class GuideCategory extends ObjectModel
if ($this->id) {
return _PS_ROOT_DIR_.'/'.self::getSubPath().'/'.$this->id.'.jpg';
}
return '';
}
@ -74,6 +77,7 @@ class GuideCategory extends ObjectModel
if ($this->id) {
return __PS_BASE_URI__.self::getSubPath().'/'.$this->id.'.jpg';
}
return '';
}
@ -90,15 +94,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 +116,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,15 +135,11 @@ 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
));
}
}
@ -180,13 +170,13 @@ class GuideCategory extends ObjectModel
{
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()) {
@ -221,11 +211,11 @@ 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;
@ -241,8 +231,8 @@ class GuideCategory extends ObjectModel
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']))
@ -274,7 +264,7 @@ class GuideCategory extends ObjectModel
$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);
}

View File

@ -0,0 +1,6 @@
<?php
require_once dirname(__FILE__).'/../../config/config.inc.php';
require_once dirname(__FILE__).'/controllers/front/ContentController.php';
$controller = new ContentController();
$controller->run();

View File

@ -0,0 +1,23 @@
<?php
class CategoryController extends FrontController
{
//public function init(){}
//public function preProcess(){}
//public function displayHeader(){}
//public function process(){}
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);
}
}

View File

@ -0,0 +1,17 @@
<?php
class ContentController extends FrontController
{
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);
}
}

View File

@ -31,6 +31,8 @@ class PurchaseGuide extends Module
return FALSE;
}
$this->registerHook('leftColumn');
return TRUE;
}
@ -241,4 +243,19 @@ class PurchaseGuide extends Module
');
}
public function hookDisplayNavTop(){}
public function hookDisplayNavLeft(){}
public function hookRightColumn(){}
public function hookLeftColumn()
{
return $this->display(__FILE__, '/views/templates/front/leftcolumn.tpl');
}
public function displayCategory(){}
public function displayContent(){}
}

View File

@ -0,0 +1,6 @@
{include file="$tpl_dir./breadcrumb.tpl"}
<h1>TITLE</h1>
<div class="rte{if $content_only} content_only{/if}">
CONTENT
</div>

View File

@ -0,0 +1,12 @@
LEFT
HOOK_EXEC
Blockcms
Liste des catégories
RIGHT
Affichage du contenu categorie
Titre + Texte + image
Affichage menu des sous rubriques
Affichage du contenu de la sous rubrique

View File

@ -0,0 +1,11 @@
<div class="block-cms informations_block_left">
<h4>Vêtements</h4>
<ul class="block_content">
<li>
<a href="#">Bébés</a>
</li>
<li>
<a href="#">Enfants</a>
</li>
</ul>
</div>

View File

@ -396,6 +396,7 @@ class FrontController extends FrontControllerCore {
'module-ant_support_form-support',
'module-paypal-express_checkout-payment',
'module-paymentinfo-manage',
'module-purchaseguide-',
);
$displayRight = array(