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 | if (mobile_theme()) |
---|
14 | { |
---|
15 | return; |
---|
16 | } |
---|
17 | |
---|
18 | global $prefixeTable, $conf; |
---|
19 | |
---|
20 | $conf['Stuffs'] = @unserialize($conf['PWG_Stuffs']); |
---|
21 | |
---|
22 | define('STUFFS_DIR' , basename(dirname(__FILE__))); |
---|
23 | define('STUFFS_PATH' , PHPWG_PLUGINS_PATH . STUFFS_DIR . '/'); |
---|
24 | define('STUFFS_TABLE' , $prefixeTable . 'stuffs'); |
---|
25 | |
---|
26 | // Need upgrade? |
---|
27 | if ($conf['Stuffs'] === false) |
---|
28 | include('admin/upgrade.inc.php'); |
---|
29 | |
---|
30 | function stuffs_admin_menu($menu) |
---|
31 | { |
---|
32 | global $conf; |
---|
33 | |
---|
34 | array_push($menu, array( |
---|
35 | 'NAME' => 'PWG Stuffs', |
---|
36 | 'URL' => get_root_url().'admin.php?page=plugin-'.STUFFS_DIR |
---|
37 | ) |
---|
38 | ); |
---|
39 | return $menu; |
---|
40 | } |
---|
41 | |
---|
42 | function load_stuffs() |
---|
43 | { |
---|
44 | global $template, $conf; |
---|
45 | |
---|
46 | include(STUFFS_PATH . 'class.inc.php'); |
---|
47 | include(STUFFS_PATH . 'functions.inc.php'); |
---|
48 | |
---|
49 | $template->set_template_dir(STUFFS_PATH.'theme/template/'); |
---|
50 | $template->set_filename('stuffs', 'stuffs_blocks.tpl'); |
---|
51 | $template->assign('SHOW_THUMBNAIL_CAPTION', $conf['show_thumbnail_caption']); |
---|
52 | |
---|
53 | $stuffs = new stuffs(); |
---|
54 | |
---|
55 | if (!empty($stuffs->blocks['begin'])) |
---|
56 | { |
---|
57 | $template->assign('blocks', $stuffs->blocks['begin']); |
---|
58 | $template->concat($stuffs->prefixe.'BEFORE', $template->parse('stuffs', true)); |
---|
59 | } |
---|
60 | if (!empty($stuffs->blocks['end'])) |
---|
61 | { |
---|
62 | $template->assign('blocks', $stuffs->blocks['end']); |
---|
63 | $template->concat($stuffs->prefixe.'AFTER', $template->parse('stuffs', true)); |
---|
64 | } |
---|
65 | } |
---|
66 | |
---|
67 | function stuffs_section_init() |
---|
68 | { |
---|
69 | global $tokens, $page; |
---|
70 | |
---|
71 | switch (script_basename()) |
---|
72 | { |
---|
73 | case 'picture': |
---|
74 | $page['stuffs_section'] = 'on_picture'; |
---|
75 | break; |
---|
76 | |
---|
77 | case 'index': |
---|
78 | $actions = array('delete_comment', 'validate_comment', 'edit_comment', ''); |
---|
79 | if (count($tokens) == 1 and in_array($tokens[0], $actions)) |
---|
80 | { |
---|
81 | $page['stuffs_section'] = 'on_home'; |
---|
82 | break; |
---|
83 | } |
---|
84 | elseif (isset($page['section']) and $page['section'] == 'categories') |
---|
85 | { |
---|
86 | $page['stuffs_section'] = isset($page['category']) ? 'on_cats' : 'on_root'; |
---|
87 | break; |
---|
88 | } |
---|
89 | |
---|
90 | default: return; |
---|
91 | } |
---|
92 | |
---|
93 | add_event_handler('loc_begin_index', 'load_stuffs'); |
---|
94 | add_event_handler('loc_begin_picture', 'load_stuffs'); |
---|
95 | } |
---|
96 | |
---|
97 | add_event_handler('get_admin_plugin_menu_links', 'stuffs_admin_menu'); |
---|
98 | add_event_handler('loc_end_section_init', 'stuffs_section_init', 60); |
---|
99 | |
---|
100 | ?> |
---|