Ignore:
Timestamp:
12/04/12 16:16:01 (7 years ago)
Author:
mistic100
Message:

improve display with different sizes, allow [random] on the whole gallery and add FandF

Location:
extensions/ExtendedDescription
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • extensions/ExtendedDescription/main.inc.php

    r19159 r19282  
    137137 
    138138  // Balises [img=xx.yy,xx.yy,xx.yy;left|right|;name|titleName|] 
    139   //$patterns[] = '#\[img=(\d*)\.?(\d*|);?(left|right|);?(name|titleName|)\]#ie'; 
    140139  $patterns[] = '#\[img=([\d\s\.,]*);?(left|right|);?(name|titleName|)\]#ie'; 
    141140  $replacements[] = ($param == 'subcatify_category_description') ? '' : 'get_img_thumb("$1", "$2", "$3")'; 
    142141   
    143142  // Balises [photo id=xx album=yy size=SQ|TH|XXS|XS|S|M|L|XL|XXL html=yes|no link=yes|no] 
    144   // $patterns[] = '#\[photo(?:(?:\s+(id)=(\d+))|(?:\s+(album)=(\d+))|(?:\s+(size)=(SQ|TH|XXS|XS|S|M|L|XL|XXL))|(?:\s+(html)=(yes|no))|(?:\s+(link)=(yes|no))){1,5}\s*\]#ie'; //10 
    145143  $patterns[] = '#\[photo ([^\]]+)\]#ie'; 
    146144  $replacements[] = ($param == 'subcatify_category_description') ? '' : 'get_photo_sized("$1")'; 
    147145 
    148146  // Balises [random album=xx size=SQ|TH|XXS|XS|S|M|L|XL|XXL html=yes|no link=yes|no] 
    149   // $patterns[] = '#\[random(?:(?:\s+(album|cat)=(\d+))|(?:\s+(size)=(SQ|TH|XXS|XS|S|M|L|XL|XXL))|(?:\s+(html)=(yes|no))|(?:\s+(link)=(yes|no))){1,4}\s*\]#ie'; //8 
    150   $patterns[] = '#\[random ([^\]]+)\]#ie'; 
     147  $patterns[] = '#\[random([^\]]*)\]#ie'; 
    151148  $replacements[] = ($param == 'subcatify_category_description') ? '' : 'extdesc_get_random_photo("$1")'; 
    152149   
    153150  // Balises [slider album=xx nb_images=yy random=yes|no list=aa,bb,cc size=SQ|TH|XXS|XS|S|M|L|XL|XXL speed=z title=yes|no effect=... arrows=yes|no control=yes|no elastic=yes|no] 
    154   // $patterns[] = '#\[slider(?:(?:\s+(album)=(\d+))|(?:\s+(nb_images)=(\d+))|(?:\s+(random)=(yes|no))|(?:\s+(list)=([\d,]+))|(?:\s+(size)=(SQ|TH|XXS|XS|S|M|L|XL|XXL))|(?:\s+(speed)=(\d+))|(?:\s+(title)=(yes|no))|(?:\s+(effect)=([a-zA-Z]+))|(?:\s+(arrows)=(yes|no))|(?:\s+(control)=(yes|no))|(?:\s+(elastic)=(yes|no))){1,11}\s*\]#ie'; //22 
    155151  $patterns[] = '#\[slider ([^\]]+)\]#ie'; 
    156152  $replacements[] = ($param == 'subcatify_category_description') ? '' : 'get_slider("$1")'; 
     
    490486 * Return html code for a random photo 
    491487 * 
    492  * @int    album: select picture from this album 
     488 * @int    album: select picture from this album (default: all) 
    493489 * @string size:  picture size                   (default: M) 
    494490 * @string html:  return complete html structure (default: yes) 
     
    508504   
    509505  // check album id 
    510   if (empty($params['album'])) 
    511   { 
    512     if (empty($params['cat'])) return 'missing album id'; 
     506  if ( empty($params['album']) and !empty($params['cat']) ) 
     507  { 
    513508    $params['album'] = $params['cat']; 
    514509  } 
     
    516511  // get picture id 
    517512  $query = ' 
    518 SELECT id 
     513SELECT id, category_id 
    519514  FROM '.IMAGES_TABLE.' 
    520515    JOIN '.IMAGE_CATEGORY_TABLE.' ON image_id = id 
    521   WHERE category_id = '.$params['album'].' 
     516  WHERE  
     517    '.(empty($params['album']) ? '1=1': 'category_id = '.$params['album']); 
     518     
     519  $query.= ' '.get_sql_condition_FandF(array( 
     520                  'forbidden_categories' => 'category_id', 
     521                  'visible_categories' => 'category_id', 
     522                  'visible_images' => 'id' 
     523                  ), 
     524                'AND' 
     525                ); 
     526   
     527  $query.= ' 
    522528  ORDER BY '.DB_RANDOM_FUNCTION.'() 
    523529  LIMIT 1 
     
    527533  if (pwg_db_num_rows($result)) 
    528534  { 
    529     list($img_id) = pwg_db_fetch_row($result); 
    530     return get_photo_sized('id='.$img_id.' album='.$params['album'].' size='.$params['size'].' html='.$params['html'].' link='.$params['link']); 
     535    list($params['id'], $params['album']) = pwg_db_fetch_row($result); 
     536    return get_photo_sized($params); 
    531537  } 
    532538 
     
    549555 * @string arrows:    display navigation arrows         (default: yes) 
    550556 * @string control:   display navigation bar            (default: yes) 
    551  * @string elastic:   adapt slider size to each picture (default: no) 
     557 * @string elastic:   adapt slider size to each picture (default: yes) 
    552558 */ 
    553559function get_slider($param) 
     
    566572    'arrows' =>    array('yes|no', 'yes'), 
    567573    'control' =>   array('yes|no', 'yes'), 
    568     'elastic' =>   array('yes|no', 'no'), 
     574    'elastic' =>   array('yes|no', 'yes'), 
    569575    ); 
    570576     
     
    577583   
    578584  // parameters 
    579   $params['arrows'] = $params['arrows']==='no' ? 'false' : 'true'; 
    580   $params['control'] = $params['control']==='no' ? 'false' : 'true'; 
     585  $params['arrows'] = $params['arrows']==='yes' ? 'true' : 'false'; 
     586  $params['control'] = $params['control']==='yes' ? 'true' : 'false'; 
    581587  $params['elastic'] = $params['elastic']==='yes' ? true : false; 
    582588  $params['title'] = $params['title']==='yes' ? true : false; 
     589  $params['random'] = $params['random']==='yes' ? true : false; 
    583590   
    584591  // pictures from album... 
    585592  if (!empty($params['album'])) 
    586593  { 
    587     // parameters 
    588     $params['random'] = $params['random']==='yes' ? true : false; 
    589      
    590594    // get image order inside category 
    591595    if ($params['random']) 
     
    689693function parse_parameters($param, $default_params) 
    690694{ 
     695  if (is_array($param)) 
     696  { 
     697    return $param; 
     698  } 
     699   
    691700  $params = array(); 
    692701   
  • extensions/ExtendedDescription/template/slider.tpl

    r17349 r19282  
    2424{/footer_script} 
    2525 
    26 {if not $elastic_size} 
    27 {assign var=slider_min_h value=$img_size.h} 
     26{if $elastic_size} 
     27{assign var=slider_full_height value=0} 
     28{else} 
     29{assign var=slider_full_height value=$img_size.h} 
    2830{/if} 
     31{assign var=slider_full_width value=0} 
    2932 
    30 <div class="slider-wrapper theme-default" style="width:{$img_size.w}px;{if $elastic_size}height:{math equation='x+y' x=$img_size.h y=40}px;{/if}"> 
    31   <div id="slider{$slider_id}" class="nivoSlider" style="width:{$img_size.w}px;{if $elastic_size}height:{$img_size.h}px;{/if}"> 
    32   {foreach from=$slider_content item=thumbnail}{strip} 
     33<div class="slider-wrapper theme-default"> 
     34  <div id="slider{$slider_id}" class="nivoSlider"> 
     35  {foreach from=$slider_content item=thumbnail name=slider}{strip} 
    3336    {assign var=derivative value=$pwg->derivative($derivative_params, $thumbnail.src_image)} 
    3437    {if !$derivative->is_cached()} 
     
    3942    <img {if $derivative->is_cached()}src="{$derivative->get_url()}"{else}src="" data-src="{$derivative->get_url()}"{/if} alt="{$thumbnail.TN_ALT}" {$derivative->get_size_htm()} {if $show_title}title="<a href='{$thumbnail.URL}'>{$thumbnail.NAME|replace:'"':"'"}</a>"{/if}> 
    4043     
    41     {if not $elastic_size} 
    4244    {assign var=derivative_size value=$derivative->get_size()} 
    43     {math assign=slider_min_h equation="min(x,y)" x=$slider_min_h y=$derivative_size[1]} 
    44     {/if} 
    45   {/strip}{/foreach} 
     45    {math assign=slider_full_width equation="max(x,y)" x=$slider_full_width y=$derivative_size[0]} 
     46  {if $elastic_size} 
     47    {math assign=slider_full_height equation="max(x,y)" x=$slider_full_height y=$derivative_size[1]} 
     48  {else} 
     49    {math assign=slider_full_height equation="min(x,y)" x=$slider_full_height y=$derivative_size[1]} 
     50  {/if} 
     51  {if $smarty.foreach.slider.first} 
     52    {assign var=slider_init_width value=$derivative_size[0]} 
     53    {assign var=slider_init_height value=$derivative_size[1]} 
     54  {/if} 
     55   
     56  {/strip} 
     57  {/foreach} 
    4658  </div> 
    4759</div> 
    4860 
    49 {if not $elastic_size} 
    5061{footer_script} 
     62$("#slider{$slider_id}").parent(".slider-wrapper").css({ldelim} 
     63  height: {$slider_full_height}{if $controlNav=='true'}+40{/if}, 
     64  width: {$slider_full_width} 
     65}); 
    5166$("#slider{$slider_id}").css({ldelim} 
    52   height: {$slider_min_h} 
     67  height: {if $elastic_size}{$slider_init_height}{else}{$slider_full_height}{/if}, 
     68  width: {$slider_init_width} 
    5369}); 
    5470{/footer_script} 
    55 {/if} 
Note: See TracChangeset for help on using the changeset viewer.