printFieldHeader($field ); echo $this->{$field["type"]}($field); $this->printFieldFooter(); } /** * Stampa una sezione basandosi sul modello concettuale * * @param ?String $name nome della sezione * @param Array $section struttura della sezione * @return void */ function printSection(?String $name, Array $section) { // WORKAROUND se un field si trova nella root if(str_starts_with($name, "eforms2")) { return $this->printField($section); } // Repeatable if(!isset($section["__meta"])) { foreach($section as $key => $member) { $this->printSection($key, $member); } return; } extract($section["__meta"]); // Extract __meta fields as variables // Clear them from the array unset($section["__meta"]); $auto_collapse = str_contains(strtolower($name), "unpublish"); $collapsed = $auto_collapse ? "collapsed" : ""; $collapse_button = $this->button( [ "name" => "button", "required" => false, "size" => "pr-2", "type" => "button", "title" => "", "attrs" => [ "data-toggle" => "collapse", "data-target" => "#collapse-{$unique_identifier}", "class" => "btn btn-sm btn-block btn-outline-secondary mr-2 {$collapsed}", ] ]); // Display headers if($display_type == "SECTION") { $this->printSectionHeader($this->translate($label), $id, $unique_identifier, $collapse_button); } else if($display_type == "GROUP") { $add_button = $delete_button = ""; // First iteration if($repeatable) { if($iteration == 0) { $add_button = $this->createAddButton($unique_identifier, $section_object, $this->notice, $this->info['codice'], $prefix); } elseif($preventDelete === false) { $delete_button = $this->createDeleteButton($unique_identifier); } } $this->printGroupHeader( $this->translate($label), $id, $unique_identifier, $repeatable, $iteration, $total_iterations, $add_button, $delete_button, $collapse_button, $tabNameProvider ?? $this->translate($label) . " - " . ($iteration + 1) ); } // For each member foreach($section as $key => $member) { // Print iteration if($display_type == "SECTION") { } if(isset($member["name"])) { $this->printField($member); } else { // Section $this->printSection($key, $member); } } if($display_type == "SECTION") { $this->printSectionFooter(); } if($display_type == "GROUP") { $this->printGroupFooter( $this->translate($label), $id, $unique_identifier, $repeatable, $iteration, $total_iterations, $add_button, $delete_button, $collapse_button ); } } /** * Print GUUE FORM * * @param mixed $section * @return void */ public function printForm(Array $section, Int $subsection_index) : void { $full_structure = []; $section_structure = $this->createFormStructure($section, $subsection_index, true, $full_structure); if($_SESSION["utente"]->isSupportoOrRoot()) { // Print settings toggles ?>

Strumenti di debug

printNoEFXButton($this->enable_efx_evaluation); $this->printShowLabelsButton($this->hide_labels); $this->printDebugEfxButton($this->advanced_debug); $this->printForcedSuggestionsButton($this->enable_forced_suggestions); // Print debug area if($this->mode === "edit" && $this->advanced_debug) { ?>
printDebugArea($full_structure); ?>
renderIntegrationHelpers("floating"); echo ""; $ready = empty($this->info["codice"]) ? "" : "data-ready=1"; echo "
"; foreach($section_structure as $key => $section) { if($key === "__meta") continue; $this->printSection($key, $section); } // Prepare autosave URL if($this->enable_efx_evaluation) { $autosave_url = "/backend/guue/save.php?"; // Check for valid section if(preg_match("/GR-([A-Za-z0-9-_])+/i", $_GET["section"] ?? "") === 1) { $autosave_url .= "section=" . $_GET["section"]; // Check for valid subsection if(is_numeric($_GET["subsection_index"] ?? "")) { $autosave_url .= "&subsection_index=" . $_GET["subsection_index"]; } } ?> insertJavascript(); } protected function printIntegrationSectionHeader(string $label, string $unique_identifier, string $collapse_button, string $position) { ?>
integration-section-header" id=''>

hide_labels): ?> ()

renderIntegrationHelpers($name); } protected function printGroupHeader(?String $label, ?String $name, String $unique_identifier , bool $repeatable, int $iteration, int $total_iterations, string $add_button, string $delete_button, string $collapse_button, string $tabName) : void { $auto_collapse = str_contains(strtolower($name), "unpublish"); if($repeatable) { ?>

hide_labels): ?> ()

renderIntegrationHelpers($name); ?>

hide_labels): ?> ()

