function get_element_metadata($infos) { return get_sync_metadata($infos); }
/** * Sync all metadata of a list of images. * Metadata are fetched from original files and saved in database. * * @param int[] $ids */ function sync_metadata($ids) { global $conf; if (!defined('CURRENT_DATE')) { define('CURRENT_DATE', date('Y-m-d')); } $datas = array(); $tags_of = array(); $query = ' SELECT id, path, representative_ext FROM ' . IMAGES_TABLE . ' WHERE id IN ( ' . wordwrap(implode(', ', $ids), 160, "\n") . ' ) ;'; $result = pwg_query($query); while ($data = pwg_db_fetch_assoc($result)) { $data = get_sync_metadata($data); if ($data === false) { continue; } $id = $data['id']; foreach (array('keywords', 'tags') as $key) { if (isset($data[$key])) { if (!isset($tags_of[$id])) { $tags_of[$id] = array(); } foreach (explode(',', $data[$key]) as $tag_name) { $tags_of[$id][] = tag_id_from_tag_name($tag_name); } } } $data['date_metadata_update'] = CURRENT_DATE; $datas[] = $data; } if (count($datas) > 0) { $update_fields = get_sync_metadata_attributes(); $update_fields[] = 'date_metadata_update'; $update_fields = array_diff($update_fields, array('tags', 'keywords')); mass_updates(IMAGES_TABLE, array('primary' => array('id'), 'update' => $update_fields), $datas, MASS_UPDATES_SKIP_EMPTY); } set_tags_of($tags_of); }