*/ /** * patTemplate function FAQ * * Simple FAQ list * * @version 0.1.0 * @package Wombat * @subpackage patTemplate */ class patTemplate_Function_FAQ extends patTemplate_Function { /** * Function Type * @var integer */ public $_type = PATTEMPLATE_FUNCTION_RUNTIME; /** * Configuration * @var array */ private $config = array( 'type' => 0 ); /** * @var WBDatasource_Table */ private $table; /** * @var patTemplate */ private $tmpl; /** * constructor * */ public function __construct() { $this->table = WBClass::create('WBDatasource_Table'); $this->tmpl = WBClass::create('patTemplate'); } /** * Call the Function * * @todo add ACL * @param array parameters of the function (= attributes of the tag) * @param string content of the tag * @return string content to insert into the template */ public function call($params, $content) { $params = array_merge(array( 'type' => 0 ), $params ); $this->tmpl->readTemplatesFromInput('FAQ/Function/list.tmpl'); $clause = array(); $clause[] = array( 'field' => 'enabled', 'value' => 1 ); if (!empty($params['type'])) { $params['type'] = array_map('trim', explode(',', $params['type'])); $clause[] = array( 'field' => $this->table->getIdentifier('faqtype', true), 'value' => $params['type'], 'relation' => 'in' ); } $option = array(); $option['limit'] = 50; $list = $this->table->get('faq', null, null, $clause); $this->tmpl->addGlobalVar('list_count', count($list)); $this->tmpl->addRows('list_entry', $list); return $this->tmpl->getParsedTemplate('snippet'); } }