Base class with common features for database based items and item collections.
package |
CONTENIDO API |
subpackage |
Model |
copyright |
four for business AG |
Methods
Constructor function for downwards compatibility
Item($sTable, $sPrimaryKey, $iLifetime)
Inherited
inherited_from |
\Item::Item() |
Parameters
$sTable
$sPrimaryKey
$iLifetime
Constructor Function
__construct(mixed $mId) : void
Parameters
$mId
mixed
Specifies the ID of item to load
Exceptions
Filters the passed data using the functions defines in the _arrInFilters array.
_inFilter(mixed $mData) : mixed
Inherited
Parameters
$mData
mixed
Data to filter
Returns
mixed
Filtered data
cApiModule()
cApiModule($mId)
deprecated |
[2011-03-15] Old constructor function for downwards
compatibility |
Parameters
$mId
Deletes a custom property.
deleteProperty(string $sType, string $sName) : bool
Inherited
inherited_from |
\Item::deleteProperty() |
Parameters
$sType
string
Specifies the type
$sName
string
Specifies the name
Returns
bool
Deletes a custom property by its id.
deletePropertyById(int $idprop) : bool
Inherited
inherited_from |
\Item::deletePropertyById() |
Parameters
$idprop
int
Id of property
Returns
bool
Escape string for using in SQL-Statement.
escape(string $sString) : string
Inherited
inherited_from |
\cItemBaseAbstract::escape() |
inherited_from |
\Item::escape() |
Parameters
$sString
string
The string to escape
Returns
string
Escaped string
Exports the specified module to a zip file
export()
exportPackage()
exportPackage($sPackageFileName, $bReturn)
deprecated |
[2012-02-29] This function is not longer supported. |
Parameters
$sPackageFileName
$bReturn
Wrapper for getField (less to type).
get(string $sField) : mixed
Inherited
inherited_from |
\Item::get() |
Parameters
$sField
string
Specifies the field to retrieve
Returns
mixed
Value of the field
Gets the value of a specific field.
getField($field) : mixed
Parameters
$field
Returns
mixed
Value of the field
getPackageOverview()
getPackageOverview($sFile)
deprecated |
[2012-02-29] This function is not longer supported. |
Parameters
$sFile
Returns a custom property.
getProperty(string $sType, string $sName) : mixed
Inherited
inherited_from |
\Item::getProperty() |
Parameters
$sType
string
Specifies the type
$sName
string
Specifies the name
Returns
mixed
Value of the given property or false
Returns the translated name of the module if a translation exists.
getTranslatedName() : string
Returns
string
Translated module name or original
Get the informations of used templates
getUsedTemplates() : array
Returns
array
template data
Imports the a module from a XML file, uses xmlparser and callbacks
import($sFile, $tempName)
Parameters
$sFile
$tempName
Imports the a module from a XML file, uses xmlparser and callbacks
importModuleFromXML($sFile)
importPackage()
importPackage($sFile, $aOptions)
deprecated |
[2012-02-29] This function is not longer supported. |
Parameters
$sFile
$aOptions
Checks if a the item is already loaded.
isLoaded() : bool
Inherited
inherited_from |
\Item::isLoaded() |
Returns
bool
Checks if the module is a pre-4.3 module
isOldModule() : bool
Returns
bool
true if this module is an old one
Loads an item by colum/field from the database.
loadBy(string $sField, mixed $mValue, bool $bSafe) : bool
Inherited
inherited_from |
\Item::loadBy() |
Parameters
$sField
string
Specifies the field
$mValue
mixed
Specifies the value
$bSafe
bool
Use inFilter or not
Exceptions
\cException |
if more than one item has been found matching the given arguments |
Returns
bool
True if the load was successful
Loads an item by colums/fields from the database.
loadByMany(array $aAttributes, bool $bSafe) : bool
Inherited
inherited_from |
\Item::loadByMany() |
Parameters
$aAttributes
array
associative array with field / value pairs
$bSafe
bool
Use inFilter or not
Exceptions
\cException |
if more than one item could be found matching the given arguments |
Returns
bool
True if the load was successful
Loads an item by ID from the database.
loadByPrimaryKey(string $mValue) : bool
Inherited
inherited_from |
\Item::loadByPrimaryKey() |
Parameters
$mValue
string
Specifies the primary key value
Returns
bool
True if the load was successful
Loads an item by it's recordset.
loadByRecordSet(array $aRecordSet)
Inherited
inherited_from |
\Item::loadByRecordSet() |
Parameters
$aRecordSet
array
The recordset of the item
Checks if the module is in use
moduleInUse($module, $bSetData) : bool
Parameters
$module
$bSetData
Returns
bool
Specifies if the module is in use
Parses the module for mi18n strings and returns them in an array
parseModuleForStrings() : array
Returns
array
Found strings for this module
This method get the input and output for translating
from files and not from db-table.
parseModuleForStringsLoadFromFile($cfg, $client, $lang)
Parameters
$cfg
$client
$lang
Registers a new callback.
register(string $event, mixed $callback, mixed $class) : void
InheritedStatic
Example:
cGenericDb::register(cGenericDb::CREATE_SUCCESS, 'itemCreateHandler', 'cApiArticle');
cGenericDb::register(cGenericDb::CREATE_SUCCESS, array('cCallbackHandler', 'executeCreateHandle'), 'cApiArticle');
inherited_from |
\cGenericDb::register() |
inherited_from |
\cItemBaseAbstract::register() |
inherited_from |
\Item::register() |
Parameters
$event
string
Callback event, must be a valid value of a cGenericDb event constant
$callback
mixed
Callback to register
$class
mixed
Class name for registering callback (can be string of array with names of the concrete Item classes)
Exceptions
Shortcut to setField.
set(string $sField, string $mValue, bool $bSafe)
Inherited
inherited_from |
\Item::set() |
Parameters
$mValue
string
Value to set
$bSafe
bool
Flag to run defined inFilter on passed value
Userdefined setter for module fields.
setField(string $name, mixed $value, bool $bSafe)
Parameters
$name
string
$value
mixed
$bSafe
bool
Flag to run defined inFilter on passed value
Define the filter functions used when data is being stored or retrieved
from the database.
setFilters(array $aInFilters, array $aOutFilters) : void
Inherited
Examples:
$obj->setFilters(array('addslashes'), array('stripslashes'));
$obj->setFilters(array('htmlencode', 'addslashes'), array('stripslashes', 'htmlencode'));
inherited_from |
\Item::setFilters() |
Parameters
$aInFilters
array
Array with function names
$aOutFilters
array
Array with function names
Sets a custom property.
setProperty(string $sType, string $sName, mixed $mValue) : bool
Inherited
inherited_from |
\Item::setProperty() |
Parameters
$sType
string
Specifies the type
$sName
string
Specifies the name
$mValue
mixed
Specifies the value
Returns
bool
Sets the translated name of the module
setTranslatedName($name) : \none
Parameters
$name
string Translated name of the module
Returns
\none
Stores the loaded and modified item to the database.
store($bJustStore) : bool
Parameters
$bJustStore
Returns
bool
Returns current item data as an assoziative array.
toArray() : array | false
Inherited
inherited_from |
\Item::toArray() |
Returns
array
false
Returns current item data as an object.
toObject() : \stdClass | false
Inherited
inherited_from |
\Item::toObject() |
Returns
Unregisters all callbacks for a specific event in a class.
unregister(string $event, mixed $class) : void
InheritedStatic
Example:
cGenericDb::unregister(cGenericDb::CREATE_SUCCESS, 'cApiArticle');
inherited_from |
\cGenericDb::unregister() |
inherited_from |
\cItemBaseAbstract::unregister() |
inherited_from |
\Item::unregister() |
Parameters
$event
string
Callback event, must be a valid value of a cGenericDb event constant
$class
mixed
Class name for unregistering callback (can be string of array with names of the concrete Item classes)
Exceptions
Executes all callbacks for a specific event in a class.
_executeCallbacks(string $event, string $class, array $arguments) : void
Inherited
inherited_from |
\cGenericDb::_executeCallbacks() |
inherited_from |
\cItemBaseAbstract::_executeCallbacks() |
inherited_from |
\Item::_executeCallbacks() |
Parameters
$event
string
Callback event, must be a valid value of a cGenericDb event constant
$class
string
Class name for executing callback
$arguments
array
Arguments to pass to the callback function
Exceptions
Returns properties instance, instantiates it if not done before.
_getPropertiesCollectionInstance() : \cApiPropertyCollection
Inherited
inherited_from |
\cItemBaseAbstract::_getPropertiesCollectionInstance() |
inherited_from |
\Item::_getPropertiesCollectionInstance() |
Returns
Returns the second database instance, usable to run additional statements
without losing current query results.
_getSecondDBInstance() : \cDb
Inherited
inherited_from |
\cItemBaseAbstract::_getSecondDBInstance() |
inherited_from |
\Item::_getSecondDBInstance() |
Returns
Loads an item by passed where clause from the database.
_loadByWhereClause(string $sWhere) : bool
Inherited
This function is expensive, since it executes allways a query to the database
to retrieve the primary key, even if the record set is aleady cached.
NOTE: Passed value has to be escaped before. This will not be done by this function.
inherited_from |
\Item::_loadByWhereClause() |
Parameters
$sWhere
string
The where clause like 'idart = 123 AND idlang = 1'
Exceptions
\cException |
if more than one item could be found matching the given where clause |
Returns
bool
True if the load was successful
Function which is called whenever an item is loaded.
_onLoad() : void
Inherited
Inherited classes should override this function if desired.
inherited_from |
\Item::_onLoad() |
Filters the passed data using the functions defines in the _arrOutFilters array.
_outFilter(mixed $mData) : mixed
Inherited
Parameters
$mData
mixed
Data to filter
Returns
mixed
Filtered data
Add recrusive folder to zip archive
_addFolderToZip(string $dir, string $zipArchive, string $zipdir)
Parameters
$dir
string
direcotry name
$zipArchive
string
name of the archive
$zipdir
string
Save the modul properties (description,type.
_getModuleProperties(string $sFile)
Parameters
$sFile
string
Where is the modul info.xml file
Parse import xml file and returns its values.
_parseImportFile(string $sFile) : array
Parameters
$sFile
string
Filename including path of import xml file
Returns
array
Array with module data from XML file
Properties
$primaryKey : string
Inherited
inherited_from |
\cItemBaseAbstract::$$primaryKey |
inherited_from |
\Item::$$primaryKey |
$values : array
Inherited
inherited_from |
\Item::$$values |
$virgin : bool
Inherited
If true, the object
is virgin and no operations on it except load-Functions are allowed.
inherited_from |
\cItemBaseAbstract::$$virgin |
inherited_from |
\Item::$$virgin |
$_arrInFilters : array
Inherited
inherited_from |
\Item::$$_arrInFilters |
$_arrOutFilters : array
Inherited
inherited_from |
\Item::$$_arrOutFilters |
$_className : string
Inherited
inherited_from |
\cItemBaseAbstract::$$_className |
inherited_from |
\Item::$$_className |
$_oCache : \cItemCache
Inherited
inherited_from |
\cItemBaseAbstract::$$_oCache |
inherited_from |
\Item::$$_oCache |
$_packageStructure : array
$_settings : array
Inherited
inherited_from |
\cItemBaseAbstract::$$_settings |
inherited_from |
\Item::$$_settings |
$cache : array
Inherited
inherited_from |
\cItemBaseAbstract::$$cache |
inherited_from |
\Item::$$cache |
$db : \cDb
Inherited
inherited_from |
\cItemBaseAbstract::$$db |
inherited_from |
\Item::$$db |
$lasterror : string
Inherited
inherited_from |
\cItemBaseAbstract::$$lasterror |
inherited_from |
\Item::$$lasterror |
$lifetime : int
Inherited
inherited_from |
\cItemBaseAbstract::$$lifetime |
inherited_from |
\Item::$$lifetime |
$modifiedValues : array
Inherited
inherited_from |
\Item::$$modifiedValues |
$oldPrimaryKey : string
Inherited
inherited_from |
\Item::$$oldPrimaryKey |
$properties : \cApiPropertyCollection
Inherited
inherited_from |
\cItemBaseAbstract::$$properties |
inherited_from |
\Item::$$properties |
$secondDb : \cDb
Inherited
inherited_from |
\cItemBaseAbstract::$$secondDb |
inherited_from |
\Item::$$secondDb |
$table : string
Inherited
inherited_from |
\cItemBaseAbstract::$$table |
inherited_from |
\Item::$$table |
$_callbacks : array
Inherited
inherited_from |
\cGenericDb::$$_callbacks |
inherited_from |
\cItemBaseAbstract::$$_callbacks |
inherited_from |
\Item::$$_callbacks |
Constants
Callbacks are executed before a item is created.
CREATE_BEFORE
Inherited
Expected parameters for callback: none
inherited_from |
\cGenericDb::CREATE_BEFORE |
inherited_from |
\cItemBaseAbstract::CREATE_BEFORE |
inherited_from |
\Item::CREATE_BEFORE |
Callbacks are executed if item could not be created.
CREATE_FAILURE
Inherited
Expected parameters for callback: none
inherited_from |
\cGenericDb::CREATE_FAILURE |
inherited_from |
\cItemBaseAbstract::CREATE_FAILURE |
inherited_from |
\Item::CREATE_FAILURE |
Callbacks are executed if item could be created successfully.
CREATE_SUCCESS
Inherited
Expected parameters for callback: ID of created item
inherited_from |
\cGenericDb::CREATE_SUCCESS |
inherited_from |
\cItemBaseAbstract::CREATE_SUCCESS |
inherited_from |
\Item::CREATE_SUCCESS |
Callbacks are executed before deleting an item.
DELETE_BEFORE
Inherited
Expected parameters for callback: ID of them item to delete
inherited_from |
\cGenericDb::DELETE_BEFORE |
inherited_from |
\cItemBaseAbstract::DELETE_BEFORE |
inherited_from |
\Item::DELETE_BEFORE |
Callbacks are executed if deletion of an item fails.
DELETE_FAILURE
Inherited
Expected parameters for callback: ID of them item to delete
inherited_from |
\cGenericDb::DELETE_FAILURE |
inherited_from |
\cItemBaseAbstract::DELETE_FAILURE |
inherited_from |
\Item::DELETE_FAILURE |
Callbacks are executed if item was deleted successfully.
DELETE_SUCCESS
Inherited
Expected parameters for callback: ID of them item to delete
inherited_from |
\cGenericDb::DELETE_SUCCESS |
inherited_from |
\cItemBaseAbstract::DELETE_SUCCESS |
inherited_from |
\Item::DELETE_SUCCESS |
Callbacks are executed before store process is executed.
STORE_BEFORE
Inherited
Expected parameters for callback: Item instance
inherited_from |
\cGenericDb::STORE_BEFORE |
inherited_from |
\cItemBaseAbstract::STORE_BEFORE |
inherited_from |
\Item::STORE_BEFORE |
Callbacks are executed if store process failed.
STORE_FAILURE
Inherited
This is also likely to happen if query would not change anything in database!
Expected parameters for callback: Item instance
inherited_from |
\cGenericDb::STORE_FAILURE |
inherited_from |
\cItemBaseAbstract::STORE_FAILURE |
inherited_from |
\Item::STORE_FAILURE |
Callbacks are executed if store process saved the values in the database.
STORE_SUCCESS
Inherited
Expected parameters for callback: Item instance
inherited_from |
\cGenericDb::STORE_SUCCESS |
inherited_from |
\cItemBaseAbstract::STORE_SUCCESS |
inherited_from |
\Item::STORE_SUCCESS |