Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
File_Versioning Class Reference

Public Member Functions

 File_Versioning ($dir)
 
 initRepository ()
 
 _iso8601Ts ($iso8601)
 
 _tsIso8601 ($timestamp)
 
 _getFileInfoAtVersion ($fileid, $version=null)
 
 _getFileInfoFromRealFile ($real_file)
 
 _getFileInfoFromPath ($file_path, $version=null)
 
 _lockFile ($fileid)
 
 _releaseFile ($fileid)
 
 add ($rep_path, $real_file, $extra_info='')
 
 _updateFile ($fileid, $rep_path, $real_file, $extra_info='')
 
 _createFFVFile ($real_file, $fileid, $version)
 
 _checkOutCheck ($rep_file, $version=null, $date=null)
 
 _validateFileVersion ($rep_file, $info)
 
 _updateFileVersion ($real_file, $fileid, $version)
 
 checkOut ($rep_file, $dest_dir, $version=null, $date=null)
 
 output ($rep_file, $version=null, $date=null)
 
 upToDate ($real_file)
 
 _fileModified ($ver_info, $real_file)
 
 commit ($real_file, $extra_info='')
 
 remove ($real_file, $extra_info='')
 
 clearOut ($real_file)
 
 changeFvTypeCode ($real_file, $new_type_code)
 

Data Fields

 $_dir
 
 $num_lock_attempts = 4
 

Detailed Description

Definition at line 38 of file file_versioning.inc.

Member Function Documentation

_checkOutCheck (   $rep_file,
  $version = null,
  $date = null 
)

Before a checkout can occur this function is run to return validated information about the file If array is empty something went wrong

Parameters
string$rep_filethe path to the file in the repository
string$versionCheck out this version of the file (null means latest version)
string$dateCheck out the file as it was at this date (null means latest version) - Doesn't override $version\ Format is unix timestamp
Returns
mixed array|int private
See Also
checkOut() output()

Definition at line 690 of file file_versioning.inc.

_createFFVFile (   $real_file,
  $fileid,
  $version 
)

Actually updates the file in the repository and returns the new version number or zero on error

Parameters
string$real_filethe path to the file in the filesystem to add to the repository
int$fileidthe fileid of the file we are updating
int$versionthe version number to write out
Returns
int private
See Also
add() update()

Definition at line 640 of file file_versioning.inc.

_fileModified (   $ver_info,
  $real_file 
)

Checks to see what the status of the passed (checked out) file

Parameters
string$ver_infothe version information from _getFileInfoAtVersion()
string$real_filethe checked out filename (ie the path to it on the filesystem)
Returns
boolean private

Definition at line 1086 of file file_versioning.inc.

_getFileInfoAtVersion (   $fileid,
  $version = null 
)

Returns the main information about the repository from the the passed path and filename Returns either an error code or the info

Parameters
int$fileidthe id of the file to retrieve
int$versionthe version, NULL to get the latest version
Returns
mixed array private

Definition at line 145 of file file_versioning.inc.

_getFileInfoFromPath (   $file_path,
  $version = null 
)

Returns the main information about the repository from the the passed path and filename

Returns either an error code or the info

Parameters
string$file_paththe path to the file in the repository
int$versionthe version
Returns
array private
See Also
_getFileInfoAtVersion()

Definition at line 247 of file file_versioning.inc.

_getFileInfoFromRealFile (   $real_file)

Returns the information from the checked out files .FFV dir entry Returns either an error code or the info

Parameters
string$real_filethe checked out filename (ie the path to it on the filesystem)
Returns
mixed int|array private
See Also
_getFileInfoAtVersion()

Definition at line 194 of file file_versioning.inc.

_iso8601Ts (   $iso8601)

Takes an ISO-8601 compliant date-time string and returns a unix timestamp for it

Parameters
string$iso8601date time string in 'YYYY-MM-DD HH:MM:SS' format
Deprecated:
use iso8601_ts() in core/include/general.inc instead
Returns
int private

Definition at line 112 of file file_versioning.inc.

_lockFile (   $fileid)

Attempt to lock a file

Parameters
int$fileidthe id of the file to lock
Returns
boolean private

Definition at line 278 of file file_versioning.inc.

_releaseFile (   $fileid)

Release a lock on a file

Parameters
int$fileidthe id of the file to unlock
Returns
boolean private

Definition at line 344 of file file_versioning.inc.

_tsIso8601 (   $timestamp)

Takes a unix timestamp for it and returns an ISO-8601 compliant date-time string

Parameters
int$timestampunix timestamp
Deprecated:
use ts_iso8601() in core/include/general.inc instead
Returns
string private

