/**
  * Return top level Metalib KB categories as XML
  *
  * @param Xerxes_Framework_Request $objRequest
  * @param Xerxes_Framework_Registry $objRegistry
  * @return int status
  */
 public function doExecute()
 {
     $objXml = new DOMDOcument();
     $objData = new Xerxes_DataMap();
     $lang = $this->request->getProperty("lang");
     $arrResults = $objData->getCategories($lang);
     $x = 1;
     if (count($arrResults) > 0) {
         $objXml->loadXML("<categories />");
         foreach ($arrResults as $objCategoryData) {
             $objCategory = $objXml->createElement("category");
             $objCategory->setAttribute("position", $x);
             foreach ($objCategoryData->properties() as $key => $value) {
                 if ($value != null) {
                     $objElement = $objXml->createElement("{$key}", Xerxes_Framework_Parser::escapeXml($value));
                     $objCategory->appendChild($objElement);
                 }
             }
             // add the url for the category
             $arrParams = array("base" => "databases", "action" => "subject", "subject" => $objCategoryData->normalized);
             $url = Xerxes_Framework_Parser::escapeXml($this->request->url_for($arrParams));
             $objElement = $objXml->createElement("url", $url);
             $objCategory->appendChild($objElement);
             $objXml->documentElement->appendChild($objCategory);
             $x++;
         }
     }
     $this->request->addDocument($objXml);
     return 1;
 }
 public function doExecute()
 {
     $arrSaved = array();
     $arrMatch = array();
     $objData = new Xerxes_DataMap();
     // find all of the xerxes records
     $objRecords = $this->request->getData("//xerxes_record", null, "DOMNodeList");
     if ($objRecords->length > 0) {
         foreach ($objRecords as $objXerxesRecord) {
             $strResultSet = "";
             $strRecordNumber = "";
             $objResultSet = $objXerxesRecord->getElementsByTagName("result_set")->item(0);
             $objRecordNumber = $objXerxesRecord->getElementsByTagName("record_number")->item(0);
             if ($objResultSet != null) {
                 $strResultSet = $objResultSet->nodeValue;
             }
             if ($objRecordNumber != null) {
                 $strRecordNumber = $objRecordNumber->nodeValue;
             }
             if ($strRecordNumber != "" && $strResultSet != "") {
                 // see if it's listed in session as being saved
                 if (Xerxes_Helper::isMarkedSaved($strResultSet, $strRecordNumber)) {
                     $key = Xerxes_Helper::savedRecordKey($strResultSet, $strRecordNumber);
                     $id = $_SESSION['resultsSaved'][$key]['xerxes_record_id'];
                     array_push($arrSaved, $id);
                     $arrMatch[$id] = $strResultSet . ":" . $strRecordNumber;
                 }
             }
         }
         if (count($arrSaved) == 0) {
             return 0;
         }
         // fetch all the saved records on this page in one query to the database
         $arrResults = $objData->getRecordsByID($arrSaved);
         if (count($arrResults) == 0) {
             return 0;
         } else {
             $objXml = new DOMDocument();
             $objXml->loadXML("<saved_records />");
             foreach ($arrResults as $objSavedRecord) {
                 // id
                 $objSavedRecordXml = $objXml->createElement("saved");
                 $objSavedRecordXml->setAttribute("id", $arrMatch[$objSavedRecord->id]);
                 $objIDXml = $objXml->createElement("id", $objSavedRecord->id);
                 $objSavedRecordXml->appendChild($objIDXml);
                 // labels
                 foreach ($objSavedRecord->tags as $tag) {
                     $objTagXml = $objXml->createElement("tag", Xerxes_Framework_Parser::escapeXml($tag));
                     $objSavedRecordXml->appendChild($objTagXml);
                 }
                 $objXml->documentElement->appendChild($objSavedRecordXml);
             }
             $this->request->addDocument($objXml);
             return 1;
         }
     }
 }
 public function doExecute()
 {
     $lang = $this->request->getProperty("lang");
     // main list of subcategories and databases
     $objXml = new DOMDocument();
     $objXml->loadXML("<category />");
     // list of subcategories that should go in the sidebar
     $objSidebar = new DOMDocument();
     $objSidebar->loadXML("<sidebar />");
     $strOld = $this->request->getProperty("category");
     $strSubject = $this->request->getProperty("subject");
     $configSidebar = $this->registry->getConfig("SUBCATEGORIES_SIDEBAR", false, null, $lang);
     $arrSidebar = explode(",", $configSidebar);
     // look up home page default subject from config if no subject was specified, and we were
     // instructed to look it up with use_categories_quicksearch=true
     if ($strSubject == "" && $this->request->getProperty("use_categories_quicksearch") == "true") {
         $strSubject = $this->registry->getConfig("categories_quicksearch", false, "quick-search", $lang);
     }
     $objData = new Xerxes_DataMap();
     $objCategoryData = $objData->getSubject($strSubject, $strOld, "metalib", null, $lang);
     $y = 1;
     if ($objCategoryData != null) {
         $objXml->documentElement->setAttribute("name", $objCategoryData->name);
         $objXml->documentElement->setAttribute("normalized", $objCategoryData->normalized);
         // standard url for the category
         $arrParams = array("base" => "databases", "action" => "subject", "subject" => $objCategoryData->normalized);
         $url = Xerxes_Framework_Parser::escapeXml($this->request->url_for($arrParams));
         $objElement = $objXml->createElement("url", $url);
         $objXml->documentElement->appendChild($objElement);
         // the attributes of the subcategories
         $db_list_index = 1;
         foreach ($objCategoryData->subcategories as $objSubData) {
             $objSubCategory = $objXml->createElement("subcategory");
             $objSubCategory->setAttribute("name", $objSubData->name);
             $objSubCategory->setAttribute("position", $y);
             $objSubCategory->setAttribute("id", $objSubData->id);
             $y++;
             // the database information
             foreach ($objSubData->databases as $objDatabaseData) {
                 $objDatabase = Xerxes_Helper::databaseToNodeset($objDatabaseData, $this->request, $this->registry, $db_list_index);
                 $objDatabase = $objXml->importNode($objDatabase, true);
                 $objSubCategory->appendChild($objDatabase);
             }
             // if marked for the sidebar, put it there
             if (in_array($objSubData->name, $arrSidebar)) {
                 $objImport = $objSidebar->importNode($objSubCategory, true);
                 $objSidebar->documentElement->appendChild($objImport);
             } else {
                 $objXml->documentElement->appendChild($objSubCategory);
             }
         }
     }
     $this->request->addDocument($objXml);
     $this->request->addDocument($objSidebar);
     return 1;
 }
 public function doExecute()
 {
     // If supplied in URL, use that (for future API use).
     // Nevermind, this is a privacy problem until we right access
     // controls for that future API use.
     //$username = $this->request->getProperty("username");
     //if ( ! $username ) {
     // default to logged in user
     $username = $this->request->getSession("username");
     //}
     // we can only do this if we have a real user (not temp user), otherwise
     // just add no XML.
     if ($username == null || !Xerxes_Framework_Restrict::isAuthenticatedUser($this->request)) {
         return 0;
     }
     $objXml = new DOMDOcument();
     $objData = new Xerxes_DataMap();
     $arrResults = $objData->getUserCreatedCategories($username);
     $x = 1;
     if (count($arrResults) > 0) {
         $objXml->loadXML("<userCategories />");
         foreach ($arrResults as $objCategoryData) {
             $objCategory = $objXml->createElement("category");
             $objCategory->setAttribute("position", $x);
             foreach ($objCategoryData->properties() as $key => $value) {
                 if ($value != null) {
                     $objElement = $objXml->createElement("{$key}", Xerxes_Framework_Parser::escapeXml($value));
                     $objCategory->appendChild($objElement);
                 }
             }
             // add the url for the category
             $arrParams = array("base" => "collections", "action" => "subject", "username" => $username, "subject" => $objCategoryData->normalized);
             $url = Xerxes_Framework_Parser::escapeXml($this->request->url_for($arrParams));
             $objElement = $objXml->createElement("url", $url);
             $objCategory->appendChild($objElement);
             $objXml->documentElement->appendChild($objCategory);
             $x++;
         }
     }
     $this->request->addDocument($objXml);
     return 1;
 }
