r68301 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r68300‎ | r68301 | r68302 >
Date:06:12, 20 June 2010
Author:nad
Status:deferred
Tags:
Comment:
ereg deprecated, change to preg's
Modified paths:
  • /trunk/extensions/RecordAdmin/RecordAdmin_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/RecordAdmin/RecordAdmin_body.php
@@ -46,7 +46,7 @@
4747 if ( is_object( $title ) && $title->isRedirect() ) {
4848 $article = new Article( $title );
4949 $content = $article->getContent();
50 - if ( preg_match( '/\[\[(.+?)\]\]/', $content, $m ) ) $title = Title::newFromText( $m[1] );
 50+ if ( preg_match( "|\[\[(.+?)\]\]|", $content, $m ) ) $title = Title::newFromText( $m[1] );
5151 }
5252
5353 if ( is_object( $title ) ) {
@@ -131,7 +131,7 @@
132132 $this->template = Title::makeTitle( NS_TEMPLATE, $type );
133133
134134 if ( $type && $wgRecordAdminUseNamespaces ) {
135 - if ( $wpTitle && !ereg( "^$type:.+$", $wpTitle ) ) $wpTitle = "$type:$wpTitle";
 135+ if ( $wpTitle && !preg_match( "|^$type:.+$|", $wpTitle ) ) $wpTitle = "$type:$wpTitle";
136136 }
137137 $wgOut->addHTML(
138138 '<div class="recordadmin-menubar"><a href="' . $title->getLocalURL() . "/$type\">" . wfMsg( 'recordadmin-newsearch', $type ) . '</a>'
@@ -141,7 +141,7 @@
142142
143143 # Get posted form values if any
144144 $posted = array();
145 - foreach ( $_REQUEST as $k => $v ) if ( preg_match( '|^ra_(\\w+)|', $k, $m ) ) $posted[$m[1]] = is_array( $v ) ? join( "\n", $v ) : $v;
 145+ foreach ( $_REQUEST as $k => $v ) if ( preg_match( "|^ra_(\\w+)|", $k, $m ) ) $posted[$m[1]] = is_array( $v ) ? join( "\n", $v ) : $v;
146146 $this->filter = $posted;
147147
148148 # Read in and prepare the form for this record type if one has been selected
@@ -343,7 +343,7 @@
344344 # Loop through all records of this type adding only those that match the regex fields
345345 $records = array();
346346 foreach ( self::getRecordsByType( $type ) as $t ) {
347 - if ( empty( $wpTitle ) || eregi( $wpTitle, $t->getPrefixedText() ) ) {
 347+ if ( empty( $wpTitle ) || preg_match( "|$wpTitle|i", $t->getPrefixedText() ) ) {
348348 $a = new Article( $t );
349349 $text = $a->getContent();
350350 $match = true;
@@ -386,7 +386,7 @@
387387 }
388388
389389 # Sort the records according to "orderby" parameter
390 - if ( $this->desc = eregi( ' +desc *$', $orderby ) ) $orderby = eregi_replace( ' +desc *$', '', $orderby );
 390+ if ( $this->desc = preg_match( "| +desc *$|", $orderby ) ) $orderby = preg_replace( "| +desc *$|", "", $orderby );
391391 $this->orderBy = $orderby;
392392 usort( $records, array( $this, 'sortCallback' ) );
393393
@@ -429,9 +429,9 @@
430430 break;
431431
432432 default:
433 - $a = preg_replace( '|(\d\d)[-/](\d\d)[-/](\d\d\d\d)|', '$3/$2/$1', $a ); # hack for dd/mm/yyyy format - best to use yyyy-mm-dd
434 - $b = preg_replace( '|(\d\d)[-/](\d\d)[-/](\d\d\d\d)|', '$3/$2/$1', $b );
435 - if ( !is_numeric( $b ) && ereg( '[0-9]{4}', $b ) && $tmp = strtotime( $b ) ) {
 433+ $a = preg_replace( "|(\d\d)[-/](\d\d)[-/](\d\d\d\d)|", "$3/$2/$1", $a ); # hack for dd/mm/yyyy format - best to use yyyy-mm-dd
 434+ $b = preg_replace( "|(\d\d)[-/](\d\d)[-/](\d\d\d\d)|", "$3/$2/$1", $b );
 435+ if ( !is_numeric( $b ) && preg_match( "|[0-9]{4}|", $b ) && $tmp = strtotime( $b ) ) {
436436 $b = $tmp;
437437 $a = strtotime( $a );
438438 }
@@ -484,7 +484,7 @@
485485 'modified' => "<th class='col3 col-modified'>" . wfMsg( 'recordadmin-modified' ) . "$br</th>"
486486 );
487487 foreach ( array_keys( $this->types ) as $col ) {
488 - $class = 'col' . preg_replace( '|\W|', '-', $col );
 488+ $class = 'col' . preg_replace( "|\W|", "-", $col );
489489 $th[$col] = "<th class='$class'>$col$br</th>";
490490 }
491491 $tmp = array();
@@ -565,7 +565,7 @@
566566 foreach ( $cols as $col ) {
567567 if ( !isset( $row[$col] ) ) {
568568 $v = isset( $r[$col] ) ? $wgParser->parse( $r[$col], $wgTitle, $wgParser->mOptions, true, false )->getText() : '&#160;';
569 - $class = 'col' . preg_replace( '|\W|', '-', $col );
 569+ $class = 'col' . preg_replace( "|\W|", "-", $col );
570570 $row[$col] = "<td class='$class'>$v</td>";
571571 }
572572 $table .= "$row[$col]\n";
@@ -1057,7 +1057,7 @@
10581058 elseif ( $k == 'groupby' ) $groupby = $v;
10591059 elseif ( $k == 'format' ) $format = $v;
10601060 elseif ( $k == 'cols' ) $cols = self::split( $v, ',' );
1061 - elseif ( $k == 'sortable' ) $sortable = eregi( '1|yes|true|on', $v );
 1061+ elseif ( $k == 'sortable' ) $sortable = preg_match( '/(1|yes|true|on)/i', $v );
10621062 elseif ( $k == 'template' ) $template = $v;
10631063 elseif ( $k == 'count' ) $count = $v;
10641064 elseif ( $k == 'export' ) $export = $v;

Status & tagging log