ConfigService

Extends \OCA\Gallery\Service\FilesService

Finds configurations files and returns a configuration array

Checks the current and parent folders for configuration files and to see if we're allowed to look for media file Supports explicit inheritance

package

OCA\Gallery\Service

Methods

Constructor

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

Arguments

$appName

string

$logger

\OCP\ILogger

Adds the SVG media type if it's not already there

addSvgSupport(array<mixed,string> $supportedMimes, boolean $nativeSvgSupport) : array<mixed,string>

If it's enabled, but doesn't work, an exception will be raised when trying to generate a preview. If it's disabled, we support it via the browser's native support

Arguments

$supportedMimes

array<mixed,string>

$nativeSvgSupport

boolean

Response

array<mixed,string>

Builds the error message to send back when there is an error

buildErrorMessage(\OCA\Gallery\Config\ConfigException $exception, \OCP\Files\Folder $folder) : \OCA\Gallery\Service\array<array<string,string>,bool>
fixme

Missing translation

Arguments

$folder

\OCP\Files\Folder

the current folder

Response

\OCA\Gallery\Service\array,bool>

Returns a parsed configuration if one was found in the current folder or generates an error message to send back

buildFolderConfig(\OCP\Files\Folder $folder, string $configName, array $collectedConfig, integer $level) : array

Arguments

$folder

\OCP\Files\Folder

the current folder

$configName

string

name of the configuration file

$collectedConfig

array

the configuration collected so far

$level

integer

the starting level is 0 and we add 1 each time we visit a parent folder

Response

array

Returns an album configuration array

collectConfig(\OCP\Files\Folder $folder, string $ignoreAlbum, string $configName, integer $level, array $configSoFar = array()) : array

Goes through all the parent folders until either we're told the album is private or we've reached the root folder

Arguments

$folder

\OCP\Files\Folder

the current folder

$ignoreAlbum

string

name of the file which blacklists folders

$configName

string

name of the configuration file

$level

integer

the starting level is 0 and we add 1 each time we visit a parent folder

$configSoFar

array

the configuration collected so far

Response

array

<null|array,bool>

Determines if we have a configuration file to work with

configExists(\OCP\Files\Folder $rootFolder) : boolean

Arguments

$rootFolder

\OCP\Files\Folder

the virtual root folder

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 configuration of the currently selected folder

getConfig(\OCP\Files\Folder $folderNode, array $features) : array|null
  • information (description, copyright)
    • sorting (date, name, inheritance)
    • design (colour)
    • if the album should be ignored
Throws
\OCA\Gallery\Service\ForbiddenServiceException

Arguments

$folderNode

\OCP\Files\Folder

the current folder

$features

array

the list of features retrieved fro the configuration file

Response

array|null

Returns a list of supported features

getFeaturesList() : array<mixed,string>

Response

array<mixed,string>

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>

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

Looks for an album configuration in the parent folder

getParentConfig(\OCP\Files\Folder $folder, string $privacyChecker, string $configName, integer $level, array $collectedConfig) : \OCA\Gallery\Service\array<null|\OCA\Gallery\Service\array,bool>

We will look up to the virtual root of a shared folder, for privacy reasons

Arguments

$folder

\OCP\Files\Folder

the current folder

$privacyChecker

string

name of the file which blacklists folders

$configName

string

name of the configuration file

$level

integer

the starting level is 0 and we add 1 each time we visit a parent folder

$collectedConfig

array

the configuration collected so far

Response

\OCA\Gallery\Service\array

This builds and returns a list of all supported media types

getSupportedMediaTypes(boolean $extraMediaTypes, boolean $nativeSvgSupport) : array<mixed,string>
todo

Native SVG could be disabled via admin settings

Arguments

$extraMediaTypes

boolean

$nativeSvgSupport

boolean

Response

array<mixed,string>

all supported media types

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 passed mime type is supported

isMimeSupported(string $mimeType = '*') : boolean

In case of a failure, we just return that the media type is not supported

Arguments

$mimeType

string

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

Throws an exception if the media type of the file is not part of what the app allows

validateMimeType( $mimeType) 
Throws
\OCA\Gallery\Service\ForbiddenServiceException

Arguments

$mimeType

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

Removes links if they were collected outside of the virtual root

validatesInfoConfig(array $albumConfig) : array

This is for shared folders which have a virtual root

Arguments

$albumConfig

array

Response

array

Properties

configName

configName : string
var

Type(s)

string

<string,bool>

completionStatus : array
var

<string,bool>

Type(s)

array

configParser

configParser : \OCA\Gallery\Config\ConfigParser

previewManager

previewManager : \OCA\Gallery\Preview\Preview

baseMimeTypes

baseMimeTypes : array<mixed,string>
todo

This hard-coded array could be replaced by admin settings

var

Type(s)

array<mixed,string>

These types are useful for files preview in the files app, but not for the gallery side

slideshowMimeTypes : 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