示例#5
0
 public function setTagsCache($arrResults)
 {
     // we'll store the tags summary in session so that edits can be
     // done without round-tripping to the database; xslt can display
     // the summary by getting it from the request xml
     // make sure they are alphabetical
     ksort($arrResults);
     $this->request->setSession("tags", $arrResults);
     // but also add it to the request with urls
     $objXml = new DOMDocument();
     $objXml->loadXML("<tags />");
     foreach ($arrResults as $label => $total) {
         $objTag = $objXml->createElement("tag");
         $objXml->documentElement->appendChild($objTag);
         $arrUrl = array("base" => "folder", "action" => "home", "username" => $this->request->getSession("username"), "label" => $label);
         $objTag->setAttribute("label", $label);
         $objTag->setAttribute("total", $total);
         $objTag->setAttribute("url", Xerxes_Framework_Parser::escapeXml($this->request->url_for($arrUrl)));
     }
     $this->request->addDocument($objXml);
 }
示例#6
0
 public function publicXML()
 {
     // pass any configuration options defined as type=pass to the xml
     $objConfigXml = new DOMDocument();
     $objConfigXml->loadXML("<config />");
     foreach ($this->getPass() as $key => $value) {
         if ($value instanceof SimpleXMLElement) {
             // just spit it back out again as XML
             $objElement = $objConfigXml->createElement($key);
             $objConfigXml->documentElement->appendChild($objElement);
             foreach ($value->children() as $child) {
                 // need to convert to DOMDocument.
                 $domValue = dom_import_simplexml($child);
                 $domValue = $objConfigXml->importNode($domValue, true);
                 $objElement->appendChild($domValue);
             }
         } else {
             // simple string value
             $objElement = $objConfigXml->createElement($key, Xerxes_Framework_Parser::escapeXml($value));
             $objConfigXml->documentElement->appendChild($objElement);
         }
     }
     return $objConfigXml;
 }
 public function doExecute()
 {
     $start = microtime(true);
     $arrFields = array();
     // fields to return in response
     $iMaximumRecords = 10;
     // maximum number of records to return
     $iTotalHits = 0;
     // total number of hits in response
     $arrResults = array();
     // holds results returned
     // metalib search object
     $objSearch = $this->getSearchObject();
     // parameters from request
     $id = $this->request->getProperty("group");
     $strGroup = $this->getGroupNumber();
     $strResultSet = $this->request->getProperty("resultSet");
     $iStartRecord = (int) $this->request->getProperty("startRecord");
     // access control
     $objSearchXml = $this->getCache($id, "search", "DOMDocument");
     Xerxes_Helper::checkDbListSearchableByUser($objSearchXml, $this->request, $this->registry);
     // marc fields to return from metalib; we specify these here in order to keep
     // the response size as small (and thus as fast) as possible
     $strMarcFields = self::MARC_FIELDS_BRIEF;
     // $strMarcFields = "#####, OPURL";
     // configuration options
     $configRecordPerPage = $this->registry->getConfig("RECORDS_PER_PAGE", false, self::DEFAULT_RECORDS_PER_PAGE);
     $configMarcFields = $this->registry->getConfig("MARC_FIELDS_BRIEF", false);
     $configIncludeMarcRecord = $this->registry->getConfig("XERXES_BRIEF_INCLUDE_MARC", false, false);
     $configFacets = $this->registry->getConfig("FACETS", false, false);
     // add additional marc fields specified in the config file
     if ($configMarcFields != null) {
         $configMarcFields .= ", " . $strMarcFields;
     } else {
         $configMarcFields = $strMarcFields;
     }
     // empty querystring values will return as 0, so fix here in case
     if ($iStartRecord == 0) {
         $iStartRecord = 1;
     }
     $iMaximumRecords = (int) $configRecordPerPage;
     // extract total hits from this result set
     $objXml = $this->getCache($id, "group", "SimpleXML");
     foreach ($objXml->xpath("//base_info") as $base_info) {
         if ($base_info->set_number == $strResultSet) {
             $strTotalHits = $base_info->no_of_documents;
             if ($strTotalHits == "888888888") {
                 $iTotalHits = 1;
             } else {
                 $iTotalHits = (int) $strTotalHits;
             }
         }
     }
     // set marc fields to return in response
     $arrFields = explode(",", $configMarcFields);
     // get results from metalib
     $objResultsXml = $objSearch->retrieve($strResultSet, $iStartRecord, $iMaximumRecords, $iTotalHits, "customize", $arrFields);
     // build the response, including previous cached data
     $objXml = new DOMDocument();
     $objXml = $this->documentElement();
     $objXml = $this->addSearchInfo($objXml, $id);
     $objXml = $this->addStatus($objXml, $id, $strResultSet, $iTotalHits);
     $objXml = $this->addProgress($objXml, $this->request->getSession("refresh-{$strGroup}"));
     // if this is a search-and-link resource add the original xml that contains the link
     if ($objResultsXml->getElementsByTagName("search_and_link")->item(0) != null) {
         $objImport = $objXml->importNode($objResultsXml->documentElement, true);
         $objXml->documentElement->appendChild($objImport);
         // this is a http post submission, so we need to see if we have added the post
         // data to the alternate record link in the IRD, since X-Server bug prevents this
         // from coming through in the response
         $objSearchType = $objResultsXml->getElementsByTagName("search_and_link_type")->item(0);
         if ($objSearchType != null) {
             if ($objSearchType->nodeValue == "POST") {
                 $objSearchXml = $this->getCache($id, "search", "SimpleXML");
                 $objGroupXml = $this->getCache($id, "group", "SimpleXML");
                 $databases_id = $objGroupXml->xpath("//base_info[set_number = '{$strResultSet}']/base_001");
                 if (count($databases_id) != 1) {
                     throw new Exception("cannot find search-and-link database in group cache");
                 }
                 $metalib_id = (string) $databases_id[0];
                 $databases = $objSearchXml->xpath("//database[@metalib_id='{$metalib_id}']");
                 if (count($databases) != 1) {
                     throw new Exception("cannot find database '{$metalib_id}' in search cache");
                 }
                 $database = $databases[0];
                 // the form action
                 $post = (string) $database->link_search_post;
                 // the data to be posted
                 $data = (string) $database->link_native_record_alternative;
                 if ($post == "" || $data == "") {
                     throw new Exception("cannot create http post elements for search-and-link database");
                 }
                 // xml close to what we need in html, just to make this easy
                 $objPostXML = $objXml->createElement("post");
                 $objXml->documentElement->appendChild($objPostXML);
                 $objForm = $objXml->createElement("form");
                 $objForm->setAttribute("action", Xerxes_Framework_Parser::escapeXml($post));
                 $objPostXML->appendChild($objForm);
                 foreach (explode("&", $data) as $pair) {
                     $arrKeys = explode("=", $pair);
                     $key = $arrKeys[0];
                     $value = $arrKeys[1];
                     // metalib docs say only TERM1 is used in the 'URL mask',
                     if ($value == "TERM1") {
                         $value = (string) $objSearchXml->pair[0]->query;
                     }
                     $objInput = $objXml->createElement("input");
                     $objInput->setAttribute("name", $key);
                     $objInput->setAttribute("value", $value);
                     $objForm->appendChild($objInput);
                 }
             }
         }
     } else {
         // add the records themselves
         foreach ($objResultsXml->getElementsByTagName("record") as $objRecord) {
             array_push($arrResults, $objRecord);
         }
         // this will also convert the marc-xml to xerxes_record, and check for an already
         // saved record
         $objXml = $this->addRecords($objXml, $arrResults, $configIncludeMarcRecord);
     }
     $objXml = $this->addFacets($objXml, $id, $configFacets);
     $this->request->addDocument($objXml);
     // echo time(true) - $start . "<br>";
     return 1;
 }
