MediaWiki  1.34.0
XmlJsCode.php
Go to the documentation of this file.
1 <?php
40 class XmlJsCode {
41  public $value;
42 
43  function __construct( $value ) {
44  $this->value = $value;
45  }
46 
58  public static function encodeObject( $obj, $pretty = false ) {
59  $parts = [];
60  foreach ( $obj as $key => $value ) {
61  $parts[] =
62  ( $pretty ? ' ' : '' ) .
63  Xml::encodeJsVar( $key, $pretty ) .
64  ( $pretty ? ': ' : ':' ) .
65  Xml::encodeJsVar( $value, $pretty );
66  }
67  return new self(
68  '{' .
69  ( $pretty ? "\n" : '' ) .
70  implode( $pretty ? ",\n" : ',', $parts ) .
71  ( $pretty ? "\n" : '' ) .
72  '}'
73  );
74  }
75 }
value
if( $inline) $status value
Definition: SyntaxHighlight.php:346
Xml\encodeJsVar
static encodeJsVar( $value, $pretty=false)
Encode a variable of arbitrary type to JavaScript.
Definition: Xml.php:659
XmlJsCode
A wrapper class which causes Xml::encodeJsVar() and Xml::encodeJsCall() to interpret a given string a...
Definition: XmlJsCode.php:40
XmlJsCode\$value
$value
Definition: XmlJsCode.php:41
XmlJsCode\encodeObject
static encodeObject( $obj, $pretty=false)
Encode an object containing XmlJsCode objects.
Definition: XmlJsCode.php:58
XmlJsCode\__construct
__construct( $value)
Definition: XmlJsCode.php:43