blob: 099b306a4776bc8a6ca62c03ef3acd962cf2239c (
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
<?php
/**
* @ingroup SMWDataItems
*/
/**
* This class implements error list data items. These data items are used to
* pass around lists of error messages within the application. They are not
* meant to be stored or exported, but they can be useful to a user.
*
* @since 1.6
*
* @author Markus Krötzsch
* @ingroup SMWDataItems
*/
class SMWDIError extends SMWDataItem {
/**
* List of error messages. Should always be safe for HTML.
* @var array of strings
*/
protected $m_errors;
/**
* @var string
*/
private $userValue;
public function __construct( $errors, $userValue = '' ) {
$this->m_errors = $errors;
$this->userValue = $userValue;
}
public function getDIType() {
return SMWDataItem::TYPE_ERROR;
}
public function getErrors() {
return $this->m_errors;
}
/**
* @since 3.0
*
* @return string
*/
public function getUserValue() {
return $this->userValue;
}
public function getSortKey() {
return 'error';
}
public function getString() {
return $this->getSerialization();
}
public function getSerialization() {
return serialize( $this->m_errors );
}
/**
* Create a data item from the provided serialization string and type
* ID.
* @todo Be more careful with unserialization. It can create E_NOTICEs.
* @return SMWDIError
*/
public static function doUnserialize( $serialization ) {
return new SMWDIError( unserialize( $serialization ) );
}
public function equals( SMWDataItem $di ) {
if ( $di->getDIType() !== SMWDataItem::TYPE_ERROR ) {
return false;
}
return $di->getSerialization() === $this->getSerialization();
}
}
|