Options class
| access | public |
|---|---|
| package | kocuj_internal_lib |
| inherited_from | \KocujIL\V12a\Classes\ComponentObject |
__construct(object $projectObj) : void
| access | public |
|---|---|
| inherited_from | \KocujIL\V12a\Classes\ComponentObject::__construct() |
object\KocujIL\V12a\Classes\Project object for current project
__construct(object $projectObj) : void
| access | public |
|---|
object\KocujIL\V12a\Classes\Project object for current project
addContainer(string $containerId, integer $optionAutoload= \KocujIL\V12a\Enums\OptionAutoload::YES, integer $containerType= \KocujIL\V12a\Enums\Project\Components\All\Options\ContainerType::SITE) : void
| access | public |
|---|
stringOptions container identifier; it must have maximum 16 characters
integerAutomatic loading of option or not; this argument is ignored if $containerType is set to \KocujIL\V12a\Enums\Project\Components\All\Options\ContainerType::WIDGET; must be one of the following constants from \KocujIL\V12a\Enums\OptionAutoload: NO (when option should not be automatically loaded) or YES (when option should be automatically loaded) - default: \KocujIL\V12a\Enums\OptionAutoload::YES
integerOptions container type; must be one of the following constants from \KocujIL\V12a\Enums\Project\Components\All\Options\ContainerType: NETWORK_OR_SITE (for network - in multisite installation - or site - in standard installation - type), SITE (for site type), NETWORK (for network type), WIDGET (for widget type), DATA_SET_SITE (for data set table with options for site type) or DATA_SET_NETWORK (for data set table with options for network type) - default: \KocujIL\V12a\Enums\Project\Components\All\Options\ContainerType::SITE
addDataSetElement($containerId) : integer
| access | public |
|---|
integerNew element identifier for data setaddDefinition(string $containerId, string $optionId, string $type, string $defaultValue, string $label, integer $optionArray= \KocujIL\V12a\Enums\Project\Components\All\Options\OptionArray::NO, array $arraySettings= array(), array $dataSetSettings= array(), array $additional= array()) : void
| todo | disallow option id as "option_id" or "option_value" |
|---|---|
| todo | add requirement that "global_foreignkeyforcontainer", "global_ordervalue" or "global_unique" can be set only when "global_searchkey" is set |
| todo | add checking if "global_ordervalue" is only for one option in container |
| access | public |
stringOptions container identifier
stringOption identifier
stringOption type
stringOption default value
stringOption label
integerOption is array or standard; must be one of the following constants from \KocujIL\V12a\Enums\Project\Components\All\Options\OptionArray: NO (when it is standard option) or YES (when it is array option) - default: \KocujIL\V12a\Enums\Project\Components\All\Options\OptionArray::NO
arrayArray settings if $optionArray is set to \KocujIL\V12a\Enums\Project\Components\All\Options\OptionArray::YES - default: empty
arrayarrayData set settings for option; each options type can use different data set settings; there are the following data set settings which can be always used: "global_foreignkeyforcontainer" (string type; name of container for which this option is foreign key, so selected value can be only from available values in column "option_id" in the selected container; it works only if "global_searchkey" is set to true), "global_ordervalue" (bool type; if container is for data set and it is set to true, this value will be used for default ordering the elements list), "global_searchkey" (bool type; if container is for data set and it is set to true, there will be an additional column with option value for this definition), "global_unique" (bool type; if container is for data set and it is set to true, this field will be checked if its value is unique in data set; it works only if "global_searchkey" is set to true) - default: empty
addType(string $optionType, array|string $callbackDefaultValue= NULL, array|string $callbackValidation= NULL, integer $typeLengthSupport= \KocujIL\V12a\Enums\Project\Components\All\Options\TypeLengthSupport::NO, integer $typeFormat= \KocujIL\V12a\Enums\Project\Components\All\Options\TypeFormat::TEXT) : void
| access | public |
|---|
stringOptions type
arraystringCallback function or method name for default value of option; can be global function or method from any class; if empty, no callback will be used - default: NULL
arraystringCallback function or method name for validation of option; can be global function or method from any class; if empty, no callback will be used - default: NULL
integerMinimum and maximum length is supported or not; must be one of the following constants from \KocujIL\V12a\Enums\Project\Components\All\Options\TypeLengthSupport: NO (when length limits are not supported) or YES (when length limits are supported) - default: \KocujIL\V12a\Enums\Project\Components\All\Options\TypeLengthSupport::NO
integerFormat of value; must be one of the following constants from \KocujIL\V12a\Enums\Project\Components\All\Options\TypeFormat: TEXT (when format is text), NUMBER_INT (when format is int number) or NUMBER_FLOAT (when format is float number) - default: \KocujIL\V12a\Enums\Project\Components\All\Options\TypeFormat::TEXT
checkContainer(string $id) : boolean
| access | public |
|---|
stringOptions container identifier
booleanOptions container exists (true) or not (false)checkDataSetElementId(string $containerId, integer $dataSetElementId) : boolean
| access | public |
|---|
stringOptions container identifier
integerData set element identifier
booleanElement identifier exists in data set (true) or not (false)checkDefinition(string $containerId, string $optionId) : boolean
| access | public |
|---|
stringOptions container identifier
stringOption definition identifier
booleanOption definition exists (true) or not (false)checkType(string $id) : boolean
| access | public |
|---|
stringOptions type identifier
booleanOptions type exists (true) or not (false)getAllOptions(string $containerId, $dataSetElementId = 0) : array
| access | public |
|---|
stringOption container identifier
arrayOptions valuesgetComponent(string $type, integer $projectCategory= \KocujIL\V12a\Enums\ProjectCategory::CORE, string $fragment= '') : object
| access | public |
|---|
stringComponent type
integerComponent category; must be one of the following constants from \KocujIL\V12a\Enums\ProjectCategory: CORE (for "core" category), ALL (for "all" category), FRONTEND (for "frontend" category) or BACKEND (for "backend" category) - default: \KocujIL\V12a\Enums\ProjectCategory::CORE
stringComponent fragment - default: empty
objectObject of class type from componentgetContainer(string $id) : array | boolean
| access | public |
|---|
stringOptions container identifier
arraybooleanOptions container data or false if not exists; options container data have the following fields: "autoload" (bool type; if true, options container will be loaded automatically), "dbkey" (string type; database key for options container), "tablename" (string type; table name in database for data set options), "type" (int type; options container is automatic, for network or for site)getContainers() : array
| access | public |
|---|
arrayOptions containers data; each options container data has the following fields: "autoload" (bool type; if true, options container will be loaded automatically), "dbkey" (string type; database key for options container), "tablename" (string type; table name in database for data set options), "type" (int type; options container is automatic, for network or for site)getDataSetElements(string $containerId, array $searchValues= array(), string $orderBy= '', integer $order= \KocujIL\V12a\Enums\Project\Components\All\Options\Order::ASC, integer $count= 1, integer $from= 0) : array
| access | public |
|---|
stringOption container identifier
arrayIf options are for data set, these are options keys and values by which data will be searched - default: empty
stringOption by which results will be sorted - default: empty
integerOrder of sorting; must be one of the following constants from \KocujIL\V12a\Enums\Project\Components\All\Options\Order: ASC (when order is ascendand) or DESC (when order is descendant) - default: \KocujIL\V12a\Enums\Project\Components\All\Options\Order::ASC
integerHow many elements should be returned; if it set to 0, all elements will be get - default: 1
integerFrom which element data should be returned - default: 0
arrayOptions values for each founded elementgetDataSetElementsCount(string $containerId, array $searchValues = array()) : array
| access | public |
|---|
stringOption container identifier
arrayIf options are for data set, these are options keys and values by which data will be searched - default: empty
arrayOptions values for each founded elementgetDefinition(string $containerId, string $optionId) : array | boolean
| access | public |
|---|
stringOptions container identifier
stringOption definition identifier
arraybooleanOption definition data or false if not exists; option definition data have the following fields: "additional" (array type; additional settings for option), "arraymode" (int type; set if option is standard or array), "arraysettings" (array type; settings for option if it is an array), "datasetsettings" (array type; data set settings for option), "defaultvalue" (string type; option default value), "label" (string type; option label), "type" (string type; option type)getDefinitions(string $containerId) : array
| access | public |
|---|
stringOptions container identifier
arrayOptions definitions data; each option definition data has the following fields: "additional" (array type; additional settings for option), "arraymode" (int type; set if option is standard or array), "arraysettings" (array type; settings for option if it is an array), "datasetsettings" (array type; data set settings for option), "defaultvalue" (string type; option default value), "label" (string type; option label), "type" (string type; option type)getOption(string $containerId, string $optionId, integer $dataSetElementId = 0) : string
| access | public |
|---|
stringOption container identifier
stringOption identifier
integerData set element identifier - default: 0
stringOption valuegetProjectObj() : object
| access | public |
|---|
objectObject of type \KocujIL\V12a\Classes\ProjectgetStrings(string $type, integer $projectCategory = \KocujIL\V12a\Enums\ProjectCategory::CORE) : object
| access | public |
|---|
stringComponent type
integerComponent category; must be one of the following constants from \KocujIL\V12a\Enums\ProjectCategory: CORE (for "core" category), ALL (for "all" category), FRONTEND (for "frontend" category) or BACKEND (for "backend" category) - default: \KocujIL\V12a\Enums\ProjectCategory::CORE
objectObject of class type for strings from componentgetType(string $id) : array | boolean
| access | public |
|---|
stringOptions type identifier
arraybooleanOptions type data or false if not exists; options type data have the following fields: "defaultvalue" (array or string type; callback for default value of option), "format" (int type; information about format), "lengthsupport" (int type; information is minimum and maximum length is supported for this options type), "validation" (array or string type; callback for validation of option)getTypes() : array
| access | public |
|---|
arrayOptions types data; each options types data has the following fields: "defaultvalue" (array or string type; callback for default value of option), "format" (int type; information about format), "lengthsupport" (int type; information is minimum and maximum length is supported for this options type), "validation" (array or string type; callback for validation of option)loadContainerForWidget(string $containerId, array $options) : void
| access | public |
|---|
stringOption container identifier
arrayOptions
removeAllContainersFromDb() : void
| access | public |
|---|
removeContainer(string $id) : void
| access | public |
|---|
stringContainer identifier
removeContainerFromDb(string $containerId) : void
| access | public |
|---|
stringOption container identifier
removeDataSetElement(string $containerId, integer $dataSetElementId) : void
| todo | when removing other elements with foreign key set to current container, do not remove entire cache for this container from memory, but only deleted elements |
|---|---|
| access | public |
stringOptions container identifier
integerData set element identifier
removeDefinition(string $containerId, string $optionId) : void
| access | public |
|---|
stringOptions definition identifier
stringOption identifier
removeType(string $id) : void
| access | public |
|---|
stringType identifier
setOption(string $containerId, string $optionId, string $optionValue, integer $dataSetElementId = 0) : boolean
| access | public |
|---|
stringOption container identifier
stringOption identifier
stringOption value
integerData set element identifier - default: 0
booleanOptions has been set correctly (true) or not (false)setOptionWithReturnedText(string $containerId, string $optionId, string $optionValue, $outputText, integer $dataSetElementId = 0) : boolean
| access | public |
|---|
stringOption container identifier
stringOption identifier
stringOption value
integerData set element identifier - default: 0
booleanOptions has been set correctly (true) or not (false)updateAllContainersInDb() : void
| access | public |
|---|
updateContainerInDb(string $containerId) : void
| access | public |
|---|
stringOption container identifier
changeContainerTypeToArea(integer $containerType) : integer
| access | private |
|---|
integerOptions container type; must be one of the following constants from \KocujIL\V12a\Enums\Project\Components\All\Options\ContainerType: NETWORK_OR_SITE (for network - in multisite installation - or site - in standard installation - type), SITE (for site type), NETWORK (for network type) or WIDGET (for widget type) - default: \KocujIL\V12a\Enums\Project\Components\All\Options\ContainerType::SITE
integerArea typechangeOptionsByDefinitions(string $containerId, boolean $force= false, integer $dataSetElementId= 0) : void
| access | private |
|---|
stringOptions container identifier
booleanForce changing options (true) or not (false)
integerData set element identifier - default: 0
getDataSetElementsOrCount(boolean $getElements, string $containerId, array $searchValues= array(), string $orderBy= '', integer $order= \KocujIL\V12a\Enums\Project\Components\All\Options\Order::ASC, integer $count= 1, integer $from= 0) : array | integer
| access | private |
|---|
booleanGet element (true) or elements count (false)
stringOption container identifier
arrayIf options are for data set, these are options keys and values by which data will be searched - default: empty
stringOption by which results will be sorted - default: empty
integerOrder of sorting; must be one of the following constants from \KocujIL\V12a\Enums\Project\Components\All\Options\Order: ASC (when order is ascendand) or DESC (when order is descendant) - default: \KocujIL\V12a\Enums\Project\Components\All\Options\Order::ASC
integerHow many elements should be returned; if it set to 0, all elements will be get - default: 1
integerFrom which element data should be returned - default: 0
arrayintegerOptions values for each founded element or elements countloadOptionsFromDbIfNeeded(string $containerId, integer $dataSetElementId = 0) : void
| access | private |
|---|
stringOptions container identifier
integerData set element identifier - default: 0
typeDefaultValueCheckbox(object $componentObj, string $defaultOptionValue, array $additional) : string
| access | private |
|---|
objectObject with this component
stringDefault option value
arrayAdditional settings for option
stringParsed default option valuetypeDefaultValueIntegerOrFloat(object $componentObj, string $defaultOptionValue, array $additional) : string
| access | private |
|---|
objectObject with this component
stringDefault option value
arrayAdditional settings for option; there are the following additional settings which can be used: "global_maxvalue" (int type; maximum value of number), "global_minvalue" (int type; minimal value of number)
stringParsed default option valuetypeValidationCheckbox(object $componentObj, string $containerId, string $optionId, integer $optionArray, string $optionValue, array $additional) : string
| access | private |
|---|
objectObject with this component
stringOption container identifier
stringOption container identifier
integerOption is array or standard; must be one of the following constants from \KocujIL\V12a\Enums\Project\Components\All\Options\OptionArray: NO (when it is standard option) or YES (when it is array option)
stringOption value
arrayAdditional settings for option
stringOutput text if there was an error or empty string if option value has been validated correctlytypeValidationFloat(object $componentObj, string $containerId, string $optionId, integer $optionArray, string $optionValue, array $additional) : string
| access | private |
|---|
objectObject with this component
stringOption container identifier
stringOption container identifier
integerOption is array or standard; must be one of the following constants from \KocujIL\V12a\Enums\Project\Components\All\Options\OptionArray: NO (when it is standard option) or YES (when it is array option)
stringOption value
arrayAdditional settings for option; there are the following additional settings which can be used: "maxvalue" (int type; maximum value of number), "minvalue" (int type; minimal value of number)
stringOutput text if there was an error or empty string if option value has been validated correctlytypeValidationHelperIntegerOrFloat(object $componentObj, string $containerId, string $optionId, integer $optionArray, string $optionValue, array $additional, boolean $mustBeInteger) : string
| access | private |
|---|
objectObject with this component
stringOption container identifier
stringOption container identifier
integerOption is array or standard; must be one of the following constants from \KocujIL\V12a\Enums\Project\Components\All\Options\OptionArray: NO (when it is standard option) or YES (when it is array option)
stringOption value
arrayAdditional settings for option; there are the following additional settings which can be used: "maxvalue" (int type; maximum value of number), "minvalue" (int type; minimal value of number)
booleanValue must be integer (true) or not (false)
stringOutput text if there was an error or empty string if option value has been validated correctlytypeValidationInteger(object $componentObj, string $containerId, string $optionId, integer $optionArray, string $optionValue, array $additional) : string
| access | private |
|---|
objectObject with this component
stringOption container identifier
stringOption container identifier
integerOption is array or standard; must be one of the following constants from \KocujIL\V12a\Enums\Project\Components\All\Options\OptionArray: NO (when it is standard option) or YES (when it is array option)
stringOption value
arrayAdditional settings for option; there are the following additional settings which can be used: "maxvalue" (int type; maximum value of number), "minvalue" (int type; minimal value of number)
stringOutput text if there was an error or empty string if option value has been validated correctly$containers : array
array()| access | private |
|---|
$dataSetTableCreatedNow : boolean
false| access | private |
|---|
$definitions : array
array()| access | private |
|---|
$projectObj : object
NULL| access | private |
|---|
$types : array
array()| access | private |
|---|