2 rcs_id('$Id: RecentChangesCached.php,v 1.5 2008-05-06 19:19:05 rurban Exp $');
4 Copyright 1999, 2000, 2001, 2002 $ThePhpWikiProgrammingTeam
6 This file is part of PhpWiki.
8 PhpWiki is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 PhpWiki is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with PhpWiki; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 // +---------------------------------------------------------------------+
24 // | WikiPluginCached.php |
25 // +---------------------------------------------------------------------+
26 // | Copyright (C) 2002 Johannes Große (Johannes Große) |
27 // | You may copy this code freely under the conditions of the GPL |
28 // +---------------------------------------------------------------------+
30 /* There is a bug in it:
31 When the cache is empty and you safe the wikipages,
32 an immediately created cached output of
33 RecentChanges will at the rss-image-link include
38 require_once "lib/WikiPluginCached.php";
39 require_once "lib/plugin/RecentChanges.php";
41 class WikiPlugin_RecentChangesCached
42 extends WikiPluginCached
44 /* --------- overwrite virtual or abstract methods ---------------- */
45 function getPluginType() {
46 return PLUGIN_CACHED_HTML;
50 return "RecentChangesCached";
53 function getDescription() {
54 return 'Caches output of RecentChanges called with default arguments.';
57 function getVersion() {
58 return preg_replace("/[Revision: $]/", '',
62 function getDefaultArguments() {
63 return WikiPlugin_RecentChanges::getDefaultArguments();
66 function getExpire($dbi, $argarray, $request) {
67 return '+900'; // 15 minutes
70 // We don't go through pi parsing, instead we go directly to the
71 // better plugin methods.
72 function getHtml($dbi, $args, $request, $basepage) {
73 $plugin = new WikiPlugin_RecentChanges();
74 $changes = $plugin->getChanges($dbi, $args);
75 return $plugin->format($changes, $args);
77 $loader = new WikiPluginLoader;
78 return $loader->expandPI('<?plugin RecentChanges '
79 . WikiPluginCached::glueArgs($argarray)
80 . ' ?>', $request, $this, $basepage);
84 // ->box is used to display a fixed-width, narrow version with common header.
85 // Just a limited list of pagenames, without date.
86 // This does not use ->run, to avoid pi construction and deconstruction
87 function box($args = false, $request = false, $basepage = false, $do_save = false) {
88 if (!$request) $request =& $GLOBALS['request'];
89 if (!isset($args['limit'])) $args['limit'] = 15;
90 $args['format'] = 'box';
91 $args['show_minor'] = false;
92 $args['show_major'] = true;
93 $args['show_deleted'] = 'sometimes';
94 $args['show_all'] = false;
97 $cache = $this->newCache();
101 unset($argscopy['limit']);
102 $this->_args =& $args;
103 $this->_type = $this->getPluginType();
104 $this->_static = false;
107 //list($id, $url) = $this->genUrl($cache, $args);
109 /* NEW: This cache entry needs an update on major changes.
110 * So we should rather use an unique ID, because there will only be
111 * one global cached box.
113 $id = $cache->generateId(serialize(array("RecentChangesCachedBox", $argscopy)));
114 $content = $cache->get($id, 'imagecache');
115 if ($do_save || !$content || !$content['html']) {
117 $plugin = new WikiPlugin_RecentChanges();
118 $title = WikiLink($this->getName(), '', SplitPagename($this->getName()));
119 $changes = $plugin->getChanges($request->_dbi, $args);
121 $this->makeBox($title,
122 $plugin->format($changes, $args));
123 if ($errortext = $this->getError()) {
124 $this->printError($errortext, 'html');
130 $content['args'] = md5($this->_pi);
131 $expire = $this->getExpire($request->_dbi, $content['args'], $request);
132 $cache->save($id, $content, $expire, 'imagecache');
134 if ($content['html'])
135 return $content['html'];
139 // force box cache update on major changes.
140 function box_update($args = false, $request = false, $basepage = false) {
141 $this->box($args, $request, $basepage, true);
145 } // WikiPlugin_RecentChangesCached
147 // $Log: not supported by cvs2svn $
148 // Revision 1.4 2004/03/08 18:17:10 rurban
149 // added more WikiGroup::getMembersOf methods, esp. for special groups
150 // fixed $LDAP_SET_OPTIONS
151 // fixed _AuthInfo group methods
153 // Revision 1.3 2003/02/21 23:01:10 dairiki
154 // Fixes to support new $basepage argument of WikiPlugin::run().
156 // Revision 1.2 2003/01/18 22:01:44 carstenklapp
158 // Reformatting & tabs to spaces;
159 // Added copyleft, getVersion, getDescription, rcs_id.
167 // c-hanging-comment-ender-p: nil
168 // indent-tabs-mode: nil