Revision history for MyChangesAction
Revision [23443]
Last edited on 2016-05-20 07:38:48 by BrianKoontz [Replaces old-style internal links with new pipe-split links.]Additions:
For a comparison of the both versions see [[http://ranta.info/TimosChanges | TimosChanges]]. That page uses the above code, but statically assumes TimoK as user, no matter if you are logged in or not.
Deletions:
Additions:
>>
==Implemented in 1.2==
==See also:==
if ($last) {
print("<br />\n");
print("<strong>$current</strong><br />\n");
$last = $current;
$rev_link = "<a href='".$baseurl.$tag."/revisions'>history</a>";
$page_link ="<a href='".$baseurl.$tag."'>".$tag."</a>";
print(" (".$time.") (".$rev_link.") ".$page_link."<br />\n");
$orderbyalpha = TRUE;
$orderbyalpha = FALSE;
if ($vars["sorting"] == "alpha" || $vars["sorting"] == "alphabetically") {
$orderbyalpha = TRUE;
$orderbyalpha = FALSE;
$str_sorting = " along with the time of your last change ";
$str_linktxt = "order by date";
$str_linkpar = "alphabetically=0";
$str_q2 = "' ORDER BY tag ASC, time DESC";
$str_sorting = " ordered by the time of your last change ";
$str_linktxt = "order alphabetically";
$str_linkpar = "alphabetically=1";
$str_q2 = "' ORDER BY pdate DESC, tag ASC, ptime DESC";
if ($orderbyalpha) {
foreach ($pages as $page) {
if (!preg_match("/[A-Z]/", $firstChar)) {
print_edit($last,$firstChar,$page["tag"],$page["pdate"]." ".$page["ptime"]);
}
} else {
foreach($pages as $page) {
print_edit($curDay,$page["pdate"],$page["tag"],$page["ptime"]);
print("<em>No pages found.</em>");
==Implemented in 1.2==
==See also:==
if ($last) {
print("<br />\n");
print("<strong>$current</strong><br />\n");
$last = $current;
$rev_link = "<a href='".$baseurl.$tag."/revisions'>history</a>";
$page_link ="<a href='".$baseurl.$tag."'>".$tag."</a>";
print(" (".$time.") (".$rev_link.") ".$page_link."<br />\n");
$orderbyalpha = TRUE;
$orderbyalpha = FALSE;
if ($vars["sorting"] == "alpha" || $vars["sorting"] == "alphabetically") {
$orderbyalpha = TRUE;
$orderbyalpha = FALSE;
$str_sorting = " along with the time of your last change ";
$str_linktxt = "order by date";
$str_linkpar = "alphabetically=0";
$str_q2 = "' ORDER BY tag ASC, time DESC";
$str_sorting = " ordered by the time of your last change ";
$str_linktxt = "order alphabetically";
$str_linkpar = "alphabetically=1";
$str_q2 = "' ORDER BY pdate DESC, tag ASC, ptime DESC";
if ($orderbyalpha) {
foreach ($pages as $page) {
if (!preg_match("/[A-Z]/", $firstChar)) {
print_edit($last,$firstChar,$page["tag"],$page["pdate"]." ".$page["ptime"]);
}
} else {
foreach($pages as $page) {
print_edit($curDay,$page["pdate"],$page["tag"],$page["ptime"]);
print("<em>No pages found.</em>");
Deletions:
if ($last) {
print("<br />\n");
}
print("<strong>$current</strong><br />\n");
$last = $current;
}
$rev_link = "<a href='".$baseurl.$tag."/revisions'>history</a>";
$page_link ="<a href='".$baseurl.$tag."'>".$tag."</a>";
print(" (".$time.") (".$rev_link.") ".$page_link."<br />\n");
$orderbyalpha = TRUE;
$orderbyalpha = FALSE;
if ($vars["sorting"] == "alpha" || $vars["sorting"] == "alphabetically") {
$orderbyalpha = TRUE;
}
$orderbyalpha = FALSE;
$str_sorting = " along with the time of your last change ";
$str_linktxt = "order by date";
$str_linkpar = "alphabetically=0";
$str_q2 = "' ORDER BY tag ASC, time DESC";
$str_sorting = " ordered by the time of your last change ";
$str_linktxt = "order alphabetically";
$str_linkpar = "alphabetically=1";
$str_q2 = "' ORDER BY pdate DESC, tag ASC, ptime DESC";
if ($orderbyalpha) {
foreach ($pages as $page) {
if ($last_tag != $page["tag"]) {
$last_tag = $page["tag"];
$firstChar = strtoupper($page["tag"][0]);
if (!preg_match("/[A-Z]/", $firstChar)) {
$firstChar = "#";
}
print_edit($last,$firstChar,$page["tag"],$page["pdate"]." ".$page["ptime"]);
}
}
} else {
foreach($pages as $page) {
if ($last_tag != $page["tag"]) {
$last_tag = $page["tag"];
print_edit($curDay,$page["pdate"],$page["tag"],$page["ptime"]);
}
}
}
print("<em>No pages found.</em>");
No Differences
Additions:
print(" (".$page["time"].") (".$this->Link($page["tag"], "revisions", "history", 0).") ".$this->Link($page["tag"], "", "", 0)."<br />\n");
$my_edits_count++;
}
}
if ($my_edits_count == 0)
print("<em>You have not edited any pages yet.</em>");
}
}
else
print("<em>No pages found.</em>");
}
}
else
print("<strong>This is a list of pages you've edited, ordered by the time of your last change (<a href=\"".$this->href("", $tag, "alphabetically=1")."\">order alphabetically</a>).</strong><br /><br />\n");
if ($pages = $this->LoadAll("SELECT tag, time FROM ".$this->config["table_prefix"]."pages WHERE user = '".mysql_real_escape_string($this->GetUserName())."' ORDER BY time ASC, tag ASC"))
$edited_pages[$page["tag"]] = $page["time"];
}
$edited_pages = array_reverse($edited_pages);
foreach ($edited_pages as $page["tag"] => $page["time"])
// day header
list($day, $time) = explode(" ", $page["time"]);
if ($day != $curday)
{
if ($curday) print("<br />\n");
print("<strong>$day:</strong><br />\n");
$curday = $day;
}
// print entry
print(" ($time) (".$this->Link($page["tag"], "revisions", "history", 0).") ".$this->Link($page["tag"], "", "", 0)."<br />\n");
$my_edits_count++;
}
if ($my_edits_count == 0)
print("<em>You have not edited any pages yet.</em>");
}
}
else
print("<em>No pages found.</em>");
}
}
}
else
print("<em>You're not logged in, thus the list of pages you've edited couldn't be retrieved.</em>");
}
?>
%%
----
The above code doesn't sort the pages properly when sorting by time.
I have re-coded the action like this:
// re-coded by Timo Kissing
// http://wikka.jsnx.com/TimoK
// Thanks a lot to JavaWoman for the help!
// http://wikka.jsnx.com/JavaWoman
if(!function_exists("print_edit")) {
function print_edit(&$last, &$current, &$tag, $time) {
if ($current != $last) {
if ($last) {
print("<br />\n");
}
print("<strong>$current</strong><br />\n");
$last = $current;
}
$rev_link = "<a href='".$baseurl.$tag."/revisions'>history</a>";
$page_link ="<a href='".$baseurl.$tag."'>".$tag."</a>";
print(" (".$time.") (".$rev_link.") ".$page_link."<br />\n");
}
}
if ($this->GetUser()) {
$user = $this->GetUserName();
global $baseurl;
$baseurl = $this->config["base_url"];
$str_q1 = "SELECT DATE_FORMAT(time,'%Y-%m-%d') as pdate, ";
$str_q1.= "DATE_FORMAT(time,'%H:%i:%s') as ptime, ";
$str_q1.= "tag FROM ". $this->config["table_prefix"];
$str_q1.= "pages WHERE user = '". mysql_real_escape_string($user);
if ($_REQUEST["alphabetically"] == "1") {
$orderbyalpha = TRUE;
} elseif ($_REQUEST["alphabetically"] == "0") {
$orderbyalpha = FALSE;
} elseif (is_string($vars["sorting"])) {
if ($vars["sorting"] == "alpha" || $vars["sorting"] == "alphabetically") {
$orderbyalpha = TRUE;
}
} else {
$orderbyalpha = FALSE;
}
if ($orderbyalpha) {
$str_sorting = " along with the time of your last change ";
$str_linktxt = "order by date";
$str_linkpar = "alphabetically=0";
$str_q2 = "' ORDER BY tag ASC, time DESC";
} else {
$str_sorting = " ordered by the time of your last change ";
$str_linktxt = "order alphabetically";
$str_linkpar = "alphabetically=1";
$str_q2 = "' ORDER BY pdate DESC, tag ASC, ptime DESC";
}
print("<strong>This is a list of pages you've edited,");
print($str_sorting."(<a href='".$this->href("", $tag, $str_linkpar));
print("'>".$str_linktxt."</a>).</strong><br /><br />\n");
if ($pages = $this->LoadAll($str_q1.$str_q2)) {
if ($orderbyalpha) {
foreach ($pages as $page) {
if ($last_tag != $page["tag"]) {
$last_tag = $page["tag"];
$firstChar = strtoupper($page["tag"][0]);
if (!preg_match("/[A-Z]/", $firstChar)) {
$firstChar = "#";
}
print_edit($last,$firstChar,$page["tag"],$page["pdate"]." ".$page["ptime"]);
}
}
} else {
foreach($pages as $page) {
if ($last_tag != $page["tag"]) {
$last_tag = $page["tag"];
print_edit($curDay,$page["pdate"],$page["tag"],$page["ptime"]);
}
}
}
} else {
print("<em>No pages found.</em>");
}
} else {
print("<em>You're not logged in, thus the list of pages you've edited couldn't be retrieved.</em>");
}
?>
%%
For a comparison of the both versions see [[http://ranta.info/TimosChanges TimosChanges]]. That page uses the above code, but statically assumes TimoK as user, no matter if you are logged in or not.
Thanks to JavaWoman who helped me a lot tonight with questions and ideas. Without you I couldn't have done this.
The above code seems stable, safe and fast (225 out of ~260 rows fetched in 0.07 seconds compared to 0.25 seconds with the old code), but it's 1:35AM as I am writing this, so I would be happy if some others could test it on their own wikkas and let me know if there are any problems.
----
CategoryUserContributions
$my_edits_count++;
}
}
if ($my_edits_count == 0)
print("<em>You have not edited any pages yet.</em>");
}
}
else
print("<em>No pages found.</em>");
}
}
else
print("<strong>This is a list of pages you've edited, ordered by the time of your last change (<a href=\"".$this->href("", $tag, "alphabetically=1")."\">order alphabetically</a>).</strong><br /><br />\n");
if ($pages = $this->LoadAll("SELECT tag, time FROM ".$this->config["table_prefix"]."pages WHERE user = '".mysql_real_escape_string($this->GetUserName())."' ORDER BY time ASC, tag ASC"))
$edited_pages[$page["tag"]] = $page["time"];
}
$edited_pages = array_reverse($edited_pages);
foreach ($edited_pages as $page["tag"] => $page["time"])
// day header
list($day, $time) = explode(" ", $page["time"]);
if ($day != $curday)
{
if ($curday) print("<br />\n");
print("<strong>$day:</strong><br />\n");
$curday = $day;
}
// print entry
print(" ($time) (".$this->Link($page["tag"], "revisions", "history", 0).") ".$this->Link($page["tag"], "", "", 0)."<br />\n");
$my_edits_count++;
}
if ($my_edits_count == 0)
print("<em>You have not edited any pages yet.</em>");
}
}
else
print("<em>No pages found.</em>");
}
}
}
else
print("<em>You're not logged in, thus the list of pages you've edited couldn't be retrieved.</em>");
}
?>
%%
----
The above code doesn't sort the pages properly when sorting by time.
I have re-coded the action like this:
// re-coded by Timo Kissing
// http://wikka.jsnx.com/TimoK
// Thanks a lot to JavaWoman for the help!
// http://wikka.jsnx.com/JavaWoman
if(!function_exists("print_edit")) {
function print_edit(&$last, &$current, &$tag, $time) {
if ($current != $last) {
if ($last) {
print("<br />\n");
}
print("<strong>$current</strong><br />\n");
$last = $current;
}
$rev_link = "<a href='".$baseurl.$tag."/revisions'>history</a>";
$page_link ="<a href='".$baseurl.$tag."'>".$tag."</a>";
print(" (".$time.") (".$rev_link.") ".$page_link."<br />\n");
}
}
if ($this->GetUser()) {
$user = $this->GetUserName();
global $baseurl;
$baseurl = $this->config["base_url"];
$str_q1 = "SELECT DATE_FORMAT(time,'%Y-%m-%d') as pdate, ";
$str_q1.= "DATE_FORMAT(time,'%H:%i:%s') as ptime, ";
$str_q1.= "tag FROM ". $this->config["table_prefix"];
$str_q1.= "pages WHERE user = '". mysql_real_escape_string($user);
if ($_REQUEST["alphabetically"] == "1") {
$orderbyalpha = TRUE;
} elseif ($_REQUEST["alphabetically"] == "0") {
$orderbyalpha = FALSE;
} elseif (is_string($vars["sorting"])) {
if ($vars["sorting"] == "alpha" || $vars["sorting"] == "alphabetically") {
$orderbyalpha = TRUE;
}
} else {
$orderbyalpha = FALSE;
}
if ($orderbyalpha) {
$str_sorting = " along with the time of your last change ";
$str_linktxt = "order by date";
$str_linkpar = "alphabetically=0";
$str_q2 = "' ORDER BY tag ASC, time DESC";
} else {
$str_sorting = " ordered by the time of your last change ";
$str_linktxt = "order alphabetically";
$str_linkpar = "alphabetically=1";
$str_q2 = "' ORDER BY pdate DESC, tag ASC, ptime DESC";
}
print("<strong>This is a list of pages you've edited,");
print($str_sorting."(<a href='".$this->href("", $tag, $str_linkpar));
print("'>".$str_linktxt."</a>).</strong><br /><br />\n");
if ($pages = $this->LoadAll($str_q1.$str_q2)) {
if ($orderbyalpha) {
foreach ($pages as $page) {
if ($last_tag != $page["tag"]) {
$last_tag = $page["tag"];
$firstChar = strtoupper($page["tag"][0]);
if (!preg_match("/[A-Z]/", $firstChar)) {
$firstChar = "#";
}
print_edit($last,$firstChar,$page["tag"],$page["pdate"]." ".$page["ptime"]);
}
}
} else {
foreach($pages as $page) {
if ($last_tag != $page["tag"]) {
$last_tag = $page["tag"];
print_edit($curDay,$page["pdate"],$page["tag"],$page["ptime"]);
}
}
}
} else {
print("<em>No pages found.</em>");
}
} else {
print("<em>You're not logged in, thus the list of pages you've edited couldn't be retrieved.</em>");
}
?>
%%
For a comparison of the both versions see [[http://ranta.info/TimosChanges TimosChanges]]. That page uses the above code, but statically assumes TimoK as user, no matter if you are logged in or not.
Thanks to JavaWoman who helped me a lot tonight with questions and ideas. Without you I couldn't have done this.
The above code seems stable, safe and fast (225 out of ~260 rows fetched in 0.07 seconds compared to 0.25 seconds with the old code), but it's 1:35AM as I am writing this, so I would be happy if some others could test it on their own wikkas and let me know if there are any problems.
----
CategoryUserContributions
Deletions:
Additions:
print("
Deletions:
$my_edits_count++;
}
}
if ($my_edits_count == 0)
print("<em>You have not edited any pages yet.</em>");
}
}
else
print("<em>No pages found.</em>");
}
}
else
print("<strong>This is a list of pages you've edited, ordered by the time of your last change (<a href=\"".$this->href("", $tag, "alphabetically=1")."\">order alphabetically</a>).</strong><br /><br />\n");
if ($pages = $this->LoadAll("SELECT tag, time FROM ".$this->config["table_prefix"]."pages WHERE user = '".mysql_real_escape_string($this->GetUserName())."' ORDER BY time ASC, tag ASC"))
$edited_pages[$page["tag"]] = $page["time"];
}
$edited_pages = array_reverse($edited_pages);
foreach ($edited_pages as $page["tag"] => $page["time"])
// day header
list($day, $time) = explode(" ", $page["time"]);
if ($day != $curday)
{
if ($curday) print("<br />\n");
print("<strong>$day:</strong><br />\n");
$curday = $day;
}
// print entry
print(" ($time) (".$this->Link($page["tag"], "revisions", "history", 0).") ".$this->Link($page["tag"], "", "", 0)."<br />\n");
$my_edits_count++;
}
if ($my_edits_count == 0)
print("<em>You have not edited any pages yet.</em>");
}
}
else
print("<em>No pages found.</em>");
}
}
}
else
print("<em>You're not logged in, thus the list of pages you've edited couldn't be retrieved.</em>");
}
?>
%%
----
The above code doesn't sort the pages properly when sorting by time.
I have re-coded the action like this:
// re-coded by Timo Kissing
// http://wikka.jsnx.com/TimoK
// Thanks a lot to JavaWoman for the help!
// http://wikka.jsnx.com/JavaWoman
if(!function_exists("print_edit")) {
function print_edit(&$last, &$current, &$tag, $time) {
if ($current != $last) {
if ($last) {
print("<br />\n");
}
print("<strong>$current</strong><br />\n");
$last = $current;
}
$rev_link = "<a href='".$baseurl.$tag."/revisions'>history</a>";
$page_link ="<a href='".$baseurl.$tag."'>".$tag."</a>";
print(" (".$time.") (".$rev_link.") ".$page_link."<br />\n");
}
}
if ($this->GetUser()) {
$user = $this->GetUserName();
global $baseurl;
$baseurl = $this->config["base_url"];
$str_q1 = "SELECT DATE_FORMAT(time,'%Y-%m-%d') as pdate, ";
$str_q1.= "DATE_FORMAT(time,'%H:%i:%s') as ptime, ";
$str_q1.= "tag FROM ". $this->config["table_prefix"];
$str_q1.= "pages WHERE user = '". mysql_real_escape_string($user);
if ($_REQUEST["alphabetically"] == "1") {
$orderbyalpha = TRUE;
} elseif ($_REQUEST["alphabetically"] == "0") {
$orderbyalpha = FALSE;
} elseif (is_string($vars["sorting"])) {
if ($vars["sorting"] == "alpha" || $vars["sorting"] == "alphabetically") {
$orderbyalpha = TRUE;
}
} else {
$orderbyalpha = FALSE;
}
if ($orderbyalpha) {
$str_sorting = " along with the time of your last change ";
$str_linktxt = "order by date";
$str_linkpar = "alphabetically=0";
$str_q2 = "' ORDER BY tag ASC, time DESC";
} else {
$str_sorting = " ordered by the time of your last change ";
$str_linktxt = "order alphabetically";
$str_linkpar = "alphabetically=1";
$str_q2 = "' ORDER BY pdate DESC, tag ASC, ptime DESC";
}
print("<strong>This is a list of pages you've edited,");
print($str_sorting."(<a href='".$this->href("", $tag, $str_linkpar));
print("'>".$str_linktxt."</a>).</strong><br /><br />\n");
if ($pages = $this->LoadAll($str_q1.$str_q2)) {
if ($orderbyalpha) {
foreach ($pages as $page) {
if ($last_tag != $page["tag"]) {
$last_tag = $page["tag"];
$firstChar = strtoupper($page["tag"][0]);
if (!preg_match("/[A-Z]/", $firstChar)) {
$firstChar = "#";
}
print_edit($last,$firstChar,$page["tag"],$page["pdate"]." ".$page["ptime"]);
}
}
} else {
foreach($pages as $page) {
if ($last_tag != $page["tag"]) {
$last_tag = $page["tag"];
print_edit($curDay,$page["pdate"],$page["tag"],$page["ptime"]);
}
}
}
} else {
print("<em>No pages found.</em>");
}
} else {
print("<em>You're not logged in, thus the list of pages you've edited couldn't be retrieved.</em>");
}
?>
%%
For a comparison of the both versions see [[http://ranta.info/TimosChanges TimosChanges]]. That page uses the above code, but statically assumes TimoK as user, no matter if you are logged in or not.
Thanks to JavaWoman who helped me a lot tonight with questions and ideas. Without you I couldn't have done this.
The above code seems stable, safe and fast (225 out of ~260 rows fetched in 0.07 seconds compared to 0.25 seconds with the old code), but it's 1:35AM as I am writing this, so I would be happy if some others could test it on their own wikkas and let me know if there are any problems.
----
CategoryUserContributions
Additions:
// Thanks a lot to JavaWoman for the help!
// http://wikka.jsnx.com/JavaWoman
function print_edit(&$last, &$current, &$tag, $time) {
if ($current != $last) {
$rev_link = "<a href='".$baseurl.$tag."/revisions'>history</a>";
$page_link ="<a href='".$baseurl.$tag."'>".$tag."</a>";
$user = $this->GetUserName();
global $baseurl;
$baseurl = $this->config["base_url"];
$str_q1 = "SELECT DATE_FORMAT(time,'%Y-%m-%d') as pdate, ";
$str_q1.= "DATE_FORMAT(time,'%H:%i:%s') as ptime, ";
$str_q1.= "tag FROM ". $this->config["table_prefix"];
$str_q1.= "pages WHERE user = '". mysql_real_escape_string($user);
if ($_REQUEST["alphabetically"] == "1") {
} elseif ($_REQUEST["alphabetically"] == "0") {
} elseif (is_string($vars["sorting"])) {
if ($vars["sorting"] == "alpha" || $vars["sorting"] == "alphabetically") {
$str_q2 = "' ORDER BY tag ASC, time DESC";
$str_q2 = "' ORDER BY pdate DESC, tag ASC, ptime DESC";
if ($pages = $this->LoadAll($str_q1.$str_q2)) {
print_edit($last,$firstChar,$page["tag"],$page["pdate"]." ".$page["ptime"]);
foreach($pages as $page) {
print_edit($curDay,$page["pdate"],$page["tag"],$page["ptime"]);
For a comparison of the both versions see [[http://ranta.info/TimosChanges TimosChanges]]. That page uses the above code, but statically assumes TimoK as user, no matter if you are logged in or not.
Thanks to JavaWoman who helped me a lot tonight with questions and ideas. Without you I couldn't have done this.
The above code seems stable, safe and fast (225 out of ~260 rows fetched in 0.07 seconds compared to 0.25 seconds with the old code), but it's 1:35AM as I am writing this, so I would be happy if some others could test it on their own wikkas and let me know if there are any problems.
// http://wikka.jsnx.com/JavaWoman
function print_edit(&$last, &$current, &$tag, $time) {
if ($current != $last) {
$rev_link = "<a href='".$baseurl.$tag."/revisions'>history</a>";
$page_link ="<a href='".$baseurl.$tag."'>".$tag."</a>";
$user = $this->GetUserName();
global $baseurl;
$baseurl = $this->config["base_url"];
$str_q1 = "SELECT DATE_FORMAT(time,'%Y-%m-%d') as pdate, ";
$str_q1.= "DATE_FORMAT(time,'%H:%i:%s') as ptime, ";
$str_q1.= "tag FROM ". $this->config["table_prefix"];
$str_q1.= "pages WHERE user = '". mysql_real_escape_string($user);
if ($_REQUEST["alphabetically"] == "1") {
} elseif ($_REQUEST["alphabetically"] == "0") {
} elseif (is_string($vars["sorting"])) {
if ($vars["sorting"] == "alpha" || $vars["sorting"] == "alphabetically") {
$str_q2 = "' ORDER BY tag ASC, time DESC";
$str_q2 = "' ORDER BY pdate DESC, tag ASC, ptime DESC";
if ($pages = $this->LoadAll($str_q1.$str_q2)) {
print_edit($last,$firstChar,$page["tag"],$page["pdate"]." ".$page["ptime"]);
foreach($pages as $page) {
print_edit($curDay,$page["pdate"],$page["tag"],$page["ptime"]);
For a comparison of the both versions see [[http://ranta.info/TimosChanges TimosChanges]]. That page uses the above code, but statically assumes TimoK as user, no matter if you are logged in or not.
Thanks to JavaWoman who helped me a lot tonight with questions and ideas. Without you I couldn't have done this.
The above code seems stable, safe and fast (225 out of ~260 rows fetched in 0.07 seconds compared to 0.25 seconds with the old code), but it's 1:35AM as I am writing this, so I would be happy if some others could test it on their own wikkas and let me know if there are any problems.
Deletions:
global $wakka;
if ($current != $last) {
$rev_link = $wakka->Link($tag, "revisions", "history", 0);
$page_link = $wakka->Link($tag, "", "", 0);
$edit_count++;
$user=$this->GetUserName();
$edit_count = 0;
$str_query = "SELECT tag, time FROM ". $this->config["table_prefix"];
$str_query.= "pages WHERE user = '". mysql_real_escape_string($user);
if ($_REQUEST["alphabetically"] == 1) {
} elseif(is_string($vars["sorting"]) && $_REQUEST["alphabetically"] != 0) {
if($vars["sorting"] == "alpha" || $vars["sorting"] == "alphabetically") {
$str_query .= "' ORDER BY tag ASC, time DESC";
$str_query .= "' ORDER BY time ASC";
if ($pages = $this->LoadAll($str_query)) {
print_edit($last,$firstChar,$edit_count,$page["tag"],$page["time"]);
$edited_pages[$page["tag"]] = $page["time"];
arsort($edited_pages);
$sorted_pages = array();
foreach ($edited_pages as $pagetag => $pagetime) {
list($day, $time) = explode(" ", $pagetime);
array_push($sorted_pages,array("tag" => $pagetag, "day" => $day,"time" => $time));
foreach ($sorted_pages as $key => $row) {
$days[$key] = $row['day'];
$tags[$key] = $row['tag'];
array_multisort($days, SORT_DESC, $tags, SORT_ASC, $sorted_pages);
foreach($sorted_pages as $page) {
print_edit($curDay,$page["day"],$edit_count,$page["tag"],$page["time"]);
if ($edit_count == 0) {
print("<em>You have not edited any pages yet.</em>");
For a comparison of the both versions see [[http://ranta.info/TimosChanges TimosChanges]].
Revision [7117]
Edited on 2005-04-05 10:54:29 by TimoK [Quick (dirty) fix for "Can't redeclare already declared function" error]Additions:
if(!function_exists("print_edit")) {
function print_edit(&$last, &$current, &$edit_count, $tag, $time) {
global $wakka;
if ($current != $last) {
if ($last) {
print("<br />\n");
print("<strong>$current</strong><br />\n");
$last = $current;
$rev_link = $wakka->Link($tag, "revisions", "history", 0);
$page_link = $wakka->Link($tag, "", "", 0);
print(" (".$time.") (".$rev_link.") ".$page_link."<br />\n");
$edit_count++;
function print_edit(&$last, &$current, &$edit_count, $tag, $time) {
global $wakka;
if ($current != $last) {
if ($last) {
print("<br />\n");
print("<strong>$current</strong><br />\n");
$last = $current;
$rev_link = $wakka->Link($tag, "revisions", "history", 0);
$page_link = $wakka->Link($tag, "", "", 0);
print(" (".$time.") (".$rev_link.") ".$page_link."<br />\n");
$edit_count++;
Deletions:
global $wakka;
if ($current != $last) {
if ($last) {
print("<br />\n");
print("<strong>$current</strong><br />\n");
$last = $current;
$rev_link = $wakka->Link($tag, "revisions", "history", 0);
$page_link = $wakka->Link($tag, "", "", 0);
print(" (".$time.") (".$rev_link.") ".$page_link."<br />\n");
$edit_count++;
Revision [7115]
Edited on 2005-04-05 10:38:47 by TimoK [Added alphabetical sorting inside the per-day-listing when sorting by date]Additions:
arsort($edited_pages);
$sorted_pages = array();
foreach ($edited_pages as $pagetag => $pagetime) {
list($day, $time) = explode(" ", $pagetime);
array_push($sorted_pages,array("tag" => $pagetag, "day" => $day,"time" => $time));
}
foreach ($sorted_pages as $key => $row) {
$days[$key] = $row['day'];
$tags[$key] = $row['tag'];
}
array_multisort($days, SORT_DESC, $tags, SORT_ASC, $sorted_pages);
foreach($sorted_pages as $page) {
print_edit($curDay,$page["day"],$edit_count,$page["tag"],$page["time"]);
}
$sorted_pages = array();
foreach ($edited_pages as $pagetag => $pagetime) {
list($day, $time) = explode(" ", $pagetime);
array_push($sorted_pages,array("tag" => $pagetag, "day" => $day,"time" => $time));
}
foreach ($sorted_pages as $key => $row) {
$days[$key] = $row['day'];
$tags[$key] = $row['tag'];
}
array_multisort($days, SORT_DESC, $tags, SORT_ASC, $sorted_pages);
foreach($sorted_pages as $page) {
print_edit($curDay,$page["day"],$edit_count,$page["tag"],$page["time"]);
}
Deletions:
foreach ($edited_pages as $pagetag => $pagetime) {
list($day, $time) = explode(" ", $pagetime);
print_edit($curDay,$day,$edit_count,$pagetag,$time);
Additions:
=====My Changes Action=====
>>==See also:==
Documentation: MyChangesActionInfo.>>This is the development page for the my changes action.::c::
The php code:
%%(php)
<?php
// actions/mychanges.php
// written by Carlo Zottmann
// http://wakkawikki.com/CarloZottmann
if ($user = $this->GetUser())
{
$my_edits_count = 0;
if ($_REQUEST["alphabetically"] == 1)
{
print("<strong>This is a list of pages you've edited, along with the time of your last change (<a href=\"".$this->href("", $tag)."\">order by date</a>).</strong><br /><br />\n");
if ($pages = $this->LoadAll("SELECT tag, time FROM ".$this->config["table_prefix"]."pages WHERE user = '".mysql_real_escape_string($this->GetUserName())."' ORDER BY tag ASC, time DESC"))
{
foreach ($pages as $page)
{
if ($last_tag != $page["tag"]) {
$last_tag = $page["tag"];
$firstChar = strtoupper($page["tag"][0]);
if (!preg_match("/[A-Z,a-z]/", $firstChar)) {
$firstChar = "#";
}
if ($firstChar != $curChar) {
if ($curChar) print("<br />\n");
print("<strong>$firstChar</strong><br />\n");
$curChar = $firstChar;
}
// print entry
print(" (".$page["time"].") (".$this->Link($page["tag"], "revisions", "history", 0).") ".$this->Link($page["tag"], "", "", 0)."<br />\n");
$my_edits_count++;
}
}
if ($my_edits_count == 0)
{
print("<em>You have not edited any pages yet.</em>");
}
}
else
{
print("<em>No pages found.</em>");
}
}
else
{
print("<strong>This is a list of pages you've edited, ordered by the time of your last change (<a href=\"".$this->href("", $tag, "alphabetically=1")."\">order alphabetically</a>).</strong><br /><br />\n");
if ($pages = $this->LoadAll("SELECT tag, time FROM ".$this->config["table_prefix"]."pages WHERE user = '".mysql_real_escape_string($this->GetUserName())."' ORDER BY time ASC, tag ASC"))
{
foreach ($pages as $page)
{
$edited_pages[$page["tag"]] = $page["time"];
}
$edited_pages = array_reverse($edited_pages);
foreach ($edited_pages as $page["tag"] => $page["time"])
{
// day header
list($day, $time) = explode(" ", $page["time"]);
if ($day != $curday)
{
if ($curday) print("<br />\n");
print("<strong>$day:</strong><br />\n");
$curday = $day;
}
// print entry
print(" ($time) (".$this->Link($page["tag"], "revisions", "history", 0).") ".$this->Link($page["tag"], "", "", 0)."<br />\n");
$my_edits_count++;
}
if ($my_edits_count == 0)
{
print("<em>You have not edited any pages yet.</em>");
}
}
else
{
print("<em>No pages found.</em>");
}
}
}
else
{
print("<em>You're not logged in, thus the list of pages you've edited couldn't be retrieved.</em>");
}
?>
%%
----
The above code doesn't sort the pages properly when sorting by time.
I have re-coded the action like this:
%%(php)
<?php
// actions/mychanges.php
// written by Carlo Zottmann
// http://wakkawikki.com/CarloZottmann
// re-coded by Timo Kissing
// http://wikka.jsnx.com/TimoK
function print_edit(&$last, &$current, &$edit_count, $tag, $time) {
global $wakka;
if ($current != $last) {
if ($last) {
print("<br />\n");
}
print("<strong>$current</strong><br />\n");
$last = $current;
}
$rev_link = $wakka->Link($tag, "revisions", "history", 0);
$page_link = $wakka->Link($tag, "", "", 0);
print(" (".$time.") (".$rev_link.") ".$page_link."<br />\n");
$edit_count++;
}
if ($this->GetUser()) {
$user=$this->GetUserName();
$edit_count = 0;
$str_query = "SELECT tag, time FROM ". $this->config["table_prefix"];
$str_query.= "pages WHERE user = '". mysql_real_escape_string($user);
if ($_REQUEST["alphabetically"] == 1) {
$orderbyalpha = TRUE;
} elseif(is_string($vars["sorting"]) && $_REQUEST["alphabetically"] != 0) {
if($vars["sorting"] == "alpha" || $vars["sorting"] == "alphabetically") {
$orderbyalpha = TRUE;
}
} else {
$orderbyalpha = FALSE;
}
if ($orderbyalpha) {
$str_sorting = " along with the time of your last change ";
$str_linktxt = "order by date";
$str_linkpar = "alphabetically=0";
$str_query .= "' ORDER BY tag ASC, time DESC";
} else {
$str_sorting = " ordered by the time of your last change ";
$str_linktxt = "order alphabetically";
$str_linkpar = "alphabetically=1";
$str_query .= "' ORDER BY time ASC";
}
print("<strong>This is a list of pages you've edited,");
print($str_sorting."(<a href='".$this->href("", $tag, $str_linkpar));
print("'>".$str_linktxt."</a>).</strong><br /><br />\n");
if ($pages = $this->LoadAll($str_query)) {
if ($orderbyalpha) {
foreach ($pages as $page) {
if ($last_tag != $page["tag"]) {
$last_tag = $page["tag"];
$firstChar = strtoupper($page["tag"][0]);
if (!preg_match("/[A-Z]/", $firstChar)) {
$firstChar = "#";
}
print_edit($last,$firstChar,$edit_count,$page["tag"],$page["time"]);
}
}
} else {
foreach ($pages as $page) {
$edited_pages[$page["tag"]] = $page["time"];
}
arsort($edited_pages);
foreach ($edited_pages as $pagetag => $pagetime) {
list($day, $time) = explode(" ", $pagetime);
print_edit($curDay,$day,$edit_count,$pagetag,$time);
}
}
if ($edit_count == 0) {
print("<em>You have not edited any pages yet.</em>");
}
} else {
print("<em>No pages found.</em>");
}
} else {
print("<em>You're not logged in, thus the list of pages you've edited couldn't be retrieved.</em>");
}
?>
%%
For a comparison of the both versions see [[http://ranta.info/TimosChanges TimosChanges]].
----
>>==See also:==
Documentation: MyChangesActionInfo.>>This is the development page for the my changes action.::c::
The php code:
%%(php)
<?php
// actions/mychanges.php
// written by Carlo Zottmann
// http://wakkawikki.com/CarloZottmann
if ($user = $this->GetUser())
{
$my_edits_count = 0;
if ($_REQUEST["alphabetically"] == 1)
{
print("<strong>This is a list of pages you've edited, along with the time of your last change (<a href=\"".$this->href("", $tag)."\">order by date</a>).</strong><br /><br />\n");
if ($pages = $this->LoadAll("SELECT tag, time FROM ".$this->config["table_prefix"]."pages WHERE user = '".mysql_real_escape_string($this->GetUserName())."' ORDER BY tag ASC, time DESC"))
{
foreach ($pages as $page)
{
if ($last_tag != $page["tag"]) {
$last_tag = $page["tag"];
$firstChar = strtoupper($page["tag"][0]);
if (!preg_match("/[A-Z,a-z]/", $firstChar)) {
$firstChar = "#";
}
if ($firstChar != $curChar) {
if ($curChar) print("<br />\n");
print("<strong>$firstChar</strong><br />\n");
$curChar = $firstChar;
}
// print entry
print(" (".$page["time"].") (".$this->Link($page["tag"], "revisions", "history", 0).") ".$this->Link($page["tag"], "", "", 0)."<br />\n");
$my_edits_count++;
}
}
if ($my_edits_count == 0)
{
print("<em>You have not edited any pages yet.</em>");
}
}
else
{
print("<em>No pages found.</em>");
}
}
else
{
print("<strong>This is a list of pages you've edited, ordered by the time of your last change (<a href=\"".$this->href("", $tag, "alphabetically=1")."\">order alphabetically</a>).</strong><br /><br />\n");
if ($pages = $this->LoadAll("SELECT tag, time FROM ".$this->config["table_prefix"]."pages WHERE user = '".mysql_real_escape_string($this->GetUserName())."' ORDER BY time ASC, tag ASC"))
{
foreach ($pages as $page)
{
$edited_pages[$page["tag"]] = $page["time"];
}
$edited_pages = array_reverse($edited_pages);
foreach ($edited_pages as $page["tag"] => $page["time"])
{
// day header
list($day, $time) = explode(" ", $page["time"]);
if ($day != $curday)
{
if ($curday) print("<br />\n");
print("<strong>$day:</strong><br />\n");
$curday = $day;
}
// print entry
print(" ($time) (".$this->Link($page["tag"], "revisions", "history", 0).") ".$this->Link($page["tag"], "", "", 0)."<br />\n");
$my_edits_count++;
}
if ($my_edits_count == 0)
{
print("<em>You have not edited any pages yet.</em>");
}
}
else
{
print("<em>No pages found.</em>");
}
}
}
else
{
print("<em>You're not logged in, thus the list of pages you've edited couldn't be retrieved.</em>");
}
?>
%%
----
The above code doesn't sort the pages properly when sorting by time.
I have re-coded the action like this:
%%(php)
<?php
// actions/mychanges.php
// written by Carlo Zottmann
// http://wakkawikki.com/CarloZottmann
// re-coded by Timo Kissing
// http://wikka.jsnx.com/TimoK
function print_edit(&$last, &$current, &$edit_count, $tag, $time) {
global $wakka;
if ($current != $last) {
if ($last) {
print("<br />\n");
}
print("<strong>$current</strong><br />\n");
$last = $current;
}
$rev_link = $wakka->Link($tag, "revisions", "history", 0);
$page_link = $wakka->Link($tag, "", "", 0);
print(" (".$time.") (".$rev_link.") ".$page_link."<br />\n");
$edit_count++;
}
if ($this->GetUser()) {
$user=$this->GetUserName();
$edit_count = 0;
$str_query = "SELECT tag, time FROM ". $this->config["table_prefix"];
$str_query.= "pages WHERE user = '". mysql_real_escape_string($user);
if ($_REQUEST["alphabetically"] == 1) {
$orderbyalpha = TRUE;
} elseif(is_string($vars["sorting"]) && $_REQUEST["alphabetically"] != 0) {
if($vars["sorting"] == "alpha" || $vars["sorting"] == "alphabetically") {
$orderbyalpha = TRUE;
}
} else {
$orderbyalpha = FALSE;
}
if ($orderbyalpha) {
$str_sorting = " along with the time of your last change ";
$str_linktxt = "order by date";
$str_linkpar = "alphabetically=0";
$str_query .= "' ORDER BY tag ASC, time DESC";
} else {
$str_sorting = " ordered by the time of your last change ";
$str_linktxt = "order alphabetically";
$str_linkpar = "alphabetically=1";
$str_query .= "' ORDER BY time ASC";
}
print("<strong>This is a list of pages you've edited,");
print($str_sorting."(<a href='".$this->href("", $tag, $str_linkpar));
print("'>".$str_linktxt."</a>).</strong><br /><br />\n");
if ($pages = $this->LoadAll($str_query)) {
if ($orderbyalpha) {
foreach ($pages as $page) {
if ($last_tag != $page["tag"]) {
$last_tag = $page["tag"];
$firstChar = strtoupper($page["tag"][0]);
if (!preg_match("/[A-Z]/", $firstChar)) {
$firstChar = "#";
}
print_edit($last,$firstChar,$edit_count,$page["tag"],$page["time"]);
}
}
} else {
foreach ($pages as $page) {
$edited_pages[$page["tag"]] = $page["time"];
}
arsort($edited_pages);
foreach ($edited_pages as $pagetag => $pagetime) {
list($day, $time) = explode(" ", $pagetime);
print_edit($curDay,$day,$edit_count,$pagetag,$time);
}
}
if ($edit_count == 0) {
print("<em>You have not edited any pages yet.</em>");
}
} else {
print("<em>No pages found.</em>");
}
} else {
print("<em>You're not logged in, thus the list of pages you've edited couldn't be retrieved.</em>");
}
?>
%%
For a comparison of the both versions see [[http://ranta.info/TimosChanges TimosChanges]].
----
Deletions:
>>==See also:==
Documentation: AbbreviationActionInfo.>>This is the development page for the abbreviation action.::c::
The php code:
%%(php)
<?php
/**
* Create a <abbr> or <acronym> link.
*
* Usage: {{abbr type="acronym" short="IMHO" long="In My Humble Opinion"}}
*
* @package Actions
* @subpackage
* @name abbr
*
* @author {@link http://wikka.jsnx.com/ChristianBarthelemy Christian Barthelemy} - original idea and code.
* @version 0.1
* @since Not (yet?) part of offical Wikka release
*
* @input string $type optional: the type of abbreviation
* default is abbr any other value means acronym - will be used as the html tag and as the name of the class too
*
* @input string $short required: the short writting that needs to be explained
*
* @input string $long optional: the long text to explain the meaning of the short one
* default is empty - it assumes that it has been previously provided in the same page
*
* @todo Nothing I can think about for now.
*
*/
// set defaults
$type = "abbr";
$output = "";
// ***** PARAMETERS Interface *****
$uType = $vars['type'];
if ($uType) $type = "acronym";
$uShort = $vars['short'];
if ($uShort) $short = $uShort;
$uLong = $vars['long'];
if ($uLong) $long = $uLong;
// ***** end PARAMETERS Interface *****
// ***** HTML code generation *****
// if short parameter hasn't been provided nothing is done
if ($short) {
$output="<".$type." class=\"".$type."\" ";
if ($long) {$output.="TITLE=\"".$long."\">";}
$output.=$short."</".$type.">";
}
// ***** end HTML code generation *****
print $output;
?>
%%
The added css (example):
%%(css)
.abbr {
color: red;
cursor: hand;
}
.acronym {
color: red;
cursor: hand;
}
%%
----