Class \Scrivo\PagePropertyDefinition

The PagePropertyDefinition is used to create definions for page properties.

Page properties are page objects (text blocks, images, urls, colors, etc) that can be edited using the Scrivo user interface. A page property definition holds the definition of a page property.

TODO: full tab html text entry properties still store their data into the etPageDefinition_ELEMENT table.

Defined in: PagePropertyDefinition.php.


Constructor summary

Attr. Name / Description
public

PagePropertyDefinition($context)

Create an empty page property defintion object.

Constant summary

Name Description
TYPE_APPLICATION_TAB Value indicating there's an application the tab.
TYPE_CHECKBOX Value indicating a checkbox property.
TYPE_COLOR Value indicating a color property.
TYPE_COLOR_LIST Value indicating a color select list property.
TYPE_DATE_TIME Value indicating a datetime property.
TYPE_HTML_TEXT Value indicating a html textarea property.
TYPE_HTML_TEXT_TAB Value indicating a single large html textarea on a tab.
TYPE_IMAGE Value indicating an img property.
TYPE_INPUT Value indicating an input field property.
TYPE_SELECT Value indicating a select list property.
TYPE_TEXT Value indicating a textarea property.
TYPE_URL Value indicating a url property.

Properties

Attr. Type Name Description
read-only int $id The page property definition id (DB key).
int $pageDefinitionId The id of the page definition to which this page property definition belongs.
int $pageDefinitionTabId An optional id of a page definition tab on which the page property is displayed.
\..\String $phpSelector A textual identification/key for this page property.
\..\String $title A descriptive name for the page property.
\..\String $type The page property type, one out of PagePropertyDefinition::TYPE_* constants.
stdClass $typeData Optional data needed to for this specific page property.

Member summary

Attr. Type Name Description
private \..\Context $context A Scrivo context.
private int $id The page property definition id (DB key).
private int $pageDefinitionId The id of the pageDefinition to which this page property definition belongs.
private int $pageDefinitionTabId An optional id of a pageDefinition tab on which the page property is displayed.
private \..\String $phpSelector A textual identification/key for this page property.
private boolean $resequence A flag to indicate a resquence on update
private \..\String $title A descriptive name for the page property.
private \..\String $type The page property type, one out of PagePropertyDefinition::TYPE_* constants.
private stdClass $typeData Optional data needed to for this specific page property.

Method summary

Attr. Type Name / Description
public mixed

__get($name)

Implementation of the readable properties using the PHP magic method __get().

public

__set($name, $value)

Implementation of the writable properties using the PHP magic method __set().

private

checkUniquePhpSelector()

Check if the current php selector is unique.

public static

delete($context, $id)

Delete existing page property defintion data from the database.

public static \..\PagePropertyDefinition

fetch($context, $id)

Fetch a page property defintion object from the database using its object id.

private \..\String

getTypeDataAsString()

Create a string representation of the type data member.

public static \..\String[]

getTypes()

Get an array of the possible property types.

public

insert()

Insert new page property defintion object data into the database.

public

move($dir)

Move a property one position up or down.

private int

readStr($val)

Convert a string to its most likely type.

public static \..\PagePropertyDefinition[]

select($context, $pageDefinitionId)

Select page property defintions from the database.

private

setFields($context, $rd)

Convenience method to set the fields of a page property defintion object from an array (result set row).

private

setPageDefinitionId($pageDefinitionId)

Set the id of the page definition to which this page property definition belongs.

private

setPageDefinitionTabId($pageDefinitionTabId)

Set the id of a page definition tab (optional) on which this page property is displayed.

private

setPhpSelector($phpSelector)

Set the textual identification/key for this page property.

private

setTitle($title)

Set the descriptive name for the page property.

private

setType($type)

Set the page property type, one out of the \Scrivo\PagePropertyDefinition::TYPE_* constants.

private

setTypeData($typeData)

Set the data (optional) needed to for this specific page property type.

private

setTypeDataAsString($str)

Set the type data member form a string representation.

private

setTypeDataFromRS($rs)

Convert plain text type data to an object.

public

update()

Update existing page property defintion object data in the database.

private

updateApplicationTab()

Set page property definition data for application definitions in the page_definition_tab table.

private

updateHtmlTextTab()

Set page property definition data for html text tab definitions in the page_definition_tab table.

private static

validateDelete($context, $id)

Check if deletion of page property defintion object data does not violate any business rules.

private

validateInsert()

