Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/gitdedalo/v5' into v5
Browse files Browse the repository at this point in the history
# Conflicts:
#	lib/dedalo/config/version.inc
  • Loading branch information
alex-render committed May 16, 2023
2 parents 1cf2125 + c011a95 commit fdd351f
Show file tree
Hide file tree
Showing 7 changed files with 247 additions and 168 deletions.
2 changes: 1 addition & 1 deletion lib/dedalo/common/css/structure.css

Large diffs are not rendered by default.

89 changes: 44 additions & 45 deletions lib/dedalo/component_autocomplete_hi/component_autocomplete_hi.php
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
<?php

# CONTROLLER

$tipo = $this->get_tipo();
$parent = $this->get_parent();
$section_tipo = $this->get_section_tipo();
$modo = $this->get_modo();
$modo = $this->get_modo();

$propiedades = isset($this->propiedades) ? $this->propiedades : $this->get_propiedades();
$label = $this->get_label();
$required = $this->get_required();
$debugger = $this->get_debugger();
$permissions = $this->get_component_permissions();
$ejemplo = NULL;
$html_title = "Info about $parent";
$ar_tools_obj = $this->get_ar_tools_obj();
$ar_tools_obj = $this->get_ar_tools_obj();
$lang = $this->get_lang();
$identificador_unico = $this->get_identificador_unico();
$identificador_unico = $this->get_identificador_unico();
$component_name = get_class($this);
$relation_type = $this->get_relation_type();
$dato = $this->get_dato(); // !!
Expand All @@ -28,8 +28,8 @@
$file_name = $modo;
$from_modo = $modo;

switch($modo) {

switch($modo) {

case 'edit_in_list':
// Fix always edit as modo / filename
Expand Down Expand Up @@ -64,22 +64,22 @@
if (!empty($var_requested)) {
$from_modo = $var_requested;
}

// hierarchy_terms. Defined in propiedades, constrain searched terms using children terms
$hierarchy_terms_json = null;
if (isset($propiedades->source->hierarchy_terms)) {
$ar_childrens = [];
$hierarchy_terms = [];
foreach ((array)$propiedades->source->hierarchy_terms as $key => $item) {
$resursive = (bool)$item->recursive;
# Get childrens
$ar_childrens = array_merge($ar_childrens, component_relation_children::get_childrens($item->section_id, $item->section_tipo, null, $resursive));
# Get childrens
$ar_childrens = array_merge($ar_childrens, component_relation_children::get_childrens($item->section_id, $item->section_tipo, null, $resursive));

# Add pseudo locator
$hierarchy_terms[] = $item->section_tipo .'_'. $item->section_id;
}
$constrain_data = $ar_childrens;


$filter_custom = [];
$component_section_id_tipo = section::get_ar_children_tipo_by_modelo_name_in_section($section_tipo, ['component_section_id'], true, true, true, true, false);
Expand All @@ -100,14 +100,14 @@

$hierarchy_terms_json = json_encode($hierarchy_terms);
}//end if (isset($propiedades->source->hierarchy_terms))

// ar_filter_options
$ar_filter_options = false; // Default
switch ($options_type) {
case 'hierarchy':
$hierarchy_types = isset($propiedades->source->hierarchy_types) ? $propiedades->source->hierarchy_types : null;
$hierarchy_sections = isset($propiedades->source->hierarchy_sections) ? $propiedades->source->hierarchy_sections : null;

# Resolve hierarchy_sections for speed
if (!empty($hierarchy_types)) {
$hierarchy_sections = component_autocomplete_hi::add_hierarchy_sections_from_types($hierarchy_types, (array)$hierarchy_sections);
Expand All @@ -127,36 +127,35 @@
$ar_terms = array_merge($ar_terms, $current_term);
}else{
$ar_terms[] = $current_term;
}
}
}else{
debug_log(__METHOD__." ERROR: Misconfigured section tipo: '$current_section'. No property 'term' found in section map thesaurus. Fix ASAP this structure error".to_string(), logger::ERROR);
}
}
$ar_terms = array_unique($ar_terms);

$ar_filter_options = $this->get_ar_filter_options($options_type, $hierarchy_sections);
break;

/*
* Don't used for now, maybe can unify with the component_autocomplete (it use the "filter_by_list")
*
case 'generic':
# FIlTER_BY_LIST (Propiedades option)
# FIlTER_BY_LIST (Propiedades option)
if (isset($propiedades->source->filter_by_list)) {
$ar_filter_options = $this->get_ar_filter_options($options_type, $propiedades->source->filter_by_list);
}
break;
*/
}
#dump($ar_filter_options, ' ar_filter_options ++ '.to_string());

// search_query_object params
// q_operator is injected by trigger search2
$q_operator = isset($this->q_operator) ? $this->q_operator : null;
// Limit (Max items allow. 0 for unlimited)
$limit = isset($propiedades->limit) ? (int)$propiedades->limit : 0;
// Divisor
$divisor = $this->get_divisor();
$divisor = $this->get_divisor();
$min_length = isset($propiedades->min_length) ? (int)$propiedades->min_length : 1;

