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:
parent
ca80b5ade8
commit
e6722ac1b4
10 changed files with 13 additions and 85 deletions
|
@ -203,8 +203,7 @@ if (isset($_GET['parent_id']))
|
|||
|
||||
$navigation.= get_cat_display_name_from_id(
|
||||
$_GET['parent_id'],
|
||||
$base_url.'&parent_id=',
|
||||
false
|
||||
$base_url.'&parent_id='
|
||||
);
|
||||
}
|
||||
// +-----------------------------------------------------------------------+
|
||||
|
|
|
@ -392,8 +392,7 @@ while ($row = pwg_db_fetch_assoc($result))
|
|||
$name =
|
||||
get_cat_display_name_cache(
|
||||
$row['uppercats'],
|
||||
get_root_url().'admin.php?page=album-',
|
||||
false
|
||||
get_root_url().'admin.php?page=album-'
|
||||
);
|
||||
|
||||
if ($row['category_id'] == $storage_category_id)
|
||||
|
|
|
@ -128,7 +128,7 @@ if (pwg_db_num_rows($result) > 0)
|
|||
{
|
||||
$template->append(
|
||||
'categories_because_of_groups',
|
||||
get_cat_display_name_cache($category['uppercats'], null, false)
|
||||
get_cat_display_name_cache($category['uppercats'], null)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -296,7 +296,7 @@ if (count($categories) > 0)
|
|||
|
||||
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
|
||||
{
|
||||
|
|
|
@ -64,53 +64,6 @@ function get_elapsed_time( $start, $end )
|
|||
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 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 ' '
|
||||
$treatment = str_replace( ' ', ' ', $treatment );
|
||||
$treatment = str_replace( '-', '−', $treatment );
|
||||
// composing the string to return by adding the treated string and the
|
||||
// following HTML tag -> 'My 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( ' ', ' ', $remaining );
|
||||
$treatment = str_replace( '-', '−', $treatment );
|
||||
$return_string.= $treatment;
|
||||
|
||||
return $return_string;
|
||||
}
|
||||
|
||||
// get_extension returns the part of the string after the last "."
|
||||
function get_extension( $filename )
|
||||
{
|
||||
|
|
|
@ -250,8 +250,7 @@ function display_select_categories($categories,
|
|||
$option = strip_tags(
|
||||
get_cat_display_name_cache(
|
||||
$category['uppercats'],
|
||||
null,
|
||||
false
|
||||
null
|
||||
)
|
||||
);
|
||||
}
|
||||
|
|
|
@ -31,12 +31,9 @@
|
|||
*
|
||||
* @param array cat_informations
|
||||
* @param string url
|
||||
* @param boolean replace_space
|
||||
* @return string
|
||||
*/
|
||||
function get_cat_display_name($cat_informations,
|
||||
$url = '',
|
||||
$replace_space = false)
|
||||
function get_cat_display_name($cat_informations, $url = '')
|
||||
{
|
||||
global $conf;
|
||||
|
||||
|
@ -86,15 +83,8 @@ function get_cat_display_name($cat_informations,
|
|||
$output.= $cat['name'].'</a>';
|
||||
}
|
||||
}
|
||||
if ($replace_space)
|
||||
{
|
||||
return replace_space($output);
|
||||
}
|
||||
else
|
||||
{
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 url
|
||||
* @param boolean replace_space
|
||||
* @return string
|
||||
*/
|
||||
function get_cat_display_name_cache($uppercats,
|
||||
$url = '',
|
||||
$replace_space = false,
|
||||
$single_link = false,
|
||||
$link_class = null)
|
||||
{
|
||||
|
@ -184,15 +172,8 @@ SELECT id, name, permalink
|
|||
$output.= '</a>';
|
||||
}
|
||||
|
||||
if ($replace_space)
|
||||
{
|
||||
return replace_space($output);
|
||||
}
|
||||
else
|
||||
{
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* returns HTMLized comment contents retrieved from database
|
||||
|
@ -230,12 +211,10 @@ function render_comment_content($content)
|
|||
return $content;
|
||||
}
|
||||
|
||||
function get_cat_display_name_from_id($cat_id,
|
||||
$url = '',
|
||||
$replace_space = false)
|
||||
function get_cat_display_name_from_id($cat_id, $url = '')
|
||||
{
|
||||
$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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -259,7 +259,7 @@ SELECT
|
|||
|
||||
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
|
||||
{
|
||||
|
|
|
@ -230,7 +230,7 @@ if ( empty($page['is_external']) or !$page['is_external'] )
|
|||
$hints = array();
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -149,8 +149,7 @@ SELECT id, uppercats, global_rank
|
|||
'search_categories',
|
||||
get_cat_display_name_cache(
|
||||
$category['uppercats'],
|
||||
null, // no url on category names
|
||||
false // no blank replacement
|
||||
null // no url on category names
|
||||
)
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue