r50769 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r50768‎ | r50769 | r50770 >
Date:15:12, 19 May 2009
Author:aboostani
Status:ok
Tags:
Comment:
Reverting the code that encloses article sections in their own div for the time being, because there are certain scenarios that break the document structure.
Modified paths:
  • /trunk/phase3/includes/DefaultSettings.php (modified) (history)
  • /trunk/phase3/includes/parser/Parser.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/parser/Parser.php
@@ -3371,7 +3371,7 @@
33723372 * @private
33733373 */
33743374 function formatHeadings( $text, $isMain=true ) {
3375 - global $wgMaxTocLevel, $wgContLang, $wgEnforceHtmlIds, $wgSectionContainers;
 3375+ global $wgMaxTocLevel, $wgContLang, $wgEnforceHtmlIds;
33763376
33773377 $doNumberHeadings = $this->mOptions->getNumberHeadings();
33783378 $showEditLink = $this->mOptions->getEditSection();
@@ -3657,10 +3657,6 @@
36583658
36593659 $blocks = preg_split( '/<H[1-6].*?' . '>.*?<\/H[1-6]>/i', $text );
36603660 $i = 0;
3661 -
3662 - if ( $wgSectionContainers ) {
3663 - $openDivs = array();
3664 - }
36653661
36663662 foreach( $blocks as $block ) {
36673663 if( $showEditLink && $headlineCount > 0 && $i == 0 && $block !== "\n" ) {
@@ -3676,35 +3672,7 @@
36773673 # Top anchor now in skin
36783674 $full = $full.$toc;
36793675 }
3680 -
3681 - # wrap each section in a div if $wgSectionContainers is set to true
3682 - if ( $wgSectionContainers ) {
3683 - if( !empty( $head[$i] ) ) { # if there's no next header, then don't try to close out any existing sections here
3684 - # get the level of the next header section
3685 - preg_match('/<H([0-6])/i', $head[$i], $hLevelMatches);
3686 -
3687 - if ( count($hLevelMatches) > 0 ) {
3688 - $hLevel = $hLevelMatches[1];
3689 - if ( $i != 0 ) { # we don't have an open div for section 0, so don't try to close it
3690 - # close any open divs for sections with headers that are <= to the next header level
3691 - $this->closeSectionContainers( $hLevel, $currentHLevel, $full, $openDivs);
3692 - }
3693 - $currentHLevel = $hLevel;
3694 - }
3695 - }
36963676
3697 - # open the div for the next header, if there is one
3698 - if ( isset($currentHLevel) && !empty( $head[$i] ) ) {
3699 - $full .= '<div id="section_' . $i . '_container">';
3700 - array_push($openDivs, array($currentHLevel, $i));
3701 - }
3702 -
3703 - # if we've outputed the last section of the article, close any open divs that are remaining
3704 - if ( $i == ( count($blocks) - 1) && isset($currentHLevel) ) {
3705 - $this->closeSectionContainers( $hLevel, $currentHLevel, $full, $openDivs, true);
3706 - }
3707 - }
3708 -
37093677 if( !empty( $head[$i] ) ) {
37103678 $full .= $head[$i];
37113679 }
@@ -3716,29 +3684,6 @@
37173685 return $full;
37183686 }
37193687 }
3720 -
3721 - /**
3722 - * Analyze the header level of the current and next section being parsed to
3723 - * determine if any already parsed sections need to be closed
3724 - *
3725 - * @param string $hLevel the level of the next header to be parsed
3726 - * @param string $currentHLevel the level of the last parsed header
3727 - * @param string $full a reference to the string that stores the output of the parser
3728 - * @param array $openDivs a reference to the array that stores a list of open section containers
3729 - * @return true
3730 - */
3731 - function closeSectionContainers( $hLevel, &$currentHLevel, &$full, &$openDivs, $lastCall=false) {
3732 - while ( $hLevel <= $currentHLevel || $lastCall) {
3733 - $full .= '</div>';
3734 - $popped = array_pop($openDivs);
3735 - if ( count($openDivs) ) {
3736 - $currentHLevel = $openDivs[count($openDivs) - 1][0];
3737 - } else {
3738 - break;
3739 - }
3740 - }
3741 - return true;
3742 - }
37433688
37443689 /**
37453690 * Transform wiki markup when saving a page by doing \r\n -> \n
Index: trunk/phase3/includes/DefaultSettings.php
@@ -3817,11 +3817,4 @@
38183818 * $wgInvalidUsernameCharacters above, or you will not be able to
38193819 * modify the user rights of those users via Special:UserRights
38203820 */
3821 -$wgUserrightsInterwikiDelimiter = '@';
3822 -
3823 -/**
3824 - * The $wgSectionContainers variable is used by the parser to determine if it should
3825 - * wrap each section of an article in a div. It is automatically enabled if the EditSectionHiliteLink
3826 - * extension is installed.
3827 - */
3828 -$wgSectionContainers = false;
\ No newline at end of file
 3821+$wgUserrightsInterwikiDelimiter = '@';
\ No newline at end of file

Follow-up revisions

RevisionCommit summaryAuthorDate
r51506Remove $wgSectionContainers from parser tests...simetrical16:11, 5 June 2009
r92506Refactored section assembly code to be more readable...raindrift23:23, 18 July 2011

Status & tagging log