Ejemplo n.º 1
0
function drawMenu($appurl, $phpurl, $doc, $section, $menuOrder)
{
    /* function drawMenu
    		void function
    
    		PURPOSE: draw the sidebar menu for the finding aids
    		PARAMS:
    			phpurl = the URL of the PHP script we're acting on
    			appurl = the URL of the env-sensitive path to the eXibit db
    			doc = the LDPD # of the finding aid
    			section = the section being queried (to provide context-sensitive nav)
    
    		ASSUMPTIONS:
    			main method produced viable, non-null variables
    
    	*/
    $final = "";
    foreach (array_keys($menuOrder) as $k) {
        $final .= '<div class="item">';
        /*
        			if ($k == $section)
        				$final .= "<span style=color:#336699;>&raquo;&nbsp;</span>";
        		
        			else
        				$final .=  "&nbsp;&nbsp;&nbsp;";
        */
        //$final .=  '<a href="' . $phpurl . $doc . '/' . '">';
        if ($section == "dsc") {
            $final .= '<a href="' . $phpurl . $doc . '/summary#' . $k . '">';
        } else {
            $final .= '<a href="#' . $k . '">';
        }
        $final .= $menuOrder[$k] . '</a>';
        if ($k == "using_collection") {
            $accessRestrict = getSection($appurl, $phpurl, $doc, $section, $menuOrder, "access");
            $count = isRestricted($accessRestrict);
            if ($count > 0) {
                $final .= "<br /><span class=\"highlight\"><a href=\"" . $phpurl . $doc . "/summary#using_collection\" class=\"highlight\" style=\"text-decoration:none;font-size:10px;font-weight:normal;\">Note: some material may be restricted or offsite</a></span>";
            }
        }
        $final .= "</div>";
    }
    // end FOREACH $menuOrder
    /*
    $accessRestrict = getSection($appurl, $phpurl, $doc, $section, $menuOrder, "access");
    $count = isRestricted($accessRestrict);
    if ($count > 0) 
    $final .= "<div class=\"highlight\"><a href=\"" . $phpurl . $doc . "/summary#using_collection\" class=\"highlight\" style=\"text-decoration:none;\">!</a></div>";
    */
    return $final;
}
Ejemplo n.º 2
0
function readXML($reader, $section, $validHTML, $openTag, $hrefTag, $docroot)
{
    global $phpurl;
    global $doc;
    $level = "";
    $count = 0;
    $subjects = array();
    $genreforms = array();
    $addlcreators = array();
    $current = $currentA = "";
    $change = false;
    $series = 0;
    $subseries = 0;
    $sLevel = 0;
    $render = "";
    while ($reader->read()) {
        //print "LEVEL: $level<br /><br/>";
        $tagName = "";
        $header = "";
        if ($reader->name != "#text") {
            $current = $reader->name;
        }
        if ($reader->name == "#comment") {
            continue;
        }
        if ($current == "publicationstmt") {
            $reader->next("processinfo");
        }
        if ($reader->name == "accessrestrict" && $reader->nodeType == XMLReader::ELEMENT || $reader->name == "userestrict" && $reader->nodeType == XMLReader::ELEMENT) {
            $restrict = true;
        } else {
            if ($reader->name == "accessrestrict" && $reader->nodeType == XMLReader::END_ELEMENT || $reader->name == "userestrict" && $reader->nodeType == XMLReader::END_ELEMENT) {
                $restrict = false;
            }
        }
        if ($reader->name == "author" || $reader->name == "publicationstmt") {
            if ($reader->nodeType == XMLReader::ELEMENT) {
                print "<p>";
            } else {
                print "</p>";
            }
        }
        // if author
        if ($reader->getAttribute("render") != "" && !array_key_exists($reader->name, $validHTML)) {
            $render = $reader->getAttribute("render");
        }
        if ($section == "dsc_sc") {
            $cur = "";
            if ($reader->nodeType == XMLReader::ELEMENT) {
                $cur = "start" . $reader->name;
            } else {
                if ($reader->nodeType == XMLReader::END_ELEMENT) {
                    $cur = "end" . $reader->name;
                }
            }
            //echo $cur . "<br>";
            if ($reader->name == "series" || $reader->name == "child") {
                //echo $doc . " = doc<br />";
                if ($reader->nodeType == XMLReader::ELEMENT) {
                    if ($reader->getAttribute("level1") != "") {
                        echo '<a href="' . $phpurl . $doc . '/dsc/';
                        echo $reader->getAttribute("level1");
                        if ($reader->getAttribute("level2") != "") {
                            echo '#subseries' . $reader->getAttribute("level2");
                        }
                        echo '">';
                    }
                }
            }
            //if ($reader->name == "unittitle") {
            if ($cur == "endunittitle") {
                echo '</a>';
            }
        }
        // DSC_SC
        if ($reader->name != "#text") {
            $current = $reader->name;
            //echo "current = " . $current . "<br>";
            if ($reader->getAttribute("encodinganalog")) {
                $currentA = $reader->getAttribute("encodinganalog");
            }
            // if there is markup that we should print out, do so (only if in $validHTML array)
            if (array_key_exists($reader->name, $validHTML) && $reader->name != 'unittitle' && $reader->name != 'unitdate') {
                if ($reader->nodeType == XMLReader::ELEMENT) {
                    if ($reader->name != "") {
                        if ($section == "dsc_sc" && $reader->name == "series") {
                            print "<" . $validHTML['dsc_series'] . '>' . "\n";
                        } else {
                            if ($section != "subjects") {
                                print "<" . $validHTML[$reader->name] . '>' . "\n";
                            }
                        }
                        // used for subjects -- don't delete
                        array_push($openTag, $reader->name);
                    } else {
                        array_push($openTag, $reader->name);
                    }
                } else {
                    if ($reader->nodeType == XMLReader::END_ELEMENT) {
                        if ($reader->name != "") {
                            if ($section == "dsc_sc" && $reader->name == "series") {
                                print "</" . $validHTML['dsc_series'] . '>' . "\n";
                            } else {
                                if ($section != "subjects") {
                                    print "</" . $validHTML[$reader->name] . '>' . "\n";
                                }
                            }
                            array_pop($openTag);
                        }
                    }
                }
            }
            // end IF reader->name in validHTML array
            if ($reader->name == "list" || $reader->name == "change") {
                if ($reader->name == "change") {
                    $change = true;
                }
                if ($reader->nodeType == XMLReader::ELEMENT) {
                    $sLevel++;
                    echo "<ul";
                    if ($reader->hasAttributes && $reader->getAttribute("type")) {
                        echo ' class="' . $reader->getAttribute("type") . '"';
                    }
                    echo ">";
                } else {
                    if ($reader->nodeType == XMLReader::END_ELEMENT) {
                        echo "</ul>\n";
                        $sLevel--;
                        $subseries = 0;
                        if ($reader->name == "change") {
                            $change = false;
                        }
                    }
                }
            }
            // if LIST
            if ($reader->name == "item") {
                if (!$change) {
                    if ($reader->nodeType == XMLReader::ELEMENT) {
                        echo "<li>\n";
                        if ($sLevel > 1) {
                            $subseries++;
                            //echo '<a href="dsc/' . $series . '/' . $subseries . '">';
                            echo '<a href="' . $phpurl . $doc . '/dsc/' . $series . '#subseries' . $subseries . '">';
                        } else {
                            $series++;
                            //echo '<a href="dsc/' . $series . '">';
                            echo '<a href="' . $phpurl . $doc . '/dsc/' . $series . '">';
                        }
                    } else {
                        if ($reader->nodeType == XMLReader::END_ELEMENT) {
                            echo "</a></li>\n";
                        }
                    }
                }
            }
            if ($reader->hasAttributes) {
                if ($reader->name == "extref" || $reader->name == "dao") {
                    $href = $reader->getAttribute("xlink:href");
                    // TODO -- IS THIS NECESSARY?
                    if ($hrefTag) {
                        print "</a>\n";
                    } else {
                        echo '<a href="' . $href . '">';
                    }
                    $hrefTag = !$hrefTag;
                }
                // if extref
                if ($reader->getAttribute("render") != "" || $reader->getAttribute("altrender") != "") {
                    if ($reader->getAttribute("render") != "") {
                        $render = $reader->getAttribute("render");
                    } else {
                        if ($reader->getAttribute("altrender") != "") {
                            $render = $reader->getAttribute("altrender");
                        }
                    }
                    if ($reader->nodeType == XMLReader::ELEMENT) {
                        echo "<span class=\"{$render}\">";
                    } else {
                        if ($reader->nodeType == XMLReader::END_ELEMENT) {
                            echo "</span>";
                            $render = "";
                        }
                    }
                }
                // if render
            }
            // if HAS ATTRIBUTES
            $nodeName = $reader->name;
            //"";
            if ($reader->name == "unittitle" || $reader->name == "unitdate" || $reader->name == "physdesc") {
                $nodeName = $reader->name;
                $class = "";
                if ($reader->nodeType == XMLReader::ELEMENT) {
                    $nodeName = "start" . $nodeName;
                } else {
                    if ($reader->nodeType == XMLReader::END_ELEMENT) {
                        $nodeName = "end" . $nodeName;
                    }
                }
                //echo $validHTML[$reader->name] . " " . $class . ">\n";
            }
            // IF unittitle or unitdate or physdesc
        }
        // if reader->name && not text && not comment
        if ($reader->hasValue && $section != "subjects") {
            if ($nodeName == "startunittitle" && $section != "dsc_sc") {
                echo getElement($level, true);
            }
            if ($nodeName == "startphysdesc" && $section != "dsc_sc") {
                echo getElement($level, true);
            }
            $osMatches = isRestricted($reader->value);
            if ($osMatches > 0) {
                echo "<img src=\"" . $docroot . "/images/alert.gif\" border=0 style=\"vertical-align:text-bottom\"><span class=\"highlight\">&nbsp;";
            }
            //echo "<span class='debug1'></span>";
            echo $reader->value;
            if ($osMatches > 0) {
                echo "</span><br /><br /><span style=\"color:#369\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><a href=\"http://library.columbia.edu/indiv/rbml/usingcollections/offsite_materials.html\" target=\"blank\" style=\"text-decoration:none;\"><img src=\"" . $docroot . "/images/offsite.png\" alt=\"offsite request\" style=\"border:0px;vertical-align:middle\" />More information and link to off-site request form</a>";
            }
            if ($nodeName == "endunittitle" && $section != "dsc_sc") {
                echo getElement($level, false);
            }
        } else {
            if ($reader->hasValue && $section == "subjects") {
                $tag = "";
                if (!in_array("head", $openTag)) {
                    $pattern = "/\\w/";
                    preg_match($pattern, $reader->value, $matches);
                    if (count($matches) > 0) {
                        $tag .= $reader->value;
                    }
                }
                // if open tag
                if ($current == "genreform") {
                    array_push($genreforms, $tag);
                } else {
                    if (substr($currentA, 0, 1) == "6") {
                        array_push($subjects, $tag);
                    } else {
                        if (substr($currentA, 0, 1) == "7") {
                            array_push($addlcreators, $tag);
                        }
                    }
                }
            }
        }
        // else if section is subjects
    }
    // end WHILE
    if ($section == "subjects") {
        //$clioStartS = "http://www1.columbia.edu/cgi-bin/cul/voyagersearch?Search_Arg=";
        //$clioFinishS = "&Search_Code=SUBJ_&CNT=50DB%3Dlocal&BROWSE=1&HC=2&SID=1";
        $clioStartS = "http://www.columbia.edu/cgi-bin/cul/cliosearch?search=";
        $clioFinishS = "&code=SUBJ";
        //$clioStartC = "http://www1.columbia.edu/cgi-bin/cul/voyagersearch?Search_Arg=";
        //$clioFinishC = "&Search_Code=NAME_&CNT=50DB%3Dlocal&BROWSE=1&HC=2&SID=1";
        $clioStartC = "http://www.columbia.edu/cgi-bin/cul/cliosearch?search=";
        $clioFinishC = "&code=NAME";
        // unused?
        $clioStartG = "http://clio.cul.columbia.edu/cgi-bin/Pwebrecon.cgi?Search_Arg=655A+";
        $clioFinishG = "&Search_Code=CMD&CNT=50DB%3Dlocal&BROWSE=1&HC=2&SID=1";
        $tableStart = '<table class="subjectTable"><tr><th class="firstCell" style="vertical-align:middle">Heading</th><th>CUL Archives:<br />Portal</th><th>CUL Collections:<br />CLIO</th><th>Nat\'l / Int\'l Archives:<br />ArchiveGRID</th></tr>';
        $tableFinish = '</table>';
        //$portalStart = 'http://app.cul.columbia.edu:8080/findingaids/results.html?';
        $portalStart = 'http://archivesportal.cul.columbia.edu/results.php?';
        //$portalFinish = 'origination%20asc,sort_title%20asc&wt=json&indent=true&facet=true&facet.field=subject&facet.field=repository_code&facet.field=persname&fl.audience=external&facet.mincount=1&hl=true&hl.fl=all_text&hl.fragsize=50&hl.snippets=5&hl.formatter=simple&hl.simple.pre=%3Cspan%20class=highlight%3E&hl.simple.post=%3C/span%3E&rows=20';
        $portalFinish = '&repository_code=&level=&sort=score+asc&rows=20&unitid_t=&operator=AND&advanced=on';
        $archiveGridSearch = 'http://archivegrid.org/web/jsp/s.jsp?q=';
        $portalText = 'Portal';
        $archiveText = 'ArchiveGRID';
        $clioText = 'CLIO';
        print "<p class=\"caption11px\">The subject headings listed below are found in this collection.  Links below allow searches at Columbia University through the <a href=\"http://www.columbia.edu/cgi-bin/cul/resolve?lweb0106\" target=\"_blank\">Archival Collections Portal</a> and through <a href=\"http://www.columbia.edu/cgi-bin/cul/resolve?clio\" target=\"_blank\">CLIO</a>, the catalog for Columbia University Libraries, as well as <a href=\"http://www.archivegrid.org\" target=\"_blank\">ArchiveGRID</a>, a catalog that allows users to search the holdings of multiple research libraries and archives.</p>";
        print "<p class=\"caption11px\"><strong>All links open new windows.</strong></p>\n";
        if (count($addlcreators) > 0) {
            echo "<h3>Additional Creators</h3>";
            sort($addlcreators);
            echo $tableStart;
        }
        foreach ($addlcreators as $creator) {
            if ($creator != "") {
                //echo '<tr><td>' . $creator . '</td><td>Portal</td><td>' . '<a href="' . $clioStartC . urlencode($creator) . $clioFinishC . '" target="_blank">CLIO</a><td>ArchiveGRID</td></tr>' . "\n";
                echo '<tr><td class="firstCell">' . $creator . '</td><td><a href="' . $portalStart . 'component_text=%22' . urlencode($creator) . '%22' . $portalFinish . '" target="_blank">' . $portalText . '</a></td><td>' . '<a href="' . $clioStartC . urlencode($creator) . $clioFinishC . '" target="_blank">' . $clioText . '</a></td><td><a href="' . $archiveGridSearch . '%22' . str_replace("?", "", utf8_decode($creator)) . '%22' . '" target="_blank">' . $archiveText . '</td></tr>' . "\n";
            }
            //$tagE = str_replace("?","",utf8_decode($tag));
        }
        if (count($addlcreators) > 0) {
            echo $tableFinish;
        }
        if (count($genreforms) > 0) {
            echo "<h3>Genre/Form</h3>";
            sort($genreforms);
            echo $tableStart;
        }
        foreach ($genreforms as $genre) {
            //echo $genre . "<br />";
            if ($genre != "") {
                //echo '<tr><td>' . $genre . '</td><td>Portal</td><td>' . '<a href="' . $clioStartG . "%22" . urlencode($genre) . "%22" . $clioFinishG . '" target="_blank">'. $genre . '</a></td><td>ArchiveGRID</td></tr>' . "\n";
                echo '<tr><td class="firstCell">' . $genre . '</td><td><a href="' . $portalStart . 'component_text=%22' . urlencode($genre) . '%22' . $portalFinish . '" target="_blank">' . $portalText . '</a></td><td>' . '<a href="' . $clioStartS . urlencode($genre) . $clioFinishS . '" target="_blank">' . $clioText . '</a></td><td><a href="' . $archiveGridSearch . '%22' . str_replace("?", "", utf8_decode($genre)) . '%22' . '" target="_blank">' . $archiveText . '</td></tr>' . "\n";
            }
        }
        if (count($genreforms) > 0) {
            echo $tableFinish;
        }
        if (count($subjects) > 0) {
            echo "<h3>Subjects</h3>";
            sort($subjects);
            echo $tableStart;
        }
        foreach ($subjects as $subject) {
            //echo $subject . "<br />";
            if ($subject != "") {
                echo '<tr><td class="firstCell">' . $subject . '</td><td><a href="' . $portalStart . 'component_text=%22' . urlencode($subject) . '%22' . $portalFinish . '" target="_blank">' . $portalText . '</a></td><td>' . '<a href="' . $clioStartS . urlencode($subject) . $clioFinishS . '" target="_blank">' . $clioText . '</a></td><td><a href="' . $archiveGridSearch . '%22' . str_replace("?", "", utf8_decode($subject)) . '%22' . '" target="_blank">' . $archiveText . '</td></tr>' . "\n";
            }
        }
        if (count($subjects) > 0) {
            echo $tableFinish;
        }
    }
}
Ejemplo n.º 3
0
function readXML($reader, $section, $validHTML, $openTag, $hrefTag, $docroot)
{
    global $phpurl;
    global $doc;
    global $repository;
    $level = "";
    $count = 0;
    $subjects = array();
    $genreforms = array();
    $addlcreators = array();
    $current = $currentA = "";
    $change = false;
    $series = 0;
    $subseries = 0;
    $sLevel = 0;
    $render = "";
    $sectionPrinted = false;
    while ($reader->read()) {
        //print "LEVEL: $level<br /><br/>";
        $tagName = "";
        $header = "";
        if ($reader->name != "#text") {
            $current = $reader->name;
        }
        if ($reader->name == "#comment") {
            continue;
        }
        if ($current == "publicationstmt") {
            $reader->next("processinfo");
        }
        if ($reader->name == "accessrestrict" && $reader->nodeType == XMLReader::ELEMENT || $reader->name == "userestrict" && $reader->nodeType == XMLReader::ELEMENT) {
            $restrict = true;
        } else {
            if ($reader->name == "accessrestrict" && $reader->nodeType == XMLReader::END_ELEMENT || $reader->name == "userestrict" && $reader->nodeType == XMLReader::END_ELEMENT) {
                $restrict = false;
            }
        }
        if ($reader->name == "author" || $reader->name == "publicationstmt") {
            if ($reader->nodeType == XMLReader::ELEMENT) {
                print "<p>";
            } else {
                print "</p>";
            }
        }
        // if author
        if ($reader->getAttribute("render") != "" && !array_key_exists($reader->name, $validHTML)) {
            $render = $reader->getAttribute("render");
        }
        if ($section == "dsc_sc") {
            $cur = "";
            if ($reader->nodeType == XMLReader::ELEMENT) {
                $cur = "start" . $reader->name;
            } else {
                if ($reader->nodeType == XMLReader::END_ELEMENT) {
                    $cur = "end" . $reader->name;
                }
            }
            //echo $cur . "<br>";
            if ($reader->name == "series" || $reader->name == "child") {
                if ($reader->nodeType == XMLReader::ELEMENT) {
                    if ($reader->getAttribute("level1") != "") {
                        echo '<a href="' . $phpurl . $doc . '/dsc/';
                        echo $reader->getAttribute("level1");
                        if ($reader->getAttribute("level2") != "") {
                            echo '#subseries' . $reader->getAttribute("level2");
                        }
                        echo '">';
                    }
                }
            }
            //if ($reader->name == "unittitle") {
            if ($cur == "endunittitle") {
                echo '</a>';
            }
        }
        // DSC_SC
        if ($reader->name != "#text") {
            $current = $reader->name;
            if ($reader->getAttribute("encodinganalog")) {
                $currentA = $reader->getAttribute("encodinganalog");
            }
            // if there is markup that we should print out, do so (only if in $validHTML array)
            if (array_key_exists($reader->name, $validHTML) && $reader->name != 'unittitle' && $reader->name != 'unitdate') {
                if ($reader->nodeType == XMLReader::ELEMENT) {
                    if ($reader->name != "") {
                        if ($section == "dsc_sc" && $reader->name == "series") {
                            print "<" . $validHTML['dsc_series'] . '>' . "\n";
                        } else {
                            if ($section != "subjects") {
                                print "<" . $validHTML[$reader->name] . '>' . "\n";
                            }
                        }
                        // used for subjects -- don't delete
                        array_push($openTag, $reader->name);
                    } else {
                        array_push($openTag, $reader->name);
                    }
                } else {
                    if ($reader->nodeType == XMLReader::END_ELEMENT) {
                        if ($reader->name != "") {
                            if ($section == "dsc_sc" && $reader->name == "series") {
                                print "</" . $validHTML['dsc_series'] . '>' . "\n";
                            } else {
                                if ($section != "subjects") {
                                    print "</" . $validHTML[$reader->name] . '>' . "\n";
                                }
                            }
                            array_pop($openTag);
                        }
                    }
                }
            }
            // end IF reader->name in validHTML array
            if ($reader->name == "list" || $reader->name == "change") {
                if ($reader->name == "change") {
                    $change = true;
                }
                if ($reader->nodeType == XMLReader::ELEMENT) {
                    $sLevel++;
                    echo "<ul";
                    if ($reader->hasAttributes && $reader->getAttribute("type")) {
                        echo ' class="' . $reader->getAttribute("type") . '"';
                    }
                    echo ">";
                } else {
                    if ($reader->nodeType == XMLReader::END_ELEMENT) {
                        echo "</ul>\n";
                        $sLevel--;
                        $subseries = 0;
                        if ($reader->name == "change") {
                            $change = false;
                        }
                    }
                }
            }
            // if LIST
            if ($reader->name == "item") {
                if (!$change) {
                    if ($section == "arrangement") {
                        if ($reader->nodeType == XMLReader::ELEMENT) {
                            echo "<li>\n";
                            if ($sLevel > 1 && $current == "arrangement") {
                                $subseries++;
                                //echo '<a href="dsc/' . $series . '/' . $subseries . '">';
                                //echo '<a href="dsc/' . $series . '#subseries' . $subseries . '">';
                                echo '<a href="' . $docroot . '/ead/' . $repository . '/' . $doc . '/dsc/' . $series . '#subseries' . $subseries . '">';
                            } else {
                                $series++;
                                //echo '<a href="dsc/' . $series . '">';
                                echo '<a href="' . $docroot . '/ead/' . $repository . '/' . $doc . '/dsc/' . $series . '">';
                            }
                        } else {
                            if ($reader->nodeType == XMLReader::END_ELEMENT) {
                                echo "</a></li>\n";
                            }
                        }
                    } else {
                        if ($reader->nodeType == XMLReader::ELEMENT) {
                            echo "<li>\n";
                        } else {
                            if ($reader->nodeType == XMLReader::END_ELEMENT) {
                                echo "</a></li>\n";
                            }
                        }
                    }
                    // not arrangement
                }
                // if !change
            }
            // if ITEM
            $currentLink = '';
            if ($reader->hasAttributes) {
                //echo "CURRENT = " . $current . "<br />";
                if ($reader->name == "extref" || $reader->name == "dao") {
                    $href = $reader->getAttribute("xlink:href");
                    if ($reader->nodeType == XMLReader::ELEMENT) {
                        $currentLink = ' <a href="' . $href . '">';
                    }
                    //$hrefTag = !$hrefTag;
                }
                // if extref
                if ($reader->getAttribute("render") != "" || $reader->getAttribute("altrender") != "") {
                    if ($reader->getAttribute("render") != "") {
                        $render = $reader->getAttribute("render");
                    } else {
                        if ($reader->getAttribute("altrender") != "") {
                            $render = $reader->getAttribute("altrender");
                        }
                    }
                    if ($reader->nodeType == XMLReader::ELEMENT) {
                        echo "<span class=\"{$render}\">";
                    } else {
                        if ($reader->nodeType == XMLReader::END_ELEMENT) {
                            echo "</span>";
                            $render = "";
                        }
                    }
                }
                // if render
            }
            // if HAS ATTRIBUTES
            $nodeName = $reader->name;
            //"";
            if ($reader->name == "unittitle" || $reader->name == "unitdate" || $reader->name == "physdesc") {
                $nodeName = $reader->name;
                $class = "";
                if ($reader->nodeType == XMLReader::ELEMENT) {
                    $nodeName = "start" . $nodeName;
                } else {
                    if ($reader->nodeType == XMLReader::END_ELEMENT) {
                        $nodeName = "end" . $nodeName;
                    }
                }
                //echo $validHTML[$reader->name] . " " . $class . ">\n";
            }
            // IF unittitle or unitdate or physdesc
        }
        // if reader->name && not text && not comment
        if ($reader->hasValue && $section != "subjects") {
            if ($nodeName == "startunittitle" && $section != "dsc_sc") {
                echo getElement($level, true);
            }
            if ($nodeName == "startphysdesc" && $section != "dsc_sc") {
                echo getElement($level, true);
            }
            $osMatches = isRestricted($reader->value);
            if ($osMatches > 0) {
                echo "<img src=\"" . $docroot . "/images/alert.gif\" border=0 style=\"vertical-align:text-bottom\"><span class=\"highlight\">&nbsp;";
            }
            if ($currentLink != "") {
                echo $currentLink . $reader->value . "</a>";
                $currentLink = '';
            } else {
                echo $reader->value;
            }
            if ($osMatches > 0) {
                echo "</span>";
            }
            if ($nodeName == "endunittitle" && $section != "dsc_sc") {
                echo getElement($level, false);
            }
        } else {
            if ($reader->hasValue && $section == "subjects") {
                //$clioStartS = "http://www1.columbia.edu/cgi-bin/cul/voyagersearch?Search_Arg=";
                //$clioFinishS = "&Search_Code=SUBJ_&CNT=50DB%3Dlocal&BROWSE=1&HC=2&SID=1";
                $clioStartS = "http://www.columbia.edu/cgi-bin/cul/cliosearch?search=";
                $clioFinishS = "&code=SUBJ";
                //$clioStartC = "http://www1.columbia.edu/cgi-bin/cul/voyagersearch?Search_Arg=";
                //$clioFinishC = "&Search_Code=NAME_&CNT=50DB%3Dlocal&BROWSE=1&HC=2&SID=1";
                $clioStartC = "http://www.columbia.edu/cgi-bin/cul/cliosearch?search=";
                $clioFinishC = "&code=NAME";
                // unused?
                $clioStartG = "http://clio.cul.columbia.edu/cgi-bin/Pwebrecon.cgi?Search_Arg=655A+";
                $clioFinishG = "&Search_Code=CMD&CNT=50DB%3Dlocal&BROWSE=1&HC=2&SID=1";
                $tableStart = '<table class="subjectTable"><tr><th class="firstCell" style="vertical-align:middle;">Heading</th><th>CUL Archives:<br />Portal</th><th>CUL Collections:<br />CLIO</th><th>Nat\'l / Int\'l Archives:<br />ArchiveGRID</th></tr>';
                $tableFinish = '</table>';
                $tableMStart = '<table class="subjectTable">';
                //$portalStart = 'http://app.cul.columbia.edu:8080/findingaids/results.html?';
                $portalStart = 'http://archivesportal.cul.columbia.edu/results.php?';
                //$portalFinish = 'origination%20asc,sort_title%20asc&wt=json&indent=true&facet=true&facet.field=subject&facet.field=repository_code&facet.field=persname&fl.audience=external&facet.mincount=1&hl=true&hl.fl=all_text&hl.fragsize=50&hl.snippets=5&hl.formatter=simple&hl.simple.pre=%3Cspan%20class=highlight%3E&hl.simple.post=%3C/span%3E&rows=20';
                $portalFinish = "&repository_code=&level=&sort=score+asc&rows=20&unitid_t=&operator=AND&advanced=on";
                $archiveGridSearch = 'http://archivegrid.org/web/jsp/s.jsp?q=';
                $portalText = 'Portal';
                $archiveText = 'ArchiveGRID';
                $clioText = 'CLIO';
                $tag = "";
                if (!$sectionPrinted) {
                    print "<p class=\"caption11px\">The names and terms listed below are represented in this collection.  Links below allow searches at Columbia University through the <a href=\"http://www.columbia.edu/cgi-bin/cul/resolve?lweb0106\" target=\"_blank\">Archival Collections Portal</a> and through <a href=\"http://www.columbia.edu/cgi-bin/cul/resolve?clio\" target=\"_blank\">CLIO</a>, the catalog for Columbia University Libraries, as well as <a href=\"http://www.archivegrid.org\" target=\"_blank\">ArchiveGRID</a>, a consortial/union catalog offered by OCLC that allows users to search the holdings of multiple archives and libraries.</p>";
                    print "<p class=\"caption11px\"><strong>All links open new windows.</strong></p>\n";
                    $sectionPrinted = true;
                }
                if (in_array("head", $openTag)) {
                    if ($reader->value != "Index Terms") {
                        echo "<h3>" . $reader->value . "</h3>\n";
                        echo $tableStart . $tableFinish;
                    }
                } else {
                    $pattern = "/\\w/";
                    preg_match($pattern, $reader->value, $matches);
                    if (count($matches) > 0) {
                        // ONLY IF THIS ISN'T BLANK
                        $tag = $reader->value;
                        $tagE = urlencode(str_replace("?", "", utf8_decode($tag)));
                        // debug
                        //echo $currentA . ":" . $tag . '<br />';
                        if ($current == "genreform") {
                            echo $tableMStart . '<tr><td class="firstCell">' . $tag . '</td><td><a href="' . $portalStart . 'component_text=%22' . $tagE . '%22' . $portalFinish . '" target="_blank">' . $portalText . '</a></td><td>' . '<a href="' . $clioStartS . urlencode($tag) . $clioFinishS . '" target="_blank">' . $clioText . '</a></td><td><a href="' . $archiveGridSearch . '%22' . $tagE . '%22' . '" target="_blank">' . $archiveText . '</td></tr>' . $tableFinish . "\n";
                        } else {
                            if (substr($currentA, 0, 1) == "6") {
                                echo $tableMStart . '<tr><td class="firstCell">' . $tag . '</td><td><a href="' . $portalStart . 'component_text=%22' . $tagE . '%22' . $portalFinish . '" target="_blank">' . $portalText . '</a></td><td>' . '<a href="' . $clioStartS . urlencode($tag) . $clioFinishS . '" target="_blank">' . $clioText . '</a></td><td><a href="' . $archiveGridSearch . '%22' . $tagE . '%22' . '" target="_blank">' . $archiveText . '</td></tr>' . $tableFinish . "\n";
                            } else {
                                if (substr($currentA, 0, 1) == "7") {
                                    echo $tableMStart . '<tr><td class="firstCell">' . $tag . '</td><td><a href="' . $portalStart . 'component_text=%22' . $tagE . '%22' . $portalFinish . '" target="_blank">' . $portalText . '</a></td><td>' . '<a href="' . $clioStartC . urlencode($tag) . $clioFinishC . '" target="_blank">' . $clioText . '</a></td><td><a href="' . $archiveGridSearch . '%22' . $tagE . '%22' . '" target="_blank">' . $archiveText . '</td></tr>' . $tableFinish . "\n";
                                    // DEBUG
                                    //echo '<pre>' .$tagE . mb_detect_encoding($tag) . '</pre>';
                                }
                            }
                        }
                    }
                    // if not a blank tag
                }
                // if !inarray
            }
        }
        // else if section is subjects
    }
    // end WHILE
    if ($section == "about_findaid") {
        $clioid = str_replace("ldpd_", '', $doc);
        echo '<p><strong>CLIO ID:</strong> ' . $clioid . ' <a href="http://www.columbia.edu/cgi-bin/cul/cliosearch?BIBID=' . $clioid . '" target="_blank" class="smaller">View CLIO record</a></p>';
    }
    if ($section == "using_collection") {
        echo '<h3>For Further Information</h3>';
        echo '<p>For more information about using the collections and conducting research in the Department of Drawings &amp; Archives, please see <a href="http://library.columbia.edu/indiv/avery/da/faq.html">our FAQ</a>.</p>';
    }
}