Пример #1
0
 /** sorts the visible/invisible field.
  * Split off from ImageHandler::formatMetadata, as used by more than
  * one type of handler.
  *
  * This is used by the media handlers that use the FormatMetadata class
  *
  * @param array $metadataArray Metadata array
  * @param bool|IContextSource $context Context to use (optional)
  * @return array Array for use displaying metadata.
  */
 function formatMetadataHelper($metadataArray, $context = false)
 {
     $result = ['visible' => [], 'collapsed' => []];
     $formatted = FormatMetadata::getFormattedData($metadataArray, $context);
     // Sort fields into visible and collapsed
     $visibleFields = $this->visibleMetadataFields();
     foreach ($formatted as $name => $value) {
         $tag = strtolower($name);
         self::addMeta($result, in_array($tag, $visibleFields) ? 'visible' : 'collapsed', 'exif', $tag, $value);
     }
     return $result;
 }
Пример #2
0
 /**
  * Use FormatMetadata to create formatted values for display to user
  * (is this ever used?)
  *
  * @deprecated since 1.18
  */
 function makeFormattedData()
 {
     wfDeprecated(__METHOD__, '1.18');
     $this->mFormattedExifData = FormatMetadata::getFormattedData($this->mFilteredExifData);
 }
Пример #3
0
 /**
  * @return array
  */
 function getFormattedData()
 {
     return FormatMetadata::getFormattedData($this->meta);
 }
	/**
	 * Get an array structure that looks like this:
	 *
	 * array(
	 *	'visible' => array(
	 *	   'Human-readable name' => 'Human readable value',
	 *	   ...
	 *	),
	 *	'collapsed' => array(
	 *	   'Human-readable name' => 'Human readable value',
	 *	   ...
	 *	)
	 * )
	 * The UI will format this into a table where the visible fields are always
	 * visible, and the collapsed fields are optionally visible.
	 *
	 * The function should return false if there is no metadata to display.
	 */

	function formatMetadata( $image ) {
		$result = array(
			'visible' => array(),
			'collapsed' => array()
		);
		$metadata = $image->getMetadata();
		if ( !$metadata ) {
			return false;
		}
		$exif = unserialize( $metadata );
		$exif = $exif['exif'];
		if ( !$exif ) {
			return false;
		}
		unset( $exif['MEDIAWIKI_EXIF_VERSION'] );
		if ( class_exists( 'FormatMetadata' ) ) {
			// 1.18+
			$formatted = FormatMetadata::getFormattedData( $exif );
		} else {
			// 1.17 and earlier.
			$format = new FormatExif( $exif );

			$formatted = $format->getFormattedData();
		}
		// Sort fields into visible and collapsed
		$visibleFields = $this->visibleMetadataFields();
		foreach ( $formatted as $name => $value ) {
			$tag = strtolower( $name );
			self::addMeta( $result,
				in_array( $tag, $visibleFields ) ? 'visible' : 'collapsed',
				'exif',
				$tag,
				$value
			);
		}
		$meta = unserialize( $metadata );
		$errors_raw = PagedTiffHandler::getMetadataErrors( $meta );
		if ( $errors_raw ) {
			$errors = PagedTiffHandler::joinMessages( $errors_raw );
			self::addMeta( $result,
				'collapsed',
				'metadata',
				'error',
				$errors
			);
			// XXX: need translation for <metadata-error>
		}
		if ( !empty( $meta['warnings'] ) ) {
			$warnings = PagedTiffHandler::joinMessages( $meta['warnings'] );
			self::addMeta( $result,
				'collapsed',
				'metadata',
				'warning',
				$warnings
			);
			// XXX: need translation for <metadata-warning>
		}
		return $result;
	}