renderIntegrationHelpers($name); } } protected function printGroupFooter(?String $label, ?String $name, String $unique_identifier = "", bool $repeatable, int $iteration, int $total_iterations, string $add_button, string $delete_button, string $collapse_button) : void { if($repeatable) { $close_repeatable_container = $repeatable && ($iteration >= ($total_iterations-1)); ?>
" >
button( [ "name" => "button", "required" => false, "size" => "pr-2", "type" => "button", "title" => "", "attrs" => [ "class" => "btn btn-xs btn-danger shadow-none ml-3 align-middle guue-delete-button", "style" => "float: right; margin-top: 0.2em;", "onClick" => "eForms2.deleteRepeatable('{$unique_identifier}'); return false;" ] ]); } protected function createAddButton($unique_identifier, $section, $notice, $codice, $prefix) { $object = $this->makeAdd2GUUEObject( [ "section" => $section, "notice" => $notice, "codice" => $codice, "prefix" => $prefix ]); $button = [ "name" => "button", "required" => false, "size" => "pr-2", "type" => "button", "title" => " " . __guue("Aggiungi") . "", "attrs" => [ "onClick" => "eForms2.add2GUUE('#{$unique_identifier}', '{$object}');", "class" => "btn btn-sm btn-block btn-primary guue-add-button" ] ]; return $this->button($button); } protected function printShowLabelsButton(bool $hide_labels) { ?>
type="checkbox" class="custom-control-input" id="label_toggle" >
type="checkbox" class="custom-control-input" id="efx_toggle" >
type="checkbox" class="custom-control-input" id="advanced_debug_toggle" >
type="checkbox" class="custom-control-input" id="forced_suggestion_toggle" >
suggestions)): ?>
Download XML (bozza)
xml->saveXML()), true) ?>
info["valori"]["eforms2"] ?? null; if($data_source) { dump($data_source); } ?>
info["valori"]["settings"] ?? false ) { dump($this->info["valori"]["settings"]); } if($_SESSION["notice" . $this->notice] ?? false ) { dump($_SESSION["notice" . $this->notice]); } dump($this->completed_subsections); ?>
suggestions)): ?>
suggestions) ?> integrationHelperData) ?>
getSectionByFieldID($subsection, $id, $return_section, false); if($depth_search !== null) return $depth_search; } return null; } public function processErrorTagForField($field, $error) { ob_start(); // Prendiamo la sezione alla quale appartiene $section = $this->getSectionByFieldID($this->fields, $field); if($section !== null) { $repetition = 0; // Se la sezione è ripetibile, arriviamo alla ripetizione tramite un workaround if($section["_repeatable"] ?? false) { $location = $error["@location"] ?? null; if($location) { // Troviamo la prima quadra della ripetizione visto che è sempre una macrosezione $repetition_candidate = substr($location, strpos($location, "[") + 1 ); // E prendiamo fino alla chiusura della quadra $repetition_candidate = substr($repetition_candidate, 0, strpos($repetition_candidate, "]") ); if(is_numeric($repetition_candidate)) { $repetition = (int)$repetition_candidate - 1; } } } $current_section = $_GET["section"]; $current_repetition = $_GET["subsection_index"]; // Se l'errore è in una sezione diversa dalla nostra if($current_section !== $section["id"] || $repetition != $current_repetition ) { ?> translate($section['_label'])?> 0 ? $repetition + 1 : ""; ?> > processErrorTagForField($see, $error); if($processed_field != $see) { echo $processed_field; } } } // Processiamo i riferimenti ai campi nel label $matches = []; preg_match_all('/(BT|OPT|OPP)-[\d]+(\((BT|OPT|OPP)-[\d]+\))*-+[a-zA-Z0-9]+/', $error["label"], $matches); $matches = array_unique($matches[0]) ?? []; if(preg_match("/\((BT-19[5678])\)/i", $error["label"], $unpublishField) === 1) { $labelAddition = __("Il campo {$unpublishField[1]} si riferisce alle sezioni 'Pubblicato successivamente'"); $error["label"] .= "
Info : $labelAddition"; } foreach($matches as $match) { $replaced = $this->processErrorTagForField($match, $error); if($replaced != $match) { $error["label"] = str_replace($match, $replaced, $error["label"]); } } echo($error["label"]); if($this->advanced_debug) { unset($error["label"]); echo("
");
      print_r($error);
      echo("
"); } } public function renderIntegrationHelpers(string $position) { $integrationHelperData = $this->integrationHelperData[$this->current_section_id][$this->current_subsection] ?? []; // Print integration data foreach($integrationHelperData as $integration) { if($integration["position"] !== $position) continue; // Cerchiamo il modulo di integrazione corretto global $beRoot; // Proviamo prima il path specifico $path = $beRoot."{$integration["modulo"]}/guue/render/{$integration["sottomodulo"]}.php"; // Path generico if(!file_exists($path)) { $path = $beRoot."guue/integration/{$integration["sottomodulo"]}.php"; } if (file_exists($path)) { $unique_identifier = "integration_{$integration['modulo']}_{$integration['sottomodulo']}"; $collapse_button = $this->button( [ "name" => "button", "required" => false, "size" => "pr-2", "type" => "button", "title" => "", "attrs" => [ "data-toggle" => "collapse", "data-target" => "#collapse-{$unique_identifier}", "class" => "btn btn-sm btn-block btn-outline-secondary mr-2 guue-collapse-button", ] ]); $this->printIntegrationSectionHeader($integration["title"], $unique_identifier, $collapse_button, $position); // Wrappo in una funzione perchè PHP è una cacca e non capisce il concetto di scope // delle variabili $callIntegration = function ($path) use ($integration) { // Se l'array è una lista, renderizziamo l'helper per ogni entry require($path); }; $callIntegration($path); $this->printIntegrationSectionFooter(); } } } }