Index: skins/common/wikibits.js
===================================================================
--- skins/common/wikibits.js (revision 78317)
+++ skins/common/wikibits.js (working copy)
@@ -604,14 +604,7 @@
};
window.ts_makeSortable = function( table ) {
- var firstRow;
- if ( table.rows && table.rows.length > 0 ) {
- if ( table.tHead && table.tHead.rows.length > 0 ) {
- firstRow = table.tHead.rows[table.tHead.rows.length-1];
- } else {
- firstRow = table.rows[0];
- }
- }
+ var firstRow = table.rows[0];
if ( !firstRow ) {
return;
}
Index: includes/parser/Parser.php
===================================================================
--- includes/parser/Parser.php (revision 78317)
+++ includes/parser/Parser.php (working copy)
@@ -825,189 +825,269 @@
$lines = StringUtils::explode( "\n", $text );
$out = '';
- $td_history = array(); # Is currently a td tag open?
- $last_tag_history = array(); # Save history of last lag activated (td, th or caption)
- $tr_history = array(); # Is currently a tr tag open?
- $tr_attributes = array(); # history of tr attributes
- $has_opened_tr = array(); # Did this table open a
\n";
- }
- array_push( $tr_history , true );
- array_push( $tr_attributes , '' );
- array_pop( $has_opened_tr );
- array_push( $has_opened_tr , true );
- }
+ /**
+ * Helper function for doTableStuff() separating the contents of cells from
+ * attributes. Particularly useful as there's a possible bug and this action
+ * is repeated twice.
+ *
+ * @private
+ */
+ function getCellAttr ($cell , $tag_name) {
+ $content = null;
+ $attributes = null;
- $last_tag = array_pop( $last_tag_history );
+ $cell = trim ( $cell );
- if ( array_pop( $td_history ) ) {
- $previous = "{$last_tag}>\n{$previous}";
- }
+ // A cell could contain both parameters and data
+ $cell_data = explode ( '|' , $cell , 2 );
- if ( $first_character === '|' ) {
- $last_tag = 'td';
- } elseif ( $first_character === '!' ) {
- $last_tag = 'th';
- } elseif ( $first_character === '+' ) {
- $last_tag = 'caption';
- } else {
- $last_tag = '';
- }
+ // Bug 553: Note that a '|' inside an invalid link should not
+ // be mistaken as delimiting cell parameters
+ if ( strpos( $cell_data[0], '[[' ) !== false ) {
+ $content = trim ( $cell );
+ }
+ else if ( count ( $cell_data ) == 1 ) {
+ $content = trim ( $cell_data[0] );
+ }
+ else {
+ $attributes = $this->mStripState->unstripBoth( $cell_data[0] );
+ $attributes = Sanitizer::fixTagAttributes( $attributes , $tag_name );
- array_push( $last_tag_history , $last_tag );
+ $content = trim ( $cell_data[1] );
+ }
+ return array($content, $attributes);
+ }
- # A cell could contain both parameters and data
- $cell_data = explode( '|' , $cell , 2 );
- # Bug 553: Note that a '|' inside an invalid link should not
- # be mistaken as delimiting cell parameters
- if ( strpos( $cell_data[0], '[[' ) !== false ) {
- $cell = "{$previous}<{$last_tag}>{$cell}";
- } elseif ( count( $cell_data ) == 1 ) {
- $cell = "{$previous}<{$last_tag}>{$cell_data[0]}";
- } else {
- $attributes = $this->mStripState->unstripBoth( $cell_data[0] );
- $attributes = Sanitizer::fixTagAttributes( $attributes , $last_tag );
- $cell = "{$previous}<{$last_tag}{$attributes}>{$cell_data[1]}";
- }
+ /**
+ * Helper function for doTableStuff(). This converts the structured array into html.
+ *
+ * @private
+ */
+ function printTableHtml (&$t) {
+ $r = "\n";
+ $r .= str_repeat( '- ' , $t['indent'] );
+ $r .= '
0 ) {
- if ( array_pop( $td_history ) ) {
- $out .= "\n";
+ if( $t[$i]['type'] != $last_section ) {
+ $r .= "\n<" . $t[$i]['type'] . '>';
}
- if ( array_pop( $tr_history ) ) {
- $out .= "\n";
+
+ $r .= "\n';
+ unset($t[$i][$j]);
}
- if ( !array_pop( $has_opened_tr ) ) {
- $out .= "
|
\n" ;
+ $r .= "\n";
+
+ if( !isset($t[$i+1]) || ( isset($t[$i+1]) && ($t[$i]['type'] != $t[$i+1]['type'])) ) {
+ $r .= '' . $t[$i]['type'] . '>';
}
-
- $out .= "
\n";
+ $last_section = $t[$i]['type'];
+ unset($t[$i]);
}
-
- # Remove trailing line-ending (b/c)
- if ( substr( $out, -1 ) === "\n" ) {
- $out = substr( $out, 0, -1 );
+ if ( $empty ) {
+ if ( isset($t['caption']) ) {
+ $r .= "\n |
";
+ } else {
+ return '';
+ }
}
+ $r .= "\n";
+ $r .= str_repeat( '
' , $t['indent'] );
- # special case: don't return empty table
- if ( $out === "" ) {
- $out = '';
- }
+ return $r;
+ }
- wfProfileOut( __METHOD__ );
-
- return $out;
+ /**
+ * like end() but only works on the numeric array index and php's internal pointers
+ * returns a reference to the last element of an array much like "\$arr[-1]" in perl
+ * ignores associative elements and will create a 0 key will a NULL value if there were
+ * no numric elements and an array itself if not previously defined.
+ *
+ * @private
+ */
+ function &last (&$arr) {
+ for($i = count($arr); (!isset($arr[$i]) && $i > 0); $i--) { }
+ return $arr[$i];
}
/**
@@ -2242,7 +2322,7 @@
'mUniqPrefix.'-pre|<\\/li|<\\/ul|<\\/ol|<\\/?center)/iS', $t );
if ( $openmatch or $closematch ) {
$paragraphStack = false;
- # TODO bug 5718: paragraph closed
+ # TODO bug 5718: paragraph closed
$output .= $this->closeParagraph();
if ( $preOpenMatch and !$preCloseMatch ) {
$this->mInPre = true;
Index: includes/Sanitizer.php
===================================================================
--- includes/Sanitizer.php (revision 78317)
+++ includes/Sanitizer.php (working copy)
@@ -369,7 +369,7 @@
'strike', 'strong', 'tt', 'var', 'div', 'center',
'blockquote', 'ol', 'ul', 'dl', 'table', 'caption', 'pre',
'ruby', 'rt' , 'rb' , 'rp', 'p', 'span', 'abbr', 'dfn',
- 'kbd', 'samp'
+ 'kbd', 'samp', 'thead', 'tbody', 'tfoot'
);
$htmlsingle = array(
'br', 'hr', 'li', 'dt', 'dd'
|