added elfinder module
11
sites/all/modules/contrib/files/elfinder/CHANGELOG.txt
Normal file
@@ -0,0 +1,11 @@
|
||||
2.x-dev
|
||||
-------
|
||||
- Now requires elFinder 2.0.9+
|
||||
- Added multiple root directories support
|
||||
- Added Drupal file_managed table synchronization
|
||||
- Added per-role configurable profiles support
|
||||
- Added UTF-8 downloaded filenames support
|
||||
- Added CKEditor and FCKeditor Upload tab support
|
||||
- New library search algoritm with install profiles and multiple sites support
|
||||
- Search support
|
||||
|
339
sites/all/modules/contrib/files/elfinder/LICENSE.txt
Normal file
@@ -0,0 +1,339 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Lesser General Public License instead.) You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. You must make sure that they, too, receive or can get the
|
||||
source code. And you must show them these terms so they know their
|
||||
rights.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's
|
||||
source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate
|
||||
copyright notice and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) year name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License.
|
83
sites/all/modules/contrib/files/elfinder/README.txt
Normal file
@@ -0,0 +1,83 @@
|
||||
elFinder file manager integration module for Drupal
|
||||
===================================================
|
||||
|
||||
System Requirements:
|
||||
|
||||
- Drupal 7.x
|
||||
- elFinder 2.0.9+
|
||||
|
||||
Note: elFinder 2.0rc1 no more supported - use 2.x dev build from
|
||||
http://sourceforge.net/projects/drupal-elfinder/files/Library/
|
||||
or use production version if it is available
|
||||
|
||||
Optional:
|
||||
|
||||
- Wysiwyg module
|
||||
- Wysiwyg editor:
|
||||
|
||||
- CKEditor
|
||||
- FCKeditor
|
||||
- TinyMCE 3
|
||||
- BUEdtor
|
||||
- jWYSIWYG (jWYSIWYG 0.93+, jquery 1.3+, jquery ui 1.7+)
|
||||
- YUI Editor
|
||||
- WYMeditor
|
||||
|
||||
|
||||
Installation:
|
||||
|
||||
1. Unpack archive contents into modules/elfinder
|
||||
2. Get latest elFinder at http://sourceforge.net/projects/drupal-elfinder/files/Library/ and it's contents to sites/all/libraries/elfinder
|
||||
3. REMOVE following files from library directory if it exists to avoid security hole:
|
||||
|
||||
sites/all/libraries/elfinder/elfinder.php.html
|
||||
sites/all/libraries/elfinder/connectors/php/connector.php
|
||||
sites/all/libraries/elfinder/php/connector.php
|
||||
|
||||
4. Enable elFinder module in Modules > List menu
|
||||
5. Add 'use file manager' permission to users who will be able to use elFinder at Modules > elFinder > Permissions menu
|
||||
6. Enable elFinder checkbox in your editor Wysiwyg profile at Configuration > Wysiwyg profiles > <Editor Profile> Buttons and Plugins
|
||||
|
||||
Usage:
|
||||
|
||||
1. Administration backend
|
||||
|
||||
a. Open /elfinder url (or ?q=elfinder if seo-capable urls disabled)
|
||||
b. Go to Administer page. Click 'Files' under Content section.
|
||||
|
||||
2. Inside CKEditor (FCKeditor)
|
||||
2.1. Open Image Properties dialog in editor
|
||||
2.2. Click Browse Server button near image url
|
||||
|
||||
3. Inside TinyMCE
|
||||
3.1. Open Insert/edit image dialog
|
||||
3.2. Click Browse button near image url
|
||||
|
||||
4. Inside BUEditor
|
||||
4.1. Click 'Insert/edit image'
|
||||
4.2. Click 'Browse'
|
||||
4.3. Select file
|
||||
4.4. Enter alt text then click OK
|
||||
|
||||
5. Inside jWYSIWYG
|
||||
5.1. Make sure that you have jWYSYWIG 0.93+ (http://github.com/akzhan/jwysiwyg/), jQuery 1.3+ and jQuery UI 1.7+ installed
|
||||
5.2. Click 'Insert image' button
|
||||
5.3. Click 'Browse Server' button near image url
|
||||
|
||||
6. Inside YUI Editor
|
||||
6.1. Click 'Insert Image' button
|
||||
6.2. Click 'Browse Server' button near image url
|
||||
|
||||
7. Inside WYMeditor
|
||||
7.1. Click 'Image' button
|
||||
7.2. Click 'Browse Server' button near image url
|
||||
|
||||
|
||||
|
||||
Known Issues:
|
||||
|
||||
- Not all editors supported
|
||||
- Conflicting with some devel module features
|
||||
|
||||
|
||||
|
@@ -0,0 +1,5 @@
|
||||
.elfinder-field-wrapper-volume-path {
|
||||
float:left;
|
||||
width:300px;
|
||||
bborder:#f00 1px solid;
|
||||
}
|
@@ -0,0 +1,27 @@
|
||||
|
||||
.el-finder-nav ul li {
|
||||
background:none;
|
||||
padding:0;
|
||||
margin:0;
|
||||
}
|
||||
.elfinder-cwd, .elfinder-navbar {
|
||||
font-size:13px!important;
|
||||
}
|
||||
|
||||
.elfinder-cwd-view-icons .elfinder-cwd-file {
|
||||
height: 150px;
|
||||
width: 100px;
|
||||
}
|
||||
|
||||
.elfinder-cwd-view-icons .elfinder-cwd-filename {
|
||||
white-space: normal;
|
||||
overflow:visible;
|
||||
}
|
||||
|
||||
body.elfinder #finder {
|
||||
border: none;
|
||||
}
|
||||
|
||||
body.elfinder .elfinder-toolbar, body.elfinder .elfinder-statusbar {
|
||||
border-radius: 0 !important;
|
||||
}
|
@@ -0,0 +1,6 @@
|
||||
|
||||
.el-finder-nav ul li {
|
||||
background:none;
|
||||
padding:0;
|
||||
margin:0;
|
||||
}
|
@@ -0,0 +1,9 @@
|
||||
|
||||
.el-finder-nav ul {
|
||||
list-style-type:none!important;
|
||||
}
|
||||
|
||||
.el-finder-cwd label {
|
||||
font-weight:normal!important;
|
||||
overflow:visible!important;
|
||||
}
|
After Width: | Height: | Size: 212 B |
After Width: | Height: | Size: 208 B |
After Width: | Height: | Size: 335 B |
After Width: | Height: | Size: 207 B |
After Width: | Height: | Size: 262 B |
After Width: | Height: | Size: 262 B |
After Width: | Height: | Size: 332 B |
After Width: | Height: | Size: 280 B |
After Width: | Height: | Size: 6.8 KiB |
After Width: | Height: | Size: 4.4 KiB |
After Width: | Height: | Size: 6.8 KiB |
After Width: | Height: | Size: 6.8 KiB |
After Width: | Height: | Size: 4.4 KiB |
5
sites/all/modules/contrib/files/elfinder/css/ui-themes/smoothness/jquery-ui.custom.css
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
@import url('jquery-ui.min.css');
|
||||
@import url('jquery-ui.structure.min.css');
|
||||
@import url('jquery-ui.theme.min.css');
|
||||
|
||||
|
7
sites/all/modules/contrib/files/elfinder/css/ui-themes/smoothness/jquery-ui.min.css
vendored
Normal file
5
sites/all/modules/contrib/files/elfinder/css/ui-themes/smoothness/jquery-ui.theme.min.css
vendored
Normal file
@@ -0,0 +1 @@
|
||||
// $Id$
|
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
* BUEditor integration plugin
|
||||
*/
|
||||
|
||||
/**
|
||||
* Pseudo-hook for elfinder hook_wysiwyg_plugin implementation
|
||||
*/
|
||||
function elfinder_bueditor_elfinder_editor_plugin($options) {
|
||||
drupal_add_js(array('elfinder' => array('moduleUrl' => url('elfinder'))), 'setting');
|
||||
drupal_add_js(array('elfinder' => array('moduleUrl' => url('elfinder'))), 'setting');
|
||||
drupal_add_js($options['plugin_url_base'] . '/bueditor.js');
|
||||
|
||||
return array(
|
||||
'elfinder' => array(
|
||||
'extensions' => array('elfinder' => t('elFinder')),
|
||||
'url' => $options['homepage_url'],
|
||||
'options' => array(),
|
||||
'load' => FALSE,
|
||||
),
|
||||
);
|
||||
}
|
@@ -0,0 +1,12 @@
|
||||
// $Id: elfinder.bueditor.js,v 1.1 2010/10/06 09:44:51 ph0enix Exp $
|
||||
|
||||
Drupal.elfinder.editor.bueditor = {
|
||||
fn : {
|
||||
attach: Drupal.wysiwyg.editor.attach.bueditor
|
||||
}
|
||||
}
|
||||
|
||||
Drupal.wysiwyg.editor.attach.bueditor = function(context, params, settings) {
|
||||
Drupal.settings.BUE.imceURL = Drupal.settings.elfinder.moduleUrl;
|
||||
Drupal.elfinder.editor.bueditor.fn.attach.apply(this, arguments);
|
||||
}
|
@@ -0,0 +1,30 @@
|
||||
|
||||
|
||||
function elfinder_ckeditor_callback(arg1) {
|
||||
|
||||
var url = arg1;
|
||||
|
||||
if (typeof arg1 == 'object') {
|
||||
url = arg1.url;
|
||||
}
|
||||
funcNum = window.location.search.replace(/^.*CKEditorFuncNum=(\d+).*$/, "$1");
|
||||
window.opener.CKEDITOR.tools.callFunction(funcNum, url, function() {
|
||||
// adapted from http://docs.ckeditor.com/#!/guide/dev_file_browser_api
|
||||
var dialog = this.getDialog();
|
||||
if (dialog.getName() == 'link' ) {
|
||||
var element = dialog.getContentElement('info', 'linkDisplayText');
|
||||
var display_text = element.getValue();
|
||||
// If display text is blank, insert the filename.
|
||||
if (element && !display_text) {
|
||||
element.setValue(arg1.name);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Avoid beforeunload event when selecting an image.
|
||||
// See https://github.com/Studio-42/elFinder/issues/1340
|
||||
// Maybe remove this when elfinder js library gets updated.
|
||||
$(window).off('beforeunload');
|
||||
|
||||
window.close();
|
||||
}
|
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* CKeditor integration plugin
|
||||
*/
|
||||
|
||||
/**
|
||||
* Pseudo-hook for elfinder hook_wysiwyg_plugin implementation
|
||||
*/
|
||||
function elfinder_ckeditor_elfinder_editor_plugin($options) {
|
||||
return array(
|
||||
'elfinder' => array(
|
||||
'extensions' => array('elfinder' => t('elFinder')),
|
||||
'url' => $options['homepage_url'],
|
||||
'options' => array(
|
||||
'filebrowserBrowseUrl' => $options['elfinder_url'],
|
||||
'filebrowserUploadUrl' => url('elfinder/upload/ckeditor'),
|
||||
'filebrowserImageUploadUrl' => url('elfinder/upload/ckeditor'),
|
||||
'filebrowserFlashUploadUrl' => url('elfinder/upload/ckeditor'),
|
||||
),
|
||||
'load' => FALSE,
|
||||
),
|
||||
);
|
||||
}
|
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* CKeditor Upload tab support
|
||||
*/
|
||||
|
||||
function elfinder_editor_upload_ckeditor() {
|
||||
|
||||
$p = elfinder_get_user_profile();
|
||||
|
||||
$dest = file_build_uri('');
|
||||
|
||||
if (!strpos($p->settings['ckeditor_upload_directory'], '://')) {
|
||||
$dest .= $p->settings['ckeditor_upload_directory'];
|
||||
} else {
|
||||
$dest = $p->settings['ckeditor_upload_directory'];
|
||||
}
|
||||
|
||||
$dest = elfinder_parse_path_tokens($dest);
|
||||
|
||||
$destabs = drupal_realpath($dest);
|
||||
|
||||
if (!file_prepare_directory($destabs, FILE_CREATE_DIRECTORY)) {
|
||||
drupal_set_message(t('Error. Cannot initialize directory %dir', array('%dir' => $destabs)), 'error');
|
||||
}
|
||||
|
||||
$tmpf = $_FILES;
|
||||
|
||||
foreach (array_keys($_FILES['upload']) as $key) {
|
||||
$tmpf['files'][$key]['upload'] = $_FILES['upload'][$key];
|
||||
}
|
||||
|
||||
$_FILES = $tmpf;
|
||||
|
||||
$file = file_save_upload('upload', array(), $dest);
|
||||
$file->status = FILE_STATUS_PERMANENT;
|
||||
file_save($file);
|
||||
|
||||
header('Content-Type: text/html');
|
||||
|
||||
print '<script type="text/javascript">';
|
||||
|
||||
if ($file) {
|
||||
print "window.parent.CKEDITOR.tools.callFunction(2, '" . file_create_url($file->uri) . "', '');";
|
||||
} else {
|
||||
print "window.parent.CKEDITOR.tools.callFunction(2, '', '" . t('Error uploading file!') . "');";
|
||||
}
|
||||
|
||||
print '</script>';
|
||||
|
||||
exit();
|
||||
}
|
@@ -0,0 +1,5 @@
|
||||
// $Id$
|
||||
|
||||
function elfinder_drupalnodeattach_callback(url) {
|
||||
parent.jQuery('input#edit-attach-url').val(url);
|
||||
}
|
@@ -0,0 +1 @@
|
||||
// $Id$
|
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
* FCKeditor integration plugin
|
||||
*/
|
||||
|
||||
/**
|
||||
* Pseudo-hook for elfinder hook_wysiwyg_plugin implementation
|
||||
*/
|
||||
function elfinder_fckeditor_elfinder_editor_plugin($options) {
|
||||
return array(
|
||||
'elfinder' => array(
|
||||
'extensions' => array('elfinder' => t('elFinder')),
|
||||
'url' => $options['homepage_url'],
|
||||
'options' => array(
|
||||
'LinkBrowser' => TRUE,
|
||||
'LinkBrowserURL' => $options['elfinder_url'],
|
||||
'ImageBrowser' => TRUE,
|
||||
'ImageBrowserURL' => $options['elfinder_url'],
|
||||
'FlashBrowser' => TRUE,
|
||||
'FlashBrowserURL' => $options['elfinder_url'],
|
||||
'ImageUpload' => TRUE,
|
||||
'ImageUploadURL' => url('elfinder/upload/fckeditor'),
|
||||
'FlashUpload' => TRUE,
|
||||
// 'FlashUploadURL' => $options['elfinder_connector_url'],
|
||||
'LinkUpload' => TRUE,
|
||||
// 'LinkUploadURL' => $options['elfinder_connector_url'],
|
||||
|
||||
|
||||
),
|
||||
'load' => FALSE,
|
||||
),
|
||||
);
|
||||
}
|
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* FCKeditor Upload tab support
|
||||
*/
|
||||
|
||||
function elfinder_editor_upload_fckeditor() {
|
||||
|
||||
$p = elfinder_get_user_profile();
|
||||
|
||||
$dest = file_build_uri('');
|
||||
|
||||
if (!strpos($p->settings['ckeditor_upload_directory'], '://')) {
|
||||
$dest .= $p->settings['ckeditor_upload_directory'];
|
||||
} else {
|
||||
$dest = $p->settings['ckeditor_upload_directory'];
|
||||
}
|
||||
|
||||
$dest = elfinder_parse_path_tokens($dest);
|
||||
|
||||
$destabs = drupal_realpath($dest);
|
||||
|
||||
if (!file_prepare_directory($destabs, FILE_CREATE_DIRECTORY)) {
|
||||
drupal_set_message(t('Error. Cannot initialize directory %dir', array('%dir' => $destabs)), 'error');
|
||||
}
|
||||
|
||||
$tmpf = $_FILES;
|
||||
|
||||
foreach (array_keys($_FILES['NewFile']) as $key) {
|
||||
$tmpf['files'][$key]['NewFile'] = $_FILES['NewFile'][$key];
|
||||
}
|
||||
|
||||
$_FILES = $tmpf;
|
||||
|
||||
$file = file_save_upload('NewFile', array(), $dest);
|
||||
$file->status = FILE_STATUS_PERMANENT;
|
||||
file_save($file);
|
||||
|
||||
|
||||
header('Content-Type: text/html');
|
||||
|
||||
print '<script type="text/javascript">';
|
||||
|
||||
if ($file) {
|
||||
print "window.parent.OnUploadCompleted(0, '" . file_create_url($file->uri) . "', '" . $file->filename . "', '') ;";
|
||||
} else {
|
||||
print 'window.parent.OnUploadCompleted(1,"","", "' . t('Error uploading file!') . '") ;';
|
||||
}
|
||||
|
||||
print '</script>';
|
||||
|
||||
exit();
|
||||
}
|
@@ -0,0 +1 @@
|
||||
// $Id$
|
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
* jWYSIWYG integration plugin
|
||||
*/
|
||||
|
||||
/**
|
||||
* Pseudo-hook for elfinder hook_wysiwyg_plugin implementation
|
||||
*/
|
||||
function elfinder_jwysiwyg_elfinder_editor_plugin($options) {
|
||||
if (module_exists('jquery_update') && module_exists('jquery_ui')) {
|
||||
drupal_add_css(JQUERY_UI_PATH . '/themes/base/ui.all.css');
|
||||
jquery_ui_add(array('ui.dialog', 'ui.accordion', 'ui.draggable', 'ui.droppable', 'ui.selectable'));
|
||||
} else {
|
||||
drupal_set_message(t('elFinder requires jQuery 1.3+ and jQuery UI 1.7+ for jWYSIWYG support. Please install and enable <a href="http://drupal.org/project/jquery_update">jquery_update</a> and <a href="http://drupal.org/project/jquery_ui">jquery_ui</a> modules.'), 'error');
|
||||
}
|
||||
|
||||
drupal_add_js(array('elfinder' => array('file_browser_url' => $options['elfinder_url'])), 'setting');
|
||||
drupal_add_js($options['plugin_url_base'] . '/jwysiwyg.js');
|
||||
|
||||
return array(
|
||||
'elfinder' => array(
|
||||
'extensions' => array('elfinder' => t('elFinder')),
|
||||
'url' => $options['homepage_url'],
|
||||
'options' => array(),
|
||||
'load' => FALSE,
|
||||
),
|
||||
);
|
||||
}
|
@@ -0,0 +1,34 @@
|
||||
// $Id: elfinder.jwysiwyg.js,v 1.1 2010/10/06 09:44:51 ph0enix Exp $
|
||||
|
||||
(function($) {
|
||||
|
||||
Drupal.elfinder.editor.jwysiwyg = {
|
||||
fn : {
|
||||
attach: Drupal.wysiwyg.editor.attach.jwysiwyg
|
||||
}
|
||||
}
|
||||
|
||||
Drupal.wysiwyg.editor.attach.jwysiwyg = function(context, params, settings) {
|
||||
|
||||
var imgHtml = null;
|
||||
|
||||
if (jQuery.fn.wysiwyg.defaults) {
|
||||
imgHtml = jQuery.fn.wysiwyg.defaults.formImageHtml;
|
||||
}
|
||||
|
||||
var oImgHtml = $('<div>'+imgHtml+'</div>');
|
||||
var oUrl = $("input[name=url]", oImgHtml);
|
||||
var browsebutton = $('<input type="button">');
|
||||
|
||||
browsebutton.attr('value', Drupal.t('Browse Server'));
|
||||
browsebutton.attr('onclick', 'var w = window; w.open("' + Drupal.settings.elfinder.file_browser_url + '","","toolbar=no,menubar=no,width=600,height=600")');
|
||||
browsebutton.insertAfter(oUrl);
|
||||
|
||||
if (jQuery.fn.wysiwyg.defaults) {
|
||||
jQuery.fn.wysiwyg.defaults.formImageHtml = oImgHtml.html();
|
||||
}
|
||||
|
||||
Drupal.elfinder.editor.jwysiwyg.fn.attach.apply(this, arguments);
|
||||
}
|
||||
|
||||
})(jQuery);
|
@@ -0,0 +1 @@
|
||||
// $Id$
|
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
* TinyMCE integration plugin
|
||||
*/
|
||||
|
||||
/**
|
||||
* Pseudo-hook for elfinder hook_wysiwyg_plugin implementation
|
||||
*/
|
||||
function elfinder_tinymce_elfinder_editor_plugin($options) {
|
||||
drupal_add_js($options['plugin_url_base'] . '/tinymce.js');
|
||||
return array(
|
||||
'elfinder' => array(
|
||||
'extensions' => array('elfinder' => t('elFinder')),
|
||||
'url' => $options['homepage_url'],
|
||||
'options' => array(
|
||||
'file_browser_callback' => 'elfinder_tinymce_browse_callback',
|
||||
'file_browser_url' => $options['elfinder_url'], // non standard TinyMCE configuration variable to pass source application to elFinder
|
||||
'inline_styles' => TRUE,
|
||||
),
|
||||
'load' => FALSE,
|
||||
),
|
||||
);
|
||||
}
|
@@ -0,0 +1,27 @@
|
||||
function elfinder_tinymce_browse_callback(field_name, url, type, win) {
|
||||
|
||||
var cmsURL = tinymce.settings.file_browser_url; // script URL - use an absolute path!
|
||||
if (cmsURL.indexOf("?") < 0) {
|
||||
//add the type as the only query parameter
|
||||
cmsURL = cmsURL + "?type=" + type;
|
||||
} else {
|
||||
//add the type as an additional query parameter
|
||||
// (PHP session ID is now included if there is one at all)
|
||||
cmsURL = cmsURL + "&type=" + type;
|
||||
}
|
||||
|
||||
tinyMCE.activeEditor.windowManager.open({
|
||||
file: cmsURL,
|
||||
title: 'File Manager',
|
||||
width: 900,
|
||||
height: 450,
|
||||
resizable: "yes",
|
||||
inline: "yes", // This parameter only has an effect if you use the inlinepopups plugin!
|
||||
popup_css: false, // Disable TinyMCE's default popup CSS
|
||||
close_previous: "no"
|
||||
}, {
|
||||
window: win,
|
||||
input: field_name
|
||||
});
|
||||
return false;
|
||||
}
|
@@ -0,0 +1,4 @@
|
||||
function elfinder_wymeditor_callback(url) {
|
||||
window.opener.jQuery('input.wym_src').val(url);
|
||||
window.close();
|
||||
}
|
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
// $Id$
|
||||
|
||||
/**
|
||||
* @file
|
||||
* WYMeditor integration plugin
|
||||
*/
|
||||
|
||||
/**
|
||||
* Pseudo-hook for elfinder hook_wysiwyg_plugin implementation
|
||||
*/
|
||||
function elfinder_wymeditor_elfinder_editor_plugin($options) {
|
||||
drupal_add_js($options['plugin_url_base'] . '/wymeditor.js');
|
||||
drupal_add_js(array('elfinder' => array('file_browser_url' => $options['elfinder_url'])), 'setting');
|
||||
return array(
|
||||
'elfinder' => array(
|
||||
'extensions' => array('elfinder' => t('elFinder')),
|
||||
'url' => $options['homepage_url'],
|
||||
'options' => array(),
|
||||
'load' => FALSE,
|
||||
),
|
||||
);
|
||||
}
|
@@ -0,0 +1,52 @@
|
||||
// $Id: elfinder.wymeditor.js,v 1.1.2.2 2010/12/11 11:53:49 ph0enix Exp $
|
||||
|
||||
(function($) {
|
||||
|
||||
Drupal.elfinder.editor.wymeditor = {
|
||||
fn : {
|
||||
attach: Drupal.wysiwyg.editor.attach.wymeditor
|
||||
}
|
||||
}
|
||||
|
||||
Drupal.wysiwyg.editor.attach.wymeditor = function(context, params, settings) {
|
||||
|
||||
Drupal.elfinder.editor.wymeditor.fn.attach.apply(this, arguments);
|
||||
|
||||
var $field = $('#' + params.field);
|
||||
var index = $field.data(WYMeditor.WYM_INDEX);
|
||||
|
||||
if (typeof index != 'undefined') {
|
||||
var instance = WYMeditor.INSTANCES[index];
|
||||
|
||||
var imgHtml = instance._options.dialogImageHtml;
|
||||
|
||||
var oImgHtml = $('<div>'+imgHtml+'</div>');
|
||||
|
||||
var oUrl = $("input.wym_src", oImgHtml);
|
||||
var browsebutton = $('<input type="button">');
|
||||
browsebutton.attr('value', Drupal.t('Browse Server'));
|
||||
|
||||
/* FIXME: url parameters duplicates for some reason */
|
||||
var tmp = Drupal.settings.elfinder.file_browser_url;
|
||||
var bugpos = tmp.indexOf(",");
|
||||
|
||||
var elfinderUrl = '';
|
||||
|
||||
if (bugpos != -1) {
|
||||
elfinderUrl = tmp.slice(0, bugpos);
|
||||
}
|
||||
else {
|
||||
elfinderUrl = tmp;
|
||||
}
|
||||
|
||||
browsebutton.attr('onclick', 'var w = window; w.open("' + elfinderUrl + '","","toolbar=no,menubar=no,width=600,height=600")');
|
||||
browsebutton.insertAfter(oUrl);
|
||||
|
||||
|
||||
ImgHtml = '<body class="wym_dialog wym_dialog_image" onload="WYMeditor.INIT_DIALOG(' + index + ')">' + oImgHtml.html() + '</body>';
|
||||
|
||||
instance._options.dialogImageHtml = ImgHtml;
|
||||
}
|
||||
}
|
||||
|
||||
})(jQuery);
|
@@ -0,0 +1,5 @@
|
||||
function elfinder_yui_callback(url) {
|
||||
var editorId = window.opener.Drupal.wysiwyg.activeId;
|
||||
window.opener.jQuery('input#' + editorId + '_insertimage_url').val(url);
|
||||
window.close();
|
||||
}
|
21
sites/all/modules/contrib/files/elfinder/editors/yui/yui.inc
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
* YUI editor integration plugin
|
||||
*/
|
||||
|
||||
/**
|
||||
* Pseudo-hook for elfinder hook_wysiwyg_plugin implementation
|
||||
*/
|
||||
function elfinder_yui_elfinder_editor_plugin($options) {
|
||||
drupal_add_js($options['plugin_url_base'] . '/yui.js');
|
||||
drupal_add_js(array('elfinder' => array('file_browser_url' => $options['elfinder_url'])), 'setting');
|
||||
return array(
|
||||
'elfinder' => array(
|
||||
'extensions' => array('elfinder' => t('elFinder')),
|
||||
'url' => $options['homepage_url'],
|
||||
'options' => array(),
|
||||
'load' => FALSE,
|
||||
),
|
||||
);
|
||||
}
|
33
sites/all/modules/contrib/files/elfinder/editors/yui/yui.js
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
// $Id: elfinder.yui.js,v 1.1 2010/10/06 09:44:51 ph0enix Exp $
|
||||
|
||||
(function($) {
|
||||
|
||||
Drupal.elfinder.editor.yui = {
|
||||
fn : {
|
||||
attach: Drupal.wysiwyg.editor.attach.yui
|
||||
}
|
||||
}
|
||||
|
||||
Drupal.wysiwyg.editor.attach.yui = function(context, params, settings) {
|
||||
|
||||
$('#' + params.field).parent().addClass('yui-skin-' + settings.theme);
|
||||
// Attach editor.
|
||||
var editor = new YAHOO.widget.Editor(params.field, settings);
|
||||
|
||||
editor.on('windowInsertImageRender', function(e) {
|
||||
|
||||
var dialogcode = $('#' + params.field + '-panel');
|
||||
|
||||
var oUrl = $('input#' + params.field + '_insertimage_url');
|
||||
var browsebutton = $('<input type="button">');
|
||||
|
||||
browsebutton.attr('value', Drupal.t('Browse Server'));
|
||||
browsebutton.attr('onclick', 'var w = window; w.open("' + Drupal.settings.elfinder.file_browser_url + '","","toolbar=no,menubar=no,width=600,height=600")');
|
||||
browsebutton.insertAfter(oUrl);
|
||||
|
||||
}, editor, true);
|
||||
|
||||
editor.render();
|
||||
}
|
||||
|
||||
})(jQuery);
|
13
sites/all/modules/contrib/files/elfinder/elfinder.info
Normal file
@@ -0,0 +1,13 @@
|
||||
; $Id: elfinder.info 106 2011-02-26 08:19:56Z ph0enix $
|
||||
name = elFinder
|
||||
description = AJAX file manager with Wysiwyg API capable editors support.
|
||||
package = User interface
|
||||
configure = "admin/config/media/elfinder"
|
||||
core = 7.x
|
||||
project status url = https://drupal-elfinder.sourceforge.io/release-history.php
|
||||
|
||||
; Information added by Drupal.org packaging script on 2018-12-03
|
||||
version = "7.x-2.x-dev"
|
||||
core = "7.x"
|
||||
project = "elfinder"
|
||||
datestamp = "1543843700"
|
168
sites/all/modules/contrib/files/elfinder/elfinder.install
Normal file
@@ -0,0 +1,168 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Installation file for elfinder.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_requirements().
|
||||
*/
|
||||
function elfinder_requirements($phase) {
|
||||
require_once drupal_get_path('module', 'elfinder') . "/elfinder.module";
|
||||
|
||||
$requirements = array();
|
||||
|
||||
$ver_major = 0;
|
||||
$ver_minor = 0;
|
||||
$ver_release = 0;
|
||||
$min_major = 2;
|
||||
$min_minor = 0;
|
||||
|
||||
$min_ver = "$min_major.$min_minor";
|
||||
|
||||
$libpath = elfinder_lib_path();
|
||||
$ver = '';
|
||||
|
||||
|
||||
$install_t = t('Please download it from <a href="@url">@url</a> and install to @libpath.', array('@url' => 'http://elfinder.org', '@libpath' => $libpath));
|
||||
|
||||
if ($phase == 'runtime' || $phase == 'install' || $phase == 'update') {
|
||||
$description = t('elFinder library was not found.') . ' ' . $install_t;
|
||||
|
||||
$severity = '';
|
||||
$value = t('Not found');
|
||||
|
||||
if ( (is_readable($libpath . '/connectors/php/elFinder.class.php') || is_readable($libpath . '/php/elFinder.class.php') ) && is_readable($libpath . '/js/elfinder.min.js') ) {
|
||||
|
||||
$editor_file_content = file_get_contents($libpath . '/js/elfinder.min.js');
|
||||
|
||||
$value = t('Exists');
|
||||
|
||||
if (preg_match("/(?:this|elFinder\.prototype|\.prototype)\.version\s*=\s*[\"\']([^\"\']+)[\"\']/", $editor_file_content, $matches)) {
|
||||
$ver = $matches[1];
|
||||
$value = t('@ver', array('@ver' => $ver));
|
||||
}
|
||||
|
||||
$description = '';
|
||||
|
||||
if (preg_match("/^(\d+)\.(\d+|x)(\.(\d+))?/", $ver, $matches)) {
|
||||
$ver_major = (int)$matches[1];
|
||||
$ver_minor = $matches[2];
|
||||
$ver = "$ver_major.$ver_minor";
|
||||
if (count($matches) == 5) {
|
||||
$ver_release = (int)$matches[4];
|
||||
$ver = "$ver_major.$ver_minor.$ver_release";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if (($ver_major < $min_major) || ($ver_major == 2 && $ver_minor == '1' && $ver_release < 38)) {
|
||||
$description = t('Not supported elFinder library. Please upgrade to @minver.', array('@ver' => $ver, '@minver' => $min_ver)) . ' ' . $install_t;
|
||||
$severity = REQUIREMENT_ERROR;
|
||||
} else {
|
||||
$severity = REQUIREMENT_OK;
|
||||
}
|
||||
|
||||
$badpaths_check = elfinder_check_badpaths();
|
||||
|
||||
if ($badpaths_check['result'] == FALSE) {
|
||||
$severity = REQUIREMENT_ERROR;
|
||||
$description = $badpaths_check['message'];
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
$severity = REQUIREMENT_ERROR;
|
||||
}
|
||||
|
||||
$requirements['elfinder'] = array(
|
||||
'title' => 'elFinder',
|
||||
'description' => $description,
|
||||
'value' => $value,
|
||||
'severity' => $severity
|
||||
);
|
||||
}
|
||||
|
||||
return $requirements;
|
||||
}
|
||||
|
||||
function elfinder_uninstall() {
|
||||
db_delete('variable')
|
||||
->condition('name', 'elfinder_%', 'like')
|
||||
->execute();
|
||||
|
||||
cache_clear_all('variables', 'cache');
|
||||
}
|
||||
|
||||
function elfinder_schema() {
|
||||
$schema = array();
|
||||
|
||||
$schema['elfinder_file_extinfo'] = array(
|
||||
'description' => 'Stores additional filesystem attributes',
|
||||
'fields' => array(
|
||||
'extid' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE),
|
||||
'fid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => FALSE),
|
||||
'description' => array('type' => 'varchar', 'length' => 255, 'not null' => FALSE, 'default' => ''),
|
||||
),
|
||||
'primary key' => array('extid'),
|
||||
);
|
||||
|
||||
$schema['elfinder_profile'] = array(
|
||||
'description' => 'Stores configuration profiles',
|
||||
'fields' => array(
|
||||
'pid' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE),
|
||||
'name' => array('type' => 'varchar', 'length' => 255, 'not null' => FALSE, 'default' => ''),
|
||||
'description' => array('type' => 'varchar', 'length' => 255, 'not null' => FALSE, 'default' => ''),
|
||||
'settings' => array('type' => 'text', 'not null' => FALSE),
|
||||
),
|
||||
'primary key' => array('pid'),
|
||||
);
|
||||
|
||||
return $schema;
|
||||
|
||||
}
|
||||
|
||||
function elfinder_update_7101() {
|
||||
}
|
||||
|
||||
function elfinder_update_7102() {
|
||||
$ret = array();
|
||||
|
||||
if (db_table_exists('elfinder_profile') == FALSE) {
|
||||
drupal_install_schema('elfinder');
|
||||
}
|
||||
|
||||
if (!db_field_exists('elfinder_profile', 'settings')) {
|
||||
db_add_field($ret, 'elfinder_profile', 'settings', array('type' => 'text', 'not null' => FALSE));
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
function elfinder_update_7103() {
|
||||
drupal_flush_all_caches();
|
||||
}
|
||||
|
||||
/**
|
||||
* Reformat the setting profile_role in elfinder_profile table.
|
||||
*/
|
||||
function elfinder_update_7104() {
|
||||
$results = db_query("SELECT pid, name, description, settings from {elfinder_profile}");
|
||||
foreach($results as $row) {
|
||||
$settings = unserialize($row->settings);
|
||||
if (!is_array($settings['profile_role'])) {
|
||||
if (isset($settings['profile_role']) && $settings['profile_role'] > 0) {
|
||||
$settings['profile_role'] = array($settings['profile_role'] => $settings['profile_role']);
|
||||
}
|
||||
else {
|
||||
$settings['profile_role'] = array();
|
||||
}
|
||||
db_update('elfinder_profile')
|
||||
->fields(array('settings' => serialize($settings)))
|
||||
->condition('pid', $row->pid)
|
||||
->execute();
|
||||
}
|
||||
}
|
||||
}
|
1364
sites/all/modules/contrib/files/elfinder/elfinder.module
Normal file
401
sites/all/modules/contrib/files/elfinder/inc/elfinder.admin.inc
Normal file
@@ -0,0 +1,401 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* file manager admin settings page
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Settings form callback
|
||||
*/
|
||||
function elfinder_admin() {
|
||||
$obj = drupal_get_form('elfinder_d7_admin_form');
|
||||
return drupal_render($obj);
|
||||
}
|
||||
|
||||
/**
|
||||
* Settings form definition for D7
|
||||
*/
|
||||
function elfinder_d7_admin_form($form_id, &$form_state) {
|
||||
return elfinder_admin_form($form_state);
|
||||
}
|
||||
|
||||
|
||||
function elfinder_admin_profile_links($profile_name) {
|
||||
$links = l(t('Edit'), 'admin/config/media/elfinder/profile/' . $profile_name . '/edit') . ' ' . l(t('Delete'), 'admin/config/media/elfinder/profile/' . $profile_name . '/delete');
|
||||
return $links;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 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';
|
||||
|
||||
$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) {
|
||||
$rows[] = array($profile->pid, $profile->name, $profile->description, implode(', ', array_intersect_key($roles, $profile->settings['profile_role'])), elfinder_admin_profile_links($profile->name));
|
||||
}
|
||||
} else {
|
||||
$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(
|
||||
'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'),
|
||||
'#collapsible' => TRUE,
|
||||
'#collapsed' => FALSE,
|
||||
);
|
||||
|
||||
|
||||
$form['filesystem_settings']['filesystem_public_root_label'] = array(
|
||||
'#prefix' => '<div class="custom-container">',
|
||||
'#suffix' => '</div>',
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Public files root directory label'),
|
||||
'#default_value' => variable_get('elfinder_settings_filesystem_public_root_label', ''),
|
||||
'#description' => t('Root directory label in directory tree'),
|
||||
);
|
||||
|
||||
$form['filesystem_settings']['filesystem_private_root_label'] = array(
|
||||
'#prefix' => '<div class="custom-container">',
|
||||
'#suffix' => '</div>',
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Private files root directory label'),
|
||||
'#default_value' => variable_get('elfinder_settings_filesystem_private_root_label', ''),
|
||||
'#description' => t('Root directory label in directory tree'),
|
||||
);
|
||||
|
||||
$form['filesystem_settings']['filesystem_unmanaged_root_label'] = array(
|
||||
'#prefix' => '<div class="custom-container">',
|
||||
'#suffix' => '</div>',
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Unmanaged files root directory label'),
|
||||
'#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>',
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Custom unmanaged files path'),
|
||||
'#default_value' => variable_get('elfinder_settings_filesystem_root_custom', ''),
|
||||
'#description' => t('Custom filesystem root path.') . '<br/>' . t('Available tokens: <code>%files</code> (base path, eg: <code>/</code>), <code>%name</code> (current username, eg: <code>@u</code>, <b>NOTE:</b> it is not unique - users can have same username, so better to combine it with user id value), <code>%uid</code> (current user id, eg: <code>@uid</code>), <code>%lang</code> (current language code, eg: <code>@lang</code>), plus all tokens provided by token module', array('@u' => $user->name, '@uid' => $user->uid, '@lang' => $langCode)),
|
||||
);
|
||||
|
||||
$form['filesystem_settings']['filesystem_url_custom'] = array(
|
||||
'#prefix' => '<div class="custom-container">',
|
||||
'#suffix' => '</div>',
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Custom unmanaged files URL'),
|
||||
'#default_value' => variable_get('elfinder_settings_filesystem_url_custom', ''),
|
||||
'#description' => t('Custom filesystem url.') . '<br/>' . t('Available tokens: <code>%files</code> (base path, eg: <code>/</code>), <code>%name</code> (current username, eg: <code>@u</code>, <b>NOTE:</b> it is not unique - users can have same username, so better to combine it with user id value), <code>%uid</code> (current user id, eg: <code>@uid</code>), <code>%lang</code> (current language code, eg: <code>@lang</code>), plus all tokens provided by token module', array('@u' => $user->name, '@uid' => $user->uid, '@lang' => $langCode)),
|
||||
);
|
||||
|
||||
$form['filesystem_settings']['mime_detect'] = array(
|
||||
'#type' => 'radios',
|
||||
'#title' => t('File type detection'),
|
||||
'#default_value' => variable_get('elfinder_settings_filesystem_mimedetect', 'auto'),
|
||||
'#options' => array(
|
||||
'auto' => t('Automatical detection'),
|
||||
),
|
||||
);
|
||||
|
||||
$form['filesystem_settings']['filesystem_allowed_extensions'] = array(
|
||||
'#prefix' => '<div class="custom-container">',
|
||||
'#suffix' => '</div>',
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Allowed file extensions'),
|
||||
'#maxlength' => 1000,
|
||||
'#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');
|
||||
}
|
||||
|
||||
if (function_exists('mime_content_type')) {
|
||||
$form['filesystem_settings']['mime_detect']['#options']['php'] = t('php mime_content_type()');
|
||||
}
|
||||
|
||||
$form['filesystem_settings']['mime_detect']['#options']['linux'] = t('file -ib (linux)');
|
||||
$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']['file_url_type'] = array(
|
||||
'#type' => 'radios',
|
||||
'#title' => t('Selected file url type'),
|
||||
'#default_value' => variable_get('elfinder_settings_filesystem_fileurl', 'true'),
|
||||
'#options' => array(
|
||||
'true' => t('Absolute'),
|
||||
'false' => t('Relative'),
|
||||
),
|
||||
);
|
||||
|
||||
$form['filesystem_settings']['file_perm'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Created file permissions'),
|
||||
'#default_value' => variable_get('elfinder_settings_filesystem_fileperm', '0666'),
|
||||
'#size' => 4,
|
||||
);
|
||||
|
||||
$form['filesystem_settings']['dir_perm'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Created directory permissions'),
|
||||
'#default_value' => variable_get('elfinder_settings_filesystem_dirperm', '0777'),
|
||||
'#size' => 4,
|
||||
);
|
||||
|
||||
|
||||
$form['filesystem_settings']['max_filesize'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Maximum upload size'),
|
||||
'#default_value' => variable_get('elfinder_settings_filesystem_maxfilesize', ''),
|
||||
'#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']['max_filecount'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Maximum folder size'),
|
||||
'#default_value' => variable_get('elfinder_settings_filesystem_maxfilecount', ''),
|
||||
'#description' => t('The maximum number of files allowed in a directory. 0 for unlimited.'),
|
||||
'#size' => 10,
|
||||
'#weight' => 5,
|
||||
);
|
||||
|
||||
$form['filesystem_settings']['handleprivate'] = array(
|
||||
'#type' => 'radios',
|
||||
'#title' => t('Handle private downloads'),
|
||||
'#default_value' => variable_get('elfinder_settings_filesystem_handleprivate', 'true'),
|
||||
'#options' => array(
|
||||
'true' => t('Yes'),
|
||||
'false' => t('No'),
|
||||
),
|
||||
'#description' => t('Use elFinder to handle private file downloads'),
|
||||
);
|
||||
|
||||
$form['thumbnail_settings'] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#title' => t('Image settings'),
|
||||
'#collapsible' => TRUE,
|
||||
'#collapsed' => FALSE,
|
||||
);
|
||||
|
||||
$form['thumbnail_settings']['tmbsize'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Thumbnail size'),
|
||||
'#default_value' => variable_get('elfinder_settings_thumbnail_size', '48'),
|
||||
'#size' => 4,
|
||||
);
|
||||
|
||||
$form['thumbnail_settings']['tmbdirname'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Thumbnail directory name'),
|
||||
'#default_value' => variable_get('elfinder_settings_thumbnail_dirname', 'tmb'),
|
||||
'#size' => 10,
|
||||
);
|
||||
|
||||
$form['thumbnail_settings']['imglib'] = array(
|
||||
'#type' => 'radios',
|
||||
'#title' => t('Image manipulation library'),
|
||||
'#default_value' => variable_get('elfinder_settings_thumbnail_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' => variable_get('elfinder_settings_thumbnail_tmbcrop', 'true'),
|
||||
'#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 settings'),
|
||||
'#collapsible' => TRUE,
|
||||
'#collapsed' => FALSE,
|
||||
);
|
||||
|
||||
$form['misc_settings']['rememberlastdir'] = array(
|
||||
'#type' => 'radios',
|
||||
'#title' => t('Remember last opened directory'),
|
||||
'#default_value' => variable_get('elfinder_settings_misc_rememberlastdir', 'true'),
|
||||
'#options' => array(
|
||||
'true' => t('Yes'),
|
||||
'false' => t('No'),
|
||||
),
|
||||
'#description' => t('Creates a cookie. Disable if you have issues with caching.'),
|
||||
);
|
||||
|
||||
$form['misc_settings']['usesystemjquery'] = array(
|
||||
'#type' => 'radios',
|
||||
'#title' => t('Use system jQuery'),
|
||||
'#default_value' => variable_get('elfinder_settings_misc_usesystemjquery', 'true'),
|
||||
'#options' => array(
|
||||
'true' => t('Yes'),
|
||||
'false' => t('No'),
|
||||
),
|
||||
'#description' => t('Use system jQuery and jQuery UI when possible. If set to \'No\' jQuery hosted at Google will be uses.'),
|
||||
);
|
||||
|
||||
$form['misc_settings']['manager_width'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('File manager width'),
|
||||
'#default_value' => variable_get('elfinder_settings_misc_manager_width', ''),
|
||||
'#size' => 4,
|
||||
);
|
||||
|
||||
$form['misc_settings']['manager_height'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('File manager height'),
|
||||
'#default_value' => variable_get('elfinder_settings_misc_manager_height', ''),
|
||||
'#size' => 4,
|
||||
);
|
||||
|
||||
$form['misc_settings']['hidden_folders'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Hidden folders'),
|
||||
'#maxlength' => 1000,
|
||||
'#default_value' => variable_get('elfinder_settings_misc_hidden_folders', ''),
|
||||
'#description' => t('Folders listed here will be hidden. Separate with a comma. Example: "color, css_injector, ctools, styles".'),
|
||||
);
|
||||
|
||||
$form['submit'] = array('#type' => 'submit', '#value' => t('Save configuration'));
|
||||
$form['#submit'][] = 'elfinder_admin_submit';
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save form data
|
||||
*/
|
||||
function elfinder_admin_submit($form, &$form_state) {
|
||||
variable_set('elfinder_settings_thumbnail_size', $form_state['values']['tmbsize']);
|
||||
variable_set('elfinder_settings_thumbnail_dirname', $form_state['values']['tmbdirname']);
|
||||
|
||||
if ($form_state['values']['filesystem_root_custom'] != '') {
|
||||
variable_set('elfinder_settings_filesystem_root_custom', $form_state['values']['filesystem_root_custom']);
|
||||
}
|
||||
|
||||
variable_set('elfinder_settings_filesystem_url_custom', $form_state['values']['filesystem_url_custom']);
|
||||
|
||||
|
||||
variable_set('elfinder_settings_filesystem_mimedetect', $form_state['values']['mime_detect']);
|
||||
variable_set('elfinder_settings_filesystem_fileurl', $form_state['values']['file_url_type']);
|
||||
variable_set('elfinder_settings_thumbnail_imglib', $form_state['values']['imglib']);
|
||||
variable_set('elfinder_settings_filesystem_fileperm', $form_state['values']['file_perm']);
|
||||
variable_set('elfinder_settings_filesystem_dirperm', $form_state['values']['dir_perm']);
|
||||
variable_set('elfinder_settings_misc_rememberlastdir', $form_state['values']['rememberlastdir']);
|
||||
variable_set('elfinder_settings_misc_usesystemjquery', $form_state['values']['usesystemjquery']);
|
||||
variable_set('elfinder_settings_thumbnail_tmbcrop', $form_state['values']['tmbcrop']);
|
||||
variable_set('elfinder_settings_filesystem_maxfilesize', $form_state['values']['max_filesize']);
|
||||
variable_set('elfinder_settings_filesystem_maxfilecount', $form_state['values']['max_filecount']);
|
||||
variable_set('elfinder_settings_filesystem_handleprivate', $form_state['values']['handleprivate']);
|
||||
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_hidden_folders', $form_state['values']['hidden_folders']);
|
||||
variable_set('elfinder_settings_filesystem_allowed_extensions', $form_state['values']['filesystem_allowed_extensions']);
|
||||
|
||||
drupal_set_message(t('Changes have been saved.'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate form data
|
||||
*/
|
||||
function elfinder_admin_form_validate($form, &$form_state) {
|
||||
$tmbsize = $form_state['values']['tmbsize'];
|
||||
$mwidth = $form_state['values']['manager_width'];
|
||||
$mheight = $form_state['values']['manager_height'];
|
||||
|
||||
if ($form_state['values']['filesystem_root'] == 'custom') {
|
||||
$customroot = $form_state['values']['filesystem_root_custom'];
|
||||
|
||||
if ($customroot == '') {
|
||||
form_set_error('filesystem_root_custom', t('Filesystem root cannot be empty'));
|
||||
}
|
||||
|
||||
$customroot = elfinder_parse_path_tokens($customroot);
|
||||
|
||||
// checking directory accessibility by creating test file
|
||||
if (!elfinder_prepare_directory($customroot)) {
|
||||
form_set_error('filesystem_root_custom', t('Filesystem root is not writable'));
|
||||
}
|
||||
}
|
||||
|
||||
if (!preg_match('/^\d{3,4}$/', $form_state['values']['file_perm'])) {
|
||||
form_set_error('file_perm', t('Created file permissions should be a numeric'));
|
||||
}
|
||||
|
||||
if (!preg_match('/^\d{3,4}?$/', $form_state['values']['dir_perm'])) {
|
||||
form_set_error('dir_perm', t('Created directory permissions should be a numeric'));
|
||||
}
|
||||
|
||||
if (!empty($form_state['values']['max_filesize']) && !is_numeric(parse_size($form_state['values']['max_filesize']))) {
|
||||
form_set_error('max_filesize', t('The file size option must contain a valid value. You may either leave the text field empty or enter a string like "512" (bytes), "80 KB" (kilobytes) or "50 MB" (megabytes).'));
|
||||
}
|
||||
|
||||
if ($mwidth && !is_numeric($mwidth)) {
|
||||
form_set_error('manager_width', t('Manager width size should be a number'));
|
||||
}
|
||||
|
||||
if ($mheight && !is_numeric($mheight)) {
|
||||
form_set_error('manager_height', t('Manager height size should be a number'));
|
||||
}
|
||||
|
||||
if ($tmbsize && !is_numeric($tmbsize)) {
|
||||
form_set_error('tmbsize', t('Thumbnail size should be a number'));
|
||||
}
|
||||
}
|
@@ -0,0 +1,563 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* file manager admin profile settings page
|
||||
*/
|
||||
function elfinder_admin_profile($form, &$form_state) {
|
||||
|
||||
global $user, $language;
|
||||
|
||||
$action = $form_state['build_info']['args'][0];
|
||||
$profile_name = $form_state['build_info']['args'][1];
|
||||
|
||||
drupal_add_css(drupal_get_path('module', 'elfinder') . '/css/elfinder.admin.css');
|
||||
|
||||
$profiles = elfinder_admin_profile_get();
|
||||
|
||||
$p = NULL;
|
||||
|
||||
if (!is_array($profiles)) {
|
||||
$profiles = array($profiles);
|
||||
}
|
||||
|
||||
foreach ($profiles as $prof) {
|
||||
if (is_object($prof) && $prof->name == $profile_name && $p == NULL) {
|
||||
$p = $prof;
|
||||
}
|
||||
}
|
||||
|
||||
$profile = isset($p->settings) ? $p->settings : NULL;
|
||||
|
||||
if ($action == 'profile_add') {
|
||||
$form['profile_name'] = array(
|
||||
'#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',
|
||||
);
|
||||
|
||||
$form['profile_name'] = array(
|
||||
'#default_value' => $profile_name,
|
||||
'#type' => 'hidden',
|
||||
);
|
||||
}
|
||||
|
||||
$form['profile_description'] = array(
|
||||
'#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'),
|
||||
);
|
||||
|
||||
$form['profile_action'] = array(
|
||||
'#default_value' => $action,
|
||||
'#type' => 'hidden',
|
||||
);
|
||||
|
||||
$form['filesystem_settings'] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#title' => t('File system'),
|
||||
'#collapsible' => TRUE,
|
||||
'#collapsed' => TRUE,
|
||||
);
|
||||
|
||||
$form['volumes'] = array(
|
||||
'#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>',
|
||||
);
|
||||
|
||||
$form['volumes']['volumes_wrapper']['volume'] = array(
|
||||
'#prefix' => '<div id="profile-volumes">',
|
||||
'#suffix' => '</div>',
|
||||
'#type' => 'markup',
|
||||
'#value' => ' ',
|
||||
);
|
||||
|
||||
|
||||
$dirs = $profile['volume'];
|
||||
|
||||
if (isset($form_state['values']['volume'])) {
|
||||
$choices = $form_state['values']['volume'];
|
||||
$lasti = 0;
|
||||
|
||||
for ($i = 0; $i < count($choices); $i++) {
|
||||
$form['volumes']['volumes_wrapper']['volume'][$i] = elfinder_admin_dir_form($i, $choices[$i], 0);
|
||||
$lasti = $i;
|
||||
}
|
||||
|
||||
if (isset($form_state['clicked_button']['#name']) && $form_state['clicked_button']['#name'] == 'addfield') {
|
||||
$form['volumes']['volumes_wrapper']['volume'][] = elfinder_admin_dir_form(count($choices), '', 0);
|
||||
}
|
||||
} else {
|
||||
|
||||
for ($i = 0; $i < count($dirs); $i++) {
|
||||
$form['volumes']['volumes_wrapper']['volume'][$i] = elfinder_admin_dir_form($i, $dirs[$i], 0);
|
||||
}
|
||||
|
||||
if (isset($form_state['clicked_button']['#name']) && $form_state['clicked_button']['#name'] == 'addfield') {
|
||||
$form['volumes']['volumes_wrapper']['volume'][] = elfinder_admin_dir_form(count($dirs), '', 0);
|
||||
}
|
||||
}
|
||||
|
||||
$ckeditor_volumes = array('' => t('Select One'));
|
||||
|
||||
$i = 0;
|
||||
|
||||
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++;
|
||||
}
|
||||
}
|
||||
|
||||
$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',
|
||||
),
|
||||
);
|
||||
|
||||
|
||||
$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'),
|
||||
),
|
||||
);
|
||||
|
||||
if (function_exists('finfo_open')) {
|
||||
$form['filesystem_settings']['mime_detect']['#options']['finfo'] = t('php finfo');
|
||||
}
|
||||
|
||||
if (function_exists('mime_content_type')) {
|
||||
$form['filesystem_settings']['mime_detect']['#options']['php'] = t('php mime_content_type()');
|
||||
}
|
||||
|
||||
$form['filesystem_settings']['mime_detect']['#options']['linux'] = t('file -ib (linux)');
|
||||
$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']['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'),
|
||||
),
|
||||
);
|
||||
|
||||
$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,
|
||||
);
|
||||
|
||||
$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,
|
||||
);
|
||||
|
||||
|
||||
$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,
|
||||
);
|
||||
|
||||
$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,
|
||||
);
|
||||
|
||||
$form['thumbnail_settings'] = array(
|
||||
'#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,
|
||||
);
|
||||
|
||||
$form['thumbnail_settings']['tmbdirname'] = array(
|
||||
'#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'),
|
||||
),
|
||||
);
|
||||
|
||||
$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.'),
|
||||
);
|
||||
|
||||
$form['misc_settings'] = array(
|
||||
'#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.'),
|
||||
);
|
||||
|
||||
|
||||
$form['misc_settings']['manager_width'] = array(
|
||||
'#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,
|
||||
);
|
||||
|
||||
$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.'),
|
||||
);
|
||||
|
||||
$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(''))),
|
||||
);
|
||||
|
||||
$form['submit'] = array(
|
||||
'#type' => 'submit',
|
||||
'#name' => 'save_profile',
|
||||
'#value' => t('Save configuration')
|
||||
);
|
||||
|
||||
$form['#submit'][] = 'elfinder_admin_submit';
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
function elfinder_admin_profile_callback($form, $form_state) {
|
||||
$form_state['rebuild'] = TRUE;
|
||||
return $form['volumes']['volumes_wrapper']['volume'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Settings form callback
|
||||
*/
|
||||
function elfinder_admin_profiles($action = '', $profile_name = '') {
|
||||
$obj = NULL;
|
||||
|
||||
if ($action == 'profile_delete') {
|
||||
$obj = drupal_get_form('elfinder_admin_profiles_delete_form', $action, $profile_name);
|
||||
} else {
|
||||
$obj = drupal_get_form('elfinder_admin_profile', $action, $profile_name);
|
||||
}
|
||||
|
||||
return drupal_render($obj);
|
||||
}
|
||||
|
||||
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,
|
||||
);
|
||||
|
||||
|
||||
$form['#submit'][] = 'elfinder_admin_profile_delete_submit';
|
||||
return confirm_form($form, t('Are you sure you want to delete the profile %profile?', array('%profile' => $profile_name)), 'admin/config/media/elfinder', '', t('Delete'), t('Cancel')
|
||||
);
|
||||
return $form;
|
||||
}
|
||||
|
||||
function elfinder_admin_profile_delete_submit($form, &$form_state) {
|
||||
if ($form_state['values']['confirm'] == 1) {
|
||||
drupal_set_message(t('Profile deleted'));
|
||||
$pid = elfinder_admin_profile_get_pid($form_state['values']['profile_name']);
|
||||
if ($pid > 0) {
|
||||
db_delete('elfinder_profile')
|
||||
->condition('pid', $pid)
|
||||
->execute();
|
||||
}
|
||||
}
|
||||
drupal_goto('admin/config/media/elfinder');
|
||||
}
|
||||
|
||||
function elfinder_admin_dir_form($delta, $values = array(), $votes = 0) {
|
||||
$form = array();
|
||||
|
||||
$pvtfiles = file_stream_wrapper_get_instance_by_uri('private://');
|
||||
$pubfiles = file_stream_wrapper_get_instance_by_uri('public://');
|
||||
|
||||
if (is_object($pvtfiles)) {
|
||||
$defaulturl = $pvtfiles->getExternalUrl();
|
||||
} elseif (is_object($pubfiles)) {
|
||||
$defaulturl = $pubfiles->getExternalUrl();
|
||||
}
|
||||
|
||||
|
||||
$form['volume_settings'] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#title' => t('Volume @n (@p)', array('@n' => ($delta + 1), '@p' => $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,
|
||||
);
|
||||
|
||||
$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'),
|
||||
);
|
||||
|
||||
$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,
|
||||
);
|
||||
|
||||
$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',
|
||||
),
|
||||
);
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
function elfinder_admin_profile_change_volume($form, &$form_state) {
|
||||
|
||||
$clickedbutton = $form_state['clicked_button']['#name'];
|
||||
|
||||
if (preg_match("/^rmfield-(\d+)/", $clickedbutton, $m)) {
|
||||
$itemid = $m[1];
|
||||
unset($form_state['values']['volume'][$itemid]);
|
||||
$form_state['values']['volume'] = array_values($form_state['values']['volume']);
|
||||
unset($form_state['input']['volume'][$itemid]);
|
||||
$form_state['input']['volume'] = array_values($form_state['input']['volume']);
|
||||
} elseif ($clickedbutton = 'addfield') {
|
||||
$form_state['input']['volume'][] = '';
|
||||
}
|
||||
|
||||
$form_state['rebuild'] = TRUE;
|
||||
}
|
||||
|
||||
function elfinder_admin_profile_get_pid($name) {
|
||||
$pid = db_select('elfinder_profile', 'p')->condition('name', $name)->fields('p', array('pid'))->execute()->fetchField();
|
||||
return $pid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save form data
|
||||
*/
|
||||
function elfinder_admin_submit($form, &$form_state) {
|
||||
|
||||
$settings = array('tmbsize', 'tmbdirname', 'mime_detect', 'file_url_type', 'imglib', 'file_perm', 'dir_perm', 'rememberlastdir', 'usesystemjquery', 'tmbcrop', 'max_filesize', 'manager_width', 'manager_height', 'volume', 'user_quota', 'ckeditor_upload_volume', 'ckeditor_upload_directory');
|
||||
|
||||
$profile_settings = array();
|
||||
|
||||
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]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$profile_settings[$setting] = $form_state['values'][$setting];
|
||||
}
|
||||
}
|
||||
|
||||
// Save roles.
|
||||
$profile_settings['profile_role'] = array();
|
||||
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'];
|
||||
|
||||
$pid = 0;
|
||||
|
||||
if ($form_state['values']['profile_action'] == 'profile_edit' && $profile_name) {
|
||||
$pid = elfinder_admin_profile_get_pid($profile_name);
|
||||
}
|
||||
|
||||
$profile = new StdClass;
|
||||
$profile->pid = $pid;
|
||||
$profile->name = $profile_name;
|
||||
$profile->description = $profile_description;
|
||||
$profile->settings = serialize($profile_settings);
|
||||
|
||||
if (isset($form_state['values']['save_profile'])) {
|
||||
drupal_write_record('elfinder_profile', $profile, $pid > 0 ? array('pid') : array());
|
||||
drupal_set_message(t('Profile have been saved.'));
|
||||
drupal_goto('admin/config/media/elfinder');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate form data
|
||||
*/
|
||||
function elfinder_admin_form_validate($form, &$form_state) {
|
||||
$tmbsize = $form_state['values']['tmbsize'];
|
||||
$mwidth = $form_state['values']['manager_width'];
|
||||
$mheight = $form_state['values']['manager_height'];
|
||||
|
||||
if ($form_state['values']['filesystem_root'] == 'custom') {
|
||||
$customroot = $form_state['values']['filesystem_root_custom'];
|
||||
|
||||
if ($customroot == '') {
|
||||
form_set_error('filesystem_root_custom', t('Filesystem root cannot be empty'));
|
||||
}
|
||||
|
||||
$customroot = elfinder_parse_path_tokens($customroot);
|
||||
|
||||
// checking directory accessibility by creating test file
|
||||
if (!elfinder_prepare_directory($customroot)) {
|
||||
form_set_error('filesystem_root_custom', t('Filesystem root is not writable'));
|
||||
}
|
||||
}
|
||||
|
||||
if (!preg_match('/^\d{3,4}$/', $form_state['values']['file_perm'])) {
|
||||
form_set_error('file_perm', t('Created file permissions should be a numeric'));
|
||||
}
|
||||
|
||||
if (!preg_match('/^\d{3,4}?$/', $form_state['values']['dir_perm'])) {
|
||||
form_set_error('dir_perm', t('Created directory permissions should be a numeric'));
|
||||
}
|
||||
|
||||
if (!empty($form_state['values']['max_filesize']) && !is_numeric(parse_size($form_state['values']['max_filesize']))) {
|
||||
form_set_error('max_filesize', t('The file size option must contain a valid value. You may either leave the text field empty or enter a string like "512" (bytes), "80 KB" (kilobytes) or "50 MB" (megabytes).'));
|
||||
}
|
||||
|
||||
if (!empty($form_state['values']['user_quota']) && !is_numeric(parse_size($form_state['values']['user_quota']))) {
|
||||
form_set_error('user_quota', t('The file size option must contain a valid value. You may either leave the text field empty or enter a string like "512" (bytes), "80 KB" (kilobytes) or "50 MB" (megabytes).'));
|
||||
}
|
||||
|
||||
if ($mwidth && !is_numeric($mwidth)) {
|
||||
form_set_error('manager_width', t('Manager width size should be a number'));
|
||||
}
|
||||
|
||||
if ($mheight && !is_numeric($mheight)) {
|
||||
form_set_error('manager_height', t('Manager height size should be a number'));
|
||||
}
|
||||
|
||||
if ($tmbsize && !is_numeric($tmbsize)) {
|
||||
form_set_error('tmbsize', t('Thumbnail size should be a number'));
|
||||
}
|
||||
}
|
265
sites/all/modules/contrib/files/elfinder/inc/elfinder.drupal.inc
Normal file
@@ -0,0 +1,265 @@
|
||||
<?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;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,108 @@
|
||||
<?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;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,652 @@
|
||||
<?php
|
||||
/**
|
||||
* elFinder Integration
|
||||
*
|
||||
* Copyright (c) 2010-2018, Alexey Sukhotin. All rights reserved.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* elFinder driver for Drupal filesystem.
|
||||
*
|
||||
* @author Alexey Sukhotin
|
||||
* */
|
||||
class elFinderVolumeDrupal extends elFinderVolumeLocalFileSystem {
|
||||
|
||||
protected $DrupalFilesACL = NULL;
|
||||
|
||||
/**
|
||||
* Create Drupal file object
|
||||
*
|
||||
* @param string $path file path
|
||||
* @return object
|
||||
* @author Alexey Sukhotin
|
||||
* */
|
||||
protected function _drupalfileobject($path) {
|
||||
$uri = $this->drupalpathtouri($path);
|
||||
return elfinder_get_drupal_file_obj($uri);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert path to Drupal file URI
|
||||
*
|
||||
* @param string $path file path
|
||||
* @return string
|
||||
* @author Alexey Sukhotin
|
||||
* */
|
||||
public function drupalpathtouri($path) {
|
||||
|
||||
$pvtpath = drupal_realpath('private://');
|
||||
$pubpath = drupal_realpath('public://');
|
||||
$tmppath = drupal_realpath('temporary://');
|
||||
|
||||
$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);
|
||||
} else {
|
||||
$uri = 'public://' . substr($path, strlen($pubpath) + 1);
|
||||
}
|
||||
|
||||
return @file_stream_wrapper_uri_normalize($uri);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if file extension is allowed
|
||||
*
|
||||
* @param stdClass $file file object
|
||||
* @return array
|
||||
* @author Alexey Sukhotin
|
||||
**/
|
||||
protected function CheckExtension(stdClass $file) {
|
||||
|
||||
$allowed_extensions = variable_get('elfinder_settings_filesystem_allowed_extensions', '');
|
||||
|
||||
if (!empty($allowed_extensions)) {
|
||||
|
||||
$errors = file_validate_extensions($file, $allowed_extensions);
|
||||
|
||||
if (!empty($errors)) {
|
||||
$this->setError(strip_tags(implode(' ', $errors)));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create dir
|
||||
*
|
||||
* @param string $path parent dir path
|
||||
* @param string $name new directory name
|
||||
* @return bool
|
||||
* @author Alexey Sukhotin
|
||||
* */
|
||||
protected function _mkdir($path, $name) {
|
||||
$path = $path . DIRECTORY_SEPARATOR . $name;
|
||||
|
||||
if (@drupal_mkdir($path)) {
|
||||
return $path;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create file
|
||||
*
|
||||
* @param string $path parent dir path
|
||||
* @param string $name new file name
|
||||
* @return bool
|
||||
* @author Alexey Sukhotin
|
||||
* */
|
||||
protected function _mkfile($path, $name) {
|
||||
$path = $path . DIRECTORY_SEPARATOR . $name;
|
||||
$uri = $this->drupalpathtouri($path);
|
||||
|
||||
if (!$this->CheckExtension($this->_drupalfileobject($path))) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
$file = file_save_data("", $uri);
|
||||
|
||||
$this->FileUsageAdd($file);
|
||||
|
||||
if (isset($file->fid)) {
|
||||
return $path;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy file into another file
|
||||
*
|
||||
* @param string $source source file path
|
||||
* @param string $targetDir target directory path
|
||||
* @param string $name new file name
|
||||
* @return bool
|
||||
* @author Alexey Sukhotin
|
||||
* */
|
||||
protected function _copy($source, $targetDir, $name) {
|
||||
|
||||
$target = $targetDir . DIRECTORY_SEPARATOR . (!empty($name) ? $name : basename($source));
|
||||
|
||||
if (!is_dir($target) && !$this->CheckExtension($this->_drupalfileobject($target))) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!$this->CheckUserQuota()) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (file_copy($this->_drupalfileobject($source), $this->drupalpathtouri($target))) {
|
||||
$this->FileUsageAdd($this->_drupalfileobject($target));
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Move file into another parent dir
|
||||
* Return new file path or false
|
||||
*
|
||||
* @param string $source source file path
|
||||
* @param string $target target dir path
|
||||
* @param string $name new name
|
||||
* @return bool|string
|
||||
* @author Alexey Sukhotin
|
||||
* */
|
||||
protected function _move($source, $targetDir, $name) {
|
||||
|
||||
$target = $targetDir . DIRECTORY_SEPARATOR . (!empty($name) ? $name : basename($source));
|
||||
|
||||
if (!is_dir($target) && !$this->CheckExtension($this->_drupalfileobject($target))) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (is_dir($source)) {
|
||||
$srcuri = $this->drupalpathtouri($source);
|
||||
$dsturi = $this->drupalpathtouri($target);
|
||||
|
||||
$children = db_select('file_managed', 'f')
|
||||
->condition('uri', $srcuri . '/%', 'LIKE')
|
||||
->fields('f', array('fid', 'uri'))
|
||||
->execute()
|
||||
->fetchAll();
|
||||
|
||||
foreach ($children as $child) {
|
||||
$newuri = str_replace("$srcuri/", "$dsturi/", $child->uri);
|
||||
db_update('file_managed')->fields(array('uri' => $newuri))->condition('fid', $child->fid)->execute();
|
||||
}
|
||||
|
||||
return @rename($source, $target);
|
||||
} elseif (@file_move($this->_drupalfileobject($source), $this->drupalpathtouri($target))) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove file
|
||||
*
|
||||
* @param string $path file path
|
||||
* @return bool
|
||||
* @author Alexey Sukhotin
|
||||
* */
|
||||
protected function _unlink($path) {
|
||||
|
||||
$file = $this->_drupalfileobject($path);
|
||||
$this->FileUsageDelete($file);
|
||||
|
||||
$result = @file_delete($file);
|
||||
|
||||
if ($result === TRUE) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (is_array($result)) {
|
||||
return $result['file'];
|
||||
} else {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove dir
|
||||
*
|
||||
* @param string $path dir path
|
||||
* @return bool
|
||||
* @author Alexey Sukhotin
|
||||
* */
|
||||
protected function _rmdir($path) {
|
||||
return @drupal_rmdir($path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete dirctory trees and included files.
|
||||
*
|
||||
* Clone of elfinderVolumeDriver::delTree().
|
||||
*
|
||||
* Using elFinderVolumeLocalFileSystem::delTree to delete a folder with files
|
||||
* in it would not update file_usage and file_managed tables. Using
|
||||
* elfinderVolumeDriver::delTree makes it work better.
|
||||
*/
|
||||
protected function delTree($localpath) {
|
||||
foreach ($this->_scandir($localpath) as $p) {
|
||||
elFinder::extendTimeLimit();
|
||||
$stat = $this->stat($this->convEncOut($p));
|
||||
$this->convEncIn();
|
||||
($stat['mime'] === 'directory') ? $this->delTree($p) : $this->_unlink($p);
|
||||
}
|
||||
$res = $this->_rmdir($localpath);
|
||||
$res && $this->clearstatcache();
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create new file and write into it from file pointer.
|
||||
* Return new file path or false on error.
|
||||
*
|
||||
* @param resource $fp file pointer
|
||||
* @param string $dir target dir path
|
||||
* @param string $name file name
|
||||
* @return bool|string
|
||||
* @author Dmitry (dio) Levashov, Alexey Sukhotin
|
||||
* */
|
||||
protected function _save($fp, $dir, $name, $stat) {
|
||||
$tmpname = $name;
|
||||
|
||||
$bu_ret = module_invoke_all('elfinder_beforeupload', array('name' => $name, 'dir' => $dir, 'stat' => $stat));
|
||||
|
||||
if (isset($bu_ret)) {
|
||||
if (!is_array($bu_ret)) {
|
||||
$bu_ret = array($bu_ret);
|
||||
}
|
||||
|
||||
$tmpname = end($bu_ret);
|
||||
}
|
||||
|
||||
$path = $dir . DIRECTORY_SEPARATOR . (!empty($tmpname) ? $tmpname : $name);
|
||||
|
||||
if (!$this->CheckUserQuota()) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!$this->CheckFolderCount($dir)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!$this->CheckExtension($this->_drupalfileobject($path))) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!$this->FileValidate($name)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!($target = @fopen($path, 'wb'))) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
while (!feof($fp)) {
|
||||
fwrite($target, fread($fp, 8192));
|
||||
}
|
||||
|
||||
|
||||
fclose($target);
|
||||
@chmod($path, $this->options['fileMode']);
|
||||
|
||||
$file = $this->_drupalfileobject($path);
|
||||
|
||||
@file_save($file);
|
||||
$this->FileUsageAdd($file);
|
||||
|
||||
return $path;
|
||||
}
|
||||
|
||||
protected function CheckUserQuota() {
|
||||
$space = $this->CalculateUserAllowedSpace();
|
||||
|
||||
if ($space == 0) {
|
||||
$this->setError(t('Quota exceeded'));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
protected function CheckFolderCount($dir) {
|
||||
$max_allowed = variable_get('elfinder_settings_filesystem_maxfilecount', 0);
|
||||
if ($max_allowed > 0) {
|
||||
$options = array(
|
||||
'recurse' => FALSE,
|
||||
);
|
||||
// Match name.extension. This won't count files with no extension.
|
||||
$files = file_scan_directory($dir, '/.*\..*/', $options);
|
||||
|
||||
if (count($files) >= $max_allowed) {
|
||||
$this->setError(t('Max directory file count of %count reached', array('%count' => $max_allowed)));
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Let other Drupal modules perform validation on the uploaded file.
|
||||
* See hook_file_validate().
|
||||
*
|
||||
* @param string $name file name
|
||||
* @return bool
|
||||
*/
|
||||
protected function FileValidate($name) {
|
||||
// The uploaded file is still in temp. Fetch it's name & path from $_FILES.
|
||||
$index = array_search($name, $_FILES['upload']['name']);
|
||||
if ($index !== FALSE) {
|
||||
$file = $this->_drupalfileobject($_FILES['upload']['tmp_name'][$index]);
|
||||
$validation_errors = module_invoke_all('file_validate', $file);
|
||||
if (!empty($validation_errors)) {
|
||||
$this->setError(strip_tags(implode(' ', $validation_errors)));
|
||||
return FALSE;
|
||||
}
|
||||
} else {
|
||||
watchdog('elfinder', 'File upload "' . $name . '" not found in $_FILES');
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return files list in directory.
|
||||
*
|
||||
* @param string $path dir path
|
||||
* @return array
|
||||
* @author Dmitry (dio) Levashov
|
||||
* */
|
||||
protected function _scandir($path) {
|
||||
$files = array();
|
||||
|
||||
foreach (scandir($path) as $name) {
|
||||
if ($name != '.' && $name != '..') {
|
||||
$files[] = $path . DIRECTORY_SEPARATOR . $name;
|
||||
}
|
||||
}
|
||||
return $files;
|
||||
}
|
||||
|
||||
public function owner($target) {
|
||||
$path = $this->decode($target);
|
||||
|
||||
|
||||
$file = $this->_drupalfileobject($path);
|
||||
|
||||
if ($file->fid) {
|
||||
$owneraccount = user_load($file->uid);
|
||||
|
||||
/* AS */
|
||||
$owner = $owneraccount->name;
|
||||
|
||||
$ownerformat = variable_get('elfinder_settings_filesystem_owner_format', '');
|
||||
|
||||
if ($ownerformat != '') {
|
||||
$owner = token_replace($ownerformat, array('user' => $owneraccount));
|
||||
}
|
||||
|
||||
return $owner;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
public function desc($target, $newdesc = NULL) {
|
||||
$path = $this->decode($target);
|
||||
|
||||
$file = $this->_drupalfileobject($path);
|
||||
|
||||
if ($file->fid) {
|
||||
$finfo = db_select('elfinder_file_extinfo', 'f')
|
||||
->condition('fid', $file->fid)
|
||||
->fields('f', array('fid', 'description'))
|
||||
->execute()
|
||||
->fetchObject();
|
||||
|
||||
$descobj = new StdClass;
|
||||
$descobj->fid = $file->fid;
|
||||
$descobj->description = $newdesc;
|
||||
|
||||
if ($newdesc != NULL && user_access('edit file description')) {
|
||||
if (($rc = drupal_write_record('elfinder_file_extinfo', $descobj, isset($finfo->fid) ? array('fid') : array())) == 0) {
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
return $finfo->description;
|
||||
}
|
||||
}
|
||||
return $newdesc;
|
||||
}
|
||||
|
||||
public function downloadcount($target) {
|
||||
$path = $this->decode($target);
|
||||
|
||||
$file = $this->_drupalfileobject($path);
|
||||
|
||||
if ($file->fid && module_exists('elfinder_stats')) {
|
||||
$downloads = db_select('elfinder_stats', 's')
|
||||
->fields('s', array('fid'))
|
||||
->condition('s.fid', $file->fid)
|
||||
->condition('s.type', 'download')
|
||||
->countQuery()
|
||||
->execute()
|
||||
->fetchField();
|
||||
return $downloads ? $downloads : 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
protected function _archive($dir, $files, $name, $arc) {
|
||||
|
||||
if (!$this->CheckUserQuota()) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
$ret = parent::_archive($dir, $files, $name, $arc);
|
||||
|
||||
if ($ret != FALSE) {
|
||||
$file = $this->_drupalfileobject($ret);
|
||||
@file_save($file);
|
||||
$this->FileUsageAdd($file);
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract files from archive.
|
||||
*
|
||||
* Run the parent extract() then add the files to the Drupal db.
|
||||
*
|
||||
* @param string $hash
|
||||
* Archive filename hash.
|
||||
* @param bool $makedir
|
||||
* Extract the files into a new folder.
|
||||
* @return array|bool
|
||||
*/
|
||||
public function extract($hash, $makedir = NULL) {
|
||||
if (!$this->CheckUserQuota()) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
$fstat = array();
|
||||
|
||||
if ($makedir == NULL) {
|
||||
$fstat = parent::extract($hash);
|
||||
} else {
|
||||
$fstat = parent::extract($hash, $makedir);
|
||||
}
|
||||
|
||||
if ($fstat != FALSE) {
|
||||
$path = $this->decode($fstat['hash']);
|
||||
$this->AddToDrupalDB($path);
|
||||
$file = $this->_drupalfileobject($path);
|
||||
if ($fstat['mime'] !== 'directory') {
|
||||
$this->FileUsageAdd($file);
|
||||
}
|
||||
}
|
||||
|
||||
return $fstat;
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursive function to add new files to Drupal's db.
|
||||
*
|
||||
* TODO: If a file with the same name already exists anywhere else, this will
|
||||
* not create a new entry.
|
||||
*/
|
||||
protected function AddToDrupalDB($files) {
|
||||
foreach($files AS $file) {
|
||||
if($file['mime'] == 'directory') {
|
||||
$newfiles = $this->scandir($file['hash']);
|
||||
$this->AddToDrupalDB($newfiles);
|
||||
} else {
|
||||
$filepath = $this->decode($file['hash']);
|
||||
$file_object = $this->_drupalfileobject($filepath);
|
||||
@file_save($file_object);
|
||||
$this->FileUsageAdd($file_object);
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
protected function CalculateUserAllowedSpace($checkuser = NULL) {
|
||||
global $user;
|
||||
|
||||
$realUser = isset($checkuser) ? $checkuser : $user;
|
||||
|
||||
$currentSpace = $this->CalculateUserUsedSpace($realUser);
|
||||
|
||||
$maxSpace = isset($this->options['userProfile']->settings['user_quota']) ? parse_size($this->options['userProfile']->settings['user_quota']) : NULL;
|
||||
|
||||
$diff = $maxSpace - $currentSpace;
|
||||
|
||||
if (isset($maxSpace) && $maxSpace > 0) {
|
||||
|
||||
if ($diff > 0) {
|
||||
return $diff;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
protected function CalculateUserUsedSpace($checkuser = NULL) {
|
||||
global $user;
|
||||
|
||||
$realUser = isset($checkuser) ? $checkuser : $user;
|
||||
|
||||
$q = db_query("SELECT sum(filesize) FROM {file_managed} WHERE uid = :uid", array(':uid' => $realUser->uid));
|
||||
|
||||
$result = $q->fetchField();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
protected function FileUsageAdd($file) {
|
||||
// Record that the module elfinder is using the file.
|
||||
@file_usage_add($file, 'elfinder', 'elfinderFileFetcher', 0); // 0 : means that there is no reference at the moment.
|
||||
}
|
||||
|
||||
protected function FileUsageDelete($file) {
|
||||
// Delete record that the module elfinder is using the file.
|
||||
@file_usage_delete($file, 'elfinder', 'elfinderFileFetcher', 0); // 0 : means that there is no reference at the moment.
|
||||
}
|
||||
|
||||
protected function _checkArchivers() {
|
||||
$this->archivers = variable_get('elfinder_settings_misc_archivers', array());
|
||||
|
||||
if (count($this->archivers) == 0) {
|
||||
parent::_checkArchivers();
|
||||
variable_set('elfinder_settings_misc_archivers', $this->archivers);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Rename file and return file info
|
||||
*
|
||||
* @param string $hash file hash
|
||||
* @param string $name new file name
|
||||
* @return array|false
|
||||
**/
|
||||
public function rename($hash, $name) {
|
||||
|
||||
$results = parent::rename($hash, $name);
|
||||
// Update any fields that point to this file.
|
||||
field_cache_clear();
|
||||
return $results;
|
||||
}
|
||||
|
||||
/**
|
||||
* Taken from elFinderVolumeDriver::remove().
|
||||
*
|
||||
* Adds a message if the file is in use.
|
||||
*/
|
||||
protected function remove($path, $force = false) {
|
||||
$stat = $this->stat($path);
|
||||
|
||||
if (empty($stat)) {
|
||||
return $this->setError(elFinder::ERROR_RM, $path, elFinder::ERROR_FILE_NOT_FOUND);
|
||||
}
|
||||
|
||||
$stat['realpath'] = $path;
|
||||
$this->rmTmb($stat);
|
||||
$this->clearcache();
|
||||
|
||||
if (!$force && !empty($stat['locked'])) {
|
||||
return $this->setError(elFinder::ERROR_LOCKED, $this->path($stat['hash']));
|
||||
}
|
||||
|
||||
if ($stat['mime'] == 'directory' && empty($stat['thash'])) {
|
||||
$ret = $this->delTree($this->convEncIn($path));
|
||||
$this->convEncOut();
|
||||
if (!$ret) {
|
||||
return $this->setError(elFinder::ERROR_RM, $this->path($stat['hash']));
|
||||
}
|
||||
} else {
|
||||
$results = $this->_unlink($this->convEncIn($path));
|
||||
if (!$results) {
|
||||
return $this->setError(elFinder::ERROR_RM, $this->path($stat['hash']));
|
||||
}
|
||||
if (is_array($results)) {
|
||||
// File is in use and is being protected by Drupal. Fetch the first
|
||||
// entity where it's used.
|
||||
foreach($results AS $entity_type => $entity) {
|
||||
if(is_array($entity)) {
|
||||
foreach($entity AS $id => $count) {
|
||||
if($entity_type == 'node' && is_integer($id)) {
|
||||
$node = node_load($id);
|
||||
if(!empty($node->title)) {
|
||||
return $this->setError(elFinder::ERROR_RM, $this->path($stat['hash']), '', t('File is used in @title', array('@title' => $node->title)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $this->setError(elFinder::ERROR_RM, $this->path($stat['hash']), t('File is in use.'));
|
||||
}
|
||||
$this->clearstatcache();
|
||||
}
|
||||
$this->removed[] = $stat;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
239
sites/all/modules/contrib/files/elfinder/js/elfinder.callback.js
Normal file
@@ -0,0 +1,239 @@
|
||||
// $Id: elfinder.callback.js 106 2011-02-26 08:19:56Z ph0enix $
|
||||
|
||||
(function($) {
|
||||
|
||||
/**
|
||||
* @class elFinder command "search"
|
||||
* Find files
|
||||
*
|
||||
* @author Dmitry (dio) Levashov
|
||||
**/
|
||||
elFinder.prototype.commands.search = function() {
|
||||
this.title = 'Find files';
|
||||
this.options = {ui : 'searchbutton'}
|
||||
this.alwaysEnabled = true;
|
||||
this.updateOnSelect = false;
|
||||
|
||||
/**
|
||||
* Return command status.
|
||||
* Search does not support old api.
|
||||
*
|
||||
* @return Number
|
||||
**/
|
||||
this.getstate = function() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send search request to backend.
|
||||
*
|
||||
* @param String search string
|
||||
* @return $.Deferred
|
||||
**/
|
||||
this.exec = function(q) {
|
||||
var fm = this.fm;
|
||||
|
||||
if (typeof(q) == 'string' && q) {
|
||||
return fm.request({
|
||||
data : {cmd : 'search', elfinder_search_q : q},
|
||||
notify : {type : 'search', cnt : 1, hideCnt : true}
|
||||
});
|
||||
}
|
||||
fm.getUI('toolbar').find('.'+fm.res('class', 'searchbtn')+' :text').focus();
|
||||
return $.Deferred().reject();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
elFinder.prototype.commands.test134 = function() {
|
||||
this.title = 'Test Command';
|
||||
//this.options = {ui : 'uploadbutton'}
|
||||
this.alwaysEnabled = true;
|
||||
this.updateOnSelect = false;
|
||||
this.state = 0;
|
||||
|
||||
this.getstate = function() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send search request to backend.
|
||||
*
|
||||
* @param String search string
|
||||
* @return $.Deferred
|
||||
**/
|
||||
this.exec = function(q) {
|
||||
var fm = this.fm;
|
||||
|
||||
alert(Drupal.t('test command. arg=') + q);
|
||||
|
||||
return $.Deferred().reject();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
$().ready(function() {
|
||||
var uiopts = elFinder.prototype._options.uiOptions.toolbar;
|
||||
|
||||
var newOpts = new Array();
|
||||
|
||||
var disabledCommands = Drupal.settings.elfinder.disabledCommands;
|
||||
|
||||
|
||||
for (var i in uiopts) {
|
||||
var optsGroup = uiopts[i];
|
||||
var newOptsGroup = Array();
|
||||
|
||||
for (var j in optsGroup) {
|
||||
var found = false;
|
||||
for (var k in disabledCommands) {
|
||||
if (disabledCommands[k] == optsGroup[j]) {
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (found == false) {
|
||||
newOptsGroup.push(optsGroup[j]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (i == 0) {
|
||||
newOptsGroup.push('up');
|
||||
}
|
||||
|
||||
if (newOptsGroup.length >= 1) {
|
||||
newOpts.push(newOptsGroup);
|
||||
}
|
||||
}
|
||||
|
||||
var contextMenuCwd = elFinder.prototype._options.contextmenu.cwd;
|
||||
var contextMenuFiles = elFinder.prototype._options.contextmenu.files;
|
||||
var contextMenuNavbar = elFinder.prototype._options.contextmenu.navbar;
|
||||
|
||||
var newContextMenuCwd = Array();
|
||||
var newContextMenuFiles = Array();
|
||||
var newContextMenuNavbar = Array();
|
||||
|
||||
for (var i in contextMenuCwd) {
|
||||
var found = false;
|
||||
for (var k in disabledCommands) {
|
||||
if (disabledCommands[k] == contextMenuCwd[i]) {
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (found == false && contextMenuCwd[i] != '|') {
|
||||
newContextMenuCwd.push(contextMenuCwd[i]);
|
||||
}
|
||||
}
|
||||
|
||||
for (var i in contextMenuFiles) {
|
||||
var found = false;
|
||||
for (var k in disabledCommands) {
|
||||
if (disabledCommands[k] == contextMenuFiles[i]) {
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (found == false && contextMenuFiles[i] != '|') {
|
||||
newContextMenuFiles.push(contextMenuFiles[i]);
|
||||
}
|
||||
}
|
||||
|
||||
for (var i in contextMenuNavbar) {
|
||||
var found = false;
|
||||
for (var k in disabledCommands) {
|
||||
if (disabledCommands[k] == contextMenuNavbar[i]) {
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (found == false && contextMenuNavbar[i] != '|') {
|
||||
newContextMenuNavbar.push(contextMenuNavbar[i]);
|
||||
}
|
||||
}
|
||||
elFinder.prototype._options.uiOptions.toolbar = newOpts;
|
||||
elFinder.prototype._options.contextmenu.cwd = newContextMenuCwd;
|
||||
elFinder.prototype._options.contextmenu.files = newContextMenuFiles;
|
||||
elFinder.prototype._options.contextmenu.navbar = newContextMenuNavbar;
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
$().ready(function() {
|
||||
if (Drupal.settings.elfinder) {
|
||||
var editorApp = Drupal.settings.elfinder.editorApp;
|
||||
|
||||
var elfinderOpts = {
|
||||
url : Drupal.settings.elfinder.connectorUrl,
|
||||
lang : Drupal.settings.elfinder.langCode,
|
||||
rememberLastDir : Drupal.settings.elfinder.rememberLastDir,
|
||||
closeOnEditorCallback : false,
|
||||
customData : {token: Drupal.settings.elfinder.token}
|
||||
}
|
||||
|
||||
/* Pushing all settings to elFinder */
|
||||
$.extend(elfinderOpts, Drupal.settings.elfinder);
|
||||
|
||||
if (editorApp && typeof window[Drupal.settings.elfinder.editorCallback] == 'function') {
|
||||
elfinderOpts.editorCallback = window[Drupal.settings.elfinder.editorCallback];
|
||||
}
|
||||
|
||||
if (editorApp && typeof window[Drupal.settings.elfinder.editorCallback] == 'function') {
|
||||
elfinderOpts.getFileCallback = window[Drupal.settings.elfinder.editorCallback];
|
||||
}
|
||||
|
||||
if (elfinderOpts.api21) {
|
||||
//alert('api21');
|
||||
console.log('2.1 api');
|
||||
elfinderOpts['commandsOptions'] = {
|
||||
info: {
|
||||
// Key is the same as your command name
|
||||
desc : {
|
||||
// Field label
|
||||
label : 'Description1',
|
||||
|
||||
// HTML Template
|
||||
tpl : '<div class="elfinder-info-desc"><span class="elfinder-info-spinner"></span></div>',
|
||||
|
||||
// Action that sends the request to the server and get the description
|
||||
action : function(file, filemanager, dialog) {
|
||||
// Use the @filemanager object to issue a request
|
||||
filemanager.request({
|
||||
// Issuing the custom 'desc' command, targetting the selected file
|
||||
data : { cmd: 'desc', target: file.hash, },
|
||||
preventDefault: true,
|
||||
})
|
||||
// If the request fails, populate the field with 'Unknown'
|
||||
.fail(function() {
|
||||
dialog.find('.elfinder-info-desc').html(filemanager.i18n('unknown'));
|
||||
})
|
||||
// When the request is successful, show the description
|
||||
.done(function(data) {
|
||||
dialog.find('.elfinder-info-desc').html(data.desc);
|
||||
});
|
||||
},
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
$('#finder').elfinder(elfinderOpts);
|
||||
|
||||
if(elfinderOpts.browserMode != 'backend') {
|
||||
// If this is a popup, add an event so that elfinder fills the window.
|
||||
$(window).resize(function() {
|
||||
var h = ($(window).height());
|
||||
if($('#finder').height() != h) {
|
||||
$('#finder').height(h).resize();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
})(jQuery);
|
13
sites/all/modules/contrib/files/elfinder/js/elfinder.jquery-ui.min.js
vendored
Normal file
5
sites/all/modules/contrib/files/elfinder/js/elfinder.jquery.min.js
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
Drupal.elfinder = {
|
||||
editor: {}
|
||||
|
||||
}
|
7
sites/all/modules/contrib/files/elfinder/js/helper.js
Normal file
@@ -0,0 +1,7 @@
|
||||
// $Id: helper.js 100 2011-02-20 19:14:25Z ph0enix $
|
||||
|
||||
Drupal.elfinder = {
|
||||
editor: {}
|
||||
|
||||
}
|
||||
|
295
sites/all/modules/contrib/files/elfinder/js/info.js
Normal file
@@ -0,0 +1,295 @@
|
||||
"use strict";
|
||||
/**
|
||||
* @class elFinder command "info".
|
||||
* Display dialog with file properties.
|
||||
*
|
||||
* @author Dmitry (dio) Levashov, dio@std42.ru
|
||||
**/
|
||||
|
||||
(function($) {
|
||||
|
||||
elFinder.prototype.commands.info = function() {
|
||||
var m = 'msg',
|
||||
fm = this.fm,
|
||||
spclass = 'elfinder-info-spinner',
|
||||
msg = {
|
||||
calc : fm.i18n('calc'),
|
||||
size : fm.i18n('size'),
|
||||
unknown : fm.i18n('unknown'),
|
||||
path : fm.i18n('path'),
|
||||
aliasfor : fm.i18n('aliasfor'),
|
||||
modify : fm.i18n('modify'),
|
||||
perms : fm.i18n('perms'),
|
||||
locked : fm.i18n('locked'),
|
||||
dim : fm.i18n('dim'),
|
||||
kind : fm.i18n('kind'),
|
||||
files : fm.i18n('files'),
|
||||
folders : fm.i18n('folders'),
|
||||
items : fm.i18n('items'),
|
||||
yes : fm.i18n('yes'),
|
||||
no : fm.i18n('no'),
|
||||
link : fm.i18n('link'),
|
||||
owner : fm.i18n('owner'),
|
||||
desc : fm.i18n('description'),
|
||||
downloads: fm.i18n('downloads')
|
||||
};
|
||||
|
||||
this.tpl = {
|
||||
main : '<div class="ui-helper-clearfix elfinder-info-title"><span class="elfinder-cwd-icon {class} ui-corner-all"/>{title}</div><table class="elfinder-info-tb">{content}</table>',
|
||||
itemTitle : '<strong>{name}</strong><span class="elfinder-info-kind">{kind}</span>',
|
||||
groupTitle : '<strong>{items}: {num}</strong>',
|
||||
row : '<tr><td>{label} : </td><td>{value}</td></tr>',
|
||||
spinner : '<span>{text}</span> <span class="'+spclass+' '+spclass+'-'+'{id}"/>'
|
||||
}
|
||||
|
||||
this.alwaysEnabled = true;
|
||||
this.updateOnSelect = false;
|
||||
this.shortcuts = [{
|
||||
pattern : 'ctrl+i'
|
||||
}];
|
||||
|
||||
this.init = function() {
|
||||
$.each(msg, function(k, v) {
|
||||
msg[k] = fm.i18n(v);
|
||||
});
|
||||
}
|
||||
|
||||
this.getstate = function() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
this.exec = function(hashes) {
|
||||
|
||||
var self = this,
|
||||
fm = this.fm,
|
||||
tpl = this.tpl,
|
||||
row = tpl.row,
|
||||
files = this.files(hashes),
|
||||
cnt = files.length,
|
||||
content = [],
|
||||
view = tpl.main,
|
||||
l = '{label}',
|
||||
v = '{value}',
|
||||
opts = {
|
||||
title : this.title,
|
||||
width : 'auto',
|
||||
modal : true,
|
||||
close: function() {
|
||||
$(this).elfinderdialog('destroy');
|
||||
}
|
||||
},
|
||||
count = [],
|
||||
replSpinner = function(msg) {
|
||||
dialog.find('.' + spclass).parent().text(msg);
|
||||
},
|
||||
replSpinnerById = function(msg, id) {
|
||||
dialog.find('.' + spclass + '-' + id).parent().html(msg);
|
||||
},
|
||||
id = fm.namespace + '-info-' + $.map(files, function(f) {
|
||||
return f.hash
|
||||
}).join('-'),
|
||||
dialog = fm.getUI().find('#'+id),
|
||||
size, tmb, file, title, dcnt;
|
||||
|
||||
var disabledCommands = Drupal.settings.elfinder.disabledCommands,
|
||||
viewDesc = $.inArray('desc', disabledCommands) == -1 ? true : false,
|
||||
editDesc = $.inArray('editdesc', disabledCommands) == -1 ? true : false,
|
||||
viewOwner = $.inArray('owner', disabledCommands) == -1 ? true : false,
|
||||
viewDownloads = $.inArray('downloadcount', disabledCommands) == -1 ? true : false;
|
||||
|
||||
if (!cnt) {
|
||||
return $.Deferred().reject();
|
||||
}
|
||||
|
||||
if (dialog.length) {
|
||||
dialog.elfinderdialog('toTop');
|
||||
return $.Deferred().resolve();
|
||||
}
|
||||
|
||||
|
||||
if (cnt == 1) {
|
||||
file = files[0];
|
||||
view = view.replace('{class}', fm.mime2class(file.mime));
|
||||
title = tpl.itemTitle.replace('{name}', file.name).replace('{kind}', fm.mime2kind(file));
|
||||
|
||||
if (file.tmb) {
|
||||
tmb = fm.option('tmbUrl')+file.tmb;
|
||||
}
|
||||
|
||||
if (!file.read) {
|
||||
size = msg.unknown;
|
||||
} else if (file.mime != 'directory' || file.alias) {
|
||||
size = fm.formatSize(file.size);
|
||||
} else {
|
||||
/* adding spinner id to separate field updates */
|
||||
size = tpl.spinner.replace('{text}', msg.calc).replace('{id}', 'size');
|
||||
count.push(file.hash);
|
||||
}
|
||||
|
||||
content.push(row.replace(l, msg.size).replace(v, size));
|
||||
file.alias && content.push(row.replace(l, msg.aliasfor).replace(v, file.alias));
|
||||
content.push(row.replace(l, msg.path).replace(v, fm.escape(fm.path(file.hash))));
|
||||
file.read && content.push(row.replace(l, msg.link).replace(v, '<a href="'+fm.url(file.hash)+'" target="_blank">'+file.name+'</a>'));
|
||||
|
||||
if (file.dim) { // old api
|
||||
content.push(row.replace(l, msg.dim).replace(v, file.dim));
|
||||
} else if (file.mime.indexOf('image') !== -1) {
|
||||
content.push(row.replace(l, msg.dim).replace(v, tpl.spinner.replace('{text}', msg.calc).replace('{id}', 'dim')));
|
||||
fm.request({
|
||||
data : {cmd : 'dim', target : file.hash},
|
||||
preventDefault : true
|
||||
})
|
||||
.fail(function() {
|
||||
replSpinnerById(msg.unknown, 'dim');
|
||||
})
|
||||
.done(function(data) {
|
||||
replSpinnerById(data.dim || msg.unknown, 'dim');
|
||||
});
|
||||
}
|
||||
|
||||
content.push(row.replace(l, msg.modify).replace(v, fm.formatDate(file)));
|
||||
content.push(row.replace(l, msg.perms).replace(v, fm.formatPermissions(file)));
|
||||
content.push(row.replace(l, msg.locked).replace(v, file.locked ? msg.yes : msg.no));
|
||||
|
||||
/* Don't show fields if command not allowed */
|
||||
if (viewOwner) {
|
||||
content.push(row.replace(l, Drupal.t('Owner')).replace(v, tpl.spinner.replace('{text}', msg.calc).replace('{id}', 'owner')));
|
||||
|
||||
fm.request({
|
||||
data : {cmd : 'owner', target : file.hash},
|
||||
preventDefault : true
|
||||
})
|
||||
.fail(function() {
|
||||
replSpinnerById(msg.unknown, 'owner');
|
||||
})
|
||||
.done(function(data) {
|
||||
replSpinnerById(data.owner || msg.unknown, 'owner');
|
||||
});
|
||||
}
|
||||
|
||||
/* Don't show fields if command not allowed */
|
||||
if (viewDownloads) {
|
||||
content.push(row.replace(l, Drupal.t('Downloads')).replace(v, tpl.spinner.replace('{text}', msg.calc).replace('{id}', 'downloads')));
|
||||
|
||||
fm.request({
|
||||
data : {cmd : 'downloadcount', target : file.hash},
|
||||
preventDefault : true
|
||||
})
|
||||
.fail(function() {
|
||||
replSpinnerById(msg.unknown, 'downloads');
|
||||
})
|
||||
.done(function(data) {
|
||||
replSpinnerById(data.downloadcount || msg.unknown, 'downloads');
|
||||
});
|
||||
}
|
||||
|
||||
/* Don't show fields if command not allowed */
|
||||
if (viewDesc || editDesc) {
|
||||
|
||||
var desc = '<div id="elfinder-fm-file-desc">' + msg.calc + '</div>';
|
||||
|
||||
if (editDesc) {
|
||||
|
||||
desc = '<textarea cols="20" rows="5" id="elfinder-fm-file-desc" class="ui-widget ui-widget-content" disabled="true" >' + msg.calc + '</textarea><input type="button" id="elfinder-fm-file-desc-btn-save" value="' + fm.i18n('btnSave') + '" />';
|
||||
}
|
||||
|
||||
content.push(row.replace(l, Drupal.t('Description')).replace(v , desc));
|
||||
|
||||
fm.request({
|
||||
data : {cmd : 'desc', target : file.hash},
|
||||
preventDefault : true
|
||||
})
|
||||
.done(function(data) {
|
||||
var fieldDesc = dialog.find('#elfinder-fm-file-desc');
|
||||
|
||||
if (editDesc) {
|
||||
fieldDesc.val(data.desc || '');
|
||||
fieldDesc.removeAttr('disabled');
|
||||
} else {
|
||||
fieldDesc.empty();
|
||||
fieldDesc.html(data.desc || '');
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
view = view.replace('{class}', 'elfinder-cwd-icon-group');
|
||||
title = tpl.groupTitle.replace('{items}', msg.items).replace('{num}', cnt);
|
||||
dcnt = $.map(files, function(f) {
|
||||
return f.mime == 'directory' ? 1 : null
|
||||
}).length;
|
||||
if (!dcnt) {
|
||||
size = 0;
|
||||
$.each(files, function(h, f) {
|
||||
var s = parseInt(f.size);
|
||||
|
||||
if (s >= 0 && size >= 0) {
|
||||
size += s;
|
||||
} else {
|
||||
size = 'unknown';
|
||||
}
|
||||
});
|
||||
content.push(row.replace(l, msg.kind).replace(v, msg.files));
|
||||
content.push(row.replace(l, msg.size).replace(v, fm.formatSize(size)));
|
||||
} else {
|
||||
content.push(row.replace(l, msg.kind).replace(v, dcnt == cnt ? msg.folders : msg.folders+' '+dcnt+', '+msg.files+' '+(cnt-dcnt)))
|
||||
content.push(row.replace(l, msg.size).replace(v, tpl.spinner.replace('{text}', msg.calc).replace('{id}', 'size')));
|
||||
count = $.map(files, function(f) {
|
||||
return f.hash
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
view = view.replace('{title}', title).replace('{content}', content.join(''));
|
||||
|
||||
dialog = fm.dialog(view, opts);
|
||||
dialog.attr('id', id);
|
||||
|
||||
if (editDesc) {
|
||||
var inputDesc = $('#elfinder-fm-file-desc', dialog);
|
||||
var btnSave = $('#elfinder-fm-file-desc-btn-save', dialog).button();
|
||||
|
||||
btnSave.click(function() {
|
||||
fm.lockfiles({files : [file.hash]});
|
||||
fm.request({
|
||||
data : {cmd : 'desc', target : file.hash, content : inputDesc.val()},
|
||||
notify : {type : 'desc', cnt : 1}
|
||||
})
|
||||
.always(function() {
|
||||
fm.unlockfiles({files : [file.hash]})
|
||||
});
|
||||
});
|
||||
}
|
||||
// load thumbnail
|
||||
if (tmb) {
|
||||
$('<img/>')
|
||||
.load(function() {
|
||||
dialog.find('.elfinder-cwd-icon').css('background', 'url("' + tmb + '") center center no-repeat');
|
||||
})
|
||||
.attr('src', tmb);
|
||||
}
|
||||
|
||||
// send request to count total size
|
||||
if (count.length) {
|
||||
fm.request({
|
||||
data : {cmd : 'size', targets : count},
|
||||
preventDefault : true
|
||||
})
|
||||
.fail(function() {
|
||||
replSpinnerById(msg.unknown, 'size');
|
||||
})
|
||||
.done(function(data) {
|
||||
var size = parseInt(data.size);
|
||||
fm.log(data.size)
|
||||
replSpinnerById(size >= 0 ? fm.formatSize(size) : msg.unknown, 'size');
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
})(jQuery);
|
@@ -0,0 +1,14 @@
|
||||
; $Id: elfinder_ffsel.info,v 1.1.2.2 2010/11/20 23:18:55 ph0enix Exp $
|
||||
name = elFinder BUEditor integration
|
||||
description = Adding elFinder to BUEditor Insert Image dialog
|
||||
package = User interface
|
||||
core = 7.x
|
||||
|
||||
dependencies[] = bueditor
|
||||
dependencies[] = elfinder
|
||||
|
||||
; Information added by Drupal.org packaging script on 2018-12-03
|
||||
version = "7.x-2.x-dev"
|
||||
core = "7.x"
|
||||
project = "elfinder"
|
||||
datestamp = "1543843700"
|
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
// $Id: elfinder.module 102 2011-02-20 20:11:52Z ph0enix $
|
||||
|
||||
/**
|
||||
* BUEditor support for elFinder
|
||||
* Copyright (c) 2011, Alexey Sukhotin
|
||||
*/
|
||||
|
||||
function elfinder_bueditor_elfinder_js_settings($settings) {
|
||||
|
||||
$newsettings['editorCallback'] = 'elfinder_bue_callback';
|
||||
|
||||
$newsettings['browserscripts'][] = drupal_get_path('module', 'elfinder') . '/editors/bueditor/bueditor.callback.js';
|
||||
|
||||
return array('bue' => $newsettings, 'bueditor' => $newsettings);
|
||||
}
|
||||
|
||||
/* D7 Support */
|
||||
function elfinder_bueditor_init() {
|
||||
$settings = array();
|
||||
$settings['BUE']['imceURL'] = url('elfinder', array('query' => array('app' => 'bueditor' )));
|
||||
drupal_add_js($settings, 'setting');
|
||||
}
|
||||
|
@@ -0,0 +1,13 @@
|
||||
name = elFinder File Field Source
|
||||
description = File Field Sources elFinder connector
|
||||
package = User interface
|
||||
core = 7.x
|
||||
|
||||
dependencies[] = filefield_sources
|
||||
dependencies[] = elfinder
|
||||
|
||||
; Information added by Drupal.org packaging script on 2018-12-03
|
||||
version = "7.x-2.x-dev"
|
||||
core = "7.x"
|
||||
project = "elfinder"
|
||||
datestamp = "1543843700"
|
@@ -0,0 +1,310 @@
|
||||
<?php
|
||||
|
||||
// Main hooks to tell FielField Sources about our source
|
||||
function elfinder_ffsel_filefield_sources_info() {
|
||||
$params = array();
|
||||
return elfinder_ffsel_hooks('info', $params);
|
||||
}
|
||||
|
||||
function elfinder_ffsel_hooks($method, &$params) {
|
||||
$return = array();
|
||||
|
||||
$source = 'elfinder';
|
||||
|
||||
$function = 'filefield_source_' . $source . '_' . $method;
|
||||
|
||||
if (function_exists($function)) {
|
||||
$result = call_user_func_array($function, $params);
|
||||
if (isset($result) && is_array($result)) {
|
||||
$return = array_merge_recursive($return, $result);
|
||||
} elseif (isset($result)) {
|
||||
$return[] = $result;
|
||||
}
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
// Source specific functions
|
||||
|
||||
/**
|
||||
* Implementation of hook_filefield_source_info().
|
||||
*/
|
||||
function filefield_source_elfinder_info() {
|
||||
$source = array();
|
||||
|
||||
if (!module_exists('elfinder')) {
|
||||
return $source;
|
||||
}
|
||||
|
||||
$source['elfinder'] = array(
|
||||
'name' => t('elFinder'),
|
||||
'label' => t('elFinder File browser'),
|
||||
'description' => t('Uses elFinder file manager for file selection'),
|
||||
'process' => 'filefield_source_elfinder_process',
|
||||
'weight' => -1,
|
||||
);
|
||||
return $source;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of hook_menu().
|
||||
*/
|
||||
function filefield_source_elfinder_menu() {
|
||||
$items = array();
|
||||
$items['filefield/elfinder/%/%'] = array(
|
||||
'page callback' => 'filefield_source_elfinder_page',
|
||||
'page arguments' => array(2, 3),
|
||||
'access callback' => 'filefield_edit_access',
|
||||
'access arguments' => array(2, 3),
|
||||
'type' => MENU_CALLBACK,
|
||||
);
|
||||
return $items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of hook_theme().
|
||||
*/
|
||||
function elfinder_ffsel_theme() {
|
||||
return array(
|
||||
'filefield_source_elfinder_element' => array(
|
||||
'render element' => 'element',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of hook_filefield_source_settings().
|
||||
*/
|
||||
function filefield_source_elfinder_settings($op, $field) {
|
||||
$return = array();
|
||||
|
||||
// Add settings to the FileField widget form.
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* A #process callback to extend the filefield_widget element type.
|
||||
*/
|
||||
function filefield_source_elfinder_process($element, &$form_state, $form) {
|
||||
$instance = field_widget_instance($element, $form_state);
|
||||
|
||||
$element['filefield_elfinder'] = array(
|
||||
'#weight' => 100.5,
|
||||
'#theme' => 'filefield_source_elfinder_element',
|
||||
'#filefield_source' => TRUE, // Required for proper theming.
|
||||
'#description' => filefield_sources_element_validation_help($element['#upload_validators']),
|
||||
);
|
||||
|
||||
$filepath_id = $element['#id'] . '-elfinder-path';
|
||||
$display_id = $element['#id'] . '-elfinder-display';
|
||||
$select_id = $element['#id'] . '-elfinder-select';
|
||||
$element['filefield_elfinder']['file_path'] = array(
|
||||
'#type' => 'hidden',
|
||||
'#attributes' => array(
|
||||
'id' => $filepath_id,
|
||||
'onchange' => "if (!jQuery('#$select_id').attr('disabled')) { jQuery('#$select_id').mousedown().attr('disabled', true); jQuery('#$display_id').html(this.value); }",
|
||||
),
|
||||
'#value_callback' => 'elfinder_ffsel_element_value',
|
||||
'#upload_validators' => $element['#upload_validators'],
|
||||
'#maxlength' => NULL,
|
||||
);
|
||||
|
||||
$width = variable_get('elfinder_settings_misc_manager_width', '');
|
||||
if(!$width) {
|
||||
$width = ELFINDER_POPUP_WIDTH;
|
||||
}
|
||||
$height = variable_get('elfinder_settings_misc_manager_height', '');
|
||||
if(!$height) {
|
||||
$height = ELFINDER_POPUP_HEIGHT;
|
||||
}
|
||||
|
||||
$elfinder_function = 'var left = window.screenX + (window.innerWidth / 2) - (' . $width . ' / 2); var top = window.screenY + (window.innerHeight / 2) - (' . $height . ' / 2); window.open(\'' . url('elfinder', array('query' => array('app' => 'ffs', 'field_name' => $element['#field_name'], 'filepath_id' => $filepath_id, 'select_id' => $select_id))) . '\', \'\', \'width=' . $width . ',height=' . $height . ',top=\'+top+\',left=\'+left+\',resizable=1\'); return false;';
|
||||
|
||||
$element['filefield_elfinder']['display_path'] = array(
|
||||
'#type' => 'markup',
|
||||
'#markup' => '<span id="' . $display_id . '" class="filefield-sources-elfinder-display">' . t('No file selected') . '</span> (<a class="filefield-sources-elfinder-browse" href="#" onclick="' . $elfinder_function . '">' . t('browse') . '</a>)',
|
||||
);
|
||||
|
||||
$element['filefield_elfinder']['upload_button'] = array(
|
||||
'#name' => implode('_', $element['#array_parents']) . '_elfinder_select',
|
||||
'#type' => 'submit',
|
||||
'#value' => t('Select'),
|
||||
'#validate' => array(),
|
||||
'#submit' => array('filefield_sources_field_submit'),
|
||||
'#limit_validation_errors' => array($element['#parents']),
|
||||
'#name' => $element['#name'] . '[filefield_elfinder][button]',
|
||||
'#id' => $select_id,
|
||||
'#attributes' => array('style' => 'display: none;'),
|
||||
'#ajax' => array(
|
||||
'path' => 'file/ajax/' . implode('/', $element['#array_parents']) . '/' . $form['form_build_id']['#value'],
|
||||
'wrapper' => $element['upload_button']['#ajax']['wrapper'],
|
||||
'method' => 'replace',
|
||||
'effect' => 'fade',
|
||||
),
|
||||
);
|
||||
|
||||
return $element;
|
||||
}
|
||||
|
||||
/**
|
||||
* A #filefield_value_callback function.
|
||||
*
|
||||
* No longer used.
|
||||
*/
|
||||
function filefield_source_elfinder_value($element, &$item) {
|
||||
if (isset($item['filefield_elfinder']['file_path']) && $item['filefield_elfinder']['file_path'] != '') {
|
||||
$field = field_info_field($element['#field_name']);
|
||||
|
||||
$scheme = $field['settings']['uri_scheme'];
|
||||
$wrapper = file_stream_wrapper_get_instance_by_scheme($scheme);
|
||||
$file_directory_prefix = $wrapper->getDirectoryPath();
|
||||
$uri = preg_replace('/.*(' . preg_quote('/' . $file_directory_prefix . '/', '/') . ')/', $scheme . '://', $item['filefield_elfinder']['file_path']);
|
||||
|
||||
// Resolve the file path to an FID.
|
||||
$fid = db_select('file_managed', 'f')
|
||||
->condition('uri', rawurldecode($uri))
|
||||
->fields('f', array('fid'))
|
||||
->execute()
|
||||
->fetchField();
|
||||
if ($fid) {
|
||||
$file = file_load($fid);
|
||||
if (filefield_sources_element_validate($element, $file)) {
|
||||
$item = array_merge($item, (array) $file);
|
||||
}
|
||||
} else {
|
||||
$local_root = elfinder_document_root() . '/' . $file_directory_prefix . '/';
|
||||
$file_path = preg_replace('/.*(' . preg_quote('/' . $file_directory_prefix . '/', '/') . ')/', $local_root, $item['filefield_elfinder']['file_path']);
|
||||
|
||||
if ($file = filefield_sources_save_file($file_path, $element['#upload_validators'], $element['#upload_location'], FILE_EXISTS_REPLACE)) {
|
||||
$item = array_merge($item, (array) $file);
|
||||
drupal_set_message(t('File created'));
|
||||
} else {
|
||||
form_error($element, t('The selected file could not be used because the file does not exist in the database.'));
|
||||
}
|
||||
}
|
||||
// No matter what happens, clear the value from the file path field.
|
||||
$item['filefield_elfinder']['file_path'] = '';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Theme the output of the autocomplete field.
|
||||
*/
|
||||
function theme_filefield_source_elfinder_element($variables) {
|
||||
$element = $variables['element'];
|
||||
|
||||
$output = drupal_render_children($element);
|
||||
|
||||
return '<div class="filefield-source filefield-source-elfinder clear-block">' . $output . '</div>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of hook_elfinder_js_settings
|
||||
*/
|
||||
function elfinder_ffsel_elfinder_js_settings($settings) {
|
||||
/* for filefield_sources support */
|
||||
|
||||
$newsettings = array();
|
||||
|
||||
$newsettings['connectorUrl'] = url('elfinder/connector/relative');
|
||||
|
||||
if (isset($_GET['field_name'])) {
|
||||
if (preg_match("/^[a-zA-z0-9_-]+$/", $_GET['field_name'])) {
|
||||
$newsettings['field_name'] = $_GET['field_name'];
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($_GET['filepath_id'])) {
|
||||
if (preg_match("/^[a-zA-z0-9_-]+$/", $_GET['filepath_id'])) {
|
||||
$newsettings['filepath_id'] = $_GET['filepath_id'];
|
||||
}
|
||||
}
|
||||
|
||||
$newsettings['commandsOptions']['getfile']['onlyURL'] = TRUE;
|
||||
$newsettings['commandsOptions']['getfile']['multiple'] = TRUE;
|
||||
$newsettings['browserscripts'][] = drupal_get_path('module', 'elfinder_ffsel') . '/ffs.callback.js';
|
||||
$newsettings['editorCallback'] = 'elfinder_ffs_callback';
|
||||
|
||||
return array('ffs' => $newsettings);
|
||||
}
|
||||
|
||||
/**
|
||||
* Value handler that adds the files to the filefield values.
|
||||
*
|
||||
* Adapted from filefield_source_elfinder_value()
|
||||
* and filefield_sources_plupload_element_value()
|
||||
*/
|
||||
function elfinder_ffsel_element_value($element, $input = FALSE, &$form_state = NULL) {
|
||||
|
||||
if(empty($input)) {
|
||||
return array();
|
||||
}
|
||||
|
||||
$field_parents = array_slice($element['#array_parents'], 0, -3);
|
||||
$field_element = drupal_array_get_nested_value($form_state['complete form'], $field_parents);
|
||||
$field_name = $field_element['#field_name'];
|
||||
$langcode = $field_element['#language'];
|
||||
$field = field_info_field($field_name);
|
||||
|
||||
$scheme = $field['settings']['uri_scheme'];
|
||||
$wrapper = file_stream_wrapper_get_instance_by_scheme($scheme);
|
||||
$file_directory_prefix = $wrapper->getDirectoryPath();
|
||||
|
||||
// Get existing file values.
|
||||
// File Field items are stored in the field state starting from Drupal 7.9.
|
||||
$field_state = field_form_get_state($field_element['#field_parents'], $field_name, $langcode, $form_state);
|
||||
if (isset($field_state['items'])) {
|
||||
$items = $field_state['items'];
|
||||
} else {
|
||||
$items = drupal_array_get_nested_value($form_state['values'], $field_parents);
|
||||
}
|
||||
|
||||
// Update field values with new files.
|
||||
$upload_delta = isset($field_element['#file_upload_delta']) ? $field_element['#file_upload_delta'] : 0;
|
||||
|
||||
$files = explode('%%', $input);
|
||||
|
||||
foreach($files AS $delta => $file) {
|
||||
// Respect the field's count limit.
|
||||
if($upload_delta == $field['cardinality']) {
|
||||
break;
|
||||
}
|
||||
$uri = preg_replace('/.*(' . preg_quote('/' . $file_directory_prefix . '/', '/') . ')/', $scheme . '://', $file);
|
||||
// Resolve the file path to an FID.
|
||||
$fid = db_select('file_managed', 'f')
|
||||
->condition('uri', rawurldecode($uri))
|
||||
->fields('f', array('fid'))
|
||||
->execute()
|
||||
->fetchField();
|
||||
if ($fid) {
|
||||
$file = file_load($fid);
|
||||
if (filefield_sources_element_validate($element, $file)) {
|
||||
$items[$upload_delta] = (array) $file;
|
||||
$items[$upload_delta]['_weight'] = $upload_delta;
|
||||
$upload_delta++;
|
||||
}
|
||||
} else {
|
||||
$local_root = elfinder_document_root() . '/' . $file_directory_prefix . '/';
|
||||
$file_path = preg_replace('/.*(' . preg_quote('/' . $file_directory_prefix . '/', '/') . ')/', $local_root, $file);
|
||||
|
||||
if ($file = filefield_sources_save_file($file_path, $element['#upload_validators'], $element['#upload_location'], FILE_EXISTS_REPLACE)) {
|
||||
$items[$upload_delta] = (array) $file;
|
||||
$items[$upload_delta]['_weight'] = $upload_delta;
|
||||
$upload_delta++;
|
||||
drupal_set_message(t('File created'));
|
||||
} else {
|
||||
form_error($element, t('The selected file could not be used because the file does not exist in the database.'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Update form_state values.
|
||||
drupal_array_set_nested_value($form_state['values'], $field_parents, $items);
|
||||
|
||||
// Update items.
|
||||
$field_state['items'] = $items;
|
||||
field_form_set_state($field_element['#field_parents'], $field_name, $langcode, $form_state, $field_state);
|
||||
|
||||
return '';
|
||||
}
|
@@ -0,0 +1,26 @@
|
||||
function elfinder_ffs_callback(arg1) {
|
||||
|
||||
var fieldName = Drupal.settings.elfinder.field_name;
|
||||
var fieldId = Drupal.settings.elfinder.filepath_id;
|
||||
|
||||
var url = arg1;
|
||||
|
||||
if (typeof arg1 == 'object') {
|
||||
url = arg1.url;
|
||||
}
|
||||
|
||||
var filePath = url;
|
||||
|
||||
/* Needs rework: must support both classic single file selection and multiple selection */
|
||||
//var filePath = arg1.join('%%');
|
||||
|
||||
window.opener.jQuery('input#'+fieldId).val(filePath).change();
|
||||
window.opener.focus();
|
||||
|
||||
// Avoid beforeunload event when selecting an image.
|
||||
// https://github.com/Studio-42/elFinder/issues/1340
|
||||
// Maybe remove this when elfinder js library gets updated.
|
||||
//$(window).off('beforeunload');
|
||||
|
||||
window.close();
|
||||
}
|
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* elFinder file browser page template
|
||||
* Copyright (c) 2010, Alexey Sukhotin
|
||||
*/
|
||||
?>
|
||||
<div id="finder"></div>
|
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
* elFinder file browser page template
|
||||
* Copyright (c) 2010, Alexey Sukhotin
|
||||
*/
|
||||
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml"
|
||||
lang="<?php print isset($language->language) ? $language->language : 'en'; ?>"
|
||||
xml:lang="<?php print isset($language->language) ? $language->language : 'en'; ?>">
|
||||
<head>
|
||||
<title><?php print t('File Browser'); ?></title>
|
||||
|
||||
<?php
|
||||
print drupal_get_html_head();
|
||||
print elfinder_browser_css();
|
||||
print elfinder_browser_js();
|
||||
?>
|
||||
<!-- make inline popup WORK -->
|
||||
</head>
|
||||
<body class="elfinder">
|
||||
<div id="elfinder-messages"><?php print theme('status_messages'); ?></div>
|
||||
<div id="finder"></div>
|
||||
<?php print drupal_get_js('footer'); ?>
|
||||
</body>
|
||||
</html>
|