Skip to content

Commit

Permalink
Update InstanceTable.php
Browse files Browse the repository at this point in the history
  • Loading branch information
lsgs committed Oct 19, 2022
1 parent 4871274 commit ac2746c
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions InstanceTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class InstanceTable extends AbstractExternalModule
const ACTION_TAG_FILTER = '@INSTANCETABLE_FILTER';
const ADD_NEW_BTN_YSHIFT = '0px';
const MODULE_VARNAME = 'MCRI_InstanceTable';
const ACTION_TAG_DESC = 'Use with descriptive text fields to display a table of data from instances of a repeating form, or forms in a repeating event, with (for users with edit permissions) links to add/edit instances in a popup window.<br>* @INSTANCETABLE=my_form_name<br>* @INSTANCETABLE=event_name:my_form_name<br>There are some additional tags that may be used to further tweak the table behaviour. Take a look at the documentation via the External Modulers page for more information.';
const ACTION_TAG_DESC = 'Use with descriptive text fields to display a table of data from instances of a repeating form, or forms in a repeating event, with (for users with edit permissions) links to add/edit instances in a popup window.<br>* @INSTANCETABLE=my_form_name<br>* @INSTANCETABLE=event_name:my_form_name<br>There are some additional tags that may be used to further tweak the table behaviour. Take a look at the documentation via the External Modules page for more information.';

const ERROR_NOT_REPEATING_CLASSIC = '<div class="red">ERROR: "%s" is not a repeating form. Contact the project designer.';
const ERROR_NOT_REPEATING_LONG = '<div class="red">ERROR: "%s" is not a repeating form for event "%s". Contact the project designer.';
Expand Down Expand Up @@ -365,14 +365,14 @@ protected function makeHtmlTable($repeatingFormDetails, $canEdit) {
foreach ($instanceData as $rowValues) {
$html.='<tr>';
foreach ($rowValues as $value) {
$html.="<td>".htmlspecialchars($value, ENT_QUOTES)."</td>";
$html.="<td>".REDCap::filterHtml($value)."</td>"; // $html.="<td>".htmlspecialchars($value, ENT_QUOTES)."</td>";
}
$html.='</tr>';
}
$html.='</tbody>';
} else {
// $html.='<tr><td colspan="'.$nColumns.'">No data available in table</td></tr>';
// unnecessary and DT does not supprt colspan in bidy tr // https://datatables.net/forums/discussion/32575/uncaught-typeerror-cannot-set-property-dt-cellindex-of-undefined
// unnecessary and DT does not supprt colspan in body tr // https://datatables.net/forums/discussion/32575/uncaught-typeerror-cannot-set-property-dt-cellindex-of-undefined
}
}

Expand Down Expand Up @@ -403,6 +403,7 @@ public function getInstanceData($record, $event, $form, $fields, $filter, $inclu

if (!empty($recordData[$record]['repeat_instances'][$event][$formKey])) {
foreach ($recordData[$record]['repeat_instances'][$event][$formKey] as $instance => $instanceFieldData) {
$instance = \intval($instance);
$thisInstanceValues = array();
$thisInstanceValues[] = $this->makeInstanceNumDisplay($instance, $record, $event, $form, $instance);

Expand Down Expand Up @@ -441,7 +442,7 @@ public function getInstanceData($record, $event, $form, $fields, $filter, $inclu
$outValue = $value;
}

$thisInstanceValues[] = htmlspecialchars($outValue, ENT_QUOTES);
$thisInstanceValues[] = \REDCap::filterHtml($outValue);
}

$instanceData[] = $thisInstanceValues;
Expand Down Expand Up @@ -815,7 +816,7 @@ public function redcap_every_page_before_render($project_id) {
$recordData = REDCap::getData('array',$_GET['id'],$_GET['page'].'_complete',$_GET['event_id']);

$currentInstances = array_keys($recordData[$_GET['id']]['repeat_instances'][$_GET['event_id']][$formKey]);
$_GET['instance'] = 1 + end($currentInstances);
$_GET['instance'] = (is_null($currentInstances)) ? 1 : 1 + end($currentInstances);

} else if (PAGE==='Design/action_tag_explain.php') {
$lastActionTagDesc = end(Form::getActionTags());
Expand Down

0 comments on commit ac2746c

Please sign in to comment.