return $obj->flattenArrayReal( $vals, $type, $noHtml );
}
- /**
- * Flatten an array, using the user language for any messages.
- *
- * @param array $vals Array of values
- * @param string $type Type of array (either lang, ul, ol).
- * lang = language assoc array with keys being the lang code
- * ul = unordered list, ol = ordered list
- * type can also come from the '_type' member of $vals.
- * @param bool $noHtml If to avoid returning anything resembling HTML.
- * (Ugly hack for backwards compatibility with old MediaWiki).
- * @param bool|IContextSource $context
- * @return string Single value (in wiki-syntax).
- */
- public static function flattenArray( $vals, $type = 'ul', $noHtml = false, $context = false ) {
- $obj = new FormatMetadata;
- if ( $context ) {
- $obj->setContext( $context );
- }
-
- return $obj->flattenArrayReal( $vals, $type, $noHtml );
- }
-
/**
* A function to collapse multivalued tags into a single value.
* This turns an array of (for example) authors into a bulleted list.
'File with invalid date metadata (bug 29471)' );
}
- /**
- * @param string $filename
- * @param int $expected Total image area
- * @dataProvider provideFlattenArray
- * @covers FormatMetadata::flattenArray
- */
- public function testFlattenArray( $vals, $type, $noHtml, $ctx, $expected ) {
- $actual = FormatMetadata::flattenArray( $vals, $type, $noHtml, $ctx );
- $this->assertEquals( $expected, $actual );
- }
-
- public static function provideFlattenArray() {
- return array(
- array(
- array( 1, 2, 3 ), 'ul', false, false,
- "<ul><li>1</li>\n<li>2</li>\n<li>3</li></ul>",
- ),
- array(
- array( 1, 2, 3 ), 'ol', false, false,
- "<ol><li>1</li>\n<li>2</li>\n<li>3</li></ol>",
- ),
- array(
- array( 1, 2, 3 ), 'ul', true, false,
- "\n*1\n*2\n*3",
- ),
- array(
- array( 1, 2, 3 ), 'ol', true, false,
- "\n#1\n#2\n#3",
- ),
- // TODO: more test cases
- );
- }
-
/**
* @param mixed $input
* @param mixed $output