Index: trunk/include/functions.inc.php
===================================================================
--- trunk/include/functions.inc.php	(revision 13234)
+++ trunk/include/functions.inc.php	(revision 13240)
@@ -817,20 +817,4 @@
 
 
-/* Returns the PATH to the thumbnail to be displayed. If the element does not
- * have a thumbnail, the default mime image path is returned. The PATH can be
- * used in the php script, but not sent to the browser.
- * @param array element_info assoc array containing element info from db
- * at least 'path', 'tn_ext' and 'id' should be present
- */
-function get_thumbnail_path($element_info)
-{
-  $path = get_thumbnail_location($element_info);
-  if ( !url_is_remote($path) )
-  {
-    $path = PHPWG_ROOT_PATH.$path;
-  }
-  return $path;
-}
-
 /* Returns the URL of the thumbnail to be displayed. If the element does not
  * have a thumbnail, the default mime image url is returned. The URL can be
@@ -842,30 +826,4 @@
 {
   return DerivativeImage::thumb_url($element_info);
-}
-
-/* returns the relative path of the thumnail with regards to to the root
-of piwigo (not the current page!).This function is not intended to be
-called directly from code.*/
-function get_thumbnail_location($element_info)
-{
-  global $conf;
-  if ( !empty( $element_info['tn_ext'] ) )
-  {
-    $path = substr_replace(
-      get_filename_wo_extension($element_info['path']),
-      '/'.$conf['dir_thumbnail'].'/'.$conf['prefix_thumbnail'],
-      strrpos($element_info['path'],'/'),
-      1
-      );
-    $path.= '.'.$element_info['tn_ext'];
-  }
-  else
-  {
-    $path = get_themeconf('mime_icon_dir')
-        .strtolower(get_extension($element_info['path'])).'.png';
-    // plugins want another location ?
-    $path = trigger_event( 'get_thumbnail_location', $path, $element_info);
-  }
-  return $path;
 }
 
@@ -921,14 +879,17 @@
  * @return string
  */
-function l10n($key, $textdomain='messages')
+function l10n($key)
 {
   global $lang, $conf;
 
-  if ($conf['debug_l10n'] and !isset($lang[$key]) and !empty($key))
-  {
-    trigger_error('[l10n] language key "'.$key.'" is not defined', E_USER_WARNING);
-  }
-
-  return isset($lang[$key]) ? $lang[$key] : $key;
+	if ( ($val=@$lang[$key]) == null)
+	{
+		if ($conf['debug_l10n'] and !isset($lang[$key]) and !empty($key))
+		{
+			trigger_error('[l10n] language key "'.$key.'" is not defined', E_USER_WARNING);
+		}
+		$val = $key;
+	}
+  return $val;
 }
 
Index: trunk/include/functions_category.inc.php
===================================================================
--- trunk/include/functions_category.inc.php	(revision 13234)
+++ trunk/include/functions_category.inc.php	(revision 13240)
@@ -389,10 +389,5 @@
 function rank_compare($a, $b)
 {
-  if ($a['rank'] == $b['rank'])
-  {
-    return 0;
-  }
-
-  return ($a['rank'] < $b['rank']) ? -1 : 1;
+  return $a['rank'] - $b['rank'];
 }
 
Index: trunk/include/functions_html.inc.php
===================================================================
--- trunk/include/functions_html.inc.php	(revision 13234)
+++ trunk/include/functions_html.inc.php	(revision 13240)
@@ -295,15 +295,15 @@
 function tag_alpha_compare($a, $b)
 {
-  global $page;
+  global $cache;
 
   foreach (array($a, $b) as $tag)
   {
-    if (!isset($page[__FUNCTION__.'_cache'][ $tag['name'] ]))
-    {
-      $page[__FUNCTION__.'_cache'][ $tag['name'] ] = strtolower(str2url($tag['name']));
-    }
-  }
-
-  return strcmp($page[__FUNCTION__.'_cache'][ $a['name'] ], $page[__FUNCTION__.'_cache'][ $b['name'] ]);
+    if (!isset($cache[__FUNCTION__][ $tag['name'] ]))
+    {
+      $cache[__FUNCTION__][ $tag['name'] ] = strtolower(str2url($tag['name']));
+    }
+  }
+
+  return strcmp($cache[__FUNCTION__][ $a['name'] ], $cache[__FUNCTION__][ $b['name'] ]);
 }
 
