Skip to content

Add ib and areamodif to the valid list of elements, by completing their class files! #809

@jegelstaff

Description

@jegelstaff

The modules/formulize/class/textElement.php file is a good example to work from. There needs to be a new file called ibElement.php and a new one called areamodifElement.php

To create the content of these new class file for the ib and the areamodif element types, we need to start by taking all the places in the codebase that call a method on the type-specific element handler, and take any code around that location that is referencing ib or areamodif in a hard coded way, and instead move it into the appropriate method in a new class file for the ib type of element and the areamodif type of element.

The type specific element handler is one that is instantiated by referencing the particular type of element in use, rather than the general element handler that is the parent of all the type specific ones.

An example of the code that needs to move into a new class file is in the modules/formulize/class/elementrenderer.php file. There is this block of code:

case 'areamodif':
				$ele_value[0] = $this->formulize_replaceReferencesAndVariables($ele_value[0], $entry_id, $id_form, $renderedElementMarkupName, $screen);
				if(strstr($ele_value[0], "\$value=") OR strstr($ele_value[0], "\$value =")) {
					$form_id = $id_form;
					$entryData = gatherDataset($id_form, filter: $entry_id, frid: 0);
					$entry = $entryData[0];
					$creation_datetime = getValue($entry, "creation_datetime");
					$entryData = $entry; // alternate variable name for backwards compatibility
					$ele_value[0] = removeOpeningPHPTag($ele_value[0]);
					$value = ""; // will be set in eval
					$evalResult = eval($ele_value[0]);
					if($evalResult === false) {
						$ele_value[0] = _formulize_ERROR_IN_LEFTRIGHT;
					} else {
						$ele_value[0] = $value; // value is supposed to be the thing set in the eval'd code
						$ele_value[0] = $this->formulize_replaceReferencesAndVariables($ele_value[0], $entry_id, $id_form, $renderedElementMarkupName, $screen); // just in case PHP might have added { } refs
					}
				}
				$form_ele = new XoopsFormLabel(
					$ele_caption,
					$ele_value[0],
          $renderedElementMarkupName
				);
				$form_ele->setClass("formulize-text-for-display");
			break;

And below that there is a default case where the render method of the element type handler gets called. So the code in this case statement needs to go into the render method of the new areamodifElement.php file.

One challenge (among many) in doing this is that the variable names used in the existing code, may not be defined or in scope within the new render method, so the way things are referenced may need to change. Figuring this out may require tracing back through the code to see exactly what has been passed in to the method.

Metadata

Metadata

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions