示例#1
0
 /**
  * Returns an array of MEDIAOBJECT objects for a certain collection
  *
  * @param $collection
  *		name of the collection
  * @param $filter
  *		filter on filename (defaults to none)
  */
 function getMediaListByCollection($collection, $filter = '')
 {
     global $DIR_MEDIA;
     $filelist = array();
     // 1. go through all objects and add them to the filelist
     $mediadir = $DIR_MEDIA . $collection . '/';
     // return if dir does not exist
     if (!is_dir($mediadir)) {
         return $filelist;
     }
     $dirhandle = opendir($mediadir);
     while ($filename = readdir($dirhandle)) {
         // only add files that match the filter
         if (!@is_dir($filename) && MEDIA::checkFilter($filename, $filter)) {
             array_push($filelist, new MEDIAOBJECT($collection, $filename, filemtime($mediadir . $filename)));
         }
     }
     closedir($dirhandle);
     // sort array so newer files are shown first
     usort($filelist, 'sort_media');
     return $filelist;
 }