From: Geoffrey T. D. <da...@us...> - 2003-02-15 23:33:01
|
Update of /cvsroot/phpwiki/phpwiki/lib/plugin In directory sc8-pr-cvs1:/tmp/cvs-serv27249/lib/plugin Modified Files: RedirectTo.php Log Message: Usability improvements for the RedirectTo plugin. (Mostly this applies when using RedirectTo with a page=OtherPage argument to redirect to another page in the same wiki.) (Most of these ideas are stolen verbatim from UseModWiki.) o Multiple redirects (PageOne -> PageTwo -> PageThree) not allowed. o Redirects are not activated except when action == 'browse'. o When redirections are disabled, (hopefully understandable) diagnostics are displayed. o A link to the redirecting page is displayed after the title of the target page. If the user follows this link, redirects are disabled. This allows for easy editing of the redirecting page. FIXME: Stylesheets, and perhaps templates other than the defaults will probably have to be updated before this works well in other styles and/or themes. Index: RedirectTo.php =================================================================== RCS file: /cvsroot/phpwiki/phpwiki/lib/plugin/RedirectTo.php,v retrieving revision 1.6 retrieving revision 1.7 diff -u -2 -b -p -d -r1.6 -r1.7 --- RedirectTo.php 18 Jan 2003 22:01:44 -0000 1.6 +++ RedirectTo.php 15 Feb 2003 23:32:56 -0000 1.7 @@ -66,4 +66,5 @@ extends WikiPlugin function run($dbi, $argstr, $request) { $args = ($this->getArgs($argstr, $request)); + $href = $args['href']; $page = $args['page']; @@ -79,8 +80,6 @@ extends WikiPlugin $thispage = $request->getPage(); if (! $thispage->get('locked')) { - return $this->error(HTML(fmt(_("%s is only allowed in locked pages."), - _("Redirect to an external url")), - HTML::br(), - fmt("url=\"%s\"", $url))); + return $this->disabled(fmt(_("%s is only allowed in locked pages."), + _("Redirect to an external url"))); } } @@ -90,12 +89,28 @@ extends WikiPlugin SplitQueryArgs($args['args']))); } - else - return $this->error(sprintf(_("%s or %s parameter missing"), + else { + return $this->error(fmt("%s or %s parameter missing", "'href'", "'page'")); + } if ($page == $request->getArg('pagename')) { - return $this->error(sprintf(_("Recursive redirect to self: '%s'"), - $url)); + return $this->error(fmt("Recursive redirect to self: '%s'", $url)); + } + + if ($request->getArg('action') != 'browse') + return $this->disabled("(action != 'browse')"); + + $redirectfrom = $request->getArg('redirectfrom'); + if ($redirectfrom !== false) { + if ($redirectfrom) + return $this->disabled(_("Double redirect not allowed.")); + else { + // Got here by following the "Redirected from ..." link + // on a browse page. + return $this->disabled(_("Viewing redirecting page.")); } + } + + return $request->redirect($url); } @@ -103,4 +118,28 @@ extends WikiPlugin // $Log$ +// Revision 1.7 2003/02/15 23:32:56 dairiki +// Usability improvements for the RedirectTo plugin. +// +// (Mostly this applies when using RedirectTo with a page=OtherPage +// argument to redirect to another page in the same wiki.) +// +// (Most of these ideas are stolen verbatim from UseModWiki.) +// +// o Multiple redirects (PageOne -> PageTwo -> PageThree) not allowed. +// +// o Redirects are not activated except when action == 'browse'. +// +// o When redirections are disabled, (hopefully understandable) +// diagnostics are displayed. +// +// o A link to the redirecting page is displayed after the title +// of the target page. If the user follows this link, redirects +// are disabled. This allows for easy editing of the redirecting +// page. +// +// FIXME: Stylesheets, and perhaps templates other than the defaults +// will probably have to be updated before this works well in other +// styles and/or themes. +// // Revision 1.6 2003/01/18 22:01:44 carstenklapp // Code cleanup: |