-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathhelper.php
65 lines (57 loc) · 1.64 KB
/
helper.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
<?php
/**
*
* @package phpBB.de External Images as link
* @copyright (c) 2016 phpBB.de
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
namespace phpbbde\externalimgaslink;
class helper
{
/* @var \phpbb\language\language */
protected $language;
/**
* Constructor
*
* @param \phpbb\language\language $language
*/
public function __construct(\phpbb\language\language $language)
{
$this->language = $language;
}
/**
* Inserts an array into an array at a specified offset and keeps the keys.
* (array_splice wouldn't allow keeping the keys)
* See: http://php.net/manual/en/function.array-splice.php#56794
*
* @param array $input The input array.
* @param string $search_key Specifies the key after which the array should be inserted at.
* @param array $insert_array The array which should be inserted.
* @return array
* @access public
*/
public static function array_insert($input, $search_key, $insertion)
{
$offset = array_search($search_key, array_keys($input)) + 1;
$first_array = array_splice($input, 0, $offset);
return array_merge($first_array, $insertion, $input);
}
/**
* Select image filter type
*/
public function extimgaslink_config_select($selected_type)
{
$types = array(
constants::SERVER_ONLY => 'SERVER_ONLY',
constants::SECURE_SITES => 'SECURE_SITES',
);
$options = '';
foreach ($types as $key => $value)
{
$selected = ($selected_type === $key) ? ' selected="selected"' : '';
$options .= '<option value="' . $key . '"' . $selected . '>' . $this->language->lang('EXTIMGASLINK_' . $value) . '</option>';
}
return $options;
}
}