[pmwiki-users] Require: Permanent page creator name

0 views
Skip to first unread message

imoc

unread,
Jan 31, 2008, 2:08:51 AM1/31/08
to pmwiki...@pmichaud.com
Hollow All(especially Hans),

While PmWiki becomes more and more powerful and flexible, it can be used to
be the site engine of many different kinds of web sites like blogs or forums.

But in those cases a permanent page creator name is very impotent. In the
other hand, in the wiki logic, creater is less impotent than the modifier.
In fact PmWiki only supply {$LastModifiedBy} and no {$Creater} at all.

I'm not asking a {$Creater} variable, but if PM can take it into
consideration that would be great. I'm looking for a way to use available
methods to do the same work. My question is:

If I use Hans's NewPageBoxPlus which can use another page as template, and if
I put a PTV like (:creator: ... :) in the template, how can I 'save' the
value of the $Author right into the PTV at the same time when a page was
saved?

Wish my poor English is good enough to be understood.

Cheers,
imoc

_______________________________________________
pmwiki-users mailing list
pmwiki...@pmichaud.com
http://www.pmichaud.com/mailman/listinfo/pmwiki-users

imoc

unread,
Jan 31, 2008, 2:57:23 AM1/31/08
to pmwiki...@pmichaud.com
>
Sorry to bother everybody.

I find Hans's code here:

http://groups.google.com/group/pmwiki-users/
browse_thread/thread/cd5856c9e1c0b3f0/ea594cc45bd54738?
lnk=gst&q=creator#ea594cc45bd54738

Which sulved my problem. Thanks Hans.

imoc

unread,
Jan 31, 2008, 4:18:10 AM1/31/08
to pmwiki...@pmichaud.com
>
> $FmtPV['$Creator'] = 'PageCreationAuthor($pagename)';
> function PageCreationAuthor($pagename) {
> $page = RetrieveAuthPage($pagename, 'read', true);
> foreach($page as $key => $value)
> if (strstr($key,'author'))
> $authors[$key] = $value;
> return end($authors);
> }
>

Hi Hans, I add these code in 'config.php' and put {$Creator} variable in
'Site.PageAction' like 'Post by {*$Creator}'. It worked in every page
except new page. While creating new page, there is a warning:

Warning: end() [function.end]: Passed variable is not an array or
object in /home/jbooknet/public_html/tw/local/config.php on line 121

In my config.php the line 121 is:

return end($authors);

If I ignore the message. The page can be saved with no problem. and
everything are ok at next edit.

Hans

unread,
Jan 31, 2008, 7:24:32 AM1/31/08
to imoc, pmwiki...@pmichaud.com
Thursday, January 31, 2008, 9:18:10 AM, imoc wrote:

>> $FmtPV['$Creator'] = 'PageCreationAuthor($pagename)';
>> function PageCreationAuthor($pagename) {
>> $page = RetrieveAuthPage($pagename, 'read', true);
>> foreach($page as $key => $value)
>> if (strstr($key,'author'))
>> $authors[$key] = $value;
>> return end($authors);
>> }
>>

> Hi Hans, I add these code in 'config.php' and put {$Creator} variable in
> 'Site.PageAction' like 'Post by {*$Creator}'. It worked in every page
> except new page. While creating new page, there is a warning:

> Warning: end() [function.end]: Passed variable is not an array or
> object in /home/jbooknet/public_html/tw/local/config.php on line 121

> In my config.php the line 121 is:

> return end($authors);

For a new page there is no author set in the page attributes.
Try this:

$FmtPV['$Creator'] = 'PageCreationAuthor($pagename)';
function PageCreationAuthor($pagename) {
$page = RetrieveAuthPage($pagename, 'read', true);
foreach($page as $key => $value)
if (strstr($key,'author'))
$authors[$key] = $value;

if (is_array($authors))
return end($authors);
else return '';
}

or perhaps the last line could also be

else return '{$Author}';


~Hans

imoc

unread,
Jan 31, 2008, 8:33:44 AM1/31/08
to pmwiki...@pmichaud.com

For a new page there is no author set in the page attributes.
Try this:

$FmtPV['$Creator'] = 'PageCreationAuthor($pagename)';


function PageCreationAuthor($pagename) {
$page = RetrieveAuthPage($pagename, 'read', true);
foreach($page as $key => $value)
if (strstr($key,'author'))
$authors[$key] = $value;

if (is_array($authors))
return end($authors);
else return '';
}

or perhaps the last line could also be

else return '{$Author}';


~Hans

Thanks Hans,

As usual, it worked again. :)

Hans

unread,
Feb 1, 2008, 7:02:09 AM2/1/08
to imoc, pmwiki...@pmichaud.com
Thursday, January 31, 2008, 1:33:44 PM, imoc wrote:

> As usual, it worked again. :)

Well, not quite :-(

The functions pulls the last author name from the page's diff history.
This is usually the first auther = page creator.
But if you delete part of the history with ExpireDiff or by setting
$DiffKeepDays to a short time period, the last author in th ehistory
changes, and so does the $Creator page variable.

Thank you Anke for pointing this out!

What we really need is a Creator page attribute, written into the page
when the page is created, and set to the author, alongside the
existing one for creation time 'ctime'.
I suggest 'cauthor'.

It needs a change of code in pmwiki.php in function ReadPage:
add $Author to the global list of that function, and
change line
if (@!$page) $page['ctime'] = $Now;
to
if (@!$page) { $page['ctime'] = $Now; $page['cauthor'] = $Author; }


Maybe Pm can be persuaded to do this core change.
Then we can have a true {$Creator} or {$PageCreatedBy} page variable.


~Hans

imoc

unread,
Feb 1, 2008, 9:25:31 AM2/1/08
to pmwiki...@pmichaud.com
2008/2/1, Hans <des...@softflow.co.uk>:

Well, not quite :-(

The functions pulls the last author name from the page's diff history.
This is usually the first auther = page creator.
But if you delete part of the history with ExpireDiff or by setting
$DiffKeepDays to a short time period, the last author in th ehistory
changes, and so does the $Creator page variable.

Thank you Anke for pointing this out!

What we really need is a Creator page attribute, written into the page
when the page is created, and set to the author, alongside the
existing one for creation time 'ctime'.
I suggest 'cauthor'.

It needs a change of code in pmwiki.php in function ReadPage:
add $Author to the global list of that function, and
change line
if (@!$page) $page['ctime'] = $Now;
to
if (@!$page) { $page['ctime'] = $Now; $page['cauthor'] = $Author; }

Maybe Pm can be persuaded to do this core change.
Then we can have a true {$Creator} or {$PageCreatedBy} page variable.

~Hans

---------------------------------------------

Thanks for thinking this seriously, Hans.

Since Hans was baned by gmane( his post can not show here in gmane.org)
So I think I've to invite Pm to advise us what he think about this
issue. I write some word in title. Wish Pm could see it.

Cheers,

Reply all
Reply to author
Forward
0 new messages