/** * Called by HTML_QuickForm whenever form event is made on this element * * @param string $event Name of event * @param mixed $arg event arguments * @param object $caller calling object * @since 1.0 * @access public * @return void */ function onQuickFormEvent($event, $arg, &$caller) { switch ($event) { case 'createElement': $this->_formid = $caller->getAttribute('id'); break; } return parent::onQuickFormEvent($event, $arg, $caller); }
/** * Add js to to convert normal textarea to ckeditor * * @access public * @return string */ function toHtml() { if ($this->_flagFrozen) { return $this->getFrozenHtml(); } else { $elementId = $this->getAttribute('id'); $html = parent::toHtml() . "<script type='text/javascript'>\n cj( function( ) {\n cj('#{$elementId}').removeClass();\n if ( CKEDITOR.instances['{$elementId}'] ) {\n CKEDITOR.remove(CKEDITOR.instances['{$elementId}']);\n }\n if ( cj('#{$elementId}').val( ) == '' ) cj('#{$elementId}').val(' ');\n CKEDITOR.replace( '{$elementId}' );\n var editor = CKEDITOR.instances['{$elementId}'];\n if ( editor ) {\n editor.on( 'key', function( evt ){\n global_formNavigate = false;\n } );\n editor.config.width = '" . $this->width . "';\n editor.config.height = '" . $this->height . "';\n }\n }); \n </script>"; return $html; } }
/** * Add js to to convert normal textarea to ckeditor * * @access public * @return string */ function toHtml() { if ($this->_flagFrozen) { return $this->getFrozenHtml(); } else { $elementId = $this->getAttribute('id'); $config = CRM_Core_Config::singleton(); $browseUrl = $config->userFrameworkResourceURL . 'packages/kcfinder/browse.php'; $uploadUrl = $config->userFrameworkResourceURL . 'packages/kcfinder/upload.php'; $html = parent::toHtml() . "<script type='text/javascript'>\n cj( function( ) {\n cj('#{$elementId}').removeClass();\n if ( CKEDITOR.instances['{$elementId}'] ) {\n CKEDITOR.remove(CKEDITOR.instances['{$elementId}']);\n }\n if ( cj('#{$elementId}').val( ) == '' ) cj('#{$elementId}').val(' ');\n CKEDITOR.replace( '{$elementId}' );\n var editor = CKEDITOR.instances['{$elementId}'];\n if ( editor ) {\n editor.on( 'key', function( evt ){\n global_formNavigate = false;\n } );\n editor.config.width = '" . $this->width . "';\n editor.config.height = '" . $this->height . "';\n editor.config.filebrowserBrowseUrl = '" . $browseUrl . "?cms=civicrm&type=files';\n editor.config.filebrowserImageBrowseUrl = '" . $browseUrl . "?cms=civicrm&type=images';\n editor.config.filebrowserFlashBrowseUrl = '" . $browseUrl . "?cms=civicrm&type=flash';\n editor.config.filebrowserUploadUrl = '" . $uploadUrl . "?cms=civicrm&type=files';\n editor.config.filebrowserImageUploadUrl = '" . $uploadUrl . "?cms=civicrm&type=images';\n editor.config.filebrowserFlashUploadUrl = '" . $uploadUrl . "?cms=civicrm&type=flash';\n }\n }); \n </script>"; return $html; } }
/** * Class Constructor * @param string $name * @param string $elementLabel HTML editor label * @param array $attributes Attributes for the textarea * @param array $config Optional configuration settings for the online editor. * */ public function __construct($name = null, $elementLabel = null, $attributes = [], $config = []) { if (empty($name)) { return false; } parent::__construct($name, $elementLabel, $attributes); $this->_persistantFreeze = true; $this->_type = 'html_editor'; $editor = Container::getHtmlEditor(); if ($editor) { $this->editor = $editor; $this->editor->setName($name); $this->editor->processConfig($config); } }
/** * Called by HTML_QuickForm whenever form event is made on this element * * @param string $event Name of event * @param mixed $arg event arguments * @param object &$caller calling object * @since 1.0 * @access public * @return void */ function onQuickFormEvent($event, $arg, &$caller) { switch ($event) { case 'updateValue': civicrm_drupal_wysiwyg_update_value($this, $caller); break; case 'addElement': $format = $arg[0] . '_format'; $this->format = $caller->get($format); if (!$this->format) { $this->format = variable_get('civicrm_wysiwyg_input_format', defined('FILTER_FORMAT_DEFAULT') ? FILTER_FORMAT_DEFAULT : null); } $caller->set($format, $this->format); parent::onQuickFormEvent($event, $arg, $caller); break; default: parent::onQuickFormEvent($event, $arg, $caller); } return true; }
/** 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; } }
/** * Sets value for textarea element * * @param string $value Value for textarea element * @since 1.0 * @access public * @return void */ static function setValue($value) { self::$_value = $value; }
/** * Build this element using FCKeditor */ function build_FCKeditor() { if (!FCKeditor::IsCompatible()) { return parent::toHTML(); } $this->fck_editor->Value = $this->getValue(); $result = $this->fck_editor->CreateHtml(); if (isset($this->fck_editor->Config['LoadAsciiMath'])) { if (isset($_SESSION['ascii_math_loaded']) && $_SESSION['ascii_math_loaded'] == false) { $result .= $this->fck_editor->Config['LoadAsciiMath']; $_SESSION['ascii_math_loaded'] = true; } } //Add a link to open the allowed html tags window //$result .= '<small><a href="#" onclick="MyWindow=window.open('."'".api_get_path(WEB_CODE_PATH)."help/allowed_html_tags.php?fullpage=". ($this->fullPage ? '1' : '0')."','MyWindow','toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=500,height=600,left=200,top=20'".'); return false;">'.get_lang('AllowedHTMLTags').'</a></small>'; return $result; }
/** * Return the htmlarea in HTML * * @access public * @return string */ function toHtml() { $html = null; // return frozen state if ($this->_flagFrozen) { return $this->getFrozenHtml(); // return textarea if incompatible } elseif (!$this->IsCompatible()) { return parent::toHtml(); // return textarea } else { //FIX for multiple editors in a form, initialize once (CRM-3559) if (!defined('HTML_QUICKFORM_TINYMCEEDITOR_LOADED')) { // load tinyMCEeditor $config = CRM_Core_Config::singleton(); // tinymce is wierd, it needs to be loaded initially along with jquery $html = null; $html .= sprintf('<script type="text/javascript"> cj( function( ) { cj("textarea.tinymce").tinymce({ theme : "advanced", editor_selector : "form-TinyMCE", plugins : "safari,spellchecker,layer,table,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,pagebreak", theme_advanced_buttons1 : "separator,bold,italic,underline,|,fontselect,fontsizeselect", theme_advanced_buttons1_add: "separator,forecolor,backcolor,separator,link,unlink,separator,image,hr,emotions", theme_advanced_buttons2 : "separator,numlist,bullist,|,outdent,indent,cite,separator,justifyleft,justifycenter,justifyright", theme_advanced_buttons2_add: "justifyfull,separator,pastetext,pasteword,|,spellchecker,separator,removeformat,separator,code,|,fullscreen,help", theme_advanced_buttons3 : "", theme_advanced_toolbar_location : "top", theme_advanced_toolbar_align : "left", theme_advanced_statusbar_location : "bottom", theme_advanced_resize_horizontal : false, theme_advanced_resizing : true, apply_source_formatting : true, spellchecker_languages : "+English=en,Danish=da,Dutch=nl,Finnish=fi,French=fr,German=de,Italian=it,Polish=pl,Portuguese=pt,Spanish=es,Swedish=sv", convert_urls : false, remove_script_host : false, width : "' . $this->Width . '%", setup : function(ed) { ed.onInit.addToTop( function(){ var height = cj("#" + ed.editorId).attr("height"); cj("#" + ed.editorId + "_tbl").css("height", height); cj("#" + ed.editorId + "_ifr").css("height", height); }); ed.onChange.add(function(ed, l) { global_formNavigate = false; }); } }); }); </script>'); define('HTML_QUICKFORM_TINYMCEEDITOR_LOADED', true); } // include textarea as well (TinyMCE transforms it) $html .= parent::toHTML(); $html .= sprintf('<script type="text/javascript"> cj("#' . $this->_attributes['id'] . '").attr( "height","' . $this->Height . 'px"); </script>'); return $html; } }
/** * Return the htmlarea in HTML * * @access public * @return string */ function toHtml() { $html = null; // return frozen state if ($this->_flagFrozen) { return $this->getFrozenHtml(); // return textarea if incompatible } elseif (!$this->IsCompatible()) { return parent::toHtml(); // return textarea } else { // load tinyMCEeditor $config = CRM_Core_Config::singleton(); $browseUrl = $config->userFrameworkResourceURL . 'packages/kcfinder/browse.php?opener=tinymce&cms=civicrm&type='; // tinymce is wierd, it needs to be loaded initially along with jquery $html = null; $click = $this->getAttribute('click_wysiwyg'); if ($click) { $html .= '<div id="' . $this->_attributes['id'] . '-plain" class="replace-plain" tabindex="0" title="' . ts('Click to edit') . '"><span class="icon ui-icon-pencil"></span>' . $this->getFrozenHtml() . '</div>'; } $html .= parent::toHtml(); $html .= sprintf('<script type="text/javascript"> var configArray = [{ theme : "advanced", editor_selector : "form-TinyMCE", plugins : "safari,spellchecker,layer,table,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,pagebreak", theme_advanced_buttons1 : "separator,bold,italic,underline,|,fontselect,fontsizeselect", theme_advanced_buttons1_add: "separator,forecolor,backcolor,separator,link,unlink,separator,image,hr,emotions", theme_advanced_buttons2 : "separator,numlist,bullist,|,outdent,indent,cite,separator,justifyleft,justifycenter,justifyright", theme_advanced_buttons2_add: "justifyfull,separator,pastetext,pasteword,|,spellchecker,separator,removeformat,separator,|,undo,redo,|,code,|,fullscreen,help", theme_advanced_buttons3 : "", theme_advanced_toolbar_location : "top", theme_advanced_toolbar_align : "left", theme_advanced_statusbar_location : "bottom", theme_advanced_resize_horizontal : false, theme_advanced_resizing : true, apply_source_formatting : true, spellchecker_languages : "+English=en,Danish=da,Dutch=nl,Finnish=fi,French=fr,German=de,Italian=it,Polish=pl,Portuguese=pt,Spanish=es,Swedish=sv", convert_urls : false, remove_script_host : false, width : "' . $this->Width . '%", file_browser_callback: "openKCFinder", setup : function(ed) { ed.onInit.addToTop( function(){ var height = cj("#" + ed.editorId).attr("height"); cj("#" + ed.editorId + "_tbl").css("height", height); cj("#" + ed.editorId + "_ifr").css("height", height); }); }' . $this->getConfigString() . ' }]; tinyMCE.settings = configArray[0];'); if ($click) { $html .= sprintf(' CRM.$(function($) { $("#' . $this->_attributes['id'] . '").hide(); var openWysiwyg = function() { $("#' . $this->_attributes['id'] . '-plain").remove(); $("#' . $this->_attributes['id'] . '").show(); //remove the control if element is already having tinyMCE.execCommand("mceRemoveControl", false,"' . $this->_attributes['id'] . '"); tinyMCE.execCommand("mceAddControl" , true, "' . $this->_attributes['id'] . '"); } $("#' . $this->_attributes['id'] . '-plain").click(openWysiwyg); $("#' . $this->_attributes['id'] . '-plain").keypress(openWysiwyg); }); '); } else { $html .= sprintf(' //remove the control if element is already having tinyMCE.execCommand("mceRemoveControl", false,"' . $this->_attributes['id'] . '"); tinyMCE.execCommand("mceAddControl" , true, "' . $this->_attributes['id'] . '"); '); } $html .= sprintf(' function openKCFinder(field_name, url, type, win) { tinyMCE.activeEditor.windowManager.open({ file: "' . $browseUrl . '" + type, title: "KCFinder", width: 700, height: 500, resizable: "yes", inline: true, close_previous: "no", popup_css: false }, { window: win, input: field_name }); return false; } </script>'); $html .= sprintf('<script type="text/javascript"> cj("#' . $this->_attributes['id'] . '").attr( "height","' . $this->Height . 'px"); </script>'); return $html; } }
/** * Class constructor * * @param string $elementName Input field name attribute * @param mixed $elementLabel Label(s) for a field * @param mixed $attributes Either a typical HTML attribute string or an associative array * @access public * @since 1.0 */ function HTML_QuickForm_wikiarea($elementName = null, $elementLabel = null, $attributes = null) { HTML_QuickForm_textarea::HTML_QuickForm_textarea($elementName, $elementLabel, $attributes); }
function toHtml() { if (isset($this->_editor)) { if ($this->_flagFrozen) { return $this->getFrozenHtml(); } else { return $this->_getTabs() . $this->_editor->CreateHtml(); } } else { return parent::toHtml(); } }
/** * Returns the textarea element in HTML * * @since 1.0 * @access public * @return string */ function toHtml() { if ($this->_flagFrozen) { return $this->getFrozenHtml(); } else { switch (strtolower($this->editorName)) { case 'nicedit': ob_start(); if (!defined('HTML_QuickForm_htmlarea_nicEdit_loaded')) { define('HTML_QuickForm_htmlarea_nicEdit_loaded', 1); echo '<script language="javascript" type="text/javascript" src="' . DATAFACE_URL . '/js/nicEdit/nicEdit.js"></script>'; } echo '<script language="javascript"> //<![CDATA[ bkLib.onDomLoaded(function(){ new nicEditor({fullPanel: true, iconsPath: \'' . DATAFACE_URL . '/js/nicEdit/nicEditorIcons.gif\'}).panelInstance(\'' . $this->getAttribute('id') . '\'); }); //]]></script>'; $html = ob_get_contents(); ob_end_clean(); return $html . "\n" . parent::toHtml(); case 'fckeditor': require_once 'FCKeditor/fckeditor.php'; $editor = new FCKEditor($this->getName()); $editor->BasePath = $GLOBALS['HTML_QuickForm_htmlarea']['FCKeditor_BasePath']; $editor->Value = $this->_value; $editor->Width = '100%'; $editor->Height = '480'; ob_start(); $editor->Create(); $html = ob_get_contents(); ob_end_clean(); return $html; case 'tinymce': ob_start(); if (!defined('HTML_QuickForm_htmlarea_TinyMCE_loaded')) { define('HTML_QuickForm_htmlarea_TinyMCE_loaded', true); echo '<script language="javascript" type="text/javascript" src="' . $GLOBALS['HTML_QuickForm_htmlarea']['TinyMCE_BasePath'] . '/tiny_mce.js"></script>'; } echo ' <script language="javascript" type="text/javascript"> tinyMCE.init({ editor_selector : "mceEditor", mode : "exact", elements : "' . $this->getAttribute('id') . '"'; foreach ($this->wysiwygOptions as $key => $value) { echo ', ' . $key . ' : "' . $value . '"'; } echo ' }); </script> '; $out = ob_get_contents(); ob_end_clean(); // now we can just call textarea's tohtml method. return $out . parent::toHtml(); } } }