diff options
Diffstat (limited to 'www/wiki/extensions/SemanticResultFormats/src/Outline/OutlineItem.php')
-rw-r--r-- | www/wiki/extensions/SemanticResultFormats/src/Outline/OutlineItem.php | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/www/wiki/extensions/SemanticResultFormats/src/Outline/OutlineItem.php b/www/wiki/extensions/SemanticResultFormats/src/Outline/OutlineItem.php new file mode 100644 index 00000000..7b273c25 --- /dev/null +++ b/www/wiki/extensions/SemanticResultFormats/src/Outline/OutlineItem.php @@ -0,0 +1,62 @@ +<?php + +namespace SRF\Outline; + +/** + * Represents a single item, or page, in the outline - contains both the + * SMWResultArray and an array of some of its values, for easier aggregation + * + * @license GNU GPL v2+ + * @since 3.1 + */ +class OutlineItem { + + /** + * @var [type] + */ + public $row; + + /** + * @var [] + */ + private $vals; + + /** + * @since 3.1 + * + * @param $row + */ + public function __construct( $row ) { + $this->row = $row; + $this->vals = []; + } + + /** + * @since 3.1 + * + * @param $name + * @param $value + */ + public function addFieldValue( $key, $value ) { + if ( array_key_exists( $key, $this->vals ) ) { + $this->vals[$key][] = $value; + } else { + $this->vals[$key] = [ $value ]; + } + } + + /** + * @since 3.1 + * + * @param $row + */ + public function getFieldValues( $key ) { + + if ( array_key_exists( $key, $this->vals ) ) { + return $this->vals[$key]; + } + + return [ wfMessage( 'srf_outline_novalue' )->text() ]; + } + +} |