1 | <?php |
||
26 | class PlainTextParser { |
||
27 | |||
28 | /** @var IL10N */ |
||
29 | protected $l; |
||
30 | |||
31 | /** |
||
32 | * @param IL10N $l |
||
33 | */ |
||
34 | 8 | public function __construct(IL10N $l) { |
|
37 | |||
38 | /** |
||
39 | * Parse the parameters in the subject and message |
||
40 | * |
||
41 | * @param string $message |
||
42 | * @return string |
||
43 | */ |
||
44 | 5 | public function parseMessage($message) { |
|
49 | |||
50 | /** |
||
51 | * Parse collections |
||
52 | * |
||
53 | * @param string $message |
||
54 | * @return string |
||
55 | */ |
||
56 | 5 | protected function parseCollections($message) { |
|
57 | return \preg_replace_callback('/<collection>(.*?)<\/collection>/', function ($match) { |
||
58 | $parameterList = \explode('><', $match[1]); |
||
59 | $parameterListLength = \sizeof($parameterList); |
||
60 | |||
61 | $parameters = []; |
||
62 | for ($i = 0; $i < $parameterListLength; $i++) { |
||
63 | $parameter = $parameterList[$i]; |
||
64 | if ($i > 0) { |
||
65 | $parameter = '<' . $parameter; |
||
66 | } |
||
67 | if ($i + 1 < $parameterListLength) { |
||
68 | $parameter = $parameter . '>'; |
||
69 | } |
||
70 | |||
71 | $parameters[] = $this->parseParameters($parameter); |
||
72 | } |
||
73 | if ($parameterListLength === 1) { |
||
74 | return \array_pop($parameters); |
||
75 | } else { |
||
76 | $lastParameter = \array_pop($parameters); |
||
77 | return $this->l->t('%s and %s', [ |
||
78 | \implode($this->l->t(', '), $parameters), |
||
79 | $lastParameter, |
||
80 | ]); |
||
81 | } |
||
82 | 5 | }, $message); |
|
83 | } |
||
84 | |||
85 | /** |
||
86 | * Parse the parameters in the subject and message |
||
87 | * |
||
88 | * @param string $message |
||
89 | * @return string |
||
90 | */ |
||
91 | 5 | protected function parseParameters($message) { |
|
98 | |||
99 | /** |
||
100 | * Display the parameter value |
||
101 | * |
||
102 | * @param string $message |
||
103 | * @return string |
||
104 | */ |
||
105 | 5 | protected function parseUntypedParameters($message) { |
|
110 | |||
111 | /** |
||
112 | * Display the users display name |
||
113 | * |
||
114 | * @param string $message |
||
115 | * @return string |
||
116 | */ |
||
117 | 5 | protected function parseUserParameters($message) { |
|
123 | |||
124 | /** |
||
125 | * Display the full cloud id |
||
126 | * |
||
127 | * @param string $message |
||
128 | * @return string |
||
129 | */ |
||
130 | 5 | protected function parseFederatedCloudIDParameters($message) { |
|
135 | |||
136 | /** |
||
137 | * Display the path for files |
||
138 | * |
||
139 | * @param string $message |
||
140 | * @return string |
||
141 | */ |
||
142 | protected function parseFileParameters($message) { |
||
147 | } |
||
148 |