From 961d5d5f0402aa78b1a7e4d6b7018f2075b36195 Mon Sep 17 00:00:00 2001 From: William Panting Date: Tue, 11 Sep 2012 14:03:19 -0300 Subject: [PATCH] some style fixes --- api/fedora_utils.inc | 153 ++++++++++++++++++++++++------------------- 1 file changed, 84 insertions(+), 69 deletions(-) diff --git a/api/fedora_utils.inc b/api/fedora_utils.inc index a730d7a4..a2eaf55c 100644 --- a/api/fedora_utils.inc +++ b/api/fedora_utils.inc @@ -1,23 +1,23 @@ 63) + if (strlen($new_dsid) > 63) { $new_dsid = substr($new_dsid, -63); + } - if (preg_match('/^[^a-zA-Z]/', $dsid)) + if (preg_match('/^[^a-zA-Z]/', $dsid)) { $new_dsid = 'x' . $new_dsid; + } - if (strlen($new_dsid) == 0) + if (strlen($new_dsid) == 0) { $new_dsid = 'item' . rand(1, 100); + } return $new_dsid; } @@ -229,9 +245,8 @@ function fix_dsid($dsid) { /** * Function: get_collections_as_option_array * - * Description: Returns an associative array of all collection objects in Fedora instance - * * @return array + * Returns an associative array of all collection objects in Fedora instance */ function get_collections_as_option_array() { module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); @@ -244,7 +259,7 @@ function get_collections_as_option_array() { and $object ) order by $title'; $url = variable_get('fedora_repository_url', 'http://localhost:8080/fedora/risearch'); - + $options = array( 'type' => 'tuples', 'flush' => 'TRUE', @@ -254,9 +269,9 @@ function get_collections_as_option_array() { 'stream' => 'on', 'query' => $query, ); - //The url function will take care of URL encoding... + // 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); @@ -264,7 +279,8 @@ function get_collections_as_option_array() { $trimmed_names[] = trim($namespace); } $options = array(); - foreach ($list as $item) { //removes blanks + // Removes blanks. + foreach ($list as $item) { if ($item) { $parts = explode(',', $item); $namespace = explode(':', $parts[0]); @@ -283,46 +299,45 @@ function get_collections_as_option_array() { /** * Function: get_content_models_as_option_array * - * Description: Returns an associative array of all available content models in Fedora instance - * * @return array + * associative array of all available content models in Fedora instance */ function get_content_models_as_option_array() { - module_load_include('inc', 'fedora_repository', 'api/fedora_item'); - module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); - $restricted = variable_get('fedora_namespace_restriction_enforced', TRUE); - $allowed_string = variable_get('fedora_pids_allowed', 'default: demo: changeme: islandora:'); - $namespaces = explode(':', $allowed_string); - foreach ($namespaces as $namespace) { - if ($namespace) { - $allowed[] = trim($namespace); - } + module_load_include('inc', 'fedora_repository', 'api/fedora_item'); + module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); + $restricted = variable_get('fedora_namespace_restriction_enforced', TRUE); + $allowed_string = variable_get('fedora_pids_allowed', 'default: demo: changeme: islandora:'); + $namespaces = explode(':', $allowed_string); + foreach ($namespaces as $namespace) { + if ($namespace) { + $allowed[] = trim($namespace); } - $query = 'select $object $title from <#ri> - where ($object $title - and ($object - or $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))); - $list = explode("\n", $content); - array_shift($list); - $list = preg_replace('/info:fedora\//', '', $list); - foreach ($list as $item) { //removes blanks - if ($item) { - $parts = explode(',', $item); - $nameparts = explode(':', $parts[0]); - if (!$restricted || in_array($nameparts[0], $allowed)) { + } + $query = 'select $object $title from <#ri> + where ($object $title + and ($object + or $object ) + and $object ) + order by $title'; - if (!preg_match('/fedora-system/', $nameparts[0])) { - $options[$parts[0]] = $parts[1] . ' ~ ' . $parts[0]; - } - } + $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))); + $list = explode("\n", $content); + array_shift($list); + $list = preg_replace('/info:fedora\//', '', $list); + // Removes blanks. + foreach ($list as $item) { + if ($item) { + $parts = explode(',', $item); + $nameparts = explode(':', $parts[0]); + if (!$restricted || in_array($nameparts[0], $allowed)) { + if (!preg_match('/fedora-system/', $nameparts[0])) { + $options[$parts[0]] = $parts[1] . ' ~ ' . $parts[0]; } + } } + } - return $options; -} \ No newline at end of file + return $options; +}