set_prefilter('picture_modify', 'CR_modify'); } function CR_modify($content, &$smarty) { $search = "#{'Creation date'#"; // Not ideal, but ok for now :) // We use the from the Creation date, and give them a new $replacement = '{\'Copyright\'|@translate} {\'Creation date\''; return preg_replace($search, $replacement, $content); } function CR_add_modify_vars_to_template() { global $template; load_language('plugin.lang', dirname(__FILE__).'/'); // Fetch all the copyrights and assign them to the template $query = sprintf( 'SELECT `cr_id`,`name` FROM %s WHERE `visible`<>0 ;', COPYRIGHTS_ADMIN); $result = pwg_query($query); $CRoptions = array(); while ($row = pwg_db_fetch_assoc($result)) { $CRoptions[$row['cr_id']] = $row['name']; } $template->assign('CRoptions', $CRoptions); // Get the current Copyright $image_id = $_GET['image_id']); $query = sprintf( 'SELECT `media_id`, `cr_id` FROM %s WHERE `media_id` = %d ;', COPYRIGHTS_MEDIA, $image_id); $result = pwg_query($query); $CRid = 0; // Default is '--' while ($row = pwg_db_fetch_assoc($result)) { $CRid = $row['cr_id']; } $template->assign('CRid', $CRid); } function CR_modify_submit() { if (isset($_POST['submit'])) { // The data from the submit $image_id = $_GET['image_id']); $CRid = $_POST['copyright']; // Delete the Copyright if it allready exists $query = sprintf( 'DELETE FROM %s WHERE `media_id` = %d ;', COPYRIGHTS_MEDIA, $image_id); pwg_query($query); // Insert the Copyright $query = sprintf( 'INSERT INTO %s VALUES (%d, %d) ;', COPYRIGHTS_MEDIA, $image_id, $CRid); pwg_query($query); } } ?>