initiate (); ob_start (); $db = Database::singleton (); $sql = "SELECT u._name AS author, r.*, to_char(r._create, 'DD-MM-YYYY HH24:MI:SS') AS created FROM ". $field->getRelation () ." r LEFT JOIN ". $db->getSchema () ."._user u ON u._id = r._user WHERE r._relation = '". $itemId ."' ORDER BY r._version DESC"; $sth = $db->prepare ($sql); $sth->execute (); $control = array (); while ($obj = $sth->fetch (PDO::FETCH_OBJ)) { if (in_array ($obj->_id, $control) || !$field->docExists ($obj->_id)) continue; $control [] = $obj->_id; echo $field->getDocument ($obj->_id)->getLabel () .'('. __ ('Version') .': '. $obj->_version .', '. __ ('Author') .': '. (is_null ($obj->author) ? __ ('Generated by the system') : $obj->author) .', '. __ ('Date') .': '. $obj->created .')' . "\n"; } return ob_get_clean (); ?>