Exemplo n.º 1
0
     echo $helpdesk->getNameRegexType($question_option['type']);
     //si il y a un controle sur le champ
     if ($question_option['type'] != 1) {
         //remplissage de la liste pour effectuer la vérification si le champ est non caché et obligatoire à la fois
         $question_option = json_decode($question_value['option'], true);
         $question_option_value = urldecode($question_option['value']);
         $listequestion .= "sec_" . $section_id . "::" . $question_id . "::" . $question_option_value . "::" . $question_value['name'] . "&&";
     }
 }
 if ($question_value['type'] == "7" || $question_value['type'] == "11") {
     //initialisation d'une variable pour savoir s'il y a un champ de multiplication de champ pour implémenter un champ total somme
     $boolMultiplication = 1;
 }
 if ($question_value['type'] == "8" || $question_value['type'] == "9" || $question_value['type'] == "4") {
     // section dynamique et question dynamique obligatoire
     $tab = PluginFormcreatorQuestion::_unserialize($question_value['data']);
     if (isset($tab["obli"]) && $tab["obli"] == "1") {
         $listequestion .= "sec_" . $section_id . "::" . $question_id . "::" . $question_value['name'] . "&&";
     }
 }
 $chaine = $question_value['content'];
 //remplacement lien url en BBCODE
 $chaine = preg_replace("#\\[url\\]((ht|f)tp://)([^\r\n\t<\"]*?)\\[/url\\]#sie", "'<a href=\"\\1' . str_replace(' ', '%20', '\\3') . '\">\\1\\3</a>'", $chaine);
 $chaine = preg_replace("/\\[url=(.+?)\\](.+?)\\[\\/url\\]/", "<a href=\"\$1\">\$2</a>", $chaine);
 //remplacement gras en BBCODE
 $chaine = str_replace("[b]", "<b>", $chaine);
 $chaine = str_replace("[/b]", "</b>", $chaine);
 //remplacement italique en BBCODE
 $chaine = str_replace("[i]", "<em>", $chaine);
 $chaine = str_replace("[/i]", "</em>", $chaine);
 //remplacement souligne en BBCODE
