2 rcs_id('$Id: WikiDB.php,v 1.67 2004-06-07 19:12:49 rurban Exp $');
4 //require_once('lib/stdlib.php');
5 require_once('lib/PageType.php');
7 //FIXME: arg on get*Revision to hint that content is wanted.
10 * The classes in the file define the interface to the
14 * @author Geoffrey T. Dairiki <dairiki@dairiki.org>
18 * Force the creation of a new revision.
19 * @see WikiDB_Page::createRevision()
21 define('WIKIDB_FORCE_CREATE', -1);
23 // FIXME: used for debugging only. Comment out if cache does not work
24 define('USECACHE', 1);
27 * Abstract base class for the database used by PhpWiki.
29 * A <tt>WikiDB</tt> is a container for <tt>WikiDB_Page</tt>s which in
30 * turn contain <tt>WikiDB_PageRevision</tt>s.
32 * Conceptually a <tt>WikiDB</tt> contains all possible
33 * <tt>WikiDB_Page</tt>s, whether they have been initialized or not.
34 * Since all possible pages are already contained in a WikiDB, a call
35 * to WikiDB::getPage() will never fail (barring bugs and
36 * e.g. filesystem or SQL database problems.)
38 * Also each <tt>WikiDB_Page</tt> always contains at least one
39 * <tt>WikiDB_PageRevision</tt>: the default content (e.g. "Describe
40 * [PageName] here."). This default content has a version number of
43 * <tt>WikiDB_PageRevision</tt>s have read-only semantics. One can
44 * only create new revisions or delete old ones --- one can not modify
45 * an existing revision.
49 * Open a WikiDB database.
51 * This is a static member function. This function inspects its
52 * arguments to determine the proper subclass of WikiDB to
53 * instantiate, and then it instantiates it.
57 * @param hash $dbparams Database configuration parameters.
58 * Some pertinent paramters are:
61 * <dd> The back-end type. Current supported types are:
64 * <dd> Generic SQL backend based on the PEAR/DB database abstraction
67 * <dd> Dba based backend.
71 * <dd> (Used by the SQL backend.)
72 * The DSN specifying which database to connect to.
75 * <dd> Prefix to be prepended to database table (and file names).
78 * <dd> (Used by the dba backend.)
79 * Which directory db files reside in.
82 * <dd> (Used by the dba backend.)
83 * Timeout in seconds for opening (and obtaining lock) on the
87 * <dd> (Used by the dba backend.)
89 * Which dba handler to use. Good choices are probably either
93 * @return WikiDB A WikiDB object.
95 function open ($dbparams) {
96 $dbtype = $dbparams{'dbtype'};
97 include_once("lib/WikiDB/$dbtype.php");
99 $class = 'WikiDB_' . $dbtype;
100 return new $class ($dbparams);
110 function WikiDB (&$backend, $dbparams) {
111 $this->_backend = &$backend;
112 // don't do the following with the auth_dsn!
113 if (isset($dbparams['auth_dsn'])) return;
115 $this->_cache = new WikiDB_cache($backend);
116 // If the database doesn't yet have a timestamp, initialize it now.
117 if ($this->get('_timestamp') === false)
120 //FIXME: devel checking.
121 //$this->_backend->check();
125 * Get any user-level warnings about this WikiDB.
127 * Some back-ends, e.g. by default create there data files in the
128 * global /tmp directory. We would like to warn the user when this
129 * happens (since /tmp files tend to get wiped periodically.)
130 * Warnings such as these may be communicated from specific
131 * back-ends through this method.
135 * @return string A warning message (or <tt>false</tt> if there is
138 function genericWarnings() {
143 * Close database connection.
145 * The database may no longer be used after it is closed.
147 * Closing a WikiDB invalidates all <tt>WikiDB_Page</tt>s,
148 * <tt>WikiDB_PageRevision</tt>s and <tt>WikiDB_PageIterator</tt>s
149 * which have been obtained from it.
154 $this->_backend->close();
155 $this->_cache->close();
159 * Get a WikiDB_Page from a WikiDB.
161 * A {@link WikiDB} consists of the (infinite) set of all possible pages,
162 * therefore this method never fails.
165 * @param string $pagename Which page to get.
166 * @return WikiDB_Page The requested WikiDB_Page.
168 function getPage($pagename) {
169 static $error_displayed = false;
170 $pagename = (string) $pagename;
172 if ($pagename === '') {
173 if ($error_displayed) return false;
174 $error_displayed = true;
175 if (function_exists("xdebug_get_function_stack"))
176 var_dump(xdebug_get_function_stack());
177 trigger_error("empty pagename",E_USER_WARNING);
181 assert($pagename != '');
183 return new WikiDB_Page($this, $pagename);
187 * Determine whether page exists (in non-default form).
190 * $is_page = $dbi->isWikiPage($pagename);
194 * $page = $dbi->getPage($pagename);
195 * $current = $page->getCurrentRevision();
196 * $is_page = ! $current->hasDefaultContents();
198 * however isWikiPage may be implemented in a more efficient
199 * manner in certain back-ends.
203 * @param string $pagename string Which page to check.
205 * @return boolean True if the page actually exists with
206 * non-default contents in the WikiDataBase.
208 function isWikiPage ($pagename) {
209 $page = $this->getPage($pagename);
210 $current = $page->getCurrentRevision();
211 return ! $current->hasDefaultContents();
215 * Delete page from the WikiDB.
217 * Deletes all revisions of the page from the WikiDB. Also resets
218 * all page meta-data to the default values.
222 * @param string $pagename Name of page to delete.
224 function deletePage($pagename) {
225 $this->_cache->delete_page($pagename);
227 //How to create a RecentChanges entry with explaining summary?
229 $page = $this->getPage($pagename);
230 $current = $page->getCurrentRevision();
231 $meta = $current->_data;
232 $version = $current->getVersion();
233 $meta['summary'] = _("removed");
234 $page->save($current->getPackedContent(), $version + 1, $meta);
239 * Retrieve all pages.
241 * Gets the set of all pages with non-default contents.
243 * FIXME: do we need this? I think so. The simple searches
248 * @param boolean $include_defaulted Normally pages whose most
249 * recent revision has empty content are considered to be
250 * non-existant. Unless $include_defaulted is set to true, those
251 * pages will not be returned.
253 * @return WikiDB_PageIterator A WikiDB_PageIterator which contains all pages
254 * in the WikiDB which have non-default contents.
256 function getAllPages($include_defaulted=false, $sortby=false, $limit=false) {
257 $result = $this->_backend->get_all_pages($include_defaulted,$sortby,$limit);
258 return new WikiDB_PageIterator($this, $result);
262 //function nPages() {
264 // Yes, for paging. Renamed.
265 function numPages($filter=false, $exclude='') {
266 if (method_exists($this->_backend,'numPages'))
267 $count = $this->_backend->numPages($filter,$exclude);
269 $iter = $this->getAllPages();
270 $count = $iter->count();
278 * Search for pages containing (or not containing) certain words
281 * Pages are returned in alphabetical order whenever it is
282 * practical to do so.
284 * FIXME: should titleSearch and fullSearch be combined? I think so.
287 * @param TextSearchQuery $search A TextSearchQuery object
288 * @return WikiDB_PageIterator A WikiDB_PageIterator containing the matching pages.
289 * @see TextSearchQuery
291 function titleSearch($search) {
292 $result = $this->_backend->text_search($search);
293 return new WikiDB_PageIterator($this, $result);
299 * Search for pages containing (or not containing) certain words
300 * in their entire text (this includes the page content and the
303 * Pages are returned in alphabetical order whenever it is
304 * practical to do so.
308 * @param TextSearchQuery $search A TextSearchQuery object.
309 * @return WikiDB_PageIterator A WikiDB_PageIterator containing the matching pages.
310 * @see TextSearchQuery
312 function fullSearch($search) {
313 $result = $this->_backend->text_search($search, 'full_text');
314 return new WikiDB_PageIterator($this, $result);
318 * Find the pages with the greatest hit counts.
320 * Pages are returned in reverse order by hit count.
324 * @param integer $limit The maximum number of pages to return.
325 * Set $limit to zero to return all pages. If $limit < 0, pages will
326 * be sorted in decreasing order of popularity.
328 * @return WikiDB_PageIterator A WikiDB_PageIterator containing the matching
331 function mostPopular($limit = 20, $sortby = '') {
332 // we don't support sortby=mtime here
333 if (strstr($sortby,'mtime'))
335 $result = $this->_backend->most_popular($limit, $sortby);
336 return new WikiDB_PageIterator($this, $result);
340 * Find recent page revisions.
342 * Revisions are returned in reverse order by creation time.
346 * @param hash $params This hash is used to specify various optional
350 * <dd> (integer) At most this many revisions will be returned.
352 * <dd> (integer) Only revisions since this time (unix-timestamp) will be returned.
353 * <dt> include_minor_revisions
354 * <dd> (boolean) Also include minor revisions. (Default is not to.)
355 * <dt> exclude_major_revisions
356 * <dd> (boolean) Don't include non-minor revisions.
357 * (Exclude_major_revisions implies include_minor_revisions.)
358 * <dt> include_all_revisions
359 * <dd> (boolean) Return all matching revisions for each page.
360 * Normally only the most recent matching revision is returned
364 * @return WikiDB_PageRevisionIterator A WikiDB_PageRevisionIterator containing the
365 * matching revisions.
367 function mostRecent($params = false) {
368 $result = $this->_backend->most_recent($params);
369 return new WikiDB_PageRevisionIterator($this, $result);
373 * Call the appropriate backend method.
376 * @param string $from Page to rename
377 * @param string $to New name
378 * @param boolean $updateWikiLinks If the text in all pages should be replaced.
379 * @return boolean true or false
381 function renamePage($from, $to, $updateWikiLinks = false) {
382 assert(is_string($from) && $from != '');
383 assert(is_string($to) && $to != '');
385 if (method_exists($this->_backend,'rename_page')) {
386 $oldpage = $this->getPage($from);
387 $newpage = $this->getPage($to);
388 //update all WikiLinks in existing pages
389 //non-atomic! i.e. if rename fails the links are not undone
390 if ($updateWikiLinks) {
391 require_once('lib/plugin/WikiAdminSearchReplace.php');
392 $links = $oldpage->getBackLinks();
393 while ($linked_page = $links->next()) {
394 WikiPlugin_WikiAdminSearchReplace::replaceHelper($this,$linked_page->getName(),$from,$to);
396 $links = $newpage->getBackLinks();
397 while ($linked_page = $links->next()) {
398 WikiPlugin_WikiAdminSearchReplace::replaceHelper($this,$linked_page->getName(),$from,$to);
401 if ($oldpage->exists() and ! $newpage->exists()) {
402 if ($result = $this->_backend->rename_page($from, $to)) {
403 //create a RecentChanges entry with explaining summary
404 $page = $this->getPage($to);
405 $current = $page->getCurrentRevision();
406 $meta = $current->_data;
407 $version = $current->getVersion();
408 $meta['summary'] = sprintf(_("renamed from %s"),$from);
409 $page->save($current->getPackedContent(), $version + 1, $meta);
411 } elseif (!$oldpage->getCurrentRevision() and !$newpage->exists()) {
412 // if a version 0 exists try it also.
413 $result = $this->_backend->rename_page($from, $to);
416 trigger_error(_("WikiDB::renamePage() not yet implemented for this backend"),E_USER_WARNING);
421 /** Get timestamp when database was last modified.
423 * @return string A string consisting of two integers,
424 * separated by a space. The first is the time in
425 * unix timestamp format, the second is a modification
426 * count for the database.
428 * The idea is that you can cast the return value to an
429 * int to get a timestamp, or you can use the string value
430 * as a good hash for the entire database.
432 function getTimestamp() {
433 $ts = $this->get('_timestamp');
434 return sprintf("%d %d", $ts[0], $ts[1]);
438 * Update the database timestamp.
442 $ts = $this->get('_timestamp');
443 $this->set('_timestamp', array(time(), $ts[1] + 1));
448 * Access WikiDB global meta-data.
450 * NOTE: this is currently implemented in a hackish and
451 * not very efficient manner.
455 * @param string $key Which meta data to get.
456 * Some reserved meta-data keys are:
458 * <dt>'_timestamp' <dd> Data used by getTimestamp().
461 * @return scalar The requested value, or false if the requested data
465 if (!$key || $key[0] == '%')
468 * Hack Alert: We can use any page (existing or not) to store
469 * this data (as long as we always use the same one.)
471 $gd = $this->getPage('global_data');
472 $data = $gd->get('__global');
474 if ($data && isset($data[$key]))
481 * Set global meta-data.
483 * NOTE: this is currently implemented in a hackish and
484 * not very efficient manner.
489 * @param string $key Meta-data key to set.
490 * @param string $newval New value.
492 function set($key, $newval) {
493 if (!$key || $key[0] == '%')
496 $gd = $this->getPage('global_data');
498 $data = $gd->get('__global');
505 $data[$key] = $newval;
507 $gd->set('__global', $data);
510 // simple select or create/update queries
511 function genericQuery($sql) {
513 if ($DBParams['dbtype'] == 'SQL') {
514 $result = $this->_backend->_dbh->query($sql);
515 if (DB::isError($result)) {
516 $msg = $result->getMessage();
517 trigger_error("SQL Error: ".DB::errorMessage($result), E_USER_WARNING);
522 } elseif ($DBParams['dbtype'] == 'ADODB') {
523 if (!($result = $this->_backend->_dbh->Execute($sql))) {
524 trigger_error("SQL Error: ".$this->_backend->_dbh->ErrorMsg(), E_USER_WARNING);
533 function getParam($param) {
535 if (isset($DBParams[$param])) return $DBParams[$param];
536 elseif ($param == 'prefix') return '';
540 function getAuthParam($param) {
541 global $DBAuthParams;
542 if (isset($DBAuthParams[$param])) return $DBAuthParams[$param];
543 elseif ($param == 'USER_AUTH_ORDER') return $GLOBALS['USER_AUTH_ORDER'];
544 elseif ($param == 'USER_AUTH_POLICY') return $GLOBALS['USER_AUTH_POLICY'];
551 * An abstract base class which representing a wiki-page within a
554 * A WikiDB_Page contains a number (at least one) of
555 * WikiDB_PageRevisions.
559 function WikiDB_Page(&$wikidb, $pagename) {
560 $this->_wikidb = &$wikidb;
561 $this->_pagename = $pagename;
563 if (!(is_string($pagename) and $pagename != '')) {
564 if (function_exists("xdebug_get_function_stack")) {
565 echo "xdebug_get_function_stack(): "; var_dump(xdebug_get_function_stack());
568 trigger_error("empty pagename",E_USER_WARNING);
571 } else assert(is_string($pagename) and $pagename != '');
575 * Get the name of the wiki page.
579 * @return string The page name.
582 return $this->_pagename;
586 $current = $this->getCurrentRevision();
587 return ! $current->hasDefaultContents();
591 * Delete an old revision of a WikiDB_Page.
593 * Deletes the specified revision of the page.
594 * It is a fatal error to attempt to delete the current revision.
598 * @param integer $version Which revision to delete. (You can also
599 * use a WikiDB_PageRevision object here.)
601 function deleteRevision($version) {
602 $backend = &$this->_wikidb->_backend;
603 $cache = &$this->_wikidb->_cache;
604 $pagename = &$this->_pagename;
606 $version = $this->_coerce_to_version($version);
610 $backend->lock(array('page','version'));
611 $latestversion = $cache->get_latest_version($pagename);
612 if ($latestversion && $version == $latestversion) {
613 $backend->unlock(array('page','version'));
614 trigger_error(sprintf("Attempt to delete most recent revision of '%s'",
615 $pagename), E_USER_ERROR);
619 $cache->delete_versiondata($pagename, $version);
620 $backend->unlock(array('page','version'));
624 * Delete a revision, or possibly merge it with a previous
628 * Suppose an author make a (major) edit to a page. Shortly
629 * after that the same author makes a minor edit (e.g. to fix
630 * spelling mistakes he just made.)
632 * Now some time later, where cleaning out old saved revisions,
633 * and would like to delete his minor revision (since there's
634 * really no point in keeping minor revisions around for a long
637 * Note that the text after the minor revision probably represents
638 * what the author intended to write better than the text after
639 * the preceding major edit.
641 * So what we really want to do is merge the minor edit with the
644 * We will only do this when:
646 * <li>The revision being deleted is a minor one, and
647 * <li>It has the same author as the immediately preceding revision.
650 function mergeRevision($version) {
651 $backend = &$this->_wikidb->_backend;
652 $cache = &$this->_wikidb->_cache;
653 $pagename = &$this->_pagename;
655 $version = $this->_coerce_to_version($version);
659 $backend->lock(array('version'));
660 $latestversion = $backend->get_latest_version($pagename);
661 if ($latestversion && $version == $latestversion) {
662 $backend->unlock(array('version'));
663 trigger_error(sprintf("Attempt to merge most recent revision of '%s'",
664 $pagename), E_USER_ERROR);
668 $versiondata = $cache->get_versiondata($pagename, $version, true);
670 // Not there? ... we're done!
671 $backend->unlock(array('version'));
675 if ($versiondata['is_minor_edit']) {
676 $previous = $backend->get_previous_version($pagename, $version);
678 $prevdata = $cache->get_versiondata($pagename, $previous);
679 if ($prevdata['author_id'] == $versiondata['author_id']) {
680 // This is a minor revision, previous version is
681 // by the same author. We will merge the
683 $cache->update_versiondata($pagename, $previous,
684 array('%content' => $versiondata['%content'],
685 '_supplanted' => $versiondata['_supplanted']));
690 $cache->delete_versiondata($pagename, $version);
691 $backend->unlock(array('version'));
696 * Create a new revision of a {@link WikiDB_Page}.
700 * @param int $version Version number for new revision.
701 * To ensure proper serialization of edits, $version must be
702 * exactly one higher than the current latest version.
703 * (You can defeat this check by setting $version to
704 * {@link WIKIDB_FORCE_CREATE} --- not usually recommended.)
706 * @param string $content Contents of new revision.
708 * @param hash $metadata Metadata for new revision.
709 * All values in the hash should be scalars (strings or integers).
711 * @param array $links List of pagenames which this page links to.
713 * @return WikiDB_PageRevision Returns the new WikiDB_PageRevision object. If
714 * $version was incorrect, returns false
716 function createRevision($version, &$content, $metadata, $links) {
717 $backend = &$this->_wikidb->_backend;
718 $cache = &$this->_wikidb->_cache;
719 $pagename = &$this->_pagename;
721 $backend->lock(array('version','page','recent','links','nonempty'));
723 $latestversion = $backend->get_latest_version($pagename);
724 $newversion = $latestversion + 1;
725 assert($newversion >= 1);
727 if ($version != WIKIDB_FORCE_CREATE && $version != $newversion) {
728 $backend->unlock(array('version','page','recent','links','nonempty'));
734 foreach ($data as $key => $val) {
735 if (empty($val) || $key[0] == '_' || $key[0] == '%')
739 assert(!empty($data['author']));
740 if (empty($data['author_id']))
741 @$data['author_id'] = $data['author'];
743 if (empty($data['mtime']))
744 $data['mtime'] = time();
746 if ($latestversion) {
747 // Ensure mtimes are monotonic.
748 $pdata = $cache->get_versiondata($pagename, $latestversion);
749 if ($data['mtime'] < $pdata['mtime']) {
750 trigger_error(sprintf(_("%s: Date of new revision is %s"),
751 $pagename,"'non-monotonic'"),
753 $data['orig_mtime'] = $data['mtime'];
754 $data['mtime'] = $pdata['mtime'];
757 // FIXME: use (possibly user specified) 'mtime' time or
759 $cache->update_versiondata($pagename, $latestversion,
760 array('_supplanted' => $data['mtime']));
763 $data['%content'] = &$content;
765 $cache->set_versiondata($pagename, $newversion, $data);
767 //$cache->update_pagedata($pagename, array(':latestversion' => $newversion,
768 //':deleted' => empty($content)));
770 $backend->set_links($pagename, $links);
772 $backend->unlock(array('version','page','recent','links','nonempty'));
774 return new WikiDB_PageRevision($this->_wikidb, $pagename, $newversion,
778 /** A higher-level interface to createRevision.
780 * This takes care of computing the links, and storing
781 * a cached version of the transformed wiki-text.
783 * @param string $wikitext The page content.
785 * @param int $version Version number for new revision.
786 * To ensure proper serialization of edits, $version must be
787 * exactly one higher than the current latest version.
788 * (You can defeat this check by setting $version to
789 * {@link WIKIDB_FORCE_CREATE} --- not usually recommended.)
791 * @param hash $meta Meta-data for new revision.
793 function save($wikitext, $version, $meta) {
794 $formatted = new TransformedText($this, $wikitext, $meta);
795 $type = $formatted->getType();
796 $meta['pagetype'] = $type->getName();
797 $links = $formatted->getWikiPageLinks();
799 $backend = &$this->_wikidb->_backend;
800 $newrevision = $this->createRevision($version, $wikitext, $meta, $links);
802 if (!defined('WIKIDB_NOCACHE_MARKUP') or !WIKIDB_NOCACHE_MARKUP)
803 $this->set('_cached_html', $formatted->pack());
805 // FIXME: probably should have some global state information
806 // in the backend to control when to optimize.
808 // We're doing this here rather than in createRevision because
809 // postgres can't optimize while locked.
810 if (time() % 50 == 0) {
811 if ($backend->optimize())
812 trigger_error(sprintf(_("Optimizing %s"),'backend'), E_USER_NOTICE);
815 /* Generate notification emails? */
816 if (isa($newrevision, 'wikidb_pagerevision')) {
817 // Save didn't fail because of concurrent updates.
818 $notify = $this->_wikidb->get('notify');
819 if (!empty($notify) and is_array($notify)) {
820 list($emails,$userids) = $this->getPageChangeEmails($notify);
822 $this->sendPageChangeNotification($wikitext, $version, $meta, $emails, $userids);
826 $newrevision->_transformedContent = $formatted;
830 function getPageChangeEmails($notify) {
831 $emails = array(); $userids = array();
832 foreach ($notify as $page => $users) {
833 if (glob_match($page,$this->_pagename)) {
834 foreach ($users as $userid => $user) {
835 if (!empty($user['verified']) and !empty($user['email'])) {
836 $emails[] = $user['email'];
837 $userids[] = $userid;
838 } elseif (!empty($user['email'])) {
840 // do a dynamic emailVerified check update
841 $u = $request->getUser();
842 if ($u->UserName() == $userid) {
843 if ($request->_prefs->get('emailVerified')) {
844 $emails[] = $user['email'];
845 $userids[] = $userid;
846 $notify[$page][$userid]['verified'] = 1;
847 $request->_dbi->set('notify',$notify);
850 $u = WikiUser($userid);
851 if ($u->_prefs->get('emailVerified')) {
852 $emails[] = $user['email'];
853 $userids[] = $userid;
854 $notify[$page][$userid]['verified'] = 1;
855 $request->_dbi->set('notify',$notify);
858 // ignore verification
861 if (!in_array($user['email'],$emails))
862 $emails[] = $user['email'];
869 $emails = array_unique($emails);
870 $userids = array_unique($userids);
871 return array($emails,$userids);
874 function sendPageChangeNotification(&$wikitext, $version, $meta, $emails, $userids) {
875 $backend = &$this->_wikidb->_backend;
876 $subject = _("Page change").' '.$this->_pagename;
877 $previous = $backend->get_previous_version($this->_pagename, $version);
878 if (!isset($meta['mtime'])) $meta['mtime'] = time();
880 $difflink = WikiURL($this->_pagename,array('action'=>'diff'),true);
881 $cache = &$this->_wikidb->_cache;
882 $this_content = explode("\n", $wikitext);
883 $prevdata = $cache->get_versiondata($this->_pagename, $previous, true);
884 if (empty($prevdata['%content']))
885 $prevdata = $backend->get_versiondata($this->_pagename, $previous, true);
886 $other_content = explode("\n", $prevdata['%content']);
888 include_once("lib/diff.php");
889 $diff2 = new Diff($other_content, $this_content);
890 $context_lines = max(4, count($other_content) + 1,
891 count($this_content) + 1);
892 $fmt = new UnifiedDiffFormatter($context_lines);
893 $content = $this->_pagename . " " . $previous . " " . Iso8601DateTime($prevdata['mtime']) . "\n";
894 $content .= $this->_pagename . " " . $version . " " . Iso8601DateTime($meta['mtime']) . "\n";
895 $content .= $fmt->format($diff2);
898 $difflink = WikiURL($this->_pagename,array(),true);
899 $content = $this->_pagename . " " . $version . " " . Iso8601DateTime($meta['mtime']) . "\n";
900 $content .= _("New Page");
902 $editedby = sprintf(_("Edited by: %s"), $meta['author']);
903 $emails = join(',',$emails);
904 if (mail($emails,"[".WIKI_NAME."] ".$subject,
909 trigger_error(sprintf(_("PageChange Notification of %s sent to %s"),
910 $this->_pagename, join(',',$userids)), E_USER_NOTICE);
912 trigger_error(sprintf(_("PageChange Notification Error: Couldn't send %s to %s"),
913 $this->_pagename, join(',',$userids)), E_USER_WARNING);
917 * Get the most recent revision of a page.
921 * @return WikiDB_PageRevision The current WikiDB_PageRevision object.
923 function getCurrentRevision() {
924 $backend = &$this->_wikidb->_backend;
925 $cache = &$this->_wikidb->_cache;
926 $pagename = &$this->_pagename;
928 // Prevent deadlock in case of memory exhausted errors
929 // Pure selection doesn't really need locking here.
931 // I know it would be better, but with lots of pages this deadlock is more
932 // severe than occasionally get not the latest revision.
934 $version = $cache->get_latest_version($pagename);
935 $revision = $this->getRevision($version);
936 //$backend->unlock();
942 * Get a specific revision of a WikiDB_Page.
946 * @param integer $version Which revision to get.
948 * @return WikiDB_PageRevision The requested WikiDB_PageRevision object, or
949 * false if the requested revision does not exist in the {@link WikiDB}.
950 * Note that version zero of any page always exists.
952 function getRevision($version) {
953 $cache = &$this->_wikidb->_cache;
954 $pagename = &$this->_pagename;
956 if (! $version ) // 0 or false
957 return new WikiDB_PageRevision($this->_wikidb, $pagename, 0);
959 assert($version > 0);
960 $vdata = $cache->get_versiondata($pagename, $version);
963 return new WikiDB_PageRevision($this->_wikidb, $pagename, $version,
968 * Get previous page revision.
970 * This method find the most recent revision before a specified
975 * @param integer $version Find most recent revision before this version.
976 * You can also use a WikiDB_PageRevision object to specify the $version.
978 * @return WikiDB_PageRevision The requested WikiDB_PageRevision object, or false if the
979 * requested revision does not exist in the {@link WikiDB}. Note that
980 * unless $version is greater than zero, a revision (perhaps version zero,
981 * the default revision) will always be found.
983 function getRevisionBefore($version) {
984 $backend = &$this->_wikidb->_backend;
985 $pagename = &$this->_pagename;
987 $version = $this->_coerce_to_version($version);
992 $previous = $backend->get_previous_version($pagename, $version);
993 $revision = $this->getRevision($previous);
994 //$backend->unlock();
1000 * Get all revisions of the WikiDB_Page.
1002 * This does not include the version zero (default) revision in the
1003 * returned revision set.
1005 * @return WikiDB_PageRevisionIterator A
1006 * WikiDB_PageRevisionIterator containing all revisions of this
1007 * WikiDB_Page in reverse order by version number.
1009 function getAllRevisions() {
1010 $backend = &$this->_wikidb->_backend;
1011 $revs = $backend->get_all_revisions($this->_pagename);
1012 return new WikiDB_PageRevisionIterator($this->_wikidb, $revs);
1016 * Find pages which link to or are linked from a page.
1020 * @param boolean $reversed Which links to find: true for backlinks (default).
1022 * @return WikiDB_PageIterator A WikiDB_PageIterator containing
1023 * all matching pages.
1025 function getLinks($reversed = true) {
1026 $backend = &$this->_wikidb->_backend;
1027 $result = $backend->get_links($this->_pagename, $reversed);
1028 return new WikiDB_PageIterator($this->_wikidb, $result);
1032 * All Links from other pages to this page.
1034 function getBackLinks() {
1035 return $this->getLinks(true);
1038 * Forward Links: All Links from this page to other pages.
1040 function getPageLinks() {
1041 return $this->getLinks(false);
1045 * Access WikiDB_Page meta-data.
1049 * @param string $key Which meta data to get.
1050 * Some reserved meta-data keys are:
1052 * <dt>'locked'<dd> Is page locked?
1053 * <dt>'hits' <dd> Page hit counter.
1054 * <dt>'pref' <dd> Users preferences, stored in homepages.
1055 * <dt>'owner' <dd> Default: first author_id. We might add a group with a dot here:
1056 * E.g. "owner.users"
1057 * <dt>'perm' <dd> Permission flag to authorize read/write/execution of
1058 * page-headers and content.
1059 * <dt>'score' <dd> Page score (not yet implement, do we need?)
1062 * @return scalar The requested value, or false if the requested data
1065 function get($key) {
1066 $cache = &$this->_wikidb->_cache;
1067 if (!$key || $key[0] == '%')
1069 $data = $cache->get_pagedata($this->_pagename);
1070 return isset($data[$key]) ? $data[$key] : false;
1074 * Get all the page meta-data as a hash.
1076 * @return hash The page meta-data.
1078 function getMetaData() {
1079 $cache = &$this->_wikidb->_cache;
1080 $data = $cache->get_pagedata($this->_pagename);
1082 foreach ($data as $key => $val) {
1083 if (/*!empty($val) &&*/ $key[0] != '%')
1090 * Set page meta-data.
1095 * @param string $key Meta-data key to set.
1096 * @param string $newval New value.
1098 function set($key, $newval) {
1099 $cache = &$this->_wikidb->_cache;
1100 $pagename = &$this->_pagename;
1102 assert($key && $key[0] != '%');
1104 $data = $cache->get_pagedata($pagename);
1106 if (!empty($newval)) {
1107 if (!empty($data[$key]) && $data[$key] == $newval)
1108 return; // values identical, skip update.
1111 if (empty($data[$key]))
1112 return; // values identical, skip update.
1115 $cache->update_pagedata($pagename, array($key => $newval));
1119 * Increase page hit count.
1121 * FIXME: IS this needed? Probably not.
1123 * This is a convenience function.
1124 * <pre> $page->increaseHitCount(); </pre>
1125 * is functionally identical to
1126 * <pre> $page->set('hits',$page->get('hits')+1); </pre>
1128 * Note that this method may be implemented in more efficient ways
1129 * in certain backends.
1133 function increaseHitCount() {
1134 @$newhits = $this->get('hits') + 1;
1135 $this->set('hits', $newhits);
1139 * Return a string representation of the WikiDB_Page
1141 * This is really only for debugging.
1145 * @return string Printable representation of the WikiDB_Page.
1147 function asString () {
1149 printf("[%s:%s\n", get_class($this), $this->getName());
1150 print_r($this->getMetaData());
1152 $strval = ob_get_contents();
1160 * @param integer_or_object $version_or_pagerevision
1161 * Takes either the version number (and int) or a WikiDB_PageRevision
1163 * @return integer The version number.
1165 function _coerce_to_version($version_or_pagerevision) {
1166 if (method_exists($version_or_pagerevision, "getContent"))
1167 $version = $version_or_pagerevision->getVersion();
1169 $version = (int) $version_or_pagerevision;
1171 assert($version >= 0);
1175 function isUserPage ($include_empty = true) {
1176 if ($include_empty) {
1177 $current = $this->getCurrentRevision();
1178 if ($current->hasDefaultContents()) {
1182 return $this->get('pref') ? true : false;
1185 // May be empty. Either the stored owner (/Chown), or the first authorized author
1186 function getOwner() {
1187 if ($owner = $this->get('owner'))
1188 return ($owner == "The PhpWiki programming team") ? ADMIN_USER : $owner;
1189 // check all revisions forwards for the first author_id
1190 $backend = &$this->_wikidb->_backend;
1191 $pagename = &$this->_pagename;
1192 $latestversion = $backend->get_latest_version($pagename);
1193 for ($v=1; $v <= $latestversion; $v++) {
1194 $rev = $this->getRevision($v);
1195 if ($rev and $owner = $rev->get('author_id')) {
1196 return ($owner == "The PhpWiki programming team") ? ADMIN_USER : $owner;
1202 // The authenticated author of the first revision or empty if not authenticated then.
1203 function getCreator() {
1204 if ($current = $this->getRevision(1)) return $current->get('author_id');
1211 * This class represents a specific revision of a WikiDB_Page within
1214 * A WikiDB_PageRevision has read-only semantics. You may only create
1215 * new revisions (and delete old ones) --- you cannot modify existing
1218 class WikiDB_PageRevision
1220 var $_transformedContent = false; // set by WikiDB_Page::save()
1222 function WikiDB_PageRevision(&$wikidb, $pagename, $version,
1223 $versiondata = false)
1225 $this->_wikidb = &$wikidb;
1226 $this->_pagename = $pagename;
1227 $this->_version = $version;
1228 $this->_data = $versiondata ? $versiondata : array();
1232 * Get the WikiDB_Page which this revision belongs to.
1236 * @return WikiDB_Page The WikiDB_Page which this revision belongs to.
1238 function getPage() {
1239 return new WikiDB_Page($this->_wikidb, $this->_pagename);
1243 * Get the version number of this revision.
1247 * @return integer The version number of this revision.
1249 function getVersion() {
1250 return $this->_version;
1254 * Determine whether this revision has defaulted content.
1256 * The default revision (version 0) of each page, as well as any
1257 * pages which are created with empty content have their content
1258 * defaulted to something like:
1260 * Describe [ThisPage] here.
1265 * @return boolean Returns true if the page has default content.
1267 function hasDefaultContents() {
1268 $data = &$this->_data;
1269 return empty($data['%content']);
1273 * Get the content as an array of lines.
1277 * @return array An array of lines.
1278 * The lines should contain no trailing white space.
1280 function getContent() {
1281 return explode("\n", $this->getPackedContent());
1285 * Get the pagename of the revision.
1289 * @return string pagename.
1291 function getPageName() {
1292 return $this->_pagename;
1296 * Determine whether revision is the latest.
1300 * @return boolean True iff the revision is the latest (most recent) one.
1302 function isCurrent() {
1303 if (!isset($this->_iscurrent)) {
1304 $page = $this->getPage();
1305 $current = $page->getCurrentRevision();
1306 $this->_iscurrent = $this->getVersion() == $current->getVersion();
1308 return $this->_iscurrent;
1312 * Get the transformed content of a page.
1314 * @param string $pagetype Override the page-type of the revision.
1316 * @return object An XmlContent-like object containing the page transformed
1319 function getTransformedContent($pagetype_override=false) {
1320 $backend = &$this->_wikidb->_backend;
1322 if ($pagetype_override) {
1323 // Figure out the normal page-type for this page.
1324 $type = PageType::GetPageType($this->get('pagetype'));
1325 if ($type->getName() == $pagetype_override)
1326 $pagetype_override = false; // Not really an override...
1329 if ($pagetype_override) {
1330 // Overriden page type, don't cache (or check cache).
1331 return new TransformedText($this->getPage(),
1332 $this->getPackedContent(),
1333 $this->getMetaData(),
1334 $pagetype_override);
1337 $possibly_cache_results = true;
1339 if (defined('WIKIDB_NOCACHE_MARKUP') and WIKIDB_NOCACHE_MARKUP) {
1340 if (WIKIDB_NOCACHE_MARKUP == 'purge') {
1341 // flush cache for this page.
1342 $page = $this->getPage();
1343 $page->set('_cached_html', false);
1345 $possibly_cache_results = false;
1347 elseif (!$this->_transformedContent) {
1349 if ($this->isCurrent()) {
1350 $page = $this->getPage();
1351 $this->_transformedContent = TransformedText::unpack($page->get('_cached_html'));
1354 $possibly_cache_results = false;
1356 //$backend->unlock();
1359 if (!$this->_transformedContent) {
1360 $this->_transformedContent
1361 = new TransformedText($this->getPage(),
1362 $this->getPackedContent(),
1363 $this->getMetaData());
1365 if ($possibly_cache_results) {
1366 // If we're still the current version, cache the transfomed page.
1368 if ($this->isCurrent()) {
1369 $page->set('_cached_html', $this->_transformedContent->pack());
1371 //$backend->unlock();
1375 return $this->_transformedContent;
1379 * Get the content as a string.
1383 * @return string The page content.
1384 * Lines are separated by new-lines.
1386 function getPackedContent() {
1387 $data = &$this->_data;
1390 if (empty($data['%content'])) {
1391 include_once('lib/InlineParser.php');
1392 // A feature similar to taglines at http://www.wlug.org.nz/
1393 // Lib from http://www.aasted.org/quote/
1394 if (defined('FORTUNE_DIR') and is_dir(FORTUNE_DIR)) {
1395 include_once("lib/fortune.php");
1396 $fortune = new Fortune();
1397 $quote = str_replace("\n<br>","\n", $fortune->quoteFromDir(FORTUNE_DIR));
1398 return sprintf("<verbatim>\n%s</verbatim>\n\n"._("Describe %s here."),
1399 $quote, "[" . WikiEscape($this->_pagename) . "]");
1401 // Replace empty content with default value.
1402 return sprintf(_("Describe %s here."),
1403 "[" . WikiEscape($this->_pagename) . "]");
1406 // There is (non-default) content.
1407 assert($this->_version > 0);
1409 if (!is_string($data['%content'])) {
1410 // Content was not provided to us at init time.
1411 // (This is allowed because for some backends, fetching
1412 // the content may be expensive, and often is not wanted
1415 // In any case, now we need to get it.
1416 $data['%content'] = $this->_get_content();
1417 assert(is_string($data['%content']));
1420 return $data['%content'];
1423 function _get_content() {
1424 $cache = &$this->_wikidb->_cache;
1425 $pagename = $this->_pagename;
1426 $version = $this->_version;
1428 assert($version > 0);
1430 $newdata = $cache->get_versiondata($pagename, $version, true);
1432 assert(is_string($newdata['%content']));
1433 return $newdata['%content'];
1436 // else revision has been deleted... What to do?
1437 return __sprintf("Oops! Revision %s of %s seems to have been deleted!",
1438 $version, $pagename);
1443 * Get meta-data for this revision.
1448 * @param string $key Which meta-data to access.
1450 * Some reserved revision meta-data keys are:
1452 * <dt> 'mtime' <dd> Time this revision was created (seconds since midnight Jan 1, 1970.)
1453 * The 'mtime' meta-value is normally set automatically by the database
1454 * backend, but it may be specified explicitly when creating a new revision.
1456 * <dd> To ensure consistency of RecentChanges, the mtimes of the versions
1457 * of a page must be monotonically increasing. If an attempt is
1458 * made to create a new revision with an mtime less than that of
1459 * the preceeding revision, the new revisions timestamp is force
1460 * to be equal to that of the preceeding revision. In that case,
1461 * the originally requested mtime is preserved in 'orig_mtime'.
1462 * <dt> '_supplanted' <dd> Time this revision ceased to be the most recent.
1463 * This meta-value is <em>always</em> automatically maintained by the database
1464 * backend. (It is set from the 'mtime' meta-value of the superceding
1465 * revision.) '_supplanted' has a value of 'false' for the current revision.
1467 * FIXME: this could be refactored:
1469 * <dd> Author of the page (as he should be reported in, e.g. RecentChanges.)
1471 * <dd> Authenticated author of a page. This is used to identify
1472 * the distinctness of authors when cleaning old revisions from
1474 * <dt> 'is_minor_edit' <dd> Set if change was marked as a minor revision by the author.
1475 * <dt> 'summary' <dd> Short change summary entered by page author.
1478 * Meta-data keys must be valid C identifers (they have to start with a letter
1479 * or underscore, and can contain only alphanumerics and underscores.)
1481 * @return string The requested value, or false if the requested value
1484 function get($key) {
1485 if (!$key || $key[0] == '%')
1487 $data = &$this->_data;
1488 return isset($data[$key]) ? $data[$key] : false;
1492 * Get all the revision page meta-data as a hash.
1494 * @return hash The revision meta-data.
1496 function getMetaData() {
1498 foreach ($this->_data as $key => $val) {
1499 if (!empty($val) && $key[0] != '%')
1507 * Return a string representation of the revision.
1509 * This is really only for debugging.
1513 * @return string Printable representation of the WikiDB_Page.
1515 function asString () {
1517 printf("[%s:%d\n", get_class($this), $this->get('version'));
1518 print_r($this->_data);
1519 echo $this->getPackedContent() . "\n]\n";
1520 $strval = ob_get_contents();
1528 * Class representing a sequence of WikiDB_Pages.
1529 * TODO: Enhance to php5 iterators
1531 class WikiDB_PageIterator
1533 function WikiDB_PageIterator(&$wikidb, &$pages) {
1534 $this->_pages = $pages;
1535 $this->_wikidb = &$wikidb;
1539 return $this->_pages->count();
1543 * Get next WikiDB_Page in sequence.
1547 * @return WikiDB_Page The next WikiDB_Page in the sequence.
1550 if ( ! ($next = $this->_pages->next()) )
1553 $pagename = &$next['pagename'];
1555 trigger_error('empty pagename in WikiDB_PageIterator::next()', E_USER_WARNING);
1559 if (isset($next['pagedata']))
1560 $this->_wikidb->_cache->cache_data($next);
1562 return new WikiDB_Page($this->_wikidb, $pagename);
1566 * Release resources held by this iterator.
1568 * The iterator may not be used after free() is called.
1570 * There is no need to call free(), if next() has returned false.
1571 * (I.e. if you iterate through all the pages in the sequence,
1572 * you do not need to call free() --- you only need to call it
1573 * if you stop before the end of the iterator is reached.)
1578 $this->_pages->free();
1581 function asArray() {
1583 while ($page = $this->next())
1589 // Not yet used and problematic. Order should be set in the query, not afterwards.
1590 // See PageList::sortby
1591 function setSortby ($arg = false) {
1593 $arg = @$_GET['sortby'];
1595 $sortby = substr($arg,1);
1596 $order = substr($arg,0,1)=='+' ? 'ASC' : 'DESC';
1599 if (is_array($arg)) { // array('mtime' => 'desc')
1606 // available column types to sort by:
1607 // todo: we must provide access methods for the generic dumb/iterator
1608 $this->_types = explode(',','pagename,mtime,hits,version,author,locked,minor,markup');
1609 if (in_array($sortby,$this->_types))
1610 $this->_options['sortby'] = $sortby;
1612 trigger_error(sprintf("Argument %s '%s' ignored",'sortby',$sortby), E_USER_WARNING);
1613 if (in_array(strtoupper($order),'ASC','DESC'))
1614 $this->_options['order'] = strtoupper($order);
1616 trigger_error(sprintf("Argument %s '%s' ignored",'order',$order), E_USER_WARNING);
1622 * A class which represents a sequence of WikiDB_PageRevisions.
1623 * TODO: Enhance to php5 iterators
1625 class WikiDB_PageRevisionIterator
1627 function WikiDB_PageRevisionIterator(&$wikidb, &$revisions) {
1628 $this->_revisions = $revisions;
1629 $this->_wikidb = &$wikidb;
1633 return $this->_revisions->count();
1637 * Get next WikiDB_PageRevision in sequence.
1641 * @return WikiDB_PageRevision
1642 * The next WikiDB_PageRevision in the sequence.
1645 if ( ! ($next = $this->_revisions->next()) )
1648 $this->_wikidb->_cache->cache_data($next);
1650 $pagename = $next['pagename'];
1651 $version = $next['version'];
1652 $versiondata = $next['versiondata'];
1654 if (!(is_string($pagename) and $pagename != '')) {
1655 trigger_error("empty pagename",E_USER_WARNING);
1658 } else assert(is_string($pagename) and $pagename != '');
1660 if (!is_array($versiondata)) {
1661 trigger_error("empty versiondata",E_USER_WARNING);
1664 } else assert(is_array($versiondata));
1666 if (!($version > 0)) {
1667 trigger_error("invalid version",E_USER_WARNING);
1670 } else assert($version > 0);
1672 return new WikiDB_PageRevision($this->_wikidb, $pagename, $version,
1677 * Release resources held by this iterator.
1679 * The iterator may not be used after free() is called.
1681 * There is no need to call free(), if next() has returned false.
1682 * (I.e. if you iterate through all the revisions in the sequence,
1683 * you do not need to call free() --- you only need to call it
1684 * if you stop before the end of the iterator is reached.)
1689 $this->_revisions->free();
1692 function asArray() {
1694 while ($rev = $this->next())
1703 * Data cache used by WikiDB.
1705 * FIXME: Maybe rename this to caching_backend (or some such).
1711 // FIXME: beautify versiondata cache. Cache only limited data?
1713 function WikiDB_cache (&$backend) {
1714 $this->_backend = &$backend;
1716 $this->_pagedata_cache = array();
1717 $this->_versiondata_cache = array();
1718 array_push ($this->_versiondata_cache, array());
1719 $this->_glv_cache = array();
1723 $this->_pagedata_cache = false;
1724 $this->_versiondata_cache = false;
1725 $this->_glv_cache = false;
1728 function get_pagedata($pagename) {
1729 assert(is_string($pagename) && $pagename != '');
1730 $cache = &$this->_pagedata_cache;
1732 if (!isset($cache[$pagename]) || !is_array($cache[$pagename])) {
1733 $cache[$pagename] = $this->_backend->get_pagedata($pagename);
1734 if (empty($cache[$pagename]))
1735 $cache[$pagename] = array();
1738 return $cache[$pagename];
1741 function update_pagedata($pagename, $newdata) {
1742 assert(is_string($pagename) && $pagename != '');
1744 $this->_backend->update_pagedata($pagename, $newdata);
1746 if (is_array($this->_pagedata_cache[$pagename])) {
1747 $cachedata = &$this->_pagedata_cache[$pagename];
1748 foreach($newdata as $key => $val)
1749 $cachedata[$key] = $val;
1753 function invalidate_cache($pagename) {
1754 unset ($this->_pagedata_cache[$pagename]);
1755 unset ($this->_versiondata_cache[$pagename]);
1756 unset ($this->_glv_cache[$pagename]);
1759 function delete_page($pagename) {
1760 $this->_backend->delete_page($pagename);
1761 unset ($this->_pagedata_cache[$pagename]);
1762 unset ($this->_glv_cache[$pagename]);
1766 function cache_data($data) {
1767 if (isset($data['pagedata']))
1768 $this->_pagedata_cache[$data['pagename']] = $data['pagedata'];
1771 function get_versiondata($pagename, $version, $need_content = false) {
1772 // FIXME: Seriously ugly hackage
1773 if (defined('USECACHE') and USECACHE) { //temporary - for debugging
1774 assert(is_string($pagename) && $pagename != '');
1775 // there is a bug here somewhere which results in an assertion failure at line 105
1776 // of ArchiveCleaner.php It goes away if we use the next line.
1777 $need_content = true;
1778 $nc = $need_content ? '1':'0';
1779 $cache = &$this->_versiondata_cache;
1780 if (!isset($cache[$pagename][$version][$nc])||
1781 !(is_array ($cache[$pagename])) || !(is_array ($cache[$pagename][$version]))) {
1782 $cache[$pagename][$version][$nc] =
1783 $this->_backend->get_versiondata($pagename,$version, $need_content);
1784 // If we have retrieved all data, we may as well set the cache for $need_content = false
1786 $cache[$pagename][$version]['0'] = $cache[$pagename][$version]['1'];
1789 $vdata = $cache[$pagename][$version][$nc];
1791 $vdata = $this->_backend->get_versiondata($pagename, $version, $need_content);
1794 if ($vdata && !empty($vdata['%pagedata']))
1795 $this->_pagedata_cache[$pagename] = $vdata['%pagedata'];
1799 function set_versiondata($pagename, $version, $data) {
1800 $new = $this->_backend->set_versiondata($pagename, $version, $data);
1802 $this->_versiondata_cache[$pagename][$version]['1'] = $data;
1804 $this->_versiondata_cache[$pagename][$version]['0'] = $data;
1805 // Is this necessary?
1806 unset($this->_glv_cache[$pagename]);
1809 function update_versiondata($pagename, $version, $data) {
1810 $new = $this->_backend->update_versiondata($pagename, $version, $data);
1812 $this->_versiondata_cache[$pagename][$version]['1'] = $data;
1814 $this->_versiondata_cache[$pagename][$version]['0'] = $data;
1815 // Is this necessary?
1816 unset($this->_glv_cache[$pagename]);
1819 function delete_versiondata($pagename, $version) {
1820 $new = $this->_backend->delete_versiondata($pagename, $version);
1821 unset ($this->_versiondata_cache[$pagename][$version]['1']);
1822 unset ($this->_versiondata_cache[$pagename][$version]['0']);
1823 unset ($this->_glv_cache[$pagename]);
1826 function get_latest_version($pagename) {
1827 if (defined('USECACHE')){
1828 assert (is_string($pagename) && $pagename != '');
1829 $cache = &$this->_glv_cache;
1830 if (!isset($cache[$pagename])) {
1831 $cache[$pagename] = $this->_backend->get_latest_version($pagename);
1832 if (empty($cache[$pagename]))
1833 $cache[$pagename] = 0;
1835 return $cache[$pagename];
1837 return $this->_backend->get_latest_version($pagename);
1843 // $Log: not supported by cvs2svn $
1844 // Revision 1.66 2004/06/07 18:57:27 rurban
1845 // fix rename: Change pagename in all linked pages
1847 // Revision 1.65 2004/06/04 20:32:53 rurban
1848 // Several locale related improvements suggested by Pierrick Meignen
1849 // LDAP fix by John Cole
1850 // reanable admin check without ENABLE_PAGEPERM in the admin plugins
1852 // Revision 1.64 2004/06/04 16:50:00 rurban
1853 // add random quotes to empty pages
1855 // Revision 1.63 2004/06/04 11:58:38 rurban
1856 // added USE_TAGLINES
1858 // Revision 1.62 2004/06/03 22:24:41 rurban
1859 // reenable admin check on !ENABLE_PAGEPERM, honor s=Wildcard arg, fix warning after Remove
1861 // Revision 1.61 2004/06/02 17:13:48 rurban
1862 // fix getRevisionBefore assertion
1864 // Revision 1.60 2004/05/28 10:09:58 rurban
1865 // fix bug #962117, incorrect init of auth_dsn
1867 // Revision 1.59 2004/05/27 17:49:05 rurban
1868 // renamed DB_Session to DbSession (in CVS also)
1869 // added WikiDB->getParam and WikiDB->getAuthParam method to get rid of globals
1870 // remove leading slash in error message
1871 // added force_unlock parameter to File_Passwd (no return on stale locks)
1872 // fixed adodb session AffectedRows
1873 // added FileFinder helpers to unify local filenames and DATA_PATH names
1874 // editpage.php: new edit toolbar javascript on ENABLE_EDIT_TOOLBAR
1876 // Revision 1.58 2004/05/18 13:59:14 rurban
1877 // rename simpleQuery to genericQuery
1879 // Revision 1.57 2004/05/16 22:07:35 rurban
1880 // check more config-default and predefined constants
1881 // various PagePerm fixes:
1882 // fix default PagePerms, esp. edit and view for Bogo and Password users
1883 // implemented Creator and Owner
1884 // BOGOUSERS renamed to BOGOUSER
1885 // fixed syntax errors in signin.tmpl
1887 // Revision 1.56 2004/05/15 22:54:49 rurban
1888 // fixed important WikiDB bug with DEBUG > 0: wrong assertion
1889 // improved SetAcl (works) and PagePerms, some WikiGroup helpers.
1891 // Revision 1.55 2004/05/12 19:27:47 rurban
1892 // revert wrong inline optimization.
1894 // Revision 1.54 2004/05/12 10:49:55 rurban
1895 // require_once fix for those libs which are loaded before FileFinder and
1896 // its automatic include_path fix, and where require_once doesn't grok
1897 // dirname(__FILE__) != './lib'
1898 // upgrade fix with PearDB
1899 // navbar.tmpl: remove spaces for IE button alignment
1901 // Revision 1.53 2004/05/08 14:06:12 rurban
1902 // new support for inlined image attributes: [image.jpg size=50x30 align=right]
1903 // minor stability and portability fixes
1905 // Revision 1.52 2004/05/06 19:26:16 rurban
1906 // improve stability, trying to find the InlineParser endless loop on sf.net
1908 // remove end-of-zip comments to fix sf.net bug #777278 and probably #859628
1910 // Revision 1.51 2004/05/06 17:30:37 rurban
1911 // CategoryGroup: oops, dos2unix eol
1912 // improved phpwiki_version:
1913 // pre -= .0001 (1.3.10pre: 1030.099)
1914 // -p1 += .001 (1.3.9-p1: 1030.091)
1915 // improved InstallTable for mysql and generic SQL versions and all newer tables so far.
1916 // abstracted more ADODB/PearDB methods for action=upgrade stuff:
1917 // backend->backendType(), backend->database(),
1918 // backend->listOfFields(),
1919 // backend->listOfTables(),
1921 // Revision 1.50 2004/05/04 22:34:25 rurban
1924 // Revision 1.49 2004/05/03 11:16:40 rurban
1925 // fixed sendPageChangeNotification
1926 // subject rewording
1928 // Revision 1.48 2004/04/29 23:03:54 rurban
1929 // fixed sf.net bug #940996
1931 // Revision 1.47 2004/04/29 19:39:44 rurban
1932 // special support for formatted plugins (one-liners)
1933 // like <small><plugin BlaBla ></small>
1934 // iter->asArray() helper for PopularNearby
1935 // db_session for older php's (no &func() allowed)
1937 // Revision 1.46 2004/04/26 20:44:34 rurban
1938 // locking table specific for better databases
1940 // Revision 1.45 2004/04/20 00:06:03 rurban
1941 // themable paging support
1943 // Revision 1.44 2004/04/19 18:27:45 rurban
1944 // Prevent from some PHP5 warnings (ref args, no :: object init)
1945 // php5 runs now through, just one wrong XmlElement object init missing
1946 // Removed unneccesary UpgradeUser lines
1947 // Changed WikiLink to omit version if current (RecentChanges)
1949 // Revision 1.43 2004/04/18 01:34:20 rurban
1950 // protect most_popular from sortby=mtime
1952 // Revision 1.42 2004/04/18 01:11:51 rurban
1953 // more numeric pagename fixes.
1954 // fixed action=upload with merge conflict warnings.
1955 // charset changed from constant to global (dynamic utf-8 switching)
1961 // c-basic-offset: 4
1962 // c-hanging-comment-ender-p: nil
1963 // indent-tabs-mode: nil