<commit_before><?php


/*
* CLASS MENU
*/
class menu extends common {


	protected $modo;

	
	public function __construct($modo) {
		$this->modo = $modo;
	}



	/**
	* GET_HTML
	*/
	public function get_html() {

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

		if(!login::is_logged()) return null;

		$user_id_logged 		= navigator::get_user_id();
		$arguments_tree			= array();	
		$arguments_tree['ul_id']= 'menu';	

		if( (bool)component_security_administrator::is_global_admin($user_id_logged) !== true ) {
			# Get array of authorized areas for current logged user
			$ar_authorized_areas 	= component_security_areas::get_ar_authorized_areas_for_user($user_id_logged, $mode_result='full');
			$arguments_tree['dato'] = $ar_authorized_areas;
				#dump($ar_authorized_areas,'ar_authorized_areas');
		}

		$html = self::get_menu_structure_html($option='create_link', $arguments_tree);
		
		if(SHOW_DEBUG===true) {
			global$TIMER;$TIMER[__METHOD__.'_'.get_called_class().'_'.$this->modo.'_'.microtime(1)]=microtime(1);
		}

		return $html;
	}



	/**
	* GET MENU STRUCTURE HTML (TREE)
	*
	* @param $option
	*	Name of method to execute as decorator o every line
	* @param $arguments_tree
	*	Vars needed for option decorator
	*/
	public static function get_menu_structure_html($option, $arguments_tree) {
		#unset($_SESSION['dedalo4']['config']['menu_structure_html']);

		#area::get_ar_ts_children_all_areas_plain();
		#dump($option,'option');
		#dump($arguments_tree,'arguments_tree');

		/**/
		# STATIC CACHE	(Only for menu - option='create_link' -)
		if ($option==='create_link') {
			$uid=(string)$option;
			if( isset($_SESSION['dedalo4']['config']['menu_structure_html'][$uid][DEDALO_APPLICATION_LANG]) ) {
				#error_log("--get_menu_structure_html is returned from session cache");
				if(SHOW_DEBUG===true) {
					# nothing to do;
					#dump($uid, '$uid');
					return $_SESSION['dedalo4']['config']['menu_structure_html'][$uid][DEDALO_APPLICATION_LANG];	
				}else{
					return $_SESSION['dedalo4']['config']['menu_structure_html'][$uid][DEDALO_APPLICATION_LANG];	
				}											
			}				
		}

		if(SHOW_DEBUG===true) {
			$start_time = microtime(1);
		}
		$ul_id = isset($arguments_tree['ul_id']) ? $arguments_tree['ul_id'] : 'menu';

		$menu_structure_html = "<!-- MENU --> <ul id=\"$ul_id\" class=\"menu_ul_{$option}\">";
		
			/*
			# INVENTARIO MENU (area_root)
				$area_root = new area_root();
				$ar_ts_children_areas = $area_root->get_ar_ts_children_areas();
					#dump($ar_ts_children_areas,'ar_ts_children_areas'," ar_ts_children_areas de area_root ");
				$menu_structure_html .= self::walk_ar_structure($ar_ts_children_areas, $arguments_tree, $option);

			# RESOURCES MENU (area_resource)
				$area_resource = new area_resource();
				$ar_ts_children_areas = $area_resource->get_ar_ts_children_areas();
					#dump($ar_ts_children_areas,'ar_ts_children_areas'," ar_ts_children_areas de area_resource ");
				$menu_structure_html .= self::walk_ar_structure($ar_ts_children_areas, $arguments_tree, $option);

			# ADMIN MENU (area_admin)
				$area_admin = new area_admin();
				$ar_ts_children_areas = $area_admin->get_ar_ts_children_areas();
					#dump($ar_ts_children_areas,'ar_ts_children_areas'," ar_ts_children_areas de area_admin ");
				$menu_structure_html .= self::walk_ar_structure($ar_ts_children_areas, $arguments_tree, $option);
			*/
			$ar_ts_children_areas = area::get_ar_ts_children_all_areas_hierarchized();
				#dump($ar_ts_children_areas,"ar_ts_children_areas");

			# BUILD MENU RECURSIVELY
			$menu_structure_html .= self::walk_ar_structure($ar_ts_children_areas, $arguments_tree, $option);

			
			# THESAURUS ADD MENU MANUAL
			$user_id_logged 			 = navigator::get_user_id();
			$logged_user_is_global_admin = (bool)component_security_administrator::is_global_admin($user_id_logged);
			
			$security = new security();
			$tesauro_permissions = security::get_security_permissions(DEDALO_TESAURO_TIPO,DEDALO_TESAURO_TIPO);				
			if ( (array_key_exists(DEDALO_TESAURO_TIPO, $ar_ts_children_areas) && $tesauro_permissions>=2) || $logged_user_is_global_admin===true) {			
				#dump($ar_ts_children_areas,$ar_ts_children_areas);
				switch (true) {
					case ($option==='create_link'):

						# TESAURO LINK IN MENU
						if(SHOW_DEBUG===true) {						
						$tesauro_html = '';
						$tesauro_html .= "<li class=\"has-sub menu_li_inactive\">";
						$tesauro_html .= "<a href=\"".DEDALO_LIB_BASE_URL."/ts/ts_list.php?t=".DEDALO_TESAURO_TIPO."&modo=tesauro_edit&type=all\">". ucfirst(label::get_label('tesauro'))." V3</a>";
							$tesauro_html .= "<ul>";
							$tesauro_html .= "<li><a href=\"".DEDALO_LIB_BASE_URL."/ts/ts_list.php?t=".DEDALO_TESAURO_TIPO."&modo=tesauro_edit&type=all\">". ucfirst(label::get_label('terminos'))."</a></li>";
							$tesauro_html .= "<li><a href=\"".DEDALO_LIB_BASE_URL."/ts/ts_list.php?t=".DEDALO_TESAURO_TIPO."&modo=modelo_edit&type=all\">". ucfirst(label::get_label('modelos'))." </a></li>";
							$tesauro_html .= "<li><a href=\"".DEDALO_ROOT_WEB."/jer/jer_list.php\">". ucfirst(label::get_label('jerarquias'))."</a></li>";
							$tesauro_html .= "</ul>";
						$tesauro_html .= "</li>";
						$menu_structure_html .= $tesauro_html;
						}	

						/*
						if(SHOW_DEBUG===true) {
							# TESAURO V4 LINK IN MENU
							$tesauro_html = '';
							$tesauro_html .= "<li class=\"has-sub menu_li_inactive\">";
							$tesauro_html .= "<a href=\"".DEDALO_LIB_BASE_URL."/main?t=".DEDALO_TESAURO_TIPO."\">". RecordObj_dd::get_termino_by_tipo(DEDALO_TESAURO_TIPO, DEDALO_DATA_LANG, true) ." V4</a>";
								$tesauro_html .= "<ul>";
								$tesauro_html .= "<li><a href=\"".DEDALO_LIB_BASE_URL."/main?t=".DEDALO_TESAURO_TIPO."\">". RecordObj_dd::get_termino_by_tipo(DEDALO_TESAURO_TIPO, DEDALO_DATA_LANG, true) ." V4</a></li>";
								$tesauro_html .= "<li><a href=\"".DEDALO_LIB_BASE_URL."/main?t=".DEDALO_TESAURO_TIPO."&model\">". RecordObj_dd::get_termino_by_tipo(DEDALO_TESAURO_TIPO, DEDALO_DATA_LANG, true) ." [M] V4</a></li>";
								$tesauro_html .= "<li><a href=\"".DEDALO_LIB_BASE_URL."/main?t=".DEDALO_HIERARCHY_SECTION_TIPO."\">". RecordObj_dd::get_termino_by_tipo(DEDALO_HIERARCHY_SECTION_TIPO, DEDALO_DATA_LANG, true) ." V4</a></li>";								
								$tesauro_html .= "</ul>";
							$tesauro_html .= "</li>";<commit_msg>Change the Thesaurus V3 menu<commit_after><?php


/*
* CLASS MENU
*/
class menu extends common {


	protected $modo;

	
	public function __construct($modo) {
		$this->modo = $modo;
	}



	/**
	* GET_HTML
	*/
	public function get_html() {

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

		if(!login::is_logged()) return null;

		$user_id_logged 		= navigator::get_user_id();
		$arguments_tree			= array();	
		$arguments_tree['ul_id']= 'menu';	

		if( (bool)component_security_administrator::is_global_admin($user_id_logged) !== true ) {
			# Get array of authorized areas for current logged user
			$ar_authorized_areas 	= component_security_areas::get_ar_authorized_areas_for_user($user_id_logged, $mode_result='full');
			$arguments_tree['dato'] = $ar_authorized_areas;
				#dump($ar_authorized_areas,'ar_authorized_areas');
		}

		$html = self::get_menu_structure_html($option='create_link', $arguments_tree);
		
		if(SHOW_DEBUG===true) {
			global$TIMER;$TIMER[__METHOD__.'_'.get_called_class().'_'.$this->modo.'_'.microtime(1)]=microtime(1);
		}

		return $html;
	}



	/**
	* GET MENU STRUCTURE HTML (TREE)
	*
	* @param $option
	*	Name of method to execute as decorator o every line
	* @param $arguments_tree
	*	Vars needed for option decorator
	*/
	public static function get_menu_structure_html($option, $arguments_tree) {
		#unset($_SESSION['dedalo4']['config']['menu_structure_html']);

		#area::get_ar_ts_children_all_areas_plain();
		#dump($option,'option');
		#dump($arguments_tree,'arguments_tree');

		/**/
		# STATIC CACHE	(Only for menu - option='create_link' -)
		if ($option==='create_link') {
			$uid=(string)$option;
			if( isset($_SESSION['dedalo4']['config']['menu_structure_html'][$uid][DEDALO_APPLICATION_LANG]) ) {
				#error_log("--get_menu_structure_html is returned from session cache");
				if(SHOW_DEBUG===true) {
					# nothing to do;
					#dump($uid, '$uid');
					return $_SESSION['dedalo4']['config']['menu_structure_html'][$uid][DEDALO_APPLICATION_LANG];	
				}else{
					return $_SESSION['dedalo4']['config']['menu_structure_html'][$uid][DEDALO_APPLICATION_LANG];	
				}											
			}				
		}

		if(SHOW_DEBUG===true) {
			$start_time = microtime(1);
		}
		$ul_id = isset($arguments_tree['ul_id']) ? $arguments_tree['ul_id'] : 'menu';

		$menu_structure_html = "<!-- MENU --> <ul id=\"$ul_id\" class=\"menu_ul_{$option}\">";
		
			/*
			# INVENTARIO MENU (area_root)
				$area_root = new area_root();
				$ar_ts_children_areas = $area_root->get_ar_ts_children_areas();
					#dump($ar_ts_children_areas,'ar_ts_children_areas'," ar_ts_children_areas de area_root ");
				$menu_structure_html .= self::walk_ar_structure($ar_ts_children_areas, $arguments_tree, $option);

			# RESOURCES MENU (area_resource)
				$area_resource = new area_resource();
				$ar_ts_children_areas = $area_resource->get_ar_ts_children_areas();
					#dump($ar_ts_children_areas,'ar_ts_children_areas'," ar_ts_children_areas de area_resource ");
				$menu_structure_html .= self::walk_ar_structure($ar_ts_children_areas, $arguments_tree, $option);

			# ADMIN MENU (area_admin)
				$area_admin = new area_admin();
				$ar_ts_children_areas = $area_admin->get_ar_ts_children_areas();
					#dump($ar_ts_children_areas,'ar_ts_children_areas'," ar_ts_children_areas de area_admin ");
				$menu_structure_html .= self::walk_ar_structure($ar_ts_children_areas, $arguments_tree, $option);
			*/
			$ar_ts_children_areas = area::get_ar_ts_children_all_areas_hierarchized();
				#dump($ar_ts_children_areas,"ar_ts_children_areas");

			# BUILD MENU RECURSIVELY
			$menu_structure_html .= self::walk_ar_structure($ar_ts_children_areas, $arguments_tree, $option);

			
			# THESAURUS ADD MENU MANUAL
			$user_id_logged 			 = navigator::get_user_id();
			$logged_user_is_global_admin = (bool)component_security_administrator::is_global_admin($user_id_logged);
			
			$security = new security();
			$tesauro_permissions = security::get_security_permissions(DEDALO_TESAURO_TIPO,DEDALO_TESAURO_TIPO);				
			if ( (array_key_exists(DEDALO_TESAURO_TIPO, $ar_ts_children_areas) && $tesauro_permissions>=2) || $logged_user_is_global_admin===true) {			
				#dump($ar_ts_children_areas,$ar_ts_children_areas);
				switch (true) {
					case ($option==='create_link'):

						# TESAURO LINK IN MENU
						if(SHOW_DEBUG===true) {						
						$tesauro_html = '';
						$tesauro_html .= "<li class=\"has-sub menu_li_inactive\">";
						$tesauro_html .= "<a href=\"".DEDALO_LIB_BASE_URL."/ts/ts_list.php?t=".DEDALO_TESAURO_TIPO."&modo=tesauro_edit&type=all\">TS V3</a>"; // ucfirst(label::get_label('tesauro'))
							$tesauro_html .= "<ul>";
							$tesauro_html .= "<li><a href=\"".DEDALO_LIB_BASE_URL."/ts/ts_list.php?t=".DEDALO_TESAURO_TIPO."&modo=tesauro_edit&type=all\">". ucfirst(label::get_label('terminos'))."</a></li>";
							$tesauro_html .= "<li><a href=\"".DEDALO_LIB_BASE_URL."/ts/ts_list.php?t=".DEDALO_TESAURO_TIPO."&modo=modelo_edit&type=all\">". ucfirst(label::get_label('modelos'))." </a></li>";
							$tesauro_html .= "<li><a href=\"".DEDALO_ROOT_WEB."/jer/jer_list.php\">". ucfirst(label::get_label('jerarquias'))."</a></li>";
							$tesauro_html .= "</ul>";
						$tesauro_html .= "</li>";
						$menu_structure_html .= $tesauro_html;
						}	

						/*
						if(SHOW_DEBUG===true) {
							# TESAURO V4 LINK IN MENU
							$tesauro_html = '';
							$tesauro_html .= "<li class=\"has-sub menu_li_inactive\">";
							$tesauro_html .= "<a href=\"".DEDALO_LIB_BASE_URL."/main?t=".DEDALO_TESAURO_TIPO."\">". RecordObj_dd::get_termino_by_tipo(DEDALO_TESAURO_TIPO, DEDALO_DATA_LANG, true) ." V4</a>";
								$tesauro_html .= "<ul>";
								$tesauro_html .= "<li><a href=\"".DEDALO_LIB_BASE_URL."/main?t=".DEDALO_TESAURO_TIPO."\">". RecordObj_dd::get_termino_by_tipo(DEDALO_TESAURO_TIPO, DEDALO_DATA_LANG, true) ." V4</a></li>";
								$tesauro_html .= "<li><a href=\"".DEDALO_LIB_BASE_URL."/main?t=".DEDALO_TESAURO_TIPO."&model\">". RecordObj_dd::get_termino_by_tipo(DEDALO_TESAURO_TIPO, DEDALO_DATA_LANG, true) ." [M] V4</a></li>";
								$tesauro_html .= "<li><a href=\"".DEDALO_LIB_BASE_URL."/main?t=".DEDALO_HIERARCHY_SECTION_TIPO."\">". RecordObj_dd::get_termino_by_tipo(DEDALO_HIERARCHY_SECTION_TIPO, DEDALO_DATA_LANG, true) ." V4</a></li>";								
								$tesauro_html .= "</ul>";
							$tesauro_html .= "</li>";
{'fraction_non_alphanumeric': 0.17240834386852086, 'fraction_numerical': 0.0022914032869785082, 'mean_word_length': 4.925561797752809, 'pattern_counts': {'":': 0, '<': 81, '<?xml version=': 0, '>': 91, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1338523', 'n_tokens_mistral': 5676, 'n_tokens_neox': 4995, 'n_words': 585}