Skip to content

Commit

Permalink
Getting form prefixes on elements in Page settings, and general other…
Browse files Browse the repository at this point in the history
… improvements
  • Loading branch information
jegelstaff committed Sep 22, 2024
1 parent aab2add commit 42ac17e
Showing 6 changed files with 141 additions and 136 deletions.
4 changes: 2 additions & 2 deletions modules/formulize/admin/generateTemplateElementHandleHelp.php
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@
$allFids = $allFidsToUse;
} elseif ($selectedFramework and isset($frameworks[$selectedFramework])) {
$linkedForms = checkForLinks($selectedFramework, array($form_id), $form_id);
$allFids = $linkedForms['fids'] + $linkedForms['sub_fids'];
$allFids = array_merge($linkedForms['fids'], $linkedForms['sub_fids']);
} else {
$allFids = array(0=>$form_id);
}
@@ -27,7 +27,7 @@
$thisFidHandles = $thisFidObj->getVar('elementHandles');
foreach($thisFidElements as $zz => $thisFidElement) {
$elementHeading = $thisFidColheads[$zz] ? $thisFidColheads[$zz] : $thisFidCaptions[$zz];
$elementOptions[$thisFidHandles[$zz]] = printSmart(trans(strip_tags($thisFidObj->title.': '.$elementHeading)), 125);
$elementOptions[$thisFidHandles[$zz]] = (isset($allFidsToUse) OR $selectedFramework) ? printSmart(trans(strip_tags($thisFidObj->title.': '.$elementHeading)), 125) : printSmart(trans(strip_tags($elementHeading)), 40);
// for passing to custom button logic, so we know all the element options for each form in framework
$elementOptionsFid[$thisFid][$thisFidElement] = printSmart(trans(strip_tags($elementHeading)), 75);
$class = $class == "even" ? "odd" : "even";
40 changes: 22 additions & 18 deletions modules/formulize/admin/screen.php
Original file line number Diff line number Diff line change
@@ -319,21 +319,21 @@

// setup all the elements in this form for use in the listboxes
include_once XOOPS_ROOT_PATH . "/modules/formulize/class/forms.php";
$options = multiPageScreen_addToOptionsList($form_id, array());
$frid = $screen->getVar("frid");
$options = multiPageScreen_addToOptionsList($form_id, array(), $frid);

// add in elements from other forms in the framework, by looping through each link in the framework and checking if it is a display as one, one-to-one link
// added March 20 2008, by jwe
$frid = $screen->getVar("frid");
if ($frid) {
$framework_handler =& xoops_getModuleHandler('frameworks');
$frameworkObject = $framework_handler->get($frid);
foreach($frameworkObject->getVar("links") as $thisLinkObject) {
if ($thisLinkObject->getVar("unifiedDisplay") AND ( $thisLinkObject->getVar("relationship") == 1 OR
($thisLinkObject->getVar("relationship") == 2 AND $thisLinkObject->getVar("form1") != $form_id)
OR ($thisLinkObject->getVar("relationship") == 3 AND $thisLinkObject->getVar("form2") != $form_id)
)) {
if ($thisLinkObject->getVar("unifiedDisplay") AND (( $thisLinkObject->getVar("relationship") == 1 AND ($thisLinkObject->getVar("form1") == $form_id OR $thisLinkObject->getVar("form2") == $form_id))
OR ($thisLinkObject->getVar("relationship") == 2 AND $thisLinkObject->getVar("form1") != $form_id AND $thisLinkObject->getVar("form2") == $form_id)
OR ($thisLinkObject->getVar("relationship") == 3 AND $thisLinkObject->getVar("form2") != $form_id AND $thisLinkObject->getVar("form1") == $form_id)
)) {
$thisFid = $thisLinkObject->getVar("form1") == $form_id ? $thisLinkObject->getVar("form2") : $thisLinkObject->getVar("form1");
$options = multiPageScreen_addToOptionsList($thisFid, $options);
$options = multiPageScreen_addToOptionsList($thisFid, $options, $frid);
}
}
}
@@ -402,16 +402,18 @@
// pages data
$multipagePages = array();
$multipagePages['pages'] = $pages;

$element_list = multiPageScreen_addToOptionsList($form_id, array());
$frid = $screen->getVar("frid");
$frid = $screen->getVar("frid");
$element_list = multiPageScreen_addToOptionsList($form_id, array(), $frid);
if ($frid) {
$framework_handler =& xoops_getModuleHandler('frameworks');
$frameworkObject = $framework_handler->get($frid);
foreach($frameworkObject->getVar("links") as $thisLinkObject) {
if ($thisLinkObject->getVar("unifiedDisplay") AND $thisLinkObject->getVar("relationship") == 1) {
$thisFid = $thisLinkObject->getVar("form1") == $form_id ? $thisLinkObject->getVar("form2") : $thisLinkObject->getVar("form1");
$element_list = multiPageScreen_addToOptionsList($thisFid, $element_list);
if ($thisLinkObject->getVar("unifiedDisplay") AND (( $thisLinkObject->getVar("relationship") == 1 AND ($thisLinkObject->getVar("form1") == $form_id OR $thisLinkObject->getVar("form2") == $form_id))
OR ($thisLinkObject->getVar("relationship") == 2 AND $thisLinkObject->getVar("form1") != $form_id AND $thisLinkObject->getVar("form2") == $form_id)
OR ($thisLinkObject->getVar("relationship") == 3 AND $thisLinkObject->getVar("form2") != $form_id AND $thisLinkObject->getVar("form1") == $form_id)
)) {
$thisFid = $thisLinkObject->getVar("form1") == $form_id ? $thisLinkObject->getVar("form2") : $thisLinkObject->getVar("form1");
$element_list = multiPageScreen_addToOptionsList($thisFid, $element_list, $frid);
}
}
}
@@ -422,16 +424,18 @@
}

if ($screen_id != "new" && $settings['type'] == 'form') {

$element_list = multiPageScreen_addToOptionsList($form_id, array());
$frid = $screen->getVar("frid");
$frid = $screen->getVar("frid");
$element_list = multiPageScreen_addToOptionsList($form_id, array(), $frid);
if ($frid) {
$framework_handler =& xoops_getModuleHandler('frameworks');
$frameworkObject = $framework_handler->get($frid);
foreach($frameworkObject->getVar("links") as $thisLinkObject) {
if ($thisLinkObject->getVar("unifiedDisplay") AND $thisLinkObject->getVar("relationship") == 1) {
if ($thisLinkObject->getVar("unifiedDisplay") AND (( $thisLinkObject->getVar("relationship") == 1 AND ($thisLinkObject->getVar("form1") == $form_id OR $thisLinkObject->getVar("form2") == $form_id))
OR ($thisLinkObject->getVar("relationship") == 2 AND $thisLinkObject->getVar("form1") != $form_id AND $thisLinkObject->getVar("form2") == $form_id)
OR ($thisLinkObject->getVar("relationship") == 3 AND $thisLinkObject->getVar("form2") != $form_id AND $thisLinkObject->getVar("form1") == $form_id)
)) {
$thisFid = $thisLinkObject->getVar("form1") == $form_id ? $thisLinkObject->getVar("form2") : $thisLinkObject->getVar("form1");
$element_list = multiPageScreen_addToOptionsList($thisFid, $element_list);
$element_list = multiPageScreen_addToOptionsList($thisFid, $element_list, $frid);
}
}
}
14 changes: 7 additions & 7 deletions modules/formulize/admin/screen_multipage_pages_settings.php
Original file line number Diff line number Diff line change
@@ -59,22 +59,22 @@

// setup all the elements in this form for use in the listboxes
include_once XOOPS_ROOT_PATH . "/modules/formulize/class/forms.php";
$frid = $screen->getVar("frid");
$fid = $screen->getVar('fid');
$options = multiPageScreen_addToOptionsList($fid, array());
$options = multiPageScreen_addToOptionsList($fid, array(), $frid);

// add in elements from other forms in the framework, by looping through each link in the framework and checking if it is a display as one, one-to-one link
// added March 20 2008, by jwe
$frid = $screen->getVar("frid");
if ($frid) {
$framework_handler =& xoops_getModuleHandler('frameworks', 'formulize');
$frameworkObject = $framework_handler->get($frid);
foreach($frameworkObject->getVar("links") as $thisLinkObject) {
if ($thisLinkObject->getVar("unifiedDisplay") AND ( $thisLinkObject->getVar("relationship") == 1 OR
($thisLinkObject->getVar("relationship") == 2 AND $thisLinkObject->getVar("form1") != $form_id)
OR ($thisLinkObject->getVar("relationship") == 3 AND $thisLinkObject->getVar("form2") != $form_id)
)) {
if ($thisLinkObject->getVar("unifiedDisplay") AND (( $thisLinkObject->getVar("relationship") == 1 AND ($thisLinkObject->getVar("form1") == $fid OR $thisLinkObject->getVar("form2") == $fid))
OR ($thisLinkObject->getVar("relationship") == 2 AND $thisLinkObject->getVar("form1") != $fid AND $thisLinkObject->getVar("form2") == $fid)
OR ($thisLinkObject->getVar("relationship") == 3 AND $thisLinkObject->getVar("form2") != $fid AND $thisLinkObject->getVar("form1") == $fid)
)) {
$thisFid = $thisLinkObject->getVar("form1") == $fid ? $thisLinkObject->getVar("form2") : $thisLinkObject->getVar("form1");
$options = multiPageScreen_addToOptionsList($thisFid, $options);
$options = multiPageScreen_addToOptionsList($thisFid, $options, $frid);
}
}
}
5 changes: 3 additions & 2 deletions modules/formulize/class/multiPageScreen.php
Original file line number Diff line number Diff line change
@@ -331,13 +331,14 @@ public function setDefaultFormScreenVars($defaultFormScreen, $formTitle, $fid, $

}

function multiPageScreen_addToOptionsList($fid, $options) {
function multiPageScreen_addToOptionsList($fid, $options, $frid) {
$formObject = new formulizeForm($fid);
$elements = $formObject->getVar('elements');
$elementCaptions = $formObject->getVar('elementCaptions');
$elementColheads = $formObject->getVar('elementColheads');
foreach($elementCaptions as $key=>$elementCaption) {
$options[$elements[$key]] = trans(strip_tags($elementColheads[$key])) ? printSmart(trans(strip_tags($elementColheads[$key]))) : printSmart(trans(strip_tags($elementCaption))); // need to pull out potential HTML tags from the caption/colhead
$elementLabel = $elementColheads[$key] ? $elementColheads[$key] : $elementCaption;
$options[$elements[$key]] = $frid ? printSmart(trans(strip_tags($formObject->title.': '.$elementLabel)), 125) : printSmart(trans(strip_tags($elementLabel)), 40); // need to pull out potential HTML tags from the caption/colhead
}
return $options;
}
8 changes: 4 additions & 4 deletions modules/formulize/include/functions.php
Original file line number Diff line number Diff line change
@@ -5073,9 +5073,9 @@ function formulize_createFilterUI($filterSettings, $filterName, $formWithSourceE
foreach ($vs as $row=>$values) {
$thisFidObj = $form_handler->get($fid);
if ($values['ele_colhead'] != "") {
$options[$values['ele_handle']] = printSmart(trans(strip_tags($thisFidObj->title.': '.$values['ele_colhead'])), 125);
$options[$values['ele_handle']] = $frid ? printSmart(trans(strip_tags($thisFidObj->title.': '.$values['ele_colhead'])), 125) : printSmart(trans(strip_tags($values['ele_colhead'])), 40);
} else {
$options[$values['ele_handle']] = printSmart(trans(strip_tags($thisFidObj->title.': '.$values['ele_caption'])), 125);
$options[$values['ele_handle']] = $frid ? printSmart(trans(strip_tags($thisFidObj->title.': '.$values['ele_caption'])), 125) : printSmart(trans(strip_tags($values['ele_caption'])), 40);
}
}
}
@@ -5221,9 +5221,9 @@ function getExistingFilter($filterSettings, $filterName, $formWithSourceElements
foreach ($vs as $row=>$values) {
$thisFidObj = $form_handler->get($fid);
if ($values['ele_colhead'] != "") {
$options[$values['ele_handle']] = printSmart(trans(strip_tags($thisFidObj->title.': '.$values['ele_colhead'])), 125);
$options[$values['ele_handle']] = $frid ? printSmart(trans(strip_tags($thisFidObj->title.': '.$values['ele_colhead'])), 125) : printSmart(trans(strip_tags($values['ele_colhead'])), 40);
} else {
$options[$values['ele_handle']] = printSmart(trans(strip_tags($thisFidObj->title.': '.$values['ele_caption'])), 125);
$options[$values['ele_handle']] = $frid ? printSmart(trans(strip_tags($thisFidObj->title.': '.$values['ele_caption'])), 125) : printSmart(trans(strip_tags($values['ele_caption'])), 40);
}
}
}
206 changes: 103 additions & 103 deletions modules/formulize/templates/admin/screen_multipage_pages_settings.html
Original file line number Diff line number Diff line change
@@ -1,103 +1,103 @@
<div>
<form name="popupform">
<input type="hidden" name="formulize_admin_handler" value="screen_multipage_pages">
<input type="hidden" name="formulize_admin_key" value="<{$sid}>">
<input type="hidden" name="reloadpopup" value="">
<input type="hidden" name="conditionsdelete" value="">
<input type="hidden" name="piforjquery" value=<{$pageIndex}>>
<div id=popupsavebutton><input type="button" class="savebuttonpopup" id="savebuttonpopup" value="Save your changes"/></div>
<div id="popupsavewarning">You have unsaved changes!</div>
<div style="clear: both"></div>
<div class="accordion-box">
<div class="form-item required">
<label for="screens-pagetitle_<{$pageIndex}>">Title for page number <{$pageNumber}></label>
<input type="text" class="required_formulize_element" id="screens-pagetitle_<{$pageIndex}>" name="screens-pagetitle_<{$pageIndex}>" value="<{$pageTitle}>" size="30" maxlength="255"/>
<div class="description"></div>
</div>
<div class="form-item">
<label for="screens-page<{$pageIndex}>">Form elements to display on page <{$pageNumber}></label>
<select id="screens-page<{$pageIndex}>" name="screens-page<{$pageIndex}>[]" size="10" multiple>
<{html_options options=$options selected=$pageElements}>
</select>
<div class="description"></div>
</div>
</div>
<div class="accordion-box">
<p>What conditions are there on the display of this page?</p>
<{$pageConditions}>
<div class="description"><p>If you don't specify any conditions, the page will always be included in the form.</p></div>
</div>


</form>
</div>

<script type="text/javascript">
// If saveLock is turned on, do not display save button to user, instead display "READ ONLY"
$( document ).ready(function() {
<{if $content.isSaveLocked}>
document.getElementById('savebuttonpopup').style.visibility = 'hidden';
document.getElementById('popupsavebutton').innerHTML = "READ ONLY";
<{/if}>
});
$("input").change(function() {
window.document.getElementById('popupsavewarning').style.display = 'block';
});
$("input[type=text]").keydown(function() {
window.document.getElementById('popupsavewarning').style.display = 'block';
});
$("select").change(function() {
window.document.getElementById('popupsavewarning').style.display = 'block';
});
$("textarea").keydown(function() {
window.document.getElementById('popupsavewarning').style.display = 'block';
});


$(".savebuttonpopup").click(function() {
$(".required_formulize_element").each(function() {
if($(this).val() == "") {
alert("Pages must have titles!");
$(this).focus();
}
});
});

$("[name=addcon]").click(function () {
$(".savebuttonpopup").click();
return false;
});

$(".conditionsdelete").click(function () {
$("[name=conditionsdelete]").val($(this).attr('target'));
$(".savebuttonpopup").click();
return false;
});

$(".savebuttonpopup").click(function() {
if(validateRequired()) {
var pagedata = window.document.getElementsByName("popupform");
$.post("save.php?popupsave=1", $(pagedata).serialize(), function(data) {
if(data) {
if(data.substr(0,10)=="/* eval */") {
eval(data);
} else {
alert(data);
}
}
window.document.getElementById('popupsavewarning').style.display = 'none';
});
}
$(".savebuttonpopup").blur();
});
function reloadPopup() {
$("#dialog-page-settings-content").load('<{$smarty.const.XOOPS_URL}>/modules/formulize/admin/screen_multipage_pages_settings.php?page=<{$pageIndex}>&sid=<{$sid}>');
}

</script>
<div>
<form name="popupform">
<input type="hidden" name="formulize_admin_handler" value="screen_multipage_pages">
<input type="hidden" name="formulize_admin_key" value="<{$sid}>">
<input type="hidden" name="reloadpopup" value="">
<input type="hidden" name="conditionsdelete" value="">
<input type="hidden" name="piforjquery" value=<{$pageIndex}>>
<div id=popupsavebutton><input type="button" class="savebuttonpopup" id="savebuttonpopup" value="Save your changes"/></div>
<div id="popupsavewarning">You have unsaved changes!</div>
<div style="clear: both"></div>
<div class="accordion-box">
<div class="form-item required">
<label for="screens-pagetitle_<{$pageIndex}>">Title for page number <{$pageNumber}></label>
<input type="text" class="required_formulize_element" id="screens-pagetitle_<{$pageIndex}>" name="screens-pagetitle_<{$pageIndex}>" value="<{$pageTitle}>" size="30" maxlength="255"/>
<div class="description"></div>
</div>
<div class="form-item">
<label for="screens-page<{$pageIndex}>">Form elements to display on page <{$pageNumber}></label><br>
<select id="screens-page<{$pageIndex}>" name="screens-page<{$pageIndex}>[]" size="10" multiple>
<{html_options options=$options selected=$pageElements}>
</select>
<div class="description"></div>
</div>
</div>

<div class="accordion-box">
<p>What conditions are there on the display of this page?</p>
<{$pageConditions}>
<div class="description"><p>If you don't specify any conditions, the page will always be included in the form.</p></div>
</div>


</form>
</div>

<script type="text/javascript">

// If saveLock is turned on, do not display save button to user, instead display "READ ONLY"
$( document ).ready(function() {
<{if $content.isSaveLocked}>
document.getElementById('savebuttonpopup').style.visibility = 'hidden';
document.getElementById('popupsavebutton').innerHTML = "READ ONLY";
<{/if}>

});

$("input").change(function() {
window.document.getElementById('popupsavewarning').style.display = 'block';
});
$("input[type=text]").keydown(function() {
window.document.getElementById('popupsavewarning').style.display = 'block';
});
$("select").change(function() {
window.document.getElementById('popupsavewarning').style.display = 'block';
});
$("textarea").keydown(function() {
window.document.getElementById('popupsavewarning').style.display = 'block';
});


$(".savebuttonpopup").click(function() {
$(".required_formulize_element").each(function() {
if($(this).val() == "") {
alert("Pages must have titles!");
$(this).focus();
}
});
});

$("[name=addcon]").click(function () {
$(".savebuttonpopup").click();
return false;
});

$(".conditionsdelete").click(function () {
$("[name=conditionsdelete]").val($(this).attr('target'));
$(".savebuttonpopup").click();
return false;
});

$(".savebuttonpopup").click(function() {
if(validateRequired()) {
var pagedata = window.document.getElementsByName("popupform");
$.post("save.php?popupsave=1", $(pagedata).serialize(), function(data) {
if(data) {
if(data.substr(0,10)=="/* eval */") {
eval(data);
} else {
alert(data);
}
}
window.document.getElementById('popupsavewarning').style.display = 'none';

});
}
$(".savebuttonpopup").blur();
});

function reloadPopup() {
$("#dialog-page-settings-content").load('<{$smarty.const.XOOPS_URL}>/modules/formulize/admin/screen_multipage_pages_settings.php?page=<{$pageIndex}>&sid=<{$sid}>');
}

</script>

0 comments on commit 42ac17e

Please sign in to comment.