Система управления «Сайт PRO»
Версия 20240107

Класс Element

Объект $Element: Cms\Root\Form\Element наследует DOMElement

Объект «Элемент формы»

Исходный код
class Element extends \DOMElement { … }

Свойства

$field

$Element->field
Исходный код
    var $field;

Методы

__construct()

new Element($name='field', $value=null, $namespaceURI=null);
Исходный код
    function __construct($name = 'field', $value = null, $namespaceURI = null) {
        switch (func_num_args()) {
            case 3: return parent::__construct($name, $value, $namespaceURI);
            case 2: return parent::__construct($name, $value);
            default: return parent::__construct($name);
        }
    }

display()

$Element->display($outer=true);
Исходный код
    function display($outer = true) {
        $html = array();
        $tagName = $this->tagName;
        /**
         * @if false
         * @var Document $ownerDocument
         * @endif
         */
        $ownerDocument = $this->ownerDocument;
        if ($outer && $this->nodeType === XML_ELEMENT_NODE) {
            if ($tagName === 'field') {
                if (isset($this->field)) {
                    $field = $this->field;
                } elseif (is_string($name = $this->getAttribute('name'))) {
                    $field = $ownerDocument->fields[$name];
                }
                if ($field) {
                    return $field->display();
                }
            } elseif ($tagName === 'input' || $tagName === 'select' || $tagName === 'textarea') {
                if (isset($this->field)) {
                    $field = $this->field;
                } elseif (is_string($name = $this->getAttribute('name'))) {
                    $field = $ownerDocument->fields[$name];
                }
                if ($field) {
                    return $field->displayInput();
                }
            } elseif ($tagName === 'group') {
                $group = new \Cms\Root\Form\Field\Group($this);
                return $group->display();
            } elseif ($tagName === 'script') {
                return $this->Main()->Display()->callTemplate('field', 'script', $this->Page(), array( 'Element' => $this, 'script' => $this ));
            } elseif ($tagName === 'clear') {
                return $this->Main()->Display()->callTemplate('field', 'clear', $this->Page(), array( 'Element' => $this ));
            } elseif ($tagName === 'hr') {
                return $this->Main()->Display()->callTemplate('field', 'hr', $this->Page(), array( 'Element' => $this ));
            }
        }
        if ($outer) {
            $html = array();
            $html[] = '<' . $tagName;
            foreach ($this->attributes as $attributeName => $attribute) $html[] = ' ' . $attributeName . '="' . htmlspecialchars($attribute->value) . '"';
            $html[] = '>';
        }
        /**
         * @if false
         * @var Element $childNode
         * @endif
         */
        foreach ($this->childNodes as $childNode) {
            if ($childNode->nodeType === XML_ELEMENT_NODE) {
                $html[] = $childNode->display();
            } elseif ($childNode->nodeType === XML_TEXT_NODE) {
                /**
                 * @if false
                 * @var DOMText $childNode
                 * @endif
                 */
                $html[] = $childNode->data;
            } elseif ($childNode->nodeType === XML_PI_NODE) {
                /**
                 * @if false
                 * @var DOMElement $childNode
                 * @endif
                 */
                if ($childNode->target === 'php') {
                    ob_start();
                    $r = $this->evalCode($childNode->data);
                    $html[] = ob_get_clean();
                    if (is_string($r)) $html[] = $r;
                }
            } elseif ($childNode->nodeType === XML_CDATA_SECTION_NODE) {
                $html[] = $childNode->nodeValue;
            }
        }
        if ($outer && !$this->isVoid()) {
            $html[] = '</' . $tagName . '>';
        }
        return implode('', $html);
    }

isVoid()

$Element->isVoid();
Исходный код
    function isVoid() {
        static $voidTags = array(
            'area',
            'base',
            'br',
            'col',
            'command',
            'embed',
            'hr',
            'img',
            'input',
            'keygen',
            'link',
            'meta',
            'param',
            'source',
            'track',
            'wbr',
        );
        return in_array($this->tagName, $voidTags);
    }

App()

$Element->App();
Исходный код
    function App() {
        return \Cms\Site\App::getInstance();
    }

root()

$Element->root();
Исходный код
    function root() {
        return $this->App()->root();
    }

Conf()

$Element->Conf();
Исходный код
    function Conf() {
        return $this->App()->Conf();
    }

Data()

$Element->Data();
Исходный код
    function Data() {
        return $this->App()->Data();
    }

Auth()

$Element->Auth();
Исходный код
    function Auth() {
        return $this->App()->Auth();
    }

Main()

$Element->Main();
Исходный код
    function Main() {
        return $this->App()->Main();
    }

Form()

$Element->Form();
Исходный код
    function Form() {
        return $this->App()->Form();
    }

Page()

$Element->Page();
Исходный код
    function Page() {
        /**
         * @if false
         * @var Document $ownerDocument
         * @endif
         */
        $ownerDocument = $this->ownerDocument;
        if (is_object($ownerDocument) && isset($ownerDocument->Page)) {
            return $ownerDocument->Page;
        }
    }

evalCode()

$Element->evalCode();
Исходный код
    function evalCode() {
        global $_RESULT; if (!is_array($_RESULT)) $_RESULT = array();
        $App = $this->App();
        $root = $App->root();
        $Conf = $App->Conf();
        $Data = $App->Data();
        $Auth = $App->Auth();
        $Main = $App->Main();
        $Form = $App->Form();
        $Page = $this->Page();
        $Request = $Main->Request();
        $Storage = $Main->Storage();
        $Modules = $Main->Modules();
        $Display = $Main->Display();
        return eval(func_get_arg(0) . ';');
    }