From: Sam Reed Date: Mon, 18 Apr 2011 13:08:20 +0000 (+0000) Subject: Few style/whitespace/comment issues from r86169 X-Git-Tag: 1.31.0-rc.0~30739 X-Git-Url: http://git.cyclocoop.org/%24href?a=commitdiff_plain;h=cb6817628d20f0d62facb0d3c1d0232f29f3e677;p=lhc%2Fweb%2Fwiklou.git Few style/whitespace/comment issues from r86169 --- diff --git a/includes/filerepo/File.php b/includes/filerepo/File.php index 0e1ac940f5..c3d90cab1d 100644 --- a/includes/filerepo/File.php +++ b/includes/filerepo/File.php @@ -312,12 +312,12 @@ abstract class File { */ public function convertMetadataVersion($metadata, $version) { $handler = $this->getHandler(); - if (!is_array($metadata)) { + if ( !is_array( $metadata ) ) { //just to make the return type consistant $metadata = unserialize( $metadata ); } if ( $handler ) { - return $handler->convertMetadataVersion($metadata, $version); + return $handler->convertMetadataVersion( $metadata, $version ); } else { return $metadata; } diff --git a/includes/media/BitmapMetadataHandler.php b/includes/media/BitmapMetadataHandler.php index e618762dfa..ce71a58028 100644 --- a/includes/media/BitmapMetadataHandler.php +++ b/includes/media/BitmapMetadataHandler.php @@ -10,16 +10,16 @@ and the various metadata extractors. */ class BitmapMetadataHandler { - private $metadata = Array(); - private $metaPriority = Array( - 20 => Array( 'other' ), - 40 => Array( 'native' ), - 60 => Array( 'iptc-good-hash', 'iptc-no-hash' ), - 70 => Array( 'xmp-deprecated' ), - 80 => Array( 'xmp-general' ), - 90 => Array( 'xmp-exif' ), - 100 => Array( 'iptc-bad-hash' ), - 120 => Array( 'exif' ), + private $metadata = array(); + private $metaPriority = array( + 20 => array( 'other' ), + 40 => array( 'native' ), + 60 => array( 'iptc-good-hash', 'iptc-no-hash' ), + 70 => array( 'xmp-deprecated' ), + 80 => array( 'xmp-general' ), + 90 => array( 'xmp-exif' ), + 100 => array( 'iptc-bad-hash' ), + 120 => array( 'exif' ), ); private $iptcType = 'iptc-no-hash'; diff --git a/includes/media/Exif.php b/includes/media/Exif.php index adaec1d1b2..d41b6547a0 100644 --- a/includes/media/Exif.php +++ b/includes/media/Exif.php @@ -584,6 +584,10 @@ class Exif { } } + /** + * @param $in + * @return bool + */ private function isASCII( $in ) { if ( is_array( $in ) ) { return false; @@ -602,6 +606,10 @@ class Exif { return true; } + /** + * @param $in + * @return bool + */ private function isShort( $in ) { if ( !is_array( $in ) && sprintf('%d', $in) == $in && $in >= 0 && $in <= 65536 ) { $this->debug( $in, __FUNCTION__, true ); @@ -612,6 +620,10 @@ class Exif { } } + /** + * @param $in + * @return bool + */ private function isLong( $in ) { if ( !is_array( $in ) && sprintf('%d', $in) == $in && $in >= 0 && $in <= 4294967296 ) { $this->debug( $in, __FUNCTION__, true ); @@ -622,6 +634,10 @@ class Exif { } } + /** + * @param $in + * @return bool + */ private function isRational( $in ) { $m = array(); if ( !is_array( $in ) && @preg_match( '/^(\d+)\/(\d+[1-9]|[1-9]\d*)$/', $in, $m ) ) { # Avoid division by zero @@ -632,24 +648,19 @@ class Exif { } } + /** + * @param $in + * @return bool + */ private function isUndefined( $in ) { - $this->debug( $in, __FUNCTION__, true ); return true; - - /* Exif::UNDEFINED means string of bytes - so this validation does not make sense. - comment out for now. - if ( !is_array( $in ) && preg_match( '/^\d{4}$/', $in ) ) { // Allow ExifVersion and FlashpixVersion - $this->debug( $in, __FUNCTION__, true ); - return true; - } else { - $this->debug( $in, __FUNCTION__, false ); - return false; - } - */ } + /** + * @param $in + * @return bool + */ private function isSlong( $in ) { if ( $this->isLong( abs( $in ) ) ) { $this->debug( $in, __FUNCTION__, true ); @@ -660,6 +671,10 @@ class Exif { } } + /** + * @param $in + * @return bool + */ private function isSrational( $in ) { $m = array(); if ( !is_array( $in ) && preg_match( '/^(-?\d+)\/(\d+[1-9]|[1-9]\d*)$/', $in, $m ) ) { # Avoid division by zero @@ -756,17 +771,19 @@ class Exif { } $type = gettype( $in ); $class = ucfirst( __CLASS__ ); - if ( $type === 'array' ) + if ( $type === 'array' ) { $in = print_r( $in, true ); + } - if ( $action === true ) + if ( $action === true ) { wfDebugLog( $this->log, "$class::$fname: accepted: '$in' (type: $type)\n"); - elseif ( $action === false ) + } elseif ( $action === false ) { wfDebugLog( $this->log, "$class::$fname: rejected: '$in' (type: $type)\n"); - elseif ( $action === null ) + } elseif ( $action === null ) { wfDebugLog( $this->log, "$class::$fname: input was: '$in' (type: $type)\n"); - else + } else { wfDebugLog( $this->log, "$class::$fname: $action (type: $type; content: '$in')\n"); + } } /** diff --git a/includes/media/FormatMetadata.php b/includes/media/FormatMetadata.php index e5d0d7a7ee..f6abb701bb 100644 --- a/includes/media/FormatMetadata.php +++ b/includes/media/FormatMetadata.php @@ -567,8 +567,6 @@ class FormatMetadata { } break; - - // This is not in the Exif standard, just a special // case for our purposes which enables wikis to wikify // the make, model and software name to link to their articles. @@ -1171,8 +1169,6 @@ class FormatMetadata { * Format a coordinate value, convert numbers from floating point * into degree minute second representation. * - * @private - * * @param $coords Array: degrees, minutes and seconds * @param $type String: latitude or longitude (for if its a NWS or E) * @return mixed A floating point number or whatever we were fed @@ -1345,8 +1341,8 @@ class FormatExif { wfDeprecated(__METHOD__); $this->meta = $meta; } + function getFormattedData ( ) { return FormatMetadata::getFormattedData( $this->meta ); } - } diff --git a/includes/media/IPTC.php b/includes/media/IPTC.php index 83aaf3ed14..dcc21e74b2 100644 --- a/includes/media/IPTC.php +++ b/includes/media/IPTC.php @@ -157,8 +157,6 @@ class IPTC { } else { $data['Software'] = $software; } - - break; case '2#075': /* Object cycle. @@ -430,8 +428,11 @@ class IPTC { // most of the time if there is no 1:90 tag, it is either ascii, latin1, or utf-8 $oldData = $data; UtfNormal::quickIsNFCVerify( $data ); //make $data valid utf-8 - if ($data === $oldData) return $data; //if validation didn't change $data - else return self::convIPTCHelper ( $oldData, 'Windows-1252' ); + if ($data === $oldData) { + return $data; //if validation didn't change $data + } else { + return self::convIPTCHelper ( $oldData, 'Windows-1252' ); + } } return trim( $data ); } diff --git a/includes/media/Jpeg.php b/includes/media/Jpeg.php index c8a1043db2..4d0d82652d 100644 --- a/includes/media/Jpeg.php +++ b/includes/media/Jpeg.php @@ -135,6 +135,4 @@ class JpegHandler extends BitmapHandler { } return $this->formatMetadataHelper( $exif ); } - - } diff --git a/includes/media/JpegMetadataExtractor.php b/includes/media/JpegMetadataExtractor.php index a556aa93e4..d95dbafd78 100644 --- a/includes/media/JpegMetadataExtractor.php +++ b/includes/media/JpegMetadataExtractor.php @@ -6,6 +6,7 @@ * Based somewhat on GIFMetadataExtrator. */ class JpegMetadataExtractor { + const MAX_JPEG_SEGMENTS = 200; // the max segment is a sanity check. // A jpeg file should never even remotely have @@ -27,17 +28,25 @@ class JpegMetadataExtractor { $segmentCount = 0; - $segments = Array( 'XMP_ext' => array(), 'COM' => array() ); + $segments = array( 'XMP_ext' => array(), 'COM' => array() ); - if ( !$filename ) throw new MWException( "No filename specified for " . __METHOD__ ); - if ( !file_exists( $filename ) || is_dir( $filename ) ) throw new MWException( "Invalid file $filename passed to " . __METHOD__ ); + if ( !$filename ) { + throw new MWException( "No filename specified for " . __METHOD__ ); + } + if ( !file_exists( $filename ) || is_dir( $filename ) ) { + throw new MWException( "Invalid file $filename passed to " . __METHOD__ ); + } $fh = fopen( $filename, "rb" ); - if ( !$fh ) throw new MWException( "Could not open file $filename" ); + if ( !$fh ) { + throw new MWException( "Could not open file $filename" ); + } $buffer = fread( $fh, 2 ); - if ( $buffer !== "\xFF\xD8" ) throw new MWException( "Not a jpeg, no SOI" ); + if ( $buffer !== "\xFF\xD8" ) { + throw new MWException( "Not a jpeg, no SOI" ); + } while ( !feof( $fh ) ) { $buffer = fread( $fh, 1 ); $segmentCount++; @@ -136,7 +145,9 @@ class JpegMetadataExtractor { * @return String if the iptc hash is good or not. */ public static function doPSIR ( $app13 ) { - if ( !$app13 ) return; + if ( !$app13 ) { + return; + } // First compare hash with real thing // 0x404 contains IPTC, 0x425 has hash // This is used to determine if the iptc is newer than @@ -171,7 +182,9 @@ class JpegMetadataExtractor { $lenName = ord( substr( $app13, $offset, 1 ) ) + 1; // we never use the name so skip it. +1 for length byte - if ( $lenName % 2 == 1 ) $lenName++; // pad to even. + if ( $lenName % 2 == 1 ) { + $lenName++; + } // pad to even. $offset += $lenName; // now length of data (unsigned long big endian) diff --git a/includes/media/PNG.php b/includes/media/PNG.php index 3206d96f39..f688b4c890 100644 --- a/includes/media/PNG.php +++ b/includes/media/PNG.php @@ -109,16 +109,19 @@ class PNGHandler extends BitmapHandler { $info = array(); $info[] = $original; - if ($metadata['loopCount'] == 0) + if ( $metadata['loopCount'] == 0 ) { $info[] = wfMsgExt( 'file-info-png-looped', 'parseinline' ); - elseif ($metadata['loopCount'] > 1) + } elseif ( $metadata['loopCount'] > 1 ) { $info[] = wfMsgExt( 'file-info-png-repeat', 'parseinline', $metadata['loopCount'] ); + } - if ($metadata['frameCount'] > 0) + if ( $metadata['frameCount'] > 0 ) { $info[] = wfMsgExt( 'file-info-png-frames', 'parseinline', $metadata['frameCount'] ); + } - if ($metadata['duration']) + if ( $metadata['duration'] ) { $info[] = $wgLang->formatTimePeriod( $metadata['duration'] ); + } return $wgLang->commaList( $info ); } diff --git a/includes/media/XMP.php b/includes/media/XMP.php index 1b001191f1..fd95f3c17c 100644 --- a/includes/media/XMP.php +++ b/includes/media/XMP.php @@ -296,10 +296,9 @@ class XMPReader { // or programs that make such files.. $guid = substr( $content, 0, 32 ); if ( !isset( $this->results['xmp-special']['HasExtendedXMP'] ) - || $this->results['xmp-special']['HasExtendedXMP'] !== $guid ) - { + || $this->results['xmp-special']['HasExtendedXMP'] !== $guid ) { wfDebugLog('XMP', __METHOD__ . " Ignoring XMPExtended block due to wrong guid (guid= '$guid' )"); - return; + return false; } $len = unpack( 'Nlength/Noffset', substr( $content, 32, 8 ) ); @@ -646,7 +645,6 @@ class XMPReader { } } - /** * Hit an opening element while in MODE_IGNORE * @@ -664,6 +662,7 @@ class XMPReader { array_unshift( $this->mode, self::MODE_IGNORE ); } } + /** * Start element in MODE_BAG (unordered array) * this should always be @@ -679,6 +678,7 @@ class XMPReader { } } + /** * Start element in MODE_SEQ (ordered array) * this should always be @@ -699,6 +699,7 @@ class XMPReader { } } + /** * Start element in MODE_LANG (language alternative) * this should always be @@ -721,6 +722,7 @@ class XMPReader { } } + /** * Handle an opening element when in MODE_SIMPLE * @@ -761,6 +763,7 @@ class XMPReader { } } + /** * Start an element when in MODE_QDESC. * This generally happens when a simple element has an inner @@ -784,6 +787,7 @@ class XMPReader { array_unshift( $this->curItem, $elm ); } } + /** * Starting an element when in MODE_INITIAL * This usually happens when we hit an element inside @@ -836,6 +840,7 @@ class XMPReader { // process attributes $this->doAttribs( $attribs ); } + /** * Hit an opening element when in a Struct (MODE_STRUCT) * This is generally for fields of a compound property. @@ -887,6 +892,7 @@ class XMPReader { array_unshift( $this->curItem, $this->curItem[0] ); } } + /** * opening element in MODE_LI * process elements of arrays. @@ -937,6 +943,7 @@ class XMPReader { } } + /** * Opening element in MODE_LI_LANG. * process elements of language alternatives @@ -1055,9 +1062,6 @@ class XMPReader { throw new MWException( 'StartElement in unknown mode: ' . $this->mode[0] ); break; } - - - } /** * Process attributes. @@ -1162,6 +1166,4 @@ class XMPReader { $this->results['xmp-' . $info['map_group']][$finalName] = $val; } } - - } diff --git a/includes/media/XMPValidate.php b/includes/media/XMPValidate.php index 382a514ba2..0f1d375cbe 100644 --- a/includes/media/XMPValidate.php +++ b/includes/media/XMPValidate.php @@ -37,6 +37,7 @@ class XMPValidate { } } + /** * function to validate rational properties ( 12/10 ) * @@ -55,6 +56,7 @@ class XMPValidate { } } + /** * function to validate rating properties -1, 0-5 * @@ -93,6 +95,7 @@ class XMPValidate { } } } + /** * function to validate integers * @@ -111,6 +114,7 @@ class XMPValidate { } } + /** * function to validate properties with a fixed number of allowed * choices. (closed choice) @@ -141,6 +145,7 @@ class XMPValidate { $val = null; } } + /** * function to validate and modify flash structure * @@ -169,6 +174,7 @@ class XMPValidate { | ( ( $val['RedEyeMode'] === 'True' ) << 6 ) ); } } + /** * function to validate LangCode properties ( en-GB, etc ) * @@ -193,6 +199,7 @@ class XMPValidate { } } + /** * function to validate date properties, and convert to Exif format. * @@ -263,6 +270,7 @@ class XMPValidate { } } + /** function to validate, and more importantly * translate the XMP DMS form of gps coords to * the decimal form we use. @@ -311,7 +319,5 @@ class XMPValidate { $val = null; return; } - } - }