Handles call like an openRosa compliant server. Implements the api as described on https://bitbucket.org/javarosa/javarosa/wiki/OpenRosaAPI
To implement, place the controller in the right directory and allow access without login to the following actions: formList - Lists the forms available submission - Handles receiving a submitted form download - Download a form
package | Gems |
---|---|
subpackage | Default |
author | Menno Dekker |
copyright | Copyright (c) 2014 Erasmus MC |
license | New BSD License |
inherited_from | \Gems_Controller_BrowseEditAction |
afterFormLoad(array $data, boolean $isNew)
array
boolean
afterSave(array $data, boolean $isNew) : boolean
As the data was already saved, it can NOT be changed anymore
array
boolean
boolean
True when you want to display the default 'saved' messagesafterSaveRoute(mixed $data) : boolean
mixed
data array or Zend Request
boolean
autofilterAction()
beforeFormDisplay(\Zend_Form $form, boolean $isNew) : \Zend_Form
Here we add the table display to the form.
\Zend_Form
boolean
\Zend_Form
beforeSave(array $data, boolean $isNew, \Zend_Form $form = null
) : boolean
array
The data that will be saved.
boolean
$param \Zend_Form $form
boolean
Returns true if flow should continuecreateAction()
Uses $this->getModel() $this->addFormElements()
deleteAction()
Uses $this->getModel() $this->addFormElements()
downloadAction()
editAction()
Uses $this->getModel() $this->addFormElements()
excelAction()
When you want to change the output, there are two places to check:
$this->addExcelColumns($model), where the model can be changed to have labels for columns you need exported
formlistAction()
getAfterSaveRoute(mixed $data) : mixed
mixed
array or \Zend_Controller_Request_Abstract
mixed
array with route options or false when no redirect is foundgetBrowseTable(array $baseUrl= array()
, $sort= null
, $model= null
) : \MUtil_Html_TableElement
Overruled to add css classes for Gems
array
\MUtil_Html_TableElement
getCachedRequestData(boolean $includeDefaults= true
, string $sourceAction= null
, boolean $readonly= false
, boolean $filterEmpty= true
) : array
boolean
Include the default values (yes for filtering, no for urls
string
The action to get the cache from if not the current one.
boolean
Optional, tell the cache not to store any new values
boolean
Optional, filter empty values from cache
array
getDefaultSearchData() : array
Used to specify the filter when no values have been entered by the user.
array
getInstanceId() : mixed
Overrule this function if the last item in the page title should be something other than te value of \MUtil_Model::REQUEST_ID.
mixed
getModelForm(array $data, \optional $new = false
) : \Zend_Form
array
The data that will later be loaded into the form, can be changed
\optional
boolean $new Form should be for a new element
\Zend_Form
getShowTable(integer $columns= 1
, mixed $filter= null
, mixed $sort= null
) : \MUtil_Html_TableElement
Overruled to add css classes for Gems
integer
The number of columns to use for presentation
mixed
A valid filter for \MUtil_Model_ModelAbstract->load()
mixed
A valid sort for \MUtil_Model_ModelAbstract->load()
\MUtil_Html_TableElement
getTitle(string $separator = null
) : string
If the title is an array the seperator concatenates the parts.
string
string
getTopic($count = 1
)
getTopic(integer $count = 1
) : \$string
integer
\$string
getTopicTitle()
getTopicTitle()
return $string
imageAction()
importAction()
indexAction()
init()
initHtml(boolean $reset = false
) : void
boolean
Throws away any existing html output when true
isConfirmedItem($title, $question= null
, $info= null
)
onFakeSubmit(\Zend_Form $form, array $data)
When not rerouted, the form will be populated afterwards
\Zend_Form
The populated form
array
The data-array we are working on
preDispatch()
scanresponsesAction()
showAction()
Uses: $this->getModel() $this->getShowTable();
submissionAction()
Takes two roundtrips:
_applySearchParameters(\MUtil_Model_ModelAbstract $model, $useStored = false
)
_createSelectElement(string $name, string|array $options, string $empty = null
) : \Zend_Form_Element_Select
string
Name of the select element
string
array
Can be a SQL select string or key/value array of options
string
Text to display for the empty selector
\Zend_Form_Element_Select
_createTable()
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.
\MUtil_Model_Bridge_TableBridge
\MUtil_Model_ModelAbstract
addExcelColumns(\MUtil_Model_ModelAbstract $model)
Only columns that have a label will be exported.
example:
$model->set('columnname', 'label', $this->_('Excel label'));
\MUtil_Model_ModelAbstract
aliasAction(string $alias)
Use this when an action is a Ajax action for retrieving information for use within the screen of another action
string
createForm(mixed $options = array()
) : \Gems_Form
mixed
\Gems_Form
createMenuLinks($includeLevel= 2
, $parentLabel= true
)
createModel($detailed, $action)
findAllowedMenuItem($action)
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
\MUtil_Model_ModelAbstract
array
The $form field values (can be usefull, but no need to set them)
array
Of \Zend_Form_Element's or static tekst to add to the html or null for group breaks.getAutoSearchForm(string $targetId) : \Gems_Form | null
string
\Gems_Form
null
getAutoSearchHref()
getAutoSearchReset() : \Zend_Form_Element_Submit
\Zend_Form_Element_Submit
getAutoSearchSubmit(\MUtil_Model_ModelAbstract $model, \MUtil_Form $form)
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.
array
The current user input
array
New filter statementsgetExcelData(array $data, \MUtil_Model_ModelAbstract $model) : array
array
\MUtil_Model_ModelAbstract
array
getXml(string $rootNode) : \SimpleXMLElement
string
\SimpleXMLElement
loadSnippetLoader()
makeRosaResponse()
processForm(string $saveLabel= null
, array $data= null
) : \Zend_Form | null
string
A label describing the form
array
An array of data to use, adding to the data from the post
\Zend_Form
null
Returns a form to display or null when finishedsetPageTitle(string $title)
string
Title
processReceivedForm($answerXmlFile) : string
string
ResultID or false on failure$autoFilter
true
$db : \Zend_Db_Adapter_Abstract
$filterStandard
$formDir : string
Will be set on init to: GEMS_ROOT_DIR . '/var/uploads/openrosa/forms/';
$formatExcelData : boolean
true
$loader : \Gems_Loader
$pageTitle : string
$requestCache : \Gems_Util_RequestCache
$responseDir : string
Will be set on init to: GEMS_ROOT_DIR . '/var/uploads/openrosa/';
$sortKey
$summarizedActions
array('index', 'autofilter')
$tableSnippets
$useCsrf : boolean
true
$useKeyboardSelector
true
$useMultiRowForm
false
$usePreviousFilter
true
$useTabbedForms
false
$util : \Gems_Util
$auth : \Zend_Auth
$authActions : array
array('formlist', 'submission', 'download')
ODK Collect: http://code.google.com/p/opendatakit/wiki/ODKCollect
$csrfId : string
'no_csrfx'
$csrfTimeout : integer
300
$importSnippets : mixed
'ModelImportSnippet'
$openrosaFormID : integer
null
RESET_PARAM = 'reset'
SEARCH_BUTTON = 'AUTO_SEARCH_TEXT_BUTTON'