18 require_once SQ_INCLUDE_PATH.
'/asset_edit/asset_edit_fns.inc';
45 $this->static_screens[
'details'][
'force_unlock'] = FALSE;
65 $write_access = $asset->writeAccess(
'attributes');
67 $parents = $GLOBALS[
'SQ_SYSTEM']->am->getParents($asset->id.
':q1',
'', TRUE);
71 <script type=
"text/javascript" src=
"<?php echo sq_web_path('data') ?>/asset_types/simple_form/js/sort_order_manip.js"></script>
72 <div style=
"display:none"><?php sq_print_icon(sq_web_path(
'lib').
'/web/images/icons/internal_message/priority_2.png', 16, 16,
'',
'',
'id="'.$prefix.
'_moved_up" align="absmiddle"') ?>
73 <?php sq_print_icon(sq_web_path(
'lib').
'/web/images/icons/internal_message/priority_4.png', 16, 16,
'',
'',
'id="'.$prefix.
'_moved_down" align="absmiddle"') ?></div>
74 <table
class=
"sq-backend-table">
78 <?php echo translate(
'question'); ?>
81 <?php echo translate(
'type'); ?>
83 <?php
if ($write_access) {
84 ?><th style=
"width:30px; text-align:center">
85 <?php echo translate(
'up'); ?>
87 <th colspan=
"2" style=
"text-align:center">
88 <?php echo translate(
'position'); ?>
90 <th style=
"width:30px; text-align:center">
91 <?php echo translate(
'down'); ?>
93 <th style=
"width:50px; text-align:center">
94 <?php echo translate(
'delete'); ?>
100 <?php
if (count($asset->attr(
'questions')) <= 0) {
101 ?><tr><td colspan=
"<?php echo $write_access ? 8 : 3 ?>" style=
"font-style:italic; text-align:center"><?php echo translate(
'core_simple_form_no_questions'); ?></td></tr><?php
103 foreach ($asset->attr(
'questions') as $shadowid => $asset_data) {
104 $assetid = $asset->id.
':q'.$shadowid;
105 $q = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($assetid);
106 $href = $q->getBackendHref(
'details');
107 $GLOBALS[
'SQ_SYSTEM']->am->forgetAsset($q);
109 <tr
id=
"<?php echo $prefix.'_order_row'.$asset_data['sort_order'] ?>">
111 <span name=
"<?php echo $prefix.'_order_o'.$asset_data['sort_order'] ?>" id=
"<?php echo $prefix.'_order_o'.$asset_data['sort_order'] ?>"><?php echo get_asset_tag_line($assetid,
'details') ?><!-- <b><a href=
"<?php echo $href ?>"><?php
114 <span name=
"<?php echo $prefix.'_order_t'.$asset_data['sort_order'] ?>" id=
"<?php echo $prefix.'_order_t'.$asset_data['sort_order'] ?>"><?php
115 $q_type = str_replace(
'form_question_type',
'', $asset_data[
'type_code']);
116 $q_type = str_replace(
'_',
' ', $q_type);
117 $q_type = trim(ucwords($q_type));
121 <?php
if ($write_access) {
122 ?><td style=
"width:30px; text-align:center">
124 if ($asset_data[
'sort_order'] != 0) {
125 ?><a href=
"#" onclick=
"moveQuestion(document.main_form, '<?php echo $prefix ?>', <?php echo $asset_data['sort_order'] ?>, <?php echo $asset_data['sort_order'] - 1 ?>); return false;"><script language=
"JavaScript" 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
129 <td style=
"width:30px; text-align:right">
130 <span
id=
"<?php echo $prefix.'_order_so'.$asset_data['sort_order'] ?>"><?php echo $asset_data[
'sort_order'] + 1; ?></span>
132 <td style=
"width:30px; text-align:left">
133 <span
id=
"<?php echo $prefix.'_order_soa'.$asset_data['sort_order'] ?>"></span><span style=
"visibility:hidden; font-weight: bold" name=
"<?php echo $prefix.'_order_soc'.$asset_data['sort_order'] ?>" id=
"<?php echo $prefix.'_order_soc'.$asset_data['sort_order'] ?>"><?php echo $asset_data[
'sort_order'] + 1; ?></span>
135 <td style=
"width:30px; text-align:center">
137 if ($asset_data[
'sort_order'] != count($asset->attr(
'questions')) -1) {
138 ?><a href=
"#" onclick=
"moveQuestion(document.main_form, '<?php echo $prefix ?>', <?php echo $asset_data['sort_order'] ?>, <?php echo $asset_data['sort_order'] + 1 ?>); return false;"><script language=
"JavaScript" 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
142 <td style=
"width:50px; text-align:center">
143 <?php check_box($prefix.
'_order[delete]['.$asset_data[
'sort_order'].
']'); ?>
153 return $write_access;
170 if (!$asset->writeAccess(
'attributes'))
return FALSE;
171 if (!isset($_POST[$prefix.
'_order'][
'reorder'])) {
175 $old_questions = $asset->attr(
'questions');
176 $questions = Array();
180 foreach ($_POST[$prefix.
'_order'][
'reorder'] as $order_shadowid) {
181 if (empty($_POST[$prefix.
'_order'][
'delete'][$old_sort_order])) {
182 $questions[$order_shadowid] =& $old_questions[$order_shadowid];
183 $questions[$order_shadowid][
'sort_order'] = $new_sort_order;
189 $asset->setAttrValue(
'questions', $questions);
207 if (!$asset->writeAccess(
'attributes')) {
208 ?><i><?php echo translate(
'core_simple_form_lock_to_add_questions'); ?></i><?php
212 $am =& $GLOBALS[
'SQ_SYSTEM']->am;
213 $question_types = $am->getTypeDescendants(
'form_question');
214 $questions = Array(
'' =>
'-- '.translate(
'choose_type').
' --');
216 foreach ($question_types as $question) {
217 $q = str_replace(
'form_question_type',
'', $question);
218 $q = str_replace(
'_',
' ', $q);
219 $q = trim(ucwords($q));
220 $questions[$question] = $q;
223 $prefix = str_replace(
':',
'_',$prefix);
225 <div
id=
"question-list-<?php echo $prefix; ?>">
227 for ($i =0; $i < 2; $i++) {
229 <div><input type=
"text" name=
"<?php echo $prefix; ?>_add[names][]" /><?php echo combo_box($prefix.
'_add[types][]', $questions, FALSE,
''); ?><button type=
"button" tabindex=
"99999" class=
"delete-button"> </button></div>
234 <script type=
"text/javascript">
236 var optionList = document.getElementById(
'question-list-<?php echo $prefix; ?>');
237 var divs = optionList.getElementsByTagName(
'DIV');
238 for (var i=0; i < divs.length; i++) {
239 var thisDiv = divs[i];
241 var inputs = thisDiv.getElementsByTagName(
'INPUT');
242 for (var j=0; j < inputs.length; j++) {
243 inputs[j].onfocus = expandListFormFn;
245 var selects = thisDiv.getElementsByTagName(
'SELECT');
246 for (var j=0; j < selects.length; j++) {
247 selects[j].onfocus = expandListFormFn;
249 var buttons = thisDiv.getElementsByTagName(
'BUTTON');
250 for (var j=0; j < buttons.length; j++) {
251 buttons[j].onclick = deleteRowFormFn;
273 if (!$asset->writeAccess(
'attributes'))
return FALSE;
275 $names = $_POST[$prefix.
'_add'][
'names'];
276 $types = $_POST[$prefix.
'_add'][
'types'];
279 $am =& $GLOBALS[
'SQ_SYSTEM']->am;
281 foreach ($types as $i => $type) {
282 if (empty($type))
continue;
284 $am->includeAsset($type);
285 $GLOBALS[
'SQ_SYSTEM']->changeDatabaseConnection(
'db2');
286 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'BEGIN');
289 if (!$asset->createQuestion($type, $names[$i])) {
290 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
291 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
295 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'COMMIT');
296 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
317 $write_access = $asset->writeAccess(
'links');
318 $bodycopy_link = $GLOBALS[
'SQ_SYSTEM']->am->getLink($asset->id, SQ_LINK_TYPE_2,
'bodycopy',
'format');
319 $enabled = !empty($bodycopy_link);
323 '1' => translate(
'yes'),
324 '0' => translate(
'no'),
327 combo_box($prefix.
'_use_bodycopy', $options, FALSE, Array($enabled));
330 echo $enabled ? translate(
'on') : translate(
'off');
333 return $write_access;
350 if (!$asset->writeAccess(
'links'))
return FALSE;
351 $enabled = $_POST[$prefix.
'_use_bodycopy'];
353 $GLOBALS[
'SQ_SYSTEM']->changeDatabaseConnection(
'db2');
354 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'BEGIN');
356 if (!$asset->setUseFormatBodycopy($enabled)) {
357 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
358 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
362 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'COMMIT');
363 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();