create('faqs/list/all', false, 'full=1&noencode=1'); header('Location: '.$url); exit; incluXXXde_lan(e_PLUGIN."faqs/languages/".e_LANGUAGE."/".e_LANGUAGE."_front.php"); require_once (e_HANDLER."form_handler.php"); require_once (e_HANDLER."userclass_class.php"); require_once (e_HANDLER."ren_help.php"); require_once (e_HANDLER."comment_class.php"); if (!vartrue($FAQ_VIEW_TEMPLATE)) { if (file_exists(THEME."faqs_template.php")) { require_once (THEME."faqs_template.php"); } else { require_once (e_PLUGIN."faqs/faqs_template.php"); } } // require_once(HEADERF); // $pref['add_faq']=1; $rs = new form; $cobj = new comment; if (!vartrue($_GET['elan'])) { $qs = explode(".", e_QUERY); $action = $qs[0]; $id = $qs[1]; $idx = $qs[2]; } $from = (vartrue($from) ? $from : 0); $amount = 50; if (isset($_POST['faq_submit'])) { $message = "-"; if ($_POST['faq_question'] != "" || $_POST['data'] != "") { $faq_question = $aj->formtpa($_POST['faq_question'], "on"); $data = $aj->formtpa($_POST['data'], "on"); $count = ($sql->db_Count("faqs", "(*)", "WHERE faq_parent='".$_POST['faq_parent']."' ") + 1); $sql->db_Insert("faqs", " 0, '".$_POST['faq_parent']."', '$faq_question', '$data', '".$_POST['faq_comment']."', '".time()."', '".USERID."', '".$count."' "); $message = FAQ_ADLAN_32; unset($faq_question, $data); } else { $message = FAQ_ADLAN_30; } $id = $_POST['faq_parent']; } if (isset($_POST['faq_edit_submit'])) { if ($_POST['faq_question'] != "" || $_POST['data'] != "") { $faq_question = $aj->formtpa($_POST['faq_question'], "on"); $data = $aj->formtpa($_POST['data'], "on"); $sql->db_Update("faqs", "faq_parent='".$_POST['faq_parent']."', faq_question ='$faq_question', faq_answer='$data', faq_comment='".$_POST['faq_comment']."' WHERE faq_id='".$idx."' "); $message = FAQ_ADLAN_29; unset($faq_question, $data); } else { $message = FAQ_ADLAN_30; } } if (isset($_POST['commentsubmit'])) { $pid = (IsSet($_POST['pid']) ? $_POST['pid'] : 0); $cobj->enter_comment($_POST['author_name'], $_POST['comment'], "faq", $idx, $pid, $_POST['subject']); } // Actions +++++++++++++++++++++++++++++ $faq = new faq; $faqpref = e107::getPlugConfig('faqs')->getPref(); if ($action == "" || $action == "main") { if(vartrue($faqpref['classic_look'])) { $ftmp = $faq->show_existing_parents($action, $sub_action, $id, $from, $amount); $caption = FAQLAN_41; } else { $ftmp = $faq->view_all(); $caption = FAQLAN_FAQ; } if (vartrue($faqpref['faq_title'])) { define("e_PAGETITLE", $faqpref['faq_title']); } else { define("e_PAGETITLE", FAQLAN_23); } require_once (HEADERF); $ns->tablerender($caption, $ftmp['text']); } if($action == "cat" && $idx) { $ftmp = $faq->view_faq($idx) ; define("e_PAGETITLE",FAQLAN_FAQ." - ". $ftmp['title']); require_once(HEADERF); $ns -> tablerender($ftmp['caption'], $ftmp['text']); } if ($action == "cat") { $ftmp = $faq->view_cat_list($action, $id); define("e_PAGETITLE", strip_tags($ftmp['title'].$ftmp['caption'])); require_once (HEADERF); $ns->tablerender($ftmp['caption'], $ftmp['text']); } if ((check_class($faqpref['add_faq']) || ADMIN) && ($action == "new" || $action == "edit")) { require_once (HEADERF); $faq->add_faq($action, $id, $idx); } require_once (FOOTERF); exit; // ====== +++++++++++++++++++++++++++++ class faq { var $pref = array(); function __construct() { $sc = e107::getScBatch('faqs',TRUE); $this->pref = e107::getPlugConfig('faqs')->getPref(); $sc->pref = $this->pref; // setScVar('faqs_shortcodes', 'pref', $this->pref); } function view_all() // new funtion to render all FAQs { $sql = e107::getDb(); $tp = e107::getParser(); $ret = array(); global $FAQ_START, $FAQ_END, $FAQ_LISTALL_START,$FAQ_LISTALL_LOOP,$FAQ_LISTALL_END; //require_once (e_PLUGIN."faqs/faqs_shortcodes.php"); $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.") ORDER BY cat.faq_info_order,f.faq_order "; $sql->db_Select_gen($query); $text = $tp->parseTemplate($FAQ_START, true); $prevcat = ""; $sc = e107::getScBatch('faqs',TRUE); // var_dump($sc); while ($rw = $sql->db_Fetch()) { $sc->setVars($rw); if($rw['faq_info_order'] != $prevcat) { if($prevcat !='') { $text .= $tp->parseTemplate($FAQ_LISTALL_END, true, $sc); } $text .= "\n\n\n\n"; $text .= $tp->parseTemplate($FAQ_LISTALL_START, true, $sc); $start = TRUE; } $text .= $tp->parseTemplate($FAQ_LISTALL_LOOP, true, $sc); $prevcat = $rw['faq_info_order']; } $text .= $tp->parseTemplate($FAQ_LISTALL_END, true, $sc); $text .= $tp->parseTemplate($FAQ_END, true, $sc); $ret['title'] = FAQLAN_FAQ; $ret['text'] = $text; $ret['caption'] = vartrue($caption); return $ret; } // ------------- Everything below here is kept for backwards-compatability 'Classic Look' ------------ function view_cat_list($action, $id) { global $ns,$row,$FAQ_LIST_START,$FAQ_LIST_LOOP,$FAQ_LIST_END; $tp = e107::getParser(); $sql = e107::getDb(); $sc = e107::getScBatch('faqs',TRUE); $query = "SELECT f.*,cat.* FROM #faqs AS f LEFT JOIN #faqs_info AS cat ON f.faq_parent = cat.faq_info_id WHERE f.faq_parent = '$id' "; $sql->db_Select_gen($query); $sc->setVars($row); $text = $tp->parseTemplate($FAQ_LIST_START, true); while ($rw = $sql->db_Fetch()) { $sc->setVars($rw); $text .= $tp->parseTemplate($FAQ_LIST_LOOP, true); $caption = " Category: ".$rw['faq_info_title'].""; } $text .= $tp->parseTemplate($FAQ_LIST_END, true); $ret['title'] = FAQLAN_FAQ." - ".$category_title; $ret['text'] = $text.$this->faq_footer($id); $ret['caption'] = $caption; return $ret; } // ============================================================================= function show_existing_parents($action, $sub_action, $id, $from, $amount) { $tp = e107::getParser(); $sql = e107::getDb(); // ##### Display scrolling list of existing FAQ items --------------------------------------------------------------------------------------------------------- global $FAQ_CAT_START,$FAQ_CAT_PARENT,$FAQ_CAT_CHILD,$FAQ_CAT_END; // require_once (e_PLUGIN."faqs/faqs_shortcodes.php"); $sc = e107::getScBatch('faqs',TRUE); $text = "
"; $qry = "SELECT dc.*, COUNT(d.faq_id) AS f_count, COUNT(d2.faq_id) AS f_subcount FROM #faqs_info AS dc LEFT JOIN #faqs AS d ON dc.faq_info_id = d.faq_parent LEFT JOIN #faqs_info as dc2 ON dc2.faq_info_parent = dc.faq_info_id LEFT JOIN #faqs AS d2 ON dc2.faq_info_id = d2.faq_parent WHERE dc.faq_info_class IN (".USERCLASS_LIST.") GROUP by dc.faq_info_id ORDER by dc.faq_info_order,dc.faq_info_parent "; // $text .= $FAQ_CAT_START; $sql->db_Select_gen($qry); while ($row = $sql->db_Fetch()) { $sc->setVars($row); if ($row['faq_info_parent'] == '0') // { $text .= $tp->parseTemplate($FAQ_CAT_PARENT, true); } else { if (!$row['f_count'] && !$row['f_subcount']) { $text .= $tp->parseTemplate($FAQ_CAT_CHILD, true); } else { $text .= $tp->parseTemplate($FAQ_CAT_CHILD, true); } } } $text .= $FAQ_CAT_END; $ret['text'] = $text.$this->faq_footer(); return $ret; } // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ function view_faq($idx) { global $ns,$row,$sql,$aj,$pref,$cobj,$id,$tp,$FAQ_VIEW_TEMPLATE; //require_once (e_PLUGIN."faqs/faqs_shortcodes.php"); $sc = e107::getScBatch('faqs',TRUE); $sql->db_Select("faqs", "*", "faq_id='$idx' LIMIT 1"); $row = $sql->db_Fetch(); $sc->setVars($row); $caption = " FAQ #".$row['faq_id']; $text = $tp->parseTemplate($FAQ_VIEW_TEMPLATE, true); // $text = $tp->toHTML($text, TRUE); $ret['text'] = $text; $ret['caption'] = $caption; $ret['title'] = $row['faq_question']; $ret['comments'] = $text; return $ret; $subject = (!$subject ? $aj->formtpa($faq_question) : $subject); if (check_class($row['faq_comment'])) { $action = "comment"; $table = "faq"; $query = ($pref['nested_comments'] ? "comment_item_id='$idx' AND (comment_type='$table' OR comment_type='3') AND comment_pid='0' ORDER BY comment_datestamp" : "comment_item_id='$idx' AND (comment_type='$table' OR comment_type='3') ORDER BY comment_datestamp"); unset($text); if (!is_object($sql2)) { $sql2 = new db; } if ($comment_total = $sql2->db_Select("comments", "*", $query)) { $width = 0; while ($row = $sql2->db_Fetch()) { if ($pref['nested_comments']) { $text = $cobj->render_comment($row, $table, $action, $idx.".".$id, $width, $subject); $ns->tablerender(FAQLAN_38, $text); } else { $text .= $cobj->render_comment($row, $table, $action, $idx.".".$id, $width, $subject); } } if (!$pref['nested_comments']) { $ns->tablerender("Comments", $text); } if (ADMIN && getperms("B")) { // bkwon 05-Jun-2004 fix URL to moderate comment echo "
moderate comments

