<%
}
if (params.includeBaseline != null && baselineReading != null) {
if ("html".equals(params.format)) {
%>
<%
}
String tokens[] = baselineReading.getTokens();
for (int i = 0; i < tokens.length; ++i) {
baselineReadingWords.add(new ReadingWord(tokens[i]));
if ("html".equals(params.format)) {
%>
<%=tokens[i]%>
<%
}
}
if ("html".equals(params.format)) {
%>
<%
}
String appAttrib = "";
if (segments.size() > 0) {
List
segIDs = segments.get(0).getSegmentGroups();
if (segIDs.size() > 0) {
Project p = ProjectManagement.getProject(segIDs.get(0));
if (p != null) {
appAttrib = p.getApparatusAttribution();
}
}
}
if (appAttrib == null || appAttrib.length() < 1) {
if (verses.getText().startsWith("Acts")) {
Project p = ProjectManagement.getProject(88);
if (p != null) {
appAttrib = p.getApparatusAttribution();
}
}
if (verses.getText().startsWith("Mark")) {
Project p = ProjectManagement.getProject(54);
if (p != null) {
appAttrib = p.getApparatusAttribution();
}
}
}
if (appAttrib != null && appAttrib.length() > 0) {
if ("html".equals(params.format)) {
%>
<%= appAttrib %>
<%
}
}
if (params.docID != null) {
String app = loadModuleText(params.docID, params.indexContent, "tei", false, "footnotes=On");
logger.info("Directly from Crosswire: " + app);
StringBuffer allApps = new StringBuffer(app);
String t = Transcription.popElement(allApps, "app");
if (t == null) t = allApps.toString();
out.print("");
while (t != null) {
String nextT = Transcription.popElement(allApps, "app");
StringBuffer allReadings = new StringBuffer(t);
out.print("");
String l = Transcription.popElement(allReadings, "lem");
if (l != null) {
out.print("
- ");
out.print(l);
out.print("
");
}
// out.print("
");
String r = Transcription.popElement(allReadings, "rdg");
while (r != null) {
String nextR = Transcription.popElement(allReadings, "rdg");
out.print("- ");
out.print(r);
out.print("
");
r = nextR;
}
// out.print("
");
out.print("
\n");
t = nextT;
}
out.print("
");
return;
}
else {
if ("html".equals(params.format)) {
if ("verse".equals(params.summarizeFullyLacWits)) {
%>
Fully non-extant witnesses:
<%
if (fullyLacWits != null) {
boolean first = true;
for (SegmentReadingWitness srw : fullyLacWits) {
if (!first) out.print(params.witnessDelimiter);
out.print(srw.getWitnessText().replaceAll("_", " "));
first = false;
}
}
%>
<%
}
%>
<%
}
for (Segment s : segments) {
// be sure to do these for the other output formats!!!
if (params.cleanHands) s.cleanHands();
if (params.collapseA) s.designateDotDotDot();
if (params.collapseByz) s.designateByz();
String cd = s.getContextDescription().replaceAll("[^0-9\\-]", "");
String words[] = cd.split("-");
String firstLabel = "";
boolean firstReading = true;
int readNo = 0;
SegmentReading srs[] = s.getSegmentReadings();
Arrays.sort(srs);
int nonLacCount = 0;
int nonLacNonSubCount = 0;
for (SegmentReading sr : srs) {
if (!"zz".equals(sr.getReadingName()) && (!"zu".equals(sr.getReadingName())) && (!"zw".equals(sr.getReadingName())) && (!"zv".equals(sr.getReadingName()))) {
++nonLacCount;
++nonLacNonSubCount;
List subLabels = sr.getSubLabels();
nonLacCount += subLabels.size();
}
}
try {
int start = Integer.parseInt(words[0]);
words[0] = Integer.toString(Integer.parseInt(words[0])/2-1);
if (words.length > 1) words[1] = Integer.toString(Integer.parseInt(words[1])/2-1);
if (start % 2 != 0) {
if (words.length < 2) {
words = new String[] { words[0], words[0] };
words[1] = Integer.toString(Integer.parseInt(words[1])+1);
}
}
if (srs.length > 0) firstLabel = srs[0].getReadingName();
}
catch (Exception e) {}
String projectStatus = "";
// we need to check if we're the right projects status, but for now, just show any project status
if (params.includeProjectStatus != null) {
String comment = s.getStatusComment();
String statusText = "Unassigned";
switch (s.getStatus()) {
case 0: statusText = "Assigned"; break;
case 1: statusText = "Reviewed"; break;
case 2: statusText = "Of Interested"; break;
case 4: statusText = "Problematic"; break;
case 3: statusText = "Complete"; break;
}
if (comment != null && comment.trim().length() > 0) {
comment = statusText + " \n" + comment;
}
else comment = statusText;
projectStatus = "title=\""+comment+"\" data-segID=\""+s.getSegmentID()+"\" data-projectStatus=\""+s.getStatus()+"\" data-statusComment=\""+HTTPUtils.canonize(s.getStatusComment())+"\"";
}
// we want to include the segment always if we're HTML because we just display:none; on them and have the data if we want to extend the UI with hover help
boolean showSegment = (nonLacCount != 1 || params.style == null || "html".equals(params.format) || !params.style.startsWith("Minimal"));
//params.getLogger().info("segment: " + s.getContextDescription() + "nonLacCount: " + nonLacCount + "; nonLacNonSubCount: " + nonLacNonSubCount);
if ("Minimal".equals(params.style) && "icml".equals(params.format)) {
if (nonLacNonSubCount == 1) showSegment = false;
}
if (showSegment) {
if ("html".equals(params.format)) {
%>
id="segment_<%=words[0]+(words.length > 1?"-"+words[1]:"")%>" <%=projectStatus %> data-nonLacCount="<%=nonLacCount%>" data-label="<%=firstLabel%>" data-wordsegs="<%=cd%>"
class="appSegment segmentHead baseTextWord_<%=words[0]+(words.length > 1?"-"+words[1]:"")%>">
<%=s.getContextDescription()%>
|
<%
}
else if ("icml".equals(params.format)) {
%>
11
Helvetica
<%=s.getContextDescription()%>
<%
}
for (SegmentReading sr : srs) {
List subLabels = sr.getSubLabels();
// add our base reading (no sublabel)
subLabels.add(0, "");
for (String subLabel : subLabels) {
String displayLabel = sr.getReadingDisplay()+subLabel;
if ("Minimal".equals(params.style) && "icml".equals(params.format)) {
if ("a".equals(sr.getReadingName())
|| "zz".equals(sr.getReadingName())
|| "zv".equals(sr.getReadingName())
|| "zu".equals(sr.getReadingName())
|| "zw".equals(sr.getReadingName())
) {
continue;
}
}
++readNo;
// TODO: do we need this: if (sr.getWitnessesText(false, subLabel, params.witnessDelimiter).trim().length() == 0) continue;
//params.getLogger().info("segmentReadingsCount ("+cd+"): " + srs.length + "; nonLacCount: " + nonLacCount + "; processing reading: " + sr.getReadingName() + "; subLabel: " + subLabel);
if (!firstReading) {
if ("html".equals(params.format)) {
%>
1?"-"+words[1]:"")%>"
data-label="<%=sr.getReadingName()%>"
<%
if (subLabel != null && subLabel.trim().length() > 0) {
%>
data-sublabel="<%=subLabel%>"
<%
}
%>
data-nonLacCount="<%=nonLacCount%>"
>
|
<%
}
}
else out.println("");
String reading = sr.getReading(subLabel).trim();
//params.getLogger().info("sr("+subLabel+"): " + sr.toString());
String subtext = subLabel.length() > 0 ? "" : sr.getReadingSubtext();
String supportingReading = sr.getSupportingReading();
if (supportingReading != null) { supportingReading = supportingReading.trim(); if (supportingReading.length() == 0) supportingReading = null; }
if ("html".equals(params.format)) {
%>
<%=displayLabel%> |
<%
} else if ("icml".equals(params.format)) {
%>
11
<%=("zw".equals(sr.getReadingName()) ? "Times New Roman" : "Helvetica") %>
<%=((!firstReading) ? " ":"")+displayLabel%>
<%
}
if ("html".equals(params.format)) {
%>
"
data-segmentid="<%=s.getSegmentID()%>"
data-label="<%=sr.getReadingName()%>"
data-wordsegs="<%=cd%>"
data-segmentreadingid="<%=sr.getSegmentReadingID()%>"
<%
if (subLabel != null && subLabel.trim().length() > 0) {
%>
data-sublabel="<%=subLabel%>"
<%
}
%>
><%= reading %>
<%
} else if ("icml".equals(params.format)) {
%>
" AppliedLanguage="$ID/Greek">
11
<%=("zw".equals(sr.getReadingName()) ? "Helvetica":"SymbolGreekTU")%>
<%= reading %>
<%
}
if ("html".equals(params.format)) {
%>
<%=subtext != null && subtext.length() > 0 ? " " + subtext.trim() : ""%>
<%=reading.length() > 0 ? " " : ""%>
<%
} else if ("icml".equals(params.format) && (subtext != null && subtext.length() > 0)) {
%>
11
Helvetica
<%=subtext.trim()%>
<%
}
//params.getLogger().info("segmentReadingWitnesses: " + sr.getWitnesses());
String primaryWitnesses = sr.getWitnessesText("html".equals(params.format), subLabel, params.witnessDelimiter, params.groupAugmentedWitnesses && params.augmentGroupID != null ? params.augmentGroupID * -1 : null, true, (!"false".equals(params.summarizeFullyLacWits)));
String extEvidenceOut = "";
if ("html".equals(params.format)) {
extEvidenceOut += " 0) {
extEvidenceOut += " data-sublabel=\""+subLabel + "\"";
}
extEvidenceOut += " data-wordsegs=\""+cd+"\" class=\"extEvidence\" id=\"extEv"+readNo+"\"";
extEvidenceOut += ">";
}
if (params.includeCitations) {
String url = "http://intf.uni-muenster.de/apparat/webservice/api.php";
url += "?book=" + ((VerseKey)verses.getElement(0)).getBook();
url += "&chapter=" + ((VerseKey)verses.getElement(0)).getChapter();
url += "&verse=" + ((VerseKey)verses.getElement(0)).getVerse();
url += "&segment="+ s.getContextDescription();
url += "&labez="+ sr.getReadingName();
if (subLabel != null && subLabel.trim().length() > 0) {
url += "&labezsuf="+ subLabel;
}
String t = "";
try {
String fathersResponse = HTTPUtils.postURL(url, null).toString();
//params.getLogger().info("url: " + url + "; response: " + fathersResponse);
if (fathersResponse.indexOf("author") > -1) {
XMLBlock f = XMLBlock.createXMLBlock(fathersResponse);
XMLBlock address = f.getBlock("address");
if (address != null) {
int extOffset = primaryWitnesses.indexOf(Apparatus.SegmentReading.afterSecondaryText);
String beforeExtEvidence = extOffset > 0 ? primaryWitnesses.substring(0, extOffset) : "";
beforeExtEvidence = beforeExtEvidence.replace(Apparatus.SegmentReading.afterPrimaryText, "");
//params.getLogger().info("S: " + s.getContextDescription() + "; BEFORE EXTERNAL EVIDENCE: *" + beforeExtEvidence + "*; witnessDelimiter: *" + params.witnessDelimiter + "*");
boolean needPrecedingComma = (!beforeExtEvidence.endsWith(params.witnessDelimiter) && beforeExtEvidence.length() > 0);
for (XMLDataElement e : address.getElements("author")) {
if (t.length() > 0 || needPrecedingComma) t += params.witnessDelimiter;
if ("html".equals(params.format)) {
t += "";
}
t += e.getText();
if ("html".equals(params.format)) {
t += "";
}
}
if (!needPrecedingComma) t += params.witnessDelimiter;
}
}
}
catch(Exception e) {}
extEvidenceOut += t;
}
if ("html".equals(params.format)) {
extEvidenceOut += "";
}
//params.getLogger().info("primaryWitnesses: " + primaryWitnesses + "; extEvidenceOut: " + extEvidenceOut);
primaryWitnesses = primaryWitnesses.replaceAll(Apparatus.SegmentReading.afterSecondaryText, extEvidenceOut);
//params.getLogger().info("primaryWitnesses after replace: " + primaryWitnesses);
// group augmented witnesses
String augmentedWitnesses = "";
String underMentionedWitnesses = "";
if (sr.underMentions != null) underMentionedWitnesses = sr.getWitnessesText("a", sr.underMentions, "html".equals(params.format), subLabel, params.witnessDelimiter, params.augmentGroupID, false, (!"false".equals(params.summarizeFullyLacWits)));
if (params.groupAugmentedWitnesses && params.augmentGroupID != null) {
augmentedWitnesses = sr.getWitnessesText("html".equals(params.format), subLabel, params.witnessDelimiter, params.augmentGroupID, false, (!"false".equals(params.summarizeFullyLacWits)));
if (primaryWitnesses.length() > 0 && augmentedWitnesses.length() > 0) {
String aw = augmentedWitnesses;
augmentedWitnesses = "";
if ("html".equals(params.format)) {
augmentedWitnesses += "";
}
augmentedWitnesses += params.witnessDelimiter;
if ("html".equals(params.format)) {
augmentedWitnesses += "";
}
augmentedWitnesses += aw;
}
}
if ("html".equals(params.format)) {
%>
<%=primaryWitnesses%>
<% if (supportingReading != null) { %>
<%=supportingReading%>
<% }
if (params.groupAugmentedWitnesses && params.augmentGroupID != null) {
%>
<%=augmentedWitnesses%>
<% }
if (underMentionedWitnesses.length() > 0) {
%>
<%=underMentionedWitnesses%>
<% } %>
|
<%
if (params.includeProjectStatus != null) {
%>
" : "> "%> |
<%
}
%>
<%
}
else if ("icml".equals(params.format)) {
if (!"Minimal".equals(params.style)) {
String allWitnesses = primaryWitnesses+augmentedWitnesses;
allWitnesses = allWitnesses.replaceAll("]*>", "");
allWitnesses = allWitnesses.replaceAll("", "");
allWitnesses = allWitnesses.replaceAll("[^>]*
", "");
List witnessSegments = new ArrayList();
boolean superscript = false;
int lastStart = 0;
%>
11
Helvetica
<%
for (int i = 0; i < allWitnesses.length(); ++i) {
if (superscripts.containsKey(allWitnesses.charAt(i)) && superscript == false) {
String witText = allWitnesses.substring(lastStart, i);
try {
witText = witText.replaceAll("([^:])(L|K|S|CPA):", "11Helvetica$1$2:11Helvetica");
witText = witText.replaceAll("^(L|K|S|CPA):", "11Helvetica$1:11Helvetica");
witText = witText.replaceAll("Byz", "11HelveticaByz11Helvetica");
}
catch (Exception e) { e.printStackTrace(); }
%>
11
Helvetica
<%=witText%>
<%
superscript = true;
lastStart = i;
}
else if (!superscripts.containsKey(allWitnesses.charAt(i)) && superscript == true) {
String superUnicodeToNormal = "";
for (Character c : allWitnesses.substring(lastStart, i).toCharArray()) {
superUnicodeToNormal += superscripts.get(c);
}
%>
11
Helvetica
<%=superUnicodeToNormal%>
<%
lastStart = i;
superscript = false;
}
}
String witText = allWitnesses.substring(lastStart);
try {
witText = witText.replaceAll("([^:])(L|K|S|CPA):", "11Helvetica$1$2:11Helvetica");
witText = witText.replaceAll("^(L|K|S|CPA):", "11Helvetica$1:11Helvetica");
witText = witText.replaceAll("Byz", "11HelveticaByz11Helvetica");
}
catch (Exception e) { e.printStackTrace(); }
%>
11
Helvetica
<%=witText%>
<%
}
%>
11
Helvetica
<%
}
firstReading = false;
}
}
if ("icml".equals(params.format)) {
}
}
}
//params.getLogger().info("processing verse: " + verses.getText() + "; segments to html returned;");
if ("html".equals(params.format)) {
%>
<%
}
if (params.includeBaseline != null && baselineReading != null) { %>
<%
}
if ("html".equals(params.format)) {
%>