Changeset 1612 for trunk/picture.php


Ignore:
Timestamp:
Nov 17, 2006, 5:26:10 AM (17 years ago)
Author:
rvelices
Message:
  • plugins can have full control over the path/url of the element/image/

thumbnail/high (it is possible now to have secure images, on the fly
watermarking, mod download and media integrator plugins working together in
any combination and without touching PWG core)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/picture.php

    r1596 r1612  
    2929include_once(PHPWG_ROOT_PATH.'include/common.inc.php');
    3030include(PHPWG_ROOT_PATH.'include/section_init.inc.php');
     31include_once(PHPWG_ROOT_PATH.'include/functions_picture.inc.php');
    3132
    3233// Check Access and exit when user status is not ok
     
    311312  }
    312313
    313   $cat_directory = dirname($row['path']);
    314   $file_wo_ext = get_filename_wo_extension($row['file']);
    315 
    316314  // ------ build element_path and element_url
    317   $picture[$i]['element_url'] = $row['path'];
    318   if ( ! url_is_remote($row['path']) )
    319   {
    320     $picture[$i]['element_url'] = get_root_url().$row['path'];
    321   }
     315  $picture[$i]['element_path'] = get_element_path($picture[$i]);
     316  $picture[$i]['element_url'] = get_element_url($picture[$i]);
    322317
    323318  // ------ build image_path and image_url
    324   if ($picture[$i]['is_picture'])
    325   {
    326     $picture[$i]['image_path'] = $row['path'];
    327     // if we are working on the "current" element, we search if there is a
    328     // high quality picture
    329     if ($i == 'current')
     319  if ($i=='current' or $i=='next')
     320  {
     321    $picture[$i]['image_path'] = get_image_path( $picture[$i] );
     322    $picture[$i]['image_url'] = get_image_url( $picture[$i] );
     323  }
     324
     325  if ($i=='current')
     326  {
     327    if ( $picture[$i]['is_picture'] )
    330328    {
    331       if (($row['has_high'] == 'true') and ($user['enabled_high'] == 'true'))
     329      if ( $user['enabled_high']=='true' )
    332330      {
    333         $url_high=$cat_directory.'/pwg_high/'.$row['file'];
    334          $picture[$i]['high_url'] = $picture[$i]['high_path'] = $url_high;
    335         if ( ! url_is_remote($picture[$i]['high_path']) )
     331        $hi_url=get_high_url($picture[$i]);
     332        if ( !empty($hi_url) )
    336333        {
    337           $picture[$i]['high_url'] = get_root_url().$picture[$i]['high_path'];
     334          $picture[$i]['high_url'] = $hi_url;
     335          $picture[$i]['download_url'] = get_download_url('h',$picture[$i]);
    338336        }
    339337      }
    340338    }
     339    else
     340    { // not a pic - need download link
     341      $picture[$i]['download_url'] = get_download_url('e',$picture[$i]);
     342    }
     343  }
     344
     345  $picture[$i]['thumbnail'] = get_thumbnail_url($row);
     346
     347  if ( !empty( $row['name'] ) )
     348  {
     349    $picture[$i]['name'] = $row['name'];
    341350  }
    342351  else
    343   {// not a picture
    344     if (isset($row['representative_ext']) and $row['representative_ext']!='')
    345     {
    346       $picture[$i]['image_path'] =
    347         $cat_directory.'/pwg_representative/'
    348         .$file_wo_ext.'.'.$row['representative_ext'];
    349     }
    350     else
    351     {
    352       $picture[$i]['image_path'] =
    353         get_themeconf('mime_icon_dir')
    354         .strtolower(get_extension($row['file'])).'.png';
    355     }
    356   }
    357 
    358   $picture[$i]['image_url'] = $picture[$i]['image_path'];
    359   if ( ! url_is_remote($picture[$i]['image_path']) )
    360   {
    361     $picture[$i]['image_url'] = get_root_url().$picture[$i]['image_path'];
    362   }
    363 
    364   if (!$picture[$i]['is_picture'])
    365   {// if picture is not a file, we need the download link
    366     $picture[$i]['download_url'] = $picture[$i]['element_url'];
    367   }
    368   else
    369   {// if picture is a file with high, we put the download link
    370     if ( isset($picture[$i]['high_path']) )
    371     {
    372       $picture[$i]['download_url'] = get_root_url().'action.php?dwn='
    373         .$picture[$i]['high_path'];
    374     }
    375   }
    376 
    377   $picture[$i]['thumbnail'] = get_thumbnail_url($row);
    378 
    379   if ( !empty( $row['name'] ) )
    380   {
    381     $picture[$i]['name'] = $row['name'];
    382   }
    383   else
    384   {
     352  {
     353    $file_wo_ext = get_filename_wo_extension($row['file']);
    385354    $picture[$i]['name'] = str_replace('_', ' ', $file_wo_ext);
    386355  }
     
    427396    );
    428397}
    429 
    430 // now give an opportunity to the filters to alter element_url,
    431 // image_url, high_url and download_url
    432 $picture = trigger_event('picture_navigation', $picture);
    433398
    434399$url_admin =
Note: See TracChangeset for help on using the changeset viewer.