/** * Handles the saving of image meta data * * @author Andreas Gohr <*****@*****.**> */ function media_metasave($id, $auth, $data) { if ($auth < AUTH_UPLOAD) { return false; } if (!checkSecurityToken()) { return false; } global $lang; global $conf; $src = mediaFN($id); $meta = new JpegMeta($src); $meta->_parseAll(); foreach ($data as $key => $val) { $val = trim($val); if (empty($val)) { $meta->deleteField($key); } else { $meta->setField($key, $val); } } if ($meta->save()) { if ($conf['fperm']) { chmod($src, $conf['fperm']); } msg($lang['metasaveok'], 1); return $id; } else { msg($lang['metasaveerr'], -1); return false; } }
/** * Handles the saving of image meta data * * @author Andreas Gohr <*****@*****.**> * @author Kate Arzamastseva <*****@*****.**> * * @param string $id media id * @param int $auth permission level * @param array $data * @return false|string */ function media_metasave($id, $auth, $data) { if ($auth < AUTH_UPLOAD) { return false; } if (!checkSecurityToken()) { return false; } global $lang; global $conf; $src = mediaFN($id); $meta = new JpegMeta($src); $meta->_parseAll(); foreach ($data as $key => $val) { $val = trim($val); if (empty($val)) { $meta->deleteField($key); } else { $meta->setField($key, $val); } } $old = @filemtime($src); if (!file_exists(mediaFN($id, $old)) && file_exists($src)) { // add old revision to the attic media_saveOldRevision($id); } $filesize_old = filesize($src); if ($meta->save()) { if ($conf['fperm']) { chmod($src, $conf['fperm']); } @clearstatcache(true, $src); $new = @filemtime($src); $filesize_new = filesize($src); $sizechange = $filesize_new - $filesize_old; // add a log entry to the media changelog addMediaLogEntry($new, $id, DOKU_CHANGE_TYPE_EDIT, $lang['media_meta_edited'], '', null, $sizechange); msg($lang['metasaveok'], 1); return $id; } else { msg($lang['metasaveerr'], -1); return false; } }