contenido\includes\functions.general.php

Show: PublicProtectedPrivateinherited
Table of Contents
Project: Contenido Content Management System

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

>VConstant  $constant = $value
>VConstant  PHP_EOL = "\r\n"
>VConstant  PHP_EOL = "\n"

Functions

functionSaveKeywordsforart( $keycode,  $idart,  $place,  $lang) : void

Parameters
NameTypeDescription
$keycode
$idart
$place
$lang
Details
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.  
functionaddArtspec(string $artspectext,  $online) : void

add new article specification

Parameters
NameTypeDescription
$artspectextstring

article specification text

$online
functionarray_combine( $keys,  $values) : void

Parameters
NameTypeDescription
$keys
$values
functionarray_csort() : void

functionarray_search_recursive( $search,  $array,  $partial = false,  $strict = false) : void

Parameters
NameTypeDescription
$search
$array
$partial
$strict
functionbackToMainArea(bool $send) : void

Redirect to main area

Parameters
NameTypeDescription
$sendbool

Redirect Yes/No

Details
Author
Jan Lengowski  
Copyright
four for business AG  
functionbuildArticleSelect(String $sName, String $iIdCat,  $sValue) : String

Build a Article select Box

Parameters
NameTypeDescription
$sNameString

Name of the SelectBox

$iIdCatString

Value of the SelectBox

$sValue
Returns
TypeDescription
StringHTML
functionbuildCategorySelect(String $sName, String $sValue, Integer $sLevel = 0, String $sStyle = "") : String

Build a Category / Article select Box

Parameters
NameTypeDescription
$sNameString

Name of the SelectBox

$sValueString

Value of the SelectBox

$sLevelInteger

Value of highest level that should be shown

$sStyleString

Optional style informations for select

Returns
TypeDescription
StringHTML
functioncDie( $file,  $line,  $message) : void

cDie: Contenido die-alternative

Parameters
NameTypeDescription
$file

File name (use FILE)

$line

Line number (use LINE)

$message

Message to display

functioncError( $file,  $line,  $message) : void

cError: Contenido error

Parameters
NameTypeDescription
$file

File name (use FILE)

$line

Line number (use LINE)

$message

Message to display

functioncIDNADecode( $targetEncoding,  $string) : void

Parameters
NameTypeDescription
$targetEncoding
$string
functioncIDNAEncode( $sourceEncoding,  $string) : void

Parameters
NameTypeDescription
$sourceEncoding
$string
functioncInitializeArrayKey( $aArray,  $sKey,  $mDefault = "") : void

Parameters
NameTypeDescription
$aArray
$sKey
$mDefault
functioncWarning( $file,  $line,  $message) : void

cWarning: Contenido warning

Parameters
NameTypeDescription
$file

File name (use FILE)

$line

Line number (use LINE)

$message

Message to display

functioncallPluginStore( $entity) : void

callPluginStore: Calls the plugin's store methods

Example: callPluginStore("frontendusers");

Parameters
NameTypeDescription
$entity

Name of the directory to scan

functioncheckMySQLConnectivity() : void

functioncleanupSessions() : void

functioncreateRandomName( $nameLength) : string

createRandomName: Creates a random name (example: Passwords)

Example: echo createRandomName(8);

Parameters
NameTypeDescription
$nameLength

Length of the generated string

Returns
TypeDescription
stringrandom name
functiondefine_if( $constant,  $value) : void

Parameters
NameTypeDescription
$constant
$value
functiondeleteArtspec(integer $idartspec) : void

delete specified article specification

Parameters
NameTypeDescription
$idartspecinteger

article specification id

functiondeleteSystemProperty(string $type, string $name) : void

Remove a system property entry

Parameters
NameTypeDescription
$typestring

The type of the item

$namestring

The name of the item

functiondisplayPlugin( $entity,  $form) : void

Parameters
NameTypeDescription
$entity
$form
functionendAndLogTiming(\uuid $uuid) : void

endAndLogTiming: Ends the timing process and logs it to the timings file

Parameters
NameTypeDescription
$uuid\uuid

int UUID which has been used for timing

functionfakeheader( $time) : void

Parameters
NameTypeDescription
$time
functionfile_get_contents( $filename,  $use_include_path = 0) : void

Parameters
NameTypeDescription
$filename
$use_include_path
functionfile_put_contents( $filename,  $content) : void

Parameters
NameTypeDescription
$filename
$content
functiongetArtspec() : array

retrieve list of article specifications for current client and language

Returns
TypeDescription
arraylist of article specifications
functiongetAvailableContentTypes(int $idartlang) : void

Extracts 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

Parameters
NameTypeDescription
$idartlangint

