Browse Source

Use url() to build query.

pull/126/head
Adam Vessey 13 years ago
parent
commit
f674a99b0b
  1. 2
      ObjectHelper.inc
  2. 15
      api/fedora_utils.inc
  3. 36
      fedora_repository.module

2
ObjectHelper.inc

@ -163,7 +163,6 @@ class ObjectHelper {
CURLOPT_FOLLOWLOCATION => TRUE, // allow redirects CURLOPT_FOLLOWLOCATION => TRUE, // allow redirects
//CURLOPT_TIMEOUT => 15, // times out after 15s //CURLOPT_TIMEOUT => 15, // times out after 15s
CURLOPT_USERAGENT => $user_agent, CURLOPT_USERAGENT => $user_agent,
CURLOPT_URL => $url,
CURLOPT_USERPWD => "$fedoraUser:$fedoraPass", 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. // 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, //CURLOPT_HTTPAUTH => CURLAUTH_ANY,
@ -243,6 +242,7 @@ class ObjectHelper {
CURLOPT_HTTPGET => TRUE, //CURLOPT_NOBODY sets it to 'HEAD' CURLOPT_HTTPGET => TRUE, //CURLOPT_NOBODY sets it to 'HEAD'
CURLOPT_RETURNTRANSFER => FALSE, //Want to output as efficiently as possible now... CURLOPT_RETURNTRANSFER => FALSE, //Want to output as efficiently as possible now...
); );
curl_setopt_array($ch, $opts);
$curl_stat = curl_exec($ch); $curl_stat = curl_exec($ch);
if (!$curl_stat) { if (!$curl_stat) {

15
api/fedora_utils.inc

@ -244,8 +244,19 @@ function get_collections_as_option_array() {
and $object <fedora-model:state> <info:fedora/fedora-system:def/model#Active>) and $object <fedora-model:state> <info:fedora/fedora-system:def/model#Active>)
order by $title'; order by $title';
$url = variable_get('fedora_repository_url', 'http://localhost:8080/fedora/risearch'); $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); $list = explode("\n", $content);
array_shift($list); array_shift($list);
$list = preg_replace('/info:fedora\//', '', $list); $list = preg_replace('/info:fedora\//', '', $list);

36
fedora_repository.module

@ -660,42 +660,6 @@ function fedora_repository_download_datastream_form(&$form_state, $pid, $dsid, $
return $form; 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 * fedora repository replace stream
* @param type $pid * @param type $pid

Loading…
Cancel
Save