PHP Class ChangeLog, dokuwiki

Inheritance: extends DataObject
Afficher le fichier Open project: splitbrain/dokuwiki Class Usage Examples

Protected Properties

Свойство Type Description
$cache array
$chunk_size integer
$id string

Méthodes publiques

Méthode Description
__construct ( string $id, integer $chunk_size = 8192 ) Constructor
getLastRevisionAt ( number $date_at ) : string Return an existing revision for a specific date which is the current one or younger or equal then the date
getRelativeRevision ( integer $rev, integer $direction ) : boolean | integer Get the nth revision left or right handside for a specific page id and revision (timestamp)
getRevisionInfo ( integer $rev ) : boolean | array Get the changelog information for a specific page id and revision (timestamp)
getRevisions ( integer $first, integer $num ) : array Return a list of page revisions numbers
getRevisionsAround ( integer $rev1, integer $rev2, integer $max = 50 ) : array Returns revisions around rev1 and rev2 When available it returns $max entries for each revision
isCurrentRevision ( integer $rev ) : boolean Check whether given revision is the current page
setChunkSize ( integer $chunk_size ) Set chunk size for file reading Chunk size zero let read whole file at once

Méthodes protégées

Méthode Description
getChangelogFilename ( ) : string Returns path to changelog
getFilename ( ) : string Returns path to current page/media
getNewlinepointer ( resource $fp, integer $finger ) : integer Set pointer to first new line after $finger and return its position
readAdjacentChunk ( resource $fp, integer $head, integer $tail, integer $direction ) : array Returns the next lines of the changelog of the chunck before head or after tail
readChunk ( resource $fp, integer $head, integer $tail ) : array Read chunk and return array with lines of given chunck.
readloglines ( integer $rev ) : array | false Returns lines from changelog.
retrieveRevisionsAround ( integer $rev, integer $max ) : boolean | array Collect the $max revisions near to the timestamp $rev

Method Details

__construct() public méthode

Constructor
public __construct ( string $id, integer $chunk_size = 8192 )
$id string page id
$chunk_size integer maximum block size read from file

getChangelogFilename() abstract protected méthode

Returns path to changelog
abstract protected getChangelogFilename ( ) : string
Résultat string path to file

getFilename() abstract protected méthode

Returns path to current page/media
abstract protected getFilename ( ) : string
Résultat string path to file

getLastRevisionAt() public méthode

Return an existing revision for a specific date which is the current one or younger or equal then the date
public getLastRevisionAt ( number $date_at ) : string
$date_at number timestamp
Résultat string revision ('' for current)

getNewlinepointer() protected méthode

Set pointer to first new line after $finger and return its position
protected getNewlinepointer ( resource $fp, integer $finger ) : integer
$fp resource filepointer
$finger integer a pointer
Résultat integer pointer

getRelativeRevision() public méthode

For large changelog files, only the chunk containing the reference revision $rev is read and sometimes a next chunck. Adjacent changelog lines are optimistically parsed and cached to speed up consecutive calls to getRevisionInfo.
public getRelativeRevision ( integer $rev, integer $direction ) : boolean | integer
$rev integer revision timestamp used as startdate (doesn't need to be revisionnumber)
$direction integer give position of returned revision with respect to $rev; positive=next, negative=prev
Résultat boolean | integer timestamp of the requested revision otherwise false

getRevisionInfo() public méthode

Adjacent changelog lines are optimistically parsed and cached to speed up consecutive calls to getRevisionInfo. For large changelog files, only the chunk containing the requested changelog line is read.
Author: Ben Coburn ([email protected])
Author: Kate Arzamastseva ([email protected])
public getRevisionInfo ( integer $rev ) : boolean | array
$rev integer revision timestamp
Résultat boolean | array false or array with entries: - date: unix timestamp - ip: IPv4 address (127.0.0.1) - type: log line type - id: page id - user: user name - sum: edit summary (or action reason) - extra: extra data (varies by line type)

getRevisions() public méthode

Does not guarantee that the revision exists in the attic, only that a line with the date exists in the changelog. By default the current revision is skipped. The current revision is automatically skipped when the page exists. See $INFO['meta']['last_change'] for the current revision. A negative $first let read the current revision too. For efficiency, the log lines are parsed and cached for later calls to getRevisionInfo. Large changelog files are read backwards in chunks until the requested number of changelog lines are recieved.
Author: Ben Coburn ([email protected])
Author: Kate Arzamastseva ([email protected])
public getRevisions ( integer $first, integer $num ) : array
$first integer skip the first n changelog lines
$num integer number of revisions to return
Résultat array with the revision timestamps

getRevisionsAround() public méthode

Returns revisions around rev1 and rev2 When available it returns $max entries for each revision
public getRevisionsAround ( integer $rev1, integer $rev2, integer $max = 50 ) : array
$rev1 integer oldest revision timestamp
$rev2 integer newest revision timestamp (0 looks up last revision)
$max integer maximum number of revisions returned
Résultat array with two arrays with revisions surrounding rev1 respectively rev2

isCurrentRevision() public méthode

Check whether given revision is the current page
public isCurrentRevision ( integer $rev ) : boolean
$rev integer timestamp of current page
Résultat boolean true if $rev is current revision, otherwise false

readAdjacentChunk() protected méthode

Returns the next lines of the changelog of the chunck before head or after tail
protected readAdjacentChunk ( resource $fp, integer $head, integer $tail, integer $direction ) : array
$fp resource filepointer
$head integer position head of last chunk
$tail integer position tail of last chunk
$direction integer positive forward, negative backward
Résultat array with entries: - $lines: changelog lines of readed chunk - $head: head of chunk - $tail: tail of chunk

readChunk() protected méthode

Has no check if $head and $tail are really at a new line
protected readChunk ( resource $fp, integer $head, integer $tail ) : array
$fp resource resource filepointer
$head integer start point chunck
$tail integer end point chunck
Résultat array lines read from chunck

readloglines() protected méthode

If file larger than $chuncksize, only chunck is read that could contain $rev.
protected readloglines ( integer $rev ) : array | false
$rev integer revision timestamp
Résultat array | false if success returns array(fp, array(changeloglines), $head, $tail, $eof) where fp only defined for chuck reading, needs closing. otherwise false

retrieveRevisionsAround() protected méthode

Collect the $max revisions near to the timestamp $rev
protected retrieveRevisionsAround ( integer $rev, integer $max ) : boolean | array
$rev integer revision timestamp
$max integer maximum number of revisions to be returned
Résultat boolean | array return array with entries: - $requestedrevs: array of with $max revision timestamps - $revs: all parsed revision timestamps - $fp: filepointer only defined for chuck reading, needs closing. - $lines: non-parsed changelog lines before the parsed revisions - $head: position of first readed changelogline - $lasttail: position of end of last readed changelogline otherwise false

setChunkSize() public méthode

Set chunk size for file reading Chunk size zero let read whole file at once
public setChunkSize ( integer $chunk_size )
$chunk_size integer maximum block size read from file

Property Details

$cache protected_oe property

protected array $cache
Résultat array

$chunk_size protected_oe property

protected int $chunk_size
Résultat integer

$id protected_oe property

protected string $id
Résultat string