Completed
Push — master ( 945d9a...e5db64 )
by Schlaefer
02:51
created
app/Plugin/Stopwatch/View/Helper/StopwatchHelper.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -59,7 +59,7 @@
 block discarded – undo
59 59
 	}
60 60
 
61 61
 	public function getResult() {
62
-		return "<pre>" . Stopwatch::getString() . "</pre>";
62
+		return "<pre>".Stopwatch::getString()."</pre>";
63 63
 	}
64 64
 
65 65
 }
Please login to merge, or discard this patch.
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -5,21 +5,21 @@  discard block
 block discarded – undo
5 5
 
6 6
 class StopwatchHelper extends AppHelper {
7 7
 
8
-	public $helpers = array(
9
-		'Html'
10
-	);
8
+    public $helpers = array(
9
+        'Html'
10
+    );
11 11
 
12
-	public function plot() {
13
-		$stopwatchData = Stopwatch::getJs();
14
-		$out = $this->Html->script(
15
-			array(
16
-				'Stopwatch.jquery.flot.min.js',
17
-				'Stopwatch.jquery.flot.stack.min.js'
18
-			)
19
-		);
20
-		$out .= '<div id="stopwatch-plot" style="width:300px;height:600px;"></div>';
21
-		$out .= '<div style="width: 300px;"><div id="stopwatch-exp">---</div><div id="stopwatch-legend"></div></div>';
22
-		$out .= $this->Html->scriptBlock(<<<EOF
12
+    public function plot() {
13
+        $stopwatchData = Stopwatch::getJs();
14
+        $out = $this->Html->script(
15
+            array(
16
+                'Stopwatch.jquery.flot.min.js',
17
+                'Stopwatch.jquery.flot.stack.min.js'
18
+            )
19
+        );
20
+        $out .= '<div id="stopwatch-plot" style="width:300px;height:600px;"></div>';
21
+        $out .= '<div style="width: 300px;"><div id="stopwatch-exp">---</div><div id="stopwatch-legend"></div></div>';
22
+        $out .= $this->Html->scriptBlock(<<<EOF
23 23
 		$.plot($("#stopwatch-plot"), {$stopwatchData}, {
24 24
 				series: {
25 25
 						stack: true,
@@ -54,13 +54,13 @@  discard block
 block discarded – undo
54 54
         }
55 55
     });
56 56
 EOF
57
-		);
58
-		return $out;
59
-	}
57
+        );
58
+        return $out;
59
+    }
60 60
 
61
-	public function getResult() {
62
-		return "<pre>" . Stopwatch::getString() . "</pre>";
63
-	}
61
+    public function getResult() {
62
+        return "<pre>" . Stopwatch::getString() . "</pre>";
63
+    }
64 64
 
65 65
 }
66 66
 
Please login to merge, or discard this patch.
app/Plugin/MailObfuscator/View/Helper/MailObfuscatorHelper.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -13,11 +13,11 @@
 block discarded – undo
13 13
 			if (empty($title) === false) {
14 14
 				$hasTitle = 1;
15 15
 			}
16
-			$rand = "moh_" . md5(mt_rand(1, 10000) . $addr);
16
+			$rand = "moh_".md5(mt_rand(1, 10000).$addr);
17 17
 			list($ttl, $dom) = explode('@', $addr);
18 18
 
19 19
 			// missing  style='unicode-bidi:bidi-override;direction:rtl;'
20
-			$mailto = '<a id="' . $rand . '" href="#" data-ttl="' . $ttl . '" data-dom="' . $dom . '">' . $title . '</a>';
20
+			$mailto = '<a id="'.$rand.'" href="#" data-ttl="'.$ttl.'" data-dom="'.$dom.'">'.$title.'</a>';
21 21
 			$mailto .= '<noscript><p>[You need to have Javascript enabled to see this mail address.]</p></noscript>';
