46
How to Make an Islandora Solution Pack iCampCA, January 2014

Islandora Solution Pack How to Make an to make a...Islandora Solution Pack Drupal module, which defines: Forms for ingesting objects Functions for creating derivatives Themes for rendering

Embed Size (px)

Citation preview

Page 1: Islandora Solution Pack How to Make an to make a...Islandora Solution Pack Drupal module, which defines: Forms for ingesting objects Functions for creating derivatives Themes for rendering

How to Make anIslandora Solution Pack

iCampCA, January 2014

Page 2: Islandora Solution Pack How to Make an to make a...Islandora Solution Pack Drupal module, which defines: Forms for ingesting objects Functions for creating derivatives Themes for rendering

Islandora Solution Pack

● Drupal module, which defines:○ Forms for ingesting objects○ Functions for creating derivatives○ Themes for rendering objects and data streams○ Batches for managing objects○ Can define collections

● Typically defines Content Models and Collection Objects

Page 3: Islandora Solution Pack How to Make an to make a...Islandora Solution Pack Drupal module, which defines: Forms for ingesting objects Functions for creating derivatives Themes for rendering

Drupal Overview

● Hooks● Menus● Permissions● Theming

Docs: http://api.drupal.org/api/drupal/7

Page 4: Islandora Solution Pack How to Make an to make a...Islandora Solution Pack Drupal module, which defines: Forms for ingesting objects Functions for creating derivatives Themes for rendering

Drupal Hooks

● Functions that can be called by other modules

● Rely on ‘magic’ naming scheme● hook_do_something()● mymodule_do_something()

Page 5: Islandora Solution Pack How to Make an to make a...Islandora Solution Pack Drupal module, which defines: Forms for ingesting objects Functions for creating derivatives Themes for rendering

module_invoke_all($hook, $a, $b, $etc)● Invokes $hook in all enabled modules● hook_foo_bar() is implemented as

mymodule_foo_bar()

Page 6: Islandora Solution Pack How to Make an to make a...Islandora Solution Pack Drupal module, which defines: Forms for ingesting objects Functions for creating derivatives Themes for rendering

Example Hook

Page 7: Islandora Solution Pack How to Make an to make a...Islandora Solution Pack Drupal module, which defines: Forms for ingesting objects Functions for creating derivatives Themes for rendering

Implementation

Page 8: Islandora Solution Pack How to Make an to make a...Islandora Solution Pack Drupal module, which defines: Forms for ingesting objects Functions for creating derivatives Themes for rendering

Drupal Menus

● Multiple purpose○ Define routes○ Define tabs○ Define local actions○ Define callbacks○ Enforce permissions

Page 9: Islandora Solution Pack How to Make an to make a...Islandora Solution Pack Drupal module, which defines: Forms for ingesting objects Functions for creating derivatives Themes for rendering

Typical Menu Item

Page 10: Islandora Solution Pack How to Make an to make a...Islandora Solution Pack Drupal module, which defines: Forms for ingesting objects Functions for creating derivatives Themes for rendering

Menu Item ‘types’

MENU_NORMAL_ITEM Shows up as an item in the navigation menu and breadcrumbs

MENU_CALLBACK Associates a path with a callback function, used to render pages and generate non-HTML responses (JSON for example). No Navigation / Breadcrumbs

MENU_LOCAL_TASK Typically shows up as a tab

MENU_DEFAULT_LOCAL_TASK Shows up as the default tab

MENU_LOCAL_ACTION Typically shows up as a link

Page 11: Islandora Solution Pack How to Make an to make a...Islandora Solution Pack Drupal module, which defines: Forms for ingesting objects Functions for creating derivatives Themes for rendering

Menu Callback Function Arguments‘page callback' => 'islandora_fits_metadata_display','page arguments' => array(2),

http://localhost/drupal7/islandora/object/changeme%3A10/manage/fits_metadata

Page 12: Islandora Solution Pack How to Make an to make a...Islandora Solution Pack Drupal module, which defines: Forms for ingesting objects Functions for creating derivatives Themes for rendering

Drupal Permissions

● Define who can view/edit content● Define who can perform actions

Page 13: Islandora Solution Pack How to Make an to make a...Islandora Solution Pack Drupal module, which defines: Forms for ingesting objects Functions for creating derivatives Themes for rendering

hook_permission()

Page 14: Islandora Solution Pack How to Make an to make a...Islandora Solution Pack Drupal module, which defines: Forms for ingesting objects Functions for creating derivatives Themes for rendering

