Skip to content

Commit

Permalink
Smartening up to avoid warnings/notices (#565)
Browse files Browse the repository at this point in the history
  • Loading branch information
jegelstaff authored Nov 13, 2024
1 parent 7ef670e commit 33bec16
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 16 deletions.
6 changes: 3 additions & 3 deletions modules/formulize/class/fileUploadElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,9 @@ function adminSave($element, $ele_value) {
// $element is the element object
function loadValue($value, $ele_value, $element) {
$value = unserialize($value); // what we've got in the database is a serialized array, first key is filename, second key is flag for whether the filename is for real (might be an error message)
$ele_value[3] = $value['name'] ? $value['name'] : null; // add additional keys to ele_value where we'll put the value that is coming from the database for user's to see, plus other flags and so on
$ele_value[4] = $this->getFileDisplayName(strval($value['name']));
$ele_value[5] = $value['isfile'] ? $value['name'] : null;
$ele_value[3] = (isset($value['name']) AND $value['name']) ? $value['name'] : null; // add additional keys to ele_value where we'll put the value that is coming from the database for user's to see, plus other flags and so on
$ele_value[4] = $this->getFileDisplayName(strval($ele_value[3]));
$ele_value[5] = (isset($value['isfile']) AND $value['isfile']) ? $ele_value[3] : null;
return $ele_value;
}

Expand Down
36 changes: 24 additions & 12 deletions modules/formulize/include/extract.php
Original file line number Diff line number Diff line change
Expand Up @@ -931,10 +931,15 @@ function formulize_generateJoinSQL($linkOrdinal, $linkcommonvalue, $linkselfids,
if($linkcommonvalue[$linkOrdinal]) { // common value
$newJoinText = " $mainAlias.`" . $joinHandles[$linkselfids[$linkOrdinal]] . "`=$subAlias.`" . $joinHandles[$linktargetids[$linkOrdinal]]."`";
} elseif($linktargetids[$linkOrdinal]) { // linked selectbox
$main_ele_value = formulize_isLinkedSelectBox($linkselfids[$linkOrdinal]);
$target_ele_value = formulize_isLinkedSelectBox($linktargetids[$linkOrdinal]);
$mainBoxProperties = explode("#*=:*", $main_ele_value[2]);
$targetBoxProperties = explode("#*=:*", $target_ele_value[2]);
// set some values to use for figuring out the comparison of things in a sec...
$mainBoxProperties = array('','');
$targetBoxProperties = array('','');
if($main_ele_value = formulize_isLinkedSelectBox($linkselfids[$linkOrdinal])) {
$mainBoxProperties = explode("#*=:*", $main_ele_value[2]);
}
if($target_ele_value = formulize_isLinkedSelectBox($linktargetids[$linkOrdinal])) {
$targetBoxProperties = explode("#*=:*", $target_ele_value[2]);
}
// if the target is the link, or they're both links and the target is pointing to the main
if(($target_ele_value AND !$main_ele_value)
OR ($target_ele_value AND $main_ele_value AND $targetBoxProperties[1] == $joinHandles[$linkselfids[$linkOrdinal]])) {
Expand Down Expand Up @@ -971,7 +976,9 @@ function formulize_filterHasSingleEntry($filter) {
// filter strings can have multiple comparisons separated by ][
// a single number as the comparison value, means isolate that entry, and that's what we're looking for in this function
if(!is_array($filter)) {
$filter = array(0=>'AND', 1=>$filter);
$filter = array(0=>array(
0=>'AND', 1=>$filter)
);
}
foreach($filter as $thisFilter) {
$filterDetails = $thisFilter[1];
Expand Down Expand Up @@ -1823,13 +1830,18 @@ function formulize_getElementHandleFromID($element_id) {
// returns the ele_value array for this element if it is linked
// does not return the link if the values are snapshotted
function formulize_isLinkedSelectBox($elementOrHandle, $isHandle=false) {
static $cachedElements = array();
if(!isset($cachedElements[$elementOrHandle])) {
$evqRow = formulize_getElementMetaData($elementOrHandle, $isHandle);
$cachedElements[$elementOrHandle] = strstr($evqRow['ele_value'], "#*=:*") ? unserialize($evqRow['ele_value']) : false;
$cachedElements[$elementOrHandle] = ($cachedElements[$elementOrHandle] AND !$cachedElements[$elementOrHandle]['snapshot']) ? $cachedElements[$elementOrHandle] : false;
}
return $cachedElements[$elementOrHandle];
static $cachedElements = array();
if(!isset($cachedElements[$elementOrHandle])) {
$cachedElements[$elementOrHandle] = false; // default to false
$evqRow = formulize_getElementMetaData($elementOrHandle, $isHandle);
if(strstr($evqRow['ele_value'], "#*=:*")) {
$ele_value = unserialize($evqRow['ele_value']);
if(!isset($ele_value['snapshot']) OR !$ele_value['snapshot']) {
$cachedElements[$elementOrHandle] = $ele_value; // linked element that is not a snapshot, yay!
}
}
}
return $cachedElements[$elementOrHandle];
}

// This function returns true or false depending on whether an element is a multiselect selectbox or checkboxes
Expand Down
2 changes: 1 addition & 1 deletion modules/formulize/include/formdisplay.php
Original file line number Diff line number Diff line change
Expand Up @@ -3950,7 +3950,7 @@ function drawJavascriptForConditionalElements($conditionalElements, $governingEl
$initCode .= "relevantElements['".$thisGovernedElement."'][$topKey] = '".$thisGoverningElement."';\n";
$initCode .= "governedElements['".$thisGoverningElement."'][$innerKey] = '".$thisGovernedElement."';\n";
$initCode .= "oneToOneElements['".$thisGovernedElement."'][$topKey] = ";
if($oneToOneElements[$thisGoverningElement] == true) {
if(isset($oneToOneElements[$thisGoverningElement]) AND $oneToOneElements[$thisGoverningElement] == true) {
$initCode .= "true;\n";
foreach($oneToOneMetaData[$thisGoverningElement] as $key=>$value) {
$initCode .= "oneToOneElements['".$thisGovernedElement."']['$key'] = '$value';\n";
Expand Down

0 comments on commit 33bec16

Please sign in to comment.