written for my german wiki-page
http://lapppedia.de.vu after complaints not finding any pages in clusters — CooperFreak
{{pageindexbyname}}
/actions/pageindexbyname.php
<?php
// action 'pageindexbyname'
// modified by YaroslavSyuzev 02 Fev 2005
// modified by Robert Schlieder mail: cooperfreak@gmx.de
// Diese Skript ist nur für meine Seite angepasst (www.lapppedia.de.vu)
// daher sollte man einen Grossteil der Strings bearbeiten.
// der Einfachheit halber habe ich auch auf verschiedene Sprachen ($this->GetResourceValue()) verzichtet
// wer Lust hat kann dies natürlich implementieren.
$offset = ( isset($_GET["offset"]) ) ? (int)$_GET["offset"] : 0;
$pages_to_display = array();
$sql = "select ".$this->pages_meta." from ".$this->config["table_prefix"]."pages where ".
"latest = 'Y' and LEFT(supertag,7)!='comment' order by BINARY tag";
if ($pages = $this->LoadAll($sql))
{
foreach ($pages as $page)
{
if (strrpos($page["tag"],"/")) array_push($page,substr($page["tag"],strrpos($page["tag"],"/")+1));
else array_push($page,$page["tag"]);
if ($this->config["hide_locked"]) $access = $this->HasAccess("read",$page["tag"]);
else $access = true;
if ($access)
$pages_to_display[$page["tag"]] = $page;
}
}
function sortiere($a, $b) {
return strcasecmp($a[0],$b[0]);
}
uasort($pages_to_display,"sortiere");
// Vorhandene Buchstaben heraussuchen
$all_caps=array();
foreach ($pages_to_display as $page)
{
$firstChar = strtoupper($page[0][0]);
if (!preg_match("/".$this->language["ALPHA"]."/", $firstChar)) { $firstChar = "#"; }
array_push($all_caps,$firstChar);
}
$capitals=array_unique($all_caps);
sort($capitals);
if ($offset > 0)
$prev_page_link = '<a href="?wakka='.$this->getPageTag().'&offset='.($offset-1).'">< '.$this->GetResourceValue("Prev").'</a>';
else
$prev_page_link = "< ".$this->GetResourceValue("Prev");
if ($offset < sizeof($capitals)-1)
$next_page_link = '<a href="?wakka='.$this->getPageTag().'&offset='.($offset+1).'">'.$this->GetResourceValue("Next").' ></a>';
else
$next_page_link = $this->GetResourceValue("Next")." >";
if ($pages_to_display)
{
print "<p class='logBtn'><strong>$prev_page_link ";
while(list($key, $val) = each($capitals)) {
print('<a href="?wakka='.$this->getPageTag().'&offset='.$key.'">'.$val.'</a> ');
}
print "$next_page_link</strong></p>\n";
}
else
echo $this->GetResourceValue("NoPagesFound");
foreach ($pages_to_display as $page)
{
$firstChar = strtoupper($page[0][0]);
if (!preg_match("/".$this->language["ALPHA"]."/", $firstChar))
{ $firstChar = "#"; }
if ($firstChar == $capitals[$offset])
print($this->Link("/".$page["tag"],"",$page[0]." (".$page["tag"].")")."<br />\n");
}
if ($pages_to_display)
{
print("<p class='logBtn'><strong>$prev_page_link ");
reset($capitals);
while (list($key, $val) = each($capitals))
print('<a href="?wakka='.$this->getPageTag().'&offset='.$key.'">'.$val.'</a> ');
print("$next_page_link</strong></p>\n");
}
?>