1 | <?php |
---|
2 | defined('MPS_PATH') or die('Hacking attempt!'); |
---|
3 | |
---|
4 | /** |
---|
5 | * admin plugins menu link |
---|
6 | */ |
---|
7 | function mps_admin_plugin_menu_links($menu) |
---|
8 | { |
---|
9 | $menu[] = array( |
---|
10 | 'NAME' => l10n('MyPiwiShop'), |
---|
11 | 'URL' => MPS_ADMIN, |
---|
12 | ); |
---|
13 | |
---|
14 | return $menu; |
---|
15 | } |
---|
16 | |
---|
17 | |
---|
18 | /** |
---|
19 | * add an action to the Batch Manager unit |
---|
20 | */ |
---|
21 | |
---|
22 | function mps_loc_end_element_set_unit() |
---|
23 | { |
---|
24 | include_once(MPS_PATH.'admin/MyPiwiShopBatchUnit.php'); |
---|
25 | |
---|
26 | global $template; |
---|
27 | $template->set_filename('mps_batch_unit', realpath(MPS_PATH.'admin/template/MyPiwiShopBatchUnit.tpl')); |
---|
28 | $template->assign_var_from_handle('MPS_BATCH_UNIT', 'mps_batch_unit'); |
---|
29 | |
---|
30 | $template->set_prefilter('batch_manager_unit', 'batch_unit_form'); |
---|
31 | } |
---|
32 | |
---|
33 | function batch_unit_form($content) |
---|
34 | { |
---|
35 | |
---|
36 | $search = '#</table>(\s*)</fieldset>#s'; |
---|
37 | $replace ='</table>$1<div class="MyPiwiShopBatchUnit" style="text-align:left">{combine_script id="batchmanagerunit" load="footer" path="'.MPS_PATH.'/admin/template/js/batchmanagerunit.js"} |
---|
38 | {include file="'.realpath(MPS_PATH).'/admin/template/MyPiwiShopBatchUnit.tpl" imgid=$element.id}</div>$1</fieldset>'; |
---|
39 | |
---|
40 | return preg_replace($search, $replace, $content); |
---|
41 | } |
---|
42 | |
---|
43 | /** |
---|
44 | * add an action to the Batch Manager |
---|
45 | */ |
---|
46 | |
---|
47 | function mps_loc_end_element_set_global() |
---|
48 | { |
---|
49 | include_once(MPS_PATH.'admin/MyPiwiShopBatch.php'); |
---|
50 | |
---|
51 | global $template; |
---|
52 | |
---|
53 | $template->set_filename('mps_batch_global', (MPS_PATH.'admin/template/MyPiwiShopBatch.tpl')); |
---|
54 | |
---|
55 | $template->append('element_set_global_plugins_actions', array( |
---|
56 | 'ID' => 'mps', |
---|
57 | 'NAME' => l10n('MyPiwiShop'), |
---|
58 | 'CONTENT' => $template->parse('mps_batch_global', true) |
---|
59 | )); |
---|
60 | } |
---|
61 | |
---|
62 | /** |
---|
63 | * perform added action |
---|
64 | */ |
---|
65 | function mps_element_set_global_action($action, $collection) |
---|
66 | { |
---|
67 | if ($action == 'mps') |
---|
68 | { |
---|
69 | global $page; |
---|
70 | |
---|
71 | if (empty($_POST['productcheck'])) |
---|
72 | { |
---|
73 | $page['errors'][] = l10n('Select at least one product'); |
---|
74 | } |
---|
75 | else if ($_POST['thisprod']=='del') |
---|
76 | { |
---|
77 | $product_id = $_POST['productcheck']; |
---|
78 | deletAll_product_image($product_id, $collection); |
---|
79 | $page['infos'][] = l10n('Products have been removed for these pictures'); |
---|
80 | } |
---|
81 | else |
---|
82 | { |
---|
83 | $product_id = $_POST['productcheck']; |
---|
84 | add_product_image($product_id, $collection); |
---|
85 | $page['infos'][] = l10n('products have been added to these images'); |
---|
86 | } |
---|
87 | } |
---|
88 | |
---|
89 | } |
---|
90 | |
---|