Passed
Push — master ( 0b9e3e...5a5c41 )
by Cody
04:44
created

Backend::loading()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 4
rs 10
1
<?php
2
class Backend extends Handler {
3
	function loading() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
4
		header("Content-type: text/html");
5
		print __("Loading, please wait...") . " " .
6
			"<img src='images/indicator_tiny.gif'>";
7
	}
8
9
	function digestTest() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
10
		if (isset($_SESSION['uid'])) {
11
			header("Content-type: text/html");
12
13
			$rv = Digest::prepare_headlines_digest($_SESSION['uid'], 1, 1000);
14
15
			print "<h1>HTML</h1>";
16
			print $rv[0];
17
			print "<h1>Plain text</h1>";
18
			print "<pre>".$rv[3]."</pre>";
19
		} else {
20
			print error_json(6);
21
		}
22
	}
23
24
	function help() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
25
		$topic = clean_filename($_REQUEST["topic"]); // only one for now
26
27
		if ($topic == "main") {
28
			$info = get_hotkeys_info();
29
			$imap = get_hotkeys_map();
30
			$omap = array();
31
32
			foreach ($imap[1] as $sequence => $action) {
33
				if (!isset($omap[$action])) $omap[$action] = array();
34
35
				array_push($omap[$action], $sequence);
36
			}
37
38
			print "<ul class='panel panel-scrollable hotkeys-help' style='height : 300px'>";
39
40
			$cur_section = "";
41
			foreach ($info as $section => $hotkeys) {
42
43
				if ($cur_section) print "<li>&nbsp;</li>";
44
				print "<li><h3>" . $section . "</h3></li>";
45
				$cur_section = $section;
46
47
				foreach ($hotkeys as $action => $description) {
48
49
					if (is_array($omap[$action])) {
50
						foreach ($omap[$action] as $sequence) {
51
							if (strpos($sequence, "|") !== FALSE) {
52
								$sequence = substr($sequence,
53
									strpos($sequence, "|")+1,
54
									strlen($sequence));
55
							} else {
56
								$keys = explode(" ", $sequence);
57
58
								for ($i = 0; $i < count($keys); $i++) {
0 ignored issues
show
Performance Best Practice introduced by
It seems like you are calling the size function count() as part of the test condition. You might want to compute the size beforehand, and not on each iteration.

If the size of the collection does not change during the iteration, it is generally a good practice to compute it beforehand, and not on each iteration:

for ($i=0; $i<count($array); $i++) { // calls count() on each iteration
}

// Better
for ($i=0, $c=count($array); $i<$c; $i++) { // calls count() just once
}
Loading history...
59
									if (strlen($keys[$i]) > 1) {
60
										$tmp = '';
61
										foreach (str_split($keys[$i]) as $c) {
62
											switch ($c) {
63
												case '*':
64
													$tmp .= __('Shift') . '+';
65
													break;
66
												case '^':
67
													$tmp .= __('Ctrl') . '+';
68
													break;
69
												default:
70
													$tmp .= $c;
71
											}
72
										}
73
										$keys[$i] = $tmp;
74
									}
75
								}
76
								$sequence = join(" ", $keys);
77
							}
78
79
							print "<li>";
80
							print "<div class='hk'><code>$sequence</code></div>";
81
							print "<div class='desc'>$description</div>";
82
							print "</li>";
83
						}
84
					}
85
				}
86
			}
87
88
			print "</ul>";
89
		}
90
91
		print "<footer class='text-center'>";
92
		print "<button dojoType='dijit.form.Button'
93
			onclick=\"return dijit.byId('helpDlg').hide()\">".__('Close this window')."</button>";
94
		print "</footer>";
95
96
	}
97
}
98