Skip to content
Snippets Groups Projects
Commit f723eff1 authored by Kevin Abel's avatar Kevin Abel
Browse files

Coding standards and add WDN include path

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