[ Index ]

PHP Cross Reference of DokuWiki

title

Body

[close]

/inc/ChangeLog/ -> ChangeLog.php (summary)

methods for handling of changelog of pages or media files

File Size: 666 lines (22 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 14 functions

  __construct()
  setChunkSize()
  getRevisionInfo()
  getRevisions()
  getRelativeRevision()
  getRevisionsAround()
  hasRevisions()
  readloglines()
  readChunk()
  getNewlinepointer()
  isCurrentRevision()
  getLastRevisionAt()
  readAdjacentChunk()
  retrieveRevisionsAround()

Functions
Functions that are not part of a class:

__construct($id, $chunk_size = 8192)   X-Ref
Constructor

param: string $id page id
param: int $chunk_size maximum block size read from file

setChunkSize($chunk_size)   X-Ref
Set chunk size for file reading
Chunk size zero let read whole file at once

param: int $chunk_size maximum block size read from file

getRevisionInfo($rev)   X-Ref
Get the changelog information for a specific page id and revision (timestamp)

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 <btcoburn@silicodon.net>
author: Kate Arzamastseva <pshns@ukr.net>
return: bool|array false or array with entries:
param: int $rev revision timestamp

getRevisions($first, $num)   X-Ref
Return a list of page revisions numbers

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 <btcoburn@silicodon.net>
author: Kate Arzamastseva <pshns@ukr.net>
return: array with the revision timestamps
param: int $first skip the first n changelog lines
param: int $num number of revisions to return

getRelativeRevision($rev, $direction)   X-Ref
Get the nth revision left or right handside  for a specific page id and revision (timestamp)

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.

return: bool|int
param: int $rev revision timestamp used as startdate (doesn't need to be revisionnumber)
param: int $direction give position of returned revision with respect to $rev; positive=next, negative=prev

getRevisionsAround($rev1, $rev2, $max = 50)   X-Ref
Returns revisions around rev1 and rev2
When available it returns $max entries for each revision

return: array with two arrays with revisions surrounding rev1 respectively rev2
param: int $rev1 oldest revision timestamp
param: int $rev2 newest revision timestamp (0 looks up last revision)
param: int $max maximum number of revisions returned

hasRevisions()   X-Ref
Checks if the ID has old revisons

return: boolean

readloglines($rev)   X-Ref
Returns lines from changelog.
If file larger than $chuncksize, only chunck is read that could contain $rev.

return: array|false
param: int $rev revision timestamp

readChunk($fp, $head, $tail)   X-Ref
Read chunk and return array with lines of given chunck.
Has no check if $head and $tail are really at a new line

return: array lines read from chunck
param: resource $fp resource filepointer
param: int $head start point chunck
param: int $tail end point chunck

getNewlinepointer($fp, $finger)   X-Ref
Set pointer to first new line after $finger and return its position

return: int pointer
param: resource $fp filepointer
param: int $finger a pointer

isCurrentRevision($rev)   X-Ref
Check whether given revision is the current page

return: bool true if $rev is current revision, otherwise false
param: int $rev timestamp of current page

getLastRevisionAt($date_at)   X-Ref
Return an existing revision for a specific date which is
the current one or younger or equal then the date

return: string revision ('' for current)
param: number $date_at timestamp

readAdjacentChunk($fp, $head, $tail, $direction)   X-Ref
Returns the next lines of the changelog  of the chunck before head or after tail

return: array with entries:
param: resource $fp filepointer
param: int $head position head of last chunk
param: int $tail position tail of last chunk
param: int $direction positive forward, negative backward

retrieveRevisionsAround($rev, $max)   X-Ref
Collect the $max revisions near to the timestamp $rev

return: bool|array
param: int $rev revision timestamp
param: int $max maximum number of revisions to be returned