ILIAS  release_7 Revision v7.30-3-g800a261c036
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
5include_once "Services/Object/classes/class.ilObjectListGUI.php";
6
15{
17
18 protected $title = '';
19
23 public function init()
24 {
25 $this->delete_enabled = true;
26 $this->cut_enabled = true;
27 $this->copy_enabled = true;
28 $this->subscribe_enabled = true;
29 $this->link_enabled = true;
30 $this->info_screen_enabled = true;
31 $this->type = "file";
32 $this->gui_class_name = "ilobjfilegui";
33
34 // general commands array
35 $this->commands = ilObjFileAccess::_getCommands();
36 }
37
38
46 public function getCommandFrame($a_cmd)
47 {
48 $frame = "";
49 switch ($a_cmd) {
50 case 'sendfile':
51 if (ilObjFileAccess::_isFileInline($this->title)) {
52 $frame = '_blank';
53 }
54 break;
55 case "":
56 $frame = ilFrameTargetInfo::_getFrame("RepositoryContent");
57 break;
58
59 default:
60 }
61
62 return $frame;
63 }
64
65
73 public function getIconImageType()
74 {
75 return ilObjFileAccess::_isFileInline($this->title) ? $this->type . '_inline' : $this->type;
76 }
77
78
84 public function getTitle()
85 {
86 // Remove filename extension from title
87 $string = preg_replace('/\\.[a-z0-9]+\\z/i', '', $this->title);
88 return $this->secure(is_string($string) ? $string : '');
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 $file_data = ilObjFileAccess::getListGUIData($this->obj_id);
127 if (is_array($file_data)) {
128
129 if(empty($file_data['rid']) && parent::checkCommandAccess("write", "versions", $this->ref_id, $this->type)) {
130 $props[] = array(
131 "alert" => true,
132 "property" => $DIC->language()->txt("migrated"),
133 "value" => $DIC->language()->txt("not_yet_migrated"),
134 "propertyNameVisible" => false,
135 "newline"=>true
136 );
137 }
138
139
140 $props[] = array(
141 "alert" => false,
142 "property" => $DIC->language()->txt("size"),
143 "value" => ilUtil::formatSize($file_data['size'], 'short'),
144 'propertyNameVisible' => false,
145 );
146 $version = $file_data['version'];
147 if ($version > 1) {
148 // add versions link
149 if (parent::checkCommandAccess("write", "versions", $this->ref_id, $this->type)) {
150 $link = $this->getCommandLink("versions");
151 $value = "<a href=\"$link\">" . $DIC->language()->txt("version") . ": $version</a>";
152 } else {
153 $value = $DIC->language()->txt("version") . ": $version";
154 }
155 $props[] = array(
156 "alert" => false,
157 "property" => $DIC->language()->txt("version"),
158 "value" => $value,
159 "propertyNameVisible" => false,
160 );
161 }
162
163
164 // #6040
165 if ($file_data["date"]) {
166 $props[] = array(
167 "alert" => false,
168 "property" => $DIC->language()->txt("last_update"),
169 "value" => ilDatePresentation::formatDate(new ilDateTime($file_data["date"], IL_CAL_DATETIME)),
170 'propertyNameVisible' => false,
171 );
172 }
173
174 if ($file_data["page_count"]) {
175 $props[] = array(
176 "alert" => false,
177 "property" => $DIC->language()->txt("page_count"),
178 "value" => $file_data["page_count"],
179 'propertyNameVisible' => true,
180 );
181 }
182 }
183
184 return $props;
185 }
186
187
191 public function getCommandImage($a_cmd)
192 {
193 switch ($a_cmd) {
194 default:
195 return "";
196 }
197 }
198
199
207 public function getCommandLink($a_cmd)
208 {
209 // overwritten to always return the permanent download link
210
211 // only create permalink for repository
212 if ($a_cmd == "sendfile" && $this->context == self::CONTEXT_REPOSITORY) {
213 // return the perma link for downloads
214 return ilObjFileAccess::_getPermanentDownloadLink($this->ref_id);
215 }
216
217 return parent::getCommandLink($a_cmd);
218 }
219} // END class.ilObjFileListGUI
An exception for terminatinating execution or to throw for unit testing.
const IL_CAL_DATETIME
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false, $include_seconds=false)
Format a date @access public.
@classDescription Date and time handling
static _getFrame($a_class, $a_type='')
Get content frame name.
static _getCommands()
get commands this method returns an array of all possible commands/permission combinations example: $...
static _getFileExtension($a_file_name)
Gets the file extension of the specified file name.
static _isFileInline($a_file_name)
Returns true, if the specified file shall be displayed inline in the browser.
static _getPermanentDownloadLink($ref_id)
Gets the permanent download link for the file.
static getListGUIData($a_obj_id)
Class ilObjFileListGUI.
getProperties()
Get item properties.
getTitle()
getTitle overwritten in class.ilObjLinkResourceList.php
getCommandImage($a_cmd)
Get command icon image.
getCommandLink($a_cmd)
Get command link url.
getIconImageType()
Returns the icon image type.
getCommandFrame($a_cmd)
Get command target frame.
Class ilObjectListGUI.
static formatSize($size, $a_mode='short', $a_lng=null)
Returns the specified file size value in a human friendly form.
global $DIC
Definition: goto.php:24
trait ilObjFileSecureString
Trait ilObjFileSecureString.