-
Notifications
You must be signed in to change notification settings - Fork 28
/
ext.php
72 lines (63 loc) · 1.84 KB
/
ext.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<?php
/**
*
* Advanced BBCode Box
*
* @copyright (c) 2015 Matt Friedman
* @license GNU General Public License, version 2 (GPL-2.0)
*
*/
namespace vse\abbc3;
use phpbb\filesystem\exception\filesystem_exception;
class ext extends \phpbb\extension\base
{
const MOVE_UP = 'move_up';
const MOVE_DOWN = 'move_down';
const MOVE_DRAG = 'move_drag';
const PHPBB_MIN_VERSION = '3.2.2'; // Require 3.2.2 due to TextFormatter and BBCode changes
const PHPBB_LEGACY_MAX = '3.3.10'; // Max version of phpBB to use legacy settings
const ABBC3_BBCODE_FONTS = ['ABBC3_FONT_SAFE' => ['Arial', 'Arial Black', 'Comic Sans MS', 'Courier New', 'Georgia', 'Impact', 'Tahoma', 'Times New Roman', 'Trebuchet MS', 'Verdana']];
/**
* {@inheritdoc}
*/
public function is_enableable()
{
$config = $this->container->get('config');
return $this->version_check($config['version']) && $this->version_check(PHPBB_VERSION);
}
/**
* {@inheritdoc}
*/
public function enable_step($old_state)
{
if ($old_state === false)
{
$filesystem = $this->container->get('filesystem');
$root_path = $this->container->getParameter('core.root_path');
try // Make an ABBC3 icon dir in phpBB's images dir
{
if (!$filesystem->exists($root_path . 'images/abbc3/icons'))
{
$filesystem->mkdir($root_path . 'images/abbc3/icons');
}
}
catch (filesystem_exception $e)
{
$user = $this->container->get('user');
$this->container->get('log')->add('critical', $user->data['user_id'], $user->ip, 'LOG_ABBC3_ENABLE_FAIL', false, [$e->get_filename()]);
}
return 'abbc3-step';
}
return parent::enable_step($old_state);
}
/**
* Enable version check
*
* @param string|int $version The version to check
* @return bool
*/
protected function version_check($version)
{
return phpbb_version_compare($version, self::PHPBB_MIN_VERSION, '>=');
}
}