|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* @file |
|
4
|
|
|
* Administration-related forms and such. |
|
5
|
|
|
*/ |
|
6
|
|
|
use OPCache\OPCache; |
|
7
|
|
|
|
|
8
|
|
|
/** |
|
9
|
|
|
* Form callback for OPcache's administration form. |
|
10
|
|
|
*/ |
|
11
|
|
|
function opcache_admin_form($form, &$form_state) { |
|
|
|
|
|
|
12
|
|
|
drupal_set_title(t('OPcache')); |
|
13
|
|
|
$backends = variable_get('opcache_backends', NULL); |
|
14
|
|
|
$form['opcache_backends'] = array( |
|
15
|
|
|
'#type' => 'textarea', |
|
16
|
|
|
'#title' => t('PHP proxy back-ends'), |
|
17
|
|
|
'#default_value' => empty($backends) ? '' : implode("\n", $backends), |
|
18
|
|
|
'#description' => t('If you run PHP behind one or more proxy back-ends, enter the full URLs to the PHP servers here, one per line. Include the protocol, and if clean URLs are not enabled, append “index.php?q=” to the end. For example, “http://127.0.0.1:8080/” or “https://192.168.0.12/drupal/index.php?q=”. If you are not running PHP behind a proxy back-end, leave this field blank.'), |
|
19
|
|
|
'#weight' => 0, |
|
20
|
|
|
); |
|
21
|
|
|
$form['submit'] = array( |
|
22
|
|
|
'#type' => 'submit', |
|
23
|
|
|
'#value' => t('Save configuration'), |
|
24
|
|
|
'#weight' => 990, |
|
25
|
|
|
); |
|
26
|
|
|
return $form; |
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* Submit handler for our configuration form. |
|
31
|
|
|
*/ |
|
32
|
|
|
function opcache_admin_form_submit($form, $form_state) { |
|
|
|
|
|
|
33
|
|
|
$trimmed = trim($form_state['values']['opcache_backends']); |
|
34
|
|
|
if (!empty($trimmed)) { |
|
35
|
|
|
$backends = preg_split("/\r\n|\n|\r/", $form_state['values']['opcache_backends']); |
|
36
|
|
|
} |
|
37
|
|
|
else { |
|
38
|
|
|
$backends = NULL; |
|
39
|
|
|
} |
|
40
|
|
|
variable_set('opcache_backends', $backends); |
|
41
|
|
|
drupal_set_message(t('The configuration options have been saved.')); |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* Page callback for OPCache status. |
|
46
|
|
|
*/ |
|
47
|
|
|
function opcache_admin_status() { |
|
48
|
|
|
$opcache = new OPCache(); |
|
49
|
|
|
$status = $opcache->status(); |
|
50
|
|
|
$render = array( |
|
51
|
|
|
'opcache-status' => array( |
|
52
|
|
|
'#theme' => 'table', |
|
53
|
|
|
'#rows' => $status, |
|
54
|
|
|
), |
|
55
|
|
|
); |
|
56
|
|
|
return drupal_render($render); |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* Page callback for OPCache configuration. |
|
61
|
|
|
*/ |
|
62
|
|
|
|
|
63
|
|
|
function opcache_admin_config() { |
|
64
|
|
|
$opcache = new OPCache(); |
|
65
|
|
|
$config = $opcache->config(); |
|
66
|
|
|
$render = array( |
|
67
|
|
|
'opcache-config' => array( |
|
68
|
|
|
'#theme' => 'table', |
|
69
|
|
|
'#rows' => $config, |
|
70
|
|
|
), |
|
71
|
|
|
); |
|
72
|
|
|
return drupal_render($render); |
|
73
|
|
|
} |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.