Permissions admin interface

Page 15: Islandora Solution Pack How to Make an to make a...Islandora Solution Pack Drupal module, which defines: Forms for ingesting objects Functions for creating derivatives Themes for rendering

Basics of a Module.info file.module file.install (Mention)Everything else:

/includes /theme /test

/js /css /data or /xml

Page 16: Islandora Solution Pack How to Make an to make a...Islandora Solution Pack Drupal module, which defines: Forms for ingesting objects Functions for creating derivatives Themes for rendering

Location of Modules

[drupalroot]/sites/default/modules/[drupalroot]/sites/all/modules/

[drupalroot]/sites/all/modules/mymodule/mymodule.infomymodule.module

Page 17: Islandora Solution Pack How to Make an to make a...Islandora Solution Pack Drupal module, which defines: Forms for ingesting objects Functions for creating derivatives Themes for rendering

Drupal Theming

● All HTML/XML/text sent to browser should pass through the theming layer

● Also enforces security● Theming allows local sites to override your

module’s output in template.php, etc.

Page 18: Islandora Solution Pack How to Make an to make a...Islandora Solution Pack Drupal module, which defines: Forms for ingesting objects Functions for creating derivatives Themes for rendering

Theming Components

● Theme functions● Preprocess functions● Templates

Page 19: Islandora Solution Pack How to Make an to make a...Islandora Solution Pack Drupal module, which defines: Forms for ingesting objects Functions for creating derivatives Themes for rendering

Theming Functions: hook_theme

Page 20: Islandora Solution Pack How to Make an to make a...Islandora Solution Pack Drupal module, which defines: Forms for ingesting objects Functions for creating derivatives Themes for rendering

theme_mymodule_my_hello($variables)

Page 21: Islandora Solution Pack How to Make an to make a...Islandora Solution Pack Drupal module, which defines: Forms for ingesting objects Functions for creating derivatives Themes for rendering

Calling Your Theming Hook$output = theme(‘mymodule_my_hello’, array(‘title’ => ‘This is my title’));

Don’t call theme functions directly aka theme_table, always use theme(‘theme_name’)

Page 22: Islandora Solution Pack How to Make an to make a...Islandora Solution Pack Drupal module, which defines: Forms for ingesting objects Functions for creating derivatives Themes for rendering

Templates

Page 23: Islandora Solution Pack How to Make an to make a...Islandora Solution Pack Drupal module, which defines: Forms for ingesting objects Functions for creating derivatives Themes for rendering

Preprocess Function

Page 24: Islandora Solution Pack How to Make an to make a...Islandora Solution Pack Drupal module, which defines: Forms for ingesting objects Functions for creating derivatives Themes for rendering

Template: mymodule-hello.tpl.php

<div><?php print $title; ?></div>

Page 25: Islandora Solution Pack How to Make an to make a...Islandora Solution Pack Drupal module, which defines: Forms for ingesting objects Functions for creating derivatives Themes for rendering

Back to Islandora….

● Tuque API● Islandora API● Content models● Collection policies● Islandora hooks● Islandora permissions

Page 26: Islandora Solution Pack How to Make an to make a...Islandora Solution Pack Drupal module, which defines: Forms for ingesting objects Functions for creating derivatives Themes for rendering

Islandora Versioning

● Version numbering scheme○ Drupal 7 version 1.2○ Github branch 7.x-release○ Github branch 7.x

● Always develop against HEAD (7.x)● Don’t mix and match versions

Page 27: Islandora Solution Pack How to Make an to make a...Islandora Solution Pack Drupal module, which defines: Forms for ingesting objects Functions for creating derivatives Themes for rendering

Tuque

● PHP library that provides an interface to the Fedora Commons REST API

● Separate from Islandora● Included by islandora/includes/tuque.inc

Page 29: Islandora Solution Pack How to Make an to make a...Islandora Solution Pack Drupal module, which defines: Forms for ingesting objects Functions for creating derivatives Themes for rendering

islandora.api.php

● You can find all the hooks defined by islandora in this file

● Is not functional code, is documentation for hooks

● Vs. Tuque○ Tuque is an interface to Fedora Commons○ Islandora implements Tuque like it would any other

library

Page 30: Islandora Solution Pack How to Make an to make a...Islandora Solution Pack Drupal module, which defines: Forms for ingesting objects Functions for creating derivatives Themes for rendering

islandora.api.php

● Common hooks○ View / Edit / Purge / Access / Derive

