|
Cookbook /
RenamePageSummary: Rename a wiki page from a browser
Version: 2005-09-23
Prerequisites: pmwiki-2
Status: stable
Maintainer: jr
Categories: System tools
GoalProvide a way to rename a wiki page from a browser, either within groups or across groups. As an extra bonus, this also provides a way for cross-group include directives to qualify any unqualified links. And you get SolutionPlease note. The PublishPDF library includes the RenamePage recipe. rename.phpΔ is a script that adds
?action=rename, ?action=links and (:linkslist pagename:) to PmWiki.Important: the latest version requires that you also download and install either:
Do not use both. Installation InstructionsPut the scripts in cookbook/ as per the module guidelines. The script is only loaded if its actions are requested. The lines work for farm and non-farm installations. Update config.php as follows:
## Activate the RenamePage recipe.
if ($action == 'rename' || $action == 'postrename' || $action == 'links' ) {
include_once("$FarmD/cookbook/renamehelper.php");
include_once("$FarmD/cookbook/rename.php");
}
Note: If you are using Markup Extensions then you don't need renamehelper.php and you should not use the line that includes renamehelper.php: just omit that line or comment it out with ##.
Instructions for use
The original page is still there, but now redirects to the renamed page. Depending on your appetite for risk, you may wish to test this on some non-critical pages before attempting a wholescale wiki restructuring. Edit integrationTo have this functionality as part of the normal edit action add a (rename) link after the 'Editing Group.Page' heading. Something like:
$PageEditFmt =
str_replace('</h1>',' <a href=\'$PageUrl?action=rename\'>'.
'(rename)</a></h1>',$PageEditFmt);
Alternatively edit Site.PageActions and add this
* %item rel=nofollow class=rename accesskey=$[ak_rename]% [[{*$FullName}?action=rename | $[Rename] ]]
Cool new features:Qualified Include(:includeg Group.PageName:)
This qualifies any unqualified links it finds on PageName. All regular include capabilities should still work. There is currently a bug in this feature in that it interprets [[<<]] markup as an unqualified link called 'Lt Lt'. swestrup November 19, 2007, at 10:45 PM
List of all links on the specified pageYet another cool new feature: (:linkslist pagename:)
This gives an alphabetic list of all links on the specified page.
Useful in a SideBar.
Or, to see all links on the current page, append History
ContributorQuestionsAfter using the rename function, the new page does not appear in the AllRecentChanges. Why? Is it because the rename function is not considered as a "change"? - kt007 December 02, 2004, at 08:59 AM Correct. If you click on the old name in AllRecentChanges, PmWiki will redirect you to the new name. The script works by doing a file copy, rather than 'edit old and post new'. Of course, as soon as you edit the new page, AllRecentChanges gets updated. jr it's not possible to use the attached script. should it be a .zip file? Han (05 feb 05) My browser insists on saving it with a .html extension. You need to change this to .php to make it usable. It the script doesn't change the Pagereferences but makes a redirection from the old pagename to the new one. Is this the wanted behaviour, or is something wrong on my installation? So the original linkreference in all other pages still be the same. Is there a option to change the pagereferences to the new pagename instead of redirect? noskule Is it possible to rename a group?
See AlsoWikiSh includes a CommentsPageStore compatibilityThe current semantics of a rename operation is:
I think that it can be made entirely compatible with PageStore: simply read the old page, then write it with the new name. I think that would mean rewriting $page = RetrieveAuthPage ($old, 'edit'); WritePage ($new, $page); Done 27 May 2005
Rename PasswordYou should also add the possibility to set a password for renaming (This should be already possible within the I'll have to investigate this -- it's not clear to me how to make it work. jr
All you have to do is to RetrieveAuthPage($pagename, 'rename'). However, I think it's enough to require edit privilege - the only thing that remains to be done is to change the RetrieveAuthPage($pagename, 'read') in line 30 with RetrieveAuthPage($pagename, 'edit'). Joachim Durchholz
Right. Done.
Updating unqualified linksIf an author moves a page from one group to another, any unqualified wiki links in the page will now probably refer to non-existing pages. Sometimes this is what one wants; sometimes one will need to edit the page and update some or all of the links to insert a group qualifier. If one were moving a lot of pages this could be a bit of a chore. On the other hand, if one were moving a lot of pages, chances are the unqualified links will point to pages that are also being moved. It is a fairly minor task for the script to insert the original group name as a qualifier on all unqualified page references. This could perhaps be an option via a check box on the rename form. If there is a demand for this capability, we can look at adding it. Cast a vote from 1 (not required) to 5 (no use without this feature). Here's an alternate proposal. Don't use a single checkbox, but list all the unqualifiedly-linked-to pages with a checkbox that indicates whether they should be made qualified. (The list of linked-to page should be produced by finding all unqualified links and eliminating any duplicates.) The page names in the list should be links to the pages. This allows the end user to double-check these names and make sure that they really should be moved. (The Rename page might add a note indicating that these links are best opened using "Open in New Window" or "Open in New Tab", so that the Rename page is kept open.) Great idea -- I'll need to think about how to implement it. Displaying a list of unqualified links would be a start... jr
A version that lists unqualified links is Suggestion for the FormIt would be helpful to the users if the form were to provide instructions, especially identifying the option of keying I'll investigate including a Site.RenameQuickReference page that automatically gets displayed (and of course can be edited). And I hadn't realised that one could rename a page into a new group in that way. I'm quite surprised that it works! jr
The present The following changes update the script so someone can use, for example, $HandleAuth['rename'] = 'admin';
in config.php to change the required authorization level for renaming a page.
33a34
> SDV($HandleAuth['rename'],'edit');
34a36
> SDV($HandleAuth['postrename'],$HandleAuth['rename']);
66c68
< function HandleRename($pagename) {
---
> function HandleRename($pagename,$auth) {
67a70,71
> $page = RetrieveAuthPage($pagename, $auth, true, READPAGE_CURRENT);
> if (!$page) Abort('?unauthorized');
76c80
< function HandlePostRename($pagename) {
---
> function HandlePostRename($pagename,$auth) {
83c87
< $page = RetrieveAuthPage($pagename,"edit");
---
> $page = RetrieveAuthPage($pagename,$auth);
--Hagan 2006-01-18 I made an actual rename instead of a redirected rename function. I made this update in the rename.php file. I don't know about the unqualified links and stuff so I didn't include that in my function. Perhaps someone can incorporate that stuff in. I posted this in (http://pmwiki.org/wiki/PITS/00864) and a related fix in (http://pmwiki.org/wiki/PITS/00863). Anyhoo, here's my version of it: function HandlePostRename($pagename) { global } I needed functionality for moving attachments associated with a page when renaming the page (by "associated with" I mean attachments which are actually linked on the page and are unqualified, i.e. in the same namespace as the page). I have added something basic -- it works for me (on Linux), but it is by no means thoroughly tested, and it's not very polished. CAVEAT: I couldn't think of a tidy way to determine the upload prefix of a page other than the current page, so I use an additional variable in the main local config file.
Here is my modified copy (based on version 2.0.17): rename-20080401.phpΔ Instructions for use:
Note:
This modification could probably be extended to offer the option of qualifying unqualified file links. Adrianna April 01, 2008, at 09:43 AM |