Backend\Widgets\MediaManager

Source: ~/modules/backend/widgets/MediaManager.php

Extends:

Media Manager widget.

Public properties

public boolean $readOnly

Determines whether the widget is in readonly mode or not.

public boolean $bottomToolbar

Determines whether the bottom toolbar is visible.

public boolean $cropAndInsertButton

Determines whether the Crop & Insert button is visible.

Show inherited public properties

Inherited public properties

Protected properties

protected string $brokenImageHash

Hash string for the broken image graphic.

Show inherited protected properties

Inherited protected properties

Public methods

public void __construct($controller, $alias, $readOnly=false)

Constructor.

Parameters
  • $controller
  • $alias
  • $readOnly

public array onApplyName()

Reanem library item AJAX handler

public array onChangeView()

Set view preference AJAX handler

public array onCreateFolder()

Create library folder AJAX handler

public array onCropImage()

Crop image AJAX handler

public array onDeleteItem()

Delete library item AJAX handler

public array onEndCroppingSession()

End crop session AJAX handler

public array onGenerateThumbnails()

Generate thumbnail AJAX handler

public array onGetSidebarThumbnail()

Get thumbnail AJAX handler

public array onGoToFolder()

Change view AJAX handler

public array onLoadImageCropPopup()

Load image for cropping AJAX handler

public array onLoadMovePopup()

Show move item popup AJAX handler

public array onLoadPopup()

Start image cropping session AJAX handler

public array onLoadRenamePopup()

Show rename item popup AJAX handler

public array onMoveItems()

Move library item AJAX handler

public array onResizeImage()

Resize image AJAX handler

public array onSearch()

Perform search AJAX handler

public array onSetFilter()

Set filter preference AJAX handler

public array onSetSidebarVisible()

Sidebar visibility AJAX handler

public array onSetSorting()

Set sorting preference AJAX handler

public string render()

Renders the widget.

Show inherited public methods

