/** * Create output */ function render($mode, Doku_Renderer $renderer, $data) { if ($mode == 'xthml') { return true; // don't output anything } elseif ($mode == 'metadata') { /** @var Doku_Renderer_metadata $renderer */ // do some validation / conversion for date metadata if (isset($data['date'])) { if (is_array($data['date'])) { foreach ($data['date'] as $key => $date) { $date = $this->_convertDate(trim($date)); if (!$date) { unset($data['date'][$key]); } else { $data['date'][$key] = $date; } } } else { unset($data['date']); } } // now merge the arrays $protected = array('description', 'date', 'contributor'); foreach ($data as $key => $value) { // be careful with sub-arrays of $meta['relation'] if ($key == 'relation') { foreach ($value as $subkey => $subvalue) { if ($subkey == 'media') { $renderer->meta[$key][$subkey][cleanID($subvalue)] = @file_exists(mediaFN($subvalue)); } elseif ($subkey == 'firstimage') { /* The metadata renderer overrides the first image value with its internal value at the end. Therefore the only thing we can do is setting this internal value by calling _firstimage. This fails if there has already been a first image saved. */ $renderer->_firstimage($subvalue); } else { // for everything else assume that we have a page id $renderer->meta[$key][$subkey][cleanID($subvalue)] = page_exists($subvalue); } } // be careful with some senisitive arrays of $meta } elseif (in_array($key, $protected)) { if (array_key_exists($key, $renderer->meta)) { $renderer->meta[$key] = array_merge($renderer->meta[$key], $value); } else { $renderer->meta[$key] = $value; } // no special treatment for the rest } else { $renderer->meta[$key] = $value; } } } }