source: extensions/bbcode_bar/main.inc.php @ 10011

Last change on this file since 10011 was 10011, checked in by mistic100, 13 years ago

better compatibility test with SmiliesSupport

File size: 1.9 KB
Line 
1<?php 
2/*
3Plugin Name: BBCode Bar
4Version: 2.2.a
5Description: Allow use BBCode for comments and descriptions.
6Plugin URI: http://piwigo.org/ext/extension_view.php?eid=140
7Author: Atadilo & P@t & Mistic
8*/
9
10if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
11
12define('BBcode_DIR' , basename(dirname(__FILE__)));
13define('BBcode_PATH' , PHPWG_PLUGINS_PATH . BBcode_DIR . '/');
14define('BBcode_codes', serialize(array('b','i','u','s','p','center','right','quote','ul','ol','img','url','email','size','color')));
15
16include_once(BBcode_PATH.'bbcode_bar.inc.php');
17add_event_handler('init', 'init_bbcode_bar');
18
19function init_bbcode_bar()
20{
21        remove_event_handler('render_comment_content', 'render_comment_content');
22        add_event_handler('render_comment_content', 'BBCodeParse');
23        add_event_handler('loc_after_page_header', 'add_bbcode_bar');
24}
25
26function add_bbcode_bar() {
27        global $page;
28       
29        if (isset($page['body_id']) AND $page['body_id'] == 'thePicturePage') {
30                set_bbcode_bar();
31        }
32}
33
34if (script_basename() == 'admin')
35{
36        add_event_handler('get_admin_plugin_menu_links', 'bbcode_bar_admin_menu');
37        function bbcode_bar_admin_menu($menu)
38        {
39                array_push($menu, array(
40                        'NAME' => 'BBCode Bar',
41                        'URL' => get_root_url().'admin.php?page=plugin-' . BBcode_DIR
42                ));
43                return $menu;
44        }
45       
46        // version 2.2.a or greater of SmiliesSupport is required
47        add_event_handler('loc_end_admin', 'bbcode_bar_check_smilies');
48        function bbcode_bar_check_smilies() {
49                global $page, $template, $pwg_loaded_plugins;
50               
51                if (
52                        ($_GET['page'] == 'plugins_list' OR $_GET['section'] == 'bbcode_bar/admin.php')
53                        AND isset($pwg_loaded_plugins['SmiliesSupport']) 
54                        AND version_compare($pwg_loaded_plugins['SmiliesSupport']['version'], '2.2.a') == -1
55                ) {
56                        $page['warnings'][] = "BBCode Bar : SmiliesSupport has been detected, but is not up to date. Version 2.2.a or greater is required. Please update.";
57                        $template->assign('warnings', $page['warnings']);
58                }
59        }
60       
61}
62
63?>
Note: See TracBrowser for help on using the repository browser.