SVN tag for release should only contain scripts in "docs" folder without "mods",...
[atutor.git] / docs / mods / _core / file_manager / index.php
1 <?php
2 /****************************************************************/
3 /* ATutor                                                                                                               */
4 /****************************************************************/
5 /* Copyright (c) 2002-2010                                      */
6 /* Inclusive Design Institute                                   */
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_once(AT_INCLUDE_PATH.'../mods/_core/file_manager/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         ATutor.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 language="JavaScript" type="text/javascript">
63
64             var myUpload; // mostly used for testing
65
66             jQuery(document).ready(function () {
67                     myUpload = fluid.progressiveEnhanceableUploader(".flc-uploader", ".fl-ProgEnhance-basic", {
68                         uploadManager: {
69                                     type: "fluid.swfUploadManager",
70                 
71                                     options: {
72                                        // Set the uploadURL to the URL for posting files to your server.
73                                        uploadURL: "'.$_base_href.'include/lib/upload.php?path='.urlencode($current_path.$pathext).'",
74                 
75                                        // This option points to the location of the SWFUpload Flash object that ships with Fluid Infusion.
76                                        flashURL: "jscripts/infusion/lib/swfupload/flash/swfupload.swf"
77                                         }
78                                 },
79                 
80                         listeners: {
81                         onFileSuccess: function (file, serverData){
82                                 // example assumes that the server code passes the new image URL in the serverData
83                                 window.location="'.$_SERVER['PHP_SELF'].'?pathext=' . urlencode($pathext) . SEP . 'popup=' . $popup . SEP . 'framed=' . $framed . SEP . 'msg=FILEUPLOAD_DONE";
84                         }
85                     },
86                 
87                  decorators: [{
88                     type: "fluid.swfUploadSetupDecorator",
89                     options: {
90                          // This option points to the location of the Browse Files button used with Flash 10 clients.
91                          flashButtonImageURL: "'.AT_BASE_HREF.'jscripts/infusion/components/uploader/images/browse.png"
92                                         }
93                  }]
94                      });
95                 });
96         </script>
97     ';
98 }
99
100 global $msg;
101 if (isset($_GET['msg']))
102         $msg -> addFeedback($_GET['msg']);
103
104 require('top.php');
105 $_SESSION['done'] = 1;
106
107 require(AT_INCLUDE_PATH.'../mods/_core/file_manager/filemanager_display.inc.php');
108
109 closedir($dir);
110
111 ?>
112 <script type="text/javascript">
113 //<!--
114 function Checkall(form){ 
115   for (var i = 0; i < form.elements.length; i++){    
116     eval("form.elements[" + i + "].checked = form.checkall.checked");  
117   } 
118 }
119 function openWindow(page) {
120         newWindow = window.open(page, "progWin", "width=400,height=200,toolbar=no,location=no");
121         newWindow.focus();
122 }
123 //-->
124 </script>
125 <?php require(AT_INCLUDE_PATH.'footer.inc.php'); ?>