Language specific ID of the arcticle

Details
Author
Jan Lengowski  
Copyright
four for business AG  
functiongetCanonicalDay(integer $iDay) : string

Get multi-language day

Parameters
NameTypeDescription
$iDayinteger

the day number of date(w)

Returns
TypeDescription
stringDayname of current language
functiongetCanonicalMonth( $month) : void

Parameters
NameTypeDescription
$month
functiongetClientName( $idclient) : string

getClientName: Returns the client name for a given ID

Parameters
NameTypeDescription
$idclient
Returns
TypeDescription
stringclient name
functiongetEffectiveSetting(string $type, string $name, string $default = "") : mixed

Returns 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.

Parameters
NameTypeDescription
$typestring

The type of the item

$namestring

The name of the item

$defaultstring

Optional default value

Returns
TypeDescription
mixedboolean false if nothing was found
functiongetEffectiveSettingsByType( $sType) : array

Returns 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.

Parameters
NameTypeDescription
$sType
Returns
TypeDescription
arrayValue
functiongetFileExtension(string $filename) : \extension

getFileExtension Returns the file extension of a given file

Parameters
NameTypeDescription
$filenamestring

Name of the file

Returns
TypeDescription
\extensionon success, false if no extension could be extracted.
functiongetGroupOrUserName( $uid) : void

Parameters
NameTypeDescription
$uid
functiongetIDForArea( $area) : void

Parameters
NameTypeDescription
$area
functiongetLanguageNamesByClient( $client) : void

Parameters
NameTypeDescription
$client
functiongetLanguagesByClient( $client) : void

Parameters
NameTypeDescription
$client
functiongetNamedFrame( $frame) : string

getNamedFrame: Returns the name of the numeric frame given

Parameters
NameTypeDescription
$frame

Frame number

Returns
TypeDescription
stringCanonical name of the frame
functiongetParentAreaId( $area) : void

Parameters
NameTypeDescription
$area
functiongetPhpModuleInfo( $moduleName) : array

getPhpModuleInfo - 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)

Parameters
NameTypeDescription
$moduleName
Returns
TypeDescription
arraysee above for example
Details
Author
Marco Jahn  
functiongetSystemProperties(boolean $bGetPropId = 0) : array

Retrieves all available system properties.

Array format:

$array[$type][$name] = $value;

Parameters
NameTypeDescription
$bGetPropIdboolean

bGetPropId - if true special mode is activated which generates for each property a third array, which also contains idsystemprop value

Returns
TypeDescription
array
Details
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;  
functiongetSystemPropertiesByType( $sType) : array

Gets system property entries

Parameters
NameTypeDescription
$sType
Returns
TypeDescription
arrayValue
functiongetSystemProperty(string $type, string $name) : mixed

Gets a system property entry

Parameters
NameTypeDescription
$typestring

The type of the item

$namestring

The name of the item

Returns
TypeDescription
mixedboolean false if nothing was found, or
functionget_include_path() : void

functiongetmicrotime() : void

functionhtmldecode( $string) : void

Parameters
NameTypeDescription
$string
functionhuman_readable_size( $number) : void

Parameters
NameTypeDescription
$number
functionincludePlugins( $entity) : void

includePlugins: Includes plugins for a given entity

Example: includePlugins("frontendusers");

Parameters
NameTypeDescription
$entity

Name of the directory to scan

functionisGroup( $uid) : void

Parameters
NameTypeDescription
$uid
functionisImageMagickAvailable() : boolean

isImageMagickAvailable - checks if ImageMagick is available

Returns
TypeDescription
booleantrue if ImageMagick is available
functionisRunningFromWeb() : boolean

isRunningFromWeb - checks if the script is being runned from the web

Returns
TypeDescription
booleantrue if the script is running from the web
functionisValidMail( $sEMail,  $bStrict = false) : void

Parameters
NameTypeDescription
$sEMail
$bStrict
functionis_a( $object,  $className) : void

Parameters
NameTypeDescription
$object
$className
functionis_alphanumeric(Mixed $test, Bool $umlauts = true) : Bool

Checks if a value is alphanumeric

Parameters
NameTypeDescription
$testMixed

Value to test

$umlautsBool

[Use german Umlaute] Optional

Returns
TypeDescription
BoolValue is alphanumeric
functionis_dbfs( $file) : void

Parameters
NameTypeDescription
$file
functionlocale_arsort( $locale,  $array) : void

Parameters
NameTypeDescription
$locale
$array
functionmarkSubMenuItem(int $menuitem, bool $return = false) : void

Write JavaScript to mark

Parameters
NameTypeDescription
$menuitemint

