updated elysia_cron, elfinder, metatag, libraries, email_registration, migrate, nodeform_cols
This commit is contained in:
@@ -1,4 +1,9 @@
|
||||
<?php
|
||||
/**
|
||||
* elFinder Integration
|
||||
*
|
||||
* Copyright (c) 2010-2018, Alexey Sukhotin. All rights reserved.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
@@ -28,30 +33,29 @@ function elfinder_admin_profile_links($profile_name) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Settings form definition
|
||||
*/
|
||||
function elfinder_admin_form(&$form_state) {
|
||||
global $user, $language;
|
||||
$path = drupal_get_path('module', 'elfinder');
|
||||
// require_once $path .'/inc/' . 'elfinder.admin.profiles.inc';
|
||||
// require_once $path .'/inc/' . 'elfinder.admin.profiles.inc';
|
||||
|
||||
$langCode = isset($language->language) ? $language->language : 'en';
|
||||
|
||||
|
||||
$form['profiles'] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#title' => t('Profiles'),
|
||||
'#collapsible' => TRUE,
|
||||
'#collapsed' => FALSE,
|
||||
);
|
||||
|
||||
|
||||
$profiles = elfinder_admin_profile_get();
|
||||
|
||||
|
||||
$roles = user_roles();
|
||||
|
||||
|
||||
$rows = array();
|
||||
|
||||
|
||||
if ($profiles) {
|
||||
if (is_array($profiles)) {
|
||||
foreach ($profiles as $profile) {
|
||||
@@ -61,21 +65,21 @@ function elfinder_admin_form(&$form_state) {
|
||||
$profile = $profiles;
|
||||
$rows[] = array($profile->pid, $profile->name, $profile->description, implode(', ', array_intersect_key($roles, $profile->settings['profile_role'])), elfinder_admin_profile_links($profile->name));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
$profile_table = theme('table', array(
|
||||
$profile_table = theme('table', array(
|
||||
'header' => array(t('Id'), t('Name'), t('Description'), t('Role'), ''),
|
||||
'rows' => $rows
|
||||
));
|
||||
|
||||
|
||||
$addprofile = l(t('Add profile'), 'admin/config/media/elfinder/profile');
|
||||
|
||||
|
||||
$form['profiles']['profile_list'] = array(
|
||||
'#type' => 'markup',
|
||||
'#markup' => "$profile_table<br/>$addprofile",
|
||||
);
|
||||
|
||||
|
||||
$form['filesystem_settings'] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#title' => t('File system settings'),
|
||||
@@ -110,7 +114,7 @@ function elfinder_admin_form(&$form_state) {
|
||||
'#default_value' => variable_get('elfinder_settings_filesystem_unmanaged_root_label', ''),
|
||||
'#description' => t('Root directory label in directory tree'),
|
||||
);
|
||||
|
||||
|
||||
$form['filesystem_settings']['filesystem_root_custom'] = array(
|
||||
'#prefix' => '<div class="custom-container">',
|
||||
'#suffix' => '</div>',
|
||||
@@ -137,7 +141,7 @@ function elfinder_admin_form(&$form_state) {
|
||||
'auto' => t('Automatical detection'),
|
||||
),
|
||||
);
|
||||
|
||||
|
||||
$form['filesystem_settings']['filesystem_allowed_extensions'] = array(
|
||||
'#prefix' => '<div class="custom-container">',
|
||||
'#suffix' => '</div>',
|
||||
@@ -147,7 +151,7 @@ function elfinder_admin_form(&$form_state) {
|
||||
'#default_value' => variable_get('elfinder_settings_filesystem_allowed_extensions', ''),
|
||||
'#description' => t('Separate extensions with a space or comma and do not include the leading dot.'),
|
||||
);
|
||||
|
||||
|
||||
if (function_exists('finfo_open')) {
|
||||
$form['filesystem_settings']['mime_detect']['#options']['finfo'] = t('php finfo');
|
||||
}
|
||||
@@ -160,8 +164,41 @@ function elfinder_admin_form(&$form_state) {
|
||||
$form['filesystem_settings']['mime_detect']['#options']['bsd'] = t('file -Ib (bsd)');
|
||||
$form['filesystem_settings']['mime_detect']['#options']['internal'] = t('By file extension (built-in)');
|
||||
$form['filesystem_settings']['mime_detect']['#options']['drupal'] = t('Drupal API');
|
||||
|
||||
|
||||
|
||||
|
||||
$form['filesystem_settings']['filesystem_inline_preview'] = array(
|
||||
'#type' => 'radios',
|
||||
'#title' => t('Preview'),
|
||||
'#default_value' => variable_get('elfinder_settings_filesystem_inline_preview', 'default'),
|
||||
'#description' => t('File types allowed to display in preview'),
|
||||
'#options' => array(
|
||||
'default' => t('Default - images, video, audio, pdf, text'),
|
||||
'all' => t('All supported for preview files - additional: md, psd, html, archives, swf, sharecad.org, MS Office Online, Google Docs - be careful'),
|
||||
'custom' => t('Custom regex'),
|
||||
'disabled' => t('Disabled'),
|
||||
),
|
||||
);
|
||||
|
||||
$form['filesystem_settings']['filesystem_inline_preview_custom'] = array(
|
||||
'#prefix' => '<div class="custom-container">',
|
||||
'#suffix' => '</div>',
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Custom preview match regex'),
|
||||
'#default_value' => variable_get('elfinder_settings_filesystem_inlinepreviewcustom', '^(?:(?:image|video|audio)|application/(?:x-mpegURL|dash\\+xml)|(?:text/plain|application/pdf)$)'),
|
||||
'#description' => t('Custom mime type match regex for preview'),
|
||||
);
|
||||
|
||||
$form['filesystem_settings']['filesystem_external_preview'] = array(
|
||||
'#type' => 'radios',
|
||||
'#title' => t('External Service Preview'),
|
||||
'#default_value' => variable_get('elfinder_settings_filesystem_external_preview', 'disabled'),
|
||||
'#description' => t('Use Microsoft, Google and other online services to preview some office documents. <b>Warning!</b> By previewing document with external services <b>YOU ARE ULOADING</b> the document to them. Google, Microsoft and other service owners usually <b>TRACK</b> your activity and <b>share it with Sales, CIA, FSB (KGB), FBI, governors, etc.</b>'),
|
||||
'#options' => array(
|
||||
'default' => t('Use Microsoft Office and Google Docs for preview'),
|
||||
'disabled' => t('Disabled'),
|
||||
),
|
||||
);
|
||||
|
||||
$form['filesystem_settings']['file_url_type'] = array(
|
||||
'#type' => 'radios',
|
||||
'#title' => t('Selected file url type'),
|
||||
@@ -170,7 +207,7 @@ function elfinder_admin_form(&$form_state) {
|
||||
'true' => t('Absolute'),
|
||||
'false' => t('Relative'),
|
||||
),
|
||||
);
|
||||
);
|
||||
|
||||
$form['filesystem_settings']['file_perm'] = array(
|
||||
'#type' => 'textfield',
|
||||
@@ -195,7 +232,7 @@ function elfinder_admin_form(&$form_state) {
|
||||
'#size' => 10,
|
||||
'#weight' => 5,
|
||||
);
|
||||
|
||||
|
||||
$form['filesystem_settings']['max_filecount'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Maximum folder size'),
|
||||
@@ -204,7 +241,7 @@ function elfinder_admin_form(&$form_state) {
|
||||
'#size' => 10,
|
||||
'#weight' => 5,
|
||||
);
|
||||
|
||||
|
||||
$form['filesystem_settings']['handleprivate'] = array(
|
||||
'#type' => 'radios',
|
||||
'#title' => t('Handle private downloads'),
|
||||
@@ -222,7 +259,7 @@ function elfinder_admin_form(&$form_state) {
|
||||
'#collapsible' => TRUE,
|
||||
'#collapsed' => FALSE,
|
||||
);
|
||||
|
||||
|
||||
$form['thumbnail_settings']['tmbsize'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Thumbnail size'),
|
||||
@@ -244,7 +281,7 @@ function elfinder_admin_form(&$form_state) {
|
||||
'#options' => array(
|
||||
'auto' => t('Automatical detection'),
|
||||
'imagick' => t('Image Magick'),
|
||||
'gd' => t('GD'),
|
||||
'gd' => t('GD'),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -265,7 +302,7 @@ function elfinder_admin_form(&$form_state) {
|
||||
'#collapsible' => TRUE,
|
||||
'#collapsed' => FALSE,
|
||||
);
|
||||
|
||||
|
||||
$form['misc_settings']['rememberlastdir'] = array(
|
||||
'#type' => 'radios',
|
||||
'#title' => t('Remember last opened directory'),
|
||||
@@ -312,7 +349,7 @@ function elfinder_admin_form(&$form_state) {
|
||||
|
||||
$form['submit'] = array('#type' => 'submit', '#value' => t('Save configuration'));
|
||||
$form['#submit'][] = 'elfinder_admin_submit';
|
||||
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
@@ -344,11 +381,25 @@ function elfinder_admin_submit($form, &$form_state) {
|
||||
variable_set('elfinder_settings_filesystem_public_root_label', $form_state['values']['filesystem_public_root_label']);
|
||||
variable_set('elfinder_settings_filesystem_private_root_label', $form_state['values']['filesystem_private_root_label']);
|
||||
variable_set('elfinder_settings_filesystem_unmanaged_root_label', $form_state['values']['filesystem_unmanaged_root_label']);
|
||||
variable_set('elfinder_settings_misc_manager_width', $form_state['values']['manager_width']);
|
||||
variable_set('elfinder_settings_misc_manager_height', $form_state['values']['manager_height']);
|
||||
variable_set('elfinder_settings_misc_manager_width', $form_state['values']['manager_width']);
|
||||
variable_set('elfinder_settings_misc_manager_height', $form_state['values']['manager_height']);
|
||||
variable_set('elfinder_settings_misc_hidden_folders', $form_state['values']['hidden_folders']);
|
||||
variable_set('elfinder_settings_filesystem_allowed_extensions', $form_state['values']['filesystem_allowed_extensions']);
|
||||
|
||||
|
||||
if ($form_state['values']['filesystem_inline_preview'] == 'default') {
|
||||
variable_set('elfinder_settings_filesystem_inlinepreviewregex', '^(?:(?:image|video|audio)|application/(?:x-mpegURL|dash\\+xml)|(?:text/plain|application/pdf)$)');
|
||||
} else if ($form_state['values']['filesystem_inline_preview'] == 'all') {
|
||||
variable_set('elfinder_settings_filesystem_inlinepreviewregex', '.');
|
||||
} else if ($form_state['values']['filesystem_inline_preview'] == 'custom') {
|
||||
variable_set('elfinder_settings_filesystem_inlinepreviewregex', variable_get('elfinder_settings_filesystem_inlinepreviewcustom', '^$'));
|
||||
} else {
|
||||
variable_set('elfinder_settings_filesystem_inlinepreviewregex', '^$');
|
||||
}
|
||||
|
||||
variable_set('elfinder_settings_filesystem_inline_preview', $form_state['values']['filesystem_inline_preview']);
|
||||
variable_set('elfinder_settings_filesystem_inlinepreviewcustom', $form_state['values']['filesystem_inline_preview_custom']);
|
||||
variable_set('elfinder_settings_filesystem_external_preview', $form_state['values']['filesystem_external_preview']);
|
||||
|
||||
drupal_set_message(t('Changes have been saved.'));
|
||||
}
|
||||
|
||||
@@ -398,4 +449,4 @@ function elfinder_admin_form_validate($form, &$form_state) {
|
||||
if ($tmbsize && !is_numeric($tmbsize)) {
|
||||
form_set_error('tmbsize', t('Thumbnail size should be a number'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,4 +1,9 @@
|
||||
<?php
|
||||
/**
|
||||
* elFinder Integration
|
||||
*
|
||||
* Copyright (c) 2010-2018, Alexey Sukhotin. All rights reserved.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
@@ -31,69 +36,69 @@ function elfinder_admin_profile($form, &$form_state) {
|
||||
|
||||
if ($action == 'profile_add') {
|
||||
$form['profile_name'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Profile Name'),
|
||||
'#default_value' => '',
|
||||
'#size' => 14,
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Profile Name'),
|
||||
'#default_value' => '',
|
||||
'#size' => 14,
|
||||
);
|
||||
} else {
|
||||
$form['profile_name_label'] = array(
|
||||
'#title' => t('Profile Name'),
|
||||
'#markup' => $profile_name,
|
||||
'#size' => 14,
|
||||
'#type' => 'item',
|
||||
'#title' => t('Profile Name'),
|
||||
'#markup' => $profile_name,
|
||||
'#size' => 14,
|
||||
'#type' => 'item',
|
||||
);
|
||||
|
||||
$form['profile_name'] = array(
|
||||
'#default_value' => $profile_name,
|
||||
'#type' => 'hidden',
|
||||
'#default_value' => $profile_name,
|
||||
'#type' => 'hidden',
|
||||
);
|
||||
}
|
||||
|
||||
$form['profile_description'] = array(
|
||||
'#type' => 'textarea',
|
||||
'#title' => t('Description'),
|
||||
'#default_value' => isset($p->description) ? $p->description : '',
|
||||
'#type' => 'textarea',
|
||||
'#title' => t('Description'),
|
||||
'#default_value' => isset($p->description) ? $p->description : '',
|
||||
);
|
||||
|
||||
$form['profile_role'] = array(
|
||||
'#type' => 'checkboxes',
|
||||
'#title' => t('Roles'),
|
||||
'#default_value' => isset($profile['profile_role']) ? array_keys($profile['profile_role']) : array(),
|
||||
'#options' => user_roles(),
|
||||
'#description' => t('Roles for which profile settings will be applied'),
|
||||
'#type' => 'checkboxes',
|
||||
'#title' => t('Roles'),
|
||||
'#default_value' => isset($profile['profile_role']) ? array_keys($profile['profile_role']) : array(),
|
||||
'#options' => user_roles(),
|
||||
'#description' => t('Roles for which profile settings will be applied'),
|
||||
);
|
||||
|
||||
$form['profile_action'] = array(
|
||||
'#default_value' => $action,
|
||||
'#type' => 'hidden',
|
||||
'#default_value' => $action,
|
||||
'#type' => 'hidden',
|
||||
);
|
||||
|
||||
$form['filesystem_settings'] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#title' => t('File system'),
|
||||
'#collapsible' => TRUE,
|
||||
'#collapsed' => TRUE,
|
||||
'#type' => 'fieldset',
|
||||
'#title' => t('File system'),
|
||||
'#collapsible' => TRUE,
|
||||
'#collapsed' => TRUE,
|
||||
);
|
||||
|
||||
$form['volumes'] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#title' => t('Volumes'),
|
||||
'#collapsible' => TRUE,
|
||||
'#collapsed' => FALSE,
|
||||
'#type' => 'fieldset',
|
||||
'#title' => t('Volumes'),
|
||||
'#collapsible' => TRUE,
|
||||
'#collapsed' => FALSE,
|
||||
);
|
||||
|
||||
$form['volumes']['volumes_wrapper'] = array(
|
||||
'#weight' => -4,
|
||||
'#prefix' => '<div class="clear-block" id="poll-choice-wrapper">',
|
||||
'#suffix' => '</div>',
|
||||
'#weight' => -4,
|
||||
'#prefix' => '<div class="clear-block" id="poll-choice-wrapper">',
|
||||
'#suffix' => '</div>',
|
||||
);
|
||||
|
||||
$form['volumes']['volumes_wrapper']['volume'] = array(
|
||||
'#prefix' => '<div id="profile-volumes">',
|
||||
'#suffix' => '</div>',
|
||||
'#type' => 'markup',
|
||||
'#value' => ' ',
|
||||
'#prefix' => '<div id="profile-volumes">',
|
||||
'#suffix' => '</div>',
|
||||
'#type' => 'markup',
|
||||
'#value' => ' ',
|
||||
);
|
||||
|
||||
|
||||
@@ -129,35 +134,35 @@ function elfinder_admin_profile($form, &$form_state) {
|
||||
foreach ($form['volumes']['volumes_wrapper']['volume'] as $volume) {
|
||||
if (is_array($volume) && isset($volume['volume_settings'])) {
|
||||
$ckeditor_volumes[] = t('Volume @i (@path)', array(
|
||||
'@i' => $i,
|
||||
'@path' => $volume['volume_settings']['path']['#default_value'],
|
||||
));
|
||||
'@i' => $i,
|
||||
'@path' => $volume['volume_settings']['path']['#default_value'],
|
||||
));
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
|
||||
$form['volumes']['volumes_wrapper']['volume_add'] = array(
|
||||
'#type' => 'submit',
|
||||
'#value' => t('Add volume'),
|
||||
'#weight' => 1,
|
||||
'#name' => 'addfield',
|
||||
'#submit' => array('elfinder_admin_profile_change_volume'),
|
||||
'#ajax' => array(
|
||||
'wrapper' => 'profile-volumes',
|
||||
'callback' => 'elfinder_admin_profile_callback',
|
||||
'method' => 'replace',
|
||||
'effect' => 'fade',
|
||||
),
|
||||
'#type' => 'submit',
|
||||
'#value' => t('Add volume'),
|
||||
'#weight' => 1,
|
||||
'#name' => 'addfield',
|
||||
'#submit' => array('elfinder_admin_profile_change_volume'),
|
||||
'#ajax' => array(
|
||||
'wrapper' => 'profile-volumes',
|
||||
'callback' => 'elfinder_admin_profile_callback',
|
||||
'method' => 'replace',
|
||||
'effect' => 'fade',
|
||||
),
|
||||
);
|
||||
|
||||
|
||||
$form['filesystem_settings']['mime_detect'] = array(
|
||||
'#type' => 'radios',
|
||||
'#title' => t('File type detection'),
|
||||
'#default_value' => isset($profile['mimedetect']) ? $profile['mimedetect'] : 'auto',
|
||||
'#options' => array(
|
||||
'auto' => t('Automatical detection'),
|
||||
),
|
||||
'#type' => 'radios',
|
||||
'#title' => t('File type detection'),
|
||||
'#default_value' => isset($profile['mimedetect']) ? $profile['mimedetect'] : 'auto',
|
||||
'#options' => array(
|
||||
'auto' => t('Automatical detection'),
|
||||
),
|
||||
);
|
||||
|
||||
if (function_exists('finfo_open')) {
|
||||
@@ -175,144 +180,144 @@ function elfinder_admin_profile($form, &$form_state) {
|
||||
|
||||
|
||||
$form['filesystem_settings']['file_url_type'] = array(
|
||||
'#type' => 'radios',
|
||||
'#title' => t('Selected file url type'),
|
||||
'#default_value' => $profile['file_url_type'] == 'true' ? 'true' : 'false',
|
||||
'#options' => array(
|
||||
'true' => t('Absolute'),
|
||||
'false' => t('Relative'),
|
||||
),
|
||||
'#type' => 'radios',
|
||||
'#title' => t('Selected file url type'),
|
||||
'#default_value' => $profile['file_url_type'] == 'true' ? 'true' : 'false',
|
||||
'#options' => array(
|
||||
'true' => t('Absolute'),
|
||||
'false' => t('Relative'),
|
||||
),
|
||||
);
|
||||
|
||||
$form['filesystem_settings']['file_perm'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Created file permissions'),
|
||||
'#default_value' => isset($profile['file_perm']) ? $profile['file_perm'] : '0666',
|
||||
'#size' => 4,
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Created file permissions'),
|
||||
'#default_value' => isset($profile['file_perm']) ? $profile['file_perm'] : '0666',
|
||||
'#size' => 4,
|
||||
);
|
||||
|
||||
$form['filesystem_settings']['dir_perm'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Created directory permissions'),
|
||||
'#default_value' => isset($profile['dir_perm']) ? $profile['dir_perm'] : '0777',
|
||||
'#size' => 4,
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Created directory permissions'),
|
||||
'#default_value' => isset($profile['dir_perm']) ? $profile['dir_perm'] : '0777',
|
||||
'#size' => 4,
|
||||
);
|
||||
|
||||
|
||||
$form['filesystem_settings']['max_filesize'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Maximum upload size'),
|
||||
'#default_value' => isset($profile['max_filesize']) ? $profile['max_filesize'] : '',
|
||||
'#description' => t('Enter a value like "512" (bytes), "80 KB" (kilobytes) or "50 MB" (megabytes) in order to restrict the allowed file size. If left empty the file sizes will be limited only by PHP\'s maximum post and file upload sizes (current limit <strong>%limit</strong>).', array('%limit' => format_size(file_upload_max_size()))),
|
||||
'#size' => 10,
|
||||
'#weight' => 5,
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Maximum upload size'),
|
||||
'#default_value' => isset($profile['max_filesize']) ? $profile['max_filesize'] : '',
|
||||
'#description' => t('Enter a value like "512" (bytes), "80 KB" (kilobytes) or "50 MB" (megabytes) in order to restrict the allowed file size. If left empty the file sizes will be limited only by PHP\'s maximum post and file upload sizes (current limit <strong>%limit</strong>).', array('%limit' => format_size(file_upload_max_size()))),
|
||||
'#size' => 10,
|
||||
'#weight' => 5,
|
||||
);
|
||||
|
||||
$form['filesystem_settings']['user_quota'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('User quota'),
|
||||
'#default_value' => isset($profile['user_quota']) ? $profile['user_quota'] : '',
|
||||
'#description' => t('Enter a value like "512" (bytes), "80 KB" (kilobytes) or "50 MB" (megabytes) in order to restrict the allowed file size. If left empty the file sizes will be unlimited.'),
|
||||
'#size' => 10,
|
||||
'#weight' => 5,
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('User quota'),
|
||||
'#default_value' => isset($profile['user_quota']) ? $profile['user_quota'] : '',
|
||||
'#description' => t('Enter a value like "512" (bytes), "80 KB" (kilobytes) or "50 MB" (megabytes) in order to restrict the allowed file size. If left empty the file sizes will be unlimited.'),
|
||||
'#size' => 10,
|
||||
'#weight' => 5,
|
||||
);
|
||||
|
||||
$form['thumbnail_settings'] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#title' => t('Thumbnails'),
|
||||
'#collapsible' => TRUE,
|
||||
'#collapsed' => TRUE,
|
||||
'#type' => 'fieldset',
|
||||
'#title' => t('Thumbnails'),
|
||||
'#collapsible' => TRUE,
|
||||
'#collapsed' => TRUE,
|
||||
);
|
||||
|
||||
$form['thumbnail_settings']['tmbsize'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Thumbnail size'),
|
||||
'#default_value' => isset($profile['tmbsize']) ? $profile['tmbsize'] : '48',
|
||||
'#size' => 4,
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Thumbnail size'),
|
||||
'#default_value' => isset($profile['tmbsize']) ? $profile['tmbsize'] : '48',
|
||||
'#size' => 4,
|
||||
);
|
||||
|
||||
$form['thumbnail_settings']['tmbdirname'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Thumbnail directory name'),
|
||||
'#default_value' => isset($profile['tmbdirname']) ? $profile['tmbdirname'] : 'tmb',
|
||||
'#size' => 10,
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Thumbnail directory name'),
|
||||
'#default_value' => isset($profile['tmbdirname']) ? $profile['tmbdirname'] : 'tmb',
|
||||
'#size' => 10,
|
||||
);
|
||||
|
||||
$form['thumbnail_settings']['imglib'] = array(
|
||||
'#type' => 'radios',
|
||||
'#title' => t('Image manipulation library'),
|
||||
'#default_value' => isset($profile['imglib']) ? $profile['imglib'] : 'auto',
|
||||
'#options' => array(
|
||||
'auto' => t('Automatical detection'),
|
||||
'imagick' => t('Image Magick'),
|
||||
'gd' => t('GD'),
|
||||
),
|
||||
'#type' => 'radios',
|
||||
'#title' => t('Image manipulation library'),
|
||||
'#default_value' => isset($profile['imglib']) ? $profile['imglib'] : 'auto',
|
||||
'#options' => array(
|
||||
'auto' => t('Automatical detection'),
|
||||
'imagick' => t('Image Magick'),
|
||||
'gd' => t('GD'),
|
||||
),
|
||||
);
|
||||
|
||||
$form['thumbnail_settings']['tmbcrop'] = array(
|
||||
'#type' => 'radios',
|
||||
'#title' => t('Image crop'),
|
||||
'#default_value' => $profile['tmbcrop'] == 'true' ? 'true' : 'false',
|
||||
'#options' => array(
|
||||
'true' => t('Yes'),
|
||||
'false' => t('No'),
|
||||
),
|
||||
'#description' => t('Crop image to fit thumbnail size. Yes - crop, No - scale image to fit thumbnail size.'),
|
||||
'#type' => 'radios',
|
||||
'#title' => t('Image crop'),
|
||||
'#default_value' => $profile['tmbcrop'] == 'true' ? 'true' : 'false',
|
||||
'#options' => array(
|
||||
'true' => t('Yes'),
|
||||
'false' => t('No'),
|
||||
),
|
||||
'#description' => t('Crop image to fit thumbnail size. Yes - crop, No - scale image to fit thumbnail size.'),
|
||||
);
|
||||
|
||||
$form['misc_settings'] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#title' => t('Miscellaneous'),
|
||||
'#collapsible' => TRUE,
|
||||
'#collapsed' => TRUE,
|
||||
'#type' => 'fieldset',
|
||||
'#title' => t('Miscellaneous'),
|
||||
'#collapsible' => TRUE,
|
||||
'#collapsed' => TRUE,
|
||||
);
|
||||
|
||||
$form['misc_settings']['rememberlastdir'] = array(
|
||||
'#type' => 'radios',
|
||||
'#title' => t('Remember last opened directory'),
|
||||
'#default_value' => $profile['rememberlastdir'] == 'true' ? 'true' : 'false',
|
||||
'#options' => array(
|
||||
'true' => t('Yes'),
|
||||
'false' => t('No'),
|
||||
),
|
||||
'#description' => t('Creates a cookie. Disable if you have issues with caching.'),
|
||||
'#type' => 'radios',
|
||||
'#title' => t('Remember last opened directory'),
|
||||
'#default_value' => $profile['rememberlastdir'] == 'true' ? 'true' : 'false',
|
||||
'#options' => array(
|
||||
'true' => t('Yes'),
|
||||
'false' => t('No'),
|
||||
),
|
||||
'#description' => t('Creates a cookie. Disable if you have issues with caching.'),
|
||||
);
|
||||
|
||||
|
||||
$form['misc_settings']['manager_width'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('File manager width'),
|
||||
'#default_value' => isset($profile['manager_width']) ? $profile['manager_width'] : '',
|
||||
'#size' => 4,
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('File manager width'),
|
||||
'#default_value' => isset($profile['manager_width']) ? $profile['manager_width'] : '',
|
||||
'#size' => 4,
|
||||
);
|
||||
|
||||
$form['misc_settings']['manager_height'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('File manager height'),
|
||||
'#default_value' => isset($profile['manager_height']) ? $profile['manager_height'] : '',
|
||||
'#size' => 4,
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('File manager height'),
|
||||
'#default_value' => isset($profile['manager_height']) ? $profile['manager_height'] : '',
|
||||
'#size' => 4,
|
||||
);
|
||||
|
||||
$form['misc_settings']['ckeditor_upload_settings'] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#title' => t('CKEditor/FCKeditor Upload Settings'),
|
||||
'#collapsible' => TRUE,
|
||||
'#collapsed' => TRUE,
|
||||
'#description' => t('CKEditor and FCKeditor allowing to upload and insert image files directly from Insert Image dialog.'),
|
||||
'#type' => 'fieldset',
|
||||
'#title' => t('CKEditor/FCKeditor Upload Settings'),
|
||||
'#collapsible' => TRUE,
|
||||
'#collapsed' => TRUE,
|
||||
'#description' => t('CKEditor and FCKeditor allowing to upload and insert image files directly from Insert Image dialog.'),
|
||||
);
|
||||
|
||||
$form['misc_settings']['ckeditor_upload_settings']['ckeditor_upload_directory'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Path'),
|
||||
'#default_value' => isset($profile['ckeditor_upload_directory']) ? $profile['ckeditor_upload_directory'] : '',
|
||||
'#size' => 40,
|
||||
'#description' => t('Image upload path. Default file uri is used if no uri prefix specified. Examples: public://ckeditor - image will be uploaded into public://ckeditor; images/ckeditor - image will be uploaded to :uriimages/ckeditor', array(':uri' => file_build_uri(''))),
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Path'),
|
||||
'#default_value' => isset($profile['ckeditor_upload_directory']) ? $profile['ckeditor_upload_directory'] : '',
|
||||
'#size' => 40,
|
||||
'#description' => t('Image upload path. Default file uri is used if no uri prefix specified. Examples: public://ckeditor - image will be uploaded into public://ckeditor; images/ckeditor - image will be uploaded to :uriimages/ckeditor', array(':uri' => file_build_uri(''))),
|
||||
);
|
||||
|
||||
$form['submit'] = array(
|
||||
'#type' => 'submit',
|
||||
'#name' => 'save_profile',
|
||||
'#value' => t('Save configuration')
|
||||
'#type' => 'submit',
|
||||
'#name' => 'save_profile',
|
||||
'#value' => t('Save configuration')
|
||||
);
|
||||
|
||||
$form['#submit'][] = 'elfinder_admin_submit';
|
||||
@@ -343,8 +348,8 @@ function elfinder_admin_profiles($action = '', $profile_name = '') {
|
||||
function elfinder_admin_profiles_delete_form($form_id, &$form_state, $action, $profile_name) {
|
||||
$form = array();
|
||||
$form['profile_name'] = array(
|
||||
'#type' => 'hidden',
|
||||
'#default_value' => $profile_name,
|
||||
'#type' => 'hidden',
|
||||
'#default_value' => $profile_name,
|
||||
);
|
||||
|
||||
|
||||
@@ -381,53 +386,53 @@ function elfinder_admin_dir_form($delta, $values = array(), $votes = 0) {
|
||||
|
||||
|
||||
$form['volume_settings'] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#title' => t('Volume @n (@p)', array('@n' => ($delta + 1), '@p' => $values['path'])),
|
||||
'#collapsible' => TRUE,
|
||||
'#collapsed' => FALSE,
|
||||
'#type' => 'fieldset',
|
||||
'#title' => t('Volume @n (@p)', array('@n' => ($delta + 1), '@p' => isset($values['path']) ? $values['path'] : '')),
|
||||
'#collapsible' => TRUE,
|
||||
'#collapsed' => FALSE,
|
||||
);
|
||||
|
||||
$form['volume_settings']['path'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Path'),
|
||||
'#default_value' => isset($values['path']) ? $values['path'] : '',
|
||||
'#parents' => array('volume', $delta, 'path'),
|
||||
'#prefix' => '<div class="elfinder-field-wrapper-volume-path">',
|
||||
'#suffix' => '</div>',
|
||||
'#size' => 40,
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Path'),
|
||||
'#default_value' => isset($values['path']) ? $values['path'] : '',
|
||||
'#parents' => array('volume', $delta, 'path'),
|
||||
'#prefix' => '<div class="elfinder-field-wrapper-volume-path">',
|
||||
'#suffix' => '</div>',
|
||||
'#size' => 40,
|
||||
);
|
||||
|
||||
$form['volume_settings']['label'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Label'),
|
||||
'#size' => 15,
|
||||
'#default_value' => isset($values['label']) ? $values['label'] : '',
|
||||
'#description' => t('Root directory label in directory tree'),
|
||||
'#parents' => array('volume', $delta, 'label'),
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Label'),
|
||||
'#size' => 15,
|
||||
'#default_value' => isset($values['label']) ? $values['label'] : '',
|
||||
'#description' => t('Root directory label in directory tree'),
|
||||
'#parents' => array('volume', $delta, 'label'),
|
||||
);
|
||||
|
||||
$form['volume_settings']['url'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('URL'),
|
||||
'#default_value' => isset($values['url']) ? $values['url'] : '',
|
||||
'#parents' => array('volume', $delta, 'url'),
|
||||
'#prefix' => '<div class="elfinder-field-wrapper-volume-path">',
|
||||
'#suffix' => '</div>',
|
||||
'#description' => t('Custom URL prefix (default %def)', array('%def' => $defaulturl)),
|
||||
'#size' => 40,
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('URL'),
|
||||
'#default_value' => isset($values['url']) ? $values['url'] : '',
|
||||
'#parents' => array('volume', $delta, 'url'),
|
||||
'#prefix' => '<div class="elfinder-field-wrapper-volume-path">',
|
||||
'#suffix' => '</div>',
|
||||
'#description' => t('Custom URL prefix (default %def)', array('%def' => $defaulturl)),
|
||||
'#size' => 40,
|
||||
);
|
||||
|
||||
$form['volume_settings']['delete'] = array(
|
||||
'#type' => 'submit',
|
||||
'#value' => t('Delete'),
|
||||
'#name' => 'rmfield-' . $delta,
|
||||
'#submit' => array('elfinder_admin_profile_change_volume'),
|
||||
'#ajax' => array(
|
||||
'callback' => 'elfinder_admin_profile_callback',
|
||||
'wrapper' => 'profile-volumes',
|
||||
'method' => 'replace',
|
||||
'effect' => 'fade',
|
||||
),
|
||||
'#type' => 'submit',
|
||||
'#value' => t('Delete'),
|
||||
'#name' => 'rmfield-' . $delta,
|
||||
'#submit' => array('elfinder_admin_profile_change_volume'),
|
||||
'#ajax' => array(
|
||||
'callback' => 'elfinder_admin_profile_callback',
|
||||
'wrapper' => 'profile-volumes',
|
||||
'method' => 'replace',
|
||||
'effect' => 'fade',
|
||||
),
|
||||
);
|
||||
|
||||
return $form;
|
||||
@@ -466,28 +471,28 @@ function elfinder_admin_submit($form, &$form_state) {
|
||||
|
||||
foreach ($settings as $setting) {
|
||||
if (isset($form_state['values'][$setting])) {
|
||||
|
||||
|
||||
/* Excluding empty volumes */
|
||||
if ($setting == 'volume') {
|
||||
for ($i = 0; $i < count($form_state['values']['volume']); $i++) {
|
||||
if (empty($form_state['values']['volume'][$i]['path'])) {
|
||||
unset($form_state['values']['volume'][$i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($setting == 'volume') {
|
||||
for ($i = 0; $i < count($form_state['values']['volume']); $i++) {
|
||||
if (empty($form_state['values']['volume'][$i]['path'])) {
|
||||
unset($form_state['values']['volume'][$i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$profile_settings[$setting] = $form_state['values'][$setting];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Save roles.
|
||||
$profile_settings['profile_role'] = array();
|
||||
foreach($form_state['values']['profile_role'] as $rid) {
|
||||
foreach ($form_state['values']['profile_role'] as $rid) {
|
||||
if ($rid != 0) {
|
||||
$profile_settings['profile_role'][$rid] = $rid;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$profile_name = $form_state['values']['profile_name'];
|
||||
$profile_description = $form_state['values']['profile_description'];
|
||||
|
||||
|
@@ -1,265 +1,285 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* elFinder conenctor class
|
||||
*/
|
||||
|
||||
class elFinderDrupal extends elFinder {
|
||||
public function __construct($opts) {
|
||||
if (is_callable(array($this, 'version'))) {
|
||||
|
||||
$ver = floatval($this->version());
|
||||
|
||||
if (isset(elFinder::$ApiVersion)) {
|
||||
$ver = elFinder::$ApiVersion;
|
||||
}
|
||||
|
||||
if ($ver == 2.1 && is_callable(array($this, 'revision')) && $this->revision() < 37) {
|
||||
$this->connector_unsupported_error();
|
||||
}
|
||||
|
||||
parent::__construct($opts);
|
||||
|
||||
$this->commands['desc'] = array('target' => TRUE, 'content' => FALSE);
|
||||
$this->commands['owner'] = array('target' => TRUE, 'content' => FALSE);
|
||||
$this->commands['downloadcount'] = array('target' => TRUE);
|
||||
|
||||
} else {
|
||||
$this->connector_unsupported_error();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function connector_unsupported_error() {
|
||||
$this->connector_error(t('Unsupported elFinder library version. Please upgrade.'));
|
||||
}
|
||||
|
||||
public function connector_error($message) {
|
||||
exit(drupal_json_encode(array('error' => array(strip_tags($message)))));
|
||||
}
|
||||
|
||||
/* Overriding search query argument name 'q' since it's already used in Drupal */
|
||||
|
||||
public function commandArgsList($cmd) {
|
||||
$this->commands['search']['elfinder_search_q'] = TRUE;
|
||||
return $this->commandExists($cmd) ? $this->commands[$cmd] : array();
|
||||
}
|
||||
|
||||
protected function search($args) {
|
||||
$q = trim($args['elfinder_search_q']);
|
||||
$mimes = !empty($args['mimes']) && is_array($args['mimes']) ? $args['mimes'] : array();
|
||||
$target = !empty($args['target']) ? $args['target'] : null;
|
||||
$result = array();
|
||||
$errors = array();
|
||||
|
||||
if ($target) {
|
||||
if ($volume = $this->volume($target)) {
|
||||
$result = $volume->search($q, $mimes, $target);
|
||||
$errors = array_merge($errors, $volume->error());
|
||||
}
|
||||
} else {
|
||||
foreach ($this->volumes as $volume) {
|
||||
$result = array_merge($result, $volume->search($q, $mimes));
|
||||
$errors = array_merge($errors, $volume->error());
|
||||
}
|
||||
}
|
||||
|
||||
// Exclude hidden folders from search results.
|
||||
$hidden_folders = variable_get('elfinder_settings_misc_hidden_folders', '');
|
||||
if($hidden_folders) {
|
||||
$hidden_folders = explode(',', $hidden_folders);
|
||||
foreach($result AS $key => $file) {
|
||||
$parts = explode('/', $file['path']);
|
||||
if(in_array($parts[1], $hidden_folders)) {
|
||||
unset($result[$key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$result = array('files' => $result);
|
||||
if ($errors) {
|
||||
$result['warning'] = $errors;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
protected function desc($args) {
|
||||
$target = $args['target'];
|
||||
$desc = $args['content'];
|
||||
$error = array(self::ERROR_UNKNOWN, '#' . $target);
|
||||
|
||||
if (($volume = $this->volume($target)) == FALSE
|
||||
|| ($file = $volume->file($target)) == FALSE) {
|
||||
return array('error' => $this->error($error, self::ERROR_FILE_NOT_FOUND));
|
||||
}
|
||||
|
||||
$error[1] = $file['name'];
|
||||
|
||||
if ($volume->driverId() == 'f') {
|
||||
return array('desc' => '');
|
||||
}
|
||||
|
||||
if ($volume->commandDisabled('desc')) {
|
||||
return array('error' => $this->error($error, self::ERROR_ACCESS_DENIED));
|
||||
}
|
||||
|
||||
if (($desc = $volume->desc($target, $desc)) == -1) {
|
||||
return array('error' => $this->error($error, $volume->error()));
|
||||
}
|
||||
|
||||
return array('desc' => $desc);
|
||||
}
|
||||
|
||||
protected function owner($args) {
|
||||
$target = $args['target'];
|
||||
|
||||
$error = array(self::ERROR_UNKNOWN, '#' . $target);
|
||||
|
||||
if (($volume = $this->volume($target)) == FALSE
|
||||
|| ($file = $volume->file($target)) == FALSE) {
|
||||
return array('error' => $this->error($error, self::ERROR_FILE_NOT_FOUND));
|
||||
}
|
||||
|
||||
$error[1] = $file['name'];
|
||||
|
||||
if ($volume->driverId() == 'f') {
|
||||
return array('owner' => '');
|
||||
}
|
||||
|
||||
if ($volume->commandDisabled('owner')) {
|
||||
return array('error' => $this->error($error, self::ERROR_ACCESS_DENIED));
|
||||
}
|
||||
|
||||
if (($owner = $volume->owner($target)) == FALSE) {
|
||||
return array('error' => $this->error($error, $volume->error()));
|
||||
}
|
||||
|
||||
return array('owner' => $owner);
|
||||
}
|
||||
|
||||
protected function downloadcount($args) {
|
||||
$target = $args['target'];
|
||||
|
||||
$error = array(self::ERROR_UNKNOWN, '#' . $target);
|
||||
|
||||
if (($volume = $this->volume($target)) == FALSE
|
||||
|| ($file = $volume->file($target)) == FALSE) {
|
||||
return array('error' => $this->error($error, self::ERROR_FILE_NOT_FOUND));
|
||||
}
|
||||
|
||||
$error[1] = $file['name'];
|
||||
|
||||
if ($volume->driverId() == 'f') {
|
||||
return array('downloadcount' => '');
|
||||
}
|
||||
|
||||
if ($volume->commandDisabled('downloadcount')) {
|
||||
return array('error' => $this->error($error, self::ERROR_ACCESS_DENIED));
|
||||
}
|
||||
|
||||
if (($downloadcount = $volume->downloadcount($target)) == FALSE) {
|
||||
return array('error' => $this->error($error, $volume->error()));
|
||||
}
|
||||
|
||||
return array('downloadcount' => $downloadcount);
|
||||
}
|
||||
|
||||
/**
|
||||
* Required to output file in browser when volume URL is not set
|
||||
* Return array contains opened file pointer, root itself and required headers
|
||||
*
|
||||
* @param array command arguments
|
||||
* @return array
|
||||
* @author Dmitry (dio) Levashov
|
||||
* */
|
||||
protected function file($args) {
|
||||
$target = $args['target'];
|
||||
$download = !empty($args['download']);
|
||||
$h403 = 'HTTP/1.x 403 Access Denied';
|
||||
$h404 = 'HTTP/1.x 404 Not Found';
|
||||
|
||||
if (($volume = $this->volume($target)) == FALSE) {
|
||||
return array('error' => self::$errors[self::ERROR_FILE_NOT_FOUND], 'header' => $h404, 'raw' => TRUE);
|
||||
}
|
||||
|
||||
if (($file = $volume->file($target)) == FALSE) {
|
||||
return array('error' => self::$errors[self::ERROR_FILE_NOT_FOUND], 'header' => $h404, 'raw' => TRUE);
|
||||
}
|
||||
|
||||
if (!$file['read']) {
|
||||
return array('error' => self::$errors[self::ERROR_ACCESS_DENIED], 'header' => $h403, 'raw' => TRUE);
|
||||
}
|
||||
|
||||
if ($volume->driverId() != 'f' && (($fp = $volume->open($target)) == FALSE)) {
|
||||
return array('error' => self::$errors[self::ERROR_FILE_NOT_FOUND], 'header' => $h404, 'raw' => TRUE);
|
||||
}
|
||||
|
||||
$mime = ($download) ? 'application/octet-stream' : $file['mime'];
|
||||
|
||||
$result = array(
|
||||
'volume' => $volume,
|
||||
'pointer' => $fp,
|
||||
'info' => $file,
|
||||
'header' => array(
|
||||
"Content-Type: " . $mime,
|
||||
"Content-Disposition: " . $this->GetContentDisposition($file['name'], $mime, $download),
|
||||
"Content-Location: " . $file['name'],
|
||||
'Content-Transfer-Encoding: binary',
|
||||
"Content-Length: " . $file['size'],
|
||||
"Connection: close"
|
||||
)
|
||||
);
|
||||
|
||||
$real_path = $this->realpath($target);
|
||||
module_invoke_all('file_download', $volume->drupalpathtouri($real_path));
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generating Content-Disposition HTTP header
|
||||
*
|
||||
* @param string $file Filename
|
||||
* @param string $filemime MIME Type
|
||||
* @param bool $download Disposition type (true = download file, false = open file in browser)
|
||||
* @return string
|
||||
* @author Dmitry (dio) Levashov, Alexey Sukhotin
|
||||
* */
|
||||
public static function GetContentDisposition($file, $filemime, $download = FALSE) {
|
||||
|
||||
$disp = '';
|
||||
$filename = $file;
|
||||
$ua = $_SERVER["HTTP_USER_AGENT"];
|
||||
$mime = $filemime;
|
||||
|
||||
if ($download) {
|
||||
$disp = 'attachment';
|
||||
$mime = 'application/octet-stream';
|
||||
} else {
|
||||
$disp = preg_match('/^(image|text)/i', $mime)
|
||||
|| $mime == 'application/x-shockwave-flash' ? 'inline' : 'attachment';
|
||||
}
|
||||
|
||||
$disp .= '; ';
|
||||
|
||||
if (preg_match("/MSIE ([0-9]{1,}[\.0-9]{0,})/", $ua)) {
|
||||
$filename = rawurlencode($filename);
|
||||
$filename = str_replace("+", "%20", $filename);
|
||||
//$filename = str_replace(" ", "%20", $filename);
|
||||
$disp .= "filename=" . $filename;
|
||||
} elseif (preg_match("/Firefox\/(\d+)/", $ua, $m)) {
|
||||
if ($m[1] >= 8) {
|
||||
$disp .= "filename*=?UTF-8''" . rawurlencode($filename);
|
||||
} else {
|
||||
$disp .= "filename*=\"?UTF-8''" . rawurlencode($filename) . "\";";
|
||||
}
|
||||
} else {
|
||||
$disp .= "filename=" . $filename;
|
||||
}
|
||||
|
||||
return $disp;
|
||||
}
|
||||
|
||||
}
|
||||
<?php
|
||||
/**
|
||||
* elFinder Integration
|
||||
*
|
||||
* Copyright (c) 2010-2019, Alexey Sukhotin. All rights reserved.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* elFinder conenctor class
|
||||
*/
|
||||
class elFinderDrupal extends elFinder {
|
||||
|
||||
protected $elFinderDrupalLibVersion;
|
||||
protected $elFinderDrupalLibRevision;
|
||||
|
||||
public function __construct($opts) {
|
||||
if (is_callable(array($this, 'version'))) {
|
||||
|
||||
$this->elFinderDrupalLibVersion = floatval($this->version());
|
||||
|
||||
if (isset(elFinder::$ApiVersion)) {
|
||||
$this->elFinderDrupalLibVersion = elFinder::$ApiVersion;
|
||||
}
|
||||
|
||||
if (is_callable(array($this, 'revision'))) {
|
||||
$this->elFinderDrupalLibRevision = $this->revision();
|
||||
}
|
||||
|
||||
if ($this->elFinderDrupalLibVersion == 2.1 && is_callable(array($this, 'revision')) && $this->revision() < 37) {
|
||||
$this->connector_unsupported_error();
|
||||
}
|
||||
|
||||
parent::__construct($opts);
|
||||
|
||||
$this->commands['desc'] = array('target' => TRUE, 'content' => FALSE);
|
||||
$this->commands['owner'] = array('target' => TRUE, 'content' => FALSE);
|
||||
$this->commands['downloadcount'] = array('target' => TRUE);
|
||||
|
||||
} else {
|
||||
$this->connector_unsupported_error();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function connector_unsupported_error() {
|
||||
$this->connector_error(t('Unsupported elFinder library version. Please upgrade.'));
|
||||
}
|
||||
|
||||
public function connector_error($message) {
|
||||
exit(drupal_json_encode(array('error' => array(strip_tags($message)))));
|
||||
}
|
||||
|
||||
/* Overriding search query argument name 'q' since it's already used in Drupal */
|
||||
|
||||
public function commandArgsList($cmd) {
|
||||
$this->commands['search']['elfinder_search_q'] = TRUE;
|
||||
return $this->commandExists($cmd) ? $this->commands[$cmd] : array();
|
||||
}
|
||||
|
||||
protected function search($args) {
|
||||
$q = trim($args['elfinder_search_q']);
|
||||
$mimes = !empty($args['mimes']) && is_array($args['mimes']) ? $args['mimes'] : array();
|
||||
$target = !empty($args['target']) ? $args['target'] : null;
|
||||
$result = array();
|
||||
$errors = array();
|
||||
|
||||
if ($target) {
|
||||
if ($volume = $this->volume($target)) {
|
||||
$result = $volume->search($q, $mimes, $target);
|
||||
$errors = array_merge($errors, $volume->error());
|
||||
}
|
||||
} else {
|
||||
foreach ($this->volumes as $volume) {
|
||||
$result = array_merge($result, $volume->search($q, $mimes));
|
||||
$errors = array_merge($errors, $volume->error());
|
||||
}
|
||||
}
|
||||
|
||||
// Exclude hidden folders from search results.
|
||||
$hidden_folders = variable_get('elfinder_settings_misc_hidden_folders', '');
|
||||
if($hidden_folders) {
|
||||
$hidden_folders = explode(',', $hidden_folders);
|
||||
foreach($result AS $key => $file) {
|
||||
$parts = explode('/', $file['path']);
|
||||
if(in_array($parts[1], $hidden_folders)) {
|
||||
unset($result[$key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$result = array('files' => $result);
|
||||
if ($errors) {
|
||||
$result['warning'] = $errors;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
protected function desc($args) {
|
||||
$target = $args['target'];
|
||||
$desc = $args['content'];
|
||||
$error = array(self::ERROR_UNKNOWN, '#' . $target);
|
||||
|
||||
if (($volume = $this->volume($target)) == FALSE
|
||||
|| ($file = $volume->file($target)) == FALSE) {
|
||||
return array('error' => $this->error($error, self::ERROR_FILE_NOT_FOUND));
|
||||
}
|
||||
|
||||
$error[1] = $file['name'];
|
||||
|
||||
if ($volume->driverId() == 'f') {
|
||||
return array('desc' => '');
|
||||
}
|
||||
|
||||
if ($volume->commandDisabled('desc')) {
|
||||
return array('error' => $this->error($error, self::ERROR_ACCESS_DENIED));
|
||||
}
|
||||
|
||||
if (($desc = $volume->desc($target, $desc)) == -1) {
|
||||
return array('error' => $this->error($error, $volume->error()));
|
||||
}
|
||||
|
||||
return array('desc' => $desc);
|
||||
}
|
||||
|
||||
protected function owner($args) {
|
||||
$target = $args['target'];
|
||||
|
||||
$error = array(self::ERROR_UNKNOWN, '#' . $target);
|
||||
|
||||
if (($volume = $this->volume($target)) == FALSE
|
||||
|| ($file = $volume->file($target)) == FALSE) {
|
||||
return array('error' => $this->error($error, self::ERROR_FILE_NOT_FOUND));
|
||||
}
|
||||
|
||||
$error[1] = $file['name'];
|
||||
|
||||
if ($volume->driverId() == 'f') {
|
||||
return array('owner' => '');
|
||||
}
|
||||
|
||||
if ($volume->commandDisabled('owner')) {
|
||||
return array('error' => $this->error($error, self::ERROR_ACCESS_DENIED));
|
||||
}
|
||||
|
||||
if (($owner = $volume->owner($target)) == FALSE) {
|
||||
return array('error' => $this->error($error, $volume->error()));
|
||||
}
|
||||
|
||||
return array('owner' => $owner);
|
||||
}
|
||||
|
||||
protected function downloadcount($args) {
|
||||
$target = $args['target'];
|
||||
|
||||
$error = array(self::ERROR_UNKNOWN, '#' . $target);
|
||||
|
||||
if (($volume = $this->volume($target)) == FALSE
|
||||
|| ($file = $volume->file($target)) == FALSE) {
|
||||
return array('error' => $this->error($error, self::ERROR_FILE_NOT_FOUND));
|
||||
}
|
||||
|
||||
$error[1] = $file['name'];
|
||||
|
||||
if ($volume->driverId() == 'f') {
|
||||
return array('downloadcount' => '');
|
||||
}
|
||||
|
||||
if ($volume->commandDisabled('downloadcount')) {
|
||||
return array('error' => $this->error($error, self::ERROR_ACCESS_DENIED));
|
||||
}
|
||||
|
||||
if (($downloadcount = $volume->downloadcount($target)) == FALSE) {
|
||||
return array('error' => $this->error($error, $volume->error()));
|
||||
}
|
||||
|
||||
return array('downloadcount' => $downloadcount);
|
||||
}
|
||||
|
||||
/**
|
||||
* Required to output file in browser when volume URL is not set
|
||||
* Return array contains opened file pointer, root itself and required headers
|
||||
*
|
||||
* @param array command arguments
|
||||
* @return array
|
||||
* @author Dmitry (dio) Levashov
|
||||
* */
|
||||
protected function file($args) {
|
||||
|
||||
if ($this->elFinderDrupalLibVersion >= 2.1 && $this->elFinderDrupalLibRevision > 38) {
|
||||
return parent::file($args);
|
||||
}
|
||||
|
||||
$target = $args['target'];
|
||||
$download = !empty($args['download']);
|
||||
$h403 = 'HTTP/1.x 403 Access Denied';
|
||||
$h404 = 'HTTP/1.x 404 Not Found';
|
||||
|
||||
if (($volume = $this->volume($target)) == FALSE) {
|
||||
return array('error' => self::$errors[self::ERROR_FILE_NOT_FOUND], 'header' => $h404, 'raw' => TRUE);
|
||||
}
|
||||
|
||||
if (($file = $volume->file($target)) == FALSE) {
|
||||
return array('error' => self::$errors[self::ERROR_FILE_NOT_FOUND], 'header' => $h404, 'raw' => TRUE);
|
||||
}
|
||||
|
||||
if (!$file['read']) {
|
||||
return array('error' => self::$errors[self::ERROR_ACCESS_DENIED], 'header' => $h403, 'raw' => TRUE);
|
||||
}
|
||||
|
||||
if ($volume->driverId() != 'f' && (($fp = $volume->open($target)) == FALSE)) {
|
||||
return array('error' => self::$errors[self::ERROR_FILE_NOT_FOUND], 'header' => $h404, 'raw' => TRUE);
|
||||
}
|
||||
|
||||
$mime = ($download) ? 'application/octet-stream' : $file['mime'];
|
||||
|
||||
$result = array(
|
||||
'volume' => $volume,
|
||||
'pointer' => $fp,
|
||||
'info' => $file,
|
||||
'header' => array(
|
||||
"Content-Type: " . $mime,
|
||||
"Content-Disposition: " . $this->GetContentDisposition($file['name'], $mime, $download),
|
||||
"Content-Location: " . $file['name'],
|
||||
'Content-Transfer-Encoding: binary',
|
||||
"Content-Length: " . $file['size'],
|
||||
"Connection: close"
|
||||
)
|
||||
);
|
||||
|
||||
$real_path = $this->realpath($target);
|
||||
module_invoke_all('file_download', $volume->drupalpathtouri($real_path));
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generating Content-Disposition HTTP header
|
||||
*
|
||||
* @param string $file Filename
|
||||
* @param string $filemime MIME Type
|
||||
* @param bool $download Disposition type (true = download file, false = open file in browser)
|
||||
* @return string
|
||||
* @author Dmitry (dio) Levashov, Alexey Sukhotin
|
||||
* */
|
||||
public static function GetContentDisposition($file, $filemime, $download = FALSE) {
|
||||
|
||||
$disp = '';
|
||||
$filename = $file;
|
||||
$ua = $_SERVER["HTTP_USER_AGENT"];
|
||||
$mime = $filemime;
|
||||
|
||||
if ($download) {
|
||||
$disp = 'attachment';
|
||||
$mime = 'application/octet-stream';
|
||||
} else {
|
||||
$disp = preg_match('/^(image|text)/i', $mime)
|
||||
|| $mime == 'application/x-shockwave-flash' ? 'inline' : 'attachment';
|
||||
}
|
||||
|
||||
$disp .= '; ';
|
||||
|
||||
if (preg_match("/MSIE ([0-9]{1,}[\.0-9]{0,})/", $ua)) {
|
||||
$filename = rawurlencode($filename);
|
||||
$filename = str_replace("+", "%20", $filename);
|
||||
//$filename = str_replace(" ", "%20", $filename);
|
||||
$disp .= "filename=" . $filename;
|
||||
} elseif (preg_match("/Firefox\/(\d+)/", $ua, $m)) {
|
||||
if ($m[1] >= 8) {
|
||||
$disp .= "filename*=?UTF-8''" . rawurlencode($filename);
|
||||
} else {
|
||||
$disp .= "filename*=\"?UTF-8''" . rawurlencode($filename) . "\";";
|
||||
}
|
||||
} elseif (preg_match("/Chrome\/(\d+)/", $ua, $m)) {
|
||||
$disp .= "filename=\"" . $filename . "\"";
|
||||
} else {
|
||||
$disp .= "filename=" . $filename;
|
||||
}
|
||||
|
||||
return $disp;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@@ -1,108 +1,114 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
* elfinder ACL class
|
||||
*/
|
||||
class elFinderDrupalACL {
|
||||
|
||||
public function fsAccessPublic($attr, $path, $data, $volume) {
|
||||
|
||||
if (strpos(basename($path), '.') === 0 && $attr == 'hidden') {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* Hiding thumbnail folder */
|
||||
if (strstr($path, DIRECTORY_SEPARATOR . variable_get('elfinder_settings_thumbnail_dirname', 'tmb')) && $attr == 'hidden') {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// Hide folders hidden by config settings.
|
||||
$f = drupal_realpath("public://") . "/";
|
||||
$folder = str_replace($f, "", $path);
|
||||
$hidden_folder = preg_split("/[\s,]+/", variable_get('elfinder_settings_misc_hidden_folders', ''));
|
||||
if (in_array($folder, $hidden_folder) && $attr == 'hidden') {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (strstr($path, DIRECTORY_SEPARATOR . '.quarantine') && $attr == 'hidden') {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if ($attr == 'read') {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if ($attr == 'write') {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* if ($attr == 'write' && user_access('write public files')) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if ($attr == 'locked' && !user_access('write public files')) {
|
||||
return TRUE;
|
||||
} */
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
public function fsAccessPrivate($attr, $path, $data, $volume) {
|
||||
|
||||
if (strpos(basename($path), '.') === 0 && $attr == 'hidden') {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* Hiding thumbnail folder */
|
||||
if (strstr($path, DIRECTORY_SEPARATOR . variable_get('elfinder_settings_thumbnail_dirname', 'tmb')) && $attr == 'hidden') {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (strstr($path, DIRECTORY_SEPARATOR . '.quarantine') && $attr == 'hidden') {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if ($attr == 'read') {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
if ($attr == 'write') {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* if ($attr == 'write' && user_access('write public files')) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if ($attr == 'locked' && !user_access('write public files')) {
|
||||
return TRUE;
|
||||
} */
|
||||
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
public function fsAccessUnmanaged($attr, $path, $data, $volume) {
|
||||
|
||||
if (strpos(basename($path), '.') === 0 && $attr == 'hidden') {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* Hiding thumbnail folder */
|
||||
if (strstr($path, DIRECTORY_SEPARATOR . variable_get('elfinder_settings_thumbnail_dirname', 'tmb')) && $attr == 'hidden') {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (strstr($path, DIRECTORY_SEPARATOR . '.quarantine') && $attr == 'hidden') {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if ($attr == 'read') {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
<?php
|
||||
/**
|
||||
* elFinder Integration
|
||||
*
|
||||
* Copyright (c) 2010-2018, Alexey Sukhotin. All rights reserved.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* elfinder ACL class
|
||||
*/
|
||||
class elFinderDrupalACL {
|
||||
|
||||
public function fsAccessPublic($attr, $path, $data, $volume) {
|
||||
|
||||
if (strpos(basename($path), '.') === 0 && $attr == 'hidden') {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* Hiding thumbnail folder */
|
||||
if (strstr($path, DIRECTORY_SEPARATOR . variable_get('elfinder_settings_thumbnail_dirname', 'tmb')) && $attr == 'hidden') {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// Hide folders hidden by config settings.
|
||||
$f = drupal_realpath("public://") . "/";
|
||||
$folder = str_replace($f, "", $path);
|
||||
$hidden_folder = preg_split("/[\s,]+/", variable_get('elfinder_settings_misc_hidden_folders', ''));
|
||||
if (in_array($folder, $hidden_folder) && $attr == 'hidden') {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (strstr($path, DIRECTORY_SEPARATOR . '.quarantine') && $attr == 'hidden') {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if ($attr == 'read') {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if ($attr == 'write') {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* if ($attr == 'write' && user_access('write public files')) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if ($attr == 'locked' && !user_access('write public files')) {
|
||||
return TRUE;
|
||||
} */
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
public function fsAccessPrivate($attr, $path, $data, $volume) {
|
||||
|
||||
if (strpos(basename($path), '.') === 0 && $attr == 'hidden') {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* Hiding thumbnail folder */
|
||||
if (strstr($path, DIRECTORY_SEPARATOR . variable_get('elfinder_settings_thumbnail_dirname', 'tmb')) && $attr == 'hidden') {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (strstr($path, DIRECTORY_SEPARATOR . '.quarantine') && $attr == 'hidden') {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if ($attr == 'read') {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
if ($attr == 'write') {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* if ($attr == 'write' && user_access('write public files')) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if ($attr == 'locked' && !user_access('write public files')) {
|
||||
return TRUE;
|
||||
} */
|
||||
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
public function fsAccessUnmanaged($attr, $path, $data, $volume) {
|
||||
|
||||
if (strpos(basename($path), '.') === 0 && $attr == 'hidden') {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* Hiding thumbnail folder */
|
||||
if (strstr($path, DIRECTORY_SEPARATOR . variable_get('elfinder_settings_thumbnail_dirname', 'tmb')) && $attr == 'hidden') {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (strstr($path, DIRECTORY_SEPARATOR . '.quarantine') && $attr == 'hidden') {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if ($attr == 'read') {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
}
|
@@ -40,15 +40,16 @@ class elFinderVolumeDrupal extends elFinderVolumeLocalFileSystem {
|
||||
$pvtpath = drupal_realpath('private://');
|
||||
$pubpath = drupal_realpath('public://');
|
||||
$tmppath = drupal_realpath('temporary://');
|
||||
$final_path = DIRECTORY_SEPARATOR !== '/' ? str_replace(DIRECTORY_SEPARATOR, '/', $path) : $path;
|
||||
|
||||
$uri = '';
|
||||
|
||||
if (strpos($path, $pvtpath) === 0) {
|
||||
$uri = 'private://' . substr($path, strlen($pvtpath) + 1);
|
||||
} elseif (strpos($path, $tmppath) === 0) {
|
||||
$uri = 'temporary://' . substr($path, strlen($tmppath) + 1);
|
||||
if (strpos($final_path, $pvtpath) === 0) {
|
||||
$uri = 'private://' . substr($final_path, strlen($pvtpath) + 1);
|
||||
} elseif (strpos($final_path, $tmppath) === 0) {
|
||||
$uri = 'temporary://' . substr($final_path, strlen($tmppath) + 1);
|
||||
} else {
|
||||
$uri = 'public://' . substr($path, strlen($pubpath) + 1);
|
||||
$uri = 'public://' . substr($final_path, strlen($pubpath) + 1);
|
||||
}
|
||||
|
||||
return @file_stream_wrapper_uri_normalize($uri);
|
||||
@@ -357,7 +358,8 @@ class elFinderVolumeDrupal extends elFinderVolumeLocalFileSystem {
|
||||
$this->setError(strip_tags(implode(' ', $validation_errors)));
|
||||
return FALSE;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
watchdog('elfinder', 'File upload "' . $name . '" not found in $_FILES');
|
||||
}
|
||||
return TRUE;
|
||||
@@ -405,6 +407,12 @@ class elFinderVolumeDrupal extends elFinderVolumeLocalFileSystem {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
public static function stat_corrector(&$stat, $path, $statOwner, $volumeDriveInstance) {
|
||||
if (method_exists($volumeDriveInstance, 'owner')) {
|
||||
$stat['owner'] = $volumeDriveInstance->owner($volumeDriveInstance->encode($path));
|
||||
}
|
||||
}
|
||||
|
||||
public function desc($target, $newdesc = NULL) {
|
||||
$path = $this->decode($target);
|
||||
|
||||
|
Reference in New Issue
Block a user