sentence1
stringlengths
52
3.87M
sentence2
stringlengths
1
47.2k
label
stringclasses
1 value
protected function getAutoSearchElements(array $data) { $elements = parent::getAutoSearchElements($data); $this->_addPeriodSelectors($elements, 'gla_created'); $elements[] = null; $elements[] = $this->_('Specific action'); $sql = "SELECT gls_id_action, gls_name ...
Returns a text element for autosearch. Can be overruled. The form / html elements to search on. Elements can be grouped by inserting null's between them. That creates a distinct group of elements @param array $data The $form field values (can be usefull, but no need to set them) @return array Of \Zend_Form_Element's ...
entailment
public function getExportModelSource() { if (! $this->_exportModelSource) { $this->_exportModelSource = $this->loader->getExportModelSource($this->exportModelSourceClass); } return $this->_exportModelSource; }
Function to get a model source for this export @return \Gems_Export_ModelSource_ExportModelSourceAbstract
entailment
public function getSearchFilter($useRequest = false) { if (null !== $this->_searchFilter) { return $this->_searchFilter; } $this->_searchFilter = parent::getSearchFilter($useRequest); $this->_searchFilter[] = 'gto_start_time IS NOT NULL'; if (!isset($this->_sear...
Get the filter to use with the model for searching including model sorts, etc.. @param boolean $useRequest Use the request as source (when false, the session is used) @return array or false
entailment
public function getHtmlOutput(\Zend_View_Abstract $view) { $seq = $this->getHtmlSequence(); $seq->h2($this->_('Checks')); $ul = $seq->ul(); $ul->li($this->_('Executes respondent change event for all active respondents.')); $seq->pInfo($this->_( 'Run this co...
Create the snippets content This is a stub function either override getHtmlOutput() or override render() @param \Zend_View_Abstract $view Just in case it is needed here @return \MUtil_Html_HtmlInterface Something that can be rendered
entailment
public function execute($sourceId = null, $sourceSurveyId = null, $surveyId = null) { $batch = $this->getBatch(); if ($surveyId) { $survey = $this->loader->getTracker()->getSurvey($surveyId); } else { $survey = $this->loader->getTracker()->getSurveyBySourceId($source...
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 replaceCreateView(\Gems_Tracker_Survey $survey, \MUtil_Model_ModelAbstract $answerModel) { $viewName = $this->getViewName($survey); $responseDb = $this->project->getResponseDatabase(); $fieldSql = ''; foreach ($answerModel->getItemsOrdered() as $name) { ...
Handles creating or replacing the view for this survey @param \Gems_Tracker_Survey $viewName @param \MUtil_Model_ModelAbstract $answerModel
entailment
public function addSeparator($token) { $cellContent = $this->wikiContentArr[$this->separatorCount]; if ($cellContent === '') { if ($this->previousGenerator) { $this->previousGenerator->setColSpan($this->previousGenerator->getColSpan() + 1); } } else { ...
called by the inline parser, when it found a separator. @param string $token
entailment
public function getHtmlOutput(\Zend_View_Abstract $view) { //$view->headLink()->prependStylesheet($view->serverUrl() . \GemsEscort::getInstance()->basepath->getBasePath() . '/gems/css/barchart.less', 'screen,print'); $htmlDiv = \MUtil_Html::create()->div(' ', array('class'=>'barchartcontainer')); ...
Copied from parent, but insert chart instead of table after commented out part @param \Zend_View_Abstract $view @return type
entailment
private function getPercentage($value) { $percentage = ($value - $this->min) / ($this->max - $this->min) * 100; return $percentage; }
Return the percentage in the range between min and max for this chart @param number $value @return float
entailment
public function getTab(): string { $mailsCount = count($this->traceableMailer->getMails()); if ($mailsCount === 0) { return ''; } ob_start(); require 'templates/tab.phtml'; return (string) ob_get_clean(); }
Renders HTML code for custom tab.
entailment
protected function _ensureTrackFields() { if (! is_array($this->_fields)) { // Check for cases where the track id is zero, but there is a field for track 0 in the db if ($this->_trackId) { $model = $this->getMaintenanceModel(); $fields = $model->load(...
Loads the $this->_trackFields array, if not already there
entailment
public function calculateFieldsInfo(array $data) { if (! $this->exists) { return null; } $output = array(); foreach ($this->_fields as $key => $field) { if ($field instanceof FieldInterface) { if ($field->toTrackInfo()) { ...
Calculate the content for the track info field using the other fields @param array $data The field values @return string The description to save as track_info
entailment
public function getDataModelDependency() { if (! $this->exists) { return null; } $dependency = new FieldDataDependency(); foreach ($this->_fields as $key => $field) { if ($field instanceof FieldInterface) { $dependsOn = $field->getDataModelDe...
Get model dependency that changes model settings for each row when loaded @return \MUtil\Model\Dependency\DependencyInterface or null
entailment
public function getDataModelSettings() { if (! $this->exists) { return array(); } $fieldSettings = array(); foreach ($this->_fields as $key => $field) { if ($field instanceof FieldInterface) { $fieldSettings[$key] = $field->getDataModelSettin...
Get a big array with model settings for fields in a track @return array fieldname => array(settings)
entailment
public function getDataStorageModel() { if (! $this->_dataModel instanceof FieldDataModel) { $this->_dataModel = $this->tracker->createTrackClass('Model\\FieldDataModel'); } return $this->_dataModel; }
Get the storage model for field values @return \Gems\Tracker\Model\FieldDataModel
entailment
public function getFieldByCode($code) { foreach ($this->_fields as $field) { if ($field instanceof FieldInterface) { if ($field->getCode() == $code) { return $field; } } } return null; }
Get a specific field by field code @param string $code @return \Gems\Tracker\Field\FieldInterface
entailment
public function getFieldByOrder($order) { foreach ($this->_fields as $field) { if ($field instanceof FieldInterface) { if ($field->getOrder() == $order) { return $field; } } } return null; }
Get a specific field by field order @param int $order @return \Gems\Tracker\Field\FieldInterface
entailment
public function getFieldCodes() { $fields = array(); foreach ($this->_trackFields as $key => $field) { $fields[$key] = $field['gtf_field_code']; } return $fields; }
Returns an array of the fields in this track key / value are id / code @return array fieldid => fieldcode
entailment
public function getFieldDefaults() { $output = array(); foreach ($this->_trackFields as $key => $field) { $output[$key] = $field['gtf_field_default']; } return $output; }
Returns an array of the fields in this track key / value are id / code @return array fieldid => fieldcode
entailment
public function getFieldNames() { $fields = array(); foreach ($this->_trackFields as $key => $field) { $fields[$key] = $field['gtf_field_name']; } return $fields; }
Returns an array of the fields in this track key / value are id / field name @return array fieldid => fieldcode
entailment
public function getFieldsDataFor($respTrackId) { if (! $this->_fields) { return array(); } // Set the default values to empty as we currently do not store default values for fields $output = array_fill_keys(array_keys($this->_fields), null); if (! $respTrackId) ...
Returns the field data for the respondent track id. @param int $respTrackId Gems respondent track id or null when new @return array of the existing field values for this respondent track
entailment
protected function getFieldsOfType($fieldType, $element) { $output = array(); $fieldArray = (array) $fieldType; foreach ($this->_trackFields as $key => $field) { if (in_array($field['gtf_field_type'], $fieldArray)) { $output[$key] = $field[$element]; ...
Returns an array name => $element of all the fields of the type specified @param string|array $fieldType One or more field types @return array name => $element
entailment
public function getMaintenanceModel($detailed = false, $action = 'index') { if (isset($this->_maintenanceModels[$action])) { return $this->_maintenanceModels[$action]; } $model = $this->tracker->createTrackClass('Model\\FieldMaintenanceModel'); if ($detailed) { ...
Returns a model that can be used to retrieve or save the field definitions for the track editor. @param boolean $detailed Create a model for the display of detailed item data or just a browse table @param string $action The current action @return \Gems\Tracker\Model\FieldMaintenanceModel
entailment
public function hasAppointmentFields() { if (null === $this->_hasAppointmentFields) { $this->_hasAppointmentFields = false; foreach ($this->_trackFields as $field) { if (self::TYPE_APPOINTMENT == $field['gtf_field_type']) { $this->_hasAppointmentF...
True when this track contains appointment fields @return boolean
entailment
public function isAppointment($fieldName) { return isset($this->_trackFields[$fieldName]) && (self::TYPE_APPOINTMENT == $this->_trackFields[$fieldName]['gtf_field_type']); }
Is the field an appointment type @param string $fieldName @return boolean
entailment
public function processBeforeSave(array $fieldData, array $trackData) { $this->changed = false; if (! $this->exists) { return null; } foreach ($this->_fields as $key => $field) { if ($field instanceof FieldInterface) { $field->calculationStar...
Processes the values and and changes them as required @param array $fieldData The field values @param array $trackData The currently available track data (track id may be empty) @return array The processed data
entailment
public function saveFields($respTrackId, array $fieldData) { $saves = array(); foreach ($this->_fields as $key => $field) { if ($field instanceof FieldInterface) { if (array_key_exists($key, $fieldData)) { $inVal = $fieldData[$key]; } ...
Saves the field data for the respondent track id. @param int $respTrackId Gems respondent track id @param array $fieldData The values to save, only the key is used, not the code @return int The number of changed fields
entailment
public static function splitKey($key) { if (strpos($key, self::FIELD_KEY_SEPARATOR) === false) { return null; } list($sub, $fieldId) = explode(self::FIELD_KEY_SEPARATOR, $key, 2); return array('sub' => $sub, 'gtf_id_field' => $fieldId); }
Split an external field key in component parts @param string $sub @param int $fieldId @return array 'sub' => suIdb, 'gtf_id_field; => fieldId
entailment
protected function addFormElements(\Zend_Form $form) { if ($this->user->hasEmailAddress()) { $order = count($form->getElements())-1; $createElement = new \MUtil_Form_Element_FakeSubmit('create_account'); $createElement->setLabel($this->_('Create account mail')) ...
Add the elements to the form @param \Zend_Form $form
entailment
protected function onFakeSubmit() { if (isset($this->formData['create_account']) && $this->formData['create_account']) { $mail = $this->loader->getMailLoader()->getMailer('staffPassword', $this->user->getUserId()); if ($mail->setCreateAccountTemplate()) { $mail->send(...
Hook that allows actions when the form is submitted, but it was not the submit button that was checked When not rerouted, the form will be populated afterwards
entailment
public function getMessages() { if ($this->_authResult->isValid()) { return array(); } else { $messages = $this->_authResult->getMessages(); switch (count($messages)) { case 0: return array($this->_message); c...
Returns an array of messages that explain why the most recent isValid() call returned false. The array keys are validation failure message identifiers, and the array values are the corresponding human-readable message strings. If isValid() was never called or if the most recent isValid() call returned true, then this ...
entailment
public function render($text) { $text = $this->config->onStart($text); $linesIterator = new \ArrayIterator(preg_split("/\015\012|\015|\012/", $text)); // we split the text at all line feeds $this->documentGenerator->clear(); $this->errors = array(); while ($linesIterator->v...
Main method to call to convert a wiki text into an other format, according to the rules given to the constructor. @param string $text The wiki text to convert. @return string The converted text.
entailment
public function isValid($value, $context = array()) { $result = true; $ranges = explode('|', $value); foreach ($ranges as $range) { if (($sep = strpos($range, '-')) !== false) { $range = IpFactory::rangeFromBoundaries(substr($range, 0, $sep), substr($range, $sep...
Returns true if and only if $value meets the validation requirements If $value fails validation, then this method returns false, and getMessages() will return an array of messages that explain why the validation failed. @param mixed $value @return boolean @todo ip2long is broken on Windows, find a replacement
entailment
public function getPanel() { $linebreak = $this->getLinebreak(); $included = $this->_getIncludedFiles(); $html = '<h4>' . count($included).' files included worth '; $size = 0; foreach ($included as $file) { $size += filesize($file); } $html .= roun...
Gets content panel for the Debugbar @return string
entailment
protected function _getIncludedFiles() { if (null !== $this->_includedFiles) { return $this->_includedFiles; } $this->_includedFiles = get_included_files(); sort($this->_includedFiles); return $this->_includedFiles; }
Gets included files @return array
entailment
protected function addFormElements(\MUtil_Model_Bridge_FormBridgeInterface $bridge, \MUtil_Model_ModelAbstract $model) { $bridge->addHidden('grl_id_role'); $bridge->addText('grl_name'); $bridge->addText('grl_description'); $roles = $this->acl->getRoles(); if ($roles) { ...
Adds elements from the model to the bridge that creates the form. Overrule this function to add different elements to the browse table, without having to recode the core table building code. @param \MUtil_Model_Bridge_FormBridgeInterface $bridge @param \MUtil_Model_ModelAbstract $model
entailment
protected function beforeSave() { if (isset($this->formData['grl_parents']) && (! is_array($this->formData['grl_parents']))) { $this->formData['grl_parents'] = explode(',', $this->formData['grl_parents']); } if (isset($this->formData['grl_parents']) && is_array($this->formData['g...
Perform some actions to the data before it is saved to the database
entailment
protected function loadFormData() { // \MUtil_Echo::track(file_get_contents('php://input')); parent::loadFormData(); // \MUtil_Echo::track($this->formData); // Sometimes these settings sneek in when changing the parents of a role foreach(['pr.nologin', 'pr.islogin'] as $val)...
Hook that loads the form data from $_POST or the model Or from whatever other source you specify here.
entailment
public function getSqlAppointmentsWhere() { $where = $this->getSqlEpisodeWhere(); if (($where == parent::NO_MATCH_SQL) || ($where == parent::MATCH_ALL_SQL)) { return $where; } return sprintf( "gap_id_episode IN (SELECT gec_episode_of_care_id FRO...
Generate a where statement to filter an appointment model @return string
entailment
public function matchAppointment(\Gems_Agenda_Appointment $appointment) { $episode = $appointment->getEpisode(); if (! ($episode && $episode->exists)) { return false; } return $this->matchEpisode($episode); }
Check a filter for a match @param \Gems\Agenda\Gems_Agenda_Appointment $appointment @return boolean
entailment
protected function getExportModel() { $model = parent::getExportModel(); $model->del('parents', 'formatFunction'); $model->del('allowed', 'formatFunction'); $model->del('inherited', 'formatFunction'); return $model; }
Get the model for export and have the option to change it before using for export @return
entailment
protected function getRoles() { $roles = []; foreach ($this->acl->getRolePrivileges() as $role => $privileges) { $roles[$role]['role'] = $role; $roles[$role]['parents'] = $privileges[\MUtil_Acl::PARENTS] ? implode(', ', $privileges[\MUtil_Acl::PARENTS]) : null; ...
Get list of privileges, their menu options and which role is allowed or denied this specific privilege @return array list of roles
entailment
public function execute($sourceId = null, $command = null) { $batch = $this->getBatch(); $params = array_slice(func_get_args(), 2); $source = $this->loader->getTracker()->getSource($sourceId); if ($messages = call_user_func_array(array($source, $command), $params)) { fo...
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 afterRegistry() { parent::afterRegistry(); $this->maskStore = $this->loader->getUserMaskStore(); $this->maskStore->setMaskSettings($this->_data['ggp_mask_settings']); }
Called after the check that all required registry values have been set correctly has run. @return void
entailment
public function isTwoFactorRequired($ipAddress, $hasKey) { // \MUtil_Echo::track($ipAddress, $hasKey, $this->_get('ggp_2factor_set'), $this->_get('ggp_2factor_not_set')); if ($hasKey) { switch ($this->_get('ggp_2factor_set')) { case self::TWO_FACTOR_SET_REQUIRED:...
Should a user be authorized using two factor authentication? @param string $ipAddress @param boolean $hasKey @return boolean
entailment
protected function loadData($id) { try { $sql = "SELECT * FROM gems__groups WHERE ggp_id_group = ? LIMIT 1"; $data = $this->db->fetchRow($sql, intval($id)); } catch (\Exception $e) { $data = false; } if (! $data) { $data = $this->_noGro...
Load the data when the cache is empty. @param mixed $id @return array The array of data values
entailment
protected function _getConditionClass($conditionType) { if (isset($this->_conditionClasses[$conditionType])) { return $this->_conditionClasses[$conditionType]; } else { throw new Gems_Exception_Coding("No condition class exists for condition type '$conditionType'."); ...
Lookup condition class for an event type. This class or interface should at the very least implement the ConditionInterface. @see ConditionInterface @param string $conditionType The type (i.e. lookup directory) to find the associated class for @return string Class/interface name associated with the type
entailment
protected function _listConditions($conditionType) { $classType = $this->_getConditionClass($conditionType); $paths = $this->_getConditionDirs($conditionType); return $this->util->getTranslated()->getEmptyDropdownArray() + $this->listClasses($classType, $paths); }
Returns a list of selectable conditions with an empty element as the first option. @param string $conditionType The type (i.e. lookup directory with an associated class) of the conditions to list @return ConditionInterface or more specific a $conditionClass type object
entailment
protected function _loadCondition($conditionName, $conditionType) { $conditionClass = $this->_getConditionClass($conditionType); if (! class_exists($conditionName, true)) { throw new Gems_Exception_Coding("The condition '$conditionName' of type '$conditionType' can not be found"); ...
Loads and initiates a condition class and returns the class (without triggering the condition itself). @param string $conditionName The class name of the individual event to load @param string $conditionType The type (i.e. lookup directory with an associated class) of the event @return ConditionInterface or more speci...
entailment
public function getTokenTableStructure() { $tableName = $this->_getTokenTableName(); $table = new \Zend_DB_Table(array('name' => $tableName, 'db' => $this->lsDb)); $info = $table->info(); $metaData = $info['metadata']; return $metaData; }
Get the table structure of the token table @return array List of Zend_DB Table metadata
entailment
protected function addBrowseTableColumns(\MUtil_Model_Bridge_TableBridge $bridge, \MUtil_Model_ModelAbstract $model) { $bridge->gr2o_id_organization; if ($menuItem = $this->menu->find(array('controller' => 'appointment', 'action' => 'show', 'allowed' => true))) { $appButton = $menuItem-...
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_AppointmentModel) { $this->model = $this->loader->getModels()->createAppointmentModel(); $this->model->applyBrowseSettings(); } $this->model->addColumn(new \Zend_Db_Expr("CONVERT(gap_admissio...
Creates the model @return \MUtil_Model_ModelAbstract
entailment
public function getHtmlOutput(\Zend_View_Abstract $view) { $data = $this->getModel()->loadFirst(); if ($data && isset($data['relpath'])) { $nameForUser = $data['relpath']; } else { $nameForUser = $this->request->getParam(\MUtil_Model::REQUEST_ID, $this->_('unknown'))...
Create the snippets content This is a stub function either override getHtmlOutput() or override render() @param \Zend_View_Abstract $view Just in case it is needed here @return \MUtil_Html_HtmlInterface Something that can be rendered
entailment
protected function getTitle() { if ($this->formTitle) { return $this->formTitle; } elseif ($this->unDelete) { return sprintf($this->_('Undelete %s!'), $this->getTopic()); } else { return sprintf($this->_('Delete %s!'), $this->getTopic()); } }
Retrieve the header title to display @return string
entailment
protected function initItems() { if (is_null($this->_items)) { // Set the element classes $model = $this->getModel(); $keys = $model->getKeys(); foreach ($model->getItemNames() as $item) { if (($item == $this->receptionCodeItem) || in_array($...
Initialize the _items variable to hold all items from the model
entailment
protected function loadForm() { $model = $this->getModel(); $this->unDelete = $this->isUndeleting(); $receptionCodes = $this->getReceptionCodes(); // \MUtil_Echo::track($this->unDelete, $receptionCodes); if (! $receptionCodes) { throw new \Gems_Exception($this->...
Makes sure there is a form.
entailment
protected function saveData() { $this->beforeSave(); $changed = $this->setReceptionCode( $this->formData[$this->receptionCodeItem], $this->loader->getCurrentUser()->getUserId() ); $this->afterSave($changed); $this->accesslog->logChan...
Hook containing the actual save code. Call's afterSave() for user interaction. @see afterSave()
entailment
protected function createModel() { $model = $this->token->getModel(); if ($model instanceof \Gems_Tracker_Model_StandardTokenModel) { $model->addEditTracking(); if ($this->createData) { $model->applyInsertionFormatting(); } } ret...
Creates the model @return \MUtil_Model_ModelAbstract
entailment
public function getHtmlOutput(\Zend_View_Abstract $view) { if ($this->tokenId) { if ($this->token->exists) { return parent::getHtmlOutput($view); } else { $this->addMessage(sprintf($this->_('Token %s not found.'), $this->tokenId)); } ...
Create the snippets content This is a stub function either override getHtmlOutput() or override render() @param \Zend_View_Abstract $view Just in case it is needed here @return \MUtil_Html_HtmlInterface Something that can be rendered
entailment
public function hasHtmlOutput() { if (! $this->tokenId) { if ($this->token) { $this->tokenId = $this->token->getTokenId(); } elseif ($this->request) { $this->tokenId = $this->request->getParam(\MUtil_Model::REQUEST_ID); } } ...
The place to check if the data set in the snippet is valid to generate the snippet. When invalid data should result in an error, you can throw it here but you can also perform the check in the checkRegistryRequestsAnswers() function from the {@see \MUtil_Registry_TargetInterface}. @return boolean
entailment
public function parse($line) { $this->error = false; $this->currentTextLineContainer = $this->textLineContainers[$this->config->defaultTextLineContainer]; $firsttag = clone ($this->currentTextLineContainer->tag); $this->str = preg_split($this->currentTextLineContainer->pattern, $lin...
Main function which parses a line of wiki content. @param string $line a string containing wiki content, but without line feeds @return \WikiRenderer\Generator\InlineGeneratorInterface the line transformed to the target content
entailment
protected function _parse(\WikiRenderer\InlineTag $tag, $posstart) { $checkNextTag = true; // we analyse each part of the string, for ($i = $posstart + 1; $i < $this->end; ++$i) { $t = &$this->str[$i]; // is it the escape char ? if ($this->escapeChar != ...
Parser's core function. @param \WikiRenderer\InlineTag $tag ??? @param int $posstart ??? @return int new position
entailment
protected function addStepElementsFor(\MUtil_Model_Bridge_FormBridgeInterface $bridge, \MUtil_Model_ModelAbstract $model, $step) { $this->displayHeader($bridge, sprintf( $this->_('%s track export. Step %d of %d.'), $this->trackEngine->getTrackName(), $step, ...
Add the elements from the model to the bridge for the current step @param \MUtil_Model_Bridge_FormBridgeInterface $bridge @param \MUtil_Model_ModelAbstract $model @param int $step The current step
entailment
protected function addStepExportCodes(\MUtil_Model_Bridge_FormBridgeInterface $bridge, \MUtil_Model_ModelAbstract $model) { $this->displayHeader($bridge, $this->_('Set the survey export codes'), 'h3'); $rounds = $this->formData['rounds']; $surveyCodes = array(); foreach ($roun...
Add the elements from the model to the bridge for the current step @param \MUtil_Model_Bridge_FormBridgeInterface $bridge @param \MUtil_Model_ModelAbstract $model
entailment
protected function addStepExportSettings(\MUtil_Model_Bridge_FormBridgeInterface $bridge, \MUtil_Model_ModelAbstract $model) { $this->displayHeader($bridge, $this->_('Select what to export'), 'h3'); $this->addItems($bridge, 'orgs', 'fields', 'rounds'); }
Add the elements from the model to the bridge for the current step @param \MUtil_Model_Bridge_FormBridgeInterface $bridge @param \MUtil_Model_ModelAbstract $model
entailment
protected function addStepGenerateExportFile(\MUtil_Model_Bridge_FormBridgeInterface $bridge, \MUtil_Model_ModelAbstract $model) { // Things go really wrong (at the session level) if we run this code // while the finish button was pressed if ($this->isFinishedClicked()) { return;...
Add the elements from the model to the bridge for the current step @param \MUtil_Model_Bridge_FormBridgeInterface $bridge @param \MUtil_Model_ModelAbstract $model
entailment
protected function afterFormValidationFor($step) { if (2 == $step) { $model = $this->getModel(); $saves = array(); foreach ($model->getCol('surveyId') as $name => $sid) { if (isset($this->formData[$name]) && $this->formData[$name]) { $s...
Overrule this function for any activities you want to take place after the form has successfully been validated, but before any buttons are processed. @param int $step The current step
entailment
protected function createForm($options = null) { if (\MUtil_Bootstrap::enabled()) { if (!isset($options['class'])) { $options['class'] = 'form-horizontal'; } if (!isset($options['role'])) { $options['role'] = 'form'; } ...
Creates an empty form. Allows overruling in sub-classes. @param mixed $options @return \Zend_Form
entailment
protected function createModel() { if (! $this->exportModel instanceof \MUtil_Model_ModelAbstract) { $yesNo = $this->util->getTranslated()->getYesNo(); $model = new \MUtil_Model_SessionModel('export_for_' . $this->request->getControllerName()); $model->set('orgs', 'labe...
Creates the model @return \MUtil_Model_ModelAbstract
entailment
protected function downloadExportFile() { $this->view->layout()->disableLayout(); \Zend_Controller_Action_HelperBroker::getExistingHelper('viewRenderer')->setNoRender(true); $batch = $this->getExportBatch(false); $downloadName = $batch->getSessionVariable('downloadname'); ...
Performs actual download @param \MUtil_Model_Bridge_FormBridgeInterface $bridge @param \MUtil_Model_ModelAbstract $model
entailment
protected function loadFormData() { $model = $this->getModel(); if ($this->request->isPost()) { $this->formData = $model->loadPostData($this->request->getPost() + $this->formData, true); } elseif ('download' == $this->request->getParam($this->stepFieldName)) { $this...
Hook that loads the form data from $_POST or the model Or from whatever other source you specify here.
entailment
protected function setAfterSaveRoute() { $filename = $this->getExportBatch(false)->getSessionVariable('filename'); if ($filename) { // Now is a good moment to remove the temporary file @unlink($filename); } // Default is just go to the index if ($this-...
Set what to do when the form is 'finished'. @return \Gems\Tracker\Snippets\ExportTrackSnippetAbstract
entailment
public function validationApplies() { $return = true; if ($criteria = $this->owner->validationLogicCriteria) { $fields = $this->owner->rootFieldList(); if (eval($criteria->phpEvalString()) === false) { throw new Exception("There is a syntax error in the const...
Checks to see if any ValidationLogicCriteria has been set and if so, should the validation constraints still be applied @return bool
entailment
public function addTo($email, $name = '', $bounce = null) { if (is_null($bounce)) { $bounce = $this->bounceCheck(); } if ($bounce === true) { $name = str_replace('@', ' at ', $email); if (is_array($email)) { $name = array_shift($name); ...
Adds To-header and recipient, $email can be an array, or a single string address @param string|array $email @param string $name @param boolean $bounce When true the e-mail is bounced to the from address, when omitted bounce is read from project settings @return \Zend_Mail Provides fluent interface
entailment
public function checkTransport($from) { if (! array_key_exists($from, self::$mailServers)) { $sql = 'SELECT * FROM gems__mail_servers WHERE ? LIKE gms_from ORDER BY LENGTH(gms_from) DESC LIMIT 1'; // Always set cache, se we know when not to check for this row. $serverDat...
Returns \Zend_Mail_Transport_Abstract when something else than the default mail protocol should be used. @staticvar array $mailServers @param email address $from @return \Zend_Mail_Transport_Abstract or null
entailment
public function setTemplateStyle($style = null) { if (null == $style) { $style = GEMS_PROJECT_NAME; } $this->setHtmlTemplateFile(APPLICATION_PATH . '/configs/email/' . $style . '.html'); return $this; }
Set the template using style as basis @param string $style @return \MUtil_Mail (continuation pattern)
entailment
public function delete($filter = true) { $this->trackUsage(); $rows = $this->load($filter); if ($rows) { foreach ($rows as $row) { if (isset($row['gro_id_round'])) { $roundId = $row['gro_id_round']; if ($this->isDeleteable(...
Delete items from the model @param mixed $filter True to use the stored filter, array to specify a different filter @return int The number of items deleted
entailment
public function isDeleteable($roundId) { if (! $roundId) { return true; } $sql = "SELECT gto_id_token FROM gems__tokens WHERE gto_id_round = ? AND gto_start_time IS NOT NULL"; return (boolean) ! $this->db->fetchOne($sql, $roundId); }
Can this round be deleted as is? @param int $roundId @return boolean
entailment
public function processTokenData(\Gems_Tracker_Token $token) { $result = var_export($token->getRawAnswers(), true); \MUtil_Echo::r($result, $token->getTokenId()); return false; }
Process the data and return the answers that should be changed. Storing the changed values is handled by the calling function. @param \Gems_Tracker_Token $token Gems token object @return array Containing the changed values
entailment
protected function addBrowseColumn1(\MUtil_Model_Bridge_TableBridge $bridge, \MUtil_Model_ModelAbstract $model) { $br = \MUtil_Html::create('br'); if (isset($this->searchFilter['grc_success']) && (! $this->searchFilter['grc_success'])) { $model->set('grc_description', 'label', $this->_(...
Add first columns (group) from the model to the bridge that creates the browse table. You can actually add more than one column in this function, but just call all four functions with the default columns in each Overrule this function to add different columns to the browse table, without having to recode the core tab...
entailment
protected function addBrowseColumn2(\MUtil_Model_Bridge_TableBridge $bridge, \MUtil_Model_ModelAbstract $model) { if ($this->currentUser->isFieldMaskedWhole('name') && $this->currentUser->isFieldMaskedWhole('gr2o_email')) { return; } $br = \MUtil_Html::create('br'); $mo...
Add first columns (group) from the model to the bridge that creates the browse table. You can actually add more than one column in this function, but just call all four functions with the default columns in each Overrule this function to add different columns to the browse table, without having to recode the core tab...
entailment
protected function addBrowseColumn3(\MUtil_Model_Bridge_TableBridge $bridge, \MUtil_Model_ModelAbstract $model) { $br = \MUtil_Html::create('br'); if ($model->hasAlias('gems__respondent2track')) { $model->set('gtr_track_name', 'label', $this->_('Track')); $model->set('gr2t_...
Add first columns (group) from the model to the bridge that creates the browse table. You can actually add more than one column in this function, but just call all four functions with the default columns in each Overrule this function to add different columns to the browse table, without having to recode the core tab...
entailment
protected function addBrowseColumn4(\MUtil_Model_Bridge_TableBridge $bridge, \MUtil_Model_ModelAbstract $model) { $maskBirthday = $this->currentUser->isFieldMaskedWhole('grs_birthday'); $maskPhone = $this->currentUser->isFieldMaskedWhole('grs_phone_1'); if ($maskBirthday && $maskPhone) {...
Add first columns (group) from the model to the bridge that creates the browse table. You can actually add more than one column in this function, but just call all four functions with the default columns in each Overrule this function to add different columns to the browse table, without having to recode the core tab...
entailment
public function getRedirectRoute() { if (null !== $this->_redirectUrl) { return $this->_redirectUrl; } $this->_redirectUrl = false; // Retrieve these before the session is reset $staticSession = \GemsEscort::getInstance()->getStaticSession(); if ($stati...
When hasHtmlOutput() is false a snippet code user should check for a redirectRoute. Otherwise the redirect calling render() will execute the redirect. This function should never return a value when the snippet does not redirect. Also when hasHtmlOutput() is true this function should not be called. @see \Zend_Control...
entailment
private function _($messageId, $locale = null) { if ($this->translate) { return $this->translate->_($messageId, $locale); } return $messageId; }
proxy for easy access to translations @param string $messageId Translation string @param string|\Zend_Locale $locale (optional) Locale/Language to use, identical with locale identifier, @see \Zend_Locale for more information @return string
entailment
public function reset($id) { $template = $this->load(array('name'=>$id)); $result = false; if (count($template) == 1) { if (unlink($this->_path . '/template-local.ini')) { // Now force recompile $this->_templates = false; $this...
Reset a template to it's default values by deleteing template-local.ini @param string $id @return boolean true on success
entailment
public function afterRegistry() { parent::afterRegistry(); $setOnSave = \MUtil_Model_ModelAbstract::SAVE_TRANSFORMER; $switches = $this->getTextSettings(); // Make sure the calculated name is saved if (! isset($switches['gaf_calc_name'], $switches['gaf_calc_name'][$setOnSa...
Called after the check that all required registry values have been set correctly has run. @return void
entailment
public function calcultateAndCheckName($value, $isNew = false, $name = null, array $context = array()) { return substr($this->calcultateName($value, $isNew, $name, $context), 0, $this->_maxNameCalcLength); }
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
protected function addFillerSelect(array &$elements, $data, $elementId = 'filler') { if (isset($data['gto_id_track']) && !empty($data['gto_id_track'])) { $trackId = (int) $data['gto_id_track']; } else { $trackId = -1; } $sqlGroups = "SE...
Add filler select to the elements array @param array $elements @param array $data @param string $elementId
entailment
protected function getAutoSearchElements(array $data) { $elements = parent::getAutoSearchElements($data); if ($elements) { $elements[] = null; // break into separate spans } if ($this->periodSelector) { $dates = array( '_gto_valid_from gto_va...
Returns a text element for autosearch. Can be overruled. The form / html elements to search on. Elements can be grouped by inserting null's between them. That creates a distinct group of elements @param array $data The $form field values (can be usefull, but no need to set them) @return array Of \Zend_Form_Element's ...
entailment
protected function getEveryOption() { return [ 'notmailed' => $this->_('Not emailed'), 'tomail' => $this->_('To email'), 'toremind' => $this->_('Needs reminder'), 'hasnomail' => $this->_('Missing email'), 'notmailable' => $thi...
The sued options @return array
entailment
public function errorAction() { $errors = $this->_getParam('error_handler'); $exception = $errors->exception; $info = null; $message = 'Application error'; $responseCode = 200; switch ($errors->type) { case \Zend_Controller_...
Action for displaying an error, CLI as well as HTTP
entailment
public function getChanges(array $context, $new) { $multi = explode(FieldAbstract::FIELD_SEP, $context['gtf_field_values']); if (empty($context['gtf_field_values']) || empty($multi)) { $multi = $this->util->getTranslated()->getYesNo(); } $empty = []; if ($context...
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
public function afterRegistry() { parent::afterRegistry(); $this->addColumn($this->util->getTokenData()->getStatusExpression(), 'status'); if (! $this->request instanceof \Zend_Controller_Request_Abstract) { $this->request = \Zend_Controller_Front::getInstance()->getRequest(); ...
Called after the check that all required registry values have been set correctly has run. @return void
entailment
public function processChangedRespondent(\Gems_Tracker_Respondent $respondent) { $changes = 0; $tracker = $this->loader->getTracker(); $respTracks = $tracker->getRespondentTracks($respondent->getId(), $respondent->getOrganizationId()); $userId = $this->currentUser->getUserI...
Process the respondent and return true when data has changed. The event has to handle the actual storage of the changes. @param \Gems_Tracker_Respondent $respondent @param int $userId The current user @return boolean True when something changed
entailment
public function getEveryStatus() { static $status; if ($status) { return $status; } $status = array( 'U' => $this->_('Valid from date unknown'), 'W' => $this->_('Valid from date in the future'), 'O' => $this->_('Open - can be answered...
Returns a status code => decription array @static $status array @return array
entailment
public function getStatusDescription($value) { $status = $this->getEveryStatus(); if (isset($status[$value])) { return $status[$value]; } return $status['D']; }
Returns the description to add to the answer @param string $value Character @return string
entailment
public function getStatusIcon($value) { $status = $this->getStatusIcons(); if (isset($status[$value])) { return $status[$value]; } return $status['D']; }
Returns the decription to add to the answer @param string $value Character @return string
entailment
public function getStatusIcons() { static $status; if (is_null($status)) { $spanU = \MUtil_Html::create('span', array('class' => 'fa-stack', 'renderClosingTag' => true)); $spanU->i(array('class' => 'fa fa-circle fa-stack-2x', 'renderClosingTag' => true)); $spanU-...
Returns the status icons in an array @return array
entailment
public function getTokenAnswerLink($tokenId, $tokenStatus, $keepCaps) { if ('A' == $tokenStatus || 'P' == $tokenStatus || 'I' == $tokenStatus) { $menuItem = $this->_getAnswerMenuItem(); $label = $menuItem->get('label'); $link = $menuItem->toActionLink( ...
Generate a menu link for answers pop-up @param string $tokenId @param string $tokenStatus @param boolean $keepCaps Keep the capital letters in the label @return \MUtil_Html_AElement
entailment