ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilObjFileListGUI.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2005 ILIAS open source, University of Cologne |
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; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
24 include_once "Services/Object/classes/class.ilObjectListGUI.php";
25 
35 {
40  function ilObjFileListGUI()
41  {
42  $this->ilObjectListGUI();
43  }
44 
48  function init()
49  {
50  $this->delete_enabled = true;
51  $this->cut_enabled = true;
52  $this->copy_enabled = true;
53  $this->subscribe_enabled = true;
54  $this->link_enabled = true;
55  $this->payment_enabled = true;
56  $this->info_screen_enabled = true;
57  $this->type = "file";
58  $this->gui_class_name = "ilobjfilegui";
59 
60  // general commands array
61  include_once('./Modules/File/classes/class.ilObjFileAccess.php');
62  $this->commands = ilObjFileAccess::_getCommands();
63  }
64 
65 
74  function initItem($a_ref_id, $a_obj_id, $a_title = "", $a_description = "")
75  {
76  parent::initItem($a_ref_id, $a_obj_id, $a_title, $a_description);
77  }
78 
79 
87  function getCommandFrame($a_cmd)
88  {
89  if(IS_PAYMENT_ENABLED)
90  {
91  include_once 'Services/Payment/classes/class.ilPaymentObject.php';
92  if(ilPaymentObject::_isBuyable($this->ref_id) &&
93  !ilPaymentObject::_hasAccess($this->ref_id))
94  {
95  return '';
96  }
97  }
98  $frame = "";
99  switch($a_cmd)
100  {
101  // BEGIN WebDAV: View inline objects in a blank window
102  case 'sendfile' :
103  require_once('class.ilObjFileAccess.php');
104  if (ilObjFileAccess::_isFileInline($this->title))
105  {
106  $frame = '_blank';
107  }
108  break;
109  // END WebDAV View inline objects in a blank window
110 
111  case "":
112  $frame = ilFrameTargetInfo::_getFrame("RepositoryContent");
113  break;
114 
115  default:
116  }
117 
118  return $frame;
119  }
120 
121  // BEGIN WebDAV: getIconImageType.
129  function getIconImageType()
130  {
131  include_once('class.ilObjFileAccess.php');
132 
133  return ilObjFileAccess::_isFileInline($this->title) ? $this->type.'_inline' : $this->type;
134  }
135  // END WebDAV: getIconImageType.
136 
137  // BEGIN WebDAV: Suppress filename extension from title.
143  function getTitle()
144  {
145  // Remove filename extension from title
146  return preg_replace('/\\.[a-z0-9]+\\z/i','', $this->title);
147  }
148  // END WebDAV: Suppress filename extension from title.
149 
150 
159  function getProperties()
160  {
161  global $lng, $ilUser;
162 
163  // BEGIN WebDAV: Get parent properties
164  $props = parent::getProperties();
165  // END WebDAV: Get parent properties
166 
167  // to do: implement extra smaller file info object
168  include_once("./Modules/File/classes/class.ilObjFileAccess.php");
169 
170  // Display a warning if a file is not a hidden Unix file, and
171  // the filename extension is missing
172  if (! preg_match('/^\\.|\\.[a-zA-Z0-9]+$/', $this->title))
173  {
174  $props[] = array("alert" => false, "property" => $lng->txt("filename_interoperability"),
175  "value" => $lng->txt("filename_extension_missing"),
176  'propertyNameVisible' => false);
177  }
178 
179  // BEGIN WebDAV: Only display relevant information.
180  $props[] = array("alert" => false, "property" => $lng->txt("type"),
181  "value" => ilObjFileAccess::_getFileExtension($this->title),
182  'propertyNameVisible' => false
183  );
184 
185  $fileData = ilObjFileAccess::_lookupFileData($this->obj_id);
186  $props[] = array("alert" => false, "property" => $lng->txt("size"),
187  "value" => ilFormat::formatSize($fileData['file_size'], 'short'),
188  'propertyNameVisible' => false);
189  $version = $fileData['version'];
190  if ($version > 1)
191  {
192  $props[] = array("alert" => false, "property" => $lng->txt("version"),
193  "value" => $version);
194  }
195  $props[] = array("alert" => false, "property" => $lng->txt("last_update"),
196  "value" => ilObject::_lookupLastUpdate($this->obj_id, true),
197  'propertyNameVisible' => false);
198  // END WebDAV: Only display relevant information.
199 
200  return $props;
201  }
202 
210  /*
211  function getCommandLink($a_cmd)
212  {
213  // separate method for this line
214  $cmd_link = "repo.php?ref_id=".$this->ref_id."&cmd=$a_cmd";
215 
216  return $cmd_link;
217  }*/
218 
222  function getCommandImage($a_cmd)
223  {
224  switch ($a_cmd)
225  {
226  case "versions":
227  return ilUtil::getImagePath("cmd_versions_s.gif");
228 
229  default:
230  return "";
231  }
232  }
233 
234 
235 
236 } // END class.ilObjFileListGUI
237 ?>