function getDescriptionByRecordId() { global $configArray; //Load the record id that the user wants to search for $recordId = trim($_REQUEST['recordId']); // Setup Search Engine Connection $class = $configArray['Index']['engine']; $url = $configArray['Index']['url']; /** @var SearchObject_Solr db */ $this->db = new $class($url); //Search the database by title and author if ($recordId) { if (preg_match('/^b\\d{7}[\\dx]$/', $recordId)) { $recordId = '.' . $recordId; } $searchResults = $this->db->search("{$recordId}", 'Id'); } else { $results = array('result' => false, 'message' => 'Please enter the record Id to look for'); return $results; } if ($searchResults['response']['numFound'] == 0) { $results = array('result' => false, 'message' => 'Sorry, we could not find a description for that record id'); } else { $firstRecord = $searchResults['response']['docs'][0]; require_once ROOT_DIR . '/RecordDrivers/GroupedWorkDriver.php'; $groupedWork = new GroupedWorkDriver($firstRecord); $results = array('result' => true, 'message' => 'Found a summary for record ' . $firstRecord['title_display'] . ' by ' . $firstRecord['author_display'], 'recordsFound' => $searchResults['response']['numFound'], 'description' => $groupedWork->getDescription()); } return $results; }