Suggestion for Allowing Columns on Wikka Pageindex action
By IvanLaninI try to made adjustment to pageindex action to allow column such on category. The following code is what I've came up with, also including tweaking on the index_header.
Please comment. Thx.
<?php
if ($pages = $this->LoadAllPages())
{
if (!isset($col)) $col = 1;
if (isset($_REQUEST["letter"])) $requested_letter = $_REQUEST["letter"]; else $requested_letter = '';
if (!$requested_letter && isset($letter)) $requested_letter = strtoupper($letter);
$cached_username = $this->GetUserName();
$link = $this->href("", "", "letter=");
$index_header = "<strong>" . (($requested_letter != '') ? "<a href='$link'>All</a>" : "All") . "</strong> \n";
$user_owns_pages = false;
$index_output = "";
$current_character = "";
$character_changed = false;
$char_count = 0;
foreach ($pages as $page) {
$firstChar = strtoupper($page["tag"][0]);
if (!preg_match("/[A-Za-z]/", $firstChar)) $firstChar = "#";
if ($firstChar != $current_character) {
$current_character = $firstChar;
$character_changed = true;
$char_index[$current_character] = 0;
}
$char_index[$firstChar]++;
if ($requested_letter == '' || $firstChar == $requested_letter && $character_changed)
$character_changed = false;
}
$current_character = "";
$character_changed = false;
$index_output .= "<table width=\"100%\" border=\"0\">\n";
foreach ($pages as $page)
{
$page_owner = $page["owner"];
// $this->CachePage($page);
$firstChar = strtoupper($page["tag"][0]);
if (!preg_match("/[A-Za-z]/", $firstChar)) $firstChar = "#";
if ($firstChar != $current_character) {
$index_header .= "<strong>" .
(($requested_letter != '' && $firstChar == $requested_letter) ?
$firstChar : "<a href='$link$firstChar'>$firstChar</a>") .
"</strong> \n";
$current_character = $firstChar;
$character_changed = true;
}
if ($requested_letter == '' || $firstChar == $requested_letter) {
if ($character_changed) {
$char_count = 0;
$index_output .= "<tr><td> </td></tr>\n";
$index_output .= "<tr><td><strong>$firstChar</strong></td></tr>\n<tr>\n";
$character_changed = false;
}
if ($char_count == $col) {
$index_output .= "</tr>\n<tr>";
$char_count = 0;
}
$index_output .= '<td>' . $this->Link($page["tag"]);
if ($cached_username == $page_owner) {
$index_output .= "*";
$user_owns_pages = true;
} elseif ($page_owner != '(Public)' && $page_owner != '') {
$index_output .= " . . . . Owner: ".$page_owner;
}
$index_output .= "</td>\n";
$char_count++;
}
}
$index_output .= "</tr>\n</table>";
$index_header .= "<br />";
if ($user_owns_pages) $index_output .= "<br />\n* Indicates a page that you own.<br />\n";
print $index_header.$index_output;
} else {
print("<em>No pages found.</em>");
}
?>
if ($pages = $this->LoadAllPages())
{
if (!isset($col)) $col = 1;
if (isset($_REQUEST["letter"])) $requested_letter = $_REQUEST["letter"]; else $requested_letter = '';
if (!$requested_letter && isset($letter)) $requested_letter = strtoupper($letter);
$cached_username = $this->GetUserName();
$link = $this->href("", "", "letter=");
$index_header = "<strong>" . (($requested_letter != '') ? "<a href='$link'>All</a>" : "All") . "</strong> \n";
$user_owns_pages = false;
$index_output = "";
$current_character = "";
$character_changed = false;
$char_count = 0;
foreach ($pages as $page) {
$firstChar = strtoupper($page["tag"][0]);
if (!preg_match("/[A-Za-z]/", $firstChar)) $firstChar = "#";
if ($firstChar != $current_character) {
$current_character = $firstChar;
$character_changed = true;
$char_index[$current_character] = 0;
}
$char_index[$firstChar]++;
if ($requested_letter == '' || $firstChar == $requested_letter && $character_changed)
$character_changed = false;
}
$current_character = "";
$character_changed = false;
$index_output .= "<table width=\"100%\" border=\"0\">\n";
foreach ($pages as $page)
{
$page_owner = $page["owner"];
// $this->CachePage($page);
$firstChar = strtoupper($page["tag"][0]);
if (!preg_match("/[A-Za-z]/", $firstChar)) $firstChar = "#";
if ($firstChar != $current_character) {
$index_header .= "<strong>" .
(($requested_letter != '' && $firstChar == $requested_letter) ?
$firstChar : "<a href='$link$firstChar'>$firstChar</a>") .
"</strong> \n";
$current_character = $firstChar;
$character_changed = true;
}
if ($requested_letter == '' || $firstChar == $requested_letter) {
if ($character_changed) {
$char_count = 0;
$index_output .= "<tr><td> </td></tr>\n";
$index_output .= "<tr><td><strong>$firstChar</strong></td></tr>\n<tr>\n";
$character_changed = false;
}
if ($char_count == $col) {
$index_output .= "</tr>\n<tr>";
$char_count = 0;
}
$index_output .= '<td>' . $this->Link($page["tag"]);
if ($cached_username == $page_owner) {
$index_output .= "*";
$user_owns_pages = true;
} elseif ($page_owner != '(Public)' && $page_owner != '') {
$index_output .= " . . . . Owner: ".$page_owner;
}
$index_output .= "</td>\n";
$char_count++;
}
}
$index_output .= "</tr>\n</table>";
$index_header .= "<br />";
if ($user_owns_pages) $index_output .= "<br />\n* Indicates a page that you own.<br />\n";
print $index_header.$index_output;
} else {
print("<em>No pages found.</em>");
}
?>
CategoryUserContributions
Sorry to butt in, and I appreciate the contribution - but I've "renamed" your page ebcause we have a naming convention: pages starting with Modxxx are for describing actual modifations implemented in a Wikka release. Your page name was thus highly confusing.
Please also add the page into the UserContributions category!
Works fine on my system.
I think it would be nice to have mod.