made a copy
[atutor.git] / tools / filemanager / index.php
1 <?php
2 /****************************************************************/
3 /* ATutor                                                                                                               */
4 /****************************************************************/
5 /* Copyright (c) 2002-2008 by Greg Gay & Joel Kronenberg        */
6 /* Adaptive Technology Resource Centre / University of Toronto  */
7 /* http://atutor.ca                                                                                             */
8 /*                                                              */
9 /* This program is free software. You can redistribute it and/or*/
10 /* modify it under the terms of the GNU General Public License  */
11 /* as published by the Free Software Foundation.                                */
12 /****************************************************************/
13 // $Id$
14
15 define('AT_INCLUDE_PATH', '../../include/');
16 require(AT_INCLUDE_PATH.'vitals.inc.php');
17 require(AT_INCLUDE_PATH.'lib/filemanager.inc.php');
18
19 if ((isset($_REQUEST['popup']) && $_REQUEST['popup']) && 
20         (!isset($_REQUEST['framed']) || !$_REQUEST['framed'])) {
21         $popup = TRUE;
22         $framed = FALSE;
23 } else if (isset($_REQUEST['framed']) && $_REQUEST['framed'] && isset($_REQUEST['popup']) && $_REQUEST['popup']) {
24         $popup = TRUE;
25         $framed = TRUE;
26 } else {
27         $popup = FALSE;
28         $framed = FALSE;
29 }
30
31 // If Flash is detected, call the necessary css and js, and configure settings to use the Fluid Uploader
32 if (isset($_SESSION['flash']) && $_SESSION['flash'] == "yes") {
33     /* Provide the option of switching between Fluid Uploader and simple single file uploader
34        and save the user preference as a cookie */
35     if (!isset($_COOKIE["fluid_on"]))
36         setcookie("fluid_on", "yes", time()+1200); 
37
38     $fluid_dir = 'jscripts/infusion/';
39     $framed = intval($_GET['framed']);
40     $popup = intval($_GET['popup']);
41     $current_path = AT_CONTENT_DIR.$_SESSION['course_id'].'/';
42
43     if ($_GET['pathext'] != '') {
44         $pathext = urldecode($_GET['pathext']);
45     } else if ($_POST['pathext'] != '') {
46         $pathext = $_POST['pathext'];
47     }
48
49     if($_GET['back'] == 1) {
50         $pathext  = substr($pathext, 0, -1);
51         $slashpos = strrpos($pathext, '/');
52         if($slashpos == 0) {
53             $pathext = '';
54         } else {
55             $pathext = substr($pathext, 0, ($slashpos+1));
56         }
57
58     }
59
60     $_custom_head .= '
61         <link href="'.$fluid_dir.'components/uploader/css/Uploader.css" rel="stylesheet" type="text/css" />
62         <script src="'.$fluid_dir.'InfusionAll.js" type="text/javascript"></script>
63         <script language="JavaScript" type="text/javascript">
64
65             var myUpload; // mostly used for testing
66
67             jQuery(document).ready(function () {
68                     myUpload = fluid.progressiveEnhanceableUploader(".flc-uploader", ".fl-ProgEnhance-basic", {
69                         uploadManager: {
70                                     type: "fluid.swfUploadManager",
71                 
72                                     options: {
73                                        // Set the uploadURL to the URL for posting files to your server.
74                                        uploadURL: "'.$_base_href.'include/lib/upload.php?path='.urlencode($current_path.$pathext).'",
75                 
76                                        // This option points to the location of the SWFUpload Flash object that ships with Fluid Infusion.
77                                        flashURL: "jscripts/infusion/lib/swfupload/flash/swfupload.swf"
78                                         }
79                                 },
80                 
81                         listeners: {
82                         onFileSuccess: function (file, serverData){
83                                 // example assumes that the server code passes the new image URL in the serverData
84                                 window.location="'.$_SERVER['PHP_SELF'].'?pathext=' . urlencode($pathext) . SEP . 'popup=' . $popup . SEP . 'framed=' . $framed . SEP . 'msg=FILEUPLOAD_DONE";
85                         }
86                     },
87                 
88                  decorators: [{
89                     type: "fluid.swfUploadSetupDecorator",
90                     options: {
91                          // This option points to the location of the Browse Files button used with Flash 10 clients.
92                          flashButtonImageURL: "'.AT_BASE_HREF.'jscripts/infusion/components/uploader/images/browse.png"
93                                         }
94                  }]
95                      });
96                 });
97         </script>
98     ';
99 }
100
101 global $msg;
102 if (isset($_GET['msg']))
103         $msg -> addFeedback($_GET['msg']);
104
105 require('top.php');
106 $_SESSION['done'] = 1;
107
108 require(AT_INCLUDE_PATH.'html/filemanager_display.inc.php');
109
110 closedir($dir);
111
112 ?>
113 <script type="text/javascript">
114 //<!--
115 function Checkall(form){ 
116   for (var i = 0; i < form.elements.length; i++){    
117     eval("form.elements[" + i + "].checked = form.checkall.checked");  
118   } 
119 }
120 function openWindow(page) {
121         newWindow = window.open(page, "progWin", "width=400,height=200,toolbar=no,location=no");
122         newWindow.focus();
123 }
124 //-->
125 </script>
126 <?php require(AT_INCLUDE_PATH.'footer.inc.php'); ?>