Code Duplication    Length = 68-68 lines in 2 locations

class/utility.php 1 location

@@ 336-403 (lines=68) @@
333
     * @param  string                                                                                                                         $supplemental
334
     * @return bool|XoopsFormDhtmlTextArea|XoopsFormEditor|XoopsFormFckeditor|XoopsFormHtmlarea|XoopsFormTextArea|XoopsFormTinyeditorTextArea
335
     */
336
    public static function getWysiwygForm($caption, $name, $value = '', $width = '100%', $height = '400px', $supplemental = '')
337
    {
338
        $editor_option            = strtolower(static::getModuleOption('form_options'));
339
        $editor                   = false;
340
        $editor_configs           = [];
341
        $editor_configs['name']   = $name;
342
        $editor_configs['value']  = $value;
343
        $editor_configs['rows']   = 35;
344
        $editor_configs['cols']   = 60;
345
        $editor_configs['width']  = '100%';
346
        $editor_configs['height'] = '350px';
347
        $editor_configs['editor'] = $editor_option;
348
349
        if (static::isX23()) {
350
            $editor = new XoopsFormEditor($caption, $name, $editor_configs);
351
352
            return $editor;
353
        }
354
355
        // Only for Xoops 2.0.x
356
        switch ($editor_option) {
357
            case 'fckeditor':
358
                if (is_readable(XOOPS_ROOT_PATH . '/class/fckeditor/formfckeditor.php')) {
359
                    require_once XOOPS_ROOT_PATH . '/class/fckeditor/formfckeditor.php';
360
                    $editor = new XoopsFormFckeditor($caption, $name, $value);
361
                }
362
                break;
363
364
            case 'htmlarea':
365
                if (is_readable(XOOPS_ROOT_PATH . '/class/htmlarea/formhtmlarea.php')) {
366
                    require_once XOOPS_ROOT_PATH . '/class/htmlarea/formhtmlarea.php';
367
                    $editor = new XoopsFormHtmlarea($caption, $name, $value);
368
                }
369
                break;
370
371
            case 'dhtmltextarea':
372
            case 'dhtml':
373
                $editor = new XoopsFormDhtmlTextArea($caption, $name, $value, 10, 50, $supplemental);
374
                break;
375
376
            case 'textarea':
377
                $editor = new XoopsFormTextArea($caption, $name, $value);
378
                break;
379
380
            case 'tinyeditor':
381
            case 'tinymce':
382
                if (is_readable(XOOPS_ROOT_PATH . '/class/xoopseditor/tinyeditor/formtinyeditortextarea.php')) {
383
                    require_once XOOPS_ROOT_PATH . '/class/xoopseditor/tinyeditor/formtinyeditortextarea.php';
384
                    $editor = new XoopsFormTinyeditorTextArea([
385
                                                                  'caption' => $caption,
386
                                                                  'name'    => $name,
387
                                                                  'value'   => $value,
388
                                                                  'width'   => '100%',
389
                                                                  'height'  => '400px'
390
                                                              ]);
391
                }
392
                break;
393
394
            case 'koivi':
395
                if (is_readable(XOOPS_ROOT_PATH . '/class/wysiwyg/formwysiwygtextarea.php')) {
396
                    require_once XOOPS_ROOT_PATH . '/class/wysiwyg/formwysiwygtextarea.php';
397
                    $editor = new XoopsFormWysiwygTextArea($caption, $name, $value, $width, $height, '');
398
                }
399
                break;
400
        }
401
402
        return $editor;
403
    }
404
405
    /**
406
     * Internal function

include/functions.php 1 location

@@ 214-281 (lines=68) @@
211
 * @param  string                                                                                                                         $supplemental
212
 * @return bool|XoopsFormDhtmlTextArea|XoopsFormEditor|XoopsFormFckeditor|XoopsFormHtmlarea|XoopsFormTextArea|XoopsFormTinyeditorTextArea
213
 */
214
function news_getWysiwygForm($caption, $name, $value = '', $width = '100%', $height = '400px', $supplemental = '')
215
{
216
    $editor_option            = strtolower(news_getmoduleoption('form_options'));
217
    $editor                   = false;
218
    $editor_configs           = [];
219
    $editor_configs['name']   = $name;
220
    $editor_configs['value']  = $value;
221
    $editor_configs['rows']   = 35;
222
    $editor_configs['cols']   = 60;
223
    $editor_configs['width']  = '100%';
224
    $editor_configs['height'] = '350px';
225
    $editor_configs['editor'] = $editor_option;
226
227
    if (news_isX23()) {
228
        $editor = new XoopsFormEditor($caption, $name, $editor_configs);
229
230
        return $editor;
231
    }
232
233
    // Only for Xoops 2.0.x
234
    switch ($editor_option) {
235
        case 'fckeditor':
236
            if (is_readable(XOOPS_ROOT_PATH . '/class/fckeditor/formfckeditor.php')) {
237
                require_once XOOPS_ROOT_PATH . '/class/fckeditor/formfckeditor.php';
238
                $editor = new XoopsFormFckeditor($caption, $name, $value);
239
            }
240
            break;
241
242
        case 'htmlarea':
243
            if (is_readable(XOOPS_ROOT_PATH . '/class/htmlarea/formhtmlarea.php')) {
244
                require_once XOOPS_ROOT_PATH . '/class/htmlarea/formhtmlarea.php';
245
                $editor = new XoopsFormHtmlarea($caption, $name, $value);
246
            }
247
            break;
248
249
        case 'dhtmltextarea':
250
        case 'dhtml':
251
            $editor = new XoopsFormDhtmlTextArea($caption, $name, $value, 10, 50, $supplemental);
252
            break;
253
254
        case 'textarea':
255
            $editor = new XoopsFormTextArea($caption, $name, $value);
256
            break;
257
258
        case 'tinyeditor':
259
        case 'tinymce':
260
            if (is_readable(XOOPS_ROOT_PATH . '/class/xoopseditor/tinyeditor/formtinyeditortextarea.php')) {
261
                require_once XOOPS_ROOT_PATH . '/class/xoopseditor/tinyeditor/formtinyeditortextarea.php';
262
                $editor = new XoopsFormTinyeditorTextArea([
263
                                                              'caption' => $caption,
264
                                                              'name'    => $name,
265
                                                              'value'   => $value,
266
                                                              'width'   => '100%',
267
                                                              'height'  => '400px'
268
                                                          ]);
269
            }
270
            break;
271
272
        case 'koivi':
273
            if (is_readable(XOOPS_ROOT_PATH . '/class/wysiwyg/formwysiwygtextarea.php')) {
274
                require_once XOOPS_ROOT_PATH . '/class/wysiwyg/formwysiwygtextarea.php';
275
                $editor = new XoopsFormWysiwygTextArea($caption, $name, $value, $width, $height, '');
276
            }
277
            break;
278
    }
279
280
    return $editor;
281
}
282
283
/**
284
 * Internal function