From 5c8d8e0a3b92a76062c0d9ac3059767e5e92ec1c Mon Sep 17 00:00:00 2001 From: Kevin Abel <kabel2@unl.edu> Date: Tue, 16 Aug 2011 21:15:24 +0000 Subject: [PATCH] Updated the XML schema of the custom local search. Still appear to not be working properly. --- src/UNL/Search/CSEGenerator.php | 39 +++++++++++++++------------------ 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/src/UNL/Search/CSEGenerator.php b/src/UNL/Search/CSEGenerator.php index c518deb..9d8b219 100644 --- a/src/UNL/Search/CSEGenerator.php +++ b/src/UNL/Search/CSEGenerator.php @@ -1,50 +1,47 @@ -<?php +<?php class UNL_Search_CSEGenerator { public static function generateCSE($url) { - $xml = '<CustomSearchEngine volunteers="false" - keywords="unl" - language="en" - visible="false" - encoding="UTF-8"> - <Title>UNL Custom Search Engine for '.htmlentities($url, ENT_QUOTES).'</Title> + $xml = ' +<GoogleCustomizations> + <CustomSearchEngine> + <Title>UNL Custom Search Engine for '. htmlentities($url, ENT_QUOTES) . '</Title> <Description>This custom search engine was automatically generated by the UNL Web Developer Network.</Description> <Context> <BackgroundLabels> - <Label name="_cse_local_site" mode="FILTER"/> + <Label name="_cse_localsite" mode="FILTER"/> + <Label name="_cse_exclude_localsite" mode="EXCLUDE"/> </BackgroundLabels> - </Context> - <LookAndFeel nonprofit="true"/> - <Annotations>'; + <LookAndFeel nonprofit="true"/> + </CustomSearchEngine>'; + $xml .= ' + <Annotations>'; foreach (UNL_Search_CSEGenerator::getIncludedSites($url) as $include) { $xml .= " - <Annotation about=\"$include*\"> - <Label name=\"_cse_local_site\"/> - </Annotation>"; + <Annotation about=\"$include*\"> + <Label name=\"_cse_localsite\"/> + </Annotation>"; } foreach (UNL_Search_CSEGenerator::getExcludedSites($url) as $exclude) { $xml .= " <Annotation about=\"$exclude*\"> - <Label name=\"_cse_exclude_local_site\"/> + <Label name=\"_cse_exclude_localsite\"/> </Annotation>"; } $xml .= ' </Annotations> - <LookAndFeel resultsurl="http://www1.unl.edu/search/" nonprofit="true" adsposition="11"> - <Colors url="#008000" background="#FFFFFF" border="#FFFFFF" title="#C60202" text="#000000" visited="#990000" light="#000000" /> - </LookAndFeel> - </CustomSearchEngine>'; +</GoogleCustomizations>'; return $xml; } - + public static function getIncludedSites($baseurl) { $baseurl = str_replace('http://', '', $baseurl); return array($baseurl); } - + public static function getExcludedSites($baseurl) { return array(); -- GitLab