"; } } $cobj->form_comment($action, $table, $idx.".".$id, $subject, $content_type); } // end of check_class } function faq_footer($id='') { global $faqpref,$timing_start,$tp,$cust_footer, $CUSTOMPAGES, $CUSTOMHEADER, $CUSTOMHEADER; $text_menu .= "

  [ Back to Categories ]  "; if(check_class($faqpref['add_faq'])){ $text_menu .="[ Submit a Question ]"; } $text_menu .="
"; $text_menu .= "

".$tp->parseTemplate("{SEARCH=faqs}")."
"; return $text_menu; // require_once (FOOTERF); } function add_faq($action, $id, $idx) { global $rs; $tp = e107::getParser(); $sql = e107::getDb(); $ns = e107::getRender(); $userid = USERID; $text .= "
"; $sql->db_Select("faqs", "*", "faq_parent='$id' AND faq_author = '$userid' ORDER BY faq_id ASC"); $text .= "
"; while ($rw = $sql->db_Fetch()) { // list($pfaq_id, $pfaq_parent, $pfaq_question, $pfaq_answer, $pfaq_comment); $rw['faq_question'] = substr($rw['faq_question'], 0, 50)." ... "; $text .= ""; } $text .= "
".FAQ_ADLAN_49." Options
".($rw['faq_question'] ? $tp->toHTML($rw['faq_question']) : "[".NWSLAN_42."]")." ".$rs->form_button("submit", "entry_edit_{$rw['faq_id']}", FAQ_ADLAN_45, "onclick=\"document.location='".e_SELF."?edit.".$id.".".$rw['faq_id'].".'\""); // $text .= $rs -> form_button("submit", "entry_delete", FAQ_ADLAN_50, "onclick=\"document.location='".e_SELF."?delentry.$id.$pfaq_id'\"")." $text .= "
"; if ($action == "edit") { $sql->db_Select("faqs", "*", " faq_id = '$idx' "); $row = $sql->db_Fetch(); extract($row); $data = $faq_answer; } $text .= "
"; $text .= " "; $text .= " "; if (ADMIN) { $text .= ""; require_once (e_HANDLER."userclass_class.php"); $text .= ""; $text .= " "; } else { $text .= ""; } $text .= "
"; $text .= (is_numeric($id)) ? "Edit" : "Add"; $text .= " an FAQ
".FAQ_ADLAN_78." "; $text .= "
".FAQ_ADLAN_51."
".FAQ_ADLAN_60."

"; $text .= ren_help("addtext"); $text .= "
".FAQ_ADLAN_52."".r_userclass("faq_comment", $faq_comment, "", "public,guest,nobody,member,admin,classes")."
"; if ($action == "edit") { $text .= " "; } else { $text .= ""; } $text .= "
"; if(varset($faq)) { $sql->db_Select("faqs_info", "*", "faq_info_id='$faq'"); $row = $sql->db_Fetch(); extract($row); } $ns->tablerender("Frequently asked Questions".$faq_info_title, "
".$text."
".$this->faq_footer()); } } ?>