function BrixEditor($custom_config = array()) {
global $DATI, $PAGINA;
$configurazione["tipo"] = "inner"; // inner|outer
if($custom_config) $configurazione = array_merge_recursive_replace($configurazione, $custom_config);
$html_opts = '
';
$html_opts = '' . $html_opts . '
';
$html_editor = '';
$html_editor = '' . $html_editor . '
' . $html_opts;
$DATI["less_dynamic_css"] .= "
#brix_opts {
._el_btn_add {
* {
pointer-events: none;
}
._el_html_cont {
display : none;
}
}
}
";
ob_start();
?>
$( document ).on( "click", "._el_btn_rem", function() {
$(this).closest("._el_html_cont").remove();
});
$( document ).on( "click", "._el_btn_add", function() {
var html_el = $("._el_html_cont", $(this)).clone();
html_el.prepend('X
');
$("#brix_canvas").append(html_el);
});
$(document).ready(function() {
});
$js_inc = ob_get_clean();
$DATI["body:" . $js_inc] = "JS,PRE_CLOSE";
return $html_editor;
}
function BrixElementoBeforeAfter($custom_config = array()) {
global $DATI, $PAGINA;
$configurazione["tipo"] = "inner"; // inner|outer
if($custom_config) $configurazione = array_merge_recursive_replace($configurazione, $custom_config);
if($configurazione["brick"]["dom"]["attributi"]["id"] != "") {
$el_id = $configurazione["brick"]["dom"]["attributi"]["id"];
}
$html_inc_before = "";
$html_inc_after = "";
$indice_check_before = $configurazione["tipo"] . "Before";
$indice_check_after = $configurazione["tipo"] . "After";
if($configurazione["elemento"] != "") {
if($configurazione["contenuto"] != "") {
if($configurazione["brick"][$configurazione["elemento"]][$indice_check_before]["include"] != "" and is_file($configurazione["brick"][$configurazione["elemento"]][$indice_check_before]["include"])) {
ob_start();
include($configurazione["brick"][$configurazione["elemento"]][$indice_check_before]["include"]);
$html_inc_before = ob_get_clean();
}
if($configurazione["brick"][$configurazione["elemento"]][$indice_check_after]["include"] != "" and is_file($configurazione["brick"][$configurazione["elemento"]][$indice_check_after]["include"])) {
ob_start();
include($configurazione["brick"][$configurazione["elemento"]][$indice_check_after]["include"]);
$html_inc_after = ob_get_clean();
}
$indice_dati_before = 'el-' . $el_id . '-' . $configurazione["elemento"] . '-' . $indice_check_before;
$indice_dati_after = 'el-' . $el_id . '-' . $configurazione["elemento"] . '-' . $indice_check_after;
// print '' . $indice_dati_before . ' -- ' . $indice_dati_after . '
';
// print '{' . $indice_dati_before . '}{' . $indice_dati_after . '}
';
$configurazione["contenuto"] = '{'. $indice_dati_before . '}' . $configurazione["contenuto"] . '{'. $indice_dati_after . '}';
$configurazione["contenuto"] = $html_inc_before . $configurazione["contenuto"] . $html_inc_after;
return $configurazione["contenuto"];
}
}
return;
}
function BrixOutBrick($custom_config = array()) {
global $DATI, $PAGINA, $css_framework, $P, $MENU;
$configurazione["tipo"] = "";
if($custom_config) $configurazione = array_merge_recursive_replace($configurazione, $custom_config);
if($configurazione["brick"]) {
if($configurazione["brick"]["dom"]["attributi"]["id"] != "") {
$el_id = $configurazione["brick"]["dom"]["attributi"]["id"];
} else {
trigger_error("un elemento non può non avere un id");
}
$classe_selettore_tipo_elemento = "_bx_" . $configurazione["brick"]["tipo"];
$output_brick_template = '
::_bx_header_::
::_bx_body_::
::_bx_footer_::
';
$check_include_tpl = indiIncludePath("_pagine/elementi/Brix/BrixBrick.inc.php");
if($check_include_tpl) {
ob_start();
$testmp = include(indiIncludePath("_pagine/elementi/Brix/BrixBrick.inc.php"));
$output_brick_template = ob_get_clean();
}
if($configurazione["brick"]["template"] != "") $output_brick_template = $configurazione["brick"]["template"];
if($output_brick_template != "") {
$brick_out_html["_bx_header_"] = "";
$brick_out_html["_bx_body_"] = "";
$brick_out_html["_bx_footer_"] = "";
if(true) { // css brick generici, prima di quelli relativi ai singoli tipi ///////////////////////////////////
$css_blocco["_br_output"] = "";
if($css_framework["container"]["funzione"]) {
$css_blocco["_br_output"] .= "
._bx_container {
." . $css_framework["container"]["funzione"] . "();
}
";
}
// $css_blocco["_br_output"] .= "._bx_container { background-color: rgba(15,150,150,0.35); } ._bx_element { margin:2px; border: 1px dashed #444; } ._bx_content_grid > * { border: 1px solid #F00; }";
$css_blocco["_br_output"] .= "
._bx_content_grid {
display : grid;
gap : 1rem;
grid-template-columns : 1fr;
}
._bx_element {
&._bx_element_plain {
padding-top : 2rem;
padding-bottom : 2rem;
}
&._bx_element_bg {
._bx_element_mask {
padding-top : 2rem;
padding-bottom : 2rem;
}
}
}
._bx_element {
position : relative;
background-color : #F5F5F5;
}
";
if(DEVICE == "phone") {
$css_blocco["_br_output"] .= "";
} else {
$css_blocco["_br_output"] .= "
";
}
if($css_blocco) {
datiAdd("less_dynamic_css_array_before", $css_blocco);
unset($css_blocco);
}
}
if(true) { // brick body ////////////////////////////////
$brick_el_array_edit = array();
if($configurazione["brick"]["tipo"] != "") { // tipi di elementi ///////////////////////////////////
ob_start();
include(indiIncludePath("_pagine/elementi/Brix/elementi/" . $configurazione["brick"]["tipo"] . ".php"));
$brick_out_html["_bx_body_"] = ob_get_clean();
if($configurazione["brick"]["template_output_elemento"] != "") {
$brick_out_html["_bx_body_"] = str_replace("::output_elemento::", $brick_out_html["_bx_body_"], $configurazione["brick"]["template_output_elemento"]);
}
if($brick_out_html["_bx_body_"] != "") {
$brick_out_html["_bx_body_"] = BrixElementoBeforeAfter(["brick" => $configurazione["brick"], "contenuto" => $brick_out_html["_bx_body_"], "elemento" => "body"]);
$brick_out_html["_bx_body_"] = '' . $brick_out_html["_bx_body_"] . '
';
$brick_out_html["_bx_body_"] = BrixElementoBeforeAfter(["brick" => $configurazione["brick"], "contenuto" => $brick_out_html["_bx_body_"], "elemento" => "body", "tipo" => "outer"]);
}
}
}
if(true) { // brick header ////////////////////////////////
if($configurazione["brick"]["dati"]["header"]) $dh = $configurazione["brick"]["dati"]["header"];
if($dh["titolo"]) {
ob_start();
include(indiIncludePath("_pagine/elementi/Brix/BrixBrickHeader.php"));
$brick_out_html["_bx_header_"] = trim(ob_get_clean());
}
if($brick_out_html["_bx_header_"] != "") {
$brick_out_html["_bx_header_"] = BrixElementoBeforeAfter(["brick" => $configurazione["brick"], "contenuto" => $brick_out_html["_bx_header_"], "elemento" => "header"]);
$brick_out_html["_bx_header_"] = '';
$brick_out_html["_bx_header_"] = BrixElementoBeforeAfter(["brick" => $configurazione["brick"], "contenuto" => $brick_out_html["_bx_header_"], "elemento" => "header", "tipo" => "outer"]);
}
}
if(true) { // brick footer ////////////////////////////////
// contenuto footer?
// $brick_out_html["_bx_footer_"] = 'brick footer';
if($brick_out_html["_bx_footer_"] != "") {
$brick_out_html["_bx_footer_"] = BrixElementoBeforeAfter(["brick" => $configurazione["brick"], "contenuto" => $brick_out_html["_bx_footer_"], "elemento" => "footer"]);
$brick_out_html["_bx_footer_"] = '';
$brick_out_html["_bx_footer_"] = BrixElementoBeforeAfter(["brick" => $configurazione["brick"], "contenuto" => $brick_out_html["_bx_footer_"], "elemento" => "footer", "tipo" => "outer"]);
}
}
$el_replace = getTagElementiTemplate($output_brick_template);
if(is_array($el_replace)) foreach($el_replace as $k => $v) {
$output_brick_template = str_replace("::" . $v . "::",$brick_out_html[$v], $output_brick_template);
}
if(true) { // brick guscio ////////////////////////////////
if(isset($configurazione["brick"]["dom"]["attributi"]["class"])) {
$configurazione["brick"]["dom"]["attributi"]["class"] = "_bx_element " . $classe_selettore_tipo_elemento . " " . $configurazione["brick"]["dom"]["attributi"]["class"];
} else {
$configurazione["brick"]["dom"]["attributi"]["class"] = "_bx_element " . $classe_selettore_tipo_elemento . "";
}
if($configurazione["brick"]["background"]["tipo"] == "img") {
$configurazione["brick"]["dom"]["attributi"]["class"] .= " _bx_element_bg ";
} else {
$configurazione["brick"]["dom"]["attributi"]["class"] .= " _bx_element_plain ";
}
$attr_html = array_to_attributi_html(["array_attributi" => $configurazione["brick"]["dom"]["attributi"]]);
if(isEditorSezioni()) {
$cfg_edit = array();
if(is_array($brick_el_array_edit)) {
$cfg_edit["opzioni"]["lista"] = $brick_el_array_edit;
}
$cfg_edit["attiva_edit"] = true;
$cfg_edit["elemento_id"] = $configurazione["brick"]["dom"]["attributi"]["id"];
$output_brick_template = edit_elemento_tag($cfg_edit) . $output_brick_template;
}
if($configurazione["brick"]["background"]["tipo"] == "img") {
$varsBackupBannerElemento = $vars;
ob_start();
$vars = array();
$vars["struttura"]["banner"]["attributi"] = $configurazione["brick"]["dom"]["attributi"];
$vars["struttura"]["banner"]["altezza"] = "auto";
$vars["immagini"]["immagini_cake"]["lista"] = $P["Immagini"];
$vars["contenuto_custom_banner"] = $output_brick_template;
$vars["struttura"]["mask_over"]["attributi"]["class"][0] = "_bx_element_mask";
$vars["stampa_contenitore_contenuto"] = false;
$vars["css_base_iniziale"] = false;
$vars["tipo_sfondo"] = "bg_fixed"; // color|bg|bg_img|bg_fixed|bg_slider|img_banda
include($DATI["cdn_basepath"]."_pagine/elementi/banner/banner.inc.php");
$output_brick_template = ob_get_clean();
$vars = $varsBackupBannerElemento;
} else {
$output_brick_template = '' . $output_brick_template . '
';
}
}
return $output_brick_template;
} else {
trigger_error("il template non può essere vuoto!");
}
}
return;
}
function BrixOutLista($custom_config = array()) {
global $DATI, $PAGINA;
$configurazione["tipo"] = "";
if($custom_config) $configurazione = array_merge_recursive_replace($configurazione, $custom_config);
if(is_array($configurazione["brix"]["sezioni"]["lista"]) and sizeof($configurazione["brix"]["sezioni"]["lista"])>0) {
foreach($configurazione["brix"]["sezioni"]["lista"] as $ks => $sezione) {
if(is_array($sezione["brix"]["lista"]) and sizeof($sezione["brix"]["lista"])>0) {
foreach($sezione["brix"]["lista"] as $kb => $brick) {
$output_brick = BrixOutBrick(array("brick" => $brick));
if($output_brick != "") {
$BrixOutHtml .= $output_brick;
}
}
}
}
if($BrixOutHtml != "") {
$BrixOutHtml = '' . $BrixOutHtml . '';
return $BrixOutHtml;
}
}
return;
}
?>