コード例 #1
0
 function toHtml()
 {
     if ($this->_hiddenLabel) {
         $this->_generateId();
         return '<label class="accesshide" for="' . $this->getAttribute('id') . '" >' . $this->getLabel() . '</label>' . parent::toHtml();
     } else {
         return parent::toHtml();
     }
 }
コード例 #2
0
 /**
  * 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('&nbsp;');\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;
     }
 }
コード例 #3
0
 /**
  * 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('&nbsp;');\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;
     }
 }
コード例 #4
0
ファイル: tinymce.php プロジェクト: ksecor/civicrm
    /**
     * 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;
        }
    }
コード例 #5
0
ファイル: tinymce.php プロジェクト: kidaa30/yes
    /**
     * 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;
        }
    }
コード例 #6
0
ファイル: textarea.php プロジェクト: gabrielrosset/moodle
 /**
  * Returns HTML for this form element.
  *
  * @return string
  */
 function toHtml()
 {
     // Add the class at the last minute.
     if ($this->get_force_ltr()) {
         if (!isset($this->_attributes['class'])) {
             $this->_attributes['class'] = 'text-ltr';
         } else {
             $this->_attributes['class'] .= ' text-ltr';
         }
     }
     if ($this->_hiddenLabel) {
         $this->_generateId();
         return '<label class="accesshide" for="' . $this->getAttribute('id') . '" >' . $this->getLabel() . '</label>' . parent::toHtml();
     } else {
         return parent::toHtml();
     }
 }
コード例 #7
0
ファイル: form.php プロジェクト: nonfiction/nterchange
 function toHtml()
 {
     if (isset($this->_editor)) {
         if ($this->_flagFrozen) {
             return $this->getFrozenHtml();
         } else {
             return $this->_getTabs() . $this->_editor->CreateHtml();
         }
     } else {
         return parent::toHtml();
     }
 }
コード例 #8
0
ファイル: htmlarea.php プロジェクト: minger11/Pipeline
    /**
     * 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();
            }
        }
    }