示例#8
0
 public function doExecute()
 {
     $this->add_export_options();
     // get request paramaters
     $strUsername = $this->request->getSession("username");
     $strOrder = $this->request->getProperty("sortKeys");
     $iStart = $this->request->getProperty("startRecord");
     $strReturn = $this->request->getProperty("return");
     $strLabel = $this->request->getProperty("label");
     $strType = $this->request->getProperty("type");
     $strView = $this->request->getProperty("view");
     // id numbers can come in the form of multiple 'record' params or a single
     // 'records' param, with the ids comma separated
     $arrID = $this->request->getProperty("record", true);
     $strIDs = $this->request->getProperty("records");
     if ($strIDs != null) {
         $arrID = explode(",", $strIDs);
     }
     // these are typically set in actions.xml
     $strLimit = $this->request->getProperty("limit");
     $strLoginOverride = $this->request->getProperty("doNotEnforceLogin");
     // configuration settings
     // default records per page is either set explicitly in saved_record_per_page in config
     // or is the main (metasearch) defaul_records_per_page or 20 which is the const
     $defaultMax = $this->registry->getConfig("DEFAULT_RECORDS_PER_PAGE", false, self::DEFAULT_RECORDS_PER_PAGE);
     $iCount = $this->registry->getConfig("SAVED_RECORDS_PER_PAGE", false, $defaultMax);
     $iCountExport = $this->registry->getConfig("MAXIMUM_RECORD_EXPORT_LIMIT", false, 1000);
     $configMarcBrief = $this->registry->getConfig("XERXES_BRIEF_INCLUDE_MARC", false, false);
     $configMarcFull = $this->registry->getConfig("XERXES_FULL_INCLUDE_MARC", false, false);
     // brief records and export actions should be set to export limit
     if ($strLimit == null) {
         $iCount = $iCountExport;
     }
     // save the return url back to metasearch page if specified
     if ($strReturn != "") {
         $this->request->setSession("SAVED_RETURN", $strReturn);
     }
     ### access control
     // can only override login if username is *NOT* supplied in the paramaters,
     // this prevents people from manually attempting this; 'doNotEnforceLogin'
     // must then only be used in conjunction with specific id numbers
     if ($this->request->getProperty("username") != null && $strLoginOverride != null) {
         throw new Exception("access denied");
     }
     // ensure this is the same user, unless 'doNotEnforceLogin' overrides this,
     // such as with RefWorks or other third-party export
     if ($strLoginOverride == null) {
         $strRedirect = $this->enforceUsername();
         if ($strRedirect != null) {
             $this->request->setRedirect($strRedirect);
             return 1;
         }
     }
     ### records
     // get the total number of records
     $iTotal = $this->getTotal($strUsername, $strLabel, $strType);
     // fetch result(s) from the database
     $objData = new Xerxes_DataMap();
     $arrResults = array();
     if ($arrID != "") {
         $arrResults = $objData->getRecordsByID($arrID);
     } elseif ($strLabel != "") {
         $arrResults = $objData->getRecordsByLabel($strUsername, $strLabel, $strOrder, $iStart, $iCount);
     } elseif ($strType != "") {
         $arrResults = $objData->getRecordsByFormat($strUsername, $strType, $strOrder, $iStart, $iCount);
     } else {
         $arrResults = $objData->getRecords($strUsername, $strView, $strOrder, $iStart, $iCount);
     }
     // create master results xml doc
     $objXml = new DOMDocument();
     $objXml->recover = true;
     $objXml->loadXML("<results />");
     if (count($arrResults) > 0) {
         $objRecords = $objXml->createElement("records");
         $objXml->documentElement->appendChild($objRecords);
         // @todo move this to point of save for search arch
         /* 
         enhance records with links generated from metalib templates,
         and get a list of databases too. We need to get the Xerxes_Records 
         out of our list of Xerxes_Data_Records first.
         */
         $xerxes_records = array();
         $database_links_dom = "";
         foreach ($arrResults as $objDataRecord) {
             if ($objDataRecord->xerxes_record instanceof Xerxes_MetalibRecord) {
                 array_push($xerxes_records, $objDataRecord->xerxes_record);
             }
         }
         if (count($xerxes_records) > 0) {
             Xerxes_MetalibRecord::completeUrlTemplates($xerxes_records, $this->request, $this->registry, $database_links_dom);
             $database_links = $objXml->importNode($database_links_dom->documentElement, true);
             $objXml->documentElement->appendChild($database_links);
         }
         /*  Add the records */
         foreach ($arrResults as $objDataRecord) {
             // create a new record
             $objRecord = $objXml->createElement("record");
             $objRecords->appendChild($objRecord);
             // full record url
             $arrParams = array("base" => "folder", "action" => "full", "username" => $strUsername, "record" => $objDataRecord->id);
             $url = $this->request->url_for($arrParams);
             $objUrlFull = $objXml->createElement("url_full", $url);
             $objRecord->appendChild($objUrlFull);
             // delete url
             $arrParams = array("base" => "folder", "action" => "delete", "username" => $strUsername, "source" => $objDataRecord->source, "id" => $objDataRecord->original_id, "type" => $strType, "label" => $strLabel, "startRecord" => $iStart, "total" => $iTotal, "sortKeys" => $strOrder, "recordsPerPage" => $iCount);
             $url = $this->request->url_for($arrParams);
             $objUrlDelete = $objXml->createElement("url_delete", $url);
             $objRecord->appendChild($objUrlDelete);
             // openurl link
             $arrParams = array("base" => "folder", "action" => "redirect", "type" => "openurl", "id" => $objDataRecord->id);
             $configLinkResolver = $this->registry->getConfig("LINK_RESOLVER_ADDRESS", true);
             $configSID = $this->registry->getConfig("APPLICATION_SID", false, "calstate.edu:xerxes");
             foreach ($objDataRecord->properties() as $key => $value) {
                 if ($key == "username" && $strLoginOverride != null) {
                     // exclude the username if login overridden, for privacy
                 } elseif ($key == "xerxes_record" && $value != null) {
                     // import the xerxes record
                     $objXerxesRecord = $value;
                     $objBibRecord = new DOMDocument();
                     $objBibRecord = $objXerxesRecord->toXML();
                     // import it
                     $objImportNode = $objXml->importNode($objBibRecord->documentElement, true);
                     $objRecord->appendChild($objImportNode);
                     // and openurl kev context object from record
                     $kev = Xerxes_Framework_Parser::escapeXml($objXerxesRecord->getOpenURL(null, $configSID));
                     $objOpenUrl = $objXml->createElement("openurl_kev_co", $kev);
                     $objRecord->appendChild($objOpenUrl);
                     // full open url
                     $url = Xerxes_Framework_Parser::escapeXml($objXerxesRecord->getOpenURL($configLinkResolver, $configSID));
                     $objUrlOpen = $objXml->createElement("url_open", $url);
                     $objRecord->appendChild($objUrlOpen);
                     // import the marc record, but only if configured to do so; since both brief
                     // and full record display come in on the same command, we'll use the record count
                     // here as an approximate for the brief versus full view -- hacky, hacky
                     $iNumRecords = count($arrID);
                     if ($strView != "brief" && $configMarcFull == true && $iNumRecords == 1 || $strView != "brief" && $configMarcBrief == true && $iNumRecords != 1) {
                         $objOriginalXml = $objXerxesRecord->getOriginalXML();
                         $objImportNode = $objXml->importNode($objOriginalXml->documentElement, true);
                         $objRecord->appendChild($objImportNode);
                     }
                 } else {
                     $objElement = $objXml->createElement($key, Xerxes_Framework_Parser::escapeXml($value));
                     $objRecord->appendChild($objElement);
                 }
             }
             $arrMulti = array("tags");
             foreach ($arrMulti as $multi) {
                 foreach ($objDataRecord->{$multi} as $value) {
                     // remove the trailing 's'
                     $single = substr($multi, 0, strlen($multi) - 1);
                     if ($value != null) {
                         $objElement = $objXml->createElement($single, Xerxes_Framework_Parser::escapeXml($value));
                         $objRecord->appendChild($objElement);
                     }
                 }
             }
         }
     }
     $this->request->addDocument($objXml);
     return 1;
 }
