Changeset 13240


Ignore:
Timestamp:
Feb 18, 2012, 9:46:46 PM (12 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
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin.php

    r13077 r13240  
    246246        'site_update',  // ?only POST
    247247        'cat_list',     // delete cat
    248         'album',        // delete cat; public/private; lock/unlock, permissions
    249248        'cat_move',     // ?only POST
    250249        'cat_options',  // ?only POST; public/private; lock/unlock
    251         'photo',
    252250        'picture_modify', // ?only POST; associate/dissociate
    253251        'user_perm',
     
    258256    or ( !empty($_POST) and in_array($page['page'],
    259257        array(
     258                                        'photo',
     259                                        'album',        // public/private; lock/unlock, permissions
    260260          'batch_manager',  // associate/dissociate; delete; set level
    261261          'user_list',    // group assoc; user level
  • trunk/admin/comments.php

    r13079 r13240  
    127127        'id'=>$row['image_id'],
    128128        'path'=>$row['path'],
    129         'tn_ext'=>@$row['tn_ext']
    130129        )
    131130     );
  • trunk/admin/derivatives.php

    r13035 r13240  
    5353      continue;
    5454
    55     $v = intval($pderivative['w']);
    56     if ($v<=0 || $v<=$prev_w)
    57     {
    58       $errors[$type]['w'] = '>'.$prev_w;
    59     }
    60     $v = intval($pderivative['h']);
    61     if ($v<=0 || $v<=$prev_h)
    62     {
    63       $errors[$type]['h'] = '>'.$prev_h;
    64     }
     55                if ($type==IMG_THUMB)
     56                {
     57                        $w = intval($pderivative['w']);
     58                        if ($w<=0)
     59                        {
     60                                $errors[$type]['w'] = '>0';
     61                        }
     62                        $h = intval($pderivative['h']);
     63                        if ($h<=0)
     64                        {
     65                                $errors[$type]['h'] = '>0';
     66                        }
     67                        if (max($w,$h) <= $prev_w)
     68                        {
     69                                $errors[$type]['w'] = $errors[$type]['h'] = '>'.$prev_w;
     70                        }
     71                }
     72                else
     73                {
     74                        $v = intval($pderivative['w']);
     75                        if ($v<=0 || $v<=$prev_w)
     76                        {
     77                                $errors[$type]['w'] = '>'.$prev_w;
     78                        }
     79                        $v = intval($pderivative['h']);
     80                        if ($v<=0 || $v<=$prev_h)
     81                        {
     82                                $errors[$type]['h'] = '>'.$prev_h;
     83                        }
     84                }
    6585    $v = intval($pderivative['crop']);
    6686    if ($v<0 || $v>100)
  • 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
  • trunk/notification.php

    r12922 r13240  
    2828define('PHPWG_ROOT_PATH','./');
    2929include_once( PHPWG_ROOT_PATH.'include/common.inc.php' );
     30
     31/**
     32 * search an available feed_id
     33 *
     34 * @return string feed identifier
     35 */
     36function find_available_feed_id()
     37{
     38  while (true)
     39  {
     40    $key = generate_key(50);
     41    $query = '
     42SELECT COUNT(*)
     43  FROM '.USER_FEED_TABLE.'
     44  WHERE id = \''.$key.'\'
     45;';
     46    list($count) = pwg_db_fetch_row(pwg_query($query));
     47    if (0 == $count)
     48    {
     49      return $key;
     50    }
     51  }
     52}
    3053
    3154// +-----------------------------------------------------------------------+
  • trunk/themes/default/theme.css

    r13167 r13240  
    295295        -webkit-border-radius: 4px; /* Safari webkit project */
    296296}
    297 .thumbnails .wrap2 A,
    298 .thumbnails LABEL {
     297.thumbnails .wrap2 A {
    299298        display: block;
    300299        border-bottom: 0;
Note: See TracChangeset for help on using the changeset viewer.