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:
Returns:

string

_getEditSuccessMessage(Omeka_Record_AbstractRecord $record)

Return the success message for editing a record.

Default is empty string. Subclasses should override it.

Parameters:
Returns:

string

_getDeleteSuccessMessage(Omeka_Record_AbstractRecord $record)

Return the success message for deleting a record.

Default is empty string. Subclasses should override it.

Parameters:
Returns:

string

_getDeleteConfirmMessage(Omeka_Record_AbstractRecord $record)

Return the delete confirm message for deleting a record.

Parameters:
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:
_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:
_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:
_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