https://www.mediawiki.org/wiki/Special:Code/MediaWiki/113280

Revision: 113280
Author:   maxsem
Date:     2012-03-07 19:40:21 +0000 (Wed, 07 Mar 2012)
Log Message:
-----------
Detect sections with references

Modified Paths:
--------------
    trunk/extensions/MobileFrontend/api/ApiMobileView.php

Modified: trunk/extensions/MobileFrontend/api/ApiMobileView.php
===================================================================
--- trunk/extensions/MobileFrontend/api/ApiMobileView.php       2012-03-07 
19:37:17 UTC (rev 113279)
+++ trunk/extensions/MobileFrontend/api/ApiMobileView.php       2012-03-07 
19:40:21 UTC (rev 113280)
@@ -4,7 +4,7 @@
        /**
         * Increment this when changing the format of cached data
         */
-       const CACHE_VERSION = 1;
+       const CACHE_VERSION = 2;
 
        public function __construct( $main, $action ) {
                parent::__construct( $main, $action );
@@ -43,6 +43,9 @@
                                        $section[$textElement] = 
$data['text'][$i];
                                        unset( $requestedSections[$i] );
                                }
+                               if ( isset( $data['refsections'][$i] ) ) {
+                                       $section['references'] = '';
+                               }
                                $result[] = $section;
                        }
                        $missingSections = $requestedSections;
@@ -95,6 +98,7 @@
                $data['sections'] = $parserOutput->getSections();
                $chunks = preg_split( '/<h(?=[1-6]\b)/i', $html );
                $data['text'] = array();
+               $data['refsections'] = array();
                foreach ( $chunks as $chunk ) {
                        if ( count( $data['text'] ) ) {
                                $chunk = "<h$chunk";
@@ -102,6 +106,9 @@
                        if ( $wgUseTidy && count( $chunks ) > 1 ) {
                                $chunk = MWTidy::tidy( $chunk );
                        }
+                       if ( preg_match( '/<ol\b[^>]*?class="references"/', 
$chunk ) ) {
+                               $data['refsections'][count( $data['text'] )] = 
true;
+                       }
                        $data['text'][] = $chunk;
                }
                if ( count( $chunks ) != count( $data['sections'] ) + 1 ) {


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to