// blocks, where it's usually between 32-127 bytes each.
const MAX_SUBBLOCKS = 262144; // 5mb divided by 20.
+ /**
+ * @throws Exception
+ * @param $filename string
+ * @return array
+ */
static function getMetadata( $filename ) {
self::$gif_frame_sep = pack( "C", ord("," ) );
self::$gif_extension_sep = pack( "C", ord("!" ) );
);
}
+ /**
+ * @param $fh
+ * @param $bpp
+ * @return void
+ */
static function readGCT( $fh, $bpp ) {
if ( $bpp > 0 ) {
for( $i=1; $i<=pow( 2, $bpp ); ++$i ) {
}
}
+ /**
+ * @param $data
+ * @return int
+ */
static function decodeBPP( $data ) {
$buf = unpack( 'C', $data );
$buf = $buf[1];
return $have_map ? $bpp : 0;
}
+ /**
+ * @param $fh
+ * @return
+ */
static function skipBlock( $fh ) {
while ( !feof( $fh ) ) {
$buf = fread( $fh, 1 );
break;
case '2#115': /* source */
/* "Identifies the original owner of the intellectual content of the
- *objectdata. This could be an agency, a member of an agency or
+ *objectdata. This could be an agency, a member of an agency or
*an individual." */
$data['Source'] = self::convIPTC( $val, $c );
break;
/**
* Convert an iptc date and time tags into the exif format
*
- * @todo Potentially this should also capture the timezone offset.
+ * @todo Potentially this should also capture the timezone offset.
* @param Array $date The date tag
* @param Array $time The time tag
+ * @param $c
* @return String Date in exif format.
*/
private static function timeHelper( $date, $time, $c ) {
$dateOnly = true;
}
- if ( ! ( preg_match('/\d\d\d\d\d\d[-+]\d\d\d\d/', $time)
+ if ( ! ( preg_match('/\d\d\d\d\d\d[-+]\d\d\d\d/', $time)
&& preg_match('/\d\d\d\d\d\d\d\d/', $date)
&& substr($date, 0, 4) !== '0000'
&& substr($date, 4, 2) !== '00'
} else {
return $finalTimestamp;
}
-
}
/**
* Helper function to convert charset for iptc values.
* @param $data Mixed String or Array: The iptc string
* @param $charset String: The charset
+ *
+ * @return string
*/
private static function convIPTC ( $data, $charset ) {
if ( is_array( $data ) ) {
$val = self::convIPTCHelper( $val, $charset );
}
} else {
- $data = self::convIPTCHelper ( $data, $charset );
+ $data = self::convIPTCHelper( $data, $charset );
}
return $data;
* Helper function of a helper function to convert charset for iptc values.
* @param $data Mixed String or Array: The iptc string
* @param $charset String: The charset
+ *
+ * @return string
*/
private static function convIPTCHelper ( $data, $charset ) {
if ( $charset ) {
if ($data === $oldData) {
return $data; //if validation didn't change $data
} else {
- return self::convIPTCHelper ( $oldData, 'Windows-1252' );
+ return self::convIPTCHelper( $oldData, 'Windows-1252' );
}
}
return trim( $data );
/**
* take the value of 1:90 tag and returns a charset
- * @param String $tag 1:90 tag.
- * @return charset name or "?"
+ * @param String $tag 1:90 tag.
+ * @return string charset name or "?"
* Warning, this function does not (and is not intended to) detect
* all iso 2022 escape codes. In practise, the code for utf-8 is the
* only code that seems to have wide use. It does detect that code.
$c = "NS_4551-1";
break;
case "\x1b(f": //iso646-FR
- $c = "NF_Z_62-010";
+ $c = "NF_Z_62-010";
break;
case "\x1b(g":
$c = "PT2"; //iso646-PT2
$c = 'CSN_369103';
break;
default:
- wfDebugLog('iptc', __METHOD__ . 'Unknown charset in iptc 1:90: ' . bin2hex( $tag ) );
+ wfDebugLog('iptc', __METHOD__ . 'Unknown charset in iptc 1:90: ' . bin2hex( $tag ) );
//at this point just give up and refuse to parse iptc?
$c = false;
}
array( $this, 'endElement' ) );
xml_set_character_data_handler( $this->xmlParser, array( $this, 'char' ) );
-
-
}
/** Destroy the xml parser
}
}
+
/** When we hit a closing element in MODE_IGNORE
* Check to see if this is the element we started to ignore,
* in which case we get out of MODE_IGNORE
return;
}
+
/**
* Hit a closing element when in MODE_SIMPLE.
* This generally means that we finished processing a
array_shift( $this->mode );
}
+
/**
* Hit a closing element in MODE_STRUCT, MODE_SEQ, MODE_BAG
* generally means we've finished processing a nested structure.
throw new MWException( __METHOD__ . " expected </rdf:seq> or </rdf:bag> but instead got $elm." );
}
}
+
/**
* End element while in MODE_QDESC
* mostly when ending an element when we have a simple value
}
+
/**
* Handler for hitting a closing element.
*
break;
}
}
+
/**
* Process attributes.
* Simple values can be stored as either a tag or attribute
}
}
}
+
/**
* Given an extracted value, save it to results array
*