22 22
 			$mailto .= $this->Html->scriptBlock(
23 23
 				"$(function(){
Please login to merge, or discard this patch.
Indentation   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -1,26 +1,26 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-	App::uses('AppHelper', 'View/Helper');
4
-
5
-	class MailObfuscatorHelper extends AppHelper {
6
-
7
-		public $helpers = [
8
-			'Html'
9
-		];
10
-
11
-		public function link($addr, $title = '') {
12
-			$hasTitle = 0;
13
-			if (empty($title) === false) {
14
-				$hasTitle = 1;
15
-			}
16
-			$rand = "moh_" . md5(mt_rand(1, 10000) . $addr);
17
-			list($ttl, $dom) = explode('@', $addr);
18
-
19
-			// missing  style='unicode-bidi:bidi-override;direction:rtl;'
20
-			$mailto = '<a id="' . $rand . '" href="#" data-ttl="' . $ttl . '" data-dom="' . $dom . '">' . $title . '</a>';
21
-			$mailto .= '<noscript><p>[You need to have Javascript enabled to see this mail address.]</p></noscript>';
22
-			$mailto .= $this->Html->scriptBlock(
23
-				"$(function(){
3
+    App::uses('AppHelper', 'View/Helper');
4
+
5
+    class MailObfuscatorHelper extends AppHelper {
6
+
7
+        public $helpers = [
8
+            'Html'
9
+        ];
10
+
11
+        public function link($addr, $title = '') {
12
+            $hasTitle = 0;
13
+            if (empty($title) === false) {
14
+                $hasTitle = 1;
15
+            }
16
+            $rand = "moh_" . md5(mt_rand(1, 10000) . $addr);
17
+            list($ttl, $dom) = explode('@', $addr);
18
+
19
+            // missing  style='unicode-bidi:bidi-override;direction:rtl;'
20
+            $mailto = '<a id="' . $rand . '" href="#" data-ttl="' . $ttl . '" data-dom="' . $dom . '">' . $title . '</a>';
21
+            $mailto .= '<noscript><p>[You need to have Javascript enabled to see this mail address.]</p></noscript>';
22
+            $mailto .= $this->Html->scriptBlock(
23
+                "$(function(){
24 24
 						var el = $('#$rand'),
25 25
 								mt = el.data('ttl') + '@' + el.data('dom');
26 26
 						el.attr('href', 'mai' + 'lto:' + mt);
@@ -28,8 +28,8 @@  discard block
 block discarded – undo
28 28
 					})
29 29
 			");
30 30
 
31
-			return $mailto;
32
-		}
31
+            return $mailto;
32
+        }
33 33
 
34
-	}
34
+    }
35 35
 
Please login to merge, or discard this patch.
app/Plugin/M/Lib/MCacheSupportCachelet.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@
 block discarded – undo
5 5
 	class MCacheSupportCachelet extends CacheSupportCachelet {
6 6
 
7 7
 		public function clear($id = null) {
8
-			touch(CakePlugin::path('M') . 'webroot/touch.txt');
8
+			touch(CakePlugin::path('M').'webroot/touch.txt');
9 9
 		}
10 10
 
11 11
 	}
12 12
\ No newline at end of file
Please login to merge, or discard this patch.
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -1,11 +1,11 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-	use Saito\Cache\CacheSupportCachelet;
3
+    use Saito\Cache\CacheSupportCachelet;
4 4
 
5
-	class MCacheSupportCachelet extends CacheSupportCachelet {
5
+    class MCacheSupportCachelet extends CacheSupportCachelet {
6 6
 
7
-		public function clear($id = null) {
8
-			touch(CakePlugin::path('M') . 'webroot/touch.txt');
9
-		}
7
+        public function clear($id = null) {
8
+            touch(CakePlugin::path('M') . 'webroot/touch.txt');
9
+        }
10 10
 
11
-	}
12 11
\ No newline at end of file
12
+    }
13 13
\ No newline at end of file
Please login to merge, or discard this patch.
app/Plugin/Detectors/Controller/Component/DetectorsComponent.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -95,7 +95,7 @@
 block discarded – undo
95 95
 			if ($this->_isBot === null) {
96 96
 				$agent = env('HTTP_USER_AGENT');
97 97
 				$imploded = implode('|', $this->_bots);
98
-				$this->_isBot = (bool)preg_match('/' . $imploded . '/i', $agent);
98
+				$this->_isBot = (bool) preg_match('/'.$imploded.'/i', $agent);
99 99
 			}
100 100
 			return $this->_isBot;
101 101
 		}
Please login to merge, or discard this patch.
Indentation   +113 added lines, -113 removed lines patch added patch discarded remove patch
@@ -1,123 +1,123 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-	App::uses('Component', 'Controller');
3
+    App::uses('Component', 'Controller');
4 4
 
