Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
84.62% |
11 / 13 |
|
75.00% |
6 / 8 |
CRAP | |
0.00% |
0 / 1 |
| driver | |
84.62% |
11 / 13 |
|
75.00% |
6 / 8 |
9.29 | |
0.00% |
0 / 1 |
| __construct | |
100.00% |
6 / 6 |
|
100.00% |
1 / 1 |
1 | |||
| get_custom_html | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| prepare_form_acp | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| delete | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| get_name | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| get_config_name | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
2 | |||
| get_acp_template_name | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| set_name | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * |
| 4 | * This file is part of the phpBB Forum Software package. |
| 5 | * |
| 6 | * @copyright (c) phpBB Limited <https://www.phpbb.com> |
| 7 | * @license GNU General Public License, version 2 (GPL-2.0) |
| 8 | * |
| 9 | * For full copyright and license information, please see |
| 10 | * the docs/CREDITS.txt file. |
| 11 | * |
| 12 | */ |
| 13 | |
| 14 | namespace phpbb\avatar\driver; |
| 15 | |
| 16 | /** |
| 17 | * Base class for avatar drivers |
| 18 | */ |
| 19 | abstract class driver implements \phpbb\avatar\driver\driver_interface |
| 20 | { |
| 21 | /** |
| 22 | * Avatar driver name |
| 23 | * @var string |
| 24 | */ |
| 25 | protected $name; |
| 26 | |
| 27 | /** |
| 28 | * Current board configuration |
| 29 | * @var \phpbb\config\config |
| 30 | */ |
| 31 | protected $config; |
| 32 | |
| 33 | /** @var \FastImageSize\FastImageSize */ |
| 34 | protected $imagesize; |
| 35 | |
| 36 | /** |
| 37 | * Current $phpbb_root_path |
| 38 | * @var string |
| 39 | */ |
| 40 | protected $phpbb_root_path; |
| 41 | |
| 42 | /** |
| 43 | * Current $php_ext |
| 44 | * @var string |
| 45 | */ |
| 46 | protected $php_ext; |
| 47 | |
| 48 | /** |
| 49 | * Path Helper |
| 50 | * @var \phpbb\path_helper |
| 51 | */ |
| 52 | protected $path_helper; |
| 53 | |
| 54 | /** |
| 55 | * Cache driver |
| 56 | * @var \phpbb\cache\driver\driver_interface |
| 57 | */ |
| 58 | protected $cache; |
| 59 | |
| 60 | /** |
| 61 | * Array of allowed avatar image extensions |
| 62 | * Array is used for setting the allowed extensions in the fileupload class |
| 63 | * and as a base for a regex of allowed extensions, which will be formed by |
| 64 | * imploding the array with a "|". |
| 65 | * |
| 66 | * @var array |
| 67 | */ |
| 68 | protected $allowed_extensions = array( |
| 69 | 'gif', |
| 70 | 'jpg', |
| 71 | 'jpeg', |
| 72 | 'png', |
| 73 | ); |
| 74 | |
| 75 | /** |
| 76 | * Construct a driver object |
| 77 | * |
| 78 | * @param \phpbb\config\config $config phpBB configuration |
| 79 | * @param \FastImageSize\FastImageSize $imagesize FastImageSize class |
| 80 | * @param string $phpbb_root_path Path to the phpBB root |
| 81 | * @param string $php_ext PHP file extension |
| 82 | * @param \phpbb\path_helper $path_helper phpBB path helper |
| 83 | * @param \phpbb\cache\driver\driver_interface|null $cache Cache driver |
| 84 | */ |
| 85 | public function __construct(\phpbb\config\config $config, \FastImageSize\FastImageSize $imagesize, $phpbb_root_path, $php_ext, \phpbb\path_helper $path_helper, \phpbb\cache\driver\driver_interface|null $cache = null) |
| 86 | { |
| 87 | $this->config = $config; |
| 88 | $this->imagesize = $imagesize; |
| 89 | $this->phpbb_root_path = $phpbb_root_path; |
| 90 | $this->php_ext = $php_ext; |
| 91 | $this->path_helper = $path_helper; |
| 92 | $this->cache = $cache; |
| 93 | } |
| 94 | |
| 95 | /** |
| 96 | * {@inheritdoc} |
| 97 | */ |
| 98 | public function get_custom_html($user, $row, $alt = '') |
| 99 | { |
| 100 | return ''; |
| 101 | } |
| 102 | |
| 103 | /** |
| 104 | * {@inheritdoc} |
| 105 | */ |
| 106 | public function prepare_form_acp($user) |
| 107 | { |
| 108 | return array(); |
| 109 | } |
| 110 | |
| 111 | /** |
| 112 | * {@inheritdoc} |
| 113 | */ |
| 114 | public function delete($row) |
| 115 | { |
| 116 | return true; |
| 117 | } |
| 118 | |
| 119 | /** |
| 120 | * {@inheritdoc} |
| 121 | */ |
| 122 | public function get_name() |
| 123 | { |
| 124 | return $this->name; |
| 125 | } |
| 126 | |
| 127 | /** |
| 128 | * {@inheritdoc} |
| 129 | */ |
| 130 | public function get_config_name() |
| 131 | { |
| 132 | return preg_replace('#^phpbb\\\\avatar\\\\driver\\\\#', '', get_class($this)) ?: ''; |
| 133 | } |
| 134 | |
| 135 | /** |
| 136 | * {@inheritdoc} |
| 137 | */ |
| 138 | public function get_acp_template_name() |
| 139 | { |
| 140 | return 'acp_avatar_options_' . $this->get_config_name() . '.html'; |
| 141 | } |
| 142 | |
| 143 | /** |
| 144 | * Sets the name of the driver. |
| 145 | * |
| 146 | * @param string $name Driver name |
| 147 | */ |
| 148 | public function set_name($name) |
| 149 | { |
| 150 | $this->name = $name; |
| 151 | } |
| 152 | } |