1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23:
24: $plugin_is_filter = 5 | ADMIN_PLUGIN;
25: $plugin_description = gettext('Provides file handling for the <code>upload/files</code> tab and the <em>TinyMCE</em> file browser.');
26: $plugin_author = "Stephen Billard (sbillard)";
27:
28: $option_interface = 'elFinder_options';
29:
30: 31: 32: 33:
34: class elFinder_options {
35:
36: 37: 38: 39:
40: function __construct() {
41: setOptionDefault('elFinder_files', 1);
42: setOptionDefault('elFinder_tinymce', 0);
43: }
44:
45: 46: 47: 48: 49:
50: function getOptionsSupported() {
51: $options = array(gettext('Files tab') => array('key' => 'elFinder_files', 'type' => OPTION_TYPE_CHECKBOX,
52: 'desc' => gettext('Use as the upload <em>files</em> subtab.')),
53: gettext('TinyMCE plugin') => array('key' => 'elFinder_tinymce', 'type' => OPTION_TYPE_CHECKBOX,
54: 'desc' => gettext('Enable plugin for TinyMCE.'))
55: );
56: return $options;
57: }
58:
59: function handleOption($option, $currentValue) {
60:
61: }
62:
63: }
64:
65: if (getOption('elFinder_files') && zp_loggedin(FILES_RIGHTS)) {
66: zp_register_filter('admin_tabs', 'elFinder_admin_tabs', 50);
67: }
68: if (getOption('elFinder_tinymce')) {
69: zp_register_filter('tinymce_zenpage_config', 'elFinder_tinymce');
70: }
71:
72: function elFinder_admin_tabs($tabs) {
73: $me = sprintf(gettext('files (%s)'), 'elFinder');
74: $mylink = PLUGIN_FOLDER . '/' . 'elFinder/filemanager.php?page=upload&tab=elFinder&type=' . gettext('files');
75: if (is_null($tabs['upload'])) {
76: $tabs['upload'] = array('text' => gettext("upload"),
77: 'link' => WEBPATH . "/" . ZENFOLDER . '/admin-upload.php',
78: 'subtabs' => NULL);
79: }
80: $tabs['upload']['subtabs'][$me] = $mylink;
81: if (zp_getcookie('uploadtype') == 'elFinder')
82: $tabs['upload']['link'] = $mylink;
83: return $tabs;
84: }
85:
86: function elFinder_tinymce($discard) {
87:
88: $file = FULLWEBPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER . '/elFinder/elfinder.php?XSRFToken=' . getXSRFToken('elFinder');
89: ?>
90: <script type="text/javascript">
91:
92: function elFinderBrowser(field_name, url, type, win) {
93: tinymce.activeEditor.windowManager.open({
94: file: '<?php echo $file; ?>',
95: title: 'elFinder 2.0',
96: width: 900,
97: height: 450,
98: close_previous: 'no',
99: inline: 'yes',
100: popup_css: false,
101: resizable: 'yes'
102: }, {
103: setUrl: function(url) {
104: win.document.getElementById(field_name).value = url;
105: }
106: });
107: return false;
108: }
109:
110: </script>
111:
112: <?php
113: return 'elFinderBrowser';
114: }
115: ?>