Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
U
UNL_Search
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Ryan Dee
UNL_Search
Commits
b78b5f23
Commit
b78b5f23
authored
10 years ago
by
Kevin Abel
Browse files
Options
Downloads
Patches
Plain Diff
Implement the 4.0 template and embedded search in the controller
parent
3ea7d04b
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
www/index.php
+83
-80
83 additions, 80 deletions
www/index.php
with
83 additions
and
80 deletions
www/index.php
+
83
−
80
View file @
b78b5f23
<?php
$config_file
=
__DIR__
.
'/../config.sample.php'
;
if
(
file_exists
(
__DIR__
.
'/../config.inc.php'
))
{
$config_file
=
__DIR__
.
'/../config.inc.php'
;
}
require_once
$config_file
;
function
renderTemplate
(
$file
,
$params
=
array
())
{
extract
(
$params
);
include
$file
;
}
$isEmbed
=
isset
(
$_GET
[
'embed'
])
&&
$_GET
[
'embed'
];
UNL_Templates
::
setCachingService
(
new
UNL_Templates_CachingService_Null
());
UNL_Templates
::
$options
[
'version'
]
=
4.0
;
UNL_Templates
::
$options
[
'version'
]
=
3.1
;
$page
=
UNL_Templates
::
factory
(
'Fixed'
)
;
$template
=
'Fixed'
;
if
(
!
$isEmbed
)
{
$page
->
doctitle
=
'<title>Search | University of Nebraska–Lincoln</title>'
;
$page
->
pagetitle
=
''
;
ob_start
();
renderTemplate
(
'templates/breadcrumbs.tpl.php'
);
$page
->
breadcrumbs
=
ob_get_clean
();
}
if
(
isset
(
$_GET
[
'format'
])
&&
$_GET
[
'format'
]
==
'mobile'
)
{
$template
=
'Mobile'
;
if
(
UNL_Search
::
$mode
===
'debug'
)
{
$page
->
addScript
(
'js/search.js'
);
}
else
{
$page
->
addScript
(
'js/search.min.js'
);
}
$page
=
UNL_Templates
::
factory
(
'Fixed'
);
$page
->
doctitle
=
'<title>UNL | Search</title>'
;
$page
->
pagetitle
=
''
;
$page
->
breadcrumbs
=
'
<ul>
<li><a href="http://www.unl.edu/" title="University of Nebraska–Lincoln">UNL</a></li>
<li>Search</li>
</ul>'
;
$local_results
=
''
;
$inlineJS
=
''
;
$apiKey
=
UNL_Search
::
getJSAPIKey
();
$page
->
addScript
(
'http://www.google.com/jsapi'
.
(
empty
(
$apiKey
)
?
''
:
'?key='
.
$apiKey
));
$page
->
head
.
=
'
<link rel="stylesheet" href="http://www.google.com/cse/style/look/default.css" type="text/css" />
<link rel="stylesheet" type="text/css" href="http://directory.unl.edu/css/result_lists.css" />
<link rel="stylesheet" type="text/css" href="searchCSS.css" />
'
;
if
(
$template
==
'Mobile'
)
{
$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>'
;
$params
=
array
(
'autoload'
=>
json_encode
(
array
(
'modules'
=>
array
(
array
(
'name'
=>
'search'
,
'version'
=>
'1.0'
,
'callback'
=>
'searchInit'
,
'style'
=>
'//www.google.com/cse/style/look/v2/default.css'
),
))),
);
if
(
!
empty
(
$apiKey
))
{
$params
[
'key'
]
=
$apiKey
;
}
$page
->
addScript
(
'searchFunc.js'
);
$page
->
addScript
(
'//www.google.com/jsapi?'
.
http_build_query
(
$params
));
$page
->
addStyleSheet
(
'css/search.css'
);
if
(
isset
(
$_GET
[
'u'
])
//u is referring site
&&
$_GET
[
'u'
]
!==
'http://www.unl.edu/'
&&
preg_match
(
'/^https?/'
,
$_GET
[
'u'
])
&&
filter_var
(
$_GET
[
'u'
],
FILTER_VALIDATE_URL
,
FILTER_FLAG_SCHEME_REQUIRED
)
&&
$scanned
=
@
file_get_contents
(
$_GET
[
'u'
]))
{
//u is referring site
if
(
isset
(
$_GET
[
'u'
])
&&
$scanned
=
UNL_Search
::
getScannedPage
(
$_GET
[
'u'
]))
{
// Add local site search results
$scanned
=
new
UNL_Templates_Scanner
(
$scanned
);
if
(
isset
(
$scanned
->
navlinks
))
{
//we're scrapping the navigation and other content from the originatting site.
// we're scrapping the navigation and other content from the originatting site.
if
(
!
$isEmbed
&&
isset
(
$scanned
->
navlinks
))
{
require_once
'HTMLPurifier.auto.php'
;
$config
=
HTMLPurifier_Config
::
createDefault
();
$config
->
set
(
'Cache.SerializerPath'
,
'/tmp'
);
...
...
@@ -63,7 +71,8 @@ if (isset($_GET['u']) //u is referring site
$page
->
leftcollinks
=
$purifier
->
purify
(
$scanned
->
leftcollinks
);
}
if
(
!
empty
(
$scanned
->
contactinfo
))
{
$page
->
contactinfo
=
$purifier
->
purify
(
$scanned
->
contactinfo
);
$page
->
contactinfo
=
$purifier
->
purify
(
preg_replace
(
'#<h3>.*</h3>#'
,
''
,
$scanned
->
contactinfo
));
}
if
(
!
empty
(
$scanned
->
footercontent
))
{
$page
->
footercontent
=
$purifier
->
purify
(
$scanned
->
footercontent
);
...
...
@@ -72,62 +81,56 @@ if (isset($_GET['u']) //u is referring site
if
(
isset
(
$_GET
[
'cx'
]))
{
// Use their custom search engine instead of the linked one.
$context
=
'"'
.
htmlentities
(
$_GET
[
'cx'
],
ENT_QUOTES
)
.
'"'
;
$context
=
$_GET
[
'cx'
]
;
}
else
{
// Auto-build a custom search engine
$context
=
'{crefUrl :"http://www1.unl.edu/search/linkedcse/?u='
.
$_GET
[
'u'
]
.
'"}'
;
$context
=
array
(
'crefUrl'
=>
UNL_Search
::
getLinkedCSEUrl
(
$_GET
[
'u'
]
))
;
}
$page
->
addScriptDeclaration
(
'
UNL_Search.do_local_search = true;
UNL_Search.local_search_context = '
.
$context
.
';
'
);
$local_results
=
'
<h3 class="sec_header">'
.
$page
->
titlegraphic
.
' Results</h3>
<div id="local_results" class="google-results"></div>'
;
}
else
{
$context
=
json_encode
(
$context
);
$inlineJS
.
=
"var LOCAL_SEARCH_CONTEXT =
{
$context
}
;
\n
"
;
ob_start
();
renderTemplate
(
'templates/google-results.tpl.php'
,
array
(
'title'
=>
$page
->
titlegraphic
,
'id'
=>
'local_results'
,
));
$local_results
=
ob_get_clean
();
}
elseif
(
!
$isEmbed
)
{
// Default search for no referring site.
$page
->
titlegraphic
=
'<h1>UNL Search</h1>'
;
$page
->
addScriptDeclaration
(
'UNL_Search.do_local_search = false;'
);
$page
->
titlegraphic
=
'UNL Search'
;
$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
->
contactinfo
=
preg_replace
(
'#<h3>.*</h3>#'
,
''
,
file_get_contents
(
'http://www.unl.edu/ucomm/sharedcode/footerContactInfo.html'
)
)
;
$page
->
footercontent
=
file_get_contents
(
'http://www.unl.edu/ucomm/sharedcode/footer.html'
);
}
if
(
isset
(
$_GET
[
'q'
]))
{
$q
=
json_encode
(
$_GET
[
'q'
]);
$inlineJS
.
=
"var INITIAL_QUERY =
{
$q
}
;
\n
"
;
}
$page
->
addScriptDeclaration
(
$inlineJS
);
$page
->
maincontentarea
=
'
<div id="searchform">
<form action="./" method="get">
<fieldset>
<label for="q">Search</label>
<input class="search-query" type="text" name="q" id="search_q" title="search" />'
;
if
(
!
empty
(
$local_results
))
{
$page
->
maincontentarea
.
=
'<input type="hidden" name="u" value="'
.
htmlentities
(
$_GET
[
'u'
],
ENT_QUOTES
)
.
'" />'
;
ob_start
();
if
(
!
$isEmbed
)
{
renderTemplate
(
'templates/search-form.tpl.php'
,
array
(
'local_results'
=>
$local_results
));
}
renderTemplate
(
'templates/search-results.tpl.php'
,
array
(
'isEmbed'
=>
$isEmbed
,
'local_results'
=>
$local_results
));
$maincontent
=
ob_get_clean
();
if
(
!
$isEmbed
)
{
$page
->
maincontentarea
=
$maincontent
;
echo
$page
;
}
else
{
renderTemplate
(
'templates/embed.tpl.php'
,
array
(
'head'
=>
$page
->
head
,
'maincontent'
=>
$maincontent
));
}
$page
->
maincontentarea
.
=
'
<input class="search-button" title="search" type="submit" value="Search" />
</fieldset>
</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="grid8 first" id="search_results">
'
.
$local_results
.
'
<h3 class="sec_header">UNL Web</h3>
<div id="unl_results" class="google-results"></div>
</div>
<div class="grid4" id="directory_results">
<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>
'
;
echo
$page
;
?>
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment