From: <var...@us...> - 2008-09-07 15:13:48
|
Revision: 6248 http://phpwiki.svn.sourceforge.net/phpwiki/?rev=6248&view=rev Author: vargenau Date: 2008-09-07 15:13:56 +0000 (Sun, 07 Sep 2008) Log Message: ----------- Renamed class Theme to WikiTheme to avoid Gforge name clash Modified Paths: -------------- trunk/doc/THEMES trunk/lib/HtmlElement.php trunk/lib/PageList.php trunk/lib/config.php trunk/lib/editpage.php trunk/lib/loadsave.php trunk/lib/main.php trunk/lib/plugin/FrameInclude.php trunk/lib/plugin/ListPages.php trunk/lib/plugin/PageHistory.php trunk/lib/plugin/PreferenceApp.php trunk/lib/plugin/RecentChanges.php trunk/lib/plugin/UpLoad.php trunk/lib/plugin/UserPreferences.php trunk/lib/stdlib.php trunk/pgsrc/ReleaseNotes trunk/themes/Crao/themeinfo.php trunk/themes/Hawaiian/themeinfo.php trunk/themes/MacOSX/themeinfo.php trunk/themes/MonoBook/themeinfo.php trunk/themes/Portland/themeinfo.php trunk/themes/Sidebar/themeinfo.php trunk/themes/SpaceWiki/themeinfo.php trunk/themes/Wordpress/themeinfo.php trunk/themes/blog/themeinfo.php trunk/themes/default/themeinfo.php trunk/themes/shamino_com/themeinfo.php trunk/themes/smaller/themeinfo.php trunk/themes/wikilens/themeinfo.php Added Paths: ----------- trunk/lib/WikiTheme.php Removed Paths: ------------- trunk/lib/Theme.php Modified: trunk/doc/THEMES =================================================================== --- trunk/doc/THEMES 2008-09-07 15:06:20 UTC (rev 6247) +++ trunk/doc/THEMES 2008-09-07 15:13:56 UTC (rev 6248) @@ -1,4 +1,4 @@ -! Brief Example of Creating Your Own Theme +! Brief Example of Creating Your Own WikiTheme To create or modify one of the existing themes: * Make a copy of one of the themes. @@ -7,11 +7,11 @@ same directory structure and modify them there instead of the originals. * Fix the name in themeinfo.php: - $Theme = new Theme('NewName'); -* or if you have to override some default Theme methods - class Theme_NewName extends Theme; + $WikiTheme = new WikiTheme('NewName'); +* or if you have to override some default WikiTheme methods + class WikiTheme_NewName extends WikiTheme; ... - $Theme = new Theme_NewName('NewName'); + $WikiTheme = new WikiTheme_NewName('NewName'); Note: @@ -32,7 +32,7 @@ Only one template is called, ususally the "html.tmpl" template, which includes all other templates then. -Theme templates are regular xhtml, but the php parts within "<?" and "?>" +WikiTheme templates are regular xhtml, but the php parts within "<?" and "?>" are treated especially by phpwiki. HTML entities within the php parts should be created by our HtmlElement methods, which create well-formed HTML objects. Modified: trunk/lib/HtmlElement.php =================================================================== --- trunk/lib/HtmlElement.php 2008-09-07 15:06:20 UTC (rev 6247) +++ trunk/lib/HtmlElement.php 2008-09-07 15:13:56 UTC (rev 6248) @@ -559,122 +559,6 @@ return HTML($html); } -/** - $Log: not supported by cvs2svn $ - Revision 1.49 2007/06/02 18:23:49 rurban - Added accesskeys - - Revision 1.48 2007/05/24 18:51:35 rurban - add param (for YouTube) - - Revision 1.47 2005/08/06 12:53:36 rurban - beautify SCRIPT lines - - Revision 1.46 2005/01/25 06:50:33 rurban - added label - - Revision 1.45 2005/01/10 18:05:56 rurban - php5 case-sensitivity - - Revision 1.44 2005/01/08 20:58:19 rurban - ending space after colgroup breaks _setTagProperty - - Revision 1.43 2004/11/21 11:59:14 rurban - remove final \n to be ob_cache independent - - Revision 1.42 2004/09/26 17:09:23 rurban - add SVG support for Ploticus (and hopefully all WikiPluginCached types) - SWF not yet. - - Revision 1.41 2004/08/05 17:31:50 rurban - more xhtml conformance fixes - - Revision 1.40 2004/06/25 14:29:17 rurban - WikiGroup refactoring: - global group attached to user, code for not_current user. - improved helpers for special groups (avoid double invocations) - new experimental config option ENABLE_XHTML_XML (fails with IE, and document.write()) - fixed a XHTML validation error on userprefs.tmpl - - Revision 1.39 2004/05/17 13:36:49 rurban - Apply RFE #952323 "ExternalSearchPlugin improvement", but - with <button><img></button> - - Revision 1.38 2004/05/12 10:49:54 rurban - require_once fix for those libs which are loaded before FileFinder and - its automatic include_path fix, and where require_once doesn't grok - dirname(__FILE__) != './lib' - upgrade fix with PearDB - navbar.tmpl: remove spaces for IE button alignment - - Revision 1.37 2004/04/26 20:44:34 rurban - locking table specific for better databases - - Revision 1.36 2004/04/19 21:51:41 rurban - php5 compatibility: it works! - - Revision 1.35 2004/04/19 18:27:45 rurban - Prevent from some PHP5 warnings (ref args, no :: object init) - php5 runs now through, just one wrong XmlElement object init missing - Removed unneccesary UpgradeUser lines - Changed WikiLink to omit version if current (RecentChanges) - - Revision 1.34 2004/03/24 19:39:02 rurban - php5 workaround code (plus some interim debugging code in XmlElement) - php5 doesn't work yet with the current XmlElement class constructors, - WikiUserNew does work better than php4. - rewrote WikiUserNew user upgrading to ease php5 update - fixed pref handling in WikiUserNew - added Email Notification - added simple Email verification - removed emailVerify userpref subclass: just a email property - changed pref binary storage layout: numarray => hash of non default values - print optimize message only if really done. - forced new cookie policy: delete pref cookies, use only WIKI_ID as plain string. - prefs should be stored in db or homepage, besides the current session. - - Revision 1.33 2004/03/18 22:32:33 rurban - work to make it php5 compatible - - Revision 1.32 2004/02/15 21:34:37 rurban - PageList enhanced and improved. - fixed new WikiAdmin... plugins - editpage, Theme with exp. htmlarea framework - (htmlarea yet committed, this is really questionable) - WikiUser... code with better session handling for prefs - enhanced UserPreferences (again) - RecentChanges for show_deleted: how should pages be deleted then? - - Revision 1.31 2003/02/27 22:47:26 dairiki - New functions in HtmlElement: - - JavaScript($js) - Helper for generating javascript. - - IfJavaScript($if_content, $else_content) - Helper for generating - <script>document.write('...')</script><noscript>...</noscript> - constructs. - - Revision 1.30 2003/02/17 06:02:25 dairiki - Remove functions HiddenGets() and HiddenPosts(). - - These functions were evil. They didn't check the request method, - so they often resulted in GET args being converted to POST args, - etc... - - One of these is still used in lib/plugin/WikiAdminSelect.php, - but, so far as I can tell, that code is both broken _and_ it - doesn't do anything. - - Revision 1.29 2003/02/15 01:54:19 dairiki - Added HTML::meta() for <meta> tag. - - Revision 1.28 2003/01/04 02:32:30 carstenklapp - Added 'col' and 'colgroup' table elements used by PluginManager. - - */ - // (c-file-style: "gnu") // Local Variables: // mode: php Modified: trunk/lib/PageList.php =================================================================== --- trunk/lib/PageList.php 2008-09-07 15:06:20 UTC (rev 6247) +++ trunk/lib/PageList.php 2008-09-07 15:13:56 UTC (rev 6248) @@ -334,12 +334,12 @@ function _PageList_Column_time ($field, $default_heading) { $this->_PageList_Column($field, $default_heading, 'right'); global $WikiTheme; - $this->Theme = &$WikiTheme; + $this->WikiTheme = &$WikiTheme; } function _getValue ($page_handle, &$revision_handle) { $time = _PageList_Column::_getValue($page_handle, $revision_handle); - return $this->Theme->formatDateTime($time); + return $this->WikiTheme->formatDateTime($time); } function _getSortableValue ($page_handle, &$revision_handle) { @@ -1694,302 +1694,6 @@ } } -// $Log: not supported by cvs2svn $ -// Revision 1.154 2008/03/17 19:07:51 rurban -// No sort links on dumped pages. -// checked="CHECKED" -// Add defaults for all supported Columns, like locked, minor, ... -// -// Revision 1.153 2008/02/15 19:52:04 vargenau -// Corrected bug #1847961: In AllPages with a limit, last page is incorrectly numbered -// -// Revision 1.152 2008/02/15 19:46:12 vargenau -// Allow sorting by hits; test method_exists -// -// Revision 1.151 2008/02/14 18:42:53 rurban -// ref to a class does not work with php-4, add ratingvalue -// -// Revision 1.150 2008/01/31 20:28:47 vargenau -// Valid HTML code: tfoot must be before tbody -// -// Revision 1.149 2008/01/26 14:13:29 vargenau -// XHTML is case-sensitive; use correct case -// -// Revision 1.148 2007/09/19 18:00:49 rurban -// enable "^A or ^B" pages argument for PageLists: e.g. large htmldump-s -// -// Revision 1.147 2007/09/15 12:26:25 rurban -// add explodePageList comments -// -// Revision 1.146 2007/09/12 19:33:29 rurban -// allow array to be exploded (comma problem) -// -// Revision 1.145 2007/08/25 17:58:14 rurban -// more limit fixes: limit earlier, fix COUNT slice -// -// Revision 1.143 2007/07/14 12:03:19 rurban -// support listtype=dl and ranked search -// -// Revision 1.142 2007/07/01 09:09:19 rurban -// fix PageList with multiple lists: added id, fixed sortby REQUEST logic -// -// Revision 1.141 2007/05/24 18:40:55 rurban -// display list with tokens problem -// -// Revision 1.140 2007/05/13 18:12:55 rurban -// force adding a options[type] column: fixes LinkDatabase -// -// Revision 1.139 2007/01/25 07:42:01 rurban -// Support nopage -// -// Revision 1.138 2007/01/20 11:24:15 rurban -// Support paging limit if ->_pages is not yet limited by the backend (AllPagesByMe) -// -// Revision 1.137 2007/01/07 18:43:08 rurban -// Honor predefined ->_rows: hack to (re-)allow non-pagenames, used by WikiAdminUtils -// -// Revision 1.136 2007/01/02 13:18:46 rurban -// filter pageNames through limit, needed for xmlrpc. publish col->current_row and col->current_column counters during iteration. use table width=100% with captions. Clarify API: sortby,limit and exclude are strings. -// -// Revision 1.135 2005/09/14 05:59:03 rurban -// optimized explodePageList to use SQL when available -// (titleSearch instead of getAllPages) -// -// Revision 1.134 2005/09/11 14:55:05 rurban -// implement fulltext stoplist -// -// Revision 1.133 2005/08/27 09:41:37 rurban -// new helper method -// -// Revision 1.132 2005/04/09 09:16:15 rurban -// fix recursive PageList azhead+cols listing -// -// Revision 1.131 2005/02/04 10:48:06 rurban -// fix usort ref warning. Thanks to Charles Corrigan -// -// Revision 1.130 2005/01/28 12:07:36 rurban -// reformatting -// -// Revision 1.129 2005/01/25 06:58:21 rurban -// reformatting -// -// Revision 1.128 2004/12/26 17:31:35 rurban -// fixed prev link logic -// -// Revision 1.127 2004/12/26 17:19:28 rurban -// dont break sideeffecting sortby flips on paging urls (MostPopular) -// -// Revision 1.126 2004/12/16 18:26:57 rurban -// Avoid double calculation -// -// Revision 1.125 2004/11/25 17:20:49 rurban -// and again a couple of more native db args: backlinks -// -// Revision 1.124 2004/11/23 15:17:14 rurban -// better support for case_exact search (not caseexact for consistency), -// plugin args simplification: -// handle and explode exclude and pages argument in WikiPlugin::getArgs -// and exclude in advance (at the sql level if possible) -// handle sortby and limit from request override in WikiPlugin::getArgs -// ListSubpages: renamed pages to maxpages -// -// Revision 1.123 2004/11/23 13:35:31 rurban -// add case_exact search -// -// Revision 1.122 2004/11/21 11:59:15 rurban -// remove final \n to be ob_cache independent -// -// Revision 1.121 2004/11/20 17:35:47 rurban -// improved WantedPages SQL backends -// PageList::sortby new 3rd arg valid_fields (override db fields) -// WantedPages sql pager inexact for performance reasons: -// assume 3 wantedfrom per page, to be correct, no getTotal() -// support exclude argument for get_all_pages, new _sql_set() -// -// Revision 1.120 2004/11/20 11:28:49 rurban -// fix a yet unused PageList customPageListColumns bug (merge class not decl to _types) -// change WantedPages to use PageList -// change WantedPages to print the list of referenced pages, not just the count. -// the old version was renamed to WantedPagesOld -// fix and add handling of most standard PageList arguments (limit, exclude, ...) -// TODO: pagename sorting, dumb/WantedPagesIter and SQL optimization -// -// Revision 1.119 2004/11/11 14:34:11 rurban -// minor clarifications -// -// Revision 1.118 2004/11/01 10:43:55 rurban -// seperate PassUser methods into seperate dir (memory usage) -// fix WikiUser (old) overlarge data session -// remove wikidb arg from various page class methods, use global ->_dbi instead -// ... -// -// Revision 1.117 2004/10/14 21:06:01 rurban -// fix dumphtml with USE_PATH_INFO (again). fix some PageList refs -// -// Revision 1.116 2004/10/14 19:19:33 rurban -// loadsave: check if the dumped file will be accessible from outside. -// and some other minor fixes. (cvsclient native not yet ready) -// -// Revision 1.115 2004/10/14 17:15:05 rurban -// remove class _PageList_Page, fix sortby=0 (start with 1, use strings), fix _PageList_Column_content for old phps, hits as int -// -// Revision 1.114 2004/10/12 13:13:19 rurban -// php5 compatibility (5.0.1 ok) -// -// Revision 1.113 2004/10/05 17:00:03 rurban -// support paging for simple lists -// fix RatingDb sql backend. -// remove pages from AllPages (this is ListPages then) -// -// Revision 1.112 2004/10/04 23:39:58 rurban -// list of page objects -// -// Revision 1.111 2004/09/24 18:50:45 rurban -// fix paging of SqlResult -// -// Revision 1.110 2004/09/17 14:43:31 rurban -// typo -// -// Revision 1.109 2004/09/17 14:22:10 rurban -// update comments -// -// Revision 1.108 2004/09/17 12:46:22 rurban -// seperate pagingTokens() -// support new default args: comma (1 and 2), commasep, ordered, cols, -// azhead (1 only) -// -// Revision 1.107 2004/09/14 10:29:08 rurban -// exclude pages already in addPages to simplify plugins -// -// Revision 1.106 2004/09/06 10:22:14 rurban -// oops, forgot global request -// -// Revision 1.105 2004/09/06 08:38:30 rurban -// modularize paging helper (for SqlResult) -// -// Revision 1.104 2004/08/18 11:01:55 rurban -// fixed checkbox list Select button: -// no GET request on click, -// only select the list checkbox entries, no other options. -// -// Revision 1.103 2004/07/09 10:06:49 rurban -// Use backend specific sortby and sortable_columns method, to be able to -// select between native (Db backend) and custom (PageList) sorting. -// Fixed PageList::AddPageList (missed the first) -// Added the author/creator.. name to AllPagesBy... -// display no pages if none matched. -// Improved dba and file sortby(). -// Use &$request reference -// -// Revision 1.102 2004/07/08 21:32:35 rurban -// Prevent from more warnings, minor db and sort optimizations -// -// Revision 1.101 2004/07/08 19:04:41 rurban -// more unittest fixes (file backend, metadata RatingsDb) -// -// Revision 1.100 2004/07/07 15:02:26 dfrankow -// Take out if that prevents column sorting -// -// Revision 1.99 2004/07/02 18:49:02 dfrankow -// Change one line so that if addPageList() is passed null, it is still -// okay. The unit tests do this (ask to list AllUsers where there are no -// users, or something like that). -// -// Revision 1.98 2004/07/01 08:51:22 rurban -// dumphtml: added exclude, print pagename before processing -// -// Revision 1.97 2004/06/29 09:11:10 rurban -// More memory optimization: -// don't cache unneeded _cached_html and %content for content and size columns -// (only if sortable, which will fail for too many pages) -// -// Revision 1.96 2004/06/29 08:47:42 rurban -// Memory optimization (reference to parent, smart bool %content) -// Fixed class grouping in table -// -// Revision 1.95 2004/06/28 19:00:01 rurban -// removed non-portable LIMIT 1 (it's getOne anyway) -// removed size from info=most: needs to much memory -// -// Revision 1.94 2004/06/27 10:26:02 rurban -// oci8 patch by Philippe Vanhaesendonck + some ADODB notes+fixes -// -// Revision 1.93 2004/06/25 14:29:17 rurban -// WikiGroup refactoring: -// global group attached to user, code for not_current user. -// improved helpers for special groups (avoid double invocations) -// new experimental config option ENABLE_XHTML_XML (fails with IE, and document.write()) -// fixed a XHTML validation error on userprefs.tmpl -// -// Revision 1.92 2004/06/21 17:01:39 rurban -// fix typo and rating method call -// -// Revision 1.91 2004/06/21 16:22:29 rurban -// add DEFAULT_DUMP_DIR and HTML_DUMP_DIR constants, for easier cmdline dumps, -// fixed dumping buttons locally (images/buttons/), -// support pages arg for dumphtml, -// optional directory arg for dumpserial + dumphtml, -// fix a AllPages warning, -// show dump warnings/errors on DEBUG, -// don't warn just ignore on wikilens pagelist columns, if not loaded. -// RateIt pagelist column is called "rating", not "ratingwidget" (Dan?) -// -// Revision 1.90 2004/06/18 14:38:21 rurban -// adopt new PageList style -// -// Revision 1.89 2004/06/17 13:16:08 rurban -// apply wikilens work to PageList: all columns are sortable (slightly fixed) -// -// Revision 1.88 2004/06/14 11:31:35 rurban -// renamed global $Theme to $WikiTheme (gforge nameclash) -// inherit PageList default options from PageList -// default sortby=pagename -// use options in PageList_Selectable (limit, sortby, ...) -// added action revert, with button at action=diff -// added option regex to WikiAdminSearchReplace -// -// Revision 1.87 2004/06/13 16:02:12 rurban -// empty list of pages if user=[] and not authenticated. -// -// Revision 1.86 2004/06/13 15:51:37 rurban -// Support pagelist filter for current author,owner,creator by [] -// -// Revision 1.85 2004/06/13 15:33:19 rurban -// new support for arguments owner, author, creator in most relevant -// PageList plugins. in WikiAdmin* via preSelectS() -// -// Revision 1.84 2004/06/08 13:51:56 rurban -// some comments only -// -// Revision 1.83 2004/05/18 13:35:39 rurban -// improve Pagelist layout by equal pagename width for limited lists -// -// Revision 1.82 2004/05/16 22:07:35 rurban -// check more config-default and predefined constants -// various PagePerm fixes: -// fix default PagePerms, esp. edit and view for Bogo and Password users -// implemented Creator and Owner -// BOGOUSERS renamed to BOGOUSER -// fixed syntax errors in signin.tmpl -// -// Revision 1.81 2004/05/13 12:30:35 rurban -// fix for MacOSX border CSS attr, and if sort buttons are not found -// -// Revision 1.80 2004/04/20 00:56:00 rurban -// more paging support and paging fix for shorter lists -// -// Revision 1.79 2004/04/20 00:34:16 rurban -// more paging support -// -// Revision 1.78 2004/04/20 00:06:03 rurban -// themable paging support -// -// Revision 1.77 2004/04/18 01:11:51 rurban -// more numeric pagename fixes. -// fixed action=upload with merge conflict warnings. -// charset changed from constant to global (dynamic utf-8 switching) -// - // (c-file-style: "gnu") // Local Variables: // mode: php Deleted: trunk/lib/Theme.php =================================================================== --- trunk/lib/Theme.php 2008-09-07 15:06:20 UTC (rev 6247) +++ trunk/lib/Theme.php 2008-09-07 15:13:56 UTC (rev 6248) @@ -1,2203 +0,0 @@ -<?php rcs_id('$Id$'); -/* Copyright (C) 2002,2004,2005,2006 $ThePhpWikiProgrammingTeam - * - * This file is part of PhpWiki. - * - * PhpWiki is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * PhpWiki is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with PhpWiki; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/** - * Customize output by themes: templates, css, special links functions, - * and more formatting. - */ - -require_once(dirname(__FILE__).'/HtmlElement.php'); - -/** - * Make a link to a wiki page (in this wiki). - * - * This is a convenience function. - * - * @param mixed $page_or_rev - * Can be:<dl> - * <dt>A string</dt><dd>The page to link to.</dd> - * <dt>A WikiDB_Page object</dt><dd>The page to link to.</dd> - * <dt>A WikiDB_PageRevision object</dt><dd>A specific version of the page to link to.</dd> - * </dl> - * - * @param string $type - * One of:<dl> - * <dt>'unknown'</dt><dd>Make link appropriate for a non-existant page.</dd> - * <dt>'known'</dt><dd>Make link appropriate for an existing page.</dd> - * <dt>'auto'</dt><dd>Either 'unknown' or 'known' as appropriate.</dd> - * <dt>'button'</dt><dd>Make a button-style link.</dd> - * <dt>'if_known'</dt><dd>Only linkify if page exists.</dd> - * </dl> - * Unless $type of of the latter form, the link will be of class 'wiki', 'wikiunknown', - * 'named-wiki', or 'named-wikiunknown', as appropriate. - * - * @param mixed $label (string or XmlContent object) - * Label for the link. If not given, defaults to the page name. - * - * @return XmlContent The link - */ -function WikiLink ($page_or_rev, $type = 'known', $label = false) { - global $WikiTheme, $request; - - if ($type == 'button') { - return $WikiTheme->makeLinkButton($page_or_rev, $label); - } - - $version = false; - - if (isa($page_or_rev, 'WikiDB_PageRevision')) { - $version = $page_or_rev->getVersion(); - if ($page_or_rev->isCurrent()) - $version = false; - $page = $page_or_rev->getPage(); - $pagename = $page->getName(); - $wikipage = $pagename; - $exists = true; - } - elseif (isa($page_or_rev, 'WikiDB_Page')) { - $page = $page_or_rev; - $pagename = $page->getName(); - $wikipage = $pagename; - } - elseif (isa($page_or_rev, 'WikiPageName')) { - $wikipage = $page_or_rev; - $pagename = $wikipage->name; - if (!$wikipage->isValid('strict')) - return $WikiTheme->linkBadWikiWord($wikipage, $label); - } - else { - $wikipage = new WikiPageName($page_or_rev, $request->getPage()); - $pagename = $wikipage->name; - if (!$wikipage->isValid('strict')) - return $WikiTheme->linkBadWikiWord($wikipage, $label); - } - - if ($type == 'auto' or $type == 'if_known') { - if (isset($page)) { - $exists = $page->exists(); - } - else { - $dbi =& $request->_dbi; - $exists = $dbi->isWikiPage($wikipage->name); - } - } - elseif ($type == 'unknown') { - $exists = false; - } - else { - $exists = true; - } - - // FIXME: this should be somewhere else, if really needed. - // WikiLink makes A link, not a string of fancy ones. - // (I think that the fancy split links are just confusing.) - // Todo: test external ImageLinks http://some/images/next.gif - if (isa($wikipage, 'WikiPageName') and - ! $label and - strchr(substr($wikipage->shortName,1), SUBPAGE_SEPARATOR)) - { - $parts = explode(SUBPAGE_SEPARATOR, $wikipage->shortName); - $last_part = array_pop($parts); - $sep = ''; - $link = HTML::span(); - foreach ($parts as $part) { - $path[] = $part; - $parent = join(SUBPAGE_SEPARATOR, $path); - if ($WikiTheme->_autosplitWikiWords) - $part = " " . $part; - if ($part) - $link->pushContent($WikiTheme->linkExistingWikiWord($parent, $sep . $part)); - $sep = $WikiTheme->_autosplitWikiWords - ? ' ' . SUBPAGE_SEPARATOR : SUBPAGE_SEPARATOR; - } - if ($exists) - $link->pushContent($WikiTheme->linkExistingWikiWord($wikipage, $sep . $last_part, - $version)); - else - $link->pushContent($WikiTheme->linkUnknownWikiWord($wikipage, $sep . $last_part)); - return $link; - } - - if ($exists) { - return $WikiTheme->linkExistingWikiWord($wikipage, $label, $version); - } - elseif ($type == 'if_known') { - if (!$label && isa($wikipage, 'WikiPageName')) - $label = $wikipage->shortName; - return HTML($label ? $label : $pagename); - } - else { - return $WikiTheme->linkUnknownWikiWord($wikipage, $label); - } -} - - - -/** - * Make a button. - * - * This is a convenience function. - * - * @param $action string - * One of <dl> - * <dt>[action]</dt><dd>Perform action (e.g. 'edit') on the selected page.</dd> - * <dt>[ActionPage]</dt><dd>Run the actionpage (e.g. 'BackLinks') on the selected page.</dd> - * <dt>'submit:'[name]</dt><dd>Make a form submission button with the given name. - * ([name] can be blank for a nameless submit button.)</dd> - * <dt>a hash</dt><dd>Query args for the action. E.g.<pre> - * array('action' => 'diff', 'previous' => 'author') - * </pre></dd> - * </dl> - * - * @param $label string - * A label for the button. If ommited, a suitable default (based on the valued of $action) - * will be picked. - * - * @param $page_or_rev mixed - * Which page (& version) to perform the action on. - * Can be one of:<dl> - * <dt>A string</dt><dd>The pagename.</dd> - * <dt>A WikiDB_Page object</dt><dd>The page.</dd> - * <dt>A WikiDB_PageRevision object</dt><dd>A specific version of the page.</dd> - * </dl> - * ($Page_or_rev is ignored for submit buttons.) - */ -function Button ($action, $label = false, $page_or_rev = false, $options = false) { - global $WikiTheme; - - if (!is_array($action) && preg_match('/^submit:(.*)/', $action, $m)) - return $WikiTheme->makeSubmitButton($label, $m[1], $page_or_rev, $options); - else - return $WikiTheme->makeActionButton($action, $label, $page_or_rev, $options); -} - -class Theme { - var $HTML_DUMP_SUFFIX = ''; - var $DUMP_MODE = false, $dumped_images, $dumped_css; - - /** - * noinit: Do not initialize unnecessary items in default_theme fallback twice. - */ - function Theme ($theme_name = 'default', $noinit = false) { - $this->_name = $theme_name; - $this->_themes_dir = NormalizeLocalFileName("themes"); - $this->_path = defined('PHPWIKI_DIR') ? NormalizeLocalFileName("") : ""; - $this->_theme = "themes/$theme_name"; - - if ($theme_name != 'default') - $this->_default_theme = new Theme('default',true); - if ($noinit) return; - - $script_url = deduce_script_name(); - if ((DEBUG & _DEBUG_REMOTE) and isset($_GET['start_debug'])) - $script_url .= ("?start_debug=".$_GET['start_debug']); - $this->addMoreHeaders(JavaScript("var data_path = '". javascript_quote_string(DATA_PATH) ."';\n" - ."var pagename = '". javascript_quote_string($GLOBALS['request']->getArg('pagename')) ."';\n" - ."var script_url= '". javascript_quote_string($script_url) ."';\n" - ."var stylepath = '". javascript_quote_string(DATA_PATH) . '/'.$this->_theme."/';\n")); - // by pixels - if ((is_object($GLOBALS['request']) // guard against unittests - and $GLOBALS['request']->getPref('doubleClickEdit')) - or ENABLE_DOUBLECLICKEDIT) - $this->initDoubleClickEdit(); - - // will be replaced by acDropDown - if (ENABLE_LIVESEARCH) { // by bitflux.ch - $this->initLiveSearch(); - } - // replaces external LiveSearch - if (defined("ENABLE_ACDROPDOWN") and ENABLE_ACDROPDOWN) { - $this->initMoAcDropDown(); - } - $this->_css = array(); - } - - function file ($file) { - return $this->_path . "$this->_theme/$file"; - } - - function _findFile ($file, $missing_okay = false) { - if (file_exists($this->file($file))) - return "$this->_theme/$file"; - - // FIXME: this is a short-term hack. Delete this after all files - // get moved into themes/... - if (file_exists($this->_path . $file)) - return $file; - - if (isset($this->_default_theme)) { - return $this->_default_theme->_findFile($file, $missing_okay); - } - else if (!$missing_okay) { - if (DEBUG & function_exists('debug_backtrace')) { // >= 4.3.0 - echo "<pre>", printSimpleTrace(debug_backtrace()), "</pre>\n"; - } - trigger_error("$this->_theme/$file: not found", E_USER_NOTICE); - } - return false; - } - - function _findData ($file, $missing_okay = false) { - $path = $this->_findFile($file, $missing_okay); - if (!$path) - return false; - - if (defined('DATA_PATH')) - return DATA_PATH . "/$path"; - return $path; - } - - //////////////////////////////////////////////////////////////// - // - // Date and Time formatting - // - //////////////////////////////////////////////////////////////// - - // Note: Windows' implemetation of strftime does not include certain - // format specifiers, such as %e (for date without leading zeros). In - // general, see: - // http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/_crt_strftime.2c_.wcsftime.asp - // As a result, we have to use %d, and strip out leading zeros ourselves. - - var $_dateFormat = "%B %d, %Y"; - var $_timeFormat = "%I:%M %p"; - - var $_showModTime = true; - - /** - * Set format string used for dates. - * - * @param $fs string Format string for dates. - * - * @param $show_mod_time bool If true (default) then times - * are included in the messages generated by getLastModifiedMessage(), - * otherwise, only the date of last modification will be shown. - */ - function setDateFormat ($fs, $show_mod_time = true) { - $this->_dateFormat = $fs; - $this->_showModTime = $show_mod_time; - } - - /** - * Set format string used for times. - * - * @param $fs string Format string for times. - */ - function setTimeFormat ($fs) { - $this->_timeFormat = $fs; - } - - /** - * Format a date. - * - * Any time zone offset specified in the users preferences is - * taken into account by this method. - * - * @param $time_t integer Unix-style time. - * - * @return string The date. - */ - function formatDate ($time_t) { - global $request; - - $offset_time = $time_t + 3600 * $request->getPref('timeOffset'); - // strip leading zeros from date elements (ie space followed by zero) - return preg_replace('/ 0/', ' ', - strftime($this->_dateFormat, $offset_time)); - } - - /** - * Format a date. - * - * Any time zone offset specified in the users preferences is - * taken into account by this method. - * - * @param $time_t integer Unix-style time. - * - * @return string The time. - */ - function formatTime ($time_t) { - //FIXME: make 24-hour mode configurable? - global $request; - $offset_time = $time_t + 3600 * $request->getPref('timeOffset'); - return preg_replace('/^0/', ' ', - strtolower(strftime($this->_timeFormat, $offset_time))); - } - - /** - * Format a date and time. - * - * Any time zone offset specified in the users preferences is - * taken into account by this method. - * - * @param $time_t integer Unix-style time. - * - * @return string The date and time. - */ - function formatDateTime ($time_t) { - return $this->formatDate($time_t) . ' ' . $this->formatTime($time_t); - } - - /** - * Format a (possibly relative) date. - * - * If enabled in the users preferences, this method might - * return a relative day (e.g. 'Today', 'Yesterday'). - * - * Any time zone offset specified in the users preferences is - * taken into account by this method. - * - * @param $time_t integer Unix-style time. - * - * @return string The day. - */ - function getDay ($time_t) { - global $request; - - if ($request->getPref('relativeDates') && ($date = $this->_relativeDay($time_t))) { - return ucfirst($date); - } - return $this->formatDate($time_t); - } - - /** - * Format the "last modified" message for a page revision. - * - * @param $revision object A WikiDB_PageRevision object. - * - * @param $show_version bool Should the page version number - * be included in the message. (If this argument is omitted, - * then the version number will be shown only iff the revision - * is not the current one. - * - * @return string The "last modified" message. - */ - function getLastModifiedMessage ($revision, $show_version = 'auto') { - global $request; - if (!$revision) return ''; - - // dates >= this are considered invalid. - if (! defined('EPOCH')) - define('EPOCH', 0); // seconds since ~ January 1 1970 - - $mtime = $revision->get('mtime'); - if ($mtime <= EPOCH) - return fmt("Never edited"); - - if ($show_version == 'auto') - $show_version = !$revision->isCurrent(); - - if ($request->getPref('relativeDates') && ($date = $this->_relativeDay($mtime))) { - if ($this->_showModTime) - $date = sprintf(_("%s at %s"), - $date, $this->formatTime($mtime)); - - if ($show_version) - return fmt("Version %s, saved %s", $revision->getVersion(), $date); - else - return fmt("Last edited %s", $date); - } - - if ($this->_showModTime) - $date = $this->formatDateTime($mtime); - else - $date = $this->formatDate($mtime); - - if ($show_version) - return fmt("Version %s, saved on %s", $revision->getVersion(), $date); - else - return fmt("Last edited on %s", $date); - } - - function _relativeDay ($time_t) { - global $request; - - if (is_numeric($request->getPref('timeOffset'))) - $offset = 3600 * $request->getPref('timeOffset'); - else - $offset = 0; - - $now = time() + $offset; - $today = localtime($now, true); - $time = localtime($time_t + $offset, true); - - if ($time['tm_yday'] == $today['tm_yday'] && $time['tm_year'] == $today['tm_year']) - return _("today"); - - // Note that due to daylight savings chages (and leap seconds), $now minus - // 24 hours is not guaranteed to be yesterday. - $yesterday = localtime($now - (12 + $today['tm_hour']) * 3600, true); - if ($time['tm_yday'] == $yesterday['tm_yday'] - and $time['tm_year'] == $yesterday['tm_year']) - return _("yesterday"); - - return false; - } - - /** - * Format the "Author" and "Owner" messages for a page revision. - */ - function getOwnerMessage ($page) { - if (!ENABLE_PAGEPERM or !class_exists("PagePermission")) - return ''; - $dbi =& $GLOBALS['request']->_dbi; - $owner = $page->getOwner(); - if ($owner) { - /* - if ( mayAccessPage('change',$page->getName()) ) - return fmt("Owner: %s", $this->makeActionButton(array('action'=>_("chown"), - 's' => $page->getName()), - $owner, $page)); - */ - if ( $dbi->isWikiPage($owner) ) - return fmt("Owner: %s", WikiLink($owner)); - else - return fmt("Owner: %s", '"'.$owner.'"'); - } - } - - /* New behaviour: (by Matt Brown) - Prefer author (name) over internal author_id (IP) */ - function getAuthorMessage ($revision) { - if (!$revision) return ''; - $dbi =& $GLOBALS['request']->_dbi; - $author = $revision->get('author'); - if (!$author) $author = $revision->get('author_id'); - if (!$author) return ''; - if ( $dbi->isWikiPage($author) ) { - return fmt("by %s", WikiLink($author)); - } else { - return fmt("by %s", '"'.$author.'"'); - } - } - - //////////////////////////////////////////////////////////////// - // - // Hooks for other formatting - // - //////////////////////////////////////////////////////////////// - - //FIXME: PHP 4.1 Warnings - //lib/Theme.php:84: Notice[8]: The call_user_method() function is deprecated, - //use the call_user_func variety with the array(&$obj, "method") syntax instead - - function getFormatter ($type, $format) { - $method = strtolower("get${type}Formatter"); - if (method_exists($this, $method)) - return $this->{$method}($format); - return false; - } - - //////////////////////////////////////////////////////////////// - // - // Links - // - //////////////////////////////////////////////////////////////// - - var $_autosplitWikiWords = false; - function setAutosplitWikiWords($autosplit=true) { - $this->_autosplitWikiWords = $autosplit ? true : false; - } - - function maybeSplitWikiWord ($wikiword) { - if ($this->_autosplitWikiWords) - return SplitPagename($wikiword); - else - return $wikiword; - } - - var $_anonEditUnknownLinks = true; - function setAnonEditUnknownLinks($anonedit=true) { - $this->_anonEditUnknownLinks = $anonedit ? true : false; - } - - function linkExistingWikiWord($wikiword, $linktext = '', $version = false) { - global $request; - - if ($version !== false and !$this->HTML_DUMP_SUFFIX) - $url = WikiURL($wikiword, array('version' => $version)); - else - $url = WikiURL($wikiword); - - // Extra steps for dumping page to an html file. - if ($this->HTML_DUMP_SUFFIX) { - $url = preg_replace('/^\./', '%2e', $url); // dot pages - } - - $link = HTML::a(array('href' => $url)); - - if (isa($wikiword, 'WikiPageName')) - $default_text = $wikiword->shortName; - else - $default_text = $wikiword; - - if (!empty($linktext)) { - $link->pushContent($linktext); - $link->setAttr('class', 'named-wiki'); - $link->setAttr('title', $this->maybeSplitWikiWord($default_text)); - } - else { - $link->pushContent($this->maybeSplitWikiWord($default_text)); - $link->setAttr('class', 'wiki'); - } - if ($request->getArg('frame')) - $link->setAttr('target', '_top'); - return $link; - } - - function linkUnknownWikiWord($wikiword, $linktext = '') { - global $request; - - // Get rid of anchors on unknown wikiwords - if (isa($wikiword, 'WikiPageName')) { - $default_text = $wikiword->shortName; - $wikiword = $wikiword->name; - } - else { - $default_text = $wikiword; - } - - if ($this->DUMP_MODE) { // HTML, PDF or XML - $link = HTML::u( empty($linktext) ? $wikiword : $linktext); - $link->addTooltip(sprintf(_("Empty link to: %s"), $wikiword)); - $link->setAttr('class', empty($linktext) ? 'wikiunknown' : 'named-wikiunknown'); - return $link; - } else { - // if AnonEditUnknownLinks show "?" only users which are allowed to edit this page - if (! $this->_anonEditUnknownLinks and - ( ! $request->_user->isSignedIn() - or ! mayAccessPage('edit', $request->getArg('pagename')))) - { - $text = HTML::span( empty($linktext) ? $wikiword : $linktext); - $text->setAttr('class', empty($linktext) ? 'wikiunknown' : 'named-wikiunknown'); - return $text; - } else { - $url = WikiURL($wikiword, array('action' => 'create')); - $button = $this->makeButton('?', $url); - $button->addTooltip(sprintf(_("Create: %s"), $wikiword)); - } - } - - $link = HTML::span(); - if (!empty($linktext)) { - $link->pushContent(HTML::u($linktext)); - $link->setAttr('class', 'named-wikiunknown'); - } - else { - $link->pushContent(HTML::u($this->maybeSplitWikiWord($default_text))); - $link->setAttr('class', 'wikiunknown'); - } - if (!isa($button, "ImageButton")) - $button->setAttr('rel', 'nofollow'); - $link->pushContent($button); - if ($request->getPref('googleLink')) { - $gbutton = $this->makeButton('G', "http://www.google.com/search?q=" - . urlencode($wikiword)); - $gbutton->addTooltip(sprintf(_("Google:%s"), $wikiword)); - $link->pushContent($gbutton); - } - if ($request->getArg('frame')) - $link->setAttr('target', '_top'); - - return $link; - } - - function linkBadWikiWord($wikiword, $linktext = '') { - global $ErrorManager; - - if ($linktext) { - $text = $linktext; - } - elseif (isa($wikiword, 'WikiPageName')) { - $text = $wikiword->shortName; - } - else { - $text = $wikiword; - } - - if (isa($wikiword, 'WikiPageName')) - $message = $wikiword->getWarnings(); - else - $message = sprintf(_("'%s': Bad page name"), $wikiword); - $ErrorManager->warning($message); - - return HTML::span(array('class' => 'badwikiword'), $text); - } - - //////////////////////////////////////////////////////////////// - // - // Images and Icons - // - //////////////////////////////////////////////////////////////// - var $_imageAliases = array(); - var $_imageAlt = array(); - - /** - * - * (To disable an image, alias the image to <code>false</code>. - */ - function addImageAlias ($alias, $image_name) { - // fall back to the PhpWiki-supplied image if not found - if ((empty($this->_imageAliases[$alias]) - and $this->_findFile("images/$image_name", true)) - or $image_name === false) - $this->_imageAliases[$alias] = $image_name; - } - - function addImageAlt ($alias, $alt_text) { - $this->_imageAlt[$alias] = $alt_text; - } - function getImageAlt ($alias) { - return $this->_imageAlt[$alias]; - } - - function getImageURL ($image) { - $aliases = &$this->_imageAliases; - - if (isset($aliases[$image])) { - $image = $aliases[$image]; - if (!$image) - return false; - } - - // If not extension, default to .png. - if (!preg_match('/\.\w+$/', $image)) - $image .= '.png'; - - // FIXME: this should probably be made to fall back - // automatically to .gif, .jpg. - // Also try .gif before .png if browser doesn't like png. - - $path = $this->_findData("images/$image", 'missing okay'); - if (!$path) // search explicit images/ or button/ links also - $path = $this->_findData("$image", 'missing okay'); - - if ($this->DUMP_MODE) { - if (empty($this->dumped_images)) $this->dumped_images = array(); - $path = "images/". basename($path); - if (!in_array($path,$this->dumped_images)) - $this->dumped_images[] = $path; - } - return $path; - } - - function setLinkIcon($proto, $image = false) { - if (!$image) - $image = $proto; - - $this->_linkIcons[$proto] = $image; - } - - function getLinkIconURL ($proto) { - $icons = &$this->_linkIcons; - if (!empty($icons[$proto])) - return $this->getImageURL($icons[$proto]); - elseif (!empty($icons['*'])) - return $this->getImageURL($icons['*']); - return false; - } - - var $_linkIcon = 'front'; // or 'after' or 'no'. - // maybe also 'spanall': there is a scheme currently in effect with front, which - // spans the icon only to the first, to let the next words wrap on line breaks - // see stdlib.php:PossiblyGlueIconToText() - function getLinkIconAttr () { - return $this->_linkIcon; - } - function setLinkIconAttr ($where) { - $this->_linkIcon = $where; - } - - function addButtonAlias ($text, $alias = false) { - $aliases = &$this->_buttonAliases; - - if (is_array($text)) - $aliases = array_merge($aliases, $text); - elseif ($alias === false) - unset($aliases[$text]); - else - $aliases[$text] = $alias; - } - - function getButtonURL ($text) { - $aliases = &$this->_buttonAliases; - if (isset($aliases[$text])) - $text = $aliases[$text]; - - $qtext = urlencode($text); - $url = $this->_findButton("$qtext.png"); - if ($url && strstr($url, '%')) { - $url = preg_replace('|([^/]+)$|e', 'urlencode("\\1")', $url); - } - if (!$url) {// Jeff complained about png not supported everywhere. - // This was not PC until 2005. - $url = $this->_findButton("$qtext.gif"); - if ($url && strstr($url, '%')) { - $url = preg_replace('|([^/]+)$|e', 'urlencode("\\1")', $url); - } - } - if ($url and $this->DUMP_MODE) { - if (empty($this->dumped_buttons)) $this->dumped_buttons = array(); - $file = $url; - if (defined('DATA_PATH')) - $file = substr($url,strlen(DATA_PATH)+1); - $url = "images/buttons/".basename($file); - if (!array_key_exists($text, $this->dumped_buttons)) - $this->dumped_buttons[$text] = $file; - } - return $url; - } - - function _findButton ($button_file) { - if (empty($this->_button_path)) - $this->_button_path = $this->_getButtonPath(); - - foreach ($this->_button_path as $dir) { - if ($path = $this->_findData("$dir/$button_file", 1)) - return $path; - } - return false; - } - - function _getButtonPath () { - $button_dir = $this->_findFile("buttons"); - $path_dir = $this->_path . $button_dir; - if (!file_exists($path_dir) || !is_dir($path_dir)) - return array(); - $path = array($button_dir); - - $dir = dir($path_dir); - while (($subdir = $dir->read()) !== false) { - if ($subdir[0] == '.') - continue; - if ($subdir == 'CVS') - continue; - if (is_dir("$path_dir/$subdir")) - $path[] = "$button_dir/$subdir"; - } - $dir->close(); - // add default buttons - $path[] = "themes/default/buttons"; - $path_dir = $this->_path . "themes/default/buttons"; - $dir = dir($path_dir); - while (($subdir = $dir->read()) !== false) { - if ($subdir[0] == '.') - continue; - if ($subdir == 'CVS') - continue; - if (is_dir("$path_dir/$subdir")) - $path[] = "themes/default/buttons/$subdir"; - } - $dir->close(); - - return $path; - } - - //////////////////////////////////////////////////////////////// - // - // Button style - // - //////////////////////////////////////////////////////////////// - - function makeButton ($text, $url, $class = false, $options = false) { - // FIXME: don't always try for image button? - - // Special case: URLs like 'submit:preview' generate form - // submission buttons. - if (preg_match('/^submit:(.*)$/', $url, $m)) - return $this->makeSubmitButton($text, $m[1], $class, $options); - - if (is_string($text)) - $imgurl = $this->getButtonURL($text); - else - $imgurl = $text; - if ($imgurl) - return new ImageButton($text, $url, - in_array($class,array("wikiaction","wikiadmin"))?"wikibutton":$class, - $imgurl, $options); - else - return new Button($this->maybeSplitWikiWord($text), $url, - $class, $options); - } - - function makeSubmitButton ($text, $name, $class = false, $options = false) { - $imgurl = $this->getButtonURL($text); - - if ($imgurl) - return new SubmitImageButton($text, $name, !$class ? "wikibutton" : $class, $imgurl, $options); - else - return new SubmitButton($text, $name, $class, $options); - } - - /** - * Make button to perform action. - * - * This constructs a button which performs an action on the - * currently selected version of the current page. - * (Or anotherpage or version, if you want...) - * - * @param $action string The action to perform (e.g. 'edit', 'lock'). - * This can also be the name of an "action page" like 'LikePages'. - * Alternatively you can give a hash of query args to be applied - * to the page. - * - * @param $label string Textual label for the button. If left empty, - * a suitable name will be guessed. - * - * @param $page_or_rev mixed The page to link to. This can be - * given as a string (the page name), a WikiDB_Page object, or as - * WikiDB_PageRevision object. If given as a WikiDB_PageRevision - * object, the button will link to a specific version of the - * designated page, otherwise the button links to the most recent - * version of the page. - * - * @return object A Button object. - */ - function makeActionButton ($action, $label = false, $page_or_rev = false, $options = false) { - extract($this->_get_name_and_rev($page_or_rev)); - - if (is_array($action)) { - $attr = $action; - $action = isset($attr['action']) ? $attr['action'] : 'browse'; - } - else - $attr['action'] = $action; - - $class = is_safe_action($action) ? 'wikiaction' : 'wikiadmin'; - if ( !$label ) - $label = $this->_labelForAction($action); - - if ($version) - $attr['version'] = $version; - - if ($action == 'browse') - unset($attr['action']); - - $options = $this->fixAccesskey($options); - - return $this->makeButton($label, WikiURL($pagename, $attr), $class, $options); - } - - function tooltipAccessKeyPrefix() { - static $tooltipAccessKeyPrefix = null; - if ($tooltipAccessKeyPrefix) return $tooltipAccessKeyPrefix; - - $tooltipAccessKeyPrefix = 'alt'; - if (isBrowserOpera()) $tooltipAccessKeyPrefix = 'shift-esc'; - elseif (isBrowserSafari() or browserDetect("Mac") or isBrowserKonqueror()) - $tooltipAccessKeyPrefix = 'ctrl'; - // ff2 win and x11 only - elseif ((browserDetect("firefox/2") or browserDetect("minefield/3") or browserDetect("SeaMonkey/1.1")) - and ((browserDetect("windows") or browserDetect("x11")))) - $tooltipAccessKeyPrefix = 'alt-shift'; - return $tooltipAccessKeyPrefix; - } - - /** Define the accesskey in the title only, with ending [p] or [alt-p]. - * This fixes the prefix in the title and sets the accesskey. - */ - function fixAccesskey($attrs) { - if (!empty($attrs['title']) and preg_match("/\[(alt-)?(.)\]$/", $attrs['title'], $m)) - { - if (empty($attrs['accesskey'])) $attrs['accesskey'] = $m[2]; - // firefox 'alt-shift', MSIE: 'alt', ... see wikibits.js - $attrs['title'] = preg_replace("/\[(alt-)?(.)\]$/", "[".$this->tooltipAccessKeyPrefix()."-\\2]", $attrs['title']); - } - return $attrs; - } - - /** - * Make a "button" which links to a wiki-page. - * - * These are really just regular WikiLinks, possibly - * disguised (e.g. behind an image button) by the theme. - * - * This method should probably only be used for links - * which appear in page navigation bars, or similar places. - * - * Use linkExistingWikiWord, or LinkWikiWord for normal links. - * - * @param $page_or_rev mixed The page to link to. This can be - * given as a string (the page name), a WikiDB_Page object, or as - * WikiDB_PageRevision object. If given as a WikiDB_PageRevision - * object, the button will link to a specific version of the - * designated page, otherwise the button links to the most recent - * version of the page. - * - * @return object A Button object. - */ - function makeLinkButton ($page_or_rev, $label = false, $action = false) { - extract($this->_get_name_and_rev($page_or_rev)); - - $args = $version ? array('version' => $version) : false; - if ($action) $args['action'] = $action; - - return $this->makeButton($label ? $label : $pagename, - WikiURL($pagename, $args), 'wiki'); - } - - function _get_name_and_rev ($page_or_rev) { - $version = false; - - if (empty($page_or_rev)) { - global $request; - $pagename = $request->getArg("pagename"); - $version = $request->getArg("version"); - } - elseif (is_object($page_or_rev)) { - if (isa($page_or_rev, 'WikiDB_PageRevision')) { - $rev = $page_or_rev; - $page = $rev->getPage(); - if (!$rev->isCurrent()) $version = $rev->getVersion(); - } - else { - $page = $page_or_rev; - } - $pagename = $page->getName(); - } - elseif (is_numeric($page_or_rev)) { - $version = $page_or_rev; - } - else { - $pagename = (string) $page_or_rev; - } - return compact('pagename', 'version'); - } - - function _labelForAction ($action) { - switch ($action) { - case 'edit': return _("Edit"); - case 'diff': return _("Diff"); - case 'logout': return _("Sign Out"); - case 'login': return _("Sign In"); - case 'lock': return _("Lock Page"); - case 'unlock': return _("Unlock Page"); - case 'remove': return _("Remove Page"); - default: - // I don't think the rest of these actually get used. - // 'setprefs' - // 'upload' 'dumpserial' 'loadfile' 'zip' - // 'save' 'browse' - return gettext(ucfirst($action)); - } - } - - //---------------------------------------------------------------- - var $_buttonSeparator = "\n | "; - - function setButtonSeparator($separator) { - $this->_buttonSeparator = $separator; - } - - function getButtonSeparator() { - return $this->_buttonSeparator; - } - - - //////////////////////////////////////////////////////////////// - // - // CSS - // - // Notes: - // - // Based on testing with Galeon 1.2.7 (Mozilla 1.2): - // Automatic media-based style selection (via <link> tags) only - // seems to work for the default style, not for alternate styles. - // - // Doing - // - // <link rel="stylesheet" type="text/css" href="phpwiki.css" /> - // <link rel="stylesheet" type="text/css" href="phpwiki-printer.css" media="print" /> - // - // works to make it so that the printer style sheet get used - // automatically when printing (or print-previewing) a page - // (but when only when the default style is selected.) - // - // Attempts like: - // - // <link rel="alternate stylesheet" title="Modern" - // type="text/css" href="phpwiki-modern.css" /> - // <link rel="alternate stylesheet" title="Modern" - // type="text/css" href="phpwiki-printer.css" media="print" /> - // - // Result in two "Modern" choices when trying to select alternate style. - // If one selects the first of those choices, one gets phpwiki-modern - // both when browsing and printing. If one selects the second "Modern", - // one gets no CSS when browsing, and phpwiki-printer when printing. - // - // The Real Fix? - // ============= - // - // We should probably move to doing the media based style - // switching in the CSS files themselves using, e.g.: - // - // @import url(print.css) print; - // - //////////////////////////////////////////////////////////////// - - function _CSSlink($title, $css_file, $media, $is_alt = false) { - // Don't set title on default style. This makes it clear to - // the user which is the default (i.e. most supported) style. - if ($is_alt and isBrowserKonqueror()) - return HTML(); - $link = HTML::link(array('rel' => $is_alt ? 'alternate stylesheet' : 'stylesheet', - 'type' => 'text/css', - 'charset' => $GLOBALS['charset'], - 'href' => $this->_findData($css_file))); - if ($is_alt) - $link->setAttr('title', $title); - - if ($media) - $link->setAttr('media', $media); - if ($this->DUMP_MODE) { - if (empty($this->dumped_css)) $this->dumped_css = array(); - if (!in_array($css_file,$this->dumped_css)) $this->dumped_css[] = $css_file; - $link->setAttr('href', basename($link->getAttr('href'))); - } - - return $link; - } - - /** Set default CSS source for this theme. - * - * To set styles to be used for different media, pass a - * hash for the second argument, e.g. - * - * $theme->setDefaultCSS('default', array('' => 'normal.css', - * 'print' => 'printer.css')); - * - * If you call this more than once, the last one called takes - * precedence as the default style. - * - * @param string $title Name of style (currently ignored, unless - * you call this more than once, in which case, some of the style - * will become alternate (rather than default) styles, and then their - * titles will be used. - * - * @param mixed $css_files Name of CSS file, or hash containing a mapping - * between media types and CSS file names. Use a key of '' (the empty string) - * to set the default CSS for non-specified media. (See above for an example.) - */ - function setDefaultCSS ($title, $css_files) { - if (!is_array($css_files)) - $css_files = array('' => $css_files); - // Add to the front of $this->_css - unset($this->_css[$title]); - $this->_css = array_merge(array($title => $css_files), $this->_css); - } - - /** Set alternate CSS source for this theme. - * - * @param string $title Name of style. - * @param string $css_files Name of CSS file. - */ - function addAlternateCSS ($title, $css_files) { - if (!is_array($css_files)) - $css_files = array('' => $css_files); - $this->_css[$title] = $css_files; - } - - /** - * @return string HTML for CSS. - */ - function getCSS () { - $css = array(); - $is_alt = false; - foreach ($this->_css ... [truncated message content] |