Completed
Push — master ( c9d81d...e55d95 )
by
unknown
02:05
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';
@@ -29,10 +29,10 @@  discard block
 block discarded – undo
29 29
             $data['date'] = date('c', $data['date']);
30 30
             $priorityField = $_DocLister->getCFGDef('priority', 'tv.sitemap_priority');
31 31
             $changefreqField = $_DocLister->getCFGDef('changefreq', 'tv.sitemap_changefreq');
32
-            if (!empty($data[$priorityField])) {
32
+            if ( ! empty($data[$priorityField])) {
33 33
                 $data['priority'] = $data[$priorityField];
34 34
             }
35
-            if (!empty($data[$changefreqField])) {
35
+            if ( ! empty($data[$changefreqField])) {
36 36
                 $data['update'] = $data[$changefreqField];
37 37
             }
38 38
 
@@ -41,8 +41,8 @@  discard block
 block discarded – undo
41 41
     }
42 42
 }
43 43
 
44
-$out = $modx->runSnippet('DocLister',$params);
45
-if (!empty($out)) {
44
+$out = $modx->runSnippet('DocLister', $params);
45
+if ( ! empty($out)) {
46 46
     $out = "<?xml version=\"1.0\" encoding=\"{$modx->config['modx_charset']}\"?>\n<urlset xmlns=\"{$schema}\">{$out}\n</urlset>";
47 47
 }
48 48
 
Please login to merge, or discard this patch.
Braces   +18 added lines, -13 removed lines patch added patch discarded remove patch
@@ -1,38 +1,43 @@  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
             $data['date'] = date('c', $data['date']);
30 35
             $priorityField = $_DocLister->getCFGDef('priority', 'tv.sitemap_priority');
31 36
             $changefreqField = $_DocLister->getCFGDef('changefreq', 'tv.sitemap_changefreq');
32
-            if (!empty($data[$priorityField])) {
37
+            if (!empty($data[$priorityField])) {
33 38
                 $data['priority'] = $data[$priorityField];
34 39
             }
35
-            if (!empty($data[$changefreqField])) {
40
+            if (!empty($data[$changefreqField])) {
36 41
                 $data['update'] = $data[$changefreqField];
37 42
             }
38 43
 
@@ -42,7 +47,7 @@  discard block
 block discarded – undo
42 47
 }
43 48
 
44 49
 $out = $modx->runSnippet('DocLister',$params);
45
-if (!empty($out)) {
50
+if (!empty($out)) {
46 51
     $out = "<?xml version=\"1.0\" encoding=\"{$modx->config['modx_charset']}\"?>\n<urlset xmlns=\"{$schema}\">{$out}\n</urlset>";
47 52
 }
48 53
 
Please login to merge, or discard this patch.