sentence1 stringlengths 52 3.87M | sentence2 stringlengths 1 47.2k | label stringclasses 1
value |
|---|---|---|
public function getSearchFilter($useRequest = true)
{
$filter = parent::getSearchFilter($useRequest);
unset($filter['AUTO_SEARCH_TEXT_BUTTON']);
$where = \Gems_Snippets_AutosearchFormSnippet::getPeriodFilter($filter, $this->db, null, 'yyyy-MM-dd HH:mm:ss');
if ($where) {
... | Get the filter to use with the model for searching
@param boolean $useRequest Use the request as source (when false, the session is used)
@return array or false | entailment |
public function indexAction()
{
if ($this->checkForAnswersOnLoad) {
$this->loader->getTracker()->processCompletedTokens(
null,
$this->currentUser->getUserId(),
$this->currentUser->getCurrentOrganizationId(),
true
... | Default overview action | entailment |
public function extractFileAsText($disableCache = false)
{
/** @var File $file */
$file = $this->owner;
if (!$disableCache) {
$text = $this->getTextCache()->load($file);
if ($text) {
return $text;
}
}
// Determine which ext... | Tries to parse the file contents if a FileTextExtractor class exists to handle the file type, and
returns the text. The value is also cached into the File record itself.
@param boolean $disableCache If false, the file content is only parsed on demand.
If true, the content parsing is forced, bypassing
the cached versio... | entailment |
protected function addTableCells(\MUtil_Model_Bridge_VerticalTableBridge $bridge)
{
$bridge->setColumnCount(1);
$HTML = \MUtil_Html::create();
$bridge->tdh($this->getCaption(), array('colspan' => 2));
// Caption for tracks
$trackLabel = $this->_('Assigned tracks');
... | Place to set the data to display
@param \MUtil_Model_Bridge_VerticalTableBridge $bridge
@return void | entailment |
public function calcultateName($value, $isNew = false, $name = null, array $context = array())
{
if (isset($context['gaf_filter_text1']) && $context['gaf_filter_text1']) {
return sprintf($this->_('Episode subject contains %s'), $context['gaf_filter_text1']);
} else {
return $... | A ModelAbstract->setOnSave() function that returns the input
date as a valid date.
@see \MUtil_Model_ModelAbstract
@param mixed $value The value being saved
@param boolean $isNew True when a new item is being saved
@param string $name The name of the current field
@param array $context Optional, the other values bein... | entailment |
public function addElement(\Zend_Form_Element $element)
{
$decorators = $element->getDecorators();
$decorator = array_shift($decorators);
$element->setDecorators(array($decorator,
array('Description', array('class'=>'description')),
'Errors',
... | Add element to stack
@param \Zend_Form_Element $element
@return \Zend_Form_DisplayGroup | entailment |
public function loadDefaultDecorators()
{
if ($this->loadDefaultDecoratorsIsDisabled()) {
return $this;
}
$decorators = $this->getDecorators();
if (empty($decorators)) {
$this->addDecorator('FormElements')
->addDecorator(array('table' => 'Htm... | Load default decorators
@return void | entailment |
protected function _addJoinTables()
{
$this->addTable('gems__respondents', array('gap_id_user' => 'grs_id_user'));
if ($this->has('gap_id_organization')) {
$this->addTable(
'gems__organizations',
array('gap_id_organization' => 'gor_id_organization... | Add the join tables instead of lookup tables. | entailment |
public function afterRegistry()
{
$agenda = $this->loader->getAgenda();
if ($agenda) {
$this->addColumn(
"CASE WHEN gap_status IN ('" .
implode("', '", $agenda->getStatusKeysInactive()) .
"') THEN 'deleted' ELSE '' END"... | Called after the check that all required registry values
have been set correctly has run.
This function is no needed if the classes are setup correctly
@return void | entailment |
public function applyBrowseSettings()
{
$this->_addJoinTables();
$this->resetOrder();
$agenda = $this->loader->getAgenda();
$this->setIfExists('gap_admission_time', 'label', $this->_('Appointment'),
// 'formatFunction', array($this->util->getTranslated(), 'f... | Set those settings needed for the browse display
@return \Gems_Model_AppointmentModel | entailment |
public function applyDetailSettings($setMulti = true)
{
$this->resetOrder();
$agenda = $this->loader->getAgenda();
$dbLookup = $this->util->getDbLookup();
$empty = $this->util->getTranslated()->getEmptyDropdownArray();
$this->setIfExists('gap_admission_time', 'l... | Set those settings needed for the detailed display
@param boolean $setMulti When false organization dependent multi options are nor filled.
@return \Gems_Model_AppointmentModel | entailment |
public function applyEditSettings($orgId = null)
{
$this->applyDetailSettings(false);
$agenda = $this->loader->getAgenda();
$empty = $this->util->getTranslated()->getEmptyDropdownArray();
$this->setIfExists('gap_id_organization', 'default', $orgId ?: $this->currentOrganization->ge... | Set those values needed for editing
@param int $orgId The id of the current organization
@return \Gems_Model_AppointmentModel | entailment |
public function save(array $newValues, array $filter = null)
{
// When appointment id is not set, then check for existing instances of
// this appointment using the source information
if ((!isset($newValues['gap_id_appointment'])) &&
isset($newValues['gap_id_in_source'], $new... | Save a single model item.
@param array $newValues The values to store for a single model item.
@param array $filter If the filter contains old key values these are used
to decide on update versus insert.
@return array The values as they are after saving (they may change). | entailment |
public function showEpisode($episodeId)
{
if (! $episodeId) {
return null;
}
$episode = $this->loader->getAgenda()->getEpisodeOfCare($episodeId);
if (! $episode->exists) {
return $episodeId;
}
$episodeItem = $this->menu->findAllowedController... | Display the episode
@param int $episodeId
@return string | entailment |
public function matchEpisode(EpisodeOfCare $episode)
{
if (! $this->_data['gaf_filter_text1']) {
return ! $episode->getSubject();
}
$regex = '/' . str_replace(array('%', '_'), array('.*', '.{1,1}'),$this->_data['gaf_filter_text1']) . '/i';
return (boolean) preg_match($r... | Check a filter for a match
@param \Gems\Agenda\EpisodeOfCare $episode
@return boolean | entailment |
public function execute($lineNr = null, $fieldData = null)
{
$batch = $this->getBatch();
$import = $batch->getVariable('import');
if (isset($fieldData['gtf_id_order']) && $fieldData['gtf_id_order']) {
$import['fieldOrder'][$fieldData['gtf_id_order']] = false;
if ($... | Should handle execution of the task, taking as much (optional) parameters as needed
The parameters should be optional and failing to provide them should be handled by
the task
@param array $trackData Nested array of trackdata | entailment |
public function calculateFieldInfo($currentValue, array $fieldData)
{
if (! $currentValue) {
return $currentValue;
}
// Display nice
$sql = $this->_sql . "WHERE grr_id = ?";
$row = $this->db->fetchRow($sql, $currentValue);
if ($row && isset($row['name'])... | Calculation the field info display for this type
@param array $currentValue The current value
@param array $fieldData The other values loaded so far
@return mixed the new value | entailment |
public function getDataModelDependyChanges(array $context, $new)
{
if ($this->isReadOnly()) {
return null;
}
$sql = $this->_sql ."WHERE grr_id_respondent = ? ORDER BY grr_type";
$empty = $this->util->getTranslated()->getEmptyDropdownArray();
$output['multiOp... | Returns the changes to the model for this field that must be made in an array consisting of
<code>
array(setting1 => $value1, setting2 => $value2, ...),
</code>
By using [] array notation in the setting array key you can append to existing
values.
Use the setting 'value' to change a value in the original data.
When... | entailment |
public function showRelation($value)
{
// Display nicer
$display = $this->calculateFieldInfo($value, array());
if ($value == $display) {
$display = $this->_('-');
}
return $display;
} | Display a relation as text
@param value $value
@return string | entailment |
public function autofilterAction($resetMvc = true)
{
$htmlOrig = $this->html;
$div = $this->html->div(array('id' => 'autofilter_target', 'class' => 'table-container'));
// Already done when this value is false
if ($resetMvc) {
$this->autofilterParameters = $this->au... | The automatically filtered result
@param $resetMvc When true only the filtered resulsts | entailment |
public function excelAction()
{
// Make sure we have all the parameters used by the model
$this->autofilterParameters = $this->autofilterParameters + $this->_autofilterExtraParameters;
$model = $this->getExportModel();
// Set any defaults.
if (isset($this->autofilterParamet... | Outputs the model to excel, applying all filters and searches needed
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 mode... | entailment |
public function exportAction()
{
$step = $this->request->getParam('step');
$post = $this->request->getPost();
$this->autofilterParameters = $this->autofilterParameters + $this->_autofilterExtraParameters;
$model = $this->getExportModel();
if (isset($this->autofilte... | Export model data | entailment |
protected function firstAllowedMenuItem($action, $action2 = null)
{
$actions = \MUtil_Ra::args(func_get_args());
$controller = $this->_getParam('controller');
foreach ($actions as $action) {
$menuItem = $this->menu->find(array('controller' => $controller, 'action' => $action, 'a... | Finds the first item with one of the actions specified as parameter and using the current controller
@param string $action
@param string $action2
@return \Gems_Menu_SubMenuItem | entailment |
protected function getExcelData($data, \MUtil_Model_ModelAbstract $model)
{
$headings = array();
$emptyMsg = $this->_('No data found.');
foreach ($model->getItemsOrdered() as $name) {
if ($label = $model->get($name, 'label')) {
$headings[$name] = (string) $label;
... | Returns an array with all columns from the model that have a label
@param array $data
@param \MUtil_Model_ModelAbstract $model
@return array | entailment |
protected function getExportModel()
{
$model = $this->getModel();
$noExportColumns = $model->getColNames('noExport');
foreach($noExportColumns as $colName) {
$model->remove($colName, 'label');
}
return $model;
} | Get the model for export and have the option to change it before using for export
@return | entailment |
public function getImporter()
{
return $this->loader->getImportLoader()->getImporter(
$this->getRequest()->getControllerName(),
$this->getModel()
);
} | Get an Importer object for this actions
@return \MUtil_Model_Importer | entailment |
public function getMessenger()
{
if (! $this->messenger) {
$this->setMessenger($this->loader->getMessenger());
}
return $this->messenger;
} | Returns a session based message store for adding messages to.
@return \Zend_Controller_Action_Helper_FlashMessenger | entailment |
public function getTitle($separator = null)
{
if ($title_set = parent::getTitle($separator)) {
return $title_set;
}
$title = array();
foreach($this->menu->getActivePath($this->getRequest()) as $menuItem) {
$title[] = $menuItem->get('label');
}
... | Returns the current html/head/title for this page.
If the title is an array the seperator concatenates the parts.
@param string $separator
@return string | entailment |
public function indexAction()
{
$this->autofilterParameters = $this->autofilterParameters + $this->_autofilterExtraParameters;
if (! isset($this->indexParameters['contentTitle'])) {
$this->indexParameters['contentTitle'] = $this->getIndexTitle();
}
return parent::indexAc... | Action for showing a browse page | entailment |
public function initHtml($reset = false)
{
if (! $this->html) {
\Gems_Html::init();
}
parent::initHtml($reset);
} | Intializes the html component.
@param boolean $reset Throws away any existing html output when true
@return void | entailment |
public function setMessenger(\Zend_Controller_Action_Helper_FlashMessenger $messenger)
{
$this->messenger = $messenger;
$this->view->messenger = $messenger;
return $this;
} | Set the session based message store.
@param \Zend_Controller_Action_Helper_FlashMessenger $messenger
@return \MUtil_Controller_Action | entailment |
public function showAction()
{
if (! isset($this->showParameters['contentTitle'])) {
$this->showParameters['contentTitle'] = $this->getShowTitle();
}
parent::showAction();
} | Action for showing an item page with title | entailment |
protected function addFormElements(\MUtil_Model_Bridge_FormBridgeInterface $bridge, \MUtil_Model_ModelAbstract $model)
{
$this->mailElements->setForm($bridge->getForm());
$this->initItems();
$this->addItems($bridge, 'gct_name');
$this->addItems($bridge, 'gct_id_template', 'gct_target... | Adds elements from the model to the bridge that creates the form.
@param \MUtil_Model_Bridge_FormBridgeInterface $bridge
@param \MUtil_Model_ModelAbstract $model | entailment |
public function afterRegistry()
{
$this->mailElements = $this->loader->getMailLoader()->getMailElements();
$this->mailTargets = $this->loader->getMailLoader()->getMailTargets();
parent::afterRegistry();
} | Called after the check that all required registry values
have been set correctly has run.
@return void | entailment |
protected function getPreview($templateArray)
{
$multi = false;
if (count($templateArray) > 1) {
$multi = true;
$allLanguages = $this->util->getLocalized()->getLanguages();
}
$htmlView = \MUtil_Html::create()->div();
$textView = \MUtil_Html::create()-... | Style the template previews
@param array $templateArray template data
@return array html and text views | entailment |
protected function loadFormData()
{
parent::loadFormData();
$this->loadMailer();
if (isset($this->formData['gctt'])) {
$multi = false;
if (count($this->formData['gctt']) > 1) {
$multi = true;
$allLanguages = $this->util->getLocalized()... | Load extra data not from the model into the form | entailment |
protected function loadMailer()
{
$this->mailTarget = false;
if (isset($this->formData['gct_target']) && isset($this->mailTargets[$this->formData['gct_target']])) {
$this->mailTarget = $this->formData['gct_target'];
} else {
reset($this->mailTargets);
$th... | Loads the correct mailer | entailment |
protected function onFakeSubmit()
{
if ($this->request->isPost()) {
if (! empty($this->formData['preview'])) {
$this->addMessage($this->_('Preview updated'));
return;
}
if (! empty($this->formData['sendtest'])) {
$this->ma... | When the form is submitted with a non 'save' button | entailment |
protected function afterSave($changed)
{
parent::afterSave($changed);
$model = $this->getModel();
if ($model instanceof \Gems_Model_AppointmentModel) {
$count = $model->getChangedTokenCount();
if ($count) {
$this->addMessage(sprintf($this->plural('%d ... | Hook that allows actions when data was saved
When not rerouted, the form will be populated afterwards
@param int $changed The number of changed rows (0 or 1 usually, but can be more) | entailment |
public function execute($row = null,
$noToken = \Gems_Model_Translator_AnswerTranslatorAbstract::TOKEN_ERROR,
$tokenCompletion = \Gems_Model_Translator_AnswerTranslatorAbstract::TOKEN_ERROR)
{
// \MUtil_Echo::track($row);
if ($this->iterator instanceof \Iterator && !is_array(... | Should handle execution of the task, taking as much (optional) parameters as needed
The parameters should be optional and failing to provide them should be handled by
the task
@param array $row Row to save | entailment |
protected function _getArrayRendered()
{
$results = parent::_getArrayRendered();
if (isset($results[\MUtil_Model::REQUEST_ID1], $results[\MUtil_Model::REQUEST_ID2]) &&
($results[\MUtil_Model::REQUEST_ID2] == $this->_hiddenOrgId)) {
$results[\MUtil_Model::REQUEST_ID] = $... | Returns the rendered values of th earray elements
@return array | entailment |
public function formatValues($value)
{
$options = $this->getOptions();
if (is_array($value)) {
if ($options) {
foreach ($value as &$val) {
if (isset($options[$val])) {
$val = $options[$val];
}
... | This formatFunction is needed because the options are not set before the concatenated row
@param string $value
@return string | entailment |
public function getChanges(array $context, $new)
{
$options = $this->getOptions($context['gtf_id_track']);
if ($options) {
// formatFunction is needed because the options are not set before the concatenated row
return array(
'htmlCalc' => array(
... | Returns the changes that must be made in an array consisting of
<code>
array(
field1 => array(setting1 => $value1, setting2 => $value2, ...),
field2 => array(setting3 => $value3, setting4 => $value4, ...),
</code>
By using [] array notation in the setting name you can append to existing
values.
Use the setting 'valu... | entailment |
protected function getOptions($trackId = null)
{
if (null === $trackId) {
$trackId = $this->_trackId;
}
$appFields = $this->db->fetchPairs("
SELECT gtap_id_app_field, gtap_field_name
FROM gems__track_appointments
WHERE gtap_id_track = ... | Get the calculate from options
@param int $trackId
@return array | entailment |
protected function loadFields()
{
$forResp = $this->_('for respondents');
$forStaff = $this->_('for staff');
$this->addField('tokens')
->setLabel($this->_('Activated surveys'))
->setToCount("gto_id_token");
$tUtil = $this->util->getTokenData();
... | Tells the models which fields to expect. | entailment |
protected function processFilter(\Zend_Controller_Request_Abstract $request, array $filter)
{
// \MUtil_Echo::r($filter, __CLASS__ . '->' . __FUNCTION__);
$mainFilter = isset($filter['main_filter']) ? $filter['main_filter'] : null;
unset($filter['main_filter']);
$forGroup =... | Processing of filter, can be overriden.
@param \Zend_Controller_Request_Abstract $request
@param array $filter
@return array | entailment |
protected function processSelect(\Zend_Db_Select $select)
{
// $select->joinLeft('gems__rounds', 'gto_id_round = gro_id_round', array());
// $select->join('gems__tracks', 'gto_id_track = gtr_id_track', array());
$select->join('gems__surveys', 'gto_id_survey = gsu_id_sur... | Stub function to allow extension of standard one table select.
@param \Zend_Db_Select $select | entailment |
public function calcultateName($value, $isNew = false, $name = null, array $context = array())
{
$filter[] = $context['gaf_filter_text1'];
$filter[] = $context['gaf_filter_text2'];
$filter[] = $context['gaf_filter_text3'];
$filter = array_filter($filter);
if ($filter) {
... | A ModelAbstract->setOnSave() function that returns the input
date as a valid date.
@see \MUtil_Model_ModelAbstract
@param mixed $value The value being saved
@param boolean $isNew True when a new item is being saved
@param string $name The name of the current field
@param array $context Optional, the other values bein... | entailment |
public function send(Message $mail): void
{
// Trace sent mails
$this->mails[] = $mail;
// Delegate to original mailer
$this->mailer->send($mail);
} | Sends email | entailment |
protected function createModel()
{
$model = $this->token->getModel();
$model->set('gto_reception_code',
'label', $model->get('grc_description', 'label'),
'required', true);
return $model;
} | Creates the model
@return \MUtil_Model_ModelAbstract | entailment |
public function getReceptionCodes()
{
$rcLib = $this->util->getReceptionCodeLibrary();
if ($this->unDelete) {
return $rcLib->getTokenRestoreCodes();
}
if ($this->token->isCompleted()) {
return $rcLib->getCompletedTokenDeletionCodes();
}
return... | Called after loadFormData() and isUndeleting() but before the form is created
@return array | entailment |
public function setReceptionCode($newCode, $userId)
{
// Get the code object
$code = $this->util->getReceptionCode($newCode);
// Use the token function as that cascades the consent code
$changed = $this->token->setReceptionCode($code, $this->formData['gto_comment'], $userId);
... | Hook performing actual save
@param string $newCode
@param int $userId
@return $changed | entailment |
protected function setAfterSaveRoute()
{
// Default is just go to the index
if ($this->routeAction && ($this->request->getActionName() !== $this->routeAction)) {
$tokenId = $this->_replacementTokenId ? $this->_replacementTokenId : $this->token->getTokenId();
$this->afterSaveR... | Set what to do when the form is 'finished'.
@return DeleteTrackTokenSnippet (continuation pattern) | entailment |
public function getSessionData(bool $checkExists = true) : ?array
{
if ($checkExists) {
$manager = Container::getDefaultManager();
if (!$manager->sessionExists()) {
return null;
}
}
$container = new Container();
$arraysession = $co... | {@inheritdoc} | entailment |
private function collectSessionData(array $arraysession) : array
{
$data = [];
foreach ($arraysession as $key => $row) {
if ($row instanceof ArrayObject) {
$iterator = $row->getIterator();
while ($iterator->valid()) {
$data[$key][$iter... | {@inheritdoc} | entailment |
public function sessionSetting(string $containerName, string $keysession, string $value = null, array $options = []) : bool
{
$container = new Container($containerName);
$new = $options['new'] ?? false;
if ($new && $value) {
return $this->addSession($container, $keysession, $val... | {@inheritdoc} | entailment |
private function addSession(Container $container, string $keysession, string $value) : bool
{
if ($container->offsetExists($keysession)) {
return false;
}
$container->offsetSet($keysession, $value);
return true;
} | Add new session data. | entailment |
private function setUnset(Container $container, string $keysession, ?string $value, bool $set = false) : bool
{
if (!$container->offsetExists($keysession)) {
return false;
}
if ($set && $value) {
$container->offsetSet($keysession, $value);
return true;
... | Set/Unset session data. | entailment |
public function clearSession(string $byContainer = null) : void
{
(new Container())->getManager()
->getStorage()
->clear($byContainer);
} | {@inheritdoc} | entailment |
public function calcultateName($value, $isNew = false, $name = null, array $context = array())
{
$output = array();
if (isset($context['gaf_filter_text1']) && $context['gaf_filter_text1']) {
$output[] = sprintf($this->_('Activity "%s"'), $context['gaf_filter_text1']);
}
i... | A ModelAbstract->setOnSave() function that returns the input
date as a valid date.
@see \MUtil_Model_ModelAbstract
@param mixed $value The value being saved
@param boolean $isNew True when a new item is being saved
@param string $name The name of the current field
@param array $context Optional, the other values bein... | entailment |
public function getTextSettings()
{
$description = sprintf($this->_(
"Use the %%-sign to search for zero or more random characters and an _ for a single random character."
));
return array(
'gaf_filter_text1' => array(
'label' => $th... | Get the settings for the gaf_filter_textN fields
Fields not in this array are not shown in any way
@return array gaf_filter_textN => array(modelFieldName => fieldValue) | entailment |
public function isValid($conditionId, $context)
{
$result = false;
if (isset($context['gro_id_track']) && $context['gro_id_track']) {
$trackEngine = $this->tracker->getTrackEngine($context['gro_id_track']);
$codes = $trackEngine->getFieldCodes();
$result = in_arr... | Does this track have the fieldcode the condition depends on?
@param type $conditionId
@param type $context
@return boolean | entailment |
protected function createModel($detailed, $action)
{
$model = $this->loader->getModels()->getConditionModel();
if ($detailed) {
if (('edit' == $action) || ('create' == $action)) {
$model->applyEditSettings(('create' == $action));
} else {
$mod... | Creates a model for getModel(). Called only for each new $action.
The parameters allow you to easily adapt the model to the current action. The $detailed
parameter was added, because the most common use of action is a split between detailed
and summarized actions.
@param boolean $detailed True when the current action... | entailment |
protected function addScript()
{
$view = $this->view;
\MUtil_JQuery::enableView($view);
$jquery = $view->jQuery();
$jquery->enable(); //Just to make sure
$handler = \ZendX_JQuery_View_Helper_JQuery::getJQueryHandler();
$script = "$('input[type=\"submit\"]').mouse... | This script disables the onchange that is fired just before the click on the submit button fires.
The onchange submits the form, changes the csrf token and then the submit button fires with the old
csrf that is invalid. This could prevent a needed (fake)submit to change values, but for now it
does not seem like a probl... | entailment |
public function execute($trackId = null, $roundId = null)
{
$batch = $this->getBatch();
$select = $this->db->select();
$select->from('gems__rounds', array(
'gro_id_order', 'gro_id_relationfield', 'gro_round_description', 'gro_icon_file',
'gro_changed_event', 'gro_dis... | Should handle execution of the task, taking as much (optional) parameters as needed
The parameters should be optional and failing to provide them should be handled by
the task | entailment |
protected function createModel()
{
// Replace two checkboxes with on radio button control
$this->model->set('ggp_staff_members', 'elementClass', 'Hidden');
$this->model->setOnSave('ggp_staff_members', array($this, 'saveIsStaff'));
$this->model->set('ggp_respondent_members', 'elementC... | Creates the model
@return \MUtil_Model_ModelAbstract | entailment |
protected function loadFormData()
{
if (! $this->formData) {
parent::loadFormData();
$model = $this->getModel();
$roles = $model->get('ggp_role', 'multiOptions');
$userRoles = $this->currentUser->getAllowedRoles();
// \MUtil_Echo::track($... | Hook that loads the form data from $_POST or the model
Or from whatever other source you specify here. | entailment |
public function loadStaffRespondent($value, $isNew = false, $name = null, array $context = array(), $isPost = false)
{
if (! $isPost) {
if (!isset($context['staff_respondent'])) {
if (isset($context['ggp_staff_members']) && $context['ggp_staff_members'] == 1) {
... | A ModelAbstract->setOnLoad() function that takes care of transforming a
dateformat read from the database to a \Zend_Date format
If empty or \Zend_Db_Expression (after save) it will return just the value
currently there are no checks for a valid date format.
@see \MUtil_Model_ModelAbstract
@param mixed $value The va... | entailment |
public function saveIsRespondent($value, $isNew = false, $name = null, array $context = array())
{
return (isset($context['staff_respondent']) && (2 == $context['staff_respondent'])) ? 1 : 0;
} | A ModelAbstract->setOnSave() function that returns the input
date as a valid date.
@see \MUtil_Model_ModelAbstract
@param mixed $value The value being saved
@param boolean $isNew True when a new item is being saved
@param string $name The name of the current field
@param array $context Optional, the other values bein... | entailment |
public function saveIsStaff($value, $isNew = false, $name = null, array $context = array())
{
return (isset($context['staff_respondent']) && (1 == $context['staff_respondent'])) ? 1 : 0;
} | A ModelAbstract->setOnSave() function that returns the input
date as a valid date.
@see \MUtil_Model_ModelAbstract
@param mixed $value The value being saved
@param boolean $isNew True when a new item is being saved
@param string $name The name of the current field
@param array $context Optional, the other values bein... | entailment |
public function addSeparator($token)
{
$this->wikiContent .= $this->wikiContentArr[$this->separatorCount];
if (count($this->cell) === 0) {
$this->generator->setColSpan($this->generator->getColSpan() + 1);
} else {
if ($this->hasStartHeader && $this->hasEndHeader) {
... | called by the inline parser, when it found a separator.
@param string $token | entailment |
protected function addBrowseTableColumns(\MUtil_Model_Bridge_TableBridge $bridge, \MUtil_Model_ModelAbstract $model)
{
$this->bridge = $bridge;
if ($this->useColumns && $this->columns) {
parent::addBrowseTableColumns($bridge, $model);
return;
}
if ($model->ha... | Adds columns from the model to the bridge that creates the browse table.
Overrule this function to add different columns to the browse table, without
having to recode the core table building code.
@param \MUtil_Model_Bridge_TableBridge $bridge
@param \MUtil_Model_ModelAbstract $model
@return void | entailment |
protected function createModel()
{
if (! $this->model instanceof \Gems_Model_RespondentModel) {
$this->model = $this->loader->getModels()->createRespondentModel();
$this->model->applyBrowseSettings();
}
return $this->model;
} | Creates the model
@return \MUtil_Model_ModelAbstract | entailment |
public function execute($respId = null, $orgId = null)
{
$batch = $this->getBatch();
$org = $this->loader->getOrganization($orgId);
$changeEventClass = $org->getRespondentChangeEventClass();
if ($changeEventClass) {
$event = $this->loader->getEvents()->loadRespondentC... | Should handle execution of the task, taking as much (optional) parameters as needed
The parameters should be optional and failing to provide them should be handled by
the task | entailment |
public function getLabeledColumns()
{
if (!$this->model->hasMeta('labeledColumns')) {
$orderedCols = $this->model->getItemsOrdered();
$results = array();
foreach ($orderedCols as $name) {
if ($this->model->has($name, 'label')) {
$resul... | Returns an array of ordered columnnames that have a label
@return array Array of columnnames | entailment |
protected function addFile()
{
$exportTempDir = GEMS_ROOT_DIR . DIRECTORY_SEPARATOR . 'var' . DIRECTORY_SEPARATOR . 'tmp' . DIRECTORY_SEPARATOR;
if (! is_dir($exportTempDir)) {
\MUtil_File::ensureDir($exportTempDir);
}
$tempFilename = $exportTempDir . 'export-' . ... | Creates a new file and adds it to the files array | entailment |
public function addRows($data, $modelId, $tempFilename, $filter)
{
$this->data = $data;
$this->modelId = $modelId;
$this->model = $this->getModel();
$this->model->setFilter($filter + $this->model->getFilter());
if ($this->model) {
$rows = $this->model->load(... | Add model rows to file. Can be batched
@param array $data Data submitted by export form
@param array $modelId Model Id when multiple models are passed
@param string $tempFilename The temporary filename while the file is being written
@param array $filter ... | entailment |
protected function cleanupName($filename)
{
$filename = str_replace(array('/', '\\', ':', ' '), '_', $filename);
// Remove dot if it starts with one
$filename = trim($filename, '.');
return \MUtil_File::cleanupName($filename);
} | Clean a proposed filename up so it can be used correctly as a filename
@param string $filename Proposed filename
@return string filtered filename | entailment |
protected function filterCsvInjection($input)
{
// Try to prevent csv injection
$dangers = ['=', '+', '-', '@'];
// Trim leading spaces for our test
$trimmed = trim($input);
if (strlen($trimmed)>1 && in_array($trimmed[0], $dangers)) {
return "'" ... | Single point for mitigating csv injection vulnerabilities
https://www.owasp.org/index.php/CSV_Injection
@param string $input
@return string | entailment |
protected function filterRow($row)
{
$exportRow = array();
foreach ($row as $columnName => $result) {
if ($this->model->get($columnName, 'label')) {
$options = $this->model->get($columnName, $this->modelFilterAttributes);
foreach ($options as $optionName... | Filter the data in a row so that correct values are being used
@param array $row a row in the model
@return array The filtered row | entailment |
public function finalizeFiles()
{
$this->getFiles();
if (count($this->files) === 0) {
return false;
}
$firstName = key($this->files);
$file = array();
if (count($this->files) === 1) {
$firstFile = $this->files[$firstName];
$f... | Finalizes the files stored in $this->files.
If it has 1 file, it will return that file, if it has more, it will return a zip containing all the files, named as the first file in the array.
@return File with download headers | entailment |
protected function getAnswerModel(array $filter, array $data, $sort)
{
$exportModelSource = $this->loader->getExportModelSource('AnswerExportModelSource');
$model = $exportModelSource->getModel($filter, $data);
$noExportColumns = $model->getColNames('noExport');
foreach($noExportColu... | Return the answermodel for the given filter
@param array $filter
@param array $data
@param array|string $sort
@return type | entailment |
protected function getFiles()
{
if (!$this->files) {
$files = array();
if ($this->batch) {
$files = $this->batch->getSessionVariable('files');
} else {
$files = $this->_session->files;
}
if (!is_array($files)) {
... | Returns the files array. It might be stored in the batch session or normal session.
@return array Files array | entailment |
public function getModel()
{
if ($this->batch) {
$model = $this->batch->getVariable('model');
} else {
$model = $this->_session->model;
}
if (is_array($model)) {
if ($this->modelId && isset($model['surveys'][$this->modelId])) {
$cur... | Get the model to export
@return \MUtil_Model_ModelAbstract | entailment |
protected function getModelCount($filter = true)
{
if ($this->model && $this->model instanceof \MUtil_Model_ModelAbstract) {
$totalCount = $this->model->loadPaginator()->getTotalItemCount();
return $totalCount;
}
return 0;
} | Get the number of items in a specific model, using the models paginator
@param array $filter Filter for the model
@return int Number of items in the model | entailment |
public function createModel($detailed, $action)
{
//
$model = new \Gems_Model_JoinModel('resptrack' , 'gems__respondent2track');
$model->addTable('gems__respondent2org', array(
'gr2t_id_user' => 'gr2o_id_user',
'gr2t_id_organization' => 'gr2o_id_organization'
... | Creates a model for getModel(). Called only for each new $action.
The parameters allow you to easily adapt the model to the current action. The $detailed
parameter was added, because the most common use of action is a split between detailed
and summarized actions.
@param boolean $detailed True when the current action... | entailment |
public function excelAction()
{
$model = $this->getModel();
$model->set('gr2t_id_respondent_track', 'label', 'attribute_4', 'order', '5');
foreach ($model->getColNames('has_orig') as $name) {
$model->set($name . '_orig', 'label', $model->get($name, 'label') . ' {RAW]');
... | Outputs the model to excel, applying all filters and searches needed
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 mode... | entailment |
protected function _translateAndSort(array $pairs)
{
$translations = array_map([$this->translateAdapter, '_'], $pairs);
asort($translations);
return $translations;
} | Translate and sort while maintaining key association
@param array $pairs
@return array | entailment |
public function getCompletedTokenDeletionCodes()
{
$select = $this->_getDeletionCodeSelect();
$select->where('grc_for_surveys = ?', self::APPLY_DO);
return $this->_translateAndSort($this->db->fetchPairs($select));
} | Returns the token deletion reception code list.
@return array a value => label array. | entailment |
public function getRedoValues()
{
static $data;
if (! $data) {
$data = array(
self::REDO_NONE => $this->_('No'),
self::REDO_ONLY => $this->_('Yes (forget answers)'),
self::REDO_COPY => $this->_('Yes (keep answers)'));
}
re... | Return the field values for the redo code.
<ul><li>0: do not redo</li>
<li>1: redo but do not copy answers</li>
<li>2: redo and copy answers</li></ul>
@staticvar array $data
@return array | entailment |
public function getSurveyApplicationValues()
{
static $data;
if (! $data) {
$data = array(
self::APPLY_NOT => $this->_('No'),
self::APPLY_DO => $this->_('Yes (for individual tokens)'),
self::APPLY_STOP => $this->_('Stop (for tokens in u... | Return the field values for surveys.
<ul><li>0: do not use</li>
<li>1: use (and cascade)</li>
<li>2: use for open rounds only</li></ul>
@staticvar array $data
@return array | entailment |
public function getRespondentDeletionCodes()
{
$select = $this->_getDeletionCodeSelect();
$select->where('grc_for_respondents = 1');
return $this->_translateAndSort($this->db->fetchPairs($select));
} | Returns the respondent deletion reception code list.
@return array a value => label array. | entailment |
public function getRespondentRestoreCodes()
{
$select = $this->_getRestoreSelect();
$select->where('grc_for_respondents = 1');
return $this->_translateAndSort($this->db->fetchPairs($select));
} | Returns the respondent deletion reception code list.
@return array a value => label array. | entailment |
public function getTokenRestoreCodes()
{
$select = $this->_getRestoreSelect();
$select->where('grc_for_surveys = ?', self::APPLY_DO);
return $this->_translateAndSort($this->db->fetchPairs($select));
} | Returns the token deletion reception code list.
@return array a value => label array. | entailment |
public function getTrackDeletionCodes()
{
$select = $this->_getDeletionCodeSelect();
$select->where('(grc_for_tracks = 1 OR grc_for_surveys = ?)', self::APPLY_STOP);
return $this->_translateAndSort($this->db->fetchPairs($select));
} | Returns the track deletion reception code list.
@return array a value => label array. | entailment |
public function getTrackRestoreCodes()
{
$select = $this->_getRestoreSelect();
$select->where('(grc_for_tracks = 1 OR grc_for_surveys = ?)', self::APPLY_STOP);
return $this->_translateAndSort($this->db->fetchPairs($select));
} | Returns the track deletion reception code list.
@return array a value => label array. | entailment |
public function getUnansweredTokenDeletionCodes()
{
$select = $this->_getDeletionCodeSelect();
$select->where('grc_for_surveys = ?', self::APPLY_DO)
->where('grc_redo_survey = ?', self::REDO_NONE);
return $this->_translateAndSort($this->db->fetchPairs($select));
} | Returns the token deletion reception code list.
@return array a value => label array. | entailment |
public function addByController($controller, $action = 'index', $label = null)
{
$query['controller'] = $controller;
$query['action'] = $action;
if ($menuItem = $this->menu->findFirst($query)) {
$this->addMenuItem($menuItem, $label);
}
return $this;
} | Add a menu item by specifying the controller
@param string $controller Controller name
@param string $action Action name
@param string $label Optional alternative label
@return \Gems_Menu_MenuList (continuation pattern) | entailment |
public function addCurrentChildren()
{
foreach ($this->menu->getCurrentChildren() as $menuItem) {
$this->addMenuItem($menuItem);
}
return $this;
} | Adds the children of the current menu item to this list
@return \Gems_Menu_MenuList (continuation pattern) | entailment |
public function addCurrentGrandParent($label = null)
{
$parent = $this->menu->getCurrentParent();
if ($parent && (! $parent->isTopLevel())) {
$grandPa = $parent->getParent();
if ($grandPa && (! $grandPa->isTopLevel())) {
$this->addMenuItem($grandPa, $label);
... | Adds the parent of parent of the current menu item
Does nothing when the parent is a top level item (has no
controllor or is the \Gems_menu itself).
@param string $label Optional alternative label
@return \Gems_Menu_MenuList (continuation pattern) | entailment |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.