class DocumentLock extends UIAjaxComponent

Class DocumentLock

This class represent a generic document locking component. It can be used by default object instantiation or via xui tag in templates. The display of this component is a uniformed

XUI Tag structure:

        <xui:document_lock document_index_id="[integer]" activity="EDIT|VIEW" ttl="[integer]" />

Constants

SYSTEM_TEMPLATE_UI_FOLDER

UPDATE_INTERVAL

Value for periodical update via ajax

STATE_LOCKED

States for document.

Used to determine the current nad previous locking state.

STATE_FREE

Properties

$xf_link from  UIComponent
$link_id from  UIComponent
array $GPvars from  UIComponent
Controller $mod from  UIComponent
protected array $local_template_marker from  UIComponent
protected bool $_overwrite_param_array from  UIComponent
protected bool|array|ModelCollection $marker_content from  UIComponent
string $mod_object_manager from  UIComponent
protected bool $_orig_marker_content from  UIComponent
protected array $_allowed_params_filter from  UIComponent
string $unique_dom_id from  UIComponent
protected string $uid from  UIComponent
string read-only $_content

When used in template this property will contain the XML/HTML within the XUI Nodes

from  UIComponent
$link from  UIAjaxComponent
protected string $js_class from  UIAjaxComponent
protected array $js_options from  UIAjaxComponent
protected array $css_classes from  UIAjaxComponent
protected array $xui_payload from  UIAjaxComponent
protected bool $deferredLoading from  UIAjaxComponent
protected bool $deferredLoadingMessage from  UIAjaxComponent
protected int $document_index_id
protected int $activity
protected int $ttl

Methods

__construct(string $link_id = null)

UIComponent constructor.

string
__toString()

No description

add_css_class($css_class)

Adds a custom css class to the root element of this component.

add_dependency(string $dep_name, UIAjaxComponent $dep_obj, bool $reloadOnUpdate = false)

Add a new UIAjaxComponent object and register it under a certain name this component will use that name to retrieve the object in order to interact with it.

add_url_parameter(mixed $key, mixed $value)

Adds a parameter to url parameter list.

enable_periodical_update(int $interval)

Enables the periodical update via ajax.

mixed
get($var)

Get Variable / Option

string
getPlaceholderContent()

Returns a placeholder which is used to display while this component is loading the content.

mixed
get_dependency($dep_name)

Returns a dependent object in order to interact with it

int
get_locking_user_id()

Return the user id of the user that locks the document.

string
get_unique_dom_id()

Generates a unique dom id, dependent on the provided UID, as well as the current context.

Template|null
get_view(string|bool $section = false)

Return new template view If using within module xui the tpl file should be named [class_name].tpl e.g. xui_core_table.tpl within the module's template folder

init()

Class initialization

bool
is_locked()

Returns whether the target document index is locked or not.

string
parse_template(string $template_content, array|bool $marker_array = false)

No description

string|null
parse_template_cb_wrapper(mixed $matches)

No description

mixed|string
parse_xtag($xml_source)

No description

process()

dummy process method - may be overwritten

process_xui()

Process and prepare xui for rendering.

render()

Default render method. wraps the content provided by render_xui_content in a unique div and generates a JS object for the GUI

mixed
render_xtag_element()

No description

string|Template
render_xui()

Rendering method for this xui component.

void
reset_marker_content()

restores original content of marker_content

void
set(mixed $var, mixed $value = false)

Set Variable / Option

void
setDeferredLoading(bool $bool, string $message = '')

Set true to load the content deferred. Displays a placeholder while loading the content. Optional you can pass a message which will replace the default loading message.

set_activity($activity)

Sets the activity for the targeted document index. This value effects the message, appearance and interaction of the document lock/view. Use EDIT if the current view is based on a document index and can be modified for instance by a form.

void
set_array(mixed $member_array, mixed $vars)

Set Variable / Option for an array

set_document_index(DocumentIndex $document_index_model)

