~quam-plures-core/quam-plures/xml-comment-feeds-fix

« back to all changes in this revision

Viewing changes to qp_inc/files/views/_file_upload.view.php

  • Committer: EdB
  • Date: 2013-05-18 17:02:22 UTC
  • mfrom: (7556.2.107 quam-plures)
  • Revision ID: 1912webworks@gmail.com-20130518170222-ccp8ok2njoasujlb
updating to current core

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
/**
3
3
 * This file implements the UI for file upload.
4
4
 *
5
 
 * This file is part of Quam Plures - {@link http://quamplures.net/}
6
 
 * See also {@link https://launchpad.net/quam-plures}.
7
 
 *
8
 
 * @copyright (c) 2009 - 2011 by the Quam Plures developers - {@link http://quamplures.net/}
9
 
 * @copyright (c)2003-2009 by Francois PLANQUE - {@link http://fplanque.net/}
10
 
 * Parts of this file are copyright (c)2004-2006 by Daniel HAHLER - {@link http://thequod.de/contact}.
11
 
 *
12
 
 * {@internal License choice
13
 
 * - If you have received this file as part of a package, please find the license.txt file in
14
 
 *   the same folder or the closest folder above for complete license terms.
15
 
 * - If you have received this file individually (e-g: from http://evocms.cvs.sourceforge.net/)
16
 
 *   then you must choose one of the following licenses before using the file:
17
 
 *   - GNU General Public License 2 (GPL) - http://www.opensource.org/licenses/gpl-license.php
18
 
 *   - Mozilla Public License 1.1 (MPL) - http://www.opensource.org/licenses/mozilla1.1.php
19
 
 * }}
20
 
 *
21
 
 * {@internal Open Source relicensing agreement:
22
 
 * Daniel HAHLER grants Francois PLANQUE the right to license
23
 
 * Daniel HAHLER's contributions to this file and the b2evolution project
24
 
 * under any OSI approved OSS license (http://www.opensource.org/licenses/).
25
 
 * }}
26
 
 *
27
 
 * {@internal Below is a list of authors who have contributed to design/coding of this file: }}
28
 
 * @author blueyed: Daniel HAHLER.
29
 
 * @author fplanque: Francois PLANQUE.
30
 
 *
 
5
 * @author {@link http://wonderwinds.com/ Ed Bennett}
 
6
 * @author {@link http://daniel.hahler.de/ Daniel HAHLER}
 
7
 * @author {@link http://fplanque.net/ Francois PLANQUE}
 
8
 * @copyright (c) 2009 by {@link http://quamplures.net/ the Quam Plures project}
 
9
 * @license http://www.gnu.org/licenses/gpl.txt GNU General Public License v3
31
10
 * @package files
32
11
 */
33
 
