r113280 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r113279‎ | r113280 | r113281 >
Date:19:40, 7 March 2012
Author:maxsem
Status:ok
Tags:
Comment:
Detect sections with references
Modified paths:
  • /trunk/extensions/MobileFrontend/api/ApiMobileView.php (modified) (history)

Diff [purge]

Index: trunk/extensions/MobileFrontend/api/ApiMobileView.php
@@ -4,7 +4,7 @@
55 /**
66 * Increment this when changing the format of cached data
77 */
8 - const CACHE_VERSION = 1;
 8+ const CACHE_VERSION = 2;
99
1010 public function __construct( $main, $action ) {
1111 parent::__construct( $main, $action );
@@ -43,6 +43,9 @@
4444 $section[$textElement] = $data['text'][$i];
4545 unset( $requestedSections[$i] );
4646 }
 47+ if ( isset( $data['refsections'][$i] ) ) {
 48+ $section['references'] = '';
 49+ }
4750 $result[] = $section;
4851 }
4952 $missingSections = $requestedSections;
@@ -95,6 +98,7 @@
9699 $data['sections'] = $parserOutput->getSections();
97100 $chunks = preg_split( '/<h(?=[1-6]\b)/i', $html );
98101 $data['text'] = array();
 102+ $data['refsections'] = array();
99103 foreach ( $chunks as $chunk ) {
100104 if ( count( $data['text'] ) ) {
101105 $chunk = "<h$chunk";
@@ -102,6 +106,9 @@
103107 if ( $wgUseTidy && count( $chunks ) > 1 ) {
104108 $chunk = MWTidy::tidy( $chunk );
105109 }
 110+ if ( preg_match( '/<ol\b[^>]*?class="references"/', $chunk ) ) {
 111+ $data['refsections'][count( $data['text'] )] = true;
 112+ }
106113 $data['text'][] = $chunk;
107114 }
108115 if ( count( $chunks ) != count( $data['sections'] ) + 1 ) {

Status & tagging log