Project

General

Profile

« Previous | Next » 

Revision 2033

Added by Dietmar almost 11 years ago

! /include/editarea/wb_wrapper_edit_area.php:: add init parameters as Array
! /modules/droplets/modify_droplet.php call edit_area with Array

View differences:

branches/2.8.x/CHANGELOG
11 11
! = Update/Change
12 12
===============================================================================
13 13

  
14
16 Dec-2013 Build 2033 Dietmar Woellbrink (Luisehahne)
15
! /include/editarea/wb_wrapper_edit_area.php:: add init parameters as Array
16
! /modules/droplets/modify_droplet.php call edit_area with Array
14 17
16 Dec-2013 Build 2032 Dietmar Woellbrink (Luisehahne)
15 18
! /modules/droplets/example/ update some droplets and remove the old ones
16 19
15 Dec-2013 Build 2031 Dietmar Woellbrink (Luisehahne)
branches/2.8.x/wb/include/editarea/wb_wrapper_edit_area.php
37 37
/*]]>*/
38 38
</script>
39 39

  
40
<?php
40
<?php }
41 41

  
42
if (!function_exists('getEditareaDefaultSettings')) {
43
    function getEditareaDefaultSettings() {
44
        
45
    /**
46
     * toolbar: define the toolbar that will be displayed, each element being separated by a ",".
47
     * Type: String (combinaison of: "|", "*", "search", "go_to_line", "undo", "redo", "change_smooth_selection", "reset_highlight", "highlight", "word_wrap", "help", "save", "load", "new_document", "syntax_selection")
48
     * "|" or "separator" make appears a separator in the toolbar.
49
     * "*" or "return" make appears a line-break in the toolbar
50
     * Default: "search, go_to_line, fullscreen, |, undo, redo, |, select_font,|, change_smooth_selection, highlight, reset_highlight, word_wrap, |, help"
51
     */
52
    
53
    return array (
54
    		'id' => "src"	// should contain the id of the textarea that should be converted into an editor
55
    		,'language' => "en"
56
    		,'syntax' => ""
57
    		,'start_highlight' => false	// if start with highlight
58
    		,'is_multi_files' => false		// enable the multi file mode (the textarea content is ignored)
59
    		,'min_width' => 400
60
    		,'min_height' => 125
61
    		,'allow_resize' => "y"	// possible values: "no", "both", "x", "y"
62
    		,'allow_toggle' => true		// true or false
63
    		,'plugins' => "" // comma separated plugin list
64
    		,'browsers' => "all"	// all or known
65
    		,'display' => "onload" 		// onload or later
66
    		,'toolbar' => "search, go_to_line, fullscreen, |, undo, redo, |, select_font,|, change_smooth_selection, highlight, reset_highlight, word_wrap, |, help"
67
    		,'begin_toolbar' => ""		//  "new_document, save, load, |"
68
    		,'end_toolbar' => ""		// or end_toolbar
69
    		,'font_size' => "10"		// not for IE
70
    		,'font_family' => "monospace, verdana"	// can be "verdana,monospace". Allow non monospace font but Firefox get smaller tabulation with non monospace fonts. IE doesn't change the tabulation width and Opera doesn't take this option into account... 
71
    		,'cursor_position' => "begin"
72
    		,'gecko_spellcheck' => false	// enable/disable by default the gecko_spellcheck
73
    		,'max_undo' => 30
74
    		,'fullscreen' => false
75
    		,'is_editable' => true
76
    		,'word_wrap' => false		// define if the text is wrapped of not in the textarea
77
    		,'replace_tab_by_spaces' => false
78
    		,'debug' => false		// used to display some debug information into a newly created textarea. Can be usefull to display trace info in it if you want to modify the code
79
    		,'show_line_colors' => false	// if the highlight is disabled for the line currently beeing edited (if enabled => heavy CPU use)
80
    		,'syntax_selection_allow' => "basic,brainfuck,c,coldfusion,cpp,css,html,java,js,pas,perl,php,python,ruby,robotstxt,sql,tsql,vb,xml"
81
    		,'smooth_selection' => true
82
    		,'autocompletion' => false	// NOT IMPLEMENTED			
83
    		,'load_callback' => ""		// click on load button (function name)
84
    		,'save_callback' => ""		// click on save button (function name)
85
    		,'change_callback' => ""	// textarea onchange trigger (function name)
86
    		,'submit_callback' => ""	// form submited (function name)
87
    		,'EA_init_callback' => ""	// EditArea initiliazed (function name)
88
    		,'EA_delete_callback' => ""	// EditArea deleted (function name)
89
    		,'EA_load_callback' => ""	// EditArea fully loaded and displayed (function name)
90
    		,'EA_unload_callback' => ""	// EditArea delete while being displayed (function name)
91
    		,'EA_toggle_on_callback' => ""	         // EditArea toggled on (function name)
92
    		,'EA_toggle_off_callback' => ""	        // EditArea toggled off (function name)
93
    		,'EA_file_switch_on_callback' => ""	    // a new tab is selected (called for the newly selected file)
94
    		,'EA_file_switch_off_callback' => ""	// a new tab is selected (called for the previously selected file)
95
    		,'EA_file_close_callback' => ""		    // close a tab
96
    	);
97
    }
42 98
}
43 99
if (!function_exists('registerEditArea')) {
44
	function registerEditArea(
45
                $id = 'code_area',
46
                $syntax = 'php',
47
                $syntax_selection = true,
48
                $allow_resize = 'both',
49
                $allow_toggle = true,
50
                $start_highlight = true,
51
                $min_width = 600,
52
                $min_height = 450,
53
                $toolbar = 'default'  )
54
	{
100
    
101
function registerEditArea( $initId = null 
102
            ,$syntax = "php"
103
            ,$syntax_selection = true
104
            ,$allow_resize = "both"
105
            ,$allow_toggle = true
106
            ,$start_highlight = true
107
            ,$min_width = 600
108
            ,$min_height = 450
109
            ,$toolbar = "default" 
110
            ) 
111
{                
55 112

  
113
$isArray = true;
114
if( is_array($initId) ){
115
//    $json = json_encode($sInitId, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_HEX_TAG);
116
    $aInitEditArea = getEditareaDefaultSettings();
117
    $aInitEditArea = array_merge($aInitEditArea,$initId);      
118
} else {
119
    $id = $initId;
120
    $aInitEditArea = getEditareaDefaultSettings();    
121
    $aInitEditArea['id'] = $initId;
122
    $aInitEditArea['syntax'] = $syntax;
123
    $aInitEditArea['syntax_selection_allow'] = $syntax_selection;
124
    $aInitEditArea['allow_resize'] = $allow_resize;
125
    $aInitEditArea['allow_toggle'] = $allow_toggle;
126
    $aInitEditArea['start_highlight'] = $start_highlight;
127
    $aInitEditArea['min_width'] = $min_width;
128
    $aInitEditArea['min_height'] = $min_height;
129
    $aInitEditArea['toolbar'] = $toolbar;
130
}
56 131
		// set default toolbar if no user defined was specified
57
		if ($toolbar == 'default') {
58
			$toolbar = 'search, fullscreen, |, undo, redo, |, select_font, syntax_selection, |, highlight, reset_highlight, |, help';
59
			$toolbar = (!$syntax_selection) ? str_replace('syntax_selection,', '', $toolbar) : $toolbar;
132
		if ($aInitEditArea['toolbar'] == 'default') {
133
			$aInitEditArea['toolbar'] = 'search, fullscreen, |, undo, redo, |, select_font, |, change_smooth_selection, highlight, reset_highlight, |, help';
134
//			$aInitEditArea['toolbar'] = (!$aInitEditArea['syntax_selection_allow']) ? str_replace('syntax_selection,', '', $aInitEditArea['toolbar']) : $aInitEditArea['toolbar'];
60 135
		}
61 136

  
62 137
		// check if used Website Baker backend language is supported by EditArea
63 138
		$language = 'en';
64
		if (defined('LANGUAGE') && file_exists(dirname(__FILE__) . '/langs/' . strtolower(LANGUAGE) . '.js'))
139

  
140
		if (defined('LANGUAGE') && is_readable(dirname(__FILE__).'/langs/'.strtolower(LANGUAGE).'.js'))
65 141
        {
66
			$language = strtolower(LANGUAGE);
142
			$aInitEditArea['language'] = strtolower(LANGUAGE);
67 143
		}
68 144

  
69 145
		// check if highlight syntax is supported by edit_area
70
		$syntax = in_array($syntax, array('css', 'html', 'js', 'php', 'xml')) ? $syntax : 'php';
146
		$aInitEditArea['syntax'] = in_array($aInitEditArea['syntax'], array('css', 'html', 'js', 'php', 'xml')) ? $aInitEditArea['syntax'] : 'basic';
71 147

  
72 148
		// check if resize option is supported by edit_area
73
		$allow_resize = in_array($allow_resize, array('no', 'both', 'x', 'y')) ? $allow_resize : 'no';
149
		$aInitEditArea['allow_resize'] = in_array($aInitEditArea['allow_resize'], array('no', 'both', 'x', 'y')) ? $aInitEditArea['allow_resize'] : 'no';
74 150

  
75 151
		if(!defined('LOADER_HELP')) {
76 152
			loader_help();
77 153
	        define('LOADER_HELP', true);
78 154
		}
79

  
155
        if(version_compare(PHP_VERSION, '5.3', '<'))
156
        {
157
            $json = json_encode($aInitEditArea);
158
        } else {
159
            $json = json_encode($aInitEditArea, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_HEX_TAG);
160
        }
80 161
		// return the Javascript code
81 162
		$result = <<< EOT
82 163
		<script type="text/javascript">
83
			editAreaLoader.init({
84
				id: 				'$id',
85
				start_highlight:	$start_highlight,
86
				syntax:			    '$syntax',
87
				min_width:			$min_width,
88
				min_height:		    $min_height,
89
				allow_resize: 		'$allow_resize',
90
				allow_toggle: 		'$allow_toggle',
91
				toolbar: 			'$toolbar',
92
				language:			'$language'
93
			});
164
			editAreaLoader.init( $json );
94 165
		</script>
95 166
EOT;
96 167
		return $result;
......
135 206
		return $syntax ;
136 207
	}
137 208
}
138

  
139
?>
branches/2.8.x/wb/admin/interface/version.php
51 51

  
52 52
// check if defined to avoid errors during installation (redirect to admin panel fails if PHP error/warnings are enabled)
53 53
if(!defined('VERSION')) define('VERSION', '2.8.3');
54
if(!defined('REVISION')) define('REVISION', '2032');
54
if(!defined('REVISION')) define('REVISION', '2033');
55 55
if(!defined('SP')) define('SP', '');
branches/2.8.x/wb/modules/droplets/modify_droplet.php
46 46
	}
47 47
}
48 48
require_once(WB_PATH . '/include/editarea/wb_wrapper_edit_area.php');
49
echo registerEditArea ('contentedit','php',true,'both',true,true,600,450,'search, fullscreen, |, undo, redo, |, select_font,|, highlight, reset_highlight, |, help');
50 49

  
50
/**
51
 * toolbar: define the toolbar that will be displayed, each element being separated by a ",".
52
 * Type: String (combinaison of: "|", "*", "search", "go_to_line", "undo", "redo", "change_smooth_selection", "reset_highlight", "highlight", "word_wrap", "help", "save", "load", "new_document", "syntax_selection")
53
 * "|" or "separator" make appears a separator in the toolbar.
54
 * "*" or "return" make appears a line-break in the toolbar
55
 * Default: "search, go_to_line, fullscreen, |, undo, redo, |, select_font,|, change_smooth_selection, highlight, reset_highlight, word_wrap, |, help"
56

  
57
$aDefaultSettings = array (
58
		'id' => "src"	// should contain the id of the textarea that should be converted into an editor
59
		,'language' => "en"
60
		,'syntax' => ""
61
		,'start_highlight' => false	// if start with highlight
62
		,'is_multi_files' => false		// enable the multi file mode (the textarea content is ignored)
63
		,'min_width' => 400
64
		,'min_height' => 125
65
		,'allow_resize' => "y"	// possible values: "no", "both", "x", "y"
66
		,'allow_toggle' => true		// true or false
67
		,'plugins' => "" // comma separated plugin list
68
		,'browsers' => "all"	// all or known
69
		,'display' => "onload" 		// onload or later
70
		,'toolbar' => "search, go_to_line, fullscreen, |, undo, redo, |, select_font,|, change_smooth_selection, highlight, reset_highlight, word_wrap, |, help"
71
		,'begin_toolbar' => ""		//  "new_document, save, load, |"
72
		,'end_toolbar' => ""		// or end_toolbar
73
		,'font_size' => "10"		// not for IE
74
		,'font_family' => "monospace"	// can be "verdana,monospace". Allow non monospace font but Firefox get smaller tabulation with non monospace fonts. IE doesn't change the tabulation width and Opera doesn't take this option into account... 
75
		,'cursor_position' => "begin"
76
		,'gecko_spellcheck' => false	// enable/disable by default the gecko_spellcheck
77
		,'max_undo' => 30
78
		,'fullscreen' => false
79
		,'is_editable' => true
80
		,'word_wrap' => false		// define if the text is wrapped of not in the textarea
81
		,'replace_tab_by_spaces' => false
82
		,'debug' => false		// used to display some debug information into a newly created textarea. Can be usefull to display trace info in it if you want to modify the code
83
		,'show_line_colors' => false	// if the highlight is disabled for the line currently beeing edited (if enabled => heavy CPU use)
84
		,'syntax_selection_allow' => "basic,brainfuck,c,coldfusion,cpp,css,html,java,js,pas,perl,php,python,ruby,robotstxt,sql,tsql,vb,xml"
85
		,'smooth_selection' => true
86
		,'autocompletion' => false	// NOT IMPLEMENTED			
87
		,'load_callback' => ""		// click on load button (function name)
88
		,'save_callback' => ""		// click on save button (function name)
89
		,'change_callback' => ""	// textarea onchange trigger (function name)
90
		,'submit_callback' => ""	// form submited (function name)
91
		,'EA_init_callback' => ""	// EditArea initiliazed (function name)
92
		,'EA_delete_callback' => ""	// EditArea deleted (function name)
93
		,'EA_load_callback' => ""	// EditArea fully loaded and displayed (function name)
94
		,'EA_unload_callback' => ""	// EditArea delete while being displayed (function name)
95
		,'EA_toggle_on_callback' => ""	         // EditArea toggled on (function name)
96
		,'EA_toggle_off_callback' => ""	        // EditArea toggled off (function name)
97
		,'EA_file_switch_on_callback' => ""	    // a new tab is selected (called for the newly selected file)
98
		,'EA_file_switch_off_callback' => ""	// a new tab is selected (called for the previously selected file)
99
		,'EA_file_close_callback' => ""		    // close a tab
100
	);
101
 */
