Beispiel #1
0
 /**
  * @medium
  */
 function testSearch()
 {
     $storage1 = $this->getTestStorage();
     $storage2 = $this->getTestStorage();
     $storage3 = $this->getTestStorage();
     \OC\Files\Filesystem::mount($storage1, array(), '/');
     \OC\Files\Filesystem::mount($storage2, array(), '/substorage');
     \OC\Files\Filesystem::mount($storage3, array(), '/folder/anotherstorage');
     $rootView = new \OC\Files\View('');
     $results = $rootView->search('foo');
     $this->assertEquals(6, count($results));
     $paths = array();
     foreach ($results as $result) {
         $this->assertEquals($result['path'], \OC\Files\Filesystem::normalizePath($result['path']));
         $paths[] = $result['path'];
     }
     $this->assertContains('/foo.txt', $paths);
     $this->assertContains('/foo.png', $paths);
     $this->assertContains('/substorage/foo.txt', $paths);
     $this->assertContains('/substorage/foo.png', $paths);
     $this->assertContains('/folder/anotherstorage/foo.txt', $paths);
     $this->assertContains('/folder/anotherstorage/foo.png', $paths);
     $folderView = new \OC\Files\View('/folder');
     $results = $folderView->search('bar');
     $this->assertEquals(2, count($results));
     $paths = array();
     foreach ($results as $result) {
         $paths[] = $result['path'];
     }
     $this->assertContains('/anotherstorage/folder/bar.txt', $paths);
     $this->assertContains('/bar.txt', $paths);
     $results = $folderView->search('foo');
     $this->assertEquals(2, count($results));
     $paths = array();
     foreach ($results as $result) {
         $paths[] = $result['path'];
     }
     $this->assertContains('/anotherstorage/foo.txt', $paths);
     $this->assertContains('/anotherstorage/foo.png', $paths);
     $this->assertEquals(6, count($rootView->searchByMime('text')));
     $this->assertEquals(3, count($folderView->searchByMime('text')));
 }
Beispiel #2
0
    if (is_array($linkItem) && isset($linkItem['uid_owner'])) {
        // seems to be a valid share
        $type = $linkItem['item_type'];
        $fileSource = $linkItem['file_source'];
        $shareOwner = $linkItem['uid_owner'];
        $path = null;
        $rootLinkItem = \OCP\Share::resolveReShare($linkItem);
        $fileOwner = $rootLinkItem['uid_owner'];
        // Setup FS with owner
        OCP\JSON::checkUserExists($fileOwner);
        OC_Util::tearDownFS();
        OC_Util::setupFS($fileOwner);
        // The token defines the target directory (security reasons)
        $path = \OC\Files\Filesystem::getPath($linkItem['file_source']);
        $view = new \OC\Files\View(\OC\Files\Filesystem::getView()->getAbsolutePath($path));
        $images = $view->searchByMime('image');
        $result = array();
        foreach ($images as $image) {
            $result[] = $token . $image['path'];
        }
        OCP\JSON::setContentTypeHeader();
        echo json_encode(array('images' => $result, 'users' => array(), 'displayNames' => array()));
        exit;
    }
}
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('gallery');
$images = \OCP\Files::searchByMime('image');
$user = \OCP\User::getUser();
$users = array();
$result = array();
Beispiel #3
0
 public function create($albumPath, $square = false)
 {
     $albumView = new \OC\Files\View($this->view->getRoot() . $albumPath);
     $images = $albumView->searchByMime('image', 10);
     $count = min(count($images), 10);
     $thumbnail = imagecreatetruecolor($count * 200, 200);
     for ($i = 0; $i < $count; $i++) {
         $thumb = new Thumbnail($albumPath . $images[$i]['path'], $this->user, true);
         $image = $thumb->get();
         if ($image && $image->valid()) {
             imagecopy($thumbnail, $image->resource(), $i * 200, 0, 0, 0, 200, 200);
             $image->destroy();
         }
     }
     imagepng($thumbnail, $this->path);
     imagedestroy($thumbnail);
 }
Beispiel #4
0
$user = \OC_User::getUser();
foreach ($images as &$image) {
    $image['path'] = $user . $image['path'];
}
$shared = array();
$sharedSources = OCP\Share::getItemsSharedWith('gallery');
$users = array();
foreach ($sharedSources as $sharedSource) {
    $owner = $sharedSource['uid_owner'];
    if (array_search($owner, $users) === false) {
        $users[] = $owner;
    }
    \OC\Files\Filesystem::initMountPoints($owner);
    $ownerView = new \OC\Files\View('/' . $owner . '/files');
    $path = $ownerView->getPath($sharedSource['item_source']);
    if ($path) {
        $shareName = basename($path);
        $shareView = new \OC\Files\View('/' . $owner . '/files' . $path);
        $sharedImages = $shareView->searchByMime('image');
        foreach ($sharedImages as $sharedImage) {
            $sharedImage['path'] = $owner . '/' . $sharedSource['item_source'] . '/' . $shareName . $sharedImage['path'];
            $images[] = $sharedImage;
        }
    }
}
$displayNames = array();
foreach ($users as $user) {
    $displayNames[$user] = \OCP\User::getDisplayName($user);
}
OCP\JSON::setContentTypeHeader();
echo json_encode(array('images' => $images, 'users' => $users, 'displayNames' => $displayNames));
	<div id="file_action_panel"></div>
	<!-- Set dir value to be passed to integrate.js -->
	<input type="hidden" name="dir" value="<?php 
p(empty($_['dir']) ? '' : rtrim($_['dir'], '/'));
?>
" id="dir">

</div>

<div class="actions"></div>

<?php 
// Search for pdf files in current directory.
$view = new \OC\Files\View('/' . \OCP\USER::getUser() . '/files' . $current_dir);
$pdfs = $view->searchByMime('application/pdf');
sort($pdfs);
// Cleans the eBooks table of files that have been deleted from the files app.
if ($current_dir == '/') {
    check_consistency_with_database($current_dir, $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'];