Made more changes to the Admin Fields Conditions area to insure that the correct behaviour is aplied to the required fields. Removed the double forward slashes from the paths in the structure area of the compiler.

This commit is contained in:
2018-09-10 13:04:52 +02:00
parent 5b1813db7c
commit 49ef674c79
18 changed files with 326 additions and 170 deletions

View File

@ -2696,6 +2696,11 @@ class Get
{
return $this->uniqueFieldNames[$listViewName . $field['hash']];
}
// always make sure we have a field name and type
if (!isset($field['settings']) || !isset($field['settings']->type_name) || !isset($field['settings']->name))
{
return 'error';
}
// set the type name
$type_name = ComponentbuilderHelper::safeString($field['settings']->type_name);
// set the name of the field

View File

@ -964,7 +964,7 @@ class Structure extends Get
}
$back = true;
}
// chekc if we had success
// check if we had success
if ($back || $front)
{
return true;
@ -1308,9 +1308,11 @@ class Structure extends Get
// make we have not duplicates
$key_pointer = ComponentbuilderHelper::safeString($custom['folder']) . '_f' . $pointer_tracker;
$pointer_tracker++;
// fix custom path
$custom['path'] = ltrim($custom['path'], '/');
// set new folder to object
$versionData->move->static->$key_pointer = new stdClass();
$versionData->move->static->$key_pointer->naam = $custom['folder'];
$versionData->move->static->$key_pointer->naam = str_replace('//','/', $custom['folder']);
$versionData->move->static->$key_pointer->path = 'c0mp0n3nt/' . $custom['path'];
$versionData->move->static->$key_pointer->rename = $rename;
$versionData->move->static->$key_pointer->newName = $newname;
@ -1359,7 +1361,7 @@ class Structure extends Get
$pointer_tracker++;
// set new file to object
$versionData->move->static->$key_pointer = new stdClass();
$versionData->move->static->$key_pointer->naam = $custom['file'];
$versionData->move->static->$key_pointer->naam = str_replace('//','/',$custom['file']);
// update the dynamic component name placholders in file names
$custom['path'] = $this->setPlaceholders($custom['path'], $this->placeholders);
// get the path info
@ -1374,6 +1376,9 @@ class Structure extends Get
}
elseif ('full' === $customPath)
{
// fix custom path
$custom['path'] = ltrim($custom['path'], '/');
// get file array
$fileArray = explode('/', $custom['file']);
// set the info
$versionData->move->static->$key_pointer->path = 'c0mp0n3nt/' . $custom['path'];
@ -1383,7 +1388,7 @@ class Structure extends Get
else
{
// fix custom path
$custom['path'] = trim($custom['path'], '/');
$custom['path'] = ltrim($custom['path'], '/');
// set the info
$versionData->move->static->$key_pointer->path = 'c0mp0n3nt/' . $custom['path'];
$versionData->move->static->$key_pointer->rename = false;

View File

@ -4388,12 +4388,10 @@ class Interpretation extends Fields
{
if ($type !== 'static')
{
//var_dump($replacment); echo PHP_EOL;
$echos[$replacment] = "#" . "#" . "#" . $replacment . "#" . "#" . "#<br />";
}
elseif ($type === 'static')
{
//var_dump($replacment); echo PHP_EOL;
$echos[$replacment] = "#" . "#" . "#" . $replacment . "#" . "#" . "#<br />";
}
}
@ -9228,7 +9226,7 @@ class Interpretation extends Fields
// set the if values
$ifValue[$matchName] = $this->ifValueScript($matchName, $condition['match_behavior'], $condition['match_type'], $options);
// set the target controls
$targetControls[$matchName] = $this->setTargetControlsScript($condition['target_field'], $targetBehavior, $targetDefault, $uniqueVar, $viewName);
$targetControls[$matchName] = $this->setTargetControlsScript($toggleSwitch[$matchName], $condition['target_field'], $targetBehavior, $targetDefault, $uniqueVar, $viewName);
foreach ($relations as $relation)
{
@ -9266,7 +9264,7 @@ class Interpretation extends Fields
// set the if values
$ifValue[$matchName] = $this->ifValueScript($matchName, $condition['match_behavior'], $condition['match_type'], $options);
// set the target controls
$targetControls[$matchName] = $this->setTargetControlsScript($condition['target_field'], $targetBehavior, $targetDefault, $uniqueVar, $viewName);
$targetControls[$matchName] = $this->setTargetControlsScript($toggleSwitch[$matchName], $condition['target_field'], $targetBehavior, $targetDefault, $uniqueVar, $viewName);
}
}
}
@ -9434,11 +9432,6 @@ class Interpretation extends Fields
}
$ifcounter++;
}
else
{
var_dump($functions);
var_dump($ifValue);exit;
}
}
$func .= ")" . PHP_EOL . $this->_t(1) . "{";
}
@ -9451,19 +9444,21 @@ class Interpretation extends Fields
foreach ($controls as $target => $action)
{
$func .= $action['behavior'];
if (ComponentbuilderHelper::checkString($action['hide']))
if (ComponentbuilderHelper::checkString($action[$targetBehavior]))
{
$func .= $action[$targetBehavior];
$head .= $action['requiredVar'];
}
}
// check if this is a toggle switch
if ($toggleSwitch[$f_matchKeys[0]])
{
$func .= PHP_EOL . $this->_t(1) . "}" . PHP_EOL . $this->_t(1) . "else" . PHP_EOL . $this->_t(1) . "{";
// load the default behavior
foreach ($controls as $target => $action)
{
$func .= $action['default'];
if (ComponentbuilderHelper::checkString($action['hide']))
if (ComponentbuilderHelper::checkString($action[$targetDefault]))
{
$func .= $action[$targetDefault];
}
@ -9680,7 +9675,7 @@ class Interpretation extends Fields
return false;
}
public function setTargetControlsScript($targets, $targetBehavior, $targetDefault, $uniqueVar, $viewName)
public function setTargetControlsScript($toggleSwitch, $targets, $targetBehavior, $targetDefault, $uniqueVar, $viewName)
{
$bucket = array();
if (ComponentbuilderHelper::checkArray($targets) && !in_array($uniqueVar, $this->targetControlsScriptChecker))
@ -9725,25 +9720,48 @@ class Interpretation extends Fields
// the hide required function
if ($target['required'] === 'yes')
{
$hide = PHP_EOL . $this->_t(2) . "if (!jform_" . $unique . "_required)";
$hide .= PHP_EOL . $this->_t(2) . "{";
$hide .= PHP_EOL . $this->_t(3) . "updateFieldRequired('" . $target['name'] . "',1);";
$hide .= PHP_EOL . $this->_t(3) . "jQuery('#jform_" . $target['name'] . "').removeAttr('required');";
$hide .= PHP_EOL . $this->_t(3) . "jQuery('#jform_" . $target['name'] . "').removeAttr('aria-required');";
$hide .= PHP_EOL . $this->_t(3) . "jQuery('#jform_" . $target['name'] . "').removeClass('required');";
$hide .= PHP_EOL . $this->_t(3) . "jform_" . $unique . "_required = true;";
$hide .= PHP_EOL . $this->_t(2) . "}";
$bucket[$target['name']]['hide'] = $hide;
// the show required function
$show = PHP_EOL . $this->_t(2) . "if (jform_" . $unique . "_required)";
$show .= PHP_EOL . $this->_t(2) . "{";
$show .= PHP_EOL . $this->_t(3) . "updateFieldRequired('" . $target['name'] . "',0);";
$show .= PHP_EOL . $this->_t(3) . "jQuery('#jform_" . $target['name'] . "').prop('required','required');";
$show .= PHP_EOL . $this->_t(3) . "jQuery('#jform_" . $target['name'] . "').attr('aria-required',true);";
$show .= PHP_EOL . $this->_t(3) . "jQuery('#jform_" . $target['name'] . "').addClass('required');";
$show .= PHP_EOL . $this->_t(3) . "jform_" . $unique . "_required = false;";
$show .= PHP_EOL . $this->_t(2) . "}" . PHP_EOL;
$bucket[$target['name']]['show'] = $show;
if ($toggleSwitch)
{
$hide = PHP_EOL . $this->_t(2) . "//" . $this->setLine(__LINE__) . " remove required attribute from " . $target['name'] . " field";
$hide .= PHP_EOL . $this->_t(2) . "if (!jform_" . $unique . "_required)";
$hide .= PHP_EOL . $this->_t(2) . "{";
$hide .= PHP_EOL . $this->_t(3) . "updateFieldRequired('" . $target['name'] . "',1);";
$hide .= PHP_EOL . $this->_t(3) . "jQuery('#jform_" . $target['name'] . "').removeAttr('required');";
$hide .= PHP_EOL . $this->_t(3) . "jQuery('#jform_" . $target['name'] . "').removeAttr('aria-required');";
$hide .= PHP_EOL . $this->_t(3) . "jQuery('#jform_" . $target['name'] . "').removeClass('required');";
$hide .= PHP_EOL . $this->_t(3) . "jform_" . $unique . "_required = true;";
$hide .= PHP_EOL . $this->_t(2) . "}";
$bucket[$target['name']]['hide'] = $hide;
// the show required function
$show = PHP_EOL . $this->_t(2) . "//" . $this->setLine(__LINE__) . " add required attribute to " . $target['name'] . " field";
$show .= PHP_EOL . $this->_t(2) . "if (jform_" . $unique . "_required)";
$show .= PHP_EOL . $this->_t(2) . "{";
$show .= PHP_EOL . $this->_t(3) . "updateFieldRequired('" . $target['name'] . "',0);";
$show .= PHP_EOL . $this->_t(3) . "jQuery('#jform_" . $target['name'] . "').prop('required','required');";
$show .= PHP_EOL . $this->_t(3) . "jQuery('#jform_" . $target['name'] . "').attr('aria-required',true);";
$show .= PHP_EOL . $this->_t(3) . "jQuery('#jform_" . $target['name'] . "').addClass('required');";
$show .= PHP_EOL . $this->_t(3) . "jform_" . $unique . "_required = false;";
$show .= PHP_EOL . $this->_t(2) . "}";
$bucket[$target['name']]['show'] = $show;
}
else
{
$hide = PHP_EOL . $this->_t(2) . "//" . $this->setLine(__LINE__) . " remove required attribute from " . $target['name'] . " field";
$hide .= PHP_EOL . $this->_t(2) . "updateFieldRequired('" . $target['name'] . "',1);";
$hide .= PHP_EOL . $this->_t(2) . "jQuery('#jform_" . $target['name'] . "').removeAttr('required');";
$hide .= PHP_EOL . $this->_t(2) . "jQuery('#jform_" . $target['name'] . "').removeAttr('aria-required');";
$hide .= PHP_EOL . $this->_t(2) . "jQuery('#jform_" . $target['name'] . "').removeClass('required');";
$hide .= PHP_EOL . $this->_t(2) . "jform_" . $unique . "_required = true;" . PHP_EOL;
$bucket[$target['name']]['hide'] = $hide;
// the show required function
$show = PHP_EOL . $this->_t(2) . "//" . $this->setLine(__LINE__) . " add required attribute to " . $target['name'] . " field";
$show .= PHP_EOL . $this->_t(2) . "updateFieldRequired('" . $target['name'] . "',0);";
$show .= PHP_EOL . $this->_t(2) . "jQuery('#jform_" . $target['name'] . "').prop('required','required');";
$show .= PHP_EOL . $this->_t(2) . "jQuery('#jform_" . $target['name'] . "').attr('aria-required',true);";
$show .= PHP_EOL . $this->_t(2) . "jQuery('#jform_" . $target['name'] . "').addClass('required');";
$show .= PHP_EOL . $this->_t(2) . "jform_" . $unique . "_required = false;" . PHP_EOL;
$bucket[$target['name']]['show'] = $show;
}
// make sure that the axaj and other needed things for this view is loaded
$this->validationFixBuilder[$viewName][] = $target['name'];
}
@ -9860,7 +9878,6 @@ class Interpretation extends Fields
// TODO this needs a closer look, a bit buggy
$userFix = " && " . $value . " != 0";
}
//echo '<pre>'; var_dump($type);exit;
$string .= 'isSet(' . $value . ')' . $userFix;
}
}