SearchMediaService

Extends \OCA\Gallery\Service\FilesService

Searches the instance for media files which can be shown

package

OCA\Gallery\Service

Methods

Constructor

__construct(string $appName, \OCA\Gallery\Environment\Environment $environment, \OCP\ILogger $logger) 
inherited

Arguments

$appName

string

$logger

\OCP\ILogger

Returns true if there is no need to check any other sub-folder at the same depth level

abortSearch(integer $subDepth, integer $count) : boolean

Arguments

$subDepth

integer

$count

integer

Response

boolean

Adds a file to the images array

addFileToImagesArray(string $mimeType, \OCP\Files\File $file) 

Arguments

$mimeType

string

the media type of the file to add to the images array

$file

\OCP\Files\File

the file to add to the images array

Adds a folder to the albums array

addFolderToAlbumsArray(\OCP\Files\Folder $folder) 

Arguments

$folder

\OCP\Files\Folder

the folder to add to the albums array

Adds the node to the list of images if it's a file and we can generate a preview of it

addMediaFile(\OCP\Files\File|\OCP\Files\Folder $node, string $nodeType, integer $albumImageCounter) : integer

Arguments

$node

\OCP\Files\File|\OCP\Files\Folder

$nodeType

string

$albumImageCounter

integer

Response

integer

Checks if we need to look for media files in the specified folder

folderNeedsToBeSearched( $subFolders, integer $subDepth, integer $albumImageCounter) : boolean

Arguments

$subFolders

$subDepth

integer

$albumImageCounter

integer

Response

boolean

Returns an array containing information about a node

formatNodeData(string $imagePath, integer $nodeId, integer $mTime, string $etag, integer $size, boolean $sharedWithUser,  $ownerData, integer $permissions) : array
inherited

Arguments

$imagePath

string

$nodeId

integer

$mTime

integer

$etag

string

$size

integer

$sharedWithUser

boolean

$ownerData

$permissions

integer

Response

array

Returns the node if it's a folder we have access to

getAllowedSubFolder(\OCP\Files\Folder $node, string $nodeType) : array|\OCP\Files\Folder
inherited

Arguments

$node

\OCP\Files\Folder

$nodeType

string

Response

array|\OCP\Files\Folder

Returns the file matching the given ID

getFile(integer $nodeId) : \OCP\Files\Node
inherited
Throws
\OCA\Gallery\Service\NotFoundServiceException

Arguments

$nodeId

integer

ID of the resource to locate

Response

\OCP\Files\Node

Returns various information about a folder

getFolderData(\OCP\Files\Folder $node) : \OCA\Gallery\Service\array<string,int|string|boolean|\OCA\Gallery\Service\array<string,int|\OCA\Gallery\Service\string>>
inherited

Arguments

$node

\OCP\Files\Folder

Response

\OCA\Gallery\Service\array>

This returns the list of all media files which can be shown starting from the given folder

getMediaFiles(\OCP\Files\Folder $folderNode, array<mixed,string> $supportedMediaTypes, array $features) : \OCA\Gallery\Service\array<null|\OCA\Gallery\Service\array<string,string|\OCA\Gallery\Service\int>>

Arguments

$folderNode

\OCP\Files\Folder

the current album

$supportedMediaTypes

array<mixed,string>

the list of supported media types

$features

array

the list of supported features

Response

\OCA\Gallery\Service\array>

all the images we could find

Returns the node matching the given ID

getNode(integer $nodeId) : \OCP\Files\Node
inherited
Throws
\OCA\Gallery\Service\NotFoundServiceException

Arguments

$nodeId

integer

ID of the resource to locate

Response

\OCP\Files\Node

Returns various information about a node

getNodeData(\OCP\Files\Node|\OCP\Files\File|\OCP\Files\Folder $node) : \OCA\Gallery\Service\array<string,int|string|boolean|\OCA\Gallery\Service\array<string,int|\OCA\Gallery\Service\string>>
inherited

Arguments

$node

\OCP\Files\Node|\OCP\Files\File|\OCP\Files\Folder

Response

\OCA\Gallery\Service\array>

Retrieves all files and sub-folders contained in a folder

getNodes(\OCP\Files\Folder $folder, integer $subDepth) : array
inherited

If we can't find anything in the current folder, we throw an exception as there is no point in doing any more work, but if we're looking at a sub-folder, we return an empty array so that it can be simply ignored

Arguments

$folder

\OCP\Files\Folder

$subDepth

