function do_indices($node) { $this->indices = array(); $doc = new DOMDOcument(); $i_node = $doc->importNode($node, true); $xpath = new DOMXPath($doc); $count = 0; foreach ($i_node->childNodes as $cell) { if (!$cell instanceof DOMElement || $cell->tagName != 'Cell') { //could be text node with whitespace continue; } $count++; $header = $cell->textContent; $this->indices[$header] = $count; } }
public function doExecute() { $objXml = new DOMDOcument(); $objXml->loadXML("<databases />"); $strID = $this->request->getProperty("id"); $strQuery = $this->request->getProperty("query"); $alpha = $this->request->getProperty("alpha"); $objDataMap = new Xerxes_DataMap(); $arrResults = array(); if ($strID) { $arrResults = $objDataMap->getDatabases($strID); if (count($arrResults) == 0) { throw new Xerxes_Exception_NotFound("Can not find database with id {$strID}"); } } elseif ($alpha != "") { $this->addAlphaList(); $arrResults = $objDataMap->getDatabasesStartingWith($alpha); } elseif ($strQuery) { $arrResults = $objDataMap->getDatabases(null, $strQuery); } elseif ($this->request->getProperty("suppress_full_db_list") != "true") { $this->addAlphaList(); // only show single letters, please if ($this->registry->getConfig("DATABASE_LIST_SINGLE_LETTER_DISPAY", false, false) && $this->request->getProperty("action") == "alphabetical") { $params = array("base" => "databases", "action" => "alphabetical", "alpha" => "A"); $link = $this->request->url_for($params); $this->request->setRedirect($link); return 0; } // all database $arrResults = $objDataMap->getDatabases(); } foreach ($arrResults as $objDatabaseData) { $objDatabase = Xerxes_Helper::databaseToNodeset($objDatabaseData, $this->request, $this->registry); $objDatabase = $objXml->importNode($objDatabase, true); $objXml->documentElement->appendChild($objDatabase); } $this->request->addDocument($objXml); return 1; }
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; }
/** * 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; }