Inherited public methods

  • public void __call($name, $params) - defined in October\Rain\Extension\Extendable.
  • public static void __callStatic($name, $params) - defined in October\Rain\Extension\Extendable.
  • public void __get($name) - defined in October\Rain\Extension\Extendable.
  • public void __set($name, $value) - defined in October\Rain\Extension\Extendable.
  • public void addCss(string $name, array $attributes=array()) - defined in Backend\Classes\WidgetBase. Adds StyleSheet asset to the asset list. Call $this->makeAssets() in a view.
  • public void addDynamicMethod(string $dynamicName, callable $method, string $extension=NULL) - defined in October\Rain\Extension\Extendable. Programmatically adds a method to the extendable class.
  • public void addDynamicProperty(string $dynamicName, string $value=NULL) - defined in October\Rain\Extension\Extendable. Programmatically adds a property to the extendable class.
  • public void addJs(string $name, array $attributes=array()) - defined in Backend\Classes\WidgetBase. Adds JavaScript asset to the asset list. Call $this->makeAssets() in a view.
  • public void addRss(string $name, array $attributes=array()) - defined in Backend\Classes\WidgetBase. Adds an RSS link asset to the asset list. Call $this->makeAssets() in a view.
  • public void addViewPath(string|array $path) - defined in Backend\Classes\WidgetBase. Prepends a path on the available view path locations.
  • public mixed asExtension(string $shortName) - defined in October\Rain\Extension\Extendable. Short hand for getClassExtension() method, except takes the short.
  • public self bindEvent($event, $callback, $priority=0) - defined in Backend\Classes\WidgetBase. Create a new event binding.
  • public self bindEventOnce($event, $callback) - defined in Backend\Classes\WidgetBase. Create a new event binding that fires once only.
  • public void bindToController() - defined in Backend\Classes\WidgetBase. Binds a widget to the controller for safe use.
  • public static void clearExtendedClasses() - defined in October\Rain\Extension\Extendable. Clear the list of extended classes so they will be re-extended.
  • public string combineAssets(array $assets, string $localPath='') - defined in Backend\Classes\WidgetBase. Run the provided assets through the Asset Combiner.
  • public static void extend($callback) - defined in October\Rain\Extension\Extendable.
  • public void extendClassWith(string $extensionName) - defined in October\Rain\Extension\Extendable. Dynamically extend a class with a specified behavior.
  • public mixed extendableCall(string $name, array $params=NULL) - defined in October\Rain\Extension\Extendable. Magic method for __call().
  • public static mixed extendableCallStatic(string $name, array $params=NULL) - defined in October\Rain\Extension\Extendable. Magic method for __callStatic().
  • public void extendableConstruct() - defined in October\Rain\Extension\Extendable. This method should be called as part of the constructor.
  • public static void extendableExtendCallback(callable $callback) - defined in October\Rain\Extension\Extendable. Helper method for ::extend() static method.
  • public string extendableGet(string $name) - defined in October\Rain\Extension\Extendable. Magic method for __get().
  • public string extendableSet(string $name, string $value) - defined in October\Rain\Extension\Extendable. Magic method for __set().
  • public array fireEvent(string $event, array $params=array(), boolean $halt=false) - defined in Backend\Classes\WidgetBase. Fire an event and call the listeners.
  • public mixed fireSystemEvent(string $event, array $params=array(), boolean $halt=true) - defined in Backend\Classes\WidgetBase. Fires a combination of local and global events. The first segment is removed.
  • public string fireViewEvent(string $event, array $params=array()) - defined in Backend\Classes\WidgetBase. Special event function used for extending within view files,
  • public void flushAssets() - defined in Backend\Classes\WidgetBase. Disables the use, and subequent broadcast, of assets. This is useful.
  • public string getAssetPath(string $fileName, string $assetPath=NULL) - defined in Backend\Classes\WidgetBase. Locates a file based on it's definition. If the file starts with.
  • public array getAssetPaths() - defined in Backend\Classes\WidgetBase. Returns an array of all registered asset paths.
  • public mixed getClassExtension(string $name) - defined in October\Rain\Extension\Extendable. Returns a behavior object from an extendable class, example:.
  • public array getClassMethods() - defined in October\Rain\Extension\Extendable. Get a list of class methods, extension equivalent of get_class_methods().
  • public string getConfig(string $name, string $default=NULL) - defined in Backend\Classes\WidgetBase. Safe accessor for configuration values.
  • public string getConfigPath(string $fileName, mixed $configPath=NULL) - defined in Backend\Classes\WidgetBase. Locates a file based on it's definition. If the file starts with.
  • public void getController() - defined in Backend\Classes\WidgetBase. Returns the controller using this widget.
  • public array getDynamicProperties() - defined in October\Rain\Extension\Extendable. Returns all dynamic properties and their values.
  • public string getEventHandler(string $name) - defined in Backend\Classes\WidgetBase. Returns a fully qualified event handler name for this widget.
  • public string getFatalError() - defined in Backend\Classes\WidgetBase. Returns the fatal error message
  • public string getId(string $suffix=NULL) - defined in Backend\Classes\WidgetBase. Returns a unique ID for this widget. Useful in creating HTML markup.
  • public string getViewPath(string $fileName, mixed $viewPath=NULL) - defined in Backend\Classes\WidgetBase. Locates a file based on its definition. The file name can be prefixed with a.
  • public array getViewPaths() - defined in Backend\Classes\WidgetBase. Returns the active view path locations.
  • public string guessConfigPath(string $suffix='') - defined in Backend\Classes\WidgetBase. Guess the package path for the called class.
  • public string guessConfigPathFrom(string $class, string $suffix='') - defined in Backend\Classes\WidgetBase. Guess the package path from a specified class.
  • public string guessViewPath(string $suffix='', bool $isPublic=false) - defined in Backend\Classes\WidgetBase. Guess the package path for the called class.
  • public string guessViewPathFrom(string $class, string $suffix='', bool $isPublic=false) - defined in Backend\Classes\WidgetBase. Guess the package path from a specified class.
  • public void handleError($exception) - defined in Backend\Classes\WidgetBase. Sets standard page variables in the case of a controller error.
  • public bool hasAssetsDefined() - defined in Backend\Classes\WidgetBase. Returns true if assets any have been added.
  • public boolean hasFatalError() - defined in Backend\Classes\WidgetBase. Determines whether a fatal error has been set or not.
  • public void init() - defined in Backend\Classes\WidgetBase. Initialize the widget, called by the constructor and free from its parameters.
  • public boolean isClassExtendedWith(string $name) - defined in October\Rain\Extension\Extendable. Check if extendable class is extended with a behavior object.
  • public string makeAssets(string $type=NULL) - defined in Backend\Classes\WidgetBase. Outputs <link> and <script> tags to load assets previously added with addJs and addCss method calls.
  • public array|stdClass makeConfig(array $configFile=array(), array $requiredConfig=array()) - defined in Backend\Classes\WidgetBase. Reads the contents of the supplied file and applies it to this object.
  • public stdClass makeConfigFromArray(array $configArray=array()) - defined in Backend\Classes\WidgetBase. Makes a config object from an array, making the first level keys properties of a new object.
  • public string makeFileContents(string $filePath, array $extraParams=array()) - defined in Backend\Classes\WidgetBase. Includes a file path using output buffering.
  • public Backend\Classes\FormWidgetBase makeFormWidget(string $class, mixed $fieldConfig=array(), array $widgetConfig=array()) - defined in Backend\Classes\WidgetBase. Makes a form widget object with the supplied form field and widget configuration.
  • public mixed makeLayout(string $name=NULL, array $params=array(), bool $throwException=true) - defined in Backend\Classes\WidgetBase. Render a layout.
  • public string makeLayoutPartial(string $partial, array $params=array()) - defined in Backend\Classes\WidgetBase. Renders a layout partial.
  • public mixed makePartial(string $partial, array $params=array(), bool $throwException=true) - defined in Backend\Classes\WidgetBase. Render a partial file contents located in the views folder.
  • public string makeView(string $view) - defined in Backend\Classes\WidgetBase. Loads a view with the name specified. Applies layout if its name is provided by the parent object.
  • public string makeViewContent(string $contents, string $layout=NULL) - defined in Backend\Classes\WidgetBase. Renders supplied contents inside a layout.
  • public Backend\Classes\WidgetBase makeWidget(string $class, array $widgetConfig=array()) - defined in Backend\Classes\WidgetBase. Makes a widget object with the supplied configuration file.
  • public stdClass mergeConfig(mixed $configA, mixed $configB) - defined in Backend\Classes\WidgetBase. Merges two configuration sources, either prepared or not, and returns.
  • public boolean methodExists(string $name) - defined in October\Rain\Extension\Extendable. Checks if a method exists, extension equivalent of method_exists().
  • public boolean propertyExists(string $name) - defined in October\Rain\Extension\Extendable. Checks if a property exists, extension equivalent of property_exists().
  • public void resetSession() - defined in Backend\Classes\WidgetBase. Resets all session data related to this widget.
  • public self unbindEvent(string $event=NULL) - defined in Backend\Classes\WidgetBase. Destroys an event binding.

