ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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
17{
21 function init()
22 {
23 $this->delete_enabled = true;
24 $this->cut_enabled = true;
25 $this->copy_enabled = true;
26 $this->subscribe_enabled = true;
27 $this->link_enabled = true;
28 $this->info_screen_enabled = true;
29 $this->type = "file";
30 $this->gui_class_name = "ilobjfilegui";
31
32 // general commands array
33 include_once('./Modules/File/classes/class.ilObjFileAccess.php');
34 $this->commands = ilObjFileAccess::_getCommands();
35 }
36
44 function getCommandFrame($a_cmd)
45 {
46 $frame = "";
47 switch($a_cmd)
48 {
49 // BEGIN WebDAV: View inline objects in a blank window
50 case 'sendfile' :
51 require_once('Modules/File/classes/class.ilObjFileAccess.php');
52 if (ilObjFileAccess::_isFileInline($this->title))
53 {
54 $frame = '_blank';
55 }
56 break;
57 // END WebDAV View inline objects in a blank window
58
59 case "":
60 $frame = ilFrameTargetInfo::_getFrame("RepositoryContent");
61 break;
62
63 default:
64 }
65
66 return $frame;
67 }
68
69 // BEGIN WebDAV: getIconImageType.
77 function getIconImageType()
78 {
79 include_once('Modules/File/classes/class.ilObjFileAccess.php');
80
81 return ilObjFileAccess::_isFileInline($this->title) ? $this->type.'_inline' : $this->type;
82 }
83 // END WebDAV: getIconImageType.
84
85 // BEGIN WebDAV: Suppress filename extension from title.
91 function getTitle()
92 {
93 // Remove filename extension from title
94 return preg_replace('/\\.[a-z0-9]+\\z/i','', $this->title);
95 }
96 // END WebDAV: Suppress filename extension from title.
97
98
107 function getProperties()
108 {
109 global $lng, $ilUser;
110
111 // BEGIN WebDAV: Get parent properties
112 $props = parent::getProperties();
113 // END WebDAV: Get parent properties
114
115 // to do: implement extra smaller file info object
116 include_once("./Modules/File/classes/class.ilObjFileAccess.php");
117
118 // Display a warning if a file is not a hidden Unix file, and
119 // the filename extension is missing
120 if (! preg_match('/^\\.|\\.[a-zA-Z0-9]+$/', $this->title))
121 {
122 $props[] = array("alert" => false, "property" => $lng->txt("filename_interoperability"),
123 "value" => $lng->txt("filename_extension_missing"),
124 'propertyNameVisible' => false);
125 }
126
127 // BEGIN WebDAV: Only display relevant information.
128 $props[] = array("alert" => false, "property" => $lng->txt("type"),
129 "value" => ilObjFileAccess::_getFileExtension($this->title),
130 'propertyNameVisible' => false
131 );
132
133 $fileData = ilObjFileAccess::getListGUIData($this->obj_id);
134 if(is_array($fileData))
135 {
136 $props[] = array("alert" => false, "property" => $lng->txt("size"),
137 "value" => ilUtil::formatSize($fileData['size'], 'short'),
138 'propertyNameVisible' => false);
139 $version = $fileData['version'];
140 if ($version > 1)
141 {
142 // add versions link
143 if (parent::checkCommandAccess("write", "versions", $this->ref_id, $this->type))
144 {
145 $link = $this->getCommandLink("versions");
146 $value = "<a href=\"$link\">".$lng->txt("version").": $version</a>";
147 }
148 else
149 {
150 $value = $lng->txt("version").": $version";
151 }
152 $props[] = array("alert" => false, "property" => $lng->txt("version"),
153 "value" => $value,
154 "propertyNameVisible" => false);
155 }
156
157 // #6040
158 if($fileData["date"])
159 {
160 $props[] = array("alert" => false, "property" => $lng->txt("last_update"),
161 "value" => ilDatePresentation::formatDate(new ilDateTime($fileData["date"],IL_CAL_DATETIME)),
162 'propertyNameVisible' => false);
163 }
164 }
165 // END WebDAV: Only display relevant information.
166
167 return $props;
168 }
169
177 /*
178 function getCommandLink($a_cmd)
179 {
180 // separate method for this line
181 $cmd_link = "repo.php?ref_id=".$this->ref_id."&cmd=$a_cmd";
182
183 return $cmd_link;
184 }*/
185
189 function getCommandImage($a_cmd)
190 {
191 switch ($a_cmd)
192 {
193 default:
194 return "";
195 }
196 }
197
204 function getCommandLink($a_cmd)
205 {
206 // overwritten to always return the permanent download link
207
208 // only create permalink for repository
209 if ($a_cmd == "sendfile" && $this->context == self::CONTEXT_REPOSITORY)
210 {
211 // return the perma link for downloads
212 return ilObjFileAccess::_getPermanentDownloadLink($this->ref_id);
213 }
214
215 return parent::getCommandLink($a_cmd);
216 }
217
218} // END class.ilObjFileListGUI
219?>
An exception for terminatinating execution or to throw for unit testing.
const IL_CAL_DATETIME
static formatDate(ilDateTime $date)
Format a date @access public.
@classDescription Date and time handling
static _getFrame($a_class, $a_type='')
Get content frame name.
static _getCommands()
get commands
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 link url.
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 $lng
Definition: privfeed.php:17
$ilUser
Definition: imgupload.php:18