Repository navigation
Expand file tree
/
Copy path_inlines.plugin.php
More file actions
259 lines (217 loc) · 6.24 KB
/
Copy path_inlines.plugin.php
File metadata and controls
259 lines (217 loc) · 6.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
<?php
/**
* This file implements the Inlines Toolbar plugin for b2evolution
*
* b2evolution - {@link http://b2evolution.net/}
* Released under GNU GPL License - {@link http://b2evolution.net/about/gnu-gpl-license}
* @copyright (c)2003-2017 by Francois Planque - {@link http://fplanque.com/}
*
* @package plugins
*/
if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
/**
* @package plugins
*/
class inlines_plugin extends Plugin
{
var $code = 'evo_inlines';
var $name = 'Inline Short Tags';
var $priority = 50;
var $version = '6.9.4';
var $group = 'editor';
var $number_of_installs = 1;
/**
* Init
*/
function PluginInit( & $params )
{
$this->short_desc = T_('Inline short tags inserting');
$this->long_desc = T_('This plugin will display a toolbar with buttons to quickly insert inline short tags.');
}
/**
* Event handler: Called when displaying editor toolbars on post/item form.
*
* This is for post/item edit forms only. Comments, PMs and emails use different events.
*
* @param array Associative array of parameters
* @return boolean did we display a toolbar?
*/
function AdminDisplayToolbar( & $params )
{
$Item = & $params['Item'];
if( empty( $Item ) )
{
return false;
}
$item_Blog = & $Item->get_Blog();
if( ! $this->get_coll_setting( 'coll_use_for_posts', $item_Blog ) )
{ // This plugin is disabled to use for posts:
return false;
}
$params['target_type'] = 'Item';
return $this->DisplayCodeToolbar( $params );
}
/**
* Event handler: Called when displaying editor toolbars on comment form.
*
* @param array Associative array of parameters
* @return boolean did we display a toolbar?
*/
function DisplayCommentToolbar( & $params )
{
$Comment = & $params['Comment'];
if( $Comment )
{ // Get a post of the comment:
$comment_Item = & $Comment->get_Item();
}
if( empty( $comment_Item ) )
{
return false;
}
$item_Blog = & $comment_Item->get_Blog();
if( ! $this->get_coll_setting( 'coll_use_for_comments', $item_Blog ) )
{ // This plugin is disabled to use for comments:
return false;
}
$params['target_type'] = 'Comment';
return $this->DisplayCodeToolbar( $params );
}
/**
* Event handler: Called when displaying editor toolbars for email.
*
* @param array Associative array of parameters
* @return boolean did we display a toolbar?
*/
function DisplayEmailToolbar( & $params )
{
$params['target_type'] = 'EmailCampaign';
return $this->DisplayCodeToolbar( $params );
}
/**
* Event handler: Called when displaying editor toolbars for message.
*
* @param array Associative array of parameters
* @return boolean did we display a toolbar?
*/
function DisplayMessageToolbar( & $params )
{
$params['target_type'] = 'Message';
return $this->DisplayCodeToolbar( $params );
}
/**
* Display a code toolbar
*
* @param array Associative array of parameters
* @return boolean did we display a toolbar?
*/
function DisplayCodeToolbar( & $params )
{
global $Hit, $blog;
if( $Hit->is_lynx() )
{ // let's deactivate quicktags on Lynx, because they don't work there.
return false;
}
$params = array_merge( array(
'js_prefix' => '', // Use different prefix if you use several toolbars on one page
), $params );
$temp_ID = empty( $params['temp_ID'] ) ? NULL : $params['temp_ID'];
// Load js to work with textarea
require_js_defer( 'functions.js', 'blog', true );
switch( $params['target_type'] )
{
case 'Item':
$Item = & $params['Item'];
$target_ID = $Item->ID;
if( empty( $target_ID ) && empty( $temp_ID ) )
{
return false;
}
break;
case 'Comment':
$Comment = & $params['Comment'];
$target_ID = $Comment->ID;
if( empty( $target_ID ) )
{
return false;
}
break;
case 'EmailCampaign':
$EmailCampaign = & $params['EmailCampaign'];
$target_ID = $EmailCampaign->ID;
if( empty( $target_ID ) )
{
return false;
}
break;
case 'Message':
$Message = & $params['Message'];
$target_ID = empty( $Message ) ? NULL : $Message->ID;
if( empty( $target_ID ) && empty( $temp_ID ) )
{
return false;
}
break;
default:
return false;
}
$insert_inline_params = array(
'target_ID' => $target_ID,
'target_type' => $params['target_type'],
'request_from' => is_admin_page() ? 'back' : 'front',
);
if( isset( $blog ) )
{
$insert_inline_params['blog'] = $blog;
}
if( isset( $temp_ID ) )
{
$insert_inline_params['temp_ID'] = $temp_ID;
}
$js_config = array(
'prefix' => $params['js_prefix'],
'plugin_code' => $this->code,
'target_ID' => empty( $target_ID ) ? NULL : format_to_js( $target_ID ),
'temp_ID' => empty( $temp_ID ) ? NULL : format_to_js( $temp_ID ),
'target_type' => format_to_js( $params['target_type'] ),
'toolbar_title_before' => format_to_js( $this->get_template( 'toolbar_title_before' ) ),
'toolbar_title_after' => format_to_js( $this->get_template( 'toolbar_title_after' ) ),
'toolbar_group_before' => format_to_js( $this->get_template( 'toolbar_group_before' ) ),
'toolbar_group_after' => format_to_js( $this->get_template( 'toolbar_group_after' ) ),
'toolbar_title' => T_('Inlines').': ',
'button_title' => T_('inline image'),
'button_class' => $this->get_template( 'toolbar_button_class' ),
'insert_inline_url' => $this->get_htsrv_url( 'insert_inline', $insert_inline_params, '&' ),
);
if( is_ajax_request() )
{
?>
<script>
jQuery( document ).ready( function() {
window.evo_init_inlines_toolbar( <?php echo evo_json_encode( $js_config ); ?> );
} );
</script>
<?php
}
else
{
expose_var_to_js( 'inlines_toolbar_'.$params['js_prefix'], $js_config, 'evo_init_inlines_toolbar_config' );
}
echo $this->get_template( 'toolbar_before', array( '$toolbar_class$' => $params['js_prefix'].$this->code.'_toolbar' ) );
echo $this->get_template( 'toolbar_after' );
return true;
}
function GetHtsrvMethods()
{
return array( 'insert_inline' );
}
/**
* Load insert image links
*
* @param array Params
*/
function htsrv_insert_inline( $params )
{
insert_image_links_block( $params );
}
}
?>