'Copyrights', 'URL' => get_admin_plugin_menu_link(dirname(__FILE__)).'/admin.php' ) ); return $menu; } /* +-----------------------------------------------------------------------+ * | Plugin image | * +-----------------------------------------------------------------------+ */ //if (script_basename() == 'picture') // Why should i want this here? include_once(dirname(__FILE__).'/image.php'); /* +-----------------------------------------------------------------------+ * | Plugin batchmanager | * +-----------------------------------------------------------------------+ */ // @Johan: Misschien een goed idee om dit ook in een apart php scriptje te zetten, voor de overzichtelijkheid. // En om deze reden (Citaat uit de piwigo docs http://piwigo.org/doc/doku.php?id=en:plugins): // Code size // When PWG loads the plugins, it will include every main.inc.php. // Don't put in your main.inc.php 3000 lines of code just to add a page on the administration menu. // Split you main.inc.php in several files and feel free to add include_once inside functions defined in main.inc.php as much as you want. // Add copyrights drop down menu to the batch manager add_event_handler('loc_end_element_set_global', 'copyrights_batch'); // Add handler to the submit event of the batch manager add_event_handler('element_set_global_action', 'copyrights_batch_submit', 50, 2); function copyrights_batch() { global $template; load_language('plugin.lang', dirname(__FILE__).'/'); // Engels is voorlopig goed zat // Assign the template for batch management $template->set_filename('batch', dirname(__FILE__).'/batch.tpl'); // 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); // Goed, ik weet dus echt niet waarom dit hieronder gedaan wordt... // AHA!!!! - dit is er zodat de "choose action" optie deze plugin gebruikt.... $template->append('element_set_global_plugins_actions', array( 'ID' => 'copyrights', // ID of the batch manager action 'NAME' => l10n('Edit copyright'), // Description of the batch manager action 'CONTENT' => $template->parse('batch', true) ) ); } // * Deze functie wordt een keer aangeroepen, nadat de gebruiker submit. // * Fietst met een foreach loop over de geselecteerde fotos // * Rammelt alle toevoegingen in 1x met mass_updates naar de db. function copyrights_batch_submit($action, $collection) { if ($action == 'copyrights') { $crID = pwg_db_real_escape_string($_POST['copyrightID']); if (count($collection) > 0) { $query = sprintf( 'DELETE FROM %s WHERE media_id IN (%s) ;', COPYRIGHTS_MEDIA, implode(',', $collection)); pwg_query($query); } $edits = array(); foreach ($collection as $image_id) { array_push( $edits, array( 'media_id' => $image_id, 'cr_id' => $crID, ) ); } mass_inserts( COPYRIGHTS_MEDIA, // Table name array_keys($edits[0]), //Columns $edits // Data ); } } ?>