diff --git a/SearchClass.inc b/SearchClass.inc
deleted file mode 100644
index 473076a1..00000000
--- a/SearchClass.inc
+++ /dev/null
@@ -1,612 +0,0 @@
- $e->getMessage()), NULL, WATCHDOG_ERROR);
- return 'Error getting solr search results class. Check watchdog for more info.';
- }
- return $implementation->$solrFunction($query, $startPage, $fq, $dismax);
- }
-
- /**
- * build solr search form ??
- * @param type $repeat
- * @param type $pathToSearchTerms
- * @param type $query
- * @return type
- */
- function build_solr_search_form($repeat = NULL, $pathToSearchTerms = NULL, $query = NULL) {
- $types = $this->get_search_terms_array(NULL, 'solrSearchTerms.xml');
- $queryArray = NULL;
- if (isset($query)) {
- $queryArray = explode('AND', $query);
- }
-
- $andOrArray = array(
- 'AND' => 'and',
- //'OR' => 'or' //removed or for now as it would be a pain to parse
- );
- $form = array();
-
- if (!isset($repeat)) {
- $repeat = variable_get('islandora_solr_search_block_repeat', t('3'));
- }
- $var0 = explode(':', $queryArray[0]);
- $var1 = explode(':', $queryArray[1]);
- $form['search_type']['type1'] = array(
- '#title' => t(''),
- '#type' => 'select',
- '#options' => $types,
- '#default_value' => trim($var0[0])
- );
- $form['fedora_terms1'] = array(
- '#size' => '24',
- '#type' => 'textfield',
- '#title' => t(''),
- '#required' => TRUE,
- '#default_value' => (count($var0) >= 2 ? trim($var0[1]) : ''),
- );
- $form['andor1'] = array(
- '#title' => t(''),
- '#type' => 'select',
- '#default_value' => 'AND',
- '#options' => $andOrArray
- );
- $form['search_type']['type2'] = array(
- '#title' => t(''),
- '#type' => 'select',
- '#options' => $types,
- '#default_value' => (count($var1) >= 2 ? trim($var1[0]) : ''),
- );
- $form['fedora_terms2'] = array(
- '#size' => '24',
- '#type' => 'textfield',
- '#title' => t(''),
- '#default_value' => (count($var1) >= 2 ? $var1[1] : ''),
- );
- if ($repeat > 2 && $repeat < 9) { //don't want less then 2 or more then 9
- for ($i = 3; $i < $repeat + 1; $i++) {
- $t = $i - 1;
- $field_and_term = explode(':', $queryArray[$t]);
- $form["andor$t"] = array(
- '#title' => t(''),
- '#type' => 'select',
- '#default_value' => 'AND',
- '#options' => $andOrArray
- );
- $form['search_type']["type$i"] = array(
- '#title' => t(''),
- '#type' => 'select',
- '#options' => $types,
- '#default_value' => trim($field_and_term[0])
- );
- $form["fedora_terms$i"] = array(
- '#size' => '24',
- '#type' => 'textfield',
- '#title' => t(''),
- '#default_value' => (count($field_and_term) >= 2 ? trim($field_and_term[1]) : ''),
- );
- }
- }
-
- $form['submit'] = array(
- '#type' => 'submit',
- '#value' => t('search')
- );
- return $form;
- }
-
- /**
- * build simple solr form ??
- * @return string
- */
- function build_simple_solr_form() {
- //$form = array();
- $form["search_query"] = array(
- '#size' => '30',
- '#type' => 'textfield',
- '#title' => t(''),
- // '#default_value' => (count($field_and_term) >= 2 ? trim($field_and_term[1]) : ''),
- );
- $form['submit'] = array(
- '#type' => 'submit',
- '#value' => t('search')
- );
- return $form;
- }
-
- /**
- * theme solr search form ??
- * @param type $form
- * @return type
- */
- function theme_solr_search_form($form) {
- if (!isset($repeat)) {
- $repeat = variable_get('islandora_solr_search_block_repeat', t('3'));
- }
-
- $output = drupal_render($form['search_type']['type1']);
- $output .= drupal_render($form['fedora_terms1']);
- $output .= drupal_render($form['andor1']) . drupal_render($form['search_type']['type2']);
- $output .= drupal_render($form['fedora_terms2']);
- if ($repeat > 2 && $repeat < 9) {
- for ($i = 3; $i < $repeat + 1; $i++) {
- $t = $i - 1;
- $output .= drupal_render($form["andor$t"]) . drupal_render($form['search_type']["type$i"]);
- $output .= drupal_render($form["fedora_terms$i"]);
- }
- }
- $output .= drupal_render($form['submit']);
- $output .= drupal_render($form);
- return $output;
- }
-
- /**
- * quick search ??
- * @param type $type
- * @param type $query
- * @param type $showForm
- * @param type $orderBy
- * @param type $userArray
- * @return type
- */
- function quickSearch($type, $query, $showForm = 1, $orderBy = 0, & $userArray) {
- module_load_include('inc', 'fedora_repository', 'ObjectHelper');
- module_load_include('inc', 'fedora_repository', 'api/fedora_utils');
- if (user_access('view fedora collection')) {
- $numberOfHistPerPage = '5000'; //hack for IR they do not want next button
- $luceneQuery = NULL;
- // Demo search string ?operation=gfindObjects&indexName=DemoOnLucene&query=fgs.DS.first.text%3Achristmas&hitPageStart=11&hitPageSize=10
- $keywords = explode(' ', $query);
-
- foreach ($keywords as $keyword) {
- $luceneQuery .= $type . ':' . $keyword . '+AND+';
- }
- $luceneQuery = substr($luceneQuery, 0, strlen($luceneQuery) - 5);
-
- $indexName = variable_get('fedora_index_name', 'DemoOnLucene');
- $keys = htmlentities(urlencode($query));
- $searchUrl = variable_get('fedora_fgsearch_url', 'http://localhost:8080/fedoragsearch/rest');
- $searchString = '?operation=gfindObjects&indexName=' . $indexName . '&restXslt=copyXml&query=' . $luceneQuery;
- $searchString .= '&hitPageSize=' . $numberOfHistPerPage . '&hitPageStart=1';
- //$searchString = htmlentities($searchString);
- $searchUrl .= $searchString;
-
- // $objectHelper = new ObjectHelper();
-
- $resultData = do_curl($searchUrl, 1);
- if (isset($userArray)) {
- $doc = new DOMDocument();
- $doc->loadXML($resultData);
- $xPath = new DOMXPath($doc);
- // Add users to department list. This is a hack as not all users will be in dupal
- $nodeList = $xPath->query('//field[@name="refworks.u1"]');
- foreach ($nodeList as $node) {
- if (!in_array($node->nodeValue, $userArray)) {
- $userArray[] = $node->nodeValue;
- }
- }
- }
- if ($showForm) {
- $output = 'Quick Search
';
- }
- $output .= $this->applyXSLT($resultData, $orderBy);
- return $output;
- }
- }
-
- /**
- * gets term from a lucene index and displays them in a list
- * @param type $fieldName
- * @param type $startTerm
- * @param type $displayName
- * @return type
- */
- function getTerms($fieldName, $startTerm, $displayName = NULL) {
- module_load_include('inc', 'fedora_repository', 'ObjectHelper');
- module_load_include('inc', 'fedora_repository', 'api/fedora_utils');
- $indexName = variable_get('fedora_index_name', 'DemoOnLucene');
- $searchUrl = variable_get('fedora_fgsearch_url', 'http://localhost:8080/fedoragsearch/rest');
- if ($startTerm == NULL) {
- $startTerm = "";
- }
- $startTerm = drupal_urlencode($startTerm);
- $query = 'operation=browseIndex&startTerm=' . $startTerm . '&fieldName=' . $fieldName . '&termPageSize=20&indexName=' . $indexName . '&restXslt=copyXml&resultPageXslt=copyXml';
- // $query=drupal_urlencode($query);
- $query = '?' . $query;
- $searchString = $searchUrl . $query;
-
- $objectHelper = new ObjectHelper();
-
- $resultData = do_curl($searchString, 1);
- $path = drupal_get_path('module', 'fedora_repository');
-
- $output .= $this->applySpecifiedXSLT($resultData, $path . '/xsl/browseIndexToResultPage.xslt', $displayName);
- //$output .= '
'.$alpha_out;
- return $output;
- }
-
- /**
- * custom search ??
- * @param type $query
- * @param type $startPage
- * @param type $xslt
- * @param type $numberOfHistPerPage
- * @return type
- */
- function custom_search($query, $startPage=1, $xslt= '/xsl/advanced_search_results.xsl', $numberOfHistPerPage = 50) {
- module_load_include('inc', 'fedora_repository', 'ObjectHelper');
- module_load_include('inc', 'fedora_repository', 'api/fedora_utils');
-
- if (user_access('view fedora collection')) {
- //$numberOfHistPerPage = '50';//hack for IR they do not want next button
- $luceneQuery = NULL;
- $indexName = variable_get('fedora_index_name', 'DemoOnLucene');
- $copyXMLFile = 'copyXml';
- // if($indexName=='ilives' || $indexName=='BasicIndex'){
- // $copyXMLFile = 'copyXmliLives';
- // }
- $query = trim($query);
- $query = htmlentities(urlencode($query));
- $searchUrl = variable_get('fedora_fgsearch_url', 'http://localhost:8080/fedoragsearch/rest');
- $searchString = '?operation=gfindObjects&indexName=' . $indexName . '&restXslt=' . $copyXMLFile . '&query=' . $query;
- $searchString .= '&hitPageSize=' . $numberOfHistPerPage . '&hitPageStart=' . $startPage;
- //$searchString = htmlentities($searchString);
- $searchUrl .= $searchString;
-
- //$objectHelper = new ObjectHelper();
-
- $resultData = do_curl($searchUrl, 1);
- //var_dump($resultData);exit(0);
- // $doc = new DOMDocument();
- // $doc->loadXML($resultData);
-
- $output .= $this->applyLuceneXSLT($resultData, $startPage, $xslt, $query);
- return $output;
- }
- }
-
- /**
- * apply specified xslt ??
- * @global type $user
- * @param type $resultData
- * @param type $pathToXSLT
- * @param type $displayName
- * @return type
- */
- function applySpecifiedXSLT($resultData, $pathToXSLT, $displayName = NULL) {
- $proc = NULL;
- global $user;
- if (!$resultData) {
- drupal_set_message(t('No data found!'));
- return ' '; //no results
- }
- try {
- $proc = new XsltProcessor();
- } catch (Exception $e) {
- drupal_set_message(t('Error loading ' . $pathToXSLT . ' xslt!') . $e->getMessage());
- return ' ';
- }
-
- //$proc->setParameter('', 'searchUrl', url('search') . '/fedora_repository'); //needed in our xsl
- $proc->setParameter('', 'objectsPage', base_path());
- $proc->setParameter('', 'userID', $user->uid);
- if (isset($displayName)) {
- $proc->setParameter('', 'displayName', $displayName);
- }
- else {
- $proc->setParameter('', 'displayName', "test");
- }
-
- $xsl = new DomDocument();
-
- $test = $xsl->load($pathToXSLT);
-
- if (!isset($test)) {
- drupal_set_message(t('Error loading ' . $pathToXSLT . ' xslt!'));
- return t('Error loading !pathToXSLT xslt.', array('!pathToXSLT' => $pathToXSLT));
- }
-
- $input = new DomDocument();
-
- $didLoadOk = $input->loadXML($resultData);
-
- if (!isset($didLoadOk)) {
- drupal_set_message(t('Error loading XML data!'));
- return t('Error loading XML data.');
- }
- else {
- $proc->importStylesheet($xsl);
- $newdom = $proc->transformToDoc($input);
- return $newdom->saveXML();
- }
- }
-
- //default function for lucene results
-
- /**
- * apply an xslt to lucene gsearch search results
- *
- * @param $resultData
- * @param $startPage
- * @param $xslt_file
- * @param $query the query that was executed. May want to pass this on.
- */
- function applyLuceneXSLT($resultData, $startPage = 1, $xslt_file = '/xsl/results.xsl', $query=NULL) {
- $path = drupal_get_path('module', 'fedora_repository');
- $test = $xslt_file;
- $isRestricted = variable_get('fedora_namespace_restriction_enforced', TRUE);
- if (!isRestricted && $xslt_file == NULL) {
- $xslt_file = '/xsl/unfilteredresults.xsl';
- }
- $proc = NULL;
- if (!$resultData) {
- //drupal_set_message(t('No Results!'));
- return ' '; //no results
- }
- try {
- $proc = new XsltProcessor();
- } catch (Exception $e) {
- drupal_set_message(t('Error loading results xslt!') . $e->getMessage());
- return ' ';
- }
- if (isset($query)) {
- $proc->setParameter('', 'fullQuery', $query);
- }
- //inject into xsl stylesheet
- global $user;
- $proc->setParameter('', 'userID', $user->uid);
- $proc->setParameter('', 'searchToken', drupal_get_token('fedora_repository_advanced_search')); //token generated by Drupal, keeps tack of what tab etc we are on
- $proc->setParameter('', 'searchUrl', url('search') . '/fedora_repository'); //needed in our xsl
- $proc->setParameter('', 'objectsPage', base_path());
- $proc->setParameter('', 'allowedPidNameSpaces', variable_get('fedora_pids_allowed', 'default: demo: changeme: islandora: ilives: islandora-book: books: newspapers: '));
- $proc->setParameter('', 'hitPageStart', $startPage);
- $proc->registerPHPFunctions();
- $xsl = new DomDocument();
-
- $test = $xsl->load($path . $xslt_file);
- if (!isset($test)) {
- drupal_set_message(t('Error loading search results xslt!'));
- return t('Error loading search results XSLT.');
- }
-
- $input = new DomDocument();
- $didLoadOk = $input->loadXML($resultData);
-
- if (!isset($didLoadOk)) {
- drupal_set_message(t('Error loading search results!'));
- return t('Error loading search results.');
- }
- else {
- $proc->importStylesheet($xsl);
- $newdom = $proc->transformToDoc($input);
- return $newdom->saveXML();
- }
- }
-
- /**
- * xslt for islandscholar these xslt functions can probably be pulled into one
- * @param type $resultData
- * @param type $orderBy
- * @return type
- */
- function applyXSLT($resultData, $orderBy = 0) {
- $path = drupal_get_path('module', 'fedora_repository');
- $proc = NULL;
- if (!$resultData) {
- //drupal_set_message(t('No Results!'));
- return ' '; //no results
- }
- try {
- $proc = new XsltProcessor();
- } catch (Exception $e) {
- drupal_set_message(t('Error loading results xslt!') . " " . $e->getMessage());
- return ' ';
- }
-
- //inject into xsl stylesheet
- //$proc->setParameter('', 'searchToken', drupal_get_token('search_form')); //token generated by Drupal, keeps tack of what tab etc we are on
- $proc->setParameter('', 'userID', $user->uid);
- $proc->setParameter('', 'searchUrl', url('search') . '/fedora_repository'); //needed in our xsl
- $proc->setParameter('', 'objectsPage', base_path());
- $proc->setParameter('', 'allowedPidNameSpaces', variable_get('fedora_pids_allowed', 'default: demo: changeme: islandora: ilives: islandora-book: books: newspapers: '));
- $proc->setParameter('', 'orderBy', $orderBy);
- $xsl = new DomDocument();
-
- $test = $xsl->load($path . '/ir/xsl/results.xsl');
- if (!isset($test)) {
- drupal_set_message(t('Error loading search results xslt!'));
- return t('Error loading search results XSLT.');
- }
-
- $input = new DomDocument();
- $didLoadOk = $input->loadXML($resultData);
-
- if (!isset($didLoadOk)) {
- drupal_set_message(t('Error loading search results!'));
- return t('Error loading search results.');
- }
- else {
- $xsl = $proc->importStylesheet($xsl);
- $newdom = $proc->transformToDoc($input);
- return $newdom->saveXML();
- }
- }
-
- /**
- * theme advanced search form ??
- * @param type $form
- * @param type $repeat
- * @return type
- */
- function theme_advanced_search_form($form, $repeat=NULL) {
- if (!isset($repeat)) {
- $repeat = variable_get('fedora_repository_advanced_block_repeat', t('3'));
- }
-
- $output = drupal_render($form['search_type']['type1']);
- $output .= drupal_render($form['fedora_terms1']);
- $output .= drupal_render($form['andor1']) . drupal_render($form['search_type']['type2']);
- $output .= drupal_render($form['fedora_terms2']);
- if ($repeat > 2 && $repeat < 9) {
- for ($i = 3; $i < $repeat + 1; $i++) {
- $t = $i - 1;
- $output .= drupal_render($form["andor$t"]) . drupal_render($form['search_type']["type$i"]);
- $output .= drupal_render($form["fedora_terms$i"]);
- }
- }
- $output .= drupal_render($form['submit']);
- $output .= drupal_render($form);
- return $output;
- }
-
- /**
- * build search form, custom blocks should set the number of repeats or it will use the default
- * @param type $repeat
- * @param type $pathToSearchTerms
- * @param type $query
- * @return string
- */
- function build_advanced_search_form($repeat = NULL, $pathToSearchTerms = NULL, $query = NULL) {
- $types = $this->get_search_terms_array($pathToSearchTerms);
- $queryArray = NULL;
- if (isset($query)) {
- $queryArray = explode('AND', $query);
- }
-
- $andOrArray = array(
- 'AND' => 'and',
- //'OR' => 'or' //removed or for now as it would be a pain to parse
- );
- $form = array();
-
- if (!isset($repeat)) {
- $repeat = variable_get('fedora_repository_advanced_block_repeat', t('3'));
- }
- $var0 = explode(':', $queryArray[0]);
- $var1 = explode(':', $queryArray[1]);
- $form['search_type']['type1'] = array(
- '#title' => t(''),
- '#type' => 'select',
- '#options' => $types,
- '#default_value' => trim($var0[0])
- );
- $form['fedora_terms1'] = array(
- '#size' => '24',
- '#type' => 'textfield',
- '#title' => t(''),
- '#required' => TRUE,
- '#default_value' => (count($var0) >= 2 ? trim($var0[1]) : ''),
- );
- $form['andor1'] = array(
- '#title' => t(''),
- '#type' => 'select',
- '#default_value' => 'AND',
- '#options' => $andOrArray
- );
- $form['search_type']['type2'] = array(
- '#title' => t(''),
- '#type' => 'select',
- '#options' => $types,
- '#default_value' => (count($var1) >= 2 ? trim($var1[0]) : ''),
- );
- $form['fedora_terms2'] = array(
- '#size' => '24',
- '#type' => 'textfield',
- '#title' => t(''),
- '#default_value' => (count($var1) >= 2 ? $var1[1] : ''),
- );
- if ($repeat > 2 && $repeat < 9) { //don't want less then 2 or more then 9
- for ($i = 3; $i < $repeat + 1; $i++) {
- $t = $i - 1;
- $field_and_term = explode(':', $queryArray[$t]);
- $form["andor$t"] = array(
- '#title' => t(''),
- '#type' => 'select',
- '#default_value' => 'AND',
- '#options' => $andOrArray
- );
- $form['search_type']["type$i"] = array(
- '#title' => t(''),
- '#type' => 'select',
- '#options' => $types,
- '#default_value' => trim($field_and_term[0])
- );
- $form["fedora_terms$i"] = array(
- '#size' => '24',
- '#type' => 'textfield',
- '#title' => t(''),
- '#default_value' => (count($field_and_term) >= 2 ? trim($field_and_term[1]) : ''),
- );
- }
- }
-
- $form['submit'] = array(
- '#type' => 'submit',
- '#value' => t('search')
- );
- return $form;
- }
-
- /**
- * get search terms array
- * @param type $path
- * @param string $file
- * @return type
- */
- function get_search_terms_array($path = NULL, $file = NULL) {
- if (!isset($path)) {
- $path = drupal_get_path('module', 'fedora_repository');
- }
- $xmlDoc = new DomDocument();
- if (!isset($file)) {
- $file = 'searchTerms.xml';
- }
- $xmlDoc->load($path . '/' . $file);
- $nodeList = $xmlDoc->getElementsByTagName('term');
- $types = array();
- for ($i = 0; $i < $nodeList->length; $i++) {
- $field = $nodeList->item($i)->getElementsByTagName('field');
- $value = $nodeList->item($i)->getElementsByTagName('value');
- $fieldValue = $field->item(0)->nodeValue;
- $valueValue = $value->item(0)->nodeValue;
- $types["$fieldValue"] = "$valueValue";
- }
- return $types;
- }
-
-}
diff --git a/collection_policy.xsd b/collection_policy.xsd
index d5ea6637..35a52bdb 100644
--- a/collection_policy.xsd
+++ b/collection_policy.xsd
@@ -45,4 +45,4 @@
-
\ No newline at end of file
+
diff --git a/fedora_repository.module b/fedora_repository.module
index 1beb9b06..d5ca00e6 100644
--- a/fedora_repository.module
+++ b/fedora_repository.module
@@ -1261,264 +1261,12 @@ function repository_service($pid = NULL, $servicePid = NULL, $serviceMethod = NU
exit();
}
-//Search Stuff ********************************************************************
-
-/**
- * Implements hook_search().
- * sends a search query to fedora fgsearch which is backed by Lucene
- * In our implementation of Fedora we have api-a and api-m locked down
- * to authorized users but at the object level. We can query Lucene and the
- * RI index to get a list of results without authorization but to view any
- * datastreams users must be authorized.
- *
- * @param type $op
- * @param type $keys
- * @return array
- */
-function fedora_repository_search($op = 'search', $keys = NULL) {
- module_load_include('inc', 'fedora_repository', 'ObjectHelper');
- module_load_include('inc', 'fedora_repository', 'api/fedora_utils');
-
- switch ($op) {
- case 'name':
- if (user_access('view fedora collection')) {
- return t('Digital Repository', array('-9'));
- }
- case 'search':
- if (user_access('view fedora collection')) {
-//demo search string ?operation=gfindObjects&indexName=DemoOnLucene&query=fgs.DS.first.text%3Achristmas&hitPageStart=11&hitPageSize=10
- $resultData = NULL;
- $numberOfHitsPerPage = NULL;
- $index = strpos($keys, '.');
- $test = substr($keys, 0, $index + 1);
- $type = NULL;
- if ($index > 0) {
- $index = strpos($keys, ':');
- $type = substr($keys, 0, $index);
- $keys = substr($keys, $index + 1);
- }
-
- $index = strpos($keys, ':');
- $startPage = substr($keys, 0, $index);
- if ($index > 1) {
- $keys = substr($keys, $index + 1);
- }
-
- if (!$startPage) {
- $startPage = 1;
- }
-
- $xmlDoc = NULL;
-
- $path = drupal_get_path('module', 'fedora_repository');
- $xmlDoc = new DomDocument();
- $xmlDoc->load($path . '/searchTerms.xml');
- $nodeList = $xmlDoc->getElementsByTagName('default');
- if (!$type) {
- $type = $nodeList->item(0)->nodeValue;
- }
- $nodeList = $xmlDoc->getElementsByTagName('number_of_results');
- $numberOfHitsPerPage = $nodeList->item(0)->nodeValue;
-
- $indexName = variable_get('fedora_index_name', 'DemoOnLucene');
- $keys = htmlentities(urlencode($keys));
- $searchQuery = NULL;
- if (isset($type) && strcmp($type, ':')) {
- $searchQuery = $type . ':' . $keys;
- }
- else {
- $searchQuery = $keys;
- }
-
- $searchUrl = variable_get('fedora_fgsearch_url', 'http://localhost:8080/fedoragsearch/rest');
- $searchString = '?operation=gfindObjects&indexName=' . $indexName . '&restXslt=copyXml&query=' . $searchQuery;
- $searchString .= '&hitPageSize=' . $numberOfHitsPerPage . '&hitPageStart=' . $startPage;
-
- $searchUrl .= $searchString;
- $objectHelper = new ObjectHelper();
- $resultData = do_curl($searchUrl);
-
- $results[] = array(
- array(
- 'data' => $resultData,
- 'colspan' => 2
- )
- );
- return $results;
- }
- }
-}
-
-/**
- * Implements hook_search_page().
- * Display the search results
- *
- * @param type $resultData
- *
- * @return array
- */
-function fedora_repository_search_page($resultData) {
- $path = drupal_get_path('module', 'fedora_repository');
- $isRestricted = variable_get('fedora_namespace_restriction_enforced', TRUE);
- $proc = NULL;
- // No results.
- if (!$resultData[0][0]['data']) {
- return '';
- }
- $text = utf8_encode($resultData[0][0]['data']);
-
- try {
- $proc = new XsltProcessor();
- } catch (Exception $e) {
- $out[] = array(
- array(
- 'data' => $e->getMessage(),
- 'colspan' => 2,
- ),
- );
- return $out;
- }
-
- // Inject into xsl stylesheet.
- $proc->setParameter('', 'searchToken', drupal_get_token('search_form')); //token generated by Drupal, keeps tack of what tab etc we are on
- $proc->setParameter('', 'searchUrl', url('search') . '/fedora_repository'); //needed in our xsl
- $proc->setParameter('', 'objectsPage', base_path());
- $proc->setParameter('', 'allowedPidNameSpaces', variable_get('fedora_pids_allowed', 'default: demo: changeme: islandora: ilives: islandora-book: books: newspapers: '));
- $proc->registerPHPFunctions();
- $xsl = new DomDocument();
- if ($isRestricted) {
- $xsl->load($path . '/xsl/results.xsl');
- }
- else {
- $xsl->load($path . '/xsl/unfilteredresults.xsl');
- }
-
- $input = new DomDocument();
- $didLoadOk = $input->loadXML(utf8_encode($resultData[0][0]['data']));
-
- if (!$didLoadOk) {
- $results[] = array(
- array(
- 'data' => 'Error parsing results',
- 'colspan' => 2
- )
- );
- }
- else {
- $xsl = $proc->importStylesheet($xsl);
- $newdom = $proc->transformToDoc($input);
-
- $results[] = array(
- array(
- 'data' => $newdom->saveHTML(),
- 'colspan' => 2
- )
- );
- }
-
- $header = array(
- array(
- 'data' => t('Collection results'),
- NULL,
- ),
- (NULL)
- );
-
- $output .= theme('table', $header, $results);
- return $output;
-}
-
-/**
- * Implementation of hook_form_alter().
- * allows the advanced search form in drupal
- *
- * @param type $form
- * @param type $form_state
- * @param type $form_id
- */
-function fedora_repository_form_alter(&$form, &$form_state, $form_id) {
-// Advanced node search form
- module_load_include('inc', 'fedora_repository', 'SearchClass');
- $path = drupal_get_path('module', 'fedora_repository');
- if ($form_id == 'search_form' && arg(1) == 'fedora_repository' && user_access('use advanced search')) {
- $default_value = $form['basic']['inline']['keys']['#default_value'];
- $index = strpos($default_value, '.');
- $test = substr($default_value, 0, $index + 1);
- $type = NULL;
- if ($index > 0) {
- $index = strpos($default_value, ':');
- $type = substr($default_value, 0, $index);
- $default_value = substr($default_value, $index + 1);
- }
- $form['basic']['inline']['keys']['#default_value'] = $default_value;
-// Keyword boxes:
- $form['advanced'] = array(
- '#type' => 'fieldset',
- '#title' => t('Advanced search'),
- '#collapsible' => TRUE,
- '#collapsed' => TRUE,
- '#attributes' => array(
- 'class' => 'search-advanced'
- ),
- );
- $form['advanced']['keywords'] = array(
- '#prefix' => '',
- '#suffix' => '
',
- );
- $xmlDoc = new DomDocument();
- $xmlDoc->load($path . '/searchTerms.xml');
- $nodeList = $xmlDoc->getElementsByTagName('term');
- $searchClass = new SearchClass();
- $types = $searchClass->get_search_terms_array();
-
- $form['advanced']['type'] = array(
- '#type' => 'select',
- '#title' => t('Choose a field to search'),
- '#prefix' => '', '#suffix' => '
', '#options' => $types,
- '#default_value' => $type,
- );
- $form['advanced']['submit'] = array(
- '#type' => 'submit',
- '#value' => t('Advanced search'),
- '#prefix' => '', '#suffix' => '
',
- );
- $form['#validate'][] = 'fedora_repository_search_validate';
- }
-}
-
-/**
- * Implementation of hook_search_validate()
- *
- * @param type $form
- * @param type $form_state
- */
-function fedora_repository_search_validate($form, &$form_state) {
-// Initialise using any existing basic search keywords.
- $keys = $form_state['values']['processed_keys'];
-
- if (isset($form_state['values']['type'])) {
- $type = $form_state['values']['type'];
- if ($type) {
- $keys = $type . ':' . $keys;
- }
- }
-
- if (!empty($keys)) {
- form_set_value($form['basic']['inline']['processed_keys'], trim($keys), $form_state); //set the form string
- }
-}
-
/**
* fedora repository theme
* @return type
*/
function fedora_repository_theme() {
return array(
- 'fedora_repository_mnpl_advanced_search_form' => array(
- 'arguments' => array(
- 'form' => NULL,
- ),
- ),
'fedora_repository_time' => array(
'arguments' => array(
'element' => NULL
@@ -1532,77 +1280,6 @@ function fedora_repository_theme() {
);
}
-/**
- * Get a list of terms from a lucene index
- *
- * @param type $field
- * @param type $startTerm
- * @param type $displayName
- * @return type
- */
-function fedora_repository_list_terms($field, $startTerm = NULL, $displayName = NULL) {
- module_load_include('inc', 'fedora_repository', 'SearchClass');
- $searchClass = new SearchClass();
- return $searchClass->getTerms($field, $startTerm, $displayName);
-}
-
-/**
- * fedora repository mnpl advanced search form
- * @return type
- */
-function fedora_repository_mnpl_advanced_search_form() {
- module_load_include('inc', 'fedora_repository', 'SearchClass');
- $searchClass = new SearchClass();
- return $searchClass->build_advanced_search_form();
-}
-
-/**
- * theme fedora repository mnpl advanced search form
- * @param type $form
- * @return type
- */
-function theme_fedora_repository_mnpl_advanced_search_form($form) {
- module_load_include('inc', 'fedora_repository', 'SearchClass');
- $advanced_search_form = new SearchClass();
- return $advanced_search_form->theme_advanced_search_form($form);
-}
-
-/**
- * fedora repository mnpl advanced search
- * @param type $query
- * @param type $startPage
- * @return type
- */
-function fedora_repository_mnpl_advanced_search($query, $startPage = 1) {
- module_load_include('inc', 'fedora_repository', 'SearchClass');
- $searchClass = new SearchClass();
- $retVal = $searchClass->custom_search($query, $startPage);
- return $searchClass->custom_search($query, $startPage);
-}
-
-/**
- * fedora repository mnpl_advanced search form submit
- * @param type $form
- * @param type $form_state
- */
-function fedora_repository_mnpl_advanced_search_form_submit($form, &$form_state) {
- $type_id = $form_state['values']['type'];
- $repeat = variable_get('fedora_repository_advanced_block_repeat', t('3'));
- $searchString = $form_state['values']['type1'] . ':' . $form_state['values']['fedora_terms1'];
- if ($form_state['values']['fedora_terms2'] != '') {
- $searchString .=' +' . $form_state['values']['andor1'] . '+' . $form_state['values']['type2'] . ':' . $form_state['values']['fedora_terms2'];
- }
- if ($repeat > 2 && $repeat < 9) {
- for ($i = 3; $i < $repeat + 1; $i++) {
- $t = $i - 1;
- if ($form_state['values']["fedora_terms$i"] != '') {
- $searchString .= '+' . $form_state['values']["andor$t"] . '+' . $form_state['values']["type$i"] . ':' . $form_state['values']["fedora_terms$i"];
- }
- }
- }
- drupal_goto("fedora/repository/mnpl_advanced_search/$searchString");
-}
-
/**
* fedora repository install demo page
* @return type
diff --git a/formClass.inc b/formClass.inc
index 30f7d220..82f63801 100644
--- a/formClass.inc
+++ b/formClass.inc
@@ -121,14 +121,6 @@ class formClass {
'access arguments' => array('add fedora datastreams')
);
- //new for mnpl******************************************
- $items['fedora/repository/mnpl_advanced_search'] = array(
- 'title' => t('Repository advanced search'),
- 'page callback' => 'fedora_repository_mnpl_advanced_search',
- 'type' => MENU_CALLBACK,
- 'access arguments' => array('view fedora collection')
- );
-
$items['fedora/ingestObject'] = array(
'title' => t('Ingest object'),
'page callback' => 'fedora_repository_ingest_object',
@@ -136,13 +128,6 @@ class formClass {
'access arguments' => array('add fedora datastreams')
);
- $items['fedora/repository/list_terms'] = array(
- 'title' => t('List terms'),
- 'page callback' => 'fedora_repository_list_terms',
- 'type' => MENU_CALLBACK,
- 'access arguments' => array('view fedora collection')
- );
-
/* Export functionality */
$items['fedora/basket'] = array(
'title' => t('Fedora Basket'),