Commit 75eb009a authored by Brett Bieber's avatar Brett Bieber
Browse files

Rearrange dirs so we have branches tags and trunk.

parents
<?php
class UNL_Search
{
function __construct()
{
}
public static function removeRelativePaths($html, $base_url)
{
$needles = array('href="', 'src="', 'background="');
$new_base_url = $base_url;
$base_url_parts = parse_url($base_url);
if (substr($base_url,-1) != '/') {
if (isset($base_url_parts['path'])) {
$path = pathinfo($base_url_parts['path']);
} else {
$path = pathinfo('/');
}
$new_base_url = substr($new_base_url, 0, strlen($new_base_url)-strlen($path['basename']));
}
foreach ($needles as $needle) {
$new_txt = '';
while ($pos = strpos($html, $needle)) {
$pos += strlen($needle);
if (substr($html,$pos,7) != 'http://'
&& substr($html,$pos,8) != 'https://'
&& substr($html,$pos,6) != 'ftp://'
&& substr($html,$pos,9) != 'mailto://') {
if (substr($html,$pos,1) == '/') {
$new_base_url = $base_url_parts['scheme'].'://'.$base_url_parts['host'];
}
$new_txt .= substr($html,0,$pos).$new_base_url;
} else {
$new_txt .= substr($html,0,$pos);
}
$html = substr($html,$pos);
}
$html = $new_txt.$html;
}
return $html;
}
}
?>
\ No newline at end of file
<?php
class UNL_Search_CSEGenerator
{
public static function generateCSE($url)
{
$xml = '<CustomSearchEngine volunteers="false"
keywords="unl"
language="en"
visible="false"
encoding="UTF-8">
<Title>UNL Custom Search Engine for '.htmlentities($url).'</Title>
<Description>This custom search engine was automatically generated by the UNL Web Developer Network.</Description>
<Context>
<BackgroundLabels>
<Label name="_cse_local_site" mode="FILTER"/>
</BackgroundLabels>
</Context>
<LookAndFeel nonprofit="true"/>
<Annotations>';
foreach (UNL_Search_CSEGenerator::getIncludedSites($url) as $include) {
$xml .= "
<Annotation about=\"$include*\">
<Label name=\"_cse_local_site\"/>
</Annotation>";
}
foreach (UNL_Search_CSEGenerator::getExcludedSites($url) as $exclude) {
$xml .= "
<Annotation about=\"$exclude*\">
<Label name=\"_cse_exclude_local_site\"/>
</Annotation>";
}
$xml .= '
</Annotations>
<LookAndFeel resultsurl="http://www1.unl.edu/search/" nonprofit="true" adsposition="11">
<Colors url="#008000" background="#FFFFFF" border="#FFFFFF" title="#C60202" text="#000000" visited="#990000" light="#000000" />
</LookAndFeel>
</CustomSearchEngine>';
return $xml;
}
public static function getIncludedSites($baseurl)
{
$baseurl = str_replace('http://', '', $baseurl);
return array($baseurl);
}
public static function getExcludedSites($baseurl)
{
return array();
}
}
?>
\ No newline at end of file
<?php
ini_set('display_errors',true);
error_reporting(E_ALL);
require_once 'UNL/Autoload.php';
UNL_Templates::$options['version'] = 3;
$page = UNL_Templates::factory('Fixed');
$page->doctitle = '<title>UNL | Search</title>';
$local_results = '';
$page->head .= '
<script src="http://www.google.com/jsapi?key=ABQIAAAAfxH7RKwDLHYhDD9dSUZe-RTELkNjcWhKXky6vQZrvQAPA5Uw6xR-eQp2X1fKnLG-UqeKQ_7mwv5CcQ" type="text/javascript"></script>
<script type="text/javascript" src="/ucomm/templatedependents/templatesharedcode/scripts/bsn.AutoSuggest_2.1.3.js"></script>
<link rel="stylesheet" type="text/css" href="searchCSS.css" />
';
$page->addScript('searchFunc.js');
$options = array('allowed_schemes' => array('http','https'));
if (isset($_GET['u'])
&& preg_match('/^https?/', $_GET['u'])
&& filter_var($_GET['u'], FILTER_VALIDATE_URL, FILTER_FLAG_SCHEME_REQUIRED)
&& $scanned = @file_get_contents($_GET['u'])) {
$scanned = new UNL_Templates_Scanner($scanned);
if (isset($scanned->navlinks)) {
require_once 'HTMLPurifier.auto.php';
$config = HTMLPurifier_Config::createDefault();
$config->set('Cache.SerializerPath', '/tmp');
$purifier = new HTMLPurifier($config);
$page->head .= '<link rel="home" href="'.htmlentities($_GET['u'], ENT_QUOTES).'" />';
$page->breadcrumbs = $purifier->purify(UNL_Search::removeRelativePaths($scanned->breadcrumbs, $_GET['u']));
$page->titlegraphic = $purifier->purify($scanned->titlegraphic);
$page->navlinks = $purifier->purify(UNL_Search::removeRelativePaths($scanned->navlinks, $_GET['u']));
if (!empty($scanned->leftcollinks)) {
$page->leftcollinks = $purifier->purify($scanned->leftcollinks);
}
if (!empty($scanned->contactinfo)) {
$page->contactinfo = $purifier->purify($scanned->contactinfo);
}
}
$context = 'http://www1.unl.edu/search/linkedcse/?u='.$_GET['u'];
$page->addScriptDeclaration('
UNL_Search.do_local_search = true;
UNL_Search.local_search_context = "'.$context.'";
');
$local_results = '
<h3 class="sec_header">Local Results</h3>
<div id="local_results"></div>';
} else {
// Default search for no referring site.
$page->titlegraphic = '<h1>UNL Search</h1>';
$page->addScriptDeclaration('UNL_Search.do_local_search = false;');
$page->breadcrumbs = str_replace('Department', 'Search', $page->breadcrumbs);
$page->navlinks = file_get_contents('http://www.unl.edu/ucomm/sharedcode/navigation.html');
$page->leftcollinks = file_get_contents('http://www.unl.edu/ucomm/sharedcode/relatedLinks.html');
$page->contactinfo = file_get_contents('http://www.unl.edu/ucomm/sharedcode/footerContactInfo.html');
$page->footercontent = file_get_contents('http://www.unl.edu/ucomm/sharedcode/footer.html');
}
$page->maincontentarea = '
<div id="searchform">
<form action="http://www1.unl.edu/search/" method="get">
<input style="width:90%" type="text" name="q" />';
if (!empty($local_results)) {
$page->maincontentarea .= '<input type="hidden" name="u" value="'.htmlentities($_GET['u'], ENT_QUOTES).'" />';
}
$page->maincontentarea .= '
<input type="submit" value="Search" />
</form>
<noscript>
<form action="http://www.googlesyndicatedsearch.com/u/UNL1" method="get">
<input style="width:90%" type="text" name="q" />
<input type="submit" value="Search" />
</form>
</noscript>
</div>
<div class="col right">
<h3 class="sec_header">Peoplefinder</h3>
<div id="ppl_results"></div>
<a href="http://www1.unl.edu/wdn/wiki/About_Peoplefinder">About Peoplefinder</a>
</div>
<div class="three_col left">
'.$local_results.'
<h3 class="sec_header">UNL Web</h3>
<div id="unl_results"></div>
</div>
';
echo $page;
?>
\ No newline at end of file
<?php
if (!isset($_GET['u'])) {
exit();
}
chdir(dirname(dirname(__FILE__)));
require_once 'UNL/Autoload.php';
header('Content-type:application/xml');
echo UNL_Search_CSEGenerator::generateCSE($_GET['u']);
?>
\ No newline at end of file
/* Google/Peoplefinder Styles */
#ppl_results ul{
list-style:none;
padding:0;
margin-bottom:5px;
}
#ppl_results ul li.ppl_Sresult{
border-bottom:1px solid #ddd;
padding:0.7em 0 0.7em 0.7em;
}
#ppl_results ul li.ppl_Sresult:hover, #ppl_results ul li.ppl_Sresult.alt:hover{
background:#FFFEF0;
border-bottom:1px solid #d3d3d3;
}
#ppl_results ul li.ppl_Sresult.alt{
background:#FAFAFA;
}
#ppl_results ul li.ppl_Sresult div.tel{
background:url(http://peoplefinder.unl.edu/images/mobile.gif) no-repeat 0 0.75em;
padding:0.5em 0 0 1em;
position:relative;
color:#333;
}
#ppl_results .fn{
float:left;
margin-right:0.2em;
}
#ppl_results .cMatch{
background:#ffffcc;
margin:1em 0 1em 0;
padding:0.5em;
border:1px solid #d0c8a5;
}
#ppl_results .cMatch p {
margin:0;
}
#ppl_results .cNav{
position:absolute;
right:0;
top:0;
font-weight:normal;
letter-spacing:-0.1em;
}
#ppl_results a.cInfo{
background:url(http://peoplefinder.unl.edu/images/person.gif) no-repeat 0 3px;
padding:0 0 0 1em;
margin-left:0.8em;color:#555;text-decoration:underline;
}
#ppl_results .eppa{
font-size:0.75em;
margin-top:0.2em;
}
/*
The Search results
*/
#unl_results {min-height: 300px; background:url('/wdn/templates_3.0/css/header/images/colorbox/loading.gif') center 30px no-repeat;}
#searchform {
margin-bottom: 10px;
}
.gsc-input {
font-size: 1.1em;
}
.gs-result .gs-title, .gs-result .gs-title *{
color : #990000;
text-decoration: none;
font-size: 1.1em;
}
.gs-result .gs-title a:hover, .gs-result .gs-title a:hover * {
color : #cc0000;
}
.gs-result.alt {
background:#FAFAFA;
}
.gs-result {
border-bottom:1px solid #ddd;
padding: 0.7em;
}
.gs-result:hover {
background:#FFFEF0;
border-bottom:1px solid #d3d3d3;
}
.gs-search-nav {
margin-top: 10px;
text-align: right;
}
.gs-watermark {
display: none;
}
/* HCard Popup Styles */
body
{
position: relative;
}
div.hcardPopup
{
position: absolute;
background-image: url(images/as_pointer.gif);
background-position: center right;
background-repeat: no-repeat;
padding: 0 10px 0 0;
}
div.hcardPopup div.as_header,
div.hcardPopup div.as_footer
{
position: relative;
height: 6px;
padding: 0 6px;
background-image: url(/ucomm/templatedependents/templatecss/components/images/ul_corner_tr.gif);
background-position: top right;
background-repeat: no-repeat;
overflow: hidden;
}
div.hcardPopup div.as_footer
{
background-image: url(/ucomm/templatedependents/templatecss/components/images/ul_corner_br.gif);
}
div.hcardPopup div.as_header div.as_corner,
div.hcardPopup div.as_footer div.as_corner
{
position: absolute;
top: 0;
left: 0;
height: 6px;
width: 6px;
background-image: url(/ucomm/templatedependents/templatecss/components/images/ul_corner_tl.gif);
background-position: top left;
background-repeat: no-repeat;
}
div.hcardPopup div.as_footer div.as_corner
{
background-image: url(/ucomm/templatedependents/templatecss/components/images/ul_corner_bl.gif);
}
div.hcardPopup div.as_header div.as_bar,
div.hcardPopup div.as_footer div.as_bar
{
height: 6px;
overflow: hidden;
background-color: #333;
}
div.hcardPopup ul
{
list-style: none;
margin: 0 0 -4px 0;
padding: 0;
overflow: hidden;
background-color: #333;
}
div.hcardPopup ul li
{
color: #ccc;
padding: 0;
margin: 0 4px 4px;
text-align: left;
}
div.vcard {
padding: 5px;
color: #fff;
}
div.vcard a {
color: #fff;
}
div.vcard .fn {
float: left;
font-weight: bold;
margin-right: 4px;
}
div.vcard .vcardinfo {
padding: 6px;
line-height: 1.1;
position: relative;
}
div.vcard .adr, div.vard .tel {
margin-top:10px;
margin-bottom:10px;
font-size:0.9em;
}
div.vcard .type {
font-weight: bold;
}
div.vcard .eppa{
font-size:0.75em;
margin-top:0.2em;
}
\ No newline at end of file
// Load the Google Search AJAX API
google.load("search", "1");
function searchInit() {
UNL_Search.peoplefinderCache = new UNL_Search.Cache();
UNL_Search.hcardCache = new UNL_Search.Cache();
//Parse the querystring for q
var qs = location.search.substring(1,location.search.length);
qs = qs.replace(/\+/g, ' ');
var args = qs.split('&');
for (var i=0;i<args.length;i++) {
var pair = args[i].split('=');
var name = unescape(pair[0]);
if (name == "q") {
if (pair.length == 2) {
UNL_Search.query = unescape(pair[1])
} else {
UNL_Search.query = "";
}
break;
}
}
UNL_Search.unl_search = new google.search.WebSearch();
//Apply the Custom Search Engine
UNL_Search.unl_search.setSiteRestriction("015236299699564929946:nk1siew10ie");
UNL_Search.unl_search.setResultSetSize(GSearch.LARGE_RESULTSET)
UNL_Search.unl_search.setSearchCompleteCallback(UNL_Search, UNL_Search.handleUNLResults)
UNL_Search.unl_search.setLinkTarget(GSearch.LINK_TARGET_SELF);
if (UNL_Search.do_local_search) {
UNL_Search.local_search = new google.search.WebSearch();
//Apply the Custom Search Engine
UNL_Search.local_search.setSiteRestriction({crefUrl : UNL_Search.local_search_context});
//UNL_Search.local_search.setSiteRestriction('000150017203523626721:-1etga1qfci');
UNL_Search.local_search.setResultSetSize(GSearch.SMALL_RESULTSET)
UNL_Search.local_search.setSearchCompleteCallback(UNL_Search, UNL_Search.handleLocalResults)
UNL_Search.local_search.setLinkTarget(GSearch.LINK_TARGET_SELF);
}
var gSearchForm = new GSearchForm(false, document.getElementById("searchform"));
gSearchForm.setOnSubmitCallback(UNL_Search, UNL_Search.doQuery);
gSearchForm.input.value = (UNL_Search.query ? UNL_Search.query : "");
// Execute an inital search
if (UNL_Search.query && UNL_Search.query != "") {
UNL_Search.unl_search.execute(UNL_Search.query);
if (UNL_Search.do_local_search) {
UNL_Search.local_search.execute(UNL_Search.query);
}
UNL_Search.doPeoplefinderQuery(UNL_Search.query);
}
}
//Attach search initializer to onLoad
google.setOnLoadCallback(searchInit);
//
// UNL_Search Namespace
//
if (typeof(UNL_Search) == "undefined")
UNL_Search = {};
UNL_Search.query = null;
UNL_Search.do_local_search = false;
UNL_Search.unl_search = null;
UNL_Search.local_search = null;
UNL_Search.local_search_context = null;
UNL_Search.scrolldelay = null;
UNL_Search.hcardTimeout = null;
UNL_Search.hcardCache = null;
UNL_Search.peoplefinderCache = null;
//Caching Class
//
UNL_Search.Cache = {};
UNL_Search.Cache = function() {
this.storage = new Object();
};
UNL_Search.Cache.prototype.save = function(key, data) {
this.storage[key] = data;
};
UNL_Search.Cache.prototype.get = function (key) {
var val = null;
if (this.storage[key] != null) {
val = this.storage[key];
}
return val;
};
UNL_Search.handleUNLResults = function () {
UNL_Search.handleResults('unl_results', UNL_Search.unl_search);
};
UNL_Search.handleLocalResults = function () {
UNL_Search.handleResults('local_results', UNL_Search.local_search);
};
UNL_Search.handleResults = function (result_div, searchobj) {
var resultsDIV = document.getElementById(result_div);
if (searchobj.results && searchobj.results.length > 0) {
resultsDIV.innerHTML = '';
WDN.jQuery(resultsDIV).css('background', 'none');
//var resultHead = '<p>Results <strong>' + (1 + 8 * searchobj.cursor.currentPageIndex) + '</strong> - <strong>' + (8 + 8 * searchobj.cursor.currentPageIndex) + '</strong> of about <strong>' + searchobj.cursor.estimatedResultCount + '</strong> for <em>' + query + '</em></p>';
//resultsDIV.innerHTML += resultHead;
for (var i = 0; i < searchobj.results.length; i++) {
if (i % 2 != 0) {
searchobj.results[i].html.className += " alt";
}
resultsDIV.appendChild(searchobj.results[i].html);
}
var nav = document.createElement("div");
nav.className = "gs-search-nav";
for (var i = 0; i < searchobj.cursor.pages.length; i++) {
var pageText = '';
if (searchobj.cursor.currentPageIndex != i) {
pageText += '<a onclick="UNL_Search.unl_search.gotoPage(' + i + '); return false;" href="#">' + searchobj.cursor.pages[i].label + '</a>&nbsp;&nbsp;';
} else {
pageText += searchobj.cursor.pages[i].label + '&nbsp;&nbsp;';
}
nav.innerHTML += pageText;
}
if (searchobj.cursor.pages.length >= 8) {
nav.innerHTML += '<a href="' + searchobj.cursor.moreResultsUrl + '">More Results &gt;&gt;</a>';
}
resultsDIV.appendChild(nav);
} else {
WDN.jQuery(resultsDIV).html('<p>No results found.</p>');
}
};
UNL_Search.doPeoplefinderQuery = function (val) {
var cacheData = this.peoplefinderCache.get(val)
if (cacheData) {
this.handlePeoplefinderResults(cacheData);
} else {
var http = new XMLHTTP();
http.open("GET", "http://peoplefinder.unl.edu/service.php?q=" + val, true);
var pointer = this;
http.onreadystatechange = function(){
if (http.readyState == 4) {
if (http.status == 200) {
var data = http.responseText;
pointer.peoplefinderCache.save(val, data);
pointer.handlePeoplefinderResults(data);
} else {
// Error loading file!
}
}
};
http.send(null);
}
};
UNL_Search.handlePeoplefinderResults = function (peoplefinderText) {
var htmlDoc = _b.DOM.cE("div");
htmlDoc.innerHTML = peoplefinderText;
var results = htmlDoc.getElementsByTagName("ul");
if (results.length > 0) {
var goodResults = _b.DOM.cE("ul");
var resultSet = results[0].getElementsByTagName("li");
var i;
var len = resultSet.length;
for (i = 0; i < 10 && i < len; i++) {
if (i % 2 != 0) {
resultSet[0].className = "ppl_Sresult alt";
} else {
resultSet[0].className = "ppl_Sresult";
}
theAs = resultSet[0].getElementsByTagName("a");
for (var j = 0; j < theAs.length; j++) {
if (theAs[j].href.indexOf("peoplefinder") > -1) {
if (theAs[j].parentNode.nodeName != "LI") {
theAs[j].onclick = function(){ return UNL_Search.showHCard(this.parentNode.parentNode, this.href) };
} else {
theAs[j].onclick = function(){ return UNL_Search.showHCard(this.parentNode, this.href) };
}
}
}
goodResults.appendChild(resultSet[0]);
}
document.getElementById("ppl_results").innerHTML = '';
document.getElementById("ppl_results").appendChild(goodResults);
if (i < len) {