Sets the id of the target document index.

set_document_index_id(int $id)

Sets the id of the target document index.

void
set_marker_content(mixed $marker_content = false)

sets marker_content to passed data -> restore original content with reset_marker_content()

set_mod(mixed $mod)

Set link to owning module

set_option(string $key, mixed $val)

Sets options. This options will be used in the JS element of this XUI class.

void
set_render_params(mixed $input_params = array())

Used to inject params. Only allowed params will be used (see $allowed_params_filter)

set_ttl(int $seconds)

Sets the time to live value. This value is used to remove exceeded locks and views on a document index. The ttl value is set to 30 seconds by default. All entries will bbe deleted where the update time is more than the specified ttl value in the past.

set_uid($uid)

No description

set_url_parameters(array $parameters)

Sets the url parameter that is used for component loading.

Details

in UIComponent at line 64
__construct(string $link_id = null)

UIComponent constructor.

Parameters

string $link_id

in UIComponent at line 324
string __toString()

No description

Return Value

string

in UIAjaxComponent at line 139
add_css_class($css_class)

Adds a custom css class to the root element of this component.

Parameters

$css_class

in UIAjaxComponent at line 106
add_dependency(string $dep_name, UIAjaxComponent $dep_obj, bool $reloadOnUpdate = false)

Add a new UIAjaxComponent object and register it under a certain name this component will use that name to retrieve the object in order to interact with it.

Parameters

string $dep_name
UIAjaxComponent $dep_obj
bool $reloadOnUpdate

Set true to reload dependency if this component is updated.

in UIAjaxComponent at line 80
add_url_parameter(mixed $key, mixed $value)

Adds a parameter to url parameter list.

Parameters

mixed $key
mixed $value

in UIAjaxComponent at line 161
enable_periodical_update(int $interval)

Enables the periodical update via ajax.

The ajax calls will be execute after an interval of seconds passed by parameter one.

Parameters

int $interval

in UIComponent at line 185
mixed get($var)

Get Variable / Option

Parameters

$var

Return Value

mixed

in UIAjaxComponent at line 200
protected string getPlaceholderContent()

Returns a placeholder which is used to display while this component is loading the content.

Return Value

string

in UIAjaxComponent at line 122
mixed get_dependency($dep_name)

Returns a dependent object in order to interact with it

Parameters

$dep_name

Return Value

mixed

at line 157
int get_locking_user_id()

Return the user id of the user that locks the document.

This method returns the correct result after this xui was processed. Returns user_id if the document index is in EDIT mode and locked by the first visitor, otherwise it will return zero.

Return Value

int

The user id if there is a lock otherwise 0

in UIComponent at line 202
string get_unique_dom_id()

Generates a unique dom id, dependent on the provided UID, as well as the current context.

Return Value

string

in UIComponent at line 289
Template|null get_view(string|bool $section = false)

Return new template view If using within module xui the tpl file should be named [class_name].tpl e.g. xui_core_table.tpl within the module's template folder

Parameters

string|bool $section

Name

Return Value

Template|null

Exceptions

Exception

at line 81
init()

Class initialization

This class uses an periodical update via ajax. This update allows to maintain the entries in the document lock table. This means, the current users watching at, updates their entries to keep them alive, otherwise the entries will be detected as exceeded and deleted.

The default update value is 15 seconds.

at line 169
bool is_locked()

Returns whether the target document index is locked or not.

This method returns the correct result after this xui was processed. Returns TRUE if the document index is in EDIT mode and one or more users is actual watching at, FALSE in VIEW mode or if there nobody is watching at.

Return Value

bool

Returns TRUE if locked otherwise FALSE.

in UIComponent at line 221
string parse_template(string $template_content, array|bool $marker_array = false)

No description

Parameters

string $template_content

HTML Template

array|bool $marker_array

Markers and Values

Return Value

string

Parsed HTML Content

in UIComponent at line 234
string|null parse_template_cb_wrapper(mixed $matches)