if( !defined('QP_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
 
12
if(!defined('QP_MAIN_INIT')) die('fail');
34
13
 
35
 
/**
36
 
 * @var Settings
37
 
 */
 
14
global $ads_list_path;
 
15
global $failedFiles;
 
16
global $fm_FileRoot;
38
17
global $Settings;
39
 
 
 
18
global $upload_quickmode;
 
19
global $uploadwithproperties;
40
20
global $UserSettings;
41
 
 
42
 
global $upload_quickmode, $failedFiles, $ads_list_path, $uploadwithproperties;
43
 
 
44
 
global $fm_FileRoot;
45
21
?>
46
22
 
47
23
<script type="text/javascript">
48
 
        <!--
49
 
        /**
50
 
         * Mighty cool function to append an input or textarea element onto another element.
51
 
         *
52
 
         * @usedby addAnotherFileInput()
53
 
         */
54
 
        function appendLabelAndInputElements( appendTo, labelText, labelBr, inputOrTextarea, inputName,
55
 
                                              inputSizeOrCols, inputMaxLengthOrRows, inputType, inputClass,
56
 
                                              inputChecked, labelLast, addLabelFor )
57
 
        {
58
 
                if( typeof( labelLast ) === 'undefined' )
59
 
                {
60
 
                        labelLast = false;
61
 
                }
62
 
 
63
 
                // INPUT:
64
 
                var fileInput = document.createElement( inputOrTextarea );
65
 
                fileInput.name = inputName;
66
 
                fileInput.id   = inputName.replace( /[\[\]]/g, '_' );
67
 
                if( inputOrTextarea == "input" )
68
 
                {
69
 
                        fileInput.type = typeof( inputType ) !== 'undefined' ?
70
 
                                                                                                inputType :
71
 
                                                                                                "text";
72
 
 
73
 
                        if( typeof( inputSizeOrCols ) !== 'undefined' )
74
 
                        {
75
 
                                fileInput.size = inputSizeOrCols;
76
 
                        }
77
 
 
78
 
                        if( typeof( inputMaxLengthOrRows ) !== 'undefined' )
79
 
                        {
80
 
                                fileInput.maxlength = inputMaxLengthOrRows;
81
 
                        }
 
24
<!--
 
25
/**
 
26
 * Mighty cool function to append an input or textarea element onto another element
 
27
 */
 
28
function appendLabelAndInputElements( appendTo, labelText, labelBr, inputOrTextarea, inputName, inputSizeOrCols,
 
29
        inputMaxLengthOrRows, inputType, inputClass, inputChecked, labelLast, addLabelFor )
 
30
{
 
31
        if( typeof( labelLast ) === 'undefined' )
 
32
        {
 
33
                labelLast = false;
 
34
        }
 
35
 
 
36
        // INPUT
 
37
        var fileInput = document.createElement( inputOrTextarea );
 
38
        fileInput.name = inputName;
 
39
        fileInput.id = inputName.replace( /[\[\]]/g, '_' );
 
40
        if( inputOrTextarea == "input" )
 
41
        {
 
42
                fileInput.type = typeof( inputType ) !== 'undefined' ? inputType : "text";
 
43
                if( typeof( inputSizeOrCols ) !== 'undefined' )
 
44
                {
 
45
                        fileInput.size = inputSizeOrCols;
 
46
                }
 
47
                if( typeof( inputMaxLengthOrRows ) !== 'undefined' )
 
48
                {
 
49
                        fileInput.maxlength = inputMaxLengthOrRows;
 
50
                }
 
51
        }
 
52
        else
 
53
        {
 
54
                fileInput.cols = inputSizeOrCols;
 
55
                fileInput.rows = inputMaxLengthOrRows;
 
56
        }
 
57
        fileInput.className = inputClass;
 
58
        if( labelLast )
 
59
        {
 
60
                // We want the label to appear after the input element
 
61
                appendTo.appendChild( fileInput );
 
62
                appendTo.appendChild( document.createTextNode( ' ' ) );
 
63
        }
 
64
 
 
65
        // LABEL
 
66
        var fileLabel = document.createElement('label');
 
67
        var fileLabelText = document.createTextNode( labelText );
 
68
        fileLabel.appendChild( fileLabelText );
 
69
        if( typeof( addLabelFor ) !== 'undefined' && addLabelFor )
 
70
        {
 
71
                fileLabel.htmlFor = fileInput.id;
 
72
        }
 
73
        appendTo.appendChild( fileLabel );
 
74
        if( ! labelLast )
 
75
        {
 
76
                // Label before input element
 
77
                if( labelBr )
 
78
                {
 
79
                        // We want a BR after the label
 
80
                        appendTo.appendChild( document.createElement('br') );
82
81
                }
83
82
                else
84
83
                {
85
 
                        fileInput.cols = inputSizeOrCols;
86
 
                        fileInput.rows = inputMaxLengthOrRows;
87
 
                }
88
 
 
89
 
                fileInput.className = inputClass;
90
 
 
91
 
                if( labelLast )
92
 
                {       // We want the label to appear after the input element:
93
 
                        appendTo.appendChild( fileInput );
94
84
                        appendTo.appendChild( document.createTextNode( ' ' ) );
95
85
                }
96
 
 
97
 
                // LABEL:
98
 
                var fileLabel = document.createElement('label');
99
 
                var fileLabelText = document.createTextNode( labelText );
100
 
 
101
 
                fileLabel.appendChild( fileLabelText );
102
 
 
103
 
                if( typeof( addLabelFor ) !== 'undefined' && addLabelFor )
104
 
                {
105
 
                        fileLabel.htmlFor = fileInput.id;
106
 
                }
107
 
 
108
 
                appendTo.appendChild( fileLabel );
109
 
 
110
 
                if( ! labelLast )
111
 
                {       // Label before input element:
112
 
                        if( labelBr )
113
 
                        { // We want a BR after the label:
114
 
                                appendTo.appendChild( document.createElement('br') );
115
 
                        }
116
 
                        else
117
 
                        {
118
 
                                appendTo.appendChild( document.createTextNode( ' ' ) );
119
 
                        }
120
 
 
121
 
                        appendTo.appendChild( fileInput );
122
 
                }
123
 
 
124
 
                appendTo.appendChild( document.createElement('br') );
125
 
 
126
 
                if( typeof( inputChecked ) !== 'undefined' && inputChecked )
127
 
                {       // Checkbox is checked:
128
 
                        fileInput.setAttribute( 'checked', 'checked' );
129
 
                }
130
 
        }
131
 
 
132
 
 
133
 
        var nextFileInputID;
134
 
 
135
 
        /**
136
 
         * Add a new fileinput area to the upload form.
137
 
         */
138
 
        function addAnotherFileInput()
139
 
        {
140
 
                var uploadfiles = document.getElementById("uploadfileinputs");
141
 
                var newLI = document.createElement("li");
142
 
                var closeLink = document.createElement("a");
143
 
                var closeImage = document.createElement("img");
144
 
 
145
 
                uploadfiles.appendChild( newLI );
146
 
                newLI.appendChild( closeLink );
147
 
                closeLink.appendChild( closeImage );
148
 
 
149
 
 
150
 
                newLI.className = "clear";
151
 
 
152
 
                closeImage.src = "<?php echo get_icon( 'close', 'url' ) ?>";
153
 
                closeImage.alt = "<?php echo get_icon( 'close', 'alt' ) ?>";
154
 
 
155
 
                <?php
156
 
                $icon_class = get_icon( 'close', 'class' );
157
 
                if( $icon_class )
158
 
                {
159
 
                        ?>
160
 
                        closeImage.className = '<?php echo $icon_class ?>';
161
 
                        <?php
162
 
                }
163
 
 
164
 
                if( get_icon( 'close', 'rollover' ) )
165
 
                { // handle rollover images ('close' by default is one).
166
 
                        ?>
167
 
                        closeLink.className = 'rollover';
168
 
                        if( typeof setupRollovers == 'function' )
169
 
                        {
170
 
                                setupRollovers();
171
 
                        }
172
 
                        <?php
173
 
                }
174
 
                ?>
175
 
                closeImage.setAttribute( 'onclick', "document.getElementById('uploadfileinputs').removeChild(this.parentNode.parentNode);" ); // TODO: setting onclick this way DOES NOT work in IE. (try attachEvent then)
176
 
                closeLink.style.cssFloat = 'right';             // standard (not working in IE)
177
 
                closeLink.style.styleFloat = 'right'; // IE
178
 
 
179
 
                appendLabelAndInputElements( newLI, '<?php echo TS_('Choose a file'); ?>:', false, 'input', 'uploadfile['+nextFileInputID+']', '70', '0', 'file', 'upload_file' );
180
 
                <?php
181
 
                if( $uploadwithproperties )
182
 
                {       // We want file properties on the upload form:
183
 
                        ?>
 
86
                appendTo.appendChild( fileInput );
 
87
        }
 
88
        appendTo.appendChild( document.createElement('br') );
 
89
 
 
90
        if( typeof( inputChecked ) !== 'undefined' && inputChecked )
 
91
        {
 
92
                // Checkbox is checked
 
93
                fileInput.setAttribute( 'checked', 'checked' );
 
94
        }
 
95
}
 
96
 
 
97
var nextFileInputID;
 
98
 
 
99
/**
 
100
 * Add a new fileinput area to the upload form.
 
101
 */
 
102
function addAnotherFileInput()
 
103
{
 
104
        var uploadfiles = document.getElementById("uploadfileinputs");
 
105
        var newLI = document.createElement("li");
 
106
        var closeLink = document.createElement("a");
 
107
        var closeImage = document.createElement("img");
 
108
        uploadfiles.appendChild( newLI );
 
109
        newLI.appendChild( closeLink );
 
110
        closeLink.appendChild( closeImage );
 
111
 
 
112
        newLI.className = "clear";
 
113
 
 
114
        closeImage.src = "<?php echo get_icon( 'close', 'url' ) ?>";
 
115
        closeImage.alt = "<?php echo get_icon( 'close', 'alt' ) ?>";
 
116
        <?php
 
117
        $icon_class = get_icon( 'close', 'class' );
 
118
        if( $icon_class )
 
119
        {
 
120
                ?>
 
121
                closeImage.className = '<?php echo $icon_class ?>';
 
122
                <?php
 
123
        }
 
124
 
 
125
        if( get_icon( 'close', 'rollover' ) )
 
126
        {
 
127
                // handle rollover images ('close' by default is one)
 
128
                ?>
 
129
                closeLink.className = 'rollover';
 
130
                if( typeof setupRollovers == 'function' )
 
131
                {
 
132
                        setupRollovers();
 
133
                }
 
134
                <?php
 
135
        }
 
136
        ?>
 
137
        closeImage.setAttribute( 'onclick', "document.getElementById('uploadfileinputs').removeChild(this.parentNode.parentNode);" );
 
138
        closeLink.style.cssFloat = 'right'; // standard (not working in IE)
 
139
        closeLink.style.styleFloat = 'right'; // IE
 
140
 
 
141
        appendLabelAndInputElements( newLI, '<?php echo TS_('Choose a file'); ?>:', false, 'input', 'uploadfile['+nextFileInputID+']', '70', '0', 'file', 'upload_file' );
 
142
        <?php
 
143
        if( $uploadwithproperties )
 
144
        {
 
145
                // We want file properties on the upload form:
 
146
                ?>
184
147
                appendLabelAndInputElements( newLI, '<?php echo TS_('Filename on server (optional)'); ?>:', false, 'input', 'uploadfile_name['+nextFileInputID+']', '50', '80', 'text', '' );
185
148
                appendLabelAndInputElements( newLI, '<?php echo TS_('Long title'); ?>:', true, 'input', 'uploadfile_title['+nextFileInputID+']', '50', '255', 'text', 'large' );
186
149
                appendLabelAndInputElements( newLI, '<?php echo TS_('Cascade file info (file name -> title -> alt -> description)?'); ?>', false, 'input', 'uploadfile_cascade['+nextFileInputID+']', undefined, undefined, 'checkbox', '', true, true, true );
187
150
                appendLabelAndInputElements( newLI, '<?php echo TS_('Alternative text (useful for images)'); ?>:', true, 'input', 'uploadfile_alt['+nextFileInputID+']', '50', '255', 'text', 'large' );
188
151
                appendLabelAndInputElements( newLI, '<?php echo TS_('Caption/Description of the file'); ?>:', true, 'textarea', 'uploadfile_desc['+nextFileInputID+']', '38', '3', '', 'large' );
189
 
                        <?php
190
 
                }
191
 
                else
192
 
                {
193
 
                        ?>
 
152
                <?php
 
153
        }
 
154
        else
 
155
        {
 
156
                ?>
194
157
                // Pretend we want to cascade metadata:
195
158
                var cascade_input = document.createElement( 'input' );
196
159
                cascade_input.name = 'uploadfile_cascade['+nextFileInputID+']';
198
161
                cascade_input.value = '1';
199
162
 
200
163
                newLI.appendChild( cascade_input );
201
 
                        <?php
202
 
                }
203
 
                ?>
204
 
 
205
 
                nextFileInputID++;
 
164
                <?php
206
165
        }
207
 
        // -->
 
166
        ?>
 
167
 
 
168
        nextFileInputID++;
 
169
}
 
170
// -->
208
171
</script>
209
172
 
210
173
<?php
211
 
        // Begin payload block:
212
 
        $this->disp_payload_begin();
213
 
 
214
 
 
215
 
        $Form = new Form( NULL, 'fm_upload_checkchanges', 'post', 'none', 'multipart/form-data' );
216
 
        $Form->begin_form( 'fform' );
217
 
                $Form->hidden_ctrl();
218
 
                $Form->hidden( 'MAX_FILE_SIZE', $Settings->get( 'upload_maxkb' )*1024 ); // Just a hint for the browser.
219
 
                $Form->hidden( 'upload_quickmode', $upload_quickmode );
220
 
                $Form->hiddens_by_key( get_memorized() );
221
 
 
222
 
 
223
 
        $Widget = new Widget( 'file_browser' );
224
 
 
225
 
        $Widget->global_icon( T_('Quit upload mode!'), 'close', regenerate_url( 'ctrl,fm_mode', 'ctrl=files' ) );
226
 
 
227
 
        $Widget->title = get_manual_link( 'file-upload' ).T_('File upload');
228
 
        $Widget->disp_template_replaced( 'block_start' );
229
 
 
230
 
 
 
174
// Begin payload block
 
175
$this->disp_payload_begin();
 
176
 
 
177
$Form = new Form( NULL, 'fm_upload_checkchanges', 'post', 'none', 'multipart/form-data' );
 
178
$Form->begin_form( 'fform' );
 
179
$Form->hidden_ctrl();
 
180
$Form->hidden( 'MAX_FILE_SIZE', $Settings->get( 'upload_maxkb' )*1024 ); // Just a hint for the browser.
 
181
$Form->hidden( 'upload_quickmode', $upload_quickmode );
 
182
$Form->hiddens_by_key( get_memorized() );
 
183
 
 
184
$Widget = new Widget( 'file_browser' );
 
185
$Widget->global_icon( T_('Quit upload mode!'), 'close', regenerate_url( 'ctrl,fm_mode', 'ctrl=files' ), T_('cancel') );
 
186
$Widget->title = T_('File upload');
 
187
$Widget->disp_template_replaced( 'block_start' );
231
188
?>
232
 
 
233
189
<table id="fm_browser" cellspacing="0" cellpadding="0">
234
 
        <thead>
235
 
                <tr>
236
 
                        <td colspan="2" id="fm_bar">
237
 
                        <?php
238
 
                                if( $uploadwithproperties )
239
 
                                {
240
 
                                        echo '<a href="'.regenerate_url( 'uploadwithproperties', 'uploadwithproperties=0' ).'">'.T_('Hide advanced upload properties').'</a>';
241
 
                                }
242
 
                                else
243
 
                                {
244
 
                                        echo '<a href="'.regenerate_url( 'uploadwithproperties', 'uploadwithproperties=1' ).'">'.T_('Show advanced upload properties').'</a>';
245
 
                                }
246
 
                        ?>
247
 
                        </td>
248
 
                </tr>
249
 
        </thead>
250
 
 
251
 
        <tbody>
252
 
                <tr>
253
 
                        <?php
254
 
                                echo '<td id="fm_dirtree">';
255
 
 
256
 
                                // Version with all roots displayed
257
 
                                echo get_directory_tree( NULL, NULL, $ads_list_path, true );
258
 
 
259
 
                                // Version with only the current root displayed:
260
 
                                /* echo get_directory_tree( $fm_FileRoot, $fm_FileRoot->ads_path, $ads_list_path, true ); */
261
 
                                echo '</td>';
262
 
                                echo '<td id="fm_files">';
263
 
 
264
 
                                if( count( $failedFiles ) )
265
 
                                {
266
 
                                        echo '<p class="error">'.T_('Some file uploads failed. Please check the errors below.').'</p>';
267
 
                                        // Display failed files:
268
 
                                        $displayFiles = & $failedFiles;
269
 
                                }
270
 
                                else
271
 
                                {       // No failed failes, display 5 empty input blocks:
272
 
                                        $displayFiles = array( NULL, NULL, NULL, NULL, NULL );
273
 
                                }
274
 
                        ?>
275
 
 
276
 
                        <script type="text/javascript">
277
 
                                <!--
278
 
                                nextFileInputID = <?php echo max( array_keys( $displayFiles ) ) + 1; ?>;
279
 
                                // -->
280
 
                        </script>
281
 
 
282
 
                        <div class="upload_title"><?php echo T_('Files to upload') ?></div>
283
 
 
284
 
                        <ul id="uploadfileinputs">
285
 
                                <?php
286
 
                                        foreach( $displayFiles as $lKey => $lMessage )
287
 
                                        { // For each file upload block to display:
288
 
 
289
 
                                                if( $lMessage !== NULL )
290
 
                                                { // This is a failed upload:
291
 
                                                        echo '<li class="invalid" title="'
292
 
                                                                                        ./* TRANS: will be displayed as title for failed file uploads */ T_('Invalid submission.').'">';
293
 
                                                        echo '<p class="error">'.$lMessage.'</p>';
294
 
                                                }
295
 
                                                else
296
 
                                                { // Not a failed upload, display normal block:
297
 
                                                        echo '<li>';
298
 
                                                }
299
 
 
300
 
                                                // fp> TODO: would be cool to add a close icon starting at the 2nd <li>
301
 
                                                // dh> TODO: it may be useful to add the "accept" attrib to the INPUT elements to give the browser a hint about the accepted MIME types
302
 
                                                ?>
303
 
 
304
 
                                                <label><?php echo T_('Choose a file'); ?>:</label>
305
 
                                                <input name="uploadfile[<?php echo $lKey; ?>]" size="70" type="file" class="upload_file" /><br />
306
 
 
307
 
                                                <?php
308
 
                                                if( $uploadwithproperties )
309
 
                                                {       // We want file properties on the upload form:
310
 
                                                        ?>
311
 
                                                        <label><?php echo T_('Filename on server (optional)'); ?>:</label>
312
 
                                                        <input name="uploadfile_name[<?php echo $lKey; ?>]" type="text" size="50" maxlength="80"
313
 
                                                                value="<?php echo ( isset( $uploadfile_name[$lKey] ) ? format_to_output( $uploadfile_name[$lKey], 'formvalue' ) : '' ) ?>" /><br />
314
 
 
315
 
                                                        <input name="uploadfile_cascade[<?php echo $lKey; ?>]" id="uploadfile_cascade_<?php echo $lKey; ?>_" type="checkbox"
316
 
                                                                <?php echo isset( $uploadfile_cascade[$lKey] ) || $lMessage === NULL /* default: checked */ ? 'checked="checked"' : '' ?> />
317
 
                                                        <label for="uploadfile_cascade_<?php echo $lKey; ?>_"><?php echo T_('Cascade file info (file name -> title -> alt -> description)?'); ?></label><br />
318
 
 
319
 
                                                        <label><?php echo T_('Long title'); ?>:</label><br />
320
 
                                                        <input name="uploadfile_title[<?php echo $lKey; ?>]" type="text" size="50" maxlength="255" class="large"
321
 
                                                                value="<?php echo ( isset( $uploadfile_title[$lKey] ) ? format_to_output( $uploadfile_title[$lKey], 'formvalue' ) : '' );
322
 
                                                                ?>" /><br />
323
 
 
324
 
                                                        <label><?php echo T_('Alternative text (useful for images)'); ?>:</label><br />
325
 
                                                        <input name="uploadfile_alt[<?php echo $lKey; ?>]" type="text" size="50" maxlength="255" class="large"
326
 
                                                                value="<?php echo ( isset( $uploadfile_alt[$lKey] ) ? format_to_output( $uploadfile_alt[$lKey], 'formvalue' ) : '' );
327
 
                                                                ?>" /><br />
328
 
 
329
 
                                                        <label><?php echo T_('Caption/Description of the file'); /* TODO: maxlength (DB) */ ?>:</label><br />
330
 
                                                        <textarea name="uploadfile_desc[<?php echo $lKey; ?>]" rows="3" cols="38" class="large"><?php
331
 
                                                                echo ( isset( $uploadfile_desc[$lKey] ) ? $uploadfile_desc[$lKey] : '' )
332
 
                                                        ?></textarea><br />
333
 
                                                        <?php
334
 
                                                }
335
 
                                                else
336
 
                                                {       // Pretend we want to cascade metadata:
337
 
                                                        ?>
338
 
                                                        <input name="uploadfile_cascade[<?php echo $lKey; ?>]" type="hidden" value="1" />
339
 
                                                        <?php
340
 
                                                }
341
 
 
342
 
                                                echo '</li>';
343
 
                                                // no text after </li> or JS will bite you! (This is where additional blocks get inserted)
344
 
                                        }
345
 
 
346
 
                                ?>
347
 
                        </ul>
348
 
 
349
 
                        <p class="uploadfileinputs"><a href="#" onclick="addAnotherFileInput(); return false;" class="small"><?php echo T_('Add another file'); ?></a></p>
350
 
 
351
 
                        <div class="upload_foot">
352
 
                                <input type="submit" value="<?php echo format_to_output( T_('Upload to server now'), 'formvalue' ); ?>" class="ActionButton" >
353
 
                                <input type="reset" value="<?php echo format_to_output( T_('Reset'), 'formvalue' ); ?>" class="ResetButton">
354
 
 
355
 
                                <p class="note">
356
 
                                        <?php
357
 
                                        $restrictNotes = array();
358
 
 
359
 
                                        // Get list of recognized file types (others are not allowed to get uploaded)
360
 
                                        // dh> because FiletypeCache/DataObjectCache has no interface for getting a list, this dirty query seems less dirty to me.
361
 
                                        $allowed_extensions = $DB->get_col( 'SELECT ftyp_extensions FROM T_filetypes WHERE ftyp_allowed != 0' );
362
 
                                        $allowed_extensions = implode( ' ', $allowed_extensions ); // implode with space, ftyp_extensions can hold many, separated by space
363
 
                                        // into array:
364
 
                                        $allowed_extensions = preg_split( '~\s+~', $allowed_extensions, -1, PREG_SPLIT_NO_EMPTY );
365
 
                                        // readable:
366
 
                                        $allowed_extensions = implode_with_and($allowed_extensions);
367
 
 
368
 
                                        $restrictNotes[] = '<strong>'.T_('Allowed file extensions').'</strong>: '.$allowed_extensions;
369
 
 
370
 
                                        if( $Settings->get( 'upload_maxkb' ) )
371
 
                                        { // We want to restrict on file size:
372
 
                                                $restrictNotes[] = '<strong>'.T_('Maximum allowed file size').'</strong>: '.bytesreadable( $Settings->get( 'upload_maxkb' )*1024 );
373
 
                                        }
374
 
 
375
 
                                        echo implode( '<br />', $restrictNotes ).'<br />';
376
 
                                        ?>
377
 
                                </p>
378
 
                        </div>
379
 
 
380
 
                </td>
381
 
                </tr>
382
 
        </tbody>
383
 
</table>
384
 
 
385
 
<?php
386
 
 
387
 
        $Widget->disp_template_raw( 'block_end' );
388
 
 
389
 
        $Form->end_form();
390
 
 
391
 
        // End payload block:
392
 
        $this->disp_payload_end();
 
190
<thead><tr><td colspan="2" id="fm_bar">
 
191
<?php
 
192
if( $uploadwithproperties )
 
193
{
 
194
        echo '<a href="'.regenerate_url( 'uploadwithproperties', 'uploadwithproperties=0' ).'">'.T_('Hide advanced upload properties').'</a>';
 
195
}
 
196
else
 
197
{
 
198
        echo '<a href="'.regenerate_url( 'uploadwithproperties', 'uploadwithproperties=1' ).'">'.T_('Show advanced upload properties').'</a>';
 
199
}
 
200
?>
 
201
</td></tr></thead>
 
202
 
 
203
<tbody>
 
204
<tr>
 
205
<?php
 
206
echo '<td id="fm_dirtree">';
 
207
 
 
208
// Version with all roots displayed
 
209
echo get_directory_tree( NULL, NULL, $ads_list_path, true );
 
210
 
 
211
// Version with only the current root displayed
 
212
# echo get_directory_tree( $fm_FileRoot, $fm_FileRoot->ads_path, $ads_list_path, true );
 
213
echo '</td>';
 
214
echo '<td id="fm_files">';
 
215
 
 
216
if( count( $failedFiles ) )
 
217
{
 
218
        echo '<p class="error">'.T_('Some file uploads failed. Please check the errors below.').'</p>';
 
219
        // Display failed files
 
220
        $displayFiles = & $failedFiles;
 
221
}
 
222
else
 
223
{
 
224
        // No failed failes, display 5 empty input blocks
 
225
        $displayFiles = array( NULL, NULL, NULL, NULL, NULL );
 
226
}
 
227
?>
 
228
 
 
229
<script type="text/javascript">
 
230
<!--
 
231
nextFileInputID = <?php echo max( array_keys( $displayFiles ) ) + 1; ?>;
 
232
// -->
 
233
</script>
 
234
 
 
235
<div class="upload_title"><?php echo T_('Files to upload') ?></div>
 
236
<ul id="uploadfileinputs">
 
237
<?php
 
238
foreach( $displayFiles as $lKey => $lMessage )
 
239
{
 
240
        // For each file upload block to display
 
241
        if( $lMessage !== NULL )
 
242
        {
 
243
                // This is a failed upload
 
244
                echo '<li class="invalid" title="'
 
245
                        ./* TRANS: will be displayed as title for failed file uploads */ T_('Invalid submission.').'">';
 
246
                echo '<p class="error">'.$lMessage.'</p>';
 
247
        }
 
248
        else
 
249
        {
 
250
                // Not a failed upload, display normal block
 
251
                echo '<li>';
 
252
        }
 
253
 
 
254
        // @todo (0000) fp> would be cool to add a close icon starting at the 2nd <li>
 
255
        // @todo (0000) dh> it may be useful to add the "accept" attrib to the INPUT
 
256
        // elements to give the browser a hint about the accepted MIME types
 
257
        ?>
 
258
 
 
259
        <label><?php echo T_('Choose a file'); ?>:</label>
 
260
        <input name="uploadfile[<?php echo $lKey; ?>]" size="70" type="file" class="upload_file" /><br />
 
261
 
 
262
        <?php
 
263
        if( $uploadwithproperties )
 
264
        {
 
265
                // We want file properties on the upload form
 
266
                ?>
 
267
                <label><?php echo T_('Filename on server (optional)'); ?>:</label>
 
268
                <input name="uploadfile_name[<?php echo $lKey; ?>]" type="text" size="50" maxlength="80" value="<?php echo ( isset( $uploadfile_name[$lKey] ) ? format_to_output( $uploadfile_name[$lKey], 'formvalue' ) : '' ) ?>" /><br />
 
269
 
 
270
                <input name="uploadfile_cascade[<?php echo $lKey; ?>]" id="uploadfile_cascade_<?php echo $lKey; ?>_" type="checkbox" <?php echo isset( $uploadfile_cascade[$lKey] ) || $lMessage === NULL /* default: checked */ ? 'checked="checked"' : '' ?>/>
 
271
                <label for="uploadfile_cascade_<?php echo $lKey; ?>_"><?php echo T_('Cascade file info (file name -> title -> alt -> description)?'); ?></label><br />
 
272
 
 
273
                <label><?php echo T_('Long title'); ?>:</label><br />
 
274
                <input name="uploadfile_title[<?php echo $lKey; ?>]" type="text" size="50" maxlength="255" class="large" value="<?php echo ( isset( $uploadfile_title[$lKey] ) ? format_to_output( $uploadfile_title[$lKey], 'formvalue' ) : '' ); ?>" /><br />
 
275
 
 
276
                <label><?php echo T_('Alternative text (useful for images)'); ?>:</label><br />
 
277
                <input name="uploadfile_alt[<?php echo $lKey; ?>]" type="text" size="50" maxlength="255" class="large" value="<?php echo ( isset( $uploadfile_alt[$lKey] ) ? format_to_output( $uploadfile_alt[$lKey], 'formvalue' ) : '' ); ?>" /><br />
 
278
 
 
279
                <label><?php echo T_('Caption/Description of the file'); ?>:</label><br />
 
280
                <textarea name="uploadfile_desc[<?php echo $lKey; ?>]" rows="3" cols="38" class="large"><?php echo ( isset( $uploadfile_desc[$lKey] ) ? $uploadfile_desc[$lKey] : '' ); ?></textarea><br />
 
281
                <?php
 
282
        }
 
283
        else
 
284
        {
 
285
                // Pretend we want to cascade metadata
 
286
                ?>
 
287
                <input name="uploadfile_cascade[<?php echo $lKey; ?>]" type="hidden" value="1" />
 
288
                <?php
 
289
        }
 
290
 
 
291
        echo '</li>';
 
292
        // no text after </li> or JS will bite you! (This is where additional blocks get inserted)
 
293
}
 
294
?>
 
295
</ul>
 
296
 
 
297
<p class="uploadfileinputs"><a href="#" onclick="addAnotherFileInput(); return false;" class="small"><?php echo T_('Add another file'); ?></a></p>
 
298
 
 
299
<div class="upload_foot">
 
300
<input type="submit" value="<?php echo format_to_output( T_('Upload to server now'), 'formvalue' ); ?>" class="ActionButton" >
 
301
<input type="reset" value="<?php echo format_to_output( T_('Reset'), 'formvalue' ); ?>" class="ResetButton">
 
302
<p class="note">
 
303
<?php
 
304
$restrictNotes = array();
 
305
// Get list of recognized file types (others are not allowed to get uploaded)
 
306
// dh> because FiletypeCache/DataObjectCache has no interface for getting a list,
 
307
// this dirty query seems less dirty to me.
 
308
$allowed_extensions = $DB->get_col( 'SELECT ftyp_extensions FROM T_filetypes WHERE ftyp_allowed != 0' );
 
309
// implode with space, ftyp_extensions can hold many, separated by space
 
310
$allowed_extensions = implode( ' ', $allowed_extensions );
 
311
// into array
 
312
$allowed_extensions = preg_split( '~\s+~', $allowed_extensions, -1, PREG_SPLIT_NO_EMPTY );
 
313
// readable
 
314
$allowed_extensions = implode_with_and( $allowed_extensions );
 
315
 
 
316
$restrictNotes[] = '<strong>'.T_('Allowed file extensions').'</strong>: '.$allowed_extensions;
 
317
 
 
318
if( $Settings->get( 'upload_maxkb' ) )
 
319
{
 
320
        // We want to restrict on file size
 
321
        $restrictNotes[] = '<strong>'.T_('Maximum allowed file size').'</strong>: '.bytesreadable( $Settings->get( 'upload_maxkb' )*1024 );
 
322
}
 
323
echo implode( '<br />', $restrictNotes ).'<br />';
 
324
?>
 
325
</p>
 
326
</div>
 
327
</td></tr></tbody></table>
 
328
 
 
329
<?php
 
330
$Widget->disp_template_raw( 'block_end' );
 
331
$Form->end_form();
 
332
// End payload block
 
333
$this->disp_payload_end();
393
334
 
394
335
?>