Changeset 277 for branches/release-1_3


Ignore:
Timestamp:
Jan 13, 2004, 11:36:56 PM (20 years ago)
Author:
z0rglub
Message:

Adding functions to retrieve all files from a directory into an array :

  • get_picture_files : returns an array with all picture files according to $confpicture_ext
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/release-1_3/admin/include/functions.php

    r276 r277  
    5454  return false;
    5555}
    56        
     56
     57/**
     58 * returns an array with all picture files according to $conf['picture_ext']
     59 *
     60 * @param string $dir
     61 * @return array
     62 */
     63function get_picture_files( $dir )
     64{
     65  global $conf;
     66
     67  $pictures = array();
     68  if ( $opendir = opendir( $dir ) )
     69  {
     70    while ( $file = readdir( $opendir ) )
     71    {
     72      if ( in_array( get_extension( $file ), $conf['picture_ext'] ) )
     73      {
     74        array_push( $pictures, $file );
     75      }
     76    }
     77  }
     78  return $pictures;
     79}
     80
     81/**
     82 * returns an array with all thumbnails according to $conf['picture_ext']
     83 * and $conf['prefix_thumbnail']
     84 *
     85 * @param string $dir
     86 * @return array
     87 */
     88function get_thumb_files( $dir )
     89{
     90  global $conf;
     91
     92  $prefix_length = strlen( $conf['prefix_thumbnail'] );
     93 
     94  $thumbnails = array();
     95  if ( $opendir = @opendir( $dir ) )
     96  {
     97    while ( $file = readdir( $opendir ) )
     98    {
     99      if ( in_array( get_extension( $file ), $conf['picture_ext'] )
     100           and substr($file,0,$prefix_length) == $conf['prefix_thumbnail'] )
     101      {
     102        array_push( $thumbnails, $file );
     103      }
     104    }
     105  }
     106  return $thumbnails;
     107}
    57108
    58109function TN_exists( $dir, $file )
Note: See TracChangeset for help on using the changeset viewer.