Merge branch 'develop' of gitlab.antadis.net:dev-antadis/bebeboutik into develop

This commit is contained in:
Christophe Latour 2017-11-23 15:18:31 +01:00
commit dd867a7017
9 changed files with 178 additions and 44 deletions

View File

@ -100,7 +100,11 @@ class BlockBestSellers extends Module
if (Configuration::get('PS_CATALOG_MODE'))
return ;
global $cookie, $smarty, $cart;
global $cookie, $smarty, $cart, $page_name;
if ($page_name == 'post') {
return;
}
$step = Tools::getValue('step');
if(!$step || ($step && $step != 3 && $step != 4)) {
$id_lang = $cookie->id_lang;

View File

@ -365,8 +365,6 @@ class AdminGuideCategories extends AdminTab
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();
@ -379,7 +377,7 @@ class AdminGuideCategories extends AdminTab
public function viewguide_category()
{
global $cookie;
$this->getList((int)($cookie->id_lang));
$this->getList((int)($cookie->id_lang), 'position');
$this->displayList();
$this->displayOptionsList();
$this->displayRequiredFields();

View File

@ -107,7 +107,9 @@ class AdminGuidePosts extends AdminTab
public function displayList()
{
$this->_orderBy = 'position';
if (Tools::getIsset('id_guide_category')) {
$this->_orderBy = 'position';
}
parent::displayList();
}
@ -128,7 +130,7 @@ class AdminGuidePosts extends AdminTab
'id_guide_category' => array(
'title' => $this->l('Catégorie du guide'),
'type' => 'select',
'options_raw' => GuideCategory::findCategoriesTree($cookie->id_lang),
'options_raw' => GuideCategory::findCategoriesTree($cookie->id_lang, 2),
'options_map' => ['id_guide_category', 'name', 'level'],
'initial_value' => $obj->id_guide_category
),

View File

@ -97,7 +97,7 @@ class GuideCategory extends ObjectModel
return '';
}
public static function findCategoriesTree($id_lang, $exclude_id=0)
public static function findCategoriesTree($id_lang, $levelMax = null, $exclude_id=0)
{
$sql = "SELECT DISTINCT a.`id_guide_category` as id_guide_category, `name`
FROM `"._DB_PREFIX_."guide_category` a
@ -106,11 +106,11 @@ class GuideCategory extends ObjectModel
WHERE b.id_lang = '".intval($id_lang)."'
AND a.`id_parent` = '%s'
";
if ($exclude_id!='0') {
if ($exclude_id != '0') {
$sql .= " AND a.`id_guide_category` <> '".intval($exclude_id)."'";
}
$rows = array();
self::findRecursiveData($rows, $sql, array(
self::findRecursiveData($rows, $sql, $levelMax, array(
'id_parent' => 0,
'identifier' => 'id_guide_category',
'level' => -1
@ -119,7 +119,7 @@ class GuideCategory extends ObjectModel
return $rows;
}
public static function findFamiliesTree($id_lang, $exclude_id=0)
public static function findFamiliesTree($id_lang, $levelMax = null, $exclude_id=0)
{
$sql = "SELECT DISTINCT a.`id_category_family` as id_category_family, `name`
FROM `"._DB_PREFIX_."category_family` a
@ -132,26 +132,28 @@ class GuideCategory extends ObjectModel
$sql .= " AND a.`id_category_family` <> '".intval($exclude_id)."'";
}
$rows = array();
self::findRecursiveData($rows, $sql, array(
self::findRecursiveData($rows, $sql, $levelMax, array(
'id_parent' => 0,
'identifier' => 'id_category_family',
'level' => -1
'level' => 0
));
return $rows;
}
private static function findRecursiveData(&$rows, $sql, array $params)
private static function findRecursiveData(&$rows, $sql, $levelMax = null, array $params)
{
$level = $params['level'];
$level++;
if ($levelMax !== null && $level >= $levelMax) {
return;
}
$resuts = Db::getInstance()->ExecuteS(sprintf($sql, intval($params['id_parent'])));
foreach($resuts as &$row) {
$results = Db::getInstance()->ExecuteS(sprintf($sql, intval($params['id_parent'])));
foreach($results as &$row) {
$row['level'] = $level;
$rows[] = $row;
self::findRecursiveData($rows, $sql, array(
self::findRecursiveData($rows, $sql, $levelMax, array(
'id_parent' => $row[$params['identifier']],
'identifier' => $params['identifier'],
'level' => $level
@ -180,10 +182,8 @@ class GuideCategory extends ObjectModel
public function update($autodate = true, $nullValues = false)
{
$this->position = self::getLastPosition((int)$this->id_parent);
$ret = parent::update($autodate, $nullValues);
$this->cleanupPositions((int)$this->id_parent);
return $ret;
self::cleanupPositions((int)$this->id_parent);
return parent::update($autodate, $nullValues);
}
public function delete()
@ -348,10 +348,10 @@ class GuideCategory extends ObjectModel
return $result;
}
public function getAutoCategoryLang($id_category, $id_lang)
public function getAutoCategoryLang($id_category, $id_lang, $active = true)
{
$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
WHERE ".($active===true?' gc.active=1 ':' 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);
@ -364,12 +364,12 @@ class GuideCategory extends ObjectModel
* @param int $id_lang
* @return array
*/
public static function getRoot($id_lang, $active = 1)
public static function getRoot($id_lang, $active = true)
{
$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
WHERE ".($active===true?' 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);
@ -382,7 +382,7 @@ class GuideCategory extends ObjectModel
* @param int $active
* @return array
*/
public function getTree($id_lang, $active = 1)
public function getTree($id_lang, $active = true)
{
return $this->recurseData(0, $id_lang, $active);
}
@ -394,13 +394,13 @@ class GuideCategory extends ObjectModel
* @param int $active
* @return array
*/
protected function recurseData($id_category, $id_lang, $active = 1)
protected function recurseData($id_category, $id_lang, $active = true)
{
$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.
($active===true?' AND gc.active=1 ':'')." AND gc.id_parent=".$id_category.
" ORDER BY position ASC";
$result = Db::getInstance()->ExecuteS($sql);
if (count($result) > 0) {

View File

@ -127,7 +127,7 @@ class GuidePost extends ObjectModel
public function update($autodate = true, $nullValues = false)
{
$this->position = self::cleanupPositions((int)$this->id_guide_category);
self::cleanupPositions((int)$this->id_guide_category);
return parent::update($autodate, $nullValues);
}
@ -180,15 +180,16 @@ class GuidePost extends ObjectModel
public function getUrlRewriteFull(){}
/**
* Get Post With one language
* Get Post with one language
* @param int $id_category
* @param int $id_lang
* @param boolean $active
* @return array
*/
public function getPostLang($id_post, $id_lang, $id_category = null)
public function getPostLang($id_post, $id_lang, $id_category = null, $active = true)
{
$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
WHERE ".($active===true?' gp.active=1 ':' 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);
@ -196,11 +197,17 @@ class GuidePost extends ObjectModel
return $result;
}
public function getAutoPostLang($id_category, $id_lang)
/**
* Auto select post
* @param int $id_category
* @param int $id_lang
* @param boolean $active
* @return array
*/
public function getAutoPostLang($id_category, $id_lang, $active = true)
{
$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
WHERE ".($active===true?' gp.active=1 ':' 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);
@ -208,10 +215,17 @@ class GuidePost extends ObjectModel
return $result;
}
public function findByCategory($id_category, $id_lang)
/**
* Find posts filter by category
* @param int $id_category
* @param int $id_lang
* @param boolean $active
* @return array
*/
public function findByCategory($id_category, $id_lang, $active = true)
{
$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
WHERE ".($active===true?' gp.active=1 ':' 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);

View File

@ -8,6 +8,7 @@ class CategoryController extends FrontController
parent::preProcess();
$id_lang = self::$cookie->id_lang;
$isEmployee = self::$cookie->isLoggedBack();
$categories = array();
// Get main categories

View File

@ -17,16 +17,17 @@ class PostController extends FrontController
$content = null;
// @todo, si on vient de l'admin, voir les post ???
$isEmployee = self::$cookie->isLoggedBack();
// Start form post
$postModel = new GuidePost();
if ($id_post != 0) {
$content = $postModel->getPostLang($id_post, $id_lang);
$content = $postModel->getPostLang($id_post, $id_lang, !$isEmployee);
$id_category = $content['id_guide_category'];
}
// Categories
if ($id_category == 0) {
if ($id_category == 0 && $isEmployee === false) {
Tools::display404Error('404.php');
}
else {
@ -47,23 +48,23 @@ class PostController extends FrontController
else {
$parentCategory = $category;
// Auto Select category
$category = $categoryModel->getAutoCategoryLang($id_category, $id_lang);
$category = $categoryModel->getAutoCategoryLang($id_category, $id_lang, !$isEmployee);
}
}
// Post
if ($content === null) {
if ($id_post != 0) {
$content = $postModel->getPostLang($id_post, $id_lang, $category['id_guide_category']);
$content = $postModel->getPostLang($id_post, $id_lang, $category['id_guide_category'], !$isEmployee);
}
// Auto Select Post
else {
$content = $postModel->getAutoPostLang($category['id_guide_category'], $id_lang);
$content = $postModel->getAutoPostLang($category['id_guide_category'], $id_lang, !$isEmployee);
}
}
// Liste des Posts
$postList = $postModel->findByCategory($category['id_guide_category'], $id_lang);
$postList = $postModel->findByCategory($category['id_guide_category'], $id_lang, !$isEmployee);
$parentCategoryModel = new GuideCategory($parentCategory['id_guide_category']);
$parentCategoryLink = $parentCategoryModel->getLinkRewrite($id_lang);
@ -92,7 +93,7 @@ class PostController extends FrontController
self::$smarty->assign(array(
'path' => $path,
'id_category' => $id_category,
'id_category' => $parentCategory['id'],
'categoryTitle' => $parentCategory['name'],
'categoryLink' => $parentCategoryLink,
'categoryRewrite' => $parentCategory['link_rewrite'],

View File

@ -272,6 +272,7 @@ class PurchaseGuide extends Module
return false;
}
$isEmployee = $cookie->isLoggedBack();
$id_category = Tools::getValue('cid', 0);
// Récup de l'arbre en fonction des catégories

View File

@ -7624,3 +7624,116 @@ div.addresses ul.address.item {
width: 100%;
}
.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 {
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,
.guide-content ul li a:visited {
color: #000;
}
.guide-content ul li.selected a {
font-weight: bold;
color: #796dc7;
}
.guide-content-txt {
width:580px;
float: right;
padding: 0 5px;
}