예제 #1
0
 /**
  * Search datadir for folders and generate new playlists. Videos will be shown as separate playlists. 
  * Images will be added to the playlist named after the folder they reside in. 
  *
  * @return void
  * @author  
  */
 public static function refreshPlaylist($datadir)
 {
     if (!file_exists($datadir) || !is_dir($datadir)) {
         throw new Exception('Nincs ilyen könyvtár', 1);
     }
     $playlist = array();
     if (file_exists($datadir) && is_dir($datadir)) {
         $i = 1;
         foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($datadir)) as $file => $object) {
             $screen = null;
             if (is_file($file) && count(preg_grep(sprintf("/%s/i", $object->getExtension()), self::$valid_video_extensions))) {
                 if (false !== ($movie = new \ffmpeg_movie($file))) {
                     // This is a valid and supported video file (based on file extension and on the fact that ffmpeg could open it)
                     $screen = array('duration' => ceil(($duration = $movie->getDuration()) * 1000), 'assets' => array(array('type' => 'video', 'name' => sprintf('%s (%s)', basename($file), $duration > 3600 ? gmdate('H:i:s', $duration) : gmdate('i:s', $duration)), 'filename' => $file)));
                 }
             }
             if (is_file($file) && count(preg_grep(sprintf("/%s/i", $object->getExtension()), array_keys(self::$valid_image_extensions)))) {
                 if (false !== ($d = getimagesize($file)) && in_array($d['mime'], self::$valid_image_extensions)) {
                     // This is a valid and supported image file (based on file extension and on the fact that getimagesize() could open it)
                     $screen = array('duration' => 5000, 'assets' => array(array('type' => 'image', 'dimensions' => 'auto', 'name' => sprintf('%s', basename($file)), 'filename' => $file)));
                 }
             }
             if (is_array($screen)) {
                 // The playlist key is a hash from the directory which contains the file, so everything in the same directory will
                 // belong to the same playlist
                 $key = md5(dirname($file));
                 if (!array_key_exists(sprintf('playlist_%s', $key), $playlist)) {
                     // This is a new playlist, set the default values
                     $playlist[sprintf('playlist_%s', $key)] = array('id' => $key, 'name' => substr(dirname($file), strlen($datadir) + 1) . ' könyvtár: ', 'starttime' => 0, 'endtime' => 0, 'priority' => 1000 - $i++, 'enabled' => false, 'loop' => true, 'screens' => array($screen));
                 } else {
                     // This playlist is already exists, add the new screen to it
                     $playlist[sprintf('playlist_%s', $key)]['screens'][] = $screen;
                     //						$playlist[sprintf('playlist_%s', $key)]['name'] .= ', ' . $name;
                 }
             }
         }
     }
     foreach ($playlist as $key => $pl) {
         // Sort playlist screens by filename (of the first asset)
         $playlist[$key]['screens'] = multiSort($pl['screens'], SORT_ASC, 'assets/0/filename');
         // Update the visible name of the playlists (now it's ordered correctly)
         $names = array();
         foreach ($playlist[$key]['screens'] as $screen) {
             $names[] = $screen['assets'][0]['name'];
         }
         $playlist[$key]['name'] .= implode(', ', $names);
     }
     // Sort playlists by name
     $playlist = multiSort($playlist, SORT_ASC, 'name');
     self::$data = $playlist;
     self::savePlaylist();
     return true;
 }
예제 #2
0
}
if (!empty($keyWords) && !empty($labels)) {
    foreach ($productsA as $value) {
        foreach ($productsB as $val) {
            if ($value == $val) {
                $products[] = $value;
            }
        }
    }
    $products = multiSort($products, $sort);
} else {
    if (empty($keyWords) && empty($labels)) {
        $products = getAllProducts($sort);
    } else {
        $products = $productsA + $productsB;
        $products = multiSort($products, $sort);
    }
}
//print_r($products);
$page_num = ceil(count($products) / 35);
$productsNum = count($products);
if (empty($products)) {
    $productsNum = 0;
} else {
    $productsNum = count($products);
}
$page_num = ceil($productsNum / 35);
$products = array_slice($products, ($page - 1) * 35, 35);
//print_r($products);
$smarty->assign('up', $up);
$smarty->assign('upper', $upper);