Beispiel #1
0
<?php

// +-------------------------------------------------+
// © 2002-2004 PMB Services / www.sigb.net pmb@sigb.net et contributeurs (voir www.sigb.net)
// +-------------------------------------------------+
// $Id: theme.inc.php,v 1.1 2014-04-01 13:45:46 arenou Exp $
if (stristr($_SERVER['REQUEST_URI'], ".inc.php")) {
    die("no access");
}
require_once $class_path . "/faq_themes.class.php";
$faq_themes = new faq_themes("faq_themes", "id_theme", "libelle_theme", $id_liste);
$faq_themes->proceed($act);
 public function get_form($id_demande = 0, $action = "./demandes.php?categ=faq&sub=question")
 {
     global $faq_question_form;
     global $msg, $charset;
     global $pmb_javascript_office_editor;
     global $lang;
     global $faq_question_first_desc, $faq_question_other_desc;
     if ($pmb_javascript_office_editor) {
         print $pmb_javascript_office_editor;
     }
     if ($id_demande && !$this->id) {
         $query = "select date_demande,date_format(date_demande, '" . $msg["format_date"] . "') as aff_date_demande, sujet_demande, libelle_theme,libelle_type, reponse_finale from demandes d, demandes_theme dt, demandes_type dy where dy.id_type=d.type_demande and dt.id_theme=d.theme_demande and id_demande='" . $id_demande . "'";
         $result = pmb_mysql_query($query);
         if (pmb_mysql_num_rows($result)) {
             $row = pmb_mysql_fetch_object($result);
             $this->num_demande = $id_demande;
             $this->question = $row->sujet_demande;
             $this->answer = $row->reponse_finale;
             $this->question_userdate = formatdate($row->date_demande);
             $this->aff_date_demande = $row->aff_date_demande;
             //recherche du theme
             $query = " select id_theme from faq_themes where libelle_theme like '" . addslashes($row->libelle_theme) . "'";
             $result = pmb_mysql_query($query);
             if (pmb_mysql_num_rows($result)) {
                 $this->num_theme = pmb_mysql_result($result, 0, 0);
             }
             //recherche du type...
             $query = " select id_type from faq_types where libelle_type like '" . addslashes($row->libelle_type) . "'";
             $result = pmb_mysql_query($query);
             if (pmb_mysql_num_rows($result)) {
                 $this->num_type = pmb_mysql_result($result, 0, 0);
             }
         }
     }
     if (!$this->aff_date_demande) {
         $this->aff_date_demande = format_date(today());
     }
     if (!$this->aff_date_answer) {
         $this->aff_date_answer = format_date(today());
     }
     if ($this->id) {
         $suppression = "\n\t\t\t<script type='text/javascript'>\n\t\t\t\tfunction confirm_delete_question(id){\n\t\t\t\t\tresult = confirm(\"" . $msg['faq_question_confirm_suppression'] . "\");\n        \t\t\tif(result) document.location = './demandes.php?categ=faq&sub=question&id='+id+'&action=delete' ;\n\t\t\t\t}\t\t\n\t\t\t</script>\n\t\t\t<input type='button' class='bouton' value=' " . $msg[63] . " ' onclick='confirm_delete_question(\"" . $this->id . "\")' />";
         $form = str_replace("!!form_title!!", htmlentities($msg['faq_question_edit_form'], ENT_QUOTES, $charset), $faq_question_form);
         $form = str_replace("!!bouton_supprimer!!", $suppression, $form);
     } else {
         $form = str_replace("!!form_title!!", htmlentities($msg['faq_question_new_form'], ENT_QUOTES, $charset), $faq_question_form);
         $form = str_replace("!!bouton_supprimer!!", "", $form);
     }
     $form = str_replace("!!id!!", htmlentities($this->id, ENT_QUOTES, $charset), $form);
     $form = str_replace("!!num_demande!!", htmlentities($this->num_demande, ENT_QUOTES, $charset), $form);
     $form = str_replace("!!action!!", $action, $form);
     $types = new faq_types("faq_types", "id_type", "libelle_type");
     $form = str_replace("!!type_selector!!", $types->getListSelector($this->num_type), $form);
     $themes = new faq_themes("faq_themes", "id_theme", "libelle_theme");
     $form = str_replace("!!theme_selector!!", $themes->getListSelector($this->num_theme), $form);
     $statut = "\t\n\t\t<select name='faq_question_statut'>\n\t\t\t<option value='1'" . ($this->statut == 1 ? " selected='selected'" : "") . ">" . $msg['faq_question_statut_visible_1'] . "</option>\n\t\t\t<option value='2'" . ($this->statut == 2 ? " selected='selected'" : "") . ">" . $msg['faq_question_statut_visible_2'] . "</option>\n\t\t\t<option value='3'" . ($this->statut == 3 ? " selected='selected'" : "") . ">" . $msg['faq_question_statut_visible_3'] . "</option>\n\t\t</select>";
     $form = str_replace("!!statut_selector!!", $statut, $form);
     $form = str_replace("!!question!!", htmlentities(strip_tags($this->question), ENT_QUOTES, $charset), $form);
     $form = str_replace("!!question_date!!", htmlentities($this->aff_date_demande, ENT_QUOTES, $charset), $form);
     $form = str_replace("!!answer!!", htmlentities(strip_tags($this->answer), ENT_QUOTES, $charset), $form);
     $form = str_replace("!!answer_date!!", htmlentities($this->aff_date_answer, ENT_QUOTES, $charset), $form);
     //gestion des descripteurs
     $categs = "";
     if (count($this->descriptors)) {
         for ($i = 0; $i < count($this->descriptors); $i++) {
             if ($i == 0) {
                 $categ = $faq_question_first_desc;
             } else {
                 $categ = $faq_question_other_desc;
             }
             //on y va
             $categ = str_replace('!!icateg!!', $i, $categ);
             $categ = str_replace('!!categ_id!!', $this->descriptors[$i], $categ);
             $categorie = new categories($this->descriptors[$i], $lang);
             $categ = str_replace('!!categ_libelle!!', $categorie->libelle_categorie, $categ);
             $categs .= $categ;
         }
         $categs = str_replace("!!max_categ!!", count($this->descriptors), $categs);
     } else {
         $categs = $faq_question_first_desc;
         $categs = str_replace('!!icateg!!', 0, $categs);
         $categs = str_replace('!!categ_id!!', "", $categs);
         $categs = str_replace('!!categ_libelle!!', "", $categs);
         $categs = str_replace('!!max_categ!!', 1, $categs);
     }
     return str_replace("!!faq_question_categs!!", $categs, $form);
     return $form;
 }
