Completed
Push — master ( deff22...6db444 )
by
unknown
02:23
created
assets/snippets/DocLister/snippet.DLSitemap.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -1,17 +1,17 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 include_once(MODX_BASE_PATH . 'assets/lib/APIHelpers.class.php');
3
-if (!isset($params['config'])) $params['config'] = "sitemap:core";
4
-if (!isset($schema)) $schema = "http://www.sitemaps.org/schemas/sitemap/0.9";
3
+if ( ! isset($params['config'])) $params['config'] = "sitemap:core";
4
+if ( ! isset($schema)) $schema = "http://www.sitemaps.org/schemas/sitemap/0.9";
5 5
 $prepare = array();
6 6
 $prepare[] = \APIhelpers::getkey($modx->event->params, 'BeforePrepare', '');
7 7
 $prepare[] = 'DLSitemap::prepare';
8 8
 $prepare[] = \APIhelpers::getkey($modx->event->params, 'AfterPrepare', '');
9 9
 $params['prepare'] = trim(implode(",", $prepare), ',');
10
-if(!class_exists("DLSitemap")){
11
-    class DLSitemap{
10
+if ( ! class_exists("DLSitemap")) {
11
+    class DLSitemap {
12 12
         public static function prepare(array $data = array(), DocumentParser $modx, $_DocLister)
13 13
         {
14
-            $data['date'] = !empty($data['editedon']) ? $data['editedon'] : $data['createdon'];
14
+            $data['date'] = ! empty($data['editedon']) ? $data['editedon'] : $data['createdon'];
15 15
             $datediff = floor((time() - $data['date']) / 86400);
16 16
             if ($datediff <= 1) {
17 17
                 $data['priority'] = '1.0';
@@ -32,10 +32,10 @@  discard block
 block discarded – undo
32 32
             }
33 33
             $priorityField = $_DocLister->getCFGDef('priority', 'tv.sitemap_priority');
34 34
             $changefreqField = $_DocLister->getCFGDef('changefreq', 'tv.sitemap_changefreq');
35
-            if (!empty($data[$priorityField])) {
35
+            if ( ! empty($data[$priorityField])) {
36 36
                 $data['priority'] = $data[$priorityField];
37 37
             }
38
-            if (!empty($data[$changefreqField])) {
38
+            if ( ! empty($data[$changefreqField])) {
39 39
                 $data['update'] = $data[$changefreqField];
40 40
             }
41 41
 
@@ -44,8 +44,8 @@  discard block
 block discarded – undo
44 44
     }
45 45
 }
46 46
 
47
-$out = $modx->runSnippet('DocLister',$params);
48
-if (!empty($out)) {
47
+$out = $modx->runSnippet('DocLister', $params);
48
+if ( ! empty($out)) {
49 49
     $out = "<?xml version=\"1.0\" encoding=\"{$modx->config['modx_charset']}\"?>\n<urlset xmlns=\"{$schema}\">{$out}\n</urlset>";
50 50
 }
51 51
 
Please login to merge, or discard this patch.
Braces   +19 added lines, -14 removed lines patch added patch discarded remove patch
@@ -1,41 +1,46 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 include_once(MODX_BASE_PATH . 'assets/lib/APIHelpers.class.php');
3
-if (!isset($params['config'])) $params['config'] = "sitemap:core";
4
-if (!isset($schema)) $schema = "http://www.sitemaps.org/schemas/sitemap/0.9";
3
+if (!isset($params['config'])) {
4
+    $params['config'] = "sitemap:core";
5
+}
6
+if (!isset($schema)) {
7
+    $schema = "http://www.sitemaps.org/schemas/sitemap/0.9";
8
+}
5 9
 $prepare = array();
6 10
 $prepare[] = \APIhelpers::getkey($modx->event->params, 'BeforePrepare', '');
7 11
 $prepare[] = 'DLSitemap::prepare';
8 12
 $prepare[] = \APIhelpers::getkey($modx->event->params, 'AfterPrepare', '');
9 13
 $params['prepare'] = trim(implode(",", $prepare), ',');
10
-if(!class_exists("DLSitemap")){
11
-    class DLSitemap{
12
-        public static function prepare(array $data = array(), DocumentParser $modx, $_DocLister)
13
-        {
14
+if(!class_exists("DLSitemap")) {
15
+    class DLSitemap
16
+    {
17
+        public static function prepare(array $data = array(), DocumentParser $modx, $_DocLister)
18
+        {
14 19
             $data['date'] = !empty($data['editedon']) ? $data['editedon'] : $data['createdon'];
15 20
             $datediff = floor((time() - $data['date']) / 86400);
16
-            if ($datediff <= 1) {
21
+            if ($datediff <= 1) {
17 22
                 $data['priority'] = '1.0';
18 23
                 $data['update'] = 'daily';
19
-            } elseif (($datediff > 1) && ($datediff <= 7)) {
24
+            } elseif (($datediff > 1) && ($datediff <= 7)) {
20 25
                 $data['priority'] = '0.75';
21 26
                 $data['update'] = 'weekly';
22
-            } elseif (($datediff > 7) && ($datediff <= 30)) {
27
+            } elseif (($datediff > 7) && ($datediff <= 30)) {
23 28
                 $data['priority'] = '0.50';
24 29
                 $data['update'] = 'weekly';
25
-            } else {
30
+            } else {
26 31
                 $data['priority'] = '0.25';
27 32
                 $data['update'] = 'monthly';
28 33
             }
29 34
             $dateFormat = $_DocLister->getCFGDef('dateFormat', '%FT%T%z');
30
-            if ($dateFormat) {
35
+            if ($dateFormat) {
31 36
                 $data['date'] = strftime($dateFormat, $data['date']);
32 37
             }
33 38
             $priorityField = $_DocLister->getCFGDef('priority', 'tv.sitemap_priority');
34 39
             $changefreqField = $_DocLister->getCFGDef('changefreq', 'tv.sitemap_changefreq');
35
-            if (!empty($data[$priorityField])) {
40
+            if (!empty($data[$priorityField])) {
36 41
                 $data['priority'] = $data[$priorityField];
37 42
             }
38
-            if (!empty($data[$changefreqField])) {
43
+            if (!empty($data[$changefreqField])) {
39 44
                 $data['update'] = $data[$changefreqField];
40 45
             }
41 46
 
@@ -45,7 +50,7 @@  discard block
 block discarded – undo
45 50
 }
46 51
 
47 52
 $out = $modx->runSnippet('DocLister',$params);
48
-if (!empty($out)) {
53
+if (!empty($out)) {
49 54
     $out = "<?xml version=\"1.0\" encoding=\"{$modx->config['modx_charset']}\"?>\n<urlset xmlns=\"{$schema}\">{$out}\n</urlset>";
50 55
 }
51 56
 
Please login to merge, or discard this patch.