Omeka_Controller_AbstractActionController

Package: Controller

class Omeka_Controller_AbstractActionController

extends Zend_Controller_Action

Base class for Omeka controllers.

Provides basic create, read, update, and delete (CRUD) operations.

property Omeka_Controller_AbstractActionController::$_browseRecordsPerPage

protected string

The number of records to browse per page.

If this is left null, then results will not paginate. This is partially because not every controller will want to paginate records and also to avoid BC breaks for plugins.

Setting this to self::RECORDS_PER_PAGE_SETTING will cause the admin-configured page limits to be used (which is often what you want).

property Omeka_Controller_AbstractActionController::$_autoCsrfProtection

protected bool

Whether to automatically generate and check for a CSRF token on add and edit.

If set to true, a variable $csrf will be assigned to the add and edit views, you must echo it inside the form on those pages, or else the requests will fail.

Note: default deletion always uses a token, regardless of this setting.

Omeka_Controller_AbstractActionController::__construct(Zend_Controller_Request_Abstract $request, Zend_Controller_Response_Abstract $response, $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 should implement 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.
Omeka_Controller_AbstractActionController::indexAction()

Forward to the ‘browse’ action

Omeka_Controller_AbstractActionController::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);

Omeka_Controller_AbstractActionController::showAction()

Retrieve a single record and render it.

Every request to this action must pass a record ID in the ‘id’ parameter.

Omeka_Controller_AbstractActionController::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 data entry. Otherwise, if the $_POST exists and is valid, it will save the new record and redirect to the ‘browse’ action.

Omeka_Controller_AbstractActionController::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.

Omeka_Controller_AbstractActionController::deleteConfirmAction()

Ask for user confirmation before deleting a record.

Omeka_Controller_AbstractActionController::deleteAction()

Delete a record from the database.

Every request to this action must pass a record ID in the ‘id’ parameter.

Omeka_Controller_AbstractActionController::getCurrentUser()

Return the record for the current user.

Returns:User|bool User object if a user is logged in, false otherwise.
Omeka_Controller_AbstractActionController::_getBrowseRecordsPerPage($pluralName = null)

Return the number of records to display per page.

By default this will read from the _browseRecordsPerPage property, which in turn defaults to null, disabling pagination. This can be overridden in subclasses by redefining the property or this method.

Setting the property to self::RECORDS_PER_PAGE_SETTING will enable pagination using the admin-configued page limits.

Parameters:
  • $pluralName (string|null) –
Returns:

int|null

Omeka_Controller_AbstractActionController::_getBrowseDefaultSort()

Return the default sorting parameters to use when none are specified.

Returns:array|null Array of parameters, with the first element being the sort_field parameter, and the second (optionally) the sort_dir.
Omeka_Controller_AbstractActionController::_getAddSuccessMessage($record)

Return the success message for adding a record.

Default is empty string. Subclasses should override it.

Parameters:
Returns:

string

Omeka_Controller_AbstractActionController::_getEditSuccessMessage($record)

Return the success message for editing a record.

Default is empty string. Subclasses should override it.

Parameters:
Returns:

string

Omeka_Controller_AbstractActionController::_getDeleteSuccessMessage($record)

Return the success message for deleting a record.

Default is empty string. Subclasses should override it.

Parameters:
Returns:

string

Omeka_Controller_AbstractActionController::_getDeleteConfirmMessage($record)

Return the delete confirm message for deleting a record.

Parameters:
Returns:

string

Omeka_Controller_AbstractActionController::_redirectAfterAdd($record)

Redirect to another page after a record is successfully added.

The default is to reidrect to this controller’s browse page.

Parameters:
Omeka_Controller_AbstractActionController::_redirectAfterEdit($record)

Redirect to another page after a record is successfully edited.

The default is to redirect to this record’s show page.

Parameters:
Omeka_Controller_AbstractActionController::_redirectAfterDelete($record)

Redirect to another page after a record is successfully deleted.

The default is to redirect to this controller’s browse page.

Parameters:
Omeka_Controller_AbstractActionController::_setActionContexts()

Augment Zend’s default action contexts.

Passes Omeka’s default additional contexts through the ‘action_contexts’ filter to allow plugins to add contexts.

Omeka_Controller_AbstractActionController::_getDeleteForm()

Get the form used for confirming deletions.

Returns:Zend_Form