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
booleanTrue when you want to display the default 'saved' messagesafterSaveRoute(mixed $data) : boolean
mixeddata array or Zend Request
booleanautofilterAction()
beforeFormDisplay(\Zend_Form $form, boolean $isNew) : \Zend_Form
Here we add the table display to the form.
\Zend_Form
boolean
\Zend_FormbeforeSave(array $data, boolean $isNew, \Zend_Form $form = null) : boolean
arrayThe data that will be saved.
boolean$param \Zend_Form $form
booleanReturns 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
mixedarray or \Zend_Controller_Request_Abstract
mixedarray 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_TableElementgetCachedRequestData(boolean $includeDefaults= true, string $sourceAction= null, boolean $readonly= false, boolean $filterEmpty= true) : array
booleanInclude the default values (yes for filtering, no for urls
stringThe action to get the cache from if not the current one.
booleanOptional, tell the cache not to store any new values
booleanOptional, filter empty values from cache
arraygetDefaultSearchData() : array
Used to specify the filter when no values have been entered by the user.
arraygetInstanceId() : mixed
Overrule this function if the last item in the page title should be something other than te value of \MUtil_Model::REQUEST_ID.
mixedgetModelForm(array $data, \optional $new = false) : \Zend_Form
arrayThe data that will later be loaded into the form, can be changed
\optionalboolean $new Form should be for a new element
\Zend_FormgetShowTable(integer $columns= 1, mixed $filter= null, mixed $sort= null) : \MUtil_Html_TableElement
Overruled to add css classes for Gems
integerThe number of columns to use for presentation
mixedA valid filter for \MUtil_Model_ModelAbstract->load()
mixedA valid sort for \MUtil_Model_ModelAbstract->load()
\MUtil_Html_TableElementgetTitle(string $separator = null) : string
If the title is an array the seperator concatenates the parts.
string
stringgetTopic($count = 1)
getTopic(integer $count = 1) : \$string
integer
\$stringgetTopicTitle()
getTopicTitle()
return $string
imageAction()
importAction()
indexAction()
init()
initHtml(boolean $reset = false) : void
booleanThrows 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_FormThe populated form
arrayThe 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
stringName of the select element
stringarrayCan be a SQL select string or key/value array of options
stringText 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_FormcreateMenuLinks($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
arrayThe $form field values (can be usefull, but no need to set them)
arrayOf \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_Formnull
getAutoSearchHref()
getAutoSearchReset() : \Zend_Form_Element_Submit
\Zend_Form_Element_SubmitgetAutoSearchSubmit(\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.
arrayThe current user input
arrayNew filter statementsgetExcelData(array $data, \MUtil_Model_ModelAbstract $model) : array
array
\MUtil_Model_ModelAbstract
arraygetXml(string $rootNode) : \SimpleXMLElement
string
\SimpleXMLElementloadSnippetLoader()
makeRosaResponse()
processForm(string $saveLabel= null, array $data= null) : \Zend_Form | null
stringA label describing the form
arrayAn array of data to use, adding to the data from the post
\Zend_FormnullReturns a form to display or null when finishedsetPageTitle(string $title)
stringTitle
processReceivedForm($answerXmlFile) : string
stringResultID 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
nullRESET_PARAM = 'reset'
SEARCH_BUTTON = 'AUTO_SEARCH_TEXT_BUTTON'