yf_html5fw class

Abstraction layer over HTML5/CSS frameworks: conf('css_framework') = bs3 (default), bs4, bs5 or empty (no framework classes).

Fileplugins/html/classes/yf_html5fw.class.php
Use_class('html5fw')

Public properties

A site sets them in its config with $PROJECT_CONF['html5fw']['NAME'] = ...;

PropertyDefaultDescription
$DEFAULT_CSS_FRAMEWORK
string
'bs3' used when conf('css_framework') is empty (yf_main::init_constants() sets bs3)
$REMOVED_CSS_FRAMEWORKS
array
['bs2' => 'Bootstrap 2', 'foundation' => 'Zurb Foundation', 'pure' => 'Pure CSS', 'semantic_ui' => 'Semantic UI', 'uikit' => 'UIkit', 'maxmert' => 'Maxmertkit'] Deleted frameworks: name => reason; a requested one warns once per request and renders with the `empty` driver
$_removed_warned
array
[] @conf_skip removed names already reported in this request

Public methods 7

form_dd_row

public function form_dd_row($content, $extra = [], $replace = [], $obj = null)
    public function form_dd_row($content, $extra = [], $replace = [], $obj = null)
    {
        return $this->_driver($extra)->form_dd_row($content, $extra, $replace, $obj);
    }
public function form_render_out($content, $extra = [], $replace = [], $obj = null)
    public function form_render_out($content, $extra = [], $replace = [], $obj = null)
    {
        return $this->_driver($extra)->form_render_out($content, $extra, $replace, $obj);
    }

form_row

public function form_row($content, $extra = [], $replace = [], $obj = null)
    public function form_row($content, $extra = [], $replace = [], $obj = null)
    {
        return $this->_driver($extra)->form_row($content, $extra, $replace, $obj);
    }

Methods starting with _ hooks and helpers; not routable as page actions

__call

public function __call($name, $args)

Catch missing method call.

    public function __call($name, $args)
    {
        return main()->extend_call($this, $name, $args);
    }

__clone

public function __clone()

We cleanup object properties when cloning.

    public function __clone()
    {
        foreach ((array) get_object_vars($this) as $k => $v) {
            $this->$k = null;
        }
    }

__toString

public function __toString(): string

Need to avoid calling render() without params.

    public function __toString()
    {
        try {
            return (string) $this->render();
        } catch (Exception $e) {
            return '';
        }
    }

_driver

public function _driver($extra = [])

The driver for the per-call css_framework, else conf('css_framework'), else DEFAULT_CSS_FRAMEWORK.

    public function _driver($extra = [])
    {
        $per_call = is_array($extra) && is_scalar($extra['css_framework'] ?? null) ? $extra['css_framework'] : '';
        $name = (string) ($per_call ?: conf('css_framework') ?: $this->DEFAULT_CSS_FRAMEWORK);
        if (isset($this->REMOVED_CSS_FRAMEWORKS[$name])) {
            if ( ! isset($this->_removed_warned[$name])) {
                $this->_removed_warned[$name] = true;
                trigger_error('HTML5FW: css_framework "' . $name . '" (' . $this->REMOVED_CSS_FRAMEWORKS[$name] . ') was removed, see https://github.com/yfix/yf/blob/master/docs/UPGRADING.md; rendering with "empty", use bs3, bs4 or bs5', E_USER_WARNING);
            }
            $name = 'empty';
        }
        return _class('html5fw_' . $name, 'classes/html5fw/');
    }