diff --git a/www/index.php b/www/index.php index c9dcf2af3fb4568078d2045d0b25d05c26614840..1b70b3486211358be918a37cd7533a7484c8f2c6 100644 --- a/www/index.php +++ b/www/index.php @@ -13,6 +13,16 @@ function renderTemplate($file, $params = array()) include $file; } +function loadDefaultSections($page) +{ + $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 = 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'); +} + $isEmbed = isset($_GET['embed']) && $_GET['embed']; UNL_Templates::setCachingService(new UNL_Templates_CachingService_Null()); @@ -58,21 +68,28 @@ $page->addStyleSheet('css/search.css'); 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 && 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->breadcrumbs = $purifier->purify(UNL_Search::removeRelativePaths($scanned->breadcrumbs, $_GET['u'])); - $page->titlegraphic = $purifier->purify(str_replace(array('<h1>', '</h1>'), '',$scanned->titlegraphic)); - $page->navlinks = $purifier->purify(UNL_Search::removeRelativePaths($scanned->navlinks, $_GET['u'])); - if (!empty($scanned->contactinfo)) { - $page->contactinfo = $purifier->purify(preg_replace('#<h3>.*</h3>#', '', $scanned->contactinfo)); - } - if (!empty($scanned->footercontent)) { - $page->footercontent = $purifier->purify($scanned->footercontent); + if (!$isEmbed) { + 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->breadcrumbs = $purifier->purify(UNL_Search::removeRelativePaths($scanned->breadcrumbs, $_GET['u'])); + $page->titlegraphic = $purifier->purify(str_replace(array('<h1>', '</h1>'), '',$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(preg_replace('#<h3>.*</h3>#', '', $scanned->contactinfo)); + } + if (!empty($scanned->footercontent)) { + $page->footercontent = $purifier->purify($scanned->footercontent); + } + } else { + loadDefaultSections($page); } } @@ -94,12 +111,7 @@ if (isset($_GET['u']) && $scanned = UNL_Search::getScannedPage($_GET['u'])) { $local_results = ob_get_clean(); } elseif (!$isEmbed) { // Default search for no referring site. - $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 = 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'); + loadDefaultSections($page); } if (isset($_GET['q'])) {