5
-	/**
6
-	 * CakePHP Detectors
7
-	 *
8
-	 * @copyright     Copyright 2012, Saito (http://saito.siezi.org/)
9
-	 * @license       MIT License (http://www.opensource.org/licenses/mit-license.php)
10
-	 * @package 			Saito.Lib
11
-	 */
12
-	class DetectorsComponent extends Component {
5
+    /**
6
+     * CakePHP Detectors
7
+     *
8
+     * @copyright     Copyright 2012, Saito (http://saito.siezi.org/)
9
+     * @license       MIT License (http://www.opensource.org/licenses/mit-license.php)
10
+     * @package 			Saito.Lib
11
+     */
12
+    class DetectorsComponent extends Component {
13 13
 
14
-		/**
15
-		 * User agent snippets for bots
16
-		 *
17
-		 * @var array
18
-		 */
19
-		protected $_bots = [
20
-			'bot',
21
-			'crawl',
22
-			'spider',
23
-			'slurp',
24
-			'archive',
25
-			'baidu',
26
-			'yandex',
27
-			'search',
28
-			'Mediapartners',
29
-			'java',
30
-			'wget',
31
-			'curl',
32
-			'Commons-HttpClient',
33
-			'Python-urllib',
34
-			'libwww',
35
-			'httpunit',
36
-			'nutch',
37
-			'teoma',
38
-			'webmon ',
39
-			'httrack',
40
-			'convera',
41
-			'biglotron',
42
-			'grub.org',
43
-			'speedy',
44
-			'fluffy',
45
-			'bibnum.bnf',
46
-			'findlink',
47
-			'panscient',
48
-			'IOI',
49
-			'ips-agent',
50
-			'yanga',
51
-			'Voyager',
52
-			'CyberPatrol',
53
-			'postrank',
54
-			'page2rss',
55
-			'linkdex',
56
-			'ezooms',
57
-			'mail.ru',
58
-			'heritrix',
59
-			'findthatfile',
60
-			'Aboundex',
61
-			'summify',
62
-			'ec2linkfinder',
63
-			'facebook',
64
-			'yeti',
65
-			'RetrevoPageAnalyzer',
66
-			'sogou',
67
-			'wotbox',
68
-			'ichiro',
69
-			'drupact',
70
-			'coccoc',
71
-			'integromedb',
72
-			'siteexplorer.info',
73
-			'proximic',
74
-			'changedetection'
75
-		];
14
+        /**
15
+         * User agent snippets for bots
16
+         *
17
+         * @var array
18
+         */
19
+        protected $_bots = [
20
+            'bot',
21
+            'crawl',
22
+            'spider',
23
+            'slurp',
24
+            'archive',
25
+            'baidu',
26
+            'yandex',
27
+            'search',
28
+            'Mediapartners',
29
+            'java',
30
+            'wget',
31
+            'curl',
32
+            'Commons-HttpClient',
33
+            'Python-urllib',
34
+            'libwww',
35
+            'httpunit',
36
+            'nutch',
37
+            'teoma',
38
+            'webmon ',
39
+            'httrack',
40
+            'convera',
41
+            'biglotron',
42
+            'grub.org',
43
+            'speedy',
44
+            'fluffy',
45
+            'bibnum.bnf',
46
+            'findlink',
47
+            'panscient',
48
+            'IOI',
49
+            'ips-agent',
50
+            'yanga',
51
+            'Voyager',
52
+            'CyberPatrol',
53
+            'postrank',
54
+            'page2rss',
55
+            'linkdex',
56
+            'ezooms',
57
+            'mail.ru',
58
+            'heritrix',
59
+            'findthatfile',
60
+            'Aboundex',
61
+            'summify',
62
+            'ec2linkfinder',
63
+            'facebook',
64
+            'yeti',
65
+            'RetrevoPageAnalyzer',
66
+            'sogou',
67
+            'wotbox',
68
+            'ichiro',
69
+            'drupact',
70
+            'coccoc',
71
+            'integromedb',
72
+            'siteexplorer.info',
73
+            'proximic',
74
+            'changedetection'
75
+        ];
76 76
 
77
-		protected $_isBot = null;
77
+        protected $_isBot = null;
78 78
 
79
-		public function initialize(Controller $Controller) {
80
-			$Controller->request->addDetector('bot',
81
-				['callback' => [$this, 'isBot']]
82
-			);
79
+        public function initialize(Controller $Controller) {
80
+            $Controller->request->addDetector('bot',
81
+                ['callback' => [$this, 'isBot']]
82
+            );
83 83
 
84
-			$Controller->request->addDetector('preview',
85
-				['callback' => ['DetectorsComponent', 'isPreview']]
86
-			);
87
-		}
84
+            $Controller->request->addDetector('preview',
85
+                ['callback' => ['DetectorsComponent', 'isPreview']]
86
+            );
87
+        }
88 88
 
89
-		/**
90
-		 * Detects if a request is made by a spider/crawler
91
-		 *
92
-		 * @return bool
93
-		 */
94
-		public function isBot() {
95
-			if ($this->_isBot === null) {
96
-				$agent = env('HTTP_USER_AGENT');
97
-				$imploded = implode('|', $this->_bots);
98
-				$this->_isBot = (bool)preg_match('/' . $imploded . '/i', $agent);
99
-			}
100
-			return $this->_isBot;
101
-		}
89
+        /**
90
+         * Detects if a request is made by a spider/crawler
91
+         *
92
+         * @return bool
93
+         */
94
+        public function isBot() {
95
+            if ($this->_isBot === null) {
96
+                $agent = env('HTTP_USER_AGENT');
97
+                $imploded = implode('|', $this->_bots);
98
+                $this->_isBot = (bool)preg_match('/' . $imploded . '/i', $agent);
99
+            }
100
+            return $this->_isBot;
101
+        }
102 102
 
103
-		/**
104
-		 * Detect if a request was made by a browser preview feature
105
-		 *
106
-		 * Adds the isPreview() method to the controllers request object.
107
-		 *
108
-		 * Supports:
109
-		 *
110
-		 * - Safari top sites
111
-		 * - Firefox prefetch
112
-		 *
113
-		 * @return bool
114
-		 */
115
-		public static function isPreview() {
116
-			$_isPreview = (
117
-					(env('HTTP_X_PURPOSE') === 'preview') // Safari
118
-					|| (env('HTTP_X_MOZ') === 'prefetch') // Firefox
119
-			);
120
-			return $_isPreview;
121
-		}
103
+        /**
104
+         * Detect if a request was made by a browser preview feature
105
+         *
106
+         * Adds the isPreview() method to the controllers request object.
107
+         *
108
+         * Supports:
109
+         *
110
+         * - Safari top sites
111
+         * - Firefox prefetch
112
+         *
113
+         * @return bool
114
+         */
115
+        public static function isPreview() {
116
+            $_isPreview = (
117
+                    (env('HTTP_X_PURPOSE') === 'preview') // Safari
118
+                    || (env('HTTP_X_MOZ') === 'prefetch') // Firefox
119
+            );
120
+            return $_isPreview;
121
+        }
122 122
 
123
-	}
124 123
\ No newline at end of file
124
+    }
125 125
\ No newline at end of file
Please login to merge, or discard this patch.
app/Plugin/Sitemap/Test/Case/Controller/SitemapsControllerTest.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@
 block discarded – undo
36 36
 			$result = $this->testAction('/sitemaps/index.xml',
37 37
 					['method' => 'GET', 'return' => 'contents']);
38 38
 			$baseUrl = $this->controller->base;
39
-			$this->assertContains($baseUrl . '/sitemaps/file/sitemap-entries-1-20000.xml',
39
+			$this->assertContains($baseUrl.'/sitemaps/file/sitemap-entries-1-20000.xml',
40 40
 					$result);
41 41
 		}
42 42
 
