From 33483934028b4061c01946c8c3319e7ceced108d Mon Sep 17 00:00:00 2001 From: vargenau Date: Wed, 11 Aug 2010 11:58:40 +0000 Subject: [PATCH] Harmonize file footer git-svn-id: svn://svn.code.sf.net/p/phpwiki/code/trunk@7638 96ab9672-09ca-45d6-a79d-3d69d39ca109 --- RPC2.php | 9 +- SOAP.php | 27 +- index.php | 25 +- lib/AccessLog.php | 54 +- lib/BlockParser.php | 99 +- lib/CachedMarkup.php | 109 +- lib/DbaDatabase.php | 23 +- lib/DbaListSet.php | 12 +- lib/ErrorManager.php | 51 +- lib/ExternalReferrer.php | 11 +- lib/HtmlElement.php | 17 +- lib/HtmlElement5.php | 17 +- lib/HtmlParser.php | 37 +- lib/HttpClient.php | 23 +- lib/IniConfig.php | 125 +- lib/InlineParser.php | 187 ++- lib/PageList.php | 207 ++- lib/RSSWriter091.php | 31 +- lib/RssParser.php | 17 +- lib/RssWriter.php | 24 +- lib/RssWriter2.php | 15 +- lib/SemanticWeb.php | 59 +- lib/WikiCallback.php | 7 +- lib/WikiDB/ADODB.php | 9 +- lib/WikiDB/PDO.php | 11 +- lib/WikiDB/SQL.php | 9 +- lib/WikiDB/adodb/adodb.inc.php | 1367 +++++++++--------- lib/WikiDB/adodb/drivers/adodb-mysql.inc.php | 311 ++-- lib/WikiDB/backend.php | 83 +- lib/WikiDB/backend/ADODB.php | 169 ++- lib/WikiDB/backend/ADODB_mssql.php | 9 +- lib/WikiDB/backend/ADODB_mssqlnative.php | 27 +- lib/WikiDB/backend/ADODB_mysql.php | 39 +- lib/WikiDB/backend/ADODB_oci8po.php | 27 +- lib/WikiDB/backend/ADODB_postgres7.php | 15 +- lib/WikiDB/backend/ADODB_sqlite.php | 9 +- lib/WikiDB/backend/PDO.php | 117 +- lib/WikiDB/backend/PDO_mysql.php | 17 +- lib/WikiDB/backend/PDO_oci8.php | 7 +- lib/WikiDB/backend/PDO_pgsql.php | 9 +- lib/WikiDB/backend/PearDB.php | 125 +- lib/WikiDB/backend/PearDB_ffpgsql.php | 67 +- lib/WikiDB/backend/PearDB_mysql.php | 29 +- lib/WikiDB/backend/PearDB_oci8.php | 19 +- lib/WikiDB/backend/PearDB_pgsql.php | 43 +- lib/WikiDB/backend/PearDB_sqlite.php | 13 +- lib/WikiDB/backend/cvs.php | 225 ++- lib/WikiDB/backend/dba.php | 7 +- lib/WikiDB/backend/dbaBase.php | Bin 31422 -> 31312 bytes lib/WikiDB/backend/dumb/AllRevisionsIter.php | 13 +- lib/WikiDB/backend/dumb/BackLinkIter.php | 5 +- lib/WikiDB/backend/dumb/LinkSearchIter.php | 27 +- lib/WikiDB/backend/dumb/MostPopularIter.php | 9 +- lib/WikiDB/backend/dumb/MostRecentIter.php | 9 +- lib/WikiDB/backend/dumb/TextSearchIter.php | 13 +- lib/WikiDB/backend/dumb/WantedPagesIter.php | 5 +- lib/WikiDB/backend/file.php | 67 +- lib/WikiDB/backend/flatfile.php | 43 +- lib/WikiDB/dba.php | 9 +- lib/WikiDB/file.php | 11 +- lib/WikiDB/flatfile.php | 15 +- lib/WikiPlugin.php | 69 +- lib/WikiPluginCached.php | 327 +++-- lib/WikiTheme.php | 185 ++- lib/XmlElement.php | 41 +- lib/XmlParser.php | 25 +- lib/XmlRpcClient.php | 13 +- lib/XmlRpcServer.php | 235 ++- lib/config.php | 43 +- lib/display.php | 45 +- lib/gif.php | 29 +- lib/imdb.php | 15 +- lib/install.php | 5 +- lib/loadsave.php | 87 +- lib/plugin/AddComment.php | 1 - lib/plugin/AnalyseAccessLogSql.php | 1 - lib/plugin/AuthorHistory.php | 1 - lib/plugin/BackLinks.php | 1 - lib/plugin/BoxRight.php | 1 - lib/plugin/CacheTest.php | 3 +- lib/plugin/Calendar.php | 1 - lib/plugin/CalendarList.php | 1 - lib/plugin/Comment.php | 1 - lib/plugin/CreateBib.php | 4 +- lib/plugin/CreateToc.php | 1 - lib/plugin/CurrentTime.php | 1 - lib/plugin/Diff.php | 1 - lib/plugin/DynamicIncludePage.php | 1 - lib/plugin/EditMetaData.php | 1 - lib/plugin/FileInfo.php | 1 - lib/plugin/FoafViewer.php | 1 - lib/plugin/FrameInclude.php | 1 - lib/plugin/GoogleMaps.php | 1 - lib/plugin/GraphViz.php | 1 - lib/plugin/HelloWorld.php | 1 - lib/plugin/Imdb.php | 1 - lib/plugin/IncludePage.php | 1 - lib/plugin/IncludePages.php | 1 - lib/plugin/IncludeSiteMap.php | 1 - lib/plugin/IncludeTree.php | 1 - lib/plugin/InterWikiSearch.php | 1 - lib/plugin/JabberPresence.php | 1 - lib/plugin/LdapSearch.php | 1 - lib/plugin/ListSubpages.php | 1 - lib/plugin/MediawikiTable.php | 1 - lib/plugin/ModeratedPage.php | 1 - lib/plugin/NoCache.php | 1 - lib/plugin/OldStyleTable.php | 1 - lib/plugin/PageDump.php | 1 - lib/plugin/PageHistory.php | 1 - lib/plugin/PageInfo.php | 1 - lib/plugin/PageTrail.php | 1 - lib/plugin/PasswordReset.php | 1 - lib/plugin/PhotoAlbum.php | 1 - lib/plugin/PhpHighlight.php | 1 - lib/plugin/PhpWeather.php | 1 - lib/plugin/Ploticus.php | 1 - lib/plugin/PopUp.php | 1 - lib/plugin/RateIt.php | 1 - lib/plugin/RawHtml.php | 1 - lib/plugin/RecentChanges.php | 1 - lib/plugin/RecentChangesCached.php | 3 +- lib/plugin/RecentComments.php | 1 - lib/plugin/RecentEdits.php | 1 - lib/plugin/RecentReferrers.php | 1 - lib/plugin/RedirectTo.php | 1 - lib/plugin/RelatedChanges.php | 1 - lib/plugin/RichTable.php | 1 - lib/plugin/RssFeed.php | 1 - lib/plugin/SiteMap.php | 1 - lib/plugin/SpellCheck.php | 1 - lib/plugin/SqlResult.php | 1 - lib/plugin/SyncWiki.php | 1 - lib/plugin/SyntaxHighlighter.php | 1 - lib/plugin/TeX2png.php | 1 - lib/plugin/Template.php | 1 - lib/plugin/TexToPng.php | 3 +- lib/plugin/Transclude.php | 1 - lib/plugin/TranslateText.php | 1 - lib/plugin/UnfoldSubpages.php | 1 - lib/plugin/UpLoad.php | 1 - lib/plugin/UriResolver.php | 1 - lib/plugin/UserPreferences.php | 1 - lib/plugin/WatchPage.php | 1 - lib/plugin/WhoIsOnline.php | 1 - lib/plugin/WikiAdminUtils.php | 2 - lib/plugin/WikiBlog.php | 1 - lib/plugin/WikiForm.php | 1 - lib/plugin/WikiFormRich.php | 1 - lib/plugin/WikiForum.php | 1 - lib/plugin/WikiPoll.php | 1 - lib/plugin/WikicreoleTable.php | 1 - lib/plugin/YouTube.php | 1 - lib/plugin/_AuthInfo.php | 1 - lib/plugin/_BackendInfo.php | 1 - lib/plugin/_PreferencesInfo.php | 1 - lib/plugin/_Retransform.php | 1 - lib/plugin/_WikiTranslation.php | 1 - lib/plugin/text2png.php | 2 - lib/prepend.php | 20 +- lib/purgepage.php | 1 - lib/removepage.php | 2 - lib/stdlib.php | 267 ++-- lib/upgrade.php | 119 +- tests/CompatInfo.php | 16 +- tests/unit/lib/HtmlParserTest.php | 8 +- tests/unit/lib/InlineParserTest.php | 23 +- tests/unit/lib/XmlRpcTest.php | 5 +- tests/unit/test.php | 63 +- themes/Crao/themeinfo.php | 10 +- themes/Hawaiian/lib/random.php | 7 +- themes/Hawaiian/themeinfo.php | 4 +- themes/MacOSX/lib/RecentChanges.php | 6 +- themes/MacOSX/themeinfo.php | 8 +- themes/MonoBook/themeinfo.php | 30 +- themes/Portland/lib/RecentChanges.php | 4 +- themes/Portland/themeinfo.php | 7 +- themes/Sidebar/themeinfo.php | 20 +- themes/SpaceWiki/lib/RecentChanges.php | 6 +- themes/SpaceWiki/themeinfo.php | 7 +- themes/Wordpress/lib/RecentChanges.php | 4 +- themes/Wordpress/themeinfo.php | 9 +- themes/blog/lib/RecentChanges.php | 3 +- themes/blog/themeinfo.php | 27 +- themes/default/themeinfo.php | 4 +- themes/gforge/themeinfo.php | 4 +- themes/shamino_com/themeinfo.php | 15 +- themes/wikilens/themeinfo.php | 10 +- 188 files changed, 2937 insertions(+), 3162 deletions(-) diff --git a/RPC2.php b/RPC2.php index a5ab8d8d3..3aa8f80f6 100644 --- a/RPC2.php +++ b/RPC2.php @@ -1,4 +1,4 @@ -service(); -// (c-file-style: "gnu") // Local Variables: // mode: php // tab-width: 8 // c-basic-offset: 4 // c-hanging-comment-ender-p: nil // indent-tabs-mode: nil -// End: -?> \ No newline at end of file +// End: +?> diff --git a/SOAP.php b/SOAP.php index c59735d45..722fb64af 100644 --- a/SOAP.php +++ b/SOAP.php @@ -5,11 +5,11 @@ * Please see http://phpwiki.sourceforge.net/phpwiki/PhpWiki.wdsl * for the wdsl discussion. * - * Todo: - * checkCredentials: set the $GLOBALS['request']->_user object for + * Todo: + * checkCredentials: set the $GLOBALS['request']->_user object for * mayAccessPage * enable native pecl extension (xml-rpc or soap) - * serverurl: + * serverurl: * Installer helper which changes server url of the default PhpWiki.wdsl * Or do it dynamically in the soap class? No, the client must connect to us. * @@ -51,7 +51,7 @@ function checkCredentials(&$server, &$credentials, $access, $pagename) { $credentials['username'] = $_SERVER['REMOTE_ADDR']; elseif (isset($GLOBALS['REMOTE_ADDR'])) $credentials['username'] = $GLOBALS['REMOTE_ADDR']; - else + else $credentials['username'] = $server->host; } } @@ -63,7 +63,7 @@ function checkCredentials(&$server, &$credentials, $access, $pagename) { } else { $request->_user = new WikiUser($request, $credentials['username']); } - $request->_user->AuthCheck(array('userid' => $credentials['username'], + $request->_user->AuthCheck(array('userid' => $credentials['username'], 'passwd' => $credentials['password'])); if (! mayAccessPage ($access, $pagename)) $server->fault(401,'',"no permission"); @@ -73,8 +73,8 @@ $GLOBALS['SERVER_NAME'] = SERVER_URL; $GLOBALS['SCRIPT_NAME'] = DATA_PATH . "/SOAP.php"; $url = SERVER_URL . DATA_PATH . "/SOAP.php"; -// Local or external wdsl support is experimental. -// It works without also. Just the client has to +// Local or external wdsl support is experimental. +// It works without also. Just the client has to // know the wdsl definitions. $server = new soap_server(/* 'PhpWiki.wdsl' */); // Now change the server url to ours, because in the wdsl is the original PhpWiki address @@ -213,7 +213,7 @@ function getRecentChanges($limit=false, $since=false, $include_minor=false, $cre global $server; checkCredentials($server,$credentials,'view',_("RecentChanges")); $dbi = WikiDB::open($GLOBALS['DBParams']); - $params = array('limit' => $limit, 'since' => $since, + $params = array('limit' => $limit, 'since' => $since, 'include_minor_revisions' => $include_minor); $page_iter = $dbi->mostRecent($params); $pages = array(); @@ -303,13 +303,13 @@ function callPlugin($pluginname, $pluginargs, $credentials=false) { } return $pages; } -/** +/** * array listRelations([ Integer option = 1 ]) * * Returns an array of all available relation names. * option: 1 relations only ( with 0 also ) * option: 2 attributes only - * option: 3 both, all names of relations and attributes + * option: 3 both, all names of relations and attributes * option: 4 unsorted, this might be added as bitvalue: 7 = 4+3. default: sorted * For some semanticweb autofill methods. * @@ -318,8 +318,8 @@ function callPlugin($pluginname, $pluginargs, $credentials=false) { function listRelations($option = 1, $credentials=false) { global $server; checkCredentials($server,$credentials,'view',_("HomePage")); - $also_attributes = $option & 2; - $only_attributes = $option & 2 and !($option & 1); + $also_attributes = $option & 2; + $only_attributes = $option & 2 and !($option & 1); $sorted = !($option & 4); return $dbh->listRelations($also_attributes, $only_attributes, @@ -351,12 +351,11 @@ function linkSearch($linktype, $search, $pages="*", $relation="*", $credentials= $server->service($GLOBALS['HTTP_RAW_POST_DATA']); -// (c-file-style: "gnu") // Local Variables: // mode: php // tab-width: 8 // c-basic-offset: 4 // c-hanging-comment-ender-p: nil // indent-tabs-mode: nil -// End: +// End: ?> diff --git a/index.php b/index.php index 76577713e..a7477b6cc 100644 --- a/index.php +++ b/index.php @@ -1,15 +1,15 @@ diff --git a/lib/AccessLog.php b/lib/AccessLog.php index f5e3ee7b5..b0ba22b68 100644 --- a/lib/AccessLog.php +++ b/lib/AccessLog.php @@ -52,7 +52,7 @@ class Request_AccessLog { //$request->_accesslog =& $this; //if (empty($request->_accesslog->entries)) register_shutdown_function("Request_AccessLogEntry_shutdown_function"); - + if ($do_sql) { if (!$request->_dbi->isSQL()) { trigger_error("Unsupported database backend for ACCESS_LOG_SQL.\nNeed DATABASE_TYPE=SQL or ADODB or PDO"); @@ -126,7 +126,7 @@ class Request_AccessLog { if ($this->logtable) { // mysql specific only: return $this->read_sql("request_host=".$this->_dbi->quote($host) - ." AND time_stamp > ". (time()-$since_minutes*60) + ." AND time_stamp > ". (time()-$since_minutes*60) ." ORDER BY time_stamp DESC"); } else { $iter = new WikiDB_Array_generic_iter(); @@ -215,7 +215,7 @@ class Request_AccessLogEntry /** * Constructor. * - * The log entry will be automatically appended to the log file or + * The log entry will be automatically appended to the log file or * SQL table when the current request terminates. * * If you want to modify a Request_AccessLogEntry before it gets @@ -267,7 +267,7 @@ class Request_AccessLogEntry function setStatus ($status) { $this->status = $status; } - + /** * Set response size. * @@ -281,7 +281,7 @@ class Request_AccessLogEntry // Workaround: $this->duration = str_replace(",",".",sprintf("%f",$seconds)); } - + /** * Get time zone offset. * @@ -351,7 +351,7 @@ class Request_AccessLogEntry /* If ACCESS_LOG_SQL & 2 we do write it by our own */ function write_sql() { global $request; - + $dbh =& $request->_dbi; if ($dbh and $dbh->isOpen() and $this->_accesslog->logtable) { //$log_tbl =& $this->_accesslog->logtable; @@ -365,7 +365,7 @@ class Request_AccessLogEntry if (!empty($args['pref']['passwd2'])) $args['pref']['passwd2'] = ''; $this->request_args = substr(serialize($args),0,254); // if VARCHAR(255) is used. } else { - $this->request_args = $request->get('QUERY_STRING'); + $this->request_args = $request->get('QUERY_STRING'); } $this->request_method = $request->get('REQUEST_METHOD'); $this->request_uri = $request->get('REQUEST_URI'); @@ -383,7 +383,7 @@ class Request_AccessLogEntry */ function Request_AccessLogEntry_shutdown_function () { global $request; - + if (isset($request->_accesslog->entries) and $request->_accesslog->logfile) foreach ($request->_accesslog->entries as $entry) { $entry->write_file(); @@ -435,12 +435,12 @@ class Request_AccessLog_SQL $query = ''; $backend_type = $request->_dbi->_backend->backendType(); switch ($backend_type) { - case 'mysql': + case 'mysql': $Referring_URL = "left(referer,length(referer)-instr(reverse(referer),'?'))"; break; - case 'pgsql': - case 'postgres7': + case 'pgsql': + case 'postgres7': $Referring_URL = "substr(referer,0,position('?' in referer))"; break; - default: + default: $Referring_URL = "referer"; } switch ($args['mode']) { @@ -470,12 +470,12 @@ class Request_AccessLog_SQL if ($where_conditions<>'') $where_conditions = 'WHERE '.$where_conditions.' '; switch ($backend_type) { - case 'mysql': + case 'mysql': $Referring_Domain = "left(referer, if(locate('/', referer, 8) > 0,locate('/', referer, 8) -1, length(referer)))"; break; - case 'pgsql': - case 'postgres7': + case 'pgsql': + case 'postgres7': $Referring_Domain = "substr(referer,0,8) || regexp_replace(substr(referer,8), '/.*', '')"; break; - default: + default: $Referring_Domain = "referer"; break; } $query = "SELECT " @@ -552,13 +552,13 @@ class Request_AccessLog_SQL // If PHPSESSID appears in the URI, just display the URI to the left of this $sessname = session_name(); switch ($backend_type) { - case 'mysql': + case 'mysql': $Request_URI = "IF(instr(request_uri, '$sessname')=0, request_uri,left(request_uri, instr(request_uri, '$sessname')-2))"; break; - case 'pgsql': - case 'postgres7': + case 'pgsql': + case 'postgres7': $Request_URI = "regexp_replace(request_uri, '$sessname.*', '')"; break; - default: + default: $Request_URI = 'request_uri'; break; } $now = time(); @@ -608,7 +608,7 @@ class Request_AccessLog_SQL return array( 'mode' => 'referring_domains', // referring_domains, referring_urls, remote_hosts, users, host_users, search_bots, search_bots_hits - 'caption' => '', + 'caption' => '', // blank means use the mode as the caption/title for the output 'local_referrers' => 'true', // only show external referring sites 'period' => '', // the type of period to report: @@ -698,19 +698,19 @@ class Request_AccessLog_SQL $len = strlen($localhost); $backend_type = $request->_dbi->_backend->backendType(); switch ($backend_type) { - case 'mysql': + case 'mysql': $ref_localhost = "left(referer,$len)<>'$localhost'"; break; - case 'pgsql': - case 'postgres7': + case 'pgsql': + case 'postgres7': $ref_localhost = "substr(referer,0,$len)<>'$localhost'"; break; - default: + default: $ref_localhost = ""; } $where_conditions = $where_conditions.$ref_localhost; } // The assumed contract is that there is a space at the end of the - // conditions string, so that following SQL clauses (such as GROUP BY) + // conditions string, so that following SQL clauses (such as GROUP BY) // will not cause a syntax error if ($where_conditions<>'') $where_conditions = $where_conditions.' '; @@ -729,7 +729,6 @@ class Request_AccessLog_SQL } -// For emacs users // Local Variables: // mode: php // tab-width: 8 @@ -737,5 +736,4 @@ class Request_AccessLog_SQL // c-hanging-comment-ender-p: nil // indent-tabs-mode: nil // End: -// vim: expandtab shiftwidth=4: ?> diff --git a/lib/BlockParser.php b/lib/BlockParser.php index 6688fc222..e8c6db58d 100644 --- a/lib/BlockParser.php +++ b/lib/BlockParser.php @@ -4,17 +4,17 @@ * Copyright (C) 2008-2009 Marc-Etienne Vargenau, Alcatel-Lucent * * 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 @@ -24,11 +24,11 @@ require_once('lib/CachedMarkup.php'); require_once('lib/InlineParser.php'); /** - * Deal with paragraphs and proper, recursive block indents + * Deal with paragraphs and proper, recursive block indents * for the new style markup (version 2) * * Everything which goes over more than line: - * automatic lists, UL, OL, DL, table, blockquote, verbatim, + * automatic lists, UL, OL, DL, table, blockquote, verbatim, * p, pre, plugin, ... * * FIXME: @@ -36,12 +36,12 @@ require_once('lib/InlineParser.php'); * (old-style) tables * FIXME: unify this with the RegexpSet in InlineParser. * - * FIXME: This is very php5 sensitive: It was fixed for 1.3.9, - * but is again broken with the 1.3.11 + * FIXME: This is very php5 sensitive: It was fixed for 1.3.9, + * but is again broken with the 1.3.11 * allow_call_time_pass_reference clean fixes * * @package Markup - * @author: Geoffrey T. Dairiki + * @author: Geoffrey T. Dairiki */ /** @@ -97,7 +97,7 @@ class AnchoredRegexpSet if (! preg_match($this->_re, $text, $m)) { return false; } - + $match = new AnchoredRegexpSet_match; $match->postmatch = substr($text, strlen($m[0])); $match->match = $m[1]; @@ -136,7 +136,7 @@ class AnchoredRegexpSet if (! preg_match($pat, $text, $m)) { return false; } - + $match = new AnchoredRegexpSet_match; $match->postmatch = substr($text, strlen($m[0])); $match->match = $m[1]; @@ -146,11 +146,11 @@ class AnchoredRegexpSet } - + class BlockParser_Input { function BlockParser_Input ($text) { - + // Expand leading tabs. // FIXME: do this better. // @@ -182,14 +182,14 @@ class BlockParser_Input { } return $this->_atSpace; } - + function currentLine () { if ($this->_pos >= count($this->_lines)) { return false; } return $this->_lines[$this->_pos]; } - + function nextLine () { $this->_atSpace = $this->_lines[$this->_pos++] === ''; if ($this->_pos >= count($this->_lines)) { @@ -202,7 +202,7 @@ class BlockParser_Input { $this->_atSpace = ($this->_lines[$this->_pos] === ''); $this->_pos++; } - + function getPos () { return array($this->_pos, $this->_atSpace); } @@ -225,7 +225,7 @@ class BlockParser_Input { else return ""; } - + function _debug ($tab, $msg) { //return ; $where = $this->where(); @@ -233,7 +233,7 @@ class BlockParser_Input { printXML(HTML::div("$tab $msg: at: '", HTML::tt($where), "'")); - flush(); + flush(); } } @@ -271,7 +271,7 @@ class BlockParser_InputSubBlock extends BlockParser_Input else return $this->_atSpace; } - + function currentLine () { return $this->_line; } @@ -296,7 +296,7 @@ class BlockParser_InputSubBlock extends BlockParser_Input function advance () { $this->nextLine(); } - + function getPos () { return array($this->_line, $this->_atSpace, $this->_input->getPos()); } @@ -306,7 +306,7 @@ class BlockParser_InputSubBlock extends BlockParser_Input $this->_atSpace = $pos[1]; $this->_input->setPos($pos[2]); } - + function getPrefix () { assert ($this->_line !== false); $line = $this->_input->currentLine(); @@ -322,7 +322,7 @@ class BlockParser_InputSubBlock extends BlockParser_Input return $this->_input->where(); } } - + class Block_HtmlElement extends HtmlElement { @@ -335,7 +335,7 @@ class Block_HtmlElement extends HtmlElement } class ParsedBlock extends Block_HtmlElement { - + function ParsedBlock (&$input, $tag = 'div', $attr = false) { $this->Block_HtmlElement($tag, $attr); $this->_initBlockTypes(); @@ -345,8 +345,8 @@ class ParsedBlock extends Block_HtmlElement { function _parse (&$input) { // php5 failed to advance the block. php5 copies objects by ref. // nextBlock == block, both are the same objects. So we have to clone it. - for ($block = $this->_getBlock($input); - $block; + for ($block = $this->_getBlock($input); + $block; $block = (is_object($nextBlock) ? clone($nextBlock) : $nextBlock)) { while ($nextBlock = $this->_getBlock($input)) { @@ -399,7 +399,7 @@ class ParsedBlock extends Block_HtmlElement { $this->_atSpace = $input->skipSpace(); $line = $input->currentLine(); - if ($line === false or $line === '') { // allow $line === '0' + if ($line === false or $line === '') { // allow $line === '0' return false; } $tight_top = !$this->_atSpace; @@ -409,7 +409,7 @@ class ParsedBlock extends Block_HtmlElement { $block = clone($this->_block_types[$m->regexp_ind]); if (DEBUG & _DEBUG_PARSER) $input->_debug('>', get_class($block)); - + if ($block->_match($input, $m)) { //$block->_text = $line; if (DEBUG & _DEBUG_PARSER) @@ -421,7 +421,7 @@ class ParsedBlock extends Block_HtmlElement { if (DEBUG & _DEBUG_PARSER) $input->_debug('[', "_match failed"); } - if ($line === false or $line === '') // allow $line === '0' + if ($line === false or $line === '') // allow $line === '0' return false; trigger_error("Couldn't match block: '$line'", E_USER_NOTICE); @@ -500,7 +500,7 @@ class Block_blockquote extends BlockMarkup 'blockquote'); return true; } - + function merge ($nextBlock) { if (get_class($nextBlock) == get_class($this)) { assert ($nextBlock->_depth < $this->_depth); @@ -535,7 +535,7 @@ class Block_list extends BlockMarkup if (preg_match('/[*#+-o]/', $input->getPrefix())) { return false; } - + $prefix = $m->match; $indent = sprintf("\\ {%d}", strlen($prefix)); @@ -619,7 +619,7 @@ class Block_table_dl_defn extends XmlContent { var $nrows; var $ncols; - + function Block_table_dl_defn ($term, $defn) { $this->XmlContent(); if (!is_array($defn)) @@ -647,7 +647,7 @@ class Block_table_dl_defn extends XmlContent $this->_tight_top = $tight_top; $this->_tight_bot = $tight_bot; } - + function _addToRow ($item) { if (empty($this->_accum)) { $this->_accum = HTML::td(); @@ -663,7 +663,7 @@ class Block_table_dl_defn extends XmlContent $row->setTightness($this->_next_tight_top, $tight_bottom); $this->_next_tight_top = $tight_bottom; - + $this->pushContent($row); $this->_accum = false; $this->_nrows++; @@ -675,7 +675,7 @@ class Block_table_dl_defn extends XmlContent return; $this->_flushRow($table_rows[0]->_tight_top); - + foreach ($table_rows as $subdef) { $this->pushContent($subdef); $this->_nrows += $subdef->nrows(); @@ -690,7 +690,7 @@ class Block_table_dl_defn extends XmlContent else $first_row->unshiftContent($th); } - + function _ComputeNcols ($defn) { $ncols = 2; foreach ($defn as $item) { @@ -774,7 +774,7 @@ class Block_table_dl extends Block_dl function _setTightness($top, $bot) { $this->_content[0]->setTightness($top, $bot); } - + function finish () { $defs = &$this->_content; @@ -782,7 +782,7 @@ class Block_table_dl extends Block_dl $ncols = 0; foreach ($defs as $defn) $ncols = max($ncols, $defn->ncols()); - + foreach ($defs as $key => $defn) $defs[$key]->setWidth($ncols); @@ -807,7 +807,7 @@ class Block_oldlists extends Block_list if (!preg_match('/[*#;]*$/A', $input->getPrefix())) { return false; } - + $prefix = $m->match; $oldindent = '[*#;](?=[#*]|;.*:.*\S)'; @@ -873,7 +873,7 @@ class Block_oldlists extends Block_list */ echo 'count($this->_content): ', count($this->_content),"\n"; echo "\$this->_content[0]: "; var_dump ($this->_content[0]); - + for ($i=1; $i < min(5, count($this->_content)); $i++) { $c =& $this->_content[$i]; echo '$this->_content[',$i,"]: \n"; @@ -918,12 +918,12 @@ class Block_pre extends BlockMarkup } } $input->advance(); - + if ($m->match == '') $text = join("
\n", $text); else $text = join("\n", $text); - + // FIXME: no , , , , or 's allowed // in a
.
         if ($m->match == '
') {
@@ -1198,7 +1198,7 @@ class Block_email_blockquote extends BlockMarkup
 {
     var $_attr = array('class' => 'mail-style-quote');
     var $_re = '>\ ?';
-    
+  
     function _match (&$input, $m) {
         //$indent = str_replace(' ', '\\ ', $m->match) . '|>$';
         $indent = $this->_re;
@@ -1235,14 +1235,14 @@ class Block_hr extends BlockMarkup
 class Block_heading extends BlockMarkup
 {
     var $_re = '!{1,3}';
-    
+  
     function _match (&$input, $m) {
         $tag = "h" . (5 - strlen($m->match));
         $text = TransformInline(trim($m->postmatch));
         $input->advance();
 
         $this->_element = new Block_HtmlElement($tag, false, $text);
-        
+      
         return true;
     }
 }
@@ -1250,7 +1250,7 @@ class Block_heading extends BlockMarkup
 class Block_heading_wikicreole extends BlockMarkup
 {
     var $_re = '={2,6}';
-    
+  
     function _match (&$input, $m) {
         $tag = "h" . strlen($m->match);
         // Remove spaces
@@ -1261,7 +1261,7 @@ class Block_heading_wikicreole extends BlockMarkup
         $input->advance();
 
         $this->_element = new Block_HtmlElement($tag, false, $text);
-        
+      
         return true;
     }
 }
@@ -1312,7 +1312,7 @@ class Block_divspan extends BlockMarkup
     	    $tag = 'div';
 	}
 	// without last >
-        $argstr = substr(trim(substr($m->match,strlen($tag)+1)),0,-1); 
+        $argstr = substr(trim(substr($m->match,strlen($tag)+1)),0,-1);
         $pos = $input->getPos();
         $pi  = $content = $m->postmatch;
         while (!preg_match('/^(.*)\<\/'.$tag.'\>(.*)$/i', $pi, $me)) {
@@ -1330,9 +1330,9 @@ class Block_divspan extends BlockMarkup
         $input->advance();
         if (strstr($content, "\n"))
             $content = TransformText($content);
-        else    
+        else  
             $content = TransformInline($content);
-        if (!$argstr) 
+        if (!$argstr)
             $args = false;
         else {
             $args = array();
@@ -1398,12 +1398,11 @@ function TransformText ($text, $markup = 2.0, $basepage = false) {
     return new XmlContent($output->getContent());
 }
 
-// (c-file-style: "gnu")
 // Local Variables:
 // mode: php
 // tab-width: 8
 // c-basic-offset: 4
 // c-hanging-comment-ender-p: nil
 // indent-tabs-mode: nil
-// End:   
+// End: 
 ?>
diff --git a/lib/CachedMarkup.php b/lib/CachedMarkup.php
index eaf76e84b..dab503da9 100644
--- a/lib/CachedMarkup.php
+++ b/lib/CachedMarkup.php
@@ -1,21 +1,21 @@
-
  * Copyright (C) 2004-2010 $ThePhpWikiProgrammingTeam
  * Copyright (C) 2008-2009 Marc-Etienne Vargenau, Alcatel-Lucent
  *
  * 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
@@ -62,7 +62,7 @@ class CacheableMarkup extends XmlContent {
         // ZLIB format has a five bit checksum in it's header.
         // Lets check for sanity.
         if (((ord($packed[0]) * 256 + ord($packed[1])) % 31 == 0)
-             and (substr($packed,0,2) == "\037\213") 
+             and (substr($packed,0,2) == "\037\213")
                   or (substr($packed,0,2) == "x\332"))   // 120, 218
         {
             if (function_exists('gzuncompress')) {
@@ -84,11 +84,11 @@ class CacheableMarkup extends XmlContent {
         if (preg_match("/^\w+$/", $packed))
             return $packed;
         // happened with _BackendInfo problem also.
-        trigger_error("Can't unpack bad cached markup. Probably php_zlib extension not loaded.", 
+        trigger_error("Can't unpack bad cached markup. Probably php_zlib extension not loaded.",
                       E_USER_WARNING);
         return false;
     }
-    
+  
     /** Get names of wikipages linked to.
      *
      * @return array of hashes { linkto=>pagename, relation=>pagename }
@@ -102,7 +102,7 @@ class CacheableMarkup extends XmlContent {
                 continue;
             $links = array_merge($links, $item_links);
         }
-        // array_unique has a bug with hashes! 
+        // array_unique has a bug with hashes!
         // set_links checks for duplicates, array_merge does not
 	//return array_unique($links);
 	return $links;
@@ -181,7 +181,7 @@ class CacheableMarkup extends XmlContent {
                            . ".*"
                            . "[.?!][\")]*\s*[\"(]*([[:upper:])]|$)";
         }
-        
+      
         if (!isset($this->_description) and preg_match("/$two_sentences/sx", $text))
             $this->_description = preg_replace("/\s*\n\s*/", " ", trim($text));
     }
@@ -204,18 +204,18 @@ class CacheableMarkup extends XmlContent {
     function getDescription () {
         return isset($this->_description) ? $this->_description : '';
     }
-    
+  
     function asXML () {
 	$xml = '';
         $basepage = $this->_basepage;
-        
+      
 	foreach ($this->_content as $item) {
             if (is_string($item)) {
                 $xml .= $item;
             }
-            elseif (is_subclass_of($item, 
-                                   check_php_version(5) 
-                                     ? 'Cached_DynamicContent' 
+            elseif (is_subclass_of($item,
+                                   check_php_version(5)
+                                     ? 'Cached_DynamicContent'
                                      : 'cached_dynamiccontent'))
             {
                 $val = $item->expand($basepage, $this);
@@ -236,11 +236,11 @@ class CacheableMarkup extends XmlContent {
             if (is_string($item)) {
                 print $item;
             }
-            elseif (is_subclass_of($item, 
-                                   check_php_version(5) 
-                                     ? 'Cached_DynamicContent' 
-                                     : 'cached_dynamiccontent')) 
-            {  	// give the content the chance to know about itself or even 
+            elseif (is_subclass_of($item,
+                                   check_php_version(5)
+                                     ? 'Cached_DynamicContent'
+                                     : 'cached_dynamiccontent'))
+            {  	// give the content the chance to know about itself or even
             	// to change itself
                 $val = $item->expand($basepage, $this);
                 if ($val) $val->printXML();
@@ -251,7 +251,7 @@ class CacheableMarkup extends XmlContent {
             }
 	}
     }
-}	
+}
 
 /**
  * The base class for all dynamic content.
@@ -301,7 +301,7 @@ class Cached_Link extends Cached_DynamicContent {
                                    $this->_getURL($basepage),
                                    $this->_getRelation($basepage));
     }
-    
+  
     function _getURL($basepage) {
 	return $this->_url;
     }
@@ -343,18 +343,18 @@ class Cached_WikiLink extends Cached_Link {
 	if (substr($this->_page,0,1) == ':') {
 	    $this->_page = substr($this->_page,1);
 	    $this->_nolink = true;
-        }    
+        }  
         if ($anchor)
             $this->_anchor = $anchor;
         if ($label and $label != $page)
             $this->_label = $label;
-        $this->_basepage = false;    
+        $this->_basepage = false;  
     }
 
     function _getType() {
         return 'internal';
     }
-    
+  
     function getPagename($basepage) {
         $page = new WikiPageName($this->_page, $basepage);
 	if ($page->isValid()) return $page->name;
@@ -364,9 +364,9 @@ class Cached_WikiLink extends Cached_Link {
     function getWikiPageLinks($basepage) {
         if ($basepage == '') return false;
 	if (isset($this->_nolink)) return false;
-        if ($link = $this->getPagename($basepage)) 
+        if ($link = $this->getPagename($basepage))
             return array(array('linkto' => $link));
-        else 
+        else
             return false;
     }
 
@@ -428,7 +428,7 @@ class Cached_WikiLinkIfKnown extends Cached_WikiLink
 	}
         return WikiLink($this->_page, 'if_known');
     }
-}    
+}  
 
 class Cached_SpellCheck extends Cached_WikiLink
 {
@@ -438,14 +438,14 @@ class Cached_SpellCheck extends Cached_WikiLink
     }
 
     function expand($basepage, &$markup) {
-        $link = HTML::a(array('class' => 'spell-wrong', 
+        $link = HTML::a(array('class' => 'spell-wrong',
 			      'title' => 'SpellCheck: '.join(', ', $this->suggestions),
-			      'name' => $this->_page), 
+			      'name' => $this->_page),
 			$this->_page);
         return $link;
     }
-}    
-    
+}  
+  
 class Cached_PhpwikiURL extends Cached_DynamicContent
 {
     function Cached_PhpwikiURL ($url, $label) {
@@ -479,16 +479,16 @@ class Cached_PhpwikiURL extends Cached_DynamicContent
             return $this->_label;
         return $this->_url;
     }
-}    
+}  
 
 /*
  * Relations (::) are named links to pages.
- * Attributes (:=) are named metadata per page, "named links to numbers with units". 
+ * Attributes (:=) are named metadata per page, "named links to numbers with units".
  * We don't want to exhaust the linktable with numbers,
- * since this would create empty pages per each value, 
- * so we don't store the attributes as full relationlink. 
- * But we do store the attribute name as relation with an empty pagename 
- * to denote that this is an attribute, 
+ * since this would create empty pages per each value,
+ * so we don't store the attributes as full relationlink.
+ * But we do store the attribute name as relation with an empty pagename
+ * to denote that this is an attribute,
  * and to enable a fast listRelations mode=attributes
  */
 class Cached_SemanticLink extends Cached_WikiLink {
@@ -519,12 +519,12 @@ class Cached_SemanticLink extends Cached_WikiLink {
 	if (!isset($this->_page) and isset($this->_attribute)) {
             // An attribute: we store it in the basepage now, to fill the cache for page->save
             // TODO: side-effect free query
-            $page = $GLOBALS['request']->getPage($basepage); 
+            $page = $GLOBALS['request']->getPage($basepage);
             $page->setAttribute($this->_relation, $this->_attribute);
             $this->_page = $basepage;
             return array(array('linkto' => '', 'relation' => $this->_relation));
 	}
-        if ($link = $this->getPagename($basepage)) 
+        if ($link = $this->getPagename($basepage))
             return array(array('linkto' => $link, 'relation' => $this->_relation));
         else
             return false;
@@ -539,10 +539,10 @@ class Cached_SemanticLink extends Cached_WikiLink {
         $is_attribute = ($m[2] == ':=');
         if ($is_attribute) {
             $this->_attribute = urldecode($m[3]);
-	    // since this stored in the markup cache, we are extra sensible 
+	    // since this stored in the markup cache, we are extra sensible
 	    // not to store false empty stuff.
 	    $units = new Units();
-            if (!DISABLE_UNITS and !$units->errcode) 
+            if (!DISABLE_UNITS and !$units->errcode)
 	    {
 		$this->_attribute_base = $units->Definition($this->_attribute);
 		$this->_unit = $units->baseunit($this->_attribute);
@@ -572,8 +572,8 @@ class Cached_SemanticLink extends Cached_WikiLink {
 		(
 		 HTML::a(array('href'  => WikiURL($is_attribute ? $this->_relation : $this->_page),
 			       'class' => "wiki ".($is_attribute ? "attribute" : "relation"),
-			       'title' => $is_attribute 
-			       ? $title 
+			       'title' => $is_attribute
+			       ? $title
 			       : sprintf(_("Relation %s to page %s"), $this->_relation, $this->_page)),
 			 $label)
 		 );
@@ -617,7 +617,7 @@ class Cached_SemanticLink extends Cached_WikiLink {
     }
 }
 
-/** 
+/**
  * Highlight found search engine terms
  */
 class Cached_SearchHighlight extends Cached_DynamicContent
@@ -632,8 +632,8 @@ class Cached_SearchHighlight extends Cached_DynamicContent
                                 'title' => _("Found by ") . $this->engine),
                           $this->_word);
     }
-}    
-    
+}  
+  
 class Cached_ExternalLink extends Cached_Link {
 
     function Cached_ExternalLink($url, $label=false) {
@@ -645,7 +645,7 @@ class Cached_ExternalLink extends Cached_Link {
     function _getType() {
         return 'external';
     }
-    
+  
     function _getName($basepage) {
 	$label = isset($this->_label) ? $this->_label : false;
 	return ($label and is_string($label)) ? $label : $this->_url;
@@ -658,7 +658,7 @@ class Cached_ExternalLink extends Cached_Link {
 	$link = LinkURL($this->_url, $label);
 
         if (GOOGLE_LINKS_NOFOLLOW) {
-            // Ignores nofollow when the user who saved the page was authenticated. 
+            // Ignores nofollow when the user who saved the page was authenticated.
             $page = $request->getPage($basepage);
             $current = $page->getCurrentRevision(false);
             if (!$current->get('author_id'))
@@ -675,7 +675,7 @@ class Cached_ExternalLink extends Cached_Link {
 }
 
 class Cached_InterwikiLink extends Cached_ExternalLink {
-    
+  
     function Cached_InterwikiLink($link, $label=false) {
 	$this->_link = $link;
         if ($label)
@@ -706,7 +706,7 @@ class Cached_InterwikiLink extends Cached_ExternalLink {
 	$label = isset($this->_label) ? $this->_label : false;
 	return ($label and is_string($label)) ? $label : $this->_link;
     }
-    
+  
     /* there may be internal interwiki links also */
     function _getType() {
         return $this->getPagename(false) ? 'internal' : 'external';
@@ -737,7 +737,7 @@ class Cached_InterwikiLink extends Cached_ExternalLink {
 }
 
 // Needed to put UserPages to backlinks. Special method to markup userpages with icons
-// Thanks to PhpWiki:DanFr for finding this bug. 
+// Thanks to PhpWiki:DanFr for finding this bug.
 // Fixed since 1.3.8, prev. versions had no userpages in backlinks
 class Cached_UserLink extends Cached_WikiLink {
     function expand($basepage, &$markup) {
@@ -753,7 +753,7 @@ class Cached_UserLink extends Cached_WikiLink {
 }
 
 /**
- * 1.3.13: Previously stored was only _pi. 
+ * 1.3.13: Previously stored was only _pi.
  * A fresh generated cache has now ->name and ->args also.
  * main::isActionPage only checks the raw content.
  */
@@ -771,7 +771,7 @@ class Cached_PluginInvocation extends Cached_DynamicContent {
 
     function setTightness($top, $bottom) {
     }
-    
+  
     function isInlineElement() {
 	return false;
     }
@@ -803,12 +803,11 @@ class Cached_PluginInvocation extends Cached_DynamicContent {
     }
 }
 
-// (c-file-style: "gnu")
 // Local Variables:
 // mode: php
 // tab-width: 8
 // c-basic-offset: 4
 // c-hanging-comment-ender-p: nil
 // indent-tabs-mode: nil
-// End:   
+// End: 
 ?>
diff --git a/lib/DbaDatabase.php b/lib/DbaDatabase.php
index eb8add4f6..4a2868a74 100644
--- a/lib/DbaDatabase.php
+++ b/lib/DbaDatabase.php
@@ -19,7 +19,7 @@ class DbaDatabase
                 $this->_error(
                     sprintf(
                 	    _("The DBA handler %s is unsupported!")."\n".
-                    	    _("Supported handlers are: %s"), 
+                    	    _("Supported handlers are: %s"),
                     	    $handler, join(",",dba_handlers())));
         }
         $this->readonly = false;
@@ -30,11 +30,11 @@ class DbaDatabase
     function set_timeout($timeout) {
         $this->_timeout = $timeout;
     }
-    
+  
     function open($mode = 'w') {
         if ($this->_dbh)
             return;             // already open.
-        
+      
         $watchdog = $this->_timeout;
 
         global $ErrorManager;
@@ -45,7 +45,7 @@ class DbaDatabase
         if (!function_exists("dba_open")) {
             echo "You don't seem to have DBA support compiled into PHP.";
         }
-	
+
         if (READONLY) {
             $mode = 'r';
         }
@@ -62,12 +62,12 @@ class DbaDatabase
             if ($watchdog <= 0)
                 break;
             // "c" failed, try "w" instead.
-            if ($mode == "w" 
-                and file_exists($this->_file) 
+            if ($mode == "w"
+                and file_exists($this->_file)
                 and (isWindows() or !is_writable($this->_file)))
             {
                 // try to continue with read-only
-                if (!defined("READONLY")) 
+                if (!defined("READONLY"))
                     define("READONLY", true);
                 $GLOBALS['request']->_dbi->readonly = true;
                 $this->readonly = true;
@@ -116,7 +116,7 @@ class DbaDatabase
     function exists($key) {
         return dba_exists($key, $this->_dbh);
     }
-    
+  
     function fetch($key) {
         $val = dba_fetch($key, $this->_dbh);
         if ($val === false)
@@ -134,7 +134,7 @@ class DbaDatabase
             return $this->_error("replace($key)");
     }
 
-    
+  
     function firstkey() {
         return dba_firstkey($this->_dbh);
     }
@@ -182,7 +182,7 @@ class DbaDatabase
             return $this->_error("optimize()");
         return 1;
     }
-    
+  
     function _error($mes) {
         //trigger_error("DbaDatabase: $mes", E_USER_WARNING);
         //return false;
@@ -201,12 +201,11 @@ class DbaDatabase
     }
 }
 
-// (c-file-style: "gnu")
 // Local Variables:
 // mode: php
 // tab-width: 8
 // c-basic-offset: 4
 // c-hanging-comment-ender-p: nil
 // indent-tabs-mode: nil
-// End:   
+// End: 
 ?>
diff --git a/lib/DbaListSet.php b/lib/DbaListSet.php
index 590c8e2cd..becb7bfe7 100644
--- a/lib/DbaListSet.php
+++ b/lib/DbaListSet.php
@@ -52,7 +52,7 @@ class DbaListSet
         list( $prev , , ) = explode(':', $this->_dbh->fetch(intval($i)), 3);
         return intval($prev);
     }
-    
+  
     function exists($i) {
         $i = intval($i);
         return $i && $this->_dbh->exists($i);
@@ -68,7 +68,7 @@ class DbaListSet
         list($prev, $next,) = explode(':', $dbh->fetch(intval($i)), 3);
         $dbh->replace($i, "$prev:$next:$data");
     }
-    
+  
     function insert_before($i, $data) {
         assert(intval($i));
         return $this->_insert_before_nc($i, $data);
@@ -78,7 +78,7 @@ class DbaListSet
         assert(intval($i));
         return $this->_insert_after_nc($i, $data);
     }
-    
+  
     function append($seq, $data) {
         $key = "s" . urlencode($seq);
         $this->_insert_before_nc($key, $data);
@@ -88,7 +88,7 @@ class DbaListSet
         $key = "s" . urlencode($seq);
         $this->_insert_after_nc($key, $data);
     }
-    
+  
     function _insert_before_nc($i, &$data) {
         $newkey = $this->_new_key();
         $old_prev = $this->_setprev($i, $newkey);
@@ -135,8 +135,6 @@ class DbaListSet
     }
 }
 
-
-// For emacs users
 // Local Variables:
 // mode: php
 // tab-width: 8
@@ -144,4 +142,4 @@ class DbaListSet
 // c-hanging-comment-ender-p: nil
 // indent-tabs-mode: nil
 // End:
-?>
\ No newline at end of file
+?>
diff --git a/lib/ErrorManager.php b/lib/ErrorManager.php
index f8492c67b..d1026ee9a 100644
--- a/lib/ErrorManager.php
+++ b/lib/ErrorManager.php
@@ -4,7 +4,7 @@ if (isset($GLOBALS['ErrorManager'])) return;
 
 // php5: ignore E_STRICT (var warnings)
 /*
-if (defined('E_STRICT') 
+if (defined('E_STRICT')
     and (E_ALL & E_STRICT)
     and (error_reporting() & E_STRICT)) {
     echo " errormgr: error_reporting=", error_reporting();
@@ -17,9 +17,9 @@ define ('EM_WARNING_ERRORS',
 	E_WARNING | E_CORE_WARNING | E_COMPILE_WARNING | E_USER_WARNING | ((check_php_version(5,3)) ? E_DEPRECATED : 0));
 define ('EM_NOTICE_ERRORS', E_NOTICE | E_USER_NOTICE);
 
-/* It is recommended to leave assertions on. 
+/* It is recommended to leave assertions on.
    You can simply comment the two lines below to leave them on.
-   Only where absolute speed is necessary you might want to turn 
+   Only where absolute speed is necessary you might want to turn
    them off.
 */
 //also turn it on if phpwiki_version notes no release
@@ -40,8 +40,8 @@ function wiki_assert_handler ($file, $line, $code) {
  * of it --- you can access the one instance via $GLOBALS['ErrorManager'].
  *
  * FIXME: more docs.
- */ 
-class ErrorManager 
+ */
+class ErrorManager
 {
     /**
      * Constructor.
@@ -97,7 +97,7 @@ class ErrorManager
         else
             echo $this->_flush_errors();
     }
-    
+  
     /**
      * Get rid of all pending error messages in case of all non-html
      * - pdf or image - output.
@@ -112,7 +112,7 @@ class ErrorManager
      *
      * This also flushes the postponed error queue.
      *
-     * @return object HTML describing any queued errors (or false, if none). 
+     * @return object HTML describing any queued errors (or false, if none).
      */
     function getPostponedErrorsAsHTML() {
         $flushed = $this->_flush_errors();
@@ -129,14 +129,14 @@ class ErrorManager
         }
         if ($worst_err->isNotice())
             return $flushed;
-        $class = $worst_err->getHtmlClass(); 
+        $class = $worst_err->getHtmlClass();
         $html = HTML::div(array('style' => 'border: none', 'class' => $class),
-                          HTML::h4(array('class' => 'errors'), 
+                          HTML::h4(array('class' => 'errors'),
                                    "PHP " . $worst_err->getDescription()));
         $html->pushContent($flushed);
         return $html;
     }
-    
+  
     /**
      * Push a custom error handler on the handler stack.
      *
@@ -228,7 +228,7 @@ class ErrorManager
         if (!empty($GLOBALS['request']->_finishing)) {
             $this->_postpone_mask = 0;
 	}
-        
+      
         $in_handler = true;
 
         foreach ($this->_handlers as $handler) {
@@ -282,7 +282,7 @@ class ErrorManager
         else if (($error->errno & error_reporting()) != 0) {
             if  (($error->errno & $this->_postpone_mask) != 0) {
                 if ((function_exists('isa') and isa($error, 'PhpErrorOnce'))
-                    or (!function_exists('isa') and 
+                    or (!function_exists('isa') and
                     (
                      // stdlib independent isa()
                      (strtolower(get_class($error)) == 'phperroronce')
@@ -311,7 +311,7 @@ class ErrorManager
     function warning($msg, $errno = E_USER_NOTICE) {
         $this->handleError(new PhpWikiError($errno, $msg, '?', '?'));
     }
-    
+  
     /**
      * @access private
      */
@@ -355,7 +355,7 @@ class ErrorManager
             $request->_validators->_mtime = false;
         }
         if ($already) return;
-        
+      
         // FIXME: Howto announce that to Request->cacheControl()?
         if (!headers_sent()) {
             header( "Cache-control: no-cache" );
@@ -370,7 +370,7 @@ class ErrorManager
  *
  * This is necessary since PHP's set_error_handler() does not allow
  * one to set an object method as a handler.
- * 
+ *
  * @access private
  */
 function ErrorManager_errorHandler($errno, $errstr, $errfile, $errline)
@@ -461,7 +461,7 @@ class PhpError {
             return 'errors';
         }
     }
-    
+  
     function getDescription() {
         if ($this->isNotice()) {
             return 'Notice';
@@ -482,7 +482,7 @@ class PhpError {
            $dir = str_replace('/','\\',$dir);
            $this->errfile = str_replace('/','\\',$this->errfile);
            $dir .= "\\";
-        } else 
+        } else
            $dir .= '/';
         $errfile = preg_replace('|^' . preg_quote($dir) . '|', '', $this->errfile);
         $lines = explode("\n", $this->errstr);
@@ -502,7 +502,7 @@ class PhpError {
                          $this->getDescription(),
                          array_shift($lines));
         }
-        
+      
         $html = HTML::div(array('class' => $this->getHtmlClass()), HTML::p($msg));
         // The class is now used for the div container.
         // $html = HTML::div(HTML::p($msg));
@@ -512,7 +512,7 @@ class PhpError {
                 $list->pushContent(HTML::li($line));
             $html->pushContent($list);
         }
-        
+      
         return $html;
     }
 
@@ -569,7 +569,7 @@ class PhpWikiError extends PhpError {
     }
 
     function _getDetail() {
-        return HTML::div(array('class' => $this->getHtmlClass()), 
+        return HTML::div(array('class' => $this->getHtmlClass()),
                          HTML::p($this->getDescription() . ": $this->errstr"));
     }
 }
@@ -577,7 +577,7 @@ class PhpWikiError extends PhpError {
 /**
  * A class representing a Php warning, printed only the first time.
  *
- * Similar to PhpError, except only the first same error message is printed, 
+ * Similar to PhpError, except only the first same error message is printed,
  * with number of occurences.
  */
 class PhpErrorOnce extends PhpError {
@@ -606,7 +606,7 @@ class PhpErrorOnce extends PhpError {
         }
         return $this->_count;
     }
-    
+  
     function _getDetail($count=0) {
     	if (!$count) $count = $this->_count;
 	$dir = defined('PHPWIKI_DIR') ? PHPWIKI_DIR : substr(dirname(__FILE__),0,-4);
@@ -614,7 +614,7 @@ class PhpErrorOnce extends PhpError {
            $dir = str_replace('/','\\',$dir);
            $this->errfile = str_replace('/','\\',$this->errfile);
            $dir .= "\\";
-        } else 
+        } else
            $dir .= '/';
         $errfile = preg_replace('|^' . preg_quote($dir) . '|', '', $this->errfile);
         if (is_string($this->errstr))
@@ -636,7 +636,7 @@ class PhpErrorOnce extends PhpError {
 			 array_shift($lines),
 			 $count > 1 ? sprintf(" (...repeated %d times)",$count) : "");
 	}
-        $html = HTML::div(array('class' => $this->getHtmlClass()), 
+        $html = HTML::div(array('class' => $this->getHtmlClass()),
                           HTML::p($msg));
         if ($lines) {
             $list = HTML::ul();
@@ -644,7 +644,7 @@ class PhpErrorOnce extends PhpError {
                 $list->pushContent(HTML::li($line));
             $html->pushContent($list);
         }
-        
+      
         return $html;
     }
 }
@@ -659,7 +659,6 @@ if (!isset($GLOBALS['ErrorManager'])) {
     $GLOBALS['ErrorManager'] = new ErrorManager;
 }
 
-// (c-file-style: "gnu")
 // Local Variables:
 // mode: php
 // tab-width: 8
diff --git a/lib/ExternalReferrer.php b/lib/ExternalReferrer.php
index 5a20edcac..1598d29f6 100644
--- a/lib/ExternalReferrer.php
+++ b/lib/ExternalReferrer.php
@@ -1,11 +1,11 @@
  array("engine" => "Sympatico", "query1" => "query=", "query2" => "", "url" => "http://www1.sympatico.ca/"),
           "www.search123.com/cgi-bin/" => array("engine" => "Search123", "query1" => "query=", "query2" => "", "url" => "http://www.search123.com/"),
@@ -64,10 +64,10 @@ class SearchEngines {
           "lycos." => array("engine" => "Lycos", "query1" => "query=", "query2" => "", "url" => "http://www.lycos.com/"),
           "msn." => array("engine" => "MSN", "query1" => "q=", "query2" => "", "url" => "http://search.msn.com/"),
           "dmoz." => array("engine" => "Dmoz", "query1" => "search=", "query2" => "", "url" => "http://www.dmoz.org/"),
-          
+
           );
 
-    /** 
+    /**
      * parseSearchQuery(url)
      * Parses the passed refering url looking for search engine data.  If search info is found,
      * the method determines the name of the search engine, it's URL, and the search keywords
@@ -115,7 +115,6 @@ class SearchEngines {
     }
 }
 
-// For emacs users
 // Local Variables:
 // mode: php
 // tab-width: 8
diff --git a/lib/HtmlElement.php b/lib/HtmlElement.php
index 86fdd44cf..92d66f392 100644
--- a/lib/HtmlElement.php
+++ b/lib/HtmlElement.php
@@ -33,7 +33,7 @@ class HtmlElement extends XmlElement
         assert(count($args) >= 1);
         assert(is_string($args[0]));
         $this->_tag = array_shift($args);
-        
+      
         if ($args && is_array($args[0]))
             $this->_attr = array_shift($args);
         else {
@@ -56,7 +56,7 @@ class HtmlElement extends XmlElement
             elseif ($args[0] === false)
                 array_shift($args);
         }
-        
+      
         if (count($args) == 1 && is_array($args[0]))
             $args = $args[0];
         $this->_content = $args;
@@ -89,15 +89,15 @@ class HtmlElement extends XmlElement
 	    if (preg_match("/\[(alt-)?(.)\]$/", $this->_attr['title'], $m))
 	    {
 		$this->_attr['title'] = preg_replace
-                    ("/\[(alt-)?(.)\]$/", 
-                     "[".$WikiTheme->tooltipAccessKeyPrefix()."-\\2]", 
+                    ("/\[(alt-)?(.)\]$/",
+                     "[".$WikiTheme->tooltipAccessKeyPrefix()."-\\2]",
                      $this->_attr['title']);
 	    } else  {
-		$this->_attr['title'] .= 
+		$this->_attr['title'] .=
                     " [".$WikiTheme->tooltipAccessKeyPrefix()."-$key]";
 	    }
 	} else {
-	    $this->_attr['title'] = 
+	    $this->_attr['title'] =
                 "[".$WikiTheme->tooltipAccessKeyPrefix()."-$key]";
 	}
     }
@@ -126,7 +126,7 @@ class HTML extends HtmlElement {
     function raw ($html_text) {
         return new RawXml($html_text);
     }
-    
+  
     function getTagProperties($tag) {
         $props = &$GLOBALS['HTML_TagProperties'];
         return isset($props[$tag]) ? $props[$tag] : 0;
@@ -544,8 +544,7 @@ function IfJavaScript($if_content = false, $else_content = false) {
     }
     return HTML($html);
 }
-    
-// (c-file-style: "gnu")
+  
 // Local Variables:
 // mode: php
 // tab-width: 8
diff --git a/lib/HtmlElement5.php b/lib/HtmlElement5.php
index 8d00f0cca..683bc4402 100644
--- a/lib/HtmlElement5.php
+++ b/lib/HtmlElement5.php
@@ -33,7 +33,7 @@ class HtmlElement extends XmlElement
         assert(count($args) >= 1);
         assert(is_string($args[0]));
         $this->_tag = array_shift($args);
-        
+      
         if ($args && is_array($args[0]))
             $this->_attr = array_shift($args);
         else {
@@ -56,7 +56,7 @@ class HtmlElement extends XmlElement
             elseif ($args[0] === false)
                 array_shift($args);
         }
-        
+      
         if (count($args) == 1 && is_array($args[0]))
             $args = $args[0];
         $this->_content = $args;
@@ -89,15 +89,15 @@ class HtmlElement extends XmlElement
 	    if (preg_match("/\[(alt-)?(.)\]$/", $this->_attr['title'], $m))
 	    {
 		$this->_attr['title'] = preg_replace
-                    ("/\[(alt-)?(.)\]$/", 
-                     "[".$WikiTheme->tooltipAccessKeyPrefix()."-\\2]", 
+                    ("/\[(alt-)?(.)\]$/",
+                     "[".$WikiTheme->tooltipAccessKeyPrefix()."-\\2]",
                      $this->_attr['title']);
 	    } else  {
-		$this->_attr['title'] .= 
+		$this->_attr['title'] .=
                     " [".$WikiTheme->tooltipAccessKeyPrefix()."-$key]";
 	    }
 	} else {
-	    $this->_attr['title'] = 
+	    $this->_attr['title'] =
                 "[".$WikiTheme->tooltipAccessKeyPrefix()."-$key]";
 	}
     }
@@ -126,7 +126,7 @@ class HTML extends HtmlElement {
     public static function raw ($html_text) {
         return new RawXml($html_text);
     }
-    
+  
     function getTagProperties($tag) {
         $props = &$GLOBALS['HTML_TagProperties'];
         return isset($props[$tag]) ? $props[$tag] : 0;
@@ -544,8 +544,7 @@ function IfJavaScript($if_content = false, $else_content = false) {
     }
     return HTML($html);
 }
-    
-// (c-file-style: "gnu")
+  
 // Local Variables:
 // mode: php
 // tab-width: 8
diff --git a/lib/HtmlParser.php b/lib/HtmlParser.php
index 57dbda041..d631513f5 100644
--- a/lib/HtmlParser.php
+++ b/lib/HtmlParser.php
@@ -28,10 +28,10 @@
 /**
  * Base class to implement html => wikitext converters,
  * extendable for various wiki syntax versions.
- * This is needed to be able to use htmlarea-alike editors, 
+ * This is needed to be able to use htmlarea-alike editors,
  * and to import XML or HTML documents.
  *
- * See also php-html.sf.net for a php-only version, if 
+ * See also php-html.sf.net for a php-only version, if
  * you don't have the expat/libxml extension included.
  * See also http://search.cpan.org/~diberri/HTML-WikiConverter/
  *
@@ -40,13 +40,13 @@
 // RssParser contains the XML (expat) and url-grabber methods
 require_once('lib/XmlParser.php');
 
-class HtmlParser 
-extends XmlParser 
+class HtmlParser
+extends XmlParser
 {
     var $dialect, $_handlers, $root;
 
-    /** 
-     *  dialect: "PhpWiki2", "PhpWiki" 
+    /**
+     *  dialect: "PhpWiki2", "PhpWiki"
      *  possible more dialects: MediaWiki, kwiki, c2
      */
     function HtmlParser($dialect = "PhpWiki2", $encoding = '') {
@@ -114,8 +114,8 @@ extends XmlParser
     }
 
     /** elem_contents()
-     *  $output = $parser->elem_contents( $elem ); 
-     
+     *  $output = $parser->elem_contents( $elem );
+
      * Returns a wikified version of the contents of the specified
      * HTML element. This is done by passing each element of this
      * element's content list through the C method, and
@@ -185,7 +185,7 @@ extends XmlParser
         if (!$node or !in_array($node->_tag,array("div","p")))
             return false;
         $contents = $node->getContent();
-        // Returns true if sole child is an IMG tag  
+        // Returns true if sole child is an IMG tag
         if (count($contents) == 1 and isset($contents[0]) and $contents[0]->_tag == 'img')
             return true;
         // Check if child is a sole A tag that contains an IMG tag
@@ -214,10 +214,10 @@ extends XmlParser
 
 
 class HtmlParser_PhpWiki2
-extends HtmlParser 
+extends HtmlParser
 {
     function HtmlParser_PhpWiki2() {
-        $this->_handlers = 
+        $this->_handlers =
             array('html'   => '',
                   'head'   => '',
                   'title'  => '',
@@ -225,7 +225,7 @@ extends HtmlParser
                   'link'   => '',
                   'script' => '',
                   'body'   => '',
-                  
+
                   'br'     => "
", 'b' => array( "*" ), 'strong' => array( "*" ), @@ -236,7 +236,7 @@ extends HtmlParser // PRE blocks are handled specially (see tidy_whitespace and // wikify methods) 'pre' => array( "
", "
" ), - + 'dl' => array( '', "\n\n" ), 'dt' => array( ';', '' ), 'dd' => array( ':', '' ), @@ -272,7 +272,7 @@ extends HtmlParser } function wikify_table( $node ) { - $this->ident = ''; + $this->ident = ''; return "| \n" . $this->elem_contents($node) . "|\n\n"; } function wikify_tr( $node ) { @@ -323,7 +323,7 @@ extends HtmlParser } return $markup.' '.trim($this->elem_contents($node))."\n\n"; } - + function wikify_verbatim( $node ) { $contents = $this->elem_contents( $node ); return "\n\n$contents\n"; @@ -350,7 +350,7 @@ extends HtmlParser if ( !$alignment and $image_div ) { $css_style = $image_div->getAttr('style'); $css_class = $image_div->getAttr('class'); - + // float => align: Check for float attribute; if it's there, // then we'll add it to the [Image] syntax if (!$alignment and preg_match("/float\:\s*(right|left)/i",$css_style,$m)) @@ -367,7 +367,7 @@ extends HtmlParser } else { $this->log( " Image is not contained within a DIV" ); } - if ($alignment) + if ($alignment) $attrs[] = "align=$alignment"; // // Check if we need to request a thumbnail of this @@ -382,7 +382,7 @@ extends HtmlParser $abs_url = $this->absolute_url( $node->getAttr('src') ); $this->log( " Fetching image '$abs_url' from the network" ); list( $actual_w, $actual_h, $flag, $attr_str) = getimagesize( $abs_url ); - + // If the WIDTH attribute of the IMG tag is not equal // to the actual width of the image, then we need to // create a thumbnail @@ -414,7 +414,6 @@ extends HtmlParser } } -// For emacs users // Local Variables: // mode: php // tab-width: 8 diff --git a/lib/HttpClient.php b/lib/HttpClient.php index 22c6a2b7e..0b1e96543 100644 --- a/lib/HttpClient.php +++ b/lib/HttpClient.php @@ -1,14 +1,14 @@ cookies array ready for the next request - // Note: This currently ignores the cookie path (and time) completely. Time is not important, + // Note: This currently ignores the cookie path (and time) completely. Time is not important, // but path could possibly lead to security problems. var $persist_referers = true; // For each request, sends path of last request as referer var $debug = false; @@ -72,7 +72,7 @@ class HttpClient { $this->method = 'POST'; $boundary = $this->boundary; //"httpclient_boundary"; $headers[] = "Content-Type: multipart/form-data; boundary=\"$boundary\""; - $basename = basename($filename); + $basename = basename($filename); $this->postdata = "\r\n--$boundary\r\n" ."Content-Disposition: form-data; filename=\"$basename\"\r\n" @@ -124,8 +124,8 @@ class HttpClient { socket_set_timeout($fp, $this->timeout); if ( $this->method == 'POST' and preg_match("/\/", $this->postdata)) $request = $this->buildRequest("text/xml"); //xmlrpc - else if ( $this->method == 'POST' and strstr("\r\nContent-Disposition: form-data; filename=", - $this->postdata)) + else if ( $this->method == 'POST' and strstr("\r\nContent-Disposition: form-data; filename=", + $this->postdata)) { //file upload $boundary = $this->boundary; @@ -150,7 +150,7 @@ class HttpClient { if ($line === false) { $this->errormsg = "Empty ". $this->method. " response"; return false; - } + } if (!preg_match('/HTTP\/(\\d\\.\\d)\\s*(\\d+)\\s*(.*)/', $line, $m)) { $this->errormsg = "Status code line invalid: ".htmlentities($line); $this->debug($this->errormsg); @@ -236,18 +236,18 @@ class HttpClient { $url = parse_url($location.$uri); if ($this->method == 'POST') return $this->doRequest(); - else + else // This will FAIL if redirect is to a different site return $this->get($url['path']); } } return true; } - + function buildRequest($ContentType = 'application/x-www-form-urlencoded') { $headers = array(); // Using 1.1 leads to all manner of problems, such as "chunked" encoding - $headers[] = "{$this->method} {$this->path} HTTP/1.0"; + $headers[] = "{$this->method} {$this->path} HTTP/1.0"; $headers[] = "Host: {$this->host}"; $headers[] = "User-Agent: {$this->user_agent}"; $headers[] = "Accept: {$this->accept}"; @@ -383,10 +383,9 @@ class HttpClient { } print ''; } - } + } } -// For emacs users // Local Variables: // mode: php // tab-width: 8 diff --git a/lib/IniConfig.php b/lib/IniConfig.php index 5f289a4f3..dda58c03e 100644 --- a/lib/IniConfig.php +++ b/lib/IniConfig.php @@ -22,12 +22,12 @@ * 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 @@ -45,7 +45,7 @@ * * - Don't use too much globals for easier integration into other projects * (namespace pollution). (gforge, phpnuke, postnuke, phpBB2, carolina, ...) - * Use one global $phpwiki object instead which holds the cfg vars, constants + * Use one global $phpwiki object instead which holds the cfg vars, constants * and all other globals. * (global $FieldSeparator, $charset, $WikiNameRegexp, $KeywordLinkRegexp; * global $DisabledActions, $DBParams, $LANG, $AllActionPages) @@ -90,7 +90,7 @@ function save_dump($file) { } // cannot be optimized, maybe leave away predefined consts somehow foreach (get_defined_constants() as $var => $val) { - if (substr($var,0,4) != "PHP_" and substr($var,0,2) != "E_" + if (substr($var,0,4) != "PHP_" and substr($var,0,2) != "E_" and substr($var,0,2) != "T_" and substr($var,0,2) != "M_") fwrite($fp, "if(!defined('".$var."')) define('".$var."',unserialize(\"" .addslashes(serialize($val))."\"));\n"); @@ -123,7 +123,7 @@ function IniConfig($file) { // First-time installer detection here... // Similar to SetupWiki() if (!file_exists($file)) { - // We need to DATA_PATH for configurator, or pass the posted values + // We need to DATA_PATH for configurator, or pass the posted values // somewhow to the script include_once(dirname(__FILE__)."/install.php"); run_install("_part1"); @@ -133,14 +133,14 @@ function IniConfig($file) { } // List of all valid config options to be define()d which take "values" (not - // booleans). Needs to be categorised, and generally made a lot tidier. + // booleans). Needs to be categorised, and generally made a lot tidier. $_IC_VALID_VALUE = array ('WIKI_NAME', 'ADMIN_USER', 'ADMIN_PASSWD', 'DEFAULT_DUMP_DIR', 'HTML_DUMP_DIR', 'HTML_DUMP_SUFFIX', 'MAX_UPLOAD_SIZE', 'MINOR_EDIT_TIMEOUT', 'ACCESS_LOG', 'CACHE_CONTROL', 'CACHE_CONTROL_MAX_AGE', 'COOKIE_EXPIRATION_DAYS', 'COOKIE_DOMAIN', - 'PASSWORD_LENGTH_MINIMUM', 'USER_AUTH_POLICY', + 'PASSWORD_LENGTH_MINIMUM', 'USER_AUTH_POLICY', 'GROUP_METHOD', 'EDITING_POLICY', 'THEME', 'CHARSET', 'WIKI_PGSRC', 'DEFAULT_WIKI_PGSRC', @@ -149,7 +149,7 @@ function IniConfig($file) { //'DATABASE_PREFIX', 'DATABASE_DSN', 'DATABASE_TYPE', 'DATABASE_DBHANDLER', 'DATABASE_OPTIMISE_FREQUENCY', 'INTERWIKI_MAP_FILE', 'COPYRIGHTPAGE_TITLE', 'COPYRIGHTPAGE_URL', - 'AUTHORPAGE_TITLE', 'AUTHORPAGE_URL', + 'AUTHORPAGE_TITLE', 'AUTHORPAGE_URL', 'WIKI_NAME_REGEXP', 'PLUGIN_CACHED_DATABASE', 'PLUGIN_CACHED_FILENAME_PREFIX', 'PLUGIN_CACHED_HIGHWATER', 'PLUGIN_CACHED_LOWWATER', 'PLUGIN_CACHED_MAXLIFETIME', @@ -163,8 +163,8 @@ function IniConfig($file) { // Optional values which need to be defined. // These are not defined in config-default.ini and empty if not defined. $_IC_OPTIONAL_VALUE = array - ( - 'DEBUG', 'TEMP_DIR', 'DEFAULT_LANGUAGE', + ( + 'DEBUG', 'TEMP_DIR', 'DEFAULT_LANGUAGE', 'LDAP_AUTH_HOST','LDAP_SET_OPTION','LDAP_BASE_DN', 'LDAP_AUTH_USER', 'LDAP_AUTH_PASSWORD','LDAP_SEARCH_FIELD','LDAP_OU_GROUP','LDAP_OU_USERS', 'AUTH_USER_FILE','DBAUTH_AUTH_DSN', @@ -172,7 +172,7 @@ function IniConfig($file) { 'AUTH_USER_FILE', 'AUTH_GROUP_FILE', 'AUTH_SESS_USER', 'AUTH_SESS_LEVEL', 'GOOGLE_LICENSE_KEY','FORTUNE_DIR', 'DISABLE_GETIMAGESIZE','DBADMIN_USER','DBADMIN_PASSWD', - 'SESSION_SAVE_PATH', + 'SESSION_SAVE_PATH', 'TOOLBAR_PAGELINK_PULLDOWN', 'TOOLBAR_TEMPLATE_PULLDOWN', 'TOOLBAR_IMAGE_PULLDOWN', 'EXTERNAL_LINK_TARGET', 'ACCESS_LOG_SQL', 'USE_EXTERNAL_HTML2PDF', 'LOGIN_LOG','LDAP_SEARCH_FILTER' @@ -183,8 +183,8 @@ function IniConfig($file) { ('ENABLE_USER_NEW', 'ENABLE_PAGEPERM', 'ENABLE_EDIT_TOOLBAR', 'JS_SEARCHREPLACE', 'ENABLE_XHTML_XML', 'ENABLE_DOUBLECLICKEDIT', 'ENABLE_LIVESEARCH', 'ENABLE_ACDROPDOWN', 'USECACHE', 'WIKIDB_NOCACHE_MARKUP', - 'ENABLE_REVERSE_DNS', 'ENCRYPTED_PASSWD', 'ZIPDUMP_AUTH', - 'ENABLE_RAW_HTML', 'ENABLE_RAW_HTML_LOCKEDONLY', 'ENABLE_RAW_HTML_SAFE', + 'ENABLE_REVERSE_DNS', 'ENCRYPTED_PASSWD', 'ZIPDUMP_AUTH', + 'ENABLE_RAW_HTML', 'ENABLE_RAW_HTML_LOCKEDONLY', 'ENABLE_RAW_HTML_SAFE', 'STRICT_MAILABLE_PAGEDUMPS', 'COMPRESS_OUTPUT', 'ALLOW_ANON_USER', 'ALLOW_ANON_EDIT', 'ALLOW_BOGO_LOGIN', 'ALLOW_USER_PASSWORDS', @@ -216,8 +216,8 @@ function IniConfig($file) { $rs[$k] = $v; } } - unset($k); unset($v); - + unset($k); unset($v); + foreach ($_IC_VALID_VALUE as $item) { if (defined($item)) { unset($rs[$item]); @@ -234,7 +234,7 @@ function IniConfig($file) { array('DATABASE_PREFIX', 'SERVER_NAME', 'SERVER_PORT', 'SCRIPT_NAME', 'DATA_PATH', 'PHPWIKI_DIR', 'VIRTUAL_PATH', 'LDAP_AUTH_HOST','IMAP_AUTH_HOST','POP3_AUTH_HOST', - 'PLUGIN_CACHED_CACHE_DIR','EXTERNAL_HTML2PDF_PAGELIST'))) + 'PLUGIN_CACHED_CACHE_DIR','EXTERNAL_HTML2PDF_PAGELIST'))) { ; } elseif (!defined("_PHPWIKI_INSTALL_RUNNING")) { @@ -257,10 +257,10 @@ function IniConfig($file) { //} elseif (array_key_exists($item, $rsdef)) { // $val = $rsdef[$item]; } else { - $val = false; + $val = false; //trigger_error(sprintf("missing boolean config setting for %s",$item)); } - + // calculate them later: old or dynamic constants if (!array_key_exists($item, $rs) and in_array($item, array('USE_PATH_INFO', 'USE_DB_SESSION', @@ -316,13 +316,13 @@ function IniConfig($file) { } $valid_database_types = array('SQL','ADODB','PDO','dba','file','flatfile','cvs','cvsclient'); if (!in_array(DATABASE_TYPE, $valid_database_types)) - trigger_error(sprintf("Invalid DATABASE_TYPE=%s. Choose one of %s", - DATABASE_TYPE, join(",", $valid_database_types)), + trigger_error(sprintf("Invalid DATABASE_TYPE=%s. Choose one of %s", + DATABASE_TYPE, join(",", $valid_database_types)), E_USER_ERROR); - unset($valid_database_types); + unset($valid_database_types); if (DATABASE_TYPE == 'PDO') { if (!check_php_version(5)) - trigger_error("Invalid DATABASE_TYPE=PDO. PDO requires at least php-5.0!", + trigger_error("Invalid DATABASE_TYPE=PDO. PDO requires at least php-5.0!", E_USER_ERROR); // try to load it dynamically (unix only) if (!loadPhpExtension("pdo")) { @@ -334,7 +334,7 @@ function IniConfig($file) { } // Detect readonly database, e.g. system mounted read-only for maintenance // via dbh->readonly later. Unfortunately not possible as constant. - + // USE_DB_SESSION default logic: if (!defined('USE_DB_SESSION')) { if ($DBParams['db_session_table'] @@ -344,7 +344,7 @@ function IniConfig($file) { define('USE_DB_SESSION', false); } } - unset($item); unset($k); + unset($item); unset($k); // Expiry stuff global $ExpireParams; @@ -362,14 +362,14 @@ function IniConfig($file) { unset($rs[$item]); } } - unset($item); unset($major); unset($max); - + unset($item); unset($major); unset($max); + // User authentication if (!isset($GLOBALS['USER_AUTH_ORDER'])) { if (isset($rs['USER_AUTH_ORDER'])) - $GLOBALS['USER_AUTH_ORDER'] = preg_split('/\s*:\s*/', + $GLOBALS['USER_AUTH_ORDER'] = preg_split('/\s*:\s*/', $rs['USER_AUTH_ORDER']); - else + else $GLOBALS['USER_AUTH_ORDER'] = array("PersonalPage"); } @@ -377,7 +377,7 @@ function IniConfig($file) { if (in_array('Db', $GLOBALS['USER_AUTH_ORDER']) && empty($rs['DBAUTH_AUTH_DSN'])) { $rs['DBAUTH_AUTH_DSN'] = $DBParams['dsn']; } - + global $DBAuthParams; $DBAP_MAP = array('DBAUTH_AUTH_DSN' => 'auth_dsn', 'DBAUTH_AUTH_CHECK' => 'auth_check', @@ -416,7 +416,7 @@ function IniConfig($file) { } // SQL defaults to ACCESS_LOG_SQL = 2 else { - define('ACCESS_LOG_SQL', + define('ACCESS_LOG_SQL', in_array(DATABASE_TYPE, array('SQL','ADODB','PDO')) ? 2 : 0); } @@ -447,7 +447,7 @@ function IniConfig($file) { _check_int_constant($rs[$item]); define($item, $rs[$item]); unset($rs[$item]); - } else + } else define($item, ''); } @@ -462,8 +462,8 @@ function IniConfig($file) { define($item, $rsdef[$item]); } } - unset($item); - + unset($item); + // LDAP bind options global $LDAP_SET_OPTION; if (defined('LDAP_SET_OPTION') and LDAP_SET_OPTION) { @@ -493,7 +493,7 @@ function IniConfig($file) { if (!trim($WikiNameRegexp)) $WikiNameRegexp = '(?/ext/standard/html.c // For performance reasons we require a magic constant to ignore this warning. if (defined('IGNORE_CHARSET_NOT_SUPPORTED_WARNING') - and IGNORE_CHARSET_NOT_SUPPORTED_WARNING) + and IGNORE_CHARSET_NOT_SUPPORTED_WARNING) { $ErrorManager->pushErrorHandler (new WikiFunctionCb('_ignore_unknown_charset_warning')); @@ -743,7 +743,7 @@ function fixup_static_configs($file) { } // Used by SetupWiki to pull in required pages, if not translated, then in english. - // Also used by _WikiTranslation. Really important are only those which return pagelists + // Also used by _WikiTranslation. Really important are only those which return pagelists // or contain basic functionality. $AllActionPages = $ActionPages; $AllActionPages[] = 'AllPagesCreatedByMe'; @@ -789,10 +789,10 @@ function fixup_static_configs($file) { $themes_dir = FindFile("themes"); define('PHPWIKI_DIR', dirname($themes_dir)); } - + // If user has not defined DATA_PATH, we want to use relative URLs. if (!defined('DATA_PATH')) { - // fix similar to the one suggested by jkalmbach for + // fix similar to the one suggested by jkalmbach for // installations in the webrootdir, like "http://phpwiki.org/HomePage" if (!defined('SCRIPT_NAME')) define('SCRIPT_NAME', deduce_script_name()); @@ -814,8 +814,8 @@ function fixup_static_configs($file) { if (!defined('THEME')) define('THEME', 'default'); - - /*$configurator_link = HTML(HTML::br(), "=>", + + /*$configurator_link = HTML(HTML::br(), "=>", HTML::a(array('href'=>DATA_PATH."/configurator.php"), _("Configurator")));*/ // check whether the crypt() function is needed and present @@ -832,7 +832,7 @@ function fixup_static_configs($file) { // Basic configurator validation if (!defined('ADMIN_USER') or ADMIN_USER == '') { - $error = sprintf("%s may not be empty. Please update your configuration.", + $error = sprintf("%s may not be empty. Please update your configuration.", "ADMIN_USER"); // protect against recursion if (!preg_match("/config\-(dist|default)\.ini$/", $file) @@ -848,12 +848,12 @@ function fixup_static_configs($file) { } } if (!defined('ADMIN_PASSWD') or ADMIN_PASSWD == '') { - $error = sprintf("%s may not be empty. Please update your configuration.", + $error = sprintf("%s may not be empty. Please update your configuration.", "ADMIN_PASSWD"); // protect against recursion if (!preg_match("/config\-(dist|default)\.ini$/", $file) - and !defined("_PHPWIKI_INSTALL_RUNNING")) - { + and !defined("_PHPWIKI_INSTALL_RUNNING")) + { include_once(dirname(__FILE__)."/install.php"); run_install("_part1"); trigger_error($error, E_USER_ERROR); @@ -867,7 +867,7 @@ function fixup_static_configs($file) { if (defined('USE_DB_SESSION') and USE_DB_SESSION) { if (! $DBParams['db_session_table'] ) { $DBParams['db_session_table'] = @$DBParams['prefix'] . 'session'; - trigger_error(sprintf("DATABASE_SESSION_TABLE configuration set to %s.", + trigger_error(sprintf("DATABASE_SESSION_TABLE configuration set to %s.", $DBParams['db_session_table']), E_USER_ERROR); } @@ -876,16 +876,16 @@ function fixup_static_configs($file) { if (!defined('ENABLE_USER_NEW')) define('ENABLE_USER_NEW',true); if (!defined('ALLOW_USER_LOGIN')) define('ALLOW_USER_LOGIN', defined('ALLOW_USER_PASSWORDS') && ALLOW_USER_PASSWORDS); - if (!defined('ALLOW_ANON_USER')) define('ALLOW_ANON_USER', true); - if (!defined('ALLOW_ANON_EDIT')) define('ALLOW_ANON_EDIT', false); + if (!defined('ALLOW_ANON_USER')) define('ALLOW_ANON_USER', true); + if (!defined('ALLOW_ANON_EDIT')) define('ALLOW_ANON_EDIT', false); if (!defined('REQUIRE_SIGNIN_BEFORE_EDIT')) define('REQUIRE_SIGNIN_BEFORE_EDIT', ! ALLOW_ANON_EDIT); if (!defined('ALLOW_BOGO_LOGIN')) define('ALLOW_BOGO_LOGIN', true); if (!ENABLE_USER_NEW) { if (!defined('ALLOW_HTTP_AUTH_LOGIN')) define('ALLOW_HTTP_AUTH_LOGIN', false); - if (!defined('ALLOW_LDAP_LOGIN')) + if (!defined('ALLOW_LDAP_LOGIN')) define('ALLOW_LDAP_LOGIN', function_exists('ldap_connect') and defined('LDAP_AUTH_HOST')); - if (!defined('ALLOW_IMAP_LOGIN')) + if (!defined('ALLOW_IMAP_LOGIN')) define('ALLOW_IMAP_LOGIN', function_exists('imap_open') and defined('IMAP_AUTH_HOST')); } @@ -895,9 +895,9 @@ function fixup_static_configs($file) { } } -/** +/** * Define constants which are client or request specific and should not be dumped statically. - * Such as the language, and the virtual and server paths, which might be overridden + * Such as the language, and the virtual and server paths, which might be overridden * by startup scripts for wiki farms. */ function fixup_dynamic_configs($file) { @@ -924,13 +924,13 @@ function fixup_dynamic_configs($file) { if (empty($LANG)) { if (!defined("DEFAULT_LANGUAGE") or !DEFAULT_LANGUAGE) { // TODO: defer this to WikiRequest::initializeLang() - $LANG = guessing_lang(); + $LANG = guessing_lang(); guessing_setlocale (LC_ALL,$LANG); } else $LANG = DEFAULT_LANGUAGE; } - + // Set up (possibly fake) gettext() // Todo: this could be moved to fixup_static_configs() // Bug #1381464 with php-5.1.1 @@ -940,7 +940,7 @@ function fixup_dynamic_configs($file) { { $locale = array(); - function gettext ($text) { + function gettext ($text) { global $locale; if (!empty ($locale[$text])) return $locale[$text]; @@ -1044,7 +1044,7 @@ function fixup_dynamic_configs($file) { } } } - + if (SERVER_PORT && SERVER_PORT != (SERVER_PROTOCOL == 'https' ? 443 : 80)) { define('SERVER_URL', @@ -1120,12 +1120,11 @@ function fixup_dynamic_configs($file) { } -// (c-file-style: "gnu") // Local Variables: // mode: php // tab-width: 8 // c-basic-offset: 4 // c-hanging-comment-ender-p: nil // indent-tabs-mode: nil -// End: +// End: ?> diff --git a/lib/InlineParser.php b/lib/InlineParser.php index 7cd7693f1..9be8361d9 100644 --- a/lib/InlineParser.php +++ b/lib/InlineParser.php @@ -1,21 +1,21 @@ - * Copyright (C) 2004-2010 Reini Urban * Copyright (C) 2008-2009 Marc-Etienne Vargenau, Alcatel-Lucent * * 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 @@ -129,9 +129,9 @@ class RegexpSet $match->regexp_ind += $prevMatch->regexp_ind + 1; return $match; } - + } - + // Failed. Look for match after current position. $repeat = sprintf('{%d,}?', $pos + 1); return $this->_match($text, $this->_regexps, $repeat); @@ -143,13 +143,13 @@ class RegexpSet // A - ANCHORED // S - STUDY function _match ($text, $regexps, $repeat) { - // If one of the regexps is an empty string, php will crash here: - // sf.net: Fatal error: Allowed memory size of 8388608 bytes exhausted + // If one of the regexps is an empty string, php will crash here: + // sf.net: Fatal error: Allowed memory size of 8388608 bytes exhausted // (tried to allocate 634 bytes) if (_INLINE_OPTIMIZATION) { // disabled, wrong // So we try to minize memory usage, by looping explicitly, - // and storing only those regexp which actually match. - // There may be more than one, so we have to find the longest, + // and storing only those regexp which actually match. + // There may be more than one, so we have to find the longest, // and match inside until the shortest is empty. $matched = array(); $matched_ind = array(); for ($i=0; $i 2) { assert(!empty($repeat)); assert(!empty($regexps)); - // We could do much better, if we would know the matching markup for the + // We could do much better, if we would know the matching markup for the // longest regexp match: $hugepat= "/ ( . $repeat ) ( (" . join(')|(', $regexps) . ") ) /Asx"; // Proposed premature optimization 1: @@ -189,7 +189,7 @@ class RegexpSet } else { $match->regexp_ind = $regexp_ind; } - + $match->postmatch = substr($text, strlen($m[0])); $match->prematch = $m[1]; $match->match = $m[2]; @@ -198,10 +198,10 @@ class RegexpSet if (DEBUG & _DEBUG_PARSER) { static $_already_dumped = 0; if (!$_already_dumped) { - var_dump($regexps); + var_dump($regexps); if (_INLINE_OPTIMIZATION) var_dump($matched); - var_dump($matched_ind); + var_dump($matched_ind); } $_already_dumped = 1; PrintXML(HTML::dl(HTML::dt("input"), @@ -229,7 +229,7 @@ class RegexpSet * * When a match is found for the regexp, the matching text is replaced. * The replacement content is obtained by calling the SimpleMarkup::markup method. - */ + */ class SimpleMarkup { var $_match_regexp; @@ -258,7 +258,7 @@ class SimpleMarkup * A balanced markup rule. * * These are defined by a start regexp, and an end regexp. - */ + */ class BalancedMarkup { var $_start_regexp; @@ -270,7 +270,7 @@ class BalancedMarkup function getStartRegexp () { return $this->_start_regexp; } - + /** Get the ending regexp for this rule. * * @param string $match The text which matched the starting regexp. @@ -300,7 +300,7 @@ class Markup_escape extends SimpleMarkup function getMatchRegexp () { return ESCAPE_CHAR . '(?: [[:alnum:]]+ | .)'; } - + function markup ($match) { assert(strlen($match) >= 2); return substr($match, 1); @@ -326,7 +326,7 @@ function LinkBracketLink($bracketlink) { // $bracketlink will start and end with brackets; in between will // be either a page name, a URL or both separated by a pipe. - + $wikicreolesyntax = false; if (string_starts_with($bracketlink, "[[") or string_starts_with($bracketlink, "#[[")) { @@ -334,7 +334,7 @@ function LinkBracketLink($bracketlink) { $bracketlink = str_replace("[[", "[", $bracketlink); $bracketlink = str_replace("]]", "]", $bracketlink); } - + // Strip brackets and leading space // bug#1904088 Some brackets links on 2 lines cause the parser to crash preg_match('/(\#?) \[\s* (?: (.*?) \s* (?getImageURL($imgurl); } - // for objects (non-images) the link is taken as alt tag, + // for objects (non-images) the link is taken as alt tag, // which is in return taken as alternative img $label = LinkImage($imgurl, $link); } @@ -441,14 +441,14 @@ function LinkBracketLink($bracketlink) { elseif (substr($link,0,8) == 'phpwiki:') return new Cached_PhpwikiURL($link, $label); - /* Semantic relations and attributes. + /* Semantic relations and attributes. * Relation and attribute names must be word chars only, no space. * Links and Attributes may contain everything. word, nums, units, space, groupsep, numsep, ... */ elseif (preg_match("/^ (\w+) (:[:=]) (.*) $/x", $link) and !isImageLink($link)) return new Cached_SemanticLink($link, $label); - /* Do not store the link */ + /* Do not store the link */ elseif (substr($link,0,1) == ':') return new Cached_WikiLink($link, $label); @@ -459,12 +459,12 @@ function LinkBracketLink($bracketlink) { * [what a pic|File:my_image.gif] shows a named inter-wiki link to the gif * [File:my_image.gif|what a pic] shows an inlined image linked to the page "what a pic" * - * Note that for simplicity we will accept embedded object tags (non-images) + * Note that for simplicity we will accept embedded object tags (non-images) * here also, and seperate them later in LinkImage() */ elseif (strstr($link,':') - and ($intermap = getInterwikiMap()) - and preg_match("/^" . $intermap->getRegexp() . ":/", $link)) + and ($intermap = getInterwikiMap()) + and preg_match("/^" . $intermap->getRegexp() . ":/", $link)) { // trigger_error("label: $label link: $link", E_USER_WARNING); if (empty($label) and isImageLink($link)) { @@ -504,7 +504,7 @@ class Markup_wikicreolebracketlink extends SimpleMarkup class Markup_bracketlink extends SimpleMarkup { var $_match_regexp = "\\#? \\[ .*? [^]\\s] .*? \\]"; - + function markup ($match) { $link = LinkBracketLink($match); assert($link->isInlineElement()); @@ -523,7 +523,7 @@ class Markup_spellcheck extends SimpleMarkup $words = array_keys($this->suggestions); return "(?<= \W ) (?:" . join('|', $words) . ") (?= \W )"; } - + function markup ($match) { if (empty($this->suggestions) or empty($this->suggestions[$match])) return $match; @@ -553,7 +553,7 @@ class Markup_url extends SimpleMarkup function getMatchRegexp () { return "(?\"']+ (?getDbh(); @@ -632,11 +632,11 @@ class Markup_linebreak extends SimpleMarkup class Markup_wikicreole_italics extends BalancedMarkup { var $_start_regexp = "\\/\\/"; - + function getEndRegexp ($match) { - return "\\/\\/"; + return "\\/\\/"; } - + function markup ($match, $body) { $tag = 'em'; return new HtmlElement($tag, $body); @@ -646,11 +646,11 @@ class Markup_wikicreole_italics extends BalancedMarkup class Markup_wikicreole_bold extends BalancedMarkup { var $_start_regexp = "\\*\\*"; - + function getEndRegexp ($match) { - return "\\*\\*"; + return "\\*\\*"; } - + function markup ($match, $body) { $tag = 'strong'; return new HtmlElement($tag, $body); @@ -660,11 +660,11 @@ class Markup_wikicreole_bold extends BalancedMarkup class Markup_wikicreole_monospace extends BalancedMarkup { var $_start_regexp = "\\#\\#"; - + function getEndRegexp ($match) { - return "\\#\\#"; + return "\\#\\#"; } - + function markup ($match, $body) { $tag = 'tt'; return new HtmlElement($tag, $body); @@ -674,25 +674,25 @@ class Markup_wikicreole_monospace extends BalancedMarkup class Markup_wikicreole_superscript extends BalancedMarkup { var $_start_regexp = "\\^\\^"; - + function getEndRegexp ($match) { - return "\\^\\^"; + return "\\^\\^"; } - + function markup ($match, $body) { $tag = 'sup'; return new HtmlElement($tag, $body); } } - + class Markup_wikicreole_subscript extends BalancedMarkup { var $_start_regexp = ",,"; - + function getEndRegexp ($match) { - return $match; + return $match; } - + function markup ($match, $body) { $tag = 'sub'; return new HtmlElement($tag, $body); @@ -706,7 +706,7 @@ class Markup_old_emphasis extends BalancedMarkup function getEndRegexp ($match) { return $match; } - + function markup ($match, $body) { $tag = $match == "''" ? 'em' : 'strong'; return new HtmlElement($tag, $body); @@ -743,9 +743,9 @@ class Markup_nestled_emphasis extends BalancedMarkup $start[] = "(?<= { ) ${any} (?! } )"; $start[] = "(?<= < ) ${any} (?! > )"; $start[] = "(?<= \\( ) ${any} (?! \\) )"; - + $start = "(?:" . join('|', $start) . ")"; - + // Any of the above must be immediately followed by non-whitespace. $start_regexp = $start . "(?= \S)"; } @@ -757,7 +757,7 @@ class Markup_nestled_emphasis extends BalancedMarkup $chr = preg_quote($match); return "(?<= \S | ^ ) (?\"'\\/:.,;!? _*=] | $)"; } - + function markup ($match, $body) { switch ($match) { case '*': return new HtmlElement('b', $body); @@ -769,13 +769,13 @@ class Markup_nestled_emphasis extends BalancedMarkup class Markup_html_emphasis extends BalancedMarkup { - var $_start_regexp = + var $_start_regexp = "<(?: b|big|i|small|tt|em|strong|cite|code|dfn|kbd|samp|s|strike|del|var|sup|sub )>"; function getEndRegexp ($match) { return "<\\/" . substr($match, 1); } - + function markup ($match, $body) { $tag = substr($match, 1, -1); return new HtmlElement($tag, $body); @@ -784,7 +784,7 @@ class Markup_html_emphasis extends BalancedMarkup class Markup_html_divspan extends BalancedMarkup { - var $_start_regexp = + var $_start_regexp = "<(?: div|span )(?: \s[^>]*)?>"; function getEndRegexp ($match) { @@ -794,7 +794,7 @@ class Markup_html_divspan extends BalancedMarkup $tag = 'div'; return "<\\/" . $tag . '>'; } - + function markup ($match, $body) { if (substr($match,1,4) == 'span') $tag = 'span'; @@ -824,7 +824,7 @@ class Markup_html_abbr extends BalancedMarkup $tag = 'acronym'; return "<\\/" . $tag . '>'; } - + function markup ($match, $body) { if (substr($match,1,4) == 'abbr') $tag = 'abbr'; @@ -851,7 +851,7 @@ class Markup_color extends BalancedMarkup { // %color=blue% blue text %% and back to normal var $_start_regexp = "%color=(?: [^%]*)%"; var $_end_regexp = "%%"; - + function markup ($match, $body) { $color = strtolower(substr($match, 7, -1)); @@ -876,16 +876,16 @@ class Markup_color extends BalancedMarkup { } // HTML 4 defines the following 16 colors - if (in_array($color, array('aqua', 'black', 'blue', 'fuchsia', + if (in_array($color, array('aqua', 'black', 'blue', 'fuchsia', 'gray', 'green', 'lime', 'maroon', 'navy', 'olive', 'purple', 'red', 'silver', 'teal', 'white', 'yellow')) - or ((substr($color,0,1) == '#') + or ((substr($color,0,1) == '#') and ((strlen($color) == 4) or (strlen($color) == 7)) and (strspn(substr($color,1),'0123456789abcdef') == strlen($color)-1))) { return new HtmlElement('span', array('style' => "color: $color"), $body); } else { - return new HtmlElement('span', array('class' => 'error'), + return new HtmlElement('span', array('class' => 'error'), sprintf(_("unknown color %s ignored"), substr($match, 7, -1))); } } @@ -913,7 +913,7 @@ class Markup_html_comment extends SimpleMarkup } } -// Special version for single-line plugins formatting, +// Special version for single-line plugins formatting, // like: '< ?plugin PopularNearby ? >' class Markup_plugin extends SimpleMarkup { @@ -957,7 +957,7 @@ class Markup_xml_plugin extends BalancedMarkup } function markup ($match, $body) { global $PLUGIN_MARKUP_MAP; - $name = substr($match,2,-2); + $name = substr($match,2,-2); $vars = ''; if (preg_match('/^(\S+)\|(.*)$/', $name, $_m)) { $name = $_m[1]; @@ -1017,7 +1017,7 @@ class Markup_template_plugin extends SimpleMarkup { // patch #1732793: allow \n, mult. {{ }} in one line, and single letters var $_match_regexp = '\{\{.*?\}\}'; - + function markup ($match) { $page = substr($match,2,-2); @@ -1074,15 +1074,15 @@ class Markup_template_plugin extends SimpleMarkup return new Cached_PluginInvocation($s); } - $page = str_replace("\n", "", $page); + $page = str_replace("\n", "", $page); $vars = ''; if (preg_match('/^(\S+?)\|(.*)$/', $page, $_m)) { $page = $_m[1]; - $vars = '"' . preg_replace('/\|/', '" "', $_m[2]) . '"'; + $vars = '"' . preg_replace('/\|/', '" "', $_m[2]) . '"'; $vars = preg_replace('/"(\S+)=([^"]*)"/', '\\1="\\2"', $vars); } - + // page may contain a version number // {{foo?version=5}} // in that case, output is "page=foo rev=5" @@ -1113,12 +1113,12 @@ class Markup_html_entities extends SimpleMarkup { '©' => '©', '™' => '™', ); - $this->_match_regexp = - '(: ' . - join('|', array_map('preg_quote', array_keys($this->_entities))) . + $this->_match_regexp = + '(: ' . + join('|', array_map('preg_quote', array_keys($this->_entities))) . ' )'; } - + function markup ($match) { return HTML::Raw($this->_entities[$match]); } @@ -1126,7 +1126,7 @@ class Markup_html_entities extends SimpleMarkup { class Markup_isonumchars extends SimpleMarkup { var $_match_regexp = '\&\#\d{2,5};'; - + function markup ($match) { return HTML::Raw($match); } @@ -1135,7 +1135,7 @@ class Markup_isonumchars extends SimpleMarkup { class Markup_isohexchars extends SimpleMarkup { // hexnums, like ¤ <=> ¤ var $_match_regexp = '\&\#x[0-9a-fA-F]{2,4};'; - + function markup ($match) { return HTML::Raw($match); } @@ -1147,10 +1147,10 @@ class InlineTransformer { var $_regexps = array(); var $_markup = array(); - + function InlineTransformer ($markup_types = false) { global $request; - // We need to extend the inline parsers by certain actions, like SearchHighlight, + // We need to extend the inline parsers by certain actions, like SearchHighlight, // SpellCheck and maybe CreateToc. if (!$markup_types) { $non_default = false; @@ -1161,7 +1161,7 @@ class InlineTransformer 'wikicreole_superscript', 'wikicreole_subscript', 'wikicreole_italics', 'wikicreole_bold', - 'wikicreole_monospace', + 'wikicreole_monospace', 'old_emphasis', 'nestled_emphasis', 'html_emphasis', 'html_abbr', 'plugin', 'plugin_wikicreole', 'isonumchars', 'isohexchars', /*'html_entities'*/ @@ -1211,7 +1211,7 @@ class InlineTransformer $this->_regexps[] = $regexp; $this->_markup[] = $markup; } - + function parse (&$text, $end_regexps = array('$')) { $regexps = $this->_regexps; @@ -1219,18 +1219,18 @@ class InlineTransformer array_unshift($regexps, $end_regexps[0]); //array_push($regexps, $end_regexps[0]); $regexps = new RegexpSet($regexps); - + $input = $text; $output = new XmlContent; $match = $regexps->match($input); - + while ($match) { if ($match->regexp_ind == 0) { // No start pattern found before end pattern. // We're all done! - if (isset($markup) and is_object($markup) - and isa($markup,'Markup_plugin')) + if (isset($markup) and is_object($markup) + and isa($markup,'Markup_plugin')) { $current =& $output->_content[count($output->_content)-1]; $current->setTightness(true,true); @@ -1241,7 +1241,7 @@ class InlineTransformer } $markup = $this->_markup[$match->regexp_ind - 1]; - $body = $this->_parse_markup_body($markup, $match->match, + $body = $this->_parse_markup_body($markup, $match->match, $match->postmatch, $end_regexps); if (!$body) { // Couldn't match balanced expression. @@ -1257,8 +1257,8 @@ class InlineTransformer else $current = $markup->markup($match->match, $body); $input = $match->postmatch; - if (isset($markup) and is_object($markup) - and isa($markup,'Markup_plugin')) + if (isset($markup) and is_object($markup) + and isa($markup,'Markup_plugin')) { $current->setTightness(true,true); } @@ -1294,7 +1294,7 @@ class LinkTransformer extends InlineTransformer { function LinkTransformer () { $this->InlineTransformer(array('escape', 'wikicreolebracketlink', 'bracketlink', 'url', - 'semanticlink', 'interwiki', 'wikiword', + 'semanticlink', 'interwiki', 'wikiword', )); } } @@ -1316,7 +1316,7 @@ function TransformInline($text, $markup = 2.0, $basepage=false) { if (empty($trfm) or $action == 'SpellCheck') { $trfm = new InlineTransformer; } - + if ($markup < 2.0) { $text = ConvertOldMarkup($text, 'inline'); } @@ -1329,7 +1329,7 @@ function TransformInline($text, $markup = 2.0, $basepage=false) { function TransformLinks($text, $markup = 2.0, $basepage = false) { static $trfm; - + if (empty($trfm)) { $trfm = new LinkTransformer; } @@ -1337,7 +1337,7 @@ function TransformLinks($text, $markup = 2.0, $basepage = false) { if ($markup < 2.0) { $text = ConvertOldMarkup($text, 'links'); } - + if ($basepage) { return new CacheableMarkup($trfm->parse($text), $basepage); } @@ -1349,7 +1349,7 @@ function TransformLinks($text, $markup = 2.0, $basepage = false) { */ function TransformInlineNowiki($text, $markup = 2.0, $basepage=false) { static $trfm; - + if (empty($trfm)) { $trfm = new NowikiTransformer; } @@ -1359,12 +1359,11 @@ function TransformInlineNowiki($text, $markup = 2.0, $basepage=false) { return $trfm->parse($text); } -// (c-file-style: "gnu") // Local Variables: // mode: php // tab-width: 8 // c-basic-offset: 4 // c-hanging-comment-ender-p: nil // indent-tabs-mode: nil -// End: +// End: ?> diff --git a/lib/PageList.php b/lib/PageList.php index db9aa3fc5..811cd38a7 100644 --- a/lib/PageList.php +++ b/lib/PageList.php @@ -44,10 +44,10 @@ * 'creator' _("Creator") * 'owner' _("Owner") * 'checkbox' selectable checkbox at the left. - * 'content' + * 'content' * * Special, custom columns: Either theme or plugin (WikiAdmin*) specific. - * 'remove' _("Remove") + * 'remove' _("Remove") * 'perm' _("Permission Mask") * 'acl' _("ACL") * 'renamed_pagename' _("Rename to") @@ -65,12 +65,12 @@ * database. If lots of revisions have been made to a page, it's more than likely * that some older revisions (include revision 1) have been cleaned (deleted). * - * DONE: + * DONE: * paging support: limit, offset args * check PagePerm "list" access-type, * all columns are sortable. Thanks to the wikilens team. * cols > 1, comma, azhead, ordered (OL lists) - * ->supportedArgs() which arguments are supported, so that the plugin + * ->supportedArgs() which arguments are supported, so that the plugin * doesn't explictly need to declare it * added slice option when the page_iter (e.g. ->_pages) is already sliced. * @@ -79,9 +79,9 @@ * info=relation,linkto nopage=1 * use custom format method (RecentChanges, rss, ...) * - * FIXED: - * fix memory exhaustion on large pagelists with old --memory-limit php's only. - * Status: improved 2004-06-25 16:19:36 rurban + * FIXED: + * fix memory exhaustion on large pagelists with old --memory-limit php's only. + * Status: improved 2004-06-25 16:19:36 rurban */ class _PageList_Column_base { var $_tdattr = array(); @@ -121,10 +121,10 @@ class _PageList_Column_base { $sortby = PageList::sortby($this->_field, 'flip_order'); //Fixme: pass all also other GET args along. (limit, p[]) //TODO: support GET and POST - $s = HTML::a(array('href' => + $s = HTML::a(array('href' => $request->GetURLtoSelf(array('sortby' => $sortby)), 'class' => 'pagetitle', - 'title' => sprintf(_("Sort by %s"), $this->_field)), + 'title' => sprintf(_("Sort by %s"), $this->_field)), $nbsp, HTML::u($this->_heading), $nbsp); } else { $s = HTML($nbsp, HTML::u($this->_heading), $nbsp); @@ -140,12 +140,12 @@ class _PageList_Column_base { $nbsp = HTML::raw(' '); if (!$WikiTheme->DUMP_MODE /* or in_array($this->_field, PageList::sortable_columns()) */) { // TODO: add to multiple comma-delimited sortby args: "+hits,+pagename" - $src = false; + $src = false; $noimg_src = $WikiTheme->getButtonURL('no_order'); if ($noimg_src) $noimg = HTML::img(array('src' => $noimg_src, 'alt' => '.')); - else + else $noimg = $nbsp; if ($pagelist->sortby($colNum, 'check')) { // show icon? request or plugin arg $sortby = $pagelist->sortby($colNum, 'flip_order'); @@ -161,14 +161,14 @@ class _PageList_Column_base { $reverse = ""; $img->setAttr('alt', "."); } else { - $img = HTML::img(array('src' => $src, + $img = HTML::img(array('src' => $src, 'alt' => _("Click to reverse sort order"))); } - $s = HTML::a(array('href' => + $s = HTML::a(array('href' => //Fixme: pass all also other GET args along. (limit is ok, p[]) - $request->GetURLtoSelf(array('sortby' => $sortby, + $request->GetURLtoSelf(array('sortby' => $sortby, 'id' => $pagelist->id)), - 'class' => 'gridbutton', + 'class' => 'gridbutton', 'title' => sprintf(_("Click to sort by %s"), $reverse . $this->_field)), $nbsp, $this->_heading, $nbsp, $img, @@ -176,7 +176,7 @@ class _PageList_Column_base { } else { $s = HTML($nbsp, $this->_heading, $nbsp); } - return HTML::th(array('align' => 'center', 'valign' => 'middle', + return HTML::th(array('align' => 'center', 'valign' => 'middle', 'class' => 'gridbutton'), $s); } @@ -199,7 +199,7 @@ class _PageList_Column_base { } else { $ret = (!isset($colvala) || ($colvala < $colvalb)) ? -1 : 1; } - return $ret; + return $ret; } }; @@ -229,7 +229,7 @@ class _PageList_Column extends _PageList_Column_base { return $page_handle->get($this->_field); } } - + function _getSortableValue ($page_handle, &$revision_handle) { $val = $this->_getValue($page_handle, $revision_handle); if ($this->_field == 'hits') @@ -260,9 +260,9 @@ class _PageList_Column_size extends _PageList_Column { $this->_getValue($pagelist, $page_handle, $revision_handle), HTML::raw(' ')); } - + function _getValue (&$pagelist, $page_handle, &$revision_handle) { - if (!$revision_handle or (!$revision_handle->_data['%content'] + if (!$revision_handle or (!$revision_handle->_data['%content'] or $revision_handle->_data['%content'] === true)) { $revision_handle = $page_handle->getCurrentRevision(true); unset($revision_handle->_data['%pagedata']['_cached_html']); @@ -273,11 +273,11 @@ class _PageList_Column_size extends _PageList_Column { unset($revision_handle->_data['%content']); return $size; } - + function _getSortableValue ($page_handle, &$revision_handle) { if (!$revision_handle) $revision_handle = $page_handle->getCurrentRevision(true); - return (empty($revision_handle->_data['%content'])) + return (empty($revision_handle->_data['%content'])) ? 0 : strlen($revision_handle->_data['%content']); } @@ -339,7 +339,7 @@ class _PageList_Column_checkbox extends _PageList_Column { // don't sort this javascript button function button_heading ($pagelist, $colNum) { $s = HTML(HTML::raw(' '), $this->_heading, HTML::raw(' ')); - return HTML::th(array('align' => 'center', 'valign' => 'middle', + return HTML::th(array('align' => 'center', 'valign' => 'middle', 'class' => 'gridbutton'), $s); } }; @@ -373,8 +373,8 @@ class _PageList_Column_version extends _PageList_Column { // on very large Wikis this will fail if used with AllPages // (PHP memory limit exceeded) class _PageList_Column_content extends _PageList_Column { - function _PageList_Column_content ($field, $default_heading, $align=false, - $search=false, $hilight_re=false) + function _PageList_Column_content ($field, $default_heading, $align=false, + $search=false, $hilight_re=false) { $this->_PageList_Column($field, $default_heading, $align); $this->bytes = 50; @@ -392,9 +392,9 @@ class _PageList_Column_content extends _PageList_Column { '»'.$this->search.'«'); } } - + function _getValue ($page_handle, &$revision_handle) { - if (!$revision_handle or (!$revision_handle->_data['%content'] + if (!$revision_handle or (!$revision_handle->_data['%content'] or $revision_handle->_data['%content'] === true)) { $revision_handle = $page_handle->getCurrentRevision(true); } @@ -486,7 +486,7 @@ class _PageList_Column_author extends _PageList_Column { else return $author; } - + function _getSortableValue ($page_handle, &$revision_handle) { return _PageList_Column::_getValue($page_handle, $revision_handle); } @@ -564,7 +564,7 @@ class PageList { // unique id per pagelist on each page. if (!isset($GLOBALS['request']->_pagelist)) $GLOBALS['request']->_pagelist = 0; - else + else $GLOBALS['request']->_pagelist++; $this->id = $GLOBALS['request']->_pagelist; if ($GLOBALS['request']->getArg('count')) @@ -574,7 +574,7 @@ class PageList { $this->_initAvailableColumns(); // let plugins predefine only certain objects, such its own custom pagelist columns - $symbolic_columns = + $symbolic_columns = array( 'all' => array_diff(array_keys($this->_types), // all but... array('checkbox','remove','renamed_pagename', @@ -582,7 +582,7 @@ class PageList { 'most' => array('pagename','mtime','author','hits'), 'some' => array('pagename','mtime','author') ); - if (isset($this->_options['listtype']) + if (isset($this->_options['listtype']) and $this->_options['listtype'] == 'dl') $this->_options['nopage'] = 1; if ($columns) { @@ -618,8 +618,8 @@ class PageList { global $request; // explicit header options: ?id=x&sortby=... override options[] // support multiple sorts. check multiple, no nested elseif - if (($this->id == $request->getArg("id")) - and $request->getArg('sortby')) + if (($this->id == $request->getArg("id")) + and $request->getArg('sortby')) { // add it to the front of the sortby array $this->sortby($request->getArg('sortby'), 'init'); @@ -629,9 +629,9 @@ class PageList { if (empty($this->_options['sortby'])) $this->_options['sortby'] = $options['sortby']; $this->sortby($options['sortby'], 'init'); - } // global options - if (!isset($request->args["id"]) and $request->getArg('sortby') - and empty($this->_options['sortby'])) + } // global options + if (!isset($request->args["id"]) and $request->getArg('sortby') + and empty($this->_options['sortby'])) { $this->_options['sortby'] = $request->getArg('sortby'); $this->sortby($this->_options['sortby'], 'init'); @@ -639,18 +639,18 @@ class PageList { // same as above but without the special sortby push, and mutually exclusive (elseif) foreach ($this->pagingArgs() as $key) { if ($key == 'sortby') continue; - if (($this->id == $request->getArg("id")) - and $request->getArg($key)) + if (($this->id == $request->getArg("id")) + and $request->getArg($key)) { $this->_options[$key] = $request->getArg($key); } // plugin options elseif (!empty($options) and !empty($options[$key])) { $this->_options[$key] = $options[$key]; - } // global options + } // global options elseif (!isset($request->args["id"]) and $request->getArg($key)) { $this->_options[$key] = $request->getArg($key); } - else + else $this->_options[$key] = false; } if ($exclude) { @@ -665,14 +665,14 @@ class PageList { // Currently PageList takes these arguments: // 1: info, 2: exclude, 3: hash of options - // Here we declare which options are supported, so that - // the calling plugin may simply merge this with its own default arguments + // Here we declare which options are supported, so that + // the calling plugin may simply merge this with its own default arguments function supportedArgs () { // Todo: add all supported Columns, like locked, minor, ... return array(// Currently supported options: /* what columns, what pages */ 'info' => 'pagename', - 'exclude' => '', // also wildcards, comma-seperated lists + 'exclude' => '', // also wildcards, comma-seperated lists // and arrays /* select pages by meta-data: */ 'author' => false, // current user by [] @@ -680,7 +680,7 @@ class PageList { 'creator' => false, // current user by [] /* for the sort buttons in */ - 'sortby' => '', // same as for WikiDB::getAllPages + 'sortby' => '', // same as for WikiDB::getAllPages // (unsorted is faster) /* PageList pager options: @@ -691,19 +691,19 @@ class PageList { 'paging' => 'auto', // 'auto' top + bottom rows if applicable // // 'top' top only if applicable // // 'bottom' bottom only if applicable - // // 'none' don't page at all + // // 'none' don't page at all // (TODO: clarify what if $paging==false ?) /* list-style options (with single pagename column only so far) */ 'cols' => 1, // side-by-side display of list (1-3) 'azhead' => 0, // 1: group by initials // 2: provide shortcut links to initials also - 'comma' => 0, // condensed comma-seperated list, + 'comma' => 0, // condensed comma-seperated list, // 1 if without links, 2 if with 'commasep' => false, // Default: ', ' 'listtype' => '', // ul (default), ol, dl, comma 'ordered' => false, // OL or just UL lists (ignored for comma) - 'linkmore' => '', // If count>0 and limit>0 display a link with + 'linkmore' => '', // If count>0 and limit>0 display a link with // the number of all results, linked to the given pagename. 'nopage' => false, // for info=col omit the pagename column @@ -719,11 +719,11 @@ class PageList { 'external' => null, ); } - + function pagingArgs() { return array('sortby','limit','paging','count','dosort'); } - + function clearArg($arg_name) { if (isset($this->_options[$arg_name])) unset($this->_options[$arg_name]); @@ -809,7 +809,7 @@ class PageList { or (!empty($this->_excluded_pages) and in_array($page_handle->getName(), $this->_excluded_pages))) return; // exclude page. - + // enforce view permission if (!mayAccessPage('view', $page_handle->getName())) return; @@ -849,7 +849,7 @@ class PageList { $limit += $from; while ($page = $page_iter->next()) { $i++; - if ($from and $i < $from) + if ($from and $i < $from) continue; if (!$limit or ($limit and $i < $limit)) $this->addPage($page); @@ -877,8 +877,8 @@ class PageList { $this->_options['slice'] = 0; $i = 0; foreach ($list as $page) { - $i++; - if ($from and $i < $from) + $i++; + if ($from and $i < $from) continue; if (!$limit or ($limit and $i < $limit)) { if (is_object($page)) $page = $page->_pagename; @@ -899,7 +899,7 @@ class PageList { extract($dbi->_backend->_table_names); $row = $dbi->_backend->_dbh->getRow("SELECT max(length(pagename)) FROM $page_tbl"); return $row ? $row[0] : false; - } else + } else return false; } @@ -916,7 +916,7 @@ class PageList { if ($this->isEmpty()) return $this->_emptyList($caption); - elseif (isset($this->_options['listtype']) + elseif (isset($this->_options['listtype']) and in_array($this->_options['listtype'], array('ol','ul','comma','dl'))) return $this->_generateList($caption); elseif (count($this->_columns) == 1) @@ -932,16 +932,16 @@ class PageList { function asXML() { return AsXML($this->getContent()); } - - /** + + /** * Handle sortby requests for the DB iterator and table header links. * Prefix the column with + or - like "+pagename","-mtime", ... * - * Supported actions: + * Supported actions: * 'init' : unify with predefined order. "pagename" => "+pagename" * 'flip_order' : "mtime" => "+mtime" => "-mtime" ... * 'db' : "-pagename" => "pagename DESC" - * 'check' : + * 'check' : * * Now all columns are sortable. (patch by DanFr) * Some columns have native DB backend methods, some not. @@ -964,7 +964,7 @@ class PageList { else $result[] = $this->sortby($col, $action, $valid_fields); } - // 'check' returns true/false for every col. return true if all are true. + // 'check' returns true/false for every col. return true if all are true. // i.e. the unsupported 'every' operator in functional languages. if ($action == 'check') return $result; @@ -1013,7 +1013,7 @@ class PageList { $arg = $request->getArg('sortby'); return ($arg and strstr($arg, $column) - and (!isset($request->args['id']) + and (!isset($request->args['id']) or $this->id == $request->getArg('id'))); } elseif ($action == 'db') { // Performance enhancement: use native DB sort if possible. @@ -1037,16 +1037,16 @@ class PageList { * * echo implode(":",explodeList("Test*",array("xx","Test1","Test2"))); */ - function explodePageList($input, $include_empty=false, $sortby='', - $limit='', $exclude='') + function explodePageList($input, $include_empty=false, $sortby='', + $limit='', $exclude='') { if (empty($input)) return array(); if (is_array($input)) return $input; // expand wildcards from list of all pages if (preg_match('/[\?\*]/', $input) or substr($input,0,1) == "^") { include_once("lib/TextSearchQuery.php"); - $search = new TextSearchQuery(str_replace(",", " ", $input), true, - (substr($input,0,1) == "^") ? 'posix' : 'glob'); + $search = new TextSearchQuery(str_replace(",", " ", $input), true, + (substr($input,0,1) == "^") ? 'posix' : 'glob'); $dbi = $GLOBALS['request']->getDbh(); $iter = $dbi->titleSearch($search, $sortby, $limit, $exclude); $pages = array(); @@ -1061,8 +1061,8 @@ class PageList { } // TODO: optimize getTotal => store in count - function allPagesByAuthor($wildcard, $include_empty=false, $sortby='', - $limit='', $exclude='') + function allPagesByAuthor($wildcard, $include_empty=false, $sortby='', + $limit='', $exclude='') { $dbi = $GLOBALS['request']->getDbh(); $allPagehandles = $dbi->getAllPages($include_empty, $sortby, $limit, $exclude); @@ -1088,7 +1088,7 @@ class PageList { return $allPages; } - function allPagesByOwner($wildcard, $include_empty=false, $sortby='', + function allPagesByOwner($wildcard, $include_empty=false, $sortby='', $limit='', $exclude='') { $dbi = $GLOBALS['request']->getDbh(); $allPagehandles = $dbi->getAllPages($include_empty, $sortby, $limit, $exclude); @@ -1113,7 +1113,7 @@ class PageList { return $allPages; } - function allPagesByCreator($wildcard, $include_empty=false, $sortby='', + function allPagesByCreator($wildcard, $include_empty=false, $sortby='', $limit='', $exclude='') { $dbi = $GLOBALS['request']->getDbh(); $allPagehandles = $dbi->getAllPages($include_empty, $sortby, $limit, $exclude); @@ -1157,8 +1157,8 @@ class PageList { //////////////////// // private //////////////////// - /** Plugin and theme hooks: - * If the pageList is initialized with $options['types'] these types are also initialized, + /** Plugin and theme hooks: + * If the pageList is initialized with $options['types'] these types are also initialized, * overriding the standard types. */ function _initAvailableColumns() { @@ -1228,7 +1228,7 @@ class PageList { $this->_types = array(); // add plugin specific pageList columns, initialized by $options['types'] $this->_types = array_merge($standard_types, $this->_types); - // add theme custom specific pageList columns: + // add theme custom specific pageList columns: // set the 4th param as the current pagelist object. if (!empty($customPageListColumns)) { foreach ($customPageListColumns as $column => $params) { @@ -1281,14 +1281,14 @@ class PageList { $silently_ignore = array('numbacklinks', 'rating','ratingvalue', 'coagreement', 'minmisery', - 'averagerating', 'top3recs', + 'averagerating', 'top3recs', 'relation', 'linkto'); if (!in_array($column, $silently_ignore)) trigger_error(sprintf("%s: Bad column", $column), E_USER_NOTICE); return false; } if (!GFORGE) { - // FIXME: anon users might rate and see ratings also. + // FIXME: anon users might rate and see ratings also. // Defer this logic to the plugin. if ($column == 'rating' and !$GLOBALS['request']->_user->isSignedIn()) { return false; @@ -1431,8 +1431,8 @@ class PageList { $tokens = array(); $tokens['PREV'] = false; $tokens['PREV_LINK'] = ""; $tokens['COLS'] = $ncolumns; - $tokens['COUNT'] = $numrows; - $tokens['OFFSET'] = $offset; + $tokens['COUNT'] = $numrows; + $tokens['OFFSET'] = $offset; $tokens['SIZE'] = $pagesize; $tokens['NUMPAGES'] = (int) ceil($numrows / $pagesize); $tokens['ACTPAGE'] = (int) ceil(($offset / $pagesize)+1); @@ -1448,7 +1448,7 @@ class PageList { $next = $defargs; $tokens['NEXT'] = false; $tokens['NEXT_LINK'] = ""; if (($offset + $pagesize) < $numrows) { - $next['limit'] = min($offset + $pagesize, $numrows - $pagesize) + $next['limit'] = min($offset + $pagesize, $numrows - $pagesize) . ",$pagesize"; $next['count'] = $numrows; $tokens['LIMIT'] = $next['limit']; @@ -1459,22 +1459,22 @@ class PageList { } return $tokens; } - + // make a table given the caption function _generateTable($caption) { if (count($this->_sortby) > 0) $this->_sortPages(); - + // wikiadminutils hack. that's a way to pagelist non-pages $rows = isset($this->_rows) ? $this->_rows : array(); $i = 0; $count = $this->getTotal(); - $do_paging = ( isset($this->_options['paging']) - and !empty($this->_options['limit']) - and $count + $do_paging = ( isset($this->_options['paging']) + and !empty($this->_options['limit']) + and $count and $this->_options['paging'] != 'none' ); if ($do_paging) { - $tokens = $this->pagingTokens($count, - count($this->_columns), + $tokens = $this->pagingTokens($count, + count($this->_columns), $this->_options['limit']); if ($tokens and !empty($this->_options['slice'])) $this->_pages = array_slice($this->_pages, $tokens['OFFSET'], $tokens['SIZE']); @@ -1486,7 +1486,7 @@ class PageList { $table = HTML::table(array('cellpadding' => 0, 'cellspacing' => 1, 'border' => 0, - 'width' => '100%', + 'width' => '100%', 'class' => 'pagelist')); if ($caption) { $table->pushContent(HTML::caption(array('align'=>'top'), $caption)); @@ -1497,9 +1497,9 @@ class PageList { $i = 1; // start with 1! foreach ($this->_columns as $col) { $heading = $col->button_heading($this, $i); - if ( $do_paging - and isset($col->_field) - and $col->_field == 'pagename' + if ( $do_paging + and isset($col->_field) + and $col->_field == 'pagename' and ($maxlen = $this->maxLen())) { } $row->pushContent($heading); @@ -1508,7 +1508,7 @@ class PageList { $i++; } // Table summary for non-visual browsers. - $table->setAttr('summary', sprintf(_("Columns: %s."), + $table->setAttr('summary', sprintf(_("Columns: %s."), join(", ", $table_summary))); $table->pushContent(HTML::colgroup(array('span' => count($this->_columns)))); if ( $do_paging ) { @@ -1560,7 +1560,7 @@ class PageList { // FIXME: only unique list entries, esp. with nopage function _generateList($caption='') { if (empty($this->_pages)) return; // stop recursion - if (!isset($this->_options['listtype'])) + if (!isset($this->_options['listtype'])) $this->_options['listtype'] = ''; foreach ($this->_pages as $pagenum => $page) { $one_row = $this->_renderPageRow($page); @@ -1577,13 +1577,13 @@ class PageList { } if (count($this->_sortby) > 0) $this->_sortPages(); $count = $this->getTotal(); - $do_paging = ( isset($this->_options['paging']) - and !empty($this->_options['limit']) - and $count + $do_paging = ( isset($this->_options['paging']) + and !empty($this->_options['limit']) + and $count and $this->_options['paging'] != 'none' ); if ( $do_paging ) { - $tokens = $this->pagingTokens($count, - count($this->_columns), + $tokens = $this->pagingTokens($count, + count($this->_columns), $this->_options['limit']); if ($tokens) { $paging = Template("pagelink", $tokens); @@ -1609,7 +1609,7 @@ class PageList { for ($i=$offset; $i < $offset+$count; $i += $length) { $this->_saveOptions(array('cols' => 0, 'paging' => 'none')); $this->_pages = array_slice($this->_pages, $i, $length); - $cols->pushContent(HTML::td(/*array('width' => $width),*/ + $cols->pushContent(HTML::td(/*array('width' => $width),*/ $this->_generateList())); $this->_restoreOptions(); } @@ -1619,9 +1619,9 @@ class PageList { $cols)); return $out; } - + // Ignore azhead if not sorted by pagename - if (!empty($this->_options['azhead']) + if (!empty($this->_options['azhead']) and strstr($this->sortby($this->_options['sortby'], 'init'), "pagename") ) { @@ -1668,7 +1668,7 @@ class PageList { } elseif ($this->_options['listtype'] == 'ul') $this->_options['ordered'] = 0; if ($this->_options['listtype'] == 'ol' and !empty($this->_options['ordered'])) { - $list = HTML::ol(array('class' => 'pagelist', + $list = HTML::ol(array('class' => 'pagelist', 'start' => $this->_options['ordered'])); } elseif ($this->_options['listtype'] == 'dl') { $list = HTML::dl(array('class' => 'pagelist')); @@ -1685,11 +1685,11 @@ class PageList { $pagehtml = $one_row['render']; if (!$pagehtml) continue; $group = ($i++ / $this->_group_rows); - //TODO: here we switch every row, in tables every third. + //TODO: here we switch every row, in tables every third. // unification or parametrized? $class = ($group % 2) ? 'oddrow' : 'evenrow'; if ($this->_options['listtype'] == 'dl') { - $header = $one_row['header']; + $header = $one_row['header']; $list->pushContent(HTML::dt(array('class' => $class), $header), HTML::dd(array('class' => $class), $pagehtml)); } else @@ -1704,7 +1704,7 @@ class PageList { } // comma=1 - // Condense list without a href links: "Page1, Page2, ..." + // Condense list without a href links: "Page1, Page2, ..." // Alternative $seperator = HTML::Raw(' · ') // FIXME: only unique list entries, esp. with nopage function _generateCommaListAsString() { @@ -1739,7 +1739,7 @@ class PageList { } return $html; } - + function _emptyList($caption) { $html = HTML(); if ($caption) { @@ -1808,7 +1808,6 @@ extends PageList { } } -// (c-file-style: "gnu") // Local Variables: // mode: php // tab-width: 8 diff --git a/lib/RSSWriter091.php b/lib/RSSWriter091.php index 08aa0049c..1abff93d7 100644 --- a/lib/RSSWriter091.php +++ b/lib/RSSWriter091.php @@ -33,15 +33,15 @@ class RSSWriter091 extends RSSWriter } /** * Finish construction of RSS. - */ - function finish() + */ + function finish() { if (isset($this->_finished)) return; - + $channel = &$this->_channel; $items = &$this->_items; - + if ($items) { foreach ($items as $i) @@ -70,15 +70,15 @@ class RSSWriter091 extends RSSWriter print("\"http://my.netscape.com/publish/formats/rss-0.91.dtd\">\n\n"); $this->printXML(); } - - + + } class _RecentChanges_RssFormatter091 extends _RecentChanges_RSSFormatter // This class should probably go at then of RecentChanges.php { - function format ($changes) + function format ($changes) { // include_once('lib/RssWriter.php'); $rss = new RssWriter091; @@ -102,7 +102,7 @@ extends _RecentChanges_RSSFormatter } - function channel_properties () + function channel_properties () { global $request; @@ -114,34 +114,33 @@ extends _RecentChanges_RSSFormatter 'language' => 'en-US'); /* FIXME: language should come from $LANG (or other config variable). */ - - /* FIXME: other things one might like in : + + /* FIXME: other things one might like in : * managingEditor * webmaster * lastBuildDate * copyright */ } - - + + function item_properties ($rev) { $page = $rev->getPage(); $pagename = $page->getName(); - + return array( 'title' => SplitPagename($pagename), 'description' => $this->summary($rev), - 'link' => $this->pageURL($rev) + 'link' => $this->pageURL($rev) ); } } -// (c-file-style: "gnu") // Local Variables: // mode: php // tab-width: 8 // c-basic-offset: 4 // c-hanging-comment-ender-p: nil // indent-tabs-mode: nil -// End: +// End: ?> diff --git a/lib/RssParser.php b/lib/RssParser.php index 7ebf43159..ee02e1a2d 100644 --- a/lib/RssParser.php +++ b/lib/RssParser.php @@ -30,9 +30,9 @@ */ /** - * 2004-04-09 16:30:50 rurban: + * 2004-04-09 16:30:50 rurban: * added fsockopen allow_url_fopen = Off workaround - * 2004-04-12 20:04:12 rurban: + * 2004-04-12 20:04:12 rurban: * fixes for IMAGE element (sf.net) * 2005-04-10 11:17:35 rurban * certain RSS dont contain tags to describe the list of @@ -41,7 +41,7 @@ require_once('lib/XmlParser.php'); -class RSSParser +class RSSParser extends XmlParser { var $title = ""; @@ -75,7 +75,7 @@ extends XmlParser { if ($tagName == "ITEM") { if (empty($this->items)) { - $this->items = array(); + $this->items = array(); $GLOBALS['rss_parser_items'] =& $this->items; } elseif (!empty($this->items[0]['link']) and $this->items[0]['title'] == '') { // override the initial list with detailed 's @@ -160,11 +160,11 @@ extends XmlParser { } } } - + function parse($content, $is_final = true) { - xml_parse($this->_parser, $content, $is_final) or - trigger_error(sprintf("XML error: %s at line %d", - xml_error_string(xml_get_error_code($this->_parser)), + xml_parse($this->_parser, $content, $is_final) or + trigger_error(sprintf("XML error: %s at line %d", + xml_error_string(xml_get_error_code($this->_parser)), xml_get_current_line_number($this->_parser)), E_USER_WARNING); //OO workaround: parser object looses its params. we have to store them in globals @@ -179,7 +179,6 @@ extends XmlParser { } } -// For emacs users // Local Variables: // mode: php // tab-width: 8 diff --git a/lib/RssWriter.php b/lib/RssWriter.php index 12fbe076e..b753b595b 100644 --- a/lib/RssWriter.php +++ b/lib/RssWriter.php @@ -53,7 +53,7 @@ class RssWriter extends XmlElement function channel($properties, $uri = false) { $this->_channel = $this->__node('channel', $properties, $uri); } - + // Args should include: // 'title', 'link' // and can include: @@ -94,7 +94,7 @@ class RssWriter extends XmlElement $seq->pushContent($this->__ref('rdf:li', $item)); } $channel->pushContent(new XmlElement('items', false, $seq)); - + if (isset($this->_image)) { $channel->pushContent($this->__ref('image', $this->_image)); $items[] = $this->_image; @@ -111,7 +111,7 @@ class RssWriter extends XmlElement $this->__spew(); $this->_finished = true; } - + /** * Write output to HTTP client. */ @@ -121,8 +121,8 @@ class RssWriter extends XmlElement //printf("\n", PHPWIKI_VERSION); $this->printXML(); } - - + + /** * Create a new RDF typedNode. */ @@ -156,8 +156,8 @@ class RssWriter extends XmlElement $this->__check_predicate($prop); if (is_array($val)) $out[] = new XmlElement($prop, $val); - elseif (is_object($val)) - $out[] = $val; + elseif (is_object($val)) + $out[] = $val; else $out[] = new XmlElement($prop, false, $val); } @@ -187,11 +187,11 @@ class RssWriter extends XmlElement } }; -/* Taken from mediawiki. - * See http://www.atomenabled.org/developers/syndication/ +/* Taken from mediawiki. + * See http://www.atomenabled.org/developers/syndication/ */ class AtomFeed extends RssWriter { - + // Args should include: // 'title', 'link', 'description' // and can include: @@ -251,13 +251,11 @@ class AtomFeed extends RssWriter { } } - -// (c-file-style: "gnu") // Local Variables: // mode: php // tab-width: 8 // c-basic-offset: 4 // c-hanging-comment-ender-p: nil // indent-tabs-mode: nil -// End: +// End: ?> diff --git a/lib/RssWriter2.php b/lib/RssWriter2.php index 15398f4ab..14bf6a011 100644 --- a/lib/RssWriter2.php +++ b/lib/RssWriter2.php @@ -12,7 +12,7 @@ include_once("lib/RssWriter.php"); * * @see http://blogs.law.harvard.edu/tech/rss, * http://www.usemod.com/cgi-bin/mb.pl?ModWiki - * no namespace! + * no namespace! * http://sourceforge.net/mailarchive/forum.php?thread_id=4872845&forum_id=37467 */ class RssWriter2 extends RssWriter @@ -48,13 +48,13 @@ class RssWriter2 extends RssWriter // none function cloud($properties) { // xml-rpc or soap or http-post - if (!isset($properties['protocol'])) $properties['protocol'] = 'xml-rpc'; - if (!isset($properties['registerProcedure'])) + if (!isset($properties['protocol'])) $properties['protocol'] = 'xml-rpc'; + if (!isset($properties['registerProcedure'])) $properties['registerProcedure'] = 'rssPleaseNotify'; if (!isset($properties['path'])) $properties['path'] = DATA_PATH.'/RPC2.php'; - if (!isset($properties['port'])) - $properties['port'] = !SERVER_PORT - ? '80' + if (!isset($properties['port'])) + $properties['port'] = !SERVER_PORT + ? '80' : (SERVER_PROTOCOL == 'https' ? '443' : '80'); if (!isset($properties['domain'])) $properties['domain'] = SERVER_NAME; $this->_cloud = $this->__node('cloud', $properties); @@ -75,12 +75,11 @@ class RssWriter2 extends RssWriter } }; -// (c-file-style: "gnu") // Local Variables: // mode: php // tab-width: 8 // c-basic-offset: 4 // c-hanging-comment-ender-p: nil // indent-tabs-mode: nil -// End: +// End: ?> diff --git a/lib/SemanticWeb.php b/lib/SemanticWeb.php index 667fab9ab..6a0222dfb 100644 --- a/lib/SemanticWeb.php +++ b/lib/SemanticWeb.php @@ -2,13 +2,13 @@ /** * What to do on ?format=rdf What to do on ?format=owl * - * Map relations on a wikipage to a RDF ressource to build a "Semantic Web" + * Map relations on a wikipage to a RDF ressource to build a "Semantic Web" * - a web ontology frontend compatible to OWL (web ontology language). * http://www.w3.org/2001/sw/Activity * Simple RDF ontologies contain facts and rules, expressed by RDF triples: * Subject (page) -> Predicate (verb, relation) -> Object (links) - * OWL extents that to represent a typical OO framework. - * OO predicates: + * OWL extents that to represent a typical OO framework. + * OO predicates: * is_a, has_a, ... * OWL predicates: * subClassOf, restrictedBy, onProperty, intersectionOf, allValuesFrom, ... @@ -19,10 +19,10 @@ * DAML should also be supported. * * Purpose: - * - Another way to represent various KB models in various DL languages. + * - Another way to represent various KB models in various DL languages. * (OWL/DAML/other DL) - * - Frontend to various KB model reasoners and representations. - * - Generation/update of static wiki pages based on external OWL/DL/KB + * - Frontend to various KB model reasoners and representations. + * - Generation/update of static wiki pages based on external OWL/DL/KB * (=> ModelTest/Categories) * KB Blackboard and Visualization. * - OWL generation based on static wiki pages (ModelTest?format=owl) @@ -31,7 +31,7 @@ * - Each page must be representable with an unique URL. * - Each fact must be representable with an unique RDF triple. * - A class is represented by a category page. - * - To represent more expressive description logic, "enriched" + * - To represent more expressive description logic, "enriched" * links will not be enough (? variable symbolic objects). * * Rules: (may be represented by special content on a page) @@ -40,9 +40,9 @@ * RDF Triple: (representing facts) * Subject (page) -> Predicate (verb, relation) -> Object (links) * Subject: a page - * Verb: + * Verb: * Special link qualifiers represent RDF triples, based on RDF standard notation. - * See RDF standard DTD's on daml.org and w3.org, plus your custom predicates. + * See RDF standard DTD's on daml.org and w3.org, plus your custom predicates. * (need your own DTD) * Example: page [Ape] isa:Animal, ... * Object: special links on a page. @@ -56,7 +56,7 @@ * Of course *real* expert systems ("reasoners") will help/must be used in * optimization and maintainance of the SemanticWeb KB (Knowledge * Base). Hooks will be tested to KM (an interactive KB playground), - * LISA (standard unifier), FaCT, RACER, ... + * LISA (standard unifier), FaCT, RACER, ... * Maybe also ZEBU (parser generator) is needed to convert the wiki KB * syntax to the KB reasoner backend (LISA, KM, CLIPS, JESS, FaCT, @@ -68,13 +68,13 @@ * * SEAL (omntoweb.org) is similar to that, just on top of the Zope CMF. * FaCT uses e.g. this KB DTD: - - - + + + ... (facts and rules described in XML) * * Links: - * http://phpwiki.org/SemanticWeb, + * http://phpwiki.org/SemanticWeb, * http://en.wikipedia.org/wiki/Knowledge_representation * http://www.ontoweb.org/ * http://www.semwebcentral.org/ (OWL on top of GForge) @@ -109,7 +109,7 @@ require_once('lib/Units.php'); /** - * RdfWriter - A class to represent the links of a list of wikipages as RDF. + * RdfWriter - A class to represent the links of a list of wikipages as RDF. * Supports ?format=rdf * * RdfWriter (unsorted) @@ -120,7 +120,7 @@ class RdfWriter extends RssWriter // in fact it should be rewritten to be other { function RdfWriter (&$request, &$pagelist) { $this->_request =& $request; - $this->_pagelist =& $pagelist; + $this->_pagelist =& $pagelist; $this->XmlElement('rdf:RDF', array('xmlns' => "http://purl.org/rss/1.0/", 'xmlns:rdf' => 'http://www.w3.org/1999/02/22-rdf-syntax-ns#')); @@ -251,7 +251,7 @@ class OwlWriter extends RdfWriter { }; /** - * ModelWriter - Export a KB as set of wiki pages. + * ModelWriter - Export a KB as set of wiki pages. * Requires an actionpage returning a pagelist. * Probably based on some convenient DL expression syntax. (deffact, defrule, ...) * @@ -263,16 +263,16 @@ class ModelWriter extends OwlWriter { }; /** - * NumericSearchQuery can do: + * NumericSearchQuery can do: * ("population < 20000 and area > 1000000", array("population", "area")) - * ->match(array('population' => 100000, 'area' => 10000000)) + * ->match(array('population' => 100000, 'area' => 10000000)) * @see NumericSearchQuery * * SemanticAttributeSearchQuery can detect and unify units in numbers. * ("population < 2million and area > 100km2", array("population", "area")) * ->match(array('population' => 100000, 'area' => 10000000)) * - * Do we need a real parser or can we just regexp over some allowed unit + * Do we need a real parser or can we just regexp over some allowed unit * suffixes to detect the numbers? * See man units(1) and /usr/share/units.dat * base units: $ units "1 million miles" @@ -299,9 +299,9 @@ extends NumericSearchQuery } /** - * Strip non-numeric chars from the variable (as the groupseperator) and replace + * Strip non-numeric chars from the variable (as the groupseperator) and replace * it in the symbolic query for evaluation. - * This version unifies the attribute values from the database to a + * This version unifies the attribute values from the database to a * numeric basevalue before comparison. (area:=963.6km^2 => 9.366e+08 m^2) * * @access private @@ -314,7 +314,7 @@ extends NumericSearchQuery $value = preg_replace("/,/", "", $value); $this->_bound[] = array('linkname' => $x, 'linkvalue' => $value); - // We must ensure that the same baseunits are matched against. + // We must ensure that the same baseunits are matched against. // We cannot compare m^2 to m or '' $val_base = $this->_units->basevalue($value); if (!DISABLE_UNITS and $this->_units->baseunit($value) != $this->unit) { @@ -330,7 +330,7 @@ extends NumericSearchQuery $value = $val_base; if (!is_numeric($value)) { $this->_workquery = ''; //must return false - trigger_error("Cannot match against non-numeric attribute value $x := $ori_value", + trigger_error("Cannot match against non-numeric attribute value $x := $ori_value", E_USER_NOTICE); return ''; } @@ -344,18 +344,18 @@ extends NumericSearchQuery /** * SemanticSearchQuery can do: * (is_a::city and population < 20000) and (*::city and area > 1000000) - * ->match(array('is_a' => 'city', 'linkfrom' => array(), + * ->match(array('is_a' => 'city', 'linkfrom' => array(), * population' => 100000, 'area' => 10000000)) * @return array A list of found and bound matches */ class SemanticSearchQuery extends SemanticAttributeSearchQuery { - function hasAttributes() { // TODO + function hasAttributes() { // TODO } - function hasRelations() { // TODO + function hasRelations() { // TODO } - function getLinkNames() { // TODO + function getLinkNames() { // TODO } } @@ -397,12 +397,11 @@ class ReasonerBackend_Racer extends ReasonerBackend { class ReasonerBackend_KM extends ReasonerBackend { }; -// (c-file-style: "gnu") // Local Variables: // mode: php // tab-width: 8 // c-basic-offset: 4 // c-hanging-comment-ender-p: nil // indent-tabs-mode: nil -// End: +// End: ?> diff --git a/lib/WikiCallback.php b/lib/WikiCallback.php index e3552dcdc..ea2fab45d 100644 --- a/lib/WikiCallback.php +++ b/lib/WikiCallback.php @@ -36,7 +36,7 @@ class WikiCallback } trigger_error("WikiCallback::new: bad arg", E_USER_ERROR); } - + /** * Call callback. * @@ -66,7 +66,7 @@ class WikiCallback * * @return string The name of the callback function. * (This value is suitable for passing as the callback parameter - * to a number of different Pear functions and methods.) + * to a number of different Pear functions and methods.) * @access public */ function toPearCb() { @@ -155,12 +155,11 @@ class WikiAnonymousCb } } -// (c-file-style: "gnu") // Local Variables: // mode: php // tab-width: 8 // c-basic-offset: 4 // c-hanging-comment-ender-p: nil // indent-tabs-mode: nil -// End: +// End: ?> diff --git a/lib/WikiDB/ADODB.php b/lib/WikiDB/ADODB.php index 1d3871d41..8ef9729d0 100644 --- a/lib/WikiDB/ADODB.php +++ b/lib/WikiDB/ADODB.php @@ -4,9 +4,9 @@ require_once('lib/WikiDB.php'); /** - * WikiDB layer for ADODB, which does nothing more than calling the + * WikiDB layer for ADODB, which does nothing more than calling the * mysql-specific ADODB backend. - * Support for a newer adodb library, the adodb extension library + * Support for a newer adodb library, the adodb extension library * and more databases will come with PhpWiki v1.3.10 * * @author: Lawrence Akka, Reini Urban @@ -37,7 +37,7 @@ class WikiDB_ADODB extends WikiDB if (!$backend->_dbh->_connectionID) return false; $this->WikiDB($backend, $dbparams); } - + /** * Determine whether page exists (in non-default form). * @see WikiDB::isWikiPage @@ -98,8 +98,7 @@ class WikiDB_ADODB extends WikiDB } }; - -// For emacs users + // Local Variables: // mode: php // tab-width: 8 diff --git a/lib/WikiDB/PDO.php b/lib/WikiDB/PDO.php index fa11a728d..03f1ed562 100644 --- a/lib/WikiDB/PDO.php +++ b/lib/WikiDB/PDO.php @@ -4,7 +4,7 @@ require_once('lib/WikiDB.php'); /** - * WikiDB layer for PDO, the new php5 abstraction layer, with support for + * WikiDB layer for PDO, the new php5 abstraction layer, with support for * prepared statements and transactions. * * "The PHP Data Objects (PDO) extension defines a lightweight, @@ -35,7 +35,7 @@ class WikiDB_PDO extends WikiDB $backend = new $backend_class($dbparams); $this->WikiDB($backend, $dbparams); } - + /** * Determine whether page exists (in non-default form). * @see WikiDB::isWikiPage @@ -88,7 +88,7 @@ class WikiDB_PDO extends WikiDB } if ($sth->execute()) $result = $sth->fetch(PDO_FETCH_BOTH); - else + else return false; } catch (PDOException $e) { @@ -106,8 +106,7 @@ class WikiDB_PDO extends WikiDB } }; - -// For emacs users + // Local Variables: // mode: php // tab-width: 8 @@ -115,4 +114,4 @@ class WikiDB_PDO extends WikiDB // c-hanging-comment-ender-p: nil // indent-tabs-mode: nil // End: -?> \ No newline at end of file +?> diff --git a/lib/WikiDB/SQL.php b/lib/WikiDB/SQL.php index 5dd10e422..1aa08b260 100644 --- a/lib/WikiDB/SQL.php +++ b/lib/WikiDB/SQL.php @@ -26,7 +26,7 @@ class WikiDB_SQL extends WikiDB if (DB::isError($backend->_dbh)) return; $this->WikiDB($backend, $dbparams); } - + function view_dsn ($dsn = false) { if (!$dsn) $dsninfo = DB::parseDSN($GLOBALS['DBParams']['dsn']); @@ -40,7 +40,7 @@ class WikiDB_SQL extends WikiDB ); } - + /** * Determine whether page exists (in non-default form). * @see WikiDB::isWikiPage for the slow generic version @@ -55,7 +55,7 @@ class WikiDB_SQL extends WikiDB return $this->_cache->_id_cache[$pagename]; } - // adds surrounding quotes + // adds surrounding quotes function quote ($s) { return $this->_backend->_dbh->quoteSmart($s); } // no surrounding quotes because we know it's a string function qstr ($s) { return $this->_backend->_dbh->escapeSimple($s); } @@ -91,8 +91,6 @@ class WikiDB_SQL extends WikiDB }; - -// For emacs users // Local Variables: // mode: php // tab-width: 8 @@ -100,5 +98,4 @@ class WikiDB_SQL extends WikiDB // c-hanging-comment-ender-p: nil // indent-tabs-mode: nil // End: - ?> diff --git a/lib/WikiDB/adodb/adodb.inc.php b/lib/WikiDB/adodb/adodb.inc.php index d401e2af2..3a8a50cde 100644 --- a/lib/WikiDB/adodb/adodb.inc.php +++ b/lib/WikiDB/adodb/adodb.inc.php @@ -1,9 +1,9 @@ - Manual is at http://php.weblogs.com/adodb_manual - + */ - + if (!defined('_ADODB_LAYER')) { define('_ADODB_LAYER',1); - + //========================================================================== // CONSTANT DEFINITIONS //========================================================================== - /** + /** * Set ADODB_DIR to the directory where this file resides... * This constant was formerly called $ADODB_RootPath */ if (!defined('ADODB_DIR')) define('ADODB_DIR',dirname(__FILE__)); - + //========================================================================== // GLOBAL VARIABLES //========================================================================== - GLOBAL + GLOBAL $ADODB_vers, // database version $ADODB_COUNTRECS, // count number of records returned - slows down query $ADODB_CACHE_DIR, // directory to cache recordsets $ADODB_EXTENSION, // ADODB extension installed $ADODB_COMPAT_PATCH, // If $ADODB_COUNTRECS and this is true, $rs->fields is available on EOF $ADODB_FETCH_MODE; // DEFAULT, NUM, ASSOC or BOTH. Default follows native driver default... - + //========================================================================== // GLOBAL SETUP //========================================================================== - + $ADODB_EXTENSION = defined('ADODB_EXTENSION'); if (!$ADODB_EXTENSION || ADODB_EXTENSION < 4.0) { - + define('ADODB_BAD_RS','

Bad $rs in %s. Connection or SQL invalid. Try using $connection->debug=true;

'); - + // allow [ ] @ ` " and . in table names define('ADODB_TABLE_REGEX','([]0-9a-z_\"\`\.\@\[-]*)'); - + // prefetching used by oracle if (!defined('ADODB_PREFETCH_ROWS')) define('ADODB_PREFETCH_ROWS',10); - - + + /* Controls ADODB_FETCH_ASSOC field-name case. Default is 2, use native case-names. This currently works only with mssql, odbc, oci8po and ibase derived drivers. - + 0 = assoc lowercase field names. $rs->fields['orderid'] 1 = assoc uppercase field names. $rs->fields['ORDERID'] 2 = use native-case field names. $rs->fields['OrderID'] */ - + define('ADODB_FETCH_DEFAULT',0); define('ADODB_FETCH_NUM',1); define('ADODB_FETCH_ASSOC',2); define('ADODB_FETCH_BOTH',3); - + if (!defined('TIMESTAMP_FIRST_YEAR')) define('TIMESTAMP_FIRST_YEAR',100); - + if (strnatcmp(PHP_VERSION,'4.3.0')>=0) { define('ADODB_PHPVER',0x4300); } else if (strnatcmp(PHP_VERSION,'4.2.0')>=0) { @@ -100,17 +100,17 @@ define('ADODB_PHPVER',0x4000); } } - + //if (!defined('ADODB_ASSOC_CASE')) define('ADODB_ASSOC_CASE',2); - - + + /** Accepts $src and $dest arrays, replacing string $data */ function ADODB_str_replace($src, $dest, $data) { if (ADODB_PHPVER >= 0x4050) return str_replace($src,$dest,$data); - + $s = reset($src); $d = reset($dest); while ($s !== false) { @@ -120,47 +120,47 @@ } return $data; } - + function ADODB_Setup() { - GLOBAL + GLOBAL $ADODB_vers, // database version $ADODB_COUNTRECS, // count number of records returned - slows down query $ADODB_CACHE_DIR, // directory to cache recordsets $ADODB_FETCH_MODE; - + $ADODB_FETCH_MODE = ADODB_FETCH_DEFAULT; - + if (!isset($ADODB_CACHE_DIR)) { $ADODB_CACHE_DIR = '/tmp'; //(isset($_ENV['TMP'])) ? $_ENV['TMP'] : '/tmp'; } else { // do not accept url based paths, eg. http:/ or ftp:/ - if (strpos($ADODB_CACHE_DIR,'://') !== false) + if (strpos($ADODB_CACHE_DIR,'://') !== false) die("Illegal path http:// or ftp://"); } - - + + // Initialize random number generator for randomizing cache flushes srand(((double)microtime())*1000000); - + /** * ADODB version as a string. */ $ADODB_vers = 'V4.22 15 Apr 2004 (c) 2000-2004 John Lim (jlim#natsoft.com.my). All rights reserved. Released BSD & LGPL.'; - + /** - * Determines whether recordset->RecordCount() is used. + * Determines whether recordset->RecordCount() is used. * Set to false for highest performance -- RecordCount() will always return -1 then * for databases that provide "virtual" recordcounts... */ - if (!isset($ADODB_COUNTRECS)) $ADODB_COUNTRECS = true; + if (!isset($ADODB_COUNTRECS)) $ADODB_COUNTRECS = true; } - - + + //========================================================================== // CHANGE NOTHING BELOW UNLESS YOU ARE DESIGNING ADODB //========================================================================== - + ADODB_Setup(); //========================================================================== @@ -169,23 +169,23 @@ /** * Helper class for FetchFields -- holds info on a column */ - class ADOFieldObject { + class ADOFieldObject { var $name = ''; var $max_length=0; var $type=""; // additional fields by dannym... (danny_milo@yahoo.com) - var $not_null = false; + var $not_null = false; // actually, this has already been built-in in the postgres, fbsql AND mysql module? ^-^ // so we can as well make not_null standard (leaving it at "false" does not harm anyways) - var $has_default = false; // this one I have done only in mysql and postgres for now ... + var $has_default = false; // this one I have done only in mysql and postgres for now ... // others to come (dannym) var $default_value; // default, if any, and supported. Check has_default first. } - - + + function ADODB_TransMonitor($dbms, $fn, $errno, $errmsg, $p1, $p2, &$thisConnection) { //print "Errorno ($fn errno=$errno m=$errmsg) "; @@ -195,27 +195,27 @@ $fn($dbms, $fn, $errno, $errmsg, $p1, $p2,$thisConnection); } } - + //========================================================================== // CLASS ADOConnection //========================================================================== - + /** * Connection object. For connecting to databases, and executing queries. - */ + */ class ADOConnection { // - // PUBLIC VARS + // PUBLIC VARS // var $dataProvider = 'native'; - var $databaseType = ''; /// RDBMS currently in use, eg. odbc, mysql, mssql - var $database = ''; /// Name of database to be used. - var $host = ''; /// The hostname of the database server - var $user = ''; /// The username which is used to connect to the database server. + var $databaseType = ''; /// RDBMS currently in use, eg. odbc, mysql, mssql + var $database = ''; /// Name of database to be used. + var $host = ''; /// The hostname of the database server + var $user = ''; /// The username which is used to connect to the database server. var $password = ''; /// Password for the username. For security, we no longer store it. var $debug = false; /// if set to true will output sql statements var $maxblobsize = 256000; /// maximum size of blobs or large text fields -- some databases die otherwise like foxpro - var $concat_operator = '+'; /// default concat operator -- change to || for Oracle/Interbase + var $concat_operator = '+'; /// default concat operator -- change to || for Oracle/Interbase var $substr = 'substr'; /// substring operator var $length = 'length'; /// string length operator var $random = 'rand()'; /// random function @@ -250,9 +250,9 @@ var $sysDate = false; /// name of function that returns the current date var $sysTimeStamp = false; /// name of function that returns the current timestamp var $arrayClass = 'ADORecordSet_array'; /// name of class used to generate array recordsets, which are pre-downloaded recordsets - + var $noNullStrings = false; /// oracle specific stuff - if true ensures that '' is converted to ' ' - var $numCacheHits = 0; + var $numCacheHits = 0; var $numCacheMisses = 0; var $pageExecuteCountRows = true; var $uniqueSort = false; /// indicates that all fields in order by must be unique @@ -261,61 +261,61 @@ var $ansiOuter = false; /// whether ansi outer join syntax supported var $autoRollback = false; // autoRollback on PConnect(). var $poorAffectedRows = false; // affectedRows not working or unreliable - + var $fnExecute = false; var $fnCacheExecute = false; var $blobEncodeType = false; // false=not required, 'I'=encode to integer, 'C'=encode to char var $rsPrefix = "ADORecordSet_"; - + var $autoCommit = true; /// do not modify this yourself - actually private var $transOff = 0; /// temporarily disable transactions var $transCnt = 0; /// count of nested transactions - + var $fetchMode=false; // // PRIVATE VARS // var $_oldRaiseFn = false; var $_transOK = null; - var $_connectionID = false; /// The returned link identifier whenever a successful database connection is made. + var $_connectionID = false; /// The returned link identifier whenever a successful database connection is made. var $_errorMsg = false; /// A variable which was used to keep the returned last error message. The value will - /// then returned by the errorMsg() function - var $_errorCode = false; /// Last error code, not guaranteed to be used - only by oci8 + /// then returned by the errorMsg() function + var $_errorCode = false; /// Last error code, not guaranteed to be used - only by oci8 var $_queryID = false; /// This variable keeps the last created result link identifier - + var $_isPersistentConnection = false; /// A boolean variable to state whether its a persistent connection or normal connection. */ var $_bindInputArray = false; /// set to true if ADOConnection.Execute() permits binding of array parameters. var $_evalAll = false; var $_affected = false; var $_logsql = false; - - + + /** * Constructor */ - function ADOConnection() + function ADOConnection() { die('Virtual Class -- cannot instantiate'); } - + /** Get server version info... - - @returns An array with 2 elements: $arr['string'] is the description string, + + @returns An array with 2 elements: $arr['string'] is the description string, and $arr[version] is the version (also a string). */ function ServerInfo() { return array('description' => '', 'version' => ''); } - + function _findvers($str) { if (preg_match('/([0-9]+\.([0-9\.])+)/',$str, $arr)) return $arr[1]; else return ''; } - + /** * All error messages go through this bottleneck function. * You can define your own handler by defining the function name in ADODB_OUTP. @@ -323,7 +323,7 @@ function outp($msg,$newline=true) { global $HTTP_SERVER_VARS,$ADODB_FLUSH,$ADODB_OUTP; - + if (defined('ADODB_OUTP')) { $fn = ADODB_OUTP; $fn($msg,$newline); @@ -333,23 +333,23 @@ $fn($msg,$newline); return; } - + if ($newline) $msg .= "
\n"; - + if (isset($HTTP_SERVER_VARS['HTTP_USER_AGENT'])) echo $msg; else echo strip_tags($msg); - if (!empty($ADODB_FLUSH) && ob_get_length() !== false) flush(); // dp not flush if output buffering enabled - useless - thx to Jesse Mullan - + if (!empty($ADODB_FLUSH) && ob_get_length() !== false) flush(); // dp not flush if output buffering enabled - useless - thx to Jesse Mullan + } - + function Time() { $rs =& $this->Execute("select $this->sysTimeStamp"); if ($rs && !$rs->EOF) return $this->UnixTimeStamp(reset($rs->fields)); - + return false; } - + /** * Connect to database * @@ -360,15 +360,15 @@ * @param [forceNew] force new connection * * @return true or false - */ - function Connect($argHostname = "", $argUsername = "", $argPassword = "", $argDatabaseName = "", $forceNew = false) + */ + function Connect($argHostname = "", $argUsername = "", $argPassword = "", $argDatabaseName = "", $forceNew = false) { if ($argHostname != "") $this->host = $argHostname; if ($argUsername != "") $this->user = $argUsername; if ($argPassword != "") $this->password = $argPassword; // not stored for security reasons - if ($argDatabaseName != "") $this->database = $argDatabaseName; - - $this->_isPersistentConnection = false; + if ($argDatabaseName != "") $this->database = $argDatabaseName; + + $this->_isPersistentConnection = false; if ($fn = $this->raiseErrorFn) { if ($forceNew) { if ($this->_nconnect($this->host, $this->user, $this->password, $this->database)) return true; @@ -387,14 +387,14 @@ } if ($this->debug) ADOConnection::outp( $this->host.': '.$this->ErrorMsg()); return false; - } - + } + function _nconnect($argHostname, $argUsername, $argPassword, $argDatabaseName) { return $this->_connect($argHostname, $argUsername, $argPassword, $argDatabaseName); } - - + + /** * Always force a new connection to database - currently only works with oracle * @@ -404,12 +404,12 @@ * @param [argDatabaseName] database * * @return true or false - */ - function NConnect($argHostname = "", $argUsername = "", $argPassword = "", $argDatabaseName = "") + */ + function NConnect($argHostname = "", $argUsername = "", $argPassword = "", $argDatabaseName = "") { return $this->Connect($argHostname, $argUsername, $argPassword, $argDatabaseName, true); } - + /** * Establish persistent connect to database * @@ -419,25 +419,25 @@ * @param [argDatabaseName] database * * @return return true or false - */ + */ function PConnect($argHostname = "", $argUsername = "", $argPassword = "", $argDatabaseName = "") { - if (defined('ADODB_NEVER_PERSIST')) + if (defined('ADODB_NEVER_PERSIST')) return $this->Connect($argHostname,$argUsername,$argPassword,$argDatabaseName); - + if ($argHostname != "") $this->host = $argHostname; if ($argUsername != "") $this->user = $argUsername; if ($argPassword != "") $this->password = $argPassword; - if ($argDatabaseName != "") $this->database = $argDatabaseName; - - $this->_isPersistentConnection = true; - + if ($argDatabaseName != "") $this->database = $argDatabaseName; + + $this->_isPersistentConnection = true; + if ($fn = $this->raiseErrorFn) { if ($this->_pconnect($this->host, $this->user, $this->password, $this->database)) return true; $err = $this->ErrorMsg(); if (empty($err)) $err = "Connection error to server '$argHostname' with user '$argUsername'"; $fn($this->databaseType,'PCONNECT',$this->ErrorNo(),$err,$this->host,$this->database,$this); - } else + } else if ($this->_pconnect($this->host, $this->user, $this->password, $this->database)) return true; if ($this->debug) ADOConnection::outp( $this->host.': '.$this->ErrorMsg()); @@ -446,11 +446,11 @@ // Format date column in sql string given an input format that understands Y M D function SQLDate($fmt, $col=false) - { + { if (!$col) $col = $this->sysDate; return $col; // child class implement } - + /** * Should prepare the sql statement and return the stmt resource. * For databases that do not support this, we return the $sql. To ensure @@ -465,7 +465,7 @@ * @return return FALSE, or the prepared statement, or the original sql if * if the database does not support prepare. * - */ + */ function Prepare($sql) { return $sql; @@ -484,12 +484,12 @@ * @return return FALSE, or the prepared statement, or the original sql if * if the database does not support prepare. * - */ + */ function PrepareSP($sql,$param=true) { return $this->Prepare($sql,$param); } - + /** * PEAR DB Compat */ @@ -497,7 +497,7 @@ { return $this->qstr($s,false); } - + /** Requested by "Karsten Dambekalns" */ @@ -510,18 +510,18 @@ { $s = $this->qstr($s,false); } - + /** - * PEAR DB Compat - do not use internally. + * PEAR DB Compat - do not use internally. */ function ErrorNative() { return $this->ErrorNo(); } - + /** - * PEAR DB Compat - do not use internally. + * PEAR DB Compat - do not use internally. */ function nextId($seq_name) { @@ -539,19 +539,19 @@ { return false; } - + function CommitLock($table) { return $this->CommitTrans(); } - + function RollbackLock($table) { return $this->RollbackTrans(); } - + /** - * PEAR DB Compat - do not use internally. + * PEAR DB Compat - do not use internally. * * The fetch modes for NUMERIC and ASSOC for PEAR DB and ADODB are identical * for easy porting :-) @@ -560,20 +560,20 @@ * @returns The previous fetch mode */ function SetFetchMode($mode) - { + { $old = $this->fetchMode; $this->fetchMode = $mode; - + if ($old === false) { global $ADODB_FETCH_MODE; return $ADODB_FETCH_MODE; } return $old; } - + /** - * PEAR DB Compat - do not use internally. + * PEAR DB Compat - do not use internally. */ function &Query($sql, $inputarr=false) { @@ -582,18 +582,18 @@ return $rs; } - + /** * PEAR DB Compat - do not use internally */ function &LimitQuery($sql, $offset, $count, $params=false) { - $rs = &$this->SelectLimit($sql, $count, $offset, $params); + $rs = &$this->SelectLimit($sql, $count, $offset, $params); if (!$rs && defined('ADODB_PEAR')) return ADODB_PEAR_Error(); return $rs; } - + /** * PEAR DB Compat - do not use internally */ @@ -601,13 +601,13 @@ { return $this->Close(); } - + /* Returns placeholder for parameter, eg. $DB->Param('a') - + will return ':a' for Oracle, and '?' for most other databases... - + For databases that require positioned params, eg $1, $2, $3 for postgresql, pass in Param(false) before setting the first parameter. */ @@ -615,7 +615,7 @@ { return '?'; } - + /* InParameter and OutParameter are self-documenting versions of Parameter(). */ @@ -623,22 +623,22 @@ { return $this->Parameter($stmt,$var,$name,false,$maxLen,$type); } - + /* */ function OutParameter(&$stmt,&$var,$name,$maxLen=4000,$type=false) { return $this->Parameter($stmt,$var,$name,true,$maxLen,$type); - + } - - /* + + /* Usage in oracle $stmt = $db->Prepare('select * from table where id =:myid and group=:group'); $db->Parameter($stmt,$id,'myid'); $db->Parameter($stmt,$group,'group',64); $db->Execute(); - + @param $stmt Statement returned by Prepare() or PrepareSP(). @param $var PHP variable to bind to @param $name Name of stored procedure variable name to bind to. @@ -651,11 +651,11 @@ { return false; } - + /** Improved method of initiating a transaction. Used together with CompleteTrans(). Advantages include: - + a. StartTrans/CompleteTrans is nestable, unlike BeginTrans/CommitTrans/RollbackTrans. Only the outermost block is treated as a transaction.
b. CompleteTrans auto-detects SQL errors, and will rollback on errors, commit otherwise.
@@ -668,21 +668,21 @@ $this->transOff += 1; return; } - + $this->_oldRaiseFn = $this->raiseErrorFn; $this->raiseErrorFn = $errfn; $this->_transOK = true; - + if ($this->debug && $this->transCnt > 0) ADOConnection::outp("Bad Transaction: StartTrans called within BeginTrans"); $this->BeginTrans(); $this->transOff = 1; } - + /** Used together with StartTrans() to end a transaction. Monitors connection for sql errors, and will commit or rollback as appropriate. - - @autoComplete if true, monitor sql errors and commit and rollback as appropriate, + + @autoComplete if true, monitor sql errors and commit and rollback as appropriate, and if set to false force rollback even if no SQL error detected. @returns true on commit, false on rollback. */ @@ -693,7 +693,7 @@ return true; } $this->raiseErrorFn = $this->_oldRaiseFn; - + $this->transOff = 0; if ($this->_transOK && $autoComplete) { if (!$this->CommitTrans()) { @@ -705,16 +705,16 @@ $this->RollbackTrans(); if ($this->debug) ADOCOnnection::outp("Smart Rollback occurred"); } - + return $this->_transOK; } - + /* At the end of a StartTrans/CompleteTrans block, perform a rollback. */ function FailTrans() { - if ($this->debug) + if ($this->debug) if ($this->transOff == 0) { ADOConnection::outp("FailTrans outside StartTrans/CompleteTrans"); } else { @@ -723,7 +723,7 @@ } $this->_transOK = false; } - + /** Check if transaction has failed, only for Smart Transactions. */ @@ -732,15 +732,15 @@ if ($this->transOff > 0) return $this->_transOK == false; return false; } - + /** - * Execute SQL + * Execute SQL * * @param sql SQL statement to execute, or possibly an array holding prepared statement ($sql[0] will hold sql text) * @param [inputarr] holds the input data to bind to. Null elements will be set to null. * @return RecordSet or false */ - function &Execute($sql,$inputarr=false) + function &Execute($sql,$inputarr=false) { if ($this->fnExecute) { $fn = $this->fnExecute; @@ -751,17 +751,17 @@ $element0 = reset($inputarr); # is_object check is because oci8 descriptors can be passed in $array_2d = is_array($element0) && !is_object(reset($element0)); - + if (!is_array($sql) && !$this->_bindInputArray) { $sqlarr = explode('?',$sql); - + if (!$array_2d) $inputarr = array($inputarr); foreach($inputarr as $arr) { $sql = ''; $i = 0; foreach($arr as $v) { $sql .= $sqlarr[$i]; // from Ron Baldwin - // Only quote string types + // Only quote string types if (gettype($v) == 'string') $sql .= $this->qstr($v); else if ($v === null) @@ -771,13 +771,13 @@ $i += 1; } $sql .= $sqlarr[$i]; - - if ($i+1 != sizeof($sqlarr)) + + if ($i+1 != sizeof($sqlarr)) ADOConnection::outp( "Input Array does not match ?: ".htmlspecialchars($sql)); - + $ret =& $this->_Execute($sql,false); if (!$ret) return $ret; - } + } } else { if ($array_2d) { $stmt = $this->Prepare($sql); @@ -794,13 +794,13 @@ return $ret; } - + function& _Execute($sql,$inputarr=false) { if ($this->debug) { global $HTTP_SERVER_VARS; - + $ss = ''; if ($inputarr) { foreach($inputarr as $kk=>$vv) { @@ -810,61 +810,61 @@ $ss = "[ $ss ]"; } $sqlTxt = str_replace(',',', ',is_array($sql) ?$sql[0] : $sql); - + // check if running from browser or command-line $inBrowser = isset($HTTP_SERVER_VARS['HTTP_USER_AGENT']); - + if ($inBrowser) { if ($this->debug === -1) ADOConnection::outp( "
\n($this->databaseType): ".htmlspecialchars($sqlTxt)."   $ss\n
\n",false); - else + else ADOConnection::outp( "
\n($this->databaseType): ".htmlspecialchars($sqlTxt)."   $ss\n
\n",false); } else { ADOConnection::outp("-----\n($this->databaseType): ".($sqlTxt)." \n-----\n",false); } $this->_queryID = $this->_query($sql,$inputarr); - /* + /* Alexios Fakios notes that ErrorMsg() must be called before ErrorNo() for mssql because ErrorNo() calls Execute('SELECT @ERROR'), causing recursion */ - if ($this->databaseType == 'mssql') { + if ($this->databaseType == 'mssql') { // ErrorNo is a slow function call in mssql, and not reliable in PHP 4.0.6 if($emsg = $this->ErrorMsg()) { if ($err = $this->ErrorNo()) ADOConnection::outp($err.': '.$emsg); } } else if (!$this->_queryID) { ADOConnection::outp($this->ErrorNo() .': '. $this->ErrorMsg()); - } + } } else { //**************************** // non-debug version of query //**************************** - + $this->_queryID =@$this->_query($sql,$inputarr); } - + /************************ // OK, query executed *************************/ if ($this->_queryID === false) { // error handling if query fails - if ($this->debug == 99) adodb_backtrace(true,5); + if ($this->debug == 99) adodb_backtrace(true,5); $fn = $this->raiseErrorFn; if ($fn) { $fn($this->databaseType,'EXECUTE',$this->ErrorNo(),$this->ErrorMsg(),$sql,$inputarr,$this); - } - - return false; - } - + } + return false; + } + + if ($this->_queryID === true) { // return simplified empty recordset for inserts/updates/deletes with lower overhead $rs =& new ADORecordSet_empty(); return $rs; } - + // return real recordset from select statement $rsclass = $this->rsPrefix.$this->databaseType; $rs =& new $rsclass($this->_queryID,$this->fetchMode); @@ -874,9 +874,9 @@ else $rs->sql = $sql; if ($rs->_numOfRows <= 0) { global $ADODB_COUNTRECS; - + if ($ADODB_COUNTRECS) { - if (!$rs->EOF){ + if (!$rs->EOF){ $rs = &$this->_rs2rs($rs,-1,-1,!is_array($sql)); $rs->_queryID = $this->_queryID; } else @@ -911,9 +911,9 @@ if (!$this->hasGenID) { return 0; // formerly returns false pre 1.60 } - + $getnext = sprintf($this->_genIDSQL,$seqname); - + $holdtransOK = $this->_transOK; $rs = @$this->Execute($getnext); if (!$rs) { @@ -923,15 +923,15 @@ } if ($rs && !$rs->EOF) $this->genID = reset($rs->fields); else $this->genID = 0; // false - + if ($rs) $rs->Close(); return $this->genID; - } + } /** * @return the last inserted ID. Not all databases support this. - */ + */ function Insert_ID() { if ($this->_logsql && $this->lastInsID) return $this->lastInsID; @@ -949,8 +949,8 @@ * * @return the last inserted ID. All databases support this. But aware possible * problems in multiuser environments. Heavy test this before deploying. - */ - function PO_Insert_ID($table="", $id="") + */ + function PO_Insert_ID($table="", $id="") { if ($this->hasInsertID){ return $this->Insert_ID(); @@ -961,7 +961,7 @@ /** * @return # rows affected by UPDATE/DELETE - */ + */ function Affected_Rows() { if ($this->hasAffectedRows) { @@ -971,12 +971,12 @@ $val = $this->_affectedrows(); return ($val < 0) ? false : $val; } - + if ($this->debug) ADOConnection::outp( '

Affected_Rows error

',false); return false; } - - + + /** * @return the last error message */ @@ -984,29 +984,29 @@ { return '!! '.strtoupper($this->dataProvider.' '.$this->databaseType).': '.$this->_errorMsg; } - - + + /** * @return the last error number. Normally 0 means no error. */ - function ErrorNo() + function ErrorNo() { return ($this->_errorMsg) ? -1 : 0; } - + function MetaError($err=false) { include_once(ADODB_DIR."/adodb-error.inc.php"); if ($err === false) $err = $this->ErrorNo(); return adodb_error($this->dataProvider,$this->databaseType,$err); } - + function MetaErrorMsg($errno) { include_once(ADODB_DIR."/adodb-error.inc.php"); return adodb_errormsg($errno); } - + /** * @returns an array with the primary key columns in it. */ @@ -1026,7 +1026,7 @@ return ADODB_VIEW_PRIMARYKEYS($this->databaseType, $this->database, $table, $owner); return false; } - + /** * @returns assoc array where keys are tables, and values are foreign keys */ @@ -1040,16 +1040,16 @@ * @param dbName is the name of the database to select * @return true or false */ - function SelectDB($dbName) + function SelectDB($dbName) {return false;} - - + + /** - * Will select, getting rows from $offset (1-based), for $nrows. + * Will select, getting rows from $offset (1-based), for $nrows. * This simulates the MySQL "select * from table limit $offset,$nrows" , and * the PostgreSQL "select * from table limit $nrows offset $offset". Note that * MySQL and PostgreSQL parameter ordering is the opposite of the other. - * eg. + * eg. * SelectLimit('select * from table',3); will return rows 1 to 3 (1-based) * SelectLimit('select * from table',3,2); will return rows 3 to 5 (1-based) * @@ -1066,14 +1066,14 @@ function &SelectLimit($sql,$nrows=-1,$offset=-1, $inputarr=false,$secs2cache=0) { if ($this->hasTop && $nrows > 0) { - // suggested by Reinhard Balling. Access requires top after distinct + // suggested by Reinhard Balling. Access requires top after distinct // Informix requires first before distinct - F Riosa $ismssql = (strpos($this->databaseType,'mssql') !== false); if ($ismssql) $isaccess = false; else $isaccess = (strpos($this->databaseType,'access') !== false); - + if ($offset <= 0) { - + // access includes ties in result if ($isaccess) { $sql = preg_replace( @@ -1103,14 +1103,14 @@ } } } - + // if $offset>0, we want to skip rows, and $ADODB_COUNTRECS is set, we buffer rows // 0 to offset-1 which will be discarded anyway. So we disable $ADODB_COUNTRECS. global $ADODB_COUNTRECS; - + $savec = $ADODB_COUNTRECS; $ADODB_COUNTRECS = false; - + if ($offset>0){ if ($secs2cache>0) $rs = &$this->CacheExecute($secs2cache,$sql,$inputarr); else $rs = &$this->Execute($sql,$inputarr); @@ -1125,7 +1125,7 @@ //print_r($rs); return $rs; } - + /** * Create serializable recordset. Breaks rs link to connection. * @@ -1136,10 +1136,10 @@ $rs2 =& $this->_rs2rs($rs); $ignore = false; $rs2->connection =& $ignore; - + return $rs2; } - + /** * Convert database recordset to an array recordset * input recordset's cursor should be at beginning, and @@ -1153,7 +1153,7 @@ function &_rs2rs(&$rs,$nrows=-1,$offset=-1,$close=true) { if (! $rs) return false; - + $dbtype = $rs->databaseType; if (!$dbtype) { $rs = &$rs; // required to prevent crashing in 4.2.1, but does not happen in 4.3.1 -- why ? @@ -1171,9 +1171,9 @@ $arr =& $rs->GetArrayLimit($nrows,$offset); //print_r($arr); if ($close) $rs->Close(); - + $arrayClass = $this->arrayClass; - + $rs2 =& new $arrayClass(); $rs2->connection = &$this; $rs2->sql = $rs->sql; @@ -1181,7 +1181,7 @@ $rs2->InitArrayFields($arr,$flds); return $rs2; } - + /* * Return all rows. Compat with PEAR DB */ @@ -1190,16 +1190,16 @@ $arr =& $this->GetArray($sql,$inputarr); return $arr; } - + function &GetAssoc($sql, $inputarr=false,$force_array = false, $first2cols = false) { $rs =& $this->Execute($sql, $inputarr); if (!$rs) return false; - + $arr =& $rs->GetAssoc($force_array,$first2cols); return $arr; } - + function &CacheGetAssoc($secs2cache, $sql=false, $inputarr=false,$force_array = false, $first2cols = false) { if (!is_numeric($secs2cache)) { @@ -1208,11 +1208,11 @@ } $rs =& $this->CacheExecute($secs2cache, $sql, $inputarr); if (!$rs) return false; - + $arr =& $rs->GetAssoc($force_array,$first2cols); return $arr; } - + /** * Return first element of first row of sql statement. Recordset is disposed * for you. @@ -1225,29 +1225,29 @@ global $ADODB_COUNTRECS; $crecs = $ADODB_COUNTRECS; $ADODB_COUNTRECS = false; - + $ret = false; $rs = &$this->Execute($sql,$inputarr); - if ($rs) { + if ($rs) { if (!$rs->EOF) $ret = reset($rs->fields); $rs->Close(); - } + } $ADODB_COUNTRECS = $crecs; return $ret; } - + function CacheGetOne($secs2cache,$sql=false,$inputarr=false) { $ret = false; $rs = &$this->CacheExecute($secs2cache,$sql,$inputarr); - if ($rs) { + if ($rs) { if (!$rs->EOF) $ret = reset($rs->fields); $rs->Close(); - } - + } + return $ret; } - + function GetCol($sql, $inputarr = false, $trim = false) { $rv = false; @@ -1269,7 +1269,7 @@ } return $rv; } - + function CacheGetCol($secs, $sql = false, $inputarr = false,$trim=false) { $rv = false; @@ -1290,21 +1290,21 @@ } return $rv; } - + /* Calculate the offset of a date for a particular database and generate appropriate SQL. Useful for calculating future/past dates and storing in a database. - + If dayFraction=1.5 means 1.5 days from now, 1.0/24 for 1 hour. */ function OffsetDate($dayFraction,$date=false) - { + { if (!$date) $date = $this->sysDate; return '('.$date.'+'.$dayFraction.')'; } - - + + /** * * @param sql SQL statement @@ -1313,39 +1313,39 @@ function &GetArray($sql,$inputarr=false) { global $ADODB_COUNTRECS; - + $savec = $ADODB_COUNTRECS; $ADODB_COUNTRECS = false; $rs =& $this->Execute($sql,$inputarr); $ADODB_COUNTRECS = $savec; - if (!$rs) + if (!$rs) if (defined('ADODB_PEAR')) return ADODB_PEAR_Error(); else return false; $arr =& $rs->GetArray(); $rs->Close(); return $arr; } - + function &CacheGetAll($secs2cache,$sql=false,$inputarr=false) { global $ADODB_COUNTRECS; - + $savec = $ADODB_COUNTRECS; $ADODB_COUNTRECS = false; $rs =& $this->CacheExecute($secs2cache,$sql,$inputarr); $ADODB_COUNTRECS = $savec; - - if (!$rs) + + if (!$rs) if (defined('ADODB_PEAR')) return ADODB_PEAR_Error(); else return false; - + $arr =& $rs->GetArray(); $rs->Close(); return $arr; } - - - + + + /** * Return one row of sql statement. Recordset is disposed for you. * @@ -1357,9 +1357,9 @@ global $ADODB_COUNTRECS; $crecs = $ADODB_COUNTRECS; $ADODB_COUNTRECS = false; - + $rs =& $this->Execute($sql,$inputarr); - + $ADODB_COUNTRECS = $crecs; if ($rs) { if (!$rs->EOF) $arr = $rs->fields; @@ -1367,10 +1367,10 @@ $rs->Close(); return $arr; } - + return false; } - + function &CacheGetRow($secs2cache,$sql=false,$inputarr=false) { $rs =& $this->CacheExecute($secs2cache,$sql,$inputarr); @@ -1382,9 +1382,9 @@ } return false; } - + /** - * Insert or replace a single record. Note: this is not the same as MySQL's replace. + * Insert or replace a single record. Note: this is not the same as MySQL's replace. * ADOdb's Replace() uses update-insert semantics, not insert-delete-duplicates of MySQL. * Also note that no table locking is done currently, so it is possible that the * record be inserted twice by two programs... @@ -1400,24 +1400,24 @@ * * Currently blob replace not supported * - * returns 0 = fail, 1 = update, 2 = insert + * returns 0 = fail, 1 = update, 2 = insert */ - + function Replace($table, $fieldArray, $keyCol, $autoQuote=false, $has_autoinc=false) { global $ADODB_INCLUDED_LIB; if (empty($ADODB_INCLUDED_LIB)) include_once(ADODB_DIR.'/adodb-lib.inc.php'); - + return _adodb_replace($this, $table, $fieldArray, $keyCol, $autoQuote, $has_autoinc); } - - + + /** - * Will select, getting rows from $offset (1-based), for $nrows. + * Will select, getting rows from $offset (1-based), for $nrows. * This simulates the MySQL "select * from table limit $offset,$nrows" , and * the PostgreSQL "select * from table limit $nrows offset $offset". Note that * MySQL and PostgreSQL parameter ordering is the opposite of the other. - * eg. + * eg. * CacheSelectLimit(15,'select * from table',3); will return rows 1 to 3 (1-based) * CacheSelectLimit(15,'select * from table',3,2); will return rows 3 to 5 (1-based) * @@ -1431,7 +1431,7 @@ * @return the recordset ($rs->databaseType == 'array') */ function &CacheSelectLimit($secs2cache,$sql,$nrows=-1,$offset=-1,$inputarr=false) - { + { if (!is_numeric($secs2cache)) { if ($sql === false) $sql = -1; if ($offset == -1) $offset = false; @@ -1443,20 +1443,20 @@ } return $rs; } - + /** - * Flush cached recordsets that match a particular $sql statement. + * Flush cached recordsets that match a particular $sql statement. * If $sql == false, then we purge all files in the cache. */ function CacheFlush($sql=false,$inputarr=false) { global $ADODB_CACHE_DIR; - + if (strlen($ADODB_CACHE_DIR) > 1 && !$sql) { if (strncmp(PHP_OS,'WIN',3) === 0) { $cmd = 'del /s '.str_replace('/','\\',$ADODB_CACHE_DIR).'\adodb_*.cache'; } else { - $cmd = 'rm -rf '.$ADODB_CACHE_DIR.'/??/adodb_*.cache'; + $cmd = 'rm -rf '.$ADODB_CACHE_DIR.'/??/adodb_*.cache'; // old version 'rm -f `find '.$ADODB_CACHE_DIR.' -name adodb_*.cache`'; } if ($this->debug) { @@ -1465,14 +1465,14 @@ exec($cmd); } return; - } + } $f = $this->_gencachename($sql.serialize($inputarr),false); adodb_write_file($f,''); // is adodb_write_file needed? if (!@unlink($f)) { if ($this->debug) ADOConnection::outp( "CacheFlush: failed for $f"); } } - + /** * Private function to generate filename for caching. * Filename is generated based on: @@ -1482,30 +1482,30 @@ * - database name * - userid * - * We create 256 sub-directories in the cache directory ($ADODB_CACHE_DIR). - * Assuming that we can have 50,000 files per directory with good performance, + * We create 256 sub-directories in the cache directory ($ADODB_CACHE_DIR). + * Assuming that we can have 50,000 files per directory with good performance, * then we can scale to 12.8 million unique cached recordsets. Wow! */ function _gencachename($sql,$createdir) { global $ADODB_CACHE_DIR; - + $m = md5($sql.$this->databaseType.$this->database.$this->user); $dir = $ADODB_CACHE_DIR.'/'.substr($m,0,2); if ($createdir && !file_exists($dir)) { $oldu = umask(0); - if (!mkdir($dir,0771)) + if (!mkdir($dir,0771)) if ($this->debug) ADOConnection::outp( "Unable to mkdir $dir for $sql"); umask($oldu); } return $dir.'/adodb_'.$m.'.cache'; } - - + + /** * Execute SQL, caching recordsets. * - * @param [secs2cache] seconds to cache data, set to 0 to force query. + * @param [secs2cache] seconds to cache data, set to 0 to force query. * This is an optional parameter. * @param sql SQL statement to execute * @param [inputarr] holds the input data to bind to @@ -1520,12 +1520,12 @@ } global $ADODB_INCLUDED_CSV; if (empty($ADODB_INCLUDED_CSV)) include_once(ADODB_DIR.'/adodb-csvlib.inc.php'); - + if (is_array($sql)) $sql = $sql[0]; - + $md5file = $this->_gencachename($sql.serialize($inputarr),true); $err = ''; - + if ($secs2cache > 0){ $rs = &csv2rs($md5file,$err,$secs2cache); $this->numCacheHits += 1; @@ -1547,7 +1547,7 @@ $eof = $rs->EOF; $rs = &$this->_rs2rs($rs); // read entire recordset into memory immediately $txt = _rs2serialize($rs,false,$sql); // serialize - + if (!adodb_write_file($md5file,$txt,$this->debug)) { if ($fn = $this->raiseErrorFn) { $fn($this->databaseType,'CacheExecute',-32000,"Cache write error",$md5file,$sql,$this); @@ -1556,44 +1556,44 @@ } if ($rs->EOF && !$eof) { $rs->MoveFirst(); - //$rs = &csv2rs($md5file,$err); + //$rs = &csv2rs($md5file,$err); $rs->connection = &$this; // Pablo suggestion - } - + } + } else @unlink($md5file); } else { $this->_errorMsg = ''; $this->_errorCode = 0; - + if ($this->fnCacheExecute) { $fn = $this->fnCacheExecute; $fn($this, $secs2cache, $sql, $inputarr); } // ok, set cached object found $rs->connection = &$this; // Pablo suggestion - if ($this->debug){ + if ($this->debug){ global $HTTP_SERVER_VARS; - + $inBrowser = isset($HTTP_SERVER_VARS['HTTP_USER_AGENT']); $ttl = $rs->timeCreated + $secs2cache - time(); $s = is_array($sql) ? $sql[0] : $sql; if ($inBrowser) $s = ''.htmlspecialchars($s).''; - + ADOConnection::outp( " $md5file reloaded, ttl=$ttl [ $s ]"); } } return $rs; } - - + + /** * Generates an Update Query based on an existing recordset. * $arrFields is an associative array of fields with the value * that should be assigned. * * Note: This function should only be used on a recordset - * that is run against a single table and sql should only + * that is run against a single table and sql should only * be a simple select stmt with no groupby/orderby/limit * * "Jonathan Younger" @@ -1615,22 +1615,22 @@ * that is run against a single table. */ function GetInsertSQL(&$rs, $arrFields,$magicq=false) - { + { global $ADODB_INCLUDED_LIB; if (empty($ADODB_INCLUDED_LIB)) include_once(ADODB_DIR.'/adodb-lib.inc.php'); return _adodb_getinsertsql($this,$rs,$arrFields,$magicq); } - + /** * Update a blob column, given a where clause. There are more sophisticated * blob handling functions that we could have implemented, but all require * a very complex API. Instead we have chosen something that is extremely - * simple to understand and use. + * simple to understand and use. * * Note: $blobtype supports 'BLOB' and 'CLOB', default is BLOB of course. * - * Usage to update a $blobvalue which has a primary key blob_id=1 into a + * Usage to update a $blobvalue which has a primary key blob_id=1 into a * field blobtable.blobcolumn: * * UpdateBlob('blobtable', 'blobcolumn', $blobvalue, 'blob_id=1'); @@ -1640,7 +1640,7 @@ * $conn->Execute('INSERT INTO blobtable (id, blobcol) VALUES (1, null)'); * $conn->UpdateBlob('blobtable','blobcol',$blob,'id=1'); */ - + function UpdateBlob($table,$column,$val,$where,$blobtype='BLOB') { return $this->Execute("UPDATE $table SET $column=? WHERE $where",array($val)) != false; @@ -1649,7 +1649,7 @@ /** * Usage: * UpdateBlob('TABLE', 'COLUMN', '/path/to/file', 'ID=1'); - * + * * $blobtype supports 'BLOB' and 'CLOB' * * $conn->Execute('INSERT INTO blobtable (id, blobcol) VALUES (1, null)'); @@ -1663,45 +1663,45 @@ fclose($fd); return $this->UpdateBlob($table,$column,$val,$where,$blobtype); } - + function BlobDecode($blob) { return $blob; } - + function BlobEncode($blob) { return $blob; } - + function SetCharSet($charset) { return false; } - - function IfNull( $field, $ifNull ) + + function IfNull( $field, $ifNull ) { return " CASE WHEN $field is null THEN $ifNull ELSE $field END "; } - + function LogSQL($enable=true) { include_once(ADODB_DIR.'/adodb-perf.inc.php'); - + if ($enable) $this->fnExecute = 'adodb_log_sql'; else $this->fnExecute = false; - - $old = $this->_logsql; + + $old = $this->_logsql; $this->_logsql = $enable; if ($enable && !$old) $this->_affected = false; return $old; } - + function GetCharSet() { return false; } - + /** * Usage: * UpdateClob('TABLE', 'COLUMN', $var, 'ID=1', 'CLOB'); @@ -1713,8 +1713,8 @@ { return $this->UpdateBlob($table,$column,$val,$where,'CLOB'); } - - + + /** * Change the SQL connection locale to a specified locale. * This is used to get the date formats written depending on the client locale. @@ -1729,22 +1729,22 @@ $this->fmtDate="Y-m-d"; $this->fmtTimeStamp = "Y-m-d H:i:s"; break; - + case 'Fr': case 'Ro': case 'It': $this->fmtDate="d-m-Y"; $this->fmtTimeStamp = "d-m-Y H:i:s"; break; - + case 'Ge': $this->fmtDate="d.m.Y"; $this->fmtTimeStamp = "d.m.Y H:i:s"; break; } } - - + + /** * $meta contains the desired type, which could be... * C for character. You will have to define the precision yourself. @@ -1758,7 +1758,7 @@ * I for integer * R for autoincrement counter/integer * and if you want to use double-byte, add a 2 to the end, like C2 or X2. - * + * * * @return the actual type of the data or false if no such type available */ @@ -1769,41 +1769,41 @@ case 'X': return 'VARCHAR'; case 'B': - + case 'D': case 'T': case 'L': - + case 'R': - + case 'I': case 'N': return false; } } - + /** * Close Connection */ - function Close() + function Close() { return $this->_close(); - - // "Simon Lee" reports that persistent connections need + + // "Simon Lee" reports that persistent connections need // to be closed too! //if ($this->_isPersistentConnection != true) return $this->_close(); - //else return true; + //else return true; } - + /** * Begin a Transaction. Must be followed by CommitTrans() or RollbackTrans(). * * @return true if succeeded or false if database does not support transactions */ function BeginTrans() {return false;} - - + + /** * If database does not support transactions, always return true as data always commited * @@ -1811,47 +1811,47 @@ * * @return true/false. */ - function CommitTrans($ok=true) + function CommitTrans($ok=true) { return true;} - - + + /** * If database does not support transactions, rollbacks always fail, so return false * * @return true/false. */ - function RollbackTrans() + function RollbackTrans() { return false;} /** - * return the databases that the driver can connect to. + * return the databases that the driver can connect to. * Some databases will return an empty array. * * @return an array of database names. */ - function MetaDatabases() + function MetaDatabases() { global $ADODB_FETCH_MODE; - + if ($this->metaDatabasesSQL) { - $save = $ADODB_FETCH_MODE; - $ADODB_FETCH_MODE = ADODB_FETCH_NUM; - + $save = $ADODB_FETCH_MODE; + $ADODB_FETCH_MODE = ADODB_FETCH_NUM; + if ($this->fetchMode !== false) $savem = $this->SetFetchMode(false); - + $arr = $this->GetCol($this->metaDatabasesSQL); if (isset($savem)) $this->SetFetchMode($savem); - $ADODB_FETCH_MODE = $save; - + $ADODB_FETCH_MODE = $save; + return $arr; } - + return false; } - + /** - * @param ttype can either be 'VIEW' or 'TABLE' or false. + * @param ttype can either be 'VIEW' or 'TABLE' or false. * If false, both views and tables are returned. * "VIEW" returns only views * "TABLE" returns only tables @@ -1859,32 +1859,32 @@ * @param mask is the input mask - only supported by oci8 and postgresql * * @return array of tables for current database. - */ - function &MetaTables($ttype=false,$showSchema=false,$mask=false) + */ + function &MetaTables($ttype=false,$showSchema=false,$mask=false) { global $ADODB_FETCH_MODE; - + if ($mask) return false; - + if ($this->metaTablesSQL) { // complicated state saving by the need for backward compat - $save = $ADODB_FETCH_MODE; - $ADODB_FETCH_MODE = ADODB_FETCH_NUM; - + $save = $ADODB_FETCH_MODE; + $ADODB_FETCH_MODE = ADODB_FETCH_NUM; + if ($this->fetchMode !== false) $savem = $this->SetFetchMode(false); - + $rs = $this->Execute($this->metaTablesSQL); if (isset($savem)) $this->SetFetchMode($savem); - $ADODB_FETCH_MODE = $save; - + $ADODB_FETCH_MODE = $save; + if ($rs === false) return false; $arr =& $rs->GetArray(); $arr2 = array(); - - if ($hast = ($ttype && isset($arr[0][1]))) { + + if ($hast = ($ttype && isset($arr[0][1]))) { $showt = strncmp($ttype,'T',1); } - + for ($i=0; $i < sizeof($arr); $i++) { if ($hast) { if ($showt == 0) { @@ -1900,8 +1900,8 @@ } return false; } - - + + function _findschema(&$table,&$schema) { if (!$schema && ($at = strpos($table,'.')) !== false) { @@ -1909,9 +1909,9 @@ $table = substr($table,$at+1); } } - + /** - * List columns in a database as an array of ADOFieldObjects. + * List columns in a database as an array of ADOFieldObjects. * See top of file for definition of object. * * @param table table name to query @@ -1920,15 +1920,15 @@ * * @return array of ADOFieldObjects for current table. */ - function &MetaColumns($table,$upper=true) + function &MetaColumns($table,$upper=true) { global $ADODB_FETCH_MODE; - + if (!empty($this->metaColumnsSQL)) { - + $schema = false; $this->_findschema($table,$schema); - + $save = $ADODB_FETCH_MODE; $ADODB_FETCH_MODE = ADODB_FETCH_NUM; if ($this->fetchMode !== false) $savem = $this->SetFetchMode(false); @@ -1948,17 +1948,17 @@ if ($fld->scale>0) $fld->max_length += 1; } else $fld->max_length = $rs->fields[2]; - - if ($ADODB_FETCH_MODE == ADODB_FETCH_NUM) $retarr[] = $fld; + + if ($ADODB_FETCH_MODE == ADODB_FETCH_NUM) $retarr[] = $fld; else $retarr[$fld->name] = $fld; $rs->MoveNext(); } $rs->Close(); - return $retarr; + return $retarr; } return false; } - + /** * List indexes on a table as an array. * @param table table name to query @@ -1972,40 +1972,40 @@ } /** - * List columns names in a table as an array. + * List columns names in a table as an array. * @param table table name to query * * @return array of column names for current table. - */ - function &MetaColumnNames($table) + */ + function &MetaColumnNames($table) { $objarr =& $this->MetaColumns($table); if (!is_array($objarr)) return false; - + $arr = array(); foreach($objarr as $v) { $arr[strtoupper($v->name)] = $v->name; } return $arr; } - + /** * Different SQL databases used different methods to combine strings together. - * This function provides a wrapper. - * + * This function provides a wrapper. + * * param s variable number of string parameters * * Usage: $db->Concat($str1,$str2); - * + * * @return concatenated string - */ + */ function Concat() - { + { $arr = func_get_args(); return implode($this->concat_operator, $arr); } - - + + /** * Converts a date "d" to a string that the database can understand. * @@ -2025,8 +2025,8 @@ return adodb_date($this->fmtDate,$d); } - - + + /** * Converts a timestamp "ts" to a string that the database can understand. * @@ -2039,16 +2039,16 @@ if (empty($ts) && $ts !== 0) return 'null'; # strlen(14) allows YYYYMMDDHHMMSS format - if (!is_string($ts) || (is_numeric($ts) && strlen($ts)<14)) + if (!is_string($ts) || (is_numeric($ts) && strlen($ts)<14)) return adodb_date($this->fmtTimeStamp,$ts); - + if ($ts === 'null') return $ts; if ($this->isoDates && strlen($ts) !== 14) return "'$ts'"; - + $ts = ADOConnection::UnixTimeStamp($ts); return adodb_date($this->fmtTimeStamp,$ts); } - + /** * Also in ADORecordSet. * @param $v is a date string in YYYY-MM-DD format @@ -2057,14 +2057,14 @@ */ function UnixDate($v) { - if (!preg_match( "|^([0-9]{4})[-/\.]?([0-9]{1,2})[-/\.]?([0-9]{1,2})|", + if (!preg_match( "|^([0-9]{4})[-/\.]?([0-9]{1,2})[-/\.]?([0-9]{1,2})|", ($v), $rr)) return false; if ($rr[1] <= TIMESTAMP_FIRST_YEAR) return 0; // h-m-s-MM-DD-YY return @adodb_mktime(0,0,0,$rr[2],$rr[3],$rr[1]); } - + /** * Also in ADORecordSet. @@ -2074,17 +2074,17 @@ */ function UnixTimeStamp($v) { - if (!preg_match( - "|^([0-9]{4})[-/\.]?([0-9]{1,2})[-/\.]?([0-9]{1,2})[ ,-]*(([0-9]{1,2}):?([0-9]{1,2}):?([0-9\.]{1,4}))?|", + if (!preg_match( + "|^([0-9]{4})[-/\.]?([0-9]{1,2})[-/\.]?([0-9]{1,2})[ ,-]*(([0-9]{1,2}):?([0-9]{1,2}):?([0-9\.]{1,4}))?|", ($v), $rr)) return false; - - if ($rr[1] <= TIMESTAMP_FIRST_YEAR && $rr[2]<= 1) return 0; + if ($rr[1] <= TIMESTAMP_FIRST_YEAR && $rr[2]<= 1) return 0; + // h-m-s-MM-DD-YY if (!isset($rr[5])) return adodb_mktime(0,0,0,$rr[2],$rr[3],$rr[1]); return @adodb_mktime($rr[5],$rr[6],$rr[7],$rr[2],$rr[3],$rr[1]); } - + /** * Also in ADORecordSet. * @@ -2095,7 +2095,7 @@ * * @return a date formated as user desires */ - + function UserDate($v,$fmt='Y-m-d') { $tt = $this->UnixDate($v); @@ -2104,11 +2104,11 @@ else if ($tt == 0) return $this->emptyDate; else if ($tt == -1) { // pre-TIMESTAMP_FIRST_YEAR } - + return adodb_date($fmt,$tt); - + } - + /** * * @param v is the character timestamp in YYYY-MM-DD hh:mm:ss format @@ -2126,14 +2126,14 @@ if ($tt == 0) return $this->emptyTimeStamp; return adodb_date($fmt,$tt); } - + /** - * Quotes a string, without prefixing nor appending quotes. + * Quotes a string, without prefixing nor appending quotes. */ function addq($s, $magicq=false) { if (!$magicq) { - + if ($this->replaceQuote[0] == '\\'){ // only since php 4.0.5 $s = adodb_str_replace(array('\\',"\0"),array('\\\\',"\\\0"),$s); @@ -2141,10 +2141,10 @@ } return str_replace("'",$this->replaceQuote,$s); } - + // undo magic quotes for " $s = str_replace('\\"','"',$s); - + if ($this->replaceQuote == "\\'") // ' already quoted, no need to change anything return $s; else {// change \' to '' for sybase/mssql @@ -2152,12 +2152,12 @@ return str_replace("\\'",$this->replaceQuote,$s); } } - + /** * Correctly quotes a string so that all strings are escaped. We prefix and append * to the string single-quotes. * An example is $db->qstr("Don't bother",magic_quotes_runtime()); - * + * * @param s the string to quote * @param [magic_quotes] if $s is GET/POST var, set to get_magic_quotes_gpc(). * This undoes the stupidity of magic quotes for GPC. @@ -2165,9 +2165,9 @@ * @return quoted string to be sent back to database */ function qstr($s,$magic_quotes=false) - { + { if (!$magic_quotes) { - + if ($this->replaceQuote[0] == '\\'){ // only since php 4.0.5 $s = adodb_str_replace(array('\\',"\0"),array('\\\\',"\\\0"),$s); @@ -2175,10 +2175,10 @@ } return "'".str_replace("'",$this->replaceQuote,$s)."'"; } - + // undo magic quotes for " $s = str_replace('\\"','"',$s); - + if ($this->replaceQuote == "\\'") // ' already quoted, no need to change anything return "'$s'"; else {// change \' to '' for sybase/mssql @@ -2186,11 +2186,11 @@ return "'".str_replace("\\'",$this->replaceQuote,$s)."'"; } } - - + + /** - * Will select the supplied $page number from a recordset, given that it is paginated in pages of - * $nrows rows per page. It also saves two boolean values saying if the given page is the first + * Will select the supplied $page number from a recordset, given that it is paginated in pages of + * $nrows rows per page. It also saves two boolean values saying if the given page is the first * and/or last one of the recordset. Added by Iván Oliva to provide recordset pagination. * * See readme.htm#ex8 for an example of usage. @@ -2205,7 +2205,7 @@ * NOTE: phpLens uses a different algorithm and does not use PageExecute(). * */ - function &PageExecute($sql, $nrows, $page, $inputarr=false, $secs2cache=0) + function &PageExecute($sql, $nrows, $page, $inputarr=false, $secs2cache=0) { global $ADODB_INCLUDED_LIB; if (empty($ADODB_INCLUDED_LIB)) include_once(ADODB_DIR.'/adodb-lib.inc.php'); @@ -2213,11 +2213,11 @@ return _adodb_pageexecute_no_last_page($this, $sql, $nrows, $page, $inputarr, $secs2cache); } - - + + /** - * Will select the supplied $page number from a recordset, given that it is paginated in pages of - * $nrows rows per page. It also saves two boolean values saying if the given page is the first + * Will select the supplied $page number from a recordset, given that it is paginated in pages of + * $nrows rows per page. It also saves two boolean values saying if the given page is the first * and/or last one of the recordset. Added by Iván Oliva to provide recordset pagination. * * @param secs2cache seconds to cache data, set to 0 to force query @@ -2227,11 +2227,11 @@ * @param [inputarr] array of bind variables * @return the recordset ($rs->databaseType == 'array') */ - function &CachePageExecute($secs2cache, $sql, $nrows, $page,$inputarr=false) + function &CachePageExecute($secs2cache, $sql, $nrows, $page,$inputarr=false) { /*switch($this->dataProvider) { case 'postgres': - case 'mysql': + case 'mysql': break; default: $secs2cache = 0; break; }*/ @@ -2240,23 +2240,23 @@ } } // end class ADOConnection - - - - //============================================================================================== + + + + //============================================================================================== // CLASS ADOFetchObj - //============================================================================================== - + //============================================================================================== + /** * Internal placeholder for record objects. Used by ADORecordSet->FetchObj(). */ class ADOFetchObj { }; - - //============================================================================================== + + //============================================================================================== // CLASS ADORecordSet_empty - //============================================================================================== - + //============================================================================================== + /** * Lightweight recordset when there are no records to be returned */ @@ -2275,15 +2275,15 @@ function FetchRow() {return false;} function FieldCount(){ return 0;} } - - //============================================================================================== + + //============================================================================================== // DATE AND TIME FUNCTIONS - //============================================================================================== + //============================================================================================== include_once(ADODB_DIR.'/adodb-time.inc.php'); - - //============================================================================================== + + //============================================================================================== // CLASS ADORecordSet - //============================================================================================== + //============================================================================================== if (PHP_VERSION < 5) include_once(ADODB_DIR.'/adodb-php4.inc.php'); else include_once(ADODB_DIR.'/adodb-iterator.inc.php'); @@ -2295,7 +2295,7 @@ */ class ADORecordSet extends ADODB_BASE_RS { /* - * public variables + * public variables */ var $dataProvider = "native"; var $fields = false; /// holds the current row data @@ -2303,8 +2303,8 @@ /// in other words, we use a text area for editing. var $canSeek = false; /// indicates that seek is supported var $sql; /// sql text - var $EOF = false; /// Indicates that the current record position is after the last record in a Recordset object. - + var $EOF = false; /// Indicates that the current record position is after the last record in a Recordset object. + var $emptyTimeStamp = ' '; /// what to display when $time==0 var $emptyDate = ' '; /// what to display when $time==0 var $debug = false; @@ -2314,7 +2314,7 @@ var $fetchMode; /// default fetch mode var $connection = false; /// the parent connection /* - * private variables + * private variables */ var $_numOfRows = -1; /** number of rows, or -1 */ var $_numOfFields = -1; /** number of fields in recordset */ @@ -2324,27 +2324,27 @@ var $_inited = false; /** Init() should only be called once */ var $_obj; /** Used by FetchObj */ var $_names; /** Used by FetchObj */ - + var $_currentPage = -1; /** Added by Iván Oliva to implement recordset pagination */ var $_atFirstPage = false; /** Added by Iván Oliva to implement recordset pagination */ var $_atLastPage = false; /** Added by Iván Oliva to implement recordset pagination */ - var $_lastPageNo = -1; + var $_lastPageNo = -1; var $_maxRecordCount = 0; var $datetime = false; - + /** * Constructor * * @param queryID this is the queryID returned by ADOConnection->_query() * */ - function ADORecordSet($queryID) + function ADORecordSet($queryID) { $this->_queryID = $queryID; } - - - + + + function Init() { if ($this->_inited) return; @@ -2355,7 +2355,7 @@ $this->_numOfFields = 0; } if ($this->_numOfRows != 0 && $this->_numOfFields && $this->_currentRow == -1) { - + $this->_currentRow = 0; if ($this->EOF = ($this->_fetch() === false)) { $this->_numOfRows = 0; // _numOfRows could be -1 @@ -2364,11 +2364,11 @@ $this->EOF = true; } } - - + + /** * Generate a SELECT tag string from a recordset, and return the string. - * If the recordset has 2 cols, we treat the 1st col as the containing + * If the recordset has 2 cols, we treat the 1st col as the containing * the text to display to the user, and 2nd col as the return value. Default * strings are compared with the FIRST column. * @@ -2379,7 +2379,7 @@ * @param [size] #rows to show for listbox. not used by popup * @param [selectAttr] additional attributes to defined for SELECT tag. * useful for holding javascript onChange='...' handlers. - & @param [compareFields0] when we have 2 cols in recordset, we compare the defstr with + & @param [compareFields0] when we have 2 cols in recordset, we compare the defstr with * column 0 (1st col) if this is true. This is not documented. * * @return HTML @@ -2394,15 +2394,15 @@ return _adodb_getmenu($this, $name,$defstr,$blank1stItem,$multiple, $size, $selectAttr,$compareFields0); } - + /** * Generate a SELECT tag string from a recordset, and return the string. - * If the recordset has 2 cols, we treat the 1st col as the containing + * If the recordset has 2 cols, we treat the 1st col as the containing * the text to display to the user, and 2nd col as the return value. Default * strings are compared with the SECOND column. * */ - function GetMenu2($name,$defstr='',$blank1stItem=true,$multiple=false,$size=0, $selectAttr='') + function GetMenu2($name,$defstr='',$blank1stItem=true,$multiple=false,$size=0, $selectAttr='') { global $ADODB_INCLUDED_LIB; if (empty($ADODB_INCLUDED_LIB)) include_once(ADODB_DIR.'/adodb-lib.inc.php'); @@ -2418,10 +2418,10 @@ * * @return an array indexed by the rows (0-based) from the recordset */ - function &GetArray($nRows = -1) + function &GetArray($nRows = -1) { global $ADODB_EXTENSION; if ($ADODB_EXTENSION) return adodb_getall($this,$nRows); - + $results = array(); $cnt = 0; while (!$this->EOF && $nRows != $cnt) { @@ -2431,13 +2431,13 @@ } return $results; } - + function &GetAll($nRows = -1) { $arr =& $this->GetArray($nRows); return $arr; } - + /* * Some databases allow multiple recordsets to be returned. This function * will return true if there is a next recordset, or false if no more. @@ -2446,9 +2446,9 @@ { return false; } - + /** - * return recordset as a 2-dimensional array. + * return recordset as a 2-dimensional array. * Helper function for ADOConnection->SelectLimit() * * @param offset is the row to start calculations from (1-based) @@ -2456,26 +2456,26 @@ * * @return an array indexed by the rows (0-based) from the recordset */ - function &GetArrayLimit($nrows,$offset=-1) - { + function &GetArrayLimit($nrows,$offset=-1) + { if ($offset <= 0) { $arr =& $this->GetArray($nrows); return $arr; - } - + } + $this->Move($offset); - + $results = array(); $cnt = 0; while (!$this->EOF && $nrows != $cnt) { $results[$cnt++] = $this->fields; $this->MoveNext(); } - + return $results; } - - + + /** * Synonym for GetArray() for compatibility with ADO. * @@ -2483,15 +2483,15 @@ * * @return an array indexed by the rows (0-based) from the recordset */ - function &GetRows($nRows = -1) + function &GetRows($nRows = -1) { $arr =& $this->GetArray($nRows); return $arr; } - + /** - * return whole recordset as a 2-dimensional associative array if there are more than 2 columns. - * The first column is treated as the key and is not included in the array. + * return whole recordset as a 2-dimensional associative array if there are more than 2 columns. + * The first column is treated as the key and is not included in the array. * If there is only 2 columns, it will return a 1 dimensional array of key-value pairs unless * $force_array == true. * @@ -2499,10 +2499,10 @@ * array is returned, otherwise a 2 dimensional array is returned. If this sounds confusing, * read the source. * - * @param [first2cols] means if there are more than 2 cols, ignore the remaining cols and + * @param [first2cols] means if there are more than 2 cols, ignore the remaining cols and * instead of returning array[col0] => array(remaining cols), return array[col0] => col1 * - * @return an associative array indexed by the first column of the array, + * @return an associative array indexed by the first column of the array, * or false if the data has less than 2 cols. */ function &GetAssoc($force_array = false, $first2cols = false) { @@ -2512,7 +2512,7 @@ } $numIndex = isset($this->fields[0]); $results = array(); - + if (!$first2cols && ($cols > 2 || $force_array)) { if ($numIndex) { while (!$this->EOF) { @@ -2537,16 +2537,16 @@ while (!$this->EOF) { // some bug in mssql PHP 4.02 -- doesn't handle references properly so we FORCE creating a new string $v1 = trim(reset($this->fields)); - $v2 = ''.next($this->fields); + $v2 = ''.next($this->fields); $results[$v1] = $v2; $this->MoveNext(); } } } - return $results; + return $results; } - - + + /** * * @param v is the character timestamp in YYYY-MM-DD hh:mm:ss format @@ -2563,8 +2563,8 @@ if ($tt === 0) return $this->emptyTimeStamp; return adodb_date($fmt,$tt); } - - + + /** * @param v is the character date in YYYY-MM-DD format, returned by database * @param fmt is the format to apply to it, using date() @@ -2580,10 +2580,10 @@ else if ($tt == -1) { // pre-TIMESTAMP_FIRST_YEAR } return adodb_date($fmt,$tt); - + } - - + + /** * @param $v is a date string in YYYY-MM-DD format * @@ -2591,15 +2591,15 @@ */ function UnixDate($v) { - - if (!preg_match( "|^([0-9]{4})[-/\.]?([0-9]{1,2})[-/\.]?([0-9]{1,2})|", + + if (!preg_match( "|^([0-9]{4})[-/\.]?([0-9]{1,2})[-/\.]?([0-9]{1,2})|", ($v), $rr)) return false; - + if ($rr[1] <= TIMESTAMP_FIRST_YEAR) return 0; // h-m-s-MM-DD-YY return @adodb_mktime(0,0,0,$rr[2],$rr[3],$rr[1]); } - + /** * @param $v is a timestamp string in YYYY-MM-DD HH-NN-SS format @@ -2608,18 +2608,18 @@ */ function UnixTimeStamp($v) { - - if (!preg_match( - "|^([0-9]{4})[-/\.]?([0-9]{1,2})[-/\.]?([0-9]{1,2})[ ,-]*(([0-9]{1,2}):?([0-9]{1,2}):?([0-9\.]{1,4}))?|", + + if (!preg_match( + "|^([0-9]{4})[-/\.]?([0-9]{1,2})[-/\.]?([0-9]{1,2})[ ,-]*(([0-9]{1,2}):?([0-9]{1,2}):?([0-9\.]{1,4}))?|", ($v), $rr)) return false; if ($rr[1] <= TIMESTAMP_FIRST_YEAR && $rr[2]<= 1) return 0; - + // h-m-s-MM-DD-YY if (!isset($rr[5])) return adodb_mktime(0,0,0,$rr[2],$rr[3],$rr[1]); return @adodb_mktime($rr[5],$rr[6],$rr[7],$rr[2],$rr[3],$rr[1]); } - - + + /** * PEAR DB Compat - do not use internally */ @@ -2627,8 +2627,8 @@ { return $this->Close(); } - - + + /** * PEAR DB compat, number of rows */ @@ -2636,8 +2636,8 @@ { return $this->_numOfRows; } - - + + /** * PEAR DB compat, number of cols */ @@ -2645,9 +2645,9 @@ { return $this->_numOfFields; } - + /** - * Fetch a row, returning false if no more rows. + * Fetch a row, returning false if no more rows. * This is PEAR DB compat mode. * * @return false or array containing the current record @@ -2660,10 +2660,10 @@ if (!$this->_fetch()) $this->EOF = true; return $arr; } - - + + /** - * Fetch a row, returning PEAR_Error if no more rows. + * Fetch a row, returning PEAR_Error if no more rows. * This is PEAR DB compat mode. * * @return DB_OK or error object @@ -2675,26 +2675,26 @@ $this->MoveNext(); return 1; // DB_OK } - - + + /** * Move to the first row in the recordset. Many databases do NOT support this. * * @return true or false */ - function MoveFirst() + function MoveFirst() { if ($this->_currentRow == 0) return true; - return $this->Move(0); - } + return $this->Move(0); + } + - /** - * Move to the last row in the recordset. + * Move to the last row in the recordset. * * @return true or false */ - function MoveLast() + function MoveLast() { if ($this->_numOfRows >= 0) return $this->Move($this->_numOfRows-1); if ($this->EOF) return false; @@ -2706,14 +2706,14 @@ $this->EOF = false; return true; } - - + + /** * Move to next record in the recordset. * * @return true if there still rows available, or false if there are no more rows (EOF). */ - function MoveNext() + function MoveNext() { if (!$this->EOF) { $this->_currentRow++; @@ -2728,8 +2728,8 @@ } */ return false; - } - + } + /** * Random access to a specific row in the recordset. Some databases do not support * access to previous rows in the databases (no scrolling backwards). @@ -2738,15 +2738,15 @@ * * @return true if there still rows available, or false if there are no more rows (EOF). */ - function Move($rowNumber = 0) + function Move($rowNumber = 0) { $this->EOF = false; if ($rowNumber == $this->_currentRow) return true; if ($rowNumber >= $this->_numOfRows) if ($this->_numOfRows != -1) $rowNumber = $this->_numOfRows-2; - - if ($this->canSeek) { - + + if ($this->canSeek) { + if ($this->_seek($rowNumber)) { $this->_currentRow = $rowNumber; if ($this->_fetch()) { @@ -2764,26 +2764,26 @@ adodb_movenext($this); } } else { - + while (! $this->EOF && $this->_currentRow < $rowNumber) { $this->_currentRow++; - + if (!$this->_fetch()) $this->EOF = true; } } return !($this->EOF); } - - $this->fields = false; + + $this->fields = false; $this->EOF = true; return false; } - - + + /** * Get the value of a field in the current row by column name. * Will not work if ADODB_FETCH_MODE is set to ADODB_FETCH_NUM. - * + * * @param colname is the field to access * * @return the value of $colname column @@ -2792,7 +2792,7 @@ { return $this->fields[$colname]; } - + function GetAssocKeys($upper=true) { $this->bind = array(); @@ -2802,7 +2802,7 @@ else $this->bind[($upper) ? strtoupper($o->name) : strtolower($o->name)] = $i; } } - + /** * Use associative array to get fields array for databases that do not support * associative arrays. Submitted by Paolo S. Asioli paolo.asioli@libero.it @@ -2816,44 +2816,44 @@ { $record = array(); // if (!$this->fields) return $record; - + if (!$this->bind) { $this->GetAssocKeys($upper); } - + foreach($this->bind as $k => $v) { $record[$k] = $this->fields[$v]; } return $record; } - - + + /** * Clean up recordset * * @return true or false */ - function Close() + function Close() { // free connection object - this seems to globally free the object // and not merely the reference, so don't do this... - // $this->connection = false; + // $this->connection = false; if (!$this->_closed) { $this->_closed = true; - return $this->_close(); + return $this->_close(); } else return true; } - + /** - * synonyms RecordCount and RowCount + * synonyms RecordCount and RowCount * * @return the number of rows or -1 if this is not supported */ function RecordCount() {return $this->_numOfRows;} - - + + /* * If we are using PageExecute(), this will return the maximum possible rows * that can be returned when paging a recordset. @@ -2862,14 +2862,14 @@ { return ($this->_maxRecordCount) ? $this->_maxRecordCount : $this->RecordCount(); } - + /** - * synonyms RecordCount and RowCount + * synonyms RecordCount and RowCount * * @return the number of rows or -1 if this is not supported */ - function RowCount() {return $this->_numOfRows;} - + function RowCount() {return $this->_numOfRows;} + /** * Portable RecordCount. Pablo Roca @@ -2878,38 +2878,38 @@ * * But aware possible problems in multiuser environments. For better speed the table * must be indexed by the condition. Heavy test this before deploying. - */ + */ function PO_RecordCount($table="", $condition="") { - + $lnumrows = $this->_numOfRows; // the database doesn't support native recordcount, so we do a workaround if ($lnumrows == -1 && $this->connection) { IF ($table) { - if ($condition) $condition = " WHERE " . $condition; + if ($condition) $condition = " WHERE " . $condition; $resultrows = &$this->connection->Execute("SELECT COUNT(*) FROM $table $condition"); if ($resultrows) $lnumrows = reset($resultrows->fields); } } return $lnumrows; } - + /** * @return the current row in the recordset. If at EOF, will return the last row. 0-based. */ function CurrentRow() {return $this->_currentRow;} - + /** * synonym for CurrentRow -- for ADO compat * * @return the current row in the recordset. If at EOF, will return the last row. 0-based. */ function AbsolutePosition() {return $this->_currentRow;} - + /** * @return the number of columns in the recordset. Some databases will set this to 0 * if no records are returned, others will return the number of columns in the query. */ - function FieldCount() {return $this->_numOfFields;} + function FieldCount() {return $this->_numOfFields;} /** @@ -2919,11 +2919,11 @@ * * @return the ADOFieldObject for that column, or false. */ - function &FetchField($fieldoffset) + function &FetchField($fieldoffset) { // must be defined by child class - } - + } + /** * Get the ADOFieldObjects of all columns in an array. * @@ -2931,11 +2931,11 @@ function FieldTypesArray() { $arr = array(); - for ($i=0, $max=$this->_numOfFields; $i < $max; $i++) + for ($i=0, $max=$this->_numOfFields; $i < $max; $i++) $arr[] = $this->FetchField($i); return $arr; } - + /** * Return the fields array of the current row as an object for convenience. * The default case is lowercase field names. @@ -2947,11 +2947,11 @@ $o =& $this->FetchObject(false); return $o; } - + /** * Return the fields array of the current row as an object for convenience. * The default case is uppercase. - * + * * @param $isupper to set the object property names to uppercase * * @return the object with the properties set to the fields of the current row @@ -2972,16 +2972,16 @@ $name = $this->_names[$i]; if ($isupper) $n = strtoupper($name); else $n = $name; - + $o->$n = $this->Fields($name); } return $o; } - + /** * Return the fields array of the current row as an object for convenience. * The default is lower-case field names. - * + * * @return the object with the properties set to the fields of the current row, * or false if EOF * @@ -2991,12 +2991,12 @@ { return $this->FetchNextObject(false); } - - + + /** - * Return the fields array of the current row as an object for convenience. + * Return the fields array of the current row as an object for convenience. * The default is upper case field names. - * + * * @param $isupper to set the object property names to uppercase * * @return the object with the properties set to the fields of the current row, @@ -3008,14 +3008,14 @@ { $o = false; if ($this->_numOfRows != 0 && !$this->EOF) { - $o = $this->FetchObject($isupper); + $o = $this->FetchObject($isupper); $this->_currentRow++; if ($this->_fetch()) return $o; } $this->EOF = true; return $o; } - + /** * Get the metatype of the column. This is used for formatting. This is because * many databases use different names for the same type, so we transform the original @@ -3026,8 +3026,8 @@ * fields bigger than a certain size as a 'B' (blob). * @param fieldobj is the field object returned by the database driver. Can hold * additional info (eg. primary_key for mysql). - * - * @return the general type of the data: + * + * @return the general type of the data: * C for character < 200 chars * X for teXt (>= 200 chars) * B for Binary @@ -3037,7 +3037,7 @@ * L for logical/Boolean * I for integer * R for autoincrement counter/integer - * + * * */ function MetaType($t,$len=-1,$fieldobj=false) @@ -3088,7 +3088,7 @@ 'T' => 'T', ## 'BOOL' => 'L', - 'BOOLEAN' => 'L', + 'BOOLEAN' => 'L', 'BIT' => 'L', 'L' => 'L', ## @@ -3118,62 +3118,62 @@ 'NUM' => 'N', 'NUMERIC' => 'N', 'MONEY' => 'N', - + ## informix 9.2 - 'SQLINT' => 'I', - 'SQLSERIAL' => 'I', - 'SQLSMINT' => 'I', - 'SQLSMFLOAT' => 'N', - 'SQLFLOAT' => 'N', - 'SQLMONEY' => 'N', - 'SQLDECIMAL' => 'N', - 'SQLDATE' => 'D', - 'SQLVCHAR' => 'C', - 'SQLCHAR' => 'C', - 'SQLDTIME' => 'T', - 'SQLINTERVAL' => 'N', - 'SQLBYTES' => 'B', - 'SQLTEXT' => 'X' + 'SQLINT' => 'I', + 'SQLSERIAL' => 'I', + 'SQLSMINT' => 'I', + 'SQLSMFLOAT' => 'N', + 'SQLFLOAT' => 'N', + 'SQLMONEY' => 'N', + 'SQLDECIMAL' => 'N', + 'SQLDATE' => 'D', + 'SQLVCHAR' => 'C', + 'SQLCHAR' => 'C', + 'SQLDTIME' => 'T', + 'SQLINTERVAL' => 'N', + 'SQLBYTES' => 'B', + 'SQLTEXT' => 'X' ); - + $tmap = false; $t = strtoupper($t); $tmap = @$typeMap[$t]; switch ($tmap) { case 'C': - - // is the char field is too long, return as text field... + + // is the char field is too long, return as text field... if ($this->blobSize >= 0) { if ($len > $this->blobSize) return 'X'; } else if ($len > 250) { return 'X'; } return 'C'; - + case 'I': if (!empty($fieldobj->primary_key)) return 'R'; return 'I'; - + case false: return 'N'; - + case 'B': - if (isset($fieldobj->binary)) + if (isset($fieldobj->binary)) return ($fieldobj->binary) ? 'B' : 'X'; return 'B'; - + case 'D': if (!empty($this->datetime)) return 'T'; return 'D'; - - default: + + default: if ($t == 'LONG' && $this->dataProvider == 'oci8') return 'B'; return $tmap; } } - + function _close() {} - + /** * set/returns the current recordset page when paginating */ @@ -3182,7 +3182,7 @@ if ($page != -1) $this->_currentPage = $page; return $this->_currentPage; } - + /** * set/returns the status of the atFirstPage flag when paginating */ @@ -3191,13 +3191,13 @@ if ($status != false) $this->_atFirstPage = $status; return $this->_atFirstPage; } - + function LastPageNo($page = false) { if ($page != false) $this->_lastPageNo = $page; return $this->_lastPageNo; } - + /** * set/returns the status of the atLastPage flag when paginating */ @@ -3206,20 +3206,20 @@ if ($status != false) $this->_atLastPage = $status; return $this->_atLastPage; } - + } // end class ADORecordSet - - //============================================================================================== + + //============================================================================================== // CLASS ADORecordSet_array - //============================================================================================== - + //============================================================================================== + /** * This class encapsulates the concept of a recordset created in memory * as an array. This is useful for the creation of cached recordsets. - * + * * Note that the constructor is different from the standard ADORecordSet */ - + class ADORecordSet_array extends ADORecordSet { var $databaseType = 'array'; @@ -3241,21 +3241,21 @@ function ADORecordSet_array($fakeid=1) { global $ADODB_FETCH_MODE,$ADODB_COMPAT_FETCH; - + // fetch() on EOF does not delete $this->fields $this->compat = !empty($ADODB_COMPAT_FETCH); - $this->ADORecordSet($fakeid); // fake queryID + $this->ADORecordSet($fakeid); // fake queryID $this->fetchMode = $ADODB_FETCH_MODE; } - - + + /** * Setup the array. * * @param array is a 2-dimensional array holding the data. - * The first row should hold the column names + * The first row should hold the column names * unless paramter $colnames is used. - * @param typearr holds an array of types. These are the same types + * @param typearr holds an array of types. These are the same types * used in MetaTypes (C,B,L,I,N). * @param [colnames] array of column names. If set, then the first row of * $array should not hold the column names. @@ -3263,7 +3263,7 @@ function InitArray($array,$typearr,$colnames=false) { $this->_array = $array; - $this->_types = $typearr; + $this->_types = $typearr; if ($colnames) { $this->_skiprow1 = false; $this->_colnames = $colnames; @@ -3277,7 +3277,7 @@ * Setup the Array and datatype file objects * * @param array is a 2-dimensional array holding the data. - * The first row should hold the column names + * The first row should hold the column names * unless paramter $colnames is used. * @param fieldarr holds an array of ADOFieldObject's. */ @@ -3287,10 +3287,10 @@ $this->_skiprow1= false; if ($fieldarr) { $this->_fieldobjects =& $fieldarr; - } + } $this->Init(); } - + function &GetArray($nRows=-1) { if ($nRows == -1 && $this->_currentRow <= 0 && !$this->_skiprow1) { @@ -3300,21 +3300,21 @@ return $arr; } } - + function _initrs() { $this->_numOfRows = sizeof($this->_array); if ($this->_skiprow1) $this->_numOfRows -= 1; - + $this->_numOfFields =(isset($this->_fieldobjects)) ? sizeof($this->_fieldobjects):sizeof($this->_types); } - + /* Use associative array to get fields array */ function Fields($colname) { if ($this->fetchMode & ADODB_FETCH_ASSOC) return $this->fields[$colname]; - + if (!$this->bind) { $this->bind = array(); for ($i=0; $i < $this->_numOfFields; $i++) { @@ -3324,8 +3324,8 @@ } return $this->fields[$this->bind[strtoupper($colname)]]; } - - function &FetchField($fieldOffset = -1) + + function &FetchField($fieldOffset = -1) { if (isset($this->_fieldobjects)) { return $this->_fieldobjects[$fieldOffset]; @@ -3334,10 +3334,10 @@ $o->name = $this->_colnames[$fieldOffset]; $o->type = $this->_types[$fieldOffset]; $o->max_length = -1; // length not known - + return $o; } - + function _seek($row) { if (sizeof($this->_array) && 0 <= $row && $row < $this->_numOfRows) { @@ -3348,31 +3348,31 @@ } return false; } - - function MoveNext() + + function MoveNext() { - if (!$this->EOF) { + if (!$this->EOF) { $this->_currentRow++; - + $pos = $this->_currentRow; - + if ($this->_numOfRows <= $pos) { if (!$this->compat) $this->fields = false; } else { if ($this->_skiprow1) $pos += 1; $this->fields = $this->_array[$pos]; return true; - } + } $this->EOF = true; } - - return false; - } + return false; + } + function _fetch() { $pos = $this->_currentRow; - + if ($this->_numOfRows <= $pos) { if (!$this->compat) $this->fields = false; return false; @@ -3381,35 +3381,35 @@ $this->fields = $this->_array[$pos]; return true; } - - function _close() + + function _close() { - return true; + return true; } - + } // ADORecordSet_array - //============================================================================================== + //============================================================================================== // HELPER FUNCTIONS - //============================================================================================== - + //============================================================================================== + /** * Synonym for ADOLoadCode. Private function. Do not use. * * @deprecated */ - function ADOLoadDB($dbType) - { + function ADOLoadDB($dbType) + { return ADOLoadCode($dbType); } - + /** * Load the code for a specific database driver. Private function. Do not use. */ - function ADOLoadCode($dbType) + function ADOLoadCode($dbType) { global $ADODB_LASTDB; - + if (!$dbType) return false; $db = strtolower($dbType); switch ($db) { @@ -3419,10 +3419,10 @@ } @include_once(ADODB_DIR."/drivers/adodb-".$db.".inc.php"); $ADODB_LASTDB = $db; - + $ok = class_exists("ADODB_" . $db); if ($ok) return $db; - + $file = ADODB_DIR."/drivers/adodb-".$db.".inc.php"; if (!file_exists($file)) ADOConnection::outp("Missing file: $file"); else ADOConnection::outp("Syntax error in file: $file"); @@ -3437,7 +3437,7 @@ $tmp =& ADONewConnection($db); return $tmp; } - + /** * Instantiate a new Connection class for a specific database driver. * @@ -3449,10 +3449,10 @@ function &ADONewConnection($db='') { GLOBAL $ADODB_NEWCONNECTION, $ADODB_LASTDB; - + if (!defined('ADODB_ASSOC_CASE')) define('ADODB_ASSOC_CASE',2); $errorfn = (defined('ADODB_ERROR_HANDLER')) ? ADODB_ERROR_HANDLER : false; - + if (!empty($ADODB_NEWCONNECTION)) { $obj = $ADODB_NEWCONNECTION($db); if ($obj) { @@ -3460,12 +3460,12 @@ return $obj; } } - + if (!isset($ADODB_LASTDB)) $ADODB_LASTDB = ''; if (empty($db)) $db = $ADODB_LASTDB; - + if ($db != $ADODB_LASTDB) $db = ADOLoadCode($db); - + if (!$db) { if ($errorfn) { // raise an error @@ -3475,48 +3475,48 @@ $db,false,$ignore); } else ADOConnection::outp( "

ADONewConnection: Unable to load database driver '$db'

",false); - + return false; } - + $cls = 'ADODB_'.$db; if (!class_exists($cls)) { adodb_backtrace(); return false; } - + $obj =& new $cls(); if ($errorfn) $obj->raiseErrorFn = $errorfn; - + return $obj; } - + // $perf == true means called by NewPerfMonitor() function _adodb_getdriver($provider,$drivername,$perf=false) { - if ($provider !== 'native' && $provider != 'odbc' && $provider != 'ado') + if ($provider !== 'native' && $provider != 'odbc' && $provider != 'ado') $drivername = $provider; else { if (substr($drivername,0,5) == 'odbc_') $drivername = substr($drivername,5); else if (substr($drivername,0,4) == 'ado_') $drivername = substr($drivername,4); - else + else switch($drivername) { case 'oracle': $drivername = 'oci8';break; //case 'sybase': $drivername = 'mssql';break; - case 'access': + case 'access': if ($perf) $drivername = ''; break; - case 'db2': + case 'db2': break; default: $drivername = 'generic'; break; } } - + return $drivername; } - + function &NewPerfMonitor(&$conn) { $drivername = _adodb_getdriver($conn->dataProvider,$conn->databaseType,true); @@ -3526,14 +3526,14 @@ $class = "Perf_$drivername"; if (!class_exists($class)) return false; $perf =& new $class($conn); - + return $perf; } - + function &NewDataDictionary(&$conn) { $drivername = _adodb_getdriver($conn->dataProvider,$conn->databaseType); - + include_once(ADODB_DIR.'/adodb-lib.inc.php'); include_once(ADODB_DIR.'/adodb-datadict.inc.php'); $path = ADODB_DIR."/datadict/datadict-$drivername.inc.php"; @@ -3551,7 +3551,7 @@ $dict->quote = $conn->nameQuote; if (is_resource($conn->_connectionID)) $dict->serverInfo = $conn->ServerInfo(); - + return $dict; } @@ -3560,11 +3560,11 @@ * Save a file $filename and its $contents (normally for caching) with file locking */ function adodb_write_file($filename, $contents,$debug=false) - { + { # http://www.php.net/bugs.php?id=9203 Bug that flock fails on Windows # So to simulate locking, we assume that rename is an atomic operation. - # First we delete $filename, then we create a $tempfile write to it and - # rename to the desired $filename. If the rename works, then we successfully + # First we delete $filename, then we create a $tempfile write to it and + # rename to the desired $filename. If the rename works, then we successfully # modified the file exclusively. # What a stupid need - having to simulate locking. # Risks: @@ -3574,11 +3574,11 @@ # 4. another process creates $filename between unlink() and rename() -- ok, rename() fails and cache updated if (strncmp(PHP_OS,'WIN',3) === 0) { // skip the decimal place - $mtime = substr(str_replace(' ','_',microtime()),2); + $mtime = substr(str_replace(' ','_',microtime()),2); // getmypid() actually returns 0 on Win98 - never mind! $tmpname = $filename.uniqid($mtime).getmypid(); if (!($fd = fopen($tmpname,'a'))) return false; - $ok = ftruncate($fd,0); + $ok = ftruncate($fd,0); if (!fwrite($fd,$contents)) $ok = false; fclose($fd); chmod($tmpname,0644); @@ -3603,24 +3603,24 @@ if ($debug)ADOConnection::outp( " Failed acquiring lock for $filename
\n"); $ok = false; } - + return $ok; } - + /* Perform a print_r, with pre tags for better formatting. */ function adodb_pr($var) { - if (isset($_SERVER['HTTP_USER_AGENT'])) { + if (isset($_SERVER['HTTP_USER_AGENT'])) { echo "
\n";print_r($var);echo "
\n"; } else print_r($var); } - + /* Perform a stack-crawl and pretty print it. - + @param printOrArr Pass in a boolean to indicate print, or an $exception->trace array (assumes that print is true then). @param levels Number of levels to display */ @@ -3628,23 +3628,23 @@ { $s = ''; if (PHPVERSION() < 4.3) return; - + $html = (isset($_SERVER['HTTP_USER_AGENT'])); $fmt = ($html) ? " %% line %4d, file: %s" : "%% line %4d, file: %s"; $MAXSTRLEN = 64; - + $s = ($html) ? '
' : '';
-		
+
 		if (is_array($printOrArr)) $traceArr = $printOrArr;
 		else $traceArr = debug_backtrace();
 		array_shift($traceArr);
 		$tabs = sizeof($traceArr)-1;
-		
+
 		foreach ($traceArr as $arr) {
 			$levels -= 1;
 			if ($levels < 0) break;
-			
+	
 			$args = array();
 			for ($i=0; $i < $tabs; $i++) $s .=  ($html) ? '   ' : "\t";
 			$tabs -= 1;
@@ -3664,21 +3664,20 @@
 				}
 			}
 			$s .= $arr['function'].'('.implode(', ',$args).')';
-			
-			
+	
+	
 			$s .= @sprintf($fmt, $arr['line'],$arr['file'],basename($arr['file']));
-				
+		
 			$s .= "\n";
-		}	
+		}
 		if ($html) $s .= '
'; if ($printOrArr) print $s; - + return $s; } - -} // defined -// For emacs users +} + // Local Variables: // mode: php // tab-width: 4 @@ -3686,4 +3685,4 @@ // c-hanging-comment-ender-p: nil // indent-tabs-mode: nil // End: -?> \ No newline at end of file +?> diff --git a/lib/WikiDB/adodb/drivers/adodb-mysql.inc.php b/lib/WikiDB/adodb/drivers/adodb-mysql.inc.php index 294edb939..138996b7e 100644 --- a/lib/WikiDB/adodb/drivers/adodb-mysql.inc.php +++ b/lib/WikiDB/adodb/drivers/adodb-mysql.inc.php @@ -1,16 +1,16 @@ metaTablesSQL; $mask = $this->qstr($mask); $this->metaTablesSQL .= " like $mask"; } $ret =& ADOConnection::MetaTables($ttype,$showSchema); - + if ($mask) { $this->metaTablesSQL = $save; } return $ret; } - - + + function &MetaIndexes ($table, $primary = FALSE, $owner=false) { // save old fetch mode global $ADODB_FETCH_MODE; - + $save = $ADODB_FETCH_MODE; $ADODB_FETCH_MODE = ADODB_FETCH_NUM; if ($this->fetchMode !== FALSE) { $savem = $this->SetFetchMode(FALSE); } - + // get index details $rs = $this->Execute(sprintf('SHOW INDEX FROM %s',$table)); - + // restore fetchmode if (isset($savem)) { $this->SetFetchMode($savem); } $ADODB_FETCH_MODE = $save; - + if (!is_object($rs)) { return FALSE; } - + $indexes = array (); - + // parse index data into array while ($row = $rs->FetchRow()) { if ($primary == FALSE AND $row[2] == 'PRIMARY') { continue; } - + if (!isset($indexes[$row[2]])) { $indexes[$row[2]] = array( 'unique' => ($row[1] == 0), 'columns' => array() ); } - + $indexes[$row[2]]['columns'][$row[3] - 1] = $row[4]; } - + // sort columns by order in the index foreach ( array_keys ($indexes) as $index ) { ksort ($indexes[$index]['columns']); } - + return $indexes; } - + // if magic quotes disabled, use mysql_real_escape_string() function qstr($s,$magic_quotes=false) { if (!$magic_quotes) { - + if (ADODB_PHPVER >= 0x4300) { if (is_resource($this->_connectionID)) return "'".mysql_real_escape_string($s,$this->_connectionID)."'"; @@ -133,19 +133,19 @@ class ADODB_mysql extends ADOConnection { if ($this->replaceQuote[0] == '\\'){ $s = adodb_str_replace(array('\\',"\0"),array('\\\\',"\\\0"),$s); } - return "'".str_replace("'",$this->replaceQuote,$s)."'"; + return "'".str_replace("'",$this->replaceQuote,$s)."'"; } - + // undo magic quotes for " $s = str_replace('\\"','"',$s); return "'$s'"; } - + function _insertid() { return mysql_insert_id($this->_connectionID); } - + function GetOne($sql,$inputarr=false) { $rs =& $this->SelectLimit($sql,1,-1,$inputarr); @@ -154,38 +154,38 @@ class ADODB_mysql extends ADOConnection { if ($rs->EOF) return false; return reset($rs->fields); } - + return false; } - + function _affectedrows() { return mysql_affected_rows($this->_connectionID); } - + // See http://www.mysql.com/doc/M/i/Miscellaneous_functions.html // Reference on Last_Insert_ID on the recommended way to simulate sequences var $_genIDSQL = "update %s set id=LAST_INSERT_ID(id+1);"; var $_genSeqSQL = "create table %s (id int not null)"; var $_genSeq2SQL = "insert into %s values (%s)"; var $_dropSeqSQL = "drop table %s"; - + function CreateSequence($seqname='adodbseq',$startID=1) { if (empty($this->_genSeqSQL)) return false; $u = strtoupper($seqname); - + $ok = $this->Execute(sprintf($this->_genSeqSQL,$seqname)); if (!$ok) return false; return $this->Execute(sprintf($this->_genSeq2SQL,$seqname,$startID-1)); } - + function GenID($seqname='adodbseq',$startID=1) { // post-nuke sets hasGenID to false if (!$this->hasGenID) return false; - + $savelog = $this->_logsql; $this->_logsql = false; $getnext = sprintf($this->_genIDSQL,$seqname); @@ -199,13 +199,13 @@ class ADODB_mysql extends ADOConnection { $rs = $this->Execute($getnext); } $this->genID = mysql_insert_id($this->_connectionID); - + if ($rs) $rs->Close(); - + $this->_logsql = $savelog; return $this->genID; } - + function &MetaDatabases() { $qid = mysql_list_dbs($this->_connectionID); @@ -219,11 +219,11 @@ class ADODB_mysql extends ADOConnection { } return $arr; } - - + + // Format date column in sql string given an input format that understands Y M D function SQLDate($fmt, $col=false) - { + { if (!$col) $col = $this->sysTimeStamp; $s = 'DATE_FORMAT('.$col.",'"; $concat = false; @@ -238,7 +238,7 @@ class ADODB_mysql extends ADOConnection { case 'Q': case 'q': $s .= "'),Quarter($col)"; - + if ($len > $i+1) $s .= ",DATE_FORMAT($col,'"; else $s .= ",('"; $concat = true; @@ -246,7 +246,7 @@ class ADODB_mysql extends ADOConnection { case 'M': $s .= '%b'; break; - + case 'm': $s .= '%m'; break; @@ -254,30 +254,30 @@ class ADODB_mysql extends ADOConnection { case 'd': $s .= '%d'; break; - - case 'H': + + case 'H': $s .= '%H'; break; - + case 'h': $s .= '%I'; break; - + case 'i': $s .= '%i'; break; - + case 's': $s .= '%s'; break; - + case 'a': case 'A': $s .= '%p'; break; - + default: - + if ($ch == '\\') { $i++; $ch = substr($fmt,$i,1); @@ -290,7 +290,7 @@ class ADODB_mysql extends ADOConnection { if ($concat) $s = "CONCAT($s)"; return $s; } - + // returns concatenated string // much easier to run "mysqld --ansi" or "mysqld --sql-mode=PIPES_AS_CONCAT" and use || operator @@ -298,19 +298,19 @@ class ADODB_mysql extends ADOConnection { { $s = ""; $arr = func_get_args(); - + // suggestion by andrew005@mnogo.ru - $s = implode(',',$arr); + $s = implode(',',$arr); if (strlen($s) > 0) return "CONCAT($s)"; else return ''; } - + function OffsetDate($dayFraction,$date=false) - { + { if (!$date) $date = $this->sysDate; return "from_unixtime(unix_timestamp($date)+($dayFraction)*24*3600)"; } - + // returns true or false function _connect($argHostname, $argUsername, $argPassword, $argDatabasename) { @@ -322,12 +322,12 @@ class ADODB_mysql extends ADOConnection { $this->forceNewConnect); else $this->_connectionID = mysql_connect($argHostname,$argUsername,$argPassword); - + if ($this->_connectionID === false) return false; if ($argDatabasename) return $this->SelectDB($argDatabasename); - return true; + return true; } - + // returns true or false function _pconnect($argHostname, $argUsername, $argPassword, $argDatabasename) { @@ -338,39 +338,39 @@ class ADODB_mysql extends ADOConnection { if ($this->_connectionID === false) return false; if ($this->autoRollback) $this->RollbackTrans(); if ($argDatabasename) return $this->SelectDB($argDatabasename); - return true; + return true; } - + function _nconnect($argHostname, $argUsername, $argPassword, $argDatabasename) { $this->forceNewConnect = true; return $this->_connect($argHostname, $argUsername, $argPassword, $argDatabasename); } - - function &MetaColumns($table) + + function &MetaColumns($table) { - + if ($this->metaColumnsSQL) { global $ADODB_FETCH_MODE; - + $save = $ADODB_FETCH_MODE; $ADODB_FETCH_MODE = ADODB_FETCH_NUM; if ($this->fetchMode !== false) $savem = $this->SetFetchMode(false); - + $rs = $this->Execute(sprintf($this->metaColumnsSQL,$table)); - + if (isset($savem)) $this->SetFetchMode($savem); $ADODB_FETCH_MODE = $save; - + if ($rs === false) return false; - + $retarr = array(); while (!$rs->EOF){ $fld = new ADOFieldObject(); $fld->name = $rs->fields[0]; $type = $rs->fields[1]; - - + + // split type into type(length): $fld->scale = null; if (strpos($type,',') && preg_match("/^(.+)\((\d+),(\d+)/", $type, $query_array)) { @@ -397,7 +397,7 @@ class ADODB_mysql extends ADOConnection { $fld->primary_key = ($rs->fields[3] == 'PRI'); $fld->auto_increment = (strpos($rs->fields[5], 'auto_increment') !== false); $fld->binary = (strpos($fld->type,'blob') !== false); - + if (!$fld->binary) { $d = $rs->fields[4]; if ($d != "" && $d != "NULL") { @@ -407,68 +407,68 @@ class ADODB_mysql extends ADOConnection { $fld->has_default = false; } } - if ($save == ADODB_FETCH_NUM) $retarr[] = $fld; + if ($save == ADODB_FETCH_NUM) $retarr[] = $fld; else $retarr[strtoupper($fld->name)] = $fld; $rs->MoveNext(); } $rs->Close(); - return $retarr; + return $retarr; } return false; } - + // returns true or false - function SelectDB($dbName) + function SelectDB($dbName) { $this->databaseName = $dbName; if ($this->_connectionID) { - return @mysql_select_db($dbName,$this->_connectionID); + return @mysql_select_db($dbName,$this->_connectionID); } - else return false; + else return false; } - + // parameters use PostgreSQL convention, not MySQL function &SelectLimit($sql,$nrows=-1,$offset=-1,$inputarr=false,$secs=0) { $offsetStr =($offset>=0) ? "$offset," : ''; - + if ($secs) $rs =& $this->CacheExecute($secs,$sql." LIMIT $offsetStr$nrows",$inputarr); else $rs =& $this->Execute($sql." LIMIT $offsetStr$nrows",$inputarr); return $rs; } - - + + // returns queryID or false function _query($sql,$inputarr) { //global $ADODB_COUNTRECS; - //if($ADODB_COUNTRECS) + //if($ADODB_COUNTRECS) return mysql_query($sql,$this->_connectionID); //else return @mysql_unbuffered_query($sql,$this->_connectionID); // requires PHP >= 4.0.6 } - /* Returns: the last error message from previous database operation */ - function ErrorMsg() + /* Returns: the last error message from previous database operation */ + function ErrorMsg() { - + if ($this->_logsql) return $this->_errorMsg; if (empty($this->_connectionID)) $this->_errorMsg = @mysql_error(); else $this->_errorMsg = @mysql_error($this->_connectionID); return $this->_errorMsg; } - - /* Returns: the last error number from previous database operation */ - function ErrorNo() + + /* Returns: the last error number from previous database operation */ + function ErrorNo() { if ($this->_logsql) return $this->_errorCode; if (empty($this->_connectionID)) return @mysql_errno(); else return @mysql_errno($this->_connectionID); } - - + + // returns true or false function _close() { @@ -476,37 +476,37 @@ class ADODB_mysql extends ADOConnection { $this->_connectionID = false; } - + /* * Maximum size of C field */ function CharMax() { - return 255; + return 255; } - + /* * Maximum size of X field */ function TextMax() { - return 4294967295; + return 4294967295; } - + } - + /*-------------------------------------------------------------------------------------- Class Name: Recordset --------------------------------------------------------------------------------------*/ -class ADORecordSet_mysql extends ADORecordSet{ - +class ADORecordSet_mysql extends ADORecordSet{ + var $databaseType = "mysql"; var $canSeek = true; - - function ADORecordSet_mysql($queryID,$mode=false) + + function ADORecordSet_mysql($queryID,$mode=false) { - if ($mode === false) { + if ($mode === false) { global $ADODB_FETCH_MODE; $mode = $ADODB_FETCH_MODE; } @@ -518,10 +518,10 @@ class ADORecordSet_mysql extends ADORecordSet{ case ADODB_FETCH_DEFAULT: case ADODB_FETCH_BOTH:$this->fetchMode = MYSQL_BOTH; break; } - - $this->ADORecordSet($queryID); + + $this->ADORecordSet($queryID); } - + function _initrs() { //GLOBAL $ADODB_COUNTRECS; @@ -529,10 +529,10 @@ class ADORecordSet_mysql extends ADORecordSet{ $this->_numOfRows = @mysql_num_rows($this->_queryID); $this->_numOfFields = @mysql_num_fields($this->_queryID); } - - function &FetchField($fieldOffset = -1) - { - + + function &FetchField($fieldOffset = -1) + { + if ($fieldOffset != -1) { $o = @mysql_fetch_field($this->_queryID, $fieldOffset); $f = @mysql_field_flags($this->_queryID,$fieldOffset); @@ -545,7 +545,7 @@ class ADORecordSet_mysql extends ADORecordSet{ $o->max_length = @mysql_field_len($this->_queryID); // suggested by: Jim Nicholson (jnich@att.com) //$o->max_length = -1; // mysql returns the max length less spaces -- so it is unrealiable } - + return $o; } @@ -555,13 +555,13 @@ class ADORecordSet_mysql extends ADORecordSet{ $row =& ADORecordSet::GetRowAssoc($upper); return $row; } - + /* Use associative array to get fields array */ function Fields($colname) - { + { // added @ by "Michael William Miller" if ($this->fetchMode != MYSQL_NUM) return @$this->fields[$colname]; - + if (!$this->bind) { $this->bind = array(); for ($i=0; $i < $this->_numOfFields; $i++) { @@ -571,27 +571,27 @@ class ADORecordSet_mysql extends ADORecordSet{ } return $this->fields[$this->bind[strtoupper($colname)]]; } - + function _seek($row) { if ($this->_numOfRows == 0) return false; return @mysql_data_seek($this->_queryID,$row); } - - + + // 10% speedup to move MoveNext to child class - function MoveNext() + function MoveNext() { //global $ADODB_EXTENSION;if ($ADODB_EXTENSION) return adodb_movenext($this); - + if ($this->EOF) return false; - + $this->_currentRow++; $this->fields = @mysql_fetch_array($this->_queryID,$this->fetchMode); if (is_array($this->fields)) return true; - + $this->EOF = true; - + /* -- tested raising an error -- appears pointless $conn = $this->connection; if ($conn && $conn->raiseErrorFn && ($errno = $conn->ErrorNo())) { @@ -600,19 +600,19 @@ class ADORecordSet_mysql extends ADORecordSet{ } */ return false; - } - + } + function _fetch() { $this->fields = @mysql_fetch_array($this->_queryID,$this->fetchMode); return is_array($this->fields); } - + function _close() { - @mysql_free_result($this->_queryID); - $this->_queryID = false; + @mysql_free_result($this->_queryID); + $this->_queryID = false; } - + function MetaType($t,$len=-1,$fieldobj=false) { if (is_object($t)) { @@ -620,48 +620,48 @@ class ADORecordSet_mysql extends ADORecordSet{ $t = $fieldobj->type; $len = $fieldobj->max_length; } - + $len = -1; // mysql max_length is not accurate switch (strtoupper($t)) { - case 'STRING': + case 'STRING': case 'CHAR': - case 'VARCHAR': - case 'TINYBLOB': - case 'TINYTEXT': - case 'ENUM': - case 'SET': + case 'VARCHAR': + case 'TINYBLOB': + case 'TINYTEXT': + case 'ENUM': + case 'SET': if ($len <= $this->blobSize) return 'C'; - + case 'TEXT': - case 'LONGTEXT': + case 'LONGTEXT': case 'MEDIUMTEXT': return 'X'; - + // php_mysql extension always returns 'blob' even if 'text' // so we have to check whether binary... case 'IMAGE': - case 'LONGBLOB': + case 'LONGBLOB': case 'BLOB': case 'MEDIUMBLOB': return !empty($fieldobj->binary) ? 'B' : 'X'; - + case 'YEAR': case 'DATE': return 'D'; - + case 'TIME': case 'DATETIME': case 'TIMESTAMP': return 'T'; - - case 'INT': + + case 'INT': case 'INTEGER': case 'BIGINT': case 'TINYINT': case 'MEDIUMINT': - case 'SMALLINT': - + case 'SMALLINT': + if (!empty($fieldobj->primary_key)) return 'R'; else return 'I'; - + default: return 'N'; } } @@ -669,12 +669,11 @@ class ADORecordSet_mysql extends ADORecordSet{ } } -// (c-file-style: "gnu") // Local Variables: // mode: php // tab-width: 8 // c-basic-offset: 4 // c-hanging-comment-ender-p: nil // indent-tabs-mode: nil -// End: -?> \ No newline at end of file +// End: +?> diff --git a/lib/WikiDB/backend.php b/lib/WikiDB/backend.php index ccac4ab0a..d8fa91fb9 100644 --- a/lib/WikiDB/backend.php +++ b/lib/WikiDB/backend.php @@ -4,7 +4,7 @@ /* Pagedata - maintained by WikiPage + maintained by WikiPage //:latestversion //:deleted (*) (Set if latest content is empty.) //:pagename (*) @@ -27,11 +27,11 @@ //version //created (*) //%superceded - + //:serial (types are scalars: strings, ints, bools) -*/ +*/ /** * A WikiDB_backend handles the storage and retrieval of data for a WikiDB. @@ -64,7 +64,7 @@ class WikiDB_backend *
locked
If the page is locked. *
hits
The page hit count. *
created
Unix time of page creation. (FIXME: Deprecated: I - * don't think we need this...) + * don't think we need this...) * */ function get_pagedata($pagename) { @@ -80,7 +80,7 @@ class WikiDB_backend * * For example: *
-     *   $backend->update_pagedata($pagename, array('locked' => 1)); 
+     *   $backend->update_pagedata($pagename, array('locked' => 1));
      * 
* will set the value of 'locked' to 1 for the specified page, but it * will not affect the value of 'hits' (or whatever other meta-data @@ -88,7 +88,7 @@ class WikiDB_backend * * To delete a particular piece of meta-data, set its value to false. *
-     *   $backend->update_pagedata($pagename, array('locked' => false)); 
+     *   $backend->update_pagedata($pagename, array('locked' => false));
      * 
* * @param $pagename string Page name. @@ -97,7 +97,7 @@ class WikiDB_backend function update_pagedata($pagename, $newdata) { trigger_error("virtual", E_USER_ERROR); } - + /** * Get the current version number for a page. @@ -109,7 +109,7 @@ class WikiDB_backend function get_latest_version($pagename) { trigger_error("virtual", E_USER_ERROR); } - + /** * Get preceding version number. * @@ -121,7 +121,7 @@ class WikiDB_backend function get_previous_version($pagename, $version) { trigger_error("virtual", E_USER_ERROR); } - + /** * Get revision meta-data and content. * @@ -173,9 +173,9 @@ class WikiDB_backend $this->set_links($pagename, false); // links are purged. // SQL needs to invalidate the non_empty id if (! WIKIDB_NOCACHE_MARKUP) { - // need the hits, perms and LOCKED, otherwise you can reset the perm + // need the hits, perms and LOCKED, otherwise you can reset the perm // by action=remove and re-create it with default perms - $pagedata = $this->get_pagedata($pagename); + $pagedata = $this->get_pagedata($pagename); unset($pagedata['_cached_html']); $this->update_pagedata($pagename, $pagedata); } @@ -248,7 +248,7 @@ class WikiDB_backend } $this->set_versiondata($pagename, $version, $data); } - + /** * Set links for page. * @@ -259,7 +259,7 @@ class WikiDB_backend function set_links($pagename, $links) { trigger_error("virtual", E_USER_ERROR); } - + /** * Find pages which link to or are linked from a page. * @@ -285,7 +285,7 @@ class WikiDB_backend include_once('lib/WikiDB/backend/dumb/AllRevisionsIter.php'); return new WikiDB_backend_dumb_AllRevisionsIter($this, $pagename); } - + /** * Get all pages in the database. * @@ -308,7 +308,7 @@ class WikiDB_backend function get_all_pages($include_defaulted, $orderby=false, $limit='', $exclude='') { trigger_error("virtual", E_USER_ERROR); } - + /** * Title or full text search. * @@ -317,7 +317,7 @@ class WikiDB_backend * * @access protected * - * @param $search object A TextSearchQuery object describing the parsed query string, + * @param $search object A TextSearchQuery object describing the parsed query string, * with efficient methods for SQL and PCRE match. * * @param $fullsearch boolean If true, a full text search is performed, @@ -327,8 +327,8 @@ class WikiDB_backend * * @see WikiDB::titleSearch */ - function text_search($search, $fulltext=false, $sortby='', - $limit='', $exclude='') + function text_search($search, $fulltext=false, $sortby='', + $limit='', $exclude='') { // This method implements a simple linear search // through all the pages in the database. @@ -338,8 +338,8 @@ class WikiDB_backend include_once('lib/WikiDB/backend/dumb/TextSearchIter.php'); // ignore $limit $pages = $this->get_all_pages(false, $sortby, false, $exclude); - return new WikiDB_backend_dumb_TextSearchIter($this, $pages, $search, $fulltext, - array('limit' => $limit, + return new WikiDB_backend_dumb_TextSearchIter($this, $pages, $search, $fulltext, + array('limit' => $limit, 'exclude' => $exclude)); } @@ -348,7 +348,7 @@ class WikiDB_backend * * @access protected * @param $pages object A TextSearchQuery object. - * @param $linkvalue object A TextSearchQuery object for the linkvalues + * @param $linkvalue object A TextSearchQuery object for the linkvalues * (linkto, relation or backlinks or attribute values). * @param $linktype string One of the 4 linktypes. * @param $relation object A TextSearchQuery object or false. @@ -471,7 +471,7 @@ class WikiDB_backend } /** - * Put the database into a consistent state + * Put the database into a consistent state * by reparsing and restoring all pages. * * This should put the database into a consistent state. @@ -504,7 +504,7 @@ class WikiDB_backend $search = strtolower(trim($search)); if (!$search) return array(array(),array()); - + $words = preg_split('/\s+/', $search); $exclude = array(); foreach ($words as $key => $word) { @@ -517,10 +517,10 @@ class WikiDB_backend return array($words, $exclude); } - /** + /** * Split the given limit parameter into offset,limit. (offset is optional. default: 0) - * Duplicate the PageList function here to avoid loading the whole PageList.php - * Usage: + * Duplicate the PageList function here to avoid loading the whole PageList.php + * Usage: * list($offset,$count) = $this->limit($args['limit']); */ function limit($limit) { @@ -538,8 +538,8 @@ class WikiDB_backend return array(0, $limit); } } - - /** + + /** * Handle sortby requests for the DB iterator and table header links. * Prefix the column with + or - like "+pagename","-mtime", ... * supported actions: 'flip_order' "mtime" => "+mtime" => "-mtime" ... @@ -547,7 +547,7 @@ class WikiDB_backend * In PageList all columns are sortable. (patch by DanFr) * Here with the backend only some, the rest is delayed to PageList. * (some kind of DumbIter) - * Duplicate the PageList function here to avoid loading the whole + * Duplicate the PageList function here to avoid loading the whole * PageList.php, and it forces the backend specific sortable_columns() */ function sortby ($column, $action, $sortable_columns=false) { @@ -580,8 +580,8 @@ class WikiDB_backend $this->_sortby[$column] = $order; return $order . $column; } elseif ($action == 'check') { - return (!empty($this->_sortby[$column]) or - ($GLOBALS['request']->getArg('sortby') and + return (!empty($this->_sortby[$column]) or + ($GLOBALS['request']->getArg('sortby') and strstr($GLOBALS['request']->getArg('sortby'),$column))); } elseif ($action == 'db') { // native sort possible? @@ -590,7 +590,7 @@ class WikiDB_backend if (in_array($column, $sortable_columns)) // asc or desc: +pagename, -pagename return $column . ($order == '+' ? ' ASC' : ' DESC'); - else + else return ''; } return ''; @@ -600,7 +600,7 @@ class WikiDB_backend return array('pagename'/*,'mtime','author_id','author'*/); } - // adds surrounding quotes + // adds surrounding quotes function quote ($s) { return "'".$s."'"; } // no surrounding quotes because we know it's a string function qstr ($s) { return $s; } @@ -627,14 +627,14 @@ class WikiDB_backend // Problem: date formats are backend specific. Either use unixtime as %d (long), // or the native timestamp format. $entry->time, - $entry->host, + $entry->host, $entry->user, $entry->request_method, $entry->request, $entry->request_args, $entry->request_uri, - $entry->_ncsa_time($entry->time), - $entry->status, + $entry->_ncsa_time($entry->time), + $entry->status, (int)$entry->size, $entry->referer, $entry->user_agent, @@ -678,7 +678,7 @@ class WikiDB_backend_iterator if (!empty($this->_pages)) return count($this->_pages); else - return 0; + return 0; } function asArray() { @@ -692,7 +692,7 @@ class WikiDB_backend_iterator return $result; } } - + /** * limit - if empty the pagelist iterator will do nothing. * Some backends limit the result set itself (dba, file, flatfile), @@ -736,7 +736,7 @@ class WikiDB_backend_search return "preg_match(\"/\".$word.\"/\"".($this->_case_exact ? "i":"").")"; } /* Eliminate stoplist words. - * Keep a list of Stoplisted words to inform the poor user. + * Keep a list of Stoplisted words to inform the poor user. */ function isStoplisted ($node) { // check only on WORD or EXACT fulltext search @@ -764,7 +764,7 @@ class WikiDB_backend_search_sql extends WikiDB_backend_search if ($word == '%') // ALL shortcut return "1=1"; else - return ($this->_case_exact + return ($this->_case_exact ? "pagename LIKE '$word'" : "LOWER(pagename) LIKE '$word'"); } @@ -777,12 +777,11 @@ class WikiDB_backend_search_sql extends WikiDB_backend_search else return $this->_pagename_match_clause($node) // probably convert this MATCH AGAINST or SUBSTR/POSITION without wildcards - . ($this->_case_exact ? " OR content LIKE '$word'" + . ($this->_case_exact ? " OR content LIKE '$word'" : " OR LOWER(content) LIKE '$word'"); } } -// For emacs users // Local Variables: // mode: php // tab-width: 8 diff --git a/lib/WikiDB/backend/ADODB.php b/lib/WikiDB/backend/ADODB.php index 0b1024d4a..8e1c75ff6 100644 --- a/lib/WikiDB/backend/ADODB.php +++ b/lib/WikiDB/backend/ADODB.php @@ -20,19 +20,19 @@ along with PhpWiki; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ +*/ /** - * Based on PearDB.php. + * Based on PearDB.php. * @author: Lawrence Akka, Reini Urban * * Now (since phpwiki-1.3.10) with adodb-4.22, by Reini Urban: * 1) Extended to use all available database backends, not only mysql. * 2) It uses the ultra-fast binary adodb extension if loaded. * 3) We use FETCH_NUM instead of FETCH_ASSOC (faster and more generic) - * 4) To support generic iterators which return ASSOC fields, and to support queries with + * 4) To support generic iterators which return ASSOC fields, and to support queries with * variable columns, some trickery was needed to use recordset specific fetchMode. - * The first Execute uses the global fetchMode (ASSOC), then it's resetted back to NUM + * The first Execute uses the global fetchMode (ASSOC), then it's resetted back to NUM * and the recordset fetchmode is set to ASSOC. * 5) Transaction support, and locking as fallback. * 6) 2004-12-10 added extra page.cached_html @@ -42,25 +42,25 @@ * phpwiki-1.3.12: get rid of ISNULL * phpwiki-1.3.13: tsearch2 and stored procedures * - * ADODB basic differences to PearDB: It pre-fetches the first row into fields, + * ADODB basic differences to PearDB: It pre-fetches the first row into fields, * is dirtier in style, layout and more low-level ("worse is better"). - * It has less needed basic features (modifyQuery, locks, ...), but some more + * It has less needed basic features (modifyQuery, locks, ...), but some more * unneeded features included: paging, monitoring and sessions, and much more drivers. - * No locking (which PearDB supports in some backends), and sequences are very + * No locking (which PearDB supports in some backends), and sequences are very * bad compared to PearDB. * Old Comments, by Lawrence Akka: - * 1) ADODB's GetRow() is slightly different from that in PEAR. It does not + * 1) ADODB's GetRow() is slightly different from that in PEAR. It does not * accept a fetchmode parameter * That doesn't matter too much here, since we only ever use FETCHMODE_ASSOC - * 2) No need for ''s around strings in sprintf arguments - qstr puts them + * 2) No need for ''s around strings in sprintf arguments - qstr puts them * there automatically - * 3) ADODB has a version of GetOne, but it is difficult to use it when + * 3) ADODB has a version of GetOne, but it is difficult to use it when * FETCH_ASSOC is in effect. * Instead, use $rs = Execute($query); $value = $rs->fields["$colname"] * 4) No error handling yet - could use ADOConnection->raiseErrorFn - * 5) It used to be faster then PEAR/DB at the beginning of 2002. - * Now at August 2002 PEAR/DB with our own page cache added, + * 5) It used to be faster then PEAR/DB at the beginning of 2002. + * Now at August 2002 PEAR/DB with our own page cache added, * performance is comparable. */ @@ -89,10 +89,10 @@ extends WikiDB_backend //FIXME: how to catch connection errors for dbamin_user? if (!empty($parsed['persistent']) or DATABASE_PERSISTENT) - $conn = $this->_dbh->PConnect($parsed['hostspec'],$parsed['username'], + $conn = $this->_dbh->PConnect($parsed['hostspec'],$parsed['username'], $parsed['password'], $parsed['database']); else - $conn = $this->_dbh->Connect($parsed['hostspec'],$parsed['username'], + $conn = $this->_dbh->Connect($parsed['hostspec'],$parsed['username'], $parsed['password'], $parsed['database']); if (!$conn) return; @@ -138,7 +138,7 @@ extends WikiDB_backend if (!$this->_dbh) return; if ($this->_lock_count) { - trigger_error("WARNING: database still locked " . + trigger_error("WARNING: database still locked " . '(lock_count = $this->_lock_count)' . "\n
", E_USER_WARNING); } @@ -162,7 +162,7 @@ extends WikiDB_backend $dbh->qstr($pagename))); return $row ? $row[0] : false; } - + function get_all_pagenames() { $dbh = &$this->_dbh; extract($this->_table_names); @@ -210,7 +210,7 @@ extends WikiDB_backend function _extract_page_data($data, $hits) { if (empty($data)) return array('hits' => $hits); - else + else return array_merge(array('hits' => $hits), $this->_unserialize($data)); } @@ -230,13 +230,13 @@ extends WikiDB_backend $where = sprintf("pagename=%s", $dbh->qstr($pagename)); $dbh->BeginTrans( ); $dbh->RowLock($page_tbl,$where); - + $data = $this->get_pagedata($pagename); if (!$data) { $data = array(); $this->_get_pageid($pagename, true); // Creates page record } - + $hits = (empty($data['hits'])) ? 0 : (int)$data['hits']; unset($data['hits']); @@ -353,7 +353,7 @@ extends WikiDB_backend 1); return $rs->fields ? (int)$rs->fields[0] : false; } - + /** * Get version data. * @@ -366,10 +366,10 @@ extends WikiDB_backend $dbh = &$this->_dbh; extract($this->_table_names); extract($this->_expressions); - + assert(is_string($pagename) and $pagename != ''); assert($version > 0); - + // FIXME: optimization: sometimes don't get page data? if ($want_content) { $fields = $this->page_tbl_fields . ", $page_tbl.pagedata AS pagedata" @@ -437,10 +437,10 @@ extends WikiDB_backend function set_versiondata($pagename, $version, $data) { $dbh = &$this->_dbh; $version_tbl = $this->_table_names['version_tbl']; - + $minor_edit = (int) !empty($data['is_minor_edit']); unset($data['is_minor_edit']); - + $mtime = (int)$data['mtime']; unset($data['mtime']); assert(!empty($mtime)); @@ -448,7 +448,7 @@ extends WikiDB_backend @$content = (string) $data['%content']; unset($data['%content']); unset($data['%pagedata']); - + $this->lock(array('page','recent','version','nonempty')); $dbh->BeginTrans( ); $dbh->CommitLock($version_tbl); @@ -468,7 +468,7 @@ extends WikiDB_backend else $dbh->RollbackTrans( ); $this->unlock(array('page','recent','version','nonempty')); } - + /** * Delete an old revision of a page. */ @@ -491,10 +491,10 @@ extends WikiDB_backend /** * Delete page from the database with backup possibility. * i.e save_page('') and DELETE nonempty id - * - * deletePage increments latestversion in recent to a non-existent version, + * + * deletePage increments latestversion in recent to a non-existent version, * and removes the nonempty row, - * so that get_latest_version returns id+1 and get_previous_version returns prev id + * so that get_latest_version returns id+1 and get_previous_version returns prev id * and page->exists returns false. */ function delete_page($pagename) { @@ -523,17 +523,17 @@ extends WikiDB_backend '', $this->_serialize($meta))) and $dbh->Execute("DELETE FROM $nonempty_tbl WHERE id=$id") and $this->set_links($pagename, false) - // need to keep perms and LOCKED, otherwise you can reset the perm + // need to keep perms and LOCKED, otherwise you can reset the perm // by action=remove and re-create it with default perms - // keep hits but delete meta-data - //and $dbh->Execute("UPDATE $page_tbl SET pagedata='' WHERE id=$id") + // keep hits but delete meta-data + //and $dbh->Execute("UPDATE $page_tbl SET pagedata='' WHERE id=$id") ) { - $this->unlock(array('version','recent','nonempty','page','link')); + $this->unlock(array('version','recent','nonempty','page','link')); $dbh->CommitTrans( ); return true; } else { - $this->unlock(array('version','recent','nonempty','page','link')); + $this->unlock(array('version','recent','nonempty','page','link')); $dbh->RollbackTrans( ); return false; } @@ -542,7 +542,7 @@ extends WikiDB_backend function purge_page($pagename) { $dbh = &$this->_dbh; extract($this->_table_names); - + $this->lock(array('version','recent','nonempty','page','link')); if ( ($id = $this->_get_pageid($pagename, false)) ) { $dbh->Execute("DELETE FROM $nonempty_tbl WHERE id=$id"); @@ -574,7 +574,7 @@ extends WikiDB_backend //function update_versiondata($pagename, $version, $data) { //} - /* + /* * Update link table. * on DEBUG: delete old, deleted links from page */ @@ -598,7 +598,7 @@ extends WikiDB_backend $linkto = $link['linkto']; if (isset($link['relation'])) $relation = $this->_get_pageid($link['relation'], true); - else + else $relation = 0; if ($linkto === "") { // ignore attributes continue; @@ -615,13 +615,13 @@ extends WikiDB_backend if ($relation) { $dbh->Execute("INSERT INTO $link_tbl (linkfrom, linkto, relation)" . " VALUES ($pageid, $linkid, $relation)"); - } else { + } else { $dbh->Execute("INSERT INTO $link_tbl (linkfrom, linkto)" . " VALUES ($pageid, $linkid)"); } if ($oldlinks and array_key_exists($linkid, $oldlinks)) { // This was also in the previous page - unset($oldlinks[$linkid]); + unset($oldlinks[$linkid]); } } } @@ -675,7 +675,7 @@ extends WikiDB_backend $linkto = $link['linkto']; if ($link['relation']) $relation = $this->_get_pageid($link['relation'], true); - else + else $relation = 0; // avoid duplicates if (isset($linkseen[$linkto]) and !$relation) { @@ -702,7 +702,7 @@ extends WikiDB_backend if ($relation) { $dbh->Execute("INSERT INTO $link_tbl (linkfrom, linkto, relation)" . " VALUES ($pageid, $linkid, $relation)"); - } else { + } else { $dbh->Execute("INSERT INTO $link_tbl (linkfrom, linkto)" . " VALUES ($pageid, $linkid)"); } @@ -710,7 +710,7 @@ extends WikiDB_backend if (array_key_exists($linkid, $oldlinks)) { // This was also in the previous page - unset($oldlinks[$linkid]); + unset($oldlinks[$linkid]); } } } @@ -725,7 +725,7 @@ extends WikiDB_backend . " LEFT JOIN $version_tbl USING (id)" . " WHERE $nonempty_tbl.id is NULL" . " AND $version_tbl.id is NULL" - . " AND $page_tbl.id=$id")) + . " AND $page_tbl.id=$id")) { trigger_error("delete empty and non-referenced link $name ($id)", E_USER_NOTICE); $dbh->Execute("DELETE FROM $page_tbl WHERE id=$id"); // this purges the link @@ -736,17 +736,17 @@ extends WikiDB_backend $this->unlock(array('link')); return true; } - + /** * Find pages which link to or are linked from a page. * * Optimization: save request->_dbi->_iwpcache[] to avoid further iswikipage checks * (linkExistingWikiWord or linkUnknownWikiWord) - * This is called on every page header GleanDescription, so we can store all the + * This is called on every page header GleanDescription, so we can store all the * existing links. - * - * relations: $backend->get_links is responsible to add the relation to the pagehash - * as 'linkrelation' key as pagename. See WikiDB_PageIterator::next + * + * relations: $backend->get_links is responsible to add the relation to the pagehash + * as 'linkrelation' key as pagename. See WikiDB_PageIterator::next * if (isset($next['linkrelation'])) */ function get_links($pagename, $reversed=true, $include_empty=false, @@ -764,7 +764,7 @@ extends WikiDB_backend if ($orderby) $orderby = " ORDER BY $want." . $orderby; if ($exclude) // array of pagenames $exclude = " AND $want.pagename NOT IN ".$this->_sql_set($exclude); - else + else $exclude=''; $qpagename = $dbh->qstr($pagename); @@ -785,7 +785,7 @@ extends WikiDB_backend echo "SELECT linkee.id AS id, linkee.pagename AS pagename, related.pagename as linkrelation FROM link, page linkee, page linker JOIN page related ON (link.relation=related.id) WHERE linkfrom=linker.id AND linkto=linkee.id AND linker.pagename='SanDiego'" | mysql phpwiki id pagename linkrelation 2268 California located_in -*/ +*/ if ($limit) { // extract from,count from limit list($offset,$count) = $this->limit($limit); @@ -821,7 +821,7 @@ id pagename linkrelation } /* - * + * */ function get_all_pages($include_empty=false, $sortby='', $limit='', $exclude='') { $dbh = &$this->_dbh; @@ -832,7 +832,7 @@ id pagename linkrelation if ($exclude) {// array of pagenames $and = ' AND '; $exclude = " $page_tbl.pagename NOT IN ".$this->_sql_set($exclude); - } else { + } else { $exclude=''; } @@ -883,24 +883,24 @@ id pagename linkrelation //$dbh->SetFetchMode(ADODB_FETCH_NUM); return new WikiDB_backend_ADODB_iter($this, $result, $this->page_tbl_field_list); } - + /** * Title and fulltext search. */ - function text_search($search, $fullsearch=false, - $sortby='', $limit='', $exclude='') + function text_search($search, $fullsearch=false, + $sortby='', $limit='', $exclude='') { $dbh = &$this->_dbh; extract($this->_table_names); $orderby = $this->sortby($sortby, 'db'); if ($orderby) $orderby = ' ORDER BY ' . $orderby; - + $table = "$nonempty_tbl, $page_tbl"; $join_clause = "$nonempty_tbl.id=$page_tbl.id"; $fields = $this->page_tbl_fields; $field_list = $this->page_tbl_field_list; $searchobj = new WikiDB_backend_ADODB_search($search, $dbh); - + if ($fullsearch) { $table .= ", $recent_tbl"; $join_clause .= " AND $page_tbl.id=$recent_tbl.id"; @@ -909,13 +909,13 @@ id pagename linkrelation $join_clause .= " AND $page_tbl.id=$version_tbl.id AND latestversion=version"; $fields .= ",$page_tbl.pagedata as pagedata," . $this->version_tbl_fields; - $field_list = array_merge($field_list, array('pagedata'), + $field_list = array_merge($field_list, array('pagedata'), $this->version_tbl_field_list); $callback = new WikiMethodCb($searchobj, "_fulltext_match_clause"); } else { $callback = new WikiMethodCb($searchobj, "_pagename_match_clause"); } - + $search_clause = $search->makeSqlClauseObj($callback); $sql = "SELECT $fields FROM $table" . " WHERE $join_clause" @@ -935,8 +935,8 @@ id pagename linkrelation } /* - * TODO: efficiently handle wildcards exclusion: exclude=Php* => 'Php%', - * not sets. See above, but the above methods find too much. + * TODO: efficiently handle wildcards exclusion: exclude=Php* => 'Php%', + * not sets. See above, but the above methods find too much. * This is only for already resolved wildcards: * " WHERE $page_tbl.pagename NOT IN ".$this->_sql_set(array('page1','page2')); */ @@ -955,8 +955,8 @@ id pagename linkrelation $dbh = &$this->_dbh; extract($this->_table_names); $order = "DESC"; - if ($limit < 0){ - $order = "ASC"; + if ($limit < 0){ + $order = "ASC"; $limit = -$limit; $where = ""; } else { @@ -967,7 +967,7 @@ id pagename linkrelation else $orderby = ""; } else $orderby = " ORDER BY hits $order"; - $sql = "SELECT " + $sql = "SELECT " . $this->page_tbl_fields . " FROM $nonempty_tbl, $page_tbl" . " WHERE $nonempty_tbl.id=$page_tbl.id" @@ -1000,7 +1000,7 @@ id pagename linkrelation $pick = array(); if ($since) $pick[] = "mtime >= $since"; - + if ($include_all_revisions) { // Include all revisions of each page. $table = "$page_tbl, $version_tbl"; @@ -1020,7 +1020,7 @@ id pagename linkrelation $join_clause = "$page_tbl.id=$recent_tbl.id"; $table .= ", $version_tbl"; $join_clause .= " AND $version_tbl.id=$page_tbl.id"; - + if ($exclude_major_revisions) { // Include only most recent minor revision $pick[] = 'version=latestminor'; @@ -1056,7 +1056,7 @@ id pagename linkrelation $result = $dbh->Execute($sql); } //$result->fields['version'] = $result->fields[6]; - return new WikiDB_backend_ADODB_iter($this, $result, + return new WikiDB_backend_ADODB_iter($this, $result, array_merge($this->page_tbl_field_list, $this->version_tbl_field_list)); } @@ -1068,24 +1068,24 @@ id pagename linkrelation extract($this->_table_names); if ($orderby = $this->sortby($sortby, 'db', array('pagename','wantedfrom'))) $orderby = 'ORDER BY ' . $orderby; - + if ($exclude_from) // array of pagenames $exclude_from = " AND pp.pagename NOT IN ".$this->_sql_set($exclude_from); if ($exclude) // array of pagenames $exclude = " AND p.pagename NOT IN ".$this->_sql_set($exclude); - /* + /* all empty pages, independent of linkstatus: select pagename as empty from page left join nonempty using(id) where is null(nonempty.id); only all empty pages, which have a linkto: - select page.pagename, linked.pagename as wantedfrom from link, page linked + select page.pagename, linked.pagename as wantedfrom from link, page linked left join page on link.linkto=page.id left join nonempty on link.linkto=nonempty.id - where nonempty.id is null and linked.id=link.linkfrom; + where nonempty.id is null and linked.id=link.linkfrom; */ $sql = "SELECT p.pagename, pp.pagename as wantedfrom" . " FROM $page_tbl p, $link_tbl linked" . " LEFT JOIN $page_tbl pp ON (linked.linkto = pp.id)" - . " LEFT JOIN $nonempty_tbl ne ON (linked.linkto = ne.id)" + . " LEFT JOIN $nonempty_tbl ne ON (linked.linkto = ne.id)" . " WHERE ne.id is NULL" . " AND (p.id = linked.linkfrom)" . $exclude_from @@ -1107,7 +1107,7 @@ id pagename linkrelation function rename_page($pagename, $to) { $dbh = &$this->_dbh; extract($this->_table_names); - + $this->lock(array('page','version','recent','nonempty','link')); if ( ($id = $this->_get_pageid($pagename, false)) ) { if ($new = $this->_get_pageid($to, false)) { @@ -1204,7 +1204,7 @@ id pagename linkrelation function _lock_tables($tables, $write_lock) { return $this->_current_lock; } - + /** * Release a write lock on the tables in the SQL database. * @@ -1269,15 +1269,15 @@ id pagename linkrelation function listOfTables() { return $this->_dbh->MetaTables(); } - + // other database needs another connection and other privileges. function listOfFields($database, $table) { $field_list = array(); $old_db = $this->database(); if ($database != $old_db) { - $conn = $this->_dbh->Connect($this->_parsedDSN['hostspec'], - DBADMIN_USER ? DBADMIN_USER : $this->_parsedDSN['username'], - DBADMIN_PASSWD ? DBADMIN_PASSWD : $this->_parsedDSN['password'], + $conn = $this->_dbh->Connect($this->_parsedDSN['hostspec'], + DBADMIN_USER ? DBADMIN_USER : $this->_parsedDSN['username'], + DBADMIN_PASSWD ? DBADMIN_PASSWD : $this->_parsedDSN['password'], $database); } foreach ($this->_dbh->MetaColumns($table, false) as $field) { @@ -1285,9 +1285,9 @@ id pagename linkrelation } if ($database != $old_db) { $this->_dbh->close(); - $conn = $this->_dbh->Connect($this->_parsedDSN['hostspec'], - $this->_parsedDSN['username'], - $this->_parsedDSN['password'], + $conn = $this->_dbh->Connect($this->_parsedDSN['hostspec'], + $this->_parsedDSN['username'], + $this->_parsedDSN['password'], $old_db); } return $field_list; @@ -1315,7 +1315,7 @@ extends WikiDB_backend_iterator $this->_fields = $field_list; } - + function count() { if (!$this->_result) { return false; @@ -1397,7 +1397,7 @@ extends WikiDB_backend_ADODB_generic_iter } } -class WikiDB_backend_ADODB_search extends WikiDB_backend_search_sql +class WikiDB_backend_ADODB_search extends WikiDB_backend_search_sql { // no surrounding quotes because we know it's a string // function _quote($word) { return $this->_dbh->escapeSimple($word); } @@ -1562,12 +1562,11 @@ class WikiDB_backend_ADODB_search extends WikiDB_backend_search_sql return $parsed; } -// (c-file-style: "gnu") // Local Variables: // mode: php // tab-width: 8 // c-basic-offset: 4 // c-hanging-comment-ender-p: nil // indent-tabs-mode: nil -// End: +// End: ?> diff --git a/lib/WikiDB/backend/ADODB_mssql.php b/lib/WikiDB/backend/ADODB_mssql.php index 2a96ac300..634310e94 100644 --- a/lib/WikiDB/backend/ADODB_mssql.php +++ b/lib/WikiDB/backend/ADODB_mssql.php @@ -27,7 +27,7 @@ extends WikiDB_backend_ADODB $this->_prefix = isset($dbparams['prefix']) ? $dbparams['prefix'] : ''; } - + /** * Pack tables. */ @@ -40,7 +40,7 @@ extends WikiDB_backend_ADODB /** * Lock tables. * - * We don't really need to lock exclusive, but I'll relax it when I fully + * We don't really need to lock exclusive, but I'll relax it when I fully * understand phpWiki locking ;-) * */ @@ -83,7 +83,7 @@ extends WikiDB_backend_ADODB function _fullsearch_sql_match_clause($word) { $word = preg_replace('/(?=[%_\\\\])/', "\\", $word); $wordq = $this->_dbh->qstr("%$word%"); - return "LOWER(pagename) LIKE $wordq " + return "LOWER(pagename) LIKE $wordq " . "OR CHARINDEX(content, '$word') > 0"; } @@ -106,12 +106,11 @@ extends WikiDB_backend_ADODB }; -// (c-file-style: "gnu") // Local Variables: // mode: php // tab-width: 8 // c-basic-offset: 4 // c-hanging-comment-ender-p: nil // indent-tabs-mode: nil -// End: +// End: ?> diff --git a/lib/WikiDB/backend/ADODB_mssqlnative.php b/lib/WikiDB/backend/ADODB_mssqlnative.php index 0e7921873..efe0125cb 100644 --- a/lib/WikiDB/backend/ADODB_mssqlnative.php +++ b/lib/WikiDB/backend/ADODB_mssqlnative.php @@ -27,7 +27,7 @@ extends WikiDB_backend_ADODB $this->_prefix = isset($dbparams['prefix']) ? $dbparams['prefix'] : ''; } - + /** * Pack tables. */ @@ -49,7 +49,7 @@ extends WikiDB_backend_ADODB function _fullsearch_sql_match_clause($word) { $word = preg_replace('/(?=[%_\\\\])/', "\\", $word); $wordq = $this->_dbh->qstr("%$word%"); - return "LOWER(pagename) LIKE $wordq " + return "LOWER(pagename) LIKE $wordq " . "OR CHARINDEX(content, '$word') > 0"; } @@ -70,7 +70,7 @@ extends WikiDB_backend_ADODB return empty($data) ? array() : unserialize(stripslashes($data)); } - /* + /* * Update link table. * on DEBUG: delete old, deleted links from page */ @@ -94,7 +94,7 @@ extends WikiDB_backend_ADODB $linkto = $link['linkto']; if (isset($link['relation'])) $relation = $this->_get_pageid($link['relation'], true); - else + else $relation = 0; if ($linkto === "") { // ignore attributes continue; @@ -111,13 +111,13 @@ extends WikiDB_backend_ADODB if ($relation) { $dbh->Execute("INSERT INTO $link_tbl (linkfrom, linkto, relation)" . " VALUES ($pageid, $linkid, $relation)"); - } else { + } else { $dbh->Execute("INSERT INTO $link_tbl (linkfrom, linkto)" . " VALUES ($pageid, $linkid)"); } if ($oldlinks and array_key_exists($linkid, $oldlinks)) { // This was also in the previous page - unset($oldlinks[$linkid]); + unset($oldlinks[$linkid]); } } } @@ -172,7 +172,7 @@ extends WikiDB_backend_ADODB $linkto = $link['linkto']; if ($link['relation']) $relation = $this->_get_pageid($link['relation'], true); - else + else $relation = 0; // avoid duplicates if (isset($linkseen[$linkto]) and !$relation) { @@ -199,7 +199,7 @@ extends WikiDB_backend_ADODB if ($relation) { $dbh->Execute("INSERT INTO $link_tbl (linkfrom, linkto, relation)" . " VALUES ($pageid, $linkid, $relation)"); - } else { + } else { $dbh->Execute("INSERT INTO $link_tbl (linkfrom, linkto)" . " VALUES ($pageid, $linkid)"); } @@ -207,7 +207,7 @@ extends WikiDB_backend_ADODB if (array_key_exists($linkid, $oldlinks)) { // This was also in the previous page - unset($oldlinks[$linkid]); + unset($oldlinks[$linkid]); } } } @@ -223,7 +223,7 @@ extends WikiDB_backend_ADODB . " LEFT JOIN $version_tbl ON ($version_tbl.id = $page_tbl.id)"//'"id" is not a recognized table hints option' . " WHERE $nonempty_tbl.id is NULL" . " AND $version_tbl.id is NULL" - . " AND $page_tbl.id=$id")) + . " AND $page_tbl.id=$id")) { trigger_error("delete empty and non-referenced link $name ($id)", E_USER_NOTICE); $dbh->Execute("DELETE FROM $page_tbl WHERE id=$id"); // this purges the link @@ -234,16 +234,15 @@ extends WikiDB_backend_ADODB } $this->unlock(array('link')); return true; - } - + } + }; -// (c-file-style: "gnu") // Local Variables: // mode: php // tab-width: 8 // c-basic-offset: 4 // c-hanging-comment-ender-p: nil // indent-tabs-mode: nil -// End: +// End: ?> diff --git a/lib/WikiDB/backend/ADODB_mysql.php b/lib/WikiDB/backend/ADODB_mysql.php index 789136d65..d9a8e252a 100644 --- a/lib/WikiDB/backend/ADODB_mysql.php +++ b/lib/WikiDB/backend/ADODB_mysql.php @@ -4,16 +4,16 @@ require_once('lib/WikiDB/backend/ADODB.php'); /* - * PROBLEM: mysql seems to be the simpliest (or most stupid) db on earth. + * PROBLEM: mysql seems to be the simpliest (or most stupid) db on earth. * (tested with 4.0.18) * See http://sql-info.de/mysql/gotchas.html for mysql specific quirks. * - * Whenever a table is write-locked, you cannot even write to other unrelated + * Whenever a table is write-locked, you cannot even write to other unrelated * tables. So it seems that we have to lock all tables! - * As workaround we try it with application locks, uniquely named locks, + * As workaround we try it with application locks, uniquely named locks, * to prevent from concurrent writes of locks with the same name. * The lock name is a strcat of the involved tables. - * + * * See also http://use.perl.org/~Smylers/journal/34246 for strict mode and warnings. */ define('DO_APP_LOCK',true); @@ -21,10 +21,10 @@ define('DO_FULL_LOCK',false); /** * WikiDB layer for ADODB-mysql, called by lib/WikiDB/ADODB.php. - * Now with support for the newer ADODB library, the ADODB extension library + * Now with support for the newer ADODB library, the ADODB extension library * and more database drivers. * To use transactions use the mysqlt driver: "mysqlt:..." - * + * * @author: Lawrence Akka, Reini Urban */ class WikiDB_backend_ADODB_mysql @@ -36,7 +36,7 @@ extends WikiDB_backend_ADODB function WikiDB_backend_ADODB_mysql($dbparams) { $this->WikiDB_backend_ADODB($dbparams); if (!$this->_dbh->_connectionID) return; - + $this->_serverinfo = $this->_dbh->ServerInfo(); if (!empty($this->_serverinfo['version'])) { $arr = explode('.',$this->_serverinfo['version']); @@ -62,20 +62,20 @@ extends WikiDB_backend_ADODB } } } - + /** * Kill timed out processes. ( so far only called on about every 50-th save. ) */ function _timeout() { if (empty($this->_dbparams['timeout'])) return; $result = mysql_query("SHOW processlist"); - while ($row = mysql_fetch_array($result)) { + while ($row = mysql_fetch_array($result)) { if ($row["db"] == $this->_dsn['database'] and $row["User"] == $this->_dsn['username'] and $row["Time"] > $this->_dbparams['timeout'] and $row["Command"] == "Sleep") { - $process_id = $row["Id"]; + $process_id = $row["Id"]; mysql_query("KILL $process_id"); } } @@ -94,8 +94,8 @@ extends WikiDB_backend_ADODB } /** - * Lock tables. As fine-grained application lock, which locks only the - * same transaction (conflicting updates and edits), and as full table + * Lock tables. As fine-grained application lock, which locks only the + * same transaction (conflicting updates and edits), and as full table * write lock. * * New: which tables as params, @@ -109,7 +109,7 @@ extends WikiDB_backend_ADODB if (!$result or $result[0] == 0) { trigger_error( "WARNING: Couldn't obtain application lock " . $lock . "\n
", E_USER_WARNING); - return; + return; } } if (DO_FULL_LOCK) { @@ -166,7 +166,7 @@ extends WikiDB_backend_ADODB return $cache[$pagename]; } } - + // attributes play this game. if ($pagename === '') return 0; @@ -199,10 +199,10 @@ extends WikiDB_backend_ADODB function set_versiondata($pagename, $version, $data) { $dbh = &$this->_dbh; $version_tbl = $this->_table_names['version_tbl']; - + $minor_edit = (int) !empty($data['is_minor_edit']); unset($data['is_minor_edit']); - + $mtime = (int)$data['mtime']; unset($data['mtime']); assert(!empty($mtime)); @@ -210,7 +210,7 @@ extends WikiDB_backend_ADODB @$content = (string) $data['%content']; unset($data['%content']); unset($data['%pagedata']); - + $this->lock(array('page','recent','version','nonempty')); $dbh->BeginTrans( ); $dbh->CommitLock($version_tbl); @@ -229,15 +229,14 @@ extends WikiDB_backend_ADODB else $dbh->RollbackTrans( ); $this->unlock(array('page','recent','version','nonempty')); } - + }; -// (c-file-style: "gnu") // Local Variables: // mode: php // tab-width: 8 // c-basic-offset: 4 // c-hanging-comment-ender-p: nil // indent-tabs-mode: nil -// End: +// End: ?> diff --git a/lib/WikiDB/backend/ADODB_oci8po.php b/lib/WikiDB/backend/ADODB_oci8po.php index 48adc0dc7..3c38f07c5 100644 --- a/lib/WikiDB/backend/ADODB_oci8po.php +++ b/lib/WikiDB/backend/ADODB_oci8po.php @@ -30,7 +30,7 @@ extends WikiDB_backend_ADODB $this->_prefix = isset($dbparams['prefix']) ? $dbparams['prefix'] : ''; } - + /** * Pack tables. */ @@ -43,7 +43,7 @@ extends WikiDB_backend_ADODB /** * Lock tables. * - * We don't really need to lock exclusive, but I'll relax it when I fully + * We don't really need to lock exclusive, but I'll relax it when I fully * understand phpWiki locking ;-) * */ @@ -92,11 +92,11 @@ extends WikiDB_backend_ADODB function _fullsearch_sql_match_clause($word) { $word = preg_replace('/(?=[%_\\\\])/', "\\", $word); $wordq = $this->_dbh->qstr("%$word%"); - return "LOWER(pagename) LIKE $wordq " + return "LOWER(pagename) LIKE $wordq " . "OR DBMS_LOB.INSTR(content, '$word') > 0"; } */ - + /** * Serialize data */ @@ -132,14 +132,14 @@ extends WikiDB_backend_ADODB // Problem: date formats are backend specific. Either use unixtime as %d (long), // or the native timestamp format. date('d-M-Y H:i:s', $entry->time), - $entry->host, + $entry->host, $entry->user, - $entry->request_method, - $entry->request, - $entry->request_uri, + $entry->request_method, + $entry->request, + $entry->request_uri, $entry->request_args, - $entry->_ncsa_time($entry->time), - $entry->status, + $entry->_ncsa_time($entry->time), + $entry->status, $entry->size, $entry->referer, $entry->user_agent, @@ -155,7 +155,7 @@ extends WikiDB_backend_ADODB_search // Index on the CLOB. While it is very efficient, it requires the // Intermedia Text option, so let's stick to the 'simple' thing // Note that this does only an exact fulltext search, not using MATCH or LIKE. - function _fulltext_match_clause($node) { + function _fulltext_match_clause($node) { if ($this->isStoplisted($node)) return "1=1"; $page = $node->sql(); @@ -166,12 +166,11 @@ extends WikiDB_backend_ADODB_search } } -// (c-file-style: "gnu") // Local Variables: // mode: php // tab-width: 8 // c-basic-offset: 4 // c-hanging-comment-ender-p: nil // indent-tabs-mode: nil -// End: -?> \ No newline at end of file +// End: +?> diff --git a/lib/WikiDB/backend/ADODB_postgres7.php b/lib/WikiDB/backend/ADODB_postgres7.php index 800ff1ce6..65a1f1763 100644 --- a/lib/WikiDB/backend/ADODB_postgres7.php +++ b/lib/WikiDB/backend/ADODB_postgres7.php @@ -9,10 +9,10 @@ if (!defined("USE_BYTEA")) // see schemas/psql-initialize.sql /** * WikiDB layer for ADODB-postgres (7 or 8), called by lib/WikiDB/ADODB.php. - * Changes 1.3.12: + * Changes 1.3.12: * - use Foreign Keys and ON DELETE CASCADE. * - bytea blob type - * + * * @author: Reini Urban */ class WikiDB_backend_ADODB_postgres7 @@ -83,7 +83,7 @@ extends WikiDB_backend_ADODB $dbh->Execute(sprintf("UPDATE $page_tbl" . " SET cached_html='%s'" . " WHERE pagename=%s", - $this->_quote($data), + $this->_quote($data), $dbh->qstr($pagename))); */ } else { @@ -141,12 +141,12 @@ extends WikiDB_backend_ADODB_search function _pagename_match_clause($node) { $word = $node->sql(); if ($node->op == 'REGEX') { // posix regex extensions - return ($this->_case_exact + return ($this->_case_exact ? "pagename ~* '$word'" : "pagename ~ '$word'"); } else { - return ($this->_case_exact - ? "pagename LIKE '$word'" + return ($this->_case_exact + ? "pagename LIKE '$word'" : "pagename ILIKE '$word'"); } } @@ -155,12 +155,11 @@ extends WikiDB_backend_ADODB_search //function _fulltext_match_clause($node) } -// (c-file-style: "gnu") // Local Variables: // mode: php // tab-width: 8 // c-basic-offset: 4 // c-hanging-comment-ender-p: nil // indent-tabs-mode: nil -// End: +// End: ?> diff --git a/lib/WikiDB/backend/ADODB_sqlite.php b/lib/WikiDB/backend/ADODB_sqlite.php index e9ae3102c..0184ad871 100644 --- a/lib/WikiDB/backend/ADODB_sqlite.php +++ b/lib/WikiDB/backend/ADODB_sqlite.php @@ -6,7 +6,7 @@ require_once('lib/WikiDB/backend/ADODB.php'); /** * WikiDB layer for ADODB-sqlite, called by lib/WikiDB/ADODB.php. * Just to create a not existing database. - * + * * @author: Reini Urban */ class WikiDB_backend_ADODB_sqlite @@ -26,7 +26,7 @@ extends WikiDB_backend_ADODB } $this->WikiDB_backend_ADODB($dbparams); } - + function _get_pageid($pagename, $create_if_missing = false) { $dbh = &$this->_dbh; $page_tbl = $this->_table_names['page_tbl']; @@ -41,7 +41,7 @@ extends WikiDB_backend_ADODB $row = $dbh->GetRow($query); if (! $row ) { - // atomic version + // atomic version // TODO: we have auto-increment since sqlite-2.3.4 // http://www.sqlite.org/faq.html#q1 $rs = $dbh->Execute(sprintf("INSERT INTO $page_tbl" @@ -56,12 +56,11 @@ extends WikiDB_backend_ADODB } }; -// (c-file-style: "gnu") // Local Variables: // mode: php // tab-width: 8 // c-basic-offset: 4 // c-hanging-comment-ender-p: nil // indent-tabs-mode: nil -// End: +// End: ?> diff --git a/lib/WikiDB/backend/PDO.php b/lib/WikiDB/backend/PDO.php index 23f493408..8dad7a2d1 100644 --- a/lib/WikiDB/backend/PDO.php +++ b/lib/WikiDB/backend/PDO.php @@ -19,7 +19,7 @@ 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 -*/ +*/ /** * @author: Reini Urban @@ -75,8 +75,8 @@ extends WikiDB_backend $this->_parsedDSN[$option] = $value; } } - $this->_dbh->database = isset($this->_parsedDSN['database']) - ? $this->_parsedDSN['database'] + $this->_dbh->database = isset($this->_parsedDSN['database']) + ? $this->_parsedDSN['database'] : $this->_parsedDSN['dbname']; } if (empty($this->_parsedDSN['password'])) $this->_parsedDSN['password'] = ''; @@ -85,15 +85,15 @@ extends WikiDB_backend // try to load it dynamically (unix only) if (!loadPhpExtension("pdo_$driver")) { echo $GLOBALS['php_errormsg'], "
\n"; - trigger_error(sprintf("dl() problem: Required extension '%s' could not be loaded!", + trigger_error(sprintf("dl() problem: Required extension '%s' could not be loaded!", "pdo_$driver"), E_USER_WARNING); } // persistent is defined as DSN option, or with a config value. // phptype://username:password@hostspec/database?persistent=false - $this->_dbh = new PDO($dbparams['dsn'], - $this->_parsedDSN['username'], + $this->_dbh = new PDO($dbparams['dsn'], + $this->_parsedDSN['username'], $this->_parsedDSN['password'], array(PDO_ATTR_AUTOCOMMIT => true, PDO_ATTR_TIMEOUT => DATABASE_TIMEOUT, @@ -111,7 +111,7 @@ extends WikiDB_backend if (isset($dbparams['_tryroot_from_upgrade'])) trigger_error(sprintf("Can't connect to database: %s", $e->getMessage()), E_USER_WARNING); - else + else exit(); } if (DEBUG & _DEBUG_SQL) { // not yet implemented @@ -184,7 +184,7 @@ extends WikiDB_backend $sth = $this->_dbh->prepare($sql); if ($sth->execute()) return $sth->fetch(PDO_FETCH_BOTH); - else + else return false; } @@ -195,7 +195,7 @@ extends WikiDB_backend if (!$this->_dbh) return; if ($this->_lock_count) { - trigger_error("WARNING: database still locked " . + trigger_error("WARNING: database still locked " . '(lock_count = $this->_lock_count)' . "\n
", E_USER_WARNING); } @@ -220,7 +220,7 @@ extends WikiDB_backend else return false; } - + function get_all_pagenames() { $dbh = &$this->_dbh; extract($this->_table_names); @@ -267,7 +267,7 @@ extends WikiDB_backend function _extract_page_data($data, $hits) { if (empty($data)) return array('hits' => $hits); - else + else return array_merge(array('hits' => $hits), $this->_unserialize($data)); } @@ -292,7 +292,7 @@ extends WikiDB_backend $data = array(); $this->_get_pageid($pagename, true); // Creates page record } - + $hits = (empty($data['hits'])) ? 0 : (int)$data['hits']; unset($data['hits']); @@ -354,7 +354,7 @@ extends WikiDB_backend // attributes play this game. if ($pagename === '') return 0; - + $dbh = &$this->_dbh; $page_tbl = $this->_table_names['page_tbl']; $sth = $dbh->prepare("SELECT id FROM $page_tbl WHERE pagename=? LIMIT 1"); @@ -386,7 +386,7 @@ extends WikiDB_backend $sth->bindParam(2, $pagename, PDO_PARAM_STR, 100); if ($sth->execute()) $this->commit(); - else + else $this->rollBack(); } } @@ -422,7 +422,7 @@ extends WikiDB_backend $sth->execute(); return $sth->fetchSingle(); } - + /** * Get version data. * @@ -435,10 +435,10 @@ extends WikiDB_backend $dbh = &$this->_dbh; extract($this->_table_names); extract($this->_expressions); - + assert(is_string($pagename) and $pagename != ''); assert($version > 0); - + // FIXME: optimization: sometimes don't get page data? if ($want_content) { $fields = $this->page_tbl_fields . ", $page_tbl.pagedata AS pagedata" @@ -508,10 +508,10 @@ extends WikiDB_backend function set_versiondata($pagename, $version, $data) { $dbh = &$this->_dbh; $version_tbl = $this->_table_names['version_tbl']; - + $minor_edit = (int) !empty($data['is_minor_edit']); unset($data['is_minor_edit']); - + $mtime = (int)$data['mtime']; unset($data['mtime']); assert(!empty($mtime)); @@ -519,7 +519,7 @@ extends WikiDB_backend @$content = (string) $data['%content']; unset($data['%content']); unset($data['%pagedata']); - + $this->lock(array('page','recent','version','nonempty')); $this->beginTransaction(); $id = $this->_get_pageid($pagename, true); @@ -559,7 +559,7 @@ extends WikiDB_backend else $this->rollBack( ); $this->unlock(array('page','recent','version','nonempty')); } - + /** * Delete an old revision of a page. */ @@ -582,10 +582,10 @@ extends WikiDB_backend /** * Delete page from the database with backup possibility. * i.e save_page('') and DELETE nonempty id - * - * deletePage increments latestversion in recent to a non-existent version, + * + * deletePage increments latestversion in recent to a non-existent version, * and removes the nonempty row, - * so that get_latest_version returns id+1 and get_previous_version returns prev id + * so that get_latest_version returns id+1 and get_previous_version returns prev id * and page->exists returns false. */ function delete_page($pagename) { @@ -606,7 +606,7 @@ extends WikiDB_backend $this->lock(array('version','recent','nonempty','page','link')); $version = $this->get_latest_version($pagename); if ($dbh->query("UPDATE $recent_tbl SET latestversion=latestversion+1," - . "latestmajor=latestversion+1,latestminor=NULL WHERE id=$id")) + . "latestmajor=latestversion+1,latestminor=NULL WHERE id=$id")) { $insert = $dbh->prepare("INSERT INTO $version_tbl" . " (id,version,mtime,minor_edit,content,versiondata)" @@ -620,16 +620,16 @@ extends WikiDB_backend if ($insert->execute() and $dbh->query("DELETE FROM $nonempty_tbl WHERE id=$id") and $this->set_links($pagename, false)) { - // need to keep perms and LOCKED, otherwise you can reset the perm + // need to keep perms and LOCKED, otherwise you can reset the perm // by action=remove and re-create it with default perms - // keep hits but delete meta-data - //and $dbh->Execute("UPDATE $page_tbl SET pagedata='' WHERE id=$id") + // keep hits but delete meta-data + //and $dbh->Execute("UPDATE $page_tbl SET pagedata='' WHERE id=$id") $this->unlock(array('version','recent','nonempty','page','link')); $this->commit(); return true; } } else { - $this->unlock(array('version','recent','nonempty','page','link')); + $this->unlock(array('version','recent','nonempty','page','link')); $this->rollBack(); return false; } @@ -638,7 +638,7 @@ extends WikiDB_backend function purge_page($pagename) { $dbh = &$this->_dbh; extract($this->_table_names); - + $this->lock(array('version','recent','nonempty','page','link')); if ( ($id = $this->_get_pageid($pagename, false)) ) { $dbh->query("DELETE FROM $version_tbl WHERE id=$id"); @@ -716,7 +716,7 @@ extends WikiDB_backend $this->unlock(array('link')); return true; } - + /** * Find pages which link to or are linked from a page. * @@ -737,7 +737,7 @@ extends WikiDB_backend if ($orderby) $orderby = " ORDER BY $want." . $orderby; if ($exclude) // array of pagenames $exclude = " AND $want.pagename NOT IN ".$this->_sql_set($exclude); - else + else $exclude=''; $limit = $this->_limit_sql($limit); @@ -787,7 +787,7 @@ extends WikiDB_backend if ($orderby) $orderby = ' ORDER BY ' . $orderby; if ($exclude) // array of pagenames $exclude = " AND $page_tbl.pagename NOT IN ".$this->_sql_set($exclude); - else + else $exclude=''; $limit = $this->_limit_sql($limit); @@ -827,12 +827,12 @@ extends WikiDB_backend . $orderby; } } - $sth = $dbh->prepare($sql . $limit); + $sth = $dbh->prepare($sql . $limit); $sth->execute(); $result = $sth->fetch(PDO_FETCH_BOTH); return new WikiDB_backend_PDO_iter($this, $result, $this->page_tbl_field_list); } - + /** * Title search. */ @@ -848,7 +848,7 @@ extends WikiDB_backend $fields = $this->page_tbl_fields; $field_list = $this->page_tbl_field_list; $searchobj = new WikiDB_backend_PDO_search($search, $dbh); - + if ($fullsearch) { $table .= ", $recent_tbl"; $join_clause .= " AND $page_tbl.id=$recent_tbl.id"; @@ -862,7 +862,7 @@ extends WikiDB_backend } else { $callback = new WikiMethodCb($searchobj, "_pagename_match_clause"); } - + $search_clause = $search->makeSqlClauseObj($callback); $sth = $dbh->prepare("SELECT $fields FROM $table" . " WHERE $join_clause" @@ -877,8 +877,8 @@ extends WikiDB_backend } /* - * TODO: efficiently handle wildcards exclusion: exclude=Php* => 'Php%', - * not sets. See above, but the above methods find too much. + * TODO: efficiently handle wildcards exclusion: exclude=Php* => 'Php%', + * not sets. See above, but the above methods find too much. * This is only for already resolved wildcards: * " WHERE $page_tbl.pagename NOT IN ".$this->_sql_set(array('page1','page2')); */ @@ -897,8 +897,8 @@ extends WikiDB_backend $dbh = &$this->_dbh; extract($this->_table_names); $order = "DESC"; - if ($limit < 0){ - $order = "ASC"; + if ($limit < 0){ + $order = "ASC"; $limit = -$limit; $where = ""; } else { @@ -909,7 +909,7 @@ extends WikiDB_backend else $orderby = ""; } else $orderby = " ORDER BY hits $order"; - $sql = "SELECT " + $sql = "SELECT " . $this->page_tbl_fields . " FROM $nonempty_tbl, $page_tbl" . " WHERE $nonempty_tbl.id=$page_tbl.id" @@ -942,7 +942,7 @@ extends WikiDB_backend $pick = array(); if ($since) $pick[] = "mtime >= $since"; - + if ($include_all_revisions) { // Include all revisions of each page. $table = "$page_tbl, $version_tbl"; @@ -962,7 +962,7 @@ extends WikiDB_backend $join_clause = "$page_tbl.id=$recent_tbl.id"; $table .= ", $version_tbl"; $join_clause .= " AND $version_tbl.id=$page_tbl.id"; - + if ($exclude_major_revisions) { // Include only most recent minor revision $pick[] = 'version=latestminor'; @@ -996,7 +996,7 @@ extends WikiDB_backend } $sth->execute(); $result = $sth->fetch(PDO_FETCH_NUM); - return new WikiDB_backend_PDO_iter($this, $result, + return new WikiDB_backend_PDO_iter($this, $result, array_merge($this->page_tbl_field_list, $this->version_tbl_field_list)); } @@ -1008,24 +1008,24 @@ extends WikiDB_backend extract($this->_table_names); if ($orderby = $this->sortby($sortby, 'db', array('pagename','wantedfrom'))) $orderby = 'ORDER BY ' . $orderby; - + if ($exclude_from) // array of pagenames $exclude_from = " AND linked.pagename NOT IN ".$this->_sql_set($exclude_from); if ($exclude) // array of pagenames $exclude = " AND $page_tbl.pagename NOT IN ".$this->_sql_set($exclude); - /* + /* all empty pages, independent of linkstatus: select pagename as empty from page left join nonempty using(id) where isnull(nonempty.id); only all empty pages, which have a linkto: - select page.pagename, linked.pagename as wantedfrom from link, page as linked - left join page on(link.linkto=page.id) left join nonempty on(link.linkto=nonempty.id) - where isnull(nonempty.id) and linked.id=link.linkfrom; + select page.pagename, linked.pagename as wantedfrom from link, page as linked + left join page on(link.linkto=page.id) left join nonempty on(link.linkto=nonempty.id) + where isnull(nonempty.id) and linked.id=link.linkfrom; */ $sql = "SELECT p.pagename, pp.pagename as wantedfrom" . " FROM $page_tbl p JOIN $link_tbl linked" . " LEFT JOIN $page_tbl pp ON linked.linkto = pp.id" - . " LEFT JOIN $nonempty_tbl ne ON linked.linkto = ne.id" + . " LEFT JOIN $nonempty_tbl ne ON linked.linkto = ne.id" . " WHERE ne.id is NULL" . " AND p.id = linked.linkfrom" . $exclude_from @@ -1047,7 +1047,7 @@ extends WikiDB_backend function rename_page($pagename, $to) { $dbh = &$this->_dbh; extract($this->_table_names); - + $this->lock(array('page','version','recent','nonempty','link')); if ( ($id = $this->_get_pageid($pagename, false)) ) { if ($new = $this->_get_pageid($to, false)) { @@ -1153,7 +1153,7 @@ extends WikiDB_backend } $this->_dbh->query("LOCK TABLES " . join(",", $locks)); } - + /** * Release a write lock on the tables in the SQL database. * @@ -1222,7 +1222,7 @@ extends WikiDB_backend } /* - * LIMIT with OFFSET is not SQL specified. + * LIMIT with OFFSET is not SQL specified. * mysql: LIMIT $offset, $count * pgsql,sqlite: LIMIT $count OFFSET $offset * InterBase,FireBird: ROWS $offset TO $last @@ -1242,10 +1242,10 @@ extends WikiDB_backend if ($limit) { list($offset, $count) = $this->limit($limit); if ($offset) { - $limit = " LIMIT $count"; + $limit = " LIMIT $count"; trigger_error("unsupported OFFSET in SQL ignored", E_USER_WARNING); } else - $limit = " LIMIT $count"; + $limit = " LIMIT $count"; } else $limit = ''; return $limit; @@ -1286,7 +1286,7 @@ extends WikiDB_backend_iterator $this->_result = $query_result; //$this->_fields = $field_list; } - + function count() { if (!is_object($this->_result)) { return false; @@ -1491,12 +1491,11 @@ class WikiDB_backend_PDO_search extends WikiDB_backend_search_sql {} return $parsed; } -// (c-file-style: "gnu") // Local Variables: // mode: php // tab-width: 8 // c-basic-offset: 4 // c-hanging-comment-ender-p: nil // indent-tabs-mode: nil -// End: +// End: ?> diff --git a/lib/WikiDB/backend/PDO_mysql.php b/lib/WikiDB/backend/PDO_mysql.php index afa50f220..fa3d711fb 100644 --- a/lib/WikiDB/backend/PDO_mysql.php +++ b/lib/WikiDB/backend/PDO_mysql.php @@ -19,7 +19,7 @@ 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 -*/ +*/ /** * @author: Reini Urban @@ -68,13 +68,13 @@ extends WikiDB_backend_PDO if (empty($this->_dbparams['timeout'])) return; $sth = $this->_dbh->prepare("SHOW processlist"); if ($sth->execute()) - while ($row = $sth->fetch(PDO_FETCH_ASSOC)) { + while ($row = $sth->fetch(PDO_FETCH_ASSOC)) { if ($row["db"] == $this->_dsn['database'] and $row["User"] == $this->_dsn['username'] and $row["Time"] > $this->_dbparams['timeout'] and $row["Command"] == "Sleep") { - $process_id = $row["Id"]; + $process_id = $row["Id"]; $this->query("KILL $process_id"); } } @@ -107,7 +107,7 @@ extends WikiDB_backend_PDO $dsn = preg_replace("/dbname=\w+;/", "dbname=".$database, $this->_dsn); $dsn = preg_replace("/database=\w+;/", "database=".$database, $dsn); $conn = new PDO($dsn, - DBADMIN_USER ? DBADMIN_USER : $this->_parsedDSN['username'], + DBADMIN_USER ? DBADMIN_USER : $this->_parsedDSN['username'], DBADMIN_PASSWD ? DBADMIN_PASSWD : $this->_parsedDSN['password']); } catch (PDOException $e) { @@ -122,7 +122,7 @@ extends WikiDB_backend_PDO $sth = $conn->prepare("SHOW COLUMNS FROM $table"); $sth->execute(); $field_list = array(); - while ($row = $sth->fetch(PDO_FETCH_NUM)) { + while ($row = $sth->fetch(PDO_FETCH_NUM)) { $field_list[] = $row[0]; } if ($database != $old_db) { @@ -140,9 +140,9 @@ extends WikiDB_backend_PDO list($offset, $count) = $this->limit($limit); if ($offset) // pgsql needs "LIMIT $count OFFSET $from" - $limit = " LIMIT $offset, $count"; + $limit = " LIMIT $offset, $count"; else - $limit = " LIMIT $count"; + $limit = " LIMIT $count"; } else $limit = ''; return $limit; @@ -150,12 +150,11 @@ extends WikiDB_backend_PDO } -// (c-file-style: "gnu") // Local Variables: // mode: php // tab-width: 8 // c-basic-offset: 4 // c-hanging-comment-ender-p: nil // indent-tabs-mode: nil -// End: +// End: ?> diff --git a/lib/WikiDB/backend/PDO_oci8.php b/lib/WikiDB/backend/PDO_oci8.php index fd55a3e74..60120a92a 100644 --- a/lib/WikiDB/backend/PDO_oci8.php +++ b/lib/WikiDB/backend/PDO_oci8.php @@ -19,7 +19,7 @@ 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 -*/ +*/ /** * @author: Reini Urban @@ -41,7 +41,7 @@ extends WikiDB_backend_PDO */ function _lock_tables($write_lock=true) { $dbh = &$this->_dbh; - + // Not sure if we really need to lock tables here, the Oracle row // locking mechanism should be more than enough // For the time being, lets stay on the safe side and lock... @@ -87,12 +87,11 @@ extends WikiDB_backend_PDO } } -// (c-file-style: "gnu") // Local Variables: // mode: php // tab-width: 8 // c-basic-offset: 4 // c-hanging-comment-ender-p: nil // indent-tabs-mode: nil -// End: +// End: ?> diff --git a/lib/WikiDB/backend/PDO_pgsql.php b/lib/WikiDB/backend/PDO_pgsql.php index c5d0176a4..ea47bc8f2 100644 --- a/lib/WikiDB/backend/PDO_pgsql.php +++ b/lib/WikiDB/backend/PDO_pgsql.php @@ -19,7 +19,7 @@ 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 -*/ +*/ /** * @author: Reini Urban @@ -37,9 +37,9 @@ extends WikiDB_backend_PDO if ($limit) { list($offset, $count) = $this->limit($limit); if ($offset) - $limit = " LIMIT $count OFFSET $from"; + $limit = " LIMIT $count OFFSET $from"; else - $limit = " LIMIT $count"; + $limit = " LIMIT $count"; } else $limit = ''; return $limit; @@ -50,12 +50,11 @@ extends WikiDB_backend_PDO } } -// (c-file-style: "gnu") // Local Variables: // mode: php // tab-width: 8 // c-basic-offset: 4 // c-hanging-comment-ender-p: nil // indent-tabs-mode: nil -// End: +// End: ?> diff --git a/lib/WikiDB/backend/PearDB.php b/lib/WikiDB/backend/PearDB.php index ecdad2433..359480bbe 100644 --- a/lib/WikiDB/backend/PearDB.php +++ b/lib/WikiDB/backend/PearDB.php @@ -16,7 +16,7 @@ extends WikiDB_backend @require_once('DB/common.php'); // Either our local pear copy or the system one // check the version! $name = check_php_version(5) ? "escapeSimple" : strtolower("escapeSimple"); - // TODO: apparently some Pear::Db version adds LIMIT 1,0 to getOne(), + // TODO: apparently some Pear::Db version adds LIMIT 1,0 to getOne(), // which is invalid for "select version()" if (!in_array($name, get_class_methods("DB_common"))) { $finder = new FileFinder; @@ -40,7 +40,7 @@ extends WikiDB_backend $ErrorManager->pushErrorHandler(new WikiMethodCb($this, '_pear_notice_filter')); $this->_pearerrhandler = true; } - + // Open connection to database $this->_dsn = $dbparams['dsn']; $this->_dbparams = $dbparams; @@ -59,7 +59,7 @@ extends WikiDB_backend isset($dbparams['_tryroot_from_upgrade']) // hack! ? E_USER_WARNING : E_USER_ERROR); if (isset($dbparams['_tryroot_from_upgrade'])) - return; + return; } $dbh->setErrorHandling(PEAR_ERROR_CALLBACK, array($this, '_pear_error_callback')); @@ -84,9 +84,9 @@ extends WikiDB_backend 'maxversion' => "MAX(version)", 'notempty' => "<>''", 'iscontent' => "content<>''"); - + } - + /** * Close database connection. */ @@ -120,7 +120,7 @@ extends WikiDB_backend . " AND pagename='%s'", $dbh->escapeSimple($pagename))); } - + function get_all_pagenames() { $dbh = &$this->_dbh; extract($this->_table_names); @@ -136,7 +136,7 @@ extends WikiDB_backend . " FROM $nonempty_tbl, $page_tbl" . " WHERE $nonempty_tbl.id=$page_tbl.id"); } - + function increaseHitCount($pagename) { $dbh = &$this->_dbh; // Hits is the only thing we can update in a fast manner. @@ -192,7 +192,7 @@ extends WikiDB_backend $data = array(); $this->_get_pageid($pagename, true); // Creates page record } - + $hits = !empty($data['hits']) ? (int)$data['hits'] : 0; unset($data['hits']); @@ -205,7 +205,7 @@ extends WikiDB_backend $data[$key] = $val; } - /* Portability issue -- not all DBMS supports huge strings + /* Portability issue -- not all DBMS supports huge strings * so we need to 'bind' instead of building a simple SQL statment. * Note that we do not need to escapeSimple when we bind $dbh->query(sprintf("UPDATE $page_tbl" @@ -239,7 +239,7 @@ extends WikiDB_backend } function _get_pageid($pagename, $create_if_missing = false) { - + // check id_cache global $request; $cache =& $request->_dbi->_cache->_id_cache; @@ -254,7 +254,7 @@ extends WikiDB_backend $dbh = &$this->_dbh; $page_tbl = $this->_table_names['page_tbl']; - + $query = sprintf("SELECT id FROM $page_tbl WHERE pagename='%s'", $dbh->escapeSimple($pagename)); @@ -291,7 +291,7 @@ extends WikiDB_backend function get_previous_version($pagename, $version) { $dbh = &$this->_dbh; extract($this->_table_names); - + return (int)$dbh->getOne(sprintf("SELECT version" . " FROM $version_tbl, $page_tbl" @@ -305,7 +305,7 @@ extends WikiDB_backend $dbh->escapeSimple($pagename), $version)); } - + /** * Get version data. * @@ -321,12 +321,12 @@ extends WikiDB_backend assert(is_string($pagename) and $pagename != ""); assert($version > 0); - + //trigger_error("GET_REVISION $pagename $version $want_content", E_USER_NOTICE); // FIXME: optimization: sometimes don't get page data? if ($want_content) { - $fields = $this->page_tbl_fields - . ",$page_tbl.pagedata as pagedata," + $fields = $this->page_tbl_fields + . ",$page_tbl.pagedata as pagedata," . $this->version_tbl_fields; } else { @@ -354,14 +354,14 @@ extends WikiDB_backend This could be done here or in upgrade. */ if (!strstr($query_result['versiondata'], ":")) { - $query_result['versiondata'] = + $query_result['versiondata'] = base64_decode($query_result['versiondata']); } $data = $this->_unserialize($query_result['versiondata']); - + $data['mtime'] = $query_result['mtime']; $data['is_minor_edit'] = !empty($query_result['minor_edit']); - + if (isset($query_result['content'])) $data['%content'] = $query_result['content']; elseif ($query_result['have_content']) @@ -387,10 +387,10 @@ extends WikiDB_backend function set_versiondata($pagename, $version, $data) { $dbh = &$this->_dbh; $version_tbl = $this->_table_names['version_tbl']; - + $minor_edit = (int) !empty($data['is_minor_edit']); unset($data['is_minor_edit']); - + $mtime = (int)$data['mtime']; unset($data['mtime']); assert(!empty($mtime)); @@ -399,7 +399,7 @@ extends WikiDB_backend unset($data['%content']); unset($data['%pagedata']); - + $this->lock(); $id = $this->_get_pageid($pagename, true); @@ -415,10 +415,10 @@ extends WikiDB_backend $this->_update_recent_table($id); $this->_update_nonempty_table($id); - + $this->unlock(); } - + /** * Delete an old revision of a page. */ @@ -469,7 +469,7 @@ extends WikiDB_backend function purge_page($pagename) { $dbh = &$this->_dbh; extract($this->_table_names); - + $this->lock(); if ( ($id = $this->_get_pageid($pagename, false)) ) { $dbh->query("DELETE FROM $nonempty_tbl WHERE id=$id"); @@ -522,7 +522,7 @@ extends WikiDB_backend } if (isset($link['relation'])) $relation = $this->_get_pageid($link['relation'], true); - else + else $relation = 0; // avoid duplicates if (isset($linkseen[$linkto]) and !$relation) @@ -543,16 +543,16 @@ extends WikiDB_backend } $this->unlock(); } - + /** * Find pages which link to or are linked from a page. * - * TESTME relations: get_links is responsible to add the relation to the pagehash - * as 'linkrelation' key as pagename. See WikiDB_PageIterator::next + * TESTME relations: get_links is responsible to add the relation to the pagehash + * as 'linkrelation' key as pagename. See WikiDB_PageIterator::next * if (isset($next['linkrelation'])) */ function get_links($pagename, $reversed=true, $include_empty=false, - $sortby='', $limit='', $exclude='', + $sortby='', $limit='', $exclude='', $want_relations = false) { $dbh = &$this->_dbh; @@ -566,7 +566,7 @@ extends WikiDB_backend if ($orderby) $orderby = " ORDER BY $want." . $orderby; if ($exclude) // array of pagenames $exclude = " AND $want.pagename NOT IN ".$this->_sql_set($exclude); - else + else $exclude=''; $qpagename = $dbh->escapeSimple($pagename); @@ -589,7 +589,7 @@ extends WikiDB_backend } else { $result = $dbh->query($sql); } - + return new WikiDB_backend_PearDB_iter($this, $result); } @@ -621,7 +621,7 @@ extends WikiDB_backend if ($orderby) $orderby = ' ORDER BY ' . $orderby; if ($exclude) // array of pagenames $exclude = " AND $page_tbl.pagename NOT IN ".$this->_sql_set($exclude); - else + else $exclude=''; if (strstr($orderby, 'mtime ')) { // multiple columns possible @@ -647,7 +647,7 @@ extends WikiDB_backend } else { if ($include_empty) { $sql = "SELECT " - . $this->page_tbl_fields + . $this->page_tbl_fields ." FROM $page_tbl" . ($exclude ? " WHERE $exclude" : '') . $orderby; @@ -672,13 +672,13 @@ extends WikiDB_backend } return new WikiDB_backend_PearDB_iter($this, $result, $options); } - + /** * Title search. * Todo: exclude */ - function text_search($search, $fulltext=false, $sortby='', $limit='', - $exclude='') + function text_search($search, $fulltext=false, $sortby='', $limit='', + $exclude='') { $dbh = &$this->_dbh; extract($this->_table_names); @@ -691,7 +691,7 @@ extends WikiDB_backend if (!class_exists($searchclass)) $searchclass = "WikiDB_backend_PearDB_search"; $searchobj = new $searchclass($search, $dbh); - + $table = "$nonempty_tbl, $page_tbl"; $join_clause = "$nonempty_tbl.id=$page_tbl.id"; $fields = $this->page_tbl_fields; @@ -709,7 +709,7 @@ extends WikiDB_backend $callback = new WikiMethodCb($searchobj, "_pagename_match_clause"); } $search_clause = $search->makeSqlClauseObj($callback); - + $sql = "SELECT $fields FROM $table" . " WHERE $join_clause" . " AND ($search_clause)" @@ -720,7 +720,7 @@ extends WikiDB_backend } else { $result = $dbh->query($sql); } - + $iter = new WikiDB_backend_PearDB_iter($this, $result); $iter->stoplisted = @$searchobj->stoplisted; return $iter; @@ -761,10 +761,10 @@ extends WikiDB_backend function most_popular($limit=20, $sortby='-hits') { $dbh = &$this->_dbh; extract($this->_table_names); - if ($limit < 0){ + if ($limit < 0){ $order = "hits ASC"; $limit = -$limit; - $where = ""; + $where = ""; } else { $order = "hits DESC"; $where = " AND hits > 0"; @@ -780,7 +780,7 @@ extends WikiDB_backend $sql = "SELECT " . $this->page_tbl_fields . " FROM $nonempty_tbl, $page_tbl" - . " WHERE $nonempty_tbl.id=$page_tbl.id" + . " WHERE $nonempty_tbl.id=$page_tbl.id" . $where . $orderby; if ($limit) { @@ -810,8 +810,8 @@ extends WikiDB_backend $pick = array(); if ($since) $pick[] = "mtime >= $since"; - - + + if ($include_all_revisions) { // Include all revisions of each page. $table = "$page_tbl, $version_tbl"; @@ -831,7 +831,7 @@ extends WikiDB_backend $join_clause = "$page_tbl.id=$recent_tbl.id"; $table .= ", $version_tbl"; $join_clause .= " AND $version_tbl.id=$page_tbl.id"; - + if ($exclude_major_revisions) { // Include only most recent minor revision $pick[] = 'version=latestminor'; @@ -856,7 +856,7 @@ extends WikiDB_backend $where_clause .= " AND " . join(" AND ", $pick); // FIXME: use SQL_BUFFER_RESULT for mysql? - $sql = "SELECT " + $sql = "SELECT " . $this->page_tbl_fields . ", " . $this->version_tbl_fields . " FROM $table" . " WHERE $where_clause" @@ -916,7 +916,7 @@ extends WikiDB_backend function rename_page ($pagename, $to) { $dbh = &$this->_dbh; extract($this->_table_names); - + $this->lock(); if (($id = $this->_get_pageid($pagename, false)) ) { if ($new = $this->_get_pageid($to, false)) { @@ -976,7 +976,7 @@ extends WikiDB_backend //. " AND content<>''" . " AND content $notempty" . ( $pageid ? " AND $recent_tbl.id=$pageid" : "")); - + $this->unlock(); } @@ -1000,7 +1000,7 @@ extends WikiDB_backend function _lock_tables($write_lock) { trigger_error("virtual", E_USER_ERROR); } - + /** * Release a write lock on the tables in the SQL database. * @@ -1044,7 +1044,7 @@ extends WikiDB_backend function _unserialize($data) { return empty($data) ? array() : unserialize($data); } - + /** * Callback for PEAR (DB) errors. * @@ -1055,7 +1055,7 @@ extends WikiDB_backend function _pear_error_callback($error) { if ($this->_is_false_error($error)) return; - + $this->_dbh->setErrorHandling(PEAR_ERROR_PRINT); // prevent recursive loops. $this->close(); trigger_error($this->_pear_error_message($error), E_USER_ERROR); @@ -1084,13 +1084,13 @@ extends WikiDB_backend //" <--kludge for brain-dead syntax coloring return false; } - + if (! in_array('ismanip', get_class_methods('DB'))) { // Pear shipped with PHP 4.0.4pl1 (and before, presumably) // does not have the DB::isManip method. return true; } - + if (DB::isManip($query)) { // If Pear thinks it's an isManip then it wouldn't have thrown // the error we're testing for.... @@ -1150,7 +1150,7 @@ extends WikiDB_backend $fields = array(); assert(!empty($database)); assert(!empty($table)); - $result = mysql_list_fields($database, $table, $this->_dbh->connection) or + $result = mysql_list_fields($database, $table, $this->_dbh->connection) or trigger_error(__FILE__.':'.__LINE__.' '.mysql_error(), E_USER_WARNING); if (!$result) return array(); $columns = mysql_num_fields($result); @@ -1187,7 +1187,7 @@ extends WikiDB_backend_iterator // This shouldn't happen, I thought. $backend->_pear_error_callback($query_result); } - + $this->_backend = &$backend; $this->_result = $query_result; $this->_options = $field_list; @@ -1198,7 +1198,7 @@ extends WikiDB_backend_iterator return false; return $this->_result->numRows(); } - + function next() { if (!$this->_result) return false; @@ -1208,7 +1208,7 @@ extends WikiDB_backend_iterator $this->free(); return false; } - + return $record; } @@ -1247,7 +1247,7 @@ extends WikiDB_backend_PearDB_generic_iter $this->free(); return false; } - + $pagedata = $backend->_extract_page_data($record); $rec = array('pagename' => $record['pagename'], 'pagedata' => $pagedata); @@ -1256,23 +1256,22 @@ extends WikiDB_backend_PearDB_generic_iter $rec['versiondata'] = $backend->_extract_version_data($record); $rec['version'] = $record['version']; } - + return $rec; } } -class WikiDB_backend_PearDB_search extends WikiDB_backend_search_sql +class WikiDB_backend_PearDB_search extends WikiDB_backend_search_sql { // no surrounding quotes because we know it's a string // function _quote($word) { return $this->_dbh->addq($word); } } -// (c-file-style: "gnu") // Local Variables: // mode: php // tab-width: 8 // c-basic-offset: 4 // c-hanging-comment-ender-p: nil // indent-tabs-mode: nil -// End: +// End: ?> diff --git a/lib/WikiDB/backend/PearDB_ffpgsql.php b/lib/WikiDB/backend/PearDB_ffpgsql.php index e002f4d35..b167682ff 100644 --- a/lib/WikiDB/backend/PearDB_ffpgsql.php +++ b/lib/WikiDB/backend/PearDB_ffpgsql.php @@ -109,7 +109,7 @@ extends WikiDB_backend_PearDB_pgsql $data = array(); $this->_get_pageid($pagename, true); // Creates page record } - + @$hits = (int)$data['hits']; unset($data['hits']); @@ -122,7 +122,7 @@ extends WikiDB_backend_PearDB_pgsql $data[$key] = $val; } - /* Portability issue -- not all DBMS supports huge strings + /* Portability issue -- not all DBMS supports huge strings * so we need to 'bind' instead of building a simple SQL statment. * Note that we do not need to escapeSimple when we bind $dbh->query(sprintf("UPDATE $page_tbl" @@ -155,12 +155,12 @@ extends WikiDB_backend_PearDB_pgsql // assert(is_string($pagename) and $pagename != ""); // assert($version > 0); - + //trigger_error("GET_REVISION $pagename $version $want_content", E_USER_NOTICE); // FIXME: optimization: sometimes don't get page data? if ($want_content) { - $fields = $this->page_tbl_fields - . ",$page_tbl.pagedata as pagedata," + $fields = $this->page_tbl_fields + . ",$page_tbl.pagedata as pagedata," . $this->version_tbl_fields; } else { @@ -190,7 +190,7 @@ extends WikiDB_backend_PearDB_pgsql } function _get_pageid($pagename, $create_if_missing = false) { - + // check id_cache global $request; $cache =& $request->_dbi->_cache->_id_cache; @@ -206,7 +206,7 @@ extends WikiDB_backend_PearDB_pgsql $dbh = &$this->_dbh; $page_tbl = $this->_table_names['page_tbl']; $pagename = PAGE_PREFIX.$pagename; - + $query = sprintf("SELECT id FROM $page_tbl WHERE pagename='%s'", $dbh->escapeSimple($pagename)); @@ -232,7 +232,7 @@ extends WikiDB_backend_PearDB_pgsql function purge_page($pagename) { $dbh = &$this->_dbh; extract($this->_table_names); - + $this->lock(); if ( ($id = $this->_get_pageid($pagename, false)) ) { $dbh->query("DELETE FROM $nonempty_tbl WHERE id=$id"); @@ -258,7 +258,7 @@ extends WikiDB_backend_PearDB_pgsql } function get_links($pagename, $reversed=true, $include_empty=false, - $sortby='', $limit='', $exclude='', + $sortby='', $limit='', $exclude='', $want_relations = false) { $dbh = &$this->_dbh; @@ -272,7 +272,7 @@ extends WikiDB_backend_PearDB_pgsql if ($orderby) $orderby = " ORDER BY $want." . $orderby; if ($exclude) // array of pagenames $exclude = " AND $want.pagename NOT IN ".$this->_sql_set($exclude); - else + else $exclude=''; $pat = PAGE_PREFIX; @@ -301,7 +301,7 @@ extends WikiDB_backend_PearDB_pgsql } else { $result = $dbh->query($sql); } - + return new WikiDB_backend_PearDB_iter($this, $result); } @@ -316,7 +316,7 @@ extends WikiDB_backend_PearDB_pgsql if ($orderby) $orderby = ' ORDER BY ' . $orderby; if ($exclude) // array of pagenames $exclude = " AND $page_tbl.pagename NOT IN ".$this->_sql_set($exclude); - else + else $exclude=''; if (strstr($orderby, 'mtime ')) { // multiple columns possible @@ -344,10 +344,10 @@ extends WikiDB_backend_PearDB_pgsql } else { if ($include_empty) { $sql = "SELECT " - . $this->page_tbl_fields + . $this->page_tbl_fields . " FROM $page_tbl" . ($exclude ? " WHERE $exclude" : '') - . ($exclude ? " AND " : " WHERE ") + . ($exclude ? " AND " : " WHERE ") . " substring($page_tbl.pagename from 0 for $p) = '$pat'" . $orderby; } @@ -378,10 +378,10 @@ extends WikiDB_backend_PearDB_pgsql extract($this->_table_names); $pat = PAGE_PREFIX; $p = strlen($pat)+1; - if ($limit < 0){ + if ($limit < 0){ $order = "hits ASC"; $limit = -$limit; - $where = ""; + $where = ""; } else { $order = "hits DESC"; $where = " AND hits > 0"; @@ -397,7 +397,7 @@ extends WikiDB_backend_PearDB_pgsql $sql = "SELECT " . $this->page_tbl_fields . " FROM $nonempty_tbl, $page_tbl" - . " WHERE $nonempty_tbl.id=$page_tbl.id" + . " WHERE $nonempty_tbl.id=$page_tbl.id" . " AND substring($page_tbl.pagename from 0 for $p) = '$pat'" . $where . $orderby; @@ -425,8 +425,8 @@ extends WikiDB_backend_PearDB_pgsql $pick = array(); if ($since) $pick[] = "mtime >= $since"; - - + + if ($include_all_revisions) { // Include all revisions of each page. $table = "$page_tbl, $version_tbl"; @@ -446,7 +446,7 @@ extends WikiDB_backend_PearDB_pgsql $join_clause = "$page_tbl.id=$recent_tbl.id"; $table .= ", $version_tbl"; $join_clause .= " AND $version_tbl.id=$page_tbl.id"; - + if ($exclude_major_revisions) { // Include only most recent minor revision $pick[] = 'version=latestminor'; @@ -474,7 +474,7 @@ extends WikiDB_backend_PearDB_pgsql $p = strlen($pat)+1; // FIXME: use SQL_BUFFER_RESULT for mysql? - $sql = "SELECT " + $sql = "SELECT " . $this->page_tbl_fields . ", " . $this->version_tbl_fields . " FROM $table" . " WHERE $where_clause" @@ -527,7 +527,7 @@ extends WikiDB_backend_PearDB_pgsql function rename_page ($pagename, $to) { $dbh = &$this->_dbh; extract($this->_table_names); - + $this->lock(); if (($id = $this->_get_pageid($pagename, false)) ) { if ($new = $this->_get_pageid($to, false)) { @@ -572,8 +572,8 @@ extends WikiDB_backend_PearDB_pgsql /** * Title search. */ - function text_search($search, $fulltext=false, $sortby='', $limit='', - $exclude='') + function text_search($search, $fulltext=false, $sortby='', $limit='', + $exclude='') { $dbh = &$this->_dbh; extract($this->_table_names); @@ -587,7 +587,7 @@ extends WikiDB_backend_PearDB_pgsql if (!class_exists($searchclass)) $searchclass = "WikiDB_backend_PearDB_search"; $searchobj = new $searchclass($search, $dbh); - + $table = "$nonempty_tbl, $page_tbl"; $join_clause = "$nonempty_tbl.id=$page_tbl.id"; $fields = $this->page_tbl_fields; @@ -614,7 +614,7 @@ extends WikiDB_backend_PearDB_pgsql $search_clause = "substring(plugin_wiki_page.pagename from 0 for $len) = '$pat') AND ("; $search_clause .= $search->makeSqlClauseObj($callback); } - + $sql = "SELECT $fields FROM $table" . " WHERE $join_clause" . " AND ($search_clause)" @@ -625,7 +625,7 @@ extends WikiDB_backend_PearDB_pgsql } else { $result = $dbh->query($sql); } - + $iter = new WikiDB_backend_PearDB_iter($this, $result); $iter->stoplisted = @$searchobj->stoplisted; return $iter; @@ -660,18 +660,18 @@ extends WikiDB_backend_PearDB_pgsql_search $word = pg_escape_string($word); $len = strlen(PAGE_PREFIX)+1; if ($node->op == 'REGEX') { // posix regex extensions - return ($this->_case_exact + return ($this->_case_exact ? "substring(pagename from $len) ~* '$word'" : "substring(pagename from $len) ~ '$word'"); } else { - return ($this->_case_exact - ? "substring(pagename from $len) LIKE '$word'" + return ($this->_case_exact + ? "substring(pagename from $len) LIKE '$word'" : "substring(pagename from $len) ILIKE '$word'"); } } - /** - * use tsearch2. See schemas/psql-tsearch2.sql and /usr/share/postgresql/contrib/tsearch2.sql + /** + * use tsearch2. See schemas/psql-tsearch2.sql and /usr/share/postgresql/contrib/tsearch2.sql * TODO: don't parse the words into nodes. rather replace "[ +]" with & and "-" with "!" and " or " with "|" * tsearch2 query language: @@ "word | word", "word & word", ! word * ~* '.*something that does not exist.*' @@ -696,12 +696,11 @@ extends WikiDB_backend_PearDB_pgsql_search } } -// (c-file-style: "gnu") // Local Variables: // mode: php // tab-width: 8 // c-basic-offset: 4 // c-hanging-comment-ender-p: nil // indent-tabs-mode: nil -// End: +// End: ?> diff --git a/lib/WikiDB/backend/PearDB_mysql.php b/lib/WikiDB/backend/PearDB_mysql.php index d3158a359..f3a2ae237 100644 --- a/lib/WikiDB/backend/PearDB_mysql.php +++ b/lib/WikiDB/backend/PearDB_mysql.php @@ -20,7 +20,7 @@ extends WikiDB_backend_PearDB $row = $this->_dbh->GetOne("SELECT version()"); if (!DB::isError($row) and !empty($row)) { $arr = explode('.',$row); - $this->_serverinfo['version'] = (string)(($arr[0] * 100) + $arr[1]) . + $this->_serverinfo['version'] = (string)(($arr[0] * 100) + $arr[1]) . "." . (integer)$arr[2]; if ($this->_serverinfo['version'] < 323.0) { // Older MySQL's don't have CASE WHEN ... END @@ -42,20 +42,20 @@ extends WikiDB_backend_PearDB } } } - + /** * Kill timed out processes. ( so far only called on about every 50-th save. ) */ function _timeout() { if (empty($this->_dbparams['timeout'])) return; $result = mysql_query("SHOW processlist"); - while ($row = mysql_fetch_array($result)) { + while ($row = mysql_fetch_array($result)) { if ($row["db"] == $this->_dbh->dsn['database'] and $row["User"] == $this->_dbh->dsn['username'] and $row["Time"] > $this->_dbparams['timeout'] - and $row["Command"] == "Sleep") + and $row["Command"] == "Sleep") { - $process_id = $row["Id"]; + $process_id = $row["Id"]; mysql_query("KILL $process_id"); } } @@ -67,10 +67,10 @@ extends WikiDB_backend_PearDB function set_versiondata($pagename, $version, $data) { $dbh = &$this->_dbh; $version_tbl = $this->_table_names['version_tbl']; - + $minor_edit = (int) !empty($data['is_minor_edit']); unset($data['is_minor_edit']); - + $mtime = (int)$data['mtime']; unset($data['mtime']); assert(!empty($mtime)); @@ -78,7 +78,7 @@ extends WikiDB_backend_PearDB @$content = (string) $data['%content']; unset($data['%content']); unset($data['%pagedata']); - + $this->lock(); $id = $this->_get_pageid($pagename, true); // requires PRIMARY KEY (id,version)! @@ -129,7 +129,7 @@ extends WikiDB_backend_PearDB $sql = "SELECT p.pagename, pp.pagename as wantedfrom" . " FROM $page_tbl p, $link_tbl linked" . " LEFT JOIN $page_tbl pp ON (linked.linkto = pp.id)" - . " LEFT JOIN $nonempty_tbl ne ON (linked.linkto = ne.id)" + . " LEFT JOIN $nonempty_tbl ne ON (linked.linkto = ne.id)" . " WHERE ISNULL(ne.id)" . " AND p.id = linked.linkfrom" . $exclude_from @@ -163,7 +163,7 @@ extends WikiDB_backend_PearDB . ( $pageid ? " AND $recent_tbl.id=$pageid" : "")); } */ - + /** * Pack tables. */ @@ -213,24 +213,23 @@ extends WikiDB_backend_PearDB class WikiDB_backend_PearDB_mysql_search extends WikiDB_backend_PearDB_search { - function _pagename_match_clause($node) { + function _pagename_match_clause($node) { $word = $node->sql(); if ($node->op == 'REGEX') { // posix regex extensions return "pagename REGEXP '$word'"; } else { - return ($this->_case_exact - ? "pagename LIKE '$word'" + return ($this->_case_exact + ? "pagename LIKE '$word'" : "LOWER(pagename) LIKE '$word'"); } } } -// (c-file-style: "gnu") // Local Variables: // mode: php // tab-width: 8 // c-basic-offset: 4 // c-hanging-comment-ender-p: nil // indent-tabs-mode: nil -// End: +// End: ?> diff --git a/lib/WikiDB/backend/PearDB_oci8.php b/lib/WikiDB/backend/PearDB_oci8.php index 09ec2db4d..7718d7672 100644 --- a/lib/WikiDB/backend/PearDB_oci8.php +++ b/lib/WikiDB/backend/PearDB_oci8.php @@ -28,7 +28,7 @@ extends WikiDB_backend_PearDB_pgsql // - No persistent conections (I don't like them) $dbh->setOption('persistent', false); // - Set lowercase compatibility option - // - Set numrows as well -- sure why this is needed, but some queries + // - Set numrows as well -- sure why this is needed, but some queries // are triggering DB_ERROR_NOT_CAPABLE $dbh->setOption('portability', DB_PORTABILITY_LOWERCASE | DB_PORTABILITY_NULL_TO_EMPTY | DB_PORTABILITY_NUMROWS); @@ -48,7 +48,7 @@ extends WikiDB_backend_PearDB_pgsql */ function _lock_tables($write_lock=true) { $dbh = &$this->_dbh; - + // Not sure if we really need to lock tables here, the Oracle row // locking mechanism should be more than enough // For the time being, lets stay on the safe side and lock... @@ -85,14 +85,14 @@ extends WikiDB_backend_PearDB_pgsql // Problem: date formats are backend specific. Either use unixtime as %d (long), // or the native timestamp format. date('d-M-Y H:i:s', $entry->time), - $entry->host, + $entry->host, $entry->user, - $entry->request_method, - $entry->request, - $entry->request_uri, + $entry->request_method, + $entry->request, + $entry->request_uri, $entry->request_args, - $entry->_ncsa_time($entry->time), - $entry->status, + $entry->_ncsa_time($entry->time), + $entry->status, $entry->size, $entry->referer, $entry->user_agent, @@ -119,12 +119,11 @@ extends WikiDB_backend_PearDB_search } } -// (c-file-style: "gnu") // Local Variables: // mode: php // tab-width: 8 // c-basic-offset: 4 // c-hanging-comment-ender-p: nil // indent-tabs-mode: nil -// End: +// End: ?> diff --git a/lib/WikiDB/backend/PearDB_pgsql.php b/lib/WikiDB/backend/PearDB_pgsql.php index 11e9402c1..375b18537 100644 --- a/lib/WikiDB/backend/PearDB_pgsql.php +++ b/lib/WikiDB/backend/PearDB_pgsql.php @@ -10,7 +10,7 @@ if (!defined("USE_BYTEA")) // see schemas/psql-initialize.sql /* Since 1.3.12 changed to use: - * Foreign Keys + * Foreign Keys * ON DELETE CASCADE * tsearch2 */ @@ -28,7 +28,7 @@ extends WikiDB_backend_PearDB // // This stuff is all just to catch and ignore these warnings, // so that they don't get reported to the user. (They are - // not consequential.) + // not consequential.) global $ErrorManager; $ErrorManager->pushErrorHandler(new WikiMethodCb($this,'_pgsql_open_error')); @@ -42,9 +42,9 @@ extends WikiDB_backend_PearDB return true; // Ignore error return false; } - + /** - * Pack tables. + * Pack tables. * NOTE: Only the table owner can do this. Either fix the schema or setup autovacuum. */ function optimize() { @@ -91,7 +91,7 @@ extends WikiDB_backend_PearDB $sth = $dbh->query(sprintf("UPDATE $page_tbl" . " SET cached_html='%s'" . " WHERE pagename='%s'", - $this->_quote($data), + $this->_quote($data), $dbh->escapeSimple($pagename))); else $sth = $dbh->query("UPDATE $page_tbl" @@ -107,10 +107,10 @@ extends WikiDB_backend_PearDB function _todo_set_versiondata($pagename, $version, $data) { $dbh = &$this->_dbh; $version_tbl = $this->_table_names['version_tbl']; - + $minor_edit = (int) !empty($data['is_minor_edit']); unset($data['is_minor_edit']); - + $mtime = (int)$data['mtime']; unset($data['mtime']); assert(!empty($mtime)); @@ -118,7 +118,7 @@ extends WikiDB_backend_PearDB @$content = (string) $data['%content']; unset($data['%content']); unset($data['%pagedata']); - + $this->lock(); $id = $this->_get_pageid($pagename, true); $dbh->query(sprintf("DELETE FROM version WHERE id=%d AND version=%d", $id, $version)); @@ -147,7 +147,7 @@ extends WikiDB_backend_PearDB function _todo_rename_page ($pagename, $to) { $dbh = &$this->_dbh; extract($this->_table_names); - + $this->lock(); if (($id = $this->_get_pageid($pagename, false)) ) { if ($new = $this->_get_pageid($to, false)) { @@ -203,8 +203,8 @@ extends WikiDB_backend_PearDB /** * Title search. */ - function text_search($search, $fulltext=false, $sortby='', $limit='', - $exclude='') + function text_search($search, $fulltext=false, $sortby='', $limit='', + $exclude='') { $dbh = &$this->_dbh; extract($this->_table_names); @@ -216,7 +216,7 @@ extends WikiDB_backend_PearDB if (!class_exists($searchclass)) $searchclass = "WikiDB_backend_PearDB_search"; $searchobj = new $searchclass($search, $dbh); - + $table = "$nonempty_tbl, $page_tbl"; $join_clause = "$nonempty_tbl.id=$page_tbl.id"; $fields = $this->page_tbl_fields; @@ -240,7 +240,7 @@ extends WikiDB_backend_PearDB $callback = new WikiMethodCb($searchobj, "_pagename_match_clause"); $search_clause = $search->makeSqlClauseObj($callback); } - + $sql = "SELECT $fields FROM $table" . " WHERE $join_clause" . " AND ($search_clause)" @@ -251,7 +251,7 @@ extends WikiDB_backend_PearDB } else { $result = $dbh->query($sql); } - + $iter = new WikiDB_backend_PearDB_iter($this, $result); $iter->stoplisted = @$searchobj->stoplisted; return $iter; @@ -265,12 +265,12 @@ extends WikiDB_backend_PearDB_search function _pagename_match_clause($node) { $word = $node->sql(); if ($node->op == 'REGEX') { // posix regex extensions - return ($this->_case_exact + return ($this->_case_exact ? "pagename ~* '$word'" : "pagename ~ '$word'"); } else { - return ($this->_case_exact - ? "pagename LIKE '$word'" + return ($this->_case_exact + ? "pagename LIKE '$word'" : "pagename ILIKE '$word'"); } } @@ -291,9 +291,9 @@ select * from stat('select idxfti from version') order by ndoc desc, nentry desc see | 42 | 69 default | 39 | 124 */ - - /** - * use tsearch2. See schemas/psql-tsearch2.sql and /usr/share/postgresql/contrib/tsearch2.sql + + /** + * use tsearch2. See schemas/psql-tsearch2.sql and /usr/share/postgresql/contrib/tsearch2.sql * TODO: don't parse the words into nodes. rather replace "[ +]" with & and "-" with "!" and " or " with "|" * tsearch2 query language: @@ "word | word", "word & word", ! word * ~* '.*something that does not exist.*' @@ -317,12 +317,11 @@ select * from stat('select idxfti from version') order by ndoc desc, nentry desc } } -// (c-file-style: "gnu") // Local Variables: // mode: php // tab-width: 8 // c-basic-offset: 4 // c-hanging-comment-ender-p: nil // indent-tabs-mode: nil -// End: +// End: ?> diff --git a/lib/WikiDB/backend/PearDB_sqlite.php b/lib/WikiDB/backend/PearDB_sqlite.php index ab1ffce7e..345a7c5e3 100644 --- a/lib/WikiDB/backend/PearDB_sqlite.php +++ b/lib/WikiDB/backend/PearDB_sqlite.php @@ -1,11 +1,11 @@ connect($DBParams['dsn'], array('persistent'=> true) ); - $result = $db->query("CREATE TABLE $table (comment varchar(50), + $result = $db->query("CREATE TABLE $table (comment varchar(50), datetime varchar(50));"); */ @@ -91,13 +91,12 @@ extends WikiDB_backend_PearDB } }; - -// (c-file-style: "gnu") + // Local Variables: // mode: php // tab-width: 8 // c-basic-offset: 4 // c-hanging-comment-ender-p: nil // indent-tabs-mode: nil -// End: -?> \ No newline at end of file +// End: +?> diff --git a/lib/WikiDB/backend/cvs.php b/lib/WikiDB/backend/cvs.php index 04231750d..62a84bde0 100644 --- a/lib/WikiDB/backend/cvs.php +++ b/lib/WikiDB/backend/cvs.php @@ -1,9 +1,9 @@ directory where the pages should be stored * this is not the CVS repository location - * . repository ==> local directory where the repository should be + * . repository ==> local directory where the repository should be * created. This can also be a :pserver: but then * set check_for_repository to false and checkout * the documents beforehand. (This is basically CVSROOT) - * . check_for_repository ==> boolean flag to indicate whether the + * . check_for_repository ==> boolean flag to indicate whether the * repository should be created, this only * applies to local directories, for pserver - * set this to false and check out the + * set this to false and check out the * document base beforehand * . debug_file ==> file name where debug information should be sent. * If file doesn't exist then it's created, if this @@ -67,12 +67,12 @@ extends WikiDB_backend * The class also adds a parameter 'module_name' to indicate the name * of the cvs module that is being used to version the documents. The * module_name is assumed to be the base name of directory given in - * wiki, e.g. if wiki == '/some/path/to/documents' then module_name - * becomes 'documents' and this module will be created in the CVS + * wiki, e.g. if wiki == '/some/path/to/documents' then module_name + * becomes 'documents' and this module will be created in the CVS * repository or assumed to exist. If on the other hand the parameter * already exists, then it is not overwritten. */ - function WikiDB_backend_cvs( $dbparam ) + function WikiDB_backend_cvs( $dbparam ) { // setup all the instance values. $this->_docDir = $dbparam{CVS_DOC_DIR}; @@ -92,15 +92,15 @@ extends WikiDB_backend $this->_cvsDebug( sprintf("Creating new repository [%s]", $this->_repository) ); - // doesn't exist, need to create it and the replace the wiki + // doesn't exist, need to create it and the replace the wiki // document directory. $this->_mkdir( $this->_repository, 0775 ); - + // assume that the repository is a local directory, prefix :local: if ( !ereg( "^:local:", $this->_repository ) ) { $this->_repository = ":local:" . $this->_repository; } - + $cmdLine = sprintf( "cvs -d \"%s\" init", $this->_repository); $this->_execCommand( $cmdLine, $cmdOutput, true ); @@ -109,14 +109,14 @@ extends WikiDB_backend ."%s V R", $this->_docDir, $this->_repository, $this->_module_name ); $this->_execCommand( $cmdLine, $cmdOutput, true ); - - // remove the wiki directory and check it out from the + + // remove the wiki directory and check it out from the // CVS repository $cmdLine = sprintf( "rm -fr %s; cd %s; cvs -d \"%s\" co %s", - $this->_docDir, dirname($this->_docDir), + $this->_docDir, dirname($this->_docDir), $this->_repository, $this->_module_name); $this->_execCommand( $cmdLine, $cmdOutput, true ); - + // add the default pages using the update_pagedata $metaData = array(); $metaData[$AUTHOR] = "PhpWiki -- CVS Backend"; @@ -126,7 +126,7 @@ extends WikiDB_backend while ( $entry = readdir( $d ) ) { $filename = $dbparam[CVS_PAGE_SOURCE] . "/" . $entry; $this->_cvsDebug( sprintf("Found [%s] in [%s]", $entry, $dbparam[CVS_PAGE_SOURCE]) ); - + if ( is_file( $filename ) ) { $metaData[CMD_CONTENT] = join('',file($filename)); $this->update_pagedata( $entry, $metaData ); @@ -134,7 +134,7 @@ extends WikiDB_backend } closedir( $d ); } - + // ensure that the results of the is_dir are cleared clearstatcache(); } @@ -143,16 +143,16 @@ extends WikiDB_backend /** * Return: metadata about page */ - function get_pagedata($pagename) + function get_pagedata($pagename) { - // the metadata information about a page is stored in the + // the metadata information about a page is stored in the // CVS directory of the document root in serialized form. The // file always has the name, i.e. '_$pagename'. $metaFile = $this->_docDir . "/CVS/_" . $pagename; if ( file_exists( $metaFile ) ) { - - $megaHash = + + $megaHash = unserialize(join( '',$this->_readFileWithPath($metaFile))); $filename = $this->_docDir . "/" . $pagename; @@ -175,11 +175,11 @@ extends WikiDB_backend * This will create a new page if page being requested does not * exist. */ - function update_pagedata($pagename, $newdata = array() ) + function update_pagedata($pagename, $newdata = array() ) { // check argument if ( ! is_array( $newdata ) ) { - trigger_error("update_pagedata: Argument 'newdata' was not array", + trigger_error("update_pagedata: Argument 'newdata' was not array", E_USER_WARNING); } @@ -233,7 +233,7 @@ extends WikiDB_backend $this->_writeMetaInfo( $pagename, $metaData ); } - function get_latest_version($pagename) + function get_latest_version($pagename) { $metaData = $this->get_pagedata( $pagename ); if ( $metaData ) { @@ -245,7 +245,7 @@ extends WikiDB_backend } } - function get_previous_version($pagename, $version) + function get_previous_version($pagename, $version) { // cvs increments the version numbers, so this is real easy ;-) return ($version > 0 ? $version - 1 : 0); @@ -255,23 +255,23 @@ extends WikiDB_backend * the version parameter is assumed to be everything after the '1.' * in the CVS versioning system. */ - function get_versiondata($pagename, $version, $want_content = false) + function get_versiondata($pagename, $version, $want_content = false) { $this->_cvsDebug( "get_versiondata: [$pagename] [$version] [$want_content]" ); - + $filedata = ""; if ( $want_content ) { // retrieve the version from the repository - $cmdLine = sprintf("cvs -d \"%s\" co -p -r 1.%d %s/%s 2>&1", - $this->_repository, $version, + $cmdLine = sprintf("cvs -d \"%s\" co -p -r 1.%d %s/%s 2>&1", + $this->_repository, $version, $this->_module_name, $pagename ); $this->_execCommand( $cmdLine, $filedata, true ); - + // TODO: DEBUG: 5 is a magic number here, depending on the // TODO: DEBUG: version of cvs used here, 5 might have to // TODO: DEBUG: change. Basically find a more reliable way of // TODO: DEBUG: doing this. - // the first 5 lines contain various bits of + // the first 5 lines contain various bits of // administrative information that can be ignored. for ( $i = 0; $i < 5; $i++ ) { array_shift( $filedata ); @@ -302,7 +302,7 @@ extends WikiDB_backend foreach ( $rVal as $key => $value ) { $this->_cvsDebug( "$key == [$value]" ); } - + return $rVal; } @@ -316,19 +316,19 @@ extends WikiDB_backend * This returns false if page was not deleted or could not be deleted * else return true. */ - function purge_page($pagename) + function purge_page($pagename) { $this->_cvsDebug( "delete_page [$pagename]") ; $filename = $this->_docDir . "/" . $pagename; $metaFile = $this->_docDir . "/CVS/_" . $pagename; - + // obtain a write block before deleting the file if ( $this->_deleteFile( $filename ) == false ) { return false; } - + $this->_deleteFile( $metaFile ); - + $this->_removePage( $pagename ); return true; @@ -340,7 +340,7 @@ extends WikiDB_backend * This returns false if page was not renamed, * else return true. */ - function rename_page($pagename, $to) + function rename_page($pagename, $to) { $this->_cvsDebug( "rename_page [$pagename,$to]") ; $data = get_pagedata($pagename); @@ -354,7 +354,7 @@ extends WikiDB_backend return true; } - function delete_versiondata($pagename, $version) + function delete_versiondata($pagename, $version) { // TODO: Not Implemented. // TODO: This is, for CVS, difficult because it implies removing a @@ -363,7 +363,7 @@ extends WikiDB_backend trigger_error("delete_versiondata: Not Implemented", E_USER_WARNING); } - function set_versiondata($pagename, $version, $data) + function set_versiondata($pagename, $version, $data) { // TODO: Not Implemented. // TODO: requires changing the log(commit) message for a particular @@ -373,13 +373,13 @@ extends WikiDB_backend trigger_error("set_versiondata: Not Implemented", E_USER_WARNING); } - function update_versiondata($pagename, $version, $newdata) + function update_versiondata($pagename, $version, $newdata) { // TODO: same problem as set_versiondata trigger_error("set_versiondata: Not Implemented", E_USER_WARNING); } - function set_links($pagename, $links) + function set_links($pagename, $links) { // TODO: needs to be tested .... $megaHash = get_pagedata( $pagename ); @@ -393,7 +393,7 @@ extends WikiDB_backend // TODO: ignores the $reversed argument and returns // TODO: the value of _links_ attribute of the meta information // TODO: to implement a reversed version, i guess, we going to - // TODO: need to do a grep on all files for the pagename in + // TODO: need to do a grep on all files for the pagename in // TODO: in question and return all those page names that contained // TODO: the required pagename! $megaHash = get_pagedata( $pagename ); @@ -406,19 +406,19 @@ extends WikiDB_backend return new WikiDB_backend_dumb_AllRevisionsIter($this, $pagename); } */ - function get_all_pages($include_empty=false, $sortby='', $limit='') + function get_all_pages($include_empty=false, $sortby='', $limit='') { // FIXME: this ignores the parameters. return new Cvs_Backend_Array_Iterator( $this->_getAllFileNamesInDir( $this->_docDir )); } - function text_search($search, $fullsearch = false, $orderby=false, $limit='', $exclude='') + function text_search($search, $fullsearch = false, $orderby=false, $limit='', $exclude='') { if ( $fullsearch ) { $iter = new Cvs_Backend_Full_Search_Iterator( - $this->_getAllFileNamesInDir( $this->_docDir ), - $search, + $this->_getAllFileNamesInDir( $this->_docDir ), + $search, $this->_docDir ); $iter->stoplisted =& $search->stoplisted; return $iter; @@ -439,7 +439,7 @@ extends WikiDB_backend arsort( $mp, SORT_NUMERIC ); } $returnVal = array(); - + while ( (list($key, $val) = each($a)) && $limit > 0 ) { $returnVal[] = $key; $limit--; @@ -451,7 +451,7 @@ extends WikiDB_backend * This only accepts the 'since' and 'limit' attributes, everything * else is ignored. */ - function most_recent($params) + function most_recent($params) { // TODO: needs to be tested ... // most recent are those pages with the highest time value ... @@ -474,7 +474,7 @@ extends WikiDB_backend } } else if ( isset( $params['since'] ) ) { while ( (list($key, $val) = each($a)) ) { - + if ( $val > $params['since'] ) { $returnVal[] = $key; } @@ -484,27 +484,27 @@ extends WikiDB_backend return new Cvs_Backend_Array_Iterator( $returnVal ); } - function lock($write_lock = true) + function lock($write_lock = true) { // TODO: to be implemented trigger_error("lock: Not Implemented", E_USER_WARNING); } - function unlock($force = false) + function unlock($force = false) { // TODO: to be implemented trigger_error("unlock: Not Implemented", E_USER_WARNING); } - function close () + function close () { } - function sync() + function sync() { } - function optimize() + function optimize() { } @@ -514,10 +514,10 @@ extends WikiDB_backend * file is created for the page. * * This can happen if rebuild() was called and someone has added - * files to the CVS repository not via PhpWiki. These files are + * files to the CVS repository not via PhpWiki. These files are * added to the document directory but without any metadata files. */ - function check() + function check() { // TODO: // TODO: test this .... i.e. add test to unit test file. @@ -535,9 +535,9 @@ extends WikiDB_backend } /** - * Do an update of the CVS repository + * Do an update of the CVS repository */ - function rebuild() + function rebuild() { // TODO: // TODO: test this .... i.e. add test to unit test file. @@ -546,10 +546,10 @@ extends WikiDB_backend $this->_execCommand( $cmdLine, $cmdOutput, true ); return true; } - - // + + // // ..-.-..-.-..-.-.. .--..-......-.--. --.-....----..... - // The rest are all internal methods, not to be used + // The rest are all internal methods, not to be used // directly. // ..-.-..-.-..-.-.. .--..-......-.--. --.-....----..... // @@ -561,7 +561,7 @@ extends WikiDB_backend $backend->update_pagedata( $page_name, array() ); } - function _strip_leading_underscore( &$item ) + function _strip_leading_underscore( &$item ) { $item = ereg_replace( "^_", "", $item ); } @@ -579,7 +579,7 @@ extends WikiDB_backend } else { $mp[$pagename] = 1; } - $this->_writeFileWithPath( $this->_docDir . "/CVS/" . CVS_MP_FILE, + $this->_writeFileWithPath( $this->_docDir . "/CVS/" . CVS_MP_FILE, serialize( $mp ) ); } @@ -610,13 +610,13 @@ extends WikiDB_backend { $mr = $this->_getMostRecent(); $mr[$pagename] = time(); - $this->_writeFileWithPath( $this->_docDir . "/CVS/" . CVS_MR_FILE, + $this->_writeFileWithPath( $this->_docDir . "/CVS/" . CVS_MR_FILE, serialize( $mr ) ); } function _writeMetaInfo( $pagename, $hashInfo ) { - $this->_writeFileWithPath( $this->_docDir . "/CVS/_" . $pagename, + $this->_writeFileWithPath( $this->_docDir . "/CVS/_" . $pagename, serialize( $hashInfo ) ); } function _writePage( $pagename, $content ) @@ -626,9 +626,9 @@ extends WikiDB_backend function _removePage( $pagename ) { $cmdLine = sprintf("cd %s; cvs remove %s 2>&1; cvs commit -m '%s' " - ."%s 2>&1", $this->_docDir, $pagename, + ."%s 2>&1", $this->_docDir, $pagename, "remove page", $pagename ); - + $this->_execCommand( $cmdLine, $cmdRemoveOutput, true ); } @@ -637,8 +637,8 @@ extends WikiDB_backend */ function _commitPage( $pagename, &$meta_data ) { - $cmdLine = sprintf( "cd %s; cvs commit -m \"%s\" %s 2>&1", - $this->_docDir, + $cmdLine = sprintf( "cd %s; cvs commit -m \"%s\" %s 2>&1", + $this->_docDir, escapeshellcmd( serialize( $meta_data ) ), $pagename ); $this->_execCommand( $cmdLine, $cmdOutput, true ); @@ -667,17 +667,17 @@ extends WikiDB_backend { // TODO: need to add a check for the mimetype so that binary // TODO: files are added as binary files - $cmdLine = sprintf("cd %s; cvs add %s 2>&1", $this->_docDir, + $cmdLine = sprintf("cd %s; cvs add %s 2>&1", $this->_docDir, $pagename ); $this->_execCommand( $cmdLine, $cmdAddOutput, true ); } /** * Returns an array containing all the names of files contained - * in a particular directory. The list is sorted according the + * in a particular directory. The list is sorted according the * string representation of the filenames. */ - function _getAllFileNamesInDir( $dirName ) + function _getAllFileNamesInDir( $dirName ) { $namelist = array(); $d = opendir( $dirName ); @@ -692,24 +692,24 @@ extends WikiDB_backend /** * Recursively create all directories. */ - function _mkdir( $path, $mode ) + function _mkdir( $path, $mode ) { $directoryName = dirname( $path ); - if ( $directoryName != "/" && $directoryName != "\\" + if ( $directoryName != "/" && $directoryName != "\\" && !is_dir( $directoryName ) && $directoryName != "" ) { $rVal = $this->_mkdir( $directoryName, $mode ); } else { $rVal = true; } - + return ($rVal && @mkdir( $path, $mode ) ); } /** * Recursively create all directories and then the file. */ - function _createFile( $path, $mode ) + function _createFile( $path, $mode ) { $this->_mkdir( dirname( $path ), $mode ); touch( $path ); @@ -721,14 +721,14 @@ extends WikiDB_backend */ function _deleteFile( $filename ) { - if( $fd = fopen($filename, 'a') ) { - - $locked = flock($fd,2); // Exclusive blocking lock + if( $fd = fopen($filename, 'a') ) { + + $locked = flock($fd,2); // Exclusive blocking lock - if (!$locked) { + if (!$locked) { $this->_cvsError("Unable to delete file, lock was not obtained.", __LINE__, $filename, EM_NOTICE_ERRORS ); - } + } if ( ($rVal = unlink( $filename )) != 0 ) { $this->_cvsDebug( "[$filename] --> Unlink returned [$rVal]" ); @@ -743,11 +743,11 @@ extends WikiDB_backend } /** - * Called when something happened that causes the CVS backend to + * Called when something happened that causes the CVS backend to * fail. */ - function _cvsError( $msg = "no message", - $errline = 0, + function _cvsError( $msg = "no message", + $errline = 0, $errfile = "lib/WikiDB/backend/cvs.php", $errno = EM_FATAL_ERRORS) { @@ -762,12 +762,12 @@ extends WikiDB_backend * Debug function specifically for the CVS database functions. * Can be deactived by setting the WikiDB['debug_file'] to "" */ - function _cvsDebug( $msg ) + function _cvsDebug( $msg ) { if ( $this->_debug_file == "" ) { return; } - + if ( !file_exists( $this->_debug_file ) ) { $this->_createFile( $this->_debug_file, 0755 ); } @@ -778,7 +778,7 @@ extends WikiDB_backend fclose( $fdlock ); return; } - + $fdappend = @fopen( $this->_debug_file, 'a' ); fwrite( $fdappend, ($msg . "\n") ); fclose( $fdappend ); @@ -792,7 +792,7 @@ extends WikiDB_backend } /** - * Execute a command and potentially exit if the flag exitOnNonZero is + * Execute a command and potentially exit if the flag exitOnNonZero is * set to true and the return value was nonZero */ function _execCommand( $cmdLine, &$cmdOutput, $exitOnNonZero ) @@ -800,7 +800,7 @@ extends WikiDB_backend $this->_cvsDebug( sprintf("Preparing to execute [%s]", $cmdLine) ); exec( $cmdLine, $cmdOutput, $cmdReturnVal ); if ( $exitOnNonZero && ($cmdReturnVal != 0) ) { - $this->_cvsDebug( sprintf("Command failed [%s], Output: ", $cmdLine) ."[". + $this->_cvsDebug( sprintf("Command failed [%s], Output: ", $cmdLine) ."[". join("\n",$cmdOutput) . "]" ); $this->_cvsError( sprintf("Command failed [%s], Return value: %s", $cmdLine, $cmdReturnVal), __LINE__ ); @@ -813,7 +813,7 @@ extends WikiDB_backend /** * Read locks a file, reads it, and returns it contents */ - function _readFileWithPath( $filename ) + function _readFileWithPath( $filename ) { if ( $fd = @fopen( $filename, "r" ) ) { $locked = flock( $fd, 1 ); // read lock @@ -833,28 +833,28 @@ extends WikiDB_backend } /** - * Either replace the contents of an existing file or create a + * Either replace the contents of an existing file or create a * new file in the particular store using the page name as the * file name. - * + * * Nothing is returned, might be useful to return something ;-) */ function _writeFileWithPath( $filename, $contents ) - { + { // TODO: $contents should probably be a reference parameter ... - if( $fd = fopen($filename, 'a') ) { - $locked = flock($fd,2); // Exclusive blocking lock - if (!$locked) { + if( $fd = fopen($filename, 'a') ) { + $locked = flock($fd,2); // Exclusive blocking lock + if (!$locked) { $this->_cvsError( "Timeout while obtaining lock.", __LINE__ ); - } + } // Second filehandle -- we use this to write the contents - $fdsafe = fopen($filename, 'w'); - fwrite($fdsafe, $contents); - fclose($fdsafe); + $fdsafe = fopen($filename, 'w'); + fwrite($fdsafe, $contents); + fclose($fdsafe); fclose($fd); } else { - $this->_cvsError( sprintf("Could not open file '%s' for writing", $filename), + $this->_cvsError( sprintf("Could not open file '%s' for writing", $filename), __LINE__ ); } } @@ -886,7 +886,7 @@ extends WikiDB_backend } /** - * Unescape a string value. Normally this comes from doing an + * Unescape a string value. Normally this comes from doing an * escapeshellcmd. This converts the following: * \{ --> { * \} --> } @@ -899,7 +899,7 @@ extends WikiDB_backend $val = str_replace( "\\}", "}", $val ); $val = str_replace( "\\;", ";", $val ); $val = str_replace( "\\\"", "\"", $val ); - + return $val; } @@ -927,7 +927,7 @@ extends WikiDB_backend_iterator $this->_array = $arrayValue; } - function next() + function next() { while ( ($rVal = array_pop( $this->_array )) != NULL ) { return $rVal; @@ -964,7 +964,7 @@ extends Cvs_Backend_Array_Iterator { do { $pageName = Cvs_Backend_Array_Iterator::next(); - } while ( !$this->_searchFile( $_searchString, + } while ( !$this->_searchFile( $_searchString, $_docDir . "/" . $pageName )); return $pageName; @@ -972,7 +972,7 @@ extends Cvs_Backend_Array_Iterator /** * Does nothing more than a grep and search the entire contents - * of the given file. Returns TRUE of the searchstring was found, + * of the given file. Returns TRUE of the searchstring was found, * false if the search string wasn't find or the file was a directory * or could not be read. */ @@ -981,10 +981,10 @@ extends Cvs_Backend_Array_Iterator // TODO: using grep here, it might make more sense to use // TODO: some sort of inbuilt/language specific method for // TODO: searching files. - $cmdLine = sprintf( "grep -E -i '%s' %s > /dev/null 2>&1", + $cmdLine = sprintf( "grep -E -i '%s' %s > /dev/null 2>&1", $searchString, $fileName ); - - return ( WikiDB_backend_cvs::_execCommand( $cmdLine, $cmdOutput, + + return ( WikiDB_backend_cvs::_execCommand( $cmdLine, $cmdOutput, false ) == 0 ); } } @@ -1014,12 +1014,11 @@ extends Cvs_Backend_Array_Iterator } } -// (c-file-style: "gnu") // Local Variables: // mode: php // tab-width: 8 // c-basic-offset: 4 // c-hanging-comment-ender-p: nil // indent-tabs-mode: nil -// End: +// End: ?> diff --git a/lib/WikiDB/backend/dba.php b/lib/WikiDB/backend/dba.php index 6e7506e77..11d2f0efa 100644 --- a/lib/WikiDB/backend/dba.php +++ b/lib/WikiDB/backend/dba.php @@ -18,7 +18,7 @@ extends WikiDB_backend_dbaBase // FIXME: error checking. $db = new DbaDatabase($dbfile, false, $dba_handler); $db->set_timeout($timeout); - + // Workaround for BDB 4.1 bugs if (file_exists($dbfile)) { $mode = 'w'; @@ -35,12 +35,11 @@ extends WikiDB_backend_dbaBase } }; -// (c-file-style: "gnu") // Local Variables: // mode: php // tab-width: 8 // c-basic-offset: 4 // c-hanging-comment-ender-p: nil // indent-tabs-mode: nil -// End: -?> \ No newline at end of file +// End: +?> diff --git a/lib/WikiDB/backend/dbaBase.php b/lib/WikiDB/backend/dbaBase.php index 0171ea89423f4127aa3172ae188bbbabeb980af6..ab5f40ef53e40be8df859fa5a17593f8756e56b7 100644 GIT binary patch delta 479 zcmY+BZ)l7G9LM`T_dGYAd9t&fp1E5*la0HYoBN|}ayyK)HFhN&xB1g?x_85MTwW*) zrPF*P5zAU4Ci=$8i;dJu-i-3f3p?H@Y!NTyjc2FCyWjWs`}XPg{r$#%$mDly<8|mUPBqn_ zs#?RXu=Tfo8#YwkwrzMigQ$%ZVORPv5%HGk(~(zYz?*0zU90xFDrTLw9l*1&7iU_I z|EpQwIwW|$z{d}(MS;8PAuh+pv90Yclz5(n_z}U(+Cg4e7Zg5SKdj(qdpqxJEDD=9 zJrR6twNc#>`VX1uxS`P9H7=akd{(%n+b=96CN*|$-zz|k2V*-9mN$$i7dp{YB$MZ{ zw9n+PWWV73F%#!{E#BYN;_y==qT@?y5g+xK!k4`}oufr8uG!;J*`2Nz=J#I`3}j8* mJ}{r5%*lBiJ)98exp(}Oiwc+Io$n1F%?UzAwMmDYI(; delta 592 zcmcccg>m0k#tm~>H_v9}W!}7uqls~|8kadUqr&7^-V`8tkXHjtifsPN+s3rHQ6Q0V z^8>*!*3Bm34xE!s#DzAuC~z?{D=2VHo+vH4d5Iz$+vXMO7Z@28Ht*Io2U3$C>PT-s zrIpSE6fx922o;&ktDglFDA$hx30yY#$gIG{Ik`b!X7VG$7NAI>sp#ZtBa6vJ3PO_) z8!dx~OcLgp+-59};B1IsoxIy@0m#Z(h$`(4u{kVgf*6elNG)<9UB|5`2rISJ%|24nWcyRCr^ zpM1e*{Xmws{c0e2&AuF{-`Al8r1YTUd>|*mNuQBPL1A;h^AeDb6D}^B%ia2b z@|#&bc7c=~uu_RD-bQaIU(8uXfM~~1*RgC_r}ZsG1tb(Z7zuw1;z?j z_2dKLs+%{&88d>zVZ!A3{vwlqJBv>CGgaQaKf#B2GiQoA<7U0o=^)D|`=qICewo(H zvpK6cm~ry%l82jTm6|hdK3@h*7XB6GjG`LJx@nm?sk+4_l{u+a3QFmDrAnHU4^?)t K0aJjz9TxzpR>9!_ diff --git a/lib/WikiDB/backend/dumb/AllRevisionsIter.php b/lib/WikiDB/backend/dumb/AllRevisionsIter.php index 497abfb67..f960ba0db 100644 --- a/lib/WikiDB/backend/dumb/AllRevisionsIter.php +++ b/lib/WikiDB/backend/dumb/AllRevisionsIter.php @@ -1,6 +1,6 @@ _pagename = $pagename; $this->_lastversion = -1; } - + /** * Get next revision in sequence. * @@ -42,10 +42,10 @@ extends WikiDB_backend_iterator if ($version) $vdata = $backend->get_versiondata($pagename, $version); //$backend->unlock(); - + if ($version == 0) return false; - + if (is_string($vdata) and !empty($vdata)) { $vdata1 = @unserialize($vdata); if (empty($vdata1)) { @@ -58,7 +58,7 @@ extends WikiDB_backend_iterator $rev = array('versiondata' => $vdata, 'pagename' => $pagename, 'version' => $version); - + if (!empty($vdata['%pagedata'])) { $rev['pagedata'] = $vdata['%pagedata']; } @@ -67,12 +67,11 @@ extends WikiDB_backend_iterator } }; -// (c-file-style: "gnu") // Local Variables: // mode: php // tab-width: 8 // c-basic-offset: 4 // c-hanging-comment-ender-p: nil // indent-tabs-mode: nil -// End: +// End: ?> diff --git a/lib/WikiDB/backend/dumb/BackLinkIter.php b/lib/WikiDB/backend/dumb/BackLinkIter.php index 608040f3a..2ff796a97 100644 --- a/lib/WikiDB/backend/dumb/BackLinkIter.php +++ b/lib/WikiDB/backend/dumb/BackLinkIter.php @@ -17,7 +17,7 @@ extends WikiDB_backend_iterator $this->_backend = &$backend; $this->_target = $pagename; } - + function next() { while ($page = $this->_pages->next()) { $pagename = $page['pagename']; @@ -30,13 +30,12 @@ extends WikiDB_backend_iterator } } } - + function free() { $this->_pages->free(); } } -// For emacs users // Local Variables: // mode: php // tab-width: 8 diff --git a/lib/WikiDB/backend/dumb/LinkSearchIter.php b/lib/WikiDB/backend/dumb/LinkSearchIter.php index fdfd17b54..8bc1ce093 100644 --- a/lib/WikiDB/backend/dumb/LinkSearchIter.php +++ b/lib/WikiDB/backend/dumb/LinkSearchIter.php @@ -26,9 +26,9 @@ * This iterator will work with any WikiDB_backend * which has a working get_links() method with want_relation support. * Currently we iterate over all pages, check for all matching links. - * As optimization a backend could iterate over the linktable instead - * and check the matching page there. There are most likely less links - * than pages and links are smaller than pages. + * As optimization a backend could iterate over the linktable instead + * and check the matching page there. There are most likely less links + * than pages and links are smaller than pages. * * This is mostly here for testing, very slow. * @@ -39,8 +39,8 @@ class WikiDB_backend_dumb_LinkSearchIter extends WikiDB_backend_iterator { - function WikiDB_backend_dumb_LinkSearchIter(&$backend, &$pageiter, $search, $linktype, - $relation=false, $options=array()) + function WikiDB_backend_dumb_LinkSearchIter(&$backend, &$pageiter, $search, $linktype, + $relation=false, $options=array()) { $this->_backend = &$backend; $this->_pages = $pageiter; @@ -78,7 +78,7 @@ extends WikiDB_backend_iterator } else { $page = $this->_page; } - // iterate the links. the links are pushed into the handy triple by _get_links + // iterate the links. the links are pushed into the handy triple by _get_links while ($link = array_shift($this->_links)) { // unmatching relations are already filtered out if ($this->search->match($link['linkvalue'])) { //pagename or attr-value @@ -117,10 +117,10 @@ extends WikiDB_backend_iterator $attribs = $page->get('attributes'); if ($attribs) { foreach ($attribs as $attribute => $value) { - if ($this->relation and !$this->relation->match($attribute)) continue; - // The logical operator and unit unification (not yet) is encoded into + if ($this->relation and !$this->relation->match($attribute)) continue; + // The logical operator and unit unification (not yet) is encoded into // a seperate search object. - if (!$this->search->match($value)) continue; + if (!$this->search->match($value)) continue; $links[] = array('pagename' => $pagename, 'linkname' => $attribute, 'linkvalue' => $value); @@ -129,11 +129,11 @@ extends WikiDB_backend_iterator unset($attribs); } else { $link_iter = $this->_backend->get_links($pagename, $this->_reverse, true, - $this->sortby, $this->limit, + $this->sortby, $this->limit, $this->exclude, $this->_want_relations); // we already stepped through all links. make use of that. if ($this->_want_relations - and isset($link_iter->_options['found_relations']) + and isset($link_iter->_options['found_relations']) and $link_iter->_options['found_relations'] == 0) { $link_iter->free(); @@ -141,8 +141,8 @@ extends WikiDB_backend_iterator } while ($link = $link_iter->next()) { if (empty($link[$this->_field])) continue; - if ($this->_want_relations and $this->relation - and !$this->relation->match($link['linkrelation'])) continue; + if ($this->_want_relations and $this->relation + and !$this->relation->match($link['linkrelation'])) continue; // check hash values, with/out want_relations $links[] = array('pagename' => $pagename, 'linkname' => $this->_want_relations ? $link['linkrelation'] : '', @@ -160,7 +160,6 @@ extends WikiDB_backend_iterator } } -// For emacs users // Local Variables: // mode: php // tab-width: 8 diff --git a/lib/WikiDB/backend/dumb/MostPopularIter.php b/lib/WikiDB/backend/dumb/MostPopularIter.php index dba1e6478..5e84c90eb 100644 --- a/lib/WikiDB/backend/dumb/MostPopularIter.php +++ b/lib/WikiDB/backend/dumb/MostPopularIter.php @@ -5,7 +5,7 @@ require_once('lib/WikiDB/backend.php'); /** - * An inefficient but general most_popular iterator. + * An inefficient but general most_popular iterator. * * This iterator will work with any backend which implements the * backend::get_all_pages() and backend::get_pagedata() @@ -42,14 +42,14 @@ extends WikiDB_backend_iterator function next() { return array_shift($this->_pages); } - + function free() { unset($this->_pages); } } function WikiDB_backend_dumb_MostPopularIter_sortf($a,$b) { - $ahits = $bhits = 0; + $ahits = $bhits = 0; if (isset($a['pagedata']['hits'])) $ahits = (int)$a['pagedata']['hits']; if (isset($b['pagedata']['hits'])) @@ -58,7 +58,7 @@ function WikiDB_backend_dumb_MostPopularIter_sortf($a,$b) { } function WikiDB_backend_dumb_MostPopularIter_sortf_rev($a,$b) { - $ahits = $bhits = 0; + $ahits = $bhits = 0; if (isset($a['pagedata']['hits'])) $ahits = (int)$a['pagedata']['hits']; if (isset($b['pagedata']['hits'])) @@ -66,7 +66,6 @@ function WikiDB_backend_dumb_MostPopularIter_sortf_rev($a,$b) { return $ahits - $bhits; } -// For emacs users // Local Variables: // mode: php // tab-width: 8 diff --git a/lib/WikiDB/backend/dumb/MostRecentIter.php b/lib/WikiDB/backend/dumb/MostRecentIter.php index f393b528b..a8d3b1caf 100644 --- a/lib/WikiDB/backend/dumb/MostRecentIter.php +++ b/lib/WikiDB/backend/dumb/MostRecentIter.php @@ -5,7 +5,7 @@ require_once('lib/WikiDB/backend.php'); /** - * An inefficient but general most_recent iterator. + * An inefficient but general most_recent iterator. * * This iterator will work with any backends. */ @@ -57,11 +57,11 @@ extends WikiDB_backend_iterator array_splice($this->_revisions, $limit); } } - + function next() { return array_shift($this->_revisions); } - + function free() { unset($this->_revisions); } @@ -79,12 +79,11 @@ function WikiDB_backend_dumb_MostRecentIter_sortf_rev($a, $b) { return $acreated - $bcreated; } -// (c-file-style: "gnu") // Local Variables: // mode: php // tab-width: 8 // c-basic-offset: 4 // c-hanging-comment-ender-p: nil // indent-tabs-mode: nil -// End: +// End: ?> diff --git a/lib/WikiDB/backend/dumb/TextSearchIter.php b/lib/WikiDB/backend/dumb/TextSearchIter.php index bea6bd1bf..66d05f124 100644 --- a/lib/WikiDB/backend/dumb/TextSearchIter.php +++ b/lib/WikiDB/backend/dumb/TextSearchIter.php @@ -4,8 +4,8 @@ class WikiDB_backend_dumb_TextSearchIter extends WikiDB_backend_iterator { - function WikiDB_backend_dumb_TextSearchIter(&$backend, &$pages, $search, $fulltext=false, - $options=array()) + function WikiDB_backend_dumb_TextSearchIter(&$backend, &$pages, $search, $fulltext=false, + $options=array()) { $this->_backend = &$backend; $this->_pages = $pages; @@ -27,14 +27,14 @@ extends WikiDB_backend_iterator function _get_content(&$page) { $backend = &$this->_backend; $pagename = $page['pagename']; - + if (!isset($page['versiondata'])) { $version = $backend->get_latest_version($pagename); $page['versiondata'] = $backend->get_versiondata($pagename, $version, true); } return $page['versiondata']['%content']; } - + function _match(&$page) { $text = $page['pagename']; if ($result = $this->_search->match($text)) { // first match the pagename only @@ -71,7 +71,7 @@ extends WikiDB_backend_iterator }*/ if (is_array($page)) $page['score'] = $score; - else + else $page->score = $score; return $page; } @@ -84,12 +84,11 @@ extends WikiDB_backend_iterator } }; -// (c-file-style: "gnu") // Local Variables: // mode: php // tab-width: 8 // c-basic-offset: 4 // c-hanging-comment-ender-p: nil // indent-tabs-mode: nil -// End: +// End: ?> diff --git a/lib/WikiDB/backend/dumb/WantedPagesIter.php b/lib/WikiDB/backend/dumb/WantedPagesIter.php index bca476ab0..e7abe0ef0 100644 --- a/lib/WikiDB/backend/dumb/WantedPagesIter.php +++ b/lib/WikiDB/backend/dumb/WantedPagesIter.php @@ -18,12 +18,12 @@ extends WikiDB_backend_iterator $this->_backend = &$backend; if (!is_array($exclude)) $this->exclude = $exclude ? PageList::explodePageList($exclude) : array(); - else + else $this->exclude = $exclude; $this->sortby = $sortby; // ignored if ($limit) { // extract from,count from limit list($this->from, $this->limit) = $backend->limit($limit); - } else { + } else { $this->limit = 0; $this->from = 0; } @@ -67,7 +67,6 @@ extends WikiDB_backend_iterator } } -// For emacs users // Local Variables: // mode: php // tab-width: 8 diff --git a/lib/WikiDB/backend/file.php b/lib/WikiDB/backend/file.php index fcd683b75..6ba11a529 100644 --- a/lib/WikiDB/backend/file.php +++ b/lib/WikiDB/backend/file.php @@ -22,18 +22,18 @@ */ /** - * Backend for handling file storage. + * Backend for handling file storage. * * Author: Jochen Kalmbach, Jochen@kalmbachnet.de */ /* - * TODO: + * TODO: * - Implement "optimize" / "sync" / "check" / "rebuild" * - Optimize "get_previous_version" * - Optimize "get_links" (reversed = true) * - Optimize "get_all_revisions" - * - Optimize "most_popular" (separate file for "hitcount", + * - Optimize "most_popular" (separate file for "hitcount", * which contains all pages) * - Optimize "most_recent" * - What should be done in "lock"/"unlock"/"close" ? @@ -98,8 +98,8 @@ extends WikiDB_backend if (!filesize($filename)) return array(); if ($fd = @fopen($filename, "rb")) { $locked = flock($fd, 1); # Read lock - if (!$locked) { - ExitWiki("Timeout while obtaining lock. Please try again"); + if (!$locked) { + ExitWiki("Timeout while obtaining lock. Please try again"); } if ($data = fread($fd, filesize($filename))) { $pd = unserialize($data); @@ -112,7 +112,7 @@ extends WikiDB_backend htmlspecialchars($filename))); else return $pd; - } + } fclose($fd); } return NULL; @@ -120,17 +120,17 @@ extends WikiDB_backend function _savePage($type, $pagename, $version, $data) { $filename = $this->_pagename2filename($type, $pagename, $version); - if($fd = fopen($filename, 'a+b')) { - $locked = flock($fd,2); // Exclusive blocking lock - if (!$locked) { - ExitWiki("Timeout while obtaining lock. Please try again"); + if($fd = fopen($filename, 'a+b')) { + $locked = flock($fd,2); // Exclusive blocking lock + if (!$locked) { + ExitWiki("Timeout while obtaining lock. Please try again"); } rewind($fd); ftruncate($fd, 0); $pagedata = serialize($data); $len = strlen($pagedata); - $num = fwrite($fd, $pagedata, $len); + $num = fwrite($fd, $pagedata, $len); assert($num == $len); fclose($fd); } else { @@ -152,7 +152,7 @@ extends WikiDB_backend // Load/Save Version-Data function _loadVersionData($pagename, $version) { if ($this->_page_version_data != NULL) { - if ( ($this->_page_version_data['pagename'] == $pagename) && + if ( ($this->_page_version_data['pagename'] == $pagename) && ($this->_page_version_data['version'] == $version) ) { return $this->_page_version_data; } @@ -160,7 +160,7 @@ extends WikiDB_backend $vd = $this->_loadPage('ver_data', $pagename, $version); if ($vd != NULL) { $this->_page_version_data = $vd; - if ( ($this->_page_version_data['pagename'] == $pagename) && + if ( ($this->_page_version_data['pagename'] == $pagename) && ($this->_page_version_data['version'] == $version) ) { return $this->_page_version_data; } @@ -271,7 +271,7 @@ extends WikiDB_backend *
locked
If the page is locked. *
hits
The page hit count. *
created
Unix time of page creation. (FIXME: Deprecated: I - * don't think we need this...) + * don't think we need this...) * */ function get_pagedata($pagename) { @@ -287,7 +287,7 @@ extends WikiDB_backend * * For example: *
-     *   $backend->update_pagedata($pagename, array('locked' => 1)); 
+     *   $backend->update_pagedata($pagename, array('locked' => 1));
      * 
* will set the value of 'locked' to 1 for the specified page, but it * will not affect the value of 'hits' (or whatever other meta-data @@ -295,7 +295,7 @@ extends WikiDB_backend * * To delete a particular piece of meta-data, set it's value to false. *
-     *   $backend->update_pagedata($pagename, array('locked' => false)); 
+     *   $backend->update_pagedata($pagename, array('locked' => false));
      * 
* * @param $pagename string Page name. @@ -311,7 +311,7 @@ extends WikiDB_backend $this->_savePageData($pagename, $newdata); // create a new pagedata-file return; } - + foreach ($newdata as $key => $val) { if (empty($val)) unset($data[$key]); @@ -320,7 +320,7 @@ extends WikiDB_backend } $this->_savePageData($pagename, $data); // write new pagedata-file } - + /** * Get the current version number for a page. @@ -332,7 +332,7 @@ extends WikiDB_backend function get_latest_version($pagename) { return $this->_getLatestVersion($pagename); } - + /** * Get preceding version number. * @@ -350,7 +350,7 @@ extends WikiDB_backend } return $prev; } - + /** * Get revision meta-data and content. * @@ -397,7 +397,7 @@ extends WikiDB_backend @rename($filename,$new); } } - $this->update_pagedata($pagename, array('pagename' => $to)); + $this->update_pagedata($pagename, array('pagename' => $to)); return true; } @@ -426,7 +426,7 @@ extends WikiDB_backend // remove page from latest_version... $this->_setLatestVersion($pagename, 0); } - + /** * Delete an old revision of a page. * @@ -443,8 +443,8 @@ extends WikiDB_backend if ($this->get_latest_version($pagename) == $version) { // try to delete the latest version! // so check if an older version exist: - if ($this->get_versiondata($pagename, - $this->get_previous_version($pagename, $version), + if ($this->get_versiondata($pagename, + $this->get_previous_version($pagename, $version), false) == false) { // there is no older version.... // so the completely page will be removed: @@ -453,7 +453,7 @@ extends WikiDB_backend } } $this->_removePage('ver_data', $pagename, $version); - } + } /** * Create a new page revision. @@ -497,7 +497,7 @@ extends WikiDB_backend } $this->set_versiondata($pagename, $version, $data); } - + /** * Set links for page. * @@ -508,7 +508,7 @@ extends WikiDB_backend function set_links($pagename, $links) { $this->_savePageLinks($pagename, $links); } - + /** * Find pages which link to or are linked from a page. * @@ -520,7 +520,7 @@ extends WikiDB_backend */ function get_links($pagename, $reversed=true, $include_empty=false, $sortby='', $limit='', $exclude='', - $want_relations=false) + $want_relations=false) { if ($reversed == false) return new WikiDB_backend_file_iter($this, $this->_loadPageLinks($pagename)); @@ -552,7 +552,7 @@ extends WikiDB_backend return new WikiDB_backend_dumb_AllRevisionsIter($this, $pagename); } */ - + /** * Get all pages in the database. * @@ -678,7 +678,7 @@ extends WikiDB_backend $search = strtolower(trim($search)); if (!$search) return array(array(),array()); - + $words = preg_split('/\s+/', $search); $exclude = array(); foreach ($words as $key => $word) { @@ -690,7 +690,7 @@ extends WikiDB_backend } return array($words, $exclude); } - + }; class WikiDB_backend_file_iter extends WikiDB_backend_iterator @@ -703,7 +703,7 @@ class WikiDB_backend_file_iter extends WikiDB_backend_iterator if (count($this->_result) > 0) reset($this->_result); } - + function next() { if (!$this->_result) return false; @@ -714,7 +714,7 @@ class WikiDB_backend_file_iter extends WikiDB_backend_iterator if ($e == false) { return false; } - + $pn = $e[1]; if (is_array($pn) and isset($pn['linkto'])) { // support relation link iterator $pn = $pn['linkto']; @@ -745,7 +745,6 @@ class WikiDB_backend_file_iter extends WikiDB_backend_iterator } } -// For emacs users // Local Variables: // mode: php // tab-width: 8 diff --git a/lib/WikiDB/backend/flatfile.php b/lib/WikiDB/backend/flatfile.php index 82d15bb21..d68af19c6 100644 --- a/lib/WikiDB/backend/flatfile.php +++ b/lib/WikiDB/backend/flatfile.php @@ -22,8 +22,8 @@ */ /** - * Backend for handling file storage as pure, readable flatfiles, - * as with PageDump. All other methods are taken from file, which + * Backend for handling file storage as pure, readable flatfiles, + * as with PageDump. All other methods are taken from file, which * handles serialized pages. * latest version_data is it page_data/ * previous ver_data is at ver_data/ @@ -51,7 +51,7 @@ extends WikiDB_backend_file return $this->_dir_names[$type].'/'.FilenameForPage($pagename); else return $this->_dir_names[$type].'/'.FilenameForPage($pagename).'--'.$version; -*/ +*/ } // Load/Save Page-Data @@ -62,14 +62,14 @@ extends WikiDB_backend_file } } //$pd = $this->_loadPage('page_data', $pagename, 0); - + $filename = $this->_pagename2filename('page_data', $pagename, 0); if (!file_exists($filename)) return NULL; if (!filesize($filename)) return array(); if ($fd = @fopen($filename, "rb")) { $locked = flock($fd, 1); // Read lock - if (!$locked) { - ExitWiki("Timeout while obtaining lock. Please try again"); + if (!$locked) { + ExitWiki("Timeout while obtaining lock. Please try again"); } if ($data = fread($fd, filesize($filename))) { // This is the only difference from file: @@ -85,7 +85,7 @@ extends WikiDB_backend_file } fclose($fd); } - + if ($pd != NULL) $this->_page_data = $pd; if ($this->_page_data != NULL) { @@ -95,8 +95,8 @@ extends WikiDB_backend_file } return array(); // no values found } - - /** Store latest version as full page_data flatfile, + + /** Store latest version as full page_data flatfile, * earlier versions as file backend ver_data. * _cached_html will not be stored. * If the given ($pagename,$version) is already in the database, @@ -114,11 +114,11 @@ extends WikiDB_backend_file $this->_savePage('ver_data', $pagename, $version, $data); } } - + // This is different to file and not yet finished. // TODO: fields not being saved as page_data should be saved to ver_data // Store as full page_data flatfile - // pagedata: date, pagename, hits + // pagedata: date, pagename, hits // versiondata: _cached_html and the rest function _savePageData($pagename, $data) { @@ -131,8 +131,8 @@ extends WikiDB_backend_file // data may be pagedate or versiondata updates if (USECACHE and empty($data['pagedata'])) { $cache =& $this->_wikidb->_cache; - if (!empty($cache->_pagedata_cache[$pagename]) - and is_array($cache->_pagedata_cache[$pagename])) + if (!empty($cache->_pagedata_cache[$pagename]) + and is_array($cache->_pagedata_cache[$pagename])) { $cachedata = &$cache->_pagedata_cache[$pagename]; foreach($data as $key => $val) @@ -144,7 +144,7 @@ extends WikiDB_backend_file //unset ($data['pagedata']); //if (empty($data['versiondata'])) // $data['versiondata'] = $data; - // TODO: + // TODO: // with versiondata merge it with previous pagedata, not to overwrite with empty pagedata // with pagedata merge it with previous versiondata, not to overwrite with empty versiondata (content) $olddata = $this->_loadPageData($pagename); @@ -159,7 +159,7 @@ extends WikiDB_backend_file } $data['pagedata'] = array_merge($olddata['pagedata'], $data['pagedata']); $data['versiondata'] = array_merge($olddata['versiondata'], $data['versiondata']); - if (empty($data['versiondata']['%content'])) + if (empty($data['versiondata']['%content'])) $data['versiondata']['%content'] = $olddata['content']; $current = new WikiDB_PageRevision($this->_wikidb, $pagename, $version, $data['versiondata']); unset ($data['versiondata']); @@ -176,16 +176,16 @@ extends WikiDB_backend_file $pagedata .= sprintf("Mime-Version: 1.0 (Produced by PhpWiki %s)\r\n", PHPWIKI_VERSION); $pagedata .= MimeifyPageRevision($page, $current); - + if ($fd = fopen($filename, 'a+b')) { - $locked = flock($fd, 2); // Exclusive blocking lock - if (!$locked) { - ExitWiki("Timeout while obtaining lock. Please try again"); + $locked = flock($fd, 2); // Exclusive blocking lock + if (!$locked) { + ExitWiki("Timeout while obtaining lock. Please try again"); } rewind($fd); ftruncate($fd, 0); $len = strlen($pagedata); - $num = fwrite($fd, $pagedata, $len); + $num = fwrite($fd, $pagedata, $len); assert($num == $len); fclose($fd); } else { @@ -194,9 +194,6 @@ extends WikiDB_backend_file } }; -//class WikiDB_backend_flatfile_iter extends WikiDB_backend_file_iter {}; - -// For emacs users // Local Variables: // mode: php // tab-width: 8 diff --git a/lib/WikiDB/dba.php b/lib/WikiDB/dba.php index d871e33ca..af2e4ce18 100644 --- a/lib/WikiDB/dba.php +++ b/lib/WikiDB/dba.php @@ -12,18 +12,17 @@ class WikiDB_dba extends WikiDB $this->WikiDB($backend, $dbparams); if (empty($dbparams['directory']) - || preg_match('@^/tmp\b@', $dbparams['directory'])) - trigger_error(sprintf(_("The %s files are in the %s directory. Please read the INSTALL file and move the database to a permanent location or risk losing all the pages!"), + || preg_match('@^/tmp\b@', $dbparams['directory'])) + trigger_error(sprintf(_("The %s files are in the %s directory. Please read the INSTALL file and move the database to a permanent location or risk losing all the pages!"), "DBA", "/tmp"), E_USER_WARNING); } }; -// (c-file-style: "gnu") // Local Variables: // mode: php // tab-width: 8 // c-basic-offset: 4 // c-hanging-comment-ender-p: nil // indent-tabs-mode: nil -// End: -?> \ No newline at end of file +// End: +?> diff --git a/lib/WikiDB/file.php b/lib/WikiDB/file.php index 1e161cfcc..f6e50845e 100644 --- a/lib/WikiDB/file.php +++ b/lib/WikiDB/file.php @@ -33,29 +33,28 @@ require_once( 'lib/WikiDB/backend/file.php' ); * Jochen Kalmbach */ class WikiDB_file extends WikiDB -{ +{ /** - * Constructor requires the DB parameters. + * Constructor requires the DB parameters. */ - function WikiDB_file( $dbparams ) + function WikiDB_file( $dbparams ) { $backend = new WikiDB_backend_file( $dbparams ); $this->WikiDB($backend, $dbparams); if (empty($dbparams['directory']) || preg_match('@^/tmp\b@', $dbparams['directory'])) - trigger_error(sprintf(_("The %s files are in the %s directory. Please read the INSTALL file and move the database to a permanent location or risk losing all the pages!"), + trigger_error(sprintf(_("The %s files are in the %s directory. Please read the INSTALL file and move the database to a permanent location or risk losing all the pages!"), "Page", "/tmp"), E_USER_WARNING); } } -// (c-file-style: "gnu") // Local Variables: // mode: php // tab-width: 8 // c-basic-offset: 4 // c-hanging-comment-ender-p: nil // indent-tabs-mode: nil -// End: +// End: ?> diff --git a/lib/WikiDB/flatfile.php b/lib/WikiDB/flatfile.php index f118140a6..f605eddcd 100644 --- a/lib/WikiDB/flatfile.php +++ b/lib/WikiDB/flatfile.php @@ -28,15 +28,15 @@ require_once( 'lib/WikiDB/backend/flatfile.php' ); /** * Wrapper class for the flatfile backend. - * flatfile has readable (mimified) page_data files, the rest is the - * same as in the file backend (serialized arrays). + * flatfile has readable (mimified) page_data files, the rest is the + * same as in the file backend (serialized arrays). */ class WikiDB_flatfile extends WikiDB -{ +{ /** - * Constructor requires the DB parameters. + * Constructor requires the DB parameters. */ - function WikiDB_flatfile( $dbparams ) + function WikiDB_flatfile( $dbparams ) { $backend = new WikiDB_backend_flatfile( $dbparams ); $backend->_wikidb =& $this; @@ -44,18 +44,17 @@ class WikiDB_flatfile extends WikiDB if (empty($dbparams['directory']) || preg_match('@^/tmp\b@', $dbparams['directory'])) - trigger_error(sprintf(_("The %s files are in the %s directory. Please read the INSTALL file and move the database to a permanent location or risk losing all the pages!"), + trigger_error(sprintf(_("The %s files are in the %s directory. Please read the INSTALL file and move the database to a permanent location or risk losing all the pages!"), "Page", "/tmp"), E_USER_WARNING); } } -// (c-file-style: "gnu") // Local Variables: // mode: php // tab-width: 8 // c-basic-offset: 4 // c-hanging-comment-ender-p: nil // indent-tabs-mode: nil -// End: +// End: ?> diff --git a/lib/WikiPlugin.php b/lib/WikiPlugin.php index 6cbe0bc47..6509dd1bb 100644 --- a/lib/WikiPlugin.php +++ b/lib/WikiPlugin.php @@ -28,7 +28,7 @@ class WikiPlugin function managesValidators() { return false; } - + // FIXME: args? function run ($dbi, $argstr, &$request, $basepage) { trigger_error("WikiPlugin::run: pure virtual function", @@ -59,7 +59,7 @@ class WikiPlugin function getWikiPageLinks ($argstr, $basepage) { return false; } - + /** * Get name of plugin. * @@ -82,7 +82,7 @@ class WikiPlugin function getDescription() { return $this->getName(); } - + function getArgs($argstr, $request=false, $defaults=false) { if ($defaults === false) { $defaults = $this->getDefaultArguments(); @@ -109,10 +109,10 @@ class WikiPlugin unset($argstr_args[$arg]); unset($argstr_defaults[$arg]); } - + foreach (array_merge($argstr_args, $argstr_defaults) as $arg => $val) { // TODO: where the heck comes this from? Put the new method over there and peace. - /*if ($request and $request->getArg('pagename') == _("PhpWikiAdministration") + /*if ($request and $request->getArg('pagename') == _("PhpWikiAdministration") and $arg == 'overwrite') // silence this warning ;*/ if ($this->allow_undeclared_arg($arg, $val)) @@ -149,7 +149,7 @@ class WikiPlugin $defaults = array(); if (empty($argstr)) return array($args, $defaults); - + $arg_p = '\w+'; $op_p = '(?:\|\|)?='; $word_p = '\S+'; @@ -199,8 +199,8 @@ class WikiPlugin $val = _(stripslashes($gt_val)); elseif ($count >= 7) $val = $word_val; - else - $val = ''; + else + $val = ''; if ($op == '=') { $args[$arg] = $val; @@ -229,7 +229,7 @@ class WikiPlugin trigger_error(sprintf(_("trailing cruft in plugin args: '%s'"), $argstr), E_USER_NOTICE); } - + /* A plugin can override this to allow undeclared arguments. Or to silence the warning. */ @@ -248,7 +248,7 @@ class WikiPlugin return $pagelist->pageNames(); elseif (is_array($pagelist)) return $pagelist; - else + else return $list; } @@ -268,44 +268,44 @@ class WikiPlugin 'description'=> $this->getDescription(), 'formsize' => 30); } - + function makeForm($argstr, $request) { $form_defaults = $this->getDefaultFormArguments(); - $defaults = array_merge($form_defaults, + $defaults = array_merge($form_defaults, array('start_debug' => $request->getArg('start_debug')), $this->getDefaultArguments()); - + $args = $this->getArgs($argstr, $request, $defaults); $plugin = $this->getName(); $textinput = $args['textinput']; assert(!empty($textinput) && isset($args['textinput'])); - + $form = HTML::form(array('action' => WikiURL($args['targetpage']), 'method' => $args['method'], 'class' => $args['class'], 'accept-charset' => $GLOBALS['charset'])); if (! USE_PATH_INFO ) { $pagename = $request->get('pagename'); - $form->pushContent(HTML::input(array('type' => 'hidden', - 'name' => 'pagename', + $form->pushContent(HTML::input(array('type' => 'hidden', + 'name' => 'pagename', 'value' => $args['targetpage']))); } if ($args['targetpage'] != $this->getName()) { - $form->pushContent(HTML::input(array('type' => 'hidden', - 'name' => 'action', + $form->pushContent(HTML::input(array('type' => 'hidden', + 'name' => 'action', 'value' => $this->getName()))); } $contents = HTML::div(); $contents->setAttr('class', $args['class']); - + foreach ($args as $arg => $val) { if (isset($form_defaults[$arg])) continue; if ($arg != $textinput && $val == $defaults[$arg]) continue; - + $i = HTML::input(array('name' => $arg, 'value' => $val)); - + if ($arg == $textinput) { //if ($inputs[$arg] == 'file') // $attr['type'] = 'file'; @@ -319,7 +319,7 @@ class WikiPlugin $i->setAttr('type', 'hidden'); } $contents->pushContent($i); - + // FIXME: hackage if ($i->getAttr('type') == 'file') { $form->setAttr('enctype', 'multipart/form-data'); @@ -329,7 +329,7 @@ class WikiPlugin 'type' => 'hidden'))); } } - + if (!empty($args['buttontext'])) $contents->pushContent(HTML::input(array('type' => 'submit', 'class' => 'button', @@ -351,7 +351,7 @@ class WikiPlugin HTML::div(array('class'=>'box-title'), $title), HTML::div(array('class'=>'box-data'), $body)); } - + function error ($message) { return HTML::div(array('class' => 'errors'), HTML::strong(fmt("Plugin %s failed.", $this->getName())), ' ', @@ -366,9 +366,9 @@ class WikiPlugin return HTML::div(array('class' => 'disabled-plugin'), $html); } - // TODO: Not really needed, since our plugins generally initialize their own + // TODO: Not really needed, since our plugins generally initialize their own // PageList object, which accepts options['types']. - // Register custom PageList types for special plugins, like + // Register custom PageList types for special plugins, like // 'hi_content' for WikiAdminSearcheplace, 'renamed_pagename' for WikiAdminRename, ... function addPageListColumn ($array) { global $customPageListColumns; @@ -377,7 +377,7 @@ class WikiPlugin $customPageListColumns[$column] = $obj; } } - + // provide a sample usage text for automatic edit-toolbar insertion function getUsage() { $args = $this->getDefaultArguments(); @@ -427,23 +427,23 @@ class WikiPluginLoader { case 'plugin': // FIXME: change API for run() (no $dbi needed). $dbi = $request->getDbh(); - // pass the parsed CachedMarkup context in dbi to the plugin + // pass the parsed CachedMarkup context in dbi to the plugin // to be able to know about itself, or even to change the markup XmlTree (CreateToc) - $dbi->_markup = &$markup; + $dbi->_markup = &$markup; // FIXME: could do better here... if (! $plugin->managesValidators()) { // Output of plugin (potentially) depends on // the state of the WikiDB (other than the current // page.) - + // Lacking other information, we'll assume things // changed last time the wikidb was touched. - + // As an additional hack, mark the ETag weak, since, // for all we know, the page might depend // on things other than the WikiDB (e.g. PhpWeather, // Calendar...) - + $timestamp = $dbi->getTimestamp(); $request->appendValidators(array('dbi_timestamp' => $timestamp, '%mtime' => (int)$timestamp, @@ -467,7 +467,7 @@ class WikiPluginLoader { return false; return $plugin->getWikiPageLinks($plugin_args, $basepage); } - + function parsePI($pi) { if (!preg_match('/^\s*<\?(plugin(?:-form|-link|-list)?)\s+(\w+)\s*(.*?)\s*\?>\s*$/s', $pi, $m)) return $this->_error(sprintf("Bad %s", 'PI')); @@ -477,7 +477,7 @@ class WikiPluginLoader { return array($pi_name, $plugin, $plugin_args); } - + function getPlugin($plugin_name, $pi=false) { global $ErrorManager; global $AllAllowedPlugins; @@ -532,7 +532,6 @@ class WikiPluginLoader { } }; -// (c-file-style: "gnu") // Local Variables: // mode: php // tab-width: 8 diff --git a/lib/WikiPluginCached.php b/lib/WikiPluginCached.php index b5e7b9886..ce8447e63 100644 --- a/lib/WikiPluginCached.php +++ b/lib/WikiPluginCached.php @@ -18,7 +18,7 @@ * 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 - */ + */ /** * You should set up the options in config/config.ini at Part seven: @@ -43,9 +43,9 @@ define('PLUGIN_CACHED_IMG_ONDEMAND', 64);// don't cache define('PLUGIN_CACHED_STATIC', 128); // make it available via /uploads/, not via /getimg.php?id= /** - * An extension of the WikiPlugin class to allow image output and - * cacheing. - * There are several abstract functions to be overloaded. + * An extension of the WikiPlugin class to allow image output and + * cacheing. + * There are several abstract functions to be overloaded. * Have a look at the example files *
  • plugin/TexToPng.php
  • *
  • plugin/CacheTest.php (extremely simple example)
  • @@ -55,21 +55,21 @@ define('PLUGIN_CACHED_STATIC', 128); // make it available via /uploads/, not v *
* * @author Johannes Große, Reini Urban - */ + */ class WikiPluginCached extends WikiPlugin -{ +{ var $_static; - /** + /** * Produces URL and id number from plugin arguments which later on, - * will allow to find a cached image or to reconstruct the complete + * will allow to find a cached image or to reconstruct the complete * plugin call to recreate the image. - * + * * @param cache object the cache object used to store the images - * @param argarray array all parameters (including those set to + * @param argarray array all parameters (including those set to * default values) of the plugin call to be * prepared * @access private - * @return array(id,url) + * @return array(id,url) * * TODO: check if args is needed at all (on lost cache) */ @@ -77,12 +77,12 @@ class WikiPluginCached extends WikiPlugin global $request; //$cacheparams = $GLOBALS['CacheParams']; - $plugincall = serialize( array( + $plugincall = serialize( array( 'pluginname' => $this->getName(), - 'arguments' => $argarray ) ); + 'arguments' => $argarray ) ); $id = $cache->generateId( $plugincall ); $plugincall_arg = rawurlencode($plugincall); - //$plugincall_arg = md5($plugincall); + //$plugincall_arg = md5($plugincall); // will not work if plugin has to recreate content and cache is lost $url = DATA_PATH . '/getimg.php?'; @@ -90,10 +90,10 @@ class WikiPluginCached extends WikiPlugin $url = substr($url, 0, -1); } if (strlen($plugincall_arg) > PLUGIN_CACHED_MAXARGLEN) { - // we can't send the data as URL so we just send the id + // we can't send the data as URL so we just send the id if (!$request->getSessionVar('imagecache'.$id)) { $request->setSessionVar('imagecache'.$id, $plugincall); - } + } $plugincall_arg = false; // not needed anymore } @@ -104,10 +104,10 @@ class WikiPluginCached extends WikiPlugin } else { // Not yet supported. // We are supposed to use the indirect 404 ErrorDocument method - // ($url is assumed to be the url of the image in - // cache_dir and the image creation script is referred to in the + // ($url is assumed to be the url of the image in + // cache_dir and the image creation script is referred to in the // ErrorDocument 404 directive.) - $url .= '/' . PLUGIN_CACHED_FILENAME_PREFIX . $id . '.img' + $url .= '/' . PLUGIN_CACHED_FILENAME_PREFIX . $id . '.img' . ($plugincall_arg ? '?args='.$plugincall_arg : ''); } if ($request->getArg("start_debug") and (DEBUG & _DEBUG_REMOTE)) @@ -115,14 +115,14 @@ class WikiPluginCached extends WikiPlugin return array($id, $url); } // genUrl - /** + /** * Replaces the abstract run method of WikiPlugin to implement - * a cache check which can avoid redundant runs. + * a cache check which can avoid redundant runs. * Do not override this method in a subclass. Instead you may * rename your run method to getHtml, getImage or getMap. * Have a close look on the arguments and required return values, - * however. - * + * however. + * * @access protected * @param dbi WikiDB database abstraction class * @param argstr string plugin arguments in the call from PhpWiki @@ -144,13 +144,13 @@ class WikiPluginCached extends WikiPlugin $this->_args =& $sortedargs; $this->_type = $this->getPluginType(); $this->_static = false; - if ($this->_type & PLUGIN_CACHED_STATIC + if ($this->_type & PLUGIN_CACHED_STATIC or $request->getArg('action') == 'pdf') // htmldoc doesn't grok subrequests - { + { $this->_type = $this->_type & ~PLUGIN_CACHED_STATIC; $this->_static = true; } - + // ---------- embed static image, no getimg.php? url ----------------- if (0 and $this->_static) { //$content = $cache->get($id, 'imagecache'); @@ -185,7 +185,7 @@ class WikiPluginCached extends WikiPlugin return HTML(); } $do_save = true; - } + } break; case PLUGIN_CACHED_IMG_INLINE: if (PLUGIN_CACHED_USECACHE && (!$content || !$content['image'])) { // new @@ -204,7 +204,7 @@ class WikiPluginCached extends WikiPlugin if (!$content || !$content['image'] || !$content['html'] ) { $do_save = $this->produceImage($content, $this, $dbi, $sortedargs, $request, 'html'); if ($this->_static) $url = $content['url']; - $content['html'] = $do_save + $content['html'] = $do_save ? $this->embedMap($id, $url, $content['html'], $dbi, $sortedargs, $request) : false; } @@ -216,7 +216,7 @@ class WikiPluginCached extends WikiPlugin $args = array(); //width+height => object args if (!empty($sortedargs['width'])) $args['width'] = $sortedargs['width']; if (!empty($sortedargs['height'])) $args['height'] = $sortedargs['height']; - $content['html'] = $do_save + $content['html'] = $do_save ? $this->embedObject($url, 'image/svg+xml', $args, HTML::embed(array_merge( array('src'=>$url, 'type'=>'image/svg+xml'), @@ -235,8 +235,8 @@ class WikiPluginCached extends WikiPlugin $args = array(); //width+height => object args if (!empty($sortedargs['width'])) $args['width'] = $sortedargs['width']; if (!empty($sortedargs['height'])) $args['height'] = $sortedargs['height']; - $content['html'] = $do_save_svg - ? $this->embedObject($url, 'image/svg+xml', $args, + $content['html'] = $do_save_svg + ? $this->embedObject($url, 'image/svg+xml', $args, $this->embedImg($pngcontent['url'], $dbi, $sortedargs, $request)) : false; } @@ -256,59 +256,59 @@ class WikiPluginCached extends WikiPlugin /* --------------------- virtual or abstract functions ----------- */ /** - * Sets the type of the plugin to html, image or map + * Sets the type of the plugin to html, image or map * production * - * @access protected - * @return int determines the plugin to produce either html, - * an image or an image map; uses on of the + * @access protected + * @return int determines the plugin to produce either html, + * an image or an image map; uses on of the * following predefined values - *
    + *
      *
    • PLUGIN_CACHED_HTML
    • *
    • PLUGIN_CACHED_IMG_INLINE
    • *
    • PLUGIN_CACHED_IMG_ONDEMAND
    • *
    • PLUGIN_CACHED_MAP
    • - *
    + *
*/ function getPluginType() { return PLUGIN_CACHED_IMG_ONDEMAND; } - /** - * Creates an image handle from the given user arguments. - * This method is only called if the return value of - * getPluginType is set to + /** + * Creates an image handle from the given user arguments. + * This method is only called if the return value of + * getPluginType is set to * PLUGIN_CACHED_IMG_INLINE or PLUGIN_CACHED_IMG_ONDEMAND. * * @access protected pure virtual * @param dbi WikiDB database abstraction class - * @param argarray array complete (!) arguments to produce - * image. It is not necessary to call + * @param argarray array complete (!) arguments to produce + * image. It is not necessary to call * WikiPlugin->getArgs anymore. - * @param request Request ??? + * @param request Request ??? * @return imagehandle image handle if successful * false if an error occured */ function getImage($dbi,$argarray,$request) { - trigger_error('WikiPluginCached::getImage: pure virtual function in file ' + trigger_error('WikiPluginCached::getImage: pure virtual function in file ' . __FILE__ . ' line ' . __LINE__, E_USER_ERROR); return false; } - /** - * Sets the life time of a cache entry in seconds. + /** + * Sets the life time of a cache entry in seconds. * Expired entries are not used anymore. * During a garbage collection each expired entry is * removed. If removing all expired entries is not * sufficient, the expire time is ignored and removing * is determined by the last "touch" of the entry. - * + * * @access protected virtual * @param dbi WikiDB database abstraction class * @param argarray array complete (!) arguments. It is - * not necessary to call + * not necessary to call * WikiPlugin->getArgs anymore. - * @param request Request ??? + * @param request Request ??? * @return string format: '+seconds' * '0' never expires */ @@ -316,18 +316,18 @@ class WikiPluginCached extends WikiPlugin return '0'; // persist forever } - /** - * Decides the image type of an image output. + /** + * Decides the image type of an image output. * Always used unless plugin type is PLUGIN_CACHED_HTML. - * + * * @access protected virtual * @param dbi WikiDB database abstraction class * @param argarray array complete (!) arguments. It is - * not necessary to call + * not necessary to call * WikiPlugin->getArgs anymore. - * @param request Request ??? + * @param request Request ??? * @return string 'png', 'jpeg' or 'gif' - */ + */ function getImageType(&$dbi, $argarray, &$request) { if (in_array($argarray['imgtype'], preg_split('/\s*:\s*/', PLUGIN_CACHED_IMGTYPES))) return $argarray['imgtype']; @@ -335,53 +335,53 @@ class WikiPluginCached extends WikiPlugin return 'png'; } - /** + /** * Produces the alt text for an image. - * <img src=... alt="getAlt(...)"> + * <img src=... alt="getAlt(...)"> * * @access protected virtual * @param dbi WikiDB database abstraction class * @param argarray array complete (!) arguments. It is - * not necessary to call + * not necessary to call * WikiPlugin->getArgs anymore. - * @param request Request ??? + * @param request Request ??? * @return string "alt" description of the image */ function getAlt($dbi,$argarray,$request) { return 'getName().' '.$this->glueArgs($argarray).'?>'; } - /** - * Creates HTML output to be cached. - * This method is only called if the plugin_type is set to + /** + * Creates HTML output to be cached. + * This method is only called if the plugin_type is set to * PLUGIN_CACHED_HTML. * * @access protected pure virtual * @param dbi WikiDB database abstraction class - * @param argarray array complete (!) arguments to produce - * image. It is not necessary to call + * @param argarray array complete (!) arguments to produce + * image. It is not necessary to call * WikiPlugin->getArgs anymore. - * @param request Request ??? + * @param request Request ??? * @param string $basepage Pagename to use to interpret links [/relative] page names. * @return string html to be printed in place of the plugin command * false if an error occured */ function getHtml($dbi, $argarray, $request, $basepage) { - trigger_error('WikiPluginCached::getHtml: pure virtual function in file ' + trigger_error('WikiPluginCached::getHtml: pure virtual function in file ' . __FILE__ . ' line ' . __LINE__, E_USER_ERROR); } - /** - * Creates HTML output to be cached. - * This method is only called if the plugin_type is set to + /** + * Creates HTML output to be cached. + * This method is only called if the plugin_type is set to * PLUGIN_CACHED_HTML. * * @access protected pure virtual * @param dbi WikiDB database abstraction class - * @param argarray array complete (!) arguments to produce - * image. It is not necessary to call + * @param argarray array complete (!) arguments to produce + * image. It is not necessary to call * WikiPlugin->getArgs anymore. - * @param request Request ??? + * @param request Request ??? * @return array(html,handle) html for the map interior (to be specific, * only <area;> tags defining hot spots) * handle is an imagehandle to the corresponding @@ -389,13 +389,13 @@ class WikiPluginCached extends WikiPlugin * array(false,false) if an error occured */ function getMap($dbi, $argarray, $request) { - trigger_error('WikiPluginCached::getHtml: pure virtual function in file ' + trigger_error('WikiPluginCached::getHtml: pure virtual function in file ' . __FILE__ . ' line ' . __LINE__, E_USER_ERROR); } /* --------------------- produce Html ----------------------------- */ - /** + /** * Creates an HTML map hyperlinked to the image specified * by url and containing the hotspots given by map. * @@ -405,10 +405,10 @@ class WikiPluginCached extends WikiPlugin * @param map string <area> tags defining active * regions in the map * @param dbi WikiDB database abstraction class - * @param argarray array complete (!) arguments to produce - * image. It is not necessary to call + * @param argarray array complete (!) arguments to produce + * image. It is not necessary to call * WikiPlugin->getArgs anymore. - * @param request Request ??? + * @param request Request ??? * @return string html output */ function embedMap($id,$url,$map,&$dbi,$argarray,&$request) { @@ -416,13 +416,13 @@ class WikiPluginCached extends WikiPlugin $key = substr($id,0,8).substr(microtime(),0,6); return HTML(HTML::map(array( 'name' => $key ), $map ), HTML::img( array( - 'src' => $url, - // 'alt' => htmlspecialchars($this->getAlt($dbi,$argarray,$request)) + 'src' => $url, + // 'alt' => htmlspecialchars($this->getAlt($dbi,$argarray,$request)) 'usemap' => '#'.$key )) ); } - /** + /** * Creates an HTML <img> tag hyperlinking to the specified * url and produces an alternative text for non-graphical * browsers. @@ -432,14 +432,14 @@ class WikiPluginCached extends WikiPlugin * @param map string <area> tags defining active * regions in the map * @param dbi WikiDB database abstraction class - * @param argarray array complete (!) arguments to produce - * image. It is not necessary to call + * @param argarray array complete (!) arguments to produce + * image. It is not necessary to call * WikiPlugin->getArgs anymore. - * @param request Request ??? + * @param request Request ??? * @return string html output */ function embedImg($url, $dbi, $argarray, $request) { - return HTML::img( array( + return HTML::img( array( 'src' => $url, 'alt' => htmlspecialchars($this->getAlt($dbi, $argarray, $request)) ) ); } @@ -474,7 +474,7 @@ class WikiPluginCached extends WikiPlugin // ---------------------- static member functions --------------------------- // -------------------------------------------------------------------------- - /** + /** * Creates one static PEAR Cache object and returns copies afterwards. * FIXME: There should be references returned * @@ -483,7 +483,7 @@ class WikiPluginCached extends WikiPlugin */ function newCache() { static $staticcache; - + if (!is_object($staticcache)) { if (!class_exists('Cache')) { // uuh, pear not in include_path! should print a warning. @@ -502,7 +502,7 @@ class WikiPluginCached extends WikiPlugin $cacheparams['imgtypes'] = preg_split('/\s*:\s*/', PLUGIN_CACHED_IMGTYPES); $staticcache = new Cache(PLUGIN_CACHED_DATABASE, $cacheparams); $staticcache->gc_maxlifetime = PLUGIN_CACHED_MAXLIFETIME; - + if (! PLUGIN_CACHED_USECACHE ) { $staticcache->setCaching(false); } @@ -510,8 +510,8 @@ class WikiPluginCached extends WikiPlugin return $staticcache; // FIXME: use references ? } - /** - * Determines whether a needed image type may is available + /** + * Determines whether a needed image type may is available * from the GD library and gives an alternative otherwise. * * @access public static @@ -521,14 +521,14 @@ class WikiPluginCached extends WikiPlugin */ function decideImgType($wish) { - if ($wish=='html') return $wish; + if ($wish=='html') return $wish; if ($wish=='jpg') { $wish = 'jpeg'; } $supportedtypes = array(); // Todo: swf, pdf, ... - $imagetypes = array( + $imagetypes = array( 'png' => IMG_PNG, - 'gif' => IMG_GIF, + 'gif' => IMG_GIF, 'jpeg' => IMG_JPEG, 'wbmp' => IMG_WBMP, 'xpm' => IMG_XPM, @@ -542,25 +542,25 @@ class WikiPluginCached extends WikiPlugin $presenttypes = ImageTypes(); foreach ($imagetypes as $imgtype => $bitmask) if ( $presenttypes && $bitmask ) - array_push($supportedtypes, $imgtype); + array_push($supportedtypes, $imgtype); } else { foreach ($imagetypes as $imgtype => $bitmask) if (function_exists("Image".$imgtype)) array_push($supportedtypes, $imgtype); } - if (in_array($wish, $supportedtypes)) + if (in_array($wish, $supportedtypes)) return $wish; elseif (!empty($supportedtypes)) return reset($supportedtypes); else return 'html'; - + } // decideImgType - /** + /** * Writes an image into a file or to the browser. - * Note that there is no check if the image can + * Note that there is no check if the image can * be written. * * @access public static @@ -582,16 +582,16 @@ class WikiPluginCached extends WikiPlugin } // writeImage - /** + /** * Sends HTTP Header for some predefined file types. * There is no parameter check. * * @access public static * @param doctype string 'gif', 'png', 'jpeg', 'html' - * @return void + * @return void */ function writeHeader($doctype) { - static $IMAGEHEADER = array( + static $IMAGEHEADER = array( 'gif' => 'Content-type: image/gif', 'png' => 'Content-type: image/png', 'jpeg' => 'Content-type: image/jpeg', @@ -606,9 +606,9 @@ class WikiPluginCached extends WikiPlugin } - /** - * Converts argument array to a string of format option="value". - * This should only be used for displaying plugin options for + /** + * Converts argument array to a string of format option="value". + * This should only be used for displaying plugin options for * the quoting of arguments is not safe, yet. * * @access public static @@ -619,7 +619,7 @@ class WikiPluginCached extends WikiPlugin if (!empty($argarray)) { $argstr = ''; while (list($key,$value)=each($argarray)) { - $argstr .= $key. '=' . '"' . $value . '" '; + $argstr .= $key. '=' . '"' . $value . '" '; // FIXME: How are values quoted? Can a value contain '"'? // TODO: rawurlencode(value) } @@ -630,7 +630,7 @@ class WikiPluginCached extends WikiPlugin // ---------------------- FetchImageFromCache ------------------------------ - /** + /** * Extracts the cache entry id from the url and the plugin call * parameters if available. * @@ -649,7 +649,7 @@ class WikiPluginCached extends WikiPlugin */ function checkCall1(&$id, &$plugincall, $cache, $request, $errorformat) { $id = $request->getArg('id'); - $plugincall = rawurldecode($request->getArg('args')); + $plugincall = rawurldecode($request->getArg('args')); if (!$id) { if (!$plugincall) { @@ -660,21 +660,21 @@ class WikiPluginCached extends WikiPlugin } else { $id = $cache->generateId( $plugincall ); } - } - return true; + } + return true; } // checkCall1 - /** + /** * Extracts the parameters necessary to reconstruct the plugin - * call needed to produce the requested image. + * call needed to produce the requested image. * - * @access static private - * @param plugincall string reference to serialized array containing both + * @access static private + * @param plugincall string reference to serialized array containing both * name and parameters of the plugin call * @param request Request ??? * @return boolean false if an error occurs, true otherwise. - * + * */ function checkCall2(&$plugincall, $request) { // if plugincall wasn't sent by URL, it must have been @@ -685,19 +685,19 @@ class WikiPluginCached extends WikiPlugin // without having written bad code. So gettextify it. $errortext = sprintf( gettext ("There is no image creation data available to id '%s'. Please reload referring page." ), - $id ); + $id ); $this->printError($errorformat, $errortext); - return false; - } + return false; + } } $plugincall = unserialize($plugincall); return true; } // checkCall2 - /** - * Creates an image or image map depending on the plugin type. - * @access static private + /** + * Creates an image or image map depending on the plugin type. + * @access static private * @param content array reference to created array which overwrite the keys * 'image', 'imagetype' and possibly 'html' * @param plugin WikiPluginCached plugin which is called to create image or map @@ -716,21 +716,21 @@ class WikiPluginCached extends WikiPlugin $imagehandle = $plugin->getImage($dbi, $argarray, $request); } - $content['imagetype'] + $content['imagetype'] = $this->decideImgType($plugin->getImageType($dbi, $argarray, $request)); $errortext = $plugin->getError(); if (!$imagehandle||$errortext) { if (!$errortext) { $errortext = "'getName(). ' ' - . $this->glueArgs($argarray)." ?>' returned no image, " + . $this->glueArgs($argarray)." ?>' returned no image, " . " although no error was reported."; } $this->printError($errorformat, $errortext); - return false; + return false; } - // image handle -> image data + // image handle -> image data if (!empty($this->_static)) { $ext = "." . $content['imagetype']; if (is_string($imagehandle) and file_exists($imagehandle)) { @@ -789,7 +789,7 @@ class WikiPluginCached extends WikiPlugin } else { $ext = isWindows()? ".tmp" : ""; } - $temp = tempnam(isWindows() ? str_replace('/', "\\", PLUGIN_CACHED_CACHE_DIR) + $temp = tempnam(isWindows() ? str_replace('/', "\\", PLUGIN_CACHED_CACHE_DIR) : PLUGIN_CACHED_CACHE_DIR, $prefix ? $prefix : PLUGIN_CACHED_FILENAME_PREFIX); if (isWindows()) { @@ -801,7 +801,7 @@ class WikiPluginCached extends WikiPlugin return $temp; } - /** + /** * Main function for obtaining images from cache or generating on-the-fly * from parameters sent by url or session vars. * @@ -811,31 +811,31 @@ class WikiPluginCached extends WikiPlugin * @param errorformat string outputs errors in 'png', 'gif', 'jpeg' or 'html' */ function fetchImageFromCache($dbi, $request, $errorformat='png') { - $cache = $this->newCache(); + $cache = $this->newCache(); $errorformat = $this->decideImgType($errorformat); // get id if (!$this->checkCall1($id, $plugincall, $cache, $request, $errorformat)) return false; - // check cache + // check cache $content = $cache->get($id, 'imagecache'); if (!empty($content['image'])) { $this->writeHeader($content['imagetype']); - print $content['image']; + print $content['image']; return true; - } + } if (!empty($content['html'])) { - print $content['html']; + print $content['html']; return true; - } + } // static version? if (!empty($content['file']) && !empty($content['url']) && file_exists($content['file'])) { print $this->embedImg($content['url'], $dbi, array(), $request); return true; - } + } // re-produce image. At first, we need the plugincall parameters. // Cached args with matching id override given args to shorten getimg.php?id=md5 - if (!empty($content['args'])) + if (!empty($content['args'])) $plugincall['arguments'] = $content['args']; if (!$this->checkCall2($plugincall, $request)) return false; @@ -852,7 +852,7 @@ class WikiPluginCached extends WikiPlugin $this->printError($errorformat, $errortext); } - if (!$this->produceImage($content, $plugin, $dbi, $argarray, + if (!$this->produceImage($content, $plugin, $dbi, $argarray, $request, $errorformat)) return false; @@ -860,19 +860,19 @@ class WikiPluginCached extends WikiPlugin if ($content['image']) { $cache->save($id, $content, $expire, 'imagecache'); - $this->writeHeader($content['imagetype']); + $this->writeHeader($content['imagetype']); print $content['image']; return true; } $errortext = "Could not create image file from imagehandle."; $this->printError($errorformat, $errortext); - return false; + return false; } // FetchImageFromCache - // -------------------- error handling ---------------------------- + // -------------------- error handling ---------------------------- - /** + /** * Resets buffer containing all error messages. This is allways * done before invoking any abstract creation routines like * getImage. @@ -883,9 +883,9 @@ class WikiPluginCached extends WikiPlugin function resetError() { $this->_errortext = ''; } - - /** - * Returns all accumulated error messages. + + /** + * Returns all accumulated error messages. * * @access protected * @return string error messages printed with complain. @@ -894,13 +894,13 @@ class WikiPluginCached extends WikiPlugin return $this->_errortext; } - /** - * Collects the error messages in a string for later output + /** + * Collects the error messages in a string for later output * by WikiPluginCached. This should be used for any errors * that occur during data (html,image,map) creation. - * + * * @access protected - * @param addtext string errormessage to be printed (separate + * @param addtext string errormessage to be printed (separate * multiple lines with '\n') * @return void */ @@ -908,8 +908,8 @@ class WikiPluginCached extends WikiPlugin $this->_errortext .= $addtext; } - /** - * Outputs the error as image if possible or as html text + /** + * Outputs the error as image if possible or as html text * if wished or html header has already been sent. * * @access static protected @@ -931,24 +931,24 @@ class WikiPluginCached extends WikiPlugin if (is_object($errortext)) $errortext = $errortext->asString(); $im = $this->text2img($errortext, 2, $red, $grey); - if (!$im) { + if (!$im) { trigger_error($errortext, E_USER_WARNING); return; } $this->writeHeader($imgtype); - $this->writeImage($imgtype, $im); + $this->writeImage($imgtype, $im); ImageDestroy($im); } } // printError - /** + /** * Basic text to image converter for error handling which allows * multiple line output. - * It will only output the first 25 lines of 80 characters. Both + * It will only output the first 25 lines of 80 characters. Both * values may be smaller if the chosen font is to big for there * is further restriction to 600 pixel in width and 350 in height. - * + * * @access static public * @param txt string multi line text to be converted * @param fontnr integer number (1-5) telling gd which internal font to use; @@ -976,8 +976,8 @@ class WikiPluginCached extends WikiPlugin } } - // prepare Parameters - + // prepare Parameters + // set maximum values $IMAGESIZE = array( 'cols' => 80, @@ -989,7 +989,7 @@ class WikiPluginCached extends WikiPlugin $charx = ImageFontWidth($fontnr); $chary = ImageFontHeight($fontnr); } else { - $charx = 10; $chary = 10; + $charx = 10; $chary = 10; } $marginx = $charx; $marginy = floor($chary/2); @@ -1011,27 +1011,27 @@ class WikiPluginCached extends WikiPlugin } $lines[$y] = chop(substr($txt, 0, $breaklen)); $wx = max($wx,strlen($lines[$y++])); - $txt = substr($txt, $breaklen); + $txt = substr($txt, $breaklen); } while ($txt && ($y < $IMAGESIZE['rows'])); // recalculate image size $IMAGESIZE['rows'] = $y; $IMAGESIZE['cols'] = $wx; - + $IMAGESIZE['width'] = $IMAGESIZE['cols'] * $charx + 2*$marginx; $IMAGESIZE['height'] = $IMAGESIZE['rows'] * $chary + 2*$marginy; // create blank image $im = @ImageCreate($IMAGESIZE['width'],$IMAGESIZE['height']); - $col = ImageColorAllocate($im, $textcol[0], $textcol[1], $textcol[2]); - $bg = ImageColorAllocate($im, $bgcol[0], $bgcol[1], $bgcol[2]); + $col = ImageColorAllocate($im, $textcol[0], $textcol[1], $textcol[2]); + $bg = ImageColorAllocate($im, $bgcol[0], $bgcol[1], $bgcol[2]); ImageFilledRectangle($im, 0, 0, $IMAGESIZE['width']-1, $IMAGESIZE['height']-1, $bg); - + // write text lines foreach($lines as $nr => $textstr) { - ImageString( $im, $fontnr, $marginx, $marginy+$nr*$chary, + ImageString( $im, $fontnr, $marginx, $marginy+$nr*$chary, $textstr, $col ); } return $im; @@ -1107,9 +1107,8 @@ class WikiPluginCached extends WikiPlugin return $ok; } -} // WikiPluginCached +} -// For emacs users // Local Variables: // mode: php // tab-width: 4 diff --git a/lib/WikiTheme.php b/lib/WikiTheme.php index 38b96b868..4b0de17b7 100644 --- a/lib/WikiTheme.php +++ b/lib/WikiTheme.php @@ -2,24 +2,24 @@ /* Copyright (C) 2002,2004,2005,2006,2008,2009,2010 $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, + * Customize output by themes: templates, css, special links functions, * and more formatting. */ @@ -61,7 +61,7 @@ function WikiLink ($page_or_rev, $type = 'known', $label = false) { } $version = false; - + if (isa($page_or_rev, 'WikiDB_PageRevision')) { $version = $page_or_rev->getVersion(); if ($page_or_rev->isCurrent()) @@ -88,7 +88,7 @@ function WikiLink ($page_or_rev, $type = 'known', $label = false) { if (!$wikipage->isValid('strict')) return $WikiTheme->linkBadWikiWord($wikipage, $label); } - + if ($type == 'auto' or $type == 'if_known') { if (isset($page)) { $exists = $page->exists(); @@ -109,8 +109,8 @@ function WikiLink ($page_or_rev, $type = 'known', $label = false) { // 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 + if (isa($wikipage, 'WikiPageName') and + ! $label and strchr(substr($wikipage->shortName,1), SUBPAGE_SEPARATOR)) { $parts = explode(SUBPAGE_SEPARATOR, $wikipage->shortName); @@ -124,11 +124,11 @@ function WikiLink ($page_or_rev, $type = 'known', $label = false) { $part = " " . $part; if ($part) $link->pushContent($WikiTheme->linkExistingWikiWord($parent, $sep . $part)); - $sep = $WikiTheme->_autosplitWikiWords + $sep = $WikiTheme->_autosplitWikiWords ? ' ' . SUBPAGE_SEPARATOR : SUBPAGE_SEPARATOR; } if ($exists) - $link->pushContent($WikiTheme->linkExistingWikiWord($wikipage, $sep . $last_part, + $link->pushContent($WikiTheme->linkExistingWikiWord($wikipage, $sep . $last_part, $version)); else $link->pushContent($WikiTheme->linkUnknownWikiWord($wikipage, $sep . $last_part)); @@ -190,7 +190,7 @@ function Button ($action, $label = false, $page_or_rev = false, $options = false class WikiTheme { var $HTML_DUMP_SUFFIX = ''; - var $DUMP_MODE = false, $dumped_images, $dumped_css; + var $DUMP_MODE = false, $dumped_images, $dumped_css; /** * noinit: Do not initialize unnecessary items in default_theme fallback twice. @@ -217,7 +217,7 @@ class WikiTheme { } if ($noinit) return; $this->_css = array(); - + // on derived classes do not add headers twice if (count($this->_parents) > 1) { return; @@ -248,7 +248,7 @@ class WikiTheme { function file ($file) { return $this->_path . "$this->_theme/$file"; - } + } function _findFile ($file, $missing_okay = false) { if (file_exists($this->file($file))) @@ -419,13 +419,13 @@ class WikiTheme { */ 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. * @@ -441,11 +441,11 @@ class WikiTheme { 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"); @@ -457,7 +457,7 @@ class WikiTheme { 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 @@ -468,20 +468,20 @@ class WikiTheme { $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; + else + $offset = 0; $now = time() + $offset; $today = localtime($now, true); @@ -489,11 +489,11 @@ class WikiTheme { 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'] + if ($time['tm_yday'] == $yesterday['tm_yday'] and $time['tm_year'] == $yesterday['tm_year']) return _("yesterday"); @@ -596,7 +596,7 @@ class WikiTheme { $default_text = $wikiword->shortName; else $default_text = $wikiword; - + if (!empty($linktext)) { $link->pushContent($linktext); $link->setAttr('class', 'named-wiki'); @@ -622,7 +622,7 @@ class WikiTheme { else { $default_text = $wikiword; } - + if ($this->DUMP_MODE) { // HTML, PDF or XML $link = HTML::span( empty($linktext) ? $wikiword : $linktext); $link->setAttr('style', 'text-decoration: underline'); @@ -631,9 +631,9 @@ class WikiTheme { 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')))) + 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'); @@ -673,7 +673,7 @@ class WikiTheme { function linkBadWikiWord($wikiword, $linktext = '') { global $ErrorManager; - + if ($linktext) { $text = $linktext; } @@ -689,10 +689,10 @@ class WikiTheme { else $message = sprintf(_("'%s': Bad page name"), $wikiword); $ErrorManager->warning($message); - + return HTML::span(array('class' => 'badwikiword'), $text); } - + //////////////////////////////////////////////////////////////// // // Images and Icons @@ -744,10 +744,10 @@ class WikiTheme { if ($this->DUMP_MODE) { if (empty($this->dumped_images)) $this->dumped_images = array(); $path = "images/". basename($path); - if (!in_array($path,$this->dumped_images)) + if (!in_array($path,$this->dumped_images)) $this->dumped_images[] = $path; } - return $path; + return $path; } function setLinkIcon($proto, $image = false) { @@ -766,8 +766,8 @@ class WikiTheme { return false; } - var $_linkIcon = 'front'; // or 'after' or 'no'. - // maybe also 'spanall': there is a scheme currently in effect with front, which + 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 () { @@ -798,7 +798,7 @@ class WikiTheme { if ($url && strstr($url, '%')) { $url = preg_replace('|([^/]+)$|e', 'urlencode("\\1")', $url); } - if (!$url) {// Jeff complained about png not supported everywhere. + if (!$url) {// Jeff complained about png not supported everywhere. // This was not PC until 2005. $url = $this->_findButton("$qtext.gif"); if ($url && strstr($url, '%')) { @@ -823,7 +823,7 @@ class WikiTheme { foreach ($this->_button_path as $dir) { if ($path = $this->_findData("$dir/$button_file", 1)) - return $path; + return $path; } return false; } @@ -834,7 +834,7 @@ class WikiTheme { 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] == '.') @@ -876,16 +876,16 @@ class WikiTheme { if (preg_match('/^submit:(.*)$/', $url, $m)) return $this->makeSubmitButton($text, $m[1], $class, $options); - if (is_string($text)) + if (is_string($text)) $imgurl = $this->getButtonURL($text); - else + else $imgurl = $text; if ($imgurl) - return new ImageButton($text, $url, - in_array($class,array("wikiaction","wikiadmin"))?"wikibutton":$class, + return new ImageButton($text, $url, + in_array($class,array("wikiaction","wikiadmin"))?"wikibutton":$class, $imgurl, $options); else - return new Button($this->maybeSplitWikiWord($text), $url, + return new Button($this->maybeSplitWikiWord($text), $url, $class, $options); } @@ -922,8 +922,8 @@ class WikiTheme { * * @return object A Button object. */ - function makeActionButton ($action, $label = false, - $page_or_rev = false, $options = false) + function makeActionButton ($action, $label = false, + $page_or_rev = false, $options = false) { extract($this->_get_name_and_rev($page_or_rev)); @@ -948,19 +948,19 @@ class WikiTheme { 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()) + 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")) + elseif ((browserDetect("firefox/2") or browserDetect("minefield/3") or browserDetect("SeaMonkey/1.1")) and ((browserDetect("windows") or browserDetect("x11")))) - $tooltipAccessKeyPrefix = 'alt-shift'; + $tooltipAccessKeyPrefix = 'alt-shift'; return $tooltipAccessKeyPrefix; } @@ -976,7 +976,7 @@ class WikiTheme { } return $attrs; } - + /** * Make a "button" which links to a wiki-page. * @@ -1003,7 +1003,7 @@ class WikiTheme { $args = $version ? array('version' => $version) : false; if ($action) $args['action'] = $action; - return $this->makeButton($label ? $label : $pagename, + return $this->makeButton($label ? $label : $pagename, WikiURL($pagename, $args), 'wiki'); } @@ -1120,14 +1120,14 @@ class WikiTheme { if ($is_alt) $link->setAttr('title', $title); - if ($media) + 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; } @@ -1299,7 +1299,7 @@ else window.onload = downloadJSAtOnload;'); function load() { $this->initGlobals(); - + // CSS file defines fonts, colors and background images for this // style. The companion '*-heavy.css' file isn't defined, it's just // expected to be in the same directory that the base style is in. @@ -1326,7 +1326,7 @@ else window.onload = downloadJSAtOnload;'); * The logo image appears on every page and links to the HomePage. */ $this->addImageAlias('logo', WIKI_NAME . 'Logo.png'); - + $this->addImageAlias('search', 'search.png'); /** @@ -1360,9 +1360,9 @@ else window.onload = downloadJSAtOnload;'); /** * Layout improvement with dangling links for mostly closed wiki's: - * If false, only users with edit permissions will be presented the + * If false, only users with edit permissions will be presented the * special wikiunknown class with "?" and Tooltip. - * If true (default), any user will see the ?, but will be presented + * If true (default), any user will see the ?, but will be presented * the PrintLoginForm on a click. */ //$this->setAnonEditUnknownLinks(false); @@ -1375,7 +1375,7 @@ else window.onload = downloadJSAtOnload;'); * Do not include the server's zone (%Z), times are converted to the * user's time zone. * - * Suggestion for french: + * Suggestion for french: * $this->setDateFormat("%A %e %B %Y"); * $this->setTimeFormat("%H:%M:%S"); * Suggestion for capable php versions, using the server locale: @@ -1389,35 +1389,35 @@ else window.onload = downloadJSAtOnload;'); * To suppress times in the "Last edited on" messages, give a * give a second argument of false: */ - //$this->setDateFormat("%B %d, %Y", false); + //$this->setDateFormat("%B %d, %Y", false); /** * Custom UserPreferences: * A list of name => _UserPreference class pairs. - * Rationale: Certain themes should be able to extend the predefined list + * Rationale: Certain themes should be able to extend the predefined list * of preferences. Display/editing is done in the theme specific userprefs.tmpl * but storage/sanification/update/... must be extended to the Get/SetPreferences methods. * See themes/wikilens/themeinfo.php */ - //$this->customUserPreference(); + //$this->customUserPreference(); /** * Register custom PageList type and define custom PageList classes. - * Rationale: Certain themes should be able to extend the predefined list - * of pagelist types. E.g. certain plugins, like MostPopular might use + * Rationale: Certain themes should be able to extend the predefined list + * of pagelist types. E.g. certain plugins, like MostPopular might use * info=pagename,hits,rating * which displays the rating column whenever the wikilens theme is active. * See themes/wikilens/themeinfo.php */ - //$this->addPageListColumn(); + //$this->addPageListColumn(); } // end of load /** * Custom UserPreferences: * A list of name => _UserPreference class pairs. - * Rationale: Certain themes should be able to extend the predefined list + * Rationale: Certain themes should be able to extend the predefined list * of preferences. Display/editing is done in the theme specific userprefs.tmpl * but storage/sanification/update/... must be extended to the Get/SetPreferences methods. * These values are just ignored if another theme is used. @@ -1432,7 +1432,7 @@ else window.onload = downloadJSAtOnload;'); } /** addPageListColumn(array('rating' => new _PageList_Column_rating('rating', _("Rate")))) - * Register custom PageList types for special themes, like + * Register custom PageList types for special themes, like * 'rating' for wikilens */ function addPageListColumn ($array) { @@ -1465,7 +1465,7 @@ else window.onload = downloadJSAtOnload;'); } // Works only on action=browse. Patch #970004 by pixels - // Usage: call $WikiTheme->initDoubleClickEdit() from theme init or + // Usage: call $WikiTheme->initDoubleClickEdit() from theme init or // define ENABLE_DOUBLECLICKEDIT function initDoubleClickEdit() { if (!$this->HTML_DUMP_SUFFIX) @@ -1476,10 +1476,10 @@ else window.onload = downloadJSAtOnload;'); // by Bitflux GmbH, bitflux.ch. You need to install the livesearch.js seperately. // Google's or acdropdown is better. function initLiveSearch() { - //subclasses of Sidebar will init this twice + //subclasses of Sidebar will init this twice static $already = 0; if (!$this->HTML_DUMP_SUFFIX and !$already) { - $this->addMoreAttr('body', 'LiveSearch', + $this->addMoreAttr('body', 'LiveSearch', HTML::Raw(" onload=\"liveSearchInit()")); $this->addMoreHeaders(JavaScript('var liveSearchURI="' .WikiURL(_("TitleSearch"),false,true).'";')); @@ -1492,7 +1492,7 @@ else window.onload = downloadJSAtOnload;'); // Immediate title search results via XMLHttpRequest // using the shipped moacdropdown js-lib function initMoAcDropDown() { - //subclasses of Sidebar will init this twice + //subclasses of Sidebar will init this twice static $already = 0; if (!$this->HTML_DUMP_SUFFIX and !$already) { $dir = $this->_findData('moacdropdown'); @@ -1504,7 +1504,7 @@ else window.onload = downloadJSAtOnload;'); // if autocomplete_remote is used: (getobject2 also for calc. the showlist width) if (DEBUG) { foreach (array("mobrowser.js","modomevent3.js","modomt.js", - "modomext.js","getobject2.js","xmlextras.js") as $js) + "modomext.js","getobject2.js","xmlextras.js") as $js) { $this->addMoreHeaders(JavaScript('', array('src' => "$dir/js/$js"))); } @@ -1527,7 +1527,7 @@ else window.onload = downloadJSAtOnload;'); } function calendarLink($date = false) { - return $this->calendarBase() . SUBPAGE_SEPARATOR . + return $this->calendarBase() . SUBPAGE_SEPARATOR . strftime("%Y-%m-%d", $date ? $date : time()); } @@ -1535,11 +1535,11 @@ else window.onload = downloadJSAtOnload;'); static $UserCalPageTitle = false; global $request; - if (!$UserCalPageTitle) - $UserCalPageTitle = $request->_user->getId() . + if (!$UserCalPageTitle) + $UserCalPageTitle = $request->_user->getId() . SUBPAGE_SEPARATOR . _("Calendar"); if (!$UserCalPageTitle) - $UserCalPageTitle = (BLOG_EMPTY_DEFAULT_PREFIX ? '' + $UserCalPageTitle = (BLOG_EMPTY_DEFAULT_PREFIX ? '' : ($request->_user->getId() . SUBPAGE_SEPARATOR)) . "Blog"; return $UserCalPageTitle; } @@ -1551,7 +1551,7 @@ else window.onload = downloadJSAtOnload;'); $jslang = @$GLOBALS['LANG']; $this->addMoreHeaders ( - $this->_CSSlink(0, + $this->_CSSlink(0, $this->_findFile('jscalendar/calendar-phpwiki.css'), 'all')); $this->addMoreHeaders (JavaScript('', @@ -1561,7 +1561,7 @@ else window.onload = downloadJSAtOnload;'); $this->addMoreHeaders(JavaScript('',array('src' => $langfile))); $this->addMoreHeaders (JavaScript('', - array('src' => + array('src' => $this->_findData('jscalendar/calendar-setup'.(DEBUG?'':'_stripped').'.js')))); // Get existing date entries for the current user @@ -1577,7 +1577,7 @@ else window.onload = downloadJSAtOnload;'); //var SPECIAL_DAYS = {"2004-05-11":1,"2004-05-12":1,"2004-06-01":1} $this->addMoreHeaders(JavaScript(' /* This table holds the existing calender entries for the current user - * calculated from the database + * calculated from the database */ var SPECIAL_DAYS = '.javascript_quote_string($js_exist).'; @@ -1593,8 +1593,8 @@ function dateExists(date, y, m, d) { if (!exists) return false; else return true; } -// This is the actual date status handler. -// Note that it receives the date object as well as separate +// This is the actual date status handler. +// Note that it receives the date object as well as separate // values of year, month and date. function dateStatusFunc(date, y, m, d) { if (dateExists(date, y, m, d)) return "existing"; @@ -1623,14 +1623,14 @@ function dateStatusFunc(date, y, m, d) { return false;}')); } /** CbNewUserEdit (&$request, $userid) - * Callback when a new user creates or edits a page + * Callback when a new user creates or edits a page */ function CbNewUserEdit (&$request, $userid) { ; // i.e. create homepage with Template/UserPage } /** CbNewUserLogin (&$request, $userid) - * Callback when a "new user" logs in. + * Callback when a "new user" logs in. * What is new? We only record changes, not logins. * Should we track user actions? * Let's say a new user is a user without homepage. @@ -1639,7 +1639,7 @@ function dateStatusFunc(date, y, m, d) { return false;}')); ; // do nothing } - /** CbUserLogout (&$request, $userid) + /** CbUserLogout (&$request, $userid) * Callback when a user logs out */ function CbUserLogout (&$request, $userid) { @@ -1775,10 +1775,10 @@ class SubmitImageButton extends SubmitButton { }; -/** +/** * A sidebar box with title and body, narrow fixed-width. * To represent abbrevated content of plugins, links or forms, - * like "Getting Started", "Search", "Sarch Pagename", + * like "Getting Started", "Search", "Sarch Pagename", * "Login", "Menu", "Recent Changes", "Last comments", "Last Blogs" * "Calendar" * ... See http://tikiwiki.org/ @@ -1800,7 +1800,7 @@ class SidebarBox { } } -/** +/** * A sidebar box for plugins. * Any plugin may provide a box($args=false, $request=false, $basepage=false) * method, with the help of WikiPlugin::makeBox() @@ -1829,7 +1829,7 @@ class PluginSidebarBox extends SidebarBox { function format($args = false) { return $this->_plugin->box($args ? array_merge($this->_args, $args) : $this->_args, - $GLOBALS['request'], + $GLOBALS['request'], $this->_basepage); } } @@ -1877,15 +1877,15 @@ class RelatedExternalLinksBox extends SidebarBox { } function listAvailableThemes() { - $available_themes = array(); + $available_themes = array(); $dir_root = 'themes'; if (defined('PHPWIKI_DIR')) $dir_root = PHPWIKI_DIR . "/$dir_root"; $dir = dir($dir_root); if ($dir) { while($entry = $dir->read()) { - if (is_dir($dir_root.'/'.$entry) - and file_exists($dir_root.'/'.$entry.'/themeinfo.php')) + if (is_dir($dir_root.'/'.$entry) + and file_exists($dir_root.'/'.$entry.'/themeinfo.php')) { array_push($available_themes, $entry); } @@ -1912,7 +1912,6 @@ function listAvailableLanguages() { return $available_languages; } -// (c-file-style: "gnu") // Local Variables: // mode: php // tab-width: 8 diff --git a/lib/XmlElement.php b/lib/XmlElement.php index 31958973c..36f6fe933 100644 --- a/lib/XmlElement.php +++ b/lib/XmlElement.php @@ -5,7 +5,7 @@ * @author: Jeff Dairiki, * Reini Urban (php5 tricks) * - * WARNING: This module is very php5 sensitive. + * WARNING: This module is very php5 sensitive. * Fixed for 1.3.9, 1.3.11 and 1.3.13 (php-5.2). * With allow_call_time_pass_reference clean fixes. */ @@ -71,7 +71,7 @@ class XmlContent else array_unshift($this->_content, $item); } - + function getContent () { return $this->_content; } @@ -188,7 +188,7 @@ class XmlContent } return true; } - + function _quote ($string) { if (!$string) return $string; return htmlspecialchars($string, ENT_COMPAT, $GLOBALS['charset']); @@ -215,7 +215,7 @@ class XmlElement extends XmlContent assert(count($args) >= 1); //assert(is_string($args[0])); $this->_tag = array_shift($args); - + if ($args && is_array($args[0])) $this->_attr = array_shift($args); else { @@ -226,7 +226,7 @@ class XmlElement extends XmlContent $this->setContent($args); } - + /** Methods only needed for XmlParser, * to be fully compatible to perl Html::Element */ @@ -241,7 +241,7 @@ class XmlElement extends XmlContent unset($this->_attr); unset($this->_content); } - + function getChildren () { return $this->_children; } @@ -255,7 +255,7 @@ class XmlElement extends XmlContent function getTag () { return $this->_tag; } - + function setAttr ($attr, $value = false) { if (is_array($attr)) { assert($value === false); @@ -267,7 +267,7 @@ class XmlElement extends XmlContent } assert(is_string($attr)); - + if ($value === false) { unset($this->_attr[$attr]); } @@ -332,7 +332,7 @@ class XmlElement extends XmlContent $class = trim($class); if ($in_class) $this->_classes[$class] = $class; - else + else unset($this->_classes[$class]); } @@ -370,12 +370,12 @@ class XmlElement extends XmlContent return substr($this->startTag(), 0, -1) . "/>"; } - + function endTag() { return "_tag>"; } - - + + function printXML () { if ($this->isEmpty()) echo $this->emptyTag(); @@ -422,7 +422,7 @@ class XmlElement extends XmlContent return false; return true; } - + /** * Is this element part of inline content? * @@ -432,7 +432,7 @@ class XmlElement extends XmlContent function isInlineElement () { return false; } - + }; class RawXml { @@ -452,7 +452,7 @@ class RawXml { function asXML () { return $this->_xml; } - + function asString () { return $this->_xml; } @@ -486,13 +486,13 @@ class FormattedText { // strings uncluttered trigger_error(sprintf(_("Can't mix '%s' with '%s' type format strings"), '%1\$s','%s'), E_USER_WARNING); - + $this->_fs = preg_replace('/(?_fs); $this->_args = array(); foreach($m[1] as $argnum) { if ($argnum < 1 || $argnum > count($args)) - trigger_error(sprintf("%s: argument index out of range", + trigger_error(sprintf("%s: argument index out of range", $argnum), E_USER_WARNING); $this->_args[] = $args[$argnum - 1]; } @@ -531,7 +531,7 @@ class FormattedText { /** * PHP5 compatibility * Error[2048]: Non-static method XmlContent::_quote() should not be called statically - * Note: There's lot of room for performance increase if the right charset variant can + * Note: There's lot of room for performance increase if the right charset variant can * be created on load-time. */ function XmlContent_quote ($string) { @@ -630,7 +630,7 @@ function AsString ($val) { $str .= AsString($x); return $str; } - + return (string) $val; } @@ -643,12 +643,11 @@ function fmt ($fs /* , ... */) { return $s; } -// (c-file-style: "gnu") // Local Variables: // mode: php // tab-width: 8 // c-basic-offset: 4 // c-hanging-comment-ender-p: nil // indent-tabs-mode: nil -// End: +// End: ?> diff --git a/lib/XmlParser.php b/lib/XmlParser.php index cd0049b86..82a7a546a 100644 --- a/lib/XmlParser.php +++ b/lib/XmlParser.php @@ -8,15 +8,15 @@ * @author: Reini Urban * * TODO: Convert more perl Html::Element style to our XmlElement style - * Needed additions to XmlElement: + * Needed additions to XmlElement: * Html::Element::parent() <=> XmlElement::parent * Html::Element::attr() <=> XmlElement::getAttr() * Html::Element::tag <=> XmlElement::_tag * Html::Element::content_list() <=> ->getContent() ??? or ->_children[] - * all_external_attr_names() <=> + * all_external_attr_names() <=> * * Problems: - * The HtmlParser object set by xml_parse() doesn't keep its parameters, + * The HtmlParser object set by xml_parse() doesn't keep its parameters, * esp. $this->root is lost. So we have to this into a global. */ @@ -40,10 +40,10 @@ /** * class XmlParser - Parse into a tree of XmlElement nodes. - * + * * PHP Problems: * inside the handlers no globals are transported, only class vars. - * when leaving the handler class all class vars are destroyed, so we + * when leaving the handler class all class vars are destroyed, so we * have to copy the root to a global. * */ @@ -55,7 +55,7 @@ class XmlParser { if ($encoding) $this->_parser = xml_parser_create($encoding); else - $this->_parser = xml_parser_create(); + $this->_parser = xml_parser_create(); xml_parser_set_option($this->_parser, XML_OPTION_TARGET_ENCODING, $GLOBALS['charset']); @@ -79,7 +79,7 @@ class XmlParser { if (!empty($this->_parser)) xml_parser_free($this->_parser); unset($this->_parser); - + if (isset($xml_parser_root)) { $xml_parser_root->_destruct(); unset($xml_parser_root); // nested parsing forbidden! @@ -104,7 +104,7 @@ class XmlParser { } } } elseif (!empty($attrs) and is_array($attrs)) { - foreach ($attrs as $key => $val) { + foreach ($attrs as $key => $val) { $key = strtolower(trim($key)); $val = str_replace(array('"',"'"),'',trim($val)); $node->_attr[$key] = $val; @@ -114,7 +114,7 @@ class XmlParser { $this->current->_content[] =& $node; // copy or ref? $node->previous =& $this->current; // ref to parallel prev } - $this->current =& $node; // ref + $this->current =& $node; // ref if (empty($this->root)) { $this->root =& $node; // ref for === test below $GLOBALS['xml_parser_root'] =& $this->root; // copy @@ -140,9 +140,9 @@ class XmlParser { } function parse($content, $is_final = true) { - xml_parse($this->_parser, $content, $is_final) or - trigger_error(sprintf("XML error: %s at line %d", - xml_error_string(xml_get_error_code($this->_parser)), + xml_parse($this->_parser, $content, $is_final) or + trigger_error(sprintf("XML error: %s at line %d", + xml_error_string(xml_get_error_code($this->_parser)), xml_get_current_line_number($this->_parser)), E_USER_WARNING); } @@ -171,7 +171,6 @@ class XmlParser { } } -// For emacs users // Local Variables: // mode: php // tab-width: 8 diff --git a/lib/XmlRpcClient.php b/lib/XmlRpcClient.php index 8d8d42b31..4168d285d 100644 --- a/lib/XmlRpcClient.php +++ b/lib/XmlRpcClient.php @@ -23,7 +23,7 @@ define('XMLRPC_EXT_LOADED', true); if (loadPhpExtension('xmlrpc')) { // fast c lib global $xmlrpc_util_path; $xmlrpc_util_path = dirname(__FILE__)."/XMLRPC/"; - include_once("lib/XMLRPC/xmlrpc_emu.inc"); + include_once("lib/XMLRPC/xmlrpc_emu.inc"); } else { // slow php lib // Include the php XML-RPC library include_once("lib/XMLRPC/xmlrpc.inc"); @@ -88,7 +88,7 @@ function wiki_xmlrpc_post($method, $args = null, $url = null, $auth = null) { if (empty($server['host'])) { $server['host'] = 'localhost'; } - if (!empty($_GET['start_debug'])) { + if (!empty($_GET['start_debug'])) { $debug = 2; } if (DEBUG & _DEBUG_REMOTE) { // xmlrpc remote debugging @@ -96,9 +96,9 @@ function wiki_xmlrpc_post($method, $args = null, $url = null, $auth = null) { $server['path'] .= '?start_debug=1'; } $params = array('method' => $method, - 'args' => $args, - 'host' => $server['host'], - 'uri' => $server['path'], + 'args' => $args, + 'host' => $server['host'], + 'uri' => $server['path'], 'debug' => $debug, 'output' => null); //TODO: auth and/or session cookie @@ -112,12 +112,11 @@ function wiki_xmlrpc_post($method, $args = null, $url = null, $auth = null) { return $result; } -// (c-file-style: "gnu") // Local Variables: // mode: php // tab-width: 8 // c-basic-offset: 4 // c-hanging-comment-ender-p: nil // indent-tabs-mode: nil -// End: +// End: ?> diff --git a/lib/XmlRpcServer.php b/lib/XmlRpcServer.php index 471404eef..fc0f31b8a 100644 --- a/lib/XmlRpcServer.php +++ b/lib/XmlRpcServer.php @@ -6,39 +6,39 @@ * LICENCE * ======= * 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 * * LIBRARY USED - POSSIBLE PROBLEMS * ================================ - * - * This file provides an XML-RPC interface for PhpWiki. - * It checks for the existence of the xmlrpc-epi c library by Dan Libby - * (see http://uk2.php.net/manual/en/ref.xmlrpc.php), and falls back to - * the slower PHP counterpart XML-RPC library by Edd Dumbill. + * + * This file provides an XML-RPC interface for PhpWiki. + * It checks for the existence of the xmlrpc-epi c library by Dan Libby + * (see http://uk2.php.net/manual/en/ref.xmlrpc.php), and falls back to + * the slower PHP counterpart XML-RPC library by Edd Dumbill. * See http://xmlrpc.usefulinc.com/php.html for details. - * + * * INTERFACE SPECIFICTION * ====================== - * - * The interface specification is that discussed at + * + * The interface specification is that discussed at * http://www.ecyrd.com/JSPWiki/Wiki.jsp?page=WikiRPCInterface - * + * * See also http://www.usemod.com/cgi-bin/mb.pl?XmlRpc * or http://www.devshed.com/c/a/PHP/Using-XMLRPC-with-PHP/ - * + * * Note: All XMLRPC methods are automatically prefixed with "wiki." * eg. "wiki.getAllPages" */ @@ -51,19 +51,19 @@ ToDo: * API v2 http://www.jspwiki.org/wiki/WikiRPCInterface2 : - * array listAttachments( utf8 page ) - Lists attachments on a given page. + * array listAttachments( utf8 page ) - Lists attachments on a given page. The array consists of utf8 attachment names that can be fed to getAttachment (or putAttachment). * base64 getAttachment( utf8 attachmentName ) - returns the content of an attachment. - * putAttachment( utf8 attachmentName, base64 content ) - (over)writes an attachment. + * putAttachment( utf8 attachmentName, base64 content ) - (over)writes an attachment. * array system.listMethods() * string system.methodHelp (string methodName) - * array system.methodSignature (string methodName) + * array system.methodSignature (string methodName) Done: Test hwiki.jar xmlrpc interface (java visualization plugin) Make use of the xmlrpc extension if found. http://xmlrpc-epi.sourceforge.net/ Resolved namespace conflicts - Added various phpwiki specific methods (mailPasswordToUser, getUploadedFileInfo, + Added various phpwiki specific methods (mailPasswordToUser, getUploadedFileInfo, putPage, titleSearch, listPlugins, getPluginSynopsis, listRelations) Use client methods in inter-phpwiki calls: SyncWiki, tests/xmlrpc/ */ @@ -71,12 +71,12 @@ Done: // Intercept GET requests from confused users. Only POST is allowed here! if (empty($GLOBALS['HTTP_SERVER_VARS'])) $GLOBALS['HTTP_SERVER_VARS'] =& $_SERVER; -if ($GLOBALS['HTTP_SERVER_VARS']['REQUEST_METHOD'] != "POST") +if ($GLOBALS['HTTP_SERVER_VARS']['REQUEST_METHOD'] != "POST") { die('This is the address of the XML-RPC interface.' . ' You must use XML-RPC calls to access information here.'); } - + require_once("lib/XmlRpcClient.php"); if (loadPhpExtension('xmlrpc')) { // fast c lib require_once("lib/XMLRPC/xmlrpcs_emu.inc"); @@ -88,7 +88,7 @@ if (loadPhpExtension('xmlrpc')) { // fast c lib /** * Helper function: Looks up a page revision (most recent by default) in the wiki database - * + * * @param xmlrpcmsg $params : string pagename [int version] * @return WikiDB _PageRevision object, or false if no such page */ @@ -108,16 +108,16 @@ function _getPageRevision ($params) $revision = $page->getCurrentRevision(); } else { $revision = $page->getRevision($version); - } + } return $revision; - } + } return false; -} +} /** * Get an xmlrpc "No such page" error message */ -function NoSuchPage ($pagename='') +function NoSuchPage ($pagename='') { global $xmlrpcerruser; return new xmlrpcresp(0, $xmlrpcerruser + 1, "No such page ".$pagename); @@ -130,7 +130,7 @@ function NoSuchPage ($pagename='') global $wiki_dmap; /** - * int getRPCVersionSupported(): Returns 1 for this version of the API + * int getRPCVersionSupported(): Returns 1 for this version of the API */ $wiki_dmap['getRPCVersionSupported'] = array('signature' => array(array($xmlrpcInt)), @@ -145,15 +145,15 @@ function getRPCVersionSupported($params) } /** - * array getRecentChanges(Date timestamp) : Get list of changed pages since + * array getRecentChanges(Date timestamp) : Get list of changed pages since * timestamp, which should be in UTC. The result is an array, where each element - * is a struct: - * name (string) : Name of the page. The name is UTF-8 with URL encoding to make it ASCII. - * lastModified (date) : Date of last modification, in UTC. - * author (string) : Name of the author (if available). Again, name is UTF-8 with URL encoding. - * version (int) : Current version. - * summary (string) : UTF-8 with URL encoding. - * A page MAY be specified multiple times. A page MAY NOT be specified multiple + * is a struct: + * name (string) : Name of the page. The name is UTF-8 with URL encoding to make it ASCII. + * lastModified (date) : Date of last modification, in UTC. + * author (string) : Name of the author (if available). Again, name is UTF-8 with URL encoding. + * version (int) : Current version. + * summary (string) : UTF-8 with URL encoding. + * A page MAY be specified multiple times. A page MAY NOT be specified multiple * times with the same modification date. * Additionally to API version 1 and 2 we added the summary field. */ @@ -180,19 +180,19 @@ function getRecentChanges($params) $version = new xmlrpcval($page->getVersion(), 'int'); // Build an array of xmlrpc structs - $pages[] = new xmlrpcval(array('name' => $name, + $pages[] = new xmlrpcval(array('name' => $name, 'lastModified' => $lastmodified, 'author' => $author, 'summary' => short_string($page->get('summary')), 'version' => $version), 'struct'); - } + } return new xmlrpcresp(new xmlrpcval($pages, "array")); -} +} /** - * base64 getPage( String pagename ): Get the raw Wiki text of page, latest version. + * base64 getPage( String pagename ): Get the raw Wiki text of page, latest version. * Page name must be UTF-8, with URL encoding. Returned value is a binary object, * with UTF-8 encoded page data. */ @@ -213,7 +213,7 @@ function getPage($params) return new xmlrpcresp(long_string($revision->getPackedContent())); } - + /** * base64 getPageVersion( String pagename, int version ): Get the raw Wiki text of page. @@ -228,10 +228,10 @@ function getPageVersion($params) { // error checking is done in getPage return getPage($params); -} +} /** - * base64 getPageHTML( String pagename ): Return page in rendered HTML. + * base64 getPageHTML( String pagename ): Return page in rendered HTML. * Returns UTF-8, expects UTF-8 with URL encoding. */ @@ -245,7 +245,7 @@ function getPageHTML($params) $revision = _getPageRevision($params); if (!$revision) return NoSuchPage(); - + $content = $revision->getTransformedContent(); $html = $content->asXML(); // HACK: Get rid of outer
@@ -255,7 +255,7 @@ function getPageHTML($params) } return new xmlrpcresp(long_string($html)); -} +} /** * base64 getPageHTMLVersion( String pagename, int version ): Return page in rendered HTML, UTF-8. @@ -268,14 +268,14 @@ $wiki_dmap['getPageHTMLVersion'] function getPageHTMLVersion($params) { return getPageHTML($params); -} +} /** * getAllPages(): Returns a list of all pages. The result is an array of strings. */ $wiki_dmap['getAllPages'] = array('signature' => array(array($xmlrpcArray)), - 'documentation' => 'Returns a list of all pages as an array of strings', + 'documentation' => 'Returns a list of all pages as an array of strings', 'function' => 'getAllPages'); function getAllPages($params) @@ -286,16 +286,16 @@ function getAllPages($params) $pages = array(); while ($page = $iterator->next()) { $pages[] = short_string($page->getName()); - } + } return new xmlrpcresp(new xmlrpcval($pages, "array")); -} +} /** - * struct getPageInfo( string pagename ) : returns a struct with elements: - * name (string): the canonical page name - * lastModified (date): Last modification date - * version (int): current version - * author (string): author name + * struct getPageInfo( string pagename ) : returns a struct with elements: + * name (string): the canonical page name + * lastModified (date): Last modification date + * version (int): current version + * author (string): author name */ $wiki_dmap['getPageInfo'] = array('signature' => array(array($xmlrpcStruct, $xmlrpcString)), @@ -307,19 +307,19 @@ function getPageInfo($params) $revision = _getPageRevision($params); if (!$revision) return NoSuchPage(); - + $name = short_string($revision->getPageName()); $version = new xmlrpcval ($revision->getVersion(), "int"); $lastmodified = new xmlrpcval(iso8601_encode($revision->get('mtime'), 0), "dateTime.iso8601"); $author = short_string($revision->get('author')); - - return new xmlrpcresp(new xmlrpcval(array('name' => $name, + + return new xmlrpcresp(new xmlrpcval(array('name' => $name, 'lastModified' => $lastmodified, - 'version' => $version, - 'author' => $author), + 'version' => $version, + 'author' => $author), "struct")); -} +} /** * struct getPageInfoVersion( string pagename, int version ) : returns @@ -336,10 +336,10 @@ function getPageInfoVersion($params) return getPageInfo($params); } - + /* array listLinks( string pagename ): Lists all links for a given page. The - * returned array contains structs, with the following elements: - * name (string) : The page name or URL the link is to. + * returned array contains structs, with the following elements: + * name (string) : The page name or URL the link is to. * type (int) : The link type. Zero (0) for internal Wiki link, * one (1) for external link (URL - image link, whatever). */ @@ -351,7 +351,7 @@ $wiki_dmap['listLinks'] function listLinks($params) { global $request; - + $ParamPageName = $params->getParam(0); $pagename = short_string_decode($ParamPageName->scalarval()); $dbh = $request->getDbh(); @@ -359,7 +359,7 @@ function listLinks($params) return NoSuchPage($pagename); $page = $dbh->getPage($pagename); - + // The fast WikiDB method. below is the slow method which goes through the formatter // NB no clean way to extract a list of external links yet, so // only internal links returned. i.e. all type 'local'. @@ -377,8 +377,8 @@ function listLinks($params) // Also, if USE_PATH_INFO is false, WikiURL is wrong // due to its use of SCRIPT_NAME. //$use_abspath = USE_PATH_INFO && ! preg_match('/RPC2.php$/', VIRTUAL_PATH); - - // USE_PATH_INFO must be defined in index.php or config.ini but not before, + + // USE_PATH_INFO must be defined in index.php or config.ini but not before, // otherwise it is ignored and xmlrpc urls are wrong. // SCRIPT_NAME here is always .../RPC2.php if (USE_PATH_INFO and !$args) { @@ -393,7 +393,7 @@ function listLinks($params) 'href' => short_string($url)), "struct"); } - + /* $current = $page->getCurrentRevision(); $content = $current->getTransformedContent(); @@ -411,15 +411,15 @@ function listLinks($params) } */ return new xmlrpcresp(new xmlrpcval ($linkstruct, "array")); -} +} /* End of WikiXMLRpc API v1 */ /* ======================================================================== */ /* Start of partial WikiXMLRpc API v2 support */ -/** +/** * struct putPage(String pagename, String content, [String author[, String password]}) - * returns a struct with elements: + * returns a struct with elements: * code (int): 200 on success, 400 or 401 on failure * message (string): success or failure message * version (int): version of new page @@ -435,7 +435,7 @@ $wiki_dmap['putPage'] function _getUser($userid='') { global $request; - + if (! $userid ) { if (!isset($_SERVER)) $_SERVER =& $GLOBALS['HTTP_SERVER_VARS']; @@ -459,7 +459,7 @@ function _getUser($userid='') { return new WikiUser($request, $userid); } } - + function putPage($params) { global $request; @@ -481,15 +481,15 @@ function putPage($params) { $request->_user = _getUser($userid); $request->_user->_group = $request->getGroup(); $request->_user->AuthCheck($userid, $passwd); - + if (! mayAccessPage ('edit', $pagename)) { return new xmlrpcresp( new xmlrpcval( - array('code' => new xmlrpcval(401, "int"), - 'version' => new xmlrpcval(0, "int"), - 'message' => + array('code' => new xmlrpcval(401, "int"), + 'version' => new xmlrpcval(0, "int"), + 'message' => short_string("no permission for " - .$request->_user->UserName())), + .$request->_user->UserName())), "struct")); } @@ -523,9 +523,9 @@ function putPage($params) { $res = 0; $message = $message = "Page $pagename unchanged"; } - return new xmlrpcresp(new xmlrpcval(array('code' => new xmlrpcval($res ? 200 : 400, "int"), - 'version' => new xmlrpcval($version, "int"), - 'message' => short_string($message)), + return new xmlrpcresp(new xmlrpcval(array('code' => new xmlrpcval($res ? 200 : 400, "int"), + 'version' => new xmlrpcval($version, "int"), + 'message' => short_string($message)), "struct")); } @@ -534,13 +534,13 @@ function putPage($params) { /* Start of private extensions */ /** - * struct getUploadedFileInfo( string localpath ) : returns a struct with elements: - * lastModified (date): Last modification date - * size (int): current version + * struct getUploadedFileInfo( string localpath ) : returns a struct with elements: + * lastModified (date): Last modification date + * size (int): current version * This is to sync uploaded files up to a remote master wiki. (SyncWiki) * Not existing files return both 0. * - * API notes: API v2 specs have array listAttachments( utf8 page ), + * API notes: API v2 specs have array listAttachments( utf8 page ), * base64 getAttachment( utf8 attachmentName ), putAttachment( utf8 attachmentName, base64 content ) */ $wiki_dmap['getUploadedFileInfo'] @@ -550,7 +550,7 @@ $wiki_dmap['getUploadedFileInfo'] function getUploadedFileInfo($params) { - // localpath is the relative part after "Upload:" + // localpath is the relative part after "Upload:" $ParamPath = $params->getParam(0); $localpath = short_string_decode($ParamPath->scalarval()); preg_replace("/^[\\ \/ \.]/", "", $localpath); // strip hacks @@ -561,26 +561,26 @@ function getUploadedFileInfo($params) } else { $size = 0; $lastmodified = 0; - } + } return new xmlrpcresp(new xmlrpcval (array('lastModified' => new xmlrpcval(iso8601_encode($lastmodified, 1), "dateTime.iso8601"), - 'size' => new xmlrpcval($size, "int")), + 'size' => new xmlrpcval($size, "int")), "struct")); } /** * Publish-Subscribe (not yet implemented) - * Client subscribes to a RecentChanges-like channel, getting a short - * callback notification on every change. Like PageChangeNotification, just shorter + * Client subscribes to a RecentChanges-like channel, getting a short + * callback notification on every change. Like PageChangeNotification, just shorter * and more complicated * RSS2 support (not yet), since radio userland's rss-0.92. now called RSS2. * BTW: Radio Userland deprecated this interface. * * boolean wiki.rssPleaseNotify ( notifyProcedure, port, path, protocol, urlList ) - * returns: true or false + * returns: true or false * - * Check of the channel behind the rssurl has a cloud element, + * Check of the channel behind the rssurl has a cloud element, * if the client has a direct IP connection (no NAT), * register the client on the WikiDB notification handler * @@ -601,7 +601,7 @@ function rssPleaseNotify($params) /* * boolean wiki.mailPasswordToUser ( username ) - * returns: true or false + * returns: true or false */ $wiki_dmap['mailPasswordToUser'] @@ -620,13 +620,13 @@ function mailPasswordToUser($params) $success = 0; if ($email) { $body = WikiURL('') . "\nPassword: " . $request->getPref('passwd'); - $success = mail($email, "[".WIKI_NAME."} Password Request", + $success = mail($email, "[".WIKI_NAME."} Password Request", $body); } return new xmlrpcresp(new xmlrpcval ($success, "boolean")); } -/** +/** * array wiki.titleSearch(String substring [, String option = "0"]) * returns an array of matching pagenames. * TODO: standardize options @@ -635,7 +635,7 @@ function mailPasswordToUser($params) */ $wiki_dmap['titleSearch'] = array('signature' => array(array($xmlrpcArray, $xmlrpcString, $xmlrpcString)), - 'documentation' => "Return matching pagenames. + 'documentation' => "Return matching pagenames. Option 1: caseexact, 2: regex, 4: starts_with, 8: exact, 16: fallback", 'function' => 'titleSearch'); @@ -647,7 +647,7 @@ function titleSearch($params) if (count($params->params) > 1) { $ParamOption = $params->getParam(1); $option = (int) $ParamOption->scalarval(); - } else + } else $option = 0; // default option: substring, case-inexact @@ -664,7 +664,7 @@ function titleSearch($params) $searchstring = "^".$searchstring."$"; } } else { - if ($option & 4 or $option & 8) { + if ($option & 4 or $option & 8) { global $xmlrpcerruser; return new xmlrpcresp(0, $xmlrpcerruser + 1, "Invalid option"); } @@ -679,7 +679,7 @@ function titleSearch($params) } // On failure try again broader (substring + case inexact) if ($fallback and empty($pages)) { - $query = new TextSearchQuery(short_string_decode($ParamPageName->scalarval()), false, + $query = new TextSearchQuery(short_string_decode($ParamPageName->scalarval()), false, $regex ? 'auto' : 'none'); $dbh = $request->getDbh(); $iterator = $dbh->titleSearch($query); @@ -690,10 +690,10 @@ function titleSearch($params) return new xmlrpcresp(new xmlrpcval($pages, "array")); } -/** +/** * array wiki.listPlugins() * - * Returns an array of all available plugins. + * Returns an array of all available plugins. * For EditToolbar pluginPulldown via AJAX * * @author: Reini Urban @@ -725,11 +725,11 @@ function listPlugins($params) } } } - + return new xmlrpcresp(new xmlrpcval($RetArray, "array")); } -/** +/** * String wiki.getPluginSynopsis(String plugin) * * For EditToolbar pluginPulldown via AJAX @@ -761,14 +761,14 @@ function getPluginSynopsis($params) $plugin_args = '\n'.str_replace($src, $replace, $desc); $synopsis = ""; // args? } - + return new xmlrpcresp(short_string($synopsis)); } -/** +/** * array wiki.callPlugin(String name, String args) * - * Returns an array of pages as returned by the plugins PageList call. + * Returns an array of pages as returned by the plugins PageList call. * Only valid for plugins returning pagelists, e.g. BackLinks, AllPages, ... * For various AJAX or WikiFormRich calls. * @@ -802,13 +802,13 @@ function callPlugin($params) return new xmlrpcresp(new xmlrpcval($list, "array")); } -/** +/** * array wiki.listRelations([ Integer option = 1 ]) * * Returns an array of all available relation names. * option: 1 relations only ( with 0 also ) * option: 2 attributes only - * option: 3 both, all names of relations and attributes + * option: 3 both, all names of relations and attributes * option: 4 unsorted, this might be added as bitvalue: 7 = 4+3. default: sorted * For some semanticweb autofill methods. * @@ -826,18 +826,18 @@ function listRelations($params) if (count($params->params) > 0) { $ParamOption = $params->getParam(0); $option = (int) $ParamOption->scalarval(); - } else + } else $option = 1; - $also_attributes = $option & 2; - $only_attributes = $option & 2 and !($option & 1); + $also_attributes = $option & 2; + $only_attributes = $option & 2 and !($option & 1); $sorted = !($option & 4); return new xmlrpcresp(new xmlrpcval($dbh->listRelations($also_attributes, $only_attributes, - $sorted), + $sorted), "array")); } -/** +/** * String pingback.ping(String sourceURI, String targetURI) Spec: http://www.hixie.ch/specs/pingback/pingback @@ -858,7 +858,7 @@ Faults the target URI, and 0x003x codes are used when the URIs are fine but the pingback cannot be acknowledged for some other reaon. - 0 + 0 A generic fault code. Servers MAY use this error code instead of any of the others if they do not have a way of determining the correct fault code. @@ -938,11 +938,11 @@ function pingBack($params) /* End of private WikiXMLRpc API extensions */ /* ======================================================================== */ - -/** - * Construct the server instance, and set up the dispatch map, + +/** + * Construct the server instance, and set up the dispatch map, * which maps the XML-RPC methods on to the wiki functions. - * Provide the "wiki." prefix to each function. Besides + * Provide the "wiki." prefix to each function. Besides * the blog - pingback, ... - functions with a seperate namespace. */ class XmlRpcServer extends xmlrpc_server @@ -966,7 +966,7 @@ class XmlRpcServer extends xmlrpc_server xmlrpc_server::service(); $ErrorManager->popErrorHandler(); } - + function _errorHandler ($e) { $msg = htmlspecialchars($e->asString()); // '--' not allowed within xml comment @@ -977,12 +977,11 @@ class XmlRpcServer extends xmlrpc_server } } -// (c-file-style: "gnu") // Local Variables: // mode: php // tab-width: 8 // c-basic-offset: 4 // c-hanging-comment-ender-p: nil // indent-tabs-mode: nil -// End: +// End: ?> diff --git a/lib/config.php b/lib/config.php index f64224313..d7a788cdd 100644 --- a/lib/config.php +++ b/lib/config.php @@ -19,12 +19,12 @@ define ('_DEBUG_INFO', 16); define ('_DEBUG_APD', 32); // APD tracing/profiling define ('_DEBUG_LOGIN', 64); // verbose login debug-msg (settings and reason for failure) define ('_DEBUG_SQL', 128); // force check db, force optimize, print some debugging logs -define ('_DEBUG_REMOTE', 256); // remote debug into subrequests (xmlrpc, ajax, wikiwyg, ...) +define ('_DEBUG_REMOTE', 256); // remote debug into subrequests (xmlrpc, ajax, wikiwyg, ...) // or test local SearchHighlight. - // internal links have persistent ?start_debug=1 + // internal links have persistent ?start_debug=1 function isCGI() { - return (substr(php_sapi_name(),0,3) == 'cgi' and + return (substr(php_sapi_name(),0,3) == 'cgi' and isset($GLOBALS['HTTP_ENV_VARS']['GATEWAY_INTERFACE']) and @preg_match('/CGI/',$GLOBALS['HTTP_ENV_VARS']['GATEWAY_INTERFACE'])); } @@ -66,13 +66,13 @@ function browserVersion() { return (float)substr($agent, 8); } function isBrowserIE() { - return (browserDetect('Mozilla/') and + return (browserDetect('Mozilla/') and browserDetect('MSIE')); } // must omit display alternate stylesheets: konqueror 3.1.4 // http://sourceforge.net/tracker/index.php?func=detail&aid=945154&group_id=6121&atid=106121 function isBrowserKonqueror($version = false) { - if ($version) return browserDetect('Konqueror/') and browserVersion() >= $version; + if ($version) return browserDetect('Konqueror/') and browserVersion() >= $version; return browserDetect('Konqueror/'); } // MacOSX Safari has certain limitations. Need detection and patches. @@ -80,11 +80,11 @@ function isBrowserKonqueror($version = false) { function isBrowserSafari($version = false) { $found = browserDetect('Spoofer/'); $found = browserDetect('AppleWebKit/') or $found; - if ($version) return $found and browserVersion() >= $version; + if ($version) return $found and browserVersion() >= $version; return $found; } function isBrowserOpera($version = false) { - if ($version) return browserDetect('Opera/') and browserVersion() >= $version; + if ($version) return browserDetect('Opera/') and browserVersion() >= $version; return browserDetect('Opera/'); } @@ -102,7 +102,7 @@ function guessing_lang ($languages=false) { $languages = array("en","de","es","fr","it","ja","zh","nl","sv"); } - $accept = false; + $accept = false; if (isset($GLOBALS['request'])) // in fixup-dynamic-config there's no request yet $accept = $GLOBALS['request']->get('HTTP_ACCEPT_LANGUAGE'); elseif (!empty($_SERVER['HTTP_ACCEPT_LANGUAGE'])) @@ -117,7 +117,7 @@ function guessing_lang ($languages=false) { // No Q it is only a locale... $lang_list[$list[$i]] = 100; } else { - // Has a Q rating + // Has a Q rating $q = explode(";",$list[$i]) ; $loc = $q[0] ; $q = explode("=",$q[1]) ; @@ -163,8 +163,8 @@ function guessing_lang ($languages=false) { */ function guessing_setlocale ($category, $locale) { $alt = array('en' => array('C', 'en_US', 'en_GB', 'en_AU', 'en_CA', 'english'), - 'de' => array('de_DE', 'de_DE', 'de_DE@euro', - 'de_AT@euro', 'de_AT', 'German_Austria.1252', 'deutsch', + 'de' => array('de_DE', 'de_DE', 'de_DE@euro', + 'de_AT@euro', 'de_AT', 'German_Austria.1252', 'deutsch', 'german', 'ge'), 'es' => array('es_ES', 'es_MX', 'es_AR', 'spanish'), 'nl' => array('nl_NL', 'dutch'), @@ -175,13 +175,13 @@ function guessing_setlocale ($category, $locale) { 'ja.euc-jp' => array('ja_JP','ja_JP.eucJP','japanese.euc'), 'zh' => array('zh_TW', 'zh_CN'), ); - if (!$locale or $locale=='C') { + if (!$locale or $locale=='C') { // do the reverse: return the detected locale collapsed to our LANG $locale = setlocale($category, ''); if ($locale) { if (strstr($locale, '_')) list ($lang) = explode('_', $locale); else $lang = $locale; - if (strlen($lang) > 2) { + if (strlen($lang) > 2) { foreach ($alt as $try => $locs) { if (in_array($locale, $locs) or in_array($lang, $locs)) { //if (empty($GLOBALS['LANG'])) $GLOBALS['LANG'] = $try; @@ -193,11 +193,11 @@ function guessing_setlocale ($category, $locale) { } if (strlen($locale) == 2) $lang = $locale; - else + else list ($lang) = explode('_', $locale); if (!isset($alt[$lang])) return false; - + foreach ($alt[$lang] as $try) { if ($res = setlocale($category, $try)) return $res; @@ -310,7 +310,7 @@ if (!function_exists('str_ireplace')) { function str_ireplace($find, $replace, $string) { if (!is_array($find)) $find = array($find); if (!is_array($replace)) { - if (!is_array($find)) + if (!is_array($find)) $replace = array($replace); else { // this will duplicate the string into an array the size of $find @@ -357,27 +357,26 @@ function getUploadFilePath() { if (!file_exists(UPLOAD_FILE_PATH)) { mkdir(UPLOAD_FILE_PATH, 0775); } - if (string_ends_with(UPLOAD_FILE_PATH, "/") + if (string_ends_with(UPLOAD_FILE_PATH, "/") or string_ends_with(UPLOAD_FILE_PATH, "\\")) { return UPLOAD_FILE_PATH; } else { return UPLOAD_FILE_PATH."/"; } } - return defined('PHPWIKI_DIR') - ? PHPWIKI_DIR . "/uploads/" + return defined('PHPWIKI_DIR') + ? PHPWIKI_DIR . "/uploads/" : realpath(dirname(__FILE__) . "/../uploads/"); } function getUploadDataPath() { if (defined('UPLOAD_DATA_PATH')) { - return string_ends_with(UPLOAD_DATA_PATH, "/") + return string_ends_with(UPLOAD_DATA_PATH, "/") ? UPLOAD_DATA_PATH : UPLOAD_DATA_PATH."/"; } - return SERVER_URL . (string_ends_with(DATA_PATH, "/") ? '' : "/") + return SERVER_URL . (string_ends_with(DATA_PATH, "/") ? '' : "/") . DATA_PATH . '/uploads/'; } -// For emacs users // Local Variables: // mode: php // tab-width: 8 diff --git a/lib/display.php b/lib/display.php index 9bf60c1ee..ba93b7655 100644 --- a/lib/display.php +++ b/lib/display.php @@ -5,7 +5,7 @@ require_once('lib/Template.php'); /** - * Extract keywords from Category* links on page. + * Extract keywords from Category* links on page. */ function GleanKeywords ($page) { if (!defined('KEYWORDS')) return ''; @@ -37,7 +37,7 @@ function RedirectorLink($pagename) { $pagename); } -/* only on ?action= */ +/* only on ?action= */ function actionPage(&$request, $action) { global $WikiTheme; global $robots; @@ -52,7 +52,7 @@ function actionPage(&$request, $action) { $actionpage = $dbi->getPage($action); $actionrev = $actionpage->getCurrentRevision(); - $pagetitle = HTML(fmt("%s: %s", + $pagetitle = HTML(fmt("%s: %s", $actionpage->getName(), $WikiTheme->linkExistingWikiWord($pagename, false, $version))); @@ -64,7 +64,7 @@ function actionPage(&$request, $action) { '%mtime' => $actionrev->get('mtime'))); $transformedContent = $actionrev->getTransformedContent(); - + /* Optionally tell google (and others) not to take notice of action pages. RecentChanges or AllPages might be an exception. */ @@ -75,13 +75,13 @@ function actionPage(&$request, $action) { } /* Handle other formats: So far we had html only. - xml is requested by loaddump, rss is handled by recentchanges, + xml is requested by loaddump, rss is handled by recentchanges, pdf is a special action, but should be a format to dump multiple pages if the actionpage plugin returns a pagelist. rdf and owl are handled by SemanticWeb. */ $format = $request->getArg('format'); - + /* At first the single page formats: html, xml */ if ($pagename == _("LinkDatabase")) { $template = Template('browse', array('CONTENT' => $transformedContent)); @@ -95,7 +95,7 @@ function actionPage(&$request, $action) { array('revision' => $revision, 'CONTENT' => $transformedContent, )); - $html = GeneratePageAsXML($template, $pagename, $revision /*, + $html = GeneratePageAsXML($template, $pagename, $revision /*, array('VALID_LINKS' => $args['VALID_LINKS'])*/); header("Content-Type: application/xhtml+xml; charset=" . $GLOBALS['charset']); echo $html; @@ -110,7 +110,7 @@ function actionPage(&$request, $action) { $loader = new WikiPluginLoader; $markup = null; // return the first found pagelist - $pagelist = $loader->expandPI($cached_element->_pi, $request, + $pagelist = $loader->expandPI($cached_element->_pi, $request, $markup, $pagename); if (is_a($pagelist, 'PageList')) break; @@ -118,7 +118,7 @@ function actionPage(&$request, $action) { } if (!$pagelist or !is_a($pagelist, 'PageList')) { if (!in_array($format, array("rss91","rss2","rss","atom","rdf"))) - trigger_error(sprintf("Format %s requires an actionpage returning a pagelist.", + trigger_error(sprintf("Format %s requires an actionpage returning a pagelist.", $format) ."\n".("Fall back to single page mode"), E_USER_WARNING); require_once('lib/PageList.php'); @@ -144,7 +144,7 @@ function actionPage(&$request, $action) { $request->setArg('pages', $args['VALID_LINKS']); $request->setArg('format',''); MakeWikiZipHtml($request); - } // time-sorted RDF á la RecentChanges + } // time-sorted RDF á la RecentChanges elseif (in_array($format, array("rss91","rss2","rss","atom"))) { $args = $request->getArgs(); //$request->setArg('format',''); @@ -166,7 +166,7 @@ function actionPage(&$request, $action) { $json_enc = json_encode($json); } else { require_once("lib/pear/JSON.php"); - $j = new Services_JSON(); + $j = new Services_JSON(); $json_enc = $j->encode($json); } header("Content-Type: application/json"); @@ -275,8 +275,8 @@ function displayPage(&$request, $template=false) { $redirect_message = HTML::span(array('class' => 'redirectfrom'), fmt("(Redirected from %s)", RedirectorLink($redirect_from))); - // abuse the $redirected template var for some status update notice - } elseif ($request->getArg('errormsg')) { + // abuse the $redirected template var for some status update notice + } elseif ($request->getArg('errormsg')) { $redirect_message = $request->getArg('errormsg'); $request->setArg('errormsg', false); } @@ -300,7 +300,7 @@ function displayPage(&$request, $template=false) { $toks['HEADER'] = $pageheader; // h1 with backlink $toks['revision'] = $revision; - // On external searchengine (google) referrer, highlight the searchterm and + // On external searchengine (google) referrer, highlight the searchterm and // pass through the Searchhighlight actionpage. if ($result = isExternalReferrer($request)) { if (!empty($result['query'])) { @@ -308,7 +308,7 @@ function displayPage(&$request, $template=false) { $request->_searchhighlight = $result; $request->appendValidators(array('%mtime' => time())); // force no cache(?) // Should be changed to check the engine and search term only - // $request->setArg('nocache', 1); + // $request->setArg('nocache', 1); $page_content = new TransformedText($revision->getPage(), $revision->getPackedContent(), $revision->getMetaData()); @@ -318,7 +318,7 @@ function displayPage(&$request, $template=false) { if ($actionpage = $request->findActionPage('SearchHighlight')) { $actionpage = $request->getPage($actionpage); $actionrev = $actionpage->getCurrentRevision(); - $pagetitle = HTML(fmt("%s: %s", + $pagetitle = HTML(fmt("%s: %s", $actionpage->getName(), $WikiTheme->linkExistingWikiWord($pagename, false, $version))); $request->appendValidators(array('actionpagerev' => $actionrev->getVersion(), @@ -340,7 +340,7 @@ function displayPage(&$request, $template=false) { } else { $page_content = $revision->getTransformedContent(); } - + /* Check for special pagenames, which are no actionpages. */ /* if ( $pagename == _("RecentVisitors")) { @@ -364,7 +364,7 @@ function displayPage(&$request, $template=false) { if (!empty($redirect_message)) $toks['redirected'] = $redirect_message; - // Massive performance problem parsing at run-time into all xml objects + // Massive performance problem parsing at run-time into all xml objects // looking for p's. Should be optional, if not removed at all. //$toks['PAGE_DESCRIPTION'] = $page_content->getDescription(); $toks['PAGE_KEYWORDS'] = GleanKeywords($page); @@ -372,7 +372,7 @@ function displayPage(&$request, $template=false) { $template = new Template('html', $request); // Handle other formats: So far we had html only. - // xml is requested by loaddump, rss is handled by RecentChanges, + // xml is requested by loaddump, rss is handled by RecentChanges, // pdf is a special action, but should be a format to dump multiple pages // if the actionpage plugin returns a pagelist. // rdf, owl, kbmodel, daml, ... are handled by SemanticWeb. @@ -394,7 +394,7 @@ function displayPage(&$request, $template=false) { //$request->setArg('format',''); if ($pagename == _("RecentChanges")) $template->printExpansion($toks); - else { + else { require_once("lib/plugin/RecentChanges.php"); $plugin = new WikiPlugin_RecentChanges(); $args = $request->getArgs(); @@ -424,7 +424,7 @@ function displayPage(&$request, $template=false) { $json_enc = json_encode($json); } else { require_once("lib/pear/JSON.php"); - $j = new Services_JSON(); + $j = new Services_JSON(); $json_enc = $j->encode($json); } header("Content-Type: application/json"); @@ -436,7 +436,7 @@ function displayPage(&$request, $template=false) { $template->printExpansion($toks); } } - + $page->increaseHitCount(); if ($request->getArg('action') != 'pdf') { @@ -446,7 +446,6 @@ function displayPage(&$request, $template=false) { return ''; } -// For emacs users // Local Variables: // mode: php // tab-width: 8 diff --git a/lib/gif.php b/lib/gif.php index 696490f2f..c7317ac34 100644 --- a/lib/gif.php +++ b/lib/gif.php @@ -81,7 +81,7 @@ function gif_outputAsJpeg($gif, $lpszFileName, $bgColor = -1) if(@fileSize($lpszFileName) > 0) { return true; } - + @unLink($lpszFileName); } } @@ -106,7 +106,7 @@ function gif_getSize($gif, &$width, &$height) else { return false; } - + return true; } @@ -143,7 +143,7 @@ class CGIFLZW while(($iIndex = $this->LZWCommand($data, false)) >= 0) { $ret .= chr($iIndex); } - + $datLen = $stLen - strlen($data); if($iIndex != -2) { @@ -157,7 +157,7 @@ class CGIFLZW if($bInit) { $this->SetCodeSize = ord($data{0}); $data = substr($data, 1); - + $this->CodeSize = $this->SetCodeSize + 1; $this->ClearCode = 1 << $this->SetCodeSize; $this->EndCode = $this->ClearCode + 1; @@ -188,7 +188,7 @@ class CGIFLZW $this->OldCode = $this->FirstCode; } while($this->FirstCode == $this->ClearCode); - + return $this->FirstCode; } @@ -233,7 +233,7 @@ class CGIFLZW while($Code >= $this->ClearCode) { $this->Stack[$this->sp] = $this->Vals[$Code]; $this->sp++; - + if($Code == $this->Next[$Code]) // Circular table entry, big GIF Error! return -1; @@ -282,13 +282,13 @@ class CGIFLZW } return -1; } - + $this->Buf[0] = $this->Buf[$this->LastByte - 2]; $this->Buf[1] = $this->Buf[$this->LastByte - 1]; - + $Count = ord($data{0}); $data = substr($data, 1); - + if($Count) { for($i = 0; $i < $Count; $i++) { $this->Buf[2 + $i] = ord($data{$i}); @@ -694,7 +694,7 @@ class CGIF if($iIndex < 0) { return false; } - + // READ FILE if(!($fh = @fOpen($lpszFileName, "rb"))) { @@ -702,8 +702,8 @@ class CGIF } $data = @fRead($fh, @fileSize($lpszFileName)); // @fClose($fh); - // $data=fread($fh,filesize($lpszFileName)); - while(!feof($fh)) { + // $data=fread($fh,filesize($lpszFileName)); + while(!feof($fh)) { $data = $data . @fread($fh, 1024); @fClose($fh); $this->m_lpData = @fRead($fh, @fileSize($lpszFileName)); @@ -745,7 +745,7 @@ class CGIF return true; } - + function getBmp($bgColor) { $out = ""; @@ -980,7 +980,6 @@ class CGIF } } -// (c-file-style: "gnu") // Local Variables: // mode: php // tab-width: 8 @@ -988,4 +987,4 @@ class CGIF // c-hanging-comment-ender-p: nil // indent-tabs-mode: nil // End: -?> \ No newline at end of file +?> diff --git a/lib/imdb.php b/lib/imdb.php index 4648cc02b..3cf81fd93 100644 --- a/lib/imdb.php +++ b/lib/imdb.php @@ -40,8 +40,8 @@ class imdb { } $parsed = parseDSN($dsn); $this->_dbh = &ADONewConnection($parsed['phptype']); - $conn = $this->_dbh->Connect($parsed['hostspec'],$parsed['username'], - $parsed['password'], $parsed['database']); + $conn = $this->_dbh->Connect($parsed['hostspec'],$parsed['username'], + $parsed['password'], $parsed['database']); $this->_dbtype = "ADODB"; } $this->_title_1_1 = array @@ -293,7 +293,7 @@ create table characters (name_id integer unsigned not null, title_id integer uns /* Search functions */ function searchTitle($title) { - return $this->_search($title, '_sql_title_clause', + return $this->_search($title, '_sql_title_clause', "SELECT m.title_id, m.title, m.date". " FROM movies as m". " WHERE ", @@ -301,7 +301,7 @@ create table characters (name_id integer unsigned not null, title_id integer uns } function searchName($name) { - return $this->_search($name, '_sql_name_clause', + return $this->_search($name, '_sql_name_clause', "SELECT n.name_id, n.name, j.description, c.role, m.title_id, m.title". " FROM names as n, jobs as j, characters as c, movies as m". " WHERE n.name_id = c.name_id". @@ -315,7 +315,7 @@ create table characters (name_id integer unsigned not null, title_id integer uns // quote the LIKE argument and construct the WHERE clause function _sql_match_clause($field, $word) { //not sure if we need this. ADODB may do it for us - $word = preg_replace('/(?=[%_\\\\])/', "\\", $word); + $word = preg_replace('/(?=[%_\\\\])/', "\\", $word); // (we need it for at least % and _ --- they're the wildcard characters // for the LIKE operator, and we need to quote them if we're searching // for literal '%'s or '_'s. --- I'm not sure about \, but it seems to @@ -334,7 +334,7 @@ create table characters (name_id integer unsigned not null, title_id integer uns function _search($what, $callback_fn, $query, $order = '') { include_once("lib/TextSearchQuery.php"); // $dbh = $GLOBALS['request']->getDbh(); - //TODO: check if the db is mysql resp. capable of google like search. + //TODO: check if the db is mysql resp. capable of google like search. // postgresql tsearch2 for example // See TextSearchQuery.php $search = new TextSearchQuery($what); @@ -357,12 +357,11 @@ SELECT m.title, m.date, n.name, c.role }; -// (c-file-style: "gnu") // Local Variables: // mode: php // tab-width: 8 // c-basic-offset: 4 // c-hanging-comment-ender-p: nil // indent-tabs-mode: nil -// End: +// End: ?> diff --git a/lib/install.php b/lib/install.php index 396495071..9bd069a3d 100644 --- a/lib/install.php +++ b/lib/install.php @@ -35,11 +35,11 @@ function init_install() { $already = 1; } -/** +/** * Display a screen of various settings: * 1. convert from older index.php configuration [TODO] * 2. database and admin_user setup based on configurator.php - * 3. dump the current settings to config/config.ini. + * 3. dump the current settings to config/config.ini. */ function run_install($part = '') { static $already = 0; @@ -57,7 +57,6 @@ function run_install($part = '') { init_install(); -// For emacs users // Local Variables: // mode: php // tab-width: 8 diff --git a/lib/loadsave.php b/lib/loadsave.php index 6219f4643..4243facdb 100644 --- a/lib/loadsave.php +++ b/lib/loadsave.php @@ -39,7 +39,7 @@ function _dump_error_handler(&$error) { return true; */ // let the message come through: call the remaining handlers: - // return false; + // return false; } function StartLoadDump(&$request, $title, $html = '') @@ -56,7 +56,7 @@ function StartLoadDump(&$request, $title, $html = '') 'CONTENT' => $html ? $html : '%BODY%')); echo ereg_replace('%BODY%.*', '', $tmpl->getExpansion($html)); $request->chunkOutput(); - + // set marker for sendPageChangeNotification() $request->_deferredPageChangeNotification = array(); } @@ -75,11 +75,11 @@ function EndLoadDump(&$request) case 'upload': $label = _("Upload File"); break; case 'loadfile': $label = _("Load File"); break; case 'upgrade': $label = _("Upgrade"); break; - case 'dumphtml': + case 'dumphtml': case 'ziphtml': $label = _("Dump pages as XHTML"); break; } if ($label) $label = str_replace(" ","_",$label); - if ($action == 'browse') // loading virgin + if ($action == 'browse') // loading virgin $pagelink = WikiLink(HOME_PAGE); else $pagelink = WikiLink(new WikiPageName(_("PhpWikiAdministration"),false,$label)); @@ -95,7 +95,7 @@ function EndLoadDump(&$request) } $editedby = sprintf(_("Edited by: %s"), $request->_user->getId()); $content = "Loaded the following pages:\n" . join("\n", $pages); - if (mail(join(',',$all_emails),"[".WIKI_NAME."] "._("LoadDump"), + if (mail(join(',',$all_emails),"[".WIKI_NAME."] "._("LoadDump"), _("LoadDump")."\n". $editedby."\n\n". $content)) @@ -207,7 +207,7 @@ function MailifyPage ($page, $nversions = 1) * * We have to apply a different "/" logic for dumpserial, htmldump and zipdump. * dirs are allowed for zipdump and htmldump, not for dumpserial - * + * * * @param $pagename string Pagename. * @return string Filename for page. @@ -260,7 +260,7 @@ function MakeWikiZip (&$request) $dbi =& $request->_dbi; $thispage = $request->getArg('pagename'); // for "Return to ..." if ($exclude = $request->getArg('exclude')) { // exclude which pagenames - $excludeList = explodePageList($exclude); + $excludeList = explodePageList($exclude); } else { $excludeList = array(); } @@ -273,7 +273,7 @@ function MakeWikiZip (&$request) } $request_args = $request->args; $timeout = (! $request->getArg('start_debug')) ? 30 : 240; - + while ($page = $page_iter->next()) { $request->args = $request_args; // some plugins might change them (esp. on POST) longer_timeout($timeout); // Reset watchdog @@ -332,7 +332,7 @@ function DumpToDir (&$request) $dbi =& $request->_dbi; $thispage = $request->getArg('pagename'); // for "Return to ..." if ($exclude = $request->getArg('exclude')) { // exclude which pagenames - $excludeList = explodePageList($exclude); + $excludeList = explodePageList($exclude); } else { $excludeList = array(); } @@ -427,10 +427,10 @@ function mkdir_p($pathname, $permission = 0777) { /** * Dump all pages as XHTML to a directory, as pagename.html. - * Copies all used css files to the directory, all used images to a + * Copies all used css files to the directory, all used images to a * "images" subdirectory, and all used buttons to a "images/buttons" subdirectory. - * The webserver must have write permissions to these directories. - * chown httpd HTML_DUMP_DIR; chmod u+rwx HTML_DUMP_DIR + * The webserver must have write permissions to these directories. + * chown httpd HTML_DUMP_DIR; chmod u+rwx HTML_DUMP_DIR * should be enough. * * @param string directory (optional) path to dump to. Default: HTML_DUMP_DIR @@ -471,7 +471,7 @@ function DumpHtmlToDir (&$request) $pages = $thispage; $page_iter = new WikiDB_Array_generic_iter(explodePageList($pages)); // not at admin page: dump only the current page - } elseif ($thispage != _("PhpWikiAdministration")) { + } elseif ($thispage != _("PhpWikiAdministration")) { $page_iter = new WikiDB_Array_generic_iter(array($thispage)); } else { $page_iter = $dbi->getAllPages(false,false,false,$excludeList); @@ -537,7 +537,7 @@ function _DumpHtmlToDir ($target, $page_iter, $exclude = false) } elseif (is_object($target)) { // $WikiTheme->DUMP_MODE == 'ZIPHTML' $zip = $target; } - + $request->_TemplatesProcessed = array(); if ($exclude) { // exclude which pagenames $excludeList = explodePageList($exclude); @@ -590,7 +590,7 @@ function _DumpHtmlToDir ($target, $page_iter, $exclude = false) $already = array(); $outfiles = array(); $already_images = array(); - + while ($page = $page_iter->next()) { if (is_string($page)) { $pagename = $page; @@ -628,7 +628,7 @@ function _DumpHtmlToDir ($target, $page_iter, $exclude = false) continue; } $relative_base = ''; - if ($WikiTheme->DUMP_MODE == 'PDFHTML') + if ($WikiTheme->DUMP_MODE == 'PDFHTML') $request->setArg('action', 'pdf'); // to omit cache headers $request->setArg('pagename', $pagename); // Template::_basepage fix $filename = FilenameForPage($pagename) . $WikiTheme->HTML_DUMP_SUFFIX; @@ -659,7 +659,7 @@ function _DumpHtmlToDir ($target, $page_iter, $exclude = false) $DUMP_MODE = $WikiTheme->DUMP_MODE; $data = GeneratePageasXML(new Template('browse', $request, $args), $pagename, $current, $args); - $WikiTheme->DUMP_MODE = $DUMP_MODE; + $WikiTheme->DUMP_MODE = $DUMP_MODE; if (preg_match_all("/_findFile($img_file, true)) - and basename($from)) + if ($img_file + and ($from = $WikiTheme->_findFile($img_file, true)) + and basename($from)) { if ($directory) { $target = "$directory/images/".basename($from); @@ -768,8 +768,8 @@ function _DumpHtmlToDir ($target, $page_iter, $exclude = false) } } - if (!empty($WikiTheme->dumped_buttons) - and is_array($WikiTheme->dumped_buttons)) + if (!empty($WikiTheme->dumped_buttons) + and is_array($WikiTheme->dumped_buttons)) { // Buttons also if ($directory) @@ -778,9 +778,9 @@ function _DumpHtmlToDir ($target, $page_iter, $exclude = false) if (array_key_exists($img_file, $already_images)) continue; $already_images[$img_file] = 1; - if ($img_file - and ($from = $WikiTheme->_findFile($img_file, true)) - and basename($from)) + if ($img_file + and ($from = $WikiTheme->_findFile($img_file, true)) + and basename($from)) { if ($directory) { $target = "$directory/images/buttons/".basename($from); @@ -807,9 +807,9 @@ function _DumpHtmlToDir ($target, $page_iter, $exclude = false) if (array_key_exists($css_file, $already_images)) continue; $already_images[$css_file] = 1; - if ($css_file - and ($from = $WikiTheme->_findFile(basename($css_file), true)) - and basename($from)) + if ($css_file + and ($from = $WikiTheme->_findFile(basename($css_file), true)) + and basename($from)) { // TODO: fix @import url(main.css); if ($directory) { @@ -834,7 +834,7 @@ function _DumpHtmlToDir ($target, $page_iter, $exclude = false) } } - if ($zip) + if ($zip) $zip->finish(); if ($WikiTheme->DUMP_MODE == 'PDFHTML') { @@ -931,7 +931,7 @@ function SavePage (&$request, &$pageinfo, $source, $filename) $current = $page->getCurrentRevision(); $skip = false; $edit = $request->getArg('edit'); - if ($merging) { + if ($merging) { if (isset($edit['keep_old'])) { $merging = false; $skip = true; @@ -941,7 +941,7 @@ function SavePage (&$request, &$pageinfo, $source, $filename) $overwrite = true; } elseif ( $current and (! $current->hasDefaultContents()) - && ($current->getPackedContent() != $content) ) + && ($current->getPackedContent() != $content) ) { include_once('lib/editpage.php'); $request->setArg('pagename', $pagename); @@ -1109,8 +1109,8 @@ function RevertPage (&$request) Button('submit:cancel', _("Cancel"), 'button')) ); $rev = $page->getRevision($version); - $html = HTML(HTML::fieldset($mesg), HTML::hr(), $rev->getTransformedContent()); - $template = Template('browse', + $html = HTML(HTML::fieldset($mesg), HTML::hr(), $rev->getTransformedContent()); + $template = Template('browse', array('CONTENT' => $html)); GeneratePage($template, $pagename, $rev); $request->checkValidators(); @@ -1123,17 +1123,17 @@ function RevertPage (&$request) $versiondata['summary'] = sprintf(_("revert to version %d"), $version); $new = $page->save($content, $currversion + 1, $versiondata); $dbi->touch(); - + $mesg = HTML::span(); $pagelink = WikiLink($pagename); - $mesg->pushContent(fmt("Revert: %s", $pagelink), + $mesg->pushContent(fmt("Revert: %s", $pagelink), fmt("- version %d saved to database as version %d", $version, $new->getVersion())); // Force browse of current page version. $request->setArg('version', false); $template = Template('savepage', array()); $template->replace('CONTENT', $new->getTransformedContent()); - + GeneratePage($template, $mesg, $new); flush(); } @@ -1294,9 +1294,9 @@ function LoadFile (&$request, $filename, $text = false, $mtime = false) $filename), $basename); } if (count($parts) > 1) - if ($overwrite) + if ($overwrite) $request->setArg('overwrite', $overwrite); - else + else unset($request->_args['overwrite']); } else if ( ($pageinfo = ParseSerializedPage($text, $default_pagename, @@ -1476,7 +1476,7 @@ function LoadFileOrDir (&$request) $finder = new FileFinder; $source = $finder->slashifyPath($source); $page = rawurldecode(basename($source)); - StartLoadDump($request, fmt("Loading '%s'", + StartLoadDump($request, fmt("Loading '%s'", HTML(dirname($source), dirname($source) ? "/" : "", WikiLink($page,'auto')))); @@ -1489,7 +1489,7 @@ function LoadFileOrDir (&$request) * - import all pgsrc pages. * - Todo: installer interface to edit config/config.ini settings * - Todo: ask for existing old index.php to convert to config/config.ini - * - Todo: theme-specific pages: + * - Todo: theme-specific pages: * blog - HomePage, ADMIN_USER/Blogs */ function SetupWiki (&$request) @@ -1536,7 +1536,7 @@ function SetupWiki (&$request) } foreach (array_merge($mandatory, $GLOBALS['AllActionPages'], - array(constant('HOME_PAGE'))) as $f) + array(constant('HOME_PAGE'))) as $f) { $page = gettext($f); $epage = urlencode($page); @@ -1554,7 +1554,7 @@ function SetupWiki (&$request) E_USER_WARNING); } } - + $pagename = _("InterWikiMap"); $map = $dbi->getPage($pagename); $map->set('locked', true); @@ -1581,7 +1581,6 @@ function LoadPostFile (&$request) EndLoadDump($request); } -// For emacs users // Local Variables: // mode: php // tab-width: 8 diff --git a/lib/plugin/AddComment.php b/lib/plugin/AddComment.php index 3205cd19a..759dfbca0 100644 --- a/lib/plugin/AddComment.php +++ b/lib/plugin/AddComment.php @@ -137,7 +137,6 @@ function togglecomments(a) { }; -// For emacs users // Local Variables: // mode: php // tab-width: 8 diff --git a/lib/plugin/AnalyseAccessLogSql.php b/lib/plugin/AnalyseAccessLogSql.php index 0c366652d..2126ce005 100644 --- a/lib/plugin/AnalyseAccessLogSql.php +++ b/lib/plugin/AnalyseAccessLogSql.php @@ -382,7 +382,6 @@ extends WikiPlugin } -// For emacs users // Local Variables: // mode: php // tab-width: 8 diff --git a/lib/plugin/AuthorHistory.php b/lib/plugin/AuthorHistory.php index 240941a8d..7f125b5d3 100644 --- a/lib/plugin/AuthorHistory.php +++ b/lib/plugin/AuthorHistory.php @@ -219,7 +219,6 @@ extends WikiPlugin }; -// For emacs users // Local Variables: // mode: php // tab-width: 8 diff --git a/lib/plugin/BackLinks.php b/lib/plugin/BackLinks.php index d234bef3f..401d108e6 100644 --- a/lib/plugin/BackLinks.php +++ b/lib/plugin/BackLinks.php @@ -182,7 +182,6 @@ class _PageList_Column_BackLinks_count extends _PageList_Column { } } -// For emacs users // Local Variables: // mode: php // tab-width: 8 diff --git a/lib/plugin/BoxRight.php b/lib/plugin/BoxRight.php index 8ac301b2b..77733797b 100644 --- a/lib/plugin/BoxRight.php +++ b/lib/plugin/BoxRight.php @@ -56,7 +56,6 @@ extends WikiPlugin } -// For emacs users // Local Variables: // mode: php // tab-width: 8 diff --git a/lib/plugin/CacheTest.php b/lib/plugin/CacheTest.php index dc3a00920..008e66bbe 100644 --- a/lib/plugin/CacheTest.php +++ b/lib/plugin/CacheTest.php @@ -162,9 +162,8 @@ extends WikiPluginCached array(255, 255, 255)); } // lazy_produceGraphics -} // WikiPlugin_CacheTest +} -// For emacs users // Local Variables: // mode: php // tab-width: 4 diff --git a/lib/plugin/Calendar.php b/lib/plugin/Calendar.php index 39fda09fd..b7227dcfd 100644 --- a/lib/plugin/Calendar.php +++ b/lib/plugin/Calendar.php @@ -244,7 +244,6 @@ extends WikiPlugin } }; -// For emacs users // Local Variables: // mode: php // tab-width: 8 diff --git a/lib/plugin/CalendarList.php b/lib/plugin/CalendarList.php index 3c9f0d02a..64f75b05a 100644 --- a/lib/plugin/CalendarList.php +++ b/lib/plugin/CalendarList.php @@ -225,7 +225,6 @@ extends WikiPlugin } }; -// For emacs users // Local Variables: // mode: php // tab-width: 8 diff --git a/lib/plugin/Comment.php b/lib/plugin/Comment.php index 9d45ec94f..2b1eb8250 100644 --- a/lib/plugin/Comment.php +++ b/lib/plugin/Comment.php @@ -57,7 +57,6 @@ extends WikiPlugin } }; -// For emacs users // Local Variables: // mode: php // tab-width: 8 diff --git a/lib/plugin/CreateBib.php b/lib/plugin/CreateBib.php index adc920490..9e13b9f4e 100644 --- a/lib/plugin/CreateBib.php +++ b/lib/plugin/CreateBib.php @@ -22,6 +22,7 @@ /** * CreateBib: Automatically create a BibTex file from page + * Based on CreateTOC * * Usage: * <> @@ -163,9 +164,6 @@ extends WikiPlugin } }; -// Based on CreateTOC - -// For emacs users // Local Variables: // mode: php // tab-width: 8 diff --git a/lib/plugin/CreateToc.php b/lib/plugin/CreateToc.php index 1f749ba04..8cf957517 100644 --- a/lib/plugin/CreateToc.php +++ b/lib/plugin/CreateToc.php @@ -478,7 +478,6 @@ extends WikiPlugin } }; -// For emacs users // Local Variables: // mode: php // tab-width: 8 diff --git a/lib/plugin/CurrentTime.php b/lib/plugin/CurrentTime.php index d764e9a33..229151686 100644 --- a/lib/plugin/CurrentTime.php +++ b/lib/plugin/CurrentTime.php @@ -81,7 +81,6 @@ extends WikiPlugin } }; -// For emacs users // Local Variables: // mode: php // tab-width: 8 diff --git a/lib/plugin/Diff.php b/lib/plugin/Diff.php index c80ec76f5..9659b85c1 100644 --- a/lib/plugin/Diff.php +++ b/lib/plugin/Diff.php @@ -198,7 +198,6 @@ extends WikiPlugin { } }; -// For emacs users // Local Variables: // mode: php // tab-width: 8 diff --git a/lib/plugin/DynamicIncludePage.php b/lib/plugin/DynamicIncludePage.php index 292119494..c7b4428ab 100644 --- a/lib/plugin/DynamicIncludePage.php +++ b/lib/plugin/DynamicIncludePage.php @@ -93,7 +93,6 @@ extends WikiPlugin_IncludePage } }; -// For emacs users // Local Variables: // mode: php // tab-width: 8 diff --git a/lib/plugin/EditMetaData.php b/lib/plugin/EditMetaData.php index 8b0fdf7d9..b4db68b5b 100644 --- a/lib/plugin/EditMetaData.php +++ b/lib/plugin/EditMetaData.php @@ -190,7 +190,6 @@ extends WikiPlugin__BackendInfo } }; -// For emacs users // Local Variables: // mode: php // tab-width: 8 diff --git a/lib/plugin/FileInfo.php b/lib/plugin/FileInfo.php index e5ad0728f..b61bbabf9 100644 --- a/lib/plugin/FileInfo.php +++ b/lib/plugin/FileInfo.php @@ -308,7 +308,6 @@ struct VS_VERSIONINFO { struct VS_VERSIONINFO } }; -// For emacs users // Local Variables: // mode: php // tab-width: 8 diff --git a/lib/plugin/FoafViewer.php b/lib/plugin/FoafViewer.php index 576ebd01b..222a4c646 100644 --- a/lib/plugin/FoafViewer.php +++ b/lib/plugin/FoafViewer.php @@ -228,7 +228,6 @@ extends WikiPlugin } } -// For emacs users // Local Variables: // mode: php // tab-width: 8 diff --git a/lib/plugin/FrameInclude.php b/lib/plugin/FrameInclude.php index d806da5ff..5f08de29f 100644 --- a/lib/plugin/FrameInclude.php +++ b/lib/plugin/FrameInclude.php @@ -143,7 +143,6 @@ extends WikiPlugin } }; -// For emacs users // Local Variables: // mode: php // tab-width: 8 diff --git a/lib/plugin/GoogleMaps.php b/lib/plugin/GoogleMaps.php index 5d4cf7df2..786060235 100644 --- a/lib/plugin/GoogleMaps.php +++ b/lib/plugin/GoogleMaps.php @@ -148,7 +148,6 @@ var marker = createMarker(point, '".$markertext->asXml()."'); map.addOverlay(mar } }; -// (c-file-style: "gnu") // Local Variables: // mode: php // tab-width: 8 diff --git a/lib/plugin/GraphViz.php b/lib/plugin/GraphViz.php index bfc4e296e..2ba0f953b 100644 --- a/lib/plugin/GraphViz.php +++ b/lib/plugin/GraphViz.php @@ -440,7 +440,6 @@ extends WikiPluginCached }; -// For emacs users // Local Variables: // mode: php // tab-width: 8 diff --git a/lib/plugin/HelloWorld.php b/lib/plugin/HelloWorld.php index 6cee8251d..11a60dc7a 100644 --- a/lib/plugin/HelloWorld.php +++ b/lib/plugin/HelloWorld.php @@ -68,7 +68,6 @@ extends WikiPlugin } }; -// For emacs users // Local Variables: // mode: php // tab-width: 8 diff --git a/lib/plugin/Imdb.php b/lib/plugin/Imdb.php index 7037328a6..71ce3876b 100644 --- a/lib/plugin/Imdb.php +++ b/lib/plugin/Imdb.php @@ -105,7 +105,6 @@ extends WikiPlugin_SqlResult } }; -// For emacs users // Local Variables: // mode: php // tab-width: 8 diff --git a/lib/plugin/IncludePage.php b/lib/plugin/IncludePage.php index c365f32ba..ff8237a7a 100644 --- a/lib/plugin/IncludePage.php +++ b/lib/plugin/IncludePage.php @@ -212,7 +212,6 @@ extends WikiPlugin // margin: 0.5ex 0px; // } -// For emacs users // Local Variables: // mode: php // tab-width: 8 diff --git a/lib/plugin/IncludePages.php b/lib/plugin/IncludePages.php index 2d3317b5a..868c2756f 100644 --- a/lib/plugin/IncludePages.php +++ b/lib/plugin/IncludePages.php @@ -76,7 +76,6 @@ extends WikiPlugin_IncludePage } }; -// For emacs users // Local Variables: // mode: php // tab-width: 8 diff --git a/lib/plugin/IncludeSiteMap.php b/lib/plugin/IncludeSiteMap.php index f28217547..560ae3eec 100644 --- a/lib/plugin/IncludeSiteMap.php +++ b/lib/plugin/IncludeSiteMap.php @@ -77,7 +77,6 @@ extends WikiPlugin_SiteMap } } -// For emacs users // Local Variables: // mode: php // tab-width: 8 diff --git a/lib/plugin/IncludeTree.php b/lib/plugin/IncludeTree.php index 0ecf8cd4b..ec7962fa5 100644 --- a/lib/plugin/IncludeTree.php +++ b/lib/plugin/IncludeTree.php @@ -65,7 +65,6 @@ extends WikiPlugin_SiteMap } } -// For emacs users // Local Variables: // mode: php // tab-width: 8 diff --git a/lib/plugin/InterWikiSearch.php b/lib/plugin/InterWikiSearch.php index 2ba5546e0..29569aea5 100644 --- a/lib/plugin/InterWikiSearch.php +++ b/lib/plugin/InterWikiSearch.php @@ -116,7 +116,6 @@ extends PageType_interwikimap }; } -// (c-file-style: "gnu") // Local Variables: // mode: php // tab-width: 8 diff --git a/lib/plugin/JabberPresence.php b/lib/plugin/JabberPresence.php index a50e78e4e..5d505c250 100644 --- a/lib/plugin/JabberPresence.php +++ b/lib/plugin/JabberPresence.php @@ -70,7 +70,6 @@ extends WikiPlugin } }; -// For emacs users // Local Variables: // mode: php // tab-width: 8 diff --git a/lib/plugin/LdapSearch.php b/lib/plugin/LdapSearch.php index 4fe01a0ef..53f7158ef 100644 --- a/lib/plugin/LdapSearch.php +++ b/lib/plugin/LdapSearch.php @@ -195,7 +195,6 @@ extends WikiPlugin } }; -// For emacs users // Local Variables: // mode: php // tab-width: 8 diff --git a/lib/plugin/ListSubpages.php b/lib/plugin/ListSubpages.php index 924df61f1..f78037e34 100644 --- a/lib/plugin/ListSubpages.php +++ b/lib/plugin/ListSubpages.php @@ -117,7 +117,6 @@ class _PageList_Column_ListSubpages_count extends _PageList_Column { } } -// For emacs users // Local Variables: // mode: php // tab-width: 8 diff --git a/lib/plugin/MediawikiTable.php b/lib/plugin/MediawikiTable.php index f467d38a7..68d1ba783 100644 --- a/lib/plugin/MediawikiTable.php +++ b/lib/plugin/MediawikiTable.php @@ -252,7 +252,6 @@ extends WikiPlugin } } -// For emacs users // Local Variables: // mode: php // tab-width: 8 diff --git a/lib/plugin/ModeratedPage.php b/lib/plugin/ModeratedPage.php index 8a8f07f9d..dc81b9ac1 100644 --- a/lib/plugin/ModeratedPage.php +++ b/lib/plugin/ModeratedPage.php @@ -443,7 +443,6 @@ extends WikiPlugin }; -// For emacs users // Local Variables: // mode: php // tab-width: 8 diff --git a/lib/plugin/NoCache.php b/lib/plugin/NoCache.php index f16a29001..44f915f92 100644 --- a/lib/plugin/NoCache.php +++ b/lib/plugin/NoCache.php @@ -57,7 +57,6 @@ extends WikiPlugin } }; -// For emacs users // Local Variables: // mode: php // tab-width: 8 diff --git a/lib/plugin/OldStyleTable.php b/lib/plugin/OldStyleTable.php index 43482bd72..586c37956 100644 --- a/lib/plugin/OldStyleTable.php +++ b/lib/plugin/OldStyleTable.php @@ -148,7 +148,6 @@ extends WikiPlugin } }; -// (c-file-style: "gnu") // Local Variables: // mode: php // tab-width: 8 diff --git a/lib/plugin/PageDump.php b/lib/plugin/PageDump.php index b16c1eb37..321ece2bd 100644 --- a/lib/plugin/PageDump.php +++ b/lib/plugin/PageDump.php @@ -311,7 +311,6 @@ _("PhpWiki developers should manually inspect the downloaded file for nested mar } }; -// For emacs users // Local Variables: // mode: php // tab-width: 8 diff --git a/lib/plugin/PageHistory.php b/lib/plugin/PageHistory.php index 63c0fa833..694105a71 100644 --- a/lib/plugin/PageHistory.php +++ b/lib/plugin/PageHistory.php @@ -335,7 +335,6 @@ extends WikiPlugin_RecentChanges } }; -// (c-file-style: "gnu") // Local Variables: // mode: php // tab-width: 8 diff --git a/lib/plugin/PageInfo.php b/lib/plugin/PageInfo.php index 1490d783c..d2470e4dd 100644 --- a/lib/plugin/PageInfo.php +++ b/lib/plugin/PageInfo.php @@ -68,7 +68,6 @@ extends WikiPlugin } }; -// (c-file-style: "gnu") // Local Variables: // mode: php // tab-width: 8 diff --git a/lib/plugin/PageTrail.php b/lib/plugin/PageTrail.php index 67c2818e8..96f385687 100644 --- a/lib/plugin/PageTrail.php +++ b/lib/plugin/PageTrail.php @@ -89,7 +89,6 @@ extends WikiPlugin } }; -// For emacs users // Local Variables: // mode: php // tab-width: 8 diff --git a/lib/plugin/PasswordReset.php b/lib/plugin/PasswordReset.php index 9bebf51a7..0abe362de 100644 --- a/lib/plugin/PasswordReset.php +++ b/lib/plugin/PasswordReset.php @@ -187,7 +187,6 @@ extends WikiPlugin } }; -// For emacs users // Local Variables: // mode: php // tab-width: 8 diff --git a/lib/plugin/PhotoAlbum.php b/lib/plugin/PhotoAlbum.php index e3f40d0da..30ca4e71c 100644 --- a/lib/plugin/PhotoAlbum.php +++ b/lib/plugin/PhotoAlbum.php @@ -657,7 +657,6 @@ display_slides();")); } }; -// For emacs users // Local Variables: // mode: php // tab-width: 8 diff --git a/lib/plugin/PhpHighlight.php b/lib/plugin/PhpHighlight.php index 55bfbec11..580c4cead 100644 --- a/lib/plugin/PhpHighlight.php +++ b/lib/plugin/PhpHighlight.php @@ -174,7 +174,6 @@ extends WikiPlugin }; -// For emacs users // Local Variables: // mode: php // tab-width: 8 diff --git a/lib/plugin/PhpWeather.php b/lib/plugin/PhpWeather.php index cc7979558..e4dd06360 100644 --- a/lib/plugin/PhpWeather.php +++ b/lib/plugin/PhpWeather.php @@ -193,7 +193,6 @@ extends WikiPlugin } }; -// For emacs users // Local Variables: // mode: php // tab-width: 8 diff --git a/lib/plugin/Ploticus.php b/lib/plugin/Ploticus.php index d1e8ef238..3d1001daa 100644 --- a/lib/plugin/Ploticus.php +++ b/lib/plugin/Ploticus.php @@ -279,7 +279,6 @@ extends WikiPluginCached } }; -// For emacs users // Local Variables: // mode: php // tab-width: 8 diff --git a/lib/plugin/PopUp.php b/lib/plugin/PopUp.php index c6e20dae6..ae60fbeee 100644 --- a/lib/plugin/PopUp.php +++ b/lib/plugin/PopUp.php @@ -94,7 +94,6 @@ extends WikiPlugin } }; -// For emacs users // Local Variables: // mode: php // tab-width: 8 diff --git a/lib/plugin/RateIt.php b/lib/plugin/RateIt.php index b9c899b65..21e3dfd54 100644 --- a/lib/plugin/RateIt.php +++ b/lib/plugin/RateIt.php @@ -436,7 +436,6 @@ var msg_rating_deleted = '"._("Rating deleted!")."'; }; -// For emacs users // Local Variables: // mode: php // tab-width: 8 diff --git a/lib/plugin/RawHtml.php b/lib/plugin/RawHtml.php index 96a4857a4..60398f171 100644 --- a/lib/plugin/RawHtml.php +++ b/lib/plugin/RawHtml.php @@ -226,7 +226,6 @@ ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. } } -// For emacs users // Local Variables: // mode: php // tab-width: 8 diff --git a/lib/plugin/RecentChanges.php b/lib/plugin/RecentChanges.php index b00de66b9..7f1d24916 100644 --- a/lib/plugin/RecentChanges.php +++ b/lib/plugin/RecentChanges.php @@ -1499,7 +1499,6 @@ class OptionsButtonBars extends HtmlElement { } } -// (c-file-style: "gnu") // Local Variables: // mode: php // tab-width: 8 diff --git a/lib/plugin/RecentChangesCached.php b/lib/plugin/RecentChangesCached.php index 99f543140..16d0ecbc3 100644 --- a/lib/plugin/RecentChangesCached.php +++ b/lib/plugin/RecentChangesCached.php @@ -129,9 +129,8 @@ extends WikiPluginCached } -} // WikiPlugin_RecentChangesCached +} -// For emacs users // Local Variables: // mode: php // tab-width: 4 diff --git a/lib/plugin/RecentComments.php b/lib/plugin/RecentComments.php index 4384923ee..cffd867c7 100644 --- a/lib/plugin/RecentComments.php +++ b/lib/plugin/RecentComments.php @@ -152,7 +152,6 @@ class RecentCommentsRevisionIterator extends WikiDB_PageRevisionIterator } -// (c-file-style: "gnu") // Local Variables: // mode: php // tab-width: 8 diff --git a/lib/plugin/RecentEdits.php b/lib/plugin/RecentEdits.php index 9b4e77b6b..361b94cdf 100644 --- a/lib/plugin/RecentEdits.php +++ b/lib/plugin/RecentEdits.php @@ -56,7 +56,6 @@ extends WikiPlugin_RecentChanges } } -// (c-file-style: "gnu") // Local Variables: // mode: php // tab-width: 8 diff --git a/lib/plugin/RecentReferrers.php b/lib/plugin/RecentReferrers.php index b96d73b18..c4b3c5b03 100644 --- a/lib/plugin/RecentReferrers.php +++ b/lib/plugin/RecentReferrers.php @@ -77,7 +77,6 @@ class WikiPlugin_RecentReferrers extends WikiPlugin } } -// (c-file-style: "gnu") // Local Variables: // mode: php // tab-width: 8 diff --git a/lib/plugin/RedirectTo.php b/lib/plugin/RedirectTo.php index 42e5c8fb3..65e4b8aec 100644 --- a/lib/plugin/RedirectTo.php +++ b/lib/plugin/RedirectTo.php @@ -103,7 +103,6 @@ extends WikiPlugin } }; -// For emacs users // Local Variables: // mode: php // tab-width: 8 diff --git a/lib/plugin/RelatedChanges.php b/lib/plugin/RelatedChanges.php index b8ef9d105..ccd615923 100644 --- a/lib/plugin/RelatedChanges.php +++ b/lib/plugin/RelatedChanges.php @@ -142,7 +142,6 @@ class RelatedChangesRevisionIterator extends WikiDB_PageRevisionIterator } } -// (c-file-style: "gnu") // Local Variables: // mode: php // tab-width: 8 diff --git a/lib/plugin/RichTable.php b/lib/plugin/RichTable.php index fa796ccab..380bc7998 100644 --- a/lib/plugin/RichTable.php +++ b/lib/plugin/RichTable.php @@ -141,7 +141,6 @@ extends WikiPlugin } } -// For emacs users // Local Variables: // mode: php // tab-width: 8 diff --git a/lib/plugin/RssFeed.php b/lib/plugin/RssFeed.php index 438edb6ac..e8b20eef3 100644 --- a/lib/plugin/RssFeed.php +++ b/lib/plugin/RssFeed.php @@ -124,7 +124,6 @@ extends WikiPlugin }; -// For emacs users // Local Variables: // mode: php // tab-width: 8 diff --git a/lib/plugin/SiteMap.php b/lib/plugin/SiteMap.php index 2a4ca68fb..331590235 100644 --- a/lib/plugin/SiteMap.php +++ b/lib/plugin/SiteMap.php @@ -218,7 +218,6 @@ extends WikiPlugin } }; -// For emacs users // Local Variables: // mode: php // tab-width: 8 diff --git a/lib/plugin/SpellCheck.php b/lib/plugin/SpellCheck.php index 7abbb61d7..f8d8b60e7 100644 --- a/lib/plugin/SpellCheck.php +++ b/lib/plugin/SpellCheck.php @@ -182,7 +182,6 @@ extends WikiPlugin } }; -// For emacs users // Local Variables: // mode: php // tab-width: 8 diff --git a/lib/plugin/SqlResult.php b/lib/plugin/SqlResult.php index 0db7219ad..592625e60 100644 --- a/lib/plugin/SqlResult.php +++ b/lib/plugin/SqlResult.php @@ -214,7 +214,6 @@ extends WikiPlugin }; -// For emacs users // Local Variables: // mode: php // tab-width: 8 diff --git a/lib/plugin/SyncWiki.php b/lib/plugin/SyncWiki.php index 53e2033ff..eefc015c3 100644 --- a/lib/plugin/SyncWiki.php +++ b/lib/plugin/SyncWiki.php @@ -352,7 +352,6 @@ extends WikiPlugin_WikiAdminUtils } }; -// For emacs users // Local Variables: // mode: php // tab-width: 8 diff --git a/lib/plugin/SyntaxHighlighter.php b/lib/plugin/SyntaxHighlighter.php index 8845357df..e2b079f4c 100644 --- a/lib/plugin/SyntaxHighlighter.php +++ b/lib/plugin/SyntaxHighlighter.php @@ -149,7 +149,6 @@ extends WikiPlugin } }; -// For emacs users // Local Variables: // mode: php // tab-width: 8 diff --git a/lib/plugin/TeX2png.php b/lib/plugin/TeX2png.php index 902e1296f..3b516f113 100644 --- a/lib/plugin/TeX2png.php +++ b/lib/plugin/TeX2png.php @@ -232,7 +232,6 @@ extends WikiPlugin } }; -// For emacs users // Local Variables: // mode: php // tab-width: 8 diff --git a/lib/plugin/Template.php b/lib/plugin/Template.php index 4e42b7167..cb764217f 100644 --- a/lib/plugin/Template.php +++ b/lib/plugin/Template.php @@ -253,7 +253,6 @@ extends WikiPlugin } }; -// For emacs users // Local Variables: // mode: php // tab-width: 8 diff --git a/lib/plugin/TexToPng.php b/lib/plugin/TexToPng.php index 72948d5d1..4c955d7c5 100644 --- a/lib/plugin/TexToPng.php +++ b/lib/plugin/TexToPng.php @@ -293,9 +293,8 @@ class WikiPlugin_TexToPng extends WikiPluginCached } return false; } // TexToImg -} // WikiPlugin_TexToPng +} -// For emacs users // Local Variables: // mode: php // tab-width: 4 diff --git a/lib/plugin/Transclude.php b/lib/plugin/Transclude.php index 8d6f66449..afca4b871 100644 --- a/lib/plugin/Transclude.php +++ b/lib/plugin/Transclude.php @@ -158,7 +158,6 @@ extends WikiPlugin } }; -// (c-file-style: "gnu") // Local Variables: // mode: php // tab-width: 8 diff --git a/lib/plugin/TranslateText.php b/lib/plugin/TranslateText.php index c2acd339b..22dcde767 100644 --- a/lib/plugin/TranslateText.php +++ b/lib/plugin/TranslateText.php @@ -131,7 +131,6 @@ extends WikiPlugin__WikiTranslation } }; -// For emacs users // Local Variables: // mode: php // tab-width: 8 diff --git a/lib/plugin/UnfoldSubpages.php b/lib/plugin/UnfoldSubpages.php index 1ac119af1..d5472fa32 100644 --- a/lib/plugin/UnfoldSubpages.php +++ b/lib/plugin/UnfoldSubpages.php @@ -177,7 +177,6 @@ extends WikiPlugin_IncludePage } }; -// For emacs users // Local Variables: // mode: php // tab-width: 8 diff --git a/lib/plugin/UpLoad.php b/lib/plugin/UpLoad.php index 46d302ccd..afd372e05 100644 --- a/lib/plugin/UpLoad.php +++ b/lib/plugin/UpLoad.php @@ -312,7 +312,6 @@ ws[cfh]"); } -// (c-file-style: "gnu") // Local Variables: // mode: php // tab-width: 8 diff --git a/lib/plugin/UriResolver.php b/lib/plugin/UriResolver.php index b14afcb6a..4ae2d7bcd 100644 --- a/lib/plugin/UriResolver.php +++ b/lib/plugin/UriResolver.php @@ -60,7 +60,6 @@ extends WikiPlugin } }; -// For emacs users // Local Variables: // mode: php // tab-width: 8 diff --git a/lib/plugin/UserPreferences.php b/lib/plugin/UserPreferences.php index 9a1300de7..d59b15c9a 100644 --- a/lib/plugin/UserPreferences.php +++ b/lib/plugin/UserPreferences.php @@ -172,7 +172,6 @@ extends WikiPlugin } }; -// For emacs users // Local Variables: // mode: php // tab-width: 8 diff --git a/lib/plugin/WatchPage.php b/lib/plugin/WatchPage.php index 9cc4d7e61..d0969fa66 100644 --- a/lib/plugin/WatchPage.php +++ b/lib/plugin/WatchPage.php @@ -164,7 +164,6 @@ extends WikiPlugin } }; -// For emacs users // Local Variables: // mode: php // tab-width: 8 diff --git a/lib/plugin/WhoIsOnline.php b/lib/plugin/WhoIsOnline.php index 2cc1b681c..ce2d78070 100644 --- a/lib/plugin/WhoIsOnline.php +++ b/lib/plugin/WhoIsOnline.php @@ -193,7 +193,6 @@ extends WikiPlugin } }; -// For emacs users // Local Variables: // mode: php // tab-width: 8 diff --git a/lib/plugin/WikiAdminUtils.php b/lib/plugin/WikiAdminUtils.php index 60c87bdc8..62d56e9ee 100644 --- a/lib/plugin/WikiAdminUtils.php +++ b/lib/plugin/WikiAdminUtils.php @@ -321,8 +321,6 @@ extends _PageList_Column { } } - -// For emacs users // Local Variables: // mode: php // tab-width: 8 diff --git a/lib/plugin/WikiBlog.php b/lib/plugin/WikiBlog.php index 8f0f9bb4d..ac5a8eab3 100644 --- a/lib/plugin/WikiBlog.php +++ b/lib/plugin/WikiBlog.php @@ -425,7 +425,6 @@ extends WikiPlugin }; -// For emacs users // Local Variables: // mode: php // tab-width: 8 diff --git a/lib/plugin/WikiForm.php b/lib/plugin/WikiForm.php index 062c79476..09490673f 100644 --- a/lib/plugin/WikiForm.php +++ b/lib/plugin/WikiForm.php @@ -120,7 +120,6 @@ extends WikiPlugin } }; -// For emacs users // Local Variables: // mode: php // tab-width: 8 diff --git a/lib/plugin/WikiFormRich.php b/lib/plugin/WikiFormRich.php index 2179c8fcd..f9334d635 100644 --- a/lib/plugin/WikiFormRich.php +++ b/lib/plugin/WikiFormRich.php @@ -393,7 +393,6 @@ extends WikiPlugin } }; -// For emacs users // Local Variables: // mode: php // tab-width: 8 diff --git a/lib/plugin/WikiForum.php b/lib/plugin/WikiForum.php index d814af188..a3d8e1f2c 100644 --- a/lib/plugin/WikiForum.php +++ b/lib/plugin/WikiForum.php @@ -130,7 +130,6 @@ extends WikiPlugin_WikiBlog } }; -// For emacs users // Local Variables: // mode: php // tab-width: 8 diff --git a/lib/plugin/WikiPoll.php b/lib/plugin/WikiPoll.php index 333f28334..7abf9c07a 100644 --- a/lib/plugin/WikiPoll.php +++ b/lib/plugin/WikiPoll.php @@ -325,7 +325,6 @@ extends WikiPlugin }; -// For emacs users // Local Variables: // mode: php // tab-width: 8 diff --git a/lib/plugin/WikicreoleTable.php b/lib/plugin/WikicreoleTable.php index b03a1d658..e83b1922e 100644 --- a/lib/plugin/WikicreoleTable.php +++ b/lib/plugin/WikicreoleTable.php @@ -144,7 +144,6 @@ extends WikiPlugin } -// For emacs users // Local Variables: // mode: php // tab-width: 8 diff --git a/lib/plugin/YouTube.php b/lib/plugin/YouTube.php index 0e10ca1c2..4c9de488c 100644 --- a/lib/plugin/YouTube.php +++ b/lib/plugin/YouTube.php @@ -184,7 +184,6 @@ extends WikiPlugin } }; -// For emacs users // Local Variables: // mode: php // tab-width: 8 diff --git a/lib/plugin/_AuthInfo.php b/lib/plugin/_AuthInfo.php index e7dca3ccd..68bffd607 100644 --- a/lib/plugin/_AuthInfo.php +++ b/lib/plugin/_AuthInfo.php @@ -197,7 +197,6 @@ extends WikiPlugin } }; -// (c-file-style: "gnu") // Local Variables: // mode: php // tab-width: 8 diff --git a/lib/plugin/_BackendInfo.php b/lib/plugin/_BackendInfo.php index c7bc8d47c..f2a537443 100644 --- a/lib/plugin/_BackendInfo.php +++ b/lib/plugin/_BackendInfo.php @@ -200,7 +200,6 @@ extends WikiPlugin }; -// (c-file-style: "gnu") // Local Variables: // mode: php // tab-width: 8 diff --git a/lib/plugin/_PreferencesInfo.php b/lib/plugin/_PreferencesInfo.php index 19cbc32e7..b6e03b79b 100644 --- a/lib/plugin/_PreferencesInfo.php +++ b/lib/plugin/_PreferencesInfo.php @@ -47,7 +47,6 @@ extends WikiPlugin } }; -// For emacs users // Local Variables: // mode: php // tab-width: 8 diff --git a/lib/plugin/_Retransform.php b/lib/plugin/_Retransform.php index 82c9a0b27..204db1172 100644 --- a/lib/plugin/_Retransform.php +++ b/lib/plugin/_Retransform.php @@ -80,7 +80,6 @@ extends WikiPlugin }; -// (c-file-style: "gnu") // Local Variables: // mode: php // tab-width: 8 diff --git a/lib/plugin/_WikiTranslation.php b/lib/plugin/_WikiTranslation.php index 661ca256e..c58c816fa 100644 --- a/lib/plugin/_WikiTranslation.php +++ b/lib/plugin/_WikiTranslation.php @@ -452,7 +452,6 @@ class _PageList_Column_customlang extends _PageList_Column { } } -// For emacs users // Local Variables: // mode: php // tab-width: 8 diff --git a/lib/plugin/text2png.php b/lib/plugin/text2png.php index c93ddd0ca..d2db5994b 100644 --- a/lib/plugin/text2png.php +++ b/lib/plugin/text2png.php @@ -20,7 +20,6 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - /** * File loading and saving diagnostic messages, to see whether an * image was saved to or loaded from the cache and what the path is. @@ -227,7 +226,6 @@ extends WikiPlugin } }; -// For emacs users // Local Variables: // mode: php // tab-width: 4 diff --git a/lib/prepend.php b/lib/prepend.php index 97960a0c9..e1898a002 100644 --- a/lib/prepend.php +++ b/lib/prepend.php @@ -8,8 +8,8 @@ // see lib/stdlib.php: phpwiki_version() define('PHPWIKI_VERSION', '1.4.0RC-20100607'); -/** - * Returns true if current php version is at mimimum a.b.c +/** + * Returns true if current php version is at mimimum a.b.c * Called: check_php_version(5,2) */ function check_php_version ($a = '0', $b = '0', $c = '0') { @@ -19,9 +19,9 @@ function check_php_version ($a = '0', $b = '0', $c = '0') { return ($PHP_VERSION >= ($a.$b.$c)); } -/** PHP5 deprecated old-style globals if !(bool)ini_get('register_long_arrays'). +/** PHP5 deprecated old-style globals if !(bool)ini_get('register_long_arrays'). * See Bug #1180115 - * We want to work with those old ones instead of the new superglobals, + * We want to work with those old ones instead of the new superglobals, * for easier coding. */ /* @@ -43,7 +43,7 @@ if (empty($GLOBALS['HTTP_SERVER_VARS'])) { } unset($k); // catch connection failures on upgrade -if (isset($GLOBALS['HTTP_GET_VARS']['action']) +if (isset($GLOBALS['HTTP_GET_VARS']['action']) and $GLOBALS['HTTP_GET_VARS']['action'] == 'upgrade') define('ADODB_ERROR_HANDLER_TYPE', E_USER_WARNING); @@ -110,7 +110,7 @@ class DebugTimer { $this->getTime('utime', $now), $this->getTime('stime', $now)); } - + function _CLK_TCK() { // FIXME: this is clearly not always right. // But how to figure out the right value? @@ -144,12 +144,12 @@ function ExitWiki($errormsg = false) if ($in_exit) exit; - + $in_exit = true; global $ErrorManager; $ErrorManager->flushPostponedErrors(); - + if(!empty($errormsg)) { PrintXML(HTML::br(), $errormsg); print "\n"; @@ -163,13 +163,11 @@ if (!defined('DEBUG') or (defined('DEBUG') and DEBUG > 2)) { $ErrorManager->setPostponedErrorMask(E_USER_NOTICE | E_NOTICE); } - -// (c-file-style: "gnu") // Local Variables: // mode: php // tab-width: 8 // c-basic-offset: 4 // c-hanging-comment-ender-p: nil // indent-tabs-mode: nil -// End: +// End: ?> diff --git a/lib/purgepage.php b/lib/purgepage.php index 95166e8fc..f76462ea2 100644 --- a/lib/purgepage.php +++ b/lib/purgepage.php @@ -56,7 +56,6 @@ function PurgePage (&$request) { GeneratePage($html, _("Purge Page")); } -// For emacs users // Local Variables: // mode: php // tab-width: 8 diff --git a/lib/removepage.php b/lib/removepage.php index b38714041..6b8a852ae 100644 --- a/lib/removepage.php +++ b/lib/removepage.php @@ -56,8 +56,6 @@ function RemovePage (&$request) { GeneratePage($html, _("Remove Page")); } - -// For emacs users // Local Variables: // mode: php // tab-width: 8 diff --git a/lib/stdlib.php b/lib/stdlib.php index 058818313..21192b5b7 100644 --- a/lib/stdlib.php +++ b/lib/stdlib.php @@ -36,7 +36,7 @@ ConvertOldMarkup ($content, $markup_type = "block") MangleXmlIdentifier($str) UnMangleXmlIdentifier($str) - + class Stack { push($item), pop(), cnt(), top() } class Alert { show() } class WikiPageName {getParent(),isValid(),getWarnings() } @@ -56,9 +56,9 @@ file_mtime ($filename) sort_file_mtime ($a, $b) - class fileSet {fileSet($directory, $filepattern = false), + class fileSet {fileSet($directory, $filepattern = false), getFiles($exclude='', $sortby='', $limit='') } - class ListRegexExpand { listMatchCallback($item, $key), + class ListRegexExpand { listMatchCallback($item, $key), expandRegex ($index, &$pages) } glob_to_pcre ($glob) @@ -85,7 +85,7 @@ firstNWordsOfContent ($n, $content) extractSection ($section, $content, $page, $quiet = false, $sectionhead = false) isExternalReferrer() - + charset_convert($from, $to, $data) string_starts_with($string, $prefix) string_ends_with($string, $suffix) @@ -109,7 +109,7 @@ if (defined('_PHPWIKI_STDLIB_LOADED')) return; else define('_PHPWIKI_STDLIB_LOADED', true); define('MAX_PAGENAME_LENGTH', 100); - + /** * Convert string to a valid XML identifier. * @@ -136,7 +136,7 @@ define('MAX_PAGENAME_LENGTH', 100); function MangleXmlIdentifier($str) { if (!$str) return 'empty.'; - + return preg_replace('/[^-_:A-Za-z0-9]|(?<=^)[^A-Za-z]/e', "'x' . sprintf('%02x', ord('\\0')) . '.'", $str); @@ -165,14 +165,14 @@ function GetCookieName() { * @param mixed $pagename If a string this will be the name of the Wiki page to link to. * If a WikiDB_Page object function will extract the name to link to. * If a WikiDB_PageRevision object function will extract the name to link to. - * @param array $args + * @param array $args * @param boolean $get_abs_url Default value is false. * @return string The absolute URL to the page passed as $pagename. */ function WikiURL($pagename, $args = '', $get_abs_url = false) { global $request, $WikiTheme; $anchor = false; - + if (is_object($pagename)) { if (isa($pagename, 'WikiDB_Page')) { $pagename = $pagename->getName(); @@ -195,7 +195,7 @@ function WikiURL($pagename, $args = '', $get_abs_url = false) { $args = 'start_debug=' . $request->getArg('start_debug'); elseif (is_array($args)) $args['start_debug'] = $request->getArg('start_debug'); - else + else $args .= '&start_debug=' . $request->getArg('start_debug'); } if (is_array($args)) { @@ -203,7 +203,7 @@ function WikiURL($pagename, $args = '', $get_abs_url = false) { foreach ($args as $key => $val) { // avoid default args if (USE_PATH_INFO and $key == 'pagename') - ; + ; elseif ($key == 'action' and $val == 'browse') ; elseif (!is_array($val)) // ugly hack for getURLtoSelf() which also takes POST vars @@ -220,7 +220,7 @@ function WikiURL($pagename, $args = '', $get_abs_url = false) { if (!empty($WikiTheme->VALID_LINKS) and $request->getArg('action') == 'pdf') { if (!in_array($pagename, $WikiTheme->VALID_LINKS)) $url = ''; - else + else $url = $base . $WikiTheme->HTML_DUMP_SUFFIX; } else { $url .= $WikiTheme->HTML_DUMP_SUFFIX; @@ -331,7 +331,7 @@ function PossiblyGlueIconToText($proto_or_url, $text) { $where = 'front'; } if ($where == 'after') { - // span the icon only to the last word (tie them together), + // span the icon only to the last word (tie them together), // to let the previous words wrap on line breaks. if (!is_object($text)) { preg_match('/^(\s*\S*)(\s*)$/', $text, $m); @@ -347,7 +347,7 @@ function PossiblyGlueIconToText($proto_or_url, $text) { $text = HTML($prefix, $text); return $text; } - // span the icon only to the first word (tie them together), + // span the icon only to the first word (tie them together), // to let the next words wrap on line breaks if (!is_object($text)) { preg_match('/^\s*(\S*)(.*?)\s*$/', $text, $m); @@ -405,7 +405,7 @@ function LinkURL($url, $linktext = '') { * Inline Images * * Syntax: [image.png size=50% border=n align= hspace= vspace= width= height=] - * Disallows sizes which are too small. + * Disallows sizes which are too small. * Spammers may use such (typically invisible) image attributes to raise their GoogleRank. * * Handle embeddable objects, like svg, class, vrml, swf, svgz, pdf, avi, wmv especially. @@ -468,7 +468,7 @@ function LinkImage($url, $alt = "") { $link->setAttr('width',$m[1]); $link->setAttr('height',$m[2]); } - } + } else { $link = HTML::span(array('class' => 'error'), sprintf(_("Invalid image attribute \"%s\" %s=%s"), @@ -503,11 +503,11 @@ function LinkImage($url, $alt = "") { if (($width = $link->getAttr('width')) and ($height = $link->getAttr('height'))) { //$width = (int) $width; // px or % or other suffix //$height = (int) $height; - if (($width < 3 and $height < 10) or - ($height < 3 and $width < 20) or + if (($width < 3 and $height < 10) or + ($height < 3 and $width < 20) or ($height < 7 and $width < 7)) { - $link = HTML::span(array('class' => 'error'), + $link = HTML::span(array('class' => 'error'), _("Invalid image size")); return $link; } @@ -520,7 +520,7 @@ function LinkImage($url, $alt = "") { elseif (! preg_match("/\.$force_img$/i", $url)) ; // only valid image extensions or scripts assumed to generate images elseif (preg_match("/^http/",$url)) { // external url - $size = @getimagesize($url); + $size = @getimagesize($url); } else { // local file if (file_exists($file = NormalizeLocalFileName($url))) { // here $size = @getimagesize($file); @@ -540,11 +540,11 @@ function LinkImage($url, $alt = "") { if ($size) { $width = $size[0]; $height = $size[1]; - if (($width < 3 and $height < 10) + if (($width < 3 and $height < 10) or ($height < 3 and $width < 20) or ($height < 7 and $width < 7)) { - $link = HTML::span(array('class' => 'error'), + $link = HTML::span(array('class' => 'error'), _("Invalid image size")); return $link; } @@ -565,7 +565,7 @@ function LinkImage($url, $alt = "") { } /** - * / tags instead of for all non-image extensions + * / tags instead of for all non-image extensions * in INLINE_IMAGES. * Called by LinkImage(), not directly. * Syntax: [image.svg size=50% alt=image.gif border=n align= hspace= vspace= width= height=] @@ -577,18 +577,18 @@ function LinkImage($url, $alt = "") { * http://www.alleged.org.uk/pdc/2002/svg-object.html * * Allowed object tags: - * DATA=URI (object data) - * CLASSID=URI (location of implementation) - * ARCHIVE=CDATA (archive files) - * CODEBASE=URI (base URI for CLASSID, DATA, ARCHIVE) - * WIDTH=Length (object width) - * HEIGHT=Length (object height) - * NAME=CDATA (name for form submission) - * USEMAP=URI (client-side image map) - * TYPE=ContentType (content-type of object) - * CODETYPE=ContentType (content-type of code) - * STANDBY=Text (message to show while loading) - * TABINDEX=NUMBER (position in tabbing order) + * DATA=URI (object data) + * CLASSID=URI (location of implementation) + * ARCHIVE=CDATA (archive files) + * CODEBASE=URI (base URI for CLASSID, DATA, ARCHIVE) + * WIDTH=Length (object width) + * HEIGHT=Length (object height) + * NAME=CDATA (name for form submission) + * USEMAP=URI (client-side image map) + * TYPE=ContentType (content-type of object) + * CODETYPE=ContentType (content-type of code) + * STANDBY=Text (message to show while loading) + * TABINDEX=NUMBER (position in tabbing order) * DECLARE (do not instantiate object) * The rest is added as tags */ @@ -653,7 +653,7 @@ function ImgObject($img, $url) { if (function_exists('mime_content_type')) $type = mime_content_type($url); } - $object = HTML::object(array_merge($img->_attr, + $object = HTML::object(array_merge($img->_attr, array('type' => $type)), //'src' => $url $img->_content); $object->setAttr('class', 'inlineobject'); @@ -679,31 +679,31 @@ class Stack { $this->items[$this->size] = $item; $this->size++; return true; - } - + } + function pop() { if ($this->size == 0) { return false; // stack is empty - } + } $this->size--; return $this->items[$this->size]; - } - + } + function cnt() { return $this->size; - } - + } + function top() { if($this->size) return $this->items[$this->size - 1]; else return ''; } - -} + +} // end class definition -function SplitQueryArgs ($query_args = '') +function SplitQueryArgs ($query_args = '') { // FIXME: use the arg-seperator which might not be & $split_args = explode('&', $query_args); @@ -716,7 +716,7 @@ function SplitQueryArgs ($query_args = '') function LinkPhpwikiURL($url, $text = '', $basepage = false) { $args = array(); - + if (!preg_match('/^ phpwiki: ([^?]*) [?]? (.*) $/x', $url, $m)) { return HTML::span(array('class' => 'error'), _("BAD phpwiki: URL")); } @@ -724,7 +724,7 @@ function LinkPhpwikiURL($url, $text = '', $basepage = false) { if ($m[1]) $pagename = urldecode($m[1]); $qargs = $m[2]; - + if (empty($pagename) && preg_match('/^(diff|edit|links|info)=([^&]+)$/', $qargs, $m)) { // Convert old style links (to not break diff links in @@ -741,7 +741,7 @@ function LinkPhpwikiURL($url, $text = '', $basepage = false) { if (isset($args['action']) && $args['action'] == 'browse') unset($args['action']); - + /*FIXME: if (empty($args['action'])) $class = 'wikilink'; @@ -759,7 +759,7 @@ function LinkPhpwikiURL($url, $text = '', $basepage = false) { HTML::u(_("Lock page to enable link"))); $class = 'wikiadmin'; } - + if (!$text) $text = HTML::span(array('class' => 'rawurl'), $url); @@ -768,7 +768,7 @@ function LinkPhpwikiURL($url, $text = '', $basepage = false) { global $WikiTheme; return $WikiTheme->linkBadWikiWord($wikipage, $url); } - + return HTML::a(array('href' => WikiURL($pagename, $args), 'class' => $class), $text); @@ -794,13 +794,13 @@ class WikiPageName * This is the full name of the page (without anchor). */ //var $name; - + /** The anchor. * * This is the referenced anchor within the page, or the empty string. */ //var $anchor; - + /** Constructor * * @param mixed $name Page name. @@ -863,7 +863,7 @@ class WikiPageName function getName() { return $this->name; } - + function getParent() { $name = $this->name; if (!($tail = strrchr($name, SUBPAGE_SEPARATOR))) @@ -885,11 +885,11 @@ class WikiPageName $warnings = array_merge($warnings, $this->_errors); if (!$warnings) return false; - + return sprintf(_("'%s': Bad page name: %s"), $this->shortName, join(', ', $warnings)); } - + function _pagename($page) { if (isa($page, 'WikiDB_Page')) return $page->getName(); @@ -923,7 +923,7 @@ class WikiPageName /** * Compress internal white-space to single space character. * - * This leads to problems with loading a foreign charset pagename, + * This leads to problems with loading a foreign charset pagename, * which cannot be deleted anymore, because unknown chars are compressed. * So BEFORE importing a file _check must be done !!! */ @@ -932,7 +932,7 @@ class WikiPageName $pagename = preg_replace('/[\s\xa0]+/', ' ', $orig = $pagename); if ($pagename != $orig) $this->_warnings[] = _("White space converted to single space"); - + // Delete any control characters. if (DATABASE_TYPE == 'cvs' or DATABASE_TYPE == 'file' or DATABASE_TYPE == 'flatfile') { $pagename = preg_replace('/[\x00-\x1f\x7f\x80-\x9f]/', '', $orig = $pagename); @@ -954,7 +954,7 @@ class WikiPageName $this->_warnings[] = _("';' is deprecated"); $pagename = str_replace(';', '', $pagename); }*/ - + // not only for SQL, also to restrict url length if (strlen($pagename) > MAX_PAGENAME_LENGTH) { $pagename = substr($pagename, 0, MAX_PAGENAME_LENGTH); @@ -962,16 +962,16 @@ class WikiPageName } // disallow some chars only on file and cvs - if ((DATABASE_TYPE == 'cvs' - or DATABASE_TYPE == 'file' - or DATABASE_TYPE == 'flatfile') - and preg_match('/(:|\.\.)/', $pagename, $m)) + if ((DATABASE_TYPE == 'cvs' + or DATABASE_TYPE == 'file' + or DATABASE_TYPE == 'flatfile') + and preg_match('/(:|\.\.)/', $pagename, $m)) { $this->_warnings[] = sprintf(_("Illegal chars %s removed"), $m[1]); $pagename = str_replace('..', '', $pagename); $pagename = str_replace(':', '', $pagename); } - + return $pagename; } } @@ -995,23 +995,23 @@ class WikiPageName * probably for now.... * @bugs Apache2 and IIS crash with OldTextFormattingRules or * AnciennesR%E8glesDeFormatage. (at the 2nd attempt to do the anchored block regex) - * It only crashes with CreateToc so far, but other pages (not in pgsrc) are + * It only crashes with CreateToc so far, but other pages (not in pgsrc) are * also known to crash, even with Apache1. */ function ConvertOldMarkup ($text, $markup_type = "block") { static $subs; static $block_re; - + // FIXME: // Trying to detect why the 2nd paragraph of OldTextFormattingRules or - // AnciennesR%E8glesDeFormatage crashes. - // It only crashes with CreateToc so far, but other pages (not in pgsrc) are + // AnciennesR%E8glesDeFormatage crashes. + // It only crashes with CreateToc so far, but other pages (not in pgsrc) are // also known to crash, even with Apache1. $debug_skip = false; // I suspect this only to crash with Apache2 and IIS. if (in_array(php_sapi_name(),array('apache2handler','apache2filter','isapi')) - and preg_match("/plugin CreateToc/", $text)) + and preg_match("/plugin CreateToc/", $text)) { trigger_error(_("The CreateTocPlugin is not yet old markup compatible! ") ._("Please remove the CreateToc line to be able to reformat this page to old markup. ") @@ -1055,7 +1055,7 @@ function ConvertOldMarkup ($text, $markup_type = "block") { // Escape '<'s //$orig[] = '/<(?!\?plugin)|(?~[[\\1|#ftnt_\\1]~]'; @@ -1069,7 +1069,7 @@ function ConvertOldMarkup ($text, $markup_type = "block") { // Escape nestled markup. $orig[] = '/^(?<=^|\s)[=_](?=\S)|(?<=\S)[=_*](?=\s|$)/m'; $repl[] = '~\\0'; - + // in old markup headings only allowed at beginning of line $orig[] = '/!/'; $repl[] = '~!'; @@ -1111,9 +1111,9 @@ function ConvertOldMarkup ($text, $markup_type = "block") { $block_re = ( '/\A((?:.|\n)*?)(^(?:' . join("|", $blockpats) . ').*$)\n?/m' ); - + } - + if ($markup_type != "block") { list ($orig, $repl) = $subs[$markup_type]; return preg_replace($orig, $repl, $text); @@ -1122,14 +1122,14 @@ function ConvertOldMarkup ($text, $markup_type = "block") { list ($orig, $repl) = $subs['inline']; $out = ''; //FIXME: - // php crashes here in the 2nd paragraph of OldTextFormattingRules, - // AnciennesR%E8glesDeFormatage and more + // php crashes here in the 2nd paragraph of OldTextFormattingRules, + // AnciennesR%E8glesDeFormatage and more // See http://www.pcre.org/pcre.txt LIMITATIONS while (preg_match($block_re, $text, $m)) { $text = substr($text, strlen($m[0])); list (,$leading_text, $block) = $m; $suffix = "\n"; - + if (strchr(" \t", $block[0])) { // Indented block $prefix = "
\n";
@@ -1145,7 +1145,7 @@ function ConvertOldMarkup ($text, $markup_type = "block") {
                 preg_match('/^([#*;]*)([*#]|;.*?:) */', $block, $m);
                 list (,$ind,$bullet) = $m;
                 $block = substr($block, strlen($m[0]));
-                
+              
                 $indent = str_repeat('     ', strlen($ind));
                 if ($bullet[0] == ';') {
                     //$term = ltrim(substr($bullet, 1));
@@ -1223,10 +1223,10 @@ function expand_tabs($str, $tab_width = 8) {
  * @return string The split name.
  */
 function SplitPagename ($page) {
-    
+  
     if (preg_match("/\s/", $page))
         return $page;           // Already split --- don't split any more.
-    
+  
     // This algorithm is specialized for several languages.
     // (Thanks to Pierrick MEIGNEN)
     // Improvements for other languages welcome.
@@ -1238,11 +1238,11 @@ function SplitPagename ($page) {
         switch ($GLOBALS['LANG']) {
         case 'en':
         case 'it':
-        case 'es': 
+        case 'es':
         case 'de':
             $RE[] = '/([[:lower:]])((?
  *
  * @see __printf
- */ 
+ */
 function __sprintf ($fmt) {
     $args = func_get_args();
     array_shift($args);
@@ -1504,12 +1504,12 @@ function __sprintf ($fmt) {
  * 
  *
  * @see __printf
- */ 
+ */
 function __vsprintf ($fmt, $args) {
     $fmt = gettext($fmt);
     // PHP's sprintf doesn't support variable with specifiers,
     // like sprintf("%*s", 10, "x"); --- so we won't either.
-    
+  
     if (preg_match_all('/(? count($args))
-                trigger_error(sprintf(_("%s: argument index out of range"), 
+                trigger_error(sprintf(_("%s: argument index out of range"),
                                       $argnum), E_USER_WARNING);
             $newargs[] = $args[$argnum - 1];
         }
         $args = $newargs;
     }
-    
+  
     // Not all PHP's have vsprintf, so...
     array_unshift($args, $fmt);
     return call_user_func_array('sprintf', $args);
@@ -1540,7 +1540,7 @@ function __vsprintf ($fmt, $args) {
 function file_mtime ($filename) {
     if ($stat = @stat($filename))
         return $stat[9];
-    else 
+    else
         return false;
 }
 
@@ -1566,15 +1566,15 @@ class fileSet {
             require_once('lib/PageList.php');
             switch (Pagelist::sortby($sortby, 'db')) {
             case 'pagename ASC': break;
-            case 'pagename DESC': 
-                $list = array_reverse($list); 
+            case 'pagename DESC':
+                $list = array_reverse($list);
                 break;
-            case 'mtime ASC': 
-                usort($list,'sort_file_mtime'); 
+            case 'mtime ASC':
+                usort($list,'sort_file_mtime');
                 break;
-            case 'mtime DESC': 
+            case 'mtime DESC':
                 usort($list,'sort_file_mtime');
-                $list = array_reverse($list); 
+                $list = array_reverse($list);
                 break;
             }
         }
@@ -1589,7 +1589,7 @@ class fileSet {
         else {
             if (! $this->_pcre_pattern )
                 $this->_pcre_pattern = glob_to_pcre($this->_pattern);
-            return preg_match('/' . $this->_pcre_pattern . ($this->_case ? '/' : '/i'), 
+            return preg_match('/' . $this->_pcre_pattern . ($this->_case ? '/' : '/i'),
                               $filename);
         }
     }
@@ -1637,12 +1637,12 @@ class ListRegexExpand {
     function ListRegexExpand (&$list, $match, $case_sensitive = true) {
     	$this->match = $match;
     	$this->list = &$list;
-    	$this->case_sensitive = $case_sensitive;	
+    	$this->case_sensitive = $case_sensitive;
         //$this->index = false;
     }
     function listMatchCallback ($item, $key) {
         $quoted = str_replace('/','\/',$item);
-    	if (preg_match('/' . $this->match . ($this->case_sensitive ? '/' : '/i'), 
+    	if (preg_match('/' . $this->match . ($this->case_sensitive ? '/' : '/i'),
                        $quoted)) {
 	    unset($this->list[$this->index]);
             $this->list[] = $item;
@@ -1669,7 +1669,7 @@ function glob_to_pcre ($glob) {
     $glob = str_replace("/", "\\/", $glob);
     // first convert some unescaped expressions to pcre style: . => \.
     $special = '.^$';
-    $re = preg_replace('/([^\xff])?(['.preg_quote($special).'])/', 
+    $re = preg_replace('/([^\xff])?(['.preg_quote($special).'])/',
                        "\\1\xff\\2", $glob);
 
     // * => .*, ? => .
@@ -1683,7 +1683,7 @@ function glob_to_pcre ($glob) {
     // Fixes Bug 1182997
     // .*? handled above, now escape the rest
     //while (strcspn($re, $escape) != strlen($re)) // loop strangely needed
-    $re = preg_replace('/([^\xff])(['.preg_quote($escape, "/").'])/', 
+    $re = preg_replace('/([^\xff])(['.preg_quote($escape, "/").'])/',
                        "\\1\xff\\2", $re);
     // Problem with 'Date/Time' => 'Date\/Time' => 'Date\xff\/Time' => 'Date\/Time'
     // 'plugin/*.php'
@@ -1692,7 +1692,7 @@ function glob_to_pcre ($glob) {
 }
 
 function glob_match ($glob, $against, $case_sensitive = true) {
-    return preg_match('/' . glob_to_pcre($glob) . ($case_sensitive ? '/' : '/i'), 
+    return preg_match('/' . glob_to_pcre($glob) . ($case_sensitive ? '/' : '/i'),
                       $against);
 }
 
@@ -1706,7 +1706,7 @@ function explodeList($input, $allnames, $glob_style = true, $case_sensitive = tr
             $f = $list[$i];
             if (preg_match('/[\?\*]/',$f)) {
             	reset($allnames);
-            	$expand = new ListRegexExpand($list, 
+            	$expand = new ListRegexExpand($list,
                     $glob_style ? glob_to_pcre($f) : $f, $case_sensitive);
             	$expand->expandRegex($i, $allnames);
             }
@@ -1716,7 +1716,7 @@ function explodeList($input, $allnames, $glob_style = true, $case_sensitive = tr
 }
 
 // echo implode(":",explodeList("Test*",array("xx","Test1","Test2")));
-function explodePageList($input, $include_empty=false, $sortby='pagename', 
+function explodePageList($input, $include_empty=false, $sortby='pagename',
 			 $limit='', $exclude='') {
     include_once("lib/PageList.php");
     return PageList::explodePageList($input, $include_empty, $sortby, $limit, $exclude);
@@ -1724,7 +1724,7 @@ function explodePageList($input, $include_empty=false, $sortby='pagename',
 
 // Class introspections
 
-/** 
+/**
  * Determine whether object is of a specified type.
  * In PHP builtin since 4.2.0 as is_a()
  * is_a() deprecated in PHP 5, in favor of instanceof operator
@@ -1732,12 +1732,12 @@ function explodePageList($input, $include_empty=false, $sortby='pagename',
  * @param $object object An object.
  * @param $class string Class name.
  * @return bool True iff $object is a $class
- * or a sub-type of $class. 
+ * or a sub-type of $class.
  */
 function isa ($object, $class) {
-    //if (check_php_version(5)) 
+    //if (check_php_version(5))
     //    return $object instanceof $class;
-    if (!check_php_version(5)) 
+    if (!check_php_version(5))
         return is_a($object, $class);
 
     $lclass = check_php_version(5) ? $class : strtolower($class);
@@ -1774,8 +1774,8 @@ function function_usable($function_name) {
              and ! isset($disabled[strtolower($function_name)])
              );
 }
-    
-    
+  
+  
 /** Hash a value.
  *
  * This is used for generating ETags.
@@ -1784,7 +1784,7 @@ function wikihash ($x) {
     if (is_scalar($x)) {
         return $x;
     }
-    elseif (is_array($x)) {            
+    elseif (is_array($x)) {          
         ksort($x);
         return md5(serialize($x));
     }
@@ -1799,7 +1799,7 @@ function wikihash ($x) {
  * Seed the random number generator.
  *
  * better_srand() ensures the randomizer is seeded only once.
- * 
+ *
  * How random do you want it? See:
  * http://www.php.net/manual/en/function.srand.php
  * http://www.php.net/manual/en/function.mt-srand.php
@@ -1820,7 +1820,7 @@ function rand_ascii($length = 1) {
     for ($i = 1; $i <= $length; $i++) {
         // return only typeable 7 bit ascii, avoid quotes
         if (function_exists('mt_rand'))
-            $s .= chr(mt_rand(40, 126)); 
+            $s .= chr(mt_rand(40, 126));
         else
             // the usually bad glibc srand()
             $s .= chr(rand(40, 126));
@@ -1847,8 +1847,8 @@ function rand_ascii_readable ($length = 6) {
 }
 
 /**
- * Recursively count all non-empty elements 
- * in array of any dimension or mixed - i.e. 
+ * Recursively count all non-empty elements
+ * in array of any dimension or mixed - i.e.
  * array('1' => 2, '2' => array('1' => 3, '2' => 4))
  * See http://www.php.net/manual/en/function.count.php
  */
@@ -1857,7 +1857,7 @@ function count_all($arg) {
     if ($arg) {
         //print_r($arg); //debugging
         $count = 0;
-        // not an array, return 1 (base case) 
+        // not an array, return 1 (base case)
         if(!is_array($arg))
             return 1;
         // else call recursively for all elements $arg
@@ -1927,7 +1927,7 @@ class Alert {
 
         $tokens = $this->_tokens;
         $tokens['BUTTONS'] = $this->_getButtons();
-        
+      
         $request->discardOutput();
         $tmpl = new Template('dialog', $request, $tokens);
         $tmpl->printXML();
@@ -1941,7 +1941,7 @@ class Alert {
         $buttons = $this->_buttons;
         if (!$buttons)
             $buttons = array(_("Okay") => $request->getURLtoSelf());
-        
+      
         global $WikiTheme;
         foreach ($buttons as $label => $url)
             print "$label $url\n";
@@ -2021,7 +2021,7 @@ function isUtf8String( $s ) {
     return preg_match("/^($ptrASCII|$ptr2Octet|$ptr3Octet|$ptr4Octet|$ptr5Octet|$ptr6Octet)*$/s", $s);
 }
 
-/** 
+/**
  * Check for UTF-8 URLs; Internet Explorer produces these if you
  * type non-ASCII chars in the URL bar or follow unescaped links.
  * Requires urldecoded pagename.
@@ -2054,14 +2054,14 @@ function fixTitleEncoding( $s ) {
     return $s;
 }
 
-/** 
+/**
  * MySQL fulltext index doesn't grok utf-8, so we
  * need to fold cases and convert to hex.
  * src: languages/Language.php:stripForSearch() from mediawiki
  */
 /*
 function stripForSearch( $string ) {
-    global $wikiLowerChars; 
+    global $wikiLowerChars;
     // '/(?:[a-z]|\xc3[\x9f-\xbf]|\xc4[\x81\x83\x85\x87])/' => "a-z\xdf-\xf6\xf8-\xff"
     return preg_replace(
                         "/([\\xc0-\\xff][\\x80-\\xbf]*)/e",
@@ -2070,7 +2070,7 @@ function stripForSearch( $string ) {
 }
 */
 
-/** 
+/**
  * Workaround for allow_url_fopen, to get the content of an external URI.
  * It returns the contents in one slurp. Parsers might want to check for allow_url_fopen
  * and use fopen, fread chunkwise. (see lib/XmlParser.php)
@@ -2190,7 +2190,7 @@ function extractSections ($sections, $content, $page, $quiet = false, $sectionhe
             $text = preg_replace("/\\s*^-{4,}\\s*$/m", "", $match[3]);
             if ($sectionhead)
                 $text = $match[1] . $section ."\n". $text;
-            $result .= $text; 
+            $result .= $text;
 
             $mycontent = explode("\n", $match[4]);
             $sections--;
@@ -2220,8 +2220,8 @@ function isExternalReferrer(&$request) {
 function loadPhpExtension($extension) {
     if (!extension_loaded($extension)) {
 	$isWindows = (substr(PHP_OS,0,3) == 'WIN');
-        $soname = ($isWindows ? 'php_' : '') 
-	        . $extension 
+        $soname = ($isWindows ? 'php_' : '')
+	        . $extension
 	        . ($isWindows ? '.dll' : '.so');
         if (!@dl($soname))
             return false;
@@ -2260,8 +2260,8 @@ function array_remove($arr,$value) {
    return array_values(array_diff($arr,array($value)));
 }
 
-/** 
- * Ensure that the script will have another $secs time left. 
+/**
+ * Ensure that the script will have another $secs time left.
  * Works only if safe_mode is off.
  * For example not to timeout on waiting socket connections.
  *   Use the socket timeout as arg.
@@ -2313,7 +2313,7 @@ function getMemoryUsage() {
 	    // Requires a newer cygwin
 	    $memstr = exec("cat /proc/$pid/statm |cut -f1");
 
-	    // if it's native windows use something like this: 
+	    // if it's native windows use something like this:
 	    //   (requires pslist from sysinternals.com, grep, sed and perl)
 	    //$memstr = exec("pslist $pid|grep -A1 Mem|sed 1d|perl -ane\"print \$"."F[5]\"");
         }
@@ -2341,7 +2341,7 @@ function getMemoryUsage() {
 function binary_search($needle, $haystack) {
     $high = count($haystack);
     $low = 0;
-   
+ 
     while (($high - $low) > 1) {
         $probe = floor(($high + $low) / 2);
         if ($haystack[$probe] < $needle) {
@@ -2444,7 +2444,7 @@ function parse_attributes($line) {
     }
 
     $options[$attribute] = $value;
-    
+  
     $line = substr($line, $i+1);
     $line = trim ($line);
     $line = trim ($line, ",");
@@ -2642,12 +2642,11 @@ function strip_accents($text) {
     return utf8_encode($res);
 }
 
-// (c-file-style: "gnu")
 // Local Variables:
 // mode: php
 // tab-width: 8
 // c-basic-offset: 4
 // c-hanging-comment-ender-p: nil
 // indent-tabs-mode: nil
-// End:   
+// End: 
 ?>
diff --git a/lib/upgrade.php b/lib/upgrade.php
index 0b49a5b9d..9734d0b05 100644
--- a/lib/upgrade.php
+++ b/lib/upgrade.php
@@ -23,24 +23,24 @@
 
 /**
  * Upgrade existing WikiDB and config settings after installing a new PhpWiki sofwtare version.
- * Status: almost no queries for verification. 
+ * Status: almost no queries for verification.
  *         simple merge conflict resolution, or Overwrite All.
  *
- * Installation on an existing PhpWiki database needs some 
+ * Installation on an existing PhpWiki database needs some
  * additional worksteps. Each step will require multiple pages.
  *
  * This is the plan:
- *  1. Check for new or changed database schema and update it 
+ *  1. Check for new or changed database schema and update it
  *     according to some predefined upgrade tables. (medium, complete)
- *  2. Check for new or changed (localized) pgsrc/ pages and ask 
- *     for upgrading these. Check timestamps, upgrade silently or 
+ *  2. Check for new or changed (localized) pgsrc/ pages and ask
+ *     for upgrading these. Check timestamps, upgrade silently or
  *     show diffs if existing. Overwrite or merge (easy, complete)
  *  3. Check for new or changed or deprecated index.php/config.ini settings
  *     and help in upgrading these. (for newer changes since 1.3.11, not yet)
  *   3a. Convert old-style index.php into config/config.ini. (easy, not yet)
  *  4. Check for changed plugin invocation arguments. (medium, done)
  *  5. Check for changed theme variables. (hard, not yet)
- *  6. Convert the single-request upgrade to a class-based multi-page 
+ *  6. Convert the single-request upgrade to a class-based multi-page
  *     version. (hard)
 
  * Done: overwrite=1 link on edit conflicts at first occurence "Overwrite all".
@@ -53,7 +53,7 @@ class Upgrade {
 
     function Upgrade (&$request) {
 	$this->request =& $request;
-	$this->dbi =& $request->_dbi; // no reference for dbadmin ? 
+	$this->dbi =& $request->_dbi; // no reference for dbadmin ?
 	$this->phpwiki_version = $this->current_db_version = phpwiki_version();
 	//$this->current_db_version = 1030.13; // should be stored in the db. should be phpwiki_version
 
@@ -120,10 +120,10 @@ class Upgrade {
 	// 1.3.13 before we pull in all missing pages, we rename existing ones
 	$this->_rename_page_helper(_("_AuthInfo"), _("DebugAuthInfo"));
 	// this is in some templates. so we keep the old name
-	//$this->_rename_page_helper($this->dbi, _("DebugInfo"), _("DebugBackendInfo")); 
+	//$this->_rename_page_helper($this->dbi, _("DebugInfo"), _("DebugBackendInfo"));
 	$this->_rename_page_helper(_("_GroupInfo"), _("GroupAuthInfo")); //never officially existed
 	$this->_rename_page_helper("InterWikiKarte", "InterWikiListe"); // german only
- 
+
 	$path = FindFile('pgsrc');
 	$pgsrc = new fileSet($path);
 	// most actionpages have the same name as the plugin
@@ -203,7 +203,7 @@ class Upgrade {
 
     function _rename_to_help_page($pagename) {
 	$newprefix = _("Help") . "/";
-	if (substr($pagename,0,strlen($newprefix)) != $newprefix) return;	
+	if (substr($pagename,0,strlen($newprefix)) != $newprefix) return;
 	$oldname = substr($pagename,strlen($newprefix));
 	$this->_rename_page_helper($oldname, $pagename);
     }
@@ -360,7 +360,7 @@ CREATE TABLE $log_tbl (
 	request_time  char(28),
 	status 	      smallint unsigned,
 	bytes_sent    smallint unsigned,
-        referer       varchar(255), 
+        referer       varchar(255),
 	agent         varchar(255),
 	request_duration float
 )");
@@ -416,7 +416,7 @@ CREATE TABLE $log_tbl (
 
 	if ($this->phpwiki_version >= 1030.12200612 and $this->db_version < 1030.13) {
 	    if ($this->isSQL and preg_match("/(pgsql|postgres)/", $backend_type)) {
-		trigger_error("You need to upgrade to schema/psql-initialize.sql manually!", 
+		trigger_error("You need to upgrade to schema/psql-initialize.sql manually!",
 			      E_USER_WARNING);
 	        // $this->_upgrade_psql_tsearch2();
 	    }
@@ -446,8 +446,8 @@ CREATE TABLE $log_tbl (
 	    extract($this->dbi->_backend->_table_names);
 
 	// 1.3.8 added session.sess_ip
-	if ($this->isSQL and $this->phpwiki_version >= 1030.08 and USE_DB_SESSION 
-	    and isset($this->request->_dbsession)) 
+	if ($this->isSQL and $this->phpwiki_version >= 1030.08 and USE_DB_SESSION
+	    and isset($this->request->_dbsession))
 	{
 	    echo _("Check for new session.sess_ip column")," ... ";
 	    $database = $this->dbi->_backend->database();
@@ -458,7 +458,7 @@ CREATE TABLE $log_tbl (
 		echo _("SKIP");
 	    } elseif (!strstr(strtolower(join(':', $sess_fields)), "sess_ip")) {
 		// TODO: postgres test (should be able to add columns at the end, but not in between)
-		echo "",_("ADDING"),""," ... ";		
+		echo "",_("ADDING"),""," ... ";
 		$this->dbi->genericSqlQuery("ALTER TABLE $session_tbl ADD sess_ip CHAR(15) NOT NULL");
 		$this->dbi->genericSqlQuery("CREATE INDEX sess_date ON $session_tbl (sess_date)");
 	    } else {
@@ -466,14 +466,14 @@ CREATE TABLE $log_tbl (
 	    }
 	    echo "
\n"; if (substr($backend_type,0,5) == 'mysql') { - // upgrade to 4.1.8 destroyed my session table: + // upgrade to 4.1.8 destroyed my session table: // sess_id => varchar(10), sess_data => varchar(5). For others obviously also. echo _("Check for mysql session.sess_id sanity")," ... "; $result = $this->dbi->genericSqlQuery("DESCRIBE $session_tbl"); if (DATABASE_TYPE == 'SQL') { $iter = new WikiDB_backend_PearDB_generic_iter($backend, $result); } elseif (DATABASE_TYPE == 'ADODB') { - $iter = new WikiDB_backend_ADODB_generic_iter($backend, $result, + $iter = new WikiDB_backend_ADODB_generic_iter($backend, $result, array("Field", "Type", "Null", "Key", "Default", "Extra")); } elseif (DATABASE_TYPE == 'PDO') { $iter = new WikiDB_backend_PDO_generic_iter($backend, $result); @@ -553,14 +553,14 @@ CREATE TABLE $log_tbl ( // 1.3.10 mysql requires page.id auto_increment // mysql, mysqli or mysqlt - if ($this->phpwiki_version >= 1030.099 and substr($backend_type,0,5) == 'mysql' - and DATABASE_TYPE != 'PDO') + if ($this->phpwiki_version >= 1030.099 and substr($backend_type,0,5) == 'mysql' + and DATABASE_TYPE != 'PDO') { echo _("Check for mysql page.id auto_increment flag")," ..."; assert(!empty($page_tbl)); $database = $this->dbi->_backend->database(); $fields = mysql_list_fields($database, $page_tbl, $this->dbi->_backend->connection()); - $columns = mysql_num_fields($fields); + $columns = mysql_num_fields($fields); for ($i = 0; $i < $columns; $i++) { if (mysql_field_name($fields, $i) == 'id') { $flags = mysql_field_flags($fields, $i); @@ -574,7 +574,7 @@ CREATE TABLE $log_tbl ( $fields = mysql_list_fields($database, $page_tbl); if (!strstr(strtolower(mysql_field_flags($fields, $i)), "auto_increment")) echo " ", _("FAILED"), "
\n"; - else + else echo _("OK"), "
\n"; } else { echo _("OK"), "
\n"; @@ -590,19 +590,19 @@ CREATE TABLE $log_tbl ( // "select * from page where LOWER(pagename) like '%search%'" does not apply LOWER! // Confirmed for 4.1.0alpha,4.1.3-beta,5.0.0a; not yet tested for 4.1.2alpha, // On windows only, though utf8 would be useful elsewhere also. - // Illegal mix of collations (latin1_bin,IMPLICIT) and + // Illegal mix of collations (latin1_bin,IMPLICIT) and // (utf8_general_ci, COERCIBLE) for operation '=']) if (isWindows() and substr($backend_type,0,5) == 'mysql') { echo _("Check for mysql 4.1.x/5.0.0 binary search on windows problem")," ..."; $mysql_version = $this->dbi->_backend->_serverinfo['version']; - if ($mysql_version < 401.0) { + if ($mysql_version < 401.0) { echo sprintf(_("version %s"), $mysql_version)," ", _("not affected"),"
\n"; } elseif ($mysql_version >= 401.6) { // FIXME: since which version? $row = $this->dbi->_backend->getRow("SHOW CREATE TABLE $page_tbl"); $result = join(" ", $row); - if (strstr(strtolower($result), "character set") - and strstr(strtolower($result), "collate")) + if (strstr(strtolower($result), "character set") + and strstr(strtolower($result), "collate")) { echo _("OK"), "
\n"; } else { @@ -612,7 +612,7 @@ CREATE TABLE $log_tbl ( $this->dbi->genericSqlQuery("ALTER TABLE $page_tbl CHANGE pagename " ."pagename VARCHAR(100) " ."CHARACTER SET '$charset' COLLATE '$charset"."_bin' NOT NULL"); - echo sprintf(_("version %s"), $mysql_version), + echo sprintf(_("version %s"), $mysql_version), " ",_("FIXED"),"", "
\n"; } @@ -622,7 +622,7 @@ CREATE TABLE $log_tbl ( assert(!empty($page_tbl)); $database = $this->dbi->_backend->database(); $fields = mysql_list_fields($database, $page_tbl, $this->dbi->_backend->connection()); - $columns = mysql_num_fields($fields); + $columns = mysql_num_fields($fields); for ($i = 0; $i < $columns; $i++) { if (mysql_field_name($fields, $i) == 'pagename') { $flags = mysql_field_flags($fields, $i); @@ -633,9 +633,9 @@ CREATE TABLE $log_tbl ( // FIXME: on duplicate pagenames this will fail! $this->dbi->genericSqlQuery("ALTER TABLE $page_tbl CHANGE pagename" ." pagename VARCHAR(100) NOT NULL"); - echo sprintf(_("version %s"), $mysql_version), + echo sprintf(_("version %s"), $mysql_version), "",_("FIXED"),"" - ,"
\n"; + ,"
\n"; } } break; @@ -652,7 +652,7 @@ CREATE TABLE $log_tbl ( "s:15:\"\"%'"); $count = 0; while ($row = $res->next()) { - $args = preg_replace("/(s:6:\"passwd\";s:15:\").*(\")/", + $args = preg_replace("/(s:6:\"passwd\";s:15:\").*(\")/", "$1$2", $row["request_args"]); $ts = $row["time_stamp"]; $rh = $row["remote_host"]; @@ -663,7 +663,7 @@ CREATE TABLE $log_tbl ( } if ($count > 0) echo "",_("FIXED"),"", "
\n"; - else + else echo _("OK"),"
\n"; if ($this->phpwiki_version >= 1030.13) { @@ -733,7 +733,7 @@ CREATE TABLE $log_tbl ( $ErrorManager->pushErrorHandler(new WikiMethodCb($this, '_dbpermission_filter')); $this->error_caught = 0; $this->dbi = WikiDB::open($AdminParams); - if (!$this->error_caught) return true; + if (!$this->error_caught) return true; // FAILED: redo our connection with the wikiuser $this->dbi = WikiDB::open($DBParams); $ErrorManager->flushPostponedErrors(); @@ -762,9 +762,9 @@ CREATE TABLE $log_tbl ( if ($this->_try_dbadmin_user(DBADMIN_USER, DBADMIN_PASSWD)) return true; } - // Check if the privileges are enough. Need CREATE and ALTER perms. + // Check if the privileges are enough. Need CREATE and ALTER perms. // And on windows: SELECT FROM mysql, possibly: UPDATE mysql. - $form = HTML::form(array("method" => "post", + $form = HTML::form(array("method" => "post", "action" => $this->request->getPostURL(), "accept-charset"=>$GLOBALS['charset']), HTML::p(_("Upgrade requires database privileges to CREATE and ALTER the phpwiki database."), @@ -786,9 +786,9 @@ CREATE TABLE $log_tbl ( 'size'=>12, 'maxlength'=>256)))), HTML::tr(HTML::td(array('align'=>'center', 'colspan' => 2), - Button("submit:", _("Submit"), 'wikiaction'), + Button("submit:", _("Submit"), 'wikiaction'), HTML::raw(' '), - Button("submit:dbadmin[cancel]", _("Cancel"), + Button("submit:dbadmin[cancel]", _("Cancel"), 'button'))))); $form->printXml(); echo "\n"; @@ -800,7 +800,7 @@ CREATE TABLE $log_tbl ( /** * if page.cached_html does not exists: - * put _cached_html from pagedata into a new seperate blob, + * put _cached_html from pagedata into a new seperate blob, * not into the huge serialized string. * * It is only rarelely needed: for current page only, if-not-modified, @@ -841,7 +841,7 @@ CREATE TABLE $log_tbl ( return $count; } - /** + /** * move _cached_html for all pages from pagedata into a new seperate blob. * decoupled from action=upgrade, so that it can be used by a WikiAdminUtils button also. */ @@ -908,13 +908,13 @@ CREATE TABLE $log_tbl ( function CheckPluginUpdate() { return; - + echo "

",sprintf(_("Check for necessary %s updates"), _("plugin argument")),"

\n"; - + $this->_configUpdates = array(); $this->_configUpdates[] = new UpgradePluginEntry - ($this, array('key' => 'plugin_randompage_numpages', + ($this, array('key' => 'plugin_randompage_numpages', 'fixed_with' => 1012.0, //'header' => _("change RandomPage pages => numpages"), //'notice' =>_("found RandomPage plugin"), @@ -922,7 +922,7 @@ CREATE TABLE $log_tbl ( "/(<\?\s*plugin\s+ RandomPage\s+)pages/", "\\1numpages"))); $this->_configUpdates[] = new UpgradePluginEntry - ($this, array('key' => 'plugin_createtoc_position', + ($this, array('key' => 'plugin_createtoc_position', 'fixed_with' => 1013.0, //'header' => _("change CreateToc align => position"), //'notice' =>_("found CreateToc plugin"), @@ -989,7 +989,7 @@ CREATE TABLE $log_tbl ( @rename($file,"$file.bak"); if (!rename($tmp, $file)) return array(false, sprintf(_("couldn't move %s to %s"), $tmp, $filename)); - return true; + return true; } } else { return array(false, sprintf(_("file %s is not writable"), $filename)); @@ -1000,7 +1000,7 @@ CREATE TABLE $log_tbl ( echo "

",sprintf(_("Check for necessary %s updates"), "config.ini"),"

\n"; $entry = new UpgradeConfigEntry - ($this, array('key' => 'cache_control_none', + ($this, array('key' => 'cache_control_none', 'fixed_with' => 1012.0, 'header' => sprintf(_("Check for %s"),"CACHE_CONTROL = NONE"), 'applicable_args' => 'CACHE_CONTROL', @@ -1008,9 +1008,9 @@ CREATE TABLE $log_tbl ( 'check_args' => array("/^\s*CACHE_CONTROL\s*=\s*NONE/", "CACHE_CONTROL = NO_CACHE"))); $entry->setApplicableCb(new WikiMethodCb($entry, '_applicable_defined_and_empty')); $this->_configUpdates[] = $entry; - + $entry = new UpgradeConfigEntry - ($this, array('key' => 'group_method_none', + ($this, array('key' => 'group_method_none', 'fixed_with' => 1012.0, 'header' => sprintf(_("Check for %s"), "GROUP_METHOD = NONE"), 'applicable_args' => 'GROUP_METHOD', @@ -1020,7 +1020,7 @@ CREATE TABLE $log_tbl ( $this->_configUpdates[] = $entry; $entry = new UpgradeConfigEntry - ($this, array('key' => 'blog_empty_default_prefix', + ($this, array('key' => 'blog_empty_default_prefix', 'fixed_with' => 1013.0, 'header' => sprintf(_("Check for %s"), "BLOG_EMPTY_DEFAULT_PREFIX"), 'applicable_args' => 'BLOG_EMPTY_DEFAULT_PREFIX', @@ -1038,7 +1038,7 @@ CREATE TABLE $log_tbl ( } // class Upgrade -class UpgradeEntry +class UpgradeEntry { /** * Add an upgrade item to be checked. @@ -1058,17 +1058,17 @@ class UpgradeEntry // the wikidb stores the version when we actually fixed that. 'fixed_with' => 'required', 'header' => '', // always printed - 'applicable_cb' => null, // method to check if applicable + 'applicable_cb' => null, // method to check if applicable 'applicable_args' => array(), // might be the config name - 'notice' => '', + 'notice' => '', 'check_cb' => null, // method to apply - 'check_args' => array()) + 'check_args' => array()) as $k => $v) { if (!isset($params[$k])) { // default if ($v == 'required') trigger_error("Required arg $k missing", E_USER_ERROR); else $this->{$k} = $v; - } else { + } else { $this->{$k} = $params[$k]; } } @@ -1083,7 +1083,7 @@ class UpgradeEntry } /* needed ? */ function setApplicableCb($object) { - $this->applicable_cb =& $object; + $this->applicable_cb =& $object; } function _check_if_already_fixed() { // not yet fixed? @@ -1168,12 +1168,12 @@ class UpgradeConfigEntry extends UpgradeEntry { /* This is different */ class UpgradePluginEntry extends UpgradeEntry { - + /** * check all pages for a plugin match */ var $silent_skip = 1; - + function default_method (&$args) { $match = $args[0]; $replace = $args[1]; @@ -1205,7 +1205,7 @@ class UpgradeThemeEntry extends UpgradeEntry { $replace = $args[1]; $template = $args[2]; } - + function fixThemeTemplate($match, $new, $template) { // for all custom themes $ourthemes = explode(":","blog:Crao:default:Hawaiian:MacOSX:MonoBook:Portland:shamino_com:SpaceWiki:wikilens:Wordpress"); @@ -1222,7 +1222,7 @@ class UpgradeThemeEntry extends UpgradeEntry { $do = $this->parent->fixLocalFile($match, $new, template); if (!$do[0]) { $success = false; - $errors .= $do[1]." "; + $errors .= $do[1]." "; echo $do[1]; } } @@ -1239,7 +1239,7 @@ class UpgradeThemeEntry extends UpgradeEntry { /* */ -// TODO: At which step are we? +// TODO: At which step are we? // validate and do it again or go on with next step. /** entry function from lib/main.php @@ -1253,7 +1253,7 @@ function DoUpgrade(&$request) { fmt("Upgrade disabled: user != isAdmin"))); return; } - // TODO: StartLoadDump should turn on implicit_flush. + // TODO: StartLoadDump should turn on implicit_flush. @ini_set("implicit_flush", true); StartLoadDump($request, _("Upgrading this PhpWiki")); $upgrade = new Upgrade($request); @@ -1275,7 +1275,6 @@ function DoUpgrade(&$request) { EndLoadDump($request); } -// For emacs users // Local Variables: // mode: php // tab-width: 8 diff --git a/tests/CompatInfo.php b/tests/CompatInfo.php index 86cb923f1..238547d37 100644 --- a/tests/CompatInfo.php +++ b/tests/CompatInfo.php @@ -8,22 +8,21 @@ * Copyright (C) 2004 Reini Urban * * 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 */ - require_once 'PHP/CompatInfo.php'; @@ -36,8 +35,8 @@ function out_row($row, $header = false) { if (!empty($file) and substr($file,0,3) != '' and $file != 'File') { $row[0] = ''.$file.''; } - foreach ($row as $r) { - echo "<$tag>", empty($r) ? ' ' : "$r", ""; + foreach ($row as $r) { + echo "<$tag>", empty($r) ? ' ' : "$r", ""; } echo "\n"; } @@ -103,7 +102,7 @@ foreach ($r as $key => $info) { $const = array_shift($info['constants']); } out_row(array($file, $info['version'], $ext, $const)); - + if (is_array($info['extensions']) and sizeof($info['extensions']) >= sizeof($info['constants'])) { foreach ($info['extensions'] as $i => $ext) { @@ -153,12 +152,11 @@ if ($debug) { echo "
\n"; } -// (c-file-style: "gnu") // Local Variables: // mode: php // tab-width: 8 // c-basic-offset: 4 // c-hanging-comment-ender-p: nil // indent-tabs-mode: nil -// End: +// End: ?> diff --git a/tests/unit/lib/HtmlParserTest.php b/tests/unit/lib/HtmlParserTest.php index 1516ce7a7..c58221861 100644 --- a/tests/unit/lib/HtmlParserTest.php +++ b/tests/unit/lib/HtmlParserTest.php @@ -20,7 +20,7 @@ class HtmlParserTest extends phpwiki_TestCase { "
" => "----", "
Indent
" => ";:Indent", "nowiki" => "\nnowiki\n", - "
Def
List
" => "; Def : List", + "
Def
List
" => "; Def : List", ); if (USE_GLOBAL_SAX) $parser = new HtmlParser("PhpWiki2"); // will not work! @@ -38,16 +38,14 @@ class HtmlParserTest extends phpwiki_TestCase { $parser->__destruct(); } } - -} +} -// (c-file-style: "gnu") // Local Variables: // mode: php // tab-width: 8 // c-basic-offset: 4 // c-hanging-comment-ender-p: nil // indent-tabs-mode: nil -// End: +// End: ?> diff --git a/tests/unit/lib/InlineParserTest.php b/tests/unit/lib/InlineParserTest.php index c9d7c103b..63df9c3d7 100644 --- a/tests/unit/lib/InlineParserTest.php +++ b/tests/unit/lib/InlineParserTest.php @@ -9,7 +9,7 @@ require_once 'lib/InlineParser.php'; require_once 'PHPUnit.php'; class InlineParserTest extends phpwiki_TestCase { - + function _tests() { $uplink = getUploadDataPath().'/image.jpg'; // last update: 1.3.13 @@ -52,14 +52,14 @@ class InlineParserTest extends phpwiki_TestCase { call_user_func(array(&$this, $this->_name)); } } - + function testNoWikiWords() { $str1 = 'This has no wiki words, and is all text.'; $xmlc1 = TransformInline($str1); $this->assertTrue(isa($xmlc1, 'XmlContent')); $c1 = $xmlc1->getContent(); - $this->assertEquals(1, count($c1)); - $this->assertEquals($str1, $c1[0]); + $this->assertEquals(1, count($c1)); + $this->assertEquals($str1, $c1[0]); } function testWikiWord() { @@ -69,18 +69,18 @@ class InlineParserTest extends phpwiki_TestCase { $this->assertTrue(isa($xml, 'XmlContent')); $c1 = $xml->getContent(); $this->assertEquals(3, count($c1)); - $this->assertTrue(isa($c1[1], 'Cached_WikiLink')); + $this->assertTrue(isa($c1[1], 'Cached_WikiLink')); - $this->assertEquals('This has 1 ', $c1[0]); - $this->assertEquals($ww, $c1[1]->asString()); - $this->assertEquals('.', $c1[2]); + $this->assertEquals('This has 1 ', $c1[0]); + $this->assertEquals($ww, $c1[1]->asString()); + $this->assertEquals('.', $c1[2]); } - + function _testLink($wiki, $expected = null) { if (is_null($expected)) { $ta = $this->_tests(); $expected = $ta[$wiki]; - } + } $xml = TransformInline($wiki); $this->assertTrue(isa($xml, 'XmlContent')); $expectobj = unserialize($expected); @@ -95,12 +95,11 @@ foreach (InlineParserTest::_tests() as $wiki => $expected) { $GLOBALS['suite']->addTest(new InlineParserTest($name)); } -// (c-file-style: "gnu") // Local Variables: // mode: php // tab-width: 8 // c-basic-offset: 4 // c-hanging-comment-ender-p: nil // indent-tabs-mode: nil -// End: +// End: ?> diff --git a/tests/unit/lib/XmlRpcTest.php b/tests/unit/lib/XmlRpcTest.php index d8de9dd54..3e7417f33 100644 --- a/tests/unit/lib/XmlRpcTest.php +++ b/tests/unit/lib/XmlRpcTest.php @@ -49,12 +49,11 @@ class XmlRpcTest extends phpwiki_TestCase { */ } -// (c-file-style: "gnu") // Local Variables: // mode: php // tab-width: 8 // c-basic-offset: 4 // c-hanging-comment-ender-p: nil // indent-tabs-mode: nil -// End: -?> \ No newline at end of file +// End: +?> diff --git a/tests/unit/test.php b/tests/unit/test.php index 39d9e92a5..fce199508 100644 --- a/tests/unit/test.php +++ b/tests/unit/test.php @@ -4,26 +4,26 @@ * $Id$ * * 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 */ /** - * Unit tests for PhpWiki. + * Unit tests for PhpWiki. * - * You must have PEAR's PHPUnit package . + * You must have PEAR's PHPUnit package . * These tests are unrelated to test/maketest.pl, which do not use PHPUnit. * These tests run from the command-line as well as from the browser. * Use the argv (from cli) or tests (from browser) params to run only certain tests. @@ -62,7 +62,7 @@ if (substr(PHP_OS,0,3) == 'WIN') $cur_dir = str_replace("\\","/", $cur_dir); $rootdir = $cur_dir . '/../../'; $ini_sep = substr(PHP_OS,0,3) == 'WIN' ? ';' : ':'; -$include_path = ini_get('include_path') . $ini_sep +$include_path = ini_get('include_path') . $ini_sep . $rootdir . $ini_sep . $rootdir . "lib/pear"; ini_set('include_path', $include_path); define('DEFAULT_LANGUAGE','en'); // don't use browser detection @@ -89,16 +89,16 @@ $database_backends = array( 'ADODB', // same backend as defined in the config.ini DSN // specific backends (need to be setup as db=test_phpwiki) 'PearDB_pgsql', 'PearDB_sqlite', 'PearDB_mysql', - //'PearDB_oci8','PearDB_mssql', - 'ADODB_postgres7', 'ADODB_sqlite', 'ADODB_mysql', - //'ADODB_oci8', 'ADODB_mssql', + //'PearDB_oci8','PearDB_mssql', + 'ADODB_postgres7', 'ADODB_sqlite', 'ADODB_mysql', + //'ADODB_oci8', 'ADODB_mssql', // 'cvs' ); if ((int)substr(phpversion(), 1) >= 5) array_push($database_backends, 'PDO_pqsql', 'PDO_sqlite', 'PDO_mysql'); //'PDO_oci', 'PDO_odbc' -//TODO: convert cvs test +//TODO: convert cvs test // For "cvs" see the seperate tests/unit_test_backend_cvs.php (cvs is experimental) //TODO: read some database values from config.ini, just use the "test_" prefix // "flatfile" testing occurs in "tests/unit/.testbox/flatfile" @@ -124,7 +124,7 @@ function printMemoryUsage($msg = '') { $mem = getMemoryUsage(); if (!$initmem) $initmem = $mem; // old libc on sf.net server doesn't understand "%+4d" - echo sprintf("%8d\t[%s%4d]\t[+%4d]\n", $mem, $mem > $oldmem ? "+" : ($mem == $oldmem ? " " : ""), + echo sprintf("%8d\t[%s%4d]\t[+%4d]\n", $mem, $mem > $oldmem ? "+" : ($mem == $oldmem ? " " : ""), $mem - $oldmem, $mem - $initmem); // TODO: print time flush(); @@ -163,7 +163,7 @@ if (defined('E_STRICT') and (E_ALL & E_STRICT)) // strict php5? else error_reporting(E_ALL); // php4 -// This is too strict, fails on every notice and warning. +// This is too strict, fails on every notice and warning. /* function myErrorHandler$errno, $errstr, $errfile, $errline) { echo "$errfile: $errline: error# $errno: $errstr\n"; @@ -199,7 +199,7 @@ function purge_dir($dir) { } function purge_testbox() { - global $DBParams; + global $DBParams; if (isset($GLOBALS['request'])) { $dbi = $GLOBALS['request']->getDbh(); } @@ -244,8 +244,8 @@ function html_option_form() { global $debug_level, $user_level, $start_debug; $form = HTML(); - $option = HTML::div(array('class' => 'option'), - HTML::span(array('title' => 'doubleclick to (un)select all', 'style'=>'font-weight: bold; padding: 1px; border: 2px outset;','onDblClick'=>'flipAll(\'test[\')'), + $option = HTML::div(array('class' => 'option'), + HTML::span(array('title' => 'doubleclick to (un)select all', 'style'=>'font-weight: bold; padding: 1px; border: 2px outset;','onDblClick'=>'flipAll(\'test[\')'), ' test: '), HTML::br()); $i = 0; @@ -257,8 +257,8 @@ function html_option_form() { } $form->pushContent(HTML::td($option)); - $option = HTML::div(array('class' => 'option'), - HTML::span(array('title' => 'doubleclick to (un)select all', 'style'=>'font-weight: bold; padding: 1px; border: 2px outset;', 'onDblClick'=>'flipAll(\'db[\')'), + $option = HTML::div(array('class' => 'option'), + HTML::span(array('title' => 'doubleclick to (un)select all', 'style'=>'font-weight: bold; padding: 1px; border: 2px outset;', 'onDblClick'=>'flipAll(\'db[\')'), ' db: '), HTML::br()); foreach ($GLOBALS['database_backends'] as $s) { @@ -275,7 +275,7 @@ function html_option_form() { formObj = document.forms[0]; for (var i=0; i < formObj.length; i++) { fldObj = formObj.elements[i]; - if ((fldObj.type == 'checkbox') && (fldObj.name.substring(0,formName.length) == formName)) { + if ((fldObj.type == 'checkbox') && (fldObj.name.substring(0,formName.length) == formName)) { if (isFirstSet == -1) isFirstSet = (fldObj.checked) ? true : false; fldObj.checked = (isFirstSet) ? false : true; @@ -286,7 +286,7 @@ function updateDebugEdit(formObj) { val=0; for (var i=0; i < formObj.length; i++) { fldObj = formObj.elements[i]; - if ((fldObj.type == 'checkbox') && (fldObj.name.substring(0,7) == '_debug[')) { + if ((fldObj.type == 'checkbox') && (fldObj.name.substring(0,7) == '_debug[')) { if (fldObj.checked) val = val + parseInt(fldObj.value); } } @@ -305,7 +305,7 @@ function updateLevelEdit(formObj) { }"); $option = HTML::div(array('class' => 'option'), HTML::span(array('title' => 'doubleclick to (un)select all', 'style'=>'font-weight: bold; padding: 1px; border: 2px outset;', - 'onDblClick'=>'flipAll(\'_debug[\')'), + 'onDblClick'=>'flipAll(\'_debug[\')'), ' debug: '),' ', HTML::input(array('name'=>'debug','id'=>'debug', 'value'=>$debug_level,'size'=>5)), @@ -328,7 +328,7 @@ function updateLevelEdit(formObj) { } $form->pushContent(HTML::td($option)); - $option = HTML::div(array('class' => 'option'), + $option = HTML::div(array('class' => 'option'), HTML::span(array('style'=>'font-weight: bold;'), "level: "), HTML::input(array('name'=>'level','id'=>'level', 'value'=>$user_level,'size'=>5)), @@ -386,7 +386,7 @@ elseif (!empty($HTTP_SERVER_VARS['argv'])) elseif (!ini_get("register_argc_argv")) echo "Could not read cmd args (register_argc_argv=Off?)\n"; // purge the testbox - + $debug_level = 1; //was 9, _DEBUG_VERBOSE | _DEBUG_TRACE //if (defined('E_STRICT')) $debug_level = 5; // add PARSER flag on php5 $user_level = 1; // BOGO (conflicts with RateIt) @@ -417,7 +417,7 @@ if (isset($HTTP_SERVER_VARS['REQUEST_METHOD'])) { } } elseif (!empty($argv) and preg_match("/test\.php$/", $argv[0])) { array_shift($argv); -} +} if (!empty($argv)) { $runtests = array(); $define = array(); @@ -470,7 +470,7 @@ flush(); if (!defined('DEBUG')) define('DEBUG', $debug_level); // override defaults: -if (!defined('RATING_STORAGE')) +if (!defined('RATING_STORAGE')) define('RATING_STORAGE', 'WIKIPAGE'); if (!defined('GROUP_METHOD')) define('GROUP_METHOD', 'NONE'); @@ -495,7 +495,7 @@ ob_end_flush(); if ($debug_level & 1) { //echo "\n"; - echo "PHPWIKI_VERSION=",PHPWIKI_VERSION, + echo "PHPWIKI_VERSION=",PHPWIKI_VERSION, strstr(PHPWIKI_VERSION,"pre") ? strftime(" / %Y%m%d") : "","\n"; if ($debug_level & 9) { // which constants affect memory? @@ -569,7 +569,7 @@ if (isset($HTTP_SERVER_VARS['REQUEST_METHOD'])) { // save and restore all args for each test. class phpwiki_TestCase extends PHPUnit_TestCase { - function setUp() { + function setUp() { global $request, $WikiTheme; include_once("themes/" . THEME . "/themeinfo.php"); $this->_savedargs = $request->_args; @@ -608,7 +608,7 @@ foreach ($run_database_backends as $dbtype) { $DBParams['dsn'] = preg_replace("/^([^:]+):/", substr($dbtype, 4).":", $DBParams['dsn']); echo "dsn: ",$DBParams['dsn'],"\n"; } - // sqlite fix: + // sqlite fix: if (preg_match('/sqlite$/', $dbtype)) { $DBParams['dsn'] = preg_replace("/127\.0\.0\.1/", '', $DBParams['dsn']); echo "dsn: ",$DBParams['dsn'],"\n"; @@ -635,12 +635,12 @@ foreach ($run_database_backends as $dbtype) { $suite = new PHPUnit_TestSuite("phpwiki"); if (file_exists(dirname(__FILE__).'/lib/'.$test.'.php')) require_once dirname(__FILE__).'/lib/'.$test.'.php'; - else + else require_once dirname(__FILE__).'/lib/plugin/'.$test.'.php'; $suite->addTest( new PHPUnit_TestSuite($test) ); - @set_time_limit(240); - $result = PHPUnit::run($suite); + @set_time_limit(240); + $result = PHPUnit::run($suite); echo "ran " . $result->runCount() . " tests, " . $result->failureCount() . " failures.\n"; ob_end_flush(); if ($result->failureCount() > 0) { @@ -661,12 +661,11 @@ foreach ($run_database_backends as $dbtype) { if (isset($HTTP_SERVER_VARS['REQUEST_METHOD'])) echo "\n"; -// (c-file-style: "gnu") // Local Variables: // mode: php // tab-width: 8 // c-basic-offset: 4 // c-hanging-comment-ender-p: nil // indent-tabs-mode: nil -// End: +// End: ?> diff --git a/themes/Crao/themeinfo.php b/themes/Crao/themeinfo.php index 2650fb1bc..1f4ef7e30 100644 --- a/themes/Crao/themeinfo.php +++ b/themes/Crao/themeinfo.php @@ -26,7 +26,7 @@ class WikiTheme_Crao extends WikiTheme { $this->setDefaultCSS('Crao', array('' => 'crao.css', 'print' => '')); - + // This allows one to manually select "Printer" style (when browsing page) // to see what the printer style looks like. //$this->addAlternateCSS(_("Printer"), 'phpwiki-printer.css'); @@ -82,24 +82,22 @@ class WikiTheme_Crao extends WikiTheme { * To suppress times in the "Last edited on" messages, give a * give a second argument of false: */ - //$this->setDateFormat("%B %d, %Y", false); + //$this->setDateFormat("%B %d, %Y", false); $this->setDateFormat("%A %e %B %Y"); // must not contain time //$this->setDateFormat("%x"); // must not contain time $this->setTimeFormat("%H:%M:%S"); //$this->setTimeFormat("%X"); - + } } $WikiTheme = new WikiTheme_Crao('Crao'); -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -// (c-file-style: "gnu") // Local Variables: // mode: php // tab-width: 8 // c-basic-offset: 4 // c-hanging-comment-ender-p: nil // indent-tabs-mode: nil -// End: +// End: ?> diff --git a/themes/Hawaiian/lib/random.php b/themes/Hawaiian/lib/random.php index a05c81d7e..6771725f3 100644 --- a/themes/Hawaiian/lib/random.php +++ b/themes/Hawaiian/lib/random.php @@ -45,14 +45,11 @@ class imageSet extends fileSet { } }; - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -// (c-file-style: "gnu") // Local Variables: // mode: php // tab-width: 8 // c-basic-offset: 4 // c-hanging-comment-ender-p: nil // indent-tabs-mode: nil -// End: -?> \ No newline at end of file +// End: +?> diff --git a/themes/Hawaiian/themeinfo.php b/themes/Hawaiian/themeinfo.php index 137552f10..3ef100f7b 100644 --- a/themes/Hawaiian/themeinfo.php +++ b/themes/Hawaiian/themeinfo.php @@ -92,13 +92,11 @@ class WikiTheme_Hawaiian extends WikiTheme { $WikiTheme = new WikiTheme_Hawaiian('Hawaiian'); -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -// (c-file-style: "gnu") // Local Variables: // mode: php // tab-width: 8 // c-basic-offset: 4 // c-hanging-comment-ender-p: nil // indent-tabs-mode: nil -// End: +// End: ?> diff --git a/themes/MacOSX/lib/RecentChanges.php b/themes/MacOSX/lib/RecentChanges.php index b54ad20bd..903e3a683 100644 --- a/themes/MacOSX/lib/RecentChanges.php +++ b/themes/MacOSX/lib/RecentChanges.php @@ -9,7 +9,7 @@ require_once('lib/plugin/PageHistory.php'); function MacOSX_RC_revision_formatter (&$fmt, &$rev) { $class = 'rc-' . $fmt->importance($rev); - + return HTML::li(array('class' => $class), $fmt->diffLink($rev), ' ', $fmt->pageLink($rev), ' ', @@ -50,13 +50,11 @@ extends _PageHistory_HtmlFormatter } } - -// (c-file-style: "gnu") // Local Variables: // mode: php // tab-width: 8 // c-basic-offset: 4 // c-hanging-comment-ender-p: nil // indent-tabs-mode: nil -// End: +// End: ?> diff --git a/themes/MacOSX/themeinfo.php b/themes/MacOSX/themeinfo.php index 0116f7f18..ee45881da 100644 --- a/themes/MacOSX/themeinfo.php +++ b/themes/MacOSX/themeinfo.php @@ -10,7 +10,7 @@ if (!defined('PHPWIKI_VERSION')) { /** * A PhpWiki theme inspired by the Aqua appearance of Mac OS X. - * + * * The images used with this theme depend on the PNG alpha channel to * blend in with whatever background color or texture is on the page. * When viewed with an older browser, the images may be incorrectly @@ -71,7 +71,7 @@ class WikiTheme_MacOSX extends WikiTheme { else { $default_text = $wikiword; } - + $url = WikiURL($wikiword, array('action' => 'create')); //$link = HTML::span(HTML::a(array('href' => $url), '?')); $button = $this->makeButton('?', $url); @@ -161,13 +161,11 @@ class WikiTheme_MacOSX extends WikiTheme { $WikiTheme = new WikiTheme_MacOSX('MacOSX'); -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -// (c-file-style: "gnu") // Local Variables: // mode: php // tab-width: 8 // c-basic-offset: 4 // c-hanging-comment-ender-p: nil // indent-tabs-mode: nil -// End: +// End: ?> diff --git a/themes/MonoBook/themeinfo.php b/themes/MonoBook/themeinfo.php index 40db5e8ec..015ae8541 100644 --- a/themes/MonoBook/themeinfo.php +++ b/themes/MonoBook/themeinfo.php @@ -16,9 +16,9 @@ if (!defined('PHPWIKI_VERSION')) { * Problems with IE: signin is at the left. * * We don't (yet) support all mediawiki UI options, but we try to. - * Besides that, maybe the mediawiki folks will see how much better phpwiki + * Besides that, maybe the mediawiki folks will see how much better phpwiki * will scale, esp. with a true database, not just mysql. - * Technically phpwiki has about 2-3 years advantage and our plugins + * Technically phpwiki has about 2-3 years advantage and our plugins * cannot destroy the layout. * Anyway, the WikiParser perl module (and our php version) will be able to import * and convert back and forth. @@ -32,7 +32,7 @@ function ActionButton ($action, $label = false, $page_or_rev = false, $options = if (is_array($action)) { $attr = $action; $act = isset($attr['action']) ? $attr['action'] : 'browse'; - } else + } else $act = $action; $class = is_safe_action($act) ? 'named-wiki' : 'wikiadmin'; /* if selected action is current then prepend selected */ @@ -45,15 +45,15 @@ function ActionButton ($action, $label = false, $page_or_rev = false, $options = else $class = $options['class']; } - return HTML::li(array('class' => $class), + return HTML::li(array('class' => $class), $WikiTheme->makeActionButton($action, $label, $page_or_rev, $options)); } -class WikiTheme_MonoBook +class WikiTheme_MonoBook /* extends WikiTheme */ extends WikiTheme_Wikilens { - + /* this adds selected to the class */ function makeActionButton ($action, $label=false, $page_or_rev=false, $options=false) { extract($this->_get_name_and_rev($page_or_rev)); @@ -104,7 +104,7 @@ extends WikiTheme_Wikilens $this->addMoreHeaders(JavaScript('',array('src' => $this->_findData("IEFixes.js")))); $this->addMoreHeaders("\n"); $this->addMoreHeaders(HTML::Raw('')); - } + } $this->addMoreAttr('body', "class-ns-0", HTML::Raw('class="ns-0"')); // CSS file defines fonts, colors and background images for this @@ -134,11 +134,11 @@ extends WikiTheme_Wikilens * is set to false then the "Thank you for editing..." screen will * be omitted. */ - + $this->addImageAlias('signature', "Signature.png"); // Uncomment this next line to disable the signature. $this->addImageAlias('signature', false); - + /* * Link icons. */ @@ -153,7 +153,7 @@ extends WikiTheme_Wikilens //$this->setLinkIcon('*', 'url'); // front or after //$this->setLinkIconAttr('after'); - + //$this->setButtonSeparator("\n | "); /** @@ -164,9 +164,9 @@ extends WikiTheme_Wikilens /** * Layout improvement with dangling links for mostly closed wiki's: - * If false, only users with edit permissions will be presented the + * If false, only users with edit permissions will be presented the * special wikiunknown class with "?" and Tooltip. - * If true (default), any user will see the ?, but will be presented + * If true (default), any user will see the ?, but will be presented * the PrintLoginForm on a click. */ $this->setAnonEditUnknownLinks(false); @@ -186,19 +186,17 @@ extends WikiTheme_Wikilens * To suppress times in the "Last edited on" messages, give a * give a second argument of false: */ - //$this->setDateFormat("%B %d, %Y", false); + //$this->setDateFormat("%B %d, %Y", false); } } $WikiTheme = new WikiTheme_MonoBook('MonoBook'); -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -// (c-file-style: "gnu") // Local Variables: // mode: php // tab-width: 8 // c-basic-offset: 4 // c-hanging-comment-ender-p: nil // indent-tabs-mode: nil -// End: +// End: ?> diff --git a/themes/Portland/lib/RecentChanges.php b/themes/Portland/lib/RecentChanges.php index 6e51b715d..ee334e04b 100644 --- a/themes/Portland/lib/RecentChanges.php +++ b/themes/Portland/lib/RecentChanges.php @@ -62,13 +62,11 @@ extends _PageHistory_HtmlFormatter } } - -// (c-file-style: "gnu") // Local Variables: // mode: php // tab-width: 8 // c-basic-offset: 4 // c-hanging-comment-ender-p: nil // indent-tabs-mode: nil -// End: +// End: ?> diff --git a/themes/Portland/themeinfo.php b/themes/Portland/themeinfo.php index 66ad6f391..cd24c32c5 100644 --- a/themes/Portland/themeinfo.php +++ b/themes/Portland/themeinfo.php @@ -25,7 +25,7 @@ class WikiTheme_Portland extends WikiTheme { else { $default_text = $wikiword; } - + $url = WikiURL($wikiword, array('action' => 'create')); $link = HTML::span(HTML::a(array('href' => $url, 'rel' => 'nofollow'), '?')); @@ -111,14 +111,11 @@ class WikiTheme_Portland extends WikiTheme { $WikiTheme = new WikiTheme_Portland('Portland'); - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -// (c-file-style: "gnu") // Local Variables: // mode: php // tab-width: 8 // c-basic-offset: 4 // c-hanging-comment-ender-p: nil // indent-tabs-mode: nil -// End: +// End: ?> diff --git a/themes/Sidebar/themeinfo.php b/themes/Sidebar/themeinfo.php index dc73f015b..62bbba6e8 100644 --- a/themes/Sidebar/themeinfo.php +++ b/themes/Sidebar/themeinfo.php @@ -73,7 +73,7 @@ class WikiTheme_Sidebar extends WikiTheme_MonoBook { * Callback when a file is uploaded. virusscan, ... * @param string $str * @return bool true for success, false to abort gracefully. - * In case of false, the file is deleted by the caller, but the callback must + * In case of false, the file is deleted by the caller, but the callback must * inform the user why the file was deleted. * Src: * if (!$WikiTheme->CbUpload($request, $file_dir . $userfile_name)) @@ -157,9 +157,9 @@ class WikiTheme_Sidebar extends WikiTheme_MonoBook { //$this->setAutosplitWikiWords(true); /** - * If true (default) show create '?' buttons on not existing pages, even if the + * If true (default) show create '?' buttons on not existing pages, even if the * user is not signed in. - * If false, anon users get no links and it looks cleaner, but then they + * If false, anon users get no links and it looks cleaner, but then they * cannot easily fix missing pages. */ $this->setAnonEditUnknownLinks(false); @@ -177,22 +177,22 @@ class WikiTheme_Sidebar extends WikiTheme_MonoBook { /** * Custom UserPreferences: * A list of name => _UserPreference class pairs. - * Rationale: Certain themes should be able to extend the predefined list + * Rationale: Certain themes should be able to extend the predefined list * of preferences. Display/editing is done in the theme specific userprefs.tmpl * but storage/sanification/update/... must be extended to the Get/SetPreferences methods. * See themes/wikilens/themeinfo.php */ - //$this->customUserPreference(); + //$this->customUserPreference(); /** * Register custom PageList type and define custom PageList classes. - * Rationale: Certain themes should be able to extend the predefined list - * of pagelist types. E.g. certain plugins, like MostPopular might use + * Rationale: Certain themes should be able to extend the predefined list + * of pagelist types. E.g. certain plugins, like MostPopular might use * info=pagename,hits,rating * which displays the rating column whenever the wikilens theme is active. * See themes/wikilens/themeinfo.php */ - //$this->addPageListColumn(); + //$this->addPageListColumn(); } } @@ -209,13 +209,11 @@ if (ENABLE_RATEIT) { $plugin->head(); } -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -// (c-file-style: "gnu") // Local Variables: // mode: php // tab-width: 8 // c-basic-offset: 4 // c-hanging-comment-ender-p: nil // indent-tabs-mode: nil -// End: +// End: ?> diff --git a/themes/SpaceWiki/lib/RecentChanges.php b/themes/SpaceWiki/lib/RecentChanges.php index 9d24a0b90..c7947f0a4 100644 --- a/themes/SpaceWiki/lib/RecentChanges.php +++ b/themes/SpaceWiki/lib/RecentChanges.php @@ -9,7 +9,7 @@ require_once('lib/plugin/PageHistory.php'); function SpaceWiki_RC_revision_formatter (&$fmt, &$rev) { $class = 'rc-' . $fmt->importance($rev); - + return HTML::li(array('class' => $class), $fmt->diffLink($rev), ' ', $fmt->pageLink($rev), ' ', @@ -73,13 +73,11 @@ extends _PageHistory_HtmlFormatter } } - -// (c-file-style: "gnu") // Local Variables: // mode: php // tab-width: 8 // c-basic-offset: 4 // c-hanging-comment-ender-p: nil // indent-tabs-mode: nil -// End: +// End: ?> diff --git a/themes/SpaceWiki/themeinfo.php b/themes/SpaceWiki/themeinfo.php index c76e9bc83..4fbbd4f06 100644 --- a/themes/SpaceWiki/themeinfo.php +++ b/themes/SpaceWiki/themeinfo.php @@ -38,7 +38,7 @@ class WikiTheme_SpaceWiki extends WikiTheme { return false; // use default return '_SpaceWiki_PageHistory_Formatter'; } - + function load() { // CSS file defines fonts, colors and background images for this // style. The companion '*-heavy.css' file isn't defined, it's just @@ -89,14 +89,11 @@ class WikiTheme_SpaceWiki extends WikiTheme { $WikiTheme = new WikiTheme_SpaceWiki('SpaceWiki'); - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -// (c-file-style: "gnu") // Local Variables: // mode: php // tab-width: 8 // c-basic-offset: 4 // c-hanging-comment-ender-p: nil // indent-tabs-mode: nil -// End: +// End: ?> diff --git a/themes/Wordpress/lib/RecentChanges.php b/themes/Wordpress/lib/RecentChanges.php index b4fa48ba4..4d0ea0f01 100644 --- a/themes/Wordpress/lib/RecentChanges.php +++ b/themes/Wordpress/lib/RecentChanges.php @@ -62,13 +62,11 @@ extends _PageHistory_HtmlFormatter } } - -// (c-file-style: "gnu") // Local Variables: // mode: php // tab-width: 8 // c-basic-offset: 4 // c-hanging-comment-ender-p: nil // indent-tabs-mode: nil -// End: +// End: ?> diff --git a/themes/Wordpress/themeinfo.php b/themes/Wordpress/themeinfo.php index 4d0e97480..534abf1fd 100644 --- a/themes/Wordpress/themeinfo.php +++ b/themes/Wordpress/themeinfo.php @@ -9,7 +9,7 @@ if (!defined('PHPWIKI_VERSION')) { // rcs_id('$Id$'); /* - * This file defines an appearance ("theme") of PhpWiki similar to the + * This file defines an appearance ("theme") of PhpWiki similar to the * Wordpress Pattern Repository. * @author: Mike Pickering */ @@ -27,7 +27,7 @@ class WikiTheme_Wordpress extends WikiTheme { else { $default_text = $wikiword; } - + $url = WikiURL($wikiword, array('action' => 'create')); $link = HTML::span(HTML::a(array('href' => $url, 'rel' => 'nofollow'), '?')); @@ -111,14 +111,11 @@ class WikiTheme_Wordpress extends WikiTheme { $WikiTheme = new WikiTheme_Wordpress('Wordpress'); - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -// (c-file-style: "gnu") // Local Variables: // mode: php // tab-width: 8 // c-basic-offset: 4 // c-hanging-comment-ender-p: nil // indent-tabs-mode: nil -// End: +// End: ?> diff --git a/themes/blog/lib/RecentChanges.php b/themes/blog/lib/RecentChanges.php index acf5bfeee..16e9e2328 100644 --- a/themes/blog/lib/RecentChanges.php +++ b/themes/blog/lib/RecentChanges.php @@ -41,12 +41,11 @@ extends _PageHistory_HtmlFormatter } */ -// (c-file-style: "gnu") // Local Variables: // mode: php // tab-width: 8 // c-basic-offset: 4 // c-hanging-comment-ender-p: nil // indent-tabs-mode: nil -// End: +// End: ?> diff --git a/themes/blog/themeinfo.php b/themes/blog/themeinfo.php index 23fa1e11d..c75178943 100644 --- a/themes/blog/themeinfo.php +++ b/themes/blog/themeinfo.php @@ -9,8 +9,8 @@ if (!defined('PHPWIKI_VERSION')) { // rcs_id('$Id$'); /** - * This file defines a blog theme for PhpWiki, - * based on Rui Carmo's excellent http://the.taoofmac.com/space/ + * This file defines a blog theme for PhpWiki, + * based on Rui Carmo's excellent http://the.taoofmac.com/space/ * which is based on the Kubrick theme: http://binarybonsai.com/kubrick/ * The layout was designed and built by Michael Heilemann, * whose blog you will find at http://binarybonsai.com/ @@ -22,21 +22,21 @@ if (!defined('PHPWIKI_VERSION')) { * it I can sing it for you." * * The CSS, XHTML and design is released under GPL: - * http://www.opensource.org/licenses/gpl-license.php + * http://www.opensource.org/licenses/gpl-license.php * - * Default is a one-person (ADMIN_USER) blog (at the BlogHomePage), but + * Default is a one-person (ADMIN_USER) blog (at the BlogHomePage), but * other blogs are also enabled for every authenticated user. * * Actionbar: Edit, Home, About, Archives, News, ..., Info [ Search ] * PageTrail: > .. > .. * Right sidebar boxes: Archives, Syndication, Links, GoogleAds * - * For the livesearch feature (autodropdown of the results while you tip) + * For the livesearch feature (autodropdown of the results while you tip) * you'll have to copy livesearch.js from http://blog.bitflux.ch/wiki/LiveSearch * to themes/default/, change the liveSearchReq.open line to: liveSearchReq.open("GET", liveSearchURI + "?format=livesearch&paging=none&limit=25&s=" + document.forms.searchform.s.value); * and define ENABLE_LIVESEARCH in config.ini to true. - * + * * Better autodropdown's are in consideration: * http://momche.net/publish/article.php?page=acdropdown) * @@ -53,7 +53,7 @@ class WikiTheme_blog extends WikiTheme { $this->calendarInit(true); } - /* overload to load from Sidebar */ + /* overload to load from Sidebar */ function _findFile ($file, $missing_okay=false) { if (file_exists($this->_path . "themes/".$this->_name."/$file")) return "themes/".$this->_name."/$file"; @@ -84,7 +84,7 @@ class WikiTheme_blog extends WikiTheme { return '_blog_RecentChanges_BoxFormatter'; return '_blog_RecentChanges_Formatter'; } - + /* TODO: use the blog summary as label instead of the pagename */ function linkExistingWikiWord($wikiword, $linktext = '', $version = false) { global $request; @@ -104,7 +104,7 @@ class WikiTheme_blog extends WikiTheme { $default_text = $wikiword->shortName; else $default_text = $wikiword; - + if (!empty($linktext)) { $link->pushContent($linktext); $link->setAttr('class', 'named-wiki'); @@ -139,9 +139,9 @@ class WikiTheme_blog extends WikiTheme { $this->setAutosplitWikiWords(false); /** - * If true (default) show create '?' buttons on not existing pages, even if the + * If true (default) show create '?' buttons on not existing pages, even if the * user is not signed in. - * If false, anon users get no links and it looks cleaner, but then they + * If false, anon users get no links and it looks cleaner, but then they * cannot easily fix missing pages. */ $this->setAnonEditUnknownLinks(false); @@ -163,14 +163,11 @@ class WikiTheme_blog extends WikiTheme { $WikiTheme = new WikiTheme_blog('blog'); define("PAGETRAIL_ARROW", " » "); - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -// (c-file-style: "gnu") // Local Variables: // mode: php // tab-width: 8 // c-basic-offset: 4 // c-hanging-comment-ender-p: nil // indent-tabs-mode: nil -// End: +// End: ?> diff --git a/themes/default/themeinfo.php b/themes/default/themeinfo.php index d99880bf0..e34f553ed 100644 --- a/themes/default/themeinfo.php +++ b/themes/default/themeinfo.php @@ -16,13 +16,11 @@ require_once('lib/WikiTheme.php'); $WikiTheme = new WikiTheme('default'); -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -// (c-file-style: "gnu") // Local Variables: // mode: php // tab-width: 8 // c-basic-offset: 4 // c-hanging-comment-ender-p: nil // indent-tabs-mode: nil -// End: +// End: ?> diff --git a/themes/gforge/themeinfo.php b/themes/gforge/themeinfo.php index 6d6ed42e1..4fcc2f27e 100644 --- a/themes/gforge/themeinfo.php +++ b/themes/gforge/themeinfo.php @@ -33,7 +33,7 @@ class WikiTheme_gforge extends WikiTheme_Wikilens { } $HTML->header(array('title'=> $group_public_name.': '.htmlspecialchars($pagename), - 'group' => $group_id, + 'group' => $group_id, 'toptab' => 'wiki', 'submenu' => $submenu->asXML() ) @@ -150,8 +150,6 @@ class WikiTheme_gforge extends WikiTheme_Wikilens { $WikiTheme = new WikiTheme_gforge('gforge'); -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -// (c-file-style: "gnu") // Local Variables: // mode: php // tab-width: 8 diff --git a/themes/shamino_com/themeinfo.php b/themes/shamino_com/themeinfo.php index 599163c15..f3650e482 100644 --- a/themes/shamino_com/themeinfo.php +++ b/themes/shamino_com/themeinfo.php @@ -11,8 +11,8 @@ if (!defined('PHPWIKI_VERSION')) { * A minimalistic design by walter rafelsberger * See http://www.shamino.com/wiki/ * - * Tiny actionbar: PageInfo, Edit and - * all other Actionbars buttons in info.tmpl, + * Tiny actionbar: PageInfo, Edit and + * all other Actionbars buttons in info.tmpl, * Signin implictly after Edit. * tiny navbar: without buttons, just links * no logo @@ -98,9 +98,9 @@ class WikiTheme_shamino_com extends WikiTheme { /** * Layout improvement with dangling links for mostly closed wiki's: - * If false, only users with edit permissions will be presented the + * If false, only users with edit permissions will be presented the * special wikiunknown class with "?" and Tooltip. - * If true (default), any user will see the ?, but will be presented + * If true (default), any user will see the ?, but will be presented * the PrintLoginForm on a click. */ $this->setAnonEditUnknownLinks(false); @@ -120,20 +120,17 @@ class WikiTheme_shamino_com extends WikiTheme { * To suppress times in the "Last edited on" messages, give a * give a second argument of false: */ - //$this->setDateFormat("%B %d, %Y", false); + //$this->setDateFormat("%B %d, %Y", false); } } $WikiTheme = new WikiTheme_shamino_com('shamino_com'); - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -// (c-file-style: "gnu") // Local Variables: // mode: php // tab-width: 8 // c-basic-offset: 4 // c-hanging-comment-ender-p: nil // indent-tabs-mode: nil -// End: +// End: ?> diff --git a/themes/wikilens/themeinfo.php b/themes/wikilens/themeinfo.php index 96e50e82b..f38f39381 100644 --- a/themes/wikilens/themeinfo.php +++ b/themes/wikilens/themeinfo.php @@ -70,9 +70,9 @@ class WikiTheme_Wikilens extends WikiTheme { /** * Layout improvement with dangling links for mostly closed wiki's: - * If false, only users with edit permissions will be presented the + * If false, only users with edit permissions will be presented the * special wikiunknown class with "?" and Tooltip. - * If true (default), any user will see the ?, but will be presented + * If true (default), any user will see the ?, but will be presented * the PrintLoginForm on a click. */ $this->setAnonEditUnknownLinks(false); @@ -92,7 +92,7 @@ class WikiTheme_Wikilens extends WikiTheme { * To suppress times in the "Last edited on" messages, give a * give a second argument of false: */ - //$this->setDateFormat("%B %d, %Y", false); + //$this->setDateFormat("%B %d, %Y", false); } } @@ -101,13 +101,11 @@ $WikiTheme = new WikiTheme_Wikilens('wikilens'); require_once("lib/wikilens/CustomPrefs.php"); require_once("lib/wikilens/PageListColumns.php"); -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -// (c-file-style: "gnu") // Local Variables: // mode: php // tab-width: 8 // c-basic-offset: 4 // c-hanging-comment-ender-p: nil // indent-tabs-mode: nil -// End: +// End: ?> -- 2.45.0