// search_query_object build
Expand All @@ -178,9 +177,9 @@
$search_query_object_options->tipo = $tipo;
$search_query_object = component_autocomplete_hi::build_search_query_object($search_query_object_options);
$json_search_query_object = json_encode( $search_query_object, JSON_UNESCAPED_UNICODE | JSON_HEX_APOS);
#dump($json_search_query_object, ' json_search_query_object ++ '.to_string());
break;
#dump($json_search_query_object, ' json_search_query_object ++ '.to_string());
break;

case 'search' :
// General vars
# dato is injected by trigger search wen is needed
Expand All @@ -201,7 +200,7 @@
$search_input_name = $this->get_search_input_name();
$source_mode = $this->get_source_mode();
$options_type = $this->get_options_type();

$ar_referenced_tipo = $this->get_ar_referenced_tipo();
$ar_referenced_tipo_json= json_handler::encode($this->get_ar_referenced_tipo());

Expand All @@ -212,14 +211,14 @@
$hierarchy_terms = [];
foreach ((array)$propiedades->source->hierarchy_terms as $key => $item) {
$resursive = (bool)$item->recursive;
# Get childrens
$ar_childrens = array_merge($ar_childrens, component_relation_children::get_childrens($item->section_id, $item->section_tipo, null, $resursive));
# Get childrens
$ar_childrens = array_merge($ar_childrens, component_relation_children::get_childrens($item->section_id, $item->section_tipo, null, $resursive));

# Add pseudo locator
$hierarchy_terms[] = $item->section_tipo .'_'. $item->section_id;
$hierarchy_terms[] = $item->section_tipo .'_'. $item->section_id;
}
$constrain_data = $ar_childrens;


$filter_custom = [];
$component_section_id_tipo = section::get_ar_children_tipo_by_modelo_name_in_section($section_tipo, ['component_section_id'], true, true, true, true, false);
Expand All @@ -239,8 +238,8 @@
}

$hierarchy_terms_json = json_encode($hierarchy_terms);
}//end if (isset($propiedades->source->hierarchy_terms))
}//end if (isset($propiedades->source->hierarchy_terms))

// ar_filter_options
$hierarchy_types = isset($propiedades->source->hierarchy_types) ? $propiedades->source->hierarchy_types : null;
$hierarchy_sections = isset($propiedades->source->hierarchy_sections) ? $propiedades->source->hierarchy_sections : null;
Expand All @@ -251,7 +250,7 @@
$hierarchy_types = isset($propiedades->source->hierarchy_types) ? $propiedades->source->hierarchy_types : null;
$hierarchy_sections = isset($propiedades->source->hierarchy_sections) ? $propiedades->source->hierarchy_sections : null;
#dump($hierarchy_sections, ' hierarchy_sections ++ '.to_string()); #return null;

# Resolve hierarchy_sections for speed
if (!empty($hierarchy_types)) {
$hierarchy_sections = component_autocomplete_hi::add_hierarchy_sections_from_types($hierarchy_types, (array)$hierarchy_sections);
Expand All @@ -270,15 +269,15 @@
$ar_terms = array_merge($ar_terms, $current_term);
}else{
$ar_terms[] = $current_term;
}
}
}
$ar_terms = array_unique($ar_terms);

$ar_filter_options = $this->get_ar_filter_options($options_type, $hierarchy_sections);
break;

case 'generic':
# FIlTER_BY_LIST (Propiedades option)
# FIlTER_BY_LIST (Propiedades option)
if (isset($propiedades->source->filter_by_list)) {
$ar_filter_options = $this->get_ar_filter_options($options_type, $propiedades->source->filter_by_list);
}
Expand All @@ -290,7 +289,7 @@
$q_operator = isset($this->q_operator) ? $this->q_operator : null;
# limit (Max items allow. 0 for unlimited)
$limit = 1;
$divisor = $this->get_divisor();
$divisor = $this->get_divisor();
$min_length = isset($propiedades->min_length) ? (int)$propiedades->min_length : 1;

// search_query_object build
Expand All @@ -311,13 +310,13 @@
$search_query_object = component_autocomplete_hi::build_search_query_object($search_query_object_options);
$json_search_query_object = json_encode( $search_query_object, JSON_UNESCAPED_UNICODE | JSON_HEX_APOS);
#dump($json_search_query_object, ' json_search_query_object ++ '.to_string());

//search mode always can edit the field, permissions always in 2
$permissions = 2;

$file_name = 'edit';
break;

case 'list_tm' :
$file_name = 'list';
case 'portal_list':
Expand All @@ -327,12 +326,12 @@
$component_info = $this->get_component_info('json');
$valor = $this->get_valor($lang);
$ar_valor = $this->get_valor($lang,'array');

$file_name = 'list';
break;

case 'list' :
//$dato = $this->get_dato();
//$dato = $this->get_dato();
# Return direct value for store in 'valor_list'
$valor = $this->get_valor($lang,'string');
echo (string)$valor; # Like "Catarroja, L'Horta Sud, Valencia/València, Comunidad Valenciana, España"
Expand All @@ -342,22 +341,22 @@
case 'relation':
return NULL;
# Force file_name to 'list'
$file_name = 'list';
$file_name = 'list';
break;