integer

Response

array

Returns the node type, either 'dir' or 'file'

getNodeType(\OCP\Files\Node $node) : string
inherited

If there is a problem, we return an empty string so that the node can be ignored

Arguments

$node

\OCP\Files\Node

Response

string

Returns what we known about the owner of a node

getOwnerData(\OCP\Files\Node $node) : null|\OCA\Gallery\Service\array<string,int|\OCA\Gallery\Service\string>
inherited

Arguments

$node

\OCP\Files\Node

Response

null|\OCA\Gallery\Service\array

Checks if we've collected enough pictures to be able to build the view

haveEnoughPictures(integer $albumImageCounter, integer $subDepth) : boolean

An album is full when we find max 4 pictures at the same level

Arguments

$albumImageCounter

integer

$subDepth

integer

Response

boolean

Determines if we can consider the node mounted locally or if it's been authorised to be scanned

isAllowed(\OCP\Files\Node $node) : boolean
inherited

Arguments

$node

\OCP\Files\Node

Response

boolean

Determines if the files are hosted locally (shared or not) and can be used by the preview system

isAllowedAndAvailable(\OCP\Files\Node $node) : boolean
inherited

isMounted() doesn't include externally hosted shares, so we need to exclude those from the non-mounted nodes

Arguments

$node

\OCP\Files\Node

Response

boolean

Determines if the node is available, as in readable

isAvailable(\OCP\Files\Node $node) : boolean
inherited
todo

Test to see by how much using file_exists slows things down

Arguments

$node

\OCP\Files\Node

Response

boolean

Determines if the node is a share which is hosted externally

isExternalShare(\OCP\Files\Node $node) : boolean
inherited

Arguments

$node

\OCP\Files\Node

Response

boolean

Determines if the user has allowed the use of external shares

isExternalShareAllowed() : boolean
inherited

Response

boolean

Returns true if the file is of a supported media type and adds it to the array of items to return

isPreviewAvailable(\OCP\Files\File $file) : boolean
todo

We could potentially check if the file is readable ($file->stat() maybe) in order to only return valid files, but this may slow down operations

Arguments

$file

\OCP\Files\File

the file to test

Response

boolean

Determines if we've reached the root folder

isRootFolder(\OCP\Files\Folder $folder, integer $level) : boolean
inherited

Arguments

$folder

\OCP\Files\Folder

$level

integer

Response

boolean

Throws an exception if this problem occurs in the current folder, otherwise just ignores the sub-folder

recoverFromGetNodesError(integer $subDepth, \Exception $exception) : array
inherited
Throws
\OCA\Gallery\Service\NotFoundServiceException

Arguments

$subDepth

integer

$exception

\Exception

Response

array

Look for media files and folders in the given folder

searchFolder(\OCP\Files\Folder $folder, integer $subDepth) : integer

Arguments

$folder

\OCP\Files\Folder

$subDepth

integer

Response

integer

Looks for pictures in sub-folders

searchSubFolders( $subFolders, integer $subDepth, integer $albumImageCounter) : integer

If we're at level 0, we need to look for pictures in sub-folders no matter what If we're at deeper levels, we only need to go further if we haven't managed to find one picture in the current folder

Arguments

$subFolders

$subDepth

integer

$albumImageCounter

integer

Response

integer

Makes extra sure that we can actually do something with the file

validateNode(\OCP\Files\Node $node) 
inherited
Throws
\OCA\Gallery\Service\NotFoundServiceException

Arguments

$node

\OCP\Files\Node

Properties

images

images : null|\OCA\Gallery\Service\array<string,string|\OCA\Gallery\Service\int>
var

Type(s)

null|\OCA\Gallery\Service\array

albums

albums : null|\OCA\Gallery\Service\array<string,string|\OCA\Gallery\Service\int>
var

Type(s)

null|\OCA\Gallery\Service\array

supportedMediaTypes

supportedMediaTypes : array<mixed,string>
var

Type(s)

array<mixed,string>

virtualRootLevel

virtualRootLevel : integer
inherited
var

Type(s)

integer

features

features : array<mixed,string>
inherited
var

Type(s)

array<mixed,string>

ignoreAlbum

ignoreAlbum : string
inherited
var

Type(s)

string

appName

appName : string
inherited
var

Type(s)

string

environment

environment : \OCA\Gallery\Environment\Environment
inherited

logger

logger : \OCP\ILogger
inherited
var

Type(s)

\OCP\ILogger