Omeka Developer Documentation¶
This is the developer documentation for Omeka 2. If you’re working on an Omeka theme or plugin, or on Omeka itself, you’ve come to the right place.
For documentation for end-users and site administrators, or for information about older Omeka versions, please visit the Omeka Codex instead.
Tutorials¶
What’s new in Omeka 2.0¶
Principles of Omeka 2.0¶
People who are familiar with conventions and patterns from Omeka 1.x will see many changes. Here are some ofbroad principles that went into the changes to Omeka 2.0
Record-centric¶
The design of Omeka 1.x tended to treat different database records as superficially very different, despite the fact they all inherit from the same class. Thus, we had functions item() alongside collection(), both of which performed very similar jobs of retrieving data from a record. Similarly, we had loop_items() and loop_collections(). That pattern extended into our plugins, e.g. simple_page() and loop_simple_pages(). This created excessive duplication of functionality.
In Omeka 2.0, we instead concentrated on the similarity across all records, designing single functions for similar tasks that work by either passing in a record or by passing in the name of the record type current in a view. For example, to retrieve the id from the current item in a view, use metadata('item', 'id'). For a collection: metadata('collection', 'id').
This requires some attention to the names of your models and how they are assigned to the view. The first parameter to metadata() will be made singular, with the assumption that the view object has a record assigned to that property name. Similarly, looping assumes a plural form, an sets the current record to the singular name.
Function Naming Conventions¶
To make our function names more consistent and easier to understand, we have introduced the following naming conventions.
- Functions that return an array or object begin with get_
- Functions that return a boolean being with is_ or has_
- Functions do not echo a string. Instead they return the string
Zend 2.0 Class Naming Conventions¶
In anticipation of an eventual move to using Zend 2.0, we have reorganized our directories and class names to conform with Zend 2.0 conventions. Thus, the classes representing records and the table for them are no longer in the same directory. Instead, there is a Table directory inside the directory containing the models. The name of the table class should be the model’s class name prefixed with Table_, e.g. Table_SimplePagesPage.
Migrating your code to Omeka 2.0¶
There are significant changes moving from Omeka 1.5 to Omeka 2.0. Principles of Omeka 2.0 offers an overall guide to the principles, both for theme developers and plugin developers.
Here, you will find a skeleton of typical tasks that will be required to migrate your code. Consult the reference section for code details.
Omeka an Archive?¶
While archivists can (and many do) use Omeka as a presentation layer to their digital holdings, Omeka is not archival management software. To underscore this fact, we’ve removed all mention of the word “archive” in the Omeka codebase and filesystem. This will require at least two additional steps when upgrading from earlier versions to 2.0:
Rename the archive/files/ directory to /archive/original/:
$ mv /path/to/omeka/archive/files/ /path/to/omeka/archive/original/
Rename the archive/ directory to files/:
$ mv /path/to/omeka/archive/ /path/to/omeka/files/
Logging and Debugging¶
Developers of both themes and plugins will need to be aware of the following changes in Omeka’s .htaccess file and config.ini file in application/config. Compare your existing files to the new .htaccess.changeme and config.ini.changeme files
.htaccess now includes an environment variable for development: # SetEnv APPLICATION_ENV development
config.ini now includes a setting for the minimal level of error logging. The default level is WARN. DEBUG is the lowest level of priority, and will show all messages. _log allows you to set your a priority, and the setting in config.ini must be set appropriately for the messages to be saved.
; log.priority ; The minimum priority level of messages that should be logged. ; default: Zend_Log::WARN (Logs warnings and above) log.priority = Zend_Log::DEBUG
Note
debug uses DEBUG priority, so to see messages logged by that function you must set the log priorty to DEBUG in config.ini.
Upgrading Plugins¶
As you look through the lists of typical tasks below, you might also want to consult Best Practices for Plugin Development
Typical tasks you will need to do to upgrade your plugins for Omeka 2.0 are:
- Change the classes your controllers and models extend from.
- Omeka_Controller_Action becomes Omeka_Controller_AbstractActionController
- Omeka_Record becomes Omeka_Record_AbstractRecord
- Update any helper functions you use in hooks for filters.
- Change your hook callbacks to have an array passed in. Typically, the expected variable name passed in in version 1.5 (e.g. $user) becomes the key for the corresponding data in the array, e.g. $user = $args['user'];. See Updating Plugins for 2.0: Hooks and Filters
- Update any filters you use. The third argument must now be an array to fit with the standard above.
- Change the helper functions used in the views * All functions of the form loop_{record type}, like loop_items(), become loop("{record type}")
- Change usage of functions that previously echoed content. For example, <?php head(); ?> should now be <?php echo head(); ?>.
Database¶
The abstract class records extend from is now Omeka_Record_AbstractRecord, not Omeka_Record
The following callbacks have been removed, along with their associated plugin hooks:
- beforeSaveForm
- afterSaveForm
- beforeInsert
- afterInsert
- beforeUpdate
- afterUpdate
- beforeValidate
- afterValidate
A boolean insert argument for the beforeSave and afterSave callbacks replaces the insert/update hooks.
The saveForm and forceSave methods are removed. Use Omeka_Record_AbstractRecord::save instead.
- SQL aliases are no longer the initials of the underlying table, they are the full table name (without the prefix). For example, the Items table alias was i in Omeka 1.x, but it is now items. You can call Omeka_Db_Table::getTableAlias to get the alias.
- Table classes can now optionally use the naming pattern Table_{Record} instead of {Record}Table. Omeka’s built-in tables use this new naming scheme.
- The Entity, EntitiesRelations, and EntityRelationships models, and their underlying tables are
removed. Any code relying on them must be changed or removed.
- User now directly stores the name and email data for users that was previously in the Entity.
- All mixins now have a prefix of Mixin_ on their class name, and have a new naming convention:
- Ownable is now Mixin_Owner.
- Taggable is now Mixin_Tag.
- ActsAsElementText is now Mixin_ElementText.
- PublicFeatured is now Mixin_PublicFeatured.
ACL and Permissions¶
Omeka_Acl is removed. All references to Omeka_Acl should be to Zend_Acl instead.
loadRoleList, loadResourceList, and loadAllowList were Omeka-specific methods, and are now gone. Now, just directly make individual calls to addRole(), addResource(), and allow(). You no longer need to use loadResourceList() to define the privileges for each resource.
checkUserPermission is also gone. Use isAllowed instead:
$acl->isAllowed(current_user(), 'Resource', 'privilege');
Controllers¶
Many methods that were previously directly called on a Controller are now controller helpers instead.
The database wrapper methods findById(), getTable('TableName'), getDb() are removed in favor of the Db helper:
// old: $record = $this->findById(); $record = $this->_helper->db->findById(); // old: $element = $this->getTable('Element')->find($elementId); $element = $this->_helper->db->getTable('Element')->find($elementId); // old: $db = $this->getDb(); $db = $this->_helper->db->getDb();
The Db helper is also now used to set the default model name. The _modelClass property is removed in favor of setDefaultModelName from the Db helper:
// 1.x public function init() { $this->_modelClass = 'MyModel'; } // 2.0 public function init() { $this->_helper->db->setDefaultModelName('MyModel'); }
The flash, flashSuccess, and flashError methods are removed in favor of the FlashMessenger helper:
$this->_helper->flashMessenger('A neutral message'); $this->_helper->flashMessenger('A success message!', 'success'); $this->_helper->flashMessenger('An error message.', 'error');
Omeka_Context¶
Omeka_Context is removed. Resources are instead available directly through Zend_Registry or through the bootstrap object:
$acl = Zend_Registry::get('bootstrap')->getResource('Acl');
Views¶
Many new CSS classes are available and should be used to ensure a consistent look and feel across Omeka plugins. It will be helpful to become familiar with them. For example, this is the new code structure to use if you need to create inputs yourself:
<div class="field"> <div class="two columns alpha"> <label for="some_input" class="required">Some Input Label</label> </div> <div class="inputs five columns omega"> <input type="text" name="some_input"> </div> </div>
Admin theme now displays an <h1> with the title you set for the page. You can remove those from your admin views.
Use new save panel features. For ease of use in the most common cases, the Omeka_Form_Admin is available.
Updating Themes¶
The number of global functions has been cut nearly in half in Omeka 2.0. This will require many changes to your themes, but will also make the patterns of usage much easier to follow and much more consistent.
Here are a few of the basic tasks for upgrading.
Change the various metadata-retrieval functions for different record types (e.g., item(), collection(), etc) to the generalized metadata function.
Change the loop structure for the various record types (e.g., loop_items(), loop_collections, etc) to the generalized loop function. Note that the structure changes from:
while(loop_items()):
to:
foreach(loop('items') as $item):
Use get_records when getting sets of any record within a theme. get_items, get_tags, and get_collections are all replaced by get_records.
Change the structure of any arrays passed to nav. nav now uses the Zend_Navigation component, which changes the way you need to specify the array of nav links. Zend has some more expansive documentation on the available options, but it’s pretty simple to convert the old label => url pairs to the new style:
echo nav(array( array('label' => 'Browse All', 'uri' => url('items')) array('label' => 'Browse By Tag', 'uri' => url('items/tags')) ));
Change other global functions that have changed. There is a complete list of old and new function names on our wiki.
Update calls to hooks and filters (wherever you use fire_plugin_hook and apply_filters). Typically, the expected variable name passed in in version 1.5 (e.g. $user) becomes the key for the corresponding data in the array, e.g. $user = $args['user']; See Updating Plugins for 2.0: Hooks and Filters
Plugin Basics¶
Best Practices for Plugin Development¶
Use Omeka_Plugin_AbstractPlugin¶
Omeka_Plugin_AbstractPlugin is here to ease common steps in setting up your plugin. See Understanding Omeka_Plugin_AbstractPlugin for details.
Method Naming Conventions¶
Method names must be in camelCase (e.g., getItem()).
For private or protected methods, prefix the method name with underscore (_).
See also the Zend Framework Coding Standards.
Maintain expected behaviors in Omeka¶
Omeka defines some hooks that operate on every record. For example, Omeka’s Omeka_Record_AbstractRecord::save method fires hooks before and after saving. In most cases, you don’t need to override it, but if you do, make sure you include $this->runCallbacks('beforeSave', $callbackArgs); and $this->runCallbacks('afterSave', $callbackArgs); where appropriate.
Similarly, whenever you override methods from abstract classes in Omeka, make sure that you have studied the parent methods’ code to include all the expected callback. This will allow other developers to work with the expected behaviors of the objects.
Also, if you use any non-standard routing in your plugin, you must override Omeka_Record_AbstractRecord::getRecordUrl so that it returns the correct url to the record. Compare the getRecordUrl() method on the SimplePagesPage model in the “Simple Pages” plugin.
Database changes¶
Omeka 2.0 switched MySQL database engines from MyISAM to InnoDB. We recommend that you set all plugin tables to InnoDB. Existing plugins may alter their tables during the upgrade hook:
public function hookUpgrade($args)
{
if (version_compare($args['old_version'], $newPluginVersion, '<')) {
// Change the storage engine to InnoDB.
$sql = "ALTER TABLE {$this->_db->TableName} ENGINE = INNODB";
$this->_db->query($sql);
}
}
Record API¶
We’ve made some major changes to the record API. The following internal callbacks have been removed:
- beforeSaveForm
- afterSaveForm
- beforeInsert
- afterInsert
- beforeUpdate
- afterUpdate
- beforeValidate
- afterValidate
As such, the following plugin hooks have been removed, where “*” is “record” or a specific record name (e.g. “item”, “collection”):
- before_save_form_*
- after_save_form_*
- before_insert_*
- after_insert_*
- before_update_*
- after_update_*
- before_validate_*
- after_validate_*
By removing these callbacks we give you full control over the timing of execution. Any logic that’s currently in the SaveForm, Insert, and Update callbacks should be moved to beforeSave() and afterSave(). Any logic that’s currently in the Validate callbacks should be moved to _validate(). For example:
// Note the order of execution.
public function beforeSave($args)
{
if ($args['insert']) {
// Do something before record insert. Equivalent to beforeInsert.
} else {
// Do something before record update. Equivalent to beforeUpdate.
}
// Do something before every record save.
if ($args['post']) {
// Do something with the POST data. Equivalent to beforeSaveForm.
}
}
// Note the order of execution.
public function afterSave($args)
{
if ($args['insert']) {
// Do something after record insert. Equivalent to afterInsert.
} else {
// Do something after record update. Equivalent to afterUpdate.
}
// Do something after every record save.
if ($args['post']) {
// Do something with the POST data. Equivalent to afterSaveForm.
}
}
Note that the signature of the beforeSave() and afterSave() has changed to beforeSave($args) and afterSave($args), with no type specified for $args. To adhere to strict standards, existing beforeSave and afterSave methods should reflect that change.
Another change is that Omeka_Record_AbstractRecord::saveForm() has been merged into save(). Using save() to handle a form in your controller can be done like this:
public function editAction()
{
// Check if the form was submitted.
if ($this->getRequest()->isPost()) {
// Set the POST data to the record.
$record->setPostData($_POST);
// Save the record. Passing false prevents thrown exceptions.
if ($record->save(false)) {
$successMessage = $this->_getEditSuccessMessage($record);
if ($successMessage) {
$this->_helper->flashMessenger($successMessage, 'success');
}
$this->_redirectAfterEdit($record);
// Flash an error if the record does not validate.
} else {
$this->_helper->flashMessenger($record->getErrors());
}
}
}
Use View Helpers instead of global functions¶
View helpers are preferred alternatives to global theming functions. They provide a convenient interface (called directly from the view object) to logic and/or markup that’s commonly used in view scripts. If you find yourself using global functions or static methods to support your views, consider using view helpers instead.
First, you must add your view helper directory path to the stack during plugin initialization:
public function hookInitialize()
{
get_view()->addHelperPath(dirname(__FILE__) . '/views/helpers', 'PluginName_View_Helper_');
}
Replace PluginName with your plugin’s name. The helpers/ directory may be anywhere in your plugin’s directory structure, but we recommend that you place it in the views/ directory for consistency.
Then create your view helper file in the helpers/ directory (named something like ViewHelperName.php) and in that file write your view helper class:
class PluginName_View_Helper_ViewHelperName extends Zend_View_Helper_Abstract
{
public function viewHelperName($arg1, $arg2)
{
// Build markup.
return $markup;
}
}
Note the use of UpperCamelCase and lowerCamelCase. The viewHelperName() method can accept any number of arguments and should return something, most often markup. You may add __construct() to the class if the helper needs a one-time setup (e.g. to assign class properties). The constructor will not be called on subsequent calls to the helper.
Now you can call your view helper directly in your view script like so:
<p><?php echo $this->viewHelperName() ?></p>
Use View Partials¶
View partials let you separate out parts of long or complicated views into separate files. For example, if you have a browse view that allows different ordering, it is best to use view partials to separate the code for the different orderings to be in different partials. For example:
<?php if (isset($_GET['view']) && $_GET['view'] == 'hierarchy'): ?>
<?php echo $this->partial('index/browse-hierarchy.php', array('simplePages' => get_simple_pages_for_loop())); ?>
<?php else: ?>
<?php echo $this->partial('index/browse-list.php', array('simplePages' => get_simple_pages_for_loop())); ?>
<?php endif; ?>
When using hooks that add markup to views, such as admin_items_show, consider using partials instead of outputting markup directly in the callback.
Use Jobs instead of Processes¶
We highly recommend that all processes that may run longer than a typical web process are sent to a job. The job will mediate the process, reducing the chance of timeout and memory usage errors that can happen even with the best written code. To run a job just write a class that contains the code to run, like so:
class YourJob extends Omeka_Job_AbstractJob
{
public function perform()
{
// code to run
}
}
You have two options on how to run the code: default and long-running. The default way is intended to run processes that, though are more processor-intensive than the typical web process, are usually not in danger of timing out. You can run these processes like so:
Zend_Registry::get('bootstrap')->getResource('jobs')->send('YourJob');
Your other option is intended for processes that will most likely result in a timeout error if run as a normal web script. Processes that import thousands of records or convert hundreds of images are examples of such processes. You can run these processes like so:
Zend_Registry::get('bootstrap')->getResource('jobs')->sendLongRunning('YourJob');
It’s important to note that nothing that uses the job system should assume or require synchronicity with the web process. If your process has to be synchronous, it shouldn’t be a job.
Load Resources for Jobs At Will¶
In previous versions, long running processes were fired directly through a background process via ProcessDispatcher::startProcess(), which loaded resources (e.g. Db, Option, Pluginbroker) in phases. Phased loading is now removed in favor of loading resources when needed.
When using the background process adapter for your jobs (typically used for long running jobs), the following resources are pre-loaded for you: Autoloader, Config, Db, Options, Pluginbroker, Plugins, Jobs, Storage, Mail. If you need other resources, load them like so in your job:
Zend_Registry::get('bootstrap')->bootstrap('YourResource');
Setting Up Your Plugin’s Config Page¶
Building Forms in Admin¶
Omeka 2.0 admin interface works with modern CSS and design practices, including responsive design. Omeka 2.0 therefore also includes a Omeka_Form_Admin class to help you quickly and easily build simple forms. It should be suitable for building basic add/edit forms. The SimplePages plugin makes uses it, can can offer a good example of usage.
It is best to put your form-building logic into your controller, e.g. in a _getForm() method. The Omeka_Form_Admin class works basically as follows.
If you are editing an existing record, instantiate it like so: $form = new Omeka_Form_Admin(array('record'=>$record);
If the form is for a record (which is typically the case), pass the record as one of the options. Additionally, if you want a link to the record’s public page on the admin side, pass 'hasPublicPage'=>true as an option:
$options = array('record'=>$record, 'hasPublicPage'=>true);
Other options available for Omeka_Form_Admin are:
- string type
- Often, this will be the record type (e.g. ‘simple_pages_page’), but can be anything. Hooks for the save panel follow the type that you give. See admin_<type>_panel_buttons and admin_<type>_panel_fields.
- string editGroupCssClass
- Change the CSS classes for the ‘main’ edit area. This should rarely be necessary.
- string saveGroupCssClass
- Change the CSS classes for the save panel. This should rarely be necessary.
To add your form elements to the main editing area, use Omeka_Form_Admin::addElementToEditGroup. You can either pass in a Zend_Form_Element you have already built, or pass in the parameters to build the element as if you were creating one. For example, creating a text input looks like this:
$form->addElementToEditGroup(
'text', 'title',
array(
'id'=>'simple-pages-title',
'size' => 40,
'value' => metadata($page, 'title'),
'label' => 'Title',
'description' => 'The title of the page (required).',
'required' => true
)
);
The first argument specifies the element type (text, textarea, etc.). The second gives the name to be used on the element in the form. The third gives a keyed array of various attributes for the element, as well as a label and a description.
If you build the Zend_Form_Element yourself, you can simply pass that in as the first parameter and leave the rest empty.
In some cases, it makes sense to add an element directly to the save panel on the right. This should be reserved for small, peripheral data, such as whether a record is public or featured, if the model implements those features.
Doing so works similarly, using the Omeka_Form_Admin::addElementToSaveGroup method:
$form->addElementToSaveGroup(
'checkbox', 'is_published',
array(
'id' => 'simple_pages_is_published',
'values' => array(1, 0),
'checked' => metadata($page, 'is_published'),
'label' => 'Publish this page?',
'description' => 'Checking this box will make the page public and it will appear in Simple Page navigation.'
)
);
As with addElementToEditGroup(), you can build the element yourself and pass it as the first parameter.
For more complex form requiring tabs and a variety of sections, you’ll want to familiarize yourself with Understanding the Admin Css.
See also Working with the Admin Theme, which includes more details of how the HTML is constructed, and the CSS classes involved.
Search¶
Omeka 2.0 allows any record to be full-text searchable, not just items, but also files, collections, exhibits, etc. This includes records implemented by your plugin.
Individual record indexing and bulk-indexing will only work on record types that have been registered via the new search_record_types filter:
public function filterSearchRecordTypes($searchableRecordTypes)
{
// Register the name of your record class. The key should be the name
// of the record class; the value should be the human readable and
// internationalized version of the record type.
$searchableRecordTypes['YourRecord'] = __('Your Record');
return $searchableRecordTypes;
}
Follow this template to make your record searchable:
class YourRecord extends Omeka_Record_AbstractRecord
{
// Add the search mixin during _initializeMixins() and after any mixins
// that can add search text, such as Mixin_ElementText. Doing this
// tells Omeka that you want this record to be searchable.
protected function _initializeMixins()
{
// Add the search mixin.
$this->_mixins[] = new Mixin_Search($this);
}
// Use the afterSave() hook to set the record's search text data.
protected function afterSave($args)
{
// A record's search text is public by default, but there are times
// when this is not desired, e.g. when an item is marked as
// private. Make a check to see if the record is public or private.
if ($private) {
// Setting the search text to private makes it invisible to
// most users.
$this->setSearchTextPrivate();
}
// Set the record's title. This will be used to identify the record
// in the search results.
$this->setSearchTextTitle($recordTitle);
// Set the record's search text. Records that implement the
// Mixin_ElementText mixin during _initializeMixins() will
// automatically have all element texts added. Note that you
// can add multiple search texts, which simply appends them.
$this->addSearchText($recordTitle);
$this->addSearchText($recordText);
}
// The search results need a route to the record show page, so build
// a routing array here. You can also assemble the URL yourself using
// the URL view helper and return the entire URL as a string.
public function getRecordUrl($action)
{
if ('your-show-action' == $action) {
return $yourCustomRecordShowUrl;
}
return array(
'module' => 'your-module',
'controller' => 'your-controller',
'action' => $action,
'id' => $this->id,
);
}
}
Once this is done you should enable the new search record type and re-index all records in your admin interface, under Settings > Search.
Customizing Search Type¶
Omeka now comes with three search query types: keyword (full text), boolean, and exact match. Full text and boolean use MySQL’s native full text engine, while exact match searches for all strings identical to the query.
Plugin authors may customize the type of search by implementing the search_query_types filter. For example, if you want to implement a “ends with” query type that searches for records that contain at least one word that ends with a string:
public function filterSearchQueryTypes($queryTypes)
{
// Accept an array and return an array.
function your_search_query_types_callback($queryTypes)
{
// Register the name of your custom query type. The key should be
// the type's GET query value; the values should be the human
// readable and internationalized version of the query type.
$queryTypes['ends_with'] = __('Ends with');
return $queryTypes;
}
}
Then you must modify the search SQL using the search_sql hook, like so:
public function hookSearchSql($args)
{
$params = $args['params'];
if ('ends_with' == $params['query_type']) {
$select = $args['select'];
// Make sure to reset the existing WHERE clause.
$select->reset(Zend_Db_Select::WHERE);
$select->where('`text` REGEXP ?', $params['query'] . '[[:>:]]');
}
}
Remember that you’re searching against an aggregate of all texts associated with a record, not structured data about the record.
Understanding Hooks¶
Hooks and Filters are the two ways to modify and extend Omeka’s capabilities. A hook “fires” in response to some action taking place in Omeka, such as saving a record, deleting a record, rendering some kinds of pages, installing a plugin, etc.
When a hook fires, it sends relevant data to a callback function. The callback function then performs any necessary actions with the data before Omeka moves on to the next callback registered for the hook, or if no more callback remain Omeka continues on with its own processing.
To take a common example, plugins will often add new kinds of information about items in Omeka. Thus, when items are saved, various plugins will need to update their own records to reflect the new changes. Since Omeka itself knows nothing of the extended functionality, this takes place through the before_save_item and after_save_item hooks.
Those callbacks to those hooks get data about the record and about the $_POST data submitted. The callbacks define by each plugin run in turn, updating their own records. After all of the callbacks have run, Omeka finally completes its process for saving the item.
Another common example is the install hook. This fires when a plugin is activated, so unlike the previous example only one callback is run – the callback defined by that plugin. This is where a plugin would create its database tables, set options, and do any other initial setup.
Hook callbacks always receive one array of arguments (though that array may be empty). They never return a value. If content is to be printed to the screen, they should use echo internally.
Understanding Filters¶
Hooks and filters are the two ways to modify and extend Omeka’s capabilities. Filters are a way for data in Omeka to be passed among different plugins that want to add to it or modify it in some way before final processing by Omeka. Typical examples include adding navigation links and changing default behaviors.
Essential Classes in Omeka¶
Understanding Omeka_Plugin_AbstractPlugin¶
Omeka_Plugin_AbstractPlugin is designed to streamline common tasks for a plugin, such as defining hook and filter callbacks and setting options when the plugin is installed.
To use it, simply create a class for your plugin as its own file in the plugins directory:
// In plugins/YourPlugin/YourPluginPlugin.php
class YourPluginPlugin extends Omeka_Plugin_AbstractPlugin
{}
Hook and filter callbacks are defined with an array. One change introduced in Omeka 2.0 is arbitrary hook and filter callback names. Before, all callback names followed a predetermined format. While this format remains an option, now a corresponding key in $_hooks and $_filters will be interpreted as the name of the callback method.
protected $_filters = array('admin_navigation_main',
'public_navigation_main',
'changeSomething' => 'display_setting_site_title',
'displayItemDublinCoreTitle' => array(
'Display',
'Item',
'Dublin Core',
'Title',
));
protected $_hooks = array('install', 'uninstall');
When installing your plugin, there might be options that need to be set. You can do this easily within the install callback by adding an $_options array and calling Omeka_Plugin_AbstractPlugin::_installOptions from the install callback, and Omeka_Plugin_AbstractPlugin::_uninstallOptions in the uninstall callback. The array is name-value pairs for the name of the option and initial value.
protected $_hooks = array('install', 'uninstall');
protected $_options = array('my_plugin_option'=>'option_value');
public function install() {
$this->_installOptions();
}
public function uninstall() {
$this->_uninstallOptions();
}
When creating tables for your plugin in the install hook, use the _db property. Omeka will convert your model names into the appropriate table names.
public function hookInstall() {
$db = $this->_db;
$sql = "
CREATE TABLE IF NOT EXISTS `$db->MyPluginModel` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`modified_by_user_id` int(10) unsigned NOT NULL,
. . .
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci";
$db->query($sql);
}
Understanding Omeka_Record_AbstractRecord¶
Understanding Omeka_Db_Table¶
Basics¶
Omeka_Db_Table is part of the Model part of Model-View-Controller in Omeka. It provides the methods for querying the database and returning results as Omeka_Record_AbstractRecord objects. The most frequently used methods in this class are Omeka_Db_Table::findBy and Omeka_Db_Table::find
Omeka_Db_Table::find simply returns a single record by the id passed in.
Omeka_Db_Table::findBy returns an array of records that match the criteria passed in with the $param argument. When creating your subclasses of Omeka_Db_Table, you will want to understand first how to build filters for queries using Omeka_Db_Table::findBy.
Omeka_Db_Table::findBy works by manipulating a Omeka_Db_Select object, which simplifies the process fo building simple SQL queries.
Filtering Queries¶
Omeka_Db_Table::findBy calls method Omeka_Db_Table::applySearchFilters. It takes a $select argument, and a $params argument. By default, this method simply checks the $params array passed in, looking for keys that match column names. For each match, a WHERE clause is generated.
Sometimes, though, it makes sense to add more complex logic. For example, you might want to filter a query by conditions on joining another table, or you might need to call a method in your subclass to process the data passed in the value of the parameter key. In such cases, Omeka has moved toward a pattern of using filterBy* methods.
In this pattern, you build more complex logic for adding a WHERE clause by passing in the $select object, and the value that you want to work with. Table_Collection offers a good example.
public function filterByPublic($select, $isPublic) { $isPublic = (bool) $isPublic; // this makes sure that empty strings and unset parameters are false //Force a preview of the public collections if ($isPublic) { $select->where('collections.public = 1'); } else { $select->where('collections.public = 0'); } }
This method does a little double-checking on the value passed in for whether the collection has been marked public, then applies the appropriate WHERE clause to the $select object.
In Table_Collection::applySearchFilters, we see the following to call it:
if(array_key_exists('public', $params)) { $this->filterByPublic($select, $params['public']); }
Understanding Omeka_Controller_AbstractActionController¶
The Admin Theme¶
Understanding the Admin Css¶
Responsive Design¶
The Omeka Admin theme uses Skeleton development kit for easy, responsive styles. Each page consists of a twelve-column grid, with sections’ columns defined by css classes. For example, a three column section would have the classes “three columns”.

The first two columns are dedicated to navigation, while the latter ten holds the main content. Plugin views are contained within ten columns, and plugin writers should look to the structure of other admin views for markup patterns.
Within the main content, Omeka forms typically take up seven columns, and leave the last three for a save panel that follows the user down the page. The following is an example of markup from the “Add Item” view. The “alpha” class signifies the first set of columns within a set, and “omega” signifies the last set of columns. These classes modify the left and right margins respectively.
<section class="seven columns alpha" id="edit-form">
<form method="post" enctype="multipart/form-data" id="item-form" action="">
...
</form>
</section>
<section class="three columns omega">
...
</section>
For reference:
- Official Skeleton website
- Build a Responsive, Mobile-Friendly Web Page With Skeleton (For a more detailed guide on understanding and using Skeleton.)
Working with the Admin Theme¶
Building a Configuration Form for Your Plugin¶
Most of the page, including the save button and overall layout is built for you. You only need to supply the actual inputs to use. The following template will help you build your forms in a way that is consistent with the rest of Omeka:
<div class="field">
<div class="two columns alpha">
<label></label>
</div>
<div class="inputs five columns omega">
<p class="explanation"></p>
<div class="input-block">
<input />
</div>
</div>
</div>
Understanding Omeka_Form_Admin¶
Omeka_Form_Admin is designed to make it easier for most plugins to conform to the look and feel of Omeka’s admin interface. In most, but not all, cases, this class will let you easily construct your form. More complex forms might require building the form from scratch.
Like the rest of Omeka, it relies heavily on Zend’s form elements. Read Understanding Form Elements for a primer.
Basics¶
The admin editing screen generally consist of two areas, the ‘main’ area and the ‘save panel’, which includes the save and delete buttons, as well as miscellaneous buttons and sometimes some form elements. Omeka_Form_Admin is meant to make building those areas in a way that keeps the look and feel as the rest of the admin theme as easy as possible for most kinds of forms. It does this by creating a DisplayGroup for each of the two areas, styling them appropriately, and letting you add your form elements to them.
It is generally best to put the logic for building your form inside a method of your controller, e.g. in _getForm($record). You then add it to your add and edit views the usual way: $this->view->form = $this->_getForm($record). Generally, extending Omeka_Form_Admin is not necessary.
Create the form like so:
protected function _getForm($record)
{
$formOptions = array('type' => 'my_type', 'hasPublicPage'=>true);
if($record && $record->exists()) {
$formOptions['record'] = $record;
}
$form = new Omeka_Form_Admin($formOptions);
// build the form elements
return $form;
}
The form option type is required. Typically, this is the name of your record type (e.g., ‘item’). Hooks into the save panel are based on this type. See admin_<type>_panel_buttons, admin_<type>_panel_fields, and admin_<type>_form
hasPublicPage is a flag to determine whether a link to the record’s public page should be created in the save panel. Defaults to false.
Building the main edit area¶
The ‘main’ content area is where the primary parts of your form go: text inputs, most select dropdowns, etc.
Use the Omeka_Form_Admin::addElementToEditGroup to add your elements to the main edit area:
Building the save panel¶
The save and delete buttons will the automatically added to the save panel. Some true form elements also make more sense in this area than in the main editing area. Often, data that is entered via a simple checkbox is a good candidate for having the form element here. Whether a page is public or not is a good example.
$form->addElementToSaveGroup('checkbox', 'is_published',
array('id' => 'my_plugin_is_published',
'values' => array(1, 0),
'checked' => metadata($record, 'is_published'),
'label' => 'Publish this page?',
'description' => 'Checking this box will make the page public.'
));
Understanding Form Elements¶
Omeka makes heavy use of Zend’s Form_Element class for building forms, rather than writing out the HTML explicitly.
Typically, elements are added directly to an Omeka_Form object or an Omeka_Form_Admin object.
The basic structure is to use the addElement() method, with three parameters:
- string $element
A string name for the form element. Typical examples are: button, captcha, checkbox, file, multicheckbox, multiselect, radio, select, submit, text, textarea.
An element object can also be passed in here. In this (rare) case, the other two parameters are usually unnecessary
- string $name
- The name attribute for the form element
- array $options
Additional options for the form element. label, description, and required are the most common options. HTML attributes such as rows and cols can also appear here, as well as class
In more complex examples, an array of validators can also be passed here
Examples¶
$form->addElement('textarea', 'description', array(
'label' => __('Description'),
'description' => __('My record description'),
'rows' => 10
));
$form->addElement('text', 'user_email', array(
'label' => __('Email'),
'description' => __("Prefered email address of the person submitting the record"),
'validators' => array('EmailAddress'),
'required' => true
));
For a more extended example, see the IndexController::_getForm() method in the SimplePages plugin, bundled with Omeka.
Modifying Themes¶
Modifying Themes¶
Overriding default templates¶
Omeka has a set of default template files that all themes use, and override when the desired page structure is different from the default.
The default theme files are in the folder /application/views/scripts in your Omeka installation. Subfolders correspond to the pages that are seen along url patterns. For example, the page displayed at {YourOmekaSite}/items/show is produced by the file in /application/views/scripts/items/show.php.
Themes might or might not override these files. The default theme, for example, has an items directory that overrides two of the default templates: random-featured.php and show.php
items/
random-featured.php
show.php
If you want to modify a file in a theme, the first place to look is in the theme’s own directories. But notice that that will only work if the theme has overridden the default template. In many cases, then, you will need to copy the default template files into the theme, taking care to maintain the directory structure.
So, for example, imagine wanting to modify the show page for items, the browse page for items, and the show page for collections in the default theme.
The /items/show.php file is easy, since the default theme already includes it.
For the browse page for items, we need to copy /application/views/scripts/items/browse.php to /default/items/browse.php
For the browse page for collections, we need to first create the directory: /default/collections
Then we can copy /application/views/scripts/collections/browse.php to /default/collections/browse.php
The result in the default theme will look like:
items/
random-featured.php
browse.php
show.php
collections/
browse.php
Working with Public Themes¶
Themes included in Omeka 2.0, “Thanks, Roy” and “Seasons”, have been rebuilt with two new features: Compass project files and Susy responsive grids. Compass is a CSS framework that utilizes the Sass preprocessor to generate styles, making it easier for front-end developers to manage typography, margin units, colors, and more. Susy is a responsive grid library that can be imported into Compass. Responsive grids allow sites to adapt to the browser width, making content more easily readable on a variety of devices.
For users who want to start using Compass and Susy with Omeka themes, here are recommended tutorials for installation. Both Compass and Susy require Ruby to be installed, and users should be comfortable with the command line.
- The Sass Way: Getting started with Sass and Compass
- The official Compass installation tutorial
- The official Susy installation tutorial
Those who simply want to edit the CSS without getting into preprocessors can ignore the ‘css/sass’ folder completely and focus on .css files. Note: if you edit a .css file but later decide to use Sass, you should back up and make note of your changes before compiling for the first time. Changes made in .scss files overwrite any changes made to .css files.
Omeka Theme Style Guide¶
Intro¶
This style guide is for use in writing themes for Omeka 2.0+. It borrows heavily from the Github style guide. This style guide is a work in progress, so excuse our dust.
Configuration¶
When setting up the Compass configuration for a theme, the settings should be as follows:
http_path = "/"
css_dir = "/"
sass_dir = "sass"
images_dir = "images"
javascripts_dir = "javascripts"
output_style = :expanded
line_comments = false
When using Git, make sure you include a .gitignore in the root of your theme folder. The most common inclusions are:
.DS_Store
.sass-cache/
Organization¶
As such, the /css directory of an Omeka theme should follow the following structure:
|- css
|--- sass
| |--- _base.scss
| |--- _normalize.scss
| |--- _print.scss
| |--- _screen.scss
| |--- style.scss
|--- config.rb
|--- style.css
Group your styles using commented headings and include a table of contents. Here is an example of a table of contents:
/*
Table of Contents
=================
-- General HTML Elements
----- Headings
----- Form Elements
-- Global Classes
-- Navigation
----- Pagination
-- Header
-- Footer
-- Content
*/
An example of a section heading:
/* !---------- Header ---------- */
Use the /* style of comments for headings you want to appear in the .css file. For Sass-only sections, such as the variables set in _bass.scss, use the // commenting syntax. The ! at the beginning of the header helps bookmark sections for theme writers using the Coda web editor.
_base.scss¶
The _base.scss file should include any variables used across multiple .scss files. Otherwise, the variables appear at the top of the file in which they are used.
_normalize.scss¶
We like to use Nicolas Gallagher’s normalize.css as our reset stylesheet. Include it as a .scss file and import it into _base.scss.
_screen.scss¶
If you are creating a responsive theme, _screen.scss is the default file for mobile-first styles. Separate .scss files should be used to group styles for different resolutions. Files should be named based on the breakpoint, i.e. _screen_480px.scss, _screen_360px.scss, _screen_40em.scss.
style.scss¶
If you are not creating a responsive theme, all styles should go in style.scss. The style.scss file should also import _base.scss and _normalize.scss. Responsive themes should also import all _screen_x.scss files here.
General styles¶
- Use 4 spaces for indentation. Do not use tabs.
- Use spaces after : when writing property declarations.
- Put spaces before { in rule declarations.
- Use hex color codes #000 unless using rgba.
International Locale Support¶
Internationalization¶
From Omeka 1.5 on, site admins can pick the locale they want Omeka to use. When working on the core, plugins, or themes, the code must be internationalized to make display in different languages and locales possible.
Text¶
For most plugins and themes, making user-facing text translatable will be the lion’s share of the internationalization work. All text strings that are presented to the user and are not editable by the user should be translated. This includes obvious suspects like text in paragraphs and other visible HTML elements, but also less obvious places like the <title> element or title and alt attributes.
Omeka uses one function for enabling text translation, the __ (double-underscore) function. Anything that needs to be translated must be passed through the double-underscore function.
Bare text¶
Before internationalization, a great deal of the user-facing text may be written directly in HTML or plain text, with no PHP code. Omeka’s translation works through a PHP function, so you need to introduce a PHP block.
Untranslatable
<p>Some text.</p>
Translatable
<p><?php echo __('Some text.'); ?></p>
Literal PHP strings¶
PHP strings that will end up being shown to the user also need to get translated. These strings are already in PHP code blocks, so the process is easy. Just wrap the double-underscore function around the string that’s already there.
Untranslatable
<?php
echo head(array(
'title' => 'Page Title'
));
?>
Translatable
<?php
echo head(array(
'title' => __('Page Title')
));
?>
Strings with variables¶
A common pattern in PHP is to write strings that directly contain variables. These need a slightly different approach to be translatable. The goal is to make translators only have to translate your string once, no matter what the particular values of the variables inside are.
To do this, you replace your variables with placeholders, and pass your variables separately into the double-underscore function. (The placeholders used are from PHP’s sprintf function.)
The basic placeholder is %s. It’s used when your original string simply contained one variable.
Untranslatable
<?php
echo "The site contains $numItems items.";
?>
Translatable
<?php
echo __('The site contains %s items.', $numItems);
?>
This will output the same way as the original, but translators will work with the single string 'The site contains %s items.' instead of many different ones for each possible number.
The %s placeholder is fine for a string with only one variable. However, with two or more, you need to account for the possibility that some translations will need to reorder the variables, because their sentence structure differs from English. With multiple variables, you must instead use numbered placeholders like %1$s, %2$s, and so on.
Untranslatable
<?php
echo "Added $file to $item.";
?>
Translatable
<?php
echo __('Added %s$1 to %s$2.', $file, $item);
?>
By using numbered placeholders, translators can reorder where the variables will appear in the string, without modifying the code to do so.
Dates and times¶
The other major thing you will often want to display differently for different for different locales are dates and times. Omeka comes pre-packaged with date formats for various locales already.
Where translations run through one function, the double-underscore function, dates and times similarly work with one function: format_date. format_date automatically selects the right format based on the site’s configured locale.
format_date takes two parameters. The first is the time you want to display. The second, which is optional, is the format you want to use. If you don’t pick a format, the default is an appropriate format for displaying a date.
Time¶
There are two possible types for the time parameter for format_date: integer and string. If you pass an integer, the time is interpreted as a Unix timestamp. If you pass a string, the time/date is interpreted according to the ISO 8601 standard (this will, among many other formats, correctly parse the output from MySQL date and time columns).
Format¶
format_date uses Zend_Date internally, so the Zend documentation is the place to go for an exhaustive list of available formats <http://framework.zend.com/manual/1.12/en/zend.date.constants.html#zend.date.constants.list>.
Format constants starting with DATE are used for displaying dates without a specific time, ones starting with DATETIME are used for date/time combinations, and ones starting with TIME are for times alone. For each, there are FULL, LONG, MEDIUM, and SHORT variants. Each variant will automatically use a format specific to the current locale, including things like the proper order for dates and the correct names of months.
The default format is Zend_Date::DATE_MEDIUM. This will display the given date/time value as a date, with medium length. In the standard US English locale, this looks like “May 31, 2013.” In a Brazilian locale, it would instead look like “31/05/2013.”
Preparing Translation Files¶
Omeka reads translations from .mo files produced with GNU gettext. There are three steps to the process. After the basic work described above is complete, you will need to
- Create a template file that includes all of the strings to translate
- Create .po files that contain the actual translations
- Compile .mo files that Omeka will use
The guide for these tasks below follows the practices used by the Omeka dev team. There are other tools and approaches that can accomplish the same tasks. The tool we use are
- ant build utility (along with a build.xml file described below)
- Transifex client (requires Python)
- podebug (requires Python)
Creating the template file¶
The simplest way to produce the template file is to follow the examples in Omeka. We begin with a template.base.pot file, which contains the basic format required to begin generating translations.
# Translation for the Simple Pages plugin for Omeka.
# Copyright (C) 2011 Roy Rosenzweig Center for History and New Media
# This file is distributed under the same license as the Omeka package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: SimplePages\n"
"Report-Msgid-Bugs-To: http://github.com/omeka/plugin-SimplePages/issues\n"
"POT-Creation-Date: 2012-01-09 21:49-0500\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
This file will be used to generate the template.pot file that is used as the template for translations. template.pot files will begin with exactly the content shown above and then include pairs of msgid s and empty msgstr. The msgid s contain the English string of text to translate. The msgstr s will eventually contain the actual translations.
The template.base.pot file is also helpful if your plugin uses strings of text that are not available for the __() function described above. For example, if your records include a flag for a permission such as allowed or required in the database, those strings need to be translated, but might not appear directly in your plugin’s display. In such cases, the strings should be added to template.base.pot below the last line:
msgid "allowed"
msgstr ""
msgid "required"
msgstr ""
If you have ant installed on your system, you can modify the following build.xml file.
<?xml version="1.0" encoding="UTF-8"?>
<project name="SimplePages" basedir=".">
<property name="lang.dir" location="languages" />
<property name="core.pot" location="../../application/languages/Omeka.pot" />
<target name="update-pot" description="Update the translation template.">
<property name="pot.file" location="${lang.dir}/template.pot"/>
<property name="pot.base" location="${lang.dir}/template.base.pot"/>
<tempfile property="pot.temp" suffix=".pot"/>
<tempfile property="pot.duplicates" suffix="-duplicates.pot" />
<copy file="${pot.base}" tofile="${pot.temp}"/>
<apply executable="xgettext" relative="true" parallel="true" verbose="true">
<arg value="--language=php"/>
<arg value="--from-code=utf-8"/>
<arg value="--keyword=__"/>
<arg value="--flag=__:1:pass-php-format"/>
<arg value="--add-comments=/"/>
<arg value="--omit-header"/>
<arg value="--join-existing"/>
<arg value="-o"/>
<arg file="${pot.temp}"/>
<fileset dir="." includes="**/*.php **/*.phtml"
excludes="tests/"/>
</apply>
<exec executable="msgcomm">
<arg value="--omit-header" />
<arg value="-o" />
<arg file="${pot.duplicates}" />
<arg file="${pot.temp}" />
<arg file="${core.pot}" />
</exec>
<exec executable="msgcomm">
<arg value="--unique" />
<arg value="-o" />
<arg file="${pot.temp}" />
<arg file="${pot.temp}" />
<arg file="${pot.duplicates}" />
</exec>
<move file="${pot.temp}" tofile="${pot.file}"/>
<delete file="${pot.duplicates}" quiet="true" />
</target>
<target name="build-mo" description="Build the MO translation files.">
<apply executable="msgfmt" dest="${lang.dir}" verbose="true">
<arg value="-o"/>
<targetfile />
<srcfile />
<fileset dir="${lang.dir}" includes="*.po"/>
<mapper type="glob" from="*.po" to="*.mo"/>
</apply>
</target>
</project>
It creates two ant commands. The first one that is important to us here is ant update-pot . It will read the template.base.pot and generate the template.pot file from the strings that are wrapped in __(). template.pot will then contain all the msgid s to be translated.
You will want to double-check that you have found all of the strings that require localization. The podebug utility can be helpful with this. It automatically generates .po files that contain pseudo-translations that will help you spot any strings that are not being translated, but should be.
Creating .po files¶
The .po files contain the localizations, named according to the ISO 639-1 standard. For example, es.po will contain translations into Spanish, and es_CO.po will contain the more precise localization to Colombian Spanish.
Omeka uses the Transifex service to produce our translations. Other tools and services also exist to help you produce your translations, but we recommend using Transifex if possible, and setting up your plugin as child project to Omeka. This will widen the pool of translators and languages for your project.
Compiling .mo files¶
Once you have created the .po files for your localizations, the final step is to compile them into binary .mo files. The second command defined by the build.xml file used above, ant build-mo will perform this task for you.
All files, template.base.pot, template.pot, and all .po and .mo files should be in a languages directory at the top level of your plugin.
User-Submitted Recipes¶
Recipe for Retaining Search or Sort Order when Paging through Items¶
Problem¶
When paging item by item using the next and previous buttons, Omeka calls the next item in the database by its ID, not by the order that you have searched or sorted prior to viewing the individual items.
Solution¶
My solution requires some changes to each theme.
Create a custom.php file to hold the new navigation function. The custom.php should be at the theme’s root (ex: /APP_DIRECTORY/themes/default/custom.php):
function custom_paging() { //Starts a conditional statement that determines a search has been run if (isset($_SERVER['QUERY_STRING'])) { // Sets the current item ID to the variable $current $current = metadata('item', 'id'); //Break the query into an array parse_str($_SERVER['QUERY_STRING'], $queryarray); //Items don't need the page level unset($queryarray['page']); $itemIds = array(); $list = array(); if (isset($queryarray['query'])) { //We only want to browse previous and next for Items $queryarray['record_types'] = array('Item'); //Get an array of the texts from the query. $textlist = get_db()->getTable('SearchText')->findBy($queryarray); //Loop through the texts ans populate the ids and records. foreach ($textlist as $value) { $itemIds[] = $value->record_id; $record = get_record_by_id($value['record_type'], $value['record_id']); $list[] = $record; } } elseif (isset($queryarray['advanced'])) { if (!array_key_exists('sort_field', $queryarray)) { $queryarray['sort_field'] = 'added'; $queryarray['sort_dir'] = 'd'; } //Get an array of the items from the query. $list = get_db()->getTable('Item')->findBy($queryarray); foreach ($list as $value) { $itemIds[] = $value->id; $list[] = $value; } } //Browsing all items in general else { if (!array_key_exists('sort_field', $queryarray)) { $queryarray['sort_field'] = 'added'; $queryarray['sort_dir'] = 'd'; } $list = get_db()->getTable('Item')->findBy($queryarray); foreach ($list as $value) { $itemIds[] = $value->id; } } //Update the query string without the page and with the sort_fields $updatedquery = http_build_query($queryarray); $updatedquery = preg_replace('/%5B[0-9]+%5D/simU', '%5B%5D', $updatedquery); // Find where we currently are in the result set $key = array_search($current, $itemIds); // If we aren't at the beginning, print a Previous link if ($key > 0) { $previousItem = $list[$key - 1]; $previousUrl = record_url($previousItem, 'show') . '?' . $updatedquery; $text = __('← Previous Item'); echo '<li id="previous-item" class="previous"><a href="' . html_escape($previousUrl) . '">' . $text . '</a></li>'; } // If we aren't at the end, print a Next link if ($key >= 0 && $key < (count($list) - 1)) { $nextItem = $list[$key + 1]; $nextUrl = record_url($nextItem, 'show') . '?' . $updatedquery; $text = __("Next Item →"); echo '<li id="next-item" class="next"><a href="' . html_escape($nextUrl) . '">' . $text . '</a></li>'; } } else { // If a search was not run, then the normal next/previous navigation is displayed. echo '<li id="previous-item" class="previous">'.link_to_previous_item_show().'</li>'; echo '<li id="next-item" class="next">'.link_to_next_item_show().'</li>'; } }
Make sure the query parameters are being passed: In the items/browse.php class, replace the line:
<h2><?php echo link_to_item(metadata('item', array('Dublin Core', 'Title')), array('class'=>'permalink')); ?></h2>
with the following to pass the query and sorting parameters:
if(isset($_SERVER['QUERY_STRING']) && !empty($_SERVER['QUERY_STRING'])) { $searchlink = record_url('item').'?' . $_SERVER['QUERY_STRING']; echo '<h2><a href="'.$searchlink.'">'. metadata('item', array('Dublin Core','Title')).'</a></h2>'; } else { echo '<h2>'.link_to_item(metadata('item', array('Dublin Core','Title')), array('class'=>'permalink')).'</h2>'; }
Have the links changed to use the new custom code from custom.php: In the items/show.php class, replace the lines:
<li id="previous-item" class="previous"><?php echo link_to_previous_item_show(); ?></li> <li id="next-item" class="next"><?php echo link_to_next_item_show(); ?></li>
with:
<?php custom_paging(); ?>
Make a copy of the application/views/scripts/search/index.php and place it under the THEME/search directory (create one if it isn’t already there).
To preserve the query and sort parameters: In search/index.php, replace the line:
<td><a href="<?php echo record_url($record, 'show'); ?>"><?php echo $searchText['title'] ? $searchText['title'] : '[Unknown]'; ?></a></td>
with:
<?php if(isset($_SERVER['QUERY_STRING']) && !empty($_SERVER['QUERY_STRING'])) { $searchlink = record_url($record, 'show').'?' . $_SERVER['QUERY_STRING']; ?> <td><a href="<?php echo $searchlink; ?>"><?php echo $searchText['title'] ? $searchText['title'] : '[Unknown]'; ?></a></td> <?php } else { ?> <td><a href="<?php echo record_url($record, 'show'); ?>"><?php echo $searchText['title'] ? $searchText['title'] : '[Unknown]'; ?></a></td> <?php } ?>
To make custom_paging work for items within an Exhibit (and sort by DC Date):
Add the following before //Browsing all items in general in Step 1.
Replace YOUR_SLUG_HERE with the slug for your Exhibit.
Replace YOUR_EXHIBIT_ID_HERE with your Exhibit ID.
Do this for each of your Exhibits.:
//Browsing exhibit YOUR_EXHIBIT_ID_HERE items elseif (strpos($_SERVER['HTTP_REFERER'],'exhibits/show/YOUR_SLUG_HERE') != false) { $exhibit_query = "search=&advanced[0][element_id]=&advanced[0][type]=&advanced[0][terms]=&range=&collection=&type=&user=&public=&featured=&exhibit=YOUR_EXHIBIT_ID_HERE&submit_search=Search&sort_field=Dublin+Core%2CDate"; parse_str($exhibit_query, $queryarray); unset($queryarray['page']); if (!array_key_exists('sort_field', $queryarray)) { $queryarray['sort_field'] = 'added'; $queryarray['sort_dir'] = 'd'; } //Get an array of the items from the query. $list = get_db()->getTable('Item')->findBy($queryarray); foreach ($list as $value) { $itemIds[] = $value->id; $list[] = $value; } }
Extending Omeka’s Standard Plugins¶
Extending Exhibit Builder 3.0¶
Exhibit Builder 3.0 allows other plugins to add their own layouts.
Placing layouts within your plugin¶
The new Exhibit Builder layouts use the same “views” system as other Omeka pages and views.
In any plugin (including the Exhibit Builder itself), layout views go in the path views/shared/exhibit_layouts.
Registering a new layout¶
Exhibit Builder provides a filter named exhibit_layouts. To add a new layout, you must hook into this filter and add some information about your new layout. You need to decide three things:
- ID: an internal name for the layout and the name of the layout folder
- Name: the admin user-facing name for the layout
- Description: the admin user-facing description of the layout
The ID is the key into the array of layouts, and the name and description are keys in an internal array. A filter implementation looks like this:
public function filterExhibitLayouts($layouts) {
$layouts['new-layout'] = array(
'name' => 'New Layout',
'description' => 'A new layout.'
);
return $layouts;
}
Basic structure of an exhibit layout¶
Each layout has its own folder under the path mentioned above. The folder name is the layouts ID, which will be used internally by the Exhibit Builder to find and store the layouts picked by the user. An ID is simply a text string, and the convention is that layout IDs be ASCII, lowercase, and hyphen-separated: sample-layout, not SampleLayout or SampleLayout.
Inside the layout folder, there are several files with predefined names that the Exhibit Builder will look for:
- form.php
- The PHP view file for the admin-side display of a form for the user to configure attachments, text, and options for a single block with this layout.
- layout.php
- The PHP view file for the public-side display of a single block with this layout.
- layout.css
- A CSS stylesheet that is automatically loaded when this layout is used on a public page.
- layout.png
- A PNG preview image for the layout. This image is displayed on the admin side when the user is selecting the layout to use. To fit with the images for the other layouts, the image should be 260 pixels wide by 140 pixels tall.
Your views can reference and use other files with names of your choosing, but the ones specified above are required and must be at the given locations.
The layout form – form.php¶
The page block that the layout is being used on is accesible in the form.php view as $block. This block object is passed to the form helpers and is used when form entries are created manually.
Attachments¶
The attachment interface is added by a simple helper:
echo $this->exhibitFormAttachments($block);
Options¶
Options are handled differently by each layout, so there is no standard form helper for them. Instead, you should use the built-in Zend form helpers to create form inputs for your layout options.
Internally, options are stored as a JSON-serialized array. Exhibit Builder automatically saves any options that are sub-keys of the options key in a block form.
Each block needs a different form name “stem,” indexed by block. So, when you’re manually creating form inputs, you need to get this stem from the block object:
$formStem = $block->getFormStem();
The pre-existing options are also available on the block object:
$options = $block->getOptions();
With those pieces of data, you can manually create a form input that will reflect the status of an option. For example, a simple text input for an option named ‘some-option’:
echo $this->formText($formStem . '[options][some-option]', @options['some-option']);
The layout view – layout.php¶
The layout view has four variables assigned to it.
- $attachments
- An array of the attachment objects for items the user has attached to this block.
- $text
- A string, containing the HTML text the user entered for this block. This text is filtered and can be output directly.
- $options
- An array of the options the user selected for this block.
- $index
- An integer, the index within the page of the current block.
Attachments¶
There are two main helpers for displaying attachments on a layout. The first is simply used for displaying a single attachment using Omeka’s file display functionality. This helper is the exhibitAttachment helper.
The exhibitAttachment helper takes 4 arguments, but only the first, $attachment, is required.
- $attachment
- The attachment object to display. This should be retrieved from the $attachments array assigned to the view.
- $fileOptions
- An array of options for displaying the attached file. See the Usage section of the file_markup documentation for examples of display options.
- $linkProps
- An array of HTML attributes that will appear on the link to the item. This link will appear if an attachment is for an item with no files, or if the $forceImage argument is true.
- $forceImage
- A boolean argument. If true, the normal file_markup-style display will not be used, and instead file_image will be. This can be useful for displaying attachments in grids or other structures where differing sizes and display methods would be unusable. This argument defaults to false.
The simplest possible example of using this helper just passes the attachment:
foreach ($attachments as $attachment):
echo $this->exhibitAttachment($attachment);
endforeach;
The second helper is the exhibitAttachmentGallery helper. The gallery helper takes an array of attachments, and displays them in a gallery format.
exhibitAttachmentGallery takes three arguments, only the first of which, $attachments, is required.
- $attachments
- An array of attachments to display a gallery of.
- $fileOptions
- An array of file display options: see the explanation for the previous helper. If no imageSize option is given, the square thumbnail size is automatically selected by this function.
- $linkProps
- An array of HTML attributes for the link around each displayed attachment. See the explanation for the previous helper.
Again, the simplest possible example simply passes the attachments. A gallery of all attachments on a block in square thumbnail format is simple:
echo $this->exhibitAttachmentGallery($attachments);
Of course, you may wish to use the attached items and files in a completely different way than the normal Omeka file display. In that case, you can directly access the Item and File objects for each attachment object, and work on them however you wish:
foreach ($attachments as $attachment):
$item = $attachment->getItem();
$file = $attachment->getFile();
endforeach;
Layout style - layout.css¶
The layout.css file is automatically loaded when the layout is used on a page. Any given page can contain many different layouts simultaneously, so you need to take some care that you don’t write styles that will interfere with other layouts.
To help with keeping styles separate, Exhibit Builder automatically wraps your layout output in a div with the class layout-<your layout id. In general, styles in layout.css should start with that class selector as the first component of every selector.
Including extra assets¶
Some scripts, styles or other content can be included directly in layout.php. But, some content may need to be placed in the <head>, or may only be included in the page once. For these scenarios, Exhibit Builder provides a hook to add content to the head for exhibit pages. Note: layout.css is automatically included, so you don’t need to write anything to include it.
The hook is called exhibit_builder_page_head. It sends two arguments, the View object $view, and $layouts, a keyed array of the layouts in use on the page being shown. You can check for your layout ID in the keys of $layouts and include whatever content your layout needs:
public function hookExhibitBuilderPageHead($args) {
if (array_key_exists('my-layout', $args['layouts'])) {
queue_js_file('my-script');
}
}
Reference¶
Omeka 2.1 API¶
Configuration¶
Global Configuration¶
Super users can configure the API using the Settings > API form.
- Enable/disable the API (default: enabled)
- Adjust the amount of results per page (default: 50)
API Keys¶
All users with log in credentials can create and rescind API keys using their Edit User form. API keys are tied to and have all the permissions of an individual user. Super users can create keys for other users. Treat keys as you would your password. Omeka provides the client’s IP address and the time it was last accessed.
Extending the API¶
Registering Your Resource¶
You can extend the API to include custom resources. Most resources are correlated to Omeka records, but you may include non-record resources as well. In your plugin class, register your resource using the api_resources filter, following this format:
<?php
protected $_filters = array('api_resources');
public function filterApiResources($apiResources)
{
// For the resource URI: /api/your_resources/[:id]
$apiResources['your_resources'] = array(
// Module associated with your resource.
'module' => 'your-plugin-name',
// Controller associated with your resource.
'controller' => 'your-resource-controller',
// Type of record associated with your resource.
'record_type' => 'YourResourceRecord',
// List of actions available for your resource.
'actions' => array(
'index', // GET request without ID
'get', // GET request with ID
'post', // POST request
'put', // PUT request (ID is required)
'delete', // DELETE request (ID is required)
),
// List of GET parameters available for your index action.
'index_params' => array('foo', 'bar'),
);
return $apiResources;
}
If not given, module and controller fall back to their defaults, “default” and “api”. Resources using the default controller MUST include a record_type. Remove actions that are not wanted or not implemented. For index actions, all GET parameters must be registered with the index_params whitelist.
Using the Default Controller¶
If your resource corresponds to an Omeka record, we highly recommend that you use the default controller. Doing so will ensure consistent behavior across resources. These records must extend Omeka_Record_AbstractRecord, implement Zend_Acl_Resource_Interface, and have a corresponding API adapter called Api_{YourRecordType} that must extend Omeka_Record_Api_AbstractRecordAdapter and be saved to your plugin’s models directory in a subdirectory named Api. This adapter is responsible for building representations of, and setting properties to, your record.
For example, an API adapter for YourRecordType saved to YourPlugin/models/Api/YourRecordType.php:
<?php
class Api_YourRecordType extends Omeka_Record_Api_AbstractRecordAdapter
{
// Get the REST representation of a record.
public function getRepresentation(Omeka_Record_AbstractRecord $record)
{
// Return a PHP array, representing the passed record.
}
// Set data to a record during a POST request.
public function setPostData(Omeka_Record_AbstractRecord $record, $data)
{
// Set properties directly to a new record.
}
// Set data to a record during a PUT request.
public function setPutData(Omeka_Record_AbstractRecord $record, $data)
{
// Set properties directly to an existing record.
}
}
Omeka_Record_Api_AbstractRecordAdapter provides a few convenience methods that make representation and record building easier:
- getResourceUrl($uri): Get the absolute URL to the passed resource. The convention is to provide an absolute URL to all resources in your representations, identified by the “url” key. This follows a hypermedia approach to API design, offering the client an easy way to consume and locate available resources. Note that this is a static method, which means you can use it in your plugin class when extending an existing resource (see “Extending Existing Resources” below).
- getDate($date): Format a date string as an ISO 8601 date, UTC timezone. The convention is to convert all dates to this format. Note that this is a static method.
- getElementTextRepresentations($record): Get representations of element texts belonging to a record. The record must initialize the ElementText mixin.
- setElementTextData($record, $data): Set element text data to a record. The record must initialize the ElementText mixin.
By implementing Zend_Acl_Resource_Interface, you record class must include the getResourceId() method. This identifies your record as relating to a unique ACL resource ID, which is used during permission checks, often automatically.
<?php
public function getResourceId()
{
// This is typically the name of the plugin, an underscore, and the pluralized record type.
return 'YourPlugin_YourRecords';
}
You may find this resource ID already defined in the plugin’s define_acl hook. If not you’ll need to add it yourself:
<?php
public function hookDefineAcl($args)
{
$acl = $args['acl'];
$acl->addResource('YourPlugin_YourRecords');
}
One last thing you may need to do is filter the select object in the record’s table class by overriding Omeka_Db_Table::getSelect(). This should protect unauthorized API users from viewing non-public records:
<?php
public function getSelect()
{
$select = parent::getSelect();
$permissions = new Omeka_Db_Select_PublicPermissions('YourPlugin_YourRecords');
// Where "your_records" is the table alias, "owner_column" is the user column to check against,
// and "public_column" is the permissions column to check against.
$permissions->apply($select, 'your_records', 'owner_column', 'public_column');
return $select;
}
Extending Existing Resources¶
You can extend the representations of existing resources by using the api_extend_* filter, where * is the resource you want to extend.
<?php
protected $_filters = array('api_extend_items');
public function filterApiExtendItems($extend, $args)
{
$item = $args['record'];
// For one resource:
$resourceId = $this->_db->getTable('YourResource')->findByItemId($item->id);
$extend['your_resources'] = array(
'id' => 1,
'url' => Omeka_Record_Api_AbstractRecordAdapter::getResourceUrl("/your_resources/{$resourceId->id}"),
'resource' => 'your_resources',
);
// Or, for multiple resources:
$extend['your_resources'] = array(
'count' => 10,
'url' => Omeka_Record_Api_AbstractRecordAdapter::getResourceUrl("/your_resources?item={$item->id}"),
'resource' => 'your_resources',
);
return $extend;
}
Note that the API enforces a pattern when extending a resource:
- id and url for a one-to-one relationship
- count and url for a one-to-many relationship
- resource is recommeded but not required
All other keys pass through as custom data that may be used for the client’s convenience.
APIs for beginners¶
What’s a REST API?¶
Put simply, an API is a formal line of communication between two programs. A REST API is one that utilizes inherent features of the Web to enable communication between a client and a server. It’s important to note that APIs aren’t designed to be exposed to you, the end user, except through intermediary programs. Remember this when you’re experimenting directly with the API; otherwise you may get frustrated.
Omeka’s REST API¶
Omeka’s REST API provides an endpoint against which you can query, create, update, and delete Omeka resources. Your Omeka endpoint is the URL to your Omeka website followed by /api, like this:
http://yourdomain.com/api
You can see which resources are available by appending /resources?pretty_print to your endpoint, like this:
http://yourdomain.com/api/resources?pretty_print
Here you are getting the /resources resource as a JSON object containing all the available resources and other information about them. (?pretty_print is helpful to get back nicely formatted JSON, but is not necessary.)
HTTP Request Methods¶
In the above response you’ll notice that all resources have at least one action. These actions, while not important to a beginner, correspond to HTTP request methods. These methods are central to REST, and you should know what they do:
- GET gets one or more representations of a resource;
- POST creates a new resource and returns the representation of the newly created resource;
- PUT modifies an existing resource and returns the representation of the newly modified resource;
- DELETE deletes an existing resource.
Until you start building your own API client, you won’t need to make POST, PUT, or DELETE requests, but GET is well suited for beginners because you can run them directly from your Web browser, as you probably did above with /resources.
Omeka’s Resources and Representations¶
A representation, in this case, is a JSON object that represents an Omeka resource. In other words, you are not getting a resource itself, but rather a representation of it. This is very much like viewing an item on a Omeka website: the item show page is not the item itself, but a representation of the item.
Every Omeka website comes with the following resources, most of which should already be familiar to you as an Omeka user:
- /collections
- /items
- /files
- /item_types
- /elements
- /element_sets
- /tags
One of the powerful features of the Omeka API is that plugins can add more resources if they wish. If they do, you’ll see them on the /resources resource.
Using the Omeka API¶
Let’s take a look at the /items resource by making a GET request to the following URL using your Web browser:
http://yourdomain.com/api/items
Assuming there are already items added to Omeka, you’ll see a JSON array of item representations, each with an “id” (the item ID), a “url” (the direct URL to that item), and other metadata about the item. Copy that URL to your Web browser and make another GET request (you’ll first need to remove backslashes from the URL, which were a necessary part of JSON formatting):
http://yourdomain.com/api/items/:id
Where :id is the item ID. You’ll see the same JSON representation of the item, but by itself. This URL is the item’s canonical URL, that is, it is an unambiguous and permanent link that represents the item itself.
So far you’ve only been using the GET method to get representations of resources. To experiment with POST, PUT, and DELETE you’ll need to use a program that is capable of sending those requests. Most modern browsers have plugins that do this in a user-friendly way:
If you’re comfortable adding, modifying, and deleting Omeka resources, read the API documentation and start making requests!
Requests¶
Endpoint URL¶
yourdomain.com/api/
Pagination¶
For index requests using the defualt controller, pagination is set in the response’s Link header:
Link: <http://yourdomain.com/api/items?page=1&per_page=50>; rel="first",
<http://localhost/omeka/api/items?page=10&per_page=50>; rel="last",
<http://localhost/omeka/api/items?page=1&per_page=50>; rel="previous",
<http://localhost/omeka/api/items?page=3&per_page=50>; rel="next"``
Global GET Parameters¶
- key: string, API key authentication
- callback: string, JSONP function name
- pretty_print: on/off, Pretty print the JSON output
Generic Requests¶
POST and PUT requests are designed to take a JSON payload that is essentially identical to a GET response of the same resource. This makes it possible to, for example, GET an item, modify the representation directly and POST or PUT it back to Omeka.
Some servers do not accept PUT or DELETE requests. For compatibility we’ve added support for the X-HTTP-Method-Override header, which you can use to declare an unsupported HTTP method.
X-HTTP-Method-Override: DELETE
GET a resource¶
Return data about the specified resource (most often a specific record):
GET /:resources/:id HTTP/1.1
GET one or more resources¶
Return data about resources (most often records):
GET /:resources HTTP/1.1
- page: integer
A response of a resource using the default controller will include a non-standard Omeka-Total-Results header set to the total count of request results.
Errors¶
Router Errors¶
All requests may return the following errors:
- 400 Bad Request
- Invalid GET request parameter: “[parameter]”
- 403 Forbidden
- Invalid key.
- API is disabled
- 404 Not Found
- The “[resource]” resource is unavailable.
- 405 Method Not Allowed
- This resource does not implement the “[action]” action.
- POST requests must not include an ID.
- PUT and DELETE requests must include an ID.
- 500 Internal Server Error
- Resources using the default controller must register a record type.
Default Controller Errors¶
Requests to the default controller may return the following errors:
- 400 Bad Request
- Invalid request. Request body must be a JSON object.
- Error when saving record.
- 403 Forbidden
- Permission denied.
- 404 Not Found
- Invalid record. Record not found.
- Invalid record. Record type “[record_type]” not found.
- Invalid record adapter. Record adapter “[record_adapter_class]” not found.
- 500 Internal Server Error
- Invalid record adapter. Record adapter “[record_adapter_class]” is invalid
- Invalid record. Record “[record_type]” must define an ACL resource.
Record Errors¶
Requests that invoke the abstract record adapter may return the following errors:
- 500 Internal Server Error
- The “[record_type]” API record adapter does not implement setPostData
- The “[record_type]” API record adapter does not implement setPutData
API Requests¶
Collections¶
GET collection¶
Return data about the specified collection.
GET /collections/:id HTTP/1.1
{
"id": 1,
"url": "http://yourdomain.com/api/collections/1",
"public": true,
"featured": false,
"added": "2013-03-27T08:17:37+00:00",
"modified": "2013-04-21T15:05:07+00:00",
"owner": {
"id": 1,
"url": "/users/1",
"resource": "users"
},
"items": {
"count": 100,
"url": "http://yourdomain.com/api/items?collection=1",
"resource": "items"
},
"element_texts": [
{
"html": false,
"text": "Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
"element_set": {
"id": 1,
"url": "http://yourdomain.com/api/element_sets/1",
"resource": "element_sets",
"name": "Dublin Core"
},
"element": {
"id": 1,
"url": "http://yourdomain.com/api/elements/1",
"resource": "element",
"name": "Title"
}
}
]
}
GET collections¶
Return data about collections.
GET /collections HTTP/1.1
- public: boolean
- featured: boolean
- added_since: string (ISO 8601)
- modified_since: string (ISO 8601)
- owner (user): integer
An array of JSON collection representations (see above).
POST collection¶
Create a new collection.
POST /collections HTTP/1.1
{
"public": true,
"featured": false,
"element_texts": [
{
"html": false,
"text": "Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
"element": {"id": 1}
}
]
}
HTTP/1.1 201 Created
Location: http://yourdomain.com/api/collections/:id
An JSON representation of the newly created collection (see above).
PUT collection¶
Edit an existing collection.
PUT /collections/:id HTTP/1.1
{
"public": true,
"featured": false,
"element_texts": [
{
"html": false,
"text": "Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
"element": {"id": 1}
}
]
}
An JSON representation of the newly edited collection (see above).
Element Sets¶
GET element set¶
Return data about the specified element set:
GET /element_sets/:id HTTP/1.1
{
"id": 1,
"url": "http://yourdomain.com/api/element_sets/1",
"record_type": null,
"name": "Dublin Core",
"description": "The Dublin Core metadata element set is common to all Omeka records.",
"elements": {
"count": 100,
"url": "http://yourdomain.com/api/elements?element_set=1",
"resource": "elements"
}
}
GET element sets¶
Return data about element sets:
An array of JSON element set representations (see above).
POST element set¶
Create a new element set.
POST /element_sets HTTP/1.1
{
"name": "Dublin Core",
"description": "The Dublin Core metadata element set is common to all Omeka records."
}
HTTP/1.1 201 Created
Location: http://yourdomain.com/api/element_sets/:id
An JSON representation of the newly created element set (see above).
Elements¶
GET element¶
Return data about the specified element:
GET /elements/:id HTTP/1.1
{
"id": 1,
"url": "http://yourdomain.com/api/elements/1",
"name": "Text",
"order": 1,
"description": "Any textual data included in the document",
"comment": null,
"element_set": {
"id": 1,
"url": "http://yourdomain.com/api/element_sets/1",
"resource": "element_sets"
},
}
GET elements¶
Return data about elements:
An array of JSON element representations (see above).
POST element¶
Create a new element.
POST /elements HTTP/1.1
{
"order": 1,
"name": "Foo",
"description": "Foo description.",
"comment": "Foo comment.",
"element_set": {"id": 1}
}
HTTP/1.1 201 Created
Location: http://yourdomain.com/api/elements/:id
An JSON representation of the newly created element (see above).
PUT element¶
Edit an existing element.
PUT /elements/:id HTTP/1.1
{
"order": 1,
"name": "Foo",
"description": "Foo description.",
"comment": "Foo comment.",
"element_set": {"id": 1}
}
An JSON representation of the newly edited element (see above).
DELETE element¶
Delete an element. Only elements belonging to the “Item Type Metadata” element set may be deleted.
DELETE /elements/:id HTTP/1.1
HTTP/1.1 204 No Content
Errors¶
In addition to the general errors, requests to the elements resource my return the following errors:
- 400 Bad Request
- Invalid record. Only elements belonging to the “Item Type Metadata” element set may be deleted.
Files¶
GET file¶
Return data about the specified file.
GET /files/:id HTTP/1.1
{
"id": 1,
"url": "/files/1",
"file_urls": {
"original": "http://yourdomain.com/files/original/2b42672de6e47a67698a52e1415bd2c0.pdf",
"fullsize": "http://yourdomain.com/files/fullsize/2b42672de6e47a67698a52e1415bd2c0.jpg",
"thumbnail": "http://yourdomain.com/files/thumbnails/2b42672de6e47a67698a52e1415bd2c0.jpg",
"square_thumbnail": "http://yourdomain.com/files/square_thumbnails/2b42672de6e47a67698a52e1415bd2c0.jpg"
},
"item": {
"id": 1,
"url": "http://yourdomain.com/api/items/1",
"resource": "items"
},
"order": null,
"size": 1953540,
"has_derivative_images": true,
"authentication": "f6089bca39470e8c19410242061b1f78",
"mime_type": "audio/mpeg",
"type_os": "MPEG ADTS, v1, 128 kbps, 44.1 kHz, JntStereo",
"filename": "54a21c1552feef92069d504fbaf145a8.mp3",
"original_filename": "1ATwUDzA3SCU.128.mp3",
"added": "2013-03-27T08:17:37+00:00",
"modified": "2013-04-21T15:05:07+00:00",
"stored": true,
"metadata": {},
"element_texts": [
{
"html": false,
"text": "Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
"element_set": {
"id": 1,
"url": "http://yourdomain.com/api/element_sets/1",
"name": "Dublin Core",
"resource": "element_sets"
},
"element": {
"id": 1,
"url": "http://yourdomain.com/api/elements/1",
"name": "Title",
"resource": "elements"
}
}
]
}
The metadata object contains data extracted by the getId3 library, and so its structure and content will vary widely based on the file type, what data the library is able to extract, and what data is embedded in the file.
Possible properties within metadata (if it is not empty) are: mime_type, video, audio, comments, comments_html, iptc, jpg. mime_type within metadata is a string, and can differ from the mime_type property in the top level of the response. All other properties will be objects.
GET files¶
Return data about files.
GET /files HTTP/1.1
- item: integer
- order: integer
- size_greater_than: integer
- has_derivative_image: boolean
- mime_type: string
- added_since: string (ISO 8601)
- modified_since: string (ISO 8601)
An array of JSON file representations (see above).
POST files¶
Create a new file. Only one file may be uploaded at a time.
POST /files HTTP/1.1
Requests must use the `multipart/form-data <http://www.w3.org/TR/html401/interact/forms.html#h-17.13.4.2>`__ content type. The content disposition name for the file must be file. The content disposition name for the JSON data must be data. We highly recommend that you use a HTTP client that is capable of encoding form-data requests for you, but the typical request should look something like this:
POST /api/files HTTP/1.1
Content-Type: multipart/form-data; boundary=E19zNvXGzXaLvS5C
----E19zNvXGzXaLvS5C
Content-Disposition: form-data; name="data"
{
"order": 2,
"item": {
"id": 1,
}
"element_texts": [
{
"html": false,
"text": "Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
"element": {"id": 1}
}
]
}
----E19zNvXGzXaLvS5C
Content-Disposition: form-data; name="file"; filename="example.pdf"
Content-Type: application/pdf
...contents of example.pdf...
----E19zNvXGzXaLvS5C
HTTP/1.1 201 Created
Location: http://yourdomain.com/api/files/:id
An JSON representation of the newly created file (see above).
PUT file¶
Edit an existing file.
PUT /files/:id HTTP/1.1
{
"order": 2,
"element_texts": [
{
"html": false,
"text": "Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
"element": {"id": 1}
}
]
}
An JSON representation of the newly edited file (see above).
Errors¶
In addition to the general errors, requests to the files resource may return the following errors:
- 400 Bad Request
- Invalid request. Request body must be a JSON object.
- Invalid request. Exactly one file must be uploaded per request.
- Invalid request. Missing JSON data.
- Invalid item. File must belong to an existing item.
- 500 Internal Server Error
- Invalid request. The default job dispatcher must be synchronous.
Item Types¶
GET item type¶
Return data about the specified item type.
GET /item_types/:id HTTP/1.1
{
"id": 1,
"url": "/item_types/1",
"name": "Text",
"description": "A resource consisting primarily of words for reading.",
"elements": [
{
"id": 1,
"url": "http://yourdomain.com/api/elements/1",
"resource": "elements"
},
{
"id": 2,
"url": "http://yourdomain.com/api/elements/2",
"resource": "elements"
},
{
"id": 3,
"url": "http://yourdomain.com/api/elements/3",
"resource": "elements"
}
],
"items": {
"count": 100,
"url": "http://yourdomain.com/api/items?item_type=1",
"resource": "items"
}
}
GET item types¶
Return data about item types.
An array of JSON item type representations (see above).
POST item type¶
Create a new item type.
POST /item_types HTTP/1.1
{
"name": "Text",
"description": "Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
"elements": [
{"id": 1},
{"id": 2},
{"id": 3}
]
}
HTTP/1.1 201 Created
Location: http://yourdomain.com/api/item_types/:id
An JSON representation of the newly created item type (see above).
Items¶
GET item¶
Return data about the specified item.
GET /items/:id HTTP/1.1
{
"id": 1,
"url": "http://yourdomain.com/api/items/1",
"item_type": {
"id": 1,
"url": "http://yourdomain.com/api/item_types/1",
"name": "Text",
"resource": "item_types"
},
"collection": {
"id": 1,
"url": "http://yourdomain.com/api/collections/1",
"resource": "collections"
},
"owner": {
"id": 1,
"url": "http://yourdomain.com/api/users/1",
"resource": "users"
},
"public": true,
"featured": false,
"added": "2013-03-27T08:17:37+00:00",
"modified": "2013-04-21T15:05:07+00:00",
"files": {
"count": 100,
"url": "http://yourdomain.com/api/files?item=1",
"resource": "files"
},
"tags": [
{
"id": 1,
"url": "http://yourdomain.com/api/tags/1",
"name": "foo",
"resource": "tags"
}
],
"element_texts": [
{
"html": false,
"text": "Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
"element_set": {
"id": 1,
"url": "http://yourdomain.com/api/element_sets/1",
"name": "Dublin Core",
"resource": "element_sets"
},
"element": {
"id": 1,
"url": "http://yourdomain.com/api/elements/1",
"name": "Title",
"resource": "elements"
}
}
]
}
GET items¶
Return data about items.
GET /items HTTP/1.1
- collection: integer
- item_type: integer
- featured: boolean
- public: boolean
- added_since: string (ISO 8601)
- modified_since: string (ISO 8601)
- owner (user): integer
An array of JSON item representations (see above).
POST item¶
Create a new item.
POST /items HTTP/1.1
{
"item_type": {"id": 1},
"collection": {"id": 1},
"public": true,
"featured": false,
"tags": [
{"name": "foo"},
{"name": "bar"}
],
"element_texts": [
{
"html": false,
"text": "Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
"element": {"id": 1}
}
]
}
HTTP/1.1 201 Created
Location: http://yourdomain.com/api/items/:id
An JSON representation of the newly created item (see above).
PUT item¶
Edit an existing item.
PUT /items/:id HTTP/1.1
{
"item_type": {"id": 1},
"collection": {"id": 1},
"public": true,
"featured": false,
"tags": [
{"name": "foo"},
{"name": "bar"}
],
"element_texts": [
{
"html": false,
"text": "Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
"element": {"id": 1}
}
]
}
An JSON representation of the newly edited item (see above).
Resources¶
GET resource¶
Individual resources cannot be shown.
GET resources¶
Return available API resources and information about them.
GET /resources HTTP/1.1
{
"resources": {
"controller": "resources",
"actions": ["get"]
},
"items": {
"record_type": "Item",
"actions": ["index", "get", "post", "put", "delete"],
"index_params": ["collection", "item_type", "featured", "public", "added_since", "modified_since", "owner"]
}
}
POST resource¶
Resources cannot be created. They must be registered via the api_resources filter.
Site¶
GET site¶
Return information about the Omeka installation.
GET /site HTTP/1.1
{
"omeka_url":"http://yourdomain.com",
"omeka_version":"2.1",
"title":"My Omeka Site",
"description":"Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
"author":"Center for History and New Media",
"copyright":"Creative Commons Attribution-ShareAlike 3.0 License"
}
Tags¶
GET tag¶
Return data about the specified tag.
GET /tag HTTP/1.1
{
"id": 1,
"url": "http://yourdomain.com/api/tags/1",
"name": "foo"
}
GET tags¶
Return data about tags.
GET /tags HTTP/1.1
An array of JSON tag representations (see above).
POST tag¶
New tags must be created via the owner record.
Users¶
GET user¶
Return data about the specified user.
GET /users/:id HTTP/1.1
{
"id": 1,
"url": "/users/1",
"username": "janedoe",
"name": "Jane Doe",
"email": "janedoe@example.com",
"active": true,
"role": "super"
}
GET users¶
Users cannot be browsed.
POST user¶
Users cannot be created.
Global (Theming) Functions¶
All Functions¶
__ (double underscore)¶
Summary¶
- __(string $string)¶
Translate a string.
Parameters: - $string (string) – The string to be translated.
Returns: string The translated string.
Usage¶
Examples¶
echo __("String to translate");
See Also¶
_log¶
Summary¶
- _log(mixed $msg, integer $priority = 6)¶
Log a message.
Enabled via config.ini: log.errors.
Parameters: - $msg (mixed) – The log message.
- $priority (integer) – See Zend_Log for a list of available priorities.
Usage¶
Examples¶
See Also¶
absolute_url¶
Summary¶
- absolute_url(mixed $options = Array, string $route, mixed $queryParams = Array, bool $reset =, bool $encode = 1)¶
Return an absolute URL.
This is necessary because Zend_View_Helper_Url returns relative URLs, thoughabsolute URLs are required in some contexts. Instantiates view helpersdirectly because a view may not be registered.
Parameters: - $options (mixed) –
- If a string is passed it is treated as an Omeka-relative link. So, passing 'items' would create a link to the items page.
- (Advanced) If an array is passed (or no argument given), it is treated as options to be passed to Omeka's routing system.
- $route (string) – The route to use if an array is passed in the first argument.
- $queryParams (mixed) – A set of query string parameters to append to the URL
- $reset (bool) – Whether Omeka should discard the current route when generating the URL.
- $encode (bool) – Whether the URL should be URL-encoded
Returns: string HTML
- $options (mixed) –
Usage¶
Examples¶
See Also¶
add_file_display_callback¶
Summary¶
- add_file_display_callback(array|string $fileIdentifiers, callback $callback, array $options = Array)¶
Declare a callback function that will be used to display files with a given MIME type and/or file extension.
Parameters: - $fileIdentifiers (array|string) – Set of MIME types and/or file extensions to which the provided callback will respond.
- $callback (callback) – Any valid callback.
- $options (array) –
Usage¶
Examples¶
add_filter¶
Summary¶
- add_filter(string|array $name, callback $callback, integer $priority = 10)¶
Declare a filter implementation.
Parameters: - $name (string|array) – The filter name.
- $callback (callback) – The function to call.
- $priority (integer) – Defaults to 10.
Usage¶
Examples¶
See Also¶
add_plugin_hook¶
Summary¶
- add_plugin_hook(string $hook, mixed $callback)¶
Declare a plugin hook implementation within a plugin.
Parameters: - $hook (string) – Name of hook being implemented.
- $callback (mixed) – Any valid PHP callback.
Usage¶
Examples¶
<?php add_plugin_hook('install', 'exhibit_builder_install'); ?>
See Also¶
add_translation_source¶
Summary¶
- add_translation_source(string $dir)¶
Add an translation source directory.
The directory’s contents should be .mo files following the naming scheme ofOmeka’s application/languages directory. If a .mo for the current localeexists, the translations will be loaded.
Parameters: - $dir (string) – Directory from which to load translations.
Usage¶
Examples¶
<?php
function exhibit_builder_initialize()
{
add_translation_source(dirname(__FILE__) . '/languages');
}
?>
See Also¶
all_element_texts¶
Summary¶
- all_element_texts(Omeka_Record_AbstractRecord|string $record, array $options = Array)¶
Return the set of all element text metadata for a record.
Parameters: - $record (Omeka_Record_AbstractRecord|string) – The record to get the element text metadata for.
- $options (array) – Options for getting the metadata.
Returns: string|array
Usage¶
Examples¶
See Also¶
apply_filters¶
Summary¶
- apply_filters(string|array $name, mixed $value, array $args = Array)¶
Apply a set of plugin filters to a given value.
Parameters: - $name (string|array) – The filter name.
- $value (mixed) – The value to filter.
- $args (array) – Additional arguments to pass to filter implementations.
Returns: mixed Result of applying filters to $value.
Usage¶
Examples¶
See Also¶
auto_discovery_link_tags¶
Summary¶
This function outputs a <link> tag for the RSS feed so the browser can auto-discover the feed.
Return a link tag for the RSS feed so the browser can auto-discover the field.
Returns: string HTML
Usage¶
Examples¶
See Also¶
body_tag¶
Summary¶
- body_tag(array $attributes = Array)¶
Returns a <body> tag with attributes.
Attributes can be filtered using the ‘body_tag_attributes’ filter.
Parameters: - $attributes (array) –
Returns: string An HTML <body> tag with attributes and their values.
Usage¶
Examples¶
See Also¶
browse_sort_links¶
Summary¶
- browse_sort_links(array $links, array $wrapperTags = Array)¶
Return the list of links for sorting displayed records.
Parameters: - $links (array) – The links to sort the headings. Should correspond to the metadata displayed.
- $wrapperTags (array) – The tags and attributes to use for the browse headings * ‘list_tag’ The HTML tag to use for the containing list * ‘link_tag’ The HTML tag to use for each list item (the browse headings) * ‘list_attr’ Attributes to apply to the containing list tag * ‘link_attr’ Attributes to apply to the list item tag
Returns: string
Usage¶
Generates HTML elements for sorting based on the metadata given.
When the records are presented as a table, as in most admin browse views, $wrapperTags should be:
array('link_tag' => 'th scope="col"', 'list_tag' => '')
Otherwise, you will want to add text and/or styling to make clear that the list presented is for sorting the displayed records.
Examples¶
See Also¶
clear_filters¶
Summary¶
- clear_filters($filterName)¶
Clear all implementations for a filter (or all filters).
Parameters: - $filterName (unknown) –
Usage¶
Examples¶
See Also¶
common¶
Summary¶
The common function loads a script, optionally passing in some variables. Themes and plugins can use this function to separate distinct blocks of output into different scripts, even if all the output will appear on one page.
By default, common tries to load the script from the “common” directory for the current theme, but any view directory can be specified.
- common(string $file, array $vars = Array, string $dir = common)
Return HTML from a file in the common/ directory, passing variables into that script.
Parameters: - $file (string) – Filename
- $vars (array) – A keyed array of variables to be extracted into the script
- $dir (string) – Defaults to ‘common’
Returns: string
Usage¶
Examples¶
See Also¶
css_src¶
Summary¶
css_src() is a helper function used when referencing a css file within a theme, and commonly included within a theme’s header.php file. It returns the path to a css file located in the css folder of that theme, usually located in themes/YourTheme/css.
Note
The queue_css_file helper is preferred to this one for most use cases.
- css_src(string $file, string $dir = css)¶
Return the web path to a css file.
Parameters: - $file (string) – Should not include the .css extension
- $dir (string) – Defaults to ‘css’
Returns: string
Usage¶
Examples¶
See Also¶
current_url¶
Summary¶
- current_url(array $params = Array)¶
Return the current URL with query parameters appended.
Instantiates view helpers directly because a view may not be registered.
Parameters: - $params (array) –
Returns: string
Usage¶
Examples¶
See Also¶
current_user¶
Summary¶
- current_user()¶
Return the currently logged in User record.
Returns: User|null Null if no user is logged in.
Usage¶
Examples¶
See Also¶
debug¶
Summary¶
- debug(string $msg)
Log a message with ‘DEBUG’ priority.
Parameters: - $msg (string) –
Usage¶
Examples¶
See Also¶
delete_option¶
Summary¶
- delete_option(string $name)¶
Delete an option from the options table.
Parameters: - $name (string) – The option name.
Usage¶
Examples¶
See Also¶
element_exists¶
Summary¶
- element_exists(string $elementSetName, string $elementName)¶
Determine whether an element set contains a specific element.
Parameters: - $elementSetName (string) – The element set name.
- $elementName (string) – The element name.
Returns: bool
Usage¶
Examples¶
See Also¶
element_form¶
Summary¶
- element_form(Element|array $element, Omeka_Record_AbstractRecord $record, array $options = Array)¶
Return the proper HTML for a form input for a given Element record.
Assume that the given element has access to all of its values (for example, all values of a Title element for a given Item).
This will output as many form inputs as there are values for a given element.In addition to that, it will give each set of inputs a label and a span withclass=”tooltip” containing the description for the element. This span caneither be displayed, hidden with CSS or converted into a tooltip withjavascript.
All sets of form inputs for elements will be wrapped in a div withclass=”field”.
Parameters: - $element (Element|array) –
- $record (Omeka_Record_AbstractRecord) –
- $options (array) –
Returns: string HTML
Usage¶
Examples¶
See Also¶
element_set_form¶
Summary¶
- element_set_form(Omeka_Record_AbstractRecord $record, string $elementSetName)¶
Return a element set form for a record.
Parameters: - $record (Omeka_Record_AbstractRecord) –
- $elementSetName (string) – The name of the element set or ‘Item Type Metadata’ for an item’s item type data.
Returns: string
Usage¶
Examples¶
See Also¶
file_id3_metadata¶
Summary¶
- file_id3_metadata(array $options = Array, File|null $file)¶
Return HTML for a file’s ID3 metadata.
Parameters: - $options (array) –
- $file (File|null) –
Returns: string|array
Usage¶
Examples¶
See Also¶
file_image¶
Summary¶
- file_image(string $imageType, array $props = Array, $file)¶
Return a customized file image tag.
Parameters: - $imageType (string) –
- $props (array) –
- $file (unknown) –
Usage¶
Examples¶
See Also¶
file_markup¶
Summary¶
- file_markup(File $files, array $props = Array, array $wrapperAttributes = Array)¶
Return HTML for a set of files.
Parameters: - $files (File) – A file record or an array of File records to display.
- $props (array) – Properties to customize display for different file types.
- $wrapperAttributes (array) – Attributes HTML attributes for the div that wraps each displayed file. If empty or null, this will not wrap the displayed file in a div.
Returns: string HTML
Usage¶
The second argument, $props, is an array of options to customize the display of files. Which options are valid depend on the particular file type and on whether a plugin has added a new method for displaying that file, but there are some fairly standard available options.
Options for many possible file types can be specified all together. Each file will only use the options that are valid for its type, and ignore the others.
- imageSize
Available for images. Default: square_thumbnail
A string naming the size of image to use. The possible sizes are thumbnail, square_thumbnail, and fullsize.
- linkToFile
Available for images and unknown-type files. Default: true
Whether the display should be wrapped in a direct link directly the file. true makes a link to the original file, false makes no link, and a string links to the specified image size (thumbnail, square_thumbnail, or fullsize).
- linkToMetadata
Available for images and unknown-type files. Default: false
If true, wrap the file in a link to the file’s “show” metadata page. This option overrides linkToFile when true.
- imgAttributes
Available for images. Default: none
An array of attributes to set on the HTML <img> tag. Keys of the array are attribute names, and values of the array are attribute values.
- linkText
Available for unknown-type files. Default: null
The text to display for the file (inside the link if one of the linking options is enabled). If null or omitted, the file’s Dublin Core Title (if available) or original filename are used as the text.
- width, height
Available for most audio and video types. Defaults vary.
The pixel height and width of the audio or video player.
Examples¶
file_markup can be passed just a file or array of files alone to produce the default display:
// Display one specific File
echo file_markup($file);
// Display all the given Files (here, the files for an Item)
echo file_markup($item->Files);
One of the simplest uses of file_markup‘s display options is to display a fullsize image instead of a small square thumbnail:
echo file_markup($file, array('imageSize' => 'fullsize'));
files_for_item¶
Summary¶
- files_for_item(array $options = Array, array $wrapperAttributes = Array, Item|null $item)¶
Return HTML for all files assigned to an item.
Parameters: - $options (array) –
- $wrapperAttributes (array) –
- $item (Item|null) – Check for this specific item record (current item if null).
Returns: string HTML
Usage¶
Examples¶
See Also¶
fire_plugin_hook¶
Summary¶
- fire_plugin_hook($name, $args = Array)¶
Declare the point of execution for a specific plugin hook.
All plugin implementations of a given hook will be executed when this iscalled. The first argument corresponds to the string name of the hook. Thesecond is an associative array containing arguments that will be passed tothe plugin hook implementations.
// Calls the hook 'after_save_item' with the arguments '$item' and '$arg2' fire_plugin_hook('after_save_item', array('item' => $item, 'foo' => $arg2));
Parameters: - $name (unknown) –
- $args (unknown) –
Usage¶
Examples¶
See Also¶
flash¶
Summary¶
- flash()
Return a flashed message from the controller.
Returns: string
Usage¶
Examples¶
See Also¶
foot¶
Summary¶
This function includes the template footer.php at the end of a page.
- foot(array $vars = Array, string $file = footer)
Return the view’s footer HTML.
Parameters: - $vars (array) – Keyed array of variables
- $file (string) – Filename of footer script (defaults to ‘footer’)
Returns: string
Usage¶
Examples¶
See Also¶
format_date¶
Summary¶
- format_date(mixed $date, string $format = FFF)¶
Format a date for output according to the current locale.
Parameters: - $date (mixed) – Date to format. If an integer, the date is intepreted as a Unix timestamp. If a string, the date is interpreted as an ISO 8601 date.
- $format (string) – Format to apply. See Zend_Date for possible formats. The default format is the current locale’s “medium” format.
Returns: string
Usage¶
Examples¶
See Also¶
get_collection_for_item¶
Summary¶
- get_collection_for_item(Item|null $item)¶
Get the Collection object for the current item.
Parameters: - $item (Item|null) – Check for this specific item record (current item if null).
Returns: Collection
Usage¶
Examples¶
See Also¶
get_current_action_contexts¶
OutputFormat-related functions
Summary¶
- get_current_action_contexts()¶
Get all output formats available in the current action.
Returns: array A sorted list of contexts.
Usage¶
Examples¶
See Also¶
get_current_record¶
Summary¶
- get_current_record(string $recordVar, bool $throwException = 1)¶
Get the current record from the view.
Parameters: - $recordVar (string) –
- $throwException (bool) –
Returns: Omeka_Record_AbstractRecord|false
Usage¶
Examples¶
See Also¶
get_custom_search_record_types¶
Summary¶
- get_custom_search_record_types()¶
Get all record types that have been customized to be searchable.
Returns: array
Usage¶
Examples¶
See Also¶
get_html_lang¶
Summary¶
- get_html_lang()¶
Get the correct HTML “lang” attribute for the current locale.
Returns: string
Usage¶
Examples¶
See Also¶
get_loop_records¶
Summary¶
- get_loop_records(string $recordsVar, $throwException = 1)¶
Get records from the view for iteration.
Note that this function will return an empty array if it is set to therecords variable. Use has_loop_records() to check if records exist.
Parameters: - $recordsVar (string) –
- $throwException (unknown) –
Returns: array|bool
Usage¶
Examples¶
See Also¶
get_next_item¶
Summary¶
- get_next_item(Item|null $item)¶
Get the next item in the database.
Parameters: - $item (Item|null) – Check for this specific item record (current item if null).
Returns: Item|null
Usage¶
Examples¶
See Also¶
get_option¶
Summary¶
- get_option($name)¶
Get an option from the options table.
If the returned value represents an object or array, it must be unserializedby the caller before use. For example:
$object = unserialize(get_option('plugin_object'));
Parameters: - $name (unknown) –
Usage¶
Examples¶
See Also¶
get_plugin_broker¶
Summary¶
- get_plugin_broker()¶
Get the broker object for Omeka plugins.
Returns: Omeka_Plugin_Broker|null
Usage¶
Examples¶
See Also¶
get_plugin_hook_output¶
Summary¶
- get_plugin_hook_output(string $name, array $args = Array)¶
Get the output of fire_plugin_hook() as a string.
Parameters: - $name (string) – The hook name.
- $args (array) – Arguments to be passed to the hook implementations.
Returns: string
Usage¶
Examples¶
See Also¶
get_plugin_ini¶
Summary¶
- get_plugin_ini(string $pluginDirName, string $iniKeyName)¶
Get specified descriptive info for a plugin from its ini file.
Parameters: - $pluginDirName (string) – The directory name of the plugin.
- $iniKeyName (string) – The name of the key in the ini file.
Returns: string|null The value of the specified plugin key. If the key does not exist, it returns null.
Usage¶
Examples¶
See Also¶
get_previous_item¶
Summary¶
- get_previous_item(Item|null $item)¶
Get the previous item in the database.
Parameters: - $item (Item|null) – Check for this specific item record (current item if null).
Returns: Item|null
Usage¶
Examples¶
See Also¶
get_random_featured_items¶
Summary¶
- get_random_featured_items(integer $num = 5, boolean|null $hasImage)¶
Get random featured items.
Parameters: - $num (integer) – The maximum number of recent items to return
- $hasImage (boolean|null) –
Returns: array|Item
Usage¶
Examples¶
See Also¶
get_recent_collections¶
Summary¶
- get_recent_collections(integer $num = 10)¶
Get the most recently added collections.
Parameters: - $num (integer) – The maximum number of recent collections to return
Returns: array
Usage¶
Examples¶
See Also¶
get_recent_files¶
Summary¶
- get_recent_files(integer $num = 10)¶
Get the most recent files.
Parameters: - $num (integer) – The maximum number of recent files to return
Returns: array
Usage¶
Examples¶
See Also¶
get_recent_items¶
Summary¶
- get_recent_items(integer $num = 10)¶
Get the most recently added items.
Parameters: - $num (integer) – The maximum number of recent items to return
Returns: array
Usage¶
Examples¶
See Also¶
get_recent_tags¶
Summary¶
Get the most recent tags.
Parameters: - $limit (integer) – The maximum number of recent tags to return
Returns: array
Usage¶
Examples¶
See Also¶
get_record_by_id¶
Summary¶
- get_record_by_id(string $recordVar, int $recordId)¶
Get a record by its ID.
Parameters: - $recordVar (string) –
- $recordId (int) –
Returns: Omeka_Record_AbstractRecord|null
Usage¶
Examples¶
See Also¶
get_records¶
Summary¶
- get_records(string $recordType, array $params = Array, integer $limit = 10)¶
Get a set of records from the database.
Parameters: - $recordType (string) – Type of records to get.
- $params (array) – Array of search parameters for records.
- $limit (integer) – Maximum number of records to return.
Returns: array An array of result records (of $recordType).
Usage¶
Examples¶
See Also¶
get_search_query_types¶
Summary¶
- get_search_query_types()¶
Get all available search query types.
Plugins may add query types via the “search_query_types” filter. The keysshould be the type’s GET query value and the respective values should be thehuman readable and internationalized version of the query type.
Plugins that add a query type must modify the select object via the”search_sql” hook to account for whatever custom search strategy theyimplement.
Returns: array
Usage¶
Examples¶
See Also¶
get_search_record_types¶
Summary¶
- get_search_record_types()¶
Get all record types that may be indexed and searchable.
Plugins may add record types via the “search_record_types” filter. Thekeys should be the record’s class name and the respective values shouldbe the human readable and internationalized version of the record type.
These record classes must extend Omeka_Record_AbstractRecord andimplement this search mixin (Mixin_Search).
Returns: array
Usage¶
Examples¶
See Also¶
get_specific_plugin_hook_output¶
Summary¶
- get_specific_plugin_hook_output()¶
Get the output of a specific plugin’s hook as a string.
This is like get_plugin_hook_output() but only calls the hook within theprovided plugin.
Returns: string|null
Usage¶
Examples¶
See Also¶
get_table_options¶
Summary¶
- get_table_options(string $tableClass, string $labelOption, array $searchParams = Array)¶
Get the options array for a given table.
Parameters: - $tableClass (string) –
- $labelOption (string) –
- $searchParams (array) – search parameters on table.
Usage¶
Examples¶
See Also¶
get_theme_option¶
Summary¶
- get_theme_option(string $optionName, string $themeName)¶
Get a theme option.
Parameters: - $optionName (string) – The option name.
- $themeName (string) – The theme name. If null, it will use the current public theme.
Returns: string The option value.
Usage¶
Examples¶
See Also¶
get_view¶
Summary¶
- get_view()¶
Get the view object.
Should be used only to avoid function scope issues within other theme helperfunctions.
Returns: Omeka_View
Usage¶
Examples¶
See Also¶
has_loop_records¶
Summary¶
- has_loop_records(string $recordsVar)¶
Check if records have been set to the view for iteration.
Note that this function will return false if the records variable is set butis an empty array, unlike get_loop_records(), which will return the emptyarray.
Parameters: - $recordsVar (string) –
Returns: bool
Usage¶
Examples¶
See Also¶
head¶
Summary¶
This function includes the file header.php in a theme. A view script needs to use this function along with foot to create the structure of the page.
- head(array $vars = Array, string $file = header)
Return the view’s header HTML.
Parameters: - $vars (array) – Keyed array of variables
- $file (string) – Filename of header script (defaults to ‘header’)
Returns: string
Usage¶
Examples¶
See Also¶
head_css¶
Summary¶
The head_css() helper function prints HTML link tags to the page for each stylesheet added with queue_css_file. It is commonly used in a theme’s common/header.php file to print the link tags inside the page head.
- head_css()¶
Return the CSS link tags that will be used on the page.
This should generally be used with echo to print the scripts in the pagehead.
Returns: string
Usage¶
Examples¶
See Also¶
head_js¶
Summary¶
The head_js() helper function prints HTML script tags to the page for each script added with queue_js_file. It is commonly used in a theme’s common/header.php file to print the script tags inside the page head.
head_js() will also include Omeka’s “default” JavaScript files.
- head_js(bool $includeDefaults = 1)¶
Return the JavaScript tags that will be used on the page.
This should generally be used with echo to print the scripts in the pagehead.
Parameters: - $includeDefaults (bool) – Whether the default javascripts should be included. Defaults to true.
Returns: string
Usage¶
Examples¶
See Also¶
html_escape¶
Summary¶
- html_escape(string $value)¶
Escape the value to display properly as HTML.
This uses the ‘html_escape’ filter for escaping.
Parameters: - $value (string) –
Returns: string
Usage¶
To avoid Cross Site Scripting attacks, any data coming from a client ($_GET, $_POST, etc) should be escaped.
Examples¶
<?php echo html_escape($_GET['search_text']); ?>
See Also¶
img¶
Summary¶
img() is a helper function used to include an image from within a theme. It returns the URL to an image file located in the images directory of that theme, usually located in themes/YourTheme/images. The resulting path can be used in an <img> tag, or anywhere else an image URL is needed.
- img(string $file, string $dir = images)
Return the web path to an image file.
Parameters: - $file (string) – Filename, including the extension.
- $dir (string) – Directory within the theme to look for image files. Defaults to ‘images’.
Returns: string
Usage¶
Examples¶
See Also¶
insert_collection¶
Summary¶
- insert_collection(array $metadata = Array, array $elementTexts = Array)¶
Insert a collection
Parameters: - $metadata (array) –
Follows the format:
array( 'public' => [true|false], 'featured' => [true|false] )
- $elementTexts (array) –
Array of element texts to assign to the collection. This follows the format:
array( [element set name] => array( [element name] => array( array('text' => [string], 'html' => [false|true]), array('text' => [string], 'html' => [false|true]) ), [element name] => array( array('text' => [string], 'html' => [false|true]), array('text' => [string], 'html' => [false|true]) ) ), [element set name] => array( [element name] => array( array('text' => [string], 'html' => [false|true]), array('text' => [string], 'html' => [false|true]) ), [element name] => array( array('text' => [string], 'html' => [false|true]), array('text' => [string], 'html' => [false|true]) ) ) );
Returns: Collection
- $metadata (array) –
Usage¶
Examples¶
See Also¶
insert_element_set¶
Summary¶
- insert_element_set(string|array $elementSetMetadata = Array, array $elements = Array)¶
Insert an element set and its elements into the database.
Parameters: - $elementSetMetadata (string|array) –
Element set information.
[(string) element set name] // OR array( 'name' => [(string) element set name, required, unique], 'description' => [(string) element set description, optional], 'record_type' => [(string) record type name, optional] );
- $elements (array) –
An array containing element data. Follows one of more of the following formats:
- An array containing element metadata
- A string of the element name
array( array( 'name' => [(string) name, required], 'description' => [(string) description, optional], ), [(string) element name] );
Returns: ElementSet
- $elementSetMetadata (string|array) –
Usage¶
Examples¶
See Also¶
insert_files_for_item¶
Summary¶
- insert_files_for_item(Item|integer $item, string|Omeka_File_Ingest_AbstractIngest $transferStrategy, array $files, array $options = Array)¶
Add files to an item.
Parameters: - $item (Item|integer) –
- $transferStrategy (string|Omeka_File_Ingest_AbstractIngest) –
- $files (array) –
- $options (array) –
Available Options:
- 'ignore_invalid_files': boolean false by default. Determine whether or not to throw exceptions when a file is not valid.
Returns: array
Usage¶
Examples¶
See Also¶
insert_item¶
Summary¶
- insert_item(array $metadata = Array, array $elementTexts = Array, array $fileMetadata = Array)¶
Insert a new item into the Omeka database.
Parameters: - $metadata (array) –
Set of metadata options for configuring the item. Array which can include the following properties:
- 'public' (boolean)
- 'featured' (boolean)
- 'collection_id' (integer)
- 'item_type_id' (integer)
- 'item_type_name' (string)
- 'tags' (string, comma-delimited)
- 'overwriteElementTexts' (boolean) -- determines whether or not to overwrite existing element texts. If true, this will loop through the element texts provided in $elementTexts, and it will update existing records where possible. All texts that are not yet in the DB will be added in the usual manner. False by default.
- $elementTexts (array) –
Array of element texts to assign to the item. This follows the format:
array( [element set name] => array( [element name] => array( array('text' => [string], 'html' => [false|true]), array('text' => [string], 'html' => [false|true]) ), [element name] => array( array('text' => [string], 'html' => [false|true]), array('text' => [string], 'html' => [false|true]) ) ), [element set name] => array( [element name] => array( array('text' => [string], 'html' => [false|true]), array('text' => [string], 'html' => [false|true]) ), [element name] => array( array('text' => [string], 'html' => [false|true]), array('text' => [string], 'html' => [false|true]) ) ) );
- $fileMetadata (array) –
Set of metadata options that allow one or more files to be associated with the item. Includes the following options:
- 'file_transfer_type' (string = 'Url|Filesystem|Upload' or Omeka_File_Transfer_Adapter_Interface). Corresponds to the $transferStrategy argument for addFiles().
- 'file_ingest_options' OPTIONAL (array of possible options to pass modify the behavior of the ingest script). Corresponds to the $options argument for addFiles().
- 'files' (array or string) Represents information indicating the file to ingest. Corresponds to the $files argument for addFiles().
Returns: Item
- $metadata (array) –
Usage¶
Examples¶
See Also¶
insert_item_type¶
Summary¶
- insert_item_type(array $metadata = Array, array $elementInfos = Array)¶
Insert a new item type.
Parameters: - $metadata (array) –
Follows the format:
array( 'name' => [string], 'description' => [string] );
- $elementInfos (array) –
An array containing element data. Each entry follows one or more of the following formats:
- An array containing element metadata
- An Element object
array( array( 'name' => [(string) name, required], 'description' => [(string) description, optional], 'order' => [(int) order, optional], ), [(Element)], );
Returns: ItemType
- $metadata (array) –
Usage¶
Examples¶
See Also¶
is_admin_theme¶
Summary¶
- is_admin_theme()¶
Determine whether or not the script is being executed through the administrative interface.
Can be used to branch behavior based on whether or not the admin theme isbeing accessed, but should not be relied upon in place of using the ACL forcontrolling access to scripts.
Returns: boolean
Usage¶
Examples¶
See Also¶
is_allowed¶
Summary¶
- is_allowed($resource, $privilege)¶
Check the ACL to determine whether the current user has proper permissions.
is_allowed('Items', 'showNotPublic');
Will check if the user has permission to view Items that are not public.
Parameters: - $resource (unknown) –
- $privilege (unknown) –
Usage¶
Examples¶
See Also¶
is_current_url¶
Summary¶
- is_current_url(string $url)¶
Determine whether the given URI matches the current request URI.
Instantiates view helpers directly because a view may not be registered.
Parameters: - $url (string) –
Returns: boolean
Usage¶
Examples¶
See Also¶
item_image¶
Summary¶
- item_image(string $imageType, array $props = Array, integer $index = 0, $item)¶
Return a customized item image tag.
Parameters: - $imageType (string) –
- $props (array) –
- $index (integer) –
- $item (unknown) –
Usage¶
Examples¶
See Also¶
item_image_gallery¶
Summary¶
- item_image_gallery(array $attrs = Array, string $imageType = square_thumbnail, boolean $filesShow =, Item $item)¶
Get a gallery of file thumbnails for an item.
Parameters: - $attrs (array) – HTML attributes for the components of the gallery, in sub-arrays for ‘wrapper’, ‘linkWrapper’, ‘link’, and ‘image’. Set a wrapper to null to omit it.
- $imageType (string) – The type of derivative image to display.
- $filesShow (boolean) – Whether to link to the files/show. Defaults to false, links to the original file.
- $item (Item) – The Item to use, the current item if omitted.
Returns: string
Usage¶
Examples¶
See Also¶
item_search_filters¶
Summary¶
- item_search_filters($params)¶
Return a list of the current search item filters in use.
Parameters: - $params (unknown) –
Returns: string
Usage¶
Examples¶
See Also¶
item_type_elements¶
Summary¶
- item_type_elements(Item|null $item)¶
Return the set of values for item type elements.
Parameters: - $item (Item|null) – Check for this specific item record (current item if null).
Returns: array
Usage¶
Examples¶
See Also¶
items_output_url¶
Summary¶
- items_output_url(string $output, array $otherParams = Array)¶
Return a URL to an output page.
Parameters: - $output (string) –
- $otherParams (array) –
Returns: string
Usage¶
Examples¶
See Also¶
items_search_form¶
Summary¶
- items_search_form(array $props = Array, string $formActionUri)¶
Return the HTML for an item search form.
Parameters: - $props (array) –
- $formActionUri (string) –
Returns: string
Usage¶
Examples¶
See Also¶
js_escape¶
Summary¶
- js_escape(string $value)¶
Escape the value for use in javascript.
This is a convenience function for encoding a value using JSON notation.Must be used when interpolating PHP output in javascript. Note on usage: donot wrap the resulting output of this function in quotes, as proper JSONencoding will take care of that.
Parameters: - $value (string) –
Returns: string
Usage¶
Examples¶
See Also¶
js_tag¶
Summary¶
- The js_tag() helper function retrieves JavaScript files located within the /javascripts/ folder
- of a theme. By using js_tag(), the relative path to the file is dynamically generated for each page.
Note
The queue_js_file helper is preferred to this one for most use cases. Normally, you should only continue to use this helper when you want to output an inline script in the body of the page.
- js_tag(string $file, string $dir = javascripts)¶
Return a javascript tag.
Parameters: - $file (string) – The name of the file, without .js extension.
- $dir (string) – The directory in which to look for javascript files. Recommended to leave the default value.
Returns: string
Usage¶
Examples¶
See Also¶
label_table_options¶
Summary¶
- label_table_options(array $options, string|null $labelOption)¶
Add a “Select Below” or other label option to a set of select options.
Parameters: - $options (array) –
- $labelOption (string|null) –
Returns: array
Usage¶
Examples¶
See Also¶
latest_omeka_version¶
Summary¶
- latest_omeka_version()¶
Return the latest available version of Omeka by accessing the appropriate URI on omeka.org.
Returns: string|false The latest available version of Omeka, or false if the request failed for some reason.
Usage¶
Examples¶
See Also¶
link_to¶
Summary¶
- link_to(Omeka_Record_AbstractRecord|string $record, string $action, string $text, array $props = Array, array $queryParams = Array)¶
Return a link tag.
Parameters: - $record (Omeka_Record_AbstractRecord|string) – The name of the controller to use for the link. If a record instance is passed, then it inflects the name of the controller from the record class.
- $action (string) – The action to use for the link
- $text (string) – The text to put in the link. Default is ‘View’.
- $props (array) – Attributes for the <a> tag
- $queryParams (array) – the parameters in the uri query
Returns: string HTML
Usage¶
Examples¶
See Also¶
link_to_admin_home_page¶
Summary¶
Creates a link to the Omeka admin anywhere in your public theme.
- link_to_admin_home_page(null|string $text, array $props = Array)¶
Return a link to the admin home page.
Parameters: - $text (null|string) –
- $props (array) –
Returns: string
Usage¶
Examples¶
See Also¶
link_to_collection¶
Summary¶
- link_to_collection(string $text, array $props = Array, array $action = show, array $collectionObj)¶
Return a link to a collection.
Parameters: - $text (string) – text to use for the title of the collection. Default behavior is to use the name of the collection.
- $props (array) – Set of attributes to use for the link.
- $action (array) – The action to link to for the collection.
- $collectionObj (array) – Collection record can be passed to this to override the collection object retrieved by get_current_record().
Returns: string
Usage¶
Examples¶
See Also¶
link_to_collection_for_item¶
Summary¶
- link_to_collection_for_item(string|null $text, array $props = Array, string $action = show)¶
Return a link to the collection to which the item belongs.
The default text displayed for this link will be the name of the collection,but that can be changed by passing a string argument.
Parameters: - $text (string|null) – Text for the link.
- $props (array) – HTML attributes for the <a> tag.
- $action (string) – ‘show’ by default.
Returns: string
Usage¶
Examples¶
See Also¶
link_to_file_show¶
Summary¶
- link_to_file_show(array $attributes = Array, string $text, File|null $file)¶
Return a link to the file metadata page for a particular file.
If no File object is specified, this will determine the file to use throughcontext. The text of the link defaults to the DC:Title of the file record,then to the original filename, unless otherwise specified.
Parameters: - $attributes (array) –
- $text (string) –
- $file (File|null) –
Returns: string
Usage¶
Examples¶
See Also¶
link_to_home_page¶
Summary¶
Returns a link to the public home page of an Omeka site.
- link_to_home_page(null|string $text, array $props = Array)¶
Return a link to the public home page.
Parameters: - $text (null|string) –
- $props (array) –
Returns: string
Usage¶
Examples¶
See Also¶
link_to_item¶
Summary¶
- link_to_item(string $text, array $props = Array, string $action = show, Item $item)¶
Return a link to an item.
Parameters: - $text (string) – HTML for the text of the link.
- $props (array) – Properties for the <a> tag.
- $action (string) – The page to link to (this will be the ‘show’ page almost always within the public theme).
- $item (Item) – Used for dependency injection testing or to use this function outside the context of a loop.
Returns: string HTML
Usage¶
Examples¶
See Also¶
link_to_item_search¶
Summary¶
- link_to_item_search(string $text, array $props = Array, string $uri)¶
Return HTML for a link to the item search form.
Parameters: - $text (string) – Text of the link. Default is ‘Search Items’.
- $props (array) – HTML attributes for the link.
- $uri (string) – Action for the form. Defaults to ‘items/browse’.
Returns: string
Usage¶
Examples¶
See Also¶
link_to_items_browse¶
Summary¶
- link_to_items_browse(string $text, array $browseParams = Array, array $linkProperties = Array)¶
Return HTML for a link to the browse page for items.
Parameters: - $text (string) – Text to display in the link.
- $browseParams (array) – Any parameters to use to build the browse page URL, e.g. array(‘collection’ => 1) would build items/browse?collection=1 as the URL.
- $linkProperties (array) – HTML attributes for the link.
Returns: string HTML
Usage¶
Examples¶
See Also¶
link_to_items_in_collection¶
Summary¶
- link_to_items_in_collection(string|null $text, array $props = Array, string $action = browse, Collection $collectionObj)¶
Return a link to the collection items browse page.
Parameters: - $text (string|null) –
- $props (array) –
- $action (string) –
- $collectionObj (Collection) –
Returns: string
Usage¶
Examples¶
See Also¶
link_to_items_rss¶
Summary¶
- link_to_items_rss(string $text, array $params = Array)¶
Return a link the the items RSS feed.
Parameters: - $text (string) – The text of the link.
- $params (array) – A set of query string parameters to merge in to the href of the link. E.g., if this link was clicked on the items/browse?collection=1 page, and array(‘foo’=>’bar’) was passed as this argument, the new URI would be items/browse?collection=1&foo=bar.
Usage¶
Examples¶
See Also¶
link_to_items_with_item_type¶
Summary¶
- link_to_items_with_item_type(string|null $text, array $props = Array, string $action = browse, $itemTypeObj)¶
Return a link to item type items browse page.
Parameters: - $text (string|null) –
- $props (array) –
- $action (string) –
- $itemTypeObj (unknown) –
Returns: string
Usage¶
Examples¶
See Also¶
link_to_next_item_show¶
Summary¶
- link_to_next_item_show(string $text, array $props = Array)¶
Return a link to the item immediately following the current one.
Parameters: - $text (string) –
- $props (array) –
Returns: string
Usage¶
Examples¶
See Also¶
link_to_previous_item_show¶
Summary¶
- link_to_previous_item_show(string $text, array $props = Array)¶
Return a link to the item immediately before the current one.
Parameters: - $text (string) –
- $props (array) –
Returns: string
Usage¶
Examples¶
See Also¶
loop¶
Summary¶
loop() is designed to make looping through records for a browse page easier.
You can either pass in an array of record to loop through or, more commonly, the name of the model (e.g. ‘items’ or ‘collections’), whose records have already been set on the page.
- loop(string $recordsVar, array|null $records)
Return an iterator used for looping an array of records.
Parameters: - $recordsVar (string) –
- $records (array|null) –
Returns: Omeka_Record_Iterator
Usage¶
Usually, the $recordsVar parameter is a string name of the model whose records have already been set in the view by the controller.
This will be the name of the table, i.e., the pluralized, underscored name of the model. For example, a CamelCase model name like “CsvImport_Import” should be “csv_import_imports”.
The string will be converted to the table name. Thus, csv_import_imports and CsvImport_Import have exactly the same effect (provided the same convention was used in setting the records to loop in the view).
Examples¶
metadata¶
Summary¶
Returns metadata about a record
- metadata(Omeka_Record_AbstractRecord|string $record, mixed $metadata, array $options = Array)
Return a piece or pieces of metadata for a record.
Parameters: - $record (Omeka_Record_AbstractRecord|string) – The record to get metadata for. If an Omeka_Record_AbstractRecord, that record is used. If a string, that string is used to look up a record in the current view.
- $metadata (mixed) – The metadata to get. If an array is given, this is Element metadata, identified by array(‘Element Set’, ‘Element’). If a string, the metadata is a record-specific “property.”
- $options (array) – Options for getting the metadata.
Returns: mixed
Usage¶
The first parameter can be either a record or the name of the current record type. The latter usage is helpful when looping through records.
For records that carry Element Set metadata, get the value for an element by passing the element set and element name as an array in the second parameter, e.g. array('Dublin Core', 'Title')
You can also get properties of the record by passing the name of the property as a string in the second parameter.
Valid keys for the $options array are:
- all: If true, return an array containing all values for the field.
- delimiter: Return the entire set of metadata as a string, where entries are separated by the given delimiter.
- index: Return the metadata entry at the given zero-based index.
- no_escape: If true, do not escape the resulting values for HTML entities.
- no_filter: If true, return the set of metadata without running any filters.
- snippet: Trim the length of each piece of text to the given length in characters.
- Passing simply the string ‘all’ is equivalent to array('all' => true)
- Passing simply an integer is equivalent to array('index' => [the integer])
Examples¶
See Also¶
option¶
Summary¶
- option(string $name)
Return the value of a particular site setting. This can be used to display any option that would be retrieved with get_option().
Content for any specific option can be filtered by using a filter named’display_option_(option)’ where (option) is the name of the option, e.g.’display_option_site_title’.
Parameters: - $name (string) – The name of the option
Returns: string
Usage¶
Examples¶
See Also¶
output_format_list¶
OutputFormat-related functions
Summary¶
- output_format_list(bool $list = 1, string $delimiter =)¶
Return an HTML list containing all available output format contexts for the current action.
Parameters: - $list (bool) – True = unordered list; False = use delimiter
- $delimiter (string) – If the first argument is false, use this as a delimiter.
Returns: string|bool HTML
Usage¶
Examples¶
See Also¶
pagination_links¶
Summary¶
- pagination_links(array $options = Array)¶
Return HTML for the set of pagination links.
Parameters: - $options (array) –
Configurable parameters for the pagination links. The following options are available:
- 'scrolling_style' (string) See Zend_View_Helper_PaginationControl for more details. Default 'Sliding'.
- 'partial_file' (string) View script to use to render the pagination HTML. Default is 'common/pagination_control.php'.
- 'page_range' (integer) See Zend_Paginator::setPageRange() for details. Default is 5.
- 'total_results' (integer) Total results to paginate through. Default is provided by the 'total_results' key of the 'pagination' array that is typically registered by the controller.
- 'page' (integer) Current page of the result set. Default is the 'page' key of the 'pagination' array.
- 'per_page' (integer) Number of results to display per page. Default is the 'per_page' key of the 'pagination' array.
- $options (array) –
Usage¶
Examples¶
See Also¶
physical_path_to¶
Summary¶
- physical_path_to(string $file)¶
Return the physical path for an asset/resource within the theme (or plugins, shared, etc.)
Parameters: - $file (string) – The filename.
Returns: string
Usage¶
Examples¶
See Also¶
pluck¶
Summary¶
- pluck(string|integer $col, array $array)
Return one column of a multidimensional array as an array.
Parameters: - $col (string|integer) – The column to pluck.
- $array (array) – The array from which to pluck.
Returns: array The column as an array.
Usage¶
Examples¶
See Also¶
plugin_is_active¶
Summary¶
- plugin_is_active($name, $version, $compOperator = >=)¶
Determine whether a plugin is installed and active.
May be used by theme/plugin writers to customize behavior based on the existence of certain plugins. Some examples of how to use this function:
Check if ExhibitBuilder is installed and activated.
if (plugin_is_active('ExhibitBuilder')):
Check if installed version of ExhibitBuilder is at least version 1.0 orhigher.
if (plugin_is_active('ExhibitBuilder', '1.0')):
Check if installed version of ExhibitBuilder is anything less than 2.0.
if (plugin_is_active('ExhibitBuilder', '2.0', '<')):
Parameters: - $name (unknown) –
- $version (unknown) –
- $compOperator (unknown) –
Usage¶
Examples¶
See Also¶
queue_css_file¶
Summary¶
- queue_css_file(string|array $file, string $media = all, string|bool $conditional =, string $dir = css)¶
Declare that a CSS file or files will be used on the page.
All “used” stylesheets will be included in the page’s head. This needs to becalled either before head(), or in a plugin_header hook.
Parameters: - $file (string|array) – File to use, if an array is passed, each array member will be treated like a file.
- $media (string) – CSS media declaration, defaults to ‘all’.
- $conditional (string|bool) – IE-style conditional comment, used generally to include IE-specific styles. Defaults to false.
- $dir (string) – Directory to search for the file. Keeping the default is recommended.
Usage¶
Examples¶
See Also¶
queue_css_string¶
Summary¶
- queue_css_string(string $string, string $media = all, string|bool $conditional =)¶
Declare a CSS string to be used on the page and included in the page’s head.
This needs to be called either before head() or in a plugin_header hook.
Parameters: - $string (string) – CSS string to include.
- $media (string) – CSS media declaration, defaults to ‘all’.
- $conditional (string|bool) – IE-style conditional comment, used generally to include IE-specific styles. Defaults to false.
Usage¶
Examples¶
See Also¶
queue_css_url¶
Summary¶
- queue_css_url($url, string $media = all, string|bool $conditional =)¶
Declare a URL to a stylesheet to be used on the page and included in the page’s head.
This needs to be called either before head() or in a plugin_header hook.
Parameters: - $url (unknown) –
- $media (string) – CSS media declaration, defaults to ‘all’.
- $conditional (string|bool) – IE-style conditional comment, used generally to include IE-specific styles. Defaults to false.
Usage¶
Examples¶
See Also¶
queue_js_file¶
Summary¶
- queue_js_file(string|array $file, string $dir = javascripts, array $options = Array)¶
Declare that a JavaScript file or files will be used on the page.
All “used” scripts will be included in the page’s head. This needs to becalled either before head(), or in a plugin_header hook.
Parameters: - $file (string|array) – File to use, if an array is passed, each array member will be treated like a file.
- $dir (string) – Directory to search for the file. Keeping the default is recommended.
- $options (array) – An array of options.
Usage¶
Examples¶
See Also¶
queue_js_string¶
Summary¶
- queue_js_string(string $string, array $options = Array)¶
Declare a JavaScript string to be used on the page and included in the page’s head.
This needs to be called either before head() or in a plugin_header hook.
Parameters: - $string (string) – JavaScript string to include.
- $options (array) – An array of options.
Usage¶
Examples¶
See Also¶
queue_js_url¶
Summary¶
- queue_js_url($url, array $options = Array)¶
Declare a URL to a JavaScript file to be used on the page.
This needs to be called either before head() or in a plugin_header hook.
Parameters: - $url (unknown) –
- $options (array) – An array of options.
Usage¶
Examples¶
See Also¶
random_featured_collection¶
Summary¶
- random_featured_collection()¶
Returns the HTML for displaying a random featured collection.
Returns: string
Usage¶
Examples¶
See Also¶
random_featured_items¶
Summary¶
- random_featured_items(int $count = 5, $hasImage)¶
Return HTML for random featured items.
Parameters: - $count (int) –
- $hasImage (unknown) –
Returns: string
Usage¶
Examples¶
See Also¶
record_url¶
Summary¶
- record_url(Omeka_Record_AbstractRecord|string $record, string|null $action, bool $getAbsoluteUrl =)¶
Return a URL to a record.
Parameters: - $record (Omeka_Record_AbstractRecord|string) –
- $action (string|null) –
- $getAbsoluteUrl (bool) –
Returns: string
Usage¶
Examples¶
See Also¶
release_object¶
Summary¶
- release_object($var)¶
Release an object from memory.
Use this fuction after you are done using an Omeka model object to preventmemory leaks. Required because PHP 5.2 does not do garbage collection oncircular references.
Parameters: - $var (unknown) –
Usage¶
Examples¶
See Also¶
search_filters¶
Summary¶
- search_filters(array $options = Array)¶
Return a list of current site-wide search filters in use.
Parameters: - $options (array) – Valid options are as follows: - id (string): the value of the div wrapping the filters.
Returns: string
Usage¶
Examples¶
See Also¶
search_form¶
Summary¶
- search_form(array $options = Array)¶
Return the site-wide search form.
Parameters: - $options (array) – Valid options are as follows: - show_advanced (bool): whether to show the advanced search; default is false. - submit_value (string): the value of the submit button; default “Submit”. - form_attributes (array): an array containing form tag attributes.
Returns: string The search form markup.
Usage¶
Examples¶
See Also¶
set_current_record¶
Summary¶
- set_current_record(string $recordVar, Omeka_Record_AbstractRecord $record, bool $setPreviousRecord =)¶
Set a record to the view as the current record.
Parameters: - $recordVar (string) –
- $record (Omeka_Record_AbstractRecord) –
- $setPreviousRecord (bool) –
Usage¶
Examples¶
See Also¶
set_loop_records¶
Summary¶
- set_loop_records(string $recordsVar, array $records)¶
Set records to the view for iteration.
Parameters: - $recordsVar (string) –
- $records (array) –
Usage¶
Examples¶
See Also¶
set_option¶
Summary¶
- set_option(string $name, string $value)¶
Set an option to the options table.
Note that objects and arrays must be serialized before being saved.
Parameters: - $name (string) – The option name.
- $value (string) – The option value.
Usage¶
Examples¶
See Also¶
set_theme_base_url¶
Summary¶
- set_theme_base_url(string $theme)¶
Set the base URL for the specified theme.
Parameters: - $theme (string) –
Usage¶
Examples¶
See Also¶
set_theme_option¶
Summary¶
- set_theme_option(string $optionName, string $optionValue, string $themeName)¶
Set a theme option.
Parameters: - $optionName (string) – The option name.
- $optionValue (string) – The option value.
- $themeName (string) – The theme name. If null, it will use the current public theme.
Usage¶
Examples¶
See Also¶
snippet¶
Summary¶
- snippet(string $text, int $startPos, int $endPos, string $append = …)
Return a substring of a given piece of text.
Note: this will only split strings on the space character.this will also strip html tags from the text before getting a snippet
Parameters: - $text (string) – Text to take snippet of
- $startPos (int) – Starting position of snippet in string
- $endPos (int) – Maximum length of snippet
- $append (string) – String to append to snippet if truncated
Returns: string Snippet of given text
Usage¶
Examples¶
See Also¶
snippet_by_word_count¶
Summary¶
- snippet_by_word_count(string $text, integer $maxWords = 20, string $ellipsis = ...)¶
Return a substring of the text by limiting the word count.
Note: it strips the HTML tags from the text before getting the snippet
Parameters: - $text (string) –
- $maxWords (integer) –
- $ellipsis (string) –
Returns: string
Usage¶
Examples¶
See Also¶
src¶
Summary¶
- src(string $file, string|null $dir, string $ext)
Return a valid src attribute value for a given file.
Parameters: - $file (string) – The filename.
- $dir (string|null) – The file’s directory.
- $ext (string) – The file’s extension.
Returns: string
Usage¶
Examples¶
See Also¶
strip_formatting¶
Summary¶
- strip_formatting(string $str, string $allowableTags =, string $fallbackStr =)¶
Strip HTML formatting (i.e. tags) from the provided string.
This is essentially a wrapper around PHP’s strip_tags() function, with theadded benefit of returning a fallback string in case the resulting strippedstring is empty or contains only whitespace.
Parameters: - $str (string) – The string to be stripped of HTML formatting.
- $allowableTags (string) – The string of tags to allow when stripping tags.
- $fallbackStr (string) – The string to be used as a fallback.
Returns: The stripped string.
Usage¶
Examples¶
See Also¶
stripslashes_deep¶
Summary¶
- stripslashes_deep(array|string $value)¶
Strip slashes recursively.
Parameters: - $value (array|string) –
Returns: array
Usage¶
Examples¶
See Also¶
tag_attributes¶
Summary¶
- tag_attributes(array|string $attributes, string $value)¶
Generate attributes for HTML tags.
Parameters: - $attributes (array|string) – Attributes for the tag. If this is a string, it will assign both ‘name’ and ‘id’ attributes that value for the tag.
- $value (string) –
Returns: string
Usage¶
Examples¶
See Also¶
tag_cloud¶
Summary¶
- tag_cloud(Omeka_Record_AbstractRecord|array $recordOrTags, string|null $link, int $maxClasses = 9, bool $tagNumber =, string $tagNumberOrder)¶
Create a tag cloud made of divs that follow the hTagcloud microformat
Parameters: - $recordOrTags (Omeka_Record_AbstractRecord|array) – The record to retrieve tags from, or the actual array of tags
- $link (string|null) – The URI to use in the link for each tag. If none given, tags in the cloud will not be given links.
- $maxClasses (int) –
- $tagNumber (bool) –
- $tagNumberOrder (string) –
Returns: string HTML for the tag cloud
Usage¶
Examples¶
See Also¶
tag_string¶
Summary¶
- tag_string(Omeka_Record_AbstractRecord|array $recordOrTags, string|null $link = items/browse, string $delimiter)¶
Return a tag string given an Item, Exhibit, or a set of tags.
Parameters: - $recordOrTags (Omeka_Record_AbstractRecord|array) – The record to retrieve tags from, or the actual array of tags
- $link (string|null) – The URL to use for links to the tags (if null, tags aren’t linked)
- $delimiter (string) – ‘, ‘ (comma and whitespace) is the default tag_delimiter option. Configurable in Settings
Returns: string HTML
Usage¶
Examples¶
See Also¶
text_to_id¶
Summary¶
- text_to_id($text, $prepend, $delimiter = -)¶
Convert a word or phrase to dashed format, i.e. Foo Bar => foo-bar.
This is primarily for easy creation of HTML ids within Omeka
- <ol>
- <li>convert to lowercase</li> <li>Replace whitespace with -</li> <li>remove all non-alphanumerics</li> <li>remove leading/trailing delimiters</li> <li>optionally prepend a piece of text</li>
</ol>
Parameters: - $text (unknown) –
- $prepend (unknown) –
- $delimiter (unknown) –
Usage¶
Examples¶
See Also¶
text_to_paragraphs¶
Summary¶
- text_to_paragraphs(string $str)¶
Replace new lines in a block of text with paragraph tags.
Looks for 2 consecutive line breaks resembling a paragraph break and wrapseach of the paragraphs with a <p> tag. If no paragraphs are found, then theoriginal text will be wrapped with line breaks.
Parameters: - $str (string) –
Returns: string
Usage¶
Examples¶
See Also¶
theme_header_background¶
Summary¶
- theme_header_background()¶
Return the theme’s header background image style.
Returns: string|null
Usage¶
Examples¶
See Also¶
total_records¶
Summary¶
- total_records(string $recordType)¶
Return the total number of a given type of record in the database.
Parameters: - $recordType (string) – Type of record to count.
Returns: integer Number of records of $recordType in the database.
Usage¶
Examples¶
See Also¶
update_collection¶
Summary¶
- update_collection(Collection|int $collection, array $metadata = Array, array $elementTexts = Array)¶
Update an existing collection.
Parameters: - $collection (Collection|int) – Either an Collection object or the ID for the collection.
- $metadata (array) – Set of options that can be passed to the collection.
- $elementTexts (array) – The element texts for the collection
Returns: Collection
Usage¶
Examples¶
See Also¶
update_item¶
Summary¶
- update_item(Item|int $item, array $metadata = Array, array $elementTexts = Array, array $fileMetadata = Array)¶
Update an existing item.
Parameters: - $item (Item|int) – Either an Item object or the ID for the item.
- $metadata (array) – Set of options that can be passed to the item.
- $elementTexts (array) –
- $fileMetadata (array) –
Returns: Item
Usage¶
Valid keys for the $metadata array include:
- 'item_type_id' : integer
- The ID of the Item Type for the Item.
- 'item_type_name' : string
- The name of the Item Type for the Item. This option takes precedence over 'item_type_id' if both are specified.
- 'collection_id' : integer
- The ID of the Collection the item belongs to.
- 'public' : integer
- Whether the Item is public (set 1 or 0).
- 'featured' : integer
- Whether the Item is featured (set 1 or 0).
- 'overwriteElementTexts' : mixed
- If present with any value, the element texts passed in $elementTexts replace the existing texts instead of appending to them.
The $elementTexts array has the same format as the array passed to Mixin_ElementText::addElementTextsByArray.
Examples¶
See Also¶
url¶
Summary¶
Returns a URL to a page in an Omeka site. This function can be used to create links between different pages on the site.
Plugin and theme writers should always use this helper when linking between pages. Hand-written or “bare” URLs are generally only valid for a particular Omeka installation. This helper generates relative URLs that are valid regardless of where an Omeka installation is located on a server.
- url(mixed $options = Array, string $route, mixed $queryParams = Array, bool $reset =, bool $encode = 1)
Return a URL given the provided arguments.
Instantiates view helpers directly because a view may not be registered.
Parameters: - $options (mixed) –
- If a string is passed it is treated as an Omeka-relative link. So, passing 'items' would create a link to the items page.
- (Advanced) If an array is passed (or no argument given), it is treated as options to be passed to Omeka's routing system.
- $route (string) – The route to use if an array is passed in the first argument.
- $queryParams (mixed) – A set of query string parameters to append to the URL
- $reset (bool) – Whether Omeka should discard the current route when generating the URL.
- $encode (bool) – Whether the URL should be URL-encoded
Returns: string HTML
- $options (mixed) –
Usage¶
Examples¶
See Also¶
url_to_link¶
Summary¶
- url_to_link(string $str)¶
Convert any URLs in a given string to links.
Parameters: - $str (string) – The string to be searched for URLs to convert to links.
Returns: string
Usage¶
Examples¶
See Also¶
By Typical Usage¶
Hooks¶
Using Hooks¶
All Hooks¶
<model>_browse_sql¶
Usage¶
Alters the Omeka_Db_Select object when finding records of type <model> using the Omeke_Db_Table::findBy method.
<model> should be the plural name of the model, e.g. items_browse_sql
Arguments¶
- Omeka_Db_Select select
- The select object
- array params
- The parameters being used to build the select object
Examples¶
add_<model>_tag¶
Usage¶
Fires when tags are added to a record of type <model>
Arguments¶
- Omeka_Record_AbstractRecord record
- The record tags are being added to.
- array added
- Array of tags added
Examples¶
admin_<type>_form¶
Usage¶
Add form elements to a form created via Omeka_Form_Admin
Arguments¶
- Omeka_Form_Admin form
- The form object
- Omeka_Record_AbstractRecord | null record
- The record being edited, if it is included in the form
admin_<type>_panel_buttons¶
Usage¶
Append content just below the save panel buttons when editing using the Omeka_Form_Admin. Often <type> will be a model type.
Arguments¶
- Omeka_View view
- The view object
- :php:class:`Omeka_Record_AbstractRecord`|null record
- The record being edited, if a record was passed in when creating the form. Otherwise, null.
Examples¶
admin_<type>_panel_fields¶
Usage¶
Append content just below the save panel fields when editing using the Omeka_Form_Admin. Often <type> will be a model type.
Arguments¶
- :php:class:`Omeka_Record_AbstractRecord`|null record
- The record being edited, if one was passed in when the form was created. Otherwise, null
- Omeka_View view
- The view object
Examples¶
admin_appearance_settings_form¶
Usage¶
Arguments¶
- Omeka_Form form
- The form object
- Omeka_View view
- The view object
Examples¶
admin_collections_browse¶
Usage¶
Arguments¶
- array collection
- Array of :php:class:`Collection`s
- Omeka_View view
- The view object
Examples¶
admin_collections_form¶
Usage¶
Append to the form for the collection being edited. Content appears underneath the tabs
Arguments¶
- Omeka_View view
- The view object
- Collection collection
- The collection being edited
Examples¶
admin_collections_show¶
Usage¶
Append content to the admin collection show page.
Arguments¶
- Collection collection
- The collection
- Omeka_View view
- The view object
Examples¶
admin_files_form¶
Usage¶
Append content to the main area of a file edit page.
Arguments¶
- File file
- The file object
- Omeka_View view
- The view object
Examples¶
admin_files_show¶
Usage¶
Append content to the main area of a file show page.
Arguments¶
- File file
- The file object
- Omeka_View view
- The view object
Examples¶
admin_file_show_sidebar¶
Usage¶
Append content to the info panels area of a file show page.
Note
To add content to the save panel, use admin_files_panel_buttons or admin_files_panel_fields.
Arguments¶
- File file
- The file object
- Omeka_View view
- The view object
Examples¶
admin_form_files¶
Usage¶
Append content to the “Files” part of the item form.
To work with the files themselves, get the $item from the $args array and look at $item->Files
Arguments¶
- Item item
- The item object
- Omeka_View view
- The view object
Examples¶
admin_general_settings_form¶
Usage¶
Manipulate the form for admin general settings.
Arguments¶
- Omeka_Form form
- The form
Examples¶
admin_head¶
Usage¶
Adds content to the header of the admin theme.
This hook is fired by the header.php script, which is loaded by a call to head() while it is populating the <head> tag for the admin theme.
Functions attaching to this hook can directly output HTML into the <head>, or use functions like queue_css and queue_js.
Plugins will likely not need to add content to the admin-side <head> for every page, but the passed request object can be used to include content on particular pages only.
Arguments¶
- Omeka_View view
- The view object
Examples¶
admin_item_types_browse¶
Usage¶
Arguments¶
- array item_types
- The array of :php:class:`ItemType`s objects
- Omeka_View view
- The view object
Examples¶
admin_item_types_form¶
Usage¶
Add content to the admin item type edit form
Arguments¶
- ItemType item_type
- The item type object
- Omeka_View view
- The view object
Examples¶
admin_item_types_show¶
Usage¶
Add content to the item types show page
Arguments¶
- ItemType item_type
- The item type object
- Omeka_View view
- The view object
Examples¶
admin_items_batch_edit_form¶
Usage¶
Appends content to the end of the batch editing screen, but before the delete option.
If adding form elements, name them “custom”
See Understanding the Admin Css for details on CSS styling
Arguments¶
- Omeka_View view
- The view object
Examples¶
See Also¶
admin_items_browse¶
Usage¶
Append content to the admin items browse page
Arguments¶
- array items
- Array of :php:class:`Item`s
- Omeka_View view
- The view object
Examples¶
admin_items_browse_detailed_each¶
Usage¶
Append content to the details view of an item on the items browse page
Arguments¶
- Item item
- The item object
- Omeka_View view
- The view object
Examples¶
public function hookAdminItemsBrowseDetailedEach($args)
{
$item = $args['item'];
$embedTable = get_db()->getTable('Embed');
$totalEmbeds = $embedTable->totalEmbeds($item->id);
$html = '<p>';
$html .= "<a href='" . url('embed-codes/item/' . $item->id) . "'>" . __('Embeds (%d)', $totalEmbeds) . "</a>";
$html .= '</p>';
echo $html;
}
admin_items_browse_simple_each¶
Usage¶
Adds content to each item’s row on the items browse page.
Arguments¶
- Item item
- The item object
- Omeka_View view
- The view object
Examples¶
admin_items_form_files¶
Append content to the “Files” part of the item form.
To work with the files themselves, get the $item from the $args array and look at $item->Files
Arguments¶
- Item item
- The item object
- Omeka_View view
- The view object
Examples¶
admin_items_form_tags¶
Usage¶
Add content to the tags form for an item.
To work with the tags themselves, get the $item from the $args array and do $item->getTags()
Arguments¶
- Item item
- The item object
- Omeka_View view
- The view object
Examples¶
admin_items_search¶
Usage¶
Append form elements to the advanced search area.
Note
If your plugin adds searchable models, checkboxes for including them in your search are controlled by the site administrator.
Arguments¶
- Omeka_View view
- The view object
Examples¶
admin_items_show¶
Usage¶
Append content to the main item show area
Arguments¶
- Item item
- The item object
- Omeka_View view
- The view object
Examples¶
admin_items_show_sidebar¶
Usage¶
Append content to the sidebar panels on the items show page.
Content should be wrapped in <div class="panel">
Note
To add content to the save panel, use admin_items_panel_buttons or admin_items_panel_fields.
Arguments¶
- Item item
- The item object
- Omeka_View view
- The view object
Examples¶
admin_themes_browse_each¶
Usage¶
Add content to a theme’s description
Arguments¶
- Theme theme
- The theme object
- Omeka_View view
- The view object
Examples¶
after_delete_<model>¶
Usage¶
Fires after any database model of type <model> is deleted.
Arguments¶
- Omeka_Record_AbstractRecord record
- The record being edited
Examples¶
after_delete_record¶
Usage¶
Fires after any database model is deleted.
Arguments¶
- Omeka_Record_AbstractRecord record
- The record being edited
Examples¶
after_ingest_file¶
Usage¶
Fires after a file is ingested, but before it is added to the item.
Examples¶
after_save_<model>¶
Usage¶
Fires after a database record of type <model> is saved.
The id is available, but changes made to the record will not be saved.
Arguments¶
- Omeka_Record_AbstractRecord record
- The record being edited
- array or false post
- The post data, or false if none
- boolean insert
- Whether the record is being inserted
Examples¶
after_save_record¶
Usage¶
Fires after any database record is saved. This includes both insert and update operations.
Since this hook fires after the record is saved, the record ID will be available, but changes made to any other record properties will not be saved.
Arguments¶
- Omeka_Record_AbstractRecord record
- The record being edited
- array or false post
- The post data, or false if none
- boolean insert
- Whether the record is being inserted
Examples¶
before_delete_<model>¶
Usage¶
Fires before any database record of type <model> is deleted.
Arguments¶
- Omeka_Record_AbstractRecord record
- The record being edited
Examples¶
before_delete_record¶
Usage¶
Fires before any database record is deleted.
Arguments¶
- Omeka_Record_AbstractRecord record
- The record being edited
Examples¶
before_save_<model>¶
Usage¶
Fires before any database record of type <model> is saved. This includes both insert and update operations.
Since this hook fires before the record is saved, the record ID will not be available, but changes made to any other record properties will be saved.
Arguments¶
- Omeka_Record_AbstractRecord record
- The record being edited
- array or false post
- The post data, or false if none
- boolean insert
- Whether the record is being inserted
Examples¶
before_save_record¶
Usage¶
Fires before any database record is saved. This includes both insert and update operations.
Since this hook fires after the record is saved, the record ID will not be available, but changes made to any other record properties will be saved.
Arguments¶
- Omeka_Record_AbstractRecord record
- The record being edited
- array or false post
- The post data, or false if none
- boolean insert
- Whether the record is being inserted
Examples¶
config¶
Usage¶
This hook processes posted data from the configuration form created by the config_form hook. Most use cases will involve setting configuration options to the database using set_option().
Both the config and config_form hooks must be used to creating a configuration form for a plugin.
Arguments¶
- array post
- The post data
Examples¶
class SimplePagesPlugin extends Omeka_Plugin_AbstractPlugin
{
protected $_hooks = array('config');
/**
* Set the options from the config form input.
*/
function hookConfig()
{
set_option('simple_pages_filter_page', (int)(boolean)$_POST['simple_pages_filter_page']);
}
}
config_form¶
Usage¶
This hook runs when the ‘Configure’ button is clicked for a specific plugin on the admin plugins panel.
Plugins use this hook to directly output the HTML that goes inside the <form> tag for the configuration form.
The config hook is used to process the submitted data from the form that was created with this hook.
Arguments¶
None
Examples¶
class SimplePagesPlugin extends Omeka_Plugin_AbstractPlugin
{
protected $_hooks = array('config_form');
/**
* Display the plugin config form.
*/
function hookConfigForm()
{
require dirname(__FILE__) . '/config_form.php';
}
}
define_acl¶
Usage¶
This hook runs when Omeka’s ACL is instantiated. It allows plugin writers to manipulate the ACL that controls user access in Omeka.
In general, plugins use this hook to restrict and/or allow access for specific user roles to the pages that it creates.
Arguments¶
- array acl
- The Zend_Acl object
Examples¶
class SimplePagesPlugin extends Omeka_Plugin_AbstractPlugin
{
protected $_hooks = array('define_acl');
function hookDefineAcl($args)
{
$acl = $args['acl'];
$indexResource = new Zend_Acl_Resource('SimplePages_Index');
$pageResource = new Zend_Acl_Resource('SimplePages_Page');
$acl->add($indexResource);
$acl->add($pageResource);
$acl->allow(array('super', 'admin'), array('SimplePages_Index', 'SimplePages_Page'));
$acl->allow(null, 'SimplePages_Page', 'show');
$acl->deny(null, 'SimplePages_Page', 'show-unpublished');
}
}
define_routes¶
Usage¶
This hook allows the plugin writer to add routes to Omeka.
Routes can be used to create custom URLs that are different than the default ones provided by Omeka for plugin pages.
Arguments¶
Zend_Controller_Router_Rewrite router
Examples¶
class SimplePagesPlugin extends Omeka_Plugin_AbstractPlugin
{
protected $_hooks = array('define_routes');
function hookDefineRoutes($args)
{
// Don't add these routes on the admin side to avoid conflicts.
if (is_admin()) {
return;
}
$router = $args['router'];
// Add custom routes based on the page slug.
$pages = get_db()->getTable('SimplePagesPage')->findAll();
foreach ($pages as $page) {
$router->addRoute(
'simple_pages_show_page_' . $page->id,
new Zend_Controller_Router_Route(
$page->slug,
array(
'module' => 'simple-pages',
'controller' => 'page',
'action' => 'show',
'id' => $page->id
)
)
);
}
}
}
See Also¶
/Tutorials/understandingRoutes
html_purifier_form_submission¶
Usage¶
Use this hook to run HTMLPurifier on submitted text. After purifying, reset the post data on the request object.
Arguments¶
- HTMLPurifier purifier
- The HTMLPurifier object
Examples¶
class SimplePagesPlugin extends Omeka_Plugin_AbstractPlugin
{
protected $_hooks = array('html_purifier_form_submission');
/**
* Filter the 'text' field of the simple-pages form, but only if the
* 'simple_pages_filter_page' setting has been enabled from within the
* configuration form.
*
* @param array $args Hook args, contains:
* 'request': Zend_Controller_Request_Http
* 'purifier': HTMLPurifier
*/
function hookHtmlPurifierFormSubmission($args)
{
$request = Zend_Controller_Front::getInstance()->getRequest();
$purifier = $args['purifier'];
// If we aren't editing or adding a page in SimplePages, don't do anything.
if ($request->getModuleName() != 'simple-pages' or !in_array($request->getActionName(), array('edit', 'add'))) {
return;
}
// Do not filter HTML for the request unless this configuration directive is on.
if (!get_option('simple_pages_filter_page')) {
return;
}
$post = $request->getPost();
$post['text'] = $purifier->purify($post['text']);
$request->setPost($post);
}
}
initialize¶
Usage¶
This hook runs during every request on installed/activated plugins. It is primarily used to modify the runtime behavior of Omeka for every request and response.
Arguments¶
None
Examples¶
class SimplePagesPlugin extends Omeka_Plugin_AbstractPlugin
{
protected $_hooks = array('initialize');
function hookInitialize()
{
add_translation_source(dirname(__FILE__) . '/languages');
}
}
install¶
Usage¶
This hook is primarily used to set options to the database and create tables, and any other initial actions required for your plugin to function, such as initial records or setting options.
Arguments¶
- integer plugin_id
- The id of the plugin
Examples¶
class SimplePagesPlugin extends Omeka_Plugin_AbstractPlugin
{
protected $_hooks = array('install');
protected $_options = array('simple_pages_filter_page' => '0');
function hookInstall()
{
// Create the table.
$db = get_db();
$sql = "
CREATE TABLE IF NOT EXISTS `$db->SimplePagesPage` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`modified_by_user_id` int(10) unsigned NOT NULL,
`created_by_user_id` int(10) unsigned NOT NULL,
`is_published` tinyint(1) NOT NULL,
`title` tinytext COLLATE utf8_unicode_ci NOT NULL,
`slug` tinytext COLLATE utf8_unicode_ci NOT NULL,
`text` text COLLATE utf8_unicode_ci,
`updated` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`inserted` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
`order` int(10) unsigned NOT NULL,
`parent_id` int(10) unsigned NOT NULL,
`template` tinytext COLLATE utf8_unicode_ci NOT NULL,
`use_tiny_mce` tinyint(1) NOT NULL,
PRIMARY KEY (`id`),
KEY `is_published` (`is_published`),
KEY `inserted` (`inserted`),
KEY `updated` (`updated`),
KEY `created_by_user_id` (`created_by_user_id`),
KEY `modified_by_user_id` (`modified_by_user_id`),
KEY `order` (`order`),
KEY `parent_id` (`parent_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci";
$db->query($sql);
// Save an example page.
$page = new SimplePagesPage;
$page->modified_by_user_id = current_user()->id;
$page->created_by_user_id = current_user()->id;
$page->is_published = 1;
$page->parent_id = 0;
$page->title = 'About';
$page->slug = 'about';
$page->text = '<p>This is an example page. Feel free to replace this content, or delete the page and start from scratch.</p>';
$page->save();
$this->_installOptions();
}
}
items_batch_edit_custom¶
Usage¶
Handles custom content added to the batch edit form by plugins using the admin_items_batch_edit_form hook.
The hook fires once for each item being edited.
Arguments¶
- Item item
- The Item currently being edited.
- mixed custom
- The “custom” data from the batch edit form.
Examples¶
See Also¶
make_<model>_featured¶
Usage¶
For models that use the Mixin_PublicFeatured, performs actions after the record is made featured.
Fires after the record is saved.
Arguments¶
- Omeka_Record_AbstractRecord record
- The record being edited
Examples¶
make_<model>_not_featured¶
Usage¶
For models that use the Mixin_PublicFeatured, performs actions after the record is made not featured.
Fires after the record is saved.
Arguments¶
- Omeka_Record_AbstractRecord record
- The record being edited
Examples¶
make_<model>_not_public¶
Usage¶
For models that use the Mixin_PublicFeatured, performs actions after the record is made not public.
Fires after the record is saved.
Arguments¶
- Omeka_Record_AbstractRecord record
- The record being edited
Examples¶
make_<model>_public¶
Usage¶
For models that use the Mixin_PublicFeatured, performs actions after the record is made public.
Fires after the record is saved.
Arguments¶
- Omeka_Record_AbstractRecord record
- The record being edited
Examples¶
public_body¶
Usage¶
Allows plugins to hook in to the top of the <body> of public themes. Content added with this hook will appear at the very top of the <body>, outside any other markup on the page.
Arguments¶
- Omeka_View view
- The view object
Examples¶
public_collections_browse¶
Usage¶
Append content at the end of the collections browse page.
Arguments¶
- Omeka_View view
- The view object
- array collections
- The array of Collection objects
Examples¶
public_collections_browse_each¶
Usage¶
Adds content at the end of each collection on the public collections browse page, before the link to the collection.
Arguments¶
- Omeka_View view
- The view object
- Colllection collection
- The current collection
Examples¶
public_collections_show¶
Usage¶
Append content to the end of a collections show page.
Arguments¶
- Omeka_View view
- The view object
- Collection collection
- The collection object
Examples¶
public_content_top¶
Usage¶
Inserts content at the top of the page.
Arguments¶
- Omeka_View view
- The view object
Examples¶
public_head¶
Usage¶
Adds content to the <head> element. Usually used to add javascript and/or css via the queue_js or queue_css functions
Arguments¶
- Omeka_View view
- The view object
Examples¶
class MyPlugin extends Omeka_Plugin_Abstract
{
protected $_hooks = array('public_head');
public function hookPublicHead($args)
{
queue_css('myplugin'); // assumes myplugin has a /views/public/css/myplugin.css file
}
}
See Also¶
queue_css queue_js
public_header¶
Usage¶
Adds content at the beginning of the <header> element, before the header image.
Arguments¶
- Omeka_View view
- The view object
Examples¶
public_home¶
Usage¶
Add content at the end of the home page
Arguments¶
- Omeka_View view
- The view object
Examples¶
public_items_browse¶
Usage¶
Append content to the items browse page
Arguments¶
- Omeka_View view
- The view object
- array items
- The array of Item objects
Examples¶
public_items_browse_each¶
Usage¶
Append content to each item in the items browse page.
Arguments¶
- Omeka_View view
- The view object
- Item item
- The current item object
Examples¶
public_items_search¶
Usage¶
Use this hook to add form elements to the advanced search form.
Additional fields should be wrapped with <div class="field">.
Arguments¶
- Omeka_View view
- The view object
Examples¶
public_items_show¶
Usage¶
Add content to the items show page
Arguments¶
- Omeka_View view
- The view object
- Item item
- The current item object
Examples¶
remove_<model>_tag¶
Usage¶
Fires when tags are removed from a record of type <model>
Arguments¶
- Omeka_Record_AbstractRecord record
- The record tags are being removed from.
- array added
- Array of tags removed
Examples¶
search_sql¶
Usage¶
Modifies the SQL query used.
This hook can be used when a custom search strategy is added using the search_query_types filter.
Arguments¶
- Omeka_Db_Select select
- The select object to modify
- array params
- Array of parameters to modify the search.
Examples¶
uninstall¶
Usage¶
Runs when a plugin is uninstalled to remove database tables, settings, etc.
Arguments¶
None
Examples¶
class SimplePagesPlugin extends Omeka_Plugin_AbstractPlugin
{
protected $_hooks = array('uninstall');
function hookUninstall()
{
// Drop the table.
$db = get_db();
$sql = "DROP TABLE IF EXISTS `$db->SimplePagesPage`";
$db->query($sql);
$this->_uninstallOptions();
}
}
uninstall_message¶
Usage¶
Add a message for when administrators deactivate your plugin.
It will be translated if your plugin provides a translation.
Arguments¶
None
Examples¶
upgrade¶
Usage¶
When Omeka detects that a user has installed a new version of the plugin, it automatically deactivates the plugin and presents an “Upgrade” button. This hook runs when a superuser clicks the “Upgrade” button. It is primarily used to migrate database tables and other data stored by older versions of the plugin.
Arguments¶
- string old_version
- The previous version that was installed and is being upgraded from.
- string new_version
- The new, current version of the plugin.
Examples¶
users_form¶
Usage¶
Adds content to the user form.
Note
If you are looking up any information about the user, wrap the operations in an if statement like so:
if($user->id) {
//your operations and output
}
This is necessary because the admin view of users includes a form to add a user, which includes a new User object. Because it is new, it does not yet exist in the database. The result is that if your plugin tries to do any operations on it, it throws a database error. Checking for $user->id ensures that the user exists in the database first.
Arguments¶
- User user
- The user object
- Omeka_Form form
- The form to modify
Examples¶
Application¶
config¶
Usage¶
This hook processes posted data from the configuration form created by the config_form hook. Most use cases will involve setting configuration options to the database using set_option().
Both the config and config_form hooks must be used to creating a configuration form for a plugin.
Arguments¶
- array post
- The post data
Examples¶
class SimplePagesPlugin extends Omeka_Plugin_AbstractPlugin
{
protected $_hooks = array('config');
/**
* Set the options from the config form input.
*/
function hookConfig()
{
set_option('simple_pages_filter_page', (int)(boolean)$_POST['simple_pages_filter_page']);
}
}
config_form¶
Usage¶
This hook runs when the ‘Configure’ button is clicked for a specific plugin on the admin plugins panel.
Plugins use this hook to directly output the HTML that goes inside the <form> tag for the configuration form.
The config hook is used to process the submitted data from the form that was created with this hook.
Arguments¶
None
Examples¶
class SimplePagesPlugin extends Omeka_Plugin_AbstractPlugin
{
protected $_hooks = array('config_form');
/**
* Display the plugin config form.
*/
function hookConfigForm()
{
require dirname(__FILE__) . '/config_form.php';
}
}
install¶
Usage¶
This hook is primarily used to set options to the database and create tables, and any other initial actions required for your plugin to function, such as initial records or setting options.
Arguments¶
- integer plugin_id
- The id of the plugin
Examples¶
class SimplePagesPlugin extends Omeka_Plugin_AbstractPlugin
{
protected $_hooks = array('install');
protected $_options = array('simple_pages_filter_page' => '0');
function hookInstall()
{
// Create the table.
$db = get_db();
$sql = "
CREATE TABLE IF NOT EXISTS `$db->SimplePagesPage` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`modified_by_user_id` int(10) unsigned NOT NULL,
`created_by_user_id` int(10) unsigned NOT NULL,
`is_published` tinyint(1) NOT NULL,
`title` tinytext COLLATE utf8_unicode_ci NOT NULL,
`slug` tinytext COLLATE utf8_unicode_ci NOT NULL,
`text` text COLLATE utf8_unicode_ci,
`updated` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`inserted` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
`order` int(10) unsigned NOT NULL,
`parent_id` int(10) unsigned NOT NULL,
`template` tinytext COLLATE utf8_unicode_ci NOT NULL,
`use_tiny_mce` tinyint(1) NOT NULL,
PRIMARY KEY (`id`),
KEY `is_published` (`is_published`),
KEY `inserted` (`inserted`),
KEY `updated` (`updated`),
KEY `created_by_user_id` (`created_by_user_id`),
KEY `modified_by_user_id` (`modified_by_user_id`),
KEY `order` (`order`),
KEY `parent_id` (`parent_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci";
$db->query($sql);
// Save an example page.
$page = new SimplePagesPage;
$page->modified_by_user_id = current_user()->id;
$page->created_by_user_id = current_user()->id;
$page->is_published = 1;
$page->parent_id = 0;
$page->title = 'About';
$page->slug = 'about';
$page->text = '<p>This is an example page. Feel free to replace this content, or delete the page and start from scratch.</p>';
$page->save();
$this->_installOptions();
}
}
initialize¶
Usage¶
This hook runs during every request on installed/activated plugins. It is primarily used to modify the runtime behavior of Omeka for every request and response.
Arguments¶
None
Examples¶
class SimplePagesPlugin extends Omeka_Plugin_AbstractPlugin
{
protected $_hooks = array('initialize');
function hookInitialize()
{
add_translation_source(dirname(__FILE__) . '/languages');
}
}
define_acl¶
Usage¶
This hook runs when Omeka’s ACL is instantiated. It allows plugin writers to manipulate the ACL that controls user access in Omeka.
In general, plugins use this hook to restrict and/or allow access for specific user roles to the pages that it creates.
Arguments¶
- array acl
- The Zend_Acl object
Examples¶
class SimplePagesPlugin extends Omeka_Plugin_AbstractPlugin
{
protected $_hooks = array('define_acl');
function hookDefineAcl($args)
{
$acl = $args['acl'];
$indexResource = new Zend_Acl_Resource('SimplePages_Index');
$pageResource = new Zend_Acl_Resource('SimplePages_Page');
$acl->add($indexResource);
$acl->add($pageResource);
$acl->allow(array('super', 'admin'), array('SimplePages_Index', 'SimplePages_Page'));
$acl->allow(null, 'SimplePages_Page', 'show');
$acl->deny(null, 'SimplePages_Page', 'show-unpublished');
}
}
define_routes¶
Usage¶
This hook allows the plugin writer to add routes to Omeka.
Routes can be used to create custom URLs that are different than the default ones provided by Omeka for plugin pages.
Arguments¶
Zend_Controller_Router_Rewrite router
Examples¶
class SimplePagesPlugin extends Omeka_Plugin_AbstractPlugin
{
protected $_hooks = array('define_routes');
function hookDefineRoutes($args)
{
// Don't add these routes on the admin side to avoid conflicts.
if (is_admin()) {
return;
}
$router = $args['router'];
// Add custom routes based on the page slug.
$pages = get_db()->getTable('SimplePagesPage')->findAll();
foreach ($pages as $page) {
$router->addRoute(
'simple_pages_show_page_' . $page->id,
new Zend_Controller_Router_Route(
$page->slug,
array(
'module' => 'simple-pages',
'controller' => 'page',
'action' => 'show',
'id' => $page->id
)
)
);
}
}
}
See Also¶
/Tutorials/understandingRoutes
uninstall¶
Usage¶
Runs when a plugin is uninstalled to remove database tables, settings, etc.
Arguments¶
None
Examples¶
class SimplePagesPlugin extends Omeka_Plugin_AbstractPlugin
{
protected $_hooks = array('uninstall');
function hookUninstall()
{
// Drop the table.
$db = get_db();
$sql = "DROP TABLE IF EXISTS `$db->SimplePagesPage`";
$db->query($sql);
$this->_uninstallOptions();
}
}
upgrade¶
Usage¶
When Omeka detects that a user has installed a new version of the plugin, it automatically deactivates the plugin and presents an “Upgrade” button. This hook runs when a superuser clicks the “Upgrade” button. It is primarily used to migrate database tables and other data stored by older versions of the plugin.
Arguments¶
- string old_version
- The previous version that was installed and is being upgraded from.
- string new_version
- The new, current version of the plugin.
Examples¶
Database¶
<model>_browse_sql¶
Usage¶
Alters the Omeka_Db_Select object when finding records of type <model> using the Omeke_Db_Table::findBy method.
<model> should be the plural name of the model, e.g. items_browse_sql
Arguments¶
- Omeka_Db_Select select
- The select object
- array params
- The parameters being used to build the select object
Examples¶
add_<model>_tag¶
Usage¶
Fires when tags are added to a record of type <model>
Arguments¶
- Omeka_Record_AbstractRecord record
- The record tags are being added to.
- array added
- Array of tags added
Examples¶
after_ingest_file¶
Usage¶
Fires after a file is ingested, but before it is added to the item.
Examples¶
make_<model>_featured¶
Usage¶
For models that use the Mixin_PublicFeatured, performs actions after the record is made featured.
Fires after the record is saved.
Arguments¶
- Omeka_Record_AbstractRecord record
- The record being edited
Examples¶
make_<model>_not_featured¶
Usage¶
For models that use the Mixin_PublicFeatured, performs actions after the record is made not featured.
Fires after the record is saved.
Arguments¶
- Omeka_Record_AbstractRecord record
- The record being edited
Examples¶
make_<model>_not_public¶
Usage¶
For models that use the Mixin_PublicFeatured, performs actions after the record is made not public.
Fires after the record is saved.
Arguments¶
- Omeka_Record_AbstractRecord record
- The record being edited
Examples¶
make_<model>_public¶
Usage¶
For models that use the Mixin_PublicFeatured, performs actions after the record is made public.
Fires after the record is saved.
Arguments¶
- Omeka_Record_AbstractRecord record
- The record being edited
Examples¶
remove_<model>_tag¶
Usage¶
Fires when tags are removed from a record of type <model>
Arguments¶
- Omeka_Record_AbstractRecord record
- The record tags are being removed from.
- array added
- Array of tags removed
Examples¶
Records¶
<model>_browse_sql¶
Usage¶
Alters the Omeka_Db_Select object when finding records of type <model> using the Omeke_Db_Table::findBy method.
<model> should be the plural name of the model, e.g. items_browse_sql
Arguments¶
- Omeka_Db_Select select
- The select object
- array params
- The parameters being used to build the select object
Examples¶
add_<model>_tag¶
Usage¶
Fires when tags are added to a record of type <model>
Arguments¶
- Omeka_Record_AbstractRecord record
- The record tags are being added to.
- array added
- Array of tags added
Examples¶
after_delete_<model>¶
Usage¶
Fires after any database model of type <model> is deleted.
Arguments¶
- Omeka_Record_AbstractRecord record
- The record being edited
Examples¶
after_save_<model>¶
Usage¶
Fires after a database record of type <model> is saved.
The id is available, but changes made to the record will not be saved.
Arguments¶
- Omeka_Record_AbstractRecord record
- The record being edited
- array or false post
- The post data, or false if none
- boolean insert
- Whether the record is being inserted
Examples¶
before_delete_<model>¶
Usage¶
Fires before any database record of type <model> is deleted.
Arguments¶
- Omeka_Record_AbstractRecord record
- The record being edited
Examples¶
before_save_<model>¶
Usage¶
Fires before any database record of type <model> is saved. This includes both insert and update operations.
Since this hook fires before the record is saved, the record ID will not be available, but changes made to any other record properties will be saved.
Arguments¶
- Omeka_Record_AbstractRecord record
- The record being edited
- array or false post
- The post data, or false if none
- boolean insert
- Whether the record is being inserted
Examples¶
make_<model>_featured¶
Usage¶
For models that use the Mixin_PublicFeatured, performs actions after the record is made featured.
Fires after the record is saved.
Arguments¶
- Omeka_Record_AbstractRecord record
- The record being edited
Examples¶
make_<model>_not_featured¶
Usage¶
For models that use the Mixin_PublicFeatured, performs actions after the record is made not featured.
Fires after the record is saved.
Arguments¶
- Omeka_Record_AbstractRecord record
- The record being edited
Examples¶
make_<model>_not_public¶
Usage¶
For models that use the Mixin_PublicFeatured, performs actions after the record is made not public.
Fires after the record is saved.
Arguments¶
- Omeka_Record_AbstractRecord record
- The record being edited
Examples¶
make_<model>_public¶
Usage¶
For models that use the Mixin_PublicFeatured, performs actions after the record is made public.
Fires after the record is saved.
Arguments¶
- Omeka_Record_AbstractRecord record
- The record being edited
Examples¶
remove_<model>_tag¶
Usage¶
Fires when tags are removed from a record of type <model>
Arguments¶
- Omeka_Record_AbstractRecord record
- The record tags are being removed from.
- array added
- Array of tags removed
Examples¶
after_delete_record¶
Usage¶
Fires after any database model is deleted.
Arguments¶
- Omeka_Record_AbstractRecord record
- The record being edited
Examples¶
after_save_record¶
Usage¶
Fires after any database record is saved. This includes both insert and update operations.
Since this hook fires after the record is saved, the record ID will be available, but changes made to any other record properties will not be saved.
Arguments¶
- Omeka_Record_AbstractRecord record
- The record being edited
- array or false post
- The post data, or false if none
- boolean insert
- Whether the record is being inserted
Examples¶
before_delete_record¶
Usage¶
Fires before any database record is deleted.
Arguments¶
- Omeka_Record_AbstractRecord record
- The record being edited
Examples¶
before_save_record¶
Usage¶
Fires before any database record is saved. This includes both insert and update operations.
Since this hook fires after the record is saved, the record ID will not be available, but changes made to any other record properties will be saved.
Arguments¶
- Omeka_Record_AbstractRecord record
- The record being edited
- array or false post
- The post data, or false if none
- boolean insert
- Whether the record is being inserted
Examples¶
Item Records¶
admin_item_types_browse¶
- array item_types
- The array of :php:class:`ItemType`s objects
- Omeka_View view
- The view object
admin_item_types_form¶
Add content to the admin item type edit form
- ItemType item_type
- The item type object
- Omeka_View view
- The view object
admin_item_types_show¶
Add content to the item types show page
- ItemType item_type
- The item type object
- Omeka_View view
- The view object
admin_items_batch_edit_form¶
Appends content to the end of the batch editing screen, but before the delete option.
If adding form elements, name them “custom”
See Understanding the Admin Css for details on CSS styling
- Omeka_View view
- The view object
admin_items_browse¶
Append content to the admin items browse page
- array items
- Array of :php:class:`Item`s
- Omeka_View view
- The view object
admin_items_browse_detailed_each¶
Append content to the details view of an item on the items browse page
- Item item
- The item object
- Omeka_View view
- The view object
public function hookAdminItemsBrowseDetailedEach($args)
{
$item = $args['item'];
$embedTable = get_db()->getTable('Embed');
$totalEmbeds = $embedTable->totalEmbeds($item->id);
$html = '<p>';
$html .= "<a href='" . url('embed-codes/item/' . $item->id) . "'>" . __('Embeds (%d)', $totalEmbeds) . "</a>";
$html .= '</p>';
echo $html;
}
admin_items_browse_simple_each¶
Adds content to each item’s row on the items browse page.
- Item item
- The item object
- Omeka_View view
- The view object
admin_items_form_files¶
Append content to the “Files” part of the item form.
To work with the files themselves, get the $item from the $args array and look at $item->Files
- Item item
- The item object
- Omeka_View view
- The view object
admin_items_form_tags¶
Add content to the tags form for an item.
To work with the tags themselves, get the $item from the $args array and do $item->getTags()
- Item item
- The item object
- Omeka_View view
- The view object
admin_items_search¶
Append form elements to the advanced search area.
Note
If your plugin adds searchable models, checkboxes for including them in your search are controlled by the site administrator.
- Omeka_View view
- The view object
admin_items_show¶
Append content to the main item show area
- Item item
- The item object
- Omeka_View view
- The view object
admin_items_show_sidebar¶
Append content to the sidebar panels on the items show page.
Content should be wrapped in <div class="panel">
Note
To add content to the save panel, use admin_items_panel_buttons or admin_items_panel_fields.
- Item item
- The item object
- Omeka_View view
- The view object
items_batch_edit_custom¶
Handles custom content added to the batch edit form by plugins using the admin_items_batch_edit_form hook.
The hook fires once for each item being edited.
- Item item
- The Item currently being edited.
- mixed custom
- The “custom” data from the batch edit form.
public_items_browse¶
Append content to the items browse page
- Omeka_View view
- The view object
- array items
- The array of Item objects
public_items_browse_each¶
Append content to each item in the items browse page.
- Omeka_View view
- The view object
- Item item
- The current item object
public_items_search¶
Use this hook to add form elements to the advanced search form.
Additional fields should be wrapped with <div class="field">.
- Omeka_View view
- The view object
Collection Records¶
admin_collections_browse¶
- array collection
- Array of :php:class:`Collection`s
- Omeka_View view
- The view object
admin_collections_form¶
Append to the form for the collection being edited. Content appears underneath the tabs
- Omeka_View view
- The view object
- Collection collection
- The collection being edited
admin_collections_show¶
Append content to the admin collection show page.
- Collection collection
- The collection
- Omeka_View view
- The view object
public_collections_browse¶
Append content at the end of the collections browse page.
- Omeka_View view
- The view object
- array collections
- The array of Collection objects
public_collections_browse_each¶
Adds content at the end of each collection on the public collections browse page, before the link to the collection.
- Omeka_View view
- The view object
- Colllection collection
- The current collection
public_collections_show¶
Append content to the end of a collections show page.
- Omeka_View view
- The view object
- Collection collection
- The collection object
Users¶
users_form¶
Usage¶
Adds content to the user form.
Note
If you are looking up any information about the user, wrap the operations in an if statement like so:
if($user->id) {
//your operations and output
}
This is necessary because the admin view of users includes a form to add a user, which includes a new User object. Because it is new, it does not yet exist in the database. The result is that if your plugin tries to do any operations on it, it throws a database error. Checking for $user->id ensures that the user exists in the database first.
Arguments¶
- User user
- The user object
- Omeka_Form form
- The form to modify
Examples¶
Admin Theme¶
admin_<type>_form¶
Usage¶
Add form elements to a form created via Omeka_Form_Admin
Arguments¶
- Omeka_Form_Admin form
- The form object
- Omeka_Record_AbstractRecord | null record
- The record being edited, if it is included in the form
admin_<type>_panel_buttons¶
Usage¶
Append content just below the save panel buttons when editing using the Omeka_Form_Admin. Often <type> will be a model type.
Arguments¶
- Omeka_View view
- The view object
- :php:class:`Omeka_Record_AbstractRecord`|null record
- The record being edited, if a record was passed in when creating the form. Otherwise, null.
Examples¶
admin_<type>_panel_fields¶
Usage¶
Append content just below the save panel fields when editing using the Omeka_Form_Admin. Often <type> will be a model type.
Arguments¶
- :php:class:`Omeka_Record_AbstractRecord`|null record
- The record being edited, if one was passed in when the form was created. Otherwise, null
- Omeka_View view
- The view object
Examples¶
admin_appearance_settings_form¶
Usage¶
Arguments¶
- Omeka_Form form
- The form object
- Omeka_View view
- The view object
Examples¶
admin_collections_browse¶
Usage¶
Arguments¶
- array collection
- Array of :php:class:`Collection`s
- Omeka_View view
- The view object
Examples¶
admin_collections_form¶
Usage¶
Append to the form for the collection being edited. Content appears underneath the tabs
Arguments¶
- Omeka_View view
- The view object
- Collection collection
- The collection being edited
Examples¶
admin_collections_show¶
Usage¶
Append content to the admin collection show page.
Arguments¶
- Collection collection
- The collection
- Omeka_View view
- The view object
Examples¶
admin_files_form¶
Usage¶
Append content to the main area of a file edit page.
Arguments¶
- File file
- The file object
- Omeka_View view
- The view object
Examples¶
admin_files_show¶
Usage¶
Append content to the main area of a file show page.
Arguments¶
- File file
- The file object
- Omeka_View view
- The view object
Examples¶
admin_file_show_sidebar¶
Usage¶
Append content to the info panels area of a file show page.
Note
To add content to the save panel, use admin_files_panel_buttons or admin_files_panel_fields.
Arguments¶
- File file
- The file object
- Omeka_View view
- The view object
Examples¶
admin_form_files¶
Usage¶
Append content to the “Files” part of the item form.
To work with the files themselves, get the $item from the $args array and look at $item->Files
Arguments¶
- Item item
- The item object
- Omeka_View view
- The view object
Examples¶
admin_general_settings_form¶
Usage¶
Manipulate the form for admin general settings.
Arguments¶
- Omeka_Form form
- The form
Examples¶
admin_head¶
Usage¶
Adds content to the header of the admin theme.
This hook is fired by the header.php script, which is loaded by a call to head() while it is populating the <head> tag for the admin theme.
Functions attaching to this hook can directly output HTML into the <head>, or use functions like queue_css and queue_js.
Plugins will likely not need to add content to the admin-side <head> for every page, but the passed request object can be used to include content on particular pages only.
Arguments¶
- Omeka_View view
- The view object
Examples¶
admin_item_types_browse¶
Usage¶
Arguments¶
- array item_types
- The array of :php:class:`ItemType`s objects
- Omeka_View view
- The view object
Examples¶
admin_item_types_form¶
Usage¶
Add content to the admin item type edit form
Arguments¶
- ItemType item_type
- The item type object
- Omeka_View view
- The view object
Examples¶
admin_item_types_show¶
Usage¶
Add content to the item types show page
Arguments¶
- ItemType item_type
- The item type object
- Omeka_View view
- The view object
Examples¶
admin_items_batch_edit_form¶
Usage¶
Appends content to the end of the batch editing screen, but before the delete option.
If adding form elements, name them “custom”
See Understanding the Admin Css for details on CSS styling
Arguments¶
- Omeka_View view
- The view object
Examples¶
See Also¶
admin_items_browse¶
Usage¶
Append content to the admin items browse page
Arguments¶
- array items
- Array of :php:class:`Item`s
- Omeka_View view
- The view object
Examples¶
admin_items_browse_detailed_each¶
Usage¶
Append content to the details view of an item on the items browse page
Arguments¶
- Item item
- The item object
- Omeka_View view
- The view object
Examples¶
public function hookAdminItemsBrowseDetailedEach($args)
{
$item = $args['item'];
$embedTable = get_db()->getTable('Embed');
$totalEmbeds = $embedTable->totalEmbeds($item->id);
$html = '<p>';
$html .= "<a href='" . url('embed-codes/item/' . $item->id) . "'>" . __('Embeds (%d)', $totalEmbeds) . "</a>";
$html .= '</p>';
echo $html;
}
admin_items_browse_simple_each¶
Usage¶
Adds content to each item’s row on the items browse page.
Arguments¶
- Item item
- The item object
- Omeka_View view
- The view object
Examples¶
admin_items_form_files¶
Append content to the “Files” part of the item form.
To work with the files themselves, get the $item from the $args array and look at $item->Files
Arguments¶
- Item item
- The item object
- Omeka_View view
- The view object
Examples¶
admin_items_form_tags¶
Usage¶
Add content to the tags form for an item.
To work with the tags themselves, get the $item from the $args array and do $item->getTags()
Arguments¶
- Item item
- The item object
- Omeka_View view
- The view object
Examples¶
admin_items_search¶
Usage¶
Append form elements to the advanced search area.
Note
If your plugin adds searchable models, checkboxes for including them in your search are controlled by the site administrator.
Arguments¶
- Omeka_View view
- The view object
Examples¶
admin_items_show¶
Usage¶
Append content to the main item show area
Arguments¶
- Item item
- The item object
- Omeka_View view
- The view object
Examples¶
admin_items_show_sidebar¶
Usage¶
Append content to the sidebar panels on the items show page.
Content should be wrapped in <div class="panel">
Note
To add content to the save panel, use admin_items_panel_buttons or admin_items_panel_fields.
Arguments¶
- Item item
- The item object
- Omeka_View view
- The view object
Examples¶
Public Theme¶
public_body¶
Usage¶
Allows plugins to hook in to the top of the <body> of public themes. Content added with this hook will appear at the very top of the <body>, outside any other markup on the page.
Arguments¶
- Omeka_View view
- The view object
Examples¶
public_collections_browse¶
Usage¶
Append content at the end of the collections browse page.
Arguments¶
- Omeka_View view
- The view object
- array collections
- The array of Collection objects
Examples¶
public_collections_browse_each¶
Usage¶
Adds content at the end of each collection on the public collections browse page, before the link to the collection.
Arguments¶
- Omeka_View view
- The view object
- Colllection collection
- The current collection
Examples¶
public_collections_show¶
Usage¶
Append content to the end of a collections show page.
Arguments¶
- Omeka_View view
- The view object
- Collection collection
- The collection object
Examples¶
public_content_top¶
Usage¶
Inserts content at the top of the page.
Arguments¶
- Omeka_View view
- The view object
Examples¶
public_head¶
Usage¶
Adds content to the <head> element. Usually used to add javascript and/or css via the queue_js or queue_css functions
Arguments¶
- Omeka_View view
- The view object
Examples¶
class MyPlugin extends Omeka_Plugin_Abstract
{
protected $_hooks = array('public_head');
public function hookPublicHead($args)
{
queue_css('myplugin'); // assumes myplugin has a /views/public/css/myplugin.css file
}
}
See Also¶
queue_css queue_js
public_header¶
Usage¶
Adds content at the beginning of the <header> element, before the header image.
Arguments¶
- Omeka_View view
- The view object
Examples¶
public_home¶
Usage¶
Add content at the end of the home page
Arguments¶
- Omeka_View view
- The view object
Examples¶
public_items_browse¶
Usage¶
Append content to the items browse page
Arguments¶
- Omeka_View view
- The view object
- array items
- The array of Item objects
Examples¶
public_items_browse_each¶
Usage¶
Append content to each item in the items browse page.
Arguments¶
- Omeka_View view
- The view object
- Item item
- The current item object
Examples¶
public_items_search¶
Usage¶
Use this hook to add form elements to the advanced search form.
Additional fields should be wrapped with <div class="field">.
Arguments¶
- Omeka_View view
- The view object
Examples¶
Filters¶
Using Filters¶
All Filters¶
<model>s_browse_params¶
Usage¶
Filters the parameters used when generating the browse page for records (the model)
Note
Use the plural form of the <model>
Value¶
array $params
Params passed to the browse query. May include both filtering and sorting parameters
Arguments¶
None
Examples¶
class MyPlugin extends Omeka_Plugin_AbstractPlugin
{
protected $_filters = array('items_browse_params');
public filterItemsBrowseParams($params)
{
//always sort by title instead of order
$params['sort_param'] = "Dublin Core,Title";
return $params;
}
}
<model>s_select_options¶
Usage¶
Filters the options for a select element for the <model>’s table. Useful if your plugin adds relations between the <model>’s table and another table.
Note
Use the plural form of the <model>
Value¶
- array $options
- Array of key-value pairs, where the key is usually a record ID and the value is determined by the model’s table
Arguments¶
None
ElementSetForm Filter¶
Usage¶
Filters the form to be used for an element set
The name of the filter is an array:
array('ElementSetForm', $recordType, $elementSet, $elementName);
- $recordType: The type of Omeka object to filter the metadata for. Most commonly, this will be ‘Item’.
- $elementSetName: The name of the element set containing the metadata field to be filtered. Possible values include ‘Dublin Core’ and ‘Item Type Metadata’.
- $elementName: The name of the specific element within the set to be filtered.
Arguments¶
- string recordType
- The type of record
- Omeka_Record_AbstractRecord record
- The record whose form is being filtered
- string elementSetName
- The name of the element set whose elements should be filtered
Examples¶
See Also¶
Element Display Filter¶
Usage¶
Alter the way an element is displayed.
The name of the filter is an array:
array('Display', $recordType, $elementSetName, $elementName);
- $recordType: The type of Omeka object to filter the metadata for. Most commonly, this will be ‘Item’.
- $elementSetName: The name of the element set containing the metadata field to be filtered. Possible values include ‘Dublin Core’ and ‘Item Type Metadata’.
- $elementName: The name of the specific element within the set to be filtered.
Value¶
- string $text
- The text to display.
Arguments¶
- Omeka_Record_AbstractRecord record
- The record being displayed
- ElementText element_text
- The ElementText object
Examples¶
class MyPlugin extends Omeka_Plugin_AbstractPlugin
{
protected $_filters = array('concealDescription' => array('Display', 'Item', 'Dublin Core', 'Description'));
public function concealDescription($text, $args)
{
//conceal the description to non-logged in users
if(!get_current_user()) {
return str_rot13($text);
}
return $text;
}
}
Element ElementForm Filter¶
Usage¶
Customize the form for a particular element. This only applies to forms generated by the element_form() helper function.
The name is an array:
array('ElementForm', $recordType, $elementSetName, $elementName);
- $recordType: The type of Omeka object to filter the metadata for. Most commonly, this will be ‘Item’.
- $elementSetName: The name of the element set containing the metadata field to be filtered. Possible values include ‘Dublin Core’ and ‘Item Type Metadata’.
- $elementName: The name of the specific element within the set to be filtered.
Value¶
array $components
The form components, like:
$components = array( 'label' => $labelComponent, 'inputs' => $inputsComponent, 'description' => $descriptionComponent, 'comment' => $commentComponent, 'add_input' => $addInputComponent, 'html' => null );
Arguments¶
Omeka_Record_AbstractRecord record
The model being edited.
Element element
The element being edited
array options
An array of additional options for the form
Examples¶
class MyPlugin extends Omeka_Plugin_AbstractPlugin
{
$_filters = array('relabelItemTitle' => array('ElementForm', 'Item', 'Dublin Core', 'Title'));
public function relabelItemTitle($components, $args)
{
$components['label'] = "Label";
return $components;
}
}
See Also¶
Element ElementInput Filter¶
Usage¶
Customize the input for a particular element. This only applies to forms generated by the element_form() helper function.
The name of the filter is an array:
array('ElementInput', $recordType, $elementSet, $elementName);
- $recordType: The type of Omeka object to filter the metadata for. Most commonly, this will be ‘Item’.
- $elementSetName: The name of the element set containing the metadata field to be filtered. Possible values include ‘Dublin Core’ and ‘Item Type Metadata’.
- $elementName: The name of the specific element within the set to be filtered.
Value¶
array $components
The input components, like:
$components = array( 'input' => $formTextarea, 'form_controls' => $removeButton, 'html_checkbox' => $useHtmlCheckbox, 'html' => null );
Arguments¶
string input_name_stem
The name of the input, e.g., Elements[1][0]
string value
The value for the input
Omeka_Record_AbstractRecord record
The model being edited
Element element
The element being edited
string index
The index of the input for the element
boolean is_html
Whether the input uses html
Examples¶
class MyPlugin extends Omeka_Plugin_AbstractPlugin
{
$_filters = array('shortenSubjectField', array('ElementInput', 'Item', 'Dublin Core', 'Title'));
public function shortenSubjectField($components, $args)
{
$components['input'] = get_view()->formText($args['input_name_stem'], $args['value']);
return $components;
}
}
Element Flatten Filter¶
Usage¶
‘Flatten’ the array of data for an element into the text to use.
The array looks like:
array('text' => 'The text', 'html'=>0);
Where the html key is a boolean for whether the element text uses HTML.
If no Element Flatten filters operate, the value of the text key is used.
This filter’s name is actually an array of strings. The first string must always be ‘Flatten’, but the last three can change depending on exactly what values you want to filter.
array('Flatten', $recordType, $elementSetName, $elementName)
- $recordType: The type of Omeka object to filter the metadata for.
- $elementSetName: The name of the element set containing the metadata field to be filtered. Possible values will include ‘Dublin Core’ and ‘Item Type Metadata’.
- $elementName: The name of the specific element within the set to be filtered.
Arguments¶
array post_array
The posted data, like array('text' => 'The text', 'html'=>0);
Element element
The element being saved.
Examples¶
$_filters = array('prependJulianToDate' => array('Flatten', 'Item', 'Dublin Core', 'Date'));
public function prependJulianToDate($flatText, $args)
{
$postArray = $args['post_array'];
$value = $postArray['text'];
return "Julian Calendar: $value";
}
See Also¶
ElementText::getTextStringFromFormPost
Element Save Filter¶
Usage¶
Customize element texts for a particular element before validating and saving a record. This is helpful if you want to prepare form data for validation automatically, limiting the possibility of a validation error.
array('Save', $recordType, $elementSetName, $elementName)
- $recordType: The type of Omeka object to filter the metadata for. Most commonly, this will be ‘Item’.
- $elementSetName: The name of the element set containing the metadata field to be filtered. Possible values include ‘Dublin Core’ and ‘Item Type Metadata’.
- $elementName: The name of the specific element within the set to be filtered.
Value¶
- string $text
- The original text for the element
Arguments¶
- Omeka_Record_AbstractRecord record
- The record that this text applies to. The type will be the same as the filter’s $recordType.
- Element element
- The Element record for this text.
Examples¶
class MyPlugin extends :php:class:`Omeka_Plugin_AbstractPlugin`
{
protected $_filters = array('addIsbnToDcId'=>array('Save', 'Item', 'Dublin Core', 'Identifier');
public function addIsbnToId($text, $args)
{
return "ISBN: $text";
}
}
Element Validation Filter¶
Usage¶
Perform a custom validation on the texts for any particular element.
This filter’s name is actually an array of strings. The first string must always be ‘Validate’, but the last three can change depending on exactly what values you want to validate.
array('Validate', $recordType, $elementSetName, $elementName)
- $recordType: The type of Omeka object to filter the metadata for.
- $elementSetName: The name of the element set containing the metadata field to be filtered. Possible values will include ‘Dublin Core’ and ‘Item Type Metadata’.
- $elementName: The name of the specific element within the set to be filtered.
Arguments¶
string text
The text for the element
Omeka_Record_AbstractRecord record
The record (subclass of Omeka_Record_AbstractRecord) being validated.
Element element
The element (e.g., Dublin Core Title) for the element text.
Examples¶
class MyPlugin extends Omeka_Plugin_AbstractPlugin
{
protected $_filters = array('itemTitleLengthValidator' => array('Validate', 'Item', 'Dublin Core', 'Title'));
public function itemTitleValidator($isValid, $args)
{
$text = $args['text'];
if(strlen($text) > 100) {
return false;
}
return true;
}
}
See Also¶
ElementText::_elementTextIsValid
action_contexts¶
Usage¶
Action contexts work in combination with response_contexts to output additiona formats, such as RSS or JSON.
Typically, you check whether the controller passed in the arguments is one defined by your plugin, then add your context (output format) to the array of values.
Then, response contexts you define direct Omeka to the views you have defined for the output.
Value¶
- array $contexts
- Array of the contexts available for a controller’s views.
Arguments¶
- Omeka_Controller_Action controller
- The controller that is producing the output.
`Zend_Controller_ActionHelper_ContextSwitch <http://framework.zend.com/manual/1.12/en/zend.controller.actionhelpers.html#zend.controller.actionhelpers.contextswitch> context_switch
Examples¶
Make an RSS feed of your records available at /my-records/browse?output=rss
class MyRecordController extends Omeka_Controller_AbstractActionController
{
//nothing to do here, since we don't need to override anything
}
class MyPlugin extends Omeka_Plugin_AbstractPlugin
{
protected $_filters = array('define_action_context');
public filterDefineActionContext($contexts, $args)
{
if($args['controller'] instanceof MyRecordController) {
$contexts['browse'][] = 'rss';
}
return $contexts;
}
}
See Also¶
admin_collections_form_tabs¶
Usage¶
Filter tabs used on the collections add/edit page
Value¶
- array $tabs
- The array of tabs. The key is the label for the tab, and the value is the html to display.
Arguments¶
- Collection collection
- The collection being edited
Examples¶
admin_dashboard_panels¶
Usage¶
Add a panel to the dashboard. HTML content is automatically wrapped in the appropriately styled <div>
Value¶
- array $panels
- Array of HTML content for each panel
Arguments¶
- Omeka_View view
- The current view object
Examples¶
admin_dashboard_stats¶
Usage¶
Add content to the stats row at the top of the dashboard
Value¶
- array $stats
- Array of links for the stats row
Arguments¶
- Omeka_View view
- The current view object
Examples¶
Original value looks like:
$stats = array(
array(link_to('items', null, total_records('Item')), __('items')),
array(link_to('collections', null, total_records('Collection')), __('collections')),
array(link_to('tags', null, total_records('Tag')), __('tags'))
);
admin_items_form_tabs¶
Usage¶
The admin_items_form_tabs filter allows you to add, remove, or modify the tabs on the edit item form.
Value¶
- array $tabs
- An array of the item form tabs. The keys are the tab names, and the values are the HTML content of each tab. A filter function should modify this array and return it.
Arguments¶
- Item item
- The Item being edited. Filter functions can use this parameter to change the tabs or content on an item-by-item basis.
Examples¶
class MyPlugin extends :php:class:`Omeka_Plugin_AbstractPlugin`
{
protected $_filters = array('admin_items_form_tabs');
public filterAdminItemsFormTabs($tabs, $args)
{
$item = $args['item'];
$tabs["My Plugin"] = uri('/my-plugin/edit/id/' . $item->id);
}
}
admin_theme_name¶
Usage¶
Filters the currently-selected admin theme. Changing the theme name through this filter will cause Omeka to use a different theme to display the admin interface.
Arguments¶
None
Examples¶
Force Omeka to use a different admin theme
public function filterAdminThemeName($theme_name)
{
return 'my-custom-admin-theme';
}
admin_whitelist¶
Usage¶
Allows admin controller views to be accessible without logging in
Value¶
array $whitelist
An array containing arrays of controller-view pairs that do not require logging in to access
Arguments¶
None
Examples¶
The default whitelist is:
array(
array('controller' => 'users', 'action' => 'activate'),
array('controller' => 'users', 'action' => 'login'),
array('controller' => 'users', 'action' => 'forgot-password'),
array('controller' => 'installer', 'action' => 'notify'),
array('controller' => 'error', 'action' => 'error')
);
To make your plugin’s admin page accessible without login
public function filterAdminWhitelist($whitelist)
{
$whitelist[] = array('controller' => 'my-controller' , 'action' => 'my-view');
return $whitelist;
api_extend_<resource>¶
Usage¶
Extends an existing resource registered with the API. If your plugin creates content related to items, for example, use this to add that data to an item’s representation. <resource> is the name of the resource, e.g. items
Arguments¶
Omeka_Record_AbstractRecord record
The record whose representation in the API you are extending
Examples¶
public function filterApiExtendItems($extend, $args)
{
$item = $args['record'];
$location = $this->_db->getTable('Location')->findBy(array('item_id' => $item->id));
if (!$location) {
return $extend;
}
$locationId = $location[0]['id'];
$extend['geolocations'] = array(
'id' => $locationId,
'url' => Omeka_Record_Api_AbstractRecordAdapter::getResourceUrl("/geolocations/$locationId"),
);
return $extend;
}
See also Extending the API
api_resources¶
Usage¶
Allows plugins to add their content to the Omeka API
Arguments¶
None
Examples¶
<?php
protected $_filters = array('api_resources');
public function filterApiResources($apiResources)
{
$apiResources['geolocations'] = array(
'record_type' => 'Location',
'actions' => array('get', 'index', 'post', 'put', 'delete'),
);
return $apiResources;
}
See also :doc:`/Reference/api/extending`
batch_edit_error¶
Usage¶
Add or alter the error message when batch editing
Value¶
- string $errorMessage
- The message to display
Arguments¶
- array metadata
- The array of metadata about the items to change
- array custom
- Array of custom data added by plugins
- array item_ids
- Array of item ids being edited
See Also¶
body_tag_attributes¶
Usage¶
Filters the tags applied to the <body> element of the page
Arguments¶
None
Examples¶
class MyPlugin extends Omeka_Plugin_AbstractPlugin
{
protected $_filters = array('body_tag_attributes');
public function filterBodyTagAttributes($attributes)
{
//add a class when users are logged in
if(current_user()) {
$attributes['class'] = trim("logged-in " . $attributes['class']);
}
return $attributes;
}
}
browse_plugins¶
Usage¶
Allows you to filter the list of plugins on the admin plugins browse page
Arguments¶
None
Examples¶
Remove plugins that do not meet minimum Omeka version unless current user is super
class MyPlugin extends :php:class:`Omeka_Plugin_AbstractPlugin`
{
protected $_filters = array('browse_plugins');
public filterBrowsePlugins($plugins)
{
$user = current_user();
if($user->getRole() != 'super') {
foreach($plugins as $key=>$plugin) {
if(!$plugin->meetsOmekaMinimumVersion()) {
unset($plugins[$key]);
}
}
}
return $plugins;
}
}
browse_themes¶
Usage¶
Allows you to filter the list of themes on the admin themes browse page
Arguments¶
None
Examples¶
Ignore themes without images
class MyPlugin extends :php:class:`Omeka_Plugin_AbstractPlugin`
{
protected $_filters = array('browse_themes');
public filterBrowseThemes($themes)
{
foreach($themes as $key=>$theme) {
if(empty($theme->image)) {
unset($themes['key'];
}
}
return $themes;
}
}
display_elements¶
Usage¶
Filters the element sets and elements when displayed via the all_element_texts function.
Value¶
- array $elementSets
- All the elements, keyed by element set.
Arguments¶
None
Examples¶
Get rid of everything except Dublin Core Title and Description
class MyPlugin extends :php:class:`Omeka_Plugin_AbstractPlugin`
{
protected $_filters = array('record_metadata_elements');
public filterRecordMetadataElements($elementSets)
{
foreach($elementSets as $set=>$elements) {
if($set == 'Dublin Core') {
foreach($elements as $key=>$element) {
if($element->name != 'Title' || $element->name != 'Description') {
unset($elementSets['Dublin Core'][$key];
}
}
}
}
return $elementSets;
}
}
display_option_*¶
Usage¶
This family of filters is used whenever the option theme function is called, to filter the value returned from the database before it is displayed.
The name of the particular filter that should be used is made by appending the name of the option to “display_option_”.
Examples¶
To print the site title, a theme writer would do the following:
<?php echo option('site_title'); ?>
If you want to prepend “Omeka: ” to the title of every printed page:
public function filterDisplayOptionSiteTitle($option)
{
return "Omeka: $option";
}
file_ingest_validators¶
Usage¶
Allows you to add or remove validators to be used when a file is uploaded.
Value¶
array $validators
A keyed array of validators to use. Validators are subclasses of Zend_Validate_Abstract.
Arguments¶
None
Examples¶
The default validators are:
array(
'extension whitelist'=> new Omeka_Validate_File_Extension,
'MIME type whitelist'=> new Omeka_Validate_File_MimeType
)
To swap out Omeka’s Mime Type validator for your own:
public function filterFileIngestValidators($validators)
{
unset($validators, 'MIME type whitelist');
$validators['my mime validator'] = new MyPlugin_Validate_File_MimeType;
return $validators;
}
file_markup¶
Usage¶
Filter the HTML for displaying a file
Value¶
- string $html
- The HTML for displaying the file
item_citation¶
Usage¶
Filters or replaces the default citation displayed for an item.
Examples¶
class MyPlugin extends Omeka_Plugin_AbstractPlugin {
protected $_filters = array(‘item_citation’);
public filterItemCitation($citation, $args) {
$citation = “”; return $citation;}
}
See Also¶
item_citation
item_search_filters¶
Usage¶
Use this filter in conjunction with the <model>_browse_sql hook to display what search filters are being applied to the item search.
If your plugin uses item_browse_sql to provide an additional filter when searching, you should use this filter to display the results.
Look through the request_array passed in the arguments for the key/value pair with key matching the additional filter you have created. Add the display value to the array as a new key/value pair, with the key being the name of your filter and the value being the text to display.
Value¶
- array $displayArray
- Array of filters for the search/browse page. Keys are possible $_GET parameters. Values are values being filtered.
Arguments¶
- array request_array
- Array of $_GET parameters
Examples¶
The MultiCollections plugin clobbers the core collection filtering message by checking if a multi-collection value is among the $_GET parameters and displaying the collection name.
public function filterItemSearchFilters($displayArray, $args)
{
$request_array = $args['request_array'];
if(isset($request_array['multi-collection'])) {
$db = get_db();
$collection = $db->getTable('Collection')->find($request_array['multi-collection']);
$displayValue = strip_formatting(metadata($collection, array('Dublin Core', 'Title')));
$displayArray['collection'] = $displayValue;
}
return $displayArray;
}
See Also¶
items_advanced_search_link_default_url¶
Usage¶
Changes the url to use for items/advanced-search
Value¶
- string $url
- The url for items advanced search
Arguments¶
None
Examples¶
locale¶
Usage¶
Set Omeka’s locale. Value must correspond to an existing *.mo file in Omeka’s translations directory
Value¶
- string locale
- The locale name
Arguments¶
None
login_adapter¶
Usage¶
The login adapter filter may be used to override the default way Omeka authenticates users, for example by checking against a different table.
Value¶
Omeka_Auth_Adapter_UserTable $authAdapter
The adapter to use for authenticating a user. You can return your own adapter if necessary for more complex authentication systems.
Arguments¶
Omeka_Form_Login login_form
The form to use for logging in. Can be replaced via the login_form filter.
Examples¶
login_form¶
Usage¶
Use this filter to modify or replace the default login form
Arguments¶
None
Examples¶
page_caching_blacklist¶
Usage¶
Arguments¶
- Omeka_Record_AbstractRecord record
- The record being saved
- string action
- The action taking place
Examples¶
class SimplePagesPlugin extends Omeka_Plugin_AbstractPlugin
{
protected $_filters = array('page_caching_blacklist');
/**
* Add pages to the blacklist
*
* @param $blacklist array An associative array urls to blacklist,
* where the key is a regular expression of relative urls to blacklist
* and the value is an array of Zend_Cache front end settings
* @param $record
* @param $args Filter arguments. contains:
* - record: the record
* - action: the action
* @return array The blacklist
*/
function filterPageCachingBlacklistForRecord($blacklist, $args)
{
$record = $args['record'];
$action = $args['action'];
if ($record instanceof SimplePagesPage) {
$page = $record;
if ($action == 'update' || $action == 'delete') {
$blacklist['/' . trim($page->slug, '/')] = array('cache'=>false);
}
}
return $blacklist;
}
}
page_caching_whitelist¶
Usage¶
Arguments¶
None
Examples¶
class SimplePagesPlugin extends Omeka_Plugin_AbstractPlugin
{
protected $_filters = array('page_caching_whitelist');
/**
* Specify the default list of urls to whitelist
*
* @param $whitelist array An associative array urls to whitelist,
* where the key is a regular expression of relative urls to whitelist
* and the value is an array of Zend_Cache front end settings
* @return array The whitelist
*/
function filterPageCachingWhitelist($whitelist)
{
// Add custom routes based on the page slug.
$pages = get_db()->getTable('SimplePagesPage')->findAll();
foreach($pages as $page) {
$whitelist['/' . trim($page->slug, '/')] = array('cache'=>true);
}
return $whitelist;
}
}
public_theme_name¶
Filters the currently-selected public theme. Changing the theme name through this filter will cause Omeka to use a different theme to display the public interface.
Arguments¶
None
Examples¶
Force Omeka to use a different public theme
public function filterPublicThemeName($theme_name)
{
return 'my-custom-admin-theme';
}
response_contexts¶
Usage¶
Filters the array of response contexts as passed to Zend Framework’s ContextSwitch helper.
Response contexts are used to serve the same data (an Item, for example) in different formats. Omeka includes by default response contexts for JSON, RSS and XML response contexts, in addition to the default context, which produces the normal HTML output.
Suffix values added to the contexts correspond to view files. Thus, to add an RSS feed at url my-records/browse?output=rss, you will have a view named browse.rss.php
Value¶
- array $contexts
- Array of contexts, corresponding to action contexts defined by using action_contexts
Arguments¶
None
Examples¶
Add an RSS feed at my-records/browse?output=rss
class MyPlugin extends Omeka_Plugin_AbstractPlugin
{
protected $_filters = array('define_response_contexts');
public function filterDefineResponseContexts($contexts)
{
$contexts['rss'] = array('suffix' => 'rss',
'headers' => array('Content-Type' => 'text/xml'));
return $contexts;
}
}
search_form_default_action¶
Usage¶
Alter the action (url) to use when the search form is submitted
Value¶
- string $url
- The url for the form’s action attribute
Arguments¶
None
search_query_types¶
Usage¶
Add a new search query type for the advanced search form
Value¶
- array $searchQueryTypes
- Array of query types
Arguments¶
None
Examples¶
The original array is
$searchQueryTypes = array(
'keyword' => __('Keyword'),
'boolean' => __('Boolean'),
'exact_match' => __('Exact match'),
);
To implement an ‘ends with’ search query type, you must use both this filter, and the search_sql hook
class EndsWithPlugin extends Omeka_Plugin_AbstractPlugin
{
protected $_filters = array('search_query_types');
protected $_hooks = array('search_sql');
public function filterSearchQueryTypes($queryTypes)
{
// Register the name of your custom query type. The key should be the
// type's GET query value; the values should be the human readable and
// internationalized version of the query type.
$queryTypes['ends_with'] = __('Ends with');
return $queryTypes;
}
public function hookSearchSql($args)
{
$params = $args['params'];
if ('ends_with' == $params['query_type']) {
$select = $args['select'];
// Make sure to reset the existing WHERE clause.
$select->reset(Zend_Db_Select::WHERE);
$select->where('`text` REGEXP ?', $params['query'] . '[[:>:]]');
}
}
}
search_record_types¶
Usage¶
Add a record type to the list of options for the search form. Plugins that add searchable content should use this to allow administrators to choose whether to include that content in the search options.
Value¶
array $searchRecordTypes
A key-value array where keys are names of record types and values are the internationalized forms of their labels:
$searchRecordTypes = array(
'Item' => __('Item'),
'File' => __('File'),
'Collection' => __('Collection'),
);
Arguments¶
None
Examples¶
class SimplePagesPlugin extends Omeka_Plugin_AbstractPlugin
{
/**
* Add SimplePagesPage as a searchable type.
*/
function filterSearchRecordTypes($recordTypes)
{
$recordTypes['SimplePagesPage'] = __('Simple Page');
return $recordTypes;
}
}
There are times when theme writers will want to change the record type label on the search results page. For example, when the “Exhibit” is a gallery and the “Exhibit Pages” are individual artists. To do this, in the theme’s custom.php file, add the following
add_filter('search_record_types', 'my_site_search_record_types');
function my_site_search_record_types($recordTypes)
{
$searchRecordTypes['Exhibit'] = __('Gallery');
$searchRecordTypes['ExhibitPage'] = __('Artist');
return $searchRecordTypes;
}
See also¶
storage_path¶
Usage¶
Changes the path to where a file is stored. This can be a simpler solution than writing your own storage adapter class.
Examples¶
Store files in different directories by extension.
class MyPlugin extends :php:class:`Omeka_Plugin_AbstractPlugin`
{
protected $_filters = array('storage_path');
public filterStoragePath($path, $args)
{
$explodedFileName = explode('.', $args['filename']);
$extension = $explodedFileName[count($explodedFileName)-1];
return 'files/' . $extension . '/' . $args['filename'];
}
}
See Also¶
system_info¶
Usage¶
Filter the list of information about the system, such as browser, PHP version, and more
Arguments¶
None
Examples¶
See Also¶
theme_options¶
Usage¶
Filters the theme configuration options before they are returned by a call to get_theme_option.
Plugins can use this filter to modify settings for particular themes, or store and use alternative settings.
The options will be provided as a serialized string, so in order to modify the options, a plugin must unserialize() the array, make whatever changes are desired, then serialize() again before returning.
Value¶
string $themeOptions
The set of all theme configuration options for a theme. This is a serialized array.
Examples¶
Exhibit Builder adds theme settings on a per-exhibit basis.
class ExhibitBuilderPlugin extends :php:class:`Omeka_Plugin_AbstractPlugin`
{
protected $_filters = array('theme_options');
public filterThemeOptions($options, $args)
{
if (Omeka_Context::getInstance()->getRequest()->getModuleName() == 'exhibit-builder' && function_exists('__v')) {
if ($exhibit = exhibit_builder_get_current_exhibit()) {
$exhibitThemeOptions = $exhibit->getThemeOptions();
}
}
if (!empty($exhibitThemeOptions)) {
return serialize($exhibitThemeOptions);
}
return $themeOptions;
}
}
Database¶
file_ingest_validators¶
Usage¶
Allows you to add or remove validators to be used when a file is uploaded.
Value¶
array $validators
A keyed array of validators to use. Validators are subclasses of Zend_Validate_Abstract.
Arguments¶
None
Examples¶
The default validators are:
array(
'extension whitelist'=> new Omeka_Validate_File_Extension,
'MIME type whitelist'=> new Omeka_Validate_File_MimeType
)
To swap out Omeka’s Mime Type validator for your own:
public function filterFileIngestValidators($validators)
{
unset($validators, 'MIME type whitelist');
$validators['my mime validator'] = new MyPlugin_Validate_File_MimeType;
return $validators;
}
Records¶
Record Metadata¶
Element Display Filter¶
Alter the way an element is displayed.
The name of the filter is an array:
array('Display', $recordType, $elementSetName, $elementName);
- $recordType: The type of Omeka object to filter the metadata for. Most commonly, this will be ‘Item’.
- $elementSetName: The name of the element set containing the metadata field to be filtered. Possible values include ‘Dublin Core’ and ‘Item Type Metadata’.
- $elementName: The name of the specific element within the set to be filtered.
- string $text
- The text to display.
- Omeka_Record_AbstractRecord record
- The record being displayed
- ElementText element_text
- The ElementText object
class MyPlugin extends Omeka_Plugin_AbstractPlugin
{
protected $_filters = array('concealDescription' => array('Display', 'Item', 'Dublin Core', 'Description'));
public function concealDescription($text, $args)
{
//conceal the description to non-logged in users
if(!get_current_user()) {
return str_rot13($text);
}
return $text;
}
}
Element ElementForm Filter¶
Customize the form for a particular element. This only applies to forms generated by the element_form() helper function.
The name is an array:
array('ElementForm', $recordType, $elementSetName, $elementName);
- $recordType: The type of Omeka object to filter the metadata for. Most commonly, this will be ‘Item’.
- $elementSetName: The name of the element set containing the metadata field to be filtered. Possible values include ‘Dublin Core’ and ‘Item Type Metadata’.
- $elementName: The name of the specific element within the set to be filtered.
array $components
The form components, like:
$components = array( 'label' => $labelComponent, 'inputs' => $inputsComponent, 'description' => $descriptionComponent, 'comment' => $commentComponent, 'add_input' => $addInputComponent, 'html' => null );
Omeka_Record_AbstractRecord record
The model being edited.
Element element
The element being edited
array options
An array of additional options for the form
class MyPlugin extends Omeka_Plugin_AbstractPlugin
{
$_filters = array('relabelItemTitle' => array('ElementForm', 'Item', 'Dublin Core', 'Title'));
public function relabelItemTitle($components, $args)
{
$components['label'] = "Label";
return $components;
}
}
Element ElementInput Filter¶
Customize the input for a particular element. This only applies to forms generated by the element_form() helper function.
The name of the filter is an array:
array('ElementInput', $recordType, $elementSet, $elementName);
- $recordType: The type of Omeka object to filter the metadata for. Most commonly, this will be ‘Item’.
- $elementSetName: The name of the element set containing the metadata field to be filtered. Possible values include ‘Dublin Core’ and ‘Item Type Metadata’.
- $elementName: The name of the specific element within the set to be filtered.
array $components
The input components, like:
$components = array( 'input' => $formTextarea, 'form_controls' => $removeButton, 'html_checkbox' => $useHtmlCheckbox, 'html' => null );
string input_name_stem
The name of the input, e.g., Elements[1][0]
string value
The value for the input
Omeka_Record_AbstractRecord record
The model being edited
Element element
The element being edited
string index
The index of the input for the element
boolean is_html
Whether the input uses html
class MyPlugin extends Omeka_Plugin_AbstractPlugin
{
$_filters = array('shortenSubjectField', array('ElementInput', 'Item', 'Dublin Core', 'Title'));
public function shortenSubjectField($components, $args)
{
$components['input'] = get_view()->formText($args['input_name_stem'], $args['value']);
return $components;
}
}
Element Flatten Filter¶
‘Flatten’ the array of data for an element into the text to use.
The array looks like:
array('text' => 'The text', 'html'=>0);
Where the html key is a boolean for whether the element text uses HTML.
If no Element Flatten filters operate, the value of the text key is used.
This filter’s name is actually an array of strings. The first string must always be ‘Flatten’, but the last three can change depending on exactly what values you want to filter.
array('Flatten', $recordType, $elementSetName, $elementName)
- $recordType: The type of Omeka object to filter the metadata for.
- $elementSetName: The name of the element set containing the metadata field to be filtered. Possible values will include ‘Dublin Core’ and ‘Item Type Metadata’.
- $elementName: The name of the specific element within the set to be filtered.
array post_array
The posted data, like array('text' => 'The text', 'html'=>0);
Element element
The element being saved.
$_filters = array('prependJulianToDate' => array('Flatten', 'Item', 'Dublin Core', 'Date'));
public function prependJulianToDate($flatText, $args)
{
$postArray = $args['post_array'];
$value = $postArray['text'];
return "Julian Calendar: $value";
}
ElementText::getTextStringFromFormPost
Element Save Filter¶
Customize element texts for a particular element before validating and saving a record. This is helpful if you want to prepare form data for validation automatically, limiting the possibility of a validation error.
array('Save', $recordType, $elementSetName, $elementName)
- $recordType: The type of Omeka object to filter the metadata for. Most commonly, this will be ‘Item’.
- $elementSetName: The name of the element set containing the metadata field to be filtered. Possible values include ‘Dublin Core’ and ‘Item Type Metadata’.
- $elementName: The name of the specific element within the set to be filtered.
- string $text
- The original text for the element
- Omeka_Record_AbstractRecord record
- The record that this text applies to. The type will be the same as the filter’s $recordType.
- Element element
- The Element record for this text.
class MyPlugin extends :php:class:`Omeka_Plugin_AbstractPlugin`
{
protected $_filters = array('addIsbnToDcId'=>array('Save', 'Item', 'Dublin Core', 'Identifier');
public function addIsbnToId($text, $args)
{
return "ISBN: $text";
}
}
Element Validation Filter¶
Perform a custom validation on the texts for any particular element.
This filter’s name is actually an array of strings. The first string must always be ‘Validate’, but the last three can change depending on exactly what values you want to validate.
array('Validate', $recordType, $elementSetName, $elementName)
- $recordType: The type of Omeka object to filter the metadata for.
- $elementSetName: The name of the element set containing the metadata field to be filtered. Possible values will include ‘Dublin Core’ and ‘Item Type Metadata’.
- $elementName: The name of the specific element within the set to be filtered.
string text
The text for the element
Omeka_Record_AbstractRecord record
The record (subclass of Omeka_Record_AbstractRecord) being validated.
Element element
The element (e.g., Dublin Core Title) for the element text.
class MyPlugin extends Omeka_Plugin_AbstractPlugin
{
protected $_filters = array('itemTitleLengthValidator' => array('Validate', 'Item', 'Dublin Core', 'Title'));
public function itemTitleValidator($isValid, $args)
{
$text = $args['text'];
if(strlen($text) > 100) {
return false;
}
return true;
}
}
ElementText::_elementTextIsValid
Search¶
item_search_filters¶
Usage¶
Use this filter in conjunction with the <model>_browse_sql hook to display what search filters are being applied to the item search.
If your plugin uses item_browse_sql to provide an additional filter when searching, you should use this filter to display the results.
Look through the request_array passed in the arguments for the key/value pair with key matching the additional filter you have created. Add the display value to the array as a new key/value pair, with the key being the name of your filter and the value being the text to display.
Value¶
- array $displayArray
- Array of filters for the search/browse page. Keys are possible $_GET parameters. Values are values being filtered.
Arguments¶
- array request_array
- Array of $_GET parameters
Examples¶
The MultiCollections plugin clobbers the core collection filtering message by checking if a multi-collection value is among the $_GET parameters and displaying the collection name.
public function filterItemSearchFilters($displayArray, $args)
{
$request_array = $args['request_array'];
if(isset($request_array['multi-collection'])) {
$db = get_db();
$collection = $db->getTable('Collection')->find($request_array['multi-collection']);
$displayValue = strip_formatting(metadata($collection, array('Dublin Core', 'Title')));
$displayArray['collection'] = $displayValue;
}
return $displayArray;
}
See Also¶
items_advanced_search_link_default_url¶
Usage¶
Changes the url to use for items/advanced-search
Value¶
- string $url
- The url for items advanced search
Arguments¶
None
Examples¶
search_form_default_action¶
Usage¶
Alter the action (url) to use when the search form is submitted
Value¶
- string $url
- The url for the form’s action attribute
Arguments¶
None
search_query_types¶
Usage¶
Add a new search query type for the advanced search form
Value¶
- array $searchQueryTypes
- Array of query types
Arguments¶
None
Examples¶
The original array is
$searchQueryTypes = array(
'keyword' => __('Keyword'),
'boolean' => __('Boolean'),
'exact_match' => __('Exact match'),
);
To implement an ‘ends with’ search query type, you must use both this filter, and the search_sql hook
class EndsWithPlugin extends Omeka_Plugin_AbstractPlugin
{
protected $_filters = array('search_query_types');
protected $_hooks = array('search_sql');
public function filterSearchQueryTypes($queryTypes)
{
// Register the name of your custom query type. The key should be the
// type's GET query value; the values should be the human readable and
// internationalized version of the query type.
$queryTypes['ends_with'] = __('Ends with');
return $queryTypes;
}
public function hookSearchSql($args)
{
$params = $args['params'];
if ('ends_with' == $params['query_type']) {
$select = $args['select'];
// Make sure to reset the existing WHERE clause.
$select->reset(Zend_Db_Select::WHERE);
$select->where('`text` REGEXP ?', $params['query'] . '[[:>:]]');
}
}
}
search_record_types¶
Usage¶
Add a record type to the list of options for the search form. Plugins that add searchable content should use this to allow administrators to choose whether to include that content in the search options.
Value¶
array $searchRecordTypes
A key-value array where keys are names of record types and values are the internationalized forms of their labels:
$searchRecordTypes = array(
'Item' => __('Item'),
'File' => __('File'),
'Collection' => __('Collection'),
);
Arguments¶
None
Examples¶
class SimplePagesPlugin extends Omeka_Plugin_AbstractPlugin
{
/**
* Add SimplePagesPage as a searchable type.
*/
function filterSearchRecordTypes($recordTypes)
{
$recordTypes['SimplePagesPage'] = __('Simple Page');
return $recordTypes;
}
}
There are times when theme writers will want to change the record type label on the search results page. For example, when the “Exhibit” is a gallery and the “Exhibit Pages” are individual artists. To do this, in the theme’s custom.php file, add the following
add_filter('search_record_types', 'my_site_search_record_types');
function my_site_search_record_types($recordTypes)
{
$searchRecordTypes['Exhibit'] = __('Gallery');
$searchRecordTypes['ExhibitPage'] = __('Artist');
return $searchRecordTypes;
}
See also¶
Text¶
display_option_*¶
Usage¶
This family of filters is used whenever the option theme function is called, to filter the value returned from the database before it is displayed.
The name of the particular filter that should be used is made by appending the name of the option to “display_option_”.
Examples¶
To print the site title, a theme writer would do the following:
<?php echo option('site_title'); ?>
If you want to prepend “Omeka: ” to the title of every printed page:
public function filterDisplayOptionSiteTitle($option)
{
return "Omeka: $option";
}
item_citation¶
Usage¶
Filters or replaces the default citation displayed for an item.
Examples¶
class MyPlugin extends Omeka_Plugin_AbstractPlugin {
protected $_filters = array(‘item_citation’);
public filterItemCitation($citation, $args) {
$citation = “”; return $citation;}
}
See Also¶
item_citation
Views¶
Admin Views¶
admin_collections_form_tabs¶
Filter tabs used on the collections add/edit page
- array $tabs
- The array of tabs. The key is the label for the tab, and the value is the html to display.
- Collection collection
- The collection being edited
admin_dashboard_panels¶
Add a panel to the dashboard. HTML content is automatically wrapped in the appropriately styled <div>
- array $panels
- Array of HTML content for each panel
- Omeka_View view
- The current view object
admin_dashboard_stats¶
Add content to the stats row at the top of the dashboard
- array $stats
- Array of links for the stats row
- Omeka_View view
- The current view object
Original value looks like:
$stats = array(
array(link_to('items', null, total_records('Item')), __('items')),
array(link_to('collections', null, total_records('Collection')), __('collections')),
array(link_to('tags', null, total_records('Tag')), __('tags'))
);
admin_items_form_tabs¶
The admin_items_form_tabs filter allows you to add, remove, or modify the tabs on the edit item form.
- array $tabs
- An array of the item form tabs. The keys are the tab names, and the values are the HTML content of each tab. A filter function should modify this array and return it.
- Item item
- The Item being edited. Filter functions can use this parameter to change the tabs or content on an item-by-item basis.
class MyPlugin extends :php:class:`Omeka_Plugin_AbstractPlugin`
{
protected $_filters = array('admin_items_form_tabs');
public filterAdminItemsFormTabs($tabs, $args)
{
$item = $args['item'];
$tabs["My Plugin"] = uri('/my-plugin/edit/id/' . $item->id);
}
}
admin_theme_name¶
Filters the currently-selected admin theme. Changing the theme name through this filter will cause Omeka to use a different theme to display the admin interface.
None
Force Omeka to use a different admin theme
public function filterAdminThemeName($theme_name)
{
return 'my-custom-admin-theme';
}
admin_whitelist¶
Allows admin controller views to be accessible without logging in
array $whitelist
An array containing arrays of controller-view pairs that do not require logging in to access
None
The default whitelist is:
array(
array('controller' => 'users', 'action' => 'activate'),
array('controller' => 'users', 'action' => 'login'),
array('controller' => 'users', 'action' => 'forgot-password'),
array('controller' => 'installer', 'action' => 'notify'),
array('controller' => 'error', 'action' => 'error')
);
To make your plugin’s admin page accessible without login
public function filterAdminWhitelist($whitelist)
{
$whitelist[] = array('controller' => 'my-controller' , 'action' => 'my-view');
return $whitelist;
Forms¶
admin_collections_form_tabs¶
Filter tabs used on the collections add/edit page
- array $tabs
- The array of tabs. The key is the label for the tab, and the value is the html to display.
- Collection collection
- The collection being edited
admin_items_form_tabs¶
The admin_items_form_tabs filter allows you to add, remove, or modify the tabs on the edit item form.
- array $tabs
- An array of the item form tabs. The keys are the tab names, and the values are the HTML content of each tab. A filter function should modify this array and return it.
- Item item
- The Item being edited. Filter functions can use this parameter to change the tabs or content on an item-by-item basis.
class MyPlugin extends :php:class:`Omeka_Plugin_AbstractPlugin`
{
protected $_filters = array('admin_items_form_tabs');
public filterAdminItemsFormTabs($tabs, $args)
{
$item = $args['item'];
$tabs["My Plugin"] = uri('/my-plugin/edit/id/' . $item->id);
}
}
Public Views¶
body_tag_attributes¶
Filters the tags applied to the <body> element of the page
None
class MyPlugin extends Omeka_Plugin_AbstractPlugin
{
protected $_filters = array('body_tag_attributes');
public function filterBodyTagAttributes($attributes)
{
//add a class when users are logged in
if(current_user()) {
$attributes['class'] = trim("logged-in " . $attributes['class']);
}
return $attributes;
}
}
Models¶
Collection¶
- class Collection¶
Package: Record
A collection and its metadata.
- property public¶
- property featured¶
- property added¶
- property modified¶
- property owner_id¶
- getProperty(string $property)¶
Get a property about this collection.
Parameters: - $property (string) – The property to get, always lowercase.
Returns: mixed The value of the property
- totalItems()¶
Determine the total number of items associated with this collection.
Returns: integer
- setAddedBy(User $user)¶
Set the user who added the collection.
Note that this is not to be confused with the collection’s “contributors”.
Parameters: - $user (User) –
- getResourceId()¶
Required by Zend_Acl_Resource_Interface.
Identifies Collection records as relating to the Collections ACLresource.
Returns: string
- hasContributor()¶
Returns whether or not the collection has at least 1 contributor element text
Returns: boolean
- _initializeMixins()¶
Initialize the mixins
- filterPostData(array $post)¶
Filter the POST data from the form.
Converts public/featured flags to booleans.
Parameters: - $post (array) –
Returns: array
- _delete()¶
All of the custom code for deleting an collection.
Returns: void
- beforeSave($args)¶
Parameters: - $args (unknown) –
- afterSave()¶
Element¶
- class Element¶
Package: Record
An element and its metadata.
- property element_set_id¶
- property order¶
- property name¶
- property description¶
- property comment¶
- setElementSet(string $elementSetName)¶
Set the element set for the element.
Parameters: - $elementSetName (string) –
Returns: void
- getElementSet()¶
Return the ElementSet objection for this element.
Returns: ElementSet
- setOrder(integer $order)¶
Set the order of the element within its element set.
Parameters: - $order (integer) –
Returns: void
- setName(string $name)¶
Set the name of the element.
Parameters: - $name (string) –
Returns: void
- setDescription(string $description)¶
Set the description for the element.
Parameters: - $description (string) –
Returns: void
- setComment($comment)¶
Parameters: - $comment (unknown) –
- setArray(array|string $data)¶
Parameters: - $data (array|string) –
If string, it’s the name of the element. Otherwise, array of metadata for the element. May contain the following keys in the array:
- name
- description
- comment
- order
- element_set_id
- element_set
Returns: void
- $data (array|string) –
- _validate()¶
Validate the element prior to being saved.
Checks the following criteria:
- Name is not empty.
- Name does not already exist within the given element set.
- _delete()¶
When deleting an element, cascade delete all element texts and item type assignments associated with the element.
- _getElementSetId($elementSetName)¶
Retrieve the element set ID from the name.
Parameters: - $elementSetName (unknown) –
Returns: int
- _nameIsInSet($elementName, $elementSetId)¶
Calculate whether the element’s name already belongs to the current set.
Parameters: - $elementName (unknown) –
- $elementSetId (unknown) –
Returns: boolean
ElementSet¶
- class ElementSet¶
Package: Record
An element set and its metadata.
- constant ITEM_TYPE_NAME¶
The name of the item type element set.
This is used wherever it is important to distinguish this special case element set from others.
- property record_type¶
- property name¶
- property description¶
- property _elementsToSave¶
- getElements()¶
- addElements(array $elements)¶
Add elements to the element set.
Parameters: - $elements (array) –
- _buildElementRecord($options)¶
Parameters: - $options (unknown) –
- afterSave($args)¶
Parameters: - $args (unknown) –
- _delete()¶
Deletes all the elements associated with an element set.
Returns: void
- _getNextElementOrder()¶
- _validate()¶
ElementText¶
File¶
- class File¶
Package: Record
A file and its metadata.
- property item_id¶
- property order¶
- property filename¶
- property original_filename¶
- property size¶
- property authentication¶
- property mime_type¶
- property type_os¶
- property has_derivative_image¶
- property added¶
- property modified¶
- property stored¶
- property metadata¶
- property _pathsByType¶
- getProperty(string $property)¶
Get a property or special value of this record.
Parameters: - $property (string) –
Returns: mixed
- _initializeMixins()¶
Initialize mixins.
- filterPostData(array $post)¶
Unset immutable properties from $_POST.
Parameters: - $post (array) –
Returns: array
- beforeSave(array $args)¶
Do something before saving this record.
Parameters: - $args (array) –
- afterSave(array $args)¶
Do something after saving this record.
Parameters: - $args (array) –
- getItem()¶
Retrieve the parent item of this record.
Returns: Item
- getPath(string $type = original)¶
Retrieve a system path for this file.
Parameters: - $type (string) –
Returns: string
- getWebPath(string $type = original)¶
Retrieve a web path for this file.
Parameters: - $type (string) –
Returns: string
- getDerivativeFilename()¶
Retrieve the derivative filename.
Returns: string
- hasThumbnail()¶
Determine whether this record has a thumbnail image.
Returns: bool
- hasFullsize()¶
Determine whether this record has a fullsize image.
Returns: bool
- getExtension()¶
Get the original file’s extension.
Returns: string
- setDefaults($filepath, $options = Array)¶
Set the default values that will be stored for this record in the ‘files’ table.
Parameters: - $filepath (unknown) –
- $options (unknown) –
Returns: void
- unlinkFile()¶
Unlink the file and file derivatives belonging to this record.
- _delete()¶
Perform any further deletion when deleting this record.
- createDerivatives()¶
Create derivatives of the original file.
- extractMetadata()¶
Extract ID3 metadata associated with the file.
Returns: boolean
- _getId3()¶
Pull down the file’s extra metadata via getID3 library.
Returns: getID3
- storeFiles()¶
Store files belonging to this record.
- getStoragePath(string $type = fullsize)¶
Get the storage path.
Parameters: - $type (string) –
Returns: string
- setStorage(Omeka_Storage $storage)¶
Set the storage object.
Parameters: - $storage (Omeka_Storage) –
- getStorage()¶
Get the storage object.
Returns: Omeka_Storage
- getResourceId()¶
Get the ACL resource ID for the record.
File records are ‘Files’ resources.
Returns: string
Item¶
- class Item¶
Package: Record
An item and its metadata.
- property item_type_id¶
- property collection_id¶
- property featured¶
- property public¶
- property added¶
- property modified¶
- property owner_id¶
- property _files¶
- _initializeMixins()¶
- getCollection()¶
Returns: null|Collection
- getItemType()¶
Retrieve the ItemType record associated with this Item.
Returns: ItemType|null
- getFiles()¶
Retrieve the set of File records associated with this Item.
Returns: array
- getItemTypeElements()¶
Retrieve a set of elements associated with the item type of the item.
Each one of the Element records that is retrieved should contain all theelement text values associated with it.
Returns: array Element records that are associated with the item type of the item. This array will be empty if the item does not have an associated type.
- getProperty(string $property)¶
Get a property for display.
Parameters: - $property (string) –
Returns: mixed
- beforeSave($args)¶
Parameters: - $args (unknown) –
- afterSave($args)¶
Logic for after the record has been saved.
Parameters: - $args (unknown) –
- _delete()¶
All of the custom code for deleting an item.
Returns: void
- _deleteFiles(array $fileIds = Array)¶
Delete files associated with the item.
If the IDs of specific files are passed in, this will delete only thosefiles (e.g. form submission). Otherwise, it will delete all filesassociated with the item.
Parameters: - $fileIds (array) – Optional
Returns: void
- _uploadFiles()¶
Iterate through the $_FILES array for files that have been uploaded to Omeka and attach each of those files to this Item.
Returns: void
- saveFiles()¶
Save all the files that have been associated with this item.
Returns: boolean
- filterPostData($post)¶
Filter post data from form submissions.
Parameters: - $post (unknown) –
Returns: array Clean post data
- fileCount()¶
Retrieve the number of files assigned to this item.
Returns: boolean
- previous()¶
Retrieve the previous Item in the database.
Returns: Item|false
- next()¶
Retrieve the next Item in the database.
Returns: Item|false
- hasThumbnail()¶
Determine whether or not the Item has a File with a thumbnail image (or any derivative image).
Returns: boolean
- getCitation()¶
Return a valid citation for this item.
Generally follows Chicago Manual of Style note format for webpages.Implementers can use the item_citation filter to return a customizedcitation.
Returns: string
- addFile(File $file)¶
Associate an unsaved (new) File record with this Item.
These File records will not be persisted in the database until the itemis saved or saveFiles() is invoked.
Parameters: - $file (File) –
Returns: void
- getResourceId()¶
Required by Zend_Acl_Resource_Interface.
Identifies Item records as relating to the Items ACL resource.
Returns: string
ItemType¶
- class ItemType¶
Package: Record
An item type and its metadata.
- property name¶
- property description¶
- property _elementsToSave¶
- property _elementsToRemove¶
- getElements()¶
Returns an array of element objects associated with this item type.
Returns: array The array of element objects associated with this item type.
- getItems(int $count = 10, boolean $recent = 1)¶
Returns an array of item objects that have this item type.
Parameters: - $count (int) – The maximum number of items to return.
- $recent (boolean) – Whether or not the items are recent.
Returns: array The items associated with the item type.
- _validate()¶
Current validation rules for Type
- ‘Name’ field can’t be blank2) ‘Name’ field must be unique
Returns: void
- filterPostData($post)¶
Filter incoming POST data from ItemType form.
Parameters: - $post (unknown) –
Returns: void
- _delete()¶
Delete all the ItemTypesElements joins
Returns: void
- afterSave($args)¶
Save Element records that are associated with this Item Type.
Parameters: - $args (unknown) –
Returns: void
- reorderElements(Array $elementOrderingArray)¶
This extracts the ordering for the elements from the form’s POST, then uses the given ordering to reorder each join record from item_types_elements into a new ordering, which is then saved.
Parameters: - $elementOrderingArray (Array) – An array of element_id => order pairs
Returns: void
- addElements(array $elements = Array)¶
Add a set of elements to the Item Type.
Parameters: - $elements (array) – Either an array of elements or an array of metadata, where each entry corresponds to a new element to add to the item type. If an element exists with the same id, it will replace the old element with the new element.
Returns: void
- addElementById($elementId)¶
Adds a new element to the item type by the id of the element
Parameters: - $elementId (unknown) –
Returns: void
- removeElements(Array $elements)¶
Removes an array of Elements from this item type The element will not be removed until the object is saved.
Parameters: - $elements (Array) – An array of Element objects or element id strings
Returns: void
- removeElement(Element|string $element)¶
Remove a single Element from this item type. The element will not be removed until the object is saved.
Parameters: - $element (Element|string) – The element object or the element id.
Returns: void
- _removeElement(Element|string $element)¶
Removes a single Element from this item type. It removes it immediately.
Parameters: - $element (Element|string) –
Returns: void
- hasElement(Element|string $element)¶
Determines whether a saved version of the item type has an element. It does not correctly determine the presence of elements that were added or removed without saving the item type object.
Parameters: - $element (Element|string) – The element object or the element id.
Returns: boolean
- totalItems()¶
Determines the total number of items that have this item type.
Returns: int The total number of items that have this item type.
- getItemTypeElementSet()¶
Returns the ‘Item Type’ element set.
Returns: ElementSet
ItemTypesElements¶
Option¶
Plugin¶
- class Plugin¶
Package: Record
A plugin and its metadata.
- property name¶
- property active¶
- property version¶
- property _displayName¶
- property _description¶
- property _link¶
- property _loaded¶
- property _hasConfig¶
- property _requiredPlugins¶
- property _optionalPlugins¶
- property _minimumOmekaVersion¶
- property _testedUpToVersion¶
- property _iniVersion¶
- property _iniTags¶
- _validate()¶
- getDirectoryName()¶
Get the name of the directory containing the plugin.
- setDirectoryName(string $name)¶
Set the name of the directory containing the plugin.
Parameters: - $name (string) –
- getDisplayName()¶
Get the human-readable name of the plugin, e.g. “Dublin Core Extended”.
If there is no human-readable name available, returns the directory name instead.
- setDisplayName(string $name)¶
Set the human-readable name of the plugin.
Parameters: - $name (string) –
- getAuthor()¶
Get the author’s name.
- setAuthor(string $author)¶
Set the author’s name.
Parameters: - $author (string) –
- getDescription()¶
Get the description of the plugin.
- setDescription(string $description)¶
Set the description of the plugin.
Parameters: - $description (string) –
- getMinimumOmekaVersion()¶
Get the minimum version of Omeka that this plugin requires to work.
- setMinimumOmekaVersion(string $version)¶
Set the minimum required version of Omeka.
Parameters: - $version (string) –
- getTestedUpToOmekaVersion()¶
Get the version of Omeka that this plugin is tested up to.
- setTestedUpToOmekaVersion(string $version)¶
Set the version of Omeka that this plugin is tested up to.
Parameters: - $version (string) –
- getRequiredPlugins()¶
Get the list of plugins that are required for this plugin to work.
- setRequiredPlugins($plugins)¶
Set the list of plugins that are required for this plugin to work.
Parameters: - $plugins (unknown) –
- getOptionalPlugins()¶
Get the list of plugins that can be used, but are not required by, this plugin.
- setOptionalPlugins($plugins)¶
Set the list of optional plugins.
Parameters: - $plugins (unknown) –
- getIniTags()¶
Get the list of tags for this plugin (from the ini file).
- setIniTags($tags)¶
Set the list of tags for this plugin.
Parameters: - $tags (unknown) –
- getLinkUrl()¶
Get the URL link from the plugin.ini.
- setLinkUrl(string $link)¶
Set the link from the plugin.ini.
Parameters: - $link (string) –
- isInstalled()¶
Whether or not the Plugin has been installed.
Returns: boolean
- isLoaded()¶
Returns: boolean
- setLoaded(boolean $flag)¶
Parameters: - $flag (boolean) –
- isActive()¶
Whether or not the plugin has been activated through the UI.
- setActive($flag)¶
Set whether or not the plugin has been activated.
Parameters: - $flag (unknown) –
- hasConfig()¶
Whether or not the plugin has a custom configuration hook.
- setHasConfig(boolean $flag)¶
Set whether or not the plugin has a custom configuration hook.
Parameters: - $flag (boolean) –
- getIniVersion()¶
Get the version of the plugin stored in the ini file.
- setIniVersion(string $version)¶
Set the version of the plugin that is indicated by the ini file.
Parameters: - $version (string) –
- getDbVersion()¶
Get the version of the plugin that is stored in the database.
- setDbVersion(string $version)¶
Set the version of the plugin that is stored in the database.
Parameters: - $version (string) –
- hasNewVersion()¶
Determine whether or not there is a new version of the plugin available.
- meetsOmekaMinimumVersion()¶
Determine whether the plugin meets the minimum version requirements for Omeka.
If the field is not set, assume that it meets the requirements. If the field is set, it must be greater than the current version of Omeka.
- meetsOmekaTestedUpToVersion()¶
- getResourceId()¶
Process¶
- class Process¶
Package: Record
A process and its metadata.
- property pid¶
- property class¶
- property user_id¶
- property status¶
- property args¶
- property started¶
- property stopped¶
- beforeSave($args)¶
Parameters: - $args (unknown) –
- getArguments()¶
- setArguments($args)¶
Parameters: - $args (unknown) –
- _isSerialized($s)¶
Parameters: - $s (unknown) –
RecordsTags¶
SearchText¶
Tag¶
- class Tag¶
Package: Record
A tag and its metadata.
- property name¶
- __toString()¶
- _delete()¶
Must also delete the taggings associated with this tag
Returns: void
- _validate()¶
- fieldIsUnique($field, $value)¶
The check for unique tag names must take into account CASE SENSITIVITY, which is accomplished via COLLATE utf8_bin sql
Parameters: - $field (unknown) –
- $value (unknown) –
Returns: bool
- rename(array $new_names)¶
Rename a tag.
Any records tagged with the “old” tag will be tagged with eachof the tags given in $new_names. The original tag will bedeleted (unless it is given as one of the $new_names).
Parameters: - $new_names (array) – Names of the tags this one should be renamed to.
Returns: void
Theme¶
- class Theme¶
Package: Record
A theme and its metadata.
Dummy model to simulate the other ActiveRecord models.
- property path¶
- property directory¶
- property image¶
- property title¶
- property description¶
- property license¶
- property website¶
- property omeka_minimum_version¶
- __construct($themeName)¶
Parameters: - $themeName (unknown) –
- setDirectoryName($dir)¶
Parameters: - $dir (unknown) –
- getScriptPath()¶
Get the physical path to the theme’s scripts.
Returns: string Physical path.
- getAssetPath()¶
Get the web path to the theme’s assets.
Returns: string Web path.
- getScriptPathForPlugin(string $pluginModuleName)¶
Get the physical path to the theme’s override scripts for the given plugin.
Parameters: - $pluginModuleName (string) – (i.e., ‘exhibit-builder’)
Returns: string Physical path.
- getAssetPathForPlugin(string $pluginModuleName)¶
Get the web path to the theme’s override assets for the given plugin.
Parameters: - $pluginModuleName (string) – (i.e., ‘exhibit-builder’)
Returns: string Web path.
- setImage($fileName)¶
Parameters: - $fileName (unknown) –
- setIni($fileName)¶
Parameters: - $fileName (unknown) –
- setConfig($fileName)¶
Parameters: - $fileName (unknown) –
- getCurrentThemeName(string $type)¶
Get the directory name of the current theme.
Parameters: - $type (string) – ‘admin’ or ‘public’, defaults to current type
Returns: string
- getAllThemes()¶
Retrieve all themes
Returns: array An array of theme objects
- getTheme(string $themeName)¶
Retrieve a theme.
Parameters: - $themeName (string) – The name of the theme.
Returns: Theme A theme object
- setOptions(string $themeName, array $themeConfigOptions)¶
Set theme configuration options.
Parameters: - $themeName (string) – The name of the theme
- $themeConfigOptions (array) – An associative array of configuration options, where each key is a configuration form input name and each value is a string value of that configuration form input
Returns: void
- getOptions(string $themeName)¶
Get theme configuration options.
Parameters: - $themeName (string) – The name of the theme
Returns: array An associative array of configuration options, where each key is a configuration form input name and each value is a string value of that configuration form input
- getOption(string $themeName, string $themeOptionName)¶
Get the value of a theme configuration option.
Parameters: - $themeName (string) – The name of the theme
- $themeOptionName (string) – The name of the theme option
Returns: string The value of the theme option
- setOption(string $themeName, string $themeOptionName, $themeOptionValue)¶
Set the value of a theme configuration option.
Parameters: - $themeName (string) – The name of the theme
- $themeOptionName (string) – The name of the theme option
- $themeOptionValue (unknown) –
Returns: void
- getOptionName(string $themeName)¶
Get the name of a specific theme’s option. Each theme has a single option in the option’s table, which stores all of the configuration options for that theme
Parameters: - $themeName (string) – The name of the theme
Returns: string The name of a specific theme’s option.
- getUploadedFileName(string $themeName, string $optionName, string $fileName)¶
Get the name of a file uploaded as a theme configuration option. This is the name of the file after it has been uploaded and renamed.
Parameters: - $themeName (string) – The name of the theme
- $optionName (string) – The name of the theme option associated with the uploaded file
- $fileName (string) – The name of the uploaded file
Returns: string The name of an uploaded file for the theme.
- _parseWebsite(string $website)¶
Parses the website string to confirm whether it has a scheme.
Parameters: - $website (string) – The website given in the theme’s INI file.
Returns: string The website URL with a prepended scheme.
User¶
- class User¶
Package: Record
A user and its metadata.
- property username¶
- property password¶
- property salt¶
- property active¶
- property role¶
- property name¶
- property email¶
- beforeSave($args)¶
Parameters: - $args (unknown) –
- filterPostData($post)¶
Parameters: - $post (unknown) –
- setPostData($post)¶
Parameters: - $post (unknown) –
- _validate()¶
- upgradeHashedPassword(string $username, string $password)¶
Upgrade the hashed password. Does nothing if the user/password is incorrect, or if same has been upgraded already.
Parameters: - $username (string) –
- $password (string) –
Returns: boolean False if incorrect username/password given, otherwise true when password can be or has been upgraded.
- getRoleId()¶
- getResourceId()¶
- generateSalt()¶
Generate a simple 16 character salt for the user.
- setPassword($password)¶
Parameters: - $password (unknown) –
- hashPassword($password)¶
Parameters: - $password (unknown) –
Models/Builder¶
Builder_Collection¶
- class Builder_Collection¶
Package: Record\Builder
Build a collection.
- property _recordClass¶
- property _settableProperties¶
- property _elementTexts¶
- setElementTexts(array $elementTexts)¶
Set the element texts for the collection.
Parameters: - $elementTexts (array) –
- _addElementTexts()¶
Add element texts to a record.
- _replaceElementTexts()¶
Replace all the element texts for existing element texts.
- _beforeBuild(Omeka_Record_AbstractRecord $record)¶
Add elements associated with the collection.
Parameters: - $record (Omeka_Record_AbstractRecord) – The collection record
Builder_ElementSet¶
- class Builder_ElementSet¶
Package: Record\Builder
Build an element set.
- property _settableProperties¶
- property _recordClass¶
- property _elementInfo¶
- setElements(array $elements)¶
Set the elements to add to the element set.
Parameters: - $elements (array) –
- setRecordMetadata(string|array $metadata)¶
Overrides setRecordMetadata() to allow giving the name of the element as a string.
Parameters: - $metadata (string|array) –
- _beforeBuild()¶
Add elements to be associated with the element set.
Builder_Item¶
- class Builder_Item¶
Package: Record\Builder
Build an item.
- constant IS_PUBLIC¶
- property _recordClass¶
- property _settableProperties¶
- property _elementTexts¶
- property _fileMetadata¶
- setElementTexts(array $elementTexts)¶
Set the element texts for the item.
Parameters: - $elementTexts (array) –
- setFileMetadata(array $fileMetadata)¶
Set the file metadata for the item.
Parameters: - $fileMetadata (array) –
- setRecordMetadata(array $metadata)¶
Overrides setRecordMetadata() to allow setting the item type by name instead of ID.
Parameters: - $metadata (array) –
Returns: void
- _addElementTexts()¶
Add element texts to a record.
- _replaceElementTexts()¶
Replace all the element texts for existing element texts.
- _addTags()¶
Add tags to an item (must exist in database).
- addFiles(string|Omeka_File_Ingest_AbstractIngest $transferStrategy, string|array $files, $options = Array)¶
Add files to an item.
<li>’Url|Filesystem’ => string|array If a string is given, this representsthe source identifier of a single file (the URL representing the file, orthe absolute file path, respectively). If an array is given, it assumesthat each entry in the array must be either an array or a string. If itan array, there are several default keys that may be present:<ul><li>’source’ => Any identifier that is appropriate to the transferstrategy in use. For ‘Url’, this should be a valid URL. For ‘Filesystem’,it must be an absolute path to the source file to be transferred.</li><li>’name’ => OPTIONAL The filename to give to the transferredfile. This can be any arbitrary filename and will be listed as theoriginal filename of the file. This will also be used to generate thearchival filename for the file. If none is given, this defaults to usingthe getOriginalFileName() method of the transfer adapter.</li><li>’metadata’ => OPTIONAL This could contain any metadata that needs to beassociated with the file. This should be indexed in the same fashionas for items. See ActsAsElementText::addTextsByArray()</li></ul></li></ul>
Parameters: - $transferStrategy (string|Omeka_File_Ingest_AbstractIngest) – This can either be one of the following strings denoting built-in transfer methods: ‘Upload’, ‘Filesystem’, ‘Url’ Or it could be an implemented Omeka_File_Ingest_AbstractIngest class.
- $files (string|array) –
This can be a single string, an array of strings, or an array of arrays, depending on the parameters that are needed by the underlying strategy. Expected parameters for the built in strategies are as follows:
- 'Upload' => null|string If a string is given, it represents the POST parameter name containing the uploaded file(s). If null is given, all files in the POST will be ingested.
- $options (unknown) –
Returns: array Set of File records ingested. May be empty if no files were ingested.
- _addIngestValidators(Omeka_File_Ingest_AbstractIngest $ingester)¶
Add the default validators for ingested files.
The default validators are whitelists for file extensions and MIME types, and those lists can be configured via the admin settings form.
These default validators can be disabled by the ‘disable_default_file_validation’ flag in the settings panel.
Plugins can add/remove/modify validators via the ‘file_ingest_validators’filter.
Parameters: - $ingester (Omeka_File_Ingest_AbstractIngest) –
Returns: void
- _beforeBuild(Omeka_Record_AbstractRecord $record)¶
Parameters: - $record (Omeka_Record_AbstractRecord) –
- _afterBuild(Omeka_Record_AbstractRecord $record)¶
Add tags to the item.
Parameters: - $record (Omeka_Record_AbstractRecord) –
Builder_ItemType¶
- class Builder_ItemType¶
Package: Record\Builder
Build an item type.
- property _recordClass¶
- property _settableProperties¶
- property _elements¶
- setElements(array $elementMetadata)¶
Set the elements that will be attached to the built ItemType record.
Parameters: - $elementMetadata (array) –
Returns: void
- _beforeBuild()¶
Add elements to be associated with the Item Type.
Models/Installer¶
Installer_Default¶
- class Installer_Default¶
Package: Install
The default installer, which extracts values from the installer form to create the default Omeka installation.
- property _db¶
- property _form¶
- setForm(Zend_Form $form)¶
Set the form from which to extract data for the installer.
Parameters: - $form (Zend_Form) –
- getDb()¶
- install()¶
- _getValue($fieldName)¶
Parameters: - $fieldName (unknown) –
- _createSchema()¶
- _createUser()¶
- _setupMigrations()¶
- _addOptions()¶
- isInstalled()¶
Installer_Exception¶
- class Installer_Exception¶
Package: Install
- property message¶
- property string¶
- property code¶
- property file¶
- property line¶
- property trace¶
- property previous¶
- __clone()¶
- __construct($message, $code, $previous)¶
Parameters: - $message (unknown) –
- $code (unknown) –
- $previous (unknown) –
- getMessage()¶
- getCode()¶
- getFile()¶
- getLine()¶
- getTrace()¶
- getPrevious()¶
- getTraceAsString()¶
- __toString()¶
Installer_InstallerInterface¶
Installer_Requirements¶
- class Installer_Requirements¶
Package: Install
- property _dbAdapter¶
- property _storage¶
- property _errorMessages¶
- property _warningMessages¶
- check()¶
- getErrorMessages()¶
- getWarningMessages()¶
- hasError()¶
- hasWarning()¶
- setDbAdapter(Zend_Db_Adapter_Abstract $db)¶
Parameters: - $db (Zend_Db_Adapter_Abstract) –
- setStorage(Omeka_Storage $storage)¶
Parameters: - $storage (Omeka_Storage) –
- _checkPhpVersionIsValid()¶
- _checkMysqliIsAvailable()¶
- _checkMysqlVersionIsValid()¶
- _checkHtaccessFilesExist()¶
- _checkRegisterGlobalsIsOff()¶
- _checkExifModuleIsLoaded()¶
- _checkFileStorageSetup()¶
- _checkFileinfoIsLoaded()¶
Installer_TaskInterface¶
Installer_Test¶
- class Installer_Test¶
Package: Install
Installer for test cases that require database access.
- property _testDefaults¶
- property _db¶
- property _form¶
- _getValue($fieldName)¶
Overridden to retrieve values only from a predefined array.
Parameters: - $fieldName (unknown) –
- install()¶
- setForm(Zend_Form $form)¶
Set the form from which to extract data for the installer.
Parameters: - $form (Zend_Form) –
- getDb()¶
- _createSchema()¶
- _createUser()¶
- _setupMigrations()¶
- _addOptions()¶
- isInstalled()¶
Models/Installer/Task¶
Installer_Task_Exception¶
Installer_Task_Migrations¶
Installer_Task_Options¶
Installer_Task_Schema¶
- class Installer_Task_Schema¶
Package: Install
Load the database schema for an Omeka installation.
Schema should be defined in an SQL file.
- property _defaultTables¶
- property _tables¶
- addTable(string $tableName, string $sqlFilePath)¶
Add an SQL table to the list of tables to create.
Parameters: - $tableName (string) –
- $sqlFilePath (string) –
- addTables(array $tables)¶
Add a set of SQL tables to the list.
Parameters: - $tables (array) –
- setTables(array $tables)¶
Set the list of SQL tables.
Parameters: - $tables (array) –
- removeTable(string $tableName)¶
Remove an SQL table from the list.
Parameters: - $tableName (string) –
- getTables()¶
Retrieve list of tables being installed.
- useDefaultTables()¶
Add all tables corresponding to the default Omeka installation.
Installer_Task_User¶
- class Installer_Task_User¶
Package: Install\Task
Create a default user for an Omeka installation.
- property _username¶
- property _password¶
- property _email¶
- property _name¶
- property _lastName¶
- property _active¶
- property _role¶
- setUsername($username)¶
Parameters: - $username (unknown) –
- setPassword($password)¶
Parameters: - $password (unknown) –
- setEmail($email)¶
Parameters: - $email (unknown) –
- setName($name)¶
Parameters: - $name (unknown) –
- setIsActive($active)¶
Parameters: - $active (unknown) –
- setRole($role)¶
Parameters: - $role (unknown) –
Models/Mixin¶
Mixin_ElementText¶
- class Mixin_ElementText¶
Package: Record\Mixin
Record mixin class for associating elements, element texts and their corresponding behaviors to a record.
- property _textsByNaturalOrder¶
ElementText records stored in the order they were retrieved from the database.
- property _textsByElementId¶
ElementText records indexed by the element_id.
- property _elementsBySet¶
Element records indexed by set name and element name, so it looks like:
$elements[‘Dublin Core’][‘Title’] = Element instance;
- property _elementsById¶
Element records indexed by ID.
- property _elementsOnForm¶
List of elements that were output on the form. This can be used to determine the DELETE SQL to use to reset the elements when saving the form.
- property _textsToSave¶
Set of ElementText records to save when submitting the form. These will only be saved to the database if they successfully validate.
- property _recordsAreLoaded¶
Whether the elements and texts have been loaded yet.
- property _elementsByRecordType¶
Sets of Element records indexed by record type.
- afterSave($args)¶
Omeka_Record_AbstractRecord callback for afterSave. Saves the ElementText records once the associated record is saved. Adds the record’s element texts to the search text.
Parameters: - $args (unknown) –
- _getDb()¶
Get the database object from the associated record.
Returns: Omeka_Db
- _getRecordType()¶
Get the class name of the associated record (Item, File, etc.).
Returns: string Type of record
- loadElementsAndTexts(boolean $reload =)¶
Load all the ElementText records for the given record (Item, File, etc.). These will be indexed by [element_id].
Also load all the Element records and index those by their name and setname.
Parameters: - $reload (boolean) – Whether or not reload all the data that was previously loaded.
Returns: void
- _loadElements($reload =)¶
Parameters: - $reload (unknown) –
- _getElementTextRecords()¶
Retrieve all of the ElementText records for the given record.
Returns: array Set of ElementText records for the record.
- _getElementRecords()¶
Retrieve all of the Element records for the given record.
Returns: array All Elements that apply to the record’s type.
- getElementTextsByRecord(Element $element)¶
Retrieve all of the record’s ElementTexts for the given Element.
Parameters: - $element (Element) –
Returns: array Set of ElementText records.
- getElementTexts(string $elementSetName, string $elementName)¶
Retrieve all of the record’s ElementTexts for the given element name and element set name.
Parameters: - $elementSetName (string) – Element set name
- $elementName (string) – Element name
Returns: array Set of ElementText records.
- getAllElementTexts()¶
Retrieve all of the record’s ElementTexts, in order.
Returns: array Set of ElementText records.
- getElementsBySetName($elementSetName)¶
Retrieve the Element records for the given ElementSet.
Parameters: - $elementSetName (unknown) –
Returns: array Set of Element records
- getAllElements()¶
Retrieve ALL the Element records for the object, organized by ElementSet. For example, $elements[‘Dublin Core’] = array(Element instance, Element instance, ...)
Returns: array Set of Element records
- getElement(string $elementSetName, string $elementName)¶
Retrieve the Element record corresponding to the given element name and element set name.
Parameters: - $elementSetName (string) –
- $elementName (string) –
Returns: Element
- getElementById(int $elementId)¶
Retrieve the Element with the given ID.
Parameters: - $elementId (int) –
Returns: Element
- _indexTextsByElementId(array $textRecords)¶
Index a set of ElementTexts based on element ID.
Parameters: - $textRecords (array) – Set of ElementText records
Returns: array The provided ElementTexts, indexed by element ID.
- _indexElementsBySet(array $elementRecords)¶
Index a set of Elements based on their name. The result is a doubly associative array, with the first key being element set name and the second being element name.
i.e., $indexed[‘Dublin Core’][‘Creator’] = Element instance
Parameters: - $elementRecords (array) – Set of Element records
Returns: array The provided Elements, indexed as described
- _indexElementsById($elementRecords)¶
Indexes the elements returned by element ID.
Parameters: - $elementRecords (unknown) –
Returns: array
- addTextForElement(Element $element, string $elementText, bool $isHtml =)¶
Add a string of text for an element.
Creates a new ElementText record, populates it with the specified text value and assigns it to the element.
saveElementTexts() must be called after this in order to save the elementtexts to the database.
Parameters: - $element (Element) – Element which text should be created for
- $elementText (string) – Text to be added
- $isHtml (bool) – Whether the text to add is HTML
- addElementTextsByArray($elementTexts)¶
Add element texts for a record based on a formatted array of values. The array must be formatted as follows:
'Element Set Name' => array('Element Name' => array(array('text' => 'foo', 'html' => false)))
Since 1.4, the array can also be formatted thusly:
array( array('element_id' => 1, 'text' => 'foo', 'html' => false) )
Parameters: - $elementTexts (unknown) –
- _addTextsByElementName($elementTexts)¶
Parameters: - $elementTexts (unknown) –
- _addTextsByElementId($texts)¶
Parameters: - $texts (unknown) –
- beforeSaveElements($post)¶
The application flow is thus:
- Build ElementText objects from the POST.2) Validate the ElementText objects and assign error messages ifnecessary.3) After the item saves correctly, delete all the ElementText recordsfor the Item.4) Save the new ElementText objects to the database.
Parameters: - $post (unknown) –
- _getElementTextsToSaveFromPost($post)¶
The POST should have a key called “Elements” that contains an array that is keyed to an element’s ID. That array should contain all the text values for that element. For example:
<code>
array(‘Elements’ =>array(‘50’ => array(array(‘text’ => ‘Foobar’, //element id 50, e.g. DC:Title’html’ => 0)),‘41’ => array(array(‘text’ => ‘<p>Baz baz baz</p>’, //element id 41, e.g. DC:Description’html’ => 1))))
</code>
Parameters: - $post (unknown) –
- getTextStringFromFormPost($postArray, $element)¶
Retrieve a text string for an element from POSTed form data.
Parameters: - $postArray (unknown) –
- $element (unknown) –
Returns: string
- _validateElementTexts()¶
Validate all the elements one by one. This is potentially a lot slower than batch processing the form, but it gives the added bonus of being able to encapsulate the logic for validation of Elements.
- _elementTextIsValid(ElementText $elementTextRecord)¶
Return whether the given ElementText record is valid.
Parameters: - $elementTextRecord (ElementText) –
Returns: boolean
- saveElementTexts()¶
Save all ElementText records that were associated with a record.
Typically called in the afterSave() hook for a record.
- deleteElementTextsByElementId($elementIdArray = Array)¶
Delete all the element texts for element_id’s that have been provided.
Parameters: - $elementIdArray (unknown) –
Returns: boolean
- deleteElementTexts()¶
Delete all the element texts assigned to the current record ID.
Returns: boolean
- hasElementText(string $elementSetName, string $elementName)¶
Returns whether or not the record has at least 1 element text
Parameters: - $elementSetName (string) – Element set name
- $elementName (string) – Element name
Returns: boolean
- getElementTextCount(string $elementSetName, string $elementName)¶
Returns the number of element texts for the record
Parameters: - $elementSetName (string) – Element set name
- $elementName (string) – Element name
Returns: boolean
Mixin_Owner¶
- class Mixin_Owner¶
Package: Record\Mixin
Mixin for models that have a user that is their “owner.”
- property _record¶
- property _column¶
- __construct($record, $column = owner_id)¶
Parameters: - $record (unknown) –
- $column (unknown) –
- beforeSave($args)¶
Parameters: - $args (unknown) –
- getOwner()¶
Get the record’s owner.
If the record has no user, this method returns null.
Returns: User|null
Mixin_PublicFeatured¶
- class Mixin_PublicFeatured¶
Package: Record\Mixin
Adds default behavior associated with the ‘public’ and ‘featured’ flags.
- property _wasPublic¶
- property _wasFeatured¶
- __construct(Omeka_Record_AbstractRecord $record)¶
Constructor
Parameters: - $record (Omeka_Record_AbstractRecord) – The underlying record
- isPublic()¶
Returns whether the record is public or not.
Returns: boolean
- setPublic(boolean $flag)¶
Sets whether the record is public or not.
Parameters: - $flag (boolean) – Whether the record is public or not
- isFeatured()¶
Returns whether the record is featured or not.
Returns: boolean
- setFeatured(boolean $flag)¶
Sets whether the record is featured or not.
Parameters: - $flag (boolean) – Whether the record is featured or not
- beforeSave($args)¶
Parameters: - $args (unknown) –
- afterSave($args)¶
Parameters: - $args (unknown) –
- _fireHook(string $state, boolean $flag)¶
Fires a hooks like ‘make_item_public’, ‘make_collection_not_featured’, etc.
Parameters: - $state (string) – Currently, ‘public’ or ‘featured’
- $flag (boolean) –
- _getHookName(string $state, boolean $flag)¶
Retrieve formatted hooks like ‘make_item_public’, ‘make_collection_not_featured’, etc.
Parameters: - $state (string) – Currently, ‘public’ or ‘featured’
- $flag (boolean) –
Returns: string The hook name
Mixin_Search¶
- class Mixin_Search¶
Package: Record\Mixin
Make an Omeka record fulltext searchable.
Any class that extends Omeka_Record_AbstractRecord can be made searchable bypushing an instance of this mixin into Omeka_Record::$_mixins duringOmeka_Record::_initializeMixins(). It must be pushed after all mixins thatcan add search text–for example, after ElementText.
The record type must also be registered using the search_record_types filter in order for the records to be searchable.
This mixin leverages the Omeka_Record_AbstractRecord::afterSave() andOmeka_Record_Mixin_AbstractMixin::afterSave() callbacks, so note their orderof execution. Records that initialize ActsAsElementText will automaticallyadd their element texts to the search text.
- property _text¶
- property _title¶
- property _public¶
- __construct($record)¶
Parameters: - $record (unknown) –
- addSearchText(string $text)¶
Add search text to this record.
This method is meant to be called during afterSave().
Parameters: - $text (string) –
- setSearchTextTitle(string $title)¶
Add a title to this record.
This method is meant to be called during afterSave().
Parameters: - $title (string) –
- setSearchTextPrivate()¶
Mark this record’s search text as not public.
This method is meant to be called during afterSave().
- afterSave($args)¶
Save the accumulated search text to the database.
Parameters: - $args (unknown) –
- afterDelete()¶
Delete this record’s search text after it has been deleted.
- saveSearchText(string $recordType, int $recordId, string $text, string $title, int $public = 1)¶
Save a search text row.
Call this statically only when necessary. Used primarily when in a recordthat does not implement Mixin_Search but contains text that is needed foranother record’s search text. For example, when saving a child recordthat contains search text that should be saved to its parent record.
Parameters: - $recordType (string) –
- $recordId (int) –
- $text (string) –
- $title (string) –
- $public (int) –
Mixin_Tag¶
- class Mixin_Tag¶
Package: Record\Mixin
- property _tagTable¶
- property _joinTable¶
- property _type¶
- __construct(Omeka_Record_AbstractRecord $record)¶
Parameters: - $record (Omeka_Record_AbstractRecord) –
- beforeDelete()¶
Fires whenever deleting a record that is taggable This will actually delete all the references to a specific tag for a specific record
Returns: void
- afterSave($args)¶
Add tags to this record’s search text.
Parameters: - $args (unknown) –
- deleteTaggings()¶
- getTaggings()¶
Retrieve all the Taggings objects that represent between a specific tag and the current record Called by whatever record has enabled this module
Returns: array of Taggings
- getTags($order = Array)¶
Get all the Tag records associated with this record
Parameters: - $order (unknown) –
Returns: array of Tag
- deleteTags(string|array $tags, string $delimiter)¶
Delete a tag from the record
Parameters: - $tags (string|array) – The tag name or array of tag names to delete from the record
- $delimiter (string) – The delimiter of the tags. Not applicable if $tags is an array
Returns: bool Returns whether a tag in $tags was deleted. Returns false if $tags is empty. Returns true if at least one tag in $tags is deleted.
- hasTag($tag)¶
If the $tag were a string and the keys of Tags were just the names of the tags, this would be: in_array(array_keys($this->Tags))
Parameters: - $tag (unknown) –
Returns: boolean
- _getTagsFromString(string $string, $delimiter)¶
Converts a delimited string of tags into an array of tag strings
Parameters: - $string (string) – A delimited string of tags
- $delimiter (unknown) –
Returns: array An array of tag strings
- addTags(array|string $tags, $delimiter)¶
Add tags for the record
Parameters: - $tags (array|string) – Either an array of tags or a delimited string
- $delimiter (unknown) –
Returns: void
- diffTagString($string, $tags, $delimiter)¶
Calculate the difference between a tag string and a set of tags
Parameters: - $string (unknown) –
- $tags (unknown) –
- $delimiter (unknown) –
Returns: array Keys(‘removed’,’added’)
- applyTagString(string $string, $delimiter)¶
This will add tags that are in the tag string and remove those that are no longer in the tag string
Parameters: - $string (string) – A string of tags delimited by $delimiter
- $delimiter (unknown) –
Returns: void
Mixin_Timestamp¶
- class Mixin_Timestamp¶
Package: Record\Mixin
Mixin for models that keep added and/or modified timestamps.
- property _record¶
- property _addedColumn¶
- property _modifiedColumn¶
- __construct(Omeka_Record_AbstractRecord $record, string $addedColumn = added, $modifiedColumn = modified)¶
Initialize the mixin.
Setting either of the column parameters to null will skip updating thattimestamp. The default column names are ‘updated’ and ‘added’.
Parameters: - $record (Omeka_Record_AbstractRecord) –
- $addedColumn (string) – Name of the column holding the “added” timestamp.
- $modifiedColumn (unknown) –
- beforeSave($args)¶
Before saving a record, set the “updated” timestamp.
Parameters: - $args (unknown) –
- _setTimestamp(string $column)¶
Update a timestamp column for the underlying record.
Parameters: - $column (string) – Column to update.
Models/Output¶
Output_CollectionOmekaXml¶
Output_FileOmekaXml¶
Output_ItemAtom¶
- class Output_ItemAtom¶
Package: Output
Model class for an Atom feed for a list of items.
- property _feed¶
- __construct(array $items)¶
Build the Atom feed using DOM.
Parameters: - $items (array) – An array of Item records.
Returns: void
- _getFeedLinks(array $items)¶
Returns the URLs, if any, for rel=self|next|previous links.
Parameters: - $items (array) –
Returns: array
- getFeed()¶
Returns the XML feed.
Returns: string
Output_ItemContainerOmekaXml¶
Output_ItemDcmesXml¶
Output_ItemOmekaXml¶
Output_ItemRss2¶
Output_OmekaJson¶
- class Output_OmekaJson¶
Package: Output
Generates JSON version of the omeka-xml output, as dictated by the JsonML XSLT.
- constant JSONML_XSLT_FILENAME¶
JsonML XML stylesheet filename
- toJson(Omeka_Output_OmekaXml_AbstractOmekaXml $omekaXml)¶
Convert omeka-xml output to JSON.
Parameters: - $omekaXml (Omeka_Output_OmekaXml_AbstractOmekaXml) –
Returns: string
Models/Table¶
Table_Collection¶
- class Table_Collection¶
Package: Db\Table
- applySearchFilters($select, $params)¶
Parameters: - $select (unknown) –
- $params (unknown) –
- _getColumnPairs()¶
- findPairsForSelectForm($options = Array)¶
Parameters: - $options (unknown) –
- getSelect()¶
Apply permissions checks to all SQL statements retrieving collections from the table
Returns: void
- findRandomFeatured()¶
- filterByPublic($select, $isPublic)¶
Apply a filter to the collections based on whether or not they are public
Parameters: - $select (unknown) –
- $isPublic (unknown) –
Returns: void
- filterByFeatured($select, $isFeatured)¶
Apply a filter to the collections based on whether or not they are featured
Parameters: - $select (unknown) –
- $isFeatured (unknown) –
Returns: void
- applySorting(Omeka_Db_Select $select, string $sortField, string $sortDir)¶
Enables sorting based on ElementSet,Element field strings.
Parameters: - $select (Omeka_Db_Select) –
- $sortField (string) – Field to sort on
- $sortDir (string) – Sorting direction (ASC or DESC)
Table_Element¶
- class Table_Element¶
Package: Db\Table
- findByRecordType($recordTypeName)¶
Find all the Element records that have a specific record type or the record type ‘All’, indicating that these elements would apply to any record type.
Parameters: - $recordTypeName (unknown) –
Returns: array
- getSelect()¶
Overriding getSelect() to always return the type_name and type_regex for retrieved elements.
Returns: Omeka_Db_Select
- _getColumnPairs()¶
Return the element’s name and id for <select> tags on it.
Returns: void
- orderElements($select)¶
Parameters: - $select (unknown) –
- findBySet($elementSet)¶
Retrieve all elements for a set.
Parameters: - $elementSet (unknown) –
Returns: Element
- findByItemType($itemTypeId)¶
Retrieve a set of Element records that belong to a specific Item Type.
Parameters: - $itemTypeId (unknown) –
Returns: array Set of element records.
- findByElementSetNameAndElementName($elementSetName, $elementName)¶
Parameters: - $elementSetName (unknown) –
- $elementName (unknown) –
- applySearchFilters(Omeka_Db_Select $select, array $params)¶
Manipulate a Select object based on a set of criteria.
Parameters: - $select (Omeka_Db_Select) –
- $params (array) –
Possible parameters include:
- record_types - array - Usually one or more of the following: All, Item, File
- sort - string - One of the following values: alpha
- element_set_name - string - Name of the element set to which results should belong.
- findPairsForSelectForm(array $options = Array)¶
Override parent class method to retrieve a multidimensional array of elements, organized by element set, to be used in Zend’s FormSelect view helper.
Parameters: - $options (array) – Set of parameters for searching/filtering results.
Returns: array
Table_ElementSet¶
- class Table_ElementSet¶
Package: Db\Table
- getSelect()¶
- findByRecordType($recordTypeName, $includeAll = 1)¶
Find all the element sets that correspond to a particular record type. If the second param is set, this will include all element sets that belong to the ‘All’ record type.
Parameters: - $recordTypeName (unknown) –
- $includeAll (unknown) –
Returns: array
- findByName($name)¶
Parameters: - $name (unknown) –
Table_ElementText¶
- class Table_ElementText¶
Package: Db\Table
- getSelectForRecord($recordId, $recordType)¶
Parameters: - $recordId (unknown) –
- $recordType (unknown) –
Returns: Omeka_Db_Select
- findByRecord(Omeka_Record_AbstractRecord $record)¶
Find all ElementText records for a given database record (Item, File, etc).
Parameters: - $record (Omeka_Record_AbstractRecord) –
Returns: array
- findByElement($elementId)¶
Parameters: - $elementId (unknown) –
Table_File¶
- class Table_File¶
Package: Db\Table
- property _target¶
- getSelect()¶
All files should only be retrieved if they join properly on the items table.
Returns: Omeka_Db_Select
- getRandomFileWithImage(integer $itemId)¶
Retrieve a random file with an image associated with an item.
Parameters: - $itemId (integer) –
Returns: File
- findByItem(integer $itemId, array $fileIds = Array, string $sort = order)¶
Retrieve files associated with an item.
Parameters: - $itemId (integer) –
- $fileIds (array) – Optional If given, this will only retrieve files with these specific IDs.
- $sort (string) – The manner by which to order the files. For example: ‘id’: file id, ‘filename’ = alphabetical by filename. The default is ‘order’, following the user’s specified order.
Returns: array
- findWithImages(integer $itemId, integer|null $index, string $sort = order)¶
Retrieve files for an item that has derivative images.
Parameters: - $itemId (integer) – The ID of the item to get images for.
- $index (integer|null) – Optional If given, this specifies the file to retrieve for an item, based upon the ordering of its files.
- $sort (string) – The manner by which to order the files. For example: ‘id’: file id, ‘filename’: alphabetical by filename. The default is ‘order’, following the user’s specified order.
Returns: File|array
- _orderFilesBy($select, string $sort)¶
Orders select results for files.
Parameters: - $select (unknown) –
- $sort (string) – The manner in which to order the files by. For example: ‘id’ = file id ‘filename’ = alphabetical by filename
Returns: void
Table_Item¶
- class Table_Item¶
Package: Db\Table
- filterByRange(Omeka_Db_Select $select, string $range)¶
Can specify a range of valid Item IDs or an individual ID
Parameters: - $select (Omeka_Db_Select) –
- $range (string) – Example: 1-4, 75, 89
Returns: void
- filterBySearch($select, $params)¶
Run the search filter on the SELECT statement
Parameters: - $select (unknown) –
- $params (unknown) –
Returns: void
- _simpleSearch(Zend_Db_Select $select, $terms)¶
Build the simple search.
The search query consists of a derived table that is INNER JOINed to themain SQL query. That derived table is a union of two SELECT queries. Thefirst query searches the FULLTEXT index on the items_elements table, andthe second query searches the tags table for every word in the searchterms and assigns each found result a rank of ‘1’. That should maketagged items show up higher on the found results list for a given search.
Parameters: - $select (Zend_Db_Select) –
- $terms (unknown) –
- _advancedSearch(Zend_Db_Select $select, $terms)¶
Build the advanced search.
Parameters: - $select (Zend_Db_Select) –
- $terms (unknown) –
- filterByPublic($select, $isPublic)¶
Apply a filter to the items based on whether or not they should be public
Parameters: - $select (unknown) –
- $isPublic (unknown) –
Returns: void
- filterByFeatured($select, $isFeatured)¶
Parameters: - $select (unknown) –
- $isFeatured (unknown) –
- filterByCollection($select, $collection)¶
Filter the SELECT statement based on an item’s collection
Parameters: - $select (unknown) –
- $collection (unknown) –
Returns: void
- filterByItemType($select, $type)¶
Filter the SELECT statement based on the item Type
Parameters: - $select (unknown) –
- $type (unknown) –
Returns: void
- filterByTags($select, $tags)¶
Query must look like the following in order to correctly retrieve items that have all the tags provided (in this example, all items that are tagged both ‘foo’ and ‘bar’):
SELECT i.idFROM omeka_items iWHERE(i.id IN(SELECT tg.record_id as idFROM omeka_records_tags tgINNER JOIN omeka_tags t ON t.id = tg.tag_idWHERE t.name = ‘foo’ AND tg.record_type = ‘Item’)AND i.id IN(SELECT tg.record_id as idFROM omeka_records_tags tgINNER JOIN omeka_tags t ON t.id = tg.tag_idWHERE t.name = ‘bar’ AND tg.record_type = ‘Item’))...
Parameters: - $select (unknown) –
- $tags (unknown) –
Returns: void
- filterByUser($select, integer $userId, $isUser = 1)¶
Filter the SELECT based on the user who owns the item
Parameters: - $select (unknown) –
- $userId (integer) – ID of the User to filter by
- $isUser (unknown) –
Returns: void
- filterByExcludedTags($select, $tags)¶
Filter SELECT statement based on items that are not tagged with a specific set of tags
Parameters: - $select (unknown) –
- $tags (unknown) –
Returns: void
- filterByHasDerivativeImage($select, boolean $hasDerivativeImage = 1)¶
Filter SELECT statement based on whether items have a derivative image file.
Parameters: - $select (unknown) –
- $hasDerivativeImage (boolean) – Whether items should have a derivative image file.
Returns: void
- applySearchFilters($select, $params)¶
Possible options: ‘public’,’user’,’featured’,’collection’,’type’,’tag’, ‘excludeTags’, ‘search’, ‘range’, ‘advanced’, ‘hasImage’,
Parameters: - $select (unknown) –
- $params (unknown) –
Returns: void
- applySorting(Omeka_Db_Select $select, string $sortField, string $sortDir)¶
Enables sorting based on ElementSet,Element field strings.
Parameters: - $select (Omeka_Db_Select) –
- $sortField (string) – Field to sort on
- $sortDir (string) – Sorting direction (ASC or DESC)
- getSelect()¶
This is a kind of simple factory that spits out proper beginnings of SQL statements when retrieving items
Returns: Omeka_Db_Select
- findFirst()¶
Return the first item accessible to the current user.
Returns: Item|null
- findLast()¶
Return the last item accessible to the current user.
Returns: Item|null
- findPrevious($item)¶
Parameters: - $item (unknown) –
- findNext($item)¶
Parameters: - $item (unknown) –
- findNearby($item, $position = next)¶
Parameters: - $item (unknown) –
- $position (unknown) –
Table_ItemType¶
Table_ItemTypesElements¶
Table_Plugin¶
Table_Process¶
Table_RecordsTags¶
Table_SearchText¶
Table_Tag¶
- class Table_Tag¶
Package: Db\Table
- findOrNew($name)¶
Parameters: - $name (unknown) –
- filterByRecord($select, $record)¶
Filter a SELECT statement based on an Omeka_Record_AbstractRecord instance
Parameters: - $select (unknown) –
- $record (unknown) –
Returns: void
- applySorting(Omeka_Db_Select $select, string $sortField, string $sortDir)¶
Apply custom sorting for tags.
This also applies the normal, built-in sorting.
Parameters: - $select (Omeka_Db_Select) –
- $sortField (string) – Sorting field.
- $sortDir (string) – Sorting direction, suitable for direct inclusion in SQL (ASC or DESC).
- filterByTagType($select, $type)¶
Filter SELECT statement based on the type of tags to view (Item, Exhibit, etc.)
Parameters: - $select (unknown) –
- $type (unknown) –
Returns: void
- filterByTagNameLike($select, $partialTagName)¶
Filter SELECT statement based on whether the tag contains the partial tag name
Parameters: - $select (unknown) –
- $partialTagName (unknown) –
Returns: void
- applySearchFilters($select, array $params = Array)¶
Retrieve a certain number of tags
Parameters: - $select (unknown) –
- $params (array) – ‘limit’ => integer ‘record’ => instanceof Omeka_Record_AbstractRecord ‘like’ => partial_tag_name ‘type’ => tag_type
Returns: void
- getSelect()¶
Returns: Omeka_Db_Select
- findTagNamesLike($partialName, $limit = 10)¶
Parameters: - $partialName (unknown) –
- $limit (unknown) –
Table_User¶
- class Table_User¶
Package: Db\Table
- findActiveById($id)¶
Find an active User given that user’s ID.
Returns null if the user being requested is not active.
Parameters: - $id (unknown) –
Returns: User|null
- _getColumnPairs()¶
- findByEmail($email)¶
Parameters: - $email (unknown) –
- applySearchFilters($select, $params)¶
Parameters: - $select (unknown) –
- $params (unknown) –
View Helpers¶
Omeka_View_Helper_AllElementTexts¶
- class Omeka_View_Helper_AllElementTexts¶
Package: View\Helper
View helper for retrieving lists of metadata for any record that uses Mixin_ElementText.
- property _record¶
The record being printed.
- property _showEmptyElements¶
Flag to indicate whether to show elements that do not have text.
- property _emptyElementString¶
String to display if elements without text are shown.
- property _elementSetsToShow¶
Element sets to list.
- property _returnType¶
Type of data to return.
- property _partial¶
Path for the view partial.
- allElementTexts(Omeka_Record_AbstractRecord|string $record, array $options = Array)¶
Get the record metadata list.
Parameters: - $record (Omeka_Record_AbstractRecord|string) – Record to retrieve metadata from.
- $options (array) – Available options: - show_empty_elements’ => bool|string Whether to show elements that do not contain text. A string will set self::$_showEmptyElements to true and set self::$_emptyElementString to the provided string. - ‘show_element_sets’ => array List of names of element sets to display. - ‘return_type’ => string ‘array’, ‘html’. Defaults to ‘html’.
Returns: string|array
- _setOptions(array $options)¶
Set the options.
Parameters: - $options (array) –
Returns: void
- _getElementsBySet()¶
Get an array of all element sets containing their respective elements.
Returns: array
- _filterItemTypeElements(array $elementsBySet)¶
Filter the display of the Item Type element set, if present.
Parameters: - $elementsBySet (array) –
Returns: array
- _elementIsShowable(Element $element, array $texts)¶
Determine if an element is allowed to be shown.
Parameters: - $element (Element) –
- $texts (array) –
Returns: boolean
- _getFormattedElementTexts(Omeka_Record_AbstractRecord $record, array $metadata)¶
Return a formatted version of all the texts for the requested element.
Parameters: - $record (Omeka_Record_AbstractRecord) –
- $metadata (array) –
Returns: array
- _getOutputAsHtml()¶
Output the default HTML format for displaying record metadata.
Returns: string
- _getOutputAsArray()¶
Get the metadata list as a PHP array.
Returns: array
- _getOutput()¶
Get the metadata list.
Returns: string|array
- _loadViewPartial(array $vars = Array)¶
Load a view partial to display the data.
Parameters: - $vars (array) – Variables to pass to the partial.
Returns: string
Omeka_View_Helper_ElementForm¶
- class Omeka_View_Helper_ElementForm¶
Package: View\Helper
Generate the form markup for entering element text metadata.
- property _element¶
Displays a form for the record’s element.
The function applies filters that allow plugins to customize the display of element form components. Here is an example of how a plugin may add and implement an element form filter:
add_filter(array(‘ElementForm’, ‘Item’, ‘Dublin Core’, ‘Title’)), ‘form_item_title’);function form_item_title(array $components, $args){
// Where $components would looks like:// array(// ‘label’ => [...],// ‘inputs’ => [...],// ‘description’ => [...],// ‘comment’ => [...],// ‘add_input’ => [...],// )// and $args looks like:// array(// ‘record’ => [...],// ‘element’ => [...],// ‘options’ => [...],// )}
- property _record¶
- elementForm(Element $element, Omeka_Record_AbstractRecord $record, $options = Array)¶
Parameters: - $element (Element) –
- $record (Omeka_Record_AbstractRecord) –
- $options (unknown) –
- _getFieldLabel()¶
- _getFieldDescription()¶
- _getFieldComment()¶
- _isPosted()¶
- _getPostArray()¶
- _getFormFieldCount()¶
How many form inputs to display for a given element.
Returns: integer
- _getPostValueForField($index)¶
Parameters: - $index (unknown) –
Returns: mixed
- _getHtmlFlagForField($index)¶
Parameters: - $index (unknown) –
- _getValueForField($index)¶
Retrieve the form value for the field.
Parameters: - $index (unknown) –
Returns: string
- getElementTexts($index)¶
If index is not given, return all texts.
Parameters: - $index (unknown) –
Returns: void
- _getInputsComponent($extraFieldCount)¶
Parameters: - $extraFieldCount (unknown) –
- _getDescriptionComponent()¶
- _getCommentComponent()¶
- _getLabelComponent()¶
Omeka_View_Helper_ElementInput¶
- class Omeka_View_Helper_ElementInput¶
Package: View\Helper
Generate the form markup for entering one HTML input for an Element.
- property _element¶
Element record to display the input for.
- property _record¶
Omeka_Record_AbstractRecord to display the input for.
- elementInput(Element $element, Omeka_Record_AbstractRecord $record, int $index = 0, string $value =, bool $isHtml =)¶
Display one form input for an Element.
Parameters: - $element (Element) – The Element to display the input for.
- $record (Omeka_Record_AbstractRecord) – The record to display the input for.
- $index (int) – The index of this input. (starting at zero).
- $value (string) – The default value of this input.
- $isHtml (bool) – Whether this input’s value is HTML.
Returns: string
- _getInputComponent(string $inputNameStem, string $value)¶
Get the actual HTML input for this Element.
Parameters: - $inputNameStem (string) –
- $value (string) –
Returns: string
- _getControlsComponent()¶
Get the button that will allow a user to remove this form input. The submit input has a class of ‘add-element’, which is used by the Javascript to do stuff.
Returns: string
- _getHtmlCheckboxComponent(string $inputNameStem, bool $isHtml)¶
Get the HTML checkbox that lets users toggle the editor.
Parameters: - $inputNameStem (string) –
- $isHtml (bool) –
Returns: string
Omeka_View_Helper_FileId3Metadata¶
- class Omeka_View_Helper_FileId3Metadata¶
Package: View\Helper
Helper used to retrieve file metadata for display.
- fileId3Metadata($file, $options)¶
Parameters: - $file (unknown) –
- $options (unknown) –
- _arrayToList($array)¶
Parameters: - $array (unknown) –
Omeka_View_Helper_FileMarkup¶
- class Omeka_View_Helper_FileMarkup¶
Package: View\Helper
View Helper for displaying files through Omeka.
This will determine how to display any given file based on the MIME type(Internet media type) of that file. Individual rendering agents are definedby callbacks that are either contained within this class or defined byplugins. Callbacks defined by plugins will override native class methods ifdefined for existing MIME types. In order to define a rendering callback thatshould be in the core of Omeka, define a method in this class and then makesure that it responds to all the correct MIME types by modifying otherproperties in this class.
- property _callbacks¶
Array of MIME types and the callbacks that can process it.
Example:array(‘video/avi’=>’wmv’);
- property _fileExtensionCallbacks¶
Array of file extensions and the callbacks that can process them.
Taken from http://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types
- property _callbackOptions¶
The array consists of the default options which are passed to the callback.
- addMimeTypes(array|string $fileIdentifiers, $callback, array $defaultOptions = Array)¶
Add MIME types and/or file extensions and associated callbacks to the list.
This allows plugins to override/define ways of displaying specific files.The most obvious example of where this would come in handy is to defineways of displaying uncommon files, such as QTVR, or novel ways ofdisplaying more common files, such as using iPaper to display PDFs.
Parameters: - $fileIdentifiers (array|string) –
Set of MIME types (Internet media types) and/or file extensions that this specific callback will respond to. Accepts the following:
- A string containing one MIME type:
'application/msword'
- A simple array containing MIME types:
array('application/msword', 'application/doc')
- A keyed array containing MIME types:
array('mimeTypes' => array('application/msword', 'application/doc'))
- A keyed array containing file extensions:
array('fileExtensions' => array('doc', 'docx''DOC', 'DOCX'))
- A keyed array containing MIME types and file extensions:
array( 'mimeTypes' => array( 'application/msword', 'application/doc', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', ), 'fileExtensions' => array('doc', 'docx', 'DOC', 'DOCX'), )
Note that file extensions are case sensitive.
- A string containing one MIME type:
- $callback (unknown) –
- $defaultOptions (array) –
Returns: void
- $fileIdentifiers (array|string) –
- defaultDisplay(File $file, array $options = Array)¶
Default display for MIME types that do not have a valid rendering callback.
This wraps the original filename in a link to download that file, with aclass of “download-file”. Any behavior more complex than that should beprocessed with a valid callback.
Parameters: - $file (File) –
- $options (array) –
Returns: string HTML
- _linkToFile(File $file, array $options, string $html)¶
Add a link for the file based on the given set of options.
If the ‘linkToMetadata’ option is true, then link to the filemetadata page (files/show). If ‘linkToFile’ is true,link to the original file, and if ‘linkToFile’ is a string, tryto link to that specific derivative. Otherwise just return the$html without wrapping in a link.
The attributes for the link will be based off the ‘linkAttributes’ option, which should be an array.
If $html is null, it defaults to original filename of the file.
Parameters: - $file (File) –
- $options (array) –
- $html (string) –
Returns: string
- wmv(File $file, array $options = Array)¶
Retrieve valid XHTML for displaying a wmv video file or equivalent. Currently this loads the video inside of an <object> tag, but that provides less flexibility than a flash wrapper, which seems to be a standard Web2.0 practice for video sharing. This limitation can be overcome by a plugin that used a flash wrapper for displaying video.
Parameters: - $file (File) –
- $options (array) –
Returns: string
- wma(File $file, array $options = Array)¶
Retrieve valid XHTML for displaying a wma audio file or equivalent. Currently this loads the video inside of an <object> tag, but that provides less flexibility than a flash wrapper, which seems to be a standard Web2.0 practice for video sharing. This limitation can be overcome by a plugin that used a flash wrapper for displaying video.
Parameters: - $file (File) –
- $options (array) –
Returns: string
- mov(File $file, array $options = Array)¶
Retrieve valid XHTML for displaying Quicktime video files
Parameters: - $file (File) –
- $options (array) – The set of default options for this includes: width, height, autoplay, controller, loop
Returns: string
- _audio(File $file, array $options, string $type)¶
Default display of audio files via <object> tags.
Parameters: - $file (File) –
- $options (array) – The set of default options for this includes: width, height, autoplay, controller, loop
- $type (string) – The Internet media type of the file
Returns: string
- ogg(File $file, array $options = Array)¶
Display OGG audio files.
Parameters: - $file (File) –
- $options (array) –
Returns: string
- mp3(File $file, array $options = Array)¶
Display MP3/MPEG audio files.
Parameters: - $file (File) –
- $options (array) –
Returns: string
- aac(File $file, array $options = Array)¶
Display AAC audio files.
Parameters: - $file (File) –
- $options (array) –
Returns: string
- aiff(File $file, array $options = Array)¶
Display AIFF audio files.
Parameters: - $file (File) –
- $options (array) –
Returns: string
- midi(File $file, array $options = Array)¶
Display MIDI audio files.
Parameters: - $file (File) –
- $options (array) –
Returns: string
- mp4(File $file, array $options = Array)¶
Display MP4 audio files.
Parameters: - $file (File) –
- $options (array) –
Returns: string
- wav(File $file, array $options = Array)¶
Display WAV audio files.
Parameters: - $file (File) –
- $options (array) –
Returns: string
- icon($file, array $options = Array)¶
Default display of an icon to represent a file.
Example usage:
echo files_for_item(array(‘showFilename’=>false,’linkToFile’=>false,’linkAttributes’=>array(‘rel’=>’lightbox’),’filenameAttributes’=>array(‘class’=>’error’),’imgAttributes’=>array(‘id’=>’foobar’),’icons’ => array(‘audio/mpeg’=>img(‘audio.gif’))));
Parameters: - $file (unknown) –
- $options (array) – Available options include: ‘showFilename’ => boolean, ‘linkToFile’ => boolean, ‘linkAttributes’ => array, ‘filenameAttributes’ => array (for the filename div), ‘imgAttributes’ => array, ‘icons’ => array.
Returns: string
- derivativeImage(File $file, $options = Array)¶
Returns valid XHTML markup for displaying an image that has been stored in Omeka.
Parameters: - $file (File) – Options for customizing the display of images. Current options include: ‘imageSize’
- $options (unknown) –
Returns: string HTML for display
- getCallback($file, $options)¶
Parameters: - $file (unknown) –
- $options (unknown) –
- getDefaultOptions(mixed $callback)¶
Parameters: - $callback (mixed) –
Returns: array
- getHtml(File $file, callback $renderer, array $options)¶
Retrieve the HTML for a given file from the callback.
Parameters: - $file (File) –
- $renderer (callback) – Any valid callback that will display the HTML.
- $options (array) – Set of options passed to the rendering callback.
Returns: string HTML for displaying the file.
- fileMarkup(File $file, array $props = Array, array $wrapperAttributes = Array)¶
Bootstrap for the helper class. This will retrieve the HTML for displaying the file and by default wrap it in a <div class=”item-file”>.
Parameters: - $file (File) –
- $props (array) – Set of options passed by a theme writer to the customize the display of any given callback.
- $wrapperAttributes (array) –
Returns: string HTML
- image_tag(File|Item $record, array $props, string $format)¶
Return a valid img tag for an image.
Parameters: - $record (File|Item) –
- $props (array) –
- $format (string) –
Returns: string
- _getCallbackKey(callback $callback)¶
Get a string key to represent a given callback.
This key can be used to store and retrieve data about thecallback, like default options.
Parameters: - $callback (callback) –
Returns: string
Omeka_View_Helper_Flash¶
- class Omeka_View_Helper_Flash¶
Package: View\Helper
View helper to display messages from FlashMessenger.
- property _flashMessenger¶
- __construct()¶
- flash()¶
Display messages from the FlashMessenger.
Returns: string HTML for messages.
- _getListHtml(string $status, string $message)¶
Get the HTML for a message.
Parameters: - $status (string) –
- $message (string) –
Returns: string
Omeka_View_Helper_GetCurrentRecord¶
- class Omeka_View_Helper_GetCurrentRecord¶
Package: View\Helper
- getCurrentRecord(string $recordVar, bool $throwException = 1)¶
Get the current record from the view.
Parameters: - $recordVar (string) –
- $throwException (bool) –
Returns: Omeka_Record_AbstractRecord|false
Omeka_View_Helper_GetLoopRecords¶
- class Omeka_View_Helper_GetLoopRecords¶
Package: View\Helper
- getLoopRecords(string $recordsVar, $throwException = 1)¶
Get records from the view for iteration.
Note that this method will return an empty array if it is set to therecords variable. Use Omeka_View_Helper_HasLoopRecords::hasLoopRecords()to check if records exist.
Parameters: - $recordsVar (string) –
- $throwException (unknown) –
Returns: array|bool
Omeka_View_Helper_HasLoopRecords¶
- class Omeka_View_Helper_HasLoopRecords¶
Package: View\Helper
- hasLoopRecords(string $recordsVar)¶
Check if records have been set to the view for iteration.
Note that this method will return false if the records variable is setbut is an empty array, unlike Omeka_View_Helper_GetLoopRecords::getLoopRecords(),which will return the empty array.
Parameters: - $recordsVar (string) –
Returns: bool
Omeka_View_Helper_ItemSearchFilters¶
- class Omeka_View_Helper_ItemSearchFilters¶
Package: View\Helper
Show the currently-active filters for a search/browse.
- itemSearchFilters(array $params)¶
Get a list of the currently-active filters for item browse/search.
Parameters: - $params (array) – Optional array of key-value pairs to use instead of reading the current params from the request.
Returns: string HTML output
Omeka_View_Helper_Loop¶
- class Omeka_View_Helper_Loop¶
Package: View\Helper
- loop(string $recordsVar, array|null $records)¶
Return an iterator used for looping an array of records.
Parameters: - $recordsVar (string) –
- $records (array|null) –
Returns: Omeka_Record_Iterator
Omeka_View_Helper_MaxFileSize¶
- class Omeka_View_Helper_MaxFileSize¶
Package: View\Helper
- property _maxFileSize¶
- __construct()¶
Set the maximum file size.
The maximum file size is the least of the configurations that affect maximum file size.
- maxFileSize()¶
Return the maximum file size.
Returns: Zend_Measure_Binary
- _getSizeMeasure(string|int $size)¶
Get the binary measurements for file size.
Parameters: - $size (string|int) –
Returns: Zend_Measure_Binary
Omeka_View_Helper_Metadata¶
- class Omeka_View_Helper_Metadata¶
Package: View\Helper
Helper used to retrieve record metadata for for display.
- property _record¶
- property _metadata¶
- metadata(Omeka_Record_AbstractRecord $record, string|array $metadata, array|string|integer $options = Array)¶
Retrieve a specific piece of a record’s metadata for display.
Parameters: - $record (Omeka_Record_AbstractRecord) – Database record representing the item from which to retrieve field data.
- $metadata (string|array) – The metadata field to retrieve. If a string, refers to a property of the record itself. If an array, refers to an Element: the first entry is the set name, the second is the element name.
- $options (array|string|integer) – Options for formatting the metadata for display. - Array options: - ‘all’: If true, return an array containing all values for the field. - ‘delimiter’: Return the entire set of metadata as a string, where entries are separated by the given delimiter. - ‘index’: Return the metadata entry at the given zero-based index. - ‘no_escape’ => If true, do not escape the resulting values for HTML entities. - ‘no_filter’: If true, return the set of metadata without running any of the filters. - ‘snippet’: Trim the length of each piece of text to the given length in characters. - Passing simply the string ‘all’ is equivalent to array(‘all’ => true) - Passing simply an integer is equivalent to array(‘index’ => [the integer])
Returns: string|array|null Null if field does not exist for item. Array if certain options are passed. String otherwise.
- _getOptions(string|integer|array $options)¶
Options can sometimes be an integer or a string instead of an array, which functions as a handy shortcut for theme writers. This converts the short form of the options into its proper array form.
Parameters: - $options (string|integer|array) –
Returns: array
- _getText(Omeka_Record_AbstractRecord $record, string|array $metadata)¶
Retrieve the text associated with a given element or field of the record.
Parameters: - $record (Omeka_Record_AbstractRecord) –
- $metadata (string|array) –
Returns: string|array Either an array of ElementText records or a string.
- _getRecordMetadata(Omeka_Record_AbstractRecord $record, string $specialValue)¶
Retrieve record metadata that is not stored as ElementTexts.
Parameters: - $record (Omeka_Record_AbstractRecord) –
- $specialValue (string) – Field name.
Returns: mixed
- _getElementText(Omeka_Record_AbstractRecord $record, string $elementSetName, string $elementName)¶
Retrieve the set of ElementText records that correspond to a given element set and element.
Parameters: - $record (Omeka_Record_AbstractRecord) –
- $elementSetName (string) –
- $elementName (string) –
Returns: array Set of ElementText records.
- _process(string|ElementText $text, int|bool $snippet, bool $escape, bool $filter)¶
Process an individual piece of text.
If given an ElementText record, the actual text string will beextracted automatically.
Parameters: - $text (string|ElementText) – Text to process.
- $snippet (int|bool) – Snippet length, or false if no snippet.
- $escape (bool) – Whether to HTML escape the text.
- $filter (bool) – Whether to pass the output through plugin filters.
Returns: string
- _filterText(string $text, ElementText|bool $elementText)¶
Apply filters to a text value.
Parameters: - $text (string) –
- $elementText (ElementText|bool) –
Returns: string
Omeka_View_Helper_Pluralize¶
- class Omeka_View_Helper_Pluralize¶
Package: View\Helper
- pluralize($var)¶
Parameters: - $var (unknown) –
Omeka_View_Helper_RecordUrl¶
- class Omeka_View_Helper_RecordUrl¶
Package: View\Helper
- recordUrl(Omeka_Record_AbstractRecord|string $record, string|null $action, bool $getAbsoluteUrl =)¶
Return a URL to a record.
Parameters: - $record (Omeka_Record_AbstractRecord|string) –
- $action (string|null) –
- $getAbsoluteUrl (bool) –
Returns: string
Omeka_View_Helper_SearchFilters¶
- class Omeka_View_Helper_SearchFilters¶
Package: View\Helper
Return a list of search filters in the current request.
- searchFilters(array $options = Array)¶
Return a list of current search filters in use.
Parameters: - $options (array) – Valid options are as follows: - id (string): the ID of the filter wrapping div.
Returns: string
Omeka_View_Helper_SearchForm¶
- class Omeka_View_Helper_SearchForm¶
Package: View\Helper
Return the site-wide search form.
- searchForm(array $options = Array)¶
Return the site-wide search form.
Parameters: - $options (array) – Valid options are as follows: - show_advanced: whether to show the advanced search; default is false. - submit_value: the value of the submit button; default “Submit”. - form_attributes: an array containing form tag attributes.
Returns: string The search form markup.
Omeka_View_Helper_SetCurrentRecord¶
- class Omeka_View_Helper_SetCurrentRecord¶
Package: View\Helper
- setCurrentRecord(string $recordVar, Omeka_Record_AbstractRecord $record, bool $setPreviousRecord =)¶
Set a record to the view as the current record.
Parameters: - $recordVar (string) –
- $record (Omeka_Record_AbstractRecord) –
- $setPreviousRecord (bool) –
Omeka_View_Helper_SetLoopRecords¶
- class Omeka_View_Helper_SetLoopRecords¶
Package: View\Helper
- setLoopRecords(string $recordsVar, array $records)¶
Set records to the view for iteration.
Parameters: - $recordsVar (string) –
- $records (array) –
Omeka_View_Helper_Singularize¶
- class Omeka_View_Helper_Singularize¶
Package: View\Helper
- singularize($var)¶
Parameters: - $var (unknown) –
Omeka_View_Helper_Url¶
- class Omeka_View_Helper_Url¶
Package: View\Helper
- url($options = Array, $name, $queryParams = Array, $reset =, $encode = 1)¶
Generate a URL for use in one of Omeka’s view templates.
There are two ways to use this method. The first way is for backwardscompatibility with older versions of Omeka as well as ease of use fortheme writers.
Here is an example of what URLs are generated by calling the function indifferent ways. The output from these examples assume that Omeka isrunning on the root of a particular domain, though that is of noimportance to how the function works.
echo $this->url('items/browse'); // outputs "/items/browse"
echo $this->url(‘items/browse’, array(‘tags’=>’foo’)); // outputs “/items/browse?tags=foo”
echo $this->url(array(‘controller’=>’items’, ‘action’=>’browse’)); // outputs “/items/browse”
echo $this->url(array(‘controller’=>’items’, ‘action’=>’browse’),’otherRoute’,array(‘tags’=>’foo’),);// outputs “/miscellaneous?tags=foo”</code>
The first example takes a URL string exactly as one would expect it tobe. This primarily exists for ease of use by theme writers. The secondexample appends a query string to the URL by passing it as an array. Notethat in both examples, the first string must be properly URL-encoded inorder to work. url(‘foo bar’) would not work because of the space.
In the third example, the URL is being built directly from parameterspassed to it. For more details on this, please see the Zend Framework’sdocumentation.
In the last example, ‘otherRoute’ is the name of the route being used, asdefined either in the routes.ini file or via a plugin. For examples ofhow to add routes via a plugin, please see Omeka’s documentation.
Parameters: - $options (unknown) –
- $name (unknown) –
- $queryParams (unknown) –
- $reset (unknown) –
- $encode (unknown) –
Controllers¶
AppearanceController¶
- class AppearanceController¶
Package: Controller
- indexAction()¶
- browseAction()¶
- editSettingsAction()¶
CollectionsController¶
- class CollectionsController¶
Package: Controller
- property contexts¶
- property _browseRecordsPerPage¶
- init()¶
- browseAction()¶
The browse collections action.
- showAction()¶
The show collection action
- addAction()¶
The add collection action
- editAction()¶
The edit collection action
- _getAddSuccessMessage($collection)¶
Parameters: - $collection (unknown) –
- _getEditSuccessMessage($collection)¶
Parameters: - $collection (unknown) –
- _getDeleteSuccessMessage($collection)¶
Parameters: - $collection (unknown) –
- _getDeleteConfirmMessage($collection)¶
Parameters: - $collection (unknown) –
- _getElementMetadata($collection, $elementSetName, $elementName)¶
Parameters: - $collection (unknown) –
- $elementSetName (unknown) –
- $elementName (unknown) –
- _getCollectionElementSets()¶
Gets the element sets for the ‘Collection’ record type.
Returns: array The element sets for the ‘Collection’ record type
ElementSetsController¶
- class ElementSetsController¶
Package: Controller
- init()¶
- _getDeleteConfirmMessage($record)¶
Parameters: - $record (unknown) –
- addAction()¶
Can’t add element sets via the admin interface, so disable these actions from being POST’ed to.
Returns: void
- editAction()¶
- _redirectAfterEdit($record)¶
Parameters: - $record (unknown) –
ElementsController¶
- class ElementsController¶
Package: Controller
- elementFormAction()¶
ErrorController¶
- class ErrorController¶
Package: Controller
- errorAction()¶
- _getException()¶
- notFoundAction()¶
Generic action to render a 404 page.
Returns: void
- forbiddenAction()¶
- methodNotAllowedAction()¶
- logException($e, $priority)¶
Parameters: - $e (unknown) –
- $priority (unknown) –
- is404(Exception $e, $handler)¶
Check to see whether the error qualifies as a 404 error
Parameters: - $e (Exception) –
- $handler (unknown) –
Returns: boolean
- is403(Exception $e)¶
Parameters: - $e (Exception) –
- renderException(Exception $e)¶
Parameters: - $e (Exception) –
- isInDebugMode()¶
FilesController¶
IndexController¶
- class IndexController¶
Package: Controller
- indexAction()¶
ItemTypesController¶
- class ItemTypesController¶
Package: Controller
- init()¶
- addAction()¶
- editAction()¶
- addNewElementAction()¶
- addExistingElementAction()¶
- changeExistingElementAction()¶
- _redirectAfterAdd($itemType)¶
Parameters: - $itemType (unknown) –
- _getDeleteConfirmMessage($itemType)¶
Parameters: - $itemType (unknown) –
- _getAddSuccessMessage($itemType)¶
Parameters: - $itemType (unknown) –
- _getForm($itemType)¶
Parameters: - $itemType (unknown) –
ItemsController¶
- class ItemsController¶
Package: Controller
- property contexts¶
- property _ajaxRequiredActions¶
- property _methodRequired¶
- init()¶
- preDispatch()¶
- searchAction()¶
This shows the search form for items by going to the correct URI.
This form can be loaded as a partial by calling items_search_form().
Returns: void
- _getItemElementSets()¶
Gets the element sets for the ‘Item’ record type.
Returns: array The element sets for the ‘Item’ record type
- editAction()¶
Adds an additional permissions check to the built-in edit action.
- _getAddSuccessMessage($item)¶
Parameters: - $item (unknown) –
- _getEditSuccessMessage($item)¶
Parameters: - $item (unknown) –
- _getDeleteSuccessMessage($item)¶
Parameters: - $item (unknown) –
- _getDeleteConfirmMessage($item)¶
Parameters: - $item (unknown) –
- _getElementMetadata($item, $elementSetName, $elementName)¶
Parameters: - $item (unknown) –
- $elementSetName (unknown) –
- $elementName (unknown) –
- addAction()¶
Finds all tags associated with items (used for tag cloud)
Returns: void
- browseAction()¶
Browse the items. Encompasses search, pagination, and filtering of request parameters. Should perhaps be split into a separate mechanism.
Returns: void
- _getBrowseRecordsPerPage()¶
Retrieve the number of items to display on any given browse page. This can be modified as a query parameter provided that a user is actually logged in.
Returns: integer
- changeTypeAction()¶
Find or create an item for this mini-form
- batchEditAction()¶
Batch editing of Items. If this is an AJAX request, it will render the ‘batch-edit’ as a partial.
Returns: void
- batchEditSaveAction()¶
Processes batch edit information. Only accessible via POST.
Returns: void
- paginationAction()¶
Goes to results page based off value in text input.
PluginsController¶
- class PluginsController¶
Package: Controller
- init()¶
- configAction()¶
Load the configuration form for a specific plugin. That configuration form will be POSTed back to this URL and processed by the plugin.
Returns: void
- installAction()¶
- activateAction()¶
Action to activate a plugin
Returns: void
- deactivateAction()¶
Action to deactivate a plugin
Returns: void
- upgradeAction()¶
- browseAction()¶
Action to browse plugins
Returns: void
- uninstallAction()¶
Action to uninstall a plugin
Returns: void
- deleteAction()¶
- addAction()¶
- _getPluginByName(boolean $create =)¶
Retrieve the Plugin record based on the name passed via the request.
Parameters: - $create (boolean) – Whether or not the plugin object should be created if it has not already been loaded.
RedirectorController¶
- class RedirectorController¶
Package: Controller
- indexAction()¶
SearchController¶
- class SearchController¶
Package: Controller
- init()¶
- indexAction()¶
- _getBrowseRecordsPerPage()¶
Return the number of results to display per page.
An authorized user can modify this using the “per_page” query parameter.
Returns: int
SettingsController¶
- class SettingsController¶
Package: Controller
- indexAction()¶
- browseAction()¶
- editSettingsAction()¶
- editSecurityAction()¶
- editSearchAction()¶
- editItemTypeElementsAction()¶
- checkImagemagickAction()¶
Determine whether or not ImageMagick has been correctly installed and configured.
In a few cases, this will indicate failure even though the ImageMagickprogram works properly. In those cases, users may ignore the results ofthis test. This is because the ‘convert’ command may have returned anon-zero status code for some reason. Keep in mind that a 0 status codealways indicates success.
Returns: boolean True if the command line return status is 0 when attempting to run ImageMagick’s convert utility, false otherwise.
- getFileExtensionWhitelistAction()¶
- getFileMimeTypeWhitelistAction()¶
- getHtmlPurifierAllowedHtmlElementsAction()¶
- getHtmlPurifierAllowedHtmlAttributesAction()¶
SystemInfoController¶
TagsController¶
ThemesController¶
- class ThemesController¶
Package: Controller
- browseAction()¶
- switchAction()¶
- configAction()¶
Load the configuration form for a specific theme. That configuration form will be POSTed back to this URL.
Returns: void
UpgradeController¶
- class UpgradeController¶
Package: Controller
- __construct(Zend_Controller_Request_Abstract $request, Zend_Controller_Response_Abstract $response, $invokeArgs = Array)¶
Parameters: - $request (Zend_Controller_Request_Abstract) –
- $response (Zend_Controller_Response_Abstract) –
- $invokeArgs (unknown) –
- indexAction()¶
- migrateAction()¶
Run the migration script, obtain any success/error output and display it in a pretty way
Returns: void
UsersController¶
- class UsersController¶
Package: Controller
- property _publicActions¶
Actions that are accessible by anonymous users.
- property _browseRecordsPerPage¶
- init()¶
- _handlePublicActions()¶
Peform common processing for the publicly accessible actions.
Set a view script variable for header and footer view scripts and don’t allow logged-in users access.
The script variables are set for actions in $_publicActions, so the scripts for those actions should use these variables.
- forgotPasswordAction()¶
Send an email providing a link that allows the user to reset their password.
- _sendResetPasswordEmail($toEmail, $activationCode)¶
Parameters: - $toEmail (unknown) –
- $activationCode (unknown) –
- activateAction()¶
- addAction()¶
Returns: void
- editAction()¶
Similar to ‘add’ action, except this requires a pre-existing record.
The ID For this record must be passed via the ‘id’ parameter.
Returns: void
- _getDeleteSuccessMessage($record)¶
Parameters: - $record (unknown) –
- _getDeleteConfirmMessage($record)¶
Parameters: - $record (unknown) –
- sendActivationEmail(User $user)¶
Send an activation email to a new user telling them how to activate their account.
Parameters: - $user (User) –
Returns: boolean True if the email was successfully sent, false otherwise.
- loginAction()¶
- getLoginErrorMessages(Zend_Auth_Result $result)¶
This exists to customize the messages that people see when their attempt to login fails. ZF has some built-in default messages, but it seems like those messages may not make sense to a majority of people using the software.
Parameters: - $result (Zend_Auth_Result) –
Returns: string
- logoutAction()¶
- _getLog()¶
Controllers/helpers¶
Omeka_Controller_Action_Helper_Acl¶
- class Omeka_Controller_Action_Helper_Acl¶
Package: Controller\ActionHelper
Leverages the ACL to automatically check permissions for the current controller/action combo.
- property _acl¶
ACL object.
- property _currentUser¶
User record corresponding to the logged-in user, otherwise null.
- property _allowed¶
Temporarily allowed permissions.
- property _autoloadResourceObject¶
Whether we should automatically try to set the resource object.
- __construct(Zend_Acl $acl, $currentUser)¶
Instantiated with the ACL permissions which will be used to verify permission levels.
Parameters: - $acl (Zend_Acl) –
- $currentUser (unknown) –
- preDispatch()¶
Determine whether or not access is granted to a specific controller/action.
If the user has been authenticated, display the Access Forbidden error page.Otherwise, give the user an opportunity to login before trying again.
Returns: void
- isAllowed(string $privilege, $resource)¶
Notifies whether the logged-in user has permission for a given resource/ privilege combination.
If an ACL resource being checked has not been defined, access to thatresource should not be controlled. This allows plugin writers toimplement controllers without also requiring them to be aware of the ACL.
Conversely, in the event that an ACL resource has been defined, all access permissions for that controller must be properly defined.
The names of resources should correspond to the name of the controllerclass minus ‘Controller’, e.g.Geolocation_IndexController -> ‘Geolocation_Index’CollectionsController -> ‘Collections’
Parameters: - $privilege (string) –
- $resource (unknown) –
Returns: boolean
- getResourceName()¶
Retrieve the name of the ACL resource based on the name of the controller and, if not the default module, the name of the module.
Returns: string
- setCurrentUser(User|null $currentUser)¶
Parameters: - $currentUser (User|null) –
- setAllowed(string $rule, boolean $isAllowed = 1)¶
Temporarily override the ACL’s permissions for this controller
Parameters: - $rule (string) –
- $isAllowed (boolean) –
- setAutoloadResourceObject(boolean $autoload)¶
Set whether the ACL helper should try to automatically load a resource object from the request.
Parameters: - $autoload (boolean) –
- _getResourceObjectFromRequest()¶
Try to get the current resource object for the request.
Returns: Zend_Acl_Resource_Interface|null
- _isLoginRequest()¶
Omeka_Controller_Action_Helper_ContextSwitch¶
- class Omeka_Controller_Action_Helper_ContextSwitch¶
Package: Controller\ActionHelper
Extends the default ContextSwitch action helper to enable JSONP.
- postJsonContext()¶
This extends the default ZF JSON serialization to work with JSONP, which enables cross-site AJAX using JSON.
Returns: void
Omeka_Controller_Action_Helper_Db¶
- class Omeka_Controller_Action_Helper_Db¶
Package: Controller\ActionHelper
An action helper replacement for the database-oriented methods that were baked into Omeka_Controller_AbstractActionController in v1.x.
- property _db¶
- property _defaultTable¶
- property _defaultModel¶
- property _findByLimit¶
- init()¶
- __call($method, $args)¶
Delegate to the default table object for all other method calls.
Parameters: - $method (unknown) –
- $args (unknown) –
- setDefaultModelName($modelName)¶
Set the class name corresponding to the default model.
Parameters: - $modelName (unknown) –
- getDefaultModelName()¶
- setDefaultTable(Omeka_Db_Table $table)¶
Parameters: - $table (Omeka_Db_Table) –
- getDb()¶
- getTable(string|null $tableName)¶
Parameters: - $tableName (string|null) –
Returns: Omeka_Db_Table
- findById($id, $table)¶
Find a particular record given its unique ID # and (optionally) its class name.
Parameters: - $id (unknown) –
- $table (unknown) –
Returns: Omeka_Record_AbstractRecord
Omeka_Controller_Action_Helper_FlashMessenger¶
- class Omeka_Controller_Action_Helper_FlashMessenger¶
Package: Controller\ActionHelper
FlashMessenger action helper.
- property _messenger¶
- __construct()¶
- addMessage($message, $status)¶
addMessage() - Add a message to flash message
Parameters: - $message (unknown) –
- $status (unknown) –
Returns: Mu_Controller_Action_Helper_FlashMessenger Provides a fluent interface
- getMessages()¶
getMessages() - Get messages
Returns: array
- _filterMessages($messages)¶
Parameters: - $messages (unknown) –
- clearMessages()¶
Clear all messages from the previous request & specified status
Returns: boolean True if messages were cleared, false if none existed
- clearCurrentMessages()¶
Clear all current messages with specified status
Returns: boolean True if messages were cleared, false if none existed
- hasMessages()¶
Whether has messages with a specific status (or any messages, if null).
- hasCurrentMessages()¶
- getCurrentMessages($status)¶
Parameters: - $status (unknown) –
- direct($message, $status)¶
Strategy pattern: proxy to addMessage()
Parameters: - $message (unknown) –
- $status (unknown) –
Returns: void
Omeka_Controller_Action_Helper_Mail¶
- class Omeka_Controller_Action_Helper_Mail¶
Package: Controller\ActionHelper
Action helper for sending email.
- property _view¶
- property _subject¶
Subject of the email.
- property _subjectPrefix¶
Prefix (prepended to the subject).
- __construct(Zend_View $view)¶
Parameters: - $view (Zend_View) – View to render as the message body.
- __call(string $method, array $args)¶
Delegate to the Zend_Mail instance.
Parameters: - $method (string) – Method called.
- $args (array) – Arguments to method.
- setSubjectPrefix(string $prefix)¶
Set the prefix for the subject header. Typically takes the form “[Site Name] ”.
Parameters: - $prefix (string) – Subject prefix.
- setSubject(string $subject)¶
Set the subject of the email.
Parameters: - $subject (string) – Email subject.
- setBodyFromView(string $viewScript, boolean $html =)¶
Render the given view and use it as the body of the email.
Parameters: - $viewScript (string) – View script path.
- $html (boolean) – Whether or not the assigned view script will render as HTML. Defaults to false.
- send(Zend_Mail_Transport_Abstract $transport)¶
Send the email.
Parameters: - $transport (Zend_Mail_Transport_Abstract) – Optional defaults to null.
Omeka_Controller_Action_Helper_ThemeConfiguration¶
- class Omeka_Controller_Action_Helper_ThemeConfiguration¶
Package: Controller\ActionHelper
Action helper for handling theme configuration.
- property _themeOptions¶
- property _formValues¶
- property _form¶
- processForm(Zend_Form $form, array $data, array $originalOptions = Array)¶
Process the theme configuration form.
For file elements, this will save them using the storage systemor remove them as is necessary.
Parameters: - $form (Zend_Form) – The form to save.
- $data (array) – The data to fill the form with.
- $originalOptions (array) – The previous options for the form.
Returns: array|bool Array of options if the form was validly submitted, false otherwise.
- _configFileElement(Zend_Form_Element_File $element)¶
Ignore a file element that has an associated hidden element, since this means that the user did not change the uploaded file.
Parameters: - $element (Zend_Form_Element_File) –
- _processFileElement(Zend_Form_Element_File $element)¶
Store and/or delete a file for a file element.
Parameters: - $element (Zend_Form_Element_File) –
- _deleteOldFile(Zend_Form_Element_File $element)¶
Delete a previously-stored theme file.
Parameters: - $element (Zend_Form_Element_File) –
Class Library by Package¶
Acl¶
Up to Class Library by Package
Omeka_Acl_Assert_Ownership¶
- class Omeka_Acl_Assert_Ownership¶
Package: Acl
Assertion to take account of “All” and “Self” sub-permissions for records.
A common use is the “edit” and “delete” permissions for Items and other”ownable” records.
- assert(Zend_Acl $acl, Zend_Acl_Role_Interface $role, Zend_Acl_Resource_Interface $resource, $privilege)¶
Assert whether or not the ACL should allow access.
Parameters: - $acl (Zend_Acl) –
- $role (Zend_Acl_Role_Interface) –
- $resource (Zend_Acl_Resource_Interface) –
- $privilege (unknown) –
- _userOwnsRecord($user, $record)¶
Check whether the user owns this specific record.
Parameters: - $user (unknown) –
- $record (unknown) –
Omeka_Acl_Assert_User¶
- class Omeka_Acl_Assert_User¶
Package: Acl
Assert whether or not a specific user is allowed access to that person’s user account data.
- property _allowSelf¶
- property _denySelf¶
- assert(Zend_Acl $acl, Zend_Acl_Role_Interface $role, Zend_Acl_Resource_Interface $resource, $privilege)¶
Assert whether or not the ACL should allow access.
Assertions follow this logic:
Non-authenticated users (null role) have no access.
There exists a set of privileges (A) that are always allowed, provided that theuser role and user resource are the same (editing own info, changing ownpassword, etc.).
There also exists a set of privileges (B) that are always denied whenperformed on one’s own user account (deleting own account, changing ownrole, etc.)
The super user can do anything that isn’t on (B), e.g. the super user account cannot modify its own role.
All other users are limited to (A).
Parameters: - $acl (Zend_Acl) –
- $role (Zend_Acl_Role_Interface) –
- $resource (Zend_Acl_Resource_Interface) –
- $privilege (unknown) –
- _isAllowedSelf($privilege)¶
Parameters: - $privilege (unknown) –
- _isDeniedSelf($privilege)¶
Parameters: - $privilege (unknown) –
- _isSelf($role, $resource)¶
Parameters: - $role (unknown) –
- $resource (unknown) –
- _isSuperUser($user)¶
Parameters: - $user (unknown) –
Application¶
Up to Class Library by Package
Omeka_Application¶
- class Omeka_Application¶
Package: Application
Core class used to bootstrap the Omeka environment.
Various duties include, but are not limited to setting up class autoload, database, configuration files, logging, plugins, front controller, etc.
When any core resource returns from init(), the result is stored in thebootstrap container. Other parts of the application can get the resourcesfrom the bootstrap when needed.
- __construct(string $environment, string|array|Zend_Config $options)¶
Initialize the application.
Parameters: - $environment (string) – The environment name.
- $options (string|array|Zend_Config) – Application configuration.
- initialize()¶
Bootstrap the entire application.
- run()¶
Display the generic error page for all otherwise-uncaught exceptions.
- _displayErrorPage(Exception $e, string $title)¶
Print an HTML page to display errors when starting the application.
Parameters: - $e (Exception) –
- $title (string) – The title of the error page.
Application\Resource¶
Up to Application
Omeka_Application_Resource_Acl¶
- class Omeka_Application_Resource_Acl¶
Package: Application\Resource
Initializes Omeka’s ACL.
- property _acl¶
Access control list object.
- init()¶
Load the hardcoded ACL definitions, then apply definitions from plugins.
Returns: Zend_Acl
- getAcl()¶
Omeka_Application_Resource_Auth¶
- class Omeka_Application_Resource_Auth¶
Package: Application\Resource
Authentication resource.
- init()¶
Returns: Zend_Auth
Omeka_Application_Resource_Autoloader¶
- class Omeka_Application_Resource_Autoloader¶
Package: Application\Resource
An application resource for class autoloaders.
Omeka_Application_Resource_Cachemanager¶
- class Omeka_Application_Resource_Cachemanager¶
Package: Application\Resource
Core resource for configuring caches for use by other components.
- init()¶
Omeka_Application_Resource_Config¶
- class Omeka_Application_Resource_Config¶
Package: Application\Resource
Load the default configuration file for Omeka.
- init()¶
Returns: Zend_Config_Ini
Omeka_Application_Resource_Currentuser¶
- class Omeka_Application_Resource_Currentuser¶
Package: Application\Resource
Retrive the User record corresponding to the authenticated user.
If the user record is not retrievable (invalid ID), then the authenticationID will be cleared.
- init()¶
Retrieve the User record associated with the authenticated user.
Note that this returns null when no User is authenticated. Priorto 1.4, this returned boolean false. For forward-compatibility, thishas been changed to null in 1.4. This is because in future versions,User will implement Zend_Role_Interface. Zend_Acl accepts null asa valid role, but it throws exceptions for boolean false (tries toconvert it to the empty string).
Returns: User|null
Omeka_Application_Resource_Db¶
- class Omeka_Application_Resource_Db¶
Package: Application\Resource
Set up the default database connection for Omeka.
- property _iniPath¶
Path to the database configuration file. Set in application.ini
- init()¶
Returns: Omeka_Db
Omeka_Application_Resource_Debug¶
- class Omeka_Application_Resource_Debug¶
Package: Application\Resource
Sets up debugging output for web requests (if enabled).
- init()¶
Omeka_Application_Resource_Exception¶
- class Omeka_Application_Resource_Exception¶
Package: Application\Resource
Marker interface.
For future exceptions thrown by Omeka_Application_Resource classes. Thisprovides a pattern for differentiating setup/configuration errors.
Omeka_Application_Resource_Frontcontroller¶
- class Omeka_Application_Resource_Frontcontroller¶
Package: Application\Resource
Front controller resource.
- init()¶
Returns: Zend_Controller_Front
Omeka_Application_Resource_Helpers¶
- class Omeka_Application_Resource_Helpers¶
Package: Application\Resource
Initializes controller action helpers.
- init()¶
- _initDbHelper()¶
- _initViewRenderer()¶
- _initResponseContexts()¶
Define the custom response format contexts for Omeka.
Plugin writers should use the ‘response_contexts’ filter to modify or expand the list of formats that existing controllers may respond to.
Example of a definition of a response context through the ZF API:
$contexts->addContext(‘dc’, array(‘suffix’ => ‘dc’,’headers’ => array(‘Content-Type’ => ‘text/xml’),’callbacks’ => array(‘init’ => ‘atBeginningDoThis’,’post’ => ‘afterwardsDoThis’)));
Returns: void
- getDefaultResponseContexts()¶
Returns the default response contexts for Omeka.
Returns: array
- _initAclHelper()¶
Omeka_Application_Resource_Jobs¶
- class Omeka_Application_Resource_Jobs¶
Package: Application\Resource
Bootstrap resource for configuring the job dispatcher.
- init()¶
Omeka_Application_Resource_Jobs_InvalidAdapterException¶
- class Omeka_Application_Resource_Jobs_InvalidAdapterException¶
Package: Application\Resource
Exception thrown when an invalid job dispatcher has been configured.
- property message¶
- property code¶
- property file¶
- property line¶
- __clone()¶
- __construct($message, $code, $previous)¶
Parameters: - $message (unknown) –
- $code (unknown) –
- $previous (unknown) –
- getMessage()¶
- getCode()¶
- getFile()¶
- getLine()¶
- getTrace()¶
- getPrevious()¶
- getTraceAsString()¶
- __toString()¶
Omeka_Application_Resource_Locale¶
- class Omeka_Application_Resource_Locale¶
Package: Application\Resource
Core resource for configuring and loading the translation and locale components.
- init()¶
- _setTranslate($locale, $cache)¶
Retrieve translation configuration options.
Parameters: - $locale (unknown) –
- $cache (unknown) –
Returns: string
Omeka_Application_Resource_Logger¶
- class Omeka_Application_Resource_Logger¶
Package: Application\Resource
If logging has been enabled in the config file, then set up Zend’s logging mechanism.
- init()¶
Returns: Zend_Log
- _addMailWriter(Zend_Log $log, string $toEmail, $filter)¶
Set up debugging emails.
Parameters: - $log (Zend_Log) –
- $toEmail (string) – Email address of debug message recipient.
- $filter (unknown) –
Omeka_Application_Resource_Mail¶
- class Omeka_Application_Resource_Mail¶
Package: Application\Resource
Set up the mail transport that Omeka uses to send mail.
This makes use of Zend_Application_Resource_Mail for configuring the mailresource. config.ini can be set up using either the Zend Framework way orusing the older Omeka configuration style (for backwards-compatibility),though the newer style is recommended.
- property _zendResource¶
- __construct($options)¶
Parameters: - $options (unknown) –
- init()¶
Returns: Zend_Mail
Omeka_Application_Resource_Options¶
- class Omeka_Application_Resource_Options¶
Package: Application\Resource
Retrieve all the options from the database.
Options are essentially site-wide variables that are stored in the database,for example the title of the site. Failure to load this resource currentlyindicates that Omeka needs to be installed.
- property _installerRedirect¶
- init()¶
Returns: array
- setInstallerRedirect($flag)¶
Parameters: - $flag (unknown) –
- _convertMigrationSchema($options)¶
If necessary, convert from the old sequentially-numbered migration scheme to the new timestamped migrations.
Parameters: - $options (unknown) –
Returns: void.
Omeka_Application_Resource_Pluginbroker¶
- class Omeka_Application_Resource_Pluginbroker¶
Package: Application\Resource
Set up the plugin broker.
- init()¶
Returns: Omeka_Plugin_Broker
Omeka_Application_Resource_Plugins¶
- class Omeka_Application_Resource_Plugins¶
Package: Application\Resource
Fire the ‘initialize’ hook for all installed plugins.
Note that this hook fires before the front controller has been initialized ordispatched.
- init()¶
Omeka_Application_Resource_Router¶
- class Omeka_Application_Resource_Router¶
Package: Application\Resource
Set up the router and the built-in routes.
- init()¶
Returns: Zend_Controller_Router_Rewrite
- _addHomepageRoute(Zend_Controller_Router_Rewrite $router)¶
Adds the homepage route to the router (as specified by the navigation settings page) The route will not be added if the user is currently on the admin theme.
Parameters: - $router (Zend_Controller_Router_Rewrite) – The router
- addRedirectRouteForDefaultRoute(String $routeName, String $uri, array $params = Array, Zend_Controller_Router_Rewrite $router)¶
Adds a redirect route for the default route and returns whether the route was successfully added If the current request matches the default route, then the flow will redirect to the index action of the RedirectorController, where the page will be redirected to the absolute uri We must use this Redirector proxy controller because a user may be redirecting to an admin page and it needs to reload the application from the admin context. Also, the Zend router and dispatcher does not allow us to directly dispatch to an absolute uri.
Parameters: - $routeName (String) – The name of the new redirect route
- $uri (String) – The absolute uri to redirect to the default route to
- $params (array) – The parameters for the redirect route.
- $router (Zend_Controller_Router_Rewrite) – The router
Returns: boolean Returns true if the route was successfully added, else false.
- _leftTrim(string $s, string $n)¶
Left trims the first occurrence of a string within a string. Note: it will only trim the first occurrence of the string.
Parameters: - $s (string) – The base string
- $n (string) – The string to remove from the left side of the base string
Returns: string
Omeka_Application_Resource_Session¶
- class Omeka_Application_Resource_Session¶
Package: Application\Resource
Initialize the session.
Customizes the session name to prevent session overlap between differentapplications that operate on the same server.
- init()¶
- _getSessionConfig()¶
Retrieve global session configuration options.
Returns: array An array containing all the global configuration options for sessions. This array contains at least one key, ‘name’, corresponding to the name of the session, which is generated automatically if not provided.
- _buildSessionName()¶
Create a unique session name.
Hashes the base directory, this ensures that session names differ betweenOmeka instances on the same server.
Returns: string
- _setOptionsFromConfig()¶
Omeka_Application_Resource_Storage¶
- class Omeka_Application_Resource_Storage¶
Package: Application\Resource
Bootstrap resource for configuring the file storage layer.
- init()¶
Omeka_Application_Resource_Theme¶
- class Omeka_Application_Resource_Theme¶
Package: Application\Resource
Set up the controller plugin that determines theme view script paths.
- property _basePath¶
Theme base path. Set by application config.
- property _webBasePath¶
Theme base URI.
Set by application config.
- init()¶
Auth¶
Up to Class Library by Package
Omeka_Auth_Adapter_UserTable¶
- class Omeka_Auth_Adapter_UserTable¶
Package: Auth
Auth adapter that uses Omeka’s users table for authentication.
- _authenticateValidateResult(array $resultIdentity)¶
Validate the identity returned from the database.
Overrides the Zend implementation to provide user IDs, not usernamesupon successful validation.
Parameters: - $resultIdentity (array) –
Captcha¶
Up to Class Library by Package
Omeka_Captcha¶
- class Omeka_Captcha¶
Package: Captcha
Factory for creating a captcha for use when soliciting public input.
- getCaptcha()¶
Get a captcha object implementing Zend’s captcha API.
Returns: Zend_Captcha_Adapter|null
- isConfigured()¶
Return whether the captcha is configured. If this returns true, getCaptcha will not return null.
Returns: boolean
Controller¶
Up to Class Library by Package
Omeka_Controller_AbstractActionController¶
- class Omeka_Controller_AbstractActionController¶
Package: Controller
Base class for Omeka controllers.
Provides basic create, read, update, and delete (CRUD) operations.
- property _browseRecordsPerPage¶
The number of records to browse per page.
If this is left null, then results will not paginate. This is partiallybecause not every controller will want to paginate records and also toavoid BC breaks for plugins.
- __construct(Zend_Controller_Request_Abstract $request, Zend_Controller_Response_Abstract $response, array $invokeArgs = Array)¶
Base controller constructor.
Does the following things:
- Aliases the redirector helper to clean up the syntax
- Sets the table object automatically if given the class of the model to use for CRUD.
- Sets all the built-in action contexts for the CRUD actions.
Instead of overriding this constructor, controller subclasses shouldimplement the init() method for initial setup.
Parameters: - $request (Zend_Controller_Request_Abstract) – Current request object.
- $response (Zend_Controller_Response_Abstract) – Response object.
- $invokeArgs (array) – Arguments passed to Zend_Controller_Action.
- indexAction()¶
Forward to the ‘browse’ action
- browseAction()¶
Retrieve and render a set of records for the controller’s model.
Using this action requires some setup:
- In your controller’s init(), set the default model name: $this->_helper->db->setDefaultModelName('YourRecord');
- In your controller, set the records per page and return them using: protected function _getBrowseRecordsPerPage();
- In your table record, filter the select object using the provided parameters using: public function applySearchFilters($select, $params);
- showAction()¶
Retrieve a single record and render it.
Every request to this action must pass a record ID in the ‘id’ parameter.
- addAction()¶
Add an instance of a record to the database.
This behaves differently based on the contents of the $_POST superglobal.If the $_POST is empty or invalid, it will render the form used for dataentry. Otherwise, if the $_POST exists and is valid, it will save the newrecord and redirect to the ‘browse’ action.
- editAction()¶
Similar to ‘add’ action, except this requires a pre-existing record.
Every request to this action must pass a record ID in the ‘id’ parameter.
- deleteConfirmAction()¶
Ask for user confirmation before deleting a record.
- deleteAction()¶
Delete a record from the database.
Every request to this action must pass a record ID in the ‘id’ parameter.
- getCurrentUser()¶
Return the record for the current user.
Returns: User|bool User object if a user is logged in, false otherwise.
- _getBrowseRecordsPerPage()¶
Return the number of records to display per page.
By default this will return null, disabling pagination. This can beoverridden in subclasses by redefining this method.
Returns: integer|null
- _getAddSuccessMessage(Omeka_Record_AbstractRecord $record)¶
Return the success message for adding a record.
Default is empty string. Subclasses should override it.
Parameters: - $record (Omeka_Record_AbstractRecord) –
Returns: string
- _getEditSuccessMessage(Omeka_Record_AbstractRecord $record)¶
Return the success message for editing a record.
Default is empty string. Subclasses should override it.
Parameters: - $record (Omeka_Record_AbstractRecord) –
Returns: string
- _getDeleteSuccessMessage(Omeka_Record_AbstractRecord $record)¶
Return the success message for deleting a record.
Default is empty string. Subclasses should override it.
Parameters: - $record (Omeka_Record_AbstractRecord) –
Returns: string
- _getDeleteConfirmMessage(Omeka_Record_AbstractRecord $record)¶
Return the delete confirm message for deleting a record.
Parameters: - $record (Omeka_Record_AbstractRecord) –
Returns: string
- _redirectAfterAdd(Omeka_Record_AbstractRecord $record)¶
Redirect to another page after a record is successfully added.
The default is to reidrect to this controller’s browse page.
Parameters: - $record (Omeka_Record_AbstractRecord) –
- _redirectAfterEdit(Omeka_Record_AbstractRecord $record)¶
Redirect to another page after a record is successfully edited.
The default is to redirect to this record’s show page.
Parameters: - $record (Omeka_Record_AbstractRecord) –
- _redirectAfterDelete(Omeka_Record_AbstractRecord $record)¶
Redirect to another page after a record is successfully deleted.
The default is to redirect to this controller’s browse page.
Parameters: - $record (Omeka_Record_AbstractRecord) –
- _setActionContexts()¶
Augment Zend’s default action contexts.
Passes Omeka’s default additional contexts through the ‘action_contexts’ filter to allow plugins to add contexts.
- _getDeleteForm()¶
Get the form used for confirming deletions.
Returns: Zend_Form
Omeka_Controller_Exception_403¶
- class Omeka_Controller_Exception_403¶
Package: Controller
If thrown by a controller, this exception will be caught within the ErrorController, which will then render a 403 Forbidden page.
- property message¶
- property string¶
- property code¶
- property file¶
- property line¶
- property trace¶
- property previous¶
- __clone()¶
- __construct($message, $code, $previous)¶
Parameters: - $message (unknown) –
- $code (unknown) –
- $previous (unknown) –
- getMessage()¶
- getCode()¶
- getFile()¶
- getLine()¶
- getTrace()¶
- getPrevious()¶
- getTraceAsString()¶
- __toString()¶
Omeka_Controller_Exception_404¶
- class Omeka_Controller_Exception_404¶
Package: Controller
If thrown within a controller, this will be caught in the ErrorController, which will render a 404 Not Found page.
- property message¶
- property string¶
- property code¶
- property file¶
- property line¶
- property trace¶
- property previous¶
- __clone()¶
- __construct($message, $code, $previous)¶
Parameters: - $message (unknown) –
- $code (unknown) –
- $previous (unknown) –
- getMessage()¶
- getCode()¶
- getFile()¶
- getLine()¶
- getTrace()¶
- getPrevious()¶
- getTraceAsString()¶
- __toString()¶
Controller\Plugin¶
Up to Controller
Omeka_Controller_Plugin_Admin¶
- class Omeka_Controller_Plugin_Admin¶
Package: Controller\Plugin
This controller plugin allows for all functionality that is specific to the Admin theme.
For now, all this includes is preventing unauthenticated access to all adminpages, with the exception of a few white-listed URLs, which are stored inthis plugin.
This controller plugin should be loaded only in the admin bootstrap.
- property _adminWhitelist¶
Controller/Action list for admin actions that do not require being logged-in
- routeStartup(Zend_Controller_Request_Abstract $request)¶
Direct requests to the admin interface. Called upon router startup, before the request is routed.
Parameters: - $request (Zend_Controller_Request_Abstract) –
Returns: void
- preDispatch(Zend_Controller_Request_Abstract $request)¶
Require login when attempting to access the admin interface. Whitelisted controller/action combinations are exempt from this requirement. Called before dispatching.
Parameters: - $request (Zend_Controller_Request_Abstract) –
Returns: void
- getRedirector()¶
Return the redirector action helper.
Returns: Zend_Controller_Action_Helper_Redirector
- getAuth()¶
Return the auth object.
Returns: Zend_Auth
- _requireLogin($request)¶
Determine whether or not the request requires an authenticated user.
Parameters: - $request (unknown) –
Returns: boolean
Omeka_Controller_Plugin_Debug¶
- class Omeka_Controller_Plugin_Debug¶
Package: Controller\Plugin
This controller plugin allows for debugging Request objects without inserting debugging code into the Zend Framework code files.
Debugging web requests is enabled by setting ‘debug.request = true’ in theconfig.ini file.
- property _requestMarkup¶
- preDispatch(Zend_Controller_Request_Abstract $request)¶
Print request debugging info for every request.
Has no effect if request debugging is not enabled in config.ini.
Parameters: - $request (Zend_Controller_Request_Abstract) – Request object.
Returns: void
- postDispatch(Zend_Controller_Request_Abstract $request)¶
Parameters: - $request (Zend_Controller_Request_Abstract) –
- dispatchLoopShutdown()¶
Print database profiling info.
Enabled conditionally when debug.profileDb = true in config.ini.
Returns: void
- _getProfilerMarkup(Zend_Db_Profiler $profiler)¶
Parameters: - $profiler (Zend_Db_Profiler) –
- _getRequestMarkup(Zend_Controller_Request_Abstract $request, Zend_Controller_Router_Interface $router)¶
Create HTML markup for request debugging.
Parameters: - $request (Zend_Controller_Request_Abstract) – Request object.
- $router (Zend_Controller_Router_Interface) – Router object.
Returns: string HTML markup.
Omeka_Controller_Plugin_HtmlPurifier¶
- class Omeka_Controller_Plugin_HtmlPurifier¶
Package: Controller\Plugin
This ZF controller plugin allows the HtmlPurifier to filter the existing forms (items, collections, users, etc.) so that fields that are allowed to contain HTML are properly filtered.
Note that this will not operate on any of the plugins.
- routeStartup(Zend_Controller_Request_Abstract $request)¶
Add the HtmlPurifier options if needed.
Parameters: - $request (Zend_Controller_Request_Abstract) –
Returns: void
- preDispatch(Zend_Controller_Request_Abstract $request)¶
Determine whether or not to filter form submissions for various controllers.
Parameters: - $request (Zend_Controller_Request_Abstract) –
Returns: void
- isFormSubmission(Zend_Controller_Request_Abstract $request)¶
Determine whether or not the request contains a form submission to either the ‘add’, ‘edit’, or ‘config’ actions.
Parameters: - $request (Zend_Controller_Request_Abstract) –
Returns: boolean
- filterCollectionsForm(Zend_Controller_Request_Abstract $request, Omeka_Filter_HtmlPurifier $htmlPurifierFilter)¶
Filter the Collections form post, including the ‘Elements’ array of the POST.
Parameters: - $request (Zend_Controller_Request_Abstract) –
- $htmlPurifierFilter (Omeka_Filter_HtmlPurifier) –
Returns: void
- filterThemesForm(Zend_Controller_Request_Abstract $request, Omeka_Filter_HtmlPurifier $htmlPurifierFilter)¶
Purify all of the data in the theme settings
Parameters: - $request (Zend_Controller_Request_Abstract) –
- $htmlPurifierFilter (Omeka_Filter_HtmlPurifier) –
Returns: void
- _purifyArray($dataArray = Array, Omeka_Filter_HtmlPurifier $htmlPurifierFilter)¶
Recurisvely purify an array
Parameters: - $dataArray (unknown) –
- $htmlPurifierFilter (Omeka_Filter_HtmlPurifier) –
Returns: array A purified array of string or array values
- filterItemsForm(Zend_Controller_Request_Abstract $request, Omeka_Filter_HtmlPurifier $htmlPurifierFilter)¶
Filter the Items form post, including the ‘Elements’ array of the POST.
Parameters: - $request (Zend_Controller_Request_Abstract) –
- $htmlPurifierFilter (Omeka_Filter_HtmlPurifier) –
Returns: void
- _filterElementsFromPost(Zend_Controller_Request_Abstract $post, Omeka_Filter_HtmlPurifier $htmlPurifierFilter)¶
Filter the ‘Elements’ array of the POST.
Parameters: - $post (Zend_Controller_Request_Abstract) –
- $htmlPurifierFilter (Omeka_Filter_HtmlPurifier) –
Returns: void
- _setupHtmlPurifierOptions()¶
Omeka_Controller_Plugin_Jsonp¶
- class Omeka_Controller_Plugin_Jsonp¶
Package: Controller\Plugin
Sets the Content-Type header for all JSON-P requests.
- constant CALLBACK_KEY¶
Callback parameter key.
- postDispatch(Zend_Controller_Request_Abstract $request)¶
Set the ‘Content-Type’ HTTP header to ‘application/x-javascript’ for omeka-json requests.
Parameters: - $request (Zend_Controller_Request_Abstract) – Request object.
Returns: void
Omeka_Controller_Plugin_Ssl¶
- class Omeka_Controller_Plugin_Ssl¶
Package: Controller\Plugin
Handle SSL configuration for Omeka sites.
- property _sslConfig¶
- property _redirector¶
- property _auth¶
- __construct($sslConfig, $redirector, Zend_Auth $auth)¶
Parameters: - $sslConfig (unknown) –
- $redirector (unknown) –
- $auth (Zend_Auth) –
- routeStartup(Zend_Controller_Request_Abstract $request)¶
Parameters: - $request (Zend_Controller_Request_Abstract) –
- preDispatch(Zend_Controller_Request_Abstract $request)¶
Parameters: - $request (Zend_Controller_Request_Abstract) –
- _isLoginRequest($request)¶
Parameters: - $request (unknown) –
- _secureAuthenticatedSession()¶
Unauthenticated sessions are not as valuable to attackers, so we only really need to check if an authenticated session is being used.
- _isSslRequest($request)¶
Parameters: - $request (unknown) –
- _redirect($request)¶
Parameters: - $request (unknown) –
- _secureAllRequests()¶
Omeka_Controller_Plugin_Upgrade¶
- class Omeka_Controller_Plugin_Upgrade¶
Package: Controller\Plugin
Overrides Omeka’s normal routing when the database needs to be upgraded.
- dispatchLoopStartup(Zend_Controller_Request_Abstract $request)¶
Set up routing for the upgrade controller.
Only allows authorized users to upgrade, and blocks the public site when an upgrade is needed.
Parameters: - $request (Zend_Controller_Request_Abstract) – Request object.
Returns: void
- _dbNeedsUpgrade()¶
- _dbCanUpgrade()¶
- _upgrade(Zend_Controller_Request_Abstract $request)¶
Redirect to the upgrade controller.
Parameters: - $request (Zend_Controller_Request_Abstract) – Request object (not used).
Returns: void
Omeka_Controller_Plugin_ViewScripts¶
- class Omeka_Controller_Plugin_ViewScripts¶
Package: Controller\Plugin
Sets up view script search paths on a per-request basis.
- property _view¶
Registered view object.
- property _dbOptions¶
List of options from the database.
- property _baseThemePath¶
Base path to themes directory.
- property _webBaseThemePath¶
Base web-accesible path to themes.
- property _pluginMvc¶
MVC plugin behaviors class.
- __construct(array $options, Omeka_Plugin_Mvc $pluginMvc)¶
Parameters: - $options (array) – List of options.
- $pluginMvc (Omeka_Plugin_Mvc) – Plugin MVC class.
- preDispatch(Zend_Controller_Request_Abstract $request)¶
Add the appropriate view scripts directories for a given request. This is pretty much the glue between the plugin broker and the View object, since it uses data from the plugin broker to determine what script paths will be available to the view.
Parameters: - $request (Zend_Controller_Request_Abstract) – Request object.
Returns: void
- _setupPathsForPlugin(string $pluginModuleName, string $themeType)¶
Set up the asset paths for a plugin.
If you’re in a plugin, check in this order: 1. plugin view scripts (only for that plugin) 2. plugin view scripts for other plugins 3. theme view scripts
This means that it needs to add the paths in the reverse order of what needsto be checked first, so theme paths first and then plugin paths.
Parameters: - $pluginModuleName (string) – The module name for the plugin.
- $themeType (string) – The type of theme: ‘admin’ or ‘public’.
Returns: void
- _setupPathsForTheme(string $themeType)¶
Set up the asset paths for the theme.
If you’re in one of the themes, check in this order:1. theme view scripts2. all plugin view scripts
Parameters: - $themeType (string) – The type of theme: ‘admin’ or ‘public’.
Returns: void
- _addPluginPaths(string $themeType, string $pluginModuleName)¶
Add asset paths for a plugin.
Parameters: - $themeType (string) – The type of theme: ‘admin’ or ‘public’.
- $pluginModuleName (string) – The module name for the plugin.
Returns: void
- _addPathToView(string $scriptPath)¶
Add a new script path for a plugin to the view.
Parameters: - $scriptPath (string) – Path from plugins dir to script dir.
Returns: void
- _getView()¶
Gets the view from the registry.
The initial call to the registry caches the view in this class.
Returns: Zend_View
Add the global views from the view scripts directory to the view.
Returns: void
- _addThemePaths(string $theme)¶
Add script and asset paths for a theme to the view.
Parameters: - $theme (string) – Theme type; either ‘public’ or ‘admin’.
Returns: void
- _addOverridePathForPlugin(string $theme, string $pluginModuleName)¶
Add theme view path for override views for a given plugin.
Parameters: - $theme (string) – Theme type; ‘public’ or ‘admin’
- $pluginModuleName (string) –
- getThemeOption(string $type)¶
Retrieve the option from the database that contains the directory of the theme to render.
Parameters: - $type (string) – Currently either ‘admin’ or ‘public’.
Returns: string
Db¶
Up to Class Library by Package
Omeka_Db¶
- class Omeka_Db¶
Package: Db
Database manager object for Omeka
While mostly a wrapper for a Zend_Db_Adapter instance, this also providesshortcuts for retrieving table objects and table names for use in SQL.
- property prefix¶
The prefix that every table in the omeka database will use.
- property _adapter¶
The database adapter.
- property _tables¶
All the tables that are currently managed by this database object.
- property _logger¶
The logger to use for logging SQL queries. If not set, no logging will be done.
- __construct(Zend_Db_Adapter_Abstract $adapter, string $prefix)¶
Parameters: - $adapter (Zend_Db_Adapter_Abstract) – A Zend Framework connection object.
- $prefix (string) – The prefix for the database tables, if applicable.
- __call(string $m, array $a)¶
Delegate to the database adapter.
Parameters: - $m (string) – Method name.
- $a (array) – Method arguments.
Returns: mixed
- __get(string $name)¶
Magic getter is a synonym for Omeka_Db::getTableName().
Example: $db->Item is equivalent to $db->getTableName(‘Item’).
Parameters: - $name (string) – Property name; table model class name in this case.
Returns: string|null
- setLogger(Zend_Log $logger)¶
Set logger for SQL queries.
Parameters: - $logger (Zend_Log) –
- getAdapter()¶
Retrieve the database adapter.
Returns: Zend_Db_Adapter_Abstract
- getTableName($class)¶
Retrieve the name of the table (including the prefix).
Parameters: - $class (unknown) –
Returns: string
- hasPrefix()¶
Check whether the database tables have a prefix.
Returns: boolean
- getTable(string $class)¶
Retrieve a table object corresponding to the model class.
Table classes can be extended by inheriting off of Omeka_Db_Table andthen calling your table Table_ModelName, e.g. Table_Item orTable_Collection. For backwards compatibility you may call your tableModelNameTable, i.e. ItemTable or CollectionTable. The latter namingpattern is deprecated.
This will cache every table object so that tables are not instantiatedmultiple times for complicated web requests.
Parameters: - $class (string) – Model class name.
Returns: Omeka_Db_Table
- setTable(string $alias, Omeka_Db_Table $table)¶
Cache a table object.
Prevents the creation of unnecessary instances.
Parameters: - $alias (string) –
- $table (Omeka_Db_Table) –
- insert(string $table, array $values = Array)¶
Every query ends up looking like: INSERT INTO table (field, field2, field3, ...) VALUES (?, ?, ?, ...) ON DUPLICATE KEY UPDATE field = ?, field2 = ?, ...
Note on portability: ON DUPLICATE KEY UPDATE is a MySQL extension.The advantage to using this is that it doesn’t care whether a row exists already.Basically it combines what would be insert() and update() methods in otherORMs into a single method
Parameters: - $table (string) – Table model class name.
- $values (array) – Rows to insert (or update).
Returns: integer The ID for the row that got inserted (or updated).
- log(string|Zend_Db_Select $sql)¶
Log SQL query if logging is configured.
This logs the query before variable substitution from bind params.
Parameters: - $sql (string|Zend_Db_Select) –
- queryBlock(string $sql, string $delimiter = ;)¶
Execute more than one SQL query at once.
Parameters: - $sql (string) – String containing SQL queries.
- $delimiter (string) – Character that delimits each SQL query.
- loadSqlFile(string $filePath)¶
Read the contents of an SQL file and execute all the queries therein.
In addition to reading the file, this will make substitutions based onspecific naming conventions. Currently makes the following substitutions:%PREFIX% will be replaced by the table prefix.
Parameters: - $filePath (string) – Path to the SQL file to load
Omeka_Db_Select¶
- class Omeka_Db_Select¶
Package: Db
Class for SQL SELECT generation and results.
- __construct(Zend_Db_Adapter $adapter)¶
Parameters: - $adapter (Zend_Db_Adapter) – (optional) Adapter to use instead of the one set up by Omeka.
- hasJoin(string $name)¶
Detect if this SELECT joins with the given table.
Parameters: - $name (string) – Table name.
Returns: boolean
Omeka_Db_Select_PublicPermissions¶
- class Omeka_Db_Select_PublicPermissions¶
Package: Db
Encapsulates the permissions check for a record that can be public or private.
- property _allPermission¶
- property _selfPermission¶
- __construct(string $resource)¶
Create the permissions object and perform the ACL checks.
The permissions check relies on ‘showNotPublic’ and (optionally)’showSelfNotPublic’ privileges on the give resource.
Parameters: - $resource (string) – ACL resource name to check.
- apply(Omeka_Db_Select $select, string $alias, string $ownerColumn = owner_id)¶
Apply the permissions to an SQL select object.
Parameters: - $select (Omeka_Db_Select) –
- $alias (string) – Table alias to query against
- $ownerColumn (string) – Optional column for checking for ownership. If falsy, the ownership check is skipped.
Db\Migration¶
Up to Db
Omeka_Db_Migration_AbstractMigration¶
- class Omeka_Db_Migration_AbstractMigration¶
Package: Db\Migration
Database migration classes may inherit from this one.
- property db¶
- getDb()¶
Returns: Omeka_Db
- down()¶
Template method for reversing the migration.
This is defined as a template method instead of leaving it abstract becausepre-existing implementations of Omeka_Db_Migration were not required toimplement the down() method. This ensures backwards compatibility forthose migrations.
- __call(string $m, array $a)¶
Proxy calls to Omeka_Db.
Allows migration writers to call db methods directly on $this.
Parameters: - $m (string) – Method name.
- $a (array) – Method arguments.
- form()¶
If the migration requires a form submission, here’s where to handle display of it
Returns: void
- up()¶
Omeka_Db_Migration_Exception¶
- class Omeka_Db_Migration_Exception¶
Package: Db\Migration
Indicates an error during the database migration process.
- property message¶
- property string¶
- property code¶
- property file¶
- property line¶
- property trace¶
- property previous¶
- __clone()¶
- __construct($message, $code, $previous)¶
Parameters: - $message (unknown) –
- $code (unknown) –
- $previous (unknown) –
- getMessage()¶
- getCode()¶
- getFile()¶
- getLine()¶
- getTrace()¶
- getPrevious()¶
- getTraceAsString()¶
- __toString()¶
Omeka_Db_Migration_Manager¶
- class Omeka_Db_Migration_Manager¶
Package: Db\Migration
Manages database migrations (both upgrades and downgrades).
- constant MIGRATION_TABLE_NAME¶
Name of the migrations table.
- constant MIGRATION_DATE_FORMAT¶
Formatting string to convert dates into YYYYMMDDHHMMSS pattern.
- constant ORIG_MIGRATION_OPTION_NAME¶
Name of the original database option storing the integer migration number.
- constant VERSION_OPTION_NAME¶
Name of the new database option storing the core software version number.
- property _db¶
- property _migrationsDir¶
Directory where migrations scripts are kept.
- __construct(Omeka_Db $db, string $migrationsDir)¶
Parameters: - $db (Omeka_Db) –
- $migrationsDir (string) –
- setupTimestampMigrations()¶
Set up Omeka to use timestamped database migrations.
This creates the ‘schema_migrations’ table, drops the ‘migration’ optionand adds the ‘omeka_version’ option to the database.
Returns: void
- markAllAsMigrated()¶
Mark all of the migrations as having been run. Used by the installer as a way of indicating that the database is entirely up to date.
Returns: void
- migrate(string $endTimestamp)¶
Migrate the database schema.
Parameters: - $endTimestamp (string) – (optional) Timestamp corresponding to the stop point for the migration. If older than the current time, database will migrate down to that point. If newer, the opposite. Defaults to the current timestamp.
Returns: void
- canUpgrade()¶
Determine whether or not it is possible to migrate the Omeka database up.
This is based entirely on whether there exist any migrations that havenot yet been applied.
Returns: void
- dbNeedsUpgrade()¶
Determine whether the database must be upgraded.
In order to return true, this requires that canUprade() == true, and also that Omeka’s code has recently been upgraded.
- finalizeDbUpgrade()¶
Finalize the database upgrade by setting the most up-to-date version of Omeka.
- getDefault(Omeka_Db|null $db)¶
Return the default configuration of the database migration manager.
Parameters: - $db (Omeka_Db|null) –
Returns: Omeka_Db_Migration_Manager
- _getAllMigratedVersions()¶
Retrieve all the versions that have been migrated.
Returns: array
- _getMigrationTableName()¶
Return the name of the table associated with schema migrations.
Returns: string
- _getMigrationFileList()¶
Return a list of migration files in the migration directory.
Returns: array An associative array where key = timestamp of migration, value = full filename of the migration.
- _migrateUp(DateTime $stopAt)¶
Migrate upwards to a specific timestamp.
Parameters: - $stopAt (DateTime) –
Returns: void
- _loadMigration(string $filename)¶
Require the migration file and return an instance of the class associated with it.
Parameters: - $filename (string) – Migration script filename.
Returns: Omeka_Db_Migration_AbstractMigration
- _getPendingMigrations(DateTime $until)¶
Retrieve a list of all migrations that have not been run yet, ending at the latest time given by $until.
Parameters: - $until (DateTime) –
Returns: array
- _recordMigration(string $time)¶
Record the migration timestamp in the schema_migrations table.
Parameters: - $time (string) –
Returns: void
Db\Table¶
Up to Db
Omeka_Db_Table¶
- class Omeka_Db_Table¶
Package: Db\Table
Database table classes.
Subclasses attached to models must follow the naming convention:Table_TableName, e.g. Table_ElementSet in models/Table/ElementSet.php.
- property _target¶
The name of the model for which this table will retrieve objects.
- property _name¶
The name of the table (sans prefix).
If this is not given, it will be inflected.
- property _tablePrefix¶
The table prefix.
Generally used to differentiate Omeka installations sharing a database.
- property _db¶
The Omeka database object.
- __construct(string $targetModel, Omeka_Db $db)¶
Construct the database table object.
Do not instantiate this by itself. Access instances only viaOmeka_Db::getTable().
Parameters: - $targetModel (string) – Class name of the table’s model.
- $db (Omeka_Db) – Database object to use for queries.
- __call(string $m, array $a)¶
Delegate to the database adapter.
Used primarily as a convenience method. For example, you can callfetchOne() and fetchAll() directly from this object.
Parameters: - $m (string) – Method name.
- $a (array) – Method arguments.
Returns: mixed
- getTableAlias()¶
Retrieve the alias for this table (the name without the prefix).
Returns: string
- getDb()¶
Retrieve the Omeka_Db instance.
Returns: Omeka_Db
- hasColumn(string $field)¶
Determine whether a model has a given column.
Parameters: - $field (string) – Field name.
Returns: bool
- getColumns()¶
Retrieve a list of all the columns for a given model.
This should be here and not in the model class because get_class_vars()returns private/protected properties when called from within the class.Will only return public properties when called in this fashion.
Returns: array
- getTableName()¶
Retrieve the name of the table for the current table (used in SQL statements).
If the table name has not been set, it will inflect the table name.
Returns: string
- setTableName(string $name)¶
Set the name of the database table accessed by this class.
If no name is provided, it will inflect the table name from the name ofthe model defined in the constructor. For example, Item -> items.
Parameters: - $name (string) – (optional) Table name.
Returns: void
- getTablePrefix()¶
Retrieve the table prefix for this table instance.
Returns: string
- setTablePrefix(string|null $tablePrefix)¶
Set the table prefix.
Defaults to the table prefix defined by the Omeka_Db instance. Thisshould remain the default in most cases. However, edge cases may requirecustomization, e.g. creating wrappers for tables generated by otherapplications.
Parameters: - $tablePrefix (string|null) –
- find(integer $id)¶
Retrieve a single record given an ID.
Parameters: - $id (integer) –
Returns: Omeka_Record_AbstractRecord|false
- findAll()¶
Get a set of objects corresponding to all the rows in the table
WARNING: This will be memory intensive and is thus not recommended forlarge data sets.
Returns: array Array of {@link Omeka_Record_AbstractRecord}s.
- findPairsForSelectForm(array $options = Array)¶
Retrieve an array of key=>value pairs that can be used as options in a <select> form input.
Parameters: - $options (array) – (optional) Set of parameters for searching/ filtering results.
Returns: array
- _getColumnPairs()¶
Retrieve the array of columns that are used by findPairsForSelectForm().
This is a template method because these columns are different for everytable, but the underlying logic that retrieves the pairs from thedatabase is the same in every instance.
Returns: array
- findBy(array $params = Array, integer $limit, integer $page)¶
Retrieve a set of model objects based on a given number of parameters
Parameters: - $params (array) – A set of parameters by which to filter the objects that get returned from the database.
- $limit (integer) – Number of objects to return per “page”.
- $page (integer) – Page to retrieve.
Returns: array|null The set of objects that is returned
- getSelect()¶
Retrieve a select object for this table.
Returns: Omeka_Db_Select
- getSelectForFindBy(array $params = Array)¶
Retrieve a select object that has had search filters applied to it.
Parameters: - $params (array) – optional Set of named search parameters.
Returns: Omeka_Db_Select
- getSelectForFind(integer $recordId)¶
Retrieve a select object that is used for retrieving a single record from the database.
Parameters: - $recordId (integer) –
Returns: Omeka_Db_Select
- applySearchFilters(Omeka_Db_Select $select, array $params)¶
Apply a set of filters to a Select object based on the parameters given.
By default, this simply checks the params for keys corresponding to databasecolumn names. For more complex filtering (e.g., when other tables are involved),or to use keys other than column names, override this method and optionallycall this parent method.
Parameters: - $select (Omeka_Db_Select) –
- $params (array) –
- applySorting(Omeka_Db_Select $select, string $sortField, string $sortDir)¶
Apply default column-based sorting for a table.
Parameters: - $select (Omeka_Db_Select) –
- $sortField (string) – Field to sort on.
- $sortDir (string) – Direction to sort.
- applyPagination(Zend_Db_Select $select, integer $limit, integer|null $page)¶
Apply pagination to a select object via the LIMIT and OFFSET clauses.
Parameters: - $select (Zend_Db_Select) –
- $limit (integer) – Number of results per “page”.
- $page (integer|null) – Page to retrieve, first if omitted.
Returns: Zend_Db_Select
- findBySql(string $sqlWhereClause, array $params = Array, boolean $findOne =)¶
Retrieve an object or set of objects based on an SQL WHERE predicate.
Parameters: - $sqlWhereClause (string) –
- $params (array) – optional Set of parameters to bind to the WHERE clause. Used to prevent security flaws.
- $findOne (boolean) – optional Whether or not to retrieve a single record or the whole set (retrieve all by default).
Returns: array|Omeka_Record_AbstractRecord|false
- count(array $params = Array)¶
Retrieve a count of all the rows in the table.
Parameters: - $params (array) – optional Set of search filters upon which to base the count.
Returns: integer
- getSelectForCount(array $params = Array)¶
Retrieve a select object used to retrieve a count of all the table rows.
Parameters: - $params (array) – optional Set of search filters.
Returns: Omeka_Db_Select
- checkExists(int $id)¶
Check whether a given row exists in the database.
Currently used to verify that a row exists even though the current usermay not have permissions to access it.
Parameters: - $id (int) – The ID of the row.
Returns: boolean
- fetchObjects(string $sql, array $params = Array)¶
Retrieve a set of record objects based on an SQL SELECT statement.
Parameters: - $sql (string) – This could be either a string or any object that can be cast to a string (commonly Omeka_Db_Select).
- $params (array) – Set of parameters to bind to the SQL statement.
Returns: array|null Set of Omeka_Record_AbstractRecord instances, or null if none can be found.
- fetchObject(string $sql, string $params = Array)¶
Retrieve a single record object from the database.
Parameters: - $sql (string) –
- $params (string) – Parameters to substitute into SQL query.
Returns: Omeka_Record_AbstractRecord or null if no record
- recordFromData(array $data)¶
Populate a record object with data retrieved from the database.
Parameters: - $data (array) – A keyed array representing a row from the database.
Returns: Omeka_Record_AbstractRecord
- _getSortParams(array $params)¶
Get and parse sorting parameters to pass to applySorting.
A sorting direction of ‘ASC’ will be used if no direction parameter ispassed.
Parameters: - $params (array) –
Returns: array|null Array of sort field, sort dir if params exist, null otherwise.
- _getHookName(string $suffix)¶
Get the name for a model-specific hook or filter..
Parameters: - $suffix (string) – The hook-specific part of the hook name.
Returns: string
Table_Collection¶
- class Table_Collection¶
Package: Db\Table
- applySearchFilters($select, $params)¶
Parameters: - $select (unknown) –
- $params (unknown) –
- _getColumnPairs()¶
- findPairsForSelectForm($options = Array)¶
Parameters: - $options (unknown) –
- getSelect()¶
Apply permissions checks to all SQL statements retrieving collections from the table
Returns: void
- findRandomFeatured()¶
- filterByPublic($select, $isPublic)¶
Apply a filter to the collections based on whether or not they are public
Parameters: - $select (unknown) –
- $isPublic (unknown) –
Returns: void
- filterByFeatured($select, $isFeatured)¶
Apply a filter to the collections based on whether or not they are featured
Parameters: - $select (unknown) –
- $isFeatured (unknown) –
Returns: void
- applySorting(Omeka_Db_Select $select, string $sortField, string $sortDir)¶
Enables sorting based on ElementSet,Element field strings.
Parameters: - $select (Omeka_Db_Select) –
- $sortField (string) – Field to sort on
- $sortDir (string) – Sorting direction (ASC or DESC)
Table_Element¶
- class Table_Element¶
Package: Db\Table
- findByRecordType($recordTypeName)¶
Find all the Element records that have a specific record type or the record type ‘All’, indicating that these elements would apply to any record type.
Parameters: - $recordTypeName (unknown) –
Returns: array
- getSelect()¶
Overriding getSelect() to always return the type_name and type_regex for retrieved elements.
Returns: Omeka_Db_Select
- _getColumnPairs()¶
Return the element’s name and id for <select> tags on it.
Returns: void
- orderElements($select)¶
Parameters: - $select (unknown) –
- findBySet($elementSet)¶
Retrieve all elements for a set.
Parameters: - $elementSet (unknown) –
Returns: Element
- findByItemType($itemTypeId)¶
Retrieve a set of Element records that belong to a specific Item Type.
Parameters: - $itemTypeId (unknown) –
Returns: array Set of element records.
- findByElementSetNameAndElementName($elementSetName, $elementName)¶
Parameters: - $elementSetName (unknown) –
- $elementName (unknown) –
- applySearchFilters(Omeka_Db_Select $select, array $params)¶
Manipulate a Select object based on a set of criteria.
Parameters: - $select (Omeka_Db_Select) –
- $params (array) –
Possible parameters include:
- record_types - array - Usually one or more of the following: All, Item, File
- sort - string - One of the following values: alpha
- element_set_name - string - Name of the element set to which results should belong.
- findPairsForSelectForm(array $options = Array)¶
Override parent class method to retrieve a multidimensional array of elements, organized by element set, to be used in Zend’s FormSelect view helper.
Parameters: - $options (array) – Set of parameters for searching/filtering results.
Returns: array
Table_ElementSet¶
- class Table_ElementSet¶
Package: Db\Table
- getSelect()¶
- findByRecordType($recordTypeName, $includeAll = 1)¶
Find all the element sets that correspond to a particular record type. If the second param is set, this will include all element sets that belong to the ‘All’ record type.
Parameters: - $recordTypeName (unknown) –
- $includeAll (unknown) –
Returns: array
- findByName($name)¶
Parameters: - $name (unknown) –
Table_ElementText¶
- class Table_ElementText¶
Package: Db\Table
- getSelectForRecord($recordId, $recordType)¶
Parameters: - $recordId (unknown) –
- $recordType (unknown) –
Returns: Omeka_Db_Select
- findByRecord(Omeka_Record_AbstractRecord $record)¶
Find all ElementText records for a given database record (Item, File, etc).
Parameters: - $record (Omeka_Record_AbstractRecord) –
Returns: array
- findByElement($elementId)¶
Parameters: - $elementId (unknown) –
Table_File¶
- class Table_File¶
Package: Db\Table
- property _target¶
- getSelect()¶
All files should only be retrieved if they join properly on the items table.
Returns: Omeka_Db_Select
- getRandomFileWithImage(integer $itemId)¶
Retrieve a random file with an image associated with an item.
Parameters: - $itemId (integer) –
Returns: File
- findByItem(integer $itemId, array $fileIds = Array, string $sort = order)¶
Retrieve files associated with an item.
Parameters: - $itemId (integer) –
- $fileIds (array) – Optional If given, this will only retrieve files with these specific IDs.
- $sort (string) – The manner by which to order the files. For example: ‘id’: file id, ‘filename’ = alphabetical by filename. The default is ‘order’, following the user’s specified order.
Returns: array
- findWithImages(integer $itemId, integer|null $index, string $sort = order)¶
Retrieve files for an item that has derivative images.
Parameters: - $itemId (integer) – The ID of the item to get images for.
- $index (integer|null) – Optional If given, this specifies the file to retrieve for an item, based upon the ordering of its files.
- $sort (string) – The manner by which to order the files. For example: ‘id’: file id, ‘filename’: alphabetical by filename. The default is ‘order’, following the user’s specified order.
Returns: File|array
- _orderFilesBy($select, string $sort)¶
Orders select results for files.
Parameters: - $select (unknown) –
- $sort (string) – The manner in which to order the files by. For example: ‘id’ = file id ‘filename’ = alphabetical by filename
Returns: void
Table_Item¶
- class Table_Item¶
Package: Db\Table
- filterByRange(Omeka_Db_Select $select, string $range)¶
Can specify a range of valid Item IDs or an individual ID
Parameters: - $select (Omeka_Db_Select) –
- $range (string) – Example: 1-4, 75, 89
Returns: void
- filterBySearch($select, $params)¶
Run the search filter on the SELECT statement
Parameters: - $select (unknown) –
- $params (unknown) –
Returns: void
- _simpleSearch(Zend_Db_Select $select, $terms)¶
Build the simple search.
The search query consists of a derived table that is INNER JOINed to themain SQL query. That derived table is a union of two SELECT queries. Thefirst query searches the FULLTEXT index on the items_elements table, andthe second query searches the tags table for every word in the searchterms and assigns each found result a rank of ‘1’. That should maketagged items show up higher on the found results list for a given search.
Parameters: - $select (Zend_Db_Select) –
- $terms (unknown) –
- _advancedSearch(Zend_Db_Select $select, $terms)¶
Build the advanced search.
Parameters: - $select (Zend_Db_Select) –
- $terms (unknown) –
- filterByPublic($select, $isPublic)¶
Apply a filter to the items based on whether or not they should be public
Parameters: - $select (unknown) –
- $isPublic (unknown) –
Returns: void
- filterByFeatured($select, $isFeatured)¶
Parameters: - $select (unknown) –
- $isFeatured (unknown) –
- filterByCollection($select, $collection)¶
Filter the SELECT statement based on an item’s collection
Parameters: - $select (unknown) –
- $collection (unknown) –
Returns: void
- filterByItemType($select, $type)¶
Filter the SELECT statement based on the item Type
Parameters: - $select (unknown) –
- $type (unknown) –
Returns: void
- filterByTags($select, $tags)¶
Query must look like the following in order to correctly retrieve items that have all the tags provided (in this example, all items that are tagged both ‘foo’ and ‘bar’):
SELECT i.idFROM omeka_items iWHERE(i.id IN(SELECT tg.record_id as idFROM omeka_records_tags tgINNER JOIN omeka_tags t ON t.id = tg.tag_idWHERE t.name = ‘foo’ AND tg.record_type = ‘Item’)AND i.id IN(SELECT tg.record_id as idFROM omeka_records_tags tgINNER JOIN omeka_tags t ON t.id = tg.tag_idWHERE t.name = ‘bar’ AND tg.record_type = ‘Item’))...
Parameters: - $select (unknown) –
- $tags (unknown) –
Returns: void
- filterByUser($select, integer $userId, $isUser = 1)¶
Filter the SELECT based on the user who owns the item
Parameters: - $select (unknown) –
- $userId (integer) – ID of the User to filter by
- $isUser (unknown) –
Returns: void
- filterByExcludedTags($select, $tags)¶
Filter SELECT statement based on items that are not tagged with a specific set of tags
Parameters: - $select (unknown) –
- $tags (unknown) –
Returns: void
- filterByHasDerivativeImage($select, boolean $hasDerivativeImage = 1)¶
Filter SELECT statement based on whether items have a derivative image file.
Parameters: - $select (unknown) –
- $hasDerivativeImage (boolean) – Whether items should have a derivative image file.
Returns: void
- applySearchFilters($select, $params)¶
Possible options: ‘public’,’user’,’featured’,’collection’,’type’,’tag’, ‘excludeTags’, ‘search’, ‘range’, ‘advanced’, ‘hasImage’,
Parameters: - $select (unknown) –
- $params (unknown) –
Returns: void
- applySorting(Omeka_Db_Select $select, string $sortField, string $sortDir)¶
Enables sorting based on ElementSet,Element field strings.
Parameters: - $select (Omeka_Db_Select) –
- $sortField (string) – Field to sort on
- $sortDir (string) – Sorting direction (ASC or DESC)
- getSelect()¶
This is a kind of simple factory that spits out proper beginnings of SQL statements when retrieving items
Returns: Omeka_Db_Select
- findFirst()¶
Return the first item accessible to the current user.
Returns: Item|null
- findLast()¶
Return the last item accessible to the current user.
Returns: Item|null
- findPrevious($item)¶
Parameters: - $item (unknown) –
- findNext($item)¶
Parameters: - $item (unknown) –
- findNearby($item, $position = next)¶
Parameters: - $item (unknown) –
- $position (unknown) –
Table_ItemType¶
Table_ItemTypesElements¶
Table_Plugin¶
Table_Process¶
Table_RecordsTags¶
Table_SearchText¶
Table_Tag¶
- class Table_Tag¶
Package: Db\Table
- findOrNew($name)¶
Parameters: - $name (unknown) –
- filterByRecord($select, $record)¶
Filter a SELECT statement based on an Omeka_Record_AbstractRecord instance
Parameters: - $select (unknown) –
- $record (unknown) –
Returns: void
- applySorting(Omeka_Db_Select $select, string $sortField, string $sortDir)¶
Apply custom sorting for tags.
This also applies the normal, built-in sorting.
Parameters: - $select (Omeka_Db_Select) –
- $sortField (string) – Sorting field.
- $sortDir (string) – Sorting direction, suitable for direct inclusion in SQL (ASC or DESC).
- filterByTagType($select, $type)¶
Filter SELECT statement based on the type of tags to view (Item, Exhibit, etc.)
Parameters: - $select (unknown) –
- $type (unknown) –
Returns: void
- filterByTagNameLike($select, $partialTagName)¶
Filter SELECT statement based on whether the tag contains the partial tag name
Parameters: - $select (unknown) –
- $partialTagName (unknown) –
Returns: void
- applySearchFilters($select, array $params = Array)¶
Retrieve a certain number of tags
Parameters: - $select (unknown) –
- $params (array) – ‘limit’ => integer ‘record’ => instanceof Omeka_Record_AbstractRecord ‘like’ => partial_tag_name ‘type’ => tag_type
Returns: void
- getSelect()¶
Returns: Omeka_Db_Select
- findTagNamesLike($partialName, $limit = 10)¶
Parameters: - $partialName (unknown) –
- $limit (unknown) –
Table_User¶
- class Table_User¶
Package: Db\Table
- findActiveById($id)¶
Find an active User given that user’s ID.
Returns null if the user being requested is not active.
Parameters: - $id (unknown) –
Returns: User|null
- _getColumnPairs()¶
- findByEmail($email)¶
Parameters: - $email (unknown) –
- applySearchFilters($select, $params)¶
Parameters: - $select (unknown) –
- $params (unknown) –
File\Derivative¶
Up to File
Omeka_File_Derivative_Exception¶
- class Omeka_File_Derivative_Exception¶
Package: File\Derivative
Exception to throw when something goes wrong in the process of creating derivative images.
- property message¶
- property string¶
- property code¶
- property file¶
- property line¶
- property trace¶
- property previous¶
- __clone()¶
- __construct($message, $code, $previous)¶
Parameters: - $message (unknown) –
- $code (unknown) –
- $previous (unknown) –
- getMessage()¶
- getCode()¶
- getFile()¶
- getLine()¶
- getTrace()¶
- getPrevious()¶
- getTraceAsString()¶
- __toString()¶
Omeka_File_Derivative_Image_Creator¶
- class Omeka_File_Derivative_Image_Creator¶
Package: File\Derivative
Create derivative images for a file in Omeka.
- property _convertPath¶
- property _identifyPath¶
- property _derivatives¶
- __construct($imDirPath)¶
Parameters: - $imDirPath (unknown) –
- setImageMagickDirPath(string $imDirPath)¶
Set the path to the ImageMagick executable.
Parameters: - $imDirPath (string) – Path to the directory containing the ImageMagick binaries.
- getConvertPath()¶
Get the full path to the ImageMagick ‘convert’ command.
Returns: string
- getIdentifyPath()¶
Get the full path to the ImageMagick ‘identify’ command.
Returns: string
- create(string $fromFilePath, string $derivFilename, string $mimeType)¶
Create all the derivatives requested with addDerivative().
Parameters: - $fromFilePath (string) –
- $derivFilename (string) –
- $mimeType (string) –
Returns: boolean
- addDerivative(string $storageType, integer|string $size, boolean $square =)¶
Add a derivative image to be created.
Parameters: - $storageType (string) –
- $size (integer|string) – If an integer, it is the size constraint for the image, meaning it will have that maximum width or height, depending on whether the image is landscape or portrait. Otherwise, it is a string of arguments to be passed to the ImageMagick convert utility. MUST BE PROPERLY ESCAPED AS SHELL ARGUMENTS.
- $square (boolean) – Whether the derivative to add should be made square.
- _createImage($origPath, $newPath, $convertArgs)¶
Generate a derivative image from an existing file stored in Omeka.
This image will be generated based on a constraint given in pixels. Forexample, if the constraint is 500, the resulting image file will be scaledso that the largest side is 500px. If the image is less than 500px on bothsides, the image will not be resized.
Derivative images will only be generated for files with mime typesthat can be identified with ImageMagick’s ‘identify’ command
Parameters: - $origPath (unknown) –
- $newPath (unknown) –
- $convertArgs (unknown) –
- _getResizeCmdArgs(integer $constraint, boolean $square)¶
Get the ImageMagick command line for resizing to the given constraints.
Parameters: - $constraint (integer) – Maximum side length in pixels.
- $square (boolean) – Whether the derivative should be squared off.
Returns: string
- _isDerivable(string $filePath)¶
Returns true only if ImageMagick is able to make derivative images of that file based upon whether or not it can be identified by ImageMagick’s ‘identify’ binary. Otherwise returns false.
Parameters: - $filePath (string) –
Returns: boolean
- _isIdentifiable(string $filePath)¶
Returns true only if the file can be identified by ImageMagick’s ‘identify’ binary
Parameters: - $filePath (string) –
Returns: boolean
- isValidImageMagickPath($dirToIm)¶
Determine whether or not the path given to ImageMagick is valid. Both the convert and identify binaries must be within the directory and executable.
Parameters: - $dirToIm (unknown) –
Returns: boolean
- getDefaultImageMagickDir()¶
Retrieve the path to the directory containing ImageMagick’s convert utility. Th
Uses the ‘which’ command-line utility to detect the path to ‘convert’.Note that this will only work if the convert utility is in PHP’s PATH andthus can be located by ‘which’.
Returns: string The path to the directory if it can be found. Otherwise returns an empty string.
- executeCommand($cmd, $status, $output, $errors)¶
Parameters: - $cmd (unknown) –
- $status (unknown) –
- $output (unknown) –
- $errors (unknown) –
Filter¶
Up to Class Library by Package
Omeka_Filter_Boolean¶
Omeka_Filter_Filename¶
- class Omeka_Filter_Filename¶
Package: Filter
Rename a file to make it suitable for inclusion in the Omeka repository.
- filter(string $value)¶
Grab the original path to the file, rename it according to our convention, and return the new path to the file.
Parameters: - $value (string) – Path to the file.
Returns: string Path to the (renamed) file.
- renameFile(string $name)¶
Creates a new, random filename for storage in Omeka.
Parameters: - $name (string) –
Returns: string
Omeka_Filter_ForeignKey¶
- class Omeka_Filter_ForeignKey¶
Package: Filter
Converts input into values suitable for use as Omeka ‘id’ key values.
- filter(mixed $value)¶
Convert any value into an unsigned integer that would be valid if stored as a foreign key in a database table.
This will return null for any value that falls outside the rangeof an unsigned integer (string, negative numbers, etc.)
Parameters: - $value (mixed) – Input value.
Returns: integer
Omeka_Filter_HtmlPurifier¶
- class Omeka_Filter_HtmlPurifier¶
Package: Filter
A Zend_Filter implementation that uses HtmlPurifier to purify a string.
- property _purifier¶
- property _purifierConfig¶
- filter($value)¶
Filter the value
Parameters: - $value (unknown) –
Returns: string An html purified string
- getDefaultAllowedHtmlElements()¶
Get the default allowed html elements.
Returns: array An array of strings corresponding to the allowed html elements
- getDefaultAllowedHtmlAttributes()¶
Get the default allowed html attributes.
Returns: array An array of strings corresponding to the allowed html attributes
- getHtmlPurifier()¶
Gets the html purifier singleton
Returns: HTMLPurifier $purifier
- setHtmlPurifier(HTMLPurifier $purifier)¶
Sets the html purifier singleton
Parameters: - $purifier (HTMLPurifier) –
Returns: void
- createHtmlPurifier(array $allowedHtmlElements, array $allowedHtmlAttributes)¶
Parameters: - $allowedHtmlElements (array) – An array of strings representing allowed HTML elements
- $allowedHtmlAttributes (array) – An array of strings representing allowed HTML attributes
Returns: HTMLPurifier
- filterAttributesWithMissingElements($htmlAttributes = Array, $htmlElements = Array)¶
Parameters: - $htmlAttributes (unknown) –
- $htmlElements (unknown) –
Form¶
Up to Class Library by Package
Omeka_Form¶
- class Omeka_Form¶
Package: Form
A Zend_Form subclass that sets up forms to be properly displayed in Omeka.
- property _defaultDisplayGroupClass¶
Class name of Omeka DisplayGroup subclass.
- property _autoApplyOmekaStyles¶
Whether or not to automatically apply Omeka-specific decorators and styling information to form elements prior to rendering.
- init()¶
Set up Omeka-specific form elements and decorators.
Returns: void
- loadDefaultDecorators()¶
Set up base form decorators.
Returns: void
- getDefaultElementDecorators()¶
Return default decorators for form elements.
Makes form output conform to Omeka conventions.
Returns: array
- applyOmekaStyles()¶
Configure element styles / decorators based on the type of element.
This may be called after elements to the form, as the decoratorconfiguration in init() runs before elements can be added.
Returns: void
- getMessagesAsString(string $messageDelimiter =, string $elementDelimiter =)¶
Retrieve all of the form error messages as a nicely formatted string.
Useful for displaying all form errors at the top of a form, or for flashingform errors after redirects.
Parameters: - $messageDelimiter (string) – The string to display between different error messages for an element.
- $elementDelimiter (string) – The string to display between different elements.
Returns: string
- setAutoApplyOmekaStyles(mixed $flag)¶
Specify whether or not to automatically apply Omeka-specific decorators and styles prior to rendering the form.
Parameters: - $flag (mixed) – A boolean or boolean-equivalent.
Returns: void
- render(Zend_View_Interface $view)¶
Apply Omeka default styles (if requested) just before rendering.
Parameters: - $view (Zend_View_Interface) –
Returns: string
- _addClassNameToElement(Zend_Form_Element $element, string $className)¶
Add a specific class name to an element.
Parameters: - $element (Zend_Form_Element) –
- $className (string) –
Returns: void
Omeka_Form_Admin¶
- class Omeka_Form_Admin¶
Package: Form
A Zend_Form subclass to set up a record editing form for the Omeka 2.0 admin user interface
- property _editDisplayGroup¶
- property _saveDisplayGroup¶
- property _saveDisplayGroupActionDecorator¶
- property _record¶
- property _type¶
- property _hasPublicPage¶
- property _editGroupCssClass¶
- property _saveGroupCssClass¶
- init()¶
- addElementToEditGroup(Zend_Form_Element|string $element, string|null $name, array|null $options)¶
Add an element to the edit area
Parameters: - $element (Zend_Form_Element|string) –
- $name (string|null) –
- $options (array|null) –
- addElementToSaveGroup(Zend_Form_Element|string $element, string|null $name, array|null $options)¶
Add an element to the save panel
Parameters: - $element (Zend_Form_Element|string) –
- $name (string|null) –
- $options (array|null) –
- addElementToDisplayGroup(string $group, Zend_Form_Element $element, string $name, array $options)¶
Generalizes creating and adding new elements to one of the display groups
You can pass in either an Zend_Form_Element you have already created, or passparameters as you would to Zend_Form::addElement
Parameters: - $group (string) – Either ‘save’ or ‘edit’
- $element (Zend_Form_Element) – The element to add to the display group
- $name (string) –
- $options (array) –
Returns: Omeka_Form_Admin
- getSaveGroupDefaultElementDecorators()¶
Get the decorators for the save display group
Returns: array The default decorators for the save display group
- setEditGroupCssClass(string $cssClass)¶
Set the class for the edit display group.
You can alter the default css class for the edit group panel by passing in anoption for ‘editGroupCssClass’ when you create an instance of Omeka_Form_Admin.This should be done very sparingly, as the default class is the best match toexisting admin theme look and feel
Parameters: - $cssClass (string) –
- setSaveGroupCssClass(string $cssClass)¶
Set the class for the save display group.
You can alter the default css class for the save group panel by passing in anoption for ‘editGroupCssClass’ when you create an instance of Omeka_Form_Admin.This should be done very sparingly, as the default class is the best match toexisting admin theme look and feel
Parameters: - $cssClass (string) –
- setType(string $type)¶
Set the record type of the object being edited (e.g., ‘item’)
Pass in the recordType as part of the options array when you create an instance
Parameters: - $type (string) –
- setRecord(Omeka_Record_AbstractRecord $record)¶
Set the record (if one exists) for the object being edited
Passing the record object as part of the options when you create the formwill automatically add ‘Edit’ and ‘Delete’ buttons to the save panel
Parameters: - $record (Omeka_Record_AbstractRecord) –
- setHasPublicPage(bool $value =)¶
Set whether the save panel should display a link to the record’s public page if it exists
By default, a link to a record’s public page is available if it exists. Pass false as the value of hasPublicPage in the options array to suppress this behavior.
Parameters: - $value (bool) – true
Http¶
Up to Class Library by Package
Omeka_Http_Client¶
- class Omeka_Http_Client¶
Package: Http
Wrapper for Zend_Http_Client.
Adds the following functionality: retries on timeouts.
- property _maxRetries¶
- property _retryCount¶
- request($method)¶
Wraps Zend_Http_Client to automatically retry timed out requests.
Parameters: - $method (unknown) –
- setMaxRetries(integer $count)¶
Set the maximum number of retries to make when a request times out.
Parameters: - $count (integer) –
Install¶
Up to Class Library by Package
Installer_Default¶
- class Installer_Default¶
Package: Install
The default installer, which extracts values from the installer form to create the default Omeka installation.
- property _db¶
- property _form¶
- setForm(Zend_Form $form)¶
Set the form from which to extract data for the installer.
Parameters: - $form (Zend_Form) –
- getDb()¶
- install()¶
- _getValue($fieldName)¶
Parameters: - $fieldName (unknown) –
- _createSchema()¶
- _createUser()¶
- _setupMigrations()¶
- _addOptions()¶
- isInstalled()¶
Installer_Exception¶
- class Installer_Exception¶
Package: Install
- property message¶
- property string¶
- property code¶
- property file¶
- property line¶
- property trace¶
- property previous¶
- __clone()¶
- __construct($message, $code, $previous)¶
Parameters: - $message (unknown) –
- $code (unknown) –
- $previous (unknown) –
- getMessage()¶
- getCode()¶
- getFile()¶
- getLine()¶
- getTrace()¶
- getPrevious()¶
- getTraceAsString()¶
- __toString()¶
Installer_InstallerInterface¶
Installer_Requirements¶
- class Installer_Requirements¶
Package: Install
- property _dbAdapter¶
- property _storage¶
- property _errorMessages¶
- property _warningMessages¶
- check()¶
- getErrorMessages()¶
- getWarningMessages()¶
- hasError()¶
- hasWarning()¶
- setDbAdapter(Zend_Db_Adapter_Abstract $db)¶
Parameters: - $db (Zend_Db_Adapter_Abstract) –
- setStorage(Omeka_Storage $storage)¶
Parameters: - $storage (Omeka_Storage) –
- _checkPhpVersionIsValid()¶
- _checkMysqliIsAvailable()¶
- _checkMysqlVersionIsValid()¶
- _checkHtaccessFilesExist()¶
- _checkRegisterGlobalsIsOff()¶
- _checkExifModuleIsLoaded()¶
- _checkFileStorageSetup()¶
- _checkFileinfoIsLoaded()¶
Installer_TaskInterface¶
Installer_Task_Exception¶
Installer_Task_Migrations¶
Installer_Task_Options¶
Installer_Task_Schema¶
- class Installer_Task_Schema¶
Package: Install
Load the database schema for an Omeka installation.
Schema should be defined in an SQL file.
- property _defaultTables¶
- property _tables¶
- addTable(string $tableName, string $sqlFilePath)¶
Add an SQL table to the list of tables to create.
Parameters: - $tableName (string) –
- $sqlFilePath (string) –
- addTables(array $tables)¶
Add a set of SQL tables to the list.
Parameters: - $tables (array) –
- setTables(array $tables)¶
Set the list of SQL tables.
Parameters: - $tables (array) –
- removeTable(string $tableName)¶
Remove an SQL table from the list.
Parameters: - $tableName (string) –
- getTables()¶
Retrieve list of tables being installed.
- useDefaultTables()¶
Add all tables corresponding to the default Omeka installation.
Installer_Test¶
- class Installer_Test¶
Package: Install
Installer for test cases that require database access.
- property _testDefaults¶
- property _db¶
- property _form¶
- _getValue($fieldName)¶
Overridden to retrieve values only from a predefined array.
Parameters: - $fieldName (unknown) –
- install()¶
- setForm(Zend_Form $form)¶
Set the form from which to extract data for the installer.
Parameters: - $form (Zend_Form) –
- getDb()¶
- _createSchema()¶
- _createUser()¶
- _setupMigrations()¶
- _addOptions()¶
- isInstalled()¶
Install\Task¶
Up to Install
Installer_Task_User¶
- class Installer_Task_User¶
Package: Install\Task
Create a default user for an Omeka installation.
- property _username¶
- property _password¶
- property _email¶
- property _name¶
- property _lastName¶
- property _active¶
- property _role¶
- setUsername($username)¶
Parameters: - $username (unknown) –
- setPassword($password)¶
Parameters: - $password (unknown) –
- setEmail($email)¶
Parameters: - $email (unknown) –
- setName($name)¶
Parameters: - $name (unknown) –
- setIsActive($active)¶
Parameters: - $active (unknown) –
- setRole($role)¶
Parameters: - $role (unknown) –
Job¶
Up to Class Library by Package
Job_ItemBatchEdit¶
Job_SearchTextIndex¶
Omeka_Job_AbstractJob¶
- class Omeka_Job_AbstractJob¶
Package: Job
Abstract implementation of an Omeka job.
Most plugin implementations of jobs will extend this class to gain convenientaccess to the database and other potentially important resources.
- property _db¶
- property _dispatcher¶
- property _user¶
- property _options¶
- __construct($options)¶
Parameters: - $options (unknown) –
- _setOptions($options)¶
Set all the options associated with this task.
This is a convenience method that calls setter methods for the optionsgiven in the array. If an element in the array does not have anassociated setter method, it will be passed into the options array.
Parameters: - $options (unknown) –
- setJobDispatcher(Omeka_Job_Dispatcher_DispatcherInterface $dispatcher)¶
Parameters: - $dispatcher (Omeka_Job_Dispatcher_DispatcherInterface) –
- getUser()¶
Get the User currently set on this Job, if any.
Returns: User|null
- resend()¶
Resend the job using the same options that were passed to the current job.
- perform()¶
Omeka_Job_JobInterface¶
Omeka_Job_Mock¶
- class Omeka_Job_Mock¶
Package: Job
Mock job class for unit tests.
- property options¶
- property performed¶
- property _db¶
- property _dispatcher¶
- property _user¶
- property _options¶
- __construct($options)¶
Parameters: - $options (unknown) –
- perform()¶
- getDb()¶
Getter method to expose protected properties.
- getDispatcher()¶
Getter method to expose protected properties.
- getMiscOptions()¶
- _setOptions($options)¶
Set all the options associated with this task.
This is a convenience method that calls setter methods for the optionsgiven in the array. If an element in the array does not have anassociated setter method, it will be passed into the options array.
Parameters: - $options (unknown) –
- setJobDispatcher(Omeka_Job_Dispatcher_DispatcherInterface $dispatcher)¶
Parameters: - $dispatcher (Omeka_Job_Dispatcher_DispatcherInterface) –
- getUser()¶
Get the User currently set on this Job, if any.
Returns: User|null
- resend()¶
Resend the job using the same options that were passed to the current job.
Job\Dispatcher¶
Up to Job
Omeka_Job_Dispatcher_Default¶
- class Omeka_Job_Dispatcher_Default¶
Package: Job\Dispatcher
Dispatches jobs in Omeka.
This provides a clean interface to adapter classes that deal with the detailsof how to dispatch jobs. It is initialized in the Jobs bootstrap resource andcan be accessed via the registry.
Standard usage, where Job_Class_Name corresponds to a valid class name for a class implementing Omeka_JobInterface:
$dispatcher = Zend_Registry::get('job_dispatcher'); $dispatcher->send('Job_Class_Name', array( 'firstOption' => 'text', 'secondOption' => 2 ));
- property _defaultAdapter¶
- property _longRunningAdapter¶
- property _user¶
- __construct(Omeka_Job_Dispatcher_Adapter_AdapterInterface $defaultAdapter, Omeka_Job_Dispatcher_Adapter_AdapterInterface $longRunningAdapter, User|null $user)¶
Parameters: - $defaultAdapter (Omeka_Job_Dispatcher_Adapter_AdapterInterface) –
- $longRunningAdapter (Omeka_Job_Dispatcher_Adapter_AdapterInterface) –
- $user (User|null) – The user account associated with the request, i.e. the user account associated with jobs sent by the dispatcher.
- setUser(User|null $user)¶
Set the user.
Parameters: - $user (User|null) –
- getUser()¶
Get the user.
Returns: User|null
- setDefaultAdapter(Omeka_Job_Dispatcher_Adapter_AdapterInterface $defaultAdapter)¶
Set the default adapter.
Parameters: - $defaultAdapter (Omeka_Job_Dispatcher_Adapter_AdapterInterface) –
- setLongRunningAdapter(Omeka_Job_Dispatcher_Adapter_AdapterInterface $longRunningAdapter)¶
Set the long running adapter.
Parameters: - $longRunningAdapter (Omeka_Job_Dispatcher_Adapter_AdapterInterface) –
- setQueueName(string $name)¶
Set the name of the queue to which default jobs will be sent.
NOTE: This may be ignored by adapters that do not understand the notionof named queues (or queues in general).
Parameters: - $name (string) –
- setQueueNameLongRunning(string $name)¶
Set the name of the queue to which long-running jobs will be sent.
NOTE: This may be ignored by adapters that do not understand the notionof named queues (or queues in general).
Parameters: - $name (string) –
- send(string $jobClass, array $options = Array)¶
Dispatch a job using the default dispatcher.
Parameters: - $jobClass (string) – Class name that implements Omeka_JobInterface.
- $options (array) – Optional associative array containing options that the task needs in order to do its job. Note that all options should be primitive data types (or arrays containing primitive data types).
- sendLongRunning(string $jobClass, array $options = Array)¶
Dispatch a job using the long-running dispatcher.
Parameters: - $jobClass (string) – Name of a class that implements Omeka_JobInterface.
- $options (array) – Optional associative array containing options that the task needs in order to do its job. Note that all options should be primitive data types (or arrays containing primitive data types).
- _getJobMetadata($class, $options)¶
Parameters: - $class (unknown) –
- $options (unknown) –
- _toJson($metadata)¶
Parameters: - $metadata (unknown) –
Omeka_Job_Dispatcher_DispatcherInterface¶
- class Omeka_Job_Dispatcher_DispatcherInterface¶
Package: Job\Dispatcher
Interface for job dispatchers in Omeka.
- setQueueName(string $name)¶
Set the name of the queue to which jobs will be sent.
NOTE: This may be ignored by adapters that do not understand the notionof named queues (or queues in general).
Parameters: - $name (string) –
- send(string $jobClass, array $options = Array)¶
Parameters: - $jobClass (string) – Name of a class that implements Omeka_JobInterface.
- $options (array) – Optional Associative array containing options that the task needs in order to do its job. Note that all options should be primitive data types (or arrays containing primitive data types).
Job\Dispatcher\Adapter¶
Up to Job\Dispatcher
- class Omeka_Job_Dispatcher_Adapter_AbstractAdapter¶
Package: Job\Dispatcher\Adapter
Abstract class for job dispatcher adapters.
- property _options¶
- __construct(array|null $options)¶
Parameters: - $options (array|null) – Optional Options to instantiate in the adapter.
- _setOptions($options)¶
Parameters: - $options (unknown) –
- getOption(string $name)¶
Retrieve an option by name as it was passed to the constructor of the adapter.
Parameters: - $name (string) –
- hasOption(string $name)¶
Whether or not the given option has been set.
Parameters: - $name (string) –
- setQueueName($name)¶
Adapter implementations do not understand named queues by default, so this default implementation returns false. Override this in subclasses to specify the correct behavior.
Parameters: - $name (unknown) –
- send(string $encodedJob, array $metadata)¶
Send the job to whatever underlying system is used by the adapter.
Parameters: - $encodedJob (string) – The job encoded as a string. In most cases, this will be passed directly into whatever client or queue the adapter uses.
- $metadata (array) – An array containing all the metadata for the job. This is the unencoded version of the first argument and exists as a convenience so that adapter writers do not have to attempt to decode the first argument manually. This array contains the following keys: <ul> <li>className - Corresponds to the class name of the job.</li> <li>options - Options that are passed to the job when it is instantiated.</li> <li>createdBy - User object (or null) corresponding to the user who created this job.</li> <li>createdAt - Zend_Date corresponding to the date/time at which this job was created.</li> </ul>
- class Omeka_Job_Dispatcher_Adapter_AdapterInterface¶
Package: Job\Dispatcher\Adapter
Interface for job dispatcher adapters.
- setQueueName(string $name)¶
Set the name of the queue that the adapter will use for incoming jobs.
Note that this will not be used by some adapters and should beimplemented to return false in those cases.
Parameters: - $name (string) –
- send(string $encodedJob, array $metadata)¶
Send the job to whatever underlying system is used by the adapter.
Parameters: - $encodedJob (string) – The job encoded as a string. In most cases, this will be passed directly into whatever client or queue the adapter uses.
- $metadata (array) – An array containing all the metadata for the job. This is the unencoded version of the first argument and exists as a convenience so that adapter writers do not have to attempt to decode the first argument manually. This array contains the following keys: <ul> <li>className - Corresponds to the class name of the job.</li> <li>options - Options that are passed to the job when it is instantiated.</li> <li>createdBy - User object (or null) corresponding to the user who created this job.</li> <li>createdAt - Zend_Date corresponding to the date/time at which this job was created.</li> </ul>
- class Omeka_Job_Dispatcher_Adapter_Array¶
Package: Job\Dispatcher\Adapter
Store dispatched jobs in an array.
This is used primarily by unit tests and should not be used in productioncode.
- property _queueName¶
- property _jobs¶
- setQueueName($name)¶
Parameters: - $name (unknown) –
- send($encodedJob, $metadata)¶
Parameters: - $encodedJob (unknown) –
- $metadata (unknown) –
- getJobs()¶
- getJob($index = 0)¶
Parameters: - $index (unknown) –
- class Omeka_Job_Dispatcher_Adapter_BackgroundProcess¶
Package: Job\Dispatcher\Adapter
Job dispatcher that uses Omeka’s existing background process API.
- property _processDispatcher¶
- property _options¶
- send($encodedJob, $metadata)¶
Dispatches a background process that executes the given job.
NOTE: No user account is bootstrapped when background.php runs (since itis CLI), so if a process triggers its own subprocesses, those will belisted as belonging to no user (ID = 0).
Parameters: - $encodedJob (unknown) –
- $metadata (unknown) –
- setProcessDispatcher(Omeka_Job_Process_Dispatcher $dispatcher)¶
For test purposes.
Parameters: - $dispatcher (Omeka_Job_Process_Dispatcher) –
- getProcessDispatcher()¶
- __construct(array|null $options)¶
Parameters: - $options (array|null) – Optional Options to instantiate in the adapter.
- _setOptions($options)¶
Parameters: - $options (unknown) –
- getOption(string $name)¶
Retrieve an option by name as it was passed to the constructor of the adapter.
Parameters: - $name (string) –
- hasOption(string $name)¶
Whether or not the given option has been set.
Parameters: - $name (string) –
- setQueueName($name)¶
Adapter implementations do not understand named queues by default, so this default implementation returns false. Override this in subclasses to specify the correct behavior.
Parameters: - $name (unknown) –
- class Omeka_Job_Dispatcher_Adapter_Beanstalk¶
Package: Job\Dispatcher\Adapter
Job dispatcher for Beanstalk.
Requires Pheanstalk library (Beanstalk client) in order to work properly.
This adapter must be instantiated with the ‘host’ option (IP address ofbeanstalk daemon) in order to work properly.
- constant DEFAULT_TTR¶
Because of the potential for long-running imports (and the fact that jobs are not idemopotent), TTR should be pretty high by default.
- property _pheanstalk¶
- property _options¶
- setQueueName(string $name)¶
Beanstalk understands the concept of ‘tubes’ instead of named queues, so set the appropriate ‘tube’ to dispatch jobs.
Parameters: - $name (string) –
- send($encodedJob, $metadata)¶
Parameters: - $encodedJob (unknown) –
- $metadata (unknown) –
- _pheanstalk()¶
- getOption($name)¶
Parameters: - $name (unknown) –
- __construct(array|null $options)¶
Parameters: - $options (array|null) – Optional Options to instantiate in the adapter.
- _setOptions($options)¶
Parameters: - $options (unknown) –
- hasOption(string $name)¶
Whether or not the given option has been set.
Parameters: - $name (string) –
- class Omeka_Job_Dispatcher_Adapter_RequiredOptionException¶
Package: Job\Dispatcher\Adapter
Exception thrown when required options have not been passed to the Omeka_Job_Dispatcher_Adapter_AdapterInterface’s constructor.
- property message¶
- property code¶
- property file¶
- property line¶
- __clone()¶
- __construct($message, $code, $previous)¶
Parameters: - $message (unknown) –
- $code (unknown) –
- $previous (unknown) –
- getMessage()¶
- getCode()¶
- getFile()¶
- getLine()¶
- getTrace()¶
- getPrevious()¶
- getTraceAsString()¶
- __toString()¶
- class Omeka_Job_Dispatcher_Adapter_Synchronous¶
Package: Job\Dispatcher\Adapter
Dispatcher for executing jobs in real-time, i.e. executing within the browser request.
WARNING: While especially useful for simple jobs or instances where it is notpossible to use one of the other adapters, keep in mind that long jobs maylead to request timeouts or open the possibility of DoS attacks by malicioususers.
- property _options¶
- send($encodedJob, $metadata)¶
Parameters: - $encodedJob (unknown) –
- $metadata (unknown) –
- __construct(array|null $options)¶
Parameters: - $options (array|null) – Optional Options to instantiate in the adapter.
- _setOptions($options)¶
Parameters: - $options (unknown) –
- getOption(string $name)¶
Retrieve an option by name as it was passed to the constructor of the adapter.
Parameters: - $name (string) –
- hasOption(string $name)¶
Whether or not the given option has been set.
Parameters: - $name (string) –
- setQueueName($name)¶
Adapter implementations do not understand named queues by default, so this default implementation returns false. Override this in subclasses to specify the correct behavior.
Parameters: - $name (unknown) –
- class Omeka_Job_Dispatcher_Adapter_ZendQueue¶
Package: Job\Dispatcher\Adapter
Dispatcher for Zend_Queue.
This would be particularly useful for installations that want to interfacewith ActiveMQ or Zend Server’s Job Queue via Zend_Queue. Note that usingthe ‘Array’ adapter should only be used for testing, as all jobs passed toit will be thrown away.
Required options include ‘adapter’ and ‘options’, whichcorrespond to the first and second arguments to Zend_Queue’s constructorrespectively.
For example, it would be configured like so in config.ini:
jobs.dispatcher = "Omeka_Job_Dispatcher_ZendQueue" jobs.adapterOptions.adapter = "PlatformJobQueue" jobs.adapterOptions.options.host = "127.0.0.1" jobs.adapterOptions.options.password = "foobar"
- property _queue¶
- property _options¶
- setQueueName($name)¶
Note that some Zend_Queue implementations understand the concept of named queues, while others do not.
Parameters: - $name (unknown) –
- send($encodedJob, $metadata)¶
Parameters: - $encodedJob (unknown) –
- $metadata (unknown) –
- _queue()¶
- __construct(array|null $options)¶
Parameters: - $options (array|null) – Optional Options to instantiate in the adapter.
- _setOptions($options)¶
Parameters: - $options (unknown) –
- getOption(string $name)¶
Retrieve an option by name as it was passed to the constructor of the adapter.
Parameters: - $name (string) –
- hasOption(string $name)¶
Whether or not the given option has been set.
Parameters: - $name (string) –
Job\Factory¶
Up to Job
Omeka_Job_Factory¶
- class Omeka_Job_Factory¶
Package: Job\Factory
Factory for instantiating Omeka_Job instances.
- property _options¶
- __construct($options = Array)¶
Parameters: - $options (unknown) –
- from(string $json)¶
Decode a message from JSON and use the results to instantiate a new job instance.
Parameters: - $json (string) –
- build($data)¶
Instantiate a new job instance from the arguments given.
Parameters: - $data (unknown) –
Omeka_Job_Factory_MalformedJobException¶
- class Omeka_Job_Factory_MalformedJobException¶
Package: Job\Factory
Exception thrown when the message could not be decoded into valid job metadata.
- property message¶
- property code¶
- property file¶
- property line¶
- __clone()¶
- __construct($message, $code, $previous)¶
Parameters: - $message (unknown) –
- $code (unknown) –
- $previous (unknown) –
- getMessage()¶
- getCode()¶
- getFile()¶
- getLine()¶
- getTrace()¶
- getPrevious()¶
- getTraceAsString()¶
- __toString()¶
Omeka_Job_Factory_MissingClassException¶
- class Omeka_Job_Factory_MissingClassException¶
Package: Job\Factory
Exception thrown when the type of job could not be inferred from the message passed to the factory.
- property message¶
- property code¶
- property file¶
- property line¶
- __clone()¶
- __construct($message, $code, $previous)¶
Parameters: - $message (unknown) –
- $code (unknown) –
- $previous (unknown) –
- getMessage()¶
- getCode()¶
- getFile()¶
- getLine()¶
- getTrace()¶
- getPrevious()¶
- getTraceAsString()¶
- __toString()¶
Job\Process¶
Up to Job
Omeka_Job_Process_AbstractProcess¶
Omeka_Job_Process_Dispatcher¶
- class Omeka_Job_Process_Dispatcher¶
Package: Job\Process
Spawns and manages background processes.
- startProcess(string $className, User $user, Array|null $args)¶
Create a table entry for a new background process and spawn it.
Parameters: - $className (string) – Omeka_Job_Process_AbstractProcess subclass name to spawn
- $user (User) – User to run process as, defaults to current user
- $args (Array|null) – Arguments specific to the child class process
Returns: Process The model object for the background process
- stopProcess(Process $process)¶
Stops a background process in progress.
Parameters: - $process (Process) – The process to stop.
Returns: bool True if the process was stopped, false if not.
- getPHPCliPath()¶
- _checkCliPath($cliPath)¶
Checks if the configured PHP-CLI path points to a valid PHP binary. Flash an appropriate error if the path is invalid.
Parameters: - $cliPath (unknown) –
- _autodetectCliPath()¶
- _getBootstrapFilePath()¶
Returns the path to the background bootstrap script.
Returns: string Path to bootstrap
- _fork($command)¶
Launch a background process, returning control to the foreground.
Parameters: - $command (unknown) –
Omeka_Job_Process_Wrapper¶
- class Omeka_Job_Process_Wrapper¶
Package: Job\Process
Wrapper that allows Omeka_Job to work with the existing Process/ Omeka_Job_Process_Dispatcher API. Jobs are passed in as the ‘job’ argument, and this wrapper handles decoding and executing the job.
- property _process¶
- _getJob($str)¶
Parameters: - $str (unknown) –
- run($args)¶
Args passed in will consist of the JSON-encoded task.
Parameters: - $args (unknown) –
- __destruct()¶
Job\Worker¶
Up to Job
Omeka_Job_Worker_Beanstalk¶
- class Omeka_Job_Worker_Beanstalk¶
Package: Job\Worker
- __construct(Pheanstalk $pheanstalk, Omeka_Job_Factory $jobFactory, Omeka_Db $db)¶
Parameters: - $pheanstalk (Pheanstalk) –
- $jobFactory (Omeka_Job_Factory) –
- $db (Omeka_Db) –
- work(Pheanstalk_Job $pJob)¶
Parameters: - $pJob (Pheanstalk_Job) –
- _interrupt($job)¶
Parameters: - $job (unknown) –
Omeka_Job_Worker_InterruptException¶
- class Omeka_Job_Worker_InterruptException¶
Package: Job\Worker
Exception thrown when the type of job could not be inferred from the message passed to the factory.
- property message¶
- property string¶
- property code¶
- property file¶
- property line¶
- property trace¶
- property previous¶
- __clone()¶
- __construct($message, $code, $previous)¶
Parameters: - $message (unknown) –
- $code (unknown) –
- $previous (unknown) –
- getMessage()¶
- getCode()¶
- getFile()¶
- getLine()¶
- getTrace()¶
- getPrevious()¶
- getTraceAsString()¶
- __toString()¶
Output¶
Up to Class Library by Package
Omeka_Output_OmekaXml_AbstractOmekaXml¶
- class Omeka_Output_OmekaXml_AbstractOmekaXml¶
Package: Output
Abstract base class for creating omeka-xml output formats.
- constant XMLNS_XSI¶
XML Schema instance namespace URI.
- constant XMLNS¶
Omeka-XML namespace URI.
- constant XMLNS_SCHEMALOCATION¶
Omeka-XML XML Schema URI.
- property _record¶
This class’ contextual record(s).
- property _context¶
The context of this DOMDocument. Determines how buildNode() builds the elements. Valid contexts include: item, file.
- property _doc¶
The final document object.
- property _node¶
The node built and set in child::_buildNode()
- _buildNode()¶
Abstract method. child::_buildNode() should set self::$_node.
- __construct(Omeka_Record_AbstractRecord|array $record, string $context)¶
Parameters: - $record (Omeka_Record_AbstractRecord|array) –
- $context (string) – The context of this DOM document.
- getDoc()¶
Get the document object.
Returns: DOMDocument
- _setRootElement(DOMElement $rootElement)¶
Set an element as root.
Parameters: - $rootElement (DOMElement) –
Returns: DOMElement The root element, including required attributes.
- _createElement(string $name, $value, $id, $parentElement)¶
Create a DOM element.
Parameters: - $name (string) – The name of the element.
- $value (unknown) –
- $id (unknown) –
- $parentElement (unknown) –
Returns: DOMElement
- _setContainerPagination(DOMElement $parentElement)¶
Set the pagination node for container elements
Parameters: - $parentElement (DOMElement) –
Returns: void
- _getElemetSetsByElementTexts(Omeka_Record_AbstractRecord $record, bool $getItemType =)¶
Get all element sets, elements, and element texts associated with the provided record.
Parameters: - $record (Omeka_Record_AbstractRecord) – The record from which to extract metadata.
- $getItemType (bool) – Whether to get the item type metadata.
Returns: stdClass A list of element sets or an item type.
- _buildElementSetContainerForRecord(Omeka_Record_AbstractRecord $record, DOMElement $parentElement)¶
Build an elementSetContainer element in a record (item or file) context.
Parameters: - $record (Omeka_Record_AbstractRecord) – The record from which to build element sets.
- $parentElement (DOMElement) – The element set container will append to this element.
Returns: void|null
- _buildItemTypeForItem(Item $item, DOMElement $parentElement)¶
Build an itemType element in an item context.
Parameters: - $item (Item) – The item from which to build the item type.
- $parentElement (DOMElement) – The item type will append to this element.
Returns: void|null
- _buildFileContainerForItem(Item $item, DOMElement $parentElement)¶
Build a fileContainer element in an item context.
Parameters: - $item (Item) – The item from which to build the file container.
- $parentElement (DOMElement) – The file container will append to this element.
Returns: void|null
- _buildCollectionForItem(Item $item, DOMElement $parentElement)¶
Build a collection element in an item context.
Parameters: - $item (Item) – The item from which to build the collection.
- $parentElement (DOMElement) – The collection will append to this element.
Returns: void|null
- _buildTagContainerForItem(Item $item, DOMElement $parentElement)¶
Build a tagContainer element in an item context.
Parameters: - $item (Item) – The item from which to build the tag container.
- $parentElement (DOMElement) – The tag container will append to this element.
Returns: void|null
- _buildItemContainerForCollection(Collection $collection, DOMElement $parentElement)¶
Build an itemContainer element in a collection context.
Parameters: - $collection (Collection) – The collection from which to build the item container.
- $parentElement (DOMElement) – The item container will append to this element.
Returns: void|null
- _buildTagUri()¶
Create a Tag URI to uniquely identify this Omeka XML instance.
Returns: string
- _buildUrl()¶
Create a absolute URI containing the current query string.
Returns: string
Output_CollectionOmekaXml¶
Output_FileOmekaXml¶
Output_ItemAtom¶
- class Output_ItemAtom¶
Package: Output
Model class for an Atom feed for a list of items.
- property _feed¶
- __construct(array $items)¶
Build the Atom feed using DOM.
Parameters: - $items (array) – An array of Item records.
Returns: void
- _getFeedLinks(array $items)¶
Returns the URLs, if any, for rel=self|next|previous links.
Parameters: - $items (array) –
Returns: array
- getFeed()¶
Returns the XML feed.
Returns: string
Output_ItemContainerOmekaXml¶
Output_ItemDcmesXml¶
Output_ItemOmekaXml¶
Output_ItemRss2¶
Output_OmekaJson¶
- class Output_OmekaJson¶
Package: Output
Generates JSON version of the omeka-xml output, as dictated by the JsonML XSLT.
- constant JSONML_XSLT_FILENAME¶
JsonML XML stylesheet filename
- toJson(Omeka_Output_OmekaXml_AbstractOmekaXml $omekaXml)¶
Convert omeka-xml output to JSON.
Parameters: - $omekaXml (Omeka_Output_OmekaXml_AbstractOmekaXml) –
Returns: string
Plugin¶
Up to Class Library by Package
Omeka_Plugin_AbstractPlugin¶
- class Omeka_Plugin_AbstractPlugin¶
Package: Plugin
Abstract plugin class.
Plugin authors may inherit from this class to aid in building their pluginframework.
- property _db¶
Database object accessible to plugin authors.
- property _hooks¶
Plugin hooks.
In the child class plugin authors should set an array containing hooknames as values and, optionally, callback names as keys. If a callbackname is given, the child class should contain an identically namedmethod. If no callback key is given, the child class should contain acorresponding hookCamelCased() method. E.g: the after_save_form_recordfilter should have a corresponding hookAfterSaveRecord() method.
For example:
array('install', 'uninstall', 'doSomething' => 'after_save_item')
- property _filters¶
Plugin filters.
In the child class plugin authors should set an array containing filternames as values and, optionally, callback names as keys. If a callbackname is given, the child class should contain an identically namedmethod. If no callback key is given, the child class should contain acorresponding filterCamelCased() method. E.g: the admin_navigation_mainfilter should have a corresponding filterAdminNavigationMain() method.
For example:
array('admin_navigation_main', 'public_navigation_main', 'changeSomething' => 'display_option_site_title', 'displayItemDublinCoreTitle' => array('Display', 'Item', 'Dublin Core', 'Title'))
- property _options¶
Plugin options.
Plugin authors should give an array containing option names as keys and their default values as values, if any.
For example:
array('option_name1' => 'option_default_value1', 'option_name2' => 'option_default_value2', 'option_name3', 'option_name4')
- __construct()¶
Construct the plugin object.
Sets the database object. Plugin authors must call parent::__construct() in the child class’s constructor, if used.
- setUp()¶
Set up the plugin to hook into Omeka.
Adds the plugin’s hooks and filters. Plugin writers must call this method after instantiating their plugin class.
- _installOptions()¶
Set options with default values.
Plugin authors may want to use this convenience method in their install hook callback.
- _uninstallOptions()¶
Delete all options.
Plugin authors may want to use this convenience method in their uninstall hook callback.
- _addHooks()¶
Validate and add hooks.
- _addFilters()¶
Validate and add filters.
Omeka_Plugin_Exception¶
- class Omeka_Plugin_Exception¶
Package: Plugin
Exception type thrown by the Omeka_Plugin class.
- property message¶
- property string¶
- property code¶
- property file¶
- property line¶
- property trace¶
- property previous¶
- __clone()¶
- __construct($message, $code, $previous)¶
Parameters: - $message (unknown) –
- $code (unknown) –
- $previous (unknown) –
- getMessage()¶
- getCode()¶
- getFile()¶
- getLine()¶
- getTrace()¶
- getPrevious()¶
- getTraceAsString()¶
- __toString()¶
Omeka_Plugin_Factory¶
- class Omeka_Plugin_Factory¶
Package: Plugin
Responsible for creating a set of Plugin records corresponding to plugins that have not been installed yet.
- property _basePath¶
Base path for plugins; the plugin directory
- __construct(string $basePath)¶
Parameters: - $basePath (string) – Plugin base directory.
- getNewPlugins(array $existingPlugins)¶
Retrieve all new plugins in the plugin directory.
Parameters: - $existingPlugins (array) – An array of existing Plugin objects.
Returns: array An array of Plugin objects for the new plugins.
- _getDirectoryList()¶
Retrieve an array of all the plugins in the plugin directory. A plugin is considered to be present when a directory includes a plugin.php file or has a valid plugin class.
Returns: array A list of valid plugin directory names.
Omeka_Plugin_Ini¶
- class Omeka_Plugin_Ini¶
Package: Plugin
Responsible for parsing the plugin.ini file for any given plugin.
- property _pluginsRootDir¶
Plugins directory.
- property _configs¶
Set of Zend_Config_Ini objects corresponding to each plugin.
- __construct(string $pluginsRootDir)¶
Parameters: - $pluginsRootDir (string) – Plugins directory.
- getPluginIniValue(string $pluginDirName, string $iniKeyName)¶
Retrieve a value in plugin.ini for a given key.
Will return a null value if no value can be found in the ini file for thekey.
Parameters: - $pluginDirName (string) – Plugin name.
- $iniKeyName (string) – INI key to retrieve.
Returns: string|null Retrieved INI value (null if not found).
- hasPluginIniFile(string $pluginDirName)¶
Return whether a plugin has a plugin.ini file
Parameters: - $pluginDirName (string) – Plugin name.
Returns: boolean
- getPluginIniFilePath(string $pluginDirName)¶
Return the path to the plugin.ini file
Parameters: - $pluginDirName (string) – Plugin name.
Returns: string
Omeka_Plugin_Mvc¶
- class Omeka_Plugin_Mvc¶
Package: Plugin
Connects plugins with Omeka’s model-view-controller system.
- property _basePath¶
Path to the root plugins directory.
- property _pluginViewDirs¶
View script directories that have been added by plugins.
- property _pluginHelpersDirs¶
View helper directories from plugins.
- __construct(string $basePath)¶
Parameters: - $basePath (string) – Plugins directory path.
- addThemeDir(string $pluginDirName, string $path, string $themeType, string $moduleName)¶
Add a theme directory to the list of plugin-added view directories.
Used by the add_theme_pages() helper to create a list of directories thatcan store static pages that integrate into the themes.
Parameters: - $pluginDirName (string) – Plugin name.
- $path (string) – Path to directory to add.
- $themeType (string) – Type of theme (‘public’, ‘admin’, or ‘shared’).
- $moduleName (string) – MVC module name.
Returns: void
- getModuleViewScriptDirs(string $moduleName)¶
Retrieve the list of plugin-added view script directories.
Parameters: - $moduleName (string) – (optional) MVC module name.
Returns: array List of indexed directory names.
- getHelpersDirs()¶
Get all the existing plugin view helper dirs, indexed by plugin name.
Returns: array
- addControllerDir(string $pluginDirName, string $moduleName)¶
Make an entire directory of controllers available to the front controller.
This has to use addControllerDirectory() instead of addModuleDirectory()because module names are case-sensitive and module directories need to belowercased to conform to Zend’s weird naming conventions.
Parameters: - $pluginDirName (string) – Plugin name.
- $moduleName (string) – MVC module name.
Returns: void
- addApplicationDirs(string $pluginDirName)¶
Set up the following directory structure for plugins:
controllers/models/libraries/views/admin/public/shared/
This also adds these folders to the correct include paths.
Parameters: - $pluginDirName (string) – Plugin name.
Returns: void
- _getModuleName(string $pluginDirName)¶
Retrieve the module name for the plugin (based on the directory name of the plugin).
Parameters: - $pluginDirName (string) – Plugin name.
Returns: string Plugin MVC module name.
- _hasIncludePath(string $path)¶
Check include path to see if it already contains a specific path.
Parameters: - $path (string) –
Returns: boolean
Plugin\Broker¶
Up to Plugin
Omeka_Plugin_Broker¶
- class Omeka_Plugin_Broker¶
Package: Plugin\Broker
Plugin Broker for Omeka.
For example,$broker->callHook(‘add_action_contexts’, array(‘controller’ => $controller))would call the ‘add_action_contexts’ on all plugins, and it would provide thecontroller object as the first argument to all implementations of that hook.
- property _callbacks¶
Array of hooks that have been implemented for plugins.
- property _filters¶
Stores all defined filters.
Storage in array where $_filters[‘filterName’][‘priority’][‘plugin’] = $hook;
- property _current¶
The directory name of the current plugin (used for calling hooks)
- addHook(string $hook, string $callback, string|null $plugin)¶
Add a hook implementation for a plugin.
Parameters: - $hook (string) – Name of the hook being implemented.
- $callback (string) – PHP callback for the hook implementation.
- $plugin (string|null) – Optional name of the plugin for which to add the hook. If omitted, the current plugin is used.
Returns: void
- getHook(string $pluginDirName, string $hook)¶
Get the hook implementation for a plugin.
Parameters: - $pluginDirName (string) – Name of the plugin to get the implementation from.
- $hook (string) – Name of the hook to get the implementation for.
Returns: callback|null
- setCurrentPluginDirName(string $pluginDirName)¶
Set the currently-focused plugin by directory name.
The plugin helper functions do not have any way of determining whatplugin to is currently in focus. These get/setCurrentPluginDirNamemethods allow the broker to know how to delegate to specific plugins ifnecessary.
Parameters: - $pluginDirName (string) – Plugin to set as current.
Returns: void
- getCurrentPluginDirName()¶
Get the directory name of the currently-focused plugin.
Returns: string
- callHook(string $name, array $args = Array, Plugin|string $plugin)¶
Call a hook by name.
Hooks can either be called globally or for a specific plugin only.
Parameters: - $name (string) – The name of the hook.
- $args (array) – Arguments to be passed to the hook implementations.
- $plugin (Plugin|string) – Name of the plugin that will invoke the hook.
Returns: void
- addFilter(string|array $name, callback $callback, $priority = 10)¶
Add a filter implementation.
Parameters: - $name (string|array) – Name of filter being implemented.
- $callback (callback) – PHP callback for filter implementation.
- $priority (unknown) –
Returns: void
- _getFilterNamespace()¶
Retrieve the namespace to use for the filter to be added.
Returns: string Name of the current plugin (if applicable). Otherwise, a magic constant that denotes globally applied filters.
- _getFilterKey(string|array $name)¶
Retrieve the key used for indexing the filter. The filter name should be either a string or an array of strings. If the filter name is an object, that might cause fiery death when using the serialized value for an array key.
Parameters: - $name (string|array) – Filter name.
Returns: string Key for filter indexing.
- getFilters(string|array $hookName)¶
Return all the filters for a specific hook in the correct order of execution.
Parameters: - $hookName (string|array) – Filter name.
Returns: array Indexed array of filter callbacks.
- clearFilters(string|null $name)¶
Clear all implementations for a filter (or all filters).
Parameters: - $name (string|null) – The name of the filter to clear. If null or omitted, all filters will be cleared.
Returns: void
- applyFilters(mixed $name, mixed $value, array $args = Array)¶
Run an arbitrary value through a set of filters.
Parameters: - $name (mixed) – The filter name.
- $value (mixed) – The value to filter.
- $args (array) – Additional arguments to pass to filter implementations.
Returns: mixed Result of applying filters to $value.
- register()¶
Register the plugin broker so that plugin writers can use global functions like add_plugin_hook() to interact with the plugin API.
Returns: void
Plugin\Installer¶
Up to Plugin
Omeka_Plugin_Installer¶
- class Omeka_Plugin_Installer¶
Package: Plugin\Installer
Changes the state of any given plugin (installed/uninstalled/activated/deactivated)
- property _broker¶
Plugin broker object.
- property _loader¶
Plugin loader object.
- __construct(Omeka_Plugin_Broker $broker, Omeka_Plugin_Loader $loader)¶
Parameters: - $broker (Omeka_Plugin_Broker) – Plugin broker object.
- $loader (Omeka_Plugin_Loader) – Plugin loader object.
- activate(Plugin $plugin)¶
Activate a plugin.
Parameters: - $plugin (Plugin) – Plugin to activate.
Returns: void
- deactivate(Plugin $plugin)¶
Deactivate a plugin.
Parameters: - $plugin (Plugin) – Plugin to deactivate.
Returns: void
- upgrade(Plugin $plugin)¶
Upgrade a plugin.
This will activate the plugin, then run the ‘upgrade’ hook.
Parameters: - $plugin (Plugin) – Plugin to upgrade.
Returns: void
Omeka_Plugin_Installer_Exception¶
- class Omeka_Plugin_Installer_Exception¶
Package: Plugin\Installer
An exception thrown when the plugin installer is unable to install, uninstall, activate, deactivate, or upgrade a plugin.
- property message¶
- property string¶
- property code¶
- property file¶
- property line¶
- property trace¶
- property previous¶
- __clone()¶
- __construct($message, $code, $previous)¶
Parameters: - $message (unknown) –
- $code (unknown) –
- $previous (unknown) –
- getMessage()¶
- getCode()¶
- getFile()¶
- getLine()¶
- getTrace()¶
- getPrevious()¶
- getTraceAsString()¶
- __toString()¶
Plugin\Loader¶
Up to Plugin
Omeka_Plugin_Loader¶
- class Omeka_Plugin_Loader¶
Package: Plugin\Loader
Loads plugins for any given request.
This will iterate through the plugins root directory and load all plugin.phpfiles by require()’ing them.
- property _broker¶
Plugin broker object.
- property _iniReader¶
Plugin INI reader object.
- property _mvc¶
Plugin MVC object.
- property _basePath¶
Plugins directory.
- property _plugins¶
An array of all plugins (installed or not) that are currently located in the plugins/ directory.
- __construct(Omeka_Plugin_Broker $broker, Omeka_Plugin_Ini $iniReader, Omeka_Plugin_Mvc $mvc, string $pluginsBaseDir)¶
Parameters: - $broker (Omeka_Plugin_Broker) – Plugin broker.
- $iniReader (Omeka_Plugin_Ini) – plugin.ini reader.
- $mvc (Omeka_Plugin_Mvc) – Plugin MVC object.
- $pluginsBaseDir (string) – Plugins directory.
- loadPlugins(array $plugins, boolean $force =)¶
Load a list of plugins.
Parameters: - $plugins (array) – List of Plugin records to load.
- $force (boolean) – If true, throws exceptions for plugins that cannot be loaded for some reason.
Returns: void
- registerPlugin(Plugin $plugin)¶
Register a plugin so that it can be accessed by other plugins (if necessary) during the load process.
There should only be a single instance of a plugin per directory name.Registering a plugin more than once, i.e. loading a plugin again after thefirst time failed, will not cause a problem as long as the same instancewas registered.
Parameters: - $plugin (Plugin) – Record of plugin to register.
Returns: void
- isRegistered(Plugin $plugin)¶
Return whether a plugin is registered or not.
Parameters: - $plugin (Plugin) –
Returns: boolean Whether the plugin is registered or not.
- load(Plugin $plugin, boolean $force =, array $pluginsWaitingToLoad = Array)¶
Load a plugin (and make sure the plugin API is available).
To be loaded, the plugin must be installed, active, and not have a newerversion. If loaded, the plugin will attempt to first load all plugins,both required and optional, that the plugin uses. However, it will notload a plugin that it uses if that plugin is not installed and activated.
Parameters: - $plugin (Plugin) –
- $force (boolean) – If true, throws exceptions if a plugin can’t be loaded.
- $pluginsWaitingToLoad (array) – Plugins waiting to be loaded
Returns: void
- _canLoad(Plugin $plugin, boolean $force)¶
Determine whether or not a plugin can be loaded. To be loaded, it must meet the following criteria: - Has a plugin.php file. - Is installed. - Is active. - Meets the minimum required version of Omeka (in plugin.ini). - Is not already loaded. - Does not have a new version available.
Parameters: - $plugin (Plugin) – Plugin to test.
- $force (boolean) – If true, throw an exception if the plugin can’t be loaded.
Returns: boolean
- hasPluginBootstrap(string|Plugin $pluginDirName)¶
Check whether a plugin has a bootstrap file.
Parameters: - $pluginDirName (string|Plugin) –
Returns: boolean
- getPluginClassName(string $pluginDirName)¶
Return the valid plugin class name.
Parameters: - $pluginDirName (string) –
Returns: string
- getPluginFilePath(string $pluginDirName)¶
Return the path to the plugin.php file.
Parameters: - $pluginDirName (string) –
Returns: string
- getPluginClassFilePath(string $pluginDirName)¶
Return the path to the plugin class file.
Parameters: - $pluginDirName (string) –
Returns: string
- getPlugins()¶
Return a list of all the plugins that have been loaded (or attempted to be loaded) thus far.
Returns: array List of Plugin objects.
- getPlugin(string $directoryName)¶
Get a plugin object by name (plugin subdirectory name).
Parameters: - $directoryName (string) – Plugin name.
Returns: Plugin|null
Omeka_Plugin_Loader_Exception¶
- class Omeka_Plugin_Loader_Exception¶
Package: Plugin\Loader
An exception thrown when the plugin loader is unable to load a plugin.
- property message¶
- property string¶
- property code¶
- property file¶
- property line¶
- property trace¶
- property previous¶
- __clone()¶
- __construct($message, $code, $previous)¶
Parameters: - $message (unknown) –
- $code (unknown) –
- $previous (unknown) –
- getMessage()¶
- getCode()¶
- getFile()¶
- getLine()¶
- getTrace()¶
- getPrevious()¶
- getTraceAsString()¶
- __toString()¶
Record¶
Up to Class Library by Package
Collection¶
- class Collection¶
Package: Record
A collection and its metadata.
- property public¶
- property featured¶
- property added¶
- property modified¶
- property owner_id¶
- getProperty(string $property)¶
Get a property about this collection.
Parameters: - $property (string) – The property to get, always lowercase.
Returns: mixed The value of the property
- totalItems()¶
Determine the total number of items associated with this collection.
Returns: integer
- setAddedBy(User $user)¶
Set the user who added the collection.
Note that this is not to be confused with the collection’s “contributors”.
Parameters: - $user (User) –
- getResourceId()¶
Required by Zend_Acl_Resource_Interface.
Identifies Collection records as relating to the Collections ACLresource.
Returns: string
- hasContributor()¶
Returns whether or not the collection has at least 1 contributor element text
Returns: boolean
- _initializeMixins()¶
Initialize the mixins
- filterPostData(array $post)¶
Filter the POST data from the form.
Converts public/featured flags to booleans.
Parameters: - $post (array) –
Returns: array
- _delete()¶
All of the custom code for deleting an collection.
Returns: void
- beforeSave($args)¶
Parameters: - $args (unknown) –
- afterSave()¶
Element¶
- class Element¶
Package: Record
An element and its metadata.
- property element_set_id¶
- property order¶
- property name¶
- property description¶
- property comment¶
- setElementSet(string $elementSetName)¶
Set the element set for the element.
Parameters: - $elementSetName (string) –
Returns: void
- getElementSet()¶
Return the ElementSet objection for this element.
Returns: ElementSet
- setOrder(integer $order)¶
Set the order of the element within its element set.
Parameters: - $order (integer) –
Returns: void
- setName(string $name)¶
Set the name of the element.
Parameters: - $name (string) –
Returns: void
- setDescription(string $description)¶
Set the description for the element.
Parameters: - $description (string) –
Returns: void
- setComment($comment)¶
Parameters: - $comment (unknown) –
- setArray(array|string $data)¶
Parameters: - $data (array|string) –
If string, it’s the name of the element. Otherwise, array of metadata for the element. May contain the following keys in the array:
- name
- description
- comment
- order
- element_set_id
- element_set
Returns: void
- $data (array|string) –
- _validate()¶
Validate the element prior to being saved.
Checks the following criteria:
- Name is not empty.
- Name does not already exist within the given element set.
- _delete()¶
When deleting an element, cascade delete all element texts and item type assignments associated with the element.
- _getElementSetId($elementSetName)¶
Retrieve the element set ID from the name.
Parameters: - $elementSetName (unknown) –
Returns: int
- _nameIsInSet($elementName, $elementSetId)¶
Calculate whether the element’s name already belongs to the current set.
Parameters: - $elementName (unknown) –
- $elementSetId (unknown) –
Returns: boolean
ElementSet¶
- class ElementSet¶
Package: Record
An element set and its metadata.
- constant ITEM_TYPE_NAME¶
The name of the item type element set.
This is used wherever it is important to distinguish this special case element set from others.
- property record_type¶
- property name¶
- property description¶
- property _elementsToSave¶
- getElements()¶
- addElements(array $elements)¶
Add elements to the element set.
Parameters: - $elements (array) –
- _buildElementRecord($options)¶
Parameters: - $options (unknown) –
- afterSave($args)¶
Parameters: - $args (unknown) –
- _delete()¶
Deletes all the elements associated with an element set.
Returns: void
- _getNextElementOrder()¶
- _validate()¶
ElementText¶
File¶
- class File¶
Package: Record
A file and its metadata.
- property item_id¶
- property order¶
- property filename¶
- property original_filename¶
- property size¶
- property authentication¶
- property mime_type¶
- property type_os¶
- property has_derivative_image¶
- property added¶
- property modified¶
- property stored¶
- property metadata¶
- property _pathsByType¶
- getProperty(string $property)¶
Get a property or special value of this record.
Parameters: - $property (string) –
Returns: mixed
- _initializeMixins()¶
Initialize mixins.
- filterPostData(array $post)¶
Unset immutable properties from $_POST.
Parameters: - $post (array) –
Returns: array
- beforeSave(array $args)¶
Do something before saving this record.
Parameters: - $args (array) –
- afterSave(array $args)¶
Do something after saving this record.
Parameters: - $args (array) –
- getItem()¶
Retrieve the parent item of this record.
Returns: Item
- getPath(string $type = original)¶
Retrieve a system path for this file.
Parameters: - $type (string) –
Returns: string
- getWebPath(string $type = original)¶
Retrieve a web path for this file.
Parameters: - $type (string) –
Returns: string
- getDerivativeFilename()¶
Retrieve the derivative filename.
Returns: string
- hasThumbnail()¶
Determine whether this record has a thumbnail image.
Returns: bool
- hasFullsize()¶
Determine whether this record has a fullsize image.
Returns: bool
- getExtension()¶
Get the original file’s extension.
Returns: string
- setDefaults($filepath, $options = Array)¶
Set the default values that will be stored for this record in the ‘files’ table.
Parameters: - $filepath (unknown) –
- $options (unknown) –
Returns: void
- unlinkFile()¶
Unlink the file and file derivatives belonging to this record.
- _delete()¶
Perform any further deletion when deleting this record.
- createDerivatives()¶
Create derivatives of the original file.
- extractMetadata()¶
Extract ID3 metadata associated with the file.
Returns: boolean
- _getId3()¶
Pull down the file’s extra metadata via getID3 library.
Returns: getID3
- storeFiles()¶
Store files belonging to this record.
- getStoragePath(string $type = fullsize)¶
Get the storage path.
Parameters: - $type (string) –
Returns: string
- setStorage(Omeka_Storage $storage)¶
Set the storage object.
Parameters: - $storage (Omeka_Storage) –
- getStorage()¶
Get the storage object.
Returns: Omeka_Storage
- getResourceId()¶
Get the ACL resource ID for the record.
File records are ‘Files’ resources.
Returns: string
Item¶
- class Item¶
Package: Record
An item and its metadata.
- property item_type_id¶
- property collection_id¶
- property featured¶
- property public¶
- property added¶
- property modified¶
- property owner_id¶
- property _files¶
- _initializeMixins()¶
- getCollection()¶
Returns: null|Collection
- getItemType()¶
Retrieve the ItemType record associated with this Item.
Returns: ItemType|null
- getFiles()¶
Retrieve the set of File records associated with this Item.
Returns: array
- getItemTypeElements()¶
Retrieve a set of elements associated with the item type of the item.
Each one of the Element records that is retrieved should contain all theelement text values associated with it.
Returns: array Element records that are associated with the item type of the item. This array will be empty if the item does not have an associated type.
- getProperty(string $property)¶
Get a property for display.
Parameters: - $property (string) –
Returns: mixed
- beforeSave($args)¶
Parameters: - $args (unknown) –
- afterSave($args)¶
Logic for after the record has been saved.
Parameters: - $args (unknown) –
- _delete()¶
All of the custom code for deleting an item.
Returns: void
- _deleteFiles(array $fileIds = Array)¶
Delete files associated with the item.
If the IDs of specific files are passed in, this will delete only thosefiles (e.g. form submission). Otherwise, it will delete all filesassociated with the item.
Parameters: - $fileIds (array) – Optional
Returns: void
- _uploadFiles()¶
Iterate through the $_FILES array for files that have been uploaded to Omeka and attach each of those files to this Item.
Returns: void
- saveFiles()¶
Save all the files that have been associated with this item.
Returns: boolean
- filterPostData($post)¶
Filter post data from form submissions.
Parameters: - $post (unknown) –
Returns: array Clean post data
- fileCount()¶
Retrieve the number of files assigned to this item.
Returns: boolean
- previous()¶
Retrieve the previous Item in the database.
Returns: Item|false
- next()¶
Retrieve the next Item in the database.
Returns: Item|false
- hasThumbnail()¶
Determine whether or not the Item has a File with a thumbnail image (or any derivative image).
Returns: boolean
- getCitation()¶
Return a valid citation for this item.
Generally follows Chicago Manual of Style note format for webpages.Implementers can use the item_citation filter to return a customizedcitation.
Returns: string
- addFile(File $file)¶
Associate an unsaved (new) File record with this Item.
These File records will not be persisted in the database until the itemis saved or saveFiles() is invoked.
Parameters: - $file (File) –
Returns: void
- getResourceId()¶
Required by Zend_Acl_Resource_Interface.
Identifies Item records as relating to the Items ACL resource.
Returns: string
ItemType¶
- class ItemType¶
Package: Record
An item type and its metadata.
- property name¶
- property description¶
- property _elementsToSave¶
- property _elementsToRemove¶
- getElements()¶
Returns an array of element objects associated with this item type.
Returns: array The array of element objects associated with this item type.
- getItems(int $count = 10, boolean $recent = 1)¶
Returns an array of item objects that have this item type.
Parameters: - $count (int) – The maximum number of items to return.
- $recent (boolean) – Whether or not the items are recent.
Returns: array The items associated with the item type.
- _validate()¶
Current validation rules for Type
- ‘Name’ field can’t be blank2) ‘Name’ field must be unique
Returns: void
- filterPostData($post)¶
Filter incoming POST data from ItemType form.
Parameters: - $post (unknown) –
Returns: void
- _delete()¶
Delete all the ItemTypesElements joins
Returns: void
- afterSave($args)¶
Save Element records that are associated with this Item Type.
Parameters: - $args (unknown) –
Returns: void
- reorderElements(Array $elementOrderingArray)¶
This extracts the ordering for the elements from the form’s POST, then uses the given ordering to reorder each join record from item_types_elements into a new ordering, which is then saved.
Parameters: - $elementOrderingArray (Array) – An array of element_id => order pairs
Returns: void
- addElements(array $elements = Array)¶
Add a set of elements to the Item Type.
Parameters: - $elements (array) – Either an array of elements or an array of metadata, where each entry corresponds to a new element to add to the item type. If an element exists with the same id, it will replace the old element with the new element.
Returns: void
- addElementById($elementId)¶
Adds a new element to the item type by the id of the element
Parameters: - $elementId (unknown) –
Returns: void
- removeElements(Array $elements)¶
Removes an array of Elements from this item type The element will not be removed until the object is saved.
Parameters: - $elements (Array) – An array of Element objects or element id strings
Returns: void
- removeElement(Element|string $element)¶
Remove a single Element from this item type. The element will not be removed until the object is saved.
Parameters: - $element (Element|string) – The element object or the element id.
Returns: void
- _removeElement(Element|string $element)¶
Removes a single Element from this item type. It removes it immediately.
Parameters: - $element (Element|string) –
Returns: void
- hasElement(Element|string $element)¶
Determines whether a saved version of the item type has an element. It does not correctly determine the presence of elements that were added or removed without saving the item type object.
Parameters: - $element (Element|string) – The element object or the element id.
Returns: boolean
- totalItems()¶
Determines the total number of items that have this item type.
Returns: int The total number of items that have this item type.
- getItemTypeElementSet()¶
Returns the ‘Item Type’ element set.
Returns: ElementSet
ItemTypesElements¶
Omeka_Record_AbstractRecord¶
- class Omeka_Record_AbstractRecord¶
Package: Record
A base class for domain objects, inspired by, though not strictly adherent to, the ActiveRecord pattern.
- property id¶
Unique ID for the record.
All implementations of Omeka_Record_AbstractRecord must have a table containing an ‘id’ column, preferably as the primary key.
- property _errors¶
Any errors raised during the validation process.
- property _cache¶
An in-memory cache for related objects that have been retrieved via the magic __get() syntax.
- property _mixins¶
Set of Omeka_Record_Mixin_AbstractMixin objects that are designed to extend the behavior of Omeka_Record_AbstractRecord implementations.
Examples include {@link Taggable}, {@link Relatable},{@link ActsAsElementText}, etc.
- property _db¶
Key/value pairs indicating aliases for methods that retrieve related data objects. For example, a subclass might define the following: <code> protected $_related = array(‘Sections’=>’loadSections’); </code> This would allow the client to write code like: <code> $sections = $subclassInstance->Sections; </code> Which would be equivalent to: <code> $sections = $subclassInstance->loadSections(); </code> The difference being, the former is cached so as to avoid multiple trips to the database.
- property _postData¶
Storage for the POST data when handling a form.
- property _locked¶
Whether or not the record is locked. Locked records cannot be saved.
- property _eventCallbacks¶
List of built in callback methods.
- property _pluginBroker¶
- __construct(Omeka_Db|null $db)¶
Parameters: - $db (Omeka_Db|null) – (optional) Defaults to the Omeka_Db instance from the bootstrap.
- construct()¶
Subclass constructor behavior.
Subclasses of Omeka_Record_AbstractRecord can override this function toadd behavior to the constructor without overriding __construct.
Returns: void
- __destruct()¶
Unsets mixins, which contain circular references, upon record destruction
IMPORTANT: Solves a memory leak when retrieving/saving records.
Required because PHP 5.2 does not do garbage collection on circular references.
- __get(string $prop)¶
Retrieve database records that are associated with the current one.
Parameters: - $prop (string) – Related data to retrieve.
Returns: mixed
- __call(string $m, array $a)¶
Delegate unknown method calls to Omeka_Record_Mixin_AbstractMixin instances.
Parameters: - $m (string) – Method name.
- $a (array) – Method arguments.
Returns: mixed
- _initializeMixins()¶
Initialize the mixins for a record.
Any Omeka_Record_AbstractRecord subclass that uses mixins shouldinitialize them here, since this is called on construction and whenmixins need to be reinitialized.
- delegateToMixins(string $method, array $args = Array, boolean $all =)¶
Delegate to the given method in one or more mixin instances.
Parameters: - $method (string) –
- $args (array) –
- $all (boolean) – (optional) Whether or not to call the same method on every mixin instance that has that method. Defaults to false.
Returns: mixed If $all is false, the return value from the invoked method. Otherwise there is no return value.
- runCallbacks($event, $args = Array)¶
Invoke all callbacks associated with a specific record event.
Callbacks execute in the following order:- Omeka_Record_AbstractRecord hooks like Omeka_Record_AbstractRecord::afterDelete()- Record mixin hooks like Taggable::afterSave()- Generic record plugin hooks like ‘before_delete_record’- Specific record plugin hooks like ‘before_delete_item’
Parameters: - $event (unknown) –
- $args (unknown) –
- _addToCache(mixed $value, string $key)¶
Add a value to the record-specific cache.
Parameters: - $value (mixed) –
- $key (string) –
Returns: void
- _getCached(string $name)¶
Get a value from the record-specific cache.
Parameters: - $name (string) –
Returns: mixed
- getProperty(string $property)¶
Get a property about the record for display purposes.
Parameters: - $property (string) – Property to get. Always lowercase.
Returns: mixed
- exists()¶
Determine whether or not this record is persistent in the database.
For simplicity, non-persistent records are indicated by the lack of avalue for the ‘id’ column.
Returns: boolean
- _validate()¶
Template method for defining record validation rules.
Should be overridden by subclasses.
Returns: void
- isValid()¶
Determine whether or not the record is valid.
Returns: boolean
- getErrors()¶
Retrieve validation errors associated with this record.
Returns: Omeka_Validate_Errors
- hasErrors()¶
Determine whether or not this record has any validation errors.
Returns: boolean
- addError(string|null $field, string $msg)¶
Add a validation error for a specific field.
Currently limited to a single error per field, so multiple error messagesmust be concatenated together.
Parameters: - $field (string|null) – Name of the field. This can be null to indicate a general error not associated with a specific field.
- $msg (string) – The error message.
Returns: void
- addErrorsFrom(Omeka_Record_AbstractRecord $record)¶
Combine errors from a different Omeka_Record_AbstractRecord instance with the errors already on this record.
Parameters: - $record (Omeka_Record_AbstractRecord) –
Returns: void
- lock()¶
Prevent a record from being modified.
Can be used to prevent accidentally saving/deleting a record if its state maychange but saving would be undesirable, such as modifying a record fordisplay purposes.
Returns: void
- getTable($class)¶
Retrieve the Omeka_Db_Table instance associated with this record, or with that of any given record class.
Parameters: - $class (unknown) –
Returns: Omeka_Db_Table
- getDb()¶
Retrieve the Omeka_Db instance associated with this record.
Returns: Omeka_Db
- toArray()¶
Retrieve an associative array of all the record’s columns and their values.
Returns: array
- save(boolean $throwIfInvalid = 1)¶
Save the record.
Parameters: - $throwIfInvalid (boolean) –
Returns: boolean Whether the save was successful.
- __clone()¶
Clone the record.
Unsets the ID so the cloned record can be saved on its own.
- delete()¶
Delete the record.
Returns: void
- _delete()¶
Template method for defining record deletion logic.
Subclasses can override this method to define additional logic for deletingrecords. Note that this is different from both the beforeDelete() andafterDelete() hooks in that it executes after beforeDelete(), but beforethe record is actually deleted.
Common use cases include emulating cascading deletes with otherdatabase rows.
Returns: void
- beforeSave($args)¶
Executes before the record is saved.
Parameters: - $args (unknown) –
- afterSave($args)¶
Executes after the record is inserted.
Parameters: - $args (unknown) –
- beforeDelete()¶
Executes before the record is deleted.
- afterDelete()¶
Executes after the record is deleted.
- setArray(array|Traversable $data)¶
Set values for the record using an associative array or iterator.
Parameters: - $data (array|Traversable) –
Returns: void
- getPluginBroker()¶
- setPluginBroker($broker)¶
Parameters: - $broker (unknown) –
- offsetExists(string $name)¶
Determine whether or not the given field has a value associated with it.
Required by ArrayAccess.
Parameters: - $name (string) –
Returns: boolean
- offsetUnset(string $name)¶
Unset the given field.
Required by ArrayAccess.
Parameters: - $name (string) –
Returns: void
- offsetGet(string $name)¶
Retrieve the value of a given field.
Required by ArrayAccess.
Parameters: - $name (string) –
Returns: mixed
- offsetSet(string $name, mixed $value)¶
Set the value of a given field.
Required by ArrayAccess.
Parameters: - $name (string) –
- $value (mixed) –
Returns: void
- filterPostData(array $post)¶
Filter the form input according to some criteria.
Template method should be overridden by subclasses that wish to implementsome sort of filtering criteria.
Parameters: - $post (array) –
Returns: array Filtered post data.
- setPostData(array $post)¶
Set the POST data to the record.
Parameters: - $post (array) –
- fieldIsUnique(string $field, mixed $value)¶
Check uniqueness of one of the record’s fields.
Parameters: - $field (string) –
- $value (mixed) – Optional If null, this will check the value of the record’s $field. Otherwise check the uniqueness of this value for the given field.
Returns: boolean
- getRecordUrl(string $action = show)¶
Get the routing parameters or the URL string to this record.
The record_url() global uses this method to get routing parameters fornon-standard records, e.g. records defined by plugins. Subclasses shouldoverride this method if the default route (as defined below) isincorrect.
Parameters: - $action (string) –
Returns: string|array A URL string or a routing array.
Omeka_Record_Exception¶
- class Omeka_Record_Exception¶
Package: Record
- property message¶
- property string¶
- property code¶
- property file¶
- property line¶
- property trace¶
- property previous¶
- __clone()¶
- __construct($message, $code, $previous)¶
Parameters: - $message (unknown) –
- $code (unknown) –
- $previous (unknown) –
- getMessage()¶
- getCode()¶
- getFile()¶
- getLine()¶
- getTrace()¶
- getPrevious()¶
- getTraceAsString()¶
- __toString()¶
Omeka_Record_Iterator¶
- class Omeka_Record_Iterator¶
Package: Record
- property _records¶
- property _view¶
- property _currentRecordVar¶
- __construct(array $records, null|Zend_View_Abstract $view, null|string $currentRecordVar)¶
Construct the record iterator.
Parameters: - $records (array) –
- $view (null|Zend_View_Abstract) –
- $currentRecordVar (null|string) –
- rewind()¶
- current()¶
Return the current record, setting it to the view if applicable.
- key()¶
- next()¶
Release the previous record and advance the pointer to the next one.
- valid()¶
Option¶
Plugin¶
- class Plugin¶
Package: Record
A plugin and its metadata.
- property name¶
- property active¶
- property version¶
- property _displayName¶
- property _description¶
- property _link¶
- property _loaded¶
- property _hasConfig¶
- property _requiredPlugins¶
- property _optionalPlugins¶
- property _minimumOmekaVersion¶
- property _testedUpToVersion¶
- property _iniVersion¶
- property _iniTags¶
- _validate()¶
- getDirectoryName()¶
Get the name of the directory containing the plugin.
- setDirectoryName(string $name)¶
Set the name of the directory containing the plugin.
Parameters: - $name (string) –
- getDisplayName()¶
Get the human-readable name of the plugin, e.g. “Dublin Core Extended”.
If there is no human-readable name available, returns the directory name instead.
- setDisplayName(string $name)¶
Set the human-readable name of the plugin.
Parameters: - $name (string) –
- getAuthor()¶
Get the author’s name.
- setAuthor(string $author)¶
Set the author’s name.
Parameters: - $author (string) –
- getDescription()¶
Get the description of the plugin.
- setDescription(string $description)¶
Set the description of the plugin.
Parameters: - $description (string) –
- getMinimumOmekaVersion()¶
Get the minimum version of Omeka that this plugin requires to work.
- setMinimumOmekaVersion(string $version)¶
Set the minimum required version of Omeka.
Parameters: - $version (string) –
- getTestedUpToOmekaVersion()¶
Get the version of Omeka that this plugin is tested up to.
- setTestedUpToOmekaVersion(string $version)¶
Set the version of Omeka that this plugin is tested up to.
Parameters: - $version (string) –
- getRequiredPlugins()¶
Get the list of plugins that are required for this plugin to work.
- setRequiredPlugins($plugins)¶
Set the list of plugins that are required for this plugin to work.
Parameters: - $plugins (unknown) –
- getOptionalPlugins()¶
Get the list of plugins that can be used, but are not required by, this plugin.
- setOptionalPlugins($plugins)¶
Set the list of optional plugins.
Parameters: - $plugins (unknown) –
- getIniTags()¶
Get the list of tags for this plugin (from the ini file).
- setIniTags($tags)¶
Set the list of tags for this plugin.
Parameters: - $tags (unknown) –
- getLinkUrl()¶
Get the URL link from the plugin.ini.
- setLinkUrl(string $link)¶
Set the link from the plugin.ini.
Parameters: - $link (string) –
- isInstalled()¶
Whether or not the Plugin has been installed.
Returns: boolean
- isLoaded()¶
Returns: boolean
- setLoaded(boolean $flag)¶
Parameters: - $flag (boolean) –
- isActive()¶
Whether or not the plugin has been activated through the UI.
- setActive($flag)¶
Set whether or not the plugin has been activated.
Parameters: - $flag (unknown) –
- hasConfig()¶
Whether or not the plugin has a custom configuration hook.
- setHasConfig(boolean $flag)¶
Set whether or not the plugin has a custom configuration hook.
Parameters: - $flag (boolean) –
- getIniVersion()¶
Get the version of the plugin stored in the ini file.
- setIniVersion(string $version)¶
Set the version of the plugin that is indicated by the ini file.
Parameters: - $version (string) –
- getDbVersion()¶
Get the version of the plugin that is stored in the database.
- setDbVersion(string $version)¶
Set the version of the plugin that is stored in the database.
Parameters: - $version (string) –
- hasNewVersion()¶
Determine whether or not there is a new version of the plugin available.
- meetsOmekaMinimumVersion()¶
Determine whether the plugin meets the minimum version requirements for Omeka.
If the field is not set, assume that it meets the requirements. If the field is set, it must be greater than the current version of Omeka.
- meetsOmekaTestedUpToVersion()¶
- getResourceId()¶
Process¶
- class Process¶
Package: Record
A process and its metadata.
- property pid¶
- property class¶
- property user_id¶
- property status¶
- property args¶
- property started¶
- property stopped¶
- beforeSave($args)¶
Parameters: - $args (unknown) –
- getArguments()¶
- setArguments($args)¶
Parameters: - $args (unknown) –
- _isSerialized($s)¶
Parameters: - $s (unknown) –
RecordsTags¶
SearchText¶
Tag¶
- class Tag¶
Package: Record
A tag and its metadata.
- property name¶
- __toString()¶
- _delete()¶
Must also delete the taggings associated with this tag
Returns: void
- _validate()¶
- fieldIsUnique($field, $value)¶
The check for unique tag names must take into account CASE SENSITIVITY, which is accomplished via COLLATE utf8_bin sql
Parameters: - $field (unknown) –
- $value (unknown) –
Returns: bool
- rename(array $new_names)¶
Rename a tag.
Any records tagged with the “old” tag will be tagged with eachof the tags given in $new_names. The original tag will bedeleted (unless it is given as one of the $new_names).
Parameters: - $new_names (array) – Names of the tags this one should be renamed to.
Returns: void
Theme¶
- class Theme¶
Package: Record
A theme and its metadata.
Dummy model to simulate the other ActiveRecord models.
- property path¶
- property directory¶
- property image¶
- property title¶
- property description¶
- property license¶
- property website¶
- property omeka_minimum_version¶
- __construct($themeName)¶
Parameters: - $themeName (unknown) –
- setDirectoryName($dir)¶
Parameters: - $dir (unknown) –
- getScriptPath()¶
Get the physical path to the theme’s scripts.
Returns: string Physical path.
- getAssetPath()¶
Get the web path to the theme’s assets.
Returns: string Web path.
- getScriptPathForPlugin(string $pluginModuleName)¶
Get the physical path to the theme’s override scripts for the given plugin.
Parameters: - $pluginModuleName (string) – (i.e., ‘exhibit-builder’)
Returns: string Physical path.
- getAssetPathForPlugin(string $pluginModuleName)¶
Get the web path to the theme’s override assets for the given plugin.
Parameters: - $pluginModuleName (string) – (i.e., ‘exhibit-builder’)
Returns: string Web path.
- setImage($fileName)¶
Parameters: - $fileName (unknown) –
- setIni($fileName)¶
Parameters: - $fileName (unknown) –
- setConfig($fileName)¶
Parameters: - $fileName (unknown) –
- getCurrentThemeName(string $type)¶
Get the directory name of the current theme.
Parameters: - $type (string) – ‘admin’ or ‘public’, defaults to current type
Returns: string
- getAllThemes()¶
Retrieve all themes
Returns: array An array of theme objects
- getTheme(string $themeName)¶
Retrieve a theme.
Parameters: - $themeName (string) – The name of the theme.
Returns: Theme A theme object
- setOptions(string $themeName, array $themeConfigOptions)¶
Set theme configuration options.
Parameters: - $themeName (string) – The name of the theme
- $themeConfigOptions (array) – An associative array of configuration options, where each key is a configuration form input name and each value is a string value of that configuration form input
Returns: void
- getOptions(string $themeName)¶
Get theme configuration options.
Parameters: - $themeName (string) – The name of the theme
Returns: array An associative array of configuration options, where each key is a configuration form input name and each value is a string value of that configuration form input
- getOption(string $themeName, string $themeOptionName)¶
Get the value of a theme configuration option.
Parameters: - $themeName (string) – The name of the theme
- $themeOptionName (string) – The name of the theme option
Returns: string The value of the theme option
- setOption(string $themeName, string $themeOptionName, $themeOptionValue)¶
Set the value of a theme configuration option.
Parameters: - $themeName (string) – The name of the theme
- $themeOptionName (string) – The name of the theme option
- $themeOptionValue (unknown) –
Returns: void
- getOptionName(string $themeName)¶
Get the name of a specific theme’s option. Each theme has a single option in the option’s table, which stores all of the configuration options for that theme
Parameters: - $themeName (string) – The name of the theme
Returns: string The name of a specific theme’s option.
- getUploadedFileName(string $themeName, string $optionName, string $fileName)¶
Get the name of a file uploaded as a theme configuration option. This is the name of the file after it has been uploaded and renamed.
Parameters: - $themeName (string) – The name of the theme
- $optionName (string) – The name of the theme option associated with the uploaded file
- $fileName (string) – The name of the uploaded file
Returns: string The name of an uploaded file for the theme.
- _parseWebsite(string $website)¶
Parses the website string to confirm whether it has a scheme.
Parameters: - $website (string) – The website given in the theme’s INI file.
Returns: string The website URL with a prepended scheme.
User¶
- class User¶
Package: Record
A user and its metadata.
- property username¶
- property password¶
- property salt¶
- property active¶
- property role¶
- property name¶
- property email¶
- beforeSave($args)¶
Parameters: - $args (unknown) –
- filterPostData($post)¶
Parameters: - $post (unknown) –
- setPostData($post)¶
Parameters: - $post (unknown) –
- _validate()¶
- upgradeHashedPassword(string $username, string $password)¶
Upgrade the hashed password. Does nothing if the user/password is incorrect, or if same has been upgraded already.
Parameters: - $username (string) –
- $password (string) –
Returns: boolean False if incorrect username/password given, otherwise true when password can be or has been upgraded.
- getRoleId()¶
- getResourceId()¶
- generateSalt()¶
Generate a simple 16 character salt for the user.
- setPassword($password)¶
Parameters: - $password (unknown) –
- hashPassword($password)¶
Parameters: - $password (unknown) –
Record\Builder¶
Up to Record
Builder_Collection¶
- class Builder_Collection¶
Package: Record\Builder
Build a collection.
- property _recordClass¶
- property _settableProperties¶
- property _elementTexts¶
- setElementTexts(array $elementTexts)¶
Set the element texts for the collection.
Parameters: - $elementTexts (array) –
- _addElementTexts()¶
Add element texts to a record.
- _replaceElementTexts()¶
Replace all the element texts for existing element texts.
- _beforeBuild(Omeka_Record_AbstractRecord $record)¶
Add elements associated with the collection.
Parameters: - $record (Omeka_Record_AbstractRecord) – The collection record
Builder_ElementSet¶
- class Builder_ElementSet¶
Package: Record\Builder
Build an element set.
- property _settableProperties¶
- property _recordClass¶
- property _elementInfo¶
- setElements(array $elements)¶
Set the elements to add to the element set.
Parameters: - $elements (array) –
- setRecordMetadata(string|array $metadata)¶
Overrides setRecordMetadata() to allow giving the name of the element as a string.
Parameters: - $metadata (string|array) –
- _beforeBuild()¶
Add elements to be associated with the element set.
Builder_Item¶
- class Builder_Item¶
Package: Record\Builder
Build an item.
- constant IS_PUBLIC¶
- property _recordClass¶
- property _settableProperties¶
- property _elementTexts¶
- property _fileMetadata¶
- setElementTexts(array $elementTexts)¶
Set the element texts for the item.
Parameters: - $elementTexts (array) –
- setFileMetadata(array $fileMetadata)¶
Set the file metadata for the item.
Parameters: - $fileMetadata (array) –
- setRecordMetadata(array $metadata)¶
Overrides setRecordMetadata() to allow setting the item type by name instead of ID.
Parameters: - $metadata (array) –
Returns: void
- _addElementTexts()¶
Add element texts to a record.
- _replaceElementTexts()¶
Replace all the element texts for existing element texts.
- _addTags()¶
Add tags to an item (must exist in database).
- addFiles(string|Omeka_File_Ingest_AbstractIngest $transferStrategy, string|array $files, $options = Array)¶
Add files to an item.
<li>’Url|Filesystem’ => string|array If a string is given, this representsthe source identifier of a single file (the URL representing the file, orthe absolute file path, respectively). If an array is given, it assumesthat each entry in the array must be either an array or a string. If itan array, there are several default keys that may be present:<ul><li>’source’ => Any identifier that is appropriate to the transferstrategy in use. For ‘Url’, this should be a valid URL. For ‘Filesystem’,it must be an absolute path to the source file to be transferred.</li><li>’name’ => OPTIONAL The filename to give to the transferredfile. This can be any arbitrary filename and will be listed as theoriginal filename of the file. This will also be used to generate thearchival filename for the file. If none is given, this defaults to usingthe getOriginalFileName() method of the transfer adapter.</li><li>’metadata’ => OPTIONAL This could contain any metadata that needs to beassociated with the file. This should be indexed in the same fashionas for items. See ActsAsElementText::addTextsByArray()</li></ul></li></ul>
Parameters: - $transferStrategy (string|Omeka_File_Ingest_AbstractIngest) – This can either be one of the following strings denoting built-in transfer methods: ‘Upload’, ‘Filesystem’, ‘Url’ Or it could be an implemented Omeka_File_Ingest_AbstractIngest class.
- $files (string|array) –
This can be a single string, an array of strings, or an array of arrays, depending on the parameters that are needed by the underlying strategy. Expected parameters for the built in strategies are as follows:
- 'Upload' => null|string If a string is given, it represents the POST parameter name containing the uploaded file(s). If null is given, all files in the POST will be ingested.
- $options (unknown) –
Returns: array Set of File records ingested. May be empty if no files were ingested.
- _addIngestValidators(Omeka_File_Ingest_AbstractIngest $ingester)¶
Add the default validators for ingested files.
The default validators are whitelists for file extensions and MIME types, and those lists can be configured via the admin settings form.
These default validators can be disabled by the ‘disable_default_file_validation’ flag in the settings panel.
Plugins can add/remove/modify validators via the ‘file_ingest_validators’filter.
Parameters: - $ingester (Omeka_File_Ingest_AbstractIngest) –
Returns: void
- _beforeBuild(Omeka_Record_AbstractRecord $record)¶
Parameters: - $record (Omeka_Record_AbstractRecord) –
- _afterBuild(Omeka_Record_AbstractRecord $record)¶
Add tags to the item.
Parameters: - $record (Omeka_Record_AbstractRecord) –
Builder_ItemType¶
- class Builder_ItemType¶
Package: Record\Builder
Build an item type.
- property _recordClass¶
- property _settableProperties¶
- property _elements¶
- setElements(array $elementMetadata)¶
Set the elements that will be attached to the built ItemType record.
Parameters: - $elementMetadata (array) –
Returns: void
- _beforeBuild()¶
Add elements to be associated with the Item Type.
Omeka_Record_Builder_AbstractBuilder¶
- class Omeka_Record_Builder_AbstractBuilder¶
Package: Record\Builder
Build or update an {@link Omeka_Record_AbstractRecord} as needed.
- property _recordClass¶
Class of record that the builder will create.
- property _settableProperties¶
String names denoting the properties of a specific record that can be set directly through the builder. This will not always be all of the fields for the record.
- property _metadataOptions¶
Parsed metadata options for the builder.
- property _record¶
Record being built or updated.
- property _db¶
- build()¶
Build the actual record. If the record already exists, update it as necessary.
Returns: Omeka_Record_AbstractRecord
- setRecordMetadata(array $metadata)¶
Set basic metadata for the record.
Note that the columns to be set must be specified in the $_settablePropertiesproperty of subclassed Builders.
Parameters: - $metadata (array) –
Returns: void
- getRecordMetadata()¶
Get the metadata that will be saved to the record.
Returns: array
- getRecord()¶
Get the record that is being acted upon by the builder.
When an Omeka_Record_AbstractRecord instance has been provided viasetRecord(), that will be returned. If a record ID has been provided,then the appropriate record will be returned.
Otherwise, a new instance of Omeka_Record_AbstractRecord will be returned.
Returns: Omeka_Record_AbstractRecord
- setRecord(Omeka_Record_AbstractRecord|integer|null $record)¶
Set the record upon which this builder will act.
Parameters: - $record (Omeka_Record_AbstractRecord|integer|null) –
Returns: void
- _beforeBuild(Omeka_Record_AbstractRecord $record)¶
All necessary tasks to take place before the record is inserted.
Exceptions may be thrown, validation errors may be added.
Parameters: - $record (Omeka_Record_AbstractRecord) –
Returns: void
- _afterBuild(Omeka_Record_AbstractRecord $record)¶
All necessary tasks that take place after the record has been inserted into the database.
Should not throw exceptions in this method.
Parameters: - $record (Omeka_Record_AbstractRecord) –
Returns: void
- _setRecordProperties(Omeka_Record_AbstractRecord $record)¶
Set the properties for the record, taking care to filter based on the $_settableProperties array.
Parameters: - $record (Omeka_Record_AbstractRecord) –
Returns: void
Omeka_Record_Builder_Exception¶
- class Omeka_Record_Builder_Exception¶
Package: Record\Builder
Exception thrown when there is an error creating a Record using {@link Omeka_Record_Builder_AbstractBuilder}.
- property message¶
- property string¶
- property code¶
- property file¶
- property line¶
- property trace¶
- property previous¶
- __clone()¶
- __construct($message, $code, $previous)¶
Parameters: - $message (unknown) –
- $code (unknown) –
- $previous (unknown) –
- getMessage()¶
- getCode()¶
- getFile()¶
- getLine()¶
- getTrace()¶
- getPrevious()¶
- getTraceAsString()¶
- __toString()¶
Record\Mixin¶
Up to Record
Mixin_ElementText¶
- class Mixin_ElementText¶
Package: Record\Mixin
Record mixin class for associating elements, element texts and their corresponding behaviors to a record.
- property _textsByNaturalOrder¶
ElementText records stored in the order they were retrieved from the database.
- property _textsByElementId¶
ElementText records indexed by the element_id.
- property _elementsBySet¶
Element records indexed by set name and element name, so it looks like:
$elements[‘Dublin Core’][‘Title’] = Element instance;
- property _elementsById¶
Element records indexed by ID.
- property _elementsOnForm¶
List of elements that were output on the form. This can be used to determine the DELETE SQL to use to reset the elements when saving the form.
- property _textsToSave¶
Set of ElementText records to save when submitting the form. These will only be saved to the database if they successfully validate.
- property _recordsAreLoaded¶
Whether the elements and texts have been loaded yet.
- property _elementsByRecordType¶
Sets of Element records indexed by record type.
- afterSave($args)¶
Omeka_Record_AbstractRecord callback for afterSave. Saves the ElementText records once the associated record is saved. Adds the record’s element texts to the search text.
Parameters: - $args (unknown) –
- _getDb()¶
Get the database object from the associated record.
Returns: Omeka_Db
- _getRecordType()¶
Get the class name of the associated record (Item, File, etc.).
Returns: string Type of record
- loadElementsAndTexts(boolean $reload =)¶
Load all the ElementText records for the given record (Item, File, etc.). These will be indexed by [element_id].
Also load all the Element records and index those by their name and setname.
Parameters: - $reload (boolean) – Whether or not reload all the data that was previously loaded.
Returns: void
- _loadElements($reload =)¶
Parameters: - $reload (unknown) –
- _getElementTextRecords()¶
Retrieve all of the ElementText records for the given record.
Returns: array Set of ElementText records for the record.
- _getElementRecords()¶
Retrieve all of the Element records for the given record.
Returns: array All Elements that apply to the record’s type.
- getElementTextsByRecord(Element $element)¶
Retrieve all of the record’s ElementTexts for the given Element.
Parameters: - $element (Element) –
Returns: array Set of ElementText records.
- getElementTexts(string $elementSetName, string $elementName)¶
Retrieve all of the record’s ElementTexts for the given element name and element set name.
Parameters: - $elementSetName (string) – Element set name
- $elementName (string) – Element name
Returns: array Set of ElementText records.
- getAllElementTexts()¶
Retrieve all of the record’s ElementTexts, in order.
Returns: array Set of ElementText records.
- getElementsBySetName($elementSetName)¶
Retrieve the Element records for the given ElementSet.
Parameters: - $elementSetName (unknown) –
Returns: array Set of Element records
- getAllElements()¶
Retrieve ALL the Element records for the object, organized by ElementSet. For example, $elements[‘Dublin Core’] = array(Element instance, Element instance, ...)
Returns: array Set of Element records
- getElement(string $elementSetName, string $elementName)¶
Retrieve the Element record corresponding to the given element name and element set name.
Parameters: - $elementSetName (string) –
- $elementName (string) –
Returns: Element
- getElementById(int $elementId)¶
Retrieve the Element with the given ID.
Parameters: - $elementId (int) –
Returns: Element
- _indexTextsByElementId(array $textRecords)¶
Index a set of ElementTexts based on element ID.
Parameters: - $textRecords (array) – Set of ElementText records
Returns: array The provided ElementTexts, indexed by element ID.
- _indexElementsBySet(array $elementRecords)¶
Index a set of Elements based on their name. The result is a doubly associative array, with the first key being element set name and the second being element name.
i.e., $indexed[‘Dublin Core’][‘Creator’] = Element instance
Parameters: - $elementRecords (array) – Set of Element records
Returns: array The provided Elements, indexed as described
- _indexElementsById($elementRecords)¶
Indexes the elements returned by element ID.
Parameters: - $elementRecords (unknown) –
Returns: array
- addTextForElement(Element $element, string $elementText, bool $isHtml =)¶
Add a string of text for an element.
Creates a new ElementText record, populates it with the specified text value and assigns it to the element.
saveElementTexts() must be called after this in order to save the elementtexts to the database.
Parameters: - $element (Element) – Element which text should be created for
- $elementText (string) – Text to be added
- $isHtml (bool) – Whether the text to add is HTML
- addElementTextsByArray($elementTexts)¶
Add element texts for a record based on a formatted array of values. The array must be formatted as follows:
'Element Set Name' => array('Element Name' => array(array('text' => 'foo', 'html' => false)))
Since 1.4, the array can also be formatted thusly:
array( array('element_id' => 1, 'text' => 'foo', 'html' => false) )
Parameters: - $elementTexts (unknown) –
- _addTextsByElementName($elementTexts)¶
Parameters: - $elementTexts (unknown) –
- _addTextsByElementId($texts)¶
Parameters: - $texts (unknown) –
- beforeSaveElements($post)¶
The application flow is thus:
- Build ElementText objects from the POST.2) Validate the ElementText objects and assign error messages ifnecessary.3) After the item saves correctly, delete all the ElementText recordsfor the Item.4) Save the new ElementText objects to the database.
Parameters: - $post (unknown) –
- _getElementTextsToSaveFromPost($post)¶
The POST should have a key called “Elements” that contains an array that is keyed to an element’s ID. That array should contain all the text values for that element. For example:
<code>
array(‘Elements’ =>array(‘50’ => array(array(‘text’ => ‘Foobar’, //element id 50, e.g. DC:Title’html’ => 0)),‘41’ => array(array(‘text’ => ‘<p>Baz baz baz</p>’, //element id 41, e.g. DC:Description’html’ => 1))))
</code>
Parameters: - $post (unknown) –
- getTextStringFromFormPost($postArray, $element)¶
Retrieve a text string for an element from POSTed form data.
Parameters: - $postArray (unknown) –
- $element (unknown) –
Returns: string
- _validateElementTexts()¶
Validate all the elements one by one. This is potentially a lot slower than batch processing the form, but it gives the added bonus of being able to encapsulate the logic for validation of Elements.
- _elementTextIsValid(ElementText $elementTextRecord)¶
Return whether the given ElementText record is valid.
Parameters: - $elementTextRecord (ElementText) –
Returns: boolean
- saveElementTexts()¶
Save all ElementText records that were associated with a record.
Typically called in the afterSave() hook for a record.
- deleteElementTextsByElementId($elementIdArray = Array)¶
Delete all the element texts for element_id’s that have been provided.
Parameters: - $elementIdArray (unknown) –
Returns: boolean
- deleteElementTexts()¶
Delete all the element texts assigned to the current record ID.
Returns: boolean
- hasElementText(string $elementSetName, string $elementName)¶
Returns whether or not the record has at least 1 element text
Parameters: - $elementSetName (string) – Element set name
- $elementName (string) – Element name
Returns: boolean
- getElementTextCount(string $elementSetName, string $elementName)¶
Returns the number of element texts for the record
Parameters: - $elementSetName (string) – Element set name
- $elementName (string) – Element name
Returns: boolean
Mixin_Owner¶
- class Mixin_Owner¶
Package: Record\Mixin
Mixin for models that have a user that is their “owner.”
- property _record¶
- property _column¶
- __construct($record, $column = owner_id)¶
Parameters: - $record (unknown) –
- $column (unknown) –
- beforeSave($args)¶
Parameters: - $args (unknown) –
- getOwner()¶
Get the record’s owner.
If the record has no user, this method returns null.
Returns: User|null
Mixin_PublicFeatured¶
- class Mixin_PublicFeatured¶
Package: Record\Mixin
Adds default behavior associated with the ‘public’ and ‘featured’ flags.
- property _wasPublic¶
- property _wasFeatured¶
- __construct(Omeka_Record_AbstractRecord $record)¶
Constructor
Parameters: - $record (Omeka_Record_AbstractRecord) – The underlying record
- isPublic()¶
Returns whether the record is public or not.
Returns: boolean
- setPublic(boolean $flag)¶
Sets whether the record is public or not.
Parameters: - $flag (boolean) – Whether the record is public or not
- isFeatured()¶
Returns whether the record is featured or not.
Returns: boolean
- setFeatured(boolean $flag)¶
Sets whether the record is featured or not.
Parameters: - $flag (boolean) – Whether the record is featured or not
- beforeSave($args)¶
Parameters: - $args (unknown) –
- afterSave($args)¶
Parameters: - $args (unknown) –
- _fireHook(string $state, boolean $flag)¶
Fires a hooks like ‘make_item_public’, ‘make_collection_not_featured’, etc.
Parameters: - $state (string) – Currently, ‘public’ or ‘featured’
- $flag (boolean) –
- _getHookName(string $state, boolean $flag)¶
Retrieve formatted hooks like ‘make_item_public’, ‘make_collection_not_featured’, etc.
Parameters: - $state (string) – Currently, ‘public’ or ‘featured’
- $flag (boolean) –
Returns: string The hook name
Mixin_Search¶
- class Mixin_Search¶
Package: Record\Mixin
Make an Omeka record fulltext searchable.
Any class that extends Omeka_Record_AbstractRecord can be made searchable bypushing an instance of this mixin into Omeka_Record::$_mixins duringOmeka_Record::_initializeMixins(). It must be pushed after all mixins thatcan add search text–for example, after ElementText.
The record type must also be registered using the search_record_types filter in order for the records to be searchable.
This mixin leverages the Omeka_Record_AbstractRecord::afterSave() andOmeka_Record_Mixin_AbstractMixin::afterSave() callbacks, so note their orderof execution. Records that initialize ActsAsElementText will automaticallyadd their element texts to the search text.
- property _text¶
- property _title¶
- property _public¶
- __construct($record)¶
Parameters: - $record (unknown) –
- addSearchText(string $text)¶
Add search text to this record.
This method is meant to be called during afterSave().
Parameters: - $text (string) –
- setSearchTextTitle(string $title)¶
Add a title to this record.
This method is meant to be called during afterSave().
Parameters: - $title (string) –
- setSearchTextPrivate()¶
Mark this record’s search text as not public.
This method is meant to be called during afterSave().
- afterSave($args)¶
Save the accumulated search text to the database.
Parameters: - $args (unknown) –
- afterDelete()¶
Delete this record’s search text after it has been deleted.
- saveSearchText(string $recordType, int $recordId, string $text, string $title, int $public = 1)¶
Save a search text row.
Call this statically only when necessary. Used primarily when in a recordthat does not implement Mixin_Search but contains text that is needed foranother record’s search text. For example, when saving a child recordthat contains search text that should be saved to its parent record.
Parameters: - $recordType (string) –
- $recordId (int) –
- $text (string) –
- $title (string) –
- $public (int) –
Mixin_Tag¶
- class Mixin_Tag¶
Package: Record\Mixin
- property _tagTable¶
- property _joinTable¶
- property _type¶
- __construct(Omeka_Record_AbstractRecord $record)¶
Parameters: - $record (Omeka_Record_AbstractRecord) –
- beforeDelete()¶
Fires whenever deleting a record that is taggable This will actually delete all the references to a specific tag for a specific record
Returns: void
- afterSave($args)¶
Add tags to this record’s search text.
Parameters: - $args (unknown) –
- deleteTaggings()¶
- getTaggings()¶
Retrieve all the Taggings objects that represent between a specific tag and the current record Called by whatever record has enabled this module
Returns: array of Taggings
- getTags($order = Array)¶
Get all the Tag records associated with this record
Parameters: - $order (unknown) –
Returns: array of Tag
- deleteTags(string|array $tags, string $delimiter)¶
Delete a tag from the record
Parameters: - $tags (string|array) – The tag name or array of tag names to delete from the record
- $delimiter (string) – The delimiter of the tags. Not applicable if $tags is an array
Returns: bool Returns whether a tag in $tags was deleted. Returns false if $tags is empty. Returns true if at least one tag in $tags is deleted.
- hasTag($tag)¶
If the $tag were a string and the keys of Tags were just the names of the tags, this would be: in_array(array_keys($this->Tags))
Parameters: - $tag (unknown) –
Returns: boolean
- _getTagsFromString(string $string, $delimiter)¶
Converts a delimited string of tags into an array of tag strings
Parameters: - $string (string) – A delimited string of tags
- $delimiter (unknown) –
Returns: array An array of tag strings
- addTags(array|string $tags, $delimiter)¶
Add tags for the record
Parameters: - $tags (array|string) – Either an array of tags or a delimited string
- $delimiter (unknown) –
Returns: void
- diffTagString($string, $tags, $delimiter)¶
Calculate the difference between a tag string and a set of tags
Parameters: - $string (unknown) –
- $tags (unknown) –
- $delimiter (unknown) –
Returns: array Keys(‘removed’,’added’)
- applyTagString(string $string, $delimiter)¶
This will add tags that are in the tag string and remove those that are no longer in the tag string
Parameters: - $string (string) – A string of tags delimited by $delimiter
- $delimiter (unknown) –
Returns: void
Mixin_Timestamp¶
- class Mixin_Timestamp¶
Package: Record\Mixin
Mixin for models that keep added and/or modified timestamps.
- property _record¶
- property _addedColumn¶
- property _modifiedColumn¶
- __construct(Omeka_Record_AbstractRecord $record, string $addedColumn = added, $modifiedColumn = modified)¶
Initialize the mixin.
Setting either of the column parameters to null will skip updating thattimestamp. The default column names are ‘updated’ and ‘added’.
Parameters: - $record (Omeka_Record_AbstractRecord) –
- $addedColumn (string) – Name of the column holding the “added” timestamp.
- $modifiedColumn (unknown) –
- beforeSave($args)¶
Before saving a record, set the “updated” timestamp.
Parameters: - $args (unknown) –
- _setTimestamp(string $column)¶
Update a timestamp column for the underlying record.
Parameters: - $column (string) – Column to update.
Omeka_Record_Mixin_AbstractMixin¶
- class Omeka_Record_Mixin_AbstractMixin¶
Package: Record\Mixin
Represents a kind of mixin for Omeka_Record_AbstractRecord implementations.
Any methods declared for an implementation of this class can be calledtransparently by an Omeka_Record_AbstractRecord object that uses one of thesemodules.
For instance, the Item model does not have an addTags() method, but theTaggable class does. Since Item declares Taggable as one of its modules,an Item instance call all of Taggable’s methods, so that adding tags would beas simple as calling $item->addTags(‘foo, bar’);
Note that this is not a true mixin because it cannot override any existingmethods on a Record object.
- property _record¶
Underlying record object.
- __construct(Omeka_Record_AbstractRecord $record)¶
Base mixin constructor.
Store the underlying record for use in the mixin.
Parameters: - $record (Omeka_Record_AbstractRecord) –
- beforeSave($args)¶
Callback automatically called by Omeka_Record_AbstractRecord.
See the corresponding {@link Omeka_Record_AbstractRecord} method fordefinitions of call times.
Parameters: - $args (unknown) –
Returns: void
- afterSave($args)¶
Parameters: - $args (unknown) –
- beforeDelete()¶
- afterDelete()¶
Session¶
Up to Class Library by Package
Omeka_Session_SaveHandler_DbTable¶
- class Omeka_Session_SaveHandler_DbTable¶
Package: Session
Wrapper for Zend_Session_SaveHandler_DbTable to hard code the table definition. This boosts performance by skipping the DESCRIBE query that retrieves this metadata by default.
Note that this must be updated meticulously after any changes to thesessions table schema.
- init()¶
Storage¶
Up to Class Library by Package
Omeka_Storage¶
- class Omeka_Storage¶
Package: Storage
Top-level helper class for handling file storage.
- property _adapter¶
- property _tempDir¶
- __construct(array $options)¶
Allows storage options to be set immediately at construction.
Parameters: - $options (array) – If set, this array will be passed to setOptions.
- __call(string $name, string $arguments)¶
Delegates calls directly to Omeka_Storage to the currently-set storage adapter.
All of the methods of the Adapter interface are accessible inthis way, as well as any other methods declared by the adapter.
Parameters: - $name (string) – Method name.
- $arguments (string) – Method arguments.
Returns: mixed
- setOptions(array $options)¶
Set global options for the storage system, as well as any adapter-specific options.
Parameters: - $options (array) – Options to set. Valid options include: * ‘adapter’: (string) Name of the storage adapter to use. * ‘adapterOptions’: (array) Array of options to pass to the adapter; see the specific adapter classes for details. * ‘temp_dir’: (string) Local temporary directory where files stored before they are handled by the adapter.
- setAdapter(Omeka_Storage_Adapter_AdapterInterface|string $adapter, array|null $options = Array)¶
Set the storage adapter to be used, as well as options for that adapter.
You can either pass an already-constructed adapter object to thismethod or use this method as a factory by passing the name of anadapter class and options to set on it.
Parameters: - $adapter (Omeka_Storage_Adapter_AdapterInterface|string) – Storage adapter to set. If an adapter object is passed, it is simply set as the current adapter. If a string is passed, an object of that class is created and set as the current adapter.
- $options (array|null) – If a string is passed to $adapter, this array of options is passed to the class’ constructor.
- getAdapter()¶
Get the current storage adapter.
You generally need to use the adapter object returned by thismethod to perform any storage actions.
Returns: Omeka_Storage_Adapter_AdapterInterface
- setTempDir(string $dir)¶
Set the temporary file storage directory path.
Parameters: - $dir (string) – Local path to directory.
- getTempDir()¶
Get the temporary file storage directory path.
If no directory has been explicitly selected, the system’s tempdirectory is set as the temp dir and returned.
Returns: string Local path to directory.
- getPathByType($filename, $type = files)¶
Parameters: - $filename (unknown) –
- $type (unknown) –
Omeka_Storage_Exception¶
- class Omeka_Storage_Exception¶
Package: Storage
- property message¶
- property string¶
- property code¶
- property file¶
- property line¶
- property trace¶
- property previous¶
- __clone()¶
- __construct($message, $code, $previous)¶
Parameters: - $message (unknown) –
- $code (unknown) –
- $previous (unknown) –
- getMessage()¶
- getCode()¶
- getFile()¶
- getLine()¶
- getTrace()¶
- getPrevious()¶
- getTraceAsString()¶
- __toString()¶
Storage\Adapter¶
Up to Storage
Omeka_Storage_Adapter_AdapterInterface¶
- class Omeka_Storage_Adapter_AdapterInterface¶
Package: Storage\Adapter
Interface for file storage adapters.
Classes that implement this interface handle the actual work ofstoring andretrieving files.
- __construct(array $options)¶
Set options for the storage adapter.
Parameters: - $options (array) –
- setUp()¶
Follow any necessary steps to set up storage prior to use.
E.g. for the filesystem adapter, this would include creating anydirectories that did not already exist. For S3, it might involvecreating a new bucket if it did not exist.
- canStore()¶
Check whether the adapter is set up correctly to be able to store files.
Returns: boolean
- store(string $source, string $dest)¶
Move a local file to “storage.”
Parameters: - $source (string) – Local filesystem path to file.
- $dest (string) – Destination path.
- move(string $source, string $dest)¶
Move a file between two storage locations.
Parameters: - $source (string) – Original storage path.
- $dest (string) – Destination storage path.
- delete(string $path)¶
Remove a “stored” file.
Parameters: - $path (string) –
- getUri(string $path)¶
Get a URI for a “stored” file.
Parameters: - $path (string) –
Returns: string URI
Omeka_Storage_Adapter_Filesystem¶
- class Omeka_Storage_Adapter_Filesystem¶
Package: Storage\Adapter
Standard local filesystem storage adapter.
The default adapter; this stores files in the Omeka files directory bydefault, but can be set to point to a different path.
- property _localDir¶
Local directory where files are stored.
- property _subDirs¶
- property _webDir¶
Web-accesible path that corresponds to $_localDir.
- __construct(array $options = Array)¶
Set options for the storage adapter.
Parameters: - $options (array) –
- setUp()¶
- canStore()¶
Check whether the adapter is set up correctly to be able to store files.
Specifically, this checks to see if the local storage directoryis writable.
Returns: boolean
- store(string $source, string $dest)¶
Move a local file to “storage.”
Parameters: - $source (string) – Local filesystem path to file.
- $dest (string) – Destination path.
- move(string $source, string $dest)¶
Move a file between two “storage” locations.
Parameters: - $source (string) – Original stored path.
- $dest (string) – Destination stored path.
- delete(string $path)¶
Remove a “stored” file.
Parameters: - $path (string) –
- getUri(string $path)¶
Get a URI for a “stored” file.
Parameters: - $path (string) –
Returns: string URI
- getOptions()¶
Return the options set by the adapter. Used primarily for testing.
- setLocalDir($dir)¶
Parameters: - $dir (unknown) –
- _getAbsPath(string $path)¶
Convert a “storage” path to an absolute filesystem path.
Parameters: - $path (string) – Storage path.
Returns: string Absolute local filesystem path.
- _rename($source, $dest)¶
Parameters: - $source (unknown) –
- $dest (unknown) –
Returns: boolean
Omeka_Storage_Adapter_TempFilesystem¶
- class Omeka_Storage_Adapter_TempFilesystem¶
Package: Storage\Adapter
Storage adapter that uses the system temp directory for its filesystem.
After the adapter is no longer needed (__destruct()), all the files that were created during its lifetime are removed.
Used primarily by the test framework.
- property _localDir¶
Local directory where files are stored.
- property _subDirs¶
- property _webDir¶
Web-accesible path that corresponds to $_localDir.
- canStore()¶
No need to perform this check.
- store(string $source, string $dest)¶
Move a local file to “storage.”
Parameters: - $source (string) – Local filesystem path to file.
- $dest (string) – Destination path.
- move(string $source, string $dest)¶
Move a file between two “storage” locations.
Parameters: - $source (string) – Original stored path.
- $dest (string) – Destination stored path.
- getUri($path)¶
Parameters: - $path (unknown) –
- _mkdir($filepath)¶
Parameters: - $filepath (unknown) –
- __construct(array $options = Array)¶
Set options for the storage adapter.
Parameters: - $options (array) –
- setUp()¶
- delete(string $path)¶
Remove a “stored” file.
Parameters: - $path (string) –
- getOptions()¶
Return the options set by the adapter. Used primarily for testing.
- setLocalDir($dir)¶
Parameters: - $dir (unknown) –
- _getAbsPath(string $path)¶
Convert a “storage” path to an absolute filesystem path.
Parameters: - $path (string) – Storage path.
Returns: string Absolute local filesystem path.
- _rename($source, $dest)¶
Parameters: - $source (unknown) –
- $dest (unknown) –
Returns: boolean
Omeka_Storage_Adapter_ZendS3¶
- class Omeka_Storage_Adapter_ZendS3¶
Package: Storage\Adapter
Cloud storage adapter for Amazon S3, using Zend’s built-in service.
Caveat: Zend’s storage adapter currently does not function correctlywith buckets that are validly-named, but use characters that cannotappear in domain names.
- property _s3¶
- property _options¶
- __construct(array $options = Array)¶
Set options for the storage adapter.
Parameters: - $options (array) –
- setUp()¶
- canStore()¶
- store(string $source, string $dest)¶
Move a local file to S3 storage.
Parameters: - $source (string) – Local filesystem path to file.
- $dest (string) – Destination path.
- move(string $source, string $dest)¶
Move a file between two “storage” locations.
Parameters: - $source (string) – Original stored path.
- $dest (string) – Destination stored path.
- delete(string $path)¶
Remove a “stored” file.
Parameters: - $path (string) –
- getUri(string $path)¶
Get a URI for a “stored” file.
Parameters: - $path (string) –
Returns: string URI
- _getBucketName()¶
Get the name of the bucket files should be stored in.
Returns: string Bucket name
- _getObjectName(string $path)¶
Get the object name. Zend’s S3 service requires you to build the object name by prepending the name of the target bucket.
Parameters: - $path (string) –
Returns: string Object name.
- _getExpiration()¶
Normalizes and returns the expiration time.
Converts to integer and returns zero for all non-positive numbers.
Returns: int
Test¶
Up to Class Library by Package
Omeka_Test_AppTestCase¶
- class Omeka_Test_AppTestCase¶
Package: Test
Abstract test case class that bootstraps the entire application.
- property _isAdminTest¶
Flag that determines whether the test should run against admin or public. Defaults to true (for admin).
- setUp()¶
Bootstrap the application on each test run.
Returns: void
- __get(string $property)¶
Proxy gets to properties to allow access to bootstrap container properties.
Parameters: - $property (string) –
Returns: mixed
- appBootstrap()¶
Bootstrap the application.
Returns: void
- setUpBootstrap(Zend_Application_Bootstrap $bootstrap)¶
Subclasses can override this to perform specialized setup on the Omeka application.
Parameters: - $bootstrap (Zend_Application_Bootstrap) –
Returns: void
- tearDown()¶
Reset objects that carry global state between test runs.
Returns: void
- dispatch(string $url, boolean $throwExceptions = 1)¶
Parameters: - $url (string) –
- $throwExceptions (boolean) –
Returns: void
- _authenticateUser(User $user)¶
Trick the environment into thinking that a user has been authenticated.
Parameters: - $user (User) –
Returns: void
- _getDefaultUser()¶
Get the user that is installed by default.
Returns: User
- _setUpThemeBootstrap($themeType)¶
Set up the bootstrap differently depending on whether the test is meant for the public or admin themes.
Parameters: - $themeType (unknown) –
Omeka_Test_Bootstrap¶
- class Omeka_Test_Bootstrap¶
Package: Test
Abstract test case class that bootstraps the entire application.
- property _container¶
- setContainer($container)¶
Set resource container
By default, if a resource callback has a non-null return value, thisvalue will be stored in a container using the resource name as thekey.
Containers must be objects, and must allow setting public properties.
Parameters: - $container (unknown) –
Returns: Zend_Application_Bootstrap_BootstrapAbstract
- getContainer()¶
Retrieve resource container
Returns: object
- hasResource($name)¶
Determine if a resource has been stored in the container
During bootstrap resource initialization, you may return a value. Ifyou do, it will be stored in the {@link setContainer() container}.You can use this method to determine if a value was stored.
Parameters: - $name (unknown) –
Returns: bool
- getResource($name)¶
Retrieve a resource from the container
During bootstrap resource initialization, you may return a value. Ifyou do, it will be stored in the {@link setContainer() container}.You can use this method to retrieve that value.
If no value was returned, this will return a null value.
Parameters: - $name (unknown) –
Returns: null|mixed
Test\Helper¶
Up to Test
Omeka_Test_Helper_Db¶
- class Omeka_Test_Helper_Db¶
Package: Test\Helper
Catch-all class for database helper methods that are shared across test cases.
- property _dbAdapter¶
Database adapter object.
- property _prefix¶
- __construct(Zend_Db_Adapter_Abstract $dbAdapter, $prefix)¶
Parameters: - $dbAdapter (Zend_Db_Adapter_Abstract) –
- $prefix (unknown) –
- __call(string $method, array $args)¶
Proxy to the db adapter object for all other requests.
Parameters: - $method (string) – Method name.
- $args (array) – Method arguments.
Returns: array
- factory($dbConfig)¶
Create an instance of the helper that is configured for the correct database.
Parameters: - $dbConfig (unknown) –
- tableExists(string $tableName)¶
Check whether a table exists in the database.
Parameters: - $tableName (string) –
Returns: boolean
- getTableCount(string $prefix)¶
Get the number of tables in the database.
Parameters: - $prefix (string) –
Returns: integer
- dropTables($tables)¶
Drop the tables from the database.
Parameters: - $tables (unknown) –
Returns: void
- truncateTables($tables)¶
Truncate the tables from the database.
Parameters: - $tables (unknown) –
Returns: void
- install()¶
- getTableNames()¶
Get the tables in the database.
Returns: array
- getRowCount(string $tableName)¶
Get the number of rows in a table.
Parameters: - $tableName (string) –
Returns: integer
- getAdapter()¶
- getPrefix()¶
Omeka_Test_Helper_DbProfiler¶
- class Omeka_Test_Helper_DbProfiler¶
Package: Test\Helper
Catch-all class for database helper methods that are shared across test cases.
- property _profiler¶
- property _test¶
- __construct(Zend_Db_Profiler $profiler, PHPUnit_Framework_Assert $test)¶
Constructor.
Parameters: - $profiler (Zend_Db_Profiler) –
- $test (PHPUnit_Framework_Assert) –
- assertDbQuery($sqlPart, $message)¶
Parameters: - $sqlPart (unknown) –
- $message (unknown) –
- assertTotalNumQueries(integer $queryCount, $msg)¶
Assert that the given number of SQL queries were made.
Parameters: - $queryCount (integer) –
- $msg (unknown) –
Omeka_Test_Helper_Mail¶
- class Omeka_Test_Helper_Mail¶
Package: Test\Helper
Encapsulates testing functionality for email.
- property _path¶
Path to the mail storage directory.
- __construct(string $path)¶
Parameters: - $path (string) – Real path to the mail storage directory.
- factory()¶
Configure an instance of the Mail helper using the registered test_config.
Returns: Omeka_Test_Helper_Mail
- _getIterator()¶
Get an iterator over the fakemail directory.
Returns: DirectoryIterator
- _isMailFile(SplFileInfo $file)¶
Check if a directory entry is a mail message file.
Parameters: - $file (SplFileInfo) –
Returns: boolean
- getMailText(integer $index = 0)¶
Return the text of the n’th email that was sent during the test.
Note that this will not return correct results if reset() was notinvoked between test runs.
Parameters: - $index (integer) –
Returns: string
- count()¶
The number of mails that have been sent.
Omeka_Test_Helper_Plugin¶
- class Omeka_Test_Helper_Plugin¶
Package: Test\Helper
Encapsulates testing functionality for Omeka plugins.
- setUp(string $pluginName)¶
Install and initialize a plugin.
Note: Normally used in the setUp() method of plugin tests.
Parameters: - $pluginName (string) –
- install(string $pluginName)¶
Install a plugin
Parameters: - $pluginName (string) – The name of the plugin to install.
Returns: Plugin
- initialize(string $pluginName)¶
Initializes the plugin hooks and filters fired in the core resources for a plugin Note: Normally used in the setUp() function of the subclasses that test plugins.
Parameters: - $pluginName (string) – If omitted, initialize all installed plugins.
Returns: void
- _defineResponseContexts()¶
Run the response_contexts filter.
Returns: void
- setPluginLoader(Omeka_Plugin_Loader $pluginLoader)¶
Set the plugin loader for the helper to use.
Parameters: - $pluginLoader (Omeka_Plugin_Loader) –
- setPluginIniReader(Omeka_Plugin_Ini $pluginIniReader)¶
Set the plugin INI reader for the helper to use.
Parameters: - $pluginIniReader (Omeka_Plugin_Ini) –
- setPluginBroker(Omeka_Plugin_Broker $pluginBroker)¶
Set the plugin broker for the helper to use.
Parameters: - $pluginBroker (Omeka_Plugin_Broker) –
- setAcl(Zend_Acl $acl)¶
Set the ACL for the helper to use.
Parameters: - $acl (Zend_Acl) –
- setRouter(Zend_Controller_Router_Interface $router)¶
Set the router for the helper to use.
Parameters: - $router (Zend_Controller_Router_Interface) –
- __get($name)¶
Lazy-loading for helper properties.
When a property is not set, attempts to load a default through standardOmeka global state. If this state is unavailable or undesireable,use the set*() methods before calling any of the other public methodsof this class.
Parameters: - $name (unknown) –
Returns: mixed
Test\Resource¶
Up to Test
Omeka_Test_Resource_Config¶
- class Omeka_Test_Resource_Config¶
Package: Test\Resource
Load the default config for the application, but also load the test config into Zend_Registry.
- property _coreResource¶
- __construct(array $options)¶
Parameters: - $options (array) – Options for resource.
- init()¶
Load both config files.
Returns: Zend_Config
Omeka_Test_Resource_Currentuser¶
- class Omeka_Test_Resource_Currentuser¶
Package: Test\Resource
Mask the behavior of Omeka_Application_Resource_Currentuser in tests.
- init()¶
Omeka_Test_Resource_Db¶
- class Omeka_Test_Resource_Db¶
Package: Test\Resource
Set up the database test environment by wiping and resetting the database to a recently-installed state.
- property dropTables¶
Flag to determine whether the tables need to be dropped. This is a slow process, and really should only be happening once, when the tests are first run.
- property runInstaller¶
Flag to determine whether the installer needs to be run.
- property _cachedAdapter¶
Avoid issues with database connections not closing properly after each test run.
- init()¶
Load and initialize the database.
Returns: Omeka_Db
- getDb()¶
Returns: Omeka_Db
- useTestConfig()¶
- setInstall(boolean $flag)¶
Set the flag that indicates whether or not to run the installer during init().
Parameters: - $flag (boolean) –
- getDbAdapter()¶
- setDbAdapter(Zend_Db_Adapter_Abstract $dbAdapter)¶
Parameters: - $dbAdapter (Zend_Db_Adapter_Abstract) –
Omeka_Test_Resource_Debug¶
- class Omeka_Test_Resource_Debug¶
Package: Test\Resource
Stub resource to mask the behavior of Omeka_Application_Resource_Debug.
- init()¶
Omeka_Test_Resource_Mail¶
- class Omeka_Test_Resource_Mail¶
Package: Test\Resource
Testing resource for saving mail to the filesystem.
- init()¶
Returns: Zend_Mail
- mailCallback($transport)¶
Makes mail output names contain both the timestamp and an incrementing counter. The timestamp ensures mails between test runs don’t collide, the counter differentiates between messages sent during the same timestamp unit (common).
Parameters: - $transport (unknown) –
Omeka_Test_Resource_Storage¶
- class Omeka_Test_Resource_Storage¶
Package: Test\Resource
Bootstrap resource for storage in test environment.
- init()¶
Omeka_Test_Resource_Tempdir¶
- class Omeka_Test_Resource_Tempdir¶
Package: Test\Resource
Bootstrap resource for storage in test environment.
- init()¶
- cleanDir($dir)¶
Parameters: - $dir (unknown) –
Validate¶
Up to Class Library by Package
Omeka_Validate_Confirmation¶
- class Omeka_Validate_Confirmation¶
Package: Validate
Adapted from Zend Framework documentation on custom validators.
- constant NOT_MATCH¶
Error message for non-matching confirmation.
- property _field¶
Field needing confirmation.
- property _messageTemplates¶
Error messages.
- property _messageVariables¶
Error message replace variables.
- __construct($field)¶
Sets validator options
Parameters: - $field (unknown) –
- isValid(string $value, string|array $context)¶
Check that the value is valid.
Parameters: - $value (string) –
- $context (string|array) –
Returns: boolean
- getField()¶
Get the name of the field that needs confirmation.
Returns: string
- setField(string $field)¶
Set the name of the field that needs confirmation.
Parameters: - $field (string) –
Returns: void
Omeka_Validate_Errors¶
- class Omeka_Validate_Errors¶
Package: Validate
This is an object wrapper for validation errors. The primary advantage to having this class is that casting it to a string will convert the errors into a nicely formatted, human-readable string.
- property _errors¶
List of validation errors.
- __construct(array|null $errors)¶
Parameters: - $errors (array|null) – Initial errors to set.
- offsetGet(mixed $key)¶
Get an error from the list. Required by ArrayObject.
Parameters: - $key (mixed) – Key into array.
- offsetSet(mixed $key, mixed $val)¶
Set an error into the list. Required by ArrayObject.
Parameters: - $key (mixed) – Key into array.
- $val (mixed) – Value to store.
- get()¶
Get the array of errors.
Returns: array
- count()¶
Get the number of errors.
Returns: integer
- __toString()¶
Get a string representation of all the stored errors.
Returns: string
- offsetExists($index)¶
Parameters: - $index (unknown) –
- offsetUnset($index)¶
Parameters: - $index (unknown) –
- append($value)¶
Parameters: - $value (unknown) –
- getArrayCopy()¶
- getFlags()¶
- setFlags($flags)¶
Parameters: - $flags (unknown) –
- asort()¶
- ksort()¶
- uasort($cmp_function)¶
Parameters: - $cmp_function (unknown) –
- uksort($cmp_function)¶
Parameters: - $cmp_function (unknown) –
- natsort()¶
- natcasesort()¶
- unserialize($serialized)¶
Parameters: - $serialized (unknown) –
- serialize()¶
- getIterator()¶
- exchangeArray($array)¶
Parameters: - $array (unknown) –
- setIteratorClass($iteratorClass)¶
Parameters: - $iteratorClass (unknown) –
- getIteratorClass()¶
Omeka_Validate_Exception¶
- class Omeka_Validate_Exception¶
Package: Validate
Exception that is thrown when a form could not be validated correctly.
- property _errors¶
Message representing form errors.
- property message¶
- property string¶
- property code¶
- property file¶
- property line¶
- property trace¶
- property previous¶
- __construct($errors)¶
Parameters: - $errors (unknown) –
Returns: void
- getErrors()¶
Get the error message that caused this exception.
Returns: string
- __clone()¶
- getMessage()¶
- getCode()¶
- getFile()¶
- getLine()¶
- getTrace()¶
- getPrevious()¶
- getTraceAsString()¶
- __toString()¶
Omeka_Validate_File_Extension¶
- class Omeka_Validate_File_Extension¶
Package: Validate
Define custom behavior for the default whitelist file extension validator.
Baseline behavior of this class is to tweak the default error messages.Messages are intentionally as detailed as possible. Note that it is theresponsibility of plugin writers to suppress or replace these messages ifnecessary for security reasons, e.g. if displaying it to the end user mightexpose the site to vulnerability probes.
- property _messageTemplates¶
Overrides default error message templates.
- property _targetExtension¶
The extension of the file being validated
- __construct(mixed $options)¶
Constructor retrieves the whitelist from the database if no arguments are given.
Parameters: - $options (mixed) –
Returns: void
- isValid(string $value, array $file)¶
Returns true if and only if the fileextension of $value is included in the set extension list.
Parameters: - $value (string) – Real file to check for extension.
- $file (array) – File data from Zend_File_Transfer.
Returns: boolean
Omeka_Validate_File_MimeType¶
- class Omeka_Validate_File_MimeType¶
Package: Validate
Validates files against a MIME type whitelist.
- property _messageTemplates¶
- property _messageVariables¶
- property _customWhitelist¶
- property _file¶
- property _mimeType¶
- __construct()¶
Construct the validator object.
- isValid(string $file)¶
Vaidate the file MIME type.
Parameters: - $file (string) –
Returns: bool
Omeka_Validate_Uri¶
- class Omeka_Validate_Uri¶
Package: Validate
Adapted from: http://www.techchorus.net/validate-uri-form-fields-zend-framework-custom-validator
- property _messageTemplates¶
- isValid($value)¶
Parameters: - $value (unknown) –
Omeka_Validate_UserPassword¶
- class Omeka_Validate_UserPassword¶
Package: Validate
Validate a password to see if it matches that of an existing user.
- constant INVALID¶
Invalid password error.
- property _messageTemplates¶
Error message templates.
- property _user¶
User to check the password against.
- isValid(string $value, null $context)¶
Validate against a user’s stored password.
Parameters: - $value (string) – Password to check.
- $context (null) – Not used.
View¶
Up to Class Library by Package
Omeka_View¶
- class Omeka_View¶
Package: View
Customized subclass of Zend Framework’s View class.
This adds the correct script paths for themes and plugins so that controllers can render the appropriate scripts.
This will also inject directly into the view scripts all variables that havebeen assigned to the view, so that theme writers can access them as $iteminstead of $this->item, for example.
- property _asset_paths¶
Maintains a key => value pairing corresponding to hard path => web path for possible assets for Omeka views.
- property _customScriptsLoaded¶
Flag indicated whether theme custom scripts have been loaded.
- __construct(array $config = Array)¶
Parameters: - $config (array) – View configuration.
- getAssetPaths()¶
Get the currently-configured asset paths.
Returns: array
- addAssetPath(string $physical, string $web)¶
Add an asset path to the view.
Parameters: - $physical (string) – Local filesystem path.
- $web (string) – URL path.
Returns: void
- setAssetPath(string $physical, string $web)¶
Remove the existing asset paths and set a single new one.
Parameters: - $physical (string) – Local filesystem path.
- $web (string) – URL path.
Returns: void
- _run()¶
Allow for variables set to the view object to be referenced in the view script by their actual name.
Also allows access to theme helpers.
For example, in a controller you might do something like:$view->assign(‘themes’, $themes);Normally in the view you would then reference $themes through:$this->themes;
Now you can reference it simply by using:$themes;
Returns: void
- _loadCustomThemeScripts()¶
Look for a ‘custom.php’ script in all script paths and include the file if it exists.
Returns: void
- addScriptPath(string $path)¶
Add a script path to the view.
Parameters: - $path (string) – Local filesystem path.
Omeka_View_Exception¶
- class Omeka_View_Exception¶
Package: View
Exceptions thrown by Omeka view code and helpers.
- property message¶
- property string¶
- property code¶
- property file¶
- property line¶
- property trace¶
- property previous¶
- __clone()¶
- __construct($message, $code, $previous)¶
Parameters: - $message (unknown) –
- $code (unknown) –
- $previous (unknown) –
- getMessage()¶
- getCode()¶
- getFile()¶
- getLine()¶
- getTrace()¶
- getPrevious()¶
- getTraceAsString()¶
- __toString()¶
Class Library by Path¶
Omeka_Application¶
- class Omeka_Application¶
Package: Application
Core class used to bootstrap the Omeka environment.
Various duties include, but are not limited to setting up class autoload, database, configuration files, logging, plugins, front controller, etc.
When any core resource returns from init(), the result is stored in thebootstrap container. Other parts of the application can get the resourcesfrom the bootstrap when needed.
- __construct(string $environment, string|array|Zend_Config $options)¶
Initialize the application.
Parameters: - $environment (string) – The environment name.
- $options (string|array|Zend_Config) – Application configuration.
- initialize()¶
Bootstrap the entire application.
- run()¶
Display the generic error page for all otherwise-uncaught exceptions.
- _displayErrorPage(Exception $e, string $title)¶
Print an HTML page to display errors when starting the application.
Parameters: - $e (Exception) –
- $title (string) – The title of the error page.
Omeka_Captcha¶
- class Omeka_Captcha¶
Package: Captcha
Factory for creating a captcha for use when soliciting public input.
- getCaptcha()¶
Get a captcha object implementing Zend’s captcha API.
Returns: Zend_Captcha_Adapter|null
- isConfigured()¶
Return whether the captcha is configured. If this returns true, getCaptcha will not return null.
Returns: boolean
Omeka_Db¶
- class Omeka_Db¶
Package: Db
Database manager object for Omeka
While mostly a wrapper for a Zend_Db_Adapter instance, this also providesshortcuts for retrieving table objects and table names for use in SQL.
- property prefix¶
The prefix that every table in the omeka database will use.
- property _adapter¶
The database adapter.
- property _tables¶
All the tables that are currently managed by this database object.
- property _logger¶
The logger to use for logging SQL queries. If not set, no logging will be done.
- __construct(Zend_Db_Adapter_Abstract $adapter, string $prefix)¶
Parameters: - $adapter (Zend_Db_Adapter_Abstract) – A Zend Framework connection object.
- $prefix (string) – The prefix for the database tables, if applicable.
- __call(string $m, array $a)¶
Delegate to the database adapter.
Parameters: - $m (string) – Method name.
- $a (array) – Method arguments.
Returns: mixed
- __get(string $name)¶
Magic getter is a synonym for Omeka_Db::getTableName().
Example: $db->Item is equivalent to $db->getTableName(‘Item’).
Parameters: - $name (string) – Property name; table model class name in this case.
Returns: string|null
- setLogger(Zend_Log $logger)¶
Set logger for SQL queries.
Parameters: - $logger (Zend_Log) –
- getAdapter()¶
Retrieve the database adapter.
Returns: Zend_Db_Adapter_Abstract
- getTableName($class)¶
Retrieve the name of the table (including the prefix).
Parameters: - $class (unknown) –
Returns: string
- hasPrefix()¶
Check whether the database tables have a prefix.
Returns: boolean
- getTable(string $class)¶
Retrieve a table object corresponding to the model class.
Table classes can be extended by inheriting off of Omeka_Db_Table andthen calling your table Table_ModelName, e.g. Table_Item orTable_Collection. For backwards compatibility you may call your tableModelNameTable, i.e. ItemTable or CollectionTable. The latter namingpattern is deprecated.
This will cache every table object so that tables are not instantiatedmultiple times for complicated web requests.
Parameters: - $class (string) – Model class name.
Returns: Omeka_Db_Table
- setTable(string $alias, Omeka_Db_Table $table)¶
Cache a table object.
Prevents the creation of unnecessary instances.
Parameters: - $alias (string) –
- $table (Omeka_Db_Table) –
- insert(string $table, array $values = Array)¶
Every query ends up looking like: INSERT INTO table (field, field2, field3, ...) VALUES (?, ?, ?, ...) ON DUPLICATE KEY UPDATE field = ?, field2 = ?, ...
Note on portability: ON DUPLICATE KEY UPDATE is a MySQL extension.The advantage to using this is that it doesn’t care whether a row exists already.Basically it combines what would be insert() and update() methods in otherORMs into a single method
Parameters: - $table (string) – Table model class name.
- $values (array) – Rows to insert (or update).
Returns: integer The ID for the row that got inserted (or updated).
- log(string|Zend_Db_Select $sql)¶
Log SQL query if logging is configured.
This logs the query before variable substitution from bind params.
Parameters: - $sql (string|Zend_Db_Select) –
- queryBlock(string $sql, string $delimiter = ;)¶
Execute more than one SQL query at once.
Parameters: - $sql (string) – String containing SQL queries.
- $delimiter (string) – Character that delimits each SQL query.
- loadSqlFile(string $filePath)¶
Read the contents of an SQL file and execute all the queries therein.
In addition to reading the file, this will make substitutions based onspecific naming conventions. Currently makes the following substitutions:%PREFIX% will be replaced by the table prefix.
Parameters: - $filePath (string) – Path to the SQL file to load
Omeka_Form¶
- class Omeka_Form¶
Package: Form
A Zend_Form subclass that sets up forms to be properly displayed in Omeka.
- property _defaultDisplayGroupClass¶
Class name of Omeka DisplayGroup subclass.
- property _autoApplyOmekaStyles¶
Whether or not to automatically apply Omeka-specific decorators and styling information to form elements prior to rendering.
- init()¶
Set up Omeka-specific form elements and decorators.
Returns: void
- loadDefaultDecorators()¶
Set up base form decorators.
Returns: void
- getDefaultElementDecorators()¶
Return default decorators for form elements.
Makes form output conform to Omeka conventions.
Returns: array
- applyOmekaStyles()¶
Configure element styles / decorators based on the type of element.
This may be called after elements to the form, as the decoratorconfiguration in init() runs before elements can be added.
Returns: void
- getMessagesAsString(string $messageDelimiter =, string $elementDelimiter =)¶
Retrieve all of the form error messages as a nicely formatted string.
Useful for displaying all form errors at the top of a form, or for flashingform errors after redirects.
Parameters: - $messageDelimiter (string) – The string to display between different error messages for an element.
- $elementDelimiter (string) – The string to display between different elements.
Returns: string
- setAutoApplyOmekaStyles(mixed $flag)¶
Specify whether or not to automatically apply Omeka-specific decorators and styles prior to rendering the form.
Parameters: - $flag (mixed) – A boolean or boolean-equivalent.
Returns: void
- render(Zend_View_Interface $view)¶
Apply Omeka default styles (if requested) just before rendering.
Parameters: - $view (Zend_View_Interface) –
Returns: string
- _addClassNameToElement(Zend_Form_Element $element, string $className)¶
Add a specific class name to an element.
Parameters: - $element (Zend_Form_Element) –
- $className (string) –
Returns: void
Omeka_Storage¶
- class Omeka_Storage¶
Package: Storage
Top-level helper class for handling file storage.
- property _adapter¶
- property _tempDir¶
- __construct(array $options)¶
Allows storage options to be set immediately at construction.
Parameters: - $options (array) – If set, this array will be passed to setOptions.
- __call(string $name, string $arguments)¶
Delegates calls directly to Omeka_Storage to the currently-set storage adapter.
All of the methods of the Adapter interface are accessible inthis way, as well as any other methods declared by the adapter.
Parameters: - $name (string) – Method name.
- $arguments (string) – Method arguments.
Returns: mixed
- setOptions(array $options)¶
Set global options for the storage system, as well as any adapter-specific options.
Parameters: - $options (array) – Options to set. Valid options include: * ‘adapter’: (string) Name of the storage adapter to use. * ‘adapterOptions’: (array) Array of options to pass to the adapter; see the specific adapter classes for details. * ‘temp_dir’: (string) Local temporary directory where files stored before they are handled by the adapter.
- setAdapter(Omeka_Storage_Adapter_AdapterInterface|string $adapter, array|null $options = Array)¶
Set the storage adapter to be used, as well as options for that adapter.
You can either pass an already-constructed adapter object to thismethod or use this method as a factory by passing the name of anadapter class and options to set on it.
Parameters: - $adapter (Omeka_Storage_Adapter_AdapterInterface|string) – Storage adapter to set. If an adapter object is passed, it is simply set as the current adapter. If a string is passed, an object of that class is created and set as the current adapter.
- $options (array|null) – If a string is passed to $adapter, this array of options is passed to the class’ constructor.
- getAdapter()¶
Get the current storage adapter.
You generally need to use the adapter object returned by thismethod to perform any storage actions.
Returns: Omeka_Storage_Adapter_AdapterInterface
- setTempDir(string $dir)¶
Set the temporary file storage directory path.
Parameters: - $dir (string) – Local path to directory.
- getTempDir()¶
Get the temporary file storage directory path.
If no directory has been explicitly selected, the system’s tempdirectory is set as the temp dir and returned.
Returns: string Local path to directory.
- getPathByType($filename, $type = files)¶
Parameters: - $filename (unknown) –
- $type (unknown) –
Omeka_View¶
- class Omeka_View¶
Package: View
Customized subclass of Zend Framework’s View class.
This adds the correct script paths for themes and plugins so that controllers can render the appropriate scripts.
This will also inject directly into the view scripts all variables that havebeen assigned to the view, so that theme writers can access them as $iteminstead of $this->item, for example.
- property _asset_paths¶
Maintains a key => value pairing corresponding to hard path => web path for possible assets for Omeka views.
- property _customScriptsLoaded¶
Flag indicated whether theme custom scripts have been loaded.
- __construct(array $config = Array)¶
Parameters: - $config (array) – View configuration.
- getAssetPaths()¶
Get the currently-configured asset paths.
Returns: array
- addAssetPath(string $physical, string $web)¶
Add an asset path to the view.
Parameters: - $physical (string) – Local filesystem path.
- $web (string) – URL path.
Returns: void
- setAssetPath(string $physical, string $web)¶
Remove the existing asset paths and set a single new one.
Parameters: - $physical (string) – Local filesystem path.
- $web (string) – URL path.
Returns: void
- _run()¶
Allow for variables set to the view object to be referenced in the view script by their actual name.
Also allows access to theme helpers.
For example, in a controller you might do something like:$view->assign(‘themes’, $themes);Normally in the view you would then reference $themes through:$this->themes;
Now you can reference it simply by using:$themes;
Returns: void
- _loadCustomThemeScripts()¶
Look for a ‘custom.php’ script in all script paths and include the file if it exists.
Returns: void
- addScriptPath(string $path)¶
Add a script path to the view.
Parameters: - $path (string) – Local filesystem path.
Libraries/Omeka/Acl¶
Libraries/Omeka/Acl/Assert¶
Omeka_Acl_Assert_Ownership¶
- class Omeka_Acl_Assert_Ownership¶
Package: Acl
Assertion to take account of “All” and “Self” sub-permissions for records.
A common use is the “edit” and “delete” permissions for Items and other”ownable” records.
- assert(Zend_Acl $acl, Zend_Acl_Role_Interface $role, Zend_Acl_Resource_Interface $resource, $privilege)¶
Assert whether or not the ACL should allow access.
Parameters: - $acl (Zend_Acl) –
- $role (Zend_Acl_Role_Interface) –
- $resource (Zend_Acl_Resource_Interface) –
- $privilege (unknown) –
- _userOwnsRecord($user, $record)¶
Check whether the user owns this specific record.
Parameters: - $user (unknown) –
- $record (unknown) –
Omeka_Acl_Assert_User¶
- class Omeka_Acl_Assert_User¶
Package: Acl
Assert whether or not a specific user is allowed access to that person’s user account data.
- property _allowSelf¶
- property _denySelf¶
- assert(Zend_Acl $acl, Zend_Acl_Role_Interface $role, Zend_Acl_Resource_Interface $resource, $privilege)¶
Assert whether or not the ACL should allow access.
Assertions follow this logic:
Non-authenticated users (null role) have no access.
There exists a set of privileges (A) that are always allowed, provided that theuser role and user resource are the same (editing own info, changing ownpassword, etc.).
There also exists a set of privileges (B) that are always denied whenperformed on one’s own user account (deleting own account, changing ownrole, etc.)
The super user can do anything that isn’t on (B), e.g. the super user account cannot modify its own role.
All other users are limited to (A).
Parameters: - $acl (Zend_Acl) –
- $role (Zend_Acl_Role_Interface) –
- $resource (Zend_Acl_Resource_Interface) –
- $privilege (unknown) –
- _isAllowedSelf($privilege)¶
Parameters: - $privilege (unknown) –
- _isDeniedSelf($privilege)¶
Parameters: - $privilege (unknown) –
- _isSelf($role, $resource)¶
Parameters: - $role (unknown) –
- $resource (unknown) –
- _isSuperUser($user)¶
Parameters: - $user (unknown) –
Libraries/Omeka/Application¶
Libraries/Omeka/Application/Resource¶
Omeka_Application_Resource_Acl¶
- class Omeka_Application_Resource_Acl¶
Package: Application\Resource
Initializes Omeka’s ACL.
- property _acl¶
Access control list object.
- init()¶
Load the hardcoded ACL definitions, then apply definitions from plugins.
Returns: Zend_Acl
- getAcl()¶
Omeka_Application_Resource_Auth¶
- class Omeka_Application_Resource_Auth¶
Package: Application\Resource
Authentication resource.
- init()¶
Returns: Zend_Auth
Omeka_Application_Resource_Autoloader¶
- class Omeka_Application_Resource_Autoloader¶
Package: Application\Resource
An application resource for class autoloaders.
Omeka_Application_Resource_Cachemanager¶
- class Omeka_Application_Resource_Cachemanager¶
Package: Application\Resource
Core resource for configuring caches for use by other components.
- init()¶
Omeka_Application_Resource_Config¶
- class Omeka_Application_Resource_Config¶
Package: Application\Resource
Load the default configuration file for Omeka.
- init()¶
Returns: Zend_Config_Ini
Omeka_Application_Resource_Currentuser¶
- class Omeka_Application_Resource_Currentuser¶
Package: Application\Resource
Retrive the User record corresponding to the authenticated user.
If the user record is not retrievable (invalid ID), then the authenticationID will be cleared.
- init()¶
Retrieve the User record associated with the authenticated user.
Note that this returns null when no User is authenticated. Priorto 1.4, this returned boolean false. For forward-compatibility, thishas been changed to null in 1.4. This is because in future versions,User will implement Zend_Role_Interface. Zend_Acl accepts null asa valid role, but it throws exceptions for boolean false (tries toconvert it to the empty string).
Returns: User|null
Omeka_Application_Resource_Db¶
- class Omeka_Application_Resource_Db¶
Package: Application\Resource
Set up the default database connection for Omeka.
- property _iniPath¶
Path to the database configuration file. Set in application.ini
- init()¶
Returns: Omeka_Db
Omeka_Application_Resource_Debug¶
- class Omeka_Application_Resource_Debug¶
Package: Application\Resource
Sets up debugging output for web requests (if enabled).
- init()¶
Omeka_Application_Resource_Exception¶
- class Omeka_Application_Resource_Exception¶
Package: Application\Resource
Marker interface.
For future exceptions thrown by Omeka_Application_Resource classes. Thisprovides a pattern for differentiating setup/configuration errors.
Omeka_Application_Resource_Frontcontroller¶
- class Omeka_Application_Resource_Frontcontroller¶
Package: Application\Resource
Front controller resource.
- init()¶
Returns: Zend_Controller_Front
Omeka_Application_Resource_Helpers¶
- class Omeka_Application_Resource_Helpers¶
Package: Application\Resource
Initializes controller action helpers.
- init()¶
- _initDbHelper()¶
- _initViewRenderer()¶
- _initResponseContexts()¶
Define the custom response format contexts for Omeka.
Plugin writers should use the ‘response_contexts’ filter to modify or expand the list of formats that existing controllers may respond to.
Example of a definition of a response context through the ZF API:
$contexts->addContext(‘dc’, array(‘suffix’ => ‘dc’,’headers’ => array(‘Content-Type’ => ‘text/xml’),’callbacks’ => array(‘init’ => ‘atBeginningDoThis’,’post’ => ‘afterwardsDoThis’)));
Returns: void
- getDefaultResponseContexts()¶
Returns the default response contexts for Omeka.
Returns: array
- _initAclHelper()¶
Omeka_Application_Resource_Jobs¶
- class Omeka_Application_Resource_Jobs¶
Package: Application\Resource
Bootstrap resource for configuring the job dispatcher.
- init()¶
Omeka_Application_Resource_Locale¶
- class Omeka_Application_Resource_Locale¶
Package: Application\Resource
Core resource for configuring and loading the translation and locale components.
- init()¶
- _setTranslate($locale, $cache)¶
Retrieve translation configuration options.
Parameters: - $locale (unknown) –
- $cache (unknown) –
Returns: string
Omeka_Application_Resource_Logger¶
- class Omeka_Application_Resource_Logger¶
Package: Application\Resource
If logging has been enabled in the config file, then set up Zend’s logging mechanism.
- init()¶
Returns: Zend_Log
- _addMailWriter(Zend_Log $log, string $toEmail, $filter)¶
Set up debugging emails.
Parameters: - $log (Zend_Log) –
- $toEmail (string) – Email address of debug message recipient.
- $filter (unknown) –
Omeka_Application_Resource_Mail¶
- class Omeka_Application_Resource_Mail¶
Package: Application\Resource
Set up the mail transport that Omeka uses to send mail.
This makes use of Zend_Application_Resource_Mail for configuring the mailresource. config.ini can be set up using either the Zend Framework way orusing the older Omeka configuration style (for backwards-compatibility),though the newer style is recommended.
- property _zendResource¶
- __construct($options)¶
Parameters: - $options (unknown) –
- init()¶
Returns: Zend_Mail
Omeka_Application_Resource_Options¶
- class Omeka_Application_Resource_Options¶
Package: Application\Resource
Retrieve all the options from the database.
Options are essentially site-wide variables that are stored in the database,for example the title of the site. Failure to load this resource currentlyindicates that Omeka needs to be installed.
- property _installerRedirect¶
- init()¶
Returns: array
- setInstallerRedirect($flag)¶
Parameters: - $flag (unknown) –
- _convertMigrationSchema($options)¶
If necessary, convert from the old sequentially-numbered migration scheme to the new timestamped migrations.
Parameters: - $options (unknown) –
Returns: void.
Omeka_Application_Resource_Pluginbroker¶
- class Omeka_Application_Resource_Pluginbroker¶
Package: Application\Resource
Set up the plugin broker.
- init()¶
Returns: Omeka_Plugin_Broker
Omeka_Application_Resource_Plugins¶
- class Omeka_Application_Resource_Plugins¶
Package: Application\Resource
Fire the ‘initialize’ hook for all installed plugins.
Note that this hook fires before the front controller has been initialized ordispatched.
- init()¶
Omeka_Application_Resource_Router¶
- class Omeka_Application_Resource_Router¶
Package: Application\Resource
Set up the router and the built-in routes.
- init()¶
Returns: Zend_Controller_Router_Rewrite
- _addHomepageRoute(Zend_Controller_Router_Rewrite $router)¶
Adds the homepage route to the router (as specified by the navigation settings page) The route will not be added if the user is currently on the admin theme.
Parameters: - $router (Zend_Controller_Router_Rewrite) – The router
- addRedirectRouteForDefaultRoute(String $routeName, String $uri, array $params = Array, Zend_Controller_Router_Rewrite $router)¶
Adds a redirect route for the default route and returns whether the route was successfully added If the current request matches the default route, then the flow will redirect to the index action of the RedirectorController, where the page will be redirected to the absolute uri We must use this Redirector proxy controller because a user may be redirecting to an admin page and it needs to reload the application from the admin context. Also, the Zend router and dispatcher does not allow us to directly dispatch to an absolute uri.
Parameters: - $routeName (String) – The name of the new redirect route
- $uri (String) – The absolute uri to redirect to the default route to
- $params (array) – The parameters for the redirect route.
- $router (Zend_Controller_Router_Rewrite) – The router
Returns: boolean Returns true if the route was successfully added, else false.
- _leftTrim(string $s, string $n)¶
Left trims the first occurrence of a string within a string. Note: it will only trim the first occurrence of the string.
Parameters: - $s (string) – The base string
- $n (string) – The string to remove from the left side of the base string
Returns: string
Omeka_Application_Resource_Session¶
- class Omeka_Application_Resource_Session¶
Package: Application\Resource
Initialize the session.
Customizes the session name to prevent session overlap between differentapplications that operate on the same server.
- init()¶
- _getSessionConfig()¶
Retrieve global session configuration options.
Returns: array An array containing all the global configuration options for sessions. This array contains at least one key, ‘name’, corresponding to the name of the session, which is generated automatically if not provided.
- _buildSessionName()¶
Create a unique session name.
Hashes the base directory, this ensures that session names differ betweenOmeka instances on the same server.
Returns: string
- _setOptionsFromConfig()¶
Omeka_Application_Resource_Storage¶
- class Omeka_Application_Resource_Storage¶
Package: Application\Resource
Bootstrap resource for configuring the file storage layer.
- init()¶
Omeka_Application_Resource_Theme¶
- class Omeka_Application_Resource_Theme¶
Package: Application\Resource
Set up the controller plugin that determines theme view script paths.
- property _basePath¶
Theme base path. Set by application config.
- property _webBasePath¶
Theme base URI.
Set by application config.
- init()¶
Libraries/Omeka/Application/Resource/Jobs¶
- class Omeka_Application_Resource_Jobs_InvalidAdapterException¶
Package: Application\Resource
Exception thrown when an invalid job dispatcher has been configured.
- property message¶
- property code¶
- property file¶
- property line¶
- __clone()¶
- __construct($message, $code, $previous)¶
Parameters: - $message (unknown) –
- $code (unknown) –
- $previous (unknown) –
- getMessage()¶
- getCode()¶
- getFile()¶
- getLine()¶
- getTrace()¶
- getPrevious()¶
- getTraceAsString()¶
- __toString()¶
Libraries/Omeka/Auth¶
Libraries/Omeka/Auth/Adapter¶
Omeka_Auth_Adapter_UserTable¶
- class Omeka_Auth_Adapter_UserTable¶
Package: Auth
Auth adapter that uses Omeka’s users table for authentication.
- _authenticateValidateResult(array $resultIdentity)¶
Validate the identity returned from the database.
Overrides the Zend implementation to provide user IDs, not usernamesupon successful validation.
Parameters: - $resultIdentity (array) –
Libraries/Omeka/Controller¶
Omeka_Controller_AbstractActionController¶
- class Omeka_Controller_AbstractActionController¶
Package: Controller
Base class for Omeka controllers.
Provides basic create, read, update, and delete (CRUD) operations.
- property _browseRecordsPerPage¶
The number of records to browse per page.
If this is left null, then results will not paginate. This is partiallybecause not every controller will want to paginate records and also toavoid BC breaks for plugins.
- __construct(Zend_Controller_Request_Abstract $request, Zend_Controller_Response_Abstract $response, array $invokeArgs = Array)¶
Base controller constructor.
Does the following things:
- Aliases the redirector helper to clean up the syntax
- Sets the table object automatically if given the class of the model to use for CRUD.
- Sets all the built-in action contexts for the CRUD actions.
Instead of overriding this constructor, controller subclasses shouldimplement the init() method for initial setup.
Parameters: - $request (Zend_Controller_Request_Abstract) – Current request object.
- $response (Zend_Controller_Response_Abstract) – Response object.
- $invokeArgs (array) – Arguments passed to Zend_Controller_Action.
- indexAction()¶
Forward to the ‘browse’ action
- browseAction()¶
Retrieve and render a set of records for the controller’s model.
Using this action requires some setup:
- In your controller’s init(), set the default model name: $this->_helper->db->setDefaultModelName('YourRecord');
- In your controller, set the records per page and return them using: protected function _getBrowseRecordsPerPage();
- In your table record, filter the select object using the provided parameters using: public function applySearchFilters($select, $params);
- showAction()¶
Retrieve a single record and render it.
Every request to this action must pass a record ID in the ‘id’ parameter.
- addAction()¶
Add an instance of a record to the database.
This behaves differently based on the contents of the $_POST superglobal.If the $_POST is empty or invalid, it will render the form used for dataentry. Otherwise, if the $_POST exists and is valid, it will save the newrecord and redirect to the ‘browse’ action.
- editAction()¶
Similar to ‘add’ action, except this requires a pre-existing record.
Every request to this action must pass a record ID in the ‘id’ parameter.
- deleteConfirmAction()¶
Ask for user confirmation before deleting a record.
- deleteAction()¶
Delete a record from the database.
Every request to this action must pass a record ID in the ‘id’ parameter.
- getCurrentUser()¶
Return the record for the current user.
Returns: User|bool User object if a user is logged in, false otherwise.
- _getBrowseRecordsPerPage()¶
Return the number of records to display per page.
By default this will return null, disabling pagination. This can beoverridden in subclasses by redefining this method.
Returns: integer|null
- _getAddSuccessMessage(Omeka_Record_AbstractRecord $record)¶
Return the success message for adding a record.
Default is empty string. Subclasses should override it.
Parameters: - $record (Omeka_Record_AbstractRecord) –
Returns: string
- _getEditSuccessMessage(Omeka_Record_AbstractRecord $record)¶
Return the success message for editing a record.
Default is empty string. Subclasses should override it.
Parameters: - $record (Omeka_Record_AbstractRecord) –
Returns: string
- _getDeleteSuccessMessage(Omeka_Record_AbstractRecord $record)¶
Return the success message for deleting a record.
Default is empty string. Subclasses should override it.
Parameters: - $record (Omeka_Record_AbstractRecord) –
Returns: string
- _getDeleteConfirmMessage(Omeka_Record_AbstractRecord $record)¶
Return the delete confirm message for deleting a record.
Parameters: - $record (Omeka_Record_AbstractRecord) –
Returns: string
- _redirectAfterAdd(Omeka_Record_AbstractRecord $record)¶
Redirect to another page after a record is successfully added.
The default is to reidrect to this controller’s browse page.
Parameters: - $record (Omeka_Record_AbstractRecord) –
- _redirectAfterEdit(Omeka_Record_AbstractRecord $record)¶
Redirect to another page after a record is successfully edited.
The default is to redirect to this record’s show page.
Parameters: - $record (Omeka_Record_AbstractRecord) –
- _redirectAfterDelete(Omeka_Record_AbstractRecord $record)¶
Redirect to another page after a record is successfully deleted.
The default is to redirect to this controller’s browse page.
Parameters: - $record (Omeka_Record_AbstractRecord) –
- _setActionContexts()¶
Augment Zend’s default action contexts.
Passes Omeka’s default additional contexts through the ‘action_contexts’ filter to allow plugins to add contexts.
- _getDeleteForm()¶
Get the form used for confirming deletions.
Returns: Zend_Form
Libraries/Omeka/Controller/Exception¶
Omeka_Controller_Exception_403¶
- class Omeka_Controller_Exception_403¶
Package: Controller
If thrown by a controller, this exception will be caught within the ErrorController, which will then render a 403 Forbidden page.
- property message¶
- property string¶
- property code¶
- property file¶
- property line¶
- property trace¶
- property previous¶
- __clone()¶
- __construct($message, $code, $previous)¶
Parameters: - $message (unknown) –
- $code (unknown) –
- $previous (unknown) –
- getMessage()¶
- getCode()¶
- getFile()¶
- getLine()¶
- getTrace()¶
- getPrevious()¶
- getTraceAsString()¶
- __toString()¶
Omeka_Controller_Exception_404¶
- class Omeka_Controller_Exception_404¶
Package: Controller
If thrown within a controller, this will be caught in the ErrorController, which will render a 404 Not Found page.
- property message¶
- property string¶
- property code¶
- property file¶
- property line¶
- property trace¶
- property previous¶
- __clone()¶
- __construct($message, $code, $previous)¶
Parameters: - $message (unknown) –
- $code (unknown) –
- $previous (unknown) –
- getMessage()¶
- getCode()¶
- getFile()¶
- getLine()¶
- getTrace()¶
- getPrevious()¶
- getTraceAsString()¶
- __toString()¶
Libraries/Omeka/Controller/Plugin¶
Omeka_Controller_Plugin_Admin¶
- class Omeka_Controller_Plugin_Admin¶
Package: Controller\Plugin
This controller plugin allows for all functionality that is specific to the Admin theme.
For now, all this includes is preventing unauthenticated access to all adminpages, with the exception of a few white-listed URLs, which are stored inthis plugin.
This controller plugin should be loaded only in the admin bootstrap.
- property _adminWhitelist¶
Controller/Action list for admin actions that do not require being logged-in
- routeStartup(Zend_Controller_Request_Abstract $request)¶
Direct requests to the admin interface. Called upon router startup, before the request is routed.
Parameters: - $request (Zend_Controller_Request_Abstract) –
Returns: void
- preDispatch(Zend_Controller_Request_Abstract $request)¶
Require login when attempting to access the admin interface. Whitelisted controller/action combinations are exempt from this requirement. Called before dispatching.
Parameters: - $request (Zend_Controller_Request_Abstract) –
Returns: void
- getRedirector()¶
Return the redirector action helper.
Returns: Zend_Controller_Action_Helper_Redirector
- getAuth()¶
Return the auth object.
Returns: Zend_Auth
- _requireLogin($request)¶
Determine whether or not the request requires an authenticated user.
Parameters: - $request (unknown) –
Returns: boolean
Omeka_Controller_Plugin_Debug¶
- class Omeka_Controller_Plugin_Debug¶
Package: Controller\Plugin
This controller plugin allows for debugging Request objects without inserting debugging code into the Zend Framework code files.
Debugging web requests is enabled by setting ‘debug.request = true’ in theconfig.ini file.
- property _requestMarkup¶
- preDispatch(Zend_Controller_Request_Abstract $request)¶
Print request debugging info for every request.
Has no effect if request debugging is not enabled in config.ini.
Parameters: - $request (Zend_Controller_Request_Abstract) – Request object.
Returns: void
- postDispatch(Zend_Controller_Request_Abstract $request)¶
Parameters: - $request (Zend_Controller_Request_Abstract) –
- dispatchLoopShutdown()¶
Print database profiling info.
Enabled conditionally when debug.profileDb = true in config.ini.
Returns: void
- _getProfilerMarkup(Zend_Db_Profiler $profiler)¶
Parameters: - $profiler (Zend_Db_Profiler) –
- _getRequestMarkup(Zend_Controller_Request_Abstract $request, Zend_Controller_Router_Interface $router)¶
Create HTML markup for request debugging.
Parameters: - $request (Zend_Controller_Request_Abstract) – Request object.
- $router (Zend_Controller_Router_Interface) – Router object.
Returns: string HTML markup.
Omeka_Controller_Plugin_HtmlPurifier¶
- class Omeka_Controller_Plugin_HtmlPurifier¶
Package: Controller\Plugin
This ZF controller plugin allows the HtmlPurifier to filter the existing forms (items, collections, users, etc.) so that fields that are allowed to contain HTML are properly filtered.
Note that this will not operate on any of the plugins.
- routeStartup(Zend_Controller_Request_Abstract $request)¶
Add the HtmlPurifier options if needed.
Parameters: - $request (Zend_Controller_Request_Abstract) –
Returns: void
- preDispatch(Zend_Controller_Request_Abstract $request)¶
Determine whether or not to filter form submissions for various controllers.
Parameters: - $request (Zend_Controller_Request_Abstract) –
Returns: void
- isFormSubmission(Zend_Controller_Request_Abstract $request)¶
Determine whether or not the request contains a form submission to either the ‘add’, ‘edit’, or ‘config’ actions.
Parameters: - $request (Zend_Controller_Request_Abstract) –
Returns: boolean
- filterCollectionsForm(Zend_Controller_Request_Abstract $request, Omeka_Filter_HtmlPurifier $htmlPurifierFilter)¶
Filter the Collections form post, including the ‘Elements’ array of the POST.
Parameters: - $request (Zend_Controller_Request_Abstract) –
- $htmlPurifierFilter (Omeka_Filter_HtmlPurifier) –
Returns: void
- filterThemesForm(Zend_Controller_Request_Abstract $request, Omeka_Filter_HtmlPurifier $htmlPurifierFilter)¶
Purify all of the data in the theme settings
Parameters: - $request (Zend_Controller_Request_Abstract) –
- $htmlPurifierFilter (Omeka_Filter_HtmlPurifier) –
Returns: void
- _purifyArray($dataArray = Array, Omeka_Filter_HtmlPurifier $htmlPurifierFilter)¶
Recurisvely purify an array
Parameters: - $dataArray (unknown) –
- $htmlPurifierFilter (Omeka_Filter_HtmlPurifier) –
Returns: array A purified array of string or array values
- filterItemsForm(Zend_Controller_Request_Abstract $request, Omeka_Filter_HtmlPurifier $htmlPurifierFilter)¶
Filter the Items form post, including the ‘Elements’ array of the POST.
Parameters: - $request (Zend_Controller_Request_Abstract) –
- $htmlPurifierFilter (Omeka_Filter_HtmlPurifier) –
Returns: void
- _filterElementsFromPost(Zend_Controller_Request_Abstract $post, Omeka_Filter_HtmlPurifier $htmlPurifierFilter)¶
Filter the ‘Elements’ array of the POST.
Parameters: - $post (Zend_Controller_Request_Abstract) –
- $htmlPurifierFilter (Omeka_Filter_HtmlPurifier) –
Returns: void
- _setupHtmlPurifierOptions()¶
Omeka_Controller_Plugin_Jsonp¶
- class Omeka_Controller_Plugin_Jsonp¶
Package: Controller\Plugin
Sets the Content-Type header for all JSON-P requests.
- constant CALLBACK_KEY¶
Callback parameter key.
- postDispatch(Zend_Controller_Request_Abstract $request)¶
Set the ‘Content-Type’ HTTP header to ‘application/x-javascript’ for omeka-json requests.
Parameters: - $request (Zend_Controller_Request_Abstract) – Request object.
Returns: void
Omeka_Controller_Plugin_Ssl¶
- class Omeka_Controller_Plugin_Ssl¶
Package: Controller\Plugin
Handle SSL configuration for Omeka sites.
- property _sslConfig¶
- property _redirector¶
- property _auth¶
- __construct($sslConfig, $redirector, Zend_Auth $auth)¶
Parameters: - $sslConfig (unknown) –
- $redirector (unknown) –
- $auth (Zend_Auth) –
- routeStartup(Zend_Controller_Request_Abstract $request)¶
Parameters: - $request (Zend_Controller_Request_Abstract) –
- preDispatch(Zend_Controller_Request_Abstract $request)¶
Parameters: - $request (Zend_Controller_Request_Abstract) –
- _isLoginRequest($request)¶
Parameters: - $request (unknown) –
- _secureAuthenticatedSession()¶
Unauthenticated sessions are not as valuable to attackers, so we only really need to check if an authenticated session is being used.
- _isSslRequest($request)¶
Parameters: - $request (unknown) –
- _redirect($request)¶
Parameters: - $request (unknown) –
- _secureAllRequests()¶
Omeka_Controller_Plugin_Upgrade¶
- class Omeka_Controller_Plugin_Upgrade¶
Package: Controller\Plugin
Overrides Omeka’s normal routing when the database needs to be upgraded.
- dispatchLoopStartup(Zend_Controller_Request_Abstract $request)¶
Set up routing for the upgrade controller.
Only allows authorized users to upgrade, and blocks the public site when an upgrade is needed.
Parameters: - $request (Zend_Controller_Request_Abstract) – Request object.
Returns: void
- _dbNeedsUpgrade()¶
- _dbCanUpgrade()¶
- _upgrade(Zend_Controller_Request_Abstract $request)¶
Redirect to the upgrade controller.
Parameters: - $request (Zend_Controller_Request_Abstract) – Request object (not used).
Returns: void
Omeka_Controller_Plugin_ViewScripts¶
- class Omeka_Controller_Plugin_ViewScripts¶
Package: Controller\Plugin
Sets up view script search paths on a per-request basis.
- property _view¶
Registered view object.
- property _dbOptions¶
List of options from the database.
- property _baseThemePath¶
Base path to themes directory.
- property _webBaseThemePath¶
Base web-accesible path to themes.
- property _pluginMvc¶
MVC plugin behaviors class.
- __construct(array $options, Omeka_Plugin_Mvc $pluginMvc)¶
Parameters: - $options (array) – List of options.
- $pluginMvc (Omeka_Plugin_Mvc) – Plugin MVC class.
- preDispatch(Zend_Controller_Request_Abstract $request)¶
Add the appropriate view scripts directories for a given request. This is pretty much the glue between the plugin broker and the View object, since it uses data from the plugin broker to determine what script paths will be available to the view.
Parameters: - $request (Zend_Controller_Request_Abstract) – Request object.
Returns: void
- _setupPathsForPlugin(string $pluginModuleName, string $themeType)¶
Set up the asset paths for a plugin.
If you’re in a plugin, check in this order: 1. plugin view scripts (only for that plugin) 2. plugin view scripts for other plugins 3. theme view scripts
This means that it needs to add the paths in the reverse order of what needsto be checked first, so theme paths first and then plugin paths.
Parameters: - $pluginModuleName (string) – The module name for the plugin.
- $themeType (string) – The type of theme: ‘admin’ or ‘public’.
Returns: void
- _setupPathsForTheme(string $themeType)¶
Set up the asset paths for the theme.
If you’re in one of the themes, check in this order:1. theme view scripts2. all plugin view scripts
Parameters: - $themeType (string) – The type of theme: ‘admin’ or ‘public’.
Returns: void
- _addPluginPaths(string $themeType, string $pluginModuleName)¶
Add asset paths for a plugin.
Parameters: - $themeType (string) – The type of theme: ‘admin’ or ‘public’.
- $pluginModuleName (string) – The module name for the plugin.
Returns: void
- _addPathToView(string $scriptPath)¶
Add a new script path for a plugin to the view.
Parameters: - $scriptPath (string) – Path from plugins dir to script dir.
Returns: void
- _getView()¶
Gets the view from the registry.
The initial call to the registry caches the view in this class.
Returns: Zend_View
Add the global views from the view scripts directory to the view.
Returns: void
- _addThemePaths(string $theme)¶
Add script and asset paths for a theme to the view.
Parameters: - $theme (string) – Theme type; either ‘public’ or ‘admin’.
Returns: void
- _addOverridePathForPlugin(string $theme, string $pluginModuleName)¶
Add theme view path for override views for a given plugin.
Parameters: - $theme (string) – Theme type; ‘public’ or ‘admin’
- $pluginModuleName (string) –
- getThemeOption(string $type)¶
Retrieve the option from the database that contains the directory of the theme to render.
Parameters: - $type (string) – Currently either ‘admin’ or ‘public’.
Returns: string
Libraries/Omeka/Db¶
Omeka_Db_Select¶
- class Omeka_Db_Select¶
Package: Db
Class for SQL SELECT generation and results.
- __construct(Zend_Db_Adapter $adapter)¶
Parameters: - $adapter (Zend_Db_Adapter) – (optional) Adapter to use instead of the one set up by Omeka.
- hasJoin(string $name)¶
Detect if this SELECT joins with the given table.
Parameters: - $name (string) – Table name.
Returns: boolean
Omeka_Db_Table¶
- class Omeka_Db_Table¶
Package: Db\Table
Database table classes.
Subclasses attached to models must follow the naming convention:Table_TableName, e.g. Table_ElementSet in models/Table/ElementSet.php.
- property _target¶
The name of the model for which this table will retrieve objects.
- property _name¶
The name of the table (sans prefix).
If this is not given, it will be inflected.
- property _tablePrefix¶
The table prefix.
Generally used to differentiate Omeka installations sharing a database.
- property _db¶
The Omeka database object.
- __construct(string $targetModel, Omeka_Db $db)¶
Construct the database table object.
Do not instantiate this by itself. Access instances only viaOmeka_Db::getTable().
Parameters: - $targetModel (string) – Class name of the table’s model.
- $db (Omeka_Db) – Database object to use for queries.
- __call(string $m, array $a)¶
Delegate to the database adapter.
Used primarily as a convenience method. For example, you can callfetchOne() and fetchAll() directly from this object.
Parameters: - $m (string) – Method name.
- $a (array) – Method arguments.
Returns: mixed
- getTableAlias()¶
Retrieve the alias for this table (the name without the prefix).
Returns: string
- getDb()¶
Retrieve the Omeka_Db instance.
Returns: Omeka_Db
- hasColumn(string $field)¶
Determine whether a model has a given column.
Parameters: - $field (string) – Field name.
Returns: bool
- getColumns()¶
Retrieve a list of all the columns for a given model.
This should be here and not in the model class because get_class_vars()returns private/protected properties when called from within the class.Will only return public properties when called in this fashion.
Returns: array
- getTableName()¶
Retrieve the name of the table for the current table (used in SQL statements).
If the table name has not been set, it will inflect the table name.
Returns: string
- setTableName(string $name)¶
Set the name of the database table accessed by this class.
If no name is provided, it will inflect the table name from the name ofthe model defined in the constructor. For example, Item -> items.
Parameters: - $name (string) – (optional) Table name.
Returns: void
- getTablePrefix()¶
Retrieve the table prefix for this table instance.
Returns: string
- setTablePrefix(string|null $tablePrefix)¶
Set the table prefix.
Defaults to the table prefix defined by the Omeka_Db instance. Thisshould remain the default in most cases. However, edge cases may requirecustomization, e.g. creating wrappers for tables generated by otherapplications.
Parameters: - $tablePrefix (string|null) –
- find(integer $id)¶
Retrieve a single record given an ID.
Parameters: - $id (integer) –
Returns: Omeka_Record_AbstractRecord|false
- findAll()¶
Get a set of objects corresponding to all the rows in the table
WARNING: This will be memory intensive and is thus not recommended forlarge data sets.
Returns: array Array of {@link Omeka_Record_AbstractRecord}s.
- findPairsForSelectForm(array $options = Array)¶
Retrieve an array of key=>value pairs that can be used as options in a <select> form input.
Parameters: - $options (array) – (optional) Set of parameters for searching/ filtering results.
Returns: array
- _getColumnPairs()¶
Retrieve the array of columns that are used by findPairsForSelectForm().
This is a template method because these columns are different for everytable, but the underlying logic that retrieves the pairs from thedatabase is the same in every instance.
Returns: array
- findBy(array $params = Array, integer $limit, integer $page)¶
Retrieve a set of model objects based on a given number of parameters
Parameters: - $params (array) – A set of parameters by which to filter the objects that get returned from the database.
- $limit (integer) – Number of objects to return per “page”.
- $page (integer) – Page to retrieve.
Returns: array|null The set of objects that is returned
- getSelect()¶
Retrieve a select object for this table.
Returns: Omeka_Db_Select
- getSelectForFindBy(array $params = Array)¶
Retrieve a select object that has had search filters applied to it.
Parameters: - $params (array) – optional Set of named search parameters.
Returns: Omeka_Db_Select
- getSelectForFind(integer $recordId)¶
Retrieve a select object that is used for retrieving a single record from the database.
Parameters: - $recordId (integer) –
Returns: Omeka_Db_Select
- applySearchFilters(Omeka_Db_Select $select, array $params)¶
Apply a set of filters to a Select object based on the parameters given.
By default, this simply checks the params for keys corresponding to databasecolumn names. For more complex filtering (e.g., when other tables are involved),or to use keys other than column names, override this method and optionallycall this parent method.
Parameters: - $select (Omeka_Db_Select) –
- $params (array) –
- applySorting(Omeka_Db_Select $select, string $sortField, string $sortDir)¶
Apply default column-based sorting for a table.
Parameters: - $select (Omeka_Db_Select) –
- $sortField (string) – Field to sort on.
- $sortDir (string) – Direction to sort.
- applyPagination(Zend_Db_Select $select, integer $limit, integer|null $page)¶
Apply pagination to a select object via the LIMIT and OFFSET clauses.
Parameters: - $select (Zend_Db_Select) –
- $limit (integer) – Number of results per “page”.
- $page (integer|null) – Page to retrieve, first if omitted.
Returns: Zend_Db_Select
- findBySql(string $sqlWhereClause, array $params = Array, boolean $findOne =)¶
Retrieve an object or set of objects based on an SQL WHERE predicate.
Parameters: - $sqlWhereClause (string) –
- $params (array) – optional Set of parameters to bind to the WHERE clause. Used to prevent security flaws.
- $findOne (boolean) – optional Whether or not to retrieve a single record or the whole set (retrieve all by default).
Returns: array|Omeka_Record_AbstractRecord|false
- count(array $params = Array)¶
Retrieve a count of all the rows in the table.
Parameters: - $params (array) – optional Set of search filters upon which to base the count.
Returns: integer
- getSelectForCount(array $params = Array)¶
Retrieve a select object used to retrieve a count of all the table rows.
Parameters: - $params (array) – optional Set of search filters.
Returns: Omeka_Db_Select
- checkExists(int $id)¶
Check whether a given row exists in the database.
Currently used to verify that a row exists even though the current usermay not have permissions to access it.
Parameters: - $id (int) – The ID of the row.
Returns: boolean
- fetchObjects(string $sql, array $params = Array)¶
Retrieve a set of record objects based on an SQL SELECT statement.
Parameters: - $sql (string) – This could be either a string or any object that can be cast to a string (commonly Omeka_Db_Select).
- $params (array) – Set of parameters to bind to the SQL statement.
Returns: array|null Set of Omeka_Record_AbstractRecord instances, or null if none can be found.
- fetchObject(string $sql, string $params = Array)¶
Retrieve a single record object from the database.
Parameters: - $sql (string) –
- $params (string) – Parameters to substitute into SQL query.
Returns: Omeka_Record_AbstractRecord or null if no record
- recordFromData(array $data)¶
Populate a record object with data retrieved from the database.
Parameters: - $data (array) – A keyed array representing a row from the database.
Returns: Omeka_Record_AbstractRecord
- _getSortParams(array $params)¶
Get and parse sorting parameters to pass to applySorting.
A sorting direction of ‘ASC’ will be used if no direction parameter ispassed.
Parameters: - $params (array) –
Returns: array|null Array of sort field, sort dir if params exist, null otherwise.
- _getHookName(string $suffix)¶
Get the name for a model-specific hook or filter..
Parameters: - $suffix (string) – The hook-specific part of the hook name.
Returns: string
Libraries/Omeka/Db/Migration¶
Omeka_Db_Migration_AbstractMigration¶
- class Omeka_Db_Migration_AbstractMigration¶
Package: Db\Migration
Database migration classes may inherit from this one.
- property db¶
- getDb()¶
Returns: Omeka_Db
- down()¶
Template method for reversing the migration.
This is defined as a template method instead of leaving it abstract becausepre-existing implementations of Omeka_Db_Migration were not required toimplement the down() method. This ensures backwards compatibility forthose migrations.
- __call(string $m, array $a)¶
Proxy calls to Omeka_Db.
Allows migration writers to call db methods directly on $this.
Parameters: - $m (string) – Method name.
- $a (array) – Method arguments.
- form()¶
If the migration requires a form submission, here’s where to handle display of it
Returns: void
- up()¶
Omeka_Db_Migration_Exception¶
- class Omeka_Db_Migration_Exception¶
Package: Db\Migration
Indicates an error during the database migration process.
- property message¶
- property string¶
- property code¶
- property file¶
- property line¶
- property trace¶
- property previous¶
- __clone()¶
- __construct($message, $code, $previous)¶
Parameters: - $message (unknown) –
- $code (unknown) –
- $previous (unknown) –
- getMessage()¶
- getCode()¶
- getFile()¶
- getLine()¶
- getTrace()¶
- getPrevious()¶
- getTraceAsString()¶
- __toString()¶
Omeka_Db_Migration_Manager¶
- class Omeka_Db_Migration_Manager¶
Package: Db\Migration
Manages database migrations (both upgrades and downgrades).
- constant MIGRATION_TABLE_NAME¶
Name of the migrations table.
- constant MIGRATION_DATE_FORMAT¶
Formatting string to convert dates into YYYYMMDDHHMMSS pattern.
- constant ORIG_MIGRATION_OPTION_NAME¶
Name of the original database option storing the integer migration number.
- constant VERSION_OPTION_NAME¶
Name of the new database option storing the core software version number.
- property _db¶
- property _migrationsDir¶
Directory where migrations scripts are kept.
- __construct(Omeka_Db $db, string $migrationsDir)¶
Parameters: - $db (Omeka_Db) –
- $migrationsDir (string) –
- setupTimestampMigrations()¶
Set up Omeka to use timestamped database migrations.
This creates the ‘schema_migrations’ table, drops the ‘migration’ optionand adds the ‘omeka_version’ option to the database.
Returns: void
- markAllAsMigrated()¶
Mark all of the migrations as having been run. Used by the installer as a way of indicating that the database is entirely up to date.
Returns: void
- migrate(string $endTimestamp)¶
Migrate the database schema.
Parameters: - $endTimestamp (string) – (optional) Timestamp corresponding to the stop point for the migration. If older than the current time, database will migrate down to that point. If newer, the opposite. Defaults to the current timestamp.
Returns: void
- canUpgrade()¶
Determine whether or not it is possible to migrate the Omeka database up.
This is based entirely on whether there exist any migrations that havenot yet been applied.
Returns: void
- dbNeedsUpgrade()¶
Determine whether the database must be upgraded.
In order to return true, this requires that canUprade() == true, and also that Omeka’s code has recently been upgraded.
- finalizeDbUpgrade()¶
Finalize the database upgrade by setting the most up-to-date version of Omeka.
- getDefault(Omeka_Db|null $db)¶
Return the default configuration of the database migration manager.
Parameters: - $db (Omeka_Db|null) –
Returns: Omeka_Db_Migration_Manager
- _getAllMigratedVersions()¶
Retrieve all the versions that have been migrated.
Returns: array
- _getMigrationTableName()¶
Return the name of the table associated with schema migrations.
Returns: string
- _getMigrationFileList()¶
Return a list of migration files in the migration directory.
Returns: array An associative array where key = timestamp of migration, value = full filename of the migration.
- _migrateUp(DateTime $stopAt)¶
Migrate upwards to a specific timestamp.
Parameters: - $stopAt (DateTime) –
Returns: void
- _loadMigration(string $filename)¶
Require the migration file and return an instance of the class associated with it.
Parameters: - $filename (string) – Migration script filename.
Returns: Omeka_Db_Migration_AbstractMigration
- _getPendingMigrations(DateTime $until)¶
Retrieve a list of all migrations that have not been run yet, ending at the latest time given by $until.
Parameters: - $until (DateTime) –
Returns: array
- _recordMigration(string $time)¶
Record the migration timestamp in the schema_migrations table.
Parameters: - $time (string) –
Returns: void
Libraries/Omeka/Db/Select¶
Omeka_Db_Select_PublicPermissions¶
- class Omeka_Db_Select_PublicPermissions¶
Package: Db
Encapsulates the permissions check for a record that can be public or private.
- property _allPermission¶
- property _selfPermission¶
- __construct(string $resource)¶
Create the permissions object and perform the ACL checks.
The permissions check relies on ‘showNotPublic’ and (optionally)’showSelfNotPublic’ privileges on the give resource.
Parameters: - $resource (string) – ACL resource name to check.
- apply(Omeka_Db_Select $select, string $alias, string $ownerColumn = owner_id)¶
Apply the permissions to an SQL select object.
Parameters: - $select (Omeka_Db_Select) –
- $alias (string) – Table alias to query against
- $ownerColumn (string) – Optional column for checking for ownership. If falsy, the ownership check is skipped.
Libraries/Omeka/File¶
Libraries/Omeka/File/Derivative¶
Omeka_File_Derivative_Exception¶
- class Omeka_File_Derivative_Exception¶
Package: File\Derivative
Exception to throw when something goes wrong in the process of creating derivative images.
- property message¶
- property string¶
- property code¶
- property file¶
- property line¶
- property trace¶
- property previous¶
- __clone()¶
- __construct($message, $code, $previous)¶
Parameters: - $message (unknown) –
- $code (unknown) –
- $previous (unknown) –
- getMessage()¶
- getCode()¶
- getFile()¶
- getLine()¶
- getTrace()¶
- getPrevious()¶
- getTraceAsString()¶
- __toString()¶
Libraries/Omeka/File/Derivative/Image¶
- class Omeka_File_Derivative_Image_Creator¶
Package: File\Derivative
Create derivative images for a file in Omeka.
- property _convertPath¶
- property _identifyPath¶
- property _derivatives¶
- __construct($imDirPath)¶
Parameters: - $imDirPath (unknown) –
- setImageMagickDirPath(string $imDirPath)¶
Set the path to the ImageMagick executable.
Parameters: - $imDirPath (string) – Path to the directory containing the ImageMagick binaries.
- getConvertPath()¶
Get the full path to the ImageMagick ‘convert’ command.
Returns: string
- getIdentifyPath()¶
Get the full path to the ImageMagick ‘identify’ command.
Returns: string
- create(string $fromFilePath, string $derivFilename, string $mimeType)¶
Create all the derivatives requested with addDerivative().
Parameters: - $fromFilePath (string) –
- $derivFilename (string) –
- $mimeType (string) –
Returns: boolean
- addDerivative(string $storageType, integer|string $size, boolean $square =)¶
Add a derivative image to be created.
Parameters: - $storageType (string) –
- $size (integer|string) – If an integer, it is the size constraint for the image, meaning it will have that maximum width or height, depending on whether the image is landscape or portrait. Otherwise, it is a string of arguments to be passed to the ImageMagick convert utility. MUST BE PROPERLY ESCAPED AS SHELL ARGUMENTS.
- $square (boolean) – Whether the derivative to add should be made square.
- _createImage($origPath, $newPath, $convertArgs)¶
Generate a derivative image from an existing file stored in Omeka.
This image will be generated based on a constraint given in pixels. Forexample, if the constraint is 500, the resulting image file will be scaledso that the largest side is 500px. If the image is less than 500px on bothsides, the image will not be resized.
Derivative images will only be generated for files with mime typesthat can be identified with ImageMagick’s ‘identify’ command
Parameters: - $origPath (unknown) –
- $newPath (unknown) –
- $convertArgs (unknown) –
- _getResizeCmdArgs(integer $constraint, boolean $square)¶
Get the ImageMagick command line for resizing to the given constraints.
Parameters: - $constraint (integer) – Maximum side length in pixels.
- $square (boolean) – Whether the derivative should be squared off.
Returns: string
- _isDerivable(string $filePath)¶
Returns true only if ImageMagick is able to make derivative images of that file based upon whether or not it can be identified by ImageMagick’s ‘identify’ binary. Otherwise returns false.
Parameters: - $filePath (string) –
Returns: boolean
- _isIdentifiable(string $filePath)¶
Returns true only if the file can be identified by ImageMagick’s ‘identify’ binary
Parameters: - $filePath (string) –
Returns: boolean
- isValidImageMagickPath($dirToIm)¶
Determine whether or not the path given to ImageMagick is valid. Both the convert and identify binaries must be within the directory and executable.
Parameters: - $dirToIm (unknown) –
Returns: boolean
- getDefaultImageMagickDir()¶
Retrieve the path to the directory containing ImageMagick’s convert utility. Th
Uses the ‘which’ command-line utility to detect the path to ‘convert’.Note that this will only work if the convert utility is in PHP’s PATH andthus can be located by ‘which’.
Returns: string The path to the directory if it can be found. Otherwise returns an empty string.
- executeCommand($cmd, $status, $output, $errors)¶
Parameters: - $cmd (unknown) –
- $status (unknown) –
- $output (unknown) –
- $errors (unknown) –
Libraries/Omeka/File/Ingest¶
Omeka_File_Ingest_AbstractIngest¶
- class Omeka_File_Ingest_AbstractIngest¶
Package: File\Ingest
An abstract class that handles ingesting files into Omeka and database.
Specific responsibilities handled by this class:
- Parsing/validating arbitrary inputs that somehow identify the files to be ingested.
- Iterating through the parsed file information, validating, and transferring each file to Omeka.
- Inserting a new record into the files table that corresponds to thetransferred file’s metadata.
- Returning a collection of the records associated with the ingestedfiles.
Typical usage is via the factory() method:
$ingest = Omeka_File_Ingest_AbstractIngest::factory('Url', $item); $fileRecords = $ingest->ingest('http://www.example.com');
- property _item¶
- property _options¶
Set of arbitrary options to use when ingesting files.
- property _validators¶
Set of validators implementing Zend_Validate_Interface.
- property mimeType¶
The current validated file MIME type.
- setItem(Item $item)¶
Set the item to use as a target when ingesting files.
Parameters: - $item (Item) –
Returns: void
- factory(string $adapterName, Item $item, array $options = Array)¶
Factory to retrieve Omeka_File_Ingest_* instances.
Parameters: - $adapterName (string) – Ingest adapter.
- $item (Item) –
- $options (array) –
Returns: Omeka_File_Ingest_AbstractIngest
- _getOriginalFilename(array $fileInfo)¶
Retrieve the original filename of the file.
Parameters: - $fileInfo (array) –
Returns: string
- _transferFile(array $fileInfo, string $originalFilename)¶
Transfer the file to Omeka.
To indicate validation errors, Omeka_File_Ingest_InvalidException can bethrown at any time. To indicate other types of non-recoverable errorsrelated to file ingest, throw Omeka_File_Ingest_Exception.
Parameters: - $fileInfo (array) –
- $originalFilename (string) –
Returns: string Real path to the transferred file.
- _parseFileInfo(mixed $files)¶
Ingest classes receive arbitrary information. This method needs to parse that information into an iterable array so that multiple files can be ingested from a single identifier.
Example use case is Omeka_File_Ingest_Upload.
Parameters: - $files (mixed) –
Returns: array
- setOptions(array $options)¶
Set options for ingesting files.
Parameters: - $options (array) – Available options include: - ‘ignore_invalid_files’: boolean false by default. Determine whether or not to throw exceptions when a file is not valid. This can be based on a number of factors: whether or not the original identifier is valid (i.e. a valid URL), whether or not the file itself is valid (i.e. invalid file extension), or whether the basic algorithm for ingesting the file fails (i.e., files cannot be transferred because the files/ directory is not writeable). This option is primarily useful for skipping known invalid files when ingesting large data sets.
Returns: void
- ingest(mixed $fileInfo)¶
Ingest based on arbitrary file identifier info.
If this is an array that has a ‘metadata’ key, that should be an arrayrepresenting element text metadata to assign to the file. SeeActsAsElementText::addElementTextsByArray() for more details.
Parameters: - $fileInfo (mixed) – An arbitrary input (array, string, object, etc.) that corresponds to one or more files to be ingested into Omeka.
Returns: array Ingested file records.
- _ignoreIngestErrors()¶
Determine whether or not to ignore file ingest errors. Based on ‘ignore_invalid_files’, which is false by default.
Returns: boolean
- _logException(Exception $e)¶
Log any exceptions that are thrown as a result of attempting to ingest invalid files.
These are logged as warnings because they are being ignored by the script,so they don’t actually kill the file ingest process.
Parameters: - $e (Exception) –
Returns: void
- _createFile(string $newFilePath, string $oldFilename, array $elementMetadata = Array)¶
Insert a File record corresponding to an ingested file and its metadata.
Parameters: - $newFilePath (string) – Path to the file within Omeka.
- $oldFilename (string) – The original filename for the file. This will usually be displayed to the end user.
- $elementMetadata (array) – See ActsAsElementText::addElementTextsByArray() for more information about the format of this array.
Returns: File
- _getDestination(string $fromFilename)¶
Retrieve the destination path for the file to be transferred.
This will generate an archival filename in order to prevent naming conflicts between ingested files.
This should be used as necessary by Omeka_File_Ingest_AbstractIngestimplementations in order to determine where to transfer any given file.
Parameters: - $fromFilename (string) – The filename from which to derive the archival filename.
Returns: string
- addValidator(Zend_Validate_Interface $validator)¶
Add Zend Framework file validators.
Emulates the way Zend Framework adds validators.
Parameters: - $validator (Zend_Validate_Interface) –
Returns: Omeka_File_Ingest_AbstractIngest
- _validateFile(string $filePath, array $fileInfo)¶
Validate a file that has been transferred to Omeka.
Implementations of Omeka_File_Ingest_AbstractIngest should use this to validate the uploaded file based on user-defined security criteria.
Important: $fileInfo may need to contain the following keys in order to work with particular Zend_Validate_File_* validation classes:
- ‘name’: string filename (for Zend_Validate_File_Extension) If ZF is unable to determine the file extension when validating, it willcheck the ‘name’ attribute instead. Current use cases involve saving thefile to a temporary location before transferring to Omeka. Mosttemporary files do not maintain the original file extension.
- ‘type’: string MIME type (for Zend_Validate_File_MimeType) If ZFis unable to determine the mime type from the transferred file. Unlessthe server running Omeka has a mime_magic file or has installed theFileInfo extension, this will be necessary.
Parameters: - $filePath (string) – Absolute path to the file. The file should be local and readable, which is required by most (if not all) of the Zend_Validate_File_* classes.
- $fileInfo (array) – Set of file info that describes a given file being ingested.
Returns: boolean True if valid, otherwise throws an exception.
Omeka_File_Ingest_AbstractSourceIngest¶
- class Omeka_File_Ingest_AbstractSourceIngest¶
Package: File\Ingest
This abstract class encapsulates all the behavior that facilitates file ingest based on the assumption that each file can be retrieved via a string containing both the name and location of that file.
Applies to: URLs, file paths on a server. Does not apply to: direct HTTP uploads.
Also, if the original filename is not properly represented by the sourceidentifier (incorrect file extension, etc.), a more accurate filename can beprovided via the ‘filename’ attribute.
- property _item¶
- property _options¶
Set of arbitrary options to use when ingesting files.
- property _validators¶
Set of validators implementing Zend_Validate_Interface.
- property mimeType¶
The current validated file MIME type.
- _getFileSource($fileInfo)¶
The ‘source’ key of the file info is parsed out by default.
Parameters: - $fileInfo (unknown) –
Returns: string
- _parseFileInfo(string|array $files)¶
Normalize a file info array.
Files can be represented as one of the following:
- a string, representing the source identifier for a single file.
- an array containing a ‘source’ key.
- an array of strings.
- an array of arrays that each contain a ‘source’ key.
Parameters: - $files (string|array) –
Returns: array Formatted info array.
- _addZendValidatorAttributes(array $fileInfo)¶
Modify the set of info about each file to ensure that it is compatible with the Zend_Validate_File_* validators.
Parameters: - $fileInfo (array) –
Returns: array
- _getOriginalFilename(array $fileInfo)¶
Retrieve the original filename.
By default, this is stored as the ‘name’ attribute in the array.
Parameters: - $fileInfo (array) –
Returns: string
- _transferFile(array $fileInfo, string $originalFilename)¶
Transfer the file to Omeka.
Parameters: - $fileInfo (array) –
- $originalFilename (string) –
Returns: string Path to file in Omeka.
- _transfer(string $source, string $destination, array $fileInfo)¶
Transfer the file from the original location to its destination.
Examples would include transferring the file via wget, or making use ofstream wrappers to copy the file.
Parameters: - $source (string) –
- $destination (string) –
- $fileInfo (array) –
Returns: void
- _validateSource(string $source, array $info)¶
Determine whether or not the file source is valid.
Examples of this would include determining whether a URL exists, orwhether read access is available for a given file.
Parameters: - $source (string) –
- $info (array) –
Returns: void
- setItem(Item $item)¶
Set the item to use as a target when ingesting files.
Parameters: - $item (Item) –
Returns: void
- factory(string $adapterName, Item $item, array $options = Array)¶
Factory to retrieve Omeka_File_Ingest_* instances.
Parameters: - $adapterName (string) – Ingest adapter.
- $item (Item) –
- $options (array) –
Returns: Omeka_File_Ingest_AbstractIngest
- setOptions(array $options)¶
Set options for ingesting files.
Parameters: - $options (array) – Available options include: - ‘ignore_invalid_files’: boolean false by default. Determine whether or not to throw exceptions when a file is not valid. This can be based on a number of factors: whether or not the original identifier is valid (i.e. a valid URL), whether or not the file itself is valid (i.e. invalid file extension), or whether the basic algorithm for ingesting the file fails (i.e., files cannot be transferred because the files/ directory is not writeable). This option is primarily useful for skipping known invalid files when ingesting large data sets.
Returns: void
- ingest(mixed $fileInfo)¶
Ingest based on arbitrary file identifier info.
If this is an array that has a ‘metadata’ key, that should be an arrayrepresenting element text metadata to assign to the file. SeeActsAsElementText::addElementTextsByArray() for more details.
Parameters: - $fileInfo (mixed) – An arbitrary input (array, string, object, etc.) that corresponds to one or more files to be ingested into Omeka.
Returns: array Ingested file records.
- _ignoreIngestErrors()¶
Determine whether or not to ignore file ingest errors. Based on ‘ignore_invalid_files’, which is false by default.
Returns: boolean
- _logException(Exception $e)¶
Log any exceptions that are thrown as a result of attempting to ingest invalid files.
These are logged as warnings because they are being ignored by the script,so they don’t actually kill the file ingest process.
Parameters: - $e (Exception) –
Returns: void
- _createFile(string $newFilePath, string $oldFilename, array $elementMetadata = Array)¶
Insert a File record corresponding to an ingested file and its metadata.
Parameters: - $newFilePath (string) – Path to the file within Omeka.
- $oldFilename (string) – The original filename for the file. This will usually be displayed to the end user.
- $elementMetadata (array) – See ActsAsElementText::addElementTextsByArray() for more information about the format of this array.
Returns: File
- _getDestination(string $fromFilename)¶
Retrieve the destination path for the file to be transferred.
This will generate an archival filename in order to prevent naming conflicts between ingested files.
This should be used as necessary by Omeka_File_Ingest_AbstractIngestimplementations in order to determine where to transfer any given file.
Parameters: - $fromFilename (string) – The filename from which to derive the archival filename.
Returns: string
- addValidator(Zend_Validate_Interface $validator)¶
Add Zend Framework file validators.
Emulates the way Zend Framework adds validators.
Parameters: - $validator (Zend_Validate_Interface) –
Returns: Omeka_File_Ingest_AbstractIngest
- _validateFile(string $filePath, array $fileInfo)¶
Validate a file that has been transferred to Omeka.
Implementations of Omeka_File_Ingest_AbstractIngest should use this to validate the uploaded file based on user-defined security criteria.
Important: $fileInfo may need to contain the following keys in order to work with particular Zend_Validate_File_* validation classes:
- ‘name’: string filename (for Zend_Validate_File_Extension) If ZF is unable to determine the file extension when validating, it willcheck the ‘name’ attribute instead. Current use cases involve saving thefile to a temporary location before transferring to Omeka. Mosttemporary files do not maintain the original file extension.
- ‘type’: string MIME type (for Zend_Validate_File_MimeType) If ZFis unable to determine the mime type from the transferred file. Unlessthe server running Omeka has a mime_magic file or has installed theFileInfo extension, this will be necessary.
Parameters: - $filePath (string) – Absolute path to the file. The file should be local and readable, which is required by most (if not all) of the Zend_Validate_File_* classes.
- $fileInfo (array) – Set of file info that describes a given file being ingested.
Returns: boolean True if valid, otherwise throws an exception.
Omeka_File_Ingest_Exception¶
- class Omeka_File_Ingest_Exception¶
Package: File\Ingest
An exception to be thrown when something goes wrong during the file ingest process.
- property message¶
- property string¶
- property code¶
- property file¶
- property line¶
- property trace¶
- property previous¶
- __clone()¶
- __construct($message, $code, $previous)¶
Parameters: - $message (unknown) –
- $code (unknown) –
- $previous (unknown) –
- getMessage()¶
- getCode()¶
- getFile()¶
- getLine()¶
- getTrace()¶
- getPrevious()¶
- getTraceAsString()¶
- __toString()¶
Omeka_File_Ingest_Filesystem¶
- class Omeka_File_Ingest_Filesystem¶
Package: File\Ingest
Implements ingesting files from the local filesystem.
- property _item¶
- property _options¶
Set of arbitrary options to use when ingesting files.
- property _validators¶
Set of validators implementing Zend_Validate_Interface.
- property mimeType¶
The current validated file MIME type.
- _getOriginalFilename(array $info)¶
Retrieve the original filename of the file to be transferred.
Check for the ‘name’ attribute first, otherwise extract the basename()from the given file path.
Parameters: - $info (array) – File info array.
Returns: string
- _transfer(string $source, string $destination, array $info)¶
Transfer a file.
Parameters: - $source (string) – Source path.
- $destination (string) – Destination path.
- $info (array) – File info array. If ‘rename’ is specified as true, move the file instead of copying.
Returns: void
- _validateSource(string $source, array $info)¶
Validate file transfer.
Parameters: - $source (string) – Source path.
- $info (array) – File info array.
- _getFileSource($fileInfo)¶
The ‘source’ key of the file info is parsed out by default.
Parameters: - $fileInfo (unknown) –
Returns: string
- _parseFileInfo(string|array $files)¶
Normalize a file info array.
Files can be represented as one of the following:
- a string, representing the source identifier for a single file.
- an array containing a ‘source’ key.
- an array of strings.
- an array of arrays that each contain a ‘source’ key.
Parameters: - $files (string|array) –
Returns: array Formatted info array.
- _addZendValidatorAttributes(array $fileInfo)¶
Modify the set of info about each file to ensure that it is compatible with the Zend_Validate_File_* validators.
Parameters: - $fileInfo (array) –
Returns: array
- _transferFile(array $fileInfo, string $originalFilename)¶
Transfer the file to Omeka.
Parameters: - $fileInfo (array) –
- $originalFilename (string) –
Returns: string Path to file in Omeka.
- setItem(Item $item)¶
Set the item to use as a target when ingesting files.
Parameters: - $item (Item) –
Returns: void
- factory(string $adapterName, Item $item, array $options = Array)¶
Factory to retrieve Omeka_File_Ingest_* instances.
Parameters: - $adapterName (string) – Ingest adapter.
- $item (Item) –
- $options (array) –
Returns: Omeka_File_Ingest_AbstractIngest
- setOptions(array $options)¶
Set options for ingesting files.
Parameters: - $options (array) – Available options include: - ‘ignore_invalid_files’: boolean false by default. Determine whether or not to throw exceptions when a file is not valid. This can be based on a number of factors: whether or not the original identifier is valid (i.e. a valid URL), whether or not the file itself is valid (i.e. invalid file extension), or whether the basic algorithm for ingesting the file fails (i.e., files cannot be transferred because the files/ directory is not writeable). This option is primarily useful for skipping known invalid files when ingesting large data sets.
Returns: void
- ingest(mixed $fileInfo)¶
Ingest based on arbitrary file identifier info.
If this is an array that has a ‘metadata’ key, that should be an arrayrepresenting element text metadata to assign to the file. SeeActsAsElementText::addElementTextsByArray() for more details.
Parameters: - $fileInfo (mixed) – An arbitrary input (array, string, object, etc.) that corresponds to one or more files to be ingested into Omeka.
Returns: array Ingested file records.
- _ignoreIngestErrors()¶
Determine whether or not to ignore file ingest errors. Based on ‘ignore_invalid_files’, which is false by default.
Returns: boolean
- _logException(Exception $e)¶
Log any exceptions that are thrown as a result of attempting to ingest invalid files.
These are logged as warnings because they are being ignored by the script,so they don’t actually kill the file ingest process.
Parameters: - $e (Exception) –
Returns: void
- _createFile(string $newFilePath, string $oldFilename, array $elementMetadata = Array)¶
Insert a File record corresponding to an ingested file and its metadata.
Parameters: - $newFilePath (string) – Path to the file within Omeka.
- $oldFilename (string) – The original filename for the file. This will usually be displayed to the end user.
- $elementMetadata (array) – See ActsAsElementText::addElementTextsByArray() for more information about the format of this array.
Returns: File
- _getDestination(string $fromFilename)¶
Retrieve the destination path for the file to be transferred.
This will generate an archival filename in order to prevent naming conflicts between ingested files.
This should be used as necessary by Omeka_File_Ingest_AbstractIngestimplementations in order to determine where to transfer any given file.
Parameters: - $fromFilename (string) – The filename from which to derive the archival filename.
Returns: string
- addValidator(Zend_Validate_Interface $validator)¶
Add Zend Framework file validators.
Emulates the way Zend Framework adds validators.
Parameters: - $validator (Zend_Validate_Interface) –
Returns: Omeka_File_Ingest_AbstractIngest
- _validateFile(string $filePath, array $fileInfo)¶
Validate a file that has been transferred to Omeka.
Implementations of Omeka_File_Ingest_AbstractIngest should use this to validate the uploaded file based on user-defined security criteria.
Important: $fileInfo may need to contain the following keys in order to work with particular Zend_Validate_File_* validation classes:
- ‘name’: string filename (for Zend_Validate_File_Extension) If ZF is unable to determine the file extension when validating, it willcheck the ‘name’ attribute instead. Current use cases involve saving thefile to a temporary location before transferring to Omeka. Mosttemporary files do not maintain the original file extension.
- ‘type’: string MIME type (for Zend_Validate_File_MimeType) If ZFis unable to determine the mime type from the transferred file. Unlessthe server running Omeka has a mime_magic file or has installed theFileInfo extension, this will be necessary.
Parameters: - $filePath (string) – Absolute path to the file. The file should be local and readable, which is required by most (if not all) of the Zend_Validate_File_* classes.
- $fileInfo (array) – Set of file info that describes a given file being ingested.
Returns: boolean True if valid, otherwise throws an exception.
Omeka_File_Ingest_InvalidException¶
- class Omeka_File_Ingest_InvalidException¶
Package: File\Ingest
Exception for indicating validation errors within an ingest.
Omeka_File_Ingest_Upload¶
- class Omeka_File_Ingest_Upload¶
Package: File\Ingest
This class creates a bridge between the ZF File Transfer HTTP adapter and Omeka’s file ingest classes.
- property _adapter¶
- property _adapterOptions¶
- property _item¶
- property _options¶
Set of arbitrary options to use when ingesting files.
- property _validators¶
Set of validators implementing Zend_Validate_Interface.
- property mimeType¶
The current validated file MIME type.
- _buildAdapter()¶
Create a ZF HTTP file transfer adapter.
Returns: void
- setOptions(array $options)¶
In addition to the default options available for Omeka_File_Ingest_AbstractIngest, this understands the following options: - ‘ignoreNoFile’ => boolean False by default. Whether or not to ignore - validation errors that occur when an uploaded file is missing. This - may occur when a file input is left empty on a form.
This option can be overridden by the ‘ignore_invalid_files’ option. Forinstance, if ‘ignoreNoFile’ is set to false but ‘ignore_invalid_files’ isset to true, any exceptions due to missing uploads will be suppressed andignored.
Parameters: - $options (array) –
Returns: void
- _getOriginalFilename(array $fileInfo)¶
The ‘name’ attribute of the $_FILES array will always contain the original name of the file.
Parameters: - $fileInfo (array) –
Returns: string
- _transferFile(array $fileInfo, string $originalFilename)¶
Use the Zend_File_Transfer adapter to upload the file.
Parameters: - $fileInfo (array) –
- $originalFilename (string) –
Returns: string Path to the file in Omeka.
- _parseFileInfo(string|null $fileInfo)¶
Use the adapter to extract the array of file information.
Parameters: - $fileInfo (string|null) – The name of the form input to ingest.
Returns: array
- addValidator(Zend_Validate_Interface $validator)¶
Use the Zend Framework adapter to handle validation instead of the built-in _validateFile() method.
Parameters: - $validator (Zend_Validate_Interface) –
Returns: void
- setItem(Item $item)¶
Set the item to use as a target when ingesting files.
Parameters: - $item (Item) –
Returns: void
- factory(string $adapterName, Item $item, array $options = Array)¶
Factory to retrieve Omeka_File_Ingest_* instances.
Parameters: - $adapterName (string) – Ingest adapter.
- $item (Item) –
- $options (array) –
Returns: Omeka_File_Ingest_AbstractIngest
- ingest(mixed $fileInfo)¶
Ingest based on arbitrary file identifier info.
If this is an array that has a ‘metadata’ key, that should be an arrayrepresenting element text metadata to assign to the file. SeeActsAsElementText::addElementTextsByArray() for more details.
Parameters: - $fileInfo (mixed) – An arbitrary input (array, string, object, etc.) that corresponds to one or more files to be ingested into Omeka.
Returns: array Ingested file records.
- _ignoreIngestErrors()¶
Determine whether or not to ignore file ingest errors. Based on ‘ignore_invalid_files’, which is false by default.
Returns: boolean
- _logException(Exception $e)¶
Log any exceptions that are thrown as a result of attempting to ingest invalid files.
These are logged as warnings because they are being ignored by the script,so they don’t actually kill the file ingest process.
Parameters: - $e (Exception) –
Returns: void
- _createFile(string $newFilePath, string $oldFilename, array $elementMetadata = Array)¶
Insert a File record corresponding to an ingested file and its metadata.
Parameters: - $newFilePath (string) – Path to the file within Omeka.
- $oldFilename (string) – The original filename for the file. This will usually be displayed to the end user.
- $elementMetadata (array) – See ActsAsElementText::addElementTextsByArray() for more information about the format of this array.
Returns: File
- _getDestination(string $fromFilename)¶
Retrieve the destination path for the file to be transferred.
This will generate an archival filename in order to prevent naming conflicts between ingested files.
This should be used as necessary by Omeka_File_Ingest_AbstractIngestimplementations in order to determine where to transfer any given file.
Parameters: - $fromFilename (string) – The filename from which to derive the archival filename.
Returns: string
- _validateFile(string $filePath, array $fileInfo)¶
Validate a file that has been transferred to Omeka.
Implementations of Omeka_File_Ingest_AbstractIngest should use this to validate the uploaded file based on user-defined security criteria.
Important: $fileInfo may need to contain the following keys in order to work with particular Zend_Validate_File_* validation classes:
- ‘name’: string filename (for Zend_Validate_File_Extension) If ZF is unable to determine the file extension when validating, it willcheck the ‘name’ attribute instead. Current use cases involve saving thefile to a temporary location before transferring to Omeka. Mosttemporary files do not maintain the original file extension.
- ‘type’: string MIME type (for Zend_Validate_File_MimeType) If ZFis unable to determine the mime type from the transferred file. Unlessthe server running Omeka has a mime_magic file or has installed theFileInfo extension, this will be necessary.
Parameters: - $filePath (string) – Absolute path to the file. The file should be local and readable, which is required by most (if not all) of the Zend_Validate_File_* classes.
- $fileInfo (array) – Set of file info that describes a given file being ingested.
Returns: boolean True if valid, otherwise throws an exception.
Omeka_File_Ingest_Url¶
- class Omeka_File_Ingest_Url¶
Package: File\Ingest
Ingest URLs into Omeka.
- property _item¶
- property _options¶
Set of arbitrary options to use when ingesting files.
- property _validators¶
Set of validators implementing Zend_Validate_Interface.
- property mimeType¶
The current validated file MIME type.
- _getOriginalFilename(array $fileInfo)¶
Return the original filename.
Parameters: - $fileInfo (array) –
Returns: string
- _getHttpClient(string $source)¶
Get a HTTP client for retrieving the given file.
Parameters: - $source (string) – Source URI.
Returns: Zend_Http_Client
- _transfer(string $source, string $destination, array $fileInfo)¶
Fetch a file from a URL.
Parameters: - $source (string) – Source URL.
- $destination (string) – Destination file path.
- $fileInfo (array) –
Returns: void
- _validateSource(string $source, array $info)¶
Ensure the source URL exists and can be read from.
Parameters: - $source (string) – Source URL.
- $info (array) – File info array (unused).
Returns: void
- _getFileSource($fileInfo)¶
The ‘source’ key of the file info is parsed out by default.
Parameters: - $fileInfo (unknown) –
Returns: string
- _parseFileInfo(string|array $files)¶
Normalize a file info array.
Files can be represented as one of the following:
- a string, representing the source identifier for a single file.
- an array containing a ‘source’ key.
- an array of strings.
- an array of arrays that each contain a ‘source’ key.
Parameters: - $files (string|array) –
Returns: array Formatted info array.
- _addZendValidatorAttributes(array $fileInfo)¶
Modify the set of info about each file to ensure that it is compatible with the Zend_Validate_File_* validators.
Parameters: - $fileInfo (array) –
Returns: array
- _transferFile(array $fileInfo, string $originalFilename)¶
Transfer the file to Omeka.
Parameters: - $fileInfo (array) –
- $originalFilename (string) –
Returns: string Path to file in Omeka.
- setItem(Item $item)¶
Set the item to use as a target when ingesting files.
Parameters: - $item (Item) –
Returns: void
- factory(string $adapterName, Item $item, array $options = Array)¶
Factory to retrieve Omeka_File_Ingest_* instances.
Parameters: - $adapterName (string) – Ingest adapter.
- $item (Item) –
- $options (array) –
Returns: Omeka_File_Ingest_AbstractIngest
- setOptions(array $options)¶
Set options for ingesting files.
Parameters: - $options (array) – Available options include: - ‘ignore_invalid_files’: boolean false by default. Determine whether or not to throw exceptions when a file is not valid. This can be based on a number of factors: whether or not the original identifier is valid (i.e. a valid URL), whether or not the file itself is valid (i.e. invalid file extension), or whether the basic algorithm for ingesting the file fails (i.e., files cannot be transferred because the files/ directory is not writeable). This option is primarily useful for skipping known invalid files when ingesting large data sets.
Returns: void
- ingest(mixed $fileInfo)¶
Ingest based on arbitrary file identifier info.
If this is an array that has a ‘metadata’ key, that should be an arrayrepresenting element text metadata to assign to the file. SeeActsAsElementText::addElementTextsByArray() for more details.
Parameters: - $fileInfo (mixed) – An arbitrary input (array, string, object, etc.) that corresponds to one or more files to be ingested into Omeka.
Returns: array Ingested file records.
- _ignoreIngestErrors()¶
Determine whether or not to ignore file ingest errors. Based on ‘ignore_invalid_files’, which is false by default.
Returns: boolean
- _logException(Exception $e)¶
Log any exceptions that are thrown as a result of attempting to ingest invalid files.
These are logged as warnings because they are being ignored by the script,so they don’t actually kill the file ingest process.
Parameters: - $e (Exception) –
Returns: void
- _createFile(string $newFilePath, string $oldFilename, array $elementMetadata = Array)¶
Insert a File record corresponding to an ingested file and its metadata.
Parameters: - $newFilePath (string) – Path to the file within Omeka.
- $oldFilename (string) – The original filename for the file. This will usually be displayed to the end user.
- $elementMetadata (array) – See ActsAsElementText::addElementTextsByArray() for more information about the format of this array.
Returns: File
- _getDestination(string $fromFilename)¶
Retrieve the destination path for the file to be transferred.
This will generate an archival filename in order to prevent naming conflicts between ingested files.
This should be used as necessary by Omeka_File_Ingest_AbstractIngestimplementations in order to determine where to transfer any given file.
Parameters: - $fromFilename (string) – The filename from which to derive the archival filename.
Returns: string
- addValidator(Zend_Validate_Interface $validator)¶
Add Zend Framework file validators.
Emulates the way Zend Framework adds validators.
Parameters: - $validator (Zend_Validate_Interface) –
Returns: Omeka_File_Ingest_AbstractIngest
- _validateFile(string $filePath, array $fileInfo)¶
Validate a file that has been transferred to Omeka.
Implementations of Omeka_File_Ingest_AbstractIngest should use this to validate the uploaded file based on user-defined security criteria.
Important: $fileInfo may need to contain the following keys in order to work with particular Zend_Validate_File_* validation classes:
- ‘name’: string filename (for Zend_Validate_File_Extension) If ZF is unable to determine the file extension when validating, it willcheck the ‘name’ attribute instead. Current use cases involve saving thefile to a temporary location before transferring to Omeka. Mosttemporary files do not maintain the original file extension.
- ‘type’: string MIME type (for Zend_Validate_File_MimeType) If ZFis unable to determine the mime type from the transferred file. Unlessthe server running Omeka has a mime_magic file or has installed theFileInfo extension, this will be necessary.
Parameters: - $filePath (string) – Absolute path to the file. The file should be local and readable, which is required by most (if not all) of the Zend_Validate_File_* classes.
- $fileInfo (array) – Set of file info that describes a given file being ingested.
Returns: boolean True if valid, otherwise throws an exception.
Libraries/Omeka/File/MimeType¶
Omeka_File_MimeType_Detect¶
- class Omeka_File_MimeType_Detect¶
Package: File\MimeType\Detect
Represents the detected MIME types of a file.
- property _file¶
- property _strategies¶
- property _mimeType¶
- property _mimeTypes¶
- property _ambiguousMimeTypes¶
- __construct(string|File $file, array $strategies = Array)¶
Set the required properties for detecting the MIME types of a file.
Parameters: - $file (string|File) – The full path to the file or a File record.
- $strategies (array) – An array of file detection strategies in priority order. If none are passed, a default list will be set. All strategies must implement Omeka_File_MimeType_Detect_StrategyInterface.
- detect()¶
Detect the MIME type of this file.
Returns: string The definitive MIME type.
- getMimeType()¶
Get the definitive MIME type of this file.
Returns: string
- getMimeTypes()¶
Get the MIME types of this file, one for each detection strategy.
Returns: array
Omeka_File_MimeType_Exception¶
- class Omeka_File_MimeType_Exception¶
Package: File\MimeType
- property message¶
- property string¶
- property code¶
- property file¶
- property line¶
- property trace¶
- property previous¶
- __clone()¶
- __construct($message, $code, $previous)¶
Parameters: - $message (unknown) –
- $code (unknown) –
- $previous (unknown) –
- getMessage()¶
- getCode()¶
- getFile()¶
- getLine()¶
- getTrace()¶
- getPrevious()¶
- getTraceAsString()¶
- __toString()¶
Libraries/Omeka/Filter¶
Omeka_Filter_Boolean¶
Omeka_Filter_Filename¶
- class Omeka_Filter_Filename¶
Package: Filter
Rename a file to make it suitable for inclusion in the Omeka repository.
- filter(string $value)¶
Grab the original path to the file, rename it according to our convention, and return the new path to the file.
Parameters: - $value (string) – Path to the file.
Returns: string Path to the (renamed) file.
- renameFile(string $name)¶
Creates a new, random filename for storage in Omeka.
Parameters: - $name (string) –
Returns: string
Omeka_Filter_ForeignKey¶
- class Omeka_Filter_ForeignKey¶
Package: Filter
Converts input into values suitable for use as Omeka ‘id’ key values.
- filter(mixed $value)¶
Convert any value into an unsigned integer that would be valid if stored as a foreign key in a database table.
This will return null for any value that falls outside the rangeof an unsigned integer (string, negative numbers, etc.)
Parameters: - $value (mixed) – Input value.
Returns: integer
Omeka_Filter_HtmlPurifier¶
- class Omeka_Filter_HtmlPurifier¶
Package: Filter
A Zend_Filter implementation that uses HtmlPurifier to purify a string.
- property _purifier¶
- property _purifierConfig¶
- filter($value)¶
Filter the value
Parameters: - $value (unknown) –
Returns: string An html purified string
- getDefaultAllowedHtmlElements()¶
Get the default allowed html elements.
Returns: array An array of strings corresponding to the allowed html elements
- getDefaultAllowedHtmlAttributes()¶
Get the default allowed html attributes.
Returns: array An array of strings corresponding to the allowed html attributes
- getHtmlPurifier()¶
Gets the html purifier singleton
Returns: HTMLPurifier $purifier
- setHtmlPurifier(HTMLPurifier $purifier)¶
Sets the html purifier singleton
Parameters: - $purifier (HTMLPurifier) –
Returns: void
- createHtmlPurifier(array $allowedHtmlElements, array $allowedHtmlAttributes)¶
Parameters: - $allowedHtmlElements (array) – An array of strings representing allowed HTML elements
- $allowedHtmlAttributes (array) – An array of strings representing allowed HTML attributes
Returns: HTMLPurifier
- filterAttributesWithMissingElements($htmlAttributes = Array, $htmlElements = Array)¶
Parameters: - $htmlAttributes (unknown) –
- $htmlElements (unknown) –
Libraries/Omeka/Form¶
Omeka_Form_Admin¶
- class Omeka_Form_Admin¶
Package: Form
A Zend_Form subclass to set up a record editing form for the Omeka 2.0 admin user interface
- property _editDisplayGroup¶
- property _saveDisplayGroup¶
- property _saveDisplayGroupActionDecorator¶
- property _record¶
- property _type¶
- property _hasPublicPage¶
- property _editGroupCssClass¶
- property _saveGroupCssClass¶
- init()¶
- addElementToEditGroup(Zend_Form_Element|string $element, string|null $name, array|null $options)¶
Add an element to the edit area
Parameters: - $element (Zend_Form_Element|string) –
- $name (string|null) –
- $options (array|null) –
- addElementToSaveGroup(Zend_Form_Element|string $element, string|null $name, array|null $options)¶
Add an element to the save panel
Parameters: - $element (Zend_Form_Element|string) –
- $name (string|null) –
- $options (array|null) –
- addElementToDisplayGroup(string $group, Zend_Form_Element $element, string $name, array $options)¶
Generalizes creating and adding new elements to one of the display groups
You can pass in either an Zend_Form_Element you have already created, or passparameters as you would to Zend_Form::addElement
Parameters: - $group (string) – Either ‘save’ or ‘edit’
- $element (Zend_Form_Element) – The element to add to the display group
- $name (string) –
- $options (array) –
Returns: Omeka_Form_Admin
- getSaveGroupDefaultElementDecorators()¶
Get the decorators for the save display group
Returns: array The default decorators for the save display group
- setEditGroupCssClass(string $cssClass)¶
Set the class for the edit display group.
You can alter the default css class for the edit group panel by passing in anoption for ‘editGroupCssClass’ when you create an instance of Omeka_Form_Admin.This should be done very sparingly, as the default class is the best match toexisting admin theme look and feel
Parameters: - $cssClass (string) –
- setSaveGroupCssClass(string $cssClass)¶
Set the class for the save display group.
You can alter the default css class for the save group panel by passing in anoption for ‘editGroupCssClass’ when you create an instance of Omeka_Form_Admin.This should be done very sparingly, as the default class is the best match toexisting admin theme look and feel
Parameters: - $cssClass (string) –
- setType(string $type)¶
Set the record type of the object being edited (e.g., ‘item’)
Pass in the recordType as part of the options array when you create an instance
Parameters: - $type (string) –
- setRecord(Omeka_Record_AbstractRecord $record)¶
Set the record (if one exists) for the object being edited
Passing the record object as part of the options when you create the formwill automatically add ‘Edit’ and ‘Delete’ buttons to the save panel
Parameters: - $record (Omeka_Record_AbstractRecord) –
- setHasPublicPage(bool $value =)¶
Set whether the save panel should display a link to the record’s public page if it exists
By default, a link to a record’s public page is available if it exists. Pass false as the value of hasPublicPage in the options array to suppress this behavior.
Parameters: - $value (bool) – true
Libraries/Omeka/Http¶
Omeka_Http_Client¶
- class Omeka_Http_Client¶
Package: Http
Wrapper for Zend_Http_Client.
Adds the following functionality: retries on timeouts.
- property _maxRetries¶
- property _retryCount¶
- request($method)¶
Wraps Zend_Http_Client to automatically retry timed out requests.
Parameters: - $method (unknown) –
- setMaxRetries(integer $count)¶
Set the maximum number of retries to make when a request times out.
Parameters: - $count (integer) –
Libraries/Omeka/Job¶
Omeka_Job_AbstractJob¶
- class Omeka_Job_AbstractJob¶
Package: Job
Abstract implementation of an Omeka job.
Most plugin implementations of jobs will extend this class to gain convenientaccess to the database and other potentially important resources.
- property _db¶
- property _dispatcher¶
- property _user¶
- property _options¶
- __construct($options)¶
Parameters: - $options (unknown) –
- _setOptions($options)¶
Set all the options associated with this task.
This is a convenience method that calls setter methods for the optionsgiven in the array. If an element in the array does not have anassociated setter method, it will be passed into the options array.
Parameters: - $options (unknown) –
- setJobDispatcher(Omeka_Job_Dispatcher_DispatcherInterface $dispatcher)¶
Parameters: - $dispatcher (Omeka_Job_Dispatcher_DispatcherInterface) –
- getUser()¶
Get the User currently set on this Job, if any.
Returns: User|null
- resend()¶
Resend the job using the same options that were passed to the current job.
- perform()¶
Omeka_Job_Factory¶
- class Omeka_Job_Factory¶
Package: Job\Factory
Factory for instantiating Omeka_Job instances.
- property _options¶
- __construct($options = Array)¶
Parameters: - $options (unknown) –
- from(string $json)¶
Decode a message from JSON and use the results to instantiate a new job instance.
Parameters: - $json (string) –
- build($data)¶
Instantiate a new job instance from the arguments given.
Parameters: - $data (unknown) –
Omeka_Job_JobInterface¶
Omeka_Job_Mock¶
- class Omeka_Job_Mock¶
Package: Job
Mock job class for unit tests.
- property options¶
- property performed¶
- property _db¶
- property _dispatcher¶
- property _user¶
- property _options¶
- __construct($options)¶
Parameters: - $options (unknown) –
- perform()¶
- getDb()¶
Getter method to expose protected properties.
- getDispatcher()¶
Getter method to expose protected properties.
- getMiscOptions()¶
- _setOptions($options)¶
Set all the options associated with this task.
This is a convenience method that calls setter methods for the optionsgiven in the array. If an element in the array does not have anassociated setter method, it will be passed into the options array.
Parameters: - $options (unknown) –
- setJobDispatcher(Omeka_Job_Dispatcher_DispatcherInterface $dispatcher)¶
Parameters: - $dispatcher (Omeka_Job_Dispatcher_DispatcherInterface) –
- getUser()¶
Get the User currently set on this Job, if any.
Returns: User|null
- resend()¶
Resend the job using the same options that were passed to the current job.
Libraries/Omeka/Job/Dispatcher¶
Omeka_Job_Dispatcher_Default¶
- class Omeka_Job_Dispatcher_Default¶
Package: Job\Dispatcher
Dispatches jobs in Omeka.
This provides a clean interface to adapter classes that deal with the detailsof how to dispatch jobs. It is initialized in the Jobs bootstrap resource andcan be accessed via the registry.
Standard usage, where Job_Class_Name corresponds to a valid class name for a class implementing Omeka_JobInterface:
$dispatcher = Zend_Registry::get('job_dispatcher'); $dispatcher->send('Job_Class_Name', array( 'firstOption' => 'text', 'secondOption' => 2 ));
- property _defaultAdapter¶
- property _longRunningAdapter¶
- property _user¶
- __construct(Omeka_Job_Dispatcher_Adapter_AdapterInterface $defaultAdapter, Omeka_Job_Dispatcher_Adapter_AdapterInterface $longRunningAdapter, User|null $user)¶
Parameters: - $defaultAdapter (Omeka_Job_Dispatcher_Adapter_AdapterInterface) –
- $longRunningAdapter (Omeka_Job_Dispatcher_Adapter_AdapterInterface) –
- $user (User|null) – The user account associated with the request, i.e. the user account associated with jobs sent by the dispatcher.
- setUser(User|null $user)¶
Set the user.
Parameters: - $user (User|null) –
- getUser()¶
Get the user.
Returns: User|null
- setDefaultAdapter(Omeka_Job_Dispatcher_Adapter_AdapterInterface $defaultAdapter)¶
Set the default adapter.
Parameters: - $defaultAdapter (Omeka_Job_Dispatcher_Adapter_AdapterInterface) –
- setLongRunningAdapter(Omeka_Job_Dispatcher_Adapter_AdapterInterface $longRunningAdapter)¶
Set the long running adapter.
Parameters: - $longRunningAdapter (Omeka_Job_Dispatcher_Adapter_AdapterInterface) –
- setQueueName(string $name)¶
Set the name of the queue to which default jobs will be sent.
NOTE: This may be ignored by adapters that do not understand the notionof named queues (or queues in general).
Parameters: - $name (string) –
- setQueueNameLongRunning(string $name)¶
Set the name of the queue to which long-running jobs will be sent.
NOTE: This may be ignored by adapters that do not understand the notionof named queues (or queues in general).
Parameters: - $name (string) –
- send(string $jobClass, array $options = Array)¶
Dispatch a job using the default dispatcher.
Parameters: - $jobClass (string) – Class name that implements Omeka_JobInterface.
- $options (array) – Optional associative array containing options that the task needs in order to do its job. Note that all options should be primitive data types (or arrays containing primitive data types).
- sendLongRunning(string $jobClass, array $options = Array)¶
Dispatch a job using the long-running dispatcher.
Parameters: - $jobClass (string) – Name of a class that implements Omeka_JobInterface.
- $options (array) – Optional associative array containing options that the task needs in order to do its job. Note that all options should be primitive data types (or arrays containing primitive data types).
- _getJobMetadata($class, $options)¶
Parameters: - $class (unknown) –
- $options (unknown) –
- _toJson($metadata)¶
Parameters: - $metadata (unknown) –
Omeka_Job_Dispatcher_DispatcherInterface¶
- class Omeka_Job_Dispatcher_DispatcherInterface¶
Package: Job\Dispatcher
Interface for job dispatchers in Omeka.
- setQueueName(string $name)¶
Set the name of the queue to which jobs will be sent.
NOTE: This may be ignored by adapters that do not understand the notionof named queues (or queues in general).
Parameters: - $name (string) –
- send(string $jobClass, array $options = Array)¶
Parameters: - $jobClass (string) – Name of a class that implements Omeka_JobInterface.
- $options (array) – Optional Associative array containing options that the task needs in order to do its job. Note that all options should be primitive data types (or arrays containing primitive data types).
Libraries/Omeka/Job/Dispatcher/Adapter¶
- class Omeka_Job_Dispatcher_Adapter_AbstractAdapter¶
Package: Job\Dispatcher\Adapter
Abstract class for job dispatcher adapters.
- property _options¶
- __construct(array|null $options)¶
Parameters: - $options (array|null) – Optional Options to instantiate in the adapter.
- _setOptions($options)¶
Parameters: - $options (unknown) –
- getOption(string $name)¶
Retrieve an option by name as it was passed to the constructor of the adapter.
Parameters: - $name (string) –
- hasOption(string $name)¶
Whether or not the given option has been set.
Parameters: - $name (string) –
- setQueueName($name)¶
Adapter implementations do not understand named queues by default, so this default implementation returns false. Override this in subclasses to specify the correct behavior.
Parameters: - $name (unknown) –
- send(string $encodedJob, array $metadata)¶
Send the job to whatever underlying system is used by the adapter.
Parameters: - $encodedJob (string) – The job encoded as a string. In most cases, this will be passed directly into whatever client or queue the adapter uses.
- $metadata (array) – An array containing all the metadata for the job. This is the unencoded version of the first argument and exists as a convenience so that adapter writers do not have to attempt to decode the first argument manually. This array contains the following keys: <ul> <li>className - Corresponds to the class name of the job.</li> <li>options - Options that are passed to the job when it is instantiated.</li> <li>createdBy - User object (or null) corresponding to the user who created this job.</li> <li>createdAt - Zend_Date corresponding to the date/time at which this job was created.</li> </ul>
- class Omeka_Job_Dispatcher_Adapter_AdapterInterface¶
Package: Job\Dispatcher\Adapter
Interface for job dispatcher adapters.
- setQueueName(string $name)¶
Set the name of the queue that the adapter will use for incoming jobs.
Note that this will not be used by some adapters and should beimplemented to return false in those cases.
Parameters: - $name (string) –
- send(string $encodedJob, array $metadata)¶
Send the job to whatever underlying system is used by the adapter.
Parameters: - $encodedJob (string) – The job encoded as a string. In most cases, this will be passed directly into whatever client or queue the adapter uses.
- $metadata (array) – An array containing all the metadata for the job. This is the unencoded version of the first argument and exists as a convenience so that adapter writers do not have to attempt to decode the first argument manually. This array contains the following keys: <ul> <li>className - Corresponds to the class name of the job.</li> <li>options - Options that are passed to the job when it is instantiated.</li> <li>createdBy - User object (or null) corresponding to the user who created this job.</li> <li>createdAt - Zend_Date corresponding to the date/time at which this job was created.</li> </ul>
- class Omeka_Job_Dispatcher_Adapter_Array¶
Package: Job\Dispatcher\Adapter
Store dispatched jobs in an array.
This is used primarily by unit tests and should not be used in productioncode.
- property _queueName¶
- property _jobs¶
- setQueueName($name)¶
Parameters: - $name (unknown) –
- send($encodedJob, $metadata)¶
Parameters: - $encodedJob (unknown) –
- $metadata (unknown) –
- getJobs()¶
- getJob($index = 0)¶
Parameters: - $index (unknown) –
- class Omeka_Job_Dispatcher_Adapter_BackgroundProcess¶
Package: Job\Dispatcher\Adapter
Job dispatcher that uses Omeka’s existing background process API.
- property _processDispatcher¶
- property _options¶
- send($encodedJob, $metadata)¶
Dispatches a background process that executes the given job.
NOTE: No user account is bootstrapped when background.php runs (since itis CLI), so if a process triggers its own subprocesses, those will belisted as belonging to no user (ID = 0).
Parameters: - $encodedJob (unknown) –
- $metadata (unknown) –
- setProcessDispatcher(Omeka_Job_Process_Dispatcher $dispatcher)¶
For test purposes.
Parameters: - $dispatcher (Omeka_Job_Process_Dispatcher) –
- getProcessDispatcher()¶
- __construct(array|null $options)¶
Parameters: - $options (array|null) – Optional Options to instantiate in the adapter.
- _setOptions($options)¶
Parameters: - $options (unknown) –
- getOption(string $name)¶
Retrieve an option by name as it was passed to the constructor of the adapter.
Parameters: - $name (string) –
- hasOption(string $name)¶
Whether or not the given option has been set.
Parameters: - $name (string) –
- setQueueName($name)¶
Adapter implementations do not understand named queues by default, so this default implementation returns false. Override this in subclasses to specify the correct behavior.
Parameters: - $name (unknown) –
- class Omeka_Job_Dispatcher_Adapter_Beanstalk¶
Package: Job\Dispatcher\Adapter
Job dispatcher for Beanstalk.
Requires Pheanstalk library (Beanstalk client) in order to work properly.
This adapter must be instantiated with the ‘host’ option (IP address ofbeanstalk daemon) in order to work properly.
- constant DEFAULT_TTR¶
Because of the potential for long-running imports (and the fact that jobs are not idemopotent), TTR should be pretty high by default.
- property _pheanstalk¶
- property _options¶
- setQueueName(string $name)¶
Beanstalk understands the concept of ‘tubes’ instead of named queues, so set the appropriate ‘tube’ to dispatch jobs.
Parameters: - $name (string) –
- send($encodedJob, $metadata)¶
Parameters: - $encodedJob (unknown) –
- $metadata (unknown) –
- _pheanstalk()¶
- getOption($name)¶
Parameters: - $name (unknown) –
- __construct(array|null $options)¶
Parameters: - $options (array|null) – Optional Options to instantiate in the adapter.
- _setOptions($options)¶
Parameters: - $options (unknown) –
- hasOption(string $name)¶
Whether or not the given option has been set.
Parameters: - $name (string) –
- class Omeka_Job_Dispatcher_Adapter_RequiredOptionException¶
Package: Job\Dispatcher\Adapter
Exception thrown when required options have not been passed to the Omeka_Job_Dispatcher_Adapter_AdapterInterface’s constructor.
- property message¶
- property code¶
- property file¶
- property line¶
- __clone()¶
- __construct($message, $code, $previous)¶
Parameters: - $message (unknown) –
- $code (unknown) –
- $previous (unknown) –
- getMessage()¶
- getCode()¶
- getFile()¶
- getLine()¶
- getTrace()¶
- getPrevious()¶
- getTraceAsString()¶
- __toString()¶
- class Omeka_Job_Dispatcher_Adapter_Synchronous¶
Package: Job\Dispatcher\Adapter
Dispatcher for executing jobs in real-time, i.e. executing within the browser request.
WARNING: While especially useful for simple jobs or instances where it is notpossible to use one of the other adapters, keep in mind that long jobs maylead to request timeouts or open the possibility of DoS attacks by malicioususers.
- property _options¶
- send($encodedJob, $metadata)¶
Parameters: - $encodedJob (unknown) –
- $metadata (unknown) –
- __construct(array|null $options)¶
Parameters: - $options (array|null) – Optional Options to instantiate in the adapter.
- _setOptions($options)¶
Parameters: - $options (unknown) –
- getOption(string $name)¶
Retrieve an option by name as it was passed to the constructor of the adapter.
Parameters: - $name (string) –
- hasOption(string $name)¶
Whether or not the given option has been set.
Parameters: - $name (string) –
- setQueueName($name)¶
Adapter implementations do not understand named queues by default, so this default implementation returns false. Override this in subclasses to specify the correct behavior.
Parameters: - $name (unknown) –
- class Omeka_Job_Dispatcher_Adapter_ZendQueue¶
Package: Job\Dispatcher\Adapter
Dispatcher for Zend_Queue.
This would be particularly useful for installations that want to interfacewith ActiveMQ or Zend Server’s Job Queue via Zend_Queue. Note that usingthe ‘Array’ adapter should only be used for testing, as all jobs passed toit will be thrown away.
Required options include ‘adapter’ and ‘options’, whichcorrespond to the first and second arguments to Zend_Queue’s constructorrespectively.
For example, it would be configured like so in config.ini:
jobs.dispatcher = "Omeka_Job_Dispatcher_ZendQueue" jobs.adapterOptions.adapter = "PlatformJobQueue" jobs.adapterOptions.options.host = "127.0.0.1" jobs.adapterOptions.options.password = "foobar"
- property _queue¶
- property _options¶
- setQueueName($name)¶
Note that some Zend_Queue implementations understand the concept of named queues, while others do not.
Parameters: - $name (unknown) –
- send($encodedJob, $metadata)¶
Parameters: - $encodedJob (unknown) –
- $metadata (unknown) –
- _queue()¶
- __construct(array|null $options)¶
Parameters: - $options (array|null) – Optional Options to instantiate in the adapter.
- _setOptions($options)¶
Parameters: - $options (unknown) –
- getOption(string $name)¶
Retrieve an option by name as it was passed to the constructor of the adapter.
Parameters: - $name (string) –
- hasOption(string $name)¶
Whether or not the given option has been set.
Parameters: - $name (string) –
Libraries/Omeka/Job/Factory¶
Omeka_Job_Factory_MalformedJobException¶
- class Omeka_Job_Factory_MalformedJobException¶
Package: Job\Factory
Exception thrown when the message could not be decoded into valid job metadata.
- property message¶
- property code¶
- property file¶
- property line¶
- __clone()¶
- __construct($message, $code, $previous)¶
Parameters: - $message (unknown) –
- $code (unknown) –
- $previous (unknown) –
- getMessage()¶
- getCode()¶
- getFile()¶
- getLine()¶
- getTrace()¶
- getPrevious()¶
- getTraceAsString()¶
- __toString()¶
Omeka_Job_Factory_MissingClassException¶
- class Omeka_Job_Factory_MissingClassException¶
Package: Job\Factory
Exception thrown when the type of job could not be inferred from the message passed to the factory.
- property message¶
- property code¶
- property file¶
- property line¶
- __clone()¶
- __construct($message, $code, $previous)¶
Parameters: - $message (unknown) –
- $code (unknown) –
- $previous (unknown) –
- getMessage()¶
- getCode()¶
- getFile()¶
- getLine()¶
- getTrace()¶
- getPrevious()¶
- getTraceAsString()¶
- __toString()¶
Libraries/Omeka/Job/Process¶
Omeka_Job_Process_AbstractProcess¶
Omeka_Job_Process_Dispatcher¶
- class Omeka_Job_Process_Dispatcher¶
Package: Job\Process
Spawns and manages background processes.
- startProcess(string $className, User $user, Array|null $args)¶
Create a table entry for a new background process and spawn it.
Parameters: - $className (string) – Omeka_Job_Process_AbstractProcess subclass name to spawn
- $user (User) – User to run process as, defaults to current user
- $args (Array|null) – Arguments specific to the child class process
Returns: Process The model object for the background process
- stopProcess(Process $process)¶
Stops a background process in progress.
Parameters: - $process (Process) – The process to stop.
Returns: bool True if the process was stopped, false if not.
- getPHPCliPath()¶
- _checkCliPath($cliPath)¶
Checks if the configured PHP-CLI path points to a valid PHP binary. Flash an appropriate error if the path is invalid.
Parameters: - $cliPath (unknown) –
- _autodetectCliPath()¶
- _getBootstrapFilePath()¶
Returns the path to the background bootstrap script.
Returns: string Path to bootstrap
- _fork($command)¶
Launch a background process, returning control to the foreground.
Parameters: - $command (unknown) –
Omeka_Job_Process_Wrapper¶
- class Omeka_Job_Process_Wrapper¶
Package: Job\Process
Wrapper that allows Omeka_Job to work with the existing Process/ Omeka_Job_Process_Dispatcher API. Jobs are passed in as the ‘job’ argument, and this wrapper handles decoding and executing the job.
- property _process¶
- _getJob($str)¶
Parameters: - $str (unknown) –
- run($args)¶
Args passed in will consist of the JSON-encoded task.
Parameters: - $args (unknown) –
- __destruct()¶
Libraries/Omeka/Job/Worker¶
Omeka_Job_Worker_Beanstalk¶
- class Omeka_Job_Worker_Beanstalk¶
Package: Job\Worker
- __construct(Pheanstalk $pheanstalk, Omeka_Job_Factory $jobFactory, Omeka_Db $db)¶
Parameters: - $pheanstalk (Pheanstalk) –
- $jobFactory (Omeka_Job_Factory) –
- $db (Omeka_Db) –
- work(Pheanstalk_Job $pJob)¶
Parameters: - $pJob (Pheanstalk_Job) –
- _interrupt($job)¶
Parameters: - $job (unknown) –
Omeka_Job_Worker_InterruptException¶
- class Omeka_Job_Worker_InterruptException¶
Package: Job\Worker
Exception thrown when the type of job could not be inferred from the message passed to the factory.
- property message¶
- property string¶
- property code¶
- property file¶
- property line¶
- property trace¶
- property previous¶
- __clone()¶
- __construct($message, $code, $previous)¶
Parameters: - $message (unknown) –
- $code (unknown) –
- $previous (unknown) –
- getMessage()¶
- getCode()¶
- getFile()¶
- getLine()¶
- getTrace()¶
- getPrevious()¶
- getTraceAsString()¶
- __toString()¶
Libraries/Omeka/Output¶
Libraries/Omeka/Output/OmekaXml¶
Omeka_Output_OmekaXml_AbstractOmekaXml¶
- class Omeka_Output_OmekaXml_AbstractOmekaXml¶
Package: Output
Abstract base class for creating omeka-xml output formats.
- constant XMLNS_XSI¶
XML Schema instance namespace URI.
- constant XMLNS¶
Omeka-XML namespace URI.
- constant XMLNS_SCHEMALOCATION¶
Omeka-XML XML Schema URI.
- property _record¶
This class’ contextual record(s).
- property _context¶
The context of this DOMDocument. Determines how buildNode() builds the elements. Valid contexts include: item, file.
- property _doc¶
The final document object.
- property _node¶
The node built and set in child::_buildNode()
- _buildNode()¶
Abstract method. child::_buildNode() should set self::$_node.
- __construct(Omeka_Record_AbstractRecord|array $record, string $context)¶
Parameters: - $record (Omeka_Record_AbstractRecord|array) –
- $context (string) – The context of this DOM document.
- getDoc()¶
Get the document object.
Returns: DOMDocument
- _setRootElement(DOMElement $rootElement)¶
Set an element as root.
Parameters: - $rootElement (DOMElement) –
Returns: DOMElement The root element, including required attributes.
- _createElement(string $name, $value, $id, $parentElement)¶
Create a DOM element.
Parameters: - $name (string) – The name of the element.
- $value (unknown) –
- $id (unknown) –
- $parentElement (unknown) –
Returns: DOMElement
- _setContainerPagination(DOMElement $parentElement)¶
Set the pagination node for container elements
Parameters: - $parentElement (DOMElement) –
Returns: void
- _getElemetSetsByElementTexts(Omeka_Record_AbstractRecord $record, bool $getItemType =)¶
Get all element sets, elements, and element texts associated with the provided record.
Parameters: - $record (Omeka_Record_AbstractRecord) – The record from which to extract metadata.
- $getItemType (bool) – Whether to get the item type metadata.
Returns: stdClass A list of element sets or an item type.
- _buildElementSetContainerForRecord(Omeka_Record_AbstractRecord $record, DOMElement $parentElement)¶
Build an elementSetContainer element in a record (item or file) context.
Parameters: - $record (Omeka_Record_AbstractRecord) – The record from which to build element sets.
- $parentElement (DOMElement) – The element set container will append to this element.
Returns: void|null
- _buildItemTypeForItem(Item $item, DOMElement $parentElement)¶
Build an itemType element in an item context.
Parameters: - $item (Item) – The item from which to build the item type.
- $parentElement (DOMElement) – The item type will append to this element.
Returns: void|null
- _buildFileContainerForItem(Item $item, DOMElement $parentElement)¶
Build a fileContainer element in an item context.
Parameters: - $item (Item) – The item from which to build the file container.
- $parentElement (DOMElement) – The file container will append to this element.
Returns: void|null
- _buildCollectionForItem(Item $item, DOMElement $parentElement)¶
Build a collection element in an item context.
Parameters: - $item (Item) – The item from which to build the collection.
- $parentElement (DOMElement) – The collection will append to this element.
Returns: void|null
- _buildTagContainerForItem(Item $item, DOMElement $parentElement)¶
Build a tagContainer element in an item context.
Parameters: - $item (Item) – The item from which to build the tag container.
- $parentElement (DOMElement) – The tag container will append to this element.
Returns: void|null
- _buildItemContainerForCollection(Collection $collection, DOMElement $parentElement)¶
Build an itemContainer element in a collection context.
Parameters: - $collection (Collection) – The collection from which to build the item container.
- $parentElement (DOMElement) – The item container will append to this element.
Returns: void|null
- _buildTagUri()¶
Create a Tag URI to uniquely identify this Omeka XML instance.
Returns: string
- _buildUrl()¶
Create a absolute URI containing the current query string.
Returns: string
Libraries/Omeka/Plugin¶
Omeka_Plugin_AbstractPlugin¶
- class Omeka_Plugin_AbstractPlugin¶
Package: Plugin
Abstract plugin class.
Plugin authors may inherit from this class to aid in building their pluginframework.
- property _db¶
Database object accessible to plugin authors.
- property _hooks¶
Plugin hooks.
In the child class plugin authors should set an array containing hooknames as values and, optionally, callback names as keys. If a callbackname is given, the child class should contain an identically namedmethod. If no callback key is given, the child class should contain acorresponding hookCamelCased() method. E.g: the after_save_form_recordfilter should have a corresponding hookAfterSaveRecord() method.
For example:
array('install', 'uninstall', 'doSomething' => 'after_save_item')
- property _filters¶
Plugin filters.
In the child class plugin authors should set an array containing filternames as values and, optionally, callback names as keys. If a callbackname is given, the child class should contain an identically namedmethod. If no callback key is given, the child class should contain acorresponding filterCamelCased() method. E.g: the admin_navigation_mainfilter should have a corresponding filterAdminNavigationMain() method.
For example:
array('admin_navigation_main', 'public_navigation_main', 'changeSomething' => 'display_option_site_title', 'displayItemDublinCoreTitle' => array('Display', 'Item', 'Dublin Core', 'Title'))
- property _options¶
Plugin options.
Plugin authors should give an array containing option names as keys and their default values as values, if any.
For example:
array('option_name1' => 'option_default_value1', 'option_name2' => 'option_default_value2', 'option_name3', 'option_name4')
- __construct()¶
Construct the plugin object.
Sets the database object. Plugin authors must call parent::__construct() in the child class’s constructor, if used.
- setUp()¶
Set up the plugin to hook into Omeka.
Adds the plugin’s hooks and filters. Plugin writers must call this method after instantiating their plugin class.
- _installOptions()¶
Set options with default values.
Plugin authors may want to use this convenience method in their install hook callback.
- _uninstallOptions()¶
Delete all options.
Plugin authors may want to use this convenience method in their uninstall hook callback.
- _addHooks()¶
Validate and add hooks.
- _addFilters()¶
Validate and add filters.
Omeka_Plugin_Broker¶
- class Omeka_Plugin_Broker¶
Package: Plugin\Broker
Plugin Broker for Omeka.
For example,$broker->callHook(‘add_action_contexts’, array(‘controller’ => $controller))would call the ‘add_action_contexts’ on all plugins, and it would provide thecontroller object as the first argument to all implementations of that hook.
- property _callbacks¶
Array of hooks that have been implemented for plugins.
- property _filters¶
Stores all defined filters.
Storage in array where $_filters[‘filterName’][‘priority’][‘plugin’] = $hook;
- property _current¶
The directory name of the current plugin (used for calling hooks)
- addHook(string $hook, string $callback, string|null $plugin)¶
Add a hook implementation for a plugin.
Parameters: - $hook (string) – Name of the hook being implemented.
- $callback (string) – PHP callback for the hook implementation.
- $plugin (string|null) – Optional name of the plugin for which to add the hook. If omitted, the current plugin is used.
Returns: void
- getHook(string $pluginDirName, string $hook)¶
Get the hook implementation for a plugin.
Parameters: - $pluginDirName (string) – Name of the plugin to get the implementation from.
- $hook (string) – Name of the hook to get the implementation for.
Returns: callback|null
- setCurrentPluginDirName(string $pluginDirName)¶
Set the currently-focused plugin by directory name.
The plugin helper functions do not have any way of determining whatplugin to is currently in focus. These get/setCurrentPluginDirNamemethods allow the broker to know how to delegate to specific plugins ifnecessary.
Parameters: - $pluginDirName (string) – Plugin to set as current.
Returns: void
- getCurrentPluginDirName()¶
Get the directory name of the currently-focused plugin.
Returns: string
- callHook(string $name, array $args = Array, Plugin|string $plugin)¶
Call a hook by name.
Hooks can either be called globally or for a specific plugin only.
Parameters: - $name (string) – The name of the hook.
- $args (array) – Arguments to be passed to the hook implementations.
- $plugin (Plugin|string) – Name of the plugin that will invoke the hook.
Returns: void
- addFilter(string|array $name, callback $callback, $priority = 10)¶
Add a filter implementation.
Parameters: - $name (string|array) – Name of filter being implemented.
- $callback (callback) – PHP callback for filter implementation.
- $priority (unknown) –
Returns: void
- _getFilterNamespace()¶
Retrieve the namespace to use for the filter to be added.
Returns: string Name of the current plugin (if applicable). Otherwise, a magic constant that denotes globally applied filters.
- _getFilterKey(string|array $name)¶
Retrieve the key used for indexing the filter. The filter name should be either a string or an array of strings. If the filter name is an object, that might cause fiery death when using the serialized value for an array key.
Parameters: - $name (string|array) – Filter name.
Returns: string Key for filter indexing.
- getFilters(string|array $hookName)¶
Return all the filters for a specific hook in the correct order of execution.
Parameters: - $hookName (string|array) – Filter name.
Returns: array Indexed array of filter callbacks.
- clearFilters(string|null $name)¶
Clear all implementations for a filter (or all filters).
Parameters: - $name (string|null) – The name of the filter to clear. If null or omitted, all filters will be cleared.
Returns: void
- applyFilters(mixed $name, mixed $value, array $args = Array)¶
Run an arbitrary value through a set of filters.
Parameters: - $name (mixed) – The filter name.
- $value (mixed) – The value to filter.
- $args (array) – Additional arguments to pass to filter implementations.
Returns: mixed Result of applying filters to $value.
- register()¶
Register the plugin broker so that plugin writers can use global functions like add_plugin_hook() to interact with the plugin API.
Returns: void
Omeka_Plugin_Exception¶
- class Omeka_Plugin_Exception¶
Package: Plugin
Exception type thrown by the Omeka_Plugin class.
- property message¶
- property string¶
- property code¶
- property file¶
- property line¶
- property trace¶
- property previous¶
- __clone()¶
- __construct($message, $code, $previous)¶
Parameters: - $message (unknown) –
- $code (unknown) –
- $previous (unknown) –
- getMessage()¶
- getCode()¶
- getFile()¶
- getLine()¶
- getTrace()¶
- getPrevious()¶
- getTraceAsString()¶
- __toString()¶
Omeka_Plugin_Factory¶
- class Omeka_Plugin_Factory¶
Package: Plugin
Responsible for creating a set of Plugin records corresponding to plugins that have not been installed yet.
- property _basePath¶
Base path for plugins; the plugin directory
- __construct(string $basePath)¶
Parameters: - $basePath (string) – Plugin base directory.
- getNewPlugins(array $existingPlugins)¶
Retrieve all new plugins in the plugin directory.
Parameters: - $existingPlugins (array) – An array of existing Plugin objects.
Returns: array An array of Plugin objects for the new plugins.
- _getDirectoryList()¶
Retrieve an array of all the plugins in the plugin directory. A plugin is considered to be present when a directory includes a plugin.php file or has a valid plugin class.
Returns: array A list of valid plugin directory names.
Omeka_Plugin_Ini¶
- class Omeka_Plugin_Ini¶
Package: Plugin
Responsible for parsing the plugin.ini file for any given plugin.
- property _pluginsRootDir¶
Plugins directory.
- property _configs¶
Set of Zend_Config_Ini objects corresponding to each plugin.
- __construct(string $pluginsRootDir)¶
Parameters: - $pluginsRootDir (string) – Plugins directory.
- getPluginIniValue(string $pluginDirName, string $iniKeyName)¶
Retrieve a value in plugin.ini for a given key.
Will return a null value if no value can be found in the ini file for thekey.
Parameters: - $pluginDirName (string) – Plugin name.
- $iniKeyName (string) – INI key to retrieve.
Returns: string|null Retrieved INI value (null if not found).
- hasPluginIniFile(string $pluginDirName)¶
Return whether a plugin has a plugin.ini file
Parameters: - $pluginDirName (string) – Plugin name.
Returns: boolean
- getPluginIniFilePath(string $pluginDirName)¶
Return the path to the plugin.ini file
Parameters: - $pluginDirName (string) – Plugin name.
Returns: string
Omeka_Plugin_Installer¶
- class Omeka_Plugin_Installer¶
Package: Plugin\Installer
Changes the state of any given plugin (installed/uninstalled/activated/deactivated)
- property _broker¶
Plugin broker object.
- property _loader¶
Plugin loader object.
- __construct(Omeka_Plugin_Broker $broker, Omeka_Plugin_Loader $loader)¶
Parameters: - $broker (Omeka_Plugin_Broker) – Plugin broker object.
- $loader (Omeka_Plugin_Loader) – Plugin loader object.
- activate(Plugin $plugin)¶
Activate a plugin.
Parameters: - $plugin (Plugin) – Plugin to activate.
Returns: void
- deactivate(Plugin $plugin)¶
Deactivate a plugin.
Parameters: - $plugin (Plugin) – Plugin to deactivate.
Returns: void
- upgrade(Plugin $plugin)¶
Upgrade a plugin.
This will activate the plugin, then run the ‘upgrade’ hook.
Parameters: - $plugin (Plugin) – Plugin to upgrade.
Returns: void
Omeka_Plugin_Loader¶
- class Omeka_Plugin_Loader¶
Package: Plugin\Loader
Loads plugins for any given request.
This will iterate through the plugins root directory and load all plugin.phpfiles by require()’ing them.
- property _broker¶
Plugin broker object.
- property _iniReader¶
Plugin INI reader object.
- property _mvc¶
Plugin MVC object.
- property _basePath¶
Plugins directory.
- property _plugins¶
An array of all plugins (installed or not) that are currently located in the plugins/ directory.
- __construct(Omeka_Plugin_Broker $broker, Omeka_Plugin_Ini $iniReader, Omeka_Plugin_Mvc $mvc, string $pluginsBaseDir)¶
Parameters: - $broker (Omeka_Plugin_Broker) – Plugin broker.
- $iniReader (Omeka_Plugin_Ini) – plugin.ini reader.
- $mvc (Omeka_Plugin_Mvc) – Plugin MVC object.
- $pluginsBaseDir (string) – Plugins directory.
- loadPlugins(array $plugins, boolean $force =)¶
Load a list of plugins.
Parameters: - $plugins (array) – List of Plugin records to load.
- $force (boolean) – If true, throws exceptions for plugins that cannot be loaded for some reason.
Returns: void
- registerPlugin(Plugin $plugin)¶
Register a plugin so that it can be accessed by other plugins (if necessary) during the load process.
There should only be a single instance of a plugin per directory name.Registering a plugin more than once, i.e. loading a plugin again after thefirst time failed, will not cause a problem as long as the same instancewas registered.
Parameters: - $plugin (Plugin) – Record of plugin to register.
Returns: void
- isRegistered(Plugin $plugin)¶
Return whether a plugin is registered or not.
Parameters: - $plugin (Plugin) –
Returns: boolean Whether the plugin is registered or not.
- load(Plugin $plugin, boolean $force =, array $pluginsWaitingToLoad = Array)¶
Load a plugin (and make sure the plugin API is available).
To be loaded, the plugin must be installed, active, and not have a newerversion. If loaded, the plugin will attempt to first load all plugins,both required and optional, that the plugin uses. However, it will notload a plugin that it uses if that plugin is not installed and activated.
Parameters: - $plugin (Plugin) –
- $force (boolean) – If true, throws exceptions if a plugin can’t be loaded.
- $pluginsWaitingToLoad (array) – Plugins waiting to be loaded
Returns: void
- _canLoad(Plugin $plugin, boolean $force)¶
Determine whether or not a plugin can be loaded. To be loaded, it must meet the following criteria: - Has a plugin.php file. - Is installed. - Is active. - Meets the minimum required version of Omeka (in plugin.ini). - Is not already loaded. - Does not have a new version available.
Parameters: - $plugin (Plugin) – Plugin to test.
- $force (boolean) – If true, throw an exception if the plugin can’t be loaded.
Returns: boolean
- hasPluginBootstrap(string|Plugin $pluginDirName)¶
Check whether a plugin has a bootstrap file.
Parameters: - $pluginDirName (string|Plugin) –
Returns: boolean
- getPluginClassName(string $pluginDirName)¶
Return the valid plugin class name.
Parameters: - $pluginDirName (string) –
Returns: string
- getPluginFilePath(string $pluginDirName)¶
Return the path to the plugin.php file.
Parameters: - $pluginDirName (string) –
Returns: string
- getPluginClassFilePath(string $pluginDirName)¶
Return the path to the plugin class file.
Parameters: - $pluginDirName (string) –
Returns: string
- getPlugins()¶
Return a list of all the plugins that have been loaded (or attempted to be loaded) thus far.
Returns: array List of Plugin objects.
- getPlugin(string $directoryName)¶
Get a plugin object by name (plugin subdirectory name).
Parameters: - $directoryName (string) – Plugin name.
Returns: Plugin|null
Omeka_Plugin_Mvc¶
- class Omeka_Plugin_Mvc¶
Package: Plugin
Connects plugins with Omeka’s model-view-controller system.
- property _basePath¶
Path to the root plugins directory.
- property _pluginViewDirs¶
View script directories that have been added by plugins.
- property _pluginHelpersDirs¶
View helper directories from plugins.
- __construct(string $basePath)¶
Parameters: - $basePath (string) – Plugins directory path.
- addThemeDir(string $pluginDirName, string $path, string $themeType, string $moduleName)¶
Add a theme directory to the list of plugin-added view directories.
Used by the add_theme_pages() helper to create a list of directories thatcan store static pages that integrate into the themes.
Parameters: - $pluginDirName (string) – Plugin name.
- $path (string) – Path to directory to add.
- $themeType (string) – Type of theme (‘public’, ‘admin’, or ‘shared’).
- $moduleName (string) – MVC module name.
Returns: void
- getModuleViewScriptDirs(string $moduleName)¶
Retrieve the list of plugin-added view script directories.
Parameters: - $moduleName (string) – (optional) MVC module name.
Returns: array List of indexed directory names.
- getHelpersDirs()¶
Get all the existing plugin view helper dirs, indexed by plugin name.
Returns: array
- addControllerDir(string $pluginDirName, string $moduleName)¶
Make an entire directory of controllers available to the front controller.
This has to use addControllerDirectory() instead of addModuleDirectory()because module names are case-sensitive and module directories need to belowercased to conform to Zend’s weird naming conventions.
Parameters: - $pluginDirName (string) – Plugin name.
- $moduleName (string) – MVC module name.
Returns: void
- addApplicationDirs(string $pluginDirName)¶
Set up the following directory structure for plugins:
controllers/models/libraries/views/admin/public/shared/
This also adds these folders to the correct include paths.
Parameters: - $pluginDirName (string) – Plugin name.
Returns: void
- _getModuleName(string $pluginDirName)¶
Retrieve the module name for the plugin (based on the directory name of the plugin).
Parameters: - $pluginDirName (string) – Plugin name.
Returns: string Plugin MVC module name.
- _hasIncludePath(string $path)¶
Check include path to see if it already contains a specific path.
Parameters: - $path (string) –
Returns: boolean
Libraries/Omeka/Plugin/Installer¶
Omeka_Plugin_Installer_Exception¶
- class Omeka_Plugin_Installer_Exception¶
Package: Plugin\Installer
An exception thrown when the plugin installer is unable to install, uninstall, activate, deactivate, or upgrade a plugin.
- property message¶
- property string¶
- property code¶
- property file¶
- property line¶
- property trace¶
- property previous¶
- __clone()¶
- __construct($message, $code, $previous)¶
Parameters: - $message (unknown) –
- $code (unknown) –
- $previous (unknown) –
- getMessage()¶
- getCode()¶
- getFile()¶
- getLine()¶
- getTrace()¶
- getPrevious()¶
- getTraceAsString()¶
- __toString()¶
Libraries/Omeka/Plugin/Loader¶
Omeka_Plugin_Loader_Exception¶
- class Omeka_Plugin_Loader_Exception¶
Package: Plugin\Loader
An exception thrown when the plugin loader is unable to load a plugin.
- property message¶
- property string¶
- property code¶
- property file¶
- property line¶
- property trace¶
- property previous¶
- __clone()¶
- __construct($message, $code, $previous)¶
Parameters: - $message (unknown) –
- $code (unknown) –
- $previous (unknown) –
- getMessage()¶
- getCode()¶
- getFile()¶
- getLine()¶
- getTrace()¶
- getPrevious()¶
- getTraceAsString()¶
- __toString()¶
Libraries/Omeka/Record¶
Omeka_Record_AbstractRecord¶
- class Omeka_Record_AbstractRecord¶
Package: Record
A base class for domain objects, inspired by, though not strictly adherent to, the ActiveRecord pattern.
- property id¶
Unique ID for the record.
All implementations of Omeka_Record_AbstractRecord must have a table containing an ‘id’ column, preferably as the primary key.
- property _errors¶
Any errors raised during the validation process.
- property _cache¶
An in-memory cache for related objects that have been retrieved via the magic __get() syntax.
- property _mixins¶
Set of Omeka_Record_Mixin_AbstractMixin objects that are designed to extend the behavior of Omeka_Record_AbstractRecord implementations.
Examples include {@link Taggable}, {@link Relatable},{@link ActsAsElementText}, etc.
- property _db¶
Key/value pairs indicating aliases for methods that retrieve related data objects. For example, a subclass might define the following: <code> protected $_related = array(‘Sections’=>’loadSections’); </code> This would allow the client to write code like: <code> $sections = $subclassInstance->Sections; </code> Which would be equivalent to: <code> $sections = $subclassInstance->loadSections(); </code> The difference being, the former is cached so as to avoid multiple trips to the database.
- property _postData¶
Storage for the POST data when handling a form.
- property _locked¶
Whether or not the record is locked. Locked records cannot be saved.
- property _eventCallbacks¶
List of built in callback methods.
- property _pluginBroker¶
- __construct(Omeka_Db|null $db)¶
Parameters: - $db (Omeka_Db|null) – (optional) Defaults to the Omeka_Db instance from the bootstrap.
- construct()¶
Subclass constructor behavior.
Subclasses of Omeka_Record_AbstractRecord can override this function toadd behavior to the constructor without overriding __construct.
Returns: void
- __destruct()¶
Unsets mixins, which contain circular references, upon record destruction
IMPORTANT: Solves a memory leak when retrieving/saving records.
Required because PHP 5.2 does not do garbage collection on circular references.
- __get(string $prop)¶
Retrieve database records that are associated with the current one.
Parameters: - $prop (string) – Related data to retrieve.
Returns: mixed
- __call(string $m, array $a)¶
Delegate unknown method calls to Omeka_Record_Mixin_AbstractMixin instances.
Parameters: - $m (string) – Method name.
- $a (array) – Method arguments.
Returns: mixed
- _initializeMixins()¶
Initialize the mixins for a record.
Any Omeka_Record_AbstractRecord subclass that uses mixins shouldinitialize them here, since this is called on construction and whenmixins need to be reinitialized.
- delegateToMixins(string $method, array $args = Array, boolean $all =)¶
Delegate to the given method in one or more mixin instances.
Parameters: - $method (string) –
- $args (array) –
- $all (boolean) – (optional) Whether or not to call the same method on every mixin instance that has that method. Defaults to false.
Returns: mixed If $all is false, the return value from the invoked method. Otherwise there is no return value.
- runCallbacks($event, $args = Array)¶
Invoke all callbacks associated with a specific record event.
Callbacks execute in the following order:- Omeka_Record_AbstractRecord hooks like Omeka_Record_AbstractRecord::afterDelete()- Record mixin hooks like Taggable::afterSave()- Generic record plugin hooks like ‘before_delete_record’- Specific record plugin hooks like ‘before_delete_item’
Parameters: - $event (unknown) –
- $args (unknown) –
- _addToCache(mixed $value, string $key)¶
Add a value to the record-specific cache.
Parameters: - $value (mixed) –
- $key (string) –
Returns: void
- _getCached(string $name)¶
Get a value from the record-specific cache.
Parameters: - $name (string) –
Returns: mixed
- getProperty(string $property)¶
Get a property about the record for display purposes.
Parameters: - $property (string) – Property to get. Always lowercase.
Returns: mixed
- exists()¶
Determine whether or not this record is persistent in the database.
For simplicity, non-persistent records are indicated by the lack of avalue for the ‘id’ column.
Returns: boolean
- _validate()¶
Template method for defining record validation rules.
Should be overridden by subclasses.
Returns: void
- isValid()¶
Determine whether or not the record is valid.
Returns: boolean
- getErrors()¶
Retrieve validation errors associated with this record.
Returns: Omeka_Validate_Errors
- hasErrors()¶
Determine whether or not this record has any validation errors.
Returns: boolean
- addError(string|null $field, string $msg)¶
Add a validation error for a specific field.
Currently limited to a single error per field, so multiple error messagesmust be concatenated together.
Parameters: - $field (string|null) – Name of the field. This can be null to indicate a general error not associated with a specific field.
- $msg (string) – The error message.
Returns: void
- addErrorsFrom(Omeka_Record_AbstractRecord $record)¶
Combine errors from a different Omeka_Record_AbstractRecord instance with the errors already on this record.
Parameters: - $record (Omeka_Record_AbstractRecord) –
Returns: void
- lock()¶
Prevent a record from being modified.
Can be used to prevent accidentally saving/deleting a record if its state maychange but saving would be undesirable, such as modifying a record fordisplay purposes.
Returns: void
- getTable($class)¶
Retrieve the Omeka_Db_Table instance associated with this record, or with that of any given record class.
Parameters: - $class (unknown) –
Returns: Omeka_Db_Table
- getDb()¶
Retrieve the Omeka_Db instance associated with this record.
Returns: Omeka_Db
- toArray()¶
Retrieve an associative array of all the record’s columns and their values.
Returns: array
- save(boolean $throwIfInvalid = 1)¶
Save the record.
Parameters: - $throwIfInvalid (boolean) –
Returns: boolean Whether the save was successful.
- __clone()¶
Clone the record.
Unsets the ID so the cloned record can be saved on its own.
- delete()¶
Delete the record.
Returns: void
- _delete()¶
Template method for defining record deletion logic.
Subclasses can override this method to define additional logic for deletingrecords. Note that this is different from both the beforeDelete() andafterDelete() hooks in that it executes after beforeDelete(), but beforethe record is actually deleted.
Common use cases include emulating cascading deletes with otherdatabase rows.
Returns: void
- beforeSave($args)¶
Executes before the record is saved.
Parameters: - $args (unknown) –
- afterSave($args)¶
Executes after the record is inserted.
Parameters: - $args (unknown) –
- beforeDelete()¶
Executes before the record is deleted.
- afterDelete()¶
Executes after the record is deleted.
- setArray(array|Traversable $data)¶
Set values for the record using an associative array or iterator.
Parameters: - $data (array|Traversable) –
Returns: void
- getPluginBroker()¶
- setPluginBroker($broker)¶
Parameters: - $broker (unknown) –
- offsetExists(string $name)¶
Determine whether or not the given field has a value associated with it.
Required by ArrayAccess.
Parameters: - $name (string) –
Returns: boolean
- offsetUnset(string $name)¶
Unset the given field.
Required by ArrayAccess.
Parameters: - $name (string) –
Returns: void
- offsetGet(string $name)¶
Retrieve the value of a given field.
Required by ArrayAccess.
Parameters: - $name (string) –
Returns: mixed
- offsetSet(string $name, mixed $value)¶
Set the value of a given field.
Required by ArrayAccess.
Parameters: - $name (string) –
- $value (mixed) –
Returns: void
- filterPostData(array $post)¶
Filter the form input according to some criteria.
Template method should be overridden by subclasses that wish to implementsome sort of filtering criteria.
Parameters: - $post (array) –
Returns: array Filtered post data.
- setPostData(array $post)¶
Set the POST data to the record.
Parameters: - $post (array) –
- fieldIsUnique(string $field, mixed $value)¶
Check uniqueness of one of the record’s fields.
Parameters: - $field (string) –
- $value (mixed) – Optional If null, this will check the value of the record’s $field. Otherwise check the uniqueness of this value for the given field.
Returns: boolean
- getRecordUrl(string $action = show)¶
Get the routing parameters or the URL string to this record.
The record_url() global uses this method to get routing parameters fornon-standard records, e.g. records defined by plugins. Subclasses shouldoverride this method if the default route (as defined below) isincorrect.
Parameters: - $action (string) –
Returns: string|array A URL string or a routing array.
Omeka_Record_Exception¶
- class Omeka_Record_Exception¶
Package: Record
- property message¶
- property string¶
- property code¶
- property file¶
- property line¶
- property trace¶
- property previous¶
- __clone()¶
- __construct($message, $code, $previous)¶
Parameters: - $message (unknown) –
- $code (unknown) –
- $previous (unknown) –
- getMessage()¶
- getCode()¶
- getFile()¶
- getLine()¶
- getTrace()¶
- getPrevious()¶
- getTraceAsString()¶
- __toString()¶
Omeka_Record_Iterator¶
- class Omeka_Record_Iterator¶
Package: Record
- property _records¶
- property _view¶
- property _currentRecordVar¶
- __construct(array $records, null|Zend_View_Abstract $view, null|string $currentRecordVar)¶
Construct the record iterator.
Parameters: - $records (array) –
- $view (null|Zend_View_Abstract) –
- $currentRecordVar (null|string) –
- rewind()¶
- current()¶
Return the current record, setting it to the view if applicable.
- key()¶
- next()¶
Release the previous record and advance the pointer to the next one.
- valid()¶
Libraries/Omeka/Record/Builder¶
Omeka_Record_Builder_AbstractBuilder¶
- class Omeka_Record_Builder_AbstractBuilder¶
Package: Record\Builder
Build or update an {@link Omeka_Record_AbstractRecord} as needed.
- property _recordClass¶
Class of record that the builder will create.
- property _settableProperties¶
String names denoting the properties of a specific record that can be set directly through the builder. This will not always be all of the fields for the record.
- property _metadataOptions¶
Parsed metadata options for the builder.
- property _record¶
Record being built or updated.
- property _db¶
- build()¶
Build the actual record. If the record already exists, update it as necessary.
Returns: Omeka_Record_AbstractRecord
- setRecordMetadata(array $metadata)¶
Set basic metadata for the record.
Note that the columns to be set must be specified in the $_settablePropertiesproperty of subclassed Builders.
Parameters: - $metadata (array) –
Returns: void
- getRecordMetadata()¶
Get the metadata that will be saved to the record.
Returns: array
- getRecord()¶
Get the record that is being acted upon by the builder.
When an Omeka_Record_AbstractRecord instance has been provided viasetRecord(), that will be returned. If a record ID has been provided,then the appropriate record will be returned.
Otherwise, a new instance of Omeka_Record_AbstractRecord will be returned.
Returns: Omeka_Record_AbstractRecord
- setRecord(Omeka_Record_AbstractRecord|integer|null $record)¶
Set the record upon which this builder will act.
Parameters: - $record (Omeka_Record_AbstractRecord|integer|null) –
Returns: void
- _beforeBuild(Omeka_Record_AbstractRecord $record)¶
All necessary tasks to take place before the record is inserted.
Exceptions may be thrown, validation errors may be added.
Parameters: - $record (Omeka_Record_AbstractRecord) –
Returns: void
- _afterBuild(Omeka_Record_AbstractRecord $record)¶
All necessary tasks that take place after the record has been inserted into the database.
Should not throw exceptions in this method.
Parameters: - $record (Omeka_Record_AbstractRecord) –
Returns: void
- _setRecordProperties(Omeka_Record_AbstractRecord $record)¶
Set the properties for the record, taking care to filter based on the $_settableProperties array.
Parameters: - $record (Omeka_Record_AbstractRecord) –
Returns: void
Omeka_Record_Builder_Exception¶
- class Omeka_Record_Builder_Exception¶
Package: Record\Builder
Exception thrown when there is an error creating a Record using {@link Omeka_Record_Builder_AbstractBuilder}.
- property message¶
- property string¶
- property code¶
- property file¶
- property line¶
- property trace¶
- property previous¶
- __clone()¶
- __construct($message, $code, $previous)¶
Parameters: - $message (unknown) –
- $code (unknown) –
- $previous (unknown) –
- getMessage()¶
- getCode()¶
- getFile()¶
- getLine()¶
- getTrace()¶
- getPrevious()¶
- getTraceAsString()¶
- __toString()¶
Libraries/Omeka/Record/Mixin¶
Omeka_Record_Mixin_AbstractMixin¶
- class Omeka_Record_Mixin_AbstractMixin¶
Package: Record\Mixin
Represents a kind of mixin for Omeka_Record_AbstractRecord implementations.
Any methods declared for an implementation of this class can be calledtransparently by an Omeka_Record_AbstractRecord object that uses one of thesemodules.
For instance, the Item model does not have an addTags() method, but theTaggable class does. Since Item declares Taggable as one of its modules,an Item instance call all of Taggable’s methods, so that adding tags would beas simple as calling $item->addTags(‘foo, bar’);
Note that this is not a true mixin because it cannot override any existingmethods on a Record object.
- property _record¶
Underlying record object.
- __construct(Omeka_Record_AbstractRecord $record)¶
Base mixin constructor.
Store the underlying record for use in the mixin.
Parameters: - $record (Omeka_Record_AbstractRecord) –
- beforeSave($args)¶
Callback automatically called by Omeka_Record_AbstractRecord.
See the corresponding {@link Omeka_Record_AbstractRecord} method fordefinitions of call times.
Parameters: - $args (unknown) –
Returns: void
- afterSave($args)¶
Parameters: - $args (unknown) –
- beforeDelete()¶
- afterDelete()¶
Libraries/Omeka/Session¶
Libraries/Omeka/Session/SaveHandler¶
Omeka_Session_SaveHandler_DbTable¶
- class Omeka_Session_SaveHandler_DbTable¶
Package: Session
Wrapper for Zend_Session_SaveHandler_DbTable to hard code the table definition. This boosts performance by skipping the DESCRIBE query that retrieves this metadata by default.
Note that this must be updated meticulously after any changes to thesessions table schema.
- init()¶
Libraries/Omeka/Storage¶
Omeka_Storage_Exception¶
- class Omeka_Storage_Exception¶
Package: Storage
- property message¶
- property string¶
- property code¶
- property file¶
- property line¶
- property trace¶
- property previous¶
- __clone()¶
- __construct($message, $code, $previous)¶
Parameters: - $message (unknown) –
- $code (unknown) –
- $previous (unknown) –
- getMessage()¶
- getCode()¶
- getFile()¶
- getLine()¶
- getTrace()¶
- getPrevious()¶
- getTraceAsString()¶
- __toString()¶
Libraries/Omeka/Storage/Adapter¶
Omeka_Storage_Adapter_AdapterInterface¶
- class Omeka_Storage_Adapter_AdapterInterface¶
Package: Storage\Adapter
Interface for file storage adapters.
Classes that implement this interface handle the actual work ofstoring andretrieving files.
- __construct(array $options)¶
Set options for the storage adapter.
Parameters: - $options (array) –
- setUp()¶
Follow any necessary steps to set up storage prior to use.
E.g. for the filesystem adapter, this would include creating anydirectories that did not already exist. For S3, it might involvecreating a new bucket if it did not exist.
- canStore()¶
Check whether the adapter is set up correctly to be able to store files.
Returns: boolean
- store(string $source, string $dest)¶
Move a local file to “storage.”
Parameters: - $source (string) – Local filesystem path to file.
- $dest (string) – Destination path.
- move(string $source, string $dest)¶
Move a file between two storage locations.
Parameters: - $source (string) – Original storage path.
- $dest (string) – Destination storage path.
- delete(string $path)¶
Remove a “stored” file.
Parameters: - $path (string) –
- getUri(string $path)¶
Get a URI for a “stored” file.
Parameters: - $path (string) –
Returns: string URI
Omeka_Storage_Adapter_Filesystem¶
- class Omeka_Storage_Adapter_Filesystem¶
Package: Storage\Adapter
Standard local filesystem storage adapter.
The default adapter; this stores files in the Omeka files directory bydefault, but can be set to point to a different path.
- property _localDir¶
Local directory where files are stored.
- property _subDirs¶
- property _webDir¶
Web-accesible path that corresponds to $_localDir.
- __construct(array $options = Array)¶
Set options for the storage adapter.
Parameters: - $options (array) –
- setUp()¶
- canStore()¶
Check whether the adapter is set up correctly to be able to store files.
Specifically, this checks to see if the local storage directoryis writable.
Returns: boolean
- store(string $source, string $dest)¶
Move a local file to “storage.”
Parameters: - $source (string) – Local filesystem path to file.
- $dest (string) – Destination path.
- move(string $source, string $dest)¶
Move a file between two “storage” locations.
Parameters: - $source (string) – Original stored path.
- $dest (string) – Destination stored path.
- delete(string $path)¶
Remove a “stored” file.
Parameters: - $path (string) –
- getUri(string $path)¶
Get a URI for a “stored” file.
Parameters: - $path (string) –
Returns: string URI
- getOptions()¶
Return the options set by the adapter. Used primarily for testing.
- setLocalDir($dir)¶
Parameters: - $dir (unknown) –
- _getAbsPath(string $path)¶
Convert a “storage” path to an absolute filesystem path.
Parameters: - $path (string) – Storage path.
Returns: string Absolute local filesystem path.
- _rename($source, $dest)¶
Parameters: - $source (unknown) –
- $dest (unknown) –
Returns: boolean
Omeka_Storage_Adapter_TempFilesystem¶
- class Omeka_Storage_Adapter_TempFilesystem¶
Package: Storage\Adapter
Storage adapter that uses the system temp directory for its filesystem.
After the adapter is no longer needed (__destruct()), all the files that were created during its lifetime are removed.
Used primarily by the test framework.
- property _localDir¶
Local directory where files are stored.
- property _subDirs¶
- property _webDir¶
Web-accesible path that corresponds to $_localDir.
- canStore()¶
No need to perform this check.
- store(string $source, string $dest)¶
Move a local file to “storage.”
Parameters: - $source (string) – Local filesystem path to file.
- $dest (string) – Destination path.
- move(string $source, string $dest)¶
Move a file between two “storage” locations.
Parameters: - $source (string) – Original stored path.
- $dest (string) – Destination stored path.
- getUri($path)¶
Parameters: - $path (unknown) –
- _mkdir($filepath)¶
Parameters: - $filepath (unknown) –
- __construct(array $options = Array)¶
Set options for the storage adapter.
Parameters: - $options (array) –
- setUp()¶
- delete(string $path)¶
Remove a “stored” file.
Parameters: - $path (string) –
- getOptions()¶
Return the options set by the adapter. Used primarily for testing.
- setLocalDir($dir)¶
Parameters: - $dir (unknown) –
- _getAbsPath(string $path)¶
Convert a “storage” path to an absolute filesystem path.
Parameters: - $path (string) – Storage path.
Returns: string Absolute local filesystem path.
- _rename($source, $dest)¶
Parameters: - $source (unknown) –
- $dest (unknown) –
Returns: boolean
Omeka_Storage_Adapter_ZendS3¶
- class Omeka_Storage_Adapter_ZendS3¶
Package: Storage\Adapter
Cloud storage adapter for Amazon S3, using Zend’s built-in service.
Caveat: Zend’s storage adapter currently does not function correctlywith buckets that are validly-named, but use characters that cannotappear in domain names.
- property _s3¶
- property _options¶
- __construct(array $options = Array)¶
Set options for the storage adapter.
Parameters: - $options (array) –
- setUp()¶
- canStore()¶
- store(string $source, string $dest)¶
Move a local file to S3 storage.
Parameters: - $source (string) – Local filesystem path to file.
- $dest (string) – Destination path.
- move(string $source, string $dest)¶
Move a file between two “storage” locations.
Parameters: - $source (string) – Original stored path.
- $dest (string) – Destination stored path.
- delete(string $path)¶
Remove a “stored” file.
Parameters: - $path (string) –
- getUri(string $path)¶
Get a URI for a “stored” file.
Parameters: - $path (string) –
Returns: string URI
- _getBucketName()¶
Get the name of the bucket files should be stored in.
Returns: string Bucket name
- _getObjectName(string $path)¶
Get the object name. Zend’s S3 service requires you to build the object name by prepending the name of the target bucket.
Parameters: - $path (string) –
Returns: string Object name.
- _getExpiration()¶
Normalizes and returns the expiration time.
Converts to integer and returns zero for all non-positive numbers.
Returns: int
Libraries/Omeka/Test¶
Omeka_Test_AppTestCase¶
- class Omeka_Test_AppTestCase¶
Package: Test
Abstract test case class that bootstraps the entire application.
- property _isAdminTest¶
Flag that determines whether the test should run against admin or public. Defaults to true (for admin).
- setUp()¶
Bootstrap the application on each test run.
Returns: void
- __get(string $property)¶
Proxy gets to properties to allow access to bootstrap container properties.
Parameters: - $property (string) –
Returns: mixed
- appBootstrap()¶
Bootstrap the application.
Returns: void
- setUpBootstrap(Zend_Application_Bootstrap $bootstrap)¶
Subclasses can override this to perform specialized setup on the Omeka application.
Parameters: - $bootstrap (Zend_Application_Bootstrap) –
Returns: void
- tearDown()¶
Reset objects that carry global state between test runs.
Returns: void
- dispatch(string $url, boolean $throwExceptions = 1)¶
Parameters: - $url (string) –
- $throwExceptions (boolean) –
Returns: void
- _authenticateUser(User $user)¶
Trick the environment into thinking that a user has been authenticated.
Parameters: - $user (User) –
Returns: void
- _getDefaultUser()¶
Get the user that is installed by default.
Returns: User
- _setUpThemeBootstrap($themeType)¶
Set up the bootstrap differently depending on whether the test is meant for the public or admin themes.
Parameters: - $themeType (unknown) –
Omeka_Test_Bootstrap¶
- class Omeka_Test_Bootstrap¶
Package: Test
Abstract test case class that bootstraps the entire application.
- property _container¶
- setContainer($container)¶
Set resource container
By default, if a resource callback has a non-null return value, thisvalue will be stored in a container using the resource name as thekey.
Containers must be objects, and must allow setting public properties.
Parameters: - $container (unknown) –
Returns: Zend_Application_Bootstrap_BootstrapAbstract
- getContainer()¶
Retrieve resource container
Returns: object
- hasResource($name)¶
Determine if a resource has been stored in the container
During bootstrap resource initialization, you may return a value. Ifyou do, it will be stored in the {@link setContainer() container}.You can use this method to determine if a value was stored.
Parameters: - $name (unknown) –
Returns: bool
- getResource($name)¶
Retrieve a resource from the container
During bootstrap resource initialization, you may return a value. Ifyou do, it will be stored in the {@link setContainer() container}.You can use this method to retrieve that value.
If no value was returned, this will return a null value.
Parameters: - $name (unknown) –
Returns: null|mixed
Libraries/Omeka/Test/Helper¶
Omeka_Test_Helper_Db¶
- class Omeka_Test_Helper_Db¶
Package: Test\Helper
Catch-all class for database helper methods that are shared across test cases.
- property _dbAdapter¶
Database adapter object.
- property _prefix¶
- __construct(Zend_Db_Adapter_Abstract $dbAdapter, $prefix)¶
Parameters: - $dbAdapter (Zend_Db_Adapter_Abstract) –
- $prefix (unknown) –
- __call(string $method, array $args)¶
Proxy to the db adapter object for all other requests.
Parameters: - $method (string) – Method name.
- $args (array) – Method arguments.
Returns: array
- factory($dbConfig)¶
Create an instance of the helper that is configured for the correct database.
Parameters: - $dbConfig (unknown) –
- tableExists(string $tableName)¶
Check whether a table exists in the database.
Parameters: - $tableName (string) –
Returns: boolean
- getTableCount(string $prefix)¶
Get the number of tables in the database.
Parameters: - $prefix (string) –
Returns: integer
- dropTables($tables)¶
Drop the tables from the database.
Parameters: - $tables (unknown) –
Returns: void
- truncateTables($tables)¶
Truncate the tables from the database.
Parameters: - $tables (unknown) –
Returns: void
- install()¶
- getTableNames()¶
Get the tables in the database.
Returns: array
- getRowCount(string $tableName)¶
Get the number of rows in a table.
Parameters: - $tableName (string) –
Returns: integer
- getAdapter()¶
- getPrefix()¶
Omeka_Test_Helper_DbProfiler¶
- class Omeka_Test_Helper_DbProfiler¶
Package: Test\Helper
Catch-all class for database helper methods that are shared across test cases.
- property _profiler¶
- property _test¶
- __construct(Zend_Db_Profiler $profiler, PHPUnit_Framework_Assert $test)¶
Constructor.
Parameters: - $profiler (Zend_Db_Profiler) –
- $test (PHPUnit_Framework_Assert) –
- assertDbQuery($sqlPart, $message)¶
Parameters: - $sqlPart (unknown) –
- $message (unknown) –
- assertTotalNumQueries(integer $queryCount, $msg)¶
Assert that the given number of SQL queries were made.
Parameters: - $queryCount (integer) –
- $msg (unknown) –
Omeka_Test_Helper_Mail¶
- class Omeka_Test_Helper_Mail¶
Package: Test\Helper
Encapsulates testing functionality for email.
- property _path¶
Path to the mail storage directory.
- __construct(string $path)¶
Parameters: - $path (string) – Real path to the mail storage directory.
- factory()¶
Configure an instance of the Mail helper using the registered test_config.
Returns: Omeka_Test_Helper_Mail
- _getIterator()¶
Get an iterator over the fakemail directory.
Returns: DirectoryIterator
- _isMailFile(SplFileInfo $file)¶
Check if a directory entry is a mail message file.
Parameters: - $file (SplFileInfo) –
Returns: boolean
- getMailText(integer $index = 0)¶
Return the text of the n’th email that was sent during the test.
Note that this will not return correct results if reset() was notinvoked between test runs.
Parameters: - $index (integer) –
Returns: string
- count()¶
The number of mails that have been sent.
Omeka_Test_Helper_Plugin¶
- class Omeka_Test_Helper_Plugin¶
Package: Test\Helper
Encapsulates testing functionality for Omeka plugins.
- setUp(string $pluginName)¶
Install and initialize a plugin.
Note: Normally used in the setUp() method of plugin tests.
Parameters: - $pluginName (string) –
- install(string $pluginName)¶
Install a plugin
Parameters: - $pluginName (string) – The name of the plugin to install.
Returns: Plugin
- initialize(string $pluginName)¶
Initializes the plugin hooks and filters fired in the core resources for a plugin Note: Normally used in the setUp() function of the subclasses that test plugins.
Parameters: - $pluginName (string) – If omitted, initialize all installed plugins.
Returns: void
- _defineResponseContexts()¶
Run the response_contexts filter.
Returns: void
- setPluginLoader(Omeka_Plugin_Loader $pluginLoader)¶
Set the plugin loader for the helper to use.
Parameters: - $pluginLoader (Omeka_Plugin_Loader) –
- setPluginIniReader(Omeka_Plugin_Ini $pluginIniReader)¶
Set the plugin INI reader for the helper to use.
Parameters: - $pluginIniReader (Omeka_Plugin_Ini) –
- setPluginBroker(Omeka_Plugin_Broker $pluginBroker)¶
Set the plugin broker for the helper to use.
Parameters: - $pluginBroker (Omeka_Plugin_Broker) –
- setAcl(Zend_Acl $acl)¶
Set the ACL for the helper to use.
Parameters: - $acl (Zend_Acl) –
- setRouter(Zend_Controller_Router_Interface $router)¶
Set the router for the helper to use.
Parameters: - $router (Zend_Controller_Router_Interface) –
- __get($name)¶
Lazy-loading for helper properties.
When a property is not set, attempts to load a default through standardOmeka global state. If this state is unavailable or undesireable,use the set*() methods before calling any of the other public methodsof this class.
Parameters: - $name (unknown) –
Returns: mixed
Libraries/Omeka/Test/Resource¶
Omeka_Test_Resource_Config¶
- class Omeka_Test_Resource_Config¶
Package: Test\Resource
Load the default config for the application, but also load the test config into Zend_Registry.
- property _coreResource¶
- __construct(array $options)¶
Parameters: - $options (array) – Options for resource.
- init()¶
Load both config files.
Returns: Zend_Config
Omeka_Test_Resource_Currentuser¶
- class Omeka_Test_Resource_Currentuser¶
Package: Test\Resource
Mask the behavior of Omeka_Application_Resource_Currentuser in tests.
- init()¶
Omeka_Test_Resource_Db¶
- class Omeka_Test_Resource_Db¶
Package: Test\Resource
Set up the database test environment by wiping and resetting the database to a recently-installed state.
- property dropTables¶
Flag to determine whether the tables need to be dropped. This is a slow process, and really should only be happening once, when the tests are first run.
- property runInstaller¶
Flag to determine whether the installer needs to be run.
- property _cachedAdapter¶
Avoid issues with database connections not closing properly after each test run.
- init()¶
Load and initialize the database.
Returns: Omeka_Db
- getDb()¶
Returns: Omeka_Db
- useTestConfig()¶
- setInstall(boolean $flag)¶
Set the flag that indicates whether or not to run the installer during init().
Parameters: - $flag (boolean) –
- getDbAdapter()¶
- setDbAdapter(Zend_Db_Adapter_Abstract $dbAdapter)¶
Parameters: - $dbAdapter (Zend_Db_Adapter_Abstract) –
Omeka_Test_Resource_Debug¶
- class Omeka_Test_Resource_Debug¶
Package: Test\Resource
Stub resource to mask the behavior of Omeka_Application_Resource_Debug.
- init()¶
Omeka_Test_Resource_Mail¶
- class Omeka_Test_Resource_Mail¶
Package: Test\Resource
Testing resource for saving mail to the filesystem.
- init()¶
Returns: Zend_Mail
- mailCallback($transport)¶
Makes mail output names contain both the timestamp and an incrementing counter. The timestamp ensures mails between test runs don’t collide, the counter differentiates between messages sent during the same timestamp unit (common).
Parameters: - $transport (unknown) –
Omeka_Test_Resource_Storage¶
- class Omeka_Test_Resource_Storage¶
Package: Test\Resource
Bootstrap resource for storage in test environment.
- init()¶
Omeka_Test_Resource_Tempdir¶
- class Omeka_Test_Resource_Tempdir¶
Package: Test\Resource
Bootstrap resource for storage in test environment.
- init()¶
- cleanDir($dir)¶
Parameters: - $dir (unknown) –
Libraries/Omeka/Validate¶
Omeka_Validate_Confirmation¶
- class Omeka_Validate_Confirmation¶
Package: Validate
Adapted from Zend Framework documentation on custom validators.
- constant NOT_MATCH¶
Error message for non-matching confirmation.
- property _field¶
Field needing confirmation.
- property _messageTemplates¶
Error messages.
- property _messageVariables¶
Error message replace variables.
- __construct($field)¶
Sets validator options
Parameters: - $field (unknown) –
- isValid(string $value, string|array $context)¶
Check that the value is valid.
Parameters: - $value (string) –
- $context (string|array) –
Returns: boolean
- getField()¶
Get the name of the field that needs confirmation.
Returns: string
- setField(string $field)¶
Set the name of the field that needs confirmation.
Parameters: - $field (string) –
Returns: void
Omeka_Validate_Errors¶
- class Omeka_Validate_Errors¶
Package: Validate
This is an object wrapper for validation errors. The primary advantage to having this class is that casting it to a string will convert the errors into a nicely formatted, human-readable string.
- property _errors¶
List of validation errors.
- __construct(array|null $errors)¶
Parameters: - $errors (array|null) – Initial errors to set.
- offsetGet(mixed $key)¶
Get an error from the list. Required by ArrayObject.
Parameters: - $key (mixed) – Key into array.
- offsetSet(mixed $key, mixed $val)¶
Set an error into the list. Required by ArrayObject.
Parameters: - $key (mixed) – Key into array.
- $val (mixed) – Value to store.
- get()¶
Get the array of errors.
Returns: array
- count()¶
Get the number of errors.
Returns: integer
- __toString()¶
Get a string representation of all the stored errors.
Returns: string
- offsetExists($index)¶
Parameters: - $index (unknown) –
- offsetUnset($index)¶
Parameters: - $index (unknown) –
- append($value)¶
Parameters: - $value (unknown) –
- getArrayCopy()¶
- getFlags()¶
- setFlags($flags)¶
Parameters: - $flags (unknown) –
- asort()¶
- ksort()¶
- uasort($cmp_function)¶
Parameters: - $cmp_function (unknown) –
- uksort($cmp_function)¶
Parameters: - $cmp_function (unknown) –
- natsort()¶
- natcasesort()¶
- unserialize($serialized)¶
Parameters: - $serialized (unknown) –
- serialize()¶
- getIterator()¶
- exchangeArray($array)¶
Parameters: - $array (unknown) –
- setIteratorClass($iteratorClass)¶
Parameters: - $iteratorClass (unknown) –
- getIteratorClass()¶
Omeka_Validate_Exception¶
- class Omeka_Validate_Exception¶
Package: Validate
Exception that is thrown when a form could not be validated correctly.
- property _errors¶
Message representing form errors.
- property message¶
- property string¶
- property code¶
- property file¶
- property line¶
- property trace¶
- property previous¶
- __construct($errors)¶
Parameters: - $errors (unknown) –
Returns: void
- getErrors()¶
Get the error message that caused this exception.
Returns: string
- __clone()¶
- getMessage()¶
- getCode()¶
- getFile()¶
- getLine()¶
- getTrace()¶
- getPrevious()¶
- getTraceAsString()¶
- __toString()¶
Omeka_Validate_Uri¶
- class Omeka_Validate_Uri¶
Package: Validate
Adapted from: http://www.techchorus.net/validate-uri-form-fields-zend-framework-custom-validator
- property _messageTemplates¶
- isValid($value)¶
Parameters: - $value (unknown) –
Omeka_Validate_UserPassword¶
- class Omeka_Validate_UserPassword¶
Package: Validate
Validate a password to see if it matches that of an existing user.
- constant INVALID¶
Invalid password error.
- property _messageTemplates¶
Error message templates.
- property _user¶
User to check the password against.
- isValid(string $value, null $context)¶
Validate against a user’s stored password.
Parameters: - $value (string) – Password to check.
- $context (null) – Not used.
Libraries/Omeka/Validate/File¶
Omeka_Validate_File_Extension¶
- class Omeka_Validate_File_Extension¶
Package: Validate
Define custom behavior for the default whitelist file extension validator.
Baseline behavior of this class is to tweak the default error messages.Messages are intentionally as detailed as possible. Note that it is theresponsibility of plugin writers to suppress or replace these messages ifnecessary for security reasons, e.g. if displaying it to the end user mightexpose the site to vulnerability probes.
- property _messageTemplates¶
Overrides default error message templates.
- property _targetExtension¶
The extension of the file being validated
- __construct(mixed $options)¶
Constructor retrieves the whitelist from the database if no arguments are given.
Parameters: - $options (mixed) –
Returns: void
- isValid(string $value, array $file)¶
Returns true if and only if the fileextension of $value is included in the set extension list.
Parameters: - $value (string) – Real file to check for extension.
- $file (array) – File data from Zend_File_Transfer.
Returns: boolean
Omeka_Validate_File_MimeType¶
- class Omeka_Validate_File_MimeType¶
Package: Validate
Validates files against a MIME type whitelist.
- property _messageTemplates¶
- property _messageVariables¶
- property _customWhitelist¶
- property _file¶
- property _mimeType¶
- __construct()¶
Construct the validator object.
- isValid(string $file)¶
Vaidate the file MIME type.
Parameters: - $file (string) –
Returns: bool
Libraries/Omeka/View¶
Omeka_View_Exception¶
- class Omeka_View_Exception¶
Package: View
Exceptions thrown by Omeka view code and helpers.
- property message¶
- property string¶
- property code¶
- property file¶
- property line¶
- property trace¶
- property previous¶
- __clone()¶
- __construct($message, $code, $previous)¶
Parameters: - $message (unknown) –
- $code (unknown) –
- $previous (unknown) –
- getMessage()¶
- getCode()¶
- getFile()¶
- getLine()¶
- getTrace()¶
- getPrevious()¶
- getTraceAsString()¶
- __toString()¶