ILIAS  release_4-4 Revision
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 
17 {
22  function ilObjFileListGUI()
23  {
24  $this->ilObjectListGUI();
25  }
26 
30  function init()
31  {
32  $this->delete_enabled = true;
33  $this->cut_enabled = true;
34  $this->copy_enabled = true;
35  $this->subscribe_enabled = true;
36  $this->link_enabled = true;
37  $this->payment_enabled = true;
38  $this->info_screen_enabled = true;
39  $this->type = "file";
40  $this->gui_class_name = "ilobjfilegui";
41 
42  // general commands array
43  include_once('./Modules/File/classes/class.ilObjFileAccess.php');
44  $this->commands = ilObjFileAccess::_getCommands();
45  }
46 
54  function getCommandFrame($a_cmd)
55  {
56  if(IS_PAYMENT_ENABLED)
57  {
58  include_once 'Services/Payment/classes/class.ilPaymentObject.php';
59  if(ilPaymentObject::_isBuyable($this->ref_id) &&
60  !ilPaymentObject::_hasAccess($this->ref_id))
61  {
62  return '';
63  }
64  }
65  $frame = "";
66  switch($a_cmd)
67  {
68  // BEGIN WebDAV: View inline objects in a blank window
69  case 'sendfile' :
70  require_once('Modules/File/classes/class.ilObjFileAccess.php');
71  if (ilObjFileAccess::_isFileInline($this->title))
72  {
73  $frame = '_blank';
74  }
75  break;
76  // END WebDAV View inline objects in a blank window
77 
78  case "":
79  $frame = ilFrameTargetInfo::_getFrame("RepositoryContent");
80  break;
81 
82  default:
83  }
84 
85  return $frame;
86  }
87 
88  // BEGIN WebDAV: getIconImageType.
96  function getIconImageType()
97  {
98  include_once('Modules/File/classes/class.ilObjFileAccess.php');
99 
100  return ilObjFileAccess::_isFileInline($this->title) ? $this->type.'_inline' : $this->type;
101  }
102  // END WebDAV: getIconImageType.
103 
104  // BEGIN WebDAV: Suppress filename extension from title.
110  function getTitle()
111  {
112  // Remove filename extension from title
113  return preg_replace('/\\.[a-z0-9]+\\z/i','', $this->title);
114  }
115  // END WebDAV: Suppress filename extension from title.
116 
117 
126  function getProperties()
127  {
128  global $lng, $ilUser;
129 
130  // BEGIN WebDAV: Get parent properties
131  $props = parent::getProperties();
132  // END WebDAV: Get parent properties
133 
134  // to do: implement extra smaller file info object
135  include_once("./Modules/File/classes/class.ilObjFileAccess.php");
136 
137  // Display a warning if a file is not a hidden Unix file, and
138  // the filename extension is missing
139  if (! preg_match('/^\\.|\\.[a-zA-Z0-9]+$/', $this->title))
140  {
141  $props[] = array("alert" => false, "property" => $lng->txt("filename_interoperability"),
142  "value" => $lng->txt("filename_extension_missing"),
143  'propertyNameVisible' => false);
144  }
145 
146  // BEGIN WebDAV: Only display relevant information.
147  $props[] = array("alert" => false, "property" => $lng->txt("type"),
148  "value" => ilObjFileAccess::_getFileExtension($this->title),
149  'propertyNameVisible' => false
150  );
151 
152  $fileData = ilObjFileAccess::getListGUIData($this->obj_id);
153  if(is_array($fileData))
154  {
155  $props[] = array("alert" => false, "property" => $lng->txt("size"),
156  "value" => ilFormat::formatSize($fileData['size'], 'short'),
157  'propertyNameVisible' => false);
158  $version = $fileData['version'];
159  if ($version > 1)
160  {
161  // add versions link
162  if (parent::checkCommandAccess("write", "versions", $this->ref_id, $this->type))
163  {
164  $link = $this->getCommandLink("versions");
165  $value = "<a href=\"$link\">".$lng->txt("version").": $version</a>";
166  }
167  else
168  {
169  $value = $lng->txt("version").": $version";
170  }
171  $props[] = array("alert" => false, "property" => $lng->txt("version"),
172  "value" => $value,
173  "propertyNameVisible" => false);
174  }
175 
176  // #6040
177  if($fileData["date"])
178  {
179  $props[] = array("alert" => false, "property" => $lng->txt("last_update"),
180  "value" => ilDatePresentation::formatDate(new ilDateTime($fileData["date"],IL_CAL_DATETIME)),
181  'propertyNameVisible' => false);
182  }
183  }
184  // END WebDAV: Only display relevant information.
185 
186  return $props;
187  }
188 
196  /*
197  function getCommandLink($a_cmd)
198  {
199  // separate method for this line
200  $cmd_link = "repo.php?ref_id=".$this->ref_id."&cmd=$a_cmd";
201 
202  return $cmd_link;
203  }*/
204 
208  function getCommandImage($a_cmd)
209  {
210  switch ($a_cmd)
211  {
212  case "versions":
213  return ilUtil::getImagePath("cmd_versions_s.png");
214 
215  default:
216  return "";
217  }
218  }
219 
226  function getCommandLink($a_cmd)
227  {
228  // overwritten to always return the permanent download link
229 
230  // only create permalink for repository
231  if ($a_cmd == "sendfile" && $this->context == self::CONTEXT_REPOSITORY)
232  {
233  // return the perma link for downloads
234  return ilObjFileAccess::_getPermanentDownloadLink($this->ref_id);
235  }
236 
237  return parent::getCommandLink($a_cmd);
238  }
239 
240 } // END class.ilObjFileListGUI
241 ?>
_getCommands()
get commands
static _getPermanentDownloadLink($ref_id)
Gets the permanent download link for the file.
static _isFileInline($a_file_name)
Returns true, if the specified file shall be displayed inline in the browser.
const IL_CAL_DATETIME
getIconImageType()
Returns the icon image type.
ilObjectListGUI()
constructor
static _getFileExtension($a_file_name)
Gets the file extension of the specified file name.
ilObjFileListGUI()
constructor
static _isBuyable($a_ref_id, $a_subtype='')
getCommandFrame($a_cmd)
Get command target frame.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
Class ilObjectListGUI.
static formatDate(ilDateTime $date)
Format a date public.
Date and time handling
global $ilUser
Definition: imgupload.php:15
static _getFrame($a_class, $a_type='')
Get content frame name.
getProperties()
Get item properties.
static formatSize($size, $a_mode='short', $a_lng=null)
Returns the specified file size value in a human friendly form.
global $lng
Definition: privfeed.php:40
static _hasAccess($a_ref_id, $a_transaction=0, $a_subtype='')
getCommandLink($a_cmd)
Get command link url.
getTitle()
getTitle overwritten in class.ilObjLinkResourceList.php
Class ilObjFileListGUI.
static getListGUIData($a_obj_id)
getCommandImage($a_cmd)
Get command link url.