| 1 | <?php |
|---|
| 2 | |
|---|
| 3 | function _list_pluck( $list, $field ) { |
|---|
| 4 | foreach ( $list as $key => $value ) { |
|---|
| 5 | if ( is_object( $value ) ) |
|---|
| 6 | $list[ $key ] = $value->$field; |
|---|
| 7 | else |
|---|
| 8 | $list[ $key ] = $value[ $field ]; |
|---|
| 9 | } |
|---|
| 10 | |
|---|
| 11 | return $list; |
|---|
| 12 | } |
|---|
| 13 | |
|---|
| 14 | require 'tinymce-schemas.php'; |
|---|
| 15 | |
|---|
| 16 | $html4_attr = _list_pluck( (array) $html4, 'attributesOrder' ); |
|---|
| 17 | $html5_attr = _list_pluck( (array) $html5, 'attributesOrder' ); |
|---|
| 18 | |
|---|
| 19 | $html4_children = _list_pluck( (array) $html4, 'children' ); |
|---|
| 20 | $html5_children = _list_pluck( (array) $html5, 'children' ); |
|---|
| 21 | |
|---|
| 22 | foreach ( $html4_children as &$element ) { |
|---|
| 23 | $element = array_keys( (array) $element ); |
|---|
| 24 | } |
|---|
| 25 | |
|---|
| 26 | foreach ( $html5_children as &$element ) { |
|---|
| 27 | $element = array_keys( (array) $element ); |
|---|
| 28 | } |
|---|
| 29 | unset( $element ); |
|---|
| 30 | |
|---|
| 31 | $html4_only = array_keys( array_diff_key( $html4_attr, $html5_attr ) ); |
|---|
| 32 | $html5_only = array_keys( array_diff_key( $html5_attr, $html4_attr ) ); |
|---|
| 33 | |
|---|
| 34 | echo "THESE ELEMENTS WERE IN THE HTML4 SCHEMA AND ARE NOT IN HTML5\n\n"; |
|---|
| 35 | echo implode( ", ", $html4_only ); |
|---|
| 36 | |
|---|
| 37 | echo "\n\n"; |
|---|
| 38 | |
|---|
| 39 | if ( false ) : |
|---|
| 40 | |
|---|
| 41 | foreach ( $html4_attr as $element => $attributes ) { |
|---|
| 42 | if ( in_array( $element, $html4_only ) ) |
|---|
| 43 | echo $element . '[' . implode( '|', $attributes ) . ']' . "\n"; |
|---|
| 44 | } |
|---|
| 45 | foreach ( $html4_attr as $element => $attributes ) { |
|---|
| 46 | if ( in_array( $element, array( 'table', 'tr', 'td', 'th', 'a', 'object', 'param', 'embed' ) ) ) |
|---|
| 47 | echo $element . '[' . implode( '|', $attributes ) . ']' . "\n"; |
|---|
| 48 | } |
|---|
| 49 | |
|---|
| 50 | endif; |
|---|
| 51 | |
|---|
| 52 | echo "These elements are new to the HTML5 schema\n\n"; |
|---|
| 53 | echo implode( ", ", $html5_only ) . "\n"; |
|---|
| 54 | |
|---|
| 55 | $shared_elements = array_keys( array_intersect_key( $html4_attr, $html5_attr ) ); |
|---|
| 56 | |
|---|
| 57 | $removed_in_html5 = array(); |
|---|
| 58 | foreach ( $shared_elements as $element ) { |
|---|
| 59 | if ( $removed = array_diff( $html4_attr[ $element ], $html5_attr[ $element ], array( 'xml:lang', 'lang' ) ) ) |
|---|
| 60 | $removed_in_html5[ $element ] = $removed; |
|---|
| 61 | } |
|---|
| 62 | |
|---|
| 63 | echo "\n\nThese elements had attributes removed from html5:\n\n"; |
|---|
| 64 | |
|---|
| 65 | foreach ( $removed_in_html5 as $element => $attributes ) { |
|---|
| 66 | echo "$element --- " . implode( ', ', $attributes ) . "\n"; |
|---|
| 67 | } |
|---|
| 68 | |
|---|
| 69 | $added_in_html5 = array(); |
|---|
| 70 | foreach ( $shared_elements as $element ) { |
|---|
| 71 | if ( $added = array_diff( $html5_attr[ $element ], $html4_attr[ $element ], array( 'accesskey', 'draggable', 'item', 'hidden', 'itemprop', 'role', 'spellcheck', 'subject' ) ) ) |
|---|
| 72 | $added_in_html5[ $element ] = $added; |
|---|
| 73 | } |
|---|
| 74 | |
|---|
| 75 | echo "\n\nThese elements had attributes added in html5:\n\n"; |
|---|
| 76 | |
|---|
| 77 | foreach ( $added_in_html5 as $element => $attributes ) { |
|---|
| 78 | echo "$element --- " . implode( ', ', $attributes ) . "\n"; |
|---|
| 79 | } |
|---|