<commit_before><?php
use_helper('sfBBCode', 'SmartFormat', 'Field');

$activities = $document->getRaw('activities');
$outing_route_desc = $document->get('outing_route_desc');
$conditions = $document->get('conditions');
$conditions_levels = $document->get('conditions_levels');
$avalanche_date = $document->getRaw('avalanche_date');
$avalanche_desc = $document->get('avalanche_desc');
$weather = $document->get('weather');
$timing = $document->get('timing');
$access_comments = $document->get('access_comments');
$hut_comments = $document->get('hut_comments');

$has_outing_route_desc = !empty($outing_route_desc);
$has_conditions = !empty($conditions);
$has_weather_or_timing = (!empty($weather) || !empty($timing));
$has_access_or_hut = (!empty($access_comments) || !empty($hut_comments));
$has_avalanche_date = !empty($avalanche_date) && count($avalanche_date) && !array_intersect(array(0, 1), $avalanche_date);
$has_avalanche_desc = $has_avalanche_date && !empty($avalanche_desc);

// hide condition levels if ski, snow, ice_climbing or snowshoeing are not among outing activities
if (!array_intersect(array(1,2,5,7), $activities))
{
    $conditions_levels = NULL;
}
$has_conditions_levels = (!empty($conditions_levels) && count($conditions_levels));

$other_conditions = '';
if (!empty($associated_areas))
{
    $area_type_list = sfConfig::get('app_areas_area_types');
    unset($area_type_list[0]);
    $area_type = '';
    foreach ($area_type_list as $key => $area_type_temp)
    {
        $area_ids = array();
        foreach ($associated_areas as $area)
        {
            if ($area['area_type'] != $key)
            {
                continue;
            }
            $area_ids[] = $area['id'];
        }
        if (!empty($area_ids))
        {
            $area_type = $area_type_temp;
            break;
        }
    }
    
    if (!empty($area_ids))
    {
        use_helper('Date');
        $link_text = __('The other conditions the same day in the same ' . $area_type);
        $date = format_date($document->get('date'), 'yyyyMMdd');
        $url = "outings/conditions?areas=" . implode('-', $area_ids) . "&date=$date";
        $other_conditions = '<p class="tips">' . link_to($link_text, $url) . "</p>\n";
    }
}