Check if this page property defintion object can be inserted into the database.

private

validateUpdate()

Check if this page property defintion object can be updated in the database.

 


Constructor

public PagePropertyDefinition(\Scrivo\Context $context=null)

Create an empty page property defintion object.

Parameters:

Type Name Def. Description
\Scrivo\Context $context null

A Scrivo context.


Constants

TYPE_APPLICATION_TAB

Value indicating there's an application the tab.

Value: "application_tab"

TYPE_CHECKBOX

Value indicating a checkbox property.

Value: "checkbox"

TYPE_COLOR

Value indicating a color property.

Value: "color"

TYPE_COLOR_LIST

Value indicating a color select list property.

Value: "colorlist"

TYPE_DATE_TIME

Value indicating a datetime property.

Value: "datetime"

TYPE_HTML_TEXT

Value indicating a html textarea property.

Value: "html_text"

TYPE_HTML_TEXT_TAB

Value indicating a single large html textarea on a tab.

Value: "html_text_tab"

TYPE_IMAGE

Value indicating an img property.

Value: "img"

TYPE_INPUT

Value indicating an input field property.

Value: "input"

TYPE_SELECT

Value indicating a select list property.

Value: "select"

TYPE_TEXT

Value indicating a textarea property.

Value: "text"

TYPE_URL

Value indicating a url property.

Value: "url"


Members


				
private \Scrivo\Context $context

A Scrivo context.

Inital value: null


				
private int $id

The page property definition id (DB key).

Inital value: 0


				
private int $pageDefinitionId

The id of the pageDefinition to which this page property definition belongs.

Inital value: 0


				
private int $pageDefinitionTabId

An optional id of a pageDefinition tab on which the page property is displayed.

Inital value: 0


				
private \Scrivo\String $phpSelector

A textual identification/key for this page property.

Inital value: null


				
private boolean $resequence

A flag to indicate a resquence on update

Inital value: false


				
private \Scrivo\String $title

A descriptive name for the page property.

Inital value: null


				
private \Scrivo\String $type

The page property type, one out of PagePropertyDefinition::TYPE_* constants.

Inital value: ""


				
private \stdClass $typeData

Optional data needed to for this specific page property.

Inital value: null


Methods

public mixed __get(string $name)

Implementation of the readable properties using the PHP magic method __get().

Parameters:

Type Name Def. Description
string $name

The name of the property to get.

Returns:

mixed Implementation of the readable properties using the PHP magic method __get().

public __set(string $name, mixed $value)

Implementation of the writable properties using the PHP magic method __set().

Parameters:

Type Name Def. Description
string $name

The name of the property to set.

mixed $value

The value of the property to set.

private checkUniquePhpSelector()

Check if the current php selector is unique.

Throws:

Exception Type Description
\Scrivo\ApplicationException If one or more of the fields contain invalid data.
public static delete(\Scrivo\Context $context, int $id)

Delete existing page property defintion data from the database.

First it is is checked if it's possible to delete page property defintion data, then the page property defintion data including its dependecies is deleted from the database.

Parameters:

Type Name Def. Description
\Scrivo\Context $context

A Scrivo context.

int $id

The object id of the page property defintion to select.

Throws:

Exception Type Description
\Scrivo\ApplicationException If the data is not accessible or if it is not possible to delete the page property defintion data.
public static \Scrivo\PagePropertyDefinition fetch(\Scrivo\Context $context, int $id)

Fetch a page property defintion object from the database using its object id.

Parameters:

Type Name Def. Description
\Scrivo\Context $context

A Scrivo context.

int $id

The object id of the page property defintion to select.

Returns:

\Scrivo\PagePropertyDefinition Fetch a page property defintion object from the database using its object id.

private \Scrivo\String getTypeDataAsString()

Create a string representation of the type data member.

Returns:

\Scrivo\String Create a string representation of the type data member.

public static \Scrivo\String[] getTypes()

Get an array of the possible property types.

Returns:

\Scrivo\String[] Get an array of the possible property types.

public insert()

Insert new page property defintion object data into the database.

First it is checked if the data of this page property defintion object can be inserted into the database, then the data is inserted into the database. If no id was set a new object id is generated.

Throws:

Exception Type Description
\Scrivo\ApplicationException If the data is not accessible or one or more of the fields contain invalid data.
public move(int $dir=\Scrivo\SequenceNo::MOVE_DOWN)

Move a property one position up or down.

Parameters:

Type Name Def. Description
int $dir \Scrivo\SequenceNo::MOVE_DOWN

