1<?php
2class Plugin_Recommend_Log {
3    var $path;
4
5    function Plugin_Recommend_Log($month) {
6        $this->path = DOKU_INC . 'data/cache/recommend';
7        if (!file_exists($this->path)) {
8            mkdir($this->path);
9        }
10        $this->path .= '/' . $month . '.log';
11    }
12
13    function getLogs() {
14        return array_map('recommend_strip_extension', glob(DOKU_INC . 'data/cache/recommend/*.log'));
15    }
16
17    function getEntries() {
18        return @file($this->path);
19    }
20
21    function writeEntry($page, $sender, $receiver, $comment) {
22	$logfile = fopen($this->path, 'a');
23        fwrite($logfile, date('r') . ': ' .
24                         "“${sender}” recommended “${page}” to " .
25                         "“${receiver}” with comment “${comment}”.\n");
26	fclose($logfile);
27    }
28}
29
30function recommend_strip_extension($str) {
31    return substr(basename($str), 0, -4);
32}
33