| Server IP : 85.158.181.41 / Your IP : 216.73.217.12 Web Server : Apache System : Linux cloud9-vm129 6.1.178+1-ph #ph SMP PREEMPT_DYNAMIC Wed Jul 29 09:00:54 UTC 2026 x86_64 User : moncbefd ( 1024) PHP Version : 7.3.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/moncbefd/www.moneta.at/callback/sofort/library/helper/ |
Upload File : |
<?php
/**
* @author SOFORT AG (integration@sofort.com)
* @link http://www.sofort.com/
*
* Copyright (c) 2012 SOFORT AG
*
* Released under the GNU General Public License (Version 2)
* [http://www.gnu.org/licenses/gpl-2.0.html]
*/
abstract class Element {
public abstract function render();
}
class Text extends Element {
public $text;
public $escape = false;
public function __construct($text, $escape = false, $trim = true) {
$this->text = $trim ? trim($text) : $text;
$this->escape = $escape;
}
public function render() {
return $this->escape ? htmlspecialchars($this->text) : $this->text;
}
}
class Tag extends Element {
public $tagname = '';
public $attributes = array();
public $children = array();
public function __construct($tagname, array $attributes = array(), $children = array()) {
$this->tagname = $tagname;
$this->attributes = $attributes;
$this->children = is_array($children) ? $children : array($children);
}
public function render() {
$output = '';
$attributes = '';
foreach ($this->children as $child) {
$output .= is_object($child) ? $child->render() : $child;
}
foreach ($this->attributes as $key => $value) {
$attributes .= " $key=\"$value\"";
}
return $this->_render($output, $attributes);
}
protected function _render($output, $attributes) {
return $output !== '' ? "<{$this->tagname}{$attributes}>{$output}</{$this->tagname}>" : "<{$this->tagname}{$attributes} />";
}
}
class HtmlTag extends Tag {
private static $selfClosingTags = array('base', 'meta', 'link', 'hr', 'br', 'param', 'img', 'area', 'input', 'col');
public function __construct($tagname, array $attributes = array(), $children = array()) {
$tagname = strtolower($tagname);
$loweredAttributes = array();
foreach ($attributes as $key => $value) {
$loweredAttributes[strtolower($key)] = $value;
}
parent::__construct($tagname, $loweredAttributes, $children);
}
protected function _render($output, $attributes) {
return in_array($this->tagname, self::$selfClosingTags) ? "<{$this->tagname}{$attributes} />" : "<{$this->tagname}{$attributes}>{$output}</{$this->tagname}>";
}
}
?>