From: <var...@us...> - 2021-08-17 16:44:59
|
Revision: 10526 http://sourceforge.net/p/phpwiki/code/10526 Author: vargenau Date: 2021-08-17 16:44:58 +0000 (Tue, 17 Aug 2021) Log Message: ----------- Remove "Optimizing database" E_USER_NOTICE Modified Paths: -------------- trunk/lib/WikiDB.php trunk/lib/main.php Modified: trunk/lib/WikiDB.php =================================================================== --- trunk/lib/WikiDB.php 2021-08-17 16:43:43 UTC (rev 10525) +++ trunk/lib/WikiDB.php 2021-08-17 16:44:58 UTC (rev 10526) @@ -1086,11 +1086,7 @@ or (DATABASE_OPTIMISE_FREQUENCY > 0 and (time() % DATABASE_OPTIMISE_FREQUENCY == 0)) ) { - if ($backend->optimize()) { - if ((int)DEBUG) { - trigger_error(_("Optimizing database"), E_USER_NOTICE); - } - } + $backend->optimize(); } /* Generate notification emails? */ Modified: trunk/lib/main.php =================================================================== --- trunk/lib/main.php 2021-08-17 16:43:43 UTC (rev 10525) +++ trunk/lib/main.php 2021-08-17 16:44:58 UTC (rev 10526) @@ -102,11 +102,7 @@ or (DATABASE_OPTIMISE_FREQUENCY > 0 and (time() % DATABASE_OPTIMISE_FREQUENCY == 0)) ) { - if ($this->_dbi->_backend->optimize()) { - if ((int)DEBUG) { - trigger_error(_("Optimizing database"), E_USER_NOTICE); - } - } + $this->_dbi->_backend->optimize(); } // Restore auth state. This doesn't check for proper authorization! This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <var...@us...> - 2021-09-17 13:29:42
|
Revision: 10565 http://sourceforge.net/p/phpwiki/code/10565 Author: vargenau Date: 2021-09-17 13:29:39 +0000 (Fri, 17 Sep 2021) Log Message: ----------- Windows 95 and Mac OS classic are dead, we use "/" as separator Modified Paths: -------------- trunk/lib/FileFinder.php trunk/lib/IniConfig.php trunk/lib/loadsave.php trunk/lib/stdlib.php trunk/lib/upgrade.php Modified: trunk/lib/FileFinder.php =================================================================== --- trunk/lib/FileFinder.php 2021-09-17 13:25:45 UTC (rev 10564) +++ trunk/lib/FileFinder.php 2021-09-17 13:29:39 UTC (rev 10565) @@ -37,14 +37,13 @@ */ class FileFinder { - public $_pathsep, $_path; + public $_path; /** - * @param $path array A list of directories in which to search for files. + * @param array $path A list of directories in which to search for files. */ function __construct($path = array()) { - $this->_pathsep = $this->_get_syspath_separator(); if (!isset($this->_path) and $path === false) $path = $this->_get_include_path(); $this->_path = $path; @@ -53,9 +52,9 @@ /** * Find file. * - * @param $file string File to search for. + * @param string $file File to search for. * @param bool $missing_okay - * @return string The filename (including path), if found, otherwise false. + * @return string|bool The filename (including path), if found, otherwise false. */ public function findFile($file, $missing_okay = false) { @@ -63,7 +62,7 @@ if (file_exists($file)) return $file; } elseif (($dir = $this->_search_path($file))) { - return $dir . $this->_use_path_separator($dir) . $file; + return $dir . '/' . $file; } return $missing_okay ? false : $this->_not_found($file); } @@ -71,42 +70,37 @@ /** * Unify used pathsep character. * Accepts array of paths also. - * This might not work on Windows95 or FAT volumes. (not tested) * - * @param string $path - * @return array|string + * @param string|array $path + * @return string|array */ public function slashifyPath($path) { - return $this->forcePathSlashes($path, $this->_pathsep); + return $this->forcePathSlashes($path); } /** * Force using '/' as path separator. * - * @param string $path - * @param string $sep - * @return array|string + * @param string|array $path + * @return string|array */ - public function forcePathSlashes($path, $sep = '/') + public function forcePathSlashes($path) { if (is_array($path)) { $result = array(); foreach ($path as $dir) { - $result[] = $this->forcePathSlashes($dir, $sep); + $result[] = $this->forcePathSlashes($dir); } return $result; } else { - if (isWindows() or $this->_isOtherPathsep()) { - if (isWindows()) $from = "\\"; - else $from = "\\"; + if (isWindows()) { + $from = "\\"; // PHP is stupid enough to use \\ instead of \ - if (isWindows()) { - if (substr($path, 0, 2) != '\\\\') - $path = str_replace('\\\\', '\\', $path); - else // UNC paths - $path = '\\\\' . str_replace('\\\\', '\\', substr($path, 2)); - } + if (substr($path, 0, 2) != '\\\\') + $path = str_replace('\\\\', '\\', $path); + else // UNC paths + $path = '\\\\' . str_replace('\\\\', '\\', substr($path, 2)); return strtr($path, $from, $sep); } else return $path; @@ -113,54 +107,10 @@ } } - private function _isOtherPathsep() - { - return $this->_pathsep != '/'; - } - /** - * The system-dependent path-separator character. - * UNIX,WindowsNT,MacOSX: / - * Windows95: \ - * Mac: : - * - * @return string path_separator. - */ - public function _get_syspath_separator() - { - if (!empty($this->_pathsep)) return $this->_pathsep; - elseif (isWindowsNT()) return "/"; // we can safely use '/' - elseif (isWindows()) return "\\"; // FAT might use '\' - // VMS or LispM is really weird, we ignore it. - else return '/'; - } - - /** - * The path-separator character of the given path. - * Windows accepts "/" also, but gets confused with mixed path_separators, - * e.g "C:\Apache\phpwiki/locale/button" - * > dir "C:\Apache\phpwiki/locale/button" => - * Parameterformat nicht korrekt - "locale" - * So if there's any '\' in the path, either fix them to '/' (not in Win95 or FAT?) - * or use '\' for ours. - * - * @param string $path - * @return string path_separator. - */ - public function _use_path_separator($path) - { - if (isWindows95()) { - if (empty($path)) return "\\"; - else return (strchr($path, "\\")) ? "\\" : '/'; - } else { - return $this->_get_syspath_separator(); - } - } - - /** * Determine if path is absolute. * - * @param $path string Path. + * @param string $path Path. * @return bool True if path is absolute. */ public function _is_abs($path) @@ -192,7 +142,7 @@ /** * Report a "file not found" error. * - * @param $file string Name of missing file. + * @param string $file Name of missing file. * @return bool false. */ private function _not_found($file) @@ -204,20 +154,13 @@ /** * Search our path for a file. * - * @param $file string File to find. - * @return string Directory which contains $file, or false. - * [5x,44ms] + * @param string $file string File to find. + * @return string|bool Directory which contains $file, or false. */ private function _search_path($file) { foreach ($this->_path as $dir) { - // ensure we use the same pathsep - if ($this->_isOtherPathsep()) { - $dir = $this->slashifyPath($dir); - $file = $this->slashifyPath($file); - if (file_exists($dir . $this->_pathsep . $file)) - return $dir; - } elseif (@file_exists($dir . $this->_pathsep . $file)) + if (@file_exists($dir . '/' . $file)) return $dir; } return false; @@ -258,7 +201,7 @@ * The directory is appended only if it is not already listed in * the include_path. * - * @param $dir string Directory to add. + * @param string $dir Directory to add. */ public function _append_to_include_path($dir) { @@ -286,7 +229,7 @@ * * The directory is prepended, and removed from the tail if already existing. * - * @param $dir string Directory to add. + * @param string $dir Directory to add. */ public function _prepend_to_include_path($dir) { @@ -300,10 +243,14 @@ @ini_set('include_path', $GLOBALS['INCLUDE_PATH']); } - // Return all the possible shortened locale specifiers for the given locale. - // Most specific first. - // de_DE.iso8859-1@euro => de_DE.iso8859-1, de_DE, de - // This code might needed somewhere else also. + /** + * Return all the possible shortened locale specifiers for the given locale. + * Most specific first. + * de_DE.iso8859-1@euro => de_DE.iso8859-1, de_DE, de + * This code might needed somewhere else also. + * + * @param string $lang Locale string + */ function locale_versions($lang) { // Try less specific versions of the locale @@ -357,7 +304,6 @@ { function __construct() { - $this->_pathsep = $this->_get_syspath_separator(); $include_path = $this->_get_include_path(); $path = array(); @@ -393,7 +339,6 @@ function __construct() { global $WikiTheme; - $this->_pathsep = $this->_get_syspath_separator(); $include_path = $this->_get_include_path(); $path = array(); @@ -476,9 +421,8 @@ if (defined("PHPWIKI_DIR")) $wikidir = PHPWIKI_DIR; else $wikidir = preg_replace('/.lib$/', '', dirname(__FILE__)); $wikidir = $finder->_strip_last_pathchar($wikidir); - $pathsep = $finder->_use_path_separator($wikidir); + $pathsep = '/'; return $finder->slashifyPath($wikidir . $pathsep . $file); - // return PHPWIKI_DIR . "/" . $file; } } @@ -509,24 +453,3 @@ if (isset($win)) return $win; return (substr(PHP_OS, 0, 3) == 'WIN'); } - -function isWindows95() -{ - static $win95; - if (isset($win95)) return $win95; - $win95 = isWindows() and !isWindowsNT(); - return $win95; -} - -function isWindowsNT() -{ - static $winnt; - if (isset($winnt)) return $winnt; - // FIXME: Do this using PHP_OS instead of php_uname(). - // $winnt = (PHP_OS == "WINNT"); // example from https://www.php.net/manual/en/ref.readline.php - if (function_usable('php_uname')) - $winnt = preg_match('/^Windows NT/', php_uname()); - else - $winnt = false; // FIXME: punt. - return $winnt; -} Modified: trunk/lib/IniConfig.php =================================================================== --- trunk/lib/IniConfig.php 2021-09-17 13:25:45 UTC (rev 10564) +++ trunk/lib/IniConfig.php 2021-09-17 13:29:39 UTC (rev 10565) @@ -120,7 +120,6 @@ // Optionally check config/config.php dump for faster startup $dump = substr($file, 0, -3) . "php"; - if (isWindows()) $dump = str_replace("/", "\\", $dump); if (file_exists($dump) and is_readable($dump) and filesize($dump) > 0 and sort_file_mtime($dump, $file) < 0) { @include($dump) or die("Error including " . $dump); if (function_exists('wiki_configrestore') and (wiki_configrestore() === 'noerr')) { @@ -862,8 +861,6 @@ // then bindtextdomain() fails, but after chdir to the correct path it will work okay. // 2. But the weird error "Undefined variable: bindtextdomain" is generated then. $bindtextdomain_path = findFile("locale", false, true); - if (isWindows()) - $bindtextdomain_path = str_replace("/", "\\", $bindtextdomain_path); $bindtextdomain_real = @bindtextdomain("phpwiki", $bindtextdomain_path); if (realpath($bindtextdomain_real) != realpath($bindtextdomain_path)) { // this will happen with virtual_paths. chdir and try again. @@ -876,7 +873,7 @@ if ($LANG != 'en') textdomain("phpwiki"); if ($chback) { // change back - chdir($bindtextdomain_real . (isWindows() ? "\\.." : "/..")); + chdir($bindtextdomain_real . "/.."); } } @@ -1011,8 +1008,6 @@ $SCRIPT_FILENAME = @$_ENV['SCRIPT_FILENAME']; if (!isset($SCRIPT_FILENAME)) $SCRIPT_FILENAME = dirname(__FILE__ . '/../') . '/index.php'; - if (isWindows()) - $SCRIPT_FILENAME = str_replace('\\\\', '\\', strtr($SCRIPT_FILENAME, '/', '\\')); define('SCRIPT_FILENAME', $SCRIPT_FILENAME); // Get remote host name, if Apache hasn't done it for us Modified: trunk/lib/loadsave.php =================================================================== --- trunk/lib/loadsave.php 2021-09-17 13:25:45 UTC (rev 10564) +++ trunk/lib/loadsave.php 2021-09-17 13:29:39 UTC (rev 10565) @@ -601,8 +601,6 @@ $request_args = $request->args; $timeout = (!$request->getArg('start_debug')) ? 60 : 240; if ($directory) { - if (isWindows()) - $directory = str_replace("\\", "/", $directory); // no Win95 support. if (!is_dir("$directory/images")) mkdir("$directory/images"); } @@ -661,7 +659,7 @@ if ($directory) mkdir_p($directory . "/" . $dirname); // Fails with "XX / YY", "XX" is created, "XX / YY" cannot be written - // if (isWindows()) // interesting Windows bug: cannot mkdir "bla " + // interesting Windows bug: cannot mkdir "bla " // Since dumps needs to be copied, we have to disallow this for all platforms. $filename = preg_replace("/ \//", "/", $filename); $relative_base = "../"; @@ -1565,10 +1563,10 @@ $epage = urlencode($page); if (!$dbi->isWikiPage($page)) { // translated version provided? - if ($lf = findLocalizedFile($pgsrc . $finder->_pathsep . $epage, 1)) { + if ($lf = findLocalizedFile($pgsrc . '/' . $epage, 1)) { LoadAny($request, $lf); } else { // load english version of required action page - LoadAny($request, findFile(DEFAULT_WIKI_PGSRC . $finder->_pathsep . urlencode($f))); + LoadAny($request, findFile(DEFAULT_WIKI_PGSRC . '/' . urlencode($f))); $page = $f; } } Modified: trunk/lib/stdlib.php =================================================================== --- trunk/lib/stdlib.php 2021-09-17 13:25:45 UTC (rev 10564) +++ trunk/lib/stdlib.php 2021-09-17 13:29:39 UTC (rev 10565) @@ -1385,7 +1385,6 @@ $this->_pcre_pattern = glob_to_pcre($this->_pattern); } $this->_case = !isWindows(); - $this->_pathsep = '/'; if (empty($directory) or !file_exists($directory) or !is_dir($directory)) { return; // early return @@ -1397,7 +1396,7 @@ } while ($filename = readdir($dir_handle)) { - if ($filename[0] == '.' || filetype($dir . $this->_pathsep . $filename) != 'file') + if ($filename[0] == '.' || filetype($dir . '/' . $filename) != 'file') continue; if ($this->_filenameSelector($filename)) { array_push($this->_fileList, "$filename"); Modified: trunk/lib/upgrade.php =================================================================== --- trunk/lib/upgrade.php 2021-09-17 13:25:45 UTC (rev 10564) +++ trunk/lib/upgrade.php 2021-09-17 13:29:39 UTC (rev 10565) @@ -237,14 +237,11 @@ if (is_writable($filename)) { $in = fopen($filename, "rb"); $out = fopen($tmp = tempnam(getUploadFilePath(), "cfg"), "wb"); - if (isWindows()) - $tmp = str_replace("/", "\\", $tmp); // Detect the existing linesep at first line. fgets strips it even if 'rb'. // Before we simply assumed \r\n on Windows local files. $s = fread($in, 1024); rewind($in); $linesep = (substr_count($s, "\r\n") > substr_count($s, "\n")) ? "\r\n" : "\n"; - //$linesep = isWindows() ? "\r\n" : "\n"; while ($s = fgets($in)) { // =>php-5.0.1 can fill count //$new = preg_replace($match, $replace, $s, -1, $count); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <var...@us...> - 2021-09-17 16:35:53
|
Revision: 10571 http://sourceforge.net/p/phpwiki/code/10571 Author: vargenau Date: 2021-09-17 16:35:51 +0000 (Fri, 17 Sep 2021) Log Message: ----------- No break needed after return Modified Paths: -------------- trunk/lib/WikiGroup.php trunk/lib/plugin/FileInfo.php Modified: trunk/lib/WikiGroup.php =================================================================== --- trunk/lib/WikiGroup.php 2021-09-17 16:25:37 UTC (rev 10570) +++ trunk/lib/WikiGroup.php 2021-09-17 16:35:51 UTC (rev 10571) @@ -112,10 +112,8 @@ switch (GROUP_METHOD) { case "NONE": return new GroupNone($not_current); - break; case "WIKIPAGE": return new GroupWikiPage($not_current); - break; case "DB": if ($GLOBALS['DBParams']['dbtype'] == 'SQL') { return new GroupDb_PearDB($not_current); @@ -127,10 +125,8 @@ break; case "FILE": return new GroupFile($not_current); - break; case "LDAP": return new GroupLDAP($not_current); - break; default: trigger_error(_("No or unsupported GROUP_METHOD defined"), E_USER_WARNING); return new WikiGroup($not_current); Modified: trunk/lib/plugin/FileInfo.php =================================================================== --- trunk/lib/plugin/FileInfo.php 2021-09-17 16:25:37 UTC (rev 10570) +++ trunk/lib/plugin/FileInfo.php 2021-09-17 16:35:51 UTC (rev 10571) @@ -161,7 +161,6 @@ } else { return HTML::raw(''); } - break; } } chdir($dir); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <var...@us...> - 2021-09-20 08:23:23
|
Revision: 10573 http://sourceforge.net/p/phpwiki/code/10573 Author: vargenau Date: 2021-09-20 08:23:20 +0000 (Mon, 20 Sep 2021) Log Message: ----------- Remove useless local variable Modified Paths: -------------- trunk/lib/BlockParser.php trunk/lib/HttpClient.php trunk/lib/PageList.php trunk/lib/editpage.php trunk/lib/loadsave.php trunk/lib/plugin/BackLinks.php trunk/lib/plugin/Diff.php trunk/lib/plugin/IncludePage.php trunk/lib/plugin/LinkSearch.php trunk/lib/plugin/ListPages.php trunk/lib/plugin/ListSubpages.php trunk/lib/plugin/RawHtml.php trunk/lib/plugin/SemanticSearchAdvanced.php trunk/lib/plugin/SystemInfo.php trunk/lib/plugin/UriResolver.php trunk/lib/plugin/VisualWiki.php trunk/lib/plugin/WikiAdminSetAclSimple.php trunk/lib/stdlib.php Modified: trunk/lib/BlockParser.php =================================================================== --- trunk/lib/BlockParser.php 2021-09-20 07:56:53 UTC (rev 10572) +++ trunk/lib/BlockParser.php 2021-09-20 08:23:20 UTC (rev 10573) @@ -1423,9 +1423,7 @@ } // Expand leading tabs. $text = expand_tabs($text); - $output = new WikiText($text); - - return $output; + return new WikiText($text); } /** Modified: trunk/lib/HttpClient.php =================================================================== --- trunk/lib/HttpClient.php 2021-09-20 07:56:53 UTC (rev 10572) +++ trunk/lib/HttpClient.php 2021-09-20 08:23:20 UTC (rev 10573) @@ -295,8 +295,7 @@ $headers[] = 'Content-Type: ' . $ContentType; $headers[] = 'Content-Length: ' . strlen($this->postdata); } - $request = implode("\r\n", $headers) . "\r\n\r\n" . $this->postdata; - return $request; + return implode("\r\n", $headers) . "\r\n\r\n" . $this->postdata; } function getStatus() Modified: trunk/lib/PageList.php =================================================================== --- trunk/lib/PageList.php 2021-09-20 07:56:53 UTC (rev 10572) +++ trunk/lib/PageList.php 2021-09-20 08:23:20 UTC (rev 10573) @@ -1091,8 +1091,7 @@ return $order . $column; } elseif ($action == 'check') { // show icon? //if specified via arg or if clicked - $show = (!empty($this->_sortby[$column]) or $this->sortby($column, 'clicked')); - return $show; + return (!empty($this->_sortby[$column]) or $this->sortby($column, 'clicked')); } elseif ($action == 'clicked') { // flip sort order? global $request; $arg = $request->getArg('sortby'); Modified: trunk/lib/editpage.php =================================================================== --- trunk/lib/editpage.php 2021-09-20 07:56:53 UTC (rev 10572) +++ trunk/lib/editpage.php 2021-09-20 08:23:20 UTC (rev 10573) @@ -841,7 +841,7 @@ } if (!$categories) return ''; // Ensure this to be inserted at the very end. Hence we added the id to the function. - $more_buttons = HTML::img(array('class' => "toolbar", + return HTML::img(array('class' => "toolbar", 'id' => 'tb-categories', 'src' => $WikiTheme->getImageURL("ed_category.png"), 'title' => _("Insert Categories"), @@ -851,7 +851,6 @@ . "',[" . join(",", $categories) . "],'" . _("Insert") . "','" . _("Close") . "','tb-categories')")); - return $more_buttons; } return ''; } @@ -891,7 +890,7 @@ } } $plugin_js = substr($plugin_js, 1); - $more_buttons = HTML::img(array('class' => "toolbar", + return HTML::img(array('class' => "toolbar", 'id' => 'tb-plugins', 'src' => $WikiTheme->getImageURL("ed_plugins.png"), 'title' => _("Insert Plugin"), @@ -901,7 +900,6 @@ . "',[" . $plugin_js . "],'" . _("Insert") . "','" . _("Close") . "','tb-plugins')")); - return $more_buttons; } return ''; } @@ -1270,10 +1268,9 @@ protected function getConflictMessage($unresolved = false) { - $message = HTML(HTML::p(fmt("Some of the changes could not automatically be combined. Please look for sections beginning with “%s”, and ending with “%s”. You will need to edit those sections by hand before you click Save.", + return HTML(HTML::p(fmt("Some of the changes could not automatically be combined. Please look for sections beginning with “%s”, and ending with “%s”. You will need to edit those sections by hand before you click Save.", "<<<<<<<", "======="), HTML::p(_("Please check it through before saving.")))); - return $message; } } Modified: trunk/lib/loadsave.php =================================================================== --- trunk/lib/loadsave.php 2021-09-20 07:56:53 UTC (rev 10572) +++ trunk/lib/loadsave.php 2021-09-20 08:23:20 UTC (rev 10573) @@ -1165,8 +1165,7 @@ $fd = fopen($mapfile, "rb"); $data = fread($fd, filesize($mapfile)); fclose($fd); - $content = $content . "\n<verbatim>\n$data</verbatim>\n"; - return $content; + return $content . "\n<verbatim>\n$data</verbatim>\n"; } function ParseSerializedPage($text, $default_pagename, $user) Modified: trunk/lib/plugin/BackLinks.php =================================================================== --- trunk/lib/plugin/BackLinks.php 2021-09-20 07:56:53 UTC (rev 10572) +++ trunk/lib/plugin/BackLinks.php 2021-09-20 08:23:20 UTC (rev 10573) @@ -218,7 +218,6 @@ function _getValue($page_handle, $revision_handle) { $iter = $page_handle->getPageLinks(); - $count = $iter->count(); - return $count; + return $iter->count(); } } Modified: trunk/lib/plugin/Diff.php =================================================================== --- trunk/lib/plugin/Diff.php 2021-09-20 07:56:53 UTC (rev 10572) +++ trunk/lib/plugin/Diff.php 2021-09-20 08:23:20 UTC (rev 10573) @@ -102,9 +102,8 @@ $page = $request->getPage($pagename); $current = $page->getCurrentRevision(); if ($current->getVersion() < 1) { - $html = HTML(HTML::p(fmt("Page “%s” does not exist.", - WikiLink($pagename, 'unknown')))); - return $html; //early return + return HTML(HTML::p(fmt("Page “%s” does not exist.", + WikiLink($pagename, 'unknown')))); //early return } if ($version) { Modified: trunk/lib/plugin/IncludePage.php =================================================================== --- trunk/lib/plugin/IncludePage.php 2021-09-20 07:56:53 UTC (rev 10572) +++ trunk/lib/plugin/IncludePage.php 2021-09-20 08:23:20 UTC (rev 10573) @@ -231,7 +231,6 @@ $c = array($ct, sprintf(_(" ... first %d bytes"), $bytes)); } } - $ct = implode("\n", $c); // one string - return $ct; + return implode("\n", $c); // one string } } Modified: trunk/lib/plugin/LinkSearch.php =================================================================== --- trunk/lib/plugin/LinkSearch.php 2021-09-20 07:56:53 UTC (rev 10572) +++ trunk/lib/plugin/LinkSearch.php 2021-09-20 08:23:20 UTC (rev 10573) @@ -112,7 +112,7 @@ */ $submit = Button('submit:search', _("LinkSearch")); $instructions = _("Search in pages for links with the matching name."); - $form = HTML::form(array('action' => $action, + return HTML::form(array('action' => $action, 'method' => 'get', 'accept-charset' => 'UTF-8'), $dirsign_switch, @@ -123,7 +123,6 @@ $query, HTML::raw(' '), $direction, HTML::raw(' '), $submit); - return $form; } /** Modified: trunk/lib/plugin/ListPages.php =================================================================== --- trunk/lib/plugin/ListPages.php 2021-09-20 07:56:53 UTC (rev 10572) +++ trunk/lib/plugin/ListPages.php 2021-09-20 08:23:20 UTC (rev 10573) @@ -149,7 +149,6 @@ function _getValue($page_handle, $revision_handle) { $iter = $page_handle->getLinks($this->_direction); - $count = $iter->count(); - return $count; + return $iter->count(); } } Modified: trunk/lib/plugin/ListSubpages.php =================================================================== --- trunk/lib/plugin/ListSubpages.php 2021-09-20 07:56:53 UTC (rev 10572) +++ trunk/lib/plugin/ListSubpages.php 2021-09-20 08:23:20 UTC (rev 10573) @@ -141,7 +141,6 @@ function _getValue($page_handle, $revision_handle) { $iter = $page_handle->getBackLinks(); - $count = $iter->count(); - return $count; + return $iter->count(); } } Modified: trunk/lib/plugin/RawHtml.php =================================================================== --- trunk/lib/plugin/RawHtml.php 2021-09-20 07:56:53 UTC (rev 10572) +++ trunk/lib/plugin/RawHtml.php 2021-09-20 08:23:20 UTC (rev 10573) @@ -182,8 +182,7 @@ // anything with ="javascript: is right out -- strip all tags and return if found $pattern = "/=\s*\S+script:\S+/Ui"; if (preg_match($pattern, $html)) { - $html = strip_tags($html); - return $html; + return strip_tags($html); } // setup -- $allowedtags is an array of $tag=>$closeit pairs, where $tag is an HTML tag to allow and $closeit is 1 if the tag requires a matching, closing tag Modified: trunk/lib/plugin/SemanticSearchAdvanced.php =================================================================== --- trunk/lib/plugin/SemanticSearchAdvanced.php 2021-09-20 07:56:53 UTC (rev 10572) +++ trunk/lib/plugin/SemanticSearchAdvanced.php 2021-09-20 08:23:20 UTC (rev 10573) @@ -109,7 +109,7 @@ $submit = Button('submit:semsearch[relations]', _("Search"), false, array('title' => 'Move to help page. No separate window')); $instructions = _("Search in all specified pages for the expression."); - $form = HTML::form(array('action' => $action, + return HTML::form(array('action' => $action, 'method' => 'post', 'accept-charset' => 'UTF-8'), $reldef, @@ -123,7 +123,6 @@ $querybox))), HTML::br(), HTML::div(array('class' => 'align-center'), $submit)); - return $form; } /** Modified: trunk/lib/plugin/SystemInfo.php =================================================================== --- trunk/lib/plugin/SystemInfo.php 2021-09-20 07:56:53 UTC (rev 10572) +++ trunk/lib/plugin/SystemInfo.php 2021-09-20 08:23:20 UTC (rev 10573) @@ -168,8 +168,7 @@ // Any useful numbers similar to a VisualWiki interestmap? function linkstats() { - $s = _("not yet"); - return $s; + return _("not yet"); } // number of homepages: easy Modified: trunk/lib/plugin/UriResolver.php =================================================================== --- trunk/lib/plugin/UriResolver.php 2021-09-20 07:56:53 UTC (rev 10572) +++ trunk/lib/plugin/UriResolver.php 2021-09-20 08:23:20 UTC (rev 10573) @@ -69,7 +69,6 @@ unset($args['start_debug']); // FIXME: ?Test=1 => Test $arg = join("/", array_keys($args)); - $xmlid = RdfWriter::makeXMLExportId($arg); - return $xmlid; + return RdfWriter::makeXMLExportId($arg); } } Modified: trunk/lib/plugin/VisualWiki.php =================================================================== --- trunk/lib/plugin/VisualWiki.php 2021-09-20 07:56:53 UTC (rev 10572) +++ trunk/lib/plugin/VisualWiki.php 2021-09-20 08:23:20 UTC (rev 10573) @@ -605,8 +605,7 @@ if ($promille * 1000 < $pro) return $col; } - $lastcol = end($this->ColorTab); - return $lastcol; + return end($this->ColorTab); } } Modified: trunk/lib/plugin/WikiAdminSetAclSimple.php =================================================================== --- trunk/lib/plugin/WikiAdminSetAclSimple.php 2021-09-20 07:56:53 UTC (rev 10572) +++ trunk/lib/plugin/WikiAdminSetAclSimple.php 2021-09-20 08:23:20 UTC (rev 10573) @@ -130,7 +130,7 @@ private function liberalPerms() { - $perm = array('view' => array(ACL_EVERY => true), + return array('view' => array(ACL_EVERY => true), 'edit' => array(ACL_EVERY => true), 'create' => array(ACL_EVERY => true), 'list' => array(ACL_EVERY => true), @@ -142,7 +142,6 @@ ACL_OWNER => true), 'change' => array(ACL_ADMIN => true, ACL_OWNER => true)); - return $perm; } /* @@ -156,7 +155,7 @@ private function restrictedPerms() { - $perm = array('view' => array(ACL_AUTHENTICATED => true, + return array('view' => array(ACL_AUTHENTICATED => true, ACL_EVERY => false), 'edit' => array(ACL_AUTHENTICATED => true, ACL_EVERY => false), @@ -172,7 +171,6 @@ ACL_OWNER => true), 'change' => array(ACL_ADMIN => true, ACL_OWNER => true)); - return $perm; } function setaclFormSimple(&$header, $pagehash) Modified: trunk/lib/stdlib.php =================================================================== --- trunk/lib/stdlib.php 2021-09-20 07:56:53 UTC (rev 10572) +++ trunk/lib/stdlib.php 2021-09-20 08:23:20 UTC (rev 10573) @@ -381,8 +381,7 @@ { // FIXME: Is this needed (or sufficient?) if (!IsSafeURL($url)) { - $link = HTML::span(array('class' => 'error'), _('Bad URL').' -- '._('Remove all of <, >, "')); - return $link; + return HTML::span(array('class' => 'error'), _('Bad URL').' -- '._('Remove all of <, >, "')); } else { if (!$linktext) $linktext = preg_replace("/mailto:/A", "", $url); @@ -419,8 +418,7 @@ $arr = explode(' ', $url); if (!empty($arr)) $url = $arr[0]; if (!IsSafeURL($url)) { - $link = HTML::span(array('class' => 'error'), _('Bad URL for image').' -- '._('Remove all of <, >, "')); - return $link; + return HTML::span(array('class' => 'error'), _('Bad URL for image').' -- '._('Remove all of <, >, "')); } // spaces in inline images must be %20 encoded! $link = HTML::img(array('src' => $url)); @@ -471,10 +469,9 @@ } } else { $url = substr(strrchr($ori_url, "/"), 1); - $link = HTML::span(array('class' => 'error'), + return HTML::span(array('class' => 'error'), sprintf(_("Invalid attribute %s=%s for image %s"), $attr, $value, $url)); - return $link; } } // Correct silently the most common error @@ -508,9 +505,8 @@ ($height < 3 and $width < 20) or ($height < 7 and $width < 7) ) { - $link = HTML::span(array('class' => 'error'), + return HTML::span(array('class' => 'error'), _("Invalid image size")); - return $link; } } else { $size = 0; @@ -545,9 +541,8 @@ or ($height < 3 and $width < 20) or ($height < 7 and $width < 7) ) { - $link = HTML::span(array('class' => 'error'), + return HTML::span(array('class' => 'error'), _("Invalid image size")); - return $link; } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <var...@us...> - 2021-09-20 09:09:58
|
Revision: 10574 http://sourceforge.net/p/phpwiki/code/10574 Author: vargenau Date: 2021-09-20 09:09:55 +0000 (Mon, 20 Sep 2021) Log Message: ----------- Remove useless semicolon Modified Paths: -------------- trunk/lib/WikiTheme.php trunk/lib/plugin/TexToPng.php trunk/lib/plugin/WhoIsOnline.php trunk/lib/wikilens/Buddy.php Modified: trunk/lib/WikiTheme.php =================================================================== --- trunk/lib/WikiTheme.php 2021-09-20 08:23:20 UTC (rev 10573) +++ trunk/lib/WikiTheme.php 2021-09-20 09:09:55 UTC (rev 10574) @@ -1689,7 +1689,7 @@ */ function CbUserLogin(&$request, $userid) { - ; // do nothing + // do nothing } /* @@ -1698,7 +1698,7 @@ */ function CbNewUserEdit(&$request, $userid) { - ; // i.e. create homepage with Template/UserPage + // i.e. create homepage with Template/UserPage } /* @@ -1710,7 +1710,7 @@ */ function CbNewUserLogin(&$request, $userid) { - ; // do nothing + // do nothing } /* @@ -1719,7 +1719,7 @@ */ function CbUserLogout(&$request, $userid) { - ; // do nothing + // do nothing } } Modified: trunk/lib/plugin/TexToPng.php =================================================================== --- trunk/lib/plugin/TexToPng.php 2021-09-20 08:23:20 UTC (rev 10573) +++ trunk/lib/plugin/TexToPng.php 2021-09-20 09:09:55 UTC (rev 10574) @@ -222,7 +222,6 @@ if (!$complainvisibly) { $this->dbg('Error during execution of ' . $cmd); } - ; foreach ($errortxt as $key => $value) { if ($complainvisibly) { $this->complain($value . "\n"); Modified: trunk/lib/plugin/WhoIsOnline.php =================================================================== --- trunk/lib/plugin/WhoIsOnline.php 2021-09-20 08:23:20 UTC (rev 10573) +++ trunk/lib/plugin/WhoIsOnline.php 2021-09-20 09:09:55 UTC (rev 10574) @@ -98,7 +98,6 @@ function getSessions($dbi, &$request) { // check the current user sessions and what they are doing - ; } // check the current sessions Modified: trunk/lib/wikilens/Buddy.php =================================================================== --- trunk/lib/wikilens/Buddy.php 2021-09-20 08:23:20 UTC (rev 10573) +++ trunk/lib/wikilens/Buddy.php 2021-09-20 09:09:55 UTC (rev 10574) @@ -77,7 +77,6 @@ $result = $dbh->_dbh->query($query); } else { // from 10 random raters of this page (non-SQL) - ; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <var...@us...> - 2021-09-20 12:47:17
|
Revision: 10594 http://sourceforge.net/p/phpwiki/code/10594 Author: vargenau Date: 2021-09-20 12:47:14 +0000 (Mon, 20 Sep 2021) Log Message: ----------- Use parameter default value Modified Paths: -------------- trunk/lib/BlockParser.php trunk/lib/Captcha.php trunk/lib/PageList.php trunk/lib/PageType.php trunk/lib/Request.php trunk/lib/SemanticWeb.php trunk/lib/WikiDB.php trunk/lib/WikiGroup.php trunk/lib/WikiPlugin.php trunk/lib/WikiPluginCached.php trunk/lib/WikiTheme.php trunk/lib/WikiUser.php trunk/lib/XmlElement.php trunk/lib/diff.php trunk/lib/loadsave.php trunk/lib/main.php trunk/lib/plugin/SystemInfo.php trunk/lib/prepend.php Modified: trunk/lib/BlockParser.php =================================================================== --- trunk/lib/BlockParser.php 2021-09-20 12:39:40 UTC (rev 10593) +++ trunk/lib/BlockParser.php 2021-09-20 12:47:14 UTC (rev 10594) @@ -461,7 +461,7 @@ if ($line === false or $line === '') // allow $line === '0' return false; - trigger_error("Couldn't match block: '$line'", E_USER_NOTICE); + trigger_error("Couldn't match block: '$line'"); return false; } } Modified: trunk/lib/Captcha.php =================================================================== --- trunk/lib/Captcha.php 2021-09-20 12:39:40 UTC (rev 10593) +++ trunk/lib/Captcha.php 2021-09-20 12:47:14 UTC (rev 10594) @@ -85,7 +85,7 @@ 'name' => 'edit[captcha_input]', 'size' => $this->length + 2, 'maxlength' => 256)); - $url = WikiURL("", array("action" => "captcha", "id" => time()), false); + $url = WikiURL("", array("action" => "captcha", "id" => time())); $el['CAPTCHA_IMAGE'] = HTML::img(array('src' => $url, 'alt' => 'captcha')); $el['CAPTCHA_LABEL'] = HTML::label(array('for' => 'edit-captcha_input'), _("Type word above:")); Modified: trunk/lib/PageList.php =================================================================== --- trunk/lib/PageList.php 2021-09-20 12:39:40 UTC (rev 10593) +++ trunk/lib/PageList.php 2021-09-20 12:47:14 UTC (rev 10594) @@ -269,7 +269,7 @@ function _getSortableValue($page_handle, $revision_handle) { if (!$revision_handle) - $revision_handle = $page_handle->getCurrentRevision(true); + $revision_handle = $page_handle->getCurrentRevision(); return (empty($revision_handle->_data['%content'])) ? 0 : strlen($revision_handle->_data['%content']); } @@ -405,7 +405,7 @@ if (!$revision_handle or (!$revision_handle->_data['%content'] or $revision_handle->_data['%content'] === true) ) { - $revision_handle = $page_handle->getCurrentRevision(true); + $revision_handle = $page_handle->getCurrentRevision(); } if (!empty($revision_handle->_data['%pagedata'])) { $revision_handle->_data['%pagedata']['_cached_html'] = ''; @@ -558,7 +558,7 @@ function _getValue($page_handle, $revision_handle) { if ($this->dbi->isWikiPage($page_handle->getName())) - return WikiLink($page_handle, 'known'); + return WikiLink($page_handle); else return WikiLink($page_handle, 'unknown'); } @@ -1397,7 +1397,7 @@ 'averagerating', 'top3recs', 'relation', 'linkto'); if (!in_array($column, $silently_ignore)) - trigger_error(sprintf("%s: Bad column", $column), E_USER_NOTICE); + trigger_error(sprintf("%s: Bad column", $column)); return false; } if (!(defined('FUSIONFORGE') && FUSIONFORGE)) { Modified: trunk/lib/PageType.php =================================================================== --- trunk/lib/PageType.php 2021-09-20 12:39:40 UTC (rev 10593) +++ trunk/lib/PageType.php 2021-09-20 12:47:14 UTC (rev 10594) @@ -338,7 +338,7 @@ if (defined('WARN_NONPUBLIC_INTERWIKIMAP') and WARN_NONPUBLIC_INTERWIKIMAP) { $error_html = sprintf(_("Loading InterWikiMap from external file %s."), INTERWIKI_MAP_FILE); - trigger_error($error_html, E_USER_NOTICE); + trigger_error($error_html); } if (file_exists(INTERWIKI_MAP_FILE)) { $filename = INTERWIKI_MAP_FILE; Modified: trunk/lib/Request.php =================================================================== --- trunk/lib/Request.php 2021-09-20 12:39:40 UTC (rev 10593) +++ trunk/lib/Request.php 2021-09-20 12:47:14 UTC (rev 10594) @@ -414,7 +414,7 @@ if (ob_get_length()) ob_clean(); $this->_is_buffering_output = false; } else { - trigger_error(_("Not buffering output"), E_USER_NOTICE); + trigger_error(_("Not buffering output")); } } @@ -812,8 +812,7 @@ . "\n" . sprintf(_("Please ensure that %s is writable, or redefine %s in config/config.ini."), sprintf(_("the file “%s”"), ACCESS_LOG), - 'ACCESS_LOG') - , E_USER_NOTICE); + 'ACCESS_LOG')); } register_shutdown_function("Request_AccessLogEntry_shutdown_function"); Modified: trunk/lib/SemanticWeb.php =================================================================== --- trunk/lib/SemanticWeb.php 2021-09-20 12:39:40 UTC (rev 10593) +++ trunk/lib/SemanticWeb.php 2021-09-20 12:47:14 UTC (rev 10594) @@ -330,8 +330,7 @@ $value = $val_base; if (!is_numeric($value)) { $this->workquery = ''; //must return false - trigger_error("Cannot match against non-numeric attribute value $x := $ori_value", - E_USER_NOTICE); + trigger_error("Cannot match against non-numeric attribute value $x := $ori_value"); return ''; } Modified: trunk/lib/WikiDB.php =================================================================== --- trunk/lib/WikiDB.php 2021-09-20 12:39:40 UTC (rev 10593) +++ trunk/lib/WikiDB.php 2021-09-20 12:47:14 UTC (rev 10594) @@ -557,7 +557,7 @@ ($this, $linked_page->getName(), $lookbehind . $from . $lookahead, $to, - true, true); + true); } // FIXME: Disabled to avoid recursive modification when renaming // a page like 'PageFoo to 'PageFooTwo' @@ -568,7 +568,7 @@ ($this, $linked_page->getName(), $lookbehind . $from . $lookahead, $to, - true, true); + true); } } } @@ -978,8 +978,7 @@ $pdata = $cache->get_versiondata($pagename, $latestversion); if ($data['mtime'] < $pdata['mtime']) { trigger_error(sprintf(_("%s: Date of new revision is %s"), - $pagename, "'non-monotonic'"), - E_USER_NOTICE); + $pagename, "'non-monotonic'")); $data['orig_mtime'] = $data['mtime']; $data['mtime'] = $pdata['mtime']; } @@ -1272,7 +1271,7 @@ return $backend->exists_link($this->_pagename, $link, $reversed); //$cache = &$this->_wikidb->_cache; // TODO: check cache if it is possible - $iter = $this->getLinks($reversed, false); + $iter = $this->getLinks($reversed); while ($page = $iter->next()) { if ($page->getName() == $link) return $page; @@ -1420,7 +1419,7 @@ { if ($this->_wikidb->readonly) { if ((int)DEBUG) { - trigger_error("readonly database", E_USER_NOTICE); + trigger_error("readonly database"); } return; } Modified: trunk/lib/WikiGroup.php =================================================================== --- trunk/lib/WikiGroup.php 2021-09-20 12:39:40 UTC (rev 10593) +++ trunk/lib/WikiGroup.php 2021-09-20 12:47:14 UTC (rev 10594) @@ -480,16 +480,13 @@ * Private method to take a WikiDB_Page and parse to determine if the * current_user is a member of the group. * @param object $group_page WikiDB_Page object for the group's page - * @param bool $strict * @return boolean True if user is a member, else false. */ - private function _inGroupPage($group_page, $strict = false) + private function _inGroupPage($group_page) { $group_revision = $group_page->getCurrentRevision(); if ($group_revision->hasDefaultContents()) { $group = $group_page->getName(); - if ($strict) trigger_error(sprintf(_("Group page “%s” does not exist"), $group), - E_USER_WARNING); return false; } $contents = $group_revision->getContent(); @@ -935,7 +932,7 @@ $info = ldap_get_entries($ldap, $sr); else { $info = array('count' => 0); - trigger_error("LDAP_SEARCH: base=\"$base_dn\" \"(cn=$group)\" failed", E_USER_NOTICE); + trigger_error("LDAP_SEARCH: base=\"$base_dn\" \"(cn=$group)\" failed"); } $base_dn = (LDAP_OU_USERS ? LDAP_OU_USERS : "ou=Users") . ($this->base_dn ? "," . $this->base_dn : ''); @@ -949,7 +946,7 @@ $members[] = $info2[$j]["cn"][0]; } } else { - trigger_error("LDAP_SEARCH: base=\"$base_dn\" \"(gidNumber=$gid)\" failed", E_USER_NOTICE); + trigger_error("LDAP_SEARCH: base=\"$base_dn\" \"(gidNumber=$gid)\" failed"); } } } Modified: trunk/lib/WikiPlugin.php =================================================================== --- trunk/lib/WikiPlugin.php 2021-09-20 12:39:40 UTC (rev 10593) +++ trunk/lib/WikiPlugin.php 2021-09-20 12:47:14 UTC (rev 10594) @@ -284,7 +284,7 @@ function handle_plugin_args_cruft($argstr, $args) { trigger_error(sprintf(_("trailing cruft in plugin args: “%s”"), - $argstr), E_USER_NOTICE); + $argstr)); } /* A plugin can override this to allow undeclared arguments. @@ -293,7 +293,7 @@ function allow_undeclared_arg($name, $value) { trigger_error(sprintf(_("Argument “%s” not declared by plugin."), - $name), E_USER_NOTICE); + $name)); return false; } Modified: trunk/lib/WikiPluginCached.php =================================================================== --- trunk/lib/WikiPluginCached.php 2021-09-20 12:39:40 UTC (rev 10593) +++ trunk/lib/WikiPluginCached.php 2021-09-20 12:47:14 UTC (rev 10594) @@ -1097,7 +1097,7 @@ if (!$ok) { trigger_error("\n" . $cmd . " failed: $errstr", E_USER_WARNING); } elseif ($request->getArg('debug')) - trigger_error("\n" . $cmd . ": success\n", E_USER_NOTICE); + trigger_error("\n" . $cmd . ": success\n"); if (!isWindows()) { if ($until) { $loop = 100000; Modified: trunk/lib/WikiTheme.php =================================================================== --- trunk/lib/WikiTheme.php 2021-09-20 12:39:40 UTC (rev 10593) +++ trunk/lib/WikiTheme.php 2021-09-20 12:47:14 UTC (rev 10594) @@ -301,7 +301,7 @@ if (isset($this->_default_theme)) { return $this->_default_theme->_findFile($file, $missing_okay); } elseif (!$missing_okay) { - trigger_error("$this->_theme/$file: not found", E_USER_NOTICE); + trigger_error("$this->_theme/$file: not found"); if (DEBUG & _DEBUG_TRACE) { echo "<pre>"; printSimpleTrace(debug_backtrace()); @@ -1309,8 +1309,7 @@ $request->_MoreHeaders[] = $element; if (!empty($this->_headers_printed) and $this->_headers_printed) { trigger_error(_("Some action(page) wanted to add more headers, but they were already printed.") - . "\n" . $element->asXML(), - E_USER_NOTICE); + . "\n" . $element->asXML()); } } Modified: trunk/lib/WikiUser.php =================================================================== --- trunk/lib/WikiUser.php 2021-09-20 12:39:40 UTC (rev 10593) +++ trunk/lib/WikiUser.php 2021-09-20 12:47:14 UTC (rev 10594) @@ -1954,7 +1954,7 @@ if (!isset($this->_prefs[$name])) { if ($name == 'passwd2') return false; if ($name == 'passwd') return false; - trigger_error("$name: unknown preference", E_USER_NOTICE); + trigger_error("$name: unknown preference"); return false; } return $this->_prefs[$name]; Modified: trunk/lib/XmlElement.php =================================================================== --- trunk/lib/XmlElement.php 2021-09-20 12:39:40 UTC (rev 10593) +++ trunk/lib/XmlElement.php 2021-09-20 12:47:14 UTC (rev 10594) @@ -127,10 +127,9 @@ } elseif (is_array($item)) { // DEPRECATED: // Use XmlContent objects instead of arrays for collections of XmlElements. - trigger_error("Passing arrays to printXML() is deprecated: (" . AsXML($item, true) . ")", - E_USER_NOTICE); + trigger_error("Passing arrays to printXML() is deprecated: (" . AsXML($item, true) . ")"); foreach ($item as $x) - $this->printXML($x); + $this->printXML(); } else { echo $this->_quote((string)$item); } @@ -148,10 +147,9 @@ $xml .= $this->_quote($item->asString()); else $xml .= sprintf("==Object(%s)==", get_class($item)); } elseif (is_array($item)) { - trigger_error("Passing arrays to ->asXML() is deprecated: (" . AsXML($item, true) . ")", - E_USER_NOTICE); + trigger_error("Passing arrays to ->asXML() is deprecated: (" . AsXML($item, true) . ")"); foreach ($item as $x) - $xml .= $this->asXML($x); + $xml .= $this->asXML(); } else $xml .= $this->_quote((string)$item); } @@ -622,8 +620,7 @@ } elseif (is_array($val)) { // DEPRECATED: // Use XmlContent objects instead of arrays for collections of XmlElements. - trigger_error("Passing arrays to PrintXML() is deprecated: (" . AsXML($val, true) . ")", - E_USER_NOTICE); + trigger_error("Passing arrays to PrintXML() is deprecated: (" . AsXML($val, true) . ")"); foreach ($val as $x) PrintXML($x); } else @@ -650,8 +647,7 @@ // Use XmlContent objects instead of arrays for collections of XmlElements. if (empty($nowarn)) { $nowarn = true; - trigger_error("Passing arrays to AsXML() is deprecated: (" . AsXML($val) . ")", - E_USER_NOTICE); + trigger_error("Passing arrays to AsXML() is deprecated: (" . AsXML($val) . ")"); unset($nowarn); } $xml = ''; @@ -677,7 +673,7 @@ } elseif (is_array($val)) { // DEPRECATED: // Use XmlContent objects instead of arrays for collections of XmlElements. - trigger_error("Passing arrays to AsString() is deprecated", E_USER_NOTICE); + trigger_error("Passing arrays to AsString() is deprecated"); $str = ''; foreach ($val as $x) $str .= AsString($x); Modified: trunk/lib/diff.php =================================================================== --- trunk/lib/diff.php 2021-09-20 12:39:40 UTC (rev 10593) +++ trunk/lib/diff.php 2021-09-20 12:47:14 UTC (rev 10594) @@ -286,7 +286,7 @@ $html = HTML::div(array('class' => 'wikitext', 'id' => 'difftext'), HTML::p(fmt("Page “%s” does not exist.", WikiLink($pagename, 'unknown')))); require_once 'lib/Template.php'; - GeneratePage($html, sprintf(_("Diff: %s"), $pagename), false); + GeneratePage($html, sprintf(_("Diff: %s"), $pagename)); return; //early return } @@ -362,7 +362,7 @@ $html->pushContent(HTML::table(PageInfoRow(_("Newer page:"), $new, $request, empty($version)), PageInfoRow(_("Older page:"), $old, - $request, false))); + $request))); if ($new && $old) { $diff = new Diff($old->getContent(), $new->getContent()); Modified: trunk/lib/loadsave.php =================================================================== --- trunk/lib/loadsave.php 2021-09-20 12:39:40 UTC (rev 10593) +++ trunk/lib/loadsave.php 2021-09-20 12:47:14 UTC (rev 10594) @@ -1155,8 +1155,7 @@ } if (!empty($error_html)) - trigger_error(_("Default InterWiki map file not loaded.") - . $error_html, E_USER_NOTICE); + trigger_error(_("Default InterWiki map file not loaded.") . $error_html); if ($goback) return $content; Modified: trunk/lib/main.php =================================================================== --- trunk/lib/main.php 2021-09-20 12:39:40 UTC (rev 10593) +++ trunk/lib/main.php 2021-09-20 12:47:14 UTC (rev 10594) @@ -961,7 +961,7 @@ return $en_action; } - trigger_error("$action: Unknown action", E_USER_NOTICE); + trigger_error("$action: Unknown action"); return 'browse'; } @@ -1070,7 +1070,7 @@ return $cache[$action] = $action; } - trigger_error("$action: Cannot find action page", E_USER_NOTICE); + trigger_error("$action: Cannot find action page"); return $cache[$action] = false; } @@ -1378,14 +1378,12 @@ 'SESSION_SAVE_PATH') . "\n" . sprintf(_("Attempting to use the directory “%s” instead."), - $tmpdir) - , E_USER_NOTICE); + $tmpdir)); if (!is_writeable($tmpdir)) { trigger_error (sprintf(_("%s is not writable."), $tmpdir) . "\n" - . _("Users will not be able to sign in.") - , E_USER_NOTICE); + . _("Users will not be able to sign in.")); } else @ini_set('session.save_path', $tmpdir); } Modified: trunk/lib/plugin/SystemInfo.php =================================================================== --- trunk/lib/plugin/SystemInfo.php 2021-09-20 12:39:40 UTC (rev 10593) +++ trunk/lib/plugin/SystemInfo.php 2021-09-20 12:47:14 UTC (rev 10594) @@ -155,7 +155,7 @@ global $request; $dbi = $request->getDbh(); $s = sprintf(_("%d pages"), $dbi->numPages(true)); - $s .= ", " . sprintf(_("%d not-empty pages"), $dbi->numPages(false)); + $s .= ", " . sprintf(_("%d not-empty pages"), $dbi->numPages()); // more bla.... // $s .= ", " . sprintf(_("earliest page from %s"), $earliestdate); // $s .= ", " . sprintf(_("latest page from %s"), $latestdate); @@ -199,8 +199,7 @@ // TODO: see WhoIsOnline hit stats, and sql accesslogs function accessstats() { - $s = _("not yet"); - return $s; + return _("not yet"); } // numeric array Modified: trunk/lib/prepend.php =================================================================== --- trunk/lib/prepend.php 2021-09-20 12:39:40 UTC (rev 10593) +++ trunk/lib/prepend.php 2021-09-20 12:47:14 UTC (rev 10594) @@ -100,7 +100,7 @@ { if (!isset($this->_times)) { // posix_times() not available. - return sprintf("real: %.3f", $this->getTime('real')); + return sprintf("real: %.3f", $this->getTime()); } $now = posix_times(); return sprintf("real: %.3f, user: %.3f, sys: %.3f", This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <var...@us...> - 2021-10-20 07:19:20
|
Revision: 10635 http://sourceforge.net/p/phpwiki/code/10635 Author: vargenau Date: 2021-10-20 07:19:18 +0000 (Wed, 20 Oct 2021) Log Message: ----------- Make changing language work Modified Paths: -------------- trunk/lib/IniConfig.php trunk/lib/config.php trunk/lib/main.php Modified: trunk/lib/IniConfig.php =================================================================== --- trunk/lib/IniConfig.php 2021-10-19 13:38:39 UTC (rev 10634) +++ trunk/lib/IniConfig.php 2021-10-20 07:19:18 UTC (rev 10635) @@ -740,69 +740,29 @@ if (!defined('DEFAULT_LANGUAGE')) // not needed anymore define('DEFAULT_LANGUAGE', ''); // detect from client - // FusionForge hack - if (!(defined('FUSIONFORGE') && FUSIONFORGE)) { - // Disable update_locale because Zend Debugger crash - if (!extension_loaded('Zend Debugger')) { - update_locale(isset($LANG) ? $LANG : DEFAULT_LANGUAGE); - } - } + $chback = 0; + if ($LANG != 'en') { - if (empty($LANG)) { - if (!defined("DEFAULT_LANGUAGE") or !DEFAULT_LANGUAGE) { - // TODO: defer this to WikiRequest::initializeLang() - $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 - if (!function_exists('bindtextdomain') - and !function_exists('gettext') - and !function_exists('_') - ) { - $locale = array(); - - function gettext($text) - { - global $locale; - if (!empty ($locale[$text])) - return $locale[$text]; - return $text; - } - - function _($text) - { - return gettext($text); - } - } else { - $chback = 0; - if ($LANG != 'en') { - - // Working around really weird gettext problems: (4.3.2, 4.3.6 win) - // bindtextdomain() in returns the current domain path. - // 1. If the script is not index.php but something like "de", on a different path - // then bindtextdomain() fails, but after chdir to the correct path it will work okay. - // 2. But the weird error "Undefined variable: bindtextdomain" is generated then. - $bindtextdomain_path = findFile("locale", false, true); + // Working around really weird gettext problems: (4.3.2, 4.3.6 win) + // bindtextdomain() in returns the current domain path. + // 1. If the script is not index.php but something like "de", on a different path + // then bindtextdomain() fails, but after chdir to the correct path it will work okay. + // 2. But the weird error "Undefined variable: bindtextdomain" is generated then. + $bindtextdomain_path = findFile("locale", false, true); + $bindtextdomain_real = @bindtextdomain("phpwiki", $bindtextdomain_path); + if (realpath($bindtextdomain_real) != realpath($bindtextdomain_path)) { + // this will happen with virtual_paths. chdir and try again. + chdir($bindtextdomain_path); + $chback = 1; $bindtextdomain_real = @bindtextdomain("phpwiki", $bindtextdomain_path); - if (realpath($bindtextdomain_real) != realpath($bindtextdomain_path)) { - // this will happen with virtual_paths. chdir and try again. - chdir($bindtextdomain_path); - $chback = 1; - $bindtextdomain_real = @bindtextdomain("phpwiki", $bindtextdomain_path); - } } - // tell gettext not to use unicode. PHP >= 4.2.0. Thanks to Kai Krakow. - if ($LANG != 'en') - textdomain("phpwiki"); - if ($chback) { // change back - chdir($bindtextdomain_real . "/.."); - } } + // tell gettext not to use unicode. PHP >= 4.2.0. Thanks to Kai Krakow. + if ($LANG != 'en') + textdomain("phpwiki"); + if ($chback) { // change back + chdir($bindtextdomain_real . "/.."); + } // language dependent updates: if (!defined('CATEGORY_GROUP_PAGE')) Modified: trunk/lib/config.php =================================================================== --- trunk/lib/config.php 2021-10-19 13:38:39 UTC (rev 10634) +++ trunk/lib/config.php 2021-10-20 07:19:18 UTC (rev 10635) @@ -57,193 +57,49 @@ @preg_match('/CGI/', $GLOBALS['HTTP_ENV_VARS']['GATEWAY_INTERFACE'])); } -/** - * If $LANG is undefined: - * Smart client language detection, based on our supported languages - * HTTP_ACCEPT_LANGUAGE="de-at,en;q=0.5" - * => "de" - * We should really check additionally if the i18n HomePage version is defined. - * So must defer this to the request loop. - * - * @return string - */ -function guessing_lang() -{ - $languages = array("en", "de", "es", "fr", "it", "ja", "zh", "nl", "sv"); - - $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'])) - $accept = $_SERVER['HTTP_ACCEPT_LANGUAGE']; - - if ($accept) { - $lang_list = array(); - $list = explode(",", $accept); - for ($i = 0; $i < count($list); $i++) { - $pos = strchr($list[$i], ";"); - if ($pos === false) { - // No Q it is only a locale... - $lang_list[$list[$i]] = 100; - } else { - // Has a Q rating - $q = explode(";", $list[$i]); - $loc = $q[0]; - $q = explode("=", $q[1]); - $lang_list[$loc] = $q[1] * 100; - } - } - - // sort by q desc - arsort($lang_list); - - // compare with languages, ignoring sublang and charset - foreach ($lang_list as $lang => $q) { - if (in_array($lang, $languages)) - return $lang; - // de_DE.iso8859-1@euro => de_DE.iso8859-1, de_DE, de - // de-DE => de-DE, de - foreach (array('@', '.', '_') as $sep) { - if (($tail = strchr($lang, $sep))) { - $lang_short = substr($lang, 0, -strlen($tail)); - if (in_array($lang_short, $languages)) - return $lang_short; - } - } - if ($pos = strpos($lang, "-") and in_array(substr($lang, 0, $pos), $languages)) - return substr($lang, 0, $pos); - } - } - return $languages[0]; -} - -/** - * Smart setlocale(). - * - * This is a version of the builtin setlocale() which is - * smart enough to try some alternatives... - * - * @param mixed $category - * @param string $locale - * @return string The new locale, or <code>false</code> if unable - * to set the requested locale. - * @see setlocale - * [56ms] - */ -function guessing_setlocale($category, $locale) -{ - $alt = array( - 'de' => array('de_DE', 'de_AT', 'de_CH', 'deutsch', 'german'), - 'en' => array('en_US', 'en_GB', 'en_AU', 'en_CA', 'en_IE', 'english', 'C'), - 'es' => array('es_ES', 'es_MX', 'es_AR', 'spanish'), - 'fr' => array('fr_FR', 'fr_BE', 'fr_CA', 'fr_CH', 'fr_LU', 'français', 'french'), - 'it' => array('it_IT', 'it_CH', 'italian'), - 'ja' => array('ja_JP', 'japanese'), - 'nl' => array('nl_NL', 'nl_BE', 'dutch'), - 'sv' => array('sv_SE', 'sv_FI', 'swedish'), - 'zh' => array('zh_TW', 'zh_CN'), - ); - 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) { - foreach ($alt as $try => $locs) { - if (in_array($locale, $locs) or in_array($lang, $locs)) { - //if (empty($GLOBALS['LANG'])) $GLOBALS['LANG'] = $try; - return $try; - } - } - } - } - } - if (strlen($locale) == 2) - $lang = $locale; - else - list ($lang) = explode('_', $locale); - if (!isset($alt[$lang])) - return false; - - foreach ($alt[$lang] as $try) { - if ($res = setlocale($category, $try)) - return $res; - // Try with charset appended... - $tryutf8 = $try . '.' . 'UTF-8'; - if ($res = setlocale($category, $tryutf8)) - return $res; - $tryutf8 = $try . '.' . 'utf8'; - if ($res = setlocale($category, $tryutf8)) - return $res; - foreach (array(".", '@', '_') as $sep) { - if ($i = strpos($try, $sep)) { - $try = substr($try, 0, $i); - if (($res = setlocale($category, $try))) - return $res; - } - } - } - return false; - // A standard locale name is typically of the form - // language[_territory][.codeset][@modifier], where language is - // an ISO 639 language code, territory is an ISO 3166 country code, - // and codeset is a character set or encoding identifier like - // ISO-8859-1 or UTF-8. -} - -// [99ms] function update_locale($loc) { if ($loc == 'C' or $loc == 'en') { - return ''; + return; } - // $LANG or DEFAULT_LANGUAGE is too less information, at least on unix for - // setlocale(), for bindtextdomain() to succeed. - $setlocale = guessing_setlocale(LC_ALL, $loc); // [56ms] - if (!$setlocale) { // system has no locale for this language, so gettext might fail - $setlocale = FileFinder::_get_lang(); - list ($setlocale,) = explode('_', $setlocale, 2); - $setlocale = guessing_setlocale(LC_ALL, $setlocale); // try again - if (!$setlocale) $setlocale = $loc; + + switch ($loc) { + case "de": + $loc = "de_DE"; + break; + case "es": + $loc = "es_ES"; + break; + case "fr": + $loc = "fr_FR"; + break; + case "it": + $loc = "it_IT"; + break; + case "ja": + $loc = "ja_JP"; + break; + case "nl": + $loc = "nl_NL"; + break; + case "de": + $loc = "sv_SE"; + break; + case "zh": + $loc = "zh_CN"; + break; } - // Try to put new locale into environment (so any - // programs we run will get the right locale.) - if (function_exists('bindtextdomain')) { - // If PHP is in safe mode, this is not allowed, - // so hide errors... - @putenv("LC_ALL=$setlocale"); - @putenv("LANG=$loc"); - @putenv("LANGUAGE=$loc"); + // First try with UTF-8 locale, both syntaxes + $res = setlocale(LC_ALL, $loc.".utf8"); + if ($res !== false) { + return; } - - // To get the POSIX character classes in the PCRE's (e.g. - // [[:upper:]]) to match extended characters (e.g. GrüßGott), we have - // to set the locale, using setlocale(). - // - // The problem is which locale to set? We would like to recognize all - // upper-case characters in the iso-8859-1 character set as upper-case - // characters --- not just the ones which are in the current $LANG. - // - // As it turns out, at least on my system (Linux/glibc-2.2) as long as - // you setlocale() to anything but "C" it works fine. (I'm not sure - // whether this is how it's supposed to be, or whether this is a bug - // in the libc...) - // - // We don't currently use the locale setting for anything else, so for - // now, just set the locale to US English. - // - // FIXME: Not all environments may support en_US? We should probably - // have a list of locales to try. - if (setlocale(LC_CTYPE, 0) == 'C') { - setlocale(LC_CTYPE, 'en_US.UTF-8'); - } else { - setlocale(LC_CTYPE, $setlocale); + $res = setlocale(LC_ALL, $loc.".UTF-8"); + if ($res !== false) { + return; } - - return $loc; + // If it fails, try with no encoding + setlocale(LC_ALL, $loc); } function deduce_script_name() Modified: trunk/lib/main.php =================================================================== --- trunk/lib/main.php 2021-10-19 13:38:39 UTC (rev 10634) +++ trunk/lib/main.php 2021-10-20 07:19:18 UTC (rev 10635) @@ -152,14 +152,9 @@ $_lang = $this->_prefs->_prefs['lang']; if (isset($_lang->lang) and $_lang->lang != $GLOBALS['LANG']) { $user_lang = $_lang->lang; - //check changed LANG and THEME inside a session. - // (e.g. by using another baseurl) - if (isset($this->_user->_authhow) and $this->_user->_authhow == 'session') - $user_lang = $GLOBALS['LANG']; update_locale($user_lang); findLocalizedButtonFile(".", 'missing_ok', 'reinit'); } - //if (empty($_lang->lang) and $GLOBALS['LANG'] != $_lang->default_value) ; } function initializeTheme($when = 'default') This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <var...@us...> - 2021-11-17 08:14:17
|
Revision: 10653 http://sourceforge.net/p/phpwiki/code/10653 Author: vargenau Date: 2021-11-17 08:14:15 +0000 (Wed, 17 Nov 2021) Log Message: ----------- Remove durations Modified Paths: -------------- trunk/lib/IniConfig.php trunk/lib/display.php trunk/lib/main.php Modified: trunk/lib/IniConfig.php =================================================================== --- trunk/lib/IniConfig.php 2021-11-17 08:09:41 UTC (rev 10652) +++ trunk/lib/IniConfig.php 2021-11-17 08:14:15 UTC (rev 10653) @@ -431,7 +431,7 @@ $GLOBALS['INCLUDE_PATH'] = $rs['INCLUDE_PATH']; } $rs['PLUGIN_CACHED_CACHE_DIR'] = TEMP_DIR . '/cache'; - if (!findFile($rs['PLUGIN_CACHED_CACHE_DIR'], 1)) { // [29ms] + if (!findFile($rs['PLUGIN_CACHED_CACHE_DIR'], 1)) { findFile(TEMP_DIR, false, 1); // TEMP must exist! mkdir($rs['PLUGIN_CACHED_CACHE_DIR'], 0777); } @@ -459,8 +459,8 @@ unset($rs); unset($rsdef); - fixup_static_configs($file); //[1ms] - fixup_dynamic_configs(); // [100ms] + fixup_static_configs($file); + fixup_dynamic_configs(); } function fixup_static_configs($file) Modified: trunk/lib/display.php =================================================================== --- trunk/lib/display.php 2021-11-17 08:09:41 UTC (rev 10652) +++ trunk/lib/display.php 2021-11-17 08:14:15 UTC (rev 10653) @@ -35,7 +35,7 @@ require_once 'lib/TextSearchQuery.php'; $search = new TextSearchQuery(KEYWORDS, true); $KeywordLinkRegexp = $search->asRegexp(); - // iterate over the pagelinks (could be a large number) [15ms on PluginManager] + // iterate over the pagelinks (could be a large number) // or do a titleSearch and check the categories if they are linked? $links = $page->getPageLinks(); $keywords[] = SplitPagename($page->getName()); Modified: trunk/lib/main.php =================================================================== --- trunk/lib/main.php 2021-11-17 08:09:41 UTC (rev 10652) +++ trunk/lib/main.php 2021-11-17 08:14:15 UTC (rev 10653) @@ -39,7 +39,7 @@ function mayAccessPage($access, $pagename) { if (defined('ENABLE_PAGEPERM') and ENABLE_PAGEPERM) - return _requiredAuthorityForPagename($access, $pagename); // typically [10-20ms per page] + return _requiredAuthorityForPagename($access, $pagename); else return true; } @@ -54,7 +54,6 @@ function __construct() { $this->_dbi = WikiDB::open($GLOBALS['DBParams']); - // first mysql request costs [958ms]! [670ms] is mysql_connect() if (in_array('File', $this->_dbi->getAuthParam('USER_AUTH_ORDER'))) { include_once 'lib/pear/File_Passwd.php'; @@ -86,7 +85,7 @@ . $dbi->getParam('db_session_table')); } - parent::__construct(); // [90ms] + parent::__construct(); // Normalize args... $this->setArg('pagename', $this->_deducePagename()); @@ -227,7 +226,6 @@ // This really maybe should be part of the constructor, but since it // may involve HTML/template output, the global $request really needs // to be initialized before we do this stuff. - // [50ms]: 36ms if wikidb_page::exists function updateAuthAndPrefs() { @@ -752,7 +750,6 @@ $this->finish(); // NORETURN } - // [574ms] mainly template:printexpansion: 393ms and template::expandsubtemplate [100+70+60ms] function handleAction() { // Check illegal characters in page names: <>[]{}|" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <var...@us...> - 2022-01-21 16:03:03
|
Revision: 10926 http://sourceforge.net/p/phpwiki/code/10926 Author: vargenau Date: 2022-01-21 16:03:01 +0000 (Fri, 21 Jan 2022) Log Message: ----------- Remove old Windows stuff Modified Paths: -------------- trunk/lib/Request.php trunk/lib/loadsave.php Modified: trunk/lib/Request.php =================================================================== --- trunk/lib/Request.php 2022-01-21 08:43:24 UTC (rev 10925) +++ trunk/lib/Request.php 2022-01-21 16:03:01 UTC (rev 10926) @@ -656,13 +656,6 @@ } } -/* Win32 Note: - [\winnt\php.ini] - You must set "upload_tmp_dir" = "/tmp/" or "C:/tmp/" - Best on the same drive as apache, with forward slashes - and with ending slash! - Otherwise "\\" => "" and the uploaded file will not be found. -*/ class Request_UploadedFile { function __construct($fileinfo) @@ -702,29 +695,10 @@ return false; } - // With windows/php 4.2.1 is_uploaded_file() always returns false. - // Be sure that upload_tmp_dir ends with a slash! if (!is_uploaded_file($fileinfo['tmp_name'])) { - if (isWindows()) { - if (!$tmp_file = get_cfg_var('upload_tmp_dir')) { - $tmp_file = dirname(tempnam('', '')); - } - $tmp_file .= '/' . basename($fileinfo['tmp_name']); - /* ending slash in php.ini upload_tmp_dir is required. */ - if (realpath(preg_replace('#/+#', '/', $tmp_file)) != realpath($fileinfo['tmp_name'])) { - trigger_error(sprintf("Uploaded tmpfile illegal: %s != %s.", $tmp_file, $fileinfo['tmp_name']) . - "\n" . - "Probably illegal TEMP environment or upload_tmp_dir setting. " . - "Esp. on WINDOWS be sure to set upload_tmp_dir in php.ini to use forward slashes and " . - "end with a slash. upload_tmp_dir = \"C:/WINDOWS/TEMP/\" is good suggestion.", - E_USER_ERROR); - return false; - } - } else { - trigger_error(sprintf("Uploaded tmpfile %s not found.", $fileinfo['tmp_name']) . "\n" . - " Probably illegal TEMP environment or upload_tmp_dir setting.", - E_USER_WARNING); - } + trigger_error(sprintf("Uploaded tmpfile %s not found.", $fileinfo['tmp_name']) . "\n" . + " Probably illegal TEMP environment or upload_tmp_dir setting.", + E_USER_WARNING); } return new Request_UploadedFile($fileinfo); } Modified: trunk/lib/loadsave.php =================================================================== --- trunk/lib/loadsave.php 2022-01-21 08:43:24 UTC (rev 10925) +++ trunk/lib/loadsave.php 2022-01-21 16:03:01 UTC (rev 10926) @@ -658,9 +658,6 @@ $dirname = dirname($filename); if ($directory) mkdir_p($directory . "/" . $dirname); - // Fails with "XX / YY", "XX" is created, "XX / YY" cannot be written - // interesting Windows bug: cannot mkdir "bla " - // Since dumps needs to be copied, we have to disallow this for all platforms. $filename = preg_replace("/ \//", "/", $filename); $relative_base = "../"; while ($count > 1) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <var...@us...> - 2022-01-27 08:04:17
|
Revision: 10947 http://sourceforge.net/p/phpwiki/code/10947 Author: vargenau Date: 2022-01-27 08:04:14 +0000 (Thu, 27 Jan 2022) Log Message: ----------- Cleanup Modified Paths: -------------- trunk/lib/WikiDB/PDO.php trunk/lib/WikiDB/SQL.php trunk/lib/WikiDB/backend/PDO.php trunk/lib/WikiDB/backend/PearDB.php trunk/lib/WikiDB.php Modified: trunk/lib/WikiDB/PDO.php =================================================================== --- trunk/lib/WikiDB/PDO.php 2022-01-26 21:03:44 UTC (rev 10946) +++ trunk/lib/WikiDB/PDO.php 2022-01-27 08:04:14 UTC (rev 10947) @@ -68,7 +68,6 @@ */ public function isWikiPage($pagename) { - $pagename = (string)$pagename; if ($pagename === '') { return false; } Modified: trunk/lib/WikiDB/SQL.php =================================================================== --- trunk/lib/WikiDB/SQL.php 2022-01-26 21:03:44 UTC (rev 10946) +++ trunk/lib/WikiDB/SQL.php 2022-01-27 08:04:14 UTC (rev 10947) @@ -70,7 +70,6 @@ */ public function isWikiPage($pagename) { - $pagename = (string)$pagename; if ($pagename === '') { return false; } Modified: trunk/lib/WikiDB/backend/PDO.php =================================================================== --- trunk/lib/WikiDB/backend/PDO.php 2022-01-26 21:03:44 UTC (rev 10946) +++ trunk/lib/WikiDB/backend/PDO.php 2022-01-27 08:04:14 UTC (rev 10947) @@ -1116,24 +1116,11 @@ extract($this->_table_names); $this->lock(array('page', 'version', 'recent', 'nonempty', 'link')); - if (($id = $this->_get_pageid($pagename))) { - if ($new = $this->_get_pageid($to)) { - // Cludge Alert! - // This page does not exist (already verified before), but exists in the page table. - // So we delete this page. - $dbh->query("DELETE FROM $nonempty_tbl WHERE id=$new"); - $dbh->query("DELETE FROM $recent_tbl WHERE id=$new"); - $dbh->query("DELETE FROM $version_tbl WHERE id=$new"); - // We have to fix all referring tables to the old id - $dbh->query("UPDATE $link_tbl SET linkfrom=$id WHERE linkfrom=$new"); - $dbh->query("UPDATE $link_tbl SET linkto=$id WHERE linkto=$new"); - $dbh->query("DELETE FROM $page_tbl WHERE id=$new"); - } - $sth = $dbh->prepare("UPDATE $page_tbl SET pagename=? WHERE id=?"); - $sth->bindParam(1, $to, PDO::PARAM_STR, 100); - $sth->bindParam(2, $id, PDO::PARAM_INT); - $sth->execute(); - } + $id = $this->_get_pageid($pagename); + $sth = $dbh->prepare("UPDATE $page_tbl SET pagename=? WHERE id=?"); + $sth->bindParam(1, $to, PDO::PARAM_STR, 100); + $sth->bindParam(2, $id, PDO::PARAM_INT); + $sth->execute(); $this->unlock(array('page', 'version', 'recent', 'nonempty', 'link')); return $id; } Modified: trunk/lib/WikiDB/backend/PearDB.php =================================================================== --- trunk/lib/WikiDB/backend/PearDB.php 2022-01-26 21:03:44 UTC (rev 10946) +++ trunk/lib/WikiDB/backend/PearDB.php 2022-01-27 08:04:14 UTC (rev 10947) @@ -919,22 +919,9 @@ extract($this->_table_names); $this->lock(); - if (($id = $this->_get_pageid($pagename))) { - if ($new = $this->_get_pageid($to)) { - // Cludge Alert! - // This page does not exist (already verified before), but exists in the page table. - // So we delete this page. - $dbh->query("DELETE FROM $nonempty_tbl WHERE id=$new"); - $dbh->query("DELETE FROM $recent_tbl WHERE id=$new"); - $dbh->query("DELETE FROM $version_tbl WHERE id=$new"); - // We have to fix all referring tables to the old id - $dbh->query("UPDATE $link_tbl SET linkfrom=$id WHERE linkfrom=$new"); - $dbh->query("UPDATE $link_tbl SET linkto=$id WHERE linkto=$new"); - $dbh->query("DELETE FROM $page_tbl WHERE id=$new"); - } - $dbh->query(sprintf("UPDATE $page_tbl SET pagename='%s' WHERE id=$id", - $dbh->escapeSimple($to))); - } + $id = $this->_get_pageid($pagename); + $dbh->query(sprintf("UPDATE $page_tbl SET pagename='%s' WHERE id=$id", + $dbh->escapeSimple($to))); $this->unlock(); return $id; } Modified: trunk/lib/WikiDB.php =================================================================== --- trunk/lib/WikiDB.php 2022-01-26 21:03:44 UTC (rev 10946) +++ trunk/lib/WikiDB.php 2022-01-27 08:04:14 UTC (rev 10947) @@ -95,7 +95,7 @@ $this->touch(); // devel checking. - if ((int)DEBUG & _DEBUG_SQL) { + if (DEBUG & _DEBUG_SQL) { $this->_backend->check(); } // might be changed when opening the database fails @@ -232,7 +232,7 @@ public function deletePage($pagename) { if (!empty($this->readonly)) { - if ((int)DEBUG) { + if (DEBUG) { trigger_error("readonly database", E_USER_WARNING); } return false; @@ -271,7 +271,7 @@ public function purgePage($pagename) { if (!empty($this->readonly)) { - if ((int)DEBUG) { + if (DEBUG) { trigger_error("readonly database", E_USER_WARNING); } return false; @@ -530,7 +530,7 @@ public function renamePage($from, $to, $updateWikiLinks = false) { if (!empty($this->readonly)) { - if ((int)DEBUG) { + if (DEBUG) { trigger_error("readonly database", E_USER_WARNING); } return false; @@ -652,7 +652,7 @@ public function set($key, $newval) { if (!empty($this->readonly)) { - if ((int)DEBUG) { + if (DEBUG) { trigger_error("readonly database", E_USER_WARNING); } return; @@ -751,20 +751,6 @@ { $this->_wikidb = &$wikidb; $this->_pagename = $pagename; - if ((int)DEBUG) { - if (!(is_string($pagename) and $pagename != '')) { - if (function_exists("xdebug_get_function_stack")) { - echo "xdebug_get_function_stack(): "; - var_dump(xdebug_get_function_stack()); - } else { - printSimpleTrace(debug_backtrace()); - } - trigger_error("empty pagename", E_USER_WARNING); - return; - } - } else { - assert(is_string($pagename) and $pagename != ''); - } } /** @@ -807,7 +793,7 @@ public function deleteRevision($version) { if ($this->_wikidb->readonly) { - if ((int)DEBUG) { + if (DEBUG) { trigger_error("readonly database", E_USER_WARNING); } return; @@ -863,7 +849,7 @@ public function mergeRevision($version) { if ($this->_wikidb->readonly) { - if ((int)DEBUG) { + if (DEBUG) { trigger_error("readonly database", E_USER_WARNING); } return; @@ -933,7 +919,7 @@ public function createRevision($version, &$content, $metadata, $links) { if ($this->_wikidb->readonly) { - if ((int)DEBUG) { + if (DEBUG) { trigger_error("readonly database", E_USER_WARNING); } return false; @@ -1025,7 +1011,7 @@ global $request; if ($this->_wikidb->readonly) { - if ((int)DEBUG) { + if (DEBUG) { trigger_error("readonly database", E_USER_WARNING); } return false; @@ -1053,7 +1039,7 @@ // // We're doing this here rather than in createRevision because // postgresql can't optimize while locked. - if (((int)DEBUG & _DEBUG_SQL) + if ((DEBUG & _DEBUG_SQL) or (DATABASE_OPTIMISE_FREQUENCY > 0 and (time() % DATABASE_OPTIMISE_FREQUENCY == 0)) ) { @@ -1368,7 +1354,7 @@ and method_exists($backend, 'set_cached_html') ) { if ($this->_wikidb->readonly) { - if ((int)DEBUG) { + if (DEBUG) { trigger_error("readonly database", E_USER_WARNING); } return; @@ -1388,7 +1374,7 @@ } if (isset($this->_wikidb->readonly) and ($this->_wikidb->readonly)) { - if ((int)DEBUG) { + if (DEBUG) { trigger_error("readonly database", E_USER_WARNING); } return; @@ -1413,7 +1399,7 @@ public function increaseHitCount() { if ($this->_wikidb->readonly) { - if ((int)DEBUG) { + if (DEBUG) { trigger_error("readonly database"); } return; @@ -2003,19 +1989,19 @@ $pagename = $next['pagename']; $version = $next['version']; $versiondata = $next['versiondata']; - if ((int)DEBUG) { + if (DEBUG) { if (!(is_string($pagename) and $pagename != '')) { trigger_error("empty pagename", E_USER_WARNING); return false; } } else assert(is_string($pagename) and $pagename != ''); - if ((int)DEBUG) { + if (DEBUG) { if (!is_array($versiondata)) { trigger_error("empty versiondata", E_USER_WARNING); return false; } } else assert(is_array($versiondata)); - if ((int)DEBUG) { + if (DEBUG) { if (!($version > 0)) { trigger_error("invalid version", E_USER_WARNING); return false; @@ -2204,7 +2190,7 @@ { assert(is_string($pagename) && $pagename != ''); if (!empty($this->readonly)) { - if ((int)DEBUG) { + if (DEBUG) { trigger_error("readonly database", E_USER_WARNING); } return; @@ -2234,7 +2220,7 @@ public function delete_page($pagename) { if (!empty($this->readonly)) { - if ((int)DEBUG) { + if (DEBUG) { trigger_error("readonly database", E_USER_WARNING); } return false; @@ -2247,7 +2233,7 @@ public function purge_page($pagename) { if (!empty($this->readonly)) { - if ((int)DEBUG) { + if (DEBUG) { trigger_error("readonly database", E_USER_WARNING); } return false; @@ -2299,7 +2285,7 @@ //unset($this->_versiondata_cache[$pagename][$version]); if (!empty($this->readonly)) { - if ((int)DEBUG) { + if (DEBUG) { trigger_error("readonly database", E_USER_WARNING); } return; @@ -2315,7 +2301,7 @@ public function update_versiondata($pagename, $version, $data) { if (!empty($this->readonly)) { - if ((int)DEBUG) { + if (DEBUG) { trigger_error("readonly database", E_USER_WARNING); } return; @@ -2332,7 +2318,7 @@ public function delete_versiondata($pagename, $version) { if (!empty($this->readonly)) { - if ((int)DEBUG) { + if (DEBUG) { trigger_error("readonly database", E_USER_WARNING); } return; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <var...@us...> - 2022-02-05 17:08:08
|
Revision: 10981 http://sourceforge.net/p/phpwiki/code/10981 Author: vargenau Date: 2022-02-05 17:08:06 +0000 (Sat, 05 Feb 2022) Log Message: ----------- WantedPages plugin: handle exclude_from argument in lib/plugin/WantedPages.php Modified Paths: -------------- trunk/lib/WikiDB/backend/PDO.php trunk/lib/WikiDB/backend/PearDB.php trunk/lib/WikiDB/backend/PearDB_ffpgsql.php trunk/lib/WikiDB/backend/PearDB_mysqli.php trunk/lib/plugin/WantedPages.php Modified: trunk/lib/WikiDB/backend/PDO.php =================================================================== --- trunk/lib/WikiDB/backend/PDO.php 2022-02-03 20:03:12 UTC (rev 10980) +++ trunk/lib/WikiDB/backend/PDO.php 2022-02-05 17:08:06 UTC (rev 10981) @@ -1078,9 +1078,6 @@ 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); } @@ -1099,7 +1096,6 @@ . " LEFT JOIN $nonempty_tbl ne ON linked.linkto = ne.id" . " WHERE ne.id IS NULL" . " AND p.id = linked.linkfrom" - . $exclude_from . $exclude . $orderby; if ($limit) { Modified: trunk/lib/WikiDB/backend/PearDB.php =================================================================== --- trunk/lib/WikiDB/backend/PearDB.php 2022-02-03 20:03:12 UTC (rev 10980) +++ trunk/lib/WikiDB/backend/PearDB.php 2022-02-05 17:08:06 UTC (rev 10981) @@ -881,9 +881,6 @@ 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); } @@ -894,7 +891,6 @@ . " LEFT JOIN $nonempty_tbl ne ON linked.linkto = ne.id" . " WHERE ne.id IS NULL" . " AND p.id = linked.linkfrom" - . $exclude_from . $exclude . $orderby; if ($limit) { Modified: trunk/lib/WikiDB/backend/PearDB_ffpgsql.php =================================================================== --- trunk/lib/WikiDB/backend/PearDB_ffpgsql.php 2022-02-03 20:03:12 UTC (rev 10980) +++ trunk/lib/WikiDB/backend/PearDB_ffpgsql.php 2022-02-05 17:08:06 UTC (rev 10981) @@ -560,8 +560,6 @@ if ($orderby = $this->sortby($sortby, 'db', array('pagename', 'wantedfrom'))) $orderby = 'ORDER BY ' . $orderby; - if ($exclude_from) // array of pagenames - $exclude_from = " AND substring(p.pagename from $p) NOT IN " . $this->_sql_set($exclude_from); if ($exclude) // array of pagenames $exclude = " AND substring(p.pagename from $p) NOT IN " . $this->_sql_set($exclude); $sql = "SELECT substring(pp.pagename from $p) AS wantedfrom, substring(p.pagename from $p) AS pagename" @@ -572,7 +570,6 @@ . " AND p.id = linked.linkfrom" . " AND substring(p.pagename from 0 for $p) = '$page_prefix'" . " AND substring(pp.pagename from 0 for $p) = '$page_prefix'" - . $exclude_from . $exclude . $orderby; if ($limit) { Modified: trunk/lib/WikiDB/backend/PearDB_mysqli.php =================================================================== --- trunk/lib/WikiDB/backend/PearDB_mysqli.php 2022-02-03 20:03:12 UTC (rev 10980) +++ trunk/lib/WikiDB/backend/PearDB_mysqli.php 2022-02-05 17:08:06 UTC (rev 10981) @@ -112,8 +112,6 @@ 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); @@ -124,7 +122,6 @@ . " LEFT JOIN $nonempty_tbl ne ON (linked.linkto = ne.id)" . " WHERE ISNULL(ne.id)" . " AND p.id = linked.linkfrom" - . $exclude_from . $exclude . $orderby; if ($limit) { Modified: trunk/lib/plugin/WantedPages.php =================================================================== --- trunk/lib/plugin/WantedPages.php 2022-02-03 20:03:12 UTC (rev 10980) +++ trunk/lib/plugin/WantedPages.php 2022-02-05 17:08:06 UTC (rev 10981) @@ -124,13 +124,15 @@ while ($row = $wanted_iter->next()) { $wantedfrom = $row['pagename']; $wanted = $row['wantedfrom']; - // ignore duplicates: - if (empty($pagelist->_wpagelist[$wanted])) - $pagelist->addPage($wanted); - if (!isset($pagelist->_wpagelist[$wanted])) - $pagelist->_wpagelist[$wanted][] = $wantedfrom; - elseif (!in_array($wantedfrom, $pagelist->_wpagelist[$wanted])) - $pagelist->_wpagelist[$wanted][] = $wantedfrom; + if (!in_array($wantedfrom, $exclude_from)) { + // ignore duplicates: + if (empty($pagelist->_wpagelist[$wanted])) + $pagelist->addPage($wanted); + if (!isset($pagelist->_wpagelist[$wanted])) + $pagelist->_wpagelist[$wanted][] = $wantedfrom; + elseif (!in_array($wantedfrom, $pagelist->_wpagelist[$wanted])) + $pagelist->_wpagelist[$wanted][] = $wantedfrom; + } } $wanted_iter->free(); unset($wanted_iter); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <var...@us...> - 2022-02-05 17:15:27
|
Revision: 10982 http://sourceforge.net/p/phpwiki/code/10982 Author: vargenau Date: 2022-02-05 17:15:23 +0000 (Sat, 05 Feb 2022) Log Message: ----------- Remove exclude_from argument from functions wanted_pages and wantedPages Modified Paths: -------------- trunk/lib/WikiDB/backend/PDO.php trunk/lib/WikiDB/backend/PearDB.php trunk/lib/WikiDB/backend/PearDB_ffpgsql.php trunk/lib/WikiDB/backend/PearDB_mysqli.php trunk/lib/WikiDB/backend.php trunk/lib/WikiDB.php trunk/lib/plugin/WantedPages.php Modified: trunk/lib/WikiDB/backend/PDO.php =================================================================== --- trunk/lib/WikiDB/backend/PDO.php 2022-02-05 17:08:06 UTC (rev 10981) +++ trunk/lib/WikiDB/backend/PDO.php 2022-02-05 17:15:23 UTC (rev 10982) @@ -1071,7 +1071,7 @@ /* * Find referenced empty pages. */ - function wanted_pages($exclude_from = '', $exclude = '', $sortby = '', $limit = '') + function wanted_pages($exclude = '', $sortby = '', $limit = '') { $dbh = &$this->_dbh; extract($this->_table_names); Modified: trunk/lib/WikiDB/backend/PearDB.php =================================================================== --- trunk/lib/WikiDB/backend/PearDB.php 2022-02-05 17:08:06 UTC (rev 10981) +++ trunk/lib/WikiDB/backend/PearDB.php 2022-02-05 17:15:23 UTC (rev 10982) @@ -874,7 +874,7 @@ /* * Find referenced empty pages. */ - function wanted_pages($exclude_from = '', $exclude = '', $sortby = '', $limit = '') + function wanted_pages($exclude = '', $sortby = '', $limit = '') { $dbh = &$this->_dbh; extract($this->_table_names); Modified: trunk/lib/WikiDB/backend/PearDB_ffpgsql.php =================================================================== --- trunk/lib/WikiDB/backend/PearDB_ffpgsql.php 2022-02-05 17:08:06 UTC (rev 10981) +++ trunk/lib/WikiDB/backend/PearDB_ffpgsql.php 2022-02-05 17:15:23 UTC (rev 10982) @@ -551,7 +551,7 @@ /* * Find referenced empty pages. */ - function wanted_pages($exclude_from = '', $exclude = '', $sortby = '', $limit = '') + function wanted_pages($exclude = '', $sortby = '', $limit = '') { $dbh = &$this->_dbh; extract($this->_table_names); Modified: trunk/lib/WikiDB/backend/PearDB_mysqli.php =================================================================== --- trunk/lib/WikiDB/backend/PearDB_mysqli.php 2022-02-05 17:08:06 UTC (rev 10981) +++ trunk/lib/WikiDB/backend/PearDB_mysqli.php 2022-02-05 17:15:23 UTC (rev 10982) @@ -105,7 +105,7 @@ /* * Find referenced empty pages. */ - function wanted_pages($exclude_from = '', $exclude = '', $sortby = '', $limit = '') + function wanted_pages($exclude = '', $sortby = '', $limit = '') { $dbh = &$this->_dbh; extract($this->_table_names); Modified: trunk/lib/WikiDB/backend.php =================================================================== --- trunk/lib/WikiDB/backend.php 2022-02-05 17:08:06 UTC (rev 10981) +++ trunk/lib/WikiDB/backend.php 2022-02-05 17:15:23 UTC (rev 10982) @@ -403,7 +403,7 @@ return new WikiDB_backend_dumb_MostRecentIter($this, $pages, $params); } - public function wanted_pages($exclude_from = '', $exclude = '', $sortby = '', $limit = '') + public function wanted_pages($exclude = '', $sortby = '', $limit = '') { include_once 'lib/WikiDB/backend/dumb/WantedPagesIter.php'; $allpages = $this->get_all_pages(true, false, false, $exclude_from); Modified: trunk/lib/WikiDB.php =================================================================== --- trunk/lib/WikiDB.php 2022-02-05 17:08:06 UTC (rev 10981) +++ trunk/lib/WikiDB.php 2022-02-05 17:15:23 UTC (rev 10982) @@ -442,7 +442,6 @@ } /** - * @param string $exclude_from * @param string $exclude * @param string $sortby Optional. "+-column,+-column2". * If false the result is faster in natural order. @@ -451,9 +450,9 @@ * @return WikiDB_backend_dumb_WantedPagesIter A generic iterator containing rows of * (duplicate) pagename, wantedfrom. */ - public function wantedPages($exclude_from = '', $exclude = '', $sortby = '', $limit = '') + public function wantedPages($exclude = '', $sortby = '', $limit = '') { - return $this->_backend->wanted_pages($exclude_from, $exclude, $sortby, $limit); + return $this->_backend->wanted_pages($exclude, $sortby, $limit); } /** Modified: trunk/lib/plugin/WantedPages.php =================================================================== --- trunk/lib/plugin/WantedPages.php 2022-02-05 17:08:06 UTC (rev 10981) +++ trunk/lib/plugin/WantedPages.php 2022-02-05 17:15:23 UTC (rev 10982) @@ -120,7 +120,7 @@ if (!$page) { list($offset, $maxcount) = $pagelist->limit($limit); - $wanted_iter = $dbi->wantedPages($exclude_from, $exclude, $sortby, $limit); + $wanted_iter = $dbi->wantedPages($exclude, $sortby, $limit); while ($row = $wanted_iter->next()) { $wantedfrom = $row['pagename']; $wanted = $row['wantedfrom']; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <var...@us...> - 2022-02-07 12:08:19
|
Revision: 10985 http://sourceforge.net/p/phpwiki/code/10985 Author: vargenau Date: 2022-02-07 12:08:16 +0000 (Mon, 07 Feb 2022) Log Message: ----------- Same prototype for get_all_pages Modified Paths: -------------- trunk/lib/WikiDB/backend.php trunk/lib/WikiDB.php Modified: trunk/lib/WikiDB/backend.php =================================================================== --- trunk/lib/WikiDB/backend.php 2022-02-05 17:52:43 UTC (rev 10984) +++ trunk/lib/WikiDB/backend.php 2022-02-07 12:08:16 UTC (rev 10985) @@ -303,7 +303,7 @@ * @param string $exclude * @return object A WikiDB_backend_iterator. */ - abstract function get_all_pages($include_empty, + abstract function get_all_pages($include_empty = false, $sortby = '', $limit = '', $exclude = ''); /** @@ -336,7 +336,7 @@ // this method with something more efficient. include_once 'lib/WikiDB/backend/dumb/TextSearchIter.php'; // ignore $limit - $pages = $this->get_all_pages(false, $sortby, false, $exclude); + $pages = $this->get_all_pages(false, $sortby, '', $exclude); return new WikiDB_backend_dumb_TextSearchIter($this, $pages, $search, $fulltext, array('limit' => $limit, 'exclude' => $exclude)); @@ -379,7 +379,7 @@ // It is expected that most backends will overload // method with something more efficient. include_once 'lib/WikiDB/backend/dumb/MostPopularIter.php'; - $pages = $this->get_all_pages(false, $sortby, false); + $pages = $this->get_all_pages(false, $sortby); return new WikiDB_backend_dumb_MostPopularIter($this, $pages, $limit); } @@ -406,7 +406,7 @@ public function wanted_pages($exclude = '', $sortby = '', $limit = '') { include_once 'lib/WikiDB/backend/dumb/WantedPagesIter.php'; - $allpages = $this->get_all_pages(true, false, false, $exclude_from); + $allpages = $this->get_all_pages(); return new WikiDB_backend_dumb_WantedPagesIter($this, $allpages, $exclude, $sortby, $limit); } Modified: trunk/lib/WikiDB.php =================================================================== --- trunk/lib/WikiDB.php 2022-02-05 17:52:43 UTC (rev 10984) +++ trunk/lib/WikiDB.php 2022-02-07 12:08:16 UTC (rev 10985) @@ -301,8 +301,7 @@ */ public function getAllPages($include_empty = false, $sortby = '', $limit = '', $exclude = '') { - $result = $this->_backend->get_all_pages($include_empty, $sortby, $limit, - $exclude); + $result = $this->_backend->get_all_pages($include_empty, $sortby, $limit, $exclude); return new WikiDB_PageIterator($this, $result, array('include_empty' => $include_empty, 'exclude' => $exclude, @@ -444,7 +443,7 @@ /** * @param string $exclude * @param string $sortby Optional. "+-column,+-column2". - * If false the result is faster in natural order. + * If empty string the result is faster in natural order. * @param string $limit Optional. Encoded as "$offset,$count". * $offset defaults to 0. * @return WikiDB_backend_dumb_WantedPagesIter A generic iterator containing rows of This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <var...@us...> - 2022-02-07 15:10:25
|
Revision: 10986 http://sourceforge.net/p/phpwiki/code/10986 Author: vargenau Date: 2022-02-07 15:10:22 +0000 (Mon, 07 Feb 2022) Log Message: ----------- Make WantedPages work for DATABASE_TYPE = dba and file Modified Paths: -------------- trunk/lib/WikiDB/backend/PDO.php trunk/lib/WikiDB/backend/PearDB.php trunk/lib/WikiDB/backend/PearDB_mysqli.php trunk/lib/plugin/WantedPages.php Modified: trunk/lib/WikiDB/backend/PDO.php =================================================================== --- trunk/lib/WikiDB/backend/PDO.php 2022-02-07 12:08:16 UTC (rev 10985) +++ trunk/lib/WikiDB/backend/PDO.php 2022-02-07 15:10:22 UTC (rev 10986) @@ -1090,7 +1090,7 @@ 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" + $sql = "SELECT p.pagename AS wantedfrom, pp.pagename AS pagename" . " 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" Modified: trunk/lib/WikiDB/backend/PearDB.php =================================================================== --- trunk/lib/WikiDB/backend/PearDB.php 2022-02-07 12:08:16 UTC (rev 10985) +++ trunk/lib/WikiDB/backend/PearDB.php 2022-02-07 15:10:22 UTC (rev 10986) @@ -885,7 +885,7 @@ $exclude = " AND p.pagename NOT IN " . $this->_sql_set($exclude); } - $sql = "SELECT p.pagename, pp.pagename AS wantedfrom" + $sql = "SELECT p.pagename AS wantedfrom, pp.pagename AS pagename" . " 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" Modified: trunk/lib/WikiDB/backend/PearDB_mysqli.php =================================================================== --- trunk/lib/WikiDB/backend/PearDB_mysqli.php 2022-02-07 12:08:16 UTC (rev 10985) +++ trunk/lib/WikiDB/backend/PearDB_mysqli.php 2022-02-07 15:10:22 UTC (rev 10986) @@ -112,11 +112,12 @@ if ($orderby = $this->sortby($sortby, 'db', array('pagename', 'wantedfrom'))) $orderby = 'ORDER BY ' . $orderby; - if ($exclude) // array of pagenames + if ($exclude) { // array of pagenames $exclude = " AND p.pagename NOT IN " . $this->_sql_set($exclude); + } /* ISNULL is mysql specific */ - $sql = "SELECT p.pagename, pp.pagename AS wantedfrom" + $sql = "SELECT p.pagename AS wantedfrom, pp.pagename AS pagename" . " 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)" Modified: trunk/lib/plugin/WantedPages.php =================================================================== --- trunk/lib/plugin/WantedPages.php 2022-02-07 12:08:16 UTC (rev 10985) +++ trunk/lib/plugin/WantedPages.php 2022-02-07 15:10:22 UTC (rev 10986) @@ -122,8 +122,8 @@ list($offset, $maxcount) = $pagelist->limit($limit); $wanted_iter = $dbi->wantedPages($exclude, $sortby, $limit); while ($row = $wanted_iter->next()) { - $wantedfrom = $row['pagename']; - $wanted = $row['wantedfrom']; + $wantedfrom = $row['wantedfrom']; + $wanted = $row['pagename']; if (!in_array($wantedfrom, $exclude_from)) { // ignore duplicates: if (empty($pagelist->_wpagelist[$wanted])) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <var...@us...> - 2022-02-15 15:16:13
|
Revision: 10998 http://sourceforge.net/p/phpwiki/code/10998 Author: vargenau Date: 2022-02-15 15:16:11 +0000 (Tue, 15 Feb 2022) Log Message: ----------- function getWikiPageLinks returns empty array instead of false Modified Paths: -------------- trunk/lib/CachedMarkup.php trunk/lib/WikiPlugin.php Modified: trunk/lib/CachedMarkup.php =================================================================== --- trunk/lib/CachedMarkup.php 2022-02-15 15:10:30 UTC (rev 10997) +++ trunk/lib/CachedMarkup.php 2022-02-15 15:16:11 UTC (rev 10998) @@ -253,7 +253,7 @@ function getWikiPageLinks($basepage) { - return false; + return array(); } } @@ -372,14 +372,17 @@ function getWikiPageLinks($basepage) { - if ($basepage == '') - return false; - if (isset($this->_nolink)) - return false; - if ($link = $this->getPagename($basepage)) + if ($basepage == '') { + return array(); + } + if (isset($this->_nolink)) { + return array(); + } + if ($link = $this->getPagename($basepage)) { return array(array('linkto' => $link)); - else - return false; + } else { + return array(); + } } function _getName($basepage) @@ -554,7 +557,9 @@ */ global $request; - if ($basepage == '') return false; + if ($basepage == '') { + return array(); + } 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 @@ -563,10 +568,11 @@ $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; + } else { + return array(); + } } function _expandurl($url) Modified: trunk/lib/WikiPlugin.php =================================================================== --- trunk/lib/WikiPlugin.php 2022-02-15 15:10:30 UTC (rev 10997) +++ trunk/lib/WikiPlugin.php 2022-02-15 15:16:11 UTC (rev 10998) @@ -84,11 +84,11 @@ * * @param string $argstr The plugin argument string. * @param string $basepage The pagename the plugin is invoked from. - * @return array|false List of pagenames linked to (or false). + * @return array List of pagenames linked to. */ function getWikiPageLinks($argstr, $basepage) { - return false; + return array(); } /** @@ -529,13 +529,16 @@ function getWikiPageLinks($pi, $basepage) { - if (!($ppi = $this->parsePI($pi))) - return false; + if (!($ppi = $this->parsePI($pi))) { + return array(); + } list($pi_name, $plugin, $plugin_args) = $ppi; - if (!is_object($plugin)) - return false; - if ($pi_name != 'plugin') - return false; + if (!is_object($plugin)) { + return array(); + } + if ($pi_name != 'plugin') { + return array(); + } return $plugin->getWikiPageLinks($plugin_args, $basepage); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <var...@us...> - 2022-02-16 16:53:31
|
Revision: 11003 http://sourceforge.net/p/phpwiki/code/11003 Author: vargenau Date: 2022-02-16 16:53:28 +0000 (Wed, 16 Feb 2022) Log Message: ----------- Use count instead of sizeof Modified Paths: -------------- trunk/lib/diff3.php trunk/lib/difflib.php trunk/lib/mimelib.php trunk/lib/plugin/Chart.php trunk/lib/plugin/DebugGroupInfo.php trunk/lib/plugin/WikicreoleTable.php Modified: trunk/lib/diff3.php =================================================================== --- trunk/lib/diff3.php 2022-02-15 18:23:37 UTC (rev 11002) +++ trunk/lib/diff3.php 2022-02-16 16:53:28 UTC (rev 11003) @@ -102,7 +102,7 @@ private function append(&$array, $lines) { - array_splice($array, sizeof($array), 0, $lines); + array_splice($array, count($array), 0, $lines); } public function input($lines) Modified: trunk/lib/difflib.php =================================================================== --- trunk/lib/difflib.php 2022-02-15 18:23:37 UTC (rev 11002) +++ trunk/lib/difflib.php 2022-02-16 16:53:28 UTC (rev 11003) @@ -36,12 +36,12 @@ public function norig() { - return $this->orig ? sizeof($this->orig) : 0; + return $this->orig ? count($this->orig) : 0; } public function nfinal() { - return $this->final ? sizeof($this->final) : 0; + return $this->final ? count($this->final) : 0; } } @@ -145,8 +145,8 @@ public function diff($from_lines, $to_lines) { - $n_from = sizeof($from_lines); - $n_to = sizeof($to_lines); + $n_from = count($from_lines); + $n_to = count($to_lines); $this->xchanged = $this->ychanged = array(); $this->xv = $this->yv = array(); @@ -190,7 +190,7 @@ } // Find the LCS. - $this->compareseq(0, sizeof($this->xv), 0, sizeof($this->yv)); + $this->compareseq(0, count($this->xv), 0, count($this->yv)); // Merge edits when possible $this->shift_boundaries($from_lines, $this->xchanged, $this->ychanged); @@ -421,9 +421,9 @@ $i = 0; $j = 0; - assert('sizeof($lines) == sizeof($changed)'); - $len = sizeof($lines); - $other_len = sizeof($other_changed); + assert('count($lines) == count($changed)'); + $len = count($lines); + $other_len = count($other_changed); while (1) { /* @@ -574,7 +574,7 @@ foreach ($this->edits as $edit) { if ($edit->orig) - array_splice($lines, sizeof($lines), 0, $edit->orig); + array_splice($lines, count($lines), 0, $edit->orig); } return $lines; } @@ -593,7 +593,7 @@ foreach ($this->edits as $edit) { if ($edit->final) - array_splice($lines, sizeof($lines), 0, $edit->final); + array_splice($lines, count($lines), 0, $edit->final); } return $lines; } @@ -630,8 +630,8 @@ $mapped_from_lines, $mapped_to_lines) { - assert(sizeof($from_lines) == sizeof($mapped_from_lines)); - assert(sizeof($to_lines) == sizeof($mapped_to_lines)); + assert(count($from_lines) == count($mapped_from_lines)); + assert(count($to_lines) == count($mapped_to_lines)); parent::__construct($mapped_from_lines, $mapped_to_lines); @@ -638,17 +638,17 @@ $xi = $yi = 0; // Optimizing loop invariants: // http://phplens.com/lens/php-book/optimizing-debugging-php.php - for ($i = 0, $max = sizeof($this->edits); $i < $max; $i++) { + for ($i = 0, $max = count($this->edits); $i < $max; $i++) { $orig = &$this->edits[$i]->orig; if (is_array($orig)) { - $orig = array_slice($from_lines, $xi, sizeof($orig)); - $xi += sizeof($orig); + $orig = array_slice($from_lines, $xi, count($orig)); + $xi += count($orig); } $final = &$this->edits[$i]->final; if (is_array($final)) { - $final = array_slice($to_lines, $yi, sizeof($final)); - $yi += sizeof($final); + $final = array_slice($to_lines, $yi, count($final)); + $yi += count($final); } } } @@ -702,7 +702,7 @@ foreach ($diff->edits as $edit) { if ($edit->type == 'copy') { if (is_array($block)) { - if (sizeof($edit->orig) <= $nlead + $ntrail) { + if (count($edit->orig) <= $nlead + $ntrail) { $block[] = $edit; } else { if ($ntrail) { @@ -718,9 +718,9 @@ $context = $edit->orig; } else { if (!is_array($block)) { - $context = array_slice($context, max(0, sizeof($context) - $nlead)); - $x0 = $xi - sizeof($context); - $y0 = $yi - sizeof($context); + $context = array_slice($context, max(0, count($context) - $nlead)); + $x0 = $xi - count($context); + $y0 = $yi - count($context); $block = array(); if ($context) $block[] = new DiffOp_Copy($context); @@ -729,9 +729,9 @@ } if ($edit->orig) - $xi += sizeof($edit->orig); + $xi += count($edit->orig); if ($edit->final) - $yi += sizeof($edit->final); + $yi += count($edit->final); } if (is_array($block)) Modified: trunk/lib/mimelib.php =================================================================== --- trunk/lib/mimelib.php 2022-02-15 18:23:37 UTC (rev 11002) +++ trunk/lib/mimelib.php 2022-02-16 16:53:28 UTC (rev 11003) @@ -282,7 +282,7 @@ $m[1], rawurldecode($reference)); } - if (sizeof($footnotes) > 0) { + if (count($footnotes) > 0) { ksort($footnotes); return "-----\n" . "!" . _("References") . "\n" Modified: trunk/lib/plugin/Chart.php =================================================================== --- trunk/lib/plugin/Chart.php 2022-02-15 18:23:37 UTC (rev 11002) +++ trunk/lib/plugin/Chart.php 2022-02-16 16:53:28 UTC (rev 11003) @@ -101,7 +101,7 @@ // y_min = 0 or smallest element in data if negative // y_max = biggest element in data - $x_max = sizeof($values) + 1; + $x_max = count($values) + 1; $y_min = min($values); if ($y_min > 0) { $y_min = 0; Modified: trunk/lib/plugin/DebugGroupInfo.php =================================================================== --- trunk/lib/plugin/DebugGroupInfo.php 2022-02-15 18:23:37 UTC (rev 11002) +++ trunk/lib/plugin/DebugGroupInfo.php 2022-02-16 16:53:28 UTC (rev 11003) @@ -59,7 +59,7 @@ foreach ($allGroups as $g) { $members = $group->getMembersOf($g); $output->pushContent(HTML::h2($g . " - members: " . - sizeof($members) . " - isMember: " . ($group->isMember($g) ? "yes" : "no") + count($members) . " - isMember: " . ($group->isMember($g) ? "yes" : "no") )); $list = HTML::ul(); foreach ($members as $m) { Modified: trunk/lib/plugin/WikicreoleTable.php =================================================================== --- trunk/lib/plugin/WikicreoleTable.php 2022-02-15 18:23:37 UTC (rev 11002) +++ trunk/lib/plugin/WikicreoleTable.php 2022-02-16 16:53:28 UTC (rev 11003) @@ -96,7 +96,7 @@ } } - $nb_rows = sizeof($table); + $nb_rows = count($table); // If table is empty, do not generate table markup if ($nb_rows == 0) { return HTML::raw(''); @@ -105,7 +105,7 @@ // Number of columns is the number of cells in the longer row $nb_cols = 0; for ($i = 0; $i < $nb_rows; $i++) { - $nb_cols = max($nb_cols, sizeof($table[$i])); + $nb_cols = max($nb_cols, count($table[$i])); } for ($i = 0; $i < $nb_rows; $i++) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <var...@us...> - 2022-03-24 13:32:28
|
Revision: 11009 http://sourceforge.net/p/phpwiki/code/11009 Author: vargenau Date: 2022-03-24 13:32:25 +0000 (Thu, 24 Mar 2022) Log Message: ----------- run php-cs-fixer Modified Paths: -------------- trunk/lib/AtomParser.php trunk/lib/BlockParser.php trunk/lib/CachedMarkup.php trunk/lib/Captcha.php trunk/lib/DbSession.php trunk/lib/DbaDatabase.php trunk/lib/DbaPartition.php trunk/lib/ErrorManager.php trunk/lib/ExternalReferrer.php trunk/lib/FileFinder.php trunk/lib/Google.php trunk/lib/HtmlElement.php trunk/lib/HtmlParser.php trunk/lib/HttpClient.php trunk/lib/IniConfig.php trunk/lib/InlineParser.php trunk/lib/MailNotify.php trunk/lib/PageList.php trunk/lib/PagePerm.php trunk/lib/PageType.php trunk/lib/PhpWikiXmlParser.php trunk/lib/Request.php trunk/lib/RssParser.php trunk/lib/RssWriter.php trunk/lib/RssWriter091.php trunk/lib/RssWriter2.php trunk/lib/SemanticWeb.php trunk/lib/SpamBlocklist.php trunk/lib/Template.php trunk/lib/TextSearchQuery.php trunk/lib/Units.php trunk/lib/WikiCallback.php trunk/lib/WikiDB.php trunk/lib/WikiGroup.php trunk/lib/WikiPlugin.php trunk/lib/WikiPluginCached.php trunk/lib/WikiTheme.php trunk/lib/WikiUser.php trunk/lib/WysiwygEdit.php trunk/lib/XmlElement.php trunk/lib/XmlRpcClient.php trunk/lib/XmlRpcServer.php trunk/lib/config.php trunk/lib/diff.php trunk/lib/diff3.php trunk/lib/difflib.php trunk/lib/display.php trunk/lib/editpage.php trunk/lib/fortune.php trunk/lib/imagecache.php trunk/lib/install.php trunk/lib/loadsave.php trunk/lib/main.php trunk/lib/mimelib.php trunk/lib/pdf.php trunk/lib/prepend.php trunk/lib/purgepage.php trunk/lib/removepage.php trunk/lib/spam_babycart.php trunk/lib/stdlib.php trunk/lib/upgrade.php Modified: trunk/lib/AtomParser.php =================================================================== --- trunk/lib/AtomParser.php 2022-03-24 13:28:33 UTC (rev 11008) +++ trunk/lib/AtomParser.php 2022-03-24 13:32:25 UTC (rev 11009) @@ -30,8 +30,7 @@ */ require_once 'lib/PhpWikiXmlParser.php'; -class AtomParser - extends PhpWikiXmlParser +class AtomParser extends PhpWikiXmlParser { // Feed public $feed = array(); @@ -70,7 +69,7 @@ public $inside_content = false; public $content = ''; - function tag_open($parser, $name, $attrs = '') + public function tag_open($parser, $name, $attrs = '') { global $current_tag, $current_attrs; @@ -86,7 +85,7 @@ } } - function tag_close($parser, $name, $attrs = '') + public function tag_close($parser, $name, $attrs = '') { if ($name == "AUTHOR") { $an_author = $this->trim_data(array( @@ -167,7 +166,7 @@ } } - function cdata($parser, $data) + public function cdata($parser, $data) { global $current_tag, $current_attrs; @@ -176,10 +175,11 @@ } else { switch ($current_tag) { case "ID": - if ($this->inside_entry) + if ($this->inside_entry) { $this->id .= $data; - else + } else { $this->feed_id .= $data; + } break; case "LINK": $a_link = array(); @@ -198,17 +198,19 @@ case "EMAIL": $this->email .= $data; break; - case "TITLE" : - if ($this->inside_entry) + case "TITLE": + if ($this->inside_entry) { $this->title .= $data; - else + } else { $this->feed_title .= $data; + } break; case "UPDATED": - if ($this->inside_entry) + if ($this->inside_entry) { $this->updated .= $data; - else + } else { $this->feed_updated .= $data; + } break; case "SUBTITLE": $this->feed_subtitle .= $data; @@ -238,12 +240,12 @@ } } - function trim_data($array) + public function trim_data($array) { return array_map(array("self", "trim_element"), $array); } - function trim_element($element) + public function trim_element($element) { if (is_array($element)) { return $this->trim_data($element); @@ -253,7 +255,7 @@ return false; } - function serialize_tag($tag_name, $attributes) + public function serialize_tag($tag_name, $attributes) { $tag = "<" . $tag_name; foreach ($attributes as $k => $v) { Modified: trunk/lib/BlockParser.php =================================================================== --- trunk/lib/BlockParser.php 2022-03-24 13:28:33 UTC (rev 11008) +++ trunk/lib/BlockParser.php 2022-03-24 13:32:25 UTC (rev 11009) @@ -83,7 +83,7 @@ * "(...)". (Anonymous groups, like "(?:...)", as well as * look-ahead and look-behind assertions are fine.) */ - function __construct($regexps) + public function __construct($regexps) { $this->_regexps = $regexps; $this->_re = "/((" . join(")|(", $regexps) . "))/Ax"; @@ -96,10 +96,11 @@ * * @return AnchoredRegexpSet_match|bool An AnchoredRegexpSet_match object, or false if no match. */ - function match($text) + public function match($text) { - if (!is_string($text)) + if (!is_string($text)) { return false; + } if (!preg_match($this->_re, $text, $m)) { return false; } @@ -129,7 +130,7 @@ * * @return AnchoredRegexpSet_match|bool An AnchoredRegexpSet_match object, or false if no match. */ - function nextMatch($text, $prevMatch) + public function nextMatch($text, $prevMatch) { // Try to find match at same position. $regexps = array_slice($this->_regexps, $prevMatch->regexp_ind + 1); @@ -154,8 +155,7 @@ class BlockParser_Input { - - function __construct($text) + public function __construct($text) { // Expand leading tabs. // FIXME: do this better. @@ -169,12 +169,13 @@ $this->_pos = 0; // Strip leading blank lines. - while ($this->_lines and !$this->_lines[0]) + while ($this->_lines and !$this->_lines[0]) { array_shift($this->_lines); + } $this->_atSpace = false; } - function skipSpace() + public function skipSpace() { $nlines = count($this->_lines); while (1) { @@ -182,8 +183,9 @@ $this->_atSpace = false; break; } - if ($this->_lines[$this->_pos] != '') + if ($this->_lines[$this->_pos] != '') { break; + } $this->_pos++; $this->_atSpace = true; } @@ -190,7 +192,7 @@ return $this->_atSpace; } - function currentLine() + public function currentLine() { if ($this->_pos >= count($this->_lines)) { return false; @@ -198,7 +200,7 @@ return $this->_lines[$this->_pos]; } - function nextLine() + public function nextLine() { $this->_atSpace = $this->_lines[$this->_pos++] === ''; if ($this->_pos >= count($this->_lines)) { @@ -207,48 +209,51 @@ return $this->_lines[$this->_pos]; } - function advance() + public function advance() { $this->_atSpace = ($this->_lines[$this->_pos] === ''); $this->_pos++; } - function getPos() + public function getPos() { return array($this->_pos, $this->_atSpace); } - function setPos($pos) + public function setPos($pos) { list($this->_pos, $this->_atSpace) = $pos; } - function getPrefix() + public function getPrefix() { return ''; } - function getDepth() + public function getDepth() { return 0; } - function where() + public function where() { - if ($this->_pos < count($this->_lines)) + if ($this->_pos < count($this->_lines)) { return $this->_lines[$this->_pos]; - else + } else { return "<EOF>"; + } } - function _debug($tab, $msg) + public function _debug($tab, $msg) { //return ; $where = $this->where(); $tab = str_repeat('____', $this->getDepth()) . $tab; - PrintXML(HTML::div("$tab $msg: at: '", + PrintXML(HTML::div( + "$tab $msg: at: '", HTML::samp($where), - "'")); + "'" + )); flush(); } } @@ -260,15 +265,15 @@ * @param string $prefix_re * @param string $initial_prefix */ - function __construct(&$input, $prefix_re, $initial_prefix = '') + public function __construct(&$input, $prefix_re, $initial_prefix = '') { $this->_input = &$input; $this->_prefix_pat = "/$prefix_re|\\s*\$/Ax"; $this->_atSpace = false; - if (($line = $input->currentLine()) === false) + if (($line = $input->currentLine()) === false) { $this->_line = false; - elseif ($initial_prefix) { + } elseif ($initial_prefix) { assert(substr($line, 0, strlen($initial_prefix)) == $initial_prefix); $this->_line = (string)substr($line, strlen($initial_prefix)); $this->_atBlank = !ltrim($line); @@ -275,57 +280,62 @@ } elseif (preg_match($this->_prefix_pat, $line, $m)) { $this->_line = (string)substr($line, strlen($m[0])); $this->_atBlank = !ltrim($line); - } else + } else { $this->_line = false; + } } - function skipSpace() + public function skipSpace() { // In contrast to the case for top-level blocks, // for sub-blocks, there never appears to be any trailing space. // (The last block in the sub-block should always be of class tight-bottom.) - while ($this->_line === '') + while ($this->_line === '') { $this->advance(); + } - if ($this->_line === false) + if ($this->_line === false) { return $this->_atSpace == 'strong_space'; - else + } else { return $this->_atSpace; + } } - function currentLine() + public function currentLine() { return $this->_line; } - function nextLine() + public function nextLine() { - if ($this->_line === '') + if ($this->_line === '') { $this->_atSpace = $this->_atBlank ? 'weak_space' : 'strong_space'; - else + } else { $this->_atSpace = false; + } $line = $this->_input->nextLine(); if ($line !== false && preg_match($this->_prefix_pat, $line, $m)) { $this->_line = (string)substr($line, strlen($m[0])); $this->_atBlank = !ltrim($line); - } else + } else { $this->_line = false; + } return $this->_line; } - function advance() + public function advance() { $this->nextLine(); } - function getPos() + public function getPos() { return array($this->_line, $this->_atSpace, $this->_input->getPos()); } - function setPos($pos) + public function setPos($pos) { $this->_line = $pos[0]; $this->_atSpace = $pos[1]; @@ -332,7 +342,7 @@ $this->_input->setPos($pos[2]); } - function getPrefix() + public function getPrefix() { assert($this->_line !== false); $line = $this->_input->currentLine(); @@ -340,12 +350,12 @@ return substr($line, 0, strlen($line) - strlen($this->_line)); } - function getDepth() + public function getDepth() { return $this->_input->getDepth() + 1; } - function where() + public function where() { return $this->_input->where(); } @@ -353,12 +363,12 @@ class Block_HtmlElement extends HtmlElement { - function __construct($tag /*, ... */) + public function __construct($tag /*, ... */) { $this->_init(func_get_args()); } - function setTightness($top, $bottom) + public function setTightness($top, $bottom) { } } @@ -370,7 +380,7 @@ private $_regexpset; private $_atSpace; - function __construct(&$input, $tag = 'div', $attr = array()) + public function __construct(&$input, $tag = 'div', $attr = array()) { parent::__construct($tag, $attr); $this->initBlockTypes(); @@ -403,8 +413,7 @@ if (!is_object($_regexpset)) { // nowiki_wikicreole must be before template_plugin - $Block_types = array - ('nowiki_wikicreole', 'template_plugin', 'placeholder', 'oldlists', 'list', 'dl', + $Block_types = array('nowiki_wikicreole', 'template_plugin', 'placeholder', 'oldlists', 'list', 'dl', 'table_dl', 'table_wikicreole', 'table_mediawiki', 'blockquote', 'heading', 'heading_wikicreole', 'hr', 'pre', 'email_blockquote', 'wikicreole_indented', @@ -417,7 +426,7 @@ } foreach ($Block_types as $type) { $class = "Block_$type"; - $proto = new $class; + $proto = new $class(); $this->_block_types[] = $proto; $this->_regexps[] = $proto->_re; } @@ -444,22 +453,26 @@ //FIXME: php5 fails to advance here! for ($m = $re_set->match($line); $m; $m = $re_set->nextMatch($line, $m)) { $block = clone($this->_block_types[$m->regexp_ind]); - if (DEBUG & _DEBUG_PARSER) + if (DEBUG & _DEBUG_PARSER) { $input->_debug('>', get_class($block)); + } if ($block->_match($input, $m)) { //$block->_text = $line; - if (DEBUG & _DEBUG_PARSER) + if (DEBUG & _DEBUG_PARSER) { $input->_debug('<', get_class($block)); + } $tight_bottom = !$input->skipSpace(); $block->_setTightness($tight_top, $tight_bottom); return $block; } - if (DEBUG & _DEBUG_PARSER) + 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'"); return false; @@ -468,7 +481,7 @@ class WikiText extends ParsedBlock { - function __construct($text) + public function __construct($text) { $input = new BlockParser_Input($text); parent::__construct($input); @@ -477,8 +490,13 @@ class SubBlock extends ParsedBlock { - function __construct(&$input, $indent_re, $initial_indent = false, - $tag = 'div', $attr = array()) + public function __construct( + &$input, + $indent_re, + $initial_indent = false, + $tag = 'div', + $attr = array() + ) { $subinput = new BlockParser_InputSubBlock($input, $indent_re, $initial_indent); parent::__construct($subinput, $tag, $attr); @@ -497,8 +515,13 @@ */ class TightSubBlock extends SubBlock { - function __construct(&$input, $indent_re, $initial_indent = false, - $tag = 'div', $attr = array()) + public function __construct( + &$input, + $indent_re, + $initial_indent = false, + $tag = 'div', + $attr = array() + ) { parent::__construct($input, $indent_re, $initial_indent, $tag, $attr); @@ -517,18 +540,18 @@ public $_re; protected $_element; - abstract function _match(&$input, $match); + abstract public function _match(&$input, $match); - function _setTightness($top, $bot) + public function _setTightness($top, $bot) { } - function merge($followingBlock) + public function merge($followingBlock) { return false; } - function finish() + public function finish() { return $this->_element; } @@ -540,22 +563,27 @@ public $_re = '\ +(?=\S)'; protected $_element; - function _match(&$input, $m) + public function _match(&$input, $m) { $this->_depth = strlen($m->match); $indent = sprintf("\\ {%d}", $this->_depth); - $this->_element = new SubBlock($input, $indent, $m->match, - 'blockquote'); + $this->_element = new SubBlock( + $input, + $indent, + $m->match, + 'blockquote' + ); return true; } - function merge($nextBlock) + public function merge($nextBlock) { if (get_class($nextBlock) == get_class($this)) { assert($nextBlock->_depth < $this->_depth); $nextBlock->_element->unshiftContent($this->_element); - if (!empty($this->_tight_top)) + if (!empty($this->_tight_top)) { $nextBlock->_tight_top = $this->_tight_top; + } return $nextBlock; } return false; @@ -574,7 +602,7 @@ public $_content = array(); public $_tag; //'ol' or 'ul' - function _match(&$input, $m) + public function _match(&$input, $m) { // A list as the first content in a list is not allowed. // E.g.: @@ -595,23 +623,27 @@ return true; } - function _setTightness($top, $bot) + public function _setTightness($top, $bot) { $li = &$this->_content[0]; $li->setTightness($top, $bot); } - function merge($nextBlock) + public function merge($nextBlock) { if (is_a($nextBlock, 'Block_list') and $this->_tag == $nextBlock->_tag) { - array_splice($this->_content, count($this->_content), 0, - $nextBlock->_content); + array_splice( + $this->_content, + count($this->_content), + 0, + $nextBlock->_content + ); return $this; } return false; } - function finish() + public function finish() { return new Block_HtmlElement($this->_tag, false, $this->_content); } @@ -622,16 +654,17 @@ public $_tag = 'dl'; private $_tight_defn; - function __construct() + public function __construct() { $this->_re = '\ {0,4}\S.*(?<!' . ESCAPE_CHAR . '):\s*$'; } - function _match(&$input, $m) + public function _match(&$input, $m) { - if (!($p = $this->_do_match($input, $m))) + if (!($p = $this->_do_match($input, $m))) { return false; - list ($term, $defn, $loose) = $p; + } + list($term, $defn, $loose) = $p; $this->_content[] = new Block_HtmlElement('dt', false, $term); $this->_content[] = $defn; @@ -639,7 +672,7 @@ return true; } - function _setTightness($top, $bot) + public function _setTightness($top, $bot) { $dt = &$this->_content[0]; $dd = &$this->_content[1]; @@ -648,7 +681,7 @@ $dd->setTightness($this->_tight_defn, $bot); } - function _do_match(&$input, $m) + public function _do_match(&$input, $m) { $pos = $input->getPos(); @@ -679,11 +712,12 @@ private $_tight_top; private $_tight_bot; - function __construct($term, $defn) + public function __construct($term, $defn) { parent::__construct(); - if (!is_array($defn)) + if (!is_array($defn)) { $defn = $defn->getContent(); + } $this->_next_tight_top = false; // value irrelevant - gets fixed later $this->_ncols = $this->ComputeNcols($defn); @@ -690,20 +724,22 @@ $this->_nrows = 0; foreach ($defn as $item) { - if ($this->IsASubtable($item)) + if ($this->IsASubtable($item)) { $this->addSubtable($item); - else + } else { $this->addToRow($item); + } } $this->flushRow(); $th = HTML::th($term); - if ($this->_nrows > 1) + if ($this->_nrows > 1) { $th->setAttr('rowspan', $this->_nrows); + } $this->_setTerm($th); } - function setTightness($tight_top, $tight_bot) + public function setTightness($tight_top, $tight_bot) { $this->_tight_top = $tight_top; $this->_tight_bot = $tight_bot; @@ -713,8 +749,9 @@ { if (empty($this->_accum)) { $this->_accum = HTML::td(); - if ($this->_ncols > 2) + if ($this->_ncols > 2) { $this->_accum->setAttr('colspan', $this->_ncols - 1); + } } $this->_accum->pushContent($item); } @@ -735,8 +772,9 @@ private function addSubtable($table) { - if (!($table_rows = $table->getContent())) + if (!($table_rows = $table->getContent())) { return; + } $this->flushRow($table_rows[0]->_tight_top); @@ -750,10 +788,11 @@ private function _setTerm($th) { $first_row = &$this->_content[0]; - if (is_a($first_row, 'Block_table_dl_defn')) + if (is_a($first_row, 'Block_table_dl_defn')) { $first_row->_setTerm($th); - else + } else { $first_row->unshiftContent($th); + } } private function ComputeNcols($defn) @@ -781,47 +820,51 @@ return $defs[0]; } - function ncols() + public function ncols() { return $this->_ncols; } - function nrows() + public function nrows() { return $this->_nrows; } - function & firstTR() + public function & firstTR() { $first = &$this->_content[0]; - if (is_a($first, 'Block_table_dl_defn')) + if (is_a($first, 'Block_table_dl_defn')) { return $first->firstTR(); + } return $first; } - function & lastTR() + public function & lastTR() { $last = &$this->_content[$this->_nrows - 1]; - if (is_a($last, 'Block_table_dl_defn')) + if (is_a($last, 'Block_table_dl_defn')) { return $last->lastTR(); + } return $last; } - function setWidth($ncols) + public function setWidth($ncols) { assert($ncols >= $this->_ncols); - if ($ncols <= $this->_ncols) + if ($ncols <= $this->_ncols) { return; + } $rows = &$this->_content; for ($i = 0; $i < count($rows); $i++) { $row = &$rows[$i]; - if (is_a($row, 'Block_table_dl_defn')) + if (is_a($row, 'Block_table_dl_defn')) { $row->setWidth($ncols - 1); - else { + } else { $n = count($row->_content); $lastcol = &$row->_content[$n - 1]; - if (!empty($lastcol)) + if (!empty($lastcol)) { $lastcol->setAttr('colspan', $ncols - 1); + } } } } @@ -831,36 +874,39 @@ { public $_tag = 'dl-table'; // phony. - function __construct() + public function __construct() { $this->_re = '\ {0,4} (?:\S.*)? (?<!' . ESCAPE_CHAR . ') \| \s* $'; } - function _match(&$input, $m) + public function _match(&$input, $m) { - if (!($p = $this->_do_match($input, $m))) + if (!($p = $this->_do_match($input, $m))) { return false; - list ($term, $defn, $loose) = $p; + } + list($term, $defn, $loose) = $p; $this->_content[] = new Block_table_dl_defn($term, $defn); return true; } - function _setTightness($top, $bot) + public function _setTightness($top, $bot) { $this->_content[0]->setTightness($top, $bot); } - function finish() + public function finish() { $defs = &$this->_content; $ncols = 0; - foreach ($defs as $defn) + foreach ($defs as $defn) { $ncols = max($ncols, $defn->ncols()); + } - foreach ($defs as $key => $defn) + foreach ($defs as $key => $defn) { $defs[$key]->setWidth($ncols); + } return HTML::table(array('class' => 'wiki-dl-table'), $defs); } @@ -874,7 +920,7 @@ | ; .*? : ) .*? (?=\S)'; - function _match(&$input, $m) + public function _match(&$input, $m) { // FIXME: if (!preg_match('/[*#;]*$/A', $input->getPrefix())) { @@ -895,11 +941,15 @@ $itemtag = 'li'; } else { $this->_tag = 'dl'; - list ($term,) = explode(':', substr($prefix, 1), 2); + list($term, ) = explode(':', substr($prefix, 1), 2); $term = trim($term); - if ($term) - $this->_content[] = new Block_HtmlElement('dt', false, - TransformInline($term)); + if ($term) { + $this->_content[] = new Block_HtmlElement( + 'dt', + false, + TransformInline($term) + ); + } $itemtag = 'dd'; } @@ -907,7 +957,7 @@ return true; } - function _setTightness($top, $bot) + public function _setTightness($top, $bot) { if (count($this->_content) == 1) { $li = &$this->_content[0]; @@ -925,7 +975,7 @@ { public $_re = '<(?:pre|verbatim|nowiki|noinclude|includeonly)>'; - function _match(&$input, $m) + public function _match(&$input, $m) { $endtag = '</' . substr($m->match, 1); $text = array(); @@ -946,10 +996,11 @@ return true; } - if ($m->match == '<nowiki>') + if ($m->match == '<nowiki>') { $text = join("<br>\n", $text); - else + } else { $text = join("\n", $text); + } if ($m->match == '<noinclude>') { $text = TransformText($text); @@ -970,7 +1021,7 @@ { public $_re = '<<<'; - function _match(&$input, $m) + public function _match(&$input, $m) { $endtag = '>>>'; $text = array(); @@ -997,7 +1048,7 @@ { public $_re = '{{{'; - function _match(&$input, $m) + public function _match(&$input, $m) { $endtag = '}}}'; $text = array(); @@ -1031,7 +1082,7 @@ * * should all work. */ - function _match(&$input, $m) + public function _match(&$input, $m) { $pos = $input->getPos(); $pi = $m->match . $m->postmatch; @@ -1054,7 +1105,7 @@ // public $_re = '<<(?!\S)'; public $_re = '<<'; - function _match(&$input, $m) + public function _match(&$input, $m) { $pos = $input->getPos(); $pi = $m->postmatch; @@ -1082,7 +1133,7 @@ { public $_re = '\s*\|'; - function _match(&$input, $m) + public function _match(&$input, $m) { $pos = $input->getPos(); $pi = "|" . $m->postmatch; @@ -1123,7 +1174,7 @@ { public $_re = '{\|'; - function _match(&$input, $m) + public function _match(&$input, $m) { $pos = $input->getPos(); $pi = $m->postmatch; @@ -1158,7 +1209,7 @@ { public $_re = '{{'; - function _match(&$input, $m) + public function _match(&$input, $m) { // If we find "}}", this is an inline template. if (strpos($m->postmatch, "}}") !== false) { @@ -1228,10 +1279,11 @@ $pi = str_replace("?version=", "\" rev=\"", $pi); } - if ($vars) + if ($vars) { $pi = '<' . '?plugin Template page="' . $pi . '" ' . $vars . ' ?>'; - else + } else { $pi = '<' . '?plugin Template page="' . $pi . '" ?>'; + } $this->_element = new Cached_PluginInvocation($pi); return true; } @@ -1242,7 +1294,7 @@ public $_attr = array('class' => 'mail-style-quote'); public $_re = '>\ ?'; - function _match(&$input, $m) + public function _match(&$input, $m) { //$indent = str_replace(' ', '\\ ', $m->match) . '|>$'; $indent = $this->_re; @@ -1256,11 +1308,16 @@ public $_attr = array('style' => 'margin-left:2em'); public $_re = ':\ ?'; - function _match(&$input, $m) + public function _match(&$input, $m) { $indent = $this->_re; - $this->_element = new SubBlock($input, $indent, $m->match, - 'div', $this->_attr); + $this->_element = new SubBlock( + $input, + $indent, + $m->match, + 'div', + $this->_attr + ); return true; } } @@ -1269,7 +1326,7 @@ { public $_re = '-{4,}\s*$'; - function _match(&$input, $m) + public function _match(&$input, $m) { $input->advance(); $this->_element = new Block_HtmlElement('hr'); @@ -1281,7 +1338,7 @@ { public $_re = '!{1,3}'; - function _match(&$input, $m) + public function _match(&$input, $m) { $tag = "h" . (5 - strlen($m->match)); $text = TransformInline(trim($m->postmatch)); @@ -1297,7 +1354,7 @@ { public $_re = '={2,6}'; - function _match(&$input, $m) + public function _match(&$input, $m) { $tag = "h" . strlen($m->match); // Remove spaces @@ -1321,7 +1378,7 @@ private $_tight_bot; private $_tight_top; - function _match(&$input, $m) + public function _match(&$input, $m) { $this->_text = $m->match; $input->advance(); @@ -1328,13 +1385,13 @@ return true; } - function _setTightness($top, $bot) + public function _setTightness($top, $bot) { $this->_tight_top = $top; $this->_tight_bot = $bot; } - function merge($nextBlock) + public function merge($nextBlock) { $class = get_class($nextBlock); if (strtolower($class) == 'block_p' and $this->_tight_bot) { @@ -1345,7 +1402,7 @@ return false; } - function finish() + public function finish() { $content = TransformInline(trim($this->_text)); $p = new Block_HtmlElement('p', false, $content); @@ -1358,7 +1415,7 @@ { public $_re = '<(?im)(?: div|span)(?:[^>]*)?>'; - function _match(&$input, $m) + public function _match(&$input, $m) { if (substr($m->match, 1, 4) == 'span') { $tag = 'span'; @@ -1370,25 +1427,29 @@ $pos = $input->getPos(); $pi = $content = $m->postmatch; while (!preg_match('/^(.*)\<\/' . $tag . '\>(.*)$/i', $pi, $me)) { - if ($pi != $content) + if ($pi != $content) { $content .= "\n$pi"; + } if (($pi = $input->nextLine()) === false) { $input->setPos($pos); return false; } } - if ($pi != $content) - $content .= $me[1]; // prematch - else + if ($pi != $content) { + $content .= $me[1]; + } // prematch + else { $content = $me[1]; + } $input->advance(); - if (strstr($content, "\n")) + if (strstr($content, "\n")) { $content = TransformText($content); - else + } else { $content = TransformInline($content); - if (!$argstr) + } + if (!$argstr) { $args = false; - else { + } else { $args = array(); while (preg_match("/(\w+)=(.+)/", $argstr, $m)) { $k = $m[1]; @@ -1401,7 +1462,9 @@ $v = $m[1]; $argstr = $m[2]; } - if (trim($k) and trim($v)) $args[$k] = $v; + if (trim($k) and trim($v)) { + $args[$k] = $v; + } } } $this->_element = new Block_HtmlElement($tag, $args, $content); Modified: trunk/lib/CachedMarkup.php =================================================================== --- trunk/lib/CachedMarkup.php 2022-03-24 13:28:33 UTC (rev 11008) +++ trunk/lib/CachedMarkup.php 2022-03-24 13:32:25 UTC (rev 11009) @@ -28,18 +28,19 @@ class CacheableMarkup extends XmlContent { - function __construct($content, $basepage) + public function __construct($content, $basepage) { $this->_basepage = $basepage; $this->_buf = ''; $this->_content = array(); $this->_append($content); - if ($this->_buf != '') + if ($this->_buf != '') { $this->_content[] = $this->_buf; + } unset($this->_buf); } - function pack() + public function pack() { // FusionForge hack // This causes a strange bug when a comment containing @@ -54,10 +55,11 @@ return gzcompress(serialize($this), 9); } - static function unpack($packed) + public static function unpack($packed) { - if (!$packed) + if (!$packed) { return false; + } // ZLIB format has a five bit checksum in its header. // Let's check for sanity. @@ -64,8 +66,7 @@ if (((ord($packed[0]) * 256 + ord($packed[1])) % 31 == 0) and (substr($packed, 0, 2) == "\037\213") or (substr($packed, 0, 2) == "x\332") - ) // 120, 218 - { + ) { // 120, 218 // Looks like ZLIB. $data = gzuncompress($packed); return unserialize($data); @@ -74,11 +75,14 @@ // Looks like a serialized object return unserialize($packed); } - if (preg_match("/^\w+$/", $packed)) + if (preg_match("/^\w+$/", $packed)) { return $packed; + } // happened with DebugBackendInfo problem also. - trigger_error("Can't unpack bad cached markup. Probably php_zlib extension not loaded.", - E_USER_WARNING); + trigger_error( + "Can't unpack bad cached markup. Probably php_zlib extension not loaded.", + E_USER_WARNING + ); return false; } @@ -86,14 +90,16 @@ * * @return array of hashes { linkto=>pagename, relation=>pagename } */ - function getWikiPageLinks() + public function getWikiPageLinks() { $links = array(); foreach ($this->_content as $item) { - if (!is_a($item, 'Cached_DynamicContent')) + if (!is_a($item, 'Cached_DynamicContent')) { continue; - if (!($item_links = $item->getWikiPageLinks($this->_basepage))) + } + if (!($item_links = $item->getWikiPageLinks($this->_basepage))) { continue; + } $links = array_merge($links, $item_links); } // array_unique has a bug with hashes! @@ -109,12 +115,13 @@ * @return array * Returns an array of hashes. */ - function getLinkInfo() + public function getLinkInfo() { $links = array(); foreach ($this->_content as $link) { - if (!is_a($link, 'Cached_Link')) + if (!is_a($link, 'Cached_Link')) { continue; + } $info = $link->getLinkInfo($this->_basepage); $links[$info->href] = $info; } @@ -121,11 +128,12 @@ return array_values($links); } - function _append($item) + public function _append($item) { if (is_array($item)) { - foreach ($item as $subitem) + foreach ($item as $subitem) { $this->_append($subitem); + } } elseif (!is_object($item)) { $this->_buf .= $this->_quote((string)$item); } elseif (is_a($item, 'Cached_DynamicContent')) { @@ -139,8 +147,9 @@ $this->_buf .= $item->emptyTag(); } else { $this->_buf .= $item->startTag(); - foreach ($item->getContent() as $subitem) + foreach ($item->getContent() as $subitem) { $this->_append($subitem); + } $this->_buf .= "</$item->_tag>"; if (!$this->getDescription() and $item->getTag() == 'p') { @@ -148,11 +157,13 @@ $this->_glean_description($item->asString()); } } - if (!$item->isInlineElement()) + if (!$item->isInlineElement()) { $this->_buf .= "\n"; + } } elseif (is_a($item, 'XmlContent')) { - foreach ($item->getContent() as $item) + foreach ($item->getContent() as $item) { $this->_append($item); + } } elseif (method_exists($item, 'asXML')) { $this->_buf .= $item->asXML(); } elseif (method_exists($item, 'asString')) { @@ -162,7 +173,7 @@ } } - function _glean_description($text) + public function _glean_description($text) { static $two_sentences; if (!$two_sentences) { @@ -171,8 +182,9 @@ . "[.?!][\")]*\s*[\"(]*([[:upper:])]|$)"; } - if (!isset($this->_description) and preg_match("/$two_sentences/sx", $text)) + if (!isset($this->_description) and preg_match("/$two_sentences/sx", $text)) { $this->_description = preg_replace("/\s*\n\s*/", " ", trim($text)); + } } /** @@ -190,12 +202,12 @@ * * @return string */ - function getDescription() + public function getDescription() { return isset($this->_description) ? $this->_description : ''; } - function asXML() + public function asXML() { $xml = ''; $basepage = $this->_basepage; @@ -214,7 +226,7 @@ return $xml; } - function printXML() + public function printXML() { $basepage = $this->_basepage; // _content might be changed from a plugin (CreateToc) @@ -244,14 +256,14 @@ */ abstract class Cached_DynamicContent { - function cache(&$cache) + public function cache(&$cache) { $cache[] = $this; } - abstract function expand($basepage, &$markup); + abstract public function expand($basepage, &$markup); - function getWikiPageLinks($basepage) + public function getWikiPageLinks($basepage) { return array(); } @@ -259,7 +271,7 @@ class XmlRpc_LinkInfo { - function __construct($page, $type, $href, $relation = '') + public function __construct($page, $type, $href, $relation = '') { $this->page = $page; $this->type = $type; @@ -274,7 +286,7 @@ public $_url; public $_relation; - function isInlineElement() + public function isInlineElement() { return true; } @@ -284,15 +296,17 @@ * This is here to support the XML-RPC listLinks method. * (See http://www.ecyrd.com/JSPWiki/Wiki.jsp?page=WikiRPCInterface) */ - function getLinkInfo($basepage) + public function getLinkInfo($basepage) { - return new XmlRpc_LinkInfo($this->_getName($basepage), + return new XmlRpc_LinkInfo( + $this->_getName($basepage), $this->_getType(), $this->_getURL($basepage), - $this->_getRelation($basepage)); + $this->_getRelation($basepage) + ); } - function _getURL($basepage) + public function _getURL($basepage) { return $this->_url; } @@ -307,18 +321,18 @@ public $_url; public $_basepage; - function isInlineElement() + public function isInlineElement() { return true; } - function _getURL($basepage) + public function _getURL($basepage) { return $this->_url; } // TODO: fix interwiki inline links in case of static dumps - function expand($basepage, &$markup) + public function expand($basepage, &$markup) { global $WikiTheme; $this->_basepage = $basepage; @@ -335,13 +349,12 @@ class Cached_WikiLink extends Cached_Link { - /** * @param string $page * @param string $label * @param string $anchor */ - function __construct($page, $label = '', $anchor = '') + public function __construct($page, $label = '', $anchor = '') { $this->_page = $page; /* ":DontStoreLink" */ @@ -349,28 +362,31 @@ $this->_page = substr($this->_page, 1); $this->_nolink = true; } - if ($anchor) + if ($anchor) { $this->_anchor = $anchor; - if ($label and $label != $page) + } + if ($label and $label != $page) { $this->_label = $label; + } $this->_basepage = false; } - function _getType() + public function _getType() { return 'internal'; } - function getPagename($basepage) + public function getPagename($basepage) { $page = new WikiPageName($this->_page, $basepage); - if ($page->isValid()) + if ($page->isValid()) { return $page->name; - else + } else { return false; + } } - function getWikiPageLinks($basepage) + public function getWikiPageLinks($basepage) { if ($basepage == '') { return array(); @@ -385,17 +401,17 @@ } } - function _getName($basepage) + public function _getName($basepage) { return $this->getPagename($basepage); } - function _getURL($basepage) + public function _getURL($basepage) { return WikiURL($this->getPagename($basepage)); } - function expand($basepage, &$markup) + public function expand($basepage, &$markup) { global $WikiTheme; $this->_basepage = $basepage; @@ -403,14 +419,18 @@ $anchor = isset($this->_anchor) ? (string)$this->_anchor : ''; $page = new WikiPageName($this->_page, $basepage, $anchor); if ($WikiTheme->DUMP_MODE and !empty($WikiTheme->VALID_LINKS)) { - if (!in_array($this->_page, $WikiTheme->VALID_LINKS)) + if (!in_array($this->_page, $WikiTheme->VALID_LINKS)) { return HTML($label ? $label : $page->getName()); + } } - if ($page->isValid()) return WikiLink($page, 'auto', $label); - else return HTML($label); + if ($page->isValid()) { + return WikiLink($page, 'auto', $label); + } else { + return HTML($label); + } } - function asXML() + public function asXML() { global $WikiTheme; $label = isset($this->_label) ? $this->_label : false; @@ -418,17 +438,19 @@ //TODO: need basepage for subpages like /Remove (within CreateTOC) $page = new WikiPageName($this->_page, $this->_basepage, $anchor); if ($WikiTheme->DUMP_MODE and $WikiTheme->VALID_LINKS) { - if (!in_array($this->_page, $WikiTheme->VALID_LINKS)) + if (!in_array($this->_page, $WikiTheme->VALID_LINKS)) { return $label ? $label : $page->getName(); + } } $link = WikiLink($page, 'auto', $label); return $link->asXML(); } - function asString() + public function asString() { - if (isset($this->_label)) + if (isset($this->_label)) { return $this->_label; + } return $this->_page; } } @@ -435,17 +457,18 @@ class Cached_WikiLinkIfKnown extends Cached_WikiLink { - function __construct($moniker) + public function __construct($moniker) { $this->_page = $moniker; } - function expand($basepage, &$markup) + public function expand($basepage, &$markup) { global $WikiTheme; if ($WikiTheme->DUMP_MODE and $WikiTheme->VALID_LINKS) { - if (!in_array($this->_page, $WikiTheme->VALID_LINKS)) + if (!in_array($this->_page, $WikiTheme->VALID_LINKS)) { return HTML($label ? $label : $page->getName()); + } } return WikiLink($this->_page, 'if_known'); } @@ -453,18 +476,20 @@ class Cached_SpellCheck extends Cached_WikiLink { - function __construct($word, $suggestions) + public function __construct($word, $suggestions) { $this->_page = $word; $this->suggestions = $suggestions; } - function expand($basepage, &$markup) + public function expand($basepage, &$markup) { - return HTML::a(array('class' => 'spell-wrong', + return HTML::a( + array('class' => 'spell-wrong', 'title' => 'SpellCheck: ' . join(', ', $this->suggestions), 'name' => $this->_page), - $this->_page); + $this->_page + ); } } @@ -472,30 +497,32 @@ { public $_page; - function __construct($url, $label) + public function __construct($url, $label) { $this->_url = $url; - if ($label) + if ($label) { $this->_label = $label; + } } - function isInlineElement() + public function isInlineElement() { return true; } - function expand($basepage, &$markup) + public function expand($basepage, &$markup) { global $WikiTheme; $label = isset($this->_label) ? $this->_label : false; if ($WikiTheme->DUMP_MODE and $WikiTheme->VALID_LINKS) { - if (!in_array($this->_page, $WikiTheme->VALID_LINKS)) + if (!in_array($this->_page, $WikiTheme->VALID_LINKS)) { return HTML($label ? $label : $page->getName()); + } } return LinkPhpwikiURL($this->_url, $label, $basepage); } - function asXML() + public function asXML() { $label = isset($this->_label) ? $this->_label : false; $link = LinkPhpwikiURL($this->_url, $label); @@ -502,10 +529,11 @@ return $link->asXML(); } - function asString() + public function asString() { - if (isset($this->_label)) + if (isset($this->_label)) { return $this->_label; + } return $this->_url; } } @@ -526,31 +554,37 @@ public $_attribute_base; public $_unit; - function __construct($url, $label = false) + public function __construct($url, $label = false) { $this->_url = $url; - if ($label && $label != $url) + if ($label && $label != $url) { $this->_label = $label; + } $this->_expandurl($this->_url); } - function isInlineElement() + public function isInlineElement() { return true; } - function getPagename($basepage) + public function getPagename($basepage) { - if (!isset($this->_page)) return false; + if (!isset($this->_page)) { + return false; + } $page = new WikiPageName($this->_page, $basepage); - if ($page->isValid()) return $page->name; - else return false; + if ($page->isValid()) { + return $page->name; + } else { + return false; + } } /* Add relation to the link table. * attributes have the _relation, but not the _page set. */ - function getWikiPageLinks($basepage) + public function getWikiPageLinks($basepage) { /** * @var WikiRequest $request @@ -575,7 +609,7 @@ } } - function _expandurl($url) + public function _expandurl($url) { $m = array(); if (!preg_match('/^ ([^:]+) (:[:=]) (.+) $/x', $url, $m)) { @@ -598,7 +632,7 @@ return $m; } - function _expand($url, $label = false) + public function _expand($url, $label = false) { global $WikiTheme; $m = $this->_expandurl($url); @@ -605,51 +639,59 @@ // do not link to the attribute value, but to the attribute $is_attribute = ($m[2] == ':='); if ($WikiTheme->DUMP_MODE and $WikiTheme->VALID_LINKS) { - if (isset($this->_page) and !in_array($this->_page, $WikiTheme->VALID_LINKS)) + if (isset($this->_page) and !in_array($this->_page, $WikiTheme->VALID_LINKS)) { return HTML($label ? $label : ($is_attribute ? $this->_relation : $this->_page)); + } } - if ($is_attribute) + if ($is_attribute) { $title = isset($this->_attribute_base) ? sprintf(_("Attribute %s, base value: %s"), $this->_relation, $this->_attribute_base) : sprintf(_("Attribute %s, value: %s"), $this->_relation, $this->_attribute); + } if ($label) { return HTML::span( - HTML::a(array('href' => WikiURL($is_attribute ? $this->_relation : $this->_page), + HTML::a( + array('href' => WikiURL($is_attribute ? $this->_relation : $this->_page), 'class' => "wiki " . ($is_attribute ? "attribute" : "relation"), 'title' => $is_attribute ? $title : sprintf(_("Relation %s to page %s"), $this->_relation, $this->_page)), - $label) + $label + ) ); } elseif ($is_attribute) { - return HTML::span - ( - HTML::a(array('href' => WikiURL($this->_relation), + return HTML::span( + HTML::a( + array('href' => WikiURL($this->_relation), 'class' => "wiki attribute", 'title' => $title), - $url) + $url + ) ); } else { - return HTML::span - ( - HTML::a(array('href' => WikiURL($this->_relation), + return HTML::span( + HTML::a( + array('href' => WikiURL($this->_relation), 'class' => "wiki relation"), - $this->_relation), + $this->_relation + ), HTML::span(array('class' => 'relation-symbol'), $m[2]), - HTML::a(array('href' => WikiURL($this->_page), + HTML::a( + array('href' => WikiURL($this->_page), 'class' => "wiki"), - $this->_page) + $this->_page + ) ); } } - function expand($basepage, &$markup) + public function expand($basepage, &$markup) { $label = isset($this->_label) ? $this->_label : false; return $this->_expand($this->_url, $label); } - function asXML() + public function asXML() { $label = isset($this->_label) ? $this->_label : false; $link = $this->_expand($this->_url, $label); @@ -656,10 +698,11 @@ return $link->asXML(); } - function asString() + public function asString() { - if (isset($this->_label)) + if (isset($this->_label)) { return $this->_label; + } return $this->_url; } } @@ -669,42 +712,44 @@ */ class Cached_SearchHighlight extends Cached_DynamicContent { - function __construct($word, $engine) + public function __construct($word, $engine) { $this->_word = $word; $this->engine = $engine; } - function expand($basepage, &$markup) + public function expand($basepage, &$markup) { - return HTML::span(array('class' => 'search-term', + return HTML::span( + array('class' => 'search-term', 'title' => _("Found by ") . $this->engine), - $this->_word); + $this->_word + ); } } class Cached_ExternalLink extends Cached_Link { - - function __construct($url, $label = false) + public function __construct($url, $label = false) { $this->_url = $url; - if ($label && $label != $url) + if ($label && $label != $url) { $this->_label = $label; + } } - function _getType() + public function _getType() { return 'external'; } - function _getName($basepage) + public function _getName($basepage) { $label = isset($this->_label) ? $this->_label : false; return ($label and is_string($label)) ? $label : $this->_url; } - function expand($basepage, &$markup) + public function expand($basepage, &$markup) { global $request; @@ -715,16 +760,18 @@ // Ignores nofollow when the user who saved the page was authenticated. $page = $request->getPage($basepage); $current = $page->getCurrentRevision(false); - if (!$current->get('author_id')) + if (!$current->get('author_id')) { $link->setAttr('rel', 'nofollow'); + } } return $link; } - function asString() + public function asString() { - if (isset($this->_label) and is_string($this->_label)) + if (isset($this->_label) and is_string($this->_label)) { return $this->_label; + } return $this->_url; } } @@ -731,17 +778,17 @@ class Cached_InterwikiLink extends Cached_ExternalLink { - - function __construct($link, $label = false) + public function __construct($link, $label = false) { $this->_link = $link; - if ($label) + if ($label) { $this->_label = $label; + } } - function getPagename($basepage) + public function getPagename($basepage) { - list ($moniker, $page) = explode(":", $this->_link, 2); + list($moniker, $page) = explode(":", $this->_link, 2); $page = new WikiPageName($page, $basepage); if ($page->isValid()) { return $page->name; @@ -750,7 +797,7 @@ } } - function getWikiPageLinks($basepage) + public function getWikiPageLinks($basepage) { /** * @var WikiRequest $request @@ -757,9 +804,13 @@ */ global $request; - if ($basepage == '') return false; + if ($basepage == '') { + return false; + } /* ":DontStoreLink" */ - if (substr($this->_link, 0, 1) == ':') return false; + if (substr($this->_link, 0, 1) == ':') { + return false; + } /* store only links to valid pagenames */ $dbi = $request->getDbh(); if ($link = $this->getPagename($basepage) and $dbi->isWikiPage($link)) { @@ -769,7 +820,7 @@ } } - function _getName($basepage) + public function _getName($basepage) { $label = isset($this->_label) ? $this->_label : false; return ($label and is_string($label)) ? $label : $this->_link; @@ -776,18 +827,18 @@ } /* there may be internal interwiki links also */ - function _getType() + public function _getType() { return $this->getPagename(false) ? 'internal' : 'external'; } - function _getURL($basepage) + public function _getURL($basepage) { $link = $this->expand($basepage, $this); return $link->getAttr('href'); } - function expand($basepage, &$markup) + public function expand($basepage, &$markup) { global $WikiTheme; $intermap = getInterwikiMap(); @@ -794,16 +845,18 @@ $label = isset($this->_label) ? $this->_label : false; //FIXME: check Upload: inlined images if ($WikiTheme->DUMP_MODE and !empty($WikiTheme->VALID_LINKS)) { - if (!in_array($this->_link, $WikiTheme->VALID_LINKS)) + if (!in_array($this->_link, $WikiTheme->VALID_LINKS)) { return HTML($label ? $label : $this->_link); + } } return $intermap->link($this->_link, $label); } - function asString() + public function asString() { - if (isset($this->_label)) + if (isset($this->_label)) { return $this->_label; + } return $this->_link; } } @@ -813,7 +866,7 @@ // Fixed since 1.3.8, prev. versions had no userpages in backlinks class Cached_UserLink extends Cached_WikiLink { - function expand($basepage, &$markup) + public function expand($basepage, &$markup) { $label = isset($this->_label) ? $this->_label : false; $anchor = isset($this->_anchor) ? (string)$this->_anchor : ''; @@ -833,8 +886,7 @@ */ class Cached_PluginInvocation extends Cached_DynamicContent { - - function __construct($pi) + public function __construct($pi) { $this->_pi = $pi; $loader = $this->_getLoader(); @@ -845,12 +897,12 @@ } } - function isInlineElement() + public function isInlineElement() { return false; } - function expand($basepage, &$markup) + public function expand($basepage, &$markup) { /** * @var WikiRequest $request @@ -861,12 +913,12 @@ return $loader->expandPI($this->_pi, $request, $markup, $basepage); } - function asString() + public function asString() { return $this->_pi; } - function getWikiPageLinks($basepage) + public function getWikiPageLinks($basepage) { $loader = $this->_getLoader(); @@ -873,7 +925,7 @@ return $loader->getWikiPageLinks($this->_pi, $basepage); } - function & _getLoader() + public function & _getLoader() { static $loader = false; Modified: trunk/lib/Captcha.php =================================================================== --- trunk/lib/Captcha.php 2022-03-24 13:28:33 UTC (rev 11008) +++ trunk/lib/Captcha.php 2022-03-24 13:32:25 UTC (rev 11009) @@ -36,7 +36,7 @@ */ public $request; - function __construct($meta = array(), $width = 250, $height = 80) + public function __construct($meta = array(), $width = 250, $height = 80) { /** * @var WikiRequest $request @@ -51,7 +51,7 @@ $this->request =& $request; } - function captchaword() + public function captchaword() { if (!$this->request->getSessionVar('captchaword')) { $this->request->setSessionVar('captchaword', $this->get_word()); @@ -59,22 +59,24 @@ return $this->request->getSessionVar('captchaword'); } - function Failed() + public function Failed() { - if ($this->request->getSessionVar('captcha_ok') == true) + if ($this->request->getSessionVar('captcha_ok') == true) { return false; + } if (!array_key_exists('captcha_input', $this->meta) or ($this->request->getSessionVar('captchaword') and ($this->request->getSessionVar('captchaword') != $this->meta['captcha_input'])) - ) + ) { return true; + } $this->request->setSessionVar('captcha_ok', true); return false; } - function getFormElements() + public function getFormElements() { $el = arr... [truncated message content] |
From: <var...@us...> - 2023-07-14 11:37:06
|
Revision: 11056 http://sourceforge.net/p/phpwiki/code/11056 Author: vargenau Date: 2023-07-14 11:37:03 +0000 (Fri, 14 Jul 2023) Log Message: ----------- lib/BlockParser.php: PHP 7: add types for function arguments and return Modified Paths: -------------- trunk/lib/BlockParser.php trunk/lib/PageList.php trunk/lib/Template.php trunk/lib/WysiwygEdit/Wikiwyg.php trunk/lib/editpage.php trunk/lib/stdlib.php Modified: trunk/lib/BlockParser.php =================================================================== --- trunk/lib/BlockParser.php 2023-07-14 11:23:14 UTC (rev 11055) +++ trunk/lib/BlockParser.php 2023-07-14 11:37:03 UTC (rev 11056) @@ -83,7 +83,7 @@ * "(...)". (Anonymous groups, like "(?:...)", as well as * look-ahead and look-behind assertions are fine.) */ - public function __construct($regexps) + public function __construct(array $regexps) { $this->_regexps = $regexps; $this->_re = "/((" . join(")|(", $regexps) . "))/Ax"; @@ -130,7 +130,7 @@ * * @return AnchoredRegexpSet_match|bool An AnchoredRegexpSet_match object, or false if no match. */ - public function nextMatch($text, $prevMatch) + public function nextMatch(string $text, $prevMatch) { // Try to find match at same position. $regexps = array_slice($this->_regexps, $prevMatch->regexp_ind + 1); @@ -175,7 +175,7 @@ $this->_atSpace = false; } - public function skipSpace() + public function skipSpace(): bool { $nlines = count($this->_lines); while (1) { @@ -215,7 +215,7 @@ $this->_pos++; } - public function getPos() + public function getPos(): array { return array($this->_pos, $this->_atSpace); } @@ -225,12 +225,12 @@ list($this->_pos, $this->_atSpace) = $pos; } - public function getPrefix() + public function getPrefix(): string { return ''; } - public function getDepth() + public function getDepth(): int { return 0; } @@ -265,7 +265,7 @@ * @param string $prefix_re * @param string $initial_prefix */ - public function __construct(&$input, $prefix_re, $initial_prefix = '') + public function __construct(&$input, string $prefix_re, string $initial_prefix = '') { $this->_input = &$input; $this->_prefix_pat = "/$prefix_re|\\s*\$/Ax"; @@ -285,7 +285,7 @@ } } - public function skipSpace() + public function skipSpace(): bool { // In contrast to the case for top-level blocks, // for sub-blocks, there never appears to be any trailing space. @@ -330,7 +330,7 @@ $this->nextLine(); } - public function getPos() + public function getPos(): array { return array($this->_line, $this->_atSpace, $this->_input->getPos()); } @@ -342,7 +342,7 @@ $this->_input->setPos($pos[2]); } - public function getPrefix() + public function getPrefix(): string { assert($this->_line !== false); $line = $this->_input->currentLine(); @@ -350,7 +350,7 @@ return substr($line, 0, strlen($line) - strlen($this->_line)); } - public function getDepth() + public function getDepth(): int { return $this->_input->getDepth() + 1; } @@ -511,7 +511,7 @@ * * We go to this trouble so that "tight" lists look somewhat reasonable * in older (non-CSS) browsers. (If you don't do this, then, without - * CSS, you only get "loose" lists. + * CSS, you only get "loose" lists). */ class TightSubBlock extends SubBlock { @@ -563,7 +563,7 @@ public $_re = '\ +(?=\S)'; protected $_element; - public function _match(&$input, $m) + public function _match(&$input, $m): bool { $this->_depth = strlen($m->match); $indent = sprintf("\\ {%d}", $this->_depth); @@ -602,7 +602,7 @@ public $_content = array(); public $_tag; //'ol' or 'ul' - public function _match(&$input, $m) + public function _match(&$input, $m): bool { // A list as the first content in a list is not allowed. // E.g.: @@ -659,7 +659,7 @@ $this->_re = '\ {0,4}\S.*(?<!' . ESCAPE_CHAR . '):\s*$'; } - public function _match(&$input, $m) + public function _match(&$input, $m): bool { if (!($p = $this->_do_match($input, $m))) { return false; @@ -807,7 +807,7 @@ return $ncols; } - private function IsASubtable($item) + private function IsASubtable($item): bool { return is_a($item, 'HtmlElement') && $item->getTag() == 'table' @@ -825,7 +825,7 @@ return $this->_ncols; } - public function nrows() + public function nrows(): int { return $this->_nrows; } @@ -879,7 +879,7 @@ $this->_re = '\ {0,4} (?:\S.*)? (?<!' . ESCAPE_CHAR . ') \| \s* $'; } - public function _match(&$input, $m) + public function _match(&$input, $m): bool { if (!($p = $this->_do_match($input, $m))) { return false; @@ -920,7 +920,7 @@ | ; .*? : ) .*? (?=\S)'; - public function _match(&$input, $m) + public function _match(&$input, $m): bool { // FIXME: if (!preg_match('/[*#;]*$/A', $input->getPrefix())) { @@ -975,7 +975,7 @@ { public $_re = '<(?:pre|verbatim|nowiki|noinclude|includeonly)>'; - public function _match(&$input, $m) + public function _match(&$input, $m): bool { $endtag = '</' . substr($m->match, 1); $text = array(); @@ -1021,7 +1021,7 @@ { public $_re = '<<<'; - public function _match(&$input, $m) + public function _match(&$input, $m): bool { $endtag = '>>>'; $text = array(); @@ -1048,7 +1048,7 @@ { public $_re = '{{{'; - public function _match(&$input, $m) + public function _match(&$input, $m): bool { $endtag = '}}}'; $text = array(); @@ -1082,7 +1082,7 @@ * * should all work. */ - public function _match(&$input, $m) + public function _match(&$input, $m): bool { $pos = $input->getPos(); $pi = $m->match . $m->postmatch; @@ -1105,7 +1105,7 @@ // public $_re = '<<(?!\S)'; public $_re = '<<'; - public function _match(&$input, $m) + public function _match(&$input, $m): bool { $pos = $input->getPos(); $pi = $m->postmatch; @@ -1133,7 +1133,7 @@ { public $_re = '\s*\|'; - public function _match(&$input, $m) + public function _match(&$input, $m): bool { $pos = $input->getPos(); $pi = "|" . $m->postmatch; @@ -1174,7 +1174,7 @@ { public $_re = '{\|'; - public function _match(&$input, $m) + public function _match(&$input, $m): bool { $pos = $input->getPos(); $pi = $m->postmatch; @@ -1209,7 +1209,7 @@ { public $_re = '{{'; - public function _match(&$input, $m) + public function _match(&$input, $m): bool { // If we find "}}", this is an inline template. if (strpos($m->postmatch, "}}") !== false) { @@ -1294,7 +1294,7 @@ public $_attr = array('class' => 'mail-style-quote'); public $_re = '>\ ?'; - public function _match(&$input, $m) + public function _match(&$input, $m): bool { //$indent = str_replace(' ', '\\ ', $m->match) . '|>$'; $indent = $this->_re; @@ -1308,7 +1308,7 @@ public $_attr = array('style' => 'margin-left:2em'); public $_re = ':\ ?'; - public function _match(&$input, $m) + public function _match(&$input, $m): bool { $indent = $this->_re; $this->_element = new SubBlock( @@ -1326,7 +1326,7 @@ { public $_re = '-{4,}\s*$'; - public function _match(&$input, $m) + public function _match(&$input, $m): bool { $input->advance(); $this->_element = new Block_HtmlElement('hr'); @@ -1338,7 +1338,7 @@ { public $_re = '!{1,3}'; - public function _match(&$input, $m) + public function _match(&$input, $m): bool { $tag = "h" . (5 - strlen($m->match)); $text = TransformInline(trim($m->postmatch)); @@ -1354,7 +1354,7 @@ { public $_re = '={2,6}'; - public function _match(&$input, $m) + public function _match(&$input, $m): bool { $tag = "h" . strlen($m->match); // Remove spaces @@ -1378,7 +1378,7 @@ private $_tight_bot; private $_tight_top; - public function _match(&$input, $m) + public function _match(&$input, $m): bool { $this->_text = $m->match; $input->advance(); @@ -1415,7 +1415,7 @@ { public $_re = '<(?im)(?: div|span)(?:[^>]*)?>'; - public function _match(&$input, $m) + public function _match(&$input, $m): bool { if (substr($m->match, 1, 4) == 'span') { $tag = 'span'; Modified: trunk/lib/PageList.php =================================================================== --- trunk/lib/PageList.php 2023-07-14 11:23:14 UTC (rev 11055) +++ trunk/lib/PageList.php 2023-07-14 11:37:03 UTC (rev 11056) @@ -54,7 +54,7 @@ */ class _PageList_Column_base { - public $_tdattr = array(); + public array $_tdattr = array(); public $_field; public function __construct($default_heading, $align = false) @@ -85,7 +85,7 @@ } // old-style heading - public function heading() + public function heading(): HTML { global $request; // allow sorting? @@ -110,7 +110,7 @@ // new grid-style sortable heading // TODO: via activeui.js ? (fast dhtml sorting) - public function button_heading($pagelist, $colNum) + public function button_heading($pagelist, $colNum): HTML { global $WikiTheme, $request; // allow sorting? @@ -172,7 +172,7 @@ * * @return int -1 if $a < $b, 1 if $a > $b, 0 otherwise. */ - public function _compare($colvala, $colvalb) + public function _compare($colvala, $colvalb): int { if (is_string($colvala)) { return strcmp($colvala, $colvalb); @@ -209,7 +209,7 @@ * @param WikiDB_PageRevision $revision_handle * @return mixed */ - public function _getValue($page_handle, $revision_handle) + public function _getValue(WikiDB_Page $page_handle, WikiDB_PageRevision $revision_handle) { if ($this->_need_rev) { if (!$revision_handle) { @@ -227,7 +227,7 @@ * @param WikiDB_PageRevision $revision_handle * @return int|string */ - public function _getSortableValue($page_handle, $revision_handle) + public function _getSortableValue(WikiDB_Page $page_handle, WikiDB_PageRevision $revision_handle) { $val = $this->_getValue($page_handle, $revision_handle); if ($this->_field == 'hits') { @@ -256,7 +256,7 @@ class _PageList_Column_size extends _PageList_Column { - public function format($pagelist, $page_handle, $revision_handle) + public function format($pagelist, $page_handle, $revision_handle): HTML { return HTML::td( $this->_tdattr, @@ -264,7 +264,7 @@ ); } - public function _getValuePageList($pagelist, $page_handle, $revision_handle) + public function _getValuePageList($pagelist, $page_handle, $revision_handle): FormattedText { if (!$revision_handle or (!$revision_handle->_data['%content'] or $revision_handle->_data['%content'] === true) @@ -280,7 +280,7 @@ return $size; } - public function _getSortableValue($page_handle, $revision_handle) + public function _getSortableValue(WikiDB_Page $page_handle, WikiDB_PageRevision $revision_handle) { if (!$revision_handle) { $revision_handle = $page_handle->getCurrentRevision(); @@ -289,7 +289,7 @@ ? 0 : strlen($revision_handle->_data['%content']); } - public function _getSize($revision_handle) + public function _getSize($revision_handle): FormattedText { $bytes = @strlen($revision_handle->_data['%content']); return ByteFormatter($bytes); @@ -305,7 +305,7 @@ $this->_textIfFalse = new RawXml('—'); //mdash } - public function _getValue($page_handle, $revision_handle) + public function _getValue(WikiDB_Page $page_handle, WikiDB_PageRevision $revision_handle) { //FIXME: check if $this is available in the parent (->need_rev) $val = parent::_getValue($page_handle, $revision_handle); @@ -327,7 +327,7 @@ parent::__construct($field, $heading, 'center'); } - public function _getValuePageList($pagelist, $page_handle, $revision_handle) + public function _getValuePageList($pagelist, $page_handle, $revision_handle): HTML { $pagename = $page_handle->getName(); $selected = !empty($pagelist->_selected[$pagename]); @@ -346,7 +346,7 @@ } } - public function format($pagelist, $page_handle, $revision_handle) + public function format($pagelist, $page_handle, $revision_handle): HTML { return HTML::td( $this->_tdattr, @@ -355,7 +355,7 @@ } // don't sort this javascript button - public function button_heading($pagelist, $colNum) + public function button_heading($pagelist, $colNum): HTML { $s = HTML($this->_heading); return HTML::th(array('class' => 'gridbutton'), $s); @@ -371,13 +371,13 @@ $this->WikiTheme = &$WikiTheme; } - public function _getValue($page_handle, $revision_handle) + public function _getValue(WikiDB_Page $page_handle, WikiDB_PageRevision $revision_handle) { $time = parent::_getValue($page_handle, $revision_handle); return $this->WikiTheme->formatDateTime($time); } - public function _getSortableValue($page_handle, $revision_handle) + public function _getSortableValue(WikiDB_Page $page_handle, WikiDB_PageRevision $revision_handle) { return parent::_getValue($page_handle, $revision_handle); } @@ -385,7 +385,7 @@ class _PageList_Column_version extends _PageList_Column { - public function _getValue($page_handle, $revision_handle) + public function _getValue(WikiDB_Page $page_handle, WikiDB_PageRevision $revision_handle) { if (!$revision_handle) { $revision_handle = $page_handle->getCurrentRevision(); @@ -425,7 +425,7 @@ } } - public function _getValue($page_handle, $revision_handle) + public function _getValue(WikiDB_Page $page_handle, WikiDB_PageRevision $revision_handle) { if (!$revision_handle or (!$revision_handle->_data['%content'] or $revision_handle->_data['%content'] === true) @@ -510,7 +510,7 @@ ); } - public function _getSortableValue($page_handle, $revision_handle) + public function _getSortableValue(WikiDB_Page $page_handle, WikiDB_PageRevision $revision_handle) { if (is_object($page_handle) and !empty($page_handle->score)) { return $page_handle->score; @@ -535,7 +535,7 @@ $this->dbi =& $request->getDbh(); } - public function _getValue($page_handle, $revision_handle) + public function _getValue(WikiDB_Page $page_handle, WikiDB_PageRevision $revision_handle) { $author = parent::_getValue($page_handle, $revision_handle); if ($this->dbi->isWikiPage($author)) { @@ -545,7 +545,7 @@ } } - public function _getSortableValue($page_handle, $revision_handle) + public function _getSortableValue(WikiDB_Page $page_handle, WikiDB_PageRevision $revision_handle) { return parent::_getValue($page_handle, $revision_handle); } @@ -553,7 +553,7 @@ class _PageList_Column_owner extends _PageList_Column_author { - public function _getValue($page_handle, $revision_handle) + public function _getValue(WikiDB_Page $page_handle, WikiDB_PageRevision $revision_handle) { $author = $page_handle->getOwner(); if ($this->dbi->isWikiPage($author)) { @@ -563,7 +563,7 @@ } } - public function _getSortableValue($page_handle, $revision_handle) + public function _getSortableValue(WikiDB_Page $page_handle, WikiDB_PageRevision $revision_handle) { return parent::_getValue($page_handle, $revision_handle); } @@ -571,7 +571,7 @@ class _PageList_Column_creator extends _PageList_Column_author { - public function _getValue($page_handle, $revision_handle) + public function _getValue(WikiDB_Page $page_handle, WikiDB_PageRevision $revision_handle) { $author = $page_handle->getCreator(); if ($this->dbi->isWikiPage($author)) { @@ -581,7 +581,7 @@ } } - public function _getSortableValue($page_handle, $revision_handle) + public function _getSortableValue(WikiDB_Page $page_handle, WikiDB_PageRevision $revision_handle) { return parent::_getValue($page_handle, $revision_handle); } @@ -598,7 +598,7 @@ $this->dbi = &$request->getDbh(); } - public function _getValue($page_handle, $revision_handle) + public function _getValue($page_handle, $revision_handle): XmlContent { if ($this->dbi->isWikiPage($page_handle->getName())) { return WikiLink($page_handle); @@ -615,7 +615,7 @@ /** * Compare two pagenames for sorting. See _PageList_Column::_compare. **/ - public function _compare($colvala, $colvalb) + public function _compare($colvala, $colvalb): int { return strcmp($colvala, $colvalb); } @@ -623,7 +623,7 @@ class _PageList_Column_perm extends _PageList_Column { - public function _getValue($page_handle, $revision_handle) + public function _getValue(WikiDB_Page $page_handle, WikiDB_PageRevision $revision_handle) { $perm_array = pagePermissions($page_handle->_pagename); return pagePermissionsSimpleFormat( @@ -636,7 +636,7 @@ class _PageList_Column_acl extends _PageList_Column { - public function _getValue($page_handle, $revision_handle) + public function _getValue(WikiDB_Page $page_handle, WikiDB_PageRevision $revision_handle) { $perm_tree = pagePermissions($page_handle->_pagename); @@ -658,19 +658,19 @@ class PageList { - public $_group_rows = 3; - public $_columns = array(); - private $_columnsMap = array(); // Maps column name to column number. + public int $_group_rows = 3; + public array $_columns = array(); + private array $_columnsMap = array(); // Maps column name to column number. private $_excluded_pages = array(); - public $_pages = array(); - public $_caption = ""; - public $_types = array(); + public array $_pages = array(); + public string $_caption = ""; + public array $_types = array(); public $_options = array(); - public $_selected = array(); - public $_sortby = array(); - public $_maxlen = 0; - private $_messageIfEmpty = ''; - public $_columns_seen = array(); + public array $_selected = array(); + public array $_sortby = array(); + public int $_maxlen = 0; + private string $_messageIfEmpty = ''; + public array $_columns_seen = array(); private $_stack; public function __construct($columns = array(), $exclude = array(), $options = array()) @@ -802,7 +802,7 @@ // 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 - public static function supportedArgs() + public static function supportedArgs(): array { // Todo: add all supported Columns, like locked, minor, ... return array( // Currently supported options: @@ -855,7 +855,7 @@ ); } - private function pagingArgs() + private function pagingArgs(): array { return array('sortby', 'limit', 'paging', 'count', 'dosort'); } @@ -876,7 +876,7 @@ $this->_caption = HTML($this->_caption, " ", $caption); } - private function getCaption() + private function getCaption(): string { // put the total into the caption if needed if (is_string($this->_caption) && strstr($this->_caption, '%d')) { @@ -885,13 +885,13 @@ return $this->_caption; } - public function getTotal() + public function getTotal(): int { return !empty($this->_options['count']) ? (int)$this->_options['count'] : count($this->_pages); } - public function isEmpty() + public function isEmpty(): bool { return empty($this->_pages); } @@ -911,7 +911,7 @@ } } - public function pageNames() + public function pageNames(): array { $pages = array(); $limit = @$this->_options['limit']; @@ -1212,7 +1212,7 @@ $sortby = '', $limit = '', $exclude = '' - ) + ): array { /** * @var WikiRequest $request @@ -1253,7 +1253,7 @@ $sortby = '', $limit = '', $exclude = '' - ) + ): array { /** * @var WikiRequest $request @@ -1293,7 +1293,7 @@ $sortby = '', $limit = '', $exclude = '' - ) + ): array { /** * @var WikiRequest $request @@ -1332,7 +1332,7 @@ $sortby = '', $limit = '', $exclude = '' - ) + ): array { /** * @var WikiRequest $request @@ -1371,7 +1371,7 @@ $sortby = '', $limit = '', $exclude = '' - ) + ): array { /** * @var WikiRequest $request @@ -1510,7 +1510,7 @@ * @param string $column column name * @return bool true if column is added, false otherwise */ - public function _addColumn($column) + public function _addColumn(string $column): bool { global $request; @@ -1642,7 +1642,7 @@ } } - public function limit($limit) + public function limit($limit): array { if (is_array($limit)) { list($from, $count) = $limit; @@ -1738,7 +1738,7 @@ } // make a table given the caption - public function _generateTable($caption = '') + public function _generateTable($caption = ''): HTML { if (count($this->_sortby) > 0) { $this->sortPages(); @@ -2010,7 +2010,7 @@ // comma=1 // Condense list without a href links: "Page1, Page2, ..." // FIXME: only unique list entries, esp. with nopage - private function generateCommaListAsString() + private function generateCommaListAsString(): XmlContent { if (defined($this->_options['commasep'])) { $separator = $this->_options['commasep']; @@ -2031,7 +2031,7 @@ // Future: 1 = reserved for plain string (see above) // 2 and more => HTML link specialization? // FIXME: only unique list entries, esp. with nopage - private function generateCommaList() + private function generateCommaList(): XmlContent { if (defined($this->_options['commasep'])) { $separator = HTML::raw($this->_options['commasep']); @@ -2049,7 +2049,7 @@ return $html; } - public function _emptyList($caption) + public function _emptyList($caption): XmlContent { $html = HTML(); if ($caption) { Modified: trunk/lib/Template.php =================================================================== --- trunk/lib/Template.php 2023-07-14 11:23:14 UTC (rev 11055) +++ trunk/lib/Template.php 2023-07-14 11:37:03 UTC (rev 11056) @@ -37,7 +37,7 @@ * @param WikiRequest $request * @param array $args */ - public function __construct($name, &$request, $args = array()) + public function __construct(string $name, WikiRequest &$request, array $args = array()) { global $WikiTheme; @@ -138,7 +138,7 @@ * @param string $varname Name of token to substitute for. * @param string $value Replacement HTML text. */ - public function replace($varname, $value) + public function replace(string $varname, string $value) { $this->_locals[$varname] = $value; } @@ -235,13 +235,13 @@ * new Template(...) * </pre> */ -function Template($name, $args = array()) +function Template($name, $args = array()): Template { global $request; return new Template($name, $request, $args); } -function alreadyTemplateProcessed($name) +function alreadyTemplateProcessed($name): bool { global $request; return !empty($request->_TemplatesProcessed[$name]) ? true : false; @@ -256,7 +256,7 @@ * @param object|bool $page_revision A WikiDB_PageRevision object or false * @param array $args hash Extract args for top-level template */ -function GeneratePage($content, $title, $page_revision = false, $args = array()) +function GeneratePage($content, string $title, $page_revision = false, array $args = array()) { global $request; Modified: trunk/lib/WysiwygEdit/Wikiwyg.php =================================================================== --- trunk/lib/WysiwygEdit/Wikiwyg.php 2023-07-14 11:23:14 UTC (rev 11055) +++ trunk/lib/WysiwygEdit/Wikiwyg.php 2023-07-14 11:37:03 UTC (rev 11056) @@ -157,7 +157,7 @@ * @param string $text * @return string */ - public function ConvertBefore($text) + public function ConvertBefore($text): string { return $text; } @@ -169,7 +169,7 @@ * @param string $text * @return string */ - public function ConvertAfter($text) + public function ConvertAfter($text): string { return TransformInline($text); } @@ -321,7 +321,7 @@ // This is called to replace the RichTable plugin by an html table // $matched contains html <p> tags so // they are deleted before the conversion. -function replace_rich_table($matched) +function replace_rich_table($matched): string { /** * @var WikiRequest $request Modified: trunk/lib/editpage.php =================================================================== --- trunk/lib/editpage.php 2023-07-14 11:23:14 UTC (rev 11055) +++ trunk/lib/editpage.php 2023-07-14 11:37:03 UTC (rev 11056) @@ -57,7 +57,7 @@ /** * @param WikiRequest $request */ - public function __construct(&$request) + public function __construct(WikiRequest &$request) { $this->request = &$request; @@ -123,7 +123,7 @@ } } - public function editPage() + public function editPage(): ?bool { $saveFailed = false; $tokens = &$this->tokens; @@ -240,7 +240,7 @@ return $this->output('editpage', _("Edit: %s")); } - public function output($template, $title_fs) + public function output($template, $title_fs): bool { global $WikiTheme; $selected = &$this->selected; @@ -279,7 +279,7 @@ return $this->output('viewsource', _("View Source: %s")); } - private function updateLock() + private function updateLock(): bool { $changed = false; if (!ENABLE_PAGE_PUBLIC && !ENABLE_EXTERNAL_PAGES) { @@ -322,7 +322,7 @@ return $changed; // lock changed. } - public function savePage() + public function savePage(): bool { $request = &$this->request; @@ -418,17 +418,17 @@ return $this->current->getVersion() != $this->_currentVersion; } - protected function canEdit() + protected function canEdit(): bool { return !$this->page->get('locked') || $this->user->isAdmin(); } - protected function isInitialEdit() + protected function isInitialEdit(): bool { return $this->_initialEdit; } - private function isUnchanged() + private function isUnchanged(): bool { $current = &$this->current; return $this->_content == $current->getPackedContent(); @@ -444,7 +444,7 @@ * ENABLE_SPAMASSASSIN: content patterns by babycart (only php >= 4.3 for now) * ENABLE_SPAMBLOCKLIST: content domain blacklist */ - private function isSpam() + private function isSpam(): bool { $current = &$this->current; $request = &$this->request; @@ -533,7 +533,7 @@ /** Number of external links in the wikitext */ - private function numLinks(&$text) + private function numLinks(&$text): int { return substr_count($text, "http://") + substr_count($text, "https://"); } @@ -540,7 +540,7 @@ /** Header of the Anti Spam message */ - private function getSpamMessage() + private function getSpamMessage(): XmlContent { return HTML( @@ -554,7 +554,7 @@ ); } - protected function getPreview() + protected function getPreview(): TransformedText { require_once 'lib/PageType.php'; $this->_content = $this->getContent(); @@ -561,7 +561,7 @@ return new TransformedText($this->page, $this->_content, $this->meta); } - protected function getConvertedPreview() + protected function getConvertedPreview(): TransformedText { require_once 'lib/PageType.php'; $this->_content = $this->getContent(); @@ -568,7 +568,7 @@ return new TransformedText($this->page, $this->_content, $this->meta); } - private function getDiff() + private function getDiff(): XmlContent { require_once 'lib/diff.php'; $html = HTML(); @@ -611,7 +611,7 @@ } } - protected function getLockedMessage() + protected function getLockedMessage(): XmlContent { return HTML( @@ -627,7 +627,7 @@ return $this->page->get('moderation'); } - private function getModeratedMessage() + private function getModeratedMessage(): XmlContent { return HTML( @@ -640,7 +640,7 @@ ); } - protected function getConflictMessage($unresolved = false) + protected function getConflictMessage($unresolved = false): XmlContent { /* xgettext only knows about c/c++ line-continuation strings @@ -1156,7 +1156,7 @@ $this->request->redirect(WikiURL($this->page, array(), 'absolute_url')); } - private function _restoreState() + private function _restoreState(): bool { $request = &$this->request; @@ -1255,7 +1255,7 @@ class LoadFileConflictPageEditor extends PageEditor { - public function editPage($saveFailed = true) + public function editPage($saveFailed = true): ?bool { $tokens = &$this->tokens; @@ -1342,7 +1342,7 @@ return $this->output('editpage', _("Merge and Edit: %s")); } - public function output($template, $title_fs) + public function output($template, $title_fs): bool { $selected = &$this->selected; $current = &$this->current; @@ -1371,7 +1371,7 @@ return true; } - protected function getConflictMessage($unresolved = false) + protected function getConflictMessage($unresolved = false): XmlContent { return HTML(HTML::p( fmt( Modified: trunk/lib/stdlib.php =================================================================== --- trunk/lib/stdlib.php 2023-07-14 11:23:14 UTC (rev 11055) +++ trunk/lib/stdlib.php 2023-07-14 11:37:03 UTC (rev 11056) @@ -125,7 +125,7 @@ * @param string $str * @return string */ -function MangleXmlIdentifier($str) +function MangleXmlIdentifier(string $str): string { if (!$str) { return 'empty.'; @@ -145,7 +145,7 @@ * configuration file. * @return string The name of the WIKI_ID cookie to use for this wiki. */ -function getCookieName() +function getCookieName(): string { return preg_replace("/[^\d\w]/", "_", WIKI_NAME) . "_WIKI_ID"; } @@ -244,7 +244,7 @@ * @param string $url * @return string Absolute URL */ -function AbsoluteURL($url) +function AbsoluteURL(string $url): string { if (preg_match('/^https?:/', $url)) { return $url; @@ -308,7 +308,7 @@ * @param string $text The text. * @return XmlContent. */ -function PossiblyGlueIconToText($proto_or_url, $text) +function PossiblyGlueIconToText(string $proto_or_url, string $text): XmlContent { global $request, $WikiTheme; if ($request->getPref('noLinkIcons')) { @@ -379,7 +379,7 @@ * @param bool $http_only if true, accept only http and https URLs * @return bool true if safe, false else. */ -function IsSafeURL($url, $http_only = false) +function IsSafeURL(string $url, bool $http_only = false): bool { if (preg_match('/([<>"])|(%3C)|(%3E)|(%22)/', $url)) { return false; @@ -402,7 +402,7 @@ * @param string $linktext Text to be displayed as link. * @return HtmlElement HtmlElement object that contains data to construct an html link. */ -function LinkURL($url, $linktext = '') +function LinkURL(string $url, string $linktext = ''): HtmlElement { // FIXME: Is this needed (or sufficient?) if (!IsSafeURL($url)) { @@ -430,7 +430,7 @@ * * Handle embeddable objects, like svg, class, vrml, svgz, pdf, avi, wmv especially. */ -function LinkImage($url, $alt = "") +function LinkImage(string $url, string $alt = "") { $force_img = "png|jpg|gif|jpeg|bmp|pl|cgi"; // Disallow tags in img src urls. Typical CSS attacks. @@ -766,7 +766,7 @@ // end class definition -function SplitQueryArgs($query_args = '') +function SplitQueryArgs(string $query_args = ''): array { // FIXME: use the arg-separator which might not be & $split_args = explode('&', $query_args); @@ -779,7 +779,7 @@ return $args; } -function LinkPhpwikiURL($url, $text = '', $basepage = false) +function LinkPhpwikiURL(string $url, string $text = '', bool $basepage = false) { /** * @var WikiRequest $request @@ -949,7 +949,7 @@ return substr($name, 0, -strlen($tail)); } - public function isValid($strict = false) + public function isValid(bool $strict = false) { if ($strict) { return !isset($this->_errors); @@ -1064,7 +1064,7 @@ * @param int $tab_width * @return string */ -function expand_tabs($str, $tab_width = 8) +function expand_tabs(string $str, int $tab_width = 8) { $split = explode("\t", $str); $tail = array_pop($split); @@ -1088,7 +1088,7 @@ * * @return string The split name. */ -function SplitPagename($page) +function SplitPagename(string $page): string { if (preg_match("/\s/", $page)) { return $page; @@ -1184,7 +1184,7 @@ * @param int $time Unix timestamp (defaults to current time). * @return string Formatted date & time. */ -function ncsa_time($time = 0) +function ncsa_time(int $time = 0) { if (!$time) { $time = time(); @@ -1199,7 +1199,7 @@ * @param bool $no_colon Don't put colon between hours and minutes. * @return string Offset as a string in the format +HH:MM. */ -function TimezoneOffset($time = 0, $no_colon = false) +function TimezoneOffset(int $time = 0, bool $no_colon = false) { if ($time == 0) { $time = time(); @@ -1229,7 +1229,7 @@ * @param int $time Time. Default: now. * @return string Date and time in ISO-8601 format. */ -function Iso8601DateTime($time = 0) +function Iso8601DateTime(int $time = 0): string { if ($time == 0) { $time = time(); @@ -1246,7 +1246,7 @@ * @param int $time Time. Default: now. * @return string Date and time in RFC-2822 format. */ -function Rfc2822DateTime($time = 0) +function Rfc2822DateTime(int $time = 0): string { if ($time == 0) { $time = time(); @@ -1260,7 +1260,7 @@ * @param int $time Time. Default: now. * @return string Date and time in RFC-1123 format. */ -function Rfc1123DateTime($time = 0) +function Rfc1123DateTime(int $time = 0): string { if ($time == 0) { $time = time(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <var...@us...> - 2023-07-14 11:54:57
|
Revision: 11057 http://sourceforge.net/p/phpwiki/code/11057 Author: vargenau Date: 2023-07-14 11:54:56 +0000 (Fri, 14 Jul 2023) Log Message: ----------- lib: PHP 7: add types for function arguments and return Modified Paths: -------------- trunk/lib/Template.php trunk/lib/stdlib.php Modified: trunk/lib/Template.php =================================================================== --- trunk/lib/Template.php 2023-07-14 11:37:03 UTC (rev 11056) +++ trunk/lib/Template.php 2023-07-14 11:54:56 UTC (rev 11057) @@ -37,7 +37,7 @@ * @param WikiRequest $request * @param array $args */ - public function __construct(string $name, WikiRequest &$request, array $args = array()) + public function __construct(string $name, &$request, array $args = array()) { global $WikiTheme; Modified: trunk/lib/stdlib.php =================================================================== --- trunk/lib/stdlib.php 2023-07-14 11:37:03 UTC (rev 11056) +++ trunk/lib/stdlib.php 2023-07-14 11:54:56 UTC (rev 11057) @@ -308,7 +308,7 @@ * @param string $text The text. * @return XmlContent. */ -function PossiblyGlueIconToText(string $proto_or_url, string $text): XmlContent +function PossiblyGlueIconToText(string $proto_or_url, string $text) { global $request, $WikiTheme; if ($request->getPref('noLinkIcons')) { @@ -402,7 +402,7 @@ * @param string $linktext Text to be displayed as link. * @return HtmlElement HtmlElement object that contains data to construct an html link. */ -function LinkURL(string $url, string $linktext = ''): HtmlElement +function LinkURL(string $url, string $linktext = '') { // FIXME: Is this needed (or sufficient?) if (!IsSafeURL($url)) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <var...@us...> - 2023-07-18 14:38:01
|
Revision: 11063 http://sourceforge.net/p/phpwiki/code/11063 Author: vargenau Date: 2023-07-18 14:37:58 +0000 (Tue, 18 Jul 2023) Log Message: ----------- PHP7: less strict typing Modified Paths: -------------- trunk/lib/PageList.php trunk/lib/Template.php trunk/lib/editpage.php Modified: trunk/lib/PageList.php =================================================================== --- trunk/lib/PageList.php 2023-07-18 14:36:37 UTC (rev 11062) +++ trunk/lib/PageList.php 2023-07-18 14:37:58 UTC (rev 11063) @@ -85,7 +85,7 @@ } // old-style heading - public function heading(): HTML + public function heading() { global $request; // allow sorting? @@ -110,7 +110,7 @@ // new grid-style sortable heading // TODO: via activeui.js ? (fast dhtml sorting) - public function button_heading($pagelist, $colNum): HTML + public function button_heading($pagelist, $colNum) { global $WikiTheme, $request; // allow sorting? @@ -209,7 +209,7 @@ * @param WikiDB_PageRevision $revision_handle * @return mixed */ - public function _getValue(WikiDB_Page $page_handle, WikiDB_PageRevision $revision_handle) + public function _getValue($page_handle, $revision_handle) { if ($this->_need_rev) { if (!$revision_handle) { @@ -227,7 +227,7 @@ * @param WikiDB_PageRevision $revision_handle * @return int|string */ - public function _getSortableValue(WikiDB_Page $page_handle, WikiDB_PageRevision $revision_handle) + public function _getSortableValue($page_handle, $revision_handle) { $val = $this->_getValue($page_handle, $revision_handle); if ($this->_field == 'hits') { @@ -256,7 +256,7 @@ class _PageList_Column_size extends _PageList_Column { - public function format($pagelist, $page_handle, $revision_handle): HTML + public function format($pagelist, $page_handle, $revision_handle) { return HTML::td( $this->_tdattr, @@ -264,7 +264,7 @@ ); } - public function _getValuePageList($pagelist, $page_handle, $revision_handle): FormattedText + public function _getValuePageList($pagelist, $page_handle, $revision_handle) { if (!$revision_handle or (!$revision_handle->_data['%content'] or $revision_handle->_data['%content'] === true) @@ -280,7 +280,7 @@ return $size; } - public function _getSortableValue(WikiDB_Page $page_handle, WikiDB_PageRevision $revision_handle) + public function _getSortableValue($page_handle, $revision_handle) { if (!$revision_handle) { $revision_handle = $page_handle->getCurrentRevision(); @@ -305,7 +305,7 @@ $this->_textIfFalse = new RawXml('—'); //mdash } - public function _getValue(WikiDB_Page $page_handle, WikiDB_PageRevision $revision_handle) + public function _getValue($page_handle, $revision_handle) { //FIXME: check if $this is available in the parent (->need_rev) $val = parent::_getValue($page_handle, $revision_handle); @@ -327,7 +327,7 @@ parent::__construct($field, $heading, 'center'); } - public function _getValuePageList($pagelist, $page_handle, $revision_handle): HTML + public function _getValuePageList($pagelist, $page_handle, $revision_handle) { $pagename = $page_handle->getName(); $selected = !empty($pagelist->_selected[$pagename]); @@ -346,7 +346,7 @@ } } - public function format($pagelist, $page_handle, $revision_handle): HTML + public function format($pagelist, $page_handle, $revision_handle) { return HTML::td( $this->_tdattr, @@ -355,7 +355,7 @@ } // don't sort this javascript button - public function button_heading($pagelist, $colNum): HTML + public function button_heading($pagelist, $colNum) { $s = HTML($this->_heading); return HTML::th(array('class' => 'gridbutton'), $s); @@ -371,13 +371,13 @@ $this->WikiTheme = &$WikiTheme; } - public function _getValue(WikiDB_Page $page_handle, WikiDB_PageRevision $revision_handle) + public function _getValue($page_handle, $revision_handle) { $time = parent::_getValue($page_handle, $revision_handle); return $this->WikiTheme->formatDateTime($time); } - public function _getSortableValue(WikiDB_Page $page_handle, WikiDB_PageRevision $revision_handle) + public function _getSortableValue($page_handle, $revision_handle) { return parent::_getValue($page_handle, $revision_handle); } @@ -385,7 +385,7 @@ class _PageList_Column_version extends _PageList_Column { - public function _getValue(WikiDB_Page $page_handle, WikiDB_PageRevision $revision_handle) + public function _getValue($page_handle, $revision_handle) { if (!$revision_handle) { $revision_handle = $page_handle->getCurrentRevision(); @@ -425,7 +425,7 @@ } } - public function _getValue(WikiDB_Page $page_handle, WikiDB_PageRevision $revision_handle) + public function _getValue($page_handle, $revision_handle) { if (!$revision_handle or (!$revision_handle->_data['%content'] or $revision_handle->_data['%content'] === true) @@ -510,7 +510,7 @@ ); } - public function _getSortableValue(WikiDB_Page $page_handle, WikiDB_PageRevision $revision_handle) + public function _getSortableValue($page_handle, $revision_handle) { if (is_object($page_handle) and !empty($page_handle->score)) { return $page_handle->score; @@ -535,7 +535,7 @@ $this->dbi =& $request->getDbh(); } - public function _getValue(WikiDB_Page $page_handle, WikiDB_PageRevision $revision_handle) + public function _getValue($page_handle, $revision_handle) { $author = parent::_getValue($page_handle, $revision_handle); if ($this->dbi->isWikiPage($author)) { @@ -545,7 +545,7 @@ } } - public function _getSortableValue(WikiDB_Page $page_handle, WikiDB_PageRevision $revision_handle) + public function _getSortableValue($page_handle, $revision_handle) { return parent::_getValue($page_handle, $revision_handle); } @@ -553,7 +553,7 @@ class _PageList_Column_owner extends _PageList_Column_author { - public function _getValue(WikiDB_Page $page_handle, WikiDB_PageRevision $revision_handle) + public function _getValue($page_handle, $revision_handle) { $author = $page_handle->getOwner(); if ($this->dbi->isWikiPage($author)) { @@ -563,7 +563,7 @@ } } - public function _getSortableValue(WikiDB_Page $page_handle, WikiDB_PageRevision $revision_handle) + public function _getSortableValue($page_handle, $revision_handle) { return parent::_getValue($page_handle, $revision_handle); } @@ -571,7 +571,7 @@ class _PageList_Column_creator extends _PageList_Column_author { - public function _getValue(WikiDB_Page $page_handle, WikiDB_PageRevision $revision_handle) + public function _getValue($page_handle, $revision_handle) { $author = $page_handle->getCreator(); if ($this->dbi->isWikiPage($author)) { @@ -581,7 +581,7 @@ } } - public function _getSortableValue(WikiDB_Page $page_handle, WikiDB_PageRevision $revision_handle) + public function _getSortableValue($page_handle, $revision_handle) { return parent::_getValue($page_handle, $revision_handle); } @@ -598,7 +598,7 @@ $this->dbi = &$request->getDbh(); } - public function _getValue($page_handle, $revision_handle): XmlContent + public function _getValue($page_handle, $revision_handle) { if ($this->dbi->isWikiPage($page_handle->getName())) { return WikiLink($page_handle); @@ -623,7 +623,7 @@ class _PageList_Column_perm extends _PageList_Column { - public function _getValue(WikiDB_Page $page_handle, WikiDB_PageRevision $revision_handle) + public function _getValue($page_handle, $revision_handle) { $perm_array = pagePermissions($page_handle->_pagename); return pagePermissionsSimpleFormat( @@ -636,7 +636,7 @@ class _PageList_Column_acl extends _PageList_Column { - public function _getValue(WikiDB_Page $page_handle, WikiDB_PageRevision $revision_handle) + public function _getValue($page_handle, $revision_handle) { $perm_tree = pagePermissions($page_handle->_pagename); @@ -1738,7 +1738,7 @@ } // make a table given the caption - public function _generateTable($caption = ''): HTML + public function _generateTable($caption = '') { if (count($this->_sortby) > 0) { $this->sortPages(); @@ -2010,7 +2010,7 @@ // comma=1 // Condense list without a href links: "Page1, Page2, ..." // FIXME: only unique list entries, esp. with nopage - private function generateCommaListAsString(): XmlContent + private function generateCommaListAsString() { if (defined($this->_options['commasep'])) { $separator = $this->_options['commasep']; @@ -2031,7 +2031,7 @@ // Future: 1 = reserved for plain string (see above) // 2 and more => HTML link specialization? // FIXME: only unique list entries, esp. with nopage - private function generateCommaList(): XmlContent + private function generateCommaList() { if (defined($this->_options['commasep'])) { $separator = HTML::raw($this->_options['commasep']); @@ -2049,7 +2049,7 @@ return $html; } - public function _emptyList($caption): XmlContent + public function _emptyList($caption) { $html = HTML(); if ($caption) { Modified: trunk/lib/Template.php =================================================================== --- trunk/lib/Template.php 2023-07-18 14:36:37 UTC (rev 11062) +++ trunk/lib/Template.php 2023-07-18 14:37:58 UTC (rev 11063) @@ -37,7 +37,7 @@ * @param WikiRequest $request * @param array $args */ - public function __construct(string $name, &$request, array $args = array()) + public function __construct(string $name, &$request, $args = array()) { global $WikiTheme; Modified: trunk/lib/editpage.php =================================================================== --- trunk/lib/editpage.php 2023-07-18 14:36:37 UTC (rev 11062) +++ trunk/lib/editpage.php 2023-07-18 14:37:58 UTC (rev 11063) @@ -57,7 +57,7 @@ /** * @param WikiRequest $request */ - public function __construct(WikiRequest &$request) + public function __construct(&$request) { $this->request = &$request; @@ -123,7 +123,7 @@ } } - public function editPage(): ?bool + public function editPage() { $saveFailed = false; $tokens = &$this->tokens; @@ -540,7 +540,7 @@ /** Header of the Anti Spam message */ - private function getSpamMessage(): XmlContent + private function getSpamMessage() { return HTML( @@ -554,7 +554,7 @@ ); } - protected function getPreview(): TransformedText + protected function getPreview() { require_once 'lib/PageType.php'; $this->_content = $this->getContent(); @@ -561,7 +561,7 @@ return new TransformedText($this->page, $this->_content, $this->meta); } - protected function getConvertedPreview(): TransformedText + protected function getConvertedPreview() { require_once 'lib/PageType.php'; $this->_content = $this->getContent(); @@ -568,7 +568,7 @@ return new TransformedText($this->page, $this->_content, $this->meta); } - private function getDiff(): XmlContent + private function getDiff() { require_once 'lib/diff.php'; $html = HTML(); @@ -611,7 +611,7 @@ } } - protected function getLockedMessage(): XmlContent + protected function getLockedMessage() { return HTML( @@ -627,7 +627,7 @@ return $this->page->get('moderation'); } - private function getModeratedMessage(): XmlContent + private function getModeratedMessage() { return HTML( @@ -640,7 +640,7 @@ ); } - protected function getConflictMessage($unresolved = false): XmlContent + protected function getConflictMessage($unresolved = false) { /* xgettext only knows about c/c++ line-continuation strings @@ -1255,7 +1255,7 @@ class LoadFileConflictPageEditor extends PageEditor { - public function editPage($saveFailed = true): ?bool + public function editPage($saveFailed = true) { $tokens = &$this->tokens; @@ -1371,7 +1371,7 @@ return true; } - protected function getConflictMessage($unresolved = false): XmlContent + protected function getConflictMessage($unresolved = false) { return HTML(HTML::p( fmt( This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <var...@us...> - 2024-02-27 09:00:23
|
Revision: 11080 http://sourceforge.net/p/phpwiki/code/11080 Author: vargenau Date: 2024-02-27 09:00:21 +0000 (Tue, 27 Feb 2024) Log Message: ----------- Deprecated: Using ${var} in strings is deprecated, use {$var} instead Modified Paths: -------------- trunk/lib/InlineParser.php trunk/lib/WikiTheme.php trunk/lib/config.php trunk/lib/mimelib.php trunk/lib/plugin/AppendText.php trunk/lib/stdlib.php Modified: trunk/lib/InlineParser.php =================================================================== --- trunk/lib/InlineParser.php 2024-02-27 08:33:44 UTC (rev 11079) +++ trunk/lib/InlineParser.php 2024-02-27 09:00:21 UTC (rev 11080) @@ -789,23 +789,23 @@ $b = "\\* (?! \\*)"; $tt = "= (?! =)"; - $any = "(?: ${i}|${b}|${tt})"; // any of the three. + $any = "(?: {$i}|{$b}|{$tt})"; // any of the three. // Any of [_*=] is okay if preceded by space or one of [-"'/:] - $start[] = "(?<= \\s|^|[-\"'\\/:]) ${any}"; + $start[] = "(?<= \\s|^|[-\"'\\/:]) {$any}"; // _ or * is okay after = as long as not immediately followed by = - $start[] = "(?<= =) (?: ${i}|${b}) (?! =)"; + $start[] = "(?<= =) (?: {$i}|{$b}) (?! =)"; // etc... - $start[] = "(?<= _) (?: ${b}|${tt}) (?! _)"; - $start[] = "(?<= \\*) (?: ${i}|${tt}) (?! \\*)"; + $start[] = "(?<= _) (?: {$b}|{$tt}) (?! _)"; + $start[] = "(?<= \\*) (?: {$i}|{$tt}) (?! \\*)"; // any delimiter okay after an opening brace ( [{<(] ) // as long as it's not immediately followed by the matching closing // brace. - $start[] = "(?<= { ) ${any} (?! } )"; - $start[] = "(?<= < ) ${any} (?! > )"; - $start[] = "(?<= \\( ) ${any} (?! \\) )"; + $start[] = "(?<= { ) {$any} (?! } )"; + $start[] = "(?<= < ) {$any} (?! > )"; + $start[] = "(?<= \\( ) {$any} (?! \\) )"; $start = "(?:" . join('|', $start) . ")"; Modified: trunk/lib/WikiTheme.php =================================================================== --- trunk/lib/WikiTheme.php 2024-02-27 08:33:44 UTC (rev 11079) +++ trunk/lib/WikiTheme.php 2024-02-27 09:00:21 UTC (rev 11080) @@ -675,7 +675,7 @@ public function getFormatter($type, $format) { - $method = strtolower("get${type}Formatter"); + $method = strtolower("get{$type}Formatter"); if (method_exists($this, $method)) { return $this->{$method}($format); } Modified: trunk/lib/config.php =================================================================== --- trunk/lib/config.php 2024-02-27 08:33:44 UTC (rev 11079) +++ trunk/lib/config.php 2024-02-27 09:00:21 UTC (rev 11080) @@ -127,7 +127,7 @@ $requri = preg_replace('/\?.*$/', '', $GLOBALS['HTTP_SERVER_VARS']['REQUEST_URI']); $requri = preg_quote($requri, '%'); - return preg_match("%^${requri}[^/]*$%", $GLOBALS['HTTP_SERVER_VARS']['SCRIPT_NAME']); + return preg_match("%^{$requri}[^/]*$%", $GLOBALS['HTTP_SERVER_VARS']['SCRIPT_NAME']); } function getUploadFilePath() Modified: trunk/lib/mimelib.php =================================================================== --- trunk/lib/mimelib.php 2024-02-27 08:33:44 UTC (rev 11079) +++ trunk/lib/mimelib.php 2024-02-27 09:00:21 UTC (rev 11080) @@ -101,7 +101,7 @@ $sep = "\r\n--$boundary\r\n"; - return $head . $sep . implode($sep, $parts) . "\r\n--${boundary}--\r\n"; + return $head . $sep . implode($sep, $parts) . "\r\n--{$boundary}--\r\n"; } /** Modified: trunk/lib/plugin/AppendText.php =================================================================== --- trunk/lib/plugin/AppendText.php 2024-02-27 08:33:44 UTC (rev 11079) +++ trunk/lib/plugin/AppendText.php 2024-02-27 09:00:21 UTC (rev 11080) @@ -125,9 +125,9 @@ if (!empty($args['before'])) { $before = preg_quote($args['before'], "/"); // Insert before - $newtext = preg_match("/\n${before}/", $oldtext) + $newtext = preg_match("/\n{$before}/", $oldtext) ? preg_replace( - "/(\n${before})/", + "/(\n{$before})/", "\n" . preg_quote($text, "/") . "\\1", $oldtext ) @@ -135,9 +135,9 @@ } elseif (!empty($args['after'])) { // Insert after $after = preg_quote($args['after'], "/"); - $newtext = preg_match("/\n${after}/", $oldtext) + $newtext = preg_match("/\n{$after}/", $oldtext) ? preg_replace( - "/(\n${after})/", + "/(\n{$after})/", "\\1\n" . preg_quote($text, "/"), $oldtext ) Modified: trunk/lib/stdlib.php =================================================================== --- trunk/lib/stdlib.php 2024-02-27 08:33:44 UTC (rev 11079) +++ trunk/lib/stdlib.php 2024-02-27 09:00:21 UTC (rev 11080) @@ -1118,10 +1118,10 @@ // capitalized words. switch ($GLOBALS['LANG']) { case 'en': - $RE[] = "/(?<= |${sep}|^)([AI])([[:upper:]][[:lower:]])/"; + $RE[] = "/(?<= |{$sep}|^)([AI])([[:upper:]][[:lower:]])/"; break; case 'fr': - $RE[] = "/(?<= |${sep}|^)([À])([[:upper:]][[:lower:]])/"; + $RE[] = "/(?<= |{$sep}|^)([À])([[:upper:]][[:lower:]])/"; break; } // Split at underscore @@ -1130,8 +1130,8 @@ // Split numerals from following letters. $RE[] = '/(\d)([[:alpha:]])/'; // Split at subpage separators. TBD in WikiTheme.php - $RE[] = "/([^${sep}]+)(${sep})/"; - $RE[] = "/(${sep})([^${sep}]+)/"; + $RE[] = "/([^{$sep}]+)({$sep})/"; + $RE[] = "/({$sep})([^{$sep}]+)/"; foreach ($RE as $key) { $RE[$key] = $key; @@ -1316,7 +1316,7 @@ return false; } - $time = strtotime("$mday $mon $year ${hh}:${mm}:${ss} GMT"); + $time = strtotime("$mday $mon $year {$hh}:{$mm}:{$ss} GMT"); if ($time == -1) { return false; } // failed This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <car...@us...> - 2025-02-14 07:32:28
|
Revision: 11105 http://sourceforge.net/p/phpwiki/code/11105 Author: carstenklapp Date: 2025-02-14 07:32:26 +0000 (Fri, 14 Feb 2025) Log Message: ----------- minor, fixed php depreciated errors Modified Paths: -------------- trunk/lib/HtmlElement.php trunk/lib/Template.php trunk/lib/XmlElement.php Modified: trunk/lib/HtmlElement.php =================================================================== --- trunk/lib/HtmlElement.php 2025-02-14 07:19:38 UTC (rev 11104) +++ trunk/lib/HtmlElement.php 2025-02-14 07:32:26 UTC (rev 11105) @@ -45,6 +45,7 @@ { public $_tag; public $_attr; + public $_properties; public function __construct($tagname /* , $attr_or_content , ...*/) { Modified: trunk/lib/Template.php =================================================================== --- trunk/lib/Template.php 2025-02-14 07:19:38 UTC (rev 11104) +++ trunk/lib/Template.php 2025-02-14 07:32:26 UTC (rev 11105) @@ -37,6 +37,13 @@ * @param WikiRequest $request * @param array $args */ + public $_name; + public $_basepage; + public $_tmpl; + public $_locals; + public $_vars; + public $_request; + public function __construct($name, &$request, $args = array()) { global $WikiTheme; Modified: trunk/lib/XmlElement.php =================================================================== --- trunk/lib/XmlElement.php 2025-02-14 07:19:38 UTC (rev 11104) +++ trunk/lib/XmlElement.php 2025-02-14 07:32:26 UTC (rev 11105) @@ -42,6 +42,8 @@ */ class XmlContent { + public $_content; + public function __construct(/* ... */) { $this->_content = array(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <car...@us...> - 2025-02-18 07:46:35
|
Revision: 11128 http://sourceforge.net/p/phpwiki/code/11128 Author: carstenklapp Date: 2025-02-18 07:46:33 +0000 (Tue, 18 Feb 2025) Log Message: ----------- disable debugging code Modified Paths: -------------- trunk/lib/SemanticWeb.php trunk/lib/difflib.php Modified: trunk/lib/SemanticWeb.php =================================================================== --- trunk/lib/SemanticWeb.php 2025-02-18 06:52:56 UTC (rev 11127) +++ trunk/lib/SemanticWeb.php 2025-02-18 07:46:33 UTC (rev 11128) @@ -193,7 +193,7 @@ */ // This plugin doesn't seem to be finished. Carsten echo "<pre>DEBUG:\n"; - print_r($this->_pagelist); + // print_r($this->_pagelist); foreach ($this->_pagelist->_pages as $page) { $relation = new TextSearchQuery("*"); foreach (array('linkto', 'linkfrom', 'relation', 'attribute') as $linktype) { Modified: trunk/lib/difflib.php =================================================================== --- trunk/lib/difflib.php 2025-02-18 06:52:56 UTC (rev 11127) +++ trunk/lib/difflib.php 2025-02-18 07:46:33 UTC (rev 11128) @@ -312,7 +312,7 @@ } foreach ($matches as $junk => $y) { if ($y > $this->seq[$k - 1]) { - assert($y < $this->seq[$k]); + //assert($y < $this->seq[$k]); // Optimization: this is a common case: // next match is just replacing previous match. $this->in_seq[$this->seq[$k]] = false; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <car...@us...> - 2025-02-19 23:04:43
|
Revision: 11153 http://sourceforge.net/p/phpwiki/code/11153 Author: carstenklapp Date: 2025-02-19 23:04:42 +0000 (Wed, 19 Feb 2025) Log Message: ----------- Merged functions DumpToDir and DumpSVNToDir. Added file counter to DumpToDir. Don't overwrite existing files. Reformat progress output. Cleanup strings for translation Modified Paths: -------------- trunk/lib/loadsave.php trunk/lib/main.php Modified: trunk/lib/loadsave.php =================================================================== --- trunk/lib/loadsave.php 2025-02-19 21:46:05 UTC (rev 11152) +++ trunk/lib/loadsave.php 2025-02-19 23:04:42 UTC (rev 11153) @@ -319,146 +319,13 @@ exit; } -/** - * @param WikiRequest $request - */ -function DumpSVNToDir(&$request) //this is mostly a copy of DumpToDir -{ - $directory = $request->getArg('directory'); - if (empty($directory)) { - $directory = DEFAULT_DUMP_DIR; - } - if (empty($directory)) { - $html = HTML::p( - array('class' => 'error'), - _("You must specify a directory to dump to") - ); - StartLoadDump($request, _("Dumping Pages for developer"), $html); - EndLoadDump($request); - return; - } - - // see if we can access the directory the user wants us to use - if (!file_exists($directory)) { - if (!mkdir_p($directory, 0755)) { - $html = HTML::p( - array('class' => 'error'), - fmt("Cannot create directory “%s”", $directory) - ); - StartLoadDump($request, _("Dumping Pages for developer"), $html); - EndLoadDump($request); - return; - } else { - $html = HTML::p(fmt( - "Created directory “%s” for the page dump...", - $directory - )); - } - } elseif (!is_writable($directory)) { - $html = HTML::p( - array('class' => 'error'), - fmt( - "Cannot use directory “%s”, it is not writable", - $directory - ) - ); - StartLoadDump($request, _("Dumping pages for SVN"), $html); - EndLoadDump($request); - return; - } else { - $html = HTML::p(fmt("Using directory “%s”", $directory)); - } - - StartLoadDump($request, _("Dumping pages for SVN"), $html); - - $dbi =& $request->_dbi; - $thispage = $request->getArg('pagename'); // for "Return to ..." - if ($exclude = $request->getArg('exclude')) { // exclude which pagenames - $excludeList = explodePageList($exclude); - } else { - $excludeList = array(); - } - $include_empty = false; - if ($request->getArg('include') == 'empty') { - $include_empty = true; - } - if ($pages = $request->getArg('pages')) { // which pagenames - if ($pages == '[]') { // current page - $pages = $thispage; - } - $page_iter = new WikiDB_Array_PageIterator(explodePageList($pages)); - } else { - $page_iter = $dbi->getAllPages($include_empty, false, false, $excludeList); - } - - $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 - - $pagename = $page->getName(); - PrintXML(HTML::br(), $pagename, ' ... '); - flush(); - - if (in_array($pagename, $excludeList)) { - PrintXML(_("Skipped")); - flush(); - continue; - } - //$filename = FilenameForPage($pagename, 'dumpsvn');//why doesn't this workzzz - $filename = rawurlencode($pagename);//this works - $msg = HTML(); - if ($page->getName() != $filename) { - $msg->pushContent( - HTML::small(fmt("saved as %s", $filename)), - " ... " - ); - } - - if ($request->getArg('include') == 'all') { - $data = MailifyPage($page, 0, true); - } else { - $data = MailifyPage($page, 1, true); - } - - if (!($fd = fopen($directory . "/" . $filename, "wb"))) { - $msg->pushContent(HTML::strong(fmt( - "couldn't open file “%s” for writing", - "$directory/$filename" - ))); - $request->finish($msg); - } - - $num = fwrite($fd, $data, strlen($data)); - $msg->pushContent(HTML::small(fmt("%s bytes written", $num))); - PrintXML($msg); - flush(); - assert($num == strlen($data)); - fclose($fd); - - $current = $page->getCurrentRevision(false); - $author=$current->get('author'); - if (isPhpWikiTeam($author)) { //default_pgsrc_hasnotbeenmodified - $creationdate = $page->get('date'); - echo (" (unmodified default page)"); - // echo " DEBUG: setting as Creation Date: " . Rfc2822DateTime($creationdate) . " " . $creationdate . "\n"; - touch($directory . "/" . $filename, $creationdate); - } else { - $moddate = $current->get('mtime'); - // echo " DEBUG: setting as Modification Date: " . Rfc2822DateTime($moddate) . " " . $moddate . "\n"; - touch($directory . "/" . $filename, $moddate); - } - } - - EndLoadDump($request); -} - function isPhpWikiTeam($author) { - $translated_teamnames = array( //do not mark these with _() + // Do not mark these for translation with _() + // More will have to be manually added as translators add to it + $translated_teamnames = array( "The PhpWiki Team", //en - "Das PhpWiki Team" //de + "Das PhpWiki-Team", //de + "L'équipe PhpWiki" //fr ); return in_array($author, $translated_teamnames, true); } @@ -468,6 +335,12 @@ */ function DumpToDir(&$request) { + $forsvn = false; + $title = _("Dumping Pages"); + if ($request->getArg('action') == 'dumpsvn') { + $forsvn = true; + $title = _("Dumping Pages for SVN"); + } $directory = $request->getArg('directory'); if (empty($directory)) { $directory = DEFAULT_DUMP_DIR; @@ -475,9 +348,9 @@ if (empty($directory)) { $html = HTML::p( array('class' => 'error'), - _("You must specify a directory to dump to") + _("You must specify a directory to dump to.") ); - StartLoadDump($request, _("Dumping Pages"), $html); + StartLoadDump($request, $title, $html); EndLoadDump($request); return; } @@ -487,14 +360,14 @@ if (!mkdir_p($directory, 0755)) { $html = HTML::p( array('class' => 'error'), - fmt("Cannot create directory “%s”", $directory) + fmt("Cannot create directory “%s”.", $directory) ); - StartLoadDump($request, _("Dumping Pages"), $html); + StartLoadDump($request, $title, $html); EndLoadDump($request); return; } else { $html = HTML::p(fmt( - "Created directory “%s” for the page dump...", + _("Created directory “%s” for the page dump..."), $directory )); } @@ -502,18 +375,18 @@ $html = HTML::p( array('class' => 'error'), fmt( - "Cannot use directory “%s”, it is not writable", + _("Cannot use directory “%s”, it is not writable."), $directory ) ); - StartLoadDump($request, _("Dumping Pages"), $html); + StartLoadDump($request, $title, $html); EndLoadDump($request); return; } else { - $html = HTML::p(fmt("Using directory “%s”", $directory)); + $html = HTML::p(fmt(_("Using directory “%s”"), $directory)); } - StartLoadDump($request, _("Dumping Pages"), $html); + StartLoadDump($request, $title, $html); $dbi =& $request->_dbi; $thispage = $request->getArg('pagename'); // for "Return to ..." @@ -537,66 +410,107 @@ $request_args = $request->args; $timeout = (!$request->getArg('start_debug')) ? 30 : 240; + PrintXML(HTML::hr()); + $counttotal = 0; + $countsaved = 0; + $countskipped = 0; + $countexcluded = 0; + $SEP = ' ... '; while ($page = $page_iter->next()) { + $counttotal++; $request->args = $request_args; // some plugins might change them (esp. on POST) longer_timeout($timeout); // Reset watchdog $pagename = $page->getName(); - PrintXML(HTML::br(), $pagename, ' ... '); + echo "\n"; + PrintXML(HTML::br(), $pagename, $SEP); flush(); if (in_array($pagename, $excludeList)) { - PrintXML(_("Skipped")); + PrintXML(_("Excluded")); flush(); + $countexcluded++; + echo "\n"; continue; } - //$filename = FilenameForPage($pagename, 'dumpserial');//why doesn't this workzzz + //$filename = FilenameForPage($pagename, $forsvn ? 'dumpsvn', 'dumpserial');//why doesn't this workzzz $filename = rawurlencode($pagename);//this works $msg = HTML(); if ($page->getName() != $filename) { $msg->pushContent( - HTML::small(fmt("saved as %s", $filename)), - " ... " + HTML::small(fmt("naming as %s", $filename)), + $SEP ); } - if ($request->getArg('include') == 'all') { - $data = MailifyPage($page, 0); + // Fixme: the way MailifyPage is called is nasty + if ($forsvn) { + if ($request->getArg('include') == 'all') { + $data = MailifyPage($page, 0, true); + } else { + $data = MailifyPage($page, 1, true); + } } else { - $data = MailifyPage($page); + if ($request->getArg('include') == 'all') { + $data = MailifyPage($page, 0); + } else { + $data = MailifyPage($page); + } } + // Do not overwrite files + if (file_exists($directory . "/" . $filename)) { + $msg->pushContent(HTML::span(_( + _("skipping existing file.") + ))); + //$request->finish($msg); + PrintXML($msg); + $countskipped++; + continue; + } if (!($fd = fopen($directory . "/" . $filename, "wb"))) { - $msg->pushContent(HTML::strong(fmt( - "couldn't open file “%s” for writing", - "$directory/$filename" + $msg->pushContent($SEP, HTML::span(_( + _("couldn't open file for writing") ))); + //$request->finish($msg); + PrintXML($msg); + flush(); + $countskipped++; + // echo "\n"; + continue; + } + if (!$fd) { + echo("\nDEBUG error: fd missing. should not get here!\n"); $request->finish($msg); } $num = fwrite($fd, $data, strlen($data)); - $msg->pushContent(HTML::small(fmt("%s bytes written", $num))); - PrintXML($msg); - flush(); + $msg->pushContent(HTML::strong(fmt(_("%s bytes written"), $num))); assert($num == strlen($data)); fclose($fd); + $countsaved++; $current = $page->getCurrentRevision(false); $author=$current->get('author'); if (isPhpWikiTeam($author)) { //default_pgsrc_hasnotbeenmodified $creationdate = $page->get('date'); - echo (" (unmodified default page)"); + assert($creationdate!=0); // echo " DEBUG: setting as Creation Date: " . Rfc2822DateTime($creationdate) . " " . $creationdate . "\n"; touch($directory . "/" . $filename, $creationdate); + $msg->pushContent(HTML::em($SEP, _("(unmodified default page)"))); } else { $moddate = $current->get('mtime'); // echo " DEBUG: setting as Modification Date: " . Rfc2822DateTime($moddate) . " " . $moddate . "\n"; touch($directory . "/" . $filename, $moddate); } - - + PrintXML($msg); + flush(); } + $msg = HTML::hr(); + $msg->pushContent(HTML::p(fmt(_("Total pages: %d, Saved: %d, Skipped: %d, Excluded: %d"), $counttotal, $countsaved, $countskipped, $countexcluded))); + PrintXML($msg); + //flush(); EndLoadDump($request); } @@ -658,10 +572,10 @@ // See if we can access the directory the user wants us to use if (!file_exists($directory)) { if (!mkdir_p($directory, 0755)) { - $request->finish(fmt("Cannot create directory “%s”", $directory)); + $request->finish(fmt(_("Cannot create directory “%s”."), $directory)); } else { $html = HTML::p(fmt( - "Created directory “%s” for the page dump...", + _("Created directory “%s” for the page dump..."), $directory )); } @@ -864,7 +778,7 @@ } if (in_array($pagename, $excludeList)) { if (!$silent) { - PrintXML(_("Skipped")); + PrintXML(_("Excluded")); flush(); } continue; @@ -941,7 +855,7 @@ $outfile = $directory . "/" . $filename; if (!($fd = fopen($outfile, "wb"))) { $msg->pushContent(HTML::strong(fmt( - "couldn't open file “%s” for writing", + _("couldn't open file “%s” for writing."), $outfile ))); $request->finish($msg); Modified: trunk/lib/main.php =================================================================== --- trunk/lib/main.php 2025-02-19 21:46:05 UTC (rev 11152) +++ trunk/lib/main.php 2025-02-19 23:04:42 UTC (rev 11153) @@ -1390,7 +1390,7 @@ public function action_dumpsvn() { include_once 'lib/loadsave.php'; - DumpSVNToDir($this); + DumpToDir($this); } public function action_dumpserial() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |