diff --git a/e107_plugins/faqs/admin_config.php b/e107_plugins/faqs/admin_config.php index 6bef5d34c..e2607e85f 100644 --- a/e107_plugins/faqs/admin_config.php +++ b/e107_plugins/faqs/admin_config.php @@ -185,7 +185,10 @@ class faq_main_ui extends e_admin_ui 'faq_question' => array('title'=> LANA_FAQ_QUESTION, 'tab' => 0, 'type' => 'text', 'width' => 'auto', 'thclass' => 'left first', 'required'=>TRUE, 'readParms'=>'editable=1'), 'faq_answer' => array('title'=> LANA_FAQ_ANSWER, 'tab' => 0, 'type' => 'bbarea', 'width' => '30%', 'readParms' => 'expand=1&truncate=50&bb=1'), 'faq_parent' => array('title'=> LAN_CATEGORY, 'tab' => 0, 'type' => 'dropdown', 'data'=> 'int', 'inline'=>true,'width' => '10%', 'filter'=>TRUE, 'batch'=>TRUE), + + 'faq_tags' => array('title'=> LANA_FAQ_TAGS, 'tab' => 1, 'type' => 'text', 'data' => 'str', 'width' => 'auto', 'inline'=> true, 'help' => LANA_FAQ_TAGS_HELP), // User id 'faq_comment' => array('title'=> LANA_FAQ_COMMENT, 'tab' => 1, 'type' => 'userclass', 'data' => 'int', 'width' => 'auto', 'inline'=> true), // User id + 'faq_datestamp' => array('title'=> LAN_DATE, 'tab' => 1, 'type' => 'datestamp', 'data'=> 'int','width' => 'auto', 'noedit' => false,'writeParms'=>'auto=1'), 'faq_author' => array('title'=> LAN_USER, 'tab' => 1, 'type' => 'user', 'data'=> 'int', 'width' => 'auto', 'thclass' => 'center', 'class'=>'center', 'writeParms' => 'currentInit=1', 'filter' => true, 'batch' => true, 'nolist' => true ), // Photo 'u.user_name' => array('title'=> LANA_FAQ_UNAME, 'tab' => 1, 'type' => 'user', 'width' => 'auto', 'noedit' => true, 'readParms'=>'idField=faq_author&link=1'), // User name diff --git a/e107_plugins/faqs/controllers/list.php b/e107_plugins/faqs/controllers/list.php index 0d49d3c47..396dcde6b 100644 --- a/e107_plugins/faqs/controllers/list.php +++ b/e107_plugins/faqs/controllers/list.php @@ -35,6 +35,7 @@ class plugin_faqs_list_controller extends eControllerFront protected $filter = array( 'all' => array( 'category' => array('int', '0:'), + 'tag' => array('str', '2:'), ), ); @@ -61,23 +62,37 @@ class plugin_faqs_list_controller extends eControllerFront // 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'); - $where = ''; + $where = array(); if($category) { - $where = " AND f.faq_parent={$category}"; + $where[] = "f.faq_parent={$category}"; } + $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 = ''; + $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 "; - $sql->gen($query); + $sql->gen($query, false); $prevcat = ""; $sc = e107::getScBatch('faqs', true); + $sc->counter = 1; + $sc->tag = htmlspecialchars($tag, ENT_QUOTES, 'utf-8'); + $sc->category = $category; $text = $tp->parseTemplate($FAQ_START, true); - $sc->counter = 1; while ($rw = $sql->db_Fetch()) { $sc->setVars($rw); diff --git a/e107_plugins/faqs/faqs_shortcodes.php b/e107_plugins/faqs/faqs_shortcodes.php index dab98cce8..b88749af6 100644 --- a/e107_plugins/faqs/faqs_shortcodes.php +++ b/e107_plugins/faqs/faqs_shortcodes.php @@ -35,16 +35,26 @@ class faqs_shortcodes extends e_shortcode function sc_faq_question($parm='') { $tp = e107::getParser(); - - if($parm == 'expand') + $parm = eHelper::scDualParams($parm); + $param = $parm[1]; + $params = $parm[2]; + + if($param == 'expand') { + $tags = ''; + if(vartrue($params['tags']) && $this->var['faq_tags']) + { + $tags = "
".$this->sc_faq_tags()."
"; + } $id = "faq_".$this->var['faq_id']; - $text = "".$tp->toHtml($this->var['faq_question'],true)." -
".$tp->toHTML($this->var['faq_answer'],TRUE)."
"; + $text = "".$tp->toHTML($this->var['faq_question'],true)." +
".$tp->toHTML($this->var['faq_answer'],TRUE).$tags."
+ "; + } else { - $text = $tp->toHtml($this->var['faq_question'],true); + $text = $tp->toHTML($this->var['faq_question'],true); } return $text; } @@ -52,12 +62,50 @@ class faqs_shortcodes extends e_shortcode function sc_faq_question_link($parm='') { $tp = e107::getParser(); - return " $this->var['faq_id']))."' >".$tp -> toHtml($this->var['faq_question']).""; + return " $this->var['faq_id']))."' >".$tp -> toHTML($this->var['faq_question']).""; } function sc_faq_answer() { - return e107::getParser()->toHtml($this->var['faq_answer'],true); + return e107::getParser()->toHTML($this->var['faq_answer'],true); + } + + + function sc_faq_tags($parm='') + { + $tags = $this->var['faq_tags']; + if(!$tags) return ''; + + if(!$parm) $parm = ' | '; + + $ret = $urlparms = array(); + if($this->category) $urlparms['category'] = $this->category; + $tags = array_map('trim', explode(',', $tags)); + foreach ($tags as $tag) + { + $urlparms['tag'] = $tag; + $url = e107::getUrl()->create('faqs/list/all', $urlparms); + $tag = htmlspecialchars($tag, ENT_QUOTES, 'utf-8'); + $ret[] = ''.$tag.''; + } + + return implode($parm, $ret); + } + + function sc_faq_current_tag($parm='') + { + if(!$this->tag) return ''; + + $tag = $this->tag; + if($parm == 'raw') return $tag; + + $urlparms = array(); + if($this->category) $urlparms['category'] = $this->category; + $urlparms['tag'] = $tag; + $url = e107::getUrl()->create('faqs/list/all', $urlparms); + if($parm == 'url') return $url; + + return ''.$tag.''; } function sc_faq_edit() @@ -71,10 +119,14 @@ class faqs_shortcodes extends e_shortcode } } - function sc_faq_category() + function sc_faq_category($parm = '') { $tp = e107::getParser(); - return " $this->var['faq_info_id']))."'>".$tp->toHtml($this->var['faq_info_title']).""; + if($parm == 'extend' && $this->tag) + { + return "".$tp->toHTML($this->var['faq_info_title'])." » ".$this->sc_faq_current_tag('raw').""; + } + return " $this->var['faq_info_id']))."'>".$tp->toHTML($this->var['faq_info_title']).""; } function sc_faq_caturl() @@ -91,7 +143,7 @@ class faqs_shortcodes extends e_shortcode function sc_faq_cat_diz() { $tp = e107::getParser(); - return $tp->toHtml($this->var['faq_info_about']); + return $tp->toHTML($this->var['faq_info_about'], true); } function sc_faq_icon() @@ -127,6 +179,3 @@ class faqs_shortcodes extends e_shortcode } } - - -?> \ No newline at end of file diff --git a/e107_plugins/faqs/faqs_sql.php b/e107_plugins/faqs/faqs_sql.php index 4c05b0fcb..8bdfbd08f 100644 --- a/e107_plugins/faqs/faqs_sql.php +++ b/e107_plugins/faqs/faqs_sql.php @@ -6,6 +6,7 @@ CREATE TABLE faqs ( faq_comment tinyint(1) unsigned NOT NULL default '0', faq_datestamp int(10) unsigned NOT NULL default '0', faq_author int(10) unsigned default NULL, + faq_tags varchar(255) NOT NULL default '', faq_order int(6) unsigned NOT NULL default '0', PRIMARY KEY (faq_id) ) ENGINE=MyISAM; diff --git a/e107_plugins/faqs/languages/English/English_admin.php b/e107_plugins/faqs/languages/English/English_admin.php index 1e13edf03..3e0ddaba2 100644 --- a/e107_plugins/faqs/languages/English/English_admin.php +++ b/e107_plugins/faqs/languages/English/English_admin.php @@ -13,6 +13,9 @@ define('LANA_FAQ_ANSWER', 'Answer'); define('LANA_FAQ_COMMENT', 'Comment'); //FIXME Use generic define('LANA_FAQ_UNAME', 'User name'); //FIXME Use generic define('LANA_FAQ_ULOGINNAME', 'User login'); //FIXME Use generic +define('LANA_FAQ_TAGS', 'Tags'); +define('LANA_FAQ_TAGS_HELP', 'Comma separated tag list'); + define('LANA_FAQ_PREF_1', 'Allow submitting of FAQs by:'); define('LANA_FAQ_PREF_2', 'Allow submitting of Questions by:'); define('LANA_FAQ_PREF_3', 'Use Classic Layout'); diff --git a/e107_plugins/faqs/templates/faqs_template.php b/e107_plugins/faqs/templates/faqs_template.php index acf9ef5a6..79955c049 100644 --- a/e107_plugins/faqs/templates/faqs_template.php +++ b/e107_plugins/faqs/templates/faqs_template.php @@ -20,11 +20,11 @@ $FAQS_TEMPLATE['end'] = " $FAQS_TEMPLATE['all']['start'] = "
-

{FAQ_CATEGORY}

+

{FAQ_CATEGORY=extend}