BrowseEdit controller

This controller handles a default model browse / edit / export to excel

package Gems
subpackage Controller
copyright Copyright (c) 2011 Erasmus MC
license New BSD License
since Class available since version 1.0
deprecated Since version 1.7.1
inherited_from \Gems_Controller_ModelActionAbstract

 Methods

Hook to alter the formdata just before the form is populated

afterFormLoad(array $data, boolean $isNew) 

Parameters

$data

array

$isNew

boolean

Hook to perform action after a record (with changes) was saved

afterSave(array $data, boolean $isNew) : boolean

As the data was already saved, it can NOT be changed anymore

Parameters

$data

array

$isNew

boolean

Returns

booleanTrue when you want to display the default 'saved' messages

Get the afterSaveRoute and execute it

afterSaveRoute(mixed $data) : boolean

Parameters

$data

mixed

data array or Zend Request

Returns

boolean

autofilterAction()

autofilterAction() 

Perform some actions on the form, right before it is displayed but already populated

beforeFormDisplay(\Zend_Form $form, boolean $isNew) : \Zend_Form

Here we add the table display to the form.

Parameters

$form

\Zend_Form

$isNew

boolean

Returns

\Zend_Form

Hook to alter formdata before saving

beforeSave(array $data, boolean $isNew, \Zend_Form $form = null) : boolean

Parameters

$data

array

The data that will be saved.

$isNew

boolean

$param \Zend_Form $form

$form

Returns

booleanReturns true if flow should continue

Creates a form for a new record

createAction() 

Uses $this->getModel() $this->addFormElements()

Retrieve a form object and add extra decorators

createForm(array $options = null) : \Gems_Form
inherited_from \Gems_Controller_ModelActionAbstract::createForm()

Parameters

$options

array

Returns

\Gems_Form

Creates a form to delete a record

deleteAction() 

Uses $this->getModel() $this->addFormElements()

Creates a form to edit

editAction() 

Uses $this->getModel() $this->addFormElements()

Outputs the model to excel, applying all filters and searches needed

excelAction() 

When you want to change the output, there are two places to check:

  1. $this->addExcelColumns($model), where the model can be changed to have labels for columns you need exported

  2. $this->getExcelData($data, $model) where the supplied data and model are merged to get output (by default all fields from the model that have a label)

Return an array with route options depending on de $data given.

getAfterSaveRoute(mixed $data) : mixed

Parameters

$data

mixed

array or \Zend_Controller_Request_Abstract

Returns

mixedarray with route options or false when no redirect is found

Creates from the model a \MUtil_Html_TableElement that can display multiple items.

getBrowseTable(array $baseUrl = array(), $sort = null, $model = null) : \MUtil_Html_TableElement

Overruled to add css classes for Gems

Parameters

$baseUrl

array

$sort

$model

Returns

\MUtil_Html_TableElement

getCachedRequestData()

getCachedRequestData(boolean $includeDefaults = true, string $sourceAction = null, boolean $readonly = false, boolean $filterEmpty = true) : array

Parameters

$includeDefaults

boolean

