eZPublish  4.5
eZSys Class Reference

Easy access to various system settings. More...

Public Member Functions

 __construct (array $serverParams=null)
 Initializes the object with settings taken from the current script run. More...
 
 __get ($propertyName)
 Magic function to get access readonly properties (protected) More...
 
 __isset ($propertyName)
 Magic function to see if readonly properties (protected) exists. More...
 
 attribute ($attr)
 
 attributes ()
 
 hasAttribute ($attr)
 

Static Public Member Functions

static addAccessPath ($path, $name= 'undefined', $siteaccess=true)
 Appends the access path (parts of url that identifies siteaccess), used by eZSys::indexFile() NOTE: Does not make sense to use for siteaccess, as you would want to clear current path and set new one normally, so preferably use eZSys::setAccessPath() in this case. More...
 
static backupFilename ()
 
static cacheDirectory ()
 
static clearAccessPath ($siteaccess=true)
 Clears the access path, used by eZSys::indexFile(). More...
 
static createShellArgument ($argumentText, $replaceList)
 
static environmentVariable ($variableName, $quiet=false)
 Return the variable named $variableName in the global ENV variable. More...
 
static envSeparator ()
 
static escapeShellArgument ($argument)
 
static ezcrc32 ($string)
 
static fileSeparator ()
 
static filesystemType ()
 
static globBrace ($pattern, $flags=0)
 
static hasEnvironmentVariable ($variableName)
 
static hostname ()
 
static indexDir ($withAccessList=true)
 
static indexFile ($withAccessPath=true)
 
static indexFileName ()
 
static init ($index= 'index.php', $forceVirtualHost=null)
 Initializes some variables according to some global PHP values. More...
 
static instance ()
 Returns a shared instance of the eZSys class. More...
 
static isDebugEnabled ()
 Return true if debugging of internals is enabled, this will display which server variables are read. More...
 
static isPHPVersionSufficient ($requiredVersion)
 Return true if the PHP version is equal or higher than $requiredVersion. More...
 
static isShellExecution ()
 
static isSSLNow ()
 
static lineSeparator ()
 
static magickQuotes ()
 Returns true if magick quotes is enabled, but does nothing. More...
 
static mergeArgumentElements ($argumentElements)
 
static osName ()
 
static osType ()
 
static path ($quiet=false)
 
static phpVersion ()
 Return the PHP version as an array with the version elements. More...
 
static phpVersionText ()
 The PHP version as text. More...
 
static protocolSchema ()
 
static removeMagicQuotes ()
 Removes magic quotes. More...
 
static requestURI ()
 
static rootDir ()
 
static serverPort ()
 
static serverProtocol ()
 
static serverURL ()
 
static serverVariable ($variableName, $quiet=false)
 
static setAccessPath (array $path=array(), $name= 'undefined', $siteaccess=true)
 Set access path (parts of url that identifies siteaccess), used by eZSys::indexFile(). More...
 
static setEnvironmentVariable ($variableName, $variableValue)
 
static setInstance (eZSys $instance=null)
 Sets eZSys instance or clears it if left undefined. More...
 
static setIsDebugEnabled ($debug)
 Sets whether internal debugging is enabled or not. More...
 
static setServerVariable ($variableName, $variableValue)
 
static siteDir ()
 
static splitArgumentIntoElements ($argumentText)
 
static storageDirectory ()
 
static varDirectory ()
 
static wwwDir ()
 

Public Attributes

 $EnvSeparator
 
 $FileSeparator
 
 $FileSystemType
 
 $IndexFile
 
 $LineSeparator
 
 $OSType
 
 $RequestURI
 
 $RootDir
 
 $ShellEscapeCharacter
 
 $SiteDir
 
 $WWWDir
 

Static Protected Member Functions

static getValidwwwDir ($phpSelf, $scriptFileName, $index)
 Generate wwwdir from phpSelf if valid accoring to scriptFileName and return null if invalid and false if there is no index in phpSelf. More...
 
static simulateGlobBrace ($filenames)
 

Protected Attributes

 $AccessPath
 
 $Params = null
 

Static Protected Attributes

static $instance = null
 

Detailed Description

Easy access to various system settings.

The system is checked to see whether a virtualhost-less setup is used and sets the appropriate variables which can be fetched with siteDir(), wwwDir() and indexFile(). It also detects file and enviroment separators, fetch them with fileSeparator() and envSeparator().

Example:

// Run the init in the index file
eZSys::init( 'index.php', $ini->variable( 'SiteAccessSettings', 'ForceVirtualHost' ) === 'true' );
print( eZSys::indexFile() );
print( eZSys::wwwDir() );

Constructor & Destructor Documentation

eZSys::__construct ( array  $serverParams = null)

Initializes the object with settings taken from the current script run.

Parameters
array | null$serverParamsFor unit testing use, see first few lines for content

Member Function Documentation

eZSys::__get (   $propertyName)

Magic function to get access readonly properties (protected)

Parameters
string$name
Returns
mixed
Exceptions
ezcBasePropertyNotFoundException
eZSys::__isset (   $propertyName)

