40 static function parse( $rawData ) {
41 $parsed = iptcparse( $rawData );
43 if ( !is_array( $parsed ) ) {
49 if ( isset( $parsed[
'1#090'] ) && isset( $parsed[
'1#090'][0] ) ) {
50 $c = self::getCharset( $parsed[
'1#090'][0] );
57 unset( $parsed[
'1#090'] );
60 foreach ( $parsed
as $tag => $val ) {
61 if ( isset( $val[0] ) && trim( $val[0] ) ==
'' ) {
62 wfDebugLog(
'iptc',
"IPTC tag $tag had only whitespace as its value." );
67 $data[
'ImageDescription'] = self::convIPTC( $val, $c );
70 $data[
'Copyright'] = self::convIPTC( $val, $c );
80 $bylines = self::convIPTC( $val, $c );
81 if ( isset( $parsed[
'2#085'] ) ) {
82 $titles = self::convIPTC( $parsed[
'2#085'], $c );
88 for ( $i = 0; $i < $titleCount; $i++ ) {
89 if ( isset( $bylines[$i] ) ) {
92 $bylines[$i] =
$titles[$i] .
', ' . $bylines[$i];
95 $data[
'Artist'] = $bylines;
98 $data[
'Keywords'] = self::convIPTC( $val, $c );
101 $data[
'CountryDest'] = self::convIPTC( $val, $c );
104 $data[
'ProvinceOrStateDest'] = self::convIPTC( $val, $c );
107 $data[
'CityDest'] = self::convIPTC( $val, $c );
110 $data[
'SublocationDest'] = self::convIPTC( $val, $c );
113 $data[
'ObjectName'] = self::convIPTC( $val, $c );
116 $data[
'SpecialInstructions'] = self::convIPTC( $val, $c );
119 $data[
'Headline'] = self::convIPTC( $val, $c );
124 $data[
'Credit'] = self::convIPTC( $val, $c );
130 $data[
'Source'] = self::convIPTC( $val, $c );
134 $data[
'EditStatus'] = self::convIPTC( $val, $c );
137 $data[
'iimCategory'] = self::convIPTC( $val, $c );
140 $data[
'iimSupplementalCategory'] = self::convIPTC( $val, $c );
143 $data[
'Urgency'] = self::convIPTC( $val, $c );
148 $data[
'FixtureIdentifier'] = self::convIPTC( $val, $c );
154 $data[
'LocationDestCode'] = self::convIPTC( $val, $c );
159 $data[
'LocationDest'] = self::convIPTC( $val, $c );
165 $software = self::convIPTC( $val, $c );
167 if ( count( $software ) !== 1 ) {
171 wfDebugLog(
'iptc',
'IPTC: Wrong count on 2:65 Software field' );
175 if ( isset( $parsed[
'2#070'] ) ) {
177 $softwareVersion = self::convIPTC( $parsed[
'2#070'], $c );
178 unset( $parsed[
'2#070'] );
179 $data[
'Software'] = [ [ $software[0], $softwareVersion[0] ] ];
181 $data[
'Software'] = $software;
187 $data[
'ObjectCycle'] = self::convIPTC( $val, $c );
195 $data[
'CountryCodeDest'] = self::convIPTC( $val, $c );
202 $data[
'OriginalTransmissionRef'] = self::convIPTC( $val, $c );
205 $data[
'Contact'] = self::convIPTC( $val, $c );
212 $data[
'Writer'] = self::convIPTC( $val, $c );
215 $data[
'LanguageCode'] = self::convIPTC( $val, $c );
225 if ( isset( $parsed[
'2#060'] ) ) {
226 $time = $parsed[
'2#060'];
239 if ( isset( $parsed[
'2#063'] ) ) {
240 $time = $parsed[
'2#063'];
252 if ( isset( $parsed[
'2#035'] ) ) {
253 $time = $parsed[
'2#035'];
265 if ( isset( $parsed[
'2#038'] ) ) {
266 $time = $parsed[
'2#038'];
280 if ( strlen( $val[0] ) == 2 ) {
282 $versionValue = ord( substr( $val[0], 0, 1 ) ) * 256;
283 $versionValue += ord( substr( $val[0], 1, 1 ) );
284 $data[
'iimVersion'] = $versionValue;
298 $con = self::convIPTC( $val, $c );
299 if ( strlen( $con[0] ) < 5 ) {
305 $extracted = substr( $con[0], 4 );
306 $data[
'IntellectualGenre'] = $extracted;
314 $codes = self::convIPTC( $val, $c );
315 foreach ( $codes
as $ic ) {
316 $fields = explode(
':', $ic, 3 );
318 if ( count( $fields ) < 2 || $fields[0] !==
'IPTC' ) {
320 .
'Invalid 2:12 - ' . $ic );
323 $data[
'SubjectNewsCode'] = $fields[1];
342 wfDebugLog(
'iptc',
"Unsupported iptc tag: $tag. Value: " . implode(
',', $val ) );
360 if ( count( $date ) === 1 ) {
363 list( $date ) = self::convIPTC( $date, $c );
368 if ( count(
$time ) === 1 ) {
372 $time =
'000000+0000';
376 if ( !( preg_match(
'/\d\d\d\d\d\d[-+]\d\d\d\d/',
$time )
377 && preg_match(
'/\d\d\d\d\d\d\d\d/', $date )
378 && substr( $date, 0, 4 ) !==
'0000'
379 && substr( $date, 4, 2 ) !==
'00'
380 && substr( $date, 6, 2 ) !==
'00'
387 wfDebugLog(
'iptc',
"IPTC: invalid time ( $time ) or date ( $date )" );
393 if ( $unixTS ===
false ) {
394 wfDebugLog(
'iptc',
"IPTC: can't convert date to TS_UNIX: $date $time." );
399 $tz = ( intval( substr(
$time, 7, 2 ) ) * 60 * 60 )
400 + ( intval( substr(
$time, 9, 2 ) ) * 60 );
402 if ( substr(
$time, 6, 1 ) ===
'-' ) {
407 if ( $finalTimestamp ===
false ) {
408 wfDebugLog(
'iptc',
"IPTC: can't make final timestamp. Date: " . ( $unixTS + $tz ) );
414 return substr( $finalTimestamp, 0, 10 );
416 return $finalTimestamp;
427 private static function convIPTC( $data, $charset ) {
428 if ( is_array( $data ) ) {
429 foreach ( $data
as &$val ) {
430 $val = self::convIPTCHelper( $val, $charset );
433 $data = self::convIPTCHelper( $data, $charset );
448 MediaWiki\suppressWarnings();
449 $data = iconv( $charset,
"UTF-8//IGNORE", $data );
450 MediaWiki\restoreWarnings();
451 if ( $data ===
false ) {
453 wfDebugLog(
'iptc', __METHOD__ .
" Error converting iptc data charset $charset to utf-8" );
459 UtfNormal\Validator::quickIsNFCVerify( $data );
460 if ( $data === $oldData ) {
463 return self::convIPTCHelper( $oldData,
'Windows-1252' );
467 return trim( $data );
555 $c =
"CSA_Z243.4-1985-1";
558 $c =
"CSA_Z243.4-1985-2";
562 case "\x1b&@\x1b\$B":
563 case "\x1b&@\x1b\$(B":
564 $c =
"JIS_C6226-1983";
596 wfDebugLog(
'iptc', __METHOD__ .
'Unknown charset in iptc 1:90: ' . bin2hex(
$tag ) );
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
static convIPTCHelper($data, $charset)
Helper function of a helper function to convert charset for iptc values.
static getCharset($tag)
take the value of 1:90 tag and returns a charset
const TS_UNIX
Unix time - the number of seconds since 1970-01-01 00:00:00 UTC.
wfTimestamp($outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
wfDebugLog($logGroup, $text, $dest= 'all', array $context=[])
Send a line to a supplementary debug log file, if configured, or main debug log if not...
const TS_EXIF
An Exif timestamp (YYYY:MM:DD HH:MM:SS)
static timeHelper($date, $time, $c)
Convert an iptc date and time tags into the exif format.
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books $tag
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
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
static convIPTC($data, $charset)
Helper function to convert charset for iptc values.
linkcache txt The LinkCache class maintains a list of article titles and the information about whether or not the article exists in the database This is used to mark up links when displaying a page If the same link appears more than once on any page then it only has to be looked up once In most cases link lookups are done in batches with the LinkBatch class or the equivalent in so the link cache is mostly useful for short snippets of parsed and for links in the navigation areas of the skin The link cache was formerly used to track links used in a document for the purposes of updating the link tables This application is now deprecated To create a you can use the following $titles
static parse($rawData)
This takes the results of iptcparse() and puts it into a form that can be handled by mediawiki...
Class for some IPTC functions.
see documentation in includes Linker php for Linker::makeImageLink & $time