Index: trunk/extensions/PageSchemas/specials/PS_EditSchema.php |
— | — | @@ -110,6 +110,22 @@ |
111 | 111 | } |
112 | 112 | |
113 | 113 | /** |
| 114 | + * Returns a nicely-formatted version of the XML passed in. |
| 115 | + * |
| 116 | + * Code based on |
| 117 | + * http://coffeecoders.de/2011/03/how-to-pretty-print-a-simplexmlobject-in-php/ |
| 118 | + */ |
| 119 | + static function prettyPrintXML( $xml ){ |
| 120 | + // Turn the XML string into a DOMDocument object, and then |
| 121 | + // back again, to have it displayed nicely. |
| 122 | + $domDocument = new DOMDocument('1.0'); |
| 123 | + $domDocument->preserveWhiteSpace = false; |
| 124 | + $domDocument->formatOutput = true; |
| 125 | + $domDocument->loadXML( $xml ); |
| 126 | + return $domDocument->saveXML( $domDocument->documentElement ); |
| 127 | + } |
| 128 | + |
| 129 | + /** |
114 | 130 | * Creates full <PageSchema> XML text, based on what was passed in by |
115 | 131 | * the form. |
116 | 132 | */ |
— | — | @@ -179,6 +195,7 @@ |
180 | 196 | } |
181 | 197 | } |
182 | 198 | $psXML .= '</PageSchema>'; |
| 199 | + $psXML = self::prettyPrintXML( $psXML ); |
183 | 200 | return $psXML; |
184 | 201 | } |
185 | 202 | |
— | — | @@ -222,10 +239,10 @@ |
223 | 240 | */ |
224 | 241 | static function printFormSection( $label, $topColor, $html, $bgColor = 'white', $isCollapsible = false, $hasExistingValues = true ) { |
225 | 242 | $className = $isCollapsible ? 'sectionBox' : ''; |
226 | | - $text = "<div class=\"$className\" style=\"background: $bgColor; border: 1px #999 solid; padding: 0px; margin-bottom: 10px; margin-top: 10px;\">\n"; |
| 243 | + $text = "<div class=\"$className\" style=\"background: $bgColor; border: 1px #999 solid; padding: 0px; margin-bottom: 10px; margin-top: 10px;\">\n"; |
227 | 244 | $text .= "<div style=\"font-weight: bold; background: $topColor; padding: 4px 7px; border-bottom: 1px #bbb solid;\">"; |
228 | 245 | if ( $isCollapsible ) { |
229 | | - $checkboxAttrs = array( 'class' => 'sectionCheckbox' ); |
| 246 | + $checkboxAttrs = array( 'class' => 'sectionCheckbox' ); |
230 | 247 | if ( $hasExistingValues ) { |
231 | 248 | $checkboxAttrs['checked'] = true; |
232 | 249 | } |