-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathqa_variables.inc
More file actions
84 lines (74 loc) · 2 KB
/
qa_variables.inc
File metadata and controls
84 lines (74 loc) · 2 KB
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
73
74
75
76
77
78
79
80
81
82
83
<?php
/**
* @file
* qa.variables.inc
*
* @author: Frédéric G. MARAND <fgm@osinet.fr>
*
* @copyright (c) 2014 Ouest Systèmes Informatiques (OSInet).
*
* @license General Public License version 2 or later
*/
use Drupal\qa\Variable;
function qa_report_variable(Variable $variable = NULL) {
$c = cache_get('views_data:fr', 'cache_views');
$ret = '<pre>' . json_encode($c, JSON_PRETTY_PRINT) . '</pre>';
return $ret;
$bc = drupal_get_breadcrumb();
$bc[] = l(t('Administration'), 'admin');
$bc[] = l(t('Reports'), 'admin/reports');
$bc[] = l(t('Quality Assurance'), 'admin/reports/qa');
$bc[] = l(t('Variables'), 'admin/reports/qa/variable');
drupal_set_breadcrumb($bc);
drupal_set_title(t('Variable: %name', array('%name' => $variable->name)), PASS_THROUGH);
return $variable->dump();
}
/**
* Page callback for variables list.
*
* @return string
*/
function qa_report_variables() {
$cached = cache_get('variables', 'cache_bootstrap');
if ($cached === FALSE) {
$cached = (object) array(
'data' => array(),
'serialized' => FALSE,
);
}
$header = array(
t('Name'),
t('Length'),
t('Value, or size for arrays'),
);
$rows = array();
foreach ($cached->data as $name => $value) {
$row = array();
$variable = new Variable($name);
$row[] = $variable->link();
$row[] = is_scalar($value) ? strlen($value) : strlen(serialize($value));
if (is_array($value)) {
$cell = t("Array[@count]", array('@count' => count($value)));
} else {
$raw = is_string($value) ? $value : serialize($value);
$raw = check_plain($raw);
$cell = (strlen($raw) > 200) ? substr($raw, 0, 200) . '…' : $raw;
}
$row[] = $cell;
$rows[] = $row;
}
usort($rows, function ($x, $y) {
if ($x[1] < $y[1]) {
$ret = -1;
} elseif ($x[1] > $y[1]) {
$ret = 1;
} else {
$ret = strcmp($x[0], $y[0]);
}
return - $ret;
});
return theme('table', array(
'header' => $header,
'rows' => $rows,
));
}