2015-04-27 14:05:31 +00:00
|
|
|
<?php
|
2022-03-11 20:35:51 +00:00
|
|
|
|
2018-08-09 09:49:10 +00:00
|
|
|
namespace PortableInfobox\Parser\Nodes;
|
2015-04-27 14:05:31 +00:00
|
|
|
|
2015-05-04 10:48:57 +00:00
|
|
|
class NodeData extends Node {
|
2021-09-10 02:52:19 +00:00
|
|
|
private const SPAN_ATTR_NAME = 'span';
|
|
|
|
private const SPAN_DEFAULT_VALUE = 1;
|
2017-01-10 12:59:46 +00:00
|
|
|
|
2021-09-10 02:52:19 +00:00
|
|
|
private const LAYOUT_ATTR_NAME = 'layout';
|
|
|
|
private const LAYOUT_DEFAULT_VALUE = 'default';
|
2015-04-27 14:05:31 +00:00
|
|
|
|
|
|
|
public function getData() {
|
2015-06-10 09:28:33 +00:00
|
|
|
if ( !isset( $this->data ) ) {
|
|
|
|
$this->data = [
|
2015-07-01 08:55:58 +00:00
|
|
|
'label' => $this->getInnerValue( $this->xmlNode->{self::LABEL_TAG_NAME} ),
|
2017-01-10 12:59:46 +00:00
|
|
|
'value' => $this->getValueWithDefault( $this->xmlNode ),
|
|
|
|
'span' => $this->getSpan(),
|
2018-12-27 01:01:19 +00:00
|
|
|
'layout' => $this->getLayout(),
|
2019-02-02 22:34:48 +00:00
|
|
|
'source' => $this->getPrimarySource(),
|
|
|
|
'item-name' => $this->getItemName()
|
2015-06-10 09:28:33 +00:00
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this->data;
|
2015-04-27 14:05:31 +00:00
|
|
|
}
|
2017-01-10 12:59:46 +00:00
|
|
|
|
|
|
|
protected function getSpan() {
|
|
|
|
$span = $this->getXmlAttribute( $this->xmlNode, self::SPAN_ATTR_NAME );
|
|
|
|
|
2017-01-10 13:28:24 +00:00
|
|
|
return ( isset( $span ) && ctype_digit( $span ) ) ? intval( $span ) : self::SPAN_DEFAULT_VALUE;
|
2017-01-10 12:59:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
protected function getLayout() {
|
|
|
|
$layout = $this->getXmlAttribute( $this->xmlNode, self::LAYOUT_ATTR_NAME );
|
|
|
|
|
|
|
|
return ( isset( $layout ) && $layout == self::LAYOUT_DEFAULT_VALUE ) ? $layout : null;
|
|
|
|
}
|
2015-04-27 14:05:31 +00:00
|
|
|
}
|