garancia/controllers/front/FaqController.php
2016-10-10 15:24:25 +02:00

113 lines
3.3 KiB
PHP
Executable File

<?php
/*
* 2007-2013 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-2013 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
class FaqControllerCore extends FrontController
{
public $php_self = 'faq';
/**
* Assign template vars related to page content
* @see FrontController::initContent()
*/
public function setMedia()
{
parent::setMedia();
$this->addCSS(_THEME_CSS_DIR_.'faq.css');
$this->addJS(_THEME_JS_DIR_.'faq.js');
}
public function getItemsFaq($id_theme = null)
{
$id_shop = $this->context->shop->id;
$id_lang = $this->context->language->id;
return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
SELECT hs.`id_devspefaq_item` as id_faq,
hss.`position`,
hss.`id_theme`,
hss.`active`,
hssl.`title`,
hssl.`description`
FROM '._DB_PREFIX_.'devspefaq hs
LEFT JOIN '._DB_PREFIX_.'devspefaq_item hss ON (hs.id_devspefaq_item = hss.id_devspefaq_item)
LEFT JOIN '._DB_PREFIX_.'devspefaq_item_lang hssl ON (hss.id_devspefaq_item = hssl.id_devspefaq_item)
WHERE (id_shop = '.(int)$id_shop.')
AND hssl.id_lang = '.(int)$id_lang.'
AND hss.`active` = 1
AND hss.`id_theme` = '.(int)$id_theme.'
ORDER BY hss.position');
}
public function getItemsTheme($id_faq_parent=0)
{
$id_shop = $this->context->shop->id;
$id_lang = $this->context->language->id;
return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
SELECT hss.`id_faq_theme` as id_theme,
hss.`position`,
hss.`active`,
hss.`id_faq_parent`,
hssl.`title`
FROM '._DB_PREFIX_.'devspefaq_theme hss
LEFT JOIN '._DB_PREFIX_.'devspefaq_theme_lang hssl ON (hss.id_faq_theme = hssl.id_faq_theme)
WHERE hssl.id_lang = '.(int)$id_lang.'
AND id_faq_parent='.$id_faq_parent.'
AND hss.`active` = 1
ORDER BY hss.position');
}
public function generationFAQ()
{
$faqParents=$this->getItemsTheme(0);
foreach($faqParents as &$row){
$row['children']=$this->getItemsTheme($row['id_theme']);
foreach($row['children'] as &$row2){
$row2['items']=$this->getItemsFaq($row2['id_theme']);
}
if($row['id_theme']!=0)
$row['items']=$this->getItemsFaq($row['id_theme']);
}
return $faqParents;
}
public function initContent()
{
// $this->context = Context::getContext();
$id_shop = $this->context->shop->id;
$id_lang = $this->context->language->id;
$this->context->smarty->assign('generationFAQ',$this->generationFAQ());
$this->setTemplate(_PS_THEME_DIR_.'faq.tpl');
parent::initContent();
}
}