-
Notifications
You must be signed in to change notification settings - Fork 1
/
AllInOne.php
315 lines (281 loc) · 8.68 KB
/
AllInOne.php
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
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
<?php
class Sedo_TinyQuattro_Listener_AllInOne
{
/***
* Diktat mode - Inline Edit
**/
public static function controllerPreDispatch(XenForo_Controller $controller, $action)
{
$options = XenForo_Application::get('options');
if( $options->quattro_disable_mobile_inline_edit
&& (Sedo_TinyQuattro_Helper_Quattro::isEnabled(false, array(null, null, null)) || $options->currentVersionId < 1020031)
&& XenForo_Visitor::isBrowsingWith('mobile')
&& XenForo_Visitor::getInstance()->enable_rte
)
{
//No matter here mobiles or only tablets, stwich off the overlay edit
$options->messageInlineEdit = 0;
}
if(!XenForo_Application::isRegistered('session'))
{
return;
}
if($controller->getResponseType() != 'json')
{
$requestPaths = XenForo_Application::get('requestPaths');
$data = array(
'noJsonRequestPaths' => $requestPaths
);
XenForo_Application::getSession()->set('sedoQuattro', $data);
}
}
/***
* Extend ControllerPublic editor
**/
public static function ControllerPublicEditor($class, array &$extend)
{
if ($class == 'XenForo_ControllerPublic_Editor')
{
$extend[] = 'Sedo_TinyQuattro_ControllerPublic_Editor';
}
}
/***
* Bb Code Formatter
**/
public static function BbCodeBaseFormatter($class, array &$extend)
{
if ($class == 'XenForo_BbCode_Formatter_Base')
{
$extend[] = 'Sedo_TinyQuattro_BbCode_Formatter_Base';
}
}
/***
* Wysiwyg Formatter
**/
public static function BbCodeWysiwygFormatter($class, array &$extend)
{
if ($class == 'XenForo_BbCode_Formatter_Wysiwyg')
{
$extend[] = 'Sedo_TinyQuattro_BbCode_Formatter_Wysiwyg';
}
}
/***
* Extend the html renderer BbCode (html=>bbcode) ; ie: background-color
**/
public static function LoadClassRendererBbCode($class, array &$extend)
{
if ($class == 'XenForo_Html_Renderer_BbCode')
{
$extend[] = 'Sedo_TinyQuattro_Html_Renderer_BbCode';
}
}
/***
* Extend the html renderer BbCode (html=>bbcode) ; ie: background-color
**/
public static function LoadClassControllerHelperEditor($class, array &$extend)
{
if ($class == 'XenForo_ControllerHelper_Editor')
{
$extend[] = 'Sedo_TinyQuattro_ControllerHelper_Editor';
}
}
/***
* Extend DW
**/
protected static $_loadedXen11 = array(); //Fix a bug with XenForo 1.1 (mostly for test purpose)
public static function ExtendDatawriter($class, array &$extend)
{
switch ($class)
{
case 'XenForo_DataWriter_User':
if (XenForo_Application::get('options')->get('quattro_parser_mobile_user_option'))
{
$extend[] = 'Sedo_TinyQuattro_Datawriter_User_MobileOption';
}
break;
case 'XenForo_DataWriter_DiscussionMessage_Post':
if (XenForo_Application::get('options')->get('quattro_parser_fourws_to_tab') && Sedo_TinyQuattro_Helper_Quattro::isOldXen())
{
//2015/02/10: Should not be needed anymore with Sedo_TinyQuattro_Html_Renderer_BbCode::preFilter
$name = 'Sedo_TinyQuattro_Datawriter_DiscussionMessage_Post';
if(!isset(self::$_loadedXen11[$name]))
{
$extend[] = $name;
self::$_loadedXen11[$name] = true;
}
}
break;
case 'XenForo_DataWriter_ConversationMessage':
if (XenForo_Application::get('options')->get('quattro_parser_fourws_to_tab') && Sedo_TinyQuattro_Helper_Quattro::isOldXen())
{
//2015/02/10: Should not be needed anymore with Sedo_TinyQuattro_Html_Renderer_BbCode::preFilter
$name = 'Sedo_TinyQuattro_Datawriter_ConversationMessage';
if(!isset(self::$_loadedXen11[$name]))
{
$extend[] = $name;
self::$_loadedXen11[$name] = true;
}
}
break;
}
}
/***
* Extend Smilie Model
**/
public static function ExtendSmilieModel($class, array &$extend)
{
if($class == 'XenForo_Model_Smilie')
{
$extend[] = 'Sedo_TinyQuattro_Model_Smilie';
}
}
/***
* Editor setup: for mce modal/ovl attach.
**/
public static function editorSetup(XenForo_View $view, $formCtrlName, &$message, array &$editorOptions, &$showWysiwyg)
{
$viewParams = $view->getParams();
$hash = $type = $id = '';
if(!empty($viewParams['forum']['node_id']))
{
$type = 'newThread';
$id = $viewParams['forum']['node_id'];
}
if(!empty($viewParams['thread']['thread_id']))
{
$type = 'newPost';
$id = $viewParams['thread']['thread_id'];
}
if(!empty($viewParams['post']['post_id']))
{
$type = 'edit';
$id = $viewParams['post']['post_id'];
}
if(!empty($viewParams['resource']))
{
if(!empty($viewParams['resource']['resource_id']))
{
$id = $viewParams['resource']['resource_id'];
$type = 'resource';
}
elseif(isset($viewParams['resource']['resource_category_id']))
{
$id = $viewParams['resource']['resource_category_id'];
$type = 'newResource';
}
}
if(!empty($viewParams['attachmentParams']['hash']))
{
$hash = $viewParams['attachmentParams']['hash'];
}
$extraParams['sedo_quattro']['attach'] = array(
'type' => $type,
'id' => $id,
'hash' => $hash
);
if(is_array($editorOptions))
{
$editorOptions += $extraParams;
}
else
{
$editorOptions = $extraParams;
}
}
/***
* Template helper - PlayWithColors
**/
public static function init_helpers(XenForo_Dependencies_Abstract $dependencies, array $data)
{
if(!isset(XenForo_Template_Helper_Core::$helperCallbacks['playwithcolors']))
{
XenForo_Template_Helper_Core::$helperCallbacks += array(
'playwithcolors' => array('Sedo_TinyQuattro_Helper_PlayWithColors', 'init')
);
}
XenForo_Template_Helper_Core::$helperCallbacks += array(
'get_mce_js_version' => array('Sedo_TinyQuattro_Helper_Quattro', 'getMceJsVersion')
);
}
/***
* Extend View Public - to Bb Code (BbCode <=> Html converter fix)
**/
public static function ViewPublicEditorToBbCode($class, array &$extend)
{
if ($class == 'XenForo_ViewPublic_Editor_ToBbCode')
{
$extend[] = 'Sedo_TinyQuattro_ViewPublic_Editor_ToBbCode';
}
}
/***
* Extend View Public - to Html
**/
public static function ViewPublicEditorToHtml($class, array &$extend)
{
if ($class == 'XenForo_ViewPublic_Editor_ToHtml')
{
$extend[] = 'Sedo_TinyQuattro_ViewPublic_Editor_ToHtml';
}
}
/***
* Get Mce Config and set it as an application + CCV management
**/
public static function controllerPreView(XenForo_FrontController $fc,
XenForo_ControllerResponse_Abstract &$controllerResponse,
XenForo_ViewRenderer_Abstract &$viewRenderer,
array &$containerParams
)
{
self::_controllerPreView($fc, $controllerResponse, $viewRenderer, $containerParams);
}
protected static function _controllerPreView(XenForo_FrontController $fc,
XenForo_ControllerResponse_Abstract &$controllerResponse,
XenForo_ViewRenderer_Abstract &$viewRenderer,
array &$containerParams
)
{
//to do: try to see if the XenForo_Application::getSession can't be used instead in an earlier listener
if(!XenForo_Visitor::getUserId())
{
return;
}
$isControllerAdmin = (strstr($controllerResponse->controllerName, 'ControllerAdmin')) ? true : false;
$controllerName = (isset($controllerResponse->controllerName)) ? $controllerResponse->controllerName : NULL;
$controllerAction = (isset($controllerResponse->controllerAction)) ? $controllerResponse->controllerAction : NULL;
$viewName = (isset($controllerResponse->viewName)) ? $controllerResponse->viewName : NULL;
$isJson = ($viewRenderer instanceof XenForo_ViewRenderer_Json) ? true : false;
if(!$isJson)
{
list($enable, $bbmParams) = Sedo_TinyQuattro_Helper_Quattro::isEnabled(true, array($controllerName, $controllerAction, $viewName));
XenForo_Application::set('mceConfig', array($enable, $bbmParams));
XenForo_Helper_Cookie::setCookie('mce_ccv', "$controllerName,$controllerAction,$viewName");
}
else
{
$bbmCCVConfigs = XenForo_Application::get('options')->get('Bbm_Bm_Cust_Config');
$useCurrentCCV = false;
if(is_array($bbmCCVConfigs))
{
foreach($bbmCCVConfigs as $bbmCCVConfig)
{
if(!empty($bbmCCVConfig['viewname']) && $bbmCCVConfig['viewname'] == $viewName)
{
$useCurrentCCV = true;
break;
}
}
}
if(!$useCurrentCCV)
{
//n-1 ccv
$ccv = explode(',' , XenForo_Helper_Cookie::getCookie('mce_ccv'));
$controllerName = isset($ccv[0]) ? $ccv[0] : null;
$controllerAction = isset($ccv[1]) ? $ccv[1] : null;
$viewName = isset($ccv[2]) ? $ccv[2] : null;
}
list($enable, $bbmParams) = Sedo_TinyQuattro_Helper_Quattro::isEnabled(true, array($controllerName, $controllerAction, $viewName));
XenForo_Application::set('mceConfig', array($enable, $bbmParams));
}
}
}
//Zend_Debug::dump($class);