Skip to content

classes_base_renderable.class

Daniel Spors edited this page Nov 14, 2024 · 5 revisions

Classes in file base/renderable.class.php

abstract class Renderable

Base class for all HTML related stuff.

Implements: <>

Subclasses: Control, Template

after

Inserts content after this element.

Definition: public function after($content)

Returns: static

Parameters:

  • mixed $content Content to be inserted

append

Appends content to this Renderable. This works exactly as Renderable::content but will return $this instead of the appended content.

Definition: public function append($content)

Returns: static

Parameters:

  • mixed $content The content to be appended

appendTo

Append this Renderable to another Renderable.

Definition: public function appendTo($target)

Returns: static

Parameters:

capture

Captures $this to the given $variable. This may me used to capture an instance from a method chain like this:

TextInput::Make()->capture($tb)->appendTo($some_container)->par()->prepend($tb->CreateLabel('enter mail:'));	

Definition: public function capture($variable)

Returns: static

Parameters:

  • static $variable Variable to assign $this to

CategorizeResources

INTERNAL Prepares given resources to be processed

clearContent

Clears all contents.

Definition: public function clearContent()

Returns: static

closest

Returns the next Control of a given type when stepping up the object tree.

Definition: public function closest($classname)

Returns: mixed The closest object or false if not found

Parameters:

  • string $classname Class to search for

content

Adds content to the Renderable. Note that this will not return $this but the $content. This allows for method chaining like this:

$this->content( new Control('div') )->css('border','1px solid red')->addClass('mydiv')->content('DIVs content');	

Definition: public function content($content, $replace=false)

Returns: T The content added

Parameters:

  • T $content The content to be added

  • bool $replace if true replaces the whole content.

first

Returns the first content. Note that this does not behave like Renderable::get(0) because it wont throw an Exception when there's no content, but return a new empty Control object.

Definition: public function first()

Returns: Renderable First content or new empty Control

get

Gets the content at index $index.

Definition: public function get($index)

Returns: mixed Content at index $index

Parameters:

  • int $index Zero based index of content to get

GetCurrentRenderer

INTERNAL Returns the current rendering object.

GetRenderingRoot

INTERNAL Gets the current rendering root object

hasContentOfInstance

Returns if there is an element in the content with the given instance type

Definition: public function hasContentOfInstance($type)

Returns: bool True if an element of given instance was found

Parameters:

  • mixed $type Instance type to search for (via InstanceOf)

HasCurrentRenderer

INTERNAL Checks if the rendering stack is empty

HasRenderingRoot

INTERNAL Checks if there's a current rendering root object

indexOf

Returns the zero based index of $content. Checks the content array for the given $content and returns it's index of found. Returns -1 if not found.

Definition: public function indexOf($content)

Returns: int Zero based index or -1 if not found

Parameters:

  • mixed $content Content to search for

insert

Inserts something to the contents of this Renderable.

Definition: public function insert($content, $index)

Returns: static

Parameters:

  • mixed $content Content to be prepended

  • int|static $index Zero base index where to insert OR Renderable to insert before

insertBefore

Adds this Renderable before another Renderable. In fact it will be inserted before the other Renderable into the other Renderables parent.

Definition: public function insertBefore($target)

Returns: static

Parameters:

isChildOf

Check if this is part of another objects tree.

Definition: public function isChildOf(Renderable $object)

Returns: bool True if this is child of object, else false

Parameters:

  • Renderable $object Root object to test

jsonSerialize

Returns all data needed for serializing this object into JSON. Note: This does not return a string, but an object to be serialized.

Definition: public function jsonSerialize()

Returns: object|array If SlimSerialisation is active, returns an array, else returns $this

last

Returns the last content. Note that this does not behave like Renderable::get(<last_index>) because it wont throw an Exception when there's no content at last_index, but return a new empty Control object.

Definition: public function last()

Returns: Renderable Last content or new empty Control

length

Gets the number of contents.

Definition: public function length()

Returns: int Length of the contents array

next

Return $this objects direct successor. Checks the parents content for $this and returns the object that was inserted directly after $this. Note that this method may throw an Exception when there's no parent or if $this is the last child.

Definition: public function next()

Returns: Renderable This objects successor in it's parent's content

par

Returns this Renderables parent object. Note that this will throw an Exception when $this has not (yet) been added to another Renderable.

Definition: public function par()

Returns: Renderable Parent object

PopRenderer

INTERNAL Removes an object from the rendering stack.

prepend

Prepends something to the contents of this Renderable.

Definition: public function prepend($content)

Returns: static

Parameters:

  • mixed $content Content to be prepended

prependTo

Prepends this Renderable to another Renderable.

Definition: public function prependTo($target)

Returns: static

Parameters:

PreRender

INTERNAL Dummy. Can be used in subclasses by overriding.

prev

Return $this objects direct predecessor. Checks the parents content for $this and returns the object that was inserted directly before $this. Note that this method may throw an Exception when there's no parent or if $this is the first child.

Definition: public function prev()

Returns: Renderable This objects predecessor in it's parent's content

PushRenderer

INTERNAL Adds an object to the rendering stack.

rmContent

Removes content.

Definition: public function rmContent($content)

Returns: static

Parameters:

  • mixed $content The content to be removed

script

Adds JavaScript-Code to the Renderable object.

Definition: public function script($scriptCode)

Returns: static

Parameters:

  • array|string $scriptCode JS code to be added

StartSlimSerialize

INTERNAL Starts slim serialization mode (see Renderable::jsonSerialize)

StopSlimSerialize

INTERNAL Stops slim serialization mode (see Renderable::jsonSerialize)

WdfRender

Renders this Renderable. Extending classes must implement this (Control, Template).

Definition: public abstract function WdfRender()

Returns: string The rendered object

WdfRenderAsRoot

Renders this Renderable as controller. Extending classes must implement this (Control, Template).

Definition: public abstract function WdfRenderAsRoot()

Returns: string The rendered object

WdfRenderInline

Renders this instance without dependencies direcly.

Definition: public function WdfRenderInline()

Returns: string Rendered HTML content

wrap

Wraps this Renderable into another one. Not words, just samples:

$wrapper = new Control('div');	
$inner = new Control('span');	
$inner->content('INNER');	
$inner->wrap($wrapper)->content("I am below 'INNER'");	
// or	
$inner = new Control('span');	
$inner->content('INNER');	
$inner->wrap('div')->content("I am below 'INNER'");	
// or	
$inner = new Control('span');	
$inner->content('INNER');	
$inner->wrap(new Control('div'))->content("I am below 'INNER'");	

Definition: public function wrap($tag_or_obj)

Returns: Renderable The (new) wrapping control

Parameters:

  • mixed $tag_or_obj String or Renderable, see samples

__collectResourcesInternal

Definition: protected function __collectResourcesInternal($template, $static_stack)

Returns: array

Parameters:

  • $template NOT DOCUMENTED

  • $static_stack NOT DOCUMENTED

__toString

Definition: public function __toString()

Returns: string

Clone this wiki locally