2009-11-09 12:57:34 +00:00
< ? php
/*
2009-11-17 10:46:35 +00:00
* e107 website system
*
2017-01-02 15:08:33 +00:00
* Copyright ( C ) 2008 - 2017 e107 Inc ( e107 . org )
2009-11-17 10:46:35 +00:00
* Released under the terms and conditions of the
* GNU General Public License ( http :// www . gnu . org / licenses / gpl . txt )
*
2016-12-30 19:48:05 +00:00
* FAQ Core Plugin
2009-11-17 10:46:35 +00:00
*
2009-11-09 12:57:34 +00:00
*/
2009-11-17 10:46:35 +00:00
2015-01-23 15:26:23 -08:00
if ( ! defined ( 'e107_INIT' ))
{
2021-01-21 09:38:38 -08:00
require_once ( __DIR__ . '/../../class2.php' );
2015-01-23 15:26:23 -08:00
}
2009-11-09 12:57:34 +00:00
2016-01-26 16:07:35 -08:00
if ( file_exists ( e_PLUGIN . " faqs/controllers/list.php " )) // bc for old controller.
2014-09-09 04:37:23 -07:00
{
$url = e107 :: getUrl () -> create ( 'faqs/list/all' , false , 'full=1&noencode=1' );
header ( 'Location: ' . $url );
exit ;
}
else
{
2015-03-31 06:26:06 -07:00
e107 :: includeLan ( e_PLUGIN . " faqs/languages/ " . e_LANGUAGE . " / " . e_LANGUAGE . " _front.php " );
2014-09-09 04:37:23 -07:00
}
2013-03-07 14:56:37 +02:00
2013-02-22 21:31:16 -08:00
2019-10-02 09:39:04 +02:00
require_once ( e_HANDLER . " form_handler.php " ); // TODO - Remove outdated code
2009-11-09 12:57:34 +00:00
require_once ( e_HANDLER . " userclass_class.php " );
2019-10-02 09:39:04 +02:00
require_once ( e_HANDLER . " ren_help.php " ); // TODO - Remove outdated code
2009-11-09 12:57:34 +00:00
require_once ( e_HANDLER . " comment_class.php " );
2019-10-02 09:39:04 +02:00
/*
2012-12-08 20:22:05 +01:00
if ( ! vartrue ( $FAQ_VIEW_TEMPLATE ))
2009-11-09 12:57:34 +00:00
{
if ( file_exists ( THEME . " faqs_template.php " ))
{
2014-09-09 04:37:23 -07:00
// require_once (THEME."faqs_template.php");
2009-11-09 12:57:34 +00:00
}
else
{
2014-09-09 04:37:23 -07:00
// require_once (e_PLUGIN."faqs/templates/faqs_template.php");
2009-11-09 12:57:34 +00:00
}
}
2019-10-02 09:39:04 +02:00
*/
2015-03-31 06:26:06 -07:00
e107 :: css ( 'faqs' , 'faqs.css' );
2009-11-09 12:57:34 +00:00
// require_once(HEADERF);
// $pref['add_faq']=1;
2019-10-02 09:39:04 +02:00
$rs = new form ; // TODO - Remove outdated code
$cobj = new comment ;
$tp = e107 :: getParser ();
$frm = e107 :: getForm ();
2009-11-09 12:57:34 +00:00
2014-09-09 20:22:59 -07:00
if ( ! vartrue ( $_GET [ 'elan' ]) && empty ( $_GET ))
2009-11-09 12:57:34 +00:00
{
2019-10-02 09:39:04 +02:00
$qs = explode ( " . " , e_QUERY );
2009-11-09 12:57:34 +00:00
$action = $qs [ 0 ];
2019-10-02 09:39:04 +02:00
$id = $qs [ 1 ];
$idx = $qs [ 2 ];
2009-11-09 12:57:34 +00:00
}
2020-12-18 19:55:12 -08:00
2014-09-09 20:22:59 -07:00
2012-12-08 15:52:40 +01:00
$from = ( vartrue ( $from ) ? $from : 0 );
2009-11-09 12:57:34 +00:00
$amount = 50 ;
if ( isset ( $_POST [ 'faq_submit' ]))
{
$message = " - " ;
if ( $_POST [ 'faq_question' ] != " " || $_POST [ 'data' ] != " " )
{
2019-10-02 09:39:04 +02:00
$faq_question = $tp -> toDB ( $_POST [ 'faq_question' ]);
$data = $tp -> toDB ( $_POST [ 'data' ]);
2020-12-17 13:13:29 -08:00
$count = ( $sql -> count ( " faqs " , " (*) " , " WHERE faq_parent=' " . intval ( $_POST [ 'faq_parent' ]) . " ' " ) + 1 );
2019-10-02 09:39:04 +02:00
2021-09-04 15:06:19 +02:00
$sql -> insert ( " faqs " , " 0, ' " . $_POST [ 'faq_parent' ] . " ', ' $faq_question ', ' $data ', ' " . e107 :: getParser () -> filter ( $_POST [ 'faq_comment' ], 'str' ) . " ', ' " . time () . " ', ' " . USERID . " ', ' " . $count . " ' " );
2019-10-02 09:39:04 +02:00
2009-11-09 12:57:34 +00:00
$message = FAQ_ADLAN_32 ;
2019-10-02 09:39:04 +02:00
2009-11-09 12:57:34 +00:00
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' ] != " " )
{
2019-10-02 09:39:04 +02:00
$faq_question = $tp -> toDB ( $_POST [ 'faq_question' ]);
$data = $tp -> toDB ( $_POST [ 'data' ]);
2009-12-02 22:34:58 +00:00
2019-10-02 09:39:04 +02:00
$sql -> update ( " faqs " , " faq_parent=' " . intval ( $_POST [ 'faq_parent' ]) . " ', faq_question =' $faq_question ', faq_answer=' $data ', faq_comment=' " . $_POST [ 'faq_comment' ] . " ' WHERE faq_id=' " . $idx . " ' " );
2009-11-09 12:57:34 +00:00
$message = FAQ_ADLAN_29 ;
2019-10-02 09:39:04 +02:00
2009-11-09 12:57:34 +00:00
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 ();
2017-01-04 08:32:40 +00:00
if ( empty ( $action ) || $action == " main " )
2009-11-09 12:57:34 +00:00
{
if ( vartrue ( $faqpref [ 'classic_look' ]))
{
2011-07-24 20:57:48 +00:00
$ftmp = $faq -> show_existing_parents ( $action , $sub_action , $id , $from , $amount );
2009-12-12 10:30:33 +00:00
$caption = FAQLAN_41 ;
2009-11-09 12:57:34 +00:00
}
else
{
2014-09-09 20:22:59 -07:00
$srch = vartrue ( $_GET [ 'srch' ]);
$ftmp = $faq -> view_all ( $srch );
2017-10-18 17:00:40 -07:00
$caption = LAN_FAQS_011 ;
2015-03-31 06:26:06 -07:00
2009-11-09 12:57:34 +00:00
}
2009-12-02 22:34:58 +00:00
2015-06-07 18:15:23 -07:00
$pageTitle = '' ;
2015-05-11 14:07:11 -07:00
if ( vartrue ( $faqpref [ 'page_title' ]))
2009-11-09 12:57:34 +00:00
{
2015-06-07 18:15:23 -07:00
$pageTitle = $faqpref [ 'page_title' ][ e_LANGUAGE ];
2009-11-09 12:57:34 +00:00
}
else
{
2015-06-07 18:15:23 -07:00
$pageTitle = $ftmp [ 'caption' ];
}
if ( ! empty ( $ftmp [ 'pagetitle' ]))
{
$pageTitle .= " : " . $ftmp [ 'pagetitle' ];
}
2021-09-22 12:14:24 -07:00
// e107::getMessage()->addDebug("TITLE: " . $pageTitle);
2015-06-07 18:15:23 -07:00
e107 :: meta ( 'og:title' , $pageTitle );
2021-09-22 12:14:24 -07:00
e107 :: title ( $pageTitle );
2015-06-07 18:15:23 -07:00
if ( ! empty ( $ftmp [ 'pagedescription' ]))
{
e107 :: meta ( 'og:description' , $ftmp [ 'pagedescription' ]);
2009-11-09 12:57:34 +00:00
}
2011-07-24 20:57:48 +00:00
2021-09-22 12:14:24 -07:00
2009-11-09 12:57:34 +00:00
require_once ( HEADERF );
2011-07-24 20:57:48 +00:00
2020-12-05 14:13:18 -08:00
e107 :: getRender () -> tablerender ( $ftmp [ 'caption' ], $ftmp [ 'text' ]);
2011-07-24 20:57:48 +00:00
2009-11-09 12:57:34 +00:00
}
if ( $action == " cat " && $idx )
{
2011-07-24 20:57:48 +00:00
$ftmp = $faq -> view_faq ( $idx ) ;
2020-12-05 14:13:18 -08:00
if ( ! defined ( " e_PAGETITLE " ))
{
2020-12-10 15:52:48 -08:00
e107 :: title ( LAN_FAQS_011 . " - " . $ftmp [ 'title' ]);
2020-12-05 14:13:18 -08:00
}
2009-11-09 12:57:34 +00:00
require_once ( HEADERF );
2020-12-05 14:13:18 -08:00
e107 :: getRender () -> tablerender ( $ftmp [ 'caption' ], $ftmp [ 'text' ]);
2009-11-09 12:57:34 +00:00
}
2009-12-02 22:34:58 +00:00
2009-11-09 12:57:34 +00:00
if ( $action == " cat " )
{
2011-07-24 20:57:48 +00:00
$ftmp = $faq -> view_cat_list ( $action , $id );
2009-12-02 22:34:58 +00:00
2020-12-10 15:52:48 -08:00
e107 :: title ( strip_tags ( $ftmp [ 'title' ] . $ftmp [ 'caption' ]));
2009-11-09 12:57:34 +00:00
require_once ( HEADERF );
2020-12-05 14:13:18 -08:00
e107 :: getRender () -> tablerender ( $ftmp [ 'caption' ], $ftmp [ 'text' ]);
2009-11-09 12:57:34 +00:00
}
2019-10-02 09:39:04 +02:00
if (( check_class ( $faqpref [ 'add_faq' ]) || ADMIN ) && ( $action == " new " || $action == " edit " ))
2009-11-09 12:57:34 +00:00
{
require_once ( HEADERF );
$faq -> add_faq ( $action , $id , $idx );
}
require_once ( FOOTERF );
exit ;
// ====== +++++++++++++++++++++++++++++
class faq
{
var $pref = array ();
2014-09-09 20:22:59 -07:00
protected $sc = null ;
protected $template = null ;
2015-06-07 18:15:23 -07:00
protected $pageTitle = null ;
protected $pageDescription = null ;
2009-12-02 22:34:58 +00:00
2009-11-09 12:57:34 +00:00
function __construct ()
{
2015-05-28 09:47:28 -07:00
$sc = e107 :: getScBatch ( 'faqs' , true );
2015-01-28 02:29:26 -08:00
$this -> pref = e107 :: pref ( 'faqs' ); // Short version of e107::getPlugConfig('faqs')->getPref(); ;
2012-11-02 01:50:28 +00:00
$sc -> pref = $this -> pref ;
2015-01-28 02:29:26 -08:00
2015-03-31 06:26:06 -07:00
if ( ! empty ( $_POST [ 'submit_a_question' ]))
{
$sql = e107 :: getDb ();
2015-04-02 12:34:32 -07:00
$existing = $sql -> select ( 'faqs' , 'faq_id' , " faq_answer='' AND faq_author_ip = ' " . USERIP . " ' " );
if ( ! empty ( $this -> pref [ 'submit_question_limit' ]) && $existing >= $this -> pref [ 'submit_question_limit' ])
2015-03-31 06:26:06 -07:00
{
2017-10-18 17:00:40 -07:00
e107 :: getMessage () -> setTitle ( LAN_WARNING , E_MESSAGE_INFO ) -> addInfo ( LAN_FAQS_005 );
2015-03-31 06:26:06 -07:00
return ;
}
$question = filter_input ( INPUT_POST , 'ask_a_question' , FILTER_SANITIZE_STRING );
$insert = array (
2015-05-28 09:47:28 -07:00
'faq_id' => 0 ,
'faq_parent' => 0 , // meaning 'unassigned/unanswered'.
2015-03-31 06:26:06 -07:00
'faq_question' => $question ,
'faq_answer' => '' ,
'faq_comment' => 0 ,
'faq_datestamp' => time (),
2015-05-28 09:47:28 -07:00
'faq_author' => USERID ,
2015-03-31 06:26:06 -07:00
'faq_author_ip' => USERIP ,
'faq_tags' => '' ,
'faq_order' => 99999
);
2019-10-02 09:39:04 +02:00
if ( $sql -> insert ( 'faqs' , $insert ))
2015-03-31 06:26:06 -07:00
{
2019-02-26 12:22:36 -08:00
$message = ! empty ( $this -> pref [ 'submit_question_acknowledgement' ]) ? e107 :: getParser () -> toHTML ( $this -> pref [ 'submit_question_acknowledgement' ], true , 'BODY' ) : LAN_FAQS_004 ;
2015-05-29 17:14:09 -07:00
e107 :: getMessage () -> addSuccess ( $message );
2015-03-31 06:26:06 -07:00
}
}
2009-12-02 22:34:58 +00:00
}
2015-03-31 06:26:06 -07:00
2014-09-09 20:22:59 -07:00
function view_all ( $srch ) // new funtion to render all FAQs
2009-11-09 12:57:34 +00:00
{
$tp = e107 :: getParser ();
2011-07-24 20:57:48 +00:00
$ret = array ();
2009-12-02 22:34:58 +00:00
2014-09-09 04:37:23 -07:00
$template = e107 :: getTemplate ( 'faqs' );
2014-09-09 20:22:59 -07:00
$this -> template = $template ;
2014-09-09 04:37:23 -07:00
2014-09-09 20:22:59 -07:00
$this -> sc = e107 :: getScBatch ( 'faqs' , TRUE );
2012-11-02 00:23:59 +00:00
2015-03-31 06:26:06 -07:00
$text = $tp -> parseTemplate ( $template [ 'start' ], true , $this -> sc ); // header
2014-09-09 04:37:23 -07:00
2013-02-22 21:31:16 -08:00
// var_dump($sc);
2012-11-02 00:23:59 +00:00
2014-09-09 20:22:59 -07:00
$text .= " <div id='faqs-container'> " ;
$text .= $this -> view_all_query ( $srch );
$text .= " </div> " ;
2015-03-31 06:26:06 -07:00
$text .= $tp -> parseTemplate ( $template [ 'end' ], true , $this -> sc ); // footer
2014-09-09 20:22:59 -07:00
2017-10-18 17:00:40 -07:00
$ret [ 'title' ] = LAN_FAQS_011 ;
2014-09-09 20:22:59 -07:00
$ret [ 'text' ] = $text ;
2015-05-29 17:14:09 -07:00
2015-06-07 18:15:23 -07:00
if ( ! empty ( $this -> pref [ 'page_title' ][ e_LANGUAGE ]))
2015-05-29 17:14:09 -07:00
{
2019-02-26 12:22:36 -08:00
$ret [ 'caption' ] = e107 :: getParser () -> toHTML ( $this -> pref [ 'page_title' ][ e_LANGUAGE ], true , 'TITLE' );
2015-05-29 17:14:09 -07:00
}
else
{
$ret [ 'caption' ] = varset ( $template [ 'caption' ]) ? $tp -> parseTemplate ( $template [ 'caption' ], true , $this -> sc ) : LAN_PLUGIN_FAQS_FRONT_NAME ;
}
2015-06-07 18:15:23 -07:00
if ( ! empty ( $this -> pageTitle ))
{
$ret [ 'pagetitle' ] = e107 :: getParser () -> toText ( $this -> pageTitle );
}
if ( ! empty ( $this -> pageDescription ))
{
$ret [ 'pagedescription' ] = e107 :: getParser () -> toText ( $this -> pageDescription , true , 'RAWTEXT' );
}
2014-09-09 20:22:59 -07:00
return $ret ;
}
function view_all_query ( $srch = '' )
{
$sql = e107 :: getDb ();
$tp = e107 :: getParser ();
2015-03-31 06:26:06 -07:00
$text = " " ;
2014-09-09 20:22:59 -07:00
2015-06-07 18:15:23 -07:00
$insert = " " ;
$item = false ;
$removeUrl = e107 :: url ( 'faqs' , 'index' );
2015-01-28 02:29:26 -08:00
2014-09-09 20:22:59 -07:00
if ( ! empty ( $srch ))
{
$srch = $tp -> toDB ( $srch );
2015-06-07 18:15:23 -07:00
$insert = " AND (f.faq_question LIKE '% " . $srch . " %' OR f.faq_answer LIKE '% " . $srch . " %' OR FIND_IN_SET (' " . $srch . " ', f.faq_tags) ) " ;
2017-10-18 17:00:40 -07:00
// $message = "<span class='label label-lg label-info'>".$srch." <a class='e-tip' title='".LAN_FAQS_006."' href='".$removeUrl."'>× </a></span>";
2015-06-07 18:15:23 -07:00
2017-10-18 17:00:40 -07:00
// e107::getMessage()->setClose(false,E_MESSAGE_INFO)->setTitle(LAN_FAQS_002,E_MESSAGE_INFO)->addInfo($message);
// $text = e107::getMessage()->render();
2015-06-07 18:15:23 -07:00
}
if ( ! empty ( $_GET [ 'id' ])) // pull out just one specific FAQ.
{
$srch = intval ( $_GET [ 'id' ]);
// $insert = " AND (f.faq_id = ".$srch.") ";
$item = $srch ;
2014-09-09 20:22:59 -07:00
}
2015-01-28 02:29:26 -08:00
if ( ! empty ( $_GET [ 'cat' ]))
2014-09-09 20:22:59 -07:00
{
2015-01-28 02:29:26 -08:00
$srch = $tp -> toDB ( $_GET [ 'cat' ]);
2015-03-31 06:26:06 -07:00
$insert = " AND (cat.faq_info_sef = ' " . $srch . " ') " ;
}
if ( ! empty ( $_GET [ 'tag' ]))
{
$srch = $tp -> toDB ( $_GET [ 'tag' ]);
$insert = " AND FIND_IN_SET (' " . $srch . " ', f.faq_tags) " ;
2017-10-18 17:00:40 -07:00
$message = " <span class='label label-lg label-info'> " . $srch . " <a class='e-tip' title=' " . LAN_FAQS_006 . " ' href=' " . $removeUrl . " '>× </a></span> " ;
2015-03-31 06:26:06 -07:00
2017-10-18 17:00:40 -07:00
e107 :: getMessage () -> setClose ( false , E_MESSAGE_INFO ) -> setTitle ( LAN_FAQS_002 , E_MESSAGE_INFO ) -> addInfo ( $message );
2015-03-31 06:26:06 -07:00
$text = e107 :: getMessage () -> render ();
2014-09-09 20:22:59 -07:00
}
2015-05-28 09:47:28 -07:00
list ( $orderBy , $ascdesc ) = explode ( '-' , vartrue ( $this -> pref [ 'orderby' ], 'faq_order-ASC' ));
$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 . " ) " . $insert . " ORDER BY cat.faq_info_order, f. " . $orderBy . " " . $ascdesc . " " ;
2014-09-09 20:22:59 -07:00
2016-04-22 08:46:34 -07:00
if ( ! $data = $sql -> retrieve ( $query , true ))
2014-09-09 20:22:59 -07:00
{
2017-10-18 17:00:40 -07:00
$message = ( ! empty ( $srch )) ? e107 :: getParser () -> lanVars ( LAN_FAQS_008 , $srch ) . " <a class='e-tip' title=' " . LAN_FAQS_007 . " ' href=' " . $removeUrl . " '> " . LAN_FAQS_007 . " </a> " : LAN_FAQS_003 ;
2016-12-30 19:48:05 +00:00
return " <div class='alert alert-warning alert-block'> " . $message . " </div> " ;
2014-09-09 20:22:59 -07:00
}
2015-01-28 02:29:26 -08:00
// -----------------
$FAQ_LISTALL = e107 :: getTemplate ( 'faqs' , true , 'all' );
2015-03-31 06:26:06 -07:00
$prevcat = " " ;
2015-01-28 02:29:26 -08:00
$sc = e107 :: getScBatch ( 'faqs' , true );
$sc -> counter = 1 ;
2017-01-02 15:36:25 +00:00
$sc -> tag = htmlspecialchars ( varset ( $tag ), ENT_QUOTES , 'utf-8' );
$sc -> category = varset ( $category );
2015-01-28 02:29:26 -08:00
2015-06-07 18:15:23 -07:00
if ( ! empty ( $_GET [ 'id' ])) // expand one specific FAQ.
{
$sc -> item = intval ( $_GET [ 'id' ]);
$js = "
$ ( document ) . ready ( function () {
$ ( 'html, body' ) . animate ({ scrollTop : $ ( 'div#faq_".$sc->item."' ) . offset () . top - 300 }, 4000 );
});
" ;
e107 :: js ( 'footer-inline' , $js );
}
2015-03-31 06:26:06 -07:00
// $text = $tp->parseTemplate($FAQ_START, true, $sc);
// $text = "";
2015-05-28 09:47:28 -07:00
if ( $this -> pref [ 'list_type' ] == 'ol' )
{
$reversed = ( $ascdesc == 'DESC' ) ? 'reversed ' : '' ;
$tsrch = array ( '<ul ' , '/ul>' );
$trepl = array ( '<ol ' . $reversed , '/ol>' );
$FAQ_LISTALL [ 'start' ] = str_replace ( $tsrch , $trepl , $FAQ_LISTALL [ 'start' ]);
$FAQ_LISTALL [ 'end' ] = str_replace ( $tsrch , $trepl , $FAQ_LISTALL [ 'end' ]);
}
2016-04-22 08:46:34 -07:00
foreach ( $data as $rw )
2009-11-09 12:57:34 +00:00
{
2015-06-07 18:47:51 -07:00
$rw [ 'faq_sef' ] = eHelper :: title2sef ( $tp -> toText ( $rw [ 'faq_question' ]), 'dashl' );
2015-06-07 18:15:23 -07:00
$sc -> setVars ( $rw );
if ( $sc -> item == $rw [ 'faq_id' ])
{
$this -> pageTitle = $rw [ 'faq_question' ];
$this -> pageDescription = $rw [ 'faq_answer' ];
}
2015-01-28 02:29:26 -08:00
2009-11-09 12:57:34 +00:00
if ( $rw [ 'faq_info_order' ] != $prevcat )
{
if ( $prevcat != '' )
{
2015-01-28 02:29:26 -08:00
$text .= $tp -> parseTemplate ( $FAQ_LISTALL [ 'end' ], true , $sc );
2009-11-09 12:57:34 +00:00
}
$text .= " \n \n <!-- FAQ Start " . $rw [ 'faq_info_order' ] . " --> \n \n " ;
2015-01-28 02:29:26 -08:00
$text .= $tp -> parseTemplate ( $FAQ_LISTALL [ 'start' ], true , $sc );
2009-12-02 22:34:58 +00:00
$start = TRUE ;
2009-11-09 12:57:34 +00:00
}
2009-12-02 22:34:58 +00:00
2015-01-28 02:29:26 -08:00
$text .= $tp -> parseTemplate ( $FAQ_LISTALL [ 'item' ], true , $sc );
2009-11-09 12:57:34 +00:00
$prevcat = $rw [ 'faq_info_order' ];
2015-01-28 02:29:26 -08:00
$sc -> counter ++ ;
2009-11-09 12:57:34 +00:00
}
2015-01-28 02:29:26 -08:00
$text .= ( $start ) ? $tp -> parseTemplate ( $FAQ_LISTALL [ 'end' ], true , $sc ) : " " ;
2015-03-31 06:26:06 -07:00
// $text .= $tp->parseTemplate($FAQ_END, true, $sc);
2014-09-09 20:22:59 -07:00
return $text ;
2011-07-24 20:57:48 +00:00
2009-11-09 12:57:34 +00:00
}
2009-12-02 22:34:58 +00:00
2009-11-09 12:57:34 +00:00
2014-09-09 20:22:59 -07:00
2009-11-09 12:57:34 +00:00
// ------------- Everything below here is kept for backwards-compatability 'Classic Look' ------------
2009-12-02 22:34:58 +00:00
2009-11-09 12:57:34 +00:00
function view_cat_list ( $action , $id )
{
global $ns , $row , $FAQ_LIST_START , $FAQ_LIST_LOOP , $FAQ_LIST_END ;
2009-12-02 22:34:58 +00:00
2012-11-02 00:23:59 +00:00
$tp = e107 :: getParser ();
$sql = e107 :: getDb ();
$sc = e107 :: getScBatch ( 'faqs' , TRUE );
2009-12-02 22:34:58 +00:00
2009-11-09 12:57:34 +00:00
$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 ' " ;
2019-10-02 09:39:04 +02:00
$sql -> gen ( $query );
2012-11-02 00:23:59 +00:00
$sc -> setVars ( $row );
2009-12-02 22:34:58 +00:00
2009-11-09 12:57:34 +00:00
$text = $tp -> parseTemplate ( $FAQ_LIST_START , true );
2009-12-02 22:34:58 +00:00
2019-10-02 09:39:04 +02:00
while ( $rw = $sql -> fetch ())
2009-11-09 12:57:34 +00:00
{
2012-11-02 00:23:59 +00:00
$sc -> setVars ( $rw );
2009-11-09 12:57:34 +00:00
$text .= $tp -> parseTemplate ( $FAQ_LIST_LOOP , true );
2016-12-30 21:39:45 +00:00
$caption = " " . LAN_CATEGORY . " : <b> " . $rw [ 'faq_info_title' ] . " </b> " ;
2009-11-09 12:57:34 +00:00
}
2009-12-02 22:34:58 +00:00
2009-11-09 12:57:34 +00:00
$text .= $tp -> parseTemplate ( $FAQ_LIST_END , true );
2009-12-02 22:34:58 +00:00
2017-10-18 17:00:40 -07:00
$ret [ 'title' ] = LAN_FAQS_011 . " - " . $category_title ;
2009-11-09 12:57:34 +00:00
$ret [ 'text' ] = $text . $this -> faq_footer ( $id );
$ret [ 'caption' ] = $caption ;
return $ret ;
}
// =============================================================================
2009-12-02 22:34:58 +00:00
2009-11-09 12:57:34 +00:00
function show_existing_parents ( $action , $sub_action , $id , $from , $amount )
{
$tp = e107 :: getParser ();
$sql = e107 :: getDb ();
2009-12-02 22:34:58 +00:00
2009-11-09 12:57:34 +00:00
// ##### Display scrolling list of existing FAQ items ---------------------------------------------------------------------------------------------------------
global $FAQ_CAT_START , $FAQ_CAT_PARENT , $FAQ_CAT_CHILD , $FAQ_CAT_END ;
2009-12-02 22:34:58 +00:00
2012-11-02 00:23:59 +00:00
// require_once (e_PLUGIN."faqs/faqs_shortcodes.php");
$sc = e107 :: getScBatch ( 'faqs' , TRUE );
2009-12-02 22:34:58 +00:00
2009-11-09 12:57:34 +00:00
$text = " <div style='text-align:center'>
< div style = 'text-align:center' > " ;
2009-12-02 22:34:58 +00:00
2009-11-09 12:57:34 +00:00
$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 " ; //
2009-12-02 22:34:58 +00:00
2009-11-09 12:57:34 +00:00
$text .= $FAQ_CAT_START ;
2009-12-02 22:34:58 +00:00
2019-10-02 09:39:04 +02:00
$sql -> gen ( $qry );
while ( $row = $sql -> fetch ())
2009-11-09 12:57:34 +00:00
{
2012-11-02 00:23:59 +00:00
$sc -> setVars ( $row );
2009-12-02 22:34:58 +00:00
2009-11-09 12:57:34 +00:00
if ( $row [ 'faq_info_parent' ] == '0' ) //
{
$text .= $tp -> parseTemplate ( $FAQ_CAT_PARENT , true );
}
else
{
2009-12-02 22:34:58 +00:00
2009-11-09 12:57:34 +00:00
if ( ! $row [ 'f_count' ] && ! $row [ 'f_subcount' ])
{
2009-12-02 22:34:58 +00:00
2009-11-09 12:57:34 +00:00
$text .= $tp -> parseTemplate ( $FAQ_CAT_CHILD , true );
}
else
{
$text .= $tp -> parseTemplate ( $FAQ_CAT_CHILD , true );
}
}
}
2009-12-02 22:34:58 +00:00
2009-11-09 12:57:34 +00:00
$text .= $FAQ_CAT_END ;
2009-12-02 22:34:58 +00:00
2019-09-30 15:56:03 +02:00
$text .= " </div>
</ div > " ;
2009-11-09 12:57:34 +00:00
$ret [ 'text' ] = $text . $this -> faq_footer ();
return $ret ;
2009-12-02 22:34:58 +00:00
2009-11-09 12:57:34 +00:00
}
2009-12-02 22:34:58 +00:00
2009-11-09 12:57:34 +00:00
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2009-12-02 22:34:58 +00:00
2009-11-09 12:57:34 +00:00
function view_faq ( $idx )
{
2019-10-02 09:39:04 +02:00
global $row , $pref , $cobj , $id , $FAQ_VIEW_TEMPLATE ;
$ns = e107 :: getRender ();
$sql = e107 :: getDb ();
$tp = e107 :: getParser ();
2012-11-02 00:23:59 +00:00
//require_once (e_PLUGIN."faqs/faqs_shortcodes.php");
$sc = e107 :: getScBatch ( 'faqs' , TRUE );
2009-12-02 22:34:58 +00:00
2019-10-02 09:39:04 +02:00
$sql -> select ( " faqs " , " * " , " faq_id=' $idx ' LIMIT 1 " );
$row = $sql -> fetch ();
2012-11-02 00:23:59 +00:00
$sc -> setVars ( $row );
2009-12-02 22:34:58 +00:00
2009-11-09 12:57:34 +00:00
$caption = " FAQ # " . $row [ 'faq_id' ];
$text = $tp -> parseTemplate ( $FAQ_VIEW_TEMPLATE , true );
2009-12-02 22:34:58 +00:00
2009-11-09 12:57:34 +00:00
// $text = $tp->toHTML($text, TRUE);
2009-12-02 22:34:58 +00:00
2019-10-02 09:39:04 +02:00
$ret [ 'text' ] = $text ;
$ret [ 'caption' ] = $caption ;
$ret [ 'title' ] = $row [ 'faq_question' ];
$ret [ 'comments' ] = $text ;
2009-12-02 22:34:58 +00:00
2009-11-09 12:57:34 +00:00
return $ret ;
2009-12-02 22:34:58 +00:00
2019-10-02 09:39:04 +02:00
$subject = ( ! $subject ? $tp -> toDB ( $faq_question ) : $subject );
2009-12-02 22:34:58 +00:00
2009-11-09 12:57:34 +00:00
if ( check_class ( $row [ 'faq_comment' ]))
{
2009-12-02 22:34:58 +00:00
2009-11-09 12:57:34 +00:00
$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 );
2019-10-02 09:39:04 +02:00
2009-11-09 12:57:34 +00:00
if ( ! is_object ( $sql2 ))
{
$sql2 = new db ;
}
2019-10-02 09:39:04 +02:00
if ( $comment_total = $sql2 -> select ( " comments " , " * " , $query ))
2009-11-09 12:57:34 +00:00
{
$width = 0 ;
2019-10-02 09:39:04 +02:00
while ( $row = $sql2 -> fetch ())
2009-11-09 12:57:34 +00:00
{
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' ])
{
2015-07-07 18:02:16 -07:00
$ns -> tablerender ( LAN_COMMENTS , $text );
2009-11-09 12:57:34 +00:00
}
if ( ADMIN && getperms ( " B " ))
{
// bkwon 05-Jun-2004 fix URL to moderate comment
2017-10-18 17:00:40 -07:00
echo " <div style='text-align:right'><a href=' " . e_ADMIN . " modcomment.php?faq. $faq_id '> " . LAN_FAQS_009 . " </a></div><br /> " ;
2009-11-09 12:57:34 +00:00
}
}
$cobj -> form_comment ( $action , $table , $idx . " . " . $id , $subject , $content_type );
} // end of check_class
}
2009-12-02 22:34:58 +00:00
2009-11-09 12:57:34 +00:00
function faq_footer ( $id = '' )
{
2019-10-02 09:39:04 +02:00
global $faqpref , $timing_start , $cust_footer , $CUSTOMPAGES , $CUSTOMHEADER , $CUSTOMHEADER ;
$tp = e107 :: getParser ();
2009-11-09 12:57:34 +00:00
$text_menu .= " <div style='text-align:center;' ><br />
2017-10-18 17:00:40 -07:00
& nbsp ; & nbsp ;[ & nbsp ; < a href = 'faqs.php?main' > " .LAN_FAQS_010. " </ a >& nbsp ;] & nbsp ; & nbsp ; " ;
2009-11-09 12:57:34 +00:00
if ( check_class ( $faqpref [ 'add_faq' ])){
2017-01-02 15:08:33 +00:00
$text_menu .= " [ <a href='faqs.php?new. $id '> " . LAN_FAQS_ASK_A_QUESTION . " </a> ] " ;
2009-11-09 12:57:34 +00:00
}
2019-10-02 09:39:04 +02:00
2009-11-09 12:57:34 +00:00
$text_menu .= " </div> " ;
2009-12-23 11:32:09 +00:00
$text_menu .= " <div style='text-align:center'><br /> " . $tp -> parseTemplate ( " { SEARCH=faqs} " ) . " </div> " ;
2019-10-02 09:39:04 +02:00
return $text_menu ;
2009-12-02 22:34:58 +00:00
2009-11-09 12:57:34 +00:00
// require_once (FOOTERF);
}
2009-12-02 22:34:58 +00:00
2009-11-09 12:57:34 +00:00
function add_faq ( $action , $id , $idx )
{
2019-10-02 09:39:04 +02:00
global $rs ; // TODO - remove old code
2009-12-02 22:34:58 +00:00
2019-10-02 09:39:04 +02:00
$tp = e107 :: getParser ();
$sql = e107 :: getDb ();
$ns = e107 :: getRender ();
2009-12-02 22:34:58 +00:00
2009-11-09 12:57:34 +00:00
$userid = USERID ;
2009-12-02 22:34:58 +00:00
2009-11-09 12:57:34 +00:00
$text .= " <table class='fborder' style= \" " . USER_WIDTH . " \" >
< tr >
< td colspan = '2' class = 'forumheader3' style = \ " width:80%; padding:0px \" > " ;
2019-10-02 09:39:04 +02:00
$sql -> select ( " faqs " , " * " , " faq_parent=' $id ' AND faq_author = ' $userid ' ORDER BY faq_id ASC " );
2009-11-09 12:57:34 +00:00
$text .= " <div style='width : auto; height : 110px; overflow : auto; '>
< table class = 'fborder' style = \ " width:100% \" >
< tr >
< td class = 'fcaption' style = \ " width:70% \" > " . FAQ_ADLAN_49 . " </td>
2016-12-30 19:48:05 +00:00
< td class = 'fcaption' style = 'text-align:center' > " .LAN_SETTINGS. " </ td ></ tr >
2009-11-09 12:57:34 +00:00
" ;
2019-10-02 09:39:04 +02:00
while ( $rw = $sql -> fetch ())
2009-11-09 12:57:34 +00:00
{
// list($pfaq_id, $pfaq_parent, $pfaq_question, $pfaq_answer, $pfaq_comment);
$rw [ 'faq_question' ] = substr ( $rw [ 'faq_question' ], 0 , 50 ) . " ... " ;
2009-12-02 22:34:58 +00:00
2009-11-09 12:57:34 +00:00
$text .= " <tr>
< td style = 'width:70%' class = 'forumheader3' > " .( $rw['faq_question'] ? $tp->toHTML ( $rw['faq_question'] ) : " [ " .NWSLAN_42. " ] " ). " </ td >
< td style = 'width:30%; text-align:center' class = 'forumheader3' >
" . $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 .= " </td>
</ tr > " ;
}
$text .= " </table></div> " ;
2009-12-02 22:34:58 +00:00
2019-10-02 09:39:04 +02:00
// TODO - optimize
2009-11-09 12:57:34 +00:00
if ( $action == " edit " )
{
2019-10-02 09:39:04 +02:00
$sql -> select ( " faqs " , " * " , " faq_id = ' $idx ' " );
$row = $sql -> fetch ();
extract ( $row ); // get rid of this
2009-11-09 12:57:34 +00:00
$data = $faq_answer ;
}
2009-12-02 22:34:58 +00:00
2009-11-09 12:57:34 +00:00
$text .= " </td>
</ tr ></ table >< form method = \ " post \" action= \" " . e_SELF . " ?cat. $id . $idx\ " id = \ " dataform \" >
< table class = 'fborder' style = \ " " . USER_WIDTH . " \" >
< tr >
< td class = 'fcaption' colspan = '2' style = 'text-align:center' > " ;
2009-12-02 22:34:58 +00:00
2016-12-30 19:48:05 +00:00
$text .= ( is_numeric ( $id )) ? LAN_EDIT : LAN_ADD ; //LAN_ADD may not exist on the front end, but I dont think this code is used - Mikey.
$text .= " FAQ</td></tr> " ;
2009-12-02 22:34:58 +00:00
2009-11-09 12:57:34 +00:00
$text .= "
< tr >
< td class = 'forumheader3' style = \ " width:20% \" > " . FAQ_ADLAN_78 . " </td>
< td class = 'forumheader3' style = \ " width:80% \" > " ;
2009-12-02 22:34:58 +00:00
2009-11-09 12:57:34 +00:00
$text .= " <select style='width:150px' class='tbox' id='faq_parent' name='faq_parent' > " ;
2019-10-02 09:39:04 +02:00
$sql -> select ( " faqs_info " , " * " , " faq_info_parent !='0' " );
while ( $prow = $sql -> fetch ())
2009-11-09 12:57:34 +00:00
{
//extract($row);
$selected = $prow [ 'faq_info_id' ] == $id ? " selected='selected' " : " " ;
$text .= " <option value= \" " . $prow [ 'faq_info_id' ] . " \" $selected > " . $prow [ 'faq_info_title' ] . " </option> " ;
}
$text .= " </select>
</ td >
</ tr > " ;
2009-12-02 22:34:58 +00:00
2009-11-09 12:57:34 +00:00
$text .= "
< tr >
< td class = 'forumheader3' style = \ " width:20% \" > " . FAQ_ADLAN_51 . " </td>
< td class = 'forumheader3' style = \ " width:80% \" >
< input class = \ " tbox \" type= \" text \" name= \" faq_question \" style= \" width:100% \" value= \" $faq_question\ " />
</ td >
</ tr >
< tr >
< td class = 'forumheader3' style = \ " width:20%;vertical-align:top \" > " . FAQ_ADLAN_60 . " </td>
< td class = 'forumheader3' style = \ " width:80% \" >
< textarea id = \ " data \" cols='15' class= \" tbox \" name= \" data \" style= \" width:100% \" rows= \" 8 \" onselect= \" storeCaret(this); \" onclick= \" storeCaret(this); \" onkeyup= \" storeCaret(this); \" > $data </textarea>
< br />
< input class = 'helpbox' type = \ " text \" id='helpb' name= \" helpb \" size= \" 70 \" style='width:100%' /><br />
" ;
$text .= ren_help ( " addtext " );
2009-12-02 22:34:58 +00:00
2009-11-09 12:57:34 +00:00
$text .= " <br /></td></tr> " ;
2009-12-02 22:34:58 +00:00
2009-11-09 12:57:34 +00:00
if ( ADMIN )
{
$text .= " <tr>
< td class = 'forumheader3' style = \ " width:20%; vertical-align:top \" > " . FAQ_ADLAN_52 . " </td> " ;
require_once ( e_HANDLER . " userclass_class.php " );
$text .= " <td class='forumheader3' > " . r_userclass ( " faq_comment " , $faq_comment , " " , " public,guest,nobody,member,admin,classes " ) . " </td> " ;
$text .= "
</ tr > " ;
}
else
{
$text .= " <input type='hidden' name='faq_comment' value='0' /> " ;
}
$text .= "
< tr >
< td class = 'forumheader' colspan = \ " 2 \" style= \" text-align:center \" >
" ;
2009-12-02 22:34:58 +00:00
2009-11-09 12:57:34 +00:00
if ( $action == " edit " )
{
$text .= " <input class= \" button \" type= \" submit \" name= \" faq_edit_submit \" value= \" " . FAQ_ADLAN_53 . " $faq_id\ " />
< input type = \ " hidden \" name= \" faq_id \" value= \" $idx\ " /> " ;
}
else
{
$text .= " <input class= \" button \" type= \" submit \" name= \" faq_submit \" value= \" " . FAQ_ADLAN_54 . " \" /> " ;
}
2009-12-02 22:34:58 +00:00
2009-11-09 12:57:34 +00:00
$text .= " <input type= \" hidden \" name= \" faq \" value= \" $faq\ " />
</ td >
</ tr >
</ table >
</ form > " ;
2009-12-02 22:34:58 +00:00
2009-11-09 12:57:34 +00:00
if ( varset ( $faq ))
{
2019-10-02 09:39:04 +02:00
$sql -> select ( " faqs_info " , " * " , " faq_info_id=' $faq ' " );
$row = $sql -> fetch ();
extract ( $row ); // get rid of this
2009-11-09 12:57:34 +00:00
}
2019-10-02 09:39:04 +02:00
$ns -> tablerender ( LAN_PLUGIN_FAQS_FRONT_NAME . $faq_info_title , " <div style='text-align:center'> " . $text . " </div> " . $this -> faq_footer ());
2009-12-02 22:34:58 +00:00
2009-11-09 12:57:34 +00:00
}
}