Skip to content

Commit

Permalink
Added box elements model detection in time_machine data to prevent er…
Browse files Browse the repository at this point in the history
…rors in component construction
  • Loading branch information
Paco committed Feb 22, 2022
1 parent a2f4a93 commit d2ba7fb
Showing 1 changed file with 29 additions and 26 deletions.
55 changes: 29 additions & 26 deletions lib/dedalo/time_machine_list/class.time_machine_list.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class time_machine_list extends common {

/**
* CONSTRUCT
*
*
*/
public function __construct($tipo, $section_id, $section_tipo, $modo='edit') {

Expand Down Expand Up @@ -75,7 +75,7 @@ public function get_time_machine_list_obj($limit=1, $offset=0, $count=false) {
}

foreach((array)$ar_component_time_machine as $tm_obj) {

$date = component_date::timestamp_to_date($tm_obj->get_timestamp(), $seconds=true);
$userID = $tm_obj->get_userID();
$mod_user_name = section::get_user_name_by_userID($userID);
Expand All @@ -85,7 +85,7 @@ public function get_time_machine_list_obj($limit=1, $offset=0, $count=false) {
$dato = $tm_obj->get_dato();
$uid = $tm_obj->get_identificador_unico();
$show_row = false;

if(empty($component_tipo)) continue;

$component_label = RecordObj_dd::get_termino_by_tipo($component_tipo, DEDALO_DATA_LANG);
Expand All @@ -94,28 +94,31 @@ public function get_time_machine_list_obj($limit=1, $offset=0, $count=false) {
switch ($modelo_name) {
case 'component_text_area':
$value = component_text_area::clean_raw_text_for_preview($dato);
$value = strip_tags($value);
$value = strip_tags($value);
break;
case 'component_state':
$value ='';
break;
case 'section':
continue 2;
break;
case 'box elements':
debug_log(__METHOD__." Ignored model $modelo_name ".to_string(), logger::WARNING);
continue 2;
break;
default:
if (!is_string($dato)) {
$current_component = component_common::get_instance(
$modelo_name,
$component_tipo,
$this->section_id,
'list',
$lang,
$this->section_tipo
$modelo_name,
$component_tipo,
$this->section_id,
'list',
$lang,
$this->section_tipo
);
$current_component->set_dato($dato);
$value = $current_component->get_valor();
#$value = json_encode($dato, JSON_UNESCAPED_UNICODE);

}else{
$value = $dato;
$value = strip_tags($value);
Expand All @@ -126,14 +129,14 @@ public function get_time_machine_list_obj($limit=1, $offset=0, $count=false) {

$max_long = 50;
if (strlen($value)>$max_long) {
$value = mb_substr($value, 0, $max_long) . '..';
$value = mb_substr($value, 0, $max_long) . '..';
}

$lang_label = null;
if($lang !== 'lg-nolan'){
$lang_label = lang::get_name_from_code($lang);
}

// Row object
$row_obj = new stdClass();
$row_obj->date = $date;
Expand All @@ -150,7 +153,7 @@ public function get_time_machine_list_obj($limit=1, $offset=0, $count=false) {
$row_obj->tool_name = 'tool_time_machine';

$ar_data[] = $row_obj;

}//end foreach((array)$ar_component_time_machine as $tm_obj)


Expand All @@ -171,14 +174,14 @@ public function get_time_machine_list_obj($limit=1, $offset=0, $count=false) {
$json->$context = $ar_context;
$json->data = $ar_data;

return (array)$json;
return (array)$json;
}//end get_inverse_references



/**
* GET_DATA
*
*
*/
public function get_ar_data($locator, $ar_components, $value_resolved=false){

Expand All @@ -193,17 +196,17 @@ public function get_ar_data($locator, $ar_components, $value_resolved=false){
$current_id->component_tipo = 'id';

$data[] = $current_id;

if($value_resolved===true && isset($ar_components)){
foreach ($ar_components as $current_relation_component) {
foreach ($current_relation_component as $modelo => $tipo) {
$modelo_name = RecordObj_dd::get_modelo_name_by_tipo($modelo, true);
$current_component = component_common::get_instance(
$modelo_name,
$tipo,
$modelo_name,
$tipo,
$section_id,
'list',
DEDALO_DATA_LANG,
'list',
DEDALO_DATA_LANG,
$section_tipo
);
$value = $current_component->get_valor();
Expand All @@ -218,7 +221,7 @@ public function get_ar_data($locator, $ar_components, $value_resolved=false){
}
}
}

return $data;

}//end get_data
Expand All @@ -227,22 +230,22 @@ public function get_ar_data($locator, $ar_components, $value_resolved=false){

/**
* GET_JSON
*
*
*/
public function get_json(){

if(SHOW_DEBUG===true) $start_time = start_time();

#dump(DEDALO_LIB_BASE_PATH .'/'. get_called_class() .'/'. get_called_class() .'_json.php', '++++++++++++++++++++');
# Class name is called class (ex. component_input_text), not this class (common)

# Class name is called class (ex. component_input_text), not this class (common)
include ( DEDALO_LIB_BASE_PATH .'/'. get_called_class() .'/'. get_called_class() .'_json.php' );

if(SHOW_DEBUG===true) {
#$GLOBALS['log_messages'][] = exec_time($start_time, __METHOD__. ' ', "html");
global$TIMER;$TIMER[__METHOD__.'_'.get_called_class().'_'.$this->tipo.'_'.$this->modo.'_'.microtime(1)]=microtime(1);
}

return $json;
}//end get_json

Expand Down

0 comments on commit d2ba7fb

Please sign in to comment.