102

  
103
/**
104
 * 
105
 */
106
$aInitEditArea = getEditareaDefaultSettings();
107
$aInitEditArea['id'] = 'contentedit';
108
$aInitEditArea['syntax'] = 'php';
109
$aInitEditArea['allow_resize'] = 'y';
110
$aInitEditArea['allow_toggle'] = true;
111
$aInitEditArea['start_highlight'] = true;
112
$aInitEditArea['min_width'] = 200;
113
$aInitEditArea['min_height'] = 250;
114
$aInitEditArea['toolbar'] = 'default';
115
$aInitEditArea['syntax_selection_allow'] = 'basic,php,css,html';
116
echo registerEditArea($aInitEditArea);
117

  
118
/**
119
 * 
120
echo registerEditArea ('contentedit'
121
                      ,'php'
122
                      ,'basic,php,css,html'
123
                      ,'y'
124
                      ,true
125
                      ,true
126
                      ,200
127
                      ,250
128
                      ,'default'
129
//                      ,'search, fullscreen, |, undo, redo, |, select_font,|, highlight, word_wrap, |, help'
130
);
131
 */
132

  
51 133
$modified_when = time();
52 134
$modified_by = ($admin->ami_group_member('1') ? 1 : $admin->get_user_id());
53 135
$sOverviewDroplets = $TEXT['LIST_OPTIONS'].' '.$DR_TEXT['DROPLETS'];
......
75 157
<input type="hidden" name="show_wysiwyg" value="<?php echo $fetch_content['show_wysiwyg']; ?>" />
76 158
<?php echo $admin->getFTAN(); ?>
77 159

  
78
<table class="row_a" cellpadding="4" cellspacing="0" border="0" width="100%">
160
<table class="row_a">
79 161
		<tr>
80 162
		<td width="10%" class="setting_name">
81 163
			<?php echo $TEXT['NAME']; ?>:
......
140 222
?>
141 223
	<tr>
142 224
		<td valign="top" class="setting_name" width="60px"><?php echo $TEXT['CODE']; ?>:</td>
143
		<td ><textarea name="savecontent" id ="contentedit" style="width: 98%; height: 450px;" rows="50" cols="120"><?php echo $content; ?></textarea>&nbsp;
225
		<td ><textarea name="savecontent" id ="contentedit" style="width: 98%; height: 450px;" rows="10" cols="12"><?php echo $content; ?></textarea>&nbsp;
144 226
		</td>
145 227
	</tr>
146 228
	<tr>

Also available in: Unified diff