Direction of the move, see \Scrivo\SequenceNo:::MOVE_*

private int readStr(string $val)

Convert a string to its most likely type.

Parameters:

Type Name Def. Description
string $val

The value to convert to either an int, float or \Scrivo\String.

Returns:

int Convert a string to its most likely type.

public static \Scrivo\PagePropertyDefinition[id] select(\Scrivo\Context $context, int $pageDefinitionId)

Select page property defintions from the database.

Parameters:

Type Name Def. Description
\Scrivo\Context $context

A Scrivo context.

int $pageDefinitionId

An id of a page definition for which to select its properties.

Returns:

\Scrivo\PagePropertyDefinition[id] Select page property defintions from the database.

private setFields(\Scrivo\Context $context, array $rd)

Convenience method to set the fields of a page property defintion object from an array (result set row).

Parameters:

Type Name Def. Description
\Scrivo\Context $context

A Scrivo context.

array $rd

An array containing the field data using the database field names as keys.

private setPageDefinitionId(int $pageDefinitionId)

Set the id of the page definition to which this page property definition belongs.

Parameters:

Type Name Def. Description
int $pageDefinitionId

The id of the page definition to which this page property definition belongs.

private setPageDefinitionTabId(int $pageDefinitionTabId)

Set the id of a page definition tab (optional) on which this page property is displayed.

Note that TYPE_HTML_TEXT_TAB and TYPE_HTML_TEXT_TAB types have their own exclusive tabs and setting their tab is therefore prohibited.

Parameters:

Type Name Def. Description
int $pageDefinitionTabId

An optional id of a page definition tab on which this page property is displayed.

private setPhpSelector(\Scrivo\String $phpSelector)

Set the textual identification/key for this page property.

Parameters:

Type Name Def. Description
\Scrivo\String $phpSelector

A textual identification/key for this page property.

private setTitle(\Scrivo\String $title)

Set the descriptive name for the page property.

Parameters:

Type Name Def. Description
\Scrivo\String $title

A descriptive name for the page property.

private setType(string $type)

Set the page property type, one out of the \Scrivo\PagePropertyDefinition::TYPE_* constants.

Note that TYPE_HTML_TEXT_TAB and TYPE_HTML_TEXT_TAB behave differently than normal properties so type juggling between these and other types is not allowed.

Parameters:

Type Name Def. Description
string $type

The property type, one out of the \Scrivo\PagePropertyDefinition::TYPE_* constants.

private setTypeData(\stdClass $typeData)

Set the data (optional) needed to for this specific page property type.

Parameters:

Type Name Def. Description
\stdClass $typeData

Optional data needed to for this specific page property type.

private setTypeDataAsString(\Scrivo\String $str)

Set the type data member form a string representation.

The format of the string should be NAME1=VALUE1\nNAME2=VALUE2\nNAME3...etc.

Parameters:

Type Name Def. Description
\Scrivo\String $str

The type data string.

private setTypeDataFromRS(array $rs)

Convert plain text type data to an object.

Parameters:

Type Name Def. Description
array $rs

The type data as stored in the database.

public update()

Update existing page property defintion object data in the database.

First it is checked if the data of this page property defintion object can be updated in the database, then the data is updated in the database.

Throws:

Exception Type Description
\Scrivo\ApplicationException If the data is not accessible or one or more of the fields contain invalid data.
private updateApplicationTab()

Set page property definition data for application definitions in the page_definition_tab table.

private updateHtmlTextTab()

Set page property definition data for html text tab definitions in the page_definition_tab table.

private static validateDelete(\Scrivo\Context $context, int $id)

Check if deletion of page property defintion object data does not violate any business rules.

Parameters:

Type Name Def. Description
\Scrivo\Context $context

A Scrivo context.

int $id

The object id of the page property defintion to select.

Throws:

Exception Type Description
\Scrivo\ApplicationException If the data is not accessible or if it is not possible to delete the language data.
private validateInsert()

Check if this page property defintion object can be inserted into the database.

Throws:

Exception Type Description
\Scrivo\ApplicationException If the data is not accessible or one or more of the fields contain invalid data.
private validateUpdate()

Check if this page property defintion object can be updated in the database.

Throws:

Exception Type Description
\Scrivo\ApplicationException If the data is not accessible or one or more of the fields contain invalid data.

Documentation generated by phpDocumentor 2.0.0a12 and ScrivoDocumentor on August 29, 2013