SECURITY: rate-limit and prevent blocked users from changing email
[lhc/web/wiklou.git] / includes / parser / PPNode_Hash_Attr.php
1 <?php
2 /**
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 * http://www.gnu.org/copyleft/gpl.html
17 *
18 * @file
19 * @ingroup Parser
20 */
21
22 /**
23 * @ingroup Parser
24 */
25 // phpcs:ignore Squiz.Classes.ValidClassName.NotCamelCaps
26 class PPNode_Hash_Attr implements PPNode {
27
28 public $name, $value;
29 private $store, $index;
30
31 /**
32 * Construct an object using the data from $store[$index]. The rest of the
33 * store array can be accessed via getNextSibling().
34 *
35 * @param array $store
36 * @param int $index
37 */
38 public function __construct( array $store, $index ) {
39 $descriptor = $store[$index];
40 if ( $descriptor[PPNode_Hash_Tree::NAME][0] !== '@' ) {
41 throw new MWException( __METHOD__ . ': invalid name in attribute descriptor' );
42 }
43 $this->name = substr( $descriptor[PPNode_Hash_Tree::NAME], 1 );
44 $this->value = $descriptor[PPNode_Hash_Tree::CHILDREN][0];
45 $this->store = $store;
46 $this->index = $index;
47 }
48
49 public function __toString() {
50 return "<@{$this->name}>" . htmlspecialchars( $this->value ) . "</@{$this->name}>";
51 }
52
53 public function getName() {
54 return $this->name;
55 }
56
57 public function getNextSibling() {
58 return PPNode_Hash_Tree::factory( $this->store, $this->index + 1 );
59 }
60
61 public function getChildren() {
62 return false;
63 }
64
65 public function getFirstChild() {
66 return false;
67 }
68
69 public function getChildrenOfType( $name ) {
70 return false;
71 }
72
73 public function getLength() {
74 return false;
75 }
76
77 public function item( $i ) {
78 return false;
79 }
80
81 public function splitArg() {
82 throw new MWException( __METHOD__ . ': not supported' );
83 }
84
85 public function splitExt() {
86 throw new MWException( __METHOD__ . ': not supported' );
87 }
88
89 public function splitHeading() {
90 throw new MWException( __METHOD__ . ': not supported' );
91 }
92 }