Huygens Remote Manager
  • Namespace
  • Class
  • Tree
  • Todo

Namespaces

  • hrm
    • job
    • param
      • base
    • setting
      • base
    • shell
    • stats
    • user
      • proxy

Classes

  • DatabaseConnection
  • Fileserver
  • FileserverV2
  • HuygensTemplate
  • HuygensTools
  • Log
  • Mail
  • Nav
  • OmeroConnection
  • QueueManager
  • System
  • Util
  • UtilV2
  • Validator

Functions

  • fileButton

Class Fileserver

Takes care of all file handling to and from the image area and provides commodity functions for creating and displaying previews.

Namespace: hrm
Package: hrm
Located at Fileserver.php

Methods summary

public
# __construct( string $name )

Fileserver constructor.

Fileserver constructor.

Parameters

$name
User name.
public boolean
# isReachable( )

Checks whether the file area is reachable.

Checks whether the file area is reachable.

Returns

boolean

True if the file area is reachable (i.e. if source and destination folders exist).

Todo

Test if accessible/writable.
public string
# username( )

Returns the name of the user.

Returns the name of the user.

Returns

string
Name of the user.
public string
# sourceFolder( )

Returns the absolute path to the user's source image folder. The folder may be on the local network.

Returns the absolute path to the user's source image folder. The folder may be on the local network.

Returns

string
Absolute path to the source image folder.
public string
# destinationFolder( )

Returns the absolute path to the user's destination image folder. The folder may be on the local network

Returns the absolute path to the user's destination image folder. The folder may be on the local network

Returns

string
Absolute path to the destination image folder.
public string
# destinationFolderFor( hrm\job\JobDescription $desc )

Returns the destination image folder from a JobDescription object

Returns the destination image folder from a JobDescription object

Parameters

$desc
JobDescription object.@

Returns

string
Festination image folder with user-generated subfolder.
public array|boolean
# files( string $extension = null )

Searches the source folder recursively, stores and also returns the list of found files

Searches the source folder recursively, stores and also returns the list of found files

Parameters

$extension
Extension to be considered to scan the folder. Omit to get all files.

Returns

array|boolean
Sorted array of file names or false if the source folder does not exist.

Todo

Do not return different types!
public string
# checkAgainstFormat( string $file, string $selectedFormat )

Extracts the file extension, also if it's a subimage.

Extracts the file extension, also if it's a subimage.

Parameters

$file
The file name.
$selectedFormat
The format selected at the select images stage.

Returns

string
The file extension.
public array
# listFiles( boolean $expand )

Searches the source folder recursively and returns all found files

Searches the source folder recursively and returns all found files

Parameters

$expand

If true, names of subimages (as in the case of lif files) are expanded and returned in the list of file names.

Please notice that this function DOES NOT STORE THE LIST OF FILES. It just returns it!

Returns

array
Sorted array of file names.

Todo

Refactor!
public array|boolean
# destFiles( string $extension = null )

Searches the destination folder recursively and returns all found files.

Searches the destination folder recursively and returns all found files.

Parameters

$extension
Extension to be considered to scan the folder. Omit to get all files.

Returns

array|boolean
Sorted array of file names or false if the destination folder does not exist.

Todo

Do not return different types!
public array
# condenseSeries( )

Condense file series by preserving only the first file of each series.

Condense file series by preserving only the first file of each series.

Files that do not belong to a series are preserved.

Returns

array
Updated (condensed) list of stored files.
public boolean
# isPartOfFileSeries( string $file )

Checks whether a given file belongs to a file series.

Checks whether a given file belongs to a file series.

Parameters

$file
The file to be checked.

Returns

boolean
True if the file belongs to a series, false otherwise.
public array
# filesOfType( string $format, boolean $isTimeSeries )

A wrapper function to list files of a certain type.

A wrapper function to list files of a certain type.

This updates the list of stored files.

Parameters

$format
Extension to be considered to scan the folder.
$isTimeSeries
True for time series, false otherwise.

Returns

array
Array of of file names.

Todo

Refactor!
public array
# allFiles( )

Scans the image source folder recursively and returns all files.

Scans the image source folder recursively and returns all files.

This does not update the stored list!

Returns

array
Sorted array of file names
public array
# tiffFiles( )

Convenience method to get TIFF files.

Convenience method to get TIFF files.

This stores the files.

Returns

array
Array of TIFF file names.
public array
# tiffSeriesFiles( )

Convenience method to get numbered TIFF series.

Convenience method to get numbered TIFF series.

This stores the files.

Returns

array
Array of numbered TIFF file names.
public array
# tiffLeicaFiles( )

Convenience method to get TIFF series with Leica style numbering

Convenience method to get TIFF series with Leica style numbering

This stores the files.

Returns

array
Array of Leica TIFF file names.
public array
# stkFiles( )

Convenience method to get all STK files (also unprocessed time series).

Convenience method to get all STK files (also unprocessed time series).

This stores the files.

Returns

array
Array of STK files with unprocessed time series.
public array
# stkSeriesFiles( )

Convenience method to get STK time series files (*_t#.stk).

Convenience method to get STK time series files (*_t#.stk).

This stores the files.

Returns

array
Array of STK time series files.
public
# resetFiles( )

Resets the list of source files. Next time the list is accessed it will be recreated automatically.

Resets the list of source files. Next time the list is accessed it will be recreated automatically.

public
# resetDestFiles( )

Resets the list of destination files. Next time the list is accessed it will be recreated automatically.

Resets the list of destination files. Next time the list is accessed it will be recreated automatically.

public
# expandSubImages( boolean $bool )

Sets a flag to indicate whether multi-experiment image files should be expanded in file lists or not.

Sets a flag to indicate whether multi-experiment image files should be expanded in file lists or not.

Parameters

$bool
True if multi-image files should be expanded; false otherwise.
public array
# selectedFiles( )

Returns the list of selected files that will be added to a job.

Returns the list of selected files that will be added to a job.

Returns

array
Array of selected file names.
public
# addFilesToSelection( array $files )

Add files to current selection if they are not already contained.

Add files to current selection if they are not already contained.

Parameters

$files
Array of file names to be added.
public
# removeAllFilesFromSelection( )

Remove all files from current selection.

Remove all files from current selection.

public
# removeFilesFromSelection( array $files )

Remove files from current selection (if they are in).

Remove files from current selection (if they are in).

Parameters

$files
Array of file names to be removed,
public string
# getFilePattern( string $fileName )

Builds a regular expression to be able to look for files based on the job id.

Builds a regular expression to be able to look for files based on the job id.

Parameters

$fileName
File name to be parsed to construct the regular expression.

Returns

string
The regular expression.

Todo

A new design and implementation of the file server is necessary.
public string
# downloadResults( array $files )

Packs a series of files to download.

Packs a series of files to download.

Parameters

$files
List of files to be added.

Returns

string
Success/error message.

Todo

This will be replaced soon!
public string
# deleteFiles( array $files, string $dir = "dest" )

Deletes a list of files and all dependent sub-files (e.g. thumbnails and so) from a user directory.

Deletes a list of files and all dependent sub-files (e.g. thumbnails and so) from a user directory.

Parameters

$files
Array of image file names.
$dir
Folder to consider, one of 'src' or 'dest'

Returns

string
Error message in case files could not be deleted.
public
# exportToOmero( )

Exports a deconvolved image to the OMERO server.

Exports a deconvolved image to the OMERO server.

public
# importFromOmero( )

Imports a raw image from the OMERO server.

Imports a raw image from the OMERO server.

public
# decompressArchive( string $file, string $type, string $dest, &string & $okMsg, &string & $errMsg, string $subdir = "", boolean $imagesOnly = true )

Extracts files from compressed archives.

Extracts files from compressed archives.

Parameters

$file
Archive name.
$type
Archive type (zip, tar, tgz...).
$dest
Destination path.
$okMsg
A reference to a string to accumulate OK messages.
$errMsg
A reference to a string to accumulate error messages.
$subdir

An optional subdirectory under $dest to expand the files to.

$imagesOnly

An optional flag to delete non-image files after extraction.

public string
# uploadFiles( array $files, string $dir )

Processes the $_FILES array posted when uploading files, moving valid one to the specified directory. Compressed files are decompressed.

Processes the $_FILES array posted when uploading files, moving valid one to the specified directory. Compressed files are decompressed.

Parameters

$files
Array of files to be uploaded.
$dir
Destination path, one of 'src' or 'dest'.

Returns

string
Message with details.

See

See PHP documentation: POST method uploads.

Todo

This will be replaced soon!
public array
# imageExtensions( )

Returns a list of file extensions for supported images

Returns a list of file extensions for supported images

Returns

array
Array of file extensions.
public
# setImageExtensions( array $extensions )

Sets the list of image extensions.

Sets the list of image extensions.

Files with these extensions under the user's source folder will be shown under available images. Whenever the image extensions are changed, the files and the selected files will be reset. Only exception is when the list of image extensions is replaced by itself.

Parameters

$extensions
Array of file extensions (strings)
public
# setDefaultImageExtensions( )

Sets the image extensions from the list of valid image extensions.

Sets the image extensions from the list of valid image extensions.

public boolean
# isImage( string $filename )

Checks whether the filename extension matches the currently selected file format.

Checks whether the filename extension matches the currently selected file format.

Parameters

$filename
File name to be checked.

Returns

boolean
True if the file extension matches the file format, false otherwise.
public boolean
# isValidImage( string $filename, boolean $alsoExtras = false )

Checks whether the file name is of a valid type.

Checks whether the file name is of a valid type.

Parameters

$filename
The file name to be checked.
$alsoExtras
If true, consider also extensions as ids or ids.gz.

Returns

boolean
True if the filename is of a valid type, false otherwise.
public string
# getCompressedArchiveType( string $filename )

Returns the archive type of a filename, if it is a valid known compressed archive.

Returns the archive type of a filename, if it is a valid known compressed archive.

Parameters

$filename
The file name to be checked.

Returns

string
The archive type if the filename is valid archive, "" otherwise.
public string
# getValidArchiveTypesAsString( )

Returns all archive types as string.

Returns all archive types as string.

Returns

string
String containing all archive types.
public array
# getSubImages( array $files )

When the selected file type is one that can contain sub-images (like LIF), the already built list of $this->files is extended to show all the available sub-images. This is done by querying HuCore.

When the selected file type is one that can contain sub-images (like LIF), the already built list of $this->files is extended to show all the available sub-images. This is done by querying HuCore.

Parameters

$files
Array of file names that have to be inspected for sub-images.

Returns

array
Updated array of file names with sub-images.
public array
# getMetaDataFromFiles( array $files )

Some files like ICS can report their metadata without having to open the whole image, which is good e.g. to see the compatibility of the selected PSF with the current Parameter Setting. This is done by querying HuCore.

Some files like ICS can report their metadata without having to open the whole image, which is good e.g. to see the compatibility of the selected PSF with the current Parameter Setting. This is done by querying HuCore.

Parameters

$files
Array of file paths (relative to the source folder).

Returns

array
N-dimensional array of metadata per file.
public array
# getMetaData( string $type = "ics", string $file = "all" )

Some files like ICS can report their metadata without having to open the whole image, which is good e.g. to see the compatibility of the selected PSF with the current Parameter Setting. This is done by querying HuCore.

Some files like ICS can report their metadata without having to open the whole image, which is good e.g. to see the compatibility of the selected PSF with the current Parameter Setting. This is done by querying HuCore.

Parameters

$type
File type, default is "ics".
$file

This can be a file name for the file to be inspected, or "all" to inspect all the files of type $type that are in the source folder.

Returns

array
N-dimensional array of metadata per file.
public string
# getImageOptionLine( string $file, integer $index, string $dir, string $type, integer $ref = 0, integer $data = 1 )

Generates a html line for a form listing images in the server

Generates a html line for a form listing images in the server

Parameters

$file
Image file name.
$index
Unused Index in the file name array.
$dir
Unused Destination directory, one of 'src', or 'dst'.
$type
Unused Type of the image, e.g. 'preview'.
$ref
Unused Default is 0.
$data
Unused Default = 1.

Returns

string
The html code for the form.

Todo

Check why this function taks 6 parameters and uses only one.
public string
# getImageAction( string $file, integer $index, string $dir, string $type, integer $ref = 0, integer $data = 1 )

Generates a javascript command to show an image preview.

Generates a javascript command to show an image preview.

Parameters

$file
Image file name.
$index
Index in the file name array.
$dir
Destination directory, one of 'src', or 'dst'.
$type
Type of the image, e.g. 'preview'.
$ref
Default is 0.
$data
Default = 1.

Returns

string
The javascript code.
public string
# imgPreview( string $image, string $dir, string $type = "preview_xy", boolean $escape = true )

Generates a link to retrieve an image thumbnail, which is a jpg file saved near the file itself.

Generates a link to retrieve an image thumbnail, which is a jpg file saved near the file itself.

Parameters

$image
Image file name.
$dir
Destination directory, one of 'src' or 'dst'.
$type

Type of thumbnail, one of 'preview_xy', 'preview_xz', 'preview_yz'; default is 'preview_xy'.

$escape
If true, the code is escaped to be used in Javascript code.

Returns

string
An link to securely get the thumbnail.
public string
# viewStrip( string $file, string $type = "stack.compare", string $dir = "dest", boolean $frame = false, integer $margin = 25 )

Shows stacks and time series saved as jpeg strips in a css container. Inspired by the paperbird code by Rom�n Cort�s:

Shows stacks and time series saved as jpeg strips in a css container. Inspired by the paperbird code by Rom�n Cort�s:

Parameters

$file
Image file name.
$type

Type of the strip, one of 'stack.compare', 'tSeries.compare', 'preview_yz'; default is 'stack.compare'.

$dir
Destination directory, one of 'src' or 'dest', default is 'dest'.
$frame
True to draw a frame, false otherwise.
$margin
Thickness of the margin around th strip, default is 25.

Returns

string
HTML code to be output to the page.

See

http://www.romancortes.com/blog/css-paper-bird/
public string
# previewPage( string $file, string $op = "close", string $mode = "MIP", integer $size = 400 )

Creates the preview page for the file browser.

Creates the preview page for the file browser.

Parameters

$file
Image file name.
$op
Operation, one of 'close' or 'home'. Default is "close".
$mode

Display mode. One of "MIP", "parameters", "log", "SFP", "stack", "tSeries", "history", "remarks". Default is "MIP".

$size
Size of the thumbnail. Default is 400.

Returns

string
HTML code (whole page).
public string
# compareResult( string $file, integer|string $size = "400", string $op = "close", string $mode = "MIP" )

Shows original/result previews side by side.

Shows original/result previews side by side.

Parameters

$file
Image file name.
$size
Size of the thumbnail. Default is 400
$op
Operation, one of 'close' or 'home'. Default is "close".
$mode

Display mode. One of "MIP, "SFP", "stack", "tSeries", "log", "history", "remarks". Default is "MIP".

Returns

string
HTML code (whole page).
public string
# genPreview( string $file, string $src, string $dest, integer $index, integer|string $sizes = "preview", string|integer $data = 0 )

Calls hucore to open an image and generate a jpeg preview.

Calls hucore to open an image and generate a jpeg preview.

Parameters

$file
Image file name.
$src
Directory, one of 'src' or 'dest'.
$dest
Directory, one of 'src' or 'dest'.
$index
Index.
$sizes
Either an integer, or "preview". Default = "preview".
$data
Either some data (unclear) or 0. Default = 0.

Returns

string
HTML page (complete).
public string
# getThumbnail( string $file, string $dir )

Serves a certain file from the dest directory. Intended to serve jpg thumbails in combination with imgThumbnail.

Serves a certain file from the dest directory. Intended to serve jpg thumbails in combination with imgThumbnail.

Parameters

$file
Image file name.
$dir
Directory, either 'src' or 'dest'.

Returns

string
Served binary file.
public string
# getMovie( string $file, string $dir = "dest" )

Serves an existing AVI movie.

Serves an existing AVI movie.

Parameters

$file
Image file name.
$dir
Directory, either 'src' or 'dest'. Default is 'dest'.

Returns

string
Served binary file.
public boolean
# hasSelection( )

Returns true if at least one file is selected.

Returns true if at least one file is selected.

Returns

boolean
True if at least one file is selected.
public boolean
# folderContains( string $folder, string $filename )

Checks if a folder contains a given file name.

Checks if a folder contains a given file name.

Parameters

$folder
Folder name
$filename
File name.

Returns

boolean
True if the folder contains the file name.
public boolean
# folderContainsNewerFile( string $folder, string $date )

Checks if a folder contains newer files than a given date.

Checks if a folder contains newer files than a given date.

Parameters

$folder
Directory to be checked.
$date
Date string.

Returns

boolean
True if at least one file is more recent than date.
public array
# createHardLinksToSharedPSFs( array $psfFiles, string $targetUser )

Create hard links into the psf_sharing/buffer folder from the folder of the sharing user and return an array of full paths created links.

Create hard links into the psf_sharing/buffer folder from the folder of the sharing user and return an array of full paths created links.

Parameters

$psfFiles
Array of psf files paths relatives to current user.
$targetUser
name of the target user.

Returns

array
Array of destination PSF paths.
public array
# createHardLinksFromSharedPSFs( array $psfFiles, string $targetUser, string $previousUser )

Create hard links into the folder of the target user from the psf_sharing/buffer folder and return an array of full paths created links.

Create hard links into the folder of the target user from the psf_sharing/buffer folder and return an array of full paths created links.

Parameters

$psfFiles
array of psf files paths relatives to current user.
$targetUser
Name of the target user.
$previousUser
Name of the previous (source) user.

Returns

array
Array of destination PSF paths.
public static
# deleteSharedFSPFilesFromBuffer( array $psfFiles )

Delete PSF files (hard links) with given relative path from the psf_sharing/buffer folder.

Delete PSF files (hard links) with given relative path from the psf_sharing/buffer folder.

Parameters

$psfFiles
Array of PSF files paths relative to the file server root.
public static string|null
# findCompanionFile( string $file )

Given the name of either an ics or and ids file, returns the name of the companion.

Given the name of either an ics or and ids file, returns the name of the companion.

The companion file must exist.

Parameters

$file

File name with either .ics or .ids extension. The case might be different (e.g. .ICS).

Returns

string|null
Full fine name of the companion file, if it exist; NULL otherwise.
public array
# getPSFiles( )

Return all files with extension ".ics" and ".h5" found by recursive scan of the source folder.

Return all files with extension ".ics" and ".h5" found by recursive scan of the source folder.

Returns

array
Array of file names.
public static boolean|null
# is_dir_empty( string $dir )

Check if a directory is empty.

Check if a directory is empty.

Parameters

$dir
Full path to directory to check.

Returns

boolean|null

True if the directory is empty, False if it is not; False if it is not readable or does not exist.

Huygens Remote Manager API documentation generated by ApiGen