@@ -1,8 +1,8 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | - $column_width = (int)(80/count($columns)); |
|
3 | + $column_width = (int)(80/count($columns)); |
|
4 | 4 | |
5 | - if(!empty($list)){ |
|
5 | + if(!empty($list)){ |
|
6 | 6 | ?><div class="bDiv" > |
7 | 7 | <table cellspacing="0" cellpadding="0" border="0" id="flex1" class="sortable"> |
8 | 8 | <thead> |
@@ -47,19 +47,19 @@ discard block |
||
47 | 47 | <a href='<?php echo $row->read_url?>' title='<?php echo $this->l('list_view')?> <?php echo $subject?>' class="edit_button"><span class='read-icon'></span></a> |
48 | 48 | <?php }?> |
49 | 49 | <?php |
50 | - if(!empty($row->action_urls)){ |
|
51 | - foreach($row->action_urls as $action_unique_id => $action_url){ |
|
52 | - $action = $actions[$action_unique_id]; |
|
53 | - ?> |
|
50 | + if(!empty($row->action_urls)){ |
|
51 | + foreach($row->action_urls as $action_unique_id => $action_url){ |
|
52 | + $action = $actions[$action_unique_id]; |
|
53 | + ?> |
|
54 | 54 | <a href="<?php echo $action_url; ?>" class="<?php echo $action->css_class; ?> crud-action" title="<?php echo $action->label?>"><?php |
55 | - if(!empty($action->image_url)) |
|
56 | - { |
|
57 | - ?><img src="<?php echo $action->image_url; ?>" alt="<?php echo $action->label?>" /><?php |
|
58 | - } |
|
59 | - ?></a> |
|
55 | + if(!empty($action->image_url)) |
|
56 | + { |
|
57 | + ?><img src="<?php echo $action->image_url; ?>" alt="<?php echo $action->label?>" /><?php |
|
58 | + } |
|
59 | + ?></a> |
|
60 | 60 | <?php } |
61 | - } |
|
62 | - ?> |
|
61 | + } |
|
62 | + ?> |
|
63 | 63 | <div class='clear'></div> |
64 | 64 | </div> |
65 | 65 | </td> |
@@ -1,21 +1,21 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | - $column_width = (int)(80/count($columns)); |
|
3 | + $column_width = (int) (80 / count($columns)); |
|
4 | 4 | |
5 | - if(!empty($list)){ |
|
5 | + if (!empty($list)) { |
|
6 | 6 | ?><div class="bDiv" > |
7 | 7 | <table cellspacing="0" cellpadding="0" border="0" id="flex1" class="sortable"> |
8 | 8 | <thead> |
9 | 9 | <tr class='hDiv'> |
10 | - <?php foreach($columns as $column){?> |
|
10 | + <?php foreach ($columns as $column) {?> |
|
11 | 11 | <th width='<?php echo $column_width?>%'> |
12 | - <div class="text-left field-sorting <?php if(isset($order_by[0]) && $column->field_name == $order_by[0]){?><?php echo $order_by[1]?><?php }?>" |
|
12 | + <div class="text-left field-sorting <?php if (isset($order_by[0]) && $column->field_name == $order_by[0]) {?><?php echo $order_by[1]?><?php }?>" |
|
13 | 13 | rel='<?php echo $column->field_name?>'> |
14 | 14 | <?php echo $column->display_as?> |
15 | 15 | </div> |
16 | 16 | </th> |
17 | 17 | <?php }?> |
18 | - <?php if(!$unset_delete || !$unset_edit || !$unset_read || !empty($actions)){?> |
|
18 | + <?php if (!$unset_delete || !$unset_edit || !$unset_read || !empty($actions)) {?> |
|
19 | 19 | <th align="left" abbr="tools" axis="col1" class="" width='20%'> |
20 | 20 | <div class="text-right"> |
21 | 21 | <?php echo $this->l('list_actions'); ?> |
@@ -25,34 +25,34 @@ discard block |
||
25 | 25 | </tr> |
26 | 26 | </thead> |
27 | 27 | <tbody> |
28 | -<?php foreach($list as $num_row => $row){ ?> |
|
29 | - <tr <?php if($num_row % 2 == 1){?>class="erow"<?php }?>> |
|
30 | - <?php foreach($columns as $column){?> |
|
31 | - <td width='<?php echo $column_width?>%' class='<?php if(isset($order_by[0]) && $column->field_name == $order_by[0]){?>sorted<?php }?>'> |
|
32 | - <div class='text-left'><?php echo $row->{$column->field_name} != '' ? $row->{$column->field_name} : ' ' ; ?></div> |
|
28 | +<?php foreach ($list as $num_row => $row) { ?> |
|
29 | + <tr <?php if ($num_row % 2 == 1) {?>class="erow"<?php }?>> |
|
30 | + <?php foreach ($columns as $column) {?> |
|
31 | + <td width='<?php echo $column_width?>%' class='<?php if (isset($order_by[0]) && $column->field_name == $order_by[0]) {?>sorted<?php }?>'> |
|
32 | + <div class='text-left'><?php echo $row->{$column->field_name} != '' ? $row->{$column->field_name} : ' '; ?></div> |
|
33 | 33 | </td> |
34 | 34 | <?php }?> |
35 | - <?php if(!$unset_delete || !$unset_edit || !$unset_read || !empty($actions)){?> |
|
35 | + <?php if (!$unset_delete || !$unset_edit || !$unset_read || !empty($actions)) {?> |
|
36 | 36 | <td align="left" width='20%'> |
37 | 37 | <div class='tools'> |
38 | - <?php if(!$unset_delete){?> |
|
38 | + <?php if (!$unset_delete) {?> |
|
39 | 39 | <a href='<?php echo $row->delete_url?>' title='<?php echo $this->l('list_delete')?> <?php echo $subject?>' class="delete-row" > |
40 | 40 | <span class='delete-icon'></span> |
41 | 41 | </a> |
42 | 42 | <?php }?> |
43 | - <?php if(!$unset_edit){?> |
|
43 | + <?php if (!$unset_edit) {?> |
|
44 | 44 | <a href='<?php echo $row->edit_url?>' title='<?php echo $this->l('list_edit')?> <?php echo $subject?>' class="edit_button"><span class='edit-icon'></span></a> |
45 | 45 | <?php }?> |
46 | - <?php if(!$unset_read){?> |
|
46 | + <?php if (!$unset_read) {?> |
|
47 | 47 | <a href='<?php echo $row->read_url?>' title='<?php echo $this->l('list_view')?> <?php echo $subject?>' class="edit_button"><span class='read-icon'></span></a> |
48 | 48 | <?php }?> |
49 | 49 | <?php |
50 | - if(!empty($row->action_urls)){ |
|
51 | - foreach($row->action_urls as $action_unique_id => $action_url){ |
|
50 | + if (!empty($row->action_urls)) { |
|
51 | + foreach ($row->action_urls as $action_unique_id => $action_url) { |
|
52 | 52 | $action = $actions[$action_unique_id]; |
53 | 53 | ?> |
54 | 54 | <a href="<?php echo $action_url; ?>" class="<?php echo $action->css_class; ?> crud-action" title="<?php echo $action->label?>"><?php |
55 | - if(!empty($action->image_url)) |
|
55 | + if (!empty($action->image_url)) |
|
56 | 56 | { |
57 | 57 | ?><img src="<?php echo $action->image_url; ?>" alt="<?php echo $action->label?>" /><?php |
58 | 58 | } |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | </tbody> |
70 | 70 | </table> |
71 | 71 | </div> |
72 | -<?php }else{?> |
|
72 | +<?php } else {?> |
|
73 | 73 | <br/> |
74 | 74 | <?php echo $this->l('list_no_items'); ?> |
75 | 75 | <br/> |
@@ -69,7 +69,7 @@ |
||
69 | 69 | </tbody> |
70 | 70 | </table> |
71 | 71 | </div> |
72 | -<?php }else{?> |
|
72 | +<?php } else{?> |
|
73 | 73 | <br/> |
74 | 74 | <?php echo $this->l('list_no_items'); ?> |
75 | 75 | <br/> |
@@ -1,30 +1,30 @@ discard block |
||
1 | 1 | <?php |
2 | - $this->set_css($this->default_theme_path.'/dashboard/css/style.css'); |
|
3 | - $this->set_js_lib($this->default_javascript_path.'/'.grocery_CRUD::JQUERY); |
|
2 | + $this->set_css($this->default_theme_path.'/dashboard/css/style.css'); |
|
3 | + $this->set_js_lib($this->default_javascript_path.'/'.grocery_CRUD::JQUERY); |
|
4 | 4 | |
5 | - $this->set_js_lib($this->default_javascript_path.'/jquery_plugins/jquery.noty.js'); |
|
6 | - $this->set_js_lib($this->default_javascript_path.'/jquery_plugins/config/jquery.noty.config.js'); |
|
7 | - $this->set_js_lib($this->default_javascript_path.'/common/lazyload-min.js'); |
|
5 | + $this->set_js_lib($this->default_javascript_path.'/jquery_plugins/jquery.noty.js'); |
|
6 | + $this->set_js_lib($this->default_javascript_path.'/jquery_plugins/config/jquery.noty.config.js'); |
|
7 | + $this->set_js_lib($this->default_javascript_path.'/common/lazyload-min.js'); |
|
8 | 8 | |
9 | - if (!$this->is_IE7()) { |
|
10 | - $this->set_js_lib($this->default_javascript_path.'/common/list.js'); |
|
11 | - } |
|
9 | + if (!$this->is_IE7()) { |
|
10 | + $this->set_js_lib($this->default_javascript_path.'/common/list.js'); |
|
11 | + } |
|
12 | 12 | |
13 | - $this->set_js($this->default_theme_path.'/flexigrid/js/cookies.js'); |
|
14 | - $this->set_js($this->default_theme_path.'/flexigrid/js/flexigrid.js'); |
|
13 | + $this->set_js($this->default_theme_path.'/flexigrid/js/cookies.js'); |
|
14 | + $this->set_js($this->default_theme_path.'/flexigrid/js/flexigrid.js'); |
|
15 | 15 | |
16 | 16 | $this->set_js($this->default_javascript_path.'/jquery_plugins/jquery.form.min.js'); |
17 | 17 | |
18 | - $this->set_js($this->default_javascript_path.'/jquery_plugins/jquery.numeric.min.js'); |
|
19 | - $this->set_js($this->default_theme_path.'/flexigrid/js/jquery.printElement.min.js'); |
|
18 | + $this->set_js($this->default_javascript_path.'/jquery_plugins/jquery.numeric.min.js'); |
|
19 | + $this->set_js($this->default_theme_path.'/flexigrid/js/jquery.printElement.min.js'); |
|
20 | 20 | |
21 | - /** Fancybox */ |
|
22 | - $this->set_css($this->default_css_path.'/jquery_plugins/fancybox/jquery.fancybox.css'); |
|
23 | - $this->set_js($this->default_javascript_path.'/jquery_plugins/jquery.fancybox-1.3.4.js'); |
|
24 | - $this->set_js($this->default_javascript_path.'/jquery_plugins/jquery.easing-1.3.pack.js'); |
|
21 | + /** Fancybox */ |
|
22 | + $this->set_css($this->default_css_path.'/jquery_plugins/fancybox/jquery.fancybox.css'); |
|
23 | + $this->set_js($this->default_javascript_path.'/jquery_plugins/jquery.fancybox-1.3.4.js'); |
|
24 | + $this->set_js($this->default_javascript_path.'/jquery_plugins/jquery.easing-1.3.pack.js'); |
|
25 | 25 | |
26 | - /** Jquery UI */ |
|
27 | - $this->load_js_jqueryui(); |
|
26 | + /** Jquery UI */ |
|
27 | + $this->load_js_jqueryui(); |
|
28 | 28 | |
29 | 29 | ?> |
30 | 30 | <script type='text/javascript'> |
@@ -108,9 +108,9 @@ discard block |
||
108 | 108 | <?php $paging_ends_to = "<span id='page-ends-to' class='page-ends-to'>". ($total_results < $default_per_page ? $total_results : $default_per_page) ."</span>"; ?> |
109 | 109 | <?php $paging_total_results = "<span id='total_items' class='total_items'>$total_results</span>"?> |
110 | 110 | <?php echo str_replace( array('{start}','{end}','{results}'), |
111 | - array($paging_starts_from, $paging_ends_to, $paging_total_results), |
|
112 | - $this->l('list_displaying') |
|
113 | - ); ?> |
|
111 | + array($paging_starts_from, $paging_ends_to, $paging_total_results), |
|
112 | + $this->l('list_displaying') |
|
113 | + ); ?> |
|
114 | 114 | </span> |
115 | 115 | </div> |
116 | 116 | <div class="pDiv"> |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | |
29 | 29 | ?> |
30 | 30 | <script type='text/javascript'> |
31 | - var base_url = '<?php echo base_url();?>'; |
|
31 | + var base_url = '<?php echo base_url(); ?>'; |
|
32 | 32 | |
33 | 33 | var subject = '<?php echo addslashes($subject); ?>'; |
34 | 34 | var ajax_list_info_url = '<?php echo $ajax_list_info_url; ?>'; |
@@ -38,20 +38,20 @@ discard block |
||
38 | 38 | |
39 | 39 | </script> |
40 | 40 | <div id='list-report-error' class='report-div error'></div> |
41 | -<div <?php if($success_message !== null){?>class="alert alert-success" role="alert" style="display:block;"<?php }?>><?php |
|
42 | -if($success_message !== null){?> |
|
41 | +<div <?php if ($success_message !== null) {?>class="alert alert-success" role="alert" style="display:block;"<?php }?>><?php |
|
42 | +if ($success_message !== null) {?> |
|
43 | 43 | <p style=" margin-top: -0px;"><?php echo $success_message; ?></p> |
44 | 44 | <?php } |
45 | 45 | ?></div> |
46 | 46 | <div class="flexigrid" style='width: 100%;' data-unique-hash="<?php echo $unique_hash; ?>"> |
47 | 47 | |
48 | - <?php echo form_open( $ajax_list_url, 'method="post" id="filtering_form" class="filtering_form" autocomplete = "off" data-ajax-list-info-url="'.$ajax_list_info_url.'"'); ?> |
|
48 | + <?php echo form_open($ajax_list_url, 'method="post" id="filtering_form" class="filtering_form" autocomplete = "off" data-ajax-list-info-url="'.$ajax_list_info_url.'"'); ?> |
|
49 | 49 | |
50 | 50 | <div id='main-table-box' class="main-table-box"> |
51 | 51 | |
52 | - <?php if(!$unset_add || !$unset_export || !$unset_print){?> |
|
52 | + <?php if (!$unset_add || !$unset_export || !$unset_print) {?> |
|
53 | 53 | <div class="tDiv"> |
54 | - <?php if(!$unset_add){?> |
|
54 | + <?php if (!$unset_add) {?> |
|
55 | 55 | <div class="tDiv2"> |
56 | 56 | <div class="displayadd"> |
57 | 57 | <a href='<?php echo $add_url?>' title='<?php echo $this->l('list_add'); ?> <?php echo $subject?>' class='add-anchor add_button'> |
@@ -64,11 +64,11 @@ discard block |
||
64 | 64 | </div> |
65 | 65 | <?php }?> |
66 | 66 | <div class="tDiv3"> |
67 | - <?php if(!$unset_export) { ?> |
|
67 | + <?php if (!$unset_export) { ?> |
|
68 | 68 | <a class="export-anchor" href="<?php echo $export_url; ?>" target="_blank"> |
69 | 69 | <div class="fbutton"> |
70 | 70 | <div> |
71 | - <span class="export"><?php echo $this->l('list_export');?></span> |
|
71 | + <span class="export"><?php echo $this->l('list_export'); ?></span> |
|
72 | 72 | </div> |
73 | 73 | </div> |
74 | 74 | </a> |
@@ -84,18 +84,18 @@ discard block |
||
84 | 84 | <?php list($show_lang_string, $entries_lang_string) = explode('{paging}', $this->l('list_show_entries')); ?> |
85 | 85 | <?php echo $show_lang_string; ?> |
86 | 86 | <select name="per_page" id='per_page' class="per_page"> |
87 | - <?php foreach($paging_options as $option){?> |
|
88 | - <option value="<?php echo $option; ?>" <?php if($option == $default_per_page){?>selected="selected"<?php }?>><?php echo $option; ?> </option> |
|
87 | + <?php foreach ($paging_options as $option) {?> |
|
88 | + <option value="<?php echo $option; ?>" <?php if ($option == $default_per_page) {?>selected="selected"<?php }?>><?php echo $option; ?> </option> |
|
89 | 89 | <?php }?> |
90 | 90 | </select> |
91 | 91 | <?php echo $entries_lang_string; ?> |
92 | - <input type='hidden' name='order_by[0]' id='hidden-sorting' class='hidden-sorting' value='<?php if(!empty($order_by[0])){?><?php echo $order_by[0]?><?php }?>' /> |
|
93 | - <input type='hidden' name='order_by[1]' id='hidden-ordering' class='hidden-ordering' value='<?php if(!empty($order_by[1])){?><?php echo $order_by[1]?><?php }?>'/> |
|
92 | + <input type='hidden' name='order_by[0]' id='hidden-sorting' class='hidden-sorting' value='<?php if (!empty($order_by[0])) {?><?php echo $order_by[0]?><?php }?>' /> |
|
93 | + <input type='hidden' name='order_by[1]' id='hidden-ordering' class='hidden-ordering' value='<?php if (!empty($order_by[1])) {?><?php echo $order_by[1]?><?php }?>'/> |
|
94 | 94 | </span> |
95 | 95 | </div> |
96 | 96 | <div class="displaysearch"> |
97 | - <?php echo $this->l('list_search');?>: <input type="text" class="qsbsearch_fieldox search_text" name="search_text" size="30" id='search_text'> |
|
98 | - <input type="button" value="<?php echo $this->l('list_search');?>" class="btn btn-default"> |
|
97 | + <?php echo $this->l('list_search'); ?>: <input type="text" class="qsbsearch_fieldox search_text" name="search_text" size="30" id='search_text'> |
|
98 | + <input type="button" value="<?php echo $this->l('list_search'); ?>" class="btn btn-default"> |
|
99 | 99 | </div> |
100 | 100 | |
101 | 101 | <div id='ajax_list' class="ajax_list"> |
@@ -105,9 +105,9 @@ discard block |
||
105 | 105 | <div class="displayshowing" style="margin-top: 10px;"> |
106 | 106 | <span class="pPageStat"> |
107 | 107 | <?php $paging_starts_from = "<span id='page-starts-from' class='page-starts-from'>1</span>"; ?> |
108 | - <?php $paging_ends_to = "<span id='page-ends-to' class='page-ends-to'>". ($total_results < $default_per_page ? $total_results : $default_per_page) ."</span>"; ?> |
|
108 | + <?php $paging_ends_to = "<span id='page-ends-to' class='page-ends-to'>".($total_results < $default_per_page ? $total_results : $default_per_page)."</span>"; ?> |
|
109 | 109 | <?php $paging_total_results = "<span id='total_items' class='total_items'>$total_results</span>"?> |
110 | - <?php echo str_replace( array('{start}','{end}','{results}'), |
|
110 | + <?php echo str_replace(array('{start}', '{end}', '{results}'), |
|
111 | 111 | array($paging_starts_from, $paging_ends_to, $paging_total_results), |
112 | 112 | $this->l('list_displaying') |
113 | 113 | ); ?> |
@@ -24,6 +24,6 @@ |
||
24 | 24 | */ |
25 | 25 | |
26 | 26 | if ( !function_exists('version_compare') || version_compare( phpversion(), '5', '<' ) ) |
27 | - include_once( 'ckeditor_php4.php' ) ; |
|
27 | + include_once( 'ckeditor_php4.php' ) ; |
|
28 | 28 | else |
29 | - include_once( 'ckeditor_php5.php' ) ; |
|
29 | + include_once( 'ckeditor_php5.php' ) ; |
@@ -23,7 +23,7 @@ |
||
23 | 23 | * @endcode |
24 | 24 | */ |
25 | 25 | |
26 | -if ( !function_exists('version_compare') || version_compare( phpversion(), '5', '<' ) ) |
|
27 | - include_once( 'ckeditor_php4.php' ) ; |
|
26 | +if (!function_exists('version_compare') || version_compare(phpversion(), '5', '<')) |
|
27 | + include_once('ckeditor_php4.php'); |
|
28 | 28 | else |
29 | - include_once( 'ckeditor_php5.php' ) ; |
|
29 | + include_once('ckeditor_php5.php'); |
@@ -23,7 +23,8 @@ |
||
23 | 23 | * @endcode |
24 | 24 | */ |
25 | 25 | |
26 | -if ( !function_exists('version_compare') || version_compare( phpversion(), '5', '<' ) ) |
|
27 | - include_once( 'ckeditor_php4.php' ) ; |
|
28 | -else |
|
29 | - include_once( 'ckeditor_php5.php' ) ; |
|
26 | +if ( !function_exists('version_compare') || version_compare( phpversion(), '5', '<' ) ) { |
|
27 | + include_once( 'ckeditor_php4.php' ) ; |
|
28 | +} else { |
|
29 | + include_once( 'ckeditor_php5.php' ) ; |
|
30 | +} |
@@ -17,540 +17,540 @@ |
||
17 | 17 | */ |
18 | 18 | class CKEditor |
19 | 19 | { |
20 | - /** |
|
21 | - * The version of %CKEditor. |
|
22 | - */ |
|
23 | - const version = '3.6.5'; |
|
24 | - /** |
|
25 | - * A constant string unique for each release of %CKEditor. |
|
26 | - */ |
|
27 | - const timestamp = 'C9A85WF'; |
|
28 | - |
|
29 | - /** |
|
30 | - * URL to the %CKEditor installation directory (absolute or relative to document root). |
|
31 | - * If not set, CKEditor will try to guess it's path. |
|
32 | - * |
|
33 | - * Example usage: |
|
34 | - * @code |
|
35 | - * $CKEditor->basePath = '/ckeditor/'; |
|
36 | - * @endcode |
|
37 | - */ |
|
38 | - public $basePath; |
|
39 | - /** |
|
40 | - * An array that holds the global %CKEditor configuration. |
|
41 | - * For the list of available options, see http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.config.html |
|
42 | - * |
|
43 | - * Example usage: |
|
44 | - * @code |
|
45 | - * $CKEditor->config['height'] = 400; |
|
46 | - * // Use @@ at the beggining of a string to ouput it without surrounding quotes. |
|
47 | - * $CKEditor->config['width'] = '@@screen.width * 0.8'; |
|
48 | - * @endcode |
|
49 | - */ |
|
50 | - public $config = array(); |
|
51 | - /** |
|
52 | - * A boolean variable indicating whether CKEditor has been initialized. |
|
53 | - * Set it to true only if you have already included |
|
54 | - * <script> tag loading ckeditor.js in your website. |
|
55 | - */ |
|
56 | - public $initialized = false; |
|
57 | - /** |
|
58 | - * Boolean variable indicating whether created code should be printed out or returned by a function. |
|
59 | - * |
|
60 | - * Example 1: get the code creating %CKEditor instance and print it on a page with the "echo" function. |
|
61 | - * @code |
|
62 | - * $CKEditor = new CKEditor(); |
|
63 | - * $CKEditor->returnOutput = true; |
|
64 | - * $code = $CKEditor->editor("editor1", "<p>Initial value.</p>"); |
|
65 | - * echo "<p>Editor 1:</p>"; |
|
66 | - * echo $code; |
|
67 | - * @endcode |
|
68 | - */ |
|
69 | - public $returnOutput = false; |
|
70 | - /** |
|
71 | - * An array with textarea attributes. |
|
72 | - * |
|
73 | - * When %CKEditor is created with the editor() method, a HTML <textarea> element is created, |
|
74 | - * it will be displayed to anyone with JavaScript disabled or with incompatible browser. |
|
75 | - */ |
|
76 | - public $textareaAttributes = array( "rows" => 8, "cols" => 60 ); |
|
77 | - /** |
|
78 | - * A string indicating the creation date of %CKEditor. |
|
79 | - * Do not change it unless you want to force browsers to not use previously cached version of %CKEditor. |
|
80 | - */ |
|
81 | - public $timestamp = "C9A85WF"; |
|
82 | - /** |
|
83 | - * An array that holds event listeners. |
|
84 | - */ |
|
85 | - private $events = array(); |
|
86 | - /** |
|
87 | - * An array that holds global event listeners. |
|
88 | - */ |
|
89 | - private $globalEvents = array(); |
|
90 | - |
|
91 | - /** |
|
92 | - * Main Constructor. |
|
93 | - * |
|
94 | - * @param $basePath (string) URL to the %CKEditor installation directory (optional). |
|
95 | - */ |
|
96 | - function __construct($basePath = null) { |
|
97 | - if (!empty($basePath)) { |
|
98 | - $this->basePath = $basePath; |
|
99 | - } |
|
100 | - } |
|
101 | - |
|
102 | - /** |
|
103 | - * Creates a %CKEditor instance. |
|
104 | - * In incompatible browsers %CKEditor will downgrade to plain HTML <textarea> element. |
|
105 | - * |
|
106 | - * @param $name (string) Name of the %CKEditor instance (this will be also the "name" attribute of textarea element). |
|
107 | - * @param $value (string) Initial value (optional). |
|
108 | - * @param $config (array) The specific configurations to apply to this editor instance (optional). |
|
109 | - * @param $events (array) Event listeners for this editor instance (optional). |
|
110 | - * |
|
111 | - * Example usage: |
|
112 | - * @code |
|
113 | - * $CKEditor = new CKEditor(); |
|
114 | - * $CKEditor->editor("field1", "<p>Initial value.</p>"); |
|
115 | - * @endcode |
|
116 | - * |
|
117 | - * Advanced example: |
|
118 | - * @code |
|
119 | - * $CKEditor = new CKEditor(); |
|
120 | - * $config = array(); |
|
121 | - * $config['toolbar'] = array( |
|
122 | - * array( 'Source', '-', 'Bold', 'Italic', 'Underline', 'Strike' ), |
|
123 | - * array( 'Image', 'Link', 'Unlink', 'Anchor' ) |
|
124 | - * ); |
|
125 | - * $events['instanceReady'] = 'function (ev) { |
|
126 | - * alert("Loaded: " + ev.editor.name); |
|
127 | - * }'; |
|
128 | - * $CKEditor->editor("field1", "<p>Initial value.</p>", $config, $events); |
|
129 | - * @endcode |
|
130 | - */ |
|
131 | - public function editor($name, $value = "", $config = array(), $events = array()) |
|
132 | - { |
|
133 | - $attr = ""; |
|
134 | - foreach ($this->textareaAttributes as $key => $val) { |
|
135 | - $attr.= " " . $key . '="' . str_replace('"', '"', $val) . '"'; |
|
136 | - } |
|
137 | - $out = "<textarea name=\"" . $name . "\"" . $attr . ">" . htmlspecialchars($value) . "</textarea>\n"; |
|
138 | - if (!$this->initialized) { |
|
139 | - $out .= $this->init(); |
|
140 | - } |
|
141 | - |
|
142 | - $_config = $this->configSettings($config, $events); |
|
143 | - |
|
144 | - $js = $this->returnGlobalEvents(); |
|
145 | - if (!empty($_config)) |
|
146 | - $js .= "CKEDITOR.replace('".$name."', ".$this->jsEncode($_config).");"; |
|
147 | - else |
|
148 | - $js .= "CKEDITOR.replace('".$name."');"; |
|
149 | - |
|
150 | - $out .= $this->script($js); |
|
151 | - |
|
152 | - if (!$this->returnOutput) { |
|
153 | - print $out; |
|
154 | - $out = ""; |
|
155 | - } |
|
156 | - |
|
157 | - return $out; |
|
158 | - } |
|
159 | - |
|
160 | - /** |
|
161 | - * Replaces a <textarea> with a %CKEditor instance. |
|
162 | - * |
|
163 | - * @param $id (string) The id or name of textarea element. |
|
164 | - * @param $config (array) The specific configurations to apply to this editor instance (optional). |
|
165 | - * @param $events (array) Event listeners for this editor instance (optional). |
|
166 | - * |
|
167 | - * Example 1: adding %CKEditor to <textarea name="article"></textarea> element: |
|
168 | - * @code |
|
169 | - * $CKEditor = new CKEditor(); |
|
170 | - * $CKEditor->replace("article"); |
|
171 | - * @endcode |
|
172 | - */ |
|
173 | - public function replace($id, $config = array(), $events = array()) |
|
174 | - { |
|
175 | - $out = ""; |
|
176 | - if (!$this->initialized) { |
|
177 | - $out .= $this->init(); |
|
178 | - } |
|
179 | - |
|
180 | - $_config = $this->configSettings($config, $events); |
|
181 | - |
|
182 | - $js = $this->returnGlobalEvents(); |
|
183 | - if (!empty($_config)) { |
|
184 | - $js .= "CKEDITOR.replace('".$id."', ".$this->jsEncode($_config).");"; |
|
185 | - } |
|
186 | - else { |
|
187 | - $js .= "CKEDITOR.replace('".$id."');"; |
|
188 | - } |
|
189 | - $out .= $this->script($js); |
|
190 | - |
|
191 | - if (!$this->returnOutput) { |
|
192 | - print $out; |
|
193 | - $out = ""; |
|
194 | - } |
|
195 | - |
|
196 | - return $out; |
|
197 | - } |
|
198 | - |
|
199 | - /** |
|
200 | - * Replace all <textarea> elements available in the document with editor instances. |
|
201 | - * |
|
202 | - * @param $className (string) If set, replace all textareas with class className in the page. |
|
203 | - * |
|
204 | - * Example 1: replace all <textarea> elements in the page. |
|
205 | - * @code |
|
206 | - * $CKEditor = new CKEditor(); |
|
207 | - * $CKEditor->replaceAll(); |
|
208 | - * @endcode |
|
209 | - * |
|
210 | - * Example 2: replace all <textarea class="myClassName"> elements in the page. |
|
211 | - * @code |
|
212 | - * $CKEditor = new CKEditor(); |
|
213 | - * $CKEditor->replaceAll( 'myClassName' ); |
|
214 | - * @endcode |
|
215 | - */ |
|
216 | - public function replaceAll($className = null) |
|
217 | - { |
|
218 | - $out = ""; |
|
219 | - if (!$this->initialized) { |
|
220 | - $out .= $this->init(); |
|
221 | - } |
|
222 | - |
|
223 | - $_config = $this->configSettings(); |
|
224 | - |
|
225 | - $js = $this->returnGlobalEvents(); |
|
226 | - if (empty($_config)) { |
|
227 | - if (empty($className)) { |
|
228 | - $js .= "CKEDITOR.replaceAll();"; |
|
229 | - } |
|
230 | - else { |
|
231 | - $js .= "CKEDITOR.replaceAll('".$className."');"; |
|
232 | - } |
|
233 | - } |
|
234 | - else { |
|
235 | - $classDetection = ""; |
|
236 | - $js .= "CKEDITOR.replaceAll( function(textarea, config) {\n"; |
|
237 | - if (!empty($className)) { |
|
238 | - $js .= " var classRegex = new RegExp('(?:^| )' + '". $className ."' + '(?:$| )');\n"; |
|
239 | - $js .= " if (!classRegex.test(textarea.className))\n"; |
|
240 | - $js .= " return false;\n"; |
|
241 | - } |
|
242 | - $js .= " CKEDITOR.tools.extend(config, ". $this->jsEncode($_config) .", true);"; |
|
243 | - $js .= "} );"; |
|
244 | - |
|
245 | - } |
|
246 | - |
|
247 | - $out .= $this->script($js); |
|
248 | - |
|
249 | - if (!$this->returnOutput) { |
|
250 | - print $out; |
|
251 | - $out = ""; |
|
252 | - } |
|
253 | - |
|
254 | - return $out; |
|
255 | - } |
|
256 | - |
|
257 | - /** |
|
258 | - * Adds event listener. |
|
259 | - * Events are fired by %CKEditor in various situations. |
|
260 | - * |
|
261 | - * @param $event (string) Event name. |
|
262 | - * @param $javascriptCode (string) Javascript anonymous function or function name. |
|
263 | - * |
|
264 | - * Example usage: |
|
265 | - * @code |
|
266 | - * $CKEditor->addEventHandler('instanceReady', 'function (ev) { |
|
267 | - * alert("Loaded: " + ev.editor.name); |
|
268 | - * }'); |
|
269 | - * @endcode |
|
270 | - */ |
|
271 | - public function addEventHandler($event, $javascriptCode) |
|
272 | - { |
|
273 | - if (!isset($this->events[$event])) { |
|
274 | - $this->events[$event] = array(); |
|
275 | - } |
|
276 | - // Avoid duplicates. |
|
277 | - if (!in_array($javascriptCode, $this->events[$event])) { |
|
278 | - $this->events[$event][] = $javascriptCode; |
|
279 | - } |
|
280 | - } |
|
281 | - |
|
282 | - /** |
|
283 | - * Clear registered event handlers. |
|
284 | - * Note: this function will have no effect on already created editor instances. |
|
285 | - * |
|
286 | - * @param $event (string) Event name, if not set all event handlers will be removed (optional). |
|
287 | - */ |
|
288 | - public function clearEventHandlers($event = null) |
|
289 | - { |
|
290 | - if (!empty($event)) { |
|
291 | - $this->events[$event] = array(); |
|
292 | - } |
|
293 | - else { |
|
294 | - $this->events = array(); |
|
295 | - } |
|
296 | - } |
|
297 | - |
|
298 | - /** |
|
299 | - * Adds global event listener. |
|
300 | - * |
|
301 | - * @param $event (string) Event name. |
|
302 | - * @param $javascriptCode (string) Javascript anonymous function or function name. |
|
303 | - * |
|
304 | - * Example usage: |
|
305 | - * @code |
|
306 | - * $CKEditor->addGlobalEventHandler('dialogDefinition', 'function (ev) { |
|
307 | - * alert("Loading dialog: " + ev.data.name); |
|
308 | - * }'); |
|
309 | - * @endcode |
|
310 | - */ |
|
311 | - public function addGlobalEventHandler($event, $javascriptCode) |
|
312 | - { |
|
313 | - if (!isset($this->globalEvents[$event])) { |
|
314 | - $this->globalEvents[$event] = array(); |
|
315 | - } |
|
316 | - // Avoid duplicates. |
|
317 | - if (!in_array($javascriptCode, $this->globalEvents[$event])) { |
|
318 | - $this->globalEvents[$event][] = $javascriptCode; |
|
319 | - } |
|
320 | - } |
|
321 | - |
|
322 | - /** |
|
323 | - * Clear registered global event handlers. |
|
324 | - * Note: this function will have no effect if the event handler has been already printed/returned. |
|
325 | - * |
|
326 | - * @param $event (string) Event name, if not set all event handlers will be removed (optional). |
|
327 | - */ |
|
328 | - public function clearGlobalEventHandlers($event = null) |
|
329 | - { |
|
330 | - if (!empty($event)) { |
|
331 | - $this->globalEvents[$event] = array(); |
|
332 | - } |
|
333 | - else { |
|
334 | - $this->globalEvents = array(); |
|
335 | - } |
|
336 | - } |
|
337 | - |
|
338 | - /** |
|
339 | - * Prints javascript code. |
|
340 | - * |
|
341 | - * @param string $js |
|
342 | - */ |
|
343 | - private function script($js) |
|
344 | - { |
|
345 | - $out = "<script type=\"text/javascript\">"; |
|
346 | - $out .= "//<![CDATA[\n"; |
|
347 | - $out .= $js; |
|
348 | - $out .= "\n//]]>"; |
|
349 | - $out .= "</script>\n"; |
|
350 | - |
|
351 | - return $out; |
|
352 | - } |
|
353 | - |
|
354 | - /** |
|
355 | - * Returns the configuration array (global and instance specific settings are merged into one array). |
|
356 | - * |
|
357 | - * @param $config (array) The specific configurations to apply to editor instance. |
|
358 | - * @param $events (array) Event listeners for editor instance. |
|
359 | - */ |
|
360 | - private function configSettings($config = array(), $events = array()) |
|
361 | - { |
|
362 | - $_config = $this->config; |
|
363 | - $_events = $this->events; |
|
364 | - |
|
365 | - if (is_array($config) && !empty($config)) { |
|
366 | - $_config = array_merge($_config, $config); |
|
367 | - } |
|
368 | - |
|
369 | - if (is_array($events) && !empty($events)) { |
|
370 | - foreach ($events as $eventName => $code) { |
|
371 | - if (!isset($_events[$eventName])) { |
|
372 | - $_events[$eventName] = array(); |
|
373 | - } |
|
374 | - if (!in_array($code, $_events[$eventName])) { |
|
375 | - $_events[$eventName][] = $code; |
|
376 | - } |
|
377 | - } |
|
378 | - } |
|
379 | - |
|
380 | - if (!empty($_events)) { |
|
381 | - foreach($_events as $eventName => $handlers) { |
|
382 | - if (empty($handlers)) { |
|
383 | - continue; |
|
384 | - } |
|
385 | - else if (count($handlers) == 1) { |
|
386 | - $_config['on'][$eventName] = '@@'.$handlers[0]; |
|
387 | - } |
|
388 | - else { |
|
389 | - $_config['on'][$eventName] = '@@function (ev){'; |
|
390 | - foreach ($handlers as $handler => $code) { |
|
391 | - $_config['on'][$eventName] .= '('.$code.')(ev);'; |
|
392 | - } |
|
393 | - $_config['on'][$eventName] .= '}'; |
|
394 | - } |
|
395 | - } |
|
396 | - } |
|
397 | - |
|
398 | - return $_config; |
|
399 | - } |
|
400 | - |
|
401 | - /** |
|
402 | - * Return global event handlers. |
|
403 | - */ |
|
404 | - private function returnGlobalEvents() |
|
405 | - { |
|
406 | - static $returnedEvents; |
|
407 | - $out = ""; |
|
408 | - |
|
409 | - if (!isset($returnedEvents)) { |
|
410 | - $returnedEvents = array(); |
|
411 | - } |
|
412 | - |
|
413 | - if (!empty($this->globalEvents)) { |
|
414 | - foreach ($this->globalEvents as $eventName => $handlers) { |
|
415 | - foreach ($handlers as $handler => $code) { |
|
416 | - if (!isset($returnedEvents[$eventName])) { |
|
417 | - $returnedEvents[$eventName] = array(); |
|
418 | - } |
|
419 | - // Return only new events |
|
420 | - if (!in_array($code, $returnedEvents[$eventName])) { |
|
421 | - $out .= ($code ? "\n" : "") . "CKEDITOR.on('". $eventName ."', $code);"; |
|
422 | - $returnedEvents[$eventName][] = $code; |
|
423 | - } |
|
424 | - } |
|
425 | - } |
|
426 | - } |
|
427 | - |
|
428 | - return $out; |
|
429 | - } |
|
430 | - |
|
431 | - /** |
|
432 | - * Initializes CKEditor (executed only once). |
|
433 | - */ |
|
434 | - private function init() |
|
435 | - { |
|
436 | - static $initComplete; |
|
437 | - $out = ""; |
|
438 | - |
|
439 | - if (!empty($initComplete)) { |
|
440 | - return ""; |
|
441 | - } |
|
442 | - |
|
443 | - if ($this->initialized) { |
|
444 | - $initComplete = true; |
|
445 | - return ""; |
|
446 | - } |
|
447 | - |
|
448 | - $args = ""; |
|
449 | - $ckeditorPath = $this->ckeditorPath(); |
|
450 | - |
|
451 | - if (!empty($this->timestamp) && $this->timestamp != "%"."TIMESTAMP%") { |
|
452 | - $args = '?t=' . $this->timestamp; |
|
453 | - } |
|
454 | - |
|
455 | - // Skip relative paths... |
|
456 | - if (strpos($ckeditorPath, '..') !== 0) { |
|
457 | - $out .= $this->script("window.CKEDITOR_BASEPATH='". $ckeditorPath ."';"); |
|
458 | - } |
|
459 | - |
|
460 | - $out .= "<script type=\"text/javascript\" src=\"" . $ckeditorPath . 'ckeditor.js' . $args . "\"></script>\n"; |
|
461 | - |
|
462 | - $extraCode = ""; |
|
463 | - if ($this->timestamp != self::timestamp) { |
|
464 | - $extraCode .= ($extraCode ? "\n" : "") . "CKEDITOR.timestamp = '". $this->timestamp ."';"; |
|
465 | - } |
|
466 | - if ($extraCode) { |
|
467 | - $out .= $this->script($extraCode); |
|
468 | - } |
|
469 | - |
|
470 | - $initComplete = $this->initialized = true; |
|
471 | - |
|
472 | - return $out; |
|
473 | - } |
|
474 | - |
|
475 | - /** |
|
476 | - * Return path to ckeditor.js. |
|
477 | - */ |
|
478 | - private function ckeditorPath() |
|
479 | - { |
|
480 | - if (!empty($this->basePath)) { |
|
481 | - return $this->basePath; |
|
482 | - } |
|
483 | - |
|
484 | - /** |
|
485 | - * The absolute pathname of the currently executing script. |
|
486 | - * Note: If a script is executed with the CLI, as a relative path, such as file.php or ../file.php, |
|
487 | - * $_SERVER['SCRIPT_FILENAME'] will contain the relative path specified by the user. |
|
488 | - */ |
|
489 | - if (isset($_SERVER['SCRIPT_FILENAME'])) { |
|
490 | - $realPath = dirname($_SERVER['SCRIPT_FILENAME']); |
|
491 | - } |
|
492 | - else { |
|
493 | - /** |
|
494 | - * realpath - Returns canonicalized absolute pathname |
|
495 | - */ |
|
496 | - $realPath = realpath( './' ) ; |
|
497 | - } |
|
498 | - |
|
499 | - /** |
|
500 | - * The filename of the currently executing script, relative to the document root. |
|
501 | - * For instance, $_SERVER['PHP_SELF'] in a script at the address http://example.com/test.php/foo.bar |
|
502 | - * would be /test.php/foo.bar. |
|
503 | - */ |
|
504 | - $selfPath = dirname($_SERVER['PHP_SELF']); |
|
505 | - $file = str_replace("\\", "/", __FILE__); |
|
506 | - |
|
507 | - if (!$selfPath || !$realPath || !$file) { |
|
508 | - return "/ckeditor/"; |
|
509 | - } |
|
510 | - |
|
511 | - $documentRoot = substr($realPath, 0, strlen($realPath) - strlen($selfPath)); |
|
512 | - $fileUrl = substr($file, strlen($documentRoot)); |
|
513 | - $ckeditorUrl = str_replace("ckeditor_php5.php", "", $fileUrl); |
|
514 | - |
|
515 | - return $ckeditorUrl; |
|
516 | - } |
|
517 | - |
|
518 | - /** |
|
519 | - * This little function provides a basic JSON support. |
|
520 | - * |
|
521 | - * @param mixed $val |
|
522 | - * @return string |
|
523 | - */ |
|
524 | - private function jsEncode($val) |
|
525 | - { |
|
526 | - if (is_null($val)) { |
|
527 | - return 'null'; |
|
528 | - } |
|
529 | - if (is_bool($val)) { |
|
530 | - return $val ? 'true' : 'false'; |
|
531 | - } |
|
532 | - if (is_int($val)) { |
|
533 | - return $val; |
|
534 | - } |
|
535 | - if (is_float($val)) { |
|
536 | - return str_replace(',', '.', $val); |
|
537 | - } |
|
538 | - if (is_array($val) || is_object($val)) { |
|
539 | - if (is_array($val) && (array_keys($val) === range(0,count($val)-1))) { |
|
540 | - return '[' . implode(',', array_map(array($this, 'jsEncode'), $val)) . ']'; |
|
541 | - } |
|
542 | - $temp = array(); |
|
543 | - foreach ($val as $k => $v){ |
|
544 | - $temp[] = $this->jsEncode("{$k}") . ':' . $this->jsEncode($v); |
|
545 | - } |
|
546 | - return '{' . implode(',', $temp) . '}'; |
|
547 | - } |
|
548 | - // String otherwise |
|
549 | - if (strpos($val, '@@') === 0) |
|
550 | - return substr($val, 2); |
|
551 | - if (strtoupper(substr($val, 0, 9)) == 'CKEDITOR.') |
|
552 | - return $val; |
|
553 | - |
|
554 | - return '"' . str_replace(array("\\", "/", "\n", "\t", "\r", "\x08", "\x0c", '"'), array('\\\\', '\\/', '\\n', '\\t', '\\r', '\\b', '\\f', '\"'), $val) . '"'; |
|
555 | - } |
|
20 | + /** |
|
21 | + * The version of %CKEditor. |
|
22 | + */ |
|
23 | + const version = '3.6.5'; |
|
24 | + /** |
|
25 | + * A constant string unique for each release of %CKEditor. |
|
26 | + */ |
|
27 | + const timestamp = 'C9A85WF'; |
|
28 | + |
|
29 | + /** |
|
30 | + * URL to the %CKEditor installation directory (absolute or relative to document root). |
|
31 | + * If not set, CKEditor will try to guess it's path. |
|
32 | + * |
|
33 | + * Example usage: |
|
34 | + * @code |
|
35 | + * $CKEditor->basePath = '/ckeditor/'; |
|
36 | + * @endcode |
|
37 | + */ |
|
38 | + public $basePath; |
|
39 | + /** |
|
40 | + * An array that holds the global %CKEditor configuration. |
|
41 | + * For the list of available options, see http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.config.html |
|
42 | + * |
|
43 | + * Example usage: |
|
44 | + * @code |
|
45 | + * $CKEditor->config['height'] = 400; |
|
46 | + * // Use @@ at the beggining of a string to ouput it without surrounding quotes. |
|
47 | + * $CKEditor->config['width'] = '@@screen.width * 0.8'; |
|
48 | + * @endcode |
|
49 | + */ |
|
50 | + public $config = array(); |
|
51 | + /** |
|
52 | + * A boolean variable indicating whether CKEditor has been initialized. |
|
53 | + * Set it to true only if you have already included |
|
54 | + * <script> tag loading ckeditor.js in your website. |
|
55 | + */ |
|
56 | + public $initialized = false; |
|
57 | + /** |
|
58 | + * Boolean variable indicating whether created code should be printed out or returned by a function. |
|
59 | + * |
|
60 | + * Example 1: get the code creating %CKEditor instance and print it on a page with the "echo" function. |
|
61 | + * @code |
|
62 | + * $CKEditor = new CKEditor(); |
|
63 | + * $CKEditor->returnOutput = true; |
|
64 | + * $code = $CKEditor->editor("editor1", "<p>Initial value.</p>"); |
|
65 | + * echo "<p>Editor 1:</p>"; |
|
66 | + * echo $code; |
|
67 | + * @endcode |
|
68 | + */ |
|
69 | + public $returnOutput = false; |
|
70 | + /** |
|
71 | + * An array with textarea attributes. |
|
72 | + * |
|
73 | + * When %CKEditor is created with the editor() method, a HTML <textarea> element is created, |
|
74 | + * it will be displayed to anyone with JavaScript disabled or with incompatible browser. |
|
75 | + */ |
|
76 | + public $textareaAttributes = array( "rows" => 8, "cols" => 60 ); |
|
77 | + /** |
|
78 | + * A string indicating the creation date of %CKEditor. |
|
79 | + * Do not change it unless you want to force browsers to not use previously cached version of %CKEditor. |
|
80 | + */ |
|
81 | + public $timestamp = "C9A85WF"; |
|
82 | + /** |
|
83 | + * An array that holds event listeners. |
|
84 | + */ |
|
85 | + private $events = array(); |
|
86 | + /** |
|
87 | + * An array that holds global event listeners. |
|
88 | + */ |
|
89 | + private $globalEvents = array(); |
|
90 | + |
|
91 | + /** |
|
92 | + * Main Constructor. |
|
93 | + * |
|
94 | + * @param $basePath (string) URL to the %CKEditor installation directory (optional). |
|
95 | + */ |
|
96 | + function __construct($basePath = null) { |
|
97 | + if (!empty($basePath)) { |
|
98 | + $this->basePath = $basePath; |
|
99 | + } |
|
100 | + } |
|
101 | + |
|
102 | + /** |
|
103 | + * Creates a %CKEditor instance. |
|
104 | + * In incompatible browsers %CKEditor will downgrade to plain HTML <textarea> element. |
|
105 | + * |
|
106 | + * @param $name (string) Name of the %CKEditor instance (this will be also the "name" attribute of textarea element). |
|
107 | + * @param $value (string) Initial value (optional). |
|
108 | + * @param $config (array) The specific configurations to apply to this editor instance (optional). |
|
109 | + * @param $events (array) Event listeners for this editor instance (optional). |
|
110 | + * |
|
111 | + * Example usage: |
|
112 | + * @code |
|
113 | + * $CKEditor = new CKEditor(); |
|
114 | + * $CKEditor->editor("field1", "<p>Initial value.</p>"); |
|
115 | + * @endcode |
|
116 | + * |
|
117 | + * Advanced example: |
|
118 | + * @code |
|
119 | + * $CKEditor = new CKEditor(); |
|
120 | + * $config = array(); |
|
121 | + * $config['toolbar'] = array( |
|
122 | + * array( 'Source', '-', 'Bold', 'Italic', 'Underline', 'Strike' ), |
|
123 | + * array( 'Image', 'Link', 'Unlink', 'Anchor' ) |
|
124 | + * ); |
|
125 | + * $events['instanceReady'] = 'function (ev) { |
|
126 | + * alert("Loaded: " + ev.editor.name); |
|
127 | + * }'; |
|
128 | + * $CKEditor->editor("field1", "<p>Initial value.</p>", $config, $events); |
|
129 | + * @endcode |
|
130 | + */ |
|
131 | + public function editor($name, $value = "", $config = array(), $events = array()) |
|
132 | + { |
|
133 | + $attr = ""; |
|
134 | + foreach ($this->textareaAttributes as $key => $val) { |
|
135 | + $attr.= " " . $key . '="' . str_replace('"', '"', $val) . '"'; |
|
136 | + } |
|
137 | + $out = "<textarea name=\"" . $name . "\"" . $attr . ">" . htmlspecialchars($value) . "</textarea>\n"; |
|
138 | + if (!$this->initialized) { |
|
139 | + $out .= $this->init(); |
|
140 | + } |
|
141 | + |
|
142 | + $_config = $this->configSettings($config, $events); |
|
143 | + |
|
144 | + $js = $this->returnGlobalEvents(); |
|
145 | + if (!empty($_config)) |
|
146 | + $js .= "CKEDITOR.replace('".$name."', ".$this->jsEncode($_config).");"; |
|
147 | + else |
|
148 | + $js .= "CKEDITOR.replace('".$name."');"; |
|
149 | + |
|
150 | + $out .= $this->script($js); |
|
151 | + |
|
152 | + if (!$this->returnOutput) { |
|
153 | + print $out; |
|
154 | + $out = ""; |
|
155 | + } |
|
156 | + |
|
157 | + return $out; |
|
158 | + } |
|
159 | + |
|
160 | + /** |
|
161 | + * Replaces a <textarea> with a %CKEditor instance. |
|
162 | + * |
|
163 | + * @param $id (string) The id or name of textarea element. |
|
164 | + * @param $config (array) The specific configurations to apply to this editor instance (optional). |
|
165 | + * @param $events (array) Event listeners for this editor instance (optional). |
|
166 | + * |
|
167 | + * Example 1: adding %CKEditor to <textarea name="article"></textarea> element: |
|
168 | + * @code |
|
169 | + * $CKEditor = new CKEditor(); |
|
170 | + * $CKEditor->replace("article"); |
|
171 | + * @endcode |
|
172 | + */ |
|
173 | + public function replace($id, $config = array(), $events = array()) |
|
174 | + { |
|
175 | + $out = ""; |
|
176 | + if (!$this->initialized) { |
|
177 | + $out .= $this->init(); |
|
178 | + } |
|
179 | + |
|
180 | + $_config = $this->configSettings($config, $events); |
|
181 | + |
|
182 | + $js = $this->returnGlobalEvents(); |
|
183 | + if (!empty($_config)) { |
|
184 | + $js .= "CKEDITOR.replace('".$id."', ".$this->jsEncode($_config).");"; |
|
185 | + } |
|
186 | + else { |
|
187 | + $js .= "CKEDITOR.replace('".$id."');"; |
|
188 | + } |
|
189 | + $out .= $this->script($js); |
|
190 | + |
|
191 | + if (!$this->returnOutput) { |
|
192 | + print $out; |
|
193 | + $out = ""; |
|
194 | + } |
|
195 | + |
|
196 | + return $out; |
|
197 | + } |
|
198 | + |
|
199 | + /** |
|
200 | + * Replace all <textarea> elements available in the document with editor instances. |
|
201 | + * |
|
202 | + * @param $className (string) If set, replace all textareas with class className in the page. |
|
203 | + * |
|
204 | + * Example 1: replace all <textarea> elements in the page. |
|
205 | + * @code |
|
206 | + * $CKEditor = new CKEditor(); |
|
207 | + * $CKEditor->replaceAll(); |
|
208 | + * @endcode |
|
209 | + * |
|
210 | + * Example 2: replace all <textarea class="myClassName"> elements in the page. |
|
211 | + * @code |
|
212 | + * $CKEditor = new CKEditor(); |
|
213 | + * $CKEditor->replaceAll( 'myClassName' ); |
|
214 | + * @endcode |
|
215 | + */ |
|
216 | + public function replaceAll($className = null) |
|
217 | + { |
|
218 | + $out = ""; |
|
219 | + if (!$this->initialized) { |
|
220 | + $out .= $this->init(); |
|
221 | + } |
|
222 | + |
|
223 | + $_config = $this->configSettings(); |
|
224 | + |
|
225 | + $js = $this->returnGlobalEvents(); |
|
226 | + if (empty($_config)) { |
|
227 | + if (empty($className)) { |
|
228 | + $js .= "CKEDITOR.replaceAll();"; |
|
229 | + } |
|
230 | + else { |
|
231 | + $js .= "CKEDITOR.replaceAll('".$className."');"; |
|
232 | + } |
|
233 | + } |
|
234 | + else { |
|
235 | + $classDetection = ""; |
|
236 | + $js .= "CKEDITOR.replaceAll( function(textarea, config) {\n"; |
|
237 | + if (!empty($className)) { |
|
238 | + $js .= " var classRegex = new RegExp('(?:^| )' + '". $className ."' + '(?:$| )');\n"; |
|
239 | + $js .= " if (!classRegex.test(textarea.className))\n"; |
|
240 | + $js .= " return false;\n"; |
|
241 | + } |
|
242 | + $js .= " CKEDITOR.tools.extend(config, ". $this->jsEncode($_config) .", true);"; |
|
243 | + $js .= "} );"; |
|
244 | + |
|
245 | + } |
|
246 | + |
|
247 | + $out .= $this->script($js); |
|
248 | + |
|
249 | + if (!$this->returnOutput) { |
|
250 | + print $out; |
|
251 | + $out = ""; |
|
252 | + } |
|
253 | + |
|
254 | + return $out; |
|
255 | + } |
|
256 | + |
|
257 | + /** |
|
258 | + * Adds event listener. |
|
259 | + * Events are fired by %CKEditor in various situations. |
|
260 | + * |
|
261 | + * @param $event (string) Event name. |
|
262 | + * @param $javascriptCode (string) Javascript anonymous function or function name. |
|
263 | + * |
|
264 | + * Example usage: |
|
265 | + * @code |
|
266 | + * $CKEditor->addEventHandler('instanceReady', 'function (ev) { |
|
267 | + * alert("Loaded: " + ev.editor.name); |
|
268 | + * }'); |
|
269 | + * @endcode |
|
270 | + */ |
|
271 | + public function addEventHandler($event, $javascriptCode) |
|
272 | + { |
|
273 | + if (!isset($this->events[$event])) { |
|
274 | + $this->events[$event] = array(); |
|
275 | + } |
|
276 | + // Avoid duplicates. |
|
277 | + if (!in_array($javascriptCode, $this->events[$event])) { |
|
278 | + $this->events[$event][] = $javascriptCode; |
|
279 | + } |
|
280 | + } |
|
281 | + |
|
282 | + /** |
|
283 | + * Clear registered event handlers. |
|
284 | + * Note: this function will have no effect on already created editor instances. |
|
285 | + * |
|
286 | + * @param $event (string) Event name, if not set all event handlers will be removed (optional). |
|
287 | + */ |
|
288 | + public function clearEventHandlers($event = null) |
|
289 | + { |
|
290 | + if (!empty($event)) { |
|
291 | + $this->events[$event] = array(); |
|
292 | + } |
|
293 | + else { |
|
294 | + $this->events = array(); |
|
295 | + } |
|
296 | + } |
|
297 | + |
|
298 | + /** |
|
299 | + * Adds global event listener. |
|
300 | + * |
|
301 | + * @param $event (string) Event name. |
|
302 | + * @param $javascriptCode (string) Javascript anonymous function or function name. |
|
303 | + * |
|
304 | + * Example usage: |
|
305 | + * @code |
|
306 | + * $CKEditor->addGlobalEventHandler('dialogDefinition', 'function (ev) { |
|
307 | + * alert("Loading dialog: " + ev.data.name); |
|
308 | + * }'); |
|
309 | + * @endcode |
|
310 | + */ |
|
311 | + public function addGlobalEventHandler($event, $javascriptCode) |
|
312 | + { |
|
313 | + if (!isset($this->globalEvents[$event])) { |
|
314 | + $this->globalEvents[$event] = array(); |
|
315 | + } |
|
316 | + // Avoid duplicates. |
|
317 | + if (!in_array($javascriptCode, $this->globalEvents[$event])) { |
|
318 | + $this->globalEvents[$event][] = $javascriptCode; |
|
319 | + } |
|
320 | + } |
|
321 | + |
|
322 | + /** |
|
323 | + * Clear registered global event handlers. |
|
324 | + * Note: this function will have no effect if the event handler has been already printed/returned. |
|
325 | + * |
|
326 | + * @param $event (string) Event name, if not set all event handlers will be removed (optional). |
|
327 | + */ |
|
328 | + public function clearGlobalEventHandlers($event = null) |
|
329 | + { |
|
330 | + if (!empty($event)) { |
|
331 | + $this->globalEvents[$event] = array(); |
|
332 | + } |
|
333 | + else { |
|
334 | + $this->globalEvents = array(); |
|
335 | + } |
|
336 | + } |
|
337 | + |
|
338 | + /** |
|
339 | + * Prints javascript code. |
|
340 | + * |
|
341 | + * @param string $js |
|
342 | + */ |
|
343 | + private function script($js) |
|
344 | + { |
|
345 | + $out = "<script type=\"text/javascript\">"; |
|
346 | + $out .= "//<![CDATA[\n"; |
|
347 | + $out .= $js; |
|
348 | + $out .= "\n//]]>"; |
|
349 | + $out .= "</script>\n"; |
|
350 | + |
|
351 | + return $out; |
|
352 | + } |
|
353 | + |
|
354 | + /** |
|
355 | + * Returns the configuration array (global and instance specific settings are merged into one array). |
|
356 | + * |
|
357 | + * @param $config (array) The specific configurations to apply to editor instance. |
|
358 | + * @param $events (array) Event listeners for editor instance. |
|
359 | + */ |
|
360 | + private function configSettings($config = array(), $events = array()) |
|
361 | + { |
|
362 | + $_config = $this->config; |
|
363 | + $_events = $this->events; |
|
364 | + |
|
365 | + if (is_array($config) && !empty($config)) { |
|
366 | + $_config = array_merge($_config, $config); |
|
367 | + } |
|
368 | + |
|
369 | + if (is_array($events) && !empty($events)) { |
|
370 | + foreach ($events as $eventName => $code) { |
|
371 | + if (!isset($_events[$eventName])) { |
|
372 | + $_events[$eventName] = array(); |
|
373 | + } |
|
374 | + if (!in_array($code, $_events[$eventName])) { |
|
375 | + $_events[$eventName][] = $code; |
|
376 | + } |
|
377 | + } |
|
378 | + } |
|
379 | + |
|
380 | + if (!empty($_events)) { |
|
381 | + foreach($_events as $eventName => $handlers) { |
|
382 | + if (empty($handlers)) { |
|
383 | + continue; |
|
384 | + } |
|
385 | + else if (count($handlers) == 1) { |
|
386 | + $_config['on'][$eventName] = '@@'.$handlers[0]; |
|
387 | + } |
|
388 | + else { |
|
389 | + $_config['on'][$eventName] = '@@function (ev){'; |
|
390 | + foreach ($handlers as $handler => $code) { |
|
391 | + $_config['on'][$eventName] .= '('.$code.')(ev);'; |
|
392 | + } |
|
393 | + $_config['on'][$eventName] .= '}'; |
|
394 | + } |
|
395 | + } |
|
396 | + } |
|
397 | + |
|
398 | + return $_config; |
|
399 | + } |
|
400 | + |
|
401 | + /** |
|
402 | + * Return global event handlers. |
|
403 | + */ |
|
404 | + private function returnGlobalEvents() |
|
405 | + { |
|
406 | + static $returnedEvents; |
|
407 | + $out = ""; |
|
408 | + |
|
409 | + if (!isset($returnedEvents)) { |
|
410 | + $returnedEvents = array(); |
|
411 | + } |
|
412 | + |
|
413 | + if (!empty($this->globalEvents)) { |
|
414 | + foreach ($this->globalEvents as $eventName => $handlers) { |
|
415 | + foreach ($handlers as $handler => $code) { |
|
416 | + if (!isset($returnedEvents[$eventName])) { |
|
417 | + $returnedEvents[$eventName] = array(); |
|
418 | + } |
|
419 | + // Return only new events |
|
420 | + if (!in_array($code, $returnedEvents[$eventName])) { |
|
421 | + $out .= ($code ? "\n" : "") . "CKEDITOR.on('". $eventName ."', $code);"; |
|
422 | + $returnedEvents[$eventName][] = $code; |
|
423 | + } |
|
424 | + } |
|
425 | + } |
|
426 | + } |
|
427 | + |
|
428 | + return $out; |
|
429 | + } |
|
430 | + |
|
431 | + /** |
|
432 | + * Initializes CKEditor (executed only once). |
|
433 | + */ |
|
434 | + private function init() |
|
435 | + { |
|
436 | + static $initComplete; |
|
437 | + $out = ""; |
|
438 | + |
|
439 | + if (!empty($initComplete)) { |
|
440 | + return ""; |
|
441 | + } |
|
442 | + |
|
443 | + if ($this->initialized) { |
|
444 | + $initComplete = true; |
|
445 | + return ""; |
|
446 | + } |
|
447 | + |
|
448 | + $args = ""; |
|
449 | + $ckeditorPath = $this->ckeditorPath(); |
|
450 | + |
|
451 | + if (!empty($this->timestamp) && $this->timestamp != "%"."TIMESTAMP%") { |
|
452 | + $args = '?t=' . $this->timestamp; |
|
453 | + } |
|
454 | + |
|
455 | + // Skip relative paths... |
|
456 | + if (strpos($ckeditorPath, '..') !== 0) { |
|
457 | + $out .= $this->script("window.CKEDITOR_BASEPATH='". $ckeditorPath ."';"); |
|
458 | + } |
|
459 | + |
|
460 | + $out .= "<script type=\"text/javascript\" src=\"" . $ckeditorPath . 'ckeditor.js' . $args . "\"></script>\n"; |
|
461 | + |
|
462 | + $extraCode = ""; |
|
463 | + if ($this->timestamp != self::timestamp) { |
|
464 | + $extraCode .= ($extraCode ? "\n" : "") . "CKEDITOR.timestamp = '". $this->timestamp ."';"; |
|
465 | + } |
|
466 | + if ($extraCode) { |
|
467 | + $out .= $this->script($extraCode); |
|
468 | + } |
|
469 | + |
|
470 | + $initComplete = $this->initialized = true; |
|
471 | + |
|
472 | + return $out; |
|
473 | + } |
|
474 | + |
|
475 | + /** |
|
476 | + * Return path to ckeditor.js. |
|
477 | + */ |
|
478 | + private function ckeditorPath() |
|
479 | + { |
|
480 | + if (!empty($this->basePath)) { |
|
481 | + return $this->basePath; |
|
482 | + } |
|
483 | + |
|
484 | + /** |
|
485 | + * The absolute pathname of the currently executing script. |
|
486 | + * Note: If a script is executed with the CLI, as a relative path, such as file.php or ../file.php, |
|
487 | + * $_SERVER['SCRIPT_FILENAME'] will contain the relative path specified by the user. |
|
488 | + */ |
|
489 | + if (isset($_SERVER['SCRIPT_FILENAME'])) { |
|
490 | + $realPath = dirname($_SERVER['SCRIPT_FILENAME']); |
|
491 | + } |
|
492 | + else { |
|
493 | + /** |
|
494 | + * realpath - Returns canonicalized absolute pathname |
|
495 | + */ |
|
496 | + $realPath = realpath( './' ) ; |
|
497 | + } |
|
498 | + |
|
499 | + /** |
|
500 | + * The filename of the currently executing script, relative to the document root. |
|
501 | + * For instance, $_SERVER['PHP_SELF'] in a script at the address http://example.com/test.php/foo.bar |
|
502 | + * would be /test.php/foo.bar. |
|
503 | + */ |
|
504 | + $selfPath = dirname($_SERVER['PHP_SELF']); |
|
505 | + $file = str_replace("\\", "/", __FILE__); |
|
506 | + |
|
507 | + if (!$selfPath || !$realPath || !$file) { |
|
508 | + return "/ckeditor/"; |
|
509 | + } |
|
510 | + |
|
511 | + $documentRoot = substr($realPath, 0, strlen($realPath) - strlen($selfPath)); |
|
512 | + $fileUrl = substr($file, strlen($documentRoot)); |
|
513 | + $ckeditorUrl = str_replace("ckeditor_php5.php", "", $fileUrl); |
|
514 | + |
|
515 | + return $ckeditorUrl; |
|
516 | + } |
|
517 | + |
|
518 | + /** |
|
519 | + * This little function provides a basic JSON support. |
|
520 | + * |
|
521 | + * @param mixed $val |
|
522 | + * @return string |
|
523 | + */ |
|
524 | + private function jsEncode($val) |
|
525 | + { |
|
526 | + if (is_null($val)) { |
|
527 | + return 'null'; |
|
528 | + } |
|
529 | + if (is_bool($val)) { |
|
530 | + return $val ? 'true' : 'false'; |
|
531 | + } |
|
532 | + if (is_int($val)) { |
|
533 | + return $val; |
|
534 | + } |
|
535 | + if (is_float($val)) { |
|
536 | + return str_replace(',', '.', $val); |
|
537 | + } |
|
538 | + if (is_array($val) || is_object($val)) { |
|
539 | + if (is_array($val) && (array_keys($val) === range(0,count($val)-1))) { |
|
540 | + return '[' . implode(',', array_map(array($this, 'jsEncode'), $val)) . ']'; |
|
541 | + } |
|
542 | + $temp = array(); |
|
543 | + foreach ($val as $k => $v){ |
|
544 | + $temp[] = $this->jsEncode("{$k}") . ':' . $this->jsEncode($v); |
|
545 | + } |
|
546 | + return '{' . implode(',', $temp) . '}'; |
|
547 | + } |
|
548 | + // String otherwise |
|
549 | + if (strpos($val, '@@') === 0) |
|
550 | + return substr($val, 2); |
|
551 | + if (strtoupper(substr($val, 0, 9)) == 'CKEDITOR.') |
|
552 | + return $val; |
|
553 | + |
|
554 | + return '"' . str_replace(array("\\", "/", "\n", "\t", "\r", "\x08", "\x0c", '"'), array('\\\\', '\\/', '\\n', '\\t', '\\r', '\\b', '\\f', '\"'), $val) . '"'; |
|
555 | + } |
|
556 | 556 | } |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | * When %CKEditor is created with the editor() method, a HTML <textarea> element is created, |
74 | 74 | * it will be displayed to anyone with JavaScript disabled or with incompatible browser. |
75 | 75 | */ |
76 | - public $textareaAttributes = array( "rows" => 8, "cols" => 60 ); |
|
76 | + public $textareaAttributes = array("rows" => 8, "cols" => 60); |
|
77 | 77 | /** |
78 | 78 | * A string indicating the creation date of %CKEditor. |
79 | 79 | * Do not change it unless you want to force browsers to not use previously cached version of %CKEditor. |
@@ -132,9 +132,9 @@ discard block |
||
132 | 132 | { |
133 | 133 | $attr = ""; |
134 | 134 | foreach ($this->textareaAttributes as $key => $val) { |
135 | - $attr.= " " . $key . '="' . str_replace('"', '"', $val) . '"'; |
|
135 | + $attr .= " ".$key.'="'.str_replace('"', '"', $val).'"'; |
|
136 | 136 | } |
137 | - $out = "<textarea name=\"" . $name . "\"" . $attr . ">" . htmlspecialchars($value) . "</textarea>\n"; |
|
137 | + $out = "<textarea name=\"".$name."\"".$attr.">".htmlspecialchars($value)."</textarea>\n"; |
|
138 | 138 | if (!$this->initialized) { |
139 | 139 | $out .= $this->init(); |
140 | 140 | } |
@@ -235,11 +235,11 @@ discard block |
||
235 | 235 | $classDetection = ""; |
236 | 236 | $js .= "CKEDITOR.replaceAll( function(textarea, config) {\n"; |
237 | 237 | if (!empty($className)) { |
238 | - $js .= " var classRegex = new RegExp('(?:^| )' + '". $className ."' + '(?:$| )');\n"; |
|
238 | + $js .= " var classRegex = new RegExp('(?:^| )' + '".$className."' + '(?:$| )');\n"; |
|
239 | 239 | $js .= " if (!classRegex.test(textarea.className))\n"; |
240 | 240 | $js .= " return false;\n"; |
241 | 241 | } |
242 | - $js .= " CKEDITOR.tools.extend(config, ". $this->jsEncode($_config) .", true);"; |
|
242 | + $js .= " CKEDITOR.tools.extend(config, ".$this->jsEncode($_config).", true);"; |
|
243 | 243 | $js .= "} );"; |
244 | 244 | |
245 | 245 | } |
@@ -378,7 +378,7 @@ discard block |
||
378 | 378 | } |
379 | 379 | |
380 | 380 | if (!empty($_events)) { |
381 | - foreach($_events as $eventName => $handlers) { |
|
381 | + foreach ($_events as $eventName => $handlers) { |
|
382 | 382 | if (empty($handlers)) { |
383 | 383 | continue; |
384 | 384 | } |
@@ -418,7 +418,7 @@ discard block |
||
418 | 418 | } |
419 | 419 | // Return only new events |
420 | 420 | if (!in_array($code, $returnedEvents[$eventName])) { |
421 | - $out .= ($code ? "\n" : "") . "CKEDITOR.on('". $eventName ."', $code);"; |
|
421 | + $out .= ($code ? "\n" : "")."CKEDITOR.on('".$eventName."', $code);"; |
|
422 | 422 | $returnedEvents[$eventName][] = $code; |
423 | 423 | } |
424 | 424 | } |
@@ -449,19 +449,19 @@ discard block |
||
449 | 449 | $ckeditorPath = $this->ckeditorPath(); |
450 | 450 | |
451 | 451 | if (!empty($this->timestamp) && $this->timestamp != "%"."TIMESTAMP%") { |
452 | - $args = '?t=' . $this->timestamp; |
|
452 | + $args = '?t='.$this->timestamp; |
|
453 | 453 | } |
454 | 454 | |
455 | 455 | // Skip relative paths... |
456 | 456 | if (strpos($ckeditorPath, '..') !== 0) { |
457 | - $out .= $this->script("window.CKEDITOR_BASEPATH='". $ckeditorPath ."';"); |
|
457 | + $out .= $this->script("window.CKEDITOR_BASEPATH='".$ckeditorPath."';"); |
|
458 | 458 | } |
459 | 459 | |
460 | - $out .= "<script type=\"text/javascript\" src=\"" . $ckeditorPath . 'ckeditor.js' . $args . "\"></script>\n"; |
|
460 | + $out .= "<script type=\"text/javascript\" src=\"".$ckeditorPath.'ckeditor.js'.$args."\"></script>\n"; |
|
461 | 461 | |
462 | 462 | $extraCode = ""; |
463 | 463 | if ($this->timestamp != self::timestamp) { |
464 | - $extraCode .= ($extraCode ? "\n" : "") . "CKEDITOR.timestamp = '". $this->timestamp ."';"; |
|
464 | + $extraCode .= ($extraCode ? "\n" : "")."CKEDITOR.timestamp = '".$this->timestamp."';"; |
|
465 | 465 | } |
466 | 466 | if ($extraCode) { |
467 | 467 | $out .= $this->script($extraCode); |
@@ -493,7 +493,7 @@ discard block |
||
493 | 493 | /** |
494 | 494 | * realpath - Returns canonicalized absolute pathname |
495 | 495 | */ |
496 | - $realPath = realpath( './' ) ; |
|
496 | + $realPath = realpath('./'); |
|
497 | 497 | } |
498 | 498 | |
499 | 499 | /** |
@@ -536,14 +536,14 @@ discard block |
||
536 | 536 | return str_replace(',', '.', $val); |
537 | 537 | } |
538 | 538 | if (is_array($val) || is_object($val)) { |
539 | - if (is_array($val) && (array_keys($val) === range(0,count($val)-1))) { |
|
540 | - return '[' . implode(',', array_map(array($this, 'jsEncode'), $val)) . ']'; |
|
539 | + if (is_array($val) && (array_keys($val) === range(0, count($val) - 1))) { |
|
540 | + return '['.implode(',', array_map(array($this, 'jsEncode'), $val)).']'; |
|
541 | 541 | } |
542 | 542 | $temp = array(); |
543 | - foreach ($val as $k => $v){ |
|
544 | - $temp[] = $this->jsEncode("{$k}") . ':' . $this->jsEncode($v); |
|
543 | + foreach ($val as $k => $v) { |
|
544 | + $temp[] = $this->jsEncode("{$k}").':'.$this->jsEncode($v); |
|
545 | 545 | } |
546 | - return '{' . implode(',', $temp) . '}'; |
|
546 | + return '{'.implode(',', $temp).'}'; |
|
547 | 547 | } |
548 | 548 | // String otherwise |
549 | 549 | if (strpos($val, '@@') === 0) |
@@ -551,6 +551,6 @@ discard block |
||
551 | 551 | if (strtoupper(substr($val, 0, 9)) == 'CKEDITOR.') |
552 | 552 | return $val; |
553 | 553 | |
554 | - return '"' . str_replace(array("\\", "/", "\n", "\t", "\r", "\x08", "\x0c", '"'), array('\\\\', '\\/', '\\n', '\\t', '\\r', '\\b', '\\f', '\"'), $val) . '"'; |
|
554 | + return '"'.str_replace(array("\\", "/", "\n", "\t", "\r", "\x08", "\x0c", '"'), array('\\\\', '\\/', '\\n', '\\t', '\\r', '\\b', '\\f', '\"'), $val).'"'; |
|
555 | 555 | } |
556 | 556 | } |
@@ -142,10 +142,11 @@ discard block |
||
142 | 142 | $_config = $this->configSettings($config, $events); |
143 | 143 | |
144 | 144 | $js = $this->returnGlobalEvents(); |
145 | - if (!empty($_config)) |
|
146 | - $js .= "CKEDITOR.replace('".$name."', ".$this->jsEncode($_config).");"; |
|
147 | - else |
|
148 | - $js .= "CKEDITOR.replace('".$name."');"; |
|
145 | + if (!empty($_config)) { |
|
146 | + $js .= "CKEDITOR.replace('".$name."', ".$this->jsEncode($_config).");"; |
|
147 | + } else { |
|
148 | + $js .= "CKEDITOR.replace('".$name."');"; |
|
149 | + } |
|
149 | 150 | |
150 | 151 | $out .= $this->script($js); |
151 | 152 | |
@@ -182,8 +183,7 @@ discard block |
||
182 | 183 | $js = $this->returnGlobalEvents(); |
183 | 184 | if (!empty($_config)) { |
184 | 185 | $js .= "CKEDITOR.replace('".$id."', ".$this->jsEncode($_config).");"; |
185 | - } |
|
186 | - else { |
|
186 | + } else { |
|
187 | 187 | $js .= "CKEDITOR.replace('".$id."');"; |
188 | 188 | } |
189 | 189 | $out .= $this->script($js); |
@@ -226,12 +226,10 @@ discard block |
||
226 | 226 | if (empty($_config)) { |
227 | 227 | if (empty($className)) { |
228 | 228 | $js .= "CKEDITOR.replaceAll();"; |
229 | - } |
|
230 | - else { |
|
229 | + } else { |
|
231 | 230 | $js .= "CKEDITOR.replaceAll('".$className."');"; |
232 | 231 | } |
233 | - } |
|
234 | - else { |
|
232 | + } else { |
|
235 | 233 | $classDetection = ""; |
236 | 234 | $js .= "CKEDITOR.replaceAll( function(textarea, config) {\n"; |
237 | 235 | if (!empty($className)) { |
@@ -289,8 +287,7 @@ discard block |
||
289 | 287 | { |
290 | 288 | if (!empty($event)) { |
291 | 289 | $this->events[$event] = array(); |
292 | - } |
|
293 | - else { |
|
290 | + } else { |
|
294 | 291 | $this->events = array(); |
295 | 292 | } |
296 | 293 | } |
@@ -329,8 +326,7 @@ discard block |
||
329 | 326 | { |
330 | 327 | if (!empty($event)) { |
331 | 328 | $this->globalEvents[$event] = array(); |
332 | - } |
|
333 | - else { |
|
329 | + } else { |
|
334 | 330 | $this->globalEvents = array(); |
335 | 331 | } |
336 | 332 | } |
@@ -381,11 +377,9 @@ discard block |
||
381 | 377 | foreach($_events as $eventName => $handlers) { |
382 | 378 | if (empty($handlers)) { |
383 | 379 | continue; |
384 | - } |
|
385 | - else if (count($handlers) == 1) { |
|
380 | + } else if (count($handlers) == 1) { |
|
386 | 381 | $_config['on'][$eventName] = '@@'.$handlers[0]; |
387 | - } |
|
388 | - else { |
|
382 | + } else { |
|
389 | 383 | $_config['on'][$eventName] = '@@function (ev){'; |
390 | 384 | foreach ($handlers as $handler => $code) { |
391 | 385 | $_config['on'][$eventName] .= '('.$code.')(ev);'; |
@@ -488,8 +482,7 @@ discard block |
||
488 | 482 | */ |
489 | 483 | if (isset($_SERVER['SCRIPT_FILENAME'])) { |
490 | 484 | $realPath = dirname($_SERVER['SCRIPT_FILENAME']); |
491 | - } |
|
492 | - else { |
|
485 | + } else { |
|
493 | 486 | /** |
494 | 487 | * realpath - Returns canonicalized absolute pathname |
495 | 488 | */ |
@@ -546,10 +539,12 @@ discard block |
||
546 | 539 | return '{' . implode(',', $temp) . '}'; |
547 | 540 | } |
548 | 541 | // String otherwise |
549 | - if (strpos($val, '@@') === 0) |
|
550 | - return substr($val, 2); |
|
551 | - if (strtoupper(substr($val, 0, 9)) == 'CKEDITOR.') |
|
552 | - return $val; |
|
542 | + if (strpos($val, '@@') === 0) { |
|
543 | + return substr($val, 2); |
|
544 | + } |
|
545 | + if (strtoupper(substr($val, 0, 9)) == 'CKEDITOR.') { |
|
546 | + return $val; |
|
547 | + } |
|
553 | 548 | |
554 | 549 | return '"' . str_replace(array("\\", "/", "\n", "\t", "\r", "\x08", "\x0c", '"'), array('\\\\', '\\/', '\\n', '\\t', '\\r', '\\b', '\\f', '\"'), $val) . '"'; |
555 | 550 | } |
@@ -3,7 +3,7 @@ |
||
3 | 3 | class Index extends My_Force_Login { |
4 | 4 | |
5 | 5 | public function __construct() { |
6 | - parent::__construct(); |
|
6 | + parent::__construct(); |
|
7 | 7 | |
8 | 8 | } |
9 | 9 |
@@ -3,7 +3,7 @@ |
||
3 | 3 | class Index extends My_Force_Login { |
4 | 4 | |
5 | 5 | public function __construct() { |
6 | - parent::__construct(); |
|
6 | + parent::__construct(); |
|
7 | 7 | |
8 | 8 | } |
9 | 9 |
@@ -2,7 +2,7 @@ |
||
2 | 2 | defined('BASEPATH') OR exit('No direct script access allowed'); |
3 | 3 | |
4 | 4 | echo "\nERROR: ", |
5 | - $heading, |
|
6 | - "\n\n", |
|
7 | - $message, |
|
8 | - "\n\n"; |
|
9 | 5 | \ No newline at end of file |
6 | + $heading, |
|
7 | + "\n\n", |
|
8 | + $message, |
|
9 | + "\n\n"; |
|
10 | 10 | \ No newline at end of file |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | <input type="button" value="Approve" name="approve" class="btn btn-default" onclick="location.href = '<?= base_url('computing-support/room-move/eh-approve?id='.$room['id']); ?>';"/> |
74 | 74 | <input type="button" value="Reject" name="reject" class="btn btn-default" onclick="location.href = '<?= base_url('computing-support/room-move/history?reid='.$room['id']); ?>';"/> |
75 | 75 | <?php break; |
76 | - default: ?> |
|
76 | + default: ?> |
|
77 | 77 | No action Required |
78 | 78 | <?php break; ?> |
79 | 79 | <?php } } elseif (in_array('CN=Dashboard_CS_NS,OU=Dashboard_Group,OU=Intranet_Group,OU=Groups,DC=cant-col,DC=ac,DC=uk', $_SESSION['ldap']['groups'])) { ?> |
@@ -82,14 +82,14 @@ discard block |
||
82 | 82 | <input type="button" value="Overide Estates" name="overide_approve" class="btn btn-default" data-toggle="modal" data-target="#overide"/> |
83 | 83 | <input type="button" value="Reject" name="reject" class="btn btn-default" onclick="location.href = '<?= base_url('computing-support/room-move/history?rcid='.$room['id']); ?>';"/> |
84 | 84 | <?php break; |
85 | - case 1: ?> |
|
85 | + case 1: ?> |
|
86 | 86 | <input type="button" value="Approve" name="approve" class="btn btn-default" onclick="location.href = '<?= base_url('computing-support/room-move/cs-approve?id='.$room['id']); ?>';"/> |
87 | 87 | <input type="button" value="Reject" name="reject" class="btn btn-default" onclick="location.href = '<?= base_url('computing-support/room-move/history?rcid='.$room['id']); ?>';"/> |
88 | 88 | <?php break; |
89 | - case 5: ?> |
|
89 | + case 5: ?> |
|
90 | 90 | <input type="button" value="Move Complete" name="complete" class="btn btn-default" onclick="location.href = '<?= base_url('computing-support/room-move/cs-complete?id='.$room['id']); ?>';"/> |
91 | 91 | <?php break; |
92 | - default: ?> |
|
92 | + default: ?> |
|
93 | 93 | No action Required |
94 | 94 | <?php break; }?> |
95 | 95 | <?php } ?> |
@@ -32,15 +32,15 @@ discard block |
||
32 | 32 | <td><?= $room['furniture'] ?></td> |
33 | 33 | <td> |
34 | 34 | <?= $room['staff_involved'] ?> |
35 | - <?php if (isset($room['staff_involved2'])) { echo '<br>'. $room['staff_involved2']; } ?> |
|
36 | - <?php if (isset($room['staff_involved3'])) { echo '<br>'. $room['staff_involved3']; } ?> |
|
37 | - <?php if (isset($room['staff_involved4'])) { echo '<br>'. $room['staff_involved4']; } ?> |
|
38 | - <?php if (isset($room['staff_involved5'])) { echo '<br>'. $room['staff_involved5']; } ?> |
|
39 | - <?php if (isset($room['staff_involved6'])) { echo '<br>'. $room['staff_involved6']; } ?> |
|
40 | - <?php if (isset($room['staff_involved7'])) { echo '<br>'. $room['staff_involved7']; } ?> |
|
41 | - <?php if (isset($room['staff_involved8'])) { echo '<br>'. $room['staff_involved8']; } ?> |
|
42 | - <?php if (isset($room['staff_involved9'])) { echo '<br>'. $room['staff_involved9']; } ?> |
|
43 | - <?php if (isset($room['staff_involved10'])) { echo '<br>'. $room['staff_involved10']; } ?> |
|
35 | + <?php if (isset($room['staff_involved2'])) { echo '<br>'.$room['staff_involved2']; } ?> |
|
36 | + <?php if (isset($room['staff_involved3'])) { echo '<br>'.$room['staff_involved3']; } ?> |
|
37 | + <?php if (isset($room['staff_involved4'])) { echo '<br>'.$room['staff_involved4']; } ?> |
|
38 | + <?php if (isset($room['staff_involved5'])) { echo '<br>'.$room['staff_involved5']; } ?> |
|
39 | + <?php if (isset($room['staff_involved6'])) { echo '<br>'.$room['staff_involved6']; } ?> |
|
40 | + <?php if (isset($room['staff_involved7'])) { echo '<br>'.$room['staff_involved7']; } ?> |
|
41 | + <?php if (isset($room['staff_involved8'])) { echo '<br>'.$room['staff_involved8']; } ?> |
|
42 | + <?php if (isset($room['staff_involved9'])) { echo '<br>'.$room['staff_involved9']; } ?> |
|
43 | + <?php if (isset($room['staff_involved10'])) { echo '<br>'.$room['staff_involved10']; } ?> |
|
44 | 44 | </td> |
45 | 45 | <td width="20%"><?= $room['reason'] ?></td> |
46 | 46 | <?php switch ($room['status']) { |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | <?php break; |
65 | 65 | case 6: ?> |
66 | 66 | <td class='success'>Move Complete</td> |
67 | - <?php break;?> |
|
67 | + <?php break; ?> |
|
68 | 68 | <?php } ?> |
69 | 69 | <td> |
70 | 70 | <?php if (in_array('CN=Dashboard_Estates_Room_Move,OU=Dashboard_Group,OU=Intranet_Group,OU=Groups,DC=cant-col,DC=ac,DC=uk', $_SESSION['ldap']['groups'])) { ?> |
@@ -7,7 +7,7 @@ |
||
7 | 7 | $query = $this->db->get('users_ad'); |
8 | 8 | if ($query->num_rows() > 0) { |
9 | 9 | foreach ($query->result_array() as $row) { |
10 | - $row_set[] = htmlentities(stripslashes($row['first_name'] . ' ' . $row['last_name'] . ' (' . $row['username'] . ')')); //build an array |
|
10 | + $row_set[] = htmlentities(stripslashes($row['first_name'].' '.$row['last_name'].' ('.$row['username'].')')); //build an array |
|
11 | 11 | } |
12 | 12 | } |
13 | 13 | ?> |