ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilFileSystemStorage5069 Class Reference
+ Inheritance diagram for ilFileSystemStorage5069:
+ Collaboration diagram for ilFileSystemStorage5069:

Public Member Functions

 __construct ($a_storage_type, $a_path_conversion, $a_container_id)
 Constructor. More...
 
 getContainerId ()
 
 create ()
 Create directory. More...
 
 getAbsolutePath ()
 Get absolute path of storage directory. More...
 
 writeToFile ($a_data, $a_absolute_path)
 Write data to file. More...
 
 deleteFile ($a_abs_name)
 Delete file. More...
 
 deleteDirectory ($a_abs_name)
 Delete directory. More...
 
 delete ()
 Delete complete directory. More...
 
 copyFile ($a_from, $a_to)
 Copy files. More...
 
 appendToPath ($a_appendix)
 
 getStorageType ()
 
 getPath ()
 Get path. More...
 

Static Public Member Functions

static _createPathFromId ($a_container_id, $a_name)
 Create a path from an id: e.g 12345 will be converted to 12/34/<name>_5. More...
 
static _copyDirectory ($a_source, $a_target)
 Copy directory and all contents. More...
 

Data Fields

const STORAGE_WEB = 1
 
const STORAGE_DATA = 2
 
const STORAGE_SECURED = 3
 
const FACTOR = 100
 
const MAX_EXPONENT = 3
 
const SECURED_DIRECTORY = "sec"
 

Protected Member Functions

 getPathPrefix ()
 Get path prefix. More...
 
 getPathPostfix ()
 Get directory name. More...
 
 init ()
 Read path info. More...
 

Protected Attributes

 $path
 

Private Attributes

 $container_id
 
 $storage_type
 
 $path_conversion = false
 

Detailed Description

Definition at line 30 of file class.ilFileSystemStorage5069.php.

Constructor & Destructor Documentation

◆ __construct()

ilFileSystemStorage5069::__construct (   $a_storage_type,
  $a_path_conversion,
  $a_container_id 
)

Constructor.

public

Parameters
intstorage type
boolEn/Disable automatic path conversion. If enabled files with id 123 will be stored in directory files/1/file_123
intobject id of container (e.g file_id or mob_id)

Definition at line 55 of file class.ilFileSystemStorage5069.php.

References init().

56  {
57  $this->storage_type = $a_storage_type;
58  $this->path_conversion = $a_path_conversion;
59  $this->container_id = $a_container_id;
60 
61  // Get path info
62  $this->init();
63  }
+ Here is the call graph for this function:

Member Function Documentation

◆ _copyDirectory()

static ilFileSystemStorage5069::_copyDirectory (   $a_source,
  $a_target 
)
static

Copy directory and all contents.

Parameters
string$a_sourceabsolute source path
string$a_targetabsolute target path

Definition at line 273 of file class.ilFileSystemStorage5069.php.

References ilUtil\rCopy().

274  {
275  return ilUtil::rCopy($a_source, $a_target);
276  }
static rCopy($a_sdir, $a_tdir, $preserveTimeAttributes=false)
Copies content of a directory $a_sdir recursively to a directory $a_tdir.
+ Here is the call graph for this function:

◆ _createPathFromId()

static ilFileSystemStorage5069::_createPathFromId (   $a_container_id,
  $a_name 
)
static

Create a path from an id: e.g 12345 will be converted to 12/34/<name>_5.

public

Parameters
intcontainer id
stringname

Definition at line 79 of file class.ilFileSystemStorage5069.php.

References $i, $path, array, getPathPostfix(), and getPathPrefix().

80  {
81  $path = array();
82  $found = false;
83  $num = $a_container_id;
84  for ($i = self::MAX_EXPONENT; $i > 0;$i--) {
85  $factor = pow(self::FACTOR, $i);
86  if (($tmp = (int) ($num / $factor)) or $found) {
87  $path[] = $tmp;
88  $num = $num % $factor;
89  $found = true;
90  }
91  }
92 
93  if (count($path)) {
94  $path_string = (implode('/', $path) . '/');
95  }
96  return $path_string . $a_name . '_' . $a_container_id;
97  }
Create styles array
The data for the language used.
$i
Definition: disco.tpl.php:19
+ Here is the call graph for this function:

