2015-04-27 14:05:31 +00:00
|
|
|
<?php
|
|
|
|
namespace Wikia\PortableInfobox\Parser\Nodes;
|
|
|
|
|
2015-05-04 10:48:57 +00:00
|
|
|
class NodeData extends Node {
|
2017-01-10 12:59:46 +00:00
|
|
|
const SPAN_ATTR_NAME = 'span';
|
|
|
|
const SPAN_DEFAULT_VALUE = 1;
|
|
|
|
|
|
|
|
const LAYOUT_ATTR_NAME = 'layout';
|
|
|
|
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(),
|
|
|
|
'layout' => $this->getLayout()
|
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
|
|
|
}
|