colas@0: # Hack for older TWiki versions colas@0: package CompatibilityHacks; colas@0: colas@0: package IteratorHack; colas@0: colas@0: sub new { colas@0: my ($class, $list) = @_; colas@0: my $this = bless({list => $list, index => 0, next => undef }, $class); colas@0: return $this; colas@0: } colas@0: colas@0: sub hasNext { colas@0: my( $this ) = @_; colas@0: return 1 if $this->{next}; colas@0: if( $this->{index} < scalar(@{$this->{list}}) ) { colas@0: $this->{next} = $this->{list}->[$this->{index}++]; colas@0: return 1; colas@0: } colas@0: return 0; colas@0: } colas@0: colas@0: sub next { colas@0: my $this = shift; colas@0: $this->hasNext(); colas@0: my $n = $this->{next}; colas@0: $this->{next} = undef; colas@0: return $n; colas@0: } colas@0: colas@0: package TWiki::Func; colas@0: colas@0: sub eachChangeSince { colas@0: my ($web, $since) = @_; colas@0: colas@0: my $changes; colas@0: if( open(F, "<$TWiki::cfg{DataDir}/$web/.changes")) { colas@0: local $/ = undef; colas@0: $changes = ; colas@0: close(F); colas@0: } colas@0: colas@0: $changes ||= ''; colas@0: colas@0: my @changes = colas@0: map { colas@0: # Create a hash for this line colas@0: { topic => $_->[0], user => $_->[1], time => $_->[2], colas@0: revision => $_->[3], more => $_->[4] }; colas@0: } colas@0: grep { colas@0: # Filter on time colas@0: $_->[2] && $_->[2] >= $since colas@0: } colas@0: map { colas@0: # Split line into an array colas@0: my @row = split(/\t/, $_, 5); colas@0: \@row; colas@0: } colas@0: reverse split( /[\r\n]+/, $changes); colas@0: colas@0: return new IteratorHack( \@changes ); colas@0: } colas@0: colas@0: 1;