ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 
15 {
16 
20  public function init()
21  {
22  $this->delete_enabled = true;
23  $this->cut_enabled = true;
24  $this->copy_enabled = true;
25  $this->subscribe_enabled = true;
26  $this->link_enabled = true;
27  $this->info_screen_enabled = true;
28  $this->type = "file";
29  $this->gui_class_name = "ilobjfilegui";
30 
31  // general commands array
32  include_once('./Modules/File/classes/class.ilObjFileAccess.php');
33  $this->commands = ilObjFileAccess::_getCommands();
34  }
35 
36 
44  public function getCommandFrame($a_cmd)
45  {
46  $frame = "";
47  switch ($a_cmd) {
48  case 'sendfile':
49  require_once('Modules/File/classes/class.ilObjFileAccess.php');
50  if (ilObjFileAccess::_isFileInline($this->title)) {
51  $frame = '_blank';
52  }
53  break;
54  case "":
55  $frame = ilFrameTargetInfo::_getFrame("RepositoryContent");
56  break;
57 
58  default:
59  }
60 
61  return $frame;
62  }
63 
64 
72  public function getIconImageType()
73  {
74  include_once('Modules/File/classes/class.ilObjFileAccess.php');
75 
76  return ilObjFileAccess::_isFileInline($this->title) ? $this->type . '_inline' : $this->type;
77  }
78 
79 
85  public function getTitle()
86  {
87  // Remove filename extension from title
88  return preg_replace('/\\.[a-z0-9]+\\z/i', '', $this->title);
89  }
90 
91 
100  public function getProperties()
101  {
102  global $DIC;
103 
104  $props = parent::getProperties();
105 
106  // to do: implement extra smaller file info object
107 
108  // Display a warning if a file is not a hidden Unix file, and
109  // the filename extension is missing
110  if (!preg_match('/^\\.|\\.[a-zA-Z0-9]+$/', $this->title)) {
111  $props[] = array(
112  "alert" => false,
113  "property" => $DIC->language()->txt("filename_interoperability"),
114  "value" => $DIC->language()->txt("filename_extension_missing"),
115  'propertyNameVisible' => false,
116  );
117  }
118 
119  $props[] = array(
120  "alert" => false,
121  "property" => $DIC->language()->txt("type"),
122  "value" => ilObjFileAccess::_getFileExtension($this->title),
123  'propertyNameVisible' => false,
124  );
125 
126  $fileData = ilObjFileAccess::getListGUIData($this->obj_id);
127  if (is_array($fileData)) {
128  $props[] = array(
129  "alert" => false,
130  "property" => $DIC->language()->txt("size"),
131  "value" => ilUtil::formatSize($fileData['size'], 'short'),
132  'propertyNameVisible' => false,
133  );
134  $version = $fileData['version'];
135  if ($version > 1) {
136  // add versions link
137  if (parent::checkCommandAccess("write", "versions", $this->ref_id, $this->type)) {
138  $link = $this->getCommandLink("versions");
139  $value = "<a href=\"$link\">" . $DIC->language()->txt("version") . ": $version</a>";
140  } else {
141  $value = $DIC->language()->txt("version") . ": $version";
142  }
143  $props[] = array(
144  "alert" => false,
145  "property" => $DIC->language()->txt("version"),
146  "value" => $value,
147  "propertyNameVisible" => false,
148  );
149  }
150 
151  // #6040
152  if ($fileData["date"]) {
153  $props[] = array(
154  "alert" => false,
155  "property" => $DIC->language()->txt("last_update"),
156  "value" => ilDatePresentation::formatDate(new ilDateTime($fileData["date"], IL_CAL_DATETIME)),
157  'propertyNameVisible' => false,
158  );
159  }
160 
161  if ($fileData["page_count"]) {
162  $props[] = array(
163  "alert" => false,
164  "property" => $DIC->language()->txt("page_count"),
165  "value" => $fileData["page_count"],
166  'propertyNameVisible' => true,
167  );
168  }
169  }
170 
171  return $props;
172  }
173 
174 
178  public function getCommandImage($a_cmd)
179  {
180  switch ($a_cmd) {
181  default:
182  return "";
183  }
184  }
185 
186 
194  public function getCommandLink($a_cmd)
195  {
196  // overwritten to always return the permanent download link
197 
198  // only create permalink for repository
199  if ($a_cmd == "sendfile" && $this->context == self::CONTEXT_REPOSITORY) {
200  // return the perma link for downloads
201  return ilObjFileAccess::_getPermanentDownloadLink($this->ref_id);
202  }
203 
204  return parent::getCommandLink($a_cmd);
205  }
206 } // END class.ilObjFileListGUI
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.
global $DIC
Definition: saml.php:7
static _getFileExtension($a_file_name)
Gets the file extension of the specified file name.
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false)
Format a date public.
static _getCommands()
get commands
getCommandFrame($a_cmd)
Get command target frame.
Class ilObjectListGUI.
Date and time handling
Create styles array
The data for the language used.
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.
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 icon image.