public static function getPresentations() { $presentations = array(); $list = \OC_FileCache::searchByMime('application', 'zip'); foreach ($list as $l) { $info = pathinfo($l); $size = \OC_Filesystem::filesize($l); $mtime = \OC_Filesystem::filemtime($l); $entry = array('url' => $l, 'name' => $info['filename'], 'size' => $size, 'mtime' => $mtime); $presentations[] = $entry; } return $presentations; }
function explore($current_dir, $sub_dirs, $num_of_results) { $return = array(); // Search for pdfs in sub directories. foreach ($sub_dirs as $dir) { $pdfs = \OC_FileCache::searchByMime('application', 'pdf', '/' . \OCP\USER::getUser() . '/files' . $current_dir . $dir . '/'); sort($pdfs); $max_count = min(count($pdfs), $num_of_results); $thumbs = array(); for ($i = $max_count - 1; $i >= 0; $i--) { if (!in_array($pdfs[$i], $thumbs)) { $thumbs[] = $pdfs[$i]; } } $return[] = array($dir, $thumbs); } return $return; }
/** * scan a folder for music * @param OC_EventSource eventSource (optional) * @return int the number of songs found */ public static function scanCollection($eventSource = null) { $music = OC_FileCache::searchByMime('audio'); $ogg = OC_FileCache::searchByMime('application', 'ogg'); $music = array_merge($music, $ogg); $eventSource->send('count', count($music)); $songs = 0; foreach ($music as $file) { self::scanFile($file); $songs++; if ($eventSource) { $eventSource->send('scanned', array('file' => $file, 'count' => $songs)); } } if ($eventSource) { $eventSource->send('done', $songs); } return $songs; }
function explore($current_dir, $sub_dirs) { $return = array(); // Search for pdfs in sub directories. foreach ($sub_dirs as $dir) { $pdfs = \OC_FileCache::searchByMime('application', 'pdf', '/' . \OCP\USER::getUser() . '/files' . $current_dir . $dir . '/'); sort($pdfs); $thumbs = array(); $count = 1; foreach ($pdfs as $pdf) { // We need only 3 pdf pages to create thumbnails for folders. if ($count <= 3) { // Store the urls in an array. $thumbs[] = $pdf; $count++; } } // Return the directory and contained pdfs(any 3). $return[] = array($dir, $thumbs); } return $return; }
if ($(elem).hasClass('title')) { $(elem).removeClass('visible'); } else { $(elem).css('margin-top', Math.floor(5-(Math.random()*10)) + 'px') .css('margin-left', Math.floor(5-(Math.random()*10))+ 'px') .css('z-index', '3'); } }); } </script> <?php include 'apps/gallery/lib/tiles.php'; $root = empty($_GET['root']) ? '/' : $_GET['root']; $images = \OC_FileCache::searchByMime('image', null, '/bartek/files' . $root); sort($images); $arr = array(); $tl = new \OC\Pictures\TilesLine(); $ts = new \OC\Pictures\TileStack(array(), ''); $previous_element = $images[0]; for ($i = 0; $i < count($images); $i++) { error_log($images[$i]); $prev_dir_arr = explode('/', $previous_element); $dir_arr = explode('/', $images[$i]); if (count($dir_arr) == 1) { $tl->addTile(new \OC\Pictures\TileSingle($images[$i])); continue; } if (strcmp($prev_dir_arr[0], $dir_arr[0]) != 0) { $tl->addTile(new \OC\Pictures\TileStack($arr, $prev_dir_arr[0]));
public static function findPaths() { $images = OC_FileCache::searchByMime('image', '', self::getScanningRoot()); $paths = array(); foreach ($images as $image) { $path = dirname($image); $path = self::getGalleryRoot() . ($path == '.' ? '' : $path); if ($path !== '/') { $path = rtrim($path, '/'); } if (array_search($path, $paths) === false) { $paths[] = $path; } // add sub path also if they don't contain images while (($path = dirname($path)) != '/') { if (array_search($path, $paths) === false) { $paths[] = $path; } } } sort($paths); return $paths; }
$song['album'] = OC_MEDIA_COLLECTION::getAlbumName($song['song_album']); OCP\JSON::encodedPrint($song); } } break; case 'play': @ob_end_clean(); $ftype = OC_Filesystem::getMimeType($arguments['path']); if (substr($ftype, 0, 5) != 'audio' and $ftype != 'application/ogg') { echo 'Not an audio file'; exit; } $songId = OC_MEDIA_COLLECTION::getSongByPath($arguments['path']); OC_MEDIA_COLLECTION::registerPlay($songId); header('Content-Type:' . $ftype); OCP\Response::enableCaching(3600 * 24); // 24 hour header('Accept-Ranges: bytes'); header('Content-Length: ' . OC_Filesystem::filesize($arguments['path'])); $mtime = OC_Filesystem::filemtime($arguments['path']); OCP\Response::setLastModifiedHeader($mtime); OC_Filesystem::readfile($arguments['path']); exit; case 'find_music': $music = OC_FileCache::searchByMime('audio'); $ogg = OC_FileCache::searchByMime('application', 'ogg'); $music = array_merge($music, $ogg); OCP\JSON::encodedPrint($music); exit; } }
?> <div id="file_action_panel"></div> <!-- Set dir value to be passed to integrate.js --> <input type="hidden" name="dir" value="<?php echo empty($_['dir']) ? '' : rtrim($_['dir'], '/'); ?> " id="dir"> </div> <div class="actions"></div> <?php // Search for pdf files in current directory. $pdfs = \OC_FileCache::searchByMime('application', 'pdf', '/' . \OCP\USER::getUser() . '/files' . $current_dir); sort($pdfs); // Construct an array, to store pdf files and directory names, in which pdf files reside. $files = array(); // Store file info in the file array. foreach ($pdfs as $pdf) { $file_info = pathinfo($pdf); $file = array(); $file['dirname'] = $file_info['dirname']; $file['basename'] = $file_info['filename']; $file['filename'] = $file_info['basename']; $file['extension'] = '.' . $file_info['extension']; $files[] = $file; } ?>
$path .= urlencode($paths[$i]) . '/'; $classess = 'crumb' . ($i == count($paths) - 1 ? ' last' : ''); echo '<div class="' . $classess . '" style="background-image:url(\'' . \OCP\image_path('core', 'breadcrumb.png') . '\')"><a href="' . \OCP\Util::linkTo('gallery', 'index.php') . '&root=' . $path . '">' . \OCP\Util::sanitizeHTML($paths[$i]) . '</a></div>'; } } ?> <!--<a href="javascript:shareGallery();"><input type="button" value="<?php echo $l->t('Share'); ?> " /></a>--><br/> </div> <div id="gallerycontent"> <?php include 'apps/gallery/lib/tiles.php'; $root = empty($_GET['root']) ? '/' : $_GET['root']; $images = \OC_FileCache::searchByMime('image', null, '/' . \OCP\USER::getUser() . '/files' . $root); sort($images); $tl = new \OC\Pictures\TilesLine(); $ts = new \OC\Pictures\TileStack(array(), ''); $previous_element = @$images[0]; $root_images = array(); $second_level_images = array(); $fallback_images = array(); // if the folder only cotains subfolders with images -> these are taken for the stack preview for ($i = 0; $i < count($images); $i++) { $prev_dir_arr = explode('/', $previous_element); $dir_arr = explode('/', $images[$i]); if (count($dir_arr) == 1) { // getting the images in this directory $root_images[] = $root . $images[$i]; } else {