118 # TIFF Rev. 6.0 Attribute Information (p22)
120 # Tags relating to image structure
123 'BitsPerSample' => [
self::SHORT, 3 ], # Number
of bits per component
124 # "When a primary image is JPEG compressed, this designation is not"
125 # "necessary and is omitted." (p23)
126 'Compression' =>
self::SHORT, # Compression scheme #p23
127 'PhotometricInterpretation' =>
self::SHORT, # Pixel composition #p23
131 'YCbCrSubSampling' => [
self::SHORT, 2 ], # Subsampling ratio
of Y to C #p24
137 # Tags relating to recording offset
138 'StripOffsets' => self::SHORT_OR_LONG, # Image
data location
139 'RowsPerStrip' => self::SHORT_OR_LONG, # Number
of rows per strip
140 'StripByteCounts' => self::SHORT_OR_LONG, # Bytes per compressed strip
141 'JPEGInterchangeFormat' => self::SHORT_OR_LONG, # Offset to JPEG SOI
142 'JPEGInterchangeFormatLength' => self::SHORT_OR_LONG, # Bytes
of JPEG
data
144 # Tags relating to image
data characteristics
145 'TransferFunction' => self::IGNORE, # Transfer
function
146 'WhitePoint' => [ self::RATIONAL, 2 ], # White point chromaticity
147 'PrimaryChromaticities' => [ self::RATIONAL, 6 ], # Chromaticities
of primarities
148 # Color space transformation matrix coefficients #p27
149 'YCbCrCoefficients' => [ self::RATIONAL, 3 ],
150 'ReferenceBlackWhite' => [ self::RATIONAL, 6 ], # Pair
of black
and white reference
values
154 'ImageDescription' => self::ASCII, # Image
title
155 'Make' => self::ASCII, # Image input equipment manufacturer
156 'Model' => self::ASCII, # Image input equipment model
158 'Artist' => self::ASCII, # Person who created the image
159 'Copyright' => self::ASCII, #
Copyright holder
162 #
Exif IFD Attribute Information (p30-31)
164 # @todo NOTE: Nonexistence of this field is taken to mean nonconformance
165 # to the Exif 2.1 AND 2.2 standards
169 # Tags relating to Image Data Characteristics
170 'ColorSpace' =>
self::SHORT, # Color space information #p32
172 # Tags relating to image configuration
174 'CompressedBitsPerPixel' =>
self::RATIONAL, # Image compression mode
178 # Tags relating to related user information
182 # Tags relating to related file information
185 # Tags relating to date and time
189 'SubSecTimeOriginal' =>
self::ASCII, # DateTimeOriginal subseconds
190 'SubSecTimeDigitized' =>
self::ASCII, # DateTimeDigitized subseconds
192 # Tags relating to picture-taking conditions (p31)
195 'ExposureProgram' =>
self::SHORT, # Exposure Program #p38
196 'SpectralSensitivity' =>
self::ASCII, # Spectral sensitivity
197 'ISOSpeedRatings' =>
self::SHORT, # ISO speed rating
199 # Optoelectronic conversion factor. Note: We don't have support for this atm.
206 'MeteringMode' =>
self::SHORT, # Metering mode #p40
210 'SubjectArea' => [
self::SHORT, 4 ], # Subject area
212 'SpatialFrequencyResponse' =>
self::IGNORE, # Spatial frequency response. Not supported atm.
213 'FocalPlaneXResolution' =>
self::RATIONAL, # Focal plane X resolution
214 'FocalPlaneYResolution' =>
self::RATIONAL, # Focal plane Y resolution
215 'FocalPlaneResolutionUnit' =>
self::SHORT, # Focal plane resolution unit #p46
216 'SubjectLocation' => [
self::SHORT, 2 ], # Subject location
218 'SensingMethod' =>
self::SHORT, # Sensing method #p46
221 'CFAPattern' =>
self::IGNORE, # CFA pattern. not supported atm.
223 'ExposureMode' =>
self::SHORT, # Exposure mode #p48
224 'WhiteBalance' =>
self::SHORT, # White Balance #p49
226 'FocalLengthIn35mmFilm' =>
self::SHORT, # Focal length
in 35 mm film
228 'GainControl' =>
self::SHORT, # Scene control #p49-50
233 # Device settings description. This could maybe be supported. Need to find an
234 # example file that uses this to see if it has stuff of interest in it.
235 'SubjectDistanceRange' =>
self::SHORT, # Subject distance range #p51
240 # GPS Attribute Information (p52)
243 # Should be an array of 4 Exif::BYTE's. However php treats it as an undefined
244 # Note exif standard calls this GPSVersionID, but php doesn't like the id suffix
245 'GPSLatitudeRef' =>
self::ASCII, # North
or South Latitude #p52-53
247 'GPSLongitudeRef' =>
self::ASCII, # East
or West Longitude #p53
250 # Altitude reference. Note, the exif standard says this should be an EXIF::Byte,
251 # but php seems to disagree.
253 'GPSTimeStamp' => [
self::RATIONAL, 3 ], # GPS time (atomic clock)
256 'GPSMeasureMode' =>
self::ASCII, # Measurement mode #p54-55
260 'GPSTrackRef' =>
self::ASCII, # Reference
for direction
of movement #p55
262 'GPSImgDirectionRef' =>
self::ASCII, # Reference
for direction
of image #p56
265 'GPSDestLatitudeRef' =>
self::ASCII, # Reference
for latitude
of destination #p56
266 'GPSDestLatitude' => [
self::RATIONAL, 3 ], # Latitude destination
267 'GPSDestLongitudeRef' =>
self::ASCII, # Reference
for longitude
of destination #p57
269 'GPSDestBearingRef' =>
self::ASCII, # Reference
for bearing
of destination #p57
271 'GPSDestDistanceRef' =>
self::ASCII, # Reference
for distance to destination #p57-58
276 'GPSDifferential' =>
self::SHORT, # GPS differential correction
288 wfWarn(
'Exif class did not have byte order specified. ' .
289 'Some properties may be decoded incorrectly.' );
290 $this->byteOrder =
'BE';
294 if ( function_exists(
'exif_read_data' ) ) {
295 Wikimedia\suppressWarnings();
296 $data = exif_read_data( $this->file, 0,
true );
297 Wikimedia\restoreWarnings();
299 throw new MWException(
"Internal error: exif_read_data not present. " .
300 "\$wgShowEXIF may be incorrectly set or not checked by an extension." );
307 $this->mRawExifData =
$data ?: [];
317 $this->mFilteredExifData = [];
319 foreach ( array_keys( $this->mRawExifData )
as $section ) {
320 if ( !array_key_exists(
$section, $this->mExifTags ) ) {
321 $this->
debug( $section, __FUNCTION__,
"'$section' is not a valid Exif section" );
325 foreach ( array_keys( $this->mRawExifData[
$section] )
as $tag ) {
326 if ( !array_key_exists( $tag, $this->mExifTags[
$section] ) ) {
327 $this->
debug( $tag, __FUNCTION__,
"'$tag' is not a valid tag in '$section'" );
331 $this->mFilteredExifData[$tag] = $this->mRawExifData[
$section][$tag];
337 $this->
debug(
$value, __FUNCTION__,
"'$tag' contained invalid data" );
338 unset( $this->mFilteredExifData[$tag] );
368 if ( isset( $this->mFilteredExifData[
'GPSAltitude'] )
369 && isset( $this->mFilteredExifData[
'GPSAltitudeRef'] )
374 list( $num, $denom ) = explode(
'/', $this->mFilteredExifData[
'GPSAltitude'] );
375 $this->mFilteredExifData[
'GPSAltitude'] = $num / $denom;
377 if ( $this->mFilteredExifData[
'GPSAltitudeRef'] ===
"\1" ) {
378 $this->mFilteredExifData[
'GPSAltitude'] *= -1;
380 unset( $this->mFilteredExifData[
'GPSAltitudeRef'] );
393 if ( isset( $this->mFilteredExifData[
'ComponentsConfiguration'] ) ) {
394 $val = $this->mFilteredExifData[
'ComponentsConfiguration'];
397 $strLen = strlen( $val );
398 for ( $i = 0; $i < $strLen; $i++ ) {
399 $ccVals[$i] = ord( substr( $val, $i, 1 ) );
401 $ccVals[
'_type'] =
'ol';
402 $this->mFilteredExifData[
'ComponentsConfiguration'] = $ccVals;
412 if ( isset( $this->mFilteredExifData[
'GPSVersion'] ) ) {
413 $val = $this->mFilteredExifData[
'GPSVersion'];
416 $strLen = strlen( $val );
417 for ( $i = 0; $i < $strLen; $i++ ) {
421 $newVal .= ord( substr( $val, $i, 1 ) );
424 if ( $this->byteOrder ===
'LE' ) {
427 for ( $i = strlen( $newVal ) - 1; $i >= 0; $i-- ) {
428 $newVal2 .= substr( $newVal, $i, 1 );
430 $this->mFilteredExifData[
'GPSVersionID'] = $newVal2;
432 $this->mFilteredExifData[
'GPSVersionID'] = $newVal;
434 unset( $this->mFilteredExifData[
'GPSVersion'] );
445 if ( isset( $this->mFilteredExifData[$prop] ) ) {
446 if ( strlen( $this->mFilteredExifData[$prop] ) <= 8 ) {
449 $this->
debug( $this->mFilteredExifData[$prop], __FUNCTION__,
false );
450 unset( $this->mFilteredExifData[$prop] );
454 $charCode = substr( $this->mFilteredExifData[$prop], 0, 8 );
455 $val = substr( $this->mFilteredExifData[$prop], 8 );
457 switch ( $charCode ) {
458 case "JIS\x00\x00\x00\x00\x00":
459 $charset =
"Shift-JIS";
469 Wikimedia\suppressWarnings();
470 $val = iconv( $charset,
'UTF-8//IGNORE', $val );
471 Wikimedia\restoreWarnings();
475 UtfNormal\Validator::quickIsNFCVerify( $valCopy );
476 if ( $valCopy !== $val ) {
477 Wikimedia\suppressWarnings();
478 $val = iconv(
'Windows-1252',
'UTF-8//IGNORE', $val );
479 Wikimedia\restoreWarnings();
485 if ( strlen( $val ) === 0 ) {
487 $this->
debug( $this->mFilteredExifData[$prop], __FUNCTION__,
"$prop: Is only whitespace" );
488 unset( $this->mFilteredExifData[$prop] );
494 $this->mFilteredExifData[$prop] = $val;
505 if ( isset( $this->mFilteredExifData[$prop] ) ) {
506 $this->mFilteredExifData[$prop] = ord( $this->mFilteredExifData[$prop] );
516 $loc =& $this->mFilteredExifData[$prop];
517 $dir =& $this->mFilteredExifData[$prop .
'Ref'];
520 if ( isset( $loc ) && isset( $dir )
521 && ( $dir ===
'N' || $dir ===
'S' || $dir ===
'E' || $dir ===
'W' )
523 list( $num, $denom ) = explode(
'/', $loc[0] );
524 $res = $num / $denom;
525 list( $num, $denom ) = explode(
'/', $loc[1] );
526 $res += ( $num / $denom ) * ( 1 / 60 );
527 list( $num, $denom ) = explode(
'/', $loc[2] );
528 $res += ( $num / $denom ) * ( 1 / 3600 );
530 if ( $dir ===
'S' || $dir ===
'W' ) {
537 if (
$res !==
false ) {
538 $this->mFilteredExifData[$prop] =
$res;
539 unset( $this->mFilteredExifData[$prop .
'Ref'] );
541 unset( $this->mFilteredExifData[$prop] );
542 unset( $this->mFilteredExifData[$prop .
'Ref'] );
592 if ( !is_array( $in ) && sprintf(
'%d', $in ) == $in && $in >= 0 && $in <= 255 ) {
593 $this->
debug( $in, __FUNCTION__,
true );
597 $this->
debug( $in, __FUNCTION__,
false );
608 if ( is_array( $in ) ) {
612 if ( preg_match(
"/[^\x0a\x20-\x7e]/", $in ) ) {
613 $this->
debug( $in, __FUNCTION__,
'found a character not in our whitelist' );
618 if ( preg_match(
'/^\s*$/', $in ) ) {
619 $this->
debug( $in, __FUNCTION__,
'input consisted solely of whitespace' );
632 if ( !is_array( $in ) && sprintf(
'%d', $in ) == $in && $in >= 0 && $in <= 65536 ) {
633 $this->
debug( $in, __FUNCTION__,
true );
637 $this->
debug( $in, __FUNCTION__,
false );
648 if ( !is_array( $in ) && sprintf(
'%d', $in ) == $in && $in >= 0 && $in <= 4294967296 ) {
649 $this->
debug( $in, __FUNCTION__,
true );
653 $this->
debug( $in, __FUNCTION__,
false );
666 # Avoid division by zero
667 if ( !is_array( $in )
668 && preg_match(
'/^(\d+)\/(\d+[1-9]|[1-9]\d*)$/', $in, $m )
670 return $this->
isLong( $m[1] ) && $this->
isLong( $m[2] );
672 $this->
debug( $in, __FUNCTION__,
'fed a non-fraction value' );
683 $this->
debug( $in, __FUNCTION__,
true );
693 if ( $this->
isLong( abs( $in ) ) ) {
694 $this->
debug( $in, __FUNCTION__,
true );
698 $this->
debug( $in, __FUNCTION__,
false );
711 # Avoid division by zero
712 if ( !is_array( $in ) &&
713 preg_match(
'/^(-?\d+)\/(\d+[1-9]|[1-9]\d*)$/', $in, $m )
717 $this->
debug( $in, __FUNCTION__,
'fed a non-fraction value' );
736 $etype = $this->mExifTags[
$section][$tag];
738 if ( is_array( $etype ) ) {
739 list( $etype, $ecount ) = $etype;
746 if ( is_array( $val ) ) {
747 $count = count( $val );
748 if ( $ecount != $count ) {
749 $this->
debug( $val, __FUNCTION__,
"Expected $ecount elements for $tag but got $count" );
755 foreach ( $val
as $v ) {
764 switch ( (
string)$etype ) {
768 return $this->
isByte( $val );
780 return $this->
isLong( $val );
806 $this->
debug( $val, __FUNCTION__,
"The tag '$tag' is unknown" );
823 $type = gettype( $in );
824 $class = ucfirst( __CLASS__ );
825 if ( is_array( $in ) ) {
826 $in = print_r( $in,
true );
829 if ( $action ===
true ) {
830 wfDebugLog( $this->log,
"$class::$fname: accepted: '$in' (type: $type)" );
831 } elseif ( $action ===
false ) {
832 wfDebugLog( $this->log,
"$class::$fname: rejected: '$in' (type: $type)" );
833 } elseif ( $action ===
null ) {
834 wfDebugLog( $this->log,
"$class::$fname: input was: '$in' (type: $type)" );
836 wfDebugLog( $this->log,
"$class::$fname: $action (type: $type; content: '$in')" );
850 $class = ucfirst( __CLASS__ );
852 wfDebugLog( $this->log,
"$class::$fname: begin processing: '{$this->basename}'" );
854 wfDebugLog( $this->log,
"$class::$fname: end processing: '{$this->basename}'" );
and(b) You must cause any modified files to carry prominent notices stating that You changed the files
wfWarn( $msg, $callerOffset=1, $level=E_USER_NOTICE)
Send a warning either to the debug log or in a PHP error depending on $wgDevelopmentWarnings.
wfBaseName( $path, $suffix='')
Return the final portion of a pathname.
wfDebugLog( $logGroup, $text, $dest='all', array $context=[])
Send a line to a supplementary debug log file, if configured, or main debug log if not.
if(defined( 'MW_SETUP_CALLBACK')) $fname
Customization point after all loading (constants, functions, classes, DefaultSettings,...
Class to extract and validate Exif data from jpeg (and possibly tiff) files.
const SRATIONAL
Two SLONGs.
validate( $section, $tag, $val, $recursive=false)
#-
const BYTE
An 8-bit (1-byte) unsigned integer.
exifPropToOrd( $prop)
Convert an Exif::UNDEFINED from a raw binary string to its value.
const SHORT_OR_LONG
A 16-bit (2-byte) or 32-bit (4-byte) unsigned integer.
string $file
The file being processed.
array $mFilteredExifData
A Filtered version of $mRawExifData that has been pruned of invalid tags and tags that contain conten...
const UNDEFINED
An 8-bit byte that can take any value depending on the field definition.
string $byteOrder
The byte order of the file.
const ASCII
An 8-bit byte containing one 7-bit ASCII code.
getFilteredData()
Get $this->mFilteredExifData.
debug( $in, $fname, $action=null)
Convenience function for debugging output.
const SHORT
A 16-bit (2-byte) unsigned integer.
charCodeString( $prop)
Do userComment tags and similar.
const LONG
A 32-bit (4-byte) unsigned integer.
array $mExifTags
Exif tags grouped by category, the tagname itself is the key and the type is the value,...
array $mRawExifData
The raw Exif data returned by exif_read_data()
__construct( $file, $byteOrder='')
makeFilteredData()
Make $this->mFilteredExifData.
string $log
The private log to log to, e.g.
string $basename
The basename of the file being processed.
collapseData()
Collapse some fields together.
const IGNORE
A fake value for things we don't want or don't support.
debugFile( $fname, $io)
Convenience function for debugging output.
exifGPStoNumber( $prop)
Convert gps in exif form to a single floating point number for example 10 degress 2040` S -> -10....
isByte( $in)
Validates if a tag value is of the type it should be according to the Exif spec.
const SLONG
A 32-bit (4-byte) signed integer (2's complement notation),.
Implements some public methods and some protected utility functions which are required by multiple ch...
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could change
$data
Utility to generate mapping file used in mw.Title (phpCharToUpper.json)
globals txt Globals are evil The original MediaWiki code relied on globals for processing context far too often MediaWiki development since then has been a story of slowly moving context out of global variables and into objects Storing processing context in object member variables allows those objects to be reused in a much more flexible way Consider the elegance of
database rows
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses after processing after processing
This code would result in ircNotify being run twice when an article is and once for brion Hooks can return three possible values
null for the local wiki Added in
you don t have to do a grep find to see where the $wgReverseTitle variable is used
Using a hook running we can avoid having all this option specific stuff in our mainline code Using the function We ve cleaned up the code here by removing clumps of infrequently used code and moving them off somewhere else It s much easier for someone working with this code to see what s _really_ going and make changes or fix bugs In we can take all the code that deals with the little used title reversing we can concentrate it all in an extension file
null for the local wiki Added should default to null in handler for backwards compatibility add a value to it if you want to add a cookie that have to vary cache options can modify as strings Extensions should add to this list prev or next refreshes the diff cache allow viewing deleted revs source
usually copyright or history_copyright This message must be in HTML not wikitext if the section is included from a template $section
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array("192.168.0.1:11211", 2))
This document describes the state of Postgres support in and is fairly well maintained The main code is very well while extensions are very hit and miss it is probably the most supported database after MySQL Much of the work in making MediaWiki database agnostic came about through the work of creating Postgres but without copying over all the usage comments General notes on the but these can almost always be programmed around *Although Postgres has a true BOOLEAN boolean columns are always mapped to as the code does not always treat the column as a and VARBINARY columns should simply be TEXT The only exception is when VARBINARY is used to store true binary data
This document describes the state of Postgres support in and is fairly well maintained The main code is very well while extensions are very hit and miss it is probably the most supported database after MySQL Much of the work in making MediaWiki database agnostic came about through the work of creating Postgres but without copying over all the usage comments General notes on the but these can almost always be programmed around *Although Postgres has a true BOOLEAN type