ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilObjFileListGUI.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2011 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
5 include_once "Services/Object/classes/class.ilObjectListGUI.php";
6 
16 {
21  function ilObjFileListGUI()
22  {
23  $this->ilObjectListGUI();
24  }
25 
29  function init()
30  {
31  $this->delete_enabled = true;
32  $this->cut_enabled = true;
33  $this->copy_enabled = true;
34  $this->subscribe_enabled = true;
35  $this->link_enabled = true;
36  $this->payment_enabled = true;
37  $this->info_screen_enabled = true;
38  $this->type = "file";
39  $this->gui_class_name = "ilobjfilegui";
40 
41  // general commands array
42  include_once('./Modules/File/classes/class.ilObjFileAccess.php');
43  $this->commands = ilObjFileAccess::_getCommands();
44  }
45 
53  function getCommandFrame($a_cmd)
54  {
55  if(IS_PAYMENT_ENABLED)
56  {
57  include_once 'Services/Payment/classes/class.ilPaymentObject.php';
58  if(ilPaymentObject::_isBuyable($this->ref_id) &&
59  !ilPaymentObject::_hasAccess($this->ref_id))
60  {
61  return '';
62  }
63  }
64  $frame = "";
65  switch($a_cmd)
66  {
67  // BEGIN WebDAV: View inline objects in a blank window
68  case 'sendfile' :
69  require_once('Modules/File/classes/class.ilObjFileAccess.php');
70  if (ilObjFileAccess::_isFileInline($this->title))
71  {
72  $frame = '_blank';
73  }
74  break;
75  // END WebDAV View inline objects in a blank window
76 
77  case "":
78  $frame = ilFrameTargetInfo::_getFrame("RepositoryContent");
79  break;
80 
81  default:
82  }
83 
84  return $frame;
85  }
86 
87  // BEGIN WebDAV: getIconImageType.
95  function getIconImageType()
96  {
97  include_once('Modules/File/classes/class.ilObjFileAccess.php');
98 
99  return ilObjFileAccess::_isFileInline($this->title) ? $this->type.'_inline' : $this->type;
100  }
101  // END WebDAV: getIconImageType.
102 
103  // BEGIN WebDAV: Suppress filename extension from title.
109  function getTitle()
110  {
111  // Remove filename extension from title
112  return preg_replace('/\\.[a-z0-9]+\\z/i','', $this->title);
113  }
114  // END WebDAV: Suppress filename extension from title.
115 
116 
125  function getProperties()
126  {
127  global $lng, $ilUser;
128 
129  // BEGIN WebDAV: Get parent properties
130  $props = parent::getProperties();
131  // END WebDAV: Get parent properties
132 
133  // to do: implement extra smaller file info object
134  include_once("./Modules/File/classes/class.ilObjFileAccess.php");
135 
136  // Display a warning if a file is not a hidden Unix file, and
137  // the filename extension is missing
138  if (! preg_match('/^\\.|\\.[a-zA-Z0-9]+$/', $this->title))
139  {
140  $props[] = array("alert" => false, "property" => $lng->txt("filename_interoperability"),
141  "value" => $lng->txt("filename_extension_missing"),
142  'propertyNameVisible' => false);
143  }
144 
145  // BEGIN WebDAV: Only display relevant information.
146  $props[] = array("alert" => false, "property" => $lng->txt("type"),
147  "value" => ilObjFileAccess::_getFileExtension($this->title),
148  'propertyNameVisible' => false
149  );
150 
151  $fileData = ilObjFileAccess::_lookupFileData($this->obj_id);
152  $props[] = array("alert" => false, "property" => $lng->txt("size"),
153  "value" => ilFormat::formatSize($fileData['file_size'], 'short'),
154  'propertyNameVisible' => false);
155  $version = $fileData['version'];
156  if ($version > 1)
157  {
158  $props[] = array("alert" => false, "property" => $lng->txt("version"),
159  "value" => $version);
160  }
161  $props[] = array("alert" => false, "property" => $lng->txt("last_update"),
162  "value" => ilObject::_lookupLastUpdate($this->obj_id, true),
163  'propertyNameVisible' => false);
164  // END WebDAV: Only display relevant information.
165 
166  return $props;
167  }
168 
176  /*
177  function getCommandLink($a_cmd)
178  {
179  // separate method for this line
180  $cmd_link = "repo.php?ref_id=".$this->ref_id."&cmd=$a_cmd";
181 
182  return $cmd_link;
183  }*/
184 
188  function getCommandImage($a_cmd)
189  {
190  switch ($a_cmd)
191  {
192  case "versions":
193  return ilUtil::getImagePath("cmd_versions_s.png");
194 
195  default:
196  return "";
197  }
198  }
199 
200 
201 
202 } // END class.ilObjFileListGUI
203 ?>