|
|
@ -6,73 +6,56 @@ |
|
|
|
* @param string $collection_pid |
|
|
|
* @param string $collection_pid |
|
|
|
* @return array |
|
|
|
* @return array |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function islandora_collection_table($collection_pid) { |
|
|
|
function islandora_collection_table($collection_pid) { |
|
|
|
module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); |
|
|
|
module_load_include('inc', 'islandora', 'RestConnection'); |
|
|
|
|
|
|
|
require_once 'sites/all/libraries/tuque/RepositoryQuery.php'; |
|
|
|
$query = "select \$object \$title from <#ri> |
|
|
|
$restConnection = new RestConnection(); |
|
|
|
where (\$object <info:fedora/fedora-system:def/relations-external#isMemberOf> <info:fedora/$collection_pid> |
|
|
|
$query = 'select $object $title from <#ri> |
|
|
|
or \$object <info:fedora/fedora-system:def/relations-external#isMemberOfCollection> <info:fedora/$collection_pid>) |
|
|
|
where ($object <info:fedora/fedora-system:def/relations-external#isMemberOf> <info:fedora/' . $collection_pid . '> |
|
|
|
and \$object <dc:title> \$title"; |
|
|
|
or $object <info:fedora/fedora-system:def/relations-external#isMemberOfCollection> <info:fedora/' . $collection_pid . '>) |
|
|
|
$query = htmlentities(urlencode($query)); |
|
|
|
and $object <dc:title> $title'; |
|
|
|
$content = ''; |
|
|
|
$results = $restConnection->repository->ri->itqlQuery($query, 'unlimited', '0'); |
|
|
|
|
|
|
|
|
|
|
|
$url = variable_get('fedora_repository_url', 'http://localhost:8080/fedora/risearch'); |
|
|
|
|
|
|
|
$url .= "?type=tuples&flush=TRUE&format=csv&limit=$limit&offset=$offset&lang=itql&stream=on&query=" . $query; |
|
|
|
|
|
|
|
$content .= do_curl($url); |
|
|
|
|
|
|
|
$results = explode("\n", $content); |
|
|
|
|
|
|
|
$lines = preg_replace('/info:fedora\/|"object","title"/', '', $results); |
|
|
|
|
|
|
|
$lines = array_values(array_filter($lines)); |
|
|
|
|
|
|
|
$keys = array(); |
|
|
|
$keys = array(); |
|
|
|
$object = array(); |
|
|
|
$objects = array(); |
|
|
|
foreach ($lines as $line) { |
|
|
|
foreach ($results as $result) { |
|
|
|
$line_parts = explode(',', $line); |
|
|
|
$objects[$result['object']['value']] = $result['title']['value']; |
|
|
|
|
|
|
|
$keys[] = $result['object']['value']; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$objects[$line_parts[0]] = $line_parts[1]; |
|
|
|
foreach ($objects as $key => $object) { |
|
|
|
$keys[] = $line_parts[0]; |
|
|
|
$rows[$key] = array( |
|
|
|
|
|
|
|
'#pid' => $key, |
|
|
|
|
|
|
|
'pid' => array('#value' => l($key, 'islandora/object/' . $key)), |
|
|
|
|
|
|
|
'title' => array( |
|
|
|
|
|
|
|
'data' => array( |
|
|
|
|
|
|
|
'#type' => 'link', |
|
|
|
|
|
|
|
'#title' => $object, |
|
|
|
|
|
|
|
'#href' => 'islandora/object/' . $key, |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$form['list'] = array( |
|
|
|
$header = array( |
|
|
|
'#value' => $list, |
|
|
|
'title' => array('data' => t('Title')), |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
$table = array( |
|
|
|
$table = array( |
|
|
|
'#header' => array(theme('table_select_header_cell'), t('Select All'), ''), |
|
|
|
'#type' => 'tableselect', |
|
|
|
'#theme' => 'islandora_collection_management_form_table', |
|
|
|
'#header' => $header, |
|
|
|
'#tree' => TRUE, |
|
|
|
'#options' => $rows, |
|
|
|
'rows' => array(), |
|
|
|
|
|
|
|
'selections' => array( |
|
|
|
|
|
|
|
'#type' => 'checkboxes', |
|
|
|
|
|
|
|
'#options' => array_fill_keys($keys, ''), |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
$rows = &$table['rows']; |
|
|
|
|
|
|
|
if(empty($objects)){ |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
foreach ($objects as $key => $object) { |
|
|
|
|
|
|
|
$rows[] = array( |
|
|
|
|
|
|
|
'#pid' => $key, |
|
|
|
|
|
|
|
'pid' => array('#value' => l($key, 'fedora/repository/' . $key)), |
|
|
|
|
|
|
|
'title' => array('#value' => $object), |
|
|
|
|
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return $table; |
|
|
|
return $table; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* themes the form table. |
|
|
|
* themes the form table. |
|
|
|
* |
|
|
|
* |
|
|
|
* @param array $element Drupal Form Element. |
|
|
|
* @param array $element Drupal Form Element. |
|
|
|
* @return string |
|
|
|
* @return string |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
|
|
|
|
function theme_islandora_basic_collection_management_form_table(array $element) { |
|
|
|
|
|
|
|
|
|
|
|
function theme_islandora_collection_management_form_table(array $element) { |
|
|
|
|
|
|
|
$rows = array(); |
|
|
|
$rows = array(); |
|
|
|
foreach (element_children($element['rows']) as $child) { |
|
|
|
foreach (element_children($element['rows']) as $child) { |
|
|
|
$setting = $element['rows'][$child]; |
|
|
|
$setting = $element['rows'][$child]; |
|
|
@ -92,3 +75,34 @@ function theme_islandora_collection_management_form_table(array $element) { |
|
|
|
$attributes = isset($element['#id']) ? array('id' => $element['#id']) : NULL; |
|
|
|
$attributes = isset($element['#id']) ? array('id' => $element['#id']) : NULL; |
|
|
|
return theme_table($element['#header'], $rows, $attributes); |
|
|
|
return theme_table($element['#header'], $rows, $attributes); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function get_collections_as_option_array() { |
|
|
|
|
|
|
|
module_load_include('inc', 'islandora', 'RestConnection'); |
|
|
|
|
|
|
|
require_once 'sites/all/libraries/tuque/RepositoryQuery.php'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$restricted = variable_get('fedora_namespace_restriction_enforced', TRUE); |
|
|
|
|
|
|
|
$allowed_string = variable_get('fedora_pids_allowed', 'default: demo: changeme: islandora:'); |
|
|
|
|
|
|
|
$namespaces = explode(':', $allowed_string); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$restConnection = new RestConnection(); |
|
|
|
|
|
|
|
$query = 'select $object $title from <#ri> |
|
|
|
|
|
|
|
where ($object <fedora-model:label> $title |
|
|
|
|
|
|
|
and $object <info:fedora/fedora-system:def/model#hasModel> <info:fedora/islandora:collectionCModel> |
|
|
|
|
|
|
|
and $object <fedora-model:state> <info:fedora/fedora-system:def/model#Active>) |
|
|
|
|
|
|
|
order by $title'; |
|
|
|
|
|
|
|
$results = $restConnection->repository->ri->itqlQuery($query, 'unlimited', '0'); |
|
|
|
|
|
|
|
foreach ($namespaces as $namespace) { |
|
|
|
|
|
|
|
$trimmed_names[] = trim($namespace); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
$options = array(); |
|
|
|
|
|
|
|
foreach ($results as $item) { //removes blanks |
|
|
|
|
|
|
|
// var_dump($item['object']['value']); |
|
|
|
|
|
|
|
$namespace = explode(':', $item['object']['value']); |
|
|
|
|
|
|
|
$namespace = trim($namespace[0]); |
|
|
|
|
|
|
|
if (!$restricted || in_array($namespace, $trimmed_names)) { |
|
|
|
|
|
|
|
$options[$item['object']['value']] = $item['title']['value']; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
unset($options['islandora:ContentModelCollection']); |
|
|
|
|
|
|
|
return $options; |
|
|
|
|
|
|
|
} |