Skip to content

classes_base_control.class

Daniel Spors edited this page Dec 19, 2023 · 3 revisions

Classes in file base/control.class.php

class Control

Base class for interactive webpage content like AJAX TextInputs.

Extends: Renderable

Subclasses: Anchor, CanvasGauge, ChartJS3, ColGroup, ContextMenu, Datamap, Form, GoogleControl, HtmlList, HtmlListItem, Image, ImageButton, ImageLink, Input, Label, LeafLet, Select, Table, TBody, Td, TextArea, TimeFormatEx, Toggle, Tr, uiControl, uiNavigationItem, uiTreeNode, WdfListing

addClass

Adds a value to the 'class' attribute. Note: you may pass multiple classes at once in a tring space separated: 'cls1 cls2'

Definition: public function addClass($class)

Returns: static

Parameters:

  • string $class CSS class(es)

addDocReady

SHORTCUT Control

attr

Attribute handling. This method may be used in four different ways:

  1. to get all attributes
  2. to get one attribute
  3. to set one attribute
  4. to set many attributes

To achieve this pass different parameters into like this:

  1. $c->attr() returns all attributes
  2. $c->attr('name') returns the 'name' attributes value
  3. $c->attr('name','mycontrol') sets the 'name' attribute values
  4. $c->attr(['name'=>'myname','href'=>'my.domain']) sets 'name' and 'href' attribute values

Note: Will return $this in cases 3. and 4. (the set cases).

Definition: public function attr($args)

Returns: static|mixed $this, an attribute value or an array of attribute values

Parameters:

  • mixed $args Arguments as described

capture

Overrides Renderable::capture to ensure a valid id.

Definition: public function capture($variable)

Returns: static

Parameters:

  • static $variable Variable to assign $this to

CloseTagNeeded

Checks whether this control needs a closing tag (in HTML code).

Definition: protected function CloseTagNeeded()

Returns: bool true if needed

css

Adds a CSS property to the control. If value is an integer (or numeric string like '12') 'px' will be added.

Definition: public function css($name, $value)

Returns: static

Parameters:

  • string $name Name of the CSS property (like width, background-image,...)

  • string $value Value of the CSS property

data

data-* attribute Handling This work exaclty like Control::attr but with all the data-* attributes.

Definition: public function data($args)

Returns: static|mixed $this, a data-attribute value or an array of data-attributes

Parameters:

  • mixed $args Arguments as described

IsAllowedAttribute

Checks if the given attribute is valid for a html element like this (depending on tag).

Definition: protected function IsAllowedAttribute($attr)

Returns: bool true if valid

Parameters:

  • string $attr The attribute to check

Make

Static creator method This is cabable of creating derivered classes too:

Control::Make('div')->content('Doh!');	
TextInput::Make()->css('width','300px');	

Arguments will be passed to constructor.

Definition: public static function Make($args)

Returns: static The created control

Parameters:

  • mixed $args Arguments as described

PreRender

INTERNAL Will be executed on HOOK_PRE_RENDER. Adds this controls init code to rendering HtmlPage if root is of that type.

removeAttr

Removes attribute $name.

Definition: public function removeAttr($name)

Returns: static

Parameters:

  • string $name Attribute name

removeClass

Removes a value from the 'class' attribute.

Definition: public function removeClass($class)

Returns: static

Parameters:

  • string $class CSS class

removeData

Removes a data-$name attribute.

Definition: public function removeData($name)

Returns: static

Parameters:

  • string $name Data name

setData

DEPRECATED (2021/10) Use Control::data instead Set a value to a data-$name attribute. Those can be accessed in JS easily using jQuery.data method

setTitle

Sets the title attribute.

Definition: public function setTitle($title)

Returns: static

Parameters:

  • string $title Value for the title-atribute

WdfRender

OVERRIDE Renderable::WdfRender

WdfRenderAsRoot

OVERRIDE Renderable::WdfRenderAsRoot

__construct

Constructs a Control

Definition: public function __construct($tag)

Returns: NOT DOCUMENTED

Parameters:

  • string $tag The HTML Tag of this control. Default ""

__get

INTERNAL Magic method __get. See Member overloading

__isset

INTERNAL Magic method __isset. See Member overloading

__method_exists

INTERNAL Checks if this class implements a method.

__set

INTERNAL Magic method __set. See Member overloading

__toString

These are HTML tags. Each (1st dimension) array key represents a tag and the value (array) contains all attributes that are allowed to use with it.

Definition: public function __toString()

Returns: NOT DOCUMENTED

Clone this wiki locally