index.php 4.69 KB
Newer Older
1
2
<?php

Brett Bieber's avatar
Brett Bieber committed
3
require_once dirname(__FILE__).'/../config.sample.php';
4
5
6

UNL_Templates::$options['version'] = 3;

7
8
9
10
11
12
13
14
$template = 'Fixed';

if (isset($_GET['format'])
    && $_GET['format'] == 'mobile') {
    $template = 'Mobile';
}

$page = UNL_Templates::factory($template);
15
16
17
$page->doctitle = '<title>UNL | Search</title>';
$local_results = '';
$page->head .= '
18
<script type="text/javascript" src="/wdn/templates_3.0/scripts/all.js"></script>
19
<script src="http://www.google.com/jsapi?key=ABQIAAAAfxH7RKwDLHYhDD9dSUZe-RTELkNjcWhKXky6vQZrvQAPA5Uw6xR-eQp2X1fKnLG-UqeKQ_7mwv5CcQ" type="text/javascript"></script>
20
<link rel="stylesheet" type="text/css" href="http://directory.unl.edu/css/peoplefinder_default.css" />
21
<link rel="stylesheet" type="text/css" href="searchCSS.css" />
22
';
23
if ($template == 'Mobile') {
24
25
26
27
28
	$page->head .='<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" >
	<script type="text/javascript">var mobileSearch = true;</script>';
} else {
	$page->head .='<script type="text/javascript">var mobileSearch = false;</script>';
}
29
30
$page->addScript('searchFunc.js');

31
if (isset($_GET['u']) //u is referring site
32
33
34
    && preg_match('/^https?/', $_GET['u'])
    && filter_var($_GET['u'], FILTER_VALIDATE_URL, FILTER_FLAG_SCHEME_REQUIRED)
    && $scanned = @file_get_contents($_GET['u'])) {
35
    // Add local site search results
36
    $scanned = new UNL_Templates_Scanner($scanned);
37
    if (isset($scanned->navlinks)) { //we're scrapping the navigation and other content from the originatting site.
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
        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);
        }
53
54
55
        if (!empty($scanned->footercontent)) {
            $page->footercontent = $purifier->purify($scanned->footercontent);
        }
56
    }
57
58
59
    
    if (isset($_GET['cx'])) {
        // Use their custom search engine instead of the linked one.
Brett Bieber's avatar
Brett Bieber committed
60
        $context = '"'.htmlentities($_GET['cx'], ENT_QUOTES).'"';
61
62
63
64
    } else {
        // Auto-build a custom search engine
        $context = '{crefUrl :"http://www1.unl.edu/search/linkedcse/?u='.$_GET['u'].'"}';
    }
65
    $page->addScriptDeclaration('
Brett Bieber's avatar
Brett Bieber committed
66
        UNL_Search.do_local_search = true;
67
        UNL_Search.local_search_context = '.$context.';
Brett Bieber's avatar
Brett Bieber committed
68
    ');
69
70
71
72
73
74
75
    $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;');
Brett Bieber's avatar
Brett Bieber committed
76
77
78
79
80
    $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');
81
82
83
84
85
86
87
 
}


$page->maincontentarea = '
<div id="searchform">
  <form action="http://www1.unl.edu/search/" method="get">
88
89
  	<label for="q">Search</label>
    <input type="text" name="q" id="q" />';
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
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="three_col left">
    '.$local_results.'
    <h3 class="sec_header">UNL Web</h3>
    <div id="unl_results"></div>
</div>
108
109
110
111
112
<div class="col right">
    <h3 class="sec_header">UNL Directory</h3>
    <div id="ppl_results"></div>
    <a href="http://www1.unl.edu/wdn/wiki/About_Peoplefinder">About the UNL Directory</a>
</div>
113
114
115
116
';
echo $page;

?>