From 38529dcedf16f3174f10dd2457a7d3941ae2ed00 Mon Sep 17 00:00:00 2001 From: rurban Date: Sun, 15 Feb 2004 21:34:37 +0000 Subject: [PATCH] PageList enhanced and improved. fixed new WikiAdmin... plugins editpage, Theme with exp. htmlarea framework (htmlarea yet committed, this is really questionable) WikiUser... code with better session handling for prefs enhanced UserPreferences (again) RecentChanges for show_deleted: how should pages be deleted then? git-svn-id: svn://svn.code.sf.net/p/phpwiki/code/trunk@3006 96ab9672-09ca-45d6-a79d-3d69d39ca109 --- lib/BlockParser.php | 4 +- lib/HtmlElement.php | 29 +++++++-- lib/InlineParser.php | 4 +- lib/PageList.php | 42 ++++++++++--- lib/Theme.php | 60 +++++++++++++++++- lib/WikiUser.php | 28 +++++++-- lib/WikiUserNew.php | 28 ++++++--- lib/config.php | 3 +- lib/editpage.php | 58 ++++++++++++++--- lib/main.php | 12 +++- lib/plugin/RecentChanges.php | 11 ++-- lib/plugin/UserPreferences.php | 34 +++++----- lib/plugin/WikiAdminRemove.php | 29 ++++----- lib/plugin/WikiAdminRename.php | 30 ++++----- lib/plugin/WikiAdminSearchReplace.php | 38 ++++++----- lib/plugin/WikiAdminSelect.php | 90 ++++++++++++++++++--------- 16 files changed, 364 insertions(+), 136 deletions(-) diff --git a/lib/BlockParser.php b/lib/BlockParser.php index 7e681bcf8..51a987729 100644 --- a/lib/BlockParser.php +++ b/lib/BlockParser.php @@ -1,4 +1,4 @@ - * * This file is part of PhpWiki. @@ -31,7 +31,7 @@ require_once('lib/InlineParser.php'); * (old-style) tables */ -// FIXME: unify this with the RegexpSet in InlinePArser. +// FIXME: unify this with the RegexpSet in InlineParser. /** * Return type from RegexpSet::match and RegexpSet::nextMatch. diff --git a/lib/HtmlElement.php b/lib/HtmlElement.php index 2e0fa0380..9d8898e2a 100644 --- a/lib/HtmlElement.php +++ b/lib/HtmlElement.php @@ -1,4 +1,4 @@ - tag containing javascript. * * @param string $js The javascript. + * @param string $script_args (optional) hash of script tags options + * e.g. to provide another version or the defer attr * @return HtmlElement A + constructs. + Revision 1.30 2003/02/17 06:02:25 dairiki Remove functions HiddenGets() and HiddenPosts(). diff --git a/lib/InlineParser.php b/lib/InlineParser.php index 5dc83c8a8..e09bf7a80 100644 --- a/lib/InlineParser.php +++ b/lib/InlineParser.php @@ -1,4 +1,4 @@ - * * This file is part of PhpWiki. @@ -394,7 +394,7 @@ class Markup_linebreak extends SimpleMarkup { var $_match_regexp = "(?: (? )"; - function markup () { + function markup ($match) { return HTML::br(); } } diff --git a/lib/PageList.php b/lib/PageList.php index 32ce87f26..0fa1a013e 100644 --- a/lib/PageList.php +++ b/lib/PageList.php @@ -1,4 +1,4 @@ -bytes = 50; - $this->_heading .= sprintf(_(" ... first %d bytes"), - $this->bytes); + if ($field == 'content') + $this->_heading .= sprintf(_(" ... first %d bytes"), + $this->bytes); + elseif ($field == 'hi_content') { + $search = $_POST['admin_replace']['from']; + $this->_heading .= sprintf(_(" ... around »%s«"),$search); + } } function _getValue ($page_handle, &$revision_handle) { if (!$revision_handle) @@ -216,17 +221,33 @@ class _PageList_Column_content extends _PageList_Column { // Not sure why implode is needed here, I thought // getContent() already did this, but it seems necessary. $c = implode("\n", $revision_handle->getContent()); - if (($len = strlen($c)) > $this->bytes) { + if ($this->_field == 'hi_content') { + $search = $_POST['admin_replace']['from']; + if ($search and ($i = strpos($c,$search))) { + $l = strlen($search); + $j = max(0,$i - ($this->bytes / 2)); + return HTML::div(array('style' => 'font-size:x-small'), + HTML::div(array('class' => 'transclusion'), + HTML::span(substr($c, $j, ($this->bytes / 2))), + HTML::span(array("style"=>"background:yellow"),$search), + HTML::span(substr($c, $i+$l, ($this->bytes / 2)))) + ); + } else { + $c = sprintf(_("»%s« not found"),$search); + return HTML::div(array('style' => 'font-size:x-small','align'=>'center'), + $c); + } + } elseif (($len = strlen($c)) > $this->bytes) { $c = substr($c, 0, $this->bytes); } include_once('lib/BlockParser.php'); // false --> don't bother processing hrefs for embedded WikiLinks $ct = TransformText($c, $revision_handle->get('markup'), false); - return HTML::div(array('style' => 'font-size:xx-small'), + return HTML::div(array('style' => 'font-size:x-small'), HTML::div(array('class' => 'transclusion'), $ct), - // TODO: Don't show bytes here if size column present too - /* Howto??? $this->parent->_columns['size'] ? "" :*/ - ByteFormatter($len, /*$longformat = */true)); + // Don't show bytes here if size column present too + ($this->parent->_columns_seen['size'] or !$len) ? "" : + ByteFormatter($len, /*$longformat = */true)); } }; @@ -341,7 +362,7 @@ class PageList { return; // exclude page. $dbi = $GLOBALS['request']->getDbh(); $page_handle = $dbi->getPage($page_handle); - } else { + } elseif (is_object($page_handle)) { if (in_array($page_handle->getName(), $this->_excluded_pages)) return; // exclude page. } @@ -454,6 +475,9 @@ class PageList { 'content' => new _PageList_Column_content('content', _("Content")), + 'hi_content' + => new _PageList_Column_content('hi_content', _("Content")), + 'remove' => new _PageList_Column_remove('remove', _("Remove")), diff --git a/lib/Theme.php b/lib/Theme.php index 2fc7468d4..bba13bc79 100644 --- a/lib/Theme.php +++ b/lib/Theme.php @@ -1,4 +1,4 @@ -_path . $this->_findFile("templates/$name.tmpl"); } + + var $_MoreHeaders = array(); + function addMoreHeaders ($element) { + array_push($this->_MoreHeaders,$element); + } + function getMoreHeaders () { + if (empty($this->_MoreHeaders)) + return ''; + $out = ''; + //$out = "\n"; + foreach ($this->_MoreHeaders as $h) { + if (is_object($h)) + $out .= printXML($h); + else + $out .= "$h\n"; + } + return $out; + } + + var $_MoreAttr = array(); + function addMoreAttr ($id,$element) { + if (empty($this->_MoreAttr) or !is_array($this->_MoreAttr[$id])) + $this->_MoreAttr[$id] = array($element); + else + array_push($this->_MoreAttr[$id],$element); + } + function getMoreAttr ($id) { + if (empty($this->_MoreAttr[$id])) + return ''; + $out = ''; + foreach ($this->_MoreAttr[$id] as $h) { + if (is_object($h)) + $out .= printXML($h); + else + $out .= "$h"; + } + return $out; + } }; @@ -1030,6 +1068,26 @@ class SubmitImageButton extends SubmitButton { }; // $Log: not supported by cvs2svn $ +// Revision 1.70 2004/01/26 09:17:48 rurban +// * changed stored pref representation as before. +// the array of objects is 1) bigger and 2) +// less portable. If we would import packed pref +// objects and the object definition was changed, PHP would fail. +// This doesn't happen with an simple array of non-default values. +// * use $prefs->retrieve and $prefs->store methods, where retrieve +// understands the interim format of array of objects also. +// * simplified $prefs->get() and fixed $prefs->set() +// * added $user->_userid and class '_WikiUser' portability functions +// * fixed $user object ->_level upgrading, mostly using sessions. +// this fixes yesterdays problems with loosing authorization level. +// * fixed WikiUserNew::checkPass to return the _level +// * fixed WikiUserNew::isSignedIn +// * added explodePageList to class PageList, support sortby arg +// * fixed UserPreferences for WikiUserNew +// * fixed WikiPlugin for empty defaults array +// * UnfoldSubpages: added pagename arg, renamed pages arg, +// removed sort arg, support sortby arg +// // Revision 1.69 2003/12/05 01:32:28 carstenklapp // New feature: Easier to run multiple wiks off of one set of code. Name // your logo and signature image files "YourWikiNameLogo.png" and diff --git a/lib/WikiUser.php b/lib/WikiUser.php index c01f3f96d..5fb8b4665 100644 --- a/lib/WikiUser.php +++ b/lib/WikiUser.php @@ -1,5 +1,5 @@ _request->setSessionVar('wiki_prefs', $prefs); // $this->_request->setCookieVar('WIKI_PREFS2', $this->_prefs, 365); // simple unpacked cookie @@ -715,6 +719,22 @@ class UserPreferences { } // $Log: not supported by cvs2svn $ +// Revision 1.48 2004/02/01 09:14:11 rurban +// Started with Group_Ldap (not yet ready) +// added new _AuthInfo plugin to help in auth problems (warning: may display passwords) +// fixed some configurator vars +// renamed LDAP_AUTH_SEARCH to LDAP_BASE_DN +// changed PHPWIKI_VERSION from 1.3.8a to 1.3.8pre +// USE_DB_SESSION defaults to true on SQL +// changed GROUP_METHOD definition to string, not constants +// changed sample user DBAuthParams from UPDATE to REPLACE to be able to +// create users. (Not to be used with external databases generally, but +// with the default internal user table) +// +// fixed the IndexAsConfigProblem logic. this was flawed: +// scripts which are the same virtual path defined their own lib/main call +// (hmm, have to test this better, phpwiki.sf.net/demo works again) +// // Revision 1.47 2004/01/27 23:23:39 rurban // renamed ->Username => _userid for consistency // renamed mayCheckPassword => mayCheckPass diff --git a/lib/WikiUserNew.php b/lib/WikiUserNew.php index 4f0019cb1..9a75d8042 100644 --- a/lib/WikiUserNew.php +++ b/lib/WikiUserNew.php @@ -1,5 +1,5 @@ _prefselect)) { + if ( $DBParams['dbtype'] == 'SQL' and !@is_int($this->_prefselect)) { $this->_prefmethod = 'SQL'; // really pear db $this->getAuthDbh(); // preparate the SELECT statement @@ -631,7 +631,7 @@ extends _AnonUser } if ( !empty($DBAuthParams['pref_update']) and $DBParams['dbtype'] == 'SQL' and - !is_int($this->_prefupdate)) { + !@is_int($this->_prefupdate)) { $this->_prefmethod = 'SQL'; $this->getAuthDbh(); $this->_prefupdate = $this->_auth_dbi->prepare( @@ -640,7 +640,7 @@ extends _AnonUser } if ( !empty($DBAuthParams['pref_update']) and $DBParams['dbtype'] == 'ADODB' and - !is_int($this->_prefupdate)) { + !isset($this->_prefupdate)) { $this->_prefmethod = 'ADODB'; // uses a simplier execute syntax $this->getAuthDbh(); // preparate the SELECT statement @@ -958,13 +958,13 @@ extends _DbPassUser $this->getAuthDbh(); $this->_auth_crypt_method = $GLOBALS['DBAuthParams']['auth_crypt_method']; // Prepare the configured auth statements - if (!empty($DBAuthParams['auth_check']) and !is_int($this->_authselect)) { + if (!empty($DBAuthParams['auth_check']) and !@is_int($this->_authselect)) { $this->_authselect = $this->_auth_dbi->prepare ( str_replace(array('"$userid"','"$password"'),array('?','?'), $DBAuthParams['auth_check']) ); } - if (!empty($DBAuthParams['auth_update']) and !is_int($this->_authupdate)) { + if (!empty($DBAuthParams['auth_update']) and !@is_int($this->_authupdate)) { $this->_authupdate = $this->_auth_dbi->prepare( str_replace(array('"$userid"','"$password"'),array('?','?'), $DBAuthParams['auth_update']) @@ -978,7 +978,7 @@ extends _DbPassUser // clutter the homepage metadata with prefs. _AnonUser::getPreferences(); $this->getAuthDbh(); - if ((! $this->_prefs) && is_int($this->_prefselect)) { + if ((! $this->_prefs) && @is_int($this->_prefselect)) { $db_result = $this->_auth_dbi->execute($this->_prefselect,$this->_userid); list($prefs_blob) = $db_result->fetchRow(); if ($restored_from_db = $this->_prefs->retrieve($prefs_blob)) { @@ -1011,7 +1011,7 @@ extends _DbPassUser //$request->setSessionVar('wiki_prefs', $this->_prefs); $request->setSessionVar('wiki_user', $request->_user); } - if (is_int($this->_prefupdate)) { + if (@is_int($this->_prefupdate)) { $db_result = $this->_auth_dbi->execute($this->_prefupdate, array($packed,$this->_userid)); } else { @@ -1052,7 +1052,7 @@ extends _DbPassUser } function checkPass($submitted_password) { - if (!is_int($this->_authselect)) + if (!@is_int($this->_authselect)) trigger_error("Either \$DBAuthParams['auth_check'] is missing or \$DBParams['dbtype'] != 'SQL'", E_USER_WARNING); @@ -1089,7 +1089,7 @@ extends _DbPassUser } function storePass($submitted_password) { - if (!is_int($this->_authupdate)) { + if (!@is_int($this->_authupdate)) { //CHECKME trigger_warning("Either \$DBAuthParams['auth_update'] not defined or \$DBParams['dbtype'] != 'SQL'", E_USER_WARNING); @@ -1887,6 +1887,14 @@ extends UserPreferences // $Log: not supported by cvs2svn $ +// Revision 1.14 2004/02/15 17:30:13 rurban +// workaround for lost db connnection handle on session restauration (->_auth_dbi) +// fixed getPreferences() (esp. from sessions) +// fixed setPreferences() (update and set), +// fixed AdoDb DB statements, +// update prefs only at UserPreferences POST (for testing) +// unified db prefs methods (but in external pref classes yet) +// // Revision 1.13 2004/02/09 03:58:12 rurban // for now default DB_SESSION to false // PagePerm: diff --git a/lib/config.php b/lib/config.php index a1aea175f..6c57f09a8 100644 --- a/lib/config.php +++ b/lib/config.php @@ -1,5 +1,5 @@ selected; $current = &$this->current; @@ -109,8 +115,11 @@ class PageEditor $title = new FormattedText ($title_fs, $pagelink); + if ($template == 'editpage' and USE_HTMLAREA) { + $Theme->addMoreHeaders(Edit_HtmlArea_Head()); + //$tokens['PAGE_SOURCE'] = Edit_HtmlArea_ConvertBefore($this->_content); + } $template = Template($template, $this->tokens); - GeneratePage($template, $title, $rev); return true; } @@ -171,6 +180,7 @@ class PageEditor $meta = array_merge($meta, $this->meta); // Save new revision + $this->_content = $this->getContent(); $newrevision = $page->save($this->_content, $this->_currentVersion + 1, $meta); if (!isa($newrevision, 'wikidb_pagerevision')) { // Save failed. (Concurrent updates). @@ -236,9 +246,21 @@ class PageEditor function getPreview () { include_once('lib/PageType.php'); + $this->_content = $this->getContent(); return new TransformedText($this->page, $this->_content, $this->meta); } + // possibly convert HTMLAREA content back to Wiki markup + function getContent () { + if (USE_HTMLAREA) { + $xml_output = Edit_HtmlArea_ConvertAfter($this->_content); + $this->_content = join("",$xml_output->_content); + return $this->_content; + } else { + return $this->_content; + } + } + function getLockedMessage () { return HTML(HTML::h2(_("Page Locked")), @@ -285,14 +307,23 @@ class PageEditor // wrap=virtual is not HTML4, but without it NS4 doesn't wrap // long lines $readonly = ! $this->canEdit(); // || $this->isConcurrentUpdate(); - - return HTML::textarea(array('class' => 'wikiedit', - 'name' => 'edit[content]', - 'rows' => $request->getPref('editHeight'), - 'cols' => $request->getPref('editWidth'), - 'readonly' => (bool) $readonly, - 'wrap' => 'virtual'), - $this->_content); + if (USE_HTMLAREA) { + $html = $this->getPreview(); + $this->_wikicontent = $this->_content; + $this->_content = $html->asXML(); + } + $textarea = HTML::textarea(array('class' => 'wikiedit', + 'name' => 'edit[content]', + 'id' => 'edit[content]', + 'rows' => $request->getPref('editHeight'), + 'cols' => $request->getPref('editWidth'), + 'readonly' => (bool) $readonly, + 'wrap' => 'virtual'), + $this->_content); + if (USE_HTMLAREA) + return Edit_HtmlArea_Textarea($textarea,$this->_wikicontent,'edit[content]'); + else + return $textarea; } function getFormElements () { @@ -366,6 +397,7 @@ class PageEditor return false; $this->_content = preg_replace('/[ \t\r]+\n/', "\n", rtrim($posted['content'])); + $this->_content = $this->getContent(); $this->_currentVersion = (int) $posted['current_version']; @@ -510,6 +542,12 @@ extends PageEditor /** $Log: not supported by cvs2svn $ + Revision 1.59 2003/12/07 20:35:26 carstenklapp + Bugfix: Concurrent updates broken since after 1.3.4 release: Fatal + error: Call to undefined function: gettransformedcontent() in + /home/groups/p/ph/phpwiki/htdocs/phpwiki2/lib/editpage.php on line + 205. + Revision 1.58 2003/03/10 18:25:22 dairiki Bug/typo fix. If you use the edit page to un/lock a page, it failed with: Fatal error: Call to a member function on a diff --git a/lib/main.php b/lib/main.php index 7be5bbcd3..37e14b2fb 100644 --- a/lib/main.php +++ b/lib/main.php @@ -1,5 +1,5 @@ getArg('pagename'); $action = $this->getArg('action'); - if ($this->getArg('start_debug')) // zend ide support + if (!empty($_GET['start_debug'])) // zend ide support return WikiURL($pagename, array('action' => $action, 'start_debug' => 1)); else return WikiURL($pagename, array('action' => $action)); @@ -864,6 +864,14 @@ main(); // $Log: not supported by cvs2svn $ +// Revision 1.114 2004/02/15 17:30:13 rurban +// workaround for lost db connnection handle on session restauration (->_auth_dbi) +// fixed getPreferences() (esp. from sessions) +// fixed setPreferences() (update and set), +// fixed AdoDb DB statements, +// update prefs only at UserPreferences POST (for testing) +// unified db prefs methods (but in external pref classes yet) +// // Revision 1.113 2004/02/12 13:05:49 rurban // Rename functional for PearDB backend // some other minor changes diff --git a/lib/plugin/RecentChanges.php b/lib/plugin/RecentChanges.php index e8181115f..faf92931a 100644 --- a/lib/plugin/RecentChanges.php +++ b/lib/plugin/RecentChanges.php @@ -1,5 +1,5 @@ mostRecent($this->getMostRecentParams($args)); - $show_deleted = $args['show_deleted']; if ($show_deleted == 'sometimes') $show_deleted = $args['show_minor']; if (!$show_deleted) $changes = new NonDeletedRevisionIterator($changes, !$args['show_all']); + else + $changes = $dbi->mostRecent($this->getMostRecentParams($args)); return $changes; } @@ -774,6 +774,9 @@ class DayButtonBar extends HtmlElement { } // $Log: not supported by cvs2svn $ +// Revision 1.82 2004/01/25 03:58:43 rurban +// use stdlib:isWikiWord() +// // Revision 1.81 2003/11/28 21:06:31 carstenklapp // Enhancement: Mozilla RecentChanges sidebar now defaults to 10 changes // instead of 1. Make diff buttons smaller with css. Added description diff --git a/lib/plugin/UserPreferences.php b/lib/plugin/UserPreferences.php index fbd1178ff..792fc5de4 100644 --- a/lib/plugin/UserPreferences.php +++ b/lib/plugin/UserPreferences.php @@ -1,7 +1,7 @@ isPost()) { - //trigger_error("DEBUG: request is post"); - if ($request->_prefs) { + if ($rp = $request->getArg('pref')) { // replace only changed prefs in $pref with those from request - $rp = $request->_prefs->_prefs; - //trigger_error("DEBUG: reading prefs from request".print_r($rp)); - //trigger_error("DEBUG: writing prefs with setPreferences".print_r($pref)); - $num = $user->setPreferences(new UserPreferences($rp)); - if (!$num) { - $errmsg = _("No changes."); - } - else { - $errmsg = fmt("%d UserPreferences fields successfully updated.", $num); + if (!empty($rp['passwd']) and ($rp['passwd2'] != $rp['passwd'])) { + $errmsg = _("Wrong password. Try again."); + } else { + //trigger_error("DEBUG: reading prefs from request".print_r($rp)); + //trigger_error("DEBUG: writing prefs with setPreferences".print_r($pref)); + $num = $user->setPreferences($rp); + if (!$num) { + $errmsg = _("No changes."); + } + else { + $pref = $user->_prefs; + $errmsg = fmt("%d UserPreferences fields successfully updated.", $num); + } } $args['errmsg'] = HTML(HTML::h2($errmsg), HTML::hr()); } @@ -133,6 +136,9 @@ extends WikiPlugin }; // $Log: not supported by cvs2svn $ +// Revision 1.15 2004/01/27 22:37:50 rurban +// fixed default args: no objects +// // Revision 1.14 2004/01/26 09:18:00 rurban // * changed stored pref representation as before. // the array of objects is 1) bigger and 2) diff --git a/lib/plugin/WikiAdminRemove.php b/lib/plugin/WikiAdminRemove.php index ba4542c23..f094f3b27 100644 --- a/lib/plugin/WikiAdminRemove.php +++ b/lib/plugin/WikiAdminRemove.php @@ -1,5 +1,5 @@ $min_age) { + if ($age >= $min_age) { if (empty($list[$pagename])) $list[$pagename] = $checked; } } + return $list; } function removePages(&$request, $pages) { @@ -157,14 +158,10 @@ extends WikiPlugin } if ($next_action == 'select') { // List all pages to select from. - $list = $this->collectPages($pages, $dbi, $args['sortby']); + $pages = $this->collectPages($pages, $dbi, $args['sortby']); } - - $info = 'checkbox'; - if ($args['info']) - $info .= "," . $args['info']; - $pagelist = new PageList_Selectable($info, $exclude); + $pagelist = new PageList_Selectable($args['info'], $exclude); $pagelist->addPageList($pages); $header = HTML::p(); @@ -175,19 +172,20 @@ extends WikiPlugin } else { $button_label = _("Remove selected pages"); - if ($args['min_age'] >= 0) { + $header->pushContent(_("Permanently remove the selected files:"),HTML::br()); + if ($args['min_age'] > 0) { $header->pushContent( - fmt("Listing pages which have been deleted at least %s days.", + fmt("Also pages which have been deleted at least %s days.", $args['min_age'])); } else { - $header->pushContent(_("Listing all pages.")); + $header->pushContent(_("List all pages.")); } - if ($args['max_age'] >= 0) { + if ($args['max_age'] > 0) { $header->pushContent( " ", - fmt("(Automatically checking pages which have been deleted at least %s days.)", + fmt("(Pages which have been deleted at least %s days are already checked.)", $args['max_age'])); } } @@ -214,6 +212,9 @@ extends WikiPlugin } // $Log: not supported by cvs2svn $ +// Revision 1.11 2004/02/11 20:00:16 rurban +// WikiAdmin... series overhaul. Rename misses the db backend methods yet. Chmod + Chwon still missing. +// // Revision 1.9 2003/02/26 22:27:22 dairiki // Fix and refactor FrameInclude plugin (more or less). // diff --git a/lib/plugin/WikiAdminRename.php b/lib/plugin/WikiAdminRename.php index 0c7302aad..4297c4b09 100644 --- a/lib/plugin/WikiAdminRename.php +++ b/lib/plugin/WikiAdminRename.php @@ -1,5 +1,5 @@ getArg('p'); $post_args = $request->getArg('admin_rename'); $next_action = 'select'; $pages = array(); - + if ($p && !$request->isPost()) + $pages = $p; if ($p && $request->isPost() && $request->_user->isAdmin() && !empty($post_args['rename']) && empty($post_args['cancel'])) { // FIXME: error message if not admin. @@ -111,7 +111,6 @@ extends WikiPlugin_WikiAdminSelect // Real action return $this->renamePages($dbi, $request, $p, $post_args['from'], $post_args['to'], $post_args['updatelinks']); } - if ($post_args['action'] == 'select') { if (!empty($post_args['from'])) $next_action = 'verify'; @@ -120,19 +119,14 @@ extends WikiPlugin_WikiAdminSelect } } } - if ($next_action == 'select') { + if ($next_action == 'select' and empty($pages)) { // List all pages to select from. - $list = $this->collectPages($pages, $dbi, $args['sortby']); + $pages = $this->collectPages($pages, $dbi, $args['sortby']); } - - - $info = 'checkbox'; - if ($args['info']) - $info .= "," . $args['info']; if ($next_action == 'verify') { - $info = "checkbox,pagename,renamed_pagename"; + $args['info'] = "checkbox,pagename,renamed_pagename"; } - $pagelist = new PageList_Selectable($info, $exclude); + $pagelist = new PageList_Selectable($args['info'], $exclude); $pagelist->addPageList($pages); $header = HTML::p(); @@ -190,6 +184,14 @@ extends WikiPlugin_WikiAdminSelect } // $Log: not supported by cvs2svn $ +// Revision 1.4 2004/02/12 17:05:39 rurban +// WikiAdminRename: +// added "Change pagename in all linked pages also" +// PageList: +// added javascript toggle for Select +// WikiAdminSearchReplace: +// fixed another typo +// // Revision 1.3 2004/02/12 13:05:50 rurban // Rename functional for PearDB backend // some other minor changes diff --git a/lib/plugin/WikiAdminSearchReplace.php b/lib/plugin/WikiAdminSearchReplace.php index 4a65d953a..de729e4bd 100644 --- a/lib/plugin/WikiAdminSearchReplace.php +++ b/lib/plugin/WikiAdminSearchReplace.php @@ -1,5 +1,5 @@ getArg('admin_replace'); $next_action = 'select'; $pages = array(); - + if ($p && !$request->isPost()) + $pages = $p; if ($p && $request->isPost() && $request->_user->isAdmin() - && !empty($post_args['rename']) && empty($post_args['cancel'])) { + && empty($post_args['cancel'])) { // FIXME: error message if not admin. - if ($post_args['action'] == 'verify') { + if ($post_args['action'] == 'verify' and !empty($post_args['from'])) { // Real action return $this->searchReplacePages($dbi, $request, $p, $post_args['from'], $post_args['to']); } - if ($post_args['action'] == 'select') { if (!empty($post_args['from'])) $next_action = 'verify'; - foreach ($p as $name) { + if (is_array($p[0])) { + foreach ($p as $name) { $pages[$name] = 1; + } + } else { + $pages = $p; } } } - if ($next_action == 'select') { + if ($next_action == 'select' and empty($pages)) { // List all pages to select from. - $list = $this->collectPages($pages, $dbi, $args['sortby']); + $pages = $this->collectPages($pages, $dbi, $args['sortby']); } - - $info = 'checkbox'; - if ($args['info']) - $info .= "," . $args['info']; if ($next_action == 'verify') { - $info = "checkbox,pagename,content"; + $args['info'] = "checkbox,pagename,hi_content"; } - $pagelist = new PageList_Selectable($info, $exclude); + $pagelist = new PageList_Selectable($args['info'], $exclude); $pagelist->addPageList($pages); $header = HTML::p(); @@ -236,6 +236,14 @@ function stri_replace($find,$replace,$string) { } // $Log: not supported by cvs2svn $ +// Revision 1.3 2004/02/12 17:05:39 rurban +// WikiAdminRename: +// added "Change pagename in all linked pages also" +// PageList: +// added javascript toggle for Select +// WikiAdminSearchReplace: +// fixed another typo +// // Revision 1.2 2004/02/12 11:47:51 rurban // typo // diff --git a/lib/plugin/WikiAdminSelect.php b/lib/plugin/WikiAdminSelect.php index 658eecef8..b57bc0a10 100644 --- a/lib/plugin/WikiAdminSelect.php +++ b/lib/plugin/WikiAdminSelect.php @@ -1,5 +1,5 @@ debug = $args['debug']; if (!empty($request->getArg['s'])) $args['s'] = $request->getArg['s']; - if (!empty($args['s'])) { + if (($request->getArg('WikiAdminSelect') == _("Go")) and + !empty($args['s'])) { $s = $args['s']; $sl = explodePageList($args['s']); $this->_list = array(); @@ -96,15 +98,17 @@ extends WikiPlugin } } else { $s = '*'; + if (!empty($args['s'])) + $s = $args['s']; $this->_list = array(); } - $this->debug = $args['debug']; + // array_multisort($this->_list, SORT_NUMERIC, SORT_DESC); $pagename = $request->getArg('pagename'); // GetUrlToSelf() with all given params //$uri = $GLOBALS['HTTP_SERVER_VARS']['REQUEST_URI']; // without s would be better. - $uri = $request->getURLtoSelf(false, array('verify')); - $form = HTML::form(array('action' => $uri, 'method' => 'POST')); + //$uri = $request->getURLtoSelf();//false, array('verify')); + $form = HTML::form(array('action' => $request->getPostURL(), 'method' => 'POST')); if ($request->getArg('WikiAdminSelect') == _("Go")) $p = false; else @@ -117,46 +121,71 @@ extends WikiPlugin HTML::input(array('type' => 'submit', 'name' => 'WikiAdminSelect', 'value' => _("Go"))))); - if ($request->isPost() && $request->getArg('verify') && !empty($p)) { + if ($request->isPost() + && ! $request->getArg('wikiadmin') + && !empty($p)) { + $this->_list = array(); // List all selected pages again. foreach ($p as $page => $name) { $this->_list[$name] = 1; } - } elseif ($request->isPost() && $request->_user->isAdmin() - && !empty($p) - && $request->getArg('action') == 'WikiAdminSelect') { + } + elseif ($request->isPost() + and $request->_user->isAdmin() + and !empty($p) + //and $request->getArg('verify') + and ($request->getArg('action') == 'WikiAdminSelect') + and $request->getArg('wikiadmin') + ) + { // handle external plugin $l = new WikiPluginLoader(); - $plugin_action = $request->getArg('submit'); - $plugin = $l->getPlugin($plugin_action); - - $ul = HTML::ul(); - foreach ($p as $page => $name) { - $plugin_args = "run_page=$name"; - $request->setArg($plugin_action, 1); - $request->setArg('p', array($page => $name)); - $action_result = $plugin->run($dbi, $plugin_args, $request); - $ul->pushContent(HTML::li(fmt("Selected page '%s' passed to '%s'.", - $name, $select))); - $ul->pushContent(HTML::ul(HTML::li($action_result))); + $a = array_keys($request->getArg('wikiadmin')); + $plugin_action = $a[0]; + $single_arg_plugins = array("Remove"); + if (in_array($plugin_action,$single_arg_plugins)) { + $plugin = $l->getPlugin($plugin_action); + $ul = HTML::ul(); + foreach ($p as $page => $name) { + $plugin_args = "run_page=$name"; + $request->setArg($plugin_action, 1); + $request->setArg('p', array($page => $name)); + // if the plugin requires more args than the pagename, + // then this plugin will not return. (Rename, SearchReplace, ...) + $action_result = $plugin->run($dbi, $plugin_args, $request); + $ul->pushContent(HTML::li(fmt("Selected page '%s' passed to '%s'.", + $name, $select))); + $ul->pushContent(HTML::ul(HTML::li($action_result))); + } + } else { + // redirect to the plugin page. + // in which page is this plugin? + $plugin_action = preg_replace("/^WikiAdmin/","",$plugin_action); + $args = array(); + foreach ($p as $page => $x) { + $args["p[$page]"] = 1; + } + header("Location: ". + WikiURL(_("PhpWikiAdministration")."/"._($plugin_action),$args,1)); + exit(); } } elseif (empty($args['s'])) { // List all pages to select from. - $this->collectPages($this->_list, $dbi, $args['sortby']); + $this->_list = $this->collectPages($this->_list, $dbi, $args['sortby']); } - $pagelist = new PageList_Selectable($info - ? 'checkbox,' . $info - : 'checkbox', $exclude); + $pagelist = new PageList_Selectable($info, $exclude); $pagelist->addPageList($this->_list); $form->pushContent($pagelist->getContent()); foreach ($args as $k => $v) { - if (!in_array($k,array('s','WikiAdminSelect','action'))) + if (!in_array($k,array('s','WikiAdminSelect','action','verify'))) $form->pushContent(HiddenInputs(array($k => $v))); // plugin params } + /* foreach ($_GET as $k => $v) { if (!in_array($k,array('s','WikiAdminSelect','action'))) $form->pushContent(HiddenInputs(array($k => $v))); // debugging params, ... } + */ if (! $request->getArg('verify')) { $form->pushContent(HTML::input(array('type' => 'hidden', 'name' => 'action', @@ -180,7 +209,7 @@ extends WikiPlugin $f = preg_replace('/.php$/','', $f); $s = preg_replace('/^WikiAdmin/','', $f); if (!in_array($s,array("Select","Utils"))) { // disable Select and Utils - $form->pushContent(Button("submit:$f", _($s), "wikiadmin")); + $form->pushContent(Button("submit:wikiadmin[$f]", _($s), "wikiadmin")); $form->pushContent($Theme->getButtonSeparator()); } } @@ -195,6 +224,11 @@ extends WikiPlugin } // $Log: not supported by cvs2svn $ +// Revision 1.9 2004/02/12 13:05:50 rurban +// Rename functional for PearDB backend +// some other minor changes +// SiteMap comes with a not yet functional feature request: includepages (tbd) +// // Revision 1.8 2004/02/11 20:00:16 rurban // WikiAdmin... series overhaul. Rename misses the db backend methods yet. Chmod + Chwon still missing. // -- 2.45.0