source: branches/MootoolsFileManager-Update/plugins/MootoolsFileManager/mootools-filemanager/Demos/selectImage.php @ 1302

Last change on this file since 1302 was 1302, checked in by gogo, 8 years ago

Updates to http://www.github.com/sleemanj/mootools-filemanager from GerHoblett?

http://www.github.com/GerHoblett/

Changes to said updates by gogo (sleemanj @ github)

Modifications to MootoolsFileManager? to work with those updates, some courtesy of GerHoblett?, some sleemanj

GerHoblett? provided a large diff which accomplished the goal in a quite different way. It has merit, however I have opted for a less-affecting path in so far as Xinha's "way" is concerned, namely, not splitting the config for a single plugin into several calls to backend config passing functions which seemed a little cumbersome.

Instead I take the option of using POST to send backend data around, at the minor expense of an extra round trip when displaying thumbnails (for each one). This could be reduced by checking for thumbnail existence and returning the thumbnail name directly in "onView" rather than the backend request to generate said thumbnail.

Still to do, is to make the preview pane thumbnail also work.


File size: 2.5 KB
Line 
1<?php
2die(json_encode(array('status'=> 0, 'error' => "\nSecurity precaution... to enable the demo, edit\nDemos/".basename(__FILE__)."\nand comment out line 2.")));
3error_reporting(E_ALL | E_STRICT);
4
5define("FILEMANAGER_CODE", true);
6
7
8define('DEVELOPMENT', 0);   // set to 01 / 1 / nonzero value to enable logging of each incoming event request.
9
10
11require_once('FM-common.php');  // this one loads the appropriate FileManager AND the support functions used in this demo
12
13
14
15
16/*
17when you want to pass absolute paths into FileManager, be reminded that ALL paths
18(except for the [mimeTypesPath] one!) are paths in URI space, i.e. the 'root'
19is assumed to be DocumentRoot.
20
21Below is a quick example how a physical filesystem path /could/ be transformed
22to a URI path -- assumed you don't get buggered by having Aliases apply to this
23particular path, in which case you are between a rock and a hard place: then you
24MUST specify URI paths instead, this 'trick' being defective.
25*/
26
27$fm_basedir = str_replace(str_replace('\\', '/', $_SERVER['DOCUMENT_ROOT']), '', dirname(str_replace('\\', '/', __FILE__))) . '/';
28
29
30
31/*
32Go to FM-common.php to edit the Alias array there to mirror your local situation.
33
34See also the 'SITE_USES_ALIASES' define and the mkNewFileManager() function in there.
35
36mkNewFileManager() is just a wrapper used to keep the demo code lean...
37*/
38$browser = mkNewFileManager(array(
39        //'directory' => $fm_basedir . 'Files/',   // absolute paths: as the relative ones, they sit in URI space, i.e. assume DocumentRoot is root '/'
40
41        'directory' => 'Files/',                   // relative paths: are relative to the URI request script path, i.e. dirname(__FILE__) or rather: $_SERVER['SCRIPT_NAME']
42
43        'filter' => 'image/',
44        'upload' => true,
45        'destroy' => false,
46        'create' => true,
47        'move' => true,
48        'download' => false,
49        'allowExtChange' => false                 // allow file name extensions to be changed; the default however is: NO (FALSE)
50));
51
52
53
54$event_cmd = (!empty($_GET['event']) ? $_GET['event'] : null);
55
56// log request data:
57FM_vardumper($browser, 'init' . $event_cmd);
58
59
60
61// and process the request:
62$browser->fireEvent($event_cmd);
63
64
65
66
67
68
69
70// Do *NOT* add a <?php ?-> close tag here! Any whitespace after that makes PHP output both a Content-Type: test/html header AND the whitespace as content.
71// This BREAKS any operation (such as mootools-filemanager::event=thumbnail) which outputs BINARY DATA (in that particular case, PHP spits out an image)
72// The safest way to prevent ANY PHP file from producing undesirable [whitespace] output is to never add that ?-> close tag.
Note: See TracBrowser for help on using the repository browser.