Magic function to see if readonly properties (protected) exists.

Parameters
string$propertyNameOption name to check for.
Returns
bool Whether the option exists.
static eZSys::addAccessPath (   $path,
  $name = 'undefined',
  $siteaccess = true 
)
static

Appends the access path (parts of url that identifies siteaccess), used by eZSys::indexFile() NOTE: Does not make sense to use for siteaccess, as you would want to clear current path and set new one normally, so preferably use eZSys::setAccessPath() in this case.

Parameters
array | string$path
string$nameAn identifer of the name of the path provided $AccessPath
bool$siteaccessHints if path is siteaccess related or not, needed in case subsequesnt code suddenly changes siteaccess and needs to clear siteaccess scope
eZSys::attribute (   $attr)

Returns the attribute value for $attr or null if the attribute does not exist.

eZSys::attributes ( )

Referenced by hasAttribute().

static eZSys::backupFilename ( )
static
Returns
the backup filename for this platform, returns .bak for win32 and ~ for unix and mac.

Referenced by eZCodeTemplate\apply(), and eZINI\save().

static eZSys::clearAccessPath (   $siteaccess = true)
static

Clears the access path, used by eZSys::indexFile().

Referenced by eZSiteAccess\change().

static eZSys::createShellArgument (   $argumentText,
  $replaceList 
)
static

Replaces % elements in the argument text $argumentText using the replace list $replaceList. It will also properly escape the argument.

See Also
splitArgumentIntoElements, mergeArgumentElements

Referenced by eZImageShellHandler\convert(), and eZImageHandler\convertFilterToText().

static eZSys::environmentVariable (   $variableName,
  $quiet = false 
)
static

Return the variable named $variableName in the global ENV variable.

If the variable is not present an error is shown and null is returned.

Referenced by eZSetupTestFileUpload().

static eZSys::envSeparator ( )
static

Returns the string which is used for enviroment separators on the current OS (server).

Referenced by eZSetupCheckExecutable().

static eZSys::escapeShellArgument (   $argument)
static

Escape a string to be used as a shell argument and return it.

Referenced by eZImageShellHandler\convert().

static eZSys::fileSeparator ( )
static

Returns the string which is used for file separators on the current OS (server).

Referenced by eZImageShellHandler\convert(), eZSetupPrvtAreDirAndFilesWritable(), eZDir\isWriteable(), and eZDir\separator().

static eZSys::filesystemType ( )
static
Returns
the filesystem type, either "win32" or "unix"

Referenced by eZStepEmailSettings\display(), eZSetupCheckExecutable(), and eZStepEmailSettings\init().

static eZSys::getValidwwwDir (   $phpSelf,
  $scriptFileName,
  $index 
)
staticprotected

Generate wwwdir from phpSelf if valid accoring to scriptFileName and return null if invalid and false if there is no index in phpSelf.

Parameters
string$phpSelf
string$scriptFileName
string$index
Returns
string|null|false String in form 'path/path2' if valid, null if not and false if $index is not part of phpself
static eZSys::globBrace (   $pattern,
  $flags = 0 
)
static

Wraps around the built-in glob() function to provide same functionality for systems (e.g Solaris) that does not support GLOB_BRACE.

Referenced by eZFS2FileHandler\fileDeleteByDirList(), eZFSFileHandler\fileDeleteByDirList(), and eZFSFileHandler\fileDeleteByWildcard().

eZSys::hasAttribute (   $attr)

Return true if the attribute $attr is set. Available attributes are wwwdir, sitedir or indexfile

static eZSys::hasEnvironmentVariable (   $variableName)
static
Returns
the true if variable named $variableName exists. If the variable is not present false is returned.

Referenced by eZSetupTestFileUpload().

static eZSys::indexFile (   $withAccessPath = true)
static
static eZSys::indexFileName ( )
static

The filepath for the index file.

Referenced by eZSiteInstaller\createSiteaccessUrls(), and eZStepSecurity\init().

static eZSys::init (   $index = 'index.php',
  $forceVirtualHost = null 
)
static

Initializes some variables according to some global PHP values.

This function should be called once in the index file with the parameters stated in the parameter list.

Parameters
string$indexThe current index file, needed for virtual host mode detection.
bool$forceVirtualHostVirtual host mode is normally autodetected, but if not this can be forced by setting this to true.
static eZSys::isDebugEnabled ( )
static

Return true if debugging of internals is enabled, this will display which server variables are read.

Set the option with setIsDebugEnabled().

Deprecated:
Since 4.5, not used
Returns
bool
static eZSys::isPHPVersionSufficient (   $requiredVersion)
static

Return true if the PHP version is equal or higher than $requiredVersion.

Use: eZSys::isPHPVersionSufficient( array( 4, 1, 0 ) );

Deprecated:
Since 4.5
Parameters
array$requiredVersionMust be an array with version number
Returns
bool
static eZSys::isShellExecution ( )
static

Determins if the script got executed over the web or the shell/commandoline.