● What the syntax means (CMODEL_PID, etc)○ CMODEL_PID: Content Model PID○ DSID: Datastream ID

● islandora.api.php● islandora_invoke_hook_list()

Page 31: Islandora Solution Pack How to Make an to make a...Islandora Solution Pack Drupal module, which defines: Forms for ingesting objects Functions for creating derivatives Themes for rendering

Lets Start!

Page 32: Islandora Solution Pack How to Make an to make a...Islandora Solution Pack Drupal module, which defines: Forms for ingesting objects Functions for creating derivatives Themes for rendering

Fedora Content Model

Data objects: stored as XML (FOXML)Datastreams

Internal: stored in the object’s XMLManaged: external to object’s XMLExternal: linked in the object’s XMLRedirect: simple redirect

Page 33: Islandora Solution Pack How to Make an to make a...Islandora Solution Pack Drupal module, which defines: Forms for ingesting objects Functions for creating derivatives Themes for rendering

Common Islandora Object Datastreams● DC (Dublin-Core)● OBJ (Uploaded Content)● TN (Thumbnail)● MODS (Metadata, XML)● RELS-EXT (External Relationships, RDF)

Page 34: Islandora Solution Pack How to Make an to make a...Islandora Solution Pack Drupal module, which defines: Forms for ingesting objects Functions for creating derivatives Themes for rendering

RELS-EXT

Page 35: Islandora Solution Pack How to Make an to make a...Islandora Solution Pack Drupal module, which defines: Forms for ingesting objects Functions for creating derivatives Themes for rendering

Islandora Solution Pack

● Drupal module● Defines

○ forms for ingesting objects○ functions for creating derivatives○ functions for rendering objects and datastreams○ Can define collections

● Typically defines Content Models and Collection Policies

Page 37: Islandora Solution Pack How to Make an to make a...Islandora Solution Pack Drupal module, which defines: Forms for ingesting objects Functions for creating derivatives Themes for rendering

Collection PoliciesA solution pack can define both a Content Model and a Collection, as well as any number of other objects.

Collections are expected to● Be of type islandora:collectionCModel● Include a COLLECTION_POLICY datastream

Page 38: Islandora Solution Pack How to Make an to make a...Islandora Solution Pack Drupal module, which defines: Forms for ingesting objects Functions for creating derivatives Themes for rendering

Displaying the Object

Page 39: Islandora Solution Pack How to Make an to make a...Islandora Solution Pack Drupal module, which defines: Forms for ingesting objects Functions for creating derivatives Themes for rendering

Implementation

Page 41: Islandora Solution Pack How to Make an to make a...Islandora Solution Pack Drupal module, which defines: Forms for ingesting objects Functions for creating derivatives Themes for rendering

Implementation

Page 42: Islandora Solution Pack How to Make an to make a...Islandora Solution Pack Drupal module, which defines: Forms for ingesting objects Functions for creating derivatives Themes for rendering

Derivative Generation

● Using the derivative hook○ In 7.x HEAD only, not in release 1.2○ Prior solution packs used islandora_object_ingested

● hook_islandora_derivative()● hook_CMODEL_PID_islandora_derivative()

Page 43: Islandora Solution Pack How to Make an to make a...Islandora Solution Pack Drupal module, which defines: Forms for ingesting objects Functions for creating derivatives Themes for rendering

Prior to hook_islandora_derivative()

Page 44: Islandora Solution Pack How to Make an to make a...Islandora Solution Pack Drupal module, which defines: Forms for ingesting objects Functions for creating derivatives Themes for rendering
Page 45: Islandora Solution Pack How to Make an to make a...Islandora Solution Pack Drupal module, which defines: Forms for ingesting objects Functions for creating derivatives Themes for rendering

Islandora Permissions

● Gotcha’s ● Object exists● Object is of a certain type● Datastream permissions● Access callbacks● XACML can influence this as well.

Page 46: Islandora Solution Pack How to Make an to make a...Islandora Solution Pack Drupal module, which defines: Forms for ingesting objects Functions for creating derivatives Themes for rendering

Access Callbacks

// Permissions (selected list, see islandora.module for rest: https://github.com/Islandora/islandora/blob/7.x/islandora.module#L84-L362)define('ISLANDORA_VIEW_OBJECTS', 'view fedora repository objects');define('ISLANDORA_METADATA_EDIT', 'edit fedora metadata');define('ISLANDORA_INGEST', 'ingest fedora objects');