1 | <?php |
---|
2 | /* |
---|
3 | Plugin Name: Comments on Albums |
---|
4 | Version: auto |
---|
5 | Description: Activate comments on albums pages |
---|
6 | Plugin URI: http://piwigo.org/ext/extension_view.php?eid=512 |
---|
7 | Author: Mistic |
---|
8 | Author URI: http://www.strangeplanet.fr |
---|
9 | */ |
---|
10 | |
---|
11 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
12 | |
---|
13 | global $prefixeTable; |
---|
14 | |
---|
15 | // +-----------------------------------------------------------------------+ |
---|
16 | // Global variables |
---|
17 | // +-----------------------------------------------------------------------+ |
---|
18 | defined('COA_ID') or define('COA_ID', basename(dirname(__FILE__))); |
---|
19 | define('COA_PATH' , PHPWG_PLUGINS_PATH . COA_ID . '/'); |
---|
20 | define('COA_TABLE' , $prefixeTable . 'comments_categories'); |
---|
21 | define('COA_ADMIN', get_root_url().'admin.php?page=plugin-' . COA_ID); |
---|
22 | define('COA_VERSION', 'auto'); |
---|
23 | |
---|
24 | |
---|
25 | // +-----------------------------------------------------------------------+ |
---|
26 | // Triggers |
---|
27 | // +-----------------------------------------------------------------------+ |
---|
28 | add_event_handler('init', 'coa_init'); |
---|
29 | function coa_init() |
---|
30 | { |
---|
31 | global $user, $conf, $pwg_loaded_plugins; |
---|
32 | |
---|
33 | // luciano doesn't use comments |
---|
34 | // incompatible with dynamic display of Stripped & Collumns |
---|
35 | if ($user['theme'] == 'luciano' or $user['theme'] == 'stripped_black_bloc') return; |
---|
36 | |
---|
37 | // apply upgrade if needed |
---|
38 | if ( |
---|
39 | COA_VERSION == 'auto' or |
---|
40 | $pwg_loaded_plugins[COA_ID]['version'] == 'auto' or |
---|
41 | version_compare($pwg_loaded_plugins[COA_ID]['version'], COA_VERSION, '<') |
---|
42 | ) |
---|
43 | { |
---|
44 | // call install function |
---|
45 | include_once(COA_PATH . 'include/install.inc.php'); |
---|
46 | coa_install(); |
---|
47 | |
---|
48 | // update plugin version in database |
---|
49 | if ( $pwg_loaded_plugins[COA_ID]['version'] != 'auto' and COA_VERSION != 'auto' ) |
---|
50 | { |
---|
51 | $query = ' |
---|
52 | UPDATE '. PLUGINS_TABLE .' |
---|
53 | SET version = "'. COA_VERSION .'" |
---|
54 | WHERE id = "'. COA_ID .'"'; |
---|
55 | pwg_query($query); |
---|
56 | |
---|
57 | $pwg_loaded_plugins[COA_ID]['version'] = COA_VERSION; |
---|
58 | |
---|
59 | if (defined('IN_ADMIN')) |
---|
60 | { |
---|
61 | $_SESSION['page_infos'][] = 'Comments on Albums updated to version '. COA_VERSION; |
---|
62 | } |
---|
63 | } |
---|
64 | } |
---|
65 | |
---|
66 | // add events handlers |
---|
67 | if (defined('IN_ADMIN')) |
---|
68 | { |
---|
69 | add_event_handler('loc_begin_admin_page', 'coa_admin_intro'); |
---|
70 | add_event_handler('loc_end_admin', 'coa_admin_comments'); |
---|
71 | } |
---|
72 | else |
---|
73 | { |
---|
74 | add_event_handler('loc_after_page_header', 'coa_albums'); |
---|
75 | add_event_handler('loc_after_page_header', 'coa_comments_page'); |
---|
76 | } |
---|
77 | add_event_handler('get_stuffs_modules', 'coa_register_stuffs_module'); |
---|
78 | } |
---|
79 | |
---|
80 | |
---|
81 | // +-----------------------------------------------------------------------+ |
---|
82 | // Functions |
---|
83 | // +-----------------------------------------------------------------------+ |
---|
84 | |
---|
85 | function coa_albums() |
---|
86 | { |
---|
87 | global $template, $page, $conf, $pwg_loaded_plugins; |
---|
88 | |
---|
89 | if ( !empty($page['section']) AND $page['section'] == 'categories' AND isset($page['category']) AND $page['body_id'] == 'theCategoryPage' ) |
---|
90 | { |
---|
91 | trigger_action('loc_begin_coa'); |
---|
92 | include(COA_PATH . 'include/coa_albums.php'); |
---|
93 | } |
---|
94 | } |
---|
95 | |
---|
96 | function coa_comments_page() |
---|
97 | { |
---|
98 | global $template, $page, $conf, $user; |
---|
99 | |
---|
100 | if (isset($page['body_id']) AND $page['body_id'] == 'theCommentsPage') |
---|
101 | { |
---|
102 | include(COA_PATH . 'include/coa_comments_page.php'); |
---|
103 | } |
---|
104 | } |
---|
105 | |
---|
106 | function coa_admin_intro() |
---|
107 | { |
---|
108 | global $page; |
---|
109 | |
---|
110 | if ($page['page'] == 'intro') |
---|
111 | { |
---|
112 | include(COA_PATH . 'include/coa_admin_intro.php'); |
---|
113 | } |
---|
114 | } |
---|
115 | |
---|
116 | function coa_admin_comments() |
---|
117 | { |
---|
118 | global $page; |
---|
119 | |
---|
120 | if ($page['page'] == 'comments') |
---|
121 | { |
---|
122 | include(COA_PATH . 'include/coa_admin_comments.php'); |
---|
123 | } |
---|
124 | } |
---|
125 | |
---|
126 | function coa_register_stuffs_module($modules) |
---|
127 | { |
---|
128 | load_language('plugin.lang', COA_PATH); |
---|
129 | |
---|
130 | array_push($modules, array( |
---|
131 | 'path' => COA_PATH . '/stuffs_module', |
---|
132 | 'name' => l10n('Last comments on albums'), |
---|
133 | 'description' => l10n('Display last posted comments on albums'), |
---|
134 | )); |
---|
135 | |
---|
136 | return $modules; |
---|
137 | } |
---|
138 | |
---|
139 | ?> |
---|