Skip to content

Plugin

Browser Plugin.

This plugin provides a html representation, so that a WebDAV server may be accessed using a browser.

The class intercepts GET requests to collection resources and generates a simple html index.

Properties

server

reference to server class.

protected \Sabre\DAV\Server $server

enablePost

enablePost turns on the 'actions' panel, which allows people to create folders and upload files straight from a browser.

protected bool $enablePost

uninterestingProperties

A list of properties that are usually not interesting. This can cut down the browser output a bit by removing the properties that most people will likely not want to see.

public array $uninterestingProperties

Methods

__construct

Creates the object.

public __construct(bool $enablePost = true): mixed

By default it will allow file creation and uploads. Specify the first argument as false to disable this

Parameters:

Parameter Type Description
$enablePost bool

initialize

Initializes the plugin and subscribes to events.

public initialize(\Sabre\DAV\Server $server): mixed

Parameters:

Parameter Type Description
$server \Sabre\DAV\Server

httpGetEarly

This method intercepts GET requests that have ?sabreAction=info appended to the URL.

public httpGetEarly(\Sabre\HTTP\RequestInterface $request, \Sabre\HTTP\ResponseInterface $response): mixed

Parameters:

Parameter Type Description
$request \Sabre\HTTP\RequestInterface
$response \Sabre\HTTP\ResponseInterface

httpGet

This method intercepts GET requests to collections and returns the html.

public httpGet(\Sabre\HTTP\RequestInterface $request, \Sabre\HTTP\ResponseInterface $response): bool

Parameters:

Parameter Type Description
$request \Sabre\HTTP\RequestInterface
$response \Sabre\HTTP\ResponseInterface

httpPOST

Handles POST requests for tree operations.

public httpPOST(\Sabre\HTTP\RequestInterface $request, \Sabre\HTTP\ResponseInterface $response): bool

Parameters:

Parameter Type Description
$request \Sabre\HTTP\RequestInterface
$response \Sabre\HTTP\ResponseInterface

escapeHTML

Escapes a string for html.

public escapeHTML(string $value): string

Parameters:

Parameter Type Description
$value string

generateDirectoryIndex

Generates the html directory index for a given url.

public generateDirectoryIndex(string $path): string

Parameters:

Parameter Type Description
$path string

generatePluginListing

Generates the 'plugins' page.

public generatePluginListing(): string

generateHeader

Generates the first block of HTML, including the tag and page header.

public generateHeader(string $title, string $path = null): string

Returns footer.

Parameters:

Parameter Type Description
$title string
$path string

generateFooter

Generates the page footer.

public generateFooter(): string

Returns html.


htmlActionsPanel

This method is used to generate the 'actions panel' output for collections.

public htmlActionsPanel(\Sabre\DAV\INode $node, mixed& $output, string $path): mixed

This specifically generates the interfaces for creating new files, and creating new directories.

Parameters:

Parameter Type Description
$node \Sabre\DAV\INode
$output mixed
$path string

getAssetUrl

This method takes a path/name of an asset and turns it into url suiteable for http access.

protected getAssetUrl(string $assetName): string

Parameters:

Parameter Type Description
$assetName string

getLocalAssetPath

This method returns a local pathname to an asset.

protected getLocalAssetPath(string $assetName): string

Parameters:

Parameter Type Description
$assetName string

Throws:


serveAsset

This method reads an asset from disk and generates a full http response.

protected serveAsset(string $assetName): mixed

Parameters:

Parameter Type Description
$assetName string

compareNodes

Sort helper function: compares two directory entries based on type and display name. Collections sort above other types.

protected compareNodes(array $a, array $b): int

Parameters:

Parameter Type Description
$a array
$b array

mapResourceType

Maps a resource type to a human-readable string and icon.

private mapResourceType(array $resourceTypes, \Sabre\DAV\INode $node): array

Parameters:

Parameter Type Description
$resourceTypes array
$node \Sabre\DAV\INode

drawPropertyRow

Draws a table row for a property.

private drawPropertyRow(string $name, mixed $value): string

Parameters:

Parameter Type Description
$name string
$value mixed

drawPropertyValue

Draws a table row for a property.

private drawPropertyValue(\Sabre\DAV\Browser\HtmlOutputHelper $html, mixed $value): string

Parameters:

Parameter Type Description
$html \Sabre\DAV\Browser\HtmlOutputHelper
$value mixed

getPluginName

Returns a plugin name.

public getPluginName(): string

Using this name other plugins will be able to access other plugins; using \Sabre\DAV\Server::getPlugin


getPluginInfo

Returns a bunch of meta-data about the plugin.

public getPluginInfo(): array

Providing this information is optional, and is mainly displayed by the Browser plugin.

The description key in the returned array may contain html and will not be sanitized.


Inherited methods

initialize

This initializes the plugin.

public initialize(\Sabre\DAV\Server $server): mixed

This function is called by Sabre\DAV\Server, after addPlugin is called.

This method should set up the required event subscriptions.

  • This method is abstract.

Parameters:

Parameter Type Description
$server \Sabre\DAV\Server

getFeatures

This method should return a list of server-features.

public getFeatures(): array

This is for example 'versioning' and is added to the DAV: header in an OPTIONS response.


getHTTPMethods

Use this method to tell the server this plugin defines additional HTTP methods.

public getHTTPMethods(string $path): array

This method is passed a uri. It should only return HTTP methods that are available for the specified uri.

Parameters:

Parameter Type Description
$path string

getPluginName

Returns a plugin name.

public getPluginName(): string

Using this name other plugins will be able to access other plugins using \Sabre\DAV\Server::getPlugin


getSupportedReportSet

Returns a list of reports this plugin supports.

public getSupportedReportSet(string $uri): array

This will be used in the {DAV:}supported-report-set property. Note that you still need to subscribe to the 'report' event to actually implement them

Parameters:

Parameter Type Description
$uri string

getPluginInfo

Returns a bunch of meta-data about the plugin.

public getPluginInfo(): array

Providing this information is optional, and is mainly displayed by the Browser plugin.

The description key in the returned array may contain html and will not be sanitized.



Automatically generated on 2025-03-18