case 'print' :
$valor = $this->get_valor($lang,'string');
break;

case 'tool_time_machine' :
case 'tool_time_machine' :
return NULL;
$id_wrapper = 'wrapper_'.$identificador_unico.'_tm';
$input_name = "{$tipo}_{$id}_tm";
$file_name = 'edit';
break;
break;

}

$page_html = DEDALO_LIB_BASE_PATH .'/'. get_class($this) . '/html/' . get_class($this) . '_' . $file_name . '.phtml';
if( !include($page_html) ) {
echo "<div class=\"error\">Invalid mode $this->modo</div>";
Expand Down
2 changes: 1 addition & 1 deletion lib/dedalo/config/version.inc
Original file line number Diff line number Diff line change
Expand Up @@ -2910,4 +2910,4 @@
define('DEDALO_BUILD', date("d-m-Y H:i:s ", $last_modification_timestamp));
$_SESSION['dedalo4']['config']['DEDALO_BUILD'] = DEDALO_BUILD;
}
*/
*/
70 changes: 54 additions & 16 deletions lib/dedalo/diffusion/class.diffusion_sql.php
Original file line number Diff line number Diff line change
Expand Up @@ -3112,6 +3112,60 @@ public static function map_locator_to_term_id($options, $dato) {



/**
* MAP_LOCATOR_TO_INT
* Get only the first locator section_id if exists
* @return int | null
*/
public static function map_locator_to_int($options=null, $dato=null) {

$value = (!empty($dato) && isset($dato[0]))
? (int)$dato[0]->section_id
: null;

return $value;
}//end map_locator_to_int



/**
* MAP_LOCATOR_TO_INT_RECURSIVE
* Convert array of locators (dato) to array of section_id.
* If isset propiedades->process_dato_arguments->custom_arguments->add_parents as true
* it will be recursive
* @param object $options
* @param array|null $dato
* @return array|null $value
*/
public static function map_locator_to_int_recursive($options=null, $dato=null) : ?array {

if (empty($dato)) {
return null;
}

$value = [];
foreach ($dato as $current_locator) {

$value[] = (string)$current_locator->section_id;;

// parents recursive
// add parents option
// if defined in properties, get current locator parents recursively and add it to current value (like municipality, region, country hierarchy)
if (isset($options->propiedades->process_dato_arguments->custom_arguments->add_parents) && $options->propiedades->process_dato_arguments->custom_arguments->add_parents===true) {
// get_parents_recursive($section_id, $section_tipo, $skip_root=true, $is_recursion=false)
$ar_parents = component_relation_parent::get_parents_recursive($current_locator->section_id, $current_locator->section_tipo, true);
foreach ($ar_parents as $parent_locator) {
$value[] = (string)$parent_locator->section_id;
}
}
}


return $value;
}//end map_locator_to_int_recursive



/**
* MAP_LOCATOR_TO_section_tipo
* Returns map first locator to plain "terminoID" like "es_2"
Expand Down Expand Up @@ -3801,22 +3855,6 @@ public static function map_quality_to_int($options, $dato) {



/**
* MAP_LOCATOR_TO_INT
* Get only the first locator section_id if exists
* @return int | null
*/
public static function map_locator_to_int($options=null, $dato=null) {

$value = (!empty($dato) && isset($dato[0]))
? (int)$dato[0]->section_id
: null;

return $value;
}//end map_locator_to_int



/**
* MAP_LOCATOR_TO_BOOLEAN
* Transform locator value (usually a radio button)
Expand Down
20 changes: 18 additions & 2 deletions lib/dedalo/publication/server_api/v1/common/class.web_data.php
Original file line number Diff line number Diff line change
Expand Up @@ -4726,9 +4726,25 @@ function escape_string($string) {
$ar_filter[] = 'gender = '. (int)$json_data->filters->gender;
}

# stolpersteine . Data stolpersteine as int like 1 . added 03-02-2021
# stolpersteine . like ["1","2"] - operator: AND
// if (!empty($json_data->filters->stolpersteine)) {
// $ar_filter[] = 'stolpersteine = '. $json_data->filters->stolpersteine;
// }
if (!empty($json_data->filters->stolpersteine)) {
$ar_filter[] = 'stolpersteine = '. $json_data->filters->stolpersteine;
$ar_stolpersteine = $json_data->filters->stolpersteine;
$ar_term = [];
foreach ((array)$ar_stolpersteine as $key => $value) {
if ($value==='*') {
$ar_filter[] = '(`stolpersteine` IS NOT NULL AND `stolpersteine`!=\'\')';
break;
}
$ar_term[] = "`stolpersteine` LIKE '%\"".escape_string($value)."\"%'";
// $ar_term[] = "`stolpersteine` = '[\"".escape_string($value)."\"]'";
}
if (!empty($ar_term)) {
$current_filter_stolpersteine = '('.implode(' OR ', $ar_term).')';
$ar_filter[] = $current_filter_stolpersteine;
}
}

# stolpersteine_date . like 376790400 OR [376790400,396790400]
Expand Down
Loading

0 comments on commit fdd351f

Please sign in to comment.