browser.php
2.8 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
<?php
/**
* @copyright Copyright (c) 2009-2020 Ryan Demmer. All rights reserved
* @license GNU/GPL 2 or later - http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* JCE is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses
*/
defined('JPATH_PLATFORM') or die;
abstract class WfBrowserHelper
{
public static function getBrowserLink($element = null, $filter = '', $callback = '')
{
$options = self::getMediaFieldOptions(array(
'element' => $element,
'filter' => $filter,
'callback' => $callback
));
return $options['url'];
}
public static function getMediaFieldLink($element = null, $filter = 'images', $callback = '')
{
$options = self::getMediaFieldOptions(array(
'element' => $element,
'filter' => $filter,
'callback' => $callback
));
return $options['url'];
}
public static function getMediaFieldOptions($options = array())
{
if (!isset($options['elememt'])) {
$options['element'] = null;
}
if (!isset($options['filter'])) {
$options['filter'] = 'images';
}
if (!isset($options['callback'])) {
$options['callback'] = '';
}
if (!isset($options['converted'])) {
$options['converted'] = false;
}
$app = JFactory::getApplication();
// set $url as empty string
$data = array(
'url' => '',
'upload' => 0
);
// load editor class
require_once JPATH_SITE . '/components/com_jce/editor/libraries/classes/application.php';
// get editor instance
$wf = WFApplication::getInstance();
// check the current user is in a profile
if ($wf->getProfile('browser')) {
// is conversion enabled?
if ($options['converted'] && (int) $wf->getParam('browser.mediafield_conversion', 1) === 0) {
return $data;
}
$token = JFactory::getSession()->getFormToken();
$data['url'] = 'index.php?option=com_jce&task=plugin.display&plugin=browser&standalone=1&' . $token . '=1&client=' . $app->getClientId();
// add context
$data['url'] .= '&context=' . $wf->getContext();
foreach ($options as $key => $value) {
if ($value) {
$data['url'] .= '&' . $key . '=' . $value;
}
}
$data['upload'] = (int) $wf->getParam('browser.mediafield_upload', 1);
}
return $data;
}
}