Protected methods

protected void abortIfReadOnly()

Abort the request with an access-denied code if readOnly mode is active

protected void checkUploadPostback()

Detect the upload post flag

protected string cleanFileName(string $name)

Creates a slug form the string. A modified version of Str::slug with the main difference that it accepts @-signs

Parameters
  • string $name

protected void copyBrokenImage(string $path)

Copy broken image to destination

Parameters
  • string $path

protected array cropImage(string $imageSrcPath, string $selectionData, string $cropSessionKey, string $path)

Business logic to crop a media library image

Parameters
  • string $imageSrcPath
  • string $selectionData
  • string $cropSessionKey
  • string $path

protected void findFiles(string $searchTerm, string $filter, string $sortBy)

Finds files from within the media library based on supplied criteria, returns an array of MediaLibraryItem objects.

Parameters
  • string $searchTerm
  • string $filter
  • string $sortBy

protected array generateThumbnail(array $thumbnailInfo, array|null $thumbnailParams=NULL)

Generate thumbnail

Parameters
  • array $thumbnailInfo
  • array|null $thumbnailParams

protected string getBrokenImageHash()

Returns a CRC32 hash for a broken image

protected string getBrokenImagePath()

Returns the path for the broken image graphic

protected array getCropEditImageUrlAndSize(string $path, string $cropSessionKey, array $params=NULL)

Prepares an image for cropping and returns payload containing a URL

Parameters
  • string $path
  • string $cropSessionKey
  • array $params

protected string getCropSessionDirPath(string $cropSessionKey)

Returns the crop session working directory path

Parameters
  • string $cropSessionKey

protected string getCurrentFolder()

Gets the user current folder from the session state

protected string getFilter()

Gets the user filter from the session state

protected string getLocalTempFilePath(string $fileName)

Get temporary local file path

Parameters
  • string $fileName

protected string getPlaceholderId(System\Classes\MediaLibraryItem $item)

Get placeholder identifier

Parameters

protected string getSearchTerm()

Gets the user search term from the session state

protected array getSelectionParams()

Gets the user selection parameters from the session state

protected bool getSidebarVisible()

Checks if the sidebar is visible

protected string getSortBy()

Gets the user sort column from the session state

protected string getSortDirection()

Gets the user sort direction from the session state

protected void getTargetDimensions(int $width, int $height, string $originalImagePath)

Get target dimensions

Parameters
  • int $width
  • int $height
  • string $originalImagePath

protected string getThumbnailDirectory()

Get thumbnail directory

protected string getThumbnailImageExtension(string $itemPath)

Preferred thumbnail image extension

Parameters
  • string $itemPath

protected string getThumbnailImagePath(array|null $thumbnailParams, string $itemPath, int $lastModified)

Generates a thumbnail image path

Parameters
  • array|null $thumbnailParams
  • string $itemPath
  • int $lastModified

protected string getThumbnailImageUrl(string $imagePath)

Returns the URL to a thumbnail

Parameters
  • string $imagePath

