@@ -41,6 +41,9 @@ discard block |
||
41 | 41 | } |
42 | 42 | |
43 | 43 | |
44 | + /** |
|
45 | + * @param string $color |
|
46 | + */ |
|
44 | 47 | public function hsl($color) |
45 | 48 | { |
46 | 49 | list($r, $g, $b) = $this->rgb($color); |
@@ -135,7 +138,7 @@ discard block |
||
135 | 138 | * |
136 | 139 | * @param string|array $color1 |
137 | 140 | * @param string|array $color2 |
138 | - * @return int |
|
141 | + * @return double |
|
139 | 142 | */ |
140 | 143 | public function lumDiff($color1, $color2) |
141 | 144 | { |
@@ -39,7 +39,7 @@ |
||
39 | 39 | /** |
40 | 40 | * Singleton |
41 | 41 | * |
42 | - * @return Nip_Helper_Date |
|
42 | + * @return Nip_Helper_Time |
|
43 | 43 | */ |
44 | 44 | static public function instance() |
45 | 45 | { |
@@ -12,42 +12,42 @@ |
||
12 | 12 | return $minutes; |
13 | 13 | } |
14 | 14 | |
15 | - public function secondsInStringTime($seconds) |
|
16 | - { |
|
17 | - if ($days = intval((floor($seconds / 86400)))) { |
|
15 | + public function secondsInStringTime($seconds) |
|
16 | + { |
|
17 | + if ($days = intval((floor($seconds / 86400)))) { |
|
18 | 18 | $seconds = $seconds - $days*86400; |
19 | - $return .= ($return ? ' ' : '') . str_pad($days, 2, 0,STR_PAD_LEFT).'d'; |
|
20 | - } |
|
21 | - if ($hours = intval((floor($seconds / 3600))) OR $return) { |
|
19 | + $return .= ($return ? ' ' : '') . str_pad($days, 2, 0,STR_PAD_LEFT).'d'; |
|
20 | + } |
|
21 | + if ($hours = intval((floor($seconds / 3600))) OR $return) { |
|
22 | 22 | $seconds = $seconds - $hours*3600; |
23 | - $return .= ($return ? ' ' : '') . str_pad($hours, 2, 0,STR_PAD_LEFT).'h'; |
|
24 | - } |
|
25 | - if ($minutes = intval((floor($seconds / 60))) OR $return) { |
|
26 | - $seconds = $seconds - $minutes*60; |
|
27 | - $return .= ($return ? ' ' : '') . str_pad($minutes, 2, 0, STR_PAD_LEFT).'m'; |
|
28 | - } |
|
23 | + $return .= ($return ? ' ' : '') . str_pad($hours, 2, 0,STR_PAD_LEFT).'h'; |
|
24 | + } |
|
25 | + if ($minutes = intval((floor($seconds / 60))) OR $return) { |
|
26 | + $seconds = $seconds - $minutes*60; |
|
27 | + $return .= ($return ? ' ' : '') . str_pad($minutes, 2, 0, STR_PAD_LEFT).'m'; |
|
28 | + } |
|
29 | 29 | |
30 | - $seconds = round($seconds, 2); |
|
30 | + $seconds = round($seconds, 2); |
|
31 | 31 | if ($seconds) { |
32 | 32 | $return .= ($return ? ' ' : '') . str_pad($seconds, 2, 0, STR_PAD_LEFT).'s'; |
33 | 33 | } |
34 | 34 | |
35 | - return $return; |
|
36 | - } |
|
35 | + return $return; |
|
36 | + } |
|
37 | 37 | |
38 | 38 | |
39 | - /** |
|
40 | - * Singleton |
|
41 | - * |
|
42 | - * @return Nip_Helper_Date |
|
43 | - */ |
|
44 | - static public function instance() |
|
45 | - { |
|
46 | - static $instance; |
|
47 | - if (!($instance instanceof self)) { |
|
48 | - $instance = new self(); |
|
49 | - } |
|
50 | - return $instance; |
|
51 | - } |
|
39 | + /** |
|
40 | + * Singleton |
|
41 | + * |
|
42 | + * @return Nip_Helper_Date |
|
43 | + */ |
|
44 | + static public function instance() |
|
45 | + { |
|
46 | + static $instance; |
|
47 | + if (!($instance instanceof self)) { |
|
48 | + $instance = new self(); |
|
49 | + } |
|
50 | + return $instance; |
|
51 | + } |
|
52 | 52 | |
53 | 53 | } |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | $minutes = false; |
8 | 8 | if (strpos($time, ':')) { |
9 | 9 | list($hours, $minutes) = explode(':', $time); |
10 | - $minutes += $hours*60; |
|
10 | + $minutes += $hours * 60; |
|
11 | 11 | } |
12 | 12 | return $minutes; |
13 | 13 | } |
@@ -15,21 +15,21 @@ discard block |
||
15 | 15 | public function secondsInStringTime($seconds) |
16 | 16 | { |
17 | 17 | if ($days = intval((floor($seconds / 86400)))) { |
18 | - $seconds = $seconds - $days*86400; |
|
19 | - $return .= ($return ? ' ' : '') . str_pad($days, 2, 0,STR_PAD_LEFT).'d'; |
|
18 | + $seconds = $seconds - $days * 86400; |
|
19 | + $return .= ($return ? ' ' : '') . str_pad($days, 2, 0, STR_PAD_LEFT) . 'd'; |
|
20 | 20 | } |
21 | 21 | if ($hours = intval((floor($seconds / 3600))) OR $return) { |
22 | - $seconds = $seconds - $hours*3600; |
|
23 | - $return .= ($return ? ' ' : '') . str_pad($hours, 2, 0,STR_PAD_LEFT).'h'; |
|
22 | + $seconds = $seconds - $hours * 3600; |
|
23 | + $return .= ($return ? ' ' : '') . str_pad($hours, 2, 0, STR_PAD_LEFT) . 'h'; |
|
24 | 24 | } |
25 | 25 | if ($minutes = intval((floor($seconds / 60))) OR $return) { |
26 | - $seconds = $seconds - $minutes*60; |
|
27 | - $return .= ($return ? ' ' : '') . str_pad($minutes, 2, 0, STR_PAD_LEFT).'m'; |
|
26 | + $seconds = $seconds - $minutes * 60; |
|
27 | + $return .= ($return ? ' ' : '') . str_pad($minutes, 2, 0, STR_PAD_LEFT) . 'm'; |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | $seconds = round($seconds, 2); |
31 | 31 | if ($seconds) { |
32 | - $return .= ($return ? ' ' : '') . str_pad($seconds, 2, 0, STR_PAD_LEFT).'s'; |
|
32 | + $return .= ($return ? ' ' : '') . str_pad($seconds, 2, 0, STR_PAD_LEFT) . 's'; |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | return $return; |
@@ -18,6 +18,9 @@ |
||
18 | 18 | |
19 | 19 | } |
20 | 20 | |
21 | + /** |
|
22 | + * @param string $key |
|
23 | + */ |
|
21 | 24 | public function setParam($key, $value) { |
22 | 25 | $this->_params[$key] = $value; |
23 | 26 | return $this; |
@@ -22,9 +22,9 @@ |
||
22 | 22 | |
23 | 23 | $dDiff = $dStart->diff($dEnd); |
24 | 24 | |
25 | - $years = (int)$dDiff->format("%y"); |
|
26 | - $months = (int)$dDiff->format("%m"); |
|
27 | - $days = (int)$dDiff->format("%d"); |
|
25 | + $years = (int) $dDiff->format("%y"); |
|
26 | + $months = (int) $dDiff->format("%m"); |
|
27 | + $days = (int) $dDiff->format("%d"); |
|
28 | 28 | |
29 | 29 | return array($years, $months, $days); |
30 | 30 | } |
@@ -11,64 +11,64 @@ |
||
11 | 11 | |
12 | 12 | class Nip_Helper_Fulltext extends Nip\Helpers\AbstractHelper { |
13 | 13 | |
14 | - public function buildString($keywords, $mode = 'any') { |
|
15 | - $return = ""; |
|
14 | + public function buildString($keywords, $mode = 'any') { |
|
15 | + $return = ""; |
|
16 | 16 | |
17 | - $keywords = explode(" ", $keywords); |
|
17 | + $keywords = explode(" ", $keywords); |
|
18 | 18 | |
19 | - switch ($mode) { |
|
20 | - case "any": |
|
21 | - foreach ($keywords as $item) { |
|
22 | - $return .= $this->matchNumbers($item).'* '; |
|
23 | - } |
|
24 | - break; |
|
19 | + switch ($mode) { |
|
20 | + case "any": |
|
21 | + foreach ($keywords as $item) { |
|
22 | + $return .= $this->matchNumbers($item).'* '; |
|
23 | + } |
|
24 | + break; |
|
25 | 25 | |
26 | - case "all": |
|
27 | - if (count($keywords) == 1) { |
|
28 | - $return .= $this->matchNumbers(reset($keywords)).'* '; |
|
29 | - } else { |
|
30 | - foreach ($keywords as $item) { |
|
31 | - $return .= '+'. $this->matchNumbers($item).'* '; |
|
32 | - } |
|
33 | - } |
|
26 | + case "all": |
|
27 | + if (count($keywords) == 1) { |
|
28 | + $return .= $this->matchNumbers(reset($keywords)).'* '; |
|
29 | + } else { |
|
30 | + foreach ($keywords as $item) { |
|
31 | + $return .= '+'. $this->matchNumbers($item).'* '; |
|
32 | + } |
|
33 | + } |
|
34 | 34 | |
35 | - break; |
|
36 | - case "exact": |
|
37 | - foreach ($keywords as $item) { |
|
38 | - $return .= $this->matchNumbers($item).' '; |
|
39 | - } |
|
40 | - $return = '+"'.$return.'"'; |
|
41 | - break; |
|
42 | - } |
|
35 | + break; |
|
36 | + case "exact": |
|
37 | + foreach ($keywords as $item) { |
|
38 | + $return .= $this->matchNumbers($item).' '; |
|
39 | + } |
|
40 | + $return = '+"'.$return.'"'; |
|
41 | + break; |
|
42 | + } |
|
43 | 43 | |
44 | - $return = strtolower(trim($return)); |
|
44 | + $return = strtolower(trim($return)); |
|
45 | 45 | |
46 | - return $return; |
|
47 | - } |
|
46 | + return $return; |
|
47 | + } |
|
48 | 48 | |
49 | 49 | |
50 | - private function matchNumbers($input) { |
|
51 | - $stripped = array("%", ",", "."); |
|
52 | - $replaced = array("__", "_", "_"); |
|
50 | + private function matchNumbers($input) { |
|
51 | + $stripped = array("%", ",", "."); |
|
52 | + $replaced = array("__", "_", "_"); |
|
53 | 53 | |
54 | - if (is_numeric(str_replace($stripped, "", $input))) { |
|
55 | - return str_replace($stripped, $replaced, $input); |
|
56 | - } else { |
|
57 | - return $input; |
|
58 | - } |
|
59 | - } |
|
54 | + if (is_numeric(str_replace($stripped, "", $input))) { |
|
55 | + return str_replace($stripped, $replaced, $input); |
|
56 | + } else { |
|
57 | + return $input; |
|
58 | + } |
|
59 | + } |
|
60 | 60 | |
61 | 61 | |
62 | - /** |
|
63 | - * Returns singleton instance |
|
64 | - * |
|
65 | - * @return Nip_Helper_Fulltext |
|
66 | - */ |
|
67 | - static public function instance() { |
|
68 | - static $instance; |
|
69 | - if (!($instance instanceof self)) { |
|
70 | - $instance = new self(); |
|
71 | - } |
|
72 | - return $instance; |
|
73 | - } |
|
62 | + /** |
|
63 | + * Returns singleton instance |
|
64 | + * |
|
65 | + * @return Nip_Helper_Fulltext |
|
66 | + */ |
|
67 | + static public function instance() { |
|
68 | + static $instance; |
|
69 | + if (!($instance instanceof self)) { |
|
70 | + $instance = new self(); |
|
71 | + } |
|
72 | + return $instance; |
|
73 | + } |
|
74 | 74 | } |
75 | 75 | \ No newline at end of file |
@@ -19,25 +19,25 @@ |
||
19 | 19 | switch ($mode) { |
20 | 20 | case "any": |
21 | 21 | foreach ($keywords as $item) { |
22 | - $return .= $this->matchNumbers($item).'* '; |
|
22 | + $return .= $this->matchNumbers($item) . '* '; |
|
23 | 23 | } |
24 | 24 | break; |
25 | 25 | |
26 | 26 | case "all": |
27 | 27 | if (count($keywords) == 1) { |
28 | - $return .= $this->matchNumbers(reset($keywords)).'* '; |
|
28 | + $return .= $this->matchNumbers(reset($keywords)) . '* '; |
|
29 | 29 | } else { |
30 | 30 | foreach ($keywords as $item) { |
31 | - $return .= '+'. $this->matchNumbers($item).'* '; |
|
31 | + $return .= '+' . $this->matchNumbers($item) . '* '; |
|
32 | 32 | } |
33 | 33 | } |
34 | 34 | |
35 | 35 | break; |
36 | 36 | case "exact": |
37 | 37 | foreach ($keywords as $item) { |
38 | - $return .= $this->matchNumbers($item).' '; |
|
38 | + $return .= $this->matchNumbers($item) . ' '; |
|
39 | 39 | } |
40 | - $return = '+"'.$return.'"'; |
|
40 | + $return = '+"' . $return . '"'; |
|
41 | 41 | break; |
42 | 42 | } |
43 | 43 |
@@ -2,33 +2,33 @@ |
||
2 | 2 | class Nip_Helper_Async extends Nip\Helpers\AbstractHelper |
3 | 3 | { |
4 | 4 | |
5 | - public function sendMessage($message, $type = 'success', $format ='json') |
|
6 | - { |
|
5 | + public function sendMessage($message, $type = 'success', $format ='json') |
|
6 | + { |
|
7 | 7 | $data = array( |
8 | 8 | 'type' => $type, |
9 | 9 | 'message' => $message, |
10 | 10 | ); |
11 | 11 | return $this->$format($data); |
12 | - } |
|
12 | + } |
|
13 | 13 | |
14 | - public function json($data) |
|
15 | - { |
|
16 | - header("Content-type: text/x-json"); |
|
17 | - echo(is_string($data) ? $data : json_encode($data)); |
|
18 | - exit(); |
|
19 | - } |
|
14 | + public function json($data) |
|
15 | + { |
|
16 | + header("Content-type: text/x-json"); |
|
17 | + echo(is_string($data) ? $data : json_encode($data)); |
|
18 | + exit(); |
|
19 | + } |
|
20 | 20 | |
21 | - public function txt($data) |
|
22 | - { |
|
23 | - header("Content-type: text/plain"); |
|
24 | - echo($data); |
|
25 | - exit(); |
|
26 | - } |
|
21 | + public function txt($data) |
|
22 | + { |
|
23 | + header("Content-type: text/plain"); |
|
24 | + echo($data); |
|
25 | + exit(); |
|
26 | + } |
|
27 | 27 | |
28 | - public function html($data) |
|
29 | - { |
|
30 | - header("Content-type: text/html"); |
|
31 | - echo($data); |
|
32 | - exit(); |
|
33 | - } |
|
28 | + public function html($data) |
|
29 | + { |
|
30 | + header("Content-type: text/html"); |
|
31 | + echo($data); |
|
32 | + exit(); |
|
33 | + } |
|
34 | 34 | } |
35 | 35 | \ No newline at end of file |
@@ -2,7 +2,7 @@ |
||
2 | 2 | class Nip_Helper_Async extends Nip\Helpers\AbstractHelper |
3 | 3 | { |
4 | 4 | |
5 | - public function sendMessage($message, $type = 'success', $format ='json') |
|
5 | + public function sendMessage($message, $type = 'success', $format = 'json') |
|
6 | 6 | { |
7 | 7 | $data = array( |
8 | 8 | 'type' => $type, |
@@ -17,9 +17,9 @@ |
||
17 | 17 | |
18 | 18 | |
19 | 19 | public function __construct($id, $content, $title = false) { |
20 | - $this->_id = $id; |
|
21 | - $this->_content = $content; |
|
22 | - $this->_title = $title; |
|
20 | + $this->_id = $id; |
|
21 | + $this->_content = $content; |
|
22 | + $this->_title = $title; |
|
23 | 23 | } |
24 | 24 | |
25 | 25 |
@@ -13,28 +13,28 @@ |
||
13 | 13 | |
14 | 14 | class Item { |
15 | 15 | |
16 | - protected $_id; |
|
17 | - protected $_content; |
|
16 | + protected $_id; |
|
17 | + protected $_content; |
|
18 | 18 | protected $_title; |
19 | 19 | |
20 | 20 | |
21 | - public function __construct($id, $content, $title = false) { |
|
22 | - $this->_id = $id; |
|
23 | - $this->_content = $content; |
|
24 | - $this->_title = $title; |
|
25 | - } |
|
21 | + public function __construct($id, $content, $title = false) { |
|
22 | + $this->_id = $id; |
|
23 | + $this->_content = $content; |
|
24 | + $this->_title = $title; |
|
25 | + } |
|
26 | 26 | |
27 | 27 | |
28 | - public function render() { |
|
29 | - $return = ''; |
|
28 | + public function render() { |
|
29 | + $return = ''; |
|
30 | 30 | |
31 | - $return .= '<div class="tooltip" id="' . $this->_id . '" style="display: none;">'; |
|
32 | - if ($this->_title !== false) { |
|
33 | - $return .= '<div class="tooltip-heading">' . $this->_title . '</div>'; |
|
34 | - } |
|
35 | - $return .= $this->_content; |
|
36 | - $return .= '</div>'; |
|
31 | + $return .= '<div class="tooltip" id="' . $this->_id . '" style="display: none;">'; |
|
32 | + if ($this->_title !== false) { |
|
33 | + $return .= '<div class="tooltip-heading">' . $this->_title . '</div>'; |
|
34 | + } |
|
35 | + $return .= $this->_content; |
|
36 | + $return .= '</div>'; |
|
37 | 37 | |
38 | - return $return; |
|
39 | - } |
|
38 | + return $return; |
|
39 | + } |
|
40 | 40 | } |
41 | 41 | \ No newline at end of file |
@@ -22,19 +22,19 @@ |
||
22 | 22 | return str_pad($hash, $len, "0", STR_PAD_LEFT); |
23 | 23 | } |
24 | 24 | |
25 | - /** |
|
26 | - * Singleton |
|
27 | - * |
|
28 | - * @return Nip_Helper_Hash |
|
29 | - */ |
|
30 | - static public function instance() |
|
31 | - { |
|
32 | - static $instance; |
|
33 | - if (!($instance instanceof self)) { |
|
34 | - $instance = new self(); |
|
35 | - } |
|
36 | - return $instance; |
|
37 | - } |
|
25 | + /** |
|
26 | + * Singleton |
|
27 | + * |
|
28 | + * @return Nip_Helper_Hash |
|
29 | + */ |
|
30 | + static public function instance() |
|
31 | + { |
|
32 | + static $instance; |
|
33 | + if (!($instance instanceof self)) { |
|
34 | + $instance = new self(); |
|
35 | + } |
|
36 | + return $instance; |
|
37 | + } |
|
38 | 38 | |
39 | 39 | |
40 | 40 | } |
41 | 41 | \ No newline at end of file |
@@ -14,7 +14,7 @@ |
||
14 | 14 | while ($len < $maxlen && pow($base, $len) < $num) |
15 | 15 | $len++; |
16 | 16 | if ($len >= $maxlen) |
17 | - throw new Exception($num." out of range (max ".pow($base, $maxlen - 1).")"); |
|
17 | + throw new Exception($num . " out of range (max " . pow($base, $maxlen - 1) . ")"); |
|
18 | 18 | $ceil = pow($base, $len); |
19 | 19 | $prime = $gp[$len]; |
20 | 20 | $dechash = ($num * $prime) % $ceil; |
@@ -11,10 +11,12 @@ |
||
11 | 11 | $gp = $golden_primes[$base]; |
12 | 12 | $maxlen = count($gp); |
13 | 13 | $len = $len > ($maxlen - 1) ? ($maxlen - 1) : $len; |
14 | - while ($len < $maxlen && pow($base, $len) < $num) |
|
15 | - $len++; |
|
16 | - if ($len >= $maxlen) |
|
17 | - throw new Exception($num." out of range (max ".pow($base, $maxlen - 1).")"); |
|
14 | + while ($len < $maxlen && pow($base, $len) < $num) { |
|
15 | + $len++; |
|
16 | + } |
|
17 | + if ($len >= $maxlen) { |
|
18 | + throw new Exception($num." out of range (max ".pow($base, $maxlen - 1).")"); |
|
19 | + } |
|
18 | 20 | $ceil = pow($base, $len); |
19 | 21 | $prime = $gp[$len]; |
20 | 22 | $dechash = ($num * $prime) % $ceil; |
@@ -28,7 +28,7 @@ |
||
28 | 28 | |
29 | 29 | public function getTotalPages() |
30 | 30 | { |
31 | - $this->totalPages = (int)($this->count / $this->itemsPerPage); |
|
31 | + $this->totalPages = (int) ($this->count / $this->itemsPerPage); |
|
32 | 32 | if ($this->count % $this->itemsPerPage != 0) { |
33 | 33 | $this->totalPages++; |
34 | 34 | } |