Please login to merge, or discard this patch.
Indentation   +57 added lines, -57 removed lines patch added patch discarded remove patch
@@ -1,64 +1,64 @@
 block discarded – undo
1 1
 <?php
2
-	App::uses('SitemapsController', 'Sitemap.Controller');
2
+    App::uses('SitemapsController', 'Sitemap.Controller');
3 3
 
4
-	/**
5
-	 * SitemapsController Test Case
6
-	 *
7
-	 */
8
-	class SitemapsControllerTest extends ControllerTestCase {
4
+    /**
5
+     * SitemapsController Test Case
6
+     *
7
+     */
8
+    class SitemapsControllerTest extends ControllerTestCase {
9 9
 
10
-		/**
11
-		 * Fixtures
12
-		 *
13
-		 * @var array
14
-		 */
15
-		public $fixtures = array(
16
-				'setting',
17
-				'user',
18
-				'user_online',
19
-				'bookmark',
20
-				'entry',
21
-				'category',
22
-				'esevent',
23
-				'esnotification',
24
-				'user_read',
25
-				'upload'
26
-		);
10
+        /**
11
+         * Fixtures
12
+         *
13
+         * @var array
14
+         */
15
+        public $fixtures = array(
16
+                'setting',
17
+                'user',
18
+                'user_online',
19
+                'bookmark',
20
+                'entry',
21
+                'category',
22
+                'esevent',
23
+                'esnotification',
24
+                'user_read',
25
+                'upload'
26
+        );
27 27
 
28
-		/**
29
-		 * testIndex method
30
-		 *
31
-		 * basic test that at least something is in the output
32
-		 *
33
-		 * @return void
34
-		 */
35
-		public function testIndex() {
36
-			$result = $this->testAction('/sitemaps/index.xml',
37
-					['method' => 'GET', 'return' => 'contents']);
38
-			$baseUrl = $this->controller->base;
39
-			$this->assertContains($baseUrl . '/sitemaps/file/sitemap-entries-1-20000.xml',
40
-					$result);
41
-		}
28
+        /**
29
+         * testIndex method
30
+         *
31
+         * basic test that at least something is in the output
32
+         *
33
+         * @return void
34
+         */
35
+        public function testIndex() {
36
+            $result = $this->testAction('/sitemaps/index.xml',
37
+                    ['method' => 'GET', 'return' => 'contents']);
38
+            $baseUrl = $this->controller->base;
39
+            $this->assertContains($baseUrl . '/sitemaps/file/sitemap-entries-1-20000.xml',
40
+                    $result);
41
+        }
42 42
 
43
-		/**
44
-		 * testFile method
45
-		 *
46
-		 * basic test that at least something is in the output
47
-		 *
48
-		 * @return void
49
-		 */
50
-		public function testFile() {
51
-			$result = $this->testAction('/sitemaps/file/sitemap-entries-1-20000.xml',
52
-					['method' => 'GET', 'return' => 'contents']);
53
-			$baseUrl = $this->controller->base;
54
-			$this->assertContains("{$baseUrl}/entries/view/1</loc>", $result);
55
-			$this->assertNotContains("{$baseUrl}/entries/view/4</loc>", $result);
56
-			$this->assertNotContains("{$baseUrl}/entries/view/6</loc>", $result);
57
-		}
43
+        /**
44
+         * testFile method
45
+         *
46
+         * basic test that at least something is in the output
47
+         *
48
+         * @return void
49
+         */
50
+        public function testFile() {
51
+            $result = $this->testAction('/sitemaps/file/sitemap-entries-1-20000.xml',
52
+                    ['method' => 'GET', 'return' => 'contents']);
53
+            $baseUrl = $this->controller->base;
54
+            $this->assertContains("{$baseUrl}/entries/view/1</loc>", $result);
55
+            $this->assertNotContains("{$baseUrl}/entries/view/4</loc>", $result);
56
+            $this->assertNotContains("{$baseUrl}/entries/view/6</loc>", $result);
57
+        }
58 58
 
59
-		public function setUp() {
60
-			Cache::clear(false, 'sitemap');
61
-			parent::setUp();
62
-		}
59
+        public function setUp() {
60
+            Cache::clear(false, 'sitemap');
61
+            parent::setUp();
62
+        }
63 63
 
64
-	}
64
+    }
Please login to merge, or discard this patch.
app/Plugin/Sitemap/View/Helper/SitemapHelper.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@
 block discarded – undo
