@@ -10,95 +10,95 @@ |
||
10 | 10 | */ |
11 | 11 | class Nip_File_Handler |
12 | 12 | { |
13 | - const MODE_READ = "r"; |
|
14 | - const MODE_WRITE = "w"; |
|
15 | - const MODE_APPEND = "a"; |
|
16 | - |
|
17 | - |
|
18 | - public $name; |
|
19 | - public $path; |
|
20 | - public $url; |
|
21 | - public $data; |
|
22 | - public $extension; |
|
23 | - public $permissions = 0777; |
|
24 | - protected $handle = null; |
|
25 | - |
|
26 | - public function __construct($data = false) |
|
27 | - { |
|
28 | - if ($data) { |
|
29 | - foreach ($data as $key => $value) { |
|
30 | - $this->$key = $value; |
|
31 | - } |
|
32 | - } |
|
33 | - } |
|
34 | - |
|
35 | - public function __call($name, $arguments) |
|
36 | - { |
|
37 | - if (substr($name, 0, 3) == 'set') { |
|
38 | - $name = str_replace("set", "", $name); |
|
39 | - $name{0} = strtolower($name{0}); |
|
40 | - |
|
41 | - $this->$name = $arguments[0]; |
|
42 | - return $this; |
|
43 | - } else { |
|
44 | - trigger_error("Method [$name] not defined", E_USER_ERROR); |
|
45 | - } |
|
46 | - } |
|
47 | - |
|
48 | - public function upload($upload) |
|
49 | - { |
|
50 | - move_uploaded_file($upload["tmp_name"], $this->path); |
|
51 | - } |
|
52 | - |
|
53 | - public function delete() |
|
54 | - { |
|
55 | - return Nip_File_System::instance()->deleteFile($this->path); |
|
56 | - } |
|
57 | - |
|
58 | - public function gzip() |
|
59 | - { |
|
60 | - if (function_exists("gzencode")) { |
|
61 | - $this->data = gzencode($this->data, 9, FORCE_GZIP); |
|
62 | - } else { |
|
63 | - return false; |
|
64 | - } |
|
65 | - return $this; |
|
66 | - } |
|
67 | - |
|
68 | - public function write($data = false, $mode = self::MODE_APPEND) |
|
69 | - { |
|
70 | - if ($data) { |
|
71 | - $this->setData($data); |
|
72 | - } |
|
73 | - |
|
74 | - $this->open($mode); |
|
75 | - fwrite($this->handle, $this->data); |
|
76 | - $this->close($mode); |
|
77 | - |
|
78 | - chmod($this->path, $this->permissions); |
|
79 | - } |
|
80 | - |
|
81 | - public function rewrite($data = false) |
|
82 | - { |
|
83 | - return $this->write($data, self::MODE_WRITE); |
|
84 | - } |
|
85 | - |
|
86 | - public function open($mode = self::MODE_READ) |
|
87 | - { |
|
88 | - $this->handle = fopen($this->path, $mode); |
|
89 | - return $this; |
|
90 | - } |
|
91 | - |
|
92 | - public function close() |
|
93 | - { |
|
94 | - if ($this->handle) { |
|
95 | - fclose($this->handle); |
|
96 | - $this->handle = null; |
|
97 | - } else { |
|
98 | - trigger_error("Attempting to close an unopened file", E_USER_WARNING); |
|
99 | - } |
|
100 | - |
|
101 | - return $this; |
|
102 | - } |
|
13 | + const MODE_READ = "r"; |
|
14 | + const MODE_WRITE = "w"; |
|
15 | + const MODE_APPEND = "a"; |
|
16 | + |
|
17 | + |
|
18 | + public $name; |
|
19 | + public $path; |
|
20 | + public $url; |
|
21 | + public $data; |
|
22 | + public $extension; |
|
23 | + public $permissions = 0777; |
|
24 | + protected $handle = null; |
|
25 | + |
|
26 | + public function __construct($data = false) |
|
27 | + { |
|
28 | + if ($data) { |
|
29 | + foreach ($data as $key => $value) { |
|
30 | + $this->$key = $value; |
|
31 | + } |
|
32 | + } |
|
33 | + } |
|
34 | + |
|
35 | + public function __call($name, $arguments) |
|
36 | + { |
|
37 | + if (substr($name, 0, 3) == 'set') { |
|
38 | + $name = str_replace("set", "", $name); |
|
39 | + $name{0} = strtolower($name{0}); |
|
40 | + |
|
41 | + $this->$name = $arguments[0]; |
|
42 | + return $this; |
|
43 | + } else { |
|
44 | + trigger_error("Method [$name] not defined", E_USER_ERROR); |
|
45 | + } |
|
46 | + } |
|
47 | + |
|
48 | + public function upload($upload) |
|
49 | + { |
|
50 | + move_uploaded_file($upload["tmp_name"], $this->path); |
|
51 | + } |
|
52 | + |
|
53 | + public function delete() |
|
54 | + { |
|
55 | + return Nip_File_System::instance()->deleteFile($this->path); |
|
56 | + } |
|
57 | + |
|
58 | + public function gzip() |
|
59 | + { |
|
60 | + if (function_exists("gzencode")) { |
|
61 | + $this->data = gzencode($this->data, 9, FORCE_GZIP); |
|
62 | + } else { |
|
63 | + return false; |
|
64 | + } |
|
65 | + return $this; |
|
66 | + } |
|
67 | + |
|
68 | + public function write($data = false, $mode = self::MODE_APPEND) |
|
69 | + { |
|
70 | + if ($data) { |
|
71 | + $this->setData($data); |
|
72 | + } |
|
73 | + |
|
74 | + $this->open($mode); |
|
75 | + fwrite($this->handle, $this->data); |
|
76 | + $this->close($mode); |
|
77 | + |
|
78 | + chmod($this->path, $this->permissions); |
|
79 | + } |
|
80 | + |
|
81 | + public function rewrite($data = false) |
|
82 | + { |
|
83 | + return $this->write($data, self::MODE_WRITE); |
|
84 | + } |
|
85 | + |
|
86 | + public function open($mode = self::MODE_READ) |
|
87 | + { |
|
88 | + $this->handle = fopen($this->path, $mode); |
|
89 | + return $this; |
|
90 | + } |
|
91 | + |
|
92 | + public function close() |
|
93 | + { |
|
94 | + if ($this->handle) { |
|
95 | + fclose($this->handle); |
|
96 | + $this->handle = null; |
|
97 | + } else { |
|
98 | + trigger_error("Attempting to close an unopened file", E_USER_WARNING); |
|
99 | + } |
|
100 | + |
|
101 | + return $this; |
|
102 | + } |
|
103 | 103 | |
104 | 104 | } |
105 | 105 | \ No newline at end of file |
@@ -62,5 +62,5 @@ |
||
62 | 62 | $filename = implode(".", $filename); |
63 | 63 | $image->path = $dir . '/' . $filename; |
64 | 64 | $image->save(); |
65 | - } |
|
65 | + } |
|
66 | 66 | } |
67 | 67 | \ No newline at end of file |
@@ -11,15 +11,15 @@ |
||
11 | 11 | |
12 | 12 | $command = array(); |
13 | 13 | $command[] = '/usr/bin/ffmpeg'; |
14 | - $command[] = "-i ".escapeshellarg($this->path); |
|
14 | + $command[] = "-i " . escapeshellarg($this->path); |
|
15 | 15 | foreach ($params as $key => $value) { |
16 | - $command[] = "-$key ".escapeshellarg($value); |
|
16 | + $command[] = "-$key " . escapeshellarg($value); |
|
17 | 17 | } |
18 | 18 | |
19 | - $path = dirname($this->path) .DIRECTORY_SEPARATOR. pathinfo($this->path, PATHINFO_FILENAME) . '.' . strtolower($params['f']); |
|
19 | + $path = dirname($this->path) . DIRECTORY_SEPARATOR . pathinfo($this->path, PATHINFO_FILENAME) . '.' . strtolower($params['f']); |
|
20 | 20 | $command[] = $path; |
21 | 21 | |
22 | - $command = implode(" ", $command) . " && chmod 777 $path".($removeOriginal ? " && rm $this->path" : ""); |
|
22 | + $command = implode(" ", $command) . " && chmod 777 $path" . ($removeOriginal ? " && rm $this->path" : ""); |
|
23 | 23 | |
24 | 24 | $process = new Process($command); |
25 | 25 | $process->start(); |
@@ -6,47 +6,47 @@ |
||
6 | 6 | protected $_error; |
7 | 7 | protected $_tmp_name; |
8 | 8 | |
9 | - public function __construct($data = array()) |
|
10 | - { |
|
11 | - if ($data) { |
|
9 | + public function __construct($data = array()) |
|
10 | + { |
|
11 | + if ($data) { |
|
12 | 12 | $this->_name = $data['name']; |
13 | 13 | $this->_tmp_name = $data['tmp_name']; |
14 | 14 | |
15 | 15 | parent::__construct(TMP_PATH . $this->_tmp_name); |
16 | - } |
|
17 | - } |
|
16 | + } |
|
17 | + } |
|
18 | 18 | |
19 | - public function valid() |
|
20 | - { |
|
21 | - $result = false; |
|
19 | + public function valid() |
|
20 | + { |
|
21 | + $result = false; |
|
22 | 22 | |
23 | 23 | $max_upload = ini_get("post_max_size"); |
24 | - $unit = strtoupper(substr($max_upload, -1)); |
|
25 | - $multiplier = ($unit == 'M') ? 1048576 : (($unit == 'K') ? 1024 : (($unit == 'G') ? 1073741824 : 1)); |
|
24 | + $unit = strtoupper(substr($max_upload, -1)); |
|
25 | + $multiplier = ($unit == 'M') ? 1048576 : (($unit == 'K') ? 1024 : (($unit == 'G') ? 1073741824 : 1)); |
|
26 | 26 | |
27 | - if ($max_upload && ((int) $_SERVER['CONTENT_LENGTH'] > $multiplier * (int) $max_upload)) { |
|
27 | + if ($max_upload && ((int) $_SERVER['CONTENT_LENGTH'] > $multiplier * (int) $max_upload)) { |
|
28 | 28 | return self::ERROR_MAX_POST_SIZE; |
29 | - } |
|
29 | + } |
|
30 | 30 | |
31 | - if (!$this->getPath()) { |
|
31 | + if (!$this->getPath()) { |
|
32 | 32 | return false; |
33 | 33 | |
34 | - } else if (isset($this->error) && $this->error != 0) { |
|
34 | + } else if (isset($this->error) && $this->error != 0) { |
|
35 | 35 | return false; |
36 | 36 | |
37 | - } else if (!isset($this->_tmp_name) || !@is_uploaded_file($this->_tmp_name)) { |
|
37 | + } else if (!isset($this->_tmp_name) || !@is_uploaded_file($this->_tmp_name)) { |
|
38 | 38 | return false; |
39 | 39 | |
40 | - } else if (!isset($this->_name)) { |
|
40 | + } else if (!isset($this->_name)) { |
|
41 | 41 | return false; |
42 | - } |
|
42 | + } |
|
43 | 43 | |
44 | - return true; |
|
45 | - } |
|
44 | + return true; |
|
45 | + } |
|
46 | 46 | |
47 | - public function upload($path) |
|
48 | - { |
|
49 | - return $this->move($path); |
|
50 | - } |
|
47 | + public function upload($path) |
|
48 | + { |
|
49 | + return $this->move($path); |
|
50 | + } |
|
51 | 51 | |
52 | 52 | } |
53 | 53 | \ No newline at end of file |
@@ -20,7 +20,7 @@ |
||
20 | 20 | public function __construct() { |
21 | 21 | } |
22 | 22 | |
23 | - public function __call($name, $arguments) { |
|
23 | + public function __call($name, $arguments) { |
|
24 | 24 | if (strpos($name, 'render') === 0) { |
25 | 25 | return call_user_func_array(array($this->getProvider(), $name), $arguments); |
26 | 26 | } |
@@ -19,12 +19,12 @@ |
||
19 | 19 | } |
20 | 20 | |
21 | 21 | public function setDraggable($draggable = true) { |
22 | - $this->setParam('draggable',(bool) $draggable); |
|
22 | + $this->setParam('draggable', (bool) $draggable); |
|
23 | 23 | return $this; |
24 | 24 | } |
25 | 25 | |
26 | 26 | public function moveOnClick($move = true) { |
27 | - $this->setParam('moveOnClick',(bool) $move); |
|
27 | + $this->setParam('moveOnClick', (bool) $move); |
|
28 | 28 | return $this; |
29 | 29 | } |
30 | 30 |
@@ -43,7 +43,7 @@ |
||
43 | 43 | <input type="submit" class="button" value="Go" /> |
44 | 44 | </p> |
45 | 45 | </form>'; |
46 | - return $return; |
|
46 | + return $return; |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | public function initContainer() { |
@@ -54,7 +54,7 @@ |
||
54 | 54 | 'height' => $service->getParam('container_height') ? $service->getParam('container_height') : '500', |
55 | 55 | ); |
56 | 56 | |
57 | - $html = '<div id="'.$this->_container['id'].'" style="width: '.$this->_container['width'].'px; height: '.$this->_container['height'].'px;"> </div> '; |
|
57 | + $html = '<div id="' . $this->_container['id'] . '" style="width: ' . $this->_container['width'] . 'px; height: ' . $this->_container['height'] . 'px;"> </div> '; |
|
58 | 58 | return $html; |
59 | 59 | } |
60 | 60 |
@@ -80,7 +80,7 @@ |
||
80 | 80 | ); |
81 | 81 | }); |
82 | 82 | '; |
83 | - $this->_scripts[] = $script; |
|
83 | + $this->_scripts[] = $script; |
|
84 | 84 | |
85 | 85 | return $return; |
86 | 86 | } |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | var script = document.createElement("script"); |
19 | 19 | script.type = "text/javascript"; |
20 | 20 | script.async = false; |
21 | - script.src = "'.$this->getScriptURL().'"; |
|
21 | + script.src = "'.$this->getScriptURL() . '"; |
|
22 | 22 | document.documentElement.firstChild.appendChild(script); |
23 | 23 | </script> |
24 | 24 | '; |
@@ -40,16 +40,16 @@ discard block |
||
40 | 40 | $html = ' |
41 | 41 | function loadMap() { |
42 | 42 | if (GBrowserIsCompatible()) { |
43 | - var map = new GMap2(document.getElementById("'.$this->_container['id'].'"));'; |
|
43 | + var map = new GMap2(document.getElementById("'.$this->_container['id'] . '"));'; |
|
44 | 44 | $center = $this->getService()->getParam('center'); |
45 | 45 | if (is_array($center) && count($center) == 3) { |
46 | - list($cLat,$cLng, $cZoom) = $center; |
|
46 | + list($cLat, $cLng, $cZoom) = $center; |
|
47 | 47 | } else { |
48 | 48 | $cLat = '37.4419'; |
49 | 49 | $cLng = '-122.1419'; |
50 | 50 | $cZoom = '1'; |
51 | 51 | } |
52 | - $html .= 'map.setCenter(new GLatLng('.$cLat.','.$cLng.' ), '.$cZoom.');'; |
|
52 | + $html .= 'map.setCenter(new GLatLng(' . $cLat . ',' . $cLng . ' ), ' . $cZoom . ');'; |
|
53 | 53 | $html .= 'map.setUIToDefault();'; |
54 | 54 | return $html; |
55 | 55 | } |
@@ -88,17 +88,17 @@ discard block |
||
88 | 88 | public function renderMarker($marker) { |
89 | 89 | $html = ''; |
90 | 90 | if ($marker->latitude && $marker->longitude) { |
91 | - $html .= 'var latlng = new GLatLng('.$marker->latitude.', '.$marker->longitude.');'; |
|
91 | + $html .= 'var latlng = new GLatLng(' . $marker->latitude . ', ' . $marker->longitude . ');'; |
|
92 | 92 | } else { |
93 | 93 | $html .= 'var latlng = map.getCenter();'; |
94 | 94 | } |
95 | 95 | $options = array( |
96 | 96 | 'draggable' => $marker->getParam('draggable'), |
97 | 97 | ); |
98 | - $html .= 'var marker = new GMarker(latlng, ' . json_encode($options) . ');'; |
|
98 | + $html .= 'var marker = new GMarker(latlng, ' . json_encode($options) . ');'; |
|
99 | 99 | if ($marker->getParam('info')) { |
100 | - $html .= 'GEvent.addListener(marker, "click", function() { |
|
101 | - marker.openInfoWindowHtml("'.$marker->getParam('info').'"); |
|
100 | + $html .= 'GEvent.addListener(marker, "click", function() { |
|
101 | + marker.openInfoWindowHtml("'.$marker->getParam('info') . '"); |
|
102 | 102 | }); |
103 | 103 | GEvent.addListener(marker, "dragstart", function() { |
104 | 104 | map.closeInfoWindow(); |
@@ -118,13 +118,13 @@ discard block |
||
118 | 118 | $listeners = $marker->getListeners(); |
119 | 119 | foreach ($listeners as $type=>$functions) { |
120 | 120 | foreach ($functions as $function) { |
121 | - $html .= 'GEvent.addListener(marker, "'.$type.'", function() { |
|
122 | - '.$function.' |
|
121 | + $html .= 'GEvent.addListener(marker, "' . $type . '", function() { |
|
122 | + '.$function . ' |
|
123 | 123 | }); |
124 | 124 | '; |
125 | 125 | } |
126 | 126 | } |
127 | - $html .= 'map.addOverlay(marker);'; |
|
127 | + $html .= 'map.addOverlay(marker);'; |
|
128 | 128 | return $html; |
129 | 129 | } |
130 | 130 | } |
@@ -3,40 +3,40 @@ |
||
3 | 3 | class Nip_Service_Google_Charts |
4 | 4 | { |
5 | 5 | |
6 | - protected $_url = "http://chart.apis.google.com/chart"; |
|
6 | + protected $_url = "http://chart.apis.google.com/chart"; |
|
7 | 7 | |
8 | - /** |
|
9 | - * Chart factory |
|
10 | - * |
|
11 | - * @param string $type |
|
12 | - * @return Nip_Service_Google_Charts_Chart |
|
13 | - */ |
|
14 | - public function getChart($type = "Line") |
|
15 | - { |
|
16 | - $class = "Nip_Service_Google_Charts_Chart_" . $type; |
|
8 | + /** |
|
9 | + * Chart factory |
|
10 | + * |
|
11 | + * @param string $type |
|
12 | + * @return Nip_Service_Google_Charts_Chart |
|
13 | + */ |
|
14 | + public function getChart($type = "Line") |
|
15 | + { |
|
16 | + $class = "Nip_Service_Google_Charts_Chart_" . $type; |
|
17 | 17 | |
18 | - $chart = new $class(); |
|
19 | - $chart->setService($this); |
|
18 | + $chart = new $class(); |
|
19 | + $chart->setService($this); |
|
20 | 20 | |
21 | - return $chart; |
|
22 | - } |
|
21 | + return $chart; |
|
22 | + } |
|
23 | 23 | |
24 | - public function getURL() |
|
25 | - { |
|
26 | - return $this->_url; |
|
27 | - } |
|
24 | + public function getURL() |
|
25 | + { |
|
26 | + return $this->_url; |
|
27 | + } |
|
28 | 28 | |
29 | - /** |
|
30 | - * Singleton |
|
31 | - * |
|
32 | - * @return Nip_Service_Google_Charts |
|
33 | - */ |
|
34 | - static public function instance() |
|
35 | - { |
|
36 | - static $instance; |
|
37 | - if (!($instance instanceof self)) { |
|
38 | - $instance = new self(); |
|
39 | - } |
|
40 | - return $instance; |
|
41 | - } |
|
29 | + /** |
|
30 | + * Singleton |
|
31 | + * |
|
32 | + * @return Nip_Service_Google_Charts |
|
33 | + */ |
|
34 | + static public function instance() |
|
35 | + { |
|
36 | + static $instance; |
|
37 | + if (!($instance instanceof self)) { |
|
38 | + $instance = new self(); |
|
39 | + } |
|
40 | + return $instance; |
|
41 | + } |
|
42 | 42 | } |
43 | 43 | \ No newline at end of file |
@@ -3,63 +3,63 @@ |
||
3 | 3 | class Nip_Service_Google_Charts_Chart |
4 | 4 | { |
5 | 5 | |
6 | - protected $_service; |
|
7 | - protected $_params = array(); |
|
6 | + protected $_service; |
|
7 | + protected $_params = array(); |
|
8 | 8 | |
9 | - public function __toString() |
|
10 | - { |
|
11 | - return $this->render(); |
|
12 | - } |
|
9 | + public function __toString() |
|
10 | + { |
|
11 | + return $this->render(); |
|
12 | + } |
|
13 | 13 | |
14 | - public function render() |
|
15 | - { |
|
16 | - return '<img src="'.$this->getService()->getURL().'?'.http_build_query($this->getParams()).'" alt="" />'; |
|
17 | - } |
|
14 | + public function render() |
|
15 | + { |
|
16 | + return '<img src="'.$this->getService()->getURL().'?'.http_build_query($this->getParams()).'" alt="" />'; |
|
17 | + } |
|
18 | 18 | |
19 | - public function getParams() |
|
20 | - { |
|
21 | - return $this->_params; |
|
22 | - } |
|
19 | + public function getParams() |
|
20 | + { |
|
21 | + return $this->_params; |
|
22 | + } |
|
23 | 23 | |
24 | - /** |
|
25 | - * @return Nip_Service_Google_Charts |
|
26 | - */ |
|
27 | - public function getService() |
|
28 | - { |
|
29 | - return $this->_service; |
|
30 | - } |
|
24 | + /** |
|
25 | + * @return Nip_Service_Google_Charts |
|
26 | + */ |
|
27 | + public function getService() |
|
28 | + { |
|
29 | + return $this->_service; |
|
30 | + } |
|
31 | 31 | |
32 | 32 | |
33 | - public function setService($service) |
|
34 | - { |
|
35 | - $this->_service = $service; |
|
36 | - return $this; |
|
37 | - } |
|
33 | + public function setService($service) |
|
34 | + { |
|
35 | + $this->_service = $service; |
|
36 | + return $this; |
|
37 | + } |
|
38 | 38 | |
39 | - public function setSize($size) |
|
40 | - { |
|
41 | - $this->setParam("chs", $size); |
|
42 | - return $this; |
|
43 | - } |
|
39 | + public function setSize($size) |
|
40 | + { |
|
41 | + $this->setParam("chs", $size); |
|
42 | + return $this; |
|
43 | + } |
|
44 | 44 | |
45 | - public function setParam($name, $value) |
|
46 | - { |
|
47 | - $this->_params[$name] = $value; |
|
48 | - return $this; |
|
49 | - } |
|
45 | + public function setParam($name, $value) |
|
46 | + { |
|
47 | + $this->_params[$name] = $value; |
|
48 | + return $this; |
|
49 | + } |
|
50 | 50 | |
51 | - public function getParam($name) |
|
52 | - { |
|
53 | - return $this->_params[$name]; |
|
54 | - } |
|
51 | + public function getParam($name) |
|
52 | + { |
|
53 | + return $this->_params[$name]; |
|
54 | + } |
|
55 | 55 | |
56 | - public function setParams($params = array()) |
|
57 | - { |
|
58 | - if (count($params)) { |
|
59 | - foreach ($params as $name => $value) { |
|
60 | - $this->setParam($name, $value); |
|
61 | - } |
|
62 | - } |
|
63 | - return $this; |
|
64 | - } |
|
56 | + public function setParams($params = array()) |
|
57 | + { |
|
58 | + if (count($params)) { |
|
59 | + foreach ($params as $name => $value) { |
|
60 | + $this->setParam($name, $value); |
|
61 | + } |
|
62 | + } |
|
63 | + return $this; |
|
64 | + } |
|
65 | 65 | } |
66 | 66 | \ No newline at end of file |
@@ -13,7 +13,7 @@ |
||
13 | 13 | |
14 | 14 | public function render() |
15 | 15 | { |
16 | - return '<img src="'.$this->getService()->getURL().'?'.http_build_query($this->getParams()).'" alt="" />'; |
|
16 | + return '<img src="' . $this->getService()->getURL() . '?' . http_build_query($this->getParams()) . '" alt="" />'; |
|
17 | 17 | } |
18 | 18 | |
19 | 19 | public function getParams() |