Which menuitem to mark

$returnbool

Return or echo script

Details
Author
Jan Lengowski  
Copyright
four for business AG  
functionmime_content_type( $file) : void

Parameters
NameTypeDescription
$file
functionnotifyOnError( $errortitle,  $errormessage) : void

Parameters
NameTypeDescription
$errortitle
$errormessage
functionrecursive_copy( $from_path,  $to_path) : void

Parameters
NameTypeDescription
$from_path
$to_path
functionrereadClients() : void

functionrestore_include_path() : void

functionscanDirectory( $sDirectory,  $bRecursive = false) : void

Parameters
NameTypeDescription
$sDirectory
$bRecursive
functionscanPlugins( $entity) : string

scanPlugins: 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!

Parameters
NameTypeDescription
$entity

Name of the directory to scan

Returns
TypeDescription
stringclient name
functionsendEncodingHeader(\DB_Contenido $db, array $cfg, int $lang) : void

Function 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.

Parameters
NameTypeDescription
$db\DB_Contenido
$cfgarray

global cfg-array

$langint

global language id

Details
Author
Holger Librenz  
Since
4.6.18  
Version
1.0.0  
functionsendPostRequest( $host,  $path,  $data,  $referer = "",  $port = 80) : void

sendPostRequest: Sents a HTTP POST request

Example: sendPostRequest("hostname", "serverpath/test.php", $data);

Parameters
NameTypeDescription
$host

Hostname or domain

$path
$data

Data to send

$referer

Referer (optional)

$port

Port (default: 80)

functionsetArtspecDefault(integer $idartspec) : void

set a default article specification

while creating a new article this defined article specification will be default setting

Parameters
NameTypeDescription
$idartspecinteger

article specification id

functionsetArtspecOnline(integer $idartspec, integer $online) : void

set article specifications online

flag to switch if an article specification should be shown the frontend or not

Parameters
NameTypeDescription
$idartspecinteger

article specification id

$onlineinteger

0/1 switch the status between on an offline

functionsetHelpContext( $area) : void

Parameters
NameTypeDescription
$area
functionsetSystemProperty(string $type, string $name, string $value, int $idsystemprop = 0) : void

Sets a system property entry

Parameters
NameTypeDescription
$typestring

The type of the item

$namestring

The name of the item

$valuestring

The value of the item

$idsystempropint

The sysprop id, use optional. If set it allows to modify type name and value

Details
Modified
Timo Trautmann 22.02.2008 Support for editing name and type  
functionset_include_path( $path) : void

Parameters
NameTypeDescription
$path
functionset_magic_quotes_gpc( $code) : void

Parameters
NameTypeDescription
$code
functionshowLocation( $area) : void

Parameters
NameTypeDescription
$area
functionshowTable( $tablename) : void

Parameters
NameTypeDescription
$tablename
functionstartTiming(\function $function, \parameters $parameters = array()) : int

startTiming: Starts the timing for a specific function

Parameters
NameTypeDescription
$function\function

string Name of the function

$parameters\parameters

array All parameters for the function to measure

Returns
TypeDescription
intuuid for this measure process
functionstr_ireplace( $find,  $replace,  $string) : void

Parameters
NameTypeDescription
$find
$replace
$string
functionstr_ireplace_once( $find,  $replace,  $subject) : string

str_ireplace_once - Replaces a string only once

Caution: This function only takes strings as parameters, not arrays!

Parameters
NameTypeDescription
$find

string String to find

$replace

string String to replace

$subject

string String to process

Returns
TypeDescription
stringProcessed string
functionstr_ireplace_once_reverse( $find,  $replace,  $subject) : string

str_ireplace_once_reverse - Replaces a string only once, in reverse direction

Caution: This function only takes strings as parameters, not arrays!

Parameters
NameTypeDescription
$find

string String to find

$replace

string String to replace

$subject

string String to process

Returns
TypeDescription
stringProcessed string
functionstr_rpos( $haystack,  $needle,  $start = 0) : string

str_rpos - Finds a string position in reverse direction

NOTE: The original strrpos-Function of PHP4 only finds a single character as needle.

Parameters
NameTypeDescription
$haystack

string String to search in

$needle

string String to search for

$start

integer Offset

Returns
TypeDescription
stringProcessed string
functionstripos( $haystack,  $needle,  $offset = 0) : void

Parameters
NameTypeDescription
$haystack
$needle
$offset
functiontrim_array(array $array) : array

Trims an array

Parameters
NameTypeDescription
$arrayarray

Array to trim

Returns
TypeDescription
arrayTrimmed array
Documentation was generated by phpDocumentor 2.0.0a12.