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. 39
      theme/theme.inc

134
islandora.module

@ -22,7 +22,6 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with the program. If not, see <http ://www.gnu.org/licenses/>. * along with the program. If not, see <http ://www.gnu.org/licenses/>.
*/ */
// Common datastreams. // Common datastreams.
define('ISLANDORA_DS_COMP_STREAM', 'DS-COMPOSITE-MODEL'); define('ISLANDORA_DS_COMP_STREAM', 'DS-COMPOSITE-MODEL');
@ -459,7 +458,8 @@ function islandora_theme() {
'variables' => array( 'variables' => array(
'object' => NULL, 'object' => NULL,
'content' => NULL, 'content' => NULL,
'islandora_content' => NULL), 'islandora_content' => NULL,
),
), ),
// Render a bunch of objects as either a grid or a list. // Render a bunch of objects as either a grid or a list.
'islandora_objects' => array( 'islandora_objects' => array(
@ -562,6 +562,12 @@ function islandora_theme() {
'file' => 'includes/solution_packs.inc', 'file' => 'includes/solution_packs.inc',
'render element' => 'form', '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 * TRUE if the user is allowed to access this object/datastream, FALSE
* otherwise. * 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'); module_load_include('inc', 'islandora', 'includes/utilities');
$is_repository_accessible = &drupal_static(__FUNCTION__); $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) { function islandora_manage_overview_object(AbstractObject $object) {
module_load_include('inc', 'islandora', 'includes/utilities'); 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); $hooks = islandora_build_hook_list(ISLANDORA_OVERVIEW_HOOK, $object->models);
foreach ($hooks as $hook) { foreach ($hooks as $hook) {
$temp = module_invoke_all($hook, $object); $temp = module_invoke_all($hook, $object);
islandora_as_renderable_array($temp); islandora_as_renderable_array($temp);
if (!empty($temp)) { if (!empty($temp)) {
arsort($temp);
$output = array_merge_recursive($output, $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); drupal_alter($hooks, $object, $output);
islandora_as_renderable_array($output); islandora_as_renderable_array($output);
return $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. * 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); $metadata = islandora_retrieve_metadata_markup($object, TRUE);
$variables = isset($dc_object) ? $dc_object->asArray() : array(); $variables = isset($dc_object) ? $dc_object->asArray() : array();
$output = theme('islandora_object_print_object', array( $output = theme('islandora_object_print_object', array(
'object' => $object, 'object' => $object,
'dc_array' => $variables, 'dc_array' => $variables,
'metadata' => $metadata, 'metadata' => $metadata,
'islandora_content' => $alter)); 'islandora_content' => $alter));
return array('Default output' => array('#markup' => $output)); return array('Default output' => array('#markup' => $output));
} }
@ -1223,7 +1210,7 @@ function islandora_object_load($object_id) {
try { try {
return $tuque->repository->getObject(urldecode($object_id)); return $tuque->repository->getObject(urldecode($object_id));
} }
catch (Exception $e) { catch (Exception $e) {
if ($e->getCode() == '404') { if ($e->getCode() == '404') {
return FALSE; return FALSE;
} }
@ -1671,10 +1658,10 @@ function islandora_object_access($op, $object, $user = NULL) {
module_load_include('inc', 'islandora', 'includes/utilities'); module_load_include('inc', 'islandora', 'includes/utilities');
$results = islandora_invoke_hook_list('islandora_object_access', $object->models, array( $results = islandora_invoke_hook_list('islandora_object_access', $object->models, array(
$op, $op,
$object, $object,
$user, $user,
)); ));
// Nothing returned FALSE, and something returned TRUE. // Nothing returned FALSE, and something returned TRUE.
$cache[$op][$object->id][$user->uid] = (!in_array(FALSE, $results, TRUE) && in_array(TRUE, $results, 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])) { if (!isset($cache[$op][$datastream->parent->id][$datastream->id][$user->uid])) {
module_load_include('inc', 'islandora', 'includes/utilities'); module_load_include('inc', 'islandora', 'includes/utilities');
$object_results = islandora_invoke_hook_list('islandora_object_access', $datastream->parent->models, array( $object_results = islandora_invoke_hook_list('islandora_object_access', $datastream->parent->models, array(
$op, $op,
$datastream->parent, $datastream->parent,
$user, $user,
)); ));
$datastream_results = islandora_invoke_hook_list('islandora_datastream_access', $datastream->parent->models, array( $datastream_results = islandora_invoke_hook_list('islandora_datastream_access', $datastream->parent->models, array(
$op, $op,
$datastream, $datastream,
$user, $user,
)); ));
// The datastream check returned FALSE, and one in the object or datastream // The datastream check returned FALSE, and one in the object or datastream
// checks returned TRUE. // checks returned TRUE.
$cache[$op][$datastream->parent->id][$datastream->id][$user->uid] = ( $cache[$op][$datastream->parent->id][$datastream->id][$user->uid] = (
!in_array(FALSE, $datastream_results, TRUE) && !in_array(FALSE, $datastream_results, TRUE) &&
(in_array(TRUE, $object_results, TRUE) || in_array(TRUE, $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]; 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, 'dsid' => $datastream->id,
); );
$logging_results = islandora_do_derivatives($object, array( $logging_results = islandora_do_derivatives($object, array(
'source_dsid' => $datastream->id, 'source_dsid' => $datastream->id,
'force' => TRUE, 'force' => TRUE,
'ds_modified_params' => $params, 'ds_modified_params' => $params,
)); ));
islandora_derivative_logging($logging_results); islandora_derivative_logging($logging_results);
islandora_conditionally_clear_cache(); islandora_conditionally_clear_cache();
} }
@ -1819,7 +1806,6 @@ function islandora_islandora_object_purged($pid) {
islandora_conditionally_clear_cache(); islandora_conditionally_clear_cache();
} }
/** /**
* Implements hook_islandora_datastream_purged(). * Implements hook_islandora_datastream_purged().
*/ */
@ -1839,22 +1825,22 @@ function islandora_form_simpletest_test_form_alter(array &$form) {
if ($filter_status) { if ($filter_status) {
$filter_status_message = theme_image(array('path' => 'misc/watchdog-ok.png', 'attributes' => array())) . " "; $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_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 { else {
$filter_status_message = theme_image(array('path' => 'misc/watchdog-error.png', 'attributes' => array())) . " "; $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_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( $form['tests'] = array(
'#type' => 'fieldset', '#type' => 'fieldset',
'#title' => t('Tests'), '#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( '#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( $form['tests']['table'] = array(
@ -2032,12 +2018,12 @@ function islandora_menu_local_tasks_alter(&$data, $router_item, $root_path) {
$tab['#suffix'] = '</li>'; $tab['#suffix'] = '</li>';
$tab['#theme'] = 'link'; $tab['#theme'] = 'link';
$tab['#text'] = theme('image', array( $tab['#text'] = theme('image', array(
'path' => "$islandora_path/images/print-icon.png", 'path' => "$islandora_path/images/print-icon.png",
'alt' => t('Print Object'), 'alt' => t('Print Object'),
'attributes' => array( 'attributes' => array(
'id' => 'print_btn', 'id' => 'print_btn',
), ),
)); ));
$tab['#path'] = "{$router_item['href']}/print_object"; $tab['#path'] = "{$router_item['href']}/print_object";
$tab['#options'] = array( $tab['#options'] = array(
'attributes' => array(), 'attributes' => array(),
@ -2174,27 +2160,7 @@ function islandora_islandora_get_breadcrumb_query_predicates(AbstractObject $obj
/** /**
* Implements hook_islandora_overview_object(). * Implements hook_islandora_overview_object().
*/ */
function islandora_islandora_overview_object(AbstractObject $object) { function islandora_create_manage_overview(AbstractObject $object) {
$cmodels = $object->models; $output = theme('islandora_object_overview', array('islandora_object' => $object));
$rows = array(); return array('cmodels' => $output);
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);
} }

39
theme/theme.inc

@ -130,8 +130,8 @@ function islandora_preprocess_islandora_default(&$variables) {
$datastreams[$id]['id'] = $id; $datastreams[$id]['id'] = $id;
$datastreams[$id]['label'] = $label; $datastreams[$id]['label'] = $label;
$datastreams[$id]['label_link'] = islandora_datastream_access(ISLANDORA_VIEW_OBJECTS, $ds) ? $datastreams[$id]['label_link'] = islandora_datastream_access(ISLANDORA_VIEW_OBJECTS, $ds) ?
l($label, $download_path) : l($label, $download_path) :
$label; $label;
$datastreams[$id]['download_url'] = $download_path; $datastreams[$id]['download_url'] = $download_path;
$datastreams[$id]['mimetype'] = $ds->mimetype; $datastreams[$id]['mimetype'] = $ds->mimetype;
$datastreams[$id]['size'] = islandora_datastream_get_human_readable_size($ds); $datastreams[$id]['size'] = islandora_datastream_get_human_readable_size($ds);
@ -268,8 +268,8 @@ function islandora_objects_object_mapper($object_id) {
$img = array( $img = array(
'#theme' => 'image', '#theme' => 'image',
'#path' => ($o && islandora_datastream_access(ISLANDORA_VIEW_OBJECTS, $o['TN']) ? '#path' => ($o && islandora_datastream_access(ISLANDORA_VIEW_OBJECTS, $o['TN']) ?
"$url/datastream/TN/view" : "$url/datastream/TN/view" :
"$module_path/images/folder.png"), "$module_path/images/folder.png"),
'#attributes' => array(), '#attributes' => array(),
); );
$img = drupal_render($img); $img = drupal_render($img);
@ -412,8 +412,8 @@ function theme_islandora_datastream_download_link(array $vars) {
$label = t('download'); $label = t('download');
return islandora_datastream_access(ISLANDORA_VIEW_OBJECTS, $datastream) ? 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); $can_edit = count($edit_registry) > 0 && islandora_datastream_access(ISLANDORA_METADATA_EDIT, $datastream);
return $can_edit ? 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(); $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