Changeset 259

Show
Ignore:
Timestamp:
08/01/08 16:02:37 (4 months ago)
Author:
alex
Message:

improved geoportail pages presentation (texts formatting, linked images)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/camptocamp.org/apps/frontend/lib/helper/GeoportailHelper.php

    r232 r259  
    11<?php 
    2 use_helper('Text', 'Field', 'sfBBCode', 'SmartFormat'); 
     2use_helper('Text', 'Field', 'sfBBCode', 'SmartFormat', 'MyImage'); 
    33 
    44function truncate_description($description, $route) { 
    55    $more = '... <span class="more_text">' . link_to('[Lire la suite]', $route) . '</span>'; 
    6     return '<p>' . parse_links(parse_bbcode(truncate_text($description, 500, $more))) . '</p>'
     6    return parse_links(parse_bbcode_simple(truncate_text($description, 500, $more)))
    77} 
    88 
     
    1717    return '<h3 class="gp_' . $module . '">' . $title . '</h3>'; 
    1818} 
     19 
     20function formate_thumbnail($images) { 
     21    if (count($images) == 0) return ''; 
     22     
     23    // take first image available 
     24    $image = $images[0]; 
     25    $caption = $image['name']; 
     26 
     27    return '<div class="image">' . 
     28           image_tag(image_url($image['filename'], 'small'), 
     29                     array('alt' => $caption, 'title' => $caption)) . 
     30           '</div>'; 
     31} 
  • trunk/camptocamp.org/apps/frontend/modules/documents/actions/actions.class.php

    r228 r259  
    874874        $this->associated_docs = Association::findAllWithBestName($id, $prefered_cultures); 
    875875 
     876        $this->associated_images = Document::fetchAdditionalFieldsFor( 
     877                                       array_filter($this->associated_docs, array('c2cTools', 'is_image')),  
     878                                       'Image', array('filename')); 
    876879    } 
    877880 
  • trunk/camptocamp.org/apps/frontend/modules/huts/templates/geoportailSuccess.php

    r228 r259  
    99 
    1010echo make_gp_title($title, 'huts'); 
     11$image = formate_thumbnail($associated_images); 
     12if ($image): 
    1113?> 
     14<p><?php echo $image; ?></p> 
     15<?php endif; ?> 
    1216 
    1317<ul class="data"> 
  • trunk/camptocamp.org/apps/frontend/modules/sites/templates/geoportailSuccess.php

    r228 r259  
    1313 
    1414echo make_gp_title($title, 'sites'); 
     15$image = formate_thumbnail($associated_images); 
     16if ($image): 
    1517?> 
     18<p><?php echo $image; ?></p> 
     19<?php endif; ?> 
    1620 
    1721<ul class="data"> 
  • trunk/camptocamp.org/apps/frontend/modules/summits/templates/geoportailSuccess.php

    r228 r259  
    1212$description = $document->get('description'); 
    1313if (!empty($description)) { 
    14     echo truncate_description($description, $route); 
     14    $description = truncate_description($description, $route); 
     15} else {   
     16    $description = ''; 
    1517} 
     18 
     19$image = formate_thumbnail($associated_images); 
     20 
     21if ($description || $image): 
    1622?> 
     23<p><?php echo $image . $description; ?></p> 
     24<?php endif; ?> 
    1725 
    1826<h4>Itinéraires associés :</h4> 
  • trunk/camptocamp.org/lib/model/doctrine/generated/BaseDocument.class.php

    r254 r259  
    12941294               "WHERE s.id = n.id AND s.geom IS NOT NULL AND n.culture = 'fr' " . 
    12951295               "ORDER BY n.name ASC"; 
     1296        // TODO: add filter on region 
    12961297        return sfDoctrine::connection()->standaloneQuery($sql)->fetchAll(); 
    12971298    } 
  • trunk/camptocamp.org/plugins/sfPunBBCodeParserPlugin/lib/helper/sfBBCodeHelper.php

    r2 r259  
    77    return sfPunBBCodeParser::parse_message($unformatted); 
    88} 
     9 
     10function parse_bbcode_simple($unformatted) { 
     11    return sfPunBBCodeParser::parse_message_simple($unformatted); 
     12} 
  • trunk/camptocamp.org/plugins/sfPunBBCodeParserPlugin/lib/sfPunBBCodeParser.class.php

    r252 r259  
    187187     * Truncate URL if longer than 55 characters (add http:// or ftp:// if missing) 
    188188     */ 
    189     public static function handle_url_tag($url, $link = ''
     189    public static function handle_url_tag($url, $link = '', $target = ''
    190190    { 
    191191        $full_url = str_replace(array(' ', '\'', '`', '"'), array('%20', '', '', ''), $url); 
     
    200200        $link = ($link == '' || $link == $url) ? ((strlen($url) > 55) ? substr($url, 0 , 39).' &hellip; '.substr($url, -10) : $url) : stripslashes($link); 
    201201 
    202         // Check if internal or external link 
     202        if (!empty($target)) $target = ' target="' . $target . '"'; 
     203 
     204            // Check if internal or external link 
    203205        if (preg_match('#^https?://'.$_SERVER['SERVER_NAME'].'#', $full_url)) 
    204             return '<a href="'.$full_url.'">'.$link.'</a>'; 
    205         return '<a class="external_link" href="'.$full_url.'">'.$link.'</a>'; 
     206            return '<a href="' . $full_url . '"' . $target . '>' . $link . '</a>'; 
     207        return '<a class="external_link" href="' . $full_url . '"' . $target . '>' . $link . '</a>'; 
    206208    } 
    207209     
     
    242244     * Convert BBCodes to their HTML equivalent 
    243245     */ 
    244     public static function do_bbcode($text
     246    public static function do_bbcode($text, $force_external_links = false
    245247    { 
    246248        if (strpos($text, 'quote') !== false) 
     
    263265                                         '<em>$1</em>', 
    264266                                         '<span style="text-decoration: underline;">$1</span>', 
    265                                          'self::handle_url_tag(\'$1\')', 
    266                                          'self::handle_url_tag(\'$1\', \'$2\')', 
     267                                         $force_external_links ? 'self::handle_url_tag(\'$1\', \'\', \'_blank\')' : 'self::handle_url_tag(\'$1\')', 
     268                                         $force_external_links ? 'self::handle_url_tag(\'$1\', \'$2\', \'_blank\')' : 'self::handle_url_tag(\'$1\', \'$2\')', 
    267269                                         'self::handle_email_tag(\'$1\')', 
    268270                                         'self::handle_email_tag(\'$1\', \'$2\')', 
     
    324326        return $text; 
    325327    } 
     328 
     329    public static function parse_message_simple($text) 
     330    { 
     331        $text = self::do_bbcode($text, true); 
     332     
     333        // remove embedded images  
     334        $text = preg_replace('#\[img\](.*)\[/img\]#e', '', $text); 
     335     
     336        // Deal with newlines, tabs and multiple spaces 
     337        $pattern = array( "\t", '       ', '  '); 
     338        $replace = array('&nbsp; &nbsp; ', '&nbsp; ', ' &nbsp;'); 
     339        $text = str_replace($pattern, $replace, $text); 
     340     
     341        return $text; 
     342    } 
    326343} 
  • trunk/camptocamp.org/web/static/css/geoportail.css

    r233 r259  
    4242} 
    4343 
     44.image { 
     45 float:left; 
     46 margin-right: 5px; 
     47 margin-bottom: 5px; 
     48} 
     49 
    4450#gp_logo { 
    4551 position:absolute;