]> git.andy128k.dev Git - ipf.git/commitdiff
add force_absolute_urls option to html widget
authorAndrey Kutejko <andy128k@gmail.com>
Mon, 30 Dec 2013 08:47:46 +0000 (10:47 +0200)
committerAndrey Kutejko <andy128k@gmail.com>
Mon, 30 Dec 2013 08:47:46 +0000 (10:47 +0200)
ipf/form/widget/htmlinput.php

index b8b26ec210c7d83e74553c2760a83baab2f44e63..5ca2f7c6d9f94478af48b3cfa3a838431ca0ee30 100644 (file)
@@ -5,12 +5,13 @@ class IPF_Form_Widget_HTMLInput extends IPF_Form_Widget
     public $mode = 'textareas';
     public $theme = 'simple';
     public $include_tinymce = true;
+    public $force_absolute_urls = false;
 
     public function __construct($attrs=array())
     {
         $defaults = array('cols' => '70',
                           'rows' => '20');
-        $config = array('tinymce_url', 'mode', 'theme', 'include_tinymce');
+        $config = array('tinymce_url', 'mode', 'theme', 'include_tinymce', 'force_absolute_urls');
         foreach ($config as $cfg) {
             if (isset($attrs[$cfg])) {
                 $this->$cfg = $attrs[$cfg];
@@ -44,7 +45,7 @@ class IPF_Form_Widget_HTMLInput extends IPF_Form_Widget
             }
         }
         $final_attrs = $this->buildAttrs(array('name' => $name), $extra_attrs);
-        return new IPF_Template_SafeString('<textarea'.IPF_Form_Widget_Attrs($final_attrs).' class="htmlEditor">'.htmlspecialchars($value, ENT_COMPAT, 'UTF-8').'</textarea>', true);
+        return new IPF_Template_SafeString('<textarea'.IPF_Form_Widget_Attrs($final_attrs).' class="htmlEditor'.($this->force_absolute_urls ? 'Abs' : '').'">'.htmlspecialchars($value, ENT_COMPAT, 'UTF-8').'</textarea>', true);
     }
 
     public function extra_js()
@@ -68,7 +69,8 @@ function ipf_filebrowser(field_name, url, type, win) {
   });
   return false;
 }
-tinyMCE.init({
+(function(){
+var defaults = {
   theme_advanced_buttons1: "bold, italic, underline, separator, undo, redo, separator, bullist, numlist, outdent, indent, separator, justifyleft, justifycenter, justifyright, justifyfull, separator, link, unlink, forecolor, backcolor, sub, sup, separator, preview",
   theme_advanced_buttons2: "code, fullscreen, image, charmap, separator, pastetext, pasteword, selectall, removeformat, separator, formatselect, fontselect, fontsizeselect",
   theme_advanced_buttons3: "tablecontrols",
@@ -76,9 +78,7 @@ tinyMCE.init({
   theme_advanced_toolbar_align: "left",
   extended_valid_elements: "span[class|style],code[class],iframe[src|width|height|name|align|frameborder|scrolling]",
   mode: "specific_textareas",
-  editor_selector: "htmlEditor",
   theme: "advanced",
-  convert_urls: "false",
   plugins: "inlinepopups, charmap, paste, table, fullscreen, preview, print, advlink, advimage",
   button_tile_map: true,
   fix_list_elements: true,
@@ -87,11 +87,22 @@ tinyMCE.init({
   dialog_type: "modal",
   width: "80%",
   height: "350",
-  relative_urls: false,
-  remove_script_host: true,
   content_css: "/media/tiny_mce/themes/advanced/skins/default/content.css",
   file_browser_callback: "ipf_filebrowser"
-});
+};
+tinyMCE.init($.extend({}, defaults, {
+  editor_selector: "htmlEditor",
+  convert_urls: false,
+  relative_urls: false,
+  remove_script_host: true
+}));
+tinyMCE.init($.extend({}, defaults, {
+  editor_selector: "htmlEditorAbs",
+  convert_urls: true,
+  relative_urls: false,
+  remove_script_host: false
+}));
+})();
 </script>',
         );
     }