PHP Класс ChangeLog, dokuwiki

Наследование: extends DataObject
Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
$cache array
$chunk_size integer
$id string

Открытые методы

Метод Описание
__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

Защищенные методы

Метод Описание
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

Описание методов

__construct() публичный Метод

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

getChangelogFilename() абстрактный защищенный Метод

Returns path to changelog
abstract protected getChangelogFilename ( ) : string
Результат string path to file

getFilename() абстрактный защищенный Метод

Returns path to current page/media
abstract protected getFilename ( ) : string
Результат string path to file

getLastRevisionAt() публичный Метод

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
Результат string revision ('' for current)

getNewlinepointer() защищенный Метод

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
Результат integer pointer

getRelativeRevision() публичный Метод

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
Результат boolean | integer timestamp of the requested revision otherwise false

getRevisionInfo() публичный Метод

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.
Автор: Ben Coburn ([email protected])
Автор: Kate Arzamastseva ([email protected])
public getRevisionInfo ( integer $rev ) : boolean | array
$rev integer revision timestamp
Результат 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() публичный Метод

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.
Автор: Ben Coburn ([email protected])
Автор: 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
Результат array with the revision timestamps

getRevisionsAround() публичный Метод

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
Результат array with two arrays with revisions surrounding rev1 respectively rev2

isCurrentRevision() публичный Метод

Check whether given revision is the current page
public isCurrentRevision ( integer $rev ) : boolean
$rev integer timestamp of current page
Результат boolean true if $rev is current revision, otherwise false

readAdjacentChunk() защищенный Метод

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
Результат array with entries: - $lines: changelog lines of readed chunk - $head: head of chunk - $tail: tail of chunk

readChunk() защищенный Метод

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
Результат array lines read from chunck

readloglines() защищенный Метод

If file larger than $chuncksize, only chunck is read that could contain $rev.
protected readloglines ( integer $rev ) : array | false
$rev integer revision timestamp
Результат array | false if success returns array(fp, array(changeloglines), $head, $tail, $eof) where fp only defined for chuck reading, needs closing. otherwise false

retrieveRevisionsAround() защищенный Метод

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
Результат 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() публичный Метод

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

Описание свойств

$cache защищенное свойство

protected array $cache
Результат array

$chunk_size защищенное свойство

protected int $chunk_size
Результат integer

$id защищенное свойство

protected string $id
Результат string