本文整理汇总了PHP中DOMElement::__construct方法的典型用法代码示例。如果您正苦于以下问题:PHP DOMElement::__construct方法的具体用法?PHP DOMElement::__construct怎么用?PHP DOMElement::__construct使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DOMElement
的用法示例。
在下文中一共展示了DOMElement::__construct方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* 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);
}
}
示例2: __construct
/**
* @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
}
示例3: __construct
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);
}
示例4: __construct
/**
* 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);
}
}
示例5: __construct
/**
* 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');
}
}
示例6: __construct
/**
* 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);
}
}
示例7: __construct
/**
* 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);
}
示例8: __construct
public function __construct()
{
parent::__construct('testsuite');
}
示例9: __construct
/**
* 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);
}
示例10: __construct
/**
* @param string $name
* @param string $value
* @param string $namespaceURI
*/
public function __construct($name = null, $value = null, $namespaceURI = null)
{
parent::__construct('testsuite', $value, $namespaceURI);
}
示例11: __construct
public function __construct($rows = 1, $cols = 1)
{
$this->rows = $rows;
$this->cols = $cols;
parent::__construct('table');
}
示例12: __construct
/**
* Create a new <thead> using DOMElement
*
* @param void
*/
public function __construct()
{
parent::__construct('thead');
}
示例13: __construct
/**
* Create a new <tfoot> using DOMElement
*
* @param void
*/
public function __construct()
{
parent::__construct('tfoot');
}
示例14: __construct
/**
* Create a new <tbody> using DOMElement
*
* @param void
*/
public function __construct()
{
parent::__construct('tbody');
}
示例15: __construct
public function __construct($val)
{
parent::__construct('value', htmlspecialchars($val));
$this->value = $val;
}