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