示例#9
0
 /**
  * Take search results and convert them to xml, with all the enhancements, including facets
  */
 public function resultsXML()
 {
     $this->url = $this->search_object->getURL();
     // get total and set in session
     if ($this->total == null) {
         $this->total = $this->search_object->getTotal();
     }
     $id = $this->getHashID() . "-" . $this->getHash();
     $this->request->setSession($id, number_format($this->total));
     $results_xml = new DOMDocument();
     $results_xml->loadXML("<results />");
     // other cached search hits?
     foreach ($this->request->getAllSession() as $session_id => $session_value) {
         if (strstr($session_id, $this->query_hash)) {
             $id = str_replace("-" . $this->query_hash, "", $session_id);
             $other = $results_xml->createElement("other", $session_value);
             $other->setAttribute("module", $id);
             $results_xml->documentElement->appendChild($other);
         }
     }
     // spelling
     $spelling_url = $this->linkSpelling();
     $spelling = $results_xml->createElement("spelling", Xerxes_Framework_Parser::escapeXml($this->request->getProperty("spelling_query")));
     $spelling->setAttribute("url", $spelling_url);
     $results_xml->documentElement->appendChild($spelling);
     // add in the original url for debugging
     $search_url = $results_xml->createElement("search_url", Xerxes_Framework_Parser::escapeXml($this->url));
     $results_xml->documentElement->appendChild($search_url);
     // add total
     $total = $results_xml->createElement("total", number_format($this->total));
     $results_xml->documentElement->appendChild($total);
     // add facets that have been selected
     $facets_chosen = $this->request->getProperties("facet.*", true);
     if (count($facets_chosen) > 0) {
         $facet_applied = $results_xml->createElement("facets_applied");
         $results_xml->documentElement->appendChild($facet_applied);
         foreach ($facets_chosen as $key => $facet) {
             $facet_level = $results_xml->createElement("facet_level", Xerxes_Framework_Parser::escapeXml($facet));
             $facet_applied->appendChild($facet_level);
             $url = new Xerxes_Framework_Request_URL($this->currentParams());
             $url->removeProperty($key, $facet);
             $remove_url = $this->request->url_for($url);
             $facet_level->setAttribute("url", $remove_url);
         }
     }
     if (count($this->results) > 0) {
         ## records
         $records_xml = $results_xml->createElement("records");
         $results_xml->documentElement->appendChild($records_xml);
         foreach ($this->results as $result) {
             $record_container = $results_xml->createElement("record");
             $records_xml->appendChild($record_container);
             // full-record link
             $record_link = Xerxes_Framework_Parser::escapeXml($this->linkFullRecord($result));
             $link_full = $results_xml->createElement("url", $record_link);
             $record_container->appendChild($link_full);
             // this one for backwards compatibility
             $link_full = $results_xml->createElement("url_full", $record_link);
             $record_container->appendChild($link_full);
             // open-url link (which may be a redirect)
             $record_openurl = Xerxes_Framework_Parser::escapeXml($this->linkOpenURL($result));
             $link_full = $results_xml->createElement("url_open", $record_openurl);
             $record_container->appendChild($link_full);
             // sms link
             $record_sms = Xerxes_Framework_Parser::escapeXml($this->linkSMS($result));
             $link_sms = $results_xml->createElement("url_sms", $record_sms);
             $record_container->appendChild($link_sms);
             // save or delete link
             $record_save = Xerxes_Framework_Parser::escapeXml($this->linkSaveRecord($result));
             $link_save = $results_xml->createElement("url_save", $record_save);
             $record_container->appendChild($link_save);
             // this one for backwards compatibility
             $link_save = $results_xml->createElement("url_save_delete", $record_save);
             $record_container->appendChild($link_save);
             // openurl kev context object please
             $kev = Xerxes_Framework_Parser::escapeXml($result->getOpenURL(null, $this->sid));
             $open_url = $results_xml->createElement("openurl_kev_co", $kev);
             $record_container->appendChild($open_url);
             // other links (probably things like author, subject links)
             $this->linkOther($result, $results_xml, $record_container);
             // xerxes-record
             $xerxes_xml = $result->toXML();
             $import = $results_xml->importNode($xerxes_xml->documentElement, true);
             $record_container->appendChild($import);
             // optionally import original xml
             if ($this->include_original == true) {
                 $original_xml = $result->getOriginalXML();
                 $original_node = $original_xml;
                 if ($original_xml instanceof DOMDocument) {
                     $original_node = $original_xml->documentElement;
                 }
                 $import = $results_xml->importNode($original_node, true);
                 $record_container->appendChild($import);
             }
         }
         ## recommendations
         if (count($this->recommendations) > 0) {
             $recommend_xml = $results_xml->createElement("recommendations");
             $results_xml->documentElement->appendChild($recommend_xml);
             foreach ($this->recommendations as $record) {
                 $record_xml = $results_xml->createElement("record");
                 $recommend_xml->appendChild($record_xml);
                 $import = $results_xml->importNode($record->toXML()->documentElement, true);
                 $record_xml->appendChild($import);
                 $open_url = $record->getOpenURL($this->link_resolver, $this->sid);
                 $open_url_xml = $results_xml->createElement("url_open", Xerxes_Framework_Parser::escapeXML($open_url));
                 $record_xml->appendChild($open_url_xml);
             }
         }
         $objPage = new Xerxes_Framework_Page();
         ## summary
         $summary_xml = $objPage->summary($this->total, (int) $this->request->getProperty("startRecord"), $this->max);
         if ($summary_xml->documentElement != null) {
             $import = $results_xml->importNode($summary_xml->documentElement, true);
             $results_xml->documentElement->appendChild($import);
         }
         ## sorting
         $arrParams = $this->sortLinkParams();
         $query_string = $this->request->url_for($arrParams);
         $sort_options = $this->sortOptions();
         $current_sort = $this->sort;
         if ($current_sort == null) {
             $current_sort = $this->sort_default;
         }
         $sort_xml = $objPage->sortDisplay($query_string, $current_sort, $sort_options);
         $import = $results_xml->importNode($sort_xml->documentElement, true);
         $results_xml->documentElement->appendChild($import);
         ## pager
         $arrParams = $this->pagerLinkParams();
         $pager_xml = $objPage->pager_dom($arrParams, "startRecord", (int) $this->request->getProperty("startRecord"), null, (int) $this->total, $this->max, $this->request);
         $import = $results_xml->importNode($pager_xml->documentElement, true);
         $results_xml->documentElement->appendChild($import);
     }
     ## facets
     $facets = $this->facets->toXML();
     $import = $results_xml->importNode($facets->documentElement, true);
     $results_xml->documentElement->appendChild($import);
     return $results_xml;
 }