◆ appendToPath()

ilFileSystemStorage5069::appendToPath (   $a_appendix)

Definition at line 278 of file class.ilFileSystemStorage5069.php.

279  {
280  $this->path .= $a_appendix;
281  }

◆ copyFile()

ilFileSystemStorage5069::copyFile (   $a_from,
  $a_to 
)

Copy files.

public

Parameters
stringabsolute source
stringabsolute target

Definition at line 258 of file class.ilFileSystemStorage5069.php.

259  {
260  if (@file_exists($a_from)) {
261  @copy($a_from, $a_to);
262  return true;
263  }
264  return false;
265  }

◆ create()

ilFileSystemStorage5069::create ( )

Create directory.

public

Definition at line 128 of file class.ilFileSystemStorage5069.php.

References ilUtil\makeDirParents().

129  {
130  if (!file_exists($this->path)) {
131  ilUtil::makeDirParents($this->path);
132  }
133  return true;
134  }
static makeDirParents($a_dir)
Create a new directory and all parent directories.
+ Here is the call graph for this function:

◆ delete()

ilFileSystemStorage5069::delete ( )

Delete complete directory.

public

Parameters

Definition at line 244 of file class.ilFileSystemStorage5069.php.

References ilUtil\delDir(), and getAbsolutePath().

245  {
246  return ilUtil::delDir($this->getAbsolutePath());
247  }
getAbsolutePath()
Get absolute path of storage directory.
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
+ Here is the call graph for this function:

◆ deleteDirectory()

ilFileSystemStorage5069::deleteDirectory (   $a_abs_name)

Delete directory.

public

Parameters
stringabsolute name

Definition at line 227 of file class.ilFileSystemStorage5069.php.

References ilUtil\delDir().

228  {
229  if (@file_exists($a_abs_name)) {
230  ilUtil::delDir($a_abs_name);
231  return true;
232  }
233  return false;
234  }
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
+ Here is the call graph for this function:

◆ deleteFile()

ilFileSystemStorage5069::deleteFile (   $a_abs_name)

Delete file.

public

Parameters
stringabsolute name

Definition at line 211 of file class.ilFileSystemStorage5069.php.

212  {
213  if (@file_exists($a_abs_name)) {
214  @unlink($a_abs_name);
215  return true;
216  }
217  return false;
218  }

◆ getAbsolutePath()

ilFileSystemStorage5069::getAbsolutePath ( )

Get absolute path of storage directory.

public

Definition at line 143 of file class.ilFileSystemStorage5069.php.

References $path.

Referenced by delete(), and ilFSStorageExercise5069\getAssignmentFilePath().

+ Here is the caller graph for this function:

◆ getContainerId()

ilFileSystemStorage5069::getContainerId ( )

Definition at line 65 of file class.ilFileSystemStorage5069.php.

References $container_id.

◆ getPath()

ilFileSystemStorage5069::getPath ( )

Get path.

Definition at line 291 of file class.ilFileSystemStorage5069.php.

References $path.

◆ getPathPostfix()

ilFileSystemStorage5069::getPathPostfix ( )
abstractprotected

Get directory name.

E.g for files => file Only relative path, no trailing slash '_<obj_id>' will be appended automatically

protected

Returns
string directory name

Referenced by _createPathFromId(), and init().

+ Here is the caller graph for this function:

◆ getPathPrefix()

ilFileSystemStorage5069::getPathPrefix ( )
abstractprotected

Get path prefix.

Prefix that will be prepended to the path No trailing slash. E.g ilFiles for files

protected

Returns
string path prefix e.g files

Referenced by _createPathFromId(), and init().

+ Here is the caller graph for this function:

