Commit f723eff1 authored by Kevin Abel's avatar Kevin Abel
Browse files

Coding standards and add WDN include path

parent 38dbb9ce
......@@ -28,15 +28,21 @@ function loadDefaultSections($page)
$isEmbed = isset($_GET['embed']) && $_GET['embed'];
$localScriptUrl = './js/search.min.js';
$pageTemplate = 'Fixed';
if (UNL_Search::$mode === 'debug') {
$page = Templates::factory('Local', Templates::VERSION_4_1);
$page->addScript('js/search.js');
} else {
$page = Templates::factory('Fixed', Templates::VERSION_4_1);
$page->addScript('js/search.min.js');
$pageTemplate = 'Local';
$localScriptUrl = './js/search.js';
}
$page = Templates::factory($pageTemplate, Templates::VERSION_4_1);
if (!$isEmbed) {
if (file_exists(__DIR__ . '/wdn/templates_4.1')) {
$page->setLocalIncludePath(__DIR__);
}
$page->doctitle = '<title>Search | University of Nebraska&ndash;Lincoln</title>';
$page->pagetitle = '';
$page->breadcrumbs = renderTemplate('templates/breadcrumbs.tpl.php');
......@@ -62,20 +68,20 @@ $page->addScript(htmlspecialchars('//www.google.com/jsapi?' . http_build_query($
$page->addStyleSheet('css/search.css');
//u is referring site
if (isset($_GET['u']) && $scanned = UNL_Search::getScannedPage($_GET['u'])) {
if (isset($_GET['u']) && $scanned = UNL_Search::getScannedPage($_GET['u'])) {
// Add local site search results
// we're scrapping the navigation and other content from the originatting site.
if (!$isEmbed) {
if (isset($scanned->titlegraphic)) {
if (isset($scanned->titlegraphic)) {
//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->titlegraphic = $purifier->purify(str_replace(array('<h1>', '</h1>'), '', $scanned->titlegraphic));
$page->affiliation = '';
foreach (array('breadcrumbs', 'navlinks', 'leftcollinks', 'contactinfo', 'affiliation') as $region) {
if (isset($scanned->{$region}) && !empty($scanned->{$region})) {
$scannedContent = $scanned->{$region};
......@@ -88,7 +94,7 @@ if (isset($_GET['u']) && $scanned = UNL_Search::getScannedPage($_GET['u'])) {
$scannedContent = preg_replace('#<h3>.*</h3>#', '', $scannedContent);
break;
}
$page->{$region} = $purifier->purify($scannedContent);
}
}
......@@ -136,14 +142,16 @@ $maincontent .= renderTemplate('templates/search-results.tpl.php', array(
if (!$isEmbed) {
$page->maincontentarea = $maincontent;
echo $page;
} else {
if (UNL_Search::$mode === 'debug') {
$template = 'templates/embed-debug.tpl.php';
} else {
$template = 'templates/embed.tpl.php';
}
echo renderTemplate($template, array(
'head' => $page->head,
'maincontent' => $maincontent
));
exit;
}
$template = 'templates/embed.tpl.php';
if (UNL_Search::$mode === 'debug') {
$template = 'templates/embed-debug.tpl.php';
}
echo renderTemplate($template, array(
'head' => $page->head,
'maincontent' => $maincontent
));
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment