Last Edit Action


In order to avoid clicking on RecentChanges to know who edited a page and why,
here's an action which prints short lastedit infos in the page body:
Last edited by JavaWoman:
Modified links pointing to docs server
Mon, 28 Jan 2008 00:11 UTC [diff]

Usage {{lastedit}}

Optional parameter: show
{{lastedit show="0"}} show user only
Last edited by JavaWoman

{{lastedit}} or {{lastedit show="1"}} show user and notes (default)
Last edited by JavaWoman:
Modified links pointing to docs server

{{lastedit show="2"}} show user, notes, date
Last edited by JavaWoman:
Modified links pointing to docs server
Mon, 28 Jan 2008 00:11 UTC

{{lastedit show="3"}} show user, notes, date and quickdiff link
Last edited by JavaWoman:
Modified links pointing to docs server
Mon, 28 Jan 2008 00:11 UTC [diff]


actions/lastedit.php
<?php

// Prints short infos on last edit
// Uses parameter: show
// 0 show user only
// 1 show user and notes
// 2 show user, notes, date
// 3 show user, notes, date and quickdiff link

// set default
if ($show == "") {$show="1";}

if ($this->method == "show") {
    $page = $this->page;
    $pagetag = $page["tag"];
    $user = ($this->LoadUser($page["user"]))? $this->Link($page["user"]) : "anonymous";

    if (!($show == 0)) {
        $note = ($page["note"])? ":<br/><span class=\"notes\">".$page["note"]."</span>" : "";
    }

    if ($show == 2 || $show == 3) {
        list($day, $time) = explode(" ", $page["time"]);
        $dateformatted = date("D, d M Y", strtotime($day));
        $timeformatted = date("H:i T", strtotime($page["time"]));
    }
    if ($show == 3) {
        $oldpage = $this->LoadSingle("SELECT * FROM ".$this->config["table_prefix"]."pages WHERE tag='".$this->GetPageTag()."' AND latest = 'N' ORDER BY time desc LIMIT 1");
        $newid = $page["id"];
        $oldid = $oldpage["id"];
        $difflink = " [<a title=\"Show differences from last version\" href=\"".$this->Href("diff", $pagetag, "a=".$page["id"]."&b=".$oldpage["id"]."&fastdiff=1")."\">diff</a>]";
    }
    $output = "<div class=\"lastedit\">Last edited by ".$user.$note."<br /> ".$dateformatted." ".$timeformatted.$difflink."</div>";
    print $output;
}
?>


Mods by JsnX:


CategoryDevelopmentActions
Comments
Comment by JavaWoman
2004-11-24 23:41:57
I like the idea - very much.
But I think the choice for the parameter values is rather unintuitive, especially with a negative value...
How about:
0 show user only
1 (default) show user and notes
2 show user, notes, date
3 show user, notes, date and quickdiff link
Then, if you want just user and notes (which I think you also think will be the most common usage) you don't need to specify a parameter at all; and we avoid a negative value.

Also, you should jus give the whole thing a class (or id and classes for the components, maybe) and have an entry in the (linked) stylesheet for it - embedded styles make things (styles) really hard to maintain and debug.
Comment by DarTar
2004-11-25 00:57:08
Yep, sorry: actually the choice of parameter values came from the first defaults that I had in mind. I'll fix it immediately.
As for the CSS selector, this was just a test to see if the idea was appreciated: before (if ever) this is turned into an official Wikka action, the CSS has of course to be updated.
Comment by GmBowen
2004-11-27 15:17:39
um, hmmm...it works fine for me, but it doesn't have the nice muted "grey" colour, or the dashed table border, or the smaller font size. Is there something missing in my css file??
Comment by DarTar
2004-11-29 08:59:25
Mike, as you can see in the ReleaseNotes, the style of the lastedit box is now determined by a CSS class.
Comment by GmBowen
2004-11-29 13:52:57
Ya, I kinda thought that was going on, but thought I'd post it too so that it might be clearer to other newbies too (other than myself....who has never gotten the hang of how css files work....although seeing your example with the calendar actually helped some. Probably something I should attend to more). Thanks DT.
Comment by GmBowen
2005-01-05 20:01:59
for those who can't find it elsewhere, the css code for lastedit is....

.lastedit {
border:dotted 1px;
padding:3pt;
margin:8pt; color:#888;
font-size:8pt;
width:30%;
}
Comment by MinusF
2006-01-06 12:43:05
show=3 breaks validation

http://wush.net/trac/wikka/ticket/103
Comment by DarTar
2006-01-06 15:17:21
Thanks for spotting this. I've made some further cleanup - take a look at the file I've uploaded.
Comment by MinusF
2006-01-08 21:36:33
nice.
if you want me to do stuff already with phpdoc, someone needs to add a section about it the coding guidelines... i am not familiar with this sytem, and as there are no guidelines, i am not even trying to do it: i would do it "wrong" anyway.

it would be nice to get these guidelines so you don't have to do duplicate work.
Comment by 212.254.114.236
2006-02-06 12:06:07
hello, is it possible to "embed" this lastedit code into the footer? how?
thanks, N.
Comment by DarTar
2006-02-06 13:31:37
You can embed any action in the page with the following code:
<?php
echo $this->Action('action');
?>
Comment by KraaK
2006-03-02 09:11:05
ok, thanks - it works.
but how can i avoid to have a breaking line?
TIA, n.
Comment by NilsLindenberg
2006-03-03 13:04:20
Kraak, where do you have a breaking-line?
Comment by KraaK
2006-03-03 16:40:32
i modified the footer in order to have something like:
Edit page :: last modified on 2005-05-28 19:22:07 by userxy :: Search:
-
but the embedded action shows the username in the following line, like:
Edit page :: last modified on 2005-05-28 19:22:07 by
userxy ::
Search:
...any idea? i removed from the code anything that could cause this (eg. <br>) but nothing changes.
thanks - n.
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki