TYPO3CMS  8
 All Classes Namespaces Files Functions Variables Pages
CommandUtility Class Reference

Static Public Member Functions

static exec ($command, &$output=null, &$returnValue=0)
 
static imageMagickCommand ($command, $parameters, $path= '')
 
static checkCommand ($cmd, $handler= '')
 
static getCommand ($cmd, $handler= '', $handlerOpt= '')
 
static addPaths ($paths)
 
static getPaths ($addInvalid=false)
 
static escapeShellArguments (array $input)
 
static escapeShellArgument ($input)
 

Static Protected Member Functions

static init ()
 
static initPaths ($paths= '')
 
static getConfiguredApps ()
 
static getPathsInternal ()
 
static fixPath ($path)
 

Static Protected Attributes

static $initialized = false
 
static $applications = []
 
static $paths = null
 

Detailed Description

Class to handle system commands. finds executables (programs) on Unix and Windows without knowing where they are

returns exec command for a program or FALSE

This class is meant to be used without instance: $cmd = CommandUtility::getCommand ('awstats','perl');

The data of this class is cached. That means if a program is found once it don't have to be searched again.

user functions:

addPaths() could be used to extend the search paths getCommand() get a command string checkCommand() returns TRUE if a command is available

Search paths that are included: $TYPO3_CONF_VARS['GFX']['processor_path_lzw'] or $TYPO3_CONF_VARS['GFX']['processor_path'] $TYPO3_CONF_VARS['SYS']['binPath'] $GLOBALS['_SERVER']['PATH'] '/usr/bin/,/usr/local/bin/' on Unix

binaries can be preconfigured with $TYPO3_CONF_VARS['SYS']['binSetup']

Definition at line 45 of file CommandUtility.php.

Member Function Documentation

static addPaths (   $paths)
static

Extend the preset paths. This way an extension can install an executable and provide the path to

Parameters
string$pathsComma separated list of extra paths where a command should be searched. Relative paths (without leading "/") are prepend with site root path (PATH_site).
Returns
void

Definition at line 250 of file CommandUtility.php.

References CommandUtility\$paths.

static checkCommand (   $cmd,
  $handler = '' 
)
static

Checks if a command is valid or not, updates global variables

Parameters
string$cmdThe command that should be executed. eg: "convert"
string$handlerExecuter for the command. eg: "perl"
Returns
bool FALSE if cmd is not found, or -1 if the handler is not found

Definition at line 147 of file CommandUtility.php.

Referenced by ExtensionManagementUtility\isServiceAvailable().

static escapeShellArgument (   $input)
static

Escape a shell argument (for example a filename) to be used on the local system.

The setting UTF8filesystem will be taken into account.

Parameters
string$inputInput-argument to be escaped
Returns
string Escaped shell argument

Definition at line 462 of file CommandUtility.php.

Referenced by GraphicalFunctions\combineExec(), GraphicalFunctions\imageMagickExec(), and GraphicalFunctions\imageMagickIdentify().

static escapeShellArguments ( array  $input)
static

Escape shell arguments (for example filenames) to be used on the local system.

The setting UTF8filesystem will be taken into account.

Parameters
string[]$input Input arguments to be escaped
Returns
string[] Escaped shell arguments

Definition at line 437 of file CommandUtility.php.

References $GLOBALS.

Referenced by PreviewProcessing\resizeImage().

static fixPath (   $path)
staticprotected

Set a path to the right format

Parameters
string$pathInput path
Returns
string Output path

Definition at line 424 of file CommandUtility.php.

static getCommand (   $cmd,
  $handler = '',
  $handlerOpt = '' 
)
static

Returns a command string for exec(), system()

Parameters
string$cmdThe command that should be executed. eg: "convert"
string$handlerHandler (executor) for the command. eg: "perl"
string$handlerOptOptions for the handler, like '-w' for "perl"
Returns
mixed Returns command string, or FALSE if cmd is not found, or -1 if the handler is not found

Definition at line 219 of file CommandUtility.php.

Referenced by CommandLineBackend\__construct().

static getConfiguredApps ( )
staticprotected

Processes and returns the paths from $GLOBALS['TYPO3_CONF_VARS']['SYS']['binSetup']

Returns
array Array of commands and path

Definition at line 347 of file CommandUtility.php.

References $GLOBALS, and GeneralUtility\trimExplode().

static getPaths (   $addInvalid = false)
static

Returns an array of search paths

Parameters
bool$addInvalidIf set the array contains invalid path too. Then the key is the path and the value is empty
Returns
array Array of search paths (empty if exec is disabled)

Definition at line 261 of file CommandUtility.php.

References CommandUtility\$paths.

Referenced by ServicesListReport\getExecutablesSearchPathList().

static getPathsInternal ( )
staticprotected

Sets the search paths from different sources, internal

Returns
array Array of absolute paths (keys and values are equal)

Definition at line 373 of file CommandUtility.php.

References $GLOBALS, and GeneralUtility\trimExplode().

static imageMagickCommand (   $command,
  $parameters,
  $path = '' 
)
static

Compile the command for running ImageMagick/GraphicsMagick.

Parameters
string$commandCommand to be run: identify, convert or combine/composite
string$parametersThe parameters string
string$pathOverride the default path (e.g. used by the install tool)
Returns
string Compiled command that deals with ImageMagick & GraphicsMagick

Definition at line 94 of file CommandUtility.php.

References $GLOBALS, GeneralUtility\fixWindowsFilePath(), and GeneralUtility\unQuoteFilenames().

Referenced by GraphicalFunctions\combineExec(), TestSetup\determineImageMagickVersion(), GraphicalFunctions\gifCompress(), GeneralUtility\imageMagickCommand(), GraphicalFunctions\imageMagickExec(), GraphicalFunctions\imageMagickIdentify(), GraphicalFunctions\readPngGif(), and PreviewProcessing\resizeImage().

static init ( )
staticprotected

Initializes this class

Returns
bool

Definition at line 284 of file CommandUtility.php.

References $GLOBALS.

static initPaths (   $paths = '')
staticprotected

Initializes and extends the preset paths with own

Parameters
string$pathsComma separated list of extra paths where a command should be searched. Relative paths (without leading "/") are prepend with site root path (PATH_site).
Returns
void

Definition at line 303 of file CommandUtility.php.

References CommandUtility\$paths, and GeneralUtility\trimExplode().

Member Data Documentation

$applications = []
staticprotected

Definition at line 63 of file CommandUtility.php.

$initialized = false
staticprotected

Definition at line 52 of file CommandUtility.php.

$paths = null
staticprotected