Recent Changes - Search:

Cookbook

PmWiki

pmwiki.org

CreditsBlock

Summary: Create a "last edited by" block that includes everybody who had a hand in developing a page
Version: 0.3 - 3 January 2005
Prerequisites: last tested with PmWiki 2.0.beta14
Status:
Categories: Administration

Purpose

What I would like to see is a "last edited by" block that includes everybody who had a hand in developing the page. It would be nice to show who originally started the page. Maybe add a block of text to PmWiki pages showing the last editor and all previous editors, such as:

Last edited by AliceFakename. Based on work by BobNotaperson, CharlieDoesntexist and anonymous users of SomeWiki.

Solution

v0.3

v0.2

Credits Block is a script that provides a customizable block that can include only the last author, or every contributer who had a hand in a page. This script creates a variable $CreditBlock that can be used in Cookbook/PmWikiTemplates. The configuration variables below help customize the credits block.

This useful script was originally developed for the PmWiki 1.0 series. Version 0.3 was coded and tested using PmWiki 2.0.beta14.

Installation Instructions

To install the software, unpack the zip file, and copy its contents to your pmwiki directory:

  1. unzip pmwiki-credits-0.3.zip (or) tar xvfz pmwiki-credits-0.3.tar.gz
  2. cp -R pmwiki-credits-0.3/* /path/to/pmwiki/
  3. Activate this script by adding the following line to your local/config.php file:
include_once('cookbook/credits.php');

This will create a variable, $CreditBlock, that you can put into your PmWiki templates however you like. I put mine at the bottom at the page, right after the "last edited" stuff.

Configuration Variables:

This module uses the following configuration variables:

$CreditAnd (Default "and ")
This provides the conjunction to join the last contributer to the "CreditOthersFormat" list.
$CreditAnonymous (Default "an anonymous user of $WikiTitle")
A string meaning a single anonymous user.
$CreditAnonymousPlural (Default "anonymous users of $WikiTitle")
A string meaning a multiple anonymous users.
$CreditAuthorLinks (Default 1)
Determines if the author name links to the author page
  • 0 -- no link
  • 1 -- link
$CreditComma (Default
", "): The mortar that joins the contributers in the "CreditOthersFormat" list.
$CreditFirstFmt (Default "Originally by \$first.")
A pattern for the credit block, showing the original person to edit the page. The substitution variable "$first" shows where to put the name.
$CreditLangauge (Default "EN")
The two-letter language code (based on ISO 639-2) for the target language. When used with the language.php file, allows for more flexible joining of names for the other contributers.
$CreditLastFmt (Default "Last edited by \$last.")
A pattern for the credit block, showing the last person to edit the page. The substitution variable "$last" shows where to put the name.
$CreditLimit (Default 2)
Maximum number of credits to list. And, yes, it's a pun.
  • 0 -- omit the credit block
  • 1 -- Show the original author and the latest editor only
  • 2 -- Show all contributers.
$CreditOthersFormat (Defaults "Based on work by \$others.")
A pattern for the credit block, showing the other people who've edited the page. The substitution variable "$others" shows where to put the list of other contributors.

Packing List

This list is incorrect - there are two credits.php files in the downloaded arvive: one at the root of the archive and one in cookbook. The copy in the cookbook directory has a bug. See Bugs below.

pmwiki-credits-0.3/
COPYING.credits
README.credits
cookbook/
credits.php
credits/
language.php
wikilib.d/
CreditBlock.HomePage

History

2004 May 28 -- 0.1.
First version, probably pretty buggy.
2004 July 20 -- 0.2.
Change to comply with the ComplexRecipes layout.
2005 January 3 --0.3
Recoded.
  1. Added ability to have the credit block provide links to the profile pages for each contributer.
  2. Will space names in accordance with SpaceWikiWords
  3. Added "language.php" that allows user to define the language for the other contributers listing. Presently there is only English (EN), Esperanto (EO), and German (DE). If you add a language, please share.

Comments

  • Should show "overflow" credits on a separate page.
  • Reads the page before any other code gets to it; it would be nice to figure out a way to "hook" into page display, so the file doesn't have to be read twice.
  • When the page history expires or is forced to expire, those authors are no longer credited.

Bugs

(These are specific code failures for v0.3)

  • If you add a space to a page made by user A, the user that adds the space (user B) will now be the original maker of the page (A->B). (new to wiki, sorry for not know how to correctly report this)

the_CName I've this error when i install this CookBook :

=php Warning: creditmakecreditblock(/local/scripts/credits/language.php): failed to open stream: Aucun fichier ou répertoire de ce type in /space_3/linucie/www/doc2/cookbook/credits.php on line 75 Fatal error: creditmakecreditblock(): Failed opening required '/local/scripts/credits/language.php' (include_path='.:/space_3/:/php/includes:/usr/local/php4/lib/php/') in /space_3/linucie/www/doc2/cookbook/credits.php on line 75

I got the same error (although it was in english). I solved it by going into cookbook/credits.php and editing line 75.
This is what it says originally:
require_once($ScriptDir.'/local/scripts/credits/language.php');
I changed it to:
require_once($ScriptDir.'cookbook/credits/language.php');
It then worked properly
menachem January 20, 2005, at 04:12 PM

Update There are two credits.php files in the archive available for download.
One ends up in cookbook/ and has the problem mentioned above (line 75 of credits.php is messed up)
The second ends up in the /path/to/pmwiki/ directory (parallel to cookbook/).
Line 75 for that credits.php reads: require_once('cookbook/credits/language.php');
That credits.php doesn't give the error
-menachem January 21, 2005, at 03:03 AM

I solved the same problem on a farm installation with the following update:
function CreditMakeCreditBlock($pagename) {
global $FarmD, $ScriptDir, $DefaultGroup, $DefaultName;
require_once("$FarmD/cookbook/credits/language.php");

  • Also received this error. Ben: This is an excellent feature, and would be worth packaging up to make installation a little smoother. At the moment I had to give up. DaveG

The links generated for the usernames in the Credit Block were not properly formatted.
The link they generated ended up missing the Group that the profiles were stored in.
This is how it showed up in my wiki page: http://otterprojectonline.info/pmwiki//menachem(approve links)
It looks like the $AuthorGroup(approve links) variable is not set by default. credits.php uses the $AuthorGroup variable to form the url. Therefore, if $AuthorGroup is not set, the link is not formatted correctly.
menachem January 21, 2005, at 03:03 AM

  • When the page history expires or is forced to expire, those authors are no longer credited.

→ Is it possible to fix this? When page history expires the changes that were made aren´t lost, but the credited authors are. Robert, January 21, 2005, at 12:23 PM CET

  • This is a great feature, I had one little problem though, the "Originally by" and "Last edited by" credits were backwards. Whoever created the page was credited as having last edited it, and vice versa. Corrected this by changing:

$first = array_shift($authors); # Original Author
$latest = array_pop($authors); # Last Contributer
to
$latest = array_shift($authors); # Original Author
$first = array_pop($authors); # Last Contributer
In both "credits.php" files. It seemed to work, though I'm not sure if there may be other problems with making that change, or even why it was neccessary in the first place (I'm not a coder). -JC, June 06, 2005

  • To get rid of output on pages with no real authors (like the RecentChanges pages), add

if (empty($authors)) return ''; after

     foreach ($page as $k => $v) {
		if (preg_match('/^author\:\d+/', $k)) {
            $authors[$k] = $v;
        }
     }

-DB October 31, 2005, at 01:57 AM

If I use this recipe (with the fix for the file in the cookbook directory, and reversing original author with last contributor, but without the no author fix), I lose the ability to log in to pages in my Secure group. Most of my wiki pages are @nopass for read. But I set Secure/GroupAttributes?action=attr to set read permissions to the same as edit, meaning you must log in to read Secure pages. If I edit any non-Secure wiki page before going to the Secure area, I'm fine. But if I'm not authenticated and I go to Secure, it only prompts for password and does not prompt for login. I tried the RequireAuthor recipe, but it didn't help. I tried turning off each recipe I've used, thankfully only a handful and I made a test wiki farm for it, and the only one I have to turn off is this one, so I know this is the culprit. I love the functionality of a credits block, but I keep getting critical tickets from users who want to go straight to the Secure group (via bookmark) and can't log in. (I'm using AuthUser['ldap'] so I don't have to manage user passwords thank goodness but that's exactly why I need the login prompt with the password prompt. I'm using $Author = $AuthId; too.) So, in summary, using this recipe causes read authorizations not to prompt for a login, while edit is fine and uses Site/AuthForm as it should. --nethope, 12/14/2007 16:28EDT

Contributors

Copyright

Copyright 2004, Evan Prodromou. Made available to you through the General Public License (GPL), which is in the zip file.

Edit - History - Print - Recent Changes - Search
Page last modified on December 14, 2007, at 03:28 PM