From 2bf38c5b005b0752789e503bab11db17f5a2f41b Mon Sep 17 00:00:00 2001 From: Paal Joergensen Date: Mon, 17 Sep 2018 12:54:21 +0200 Subject: [PATCH] Support title in metadata --- h5p-metadata.class.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/h5p-metadata.class.php b/h5p-metadata.class.php index b60158f..eb0f529 100644 --- a/h5p-metadata.class.php +++ b/h5p-metadata.class.php @@ -5,6 +5,10 @@ abstract class H5PMetadata { const FIELDS = array( + 'title' => array( + 'type' => 'text', + 'maxLength' => 255 + ), 'authors' => array( 'type' => 'json' ), @@ -42,9 +46,11 @@ abstract class H5PMetadata { /** * Make the metadata into an associative array keyed by the property names * @param mixed $metadata Array or object containing metadata + * @param bool $include_title + * @param array $types * @return array */ - public static function toDBArray($metadata, &$types = array()) { + public static function toDBArray($metadata, $include_title = true, &$types = array()) { $fields = array(); if (!is_array($metadata)) { @@ -52,6 +58,11 @@ abstract class H5PMetadata { } foreach (self::FIELDS as $key => $config) { + + if ($key === 'title' && !$include_title) { + continue; + } + if (isset($metadata[$key])) { $value = $metadata[$key]; $db_field_name = strtolower(preg_replace('/(?