sentence1
stringlengths
52
3.87M
sentence2
stringlengths
1
47.2k
label
stringclasses
1 value
protected function addBrowseTableColumns(\MUtil_Model_Bridge_TableBridge $bridge, \MUtil_Model_ModelAbstract $model) { // \MUtil_Model::$verbose = true; // // Initiate data retrieval for stuff needed by links $bridge->gr2o_patient_nr; $bridge->gr2o_id_organization; $b...
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 processFilterAndSort(\MUtil_Model_ModelAbstract $model) { $filter['gto_id_respondent'] = $this->respondent->getId(); if (is_array($this->forOtherOrgs)) { $filter['gto_id_organization'] = $this->forOtherOrgs; } elseif (true !== $this->forOtherOrgs) { ...
Overrule to implement snippet specific filtering and sorting. @param \MUtil_Model_ModelAbstract $model
entailment
protected function addModelSettings(array &$settings) { $empty = $this->util->getTranslated()->getEmptyDropdownArray(); $settings['elementClass'] = 'Select'; $settings['multiOptions'] = $empty + $this->util->getDbLookup()->getUserConsents(); }
Add the model settings like the elementClass for this field. elementClass is overwritten when this field is read only, unless you override it again in getDataModelSettings() @param array $settings The settings set so far
entailment
public function execute() { $model = new \Gems_Model_TemplateModel('templates', $this->project); $templates = $model->load(); foreach ($templates as $name => $data) { // Now load individual template $data = $model->load(array('name'=> $name)); // An...
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 addHeader($filename) { $file = fopen($filename, 'w'); $bom = pack("CCC", 0xef, 0xbb, 0xbf); fwrite($file, $bom); fclose($file); }
Add headers to a specific file @param string $filename The temporary filename while the file is being written
entailment
public function addRow($row, $file) { $exportRow = $this->filterRow($row); $labeledCols = $this->getLabeledColumns(); $exportRow = array_replace(array_flip($labeledCols), $exportRow); $changed = false; foreach ($exportRow as $name => $value) { $type = $this->model...
Add a separate row to a file @param array $row a row in the model @param file $file The already opened file
entailment
protected function addSpssFile($filename) { $model = $this->model; $files = $this->getFiles(); $datFileName = array_search($filename, $files); $spsFileName = substr($datFileName, 0, -strlen($this->fileExtension)) . '.sps'; $tmpFileName = substr($filename, 0, -strl...
Creates a correct SPSS file and adds it to the Files array
entailment
public function fixName($input) { if (!preg_match("/^([a-z]|[A-Z])+.*$/", $input)) { $input = "q_" . $input; } $input = str_replace(array(" ", "-", ":", ";", "!", "/", "\\", "'"), array("_", "_hyph_", "_dd_", "_dc_", "_excl_", "_fs_", "_bs_", '_qu_'), $input); return $inp...
Make sure the $input fieldname is correct for usage in SPSS Should start with alphanum, and contain no spaces @param string $input @return string
entailment
public function formatString($input) { if (is_array($input)) { $input = join(', ', $input); } $output = strip_tags($input); $output = str_replace(array("'", "\r", "\n"), array("''", ' ', ' '), $output); //$output = "'" . $output . "'"; return $output; ...
Formatting of strings for SPSS export. Enclose in single quotes and escape single quotes with a single quote Example: This isn't hard to understand ==> 'This isn''t hard to understand' @param type $input @return string
entailment
protected function preprocessModel() { parent::preprocessModel(); $labeledCols = $this->getLabeledColumns(); foreach($labeledCols as $columnName) { $options = array(); $type = $this->model->get($columnName, 'type'); switch ($type) { case \...
Preprocess the model to add specific options
entailment
public function isValid($value, $context = array()) { $this->_setValue((string) $value); $fieldSet = (boolean) isset($context[$this->_fieldName]) && $context[$this->_fieldName]; $valueSet = (boolean) $value; if ($valueSet && (! $fieldSet)) { return true; ...
Defined by \Zend_Validate_Interface Returns true if and only if a token has been set and the provided value matches that token. @param mixed $value @return boolean
entailment
protected function exportBatch($data) { $filter = $this->getSearchFilter(); if ($data) { $batch = $this->loader->getTaskRunnerBatch('export_surveys'); $models = $this->getExportModels($data['gto_id_survey'], $filter, $data); $batch->setVariable('model', $models...
Performs the export step
entailment
protected function exportDownload() { $this->view->layout()->disableLayout(); $this->_helper->viewRenderer->setNoRender(true); $batch = $this->loader->getTaskRunnerBatch('export_surveys'); $file = $batch->getSessionVariable('file'); foreach($file['headers'] as $header) { ...
Performs the download step
entailment
protected function addFormElements(\MUtil_Model_Bridge_FormBridgeInterface $bridge, \MUtil_Model_ModelAbstract $model) { $bridge->addElement($this->createToElement()); $bridge->addElement($this->mailElements->createMethodElement()); parent::addFormElements($bridge,$model); $bridge-...
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 getSingleTokenData() { $this->otherTokenData = $this->multipleTokenData; $singleTokenData = array_shift($this->otherTokenData); return $singleTokenData; }
Get the default token Id, from an array of tokenids. Usually the first token.
entailment
public function getTokenName(array $tokenData = null) { $data[] = $tokenData['grs_first_name']; $data[] = $tokenData['grs_surname_prefix']; $data[] = $tokenData['grs_last_name']; $data = array_filter(array_map('trim', $data)); // Remove empties return implode(' ', $data); ...
Returns the name of the user mentioned in this token in human-readable format @param array $tokenData @return string
entailment
public function afterRegistry() { parent::afterRegistry(); // Loaded from tracker and tracker does not always have the request as source value 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 getChanges(array $context, $new) { $subChange = true; if (! $new) { $fieldName = reset($this->_dependentOn); if (isset($context[$fieldName])) { $sql = $this->getSql($context[$fieldName]); $fid = $this->request->getParam(\Gems_...
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 _getAppointmentSelect() { $select = $this->db->select(); $select->from('gems__appointments') ->joinLeft( 'gems__agenda_activities', 'gap_id_activity = gaa_id_activity') ->joinLeft('gems__agenda_procedures', 'gap_id_procedure = gapr_id_procedure') ...
Get the select statement for appointments in getAppointments() Allows for overruling on project level @return \Zend_Db_Select
entailment
public function addActivity($name, $organizationId) { $model = new \MUtil_Model_TableModel('gems__agenda_activities'); \Gems_Model::setChangeFieldsByPrefix($model, 'gaa'); $values = array( 'gaa_name' => $name, 'gaa_id_organization' => $organizationId, ...
Add Activities to the table Override this method for other defaults @param string $name @param int $organizationId @return array
entailment
public function createAgendaClass($className, $param1 = null, $param2 = null) { $params = func_get_args(); array_shift($params); return $this->_loadClass($className, true, $params); }
Dynamically load and create a [Gems|Project]_Agenda_ class @param string $className @param mixed $param1 @param mixed $param2 @return object
entailment
public function getActiveAppointments($respondentId, $organizationId, $patientNr = null, $where = null) { if ($where) { $where = "($where) AND "; } else { $where = ""; } $where .= sprintf('gap_status IN (%s)', $this->getStatusKeysActiveDbQuoted()); re...
Get all active respondents for this user @param int $respondentId When null $patientNr is required @param int $organizationId @param string $patientNr Optional for when $respondentId is null @param string $where Optional extra where statement @return array appointmentId => appointment description
entailment
public function getAppointmentDisplay(array $row) { $date = new \MUtil_Date($row['gap_admission_time'], 'yyyy-MM-dd HH:mm:ss'); $results[] = $date->toString($this->appointmentDisplayFormat); if ($row['gaa_name']) { $results[] = $row['gaa_name']; } if ($row['gapr_n...
Overrule this function to adapt the display of the agenda items for each project @see \Gems_Agenda_Appointment->getDisplayString() @param array $row Row containing result select @return string
entailment
public function getAppointment($appointmentData) { if (! $appointmentData) { throw new \Gems_Exception_Coding('Provide at least the apppointment id when requesting an appointment.'); } if (is_array($appointmentData)) { if (!isset($appointmentData['gap_id_appointment...
Get an appointment object @param mixed $appointmentData Appointment id or array containing appointment data @return \Gems_Agenda_Appointment
entailment
public function getAppointments($respondentId, $organizationId, $patientNr = null, $where = null) { $select = $this->_getAppointmentSelect(); if ($where) { $select->where($where); } if ($respondentId) { $select->where('gap_id_user = ?', $respondentId) ...
Get all appointments for a respondent @param int $respondentId When null $patientNr is required @param int $organizationId @param string $patientNr Optional for when $respondentId is null @param string $where Optional extra where statement @return array appointmentId => appointment description
entailment
public function getAppointmentsForEpisode($episode) { $select = $this->_getAppointmentSelect(); if ($episode instanceof EpisodeOfCare) { $episodeId = $episode->getId(); } else { $episodeId = $episode; } $select->where('gap_id_episode = ?', $episodeId)...
Get all appointments for an episode @param int|Episode $episode Episode Id or object @return array appointmentId => appointment object
entailment
public function getEpisodeOfCare($episodeData) { if (! $episodeData) { throw new \Gems_Exception_Coding('Provide at least the episode id when requesting an episode of care.'); } if (is_array($episodeData)) { if (!isset($episodeData['gec_episode_of_care_id'])) { ...
Get an appointment object @param mixed $episodeData Episode id or array containing episode data @return \Gems\Agenda\EpisodeOfCare
entailment
public function getEpisodeStatusCodesActive() { // A => active, C => Cancelled, E => Error, F => Finished, O => Onhold, P => Planned, W => Waitlist $codes = array( 'A' => $this->_('Active'), 'F' => $this->_('Finished'), 'O' => $this->_('On hold'), 'P' ...
Get the status codes for active episode of care items see https://www.hl7.org/fhir/episodeofcare.html @return array code => label
entailment
public function getEpisodesAsOptions(array $episodes) { $options = []; foreach ($episodes as $id => $episode) { if ($episode instanceof EpisodeOfCare) { $options[$id] = $episode->getDisplayString(); } } return $options; }
Get the options list episodes for episodes @param array $episodes @return array of $episodeId => Description
entailment
public function getEpisodesFor(\Gems_Tracker_Respondent $respondent, $where = null) { return $this->getEpisodesForRespId($respondent->getId(), $respondent->getOrganizationId(), $where); }
Get the episodes for a respondent @param \Gems_Tracker_Respondent $respondent @param $where mixed Optional extra string or array filter @return array of $episodeId => \Gems\Agenda\EpisodeOfCare
entailment
public function getEpisodesForRespId($respondentId, $orgId, $where = null) { $select = $this->db->select(); $select->from('gems__episodes_of_care') ->where('gec_id_user = ?', $respondentId) ->where('gec_id_organization = ?', $orgId) ->order('gec_startd...
Get the episodes for a respondent @param int $respondentId @param int $orgId @param $where mixed Optional extra string or array filter @return array of $episodeId => \Gems\Agenda\EpisodeOfCare
entailment
public function getFilterList() { $cacheId = __CLASS__ . '_' . __FUNCTION__; $output = $this->cache->load($cacheId); if ($output) { return $output; } $output = $this->db->fetchPairs("SELECT gaf_id, COALESCE(gaf_manual_name, gaf_calc_name) " . "FR...
Load the list of assignable filters @return array filter_id => label
entailment
protected function getFieldData() { return array( 'gap_id_organization' => array( 'label' => $this->_('Organization'), 'tableName' => 'gems__organizations', 'tableId' => 'gor_id_organization', 'tableLikeFilter' => "gor_active = 1 AN...
Get a structured nested array contain information on all the appointment @return array fieldname => array(label[, tableName, tableId, tableLikeFilter))
entailment
public function getFilter($filterId) { static $filters = array(); if (isset($filters[$filterId])) { return $filters[$filterId]; } $found = $this->getFilters("SELECT * FROM gems__appointment_filters LEFT JOIN gems__track_appointments ON gaf_id = gtap_filte...
Get a filter from the database @param $filterId Id of a single filter @return AppointmentFilterInterface or null
entailment
public function getFilters($sql) { $classes = array(); $filterRows = $this->db->fetchAll($sql); $output = array(); // \MUtil_Echo::track($filterRows); foreach ($filterRows as $key => $filter) { $className = $filter['gaf_class']; if (! isset($cl...
Get the filters from the database @param $sql SQL statement @return AppointmentFilterInterface[]
entailment
public function getLocations($orgId = null) { // Make sure no invalid data gets through $orgId = intval($orgId); $cacheId = __CLASS__ . '_' . __FUNCTION__ . '_' . $orgId; if ($results = $this->cache->load($cacheId)) { return $results; } $select = $this-...
Returns an array with identical key => value pairs containing care provision locations. @param int $orgId Optional to slect for single organization @return array
entailment
public function getStatusKeysActiveDbQuoted() { $codes = array(); foreach ($this->getStatusKeysActive() as $key) { $codes[] = $this->db->quote($key); } return new \Zend_Db_Expr(implode(", ", $codes)); }
Get the status keys for active agenda items as a quoted db query string for use in "x IN (?)" @return \Zend_Db_Expr
entailment
public function getStatusKeysInactiveDbQuoted() { $codes = array(); foreach ($this->getStatusKeysInactive() as $key) { $codes[] = $this->db->quote($key); } return new \Zend_Db_Expr(implode(", ", $codes)); }
Get the status keys for active agenda items as a quoted db query string for use in "x IN (?)" @return \Zend_Db_Expr
entailment
public function getTrackCreateOptions() { return [ 0 => $this->_('Do nothing'), 4 => $this->_('Create new on minimum start date difference'), 3 => $this->_('Create always (unless the appointment already assigned)'), 2 => $this->_('Create new on minimum end dat...
Get the element that allows to create a track from an appointment When adding a new type, make sure to modify \Gems_Agenda_Appointment too @see \Gems_Agenda_Appointment::getCreatorCheckMethod() @return array Code => label
entailment
public function getTypeCodes() { return array( 'A' => $this->_('Ambulatory'), 'E' => $this->_('Emergency'), 'F' => $this->_('Field'), 'H' => $this->_('Home'), 'I' => $this->_('Inpatient'), 'S' => $this->_('Short stay'), 'V' ...
Get the type codes for agenda items @return array code => label
entailment
protected function initTranslateable() { if ($this->translateAdapter instanceof \Zend_Translate_Adapter) { // OK return; } if ($this->translate instanceof \Zend_Translate) { // Just one step $this->translateAdapter = $this->translate->getAdapt...
Function that checks the setup of this class/traight This function is not needed if the variables have been defined correctly in the source for this object and theose variables have been applied. return @void
entailment
protected function loadDefaultFilters() { if ($this->_filters) { return $this->_filters; } $cacheId = __CLASS__ . '_' . __FUNCTION__; $output = $this->cache->load($cacheId); if ($output) { foreach ($output as $key => $filterObject) { ...
Load the filters from cache or elsewhere @return AppointmentFilterInterface[]
entailment
public function matchHealthcareStaff($name, $organizationId, $create = true) { $cacheId = __CLASS__ . '_' . __FUNCTION__; $matches = $this->cache->load($cacheId); if (! $matches) { $matches = array(); $select = $this->db->select(); $select->from('gems...
Find a healt care provider for the name and organization. @param string $name The name to match against @param int $organizationId Organization id @param boolean $create Create a match when it does not exist @return int gas_id_staff staff id
entailment
public function matchLocation($name, $organizationId, $create = true) { $cacheId = __CLASS__ . '_' . __FUNCTION__; $matches = $this->cache->load($cacheId); if (! $matches) { $matches = array(); $select = $this->db->select(); $select->from('gems__locat...
Find a location for the name and organization. @param string $name The name to match against @param int $organizationId Organization id @param boolean $create Create a match when it does not exist @return array location
entailment
public function matchProcedure($name, $organizationId, $create = true) { $cacheId = __CLASS__ . '_' . __FUNCTION__; $matches = $this->cache->load($cacheId); if (! $matches) { $matches = array(); $select = $this->db->select(); $select->from('gems__agenda_...
Find a procedure code for the name and organization. @param string $name The name to match against @param int $organizationId Organization id @param boolean $create Create a match when it does not exist @return int or null
entailment
public function addContentString($wikiContent) { $this->wikiContent .= $wikiContent; $parsedContent = $this->convertWords($wikiContent); $this->generator->addContent($parsedContent); }
Called by the inline parser, when it found a new content. @param string $wikiContent The original content in wiki syntax
entailment
public function addContentGenerator($wikiContent, Generator\InlineGeneratorInterface $childGenerator) { $this->wikiContent .= $wikiContent; $this->generator->addContent($childGenerator); }
Called by the inline parser, when it found a new content. @param string $wikiContent The original content in wiki syntax @param Generator\InlineGeneratorInterface $childGenerator The content already parsed (by an other Tag object), when this tag contains other tags.
entailment
public function getBogusContent() { $generator = $this->documentGenerator->getInlineGenerator('textline'); $generator->addRawContent($this->beginTag); foreach ($this->generator->getChildGenerators() as $child) { $generator->addContent($child); } return $generator;...
Returns the generated content of the tag. @return string the content
entailment
public function generate() { $str = ''; $keysize = strlen($this->_alphabet); for ($i = 0; $i < $this->_length; ++$i) { $str .= $this->_alphabet[\Sodium\randombytes_uniform($keysize)]; } return $str; }
Generates a new identifier. @return string generated identifier
entailment
protected function configure(array $config = []) { foreach ($config as $key => $value) { $method = 'set' . $key; if (method_exists($this, $method)) { $this->$method($value); } } }
Configures the generator instance. @param array $config generator configuration
entailment
public function getHtmlOutput(\Zend_View_Abstract $view) { if ($this->sortParamAsc) { $this->dateSelector->getModel()->setSortParamAsc($this->sortParamAsc); } if ($this->sortParamDesc) { $this->dateSelector->getModel()->setSortParamDesc($this->sortParamDesc); ...
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 resetAction() { $model = $this->getModel(); $id = $this->getInstanceId(); if ($model->reset($id)) { $this->addMessage(sprintf($this->_('Resetting values for template %s to defaults successful'), $id), 'success'); } else { $this->addMes...
Reset action Deletes the template-local.ini (by means of a model function) and displays success or fail messages and returns to the index
entailment
public function addFormTabs($parentBridge, $name, $arrayOrKey1 = null) { $options = func_get_args(); $options = \MUtil_Ra::pairs($options, 2); /* $options = $this->_mergeOptions($name, $options, self::SUBFORM_OPTIONS); */ //\MUtil_Echo::track($options); if (isset($opti...
Adds a form multiple times in a table You can add your own 'form' either to the model or here in the parameters. Otherwise a form of the same class as the parent form will be created. All elements not yet added to the form are added using a new FormBridge instance using the default label / non-label distinction. @pa...
entailment
public function createBodyElement($name, $label, $required = false, $hidden = false, $mailFields = array(), $mailFieldsLabel = false) { if ($hidden) { return new \Zend_Form_Element_Hidden($name); } $options['required'] = $required; $options['label'] = $label; $ma...
Create an HTML Body element with CKEditor @return \Gems_Form_Element_CKEditor|\Zend_Form_Element_Hidden
entailment
public function createEmailElement($name, $label, $required = false, $multi = false) { $options['label'] = $label; $options['maxlength'] = 250; $options['required'] = $required; $options['size'] = 50; $element = $this->_form->createElement('text', $name, $options); ...
Default creator of an E-mail form element (set with SimpleEmails validations) @param $name @param $label @param bool $required @param bool $multi @return \Zend_Form_Element_Text
entailment
public function createMethodElement() { $multiOptions = $this->util->getTranslated()->getBulkMailProcessOptions(); $options = array( 'label' => $this->translate->_('Method'), 'multiOptions' => $multiOptions, 'required' => true, ); retu...
Create a multioption select with the different mail process options @return \Zend_Form_Element_Radio
entailment
public function createPreviewHtmlElement($label = false) { if ($label) { $options['label'] = $this->translate->_($label); } else { $options['label'] = $this->translate->_('Preview HTML'); } $options['nohidden'] = true; return $this->_form->createElement('...
Create the container that holds the preview Email HTML text. @param bool $noText Is there no preview text button? @return \MUtil_Form_Element_Exhibitor
entailment
public function createPreviewTextElement() { $options['label'] = $this->translate->_('Preview Text'); $options['nohidden'] = true; return $this->_form->createElement('Html', 'preview_text', $options); }
Create the container that holds the preview Email Plain text. @return \MUtil_Form_Element_Exhibitor
entailment
public function createModel($detailed, $action) { $model = new \MUtil_Model_TableModel('gems__consents'); $model->copyKeys(); // The user can edit the keys. $model->set('gco_description', 'label', $this->_('Description'), 'size', '10'); $model->set('gco_order', 'label'...
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 getAuthAdapter(\Gems_User_User $user, $password) { $adapter = new \Gems_Auth_Adapter_Callback(array($this->project, 'checkSuperAdminPassword'), $user->getLoginName(), array($password)); return $adapter; }
Returns an initialized Zend\Authentication\Adapter\AdapterInterface @param \Gems_User_User $user @param string $password @return Zend\Authentication\Adapter\AdapterInterface
entailment
public function getUserData($loginName, $organization) { $orgs = null; try { $orgs = $this->db->fetchPairs("SELECT gor_id_organization, gor_name FROM gems__organizations WHERE gor_active = 1 ORDER BY gor_name"); natsort($orgs); } catch (\Zend_Db_Exception $zde) { ...
Returns the data for a user object. It may be empty if the user is unknown. @param string $loginName @param int $organization @return array Of data to fill the user with.
entailment
public function isTwoFactorRequired($ipAddress, $hasKey, Group $group = null) { if (! $this->project->getSuperAdminTwoFactorKey()) { return false; } $tfExclude = $this->project->getSuperAdminTwoFactorIpExclude(); if (! $tfExclude) { return true; } ...
Should this user be authorized using two factor authentication? @param string $ipAddress @param boolean $hasKey @param Group $group @return boolean
entailment
protected function loadFields() { $forResp = $this->_('for respondents'); $forStaff = $this->_('for staff'); $this->addField('tokens') ->setLabel($this->_('Tokens')) ->setToCount("gto_id_token"); $this->addSubField('rtokens') ->setLab...
Tells the models which fields to expect.
entailment
protected function setShowTableFooter(\MUtil_Model_Bridge_VerticalTableBridge $bridge, \MUtil_Model_ModelAbstract $model) { $footer = $bridge->tfrow(); $footer[] = $this->getQuestion(); $footer[] = ' '; $footer->actionLink(array($this->confirmParameter => 1), $this->_('Yes'));...
Use findmenuitem for the abort action so we get the right id appended @param \MUtil_Model_Bridge_VerticalTableBridge $bridge @param \MUtil_Model_ModelAbstract $model
entailment
protected function createModel() { if (! $this->model instanceof FieldMaintenanceModel) { $this->model = $this->trackEngine->getFieldsMaintenanceModel(false, 'index'); } return $this->model; }
Creates the model @return \MUtil_Model_ModelAbstract
entailment
protected function getAutoSearchElements(array $data) { $elements = []; $elements['include_respondent_data'] = $this->_createCheckboxElement('include_respondent_data', $this->_('Include respondent data')); $elements['include_views'] = $this->_createCheckboxElement('include_views', $this->_(...
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 (possible nested) \Ze...
entailment
public function getFieldsTranslations() { $this->_targetModel->setAlias('gas_name_attended_by', 'gap_id_attended_by'); $this->_targetModel->setAlias('gas_name_referred_by', 'gap_id_referred_by'); $this->_targetModel->setAlias('gaa_name', 'gap_id_activity'); $this->_targetModel->setAl...
Get information on the field translations @return array of fields sourceName => targetName @throws \MUtil_Model_ModelException
entailment
public function translateRowValues($row, $key) { $row = parent::translateRowValues($row, $key); if (! $row) { return false; } // Set fixed values for import $row['gap_source'] = 'import'; $row['gap_manual_edit'] = 0; if (! isset($row['gap_i...
Perform any translations necessary for the code to work @param mixed $row array or \Traversable row @param scalar $key @return mixed Row array or false when errors occurred
entailment
public function startImport() { if ($this->_targetModel instanceof \MUtil_Model_ModelAbstract) { // No multiOptions as a new items can be created during import $fields = array( 'gap_id_attended_by', 'gap_id_referred_by', 'gap_id_activity', 'gap_id_procedure', 'gap_id...
Prepare for the import. @return \MUtil_Model_ModelTranslatorAbstract (continuation pattern)
entailment
public function execute($versionData = null) { $batch = $this->getBatch(); switch (count((array) $versionData)) { case 0: // Can be enabled in 1.7.3, for now leave it for testing // $batch->addToCounter('import_errors'); // $batch->addMess...
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 $versionData Nested array of trackdata
entailment
public function afterRegistry() { parent::afterRegistry(); $this->addColumn(new \Zend_Db_Expr(sprintf( "CASE WHEN gla_by IS NULL THEN '%s' ELSE CONCAT( COALESCE(gsf_last_name, '-'), ', ', COA...
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($detailed = false) { $this->resetOrder(); //Not only active, we want to be able to read the log for inactive organizations too $orgs = $this->db->fetchPairs('SELECT gor_id_organization, gor_name FROM gems__organizations'); $this->set('gla_created...
Set those settings needed for the browse display @return \Gems\Model\LogModel
entailment
public function refreshGroupSettings() { $group = $this->currentUser->getGroup(); if ($group instanceof Group) { $group->applyGroupToModel($this, false); } }
Function to re-apply all the masks and settings for the current group @return void
entailment
public function afterImport(\MUtil_Task_TaskBatch $batch, \MUtil_Form_Element_Html $element) { $text = parent::afterImport($batch, $element); $data = $this->formData; // Remove unuseful data unset($data['button_spacer'], $data['current_step'], $data[$this->csrfId]); // Add...
Hook for after save @param \MUtil_Task_TaskBatch $batch that was just executed @param \MUtil_Form_Element_Html $element Tetx element for display of messages @return string a message about what has changed (and used in the form)
entailment
public function isAvailable() { try { /** @var Response $result */ $result = $this->get('/', $this->getGuzzleOptions()); if ($result->getStatusCode() == 200) { return true; } } catch (RequestException $ex) { $msg = sprintf(...
Detect if the service is available @return bool
entailment
public function getVersion() { /** @var Response $response */ $response = $this->get('version', $this->getGuzzleOptions()); $version = 0.0; // Parse output if ($response->getStatusCode() == 200 && preg_match('/Apache Tika (?<version>[\.\d]+)/', $response->getBody...
Get version code @return float
entailment
public function getSupportedMimes() { if ($this->mimes) { return $this->mimes; } $response = $this->get( 'mime-types', $this->getGuzzleOptions([ 'headers' => [ 'Accept' => 'application/json', ], ...
Gets supported mime data. May include aliased mime types. @return array
entailment
public function tika($file) { $text = null; try { /** @var Response $response */ $response = $this->put( 'tika', $this->getGuzzleOptions([ 'headers' => [ 'Accept' => 'text/plain', ...
Extract text content from a given file. Logs a notice-level error if the document can't be parsed. @param string $file Full filesystem path to a file to post @return string Content of the file extracted as plain text
entailment
protected function getGuzzleOptions($options = []) { if (!empty($this->options['username']) && !empty($this->options['password'])) { $options['auth'] = [ $this->options['username'], $this->options['password'] ]; } return $options; }
Assembles an array of request options to pass to Guzzle @param array $options Authentication (etc) will be merged into this array and returned @return array
entailment
public function execute($lineNr = null, $conditionData = null) { $batch = $this->getBatch(); $conditions = $this->loader->getConditions(); $import = $batch->getVariable('import'); if (isset($conditionData['gcon_id']) && $conditionData['gcon_id']) { $import['impo...
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 authenticate() { $this->_authenticateSetup(); if ($this->_radius->AccessRequest($this->_identity,$this->_credential)) { $this->_authenticateResultInfo['code'] = Result::SUCCESS; $this->_authenticateResultInfo['messages'][] = 'Authentication successful.'; } else { $this->_authenticateRes...
authenticate() - defined by Zend\Authentication\Adapter\AdapterInterface. This method is called to attempt an authenication. Previous to this call, this adapter would have already been configured with all necessary information to successfully connect to a Radius server and attempt to find a record matching the provid...
entailment
protected function _authenticateSetup() { $exception = null; if ($this->_ip === null) { $exception = 'An ip address must be specified for use with the \Gems_User_Adapter_Radius authentication adapter.'; } elseif ($this->_sharedSecret === null) { $exception = 'A shared secret must be specified for use with...
_authenticateSetup() - This method abstracts the steps involved with making sure that this adapter was indeed setup properly with all required peices of information. @throws \Gems_Exception_Coding - in the event that setup was not done properly @return true
entailment
public function addExistingRoundsToModel(\ArrayObject $import, \MUtil_Model_ModelAbstract $model) { $currentRounds = $this->trackEngine->getRounds(); if (! $currentRounds) { return; } $importRounds = array(); $newImportRounds = array(); $tracker ...
Add the settings from the transformed import data to the formData and the model @param \ArrayObject $import @param \MUtil_Model_ModelAbstract $model
entailment
public function addImportToModelData(\ArrayObject $import) { // formDefaults are set in the Gems\Task\Tracker\Import tasks if (isset($import['formDefaults']) && $import['formDefaults']) { foreach ($import['formDefaults'] as $name => $default) { if (! (isset($this->formDat...
Add the settings from the transformed import data to the formData and the model @param \ArrayObject $import
entailment
protected function addStepChangeTrack(\MUtil_Model_Bridge_FormBridgeInterface $bridge, \MUtil_Model_ModelAbstract $model) { $this->displayHeader($bridge, $this->_('Change track information.'), 'h3'); // Load the import data form settings $this->loadImportData(); // Always add organ...
Add the elements from the model to the bridge for file check step @param \MUtil_Model_Bridge_FormBridgeInterface $bridge @param \MUtil_Model_ModelAbstract $model
entailment
protected function addStepCreateTrack(\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 file check step @param \MUtil_Model_Bridge_FormBridgeInterface $bridge @param \MUtil_Model_ModelAbstract $model
entailment
protected function addStepElementsFor(\MUtil_Model_Bridge_FormBridgeInterface $bridge, \MUtil_Model_ModelAbstract $model, $step) { $this->displayHeader($bridge, $this->getFormTitle($step), 'h2'); switch ($step) { case 2: $this->addStepFileCheck($bridge, $model); ...
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 addStepFileCheck(\MUtil_Model_Bridge_FormBridgeInterface $bridge, \MUtil_Model_ModelAbstract $model) { if ($this->onStartStep() && $this->isNextClicked()) { return; } $this->nextDisabled = true; $this->displayHeader($bridge, $this->_('Checking the cont...
Add the elements from the model to the bridge for file check step @param \MUtil_Model_Bridge_FormBridgeInterface $bridge @param \MUtil_Model_ModelAbstract $model
entailment
protected function addStepFileImport(\MUtil_Model_Bridge_FormBridgeInterface $bridge, \MUtil_Model_ModelAbstract $model) { // Reset the data $this->_session->importData = null; $this->displayHeader($bridge, $this->_('Upload a track definition file.'), 'h3'); $this->addItems($bridge...
Add the elements from the model to the bridge for file upload step @param \MUtil_Model_Bridge_FormBridgeInterface $bridge @param \MUtil_Model_ModelAbstract $model
entailment
protected function addStepRoundMatch(\MUtil_Model_Bridge_FormBridgeInterface $bridge, \MUtil_Model_ModelAbstract $model) { $this->displayHeader($bridge, $this->_('Match the current track rounds to import rounds.'), 'h3'); // Load the import data form settings $import = $this->loadImportData...
Add the elements from the model to the bridge for file check step @param \MUtil_Model_Bridge_FormBridgeInterface $bridge @param \MUtil_Model_ModelAbstract $model
entailment
protected function afterFormValidationFor($step) { parent::afterFormValidationFor($step); if (3 == $step) { $import = $this->loadImportData(); $model = $this->getModel(); $saves = array(); foreach ($model->getCol('exportCode') as $name => $exportCo...
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 afterSave($changed) { if ($this->trackEngine) { $this->addMessage($this->_('Track merge finished')); } else { $this->addMessage($this->_('Track import finished')); } $this->cache->clean(\Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG, array('tra...
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
protected function createModel() { if (! $this->importModel instanceof \MUtil_Model_ModelAbstract) { $model = new \MUtil_Model_SessionModel('import_for_' . $this->request->getControllerName()); $model->set('trackFile', 'label', $this->_('A .track.txt file'), 'co...
Creates the model @return \MUtil_Model_ModelAbstract
entailment
protected function displayHeader(\MUtil_Model_Bridge_FormBridgeInterface $bridge, $header, $tagName = 'h2') { static $count = 0; $count += 1; $element = $bridge->getForm()->createElement('html', 'step_header_' . $count); $element->$tagName($header); $bridge->addElement($ele...
Display a header @param \MUtil_Model_Bridge_FormBridgeInterface $bridge @param mixed $header Header content @param string $tagName
entailment
protected function getFormFor($step) { $baseform = $this->createForm(); if ($this->trackEngine && ($step == 4) && (\MUtil_Bootstrap::enabled() !== true) && ($baseform instanceof \MUtil_Form)) { $model = $this->getModel(); $table...
Creates from the model a \Zend_Form using createForm and adds elements using addFormElements(). @param int $step The current step @return \Zend_Form
entailment
protected function getFormTitle($step) { if ($this->trackEngine) { return sprintf( $this->_('Merge import into "%s" track. Step %d of %d.'), $this->trackEngine->getTrackName(), $step, $this->getStepCount() ...
Get the title at the top of the form @param int $step The current step @return string
entailment
protected function loadFormData() { $model = $this->getModel(); if ($this->request->isPost()) { $this->formData = $model->loadPostData($this->request->getPost() + $this->formData, true); } else { // Assume that if formData is set it is the correct formData ...
Hook that loads the form data from $_POST or the model Or from whatever other source you specify here.
entailment
protected function loadImportData() { if (isset($this->_session->importData) && ($this->_session->importData instanceof \ArrayObject)) { // No need to run this after initial load, but we need to // run this every time afterwards. $this->addImportToModelData($this->_sessio...
Load the import data in an array fo the type: \ArrayObject(array( 'track' => array(linenr => array), 'organizations' => array(linenr => array), 'fields' => array(linenr => array), 'surveys' => array(linenr => array), 'rounds' => array(linenr => array), 'errors' => array(linenr => string), )) Stored in session @retur...
entailment
protected function setAfterSaveRoute() { if ($this->_session->localfile && file_exists($this->_session->localfile)) { // Now is a good moment to remove the temporary file @unlink($this->_session->localfile); } $import = $this->loadImportData(); if (isset($im...
Set what to do when the form is 'finished'. @return \Gems\Tracker\Snippets\ImportMergeSnippetAbstract
entailment
protected function validateForm() { if (2 == $this->currentStep) { return true; } // Note we use an MUtil_Form return $this->_form->isValid($this->formData, $this->disableValidatorTranslation); }
Performs the validation. @return boolean True if validation was OK and data should be saved.
entailment