Browse Source

refactored to themed list, cleaned out non-functional code

pull/653/head
ajstanley 8 years ago
parent
commit
b5181b8653
  1. 134
      islandora.module
  2. 41
      theme/theme.inc

134
islandora.module

@ -22,7 +22,6 @@
* You should have received a copy of the GNU General Public License
* along with the program. If not, see <http ://www.gnu.org/licenses/>.
*/
// Common datastreams.
define('ISLANDORA_DS_COMP_STREAM', 'DS-COMPOSITE-MODEL');
@ -459,7 +458,8 @@ function islandora_theme() {
'variables' => array(
'object' => NULL,
'content' => NULL,
'islandora_content' => NULL),
'islandora_content' => NULL,
),
),
// Render a bunch of objects as either a grid or a list.
'islandora_objects' => array(
@ -562,6 +562,12 @@ function islandora_theme() {
'file' => 'includes/solution_packs.inc',
'render element' => 'form',
),
// Overview for manage tab
'islandora_object_overview' => array(
'file' => 'theme/theme.inc',
'template' => 'theme/islandora-object-overview',
'variables' => array('islandora_object' => NULL),
),
);
}
@ -743,7 +749,7 @@ function islandora_forms($form_id) {
* TRUE if the user is allowed to access this object/datastream, FALSE
* otherwise.
*/
function islandora_user_access($object_or_datastream, array $permissions, $content_models = array(), $access_any = TRUE, $user = NULL) {
function islandora_user_access($object_or_datastream, array$permissions, $content_models = array(), $access_any = TRUE, $user = NULL) {
module_load_include('inc', 'islandora', 'includes/utilities');
$is_repository_accessible = &drupal_static(__FUNCTION__);
@ -919,40 +925,21 @@ function islandora_object_manage_access_callback($perms, $object = NULL) {
*/
function islandora_manage_overview_object(AbstractObject $object) {
module_load_include('inc', 'islandora', 'includes/utilities');
$output = array();
$output = islandora_create_manage_overview($object);
$hooks = islandora_build_hook_list(ISLANDORA_OVERVIEW_HOOK, $object->models);
foreach ($hooks as $hook) {
$temp = module_invoke_all($hook, $object);
islandora_as_renderable_array($temp);
if (!empty($temp)) {
arsort($temp);
$output = array_merge_recursive($output, $temp);
}
}
if (empty($output)) {
// Add in the default, if we did not get any results.
$output = islandora_default_islandora_manage_overview_object($object);
}
arsort($output);
drupal_alter($hooks, $object, $output);
islandora_as_renderable_array($output);
return $output;
}
/**
* Renders the default manage object page for the given object.
*
* @param AbstractObject $object
* The object used to render the manage object page.
*
* @return array
* The default rendering of the object manage page, indexed at
* 'Default Edit output'.
*/
function islandora_default_islandora_manage_overview_object(AbstractObject $object) {
$output = theme('islandora_default_overview', array('islandora_object' => $object));
return array('Default overview output' => array('#markup' => $output));
}
/**
* Renders the given objects manage page.
*
@ -1159,10 +1146,10 @@ function islandora_default_islandora_printer_object($object, $alter) {
$metadata = islandora_retrieve_metadata_markup($object, TRUE);
$variables = isset($dc_object) ? $dc_object->asArray() : array();
$output = theme('islandora_object_print_object', array(
'object' => $object,
'dc_array' => $variables,
'metadata' => $metadata,
'islandora_content' => $alter));
'object' => $object,
'dc_array' => $variables,
'metadata' => $metadata,
'islandora_content' => $alter));
return array('Default output' => array('#markup' => $output));
}
@ -1223,7 +1210,7 @@ function islandora_object_load($object_id) {
try {
return $tuque->repository->getObject(urldecode($object_id));
}
catch (Exception $e) {
catch (Exception $e) {
if ($e->getCode() == '404') {
return FALSE;
}
@ -1671,10 +1658,10 @@ function islandora_object_access($op, $object, $user = NULL) {
module_load_include('inc', 'islandora', 'includes/utilities');
$results = islandora_invoke_hook_list('islandora_object_access', $object->models, array(
$op,
$object,
$user,
));
$op,
$object,
$user,
));
// Nothing returned FALSE, and something returned TRUE.
$cache[$op][$object->id][$user->uid] = (!in_array(FALSE, $results, TRUE) && in_array(TRUE, $results, TRUE));
@ -1716,23 +1703,23 @@ function islandora_datastream_access($op, $datastream, $user = NULL) {
if (!isset($cache[$op][$datastream->parent->id][$datastream->id][$user->uid])) {
module_load_include('inc', 'islandora', 'includes/utilities');
$object_results = islandora_invoke_hook_list('islandora_object_access', $datastream->parent->models, array(
$op,
$datastream->parent,
$user,
));
$op,
$datastream->parent,
$user,
));
$datastream_results = islandora_invoke_hook_list('islandora_datastream_access', $datastream->parent->models, array(
$op,
$datastream,
$user,
));
$op,
$datastream,
$user,
));
// The datastream check returned FALSE, and one in the object or datastream
// checks returned TRUE.
$cache[$op][$datastream->parent->id][$datastream->id][$user->uid] = (
!in_array(FALSE, $datastream_results, TRUE) &&
(in_array(TRUE, $object_results, TRUE) || in_array(TRUE, $datastream_results, TRUE))
);
!in_array(FALSE, $datastream_results, TRUE) &&
(in_array(TRUE, $object_results, TRUE) || in_array(TRUE, $datastream_results, TRUE))
);
}
return $cache[$op][$datastream->parent->id][$datastream->id][$user->uid];
@ -1804,10 +1791,10 @@ function islandora_islandora_datastream_modified(AbstractObject $object, Abstrac
'dsid' => $datastream->id,
);
$logging_results = islandora_do_derivatives($object, array(
'source_dsid' => $datastream->id,
'force' => TRUE,
'ds_modified_params' => $params,
));
'source_dsid' => $datastream->id,
'force' => TRUE,
'ds_modified_params' => $params,
));
islandora_derivative_logging($logging_results);
islandora_conditionally_clear_cache();
}
@ -1819,7 +1806,6 @@ function islandora_islandora_object_purged($pid) {
islandora_conditionally_clear_cache();
}
/**
* Implements hook_islandora_datastream_purged().
*/
@ -1839,22 +1825,22 @@ function islandora_form_simpletest_test_form_alter(array &$form) {
if ($filter_status) {
$filter_status_message = theme_image(array('path' => 'misc/watchdog-ok.png', 'attributes' => array())) . " ";
$filter_status_message .= t("Drupal filter at <strong>@filter_path</strong> is writable by the server.", array(
'@filter_path' => $filter_path,
));
'@filter_path' => $filter_path,
));
}
else {
$filter_status_message = theme_image(array('path' => 'misc/watchdog-error.png', 'attributes' => array())) . " ";
$filter_status_message .= t("Drupal filter at <strong>@filter_path</strong> is not writable by the server. Please make sure your webserver has permission to write to the Drupal filter. If the path given is incorrect, you will need to change it in your server's test config file, located in the Islandora module's 'tests' folder as test_config.ini or default.test_config.ini.", array(
'@filter_path' => $filter_path,
));
'@filter_path' => $filter_path,
));
}
$form['tests'] = array(
'#type' => 'fieldset',
'#title' => t('Tests'),
'#description' => t("Select the test(s) or test group(s) you would like to run, and click <em>Run tests</em>.<p>NOTE: Tests in groups prefixed with <em>Islandora</em> generally require a configuration file, found in the Islandora module 'tests' folder, as well as the use of the Islandora Drupal filter. Before any tests are run, please ensure that your web server has the appropriate permissions to alter the drupal-filter.xml file in your Fedora config folder. Your original Islandora Drupal filter configuration will NOT be overwritten by tests; HOWEVER, if PHP exits abnormally before the filter is reset, please use the 'Repair Drupal Filter' button below.</p><p><em>Drupal Filter Write Status:</em> !filter_status_message</p>", array(
'!filter_status_message' => $filter_status_message,
)),
'!filter_status_message' => $filter_status_message,
)),
);
$form['tests']['table'] = array(
@ -2032,12 +2018,12 @@ function islandora_menu_local_tasks_alter(&$data, $router_item, $root_path) {
$tab['#suffix'] = '</li>';
$tab['#theme'] = 'link';
$tab['#text'] = theme('image', array(
'path' => "$islandora_path/images/print-icon.png",
'alt' => t('Print Object'),
'attributes' => array(
'id' => 'print_btn',
),
));
'path' => "$islandora_path/images/print-icon.png",
'alt' => t('Print Object'),
'attributes' => array(
'id' => 'print_btn',
),
));
$tab['#path'] = "{$router_item['href']}/print_object";
$tab['#options'] = array(
'attributes' => array(),
@ -2174,27 +2160,7 @@ function islandora_islandora_get_breadcrumb_query_predicates(AbstractObject $obj
/**
* Implements hook_islandora_overview_object().
*/
function islandora_islandora_overview_object(AbstractObject $object) {
$cmodels = $object->models;
$rows = array();
foreach ($cmodels as $cmodel) {
if ($cmodel != 'fedora-system:FedoraObject-3.0') {
$o = islandora_object_load($cmodel);
if (is_object($o)) {
$rows[] = array(l($o->label, "islandora/object/{$o->id}"));
}
else {
$rows[] = array(t("@cmodel - (This content model is not in this Islandora repository.)", array('@cmodel' => $cmodel)));
}
}
}
$header = format_plural(count($rows), 'Content Model', 'Content Models');
$table = array(
'#type' => 'markup',
'#theme' => 'table',
'#header' => array($header),
'#rows' => $rows,
'#empty' => t('No Islandora content model associated with this object.'),
);
return array('cmodels' => $table);
function islandora_create_manage_overview(AbstractObject $object) {
$output = theme('islandora_object_overview', array('islandora_object' => $object));
return array('cmodels' => $output);
}

41
theme/theme.inc

@ -130,8 +130,8 @@ function islandora_preprocess_islandora_default(&$variables) {
$datastreams[$id]['id'] = $id;
$datastreams[$id]['label'] = $label;
$datastreams[$id]['label_link'] = islandora_datastream_access(ISLANDORA_VIEW_OBJECTS, $ds) ?
l($label, $download_path) :
$label;
l($label, $download_path) :
$label;
$datastreams[$id]['download_url'] = $download_path;
$datastreams[$id]['mimetype'] = $ds->mimetype;
$datastreams[$id]['size'] = islandora_datastream_get_human_readable_size($ds);
@ -139,7 +139,7 @@ function islandora_preprocess_islandora_default(&$variables) {
$datastreams[$id]['class'] = drupal_strtolower(preg_replace('/[^A-Za-z0-9]/', '-', $id));
}
catch (RepositoryException $e) {
}
}
$variables['datastreams'] = $datastreams;
@ -268,8 +268,8 @@ function islandora_objects_object_mapper($object_id) {
$img = array(
'#theme' => 'image',
'#path' => ($o && islandora_datastream_access(ISLANDORA_VIEW_OBJECTS, $o['TN']) ?
"$url/datastream/TN/view" :
"$module_path/images/folder.png"),
"$url/datastream/TN/view" :
"$module_path/images/folder.png"),
'#attributes' => array(),
);
$img = drupal_render($img);
@ -412,8 +412,8 @@ function theme_islandora_datastream_download_link(array $vars) {
$label = t('download');
return islandora_datastream_access(ISLANDORA_VIEW_OBJECTS, $datastream) ?
l($label, islandora_datastream_get_url($datastream, 'download')) :
'';
l($label, islandora_datastream_get_url($datastream, 'download')) :
'';
}
/**
@ -543,8 +543,8 @@ function theme_islandora_datastream_edit_link(array $vars) {
$can_edit = count($edit_registry) > 0 && islandora_datastream_access(ISLANDORA_METADATA_EDIT, $datastream);
return $can_edit ?
l(t('edit'), "islandora/object/{$datastream->parent->id}/datastream/{$datastream->id}/edit") :
'';
l(t('edit'), "islandora/object/{$datastream->parent->id}/datastream/{$datastream->id}/edit") :
'';
}
/**
@ -647,3 +647,26 @@ function islandora_preprocess_islandora_dublin_core_description(array &$variable
}
$variables['dc_array'] = isset($dc_object) ? $dc_object->asArray() : array();
}
/**
* Implements hook_preprocess().
*/
function islandora_preprocess_islandora_object_overview(array &$variables) {
$object = $variables['islandora_object'];
$cmodels = $object->models;
$links = array();
foreach ($cmodels as $cmodel) {
if ($cmodel != 'fedora-system:FedoraObject-3.0') {
$o = islandora_object_load($cmodel);
if (is_object($o)) {
$links[] = array(l($o->label, "islandora/object/{$o->id}"));
}
else {
$links[] = array(t("@cmodel - (This content model is not in this Islandora repository.)", array('@cmodel' => $cmodel)));
}
}
}
$pluralized_identifier = format_plural(count($links), 'Islandora content model', 'Islandora content models');
$variables['header'] = t("This object's behavior is defined by the @identifier", array("@identifier" => $pluralized_identifier));
$variables['list'] = theme('item_list', array('items' => $links));
}

Loading…
Cancel
Save