if ($has_outing_route_desc || $has_conditions || $has_conditions_levels || $has_avalanche_date)
{
    $outing_route_desc_string = field_text_data_if_set($document, 'outing_route_desc', null, array('needs_translation' => $needs_translation, 'images' => $images, 'filter_image_type' => false));
    
    $condition_name = 'conditions';
    if ($has_conditions && (array_intersect($activities, array(3,4,5)) || (in_array(2, $activities) && !array_intersect($activities, array(1,6,7)))))
    {
        $condition_name = 'conditions_and_equipment';
    }
    $lang = $needs_translation ? ' lang="' . $needs_translation . '"' : '';
    $conditions_title = content_tag('div', __($condition_name), array('class' => 'section_subtitle htext',
            'id' => '_'.$condition_name, 'data-tooltip' => ''))
                        . '<div class="field_value"' . $lang . '>';
    
    if ($has_conditions_levels)
    {
        $conditions_levels_string = conditions_levels_data($conditions_levels);
    }
    
    $avalanche_title_level = 0;
    $conditions_sub_title = '';
    $avalanche_string = '';
    if ($has_avalanche_date)
    {
        $avalanche_title_level = 3;
        if ($has_conditions)
        {
            if (preg_match('{^(\s*\n|)(\#{2,6})}s', $conditions, $match))
            {
                $avalanche_title_level = strlen($matches[2]);
            }
            else
            {
                $conditions_sub_title = '<h' . $avalanche_title_level . ' id="conditions2" class="htext"><a href="#conditions2">' . __('cond short') . '</a></h' . $avalanche_title_level . '>';
            }
        }
        
        $avalanche_desc_string = '';
        if ($has_avalanche_desc)
        {
            $avalanche_desc_string .= parse_links(parse_bbcode($avalanche_desc, $images, false));
        }
        
        $avalanche_title_class = 'htext' . ($has_conditions_levels ? '' : ' hfirst');
        $avalanche_title = '<h' . $avalanche_title_level . ' id="avalanche_info" class="' . $avalanche_title_class . '"><a href="#avalanche_info">' . __('avalanche_info_title') . '</a></h' . $avalanche_title_level . '>';
        $avalanche_date_string = '<p>'
                               . c2cTools::multibyte_ucfirst(get_paginated_value_from_list($avalanche_date, 'mod_outings_avalanche_date_list'))
                               . '</p>';

        $avalanche_string = $avalanche_title
                          . $avalanche_date_string
                          . $avalanche_desc_string;
    }
    
    $conditions_string = '';<commit_msg>design champs texte conditions<commit_after><?php
use_helper('sfBBCode', 'SmartFormat', 'Field');

$activities = $document->getRaw('activities');
$outing_route_desc = $document->get('outing_route_desc');
$conditions = $document->get('conditions');
$conditions_levels = $document->get('conditions_levels');
$avalanche_date = $document->getRaw('avalanche_date');
$avalanche_desc = $document->get('avalanche_desc');
$weather = $document->get('weather');
$timing = $document->get('timing');
$access_comments = $document->get('access_comments');
$hut_comments = $document->get('hut_comments');

$has_outing_route_desc = !empty($outing_route_desc);
$has_conditions = !empty($conditions);
$has_weather_or_timing = (!empty($weather) || !empty($timing));
$has_access_or_hut = (!empty($access_comments) || !empty($hut_comments));
$has_avalanche_date = !empty($avalanche_date) && count($avalanche_date) && !array_intersect(array(0, 1), $avalanche_date);
$has_avalanche_desc = $has_avalanche_date && !empty($avalanche_desc);

// hide condition levels if ski, snow, ice_climbing or snowshoeing are not among outing activities
if (!array_intersect(array(1,2,5,7), $activities))
{
    $conditions_levels = NULL;
}
$has_conditions_levels = (!empty($conditions_levels) && count($conditions_levels));

$other_conditions = '';
if (!empty($associated_areas))
{
    $area_type_list = sfConfig::get('app_areas_area_types');
    unset($area_type_list[0]);
    $area_type = '';
    foreach ($area_type_list as $key => $area_type_temp)
    {
        $area_ids = array();
        foreach ($associated_areas as $area)
        {
            if ($area['area_type'] != $key)
            {
                continue;
            }
            $area_ids[] = $area['id'];
        }
        if (!empty($area_ids))
        {
            $area_type = $area_type_temp;
            break;
        }
    }
    
    if (!empty($area_ids))
    {
        use_helper('Date');
        $link_text = __('The other conditions the same day in the same ' . $area_type);
        $date = format_date($document->get('date'), 'yyyyMMdd');
        $url = "outings/conditions?areas=" . implode('-', $area_ids) . "&date=$date";
        $other_conditions = '<p class="tips">' . link_to($link_text, $url) . "</p>\n";
    }
}

if ($has_outing_route_desc || $has_conditions || $has_conditions_levels || $has_avalanche_date)
{
    $outing_route_desc_string = field_text_data_if_set($document, 'outing_route_desc', null, array('needs_translation' => $needs_translation, 'images' => $images, 'filter_image_type' => false));
    
    $condition_name = 'conditions';
    if ($has_conditions && (array_intersect($activities, array(3,4,5)) || (in_array(2, $activities) && !array_intersect($activities, array(1,6,7)))))
    {
        $condition_name = 'conditions_and_equipment';
    }
    $lang = $needs_translation ? ' lang="' . $needs_translation . '"' : '';
    $conditions_title = content_tag('div', __($condition_name), array('class' => 'section_subtitle htext',
            'id' => '_'.$condition_name, 'data-tooltip' => ''))
                        . '<div class="field_value"' . $lang . '>';
    
    if ($has_conditions_levels)
    {
        $conditions_levels_string = conditions_levels_data($conditions_levels);
    }
    
    $avalanche_title_level = 0;
    $conditions_sub_title = '';
    $avalanche_string = '';
    if ($has_avalanche_date)
    {
        $avalanche_title_level = 3;
        if ($has_conditions)
        {
            if (preg_match('{^(\s*\n|)(\#{2,6})}s', $conditions, $match))
            {
                $avalanche_title_level = strlen($match[2]);
            }
            else
            {
                $conditions_sub_title = '<h' . $avalanche_title_level . ' id="conditions2" class="htext hfirst"><a href="#conditions2">' . __('cond short') . '</a></h' . $avalanche_title_level . '>';
            }
        }
        
        $avalanche_desc_string = '';
        if ($has_avalanche_desc)
        {
            $avalanche_desc_string .= parse_links(parse_bbcode($avalanche_desc, $images, false));
        }
        
        $avalanche_title_class = 'htext' . ($has_conditions_levels ? '' : ' hfirst');
        $avalanche_title = '<h' . $avalanche_title_level . ' id="avalanche_info" class="' . $avalanche_title_class . '"><a href="#avalanche_info">' . __('avalanche_info_title') . '</a></h' . $avalanche_title_level . '>';
        $avalanche_date_string = '<p>'
                               . c2cTools::multibyte_ucfirst(get_paginated_value_from_list($avalanche_date, 'mod_outings_avalanche_date_list'))
                               . '</p>';

        $avalanche_string = $avalanche_title
                          . $avalanche_date_string
                          . $avalanche_desc_string;
    }
    
    $conditions_string = '';
{'fraction_non_alphanumeric': 0.16545113565326108, 'fraction_numerical': 0.004584288393415295, 'mean_word_length': 3.1608149111400086, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 65, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1363677', 'n_tokens_mistral': 3132, 'n_tokens_neox': 3065, 'n_words': 460}