4 * Copyright 1999, 2000, 2001, 2002 $ThePhpWikiProgrammingTeam
5 * Copyright (C) 2002 Johannes Große |
7 * This file is part of PhpWiki.
9 * PhpWiki is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * PhpWiki is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with PhpWiki; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 /* There is a bug in it:
25 When the cache is empty and you safe the wikipages,
26 an immediately created cached output of
27 RecentChanges will at the rss-image-link include
31 require_once "lib/WikiPluginCached.php";
32 require_once "lib/plugin/RecentChanges.php";
34 class WikiPlugin_RecentChangesCached
35 extends WikiPluginCached
37 /* --------- overwrite virtual or abstract methods ---------------- */
38 function getPluginType() {
39 return PLUGIN_CACHED_HTML;
43 return "RecentChangesCached";
46 function getDescription() {
47 return 'Caches output of RecentChanges called with default arguments.';
50 function getVersion() {
51 return preg_replace("/[Revision: $]/", '',
55 function getDefaultArguments() {
56 return WikiPlugin_RecentChanges::getDefaultArguments();
59 function getExpire($dbi, $argarray, $request) {
60 return '+900'; // 15 minutes
63 // We don't go through pi parsing, instead we go directly to the
64 // better plugin methods.
65 function getHtml($dbi, $args, $request, $basepage) {
66 $plugin = new WikiPlugin_RecentChanges();
67 $changes = $plugin->getChanges($dbi, $args);
68 return $plugin->format($changes, $args);
70 $loader = new WikiPluginLoader;
71 return $loader->expandPI('<?plugin RecentChanges '
72 . WikiPluginCached::glueArgs($argarray)
73 . ' ?>', $request, $this, $basepage);
77 // ->box is used to display a fixed-width, narrow version with common header.
78 // Just a limited list of pagenames, without date.
79 // This does not use ->run, to avoid pi construction and deconstruction
80 function box($args = false, $request = false, $basepage = false, $do_save = false) {
81 if (!$request) $request =& $GLOBALS['request'];
82 if (!isset($args['limit'])) $args['limit'] = 12;
83 $args['format'] = 'box';
84 $args['show_minor'] = false;
85 $args['show_major'] = true;
86 $args['show_deleted'] = 'sometimes';
87 $args['show_all'] = false;
90 $cache = $this->newCache();
94 unset($argscopy['limit']);
95 $this->_args =& $args;
96 $this->_type = $this->getPluginType();
97 $this->_static = false;
100 //list($id, $url) = $this->genUrl($cache, $args);
102 /* NEW: This cache entry needs an update on major changes.
103 * So we should rather use an unique ID, because there will only be
104 * one global cached box.
106 $id = $cache->generateId(serialize(array("RecentChangesCachedBox", $argscopy)));
107 $content = $cache->get($id, 'imagecache');
108 if ($do_save || !$content || !$content['html']) {
110 $plugin = new WikiPlugin_RecentChanges();
111 $title = WikiLink($this->getName(), '', SplitPagename($this->getName()));
112 $changes = $plugin->getChanges($request->_dbi, $args);
114 $this->makeBox($title,
115 $plugin->format($changes, $args));
116 if ($errortext = $this->getError()) {
117 $this->printError($errortext, 'html');
123 $content['args'] = md5($this->_pi);
124 $expire = $this->getExpire($request->_dbi, $content['args'], $request);
125 $cache->save($id, $content, $expire, 'imagecache');
127 if ($content['html'])
128 return $content['html'];
132 // force box cache update on major changes.
133 function box_update($args = false, $request = false, $basepage = false) {
134 $this->box($args, $request, $basepage, true);
138 } // WikiPlugin_RecentChangesCached
145 // c-hanging-comment-ender-p: nil
146 // indent-tabs-mode: nil