Kwic Page Numbers

You can use a getKWICtitle routine like this one in Philosubs to get page numbers to display in your KWIC reports:

# getKWICtitle: formats the shrt cite on the left hand of the KWIC

# report and adds a link to the page if available.

# We are using a fix character width representation. The

# shrt cite ($title) is an identifier. We should probably

# avoid using HTML formatting here and talk to CSS.

# Called from:

# Revised: Nov 10 2004, MVO. Added the nocounter option for handling

# sorted KWICs.

# ----------------------------------------------------------------------

sub getKWICtitle {

local ($title, $nocounter, $intlink, $x, $thisobject, $mvobilioLine);

local ($mvobibsplit, $contit, $thislink, $offs, $mvohref);

# $nocounter = $_[0];

$nocounter = 1;

# Restored from STANDARD

$mvohref = "<A HREF=\"" . $CONTEXTUALIZER . "?p.";

$mvohref .= $doc . "." . $dbname . "." . join (".", @o) . "\">";

# END

$thisobject = $doc . ":" . @index[0];

if (@index[1] > 0) {

$thisobject .= ":" . @index[1];

}

if (@index[2] > 0) {

$thisobject .= ":" . @index[2];

}

if (!$mvoreaddividx) {

open (MVOBIB, $SYSTEM_DIR . "divindex.raw");

while ($mvobilioLine = <MVOBIB>) {

@mvobibsplit = split("\t", $mvobilioLine);

$BAYLEDIVIDX{$mvobibsplit[0]} = $mvobibsplit[1];

$mvoreaddividx++;

}

close (MVOBIB);

}

$conctit = $BAYLEDIVIDX{$thisobject};

if (!$conctit) {

$conctit = "Link Error";

}

else {

$offs = join(".", @o);

$offs =~ s/\.[0-9]*$//;

$thislink = "<a href=\"" . $PHILOGETOBJECT . "?c." . $thisobject;

$thislink .= "." . $dbname . "." . $offs . "\">";

}

$title = $conctit;

$title =~ s/ *$//;

$title =~ s/\*//g;

$title =~ s/ +/ /g;

$title =~ s/^ +//g;

$title =~ s/\xc3\xA7/c/g;

$title = &KwicFormat($title);

$title_length = length($title) + length($counter) + 1;

if ($title_length > $maxhead) {

$title = substr ($title, 0, $maxhead - 4 - length($counter));

$title .= "...";

$title_length = $maxhead;

}

if ($nocounter) {

$title_length = length($title) + 1 + 4;

}

else {

$title_length = length($title) + length($counter) + 1;

}

if ($title_length > $maxhead) {

if ($nocounter) {

$title = substr ($title, 0, $maxhead - 4 - 4);

}

else {

$title = substr ($title, 0, $maxhead - 4 - length($counter));

}

$title .= "...";

$title_length = $maxhead;

}

# First the title.

if ($nocounter) {

$title = $thislink . "<tt>" . $title . "</a>:</tt>";

}

else {

$title = "<tt>" . $counter . ". </tt>";

$title .= $thislink . "<tt>" . $title;

$title .= "</a>:</tt>";

}

if ($pagenum eq "?" || $pagenum eq "0") {

$title .= "<tt>p." . $pagenum . ")</tt>";

}

else {

$title .= " " . $mvohref . "<tt>(p." . $pagenum . ")</a></tt>";

}

# $pagenum_length = 0;

return $title;

}