Include the default values (yes for filtering, no for urls

$sourceAction

string

The action to get the cache from if not the current one.

$readonly

boolean

Optional, tell the cache not to store any new values

$filterEmpty

boolean

Optional, filter empty values from cache

Returns

array

Returns the default search values for this class instance.

getDefaultSearchData() : array

Used to specify the filter when no values have been entered by the user.

Returns

array

Return the current request ID, if any.

getInstanceId() : mixed
Inherited

Overrule this function if the last item in the page title should be something other than te value of \MUtil_Model::REQUEST_ID.

Returns

mixed

Creates from the model a \Zend_Form using createForm and adds elements using addFormElements().

getModelForm(array $data, \optional $new = false) : \Zend_Form

Parameters

$data

array

The data that will later be loaded into the form, can be changed

$new

\optional

boolean $new Form should be for a new element

Returns

\Zend_Form

Creates from the model a \MUtil_Html_TableElement for display of a single item.

getShowTable(integer $columns = 1, mixed $filter = null, mixed $sort = null) : \MUtil_Html_TableElement

Overruled to add css classes for Gems

Parameters

$columns

integer

The number of columns to use for presentation

$filter

mixed

A valid filter for \MUtil_Model_ModelAbstract->load()

$sort

mixed

A valid sort for \MUtil_Model_ModelAbstract->load()

Returns

\MUtil_Html_TableElement

Returns the current html/head/title for this page.

getTitle(string $separator = null) : string
Inherited

If the title is an array the seperator concatenates the parts.

Parameters

$separator

string

Returns

string

Helper function to allow generalized statements about the items in the model.

getTopic(integer $count = 1) : \$string
Inherited

Parameters

$count

integer

Returns

\$string

Helper function to allow generalized treatment of the header.

getTopicTitle() 
Inherited

return $string

Generic model based import action

importAction() 

indexAction()

indexAction() 

Intializes the html component.

initHtml(boolean $reset = false) : void
Inherited

Parameters

$reset

boolean

Throws away any existing html output when true

isConfirmedItem()

isConfirmedItem($title, $question = null, $info = null

Parameters

$title

$question

$info

Performs actions when the form is submitted, but the submit button was not checked

onFakeSubmit(\Zend_Form $form, array $data) 

When not rerouted, the form will be populated afterwards

Parameters

$form

\Zend_Form

The populated form

$data

array

The data-array we are working on

Shows a table displaying a single record from the model

showAction() 

Uses: $this->getModel() $this->getShowTable();

_applySearchParameters()

_applySearchParameters(\MUtil_Model_ModelAbstract $model, $useStored = false

Parameters

$model

$useStored

Creates a \Zend_Form_Element_Select

_createSelectElement(string $name, string|array $options, string $empty = null) : \Zend_Form_Element_Select

Parameters

$name

string

Name of the select element

$options

stringarray

Can be a SQL select string or key/value array of options

$empty

string

Text to display for the empty selector

Returns

\Zend_Form_Element_Select

_createTable()

_createTable() 

Adds columns from the model to the bridge that creates the browse table.

addBrowseTableColumns(\MUtil_Model_Bridge_TableBridge $bridge, \MUtil_Model_ModelAbstract $model) : void

Adds a button column to the model, if such a button exists in the model.

Parameters

$bridge

\MUtil_Model_Bridge_TableBridge

$model

\MUtil_Model_ModelAbstract

This is where you can modify the model for excel export

addExcelColumns(\MUtil_Model_ModelAbstract $model) 

Only columns that have a label will be exported.

example: $model->set('columnname', 'label', $this->_('Excel label'));

Parameters

$model

\MUtil_Model_ModelAbstract

Set the action key in request

aliasAction(string $alias) 

Use this when an action is a Ajax action for retrieving information for use within the screen of another action

Parameters

$alias

string

createForm()

createForm(mixed $options = array()) : \Gems_Form
Inherited

Parameters

$options

mixed

Returns

\Gems_Form

findAllowedMenuItem()

findAllowedMenuItem($action) 
Inherited

Parameters

$action

Returns a text element for autosearch. Can be overruled.

getAutoSearchElements(\MUtil_Model_ModelAbstract $model, array $data) : array

The form / html elements to search on. Elements can be grouped by inserting null's between them. That creates a distinct group of elements

Parameters

$model

\MUtil_Model_ModelAbstract

$data

array

The $form field values (can be usefull, but no need to set them)

Returns

arrayOf \Zend_Form_Element's or static tekst to add to the html or null for group breaks.

Creates an autosearch form for indexAction.

getAutoSearchForm(string $targetId) : \Gems_Form | null

Parameters

$targetId

string

Returns

\Gems_Formnull

getAutoSearchHref()

getAutoSearchHref() 

Creates a reset button for the search form

getAutoSearchReset() : \Zend_Form_Element_Submit

Returns

\Zend_Form_Element_Submit

getAutoSearchSubmit()

getAutoSearchSubmit(\MUtil_Model_ModelAbstract $model, \MUtil_Form $form) 

Parameters

$model

$form

Additional data filter statements for the user input.

getDataFilter(array $data) : array

User input that has the same name as a model field is automatically used as a filter, but if the name is different processing is needed. That processing should happen here.

Parameters

$data

array

The current user input

Returns

arrayNew filter statements

Returns an array with all columns from the model that have a label

getExcelData(array $data, \MUtil_Model_ModelAbstract $model) : array

Parameters

$data

array

$model

\MUtil_Model_ModelAbstract

Returns

array

Stub for overruling default snippet loader initiation.

loadSnippetLoader() 
Inherited

Handles a form, including population and saving to the model

processForm(string $saveLabel = null, array $data = null) : \Zend_Form | null

Parameters

$saveLabel

string

A label describing the form

$data

array

An array of data to use, adding to the data from the post

Returns

\Zend_FormnullReturns a form to display or null when finished

Set the page title on top of a page, also store it in a public var

setPageTitle(string $title) 

Parameters

$title

string

Title

 Properties

 

$autoFilter

$autoFilter 

Default

true
 

$db

$db : \Zend_Db_Adapter_Abstract

Default

 

$filterStandard

$filterStandard 

Default

 

Should Excel output contain formatted data (date fields, select lists)

$formatExcelData : boolean

Default

true
 

$loader

$loader : \Gems_Loader

Default

 

$menu

$menu : \Gems_Menu

Default

 

$menuCreateIncludeLevel

$menuCreateIncludeLevel 

Default

0
 

$menuEditIncludeLevel

$menuEditIncludeLevel 

Default

10
 

$menuIndexIncludeLevel

$menuIndexIncludeLevel 

Default

4
 

$menuShowIncludeLevel

$menuShowIncludeLevel 

Default

2
 

The page title at the top of each page

$pageTitle : string

Default

 

$requestCache

$requestCache : \Gems_Util_RequestCache

Default

 

$sortKey

$sortKey 

Default

 

$summarizedActions

$summarizedActions 

Default

array('index', 'autofilter')
 

$tableSnippets

$tableSnippets 

Default

 

Use csrf token on form for protection against Cross Site Request Forgery

$useCsrf : boolean

Default

true
 

$useKeyboardSelector

$useKeyboardSelector 

Default

true
 

$useMultiRowForm

$useMultiRowForm 

Default

false
 

$usePreviousFilter

$usePreviousFilter 

Default

true
 

$useTabbedForms

$useTabbedForms 

Default

false
 

$util

$util : \Gems_Util

Default

 

Field id for crsf protection field.

$csrfId : string

Default

'no_csrfx'
 

The timeout for crsf, 300 is default

$csrfTimeout : integer

Default

300
 

The snippets used for the import action

$importSnippets : mixed

Default

'ModelImportSnippet'

 Constants

 

RESET_PARAM

RESET_PARAM = 'reset' 
 

SEARCH_BUTTON

SEARCH_BUTTON = 'AUTO_SEARCH_TEXT_BUTTON'