Public Member Functions | Public Attributes

BeSystem Class Reference

BeSystem class handle BEdita system utility methods. More...

List of all members.

Public Member Functions

 checkAppDirPresence ($dirPath)
 Check whether directory $dirPath exists.
 checkAppFilePresence ($filePath)
 Check whether file $filePath exists.
 checkAppDirPerms ($dirPath, $mask=511)
 Check permissions for directory.
 createFileFromSample ($filePath)
 Create file $filePath from $filePath.sample.
 checkWritable ($filename)
 Check whether file $filename is writable.
 emptyLogs ($filename=null, $basePath=LOGS)
 delete log files
 cleanupCache ($basePath=TMP, $frontendsToo=true, $cleanAll=false)
 cleanup cached files
 cleanUpDir ($basePath, $recursive=false, $removeDirs=false)
 clean directory deleting files and eventully subdirs
 writeConfigFile ($filepath, array $dataToWrite, $insertNewVar=false)
 edit cakephp config file
 writePHPfile ($filepath, array $dataToWrite, $insertNewVar=true)
 edit an existing php file writing data from $dataToWrite array
 checkFileSyntax ($fileName)
 Check for syntax error in file.
 checkCodeSyntax ($sourceCode, $addPHPtag=false)
 Return true if no syntax errors are present in $sourceCode.
 systemUserId ()
 Get system user ID.

Public Attributes

const SYSTEM_USER_ID = 1
 System user ID, created on setup.

Detailed Description

BeSystem class handle BEdita system utility methods.

Version:
$Revision$ $LastChangedBy$ $LastChangedDate$

$Id$

Definition at line 38 of file be_system.php.


Member Function Documentation

BeSystem::checkAppDirPerms ( dirPath,
mask = 511 
)

Check permissions for directory.

Parameters:
string $dirPath
int $mask
Returns:
string

Definition at line 72 of file be_system.php.

BeSystem::checkAppDirPresence ( dirPath  ) 

Check whether directory $dirPath exists.

Parameters:
string $dirPath
Returns:
boolean

Definition at line 51 of file be_system.php.

BeSystem::checkAppFilePresence ( filePath  ) 

Check whether file $filePath exists.

Parameters:
string $filePath
Returns:
boolean

Definition at line 61 of file be_system.php.

BeSystem::checkCodeSyntax ( sourceCode,
addPHPtag = false 
)

Return true if no syntax errors are present in $sourceCode.

To check syntax it uses BeSystem::checkFileSyntax() Since 'php -l' works against files a temporary file is created in (bedita-app/tmp) and removed only if the check is correct. If BeSystem::checkFileSyntax() or file creation fails the method returns false

See also:
BeSystem::checkFileSyntax()
Parameters:
array|string $sourceCode the source code to test
boolean $addPHPtag true to add '<?php' at the begin of $sourceCode
Returns:
boolean

Definition at line 411 of file be_system.php.

References checkFileSyntax().

Referenced by writePHPfile().

BeSystem::checkFileSyntax ( fileName  ) 

Check for syntax error in file.

To check syntax it uses 'php -l' command (cli)

Parameters:
string $fileName the complete file name
Returns:
boolean true on check success

Definition at line 386 of file be_system.php.

Referenced by checkCodeSyntax().

BeSystem::checkWritable ( filename  ) 

Check whether file $filename is writable.

Parameters:
string $filename

Definition at line 92 of file be_system.php.

Referenced by writePHPfile().

BeSystem::cleanupCache ( basePath = TMP,
frontendsToo = true,
cleanAll = false 
)

cleanup cached files

Parameters:
string $basePath, base path on which build cake cache dir and smarty cache dir
bool $frontendsToo, true (default) to delete also all frontends cached files
bool $cleanAll, false (default) clean all folders in tmp/cache not just 'models', 'persistent' and 'views'
Returns:
array, it contains 'failed' => array of errors, empty if no errors occured 'success' => array deleted files

Definition at line 131 of file be_system.php.

References cleanUpDir().

BeSystem::cleanUpDir ( basePath,
recursive = false,
removeDirs = false 
)

clean directory deleting files and eventully subdirs

Parameters:
string $basePath, the starting directory path
boolean $recursive, true to deleting files recursively on subdirs
boolean $removeDirs, true to remove all subdirs too
Returns:
array, it contains 'failed' => array of errors, empty if no errors occured 'success' => array of file deleted

Definition at line 207 of file be_system.php.

Referenced by cleanupCache(), and emptyLogs().

BeSystem::createFileFromSample ( filePath  ) 

Create file $filePath from $filePath.sample.

Parameters:
string $filePath
Returns:
boolean

Definition at line 82 of file be_system.php.

BeSystem::emptyLogs ( filename = null,
basePath = LOGS 
)

delete log files

Parameters:
string $filename, filename to delete i.e. error.log
string $basePath, path to file (default is logs path)
Returns:
array, it contains 'failed' => array of errors, empty if no errors occured 'success' => array of file deleted

Definition at line 105 of file be_system.php.

References cleanUpDir().

BeSystem::systemUserId (  ) 

Get system user ID.

Returns:
int
See also:
BeSystem::SYSTEM_USER_ID

Definition at line 587 of file be_system.php.

BeSystem::writeConfigFile ( filepath,
array $  dataToWrite,
insertNewVar = false 
)

edit cakephp config file

Parameters:
type $filepath
array $dataToWrite (see BeSystem::writePHPfile)
boolean $insertNewVar, if 'true' write new var (if not already in config file)
Returns:
mixed true on success

Definition at line 264 of file be_system.php.

References writePHPfile().

BeSystem::writePHPfile ( filepath,
array $  dataToWrite,
insertNewVar = true 
)

edit an existing php file writing data from $dataToWrite array

Parameters:
string $filepath
array $dataToWrite example of $dataToWrite 1) "config" => array( "beditaUrl" => "http://localhost/workspace/bedita", 'smtpOptions'=> array( 'port' => '25', 'timeout' => '30', 'host' => 'your.smtp.server', 'username' => 'your_smtp_username', 'password' => 'your_smtp_password' ), ... )

will be generate var as $config['beditaUrl'] = 'http://localhost/workspace/bedita'; ...

2) "myvar" => "this is my var"

will be generate var as $myvar = 'this is my var';

Parameters:
boolean $insertNewVar true to permitt writing new var (not already present in original file)
Returns:
mixed true on success

Definition at line 303 of file be_system.php.

References checkCodeSyntax(), and checkWritable().

Referenced by writeConfigFile().


The documentation for this class was generated from the following file:
Generated on Fri Dec 11 2015 15:29:46 by Doxygen 1.7.1  BEditaBEdita 3.7 Corylus