Completed
Push — develop ( ef95a6...f399f2 )
by Maxim
06:16
created
manager/processors/delete_eventlog.processor.php 2 patches
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -3,17 +3,17 @@
 block discarded – undo
3 3
     die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly.");
4 4
 }
5 5
 if(!$modx->hasPermission('delete_eventlog')) {
6
-	$modx->webAlertAndQuit($_lang["error_no_privileges"]);
6
+    $modx->webAlertAndQuit($_lang["error_no_privileges"]);
7 7
 }
8 8
 
9 9
 if (isset($_GET['cls']) && $_GET['cls']==1) {
10
-	$where = '';
10
+    $where = '';
11 11
 } else {
12
-	$id = isset($_GET['id'])? (int)$_GET['id'] : 0;
13
-	if($id==0) {
14
-		$modx->webAlertAndQuit($_lang["error_no_id"]);
15
-	}
16
-	$where = "id='{$id}'";
12
+    $id = isset($_GET['id'])? (int)$_GET['id'] : 0;
13
+    if($id==0) {
14
+        $modx->webAlertAndQuit($_lang["error_no_id"]);
15
+    }
16
+    $where = "id='{$id}'";
17 17
 }
18 18
 
19 19
 // delete event log
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -1,16 +1,16 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) {
2
+if (!defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) {
3 3
     die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly.");
4 4
 }
5
-if(!$modx->hasPermission('delete_eventlog')) {
5
+if (!$modx->hasPermission('delete_eventlog')) {
6 6
 	$modx->webAlertAndQuit($_lang["error_no_privileges"]);
7 7
 }
8 8
 
9
-if (isset($_GET['cls']) && $_GET['cls']==1) {
9
+if (isset($_GET['cls']) && $_GET['cls'] == 1) {
10 10
 	$where = '';
11 11
 } else {
12
-	$id = isset($_GET['id'])? (int)$_GET['id'] : 0;
13
-	if($id==0) {
12
+	$id = isset($_GET['id']) ? (int) $_GET['id'] : 0;
13
+	if ($id == 0) {
14 14
 		$modx->webAlertAndQuit($_lang["error_no_id"]);
15 15
 	}
16 16
 	$where = "id='{$id}'";
@@ -19,5 +19,5 @@  discard block
 block discarded – undo
19 19
 // delete event log
20 20
 $modx->db->delete($modx->getFullTableName('event_log'), $where);
21 21
 
22
-$header="Location: index.php?a=114";
22
+$header = "Location: index.php?a=114";
23 23
 header($header);
Please login to merge, or discard this patch.
manager/processors/delete_category.processor.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1,13 +1,13 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) {
2
+if (!defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) {
3 3
     die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly.");
4 4
 }
5 5
 if (!$modx->hasPermission('save_plugin') && !$modx->hasPermission('save_snippet') && !$modx->hasPermission('save_template') && !$modx->hasPermission('save_module')) {
6 6
     $modx->webAlertAndQuit($_lang["error_no_privileges"]);
7 7
 }
8 8
 
9
-$id = isset($_GET['catId'])? (int)$_GET['catId'] : 0;
10
-if ($id==0) {
9
+$id = isset($_GET['catId']) ? (int) $_GET['catId'] : 0;
10
+if ($id == 0) {
11 11
     $modx->webAlertAndQuit($_lang["error_no_id"]);
12 12
 }
13 13
 
@@ -19,5 +19,5 @@  discard block
 block discarded – undo
19 19
 deleteCategory($id);
20 20
 
21 21
 // finished emptying cache - redirect
22
-$header="Location: index.php?a=76";
22
+$header = "Location: index.php?a=76";
23 23
 header($header);
Please login to merge, or discard this patch.
manager/processors/save_template.processor.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -1,27 +1,27 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) {
2
+if (!defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) {
3 3
     die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly.");
4 4
 }
5 5
 if (!$modx->hasPermission('save_template')) {
6 6
     $modx->webAlertAndQuit($_lang["error_no_privileges"]);
7 7
 }
8 8
 
9
-$id = (int)$_POST['id'];
9
+$id = (int) $_POST['id'];
10 10
 $template = $modx->db->escape($_POST['post']);
11 11
 $templatename = $modx->db->escape(trim($_POST['templatename']));
12 12
 $description = $modx->db->escape($_POST['description']);
13 13
 $locked = $_POST['locked'] == 'on' ? 1 : 0;
14
-$selectable = $id == $modx->config['default_template'] ? 1 :    // Force selectable
14
+$selectable = $id == $modx->config['default_template'] ? 1 : // Force selectable
15 15
     $_POST['selectable'] == 'on' ? 1 : 0;
16 16
 $currentdate = time() + $modx->config['server_offset_time'];
17 17
 
18 18
 //Kyle Jaebker - added category support
19 19
 if (empty($_POST['newcategory']) && $_POST['categoryid'] > 0) {
20
-    $categoryid = (int)$_POST['categoryid'];
20
+    $categoryid = (int) $_POST['categoryid'];
21 21
 } elseif (empty($_POST['newcategory']) && $_POST['categoryid'] <= 0) {
22 22
     $categoryid = 0;
23 23
 } else {
24
-    include_once(MODX_MANAGER_PATH . 'includes/categories.inc.php');
24
+    include_once(MODX_MANAGER_PATH.'includes/categories.inc.php');
25 25
     $categoryid = checkCategory($_POST['newcategory']);
26 26
     if (!$categoryid) {
27 27
         $categoryid = newCategory($_POST['newcategory']);
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
         // finished emptying cache - redirect
79 79
         if ($_POST['stay'] != '') {
80 80
             $a = ($_POST['stay'] == '2') ? "16&id=$newid" : "19";
81
-            $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay'];
81
+            $header = "Location: index.php?a=".$a."&r=2&stay=".$_POST['stay'];
82 82
             header($header);
83 83
         } else {
84 84
             $header = "Location: index.php?a=76&r=2";
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
         // finished emptying cache - redirect
131 131
         if ($_POST['stay'] != '') {
132 132
             $a = ($_POST['stay'] == '2') ? "16&id=$id" : "19";
133
-            $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay'];
133
+            $header = "Location: index.php?a=".$a."&r=2&stay=".$_POST['stay'];
134 134
             header($header);
135 135
         } else {
136 136
             $modx->unlockElement(1, $id);
Please login to merge, or discard this patch.
Switch Indentation   +109 added lines, -109 removed lines patch added patch discarded remove patch
@@ -33,115 +33,115 @@
 block discarded – undo
33 33
 }
34 34
 
35 35
 switch ($_POST['mode']) {
36
-    case '19':
37
-
38
-        // invoke OnBeforeTempFormSave event
39
-        $modx->invokeEvent("OnBeforeTempFormSave", array(
40
-            "mode" => "new",
41
-            "id" => $id
42
-        ));
43
-
44
-        // disallow duplicate names for new templates
45
-        $rs = $modx->db->select('COUNT(id)', $modx->getFullTableName('site_templates'), "templatename='{$templatename}'");
46
-        $count = $modx->db->getValue($rs);
47
-        if ($count > 0) {
48
-            $modx->manager->saveFormValues(19);
49
-            $modx->webAlertAndQuit(sprintf($_lang['duplicate_name_found_general'], $_lang['template'], $templatename), "index.php?a=19");
50
-        }
51
-
52
-        //do stuff to save the new doc
53
-        $newid = $modx->db->insert(array(
54
-            'templatename' => $templatename,
55
-            'description' => $description,
56
-            'content' => $template,
57
-            'locked' => $locked,
58
-            'selectable' => $selectable,
59
-            'category' => $categoryid,
60
-            'createdon' => $currentdate,
61
-            'editedon' => $currentdate
62
-        ), $modx->getFullTableName('site_templates'));
63
-
64
-        // invoke OnTempFormSave event
65
-        $modx->invokeEvent("OnTempFormSave", array(
66
-            "mode" => "new",
67
-            "id" => $newid
68
-        ));
69
-        // Set new assigned Tvs
70
-        saveTemplateAccess($newid);
71
-
72
-        // Set the item name for logger
73
-        $_SESSION['itemname'] = $templatename;
74
-
75
-        // empty cache
76
-        $modx->clearCache('full');
77
-
78
-        // finished emptying cache - redirect
79
-        if ($_POST['stay'] != '') {
80
-            $a = ($_POST['stay'] == '2') ? "16&id=$newid" : "19";
81
-            $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay'];
82
-            header($header);
83
-        } else {
84
-            $header = "Location: index.php?a=76&r=2";
85
-            header($header);
86
-        }
87
-
88
-        break;
89
-    case '16':
90
-
91
-        // invoke OnBeforeTempFormSave event
92
-        $modx->invokeEvent("OnBeforeTempFormSave", array(
93
-            "mode" => "upd",
94
-            "id" => $id
95
-        ));
96
-
97
-        // disallow duplicate names for templates
98
-        $rs = $modx->db->select('COUNT(*)', $modx->getFullTableName('site_templates'), "templatename='{$templatename}' AND id!='{$id}'");
99
-        $count = $modx->db->getValue($rs);
100
-        if ($count > 0) {
101
-            $modx->manager->saveFormValues(16);
102
-            $modx->webAlertAndQuit(sprintf($_lang['duplicate_name_found_general'], $_lang['template'], $templatename), "index.php?a=16&id={$id}");
103
-        }
104
-
105
-        //do stuff to save the edited doc
106
-        $modx->db->update(array(
107
-            'templatename' => $templatename,
108
-            'description' => $description,
109
-            'content' => $template,
110
-            'locked' => $locked,
111
-            'selectable' => $selectable,
112
-            'category' => $categoryid,
113
-            'editedon' => $currentdate
114
-        ), $modx->getFullTableName('site_templates'), "id='{$id}'");
115
-        // Set new assigned Tvs
116
-        saveTemplateAccess($id);
117
-
118
-        // invoke OnTempFormSave event
119
-        $modx->invokeEvent("OnTempFormSave", array(
120
-            "mode" => "upd",
121
-            "id" => $id
122
-        ));
123
-
124
-        // Set the item name for logger
125
-        $_SESSION['itemname'] = $templatename;
126
-
127
-        // first empty the cache
128
-        $modx->clearCache('full');
129
-
130
-        // finished emptying cache - redirect
131
-        if ($_POST['stay'] != '') {
132
-            $a = ($_POST['stay'] == '2') ? "16&id=$id" : "19";
133
-            $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay'];
134
-            header($header);
135
-        } else {
136
-            $modx->unlockElement(1, $id);
137
-            $header = "Location: index.php?a=76&r=2";
138
-            header($header);
139
-        }
140
-
141
-
142
-        break;
143
-    default:
144
-        $modx->webAlertAndQuit("No operation set in request.");
36
+        case '19':
37
+
38
+            // invoke OnBeforeTempFormSave event
39
+            $modx->invokeEvent("OnBeforeTempFormSave", array(
40
+                "mode" => "new",
41
+                "id" => $id
42
+            ));
43
+
44
+            // disallow duplicate names for new templates
45
+            $rs = $modx->db->select('COUNT(id)', $modx->getFullTableName('site_templates'), "templatename='{$templatename}'");
46
+            $count = $modx->db->getValue($rs);
47
+            if ($count > 0) {
48
+                $modx->manager->saveFormValues(19);
49
+                $modx->webAlertAndQuit(sprintf($_lang['duplicate_name_found_general'], $_lang['template'], $templatename), "index.php?a=19");
50
+            }
51
+
52
+            //do stuff to save the new doc
53
+            $newid = $modx->db->insert(array(
54
+                'templatename' => $templatename,
55
+                'description' => $description,
56
+                'content' => $template,
57
+                'locked' => $locked,
58
+                'selectable' => $selectable,
59
+                'category' => $categoryid,
60
+                'createdon' => $currentdate,
61
+                'editedon' => $currentdate
62
+            ), $modx->getFullTableName('site_templates'));
63
+
64
+            // invoke OnTempFormSave event
65
+            $modx->invokeEvent("OnTempFormSave", array(
66
+                "mode" => "new",
67
+                "id" => $newid
68
+            ));
69
+            // Set new assigned Tvs
70
+            saveTemplateAccess($newid);
71
+
72
+            // Set the item name for logger
73
+            $_SESSION['itemname'] = $templatename;
74
+
75
+            // empty cache
76
+            $modx->clearCache('full');
77
+
78
+            // finished emptying cache - redirect
79
+            if ($_POST['stay'] != '') {
80
+                $a = ($_POST['stay'] == '2') ? "16&id=$newid" : "19";
81
+                $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay'];
82
+                header($header);
83
+            } else {
84
+                $header = "Location: index.php?a=76&r=2";
85
+                header($header);
86
+            }
87
+
88
+            break;
89
+        case '16':
90
+
91
+            // invoke OnBeforeTempFormSave event
92
+            $modx->invokeEvent("OnBeforeTempFormSave", array(
93
+                "mode" => "upd",
94
+                "id" => $id
95
+            ));
96
+
97
+            // disallow duplicate names for templates
98
+            $rs = $modx->db->select('COUNT(*)', $modx->getFullTableName('site_templates'), "templatename='{$templatename}' AND id!='{$id}'");
99
+            $count = $modx->db->getValue($rs);
100
+            if ($count > 0) {
101
+                $modx->manager->saveFormValues(16);
102
+                $modx->webAlertAndQuit(sprintf($_lang['duplicate_name_found_general'], $_lang['template'], $templatename), "index.php?a=16&id={$id}");
103
+            }
104
+
105
+            //do stuff to save the edited doc
106
+            $modx->db->update(array(
107
+                'templatename' => $templatename,
108
+                'description' => $description,
109
+                'content' => $template,
110
+                'locked' => $locked,
111
+                'selectable' => $selectable,
112
+                'category' => $categoryid,
113
+                'editedon' => $currentdate
114
+            ), $modx->getFullTableName('site_templates'), "id='{$id}'");
115
+            // Set new assigned Tvs
116
+            saveTemplateAccess($id);
117
+
118
+            // invoke OnTempFormSave event
119
+            $modx->invokeEvent("OnTempFormSave", array(
120
+                "mode" => "upd",
121
+                "id" => $id
122
+            ));
123
+
124
+            // Set the item name for logger
125
+            $_SESSION['itemname'] = $templatename;
126
+
127
+            // first empty the cache
128
+            $modx->clearCache('full');
129
+
130
+            // finished emptying cache - redirect
131
+            if ($_POST['stay'] != '') {
132
+                $a = ($_POST['stay'] == '2') ? "16&id=$id" : "19";
133
+                $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay'];
134
+                header($header);
135
+            } else {
136
+                $modx->unlockElement(1, $id);
137
+                $header = "Location: index.php?a=76&r=2";
138
+                header($header);
139
+            }
140
+
141
+
142
+            break;
143
+        default:
144
+            $modx->webAlertAndQuit("No operation set in request.");
145 145
 }
146 146
 
147 147
 /**
Please login to merge, or discard this patch.
manager/processors/delete_user.processor.php 2 patches
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -3,17 +3,17 @@  discard block
 block discarded – undo
3 3
     die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly.");
4 4
 }
5 5
 if(!$modx->hasPermission('delete_user')) {
6
-	$modx->webAlertAndQuit($_lang["error_no_privileges"]);
6
+    $modx->webAlertAndQuit($_lang["error_no_privileges"]);
7 7
 }
8 8
 
9 9
 $id = isset($_GET['id'])? (int)$_GET['id'] : 0;
10 10
 if($id==0) {
11
-	$modx->webAlertAndQuit($_lang["error_no_id"]);
11
+    $modx->webAlertAndQuit($_lang["error_no_id"]);
12 12
 }
13 13
 
14 14
 // delete the user, but first check if we are deleting our own record
15 15
 if($id==$modx->getLoginUserID()) {
16
-	$modx->webAlertAndQuit("You can't delete yourself!");
16
+    $modx->webAlertAndQuit("You can't delete yourself!");
17 17
 }
18 18
 
19 19
 // Set the item name for logger
@@ -22,9 +22,9 @@  discard block
 block discarded – undo
22 22
 
23 23
 // invoke OnBeforeUserFormDelete event
24 24
 $modx->invokeEvent("OnBeforeUserFormDelete",
25
-	array(
26
-		"id"	=> $id
27
-	));
25
+    array(
26
+        "id"	=> $id
27
+    ));
28 28
 
29 29
 // delete the user.
30 30
 $modx->db->delete($modx->getFullTableName('manager_users'), "id='{$id}'");
@@ -39,16 +39,16 @@  discard block
 block discarded – undo
39 39
 
40 40
 // invoke OnManagerDeleteUser event
41 41
 $modx->invokeEvent("OnManagerDeleteUser",
42
-	array(
43
-		"userid"		=> $id,
44
-		"username"		=> $username
45
-	));
42
+    array(
43
+        "userid"		=> $id,
44
+        "username"		=> $username
45
+    ));
46 46
 
47 47
 // invoke OnUserFormDelete event
48 48
 $modx->invokeEvent("OnUserFormDelete",
49
-	array(
50
-		"id"	=> $id
51
-	));
49
+    array(
50
+        "id"	=> $id
51
+    ));
52 52
 
53 53
 $header="Location: index.php?a=75";
54 54
 header($header);
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -1,18 +1,18 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) {
2
+if (!defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) {
3 3
     die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly.");
4 4
 }
5
-if(!$modx->hasPermission('delete_user')) {
5
+if (!$modx->hasPermission('delete_user')) {
6 6
 	$modx->webAlertAndQuit($_lang["error_no_privileges"]);
7 7
 }
8 8
 
9
-$id = isset($_GET['id'])? (int)$_GET['id'] : 0;
10
-if($id==0) {
9
+$id = isset($_GET['id']) ? (int) $_GET['id'] : 0;
10
+if ($id == 0) {
11 11
 	$modx->webAlertAndQuit($_lang["error_no_id"]);
12 12
 }
13 13
 
14 14
 // delete the user, but first check if we are deleting our own record
15
-if($id==$modx->getLoginUserID()) {
15
+if ($id == $modx->getLoginUserID()) {
16 16
 	$modx->webAlertAndQuit("You can't delete yourself!");
17 17
 }
18 18
 
@@ -50,5 +50,5 @@  discard block
 block discarded – undo
50 50
 		"id"	=> $id
51 51
 	));
52 52
 
53
-$header="Location: index.php?a=75";
53
+$header = "Location: index.php?a=75";
54 54
 header($header);
Please login to merge, or discard this patch.
manager/processors/save_module.processor.php 2 patches
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -1,12 +1,12 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) {
2
+if (!defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) {
3 3
     die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly.");
4 4
 }
5 5
 if (!$modx->hasPermission('save_module')) {
6 6
     $modx->webAlertAndQuit($_lang["error_no_privileges"]);
7 7
 }
8 8
 
9
-$id = (int)$_POST['id'];
9
+$id = (int) $_POST['id'];
10 10
 $name = $modx->db->escape(trim($_POST['name']));
11 11
 $description = $modx->db->escape($_POST['description']);
12 12
 $resourcefile = $modx->db->escape($_POST['resourcefile']);
@@ -25,11 +25,11 @@  discard block
 block discarded – undo
25 25
 
26 26
 //Kyle Jaebker - added category support
27 27
 if (empty($_POST['newcategory']) && $_POST['categoryid'] > 0) {
28
-    $categoryid = (int)$_POST['categoryid'];
28
+    $categoryid = (int) $_POST['categoryid'];
29 29
 } elseif (empty($_POST['newcategory']) && $_POST['categoryid'] <= 0) {
30 30
     $categoryid = 0;
31 31
 } else {
32
-    include_once(MODX_MANAGER_PATH . 'includes/categories.inc.php');
32
+    include_once(MODX_MANAGER_PATH.'includes/categories.inc.php');
33 33
     $categoryid = checkCategory($_POST['newcategory']);
34 34
     if (!$categoryid) {
35 35
         $categoryid = newCategory($_POST['newcategory']);
@@ -45,15 +45,15 @@  discard block
 block discarded – undo
45 45
     $name = isset($parsed['name']) ? $parsed['name'] : $name;
46 46
     $properties = isset($parsed['properties']) ? $parsed['properties'] : $properties;
47 47
     $guid = isset($parsed['guid']) ? $parsed['guid'] : $guid;
48
-    $enable_sharedparams = isset($parsed['shareparams']) ? (int)$parsed['shareparams'] : $enable_sharedparams;
48
+    $enable_sharedparams = isset($parsed['shareparams']) ? (int) $parsed['shareparams'] : $enable_sharedparams;
49 49
 
50 50
     $description = isset($parsed['description']) ? $parsed['description'] : $description;
51
-    $version = isset($parsed['version']) ? '<b>' . $parsed['version'] . '</b> ' : '';
51
+    $version = isset($parsed['version']) ? '<b>'.$parsed['version'].'</b> ' : '';
52 52
     if ($version) {
53
-        $description = $version . trim(preg_replace('/(<b>.+?)+(<\/b>)/i', '', $description));
53
+        $description = $version.trim(preg_replace('/(<b>.+?)+(<\/b>)/i', '', $description));
54 54
     }
55 55
     if (isset($parsed['modx_category'])) {
56
-        include_once(MODX_MANAGER_PATH . 'includes/categories.inc.php');
56
+        include_once(MODX_MANAGER_PATH.'includes/categories.inc.php');
57 57
         $categoryid = getCategory($parsed['modx_category']);
58 58
     }
59 59
 }
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
         // finished emptying cache - redirect
112 112
         if ($_POST['stay'] != '') {
113 113
             $a = ($_POST['stay'] == '2') ? "108&id=$newid" : "107";
114
-            $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay'];
114
+            $header = "Location: index.php?a=".$a."&r=2&stay=".$_POST['stay'];
115 115
             header($header);
116 116
         } else {
117 117
             $header = "Location: index.php?a=106&r=2";
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
         // finished emptying cache - redirect
169 169
         if ($_POST['stay'] != '') {
170 170
             $a = ($_POST['stay'] == '2') ? "108&id=$id" : "107";
171
-            $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay'];
171
+            $header = "Location: index.php?a=".$a."&r=2&stay=".$_POST['stay'];
172 172
             header($header);
173 173
         } else {
174 174
             $modx->unlockElement(6, $id);
Please login to merge, or discard this patch.
Switch Indentation   +117 added lines, -117 removed lines patch added patch discarded remove patch
@@ -59,125 +59,125 @@
 block discarded – undo
59 59
 }
60 60
 
61 61
 switch ($_POST['mode']) {
62
-    case '107':
63
-        // invoke OnBeforeModFormSave event
64
-        $modx->invokeEvent("OnBeforeModFormSave", array(
65
-                "mode" => "new",
66
-                "id" => $id
67
-            ));
68
-
69
-        // disallow duplicate names for new modules
70
-        $rs = $modx->db->select('count(id)', $modx->getFullTableName('site_modules'), "name='{$name}'");
71
-        $count = $modx->db->getValue($rs);
72
-        if ($count > 0) {
73
-            $modx->manager->saveFormValues(107);
74
-            $modx->webAlertAndQuit(sprintf($_lang['duplicate_name_found_module'], $name), "index.php?a=107");
75
-        }
62
+        case '107':
63
+            // invoke OnBeforeModFormSave event
64
+            $modx->invokeEvent("OnBeforeModFormSave", array(
65
+                    "mode" => "new",
66
+                    "id" => $id
67
+                ));
68
+
69
+            // disallow duplicate names for new modules
70
+            $rs = $modx->db->select('count(id)', $modx->getFullTableName('site_modules'), "name='{$name}'");
71
+            $count = $modx->db->getValue($rs);
72
+            if ($count > 0) {
73
+                $modx->manager->saveFormValues(107);
74
+                $modx->webAlertAndQuit(sprintf($_lang['duplicate_name_found_module'], $name), "index.php?a=107");
75
+            }
76 76
 
77
-        // save the new module
78
-        $newid = $modx->db->insert(array(
79
-            'name' => $name,
80
-            'description' => $description,
81
-            'disabled' => $disabled,
82
-            'wrap' => $wrap,
83
-            'locked' => $locked,
84
-            'icon' => $icon,
85
-            'resourcefile' => $resourcefile,
86
-            'enable_resource' => $enable_resource,
87
-            'category' => $categoryid,
88
-            'enable_sharedparams' => $enable_sharedparams,
89
-            'guid' => $guid,
90
-            'modulecode' => $modulecode,
91
-            'properties' => $properties,
92
-            'createdon' => $currentdate,
93
-            'editedon' => $currentdate
94
-        ), $modx->getFullTableName('site_modules'));
95
-
96
-        // save user group access permissions
97
-        saveUserGroupAccessPermissons();
98
-
99
-        // invoke OnModFormSave event
100
-        $modx->invokeEvent("OnModFormSave", array(
101
-                "mode" => "new",
102
-                "id" => $newid
103
-            ));
104
-
105
-        // Set the item name for logger
106
-        $_SESSION['itemname'] = $name;
107
-
108
-        // empty cache
109
-        $modx->clearCache('full');
110
-
111
-        // finished emptying cache - redirect
112
-        if ($_POST['stay'] != '') {
113
-            $a = ($_POST['stay'] == '2') ? "108&id=$newid" : "107";
114
-            $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay'];
115
-            header($header);
116
-        } else {
117
-            $header = "Location: index.php?a=106&r=2";
118
-            header($header);
119
-        }
120
-        break;
121
-    case '108':
122
-        // invoke OnBeforeModFormSave event
123
-        $modx->invokeEvent("OnBeforeModFormSave", array(
124
-                "mode" => "upd",
125
-                "id" => $id
126
-            ));
127
-
128
-        // disallow duplicate names for new modules
129
-        $rs = $modx->db->select('count(id)', $modx->getFullTableName('site_modules'), "name='{$name}' AND id!='{$id}'");
130
-        if ($modx->db->getValue($rs) > 0) {
131
-            $modx->manager->saveFormValues(108);
132
-            $modx->webAlertAndQuit(sprintf($_lang['duplicate_name_found_module'], $name), "index.php?a=108&id={$id}");
133
-        }
77
+            // save the new module
78
+            $newid = $modx->db->insert(array(
79
+                'name' => $name,
80
+                'description' => $description,
81
+                'disabled' => $disabled,
82
+                'wrap' => $wrap,
83
+                'locked' => $locked,
84
+                'icon' => $icon,
85
+                'resourcefile' => $resourcefile,
86
+                'enable_resource' => $enable_resource,
87
+                'category' => $categoryid,
88
+                'enable_sharedparams' => $enable_sharedparams,
89
+                'guid' => $guid,
90
+                'modulecode' => $modulecode,
91
+                'properties' => $properties,
92
+                'createdon' => $currentdate,
93
+                'editedon' => $currentdate
94
+            ), $modx->getFullTableName('site_modules'));
95
+
96
+            // save user group access permissions
97
+            saveUserGroupAccessPermissons();
98
+
99
+            // invoke OnModFormSave event
100
+            $modx->invokeEvent("OnModFormSave", array(
101
+                    "mode" => "new",
102
+                    "id" => $newid
103
+                ));
104
+
105
+            // Set the item name for logger
106
+            $_SESSION['itemname'] = $name;
107
+
108
+            // empty cache
109
+            $modx->clearCache('full');
110
+
111
+            // finished emptying cache - redirect
112
+            if ($_POST['stay'] != '') {
113
+                $a = ($_POST['stay'] == '2') ? "108&id=$newid" : "107";
114
+                $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay'];
115
+                header($header);
116
+            } else {
117
+                $header = "Location: index.php?a=106&r=2";
118
+                header($header);
119
+            }
120
+            break;
121
+        case '108':
122
+            // invoke OnBeforeModFormSave event
123
+            $modx->invokeEvent("OnBeforeModFormSave", array(
124
+                    "mode" => "upd",
125
+                    "id" => $id
126
+                ));
127
+
128
+            // disallow duplicate names for new modules
129
+            $rs = $modx->db->select('count(id)', $modx->getFullTableName('site_modules'), "name='{$name}' AND id!='{$id}'");
130
+            if ($modx->db->getValue($rs) > 0) {
131
+                $modx->manager->saveFormValues(108);
132
+                $modx->webAlertAndQuit(sprintf($_lang['duplicate_name_found_module'], $name), "index.php?a=108&id={$id}");
133
+            }
134 134
 
135
-        // save the edited module
136
-        $modx->db->update(array(
137
-            'name' => $name,
138
-            'description' => $description,
139
-            'icon' => $icon,
140
-            'enable_resource' => $enable_resource,
141
-            'resourcefile' => $resourcefile,
142
-            'disabled' => $disabled,
143
-            'wrap' => $wrap,
144
-            'locked' => $locked,
145
-            'category' => $categoryid,
146
-            'enable_sharedparams' => $enable_sharedparams,
147
-            'guid' => $guid,
148
-            'modulecode' => $modulecode,
149
-            'properties' => $properties,
150
-            'editedon' => $currentdate
151
-        ), $modx->getFullTableName('site_modules'), "id='{$id}'");
152
-
153
-        // save user group access permissions
154
-        saveUserGroupAccessPermissons();
155
-
156
-        // invoke OnModFormSave event
157
-        $modx->invokeEvent("OnModFormSave", array(
158
-                "mode" => "upd",
159
-                "id" => $id
160
-            ));
161
-
162
-        // Set the item name for logger
163
-        $_SESSION['itemname'] = $name;
164
-
165
-        // empty cache
166
-        $modx->clearCache('full');
167
-
168
-        // finished emptying cache - redirect
169
-        if ($_POST['stay'] != '') {
170
-            $a = ($_POST['stay'] == '2') ? "108&id=$id" : "107";
171
-            $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay'];
172
-            header($header);
173
-        } else {
174
-            $modx->unlockElement(6, $id);
175
-            $header = "Location: index.php?a=106&r=2";
176
-            header($header);
177
-        }
178
-        break;
179
-    default:
180
-        $modx->webAlertAndQuit("No operation set in request.");
135
+            // save the edited module
136
+            $modx->db->update(array(
137
+                'name' => $name,
138
+                'description' => $description,
139
+                'icon' => $icon,
140
+                'enable_resource' => $enable_resource,
141
+                'resourcefile' => $resourcefile,
142
+                'disabled' => $disabled,
143
+                'wrap' => $wrap,
144
+                'locked' => $locked,
145
+                'category' => $categoryid,
146
+                'enable_sharedparams' => $enable_sharedparams,
147
+                'guid' => $guid,
148
+                'modulecode' => $modulecode,
149
+                'properties' => $properties,
150
+                'editedon' => $currentdate
151
+            ), $modx->getFullTableName('site_modules'), "id='{$id}'");
152
+
153
+            // save user group access permissions
154
+            saveUserGroupAccessPermissons();
155
+
156
+            // invoke OnModFormSave event
157
+            $modx->invokeEvent("OnModFormSave", array(
158
+                    "mode" => "upd",
159
+                    "id" => $id
160
+                ));
161
+
162
+            // Set the item name for logger
163
+            $_SESSION['itemname'] = $name;
164
+
165
+            // empty cache
166
+            $modx->clearCache('full');
167
+
168
+            // finished emptying cache - redirect
169
+            if ($_POST['stay'] != '') {
170
+                $a = ($_POST['stay'] == '2') ? "108&id=$id" : "107";
171
+                $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay'];
172
+                header($header);
173
+            } else {
174
+                $modx->unlockElement(6, $id);
175
+                $header = "Location: index.php?a=106&r=2";
176
+                header($header);
177
+            }
178
+            break;
179
+        default:
180
+            $modx->webAlertAndQuit("No operation set in request.");
181 181
 }
182 182
 
183 183
 /**
Please login to merge, or discard this patch.
manager/processors/unpublish_content.processor.php 2 patches
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -3,12 +3,12 @@  discard block
 block discarded – undo
3 3
     die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly.");
4 4
 }
5 5
 if(!$modx->hasPermission('save_document')||!$modx->hasPermission('publish_document')) {
6
-	$modx->webAlertAndQuit($_lang["error_no_privileges"]);
6
+    $modx->webAlertAndQuit($_lang["error_no_privileges"]);
7 7
 }
8 8
 
9 9
 $id = isset($_REQUEST['id'])? (int)$_REQUEST['id'] : 0;
10 10
 if($id==0) {
11
-	$modx->webAlertAndQuit($_lang["error_no_id"]);
11
+    $modx->webAlertAndQuit($_lang["error_no_id"]);
12 12
 }
13 13
 
14 14
 /************webber ********/
@@ -33,20 +33,20 @@  discard block
 block discarded – undo
33 33
 $udperms->role = $_SESSION['mgrRole'];
34 34
 
35 35
 if(!$udperms->checkPermissions()) {
36
-	$modx->webAlertAndQuit($_lang["access_permission_denied"]);
36
+    $modx->webAlertAndQuit($_lang["access_permission_denied"]);
37 37
 }
38 38
 
39 39
 // update the document
40 40
 $modx->db->update(
41
-	array(
42
-		'published'   => 0,
43
-		'pub_date'    => 0,
44
-		'unpub_date'  => 0,
45
-		'editedby'    => $modx->getLoginUserID(),
46
-		'editedon'    => time(),
47
-		'publishedby' => 0,
48
-		'publishedon' => 0,
49
-	), $modx->getFullTableName('site_content'), "id='{$id}'");
41
+    array(
42
+        'published'   => 0,
43
+        'pub_date'    => 0,
44
+        'unpub_date'  => 0,
45
+        'editedby'    => $modx->getLoginUserID(),
46
+        'editedon'    => time(),
47
+        'publishedby' => 0,
48
+        'publishedon' => 0,
49
+    ), $modx->getFullTableName('site_content'), "id='{$id}'");
50 50
 
51 51
 // invoke OnDocUnPublished  event
52 52
 $modx->invokeEvent("OnDocUnPublished",array("docid"=>$id));
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -1,38 +1,38 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) {
2
+if (!defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) {
3 3
     die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly.");
4 4
 }
5
-if(!$modx->hasPermission('save_document')||!$modx->hasPermission('publish_document')) {
5
+if (!$modx->hasPermission('save_document') || !$modx->hasPermission('publish_document')) {
6 6
 	$modx->webAlertAndQuit($_lang["error_no_privileges"]);
7 7
 }
8 8
 
9
-$id = isset($_REQUEST['id'])? (int)$_REQUEST['id'] : 0;
10
-if($id==0) {
9
+$id = isset($_REQUEST['id']) ? (int) $_REQUEST['id'] : 0;
10
+if ($id == 0) {
11 11
 	$modx->webAlertAndQuit($_lang["error_no_id"]);
12 12
 }
13 13
 
14 14
 /************webber ********/
15
-$content=$modx->db->getRow($modx->db->select('parent, pagetitle', $modx->getFullTableName('site_content'), "id='{$id}'"));
16
-$pid=($content['parent']==0?$id:$content['parent']);
15
+$content = $modx->db->getRow($modx->db->select('parent, pagetitle', $modx->getFullTableName('site_content'), "id='{$id}'"));
16
+$pid = ($content['parent'] == 0 ? $id : $content['parent']);
17 17
 
18 18
 /************** webber *************/
19
-$sd=isset($_REQUEST['dir'])?'&dir='.$_REQUEST['dir']:'&dir=DESC';
20
-$sb=isset($_REQUEST['sort'])?'&sort='.$_REQUEST['sort']:'&sort=createdon';
21
-$pg=isset($_REQUEST['page'])?'&page='.(int)$_REQUEST['page']:'';
22
-$add_path=$sd.$sb.$pg;
19
+$sd = isset($_REQUEST['dir']) ? '&dir='.$_REQUEST['dir'] : '&dir=DESC';
20
+$sb = isset($_REQUEST['sort']) ? '&sort='.$_REQUEST['sort'] : '&sort=createdon';
21
+$pg = isset($_REQUEST['page']) ? '&page='.(int) $_REQUEST['page'] : '';
22
+$add_path = $sd.$sb.$pg;
23 23
 
24 24
 /***********************************/
25 25
 
26 26
 
27 27
 
28 28
 // check permissions on the document
29
-include_once MODX_MANAGER_PATH . "processors/user_documents_permissions.class.php";
29
+include_once MODX_MANAGER_PATH."processors/user_documents_permissions.class.php";
30 30
 $udperms = new udperms();
31 31
 $udperms->user = $modx->getLoginUserID();
32 32
 $udperms->document = $id;
33 33
 $udperms->role = $_SESSION['mgrRole'];
34 34
 
35
-if(!$udperms->checkPermissions()) {
35
+if (!$udperms->checkPermissions()) {
36 36
 	$modx->webAlertAndQuit($_lang["access_permission_denied"]);
37 37
 }
38 38
 
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 	), $modx->getFullTableName('site_content'), "id='{$id}'");
50 50
 
51 51
 // invoke OnDocUnPublished  event
52
-$modx->invokeEvent("OnDocUnPublished",array("docid"=>$id));
52
+$modx->invokeEvent("OnDocUnPublished", array("docid"=>$id));
53 53
 
54 54
 // Set the item name for logger
55 55
 $_SESSION['itemname'] = $content['pagetitle'];
@@ -57,6 +57,6 @@  discard block
 block discarded – undo
57 57
 // empty cache
58 58
 $modx->clearCache('full');
59 59
 
60
-$header="Location: index.php?a=3&id=$pid&r=1".$add_path;
60
+$header = "Location: index.php?a=3&id=$pid&r=1".$add_path;
61 61
 
62 62
 header($header);
Please login to merge, or discard this patch.
manager/processors/delete_module.processor.php 2 patches
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -3,12 +3,12 @@  discard block
 block discarded – undo
3 3
     die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly.");
4 4
 }
5 5
 if(!$modx->hasPermission('delete_module')) {
6
-	$modx->webAlertAndQuit($_lang["error_no_privileges"]);
6
+    $modx->webAlertAndQuit($_lang["error_no_privileges"]);
7 7
 }
8 8
 
9 9
 $id = isset($_GET['id'])? (int)$_GET['id'] : 0;
10 10
 if($id==0) {
11
-	$modx->webAlertAndQuit($_lang["error_no_id"]);
11
+    $modx->webAlertAndQuit($_lang["error_no_id"]);
12 12
 }
13 13
 
14 14
 // Set the item name for logger
@@ -17,9 +17,9 @@  discard block
 block discarded – undo
17 17
 
18 18
 // invoke OnBeforeModFormDelete event
19 19
 $modx->invokeEvent("OnBeforeModFormDelete",
20
-	array(
21
-		"id"	=> $id
22
-	));
20
+    array(
21
+        "id"	=> $id
22
+    ));
23 23
 
24 24
 // delete the module.
25 25
 $modx->db->delete($modx->getFullTableName('site_modules'), "id='{$id}'");
@@ -32,9 +32,9 @@  discard block
 block discarded – undo
32 32
 
33 33
 // invoke OnModFormDelete event
34 34
 $modx->invokeEvent("OnModFormDelete",
35
-	array(
36
-		"id"	=> $id
37
-	));
35
+    array(
36
+        "id"	=> $id
37
+    ));
38 38
 
39 39
 // empty cache
40 40
 $modx->clearCache('full');
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,13 +1,13 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) {
2
+if (!defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) {
3 3
     die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly.");
4 4
 }
5
-if(!$modx->hasPermission('delete_module')) {
5
+if (!$modx->hasPermission('delete_module')) {
6 6
 	$modx->webAlertAndQuit($_lang["error_no_privileges"]);
7 7
 }
8 8
 
9
-$id = isset($_GET['id'])? (int)$_GET['id'] : 0;
10
-if($id==0) {
9
+$id = isset($_GET['id']) ? (int) $_GET['id'] : 0;
10
+if ($id == 0) {
11 11
 	$modx->webAlertAndQuit($_lang["error_no_id"]);
12 12
 }
13 13
 
@@ -40,5 +40,5 @@  discard block
 block discarded – undo
40 40
 $modx->clearCache('full');
41 41
 
42 42
 // finished emptying cache - redirect
43
-$header="Location: index.php?a=106&r=2";
43
+$header = "Location: index.php?a=106&r=2";
44 44
 header($header);
Please login to merge, or discard this patch.
manager/actions/import_site.static.php 4 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -344,7 +344,7 @@
 block discarded – undo
344 344
 
345 345
 /**
346 346
  * @param string $filepath
347
- * @return bool|string
347
+ * @return null|string
348 348
  */
349 349
 function getFileContent($filepath) {
350 350
 	global $_lang;
Please login to merge, or discard this patch.
Indentation   +333 added lines, -333 removed lines patch added patch discarded remove patch
@@ -1,17 +1,17 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) {
3
-	die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly.");
3
+    die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly.");
4 4
 }
5 5
 if(!$modx->hasPermission('import_static')) {
6
-	$modx->webAlertAndQuit($_lang["error_no_privileges"]);
6
+    $modx->webAlertAndQuit($_lang["error_no_privileges"]);
7 7
 }
8 8
 
9 9
 // Files to upload
10 10
 $allowedfiles = array(
11
-	'html',
12
-	'htm',
13
-	'shtml',
14
-	'xml'
11
+    'html',
12
+    'htm',
13
+    'shtml',
14
+    'xml'
15 15
 );
16 16
 ?>
17 17
 	<script language="javascript">
@@ -43,9 +43,9 @@  discard block
 block discarded – undo
43 43
 	<div class="tab-page">
44 44
 		<div class="container container-body">
45 45
 			<?php
46
-			if(!isset($_POST['import'])) {
47
-				echo "<div class=\"element-edit-message\">" . $_lang['import_site_message'] . "</div>";
48
-				?>
46
+            if(!isset($_POST['import'])) {
47
+                echo "<div class=\"element-edit-message\">" . $_lang['import_site_message'] . "</div>";
48
+                ?>
49 49
 				<form action="index.php" method="post" name="importFrm">
50 50
 					<input type="hidden" name="import" value="import" />
51 51
 					<input type="hidden" name="a" value="95" />
@@ -85,18 +85,18 @@  discard block
 block discarded – undo
85 85
 					<a href="javascript:;" class="btn btn-primary" onclick="window.importFrm.submit();"><i class="<?= $_style["actions_save"] ?>"></i> <?= $_lang["import_site_start"] ?></a>
86 86
 				</form>
87 87
 			<?php
88
-			} else {
89
-			run();
90
-			$modx->clearCache('full');
91
-			?>
88
+            } else {
89
+            run();
90
+            $modx->clearCache('full');
91
+            ?>
92 92
 				<a href="javascript:;" class="btn btn-primary" onclick="window.location.href='index.php?a=2';"><i class="<?= $_style["actions_close"] ?>"></i> <?= $_lang["close"] ?></a>
93 93
 				<script type="text/javascript">
94 94
 					top.mainMenu.reloadtree();
95 95
 					parent.tree.ca = 'open';
96 96
 				</script>
97 97
 				<?php
98
-			}
99
-			?>
98
+            }
99
+            ?>
100 100
 		</div>
101 101
 	</div>
102 102
 
@@ -105,64 +105,64 @@  discard block
 block discarded – undo
105 105
  * @return string
106 106
  */
107 107
 function run() {
108
-	$modx = evolutionCMS(); global $_lang;
108
+    $modx = evolutionCMS(); global $_lang;
109 109
 
110
-	$tbl_site_content = $modx->getFullTableName('site_content');
111
-	$output = '';
112
-	$maxtime = $_POST['maxtime'];
110
+    $tbl_site_content = $modx->getFullTableName('site_content');
111
+    $output = '';
112
+    $maxtime = $_POST['maxtime'];
113 113
 
114
-	if(!is_numeric($maxtime)) {
115
-		$maxtime = 30;
116
-	}
114
+    if(!is_numeric($maxtime)) {
115
+        $maxtime = 30;
116
+    }
117 117
 
118
-	@set_time_limit($maxtime);
118
+    @set_time_limit($maxtime);
119 119
 
120
-	$mtime = microtime();
121
-	$mtime = explode(' ', $mtime);
122
-	$mtime = $mtime[1] + $mtime[0];
123
-	$importstart = $mtime;
120
+    $mtime = microtime();
121
+    $mtime = explode(' ', $mtime);
122
+    $mtime = $mtime[1] + $mtime[0];
123
+    $importstart = $mtime;
124 124
 
125
-	if($_POST['reset'] == 'on') {
126
-		$modx->db->truncate($tbl_site_content);
127
-		$modx->db->query("ALTER TABLE {$tbl_site_content} AUTO_INCREMENT = 1");
128
-	}
125
+    if($_POST['reset'] == 'on') {
126
+        $modx->db->truncate($tbl_site_content);
127
+        $modx->db->query("ALTER TABLE {$tbl_site_content} AUTO_INCREMENT = 1");
128
+    }
129 129
 
130
-	$parent = (int)$_POST['parent'];
130
+    $parent = (int)$_POST['parent'];
131 131
 
132
-	if(is_dir(MODX_BASE_PATH . 'temp/import')) {
133
-		$filedir = MODX_BASE_PATH . 'temp/import/';
134
-	} elseif(is_dir(MODX_BASE_PATH . 'assets/import')) {
135
-		$filedir = MODX_BASE_PATH . 'assets/import/';
136
-	} else {
132
+    if(is_dir(MODX_BASE_PATH . 'temp/import')) {
133
+        $filedir = MODX_BASE_PATH . 'temp/import/';
134
+    } elseif(is_dir(MODX_BASE_PATH . 'assets/import')) {
135
+        $filedir = MODX_BASE_PATH . 'assets/import/';
136
+    } else {
137 137
         $filedir = '';
138 138
     }
139 139
 
140
-	$filesfound = 0;
140
+    $filesfound = 0;
141 141
 
142
-	$files = getFiles($filedir);
143
-	$files = pop_index($files);
142
+    $files = getFiles($filedir);
143
+    $files = pop_index($files);
144 144
 
145
-	// no. of files to import
146
-	$output .= sprintf('<p>' . $_lang['import_files_found'] . '</p>', $filesfound);
145
+    // no. of files to import
146
+    $output .= sprintf('<p>' . $_lang['import_files_found'] . '</p>', $filesfound);
147 147
 
148
-	// import files
149
-	if(0 < count($files)) {
150
-		$modx->db->update(array('isfolder' => 1), $tbl_site_content, "id='{$parent}'");
151
-		importFiles($parent, $filedir, $files, 'root');
152
-	}
148
+    // import files
149
+    if(0 < count($files)) {
150
+        $modx->db->update(array('isfolder' => 1), $tbl_site_content, "id='{$parent}'");
151
+        importFiles($parent, $filedir, $files, 'root');
152
+    }
153 153
 
154
-	$mtime = microtime();
155
-	$mtime = explode(' ', $mtime);
156
-	$mtime = $mtime[1] + $mtime[0];
157
-	$importend = $mtime;
158
-	$totaltime = ($importend - $importstart);
159
-	$output .= sprintf('<p>' . $_lang['import_site_time'] . '</p>', round($totaltime, 3));
154
+    $mtime = microtime();
155
+    $mtime = explode(' ', $mtime);
156
+    $mtime = $mtime[1] + $mtime[0];
157
+    $importend = $mtime;
158
+    $totaltime = ($importend - $importstart);
159
+    $output .= sprintf('<p>' . $_lang['import_site_time'] . '</p>', round($totaltime, 3));
160 160
 
161
-	if($_POST['convert_link'] == 'on') {
162
-		convertLink();
163
-	}
161
+    if($_POST['convert_link'] == 'on') {
162
+        convertLink();
163
+    }
164 164
 
165
-	return $output;
165
+    return $output;
166 166
 }
167 167
 
168 168
 /**
@@ -172,144 +172,144 @@  discard block
 block discarded – undo
172 172
  * @param string $mode
173 173
  */
174 174
 function importFiles($parent, $filedir, $files, $mode) {
175
-	$modx = evolutionCMS();
176
-	global $_lang, $allowedfiles;
177
-	global $search_default, $cache_default, $publish_default;
178
-
179
-	$tbl_site_content = $modx->getFullTableName('site_content');
180
-	$tbl_system_settings = $modx->getFullTableName('system_settings');
181
-
182
-	$createdby = $modx->getLoginUserID();
183
-	if(!is_array($files)) {
184
-		return;
185
-	}
186
-	if($_POST['object'] === 'all') {
187
-		$modx->config['default_template'] = '0';
188
-		$richtext = '0';
189
-	} else {
190
-		$richtext = '1';
191
-	}
192
-
193
-	foreach($files as $id => $value) {
194
-		if(is_array($value)) {
195
-			// create folder
196
-			$alias = $id;
197
-			printf('<span>' . $_lang['import_site_importing_document'] . '</span>', $alias);
198
-			$field = array();
199
-			$field['type'] = 'document';
200
-			$field['contentType'] = 'text/html';
201
-			$field['published'] = $publish_default;
202
-			$field['parent'] = $parent;
203
-			$field['alias'] = $modx->stripAlias($alias);
204
-			$field['richtext'] = $richtext;
205
-			$field['template'] = $modx->config['default_template'];
206
-			$field['searchable'] = $search_default;
207
-			$field['cacheable'] = $cache_default;
208
-			$field['createdby'] = $createdby;
209
-			$field['isfolder'] = 1;
210
-			$field['menuindex'] = 1;
211
-			$find = false;
212
-			foreach(array(
213
-						'index.html',
214
-						'index.htm'
215
-					) as $filename) {
216
-				$filepath = $filedir . $alias . '/' . $filename;
217
-				if($find === false && file_exists($filepath)) {
218
-					$file = getFileContent($filepath);
219
-					list($pagetitle, $content, $description) = treatContent($file, $filename, $alias);
220
-
221
-					$date = filemtime($filepath);
222
-					$field['pagetitle'] = $pagetitle;
223
-					$field['longtitle'] = $pagetitle;
224
-					$field['description'] = $description;
225
-					$field['content'] = $modx->db->escape($content);
226
-					$field['createdon'] = $date;
227
-					$field['editedon'] = $date;
228
-					$newid = $modx->db->insert($field, $tbl_site_content);
229
-					if($newid) {
230
-						$find = true;
231
-						echo ' - <span class="success">' . $_lang['import_site_success'] . '</span><br />' . "\n";
232
-						importFiles($newid, $filedir . $alias . '/', $value, 'sub');
233
-					} else {
234
-						echo '<span class="fail">' . $_lang["import_site_failed"] . "</span> " . $_lang["import_site_failed_db_error"] . $modx->db->getLastError();
235
-						exit;
236
-					}
237
-				}
238
-			}
239
-			if($find === false) {
240
-				$date = time();
241
-				$field['pagetitle'] = '---';
242
-				$field['content'] = '';
243
-				$field['createdon'] = $date;
244
-				$field['editedon'] = $date;
245
-				$field['hidemenu'] = '1';
246
-				$newid = $modx->db->insert($field, $tbl_site_content);
247
-				if($newid) {
248
-					$find = true;
249
-					echo ' - <span class="success">' . $_lang['import_site_success'] . '</span><br />' . "\n";
250
-					importFiles($newid, $filedir . $alias . '/', $value, 'sub');
251
-				} else {
252
-					echo '<span class="fail">' . $_lang["import_site_failed"] . "</span> " . $_lang["import_site_failed_db_error"] . $modx->db->getLastError();
253
-					exit;
254
-				}
255
-			}
256
-		} else {
257
-			// create document
258
-			if($mode == 'sub' && $value == 'index.html') {
259
-				continue;
260
-			}
261
-			$filename = $value;
262
-			$fparts = explode('.', $value);
263
-			$alias = $fparts[0];
264
-			$ext = (count($fparts) > 1) ? $fparts[count($fparts) - 1] : "";
265
-			printf("<span>" . $_lang['import_site_importing_document'] . "</span>", $filename);
266
-
267
-			if(!in_array($ext, $allowedfiles)) {
268
-				echo ' - <span class="fail">' . $_lang["import_site_skip"] . '</span><br />' . "\n";
269
-			} else {
270
-				$filepath = $filedir . $filename;
271
-				$file = getFileContent($filepath);
272
-				list($pagetitle, $content, $description) = treatContent($file, $filename, $alias);
273
-
274
-				$date = filemtime($filepath);
275
-				$field = array();
276
-				$field['type'] = 'document';
277
-				$field['contentType'] = 'text/html';
278
-				$field['pagetitle'] = $pagetitle;
279
-				$field['longtitle'] = $pagetitle;
280
-				$field['description'] = $description;
281
-				$field['alias'] = $modx->stripAlias($alias);
282
-				$field['published'] = $publish_default;
283
-				$field['parent'] = $parent;
284
-				$field['content'] = $modx->db->escape($content);
285
-				$field['richtext'] = $richtext;
286
-				$field['template'] = $modx->config['default_template'];
287
-				$field['searchable'] = $search_default;
288
-				$field['cacheable'] = $cache_default;
289
-				$field['createdby'] = $createdby;
290
-				$field['createdon'] = $date;
291
-				$field['editedon'] = $date;
292
-				$field['isfolder'] = 0;
293
-				$field['menuindex'] = ($alias == 'index') ? 0 : 2;
294
-				$newid = $modx->db->insert($field, $tbl_site_content);
295
-				if($newid) {
296
-					echo ' - <span class="success">' . $_lang['import_site_success'] . '</span><br />' . "\n";
297
-				} else {
298
-					echo '<span class="fail">' . $_lang["import_site_failed"] . "</span> " . $_lang["import_site_failed_db_error"] . $modx->db->getLastError();
299
-					exit;
300
-				}
301
-
302
-				$is_site_start = false;
303
-				if($filename == 'index.html') {
304
-					$is_site_start = true;
305
-				}
306
-				if($is_site_start == true && $_POST['reset'] == 'on') {
307
-					$modx->db->update(array('setting_value' => $newid), $tbl_system_settings, "setting_name='site_start'");
308
-					$modx->db->update(array('menuindex' => 0), $tbl_site_content, "id='{$newid}'");
309
-				}
310
-			}
311
-		}
312
-	}
175
+    $modx = evolutionCMS();
176
+    global $_lang, $allowedfiles;
177
+    global $search_default, $cache_default, $publish_default;
178
+
179
+    $tbl_site_content = $modx->getFullTableName('site_content');
180
+    $tbl_system_settings = $modx->getFullTableName('system_settings');
181
+
182
+    $createdby = $modx->getLoginUserID();
183
+    if(!is_array($files)) {
184
+        return;
185
+    }
186
+    if($_POST['object'] === 'all') {
187
+        $modx->config['default_template'] = '0';
188
+        $richtext = '0';
189
+    } else {
190
+        $richtext = '1';
191
+    }
192
+
193
+    foreach($files as $id => $value) {
194
+        if(is_array($value)) {
195
+            // create folder
196
+            $alias = $id;
197
+            printf('<span>' . $_lang['import_site_importing_document'] . '</span>', $alias);
198
+            $field = array();
199
+            $field['type'] = 'document';
200
+            $field['contentType'] = 'text/html';
201
+            $field['published'] = $publish_default;
202
+            $field['parent'] = $parent;
203
+            $field['alias'] = $modx->stripAlias($alias);
204
+            $field['richtext'] = $richtext;
205
+            $field['template'] = $modx->config['default_template'];
206
+            $field['searchable'] = $search_default;
207
+            $field['cacheable'] = $cache_default;
208
+            $field['createdby'] = $createdby;
209
+            $field['isfolder'] = 1;
210
+            $field['menuindex'] = 1;
211
+            $find = false;
212
+            foreach(array(
213
+                        'index.html',
214
+                        'index.htm'
215
+                    ) as $filename) {
216
+                $filepath = $filedir . $alias . '/' . $filename;
217
+                if($find === false && file_exists($filepath)) {
218
+                    $file = getFileContent($filepath);
219
+                    list($pagetitle, $content, $description) = treatContent($file, $filename, $alias);
220
+
221
+                    $date = filemtime($filepath);
222
+                    $field['pagetitle'] = $pagetitle;
223
+                    $field['longtitle'] = $pagetitle;
224
+                    $field['description'] = $description;
225
+                    $field['content'] = $modx->db->escape($content);
226
+                    $field['createdon'] = $date;
227
+                    $field['editedon'] = $date;
228
+                    $newid = $modx->db->insert($field, $tbl_site_content);
229
+                    if($newid) {
230
+                        $find = true;
231
+                        echo ' - <span class="success">' . $_lang['import_site_success'] . '</span><br />' . "\n";
232
+                        importFiles($newid, $filedir . $alias . '/', $value, 'sub');
233
+                    } else {
234
+                        echo '<span class="fail">' . $_lang["import_site_failed"] . "</span> " . $_lang["import_site_failed_db_error"] . $modx->db->getLastError();
235
+                        exit;
236
+                    }
237
+                }
238
+            }
239
+            if($find === false) {
240
+                $date = time();
241
+                $field['pagetitle'] = '---';
242
+                $field['content'] = '';
243
+                $field['createdon'] = $date;
244
+                $field['editedon'] = $date;
245
+                $field['hidemenu'] = '1';
246
+                $newid = $modx->db->insert($field, $tbl_site_content);
247
+                if($newid) {
248
+                    $find = true;
249
+                    echo ' - <span class="success">' . $_lang['import_site_success'] . '</span><br />' . "\n";
250
+                    importFiles($newid, $filedir . $alias . '/', $value, 'sub');
251
+                } else {
252
+                    echo '<span class="fail">' . $_lang["import_site_failed"] . "</span> " . $_lang["import_site_failed_db_error"] . $modx->db->getLastError();
253
+                    exit;
254
+                }
255
+            }
256
+        } else {
257
+            // create document
258
+            if($mode == 'sub' && $value == 'index.html') {
259
+                continue;
260
+            }
261
+            $filename = $value;
262
+            $fparts = explode('.', $value);
263
+            $alias = $fparts[0];
264
+            $ext = (count($fparts) > 1) ? $fparts[count($fparts) - 1] : "";
265
+            printf("<span>" . $_lang['import_site_importing_document'] . "</span>", $filename);
266
+
267
+            if(!in_array($ext, $allowedfiles)) {
268
+                echo ' - <span class="fail">' . $_lang["import_site_skip"] . '</span><br />' . "\n";
269
+            } else {
270
+                $filepath = $filedir . $filename;
271
+                $file = getFileContent($filepath);
272
+                list($pagetitle, $content, $description) = treatContent($file, $filename, $alias);
273
+
274
+                $date = filemtime($filepath);
275
+                $field = array();
276
+                $field['type'] = 'document';
277
+                $field['contentType'] = 'text/html';
278
+                $field['pagetitle'] = $pagetitle;
279
+                $field['longtitle'] = $pagetitle;
280
+                $field['description'] = $description;
281
+                $field['alias'] = $modx->stripAlias($alias);
282
+                $field['published'] = $publish_default;
283
+                $field['parent'] = $parent;
284
+                $field['content'] = $modx->db->escape($content);
285
+                $field['richtext'] = $richtext;
286
+                $field['template'] = $modx->config['default_template'];
287
+                $field['searchable'] = $search_default;
288
+                $field['cacheable'] = $cache_default;
289
+                $field['createdby'] = $createdby;
290
+                $field['createdon'] = $date;
291
+                $field['editedon'] = $date;
292
+                $field['isfolder'] = 0;
293
+                $field['menuindex'] = ($alias == 'index') ? 0 : 2;
294
+                $newid = $modx->db->insert($field, $tbl_site_content);
295
+                if($newid) {
296
+                    echo ' - <span class="success">' . $_lang['import_site_success'] . '</span><br />' . "\n";
297
+                } else {
298
+                    echo '<span class="fail">' . $_lang["import_site_failed"] . "</span> " . $_lang["import_site_failed_db_error"] . $modx->db->getLastError();
299
+                    exit;
300
+                }
301
+
302
+                $is_site_start = false;
303
+                if($filename == 'index.html') {
304
+                    $is_site_start = true;
305
+                }
306
+                if($is_site_start == true && $_POST['reset'] == 'on') {
307
+                    $modx->db->update(array('setting_value' => $newid), $tbl_system_settings, "setting_name='site_start'");
308
+                    $modx->db->update(array('menuindex' => 0), $tbl_site_content, "id='{$newid}'");
309
+                }
310
+            }
311
+        }
312
+    }
313 313
 }
314 314
 
315 315
 /**
@@ -319,27 +319,27 @@  discard block
 block discarded – undo
319 319
  * @return array
320 320
  */
321 321
 function getFiles($directory, $listing = array(), $count = 0) {
322
-	global $_lang;
323
-	global $filesfound;
324
-	$dummy = $count;
325
-	if( ! empty($directory) && $files = scandir($directory)) {
326
-		foreach($files as $file) {
327
-			if($file == '.' || $file == '..') {
328
-				continue;
329
-			} elseif($h = @opendir($directory . $file . "/")) {
330
-				closedir($h);
331
-				$count = -1;
332
-				$listing[$file] = getFiles($directory . $file . "/", array(), $count + 1);
333
-			} elseif(strpos($file, '.htm') !== false) {
334
-				$listing[$dummy] = $file;
335
-				$dummy = $dummy + 1;
336
-				$filesfound++;
337
-			}
338
-		}
339
-	} else {
340
-		echo '<p><span class="fail">' . $_lang["import_site_failed"] . "</span> " . $_lang["import_site_failed_no_open_dir"] . $directory . ".</p>";
341
-	}
342
-	return ($listing);
322
+    global $_lang;
323
+    global $filesfound;
324
+    $dummy = $count;
325
+    if( ! empty($directory) && $files = scandir($directory)) {
326
+        foreach($files as $file) {
327
+            if($file == '.' || $file == '..') {
328
+                continue;
329
+            } elseif($h = @opendir($directory . $file . "/")) {
330
+                closedir($h);
331
+                $count = -1;
332
+                $listing[$file] = getFiles($directory . $file . "/", array(), $count + 1);
333
+            } elseif(strpos($file, '.htm') !== false) {
334
+                $listing[$dummy] = $file;
335
+                $dummy = $dummy + 1;
336
+                $filesfound++;
337
+            }
338
+        }
339
+    } else {
340
+        echo '<p><span class="fail">' . $_lang["import_site_failed"] . "</span> " . $_lang["import_site_failed_no_open_dir"] . $directory . ".</p>";
341
+    }
342
+    return ($listing);
343 343
 }
344 344
 
345 345
 /**
@@ -347,13 +347,13 @@  discard block
 block discarded – undo
347 347
  * @return bool|string
348 348
  */
349 349
 function getFileContent($filepath) {
350
-	global $_lang;
351
-	// get the file
352
-	if(!$buffer = file_get_contents($filepath)) {
353
-		echo '<p><span class="fail">' . $_lang['import_site_failed'] . "</span> " . $_lang["import_site_failed_no_retrieve_file"] . $filepath . ".</p>";
354
-	} else {
355
-		return $buffer;
356
-	}
350
+    global $_lang;
351
+    // get the file
352
+    if(!$buffer = file_get_contents($filepath)) {
353
+        echo '<p><span class="fail">' . $_lang['import_site_failed'] . "</span> " . $_lang["import_site_failed_no_retrieve_file"] . $filepath . ".</p>";
354
+    } else {
355
+        return $buffer;
356
+    }
357 357
 }
358 358
 
359 359
 /**
@@ -361,20 +361,20 @@  discard block
 block discarded – undo
361 361
  * @return array
362 362
  */
363 363
 function pop_index($array) {
364
-	$new_array = array();
365
-	foreach($array as $k => $v) {
366
-		if($v !== 'index.html' && $v !== 'index.htm') {
367
-			$new_array[$k] = $v;
368
-		} else {
369
-			array_unshift($new_array, $v);
370
-		}
371
-	}
372
-	foreach($array as $k => $v) {
373
-		if(is_array($v)) {
374
-			$new_array[$k] = $v;
375
-		}
376
-	}
377
-	return $new_array;
364
+    $new_array = array();
365
+    foreach($array as $k => $v) {
366
+        if($v !== 'index.html' && $v !== 'index.htm') {
367
+            $new_array[$k] = $v;
368
+        } else {
369
+            array_unshift($new_array, $v);
370
+        }
371
+    }
372
+    foreach($array as $k => $v) {
373
+        if(is_array($v)) {
374
+            $new_array[$k] = $v;
375
+        }
376
+    }
377
+    return $new_array;
378 378
 }
379 379
 
380 380
 /**
@@ -384,108 +384,108 @@  discard block
 block discarded – undo
384 384
  * @return array
385 385
  */
386 386
 function treatContent($src, $filename, $alias) {
387
-	$modx = evolutionCMS();
388
-
389
-	$src = mb_convert_encoding($src, $modx->config['modx_charset'], 'UTF-8,SJIS-win,eucJP-win,SJIS,EUC-JP,ASCII');
390
-
391
-	if(preg_match("@<title>(.*)</title>@i", $src, $matches)) {
392
-		$pagetitle = ($matches[1] !== '') ? $matches[1] : $filename;
393
-		$pagetitle = str_replace('[*pagetitle*]', '', $pagetitle);
394
-	} else {
395
-		$pagetitle = $alias;
396
-	}
397
-	if(!$pagetitle) {
398
-		$pagetitle = $alias;
399
-	}
400
-
401
-	if(preg_match('@<meta[^>]+"description"[^>]+content=[\'"](.*)[\'"].+>@i', $src, $matches)) {
402
-		$description = ($matches[1] !== '') ? $matches[1] : $filename;
403
-		$description = str_replace('[*description*]', '', $description);
404
-	} else {
405
-		$description = '';
406
-	}
407
-
408
-	if((preg_match("@<body[^>]*>(.*)[^<]+</body>@is", $src, $matches)) && $_POST['object'] == 'body') {
409
-		$content = $matches[1];
410
-	} else {
411
-		$content = $src;
412
-		$s = '/(<meta[^>]+charset\s*=)[^>"\'=]+(.+>)/i';
413
-		$r = '$1' . $modx->config['modx_charset'] . '$2';
414
-		$content = preg_replace($s, $r, $content);
415
-		$content = preg_replace('@<title>.*</title>@i', "<title>[*pagetitle*]</title>", $content);
416
-	}
417
-	$content = str_replace('[*content*]', '[ *content* ]', $content);
418
-	$content = trim($content);
419
-	$pagetitle = $modx->db->escape($pagetitle);
420
-	return array(
421
-		$pagetitle,
422
-		$content,
423
-		$description
424
-	);
387
+    $modx = evolutionCMS();
388
+
389
+    $src = mb_convert_encoding($src, $modx->config['modx_charset'], 'UTF-8,SJIS-win,eucJP-win,SJIS,EUC-JP,ASCII');
390
+
391
+    if(preg_match("@<title>(.*)</title>@i", $src, $matches)) {
392
+        $pagetitle = ($matches[1] !== '') ? $matches[1] : $filename;
393
+        $pagetitle = str_replace('[*pagetitle*]', '', $pagetitle);
394
+    } else {
395
+        $pagetitle = $alias;
396
+    }
397
+    if(!$pagetitle) {
398
+        $pagetitle = $alias;
399
+    }
400
+
401
+    if(preg_match('@<meta[^>]+"description"[^>]+content=[\'"](.*)[\'"].+>@i', $src, $matches)) {
402
+        $description = ($matches[1] !== '') ? $matches[1] : $filename;
403
+        $description = str_replace('[*description*]', '', $description);
404
+    } else {
405
+        $description = '';
406
+    }
407
+
408
+    if((preg_match("@<body[^>]*>(.*)[^<]+</body>@is", $src, $matches)) && $_POST['object'] == 'body') {
409
+        $content = $matches[1];
410
+    } else {
411
+        $content = $src;
412
+        $s = '/(<meta[^>]+charset\s*=)[^>"\'=]+(.+>)/i';
413
+        $r = '$1' . $modx->config['modx_charset'] . '$2';
414
+        $content = preg_replace($s, $r, $content);
415
+        $content = preg_replace('@<title>.*</title>@i', "<title>[*pagetitle*]</title>", $content);
416
+    }
417
+    $content = str_replace('[*content*]', '[ *content* ]', $content);
418
+    $content = trim($content);
419
+    $pagetitle = $modx->db->escape($pagetitle);
420
+    return array(
421
+        $pagetitle,
422
+        $content,
423
+        $description
424
+    );
425 425
 }
426 426
 
427 427
 /**
428 428
  * @return void
429 429
  */
430 430
 function convertLink() {
431
-	$modx = evolutionCMS();
432
-	$tbl_site_content = $modx->getFullTableName('site_content');
431
+    $modx = evolutionCMS();
432
+    $tbl_site_content = $modx->getFullTableName('site_content');
433 433
 
434
-	$rs = $modx->db->select('id,content', $tbl_site_content);
435
-	$p = array();
434
+    $rs = $modx->db->select('id,content', $tbl_site_content);
435
+    $p = array();
436 436
     $target = array();
437
-	$dir = '';
438
-	while($row = $modx->db->getRow($rs)) {
439
-		$id = $row['id'];
440
-		$array = explode('<a href=', $row['content']);
441
-		$c = 0;
442
-		foreach($array as $v) {
443
-			if($v[0] === '"') {
444
-				$v = substr($v, 1);
445
-				list($href, $v) = explode('"', $v, 2);
446
-				$_ = $href;
447
-				if(strpos($_, $modx->config['site_url']) !== false) {
448
-					$_ = $modx->config['base_url'] . str_replace($modx->config['site_url'], '', $_);
449
-				}
450
-				if($_[0] === '/') {
451
-					$_ = substr($_, 1);
452
-				}
453
-				$_ = str_replace('/index.html', '.html', $_);
454
-				$level = substr_count($_, '../');
455
-				if(1 < $level) {
456
-					if(!isset($p[$id])) {
457
-						$p[$id] = $modx->getParentIds($id);
458
-					}
459
-					$k = array_keys($p[$id]);
460
-					while(0 < $level) {
461
-						$dir = array_shift($k);
462
-						$level--;
463
-					}
464
-					if($dir != '') {
465
-						$dir .= '/';
466
-					}
467
-				} else {
468
-					$dir = '';
469
-				}
470
-
471
-				$_ = trim($_, './');
472
-				if(strpos($_, '/') !== false) {
473
-					$_ = substr($_, strrpos($_, '/'));
474
-				}
475
-				$_ = $dir . str_replace('.html', '', $_);
476
-				if(!isset($target[$_])) {
477
-					$target[$_] = $modx->getIdFromAlias($_);
478
-				}
479
-				$target[$_] = trim($target[$_]);
480
-				if(!empty($target[$_])) {
481
-					$href = '[~' . $target[$_] . '~]';
482
-				}
483
-				$array[$c] = '<a href="' . $href . '"' . $v;
484
-			}
485
-			$c++;
486
-		}
487
-		$content = implode('', $array);
488
-		$f['content'] = $modx->db->escape($content);
489
-		$modx->db->update($f, $tbl_site_content, "id='{$id}'");
490
-	}
437
+    $dir = '';
438
+    while($row = $modx->db->getRow($rs)) {
439
+        $id = $row['id'];
440
+        $array = explode('<a href=', $row['content']);
441
+        $c = 0;
442
+        foreach($array as $v) {
443
+            if($v[0] === '"') {
444
+                $v = substr($v, 1);
445
+                list($href, $v) = explode('"', $v, 2);
446
+                $_ = $href;
447
+                if(strpos($_, $modx->config['site_url']) !== false) {
448
+                    $_ = $modx->config['base_url'] . str_replace($modx->config['site_url'], '', $_);
449
+                }
450
+                if($_[0] === '/') {
451
+                    $_ = substr($_, 1);
452
+                }
453
+                $_ = str_replace('/index.html', '.html', $_);
454
+                $level = substr_count($_, '../');
455
+                if(1 < $level) {
456
+                    if(!isset($p[$id])) {
457
+                        $p[$id] = $modx->getParentIds($id);
458
+                    }
459
+                    $k = array_keys($p[$id]);
460
+                    while(0 < $level) {
461
+                        $dir = array_shift($k);
462
+                        $level--;
463
+                    }
464
+                    if($dir != '') {
465
+                        $dir .= '/';
466
+                    }
467
+                } else {
468
+                    $dir = '';
469
+                }
470
+
471
+                $_ = trim($_, './');
472
+                if(strpos($_, '/') !== false) {
473
+                    $_ = substr($_, strrpos($_, '/'));
474
+                }
475
+                $_ = $dir . str_replace('.html', '', $_);
476
+                if(!isset($target[$_])) {
477
+                    $target[$_] = $modx->getIdFromAlias($_);
478
+                }
479
+                $target[$_] = trim($target[$_]);
480
+                if(!empty($target[$_])) {
481
+                    $href = '[~' . $target[$_] . '~]';
482
+                }
483
+                $array[$c] = '<a href="' . $href . '"' . $v;
484
+            }
485
+            $c++;
486
+        }
487
+        $content = implode('', $array);
488
+        $f['content'] = $modx->db->escape($content);
489
+        $modx->db->update($f, $tbl_site_content, "id='{$id}'");
490
+    }
491 491
 }
Please login to merge, or discard this patch.
Spacing   +83 added lines, -83 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) {
2
+if (!defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) {
3 3
 	die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly.");
4 4
 }
5
-if(!$modx->hasPermission('import_static')) {
5
+if (!$modx->hasPermission('import_static')) {
6 6
 	$modx->webAlertAndQuit($_lang["error_no_privileges"]);
7 7
 }
8 8
 
@@ -43,8 +43,8 @@  discard block
 block discarded – undo
43 43
 	<div class="tab-page">
44 44
 		<div class="container container-body">
45 45
 			<?php
46
-			if(!isset($_POST['import'])) {
47
-				echo "<div class=\"element-edit-message\">" . $_lang['import_site_message'] . "</div>";
46
+			if (!isset($_POST['import'])) {
47
+				echo "<div class=\"element-edit-message\">".$_lang['import_site_message']."</div>";
48 48
 				?>
49 49
 				<form action="index.php" method="post" name="importFrm">
50 50
 					<input type="hidden" name="import" value="import" />
@@ -104,14 +104,14 @@  discard block
 block discarded – undo
104 104
 /**
105 105
  * @return string
106 106
  */
107
-function run() {
107
+function run(){
108 108
 	$modx = evolutionCMS(); global $_lang;
109 109
 
110 110
 	$tbl_site_content = $modx->getFullTableName('site_content');
111 111
 	$output = '';
112 112
 	$maxtime = $_POST['maxtime'];
113 113
 
114
-	if(!is_numeric($maxtime)) {
114
+	if (!is_numeric($maxtime)) {
115 115
 		$maxtime = 30;
116 116
 	}
117 117
 
@@ -122,17 +122,17 @@  discard block
 block discarded – undo
122 122
 	$mtime = $mtime[1] + $mtime[0];
123 123
 	$importstart = $mtime;
124 124
 
125
-	if($_POST['reset'] == 'on') {
125
+	if ($_POST['reset'] == 'on') {
126 126
 		$modx->db->truncate($tbl_site_content);
127 127
 		$modx->db->query("ALTER TABLE {$tbl_site_content} AUTO_INCREMENT = 1");
128 128
 	}
129 129
 
130
-	$parent = (int)$_POST['parent'];
130
+	$parent = (int) $_POST['parent'];
131 131
 
132
-	if(is_dir(MODX_BASE_PATH . 'temp/import')) {
133
-		$filedir = MODX_BASE_PATH . 'temp/import/';
134
-	} elseif(is_dir(MODX_BASE_PATH . 'assets/import')) {
135
-		$filedir = MODX_BASE_PATH . 'assets/import/';
132
+	if (is_dir(MODX_BASE_PATH.'temp/import')) {
133
+		$filedir = MODX_BASE_PATH.'temp/import/';
134
+	} elseif (is_dir(MODX_BASE_PATH.'assets/import')) {
135
+		$filedir = MODX_BASE_PATH.'assets/import/';
136 136
 	} else {
137 137
         $filedir = '';
138 138
     }
@@ -143,10 +143,10 @@  discard block
 block discarded – undo
143 143
 	$files = pop_index($files);
144 144
 
145 145
 	// no. of files to import
146
-	$output .= sprintf('<p>' . $_lang['import_files_found'] . '</p>', $filesfound);
146
+	$output .= sprintf('<p>'.$_lang['import_files_found'].'</p>', $filesfound);
147 147
 
148 148
 	// import files
149
-	if(0 < count($files)) {
149
+	if (0 < count($files)) {
150 150
 		$modx->db->update(array('isfolder' => 1), $tbl_site_content, "id='{$parent}'");
151 151
 		importFiles($parent, $filedir, $files, 'root');
152 152
 	}
@@ -156,9 +156,9 @@  discard block
 block discarded – undo
156 156
 	$mtime = $mtime[1] + $mtime[0];
157 157
 	$importend = $mtime;
158 158
 	$totaltime = ($importend - $importstart);
159
-	$output .= sprintf('<p>' . $_lang['import_site_time'] . '</p>', round($totaltime, 3));
159
+	$output .= sprintf('<p>'.$_lang['import_site_time'].'</p>', round($totaltime, 3));
160 160
 
161
-	if($_POST['convert_link'] == 'on') {
161
+	if ($_POST['convert_link'] == 'on') {
162 162
 		convertLink();
163 163
 	}
164 164
 
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
  * @param array $files
172 172
  * @param string $mode
173 173
  */
174
-function importFiles($parent, $filedir, $files, $mode) {
174
+function importFiles($parent, $filedir, $files, $mode){
175 175
 	$modx = evolutionCMS();
176 176
 	global $_lang, $allowedfiles;
177 177
 	global $search_default, $cache_default, $publish_default;
@@ -180,21 +180,21 @@  discard block
 block discarded – undo
180 180
 	$tbl_system_settings = $modx->getFullTableName('system_settings');
181 181
 
182 182
 	$createdby = $modx->getLoginUserID();
183
-	if(!is_array($files)) {
183
+	if (!is_array($files)) {
184 184
 		return;
185 185
 	}
186
-	if($_POST['object'] === 'all') {
186
+	if ($_POST['object'] === 'all') {
187 187
 		$modx->config['default_template'] = '0';
188 188
 		$richtext = '0';
189 189
 	} else {
190 190
 		$richtext = '1';
191 191
 	}
192 192
 
193
-	foreach($files as $id => $value) {
194
-		if(is_array($value)) {
193
+	foreach ($files as $id => $value) {
194
+		if (is_array($value)) {
195 195
 			// create folder
196 196
 			$alias = $id;
197
-			printf('<span>' . $_lang['import_site_importing_document'] . '</span>', $alias);
197
+			printf('<span>'.$_lang['import_site_importing_document'].'</span>', $alias);
198 198
 			$field = array();
199 199
 			$field['type'] = 'document';
200 200
 			$field['contentType'] = 'text/html';
@@ -209,12 +209,12 @@  discard block
 block discarded – undo
209 209
 			$field['isfolder'] = 1;
210 210
 			$field['menuindex'] = 1;
211 211
 			$find = false;
212
-			foreach(array(
212
+			foreach (array(
213 213
 						'index.html',
214 214
 						'index.htm'
215 215
 					) as $filename) {
216
-				$filepath = $filedir . $alias . '/' . $filename;
217
-				if($find === false && file_exists($filepath)) {
216
+				$filepath = $filedir.$alias.'/'.$filename;
217
+				if ($find === false && file_exists($filepath)) {
218 218
 					$file = getFileContent($filepath);
219 219
 					list($pagetitle, $content, $description) = treatContent($file, $filename, $alias);
220 220
 
@@ -226,17 +226,17 @@  discard block
 block discarded – undo
226 226
 					$field['createdon'] = $date;
227 227
 					$field['editedon'] = $date;
228 228
 					$newid = $modx->db->insert($field, $tbl_site_content);
229
-					if($newid) {
229
+					if ($newid) {
230 230
 						$find = true;
231
-						echo ' - <span class="success">' . $_lang['import_site_success'] . '</span><br />' . "\n";
232
-						importFiles($newid, $filedir . $alias . '/', $value, 'sub');
231
+						echo ' - <span class="success">'.$_lang['import_site_success'].'</span><br />'."\n";
232
+						importFiles($newid, $filedir.$alias.'/', $value, 'sub');
233 233
 					} else {
234
-						echo '<span class="fail">' . $_lang["import_site_failed"] . "</span> " . $_lang["import_site_failed_db_error"] . $modx->db->getLastError();
234
+						echo '<span class="fail">'.$_lang["import_site_failed"]."</span> ".$_lang["import_site_failed_db_error"].$modx->db->getLastError();
235 235
 						exit;
236 236
 					}
237 237
 				}
238 238
 			}
239
-			if($find === false) {
239
+			if ($find === false) {
240 240
 				$date = time();
241 241
 				$field['pagetitle'] = '---';
242 242
 				$field['content'] = '';
@@ -244,30 +244,30 @@  discard block
 block discarded – undo
244 244
 				$field['editedon'] = $date;
245 245
 				$field['hidemenu'] = '1';
246 246
 				$newid = $modx->db->insert($field, $tbl_site_content);
247
-				if($newid) {
247
+				if ($newid) {
248 248
 					$find = true;
249
-					echo ' - <span class="success">' . $_lang['import_site_success'] . '</span><br />' . "\n";
250
-					importFiles($newid, $filedir . $alias . '/', $value, 'sub');
249
+					echo ' - <span class="success">'.$_lang['import_site_success'].'</span><br />'."\n";
250
+					importFiles($newid, $filedir.$alias.'/', $value, 'sub');
251 251
 				} else {
252
-					echo '<span class="fail">' . $_lang["import_site_failed"] . "</span> " . $_lang["import_site_failed_db_error"] . $modx->db->getLastError();
252
+					echo '<span class="fail">'.$_lang["import_site_failed"]."</span> ".$_lang["import_site_failed_db_error"].$modx->db->getLastError();
253 253
 					exit;
254 254
 				}
255 255
 			}
256 256
 		} else {
257 257
 			// create document
258
-			if($mode == 'sub' && $value == 'index.html') {
258
+			if ($mode == 'sub' && $value == 'index.html') {
259 259
 				continue;
260 260
 			}
261 261
 			$filename = $value;
262 262
 			$fparts = explode('.', $value);
263 263
 			$alias = $fparts[0];
264 264
 			$ext = (count($fparts) > 1) ? $fparts[count($fparts) - 1] : "";
265
-			printf("<span>" . $_lang['import_site_importing_document'] . "</span>", $filename);
265
+			printf("<span>".$_lang['import_site_importing_document']."</span>", $filename);
266 266
 
267
-			if(!in_array($ext, $allowedfiles)) {
268
-				echo ' - <span class="fail">' . $_lang["import_site_skip"] . '</span><br />' . "\n";
267
+			if (!in_array($ext, $allowedfiles)) {
268
+				echo ' - <span class="fail">'.$_lang["import_site_skip"].'</span><br />'."\n";
269 269
 			} else {
270
-				$filepath = $filedir . $filename;
270
+				$filepath = $filedir.$filename;
271 271
 				$file = getFileContent($filepath);
272 272
 				list($pagetitle, $content, $description) = treatContent($file, $filename, $alias);
273 273
 
@@ -292,18 +292,18 @@  discard block
 block discarded – undo
292 292
 				$field['isfolder'] = 0;
293 293
 				$field['menuindex'] = ($alias == 'index') ? 0 : 2;
294 294
 				$newid = $modx->db->insert($field, $tbl_site_content);
295
-				if($newid) {
296
-					echo ' - <span class="success">' . $_lang['import_site_success'] . '</span><br />' . "\n";
295
+				if ($newid) {
296
+					echo ' - <span class="success">'.$_lang['import_site_success'].'</span><br />'."\n";
297 297
 				} else {
298
-					echo '<span class="fail">' . $_lang["import_site_failed"] . "</span> " . $_lang["import_site_failed_db_error"] . $modx->db->getLastError();
298
+					echo '<span class="fail">'.$_lang["import_site_failed"]."</span> ".$_lang["import_site_failed_db_error"].$modx->db->getLastError();
299 299
 					exit;
300 300
 				}
301 301
 
302 302
 				$is_site_start = false;
303
-				if($filename == 'index.html') {
303
+				if ($filename == 'index.html') {
304 304
 					$is_site_start = true;
305 305
 				}
306
-				if($is_site_start == true && $_POST['reset'] == 'on') {
306
+				if ($is_site_start == true && $_POST['reset'] == 'on') {
307 307
 					$modx->db->update(array('setting_value' => $newid), $tbl_system_settings, "setting_name='site_start'");
308 308
 					$modx->db->update(array('menuindex' => 0), $tbl_site_content, "id='{$newid}'");
309 309
 				}
@@ -318,26 +318,26 @@  discard block
 block discarded – undo
318 318
  * @param int $count
319 319
  * @return array
320 320
  */
321
-function getFiles($directory, $listing = array(), $count = 0) {
321
+function getFiles($directory, $listing = array(), $count = 0){
322 322
 	global $_lang;
323 323
 	global $filesfound;
324 324
 	$dummy = $count;
325
-	if( ! empty($directory) && $files = scandir($directory)) {
326
-		foreach($files as $file) {
327
-			if($file == '.' || $file == '..') {
325
+	if (!empty($directory) && $files = scandir($directory)) {
326
+		foreach ($files as $file) {
327
+			if ($file == '.' || $file == '..') {
328 328
 				continue;
329
-			} elseif($h = @opendir($directory . $file . "/")) {
329
+			} elseif ($h = @opendir($directory.$file."/")) {
330 330
 				closedir($h);
331 331
 				$count = -1;
332
-				$listing[$file] = getFiles($directory . $file . "/", array(), $count + 1);
333
-			} elseif(strpos($file, '.htm') !== false) {
332
+				$listing[$file] = getFiles($directory.$file."/", array(), $count + 1);
333
+			} elseif (strpos($file, '.htm') !== false) {
334 334
 				$listing[$dummy] = $file;
335 335
 				$dummy = $dummy + 1;
336 336
 				$filesfound++;
337 337
 			}
338 338
 		}
339 339
 	} else {
340
-		echo '<p><span class="fail">' . $_lang["import_site_failed"] . "</span> " . $_lang["import_site_failed_no_open_dir"] . $directory . ".</p>";
340
+		echo '<p><span class="fail">'.$_lang["import_site_failed"]."</span> ".$_lang["import_site_failed_no_open_dir"].$directory.".</p>";
341 341
 	}
342 342
 	return ($listing);
343 343
 }
@@ -346,11 +346,11 @@  discard block
 block discarded – undo
346 346
  * @param string $filepath
347 347
  * @return bool|string
348 348
  */
349
-function getFileContent($filepath) {
349
+function getFileContent($filepath){
350 350
 	global $_lang;
351 351
 	// get the file
352
-	if(!$buffer = file_get_contents($filepath)) {
353
-		echo '<p><span class="fail">' . $_lang['import_site_failed'] . "</span> " . $_lang["import_site_failed_no_retrieve_file"] . $filepath . ".</p>";
352
+	if (!$buffer = file_get_contents($filepath)) {
353
+		echo '<p><span class="fail">'.$_lang['import_site_failed']."</span> ".$_lang["import_site_failed_no_retrieve_file"].$filepath.".</p>";
354 354
 	} else {
355 355
 		return $buffer;
356 356
 	}
@@ -360,17 +360,17 @@  discard block
 block discarded – undo
360 360
  * @param array $array
361 361
  * @return array
362 362
  */
363
-function pop_index($array) {
363
+function pop_index($array){
364 364
 	$new_array = array();
365
-	foreach($array as $k => $v) {
366
-		if($v !== 'index.html' && $v !== 'index.htm') {
365
+	foreach ($array as $k => $v) {
366
+		if ($v !== 'index.html' && $v !== 'index.htm') {
367 367
 			$new_array[$k] = $v;
368 368
 		} else {
369 369
 			array_unshift($new_array, $v);
370 370
 		}
371 371
 	}
372
-	foreach($array as $k => $v) {
373
-		if(is_array($v)) {
372
+	foreach ($array as $k => $v) {
373
+		if (is_array($v)) {
374 374
 			$new_array[$k] = $v;
375 375
 		}
376 376
 	}
@@ -383,34 +383,34 @@  discard block
 block discarded – undo
383 383
  * @param string $alias
384 384
  * @return array
385 385
  */
386
-function treatContent($src, $filename, $alias) {
386
+function treatContent($src, $filename, $alias){
387 387
 	$modx = evolutionCMS();
388 388
 
389 389
 	$src = mb_convert_encoding($src, $modx->config['modx_charset'], 'UTF-8,SJIS-win,eucJP-win,SJIS,EUC-JP,ASCII');
390 390
 
391
-	if(preg_match("@<title>(.*)</title>@i", $src, $matches)) {
391
+	if (preg_match("@<title>(.*)</title>@i", $src, $matches)) {
392 392
 		$pagetitle = ($matches[1] !== '') ? $matches[1] : $filename;
393 393
 		$pagetitle = str_replace('[*pagetitle*]', '', $pagetitle);
394 394
 	} else {
395 395
 		$pagetitle = $alias;
396 396
 	}
397
-	if(!$pagetitle) {
397
+	if (!$pagetitle) {
398 398
 		$pagetitle = $alias;
399 399
 	}
400 400
 
401
-	if(preg_match('@<meta[^>]+"description"[^>]+content=[\'"](.*)[\'"].+>@i', $src, $matches)) {
401
+	if (preg_match('@<meta[^>]+"description"[^>]+content=[\'"](.*)[\'"].+>@i', $src, $matches)) {
402 402
 		$description = ($matches[1] !== '') ? $matches[1] : $filename;
403 403
 		$description = str_replace('[*description*]', '', $description);
404 404
 	} else {
405 405
 		$description = '';
406 406
 	}
407 407
 
408
-	if((preg_match("@<body[^>]*>(.*)[^<]+</body>@is", $src, $matches)) && $_POST['object'] == 'body') {
408
+	if ((preg_match("@<body[^>]*>(.*)[^<]+</body>@is", $src, $matches)) && $_POST['object'] == 'body') {
409 409
 		$content = $matches[1];
410 410
 	} else {
411 411
 		$content = $src;
412 412
 		$s = '/(<meta[^>]+charset\s*=)[^>"\'=]+(.+>)/i';
413
-		$r = '$1' . $modx->config['modx_charset'] . '$2';
413
+		$r = '$1'.$modx->config['modx_charset'].'$2';
414 414
 		$content = preg_replace($s, $r, $content);
415 415
 		$content = preg_replace('@<title>.*</title>@i', "<title>[*pagetitle*]</title>", $content);
416 416
 	}
@@ -427,7 +427,7 @@  discard block
 block discarded – undo
427 427
 /**
428 428
  * @return void
429 429
  */
430
-function convertLink() {
430
+function convertLink(){
431 431
 	$modx = evolutionCMS();
432 432
 	$tbl_site_content = $modx->getFullTableName('site_content');
433 433
 
@@ -435,33 +435,33 @@  discard block
 block discarded – undo
435 435
 	$p = array();
436 436
     $target = array();
437 437
 	$dir = '';
438
-	while($row = $modx->db->getRow($rs)) {
438
+	while ($row = $modx->db->getRow($rs)) {
439 439
 		$id = $row['id'];
440 440
 		$array = explode('<a href=', $row['content']);
441 441
 		$c = 0;
442
-		foreach($array as $v) {
443
-			if($v[0] === '"') {
442
+		foreach ($array as $v) {
443
+			if ($v[0] === '"') {
444 444
 				$v = substr($v, 1);
445 445
 				list($href, $v) = explode('"', $v, 2);
446 446
 				$_ = $href;
447
-				if(strpos($_, $modx->config['site_url']) !== false) {
448
-					$_ = $modx->config['base_url'] . str_replace($modx->config['site_url'], '', $_);
447
+				if (strpos($_, $modx->config['site_url']) !== false) {
448
+					$_ = $modx->config['base_url'].str_replace($modx->config['site_url'], '', $_);
449 449
 				}
450
-				if($_[0] === '/') {
450
+				if ($_[0] === '/') {
451 451
 					$_ = substr($_, 1);
452 452
 				}
453 453
 				$_ = str_replace('/index.html', '.html', $_);
454 454
 				$level = substr_count($_, '../');
455
-				if(1 < $level) {
456
-					if(!isset($p[$id])) {
455
+				if (1 < $level) {
456
+					if (!isset($p[$id])) {
457 457
 						$p[$id] = $modx->getParentIds($id);
458 458
 					}
459 459
 					$k = array_keys($p[$id]);
460
-					while(0 < $level) {
460
+					while (0 < $level) {
461 461
 						$dir = array_shift($k);
462 462
 						$level--;
463 463
 					}
464
-					if($dir != '') {
464
+					if ($dir != '') {
465 465
 						$dir .= '/';
466 466
 					}
467 467
 				} else {
@@ -469,18 +469,18 @@  discard block
 block discarded – undo
469 469
 				}
470 470
 
471 471
 				$_ = trim($_, './');
472
-				if(strpos($_, '/') !== false) {
472
+				if (strpos($_, '/') !== false) {
473 473
 					$_ = substr($_, strrpos($_, '/'));
474 474
 				}
475
-				$_ = $dir . str_replace('.html', '', $_);
476
-				if(!isset($target[$_])) {
475
+				$_ = $dir.str_replace('.html', '', $_);
476
+				if (!isset($target[$_])) {
477 477
 					$target[$_] = $modx->getIdFromAlias($_);
478 478
 				}
479 479
 				$target[$_] = trim($target[$_]);
480
-				if(!empty($target[$_])) {
481
-					$href = '[~' . $target[$_] . '~]';
480
+				if (!empty($target[$_])) {
481
+					$href = '[~'.$target[$_].'~]';
482 482
 				}
483
-				$array[$c] = '<a href="' . $href . '"' . $v;
483
+				$array[$c] = '<a href="'.$href.'"'.$v;
484 484
 			}
485 485
 			$c++;
486 486
 		}
Please login to merge, or discard this patch.
Braces   +14 added lines, -7 removed lines patch added patch discarded remove patch
@@ -104,7 +104,8 @@  discard block
 block discarded – undo
104 104
 /**
105 105
  * @return string
106 106
  */
107
-function run() {
107
+function run()
108
+{
108 109
 	$modx = evolutionCMS(); global $_lang;
109 110
 
110 111
 	$tbl_site_content = $modx->getFullTableName('site_content');
@@ -171,7 +172,8 @@  discard block
 block discarded – undo
171 172
  * @param array $files
172 173
  * @param string $mode
173 174
  */
174
-function importFiles($parent, $filedir, $files, $mode) {
175
+function importFiles($parent, $filedir, $files, $mode)
176
+{
175 177
 	$modx = evolutionCMS();
176 178
 	global $_lang, $allowedfiles;
177 179
 	global $search_default, $cache_default, $publish_default;
@@ -318,7 +320,8 @@  discard block
 block discarded – undo
318 320
  * @param int $count
319 321
  * @return array
320 322
  */
321
-function getFiles($directory, $listing = array(), $count = 0) {
323
+function getFiles($directory, $listing = array(), $count = 0)
324
+{
322 325
 	global $_lang;
323 326
 	global $filesfound;
324 327
 	$dummy = $count;
@@ -346,7 +349,8 @@  discard block
 block discarded – undo
346 349
  * @param string $filepath
347 350
  * @return bool|string
348 351
  */
349
-function getFileContent($filepath) {
352
+function getFileContent($filepath)
353
+{
350 354
 	global $_lang;
351 355
 	// get the file
352 356
 	if(!$buffer = file_get_contents($filepath)) {
@@ -360,7 +364,8 @@  discard block
 block discarded – undo
360 364
  * @param array $array
361 365
  * @return array
362 366
  */
363
-function pop_index($array) {
367
+function pop_index($array)
368
+{
364 369
 	$new_array = array();
365 370
 	foreach($array as $k => $v) {
366 371
 		if($v !== 'index.html' && $v !== 'index.htm') {
@@ -383,7 +388,8 @@  discard block
 block discarded – undo
383 388
  * @param string $alias
384 389
  * @return array
385 390
  */
386
-function treatContent($src, $filename, $alias) {
391
+function treatContent($src, $filename, $alias)
392
+{
387 393
 	$modx = evolutionCMS();
388 394
 
389 395
 	$src = mb_convert_encoding($src, $modx->config['modx_charset'], 'UTF-8,SJIS-win,eucJP-win,SJIS,EUC-JP,ASCII');
@@ -427,7 +433,8 @@  discard block
 block discarded – undo
427 433
 /**
428 434
  * @return void
429 435
  */
430
-function convertLink() {
436
+function convertLink()
437
+{
431 438
 	$modx = evolutionCMS();
432 439
 	$tbl_site_content = $modx->getFullTableName('site_content');
433 440
 
Please login to merge, or discard this patch.
manager/includes/controls/datagrid.class.php 4 patches
Doc Comments   +7 added lines patch added patch discarded remove patch
@@ -72,6 +72,10 @@  discard block
 block discarded – undo
72 72
      */
73 73
     public $cdelim;
74 74
 
75
+    /**
76
+     * @param null|string $id
77
+     * @param string $ds
78
+     */
75 79
     public function __construct($id, $ds, $pageSize = 20, $pageNumber = -1) {
76 80
 		global $__DataGridCnt;
77 81
 
@@ -207,6 +211,9 @@  discard block
 block discarded – undo
207 211
 
208 212
 	// format column values
209 213
 
214
+    /**
215
+     * @param integer $n
216
+     */
210 217
     public function RenderRowFnc($n, $row) {
211 218
 		if($this->_alt == 0) {
212 219
 			$Style = $this->_itemStyle;
Please login to merge, or discard this patch.
Indentation   +225 added lines, -225 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
 
13 13
 class DataGrid {
14 14
 
15
-	public $ds; // datasource
15
+    public $ds; // datasource
16 16
     public $id;
17 17
     public $pageSize;            // pager settings
18 18
     public $pageNumber;
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
     public $colWraps;
37 37
     public $colColors;
38 38
     public $colTypes;            // coltype1, coltype2, etc or coltype1:format1, e.g. date:%Y %m
39
-	// data type: integer,float,currency,date
39
+    // data type: integer,float,currency,date
40 40
 
41 41
     public $header;
42 42
     public $footer;
@@ -73,239 +73,239 @@  discard block
 block discarded – undo
73 73
     public $cdelim;
74 74
 
75 75
     public function __construct($id, $ds, $pageSize = 20, $pageNumber = -1) {
76
-		global $__DataGridCnt;
76
+        global $__DataGridCnt;
77 77
 
78
-		// set id
79
-		$__DataGridCnt++;
80
-		$this->id = $this->id ? empty($id) : "dg" . $__DataGridCnt;
78
+        // set id
79
+        $__DataGridCnt++;
80
+        $this->id = $this->id ? empty($id) : "dg" . $__DataGridCnt;
81 81
 
82
-		// set datasource
83
-		$this->ds = $ds;
82
+        // set datasource
83
+        $this->ds = $ds;
84 84
 
85
-		// set pager
86
-		$this->pageSize = $pageSize;
87
-		$this->pageNumber = $pageNumber; // by setting pager to -1 will cause pager to load it's last page number
88
-		$this->pagerLocation = 'top-right';
89
-	}
85
+        // set pager
86
+        $this->pageSize = $pageSize;
87
+        $this->pageNumber = $pageNumber; // by setting pager to -1 will cause pager to load it's last page number
88
+        $this->pagerLocation = 'top-right';
89
+    }
90 90
 
91 91
     public function setDataSource($ds) {
92
-		$this->ds = $ds;
93
-	}
92
+        $this->ds = $ds;
93
+    }
94 94
 
95 95
     public function render() {
96 96
         $modx = evolutionCMS();
97
-		$columnHeaderStyle = ($this->columnHeaderStyle) ? "style='" . $this->columnHeaderStyle . "'" : '';
98
-		$columnHeaderClass = ($this->columnHeaderClass) ? "class='" . $this->columnHeaderClass . "'" : "";
99
-		$cssStyle = ($this->cssStyle) ? "style='" . $this->cssStyle . "'" : '';
100
-		$cssClass = ($this->cssClass) ? "class='" . $this->cssClass . "'" : '';
101
-
102
-		$pagerClass = ($this->pagerClass) ? "class='" . $this->pagerClass . "'" : '';
103
-		$pagerStyle = ($this->pagerStyle) ? "style='" . $this->pagerStyle . "'" : "style='background-color:#ffffff;'";
104
-
105
-		$this->_itemStyle = ($this->itemStyle) ? "style='" . $this->itemStyle . "'" : '';
106
-		$this->_itemClass = ($this->itemClass) ? "class='" . $this->itemClass . "'" : '';
107
-		$this->_altItemStyle = ($this->altItemStyle) ? "style='" . $this->altItemStyle . "'" : '';
108
-		$this->_altItemClass = ($this->altItemClass) ? "class='" . $this->altItemClass . "'" : '';
109
-
110
-		$this->_alt = 0;
111
-		$this->_total = 0;
112
-
113
-		$this->_isDataset = $modx->db->isResult($this->ds); // if not dataset then treat as array
114
-
115
-		if(!$cssStyle && !$cssClass) {
116
-			$cssStyle = "style='width:100%;border:1px solid silver;font-family:verdana,arial; font-size:11px;'";
117
-		}
118
-		if(!$columnHeaderStyle && !$columnHeaderClass) {
119
-			$columnHeaderStyle = "style='color:black;background-color:silver'";
120
-		}
121
-		if(!$this->_itemStyle && !$this->_itemClass) {
122
-			$this->_itemStyle = "style='color:black;'";
123
-		}
124
-		if(!$this->_altItemStyle && !$this->_altItemClass) {
125
-			$this->_altItemStyle = "style='color:black;background-color:#eeeeee'";
126
-		}
127
-
128
-		if($this->_isDataset && !$this->columns) {
129
-			$cols = $modx->db->numFields($this->ds);
130
-			for($i = 0; $i < $cols; $i++) $this->columns .= ($i ? "," : "") . $modx->db->fieldName($this->ds, $i);
131
-		}
132
-
133
-		// start grid
134
-		$tblStart = "<table $cssClass $cssStyle cellpadding='" . (isset($this->cellPadding) ? (int) $this->cellPadding : 1) . "' cellspacing='" . (isset($this->cellSpacing) ? (int) $this->cellSpacing : 1) . "'>";
135
-		$tblEnd = "</table>";
136
-
137
-		// build column header
138
-		$this->_colnames = explode((strstr($this->columns, "||") !== false ? "||" : ","), $this->columns);
139
-		$this->_colwidths = explode((strstr($this->colWidths, "||") !== false ? "||" : ","), $this->colWidths);
140
-		$this->_colaligns = explode((strstr($this->colAligns, "||") !== false ? "||" : ","), $this->colAligns);
141
-		$this->_colwraps = explode((strstr($this->colWraps, "||") !== false ? "||" : ","), $this->colWraps);
142
-		$this->_colcolors = explode((strstr($this->colColors, "||") !== false ? "||" : ","), $this->colColors);
143
-		$this->_coltypes = explode((strstr($this->colTypes, "||") !== false ? "||" : ","), $this->colTypes);
144
-		$this->_colcount = count($this->_colnames);
145
-		if(!$this->_isDataset) {
146
-			$this->ds = explode((strstr($this->ds, "||") !== false ? "||" : ","), $this->ds);
147
-			$this->ds = array_chunk($this->ds, $this->_colcount);
148
-		}
149
-		$tblColHdr = "<thead><tr>";
150
-		for($c = 0; $c < $this->_colcount; $c++) {
151
-			$name = $this->_colnames[$c];
152
-			$width = $this->_colwidths[$c];
153
-			$tblColHdr .= "<td $columnHeaderStyle $columnHeaderClass" . ($width ? " width='$width'" : "") . ">$name</td>";
154
-		}
155
-		$tblColHdr .= "</tr></thead>\n";
156
-
157
-		// build rows
158
-		$rowcount = $this->_isDataset ? $modx->db->getRecordCount($this->ds) : count($this->ds);
159
-		$this->_fieldnames = explode(",", $this->fields);
160
-		if($rowcount == 0) {
161
-			$tblRows .= "<tr><td " . $this->_itemStyle . " " . $this->_itemClass . " colspan='" . $this->_colcount . "'>" . $this->noRecordMsg . "</td></tr>\n";
162
-		} else {
163
-			// render grid items
164
-			if($this->pageSize <= 0) {
165
-				for($r = 0; $r < $rowcount; $r++) {
166
-					$row = $this->_isDataset ? $modx->db->getRow($this->ds) : $this->ds[$r];
167
-					$tblRows .= $this->RenderRowFnc($r + 1, $row);
168
-				}
169
-			} else {
170
-				if(!$this->pager) {
171
-					include_once dirname(__FILE__) . "/datasetpager.class.php";
172
-					$this->pager = new DataSetPager($this->id, $this->ds, $this->pageSize, $this->pageNumber);
173
-					$this->pager->setRenderRowFnc($this); // pass this object
174
-					$this->pager->cssStyle = $pagerStyle;
175
-					$this->pager->cssClass = $pagerClass;
176
-				} else {
177
-					$this->pager->pageSize = $this->pageSize;
178
-					$this->pager->pageNumber = $this->pageNumber;
179
-				}
180
-
181
-				$this->pager->render();
182
-				$tblRows = $this->pager->getRenderedRows();
183
-				$tblPager = $this->pager->getRenderedPager();
184
-			}
185
-		}
186
-
187
-		// setup header,pager and footer
188
-		$o = $tblStart;
189
-		$ptop = (substr($this->pagerLocation, 0, 3) == "top") || (substr($this->pagerLocation, 0, 4) == "both");
190
-		$pbot = (substr($this->pagerLocation, 0, 3) == "bot") || (substr($this->pagerLocation, 0, 4) == "both");
191
-		if($this->header) {
192
-			$o .= "<tr><td bgcolor='#ffffff' colspan='" . $this->_colcount . "'>" . $this->header . "</td></tr>";
193
-		}
194
-		if($tblPager && $ptop) {
195
-			$o .= "<tr><td align='" . (substr($this->pagerLocation, -4) == "left" ? "left" : "right") . "' $pagerClass $pagerStyle colspan='" . $this->_colcount . "'>" . $tblPager . "&nbsp;</td></tr>";
196
-		}
197
-		$o .= $tblColHdr . $tblRows;
198
-		if($tblPager && $pbot) {
199
-			$o .= "<tr><td align='" . (substr($this->pagerLocation, -4) == "left" ? "left" : "right") . "' $pagerClass $pagerStyle colspan='" . $this->_colcount . "'>" . $tblPager . "&nbsp;</td></tr>";
200
-		}
201
-		if($this->footer) {
202
-			$o .= "<tr><td bgcolor='#ffffff' colspan='" . $this->_colcount . "'>" . $this->footer . "</td></tr>";
203
-		}
204
-		$o .= $tblEnd;
205
-		return $o;
206
-	}
207
-
208
-	// format column values
97
+        $columnHeaderStyle = ($this->columnHeaderStyle) ? "style='" . $this->columnHeaderStyle . "'" : '';
98
+        $columnHeaderClass = ($this->columnHeaderClass) ? "class='" . $this->columnHeaderClass . "'" : "";
99
+        $cssStyle = ($this->cssStyle) ? "style='" . $this->cssStyle . "'" : '';
100
+        $cssClass = ($this->cssClass) ? "class='" . $this->cssClass . "'" : '';
101
+
102
+        $pagerClass = ($this->pagerClass) ? "class='" . $this->pagerClass . "'" : '';
103
+        $pagerStyle = ($this->pagerStyle) ? "style='" . $this->pagerStyle . "'" : "style='background-color:#ffffff;'";
104
+
105
+        $this->_itemStyle = ($this->itemStyle) ? "style='" . $this->itemStyle . "'" : '';
106
+        $this->_itemClass = ($this->itemClass) ? "class='" . $this->itemClass . "'" : '';
107
+        $this->_altItemStyle = ($this->altItemStyle) ? "style='" . $this->altItemStyle . "'" : '';
108
+        $this->_altItemClass = ($this->altItemClass) ? "class='" . $this->altItemClass . "'" : '';
109
+
110
+        $this->_alt = 0;
111
+        $this->_total = 0;
112
+
113
+        $this->_isDataset = $modx->db->isResult($this->ds); // if not dataset then treat as array
114
+
115
+        if(!$cssStyle && !$cssClass) {
116
+            $cssStyle = "style='width:100%;border:1px solid silver;font-family:verdana,arial; font-size:11px;'";
117
+        }
118
+        if(!$columnHeaderStyle && !$columnHeaderClass) {
119
+            $columnHeaderStyle = "style='color:black;background-color:silver'";
120
+        }
121
+        if(!$this->_itemStyle && !$this->_itemClass) {
122
+            $this->_itemStyle = "style='color:black;'";
123
+        }
124
+        if(!$this->_altItemStyle && !$this->_altItemClass) {
125
+            $this->_altItemStyle = "style='color:black;background-color:#eeeeee'";
126
+        }
127
+
128
+        if($this->_isDataset && !$this->columns) {
129
+            $cols = $modx->db->numFields($this->ds);
130
+            for($i = 0; $i < $cols; $i++) $this->columns .= ($i ? "," : "") . $modx->db->fieldName($this->ds, $i);
131
+        }
132
+
133
+        // start grid
134
+        $tblStart = "<table $cssClass $cssStyle cellpadding='" . (isset($this->cellPadding) ? (int) $this->cellPadding : 1) . "' cellspacing='" . (isset($this->cellSpacing) ? (int) $this->cellSpacing : 1) . "'>";
135
+        $tblEnd = "</table>";
136
+
137
+        // build column header
138
+        $this->_colnames = explode((strstr($this->columns, "||") !== false ? "||" : ","), $this->columns);
139
+        $this->_colwidths = explode((strstr($this->colWidths, "||") !== false ? "||" : ","), $this->colWidths);
140
+        $this->_colaligns = explode((strstr($this->colAligns, "||") !== false ? "||" : ","), $this->colAligns);
141
+        $this->_colwraps = explode((strstr($this->colWraps, "||") !== false ? "||" : ","), $this->colWraps);
142
+        $this->_colcolors = explode((strstr($this->colColors, "||") !== false ? "||" : ","), $this->colColors);
143
+        $this->_coltypes = explode((strstr($this->colTypes, "||") !== false ? "||" : ","), $this->colTypes);
144
+        $this->_colcount = count($this->_colnames);
145
+        if(!$this->_isDataset) {
146
+            $this->ds = explode((strstr($this->ds, "||") !== false ? "||" : ","), $this->ds);
147
+            $this->ds = array_chunk($this->ds, $this->_colcount);
148
+        }
149
+        $tblColHdr = "<thead><tr>";
150
+        for($c = 0; $c < $this->_colcount; $c++) {
151
+            $name = $this->_colnames[$c];
152
+            $width = $this->_colwidths[$c];
153
+            $tblColHdr .= "<td $columnHeaderStyle $columnHeaderClass" . ($width ? " width='$width'" : "") . ">$name</td>";
154
+        }
155
+        $tblColHdr .= "</tr></thead>\n";
156
+
157
+        // build rows
158
+        $rowcount = $this->_isDataset ? $modx->db->getRecordCount($this->ds) : count($this->ds);
159
+        $this->_fieldnames = explode(",", $this->fields);
160
+        if($rowcount == 0) {
161
+            $tblRows .= "<tr><td " . $this->_itemStyle . " " . $this->_itemClass . " colspan='" . $this->_colcount . "'>" . $this->noRecordMsg . "</td></tr>\n";
162
+        } else {
163
+            // render grid items
164
+            if($this->pageSize <= 0) {
165
+                for($r = 0; $r < $rowcount; $r++) {
166
+                    $row = $this->_isDataset ? $modx->db->getRow($this->ds) : $this->ds[$r];
167
+                    $tblRows .= $this->RenderRowFnc($r + 1, $row);
168
+                }
169
+            } else {
170
+                if(!$this->pager) {
171
+                    include_once dirname(__FILE__) . "/datasetpager.class.php";
172
+                    $this->pager = new DataSetPager($this->id, $this->ds, $this->pageSize, $this->pageNumber);
173
+                    $this->pager->setRenderRowFnc($this); // pass this object
174
+                    $this->pager->cssStyle = $pagerStyle;
175
+                    $this->pager->cssClass = $pagerClass;
176
+                } else {
177
+                    $this->pager->pageSize = $this->pageSize;
178
+                    $this->pager->pageNumber = $this->pageNumber;
179
+                }
180
+
181
+                $this->pager->render();
182
+                $tblRows = $this->pager->getRenderedRows();
183
+                $tblPager = $this->pager->getRenderedPager();
184
+            }
185
+        }
186
+
187
+        // setup header,pager and footer
188
+        $o = $tblStart;
189
+        $ptop = (substr($this->pagerLocation, 0, 3) == "top") || (substr($this->pagerLocation, 0, 4) == "both");
190
+        $pbot = (substr($this->pagerLocation, 0, 3) == "bot") || (substr($this->pagerLocation, 0, 4) == "both");
191
+        if($this->header) {
192
+            $o .= "<tr><td bgcolor='#ffffff' colspan='" . $this->_colcount . "'>" . $this->header . "</td></tr>";
193
+        }
194
+        if($tblPager && $ptop) {
195
+            $o .= "<tr><td align='" . (substr($this->pagerLocation, -4) == "left" ? "left" : "right") . "' $pagerClass $pagerStyle colspan='" . $this->_colcount . "'>" . $tblPager . "&nbsp;</td></tr>";
196
+        }
197
+        $o .= $tblColHdr . $tblRows;
198
+        if($tblPager && $pbot) {
199
+            $o .= "<tr><td align='" . (substr($this->pagerLocation, -4) == "left" ? "left" : "right") . "' $pagerClass $pagerStyle colspan='" . $this->_colcount . "'>" . $tblPager . "&nbsp;</td></tr>";
200
+        }
201
+        if($this->footer) {
202
+            $o .= "<tr><td bgcolor='#ffffff' colspan='" . $this->_colcount . "'>" . $this->footer . "</td></tr>";
203
+        }
204
+        $o .= $tblEnd;
205
+        return $o;
206
+    }
207
+
208
+    // format column values
209 209
 
210 210
     public function RenderRowFnc($n, $row) {
211
-		if($this->_alt == 0) {
212
-			$Style = $this->_itemStyle;
213
-			$Class = $this->_itemClass;
214
-			$this->_alt = 1;
215
-		} else {
216
-			$Style = $this->_altItemStyle;
217
-			$Class = $this->_altItemClass;
218
-			$this->_alt = 0;
219
-		}
220
-		$o = "<tr>";
221
-		for($c = 0; $c < $this->_colcount; $c++) {
222
-			$colStyle = $Style;
223
-			$fld = trim($this->_fieldnames[$c]);
224
-			$width = isset($this->_colwidths[$c]) ? $this->_colwidths[$c] : null;
225
-			$align = isset($this->_colaligns[$c]) ? $this->_colaligns[$c] : null;
226
-			$color = isset($this->_colcolors[$c]) ? $this->_colcolors[$c] : null;
227
-			$type = isset($this->_coltypes[$c]) ? $this->_coltypes[$c] : null;
228
-			$nowrap = isset($this->_colwraps[$c]) ? $this->_colwraps[$c] : null;
229
-			$value = $row[($this->_isDataset && $fld ? $fld : $c)];
230
-			if($color && $Style) {
231
-				$colStyle = substr($colStyle, 0, -1) . ";background-color:$color;'";
232
-			}
233
-			$value = $this->formatColumnValue($row, $value, $type, $align);
234
-			$o .= "<td $colStyle $Class" . ($align ? " align='$align'" : "") . ($color ? " bgcolor='$color'" : "") . ($nowrap ? " nowrap='$nowrap'" : "") . ($width ? " width='$width'" : "") . ">$value</td>";
235
-		}
236
-		$o .= "</tr>\n";
237
-		return $o;
238
-	}
211
+        if($this->_alt == 0) {
212
+            $Style = $this->_itemStyle;
213
+            $Class = $this->_itemClass;
214
+            $this->_alt = 1;
215
+        } else {
216
+            $Style = $this->_altItemStyle;
217
+            $Class = $this->_altItemClass;
218
+            $this->_alt = 0;
219
+        }
220
+        $o = "<tr>";
221
+        for($c = 0; $c < $this->_colcount; $c++) {
222
+            $colStyle = $Style;
223
+            $fld = trim($this->_fieldnames[$c]);
224
+            $width = isset($this->_colwidths[$c]) ? $this->_colwidths[$c] : null;
225
+            $align = isset($this->_colaligns[$c]) ? $this->_colaligns[$c] : null;
226
+            $color = isset($this->_colcolors[$c]) ? $this->_colcolors[$c] : null;
227
+            $type = isset($this->_coltypes[$c]) ? $this->_coltypes[$c] : null;
228
+            $nowrap = isset($this->_colwraps[$c]) ? $this->_colwraps[$c] : null;
229
+            $value = $row[($this->_isDataset && $fld ? $fld : $c)];
230
+            if($color && $Style) {
231
+                $colStyle = substr($colStyle, 0, -1) . ";background-color:$color;'";
232
+            }
233
+            $value = $this->formatColumnValue($row, $value, $type, $align);
234
+            $o .= "<td $colStyle $Class" . ($align ? " align='$align'" : "") . ($color ? " bgcolor='$color'" : "") . ($nowrap ? " nowrap='$nowrap'" : "") . ($width ? " width='$width'" : "") . ">$value</td>";
235
+        }
236
+        $o .= "</tr>\n";
237
+        return $o;
238
+    }
239 239
 
240 240
     public function formatColumnValue($row, $value, $type, &$align) {
241
-		if(strpos($type, ":") !== false) {
242
-			list($type, $type_format) = explode(":", $type, 2);
243
-		}
244
-		switch(strtolower($type)) {
245
-			case "integer":
246
-				if($align == "") {
247
-					$align = "right";
248
-				}
249
-				$value = number_format($value);
250
-				break;
251
-
252
-			case "float":
253
-				if($align == "") {
254
-					$align = "right";
255
-				}
256
-				if(!$type_format) {
257
-					$type_format = 2;
258
-				}
259
-				$value = number_format($value, $type_format);
260
-				break;
261
-
262
-			case "currency":
263
-				if($align == "") {
264
-					$align = "right";
265
-				}
266
-				if(!$type_format) {
267
-					$type_format = 2;
268
-				}
269
-				$value = "$" . number_format($value, $type_format);
270
-				break;
271
-
272
-			case "date":
273
-				if($align == "") {
274
-					$align = "right";
275
-				}
276
-				if(!is_numeric($value)) {
277
-					$value = strtotime($value);
278
-				}
279
-				if(!$type_format) {
280
-					$type_format = "%A %d, %B %Y";
281
-				}
282
-				$value = strftime($type_format, $value);
283
-				break;
284
-
285
-			case "boolean":
286
-				if($align == '') {
287
-					$align = "center";
288
-				}
289
-				$value = number_format($value);
290
-				if($value) {
291
-					$value = '&bull;';
292
-				} else {
293
-					$value = '&nbsp;';
294
-				}
295
-				break;
296
-
297
-			case "template":
298
-				// replace [+value+] first
299
-				$value = str_replace("[+value+]", $value, $type_format);
300
-				// replace other [+fields+]
301
-				if(strpos($value, "[+") !== false) {
302
-					foreach($row as $k => $v) {
303
-						$value = str_replace("[+$k+]", $v, $value);
304
-					}
305
-				}
306
-				break;
307
-
308
-		}
309
-		return $value;
310
-	}
241
+        if(strpos($type, ":") !== false) {
242
+            list($type, $type_format) = explode(":", $type, 2);
243
+        }
244
+        switch(strtolower($type)) {
245
+            case "integer":
246
+                if($align == "") {
247
+                    $align = "right";
248
+                }
249
+                $value = number_format($value);
250
+                break;
251
+
252
+            case "float":
253
+                if($align == "") {
254
+                    $align = "right";
255
+                }
256
+                if(!$type_format) {
257
+                    $type_format = 2;
258
+                }
259
+                $value = number_format($value, $type_format);
260
+                break;
261
+
262
+            case "currency":
263
+                if($align == "") {
264
+                    $align = "right";
265
+                }
266
+                if(!$type_format) {
267
+                    $type_format = 2;
268
+                }
269
+                $value = "$" . number_format($value, $type_format);
270
+                break;
271
+
272
+            case "date":
273
+                if($align == "") {
274
+                    $align = "right";
275
+                }
276
+                if(!is_numeric($value)) {
277
+                    $value = strtotime($value);
278
+                }
279
+                if(!$type_format) {
280
+                    $type_format = "%A %d, %B %Y";
281
+                }
282
+                $value = strftime($type_format, $value);
283
+                break;
284
+
285
+            case "boolean":
286
+                if($align == '') {
287
+                    $align = "center";
288
+                }
289
+                $value = number_format($value);
290
+                if($value) {
291
+                    $value = '&bull;';
292
+                } else {
293
+                    $value = '&nbsp;';
294
+                }
295
+                break;
296
+
297
+            case "template":
298
+                // replace [+value+] first
299
+                $value = str_replace("[+value+]", $value, $type_format);
300
+                // replace other [+fields+]
301
+                if(strpos($value, "[+") !== false) {
302
+                    foreach($row as $k => $v) {
303
+                        $value = str_replace("[+$k+]", $v, $value);
304
+                    }
305
+                }
306
+                break;
307
+
308
+        }
309
+        return $value;
310
+    }
311 311
 }
Please login to merge, or discard this patch.
Spacing   +66 added lines, -66 removed lines patch added patch discarded remove patch
@@ -10,14 +10,14 @@  discard block
 block discarded – undo
10 10
 
11 11
 $__DataGridCnt = 0;
12 12
 
13
-class DataGrid {
13
+class DataGrid{
14 14
 
15 15
 	public $ds; // datasource
16 16
     public $id;
17
-    public $pageSize;            // pager settings
17
+    public $pageSize; // pager settings
18 18
     public $pageNumber;
19 19
     public $pager;
20
-    public $pagerLocation;        // top-right, top-left, bottom-left, bottom-right, both-left, both-right
20
+    public $pagerLocation; // top-right, top-left, bottom-left, bottom-right, both-left, both-right
21 21
 
22 22
     public $cssStyle;
23 23
     public $cssClass;
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
     public $colAligns;
36 36
     public $colWraps;
37 37
     public $colColors;
38
-    public $colTypes;            // coltype1, coltype2, etc or coltype1:format1, e.g. date:%Y %m
38
+    public $colTypes; // coltype1, coltype2, etc or coltype1:format1, e.g. date:%Y %m
39 39
 	// data type: integer,float,currency,date
40 40
 
41 41
     public $header;
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
     public $cellPadding;
44 44
     public $cellSpacing;
45 45
 
46
-    public $rowAlign;            // vertical alignment: top, middle, bottom
46
+    public $rowAlign; // vertical alignment: top, middle, bottom
47 47
     public $rowIdField;
48 48
 
49 49
     public $pagerStyle;
@@ -72,12 +72,12 @@  discard block
 block discarded – undo
72 72
      */
73 73
     public $cdelim;
74 74
 
75
-    public function __construct($id, $ds, $pageSize = 20, $pageNumber = -1) {
75
+    public function __construct($id, $ds, $pageSize = 20, $pageNumber = -1){
76 76
 		global $__DataGridCnt;
77 77
 
78 78
 		// set id
79 79
 		$__DataGridCnt++;
80
-		$this->id = $this->id ? empty($id) : "dg" . $__DataGridCnt;
80
+		$this->id = $this->id ? empty($id) : "dg".$__DataGridCnt;
81 81
 
82 82
 		// set datasource
83 83
 		$this->ds = $ds;
@@ -88,50 +88,50 @@  discard block
 block discarded – undo
88 88
 		$this->pagerLocation = 'top-right';
89 89
 	}
90 90
 
91
-    public function setDataSource($ds) {
91
+    public function setDataSource($ds){
92 92
 		$this->ds = $ds;
93 93
 	}
94 94
 
95
-    public function render() {
95
+    public function render(){
96 96
         $modx = evolutionCMS();
97
-		$columnHeaderStyle = ($this->columnHeaderStyle) ? "style='" . $this->columnHeaderStyle . "'" : '';
98
-		$columnHeaderClass = ($this->columnHeaderClass) ? "class='" . $this->columnHeaderClass . "'" : "";
99
-		$cssStyle = ($this->cssStyle) ? "style='" . $this->cssStyle . "'" : '';
100
-		$cssClass = ($this->cssClass) ? "class='" . $this->cssClass . "'" : '';
97
+		$columnHeaderStyle = ($this->columnHeaderStyle) ? "style='".$this->columnHeaderStyle."'" : '';
98
+		$columnHeaderClass = ($this->columnHeaderClass) ? "class='".$this->columnHeaderClass."'" : "";
99
+		$cssStyle = ($this->cssStyle) ? "style='".$this->cssStyle."'" : '';
100
+		$cssClass = ($this->cssClass) ? "class='".$this->cssClass."'" : '';
101 101
 
102
-		$pagerClass = ($this->pagerClass) ? "class='" . $this->pagerClass . "'" : '';
103
-		$pagerStyle = ($this->pagerStyle) ? "style='" . $this->pagerStyle . "'" : "style='background-color:#ffffff;'";
102
+		$pagerClass = ($this->pagerClass) ? "class='".$this->pagerClass."'" : '';
103
+		$pagerStyle = ($this->pagerStyle) ? "style='".$this->pagerStyle."'" : "style='background-color:#ffffff;'";
104 104
 
105
-		$this->_itemStyle = ($this->itemStyle) ? "style='" . $this->itemStyle . "'" : '';
106
-		$this->_itemClass = ($this->itemClass) ? "class='" . $this->itemClass . "'" : '';
107
-		$this->_altItemStyle = ($this->altItemStyle) ? "style='" . $this->altItemStyle . "'" : '';
108
-		$this->_altItemClass = ($this->altItemClass) ? "class='" . $this->altItemClass . "'" : '';
105
+		$this->_itemStyle = ($this->itemStyle) ? "style='".$this->itemStyle."'" : '';
106
+		$this->_itemClass = ($this->itemClass) ? "class='".$this->itemClass."'" : '';
107
+		$this->_altItemStyle = ($this->altItemStyle) ? "style='".$this->altItemStyle."'" : '';
108
+		$this->_altItemClass = ($this->altItemClass) ? "class='".$this->altItemClass."'" : '';
109 109
 
110 110
 		$this->_alt = 0;
111 111
 		$this->_total = 0;
112 112
 
113 113
 		$this->_isDataset = $modx->db->isResult($this->ds); // if not dataset then treat as array
114 114
 
115
-		if(!$cssStyle && !$cssClass) {
115
+		if (!$cssStyle && !$cssClass) {
116 116
 			$cssStyle = "style='width:100%;border:1px solid silver;font-family:verdana,arial; font-size:11px;'";
117 117
 		}
118
-		if(!$columnHeaderStyle && !$columnHeaderClass) {
118
+		if (!$columnHeaderStyle && !$columnHeaderClass) {
119 119
 			$columnHeaderStyle = "style='color:black;background-color:silver'";
120 120
 		}
121
-		if(!$this->_itemStyle && !$this->_itemClass) {
121
+		if (!$this->_itemStyle && !$this->_itemClass) {
122 122
 			$this->_itemStyle = "style='color:black;'";
123 123
 		}
124
-		if(!$this->_altItemStyle && !$this->_altItemClass) {
124
+		if (!$this->_altItemStyle && !$this->_altItemClass) {
125 125
 			$this->_altItemStyle = "style='color:black;background-color:#eeeeee'";
126 126
 		}
127 127
 
128
-		if($this->_isDataset && !$this->columns) {
128
+		if ($this->_isDataset && !$this->columns) {
129 129
 			$cols = $modx->db->numFields($this->ds);
130
-			for($i = 0; $i < $cols; $i++) $this->columns .= ($i ? "," : "") . $modx->db->fieldName($this->ds, $i);
130
+			for ($i = 0; $i < $cols; $i++) $this->columns .= ($i ? "," : "").$modx->db->fieldName($this->ds, $i);
131 131
 		}
132 132
 
133 133
 		// start grid
134
-		$tblStart = "<table $cssClass $cssStyle cellpadding='" . (isset($this->cellPadding) ? (int) $this->cellPadding : 1) . "' cellspacing='" . (isset($this->cellSpacing) ? (int) $this->cellSpacing : 1) . "'>";
134
+		$tblStart = "<table $cssClass $cssStyle cellpadding='".(isset($this->cellPadding) ? (int) $this->cellPadding : 1)."' cellspacing='".(isset($this->cellSpacing) ? (int) $this->cellSpacing : 1)."'>";
135 135
 		$tblEnd = "</table>";
136 136
 
137 137
 		// build column header
@@ -142,33 +142,33 @@  discard block
 block discarded – undo
142 142
 		$this->_colcolors = explode((strstr($this->colColors, "||") !== false ? "||" : ","), $this->colColors);
143 143
 		$this->_coltypes = explode((strstr($this->colTypes, "||") !== false ? "||" : ","), $this->colTypes);
144 144
 		$this->_colcount = count($this->_colnames);
145
-		if(!$this->_isDataset) {
145
+		if (!$this->_isDataset) {
146 146
 			$this->ds = explode((strstr($this->ds, "||") !== false ? "||" : ","), $this->ds);
147 147
 			$this->ds = array_chunk($this->ds, $this->_colcount);
148 148
 		}
149 149
 		$tblColHdr = "<thead><tr>";
150
-		for($c = 0; $c < $this->_colcount; $c++) {
150
+		for ($c = 0; $c < $this->_colcount; $c++) {
151 151
 			$name = $this->_colnames[$c];
152 152
 			$width = $this->_colwidths[$c];
153
-			$tblColHdr .= "<td $columnHeaderStyle $columnHeaderClass" . ($width ? " width='$width'" : "") . ">$name</td>";
153
+			$tblColHdr .= "<td $columnHeaderStyle $columnHeaderClass".($width ? " width='$width'" : "").">$name</td>";
154 154
 		}
155 155
 		$tblColHdr .= "</tr></thead>\n";
156 156
 
157 157
 		// build rows
158 158
 		$rowcount = $this->_isDataset ? $modx->db->getRecordCount($this->ds) : count($this->ds);
159 159
 		$this->_fieldnames = explode(",", $this->fields);
160
-		if($rowcount == 0) {
161
-			$tblRows .= "<tr><td " . $this->_itemStyle . " " . $this->_itemClass . " colspan='" . $this->_colcount . "'>" . $this->noRecordMsg . "</td></tr>\n";
160
+		if ($rowcount == 0) {
161
+			$tblRows .= "<tr><td ".$this->_itemStyle." ".$this->_itemClass." colspan='".$this->_colcount."'>".$this->noRecordMsg."</td></tr>\n";
162 162
 		} else {
163 163
 			// render grid items
164
-			if($this->pageSize <= 0) {
165
-				for($r = 0; $r < $rowcount; $r++) {
164
+			if ($this->pageSize <= 0) {
165
+				for ($r = 0; $r < $rowcount; $r++) {
166 166
 					$row = $this->_isDataset ? $modx->db->getRow($this->ds) : $this->ds[$r];
167 167
 					$tblRows .= $this->RenderRowFnc($r + 1, $row);
168 168
 				}
169 169
 			} else {
170
-				if(!$this->pager) {
171
-					include_once dirname(__FILE__) . "/datasetpager.class.php";
170
+				if (!$this->pager) {
171
+					include_once dirname(__FILE__)."/datasetpager.class.php";
172 172
 					$this->pager = new DataSetPager($this->id, $this->ds, $this->pageSize, $this->pageNumber);
173 173
 					$this->pager->setRenderRowFnc($this); // pass this object
174 174
 					$this->pager->cssStyle = $pagerStyle;
@@ -188,18 +188,18 @@  discard block
 block discarded – undo
188 188
 		$o = $tblStart;
189 189
 		$ptop = (substr($this->pagerLocation, 0, 3) == "top") || (substr($this->pagerLocation, 0, 4) == "both");
190 190
 		$pbot = (substr($this->pagerLocation, 0, 3) == "bot") || (substr($this->pagerLocation, 0, 4) == "both");
191
-		if($this->header) {
192
-			$o .= "<tr><td bgcolor='#ffffff' colspan='" . $this->_colcount . "'>" . $this->header . "</td></tr>";
191
+		if ($this->header) {
192
+			$o .= "<tr><td bgcolor='#ffffff' colspan='".$this->_colcount."'>".$this->header."</td></tr>";
193 193
 		}
194
-		if($tblPager && $ptop) {
195
-			$o .= "<tr><td align='" . (substr($this->pagerLocation, -4) == "left" ? "left" : "right") . "' $pagerClass $pagerStyle colspan='" . $this->_colcount . "'>" . $tblPager . "&nbsp;</td></tr>";
194
+		if ($tblPager && $ptop) {
195
+			$o .= "<tr><td align='".(substr($this->pagerLocation, -4) == "left" ? "left" : "right")."' $pagerClass $pagerStyle colspan='".$this->_colcount."'>".$tblPager."&nbsp;</td></tr>";
196 196
 		}
197
-		$o .= $tblColHdr . $tblRows;
198
-		if($tblPager && $pbot) {
199
-			$o .= "<tr><td align='" . (substr($this->pagerLocation, -4) == "left" ? "left" : "right") . "' $pagerClass $pagerStyle colspan='" . $this->_colcount . "'>" . $tblPager . "&nbsp;</td></tr>";
197
+		$o .= $tblColHdr.$tblRows;
198
+		if ($tblPager && $pbot) {
199
+			$o .= "<tr><td align='".(substr($this->pagerLocation, -4) == "left" ? "left" : "right")."' $pagerClass $pagerStyle colspan='".$this->_colcount."'>".$tblPager."&nbsp;</td></tr>";
200 200
 		}
201
-		if($this->footer) {
202
-			$o .= "<tr><td bgcolor='#ffffff' colspan='" . $this->_colcount . "'>" . $this->footer . "</td></tr>";
201
+		if ($this->footer) {
202
+			$o .= "<tr><td bgcolor='#ffffff' colspan='".$this->_colcount."'>".$this->footer."</td></tr>";
203 203
 		}
204 204
 		$o .= $tblEnd;
205 205
 		return $o;
@@ -207,8 +207,8 @@  discard block
 block discarded – undo
207 207
 
208 208
 	// format column values
209 209
 
210
-    public function RenderRowFnc($n, $row) {
211
-		if($this->_alt == 0) {
210
+    public function RenderRowFnc($n, $row){
211
+		if ($this->_alt == 0) {
212 212
 			$Style = $this->_itemStyle;
213 213
 			$Class = $this->_itemClass;
214 214
 			$this->_alt = 1;
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
 			$this->_alt = 0;
219 219
 		}
220 220
 		$o = "<tr>";
221
-		for($c = 0; $c < $this->_colcount; $c++) {
221
+		for ($c = 0; $c < $this->_colcount; $c++) {
222 222
 			$colStyle = $Style;
223 223
 			$fld = trim($this->_fieldnames[$c]);
224 224
 			$width = isset($this->_colwidths[$c]) ? $this->_colwidths[$c] : null;
@@ -227,67 +227,67 @@  discard block
 block discarded – undo
227 227
 			$type = isset($this->_coltypes[$c]) ? $this->_coltypes[$c] : null;
228 228
 			$nowrap = isset($this->_colwraps[$c]) ? $this->_colwraps[$c] : null;
229 229
 			$value = $row[($this->_isDataset && $fld ? $fld : $c)];
230
-			if($color && $Style) {
231
-				$colStyle = substr($colStyle, 0, -1) . ";background-color:$color;'";
230
+			if ($color && $Style) {
231
+				$colStyle = substr($colStyle, 0, -1).";background-color:$color;'";
232 232
 			}
233 233
 			$value = $this->formatColumnValue($row, $value, $type, $align);
234
-			$o .= "<td $colStyle $Class" . ($align ? " align='$align'" : "") . ($color ? " bgcolor='$color'" : "") . ($nowrap ? " nowrap='$nowrap'" : "") . ($width ? " width='$width'" : "") . ">$value</td>";
234
+			$o .= "<td $colStyle $Class".($align ? " align='$align'" : "").($color ? " bgcolor='$color'" : "").($nowrap ? " nowrap='$nowrap'" : "").($width ? " width='$width'" : "").">$value</td>";
235 235
 		}
236 236
 		$o .= "</tr>\n";
237 237
 		return $o;
238 238
 	}
239 239
 
240
-    public function formatColumnValue($row, $value, $type, &$align) {
241
-		if(strpos($type, ":") !== false) {
240
+    public function formatColumnValue($row, $value, $type, &$align){
241
+		if (strpos($type, ":") !== false) {
242 242
 			list($type, $type_format) = explode(":", $type, 2);
243 243
 		}
244
-		switch(strtolower($type)) {
244
+		switch (strtolower($type)) {
245 245
 			case "integer":
246
-				if($align == "") {
246
+				if ($align == "") {
247 247
 					$align = "right";
248 248
 				}
249 249
 				$value = number_format($value);
250 250
 				break;
251 251
 
252 252
 			case "float":
253
-				if($align == "") {
253
+				if ($align == "") {
254 254
 					$align = "right";
255 255
 				}
256
-				if(!$type_format) {
256
+				if (!$type_format) {
257 257
 					$type_format = 2;
258 258
 				}
259 259
 				$value = number_format($value, $type_format);
260 260
 				break;
261 261
 
262 262
 			case "currency":
263
-				if($align == "") {
263
+				if ($align == "") {
264 264
 					$align = "right";
265 265
 				}
266
-				if(!$type_format) {
266
+				if (!$type_format) {
267 267
 					$type_format = 2;
268 268
 				}
269
-				$value = "$" . number_format($value, $type_format);
269
+				$value = "$".number_format($value, $type_format);
270 270
 				break;
271 271
 
272 272
 			case "date":
273
-				if($align == "") {
273
+				if ($align == "") {
274 274
 					$align = "right";
275 275
 				}
276
-				if(!is_numeric($value)) {
276
+				if (!is_numeric($value)) {
277 277
 					$value = strtotime($value);
278 278
 				}
279
-				if(!$type_format) {
279
+				if (!$type_format) {
280 280
 					$type_format = "%A %d, %B %Y";
281 281
 				}
282 282
 				$value = strftime($type_format, $value);
283 283
 				break;
284 284
 
285 285
 			case "boolean":
286
-				if($align == '') {
286
+				if ($align == '') {
287 287
 					$align = "center";
288 288
 				}
289 289
 				$value = number_format($value);
290
-				if($value) {
290
+				if ($value) {
291 291
 					$value = '&bull;';
292 292
 				} else {
293 293
 					$value = '&nbsp;';
@@ -298,8 +298,8 @@  discard block
 block discarded – undo
298 298
 				// replace [+value+] first
299 299
 				$value = str_replace("[+value+]", $value, $type_format);
300 300
 				// replace other [+fields+]
301
-				if(strpos($value, "[+") !== false) {
302
-					foreach($row as $k => $v) {
301
+				if (strpos($value, "[+") !== false) {
302
+					foreach ($row as $k => $v) {
303 303
 						$value = str_replace("[+$k+]", $v, $value);
304 304
 					}
305 305
 				}
Please login to merge, or discard this patch.
Braces   +15 added lines, -7 removed lines patch added patch discarded remove patch
@@ -10,7 +10,8 @@  discard block
 block discarded – undo
10 10
 
11 11
 $__DataGridCnt = 0;
12 12
 
13
-class DataGrid {
13
+class DataGrid
14
+{
14 15
 
15 16
 	public $ds; // datasource
16 17
     public $id;
@@ -72,7 +73,8 @@  discard block
 block discarded – undo
72 73
      */
73 74
     public $cdelim;
74 75
 
75
-    public function __construct($id, $ds, $pageSize = 20, $pageNumber = -1) {
76
+    public function __construct($id, $ds, $pageSize = 20, $pageNumber = -1)
77
+    {
76 78
 		global $__DataGridCnt;
77 79
 
78 80
 		// set id
@@ -88,11 +90,13 @@  discard block
 block discarded – undo
88 90
 		$this->pagerLocation = 'top-right';
89 91
 	}
90 92
 
91
-    public function setDataSource($ds) {
93
+    public function setDataSource($ds)
94
+    {
92 95
 		$this->ds = $ds;
93 96
 	}
94 97
 
95
-    public function render() {
98
+    public function render()
99
+    {
96 100
         $modx = evolutionCMS();
97 101
 		$columnHeaderStyle = ($this->columnHeaderStyle) ? "style='" . $this->columnHeaderStyle . "'" : '';
98 102
 		$columnHeaderClass = ($this->columnHeaderClass) ? "class='" . $this->columnHeaderClass . "'" : "";
@@ -127,7 +131,9 @@  discard block
 block discarded – undo
127 131
 
128 132
 		if($this->_isDataset && !$this->columns) {
129 133
 			$cols = $modx->db->numFields($this->ds);
130
-			for($i = 0; $i < $cols; $i++) $this->columns .= ($i ? "," : "") . $modx->db->fieldName($this->ds, $i);
134
+			for($i = 0; $i < $cols; $i++) {
135
+			    $this->columns .= ($i ? "," : "") . $modx->db->fieldName($this->ds, $i);
136
+			}
131 137
 		}
132 138
 
133 139
 		// start grid
@@ -207,7 +213,8 @@  discard block
 block discarded – undo
207 213
 
208 214
 	// format column values
209 215
 
210
-    public function RenderRowFnc($n, $row) {
216
+    public function RenderRowFnc($n, $row)
217
+    {
211 218
 		if($this->_alt == 0) {
212 219
 			$Style = $this->_itemStyle;
213 220
 			$Class = $this->_itemClass;
@@ -237,7 +244,8 @@  discard block
 block discarded – undo
237 244
 		return $o;
238 245
 	}
239 246
 
240
-    public function formatColumnValue($row, $value, $type, &$align) {
247
+    public function formatColumnValue($row, $value, $type, &$align)
248
+    {
241 249
 		if(strpos($type, ":") !== false) {
242 250
 			list($type, $type_format) = explode(":", $type, 2);
243 251
 		}
Please login to merge, or discard this patch.