Removes empty elements from an array.
(can be useful when using function explode to create the array from a csv)
array
CleanArray
(array $array)
-
array
$array: - the array to clean up
Replaces all multiple DIRECTORY_SEPARATOR, dots and (multiple) slashes with one single DIRECTORY_SEPARATOR to make a clean secure path parameter
string
CleanPath
(string $path, [string $full_path = true])
-
string
$path: - the path to clean
-
string
$full_path: - true to prepend uploads path on return, false to return only the cleaned $path
Replaces all multiple slashes, dots and (multiple) backslashes with one single slash to make a clean secure url parameter
string
CleanURL
(string $url, [string $full_url = true])
-
string
$url: - the url to clean
-
string
$full_url: - true to prepend uploads url on return, false to return only the cleaned $url
Checks if a filename contains illegal chars
Taken from TinyMCE Module.
boolean
ContainsIllegalChars
(string $filename)
-
string
$filename: - the filename to check
Create a dropdown form element containing a list of files that match certain conditions
string
CreateFileDropdown
(string $id, string $name, [string $dir = ''], [string $selected = ''], [array|string $excl_prefix = ''], [array|string $incl_prefix = ''], [array|string $excl_sufix = ''], [array|string $incl_sufix = ''], [array|string $file_ext = ''], [string $media_type = ''], [boolean $allow_none = true], [string $add_txt = ''])
-
string
$id: - the id of the moduleinstance that creates the filepicker input
-
string
$name: - the name of the input field
-
string
$dir: - the directory to list the files of (may be relative to uploads dir or absolute path)
-
string
$selected: - the preselected value
-
array|string
$excl_prefix: - fileprefixes to exclude (array('foo','bar',...) or csv)
-
array|string
$incl_prefix: - fileprefixes to include (array('foo','bar',...) or csv)
-
array|string
$excl_sufix: - filesufixes to exclude (array('foo','bar',...) or csv)
-
array|string
$incl_sufix: - filesufixes to include (array('foo','bar',...) or csv)
-
array|string
$file_ext: - filesufixes to include (array('foo','bar',...) or csv)
-
string
$media_type: - file or image
-
boolean
$allow_none: - set to false to hide the option 'none'
-
string
$add_txt: - any additional text that will be added to the html input when tag is rendered
Creates the filepicker input.
string
CreateFilePickerInput
(object &$module, string $id, string $name, [string $value = ''], [array $params = array()], [integer $returnid = ''])
-
object
&$module: - the module instance that calls the filepicker (this is only needed if you want to process own templates; pass the filepicker instance itself or leave it empty if you don't need this)
-
string
$id: - the id of the moduleinstance that creates the filepicker input
-
string
$name: - the name of the input field
-
string
$value: - the preselected value
-
array
$params: - the input params (param_name => param_value):
- (string) 'feu_access' => a csv of group ids of the frontend users module,
- (boolean) 'restrict_users_diraccess' => set to true if user may only access a dir of his username (notice: this has no effect if you are admin; in frontend this will always be true),
- (string) 'header_template' => specify wich template should be used to create the html output that will be placed in the <head> section (default is header.tpl of the selected theme of GBFilePickers preferences),
- (string) 'input_template' => specify wich template should be used to create the input elements (default is input.tpl of the selected theme of GBFilePickers preferences),
- (string) 'upload_template' => specify wich template should be used to create the upload form of mode dropdown (default is upload.tpl of the selected theme of GBFilePickers preferences),
- (string) 'filebrowser_template' => specify wich template should be used to create the filebrowser output (default is fileBrowser.tpl of the selected theme of GBFilePickers preferences),
- (string) 'prompt' => the prompt of the input field,
- (string) 'media_type' => the media type (at the moment only image / file are supported),
- (mixed) 'file_extensions' => an array or a csv of allowed file extensions,
- (mixed) 'exclude_prefix' => an array or a csv of file prefixes that will be excluded,
- (mixed) 'exclude_sufix' => an array or a csv of file suffixes that will be excluded,
- (mixed) 'include_prefix' => an array or a csv of file prefixes that will be included,
- (mixed) 'include_sufix' => an array or a csv of file suffixes that will be included,
- (boolean) 'show_subdirs' => set to true if user may browse subdirs (notice: this has no effect if you are admin)
- (string) 'mode' => dropdown/browser,
- (boolean) 'allow_none' => set to false if the option "none" should not be shown (notice: this has no effect if you are admin),
- (boolean) 'lock_input' => set to false if user may enter the path in the inputfield ('mode'=>'browser', 'media_type' => 'file') (notice: this has no effect if you are admin),
- (boolean) 'upload' => set to true if user may upload files (notice: this has no effect if you are admin or have permission to modify files),
- (boolean) 'delete' => set to true if user may delete files/dirs (notice: this has no effect if you are admin or have permission to modify files),
- (boolean) 'create_dirs' => set to true if user may create dirs (notice: this has no effect if you are admin or have permission to modify files),
- (string) 'add_txt' => any additional text that will be added to the html input when tag is rendered,
- (integer) 'size' => the size of the textinput ('mode' => 'browser', 'media_type' => 'file' only),
- (integer) 'maxlength' => the max length of the textinput ('mode' => 'browser', 'media_type' => 'file' only),
- (integer) 'scaling_width' => the default width of images when allow_scaling is true,
- (integer) 'scaling_height' => the default height of images when allow_scaling is true,
- (boolean) 'show_thumbfiles' => set to true if thumbs should also be shown as regular files,
- (boolean) 'allow_scaling' => set to false if user may not scale the images on upload,
- (boolean) 'create_thumbs' => set to false if the module may not create thumbs for the input,
- (boolean) 'allow_upscaling' => set to true if user may enlarge the images
- (boolean) 'force_scaling' => set to true to force resizing of image to a given size if user may not resize images
- (boolean) 'keep_aspectratio' => set to false to change aspect ratio to that one of the scaling size on resizing images
-
integer
$returnid: - the page id to return to and to print out the result after module has finished its task;
usually this has nothing to say but is required for frontend usage (must be an existing content id)
Creates the thumbnail of a given image file.
string
CreateThumbnail
(string $path)
-
string
$path: - the path of the file to create a thumbnail from (can be relative to the uploads dir or absolute)
Gets the icon for the file operation.
If FileManager is installed it uses FileManager icons.
Otherwise it uses own icons
string
GetActionIcon
(string $action)
-
string
$action: - the file operation (e.g. 'delete')
Gets the icon for a file.
If FileManager is installed it uses FileManager icons.
Otherwise it uses own icons.
string
GetFileIcon
([string $ext = ''], [bool $is_dir = false], [bool $is_image = false])
-
string
$ext: - the file extension
-
bool
$is_dir
-
bool
$is_image
Return an array containing a list of files in a directory.
Performs a non recursive search.
array
&GetFiles
([string $dir = ''], [array|string $excl_prefix = ''], [array|string $incl_prefix = ''], [array|string $excl_sufix = ''], [array|string $incl_sufix = ''], [array|string $file_ext = ''], [string $media_type = 'image'], [boolean $excl_dirs = false], [boolean $show_thumbfiles = false], [boolean $create_thumbs = true])
-
string
$dir: - the directory to list the files of (may be relative to uploads dir or absolute path)
-
array|string
$excl_prefix: - fileprefixes to exclude (array('foo','bar',...) or csv)
-
array|string
$incl_prefix: - fileprefixes to include (array('foo','bar',...) or csv)
-
array|string
$excl_sufix: - filesufixes to exclude (array('foo','bar',...) or csv)
-
array|string
$incl_sufix: - filesufixes to include (array('foo','bar',...) or csv)
-
array|string
$file_ext: - filesufixes to include (array('foo','bar',...) or csv)
-
string
$media_type: - file or image
-
boolean
$excl_dirs: - set to true to exclude directories
-
boolean
$show_thumbfiles
-
boolean
$create_thumbs: = true
Gets the file type of a file.
string
GetFileType
(string $file, [string $use_mime = false])
-
string
$file: - the path to a file
-
string
$use_mime: - set to true to detect file type by mime type
Return an array containing a list of files in a directory related to a certain input.
Performs a non recursive search.
array
&GetInputFiles
(string $id, string $name, string $dir)
-
string
$id: - the id of the moduleinstance that creates the filepicker input
-
string
$name: - the name of the input field
-
string
$dir: - the directory to list the files of (may be relative to uploads dir or absolute path)
Returns a list of available themes
array
GetThemesList
()
Returns the thumbnail of a given image file.
string
GetThumbnail
(string $path, [string $create_thumb = true], [string $urlonly = false])
-
string
$path: - the path of the file to create a thumbnail of (can be relative to the uploads dir or absolute)
-
string
$create_thumb: - set to false if thumbnail may not be created if not exists
-
string
$urlonly: - set to true to get only the url to the thumbnail
returns the calculated size of the thumbnail
array
GetThumbnailSize
(string $path)
-
string
$path: - the source path of the image
resizes images
Adapted from TinyMCE filepicker.
void
HandleFileResizing
(string $source, string $output, integer $new_width, integer $new_height, [boolean $keep_aspectratio = true], [boolean $allow_upscaling = false], [integer $quality = 100], [boolean $clean_path = true])
-
string
$source: - the source path of the image
-
string
$output: - the destination path of the resized image
-
integer
$new_width: - the new wdth to scale the image to (if $keep_aspectratio is set to true this will be just some kind of max value)
-
integer
$new_height: - the new height to scale the image to (if $keep_aspectratio is set to true this will be just some kind of max value)
-
boolean
$keep_aspectratio: - set to false if image aspect ratio may be changed
-
boolean
$allow_upscaling: - set to true if user may enlarge the image
-
integer
$quality: - the quality of the new image (jpg only)
-
boolean
$clean_path: - set to false if source is the upload_tmp_dir
Checks if a directory is empty
Taken from TinyMCE Module (extracted from filepicker).
boolean
IsDirEmpty
(string $dir)
-
string
$dir: - the path to a directory
Checks if a value is really meant to be "false".
Can be usefull when checking smarty params for the value false
bool
IsFalse
(mixed $value)
-
mixed
$value: - the value to check
Checks if a value is really meant to be "true".
Can be usefull when checking smarty params for the value true
bool
IsTrue
(mixed $value)
-
mixed
$value: - the value to check
Checks if a var is empty.
If $var is an array it recursivley checks all elements.
boolean
IsVarEmpty
(mixed &$var, [boolean $trim = true], [boolean $unset_empty_indexes = false])
-
mixed
&$var: - the var to check for empty value(s)
-
boolean
$trim: - true to trim off spaces
-
boolean
$unset_empty_indexes: - true to delete empty elements from array
Indicates if GBFilePicker output is already done
can be useful to avoid ouput of javascript and css twice
bool
Loaded
()
Sorts the files by filename; shows directories first
this function is meant to be called from the php usort() function: usort($array,array($this,'SortFiles')
Taken from TinyMCE filepicker.
integer
SortFiles
(object $file1, object $file2)
-
object
$file1: - one file to compare
a php stdClass with properties (boolean) $is_dir - a flag that specifys if it is a dir or a file;
(string) $basename - the basename of the file;
-
object
$file2: - the other file to compare
a php stdClass with properties (boolean) $is_dir - a flag that specifys if it is a dir or a file;
(string) $basename - the basename of the file;