How to Make an Islandora Solution Pack iCampCA, January 2014 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 Drupal Overview ● ● ● ● Hooks Menus Permissions Theming Docs: http://api.drupal.org/api/drupal/7 Drupal Hooks ● Functions that can be called by other modules ● Rely on ‘magic’ naming scheme ● hook_do_something() ● mymodule_do_something() module_invoke_all($hook, $a, $b, $etc) ● Invokes $hook in all enabled modules ● hook_foo_bar() is implemented as mymodule_foo_bar() Example Hook Implementation Drupal Menus ● Multiple purpose ○ ○ ○ ○ ○ Define routes Define tabs Define local actions Define callbacks Enforce permissions Typical Menu Item 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 Menu Callback Function Arguments ‘page callback' => 'islandora_fits_metadata_display', 'page arguments' => array(2), http://localhost/drupal7/islandora/object/changeme% 3A10/manage/fits_metadata Drupal Permissions ● Define who can view/edit content ● Define who can perform actions hook_permission() Permissions admin interface Basics of a Module .info file .module file .install (Mention) Everything else: /includes /theme /test /js /css /data or /xml Location of Modules [drupalroot]/sites/default/modules/ [drupalroot]/sites/all/modules/ [drupalroot]/sites/all/modules/mymodule/ mymodule.info mymodule.module 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. Theming Components ● Theme functions ● Preprocess functions ● Templates Theming Functions: hook_theme theme_mymodule_my_hello ($variables) 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’) Templates Preprocess Function Template: mymodule-hello.tpl.php <div><?php print $title; ?></div> Back to Islandora…. ● ● ● ● ● ● Tuque API Islandora API Content models Collection policies Islandora hooks Islandora permissions 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 Tuque ● PHP library that provides an interface to the Fedora Commons REST API ● Separate from Islandora ● Included by islandora/includes/tuque.inc Tuque Sample Snippets https://github. com/Islandora/islandora/wiki/Build,-Access,Modify-and-Delete-Fedora-objects-with-theTuque-interface 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 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() Lets Start! Fedora Content Model Data objects: stored as XML (FOXML) Datastreams Internal: stored in the object’s XML Managed: external to object’s XML External: linked in the object’s XML Redirect: simple redirect Common Islandora Object Datastreams ● ● ● ● ● DC (Dublin-Core) OBJ (Uploaded Content) TN (Thumbnail) MODS (Metadata, XML) RELS-EXT (External Relationships, RDF) RELS-EXT 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 Define the Content Model Include it along with any other required objects via: hook_islandora_required_objects() Content Models are expected to define a: DS_COMPOSITE_MODEL datastream Collection Policies A 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 Displaying the Object Implementation Ingest Forms Hooks ● Define your own forms and associate: ○ hook_islandora_xml_form_builder_forms() ○ hook_islandora_xml_form_builder_form_associations() ● Create / Insert steps into the ingest process. ○ hook_islandora_ingest_steps() ○ Image example Implementation 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() Prior to hook_islandora_derivative() Islandora Permissions ● ● ● ● ● ● Gotcha’s Object exists Object is of a certain type Datastream permissions Access callbacks XACML can influence this as well. 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');
© Copyright 2024