ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilFSStorageExc5242.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2006 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
24 
33 {
34  const FACTOR = 100;
35  const MAX_EXPONENT = 3;
36 
37  private $container_id;
38  private $path_conversion = false;
39 
40  protected $path;
41 
47  public function __construct($a_container_id = 0, $a_ass_id = 0)
48  {
49  $this->ass_id = $a_ass_id;
50 
51  $this->path_conversion = true;
52  $this->container_id = $a_container_id;
53 
54  // Get path info
55  $this->init();
56  }
57 
64  public static function _createPathFromId($a_container_id, $a_name)
65  {
66  $path = array();
67  $found = false;
68  $num = $a_container_id;
69  for ($i = self::MAX_EXPONENT; $i > 0;$i--) {
70  $factor = pow(self::FACTOR, $i);
71  if (($tmp = (int) ($num / $factor)) or $found) {
72  $path[] = $tmp;
73  $num = $num % $factor;
74  $found = true;
75  }
76  }
77 
78  if (count($path)) {
79  $path_string = (implode('/', $path) . '/');
80  }
81  return $path_string . $a_name . '_' . $a_container_id;
82  }
83 
89  protected function init()
90  {
91  $this->path = CLIENT_DATA_DIR;
92 
93  $this->path = ilUtil::removeTrailingPathSeparators($this->path);
94  $this->path .= '/';
95 
96  // Append path prefix
97  $this->path .= ($this->getPathPrefix() . '/');
98 
99  $this->path .= self::_createPathFromId($this->container_id, $this->getPathPostfix());
100 
101  $this->path.= "/ass_" . $this->ass_id;
102 
103  return true;
104  }
105 
112  protected function getPathPostfix()
113  {
114  return 'exc';
115  }
116 
123  protected function getPathPrefix()
124  {
125  return 'ilExercise';
126  }
130  public function getFiles()
131  {
132  $files = array();
133  if (!is_dir($this->path)) {
134  return $files;
135  }
136 
137  $dp = opendir($this->path);
138  while ($file = readdir($dp)) {
139  if (!is_dir($this->path . '/' . $file)) {
140  $files[] = array(
141  'name' => $file,
142  'size' => filesize($this->path . '/' . $file),
143  'ctime' => filectime($this->path . '/' . $file),
144  'fullpath' => $this->path . '/' . $file);
145  }
146  }
147  closedir($dp);
148  $files = ilUtil::sortArray($files, "name", "asc");
149  return $files;
150  }
151 }
$files
Definition: add-vimline.php:18
static sortArray( $array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray
__construct($a_container_id=0, $a_ass_id=0)
Constructor.
getFiles()
Get assignment files.
getPathPrefix()
Implementation of abstract method.
getPathPostfix()
Implementation of abstract method.
static _createPathFromId($a_container_id, $a_name)
Create a path from an id: e.g 12345 will be converted to 12/34/<name>_5.
static removeTrailingPathSeparators($path)
Create styles array
The data for the language used.
$i
Definition: disco.tpl.php:19
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file