示例#10
0
 /**
  * Add global array as xml to request xml document
  *
  * @param DOMDocument $objXml		[by reference] request xml document
  * @param DOMNode $objAppend		[by reference] node to append values to
  * @param array $arrValues			global array
  */
 private function addElement(&$objXml, &$objAppend, $arrValues)
 {
     foreach ($arrValues as $key => $value) {
         // need to make sure the xml element has a valid name
         // and not something crazy with spaces or commas, etc.
         $strSafeKey = Xerxes_Framework_Parser::strtolower(preg_replace('/\\W/', '_', $key));
         if (is_array($value)) {
             foreach ($value as $strKey => $strValue) {
                 $objElement = $objXml->createElement($strSafeKey);
                 $objElement->setAttribute("key", $strKey);
                 $objAppend->appendChild($objElement);
                 if (is_array($strValue)) {
                     // multi-dimensional arrays will be recursively added
                     $this->addElement($objXml, $objElement, $strValue);
                 } else {
                     $objElement->nodeValue = Xerxes_Framework_Parser::escapeXml($strValue);
                 }
             }
         } else {
             $objElement = $objXml->createElement($strSafeKey, Xerxes_Framework_Parser::escapeXml($value));
             $objAppend->appendChild($objElement);
         }
     }
 }
示例#11
0
 /**
  * Creates a sorting page element
  *
  * @param string $strSortQuery	initial page and querystring values
  * @param string $strSortKeys	selected sort value
  * @param array $arrOptions		list of sort options and values
  * @return DOMDocument 			paging navigation
  */
 public function sortDisplay($strSortQuery, $strSortKeys, $arrOptions)
 {
     $objXml = new DOMDocument();
     $objXml->loadXML("<sort_display />");
     $strBase = "";
     if (strstr($strSortQuery, "?")) {
         $strBase = "{$strSortQuery}&sortKeys";
     } else {
         $strBase = "{$strSortQuery}?sortKeys";
     }
     $x = 1;
     foreach ($arrOptions as $key => $value) {
         if ($key == $strSortKeys) {
             $objHere = $objXml->createElement("option", $value);
             $objHere->setAttribute("active", "true");
             $objXml->documentElement->appendChild($objHere);
         } else {
             $objHere = $objXml->createElement("option", $value);
             $objHere->setAttribute("active", "false");
             $objHere->setAttribute("link", Xerxes_Framework_Parser::escapeXml("{$strBase}={$key}"));
             $objXml->documentElement->appendChild($objHere);
         }
         $x++;
     }
     return $objXml;
 }
 public function doExecute()
 {
     $objXml = new DOMDOcument();
     $objXml->loadXML("<category />");
     $strSubject = $this->request->getProperty("subject");
     $strUser = $this->request->getProperty("username");
     $objData = new Xerxes_DataMap();
     $objCategoryData = null;
     //  only fetch if we actually have params, avoid the fetch-everything phenomena
     if ($strSubject && $strUser) {
         $objCategoryData = $objData->getSubject($strSubject, null, Xerxes_DataMap::userCreatedMode, $strUser);
     }
     // if there hasn't
     if (!$objCategoryData) {
         if ($this->request->getRedirect()) {
             // nevermind, we're in the creation process, already redirected,
             // just end now.
             return 1;
         } else {
             throw new Xerxes_Exception_NotFound("text_collections_error_personal_collection_not_found");
         }
     }
     // make sure they have access
     if (!$objCategoryData->published) {
         Xerxes_Helper::ensureSpecifiedUser($objCategoryData->owned_by_user, $this->request, $this->registry, "text_collections_error_private_collection");
     }
     $y = 1;
     if ($objCategoryData != null) {
         $objXml->documentElement->setAttribute("name", $objCategoryData->name);
         $objXml->documentElement->setAttribute("normalized", $objCategoryData->normalized);
         $objXml->documentElement->setAttribute("owned_by_user", $objCategoryData->owned_by_user);
         $objXml->documentElement->setAttribute("published", $objCategoryData->published);
         // we treat the 'default' collection (usually 'My Saved Records') special
         // giving it less flexibility for simplicity, in the XSL/javascript.
         if ($this->isDefaultCollection($objCategoryData)) {
             $objXml->documentElement->setAttribute("is_default_collection", "yes");
         }
         // standard url for the category
         $arrParams = array("base" => "collections", "action" => "subject", "username" => $strUser, "subject" => $objCategoryData->normalized);
         $url = Xerxes_Framework_Parser::escapeXml($this->request->url_for($arrParams));
         $objElement = $objXml->createElement("url", $url);
         $objXml->documentElement->appendChild($objElement);
         //edit url for the user-created category
         $arrParams = array("base" => "collections", "action" => "edit_form", "username" => $strUser, "subject" => $objCategoryData->normalized);
         $url = Xerxes_Framework_Parser::escapeXml($this->request->url_for($arrParams));
         $objElement = $objXml->createElement("edit_url", $url);
         $objXml->documentElement->appendChild($objElement);
         // the attributes of the subcategories
         $db_list_index = 1;
         foreach ($objCategoryData->subcategories as $objSubData) {
             $objSubCategory = $objXml->createElement("subcategory");
             $objSubCategory->setAttribute("name", $objSubData->name);
             $objSubCategory->setAttribute("position", $y);
             $objSubCategory->setAttribute("id", $objSubData->id);
             $y++;
             // the database information
             foreach ($objSubData->databases as $objDatabaseData) {
                 $objDatabase = Xerxes_Helper::databaseToNodeset($objDatabaseData, $this->request, $this->registry, $db_list_index);
                 $objDatabase = $objXml->importNode($objDatabase, true);
                 $objSubCategory->appendChild($objDatabase);
             }
             $objXml->documentElement->appendChild($objSubCategory);
         }
     }
     $this->request->addDocument($objXml);
     return 1;
 }