No description

Parameters

mixed $matches

Return Value

string|null

in UIComponent at line 260
mixed|string parse_xtag($xml_source)

No description

Parameters

$xml_source

Return Value

mixed|string

Exceptions

ContentException

in UIAjaxComponent at line 168
process()

dummy process method - may be overwritten

at line 181
protected process_xui()

Process and prepare xui for rendering.

This method also maintains the document lock table by adding, updating and deleting users. The lock and view sequence of users is sorted by the visit timestamp. The first visitor is the user, that locks the document in EDIT mode and other users queued as viewers. Is the first user leaving, the next queued user locks the document.

in UIAjaxComponent at line 214
render()

Default render method. wraps the content provided by render_xui_content in a unique div and generates a JS object for the GUI

Exceptions

Exception

in UIComponent at line 268
mixed render_xtag_element()

No description

Return Value

mixed

at line 290
protected string|Template render_xui()

Rendering method for this xui component.

Displays the actual lock and view info for the target document index. The type of the note is based on the mode (EDIT|VIEW). If there is no message set in the process method, this component displays nothing.

Return Value

string|Template

in UIComponent at line 173
void reset_marker_content()

restores original content of marker_content

Return Value

void

in UIComponent at line 106
void set(mixed $var, mixed $value = false)

Set Variable / Option

Parameters

mixed $var

Name of Variable to Set (Alternative: Assoc-Array for multiple variables)

mixed $value

Value of Variable

Return Value

void

in UIAjaxComponent at line 92
void setDeferredLoading(bool $bool, string $message = '')

Set true to load the content deferred. Displays a placeholder while loading the content. Optional you can pass a message which will replace the default loading message.

Parameters

bool $bool
string $message

Return Value

void

at line 145
set_activity($activity)

Sets the activity for the targeted document index. This value effects the message, appearance and interaction of the document lock/view. Use EDIT if the current view is based on a document index and can be modified for instance by a form.

Use VIEW mode to display the current watching users for the target document index.

Parameters

$activity

VIEW = Display only the info of viewing users EDIT = Display locking info and viewing users.

in UIComponent at line 122
void set_array(mixed $member_array, mixed $vars)

Set Variable / Option for an array

Parameters

mixed $member_array

Name of Variable to Set (Alternative: Assoc-Array for multiple variables)

mixed $vars

Value of Variable

Return Value

void

at line 118
set_document_index(DocumentIndex $document_index_model)

Sets the id of the target document index.

This document index is the target document which can be viewed or locked by users.

Parameters

DocumentIndex $document_index_model

at line 106
set_document_index_id(int $id)

Sets the id of the target document index.

This document index is the target document which can be viewed or locked by users.

Parameters

int $id

in UIComponent at line 165
void set_marker_content(mixed $marker_content = false)

sets marker_content to passed data -> restore original content with reset_marker_content()

Parameters

mixed $marker_content

Return Value

void

in UIComponent at line 90
set_mod(mixed $mod)

Set link to owning module

Parameters

mixed $mod

in UIAjaxComponent at line 150
set_option(string $key, mixed $val)

Sets options. This options will be used in the JS element of this XUI class.

Parameters

string $key

update_interval (int) | hide_loading (bool)

mixed $val

in UIComponent at line 135
void set_render_params(mixed $input_params = array())

Used to inject params. Only allowed params will be used (see $allowed_params_filter)

Parameters

mixed $input_params

Return Value

void

at line 131
set_ttl(int $seconds)

Sets the time to live value. This value is used to remove exceeded locks and views on a document index. The ttl value is set to 30 seconds by default. All entries will bbe deleted where the update time is more than the specified ttl value in the past.

Parameters

int $seconds

Time in seconds.

in UIAjaxComponent at line 129
set_uid($uid)

No description

Parameters

$uid

in UIAjaxComponent at line 70
set_url_parameters(array $parameters)

Sets the url parameter that is used for component loading.

Parameters

array $parameters