protected array getThumbnailParams(string $viewMode=NULL)

Returns thumbnail parameters

Parameters
  • string $viewMode

protected string getViewMode()

Returns the current view mode stored in the session

protected boolean isVector(string $path)

Detect if image is vector graphic (SVG)

Parameters
  • string $path

protected string itemTypeToIconClass(System\Classes\MediaLibraryItem $item, string $itemType)

Returns an icon for the item type

Parameters

protected void listFolderItems(string $searchTerm, string $filter, string $sortBy)

Returns a list of folders and files in a Library folder.

Parameters
  • string $searchTerm
  • string $filter
  • string $sortBy

protected void loadAssets()

Adds widget specific asset files. Use $this->addJs() and $this->addCss() to register new assets to include on the page.

protected array prepareVars()

Internal method to prepare view variables.

protected void removeCropEditDir(string $cropSessionKey)

Cleans up the directory used for cropping based on the session key

Parameters
  • string $cropSessionKey

protected void resizeImage(string $fullThumbnailPath, array $thumbnailParams, string $tempFilePath)

Resize an image

Parameters
  • string $fullThumbnailPath
  • array $thumbnailParams
  • string $tempFilePath

protected void setCurrentFolder(string $path)

Sets the user current folder from the session state

Parameters
  • string $path

protected void setFilter(string $filter)

Sets the user filter from the session state

Parameters
  • string $filter

protected void setSearchTerm(string $searchTerm)

Sets the user search term from the session state

Parameters
  • string $searchTerm

protected void setSelectionParams(string $selectionMode, int $selectionWidth, int $selectionHeight)

Stores the user selection parameters in the session state

Parameters
  • string $selectionMode
  • int $selectionWidth
  • int $selectionHeight

protected void setSidebarVisible(bool $visible)

Sets the sidebar visible state

Parameters
  • bool $visible

protected void setSortBy(string $sortBy)

Sets the user sort column from the session state

Parameters
  • string $sortBy

protected void setSortDirection(string $sortDirection)

Sets the user sort direction from the session state

Parameters
  • string $sortDirection

protected void setViewMode(string $viewMode)

Stores a view mode in the session

Parameters
  • string $viewMode

protected array splitPathToSegments(string $path)

Splits a path in to segments

Parameters
  • string $path

protected bool thumbnailExists(array|null $thumbnailParams, string $itemPath, int $lastModified)

Check if a thumbnail exists

Parameters
  • array|null $thumbnailParams
  • string $itemPath
  • int $lastModified

protected bool thumbnailIsError(string $thumbnailPath)

Check if a thumbnail has caused an error

Parameters
  • string $thumbnailPath

protected bool validateFileName(string $name)

Validate a proposed media item file name.

Parameters
  • string $name

protected bool validateFileType(string $name)

Check for blocked / unsafe file extensions

Parameters
  • string $name

Show inherited protected methods

Inherited protected methods

  • protected void addAsset(string $type, string $path, array $attributes) - defined in Backend\Classes\WidgetBase. Adds the provided asset to the internal asset collections.
  • protected array emitterEventSortEvents(string $eventName) - defined in Backend\Classes\WidgetBase. Sort the listeners for a given event by priority.
  • protected boolean extendableIsAccessible(mixed $class, string $propertyName) - defined in October\Rain\Extension\Extendable. Checks if a property is accessible, property equivalent of is_callable().
  • protected void extensionExtractMethods(string $extensionName, object $extensionObject) - defined in October\Rain\Extension\Extendable. Extracts the available methods from a behavior and adds it to the.
  • protected void fillFromConfig(array $properties=NULL) - defined in Backend\Classes\WidgetBase. Transfers config values stored inside the $config property directly.
  • protected string getAssetEntryBuildPath(array $asset) - defined in Backend\Classes\WidgetBase. Internal helper, attaches a build code to an asset path.
  • protected string getAssetScheme(string $asset) - defined in Backend\Classes\WidgetBase. Internal helper, get asset scheme.
  • protected void getLocalPath($relativePath) - defined in Backend\Classes\WidgetBase.
  • protected string getSession(string $key=NULL, string $default=NULL) - defined in Backend\Classes\WidgetBase. Retrieves a widget related key/value pair from session data.
  • protected void handleViewException(Exception $e, int $obLevel) - defined in Backend\Classes\WidgetBase. Handle a view exception.
  • protected string makeSessionId() - defined in Backend\Classes\WidgetBase. Returns a unique session identifier for this widget and controller action.
  • protected void putSession(string $key, string $value) - defined in Backend\Classes\WidgetBase. Saves a widget related key/value pair in to session data.
  • protected void removeDuplicates() - defined in Backend\Classes\WidgetBase. Removes duplicate assets from the entire collection.