5 5
 	class SitemapHelper extends AppHelper {
6 6
 
7 7
 		public function sitemapUrl() {
8
-			return $this->baseUrl() . 'sitemap.xml';
8
+			return $this->baseUrl().'sitemap.xml';
9 9
 		}
10 10
 
11 11
 		public function baseUrl() {
Please login to merge, or discard this patch.
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -1,15 +1,15 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-	App::uses('AppHelper', 'View/Helper');
3
+    App::uses('AppHelper', 'View/Helper');
4 4
 
5
-	class SitemapHelper extends AppHelper {
5
+    class SitemapHelper extends AppHelper {
6 6
 
7
-		public function sitemapUrl() {
8
-			return $this->baseUrl() . 'sitemap.xml';
9
-		}
7
+        public function sitemapUrl() {
8
+            return $this->baseUrl() . 'sitemap.xml';
9
+        }
10 10
 
11
-		public function baseUrl() {
12
-			return $this->url('/', true);
13
-		}
11
+        public function baseUrl() {
12
+            return $this->url('/', true);
13
+        }
14 14
 
15
-	}
15
+    }
Please login to merge, or discard this patch.
app/Plugin/Sitemap/Lib/SitemapEntries.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -88,7 +88,7 @@
 block discarded – undo
88 88
 					$changefreq = 'hourly';
89 89
 				}
90 90
 				$urls[] = [
91
-						'loc' => 'entries/view/' . $entry['Entry']['id'],
91
+						'loc' => 'entries/view/'.$entry['Entry']['id'],
92 92
 						'lastmod' => Date('c', $lastmod),
93 93
 						'changefreq' => $changefreq
94 94
 				];
Please login to merge, or discard this patch.
Indentation   +89 added lines, -89 removed lines patch added patch discarded remove patch
@@ -1,101 +1,101 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-	App::uses('SitemapGenerator', 'Sitemap.Lib');
3
+    App::uses('SitemapGenerator', 'Sitemap.Lib');
4 4
 
5
-	class SitemapEntries extends SitemapGenerator {
5
+    class SitemapEntries extends SitemapGenerator {
6 6
 
7
-		protected $_type = 'entries';
7
+        protected $_type = 'entries';
8 8
 
9
-		public function files() {
10
-			$this->_Controller->loadModel('Entry');
11
-			$entry = $this->_Controller->Entry->find('first',
12
-					[
13
-							'contain' => ['Category'],
14
-							'conditions' => ['Category.accession' => 0],
15
-							'order' => ['Entry.id' => 'DESC']
16
-					]
17
-			);
9
+        public function files() {
10
+            $this->_Controller->loadModel('Entry');
11
+            $entry = $this->_Controller->Entry->find('first',
12
+                    [
13
+                            'contain' => ['Category'],
14
+                            'conditions' => ['Category.accession' => 0],
15
+                            'order' => ['Entry.id' => 'DESC']
16
+                    ]
17
+            );
18 18
 
19
-			$count = (empty($entry)) ? 0 : $entry['Entry']['id'];
20
-			$count = intval($count / $this->_divider) + 1;
21
-			$files = [];
22
-			for ($i = 0; $i < $count; $i++) {
23
-				$start = $i * $this->_divider + 1;
24
-				$end = ($i + 1) * $this->_divider;
25
-				$files[] = ['url' => $this->_filename([$start, $end])];
26
-			}
27
-			return $files;
28
-		}
19
+            $count = (empty($entry)) ? 0 : $entry['Entry']['id'];
20
+            $count = intval($count / $this->_divider) + 1;
21
+            $files = [];
22
+            for ($i = 0; $i < $count; $i++) {
23
+                $start = $i * $this->_divider + 1;
24
+                $end = ($i + 1) * $this->_divider;
25
+                $files[] = ['url' => $this->_filename([$start, $end])];
26
+            }
27
+            return $files;
28
+        }
29 29
 
30
-		/**
31
-		 *
32
-		 * @param $params
33
-		 * @return array|mixed
34
-		 * @throws InvalidArgumentException
35
-		 */
36
-		protected function _parseParams($params) {
37
-			$start = filter_var($params[0], FILTER_VALIDATE_INT);
38
-			$end = filter_var($params[1], FILTER_VALIDATE_INT);
39
-			if (!$start || !$end || ($end - $start) > $this->_divider ||
40
-					// entries must be in even divider range
41
-					// prevents maliciously spamming the server with new cache files
42
-					($start - 1) % $this->_divider !== 0 ||
43
-					($end) % $this->_divider !== 0
30
+        /**
31
+         *
32
+         * @param $params
33
+         * @return array|mixed
34
+         * @throws InvalidArgumentException
35
+         */
36
+        protected function _parseParams($params) {
37
+            $start = filter_var($params[0], FILTER_VALIDATE_INT);
38
+            $end = filter_var($params[1], FILTER_VALIDATE_INT);
39
+            if (!$start || !$end || ($end - $start) > $this->_divider ||
40
+                    // entries must be in even divider range
41
+                    // prevents maliciously spamming the server with new cache files
42
+                    ($start - 1) % $this->_divider !== 0 ||
43
+                    ($end) % $this->_divider !== 0
44 44
 
45
-			) {
46
-				throw new InvalidArgumentException;
47
-			}
48
-			return ['start' => $start, 'end' => $end];
49
-		}
45
+            ) {
46
+                throw new InvalidArgumentException;
47
+            }
48
+            return ['start' => $start, 'end' => $end];
49
+        }
50 50
 
51
-		protected function _content($params) {
52
-			$now = time();
53
-			$filename = $this->_filename([$params['start'], $params['end']]);
54
-			$cache = Cache::read($filename, 'sitemap');
55
-			if ($cache) {
56
-				return $cache;
57
-			}
51
+        protected function _content($params) {
52
+            $now = time();
53
+            $filename = $this->_filename([$params['start'], $params['end']]);
54
+            $cache = Cache::read($filename, 'sitemap');
55
+            if ($cache) {
56
+                return $cache;
57
+            }
58 58
 
59
-			$this->_Controller->loadModel('Entry');
60
-			$entries = $this->_Controller->Entry->find('all',
61
-					[
62
-							'contain' => ['Category'],
63
-							'conditions' =>
64
-									[
65
-											'Category.accession' => 0,
66
-											'Entry.id >=' => $params['start'],
67
-											'Entry.id <=' => $params['end'],
68
-									],
69
-							'fields' => ['Entry.id', 'Entry.time', 'Entry.edited']
70
-					]
71
-			);
72
-			$urls = [];
73
-			if (empty($entries)) {
74
-				return $urls;
75
-			}
76
-			foreach ($entries as $key => $entry) {
77
-				unset($entries[$key]);
78
-				if (!empty($entry['Entry']['edited'])) {
79
-					$lastmod = strtotime($entry['Entry']['edited']);
80
-				} else {
81
-					$lastmod = strtotime($entry['Entry']['time']);
82
-				}
83
-				if ($now > ($lastmod + (3 * DAY))) { // old entries
84
-					$changefreq = 'monthly';
85
-				} elseif ($now > ($lastmod + DAY)) { // recently active entries
86
-					$changefreq = 'daily';
87
-				} else { // currently active entries
88
-					$changefreq = 'hourly';
89
-				}
90
-				$urls[] = [
91
-						'loc' => 'entries/view/' . $entry['Entry']['id'],
92
-						'lastmod' => Date('c', $lastmod),
93
-						'changefreq' => $changefreq
94
-				];
95
-			}
59
+            $this->_Controller->loadModel('Entry');
60
+            $entries = $this->_Controller->Entry->find('all',
61
+                    [
62
+                            'contain' => ['Category'],
63
+                            'conditions' =>
64
+                                    [
65
+                                            'Category.accession' => 0,
66
+                                            'Entry.id >=' => $params['start'],
67
+                                            'Entry.id <=' => $params['end'],
68
+                                    ],
69
+                            'fields' => ['Entry.id', 'Entry.time', 'Entry.edited']
70
+                    ]
71
+            );
72
+            $urls = [];
73
+            if (empty($entries)) {
74
+                return $urls;
75
+            }
76
+            foreach ($entries as $key => $entry) {
77
+                unset($entries[$key]);
78
+                if (!empty($entry['Entry']['edited'])) {
79
+                    $lastmod = strtotime($entry['Entry']['edited']);
80
+                } else {
81
+                    $lastmod = strtotime($entry['Entry']['time']);
82
+                }
83
+                if ($now > ($lastmod + (3 * DAY))) { // old entries
84
+                    $changefreq = 'monthly';
85
+                } elseif ($now > ($lastmod + DAY)) { // recently active entries
86
+                    $changefreq = 'daily';
87
+                } else { // currently active entries
88
+                    $changefreq = 'hourly';
89
+                }
90
+                $urls[] = [
91
+                        'loc' => 'entries/view/' . $entry['Entry']['id'],
92
+                        'lastmod' => Date('c', $lastmod),
93
+                        'changefreq' => $changefreq
94
+                ];
95
+            }
96 96
 
97
-			Cache::write($filename, $urls, 'sitemap');
98
-			return $urls;
99
-		}
97
+            Cache::write($filename, $urls, 'sitemap');
98
+            return $urls;
99
+        }
100 100
 
101
-	}
102 101
\ No newline at end of file
102
+    }
103 103
\ No newline at end of file
Please login to merge, or discard this patch.
app/Plugin/Sitemap/Lib/SitemapGenerator.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -77,7 +77,7 @@
 block discarded – undo
77 77
 		protected function _filename($params = []) {
78 78
 			$filename = "sitemap-{$this->_type}";
79 79
 			if ($params) {
80
-				$filename .= '-' . implode('-', $params);
80
+				$filename .= '-'.implode('-', $params);
81 81
 			}
82 82
 			return $filename;
83 83
 		}
Please login to merge, or discard this patch.
Indentation   +72 added lines, -72 removed lines patch added patch discarded remove patch
@@ -1,85 +1,85 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-	abstract class SitemapGenerator {
3
+    abstract class SitemapGenerator {
4 4
 
5
-		/**
6
-		 * Number of URLs per sitemap file.
7
-		 *
8
-		 * Mostly bound by memory available to PHP on server
9
-		 *
10
-		 * @var int
11
-		 */
12
-		protected $_divider = 20000;
5
+        /**
6
+         * Number of URLs per sitemap file.
7
+         *
8
+         * Mostly bound by memory available to PHP on server
9
+         *
10
+         * @var int
11
+         */
12
+        protected $_divider = 20000;
13 13
 
14
-		protected $_Controller;
14
+        protected $_Controller;
15 15
 
16
-		protected $_type = null;
16
+        protected $_type = null;
17 17
 
18
-		/**
19
-		 * @param Controller $Controller
20
-		 * @throws Exception
21
-		 */
22
-		public function __construct(Controller $Controller) {
23
-			$this->_Controller = $Controller;
24
-			if ($this->_type === null) {
25
-				throw new Exception('SitemapGenerator type not set.');
26
-			}
27
-			return $this;
28
-		}
18
+        /**
19
+         * @param Controller $Controller
20
+         * @throws Exception
21
+         */
22
+        public function __construct(Controller $Controller) {
23
+            $this->_Controller = $Controller;
24
+            if ($this->_type === null) {
25
+                throw new Exception('SitemapGenerator type not set.');
26
+            }
27
+            return $this;
28
+        }
29 29
 
30
-		/**
31
-		 * Returns sitemap file
32
-		 *
33
-		 * @return array keys: 'url'
34
-		 */
35
-		abstract public function files();
30
+        /**
31
+         * Returns sitemap file
32
+         *
33
+         * @return array keys: 'url'
34
+         */
35
+        abstract public function files();
36 36
 
37
-		public function content($file) {
38
-			list($type, $params) = $this->_parseFilename($file);
39
-			if ($type !== $this->_type) {
40
-				return false;
41
-			}
42
-			return $this->_content($this->_parseParams($params));
43
-		}
37
+        public function content($file) {
38
+            list($type, $params) = $this->_parseFilename($file);
39
+            if ($type !== $this->_type) {
40
+                return false;
41
+            }
42
+            return $this->_content($this->_parseParams($params));
43
+        }
44 44
 
45
-		/**
46
-		 *
47
-		 * @param $name
48
-		 * @return array
49
-		 * @throws InvalidArgumentException
50
-		 */
51
-		protected function _parseFilename($name) {
52
-			preg_match('/sitemap-(?P<type>\w*)(-(?P<params>.*))?(\.(\w*))?$/',
53
-					$name,
54
-					$matches);
55
-			if (empty($matches['type'])) {
56
-				throw new InvalidArgumentException;
57
-			}
58
-			return [$matches['type'], explode('-', $matches['params'])];
59
-		}
45
+        /**
46
+         *
47
+         * @param $name
48
+         * @return array
49
+         * @throws InvalidArgumentException
50
+         */
51
+        protected function _parseFilename($name) {
52
+            preg_match('/sitemap-(?P<type>\w*)(-(?P<params>.*))?(\.(\w*))?$/',
53
+                    $name,
54
+                    $matches);
55
+            if (empty($matches['type'])) {
56
+                throw new InvalidArgumentException;
57
+            }
58
+            return [$matches['type'], explode('-', $matches['params'])];
59
+        }
60 60
 
61
-		/**
62
-		 * Parse and validate params. Should throw exception if params are not valid.
63
-		 *
64
-		 * @param $params
65
-		 * @return mixed processed params
66
-		 */
67
-		abstract protected function _parseParams($params);
61
+        /**
62
+         * Parse and validate params. Should throw exception if params are not valid.
63
+         *
64
+         * @param $params
65
+         * @return mixed processed params
66
+         */
67
+        abstract protected function _parseParams($params);
68 68
 
69
-		/**
70
-		 * Generate urls
71
-		 *
72
-		 * @param $params
73
-		 * @return string urls
74
-		 */
75
-		abstract protected function _content($params);
69
+        /**
70
+         * Generate urls
71
+         *
72
+         * @param $params
73
+         * @return string urls
74
+         */
75
+        abstract protected function _content($params);
76 76
 
77
-		protected function _filename($params = []) {
78
-			$filename = "sitemap-{$this->_type}";
79
-			if ($params) {
80
-				$filename .= '-' . implode('-', $params);
81
-			}
82
-			return $filename;
83
-		}
77
+        protected function _filename($params = []) {
78
+            $filename = "sitemap-{$this->_type}";
79
+            if ($params) {
80
+                $filename .= '-' . implode('-', $params);
81
+            }
82
+            return $filename;
83
+        }
84 84
 
85
-	}
86 85
\ No newline at end of file
86
+    }
87 87
\ No newline at end of file
Please login to merge, or discard this patch.
app/Plugin/Api/Controller/ApiUsersController.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -58,7 +58,7 @@
 block discarded – undo
58 58
 				throw new BadRequestException('User id is missing.');
59 59
 			}
