3 * This software is governed by the CeCILL-B license. If a copy of this license
4 * is not distributed with this file, you can obtain one at
5 * http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt
7 * Authors of STUdS (initial project): Guilhem BORGHESI (borghesi@unistra.fr) and Raphaël DROZ
8 * Authors of Framadate/OpenSondate: Framasoft (https://github.com/framasoft)
10 * =============================
12 * Ce logiciel est régi par la licence CeCILL-B. Si une copie de cette licence
13 * ne se trouve pas avec ce fichier vous pouvez l'obtenir sur
14 * http://www.cecill.info/licences/Licence_CeCILL-B_V1-fr.txt
16 * Auteurs de STUdS (projet initial) : Guilhem BORGHESI (borghesi@unistra.fr) et Raphaël DROZ
17 * Auteurs de Framadate/OpenSondage : Framasoft (https://github.com/framasoft)
22 include_once('creation_sondage.php');
24 if (file_exists('bandeaux_local.php')) {
25 include_once('bandeaux_local.php');
27 include_once('bandeaux.php');
30 // Step 1/3 : error if $_SESSION from info_sondage are not valid
31 if (Utils
::issetAndNoEmpty('titre', $_SESSION) === false || Utils
::issetAndNoEmpty('nom', $_SESSION) === false ||
(($config['use_smtp']) ? Utils
::issetAndNoEmpty('adresse', $_SESSION) === false : false)) {
33 Utils
::print_header ( _("Error!") );
34 bandeau_titre(_("Error!"));
37 <div class="alert alert-danger">
38 <h3>' . _("You haven't filled the first section of the poll creation.") . ' !</h3>
39 <p>' . _("Back to the homepage of ") . ' <a href="' . Utils
::get_server_name() . '"> ' . NOMAPPLICATION
. '</a></p>
45 // Step 4 : Data prepare before insert in DB
46 if (isset($_POST["confirmecreation"])) {
47 //recuperation des données de champs textes
49 if (isset($_SESSION['choices'])) {
50 for ($i = 0; $i < count($_SESSION['choices']); $i++
) {
51 if ($_SESSION['choices'][$i]!="") {
52 $temp_results.=','.str_replace(",", " ", htmlentities(html_entity_decode($_SESSION['choices'][$i], ENT_QUOTES
, 'UTF-8'), ENT_QUOTES
, 'UTF-8'));
57 $temp_results=substr($temp_results,1);
58 $_SESSION["toutchoix"]=$temp_results;
61 if (Utils
::issetAndNoEmpty('champdatefin')) {
62 $registredate = explode("/",$_POST["champdatefin"]);
63 if (is_array($registredate) == true && count($registredate) == 3) {
64 $time = mktime(0,0,0,$registredate[1],$registredate[0],$registredate[2]);
65 if ($time > time() +
(24*60*60)) {
66 $_SESSION["champdatefin"]=$time;
71 //format du sondage AUTRE
72 $_SESSION["formatsondage"]="A".$_SESSION["studsplus"];
78 // recuperation des sujets pour sondage AUTRE
79 if (isset($_POST['choices'])) {
81 for ($i = 0; $i < count($_POST['choices']); $i++
) {
82 if (Utils
::issetAndNoEmpty($i, $_POST['choices'])) {
83 $_SESSION['choices'][$k]=htmlentities(html_entity_decode($_POST['choices'][$i], ENT_QUOTES
, 'UTF-8'), ENT_QUOTES
, 'UTF-8');
89 // Step 3/3 : Confirm poll creation and choose a removal date
90 if (isset($_POST["fin_sondage_autre"])) {
91 Utils
::print_header ( _("Removal date and confirmation (3 on 3)") );
92 bandeau_titre(_("Removal date and confirmation (3 on 3)"));
94 // Expiration date is initialised with config parameter. Value will be modified in step 4 if user has defined an other date
95 $_SESSION["champdatefin"]= time()+
(86400 * $config['default_poll_duration']); //60 sec * 60 min * 24 hours * config
97 $removal_date= utf8_encode(strftime($date_format['txt_full'], ($_SESSION["champdatefin"])));//textual date
101 for ($i=0;$i<count($_SESSION['choices']);$i++
) {
103 preg_match_all('/\[!\[(.*?)\]\((.*?)\)\]\((.*?)\)/',$_SESSION['choices'][$i],$md_a_img); // Markdown [![alt](src)](href)
104 preg_match_all('/!\[(.*?)\]\((.*?)\)/',$_SESSION['choices'][$i],$md_img); // Markdown ![alt](src)
105 preg_match_all('/\[(.*?)\]\((.*?)\)/',$_SESSION['choices'][$i],$md_a); // Markdown [text](href)
106 if (isset($md_a_img[2][0]) && $md_a_img[2][0]!='' && isset($md_a_img[3][0]) && $md_a_img[3][0]!='') { // [![alt](src)](href)
108 $li_subject_text = (isset($md_a_img[1][0]) && $md_a_img[1][0]!='') ?
stripslashes($md_a_img[1][0]) : _("Choice") .' '.($i+
1);
109 $li_subject_html = '<a href="'.$md_a_img[3][0].'"><img src="'.$md_a_img[2][0].'" class="img-responsive" alt="'.$li_subject_text.'" /></a>';
111 } elseif (isset($md_img[2][0]) && $md_img[2][0]!='') { // ![alt](src)
113 $li_subject_text = (isset($md_img[1][0]) && $md_img[1][0]!='') ?
stripslashes($md_img[1][0]) : _("Choice") .' '.($i+
1);
114 $li_subject_html = '<img src="'.$md_img[2][0].'" class="img-responsive" alt="'.$li_subject_text.'" />';
116 } elseif (isset($md_a[2][0]) && $md_a[2][0]!='') { // [text](href)
118 $li_subject_text = (isset($md_a[1][0]) && $md_a[1][0]!='') ?
stripslashes($md_a[1][0]) : _("Choice") .' '.($i+
1);
119 $li_subject_html = '<a href="'.$md_a[2][0].'">'.$li_subject_text.'</a>';
121 } else { // text only
123 $li_subject_text = stripslashes($_SESSION['choices'][$i]);
124 $li_subject_html = $li_subject_text;
128 $summary .= '<li>'.$li_subject_html.'</li>'."\n";
133 <form name="formulaire" action="' . Utils
::get_server_name() . 'choix_autre.php" method="POST" class="form-horizontal" role="form">
135 <div class="col-md-8 col-md-offset-2">
136 <div class="well summary">
137 <h4>'. _("List of your choices").'</h4>
140 <div class="alert alert-info">
141 <p>' . _("Your poll will be automatically removed after"). " " . $config['default_poll_duration'] . " " . _("days") . ': <strong>'.$removal_date.'</strong>.<br />' . _("You can fix another removal date for it.") .'</p>
142 <div class="form-group">
143 <label for="champdatefin" class="col-sm-5 control-label">'. _("Removal date (optional)") .'</label>
144 <div class="col-sm-6">
145 <div class="input-group date">
146 <span class="input-group-addon"><i class="glyphicon glyphicon-calendar text-info"></i></span>
147 <input type="text" class="form-control" id="champdatefin" data-date-format="'. _("dd/mm/yyyy") .'" aria-describedby="dateformat" name="champdatefin" value="" size="10" maxlength="10" placeholder="'. _("dd/mm/yyyy") .'" />
150 <span id="dateformat" class="sr-only">'. _("(dd/mm/yyyy)") .'</span>
153 <div class="alert alert-warning">
154 <p>'. _("Once you have confirmed the creation of your poll, you will be automatically redirected on the administration page of your poll."). '</p>';
155 if($config['use_smtp']==true){
157 <p>' . _("Then, you will receive quickly two emails: one contening the link of your poll for sending it to the voters, the other contening the link to the administration page of your poll.") .'</p>';
161 <p class="text-right">
162 <button class="btn btn-default" onclick="javascript:window.history.back();" title="'. _('Back to step 2') . '">'. _('Back') . '</button>
163 <button name="confirmecreation" value="confirmecreation" type="submit" class="btn btn-success">'. _('Create the poll') . '</button>
171 // Step 2/3 : Select choices of the poll
173 Utils
::print_header( _("Poll subjects (2 on 3)"));
174 bandeau_titre(_("Poll subjects (2 on 3)"));
177 <form name="formulaire" action="' . Utils
::get_server_name() . 'choix_autre.php" method="POST" class="form-horizontal" role="form">
179 <div class="col-md-8 col-md-offset-2">';
181 <div class="alert alert-info">
182 <p>'. _("To make a generic poll, it's better to propose at least two choices between differents subjects.") .'</p>
183 <p>'. _("You can add or remove additional choices with the buttons") .' <span class="glyphicon glyphicon-minus text-info"></span><span class="sr-only">'. _("Remove") .'</span> <span class="glyphicon glyphicon-plus text-success"></span><span class="sr-only">'. _("Add") .'</span></p>';
184 if($config['user_can_add_img_or_link']){
185 echo ' <p>'. _("It's possible to propose links or images by using "). '<a href="http://'.$lang.'.wikipedia.org/wiki/Markdown">'. _("the Markdown syntax") .'</a>.</p>';
189 // Fields choices : 5 by default
190 $nb_choices = (isset($_SESSION['choices'])) ?
max(count($_SESSION['choices']), 5) : 5;
191 for ($i = 0; $i < $nb_choices; $i++
) {
192 $choice_value = (isset($_SESSION['choices'][$i])) ?
str_replace("\\","",$_SESSION['choices'][$i]) : '';
194 <div class="form-group choice-field">
195 <label for="choice'.$i.'" class="col-sm-2 control-label">'. _("Choice") .' '.($i+
1).'</label>
196 <div class="col-sm-10 input-group">
197 <input type="text" class="form-control" name="choices[]" size="40" value="'.$choice_value.'" id="choice'.$i.'" />';
198 if($config['user_can_add_img_or_link']){
199 echo '<span class="input-group-addon btn-link md-a-img" title="'. _("Add a link or an image") .' - '. _("Choice") .' '.($i+
1).'" ><span class="glyphicon glyphicon-picture"></span> <span class="glyphicon glyphicon-link"></span></span>';
207 <div class="col-md-4">
208 <div class="btn-group btn-group">
209 <button type="button" id="remove-a-choice" class="btn btn-default" title="'. _("Remove a choice") .'"><span class="glyphicon glyphicon-minus text-info"></span><span class="sr-only">'. _("Remove") .'</span></button>
210 <button type="button" id="add-a-choice" class="btn btn-default" title="'. _("Add a choice") .'"><span class="glyphicon glyphicon-plus text-success"></span><span class="sr-only">'. _("Add") .'</span></button>
213 <div class="col-md-8 text-right">
214 <a class="btn btn-default" href="'.Utils
::get_server_name().'infos_sondage.php?choix_sondage=autre" title="'. _('Back to step 1') . '">'. _('Back') . '</a>
215 <button name="fin_sondage_autre" value="'._('Next').'" type="submit" class="btn btn-success disabled" title="'. _('Go to step 3') . '">'. _('Next') . '</button>
219 <div class="modal fade" id="md-a-imgModal" tabindex="-1" role="dialog" aria-labelledby="md-a-imgModalLabel" aria-hidden="true">
220 <div class="modal-dialog">
221 <div class="modal-content">
222 <div class="modal-header">
223 <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">'. _('Close') . '</span></button>
224 <p class="modal-title" id="md-a-imgModalLabel">'. _("Add a link or an image") .'</p>
226 <div class="modal-body">
227 <p class="alert alert-info">'. _("These fields are optional. You can add a link, an image or both.") .'</p>
228 <div class="form-group">
229 <label for="md-img"><span class="glyphicon glyphicon-picture"></span> '. _('URL of the image') . '</label>
230 <input id="md-img" type="text" placeholder="http://…" class="form-control" size="40" />
232 <div class="form-group">
233 <label for="md-a"><span class="glyphicon glyphicon-link"></span> '. _('Link') . '</label>
234 <input id="md-a" type="text" placeholder="http://…" class="form-control" size="40" />
236 <div class="form-group">
237 <label for="md-text">'. _('Alternative text') . '</label>
238 <input id="md-text" type="text" class="form-control" size="40" />
241 <div class="modal-footer">
242 <button type="button" class="btn btn-default" data-dismiss="modal">'. _('Cancel') . '</button>
243 <button type="button" class="btn btn-primary">'. _('Add') . '</button>