Exemple #1
0
 /**
  * Created a new HTML Element
  *
  * @param string $name         The tag name of the element
  * @param string $value        The value of the element.
  * @param string $namespaceURI A namespace URI to create the element within a specific namespace.
  * @param bool   $createDoc    Whether or not to create parent document and append to
  */
 public function __construct($name = 'div', $value = null, $namespaceURI = null, $createDoc = false)
 {
     parent::__construct($name, $value, $namespaceURI);
     if ($createDoc) {
         (new \DOMDocument())->appendChild($this);
     }
 }
 /**
  * @param null|DOMDocument $dom
  * @param $root
  * @param array $atts
  * @param string $tag
  */
 public function __construct($root = null, $atts = array(), $tag = 'param', $value = '')
 {
     //get ns
     if (HW_XML::getNS($tag)) {
         //namespace detect
         $ns = HW_WXR_Parser_SimpleXML::valid_namespaces(null, HW_XML::getNS($tag));
         parent::__construct($tag, null, $ns);
     } else {
         parent::__construct($tag);
     }
     if ($atts instanceof DOMElement) {
         $this->element = $atts;
     } else {
         $this->element = $this;
     }
     if (!$this->element->ownerDocument) {
         //make sure element not move from exists dom
         $this->dom = new DOMDocument(HW_Export::XML_VERSION, HW_Export::XML_ENCODING);
         //note: add to dom before do anything on DOMElement object
         $this->element = $this->dom->importNode($this->element, true);
         //convert
         $this->dom->appendChild($this->element);
     } else {
         $this->dom = $this->element->ownerDocument;
     }
     if (!empty($value) && is_string($value)) {
         $this->element->nodeValue = $value;
     }
     if (is_array($atts) && count($atts)) {
         foreach ($atts as $key => $value) {
             $this->element->setAttribute($key, $value);
         }
     }
     //$this->nodeValue = '';  //remove node value
 }
 public function __construct($name, $value = '', $namespaceURI = '')
 {
     list($ns, $name) = $this->splitns($name);
     $value = htmlspecialchars($value);
     if (!$namespaceURI && $ns) {
         $namespaceURI = $this->namespaces[$ns];
     }
     parent::__construct($name, $value, $namespaceURI);
 }
Exemple #4
0
 /**
  * Class constructor | Creates a new DOMElement
  *
  * @param string $name         [TagName for new element]
  * @param string $value        [nodeValue/textContent for new element]
  * @param string $namespaceURI [Namespace for new element]
  */
 public function __construct($name, $content = null, $namespaceURI = null)
 {
     if (is_string($content) or is_numeric($content)) {
         parent::__construct($name, "{$content}", $namespaceURI);
     } elseif (isset($content) and is_object($content) and in_array(get_class($content), ['DOMElement', 'DOMNode', 'core\\resources\\XML_Node'])) {
         parent::__construct($name, null, $namespaceURI);
         $this->append($content);
     } else {
         parent::__construct($name, null, $namespaceURI);
     }
 }
Exemple #5
0
 /**
  * Creates a new <script> element with options for src, async, defer, and type
  *
  * @param string $src   The source URL
  * @param bool   $async Whether or not the script is to be asynchronous
  * @param bool   $defer Whether or not to defer parsing of script
  * @param string $type  The type attribute, defaults to "application/javascript" without version
  */
 public function __construct($src, $async = false, $defer = false, $type = 'application/javascript')
 {
     parent::__construct('script');
     (new \DOMDocument('1.0', 'UTF-8'))->appendChild($this);
     $this->setAttribute('src', $src);
     $this->setAttribute('type', $type);
     if ($async) {
         $this->setAttribute('async', 'async');
     }
     if ($defer) {
         $this->setAttribute('defer', 'defer');
     }
 }
Exemple #6
0
 /**
  * Creates a new <dialog> element, along with the delete/close button
  *
  * @param string $id      The id attribute, used to close/delete & show dialog
  * @param mixed  $content String or \DOMNode
  */
 public function __construct($id, $content = null)
 {
     $this->id = "#{$id}" . self::ID_SUFFIX;
     parent::__construct(self::TAG);
     (new \DOMDocument('1.0', 'UTF-8'))->appendChild($this);
     $this->setAttribute('id', $id . self::ID_SUFFIX);
     $this->appendChild(new \DOMElement('button'))->setAttribute('data-delete', $this->id);
     $fullscreen = $this->appendChild(new \DOMElement('button'));
     $fullscreen->setAttribute('data-fullscreen', $this->id);
     $fullscreen->setAttribute('title', 'View full-screen');
     $this->appendChild(new \DOMElement('br'));
     $svg = $fullscreen->appendChild(new \DOMElement('svg'));
     $svg->setAttribute('class', 'currentColor icon');
     $use = $svg->appendChild(new \DOMElement('use'));
     $use->setAttribute('xlink:href', 'images/icons/combined.svg#screen-full');
     if ($content instanceof \DOMNode) {
         $this->appendChild(isset($content->ownerDocument) ? $this->ownerDocument->importNode($content, true) : $content);
     } elseif (is_string($content)) {
         $this->importHTML($content);
     }
 }
Exemple #7
0
 /**
  * Creates the table element, along with its head, foot, & body
  *
  * @param string $col ...    Any number of strings to create columns from
  */
 public function __construct()
 {
     parent::__construct('table');
     (new \DOMDocument('1.0', 'UTF-8'))->appendChild($this);
     $this->_headers = array_filter(func_get_args(), 'is_string');
     $this->_headers = array_map('strtolower', $this->_headers);
     $this->_getEmptyRow();
     $this->_thead = $this->appendChild(new THead());
     $this->_tfoot = $this->appendChild(new TFoot());
     $this->_tbody = $this->appendChild(new TBody());
     $this->_thead->build($this->_headers);
     $this->_tfoot->build($this->_headers);
 }
 public function __construct()
 {
     parent::__construct('testsuite');
 }
 /**
  * Create a new instance of XDOMElement.
  *
  * @param string      $name         The tag name of the element.
  * @param string|null $value        The value of the element.
  * @param string|null $namespaceURI The namespace of the element.
  */
 public function __construct($name, $value = null, $namespaceURI = null)
 {
     parent::__construct($name, null, $namespaceURI);
 }
 /**
  * @param string $name
  * @param string $value
  * @param string $namespaceURI
  */
 public function __construct($name = null, $value = null, $namespaceURI = null)
 {
     parent::__construct('testsuite', $value, $namespaceURI);
 }
 public function __construct($rows = 1, $cols = 1)
 {
     $this->rows = $rows;
     $this->cols = $cols;
     parent::__construct('table');
 }
Exemple #12
0
 /**
  * Create a new <thead> using DOMElement
  *
  * @param void
  */
 public function __construct()
 {
     parent::__construct('thead');
 }
Exemple #13
0
 /**
  * Create a new <tfoot> using DOMElement
  *
  * @param void
  */
 public function __construct()
 {
     parent::__construct('tfoot');
 }
Exemple #14
0
 /**
  * Create a new <tbody> using DOMElement
  *
  * @param void
  */
 public function __construct()
 {
     parent::__construct('tbody');
 }
Exemple #15
0
 public function __construct($val)
 {
     parent::__construct('value', htmlspecialchars($val));
     $this->value = $val;
 }