/** textelong() - Ajoute un élément de type texte long (textarea) au formulaire * * @param mixed L'objet QuickForm du formulaire * @param mixed Le tableau des valeurs des différentes option pour l'élément texte long * @param string Type d'action pour le formulaire : saisie, modification, vue,... saisie par défaut * @return void */ function textelong(&$formtemplate, $tableau_template, $mode, $valeurs_fiche) { list($type, $identifiant, $label, $nb_colonnes, $nb_lignes, $valeur_par_defaut, $longueurmax, $formatage, $obligatoire, $apparait_recherche, $bulle_d_aide) = $tableau_template; if (empty($formatage) || $formatage == 'wiki') { $formatage = 'wiki-textarea'; } elseif ($formatage == 'html') { $langpref = strtolower($GLOBALS['prefered_language']) . '-' . strtoupper($GLOBALS['prefered_language']); $langfile = 'tools/bazar/libs/vendor/summernote/lang/summernote-' . $langpref . '.js'; $GLOBALS['wiki']->AddJavascriptFile('tools/bazar/libs/vendor/summernote/summernote.min.js'); $GLOBALS['wiki']->AddJavascriptFile('tools/bazar/libs/vendor/summernote/plugin/summernote-ext-fontstyle.js'); $GLOBALS['wiki']->AddJavascriptFile('tools/bazar/libs/vendor/summernote/plugin/summernote-ext-well.js'); if (file_exists($langfile)) { $GLOBALS['wiki']->AddJavascriptFile($langfile); $langoptions = 'lang: "' . $langpref . '",'; } else { $langoptions = ''; } $script = '$(document).ready(function() { $(".summernote").summernote({ ' . $langoptions . ' height: 300, // set editor height minHeight: 300, // set minimum height of editor maxHeight: 550, // set maximum height of editor focus: false, // set focus to editable area after initializing summernote toolbar: [ //[groupname, [button list]] [\'style\', [\'style\', \'textboxwell\']], [\'textstyle\', [\'bold\', \'italic\', \'underline\', \'strikethrough\', \'clear\']], [\'color\', [\'color\']], [\'para\', [\'ul\', \'ol\', \'paragraph\']], [\'insert\', [\'hr\', \'link\', \'table\']], [\'misc\', [\'fullscreen\'/*, \'codeview\'*/]] ], oninit: function() { $(\'button[data-original-title=Style]\').prepend("Style").find("i").remove(); } }); });'; $GLOBALS['wiki']->AddJavascript($script); } if ($mode == 'saisie') { $longueurmaxlabel = $longueurmax ? ' (<span class="charsRemaining">' . $longueurmax . '</span> caractères restants)' : ''; $bulledaide = ''; if ($bulle_d_aide != '') { $bulledaide = ' <img class="tooltip_aide" title="' . htmlentities($bulle_d_aide, ENT_QUOTES, TEMPLATES_DEFAULT_CHARSET) . '" src="tools/bazar/presentation/images/aide.png" width="16" height="16" alt="image aide" />'; } $options = array('id' => $identifiant, 'class' => 'form-control input-xxlarge ' . ($formatage == 'html' ? 'summernote' : $formatage)); if ($longueurmax != '') { $options['maxlength'] = $longueurmax; } //gestion du champs obligatoire $symb = ''; if (isset($obligatoire) && $obligatoire == 1) { $options['required'] = 'required'; $symb .= '<span class="symbole_obligatoire">* </span>'; } $formtexte = new HTML_QuickForm_textarea($identifiant, $symb . $label . $longueurmaxlabel . $bulledaide, $options); $formtexte->setCols($nb_colonnes); $formtexte->setRows($nb_lignes); $formtemplate->addElement($formtexte); //gestion des valeurs par defaut : d'abord on regarde s'il y a une valeur a modifier, //puis s'il y a une variable passee en GET, //enfin on prend la valeur par defaut du formulaire sinon if (isset($valeurs_fiche[$identifiant])) { $defauts = array($identifiant => $valeurs_fiche[$identifiant]); } elseif (isset($_GET[$identifiant])) { $defauts = array($identifiant => stripslashes($_GET[$identifiant])); } else { $defauts = array($identifiant => stripslashes($tableau_template[5])); } $formtemplate->setDefaults($defauts); } elseif ($mode == 'requete') { // En html, pour la sécurité, on n'autorise qu'un certain nombre de balises if ($formatage == 'html') { $acceptedtags = '<h1><h2><h3><h4><h5><h6><hr><hr/><br><br/><span><blockquote><i><u><b><strong><ol><ul><li><small><div><p><a><table><tr><th><td><img><figure><caption>'; $valeurs_fiche[$identifiant] = strip_tags($valeurs_fiche[$identifiant], $acceptedtags); } return array($identifiant => $valeurs_fiche[$identifiant]); } elseif ($mode == 'html') { $html = ''; if (isset($valeurs_fiche[$identifiant]) && $valeurs_fiche[$identifiant] != '') { $html = '<div class="BAZ_rubrique" data-id="' . $identifiant . '">' . "\n" . '<span class="BAZ_label">' . $label . ' :</span>' . "\n"; $html .= '<span class="BAZ_texte"> '; if ($formatage == 'wiki-textarea') { $containsattach = strpos($valeurs_fiche[$identifiant], '{{attach') !== false; if ($containsattach) { $oldpage = $GLOBALS['wiki']->GetPageTag(); $oldpagearray = $GLOBALS['wiki']->page; $GLOBALS['wiki']->tag = $valeurs_fiche['id_fiche']; $GLOBALS['wiki']->page = $GLOBALS['wiki']->LoadPage($GLOBALS['wiki']->tag); } $html .= $GLOBALS['wiki']->Format($valeurs_fiche[$identifiant]); if ($containsattach) { $GLOBALS['wiki']->tag = $oldpage; $GLOBALS['wiki']->page = $oldpagearray; } } elseif ($formatage == 'nohtml') { $html .= htmlentities($valeurs_fiche[$identifiant], ENT_QUOTES, TEMPLATES_DEFAULT_CHARSET); } elseif ($formatage == 'html') { $html .= $valeurs_fiche[$identifiant]; } $html .= '</span>' . "\n" . '</div> <!-- /.BAZ_rubrique -->' . "\n"; } return $html; } }