Skip to content

Commit

Permalink
1. rev-sup display sanskrit-lexicon/MWS#173
Browse files Browse the repository at this point in the history
2. titular abbreviations sanskrit-lexicon/MWS#172
  • Loading branch information
funderburkjim committed Jul 11, 2024
1 parent 25b609d commit c75a092
Show file tree
Hide file tree
Showing 7 changed files with 195 additions and 63 deletions.
62 changes: 48 additions & 14 deletions v02/makotemplates/web/webtc/basicadjust.php
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,11 @@ public function ls_callback_mw($matches) {
$data1 = $data0;
$data = $data0;
}
if (preg_match('|tit="(.*?)"|',$ndata,$matchesn)) {
$titular = true;
} else {
$titular = false;
}
dbgprint($dbg,"\nls_callback_mw BEGIN: ndata=$ndata, n=$n, data0=$data0, data1=$data1\n");
if (!$this->dal_auth->status) {
return $ans;
Expand All @@ -601,26 +606,36 @@ public function ls_callback_mw($matches) {
} else if (in_array($this->dict,array('ap90','ben','sch','gra','bhs'))) {
list($code,$text) = $rec;
}
# Add lshead, so as to be able to style
// for mw and ap90, codecap = code
// be sure there is no xml in the text
if ($text == null) {$text = "";}
$text = preg_replace('/<.*?>/',' ',$text);
// convert special characters to html entities
// for instance, this handles cases when $text has single (or double) quotes
$tooltip = $this->htmlspecial($text);
dbgprint($dbg,"ls_callback_mw : n=$n, data=$data\n");
if ($code == null) {$code = "";}
$codecap = $code;
$ncode = strlen($code); // use substr_replace in case $code has parens
if (! $titular) {
if ($code == $data0) {
$titular = true;
}
}
if ($titular) {
// 07-05-2024. display of 'empty' ls
// $style = 'font-size: 11pt; font-family:charterindocapital; border-bottom: 1px dotted #000; ';
$style = 'border-bottom: 1px dotted #000; color:#8080ff;';
$ans = "<span title='$tooltip' style='$style'>$code</span>";
return $ans;
}

if ($n != '') {
//$datanew = substr_replace($data,"<lshead>$data</lshead>",0);
$datanew = $data;
dbgprint($dbg,"lshead 1: n=$n: datanew=$datanew\n");
} else {
$datanew = substr_replace($data,"<lshead>$codecap</lshead>",0,$ncode);
dbgprint($dbg,"lshead 2: n=$n: datanew=$datanew\n");
}
# be sure there is no xml in the text
if ($text == null) {$text = "";}
$text = preg_replace('/<.*?>/',' ',$text);
# convert special characters to html entities
# for instance, this handles cases when $tran has single (or double) quotes
$tooltip = $this->htmlspecial($text);
// --------------------------------------------------------------
$href = null;
//dbgprint(true,"before ls_callback_mw_href, dict=" . $this->dict . "\n");
Expand Down Expand Up @@ -1337,15 +1352,34 @@ public function move_L_mw($line) {
name of the <L> tag to <L1>
*/
$dbg=false;
dbgprint($dbg,"basicadjust.move_L_mw enter: line=\n$line\n");
if (preg_match('|<(H[1-4].)>.*(<L>.*?</L>)|',$line,$matches)) {
$H = $matches[1];
$Ltag = $matches[2];
$dict = $this->getParms->dict;
dbgprint($dbg,"basicadjust.move_L_mw enter: dict=$dict, line=\n$line\n");
//if (preg_match('|<(H[1-4].)>.*(<L>.*?</L>)|',$line,$matches)) {
if (preg_match('|(<L>.*?</L>)|',$line,$matches)) {
//$H = $matches[1];
$Ltag = $matches[1];
$revsup = "";
if ($dict == "mw") { // 07-07-2024
// Add markers for rev or sup Ⓡ, Ⓢ
if (preg_match('|<info n="sup"/>|',$line,$matches1)) {
$revsup = " sup";
} else if (preg_match('|<info n="rev" pc="(.*?)"/>|',$line,$matches1)) {
$pc = $matches1[1];
$revsup = " rev ($pc)";
} else {
$revsup = "";
}
}

// remove L element
$line = preg_replace("|$Ltag|","",$line);
// construct L1 tag
$L1tag = preg_replace("|L>|","L1>",$Ltag);
//dbgprint(true,"Ltag=$Ltag, L1tag=$L1tag\n");
// add in $revsup
if ($revsup != "") {
$L1tag = preg_replace("|</L1>|", "$revsup</L1>",$L1tag);
}
dbgprint(false,"basicadjust: Ltag=$Ltag, revsup=$revsup, L1tag=$L1tag\n");
// Insert L1tag before end of tail -- so at end of display
$line = preg_replace("|</tail>|","$L1tag</tail>",$line);
}
Expand Down
33 changes: 23 additions & 10 deletions v02/makotemplates/web/webtc/basicdisplay.php
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,8 @@ public function sthndl($xp,$el,$attribs) {
} else if ($el == "tail"){
} else if ($el == "L"){
} else if ($el == "L1"){
// for MW only, work done in chrhndl
// for MW only, work done elsewhere
$this->row .= "<L1>";
} else if ($el == "s1") {
// currently only MW. This has an 'slp1' attribute which could be
// used to replace the IAST text with Devanagari. However currently
Expand All @@ -455,7 +456,6 @@ public function sthndl($xp,$el,$attribs) {
$this->row .= "<i>";
} else if ($el == "info") {
} else if ($el == "pc"){
} else if ($el == "info") {
} else if ($el == "to") {
} else if ($el == "ns") {
} else if ($el == "shortlong") {
Expand Down Expand Up @@ -531,15 +531,22 @@ public function sthndl($xp,$el,$attribs) {
$this->row .= "&nbsp;<span class='ls'>";
}
} else if ($el == "span") {
// This could be generalized to do any attribute.
$temp = "<span";
if (isset($attribs['class'])) {
$class = $attribs['class'];
$this->row .= "<span class='$class'>";
} else if (isset($attribs['style'])) {
$temp .= " class='$class'";
}
if (isset($attribs['style'])) {
$style = $attribs['style'];
$this->row .= "<span style='$style'>";
} else {
$this->row .= "<span>";
$temp .= " style='$style'";
}
if (isset($attribs['title'])) {
$title = $attribs['title'];
$temp .= " title='$title'";
}
$temp .= ">"; // close the span
$this->row .= $temp;
} else if ($el == "lshead") {
// pwg, pw
$style = "color:blue; border-bottom: 1px dotted #000; text-decoration: none;";
Expand Down Expand Up @@ -715,6 +722,9 @@ public function endhndl($xp,$el) {
} else if ($el == "td"){
$this->row .= " </td> ";
} else if ($el == "br") {
// nothing
} else if (in_array($el,array("L","key1","h","info","tail","pc",
"body"))) {
// nothing
} else {
$this->row .= "</$el>";
Expand All @@ -740,9 +750,12 @@ public function chrhndl($xp,$data) {
$style = "font-size:normal; color:rgb(160,160,160);";
$this->row1 .= "<span style='$style'> [Cologne record ID=$data]</span>";
} else if ($this->parentEl == "L1") {
// only applies to MW. L1 tag generated in basicadjust.
$style = "font-size:normal; color:rgb(160,160,160);";
$this->row .= "<span class='lnum' style='$style'> [ID=$data]</span>";
// only applies to MW. L1 tag generated in basicadjust.
// This code is not used -- somehow over-riddenn by dispitem.php

// $style = "font-size:normal; color:rgb(160,160,160);";
//$this->row .= "<span class='lnum' style='$style'> [ID=$data]</span>";
$this->row .= $data;
} else if ($this->parentEl == 's') {
$this->row .= "<span class='$sdata'><SA>$data</SA></span>";
} else if ($this->inSanskrit) {
Expand Down
34 changes: 26 additions & 8 deletions v02/makotemplates/web/webtc/dispitem.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public function __construct($dict,$dbrec) {
controls whether the preg_match will work for the string. The default
for the parameter is 1000000 (one million).
*/
dbgprint(false,"dispitem: rec=\n $rec\n\n");
$ok = false;
if (preg_match('|<info>(.*?)</info><body>(.*?)</body>|',$rec,$matchrec)) {
$ok = true;
Expand All @@ -54,7 +55,8 @@ public function __construct($dict,$dbrec) {
}
$this->info = $matchrec[1];
$this->html = $matchrec[2];
dbgprint($dbg,"this->info starts as {$this->info}\n");
dbgprint(false,"dispItem: this->info starts as\n {$this->info}\n");
dbgprint(false,"dispItem: this->html starts as\n {$this->html}\n");
//Some derived fields
if($this->dictup == 'MW') {
list($this->pginfo,$this->hcode,$this->key2,$this->hom) = preg_split('/:/',$this->info);
Expand Down Expand Up @@ -197,7 +199,7 @@ public function basicRow1DefaultParts($prev) {
if ($hrefdata == $hrefdata_prev) {
$pageshow="";
}
// dbgprint(true,"dispitem: keyshow=$keyshow\n lnumshow=$lnumshow\n\n pageshow=$pageshow\n");
// dbgprint(false,"dispitem: keyshow=$keyshow\n lnumshow=$lnumshow\n\n pageshow=$pageshow\n");
return array($keyshow,$lnumshow,$pageshow);
}
public function get_pageshow($hrefdata) {
Expand All @@ -206,15 +208,31 @@ public function get_pageshow($hrefdata) {
$ans = "<span class='hrefdata'><span style='$style'> [Printed book page $hrefdata]</span></span>";
return $ans;
}
public function get_lnumshow_id($lnum) {
public function get_lnumshow_id($lnum0) {
// 08-04-2020
$style = "font-size:normal; color:rgb(160,160,160);";
$ans = "[<span title='Cologne record ID' style='$style'>ID=$lnum</span>]";
// 07-08-2024
// dbgprint(true,"dispitem:get_lnumshow_id: html= \n{$this->html}\n");
//if (preg_match("|<L1>(.*?)</L1>|",$this->html,$matches)) {
//if (preg_match("|<L1>([0-9.]+)(.*?)</L1>|",$this->html,$matches)) {
if (preg_match("|^([0-9.]+)(.*?)$|",$lnum0,$matches)) {
$lnum = $matches[1];
$revsup = $matches[2];
dbgprint(false," NO match for revsup\n");
} else {
$lnum = $lnum0;
$revsup = "";
}
dbgprint(false,"lnum0='$lnum0', lnum='$lnum', revsup='$revsup'\n");
//$style1 = "font-size:normal; color:rgb(160,160,160);";
//$ans = "[<span title='Cologne record ID' style='$style'>ID=$lnum</span>]";
$ans = "[" .
"<span title='Cologne record ID' style='font-size:normal; color:rgb(160,160,160);'>ID=$lnum</span>" .
"<span style='font-size:normal; color:red;'>$revsup</span>" . "]";
if (in_array($this->dictlo, array("abch", "acph", "acsj"))) {
// 10-30-2023
$ans .= "<hr style='height:3px;border-width:0;color:gray;background-color:gray'>";
}
//dbgprint(true,"get_lnumshow_id. dict={$this->dict}, ans=\n$ans\n\n");
//dbgprint(false,"get_lnumshow_id. dict={$this->dict}, ans=\n$ans\n\n");
return $ans;
}
public function basicRow1Default($prev) {
Expand Down Expand Up @@ -264,7 +282,7 @@ public function basicDisplayRecord2($prev) {
$pageshow = $this->get_pageshow($hrefdata);
$pre="<span style='font-weight:bold'>$keyshow $pageshow</span>";
}
//dbgprint(true,"lnumshow=$lnumshow, dictup=" . $this->dictup . ", hom=" . $this->hom . "\n");
//dbgprint(false,"lnumshow=$lnumshow, dictup=" . $this->dictup . ", hom=" . $this->hom . "\n");
if (($this->dictup == 'MW') and ($this->hom)) {
// make a link to change list view to be centered at this lnum
$symbol = "&#8592;"; // unicode left arrow
Expand Down Expand Up @@ -307,7 +325,7 @@ public function getHrefPage() {
}else {
$serve = "../webtc/$serve";
}
//dbgprint(true,"dispitem.getHrefPage: serve=$serve\n");
//dbgprint(false,"dispitem.getHrefPage: serve=$serve\n");
foreach($lnums as $lnum) {
if ($ans == "") {
$args = "dict=$dict&page=$lnum"; #"page=$page";
Expand Down
18 changes: 11 additions & 7 deletions v02/makotemplates/web/webtc/getwordClass.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,12 @@ public function getwordDisplay($parms,$matches) {
$dbg=false;
for($i=0;$i<$ntot;$i++) {
$dbrec = $matches[$i];
dbgprint($dbg,"disp.php. matches[$i] = \n");
for ($j=0;$j<count($dbrec);$j++) {
dbgprint($dbg," [$j] = {$dbrec[$j]}\n");
if ($dbg) {
dbgprint($dbg,"getwordClass dbrec[$i] = \n");
for ($j=0;$j<count($dbrec);$j++) {
dbgprint($dbg," [$j] = {$dbrec[$j]}\n");
}
dbgprint($dbg,"GETWORDCLASS: dbrec = " . $dbrec[2] . "\n\n");
}
$dispItem = new DispItem($dict,$dbrec);
if ($dispItem->err) {
Expand Down Expand Up @@ -203,14 +206,15 @@ public function getwordDisplay($parms,$matches) {
$dispItemPrev=null;
for($i=0;$i<$ntot;$i++) {
$dispItem = $dispItems[$i];

$dispItem1 = "";
if ($options == '1') {
$table .= $dispItem->basicDisplayRecord1($dispItemPrev);
$dispItem1 = $dispItem->basicDisplayRecord1($dispItemPrev);
}else if ($options == '2') {
$table .= $dispItem->basicDisplayRecord2($dispItemPrev);
$dispItem1 = $dispItem->basicDisplayRecord2($dispItemPrev);
}else{
$table .= $dispItem->basicDisplayRecordDefault($dispItemPrev);
$dispItem1 = $dispItem->basicDisplayRecordDefault($dispItemPrev);
}
$table .= $dispItem1;
$dispItemPrev=$dispItem;
}
$table .= "</table>\n";
Expand Down
Loading

0 comments on commit c75a092

Please sign in to comment.