Ejemplo n.º 1
0
 /**
  * Creates a new instance of HTML
  *
  * @param string $doctype  <!DOCTYPE $doctype>
  * @param string $encoding <meta charset="$encoding">
  */
 public function __construct($doctype = self::DEFAULT_DOCTYPE, $encoding = self::ENCODING)
 {
     $this->_createDocument($doctype, $encoding);
     $this->registerNodeClass('\\DOMElement', '\\' . __NAMESPACE__ . '\\HTMLElement');
     $this->registerNodeClass('\\DOMDocumentFragment', '\\' . __NAMESPACE__ . '\\Fragment');
     $this->registerNodeClass('\\DOMText', '\\' . __NAMESPACE__ . '\\Text');
     $this->appendChild($this->createElement('html'));
     $this->head = $this->createElement('head');
     $this->body = $this->createElement('body');
     $this->documentElement->appendChild($this->head);
     $this->documentElement->appendChild($this->body);
     $this->head->append('meta', null, ['charset' => $encoding]);
 }
Ejemplo n.º 2
0
<?php

namespace Index;

use shgysk8zer0\Core;
use shgysk8zer0\Core_API as API;
use shgysk8zer0\DOM;
Core\Console::getInstance()->asErrorHandler()->asExceptionHandler();
DOM\HTMLElement::$import_path = realpath(getenv('COMPONENTS_DIR'));
function build_head(\DOMElement &$head)
{
    $head('head');
}
function build_body(\DOMElement &$body)
{
    $body->parentNode->class = 'no-js';
    $body->class = 'flex column';
    $body('header', 'main', 'footer');
}
function init()
{
    $headers = Core\Headers::getInstance();
    $dom = DOM\HTML::getInstance();
    if (in_array('text/html', explode(',', $headers->accept))) {
        build_head($dom->head);
        build_body($dom->body);
        return $dom;
    } elseif ($headers->accept === 'application/json' and !empty($_REQUEST)) {
        require_once './components/handlers/request.php';
        return \Components\Handlers\Request\handle($_REQUEST);
    } else {