Beispiel #3
0
 protected function get_actives_facettes()
 {
     global $dbh, $msg, $charset;
     $filter_actives = $facettes_filter = "";
     //thèmes
     if (count($this->themes)) {
         $themes = new faq_themes("faq_themes", "id_theme", "libelle_theme");
         foreach ($this->themes as $theme) {
             $facettes_filter .= "\n\t\t\t\t\t<input type='hidden' id='faq_filters_themes' name='faq_filters[themes][]' value='" . $theme . "' />";
             $link = "javascript:document.getElementById('faq_filters_themes').value='';document.faq_filters.faq_page.value=1;document.faq_filters.submit();";
             $filter_actives .= "\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td>" . htmlentities($msg['faq_filter_themes'] . ": " . $themes->getLabel($theme), ENT_QUOTES, $charset) . "</td>\n\t\t\t\t\t\t\t<td><a href=\"" . $link . "\"><img src='./images/cross.png'/></a></td>\n\t\t\t\t\t\t</tr>";
         }
     } else {
         $facettes_filter .= "\n\t\t\t\t\t<input type='hidden' id='faq_filters_themes' name='faq_filters[themes][]' value='' />";
     }
     //Types
     if (count($this->types)) {
         $types = new faq_themes("faq_types", "id_type", "libelle_type");
         foreach ($this->types as $type) {
             $facettes_filter .= "\n\t\t\t\t\t<input type='hidden' id='faq_filters_types' name='faq_filters[types][]' value='" . $type . "' />";
             $link = "javascript:document.getElementById('faq_filters_types').value='';document.faq_filters.faq_page.value=1;document.faq_filters.submit();";
             $filter_actives .= "\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td>" . htmlentities($msg['faq_filter_types'] . ": " . $types->getLabel($type), ENT_QUOTES, $charset) . "</td>\n\t\t\t\t\t\t\t<td><a href=\"" . $link . "\"><img src='./images/cross.png'/></a></td>\n\t\t\t\t\t\t</tr>";
         }
     } else {
         $facettes_filter .= "\n\t\t\t\t\t<input type='hidden' id='faq_filters_types' name='faq_filters[types][]' value='' />";
     }
     //descripteurs
     if (count($this->descriptors)) {
         foreach ($this->descriptors as $descriptor) {
             $facettes_filter .= "\n\t\t\t\t\t<input type='hidden' id='faq_filters_descriptors' name='faq_filters[descriptors][]' value='" . $descriptor . "' />";
             $link = "javascript:document.getElementById('faq_filters_descriptors').value='';document.faq_filters.faq_page.value=1;document.faq_filters.submit();";
             $filter_actives .= "\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td>" . htmlentities($msg['faq_filter_descriptors'] . ": " . $this->filters['descriptors'][$descriptor]['label'], ENT_QUOTES, $charset) . "</td>\n\t\t\t\t\t\t\t<td><a href=\"" . $link . "\"><img src='./images/cross.png'/></a></td>\n\t\t\t\t\t\t</tr>";
         }
     } else {
         $facettes_filter .= "\n\t\t\t\t\t<input type='hidden' id='faq_filters_descriptors' name='faq_filters[descriptors][]' value='' />";
     }
     if (count($this->years)) {
         foreach ($this->years as $year) {
             $facettes_filter .= "\n\t\t\t\t\t<input type='hidden' id='faq_filters_years' name='faq_filters[years][]' value='" . $year . "' />";
             $link = "javascript:document.getElementById('faq_filters_years').value='';document.faq_filters.faq_page.value=1;document.faq_filters.submit();";
             $filter_actives .= "\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td>" . htmlentities($msg['faq_filter_years'] . ": " . $this->filters['years'][$year]['label'], ENT_QUOTES, $charset) . "</td>\n\t\t\t\t\t\t\t<td><a href=\"" . $link . "\"><img src='./images/cross.png'/></a></td>\n\t\t\t\t\t\t</tr>";
         }
     } else {
         $facettes_filter .= "\n\t\t\t\t\t<input type='hidden' id='faq_filters_years' name='faq_filters[years][]' value='' />";
     }
     if ($filter_actives) {
         $facettes_filter .= "\n\t\t\t\t<div class='faq_filters_actives'>\n\t\t\t\t\t<h3>" . htmlentities($msg['faq_facettes_actives'], ENT_QUOTES, $charset) . "</h3>\n\t\t\t\t\t<table id='active_facette'>" . $filter_actives . "\n\t\t\t\t\t</table>\n\t\t\t\t</div>\n\t\t\t\t<div class='row'>&nbsp;</div>";
     }
     return $facettes_filter;
 }
 public static function get_list($filter = true, $id_theme = 0, $id_type = 0, $id_statut = 0)
 {
     global $msg, $charset, $dbh;
     global $javascript_path;
     global $module, $categ, $sub;
     $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";
     $id_theme += 0;
     $id_type += 0;
     $list = $restrict = "";
     if ($filter) {
         $types = new faq_types("faq_types", "id_type", "libelle_type");
         $themes = new faq_themes("faq_themes", "id_theme", "libelle_theme");
         $list .= "\n\t\t<form class='form-" . $module . " name='faq_filter' action='./demandes.php' method='get'>\n\t\t\t<h3>" . htmlentities($msg['faq_filter_form_title'], ENT_QUOTES, $charset) . "</h3>\n\t\t\t<div class='form-contenu'>\n\t\t\t\t<input type='hidden' name='categ' value='" . htmlentities($categ, ENT_QUOTES, $charset) . "' />\n\t\t\t\t<input type='hidden' name='sub' value='" . htmlentities($sub, ENT_QUOTES, $charset) . "' />\t\t\n\t\t\t\t<div class='row'>\n\t\t\t\t\t<div class='colonne3'>\n\t\t\t\t\t\t<label for='faq_filter_type'>" . htmlentities($msg['faq_question_theme_label'], ENT_QUOTES, $charset) . "</label><br/>\n\t\t\t\t\t\t" . $themes->getListSelector($id_theme, "", true) . "\n\t\t\t\t\t</div>\t\t\t\n\t\t\t\t\t<div class='colonne3'>\n\t\t\t\t\t\t<label for='faq_filter_type'>" . htmlentities($msg['faq_question_type_label'], ENT_QUOTES, $charset) . "</label><br/>\n\t\t\t\t\t\t" . $types->getListSelector($id_type, "", true) . "\n\t\t\t\t\t</div>\n\t\t\t\t\t<div class='colonne_suite'>\n\t\t\t\t\t\t<label for='id_statut'>" . $msg['faq_question_statut_label'] . "</label><br/>\n\t\t\t\t\t\t<select name='id_statut' >\n\t\t\t\t\t\t\t<option value='0'" . ($id_statut == 0 ? " selected='selected'" : "") . ">" . $msg['faq_question_statut_visible_0'] . "</option>\n\t\t\t\t\t\t\t<option value='1'" . ($id_statut == 1 ? " selected='selected'" : "") . ">" . $msg['faq_question_statut_visible_1'] . "</option>\n\t\t\t\t\t\t\t<option value='2'" . ($id_statut == 2 ? " selected='selected'" : "") . ">" . $msg['faq_question_statut_visible_2'] . "</option>\n\t\t\t\t\t\t\t<option value='3'" . ($id_statut == 3 ? " selected='selected'" : "") . ">" . $msg['faq_question_statut_visible_3'] . "</option>\n\t\t\t\t\t\t</select>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\t\n\t\t\t\t<div class='row'></div>\t\t\t\t\n\t\t\t</div>\n\t\t\t<div class='row'>\n\t\t\t\t<div class='left'>\n\t\t\t\t\t<input type='submit' class='bouton' value='" . htmlentities($msg['faq_filter_form_submit'], ENT_QUOTES, $charset) . "'/>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t\t<div class='row'></div>\n\t\t</form>";
     }
     $list .= "\n\t\t<script type='text/javascript' src='" . $javascript_path . "/sorttable.js'></script>\n\t\t<table class='sortable'>\t\n\t\t\t<tr>\n\t\t\t\t<th>" . htmlentities($msg['faq_question_theme_label'], ENT_QUOTES, $charset) . "</th>\n\t\t\t\t<th>" . htmlentities($msg['faq_question_type_label'], ENT_QUOTES, $charset) . "</th>\n\t\t\t\t<th>" . htmlentities($msg['faq_question_statut'], ENT_QUOTES, $charset) . "</th>\t\t\n\t\t\t\t<th>" . htmlentities($msg['faq_question_question'], ENT_QUOTES, $charset) . "</th>\n\t\t\t\t<th>" . htmlentities($msg['faq_question_answer'], ENT_QUOTES, $charset) . "</th>\n\t\t\t</tr>";
     if ($id_theme || $id_type || $id_statut) {
         if ($id_type) {
             $restrict = "faq_question_num_type = " . $id_type;
         }
         if ($id_theme) {
             if ($restrict) {
                 $restrict .= " and ";
             }
             $restrict .= "faq_question_num_theme = " . $id_theme;
         }
         if ($id_statut) {
             if ($restrict) {
                 $restrict .= " and ";
             }
             $restrict .= "faq_question_statut = " . $id_statut;
         }
     }
     if ($restrict) {
         $query .= " where " . $restrict;
     }
     $result = pmb_mysql_query($query, $dbh);
     if (pmb_mysql_num_rows($result)) {
         $i = 0;
         while ($row = pmb_mysql_fetch_object($result)) {
             //pour l'affichage dans la liste, on nettoie !
             $question = strip_tags($row->faq_question_question);
             $question_title = "";
             if (strlen($question) > 200) {
                 $question_title = $question;
                 $question = substr($question, 0, 200) . "[...]";
             }
             $answer = strip_tags($row->faq_question_answer);
             $answer_title = "";
             if (strlen($answer) > 200) {
                 $answer_title = $answer;
                 $answer = substr($answer, 0, 200) . "[...]";
             }
             $list .= "\n\t\t\t<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 . "\"'>\n\t\t\t\t<td>" . htmlentities($row->libelle_theme, ENT_QUOTES, $charset) . "</td>\n\t\t\t\t<td>" . htmlentities($row->libelle_type, ENT_QUOTES, $charset) . "</td>\n\t\t\t\t<td>" . htmlentities($msg['faq_question_statut_visible_' . $row->faq_question_statut], ENT_QUOTES, $charset) . "</td>\n\t\t\t\t<td " . ($question_title ? "title='" . htmlentities($question_title, ENT_QUOTES, $charset) . "'" : "") . ">" . htmlentities($question, ENT_QUOTES, $charset) . "</td>\n\t\t\t\t<td " . ($answer_title ? "title='" . htmlentities($answer_title, ENT_QUOTES, $charset) . "'" : "") . ">" . htmlentities($answer, ENT_QUOTES, $charset) . "</td>\n\t\t\t</tr>";
             $i++;
         }
     } else {
         $list .= "\n\t\t\t<tr>\n\t\t\t\t<td colspan='5'>" . htmlentities($msg['faq_no_question'], ENT_QUOTES, $charset) . "</td>\n\t\t\t</tr>";
     }
     $list .= "\n\t\t</table>\n\t\t<div class='row'>\n\t\t\t<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) . "'/>\n\t\t</div>";
     return $list;
 }