summaryrefslogtreecommitdiff
path: root/inc/changelog.php
diff options
context:
space:
mode:
authorAndreas Gohr <andi@splitbrain.org>2006-10-17 11:10:36 +0200
committerAndreas Gohr <andi@splitbrain.org>2006-10-17 11:10:36 +0200
commit5b8fbc22b64a916716a97745d645316f213db374 (patch)
tree07bc72f634004a16b573c3a2c53ed41d76278323 /inc/changelog.php
parent98e707c74c940150996f311b1888cf9c4151a430 (diff)
downloadrpg-5b8fbc22b64a916716a97745d645316f213db374.tar.gz
rpg-5b8fbc22b64a916716a97745d645316f213db374.tar.bz2
read old revisons from the attic additionally to the changelog infos
darcs-hash:20061017091036-7ad00-41df4dbaddb0a20d0f000f7a1bb000aaf2176185.gz
Diffstat (limited to 'inc/changelog.php')
-rw-r--r--inc/changelog.php34
1 files changed, 34 insertions, 0 deletions
diff --git a/inc/changelog.php b/inc/changelog.php
index 9501ec392..0c6557e46 100644
--- a/inc/changelog.php
+++ b/inc/changelog.php
@@ -271,7 +271,11 @@ function getRevisionInfo($id, $rev, $chunk_size=8192) {
* backwards in chunks untill the requested number of changelog
* lines are recieved.
*
+ * Because there may exist revisions not listed in the changelog
+ * the found revisions are merged with the ones found in the attic
+ *
* @author Ben Coburn <btcoburn@silicodon.net>
+ * @see getRevisionsFromAttic()
*/
function getRevisions($id, $first, $num, $chunk_size=8192) {
global $cache_revinfo;
@@ -354,7 +358,37 @@ function getRevisions($id, $first, $num, $chunk_size=8192) {
}
}
+ // merge with attic file info
+ $revs = array_merge($revs,getRevisionsFromAttic($id,false));
+ $revs = array_unique($revs);
+ rsort($revs);
+
return $revs;
}
+/**
+ * Return a list of available and existing page revisons from the attic
+ *
+ * @author Andreas Gohr <andi@splitbrain.org>
+ * @see getRevisions()
+ */
+function getRevisionsFromAttic($id,$sorted=true){
+ $revd = dirname(wikiFN($id,'foo'));
+ $revs = array();
+ $clid = cleanID($id);
+ if(strrpos($clid,':')) $clid = substr($clid,strrpos($clid,':')+1); //remove path
+ $clid = utf8_encodeFN($clid);
+
+ if (is_dir($revd) && $dh = opendir($revd)) {
+ while (($file = readdir($dh)) !== false) {
+ if (is_dir($revd.'/'.$file)) continue;
+ if (preg_match('/^'.$clid.'\.(\d+)\.txt(\.gz)?$/',$file,$match)){
+ $revs[]=$match[1];
+ }
+ }
+ closedir($dh);
+ }
+ if($sorted) rsort($revs);
+ return $revs;
+}