-
Notifications
You must be signed in to change notification settings - Fork 0
/
unused_disp.php
146 lines (141 loc) · 4.28 KB
/
unused_disp.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
<?php
// 11-03-2020. This put as function 'getwordDisplay' in getwordClass
// The main function basicDisplay constructs an HTML table from
// an array ($matches) of data elements.
// Each of the data elements is a string which is valid XML.
// The XML is processed using the XML Parser routines (see PHP documentation)
// This XML string is further assumed to be in UTF-8 encoding.
// Nov 10, 2014. Modified to show Arabic text
// Jul 19, 2015 move DispItem class into dispitem.php
require_once('dispitem.php');
require_once('dbgprint.php');
function basicDisplay($parms,$matches) {
// June 4, 2015 -- assume $matches is filled with records of form:
// $matches[$i] == array(key,lnum,rec) -
// rec = <info>pg</info><body>html</body>
// June 14, 2015 for MW, info = pg:Hcode:key2a:hom
// July 11, 2015 Use 'Parm' object for calling sequence
// Aug 17, 2015 Remove use of _GET['options']. Always use $options='2'
$key = $parms->key;
$dict = strtoupper($parms->dict);
if(isset($_REQUEST['dispopt'])) {
$temp = $_REQUEST['dispopt'];
if (in_array($temp,array('1','2','3'))) {
$options = $temp;
}else {
$options = '2';
}
}else { # dispopt not set
$options = '2'; // $parms->options;
}
#output = returned string of html for basic display
/*
Sep 2, 2018. output link to basic.css depending on $parms->dispcss.
*/
$dictinfo = $parms->dictinfo;
$webpath = $dictinfo->get_webPath();
if (isset($parms->dispcss) && ($parms->dispcss == 'no')) {
$linkcss = "";
}else {
$linkcss = "<link rel='stylesheet' type='text/css' href='css/basic.css' />";
}
if ($options == '3') {
$output = '';
}else {
$output = <<<EOT
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
$linkcss
</head>
<body>
EOT;
}
$english = $parms->english;
/* use of 'CologneBasic' is coordinated with basic.css
So basic.css won't interfere with the user page. This
assumes that the id 'CologneBasic' is unused on user page.
*/
if (($options == '1')||($options == '2')) {
$table = "<div id='CologneBasic'>\n";
}else if ($options == '3') {
$table = "<div>";
}else {
if ($english) {
$table = "<div id='CologneBasic'>\n<h1> $key</h1>\n";
} else {
$table = "<div id='CologneBasic'>\n<h1> <SA>$key</SA></h1>\n";
}
}
$table .= "<table class='display'>\n";
$ntot = count($matches);
$dispItems=array();
$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");
}
$dispItem = new DispItem($dict,$dbrec);
if ($dispItem->err) {
//return "<p>Internal error in basicDisplay for $dict, $key</p>";
$keyin = $parms->keyin;
return "<p>Could not find headword $keyin in dictionary $dict</p>";
}
$dispItems[] = $dispItem;
}
// modify dispitem->keyshow, (when to show the key)
for($i=0;$i<$ntot;$i++) {
$dispItem=$dispItems[$i];
if ($i==0) {//show if first item
}else if ($dispItem->hom) { // show if a homonym
}else if (strlen($dispItem->hcode) == 2) { // show; Only restrictive for MW
}else if (($i>0) and ($dispItem->key== $dispItems[$i-1]->key)){ // don't show
$dispItem->keyshow = '';
}
}
// In the 'alt' version of MW, not all of the keys shown are the same.
// In this case, try adding css (shading?) to distinguish the keys that are
// NOT the same as $parms->key.
for($i=0;$i<$ntot;$i++) {
$dispItem=$dispItems[$i];
if ($dispItem->key != $parms->key) {
$dispItem->cssshade=True;
}
}
// Aug 15, 2015. Set firstHom instance variable to True where needed
$found=False;
// First, set firstHom always false
for($i=0;$i<$ntot;$i++) {
$dispItem=$dispItems[$i];
$dispItem->firstHom=False;
}
// Next, set it True on first record with hom
for($i=0;$i<$ntot;$i++) {
$dispItem=$dispItems[$i];
if ($dispItem->hom ) {
$dispItem->firstHom=True;
break; //
}
}
// Generate output
$dispItemPrev=null;
for($i=0;$i<$ntot;$i++) {
$dispItem = $dispItems[$i];
if ($options == '1') {
$table .= $dispItem->basicDisplayRecord1($dispItemPrev);
}else if ($options == '2') {
$table .= $dispItem->basicDisplayRecord2($dispItemPrev);
}else{
$table .= $dispItem->basicDisplayRecordDefault($dispItemPrev);
}
$dispItemPrev=$dispItem;
}
$table .= "</table>\n";
$output .= $table;
$output .= "</div> \n";
return $output;
}
?>