[pmwiki-users] AuthorContribution recipe - can someone with some knowledge update this

Tegan Dowling tmdowling at gmail.com
Mon Jul 16 08:39:21 CDT 2007


On 7/15/07, H. Fox <haganfox at users.sourceforge.net> wrote:
> On 7/15/07, Tegan Dowling <tmdowling at gmail.com> wrote:
> [...]
> > So I reverted to the older version of the Author Contributions recipe,
> > which created AuthorName pages in a Contributions wikigroup, using the
> > recipe authorcontribution.php, which was FORMERLY downloadable from
> > http://www.pmwiki.org/wiki/Cookbook/Authorcontribution-OldVersion (it
> > is more complex than the 4 lines that now appear on that cookbook
> > page, and I can forward it if anyone would find that useful).
>
> How about uploading it to pmwiki.org as "authorcontrib-old.php"?  Then
> it can be attached to the Authorcontribution-OldVersion page.
>

I would have, and will if that's what people want -- I just hesitated
because after all, *someone* thought it should be removed from the
page in the first place.  I don't know how to evaluate its merits, so
I'll first paste it here to see if anyone has any reasons why it
shouldn't be restored:

<?php if (!defined('PmWiki')) exit();

/*  Copyright 2004

    Version: authorcontribution 1.0.1

    *Contributors*
    Patrick Michaud
    Laurent Meister (kt007) (meister at apfelwiki dot de)
    Sebastian Siedentopf (Schlaefer) (schlaefer at macnews dot de)

    *Licence*
    You can redistribute this file and/or modify
    it under the terms of the GNU General Public License as published
    by the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    *Description*
    Collect all contributions of an author.

    If an author has a page in the group "Profiles", this generates a
page with the author's name in the group "Contributions". Every time
an author saves a wikipage this contribution is collected there in the
manner of RecentChanges.

    *Installation*
    Simply copy this file into the 'cookbook/' subdirectory, and then
add to local/config.php

        include_once("$FarmD/cookbook/authorcontrib-old.php");

    For convenience, you can use (:include Contributions.AUTHORNAME:)
to include this on the author's profile page.

    If you exclude Profiles pages from default search results, you may
also want to exclude Contributions pages.  Do so by adding to
local/config.php

        $SearchPatterns['default'][] = '!^Contributions\\.!';

    *Attention*
    This script works only with pmwiki2!

*/

$EditFunctions[] = 'PostAuthorChanges';

function PostAuthorChanges($pagename,&$page,&$new) {
  global $IsPagePosted,$RCDelimPattern;

  $AuthorChangesFmt = array(
  '$Author' =>
    '* [[$Group.$Name]]  . . . $CurrentTime - \'\' [=$ChangeSummary=] \'\' ');

  if (!$IsPagePosted) return;

  foreach($AuthorChangesFmt as $rcfmt=>$pgfmt) {

    $rcname = FmtPageName("Profiles.".$rcfmt,$pagename);  if
(!$rcname) continue;
    if (!PageExists($rcname)) continue;

    $rcname = FmtPageName("Contributions.".$rcfmt,$pagename);  if
(!$rcname) continue;
    $pgtext = FmtPageName($pgfmt,$pagename);  if (!$pgtext) continue;
    if (@$seen[$rcname]++) continue;

    $rcpage = ReadPage($rcname);
    $rcelim = preg_quote(preg_replace("/$RCDelimPattern.*$/",' ',$pgtext),'/');
    $rcpage['text'] = preg_replace("/[^\n]*$rcelim.*\n/","",@$rcpage['text']);
    if (!preg_match("/$RCDelimPattern/",$rcpage['text']))
      $rcpage['text'] .= "$pgtext\n";
    else
      $rcpage['text'] = preg_replace("/([^\n]*$RCDelimPattern.*\n)/",
        "$pgtext\n$1",$rcpage['text'],1);
    WritePage($rcname,$rcpage);
  }
}



More information about the pmwiki-users mailing list