set_prefilter('batch_manager_unit', 'CR_batch_single'); } function CR_batch_single($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} {html_options name=copyright-{$element.ID} options=$CRoptions} {\'Creation date\''; return preg_replace($search, $replacement, $content); // Dit is een interresant testje - deze functie word dus een aantal keren (3) aangeroepen, // en pas de laatste keer is bevat $content meer dan een aantal enters... // return $content.''; } function CR_add_batch_single_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); } function CR_batch_single_submit() { // The image id's: $collection = explode(',', $_POST['element_ids']); // Delete all existing id's of which the Copyright is going to be set if (count($collection) > 0) { $query = sprintf( 'DELETE FROM %s WHERE media_id IN (%s) ;', COPYRIGHTS_MEDIA, implode(',', $collection)); pwg_query($query); } // Add all Copyrights to an array $edits = array(); foreach ($collection as $image_id) { // The copyright id's $crID = pwg_db_real_escape_string($_POST['copyrightID-'.$image_id]); array_push( $edits, array( 'media_id' => $image_id, 'cr_id' => $crID, ) ); } // Add the array to the database mass_inserts( COPYRIGHTS_MEDIA, // Table name array_keys($edits[0]), // Columns $edits // Data ); } ?>