@@ -12,21 +12,21 @@ discard block |
||
12 | 12 | |
13 | 13 | class TypeAheadHelper implements ITypeAheadHelper |
14 | 14 | { |
15 | - private $definedClasses = array(); |
|
15 | + private $definedClasses = array(); |
|
16 | 16 | |
17 | - /** |
|
18 | - * @param string $class CSS class to apply this typeahead to. |
|
19 | - * @param callable $generator Generator function taking no arguments to return an array of strings. |
|
20 | - */ |
|
21 | - public function defineTypeAheadSource($class, callable $generator) |
|
22 | - { |
|
23 | - $dataList = ''; |
|
24 | - foreach ($generator() as $dataItem) { |
|
25 | - $dataList .= '"' . htmlentities($dataItem) . '", '; |
|
26 | - } |
|
27 | - $dataList = "[" . rtrim($dataList, ", ") . "]"; |
|
17 | + /** |
|
18 | + * @param string $class CSS class to apply this typeahead to. |
|
19 | + * @param callable $generator Generator function taking no arguments to return an array of strings. |
|
20 | + */ |
|
21 | + public function defineTypeAheadSource($class, callable $generator) |
|
22 | + { |
|
23 | + $dataList = ''; |
|
24 | + foreach ($generator() as $dataItem) { |
|
25 | + $dataList .= '"' . htmlentities($dataItem) . '", '; |
|
26 | + } |
|
27 | + $dataList = "[" . rtrim($dataList, ", ") . "]"; |
|
28 | 28 | |
29 | - $script = <<<JS |
|
29 | + $script = <<<JS |
|
30 | 30 | var substringMatcher = function(strs) { |
31 | 31 | return function findMatches(q, cb) { |
32 | 32 | var matches, substringRegex; |
@@ -58,32 +58,32 @@ discard block |
||
58 | 58 | source: substringMatcher({$dataList}) |
59 | 59 | }); |
60 | 60 | JS; |
61 | - $this->definedClasses[$class] = $script; |
|
62 | - } |
|
61 | + $this->definedClasses[$class] = $script; |
|
62 | + } |
|
63 | 63 | |
64 | - /** |
|
65 | - * @return string HTML fragment containing a JS block for typeaheads. |
|
66 | - */ |
|
67 | - public function getTypeAheadScriptBlock() |
|
68 | - { |
|
69 | - $jsBlocks = ''; |
|
64 | + /** |
|
65 | + * @return string HTML fragment containing a JS block for typeaheads. |
|
66 | + */ |
|
67 | + public function getTypeAheadScriptBlock() |
|
68 | + { |
|
69 | + $jsBlocks = ''; |
|
70 | 70 | |
71 | - if (count($this->definedClasses) === 0) { |
|
72 | - return ''; |
|
73 | - } |
|
71 | + if (count($this->definedClasses) === 0) { |
|
72 | + return ''; |
|
73 | + } |
|
74 | 74 | |
75 | - foreach ($this->definedClasses as $class => $js) { |
|
76 | - $jsBlocks = $js . "\r\n\r\n"; |
|
77 | - } |
|
75 | + foreach ($this->definedClasses as $class => $js) { |
|
76 | + $jsBlocks = $js . "\r\n\r\n"; |
|
77 | + } |
|
78 | 78 | |
79 | - $data = <<<HTML |
|
79 | + $data = <<<HTML |
|
80 | 80 | <script type="text/javascript"> |
81 | 81 | {$jsBlocks} |
82 | 82 | </script> |
83 | 83 | HTML; |
84 | 84 | |
85 | - $this->definedClasses = array(); |
|
85 | + $this->definedClasses = array(); |
|
86 | 86 | |
87 | - return $data; |
|
88 | - } |
|
87 | + return $data; |
|
88 | + } |
|
89 | 89 | } |
@@ -22,9 +22,9 @@ discard block |
||
22 | 22 | { |
23 | 23 | $dataList = ''; |
24 | 24 | foreach ($generator() as $dataItem) { |
25 | - $dataList .= '"' . htmlentities($dataItem) . '", '; |
|
25 | + $dataList .= '"'.htmlentities($dataItem).'", '; |
|
26 | 26 | } |
27 | - $dataList = "[" . rtrim($dataList, ", ") . "]"; |
|
27 | + $dataList = "[".rtrim($dataList, ", ")."]"; |
|
28 | 28 | |
29 | 29 | $script = <<<JS |
30 | 30 | var substringMatcher = function(strs) { |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | } |
74 | 74 | |
75 | 75 | foreach ($this->definedClasses as $class => $js) { |
76 | - $jsBlocks = $js . "\r\n\r\n"; |
|
76 | + $jsBlocks = $js."\r\n\r\n"; |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | $data = <<<HTML |
@@ -16,57 +16,57 @@ |
||
16 | 16 | */ |
17 | 17 | class Offline |
18 | 18 | { |
19 | - /** |
|
20 | - * Determines if the tool is offline |
|
21 | - * @return bool |
|
22 | - */ |
|
23 | - public static function isOffline() |
|
24 | - { |
|
25 | - global $dontUseDb; |
|
19 | + /** |
|
20 | + * Determines if the tool is offline |
|
21 | + * @return bool |
|
22 | + */ |
|
23 | + public static function isOffline() |
|
24 | + { |
|
25 | + global $dontUseDb; |
|
26 | 26 | |
27 | - return (bool)$dontUseDb; |
|
28 | - } |
|
27 | + return (bool)$dontUseDb; |
|
28 | + } |
|
29 | 29 | |
30 | - /** |
|
31 | - * Gets the offline message |
|
32 | - * |
|
33 | - * @param bool $external |
|
34 | - * @param null $message |
|
35 | - * |
|
36 | - * @return string |
|
37 | - */ |
|
38 | - public static function getOfflineMessage($external, $message = null) |
|
39 | - { |
|
40 | - global $dontUseDbCulprit, $dontUseDbReason, $baseurl; |
|
30 | + /** |
|
31 | + * Gets the offline message |
|
32 | + * |
|
33 | + * @param bool $external |
|
34 | + * @param null $message |
|
35 | + * |
|
36 | + * @return string |
|
37 | + */ |
|
38 | + public static function getOfflineMessage($external, $message = null) |
|
39 | + { |
|
40 | + global $dontUseDbCulprit, $dontUseDbReason, $baseurl; |
|
41 | 41 | |
42 | - $smarty = new Smarty(); |
|
43 | - $smarty->assign("baseurl", $baseurl); |
|
44 | - $smarty->assign("alerts", []); |
|
45 | - $smarty->assign("toolversion", Environment::getToolVersion()); |
|
42 | + $smarty = new Smarty(); |
|
43 | + $smarty->assign("baseurl", $baseurl); |
|
44 | + $smarty->assign("alerts", []); |
|
45 | + $smarty->assign("toolversion", Environment::getToolVersion()); |
|
46 | 46 | |
47 | - if (!headers_sent()) { |
|
48 | - header("HTTP/1.1 503 Service Unavailable"); |
|
49 | - } |
|
47 | + if (!headers_sent()) { |
|
48 | + header("HTTP/1.1 503 Service Unavailable"); |
|
49 | + } |
|
50 | 50 | |
51 | - if ($external) { |
|
52 | - return $smarty->fetch("offline/external.tpl"); |
|
53 | - } |
|
54 | - else { |
|
55 | - $hideCulprit = true; |
|
51 | + if ($external) { |
|
52 | + return $smarty->fetch("offline/external.tpl"); |
|
53 | + } |
|
54 | + else { |
|
55 | + $hideCulprit = true; |
|
56 | 56 | |
57 | - // Use the provided message if possible |
|
58 | - if ($message === null) { |
|
59 | - $hideCulprit = false; |
|
60 | - $message = $dontUseDbReason; |
|
61 | - } |
|
57 | + // Use the provided message if possible |
|
58 | + if ($message === null) { |
|
59 | + $hideCulprit = false; |
|
60 | + $message = $dontUseDbReason; |
|
61 | + } |
|
62 | 62 | |
63 | - $smarty->assign("hideCulprit", $hideCulprit); |
|
64 | - $smarty->assign("dontUseDbCulprit", $dontUseDbCulprit); |
|
65 | - $smarty->assign("dontUseDbReason", $message); |
|
66 | - $smarty->assign("alerts", array()); |
|
67 | - $smarty->assign('currentUser', User::getCommunity()); |
|
63 | + $smarty->assign("hideCulprit", $hideCulprit); |
|
64 | + $smarty->assign("dontUseDbCulprit", $dontUseDbCulprit); |
|
65 | + $smarty->assign("dontUseDbReason", $message); |
|
66 | + $smarty->assign("alerts", array()); |
|
67 | + $smarty->assign('currentUser', User::getCommunity()); |
|
68 | 68 | |
69 | - return $smarty->fetch("offline/internal.tpl"); |
|
70 | - } |
|
71 | - } |
|
69 | + return $smarty->fetch("offline/internal.tpl"); |
|
70 | + } |
|
71 | + } |
|
72 | 72 | } |