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 along
20 * with PhpWiki; if not, write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 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 function getPluginType()
39 return PLUGIN_CACHED_HTML;
42 function getDescription()
44 return 'Cache output of RecentChanges called with default arguments.';
47 function getDefaultArguments()
49 return WikiPlugin_RecentChanges::getDefaultArguments();
52 function getExpire($dbi, $argarray, $request)
54 return '+900'; // 15 minutes
57 // We don't go through pi parsing, instead we go directly to the
58 // better plugin methods.
61 * @param string $argstr
62 * @param WikiRequest $request
63 * @param string $basepage
66 protected function getHtml($dbi, $args, $request, $basepage)
68 $plugin = new WikiPlugin_RecentChanges();
69 $changes = $plugin->getChanges($dbi, $args);
70 return $plugin->format($changes, $args);
72 $loader = new WikiPluginLoader();
73 return $loader->expandPI('<?plugin RecentChanges '
74 . WikiPluginCached::glueArgs($argarray)
75 . ' ?>', $request, $this, $basepage);
79 protected function getImage($dbi, $argarray, $request)
81 trigger_error('pure virtual', E_USER_ERROR);
84 protected function getMap($dbi, $argarray, $request)
86 trigger_error('pure virtual', E_USER_ERROR);
89 // ->box is used to display a fixed-width, narrow version with common header.
90 // Just a limited list of pagenames, without date.
91 // This does not use ->run, to avoid pi construction and deconstruction
92 function box($args = '', $request = null, $basepage = '', $do_save = false)
94 if (!$request) $request =& $GLOBALS['request'];
95 if (!isset($args['limit'])) $args['limit'] = 12;
96 $args['format'] = 'box';
97 $args['show_minor'] = false;
98 $args['show_major'] = true;
99 $args['show_deleted'] = 'sometimes';
100 $args['show_all'] = false;
103 $cache = $this->newCache();
107 unset($argscopy['limit']);
108 $this->_args =& $args;
109 $this->_type = $this->getPluginType();
110 $this->_static = false;
113 //list($id, $url) = $this->genUrl($cache, $args);
115 /* NEW: This cache entry needs an update on major changes.
116 * So we should rather use an unique ID, because there will only be
117 * one global cached box.
119 $id = $cache->generateId(serialize(array("RecentChangesCachedBox", $argscopy)));
120 $content = $cache->get($id, 'imagecache');
121 if ($do_save || !$content || !$content['html']) {
123 $plugin = new WikiPlugin_RecentChanges();
124 $title = WikiLink($this->getName(), '', SplitPagename($this->getName()));
125 $changes = $plugin->getChanges($request->_dbi, $args);
127 $this->makeBox($title,
128 $plugin->format($changes, $args));
129 if ($errortext = $this->getError()) {
130 $this->printError($errortext, 'html');
136 $content['args'] = md5($this->_pi);
137 $expire = $this->getExpire($request->_dbi, $content['args'], $request);
138 $cache->save($id, $content, $expire, 'imagecache');
140 if ($content['html'])
141 return $content['html'];
145 // force box cache update on major changes.
146 function box_update($args = false, $request = false, $basepage = false)
148 $this->box($args, $request, $basepage, true);
157 // c-hanging-comment-ender-p: nil
158 // indent-tabs-mode: nil