From 0a1b0e066c2a625b389a3e5fce37376b59b731a8 Mon Sep 17 00:00:00 2001 From: CaMer0n Date: Wed, 23 Dec 2009 11:32:09 +0000 Subject: [PATCH] Search-related fixes and path fixes --- e107_plugins/faqs/faqs.php | 6 +++--- e107_plugins/faqs/faqs_shortcodes.php | 14 +++++++------- e107_plugins/faqs/search.php | 22 ++++++++++++++++++++++ 3 files changed, 32 insertions(+), 10 deletions(-) create mode 100644 e107_plugins/faqs/search.php diff --git a/e107_plugins/faqs/faqs.php b/e107_plugins/faqs/faqs.php index 95d45b09c..5637e2b91 100644 --- a/e107_plugins/faqs/faqs.php +++ b/e107_plugins/faqs/faqs.php @@ -9,8 +9,8 @@ * * * $Source: /cvs_backup/e107_0.8/e107_plugins/faqs/faqs.php,v $ - * $Revision: 1.6 $ - * $Date: 2009-12-12 10:30:28 $ + * $Revision: 1.7 $ + * $Date: 2009-12-23 11:32:09 $ * $Author: e107coders $ */ @@ -381,7 +381,7 @@ class faq } $text_menu .=""; - $text_menu .= "

".$tp->parseTemplate("{SEARCH=faq}")."
"; + $text_menu .= "

".$tp->parseTemplate("{SEARCH=faqs}")."
"; return $text_menu; // require_once (FOOTERF); diff --git a/e107_plugins/faqs/faqs_shortcodes.php b/e107_plugins/faqs/faqs_shortcodes.php index d4a0b65c2..7c4b51a68 100644 --- a/e107_plugins/faqs/faqs_shortcodes.php +++ b/e107_plugins/faqs/faqs_shortcodes.php @@ -10,8 +10,8 @@ | GNU General Public License (http://gnu.org). | | $Source: /cvs_backup/e107_0.8/e107_plugins/faqs/faqs_shortcodes.php,v $ - | $Revision: 1.2 $ - | $Date: 2009-11-20 05:01:51 $ + | $Revision: 1.3 $ + | $Date: 2009-12-23 11:32:09 $ | $Author: e107coders $ +----------------------------------------------------------------------------+ */ @@ -30,7 +30,7 @@ class faqs_shortcodes if($parm == 'expand') { - $text = "".$tp->toHtml($this->row['faq_question'])." + $text = "".$tp->toHtml($this->row['faq_question'])."
".$tp->toHTML($this->row['faq_answer'],TRUE)."
"; } else @@ -43,7 +43,7 @@ class faqs_shortcodes function sc_faq_question_link($parm='') { $tp = e107::getParser(); - return "row['faq_id']."' >".$tp -> toHtml($this->row['faq_question']).""; + return "row['faq_id']."' >".$tp -> toHtml($this->row['faq_question']).""; } function sc_faq_answer() @@ -58,7 +58,7 @@ class faqs_shortcodes $faqpref = e107::getPlugConfig('faqs')->getPref(); if(($faqpref['add_faq'] && $this->row['faq_author'] == USERID) || ADMIN ) { - return "[ row['faq_id']."'>Edit ]"; + return "[ row['faq_id']."'>Edit ]"; } } @@ -98,7 +98,7 @@ class faqs_shortcodes if (check_class($faqpref['add_faq'])) { - $text = "
Submit a Question + $text = "
Submit a Question
".$frm->textarea('ask_a_question','').'
'.$frm->submit('submit_a_question','Go')."
@@ -113,7 +113,7 @@ class faqs_shortcodes function sc_faq_search() { $tp = e107::getParser(); - return "

".$tp->parseTemplate("{SEARCH=faq}")."
"; + return "

".$tp->parseTemplate("{SEARCH=faqs}")."
"; } } diff --git a/e107_plugins/faqs/search.php b/e107_plugins/faqs/search.php new file mode 100644 index 000000000..be76ca52c --- /dev/null +++ b/e107_plugins/faqs/search.php @@ -0,0 +1,22 @@ + db_Select("faqs", "*", "faq_question REGEXP('".$query."') OR faq_answer REGEXP('".$query."') ORDER BY faq_id DESC ")){ + while($row = $sql -> db_Fetch()){ + extract($row); + if(eregi($query, $faq_question)){ + $que = parsesearch($faq_question, $query); + $ans = substr($faq_answer, 0,70); + $text .= "\"bullet\" ".$que."
Match found in faq question
".$ans."

"; + } + if(eregi($query, $faq_answer)){ + $resmain = parsesearch($faq_answer, $query); + $text .= "\"bullet\" ".$faq_question."
Match found in faq answer
".$resmain."

"; + } + } +}else{ + $text .= "No matches."; +} +?> \ No newline at end of file