/** * Output the different tabs into an entity sheet * * @param string $element_code The current element type represented by the code * @param integer $element_id The current element identifier to dislay tabs for * @param array $element_definition An array with the different configuration for the current element * * @return string The html code to output directly tabs */ public static function attribute_of_entity_to_tab($element_code, $element_id, $element_definition) { $attributeContentOutput = ''; /** Get the different attribute affected to the entity */ $element_atribute_list = wpshop_attributes::getElementWithAttributeAndValue($element_code, $element_id, WPSHOP_CURRENT_LOCALE, '', 'frontend'); if (is_array($element_atribute_list) && count($element_atribute_list) > 0) { foreach ($element_atribute_list[$element_id] as $attributeSetSectionName => $attributeSetContent) { $attributeToShowNumber = 0; $attributeOutput = ''; foreach ($attributeSetContent['attributes'] as $attributeId => $attributeDefinition) { /** Check the value type to check if empty or not */ if ($attributeDefinition['data_type'] == 'int') { $attributeDefinition['value'] = (int) $attributeDefinition['value']; } else { if ($attributeDefinition['data_type'] == 'decimal') { $attributeDefinition['value'] = (double) $attributeDefinition['value']; } } /** Check if the attribute is set to be displayed in frontend */ $attribute_display_state = wpshop_attributes::check_attribute_display($attributeDefinition['is_visible_in_front'], $element_definition['custom_display'], 'attribute', $attributeDefinition['code'], 'complete_sheet'); /** Output the field if the value is not null */ if ((is_array($attributeDefinition['value']) || !empty($attributeDefinition['value'])) && $attribute_display_state) { $attribute_display = wpshop_attributes::wps_attribute_values_display($attributeDefinition); $attribute_value = $attribute_display[0]; $attributeDefinition['value'] = $attribute_display[1]; $attribute_unit_list = $attribute_display[2]; /** Template parameters */ $template_part = 'product_attribute_display'; $tpl_component = array(); $tpl_component['PDT_ENTITY_CODE'] = self::currentPageCode; $tpl_component['ATTRIBUTE_CODE'] = $attributeDefinition['attribute_code']; $tpl_component['ATTRIBUTE_LABEL'] = __($attributeDefinition['frontend_label'], 'wpshop'); $tpl_component['ATTRIBUTE_VALUE'] = !is_array($attribute_value) ? stripslashes($attribute_value) : $attribute_value; $tpl_component['ATTRIBUTE_VALUE_UNIT'] = $attribute_unit_list; /** Build template */ $attributeOutput .= wpshop_display::display_template_element($template_part, $tpl_component); unset($tpl_component); $attributeToShowNumber++; } } /** Check if the attribute set section is set to be displayed in frontend */ $attribute_set_display_state = wpshop_attributes::check_attribute_display($attributeSetContent['display_on_frontend'], $element_definition['custom_display'], 'attribute_set_section', $attributeSetContent['code'], 'complete_sheet'); if (!$attribute_set_display_state) { $attributeToShowNumber = 0; $attributeOutput = ''; } $element_atribute_list[$element_id][$attributeSetSectionName]['count'] = $attributeToShowNumber; $element_atribute_list[$element_id][$attributeSetSectionName]['output'] = $attributeOutput; } /** Gestion de l'affichage */ $tab_list = $content_list = ''; foreach ($element_atribute_list[$element_id] as $attributeSetSectionName => $attributeSetContent) { if (!empty($attributeSetContent['count']) > 0) { /** Template parameters */ $template_part = 'product_attribute_tabs'; $tpl_component = array(); $tpl_component['ATTRIBUTE_SET_CODE'] = $attributeSetContent['code']; $tpl_component['ATTRIBUTE_SET_NAME'] = __($attributeSetSectionName, 'wpshop'); /** Build template */ $tpl_way_to_take = wpshop_display::check_way_for_template($template_part); if ($tpl_way_to_take[0] && !empty($tpl_way_to_take[1])) { /* Include the old way template part */ ob_start(); require wpshop_display::get_template_file($tpl_way_to_take[1]); $tab_list .= ob_get_contents(); ob_end_clean(); } else { $tab_list .= wpshop_display::display_template_element($template_part, $tpl_component); } unset($tpl_component); /** Template parameters */ $template_part = 'product_attribute_tabs_detail'; $tpl_component = array(); $tpl_component['ATTRIBUTE_SET_CODE'] = $attributeSetContent['code']; $tpl_component['ATTRIBUTE_SET_CONTENT'] = $attributeSetContent['output']; /** Build template */ $tpl_way_to_take = wpshop_display::check_way_for_template($template_part); if ($tpl_way_to_take[0] && !empty($tpl_way_to_take[1])) { /* Include the old way template part */ ob_start(); require wpshop_display::get_template_file($tpl_way_to_take[1]); $content_list .= ob_get_contents(); ob_end_clean(); } else { $content_list .= wpshop_display::display_template_element($template_part, $tpl_component); } unset($tpl_component); } } if ($tab_list != '') { /** Template parameters */ $template_part = 'product_attribute_container'; $tpl_component = array(); $tpl_component['PDT_TABS'] = apply_filters('wpshop_extra_tabs_menu_before', '') . $tab_list . apply_filters('wpshop_extra_tabs_menu_after', ''); $tpl_component['PDT_TAB_DETAIL'] = apply_filters('wpshop_extra_tabs_content_before', '') . $content_list . apply_filters('wpshop_extra_tabs_content_after', ''); /** Build template */ $tpl_way_to_take = wpshop_display::check_way_for_template($template_part); if ($tpl_way_to_take[0] && !empty($tpl_way_to_take[1])) { /* Include the old way template part */ ob_start(); require wpshop_display::get_template_file($tpl_way_to_take[1]); $attributeContentOutput = ob_get_contents(); ob_end_clean(); } else { $attributeContentOutput = wpshop_display::display_template_element($template_part, $tpl_component); } unset($tpl_component); } } return $attributeContentOutput; }