Exemplo n.º 1
0
 function convertMetadataVersion($metadata, $version = 1)
 {
     // basically flattens arrays.
     $version = explode(';', $version, 2);
     $version = intval($version[0]);
     if ($version < 1 || $version >= 2) {
         return $metadata;
     }
     $avoidHtml = true;
     if (!is_array($metadata)) {
         $metadata = unserialize($metadata);
     }
     if (!isset($metadata['MEDIAWIKI_EXIF_VERSION']) || $metadata['MEDIAWIKI_EXIF_VERSION'] != 2) {
         return $metadata;
     }
     // Treat Software as a special case because in can contain
     // an array of (SoftwareName, Version).
     if (isset($metadata['Software']) && is_array($metadata['Software']) && is_array($metadata['Software'][0]) && isset($metadata['Software'][0][0]) && isset($metadata['Software'][0][1])) {
         $metadata['Software'] = $metadata['Software'][0][0] . ' (Version ' . $metadata['Software'][0][1] . ')';
     }
     $formatter = new FormatMetadata();
     // ContactInfo also has to be dealt with specially
     if (isset($metadata['Contact'])) {
         $metadata['Contact'] = $formatter->collapseContactInfo($metadata['Contact']);
     }
     foreach ($metadata as &$val) {
         if (is_array($val)) {
             $val = $formatter->flattenArrayReal($val, 'ul', $avoidHtml);
         }
     }
     $metadata['MEDIAWIKI_EXIF_VERSION'] = 1;
     return $metadata;
 }
Exemplo n.º 2
0
 /**
  * Flatten an array, using the content language for any messages.
  *
  * @param array $vals Array of values
  * @param string $type Type of array (either lang, ul, ol).
  *   lang = language assoc array with keys being the lang code
  *   ul = unordered list, ol = ordered list
  *   type can also come from the '_type' member of $vals.
  * @param bool $noHtml If to avoid returning anything resembling HTML.
  *   (Ugly hack for backwards compatibility with old MediaWiki).
  * @param bool|IContextSource $context
  * @return string Single value (in wiki-syntax).
  * @since 1.23
  */
 public static function flattenArrayContentLang($vals, $type = 'ul', $noHtml = false, $context = false)
 {
     global $wgContLang;
     $obj = new FormatMetadata();
     if ($context) {
         $obj->setContext($context);
     }
     $context = new DerivativeContext($obj->getContext());
     $context->setLanguage($wgContLang);
     $obj->setContext($context);
     return $obj->flattenArrayReal($vals, $type, $noHtml);
 }
 /**
  * Flatten an array, using the user language for any messages.
  *
  * @param array $vals Array of values
  * @param string $type Type of array (either lang, ul, ol).
  *   lang = language assoc array with keys being the lang code
  *   ul = unordered list, ol = ordered list
  *   type can also come from the '_type' member of $vals.
  * @param bool $noHtml If to avoid returning anything resembling HTML.
  *   (Ugly hack for backwards compatibility with old MediaWiki).
  * @param bool|IContextSource $context
  * @return string Single value (in wiki-syntax).
  */
 public static function flattenArray($vals, $type = 'ul', $noHtml = false, $context = false)
 {
     $obj = new FormatMetadata();
     if ($context) {
         $obj->setContext($context);
     }
     return $obj->flattenArrayReal($vals, $type, $noHtml);
 }