grima

grima - whispering into alma's ear with APIs

This project is maintained by zemkat

Grima for developers

The main purpose of grima itself is to make it fast and simple to write new workflow helpers (grimas). Each grima is a directory (like MyGrima/) containing files like:

Specifying Input (XML)

If your grima takes input (most do), you can specify those fields using an XML document like the following:

<GrimaForm>
    <Title>Grima: Insert OCLC Number</Title>
    <Field
        name="mms_id"
        label="MMS ID of Bib"
        autocomplete="off"
        required="yes"
        placeholder="Bib to edit..."
    />
    <Field
        name="oclcnum"
        label="OCLC Number"
        autocomplete="off"
        required="yes"
        placeholder="OCLC Number to Insert..."
    />
</GrimaForm>

When you run the grima, this will generate a form like this one:

The elements are:

Specifying Behavior (PHP)

Your grima’s behavior will be specified by its PHP file, like this one for the grima called DeletePortfolio:

<?php

require_once("../grima-lib.php");

class DeletePortfolio extends GrimaTask {

    function do_task() {
        $port = new ElectronicPortfolio();
        $port->loadFromAlmaX($this['portfolio_id']);
        $port->deleteFromAlma();
        $this->addMessage('success',"Deleted portfolio {$port['portfolio_id']}: {$port['title']}");
    }

}

DeletePortfolio::RunIt();

A few notes:

Output: Display with another grima

The default behavior when a grima succeeds is to display the form again with any messages. If you want to call another grima, you can do this by overriding the print_success method of the GrimaTask, as is done in InsertOclcNo:

function print_success() {
    do_redirect('../PrintBib/PrintBib.php?mms_id=' . $this['mms_id']);
}

After the OCLC number has been successfully inserted into the specified record, the newly edited record is displayed using the PrintBib grima so that the user can confirmed that it worked correctly.

Hierarchy is another good choice for displaying a newly modified record tree.

Output: splats template engine

As seen in the above example, you can override the default output behavior by specifying your own print_success function inside your GrimaTask.

You can also trigger different behavior in print_success using the splats template engine. See PrintBib, Hierarchy, and MoreItems to see this in action.

(Documentation coming soon!)