From f674a99b0b043e11c18b1b08ed10f499f9adfea4 Mon Sep 17 00:00:00 2001 From: Adam Vessey Date: Fri, 4 May 2012 10:45:26 -0300 Subject: [PATCH] Use url() to build query. --- ObjectHelper.inc | 2 +- api/fedora_utils.inc | 23 +++++++++++++++++------ fedora_repository.module | 36 ------------------------------------ 3 files changed, 18 insertions(+), 43 deletions(-) diff --git a/ObjectHelper.inc b/ObjectHelper.inc index 67be7161..de871cdc 100644 --- a/ObjectHelper.inc +++ b/ObjectHelper.inc @@ -163,7 +163,6 @@ class ObjectHelper { CURLOPT_FOLLOWLOCATION => TRUE, // allow redirects //CURLOPT_TIMEOUT => 15, // times out after 15s CURLOPT_USERAGENT => $user_agent, - CURLOPT_URL => $url, CURLOPT_USERPWD => "$fedoraUser:$fedoraPass", // There seems to be a bug in Fedora 3.1's REST authentication, removing this line fixes the authorization denied error. //CURLOPT_HTTPAUTH => CURLAUTH_ANY, @@ -243,6 +242,7 @@ class ObjectHelper { CURLOPT_HTTPGET => TRUE, //CURLOPT_NOBODY sets it to 'HEAD' CURLOPT_RETURNTRANSFER => FALSE, //Want to output as efficiently as possible now... ); + curl_setopt_array($ch, $opts); $curl_stat = curl_exec($ch); if (!$curl_stat) { diff --git a/api/fedora_utils.inc b/api/fedora_utils.inc index 459c86ba..a730d7a4 100644 --- a/api/fedora_utils.inc +++ b/api/fedora_utils.inc @@ -239,13 +239,24 @@ function get_collections_as_option_array() { $allowed_string = variable_get('fedora_pids_allowed', 'default: demo: changeme: islandora:'); $namespaces = explode(':', $allowed_string); $query = 'select $object $title from <#ri> - where ($object $title - and $object - and $object ) - order by $title'; + where ($object $title + and $object + and $object ) + order by $title'; $url = variable_get('fedora_repository_url', 'http://localhost:8080/fedora/risearch'); - $url .= "?type=tuples&flush=TRUE&format=csv&limit=1000&lang=itql&stream=on&query="; - $content = do_curl($url . htmlentities(urlencode($query))); + + $options = array( + 'type' => 'tuples', + 'flush' => 'TRUE', + 'format' => 'csv', + 'limit' => '1000', + 'lang' => 'itql', + 'stream' => 'on', + 'query' => $query, + ); + //The url function will take care of URL encoding... + $content = do_curl(url($url, array('query' => $options))); + $list = explode("\n", $content); array_shift($list); $list = preg_replace('/info:fedora\//', '', $list); diff --git a/fedora_repository.module b/fedora_repository.module index 57c7f5ae..67397716 100644 --- a/fedora_repository.module +++ b/fedora_repository.module @@ -660,42 +660,6 @@ function fedora_repository_download_datastream_form(&$form_state, $pid, $dsid, $ return $form; } -function fedora_repository_download_datastream_form(&$form_state, $pid, $dsid, $label) { - $form = array( - '#action' => url("fedora/repository/object_download/$pid/$dsid/$label"), - 'submit' => array( - '#type' => 'submit', - '#value' => t('Download'), - ), - ); - - if (user_access(ObjectHelper::$EDIT_FEDORA_METADATA)) { - $item = new Fedora_Item($pid); - $versions = $item->get_datastream_history($dsid); - $version_array = array(); - if (is_array($versions)) { - foreach ($versions as $version) { - $version_array[] = $version->createDate; - } - } - else { - $version_array[] = $versions->createDate; - } - - if (count($version_array) > 1) { - $form['#attributes'] = array( - 'onsubmit' => 'this.action="' . $form['#action'] . '/" + this.version.value;' - ); - $form['version'] = array( - '#type' => 'select', - '#options' => array_combine($version_array, $version_array), - ); - } - } - - return $form; -} - /** * fedora repository replace stream * @param type $pid