Exemplo n.º 2
0
 function getInputQuestion($id, $type, $data, $option)
 {
     global $LANG;
     $tab = PluginFormcreatorQuestion::_unserialize($data);
     $question_option = json_decode($option, true);
     $question_option_type = $question_option['type'];
     $question_option_regex = urldecode($question_option['value']);
     switch ($type) {
         case PluginFormcreatorQuestion::TEXT_FIELD:
             // Text
             switch ($question_option['type']) {
                 case 1:
                     echo '<input type="text" id="question_' . $id . '" name="question_' . $id . '" value="' . $tab['value'] . '" size="40"/>';
                     break;
                 case 2:
                     echo '<input type="text" id="question_' . $id . '" name="question_' . $id . '" value="' . $tab['value'] . '" size="40" onBlur="verifTextNum(this);"/>';
                     break;
                 case 3:
                     echo '<input type="text" id="question_' . $id . '" name="question_' . $id . '" value="' . $tab['value'] . '" size="40" onBlur="verifText(this);"/>';
                     break;
                 case 4:
                     echo '<input type="text" id="question_' . $id . '" name="question_' . $id . '" value="' . $tab['value'] . '" size="40" onBlur="verifNum(this);"/>';
                     break;
                 case 5:
                     echo '<input type="text" id="question_' . $id . '" name="question_' . $id . '" value="' . $tab['value'] . '" size="40" onBlur="verifRegex(this,' . $question_option_regex . ');"/>';
                     break;
                 case 6:
                     echo '<input type="text" id="question_' . $id . '" name="question_' . $id . '" value="' . $tab['value'] . '" size="40" onBlur="verifMail(this);"/>';
                     break;
                 case 7:
                     echo '<table class="ds_box" cellpadding="0" cellspacing="0" id="ds_conclass" style="display: none;"><tr><td id="ds_calclass"></td></tr></table>';
                     echo '<input type="text" size="9" id="question_' . $id . '" name="question_' . $id . '" value="' . $tab['value'] . '" readonly="readonly" size="40" onfocus="ds_sh(this);"/>';
                     break;
             }
             break;
         case PluginFormcreatorQuestion::SELECT_FIELD:
             // Select
             echo '<select name="question_' . $id . '">';
             foreach ($tab['value'] as $value_id => $value) {
                 echo '<option value="' . $value . '">' . $value . '</option>';
             }
             echo '</select>';
             break;
         case PluginFormcreatorQuestion::CHECKBOX_FIELD:
             // Checkbox
             foreach ($tab['value'] as $value_id => $value) {
                 echo '<input type="checkbox" name="question_' . $id . '[]" 
                                          value="' . $value . '"/>&nbsp;' . $value . '<br />';
             }
             break;
         case PluginFormcreatorQuestion::TEXTAREA_FIELD:
             // Textarea
             echo '<textarea id="question_' . $id . '" name="question_' . $id . '" cols="50" rows="8">' . $tab['value'] . '</textarea>';
             break;
         case PluginFormcreatorQuestion::UPLOAD_FIELD:
             // Upload
             echo '<input type="file" name="question_' . $id . '" />&nbsp;' . self::getMaxUploadSize();
             break;
         case PluginFormcreatorQuestion::VALIDATION_FIELD:
             // Validation
             echo '<table>';
             echo '<tr>';
             echo '<td>';
             echo __('Approver');
             echo "&nbsp;:</td><td>";
             User::dropdown(array('name' => 'users_id_validate_' . $id, 'entity' => $_SESSION["glpiactive_entity"], 'right' => 'validate_ticket'));
             echo '</td></tr>';
             echo '<tr>';
             echo '<td>';
             echo __('Request comment');
             echo '&nbsp;:</td>';
             echo '<td><textarea name="question_' . $id . '" cols="50" rows="8">' . $tab['value'] . '</textarea></td></tr>';
             echo '</table>';
             break;
         case PluginFormcreatorQuestion::MULTIPLICATION_ITEM_FIELD:
             // 2 textfields sum
             echo '<input type="text" name="question1_' . $id . '" size="5" onKeyUp="multiplication(question1_' . $id . ', question2_' . $id . ', somme_' . $id . ', question3_' . $id . ', ' . $id . ');"/>&nbsp;';
             echo '<select name="question2_' . $id . '" onchange="multiplication(question1_' . $id . ', question2_' . $id . ', somme_' . $id . ', question3_' . $id . ', ' . $id . ');">';
             echo '<option value=""></option>';
             foreach ($tab['value'] as $value_id => $value) {
                 $typeMat = $tab["typeMat"][$value_id];
                 echo '<option value="' . $value . '">' . $typeMat . '</option>';
             }
             echo '</select>';
             echo '<input type=hidden name="question3_' . $id . '">';
             echo '&nbsp;<input type="text" id="somme_' . $id . '" name="somme_' . $id . '" size="5" readonly/>&#8364;';
             break;
         case PluginFormcreatorQuestion::DYNAMIC_FIELD:
             // Select question dynamic
             foreach ($tab['value'] as $value_id => $value) {
                 $listing .= self::creationTabDyna($tab['question'][$value_id]);
                 if ($listing != "") {
                     $listing .= ":";
                 }
             }
             while ($listing[strlen($listing) - 1] == ":") {
                 $listing = substr($listing, 0, -1);
             }
             echo '<select id="question_' . $id . '" name="question_' . $id . '" onchange="choixSelectDyna(this.options[this.selectedIndex].value);">';
             foreach ($tab['value'] as $value_id => $value) {
                 $tableau = self::creationTabDyna($tab['question'][$value_id]);
                 if ($tableau != "") {
                     $tableau = "&&" . $tableau;
                 }
                 echo "<option id='dynaQuestion_" . $id . "_" . $value_id . "' value='" . $value . "&&" . $listing . $tableau . "'>" . $value . "</option>";
             }
             echo '</select>';
             break;
         case PluginFormcreatorQuestion::DYNAMIC_SECTION:
             // Select section dynamic
             $listing = "";
             foreach ($tab['value'] as $value_id => $value) {
                 if (isset($tab['section'][$value_id])) {
                     $listing .= self::creationTabDyna($tab['section'][$value_id]);
                     if ($listing != "") {
                         $listing .= ":";
                     }
                 }
             }
             if (strlen($listing) > 0) {
                 while ($listing[strlen($listing) - 1] == ":") {
                     $listing = substr($listing, 0, -1);
                 }
             }
             echo '<select id="question_' . $id . '" name="question_' . $id . '" onchange="choixSelectDyna(this.options[this.selectedIndex].value);">';
             foreach ($tab['value'] as $value_id => $value) {
                 if (isset($tab['section'][$value_id]) && $tab['section'][$value_id] != "") {
                     $tableau = self::creationTabDyna($tab['section'][$value_id]);
                     $tableau = "&&" . $tableau;
                 } else {
                     $tableau = "";
                 }
                 echo "<option id='dynaQuestion_" . $id . "_" . $value_id . "' value='" . $value . "&&" . $listing . $tableau . "'>" . $value . "</option>";
             }
             echo '</select>';
             break;
         case PluginFormcreatorQuestion::ITEM:
             // item listing
             echo '<select name="question_' . $id . '">';
             $retour = self::getTabItem($tab['value']);
             foreach ($retour as $key => $value) {
                 echo '<option value="' . $value["name"] . '">' . $value["name"] . '</option>';
             }
             echo '</select>';
             break;
     }
 }