17 require_once SQ_INCLUDE_PATH.
'/asset.inc';
18 require_once SQ_CORE_PACKAGE_PATH.
'/interfaces/bridge/bridge.inc';
38 var $question_index = 0;
44 var $question_col_width = 0;
50 var $answer_col_width = 0;
56 var $current_answers = Array();
63 var $extra_data = Array();
70 var $submission_errors = Array();
81 $this->_ser_attrs = TRUE;
82 $this->
Asset($assetid);
106 if (!parent::_updated($update_parents))
return FALSE;
123 SQ_LINK_TYPE_2 => Array(
124 'form_section' => Array(
126 'exclusive' => FALSE,
130 'exclusive' => FALSE,
133 SQ_LINK_TYPE_3 => Array(
136 'exclusive' => FALSE,
165 public function prepareLink(
Asset $asset, $side_of_link, &$link_type, &$value, &$sort_order, &$dependant, &$exclusive)
168 if ($side_of_link ==
'major' && ($asset instanceof
Form_Section) && $dependant !=
'1') {
170 $link_type = SQ_LINK_TYPE_2;
204 function cloneComponents(&$clone, $components, $override=FALSE)
206 $GLOBALS[
'SQ_SYSTEM']->changeDatabaseConnection(
'db2');
207 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'BEGIN');
209 if (!parent::cloneComponents($clone, $components, $override)) {
210 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
211 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
215 if (in_array(
'attributes', $components) || in_array(
'all', $components)) {
216 $sort_order = $this->
attr(
'sort_order');
217 $sort_order = str_replace($this->
id.
':q', $clone->id.
':q', $sort_order);
220 $clone->setAttrValue(
'sort_order', $sort_order);
221 $clone->saveAttributes();
225 $form_parents = $GLOBALS[
'SQ_SYSTEM']->am->getDependantParents($this->
id,
'form_email', FALSE);
226 $clone_form_parents = $GLOBALS[
'SQ_SYSTEM']->am->getDependantParents($clone->id,
'form_email', FALSE);
228 $clone_form_parents = array_diff($clone_form_parents, $form_parents);
230 foreach ($clone_form_parents as $parent_assetid) {
231 $form = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($parent_assetid);
233 $recip = unserialize($form->attr(
'recipient_emails_format'));
234 $recip = str_replace(
'%response_'.$this->
id.
'_',
'%response_'.$clone->id.
'_', $recip);
235 $rec = unserialize($form->attr(
'receipt_emails_format'));
236 $rec = str_replace(
'%response_'.$this->
id.
'_',
'%response_'.$clone->id.
'_', $rec);
237 $staf = unserialize($form->attr(
'staf_format'));
238 $staf = str_replace(
'%response_'.$this->
id.
'_',
'%response_'.$clone->id.
'_', $staf);
239 $sel = $form->attr(
'selective_emails');
240 foreach ($sel as $key => $null) {
241 $sel[$key][
'address'] = str_replace(
'%response_'.$this->
id.
'_',
'%response_'.$clone->id.
'_', $sel[$key][
'address']);
242 $sel[$key][
'assetid'] = str_replace($this->
id.
':q', $clone->id.
':q', $sel[$key][
'assetid']);
246 $staf_field = str_replace($this->
id.
':q', $clone->id.
':q', $form->attr(
'staf_field'));
247 $receipt_field = str_replace($this->
id.
':q', $clone->id.
':q', $form->attr(
'receipt_field'));
250 $form->setAttrValue(
'recipient_emails_format', serialize($recip));
251 $form->setAttrValue(
'receipt_emails_format', serialize($rec));
252 $form->setAttrValue(
'staf_format', serialize($staf));
253 $form->setAttrValue(
'selective_emails', $sel);
255 $form->setAttrValue(
'staf_field', $staf_field);
256 $form->setAttrValue(
'receipt_field', $receipt_field);
258 $form->saveAttributes();
262 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'COMMIT');
263 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
279 function _getName($short_name=FALSE, $contextid=NULL)
282 if ($contextid === NULL) {
283 $contextid = $GLOBALS[
'SQ_SYSTEM']->getContextId();
287 $values = $GLOBALS[
'SQ_SYSTEM']->am->getAttributeValuesByName(
'name', $this->
type(), Array($this->
id), $contextid);
288 if (empty($values) === TRUE) {
289 return parent::_getName($short_name, $contextid);
291 return $values[$this->id];
314 function getAsset($shadowid, $type_code=
'', $mute_errors=FALSE)
317 $id_parts = explode(
':', $shadowid);
319 if (isset($id_parts[1])) {
320 $shadowid = $id_parts[1];
326 if ($shadowid{0} ==
'q') {
329 $questions = $this->
attr(
'questions');
330 $questionid = substr($shadowid, 1, strlen($shadowid));
331 if (empty($questions[$questionid]))
return $asset;
333 $q_type_code = $questions[$questionid][
'question_type_code'];
336 if (empty($type_code)) $type_code = $q_type_code;
339 if (in_array($q_type_code, $GLOBALS[
'SQ_SYSTEM']->am->getTypeDescendants($type_code, TRUE))) {
340 $questions[$questionid][
'questionid'] = $questionid;
341 $GLOBALS[
'SQ_SYSTEM']->am->includeAsset($q_type_code);
344 $asset =
new $q_type_code($this->
id, $questions[$questionid]);
366 if (!is_numeric($assetid)) {
367 if ($side_of_link ==
'minor') {
370 'majorid' => $this->
id,
371 'minorid' => $this->
id.
':'.$assetid,
372 'major_type_code' => $this->
type(),
374 'link_type' => SQ_LINK_TYPE_2,
375 'is_dependant' => TRUE,
376 'is_exclusive' => FALSE,
384 $id_parts = explode(
':', $linkid);
385 if (isset($id_parts[1]) && isset($id_parts[2])) {
386 $looking_for = $id_parts[1].
':'.$id_parts[2];
387 $tmp_question_nb = str_replace(
'q',
'', $id_parts[2]);
388 $questions = $this->
attr(
'questions');
389 if (isset($questions[$tmp_question_nb])) {
392 'majorid' => $this->
id,
393 'minorid' => $this->
id.
':q'.$tmp_question_nb,
394 'minor_type_code' => $questions[$tmp_question_nb][
'question_type_code'],
396 'link_type' => SQ_LINK_TYPE_2,
397 'is_dependant' => TRUE,
398 'is_exclusive' => FALSE,
431 function countLinks($assetid, $side_of_link=
'major', $link_types=0, $type_code=
'', $strict_type_code=TRUE, $ignore_linkid=0)
433 $tmp_questions = $this->
attr(
'questions');
434 if (isset($tmp_questions)) {
435 return count($tmp_questions);
453 $id_parts = explode(
':', $linkid);
454 if (isset($id_parts[1]) && isset($id_parts[2])) {
455 $question_to_delete = $id_parts[1].
':'.$id_parts[2];
456 $asset_to_delete = $this->
getAsset($question_to_delete);
457 if ($asset_to_delete != NULL) {
487 function getLinks($assetid, $link_types, $type_code=
'', $strict_type_code=TRUE, $side_of_link=
'major', $sort_by=NULL)
492 if (!is_numeric($assetid)) {
493 if ($side_of_link ==
'minor') {
494 $return_link = FALSE;
496 if ($type_code ==
'') {
499 }
else if ($strict_type_code) {
501 $return_link = ($type_code == $this->
type());
503 $return_link = (in_array($this->
type(), $GLOBALS[
'SQ_SYSTEM']->am->getTypeDescendants($type_code, TRUE)));
509 'majorid' => $this->
id,
510 'minorid' => $this->
id.
':'.$assetid,
511 'major_type_code' => $this->
type(),
513 'link_type' => SQ_LINK_TYPE_2,
514 'is_dependant' => TRUE,
515 'is_exclusive' => FALSE,
529 if ($link_types & SQ_LINK_TYPE_2) {
530 $questions = $this->
attr(
'questions');
535 $get_question_types = Array();
537 foreach ($questions as $questionid => $data) {
538 if ($type_code ==
'') {
540 $get_question = TRUE;
541 }
else if ($strict_type_code) {
543 $get_question = ($type_code == $data[
'question_type_code']);
547 if (isset($get_question_types[$data[
'question_type_code']])) {
548 $get_question = $get_question_types[$data[
'question_type_code']];
549 $get_question_types[$data[
'question_type_code']] = $get_question;
551 $get_question = (in_array($data[
'question_type_code'], $GLOBALS[
'SQ_SYSTEM']->am->getTypeDescendants($type_code, TRUE)));
558 'majorid' => $this->
id,
559 'minorid' => $this->
id.
':q'.$questionid,
560 'minor_type_code' => $data[
'question_type_code'],
562 'link_type' => SQ_LINK_TYPE_2,
563 'is_dependant' => TRUE,
564 'is_exclusive' => FALSE,
565 'sort_order' => $new_sort_order,
573 if (is_null($sort_by)) $sort_by =
'sort_order';
575 uasort($links, create_function(
'$a,$b',
'return $a["'.$sort_by.
'"] > $b["'.$sort_by.
'"];'));
591 $old_links = $this->
getLinks($this->
id, SQ_SC_LINK_BACKEND_NAV);
593 while (!empty($old_links)) {
594 array_push($links, array_shift($old_links));
597 $questions = $this->
attr(
'questions');
599 foreach (array_keys($links) as $i) {
609 $link[
'num_kids'] = 0;
610 $link[
'accessible'] = 1;
612 $link[
'assetid'] = $link[
'minorid'];
613 $link[
'type_code'] = $link[
'minor_type_code'];
614 $link[
'linkid'] = $link[
'majorid'].
':'.$link[
'minorid'];
616 $questionid = str_replace($this->
id.
':q',
'', $link[
'assetid']);
619 $link[
'name'] = $questions[$questionid][
'attributes'][
'name'];
620 $link[
'short_name'] = $link[
'name'];
623 $link[
'status'] = $this->status;
625 unset($link[
'minor_type_code']);
626 unset($link[
'majorid']);
627 unset($link[
'minorid']);
628 unset($link[
'value']);
629 unset($link[
'is_exclusive']);
652 function getParents($shadowid, $type_code=
'', $strict_type_code=TRUE)
655 $ret_val = $GLOBALS[
'SQ_SYSTEM']->am->generateGetParentsQuery($this->
id, $type_code, $strict_type_code);
656 if (empty($ret_val))
return Array();
659 foreach ($ret_val[
'bind_vars'] as $bind_var => $bind_value) {
666 foreach ($queried_parents as $queried_parent) {
667 $parents[$queried_parent[
'majorid']] = $queried_parent[
'type_code'];
671 $parents[$this->id] = $this->
type();
700 function getChildren($assetid, $type_code=
'', $strict_type_code=TRUE, $dependant=NULL, $sort_by=NULL)
703 if (!is_numeric($assetid))
return Array();
705 if (!is_array($type_code)) {
706 if (empty($type_code)) {
707 $type_code = Array();
709 $type_code = Array($type_code);
718 $entries = $this->
attr(
'questions');
719 if (empty($type_code)) {
720 foreach ($entries as $questionid => $data) {
721 $children[$this->
id.
':q'.$questionid] = Array(Array(
'type_code' => $data[
'question_type_code']));
724 foreach ($type_code as $this_type_code) {
725 foreach ($entries as $questionid => $data) {
726 if ($strict_type_code) {
727 if ($data[
'question_type_code'] == $this_type_code) {
728 $children[$this->
id.
':q'.$questionid] = $data[
'question_type_code'];
731 $type_desc = $GLOBALS[
'SQ_SYSTEM']->am->getTypeDescendants($this_type_code) + Array($this_type_code);
732 if (in_array($data[
'question_type_code'], $type_desc)) {
733 $children[$this->
id.
':q'.$questionid] = Array(Array(
'type_code' => $data[
'question_type_code']));
740 if (!is_null($sort_by)) {
741 uasort($children, create_function(
'$a,$b',
'return $a["'.$sort_by.
'"] > $b["'.$sort_by.
'"]'));
796 $edit->generateContentFile($this);
801 $links = $GLOBALS[
'SQ_SYSTEM']->am->getLinks($this->
id, SQ_LINK_TYPE_2,
'form', FALSE,
'minor');
803 foreach ($links as $l) {
804 $form = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($l[
'majorid'], $l[
'major_type_code']);
805 if (is_null($form))
continue;
806 if (!$form->_updated()) {
835 foreach ($questions as $q_id => $question) {
836 $q_asset = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($this->
id.
':q'.$q_id);
837 $q_code = $q_asset->generateJSCode();
839 $code .= $q_code.(empty($q_code) ?
'' :
"\n");
860 return $this->
attr(
'questions');
875 $am = $GLOBALS[
'SQ_SYSTEM']->am;
878 $questions = $this->
attr(
'questions');
879 if (!empty($questions)) {
880 foreach ($questions as $q_id => $question) {
881 if (empty($type_code) || ($question[
'question_type_code'] === $type_code)) {
882 $id = $this->
id.
':q'.$q_id;
883 $result[$id] = $am->getAsset($id);
907 foreach ($nested_sections as $section_link) {
908 $section = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($section_link[
'minorid']);
909 $questions += $section->getAllQuestionAssets($type_code);
927 return (isset($questions[$questionid])) ? $questions[$questionid] : Array();
942 $sort_order = $this->
attr(
'sort_order');
943 $question = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($sort_order[$orderid]);
961 $GLOBALS[
'SQ_SYSTEM']->changeDatabaseConnection(
'db2');
964 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'BEGIN');
967 if ($this->
attr(
'next_questionid') > 0) {
968 $new_key = $this->
attr(
'next_questionid');
969 }
else if (empty($questions)) {
972 $new_key = max(array_keys($questions)) + 1;
975 $questions[$new_key] = Array(
976 'question_type_code' => $type_code,
977 'attributes' => Array(
978 'name' =>
'Question '.(count($questions)+1),
985 $sort_order = $this->
attr(
'sort_order');
987 if (empty($sort_order)) {
990 $new_index = max(array_keys($sort_order))+1;
992 $sort_order[$new_index] = $this->
id.
':q'.$new_key;
996 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
997 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
1000 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'COMMIT');
1001 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
1020 if ($question->_questionid == 0)
return FALSE;
1022 $GLOBALS[
'SQ_SYSTEM']->changeDatabaseConnection(
'db2');
1023 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'BEGIN');
1026 unset($questions[$question->_questionid]);
1030 $sort_order = $this->
attr(
'sort_order');
1033 $old_index = array_search($question->id, $sort_order);
1034 unset($sort_order[$old_index]);
1042 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
1043 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
1046 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'COMMIT');
1047 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
1063 return count($questions);
1082 'link_value' => Array(
''),
1085 $sql_query = $GLOBALS[
'SQ_SYSTEM']->am->generateGetLinksQuery($this->
id, SQ_LINK_TYPE_2,
'form_section', TRUE,
'major', $value,
'1',
'0');
1086 if (empty($sql_query))
return Array();
1087 $sql_query[
'sql_array'][
'select'] .=
', l.majorid';
1091 $sql = implode(
' ', $sql_query[
'sql_array']);
1093 foreach ($sql_query[
'bind_vars'] as $bind_var => $bind_value) {
1097 }
catch (Exception $e) {
1098 throw new Exception(
'Unable to get section links attached to form_section: '.$this->
id.
' due to database error: '.$e->getMessage());
1147 $form_width = $form->
attr(
'form_width');
1148 $question_width = $form->
attr(
'question_col_width');
1149 $response_width = $form->
attr(
'answer_col_width');
1151 include $this->data_path.
'/content_file.php';
1153 if ($submit_buttons) {
1156 <table width=
"<?php echo $form_width; ?>">
1158 <td width=
"<?php echo $question_width; ?>"> </td>
1159 <td width=
"<?php echo $response_width; ?>">
1166 $content = ob_get_clean();
1168 require_once SQ_FUDGE_PATH.
'/general/text.inc';
1170 $keyword_list = extract_keywords($content);
1171 if (!empty($keyword_list)) {
1172 foreach ($keyword_list as $keyword) {
1173 if (isset($replacements[$keyword]))
continue;
1176 replace_keywords($content, $replacements);
1197 if (!$format_bodycopy) {
1200 trigger_error(
'Form Section asked for a custom format when it has no format bodycopy enabled. This should not happen.', E_USER_ERROR);
1203 $keywords = $format_bodycopy->getKeywords();
1204 $replacements = Array();
1206 foreach ($keywords as $keyword) {
1211 if (is_null($replacement)) {
1218 if (!is_null($replacement)) {
1219 $replacements[$keyword] = $replacement;
1224 $format_bodycopy->setKeywordReplacements($replacements);
1225 $format_bodycopy->printBody();
1230 function printSemanticSummary()
1234 foreach ($this->
attr(
'sort_order') as $sort_order => $question_assetid) {
1237 if ($this->
id == strtok($question_assetid,
':')) {
1238 $question = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($question_assetid);
1239 echo
'<dt>'.$question->attr(
'name').
'</dt>'.
"\n";
1240 echo
'<dd>'.htmlentities($question->getSummary(), ENT_NOQUOTES).
'</dd>'.
"\n";
1249 if (count($section_links) > 0) {
1253 foreach ($section_links as $section_link) {
1255 $section = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($section_link[
'minorid']);
1256 echo
'<strong>'.htmlentities($section->attr(
'name'), ENT_NOQUOTES).
'</strong>'.
"\n";
1257 $section->printSemanticSummary();
1261 if (count($section_links) > 0) {
1285 $_bodycopy_link = $GLOBALS[
'SQ_SYSTEM']->am->getLinks($this->
id, SQ_LINK_TYPE_2 | SQ_LINK_TYPE_3,
'bodycopy',
'format');
1286 $bodycopy_link = reset($_bodycopy_link);
1289 if ($bodycopy_link) {
1292 $GLOBALS[
'SQ_SYSTEM']->am->includeAsset(
'bodycopy');
1294 $link_type = ($enable_on_create ? SQ_LINK_TYPE_2 : SQ_LINK_TYPE_3);
1299 'value' =>
'format',
1300 'link_type' => $link_type,
1301 'is_dependant' => 1,
1302 'is_exclusive' => 1,
1305 $asset->setAttrValue(
'name',
'Format Bodycopy');
1306 if (!$asset->create($copy_link))
return FALSE;
1308 $GLOBALS[
'SQ_SYSTEM']->am->forgetAsset($asset);
1331 if ($only_if_enabled) {
1332 $link_types = SQ_LINK_TYPE_2;
1334 $link_types = SQ_LINK_TYPE_2 | SQ_LINK_TYPE_3;
1337 $tmp_bodycopy = $GLOBALS[
'SQ_SYSTEM']->am->getLinks($this->
id, $link_types,
'bodycopy',
'format');
1338 $bodycopy_link = reset($tmp_bodycopy);
1340 if ($bodycopy_link) {
1341 $asset = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($bodycopy_link[
'minorid'],
'bodycopy');
1357 $link_types = SQ_LINK_TYPE_2 | SQ_LINK_TYPE_3;
1359 $_bodycopy_link = $GLOBALS[
'SQ_SYSTEM']->am->getLinks($this->
id, $link_types,
'bodycopy',
'format');
1360 $bodycopy_link = reset($_bodycopy_link);
1362 if ($bodycopy_link) {
1363 return ($bodycopy_link[
'link_type'] == SQ_LINK_TYPE_2);
1383 $tmp_bodycopy = $GLOBALS[
'SQ_SYSTEM']->am->getLinks($this->
id, SQ_LINK_TYPE_2 | SQ_LINK_TYPE_3,
'bodycopy',
'format');
1384 $bodycopy_link = reset($tmp_bodycopy);
1386 if (!$bodycopy_link) {
1394 $new_link_type = ($enabled) ? SQ_LINK_TYPE_2 : SQ_LINK_TYPE_3;
1395 if ($bodycopy_link[
'link_type'] != $new_link_type) {
1396 $GLOBALS[
'SQ_SYSTEM']->am->updateLink($bodycopy_link[
'linkid'], $new_link_type);
1421 $vars[
'keywords'] = isset($vars[
'keywords']) ? $vars[
'keywords'] : Array();
1422 $keywords = Array();
1428 $vars[
'keywords'] = array_merge($vars[
'keywords'], $keywords);
1448 $questions = $this->
attr(
'questions');
1449 $keywords = Array();
1451 foreach ($questions as $shadowid => $question) {
1452 $keywords[
'question_field_'.$this->id.
'_q'.$shadowid] =
'Question Field: '.ellipsisize($question[
'attributes'][
'name'], 30).
' ('.$this->
id.
':q'.$shadowid.
')';
1453 $keywords[
'question_name_'.$this->id.
'_q'.$shadowid] =
'Question Name: '.ellipsisize($question[
'attributes'][
'name'], 30).
' ('.$this->
id.
':q'.$shadowid.
')';
1454 $keywords[
'question_id_'.$this->id.
'_q'.$shadowid] =
'Question ID: '.ellipsisize($question[
'attributes'][
'name'], 30).
' ('.$this->
id.
':q'.$shadowid.
')';
1455 $keywords[
'question_note_'.$this->id.
'_q'.$shadowid] =
'Question Note: '.ellipsisize($question[
'attributes'][
'name'], 30).
' ('.$this->
id.
':q'.$shadowid.
')';
1456 $keywords[
'question_label_'.$this->id.
'_q'.$shadowid] =
'Question Label: '.ellipsisize($question[
'attributes'][
'name'], 30).
' ('.$this->
id.
':q'.$shadowid.
')';
1459 foreach ($GLOBALS[
'SQ_SYSTEM']->am->getLinks($this->id, SQ_LINK_TYPE_2,
'form_section', FALSE) as $link) {
1461 $sectionid = $link[
'minorid'];
1462 $s = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($sectionid);
1464 $keywords += $s->getDisplayKeywords();
1465 $keywords[
'section_title_'.$s->id] =
'Nested Section Name: '.$s->name.
' ('.$s->id.
')';
1466 $keywords[
'section_contents_'.$s->id] =
'Nested Section Contents: '.$s->name.
' ('.$s->id.
')';
1468 $GLOBALS[
'SQ_SYSTEM']->am->forgetAsset($s);
1472 if ($include_submit_keywords) {
1473 $keywords[
'submit_button'] =
'Submit Button';
1474 $keywords[
'reset_button'] =
'Reset Button';
1475 $keywords[
'form_errors'] =
'Form Errors';
1493 $questions = $this->
attr(
'questions');
1494 $keywords = Array();
1496 foreach ($questions as $shadowid => $question) {
1497 $keywords[
'response_'.$this->id.
'_q'.$shadowid] = translate(
'cms_form_section_response', $this->name, ellipsisize($question[
'attributes'][
'name'], 30)).
' ('.$this->
id.
':q'.$shadowid.
')';
1498 $keywords[
'question_name_'.$this->id.
'_q'.$shadowid] = translate(
'cms_form_section_q_name', $this->name, ellipsisize($question[
'attributes'][
'name'], 30)).
' ('.$this->
id.
':q'.$shadowid.
')';
1499 $keywords[
'question_note_'.$this->id.
'_q'.$shadowid] = translate(
'cms_form_section_q_note', $this->name, ellipsisize($question[
'attributes'][
'name'], 30)).
' ('.$this->
id.
':q'.$shadowid.
')';
1502 foreach ($GLOBALS[
'SQ_SYSTEM']->am->getLinks($this->id, SQ_LINK_TYPE_2,
'form_section', FALSE) as $link) {
1504 $sectionid = $link[
'minorid'];
1505 $s = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($sectionid);
1507 $keywords += $s->getResponseKeywords();
1508 $keywords[
'section_title_'.$s->id] =
'Nested Section Name: '.$s->name.
' ('.$s->id.
')';
1510 $GLOBALS[
'SQ_SYSTEM']->am->forgetAsset($s);
1532 if (!is_null($form)) {
1533 assert_is_a($form,
'Form');
1536 $questions = $this->
attr(
'questions');
1537 $keywords = Array();
1539 foreach ($questions as $shadowid => $question) {
1541 $assetid = $this->
id.
':q'.$shadowid;
1542 $q = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($assetid);
1544 $keywords[
'question_field_'.$this->id.
'_q'.$shadowid] =
'<'.
'?php echo $GLOBALS[\'SQ_SYSTEM\']->am->getAsset(\''.$assetid.
'\')->getHtmlField(); ?
'.'>
';
1545 $keywords['question_note_
'.$this->id.'_q
'.$shadowid] = '<
'.'?php echo $GLOBALS[\
'SQ_SYSTEM\']->am->getAsset(\''.$assetid.
'\')->attr(\
'note\'); ?'.
'>';
1546 $keywords[
'question_name_'.$this->id.
'_q'.$shadowid] =
'<'.
'?php echo $GLOBALS[\'SQ_SYSTEM\']->am->getAsset(\''.$assetid.
'\')->attr(\
'name\'); ?'.
'>';
1547 $keywords[
'question_id_'.$this->id.
'_q'.$shadowid] = $assetid;
1548 $keywords[
'question_label_'.$this->id.
'_q'.$shadowid] =
'<'.
'?php echo $GLOBALS[\'SQ_SYSTEM\']->am->getAsset(\''.$assetid.
'\')->getHtmlLabel(); ?
'.'>
';
1550 $keywords['question_field_
'.$this->id.'_q
'.$shadowid] = $q->getHtmlField();
1551 $keywords['question_note_
'.$this->id.'_q
'.$shadowid] = $q->attr('note
');
1552 $keywords['question_name_
'.$this->id.'_q
'.$shadowid] = $q->attr('name
');
1553 $keywords['question_id_
'.$this->id.'_q
'.$shadowid] = $assetid;
1554 $keywords['question_label_
'.$this->id.'_q
'.$shadowid] = $q->getHtmlLabel();
1556 $GLOBALS['SQ_SYSTEM
']->am->forgetAsset($q);
1560 foreach ($GLOBALS['SQ_SYSTEM
']->am->getLinks($this->id, SQ_LINK_TYPE_2, 'form_section
', FALSE) as $link) {
1561 // get the nested form section
1562 $sectionid = $link['minorid
'];
1563 $s = $GLOBALS['SQ_SYSTEM
']->am->getAsset($sectionid);
1564 $keywords += $s->getDisplayKeywordReplacements($generating, FALSE);
1567 $keywords['section_title_
'.$s->id] = '<
'.'?php echo $GLOBALS[\
'SQ_SYSTEM\']->am->getAsset(\''.$sectionid.
'\')->name; ?
'.'>
';;
1569 $keywords['section_contents_
'.$s->id] = '<
'.'?php include_once $GLOBALS[\
'SQ_SYSTEM\']->am->getAsset(\''.$sectionid.
'\')->data_path.\
'/content_file.php\'; ?'.
'>';;
1571 $keywords[
'section_title_'.$s->id] = $s->name;
1573 $s->printBody($form);
1574 $keywords[
'section_contents_'.$s->id] = ob_get_clean();
1577 $GLOBALS[
'SQ_SYSTEM']->am->forgetAsset($s);
1581 if ($include_submit_keywords) {
1586 $submit_button = ob_get_contents();
1591 $reset_button = ob_get_contents();
1594 $keywords[
'submit_button'] = $submit_button;
1595 $keywords[
'reset_button'] = $reset_button;
1598 $keywords[
'form_errors'] = implode(
'\n', $this->submission_errors);
1601 $keywords[
'submit_button'] =
'';
1602 $keywords[
'reset_button'] =
'';
1603 $keywords[
'form_errors'] =
'';