示例#13
0
 public function toXML()
 {
     $xml = new DOMDocument();
     $xml->loadXML("<item />");
     foreach ($this as $key => $value) {
         if ($value == "") {
             continue;
         }
         $key = preg_replace('/\\W|\\s/', '', $key);
         $element = $xml->createElement($key, Xerxes_Framework_Parser::escapeXml($value));
         $xml->documentElement->appendChild($element);
     }
     return $xml;
 }
示例#14
0
 public function doExecute()
 {
     // metalib search object
     $objSearch = $this->getSearchObject();
     // params from the request
     $strQuery = $this->request->getProperty("query");
     $strQuery2 = $this->request->getProperty("query2");
     $strField = $this->request->getProperty("field");
     $strField2 = $this->request->getProperty("field2");
     $strFindOperator = $this->request->getProperty("find_operator1");
     $arrDatabases = $this->request->getProperty("database", true);
     $strSubject = $this->request->getProperty("subject");
     $strSpell = $this->request->getProperty("spell");
     $strContext = $this->request->getProperty("context");
     $strContextUrl = $this->request->getProperty("context_url");
     // configuration options
     $configNormalize = $this->registry->getConfig("NORMALIZE_QUERY", false, false);
     $configBaseUrl = $this->registry->getConfig("BASE_URL", true);
     $configYahooID = $this->registry->getConfig("YAHOO_ID", false, "calstate");
     $configSearchLimit = $this->registry->getConfig("SEARCH_LIMIT", true);
     $configContextUrl = $this->registry->getConfig("LIMIT_CONTEXT_URL", false);
     //  if so configured, ensure that context_url is limited to certain domain(s)
     if ($configContextUrl != null) {
         $bolPassed = Xerxes_Framework_Parser::withinDomain($strContextUrl, $configContextUrl);
         if ($bolPassed == false) {
             throw new Exception("context_url only allowed for specified domains");
         }
     }
     // database communications object
     $objData = new Xerxes_DataMap();
     // if subject is given but not databases, automatically find
     // databases for subject, from first sub-category.
     if ($strSubject != null && count($arrDatabases) == 0) {
         $search_limit = $this->registry->getConfig("SEARCH_LIMIT", true);
         $arrDatabases = array();
         $objSubject = $objData->getSubject(strtolower($strSubject), null, "metalib", null, $this->request->getProperty("lang"));
         // did we find a subject that has subcategories?
         if ($objSubject != null && $objSubject->subcategories != null && count($objSubject->subcategories) > 0) {
             $subs = $objSubject->subcategories;
             $objSubcategory = $subs[0];
             $index = 0;
             // get databases up to search limit from first subcat,
             // add to $arrdatabases.
             foreach ($objSubcategory->databases as $objDatabaseData) {
                 if ($objDatabaseData->searchable == 1) {
                     array_push($arrDatabases, $objDatabaseData->metalib_id);
                     $index++;
                 }
                 if ($index >= $search_limit) {
                     break;
                 }
             }
         }
     }
     // if we have a subject, but no context/contexturl, look
     // them up for the subject. Allows convenient defaults
     // for direct-linking into search results.
     if ($strContext == "" && $strSubject != "") {
         // look up the subject if we haven't already, to get the name.
         if (!isset($objSubject)) {
             $objSubject = $objData->getSubject($strSubject);
         }
         $strContext = $objSubject->name;
     }
     if ($strContextUrl == "" && $strSubject != "") {
         $strContextUrl = $this->request->url_for(array("base" => "databases", "action" => "subject", "subject" => $strSubject));
     }
     // ensure a query and field
     if ($strQuery == "") {
         throw new Exception("text_metasearch_error_no_search_terms");
     }
     if ($strField == "") {
         $strField = "WRD";
     }
     if ($strField2 == "") {
         $strField2 = "WRD";
     }
     if ($strFindOperator == "") {
         $strFindOperator = "AND";
     }
     // get databases
     $arrDB = $objData->getDatabases($arrDatabases);
     // start out database information xml object.
     $objXml = new DOMDocument();
     $objXml->loadXML("<search />");
     // access control for databases
     $excludedDbs = array();
     $excludedIDs = array();
     foreach ($arrDB as $db) {
         if (!Xerxes_Helper::dbSearchableForUser($db, $this->request, $this->registry)) {
             $excludedDbs[] = $db;
             $excludedIDs[] = (string) $db->metalib_id;
         }
     }
     if (count($excludedDbs) > 0) {
         // remove excluded dbs from our db lists. what a pain in php, sorry.
         foreach ($arrDB as $key => $db) {
             if (in_array((string) $db->metalib_id, $excludedIDs)) {
                 unset($arrDB[$key]);
             }
         }
         foreach ($arrDatabases as $key => $id) {
             if (in_array($id, $excludedIDs)) {
                 unset($arrDatabases[$key]);
             }
         }
         // and make a note of the excluded dbs please.
         $excluded_xml = $objXml->createElement("excluded_dbs");
         $objXml->documentElement->appendChild($excluded_xml);
         foreach ($excludedDbs as $db) {
             $element = Xerxes_Helper::databaseToNodeset($db, $this->request, $this->registry);
             $element = $objXml->importNode($element, true);
             $excluded_xml->appendChild($element);
         }
     }
     // ensure correct number of databases selected
     if (count($arrDatabases) < 1 && count($excludedDbs) > 0) {
         $e = new Xerxes_Exception_DatabasesDenied("text_metasearch_error_not_authorized");
         $e->setDeniedDatabases($excludedDbs);
         throw $e;
     } elseif (count($arrDatabases) < 1) {
         throw new Exception("text_metasearch_error_no_databases");
     }
     if (count($arrDatabases) > $configSearchLimit) {
         $labels = Xerxes_Framework_Labels::getInstance();
         $error = $labels->getLabel("text_metasearch_error_too_many_databases");
         $error = sprintf($error, $configSearchLimit);
         throw new Exception($error);
     }
     $strSpellCorrect = "";
     // spelling correction
     $strSpellUrl = "";
     // return url for spelling change
     $strGroup = "";
     // group id number
     $strNormalizedQuery = "";
     // normalized query
     // query parser provides normalization and spell check
     $objQueryParser = new Xerxes_QueryParser();
     // normalize query option is still experimental (2009-04-16)
     $strFullQuery = $objQueryParser->normalizeMetalibQuery($strField, $strQuery, $strFindOperator, $strField2, $strQuery2, $configNormalize);
     // initiate search with Metalib
     $strGroup = $objSearch->search($strFullQuery, $arrDatabases);
     // something went wrong, yo!
     if ($strGroup == "") {
         throw new Exception("Could not initiate search with Metalib server");
     }
     // check spelling unless this is a return submission from a previous spell correction
     $strSpellSuggestions = null;
     if ($strSpell == null) {
         // check spelling
         $strAltYahoo = $this->registry->getConfig("ALTERNATE_YAHOO_LOCATION", false);
         $strSpellCorrect = $objQueryParser->checkSpelling($strQuery, $configYahooID, $strAltYahoo);
         $strSpellCorrect2 = null;
         if ($strQuery2) {
             $strSpellCorrect2 = $objQueryParser->checkSpelling($strQuery2, $configYahooID);
         }
         if ($strSpellCorrect != "" || $strSpellCorrect2 != "") {
             // construct spell check return url with spelling suggestion
             // If both search fields were used (advanced search), spell corrections
             // may be in first, second, or both.
             $strNewQuery = $strQuery;
             $arrSuggestions = array();
             if ($strSpellCorrect) {
                 $strNewQuery = $strSpellCorrect;
                 array_push($arrSuggestions, $strSpellCorrect);
             }
             $strNewQuery2 = $strQuery2;
             if ($strSpellCorrect2) {
                 $strNewQuery2 = $strSpellCorrect2;
                 array_push($arrSuggestions, $strSpellCorrect2);
             }
             $strSpellSuggestions = join(" ", $arrSuggestions);
             $strSpellUrl = "./?base=metasearch&action=search&spell=1&query=" . urlencode($strNewQuery) . "&field=" . $strField;
             if ($strNewQuery2) {
                 $strSpellUrl .= "&query2=" . urlencode($strNewQuery2) . "&field2=" . $strField2;
             }
             $strSpellUrl .= "&context=" . urlencode($strContext);
             $strSpellUrl .= "&context_url=" . urlencode($strContextUrl);
             foreach ($arrDatabases as $strDatabase) {
                 if ($strDatabase != null) {
                     $strSpellUrl .= "&database=" . $strDatabase;
                 }
             }
         }
     }
     // create search information xml
     $arrSearch = array();
     $arrSearch["date"] = date("Y-m-d");
     $arrSearch["spelling"] = $strSpellSuggestions;
     $arrSearch["spelling_url"] = $strSpellUrl;
     $arrSearch["context"] = $strContext;
     $arrSearch["context_url"] = $strContextUrl;
     foreach ($arrSearch as $key => $value) {
         $objElement = $objXml->createElement($key, Xerxes_Framework_Parser::escapeXml($value));
         $objXml->documentElement->appendChild($objElement);
     }
     $objPair = $objXml->createElement("pair");
     $objPair->setAttribute("position", 1);
     $objXml->documentElement->appendChild($objPair);
     $arrQuery = array();
     $arrQuery["query"] = $strQuery;
     $arrQuery["field"] = $strField;
     $arrQuery["normalized"] = $strFullQuery;
     foreach ($arrQuery as $key => $value) {
         $objElement = $objXml->createElement($key, Xerxes_Framework_Parser::escapeXml($value));
         $objPair->appendChild($objElement);
     }
     // add second pair if present.
     if ($strQuery2) {
         $objOperator = $objXml->createElement("operator", $strFindOperator);
         $objOperator->setAttribute("position", 1);
         $objXml->documentElement->appendChild($objOperator);
         $objPair = $objXml->createElement("pair");
         $objPair->setAttribute("position", 2);
         $objXml->documentElement->appendChild($objPair);
         $arrQuery = array();
         $arrQuery["query"] = $strQuery2;
         $arrQuery["field"] = $strField2;
         foreach ($arrQuery as $key => $value) {
             $objElement = $objXml->createElement($key, Xerxes_Framework_Parser::escapeXml($value));
             $objPair->appendChild($objElement);
         }
     }
     // get links from ird records for those databases that have been included in the search and
     // store it here so we can get at this information easily on any subsequent page without having
     // to go back to the database
     $objDatabaseLinks = $objXml->createElement("database_links");
     $objXml->documentElement->appendChild($objDatabaseLinks);
     foreach ($arrDB as $objDatabase) {
         // create a database node and append to database_links
         $objNodeDatabase = Xerxes_Helper::databaseToLinksNodeset($objDatabase, $this->request, $this->registry);
         $objNodeDatabase = $objXml->importNode($objNodeDatabase, true);
         $objDatabaseLinks->appendChild($objNodeDatabase);
     }
     // add any warnings from metalib
     $objWarnings = $objSearch->getWarnings();
     if ($objWarnings != null) {
         $objImport = $objXml->importNode($objWarnings->documentElement, true);
         $objXml->documentElement->appendChild($objImport);
     }
     $strGroup = $this->getSearchDate() . "-" . $strGroup;
     // save this information in the cache
     $this->setCache($strGroup, "search", $objXml);
     // redirect to hits page
     $arrParams = array("base" => "metasearch", "action" => "hits", "group" => $strGroup);
     $this->saveCache();
     $this->request->setRedirect($this->request->url_for($arrParams));
     return 1;
 }
