Changeset 15


Ignore:
Timestamp:
May 21, 2003, 7:46:57 PM (21 years ago)
Author:
z0rglub
Message:

* empty log message *

Location:
trunk
Files:
2 added
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/infos_images.php

    r14 r15  
    164164  if ( is_numeric( $_GET['num'] ) and $_GET['num'] >= 0 )
    165165  {
    166     $page['start'] = floor( $_GET['num'] / $page['nb_image_page'] ) * $page['nb_image_page'];
     166    $page['start'] =
     167      floor( $_GET['num'] / $page['nb_image_page'] ) * $page['nb_image_page'];
    167168  }
    168169  // retrieving category information
  • trunk/include/functions.inc.php

    r13 r15  
    102102//   CSS "white-space: nowrap;" property unless space and minus
    103103//   characters are replaced like this function does.
     104// - Example :
     105//                 <div class="foo">My friend</div>
     106//               ( 01234567891111111111222222222233 )
     107//               (           0123456789012345678901 )
     108// becomes :
     109//             <div class="foo">My&nbsp;friend</div>
    104110function replace_space( $string )
    105111{
    106   //return $string;             
    107   $return_string = "";
     112  //return $string;
     113  $return_string = '';
     114  // $remaining is the rest of the string where to replace spaces characters
    108115  $remaining = $string;
    109                
     116  // $start represents the position of the next '<' character
     117  // $end   represents the position of the next '>' character
    110118  $start = 0;
    111119  $end = 0;
    112   $start = strpos ( $remaining, '<' );
    113   $end   = strpos ( $remaining, '>' );
     120  $start = strpos ( $remaining, '<' ); // -> 0
     121  $end   = strpos ( $remaining, '>' ); // -> 16
     122  // as long as a '<' and his friend '>' are found, we loop
    114123  while ( is_numeric( $start ) and is_numeric( $end ) )
    115124  {
     125    // $treatment is the part of the string to treat
     126    // In the first loop of our example, this variable is empty, but in the
     127    // second loop, it equals 'My friend'
    116128    $treatment = substr ( $remaining, 0, $start );
     129    // Replacement of ' ' by his equivalent '&nbsp;'
    117130    $treatment = str_replace( ' ', '&nbsp;', $treatment );
    118131    $treatment = str_replace( '-', '&minus;', $treatment );
    119     $return_string.= $treatment.substr ( $remaining, $start,
    120                                          $end - $start + 1 );
     132    // composing the string to return by adding the treated string and the
     133    // following HTML tag -> 'My&nbsp;friend</div>'
     134    $return_string.= $treatment.substr( $remaining, $start, $end-$start+1 );
     135    // the remaining string is deplaced to the part after the '>' of this
     136    // loop
    121137    $remaining = substr ( $remaining, $end + 1, strlen( $remaining ) );
    122138    $start = strpos ( $remaining, '<' );
     
    126142  $treatment = str_replace( '-', '&minus;', $treatment );
    127143  $return_string.= $treatment;
    128                
     144
    129145  return $return_string;
    130146}
Note: See TracChangeset for help on using the changeset viewer.