Referenced by eZDebug\isAllowedByCurrentIP(), eZContentOperationCollection\publishNode(), and eZDBInterface\reportError().

static eZSys::isSSLNow ( )
static

Determines if SSL is enabled and protocol HTTPS is used.

Returns
true if current access mode is HTTPS.

Referenced by eZSSLZone\switchIfNeeded().

static eZSys::lineSeparator ( )
static

Returns the string which is used for line separators on the current OS (server).

Referenced by eZINI\save().

static eZSys::magickQuotes ( )
static

Returns true if magick quotes is enabled, but does nothing.

Deprecated:
since 4.5
static eZSys::mergeArgumentElements (   $argumentElements)
static

Merges an argument list created by splitArgumentIntoElements() back into a text string. The argument text will be properly quoted.

static eZSys::osName ( )
static
Returns
the name of the specific os or false if it could not be determined. Currently detects:
  • windows (win32)
  • mac (mac)
  • linux (unix)
  • freebsd (unix)
static eZSys::path (   $quiet = false)
static
Returns
the path string for the server.

Referenced by eZSetupCheckExecutable().

static eZSys::phpVersion ( )
static

Return the PHP version as an array with the version elements.

Deprecated:
Since 4.5
Returns
array
static eZSys::phpVersionText ( )
static

The PHP version as text.

Deprecated:
Since 4.5, use PHP_VERSION
Returns
string
static eZSys::protocolSchema ( )
static

Returns the schema of the request.

static eZSys::removeMagicQuotes ( )
static

Removes magic quotes.

Deprecated:
Since 4.5, magic quotes setting has been deprecated in PHP 5.3

Referenced by eZPaymentCallbackChecker\createDataFromPOST().

static eZSys::requestURI ( )
static
Returns
the URI used for parsing modules, views and parameters, may differ from $_SERVER['REQUEST_URI'].

Referenced by eZURI\instance(), eZUser\instance(), and eZSSLZone\switchIfNeeded().

static eZSys::rootDir ( )
static

The absolute path to the root directory.

Referenced by checkPaths(), eZSetupTestDirectoryPermissions(), and eZDir\recursiveDelete().

static eZSys::serverPort ( )
static
Returns
the port of the server.

Referenced by eZHTTPTool\createRedirectUrl().

static eZSys::serverProtocol ( )
static

Referenced by extension_path().

static eZSys::serverURL ( )
static

Returns the server URL. (protocol with hostname and port)

static eZSys::serverVariable (   $variableName,
  $quiet = false 
)
static
static eZSys::setAccessPath ( array  $path = array(),
  $name = 'undefined',
  $siteaccess = true 
)
static

Set access path (parts of url that identifies siteaccess), used by eZSys::indexFile().

Parameters
array$path
string$nameAn identifer of the name of the path provided $AccessPath
bool$siteaccessHints if path is siteaccess related or not, needed in case subsequesnt code suddenly changes siteaccess and needs to clear siteaccess scope

Referenced by eZSiteAccess\change().

static eZSys::setEnvironmentVariable (   $variableName,
  $variableValue 
)
static

Sets the environment variable named $variableName to $variableValue.

Note
Variables are only set for the current page view.
static eZSys::setInstance ( eZSys  $instance = null)
static

Sets eZSys instance or clears it if left undefined.

Parameters
eZSys$instance
static eZSys::setIsDebugEnabled (   $debug)
static

Sets whether internal debugging is enabled or not.

Deprecated:
Since 4.5, has not effect anymore
Parameters
bool$debug
static eZSys::setServerVariable (   $variableName,
  $variableValue 
)
static

Sets the server variable named $variableName to $variableValue.

Note
Variables are only set for the current page view.
static eZSys::simulateGlobBrace (   $filenames)
staticprotected

Expands a list of filenames like GLOB_BRACE does.

GLOB_BRACE is non POSIX and only available in GNU glibc. This is needed to support operating systems like Solars.

static eZSys::siteDir ( )
static

The path to where all the code resides.

Referenced by attribute().

static eZSys::splitArgumentIntoElements (   $argumentText)
static

Splits the argument text into argument array elements. It will split text on spaces and set them as strings in the array, spaces will be counted and inserted as integers with the space count. Text placed in quotes will also be parsed, this allows for spaces in the text.

$list = splitArgumentIntoElements( "-geometry 100x100" );
var_dump( $list ); // will give: array( "-geometry", 1, "100x100" );

You can then easily modify the elements separately and create the argument text with mergeArgumentElements().

static eZSys::varDirectory ( )
static

Member Data Documentation

eZSys::$AccessPath
protected

Referenced by __get().

eZSys::$EnvSeparator
eZSys::$FileSeparator
eZSys::$FileSystemType
eZSys::$IndexFile

Referenced by init().

eZSys::$instance = null
staticprotected
eZSys::$LineSeparator
eZSys::$OSType
eZSys::$Params = null
protected
eZSys::$RequestURI
eZSys::$RootDir
eZSys::$ShellEscapeCharacter
eZSys::$SiteDir
eZSys::$WWWDir

The documentation for this class was generated from the following file: