1 | <?php |
---|
2 | // +-------------------------------------------------+ |
---|
3 | // © 2002-2004 PMB Services / www.sigb.net pmb@sigb.net et contributeurs (voir www.sigb.net) |
---|
4 | // +-------------------------------------------------+ |
---|
5 | // $Id: faq_questions.class.php,v 1.2 2015-04-03 11:16:19 jpermanne Exp $ |
---|
6 | |
---|
7 | if (stristr($_SERVER['REQUEST_URI'], ".class.php")) die("no access"); |
---|
8 | require_once($include_path."/templates/faq_question.tpl.php"); |
---|
9 | require_once($class_path."/faq_types.class.php"); |
---|
10 | require_once($class_path."/faq_themes.class.php"); |
---|
11 | |
---|
12 | class faq_questions { |
---|
13 | |
---|
14 | public static function get_list($filter = true,$id_theme=0, $id_type=0, $id_statut=0){ |
---|
15 | global $msg,$charset,$dbh; |
---|
16 | global $javascript_path; |
---|
17 | global $module,$categ,$sub; |
---|
18 | |
---|
19 | $query = "select * from faq_questions join faq_themes on faq_question_num_theme = id_theme join faq_types on faq_question_num_type = id_type"; |
---|
20 | $id_theme+=0; |
---|
21 | $id_type+=0; |
---|
22 | $list = $restrict = ""; |
---|
23 | |
---|
24 | |
---|
25 | if($filter){ |
---|
26 | $types = new faq_types("faq_types", "id_type", "libelle_type"); |
---|
27 | $themes = new faq_themes("faq_themes","id_theme","libelle_theme"); |
---|
28 | $list.=" |
---|
29 | <form class='form-".$module." name='faq_filter' action='./demandes.php' method='get'> |
---|
30 | <h3>".htmlentities($msg['faq_filter_form_title'],ENT_QUOTES,$charset)."</h3> |
---|
31 | <div class='form-contenu'> |
---|
32 | <input type='hidden' name='categ' value='".htmlentities($categ,ENT_QUOTES,$charset)."' /> |
---|
33 | <input type='hidden' name='sub' value='".htmlentities($sub,ENT_QUOTES,$charset)."' /> |
---|
34 | <div class='row'> |
---|
35 | <div class='colonne3'> |
---|
36 | <label for='faq_filter_type'>".htmlentities($msg['faq_question_theme_label'],ENT_QUOTES,$charset)."</label><br/> |
---|
37 | ".$themes->getListSelector($id_theme,"",true)." |
---|
38 | </div> |
---|
39 | <div class='colonne3'> |
---|
40 | <label for='faq_filter_type'>".htmlentities($msg['faq_question_type_label'],ENT_QUOTES,$charset)."</label><br/> |
---|
41 | ".$types->getListSelector($id_type,"",true)." |
---|
42 | </div> |
---|
43 | <div class='colonne_suite'> |
---|
44 | <label for='id_statut'>".$msg['faq_question_statut_label']."</label><br/> |
---|
45 | <select name='id_statut' > |
---|
46 | <option value='0'".($id_statut == 0 ? " selected='selected'" : "").">".$msg['faq_question_statut_visible_0']."</option> |
---|
47 | <option value='1'".($id_statut == 1 ? " selected='selected'" : "").">".$msg['faq_question_statut_visible_1']."</option> |
---|
48 | <option value='2'".($id_statut == 2 ? " selected='selected'" : "").">".$msg['faq_question_statut_visible_2']."</option> |
---|
49 | <option value='3'".($id_statut == 3 ? " selected='selected'" : "").">".$msg['faq_question_statut_visible_3']."</option> |
---|
50 | </select> |
---|
51 | </div> |
---|
52 | </div> |
---|
53 | <div class='row'></div> |
---|
54 | </div> |
---|
55 | <div class='row'> |
---|
56 | <div class='left'> |
---|
57 | <input type='submit' class='bouton' value='".htmlentities($msg['faq_filter_form_submit'],ENT_QUOTES,$charset)."'/> |
---|
58 | </div> |
---|
59 | </div> |
---|
60 | <div class='row'></div> |
---|
61 | </form>"; |
---|
62 | } |
---|
63 | $list.= " |
---|
64 | <script type='text/javascript' src='".$javascript_path."/sorttable.js'></script> |
---|
65 | <table class='sortable'> |
---|
66 | <tr> |
---|
67 | <th>".htmlentities($msg['faq_question_theme_label'],ENT_QUOTES,$charset)."</th> |
---|
68 | <th>".htmlentities($msg['faq_question_type_label'],ENT_QUOTES,$charset)."</th> |
---|
69 | <th>".htmlentities($msg['faq_question_statut'],ENT_QUOTES,$charset)."</th> |
---|
70 | <th>".htmlentities($msg['faq_question_question'],ENT_QUOTES,$charset)."</th> |
---|
71 | <th>".htmlentities($msg['faq_question_answer'],ENT_QUOTES,$charset)."</th> |
---|
72 | </tr>"; |
---|
73 | if($id_theme || $id_type || $id_statut){ |
---|
74 | if($id_type){ |
---|
75 | $restrict = "faq_question_num_type = ".$id_type; |
---|
76 | } |
---|
77 | if($id_theme){ |
---|
78 | if($restrict) $restrict.= " and "; |
---|
79 | $restrict.= "faq_question_num_theme = ".$id_theme; |
---|
80 | } |
---|
81 | if($id_statut){ |
---|
82 | if($restrict) $restrict.= " and "; |
---|
83 | $restrict.= "faq_question_statut = ".$id_statut; |
---|
84 | } |
---|
85 | } |
---|
86 | if($restrict){ |
---|
87 | $query.= " where ".$restrict; |
---|
88 | } |
---|
89 | $result = pmb_mysql_query($query,$dbh); |
---|
90 | if(pmb_mysql_num_rows($result)){ |
---|
91 | $i=0; |
---|
92 | while($row = pmb_mysql_fetch_object($result)){ |
---|
93 | //pour l'affichage dans la liste, on nettoie ! |
---|
94 | $question = strip_tags($row->faq_question_question); |
---|
95 | $question_title=""; |
---|
96 | if(strlen($question) > 200){ |
---|
97 | $question_title = $question; |
---|
98 | $question = substr($question,0,200)."[...]"; |
---|
99 | } |
---|
100 | $answer = strip_tags($row->faq_question_answer); |
---|
101 | $answer_title=""; |
---|
102 | if(strlen($answer) > 200){ |
---|
103 | $answer_title = $answer; |
---|
104 | $answer = substr($answer,0,200)."[...]"; |
---|
105 | } |
---|
106 | |
---|
107 | $list.=" |
---|
108 | <tr class='".($i%2 !=0 ? "even" : "odd")."' style='cursor:pointer;' onclick='document.location=\"./demandes.php?categ=faq&sub=question&action=edit&id=".$row->id_faq_question."\"'> |
---|
109 | <td>".htmlentities($row->libelle_theme,ENT_QUOTES,$charset)."</td> |
---|
110 | <td>".htmlentities($row->libelle_type,ENT_QUOTES,$charset)."</td> |
---|
111 | <td>".htmlentities($msg['faq_question_statut_visible_'.$row->faq_question_statut],ENT_QUOTES,$charset)."</td> |
---|
112 | <td ".($question_title ? "title='".htmlentities($question_title,ENT_QUOTES,$charset)."'" : "").">".htmlentities($question,ENT_QUOTES,$charset)."</td> |
---|
113 | <td ".($answer_title ? "title='".htmlentities($answer_title,ENT_QUOTES,$charset)."'" : "").">".htmlentities($answer,ENT_QUOTES,$charset)."</td> |
---|
114 | </tr>"; |
---|
115 | $i++; |
---|
116 | } |
---|
117 | }else{ |
---|
118 | $list.= " |
---|
119 | <tr> |
---|
120 | <td colspan='5'>".htmlentities($msg['faq_no_question'],ENT_QUOTES,$charset)."</td> |
---|
121 | </tr>"; |
---|
122 | } |
---|
123 | $list.=" |
---|
124 | </table> |
---|
125 | <div class='row'> |
---|
126 | <input type='button' class='bouton' onclick='document.location=\"./demandes.php?categ=faq&sub=question&action=new\"' value='".htmlentities($msg['faq_add_new_question'],ENT_QUOTES,$charset)."'/> |
---|
127 | </div>"; |
---|
128 | return $list; |
---|
129 | } |
---|
130 | } |
---|