sentence1 stringlengths 52 3.87M | sentence2 stringlengths 1 47.2k | label stringclasses 1
value |
|---|---|---|
public function execute($exportType = null, $command = null, $params = null)
{
$params = array_slice(func_get_args(), 2);
$export = $this->loader->getExport()->getExport($exportType);
$export->setBatch($this->_batch);
if ($messages = call_user_func_array(array($export, $command), $p... | 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 string $exportType Name of export class
@param string $command Command to call in export class
@param array $filter The filter ... | entailment |
public static function initialize($target, $parameters)
{
if (is_array($parameters)) {
foreach ($parameters as $key => $value) {
$method = 'set'.ucfirst(static::camelCase($key));
if (method_exists($target, $method)) {
$target->$method($value);
... | Initialize an object with a given array of parameters
Parameters are automatically converted to camelCase. Any parameters which do
not match a setter on the target object are ignored.
@param mixed $target The object to set parameters on
@param array $parameters An array of parameters to set | entailment |
public static function getMailerClassName($className)
{
if (class_exists($className)) {
return $className;
}
// replace underscores with namespace marker, PSR-0 style
$fullyQualified = '\\Omnimail\\' . str_replace('_', '\\', $className);
if (!class_exists($fullyQ... | Resolve a short Mailer name to a full namespaced Mailer class.
@param string $className
@return string
@throws \Exception | entailment |
protected function _initView($view) {
$baseUrl = \GemsEscort::getInstance()->basepath->getBasePath();
// Make sure we can use jQuery
\MUtil_JQuery::enableView($view);
// Now add the scrollTo plugin so we can scroll to today
$view->headScript()->appendFile($baseUrl . '/gems/js/j... | Initialize the view
Make sure the needed javascript is loaded
@param \Zend_View $view | entailment |
public function createMenuLink($parameterSource, $controller, $action = 'index', $label = null, $menuItem = null) {
if (!is_null($menuItem) || $menuItem = $this->findMenuItem($controller, $action)) {
$item = $menuItem->toActionLinkLower($this->request, $parameterSource, $label);
if (is_o... | Copied, optimised to we use the optional $menuItem we stored in _initView instead
of doing the lookup again and again
@param type $parameterSource
@param type $controller
@param type $action
@param type $label
@param type $menuItem
@return \MUtil_Html_AElement | entailment |
public function getHtmlOutput(\Zend_View_Abstract $view)
{
$html = $this->getHtmlSequence();
$org = $this->token->getOrganization();
$tracker = $this->loader->getTracker();
$html->h3($this->_('Token'));
if ($this->token->hasRelation()) {
$p = $html->pInfo(... | 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 loadFormData()
{
parent::loadFormData();
if ($this->createData && ($this->request->isPost() && (! isset($this->formData[$this->saveButtonId])))) {
if ((! $this->_saveButton) || (! $this->_saveButton->isChecked())) {
if (isset($this->formData['grs_ssn']... | Hook that loads the form data from $_POST or the model
Or from whatever other source you specify here. | entailment |
public function calcultateName($value, $isNew = false, $name = null, array $context = array())
{
$options = $this->util->getDbLookup()->getOrganizations();
$output = [];
foreach (['gaf_filter_text1', 'gaf_filter_text2', 'gaf_filter_text3', 'gaf_filter_text4'] as $field) {
if (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()
{
$options = $this->util->getTranslated()->getEmptyDropdownArray() +
$this->util->getDbLookup()->getOrganizations();
foreach (['gaf_filter_text1', 'gaf_filter_text2', 'gaf_filter_text3', 'gaf_filter_text4'] as $i => $field) {
$output[$fi... | 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 |
protected function getAutoSearchElements(array $data)
{
$elements = parent::getAutoSearchElements($data);
if ($elements) {
$br = \MUtil_Html::create('br');
$elements[] = $this->_createSelectElement('gtr_track_class', $this->model, $this->_('(all track engines)'));
... | 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 getSelect()
{
if (null === $this->_select) {
$db = $this->getAdapter();
/**
* Build select object
*/
$select = new \Zend_Db_Select($db);
$select->from('gems__surveys', array('gsu_export_code'))
->w... | Gets the select object to be used by the validator.
If no select object was supplied to the constructor,
then it will auto-generate one from the given table,
schema, field, and adapter options.
@return Zend_Db_Select The Select object which will be used | entailment |
public function isValid($value, $context = array())
{
$this->_setValue($value);
foreach ($context as $field => $val) {
if (\MUtil_String::startsWith($field, 'survey__')) {
$sid = intval(substr($field, 8));
if (($sid !== $this->_surveyId) && ($value == $va... | 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
@param array $context
@return boolean
@throws \Zend_Validate_Exception If va... | entailment |
protected function getAutoSearchElements(array $data)
{
$elements = parent::getAutoSearchElements($data);
$orgs = $this->currentUser->getRespondentOrganizations();
if (count($orgs) > 1) {
$elements[] = $this->_createSelectElement('gap_id_organization', $orgs, $this->_('(all orga... | 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 setAfterSaveRoute()
{
parent::setAfterSaveRoute();
if ($this->afterSaveRouteUrl) {
$this->afterSaveRouteUrl[\MUtil_Model::REQUEST_ID] = $this->formData['gtf_id_track'];
$this->afterSaveRouteUrl[\Gems_Model::FIELD_ID] = $this->formData['gtf_id_field'];
... | Set what to do when the form is 'finished'.
@return \MUtil_Snippets_ModelFormSnippetAbstract (continuation pattern) | entailment |
protected static function get_extractor_classes()
{
// Check cache
if (self::$sorted_extractor_classes) {
return self::$sorted_extractor_classes;
}
// Generate the sorted list of extractors on demand.
$classes = ClassInfo::subclassesFor(__CLASS__);
array_... | Gets the list of prioritised extractor classes
@return array | entailment |
public static function for_file($file)
{
if (!$file || (is_string($file) && !file_exists($file))) {
return null;
}
// Ensure we have a File instance to work with
if (is_string($file)) {
/** @var File $fileObject */
$fileObject = File::create();
... | Given a File object, decide which extractor instance to use to handle it
@param File|string $file
@return FileTextExtractor|null | entailment |
protected static function getPathFromFile(File $file)
{
$path = tempnam(TEMP_PATH, 'pdftextextractor_');
if (false === $path) {
throw new Exception(static::class . '->getPathFromFile() could not allocate temporary file name');
}
// Append extension to temp file if one is... | Some text extractors (like pdftotext) may require a physical file to read from, so write the current
file contents to a temp file and return its path
@param File $file
@return string
@throws Exception | entailment |
public function getRelation($respondentId, $relationId)
{
$filter = array(
'grr_id_respondent' => $respondentId, // Just a safeguard to make sure we get only relations for this patient
'grr_id' => $relationId
);
$data = $this->loadFirst($filt... | Return an object for a row of this model
@param int $respondentId
@param int $relationId
@return \Gems_Model_RespondentRelationInstance | entailment |
public function getRelationsFor($respondentId, $patientNr = null, $organizationId = null, $onlyActive = true)
{
static $relationsCache = array();
if (is_null($respondentId)) {
$respondentId = $this->loader->getUtil()->getDbLookup()->getRespondentId($patientNr, $organizationId);
... | Get the relations for a given respondentId or patientNr + organizationId combination
@param type $respondentId
@param type $patientNr
@param type $organizationId
@return array | entailment |
public static function getLogger()
{
if (!self::$_logger) {
if ($zfdebug = Zend_Controller_Front::getInstance()->getPlugin('ZFDebug_Controller_Plugin_Debug')) {
self::$_logger = $zfdebug->getPlugin('Log')->getLog();
} else {
return false;
}... | Get the ZFDebug logger
@return Zend_Log | entailment |
public static function errorHandler($level, $message, $file, $line)
{
if (! ($level & error_reporting()))
return false;
switch ($level) {
case E_NOTICE:
case E_USER_NOTICE:
$method = 'notice';
$type = 'Notice';
break... | Debug Bar php error handler
@param string $level
@param string $message
@param string $file
@param string $line
@return bool | entailment |
public function dispatchLoopShutdown()
{
$response = Zend_Controller_Front::getInstance()->getResponse();
foreach ($response->getException() as $e) {
$exception = get_class($e) . ': ' . $e->getMessage()
. ' thrown in ' . str_replace($_SERVER['DOCUMENT_ROOT'], '', $... | Defined by Zend_Controller_Plugin_Abstract
@param Zend_Controller_Request_Abstract
@return void | entailment |
public function loadExtra($name)
{
$useCurrent = ZenValidator::config()->use_current;
$parsleyFolder = 'parsley';
if($useCurrent) {
$parsleyFolder = 'parsley_current';
}
Requirements::javascript(ZENVALIDATOR_PATH . '/javascript/'.$parsleyFolder.'/extra/validator/'... | Load extra validator
@param string $name | entailment |
public function applyParsley()
{
if (!$this->field) {
throw new Exception("A constrained Field does not exist on the FieldSet, check you have the right field name for your ZenValidatorConstraint.");
}
$this->parsleyApplied = true;
if ($this->customMessage) {
$... | Sets the html attributes required for frontend validation
Subclasses should call parent::applyParsley
@return void | entailment |
public function removeParsley()
{
$this->parsleyApplied = false;
if ($this->field && $this->customMessage) {
$this->field->setAttribute(sprintf('data-parsley-%s-message', $this->getConstraintName()), '');
}
if (get_class($this->field) === 'CheckboxSetField') {
... | Removes the html attributes required for frontend validation
Subclasses should call parent::removeParsley
@return void | entailment |
public function validate($value)
{
// The value which comes in is a files array so we can look through this
// to and then get the files to test aspects of them.
if (isset($value['Files'])) {
foreach($value['Files'] as $fileID) {
$file = File::get()->byId($fileID)... | Validate function called for validator.
@param Mixed $value the value of the field being validated.
@return boolean | entailment |
public function getDefaultMessage()
{
switch ($this->type) {
case self::WIDTH:
return sprintf(
_t(
'ZenValidator.DIMWIDTH',
'Image width must be %s pixels'
),
$this->val1
... | Gets the default message for the validator
@return string the validation message | entailment |
protected function addBrowseTableColumns(\MUtil_Model_Bridge_TableBridge $bridge, \MUtil_Model_ModelAbstract $model)
{
$tData = $this->util->getTokenData();
$bridge->gr2t_id_respondent_track; // Data needed for edit button
$bridge->gr2o_id_organization; // Data needed for edit button
... | 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 addColumns(\MUtil_Html_TableElement $table)
{
$table->addColumn(
array(\MUtil_Html::raw($this->repeater->key), 'class' => $this->repeater->class),
$this->_('Question code')
);
$table->addColumn(
array(\MUtil_Html::raw... | Add the columns ot the table
This is a default implementation, overrule at will
@param \MUtil_Html_TableElement $table | entailment |
public function getHtmlOutput(\Zend_View_Abstract $view)
{
$div = \MUtil_Html::create('div');
if ($this->surveyId && $this->data) {
$div->h3(sprintf($this->_('Questions in survey %s'), $this->survey->getName()));
$div->append(parent::getHtmlOutput($view));
} else {
... | 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()
{
// Apply translations
if (! $this->showAnswersTranslated) {
// Here, not in e.g. __construct as these vars may be set during initiation
$this->showAnswersNone = $this->_($this->showAnswersNone);
$this->showAnswersRemoved ... | 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 |
protected function addClass($addClass) {
$targetClass = $this->getAttrib('class');
if(!empty($targetClass) && (strpos($targetClass, $addClass) === false)) {
$targetClass .= " {$addClass}";
} else {
$targetClass = $addClass;
}
$this->setAttrib('class... | Add a class to an existing class, taking care of spacing
@param string $targetClass The existing class
@param string $addClass the Class or classes to add, seperated by spaces | entailment |
public function loadDefaultDecorators()
{
if ($this->loadDefaultDecoratorsIsDisabled()) {
return $this;
}
$htmlTagOptions = array(
'tag' => 'div',
'id' => array('callback' => array(get_class($this), 'resolveElementId')),
);
... | Load default decorators
@return \Zend_Form_Element | entailment |
public function setBasePath($basePath) {
$basePath = (string) $basePath;
if (file_exists($basePath . '/ckeditor.js')) {
$this->basePath = $basePath;
} else {
throw new \Zend_Exception(sprintf('CKEditor.php not found at %s', $basePath));
}
return $... | Set the path to the public files of the CKEditor
@param string $basePath
@return CKEditor_Form_CKEditor | entailment |
public function setCKConfig($key, $value = null) {
if (is_array($key)) {
if (false === $value) {
// Overwrite existing config
$this->config = $key;
} else {
// Add to existing config
foreach ($key as $idx => $value)
... | Set the configuration for the CKEditor
ARRAY
Use array as first parameter to set all items at once. This will
overwrite the existing config. Use false as second parameter to ADD
to the existing config
STRING
or use a string to set items one by one, the second parameter is
the value
@param string|array $key
@param mi... | entailment |
public function setView(\Zend_View_Interface $view = null) {
if (null !== $view) {
if (false === $view->getPluginLoader('helper')->getPaths('CKEditor_View_Helper')) {
$view->addHelperPath('CKEditor/View/Helper', 'CKEditor_View_Helper');
}
}
if (!fi... | Set the view object
Ensures that the view object has the CKEditor view helper path set.
@param \Zend_View_Interface $view
@return CKEditor_Form_CKEditor | entailment |
protected function addFormElements(\Zend_Form $form)
{
$element = $form->createElement('textarea', 'script');
$element->setDescription($this->_('Separate multiple commands with semicolons (;).'));
$element->setLabel('SQL:');
$element->setRequired(true);
$form->addElement($ele... | 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 loadForm()
{
if (! $this->_form) {
$options = array();
if (\MUtil_Bootstrap::enabled()) {
//$options['class'] = 'form-horizontal';
$options['role'] = 'form';
}
$this->_form = $this->createForm($options);
... | Makes sure there is a form. | entailment |
public function getHtmlOutput(\Zend_View_Abstract $view)
{
$output = parent::getHtmlOutput($view);
if ($this->result) {
$output->h3($this->_('Result sets'));
$output[] = $this->getResultTable($this->result);
}
return $output;
} | 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 getResultTable($results)
{
$resultSet = 1;
$resultTable = \MUtil_Html::create()->array();
foreach ($results as $result) {
if (is_string($result)) {
$this->addMessage($result);
} else {
$resultRow = $resultTable->e... | Return an array attribute with the current resultset
@return \MUtil_Html_ArrayAttribute | entailment |
protected function saveData()
{
$resultSet = 0;
if($this->request->isPost()) {
$this->_form->populate($this->request->getPost());
}
if ($this->_saveButton->isChecked() && $this->_form->isValid($this->request->getPost())) {
$data = $this->_form->getValues();
... | Hook containing the actual save code.
@return int The number of "row level" items changed | entailment |
public static function pagePanel($paginator = null, $request = null, $translator = null, $args = null)
{
$types = array(
'paginator' => 'Zend_Paginator',
'request' => 'Zend_Controller_Request_Abstract',
'translator' => 'Zend_Translate',
'view' ... | Create a page panel
@param mixed $paginator \MUtil_Ra::args() arguements
@param mixed $request
@param mixed $translator
@param mixed $args
@return \MUtil_Html_PagePanel | entailment |
public function execute($lineNr = null, $fieldData = null)
{
$batch = $this->getBatch();
$import = $batch->getVariable('import');
if (! (isset($import['trackId']) && $import['trackId'])) {
// Do nothing
return;
}
$tracker = $this->loader->getTra... | 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 _processRowAfterLoad(array $row, $new = false, $isPost = false, &$transformColumns = array())
{
if ($this->_addLoadDependency) {
// Display of data field
if (! (isset($row['gtf_field_type']) && $row['gtf_field_type'])) {
$row['gtf_field_type'] = $this-... | Process on load functions and dependencies
@see addDependency()
@see setOnLoad()
@param array $row The row values to load
@param boolean $new True when it is a new item not saved in the model
@param boolean $isPost True when passing on post data
@param array $transformColumns
@return array The possibly adapted array ... | entailment |
protected function addAppointmentsToModel()
{
$model = new \MUtil_Model_TableModel('gems__track_appointments');
\Gems_Model::setChangeFieldsByPrefix($model, 'gtap');
$map = $model->getItemsOrdered();
$map = array_combine($map, str_replace('gtap_', 'gtf_', $map));
$map['gtap_... | Add appointment model to union model | entailment |
public function applyBrowseSettings($detailed = false)
{
$this->resetOrder();
$yesNo = $this->util->getTranslated()->getYesNo();
$types = $this->getFieldTypes();
$this->set('gtf_id_track'); // Set order
$this->set('gtf_field_name', 'label', $this->_('Name'));
$th... | Set those settings needed for the browse display
@param boolean $detailed For detailed settings
@return \Gems\Tracker\Model\FieldMaintenanceModel (continuation pattern) | entailment |
public function applyDetailSettings()
{
$this->applyBrowseSettings(true);
$this->_addLoadDependency = true;
$this->set('gtf_id_track', 'label', $this->_('Track'),
'multiOptions', $this->util->getTrackData()->getAllTracks()
);
$this->set('gtf... | Set those settings needed for the detailed display
@return \Gems\Tracker\Model\FieldMaintenanceModel (continuation pattern) | entailment |
public function applyEditSettings()
{
$this->applyDetailSettings();
$this->set('gtf_id_field', 'elementClass', 'Hidden');
$this->set('gtf_id_track', 'elementClass', 'Exhibitor');
$this->set('gtf_field_type', 'elementClass', 'Exhibitor');
$this->set(... | Set those values needed for editing
@return \Gems\Tracker\Model\FieldMaintenanceModel (continuation pattern) | entailment |
public function delete($filter = true)
{
$rows = $this->load($filter);
foreach ($rows as $row) {
$name = $this->getModelNameForRow($row);
$field = $row['gtf_id_field'];
if (self::FIELDS_NAME === $name) {
$this->db->delete(
... | 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 |
protected function getFieldType(array &$row)
{
if (isset($row[$this->_modelField]) && ($row[$this->_modelField] === self::APPOINTMENTS_NAME)) {
return 'appointment';
}
if (isset($row['gtf_id_field']) && $row['gtf_id_field']) {
$row[\Gems_Model::FIELD_ID] = $row['gtf_... | Get the type from the row in case it was not set
@param array $row Loaded row
@return string Data type for the row | entailment |
public function getFieldTypes()
{
$output = array(
'activity' => $this->_('Activity'),
'appointment' => $this->_('Appointment'),
'boolean' => $this->_('Boolean'),
'caretaker' => $this->_('Caretaker'),
'consent' => $this->_('Consent'),
... | The list of field types
@return array of storage name => label | entailment |
public function getModelNameForRow(array $row)
{
if (isset($row['gtf_field_type']) && ('appointment' === $row['gtf_field_type'])) {
return self::APPOINTMENTS_NAME;
}
if ((! isset($row['gtf_field_type'])) && isset($row[$this->_modelField]) && $row[$this->_modelField]) {
... | Get the name of the union model that should be used for this row.
@param array $row
@return string | entailment |
public function getTypeDependencyClass($fieldType)
{
if (isset($this->dependencies[$fieldType]) && $this->dependencies[$fieldType]) {
return 'Model\\Dependency\\' . $this->dependencies[$fieldType];
}
} | Get the dependency class name (if any)
@param string $fieldType
@return string Classname including Model\Dependency\ part | entailment |
protected function loadCalculationSources($value, $isNew = false, $name = null, array $context = array(), $isPost = false)
{
if ($isPost) {
return $value;
}
if (isset($context['gtf_filter_id']) && $context['gtf_filter_id']) {
$filters = $this->loader->getAgenda()->ge... | A ModelAbstract->setOnLoad() function that concatenates the
value if it is an array.
@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 be... | entailment |
public function loadFirst($filter = true, $sort = true, $loadDependencies = true)
{
// Needed as the default order otherwise triggers the type dependency
$oldDep = $this->_addLoadDependency;
$this->_addLoadDependency = $loadDependencies;
$output = parent::loadFirst($filter, $sort);
... | Returns an array containing the first requested item.
@param mixed $filter True to use the stored filter, array to specify a different filteloa
@param mixed $sort True to use the stored sort, array to specify a different sort
@param boolean $loadDependencies When true the row dependencies are loaded
@return array An a... | entailment |
protected function addModelSettings(array &$settings)
{
$empty = [];
$multi = explode(parent::FIELD_SEP, $this->_fieldDefinition['gtf_field_values']);
if (empty($this->_fieldDefinition['gtf_field_values']) || empty($multi)) {
$multi = $this->util->getTranslated()->getYesNo();
... | 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 afterRegistry()
{
parent::afterRegistry();
if ($this->showForRespondents && is_bool($this->showForRespondents)) {
$this->showForRespondents = $this->_('Respondents');
}
if ($this->showForStaff && is_bool($this->showForStaff)) {
$this->showForS... | Called after the check that all required registry values
have been set correctly has run.
@return void | entailment |
public function getHtmlOutput(\Zend_View_Abstract $view)
{
$pageRef = array(\MUtil_Model::REQUEST_ID => $this->request->getParam(\MUtil_Model::REQUEST_ID));
$output = false;
$addToLists = \MUtil_Html::create()->div(array('class' => 'tooldock'));
if ($this->showTitle) {
... | Allow manual assignment of surveys/tracks to a patient
If project uses the \Gems_Project_Tracks_MultiTracksInterface, show a track drowpdown
If project uses the \Gems_Project_Tracks_StandAloneSurveysInterface, show a survey
drowpdown for both staff and patient
@param \Zend_View_Abstract $view Just in case it is neede... | entailment |
public function createModel($detailed, $action)
{
$engine = $this->getTrackEngine();
$model = $engine->getFieldsMaintenanceModel($detailed, $action);
return $model;
} | 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 getDeleteQuestion()
{
$field = $this->_getParam('fid');
if (FieldMaintenanceModel::APPOINTMENTS_NAME === $this->_getParam('sub')) {
$used = $this->db->fetchOne(
"SELECT COUNT(*)
FROM gems__respondent2track2appointment
... | Helper function to get the question for the delete action.
@return $string | entailment |
public function getCreateTitle()
{
return sprintf(
$this->_('New field for %s track...') ,
$this->util->getTrackData()->getTrackTitle($this->_getIdParam())
);
} | Helper function to get the title for the create action.
@return $string | entailment |
public function getIndexTitle()
{
return sprintf($this->_('Fields %s'), $this->util->getTrackData()->getTrackTitle($this->_getIdParam()));
} | Helper function to get the title for the index action.
@return $string | entailment |
public function execute($sourceId = null, $userId = null)
{
$batch = $this->getBatch();
$source = $this->loader->getTracker()->getSource($sourceId);
if (is_null($userId)) {
$userId = $this->loader->getCurrentUser()->getUserId();
}
$surveyCount = $batch->addToCo... | 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 execute($trackId = null, $exportOrganizations = false)
{
$batch = $this->getBatch();
$data = $this->db->fetchRow("SELECT * FROM gems__tracks WHERE gtr_id_track = ?", $trackId);
$orgs = $exportOrganizations ? $data['gtr_organizations'] : false;
unset($data['gtr_id_t... | 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 addBrowseTableColumns(\MUtil_Model_Bridge_TableBridge $bridge, \MUtil_Model_ModelAbstract $model)
{
// Make sure these fields are loaded
$model->get('gro_valid_after_field');
$model->get('gro_valid_after_id');
$model->get('gro_valid_after_length');
$model->... | 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 |
public function afterRegistry()
{
parent::afterRegistry();
$model = $this->getModel();
$br = \MUtil_Html::create('br');
$sp = \MUtil_Html::raw(' ');
$this->columns[10] = array('gro_id_order');
$this->columns[20] = array('gro_id_survey');
$this->columns[30] ... | Called after the check that all required registry values
have been set correctly has run.
@return void | entailment |
protected function createModel()
{
if (! $this->model instanceof RoundModel) {
$this->model = $this->trackEngine->getRoundModel(false, 'index');
}
// Now add the joins so we can sort on the real name
// $this->model->addTable('gems__surveys', array('gro_id_survey' => 'gs... | Creates the model
@return \MUtil_Model_ModelAbstract | entailment |
protected function addShowTableRows(\MUtil_Model_Bridge_VerticalTableBridge $bridge, \MUtil_Model_ModelAbstract $model)
{
if ($this->addOnclickEdit) {
$menuItem = $this->getEditMenuItem();
if ($menuItem) {
// Add click to edit
$bridge->tbody()->onclick... | Adds rows 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_VerticalTableBridge $bridge
@param \MUtil_Model_ModelAbstract $model
@return void | entailment |
public function getHtmlOutput(\Zend_View_Abstract $view)
{
if ($table = parent::getHtmlOutput($view)) {
if ($title = $this->getTitle()) {
$htmlDiv = \MUtil_Html::div(array('renderWithoutContent' => false));
$htmlDiv->h3($title);
$this->applyHtmlA... | 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 setShowTableFooter(\MUtil_Model_Bridge_VerticalTableBridge $bridge, \MUtil_Model_ModelAbstract $model)
{
if ($this->displayMenu) {
if (! $this->menuList) {
$this->menuList = $this->menu->getCurrentMenuList($this->request, $this->_('Cancel'));
}
... | Set the footer of the browse table.
Overrule this function to set the header differently, without
having to recode the core table building code.
@param \MUtil_Model_Bridge_VerticalTableBridge $bridge
@param \MUtil_Model_ModelAbstract $model
@return void | entailment |
public function getFormElements(&$form, &$data)
{
$element = $form->createElement('multiCheckbox', 'format');
$element->setLabel($this->_('CSV options'))
->setMultiOptions(array(
'addHeader' => $this->_('Add headers with column names'),
'format... | form elements for extra options for this particular export option
@param \MUtil_Form $form Current form to add the form elements
@param array $data current options set in the form
@return array Form elements | entailment |
protected function addHeader($filename)
{
$file = fopen($filename, 'w');
$bom = pack("CCC", 0xef, 0xbb, 0xbf);
fwrite($file, $bom);
$name = $this->getName();
if (isset($this->data[$name], $this->data[$name]['format'], $this->data[$name]['format'][0]) && in_array('addHeader',... | Add headers to a specific file
@param string $filename The temporary filename while the file is being written | entailment |
public function addRows($data, $modelId, $tempFilename, $filter)
{
$name = $this->getName();
if (isset($data[$name]) && isset($data[$name]['delimiter'])) {
$this->delimiter = $data[$name]['delimiter'];
}
if (!(isset($data[$name], $data[$name]['format'], $data[$name]['form... | 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 |
public function addRow($row, $file)
{
$exportRow = $this->filterRow($row);
$labeledCols = $this->getLabeledColumns();
$exportRow = array_replace(array_flip($labeledCols), $exportRow);
fputcsv($file, $exportRow, $this->delimiter, '"');
} | Add a separate row to a file
@param array $row a row in the model
@param file $file The already opened file | 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 = $this->filterCsvInjection($output);
... | Formatting of strings for CSV export.
@param type $input
@return string | entailment |
public function filterAnswers(\MUtil_Model_Bridge_TableBridge $bridge, \MUtil_Model_ModelAbstract $model, array $currentNames)
{
$repeater = $model->loadRepeatable();
$table = $bridge->getTable();
$table->setRepeater($repeater);
// Filter unless option 'fullanswers' is tr... | This function is called in addBrowseTableColumns() to filter the names displayed
by AnswerModelSnippetGeneric.
@see \Gems_Tracker_Snippets_AnswerModelSnippetGeneric
@param \MUtil_Model_Bridge_TableBridge $bridge
@param \MUtil_Model_ModelAbstract $model
@param array $currentNames The current names in use (allows chain... | entailment |
public function getAnswerDisplaySnippets(\Gems_Tracker_Token $token)
{
$snippets = parent::getAnswerDisplaySnippets($token);
array_unshift($snippets, 'Survey_Display_FullAnswerToggleSnippet');
return $snippets;
} | Function that returns the snippets to use for this display.
@param \Gems_Tracker_Token $token The token to get the snippets for
@return array of Snippet names or nothing | entailment |
protected function createForm($options = null)
{
$form = parent::createForm($options);
$form->activateJQuery();
return $form;
} | Creates the form itself
@param array $options
@return \Gems_Form | entailment |
protected function getAutoSearchElements(array $data)
{
// Search text
$elements = parent::getAutoSearchElements($data);
$this->_addPeriodSelectors($elements, array('grco_created' => $this->_('Date sent')));
$br = \MUtil_Html::create()->br();
$elements[] = null;
... | 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 createModel($detailed, $action)
{
$fields = array();
// Export all
if ('export' === $action) {
$detailed = true;
}
$organizations = $this->util->getDbLookup()->getOrganizations();
$fields[] = 'gtr_track_name';
$sql = "CA... | 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 execute($lineNr = null, $organizationData = null)
{
$batch = $this->getBatch();
$import = $batch->getVariable('import');
if (isset($organizationData['gor_id_organization']) && $organizationData['gor_id_organization']) {
$oldId = $organizationData['gor_id_organi... | 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 addContentString($wikiContent)
{
$isMainContent = isset($this->attribute[$this->separatorCount]) &&
$this->attribute[$this->separatorCount] == '$$';
$this->wikiContentArr[$this->separatorCount] .= $wikiContent;
if ($isMainContent) {
$parsedContent = $t... | 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)
{
$isMainContent = isset($this->attribute[$this->separatorCount]) &&
$this->attribute[$this->separatorCount] == '$$';
$this->wikiContentArr[$this->separatorCount] .= $wik... | 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 addSeparator($token)
{
$this->wikiContent .= $this->wikiContentArr[$this->separatorCount];
++$this->separatorCount;
if ($this->separatorCount > count($this->separators)) {
$this->currentSeparator = end($this->separators);
} else {
$this->curren... | Called by the inline parser, when it found a separator.
@param string $token The token found as a separator | entailment |
public function getWikiContent()
{
return $this->beginTag.$this->wikiContent.$this->wikiContentArr[$this->separatorCount].$this->endTag;
} | Returns the wiki content of the tag.
@return string The content. | entailment |
public function getContent()
{
$cntattr = count($this->attribute);
$count = ($this->separatorCount >= $cntattr) ? ($cntattr - 1) : $this->separatorCount;
for ($i = 0; $i <= $count; ++$i) {
if ($this->attribute[$i] != '$$') {
$this->generator->setAttribute($this->... | Return generators that will generate final content.
@return \WikiRenderer\Generator\InlineGeneratorInterface | entailment |
public function isOtherTagAllowed()
{
if (isset($this->attribute[$this->separatorCount])) {
return ($this->attribute[$this->separatorCount] == '$$');
} else {
return false;
}
} | indicates if the tag can contains other tags.
@return bool true if the tag can contain other tags | entailment |
public function getBogusContent()
{
$generator = $this->documentGenerator->getInlineGenerator('textline');
$generator->addRawContent($this->beginTag);
$m = count($this->contents) - 1;
$s = count($this->separators);
foreach ($this->contents as $k => $v) {
if ($this... | Returns the generated content of the tag.
@return string the content | entailment |
protected function getAutoSearchElements(array $data)
{
$elements = parent::getAutoSearchElements($data);
if ($elements) {
$optionsG = $this->util->getDbLookup()->getGroups();
$elementG = $this->_createSelectElement('gsf_id_primary_group', $optionsG, $this->_('(all functions... | 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 applyBrowseSettings()
{
$formatDate = $this->util->getTranslated()->formatDate;
$this->resetOrder();
$this->setKeys(array(
\Gems_Model::RESPONDENT_TRACK => 'gr2t_id_respondent_track',
\MUtil_Model::REQUEST_ID1 => 'gr2o_patient_nr',
\M... | Set those settings needed for the browse display
@return \Gems_Model_RespondentTrackModel | entailment |
public function applyDetailSettings(\Gems_Tracker_Engine_TrackEngineInterface $trackEngine, $edit = false)
{
$this->resetOrder();
$translated = $this->util->getTranslated();
$formatDate = $this->util->getTranslated()->formatDate;
$this->set('gr2o_patient_nr', 'label', $this->_('R... | Set those settings needed for the detailed display
@param \Gems_Tracker_Engine_TrackEngineInterface $trackEngine
@param boolean $edit When true the fields are added in edit mode
@return \Gems_Model_RespondentTrackModel | entailment |
public function applyEditSettings(\Gems_Tracker_Engine_TrackEngineInterface $trackEngine)
{
$this->applyDetailSettings($trackEngine, true);
$this->addEditTracking();
$this->set('gr2o_patient_nr', 'elementClass', 'Exhibitor');
$this->set('respondent_name', 'elementClass', 'Ex... | Set those values needed for editing
@param \Gems_Tracker_Engine_TrackEngineInterface $trackEngine
@return \Gems_Model_RespondentTrackModel | entailment |
public function applyParameters(array $parameters, $includeNumericFilters = false)
{
if ($parameters) {
// Altkey
if (isset($parameters[\Gems_Model::RESPONDENT_TRACK])) {
$id = $parameters[\Gems_Model::RESPONDENT_TRACK];
unset($parameters[\Gems_Model::... | Stores the fields that can be used for sorting or filtering in the
sort / filter objects attached to this model.
@param array $parameters
@param boolean $includeNumericFilters When true numeric filter keys (0, 1, 2...) are added to the filter as well
@return array The $parameters minus the sort & textsearch keys | entailment |
public function loadNew($count = null, array $filter = null)
{
$values = array();
// Get the defaults
foreach ($this->getItemNames() as $name) {
$value = $this->get($name, 'default');
// Load 'Value' if set
if (null === $value) {
$value =... | Creates new items - in memory only. Extended to load information from linked table using $filter().
When $filter contains the keys gr2o_patient_nr and gr2o_id_organization the corresponding respondent
information is loaded into the new item.
When $filter contains the key gtr_id_track the corresponding track informati... | entailment |
public function save(array $newValues, array $filter = null)
{
$keys = $this->getKeys();
// This is the only key to save on, no matter
// the keys used to initiate the model.
$this->setKeys($this->_getKeysFor('gems__respondent2track'));
// Change the end date until the end ... | 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 getPanel()
{
$panel = '';
$linebreak = $this->getLinebreak();
# Support for APC
if (function_exists('apc_sma_info') && ini_get('apc.enabled')) {
$mem = apc_sma_info();
$memSize = $mem['num_seg'] * $mem['seg_size'];
$memAvail = $me... | Gets content panel for the Debugbar
@return string | entailment |
protected function _addRelation($select)
{
// now add a left join with the round table so we have all tokens, also the ones without rounds
if (!is_null($this->_gemsData['gto_id_relation'])) {
$select->forWhere('gto_id_relation = ?', $this->_gemsData['gto_id_relation']);
} else {
... | Add relation to the select statement
@param Gems_Tracker_Token_TokenSelect $select | entailment |
protected function _ensureRespondentData()
{
if (! isset($this->_gemsData['grs_id_user'], $this->_gemsData['gr2o_id_user'], $this->_gemsData['gco_code'])) {
$sql = "SELECT *
FROM gems__respondents INNER JOIN
gems__respondent2org ON grs_id_user = gr2o_id_user I... | Makes sure the respondent data is part of the $this->_gemsData | entailment |
protected function _getResultFieldLength()
{
if (null !== $this->resultFieldLength) {
return $this->resultFieldLength;
}
if (null !== self::$staticResultFieldLength) {
$this->resultFieldLength = self::$staticResultFieldLength;
return $this->resultFieldLen... | The maximum length of the result field
@return int | entailment |
protected function _updateToken(array $values, $userId)
{
if ($this->tracker->filterChangesOnly($this->_gemsData, $values)) {
if (\Gems_Tracker::$verbose) {
$echo = '';
foreach ($values as $key => $val) {
$echo .= $key . ': ' . $this->_gemsDat... | Update the token, both in the database and in memory.
@param array $values The values that this token should be set to
@param int $userId The current user
@return int 1 if data changed, 0 otherwise | entailment |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.