示例#15
0
 /**
  * Converts records from marc to xerxes_record and adds them to the master xml response
  * Also adds info on whether the record has already been saved this session. 
  *
  * @param DOMDOcument $objXml		master xml document
  * @param array $arrRecords			an array of marc records
  * @param bool $configMarcResults	whether to append the original marc records to the response
  * @return DOMDOcument				master xml response updated with record data
  */
 protected function addRecords($objXml, $arrRecords, $configMarcResults)
 {
     $objRecords = $objXml->createElement("records");
     $arrXerxesRecords = array();
     foreach ($arrRecords as $objRecord) {
         $objXerxesRecord = new Xerxes_MetalibRecord();
         $objXerxesRecord->loadXml($objRecord);
         array_push($arrXerxesRecords, $objXerxesRecord);
     }
     // enhance with links computed from metalib templates.
     Xerxes_MetalibRecord::completeUrlTemplates($arrXerxesRecords, $this->request, $this->registry);
     $position = $this->request->getProperty("startRecord");
     if ($position == "") {
         $position = 1;
     }
     foreach ($arrXerxesRecords as $objXerxesRecord) {
         $objRecordContainer = $objXml->createElement("record");
         $objRecords->appendChild($objRecordContainer);
         // basis for most of the links below
         $arrParams = array("base" => "metasearch", "group" => $this->request->getProperty("group"), "resultSet" => $objXerxesRecord->getResultSet(), "startRecord" => $objXerxesRecord->getRecordNumber());
         // full-text link
         $arrFullText = $arrParams;
         $arrFullText["action"] = "record";
         if ($this->request->getProperty("facet") != "") {
             // append this so the full record page knows how to get back
             $arrFullText["return"] = Xerxes_Framework_Parser::escapeXml($this->request->getServer("REQUEST_URI"));
         } else {
             // this is a regular (non-facet) result
             // we keep current resultset and position (rather than original resultset
             // and recordNumber) for the benefit of the merged set where these are different
             $arrFullText["resultSet"] = $this->request->getProperty("resultSet");
             $arrFullText["startRecord"] = $position;
         }
         $url = $this->request->url_for($arrFullText);
         $objUrlFull = $objXml->createElement("url_full", $url);
         $objRecordContainer->appendChild($objUrlFull);
         // save-delete link
         $arrSave = $arrParams;
         $arrSave["action"] = "save-delete";
         $url = $this->request->url_for($arrSave);
         $objUrlSave = $objXml->createElement("url_save_delete", $url);
         $objRecordContainer->appendChild($objUrlSave);
         // openurl redirect link
         $arrOpen = $arrParams;
         $arrOpen["action"] = "sfx";
         $url = $this->request->url_for($arrOpen);
         $objOpenUrl = $objXml->createElement("url_open", $url);
         $objRecordContainer->appendChild($objOpenUrl);
         // openurl kev context object please
         $configSID = $this->registry->getConfig("APPLICATION_SID", false, "calstate.edu:xerxes");
         $kev = Xerxes_Framework_Parser::escapeXml($objXerxesRecord->getOpenURL(null, $configSID));
         $objOpenUrl = $objXml->createElement("openurl_kev_co", $kev);
         $objRecordContainer->appendChild($objOpenUrl);
         // import xerxes xml
         $objXerxesXml = $objXerxesRecord->toXML();
         $objImportRecord = $objXml->importNode($objXerxesXml->documentElement, true);
         $objRecordContainer->appendChild($objImportRecord);
         // optionally import marc-xml
         if ($configMarcResults == true) {
             $objMarcRecord = $objXerxesRecord->getMarcXML();
             $objImportRecord = $objXml->importNode($objMarcRecord->getElementsByTagName("record")->item(0), true);
             $objRecordContainer->appendChild($objImportRecord);
         }
         $position++;
     }
     $objXml->documentElement->appendChild($objRecords);
     return $objXml;
 }