function elfinder_file_browser in elFinder file manager 7
Same name and namespace in other branches
- 6.2 elfinder.module \elfinder_file_browser()
- 6 elfinder.module \elfinder_file_browser()
- 7.3 elfinder.module \elfinder_file_browser()
- 7.2 elfinder.module \elfinder_file_browser()
File browser render
1 call to elfinder_file_browser()
1 string reference to 'elfinder_file_browser'
- elfinder_menu in ./
elfinder.module - Implements hook_menu().
File
- ./
elfinder.module, line 99
Code
function elfinder_file_browser($browser_mode = 'default') {
if (is_readable(elfinder_connector_path())) {
global $language;
$path = drupal_get_path('module', 'elfinder');
$libpath = elfinder_lib_path();
$editorApp = '';
$langCode = $language->language;
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
'browserMode' => $browser_mode,
);
if ($editorApp) {
$elfinder_js_settings['editorCallback'] = 'elfinder_' . $editorApp . '_callback';
}
$options = array(
'group' => CSS_DEFAULT,
'every_page' => FALSE,
);
elfinder_add_css($libpath . '/css/elfinder.css', $options);
elfinder_add_css($path . '/css/elfinder.drupal.css', $options);
$elfinder_jquery = key(elfinder_system_listing("jquery-[0-9\\.]+.*\\.js\$", elfinder_lib_path(), NULL, NULL));
$elfinder_jquery_ui = key(elfinder_system_listing("jquery-ui-[0-9\\.]+.*\\.js\$", elfinder_lib_path(), NULL, NULL));
$elfinder_jquery_ui_css = key(elfinder_system_listing("jquery-ui-[0-9\\.]+.*\\.css\$", elfinder_lib_path(), NULL, NULL));
$editor_file_content = file_get_contents($libpath . '/js/elfinder.min.js');
$ver = 0;
if (preg_match("/this\\.version\\s*=\\s*[\"\\']([^\"\\']+)[\"\\']/", $editor_file_content, $matches)) {
$ver = $matches[1];
}
if (variable_get('elfinder_settings_misc_usesystemjquery', 'true') == 'true' || preg_match('/^1\\.1/', $ver)) {
drupal_add_library('system', 'jquery');
drupal_add_library('system', 'ui');
drupal_add_library('system', 'ui.dialog');
drupal_add_library('system', 'ui.accordion');
drupal_add_library('system', 'ui.draggable');
drupal_add_library('system', 'ui.droppable');
drupal_add_library('system', 'ui.selectable');
drupal_add_library('system', 'ui.resizable');
}
else {
$css11 = $libpath . '/js/ui-themes/base/ui.all.css';
if (is_readable($css11)) {
elfinder_add_css($css11, $options);
}
else {
if ($elfinder_jquery_ui_css) {
elfinder_add_css($elfinder_jquery_ui_css, $options);
}
}
if ($elfinder_jquery) {
drupal_add_js($elfinder_jquery);
}
if ($elfinder_jquery_ui) {
drupal_add_js($elfinder_jquery_ui);
}
}
drupal_add_js($libpath . '/js/elfinder.full.js');
/* Adding localization */
if ($langCode != 'en' && is_readable($libpath . '/js/i18n/elfinder.' . $langCode . '.js')) {
drupal_add_js($libpath . '/js/i18n/elfinder.' . $langCode . '.js');
}
/* Getting updated frontend settings from hook_elfinder_js_settings */
$newjssettings = module_invoke_all('elfinder_js_settings', $elfinder_js_settings);
if ($newjssettings) {
$elfinder_js_settings = $newjssettings;
}
drupal_add_js(array(
'elfinder' => $elfinder_js_settings,
), 'setting');
if ($editorApp != '') {
/* Loading callbacks for returning url from file manager to caller */
$editor_plugins = elfinder_system_listing("^{$editorApp}\\.callback\\.js\$", $path . '/editors', NULL, NULL);
$callback_file = key($editor_plugins);
if (isset($callback_file)) {
drupal_add_js($callback_file);
}
}
drupal_add_js($path . '/js/helper.js');
drupal_add_js($path . '/js/elfinder.callback.js');
}
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;
}