ILIAS  Release_4_1_x_branch Revision 61804
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilFileSystemStorage Class Reference
+ Inheritance diagram for ilFileSystemStorage:
+ Collaboration diagram for ilFileSystemStorage:

Public Member Functions

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

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

Data Fields

const STORAGE_WEB = 1
const STORAGE_DATA = 2
const FACTOR = 100
const MAX_EXPONENT = 3

Protected Member Functions

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

Protected Attributes

 $path

Private Member Functions

 init ()
 Read path info.

Private Attributes

 $container_id
 $storage_type
 $path_conversion = false
 $short_path

Detailed Description

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

Constructor & Destructor Documentation

ilFileSystemStorage::__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 58 of file class.ilFileSystemStorage.php.

References init().

{
$this->storage_type = $a_storage_type;
$this->path_conversion = $a_path_conversion;
$this->container_id = $a_container_id;
// Get path info
$this->init();
}

+ Here is the call graph for this function:

ilFileSystemStorage::__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 50 of file class.ilFileSystemStorage.php.

References init().

{
$this->storage_type = $a_storage_type;
$this->path_conversion = $a_path_conversion;
$this->container_id = $a_container_id;
// Get path info
$this->init();
}

+ Here is the call graph for this function:

Member Function Documentation

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

Copy directory and all contents.

public

Parameters
stringabsolute source path
stringabsolute target path

Definition at line 286 of file class.ilFileSystemStorage.php.

References ilUtil\rCopy().

Referenced by ilFSStorageCourse\_clone().

{
return ilUtil::rCopy($a_source,$a_target);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static ilFileSystemStorage::_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 69 of file class.ilFileSystemStorage.php.

References $path.

{
$path = array();
$found = false;
$num = $a_container_id;
for($i = self::MAX_EXPONENT; $i > 0;$i--)
{
$factor = pow(self::FACTOR,$i);
if(($tmp = (int) ($num / $factor)) or $found)
{
$path[] = $tmp;
$num = $num % $factor;
$found = true;
}
}
if(count($path))
{
$path_string = (implode('/',$path));
}
return $path_string;
}
static ilFileSystemStorage::_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 82 of file class.ilFileSystemStorage.php.

References $path.

Referenced by ilExport\_getExportDirectory(), and init().

{
$path = array();
$found = false;
$num = $a_container_id;
for($i = self::MAX_EXPONENT; $i > 0;$i--)
{
$factor = pow(self::FACTOR,$i);
if(($tmp = (int) ($num / $factor)) or $found)
{
$path[] = $tmp;
$num = $num % $factor;
$found = true;
}
}
if(count($path))
{
$path_string = (implode('/',$path).'/');
}
return $path_string.$a_name.'_'.$a_container_id;
}

+ Here is the caller graph for this function:

ilFileSystemStorage::appendToPath (   $a_appendix)

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

Referenced by ilFSStorageMail\__construct().

{
$this->path .= $a_appendix;
}

+ Here is the caller graph for this function:

ilFileSystemStorage::copyFile (   $a_from,
  $a_to 
)

Copy files.

public

Parameters
stringabsolute source
stringabsolute target

Definition at line 267 of file class.ilFileSystemStorage.php.

{
if(@file_exists($a_from))
{
@copy($a_from,$a_to);
return true;
}
return false;
}
ilFileSystemStorage::create ( )

Create directory.

public

Reimplemented in ilFSStorageExercise.

Definition at line 121 of file class.ilFileSystemStorage.php.

References ilUpdateUtils\makeDirParents(), and ilUpdateUtils\removeTrailingPathSeparators().

{
if(!file_exists($this->short_path))
{
}
return true;
}

+ Here is the call graph for this function:

ilFileSystemStorage::create ( )

Create directory.

public

Reimplemented in ilFSStorageExercise.

Definition at line 134 of file class.ilFileSystemStorage.php.

References ilUtil\makeDirParents().

{
if(!file_exists($this->path))
{
ilUtil::makeDirParents($this->path);
}
return true;
}

+ Here is the call graph for this function:

ilFileSystemStorage::delete ( )

Delete complete directory.

public

Parameters

Definition at line 253 of file class.ilFileSystemStorage.php.

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

{
return ilUtil::delDir($this->getAbsolutePath());
}

+ Here is the call graph for this function:

ilFileSystemStorage::deleteDirectory (   $a_abs_name)

Delete directory.

public

Parameters
stringabsolute name

Definition at line 235 of file class.ilFileSystemStorage.php.

References ilUtil\delDir().

Referenced by ilFSStorageCourse\deleteArchive().

{
if(@file_exists($a_abs_name))
{
ilUtil::delDir($a_abs_name);
return true;
}
return false;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilFileSystemStorage::deleteFile (   $a_abs_name)

Delete file.

public

Parameters
stringabsolute name

Definition at line 218 of file class.ilFileSystemStorage.php.

Referenced by ilFSStorageCourse\deleteArchive(), ilFSStorageGroup\deleteMemberExportFile(), and ilFSStorageCourse\deleteMemberExportFile().

{
if(@file_exists($a_abs_name))
{
@unlink($a_abs_name);
return true;
}
return false;
}

+ Here is the caller graph for this function:

ilFileSystemStorage::getAbsolutePath ( )

Get absolute path of storage directory.

public

Definition at line 137 of file class.ilFileSystemStorage.php.

References $path.

{
return $this->path;
}
ilFileSystemStorage::getContainerId ( )

Definition at line 68 of file class.ilFileSystemStorage.php.

References $container_id.

Referenced by ilFSStorageGroup\getMemberExportFiles(), and ilFSStorageCourse\getMemberExportFiles().

{
}

+ Here is the caller graph for this function:

ilFileSystemStorage::getPath ( )

Get path.

Definition at line 304 of file class.ilFileSystemStorage.php.

References $path.

{
return $this->path;
}
ilFileSystemStorage::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

Reimplemented in ilFSStorageCourse, ilFSStorageCourse, ilFSStorageGroup, ilFSStorageExercise, ilFSStorageSession, ilFSStorageEvent, ilFSStorageMail, ilFSStorageFile, and ilFSStorageFile.

ilFileSystemStorage::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

Reimplemented in ilFSStorageCourse, ilFSStorageCourse, ilFSStorageGroup, ilFSStorageExercise, ilFSStorageSession, ilFSStorageEvent, ilFSStorageMail, ilFSStorageFile, and ilFSStorageFile.

Referenced by init().

+ Here is the caller graph for this function:

ilFileSystemStorage::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

Reimplemented in ilFSStorageCourse, ilFSStorageCourse, ilFSStorageGroup, ilFSStorageExercise, ilFSStorageSession, ilFSStorageEvent, ilFSStorageMail, ilFSStorageFile, and ilFSStorageFile.

ilFileSystemStorage::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

Reimplemented in ilFSStorageCourse, ilFSStorageCourse, ilFSStorageGroup, ilFSStorageExercise, ilFSStorageSession, ilFSStorageEvent, ilFSStorageMail, ilFSStorageFile, and ilFSStorageFile.

Referenced by init().

+ Here is the caller graph for this function:

ilFileSystemStorage::getShortPath ( )

Definition at line 142 of file class.ilFileSystemStorage.php.

References $short_path.

{
}
ilFileSystemStorage::getStorageType ( )

Definition at line 296 of file class.ilFileSystemStorage.php.

References $storage_type.

Referenced by ilFSStorageMail\getRelativePathExMailDirectory().

{
}

+ Here is the caller graph for this function:

ilFileSystemStorage::init ( )
private

Read path info.

private

Reimplemented in ilFSStorageExercise.

Definition at line 157 of file class.ilFileSystemStorage.php.

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

{
switch($this->storage_type)
{
case self::STORAGE_DATA:
$this->path = ilUpdateUtils::getDataDir();
break;
case self::STORAGE_WEB:
break;
}
$this->path = ilUpdateUtils::removeTrailingPathSeparators($this->path);
$this->path .= '/';
// Append path prefix
$this->path .= ($this->getPathPrefix().'/');
if($this->path_conversion)
{
if($path_id = self::_createPathFromId($this->container_id,$this->getPathPostfix()))
{
$this->path = $this->path.'/'.$path_id;
$this->path .= '/';
$this->short_path = $this->path;
}
else
{
$this->short_path = $this->path;
}
$this->path .= ($this->getPathPostfix().'_'.$this->container_id);
}
else
{
$this->short_path = $this->path;
$this->path .= ($this->getPathPostfix().'_'.$this->container_id);
}
return true;
}

+ Here is the call graph for this function:

ilFileSystemStorage::init ( )
protected

Read path info.

private

Reimplemented in ilFSStorageExercise.

Definition at line 160 of file class.ilFileSystemStorage.php.

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

Referenced by __construct().

{
switch($this->storage_type)
{
case self::STORAGE_DATA:
$this->path = ilUtil::getDataDir();
break;
case self::STORAGE_WEB:
$this->path = ilUtil::getWebspaceDir();
break;
}
$this->path = ilUtil::removeTrailingPathSeparators($this->path);
$this->path .= '/';
// Append path prefix
$this->path .= ($this->getPathPrefix().'/');
if($this->path_conversion)
{
$this->path .= self::_createPathFromId($this->container_id,$this->getPathPostfix());
}
else
{
$this->path .= ($this->getPathPostfix().'_'.$this->container_id);
}
return true;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilFileSystemStorage::rename (   $from,
  $to 
)

Definition at line 147 of file class.ilFileSystemStorage.php.

Referenced by ilFSStorageExercise\deliverFile().

{
return @rename($from,$to);
}

+ Here is the caller graph for this function:

ilFileSystemStorage::writeToFile (   $a_data,
  $a_absolute_path 
)

Write data to file.

public

Parameters

Definition at line 196 of file class.ilFileSystemStorage.php.

Referenced by ilFSStorageGroup\addMemberExportFile(), ilFSStorageCourse\addMemberExportFile(), and ilFSStorageCourse\writeArchiveFile().

{
if(!$fp = @fopen($a_absolute_path,'w+'))
{
return false;
}
if(@fwrite($fp,$a_data) === false)
{
@fclose($fp);
return false;
}
@fclose($fp);
return true;
}

+ Here is the caller graph for this function:

Field Documentation

ilFileSystemStorage::$container_id
private

Definition at line 43 of file class.ilFileSystemStorage.php.

Referenced by getContainerId(), and init().

ilFileSystemStorage::$path_conversion = false
private

Definition at line 45 of file class.ilFileSystemStorage.php.

ilFileSystemStorage::$short_path
private

Definition at line 39 of file class.ilFileSystemStorage.php.

Referenced by getShortPath().

ilFileSystemStorage::$storage_type
private

Definition at line 44 of file class.ilFileSystemStorage.php.

Referenced by getStorageType().

const ilFileSystemStorage::FACTOR = 100

Definition at line 39 of file class.ilFileSystemStorage.php.

const ilFileSystemStorage::MAX_EXPONENT = 3

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

const ilFileSystemStorage::STORAGE_WEB = 1

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


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