Changeset 11621 for extensions/Copyrights/batch_single.php
- Timestamp:
- Jul 4, 2011, 2:17:12 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/Copyrights/batch_single.php
r11619 r11621 2 2 3 3 // Add a prefilter 4 add_event_handler('loc_end_element_set_unit', ' set_prefilter_batch_single', 55 );4 add_event_handler('loc_end_element_set_unit', 'CR_set_prefilter_batch_single', 55 ); 5 5 add_event_handler('loc_end_element_set_unit', 'CR_batch_single_submit', 55 ); 6 6 7 7 // Change the variables used by the function that changes the template 8 //add_event_handler('loc_begin_admin', 'CR_add_bsm_vars_to_template');8 add_event_handler('loc_begin_admin', 'CR_add_batch_single_vars_to_template'); 9 9 10 function set_prefilter_batch_single()10 function CR_set_prefilter_batch_single() 11 11 { 12 12 global $template; … … 16 16 function CR_batch_single($content, &$smarty) 17 17 { 18 18 $search = "#<td><strong>{'Creation date'#"; // Not ideal, but ok for now :) 19 19 20 21 $replacement = '<td><strong>DWO TESTJE</strong></td>20 // We use the <tr> from the Creation date, and give them a new <tr> 21 $replacement = '<td><strong>{\'Copyright\'|@translate}</strong></td> 22 22 <td> 23 DWO TESTJE23 {html_options name=copyright-{$element.ID} options=$CRoptions} 24 24 </td> 25 25 </tr> … … 32 32 // Dit is een interresant testje - deze functie word dus een aantal keren (3) aangeroepen, 33 33 // en pas de laatste keer is bevat $content meer dan een aantal enters... 34 // return $content.'<div id="dwo_test" style="display: none;">'.$content.'</div>';34 // return $content.'<div id="dwo_test" style="display: none;">'.$content.'</div>'; 35 35 } 36 36 37 function CR_add_b sm_vars_to_template()37 function CR_add_batch_single_vars_to_template() 38 38 { 39 // set template variables ($CRoptions) 40 global $template; 41 load_language('plugin.lang', dirname(__FILE__).'/'); 42 // Fetch all the copyrights and assign them to the template 43 $query = sprintf( 44 'SELECT `cr_id`,`name` 45 FROM %s 46 WHERE `visible`<>0 47 ;', 48 COPYRIGHTS_ADMIN); 49 $result = pwg_query($query); 50 $CRoptions = array(); 51 while ($row = pwg_db_fetch_assoc($result)) { 52 $CRoptions[$row['cr_id']] = $row['name']; 53 } 54 $template->assign('CRoptions', $CRoptions); 39 global $template; 40 41 load_language('plugin.lang', dirname(__FILE__).'/'); 42 43 // Fetch all the copyrights and assign them to the template 44 $query = sprintf( 45 'SELECT `cr_id`,`name` 46 FROM %s 47 WHERE `visible`<>0 48 ;', 49 COPYRIGHTS_ADMIN); 50 $result = pwg_query($query); 51 52 $CRoptions = array(); 53 while ($row = pwg_db_fetch_assoc($result)) { 54 $CRoptions[$row['cr_id']] = $row['name']; 55 } 56 $template->assign('CRoptions', $CRoptions); 55 57 } 56 58 57 59 function CR_batch_single_submit() 58 60 { 59 // The image id's: 60 $collection = explode(',', $_POST['element_ids']); 61 62 // Delete all existing id's of which the Copyright is going to be set 63 if (count($collection) > 0) { 64 $query = sprintf( 65 'DELETE 66 FROM %s 67 WHERE media_id IN (%s) 68 ;', 69 COPYRIGHTS_MEDIA, implode(',', $collection)); 70 pwg_query($query); 71 } 72 $edits = array(); 73 foreach ($collection as $image_id) 74 { 75 // The copyright id's 76 $crID = pwg_db_real_escape_string($_POST['copyrightID-'.$image_id]); 77 78 array_push( 79 $edits, 80 array( 81 'media_id' => $image_id, 82 'cr_id' => $crID, 83 ) 84 ); 85 } 86 mass_inserts( 87 COPYRIGHTS_MEDIA, // Table name 88 array_keys($edits[0]), // Columns 89 $edits // Data 90 ); 61 // The image id's: 62 $collection = explode(',', $_POST['element_ids']); 63 64 // Delete all existing id's of which the Copyright is going to be set 65 if (count($collection) > 0) { 66 $query = sprintf( 67 'DELETE 68 FROM %s 69 WHERE media_id IN (%s) 70 ;', 71 COPYRIGHTS_MEDIA, implode(',', $collection)); 72 pwg_query($query); 73 } 74 // Add all Copyrights to an array 75 $edits = array(); 76 foreach ($collection as $image_id) { 77 // The copyright id's 78 $crID = pwg_db_real_escape_string($_POST['copyrightID-'.$image_id]); 79 80 array_push( 81 $edits, 82 array( 83 'media_id' => $image_id, 84 'cr_id' => $crID, 85 ) 86 ); 87 } 88 // Add the array to the database 89 mass_inserts( 90 COPYRIGHTS_MEDIA, // Table name 91 array_keys($edits[0]), // Columns 92 $edits // Data 93 ); 91 94 } 92 95
Note: See TracChangeset
for help on using the changeset viewer.