|
From: <var...@us...> - 2014-12-08 14:19:29
|
Revision: 9430
http://sourceforge.net/p/phpwiki/code/9430
Author: vargenau
Date: 2014-12-08 14:19:26 +0000 (Mon, 08 Dec 2014)
Log Message:
-----------
Add public/private; remove unused code
Modified Paths:
--------------
trunk/lib/upgrade.php
Modified: trunk/lib/upgrade.php
===================================================================
--- trunk/lib/upgrade.php 2014-12-08 10:50:45 UTC (rev 9429)
+++ trunk/lib/upgrade.php 2014-12-08 14:19:26 UTC (rev 9430)
@@ -67,7 +67,7 @@
$this->isSQL = $this->dbi->_backend->isSQL();
}
- function doPgsrcUpdate($pagename, $path, $filename)
+ private function doPgsrcUpdate($pagename, $path, $filename)
{
// don't ever update the HomePage
if ((defined(HOME_PAGE) and ($pagename == HOME_PAGE))
@@ -117,7 +117,7 @@
}
}
- function CheckActionPageUpdate()
+ public function CheckActionPageUpdate()
{
echo "<h2>", sprintf(_("Check for necessary %s updates"), _("Action Pages")), "</h2>\n";
// 1.3.13 before we pull in all missing pages, we rename existing ones
@@ -154,7 +154,7 @@
}
// see loadsave.php for saving new pages.
- function CheckPgsrcUpdate()
+ public function CheckPgsrcUpdate()
{
// Check some theme specific pgsrc files (blog, wikilens, fusionforge, custom).
// We check theme specific pgsrc first in case the page is present in both
@@ -203,7 +203,7 @@
}
}
- function _rename_page_helper($oldname, $pagename)
+ private function _rename_page_helper($oldname, $pagename)
{
echo sprintf(_("rename %s to %s"), $oldname, $pagename), " ...";
if ($this->dbi->isWikiPage($oldname) and !$this->dbi->isWikiPage($pagename)) {
@@ -217,7 +217,7 @@
}
}
- function _rename_to_help_page($pagename)
+ private function _rename_to_help_page($pagename)
{
$newprefix = _("Help") . "/";
if (substr($pagename, 0, strlen($newprefix)) != $newprefix) return;
@@ -230,7 +230,7 @@
* and create it.
* Supported: mysql and generic SQL, for ADODB and PearDB.
*/
- function installTable($table, $backend_type)
+ private function installTable($table, $backend_type)
{
global $DBParams;
if (!$this->isSQL) return;
@@ -395,7 +395,7 @@
* jeffs-hacks database api (around 1.3.2) later:
* people should export/import their pages if using that old versions.
*/
- function CheckDatabaseUpdate()
+ public function CheckDatabaseUpdate()
{
global $DBParams;
@@ -728,7 +728,7 @@
return false;
}
- function _try_dbadmin_user($user, $passwd)
+ private function _try_dbadmin_user($user, $passwd)
{
global $DBParams;
$AdminParams = $DBParams;
@@ -757,7 +757,7 @@
return false;
}
- function _db_init()
+ private function _db_init()
{
if (!$this->isSQL) return;
@@ -822,9 +822,9 @@
* not into the huge serialized string.
*
* It is only rarelely needed: for current page only, if-not-modified,
- * but was extracetd for every simple page iteration.
+ * but was extracted for every simple page iteration.
*/
- function _upgrade_cached_html($verbose = true)
+ private function _upgrade_cached_html($verbose = true)
{
if (!$this->isSQL) return 0;
$count = 0;
@@ -848,7 +848,7 @@
$this->dbi->genericSqlQuery("ALTER TABLE $page_tbl ADD cached_html BLOB");
if ($verbose)
echo "<b>", _("CONVERTING"), "</b>", " ... ";
- $count = _convert_cached_html();
+ $count = $this->_convert_cached_html();
if ($verbose)
echo $count, " ", _("OK"), "<br />\n";
} else {
@@ -863,7 +863,7 @@
* move _cached_html for all pages from pagedata into a new separate blob.
* decoupled from action=upgrade, so that it can be used by a WikiAdminUtils button also.
*/
- function _convert_cached_html()
+ private function _convert_cached_html()
{
if (!$this->isSQL) return 0;
//if (!in_array(DATABASE_TYPE, array('SQL','ADODB'))) return;
@@ -891,7 +891,7 @@
/**
* upgrade to 1.3.13 link structure.
*/
- function _upgrade_relation_links()
+ private function _upgrade_relation_links()
{
if ($this->phpwiki_version >= 1030.12200610 and $this->isSQL) {
echo _("Check for relation field in link table"), " ...";
@@ -926,49 +926,11 @@
}
}
- function CheckPluginUpdate()
- {
- echo "<h2>", sprintf(_("Check for necessary %s updates"),
- _("plugin argument")), "</h2>\n";
-
- $this->_configUpdates = array();
- $this->_configUpdates[] = new UpgradePluginEntry
- ($this, array('key' => 'plugin_randompage_numpages',
- 'fixed_with' => 1012.0,
- //'header' => _("change RandomPage pages => numpages"),
- //'notice' =>_("found RandomPage plugin"),
- 'check_args' => array("plugin RandomPage pages",
- "/(<\?\s*plugin\s+ RandomPage\s+)pages/",
- "\\1numpages")));
- $this->_configUpdates[] = new UpgradePluginEntry
- ($this, array('key' => 'plugin_createtoc_position',
- 'fixed_with' => 1013.0,
- //'header' => _("change CreateToc align => position"),
- //'notice' =>_("found CreateToc plugin"),
- 'check_args' => array("plugin CreateToc align",
- "/(<\?\s*plugin\s+ CreateToc[^\?]+)align/",
- "\\1position")));
-
- if (empty($this->_configUpdates)) return;
- foreach ($this->_configUpdates as $update) {
- $allpages = $this->dbi->fullSearch($this->check_args[0]);
- while ($page = $allpages->next()) {
- $current = $page->getCurrentRevision();
- $pagetext = $current->getPackedContent();
- $update->check($this->check_args[1], $this->check_args[2], $pagetext, $page, $current);
- }
- }
- free($allpages);
- unset($pagetext);
- unset($current);
- unset($page);
- }
-
/**
* preg_replace over local file.
* Only line-orientated matches possible.
*/
- function fixLocalFile($match, $replace, $filename)
+ public function fixLocalFile($match, $replace, $filename)
{
$o_filename = $filename;
if (!file_exists($filename))
@@ -1016,7 +978,7 @@
}
}
- function CheckConfigUpdate()
+ public function CheckConfigUpdate()
{
echo "<h2>", sprintf(_("Check for necessary %s updates"),
"config.ini"), "</h2>\n";
@@ -1105,12 +1067,12 @@
}
/* needed ? */
- function setApplicableCb($object)
+ public function setApplicableCb($object)
{
$this->applicable_cb =& $object;
}
- function _check_if_already_fixed()
+ private function _check_if_already_fixed()
{
// not yet fixed?
if (!isset($this->upgrade['name'])) return false;
@@ -1122,7 +1084,7 @@
return false;
}
- function pass()
+ public function pass()
{
// store in db no to fix again
$this->upgrade['name'] = $this->parent->phpwiki_version;
@@ -1135,7 +1097,7 @@
return true;
}
- function fail()
+ public function fail()
{
echo '<span style="color: red; font-weight: bold; ">' . _("FAILED") . "</span>";
if (isset($this->reason))
@@ -1145,7 +1107,7 @@
return false;
}
- function skip()
+ private function skip()
{ // not applicable
if (isset($this->silent_skip)) return true;
echo " " . _("Skipped.") . "<br />\n";
@@ -1153,7 +1115,7 @@
return true;
}
- function check($args = null)
+ public function check($args = null)
{
if ($this->header) echo $this->header, ' ... ';
if ($when = $this->_check_if_already_fixed()) {
@@ -1187,18 +1149,18 @@
class UpgradeConfigEntry extends UpgradeEntry
{
- function _applicable_defined()
+ public function _applicable_defined()
{
return (boolean)defined($this->applicable_args[0]);
}
- function _applicable_defined_and_empty()
+ public function _applicable_defined_and_empty()
{
$const = $this->applicable_args[0];
return (boolean)(defined($const) and !constant($const));
}
- function default_method($args)
+ public function default_method($args)
{
$match = $args[0];
$replace = $args[1];
@@ -1206,87 +1168,6 @@
}
} // class UpdateConfigEntry
-/* This is different */
-class UpgradePluginEntry extends UpgradeEntry
-{
-
- /**
- * check all pages for a plugin match
- */
- public $silent_skip = 1;
-
- function default_method(&$args)
- {
- $match = $args[0];
- $replace = $args[1];
- $pagetext =& $args[2];
- $page =& $args[3];
- $current =& $args[4];
- if (preg_match($match, $pagetext)) {
- echo $page->getName(), " ", $this->notice, " ... ";
- if ($newtext = preg_replace($match, $replace, $pagetext)) {
- $meta = $current->_data;
- $meta['summary'] = "upgrade: " . $this->header;
- $page->save($newtext, $current->getVersion() + 1, $meta);
- $this->pass();
- } else {
- $this->fail();
- }
- }
- }
-} // class UpdatePluginEntry
-
-/**
- * fix custom themes which are not in our distribution
- * this should be optional
- */
-class UpgradeThemeEntry extends UpgradeEntry
-{
-
- function default_method(&$args)
- {
- $match = $args[0];
- $replace = $args[1];
- $template = $args[2];
- }
-
- function fixThemeTemplate($match, $new, $template)
- {
- // for all custom themes
- $ourthemes = explode(":", "blog:Crao:default:Hawaiian:MacOSX:MonoBook:Portland:shamino_com:SpaceWiki:wikilens:Wordpress");
- $themedir = NormalizeLocalFileName("themes");
- $dh = opendir($themedir);
- while ($r = readdir($dh)) {
- if (filetype($r) == 'dir' and $r[0] != '.' and !is_array($r, $ourthemes))
- $customthemes[] = $r;
- }
- $success = true;
- $errors = '';
- foreach ($customthemes as $customtheme) {
- $template = FindFile("themes/$customtheme/templates/$template");
- $do = $this->parent->fixLocalFile($match, $new, template);
- if (!$do[0]) {
- $success = false;
- $errors .= $do[1] . " ";
- echo $do[1];
- }
- }
- return array($success, $errors);
- }
-}
-
-/**
- * TODO:
- *
- * Upgrade: Base class for multipage worksteps
- * identify, validate, display options, next step
- */
-/*
-*/
-
-// TODO: At which step are we?
-// validate and do it again or go on with next step.
-
/** entry function from lib/main.php
*/
function DoUpgrade(&$request)
@@ -1303,8 +1184,6 @@
@ini_set("implicit_flush", true);
StartLoadDump($request, _("Upgrading this PhpWiki"));
$upgrade = new Upgrade($request);
- //if (!$request->getArg('noindex'))
- // CheckOldIndexUpdate($request); // index.php => config.ini to upgrade from < 1.3.10
if (!$request->getArg('nodb')) {
$upgrade->CheckDatabaseUpdate($request); // first check cached_html and friends
}
@@ -1312,15 +1191,9 @@
$upgrade->CheckPgsrcUpdate($request);
$upgrade->CheckActionPageUpdate($request);
}
- // if (!$request->getArg('noplugin')) {
- // $upgrade->CheckPluginUpdate($request);
- // }
if (!$request->getArg('noconfig')) {
$upgrade->CheckConfigUpdate($request);
}
- // This is optional and should be linked. In EndLoadDump or PhpWikiAdministration?
- //if ($request->getArg('theme'))
- // $upgrade->CheckThemeUpdate($request);
EndLoadDump($request);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|