1 | <?php |
---|
2 | /* |
---|
3 | Plugin Name: MyPiwiShop |
---|
4 | Version: auto |
---|
5 | Description: a litle shop for your piwigo. |
---|
6 | Plugin URI: auto |
---|
7 | Author: Miklfe |
---|
8 | Author URI: http://piwitheme.fr |
---|
9 | */ |
---|
10 | |
---|
11 | |
---|
12 | |
---|
13 | defined('PHPWG_ROOT_PATH') or die('Hacking attempt!'); |
---|
14 | |
---|
15 | global $prefixeTable; |
---|
16 | |
---|
17 | |
---|
18 | // +-----------------------------------------------------------------------+ |
---|
19 | // | Define plugin constants | |
---|
20 | // +-----------------------------------------------------------------------+ |
---|
21 | define('MPS_ID', basename(dirname(__FILE__))); |
---|
22 | define('MPS_PATH' , PHPWG_PLUGINS_PATH . MPS_ID . '/'); |
---|
23 | define('MPS_PRODUCT_TABLE', $prefixeTable . 'mps_product'); |
---|
24 | define('MPS_PROD_IMG_TABLE', $prefixeTable . 'mps_prod_img'); |
---|
25 | define('MPS_PROD_OPT_TABLE', $prefixeTable . 'mps_prod_opt'); |
---|
26 | define('MPS_CONF_TABLE', $prefixeTable . 'mps_conf'); |
---|
27 | define('MPS_OPTION_TABLE', $prefixeTable . 'mps_option'); |
---|
28 | define('MPS_OPT_VAL_TABLE', $prefixeTable . 'mps_opt_val'); |
---|
29 | define('MPS_ADMIN', get_root_url() . 'admin.php?page=plugin-' . MPS_ID); |
---|
30 | define('MPS_PUBLIC', get_absolute_root_url() . make_index_url(array('section' => 'MyPiwiShop')) . '/'); |
---|
31 | define('MPS_DIR', PHPWG_ROOT_PATH . PWG_LOCAL_DIR . 'MyPiwiShop/'); |
---|
32 | define('MPS_VERSION', 'auto'); |
---|
33 | |
---|
34 | // init the plugin |
---|
35 | add_event_handler('init', 'mps_init'); |
---|
36 | |
---|
37 | if (defined('IN_ADMIN')) { |
---|
38 | include_once(MPS_PATH . 'include/admin_events.inc.php'); |
---|
39 | |
---|
40 | // admin plugins menu link |
---|
41 | add_event_handler('get_admin_plugin_menu_links', 'mps_admin_plugin_menu_links'); |
---|
42 | |
---|
43 | |
---|
44 | // new action in Batch Manager |
---|
45 | add_event_handler('loc_end_element_set_global', 'mps_loc_end_element_set_global'); |
---|
46 | add_event_handler('element_set_global_action', 'mps_element_set_global_action', EVENT_HANDLER_PRIORITY_NEUTRAL, 2); |
---|
47 | add_event_handler('loc_end_element_set_unit', 'mps_loc_end_element_set_unit'); |
---|
48 | } else { |
---|
49 | // file containing all public handlers functions |
---|
50 | include_once(MPS_PATH . 'include/public_events.inc.php'); |
---|
51 | |
---|
52 | // add button on album and photos pages |
---|
53 | add_event_handler('loc_end_index', 'mps_add_button'); |
---|
54 | add_event_handler('loc_end_picture', 'mps_add_button'); |
---|
55 | |
---|
56 | // form on photo page |
---|
57 | add_event_handler('loc_end_picture', 'mps_prepar_tpl'); |
---|
58 | add_event_handler('loc_end_picture', 'mps_init_form_picture'); |
---|
59 | } |
---|
60 | |
---|
61 | // files containing specific plugin functions |
---|
62 | include_once(MPS_PATH . 'include/functions.inc.php'); |
---|
63 | |
---|
64 | function mps_init() { |
---|
65 | global $prefixeTable; |
---|
66 | |
---|
67 | // apply upgrade if needed |
---|
68 | include_once(MPS_PATH . 'maintain.inc.php'); |
---|
69 | $maintain = new MyPiwiShop_maintain(MPS_ID); |
---|
70 | $maintain->autoUpdate(MPS_VERSION, 'install'); |
---|
71 | |
---|
72 | load_language('plugin.lang', MPS_PATH); |
---|
73 | |
---|
74 | $query=' |
---|
75 | SELECT * |
---|
76 | FROM '.MPS_CONF_TABLE.' |
---|
77 | ;'; |
---|
78 | |
---|
79 | if(pwg_db_num_rows(pwg_query($query))==0) { |
---|
80 | single_insert( |
---|
81 | $prefixeTable."mps_conf", |
---|
82 | array( |
---|
83 | 'currency' => 'EUR', |
---|
84 | ) |
---|
85 | ); |
---|
86 | } |
---|
87 | |
---|
88 | } |
---|
89 | |
---|
90 | |
---|
91 | |
---|
92 | |
---|
93 | |
---|
94 | |
---|
95 | |
---|
96 | |
---|
97 | |
---|
98 | |
---|
99 | |
---|
100 | |
---|
101 | |
---|
102 | |
---|
103 | |
---|
104 | |
---|