source: extensions/Comments_on_Albums/main.inc.php @ 15995

Revision 15995, 3.5 KB checked in by mistic100, 7 years ago (diff)

improve anti-spam system (Piwigo 2.5 feature)

Line 
1<?php
2/*
3Plugin Name: Comments on Albums
4Version: auto
5Description: Activate comments on albums pages
6Plugin URI: http://piwigo.org/ext/extension_view.php?eid=512
7Author: Mistic
8Author URI: http://www.strangeplanet.fr
9*/
10
11if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
12
13global $prefixeTable;
14
15// +-----------------------------------------------------------------------+
16//          Global variables
17// +-----------------------------------------------------------------------+
18define('COA_DIR' , basename(dirname(__FILE__)));
19define('COA_PATH' , PHPWG_PLUGINS_PATH . COA_DIR . '/');
20define('COA_TABLE' , $prefixeTable . 'comments_categories');
21define('COA_ADMIN', get_root_url().'admin.php?page=plugin-' . COA_DIR);
22
23
24// +-----------------------------------------------------------------------+
25//          Triggers
26// +-----------------------------------------------------------------------+
27add_event_handler('init', 'coa_init');
28function coa_init()
29{
30  global $user;
31 
32  // luciano doesn't use comments
33  // incompatible with dynamic display of Stripped & Collumns
34  if ($user['theme'] == 'luciano' or $user['theme'] == 'stripped_black_bloc') return;
35 
36  add_event_handler('loc_begin_page_header', 'COA_albums');
37  add_event_handler('loc_after_page_header', 'COA_comments_page');
38  add_event_handler('loc_begin_admin_page', 'COA_admin_intro');
39  add_event_handler('loc_end_admin', 'COA_admin_comments');
40  add_event_handler('get_stuffs_modules', 'COA_register_stuffs_module');
41}
42
43
44// +-----------------------------------------------------------------------+
45//          Functions
46// +-----------------------------------------------------------------------+
47
48function COA_albums() 
49{
50  global $template, $page, $conf, $pwg_loaded_plugins;
51 
52  if ( !empty($page['section']) AND $page['section'] == 'categories' AND isset($page['category']) AND $page['body_id'] == 'theCategoryPage' )
53  {
54    if (isset($pwg_loaded_plugins['bbcode_bar']) AND !isset($_GET['comment_to_edit'])) 
55    {
56      set_bbcode_bar();
57      $template->set_prefilter('comments_on_albums', 'set_bbcode_bar_prefilter'); 
58      if (isset($pwg_loaded_plugins['SmiliesSupport']))
59      {
60        $template->set_prefilter('comments_on_albums', 'set_smiliessupport_prefilter');
61      }
62    }
63    else if (isset($pwg_loaded_plugins['SmiliesSupport']) AND !isset($_GET['comment_to_edit'])) 
64    {
65      set_smiliessupport();
66      $template->set_prefilter('comments_on_albums', 'set_smiliessupport_prefilter');
67    }
68   
69    trigger_action('loc_begin_coa');
70    include(COA_PATH . 'include/coa_albums.php');
71  }
72}
73
74function COA_comments_page() 
75{
76  global $template, $page, $conf, $user;
77 
78  if (isset($page['body_id']) AND $page['body_id'] == 'theCommentsPage') 
79  {
80    include(COA_PATH . 'include/coa_comments_page.php');
81  }
82}
83
84function COA_admin_intro() 
85{
86  global $page;
87 
88  if ($page['page'] == 'intro') 
89  { 
90    include(COA_PATH . 'include/coa_admin_intro.php');
91  } 
92}
93
94function COA_admin_comments() 
95{
96  global $page;
97 
98  if ($page['page'] == 'comments') 
99  { 
100    include(COA_PATH . 'include/coa_admin_comments.php');
101  }
102}
103
104function COA_register_stuffs_module($modules) 
105{
106  load_language('plugin.lang', COA_PATH);
107 
108  array_push($modules, array(
109    'path' => COA_PATH . '/stuffs_module',
110    'name' => l10n('Last comments on albums'),
111    'description' => l10n('Display last posted comments on albums'),
112  ));
113
114  return $modules;
115}
116
117?>
Note: See TracBrowser for help on using the repository browser.