1 | <?php |
---|
2 | |
---|
3 | // Add a prefilter |
---|
4 | add_event_handler('loc_end_element_set_unit', 'set_prefilter_batch_single', 55 ); |
---|
5 | add_event_handler('loc_end_element_set_unit', 'CR_batch_single_submit', 55 ); |
---|
6 | |
---|
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'); |
---|
9 | |
---|
10 | function set_prefilter_batch_single() |
---|
11 | { |
---|
12 | global $template; |
---|
13 | $template->set_prefilter('batch_manager_unit', 'CR_batch_single'); |
---|
14 | } |
---|
15 | |
---|
16 | function CR_batch_single($content, &$smarty) |
---|
17 | { |
---|
18 | $search = "#<td><strong>{'Creation date'#"; // Not ideal, but ok for now :) |
---|
19 | |
---|
20 | // We use the <tr> from the Creation date, and give them a new <tr> |
---|
21 | $replacement = '<td><strong>DWO TESTJE</strong></td> |
---|
22 | <td> |
---|
23 | DWO TESTJE |
---|
24 | </td> |
---|
25 | </tr> |
---|
26 | |
---|
27 | <tr> |
---|
28 | <td><strong>{\'Creation date\''; |
---|
29 | |
---|
30 | return preg_replace($search, $replacement, $content); |
---|
31 | |
---|
32 | // Dit is een interresant testje - deze functie word dus een aantal keren (3) aangeroepen, |
---|
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>'; |
---|
35 | } |
---|
36 | |
---|
37 | function CR_add_bsm_vars_to_template() |
---|
38 | { |
---|
39 | //global $page, $template, $prefixeTable; |
---|
40 | |
---|
41 | // Show block only on the photo page |
---|
42 | //if ( !empty($page['image_id']) ) |
---|
43 | //{ |
---|
44 | // Sending data to the template |
---|
45 | //$template->assign( |
---|
46 | //array ( |
---|
47 | //'CR_TEST' => 'TEST' |
---|
48 | // )); |
---|
49 | //} |
---|
50 | } |
---|
51 | |
---|
52 | function CR_batch_single_submit() |
---|
53 | { |
---|
54 | // The image id's: |
---|
55 | $collection = explode(',', $_POST['element_ids']); |
---|
56 | |
---|
57 | // Delete all existing id's of which the Copyright is going to be set |
---|
58 | if (count($collection) > 0) { |
---|
59 | $query = sprintf( |
---|
60 | 'DELETE |
---|
61 | FROM %s |
---|
62 | WHERE media_id IN (%s) |
---|
63 | ;', |
---|
64 | COPYRIGHTS_MEDIA, implode(',', $collection)); |
---|
65 | pwg_query($query); |
---|
66 | } |
---|
67 | $edits = array(); |
---|
68 | foreach ($collection as $image_id) |
---|
69 | { |
---|
70 | // The copyright id's |
---|
71 | $crID = pwg_db_real_escape_string($_POST['copyrightID-'.$image_id]); |
---|
72 | |
---|
73 | array_push( |
---|
74 | $edits, |
---|
75 | array( |
---|
76 | 'media_id' => $image_id, |
---|
77 | 'cr_id' => $crID, |
---|
78 | ) |
---|
79 | ); |
---|
80 | } |
---|
81 | mass_inserts( |
---|
82 | COPYRIGHTS_MEDIA, // Table name |
---|
83 | array_keys($edits[0]), // Columns |
---|
84 | $edits // Data |
---|
85 | ); |
---|
86 | } |
---|
87 | |
---|
88 | ?> |
---|