Changeset 259
- Timestamp:
- 08/01/08 16:02:37 (4 months ago)
- Files:
-
- trunk/camptocamp.org/apps/frontend/lib/helper/GeoportailHelper.php (modified) (2 diffs)
- trunk/camptocamp.org/apps/frontend/modules/documents/actions/actions.class.php (modified) (1 diff)
- trunk/camptocamp.org/apps/frontend/modules/huts/templates/geoportailSuccess.php (modified) (1 diff)
- trunk/camptocamp.org/apps/frontend/modules/sites/templates/geoportailSuccess.php (modified) (1 diff)
- trunk/camptocamp.org/apps/frontend/modules/summits/templates/geoportailSuccess.php (modified) (1 diff)
- trunk/camptocamp.org/lib/model/doctrine/generated/BaseDocument.class.php (modified) (1 diff)
- trunk/camptocamp.org/plugins/sfPunBBCodeParserPlugin/lib/helper/sfBBCodeHelper.php (modified) (1 diff)
- trunk/camptocamp.org/plugins/sfPunBBCodeParserPlugin/lib/sfPunBBCodeParser.class.php (modified) (5 diffs)
- trunk/camptocamp.org/web/static/css/geoportail.css (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/camptocamp.org/apps/frontend/lib/helper/GeoportailHelper.php
r232 r259 1 1 <?php 2 use_helper('Text', 'Field', 'sfBBCode', 'SmartFormat' );2 use_helper('Text', 'Field', 'sfBBCode', 'SmartFormat', 'MyImage'); 3 3 4 4 function truncate_description($description, $route) { 5 5 $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))); 7 7 } 8 8 … … 17 17 return '<h3 class="gp_' . $module . '">' . $title . '</h3>'; 18 18 } 19 20 function 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 874 874 $this->associated_docs = Association::findAllWithBestName($id, $prefered_cultures); 875 875 876 $this->associated_images = Document::fetchAdditionalFieldsFor( 877 array_filter($this->associated_docs, array('c2cTools', 'is_image')), 878 'Image', array('filename')); 876 879 } 877 880 trunk/camptocamp.org/apps/frontend/modules/huts/templates/geoportailSuccess.php
r228 r259 9 9 10 10 echo make_gp_title($title, 'huts'); 11 $image = formate_thumbnail($associated_images); 12 if ($image): 11 13 ?> 14 <p><?php echo $image; ?></p> 15 <?php endif; ?> 12 16 13 17 <ul class="data"> trunk/camptocamp.org/apps/frontend/modules/sites/templates/geoportailSuccess.php
r228 r259 13 13 14 14 echo make_gp_title($title, 'sites'); 15 $image = formate_thumbnail($associated_images); 16 if ($image): 15 17 ?> 18 <p><?php echo $image; ?></p> 19 <?php endif; ?> 16 20 17 21 <ul class="data"> trunk/camptocamp.org/apps/frontend/modules/summits/templates/geoportailSuccess.php
r228 r259 12 12 $description = $document->get('description'); 13 13 if (!empty($description)) { 14 echo truncate_description($description, $route); 14 $description = truncate_description($description, $route); 15 } else { 16 $description = ''; 15 17 } 18 19 $image = formate_thumbnail($associated_images); 20 21 if ($description || $image): 16 22 ?> 23 <p><?php echo $image . $description; ?></p> 24 <?php endif; ?> 17 25 18 26 <h4>Itinéraires associés :</h4> trunk/camptocamp.org/lib/model/doctrine/generated/BaseDocument.class.php
r254 r259 1294 1294 "WHERE s.id = n.id AND s.geom IS NOT NULL AND n.culture = 'fr' " . 1295 1295 "ORDER BY n.name ASC"; 1296 // TODO: add filter on region 1296 1297 return sfDoctrine::connection()->standaloneQuery($sql)->fetchAll(); 1297 1298 } trunk/camptocamp.org/plugins/sfPunBBCodeParserPlugin/lib/helper/sfBBCodeHelper.php
r2 r259 7 7 return sfPunBBCodeParser::parse_message($unformatted); 8 8 } 9 10 function parse_bbcode_simple($unformatted) { 11 return sfPunBBCodeParser::parse_message_simple($unformatted); 12 } trunk/camptocamp.org/plugins/sfPunBBCodeParserPlugin/lib/sfPunBBCodeParser.class.php
r252 r259 187 187 * Truncate URL if longer than 55 characters (add http:// or ftp:// if missing) 188 188 */ 189 public static function handle_url_tag($url, $link = '' )189 public static function handle_url_tag($url, $link = '', $target = '') 190 190 { 191 191 $full_url = str_replace(array(' ', '\'', '`', '"'), array('%20', '', '', ''), $url); … … 200 200 $link = ($link == '' || $link == $url) ? ((strlen($url) > 55) ? substr($url, 0 , 39).' … '.substr($url, -10) : $url) : stripslashes($link); 201 201 202 // Check if internal or external link 202 if (!empty($target)) $target = ' target="' . $target . '"'; 203 204 // Check if internal or external link 203 205 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>'; 206 208 } 207 209 … … 242 244 * Convert BBCodes to their HTML equivalent 243 245 */ 244 public static function do_bbcode($text )246 public static function do_bbcode($text, $force_external_links = false) 245 247 { 246 248 if (strpos($text, 'quote') !== false) … … 263 265 '<em>$1</em>', 264 266 '<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\')', 267 269 'self::handle_email_tag(\'$1\')', 268 270 'self::handle_email_tag(\'$1\', \'$2\')', … … 324 326 return $text; 325 327 } 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(' ', ' ', ' '); 339 $text = str_replace($pattern, $replace, $text); 340 341 return $text; 342 } 326 343 } trunk/camptocamp.org/web/static/css/geoportail.css
r233 r259 42 42 } 43 43 44 .image { 45 float:left; 46 margin-right: 5px; 47 margin-bottom: 5px; 48 } 49 44 50 #gp_logo { 45 51 position:absolute;