◆ getStorageType()

ilFileSystemStorage5069::getStorageType ( )

Definition at line 283 of file class.ilFileSystemStorage5069.php.

References $storage_type.

◆ init()

ilFileSystemStorage5069::init ( )
protected

Read path info.

private

Definition at line 153 of file class.ilFileSystemStorage5069.php.

References $container_id, ilUtil\getDataDir(), getPathPostfix(), getPathPrefix(), ilUtil\getWebspaceDir(), and ilUtil\removeTrailingPathSeparators().

Referenced by __construct().

154  {
155  switch ($this->storage_type) {
156  case self::STORAGE_DATA:
157  $this->path = ilUtil::getDataDir();
158  break;
159 
160  case self::STORAGE_WEB:
161  $this->path = ilUtil::getWebspaceDir();
162  break;
163 
164  case self::STORAGE_SECURED:
165  $this->path = ilUtil::getWebspaceDir();
166  $this->path = ilUtil::removeTrailingPathSeparators($this->path);
167  $this->path .= '/' . self::SECURED_DIRECTORY;
168  break;
169  }
170  $this->path = ilUtil::removeTrailingPathSeparators($this->path);
171  $this->path .= '/';
172 
173  // Append path prefix
174  $this->path .= ($this->getPathPrefix() . '/');
175 
176  if ($this->path_conversion) {
177  $this->path .= self::_createPathFromId($this->container_id, $this->getPathPostfix());
178  } else {
179  $this->path .= ($this->getPathPostfix() . '_' . $this->container_id);
180  }
181  return true;
182  }
getPathPostfix()
Get directory name.
static removeTrailingPathSeparators($path)
getPathPrefix()
Get path prefix.
static getDataDir()
get data directory (outside webspace)
static getWebspaceDir($mode="filesystem")
get webspace directory
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ writeToFile()

ilFileSystemStorage5069::writeToFile (   $a_data,
  $a_absolute_path 
)

Write data to file.

public

Parameters

Definition at line 191 of file class.ilFileSystemStorage5069.php.

192  {
193  if (!$fp = @fopen($a_absolute_path, 'w+')) {
194  return false;
195  }
196  if (@fwrite($fp, $a_data) === false) {
197  @fclose($fp);
198  return false;
199  }
200  @fclose($fp);
201  return true;
202  }

Field Documentation

◆ $container_id

ilFileSystemStorage5069::$container_id
private

Definition at line 40 of file class.ilFileSystemStorage5069.php.

Referenced by getContainerId(), and init().

◆ $path

◆ $path_conversion

ilFileSystemStorage5069::$path_conversion = false
private

Definition at line 42 of file class.ilFileSystemStorage5069.php.

◆ $storage_type

ilFileSystemStorage5069::$storage_type
private

Definition at line 41 of file class.ilFileSystemStorage5069.php.

Referenced by getStorageType().

◆ FACTOR

const ilFileSystemStorage5069::FACTOR = 100

Definition at line 36 of file class.ilFileSystemStorage5069.php.

◆ MAX_EXPONENT

const ilFileSystemStorage5069::MAX_EXPONENT = 3

Definition at line 37 of file class.ilFileSystemStorage5069.php.

◆ SECURED_DIRECTORY

const ilFileSystemStorage5069::SECURED_DIRECTORY = "sec"

Definition at line 38 of file class.ilFileSystemStorage5069.php.

◆ STORAGE_DATA

const ilFileSystemStorage5069::STORAGE_DATA = 2

Definition at line 33 of file class.ilFileSystemStorage5069.php.

◆ STORAGE_SECURED

const ilFileSystemStorage5069::STORAGE_SECURED = 3

Definition at line 34 of file class.ilFileSystemStorage5069.php.

◆ STORAGE_WEB

const ilFileSystemStorage5069::STORAGE_WEB = 1

Definition at line 32 of file class.ilFileSystemStorage5069.php.


The documentation for this class was generated from the following file: