ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
+ Collaboration diagram for PGT storage on the filesystem:

Data Structures

class  PGTStorageFile
 The PGTStorageFile class is a class for PGT file storage. More...
 

Functions

 PGTStorageFile::getPath ()
 This method returns the name of the directory where PGT's should be stored on the filesystem. More...
 
 PGTStorageFile::getFormat ()
 This method returns the format to use when storing PGT's on the filesystem. More...
 
 PGTStorageFile::getStorageType ()
 This method returns an informational string giving the type of storage used by the object (used for debugging purposes). More...
 
 PGTStorageFile::getStorageInfo ()
 This method returns an informational string giving informations on the parameters of the storage. More...
 
 PGTStorageFile::PGTStorageFile ($cas_parent, $format, $path)
 The class constructor, called by CASClient::SetPGTStorageFile(). More...
 
 PGTStorageFile::init ()
 This method is used to initialize the storage. More...
 
 PGTStorageFile::getPGTIouFilename ($pgt_iou)
 This method returns the filename corresponding to a PGT Iou. More...
 
 PGTStorageFile::write ($pgt, $pgt_iou)
 This method stores a PGT and its corresponding PGT Iou into a file. More...
 
 PGTStorageFile::read ($pgt_iou)
 This method reads a PGT corresponding to a PGT Iou and deletes the corresponding file. More...
 

Variables

 PGTStorageFile::$_path
 a string telling where PGT's should be stored on the filesystem. More...
 
 PGTStorageFile::$_format
 a string telling the format to use to store PGT's (plain or xml). More...
 

Detailed Description

Function Documentation

◆ getFormat()

PGTStorageFile::getFormat ( )
private

This method returns the format to use when storing PGT's on the filesystem.

Returns
a string corresponding to the format used (plain or xml).

Definition at line 88 of file pgt-file.php.

89 {
90 return $this->_format;
91 }
$_format
a string telling the format to use to store PGT's (plain or xml).
Definition: pgt-file.php:79

References PGTStorageFile\$_format.

Referenced by PGTStorageFile\getPGTIouFilename().

+ Here is the caller graph for this function:

◆ getPath()

PGTStorageFile::getPath ( )
private

This method returns the name of the directory where PGT's should be stored on the filesystem.

Returns
the name of a directory (with leading and trailing '/')

Definition at line 68 of file pgt-file.php.

69 {
70 return $this->_path;
71 }
$_path
a string telling where PGT's should be stored on the filesystem.
Definition: pgt-file.php:58

References PGTStorageFile\$_path.

Referenced by PGTStorageFile\getPGTIouFilename().

+ Here is the caller graph for this function:

◆ getPGTIouFilename()

PGTStorageFile::getPGTIouFilename (   $pgt_iou)
private

This method returns the filename corresponding to a PGT Iou.

Parameters
$pgt_iouthe PGT iou.
Returns
a filename

Definition at line 208 of file pgt-file.php.

209 {
211 $filename = $this->getPath().$pgt_iou.'.'.$this->getFormat();
213 return $filename;
214 }
$filename
Definition: buildRTE.php:89
traceBegin()
This method is used to indicate the start of the execution of a function in debug mode.
Definition: CAS.php:577
traceEnd($res='')
This method is used to indicate the end of the execution of a function in debug mode.
Definition: CAS.php:604
getPath()
This method returns the name of the directory where PGT's should be stored on the filesystem.
Definition: pgt-file.php:68
getFormat()
This method returns the format to use when storing PGT's on the filesystem.
Definition: pgt-file.php:88

References $filename, PGTStorageFile\getFormat(), PGTStorageFile\getPath(), phpCAS\traceBegin(), and phpCAS\traceEnd().

Referenced by PGTStorageFile\read(), and PGTStorageFile\write().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getStorageInfo()

PGTStorageFile::getStorageInfo ( )

This method returns an informational string giving informations on the parameters of the storage.

(used for debugging purposes).

Returns
an informational string.

Reimplemented from PGTStorage.

Definition at line 116 of file pgt-file.php.

117 {
118 return 'path=`'.$this->getPath().'\', format=`'.$this->getFormat().'\'';
119 }

◆ getStorageType()

PGTStorageFile::getStorageType ( )

This method returns an informational string giving the type of storage used by the object (used for debugging purposes).

Returns
an informational string.

Reimplemented from PGTStorage.

Definition at line 104 of file pgt-file.php.

105 {
106 return "file";
107 }

◆ init()

PGTStorageFile::init ( )

This method is used to initialize the storage.

Halts on error.

Reimplemented from PGTStorage.

Definition at line 185 of file pgt-file.php.

186 {
188 // if the storage has already been initialized, return immediatly
189 if ( $this->isInitialized() )
190 return;
191 // call the ancestor's method (mark as initialized)
192 parent::init();
194 }
isInitialized()
This method tells if the storage has already been intialized.
Definition: pgt-main.php:160

References PGTStorage\isInitialized(), phpCAS\traceBegin(), and phpCAS\traceEnd().

+ Here is the call graph for this function:

◆ PGTStorageFile()

PGTStorageFile::PGTStorageFile (   $cas_parent,
  $format,
  $path 
)

The class constructor, called by CASClient::SetPGTStorageFile().

Parameters
$cas_parentthe CASClient instance that creates the object.
$formatthe format used to store the PGT's (‘plain’ and ‘xml’ allowed).
$paththe path where the PGT's should be stored

Definition at line 134 of file pgt-file.php.

135 {
137 // call the ancestor's constructor
138 $this->PGTStorage($cas_parent);
139
140 if (empty($format) ) $format = CAS_PGT_STORAGE_FILE_DEFAULT_FORMAT;
142
143 // check that the path is an absolute path
144 if (getenv("OS")=="Windows_NT"){
145
146 if (!preg_match('`^[a-zA-Z]:`', $path)) {
147 phpCAS::error('an absolute path is needed for PGT storage to file');
148 }
149
150 }
151 else
152 {
153
154 if ( $path[0] != '/' ) {
155 phpCAS::error('an absolute path is needed for PGT storage to file');
156 }
157
158 // store the path (with a leading and trailing '/')
159 $path = preg_replace('|[/]*$|','/',$path);
160 $path = preg_replace('|^[/]*|','/',$path);
161 }
162
163 $this->_path = $path;
164 // check the format and store it
165 switch ($format) {
168 $this->_format = $format;
169 break;
170 default:
171 phpCAS::error('unknown PGT file storage format (`'.CAS_PGT_STORAGE_FILE_FORMAT_PLAIN.'\' and `'.CAS_PGT_STORAGE_FILE_FORMAT_XML.'\' allowed)');
172 }
174 }
error($msg)
This method is used by interface methods to print an error and where the function was originally call...
Definition: CAS.php:544
PGTStorage($cas_parent)
The constructor of the class, should be called only by inherited classes.
Definition: pgt-main.php:63
const CAS_PGT_STORAGE_FILE_DEFAULT_PATH
Default path used when storing PGT's to file.
Definition: CAS.php:149
const CAS_PGT_STORAGE_FILE_FORMAT_PLAIN
phpCAS::setPGTStorageFile()'s 2nd parameter to write plain text files
Definition: CAS.php:153
const CAS_PGT_STORAGE_FILE_FORMAT_XML
phpCAS::setPGTStorageFile()'s 2nd parameter to write xml files
Definition: CAS.php:157
const CAS_PGT_STORAGE_FILE_DEFAULT_FORMAT
Default format used when storing PGT's to file.
Definition: CAS.php:161
$path
Definition: index.php:22

References $path, CAS_PGT_STORAGE_FILE_DEFAULT_FORMAT, CAS_PGT_STORAGE_FILE_DEFAULT_PATH, CAS_PGT_STORAGE_FILE_FORMAT_PLAIN, CAS_PGT_STORAGE_FILE_FORMAT_XML, phpCAS\error(), PGTStorage\PGTStorage(), phpCAS\traceBegin(), and phpCAS\traceEnd().

+ Here is the call graph for this function:

◆ read()

PGTStorageFile::read (   $pgt_iou)

This method reads a PGT corresponding to a PGT Iou and deletes the corresponding file.

Parameters
$pgt_iouthe PGT iou
Returns
the corresponding PGT, or FALSE on error

Reimplemented from PGTStorage.

Definition at line 250 of file pgt-file.php.

251 {
253 $pgt = FALSE;
254 $fname = $this->getPGTIouFilename($pgt_iou);
255 if ( !($f=fopen($fname,"r")) ) {
256 phpCAS::trace('could not open `'.$fname.'\'');
257 } else {
258 if ( ($pgt=fgets($f)) === FALSE ) {
259 phpCAS::trace('could not read PGT from `'.$fname.'\'');
260 }
261 fclose($f);
262 }
263
264 // delete the PGT file
265 @unlink($fname);
266
267 phpCAS::traceEnd($pgt);
268 return $pgt;
269 }
trace($str)
This method is used to log something in debug mode.
Definition: CAS.php:569
getPGTIouFilename($pgt_iou)
This method returns the filename corresponding to a PGT Iou.
Definition: pgt-file.php:208

References PGTStorageFile\getPGTIouFilename(), phpCAS\trace(), phpCAS\traceBegin(), and phpCAS\traceEnd().

+ Here is the call graph for this function:

◆ write()

PGTStorageFile::write (   $pgt,
  $pgt_iou 
)

This method stores a PGT and its corresponding PGT Iou into a file.

Echoes a warning on error.

Parameters
$pgtthe PGT
$pgt_iouthe PGT iou

Reimplemented from PGTStorage.

Definition at line 225 of file pgt-file.php.

226 {
228 $fname = $this->getPGTIouFilename($pgt_iou);
229 if ( $f=fopen($fname,"w") ) {
230 if ( fputs($f,$pgt) === FALSE ) {
231 phpCAS::error('could not write PGT to `'.$fname.'\'');
232 }
233 fclose($f);
234 } else {
235 phpCAS::error('could not open `'.$fname.'\'');
236 }
238 }

References phpCAS\error(), PGTStorageFile\getPGTIouFilename(), phpCAS\traceBegin(), and phpCAS\traceEnd().

+ Here is the call graph for this function:

Variable Documentation

◆ $_format

PGTStorageFile::$_format
private

a string telling the format to use to store PGT's (plain or xml).

Written by PGTStorageFile::PGTStorageFile(), read by getFormat().

Definition at line 79 of file pgt-file.php.

Referenced by PGTStorageFile\getFormat().

◆ $_path

PGTStorageFile::$_path
private

a string telling where PGT's should be stored on the filesystem.

Written by PGTStorageFile::PGTStorageFile(), read by getPath().

Definition at line 58 of file pgt-file.php.

Referenced by PGTStorageFile\getPath().