Index: trunk/include/functions_url.inc.php
===================================================================
--- trunk/include/functions_url.inc.php	(revision 13234)
+++ trunk/include/functions_url.inc.php	(revision 13240)
@@ -31,20 +31,13 @@
 {
   global $page;
-  if ( isset($page['root_path']) )
-  {
-    $root_url = $page['root_path'];
-  }
-  else
+  if ( ($root_url = @$page['root_path']) == null )
   {// TODO - add HERE the possibility to call PWG functions from external scripts
     $root_url = PHPWG_ROOT_PATH;
-  }
-  if ( strncmp($root_url, './', 2) != 0 )
-  {
-    return $root_url;
-  }
-  else
-  {
-    return (string)substr($root_url, 2);
-  }
+		if ( strncmp($root_url, './', 2) == 0 )
+		{
+			return substr($root_url, 2);
+		}
+  }
+	return $root_url;
 }
 
@@ -308,26 +301,29 @@
   global $conf;
   $section_string = '';
-
-  $section_of = array(
-    'category' => 'categories',
-    'tags'     => 'tags',
-    'list'     => 'list',
-    'search'   => 'search',
-    );
-
-  foreach ($section_of as $param => $section)
-  {
-    if (isset($params[$param]))
-    {
-      $params['section'] = $section;
-    }
-  }
-
-  if (!isset($params['section']))
-  {
-    $params['section'] = 'none';
-  }
-
-  switch($params['section'])
+	$section = @$params['section'];
+	if (!isset($section))
+	{
+		$section_of = array(
+			'category' => 'categories',
+			'tags'     => 'tags',
+			'list'     => 'list',
+			'search'   => 'search',
+			);
+
+		foreach ($section_of as $param => $s)
+		{
+			if (isset($params[$param]))
+			{
+				$section = $s;
+			}
+		}
+
+		if (!isset($section))
+		{
+			$section = 'none';
+		}
+	}
+
+  switch($section)
   {
     case 'categories' :
@@ -421,5 +417,5 @@
     default :
     {
-      $section_string.= '/'.$params['section'];
+      $section_string.= '/'.$section;
     }
   }
Index: trunk/include/functions_user.inc.php
===================================================================
--- trunk/include/functions_user.inc.php	(revision 13234)
+++ trunk/include/functions_user.inc.php	(revision 13240)
@@ -804,27 +804,4 @@
     list($user_id) = pwg_db_fetch_row($result);
     return $user_id;
-  }
-}
-
-/**
- * search an available feed_id
- *
- * @return string feed identifier
- */
-function find_available_feed_id()
-{
-  while (true)
-  {
-    $key = generate_key(50);
-    $query = '
-SELECT COUNT(*)
-  FROM '.USER_FEED_TABLE.'
-  WHERE id = \''.$key.'\'
-;';
-    list($count) = pwg_db_fetch_row(pwg_query($query));
-    if (0 == $count)
-    {
-      return $key;
-    }
   }
 }
Index: trunk/include/section_init.inc.php
===================================================================
--- trunk/include/section_init.inc.php	(revision 13234)
+++ trunk/include/section_init.inc.php	(revision 13240)
@@ -65,6 +65,10 @@
   // the $_GET keys are not protected in include/common.inc.php, only the values
   $rewritten = pwg_db_real_escape_string($rewritten);
-
   $page['root_path'] = PHPWG_ROOT_PATH;
+}
+
+if ( strncmp($page['root_path'], './', 2) == 0 )
+{
+	$page['root_path'] = substr($page['root_path'], 2);
 }
 
Index: trunk/include/template.class.php
===================================================================
--- trunk/include/template.class.php	(revision 13234)
+++ trunk/include/template.class.php	(revision 13240)
@@ -684,5 +684,5 @@
     else
     {
-      $ret = embellish_url(get_root_url().$script->path);
+      $ret = get_root_url().$script->path;
       if ($script->version!==false)
       {
@@ -692,5 +692,5 @@
     // trigger the event for eventual use of a cdn
     $ret = trigger_event('combined_script', $ret, $script);
-    return $ret;
+    return embellish_url($ret);
   }
 