Definition at line 128 of file file_versioning.inc.

_updateFile (   $fileid,
  $rep_path,
  $real_file,
  $extra_info = '' 
)

Actually updates the file in the repository and returns the new version number or zero on error

Parameters
int$fileidthe fileid of the file we are updating
string$rep_paththe path in the repository to store this file
string$real_filethe path to the file in the filesystem to add to the repository
string$extra_infoany extra info that can be stored with this version of the file (eg who actually added it)
Returns
int private
See Also
add() update()

Definition at line 519 of file file_versioning.inc.

_updateFileVersion (   $real_file,
  $fileid,
  $version 
)

Updates the filesize and hash info for a given file/version

Parameters
String$real_file
int$fileid
int$version
Returns
boolean private

Definition at line 919 of file file_versioning.inc.

_validateFileVersion (   $rep_file,
  $info 
)

Asserts file exists and is valid

Validate the integrity of a given file from the file respiratory If the given file does not exist (or fails its integrity checks) we attempt to replace with the private or public file version. otherwise we find the last valid previous version of this file in the respiratory and replace this version with it.

Parameters
string$rep_filethe file we are checking
array$inforelated file information we are working with
Returns
boolean private

Definition at line 828 of file file_versioning.inc.

add (   $rep_path,
  $real_file,
  $extra_info = '' 
)

Add's a file to the repository

Parameters
string$rep_paththe path in the repository to store this file
string$real_filethe path to the file in the filesystem to add to the repository
string$extra_infoany extra info that can be stored with this version of the file (eg who actually added it)
Returns
boolean public

Definition at line 378 of file file_versioning.inc.

changeFvTypeCode (   $real_file,
  $new_type_code 
)

When an asset is morphed, the type code which is still residual in the file repository directory structure and database needs to be changed over.

Parameters
string$real_filethe checked out filename (ie the path to it on the filesystem)
string$new_type_codethe type code the file has changed to (usually after a morph)

public

Definition at line 1325 of file file_versioning.inc.

checkOut (   $rep_file,
  $dest_dir,
  $version = null,
  $date = null 
)

Checks a file out of the repository

Parameters
string$rep_filethe path to the file in the repository
string$dest_dirthe directory to send the file to
string$versionCheck out this version of the file (null means latest version)
string$dateCheck out the file as it was at this date (null means latest version) - doesn't override $version
Returns
boolean public

Definition at line 961 of file file_versioning.inc.

clearOut (   $real_file)

Essentially the opposite of checkOut(), removes a checked out real file and any FFV info that was in the directory for it

Parameters
string$real_filethe checked out filename (ie the path to it on the filesystem)
Returns
int FUDGE_FV_NOT_CHECKED_OUT|FUDGE_FV_ERROR|FUDGE_FV_OK public

Definition at line 1294 of file file_versioning.inc.

commit (   $real_file,
  $extra_info = '' 
)

Commit's a file to the repository

Parameters
string$real_filethe checked out filename (ie the path to it on the filesystem)
string$extra_infoany extra info that can be stored with this version of the file (eg who actually added it)
Returns
int FUDGE_FV_NOT_CHECKED_OUT|FUDGE_FV_ERROR|FUDGE_FV_NOT_MODIFIED|FUDGE_FV_OK public

Definition at line 1106 of file file_versioning.inc.

File_Versioning (   $dir)

Constructor

Parameters
objectDB

Definition at line 60 of file file_versioning.inc.

initRepository ( )

Creates a repository for the file versioning system

Parameters
object&$dbthe PEAR::DB object representing the DB to use for storing our information
Returns
boolean public

Definition at line 79 of file file_versioning.inc.

output (   $rep_file,
  $version = null,
  $date = null 
)

Like checking out a file but output's it directly to standard output NOTE: does NOT output any HTTP headers (including 'Content-Type')

Parameters
string$rep_filethe path to the file in the repository
string$versionCheck out this version of the file (null means latest version)
string$dateCheck out the file as it was at this date (null means latest version) - doesn't override $version
Returns
boolean public

Definition at line 1015 of file file_versioning.inc.

remove (   $real_file,
  $extra_info = '' 
)

Removes a file from the repository

Parameters
string$real_filethe checked out filename (ie the path to it on the filesystem)
string$extra_infoany extra info that can be stored with this version of the file (eg who actually added it)
Returns
int public

Definition at line 1199 of file file_versioning.inc.

upToDate (   $real_file)

Checks to see if the passed (checked out) file is up to date

Parameters
string$real_filethe checked out filename (ie the path to it on the filesystem)
Returns
int public

Definition at line 1040 of file file_versioning.inc.


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