delete replace_space function, modify get_cat_display_name_* functions

git-svn-id: http://piwigo.org/svn/trunk@25425 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
mistic100 2013-11-10 16:18:55 +00:00
parent ca80b5ade8
commit e6722ac1b4
10 changed files with 13 additions and 85 deletions

View file

@ -203,8 +203,7 @@ if (isset($_GET['parent_id']))
$navigation.= get_cat_display_name_from_id( $navigation.= get_cat_display_name_from_id(
$_GET['parent_id'], $_GET['parent_id'],
$base_url.'&parent_id=', $base_url.'&parent_id='
false
); );
} }
// +-----------------------------------------------------------------------+ // +-----------------------------------------------------------------------+

View file

@ -392,8 +392,7 @@ while ($row = pwg_db_fetch_assoc($result))
$name = $name =
get_cat_display_name_cache( get_cat_display_name_cache(
$row['uppercats'], $row['uppercats'],
get_root_url().'admin.php?page=album-', get_root_url().'admin.php?page=album-'
false
); );
if ($row['category_id'] == $storage_category_id) if ($row['category_id'] == $storage_category_id)

View file

@ -128,7 +128,7 @@ if (pwg_db_num_rows($result) > 0)
{ {
$template->append( $template->append(
'categories_because_of_groups', 'categories_because_of_groups',
get_cat_display_name_cache($category['uppercats'], null, false) get_cat_display_name_cache($category['uppercats'], null)
); );
} }
} }

View file

@ -296,7 +296,7 @@ if (count($categories) > 0)
if ($page['section']=='recent_cats') if ($page['section']=='recent_cats')
{ {
$name = get_cat_display_name_cache($category['uppercats'], null, false); $name = get_cat_display_name_cache($category['uppercats'], null);
} }
else else
{ {

View file

@ -64,53 +64,6 @@ function get_elapsed_time( $start, $end )
return number_format( $end - $start, 3, '.', ' ').' s'; return number_format( $end - $start, 3, '.', ' ').' s';
} }
// - The replace_space function replaces space and '-' characters
// by their HTML equivalent &nbsb; and −
// - The function does not replace characters in HTML tags
// - This function was created because IE5 does not respect the
// CSS "white-space: nowrap;" property unless space and minus
// characters are replaced like this function does.
// - Example :
// <div class="foo">My friend</div>
// ( 01234567891111111111222222222233 )
// ( 0123456789012345678901 )
// becomes :
// <div class="foo">My&nbsp;friend</div>
function replace_space( $string )
{
//return $string;
$return_string = '';
// $remaining is the rest of the string where to replace spaces characters
$remaining = $string;
// $start represents the position of the next '<' character
// $end represents the position of the next '>' character
; // -> 0
$end = strpos ( $remaining, '>' ); // -> 16
// as long as a '<' and his friend '>' are found, we loop
while ( ($start=strpos( $remaining, '<' )) !==false
and ($end=strpos( $remaining, '>' )) !== false )
{
// $treatment is the part of the string to treat
// In the first loop of our example, this variable is empty, but in the
// second loop, it equals 'My friend'
$treatment = substr ( $remaining, 0, $start );
// Replacement of ' ' by his equivalent '&nbsp;'
$treatment = str_replace( ' ', '&nbsp;', $treatment );
$treatment = str_replace( '-', '&minus;', $treatment );
// composing the string to return by adding the treated string and the
// following HTML tag -> 'My&nbsp;friend</div>'
$return_string.= $treatment.substr( $remaining, $start, $end-$start+1 );
// the remaining string is deplaced to the part after the '>' of this
// loop
$remaining = substr ( $remaining, $end + 1, strlen( $remaining ) );
}
$treatment = str_replace( ' ', '&nbsp;', $remaining );
$treatment = str_replace( '-', '&minus;', $treatment );
$return_string.= $treatment;
return $return_string;
}
// get_extension returns the part of the string after the last "." // get_extension returns the part of the string after the last "."
function get_extension( $filename ) function get_extension( $filename )
{ {

View file

@ -250,8 +250,7 @@ function display_select_categories($categories,
$option = strip_tags( $option = strip_tags(
get_cat_display_name_cache( get_cat_display_name_cache(
$category['uppercats'], $category['uppercats'],
null, null
false
) )
); );
} }

View file

@ -31,12 +31,9 @@
* *
* @param array cat_informations * @param array cat_informations
* @param string url * @param string url
* @param boolean replace_space
* @return string * @return string
*/ */
function get_cat_display_name($cat_informations, function get_cat_display_name($cat_informations, $url = '')
$url = '',
$replace_space = false)
{ {
global $conf; global $conf;
@ -86,15 +83,8 @@ function get_cat_display_name($cat_informations,
$output.= $cat['name'].'</a>'; $output.= $cat['name'].'</a>';
} }
} }
if ($replace_space)
{
return replace_space($output);
}
else
{
return $output; return $output;
} }
}
/** /**
* returns the list of categories as a HTML string, with cache of names * returns the list of categories as a HTML string, with cache of names
@ -106,12 +96,10 @@ function get_cat_display_name($cat_informations,
* *
* @param string uppercats * @param string uppercats
* @param string url * @param string url
* @param boolean replace_space
* @return string * @return string
*/ */
function get_cat_display_name_cache($uppercats, function get_cat_display_name_cache($uppercats,
$url = '', $url = '',
$replace_space = false,
$single_link = false, $single_link = false,
$link_class = null) $link_class = null)
{ {
@ -184,15 +172,8 @@ SELECT id, name, permalink
$output.= '</a>'; $output.= '</a>';
} }
if ($replace_space)
{
return replace_space($output);
}
else
{
return $output; return $output;
} }
}
/** /**
* returns HTMLized comment contents retrieved from database * returns HTMLized comment contents retrieved from database
@ -230,12 +211,10 @@ function render_comment_content($content)
return $content; return $content;
} }
function get_cat_display_name_from_id($cat_id, function get_cat_display_name_from_id($cat_id, $url = '')
$url = '',
$replace_space = false)
{ {
$cat_info = get_cat_info($cat_id); $cat_info = get_cat_info($cat_id);
return get_cat_display_name($cat_info['upper_names'], $url, $replace_space); return get_cat_display_name($cat_info['upper_names'], $url);
} }
/** /**

View file

@ -259,7 +259,7 @@ SELECT
if ($params['fullname']) if ($params['fullname'])
{ {
$row['name'] = strip_tags(get_cat_display_name_cache($row['uppercats'], null, false)); $row['name'] = strip_tags(get_cat_display_name_cache($row['uppercats'], null));
} }
else else
{ {

View file

@ -230,7 +230,7 @@ if ( empty($page['is_external']) or !$page['is_external'] )
$hints = array(); $hints = array();
foreach ( $cats as $cat ) foreach ( $cats as $cat )
{ {
$hints[] = get_cat_display_name( array($cat), '', false ); $hints[] = get_cat_display_name( array($cat), '' );
} }
$template->assign( 'category_search_results', $hints); $template->assign( 'category_search_results', $hints);
} }

View file

@ -149,8 +149,7 @@ SELECT id, uppercats, global_rank
'search_categories', 'search_categories',
get_cat_display_name_cache( get_cat_display_name_cache(
$category['uppercats'], $category['uppercats'],
null, // no url on category names null // no url on category names
false // no blank replacement
) )
); );
} }