Changeset 13240 for trunk/include


Ignore:
Timestamp:
Feb 18, 2012, 9:46:46 PM (13 years ago)
Author:
rvelices
Message:
  • multisize thumb longest side can be smaller than the square size
  • remove unused css, shorten/optimize php called very often (at least theoretically should be faster)
Location:
trunk/include
Files:
7 edited

Legend:

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

    r13234 r13240  
    817817
    818818
    819 /* Returns the PATH to the thumbnail to be displayed. If the element does not
    820  * have a thumbnail, the default mime image path is returned. The PATH can be
    821  * used in the php script, but not sent to the browser.
    822  * @param array element_info assoc array containing element info from db
    823  * at least 'path', 'tn_ext' and 'id' should be present
    824  */
    825 function get_thumbnail_path($element_info)
    826 {
    827   $path = get_thumbnail_location($element_info);
    828   if ( !url_is_remote($path) )
    829   {
    830     $path = PHPWG_ROOT_PATH.$path;
    831   }
    832   return $path;
    833 }
    834 
    835819/* Returns the URL of the thumbnail to be displayed. If the element does not
    836820 * have a thumbnail, the default mime image url is returned. The URL can be
     
    842826{
    843827  return DerivativeImage::thumb_url($element_info);
    844 }
    845 
    846 /* returns the relative path of the thumnail with regards to to the root
    847 of piwigo (not the current page!).This function is not intended to be
    848 called directly from code.*/
    849 function get_thumbnail_location($element_info)
    850 {
    851   global $conf;
    852   if ( !empty( $element_info['tn_ext'] ) )
    853   {
    854     $path = substr_replace(
    855       get_filename_wo_extension($element_info['path']),
    856       '/'.$conf['dir_thumbnail'].'/'.$conf['prefix_thumbnail'],
    857       strrpos($element_info['path'],'/'),
    858       1
    859       );
    860     $path.= '.'.$element_info['tn_ext'];
    861   }
    862   else
    863   {
    864     $path = get_themeconf('mime_icon_dir')
    865         .strtolower(get_extension($element_info['path'])).'.png';
    866     // plugins want another location ?
    867     $path = trigger_event( 'get_thumbnail_location', $path, $element_info);
    868   }
    869   return $path;
    870828}
    871829
     
    921879 * @return string
    922880 */
    923 function l10n($key, $textdomain='messages')
     881function l10n($key)
    924882{
    925883  global $lang, $conf;
    926884
    927   if ($conf['debug_l10n'] and !isset($lang[$key]) and !empty($key))
    928   {
    929     trigger_error('[l10n] language key "'.$key.'" is not defined', E_USER_WARNING);
    930   }
    931 
    932   return isset($lang[$key]) ? $lang[$key] : $key;
     885        if ( ($val=@$lang[$key]) == null)
     886        {
     887                if ($conf['debug_l10n'] and !isset($lang[$key]) and !empty($key))
     888                {
     889                        trigger_error('[l10n] language key "'.$key.'" is not defined', E_USER_WARNING);
     890                }
     891                $val = $key;
     892        }
     893  return $val;
    933894}
    934895
  • trunk/include/functions_category.inc.php

    r13074 r13240  
    389389function rank_compare($a, $b)
    390390{
    391   if ($a['rank'] == $b['rank'])
    392   {
    393     return 0;
    394   }
    395 
    396   return ($a['rank'] < $b['rank']) ? -1 : 1;
     391  return $a['rank'] - $b['rank'];
    397392}
    398393
  • trunk/include/functions_html.inc.php

    r12920 r13240  
    295295function tag_alpha_compare($a, $b)
    296296{
    297   global $page;
     297  global $cache;
    298298
    299299  foreach (array($a, $b) as $tag)
    300300  {
    301     if (!isset($page[__FUNCTION__.'_cache'][ $tag['name'] ]))
    302     {
    303       $page[__FUNCTION__.'_cache'][ $tag['name'] ] = strtolower(str2url($tag['name']));
    304     }
    305   }
    306 
    307   return strcmp($page[__FUNCTION__.'_cache'][ $a['name'] ], $page[__FUNCTION__.'_cache'][ $b['name'] ]);
     301    if (!isset($cache[__FUNCTION__][ $tag['name'] ]))
     302    {
     303      $cache[__FUNCTION__][ $tag['name'] ] = strtolower(str2url($tag['name']));
     304    }
     305  }
     306
     307  return strcmp($cache[__FUNCTION__][ $a['name'] ], $cache[__FUNCTION__][ $b['name'] ]);
    308308}
    309309
  • trunk/include/functions_url.inc.php

    r12922 r13240  
    3131{
    3232  global $page;
    33   if ( isset($page['root_path']) )
    34   {
    35     $root_url = $page['root_path'];
    36   }
    37   else
     33  if ( ($root_url = @$page['root_path']) == null )
    3834  {// TODO - add HERE the possibility to call PWG functions from external scripts
    3935    $root_url = PHPWG_ROOT_PATH;
    40   }
    41   if ( strncmp($root_url, './', 2) != 0 )
    42   {
    43     return $root_url;
    44   }
    45   else
    46   {
    47     return (string)substr($root_url, 2);
    48   }
     36                if ( strncmp($root_url, './', 2) == 0 )
     37                {
     38                        return substr($root_url, 2);
     39                }
     40  }
     41        return $root_url;
    4942}
    5043
     
    308301  global $conf;
    309302  $section_string = '';
    310 
    311   $section_of = array(
    312     'category' => 'categories',
    313     'tags'     => 'tags',
    314     'list'     => 'list',
    315     'search'   => 'search',
    316     );
    317 
    318   foreach ($section_of as $param => $section)
    319   {
    320     if (isset($params[$param]))
    321     {
    322       $params['section'] = $section;
    323     }
    324   }
    325 
    326   if (!isset($params['section']))
    327   {
    328     $params['section'] = 'none';
    329   }
    330 
    331   switch($params['section'])
     303        $section = @$params['section'];
     304        if (!isset($section))
     305        {
     306                $section_of = array(
     307                        'category' => 'categories',
     308                        'tags'     => 'tags',
     309                        'list'     => 'list',
     310                        'search'   => 'search',
     311                        );
     312
     313                foreach ($section_of as $param => $s)
     314                {
     315                        if (isset($params[$param]))
     316                        {
     317                                $section = $s;
     318                        }
     319                }
     320
     321                if (!isset($section))
     322                {
     323                        $section = 'none';
     324                }
     325        }
     326
     327  switch($section)
    332328  {
    333329    case 'categories' :
     
    421417    default :
    422418    {
    423       $section_string.= '/'.$params['section'];
     419      $section_string.= '/'.$section;
    424420    }
    425421  }
  • trunk/include/functions_user.inc.php

    r13074 r13240  
    804804    list($user_id) = pwg_db_fetch_row($result);
    805805    return $user_id;
    806   }
    807 }
    808 
    809 /**
    810  * search an available feed_id
    811  *
    812  * @return string feed identifier
    813  */
    814 function find_available_feed_id()
    815 {
    816   while (true)
    817   {
    818     $key = generate_key(50);
    819     $query = '
    820 SELECT COUNT(*)
    821   FROM '.USER_FEED_TABLE.'
    822   WHERE id = \''.$key.'\'
    823 ;';
    824     list($count) = pwg_db_fetch_row(pwg_query($query));
    825     if (0 == $count)
    826     {
    827       return $key;
    828     }
    829806  }
    830807}
  • trunk/include/section_init.inc.php

    r12922 r13240  
    6565  // the $_GET keys are not protected in include/common.inc.php, only the values
    6666  $rewritten = pwg_db_real_escape_string($rewritten);
    67 
    6867  $page['root_path'] = PHPWG_ROOT_PATH;
     68}
     69
     70if ( strncmp($page['root_path'], './', 2) == 0 )
     71{
     72        $page['root_path'] = substr($page['root_path'], 2);
    6973}
    7074
  • trunk/include/template.class.php

    r13170 r13240  
    684684    else
    685685    {
    686       $ret = embellish_url(get_root_url().$script->path);
     686      $ret = get_root_url().$script->path;
    687687      if ($script->version!==false)
    688688      {
     
    692692    // trigger the event for eventual use of a cdn
    693693    $ret = trigger_event('combined_script', $ret, $script);
    694     return $ret;
     694    return embellish_url($ret);
    695695  }
    696696
Note: See TracChangeset for help on using the changeset viewer.