contenido\includes\functions.general.php
Description: Defines the general contenido functions
Requirements:
- Author
- Jan Lengowski
- Con_php_req
- 5.0
- Copyright
- four for business AG
- License
- http://www.contenido.org/license/LIZENZ.txt
- Link
- http://www.4fb.de
- Link
- http://www.contenido.org
- Package
- Contenido Backend includes
- Since
- file available since contenido release <= 4.6 {@internal created unknown modified 2008-06-26, Frederic Schneider, add security fix modified 2008-07-03, Dominik Ziegler, fixed bug CON-143 modified 2009-02-15, Murat Purc, fixed bug CON-238 modified 2010-09-29, Ortwin Pinke, fixed bug CON-349 modified 2010-12-16, Dominik Ziegler, display error message on database connection failure [#CON-376] $Id: functions.general.php 1246 2010-12-16 13:13:04Z dominik.ziegler $: }}
- Version
- 1.3.4
Constants
Functions
SaveKeywordsforart( $keycode, $idart, $place, $lang) : void| Name | Type | Description |
|---|---|---|
| $keycode | ||
| $idart | ||
| $place | ||
| $lang |
- Deprecated
- since 22.08.2005 This function is called everytime when the code of an article is generated. In this case indexing can cause performance problems. Indexing an article is treated now in function conSaveContentEntry.
addArtspec(string $artspectext, $online) : voidadd new article specification
| Name | Type | Description |
|---|---|---|
| $artspectext | string | article specification text |
| $online |
array_search_recursive( $search, $array, $partial = false, $strict = false) : void| Name | Type | Description |
|---|---|---|
| $search | ||
| $array | ||
| $partial | ||
| $strict |
backToMainArea(bool $send) : voidRedirect to main area
| Name | Type | Description |
|---|---|---|
| $send | bool | Redirect Yes/No |
- Author
- Jan Lengowski
- Copyright
- four for business AG
buildArticleSelect(String $sName, String $iIdCat, $sValue) : StringBuild a Article select Box
| Name | Type | Description |
|---|---|---|
| $sName | String | Name of the SelectBox |
| $iIdCat | String | Value of the SelectBox |
| $sValue |
| Type | Description |
|---|---|
| String | HTML |
buildCategorySelect(String $sName, String $sValue, Integer $sLevel = 0, String $sStyle = "") : StringBuild a Category / Article select Box
| Name | Type | Description |
|---|---|---|
| $sName | String | Name of the SelectBox |
| $sValue | String | Value of the SelectBox |
| $sLevel | Integer | Value of highest level that should be shown |
| $sStyle | String | Optional style informations for select |
| Type | Description |
|---|---|
| String | HTML |
cDie( $file, $line, $message) : voidcDie: Contenido die-alternative
| Name | Type | Description |
|---|---|---|
| $file | File name (use FILE) | |
| $line | Line number (use LINE) | |
| $message | Message to display |
cError( $file, $line, $message) : voidcError: Contenido error
| Name | Type | Description |
|---|---|---|
| $file | File name (use FILE) | |
| $line | Line number (use LINE) | |
| $message | Message to display |
cInitializeArrayKey( $aArray, $sKey, $mDefault = "") : void| Name | Type | Description |
|---|---|---|
| $aArray | ||
| $sKey | ||
| $mDefault |
cWarning( $file, $line, $message) : voidcWarning: Contenido warning
| Name | Type | Description |
|---|---|---|
| $file | File name (use FILE) | |
| $line | Line number (use LINE) | |
| $message | Message to display |
callPluginStore( $entity) : voidcallPluginStore: Calls the plugin's store methods
Example: callPluginStore("frontendusers");
| Name | Type | Description |
|---|---|---|
| $entity | Name of the directory to scan |
createRandomName( $nameLength) : stringcreateRandomName: Creates a random name (example: Passwords)
Example: echo createRandomName(8);
| Name | Type | Description |
|---|---|---|
| $nameLength | Length of the generated string |
| Type | Description |
|---|---|
| string | random name |
deleteArtspec(integer $idartspec) : voiddelete specified article specification
| Name | Type | Description |
|---|---|---|
| $idartspec | integer | article specification id |
deleteSystemProperty(string $type, string $name) : voidRemove a system property entry
| Name | Type | Description |
|---|---|---|
| $type | string | The type of the item |
| $name | string | The name of the item |
endAndLogTiming(\uuid $uuid) : voidendAndLogTiming: Ends the timing process and logs it to the timings file
| Name | Type | Description |
|---|---|---|
| $uuid | \uuid | int UUID which has been used for timing |
file_get_contents( $filename, $use_include_path = 0) : void| Name | Type | Description |
|---|---|---|
| $filename | ||
| $use_include_path |
getArtspec() : arrayretrieve list of article specifications for current client and language
| Type | Description |
|---|---|
| array | list of article specifications |
getAvailableContentTypes(int $idartlang) : voidExtracts the available content- types from the database
Creates an array $a_content[type][number] = content string f.e. $a_content['CMS_HTML'][1] = content string Same for array $a_description
| Name | Type | Description |
|---|---|---|
| $idartlang | int | Language specific ID of the arcticle |
- Author
- Jan Lengowski
- Copyright
- four for business AG
getCanonicalDay(integer $iDay) : stringGet multi-language day
| Name | Type | Description |
|---|---|---|
| $iDay | integer | the day number of date(w) |
| Type | Description |
|---|---|
| string | Dayname of current language |
getClientName( $idclient) : stringgetClientName: Returns the client name for a given ID
| Name | Type | Description |
|---|---|---|
| $idclient |
| Type | Description |
|---|---|
| string | client name |
getEffectiveSetting(string $type, string $name, string $default = "") : mixedReturns the current effective setting for a property.
The order is: System => Client => Group => User
System properties can be overridden by the group, and group properties can be overridden by the user.
| Name | Type | Description |
|---|---|---|
| $type | string | The type of the item |
| $name | string | The name of the item |
| $default | string | Optional default value |
| Type | Description |
|---|---|
| mixed | boolean false if nothing was found |
getEffectiveSettingsByType( $sType) : arrayReturns the current effective settings for a type of properties.
The order is: System => Client => Group => User
System properties can be overridden by the group, and group properties can be overridden by the user.
| Name | Type | Description |
|---|---|---|
| $sType |
| Type | Description |
|---|---|
| array | Value |
getFileExtension(string $filename) : \extensiongetFileExtension Returns the file extension of a given file
| Name | Type | Description |
|---|---|---|
| $filename | string | Name of the file |
| Type | Description |
|---|---|
| \extension | on success, false if no extension could be extracted. |
getNamedFrame( $frame) : stringgetNamedFrame: Returns the name of the numeric frame given
| Name | Type | Description |
|---|---|---|
| $frame | Frame number |
| Type | Description |
|---|---|
| string | Canonical name of the frame |
getPhpModuleInfo( $moduleName) : arraygetPhpModuleInfo - parses phpinfo() output
parses phpinfo() output (1) get informations for a specific module (parameter $modulname) (2) get informations for all modules (no parameter for $modulname needed)
if a specified extension doesn't exists or isn't activated an array will be returned: Array ( [error] => extension is not available )
to get specified information on one module use (1): getPhpModuleInfo($moduleName = 'gd');
to get all informations use (2): getPhpModuleInfo($moduleName);
EXAMPLE OUTPUT (1): Array ( [GD Support] => Array ( [0] => enabled ) ... )
EXAMPLE OUTPUT (2): Array ( [yp] => Array ( [YP Support] => Array ( [0] => enabled )
)
... }
foreach ($moduleSettings as $setting => $value) $setting contains the modul settings $value contains the settings as an array ($value[0] => Local Value && $value[1] => Master Value)
| Name | Type | Description |
|---|---|---|
| $moduleName |
| Type | Description |
|---|---|
| array | see above for example |
- Author
- Marco Jahn
getSystemProperties(boolean $bGetPropId = 0) : arrayRetrieves all available system properties.
Array format:
$array[$type][$name] = $value;
| Name | Type | Description |
|---|---|---|
| $bGetPropId | boolean | bGetPropId - if true special mode is activated which generates for each property a third array, which also contains idsystemprop value |
| Type | Description |
|---|---|
| array |
- Modified
- Timo Trautmann 22.02.2008 Support for editing name and type editing by primaray key idsystemprop if bGetPropId is set: $array[$type][$name][value] = $value; $array[$type][$name][idsystemprop] = $idsystemprop;
getSystemPropertiesByType( $sType) : arrayGets system property entries
| Name | Type | Description |
|---|---|---|
| $sType |
| Type | Description |
|---|---|
| array | Value |
getSystemProperty(string $type, string $name) : mixedGets a system property entry
| Name | Type | Description |
|---|---|---|
| $type | string | The type of the item |
| $name | string | The name of the item |
| Type | Description |
|---|---|
| mixed | boolean false if nothing was found, or |
includePlugins( $entity) : voidincludePlugins: Includes plugins for a given entity
Example: includePlugins("frontendusers");
| Name | Type | Description |
|---|---|---|
| $entity | Name of the directory to scan |
isImageMagickAvailable() : booleanisImageMagickAvailable - checks if ImageMagick is available
| Type | Description |
|---|---|
| boolean | true if ImageMagick is available |
isRunningFromWeb() : booleanisRunningFromWeb - checks if the script is being runned from the web
| Type | Description |
|---|---|
| boolean | true if the script is running from the web |
is_alphanumeric(Mixed $test, Bool $umlauts = true) : BoolChecks if a value is alphanumeric
| Name | Type | Description |
|---|---|---|
| $test | Mixed | Value to test |
| $umlauts | Bool | [Use german Umlaute] Optional |
| Type | Description |
|---|---|
| Bool | Value is alphanumeric |
markSubMenuItem(int $menuitem, bool $return = false) : voidWrite JavaScript to mark
| Name | Type | Description |
|---|---|---|
| $menuitem | int | Which menuitem to mark |
| $return | bool | Return or echo script |
- Author
- Jan Lengowski
- Copyright
- four for business AG
notifyOnError( $errortitle, $errormessage) : void| Name | Type | Description |
|---|---|---|
| $errortitle | ||
| $errormessage |
scanDirectory( $sDirectory, $bRecursive = false) : void| Name | Type | Description |
|---|---|---|
| $sDirectory | ||
| $bRecursive |
scanPlugins( $entity) : stringscanPlugins: Scans a given plugin directory and places the found plugins into the array $cfg['plugins']
Example: scanPlugins("frontendusers");
Result: $cfg['plugins']['frontendusers'] => array with all found plugins
Note: Plugins are only "found" if the following directory structure if found:
entity/ plugin1/plugin1.php plugin2/plugin2.php
The plugin's directory and file name have to be the same, otherwise the function won't find them!
| Name | Type | Description |
|---|---|---|
| $entity | Name of the directory to scan |
| Type | Description |
|---|---|
| string | client name |
sendEncodingHeader(\DB_Contenido $db, array $cfg, int $lang) : voidFunction checks current language and client settings by HTTP-Params and DB settings.
Based on this informations it will send an HTTP header for right encoding.
| Name | Type | Description |
|---|---|---|
| $db | \DB_Contenido | |
| $cfg | array | global cfg-array |
| $lang | int | global language id |
- Author
- Holger Librenz
- Since
- 4.6.18
- Version
- 1.0.0
sendPostRequest( $host, $path, $data, $referer = "", $port = 80) : voidsendPostRequest: Sents a HTTP POST request
Example: sendPostRequest("hostname", "serverpath/test.php", $data);
| Name | Type | Description |
|---|---|---|
| $host | Hostname or domain | |
| $path | ||
| $data | Data to send | |
| $referer | Referer (optional) | |
| $port | Port (default: 80) |
setArtspecDefault(integer $idartspec) : voidset a default article specification
while creating a new article this defined article specification will be default setting
| Name | Type | Description |
|---|---|---|
| $idartspec | integer | article specification id |
setArtspecOnline(integer $idartspec, integer $online) : voidset article specifications online
flag to switch if an article specification should be shown the frontend or not
| Name | Type | Description |
|---|---|---|
| $idartspec | integer | article specification id |
| $online | integer | 0/1 switch the status between on an offline |
setSystemProperty(string $type, string $name, string $value, int $idsystemprop = 0) : voidSets a system property entry
| Name | Type | Description |
|---|---|---|
| $type | string | The type of the item |
| $name | string | The name of the item |
| $value | string | The value of the item |
| $idsystemprop | int | The sysprop id, use optional. If set it allows to modify type name and value |
- Modified
- Timo Trautmann 22.02.2008 Support for editing name and type
startTiming(\function $function, \parameters $parameters = array()) : intstartTiming: Starts the timing for a specific function
| Name | Type | Description |
|---|---|---|
| $function | \function | string Name of the function |
| $parameters | \parameters | array All parameters for the function to measure |
| Type | Description |
|---|---|
| int | uuid for this measure process |
str_ireplace_once( $find, $replace, $subject) : stringstr_ireplace_once - Replaces a string only once
Caution: This function only takes strings as parameters, not arrays!
| Name | Type | Description |
|---|---|---|
| $find | string String to find | |
| $replace | string String to replace | |
| $subject | string String to process |
| Type | Description |
|---|---|
| string | Processed string |
str_ireplace_once_reverse( $find, $replace, $subject) : stringstr_ireplace_once_reverse - Replaces a string only once, in reverse direction
Caution: This function only takes strings as parameters, not arrays!
| Name | Type | Description |
|---|---|---|
| $find | string String to find | |
| $replace | string String to replace | |
| $subject | string String to process |
| Type | Description |
|---|---|
| string | Processed string |
str_rpos( $haystack, $needle, $start = 0) : stringstr_rpos - Finds a string position in reverse direction
NOTE: The original strrpos-Function of PHP4 only finds a single character as needle.
| Name | Type | Description |
|---|---|---|
| $haystack | string String to search in | |
| $needle | string String to search for | |
| $start | integer Offset |
| Type | Description |
|---|---|
| string | Processed string |
stripos( $haystack, $needle, $offset = 0) : void| Name | Type | Description |
|---|---|---|
| $haystack | ||
| $needle | ||
| $offset |