1
0
mirror of https://github.com/e107inc/e107.git synced 2025-02-13 11:04:38 +01:00

141 lines
3.4 KiB
PHP
Raw Normal View History

2013-03-07 10:22:03 +02:00
<?php
/*
* e107 website system
*
* Copyright (C) 2008-2012 e107 Inc (e107.org)
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
*/
/**
*
* @package e107
* @subpackage faqs
* @version $Id$
* @author e107inc
*
* FAQ plugin list controller
*/
2013-03-26 20:14:03 -07:00
2013-03-07 10:22:03 +02:00
2013-03-07 14:56:37 +02:00
class plugin_faqs_list_controller extends eControllerFront
2013-03-07 10:22:03 +02:00
{
2013-03-07 14:56:37 +02:00
/**
* Plugin name - used to check if plugin is installed
* Set this only if plugin requires installation
* @var string
*/
protected $plugin = 'faqs';
/**
* User input filter (_GET)
* Format 'action' => array(var => validationArray)
* @var array
*/
protected $filter = array(
'all' => array(
'category' => array('int', '0:'),
2013-03-15 17:15:29 +02:00
'tag' => array('str', '2:'),
2013-03-07 14:56:37 +02:00
),
);
2013-03-07 10:22:03 +02:00
public function init()
{
e107::lan('faqs', 'front');
2013-03-26 20:14:03 -07:00
e107::css('faqs','faqs.css');
2013-03-07 10:22:03 +02:00
}
public function actionIndex()
{
$this->_forward('all');
}
public function actionAll()
{
$sql = e107::getDb();
$tp = e107::getParser();
//global $FAQ_START, $FAQ_END, $FAQ_LISTALL_START,$FAQ_LISTALL_LOOP,$FAQ_LISTALL_END;
$FAQ_START = e107::getTemplate('faqs', true, 'start');
$FAQ_END = e107::getTemplate('faqs', true, 'end');
$FAQ_LISTALL = e107::getTemplate('faqs', true, 'all');
2013-03-07 14:56:37 +02:00
// request parameter based on filter (int match in this case, see $this->filter[all][category]) - SAFE to be used in a query
$category = $this->getRequest()->getRequestParam('category');
2013-03-15 17:15:29 +02:00
$where = array();
2013-03-07 14:56:37 +02:00
if($category)
{
2013-03-15 17:15:29 +02:00
$where[] = "f.faq_parent={$category}";
2013-03-07 14:56:37 +02:00
}
2013-03-15 17:15:29 +02:00
$tag = $this->getRequest()->getRequestParam('tag');
if($tag)
{
$where[] = "FIND_IN_SET ('".$tp->toDB($tag)."', f.faq_tags)";
}
if($where)
{
$where = ' AND '.implode(' AND ' , $where);
}
else $where = '';
2013-03-07 14:56:37 +02:00
$query = "
SELECT f.*,cat.* FROM #faqs AS f
LEFT JOIN #faqs_info AS cat ON f.faq_parent = cat.faq_info_id
WHERE cat.faq_info_class IN (".USERCLASS_LIST."){$where} ORDER BY cat.faq_info_order,f.faq_order ";
2013-03-15 17:15:29 +02:00
$sql->gen($query, false);
2013-03-07 10:22:03 +02:00
$prevcat = "";
$sc = e107::getScBatch('faqs', true);
2013-03-15 17:15:29 +02:00
$sc->counter = 1;
$sc->tag = htmlspecialchars($tag, ENT_QUOTES, 'utf-8');
$sc->category = $category;
2013-03-07 10:22:03 +02:00
$text = $tp->parseTemplate($FAQ_START, true, $sc);
2013-03-10 03:47:48 -07:00
2013-03-07 10:22:03 +02:00
while ($rw = $sql->db_Fetch())
{
$sc->setVars($rw);
2013-03-10 03:47:48 -07:00
2013-03-07 10:22:03 +02:00
if($rw['faq_info_order'] != $prevcat)
{
if($prevcat !='')
{
$text .= $tp->parseTemplate($FAQ_LISTALL['end'], true, $sc);
2013-03-07 10:22:03 +02:00
}
$text .= "\n\n<!-- FAQ Start ".$rw['faq_info_order']."-->\n\n";
$text .= $tp->parseTemplate($FAQ_LISTALL['start'], true, $sc);
2013-03-07 10:22:03 +02:00
$start = TRUE;
}
$text .= $tp->parseTemplate($FAQ_LISTALL['item'], true, $sc);
2013-03-07 10:22:03 +02:00
$prevcat = $rw['faq_info_order'];
2013-03-10 03:47:48 -07:00
$sc->counter++;
if($category) $meta = $rw;
2013-03-07 10:22:03 +02:00
}
$text .= $tp->parseTemplate($FAQ_LISTALL['end'], true, $sc);
$text .= $tp->parseTemplate($FAQ_END, true, $sc);
// add meta data if there is parent category
if(!empty($meta))
{
$response = $this->getResponse();
if($meta['faq_info_metad'])
{
$response->addMetaDescription($meta['faq_info_metad']);
}
if($meta['faq_info_metak'])
{
$response->addMetaKeywords($meta['faq_info_metak']);
}
}
2013-03-07 14:56:37 +02:00
$this->addTitle(LAN_PLUGIN_FAQS_FRONT_NAME);
2013-03-07 10:22:03 +02:00
$this->addBody($text);
}
}