Ignore:
Timestamp:
Nov 10, 2013, 5:18:55 PM (10 years ago)
Author:
mistic100
Message:

delete replace_space function, modify get_cat_display_name_* functions

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/functions.inc.php

    r25360 r25425  
    6363{
    6464  return number_format( $end - $start, 3, '.', ' ').' s';
    65 }
    66 
    67 // - The replace_space function replaces space and '-' characters
    68 //   by their HTML equivalent  &nbsb; and −
    69 // - The function does not replace characters in HTML tags
    70 // - This function was created because IE5 does not respect the
    71 //   CSS "white-space: nowrap;" property unless space and minus
    72 //   characters are replaced like this function does.
    73 // - Example :
    74 //                 <div class="foo">My friend</div>
    75 //               ( 01234567891111111111222222222233 )
    76 //               (           0123456789012345678901 )
    77 // becomes :
    78 //             <div class="foo">My&nbsp;friend</div>
    79 function replace_space( $string )
    80 {
    81   //return $string;
    82   $return_string = '';
    83   // $remaining is the rest of the string where to replace spaces characters
    84   $remaining = $string;
    85   // $start represents the position of the next '<' character
    86   // $end   represents the position of the next '>' character
    87   ; // -> 0
    88   $end   = strpos ( $remaining, '>' ); // -> 16
    89   // as long as a '<' and his friend '>' are found, we loop
    90   while ( ($start=strpos( $remaining, '<' )) !==false
    91         and ($end=strpos( $remaining, '>' )) !== false )
    92   {
    93     // $treatment is the part of the string to treat
    94     // In the first loop of our example, this variable is empty, but in the
    95     // second loop, it equals 'My friend'
    96     $treatment = substr ( $remaining, 0, $start );
    97     // Replacement of ' ' by his equivalent '&nbsp;'
    98     $treatment = str_replace( ' ', '&nbsp;', $treatment );
    99     $treatment = str_replace( '-', '&minus;', $treatment );
    100     // composing the string to return by adding the treated string and the
    101     // following HTML tag -> 'My&nbsp;friend</div>'
    102     $return_string.= $treatment.substr( $remaining, $start, $end-$start+1 );
    103     // the remaining string is deplaced to the part after the '>' of this
    104     // loop
    105     $remaining = substr ( $remaining, $end + 1, strlen( $remaining ) );
    106   }
    107   $treatment = str_replace( ' ', '&nbsp;', $remaining );
    108   $treatment = str_replace( '-', '&minus;', $treatment );
    109   $return_string.= $treatment;
    110 
    111   return $return_string;
    11265}
    11366
Note: See TracChangeset for help on using the changeset viewer.