| @@ 148-166 (lines=19) @@ | ||
| 145 | * @param stdClass $mapping |
|
| 146 | * @return string HTML |
|
| 147 | */ |
|
| 148 | protected function objectTable( $mapping ) { |
|
| 149 | $rows = []; |
|
| 150 | $empty = true; |
|
| 151 | ||
| 152 | foreach ( $mapping as $key => $val ) { |
|
| 153 | $rows[] = $this->objectRow( $key, $val ); |
|
| 154 | $empty = false; |
|
| 155 | } |
|
| 156 | if ( $empty ) { |
|
| 157 | $rows[] = Html::rawElement( 'tr', [], |
|
| 158 | Html::element( 'td', [ 'class' => 'mw-json-empty' ], |
|
| 159 | wfMessage( 'content-json-empty-object' )->text() |
|
| 160 | ) |
|
| 161 | ); |
|
| 162 | } |
|
| 163 | return Html::rawElement( 'table', [ 'class' => 'mw-json' ], |
|
| 164 | Html::rawElement( 'tbody', [], implode( '', $rows ) ) |
|
| 165 | ); |
|
| 166 | } |
|
| 167 | ||
| 168 | /** |
|
| 169 | * Create HTML table row representing one object property. |
|
| @@ 187-205 (lines=19) @@ | ||
| 184 | * @param array $mapping |
|
| 185 | * @return string HTML |
|
| 186 | */ |
|
| 187 | protected function arrayTable( $mapping ) { |
|
| 188 | $rows = []; |
|
| 189 | $empty = true; |
|
| 190 | ||
| 191 | foreach ( $mapping as $val ) { |
|
| 192 | $rows[] = $this->arrayRow( $val ); |
|
| 193 | $empty = false; |
|
| 194 | } |
|
| 195 | if ( $empty ) { |
|
| 196 | $rows[] = Html::rawElement( 'tr', [], |
|
| 197 | Html::element( 'td', [ 'class' => 'mw-json-empty' ], |
|
| 198 | wfMessage( 'content-json-empty-array' )->text() |
|
| 199 | ) |
|
| 200 | ); |
|
| 201 | } |
|
| 202 | return Html::rawElement( 'table', [ 'class' => 'mw-json' ], |
|
| 203 | Html::rawElement( 'tbody', [], implode( "\n", $rows ) ) |
|
| 204 | ); |
|
| 205 | } |
|
| 206 | ||
| 207 | /** |
|
| 208 | * Create HTML table row representing the value in an array. |
|