72 if ( $val !==
'True' && $val !==
'False' ) {
73 $this->logger->info( __METHOD__ .
" Expected True or False but got $val" );
90 if ( !preg_match(
'/^(?:-?\d+)\/(?:\d+[1-9]|[1-9]\d*)$/D', $val ) ) {
91 $this->logger->info( __METHOD__ .
" Expected rational but got $val" );
107 if ( !$standalone ) {
111 if ( !preg_match(
'/^[-+]?\d*(?:\.?\d*)$/D', $val )
112 || !is_numeric( $val )
114 $this->logger->info( __METHOD__ .
" Expected rating but got $val" );
124 $this->logger->info( __METHOD__ .
" Rating too low, setting to -1 (Rejected)" );
130 $this->logger->info( __METHOD__ .
" Rating too high, setting to 5" );
146 if ( !$standalone ) {
150 if ( !preg_match(
'/^[-+]?\d+$/D', $val ) ) {
151 $this->logger->info( __METHOD__ .
" Expected integer but got $val" );
165 if ( !$standalone ) {
172 if ( isset( $info[
'rangeLow'] )
173 && isset( $info[
'rangeHigh'] )
174 && is_numeric( $val )
175 && ( intval( $val ) <= $info[
'rangeHigh'] )
176 && ( intval( $val ) >= $info[
'rangeLow'] )
181 if ( !isset( $info[
'choices'][$val] ) && !$inRange ) {
182 $this->logger->info( __METHOD__ .
" Expected closed choice, but got $val" );
199 if ( !( isset( $val[
'Fired'] )
200 && isset( $val[
'Function'] )
201 && isset( $val[
'Mode'] )
202 && isset( $val[
'RedEyeMode'] )
203 && isset( $val[
'Return'] )
205 $this->logger->info( __METHOD__ .
" Flash structure did not have all the required components" );
208 $val = (
"\0" | ( $val[
'Fired'] ===
'True' )
209 | ( intval( $val[
'Return'] ) << 1 )
210 | ( intval( $val[
'Mode'] ) << 3 )
211 | ( ( $val[
'Function'] ===
'True' ) << 5 )
212 | ( ( $val[
'RedEyeMode'] ===
'True' ) << 6 ) );
230 if ( !$standalone ) {
234 if ( !preg_match(
'/^[-A-Za-z0-9]{2,}$/D', $val ) ) {
236 $this->logger->info( __METHOD__ .
" Expected Lang code but got $val" );
259 if ( !$standalone ) {
267 '/^([0-3]\d{3})(?:-([01]\d)(?:-([0-3]\d)(?:T([0-2]\d):([0-6]\d)(?::([0-6]\d)(?:\.\d+)?)?([-+]\d{2}:\d{2}|Z)?)?)?)?$/D',
272 $this->logger->info( __METHOD__ .
" Expected date but got $val" );
289 if (
$res[1] ===
'0000' ) {
290 $this->logger->info( __METHOD__ .
" Invalid date (year 0): $val" );
296 if ( !isset(
$res[4] ) ) {
299 if ( isset(
$res[2] ) ) {
300 $val .=
':' .
$res[2];
302 if ( isset(
$res[3] ) ) {
303 $val .=
':' .
$res[3];
309 if ( !isset(
$res[7] ) ||
$res[7] ===
'Z' ) {
313 if ( isset(
$res[6] ) &&
$res[6] !==
'' ) {
314 $val .=
':' .
$res[6];
321 $stripSeconds =
false;
322 if ( !isset(
$res[6] ) ||
$res[6] ===
'' ) {
324 $stripSeconds =
true;
335 $offset = intval( substr( $res[7], 1, 2 ) ) * 60 * 60;
336 $offset += intval( substr( $res[7], 4, 2 ) ) * 60;
337 if ( substr( $res[7], 0, 1 ) ===
'-' ) {
342 if ( $stripSeconds ) {
344 $val = substr( $val, 0, -3 );
362 if ( !$standalone ) {
368 '/(\d{1,3}),(\d{1,2}),(\d{1,2})([NWSE])/D',
371 $coord = intval( $m[1] );
372 $coord += intval( $m[2] ) * ( 1 / 60 );
373 $coord += intval( $m[3] ) * ( 1 / 3600 );
374 if ( $m[4] ===
'S' || $m[4] ===
'W' ) {
380 } elseif ( preg_match(
381 '/(\d{1,3}),(\d{1,2}(?:.\d*)?)([NWSE])/D',
384 $coord = intval( $m[1] );
385 $coord += floatval( $m[2] ) * ( 1 / 60 );
386 if ( $m[3] ===
'S' || $m[3] ===
'W' ) {
393 $this->logger->info( __METHOD__
394 .
" Expected GPSCoordinate, but got $val." );
setLogger(LoggerInterface $logger)
validateFlash($info, &$val, $standalone)
function to validate and modify flash structure
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
validateInteger($info, &$val, $standalone)
function to validate integers
__construct(LoggerInterface $logger)
const TS_UNIX
Unix time - the number of seconds since 1970-01-01 00:00:00 UTC.
validateLangCode($info, &$val, $standalone)
function to validate LangCode properties ( en-GB, etc )
const TS_EXIF
An Exif timestamp (YYYY:MM:DD HH:MM:SS)
validateClosed($info, &$val, $standalone)
function to validate properties with a fixed number of allowed choices.
validateRational($info, &$val, $standalone)
function to validate rational properties ( 12/10 )
This contains some static methods for validating XMP properties.
validateRating($info, &$val, $standalone)
function to validate rating properties -1, 0-5
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 convert($style=TS_UNIX, $ts)
Convert a timestamp string to a given format.
validateBoolean($info, &$val, $standalone)
Function to validate boolean properties ( True or False )
validateDate($info, &$val, $standalone)
function to validate date properties, and convert to (partial) Exif format.
validateGPS($info, &$val, $standalone)
function to validate, and more importantly translate the XMP DMS form of gps coords to the decimal fo...