18 require_once SQ_INCLUDE_PATH.
'/asset.inc';
19 require_once SQ_FUDGE_PATH.
'/general/general.inc';
20 require_once SQ_CORE_PACKAGE_PATH.
'/interfaces/bridge/bridge.inc';
44 var $_errors = Array();
53 var $_answers = Array();
66 $this->_ser_attrs = TRUE;
67 $this->
Asset($assetid);
89 function getAsset($assetid, $type_code=
'', $mute_errors=FALSE)
92 $id_parts = explode(
':', $assetid);
94 if (isset($id_parts[1])) {
95 $shadowid = $id_parts[1];
101 if ($shadowid{0} ==
'q') {
104 $questions = $this->
attr(
'questions');
105 $questionid = substr($shadowid, 1, strlen($shadowid));
106 if (empty($questions[$questionid]))
return $asset;
108 $q_type_code = $questions[$questionid][
'type_code'];
111 if (empty($type_code)) $type_code = $q_type_code;
114 if (in_array($q_type_code, $GLOBALS[
'SQ_SYSTEM']->am->getTypeDescendants($type_code, TRUE))) {
115 $questions[$questionid][
'questionid'] = $questionid;
116 $GLOBALS[
'SQ_SYSTEM']->am->includeAsset($q_type_code);
119 $asset =
new $q_type_code($this->
id, $questions[$questionid]);
150 function getLinks($assetid, $link_types, $type_code=
'', $strict_type_code=TRUE, $side_of_link=
'major', $sort_by=NULL, $dependant=NULL, $exclusive=NULL)
153 if (!is_numeric($assetid)) {
155 if ($side_of_link ==
'minor') {
156 $return_link = FALSE;
158 if ($type_code ==
'') {
161 }
else if ($strict_type_code) {
163 $return_link = ($type_code == $this->
type());
165 $return_link = (in_array($this->
type(), $GLOBALS[
'SQ_SYSTEM']->am->getTypeDescendants($type_code, TRUE)));
171 'majorid' => $this->
id,
172 'minorid' => $this->
id.
':'.$assetid,
173 'major_type_code' => $this->
type(),
175 'link_type' => SQ_LINK_TYPE_2,
176 'is_dependant' => TRUE,
177 'is_exclusive' => FALSE,
191 $real_type_codes = Array(
192 'bodycopy' => SQ_LINK_TYPE_2 | SQ_LINK_TYPE_3,
193 'simple_form' => SQ_LINK_TYPE_2,
196 foreach ($real_type_codes as $real_type_code => $allowed_link_types) {
197 if ($type_code ==
'') {
200 }
else if ($strict_type_code) {
201 $get_type = ($type_code == $real_type_code);
204 $get_type = (in_array($real_type_code, $GLOBALS[
'SQ_SYSTEM']->am->getTypeDescendants($type_code, TRUE)));
209 $links_query = $GLOBALS[
'SQ_SYSTEM']->am->generateGetLinksQuery($assetid, $link_types & $allowed_link_types, $real_type_code, FALSE);
214 foreach($links_query[
'bind_vars'] as $bind_var => $bind_value) {
217 $type_links = MatrixDal::executePdoAssoc($query);
218 }
catch (Exception $e) {
219 throw new Exception($e->getMessage());
222 foreach (array_keys($type_links) as $key) {
223 $type_links[$key][
'sort_order'] = $new_sort_order;
224 $links[] = $type_links[$key];
231 if ($link_types & SQ_LINK_TYPE_2) {
232 $questions = $this->
attr(
'questions');
237 $get_question_types = Array();
239 foreach ($questions as $questionid => $data) {
240 if ($type_code ==
'') {
242 $get_question = TRUE;
243 }
else if ($strict_type_code) {
245 $get_question = ($type_code == $data[
'type_code']);
249 if (isset($get_question_types[$data[
'type_code']])) {
250 $get_question = $get_question_types[$data[
'type_code']];
251 $get_question_types[$data[
'type_code']] = $get_question;
253 $get_question = (in_array($data[
'type_code'], $GLOBALS[
'SQ_SYSTEM']->am->getTypeDescendants($type_code, TRUE)));
260 'majorid' => $this->
id,
261 'minorid' => $this->
id.
':q'.$questionid,
262 'minor_type_code' => $data[
'type_code'],
264 'link_type' => SQ_LINK_TYPE_2,
265 'is_dependant' => TRUE,
266 'is_exclusive' => FALSE,
267 'sort_order' => $new_sort_order,
275 if (is_null($sort_by)) $sort_by =
'sort_order';
277 uasort($links, create_function(
'$a,$b',
'return $a["'.$sort_by.
'"] > $b["'.$sort_by.
'"];'));
293 $old_links = $this->
getLinks($this->
id, SQ_SC_LINK_BACKEND_NAV);
295 while (!empty($old_links)) {
296 array_push($links, array_shift($old_links));
299 $questions = $this->
attr(
'questions');
301 foreach (array_keys($links) as $i) {
304 if ($link[
'minor_type_code'] ==
'bodycopy') {
309 if ($link[
'minor_type_code'] ==
'simple_form') {
317 $link[
'num_kids'] = 0;
318 $link[
'accessible'] = 1;
320 $link[
'assetid'] = $link[
'minorid'];
321 $link[
'type_code'] = $link[
'minor_type_code'];
322 $link[
'linkid'] = $link[
'majorid'].
':'.$link[
'minorid'];
324 $questionid = str_replace($this->
id.
':q',
'', $link[
'assetid']);
327 $link[
'name'] = $questions[$questionid][
'attributes'][
'name'];
328 $link[
'short_name'] = $link[
'name'];
331 $link[
'status'] = $this->status;
333 unset($link[
'minor_type_code']);
334 unset($link[
'majorid']);
335 unset($link[
'minorid']);
336 unset($link[
'value']);
337 unset($link[
'is_exclusive']);
360 function getParents($shadowid, $type_code=
'', $strict_type_code=TRUE)
363 $ret_val = $GLOBALS[
'SQ_SYSTEM']->am->generateGetParentsQuery($this->
id, $type_code, $strict_type_code);
364 if (empty($ret_val))
return Array();
366 $queried_parents = NULL;
369 foreach ($ret_val[
'bind_vars'] as $bind_var => $bind_value) {
374 }
catch (Exception $e) {
375 throw new Exception($e->getMessage());
380 foreach ($queried_parents as $queried_parent) {
381 $parents[$queried_parent[
'majorid']] = $queried_parent[
'type_code'];
384 $parents[$this->id] = $this->
type();
411 function getChildren($assetid, $type_code=
'', $strict_type_code=TRUE, $dependant=NULL, $sort_by=NULL)
414 if (!is_numeric($assetid))
return Array();
416 if (!is_array($type_code)) {
417 if (empty($type_code)) {
418 $type_code = Array();
420 $type_code = Array($type_code);
428 $asset = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($assetid);
429 if (($asset instanceof
Bridge) && ($assetid != $this->
id)) {
430 $children = $asset->getChildren($assetid, $type_code, $strict_type_code, $dependant, $sort_by);
431 $this->forgetAsset($asset);
433 $ret_val = $GLOBALS[
'SQ_SYSTEM']->am->generateGetChildrenQuery($asset, $type_code, $strict_type_code, $dependant, $sort_by);
437 if (!empty($ret_val)) {
438 $sql_array = $ret_val[
'sql_array'];
439 $bind_vars = $ret_val[
'bind_vars'];
444 foreach ($bind_vars as $bind_var => $bind_value) {
447 $result = MatrixDal::executePdoGroupedAssoc($query);
448 }
catch (Exception $e) {
449 throw new Exception($e->getMessage());
457 $entries = $this->
attr(
'questions');
458 if (empty($type_code)) {
459 foreach ($entries as $questionid => $data) {
460 $children[$this->
id.
':q'.$questionid] = Array(Array(
'type_code' => $data[
'type_code']));
463 foreach ($type_code as $this_type_code) {
464 foreach ($entries as $questionid => $data) {
465 if ($strict_type_code) {
466 if ($data[
'type_code'] == $this_type_code) {
467 $children[$this->
id.
':q'.$questionid] = Array(Array(
'type_code' => $data[
'type_code']));
470 $type_desc = $GLOBALS[
'SQ_SYSTEM']->am->getTypeDescendants($this_type_code) + Array($this_type_code);
471 if (in_array($data[
'type_code'], $type_desc)) {
472 $children[$this->
id.
':q'.$questionid] = Array(Array(
'type_code' => $data[
'type_code']));
479 if (!is_null($sort_by)) {
480 uasort($children, create_function(
'$a,$b',
'return $a["'.$sort_by.
'"] > $b["'.$sort_by.
'"]'));
518 function _getName($short_name=FALSE, $contextid=NULL)
521 if ($contextid === NULL) {
522 $contextid = $GLOBALS[
'SQ_SYSTEM']->getContextId();
526 $values = $GLOBALS[
'SQ_SYSTEM']->am->getAttributeValuesByName(
'name', $this->
type(), Array($this->
id), $contextid);
527 if (empty($values) === TRUE) {
528 return parent::_getName($short_name, $contextid);
530 return $values[$this->id];
546 SQ_LINK_TYPE_2 => Array(
549 'exclusive' => FALSE,
551 'simple_form' => Array(
553 'exclusive' => FALSE,
556 SQ_LINK_TYPE_3 => Array(
559 'exclusive' => FALSE,
582 $next_question = $this->
attr(
'next_question');
583 $questions = $this->
attr(
'questions');
587 if (is_null($name)) {
588 $name =
'Question '.$next_question;
592 $questions[$next_question] = Array(
593 'type_code' => $type_code,
595 'sort_order' => count($questions),
596 'attributes' => Array(
602 $this->
setAttrValue(
'next_question', $next_question + 1);
605 $GLOBALS[
'SQ_SYSTEM']->am->acquireLock($this->
id.
':q'.$next_question,
'all', $this->
id, TRUE);
606 $GLOBALS[
'SQ_SYSTEM']->am->updateLock($this->
id,
'all');
623 list($sectionid, $shadowid) = explode(
':q', $assetid);
626 if ($sectionid != $this->
id) {
628 trigger_error(
'Cannot delete question '.$assetid.
' from '.translate(
'asset_format', $this->
_getName(), $this->
id).
' as it does not belong to this section', E_USER_WARNING);
632 $questions = $this->
attr(
'questions');
634 if (!isset($questions[$shadowid])) {
636 trigger_error(
'Cannot delete question '.$assetid.
' from '.translate(
'asset_format', $this->
_getName(), $this->
id).
' as it does not exist', E_USER_WARNING);
639 unset($questions[$shadowid]);
658 $q = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($assetid);
659 echo $q->getHTMLField();
675 if (!isset($this->_is_processed)) {
676 $this->_errors = Array();
677 $this->_answers = Array();
679 foreach ($this->
attr(
'questions') as $shadowid => $data) {
681 $assetid = $this->
id.
':q'.$shadowid;
682 $name =
'q'.$assetid;
683 $q = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($assetid);
687 if (isset($_POST[$name])) $q->setValue($_POST[$name]);
688 $valid = $q->hasValidValue();
690 if (!$valid) $this->_errors = array_merge($this->_errors, $q->getErrors());
692 $this->_answers[$assetid] = Array(
693 'name' => $data[
'name'],
694 'type_code' => $data[
'type_code'],
695 'value' => $q->getValue(),
696 'summary' => $q->getSummary(),
697 'extra_data' => $q->getExtraData(),
698 'is_error' => !$valid,
701 $GLOBALS[
'SQ_SYSTEM']->am->forgetAsset($q);
707 foreach ($GLOBALS[
'SQ_SYSTEM']->am->getLinks($this->id, SQ_LINK_TYPE_2,
'simple_form', FALSE) as $link) {
708 $sectionid = $link[
'minorid'];
709 $s = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($sectionid);
711 $valid = $s->process();
713 $this->_errors = array_merge($this->_errors, $s->getErrors());
716 $this->_answers += array_merge($this->_answers, $s->getAnswers());
718 $GLOBALS[
'SQ_SYSTEM']->am->forgetAsset($s);
722 $this->_is_processed = TRUE;
725 return empty($this->_errors);
738 return $this->_errors;
764 $am = $GLOBALS[
'SQ_SYSTEM']->am;
765 $questions = Array();
767 $questions_raw = $this->
attr(
'questions');
768 foreach ($questions_raw as $q_id => $question) {
769 $new_id = $this->
id.
':q'.$q_id;
770 $questions[$new_id] = $question;
773 unset($questions[$new_id][
'attributes']);
776 if ($include_nested) {
777 $nested_forms = $am->getLinks($this->
id, SQ_SC_LINK_SIGNIFICANT,
'simple_form', FALSE);
778 foreach ($nested_forms as $link) {
779 $form = $am->getAsset($link[
'minorid']);
780 if (!is_null($form)) {
781 $questions = array_merge($questions, $form->getQuestions($include_nested));
782 $am->forgetAsset($form);
814 return $this->_answers;
827 $answer_values = Array();
828 foreach ($this->_answers as $assetid => $data) {
829 $answer_values[$assetid] = $data[
'value'];
831 return $answer_values;
844 $answer_values = Array();
845 foreach ($this->_answers as $assetid => $data) {
846 $answer_values[$assetid] = $data[
'summary'];
848 return $answer_values;
861 $answer_values = Array();
862 foreach ($this->_answers as $assetid => $data) {
863 $answer_values[$assetid] = $data[
'extra_data'];
865 return $answer_values;
889 ?>submission_errors =
new Array();
892 $init_code = ob_get_contents();
897 $questions = $this->
attr(
'questions');
898 foreach (array_keys($questions) as $key) {
899 $q = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($this->
id.
':q'.$key);
901 $q_code = $q->generateJSCode();
902 $code .= $q_code.(empty($q_code) ?
'' :
"\n");
904 $GLOBALS[
'SQ_SYSTEM']->am->forgetAsset($q);
908 foreach ($GLOBALS[
'SQ_SYSTEM']->am->getLinks($this->id, SQ_LINK_TYPE_2,
'simple_form', FALSE) as $link) {
910 $sectionid = $link[
'minorid'];
911 $s = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($sectionid);
912 $section_questions = $s->attr(
'questions');
914 foreach (array_keys($section_questions) as $key) {
915 $q = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($s->id.
':q'.$key);
917 $q_code = $q->generateJSCode();
918 $code .= $q_code.(empty($q_code) ?
'' :
"\n");
920 $GLOBALS[
'SQ_SYSTEM']->am->forgetAsset($q);
924 $GLOBALS[
'SQ_SYSTEM']->am->forgetAsset($s);
931 return $init_code.$code;
946 if (empty($code))
return '';
950 <script
type=
"text/javascript">
951 function beforeSubmit_<?php echo $this->
getPrefix() ?>(form) {
954 if (submission_errors.length > 0) {
955 var errors_list =
"<?php echo translate('core_form_submission_errors'); ?>\n";
956 for(x in submission_errors) {
957 errors_list += submission_errors[x] +
"\n";
968 $code = ob_get_contents();
991 $vars[
'keywords'] = isset($vars[
'keywords']) ? $vars[
'keywords'] : Array();
998 $vars[
'keywords'] = array_merge($vars[
'keywords'], $keywords);
1016 $questions = $this->
attr(
'questions');
1017 $keywords = Array();
1019 foreach ($questions as $shadowid => $question) {
1020 $keywords[$prefix.$this->id.
'_q'.$shadowid] =
'Question Field: '.ellipsisize($question[
'attributes'][
'name'], 30).
' ('.$this->
id.
':q'.$shadowid.
')';
1021 $keywords[$prefix.$this->id.
'_q'.$shadowid.
'_note'] =
'Question Note: '.ellipsisize($question[
'attributes'][
'name'], 30).
' ('.$this->
id.
':q'.$shadowid.
')';
1022 $keywords[$prefix.$this->id.
'_q'.$shadowid.
'_id'] =
'Question ID: '.ellipsisize($question[
'attributes'][
'name'], 30).
' ('.$this->
id.
':q'.$shadowid.
')';
1025 foreach ($GLOBALS[
'SQ_SYSTEM']->am->getLinks($this->id, SQ_LINK_TYPE_2,
'simple_form', FALSE) as $link) {
1027 $sectionid = $link[
'minorid'];
1028 $s = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($sectionid);
1030 $keywords += $s->getDisplayKeywords($prefix);
1031 $keywords[$prefix.$s->id.
'_name'] =
'Nested Form Name: '.$s->name.
' ('.$s->id.
')';
1033 $GLOBALS[
'SQ_SYSTEM']->am->forgetAsset($s);
1037 $keywords[
'submit_button'] =
'Submit Button';
1038 $keywords[
'reset_button'] =
'Reset Button';
1039 $keywords[
'form_errors'] =
'Form Errors';
1059 $questions = $this->
attr(
'questions');
1060 $keywords = Array();
1062 foreach ($questions as $shadowid => $question) {
1063 $keywords[$prefix.$this->id.
'_q'.$shadowid] =
'Summary: '.ellipsisize($question[
'attributes'][
'name'], 30).
' ('.$this->
id.
':q'.$shadowid.
')';
1064 $keywords[$prefix.$this->id.
'_q'.$shadowid.
'_raw'] =
'Raw Response: '.ellipsisize($question[
'attributes'][
'name'], 30).
' ('.$this->
id.
':q'.$shadowid.
')';
1067 foreach ($GLOBALS[
'SQ_SYSTEM']->am->getLinks($this->id, SQ_LINK_TYPE_2,
'simple_form', FALSE) as $link) {
1069 $sectionid = $link[
'minorid'];
1070 $s = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($sectionid);
1072 $keywords += $s->getResponseKeywords($prefix);
1073 $keywords[$prefix.$s->id.
'_name'] =
'Nested Form Name: '.$s->name.
' ('.$s->id.
')';
1075 $GLOBALS[
'SQ_SYSTEM']->am->forgetAsset($s);
1100 $questions = $this->
attr(
'questions');
1101 $keywords = Array();
1103 foreach ($questions as $shadowid => $question) {
1105 $q = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($this->
id.
':q'.$shadowid);
1106 $keywords[$prefix.$this->id.
'_q'.$shadowid] = $q->getHtmlField();
1107 $keywords[$prefix.$this->id.
'_q'.$shadowid.
'_note'] = $q->attr(
'note');
1108 $keywords[$prefix.$this->id.
'_q'.$shadowid.
'_id'] =
'q'.$this->id.
'_q'.$shadowid;
1109 $GLOBALS[
'SQ_SYSTEM']->am->forgetAsset($q);
1113 foreach ($GLOBALS[
'SQ_SYSTEM']->am->getLinks($this->id, SQ_LINK_TYPE_2,
'simple_form', FALSE) as $link) {
1115 $sectionid = $link[
'minorid'];
1116 $s = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($sectionid);
1118 $keywords += $s->getDisplayKeywordReplacements($prefix);
1119 $keywords[$prefix.$s->id.
'_name'] = $s->name;
1121 $GLOBALS[
'SQ_SYSTEM']->am->forgetAsset($s);
1127 submit_button(
'submit_button', $this->
attr(
'submit_button'));
1128 $submit_button = ob_get_contents();
1132 reset_button(
'reset_button', $this->
attr(
'reset_button'));
1133 $reset_button = ob_get_contents();
1136 $keywords[
'submit_button'] = $submit_button;
1137 $keywords[
'reset_button'] = $reset_button;
1138 $keywords[
'form_errors'] = implode(
'<br/>', $this->_errors);
1158 $questions = $this->
attr(
'questions');
1159 $keywords = Array();
1161 foreach ($questions as $shadowid => $question) {
1162 $q = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($this->
id.
':q'.$shadowid);
1163 $keywords[$prefix.$this->id.
'_q'.$shadowid] = htmlentities($q->getSummary(), ENT_NOQUOTES, SQ_CONF_DEFAULT_CHARACTER_SET);
1164 $keywords[$prefix.$this->id.
'_q'.$shadowid.
'_raw'] = htmlentities($q->getValue(), ENT_NOQUOTES, SQ_CONF_DEFAULT_CHARACTER_SET);
1165 $GLOBALS[
'SQ_SYSTEM']->am->forgetAsset($q);
1169 foreach ($GLOBALS[
'SQ_SYSTEM']->am->getLinks($this->id, SQ_LINK_TYPE_2,
'simple_form', FALSE) as $link) {
1171 $sectionid = $link[
'minorid'];
1172 $s = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($sectionid);
1174 $keywords += $s->getResponseKeywordReplacements($prefix);
1175 $keywords[$prefix.$s->id.
'_name'] = $s->name;
1177 $GLOBALS[
'SQ_SYSTEM']->am->forgetAsset($s);
1203 $_bodycopy_link = $GLOBALS[
'SQ_SYSTEM']->am->getLinks($this->
id, SQ_LINK_TYPE_2 | SQ_LINK_TYPE_3,
'bodycopy',
'format');
1204 $bodycopy_link = reset($_bodycopy_link);
1207 if ($bodycopy_link) {
1210 $GLOBALS[
'SQ_SYSTEM']->am->includeAsset(
'bodycopy');
1212 $link_type = ($enable_on_create ? SQ_LINK_TYPE_2 : SQ_LINK_TYPE_3);
1217 'value' =>
'format',
1218 'link_type' => $link_type,
1219 'is_dependant' => 1,
1220 'is_exclusive' => 1,
1223 $asset->setAttrValue(
'name',
'Format Bodycopy');
1224 if (!$asset->create($copy_link))
return FALSE;
1226 $GLOBALS[
'SQ_SYSTEM']->am->forgetAsset($asset);
1249 if ($only_if_enabled) {
1250 $link_types = SQ_LINK_TYPE_2;
1252 $link_types = SQ_LINK_TYPE_2 | SQ_LINK_TYPE_3;
1255 $tmp_bodycopy = $GLOBALS[
'SQ_SYSTEM']->am->getLinks($this->
id, $link_types,
'bodycopy',
'format');
1256 $bodycopy_link = reset($tmp_bodycopy);
1258 if ($bodycopy_link) {
1259 $asset = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($bodycopy_link[
'minorid'],
'bodycopy');
1275 $link_types = SQ_LINK_TYPE_2 | SQ_LINK_TYPE_3;
1277 $_bodycopy_link = $GLOBALS[
'SQ_SYSTEM']->am->getLinks($this->
id, $link_types,
'bodycopy',
'format');
1278 $bodycopy_link = reset($_bodycopy_link);
1280 if ($bodycopy_link) {
1281 return ($bodycopy_link[
'link_type'] == SQ_LINK_TYPE_2);
1301 $tmp_bodycopy = $GLOBALS[
'SQ_SYSTEM']->am->getLinks($this->
id, SQ_LINK_TYPE_2 | SQ_LINK_TYPE_3,
'bodycopy',
'format');
1302 $bodycopy_link = reset($tmp_bodycopy);
1304 if (!$bodycopy_link) {
1312 $new_link_type = ($enabled) ? SQ_LINK_TYPE_2 : SQ_LINK_TYPE_3;
1313 if ($bodycopy_link[
'link_type'] != $new_link_type) {
1314 $GLOBALS[
'SQ_SYSTEM']->am->updateLink($bodycopy_link[
'linkid'], $new_link_type);
1336 function printBody($print_form_tags=TRUE, $submit_buttons=TRUE, $form_action=
'', $print_js=TRUE)
1342 if (empty($form_action)) {
1343 $form_action = $_SERVER[
'PHP_SELF'];
1347 if ($print_js && $this->
attr(
'client_side')) {
1349 $onsubmit =
' onSubmit="return beforeSubmit_'.$this->getPrefix().
'(this)"';
1356 if ($print_form_tags) {
1357 ?><form
id=
"<?php echo $this->getPrefix() ?>" enctype=
"multipart/form-data" action=
"<?php echo $form_action; ?>" method=
"post"<?php echo $onsubmit; ?>><?php
1361 if ($format_bodycopy) {
1367 if ($print_form_tags) {
1386 <?php
foreach ($this->
attr(
'questions') as $shadowid => $question) {
1387 $q = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($this->
id.
':q'.$shadowid);
1388 $name = array_get_index($question[
'attributes'],
'name',
'');
1389 $note = array_get_index($question[
'attributes'],
'note',
'');
1391 $field = $q->getHTMLField();
1394 <td><?php echo $name;
1395 echo ($note ==
'') ?
'' : (
'<br/><span style="font-size:0.8em">'.$note.
'</span>'); ?></td>
1396 <td><?php echo $field; ?></td>
1399 $GLOBALS[
'SQ_SYSTEM']->am->forgetAsset($q);
1403 if ($submit_buttons) {
1405 <tr><td style=
"text-align:center" colspan=
"2"><?php
1406 submit_button(
'submit_button', $this->
attr(
'submit_button'));
1407 reset_button(
'reset_button', $this->
attr(
'reset_button'));
1428 $bodycopy->setKeywordReplacements($replacements);
1429 $bodycopy->printBody();
1454 if ($include_form_info) {
1455 $form_info = Array();
1456 $lineage = $GLOBALS[
'SQ_SYSTEM']->am->getLineageFromURL();
1457 $lineage_names = Array();
1458 foreach ($lineage as $asset) {
1459 $lineage_names[] = $asset[
'name'];
1462 $form_info[] = Array(
1463 'name' =>
'Form Submitted',
1464 'value' => $this->name.
' (Id: #'.$this->id.
')',
1467 $form_info[] = Array(
1468 'name' =>
'Form URL',
1469 'value' => current_url(TRUE, TRUE),
1470 'html_value' =>
'<a href="'.current_url(TRUE, TRUE).
'">'.current_url(TRUE, TRUE).
'</a>',
1473 $form_info[] = Array(
1474 'name' =>
'Form Lineage',
1475 'value' => implode(
' => ', $lineage_names),
1478 $form_info[] = Array(
1479 'name' =>
'Time of Submission',
1480 'value' => date(
'l, j F Y H:i:s \G\M\TO'),
1483 if ($GLOBALS[
'SQ_SYSTEM']->userPublic()) {
1484 $form_info[] = Array(
1485 'name' =>
'Submitted By',
1486 'value' =>
'No logged in user',
1489 $user = $GLOBALS[
'SQ_SYSTEM']->user;
1490 $form_info[] = Array(
1491 'name' =>
'Submitted By',
1492 'value' => $user->name.
' (Id: #'.$user->id.
')',
1499 $max_name_length = 18;
1501 $max_name_length = 0;
1505 foreach ($this->
attr(
'questions') as $shadowid => $question) {
1506 $q = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($this->
id.
':q'.$shadowid);
1507 $name = array_get_index($question[
'attributes'],
'name',
'');
1508 $summary = $q->getSummary();
1512 'value' => $summary,
1514 $max_name_length = max($max_name_length, strlen($name));
1516 $GLOBALS[
'SQ_SYSTEM']->am->forgetAsset($q);
1526 if ($include_form_info) {
1528 <tr><td colspan=
"2"><strong>
Form Information</strong></td></tr>
1529 <?php
foreach ($form_info as $form_info_item) {
1532 <td valign=
"top"><ul><li><?php echo htmlspecialchars($form_info_item[
'name']); ?>:</li></ul></td>
1533 <td valign=
"top"><?php echo array_get_index($form_info_item,
'html_value', htmlspecialchars($form_info_item[
'value'])); ?></td>
1537 ?><tr><td colspan=
"2"><strong>
Form Responses</strong></td></tr><?php
1541 <?php
foreach ($answers as $answer) {
1544 <td valign=
"top"><ul><li><?php echo htmlspecialchars($answer[
'name']); ?>:</li></ul></td>
1545 <td valign=
"top"><?php echo htmlspecialchars($answer[
'value']); ?></td>
1554 if ($include_form_info) {
1555 echo
'=== Form Information ==='.
"\n";
1556 foreach ($form_info as $form_info_item) {
1557 echo
'* '.str_pad($form_info_item[
'name'], $max_name_length + 1).
': '.$form_info_item[
'value'].
"\n";
1560 echo
'=== Form Responses ==='.
"\n";
1563 foreach ($answers as $answer) {
1564 echo
'* '.str_pad($answer[
'name'], $max_name_length + 1).
': '.$answer[
'value'].
"\n";
1608 function countLinks($assetid, $side_of_link=
'major', $link_types=0, $type_code=
'', $strict_type_code=TRUE, $ignore_linkid=0)