| 1 |
$Id: README.txt,v 1.3 2006/11/06 11:57:57 dman Exp $
|
| 2 |
|
| 3 |
Drupal filebrowser_extensions.module README.txt
|
| 4 |
===============================================
|
| 5 |
|
| 6 |
Filebrowser extensions is a rewrite of the Drupal filebrowser module,
|
| 7 |
now totally stand-alone. It provides directory browsing functionality,
|
| 8 |
allowing direct, enhanced access to public folders similar to FTP browsing
|
| 9 |
within a Drupal site.
|
| 10 |
In addition, it allows :
|
| 11 |
- in-page file listings,
|
| 12 |
- Ajax directory tree explorer,
|
| 13 |
- autocomplete and pop-up widgets,
|
| 14 |
- list (as well as table) rendering,
|
| 15 |
- and custom info columns for any type of metadata
|
| 16 |
|
| 17 |
+--------------------------------------------------------+
|
| 18 |
| IMPORTANT. If you receive "An HTTP error 404 occured" |
|
| 19 |
| alert during autocompletes, this is an Apache problem. |
|
| 20 |
| See the bugfix at the end. |
|
| 21 |
+--------------------------------------------------------+
|
| 22 |
|
| 23 |
Accessing filebrowser
|
| 24 |
---------------------------------------
|
| 25 |
For security and configurability, Filebrowsing is now presented in many
|
| 26 |
individual profiles.
|
| 27 |
|
| 28 |
A filebrowser profile is a configuration that specifies what directories can be
|
| 29 |
seen by whom, and how they are presented.
|
| 30 |
|
| 31 |
There are several different parameters that can be set for each filebrowser
|
| 32 |
profile or 'view'. Available filebrowser directories can be independant of
|
| 33 |
the global file_directory_path, different users and uses mean that the
|
| 34 |
browseable area may be rooted at (restricted to) subfolders within that, and
|
| 35 |
at any point, the user may be browsing to a lower level still. To protect the
|
| 36 |
internals from casual browsers, only the last part of the path will be
|
| 37 |
displayed on the URL, the full paths that get prepended to it in practice
|
| 38 |
must be deduced via context (the path that's being called) and is configured
|
| 39 |
by admins only.
|
| 40 |
|
| 41 |
To 'publish' a directory you would create a new profile in the
|
| 42 |
admin/settings/filebrowser_extensions ,
|
| 43 |
giving it a new <b>path</b> it will become available as.
|
| 44 |
Set parameters, choose rendering options,
|
| 45 |
and link to or make a menu item for this area.
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
When using the Ajax expanders, the child folders use the same
|
| 50 |
rendering configurations as the parent.
|
| 51 |
Thus AJAX callbacks are explicitly told what the context is
|
| 52 |
(via a 'mode' parameter). This ensures the number and type
|
| 53 |
of columns to display, and what rendering engine (table or list) is correct.
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
Using Filebrowser as a widget in other contexts
|
| 58 |
---------------------------------------
|
| 59 |
Inline
|
| 60 |
---------------------------------------
|
| 61 |
The filebrowser renderer can be used embedded in other pages, or stand-alone.
|
| 62 |
|
| 63 |
To EMBED a filebrowser table, the following PHP snippet could be copied into
|
| 64 |
a (php code) node:
|
| 65 |
|
| 66 |
<?php
|
| 67 |
print filebrowser_embed('images');
|
| 68 |
?>
|
| 69 |
|
| 70 |
The default filebrowser context is the system 'files/' directory, and this
|
| 71 |
snippet renders a listing of the contents of 'files/images'.
|
| 72 |
|
| 73 |
This is useful for providing direct access to a download directory, but is only
|
| 74 |
the default rendering, and doesn't behave with subdirectories.
|
| 75 |
|
| 76 |
A slightly more advanced version lets you select which columns to show.
|
| 77 |
|
| 78 |
<?php
|
| 79 |
$folder = 'images';
|
| 80 |
|
| 81 |
$profile = array(
|
| 82 |
'cols' => 'icon;name;size',// also used as headers. (no tablesort)
|
| 83 |
'render' => 'table',
|
| 84 |
);
|
| 85 |
|
| 86 |
print filebrowser_embed($folder,$profile);
|
| 87 |
|
| 88 |
?>
|
| 89 |
|
| 90 |
Handling deep browsing to folders is trickier, and best done as a custom
|
| 91 |
callback, not a PHP snippet, but the AJAX expanders can be told to work.
|
| 92 |
A contextual profile will be created and then remembered for later
|
| 93 |
(asynchonous) requests.
|
| 94 |
|
| 95 |
<?php
|
| 96 |
$folder = '';
|
| 97 |
$context = "demo3";
|
| 98 |
// each unique embed profile needs its own 'path' or context
|
| 99 |
// in order to serve up the same configurations on the later
|
| 100 |
// ajax calls.
|
| 101 |
|
| 102 |
$profile = array(
|
| 103 |
// very simple list
|
| 104 |
'cols' => 'expander;file',
|
| 105 |
'render' => 'list',
|
| 106 |
'path' => $context,
|
| 107 |
);
|
| 108 |
|
| 109 |
// scan & render
|
| 110 |
print filebrowser_embed($folder,$profile);
|
| 111 |
?>
|
| 112 |
|
| 113 |
The default table/column layout does not work wonderfully with multiple nesting
|
| 114 |
levels, and you may find it more aesthetic and sematic to use list elements
|
| 115 |
instead.
|
| 116 |
|
| 117 |
<?php
|
| 118 |
$folder = '';
|
| 119 |
$context = "demo4";
|
| 120 |
|
| 121 |
$profile = array(
|
| 122 |
'cols' => array('expander','file'),
|
| 123 |
'path' => $context,
|
| 124 |
);
|
| 125 |
|
| 126 |
print filebrowser_embed($folder,$profile);
|
| 127 |
?>
|
| 128 |
Again, we needed to create the dummy demo context in order to support
|
| 129 |
the later AJAX calls.
|
| 130 |
|
| 131 |
|
| 132 |
---------------------------------------
|
| 133 |
Custom columns
|
| 134 |
---------------------------------------
|
| 135 |
Available columns are :
|
| 136 |
expander : AJAX callback trigger to expand directories
|
| 137 |
name : linked filename, directorys linked to callback (sortable)
|
| 138 |
file : linked filename, directories NOT linked (use when embedding)
|
| 139 |
icon : linked icon
|
| 140 |
age : formatted duration (sortable)
|
| 141 |
size : formatted size (sortable)
|
| 142 |
type : suffix (sortable)
|
| 143 |
info : description, extracted as described above
|
| 144 |
|
| 145 |
More can be added by custom modules! Then invoked from other contexts.
|
| 146 |
See the filebrowser_get_cell_hook() examples in the code.
|
| 147 |
|
| 148 |
---------------------------------------
|
| 149 |
Popup
|
| 150 |
---------------------------------------
|
| 151 |
Filebrowser can now be used as a standalone popup widget.
|
| 152 |
The following code will launch a small filebrowser window, which will send back
|
| 153 |
the path of the selected file to the named form element.
|
| 154 |
<pre>
|
| 155 |
<form>
|
| 156 |
<input type=text id='fillme'/>
|
| 157 |
<input type='button' value='browse files' onclick='goBrowse()' />
|
| 158 |
<script>
|
| 159 |
function goBrowse(){
|
| 160 |
window.open(
|
| 161 |
"<?php echo url("filebrowser_popup" ,"targetelement=fillme"); ?>",
|
| 162 |
"popup",
|
| 163 |
"width=400, height=600, resizable=yes"
|
| 164 |
)
|
| 165 |
}
|
| 166 |
</script>
|
| 167 |
</form>
|
| 168 |
</pre>
|
| 169 |
|
| 170 |
---------------------------------------
|
| 171 |
Autocomplete
|
| 172 |
---------------------------------------
|
| 173 |
Also, an autocomplete handler is available. Creating a form element:
|
| 174 |
<?php
|
| 175 |
$form["choose_file"] = array(
|
| 176 |
'#type' => 'textfield',
|
| 177 |
'#title' => t("File"),
|
| 178 |
'#autocomplete_path' => 'filebrowser_autocomplete',
|
| 179 |
);
|
| 180 |
|
| 181 |
print(drupal_get_form('demo',$form));
|
| 182 |
?>
|
| 183 |
... will help you fill in the gaps.
|
| 184 |
|
| 185 |
Extending the '#autocomplete_path' , eg:
|
| 186 |
'filebrowser_autocomplete/avatars'
|
| 187 |
would start the completion from below that directory.
|
| 188 |
(browsing is always limited to below the system 'files' directory, so paths
|
| 189 |
begin relative to that)
|
| 190 |
|
| 191 |
Autocomplete in subdirectories requires a bugfix in form.inc 4.7.2
|
| 192 |
http://drupal.org/node/52116#comment-116656
|
| 193 |
|
| 194 |
For extreme examples, see the attach.module.
|