17 require_once SQ_INCLUDE_PATH.
'/asset_edit/asset_edit_fns.inc';
18 require_once SQ_SYSTEM_ROOT.
'/core/attributes/option_list/option_list.inc';
19 require_once SQ_FUDGE_PATH.
'/general/file_system.inc';
43 $this->static_screens[
'details'][
'force_unlock'] = FALSE;
61 if (isset($asset->tmp[
'section_links'])) {
62 unset($asset->tmp[
'section_links']);
64 $sections = $asset->getSections();
66 if (empty($sections)) {
67 echo translate(
'cms_form_no_sections');
70 for (reset($sections); NULL !== ($k = key($sections)); next($sections)) {
72 echo get_asset_tag_line($s->id,
'details').
'<br />';
109 $am = $GLOBALS[
'SQ_SYSTEM']->am;
110 $admin_access = $asset->writeAccess(
'attributes');
111 $prefix = $asset->getPrefix();
112 $questions = $asset->getQuestions();
116 <script type=
"text/javascript">
117 function sortOrderMoveDown(currentOrder) {
118 if (!document.getElementById) {
119 alert(
'<?php echo translate('cms_form_no_getelementbyid
'); ?>');
123 var form = document.getElementById(
'main_form');
125 var currentElement = document.getElementById(
'<?php echo $prefix ?>_order_o' + currentOrder);
126 var nextElement = document.getElementById(
'<?php echo $prefix ?>_order_o' + (currentOrder + 1));
129 if (!nextElement)
return;
131 if (!currentElement.innerHTML) {
132 alert(
'<?php echo translate('cms_form_no_innerhtml
'); ?>');
137 var temp = currentElement.innerHTML;
138 currentElement.innerHTML = nextElement.innerHTML;
139 nextElement.innerHTML = temp;
142 var currentElement = document.getElementById(
'<?php echo $prefix ?>_order_t' + currentOrder);
143 var nextElement = document.getElementById(
'<?php echo $prefix ?>_order_t' + (currentOrder + 1));
145 var temp = currentElement.innerHTML;
146 currentElement.innerHTML = nextElement.innerHTML;
147 nextElement.innerHTML = temp;
152 temp = form.elements[
'<?php echo $prefix ?>_order[delete][' + (currentOrder+1) +
']'].checked;
153 form.elements[
'<?php echo $prefix ?>_order[delete][' + (currentOrder+1) +
']'].checked = form.elements[
'<?php echo $prefix ?>_order[delete][' + currentOrder +
']'].checked;
154 form.elements[
'<?php echo $prefix ?>_order[delete][' + currentOrder +
']'].checked = temp;
157 temp = form.elements[
'<?php echo $prefix ?>_order[reorder][' + (currentOrder+1) +
']'].value;
158 form.elements[
'<?php echo $prefix ?>_order[reorder][' + (currentOrder+1) +
']'].value = form.elements[
'<?php echo $prefix ?>_order[reorder][' + currentOrder +
']'].value;
159 form.elements[
'<?php echo $prefix ?>_order[reorder][' + currentOrder +
']'].value = temp;
163 function sortOrderMoveUp(currentOrder) {
165 if (!document.getElementById) {
166 alert(
'<?php echo translate('cms_form_no_getelementbyid
'); ?>');
170 if (currentOrder == 0)
return;
172 var form = document.getElementById(
'main_form');
174 var currentElement = document.getElementById(
'<?php echo $prefix ?>_order_o' + currentOrder);
175 var prevElement = document.getElementById(
'<?php echo $prefix ?>_order_o' + (currentOrder - 1));
177 if (!currentElement.innerHTML) {
178 alert(
'<?php echo translate('cms_form_no_innerhtml
'); ?>');
183 var temp = currentElement.innerHTML;
184 currentElement.innerHTML = prevElement.innerHTML;
185 prevElement.innerHTML = temp;
188 var currentElement = document.getElementById(
'<?php echo $prefix ?>_order_t' + currentOrder);
189 var prevElement = document.getElementById(
'<?php echo $prefix ?>_order_t' + (currentOrder - 1));
191 var temp = currentElement.innerHTML;
192 currentElement.innerHTML = prevElement.innerHTML;
193 prevElement.innerHTML = temp;
196 temp = form.elements[
'<?php echo $prefix ?>_order[delete][' + (currentOrder-1) +
']'].checked;
197 form.elements[
'<?php echo $prefix ?>_order[delete][' + (currentOrder-1) +
']'].checked = form.elements[
'<?php echo $prefix ?>_order[delete][' + currentOrder +
']'].checked;
198 form.elements[
'<?php echo $prefix ?>_order[delete][' + currentOrder +
']'].checked = temp;
201 temp = form.elements[
'<?php echo $prefix ?>_order[reorder][' + (currentOrder-1) +
']'].value;
202 form.elements[
'<?php echo $prefix ?>_order[reorder][' + (currentOrder-1) +
']'].value = form.elements[
'<?php echo $prefix ?>_order[reorder][' + currentOrder +
']'].value;
203 form.elements[
'<?php echo $prefix ?>_order[reorder][' + currentOrder +
']'].value = temp;
207 function changeAllDelStatuses(status)
209 var inputs = document.getElementsByTagName(
'INPUT');
210 for (var i = 0; i < inputs.length; i++) {
211 if (inputs[i].
id.indexOf(
"_order[delete][") < 0)
continue;
212 inputs[i].checked = status;
217 <table
class=
"sq-backend-table">
219 <td
class=
"sq-backend-table-header">
220 <?php echo translate(
'question'); ?>
222 <td
class=
"sq-backend-table-header">
223 <?php echo translate(
'type'); ?>
228 <td align=
"center" width=
"100" class=
"sq-backend-table-header" style=
"font-weight: bold;"><?php
229 if (!empty($questions)) {
230 $delete_all = check_box($prefix.
'_order[delete]',
'1', FALSE,
'changeAllDelStatuses(this.checked)');
234 echo translate(
'delete_question').$delete_all; ?>
236 <td align=
"center" width=
"100" class=
"sq-backend-table-header" style=
"font-weight: bold;"><?php echo translate(
'move'); ?></td>
242 $sort_order = $asset->attr(
'sort_order');
244 if (!empty($sort_order)) {
248 foreach ($sort_order as $sort_id => $assetid) {
249 $q = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($assetid);
250 if (is_null($q))
continue;
251 $href = $q->getBackendHref(
'details');
254 <td
class=
"sq-backend-table-cell">
255 <span name=
"<?php echo $prefix.'_order_o'.$sort_id ?>" id=
"<?php echo $prefix.'_order_o'.$sort_id ?>"><?php echo get_asset_tag_line($assetid,
'details') ?></span><?php hidden_field($prefix.
'_order[reorder]['.$sort_id.
']', $assetid); ?>
257 <td
class=
"sq-backend-table-cell">
258 <span name=
"<?php echo $prefix.'_order_t'.$sort_id ?>" id=
"<?php echo $prefix.'_order_t'.$sort_id ?>"><?php
259 $q_type = str_replace(
'Form_Question_Type',
'', get_class($q));
260 $q_type = str_replace(
'_',
' ', $q_type);
261 $q_type = trim(ucwords($q_type));
268 <td align=
"center" width=
"100" class=
"sq-backend-table-cell">
270 check_box($prefix.
'_order[delete]['.$sort_id.
']');
273 <td align=
"center" width=
"100" class=
"sq-backend-table-cell">
276 ?><a href=
"#" onclick=
"sortOrderMoveUp(<?php echo $sort_id ?>); return false;"><script type=
"text/javascript">sq_print_icon(
"<?php echo sq_web_path('lib').'/web/images/icons/up_arrow.png' ?>",
"16",
"16",
"Move Up");</script></a><?php
279 if ($i != count($sort_order) -1) {
280 ?><a href=
"#" onclick=
"sortOrderMoveDown(<?php echo $sort_id ?>); return false;"><script type=
"text/javascript">sq_print_icon(
"<?php echo sq_web_path('lib').'/web/images/icons/down_arrow.png' ?>",
"16",
"16",
"Move Down");</script></a><?php
312 $prefix = $asset->getPrefix();
314 if (isset($_POST[$prefix.
'_order'][
'reorder'])) {
315 $asset->setAttrValue(
'sort_order', array_values($_POST[$prefix.
'_order'][
'reorder']));
316 $asset->saveAttributes();
319 if (isset($_POST[$prefix.
'_order'][
'delete'])) {
320 foreach (array_keys($_POST[$prefix.
'_order'][
'delete']) as $sort_order) {
321 $question = $asset->getQuestionByOrder($sort_order);
322 $asset->deleteQuestion($question);
325 $asset->setAttrValue(
'sort_order', array_values($asset->attr(
'sort_order')));
326 $asset->saveAttributes();
355 $write_access = $asset->writeAccess(
'links');
357 if (!$write_access) {
360 foreach ($bodycopies as $bc_code => $bc_name) {
361 if ($asset->attr(
'use_bodycopy_'.$bc_code)) {
362 $bodycopy = $asset->getBodycopy($bc_name);
363 echo get_asset_tag_line($bodycopy->id,
'contents').
'<br />';
368 if ($num_bodycopies == 0) {
369 echo translate(
'cms_form_none_customised').
'<br />';
372 foreach ($bodycopies as $bc_code => $bc_name) {
373 check_box(
'use_bodycopy_'.$bc_code,
'1', $asset->attr(
'use_bodycopy_'.$bc_code));
374 echo label(translate(
'cms_form_bodycopy_'.$bc_code),
'use_bodycopy_'.$bc_code).
'<br />';
378 return $write_access;
402 foreach ($bodycopies as $bc_suffix => $bc_name) {
403 if (isset($_POST[
'use_bodycopy_'.$bc_suffix]) && !$asset->getBodycopy($bc_name)) {
404 $asset->createBodycopy($bc_name);
406 $asset->setAttrValue(
'use_bodycopy_'.$bc_suffix, isset($_POST[
'use_bodycopy_'.$bc_suffix]));
408 $asset->saveAttributes();
430 'main' =>
'Page Contents',
431 'confirmation' =>
'Confirmation Page Contents',
432 'thank_you' =>
'Thank You',
433 'unattached' =>
'Unattached Questions Format',
434 'exit' =>
'Exit Page Contents',
456 if (!$asset->writeAccess(
'attributes'))
return FALSE;
458 $am = $GLOBALS[
'SQ_SYSTEM']->am;
459 $question_types = $am->getTypeDescendants(
'form_question');
460 $questions = Array(
'' =>
'-- Choose Type --');
462 foreach ($question_types as $question) {
463 $q = str_replace(
'form_question_type',
'', $question);
464 $q = str_replace(
'_',
' ', $q);
465 $q = trim(ucwords($q));
466 $questions[$question] = $q;
469 combo_box(
'question_type', $questions, FALSE,
'');
474 for ($i = 1; $i <= 10; $i++) {
477 combo_box(
'num_questions', $num, FALSE,
'');
495 $type = (isset($_POST[
'question_type'])) ? $_POST[
'question_type'] :
'';
496 $number = (isset($_POST[
'num_questions'])) ? $_POST[
'num_questions'] :
'';
501 $am = $GLOBALS[
'SQ_SYSTEM']->am;
502 $curr_question_count = $asset->getQuestionCount() + 1;
504 if ($type && $number) {
506 $am->includeAsset($type);
508 for ($i = 0; $i < $number; $i++) {
509 if (!$asset->attachQuestion($type))
return FALSE;
510 $curr_question_count++;
531 if (!$asset->writeAccess(
'links'))
return FALSE;
534 $option_list->paint($prefix.
'_sections');
554 $new = trim(array_get_index($_REQUEST, $prefix.
'_sections_new_options',
''));
555 if (!empty($new)) $sections[] = $new;
557 $section_text = array_get_index($_POST, $prefix.
'_sections_options',
'');
558 if (!empty($section_text)) {
560 foreach ($section_text as $option) {
561 $option = trim($option);
562 if (empty($option))
continue;
563 $sections[] = $option;
567 if (empty($sections))
return FALSE;
570 $am = $GLOBALS[
'SQ_SYSTEM']->am;
572 $GLOBALS[
'SQ_SYSTEM']->changeDatabaseConnection(
'db2');
573 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'BEGIN');
575 for ($i = 0; $i < count($sections); $i++) {
576 $section_name = $sections[$i];
578 $section_count = $asset->getSectionCount() + 1;
580 $am->includeAsset(
'form_section');
582 $copy_link = Array(
'asset' => &$asset,
'link_type' => SQ_LINK_TYPE_2,
'is_dependant' => 0,
'is_exclusive' => 0);
584 $section[$i]->setAttrValue(
'name', $section_name);
586 if (!$section[$i]->create($copy_link)) {
587 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
588 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
595 if ($section[$i]->status != $asset->status && in_array($asset->status, array_keys($section[$i]->getAvailableStatii()))) {
596 $section[$i]->processStatusChange($asset->status, FALSE, FALSE);
600 if (count($sections) > 0) $asset->_updated();
602 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'COMMIT');
603 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
653 <p><?php echo translate(
'cms_form_simple_formatting_note') ?></p>
693 <p><?php echo translate(
'cms_form_complex_formatting_note') ?><br/>
694 <?php echo translate(
'cms_form_page_contents_popup_link', sq_web_path(
'data').
'/asset_types/form/popups/page_contents_keywords.php?assetid='.$asset->id, 580, 520) ?><br/>
695 <?php echo translate(
'cms_form_thank_you_popup_link', sq_web_path(
'data').
'/asset_types/form/popups/thank_you_keywords.php?assetid='.$asset->id, 580, 520) ?><br/>
733 if ($asset->writeAccess(
'attributes')) {
734 asset_finder($prefix.
'_captcha_ttf', $asset->attr(
'captcha_ttf'), Array(
'file' =>
'D'));
736 $asset_info = $GLOBALS[
'SQ_SYSTEM']->am->getAssetInfo($asset->attr(
'captcha_ttf'));
737 $ttf_file_id = $asset->attr(
'captcha_ttf');
738 if ($ttf_file_id > 0) {
739 echo get_asset_tag_line($ttf_file_id);
741 echo translate(
'none_selected');
761 if (isset($_POST[$prefix.
'_captcha_ttf'])) {
762 $ttf_file_id = $_POST[$prefix.
'_captcha_ttf'][
'assetid'];
764 if ($ttf_file_id != $asset->attr(
'captcha_ttf')) {
765 if ($ttf_file_id > 0) {
767 $ttf_file = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($ttf_file_id);
769 $ttf_file_info = $ttf_file->getExistingFile();
770 $filename = strtolower($ttf_file_info[
'filename']);
772 $extension_index = strpos($filename,
'.ttf');
773 if (($extension_index !== FALSE) && ($extension_index == strlen($filename)-4)) {
774 return $asset->setAttrValue(
'captcha_ttf', $ttf_file_id);
776 trigger_localised_error(
'CMS0109', E_USER_WARNING);
779 return $asset->setAttrValue(
'captcha_ttf', NULL);
805 $output =
'<'.
'?php'.
"\n";
806 $output .=
'$form_asset = $GLOBALS["SQ_SYSTEM"]->am->getAsset('.$asset->id.
');'.
"\n";
807 $output .=
'include_once('.str_replace(SQ_DATA_PATH,
'SQ_DATA_PATH."', $asset->data_path).
'/content_file_questions.php'.
'");'.
"\n";
808 $sections = $asset->getSections();
809 foreach ($sections as $section) {
811 $output .=
'include_once('.str_replace(SQ_DATA_PATH,
'SQ_DATA_PATH."', $section->data_path).
'/content_file.php'.
'");'.
"\n";
817 $output = preg_replace(
'/%[^<>%]+%/',
'', $output);
819 create_directory($asset->data_path);
820 return string_to_file($output, $asset->data_path.
'/content_file.php');
836 $output =
'<'.
'?php $form_asset=$GLOBALS["SQ_SYSTEM"]->am->getAsset('.$asset->id.
'); ?'.
'>'.
"\n";
841 $output = preg_replace(
'/%[^<>%]+%/',
'', $output);
843 create_directory($asset->data_path);
844 return string_to_file($output, $asset->data_path.
'/content_file_questions.php');
860 if ((
int)$asset->attr(
'form_width')) {
861 $output .=
' width="'.$asset->attr(
'form_width').
'"';
864 $sort_order = $asset->attr(
'sort_order');
865 if (empty($sort_order))
return;
867 foreach ($sort_order as $i => $assetid) {
868 $q = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($assetid);
869 if (is_null($q))
continue;
872 $output .=
'<td valign="top"';
873 $output .= ($asset->attr(
'question_col_width')) ?
' width="'.$asset->attr(
'question_col_width').
'">' :
'>';
874 $label = $q->getHtmlLabel();
877 if ($q->getVal(
'note')) {
878 $output .=
'<br /><span style="font-size:'.($asset->attr(
'note_size') ? $asset->attr(
'note_size') :
'80%').
'">'.$q->getVal(
'note').
'</span>';
880 $output .=
'</td><td';
881 $output .= ($asset->attr(
'answer_col_width')) ?
' width="'.$asset->attr(
'answer_col_width').
'">' :
'>';
882 $output .=
'<'.
'?php $q = $GLOBALS["SQ_SYSTEM"]->am->getAsset("'.$assetid.
'");
883 echo $q->getHtmlField(); ?'.
'>'.
"\n";
884 $output .=
'</td></tr>';
886 $output .=
'</table>';
908 $write_access = $asset->writeAccess(
'attributes');
909 $current = $asset->attr(
'mollom_questions_to_check');
911 $relevent_question_types = Array(
'form_question_type_text',
'form_question_type_email_address');
912 $form_questions = $asset->getAllQuestions();
914 $questions = Array();
915 foreach ($form_questions as $q_id => $q_info) {
917 $q_type = isset($q_info[
'question_type_code']) ? $q_info[
'question_type_code'] :
'';
918 if (!in_array($q_type, $relevent_question_types)) {
922 $q_name = isset($q_info[
'attributes'][
'name']) ? $q_info[
'attributes'][
'name'] : $q_id.
' (No name)';
923 $questions[$q_id] = $q_id.
' '.ucwords(str_replace(
'_',
' ', $q_name));
926 if (empty($current)) {
927 echo translate(
'cms_form_mollom_no_question_to_check');
930 <table
class=
"sq-backend-table">
932 <td
class=
"sq-backend-table-header"><?php echo translate(
'name') ?></td>
933 <td
class=
"sq-backend-table-header">Content Type</td>
936 ?><td
class=
"sq-backend-table-header"><?php echo translate(
'delete_question') ?></td><?php
941 foreach ($current as $q_id => $content_type) {
942 $question_name = isset($questions[$q_id]) ? $questions[$q_id] :
'';
943 if (!$question_name) {
948 <td
class=
"sq-backend-table-cell"><?php echo $question_name; ?></td>
949 <td
class=
"sq-backend-table-cell">
951 $content_types = Array();
952 if (file_exists(SQ_FUDGE_PATH.
'/mollom/mollom.inc')) {
953 require_once SQ_FUDGE_PATH.
'/mollom/mollom.inc';
955 $content_types = $mollom->getContentTypes();
959 combo_box($prefix.
'_content_type['.$q_id.
']', $content_types, FALSE, $content_type);
961 echo isset($content_types[$content_type]) ? $content_types[$content_type] :
'';
968 <td
class=
"sq-backend-table-cell">
969 <?php check_box($prefix.
'_delete_content_type['.$q_id.
']'); ?>
983 $new_questions = Array(
'' =>
'-- '.translate(
'select_question').
' --');
984 foreach ($questions as $q_id => $q_name) {
985 if (isset($current[$q_id]))
continue;
986 $new_questions[$q_id] = $q_name;
989 echo
'<br/><b>'.translate(
'cms_form_new_mollom_question').
' </b>';
990 combo_box($prefix.
'_new_content_type', $new_questions, FALSE,
'');
993 return $write_access;
1010 $current = $asset->attr(
'mollom_questions_to_check');
1011 $content_types = Array();
1015 foreach ($current as $q_id => $q_name) {
1016 if (!isset($_POST[$prefix.
'_delete_content_type'][$q_id]) || !$_POST[$prefix.
'_delete_content_type'][$q_id]) {
1017 if (isset($_POST[$prefix.
'_content_type'][$q_id])) {
1018 $content_types[$q_id] = trim($_POST[$prefix.
'_content_type'][$q_id]);
1020 $content_types[$q_id] = $current[$q_id];
1026 if (isset($_POST[$prefix.
'_new_content_type']) && !empty($_POST[$prefix.
'_new_content_type'])) {
1027 $new_question = $_POST[$prefix.
'_new_content_type'];
1028 if (!isset($content_types[$new_question])) {
1029 $content_types[$new_question] =
'';
1033 return $asset->setAttrValue(
'mollom_questions_to_check', $content_types);
1050 $submission_limit = $asset->attr(
'submission_limit');
1051 $write_access = $asset->writeAccess(
'attributes');
1052 $sub_logging = $asset->attr(
'log_submissions');
1055 if ($write_access) {
1056 text_box($prefix.
'_submission_limit', $submission_limit, 5);
1058 echo $submission_limit;
1061 echo
"<b>This feature can be used only if the Submission logging is turned on.</b>";
1081 $submission_limit = $asset->attr(
'submission_limit');
1082 $write_access = $asset->writeAccess(
'attributes');
1084 $new_value = array_get_index($_REQUEST, $prefix.
'_submission_limit', $submission_limit);
1086 if ($write_access && ($submission_limit != $new_value) && $asset->attr(
'log_submissions')) {
1087 $asset->setAttrValue(
'submission_limit', $new_value);
1088 $asset->saveAttributes();
1093 if ($submission_limit == 0 || $new_value == 0) {
1094 $bc_name =
'Submission Limit Reached';
1095 if ($submission_limit == 0) {
1097 $bodycopy = $asset->getBodycopy($bc_name, SQ_LINK_TYPE_2);
1098 if (is_null($bodycopy)) $bodycopy = $asset->getBodycopy($bc_name, SQ_LINK_NOTICE);
1099 if (is_null($bodycopy)) {
1100 $asset->createBodycopy($bc_name, Array(
'content' =>
'Number of submissions allowed for this form has reached. No more submissions are allowed.'));
1104 $bodycopy_link = $GLOBALS[
'SQ_SYSTEM']->am->getLink($bodycopy->id, SQ_LINK_NOTICE,
'folder', TRUE, NULL,
'minor');
1105 $GLOBALS[
'SQ_SYSTEM']->am->moveLink($bodycopy_link[
'linkid'], $bodycopy_link[
'majorid'], SQ_LINK_TYPE_2, $bodycopy_link[
'sort_order'], $bodycopy_link[
'value']);
1107 }
else if ($new_value == 0) {
1110 $bodycopy = $asset->getBodycopy($bc_name, SQ_LINK_TYPE_2);
1111 if (!is_null($bodycopy)) {
1112 $bodycopy_link = $GLOBALS[
'SQ_SYSTEM']->am->getLink($bodycopy->id, SQ_LINK_TYPE_2,
'folder', TRUE, NULL,
'minor');
1113 $GLOBALS[
'SQ_SYSTEM']->am->moveLink($bodycopy_link[
'linkid'], $bodycopy_link[
'majorid'], SQ_LINK_NOTICE, $bodycopy_link[
'sort_order'], $bodycopy_link[
'value']);