summaryrefslogtreecommitdiff
path: root/www/wiki/extensions/SemanticResultFormats/src/Outline/OutlineItem.php
blob: 7b273c25f4c8018380bca22fe6dfa50f03639cde (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
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() ];
	}

}