Class for new modul structere.

Saves the Modul-Input in a file (input.php) and Modul-Output in a file(output.php). All moduls of a clients are in [frontend]/modules/.

author rusmir.jusufovic

 Methods

Construct for the class cModuleHandler.

__construct(int $idmod) : void

With this class you can make a new Modul, rename a Modul. You can save a Output from Modul and Input in a file. The save rules are [Modulname] (is uneque) the files input and output will be named [Modulname]_input.php , [Modulname]_output.php

Parameters

$idmod

int

the id of the modul

Exceptions

\cException if the module directory can not be created

Set the new modul name.

changeModuleName($name) 
var

string

Parameters

$name

Make in all clients the module directory

createAllMainDirectories() : void

Exceptions

\cException if the frontend path can not be found or the module directory cann ot be created

Make a new module into the modul dir.

createModule($input, $output) : bool

The modul name will be [ModulName] example Contact_Form or GoogleMaps2.

Parameters

$input

$output

Returns

boolif modul exist or mkdir and saveInput and saveOutput success return true. Else if the mkdir or saveInput or saveOutput not success return false.

Make and save new file

createModuleFile(string $type, string $fileName, string $content) 

Parameters

$type

string

css | js | template directory of the file

$fileName

string

file name

$content

string

content of the file

Delete file

deleteFile(string $type, string $fileName) 

Parameters

$type

string

js |template | css directory of the file

$fileName

string

file name

Removes this module from the filesystem.

eraseModule() : bool

Also deletes the version files.

Returns

booltrue on success or false on failure

Check if exist a file

existFile(string $type, string $fileName) 

Parameters

$type

string

js | template | css the directory of the file

$fileName

string

file name

Get all files from a module directory

getAllFilesFromDirectory(string $moduleDirectory) : array

Parameters

$moduleDirectory

string

template css or js...

Returns

array

Get the cleaned name

getCleanName($name, $defaultChar) 
Static

Parameters

$name

$defaultChar

Get the main css file modulenam.css

getCssFileName() : string

Returns

string

Get the css path of the modul

getCssPath() : string

Returns

string

getEncoding()

getEncoding() 
Static

Get the content of file, modul js or css or template or php

getFilesContent(string $directory, string $fileTyp, $fileName) 

Parameters

$directory

string

where in module should we look

$fileTyp

string

css or js

$fileName

Get the name of the main js file (modulname.js)

getJsFileName() : string

Returns

stringthe name of the js file

Get the js path of the modul

getJsPath() : string

Returns

string

Get the Modul Path also cms path + module + module name.

getModulePath() : string

Returns

string

Get the php path of the modul

getPhpPath() : string

Returns

string

Get the template path.

getTemplatePath(string $file) : string

If file is set it will return the complete paht + file

Parameters

$file

string

Returns

string

Init the vars of the class.

initWithDatabaseRow($db) 

Parameters

$db

Can write/create a file

isWritable(string $fileName, string $directory) : \bool,

Parameters

$fileName

string

file name

$directory

string

directory where is the file

Returns

\bool,success true else false

Show if the Modul with the modul name exist in modul dir.

modulePathExists() 

return bool if the modul exist return true, else false

Exist the modulname in directory

modulePathExistsInDirectory(string $name) 

Parameters

$name

string

Read the input of the file _input.php

readInput() : string

Returns

stringContents of the Module file (_input.php)

Read the output of the file _output.php

readOutput() : string

Returns

stringContents of the Module file( _output.php)

Rename a modul and the input and output files.

renameModul(string $old, string $new) : bool

Parameters

$old

string

old name of the modul

$new

string

new name of the modul

Returns

booltrue if success

Rename a file

renameModuleFile(string $type, string $oldFileName, string $newFileName) : boolean

Parameters

$type

string

css | js | template directory of the file

$oldFileName

string

old name of the file

$newFileName

string

the new name of the file

Returns

booleanby success return true

Save a content in the file, use for css/js

saveContentToFile(\unknown_type $templateName, \unknown_type $fileType, \unknown_type $fileContent, $saveDirectory) : false

Parameters

$templateName

\unknown_type

$fileType

\unknown_type

$fileContent

\unknown_type

$saveDirectory

Returns

falseor string

This method save a xml file with modul information.

saveInfoXML(string $moduleName, string $description, string $type, $alias) : true

If the params not set, get the value from this

Parameters

$moduleName

string

name of the modul

$description

string

description of the modul

$type

string

type of the modul

$alias

Returns

trueif success else false

Save a string into the file (_input.php)

saveInput(string $input) : bool

Parameters

$input

string

Returns

boolif the action (save contents into the file _input.php is success) return true else false

Save a string into the file (_output.php).

saveOutput(string $output) : bool

Parameters

$output

string

Returns

boolif the action (save contents into the file _output.php is success) return true else false

setEncoding()

setEncoding($encoding) 
Static

Parameters

$encoding

Init the vars of the class, make a query to the Db

_initByModule(int $idmod) 

Parameters

$idmod

int

the id of the modul

_initWithDatabaseRow()

_initWithDatabaseRow($db) 
deprecated 2012-09-19 Use the public method initWithDatabaseRow instead!

Parameters

$db

Make main module directory.

_makeModuleDirectory() : boolean

Returns

boolean

Make a directory template/css/image/js/php if not exist

createModuleDirectory(string $type) 

Parameters

$type

string

Returns random characters

getRandomCharacters(integer $count) : string

Parameters

$count

integer

amount of characters

Returns

string

_rec_rmdir()

_rec_rmdir($path) 
deprecated 2012-09-10 Use cFileHandler::recursiveRmdir($dirname) instead

Parameters

$path

 Properties

 

$_cfg : array
 

$_cfgClient : array
 

$_client : int
 

$_description : string
 

$_directories : array
 

$_encoding : string
 

$_encodingStore 
 

$_fileEncoding : string

..) getEffectiveSetting('encoding', 'file_encoding','UTF-8')

 

$_idlang : int
 

$_idmod : int
 

$_input : string
 

$_moduleAlias : string
 

$_output : string
 

$_overrideEncoding 
 

$_type : string
 

$_db : \DB_Contenido
 

$_moduleName : string
 

$_modulePath : string
 

$_path : string