From cf0dc415341276f490cc7ee6d5f179bbe52d02ea Mon Sep 17 00:00:00 2001 From: vargenau Date: Tue, 23 Jun 2009 17:54:20 +0000 Subject: [PATCH] Better user interface and feedback messages git-svn-id: svn://svn.code.sf.net/p/phpwiki/code/trunk@6952 96ab9672-09ca-45d6-a79d-3d69d39ca109 --- lib/plugin/WikiAdminChown.php | 32 +++++++++++++------ lib/plugin/WikiAdminMarkup.php | 6 +++- lib/plugin/WikiAdminPurge.php | 45 +++++++++++++++++++++------ lib/plugin/WikiAdminRemove.php | 39 ++++++++++++++--------- lib/plugin/WikiAdminRename.php | 12 ++++--- lib/plugin/WikiAdminSearchReplace.php | 23 +++++++++----- lib/plugin/WikiAdminSetAcl.php | 15 +++++---- lib/plugin/WikiAdminSetExternal.php | 6 +++- 8 files changed, 122 insertions(+), 56 deletions(-) diff --git a/lib/plugin/WikiAdminChown.php b/lib/plugin/WikiAdminChown.php index 04aaaffbc..ebbc6d662 100644 --- a/lib/plugin/WikiAdminChown.php +++ b/lib/plugin/WikiAdminChown.php @@ -60,6 +60,7 @@ extends WikiPlugin_WikiAdminSelect } function chownPages(&$dbi, &$request, $pages, $newowner) { + $result = HTML::div(); $ul = HTML::ul(); $count = 0; foreach ($pages as $name) { @@ -74,7 +75,7 @@ extends WikiPlugin_WikiAdminSelect $version = $current->getVersion(); $meta = $current->_data; $text = $current->getPackedContent(); - $meta['summary'] = sprintf(_("Change page owner from %s to %s"), $owner, $newowner); + $meta['summary'] = "Change page owner from '".$owner."' to '".$newowner."'"; $meta['is_minor_edit'] = 0; $meta['author'] = $request->_user->UserName(); unset($meta['mtime']); // force new date @@ -93,10 +94,18 @@ extends WikiPlugin_WikiAdminSelect } if ($count) { $dbi->touch(); - return HTML($ul, HTML::p(fmt("%s pages have been permanently changed.", - $count))); + $result->setAttr('class', 'feedback'); + if ($count == 1) { + $result->pushContent(HTML::p("One page has been permanently changed:")); + } else { + $result->pushContent(HTML::p(fmt("%s pages have been permanently changed:", $count))); + } + $result->pushContent($ul); + return $result; } else { - return HTML($ul, HTML::p(fmt("No pages changed."))); + $result->setAttr('class', 'error'); + $result->pushContent(HTML::p("No pages changed.")); + return $result; } } @@ -155,10 +164,14 @@ extends WikiPlugin_WikiAdminSelect $args['info'] = "checkbox,pagename,owner,mtime"; } */ - $pagelist = new PageList_Selectable($args['info'], $args['exclude'], $args); + if ($next_action == 'select') { + $pagelist = new PageList_Selectable($args['info'], $args['exclude'], $args); + } else { + $pagelist = new PageList_Unselectable($args['info'], $args['exclude'], $args); + } $pagelist->addPageList($pages); - $header = HTML::div(); + $header = HTML::fieldset(); if ($next_action == 'verify') { $button_label = _("Yes"); $header->pushContent( @@ -168,17 +181,17 @@ extends WikiPlugin_WikiAdminSelect } else { $button_label = _("Change owner of selected pages"); - $header->pushContent(HTML::p(_("Select the pages to change the owner:"))); + $header->pushContent(HTML::legend(_("Select the pages to change the owner"))); $header = $this->chownForm($header, $post_args); } $buttons = HTML::p(Button('submit:admin_chown[chown]', $button_label, 'wikiadmin'), Button('submit:admin_chown[cancel]', _("Cancel"), 'button')); + $header->pushContent($buttons); return HTML::form(array('action' => $request->getPostURL(), 'method' => 'post'), $header, - $buttons, $pagelist->getContent(), HiddenInputs($request->getArgs(), false, @@ -193,7 +206,8 @@ extends WikiPlugin_WikiAdminSelect $header->pushContent(_("Change owner")." "); $header->pushContent(' '._("to").': '); $header->pushContent(HTML::input(array('name' => 'admin_chown[user]', - 'value' => $post_args['user']))); + 'value' => $post_args['user'], + 'size' => 40))); return $header; } } diff --git a/lib/plugin/WikiAdminMarkup.php b/lib/plugin/WikiAdminMarkup.php index 456515502..5a82b1d5b 100644 --- a/lib/plugin/WikiAdminMarkup.php +++ b/lib/plugin/WikiAdminMarkup.php @@ -98,7 +98,11 @@ extends WikiPlugin_WikiAdminSelect if ($count) { $dbi->touch(); $result->setAttr('class', 'feedback'); - $result->pushContent(HTML::p(fmt("%s pages have been permanently changed:", $count))); + if ($count == 1) { + $result->pushContent(HTML::p("One page has been permanently changed:")); + } else { + $result->pushContent(HTML::p(fmt("%s pages have been permanently changed:", $count))); + } $result->pushContent($ul); return $result; } else { diff --git a/lib/plugin/WikiAdminPurge.php b/lib/plugin/WikiAdminPurge.php index 7012654cf..83e702eab 100644 --- a/lib/plugin/WikiAdminPurge.php +++ b/lib/plugin/WikiAdminPurge.php @@ -55,10 +55,23 @@ extends WikiPlugin_WikiAdminSelect } function collectPages(&$list, &$dbi, $sortby, $limit=0) { + + $allPages = $dbi->getAllPages('include_empty',$sortby,$limit); + while ($pagehandle = $allPages->next()) { + $pagename = $pagehandle->getName(); + $current = $pagehandle->getCurrentRevision(); + if ($current->getVersion() < 1) { + continue; // No versions in database + } + if (empty($list[$pagename])) { + $list[$pagename] = false; + } + } return $list; } function purgePages(&$request, $pages) { + $result = HTML::div(); $ul = HTML::ul(); $dbi = $request->getDbh(); $count = 0; foreach ($pages as $name) { @@ -71,11 +84,23 @@ extends WikiPlugin_WikiAdminSelect $ul->pushContent(HTML::li(fmt("Didn't purge page '%s'. Access denied.", $name))); } } - if ($count) $dbi->touch(); - return HTML($ul, - HTML::p(fmt("%d pages have been permanently purged.",$count))); + if ($count) { + $dbi->touch(); + $result->setAttr('class', 'feedback'); + if ($count == 1) { + $result->pushContent(HTML::p("One page has been permanently purged:")); + } else { + $result->pushContent(HTML::p(fmt("%s pages have been permanently purged:", $count))); + } + $result->pushContent($ul); + return $result; + } else { + $result->setAttr('class', 'error'); + $result->pushContent(HTML::p("No pages purged.")); + return $result; + } } - + function run($dbi, $argstr, &$request, $basepage) { if ($request->getArg('action') != 'browse') if ($request->getArg('action') != _("PhpWikiAdministration/Purge")) @@ -126,25 +151,25 @@ extends WikiPlugin_WikiAdminSelect $pagelist = new PageList_Selectable($args['info'], $args['exclude'], array()); $pagelist->addPageList($pages); - $header = HTML::p(); + $header = HTML::fieldset(); if ($next_action == 'verify') { $button_label = _("Yes"); - $header->pushContent(HTML::strong( - _("Are you sure you want to permanently purge the following files?"))); + $header->pushContent(HTML::p(HTML::strong( + _("Are you sure you want to permanently purge the following files?")))); } else { - $button_label = _("Purge selected pages"); - $header->pushContent(_("Permanently purge the selected files:"),HTML::br()); + $button_label = _("Permanently purge selected pages"); + $header->pushContent(HTML::legend(_("Select the files to purge"))); } $buttons = HTML::p(Button('submit:admin_purge[purge]', $button_label, 'wikiadmin'), Button('submit:admin_purge[cancel]', _("Cancel"), 'button')); + $header->pushContent($buttons); // TODO: quick select by regex javascript? return HTML::form(array('action' => $request->getPostURL(), 'method' => 'post'), $header, - $buttons, $pagelist->getContent(), HiddenInputs($request->getArgs(), false, diff --git a/lib/plugin/WikiAdminRemove.php b/lib/plugin/WikiAdminRemove.php index e9d27ec22..b916344a1 100644 --- a/lib/plugin/WikiAdminRemove.php +++ b/lib/plugin/WikiAdminRemove.php @@ -2,7 +2,7 @@ rcs_id('$Id$'); /* Copyright 2002,2004 $ThePhpWikiProgrammingTeam - Copyright 2008 Marc-Etienne Vargenau, Alcatel-Lucent + Copyright 2008-2009 Marc-Etienne Vargenau, Alcatel-Lucent This file is part of PhpWiki. @@ -108,6 +108,7 @@ extends WikiPlugin_WikiAdminSelect } function removePages(&$request, $pages) { + $result = HTML::div(); $ul = HTML::ul(); $dbi = $request->getDbh(); $count = 0; foreach ($pages as $name) { @@ -120,9 +121,21 @@ extends WikiPlugin_WikiAdminSelect $ul->pushContent(HTML::li(fmt("Didn't remove page '%s'. Access denied.", $name))); } } - if ($count) $dbi->touch(); - return HTML($ul, - HTML::p(fmt("%d pages have been permanently removed.",$count))); + if ($count) { + $dbi->touch(); + $result->setAttr('class', 'feedback'); + if ($count == 1) { + $result->pushContent(HTML::p("One page has been permanently removed:")); + } else { + $result->pushContent(HTML::p(fmt("%s pages have been permanently removed:", $count))); + } + $result->pushContent($ul); + return $result; + } else { + $result->setAttr('class', 'error'); + $result->pushContent(HTML::p("No pages removed.")); + return $result; + } } function run($dbi, $argstr, &$request, $basepage) { @@ -184,41 +197,37 @@ extends WikiPlugin_WikiAdminSelect => new _PageList_Column_remove('remove', _("Remove"))))); $pagelist->addPageList($pages); - $header = HTML::p(); + $header = HTML::fieldset(); if ($next_action == 'verify') { $button_label = _("Yes"); - $header->pushContent(HTML::strong( - _("Are you sure you want to permanently remove the selected files?"))); + $header->pushContent(HTML::p(HTML::strong( + _("Are you sure you want to permanently remove the selected files?")))); } else { $button_label = _("Remove selected pages"); - $header->pushContent(_("Permanently remove the selected files:"),HTML::br()); + $header->pushContent(HTML::legend(_("Select the files to remove"))); if ($args['min_age'] > 0) { $header->pushContent( fmt("Also pages which have been deleted at least %s days.", $args['min_age'])); } - else { - $header->pushContent(_("List all pages.")); - } - + if ($args['max_age'] > 0) { $header->pushContent( " ", - fmt("(Pages which have been deleted at least %s days are already checked.)", + fmt("Pages which have been deleted at least %s days are already checked.", $args['max_age'])); } } - $buttons = HTML::p(Button('submit:admin_remove[remove]', $button_label, 'wikiadmin'), Button('submit:admin_remove[cancel]', _("Cancel"), 'button')); + $header->pushContent($buttons); // TODO: quick select by regex javascript? return HTML::form(array('action' => $request->getPostURL(), 'method' => 'post'), $header, - $buttons, $pagelist->getContent(), HiddenInputs($request->getArgs(), false, diff --git a/lib/plugin/WikiAdminRename.php b/lib/plugin/WikiAdminRename.php index 7afa3a72f..b20c0af7c 100644 --- a/lib/plugin/WikiAdminRename.php +++ b/lib/plugin/WikiAdminRename.php @@ -81,7 +81,7 @@ extends WikiPlugin_WikiAdminSelect and $newname != $name ) { if ($dbi->isWikiPage($newname)) - $ul->pushContent(HTML::li(fmt("Page %s already exists. Ignored.", + $ul->pushContent(HTML::li(fmt("Page '%s' already exists. Ignored.", WikiLink($newname)))); elseif (! mayAccessPage('edit', $name)) $ul->pushContent(HTML::li(fmt("Access denied to rename page '%s'.", @@ -121,17 +121,21 @@ extends WikiPlugin_WikiAdminSelect if ($count) { $dbi->touch(); $result->setAttr('class', 'feedback'); - $result->pushContent(HTML::p(fmt("%s pages have been permanently renamed:", $count))); + if ($count == 1) { + $result->pushContent(HTML::p("One page has been permanently renamed:")); + } else { + $result->pushContent(HTML::p(fmt("%s pages have been permanently renamed:", $count))); + } $result->pushContent($ul); return $result; } else { $result->setAttr('class', 'error'); - $result->pushContent(HTML::p(fmt("No pages renamed:"))); + $result->pushContent(HTML::p(fmt("No pages renamed."))); $result->pushContent($ul); return $result; } } - + function run($dbi, $argstr, &$request, $basepage) { $action = $request->getArg('action'); if ($action != 'browse' and $action != 'rename' diff --git a/lib/plugin/WikiAdminSearchReplace.php b/lib/plugin/WikiAdminSearchReplace.php index aa79d2a60..2ff5c7d64 100644 --- a/lib/plugin/WikiAdminSearchReplace.php +++ b/lib/plugin/WikiAdminSearchReplace.php @@ -92,6 +92,7 @@ extends WikiPlugin_WikiAdminSelect function searchReplacePages(&$dbi, &$request, $pages, $from, $to) { if (empty($from)) return HTML::p(HTML::strong(fmt("Error: Empty search string."))); + $result = HTML::div(); $ul = HTML::ul(); $count = 0; $post_args = $request->getArg('admin_replace'); @@ -100,8 +101,7 @@ extends WikiPlugin_WikiAdminSelect foreach ($pages as $pagename) { if (!mayAccessPage('edit', $pagename)) { $ul->pushContent(HTML::li(fmt("Access denied to change page '%s'.",$pagename))); - } elseif (($result = $this->replaceHelper($dbi, $request, $pagename, $from, $to, - $case_exact, $regex))) + } elseif ($this->replaceHelper($dbi, $request, $pagename, $from, $to, $case_exact, $regex)) { $ul->pushContent(HTML::li(fmt("Replaced '%s' with '%s' in page '%s'.", $from, $to, WikiLink($pagename)))); @@ -113,11 +113,18 @@ extends WikiPlugin_WikiAdminSelect } if ($count) { $dbi->touch(); - return HTML($ul, - HTML::p(fmt("%s pages changed.",$count))); + $result->setAttr('class', 'feedback'); + if ($count == 1) { + $result->pushContent(HTML::p("One page has been permanently changed:")); + } else { + $result->pushContent(HTML::p(fmt("%s pages have been permanently changed:", $count))); + } + $result->pushContent($ul); + return $result; } else { - return HTML($ul, - HTML::p(fmt("No pages changed."))); + $result->setAttr('class', 'error'); + $result->pushContent(HTML::p("No pages changed.")); + return $result; } } @@ -182,7 +189,7 @@ extends WikiPlugin_WikiAdminSelect $pagelist->addPageList($pages); - $header = HTML::div(); + $header = HTML::fieldset(); if (empty($post_args['from'])) $header->pushContent( HTML::p(HTML::em(_("Warning: The search string cannot be empty!")))); @@ -196,7 +203,7 @@ extends WikiPlugin_WikiAdminSelect else { $button_label = _("Search & Replace"); $this->replaceForm($header, $post_args); - $header->pushContent(HTML::p(_("Select the pages to search:"))); + $header->pushContent(HTML::legend(_("Select the pages to search and replace"))); } diff --git a/lib/plugin/WikiAdminSetAcl.php b/lib/plugin/WikiAdminSetAcl.php index 67e3ba5f2..e4be8e957 100644 --- a/lib/plugin/WikiAdminSetAcl.php +++ b/lib/plugin/WikiAdminSetAcl.php @@ -2,6 +2,7 @@ rcs_id('$Id$'); /* Copyright 2004 $ThePhpWikiProgrammingTeam + Copyright 2009 Marc-Etienne Vargenau, Alcatel-Lucent This file is part of PhpWiki. @@ -164,7 +165,7 @@ extends WikiPlugin_WikiAdminSelect $pages = $p; elseif ($this->_list) $pages = $this->_list; - $header = HTML::div(); + $header = HTML::fieldset(); if ($p && $request->isPost() && !empty($post_args['acl']) && empty($post_args['cancel'])) { // without individual PagePermissions: @@ -174,9 +175,7 @@ extends WikiPlugin_WikiAdminSelect } if ($post_args['action'] == 'verify') { // Real action - $header->pushContent( - $this->setaclPages($request, array_keys($p), - $request->getArg('acl'))); + return $this->setaclPages($request, array_keys($p), $request->getArg('acl')); } if ($post_args['action'] == 'select') { if (!empty($post_args['acl'])) @@ -207,21 +206,21 @@ extends WikiPlugin_WikiAdminSelect $header = $this->setaclForm($header, $post_args, $pages); $header->pushContent( HTML::p(HTML::strong( - _("Are you sure you want to permanently change access to the selected files?")))); + _("Are you sure you want to permanently change access rights to the selected files?")))); } else { - $button_label = _("SetAcl"); + $button_label = _("Change Access Rights"); $header = $this->setaclForm($header, $post_args, $pages); - $header->pushContent(HTML::p(_("Select the pages to change:"))); + $header->pushContent(HTML::legend(_("Select the pages where to change access rights"))); } $buttons = HTML::p(Button('submit:admin_setacl[acl]', $button_label, 'wikiadmin'), Button('submit:admin_setacl[cancel]', _("Cancel"), 'button')); + $header->pushContent($buttons); return HTML::form(array('action' => $request->getPostURL(), 'method' => 'post'), $header, - $buttons, $pagelist->getContent(), HiddenInputs($request->getArgs(), false, diff --git a/lib/plugin/WikiAdminSetExternal.php b/lib/plugin/WikiAdminSetExternal.php index 6bd4ddc92..531703d7b 100644 --- a/lib/plugin/WikiAdminSetExternal.php +++ b/lib/plugin/WikiAdminSetExternal.php @@ -82,7 +82,11 @@ extends WikiPlugin_WikiAdminSelect if ($count) { $dbi->touch(); $result->setAttr('class', 'feedback'); - $result->pushContent(HTML::p(fmt("%s pages have been permanently changed:", $count))); + if ($count == 1) { + $result->pushContent(HTML::p("One page has been permanently changed:")); + } else { + $result->pushContent(HTML::p(fmt("%s pages have been permanently changed:", $count))); + } $result->pushContent($ul); return $result; } else { -- 2.45.0