60 60
 			$_userId = $this->request->data['id'];
61
-			if ((int)$_userId !== $this->CurrentUser->getId()) {
61
+			if ((int) $_userId !== $this->CurrentUser->getId()) {
62 62
 				throw new ForbiddenException(sprintf(
63 63
 					'Not allowed to logout user with id `%s`.',
64 64
 					$_userId
Please login to merge, or discard this patch.
Indentation   +84 added lines, -84 removed lines patch added patch discarded remove patch
@@ -1,112 +1,112 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-	App::uses('ApiAppController', 'Api.Controller');
3
+    App::uses('ApiAppController', 'Api.Controller');
4 4
 
5
-	class ApiUsersController extends ApiAppController {
5
+    class ApiUsersController extends ApiAppController {
6 6
 
7
-		public $uses = [
8
-			'User'
9
-		];
7
+        public $uses = [
8
+            'User'
9
+        ];
10 10
 
11
-		public $helpers = [
12
-			'Api.Api'
13
-		];
11
+        public $helpers = [
12
+            'Api.Api'
13
+        ];
14 14
 
15
-		public $saveKeysToOutput = [];
15
+        public $saveKeysToOutput = [];
16 16
 
17 17
 /**
18 18
  * @throws UnauthorizedException
19 19
  * @throws BadRequestException
20 20
  */
21
-		public function login() {
22
-			$this->CurrentUser->logout();
21
+        public function login() {
22
+            $this->CurrentUser->logout();
23 23
 
24
-			if (isset($this->request->data['username']) === false) {
25
-				throw new BadRequestException('Field `username` is missing.');
26
-			}
24
+            if (isset($this->request->data['username']) === false) {
25
+                throw new BadRequestException('Field `username` is missing.');
26
+            }
27 27
 
28
-			if (isset($this->request->data['password']) === false) {
29
-				throw new BadRequestException('Field `password` is missing.');
30
-			}
28
+            if (isset($this->request->data['password']) === false) {
29
+                throw new BadRequestException('Field `password` is missing.');
30
+            }
31 31
 
32
-			$this->request->data = [
33
-				'User' => [
34
-					'username' => $this->request->data['username'],
35
-					'password' => $this->request->data['password'],
36
-					'remember_me' => empty($this->request->data['remember_me']) ? false : true
37
-				]
38
-			];
32
+            $this->request->data = [
33
+                'User' => [
34
+                    'username' => $this->request->data['username'],
35
+                    'password' => $this->request->data['password'],
36
+                    'remember_me' => empty($this->request->data['remember_me']) ? false : true
37
+                ]
38
+            ];
39 39
 
40
-			$this->CurrentUser->login();
40
+            $this->CurrentUser->login();
41 41
 
42
-			if ($this->CurrentUser->isLoggedIn() !== true) {
43
-				throw new UnauthorizedException(
44
-					'Login failed. Check your username and password.'
45
-				);
46
-			}
47
-		}
42
+            if ($this->CurrentUser->isLoggedIn() !== true) {
43
+                throw new UnauthorizedException(
44
+                    'Login failed. Check your username and password.'
45
+                );
46
+            }
47
+        }
48 48
 
49 49
 /**
50 50
  * @throws BadRequestException
51 51
  * @throws ForbiddenException
52 52
  */
53
-		public function logout() {
54
-			if (!$this->CurrentUser->isLoggedIn()) {
55
-				throw new ForbiddenException('You are not logged in.');
56
-			}
57
-			if (!isset($this->request->data['id'])) {
58
-				throw new BadRequestException('User id is missing.');
59
-			}
60
-			$_userId = $this->request->data['id'];
61
-			if ((int)$_userId !== $this->CurrentUser->getId()) {
62
-				throw new ForbiddenException(sprintf(
63
-					'Not allowed to logout user with id `%s`.',
64
-					$_userId
65
-				));
66
-			}
67
-			$this->CurrentUser->logout();
68
-		}
53
+        public function logout() {
54
+            if (!$this->CurrentUser->isLoggedIn()) {
55
+                throw new ForbiddenException('You are not logged in.');
56
+            }
57
+            if (!isset($this->request->data['id'])) {
58
+                throw new BadRequestException('User id is missing.');
59
+            }
60
+            $_userId = $this->request->data['id'];
61
+            if ((int)$_userId !== $this->CurrentUser->getId()) {
62
+                throw new ForbiddenException(sprintf(
63
+                    'Not allowed to logout user with id `%s`.',
64
+                    $_userId
65
+                ));
66
+            }
67
+            $this->CurrentUser->logout();
68
+        }
69 69
 
70 70
 /**
71 71
  * @throws InvalidArgumentException
72 72
  * @throws ForbiddenException
73 73
  */
74
-		public function markasread() {
75
-			if (!isset($this->request->data['id'])) {
76
-				throw new InvalidArgumentException('User id is missing.');
77
-			}
78
-			$_userId = $this->request->data['id'];
79
-			if (!$this->CurrentUser->isLoggedIn() ||
80
-					$this->CurrentUser->getId() != $_userId
81
-			) {
82
-				throw new ForbiddenException(sprintf(
83
-					'You are not authorized for user id `%s`.',
84
-					$_userId
85
-				));
86
-			}
87
-			if (isset($this->request->data['last_refresh'])) {
88
-				$timestamp = strtotime($this->request->data['last_refresh']);
89
-				if ($timestamp === false) {
90
-					throw new InvalidArgumentException(sprintf(
91
-						'`%s` is not a valid timestamp string.',
92
-						$timestamp
93
-					));
94
-				}
95
-				$isServerTimestampNewer =
96
-						strtotime($this->CurrentUser['last_refresh']) > $timestamp;
97
-				if ($isServerTimestampNewer === false) {
98
-					$this->CurrentUser->LastRefresh->set(date("Y-m-d H:i:s", $timestamp));
99
-				}
100
-			} else {
101
-				$this->CurrentUser->LastRefresh->set('now');
102
-			}
103
-			$this->set('id', $_userId);
104
-			$this->set('last_refresh', $this->CurrentUser['last_refresh']);
105
-		}
74
+        public function markasread() {
75
+            if (!isset($this->request->data['id'])) {
76
+                throw new InvalidArgumentException('User id is missing.');
77
+            }
78
+            $_userId = $this->request->data['id'];
79
+            if (!$this->CurrentUser->isLoggedIn() ||
80
+                    $this->CurrentUser->getId() != $_userId
81
+            ) {
82
+                throw new ForbiddenException(sprintf(
83
+                    'You are not authorized for user id `%s`.',
84
+                    $_userId
85
+                ));
86
+            }
87
+            if (isset($this->request->data['last_refresh'])) {
88
+                $timestamp = strtotime($this->request->data['last_refresh']);
89
+                if ($timestamp === false) {
90
+                    throw new InvalidArgumentException(sprintf(
91
+                        '`%s` is not a valid timestamp string.',
92
+                        $timestamp
93
+                    ));
94
+                }
95
+                $isServerTimestampNewer =
96
+                        strtotime($this->CurrentUser['last_refresh']) > $timestamp;
97
+                if ($isServerTimestampNewer === false) {
98
+                    $this->CurrentUser->LastRefresh->set(date("Y-m-d H:i:s", $timestamp));
99
+                }
100
+            } else {
101
+                $this->CurrentUser->LastRefresh->set('now');
102
+            }
103
+            $this->set('id', $_userId);
104
+            $this->set('last_refresh', $this->CurrentUser['last_refresh']);
105
+        }
106 106
 
107
-		public function beforeFilter() {
108
-			parent::beforeFilter();
109
-			$this->Auth->allow('login', 'logout');
110
-		}
107
+        public function beforeFilter() {
108
+            parent::beforeFilter();
109
+            $this->Auth->allow('login', 'logout');
110
+        }
111 111
 
112
-	}
112
+    }
Please login to merge, or discard this patch.