Changeset 16120


Ignore:
Timestamp:
Jun 28, 2012, 2:54:07 PM (8 years ago)
Author:
mistic100
Message:

new tag : [photo=xx.yy;SQ|TH|XXS|XS|S|M|L|XL|XXL]

File:
1 edited

Legend:

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

    r16119 r16120  
    120120  $replacements[] = ($param == 'subcatify_category_description') ? '' : 'get_cat_thumb("$1")';
    121121
    122   // Balises [img=xx.yy,xx.yy,xx.yy;left|rigtht|;name|titleName|]
     122  // Balises [img=xx.yy,xx.yy,xx.yy;left|right|;name|titleName|]
    123123  //$patterns[] = '#\[img=(\d*)\.?(\d*|);?(left|right|);?(name|titleName|)\]#ie';
    124124  $patterns[] = '#\[img=([\d\s\.]*);?(left|right|);?(name|titleName|)\]#ie';
    125125  $replacements[] = ($param == 'subcatify_category_description') ? '' : 'get_img_thumb("$1", "$2", "$3")';
    126 
    127     // [random album=xx]
    128     $patterns[] = '#\[random\s+(?:album|cat)=\s*?(\d+)\s*?\]#ie';
    129     $replacements[] = 'extdesc_get_random_photo("$1")';
     126 
     127  // Balises [photo=xx.yy;SQ|TH|XXS|XS|S|M|L|XL|XXL]
     128  $patterns[] = '#\[photo=([\d\.]*);?(SQ|TH|XXS|XS|S|M|L|XL|XXL|)\]#ie';
     129  $replacements[] = ($param == 'subcatify_category_description') ? '' : 'get_photo_sized("$1", "$2")';
     130
     131  // [random album=xx]
     132  $patterns[] = '#\[random\s+(?:album|cat)=\s*?(\d+)\s*?\]#ie';
     133  $replacements[] = 'extdesc_get_random_photo("$1")';
    130134
    131135  // Balises <!--complete-->, <!--more--> et <!--up-down-->
     
    367371}
    368372
     373// Return html code for a photo
     374function get_photo_sized($elem_id, $size)
     375{
     376  global $template;
     377
     378  list($image_id, $cat_id) = array_pad(explode(".",$elem_id), 2, "");
     379 
     380  $size_map = array(
     381    'SQ' => IMG_SQUARE,
     382    'TH' => IMG_THUMB,
     383    'XXS' => IMG_XXSMALL,
     384    'XS' => IMG_XSMALL,
     385    'S' => IMG_SMALL,
     386    'M' => IMG_MEDIUM,
     387    'L' => IMG_LARGE,
     388    'XL' => IMG_XLARGE,
     389    'XXL' => IMG_XXLARGE,
     390    );
     391   
     392  if (empty($size)) $size = 'M';
     393  $deriv_type = $size_map[ strtoupper($size) ];
     394
     395  $query = 'SELECT * FROM ' . IMAGES_TABLE . ' WHERE id = '.$image_id.';';
     396  $result = pwg_query($query);
     397
     398  if ($result)
     399  {
     400    $template->set_filename('extended_description_content', 'picture_content.tpl');
     401   
     402    $picture = mysql_fetch_assoc($result);
     403   
     404    // url
     405    if (!empty($cat_id))
     406    {
     407      $url = make_picture_url(array(
     408        'image_id' => $picture['id'],
     409        'category' => array(
     410          'id' => $cat_id,
     411          'name' => '',
     412          'permalink' => '')));
     413    }
     414    else
     415    {
     416      $url = make_picture_url(array('image_id' => $picture['id']));
     417    }
     418   
     419    // image
     420    $src_image = new SrcImage($picture);
     421    $derivatives = DerivativeImage::get_all($src_image);
     422    $selected_derivative = $derivatives[$deriv_type];
     423
     424    $template->assign(array(
     425      'current' => array(
     426        'selected_derivative' => $selected_derivative,
     427        'TITLE' => $picture['name'],
     428        ),
     429      'ALT_IMG' => $picture['file'],
     430      ));
     431    if (!empty($picture['comment']))
     432    {
     433      $template-assign('COMMENT_IMG', trigger_event('render_element_description', $picture['comment']));
     434    }
     435
     436    return '<a href="'.$url.'">'.$template->parse('extended_description_content', true).'</a>';
     437  }
     438 
     439  return '';
     440}
     441
     442
    369443
    370444function extdesc_get_random_photo($category_id)
Note: See TracChangeset for help on using the changeset viewer.