1 | <?php |
---|
2 | /* |
---|
3 | Plugin Name: PWG Stuffs |
---|
4 | Version: auto |
---|
5 | Description: Insert modules on your gallery |
---|
6 | Plugin URI: http://piwigo.org/ext/extension_view.php?eid=190 |
---|
7 | Author: P@t |
---|
8 | Author URI: http://www.gauchon.com |
---|
9 | */ |
---|
10 | |
---|
11 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
12 | |
---|
13 | global $prefixeTable, $conf; |
---|
14 | |
---|
15 | $conf['Stuffs'] = @unserialize($conf['PWG_Stuffs']); |
---|
16 | |
---|
17 | define('STUFFS_DIR' , basename(dirname(__FILE__))); |
---|
18 | define('STUFFS_PATH' , PHPWG_PLUGINS_PATH . STUFFS_DIR . '/'); |
---|
19 | define('STUFFS_TABLE' , $prefixeTable . 'stuffs'); |
---|
20 | |
---|
21 | // Need upgrade? |
---|
22 | if ($conf['Stuffs'] === false) |
---|
23 | include('admin/upgrade.inc.php'); |
---|
24 | |
---|
25 | function stuffs_admin_menu($menu) |
---|
26 | { |
---|
27 | global $conf; |
---|
28 | |
---|
29 | if (isset($conf['Stuffs']['piclens_upgrade'])) |
---|
30 | include('admin/upgrade.inc.php'); |
---|
31 | |
---|
32 | array_push($menu, array( |
---|
33 | 'NAME' => 'PWG Stuffs', |
---|
34 | 'URL' => get_admin_plugin_menu_link(STUFFS_PATH . 'admin/admin.php') |
---|
35 | ) |
---|
36 | ); |
---|
37 | return $menu; |
---|
38 | } |
---|
39 | |
---|
40 | function load_stuffs() |
---|
41 | { |
---|
42 | global $template; |
---|
43 | |
---|
44 | include(STUFFS_PATH . 'class.inc.php'); |
---|
45 | include(STUFFS_PATH . 'functions.inc.php'); |
---|
46 | |
---|
47 | $template->set_template_dir(STUFFS_PATH.'theme/template/'); |
---|
48 | $template->set_filename('stuffs', 'stuffs_blocks.tpl'); |
---|
49 | |
---|
50 | $stuffs = new stuffs(); |
---|
51 | |
---|
52 | if (!empty($stuffs->blocks['begin'])) |
---|
53 | { |
---|
54 | $template->assign('blocks', $stuffs->blocks['begin']); |
---|
55 | $template->concat($stuffs->prefixe.'BEFORE', $template->parse('stuffs', true)); |
---|
56 | } |
---|
57 | if (!empty($stuffs->blocks['end'])) |
---|
58 | { |
---|
59 | $template->assign('blocks', $stuffs->blocks['end']); |
---|
60 | $template->concat($stuffs->prefixe.'AFTER', $template->parse('stuffs', true)); |
---|
61 | } |
---|
62 | } |
---|
63 | |
---|
64 | function stuffs_section_init() |
---|
65 | { |
---|
66 | global $tokens, $page; |
---|
67 | |
---|
68 | switch (script_basename()) |
---|
69 | { |
---|
70 | case 'picture': |
---|
71 | $page['stuffs_section'] = 'on_picture'; |
---|
72 | break; |
---|
73 | |
---|
74 | case 'index': |
---|
75 | if (count($tokens) == 1 and empty($tokens[0])) |
---|
76 | { |
---|
77 | $page['stuffs_section'] = 'on_home'; |
---|
78 | break; |
---|
79 | } |
---|
80 | elseif (isset($page['section']) and $page['section'] == 'categories') |
---|
81 | { |
---|
82 | $page['stuffs_section'] = isset($page['category']) ? 'on_cats' : 'on_root'; |
---|
83 | break; |
---|
84 | } |
---|
85 | |
---|
86 | default: return; |
---|
87 | } |
---|
88 | |
---|
89 | add_event_handler('loc_begin_page_header', 'load_stuffs'); |
---|
90 | } |
---|
91 | |
---|
92 | add_event_handler('get_admin_plugin_menu_links', 'stuffs_admin_menu'); |
---|
93 | add_event_handler('loc_end_section_init', 'stuffs_section_init', 60); |
---|
94 | |
---|
95 | ?> |
---|