function elfinder_file_browser in elFinder file manager 6.2
Same name and namespace in other branches
- 6 elfinder.module \elfinder_file_browser()
- 7.3 elfinder.module \elfinder_file_browser()
- 7 elfinder.module \elfinder_file_browser()
- 7.2 elfinder.module \elfinder_file_browser()
File browser render
1 call to elfinder_file_browser()
- elfinder_block in ./
elfinder.module - Implements hook_block().
1 string reference to 'elfinder_file_browser'
- elfinder_menu in ./
elfinder.module - Implements hook_menu().
File
- ./
elfinder.module, line 167
Code
function elfinder_file_browser($browser_mode = 'default') {
$p = elfinder_get_user_profile();
$libpath = elfinder_lib_path() . '/';
if (is_readable(elfinder_connector_path())) {
global $language;
$path = drupal_get_path('module', 'elfinder');
$editorApp = '';
$langCode = isset($language->language) ? $language->language : 'en';
if (isset($_GET['app'])) {
if (preg_match("/^[a-zA-Z]+\$/", $_GET['app'])) {
$editorApp = $_GET['app'];
}
elseif (preg_match("/^([a-zA-Z]+)|/", $_GET['app'], $m)) {
$editorApp = $m[1];
}
}
if (isset($_GET['langCode'])) {
if (preg_match("/^[a-zA-z]{2}\$/", $_GET['langCode'])) {
$langCode = $_GET['langCode'];
}
}
/* Initial frontend settings */
$elfinder_js_settings = array(
'connectorUrl' => url('elfinder/connector'),
'moduleUrl' => url('elfinder'),
'editorApp' => $editorApp,
'langCode' => $langCode,
'rememberLastDir' => variable_get('elfinder_settings_misc_rememberlastdir', 'true') == 'true' ? TRUE : FALSE,
// remember last opened directory
'disabledCommands' => elfinder_get_disabled_commands(),
'browserMode' => $browser_mode,
'token' => drupal_get_token('elFinder'),
);
if (($mwidth = variable_get('elfinder_settings_misc_manager_width', '')) != '') {
$elfinder_js_settings['width'] = (int) $mwidth;
}
if (($mheight = variable_get('elfinder_settings_misc_manager_height', '')) != '') {
$elfinder_js_settings['height'] = (int) $mheight;
}
if ($editorApp) {
$elfinder_js_settings['editorCallback'] = 'elfinder_' . $editorApp . '_callback';
}
$options = array(
'type' => 'module',
'media' => 'screen',
);
$sysjqver = variable_get('jquery_update_jquery_version', '1.3');
if (!(module_exists('jquery_update') && preg_match('/1\\.(6|7)/', $sysjqver))) {
drupal_add_js($path . '/js/elfinder.jquery.min.js');
}
if (module_exists('jquery_ui') && preg_match("/^1\\.8/", jquery_ui_get_version())) {
elfinder_add_css(JQUERY_UI_PATH . '/themes/base/ui.all.css', $options);
jquery_ui_add(array(
'ui.dialog',
'ui.accordion',
'ui.draggable',
'ui.droppable',
'ui.selectable',
'ui.resizable',
));
}
else {
drupal_add_js($path . '/js/elfinder.jquery-ui.min.js');
}
elfinder_add_css($path . '/css/ui-themes/smoothness/jquery-ui.custom.css', $options);
elfinder_add_css($path . '/css/elfinder.common.css', $options);
$proto = !empty($_SERVER['HTTPS']) ? 'https' : 'http';
elfinder_add_css($libpath . 'css/ui-themes/smoothness/jquery-ui.custom.css');
if (is_readable($libpath . 'css/elfinder.min.css') && is_readable($libpath . 'js/elfinder.min.js')) {
elfinder_add_css($libpath . 'css/elfinder.min.css');
drupal_add_js($libpath . 'js/elfinder.min.js');
}
else {
if (is_readable($libpath . 'css/elfinder.full.css') && is_readable($libpath . 'js/elfinder.full.js')) {
elfinder_add_css($libpath . 'css/elfinder.full.css');
drupal_add_js($libpath . 'js/elfinder.full.js');
}
else {
if (is_readable($libpath . 'css/common.css') && is_readable($libpath . 'js/elFinder.js')) {
elfinder_add_css($libpath . 'css/common.css');
elfinder_add_css($libpath . 'css/dialog.css');
elfinder_add_css($libpath . 'css/toolbar.css');
elfinder_add_css($libpath . 'css/navbar.css');
elfinder_add_css($libpath . 'css/statusbar.css');
elfinder_add_css($libpath . 'css/cwd.css');
elfinder_add_css($libpath . 'css/quicklook.css');
elfinder_add_css($libpath . 'css/commands.css');
elfinder_add_css($libpath . 'css/contextmenu.css');
elfinder_add_css($libpath . 'css/theme.css');
drupal_add_js($libpath . 'js/elFinder.js');
drupal_add_js($libpath . 'js/elFinder.version.js');
drupal_add_js($libpath . 'js/jquery.elfinder.js');
drupal_add_js($libpath . 'js/elFinder.resources.js');
drupal_add_js($libpath . 'js/elFinder.options.js');
drupal_add_js($libpath . 'js/elFinder.history.js');
drupal_add_js($libpath . 'js/elFinder.command.js');
drupal_add_js($libpath . 'js/ui/overlay.js');
drupal_add_js($libpath . 'js/ui/workzone.js');
drupal_add_js($libpath . 'js/ui/navbar.js');
drupal_add_js($libpath . 'js/ui/dialog.js');
drupal_add_js($libpath . 'js/ui/tree.js');
drupal_add_js($libpath . 'js/ui/cwd.js');
drupal_add_js($libpath . 'js/ui/toolbar.js');
drupal_add_js($libpath . 'js/ui/button.js');
drupal_add_js($libpath . 'js/ui/uploadButton.js');
drupal_add_js($libpath . 'js/ui/viewbutton.js');
drupal_add_js($libpath . 'js/ui/searchbutton.js');
drupal_add_js($libpath . 'js/ui/panel.js');
drupal_add_js($libpath . 'js/ui/contextmenu.js');
drupal_add_js($libpath . 'js/ui/path.js');
drupal_add_js($libpath . 'js/ui/stat.js');
drupal_add_js($libpath . 'js/ui/places.js');
drupal_add_js($libpath . 'js/commands/back.js');
drupal_add_js($libpath . 'js/commands/forward.js');
drupal_add_js($libpath . 'js/commands/reload.js');
drupal_add_js($libpath . 'js/commands/up.js');
drupal_add_js($libpath . 'js/commands/home.js');
drupal_add_js($libpath . 'js/commands/copy.js');
drupal_add_js($libpath . 'js/commands/cut.js');
drupal_add_js($libpath . 'js/commands/paste.js');
drupal_add_js($libpath . 'js/commands/open.js');
drupal_add_js($libpath . 'js/commands/rm.js');
drupal_add_js($libpath . 'js/commands/duplicate.js');
drupal_add_js($libpath . 'js/commands/rename.js');
drupal_add_js($libpath . 'js/commands/help.js');
drupal_add_js($libpath . 'js/commands/getfile.js');
drupal_add_js($libpath . 'js/commands/mkdir.js');
drupal_add_js($libpath . 'js/commands/mkfile.js');
drupal_add_js($libpath . 'js/commands/upload.js');
drupal_add_js($libpath . 'js/commands/download.js');
drupal_add_js($libpath . 'js/commands/edit.js');
drupal_add_js($libpath . 'js/commands/quicklook.js');
drupal_add_js($libpath . 'js/commands/quicklook.plugins.js');
drupal_add_js($libpath . 'js/commands/extract.js');
drupal_add_js($libpath . 'js/commands/archive.js');
drupal_add_js($libpath . 'js/commands/search.js');
drupal_add_js($libpath . 'js/commands/view.js');
drupal_add_js($libpath . 'js/commands/resize.js');
drupal_add_js($libpath . 'js/commands/info.js');
drupal_add_js($libpath . 'js/commands/sort.js');
drupal_add_js($libpath . 'js/commands/netmount.js');
drupal_add_js($libpath . 'js/proxy/elFinderSupportVer1.js');
drupal_add_js($libpath . 'js/jquery.dialogelfinder.js');
}
else {
watchdog('Failed Requirement', 'elFinder unable to load required JS and CSS files', NULL, WATCHDOG_ERROR);
}
}
}
$langfile = $libpath . 'js/i18n/elfinder.' . $langCode . '.js';
if (is_readable($libpath . 'css/theme.css')) {
elfinder_add_css($libpath . 'css/theme.css');
}
/* Adding localization */
if (is_readable($langfile)) {
drupal_add_js($langfile);
}
/* Getting updated frontend settings from hook_elfinder_js_settings */
$newjssettings = module_invoke_all('elfinder_js_settings', $elfinder_js_settings);
if (isset($newjssettings['all'])) {
$elfinder_js_settings = array_merge($elfinder_js_settings, (array) $newjssettings['all']);
}
if (isset($newjssettings[$editorApp])) {
$elfinder_js_settings = array_merge($elfinder_js_settings, (array) $newjssettings[$editorApp]);
}
/* Loading callbacks for returning url from file manager to caller */
$editor_plugins = elfinder_system_listing("{$editorApp}\\.callback\\.js\$", $path . '/editors', 'name', 0);
$callback_file = '';
if (isset($editorApp)) {
if (isset($editorApp) && isset($editor_plugins[$editorApp . '.callback'])) {
$callback_file = $editor_plugins[$editorApp . '.callback']->filename;
if (isset($callback_file)) {
drupal_add_js($callback_file);
}
}
if (isset($elfinder_js_settings['browserscripts'])) {
foreach ((array) $elfinder_js_settings['browserscripts'] as $script) {
drupal_add_js($script);
}
unset($elfinder_js_settings['browserscripts']);
}
}
drupal_add_js($path . '/js/info.js');
drupal_add_js($path . '/js/elfinder.callback.js');
//drupal_add_js($path . '/js/mouseover.js');
drupal_add_js(array(
'elfinder' => $elfinder_js_settings,
), 'setting');
}
else {
drupal_set_message(t('elFinder library was not found. Please download it from <a href="@url">@url</a> and install to @libpath.', array(
'@url' => elfinder_download_url(),
'@libpath' => $libpath,
)), 'error');
}
if ($browser_mode && $browser_mode == 'backend') {
return theme('elfinder_page_backend');
}
else {
print theme('elfinder_page');
}
module_invoke_all('exit');
exit;
}