Completed
Push — develop ( dd48c1...053968 )
by Maxim
06:38 queued 01:16
created
manager/includes/controls/datasetpager.class.php 4 patches
Doc Comments   +6 added lines patch added patch discarded remove patch
@@ -31,6 +31,9 @@  discard block
 block discarded – undo
31 31
     public $renderPagerFnc;
32 32
     public $renderPagerFncArgs;
33 33
 
34
+    /**
35
+     * @param boolean|string $id
36
+     */
34 37
     public function __construct($id, $ds, $pageSize = 10, $pageNumber = -1) {
35 38
 		global $_PAGE; // use view state object
36 39
 
@@ -77,6 +80,9 @@  discard block
 block discarded – undo
77 80
 		$this->pageSize = $ps;
78 81
 	}
79 82
 
83
+    /**
84
+     * @param DataGrid $fncName
85
+     */
80 86
     public function setRenderRowFnc($fncName, $args = "") {
81 87
 		$this->renderRowFnc = &$fncName;
82 88
 		$this->renderRowFncArgs = $args;    // extra agruments
Please login to merge, or discard this patch.
Indentation   +149 added lines, -149 removed lines patch added patch discarded remove patch
@@ -12,18 +12,18 @@  discard block
 block discarded – undo
12 12
 
13 13
 class DataSetPager {
14 14
 
15
-	public $ds; // datasource
15
+    public $ds; // datasource
16 16
     public $pageSize;
17 17
     public $pageNumber;
18 18
     public $rows;
19 19
     public $pager;
20 20
     public $id;
21 21
 
22
-	// normal page
22
+    // normal page
23 23
     public $pageStyle;
24 24
     public $pageClass;
25 25
 
26
-	// selected page
26
+    // selected page
27 27
     public $selPageStyle;
28 28
     public $selPageClass;
29 29
     public $renderRowFnc;
@@ -32,166 +32,166 @@  discard block
 block discarded – undo
32 32
     public $renderPagerFncArgs;
33 33
 
34 34
     public function __construct($id, $ds, $pageSize = 10, $pageNumber = -1) {
35
-		global $_PAGE; // use view state object
36
-
37
-		global $__DataSetPagerCnt;
38
-
39
-		// set id
40
-		$__DataSetPagerCnt++;
41
-		$this->id = !empty($id) ? $id : "dsp" . $__DataSetPagerCnt;
42
-
43
-		// get pagenumber
44
-		// by setting pager to -1 cause pager to load it's last page number
45
-		if($pageNumber == -1) {
46
-			$pageNumber = 1;
47
-			if(isset($_GET["dpgn" . $this->id])) {
48
-				$pageNumber = $_GET["dpgn" . $this->id];
49
-			} elseif(isset($_PAGE['vs'][$id . '_dpgn'])) {
50
-				$pageNumber = $_PAGE['vs'][$id . '_dpgn'];
51
-			}
52
-		}
53
-		if(!is_numeric($pageNumber)) {
54
-			$pageNumber = 1;
55
-		}
56
-
57
-		$this->ds = $ds; // datasource
58
-		$this->pageSize = $pageSize;
59
-		$this->pageNumber = $pageNumber;
60
-		$this->rows = '';
61
-		$this->pager = '';
62
-	}
35
+        global $_PAGE; // use view state object
36
+
37
+        global $__DataSetPagerCnt;
38
+
39
+        // set id
40
+        $__DataSetPagerCnt++;
41
+        $this->id = !empty($id) ? $id : "dsp" . $__DataSetPagerCnt;
42
+
43
+        // get pagenumber
44
+        // by setting pager to -1 cause pager to load it's last page number
45
+        if($pageNumber == -1) {
46
+            $pageNumber = 1;
47
+            if(isset($_GET["dpgn" . $this->id])) {
48
+                $pageNumber = $_GET["dpgn" . $this->id];
49
+            } elseif(isset($_PAGE['vs'][$id . '_dpgn'])) {
50
+                $pageNumber = $_PAGE['vs'][$id . '_dpgn'];
51
+            }
52
+        }
53
+        if(!is_numeric($pageNumber)) {
54
+            $pageNumber = 1;
55
+        }
56
+
57
+        $this->ds = $ds; // datasource
58
+        $this->pageSize = $pageSize;
59
+        $this->pageNumber = $pageNumber;
60
+        $this->rows = '';
61
+        $this->pager = '';
62
+    }
63 63
 
64 64
     public function getRenderedPager() {
65
-		return $this->pager;
66
-	}
65
+        return $this->pager;
66
+    }
67 67
 
68 68
     public function getRenderedRows() {
69
-		return $this->rows;
70
-	}
69
+        return $this->rows;
70
+    }
71 71
 
72 72
     public function setDataSource($ds) {
73
-		$this->ds = $ds;
74
-	}
73
+        $this->ds = $ds;
74
+    }
75 75
 
76 76
     public function setPageSize($ps) {
77
-		$this->pageSize = $ps;
78
-	}
77
+        $this->pageSize = $ps;
78
+    }
79 79
 
80 80
     public function setRenderRowFnc($fncName, $args = "") {
81
-		$this->renderRowFnc = &$fncName;
82
-		$this->renderRowFncArgs = $args;    // extra agruments
81
+        $this->renderRowFnc = &$fncName;
82
+        $this->renderRowFncArgs = $args;    // extra agruments
83 83
 
84 84
 
85
-	}
85
+    }
86 86
 
87 87
     public function setRenderPagerFnc($fncName, $args = "") {
88
-		$this->renderPagerFnc = $fncName;
89
-		$this->renderPagerFncArgs = $args;    // extra agruments
90
-	}
88
+        $this->renderPagerFnc = $fncName;
89
+        $this->renderPagerFncArgs = $args;    // extra agruments
90
+    }
91 91
 
92 92
     public function render() {
93
-		global $modx, $_PAGE;
94
-
95
-		$isDataset = $modx->db->isResult($this->ds);
96
-
97
-		if(!$this->selPageStyle) {
98
-			$this->selPageStyle = "font-weight:bold";
99
-		}
100
-
101
-		// get total number of rows
102
-		$tnr = ($isDataset) ? $modx->db->getRecordCount($this->ds) : count($this->ds);
103
-
104
-		// render: no records found
105
-		if($tnr <= 0) {
106
-			$fnc = $this->renderRowFnc;
107
-			$args = $this->renderRowFncArgs;
108
-			if(isset($fnc)) {
109
-				if($args != "") {
110
-					$this->rows .= $fnc(0, null, $args);
111
-				} // if agrs was specified then we will pass three params
112
-				else {
113
-					$this->rows .= $fnc(0, null);
114
-				}                 // otherwise two will be passed
115
-			}
116
-			return;
117
-		}
118
-
119
-		// get total pages
120
-		$tp = ceil($tnr / $this->pageSize);
121
-		if($this->pageNumber > $tp) {
122
-			$this->pageNumber = 1;
123
-		}
124
-
125
-		// get page number
126
-		$p = $this->pageNumber;
127
-
128
-		// save page number to view state if available
129
-		if(isset($_PAGE['vs'])) {
130
-			$_PAGE['vs'][$this->id . '_dpgn'] = $p;
131
-		}
132
-
133
-		// render pager : renderPagerFnc($cuurentPage,$pagerNumber,$arguments="");
134
-		if($tp > 1) {
135
-		    $url = '';
136
-			$fnc = $this->renderPagerFnc;
137
-			$args = $this->renderPagerFncArgs;
138
-			if(!isset($fnc)) {
139
-				if($modx->isFrontend()) {
140
-					$url = $modx->makeUrl($modx->documentIdentifier, '', '', 'full') . '?';
141
-				} else {
142
-					$url = $_SERVER['PHP_SELF'] . '?';
143
-				}
144
-				$i = 0;
145
-				foreach($_GET as $n => $v) if($n != 'dpgn' . $this->id) {
146
-					$i++;
147
-					$url .= (($i > 1) ? "&" : "") . "$n=$v";
148
-				}
149
-				if($i >= 1) {
150
-					$url .= "&";
151
-				}
152
-			}
153
-			for($i = 1; $i <= $tp; $i++) {
154
-				if(isset($fnc)) {
155
-					if($args != "") {
156
-						$this->pager .= $fnc($p, $i, $args);
157
-					} else {
158
-						$this->pager .= $fnc($p, $i);
159
-					}
160
-				} else {
161
-					$this->pager .= ($p == $i) ? " <span class='" . $this->selPageClass . "' style='" . $this->selPageStyle . "'>$i</span> " : " <a href='" . $url . "dpgn" . $this->id . "=$i' class='" . $this->pageClass . "' style='" . $this->pageStyle . "'>$i</a> ";
162
-				}
163
-			}
164
-		}
165
-
166
-		// render row : renderRowFnc($rowNumber,$row,$arguments="")
167
-		$fnc = $this->renderRowFnc;
168
-		$args = $this->renderRowFncArgs;
169
-
170
-		if(isset($fnc)) {
171
-			$i = 1;
172
-			$fncObject = is_object($fnc);
173
-			$minitems = (($p - 1) * $this->pageSize) + 1;
174
-			$maxitems = (($p - 1) * $this->pageSize) + $this->pageSize;
175
-			while($i <= $maxitems && ($row = ($isDataset) ? $modx->db->getRow($this->ds) : $this->ds[$i - 1])) {
176
-				if($i >= $minitems && $i <= $maxitems) {
177
-					if($fncObject) {
178
-						if($args != "") {
179
-							$this->rows .= $fnc->RenderRowFnc($i, $row, $args);
180
-						} else {
181
-							$this->rows .= $fnc->RenderRowFnc($i, $row);
182
-						}
183
-					} else {
184
-						if($args != "") {
185
-							$this->rows .= $fnc($i, $row, $args);
186
-						} // if agrs was specified then we wil pass three params
187
-						else {
188
-							$this->rows .= $fnc($i, $row);
189
-						}                 // otherwise two will be passed
190
-					}
191
-
192
-				}
193
-				$i++;
194
-			}
195
-		}
196
-	}
93
+        global $modx, $_PAGE;
94
+
95
+        $isDataset = $modx->db->isResult($this->ds);
96
+
97
+        if(!$this->selPageStyle) {
98
+            $this->selPageStyle = "font-weight:bold";
99
+        }
100
+
101
+        // get total number of rows
102
+        $tnr = ($isDataset) ? $modx->db->getRecordCount($this->ds) : count($this->ds);
103
+
104
+        // render: no records found
105
+        if($tnr <= 0) {
106
+            $fnc = $this->renderRowFnc;
107
+            $args = $this->renderRowFncArgs;
108
+            if(isset($fnc)) {
109
+                if($args != "") {
110
+                    $this->rows .= $fnc(0, null, $args);
111
+                } // if agrs was specified then we will pass three params
112
+                else {
113
+                    $this->rows .= $fnc(0, null);
114
+                }                 // otherwise two will be passed
115
+            }
116
+            return;
117
+        }
118
+
119
+        // get total pages
120
+        $tp = ceil($tnr / $this->pageSize);
121
+        if($this->pageNumber > $tp) {
122
+            $this->pageNumber = 1;
123
+        }
124
+
125
+        // get page number
126
+        $p = $this->pageNumber;
127
+
128
+        // save page number to view state if available
129
+        if(isset($_PAGE['vs'])) {
130
+            $_PAGE['vs'][$this->id . '_dpgn'] = $p;
131
+        }
132
+
133
+        // render pager : renderPagerFnc($cuurentPage,$pagerNumber,$arguments="");
134
+        if($tp > 1) {
135
+            $url = '';
136
+            $fnc = $this->renderPagerFnc;
137
+            $args = $this->renderPagerFncArgs;
138
+            if(!isset($fnc)) {
139
+                if($modx->isFrontend()) {
140
+                    $url = $modx->makeUrl($modx->documentIdentifier, '', '', 'full') . '?';
141
+                } else {
142
+                    $url = $_SERVER['PHP_SELF'] . '?';
143
+                }
144
+                $i = 0;
145
+                foreach($_GET as $n => $v) if($n != 'dpgn' . $this->id) {
146
+                    $i++;
147
+                    $url .= (($i > 1) ? "&" : "") . "$n=$v";
148
+                }
149
+                if($i >= 1) {
150
+                    $url .= "&";
151
+                }
152
+            }
153
+            for($i = 1; $i <= $tp; $i++) {
154
+                if(isset($fnc)) {
155
+                    if($args != "") {
156
+                        $this->pager .= $fnc($p, $i, $args);
157
+                    } else {
158
+                        $this->pager .= $fnc($p, $i);
159
+                    }
160
+                } else {
161
+                    $this->pager .= ($p == $i) ? " <span class='" . $this->selPageClass . "' style='" . $this->selPageStyle . "'>$i</span> " : " <a href='" . $url . "dpgn" . $this->id . "=$i' class='" . $this->pageClass . "' style='" . $this->pageStyle . "'>$i</a> ";
162
+                }
163
+            }
164
+        }
165
+
166
+        // render row : renderRowFnc($rowNumber,$row,$arguments="")
167
+        $fnc = $this->renderRowFnc;
168
+        $args = $this->renderRowFncArgs;
169
+
170
+        if(isset($fnc)) {
171
+            $i = 1;
172
+            $fncObject = is_object($fnc);
173
+            $minitems = (($p - 1) * $this->pageSize) + 1;
174
+            $maxitems = (($p - 1) * $this->pageSize) + $this->pageSize;
175
+            while($i <= $maxitems && ($row = ($isDataset) ? $modx->db->getRow($this->ds) : $this->ds[$i - 1])) {
176
+                if($i >= $minitems && $i <= $maxitems) {
177
+                    if($fncObject) {
178
+                        if($args != "") {
179
+                            $this->rows .= $fnc->RenderRowFnc($i, $row, $args);
180
+                        } else {
181
+                            $this->rows .= $fnc->RenderRowFnc($i, $row);
182
+                        }
183
+                    } else {
184
+                        if($args != "") {
185
+                            $this->rows .= $fnc($i, $row, $args);
186
+                        } // if agrs was specified then we wil pass three params
187
+                        else {
188
+                            $this->rows .= $fnc($i, $row);
189
+                        }                 // otherwise two will be passed
190
+                    }
191
+
192
+                }
193
+                $i++;
194
+            }
195
+        }
196
+    }
197 197
 }
Please login to merge, or discard this patch.
Spacing   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
 
11 11
 $__DataSetPagerCnt = 0;
12 12
 
13
-class DataSetPager {
13
+class DataSetPager{
14 14
 
15 15
 	public $ds; // datasource
16 16
     public $pageSize;
@@ -31,26 +31,26 @@  discard block
 block discarded – undo
31 31
     public $renderPagerFnc;
32 32
     public $renderPagerFncArgs;
33 33
 
34
-    public function __construct($id, $ds, $pageSize = 10, $pageNumber = -1) {
34
+    public function __construct($id, $ds, $pageSize = 10, $pageNumber = -1){
35 35
 		global $_PAGE; // use view state object
36 36
 
37 37
 		global $__DataSetPagerCnt;
38 38
 
39 39
 		// set id
40 40
 		$__DataSetPagerCnt++;
41
-		$this->id = !empty($id) ? $id : "dsp" . $__DataSetPagerCnt;
41
+		$this->id = !empty($id) ? $id : "dsp".$__DataSetPagerCnt;
42 42
 
43 43
 		// get pagenumber
44 44
 		// by setting pager to -1 cause pager to load it's last page number
45
-		if($pageNumber == -1) {
45
+		if ($pageNumber == -1) {
46 46
 			$pageNumber = 1;
47
-			if(isset($_GET["dpgn" . $this->id])) {
48
-				$pageNumber = $_GET["dpgn" . $this->id];
49
-			} elseif(isset($_PAGE['vs'][$id . '_dpgn'])) {
50
-				$pageNumber = $_PAGE['vs'][$id . '_dpgn'];
47
+			if (isset($_GET["dpgn".$this->id])) {
48
+				$pageNumber = $_GET["dpgn".$this->id];
49
+			} elseif (isset($_PAGE['vs'][$id.'_dpgn'])) {
50
+				$pageNumber = $_PAGE['vs'][$id.'_dpgn'];
51 51
 			}
52 52
 		}
53
-		if(!is_numeric($pageNumber)) {
53
+		if (!is_numeric($pageNumber)) {
54 54
 			$pageNumber = 1;
55 55
 		}
56 56
 
@@ -61,40 +61,40 @@  discard block
 block discarded – undo
61 61
 		$this->pager = '';
62 62
 	}
63 63
 
64
-    public function getRenderedPager() {
64
+    public function getRenderedPager(){
65 65
 		return $this->pager;
66 66
 	}
67 67
 
68
-    public function getRenderedRows() {
68
+    public function getRenderedRows(){
69 69
 		return $this->rows;
70 70
 	}
71 71
 
72
-    public function setDataSource($ds) {
72
+    public function setDataSource($ds){
73 73
 		$this->ds = $ds;
74 74
 	}
75 75
 
76
-    public function setPageSize($ps) {
76
+    public function setPageSize($ps){
77 77
 		$this->pageSize = $ps;
78 78
 	}
79 79
 
80
-    public function setRenderRowFnc($fncName, $args = "") {
80
+    public function setRenderRowFnc($fncName, $args = ""){
81 81
 		$this->renderRowFnc = &$fncName;
82
-		$this->renderRowFncArgs = $args;    // extra agruments
82
+		$this->renderRowFncArgs = $args; // extra agruments
83 83
 
84 84
 
85 85
 	}
86 86
 
87
-    public function setRenderPagerFnc($fncName, $args = "") {
87
+    public function setRenderPagerFnc($fncName, $args = ""){
88 88
 		$this->renderPagerFnc = $fncName;
89
-		$this->renderPagerFncArgs = $args;    // extra agruments
89
+		$this->renderPagerFncArgs = $args; // extra agruments
90 90
 	}
91 91
 
92
-    public function render() {
92
+    public function render(){
93 93
 		global $modx, $_PAGE;
94 94
 
95 95
 		$isDataset = $modx->db->isResult($this->ds);
96 96
 
97
-		if(!$this->selPageStyle) {
97
+		if (!$this->selPageStyle) {
98 98
 			$this->selPageStyle = "font-weight:bold";
99 99
 		}
100 100
 
@@ -102,11 +102,11 @@  discard block
 block discarded – undo
102 102
 		$tnr = ($isDataset) ? $modx->db->getRecordCount($this->ds) : count($this->ds);
103 103
 
104 104
 		// render: no records found
105
-		if($tnr <= 0) {
105
+		if ($tnr <= 0) {
106 106
 			$fnc = $this->renderRowFnc;
107 107
 			$args = $this->renderRowFncArgs;
108
-			if(isset($fnc)) {
109
-				if($args != "") {
108
+			if (isset($fnc)) {
109
+				if ($args != "") {
110 110
 					$this->rows .= $fnc(0, null, $args);
111 111
 				} // if agrs was specified then we will pass three params
112 112
 				else {
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
 
119 119
 		// get total pages
120 120
 		$tp = ceil($tnr / $this->pageSize);
121
-		if($this->pageNumber > $tp) {
121
+		if ($this->pageNumber > $tp) {
122 122
 			$this->pageNumber = 1;
123 123
 		}
124 124
 
@@ -126,39 +126,39 @@  discard block
 block discarded – undo
126 126
 		$p = $this->pageNumber;
127 127
 
128 128
 		// save page number to view state if available
129
-		if(isset($_PAGE['vs'])) {
130
-			$_PAGE['vs'][$this->id . '_dpgn'] = $p;
129
+		if (isset($_PAGE['vs'])) {
130
+			$_PAGE['vs'][$this->id.'_dpgn'] = $p;
131 131
 		}
132 132
 
133 133
 		// render pager : renderPagerFnc($cuurentPage,$pagerNumber,$arguments="");
134
-		if($tp > 1) {
134
+		if ($tp > 1) {
135 135
 		    $url = '';
136 136
 			$fnc = $this->renderPagerFnc;
137 137
 			$args = $this->renderPagerFncArgs;
138
-			if(!isset($fnc)) {
139
-				if($modx->isFrontend()) {
140
-					$url = $modx->makeUrl($modx->documentIdentifier, '', '', 'full') . '?';
138
+			if (!isset($fnc)) {
139
+				if ($modx->isFrontend()) {
140
+					$url = $modx->makeUrl($modx->documentIdentifier, '', '', 'full').'?';
141 141
 				} else {
142
-					$url = $_SERVER['PHP_SELF'] . '?';
142
+					$url = $_SERVER['PHP_SELF'].'?';
143 143
 				}
144 144
 				$i = 0;
145
-				foreach($_GET as $n => $v) if($n != 'dpgn' . $this->id) {
145
+				foreach ($_GET as $n => $v) if ($n != 'dpgn'.$this->id) {
146 146
 					$i++;
147
-					$url .= (($i > 1) ? "&" : "") . "$n=$v";
147
+					$url .= (($i > 1) ? "&" : "")."$n=$v";
148 148
 				}
149
-				if($i >= 1) {
149
+				if ($i >= 1) {
150 150
 					$url .= "&";
151 151
 				}
152 152
 			}
153
-			for($i = 1; $i <= $tp; $i++) {
154
-				if(isset($fnc)) {
155
-					if($args != "") {
153
+			for ($i = 1; $i <= $tp; $i++) {
154
+				if (isset($fnc)) {
155
+					if ($args != "") {
156 156
 						$this->pager .= $fnc($p, $i, $args);
157 157
 					} else {
158 158
 						$this->pager .= $fnc($p, $i);
159 159
 					}
160 160
 				} else {
161
-					$this->pager .= ($p == $i) ? " <span class='" . $this->selPageClass . "' style='" . $this->selPageStyle . "'>$i</span> " : " <a href='" . $url . "dpgn" . $this->id . "=$i' class='" . $this->pageClass . "' style='" . $this->pageStyle . "'>$i</a> ";
161
+					$this->pager .= ($p == $i) ? " <span class='".$this->selPageClass."' style='".$this->selPageStyle."'>$i</span> " : " <a href='".$url."dpgn".$this->id."=$i' class='".$this->pageClass."' style='".$this->pageStyle."'>$i</a> ";
162 162
 				}
163 163
 			}
164 164
 		}
@@ -167,21 +167,21 @@  discard block
 block discarded – undo
167 167
 		$fnc = $this->renderRowFnc;
168 168
 		$args = $this->renderRowFncArgs;
169 169
 
170
-		if(isset($fnc)) {
170
+		if (isset($fnc)) {
171 171
 			$i = 1;
172 172
 			$fncObject = is_object($fnc);
173 173
 			$minitems = (($p - 1) * $this->pageSize) + 1;
174 174
 			$maxitems = (($p - 1) * $this->pageSize) + $this->pageSize;
175
-			while($i <= $maxitems && ($row = ($isDataset) ? $modx->db->getRow($this->ds) : $this->ds[$i - 1])) {
176
-				if($i >= $minitems && $i <= $maxitems) {
177
-					if($fncObject) {
178
-						if($args != "") {
175
+			while ($i <= $maxitems && ($row = ($isDataset) ? $modx->db->getRow($this->ds) : $this->ds[$i - 1])) {
176
+				if ($i >= $minitems && $i <= $maxitems) {
177
+					if ($fncObject) {
178
+						if ($args != "") {
179 179
 							$this->rows .= $fnc->RenderRowFnc($i, $row, $args);
180 180
 						} else {
181 181
 							$this->rows .= $fnc->RenderRowFnc($i, $row);
182 182
 						}
183 183
 					} else {
184
-						if($args != "") {
184
+						if ($args != "") {
185 185
 							$this->rows .= $fnc($i, $row, $args);
186 186
 						} // if agrs was specified then we wil pass three params
187 187
 						else {
Please login to merge, or discard this patch.
Braces   +21 added lines, -10 removed lines patch added patch discarded remove patch
@@ -10,7 +10,8 @@  discard block
 block discarded – undo
10 10
 
11 11
 $__DataSetPagerCnt = 0;
12 12
 
13
-class DataSetPager {
13
+class DataSetPager
14
+{
14 15
 
15 16
 	public $ds; // datasource
16 17
     public $pageSize;
@@ -31,7 +32,8 @@  discard block
 block discarded – undo
31 32
     public $renderPagerFnc;
32 33
     public $renderPagerFncArgs;
33 34
 
34
-    public function __construct($id, $ds, $pageSize = 10, $pageNumber = -1) {
35
+    public function __construct($id, $ds, $pageSize = 10, $pageNumber = -1)
36
+    {
35 37
 		global $_PAGE; // use view state object
36 38
 
37 39
 		global $__DataSetPagerCnt;
@@ -61,35 +63,42 @@  discard block
 block discarded – undo
61 63
 		$this->pager = '';
62 64
 	}
63 65
 
64
-    public function getRenderedPager() {
66
+    public function getRenderedPager()
67
+    {
65 68
 		return $this->pager;
66 69
 	}
67 70
 
68
-    public function getRenderedRows() {
71
+    public function getRenderedRows()
72
+    {
69 73
 		return $this->rows;
70 74
 	}
71 75
 
72
-    public function setDataSource($ds) {
76
+    public function setDataSource($ds)
77
+    {
73 78
 		$this->ds = $ds;
74 79
 	}
75 80
 
76
-    public function setPageSize($ps) {
81
+    public function setPageSize($ps)
82
+    {
77 83
 		$this->pageSize = $ps;
78 84
 	}
79 85
 
80
-    public function setRenderRowFnc($fncName, $args = "") {
86
+    public function setRenderRowFnc($fncName, $args = "")
87
+    {
81 88
 		$this->renderRowFnc = &$fncName;
82 89
 		$this->renderRowFncArgs = $args;    // extra agruments
83 90
 
84 91
 
85 92
 	}
86 93
 
87
-    public function setRenderPagerFnc($fncName, $args = "") {
94
+    public function setRenderPagerFnc($fncName, $args = "")
95
+    {
88 96
 		$this->renderPagerFnc = $fncName;
89 97
 		$this->renderPagerFncArgs = $args;    // extra agruments
90 98
 	}
91 99
 
92
-    public function render() {
100
+    public function render()
101
+    {
93 102
 		global $modx, $_PAGE;
94 103
 
95 104
 		$isDataset = $modx->db->isResult($this->ds);
@@ -142,8 +151,10 @@  discard block
 block discarded – undo
142 151
 					$url = $_SERVER['PHP_SELF'] . '?';
143 152
 				}
144 153
 				$i = 0;
145
-				foreach($_GET as $n => $v) if($n != 'dpgn' . $this->id) {
154
+				foreach($_GET as $n => $v) {
155
+				    if($n != 'dpgn' . $this->id) {
146 156
 					$i++;
157
+				}
147 158
 					$url .= (($i > 1) ? "&" : "") . "$n=$v";
148 159
 				}
149 160
 				if($i >= 1) {
Please login to merge, or discard this patch.
manager/includes/extenders/export.class.inc.php 5 patches
Doc Comments   +6 added lines patch added patch discarded remove patch
@@ -102,6 +102,9 @@  discard block
 block discarded – undo
102 102
 		return $rs;
103 103
 	}
104 104
 
105
+    /**
106
+     * @param string $filepath
107
+     */
105 108
     public function makeFile($docid, $filepath)
106 109
 	{
107 110
 		global  $modx,$_lang;
@@ -250,6 +253,9 @@  discard block
 block discarded – undo
250 253
 		return implode("\n", $this->output);
251 254
 	}
252 255
 
256
+    /**
257
+     * @param string $url
258
+     */
253 259
     public function curl_get_contents($url, $timeout = 30 )
254 260
     {
255 261
     	if(!function_exists('curl_init')) return @file_get_contents($url);
Please login to merge, or discard this patch.
Indentation   +209 added lines, -209 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 class EXPORT_SITE
3 3
 {
4
-	public $targetDir;
4
+    public $targetDir;
5 5
     public $generate_mode;
6 6
     public $total;
7 7
     public $count;
@@ -13,246 +13,246 @@  discard block
 block discarded – undo
13 13
     public $dirCheckCount = 0;
14 14
 
15 15
     public function __construct()
16
-	{
17
-		global $modx;
18
-
19
-		if(!defined('MODX_BASE_PATH'))  return false;
20
-		$this->exportstart = $this->get_mtime();
21
-		$this->count = 0;
22
-		$this->setUrlMode();
23
-		$this->generate_mode = 'crawl';
24
-		$this->targetDir = $modx->config['base_path'] . 'temp/export';
25
-		if(!isset($this->total)) $this->getTotal();
26
-	}
16
+    {
17
+        global $modx;
18
+
19
+        if(!defined('MODX_BASE_PATH'))  return false;
20
+        $this->exportstart = $this->get_mtime();
21
+        $this->count = 0;
22
+        $this->setUrlMode();
23
+        $this->generate_mode = 'crawl';
24
+        $this->targetDir = $modx->config['base_path'] . 'temp/export';
25
+        if(!isset($this->total)) $this->getTotal();
26
+    }
27 27
 
28 28
     public function setExportDir($dir)
29
-	{
30
-		$dir = str_replace('\\','/',$dir);
31
-		$dir = rtrim($dir, '/');
32
-		$this->targetDir = $dir;
33
-	}
29
+    {
30
+        $dir = str_replace('\\','/',$dir);
31
+        $dir = rtrim($dir, '/');
32
+        $this->targetDir = $dir;
33
+    }
34 34
 
35 35
     public function get_mtime()
36
-	{
37
-		$mtime = microtime();
38
-		$mtime = explode(' ', $mtime);
39
-		$mtime = $mtime[1] + $mtime[0];
40
-		return $mtime;
41
-	}
36
+    {
37
+        $mtime = microtime();
38
+        $mtime = explode(' ', $mtime);
39
+        $mtime = $mtime[1] + $mtime[0];
40
+        return $mtime;
41
+    }
42 42
 
43 43
     public function setUrlMode()
44
-	{
45
-		global $modx;
46
-
47
-		if($modx->config['friendly_urls']==0)
48
-		{
49
-			$modx->config['friendly_urls']  = 1;
50
-			$modx->config['use_alias_path'] = 1;
51
-			$modx->clearCache('full');
52
-		}
53
-		$modx->config['make_folders'] = '1';
54
-	}
44
+    {
45
+        global $modx;
46
+
47
+        if($modx->config['friendly_urls']==0)
48
+        {
49
+            $modx->config['friendly_urls']  = 1;
50
+            $modx->config['use_alias_path'] = 1;
51
+            $modx->clearCache('full');
52
+        }
53
+        $modx->config['make_folders'] = '1';
54
+    }
55 55
 
56 56
     public function getTotal($ignore_ids='', $noncache='0')
57
-	{
58
-		global $modx;
59
-		$tbl_site_content = $modx->getFullTableName('site_content');
60
-
61
-		$ignore_ids = array_filter(array_map('intval', explode(',', $ignore_ids)));
62
-		if(count($ignore_ids)>0)
63
-		{
64
-			$ignore_ids = "AND NOT id IN ('".implode("','", $ignore_ids)."')";
65
-		} else {
66
-			$ignore_ids = '';
67
-		}
68
-
69
-		$this->ignore_ids = $ignore_ids;
70
-
71
-		$noncache = ($noncache == 1) ? '' : 'AND cacheable=1';
72
-		$where = "deleted=0 AND ((published=1 AND type='document') OR (isfolder=1)) {$noncache} {$ignore_ids}";
73
-		$rs  = $modx->db->select('count(id)',$tbl_site_content,$where);
74
-		$this->total = $modx->db->getValue($rs);
75
-		return $this->total;
76
-	}
57
+    {
58
+        global $modx;
59
+        $tbl_site_content = $modx->getFullTableName('site_content');
60
+
61
+        $ignore_ids = array_filter(array_map('intval', explode(',', $ignore_ids)));
62
+        if(count($ignore_ids)>0)
63
+        {
64
+            $ignore_ids = "AND NOT id IN ('".implode("','", $ignore_ids)."')";
65
+        } else {
66
+            $ignore_ids = '';
67
+        }
68
+
69
+        $this->ignore_ids = $ignore_ids;
70
+
71
+        $noncache = ($noncache == 1) ? '' : 'AND cacheable=1';
72
+        $where = "deleted=0 AND ((published=1 AND type='document') OR (isfolder=1)) {$noncache} {$ignore_ids}";
73
+        $rs  = $modx->db->select('count(id)',$tbl_site_content,$where);
74
+        $this->total = $modx->db->getValue($rs);
75
+        return $this->total;
76
+    }
77 77
 
78 78
     public function removeDirectoryAll($directory='')
79
-	{
80
-	    $rs = false;
81
-		if(empty($directory)) $directory = $this->targetDir;
82
-		$directory = rtrim($directory,'/');
83
-		// if the path is not valid or is not a directory ...
84
-		if(empty($directory)) return false;
85
-		if(strpos($directory,MODX_BASE_PATH)===false) return $rs;
86
-
87
-		if(!is_dir($directory))          return $rs;
88
-		elseif(!is_readable($directory)) return $rs;
89
-		else
90
-		{
91
-			$files = glob($directory . '/*');
92
-			if(!empty($files))
93
-			{
94
-    			foreach($files as $path)
95
-    			{
79
+    {
80
+        $rs = false;
81
+        if(empty($directory)) $directory = $this->targetDir;
82
+        $directory = rtrim($directory,'/');
83
+        // if the path is not valid or is not a directory ...
84
+        if(empty($directory)) return false;
85
+        if(strpos($directory,MODX_BASE_PATH)===false) return $rs;
86
+
87
+        if(!is_dir($directory))          return $rs;
88
+        elseif(!is_readable($directory)) return $rs;
89
+        else
90
+        {
91
+            $files = glob($directory . '/*');
92
+            if(!empty($files))
93
+            {
94
+                foreach($files as $path)
95
+                {
96 96
                     $rs = is_dir($path) ? $this->removeDirectoryAll($path) : unlink($path);
97
-    			}
98
-			}
99
-		}
100
-		if($directory !== $this->targetDir) $rs = rmdir($directory);
97
+                }
98
+            }
99
+        }
100
+        if($directory !== $this->targetDir) $rs = rmdir($directory);
101 101
 
102
-		return $rs;
103
-	}
102
+        return $rs;
103
+    }
104 104
 
105 105
     public function makeFile($docid, $filepath)
106
-	{
107
-		global  $modx,$_lang;
108
-		$file_permission = octdec($modx->config['new_file_permissions']);
109
-		if($this->generate_mode==='direct')
110
-		{
111
-			$back_lang = $_lang;
112
-			$src = $modx->executeParser($docid);
113
-
114
-			$_lang = $back_lang;
115
-		}
116
-		else $src = $this->curl_get_contents(MODX_SITE_URL . "index.php?id={$docid}");
117
-
118
-
119
-		if($src !== false)
120
-		{
121
-			if($this->repl_before!==$this->repl_after) $src = str_replace($this->repl_before,$this->repl_after,$src);
122
-			$result = file_put_contents($filepath,$src);
123
-			if($result!==false) @chmod($filepath, $file_permission);
124
-
125
-			if($result !== false) return 'success';
126
-			else                  return 'failed_no_write';
127
-		}
128
-		else                      return 'failed_no_retrieve';
129
-	}
106
+    {
107
+        global  $modx,$_lang;
108
+        $file_permission = octdec($modx->config['new_file_permissions']);
109
+        if($this->generate_mode==='direct')
110
+        {
111
+            $back_lang = $_lang;
112
+            $src = $modx->executeParser($docid);
113
+
114
+            $_lang = $back_lang;
115
+        }
116
+        else $src = $this->curl_get_contents(MODX_SITE_URL . "index.php?id={$docid}");
117
+
118
+
119
+        if($src !== false)
120
+        {
121
+            if($this->repl_before!==$this->repl_after) $src = str_replace($this->repl_before,$this->repl_after,$src);
122
+            $result = file_put_contents($filepath,$src);
123
+            if($result!==false) @chmod($filepath, $file_permission);
124
+
125
+            if($result !== false) return 'success';
126
+            else                  return 'failed_no_write';
127
+        }
128
+        else                      return 'failed_no_retrieve';
129
+    }
130 130
 
131 131
     public function getFileName($docid, $alias='', $prefix, $suffix)
132
-	{
133
-		global $modx;
134
-
135
-		if($alias==='') $filename = $prefix.$docid.$suffix;
136
-		else
137
-		{
138
-			if($modx->config['suffix_mode']==='1' && strpos($alias, '.')!==false)
139
-			{
140
-				$suffix = '';
141
-			}
142
-			$filename = $prefix.$alias.$suffix;
143
-		}
144
-		return $filename;
145
-	}
132
+    {
133
+        global $modx;
134
+
135
+        if($alias==='') $filename = $prefix.$docid.$suffix;
136
+        else
137
+        {
138
+            if($modx->config['suffix_mode']==='1' && strpos($alias, '.')!==false)
139
+            {
140
+                $suffix = '';
141
+            }
142
+            $filename = $prefix.$alias.$suffix;
143
+        }
144
+        return $filename;
145
+    }
146 146
 
147 147
     public function run($parent=0)
148
-	{
149
-		global $_lang;
150
-		global $modx;
148
+    {
149
+        global $_lang;
150
+        global $modx;
151 151
 
152
-		$tbl_site_content = $modx->getFullTableName('site_content');
152
+        $tbl_site_content = $modx->getFullTableName('site_content');
153 153
 
154
-		$ignore_ids = $this->ignore_ids;
155
-		$dirpath = $this->targetDir . '/';
154
+        $ignore_ids = $this->ignore_ids;
155
+        $dirpath = $this->targetDir . '/';
156 156
 
157
-		$prefix = $modx->config['friendly_url_prefix'];
158
-		$suffix = $modx->config['friendly_url_suffix'];
157
+        $prefix = $modx->config['friendly_url_prefix'];
158
+        $suffix = $modx->config['friendly_url_suffix'];
159 159
 
160
-		$tpl = ' <span class="[+status+]">[+msg1+]</span> [+msg2+]</span>';
161
-		$ph = array();
160
+        $tpl = ' <span class="[+status+]">[+msg1+]</span> [+msg2+]</span>';
161
+        $ph = array();
162 162
 
163
-		$ph['status'] = 'fail';
164
-		$ph['msg1']   = $_lang['export_site_failed'];
165
-		$ph['msg2']   = $_lang["export_site_failed_no_write"] . ' - ' . $dirpath;
166
-		$msg_failed_no_write    = $this->parsePlaceholder($tpl,$ph);
163
+        $ph['status'] = 'fail';
164
+        $ph['msg1']   = $_lang['export_site_failed'];
165
+        $ph['msg2']   = $_lang["export_site_failed_no_write"] . ' - ' . $dirpath;
166
+        $msg_failed_no_write    = $this->parsePlaceholder($tpl,$ph);
167 167
 
168
-		$ph['msg2']   = $_lang["export_site_failed_no_retrieve"];
169
-		$msg_failed_no_retrieve = $this->parsePlaceholder($tpl,$ph);
168
+        $ph['msg2']   = $_lang["export_site_failed_no_retrieve"];
169
+        $msg_failed_no_retrieve = $this->parsePlaceholder($tpl,$ph);
170 170
 
171
-		$ph['status'] = 'success';
172
-		$ph['msg1']   = $_lang['export_site_success'];
173
-		$ph['msg2']   = '';
174
-		$msg_success            = $this->parsePlaceholder($tpl,$ph);
171
+        $ph['status'] = 'success';
172
+        $ph['msg1']   = $_lang['export_site_success'];
173
+        $ph['msg2']   = '';
174
+        $msg_success            = $this->parsePlaceholder($tpl,$ph);
175 175
 
176
-		$ph['msg2']   = $_lang['export_site_success_skip_doc'];
177
-		$msg_success_skip_doc = $this->parsePlaceholder($tpl,$ph);
176
+        $ph['msg2']   = $_lang['export_site_success_skip_doc'];
177
+        $msg_success_skip_doc = $this->parsePlaceholder($tpl,$ph);
178 178
 
179
-		$ph['msg2']   = $_lang['export_site_success_skip_dir'];
180
-		$msg_success_skip_dir = $this->parsePlaceholder($tpl,$ph);
179
+        $ph['msg2']   = $_lang['export_site_success_skip_dir'];
180
+        $msg_success_skip_dir = $this->parsePlaceholder($tpl,$ph);
181 181
 
182
-		$fields = "id, alias, pagetitle, isfolder, (content = '' AND template = 0) AS wasNull, published";
183
-		$noncache = $_POST['includenoncache']==1 ? '' : 'AND cacheable=1';
184
-		$where = "parent = '{$parent}' AND deleted=0 AND ((published=1 AND type='document') OR (isfolder=1)) {$noncache} {$ignore_ids}";
185
-		$rs = $modx->db->select($fields,$tbl_site_content,$where);
182
+        $fields = "id, alias, pagetitle, isfolder, (content = '' AND template = 0) AS wasNull, published";
183
+        $noncache = $_POST['includenoncache']==1 ? '' : 'AND cacheable=1';
184
+        $where = "parent = '{$parent}' AND deleted=0 AND ((published=1 AND type='document') OR (isfolder=1)) {$noncache} {$ignore_ids}";
185
+        $rs = $modx->db->select($fields,$tbl_site_content,$where);
186 186
 
187
-		$ph = array();
188
-		$ph['total']     = $this->total;
189
-		$folder_permission = octdec($modx->config['new_folder_permissions']);
190
-		while($row = $modx->db->getRow($rs))
191
-		{
192
-			$this->count++;
187
+        $ph = array();
188
+        $ph['total']     = $this->total;
189
+        $folder_permission = octdec($modx->config['new_folder_permissions']);
190
+        while($row = $modx->db->getRow($rs))
191
+        {
192
+            $this->count++;
193 193
             $filename = '';
194
-			$row['count']     = $this->count;
195
-			$row['url'] = $modx->makeUrl($row['id']);
196
-
197
-			if (!$row['wasNull'])
198
-			{ // needs writing a document
199
-				$docname = $this->getFileName($row['id'], $row['alias'], $prefix, $suffix);
200
-				$filename = $dirpath.$docname;
201
-				if (!is_file($filename))
202
-				{
203
-					if($row['published']==='1')
204
-					{
205
-						$status = $this->makeFile($row['id'], $filename);
206
-						switch($status)
207
-						{
208
-							case 'failed_no_write'   :
194
+            $row['count']     = $this->count;
195
+            $row['url'] = $modx->makeUrl($row['id']);
196
+
197
+            if (!$row['wasNull'])
198
+            { // needs writing a document
199
+                $docname = $this->getFileName($row['id'], $row['alias'], $prefix, $suffix);
200
+                $filename = $dirpath.$docname;
201
+                if (!is_file($filename))
202
+                {
203
+                    if($row['published']==='1')
204
+                    {
205
+                        $status = $this->makeFile($row['id'], $filename);
206
+                        switch($status)
207
+                        {
208
+                            case 'failed_no_write'   :
209 209
                                                             $row['status'] = $msg_failed_no_write;
210 210
                                                             break;
211
-							case 'failed_no_retrieve':
211
+                            case 'failed_no_retrieve':
212 212
                                                             $row['status'] = $msg_failed_no_retrieve;
213 213
                                                             break;
214
-							default:
214
+                            default:
215 215
                                                             $row['status'] = $msg_success;
216
-						}
217
-					}
218
-					else $row['status'] = $msg_failed_no_retrieve;
219
-				}
220
-				else     $row['status'] = $msg_success_skip_doc;
221
-				$this->output[] = $this->parsePlaceholder($_lang['export_site_exporting_document'], $row);
222
-			}
223
-			else
224
-			{
225
-				$row['status'] = $msg_success_skip_dir;
226
-				$this->output[] = $this->parsePlaceholder($_lang['export_site_exporting_document'], $row);
227
-			}
228
-			if ($row['isfolder']==='1' && ($modx->config['suffix_mode']!=='1' || strpos($row['alias'],'.')===false))
229
-			{ // needs making a folder
230
-				$end_dir = ($row['alias']!=='') ? $row['alias'] : $row['id'];
231
-				$dir_path = $dirpath . $end_dir;
232
-				if(strpos($dir_path,MODX_BASE_PATH)===false) return FALSE;
233
-				if (!is_dir($dir_path))
234
-				{
235
-					if (is_file($dir_path)) @unlink($dir_path);
236
-					mkdir($dir_path);
237
-					@chmod($dir_path, $folder_permission);
238
-
239
-				}
240
-
241
-
242
-				if($modx->config['make_folders']==='1' && $row['published']==='1')
243
-				{
244
-					if( ! empty($filename) && is_file($filename)) rename($filename,$dir_path . '/index.html');
245
-				}
246
-				$this->targetDir = $dir_path;
247
-				$this->run($row['id']);
248
-			}
249
-		}
250
-		return implode("\n", $this->output);
251
-	}
216
+                        }
217
+                    }
218
+                    else $row['status'] = $msg_failed_no_retrieve;
219
+                }
220
+                else     $row['status'] = $msg_success_skip_doc;
221
+                $this->output[] = $this->parsePlaceholder($_lang['export_site_exporting_document'], $row);
222
+            }
223
+            else
224
+            {
225
+                $row['status'] = $msg_success_skip_dir;
226
+                $this->output[] = $this->parsePlaceholder($_lang['export_site_exporting_document'], $row);
227
+            }
228
+            if ($row['isfolder']==='1' && ($modx->config['suffix_mode']!=='1' || strpos($row['alias'],'.')===false))
229
+            { // needs making a folder
230
+                $end_dir = ($row['alias']!=='') ? $row['alias'] : $row['id'];
231
+                $dir_path = $dirpath . $end_dir;
232
+                if(strpos($dir_path,MODX_BASE_PATH)===false) return FALSE;
233
+                if (!is_dir($dir_path))
234
+                {
235
+                    if (is_file($dir_path)) @unlink($dir_path);
236
+                    mkdir($dir_path);
237
+                    @chmod($dir_path, $folder_permission);
238
+
239
+                }
240
+
241
+
242
+                if($modx->config['make_folders']==='1' && $row['published']==='1')
243
+                {
244
+                    if( ! empty($filename) && is_file($filename)) rename($filename,$dir_path . '/index.html');
245
+                }
246
+                $this->targetDir = $dir_path;
247
+                $this->run($row['id']);
248
+            }
249
+        }
250
+        return implode("\n", $this->output);
251
+    }
252 252
 
253 253
     public function curl_get_contents($url, $timeout = 30 )
254 254
     {
255
-    	if(!function_exists('curl_init')) return @file_get_contents($url);
255
+        if(!function_exists('curl_init')) return @file_get_contents($url);
256 256
 
257 257
         $ch = curl_init();
258 258
         curl_setopt($ch, CURLOPT_URL, $url);
@@ -269,12 +269,12 @@  discard block
 block discarded – undo
269 269
 
270 270
     public function parsePlaceholder($tpl,$ph=array())
271 271
     {
272
-    	foreach($ph as $k=>$v)
273
-    	{
274
-    		$k = "[+{$k}+]";
275
-    		$tpl = str_replace($k,$v,$tpl);
276
-    	}
277
-    	return $tpl;
272
+        foreach($ph as $k=>$v)
273
+        {
274
+            $k = "[+{$k}+]";
275
+            $tpl = str_replace($k,$v,$tpl);
276
+        }
277
+        return $tpl;
278 278
     }
279 279
 
280 280
 }
Please login to merge, or discard this patch.
Spacing   +59 added lines, -59 removed lines patch added patch discarded remove patch
@@ -16,18 +16,18 @@  discard block
 block discarded – undo
16 16
 	{
17 17
 		global $modx;
18 18
 
19
-		if(!defined('MODX_BASE_PATH'))  return false;
19
+		if (!defined('MODX_BASE_PATH'))  return false;
20 20
 		$this->exportstart = $this->get_mtime();
21 21
 		$this->count = 0;
22 22
 		$this->setUrlMode();
23 23
 		$this->generate_mode = 'crawl';
24
-		$this->targetDir = $modx->config['base_path'] . 'temp/export';
25
-		if(!isset($this->total)) $this->getTotal();
24
+		$this->targetDir = $modx->config['base_path'].'temp/export';
25
+		if (!isset($this->total)) $this->getTotal();
26 26
 	}
27 27
 
28 28
     public function setExportDir($dir)
29 29
 	{
30
-		$dir = str_replace('\\','/',$dir);
30
+		$dir = str_replace('\\', '/', $dir);
31 31
 		$dir = rtrim($dir, '/');
32 32
 		$this->targetDir = $dir;
33 33
 	}
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
 	{
45 45
 		global $modx;
46 46
 
47
-		if($modx->config['friendly_urls']==0)
47
+		if ($modx->config['friendly_urls'] == 0)
48 48
 		{
49 49
 			$modx->config['friendly_urls']  = 1;
50 50
 			$modx->config['use_alias_path'] = 1;
@@ -53,13 +53,13 @@  discard block
 block discarded – undo
53 53
 		$modx->config['make_folders'] = '1';
54 54
 	}
55 55
 
56
-    public function getTotal($ignore_ids='', $noncache='0')
56
+    public function getTotal($ignore_ids = '', $noncache = '0')
57 57
 	{
58 58
 		global $modx;
59 59
 		$tbl_site_content = $modx->getFullTableName('site_content');
60 60
 
61 61
 		$ignore_ids = array_filter(array_map('intval', explode(',', $ignore_ids)));
62
-		if(count($ignore_ids)>0)
62
+		if (count($ignore_ids) > 0)
63 63
 		{
64 64
 			$ignore_ids = "AND NOT id IN ('".implode("','", $ignore_ids)."')";
65 65
 		} else {
@@ -70,72 +70,72 @@  discard block
 block discarded – undo
70 70
 
71 71
 		$noncache = ($noncache == 1) ? '' : 'AND cacheable=1';
72 72
 		$where = "deleted=0 AND ((published=1 AND type='document') OR (isfolder=1)) {$noncache} {$ignore_ids}";
73
-		$rs  = $modx->db->select('count(id)',$tbl_site_content,$where);
73
+		$rs = $modx->db->select('count(id)', $tbl_site_content, $where);
74 74
 		$this->total = $modx->db->getValue($rs);
75 75
 		return $this->total;
76 76
 	}
77 77
 
78
-    public function removeDirectoryAll($directory='')
78
+    public function removeDirectoryAll($directory = '')
79 79
 	{
80 80
 	    $rs = false;
81
-		if(empty($directory)) $directory = $this->targetDir;
82
-		$directory = rtrim($directory,'/');
81
+		if (empty($directory)) $directory = $this->targetDir;
82
+		$directory = rtrim($directory, '/');
83 83
 		// if the path is not valid or is not a directory ...
84
-		if(empty($directory)) return false;
85
-		if(strpos($directory,MODX_BASE_PATH)===false) return $rs;
84
+		if (empty($directory)) return false;
85
+		if (strpos($directory, MODX_BASE_PATH) === false) return $rs;
86 86
 
87
-		if(!is_dir($directory))          return $rs;
88
-		elseif(!is_readable($directory)) return $rs;
87
+		if (!is_dir($directory))          return $rs;
88
+		elseif (!is_readable($directory)) return $rs;
89 89
 		else
90 90
 		{
91
-			$files = glob($directory . '/*');
92
-			if(!empty($files))
91
+			$files = glob($directory.'/*');
92
+			if (!empty($files))
93 93
 			{
94
-    			foreach($files as $path)
94
+    			foreach ($files as $path)
95 95
     			{
96 96
                     $rs = is_dir($path) ? $this->removeDirectoryAll($path) : unlink($path);
97 97
     			}
98 98
 			}
99 99
 		}
100
-		if($directory !== $this->targetDir) $rs = rmdir($directory);
100
+		if ($directory !== $this->targetDir) $rs = rmdir($directory);
101 101
 
102 102
 		return $rs;
103 103
 	}
104 104
 
105 105
     public function makeFile($docid, $filepath)
106 106
 	{
107
-		global  $modx,$_lang;
107
+		global  $modx, $_lang;
108 108
 		$file_permission = octdec($modx->config['new_file_permissions']);
109
-		if($this->generate_mode==='direct')
109
+		if ($this->generate_mode === 'direct')
110 110
 		{
111 111
 			$back_lang = $_lang;
112 112
 			$src = $modx->executeParser($docid);
113 113
 
114 114
 			$_lang = $back_lang;
115 115
 		}
116
-		else $src = $this->curl_get_contents(MODX_SITE_URL . "index.php?id={$docid}");
116
+		else $src = $this->curl_get_contents(MODX_SITE_URL."index.php?id={$docid}");
117 117
 
118 118
 
119
-		if($src !== false)
119
+		if ($src !== false)
120 120
 		{
121
-			if($this->repl_before!==$this->repl_after) $src = str_replace($this->repl_before,$this->repl_after,$src);
122
-			$result = file_put_contents($filepath,$src);
123
-			if($result!==false) @chmod($filepath, $file_permission);
121
+			if ($this->repl_before !== $this->repl_after) $src = str_replace($this->repl_before, $this->repl_after, $src);
122
+			$result = file_put_contents($filepath, $src);
123
+			if ($result !== false) @chmod($filepath, $file_permission);
124 124
 
125
-			if($result !== false) return 'success';
125
+			if ($result !== false) return 'success';
126 126
 			else                  return 'failed_no_write';
127 127
 		}
128 128
 		else                      return 'failed_no_retrieve';
129 129
 	}
130 130
 
131
-    public function getFileName($docid, $alias='', $prefix, $suffix)
131
+    public function getFileName($docid, $alias = '', $prefix, $suffix)
132 132
 	{
133 133
 		global $modx;
134 134
 
135
-		if($alias==='') $filename = $prefix.$docid.$suffix;
135
+		if ($alias === '') $filename = $prefix.$docid.$suffix;
136 136
 		else
137 137
 		{
138
-			if($modx->config['suffix_mode']==='1' && strpos($alias, '.')!==false)
138
+			if ($modx->config['suffix_mode'] === '1' && strpos($alias, '.') !== false)
139 139
 			{
140 140
 				$suffix = '';
141 141
 			}
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
 		return $filename;
145 145
 	}
146 146
 
147
-    public function run($parent=0)
147
+    public function run($parent = 0)
148 148
 	{
149 149
 		global $_lang;
150 150
 		global $modx;
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
 		$tbl_site_content = $modx->getFullTableName('site_content');
153 153
 
154 154
 		$ignore_ids = $this->ignore_ids;
155
-		$dirpath = $this->targetDir . '/';
155
+		$dirpath = $this->targetDir.'/';
156 156
 
157 157
 		$prefix = $modx->config['friendly_url_prefix'];
158 158
 		$suffix = $modx->config['friendly_url_suffix'];
@@ -162,36 +162,36 @@  discard block
 block discarded – undo
162 162
 
163 163
 		$ph['status'] = 'fail';
164 164
 		$ph['msg1']   = $_lang['export_site_failed'];
165
-		$ph['msg2']   = $_lang["export_site_failed_no_write"] . ' - ' . $dirpath;
166
-		$msg_failed_no_write    = $this->parsePlaceholder($tpl,$ph);
165
+		$ph['msg2']   = $_lang["export_site_failed_no_write"].' - '.$dirpath;
166
+		$msg_failed_no_write    = $this->parsePlaceholder($tpl, $ph);
167 167
 
168 168
 		$ph['msg2']   = $_lang["export_site_failed_no_retrieve"];
169
-		$msg_failed_no_retrieve = $this->parsePlaceholder($tpl,$ph);
169
+		$msg_failed_no_retrieve = $this->parsePlaceholder($tpl, $ph);
170 170
 
171 171
 		$ph['status'] = 'success';
172 172
 		$ph['msg1']   = $_lang['export_site_success'];
173 173
 		$ph['msg2']   = '';
174
-		$msg_success            = $this->parsePlaceholder($tpl,$ph);
174
+		$msg_success = $this->parsePlaceholder($tpl, $ph);
175 175
 
176 176
 		$ph['msg2']   = $_lang['export_site_success_skip_doc'];
177
-		$msg_success_skip_doc = $this->parsePlaceholder($tpl,$ph);
177
+		$msg_success_skip_doc = $this->parsePlaceholder($tpl, $ph);
178 178
 
179 179
 		$ph['msg2']   = $_lang['export_site_success_skip_dir'];
180
-		$msg_success_skip_dir = $this->parsePlaceholder($tpl,$ph);
180
+		$msg_success_skip_dir = $this->parsePlaceholder($tpl, $ph);
181 181
 
182 182
 		$fields = "id, alias, pagetitle, isfolder, (content = '' AND template = 0) AS wasNull, published";
183
-		$noncache = $_POST['includenoncache']==1 ? '' : 'AND cacheable=1';
183
+		$noncache = $_POST['includenoncache'] == 1 ? '' : 'AND cacheable=1';
184 184
 		$where = "parent = '{$parent}' AND deleted=0 AND ((published=1 AND type='document') OR (isfolder=1)) {$noncache} {$ignore_ids}";
185
-		$rs = $modx->db->select($fields,$tbl_site_content,$where);
185
+		$rs = $modx->db->select($fields, $tbl_site_content, $where);
186 186
 
187 187
 		$ph = array();
188
-		$ph['total']     = $this->total;
188
+		$ph['total'] = $this->total;
189 189
 		$folder_permission = octdec($modx->config['new_folder_permissions']);
190
-		while($row = $modx->db->getRow($rs))
190
+		while ($row = $modx->db->getRow($rs))
191 191
 		{
192 192
 			$this->count++;
193 193
             $filename = '';
194
-			$row['count']     = $this->count;
194
+			$row['count'] = $this->count;
195 195
 			$row['url'] = $modx->makeUrl($row['id']);
196 196
 
197 197
 			if (!$row['wasNull'])
@@ -200,10 +200,10 @@  discard block
 block discarded – undo
200 200
 				$filename = $dirpath.$docname;
201 201
 				if (!is_file($filename))
202 202
 				{
203
-					if($row['published']==='1')
203
+					if ($row['published'] === '1')
204 204
 					{
205 205
 						$status = $this->makeFile($row['id'], $filename);
206
-						switch($status)
206
+						switch ($status)
207 207
 						{
208 208
 							case 'failed_no_write'   :
209 209
                                                             $row['status'] = $msg_failed_no_write;
@@ -225,11 +225,11 @@  discard block
 block discarded – undo
225 225
 				$row['status'] = $msg_success_skip_dir;
226 226
 				$this->output[] = $this->parsePlaceholder($_lang['export_site_exporting_document'], $row);
227 227
 			}
228
-			if ($row['isfolder']==='1' && ($modx->config['suffix_mode']!=='1' || strpos($row['alias'],'.')===false))
228
+			if ($row['isfolder'] === '1' && ($modx->config['suffix_mode'] !== '1' || strpos($row['alias'], '.') === false))
229 229
 			{ // needs making a folder
230
-				$end_dir = ($row['alias']!=='') ? $row['alias'] : $row['id'];
231
-				$dir_path = $dirpath . $end_dir;
232
-				if(strpos($dir_path,MODX_BASE_PATH)===false) return FALSE;
230
+				$end_dir = ($row['alias'] !== '') ? $row['alias'] : $row['id'];
231
+				$dir_path = $dirpath.$end_dir;
232
+				if (strpos($dir_path, MODX_BASE_PATH) === false) return FALSE;
233 233
 				if (!is_dir($dir_path))
234 234
 				{
235 235
 					if (is_file($dir_path)) @unlink($dir_path);
@@ -239,9 +239,9 @@  discard block
 block discarded – undo
239 239
 				}
240 240
 
241 241
 
242
-				if($modx->config['make_folders']==='1' && $row['published']==='1')
242
+				if ($modx->config['make_folders'] === '1' && $row['published'] === '1')
243 243
 				{
244
-					if( ! empty($filename) && is_file($filename)) rename($filename,$dir_path . '/index.html');
244
+					if (!empty($filename) && is_file($filename)) rename($filename, $dir_path.'/index.html');
245 245
 				}
246 246
 				$this->targetDir = $dir_path;
247 247
 				$this->run($row['id']);
@@ -250,16 +250,16 @@  discard block
 block discarded – undo
250 250
 		return implode("\n", $this->output);
251 251
 	}
252 252
 
253
-    public function curl_get_contents($url, $timeout = 30 )
253
+    public function curl_get_contents($url, $timeout = 30)
254 254
     {
255
-    	if(!function_exists('curl_init')) return @file_get_contents($url);
255
+    	if (!function_exists('curl_init')) return @file_get_contents($url);
256 256
 
257 257
         $ch = curl_init();
258 258
         curl_setopt($ch, CURLOPT_URL, $url);
259
-        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);    // 0 = DO NOT VERIFY AUTHENTICITY OF SSL-CERT
260
-        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);    // 2 = CERT MUST INDICATE BEING CONNECTED TO RIGHT SERVER
259
+        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); // 0 = DO NOT VERIFY AUTHENTICITY OF SSL-CERT
260
+        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); // 2 = CERT MUST INDICATE BEING CONNECTED TO RIGHT SERVER
261 261
         curl_setopt($ch, CURLOPT_HEADER, false);
262
-        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true );
262
+        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
263 263
         curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
264 264
         curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
265 265
         $result = curl_exec($ch);
@@ -267,12 +267,12 @@  discard block
 block discarded – undo
267 267
         return $result;
268 268
     }
269 269
 
270
-    public function parsePlaceholder($tpl,$ph=array())
270
+    public function parsePlaceholder($tpl, $ph = array())
271 271
     {
272
-    	foreach($ph as $k=>$v)
272
+    	foreach ($ph as $k=>$v)
273 273
     	{
274 274
     		$k = "[+{$k}+]";
275
-    		$tpl = str_replace($k,$v,$tpl);
275
+    		$tpl = str_replace($k, $v, $tpl);
276 276
     	}
277 277
     	return $tpl;
278 278
     }
Please login to merge, or discard this patch.
Braces   +85 added lines, -69 removed lines patch added patch discarded remove patch
@@ -13,27 +13,31 @@  discard block
 block discarded – undo
13 13
     public $dirCheckCount = 0;
14 14
 
15 15
     public function __construct()
16
-	{
16
+    {
17 17
 		global $modx;
18 18
 
19
-		if(!defined('MODX_BASE_PATH'))  return false;
19
+		if(!defined('MODX_BASE_PATH')) {
20
+		    return false;
21
+		}
20 22
 		$this->exportstart = $this->get_mtime();
21 23
 		$this->count = 0;
22 24
 		$this->setUrlMode();
23 25
 		$this->generate_mode = 'crawl';
24 26
 		$this->targetDir = $modx->config['base_path'] . 'temp/export';
25
-		if(!isset($this->total)) $this->getTotal();
27
+		if(!isset($this->total)) {
28
+		    $this->getTotal();
29
+		}
26 30
 	}
27 31
 
28 32
     public function setExportDir($dir)
29
-	{
33
+    {
30 34
 		$dir = str_replace('\\','/',$dir);
31 35
 		$dir = rtrim($dir, '/');
32 36
 		$this->targetDir = $dir;
33 37
 	}
34 38
 
35 39
     public function get_mtime()
36
-	{
40
+    {
37 41
 		$mtime = microtime();
38 42
 		$mtime = explode(' ', $mtime);
39 43
 		$mtime = $mtime[1] + $mtime[0];
@@ -41,11 +45,10 @@  discard block
 block discarded – undo
41 45
 	}
42 46
 
43 47
     public function setUrlMode()
44
-	{
48
+    {
45 49
 		global $modx;
46 50
 
47
-		if($modx->config['friendly_urls']==0)
48
-		{
51
+		if($modx->config['friendly_urls']==0) {
49 52
 			$modx->config['friendly_urls']  = 1;
50 53
 			$modx->config['use_alias_path'] = 1;
51 54
 			$modx->clearCache('full');
@@ -54,13 +57,12 @@  discard block
 block discarded – undo
54 57
 	}
55 58
 
56 59
     public function getTotal($ignore_ids='', $noncache='0')
57
-	{
60
+    {
58 61
 		global $modx;
59 62
 		$tbl_site_content = $modx->getFullTableName('site_content');
60 63
 
61 64
 		$ignore_ids = array_filter(array_map('intval', explode(',', $ignore_ids)));
62
-		if(count($ignore_ids)>0)
63
-		{
65
+		if(count($ignore_ids)>0) {
64 66
 			$ignore_ids = "AND NOT id IN ('".implode("','", $ignore_ids)."')";
65 67
 		} else {
66 68
 			$ignore_ids = '';
@@ -76,67 +78,80 @@  discard block
 block discarded – undo
76 78
 	}
77 79
 
78 80
     public function removeDirectoryAll($directory='')
79
-	{
81
+    {
80 82
 	    $rs = false;
81
-		if(empty($directory)) $directory = $this->targetDir;
83
+		if(empty($directory)) {
84
+		    $directory = $this->targetDir;
85
+		}
82 86
 		$directory = rtrim($directory,'/');
83 87
 		// if the path is not valid or is not a directory ...
84
-		if(empty($directory)) return false;
85
-		if(strpos($directory,MODX_BASE_PATH)===false) return $rs;
88
+		if(empty($directory)) {
89
+		    return false;
90
+		}
91
+		if(strpos($directory,MODX_BASE_PATH)===false) {
92
+		    return $rs;
93
+		}
86 94
 
87
-		if(!is_dir($directory))          return $rs;
88
-		elseif(!is_readable($directory)) return $rs;
89
-		else
90
-		{
95
+		if(!is_dir($directory)) {
96
+		    return $rs;
97
+		} elseif(!is_readable($directory)) {
98
+		    return $rs;
99
+		} else {
91 100
 			$files = glob($directory . '/*');
92
-			if(!empty($files))
93
-			{
94
-    			foreach($files as $path)
95
-    			{
101
+			if(!empty($files)) {
102
+    			foreach($files as $path) {
96 103
                     $rs = is_dir($path) ? $this->removeDirectoryAll($path) : unlink($path);
97 104
     			}
98 105
 			}
99 106
 		}
100
-		if($directory !== $this->targetDir) $rs = rmdir($directory);
107
+		if($directory !== $this->targetDir) {
108
+		    $rs = rmdir($directory);
109
+		}
101 110
 
102 111
 		return $rs;
103 112
 	}
104 113
 
105 114
     public function makeFile($docid, $filepath)
106
-	{
115
+    {
107 116
 		global  $modx,$_lang;
108 117
 		$file_permission = octdec($modx->config['new_file_permissions']);
109
-		if($this->generate_mode==='direct')
110
-		{
118
+		if($this->generate_mode==='direct') {
111 119
 			$back_lang = $_lang;
112 120
 			$src = $modx->executeParser($docid);
113 121
 
114 122
 			$_lang = $back_lang;
123
+		} else {
124
+		    $src = $this->curl_get_contents(MODX_SITE_URL . "index.php?id={$docid}");
115 125
 		}
116
-		else $src = $this->curl_get_contents(MODX_SITE_URL . "index.php?id={$docid}");
117 126
 
118 127
 
119
-		if($src !== false)
120
-		{
121
-			if($this->repl_before!==$this->repl_after) $src = str_replace($this->repl_before,$this->repl_after,$src);
128
+		if($src !== false) {
129
+			if($this->repl_before!==$this->repl_after) {
130
+			    $src = str_replace($this->repl_before,$this->repl_after,$src);
131
+			}
122 132
 			$result = file_put_contents($filepath,$src);
123
-			if($result!==false) @chmod($filepath, $file_permission);
133
+			if($result!==false) {
134
+			    @chmod($filepath, $file_permission);
135
+			}
124 136
 
125
-			if($result !== false) return 'success';
126
-			else                  return 'failed_no_write';
137
+			if($result !== false) {
138
+			    return 'success';
139
+			} else {
140
+			    return 'failed_no_write';
141
+			}
142
+		} else {
143
+		    return 'failed_no_retrieve';
127 144
 		}
128
-		else                      return 'failed_no_retrieve';
129 145
 	}
130 146
 
131 147
     public function getFileName($docid, $alias='', $prefix, $suffix)
132
-	{
148
+    {
133 149
 		global $modx;
134 150
 
135
-		if($alias==='') $filename = $prefix.$docid.$suffix;
136
-		else
137
-		{
138
-			if($modx->config['suffix_mode']==='1' && strpos($alias, '.')!==false)
139
-			{
151
+		if($alias==='') {
152
+		    $filename = $prefix.$docid.$suffix;
153
+		} else {
154
+			if($modx->config['suffix_mode']==='1' && strpos($alias, '.')!==false) {
140 155
 				$suffix = '';
141 156
 			}
142 157
 			$filename = $prefix.$alias.$suffix;
@@ -145,7 +160,7 @@  discard block
 block discarded – undo
145 160
 	}
146 161
 
147 162
     public function run($parent=0)
148
-	{
163
+    {
149 164
 		global $_lang;
150 165
 		global $modx;
151 166
 
@@ -187,24 +202,20 @@  discard block
 block discarded – undo
187 202
 		$ph = array();
188 203
 		$ph['total']     = $this->total;
189 204
 		$folder_permission = octdec($modx->config['new_folder_permissions']);
190
-		while($row = $modx->db->getRow($rs))
191
-		{
205
+		while($row = $modx->db->getRow($rs)) {
192 206
 			$this->count++;
193 207
             $filename = '';
194 208
 			$row['count']     = $this->count;
195 209
 			$row['url'] = $modx->makeUrl($row['id']);
196 210
 
197
-			if (!$row['wasNull'])
198
-			{ // needs writing a document
211
+			if (!$row['wasNull']) {
212
+// needs writing a document
199 213
 				$docname = $this->getFileName($row['id'], $row['alias'], $prefix, $suffix);
200 214
 				$filename = $dirpath.$docname;
201
-				if (!is_file($filename))
202
-				{
203
-					if($row['published']==='1')
204
-					{
215
+				if (!is_file($filename)) {
216
+					if($row['published']==='1') {
205 217
 						$status = $this->makeFile($row['id'], $filename);
206
-						switch($status)
207
-						{
218
+						switch($status) {
208 219
 							case 'failed_no_write'   :
209 220
                                                             $row['status'] = $msg_failed_no_write;
210 221
                                                             break;
@@ -214,34 +225,38 @@  discard block
 block discarded – undo
214 225
 							default:
215 226
                                                             $row['status'] = $msg_success;
216 227
 						}
228
+					} else {
229
+					    $row['status'] = $msg_failed_no_retrieve;
217 230
 					}
218
-					else $row['status'] = $msg_failed_no_retrieve;
231
+				} else {
232
+				    $row['status'] = $msg_success_skip_doc;
219 233
 				}
220
-				else     $row['status'] = $msg_success_skip_doc;
221 234
 				$this->output[] = $this->parsePlaceholder($_lang['export_site_exporting_document'], $row);
222
-			}
223
-			else
224
-			{
235
+			} else {
225 236
 				$row['status'] = $msg_success_skip_dir;
226 237
 				$this->output[] = $this->parsePlaceholder($_lang['export_site_exporting_document'], $row);
227 238
 			}
228
-			if ($row['isfolder']==='1' && ($modx->config['suffix_mode']!=='1' || strpos($row['alias'],'.')===false))
229
-			{ // needs making a folder
239
+			if ($row['isfolder']==='1' && ($modx->config['suffix_mode']!=='1' || strpos($row['alias'],'.')===false)) {
240
+// needs making a folder
230 241
 				$end_dir = ($row['alias']!=='') ? $row['alias'] : $row['id'];
231 242
 				$dir_path = $dirpath . $end_dir;
232
-				if(strpos($dir_path,MODX_BASE_PATH)===false) return FALSE;
233
-				if (!is_dir($dir_path))
234
-				{
235
-					if (is_file($dir_path)) @unlink($dir_path);
243
+				if(strpos($dir_path,MODX_BASE_PATH)===false) {
244
+				    return FALSE;
245
+				}
246
+				if (!is_dir($dir_path)) {
247
+					if (is_file($dir_path)) {
248
+					    @unlink($dir_path);
249
+					}
236 250
 					mkdir($dir_path);
237 251
 					@chmod($dir_path, $folder_permission);
238 252
 
239 253
 				}
240 254
 
241 255
 
242
-				if($modx->config['make_folders']==='1' && $row['published']==='1')
243
-				{
244
-					if( ! empty($filename) && is_file($filename)) rename($filename,$dir_path . '/index.html');
256
+				if($modx->config['make_folders']==='1' && $row['published']==='1') {
257
+					if( ! empty($filename) && is_file($filename)) {
258
+					    rename($filename,$dir_path . '/index.html');
259
+					}
245 260
 				}
246 261
 				$this->targetDir = $dir_path;
247 262
 				$this->run($row['id']);
@@ -252,7 +267,9 @@  discard block
 block discarded – undo
252 267
 
253 268
     public function curl_get_contents($url, $timeout = 30 )
254 269
     {
255
-    	if(!function_exists('curl_init')) return @file_get_contents($url);
270
+    	if(!function_exists('curl_init')) {
271
+    	    return @file_get_contents($url);
272
+    	}
256 273
 
257 274
         $ch = curl_init();
258 275
         curl_setopt($ch, CURLOPT_URL, $url);
@@ -269,8 +286,7 @@  discard block
 block discarded – undo
269 286
 
270 287
     public function parsePlaceholder($tpl,$ph=array())
271 288
     {
272
-    	foreach($ph as $k=>$v)
273
-    	{
289
+    	foreach($ph as $k=>$v) {
274 290
     		$k = "[+{$k}+]";
275 291
     		$tpl = str_replace($k,$v,$tpl);
276 292
     	}
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -229,7 +229,7 @@
 block discarded – undo
229 229
 			{ // needs making a folder
230 230
 				$end_dir = ($row['alias']!=='') ? $row['alias'] : $row['id'];
231 231
 				$dir_path = $dirpath . $end_dir;
232
-				if(strpos($dir_path,MODX_BASE_PATH)===false) return FALSE;
232
+				if(strpos($dir_path,MODX_BASE_PATH)===false) return false;
233 233
 				if (!is_dir($dir_path))
234 234
 				{
235 235
 					if (is_file($dir_path)) @unlink($dir_path);
Please login to merge, or discard this patch.
manager/includes/extenders/maketable.class.php 4 patches
Doc Comments   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 	/**
86 86
 	 * Sets the class attribute of the main HTML TABLE.
87 87
 	 *
88
-	 * @param $value A class for the main HTML TABLE.
88
+	 * @param string $value A class for the main HTML TABLE.
89 89
 	 */
90 90
     public function setTableClass($value) {
91 91
 		$this->tableClass= $value;
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
 	/**
131 131
 	 * Sets the class attribute of regular table rows.
132 132
 	 *
133
-	 * @param $value A class for regular table rows.
133
+	 * @param string $value A class for regular table rows.
134 134
 	 */
135 135
     public function setRowRegularClass($value) {
136 136
 		$this->rowRegularClass= $value;
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
 	/**
140 140
 	 * Sets the class attribute of alternate table rows.
141 141
 	 *
142
-	 * @param $value A class for alternate table rows.
142
+	 * @param string $value A class for alternate table rows.
143 143
 	 */
144 144
     public function setRowAlternateClass($value) {
145 145
 		$this->rowAlternateClass= $value;
@@ -215,6 +215,7 @@  discard block
 block discarded – undo
215 215
 	 *
216 216
 	 * @param $value An Array of column widths in the order of the keys in the
217 217
 	 * 			source table array.
218
+	 * @param string[] $widthArray
218 219
 	 */
219 220
     public function setColumnWidths($widthArray) {
220 221
 		$this->columnWidths= $widthArray;
@@ -242,7 +243,7 @@  discard block
 block discarded – undo
242 243
 	/**
243 244
 	 * Retrieves the width of a specific table column by index position.
244 245
 	 *
245
-	 * @param $columnPosition The index of the column to get the width for.
246
+	 * @param integer $columnPosition The index of the column to get the width for.
246 247
 	 */
247 248
     public function getColumnWidth($columnPosition) {
248 249
 		$currentWidth= '';
@@ -256,6 +257,7 @@  discard block
 block discarded – undo
256 257
 	 * Determines what class the current row should have applied.
257 258
 	 *
258 259
 	 * @param $value The position of the current row being rendered.
260
+	 * @param integer $position
259 261
 	 */
260 262
     public function determineRowClass($position) {
261 263
 		switch ($this->rowAlternatingScheme) {
Please login to merge, or discard this patch.
Indentation   +439 added lines, -439 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
  * @author Jason Coward <[email protected]> (MODX)
10 10
  */
11 11
 class MakeTable {
12
-	public $actionField;
12
+    public $actionField;
13 13
     public $cellAction;
14 14
     public $linkAction;
15 15
     public $tableWidth;
@@ -34,343 +34,343 @@  discard block
 block discarded – undo
34 34
     public $extra;
35 35
 
36 36
     public function __construct() {
37
-		$this->fieldHeaders= array();
38
-		$this->excludeFields= array();
39
-		$this->actionField= '';
40
-		$this->cellAction= '';
41
-		$this->linkAction= '';
42
-		$this->tableWidth= '';
43
-		$this->tableClass= '';
44
-		$this->rowHeaderClass= '';
45
-		$this->columnHeaderClass= '';
46
-		$this->rowRegularClass= '';
47
-		$this->rowAlternateClass= 'alt';
48
-		$this->formName= 'tableForm';
49
-		$this->formAction= '[~[*id*]~]';
50
-		$this->formElementName= '';
51
-		$this->formElementType= '';
52
-		$this->rowAlternatingScheme= 'EVEN';
53
-		$this->allOption= 0;
54
-		$this->selectedValues= array();
55
-		$this->extra= '';
56
-	}
57
-
58
-	/**
59
-	 * Sets the default link href for all cells in the table.
60
-	 *
61
-	 * @param $value A URL to execute when table cells are clicked.
62
-	 */
37
+        $this->fieldHeaders= array();
38
+        $this->excludeFields= array();
39
+        $this->actionField= '';
40
+        $this->cellAction= '';
41
+        $this->linkAction= '';
42
+        $this->tableWidth= '';
43
+        $this->tableClass= '';
44
+        $this->rowHeaderClass= '';
45
+        $this->columnHeaderClass= '';
46
+        $this->rowRegularClass= '';
47
+        $this->rowAlternateClass= 'alt';
48
+        $this->formName= 'tableForm';
49
+        $this->formAction= '[~[*id*]~]';
50
+        $this->formElementName= '';
51
+        $this->formElementType= '';
52
+        $this->rowAlternatingScheme= 'EVEN';
53
+        $this->allOption= 0;
54
+        $this->selectedValues= array();
55
+        $this->extra= '';
56
+    }
57
+
58
+    /**
59
+     * Sets the default link href for all cells in the table.
60
+     *
61
+     * @param $value A URL to execute when table cells are clicked.
62
+     */
63 63
     public function setCellAction($value) {
64
-		$this->cellAction= $this->prepareLink($value);
65
-	}
66
-
67
-	/**
68
-	 * Sets the default link href for the text presented in a cell.
69
-	 *
70
-	 * @param $value A URL to execute when text within table cells are clicked.
71
-	 */
64
+        $this->cellAction= $this->prepareLink($value);
65
+    }
66
+
67
+    /**
68
+     * Sets the default link href for the text presented in a cell.
69
+     *
70
+     * @param $value A URL to execute when text within table cells are clicked.
71
+     */
72 72
     public function setLinkAction($value) {
73
-		$this->linkAction= $this->prepareLink($value);
74
-	}
75
-
76
-	/**
77
-	 * Sets the width attribute of the main HTML TABLE.
78
-	 *
79
-	 * @param $value A valid width attribute for the HTML TABLE tag
80
-	 */
73
+        $this->linkAction= $this->prepareLink($value);
74
+    }
75
+
76
+    /**
77
+     * Sets the width attribute of the main HTML TABLE.
78
+     *
79
+     * @param $value A valid width attribute for the HTML TABLE tag
80
+     */
81 81
     public function setTableWidth($value) {
82
-		$this->tableWidth= $value;
83
-	}
84
-
85
-	/**
86
-	 * Sets the class attribute of the main HTML TABLE.
87
-	 *
88
-	 * @param $value A class for the main HTML TABLE.
89
-	 */
82
+        $this->tableWidth= $value;
83
+    }
84
+
85
+    /**
86
+     * Sets the class attribute of the main HTML TABLE.
87
+     *
88
+     * @param $value A class for the main HTML TABLE.
89
+     */
90 90
     public function setTableClass($value) {
91
-		$this->tableClass= $value;
92
-	}
93
-
94
-	/**
95
-	 * Sets the id attribute of the main HTML TABLE.
96
-	 *
97
-	 * @param $value A class for the main HTML TABLE.
98
-	 */
91
+        $this->tableClass= $value;
92
+    }
93
+
94
+    /**
95
+     * Sets the id attribute of the main HTML TABLE.
96
+     *
97
+     * @param $value A class for the main HTML TABLE.
98
+     */
99 99
     public function setTableID($value) {
100
-		$this->tableID= $value;
101
-	}
102
-
103
-	/**
104
-	 * Sets the class attribute of the table header row.
105
-	 *
106
-	 * @param $value A class for the table header row.
107
-	 */
100
+        $this->tableID= $value;
101
+    }
102
+
103
+    /**
104
+     * Sets the class attribute of the table header row.
105
+     *
106
+     * @param $value A class for the table header row.
107
+     */
108 108
     public function setRowHeaderClass($value) {
109
-		$this->rowHeaderClass= $value;
110
-	}
111
-
112
-		/**
113
-	 * Sets the class attribute of the table header row.
114
-	 *
115
-	 * @param $value A class for the table header row.
116
-	 */
109
+        $this->rowHeaderClass= $value;
110
+    }
111
+
112
+        /**
113
+         * Sets the class attribute of the table header row.
114
+         *
115
+         * @param $value A class for the table header row.
116
+         */
117 117
     public function setThHeaderClass($value) {
118
-		$this->thClass= $value;
119
-	}
120
-
121
-	/**
122
-	 * Sets the class attribute of the column header row.
123
-	 *
124
-	 * @param $value A class for the column header row.
125
-	 */
118
+        $this->thClass= $value;
119
+    }
120
+
121
+    /**
122
+     * Sets the class attribute of the column header row.
123
+     *
124
+     * @param $value A class for the column header row.
125
+     */
126 126
     public function setColumnHeaderClass($value) {
127
-		$this->columnHeaderClass= $value;
128
-	}
129
-
130
-	/**
131
-	 * Sets the class attribute of regular table rows.
132
-	 *
133
-	 * @param $value A class for regular table rows.
134
-	 */
127
+        $this->columnHeaderClass= $value;
128
+    }
129
+
130
+    /**
131
+     * Sets the class attribute of regular table rows.
132
+     *
133
+     * @param $value A class for regular table rows.
134
+     */
135 135
     public function setRowRegularClass($value) {
136
-		$this->rowRegularClass= $value;
137
-	}
138
-
139
-	/**
140
-	 * Sets the class attribute of alternate table rows.
141
-	 *
142
-	 * @param $value A class for alternate table rows.
143
-	 */
136
+        $this->rowRegularClass= $value;
137
+    }
138
+
139
+    /**
140
+     * Sets the class attribute of alternate table rows.
141
+     *
142
+     * @param $value A class for alternate table rows.
143
+     */
144 144
     public function setRowAlternateClass($value) {
145
-		$this->rowAlternateClass= $value;
146
-	}
147
-
148
-	/**
149
-	 * Sets the type of INPUT form element to be presented as the first column.
150
-	 *
151
-	 * @param $value Indicates the INPUT form element type attribute.
152
-	 */
145
+        $this->rowAlternateClass= $value;
146
+    }
147
+
148
+    /**
149
+     * Sets the type of INPUT form element to be presented as the first column.
150
+     *
151
+     * @param $value Indicates the INPUT form element type attribute.
152
+     */
153 153
     public function setFormElementType($value) {
154
-		$this->formElementType= $value;
155
-	}
156
-
157
-	/**
158
-	 * Sets the name of the INPUT form element to be presented as the first column.
159
-	 *
160
-	 * @param $value Indicates the INPUT form element name attribute.
161
-	 */
154
+        $this->formElementType= $value;
155
+    }
156
+
157
+    /**
158
+     * Sets the name of the INPUT form element to be presented as the first column.
159
+     *
160
+     * @param $value Indicates the INPUT form element name attribute.
161
+     */
162 162
     public function setFormElementName($value) {
163
-		$this->formElementName= $value;
164
-	}
165
-
166
-	/**
167
-	 * Sets the name of the FORM to wrap the table in when a form element has
168
-	 * been indicated.
169
-	 *
170
-	 * @param $value Indicates the FORM name attribute.
171
-	 */
163
+        $this->formElementName= $value;
164
+    }
165
+
166
+    /**
167
+     * Sets the name of the FORM to wrap the table in when a form element has
168
+     * been indicated.
169
+     *
170
+     * @param $value Indicates the FORM name attribute.
171
+     */
172 172
     public function setFormName($value) {
173
-		$this->formName= $value;
174
-	}
175
-
176
-	/**
177
-	 * Sets the action of the FORM element.
178
-	 *
179
-	 * @param $value Indicates the FORM action attribute.
180
-	 */
173
+        $this->formName= $value;
174
+    }
175
+
176
+    /**
177
+     * Sets the action of the FORM element.
178
+     *
179
+     * @param $value Indicates the FORM action attribute.
180
+     */
181 181
     public function setFormAction($value) {
182
-		$this->formAction= $value;
183
-	}
184
-
185
-	/**
186
-	 * Excludes fields from the table by array key.
187
-	 *
188
-	 * @param $value An Array of field keys to exclude from the table.
189
-	 */
182
+        $this->formAction= $value;
183
+    }
184
+
185
+    /**
186
+     * Excludes fields from the table by array key.
187
+     *
188
+     * @param $value An Array of field keys to exclude from the table.
189
+     */
190 190
     public function setExcludeFields($value) {
191
-		$this->excludeFields= $value;
192
-	}
193
-
194
-	/**
195
-	 * Sets the table to provide alternate row colors using ODD or EVEN rows
196
-	 *
197
-	 * @param $value 'ODD' or 'EVEN' to indicate the alternate row scheme.
198
-	 */
191
+        $this->excludeFields= $value;
192
+    }
193
+
194
+    /**
195
+     * Sets the table to provide alternate row colors using ODD or EVEN rows
196
+     *
197
+     * @param $value 'ODD' or 'EVEN' to indicate the alternate row scheme.
198
+     */
199 199
     public function setRowAlternatingScheme($value) {
200
-		$this->rowAlternatingScheme= $value;
201
-	}
202
-
203
-	/**
204
-	 * Sets the default field value to be used when appending query parameters
205
-	 * to link actions.
206
-	 *
207
-	 * @param $value The key of the field to add as a query string parameter.
208
-	 */
200
+        $this->rowAlternatingScheme= $value;
201
+    }
202
+
203
+    /**
204
+     * Sets the default field value to be used when appending query parameters
205
+     * to link actions.
206
+     *
207
+     * @param $value The key of the field to add as a query string parameter.
208
+     */
209 209
     public function setActionFieldName($value) {
210
-		$this->actionField= $value;
211
-	}
212
-
213
-	/**
214
-	 * Sets the width attribute of each column in the array.
215
-	 *
216
-	 * @param $value An Array of column widths in the order of the keys in the
217
-	 * 			source table array.
218
-	 */
210
+        $this->actionField= $value;
211
+    }
212
+
213
+    /**
214
+     * Sets the width attribute of each column in the array.
215
+     *
216
+     * @param $value An Array of column widths in the order of the keys in the
217
+     * 			source table array.
218
+     */
219 219
     public function setColumnWidths($widthArray) {
220
-		$this->columnWidths= $widthArray;
221
-	}
222
-
223
-	/**
224
-	 * An optional array of values that can be preselected when using
225
-	 *
226
-	 * @param $value Indicates the INPUT form element type attribute.
227
-	 */
220
+        $this->columnWidths= $widthArray;
221
+    }
222
+
223
+    /**
224
+     * An optional array of values that can be preselected when using
225
+     *
226
+     * @param $value Indicates the INPUT form element type attribute.
227
+     */
228 228
     public function setSelectedValues($valueArray) {
229
-		$this->selectedValues= $valueArray;
230
-	}
231
-
232
-	/**
233
-	 * Sets extra content to be presented following the table (but within
234
-	 * the form, if a form is being rendered with the table).
235
-	 *
236
-	 * @param $value A string of additional content.
237
-	 */
229
+        $this->selectedValues= $valueArray;
230
+    }
231
+
232
+    /**
233
+     * Sets extra content to be presented following the table (but within
234
+     * the form, if a form is being rendered with the table).
235
+     *
236
+     * @param $value A string of additional content.
237
+     */
238 238
     public function setExtra($value) {
239
-		$this->extra= $value;
240
-	}
241
-
242
-	/**
243
-	 * Retrieves the width of a specific table column by index position.
244
-	 *
245
-	 * @param $columnPosition The index of the column to get the width for.
246
-	 */
239
+        $this->extra= $value;
240
+    }
241
+
242
+    /**
243
+     * Retrieves the width of a specific table column by index position.
244
+     *
245
+     * @param $columnPosition The index of the column to get the width for.
246
+     */
247 247
     public function getColumnWidth($columnPosition) {
248
-		$currentWidth= '';
249
-		if (is_array($this->columnWidths)) {
250
-			$currentWidth= $this->columnWidths[$columnPosition] ? ' width="'.$this->columnWidths[$columnPosition].'" ' : '';
251
-		}
252
-		return $currentWidth;
253
-	}
254
-
255
-	/**
256
-	 * Determines what class the current row should have applied.
257
-	 *
258
-	 * @param $value The position of the current row being rendered.
259
-	 */
248
+        $currentWidth= '';
249
+        if (is_array($this->columnWidths)) {
250
+            $currentWidth= $this->columnWidths[$columnPosition] ? ' width="'.$this->columnWidths[$columnPosition].'" ' : '';
251
+        }
252
+        return $currentWidth;
253
+    }
254
+
255
+    /**
256
+     * Determines what class the current row should have applied.
257
+     *
258
+     * @param $value The position of the current row being rendered.
259
+     */
260 260
     public function determineRowClass($position) {
261
-		switch ($this->rowAlternatingScheme) {
262
-			case 'ODD' :
263
-				$modRemainder= 1;
264
-				break;
265
-			case 'EVEN' :
266
-				$modRemainder= 0;
267
-				break;
268
-		}
269
-		if ($position % 2 == $modRemainder) {
270
-			$currentClass= $this->rowRegularClass;
271
-		} else {
272
-			$currentClass= $this->rowAlternateClass;
273
-		}
274
-		return ' class="'.$currentClass.'"';
275
-	}
276
-
277
-	/**
278
-	 * Generates an onclick action applied to the current cell, to execute
279
-	 * any specified cell actions.
280
-	 *
281
-	 * @param $value Indicates the INPUT form element type attribute.
282
-	 */
261
+        switch ($this->rowAlternatingScheme) {
262
+            case 'ODD' :
263
+                $modRemainder= 1;
264
+                break;
265
+            case 'EVEN' :
266
+                $modRemainder= 0;
267
+                break;
268
+        }
269
+        if ($position % 2 == $modRemainder) {
270
+            $currentClass= $this->rowRegularClass;
271
+        } else {
272
+            $currentClass= $this->rowAlternateClass;
273
+        }
274
+        return ' class="'.$currentClass.'"';
275
+    }
276
+
277
+    /**
278
+     * Generates an onclick action applied to the current cell, to execute
279
+     * any specified cell actions.
280
+     *
281
+     * @param $value Indicates the INPUT form element type attribute.
282
+     */
283 283
     public function getCellAction($currentActionFieldValue) {
284
-		if ($this->cellAction) {
285
-			$cellAction= ' onClick="javascript:window.location=\''.$this->cellAction.$this->actionField.'='.urlencode($currentActionFieldValue).'\'" ';
286
-		}
287
-		return $cellAction;
288
-	}
289
-
290
-	/**
291
-	 * Generates the cell content, including any specified action fields values.
292
-	 *
293
-	 * @param $currentActionFieldValue The value to be applied to the link action.
294
-	 * @param $value The value of the cell.
295
-	 */
284
+        if ($this->cellAction) {
285
+            $cellAction= ' onClick="javascript:window.location=\''.$this->cellAction.$this->actionField.'='.urlencode($currentActionFieldValue).'\'" ';
286
+        }
287
+        return $cellAction;
288
+    }
289
+
290
+    /**
291
+     * Generates the cell content, including any specified action fields values.
292
+     *
293
+     * @param $currentActionFieldValue The value to be applied to the link action.
294
+     * @param $value The value of the cell.
295
+     */
296 296
     public function createCellText($currentActionFieldValue, $value) {
297
-		$cell .= $value;
298
-		if ($this->linkAction) {
299
-			$cell= '<a href="'.$this->linkAction.$this->actionField.'='.urlencode($currentActionFieldValue).'">'.$cell.'</a>';
300
-		}
301
-		return $cell;
302
-	}
303
-
304
-	/**
305
-	 * Sets an option to generate a check all link when checkbox is indicated
306
-	 * as the table formElementType.
307
-	 */
297
+        $cell .= $value;
298
+        if ($this->linkAction) {
299
+            $cell= '<a href="'.$this->linkAction.$this->actionField.'='.urlencode($currentActionFieldValue).'">'.$cell.'</a>';
300
+        }
301
+        return $cell;
302
+    }
303
+
304
+    /**
305
+     * Sets an option to generate a check all link when checkbox is indicated
306
+     * as the table formElementType.
307
+     */
308 308
     public function setAllOption() {
309
-		$this->allOption= 1;
310
-	}
311
-
312
-	/**
313
-	 * Function to prepare a link generated in the table cell/link actions.
314
-	 *
315
-	 * @param $value Indicates the INPUT form element type attribute.
316
-	 */
309
+        $this->allOption= 1;
310
+    }
311
+
312
+    /**
313
+     * Function to prepare a link generated in the table cell/link actions.
314
+     *
315
+     * @param $value Indicates the INPUT form element type attribute.
316
+     */
317 317
     public function prepareLink($link) {
318
-		if (strstr($link, '?')) {
319
-			$end= '&';
320
-		} else {
321
-			$end= '?';
322
-		}
323
-		return $link.$end;
324
-	}
325
-
326
-	/**
327
-	 * Generates the table content.
328
-	 *
329
-	 * @param $fieldsArray The associative array representing the table rows
330
-	 * and columns.
331
-	 * @param $fieldHeadersArray An optional array of values for providing
332
-	 * alternative field headers; this is an associative arrays of keys from
333
-	 * the $fieldsArray where the values represent the alt heading content
334
-	 * for each column.
335
-	 */
318
+        if (strstr($link, '?')) {
319
+            $end= '&';
320
+        } else {
321
+            $end= '?';
322
+        }
323
+        return $link.$end;
324
+    }
325
+
326
+    /**
327
+     * Generates the table content.
328
+     *
329
+     * @param $fieldsArray The associative array representing the table rows
330
+     * and columns.
331
+     * @param $fieldHeadersArray An optional array of values for providing
332
+     * alternative field headers; this is an associative arrays of keys from
333
+     * the $fieldsArray where the values represent the alt heading content
334
+     * for each column.
335
+     */
336 336
     public function create($fieldsArray, $fieldHeadersArray=array(),$linkpage="") {
337
-	    global $_lang;
338
-		if (is_array($fieldsArray)) {
339
-			$i= 0;
340
-			foreach ($fieldsArray as $fieldName => $fieldValue) {
341
-				$table .= "\t<tr".$this->determineRowClass($i).">\n";
342
-				$currentActionFieldValue= $fieldValue[$this->actionField];
343
-				if (is_array($this->selectedValues)) {
344
-					$isChecked= array_search($currentActionFieldValue, $this->selectedValues)===false? 0 : 1;
345
-				} else {
346
-					$isChecked= false;
347
-				}
348
-				$table .= $this->addFormField($currentActionFieldValue, $isChecked);
349
-				$colPosition= 0;
350
-				foreach ($fieldValue as $key => $value) {
351
-					if (!in_array($key, $this->excludeFields)) {
352
-						$table .= "\t\t<td".$this->getCellAction($currentActionFieldValue).">";
353
-						$table .= $this->createCellText($currentActionFieldValue, $value);
354
-						$table .= "</td>\n";
355
-						if ($i == 0) {
356
-							if (empty ($header) && $this->formElementType) {
357
-								$header .= "\t\t<th style=\"width:32px\" ".($this->thClass ? 'class="'.$this->thClass.'"' : '').">". ($this->allOption ? '<a href="javascript:clickAll()">all</a>' : '')."</th>\n";
358
-							}
359
-							$headerText= array_key_exists($key, $fieldHeadersArray)? $fieldHeadersArray[$key]: $key;
360
-							$header .= "\t\t<th".$this->getColumnWidth($colPosition).($this->thClass ? ' class="'.$this->thClass.'" ' : '').">".$headerText."</th>\n";
361
-						}
362
-						$colPosition ++;
363
-					}
364
-				}
365
-				$i ++;
366
-				$table .= "\t</tr>\n";
367
-			}
368
-			$table= "\n".'<table'. ($this->tableWidth ? ' width="'.$this->tableWidth.'"' : ''). ($this->tableClass ? ' class="'.$this->tableClass.'"' : ''). ($this->tableID ? ' id="'.$this->tableID.'"' : '').">\n". ($header ? "\t<thead>\n\t<tr class=\"".$this->rowHeaderClass."\">\n".$header."\t</tr>\n\t</thead>\n" : '').$table."</table>\n";
369
-			if ($this->formElementType) {
370
-				$table= "\n".'<form id="'.$this->formName.'" name="'.$this->formName.'" action="'.$this->formAction.'" method="POST">'.$table;
371
-			}
372
-			if (strlen($this->pageNav) > 1) {//changed to display the pagination if exists.
373
-				/* commented this part because of cookie
337
+        global $_lang;
338
+        if (is_array($fieldsArray)) {
339
+            $i= 0;
340
+            foreach ($fieldsArray as $fieldName => $fieldValue) {
341
+                $table .= "\t<tr".$this->determineRowClass($i).">\n";
342
+                $currentActionFieldValue= $fieldValue[$this->actionField];
343
+                if (is_array($this->selectedValues)) {
344
+                    $isChecked= array_search($currentActionFieldValue, $this->selectedValues)===false? 0 : 1;
345
+                } else {
346
+                    $isChecked= false;
347
+                }
348
+                $table .= $this->addFormField($currentActionFieldValue, $isChecked);
349
+                $colPosition= 0;
350
+                foreach ($fieldValue as $key => $value) {
351
+                    if (!in_array($key, $this->excludeFields)) {
352
+                        $table .= "\t\t<td".$this->getCellAction($currentActionFieldValue).">";
353
+                        $table .= $this->createCellText($currentActionFieldValue, $value);
354
+                        $table .= "</td>\n";
355
+                        if ($i == 0) {
356
+                            if (empty ($header) && $this->formElementType) {
357
+                                $header .= "\t\t<th style=\"width:32px\" ".($this->thClass ? 'class="'.$this->thClass.'"' : '').">". ($this->allOption ? '<a href="javascript:clickAll()">all</a>' : '')."</th>\n";
358
+                            }
359
+                            $headerText= array_key_exists($key, $fieldHeadersArray)? $fieldHeadersArray[$key]: $key;
360
+                            $header .= "\t\t<th".$this->getColumnWidth($colPosition).($this->thClass ? ' class="'.$this->thClass.'" ' : '').">".$headerText."</th>\n";
361
+                        }
362
+                        $colPosition ++;
363
+                    }
364
+                }
365
+                $i ++;
366
+                $table .= "\t</tr>\n";
367
+            }
368
+            $table= "\n".'<table'. ($this->tableWidth ? ' width="'.$this->tableWidth.'"' : ''). ($this->tableClass ? ' class="'.$this->tableClass.'"' : ''). ($this->tableID ? ' id="'.$this->tableID.'"' : '').">\n". ($header ? "\t<thead>\n\t<tr class=\"".$this->rowHeaderClass."\">\n".$header."\t</tr>\n\t</thead>\n" : '').$table."</table>\n";
369
+            if ($this->formElementType) {
370
+                $table= "\n".'<form id="'.$this->formName.'" name="'.$this->formName.'" action="'.$this->formAction.'" method="POST">'.$table;
371
+            }
372
+            if (strlen($this->pageNav) > 1) {//changed to display the pagination if exists.
373
+                /* commented this part because of cookie
374 374
 				$table .= '<div id="max-display-records" ><select style="display:inline" onchange="javascript:updatePageSize(this[this.selectedIndex].value);">';
375 375
 				$pageSizes= array (10, 25, 50, 100, 250);
376 376
 				for ($i= 0; $i < count($pageSizes); $i ++) {
@@ -381,12 +381,12 @@  discard block
 block discarded – undo
381 381
 
382 382
 				$table .= '</select>'.$_lang["pagination_table_perpage"].'</div>';
383 383
 				*/
384
-				$table .= '<div id="pagination" class="paginate">'.$_lang["pagination_table_gotopage"].'<ul>'.$this->pageNav.'</ul></div>';
385
-				//$table .= '<script language="javascript">function updatePageSize(size){window.location = \''.$this->prepareLink($linkpage).'pageSize=\'+size;}</script>';
384
+                $table .= '<div id="pagination" class="paginate">'.$_lang["pagination_table_gotopage"].'<ul>'.$this->pageNav.'</ul></div>';
385
+                //$table .= '<script language="javascript">function updatePageSize(size){window.location = \''.$this->prepareLink($linkpage).'pageSize=\'+size;}</script>';
386 386
 
387
-			}
388
-			if ($this->allOption) {
389
-				$table .= '
387
+            }
388
+            if ($this->allOption) {
389
+                $table .= '
390 390
 <script language="javascript">
391 391
 	toggled = 0;
392 392
 	function clickAll() {
@@ -399,134 +399,134 @@  discard block
 block discarded – undo
399 399
 		toggled = (toggled?0:1);
400 400
 	}
401 401
 </script>';
402
-			}
403
-			if ($this->formElementType) {
404
-				if ($this->extra) {
405
-					$table.= "\n".$this->extra."\n";
406
-				}
407
-				$table.= "\n".'</form>'."\n";
408
-			}
409
-			return $table;
410
-		}
411
-	}
412
-
413
-	/**
414
-	 * Generates optional paging navigation controls for the table.
415
-	 *
416
-	 * @param $numRecords The number of records to show per page.
417
-	 * @param $qs An optional query string to be appended to the paging links
418
-	 */
402
+            }
403
+            if ($this->formElementType) {
404
+                if ($this->extra) {
405
+                    $table.= "\n".$this->extra."\n";
406
+                }
407
+                $table.= "\n".'</form>'."\n";
408
+            }
409
+            return $table;
410
+        }
411
+    }
412
+
413
+    /**
414
+     * Generates optional paging navigation controls for the table.
415
+     *
416
+     * @param $numRecords The number of records to show per page.
417
+     * @param $qs An optional query string to be appended to the paging links
418
+     */
419 419
     public function createPagingNavigation($numRecords, $qs='') {
420
-		global $_lang;
421
-		$currentPage= (is_numeric($_GET['page']) ? $_GET['page'] : 1);
422
-		$numPages= ceil($numRecords / MAX_DISPLAY_RECORDS_NUM);
423
-		if ($numPages > 1) {
424
-			$currentURL= empty($qs)? '': '?'.$qs;
425
-			if ($currentPage > 6) {
426
-				$nav .= $this->createPageLink($currentURL, 1, $_lang["pagination_table_first"]);
427
-			}
428
-			if ($currentPage != 1) {
429
-				$nav .= $this->createPageLink($currentURL, $currentPage -1, '&lt;&lt;');
430
-			}
431
-			$offset= -4 + ($currentPage < 5 ? (5 - $currentPage) : 0);
432
-			$i= 1;
433
-			while ($i < 10 && ($currentPage + $offset <= $numPages)) {
434
-				if ($currentPage == $currentPage + $offset)
435
-					$nav .= $this->createPageLink($currentURL, $currentPage + $offset, $currentPage + $offset, true);
436
-				else
437
-					$nav .= $this->createPageLink($currentURL, $currentPage + $offset, $currentPage + $offset);
438
-				$i ++;
439
-				$offset ++;
440
-			}
441
-			if ($currentPage < $numPages) {
442
-				$nav .= $this->createPageLink($currentURL, $currentPage +1, '&gt;&gt;');
443
-			}
444
-			if ($currentPage != $numPages) {
445
-				$nav .= $this->createPageLink($currentURL, $numPages, $_lang["pagination_table_last"]);
446
-			}
447
-		}
448
-		$this->pageNav= ' '.$nav;
449
-	}
450
-
451
-	/**
452
-	 * Creates an individual page link for the paging navigation.
453
-	 *
454
-	 * @param $link The link for the page, defaulted to the current document.
455
-	 * @param $pageNum The page number of the link.
456
-	 * @param $displayText The text of the link.
457
-	 * @param $currentPage Indicates if the link is to the current page.
458
-	 * @param $qs And optional query string to be appended to the link.
459
-	 */
420
+        global $_lang;
421
+        $currentPage= (is_numeric($_GET['page']) ? $_GET['page'] : 1);
422
+        $numPages= ceil($numRecords / MAX_DISPLAY_RECORDS_NUM);
423
+        if ($numPages > 1) {
424
+            $currentURL= empty($qs)? '': '?'.$qs;
425
+            if ($currentPage > 6) {
426
+                $nav .= $this->createPageLink($currentURL, 1, $_lang["pagination_table_first"]);
427
+            }
428
+            if ($currentPage != 1) {
429
+                $nav .= $this->createPageLink($currentURL, $currentPage -1, '&lt;&lt;');
430
+            }
431
+            $offset= -4 + ($currentPage < 5 ? (5 - $currentPage) : 0);
432
+            $i= 1;
433
+            while ($i < 10 && ($currentPage + $offset <= $numPages)) {
434
+                if ($currentPage == $currentPage + $offset)
435
+                    $nav .= $this->createPageLink($currentURL, $currentPage + $offset, $currentPage + $offset, true);
436
+                else
437
+                    $nav .= $this->createPageLink($currentURL, $currentPage + $offset, $currentPage + $offset);
438
+                $i ++;
439
+                $offset ++;
440
+            }
441
+            if ($currentPage < $numPages) {
442
+                $nav .= $this->createPageLink($currentURL, $currentPage +1, '&gt;&gt;');
443
+            }
444
+            if ($currentPage != $numPages) {
445
+                $nav .= $this->createPageLink($currentURL, $numPages, $_lang["pagination_table_last"]);
446
+            }
447
+        }
448
+        $this->pageNav= ' '.$nav;
449
+    }
450
+
451
+    /**
452
+     * Creates an individual page link for the paging navigation.
453
+     *
454
+     * @param $link The link for the page, defaulted to the current document.
455
+     * @param $pageNum The page number of the link.
456
+     * @param $displayText The text of the link.
457
+     * @param $currentPage Indicates if the link is to the current page.
458
+     * @param $qs And optional query string to be appended to the link.
459
+     */
460 460
     public function createPageLink($link='', $pageNum, $displayText, $currentPage=false, $qs='') {
461
-		global $modx;
462
-		$orderBy= !empty($_GET['orderby'])? '&orderby=' . $_GET['orderby']: '';
463
-		$orderDir= !empty($_GET['orderdir'])? '&orderdir=' . $_GET['orderdir']: '';
464
-		if (!empty($qs)) $qs= "?$qs";
465
-		$link= empty($link)? $modx->makeUrl($modx->documentIdentifier, $modx->documentObject['alias'], $qs . "page=$pageNum$orderBy$orderDir"): $this->prepareLink($link) . "page=$pageNum";
466
-		$nav .= '<li'.($currentPage? ' class="currentPage"': '').'><a'.($currentPage? ' class="currentPage"': '').' href="'.$link.'">'.$displayText.'</a></li>'."\n";
467
-		return $nav;
468
-	}
469
-
470
-	/**
471
-	 * Adds an INPUT form element column to the table.
472
-	 *
473
-	 * @param $value The value attribute of the element.
474
-	 * @param $isChecked Indicates if the checked attribute should apply to the
475
-	 * element.
476
-	 */
461
+        global $modx;
462
+        $orderBy= !empty($_GET['orderby'])? '&orderby=' . $_GET['orderby']: '';
463
+        $orderDir= !empty($_GET['orderdir'])? '&orderdir=' . $_GET['orderdir']: '';
464
+        if (!empty($qs)) $qs= "?$qs";
465
+        $link= empty($link)? $modx->makeUrl($modx->documentIdentifier, $modx->documentObject['alias'], $qs . "page=$pageNum$orderBy$orderDir"): $this->prepareLink($link) . "page=$pageNum";
466
+        $nav .= '<li'.($currentPage? ' class="currentPage"': '').'><a'.($currentPage? ' class="currentPage"': '').' href="'.$link.'">'.$displayText.'</a></li>'."\n";
467
+        return $nav;
468
+    }
469
+
470
+    /**
471
+     * Adds an INPUT form element column to the table.
472
+     *
473
+     * @param $value The value attribute of the element.
474
+     * @param $isChecked Indicates if the checked attribute should apply to the
475
+     * element.
476
+     */
477 477
     public function addFormField($value, $isChecked) {
478
-		if ($this->formElementType) {
479
-			$checked= $isChecked? "checked ": "";
480
-			$field= "\t\t".'<td><input type="'.$this->formElementType.'" name="'. ($this->formElementName ? $this->formElementName : $value).'"  value="'.$value.'" '.$checked.'/></td>'."\n";
481
-		}
482
-		return $field;
483
-	}
484
-
485
-	/**
486
-	 * Generates the proper LIMIT clause for queries to retrieve paged results in
487
-	 * a MakeTable $fieldsArray.
488
-	 */
478
+        if ($this->formElementType) {
479
+            $checked= $isChecked? "checked ": "";
480
+            $field= "\t\t".'<td><input type="'.$this->formElementType.'" name="'. ($this->formElementName ? $this->formElementName : $value).'"  value="'.$value.'" '.$checked.'/></td>'."\n";
481
+        }
482
+        return $field;
483
+    }
484
+
485
+    /**
486
+     * Generates the proper LIMIT clause for queries to retrieve paged results in
487
+     * a MakeTable $fieldsArray.
488
+     */
489 489
     public function handlePaging() {
490
-		$offset= (is_numeric($_GET['page']) && $_GET['page'] > 0) ? $_GET['page'] - 1 : 0;
491
-		$limitClause= ' LIMIT '. ($offset * MAX_DISPLAY_RECORDS_NUM).', '.MAX_DISPLAY_RECORDS_NUM;
492
-		return $limitClause;
493
-	}
494
-
495
-	/**
496
-	 * Generates the SORT BY clause for queries used to retrieve a MakeTable
497
-	 * $fieldsArray
498
-	 *
499
-	 * @param $natural_order If true, the results are returned in natural order.
500
-	 */
490
+        $offset= (is_numeric($_GET['page']) && $_GET['page'] > 0) ? $_GET['page'] - 1 : 0;
491
+        $limitClause= ' LIMIT '. ($offset * MAX_DISPLAY_RECORDS_NUM).', '.MAX_DISPLAY_RECORDS_NUM;
492
+        return $limitClause;
493
+    }
494
+
495
+    /**
496
+     * Generates the SORT BY clause for queries used to retrieve a MakeTable
497
+     * $fieldsArray
498
+     *
499
+     * @param $natural_order If true, the results are returned in natural order.
500
+     */
501 501
     public function handleSorting($natural_order=false) {
502
-		$orderByClause= '';
503
-		if (!$natural_order) {
504
-			$orderby= !empty($_GET['orderby'])? $_GET['orderby']: "id";
505
-			$orderdir= !empty($_GET['orderdir'])? $_GET['orderdir']: "DESC";
506
-			$orderbyClause= !empty($orderby)? ' ORDER BY ' . $orderby . ' ' . $orderdir . ' ': "";
507
-		}
508
-		return $orderbyClause;
509
-	}
510
-
511
-	/**
512
-	 * Generates a link to order by a specific $fieldsArray key; use to generate
513
-	 * sort by links in the MakeTable $fieldHeadingsArray values.
514
-	 *
515
-	 * @param $key The $fieldsArray key for the column to sort by.
516
-	 * @param $text The text for the link (e.g. table column header).
517
-	 * @param $qs An optional query string to append to the order by link.
518
-	 */
502
+        $orderByClause= '';
503
+        if (!$natural_order) {
504
+            $orderby= !empty($_GET['orderby'])? $_GET['orderby']: "id";
505
+            $orderdir= !empty($_GET['orderdir'])? $_GET['orderdir']: "DESC";
506
+            $orderbyClause= !empty($orderby)? ' ORDER BY ' . $orderby . ' ' . $orderdir . ' ': "";
507
+        }
508
+        return $orderbyClause;
509
+    }
510
+
511
+    /**
512
+     * Generates a link to order by a specific $fieldsArray key; use to generate
513
+     * sort by links in the MakeTable $fieldHeadingsArray values.
514
+     *
515
+     * @param $key The $fieldsArray key for the column to sort by.
516
+     * @param $text The text for the link (e.g. table column header).
517
+     * @param $qs An optional query string to append to the order by link.
518
+     */
519 519
     public function prepareOrderByLink($key, $text, $qs='') {
520
-		global $modx;
521
-		if (!empty($_GET['orderdir'])) {
522
-			$orderDir= strtolower($_GET['orderdir'])=='desc'? '&orderdir=asc': '&orderdir=desc';
523
-		} else {
524
-			$orderDir= '&orderdir=asc';
525
-		}
526
-		if (!empty($qs)) {
527
-			if (!strrpos($qs, '&')==strlen($qs)-1) $qs.= '&';
528
-		}
529
-		return '<a href="[~'.$modx->documentIdentifier.'~]?'.$qs.'orderby='.$key.$orderDir.'">'.$text.'</a>';
530
-	}
520
+        global $modx;
521
+        if (!empty($_GET['orderdir'])) {
522
+            $orderDir= strtolower($_GET['orderdir'])=='desc'? '&orderdir=asc': '&orderdir=desc';
523
+        } else {
524
+            $orderDir= '&orderdir=asc';
525
+        }
526
+        if (!empty($qs)) {
527
+            if (!strrpos($qs, '&')==strlen($qs)-1) $qs.= '&';
528
+        }
529
+        return '<a href="[~'.$modx->documentIdentifier.'~]?'.$qs.'orderby='.$key.$orderDir.'">'.$text.'</a>';
530
+    }
531 531
 
532 532
 }
Please login to merge, or discard this patch.
Spacing   +124 added lines, -124 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  *
9 9
  * @author Jason Coward <[email protected]> (MODX)
10 10
  */
11
-class MakeTable {
11
+class MakeTable{
12 12
 	public $actionField;
13 13
     public $cellAction;
14 14
     public $linkAction;
@@ -33,26 +33,26 @@  discard block
 block discarded – undo
33 33
     public $fieldHeaders;
34 34
     public $extra;
35 35
 
36
-    public function __construct() {
37
-		$this->fieldHeaders= array();
38
-		$this->excludeFields= array();
39
-		$this->actionField= '';
40
-		$this->cellAction= '';
41
-		$this->linkAction= '';
42
-		$this->tableWidth= '';
43
-		$this->tableClass= '';
44
-		$this->rowHeaderClass= '';
45
-		$this->columnHeaderClass= '';
46
-		$this->rowRegularClass= '';
47
-		$this->rowAlternateClass= 'alt';
48
-		$this->formName= 'tableForm';
49
-		$this->formAction= '[~[*id*]~]';
50
-		$this->formElementName= '';
51
-		$this->formElementType= '';
52
-		$this->rowAlternatingScheme= 'EVEN';
53
-		$this->allOption= 0;
54
-		$this->selectedValues= array();
55
-		$this->extra= '';
36
+    public function __construct(){
37
+		$this->fieldHeaders = array();
38
+		$this->excludeFields = array();
39
+		$this->actionField = '';
40
+		$this->cellAction = '';
41
+		$this->linkAction = '';
42
+		$this->tableWidth = '';
43
+		$this->tableClass = '';
44
+		$this->rowHeaderClass = '';
45
+		$this->columnHeaderClass = '';
46
+		$this->rowRegularClass = '';
47
+		$this->rowAlternateClass = 'alt';
48
+		$this->formName = 'tableForm';
49
+		$this->formAction = '[~[*id*]~]';
50
+		$this->formElementName = '';
51
+		$this->formElementType = '';
52
+		$this->rowAlternatingScheme = 'EVEN';
53
+		$this->allOption = 0;
54
+		$this->selectedValues = array();
55
+		$this->extra = '';
56 56
 	}
57 57
 
58 58
 	/**
@@ -60,8 +60,8 @@  discard block
 block discarded – undo
60 60
 	 *
61 61
 	 * @param $value A URL to execute when table cells are clicked.
62 62
 	 */
63
-    public function setCellAction($value) {
64
-		$this->cellAction= $this->prepareLink($value);
63
+    public function setCellAction($value){
64
+		$this->cellAction = $this->prepareLink($value);
65 65
 	}
66 66
 
67 67
 	/**
@@ -69,8 +69,8 @@  discard block
 block discarded – undo
69 69
 	 *
70 70
 	 * @param $value A URL to execute when text within table cells are clicked.
71 71
 	 */
72
-    public function setLinkAction($value) {
73
-		$this->linkAction= $this->prepareLink($value);
72
+    public function setLinkAction($value){
73
+		$this->linkAction = $this->prepareLink($value);
74 74
 	}
75 75
 
76 76
 	/**
@@ -78,8 +78,8 @@  discard block
 block discarded – undo
78 78
 	 *
79 79
 	 * @param $value A valid width attribute for the HTML TABLE tag
80 80
 	 */
81
-    public function setTableWidth($value) {
82
-		$this->tableWidth= $value;
81
+    public function setTableWidth($value){
82
+		$this->tableWidth = $value;
83 83
 	}
84 84
 
85 85
 	/**
@@ -87,8 +87,8 @@  discard block
 block discarded – undo
87 87
 	 *
88 88
 	 * @param $value A class for the main HTML TABLE.
89 89
 	 */
90
-    public function setTableClass($value) {
91
-		$this->tableClass= $value;
90
+    public function setTableClass($value){
91
+		$this->tableClass = $value;
92 92
 	}
93 93
 
94 94
 	/**
@@ -96,8 +96,8 @@  discard block
 block discarded – undo
96 96
 	 *
97 97
 	 * @param $value A class for the main HTML TABLE.
98 98
 	 */
99
-    public function setTableID($value) {
100
-		$this->tableID= $value;
99
+    public function setTableID($value){
100
+		$this->tableID = $value;
101 101
 	}
102 102
 
103 103
 	/**
@@ -105,8 +105,8 @@  discard block
 block discarded – undo
105 105
 	 *
106 106
 	 * @param $value A class for the table header row.
107 107
 	 */
108
-    public function setRowHeaderClass($value) {
109
-		$this->rowHeaderClass= $value;
108
+    public function setRowHeaderClass($value){
109
+		$this->rowHeaderClass = $value;
110 110
 	}
111 111
 
112 112
 		/**
@@ -114,8 +114,8 @@  discard block
 block discarded – undo
114 114
 	 *
115 115
 	 * @param $value A class for the table header row.
116 116
 	 */
117
-    public function setThHeaderClass($value) {
118
-		$this->thClass= $value;
117
+    public function setThHeaderClass($value){
118
+		$this->thClass = $value;
119 119
 	}
120 120
 
121 121
 	/**
@@ -123,8 +123,8 @@  discard block
 block discarded – undo
123 123
 	 *
124 124
 	 * @param $value A class for the column header row.
125 125
 	 */
126
-    public function setColumnHeaderClass($value) {
127
-		$this->columnHeaderClass= $value;
126
+    public function setColumnHeaderClass($value){
127
+		$this->columnHeaderClass = $value;
128 128
 	}
129 129
 
130 130
 	/**
@@ -132,8 +132,8 @@  discard block
 block discarded – undo
132 132
 	 *
133 133
 	 * @param $value A class for regular table rows.
134 134
 	 */
135
-    public function setRowRegularClass($value) {
136
-		$this->rowRegularClass= $value;
135
+    public function setRowRegularClass($value){
136
+		$this->rowRegularClass = $value;
137 137
 	}
138 138
 
139 139
 	/**
@@ -141,8 +141,8 @@  discard block
 block discarded – undo
141 141
 	 *
142 142
 	 * @param $value A class for alternate table rows.
143 143
 	 */
144
-    public function setRowAlternateClass($value) {
145
-		$this->rowAlternateClass= $value;
144
+    public function setRowAlternateClass($value){
145
+		$this->rowAlternateClass = $value;
146 146
 	}
147 147
 
148 148
 	/**
@@ -150,8 +150,8 @@  discard block
 block discarded – undo
150 150
 	 *
151 151
 	 * @param $value Indicates the INPUT form element type attribute.
152 152
 	 */
153
-    public function setFormElementType($value) {
154
-		$this->formElementType= $value;
153
+    public function setFormElementType($value){
154
+		$this->formElementType = $value;
155 155
 	}
156 156
 
157 157
 	/**
@@ -159,8 +159,8 @@  discard block
 block discarded – undo
159 159
 	 *
160 160
 	 * @param $value Indicates the INPUT form element name attribute.
161 161
 	 */
162
-    public function setFormElementName($value) {
163
-		$this->formElementName= $value;
162
+    public function setFormElementName($value){
163
+		$this->formElementName = $value;
164 164
 	}
165 165
 
166 166
 	/**
@@ -169,8 +169,8 @@  discard block
 block discarded – undo
169 169
 	 *
170 170
 	 * @param $value Indicates the FORM name attribute.
171 171
 	 */
172
-    public function setFormName($value) {
173
-		$this->formName= $value;
172
+    public function setFormName($value){
173
+		$this->formName = $value;
174 174
 	}
175 175
 
176 176
 	/**
@@ -178,8 +178,8 @@  discard block
 block discarded – undo
178 178
 	 *
179 179
 	 * @param $value Indicates the FORM action attribute.
180 180
 	 */
181
-    public function setFormAction($value) {
182
-		$this->formAction= $value;
181
+    public function setFormAction($value){
182
+		$this->formAction = $value;
183 183
 	}
184 184
 
185 185
 	/**
@@ -187,8 +187,8 @@  discard block
 block discarded – undo
187 187
 	 *
188 188
 	 * @param $value An Array of field keys to exclude from the table.
189 189
 	 */
190
-    public function setExcludeFields($value) {
191
-		$this->excludeFields= $value;
190
+    public function setExcludeFields($value){
191
+		$this->excludeFields = $value;
192 192
 	}
193 193
 
194 194
 	/**
@@ -196,8 +196,8 @@  discard block
 block discarded – undo
196 196
 	 *
197 197
 	 * @param $value 'ODD' or 'EVEN' to indicate the alternate row scheme.
198 198
 	 */
199
-    public function setRowAlternatingScheme($value) {
200
-		$this->rowAlternatingScheme= $value;
199
+    public function setRowAlternatingScheme($value){
200
+		$this->rowAlternatingScheme = $value;
201 201
 	}
202 202
 
203 203
 	/**
@@ -206,8 +206,8 @@  discard block
 block discarded – undo
206 206
 	 *
207 207
 	 * @param $value The key of the field to add as a query string parameter.
208 208
 	 */
209
-    public function setActionFieldName($value) {
210
-		$this->actionField= $value;
209
+    public function setActionFieldName($value){
210
+		$this->actionField = $value;
211 211
 	}
212 212
 
213 213
 	/**
@@ -216,8 +216,8 @@  discard block
 block discarded – undo
216 216
 	 * @param $value An Array of column widths in the order of the keys in the
217 217
 	 * 			source table array.
218 218
 	 */
219
-    public function setColumnWidths($widthArray) {
220
-		$this->columnWidths= $widthArray;
219
+    public function setColumnWidths($widthArray){
220
+		$this->columnWidths = $widthArray;
221 221
 	}
222 222
 
223 223
 	/**
@@ -225,8 +225,8 @@  discard block
 block discarded – undo
225 225
 	 *
226 226
 	 * @param $value Indicates the INPUT form element type attribute.
227 227
 	 */
228
-    public function setSelectedValues($valueArray) {
229
-		$this->selectedValues= $valueArray;
228
+    public function setSelectedValues($valueArray){
229
+		$this->selectedValues = $valueArray;
230 230
 	}
231 231
 
232 232
 	/**
@@ -235,8 +235,8 @@  discard block
 block discarded – undo
235 235
 	 *
236 236
 	 * @param $value A string of additional content.
237 237
 	 */
238
-    public function setExtra($value) {
239
-		$this->extra= $value;
238
+    public function setExtra($value){
239
+		$this->extra = $value;
240 240
 	}
241 241
 
242 242
 	/**
@@ -244,10 +244,10 @@  discard block
 block discarded – undo
244 244
 	 *
245 245
 	 * @param $columnPosition The index of the column to get the width for.
246 246
 	 */
247
-    public function getColumnWidth($columnPosition) {
248
-		$currentWidth= '';
247
+    public function getColumnWidth($columnPosition){
248
+		$currentWidth = '';
249 249
 		if (is_array($this->columnWidths)) {
250
-			$currentWidth= $this->columnWidths[$columnPosition] ? ' width="'.$this->columnWidths[$columnPosition].'" ' : '';
250
+			$currentWidth = $this->columnWidths[$columnPosition] ? ' width="'.$this->columnWidths[$columnPosition].'" ' : '';
251 251
 		}
252 252
 		return $currentWidth;
253 253
 	}
@@ -257,19 +257,19 @@  discard block
 block discarded – undo
257 257
 	 *
258 258
 	 * @param $value The position of the current row being rendered.
259 259
 	 */
260
-    public function determineRowClass($position) {
260
+    public function determineRowClass($position){
261 261
 		switch ($this->rowAlternatingScheme) {
262 262
 			case 'ODD' :
263
-				$modRemainder= 1;
263
+				$modRemainder = 1;
264 264
 				break;
265 265
 			case 'EVEN' :
266
-				$modRemainder= 0;
266
+				$modRemainder = 0;
267 267
 				break;
268 268
 		}
269 269
 		if ($position % 2 == $modRemainder) {
270
-			$currentClass= $this->rowRegularClass;
270
+			$currentClass = $this->rowRegularClass;
271 271
 		} else {
272
-			$currentClass= $this->rowAlternateClass;
272
+			$currentClass = $this->rowAlternateClass;
273 273
 		}
274 274
 		return ' class="'.$currentClass.'"';
275 275
 	}
@@ -280,9 +280,9 @@  discard block
 block discarded – undo
280 280
 	 *
281 281
 	 * @param $value Indicates the INPUT form element type attribute.
282 282
 	 */
283
-    public function getCellAction($currentActionFieldValue) {
283
+    public function getCellAction($currentActionFieldValue){
284 284
 		if ($this->cellAction) {
285
-			$cellAction= ' onClick="javascript:window.location=\''.$this->cellAction.$this->actionField.'='.urlencode($currentActionFieldValue).'\'" ';
285
+			$cellAction = ' onClick="javascript:window.location=\''.$this->cellAction.$this->actionField.'='.urlencode($currentActionFieldValue).'\'" ';
286 286
 		}
287 287
 		return $cellAction;
288 288
 	}
@@ -293,10 +293,10 @@  discard block
 block discarded – undo
293 293
 	 * @param $currentActionFieldValue The value to be applied to the link action.
294 294
 	 * @param $value The value of the cell.
295 295
 	 */
296
-    public function createCellText($currentActionFieldValue, $value) {
296
+    public function createCellText($currentActionFieldValue, $value){
297 297
 		$cell .= $value;
298 298
 		if ($this->linkAction) {
299
-			$cell= '<a href="'.$this->linkAction.$this->actionField.'='.urlencode($currentActionFieldValue).'">'.$cell.'</a>';
299
+			$cell = '<a href="'.$this->linkAction.$this->actionField.'='.urlencode($currentActionFieldValue).'">'.$cell.'</a>';
300 300
 		}
301 301
 		return $cell;
302 302
 	}
@@ -305,8 +305,8 @@  discard block
 block discarded – undo
305 305
 	 * Sets an option to generate a check all link when checkbox is indicated
306 306
 	 * as the table formElementType.
307 307
 	 */
308
-    public function setAllOption() {
309
-		$this->allOption= 1;
308
+    public function setAllOption(){
309
+		$this->allOption = 1;
310 310
 	}
311 311
 
312 312
 	/**
@@ -314,11 +314,11 @@  discard block
 block discarded – undo
314 314
 	 *
315 315
 	 * @param $value Indicates the INPUT form element type attribute.
316 316
 	 */
317
-    public function prepareLink($link) {
317
+    public function prepareLink($link){
318 318
 		if (strstr($link, '?')) {
319
-			$end= '&';
319
+			$end = '&';
320 320
 		} else {
321
-			$end= '?';
321
+			$end = '?';
322 322
 		}
323 323
 		return $link.$end;
324 324
 	}
@@ -333,20 +333,20 @@  discard block
 block discarded – undo
333 333
 	 * the $fieldsArray where the values represent the alt heading content
334 334
 	 * for each column.
335 335
 	 */
336
-    public function create($fieldsArray, $fieldHeadersArray=array(),$linkpage="") {
336
+    public function create($fieldsArray, $fieldHeadersArray = array(), $linkpage = ""){
337 337
 	    global $_lang;
338 338
 		if (is_array($fieldsArray)) {
339
-			$i= 0;
339
+			$i = 0;
340 340
 			foreach ($fieldsArray as $fieldName => $fieldValue) {
341 341
 				$table .= "\t<tr".$this->determineRowClass($i).">\n";
342
-				$currentActionFieldValue= $fieldValue[$this->actionField];
342
+				$currentActionFieldValue = $fieldValue[$this->actionField];
343 343
 				if (is_array($this->selectedValues)) {
344
-					$isChecked= array_search($currentActionFieldValue, $this->selectedValues)===false? 0 : 1;
344
+					$isChecked = array_search($currentActionFieldValue, $this->selectedValues) === false ? 0 : 1;
345 345
 				} else {
346
-					$isChecked= false;
346
+					$isChecked = false;
347 347
 				}
348 348
 				$table .= $this->addFormField($currentActionFieldValue, $isChecked);
349
-				$colPosition= 0;
349
+				$colPosition = 0;
350 350
 				foreach ($fieldValue as $key => $value) {
351 351
 					if (!in_array($key, $this->excludeFields)) {
352 352
 						$table .= "\t\t<td".$this->getCellAction($currentActionFieldValue).">";
@@ -354,20 +354,20 @@  discard block
 block discarded – undo
354 354
 						$table .= "</td>\n";
355 355
 						if ($i == 0) {
356 356
 							if (empty ($header) && $this->formElementType) {
357
-								$header .= "\t\t<th style=\"width:32px\" ".($this->thClass ? 'class="'.$this->thClass.'"' : '').">". ($this->allOption ? '<a href="javascript:clickAll()">all</a>' : '')."</th>\n";
357
+								$header .= "\t\t<th style=\"width:32px\" ".($this->thClass ? 'class="'.$this->thClass.'"' : '').">".($this->allOption ? '<a href="javascript:clickAll()">all</a>' : '')."</th>\n";
358 358
 							}
359
-							$headerText= array_key_exists($key, $fieldHeadersArray)? $fieldHeadersArray[$key]: $key;
359
+							$headerText = array_key_exists($key, $fieldHeadersArray) ? $fieldHeadersArray[$key] : $key;
360 360
 							$header .= "\t\t<th".$this->getColumnWidth($colPosition).($this->thClass ? ' class="'.$this->thClass.'" ' : '').">".$headerText."</th>\n";
361 361
 						}
362
-						$colPosition ++;
362
+						$colPosition++;
363 363
 					}
364 364
 				}
365
-				$i ++;
365
+				$i++;
366 366
 				$table .= "\t</tr>\n";
367 367
 			}
368
-			$table= "\n".'<table'. ($this->tableWidth ? ' width="'.$this->tableWidth.'"' : ''). ($this->tableClass ? ' class="'.$this->tableClass.'"' : ''). ($this->tableID ? ' id="'.$this->tableID.'"' : '').">\n". ($header ? "\t<thead>\n\t<tr class=\"".$this->rowHeaderClass."\">\n".$header."\t</tr>\n\t</thead>\n" : '').$table."</table>\n";
368
+			$table = "\n".'<table'.($this->tableWidth ? ' width="'.$this->tableWidth.'"' : '').($this->tableClass ? ' class="'.$this->tableClass.'"' : '').($this->tableID ? ' id="'.$this->tableID.'"' : '').">\n".($header ? "\t<thead>\n\t<tr class=\"".$this->rowHeaderClass."\">\n".$header."\t</tr>\n\t</thead>\n" : '').$table."</table>\n";
369 369
 			if ($this->formElementType) {
370
-				$table= "\n".'<form id="'.$this->formName.'" name="'.$this->formName.'" action="'.$this->formAction.'" method="POST">'.$table;
370
+				$table = "\n".'<form id="'.$this->formName.'" name="'.$this->formName.'" action="'.$this->formAction.'" method="POST">'.$table;
371 371
 			}
372 372
 			if (strlen($this->pageNav) > 1) {//changed to display the pagination if exists.
373 373
 				/* commented this part because of cookie
@@ -402,9 +402,9 @@  discard block
 block discarded – undo
402 402
 			}
403 403
 			if ($this->formElementType) {
404 404
 				if ($this->extra) {
405
-					$table.= "\n".$this->extra."\n";
405
+					$table .= "\n".$this->extra."\n";
406 406
 				}
407
-				$table.= "\n".'</form>'."\n";
407
+				$table .= "\n".'</form>'."\n";
408 408
 			}
409 409
 			return $table;
410 410
 		}
@@ -416,36 +416,36 @@  discard block
 block discarded – undo
416 416
 	 * @param $numRecords The number of records to show per page.
417 417
 	 * @param $qs An optional query string to be appended to the paging links
418 418
 	 */
419
-    public function createPagingNavigation($numRecords, $qs='') {
419
+    public function createPagingNavigation($numRecords, $qs = ''){
420 420
 		global $_lang;
421
-		$currentPage= (is_numeric($_GET['page']) ? $_GET['page'] : 1);
422
-		$numPages= ceil($numRecords / MAX_DISPLAY_RECORDS_NUM);
421
+		$currentPage = (is_numeric($_GET['page']) ? $_GET['page'] : 1);
422
+		$numPages = ceil($numRecords / MAX_DISPLAY_RECORDS_NUM);
423 423
 		if ($numPages > 1) {
424
-			$currentURL= empty($qs)? '': '?'.$qs;
424
+			$currentURL = empty($qs) ? '' : '?'.$qs;
425 425
 			if ($currentPage > 6) {
426 426
 				$nav .= $this->createPageLink($currentURL, 1, $_lang["pagination_table_first"]);
427 427
 			}
428 428
 			if ($currentPage != 1) {
429
-				$nav .= $this->createPageLink($currentURL, $currentPage -1, '&lt;&lt;');
429
+				$nav .= $this->createPageLink($currentURL, $currentPage - 1, '&lt;&lt;');
430 430
 			}
431
-			$offset= -4 + ($currentPage < 5 ? (5 - $currentPage) : 0);
432
-			$i= 1;
431
+			$offset = -4 + ($currentPage < 5 ? (5 - $currentPage) : 0);
432
+			$i = 1;
433 433
 			while ($i < 10 && ($currentPage + $offset <= $numPages)) {
434 434
 				if ($currentPage == $currentPage + $offset)
435 435
 					$nav .= $this->createPageLink($currentURL, $currentPage + $offset, $currentPage + $offset, true);
436 436
 				else
437 437
 					$nav .= $this->createPageLink($currentURL, $currentPage + $offset, $currentPage + $offset);
438
-				$i ++;
439
-				$offset ++;
438
+				$i++;
439
+				$offset++;
440 440
 			}
441 441
 			if ($currentPage < $numPages) {
442
-				$nav .= $this->createPageLink($currentURL, $currentPage +1, '&gt;&gt;');
442
+				$nav .= $this->createPageLink($currentURL, $currentPage + 1, '&gt;&gt;');
443 443
 			}
444 444
 			if ($currentPage != $numPages) {
445 445
 				$nav .= $this->createPageLink($currentURL, $numPages, $_lang["pagination_table_last"]);
446 446
 			}
447 447
 		}
448
-		$this->pageNav= ' '.$nav;
448
+		$this->pageNav = ' '.$nav;
449 449
 	}
450 450
 
451 451
 	/**
@@ -457,13 +457,13 @@  discard block
 block discarded – undo
457 457
 	 * @param $currentPage Indicates if the link is to the current page.
458 458
 	 * @param $qs And optional query string to be appended to the link.
459 459
 	 */
460
-    public function createPageLink($link='', $pageNum, $displayText, $currentPage=false, $qs='') {
460
+    public function createPageLink($link = '', $pageNum, $displayText, $currentPage = false, $qs = ''){
461 461
 		global $modx;
462
-		$orderBy= !empty($_GET['orderby'])? '&orderby=' . $_GET['orderby']: '';
463
-		$orderDir= !empty($_GET['orderdir'])? '&orderdir=' . $_GET['orderdir']: '';
464
-		if (!empty($qs)) $qs= "?$qs";
465
-		$link= empty($link)? $modx->makeUrl($modx->documentIdentifier, $modx->documentObject['alias'], $qs . "page=$pageNum$orderBy$orderDir"): $this->prepareLink($link) . "page=$pageNum";
466
-		$nav .= '<li'.($currentPage? ' class="currentPage"': '').'><a'.($currentPage? ' class="currentPage"': '').' href="'.$link.'">'.$displayText.'</a></li>'."\n";
462
+		$orderBy = !empty($_GET['orderby']) ? '&orderby='.$_GET['orderby'] : '';
463
+		$orderDir = !empty($_GET['orderdir']) ? '&orderdir='.$_GET['orderdir'] : '';
464
+		if (!empty($qs)) $qs = "?$qs";
465
+		$link = empty($link) ? $modx->makeUrl($modx->documentIdentifier, $modx->documentObject['alias'], $qs."page=$pageNum$orderBy$orderDir") : $this->prepareLink($link)."page=$pageNum";
466
+		$nav .= '<li'.($currentPage ? ' class="currentPage"' : '').'><a'.($currentPage ? ' class="currentPage"' : '').' href="'.$link.'">'.$displayText.'</a></li>'."\n";
467 467
 		return $nav;
468 468
 	}
469 469
 
@@ -474,10 +474,10 @@  discard block
 block discarded – undo
474 474
 	 * @param $isChecked Indicates if the checked attribute should apply to the
475 475
 	 * element.
476 476
 	 */
477
-    public function addFormField($value, $isChecked) {
477
+    public function addFormField($value, $isChecked){
478 478
 		if ($this->formElementType) {
479
-			$checked= $isChecked? "checked ": "";
480
-			$field= "\t\t".'<td><input type="'.$this->formElementType.'" name="'. ($this->formElementName ? $this->formElementName : $value).'"  value="'.$value.'" '.$checked.'/></td>'."\n";
479
+			$checked = $isChecked ? "checked " : "";
480
+			$field = "\t\t".'<td><input type="'.$this->formElementType.'" name="'.($this->formElementName ? $this->formElementName : $value).'"  value="'.$value.'" '.$checked.'/></td>'."\n";
481 481
 		}
482 482
 		return $field;
483 483
 	}
@@ -486,9 +486,9 @@  discard block
 block discarded – undo
486 486
 	 * Generates the proper LIMIT clause for queries to retrieve paged results in
487 487
 	 * a MakeTable $fieldsArray.
488 488
 	 */
489
-    public function handlePaging() {
490
-		$offset= (is_numeric($_GET['page']) && $_GET['page'] > 0) ? $_GET['page'] - 1 : 0;
491
-		$limitClause= ' LIMIT '. ($offset * MAX_DISPLAY_RECORDS_NUM).', '.MAX_DISPLAY_RECORDS_NUM;
489
+    public function handlePaging(){
490
+		$offset = (is_numeric($_GET['page']) && $_GET['page'] > 0) ? $_GET['page'] - 1 : 0;
491
+		$limitClause = ' LIMIT '.($offset * MAX_DISPLAY_RECORDS_NUM).', '.MAX_DISPLAY_RECORDS_NUM;
492 492
 		return $limitClause;
493 493
 	}
494 494
 
@@ -498,12 +498,12 @@  discard block
 block discarded – undo
498 498
 	 *
499 499
 	 * @param $natural_order If true, the results are returned in natural order.
500 500
 	 */
501
-    public function handleSorting($natural_order=false) {
502
-		$orderByClause= '';
501
+    public function handleSorting($natural_order = false){
502
+		$orderByClause = '';
503 503
 		if (!$natural_order) {
504
-			$orderby= !empty($_GET['orderby'])? $_GET['orderby']: "id";
505
-			$orderdir= !empty($_GET['orderdir'])? $_GET['orderdir']: "DESC";
506
-			$orderbyClause= !empty($orderby)? ' ORDER BY ' . $orderby . ' ' . $orderdir . ' ': "";
504
+			$orderby = !empty($_GET['orderby']) ? $_GET['orderby'] : "id";
505
+			$orderdir = !empty($_GET['orderdir']) ? $_GET['orderdir'] : "DESC";
506
+			$orderbyClause = !empty($orderby) ? ' ORDER BY '.$orderby.' '.$orderdir.' ' : "";
507 507
 		}
508 508
 		return $orderbyClause;
509 509
 	}
@@ -516,15 +516,15 @@  discard block
 block discarded – undo
516 516
 	 * @param $text The text for the link (e.g. table column header).
517 517
 	 * @param $qs An optional query string to append to the order by link.
518 518
 	 */
519
-    public function prepareOrderByLink($key, $text, $qs='') {
519
+    public function prepareOrderByLink($key, $text, $qs = ''){
520 520
 		global $modx;
521 521
 		if (!empty($_GET['orderdir'])) {
522
-			$orderDir= strtolower($_GET['orderdir'])=='desc'? '&orderdir=asc': '&orderdir=desc';
522
+			$orderDir = strtolower($_GET['orderdir']) == 'desc' ? '&orderdir=asc' : '&orderdir=desc';
523 523
 		} else {
524
-			$orderDir= '&orderdir=asc';
524
+			$orderDir = '&orderdir=asc';
525 525
 		}
526 526
 		if (!empty($qs)) {
527
-			if (!strrpos($qs, '&')==strlen($qs)-1) $qs.= '&';
527
+			if (!strrpos($qs, '&') == strlen($qs) - 1) $qs .= '&';
528 528
 		}
529 529
 		return '<a href="[~'.$modx->documentIdentifier.'~]?'.$qs.'orderby='.$key.$orderDir.'">'.$text.'</a>';
530 530
 	}
Please login to merge, or discard this patch.
Braces   +83 added lines, -42 removed lines patch added patch discarded remove patch
@@ -8,7 +8,8 @@  discard block
 block discarded – undo
8 8
  *
9 9
  * @author Jason Coward <[email protected]> (MODX)
10 10
  */
11
-class MakeTable {
11
+class MakeTable
12
+{
12 13
 	public $actionField;
13 14
     public $cellAction;
14 15
     public $linkAction;
@@ -33,7 +34,8 @@  discard block
 block discarded – undo
33 34
     public $fieldHeaders;
34 35
     public $extra;
35 36
 
36
-    public function __construct() {
37
+    public function __construct()
38
+    {
37 39
 		$this->fieldHeaders= array();
38 40
 		$this->excludeFields= array();
39 41
 		$this->actionField= '';
@@ -60,7 +62,8 @@  discard block
 block discarded – undo
60 62
 	 *
61 63
 	 * @param $value A URL to execute when table cells are clicked.
62 64
 	 */
63
-    public function setCellAction($value) {
65
+    public function setCellAction($value)
66
+    {
64 67
 		$this->cellAction= $this->prepareLink($value);
65 68
 	}
66 69
 
@@ -69,7 +72,8 @@  discard block
 block discarded – undo
69 72
 	 *
70 73
 	 * @param $value A URL to execute when text within table cells are clicked.
71 74
 	 */
72
-    public function setLinkAction($value) {
75
+    public function setLinkAction($value)
76
+    {
73 77
 		$this->linkAction= $this->prepareLink($value);
74 78
 	}
75 79
 
@@ -78,7 +82,8 @@  discard block
 block discarded – undo
78 82
 	 *
79 83
 	 * @param $value A valid width attribute for the HTML TABLE tag
80 84
 	 */
81
-    public function setTableWidth($value) {
85
+    public function setTableWidth($value)
86
+    {
82 87
 		$this->tableWidth= $value;
83 88
 	}
84 89
 
@@ -87,7 +92,8 @@  discard block
 block discarded – undo
87 92
 	 *
88 93
 	 * @param $value A class for the main HTML TABLE.
89 94
 	 */
90
-    public function setTableClass($value) {
95
+    public function setTableClass($value)
96
+    {
91 97
 		$this->tableClass= $value;
92 98
 	}
93 99
 
@@ -96,7 +102,8 @@  discard block
 block discarded – undo
96 102
 	 *
97 103
 	 * @param $value A class for the main HTML TABLE.
98 104
 	 */
99
-    public function setTableID($value) {
105
+    public function setTableID($value)
106
+    {
100 107
 		$this->tableID= $value;
101 108
 	}
102 109
 
@@ -105,7 +112,8 @@  discard block
 block discarded – undo
105 112
 	 *
106 113
 	 * @param $value A class for the table header row.
107 114
 	 */
108
-    public function setRowHeaderClass($value) {
115
+    public function setRowHeaderClass($value)
116
+    {
109 117
 		$this->rowHeaderClass= $value;
110 118
 	}
111 119
 
@@ -114,7 +122,8 @@  discard block
 block discarded – undo
114 122
 	 *
115 123
 	 * @param $value A class for the table header row.
116 124
 	 */
117
-    public function setThHeaderClass($value) {
125
+    public function setThHeaderClass($value)
126
+    {
118 127
 		$this->thClass= $value;
119 128
 	}
120 129
 
@@ -123,7 +132,8 @@  discard block
 block discarded – undo
123 132
 	 *
124 133
 	 * @param $value A class for the column header row.
125 134
 	 */
126
-    public function setColumnHeaderClass($value) {
135
+    public function setColumnHeaderClass($value)
136
+    {
127 137
 		$this->columnHeaderClass= $value;
128 138
 	}
129 139
 
@@ -132,7 +142,8 @@  discard block
 block discarded – undo
132 142
 	 *
133 143
 	 * @param $value A class for regular table rows.
134 144
 	 */
135
-    public function setRowRegularClass($value) {
145
+    public function setRowRegularClass($value)
146
+    {
136 147
 		$this->rowRegularClass= $value;
137 148
 	}
138 149
 
@@ -141,7 +152,8 @@  discard block
 block discarded – undo
141 152
 	 *
142 153
 	 * @param $value A class for alternate table rows.
143 154
 	 */
144
-    public function setRowAlternateClass($value) {
155
+    public function setRowAlternateClass($value)
156
+    {
145 157
 		$this->rowAlternateClass= $value;
146 158
 	}
147 159
 
@@ -150,7 +162,8 @@  discard block
 block discarded – undo
150 162
 	 *
151 163
 	 * @param $value Indicates the INPUT form element type attribute.
152 164
 	 */
153
-    public function setFormElementType($value) {
165
+    public function setFormElementType($value)
166
+    {
154 167
 		$this->formElementType= $value;
155 168
 	}
156 169
 
@@ -159,7 +172,8 @@  discard block
 block discarded – undo
159 172
 	 *
160 173
 	 * @param $value Indicates the INPUT form element name attribute.
161 174
 	 */
162
-    public function setFormElementName($value) {
175
+    public function setFormElementName($value)
176
+    {
163 177
 		$this->formElementName= $value;
164 178
 	}
165 179
 
@@ -169,7 +183,8 @@  discard block
 block discarded – undo
169 183
 	 *
170 184
 	 * @param $value Indicates the FORM name attribute.
171 185
 	 */
172
-    public function setFormName($value) {
186
+    public function setFormName($value)
187
+    {
173 188
 		$this->formName= $value;
174 189
 	}
175 190
 
@@ -178,7 +193,8 @@  discard block
 block discarded – undo
178 193
 	 *
179 194
 	 * @param $value Indicates the FORM action attribute.
180 195
 	 */
181
-    public function setFormAction($value) {
196
+    public function setFormAction($value)
197
+    {
182 198
 		$this->formAction= $value;
183 199
 	}
184 200
 
@@ -187,7 +203,8 @@  discard block
 block discarded – undo
187 203
 	 *
188 204
 	 * @param $value An Array of field keys to exclude from the table.
189 205
 	 */
190
-    public function setExcludeFields($value) {
206
+    public function setExcludeFields($value)
207
+    {
191 208
 		$this->excludeFields= $value;
192 209
 	}
193 210
 
@@ -196,7 +213,8 @@  discard block
 block discarded – undo
196 213
 	 *
197 214
 	 * @param $value 'ODD' or 'EVEN' to indicate the alternate row scheme.
198 215
 	 */
199
-    public function setRowAlternatingScheme($value) {
216
+    public function setRowAlternatingScheme($value)
217
+    {
200 218
 		$this->rowAlternatingScheme= $value;
201 219
 	}
202 220
 
@@ -206,7 +224,8 @@  discard block
 block discarded – undo
206 224
 	 *
207 225
 	 * @param $value The key of the field to add as a query string parameter.
208 226
 	 */
209
-    public function setActionFieldName($value) {
227
+    public function setActionFieldName($value)
228
+    {
210 229
 		$this->actionField= $value;
211 230
 	}
212 231
 
@@ -216,7 +235,8 @@  discard block
 block discarded – undo
216 235
 	 * @param $value An Array of column widths in the order of the keys in the
217 236
 	 * 			source table array.
218 237
 	 */
219
-    public function setColumnWidths($widthArray) {
238
+    public function setColumnWidths($widthArray)
239
+    {
220 240
 		$this->columnWidths= $widthArray;
221 241
 	}
222 242
 
@@ -225,7 +245,8 @@  discard block
 block discarded – undo
225 245
 	 *
226 246
 	 * @param $value Indicates the INPUT form element type attribute.
227 247
 	 */
228
-    public function setSelectedValues($valueArray) {
248
+    public function setSelectedValues($valueArray)
249
+    {
229 250
 		$this->selectedValues= $valueArray;
230 251
 	}
231 252
 
@@ -235,7 +256,8 @@  discard block
 block discarded – undo
235 256
 	 *
236 257
 	 * @param $value A string of additional content.
237 258
 	 */
238
-    public function setExtra($value) {
259
+    public function setExtra($value)
260
+    {
239 261
 		$this->extra= $value;
240 262
 	}
241 263
 
@@ -244,7 +266,8 @@  discard block
 block discarded – undo
244 266
 	 *
245 267
 	 * @param $columnPosition The index of the column to get the width for.
246 268
 	 */
247
-    public function getColumnWidth($columnPosition) {
269
+    public function getColumnWidth($columnPosition)
270
+    {
248 271
 		$currentWidth= '';
249 272
 		if (is_array($this->columnWidths)) {
250 273
 			$currentWidth= $this->columnWidths[$columnPosition] ? ' width="'.$this->columnWidths[$columnPosition].'" ' : '';
@@ -257,7 +280,8 @@  discard block
 block discarded – undo
257 280
 	 *
258 281
 	 * @param $value The position of the current row being rendered.
259 282
 	 */
260
-    public function determineRowClass($position) {
283
+    public function determineRowClass($position)
284
+    {
261 285
 		switch ($this->rowAlternatingScheme) {
262 286
 			case 'ODD' :
263 287
 				$modRemainder= 1;
@@ -280,7 +304,8 @@  discard block
 block discarded – undo
280 304
 	 *
281 305
 	 * @param $value Indicates the INPUT form element type attribute.
282 306
 	 */
283
-    public function getCellAction($currentActionFieldValue) {
307
+    public function getCellAction($currentActionFieldValue)
308
+    {
284 309
 		if ($this->cellAction) {
285 310
 			$cellAction= ' onClick="javascript:window.location=\''.$this->cellAction.$this->actionField.'='.urlencode($currentActionFieldValue).'\'" ';
286 311
 		}
@@ -293,7 +318,8 @@  discard block
 block discarded – undo
293 318
 	 * @param $currentActionFieldValue The value to be applied to the link action.
294 319
 	 * @param $value The value of the cell.
295 320
 	 */
296
-    public function createCellText($currentActionFieldValue, $value) {
321
+    public function createCellText($currentActionFieldValue, $value)
322
+    {
297 323
 		$cell .= $value;
298 324
 		if ($this->linkAction) {
299 325
 			$cell= '<a href="'.$this->linkAction.$this->actionField.'='.urlencode($currentActionFieldValue).'">'.$cell.'</a>';
@@ -305,7 +331,8 @@  discard block
 block discarded – undo
305 331
 	 * Sets an option to generate a check all link when checkbox is indicated
306 332
 	 * as the table formElementType.
307 333
 	 */
308
-    public function setAllOption() {
334
+    public function setAllOption()
335
+    {
309 336
 		$this->allOption= 1;
310 337
 	}
311 338
 
@@ -314,7 +341,8 @@  discard block
 block discarded – undo
314 341
 	 *
315 342
 	 * @param $value Indicates the INPUT form element type attribute.
316 343
 	 */
317
-    public function prepareLink($link) {
344
+    public function prepareLink($link)
345
+    {
318 346
 		if (strstr($link, '?')) {
319 347
 			$end= '&';
320 348
 		} else {
@@ -333,7 +361,8 @@  discard block
 block discarded – undo
333 361
 	 * the $fieldsArray where the values represent the alt heading content
334 362
 	 * for each column.
335 363
 	 */
336
-    public function create($fieldsArray, $fieldHeadersArray=array(),$linkpage="") {
364
+    public function create($fieldsArray, $fieldHeadersArray=array(),$linkpage="")
365
+    {
337 366
 	    global $_lang;
338 367
 		if (is_array($fieldsArray)) {
339 368
 			$i= 0;
@@ -369,7 +398,8 @@  discard block
 block discarded – undo
369 398
 			if ($this->formElementType) {
370 399
 				$table= "\n".'<form id="'.$this->formName.'" name="'.$this->formName.'" action="'.$this->formAction.'" method="POST">'.$table;
371 400
 			}
372
-			if (strlen($this->pageNav) > 1) {//changed to display the pagination if exists.
401
+			if (strlen($this->pageNav) > 1) {
402
+//changed to display the pagination if exists.
373 403
 				/* commented this part because of cookie
374 404
 				$table .= '<div id="max-display-records" ><select style="display:inline" onchange="javascript:updatePageSize(this[this.selectedIndex].value);">';
375 405
 				$pageSizes= array (10, 25, 50, 100, 250);
@@ -416,7 +446,8 @@  discard block
 block discarded – undo
416 446
 	 * @param $numRecords The number of records to show per page.
417 447
 	 * @param $qs An optional query string to be appended to the paging links
418 448
 	 */
419
-    public function createPagingNavigation($numRecords, $qs='') {
449
+    public function createPagingNavigation($numRecords, $qs='')
450
+    {
420 451
 		global $_lang;
421 452
 		$currentPage= (is_numeric($_GET['page']) ? $_GET['page'] : 1);
422 453
 		$numPages= ceil($numRecords / MAX_DISPLAY_RECORDS_NUM);
@@ -431,10 +462,11 @@  discard block
 block discarded – undo
431 462
 			$offset= -4 + ($currentPage < 5 ? (5 - $currentPage) : 0);
432 463
 			$i= 1;
433 464
 			while ($i < 10 && ($currentPage + $offset <= $numPages)) {
434
-				if ($currentPage == $currentPage + $offset)
435
-					$nav .= $this->createPageLink($currentURL, $currentPage + $offset, $currentPage + $offset, true);
436
-				else
437
-					$nav .= $this->createPageLink($currentURL, $currentPage + $offset, $currentPage + $offset);
465
+				if ($currentPage == $currentPage + $offset) {
466
+									$nav .= $this->createPageLink($currentURL, $currentPage + $offset, $currentPage + $offset, true);
467
+				} else {
468
+									$nav .= $this->createPageLink($currentURL, $currentPage + $offset, $currentPage + $offset);
469
+				}
438 470
 				$i ++;
439 471
 				$offset ++;
440 472
 			}
@@ -457,11 +489,14 @@  discard block
 block discarded – undo
457 489
 	 * @param $currentPage Indicates if the link is to the current page.
458 490
 	 * @param $qs And optional query string to be appended to the link.
459 491
 	 */
460
-    public function createPageLink($link='', $pageNum, $displayText, $currentPage=false, $qs='') {
492
+    public function createPageLink($link='', $pageNum, $displayText, $currentPage=false, $qs='')
493
+    {
461 494
 		global $modx;
462 495
 		$orderBy= !empty($_GET['orderby'])? '&orderby=' . $_GET['orderby']: '';
463 496
 		$orderDir= !empty($_GET['orderdir'])? '&orderdir=' . $_GET['orderdir']: '';
464
-		if (!empty($qs)) $qs= "?$qs";
497
+		if (!empty($qs)) {
498
+		    $qs= "?$qs";
499
+		}
465 500
 		$link= empty($link)? $modx->makeUrl($modx->documentIdentifier, $modx->documentObject['alias'], $qs . "page=$pageNum$orderBy$orderDir"): $this->prepareLink($link) . "page=$pageNum";
466 501
 		$nav .= '<li'.($currentPage? ' class="currentPage"': '').'><a'.($currentPage? ' class="currentPage"': '').' href="'.$link.'">'.$displayText.'</a></li>'."\n";
467 502
 		return $nav;
@@ -474,7 +509,8 @@  discard block
 block discarded – undo
474 509
 	 * @param $isChecked Indicates if the checked attribute should apply to the
475 510
 	 * element.
476 511
 	 */
477
-    public function addFormField($value, $isChecked) {
512
+    public function addFormField($value, $isChecked)
513
+    {
478 514
 		if ($this->formElementType) {
479 515
 			$checked= $isChecked? "checked ": "";
480 516
 			$field= "\t\t".'<td><input type="'.$this->formElementType.'" name="'. ($this->formElementName ? $this->formElementName : $value).'"  value="'.$value.'" '.$checked.'/></td>'."\n";
@@ -486,7 +522,8 @@  discard block
 block discarded – undo
486 522
 	 * Generates the proper LIMIT clause for queries to retrieve paged results in
487 523
 	 * a MakeTable $fieldsArray.
488 524
 	 */
489
-    public function handlePaging() {
525
+    public function handlePaging()
526
+    {
490 527
 		$offset= (is_numeric($_GET['page']) && $_GET['page'] > 0) ? $_GET['page'] - 1 : 0;
491 528
 		$limitClause= ' LIMIT '. ($offset * MAX_DISPLAY_RECORDS_NUM).', '.MAX_DISPLAY_RECORDS_NUM;
492 529
 		return $limitClause;
@@ -498,7 +535,8 @@  discard block
 block discarded – undo
498 535
 	 *
499 536
 	 * @param $natural_order If true, the results are returned in natural order.
500 537
 	 */
501
-    public function handleSorting($natural_order=false) {
538
+    public function handleSorting($natural_order=false)
539
+    {
502 540
 		$orderByClause= '';
503 541
 		if (!$natural_order) {
504 542
 			$orderby= !empty($_GET['orderby'])? $_GET['orderby']: "id";
@@ -516,7 +554,8 @@  discard block
 block discarded – undo
516 554
 	 * @param $text The text for the link (e.g. table column header).
517 555
 	 * @param $qs An optional query string to append to the order by link.
518 556
 	 */
519
-    public function prepareOrderByLink($key, $text, $qs='') {
557
+    public function prepareOrderByLink($key, $text, $qs='')
558
+    {
520 559
 		global $modx;
521 560
 		if (!empty($_GET['orderdir'])) {
522 561
 			$orderDir= strtolower($_GET['orderdir'])=='desc'? '&orderdir=asc': '&orderdir=desc';
@@ -524,7 +563,9 @@  discard block
 block discarded – undo
524 563
 			$orderDir= '&orderdir=asc';
525 564
 		}
526 565
 		if (!empty($qs)) {
527
-			if (!strrpos($qs, '&')==strlen($qs)-1) $qs.= '&';
566
+			if (!strrpos($qs, '&')==strlen($qs)-1) {
567
+			    $qs.= '&';
568
+			}
528 569
 		}
529 570
 		return '<a href="[~'.$modx->documentIdentifier.'~]?'.$qs.'orderby='.$key.$orderDir.'">'.$text.'</a>';
530 571
 	}
Please login to merge, or discard this patch.
manager/includes/menu.class.inc.php 2 patches
Doc Comments   +4 added lines patch added patch discarded remove patch
@@ -41,6 +41,10 @@
 block discarded – undo
41 41
         $this->menu = $new;
42 42
     }
43 43
 
44
+    /**
45
+     * @param string $parentid
46
+     * @param integer $level
47
+     */
44 48
     public function DrawSub($parentid, $level)
45 49
     {
46 50
         global $modx;
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -67,14 +67,14 @@  discard block
 block discarded – undo
67 67
                 $countChild++;
68 68
                 $id = $value[0];
69 69
                 $ph['id'] = $id;
70
-                $ph['li_class'] = $this->get_li_class($id) . $value[10];
70
+                $ph['li_class'] = $this->get_li_class($id).$value[10];
71 71
                 $ph['href'] = $value[3];
72 72
                 $ph['alt'] = $value[4];
73 73
                 $ph['target'] = $value[7];
74 74
                 $ph['onclick'] = $value[5];
75 75
                 $ph['a_class'] = $this->get_a_class($id);
76 76
                 $ph['LinkAttr'] = $this->getLinkAttr($id);
77
-                $ph['itemName'] = $value[2] . $this->getItemName($id);
77
+                $ph['itemName'] = $value[2].$this->getItemName($id);
78 78
 
79 79
                 $ph['DrawSub'] = '';
80 80
 
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
     public function get_li_class($id)
114 114
     {
115 115
         if (isset($this->menu[$id])) {
116
-            return $this->defaults['parentClass'] . ' ';
116
+            return $this->defaults['parentClass'].' ';
117 117
         } else {
118 118
             return '';
119 119
         }
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
     public function get_a_class($id)
123 123
     {
124 124
         if (isset($this->menu[$id])) {
125
-            return ' class="' . $this->defaults['parentLinkClass'] . '"';
125
+            return ' class="'.$this->defaults['parentLinkClass'].'"';
126 126
         } else {
127 127
             return '';
128 128
         }
Please login to merge, or discard this patch.
manager/frames/nodes.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  *  Build and return document tree view nodes
5 5
  *
6 6
  */
7
-if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) {
7
+if (!defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) {
8 8
     die('<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly.');
9 9
 }
10 10
 
@@ -18,11 +18,11 @@  discard block
 block discarded – undo
18 18
     exit('send some data');
19 19
 } //??
20 20
 
21
-$indent = (int)$_REQUEST['indent'];
22
-$parent = (int)$_REQUEST['parent'];
23
-$expandAll = (int)$_REQUEST['expandAll'];
21
+$indent = (int) $_REQUEST['indent'];
22
+$parent = (int) $_REQUEST['parent'];
23
+$expandAll = (int) $_REQUEST['expandAll'];
24 24
 $output = '';
25
-$theme = $manager_theme . "/";
25
+$theme = $manager_theme."/";
26 26
 $hereid = isset($_REQUEST['id']) && is_numeric($_REQUEST['id']) ? $_REQUEST['id'] : '';
27 27
 
28 28
 if (isset($_REQUEST['showonlyfolders'])) {
Please login to merge, or discard this patch.
manager/actions/logging.static.php 2 patches
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  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('logs')) {
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
                             $logs_user = record_sort(array_unique_multi($logs, 'internalKey'), 'username');
66 66
                             foreach ($logs_user as $row) {
67 67
                                 $selectedtext = $row['internalKey'] == $_REQUEST['searchuser'] ? ' selected="selected"' : '';
68
-                                echo "\t\t" . '<option value="' . $row['internalKey'] . '"' . $selectedtext . '>' . $row['username'] . "</option>\n";
68
+                                echo "\t\t".'<option value="'.$row['internalKey'].'"'.$selectedtext.'>'.$row['username']."</option>\n";
69 69
                             }
70 70
                             ?>
71 71
                         </select>
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
                                     continue;
87 87
                                 }
88 88
                                 $selectedtext = $row['action'] == $_REQUEST['action'] ? ' selected="selected"' : '';
89
-                                echo "\t\t" . '<option value="' . $row['action'] . '"' . $selectedtext . '>' . $row['action'] . ' - ' . $action . "</option>\n";
89
+                                echo "\t\t".'<option value="'.$row['action'].'"'.$selectedtext.'>'.$row['action'].' - '.$action."</option>\n";
90 90
                             }
91 91
                             ?>
92 92
                         </select>
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
                             $logs_items = record_sort(array_unique_multi($logs, 'itemid'), 'itemid');
103 103
                             foreach ($logs_items as $row) {
104 104
                                 $selectedtext = $row['itemid'] == $_REQUEST['itemid'] ? ' selected="selected"' : '';
105
-                                echo "\t\t" . '<option value="' . $row['itemid'] . '"' . $selectedtext . '>' . $row['itemid'] . "</option>\n";
105
+                                echo "\t\t".'<option value="'.$row['itemid'].'"'.$selectedtext.'>'.$row['itemid']."</option>\n";
106 106
                             }
107 107
                             ?>
108 108
                         </select>
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
                             $logs_names = record_sort(array_unique_multi($logs, 'itemname'), 'itemname');
119 119
                             foreach ($logs_names as $row) {
120 120
                                 $selectedtext = $row['itemname'] == $_REQUEST['itemname'] ? ' selected="selected"' : '';
121
-                                echo "\t\t" . '<option value="' . $row['itemname'] . '"' . $selectedtext . '>' . $row['itemname'] . "</option>\n";
121
+                                echo "\t\t".'<option value="'.$row['itemname'].'"'.$selectedtext.'>'.$row['itemname']."</option>\n";
122 122
                             }
123 123
                             ?>
124 124
                         </select>
@@ -176,26 +176,26 @@  discard block
 block discarded – undo
176 176
     // get the selections the user made.
177 177
     $sqladd = array();
178 178
     if ($_REQUEST['searchuser'] != 0) {
179
-        $sqladd[] = "internalKey='" . (int)$_REQUEST['searchuser'] . "'";
179
+        $sqladd[] = "internalKey='".(int) $_REQUEST['searchuser']."'";
180 180
     }
181 181
     if ($_REQUEST['action'] != 0) {
182
-        $sqladd[] = "action=" . (int)$_REQUEST['action'];
182
+        $sqladd[] = "action=".(int) $_REQUEST['action'];
183 183
     }
184 184
     if ($_REQUEST['itemid'] != 0 || $_REQUEST['itemid'] == "-") {
185
-        $sqladd[] = "itemid='" . $_REQUEST['itemid'] . "'";
185
+        $sqladd[] = "itemid='".$_REQUEST['itemid']."'";
186 186
     }
187 187
     if ($_REQUEST['itemname'] != '0') {
188
-        $sqladd[] = "itemname='" . $modx->db->escape($_REQUEST['itemname']) . "'";
188
+        $sqladd[] = "itemname='".$modx->db->escape($_REQUEST['itemname'])."'";
189 189
     }
190 190
     if ($_REQUEST['message'] != "") {
191
-        $sqladd[] = "message LIKE '%" . $modx->db->escape($_REQUEST['message']) . "%'";
191
+        $sqladd[] = "message LIKE '%".$modx->db->escape($_REQUEST['message'])."%'";
192 192
     }
193 193
     // date stuff
194 194
     if ($_REQUEST['datefrom'] != "") {
195
-        $sqladd[] = "timestamp>" . $modx->toTimeStamp($_REQUEST['datefrom']);
195
+        $sqladd[] = "timestamp>".$modx->toTimeStamp($_REQUEST['datefrom']);
196 196
     }
197 197
     if ($_REQUEST['dateto'] != "") {
198
-        $sqladd[] = "timestamp<" . $modx->toTimeStamp($_REQUEST['dateto']);
198
+        $sqladd[] = "timestamp<".$modx->toTimeStamp($_REQUEST['dateto']);
199 199
     }
200 200
 
201 201
     // If current position is not set, set it to zero
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
     // Number of result to display on the page, will be in the LIMIT of the sql query also
209 209
     $int_num_result = is_numeric($_REQUEST['nrresults']) ? $_REQUEST['nrresults'] : $number_of_logs;
210 210
 
211
-    $extargv = "&a=13&searchuser=" . $_REQUEST['searchuser'] . "&action=" . $_REQUEST['action'] . "&itemid=" . $_REQUEST['itemid'] . "&itemname=" . $_REQUEST['itemname'] . "&message=" . $_REQUEST['message'] . "&dateto=" . $_REQUEST['dateto'] . "&datefrom=" . $_REQUEST['datefrom'] . "&nrresults=" . $int_num_result . "&log_submit=" . $_REQUEST['log_submit']; // extra argv here (could be anything depending on your page)
211
+    $extargv = "&a=13&searchuser=".$_REQUEST['searchuser']."&action=".$_REQUEST['action']."&itemid=".$_REQUEST['itemid']."&itemname=".$_REQUEST['itemname']."&message=".$_REQUEST['message']."&dateto=".$_REQUEST['dateto']."&datefrom=".$_REQUEST['datefrom']."&nrresults=".$int_num_result."&log_submit=".$_REQUEST['log_submit']; // extra argv here (could be anything depending on your page)
212 212
 
213 213
     // build the sql
214 214
     $limit = $num_rows = $modx->db->getValue($modx->db->select('COUNT(*)', $modx->getFullTableName('manager_log'), (!empty($sqladd) ? implode(' AND ', $sqladd) : '')));
@@ -216,9 +216,9 @@  discard block
 block discarded – undo
216 216
     $rs = $modx->db->select('*', $modx->getFullTableName('manager_log'), (!empty($sqladd) ? implode(' AND ', $sqladd) : ''), 'timestamp DESC, id DESC', "{$int_cur_position}, {$int_num_result}");
217 217
 
218 218
 if ($limit < 1) {
219
-    echo '<p>' . $_lang["mgrlog_emptysrch"] . '</p>';
219
+    echo '<p>'.$_lang["mgrlog_emptysrch"].'</p>';
220 220
 } else {
221
-    echo '<p>' . $_lang["mgrlog_sortinst"] . '</p>';
221
+    echo '<p>'.$_lang["mgrlog_sortinst"].'</p>';
222 222
 
223 223
     include_once "paginate.inc.php";
224 224
     // New instance of the Paging class, you can modify the color and the width of the html table
@@ -230,11 +230,11 @@  discard block
 block discarded – undo
230 230
     $current_row = $int_cur_position / $int_num_result;
231 231
 
232 232
     // Display the result as you like...
233
-    print "<p>" . $_lang["paging_showing"] . " " . $array_paging['lower'];
234
-    print " " . $_lang["paging_to"] . " " . $array_paging['upper'];
235
-    print " (" . $array_paging['total'] . " " . $_lang["paging_total"] . ")<br />";
236
-    $paging = $array_paging['first_link'] . $_lang["paging_first"] . (isset($array_paging['first_link']) ? "</a> " : " ");
237
-    $paging .= $array_paging['previous_link'] . $_lang["paging_prev"] . (isset($array_paging['previous_link']) ? "</a> " : " ");
233
+    print "<p>".$_lang["paging_showing"]." ".$array_paging['lower'];
234
+    print " ".$_lang["paging_to"]." ".$array_paging['upper'];
235
+    print " (".$array_paging['total']." ".$_lang["paging_total"].")<br />";
236
+    $paging = $array_paging['first_link'].$_lang["paging_first"].(isset($array_paging['first_link']) ? "</a> " : " ");
237
+    $paging .= $array_paging['previous_link'].$_lang["paging_prev"].(isset($array_paging['previous_link']) ? "</a> " : " ");
238 238
     $pagesfound = sizeof($array_row_paging);
239 239
     if ($pagesfound > 6) {
240 240
         $paging .= $array_row_paging[$current_row - 2]; // ."&nbsp;";
@@ -244,11 +244,11 @@  discard block
 block discarded – undo
244 244
         $paging .= $array_row_paging[$current_row + 2]; // ."&nbsp;";
245 245
     } else {
246 246
         for ($i = 0; $i < $pagesfound; $i++) {
247
-            $paging .= $array_row_paging[$i] . "&nbsp;";
247
+            $paging .= $array_row_paging[$i]."&nbsp;";
248 248
         }
249 249
     }
250
-    $paging .= $array_paging['next_link'] . $_lang["paging_next"] . (isset($array_paging['next_link']) ? "</a> " : " ") . " ";
251
-    $paging .= $array_paging['last_link'] . $_lang["paging_last"] . (isset($array_paging['last_link']) ? "</a> " : " ") . " ";
250
+    $paging .= $array_paging['next_link'].$_lang["paging_next"].(isset($array_paging['next_link']) ? "</a> " : " ")." ";
251
+    $paging .= $array_paging['last_link'].$_lang["paging_last"].(isset($array_paging['last_link']) ? "</a> " : " ")." ";
252 252
     // The above exemple print somethings like:
253 253
     // Results 1 to 20 of 597  <<< 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 >>>
254 254
     // Of course you can now play with array_row_paging in order to print
@@ -282,16 +282,16 @@  discard block
 block discarded – undo
282 282
                     if (!preg_match("/^[0-9]+$/", $logentry['itemid'])) {
283 283
                         $item = '<div style="text-align:center;">-</div>';
284 284
                     } elseif ($logentry['action'] == 3 || $logentry['action'] == 27 || $logentry['action'] == 5) {
285
-                        $item = '<a href="index.php?a=3&amp;id=' . $logentry['itemid'] . '">' . $logentry['itemname'] . '</a>';
285
+                        $item = '<a href="index.php?a=3&amp;id='.$logentry['itemid'].'">'.$logentry['itemname'].'</a>';
286 286
                     } else {
287 287
                         $item = $logentry['itemname'];
288 288
                     }
289 289
                     //index.php?a=13&searchuser=' . $logentry['internalKey'] . '&action=' . $logentry['action'] . '&itemname=' . $logentry['itemname'] . '&log_submit=true'
290
-                    $user_drill = 'index.php?a=13&searchuser=' . $logentry['internalKey'] . '&itemname=0&log_submit=true';
290
+                    $user_drill = 'index.php?a=13&searchuser='.$logentry['internalKey'].'&itemname=0&log_submit=true';
291 291
                     ?>
292 292
                     <tr>
293
-                        <td><?= '<a href="' . $user_drill . '">' . $logentry['username'] . '</a>' ?></td>
294
-                        <td class="text-nowrap"><?= '[' . $logentry['action'] . '] ' . $logentry['message'] ?></td>
293
+                        <td><?= '<a href="'.$user_drill.'">'.$logentry['username'].'</a>' ?></td>
294
+                        <td class="text-nowrap"><?= '['.$logentry['action'].'] '.$logentry['message'] ?></td>
295 295
                         <td class="text-xs-right"><?= $logentry['itemid'] ?></td>
296 296
                         <td><?= $item ?></td>
297 297
                         <td class="text-nowrap"><?= $modx->toDateFormat($logentry['timestamp'] + $server_offset_time) ?></td>
Please login to merge, or discard this patch.
Braces   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -1,22 +1,22 @@  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('logs')) {
5
+if (!$modx->hasPermission('logs')) {
6 6
     $modx->webAlertAndQuit($_lang["error_no_privileges"]);
7 7
 }
8 8
 
9
-function array_unique_multi($array, $checkKey)
10
-{
9
+function array_unique_multi($array, $checkKey)
10
+{
11 11
     // Use the builtin if we're not a multi-dimensional array
12
-    if (!is_array(current($array)) || empty($checkKey)) {
12
+    if (!is_array(current($array)) || empty($checkKey)) {
13 13
         return array_unique($array);
14 14
     }
15 15
 
16 16
     $ret = array();
17 17
     $checkValues = array(); // contains the unique key Values
18
-    foreach ($array as $key => $current) {
19
-        if (in_array($current[$checkKey], $checkValues)) {
18
+    foreach ($array as $key => $current) {
19
+        if (in_array($current[$checkKey], $checkValues)) {
20 20
             continue;
21 21
         } // duplicate
22 22
 
@@ -26,17 +26,17 @@  discard block
 block discarded – undo
26 26
     return $ret;
27 27
 }
28 28
 
29
-function record_sort($array, $key)
30
-{
29
+function record_sort($array, $key)
30
+{
31 31
     $hash = array();
32
-    foreach ($array as $k => $v) {
32
+    foreach ($array as $k => $v) {
33 33
         $hash[$k] = $v[$key];
34 34
     }
35 35
 
36 36
     natsort($hash);
37 37
 
38 38
     $records = array();
39
-    foreach ($hash as $k => $row) {
39
+    foreach ($hash as $k => $row) {
40 40
         $records[$k] = $array[$k];
41 41
     }
42 42
 
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
                             <?php
64 64
                             // get all users currently in the log
65 65
                             $logs_user = record_sort(array_unique_multi($logs, 'internalKey'), 'username');
66
-                            foreach ($logs_user as $row) {
66
+                            foreach ($logs_user as $row) {
67 67
                                 $selectedtext = $row['internalKey'] == $_REQUEST['searchuser'] ? ' selected="selected"' : '';
68 68
                                 echo "\t\t" . '<option value="' . $row['internalKey'] . '"' . $selectedtext . '>' . $row['username'] . "</option>\n";
69 69
                             }
@@ -80,9 +80,9 @@  discard block
 block discarded – undo
80 80
                             // get all available actions in the log
81 81
                             include_once "actionlist.inc.php";
82 82
                             $logs_actions = record_sort(array_unique_multi($logs, 'action'), 'action');
83
-                            foreach ($logs_actions as $row) {
83
+                            foreach ($logs_actions as $row) {
84 84
                                 $action = getAction($row['action']);
85
-                                if ($action == 'Idle') {
85
+                                if ($action == 'Idle') {
86 86
                                     continue;
87 87
                                 }
88 88
                                 $selectedtext = $row['action'] == $_REQUEST['action'] ? ' selected="selected"' : '';
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
                             <?php
101 101
                             // get all itemid currently in logging
102 102
                             $logs_items = record_sort(array_unique_multi($logs, 'itemid'), 'itemid');
103
-                            foreach ($logs_items as $row) {
103
+                            foreach ($logs_items as $row) {
104 104
                                 $selectedtext = $row['itemid'] == $_REQUEST['itemid'] ? ' selected="selected"' : '';
105 105
                                 echo "\t\t" . '<option value="' . $row['itemid'] . '"' . $selectedtext . '>' . $row['itemid'] . "</option>\n";
106 106
                             }
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
                             <?php
117 117
                             // get all itemname currently in logging
118 118
                             $logs_names = record_sort(array_unique_multi($logs, 'itemname'), 'itemname');
119
-                            foreach ($logs_names as $row) {
119
+                            foreach ($logs_names as $row) {
120 120
                                 $selectedtext = $row['itemname'] == $_REQUEST['itemname'] ? ' selected="selected"' : '';
121 121
                                 echo "\t\t" . '<option value="' . $row['itemname'] . '"' . $selectedtext . '>' . $row['itemname'] . "</option>\n";
122 122
                             }
@@ -172,36 +172,36 @@  discard block
 block discarded – undo
172 172
     <div class="container container-body">
173 173
 
174 174
 <?php
175
-if (isset($_REQUEST['log_submit'])) {
175
+if (isset($_REQUEST['log_submit'])) {
176 176
     // get the selections the user made.
177 177
     $sqladd = array();
178
-    if ($_REQUEST['searchuser'] != 0) {
178
+    if ($_REQUEST['searchuser'] != 0) {
179 179
         $sqladd[] = "internalKey='" . (int)$_REQUEST['searchuser'] . "'";
180 180
     }
181
-    if ($_REQUEST['action'] != 0) {
181
+    if ($_REQUEST['action'] != 0) {
182 182
         $sqladd[] = "action=" . (int)$_REQUEST['action'];
183 183
     }
184
-    if ($_REQUEST['itemid'] != 0 || $_REQUEST['itemid'] == "-") {
184
+    if ($_REQUEST['itemid'] != 0 || $_REQUEST['itemid'] == "-") {
185 185
         $sqladd[] = "itemid='" . $_REQUEST['itemid'] . "'";
186 186
     }
187
-    if ($_REQUEST['itemname'] != '0') {
187
+    if ($_REQUEST['itemname'] != '0') {
188 188
         $sqladd[] = "itemname='" . $modx->db->escape($_REQUEST['itemname']) . "'";
189 189
     }
190
-    if ($_REQUEST['message'] != "") {
190
+    if ($_REQUEST['message'] != "") {
191 191
         $sqladd[] = "message LIKE '%" . $modx->db->escape($_REQUEST['message']) . "%'";
192 192
     }
193 193
     // date stuff
194
-    if ($_REQUEST['datefrom'] != "") {
194
+    if ($_REQUEST['datefrom'] != "") {
195 195
         $sqladd[] = "timestamp>" . $modx->toTimeStamp($_REQUEST['datefrom']);
196 196
     }
197
-    if ($_REQUEST['dateto'] != "") {
197
+    if ($_REQUEST['dateto'] != "") {
198 198
         $sqladd[] = "timestamp<" . $modx->toTimeStamp($_REQUEST['dateto']);
199 199
     }
200 200
 
201 201
     // If current position is not set, set it to zero
202
-    if (!isset($_REQUEST['int_cur_position']) || $_REQUEST['int_cur_position'] == 0) {
202
+    if (!isset($_REQUEST['int_cur_position']) || $_REQUEST['int_cur_position'] == 0) {
203 203
         $int_cur_position = 0;
204
-    } else {
204
+    } else {
205 205
         $int_cur_position = $_REQUEST['int_cur_position'];
206 206
     }
207 207
 
@@ -215,9 +215,9 @@  discard block
 block discarded – undo
215 215
 
216 216
     $rs = $modx->db->select('*', $modx->getFullTableName('manager_log'), (!empty($sqladd) ? implode(' AND ', $sqladd) : ''), 'timestamp DESC, id DESC', "{$int_cur_position}, {$int_num_result}");
217 217
 
218
-if ($limit < 1) {
218
+if ($limit < 1) {
219 219
     echo '<p>' . $_lang["mgrlog_emptysrch"] . '</p>';
220
-} else {
220
+} else {
221 221
     echo '<p>' . $_lang["mgrlog_sortinst"] . '</p>';
222 222
 
223 223
     include_once "paginate.inc.php";
@@ -236,14 +236,14 @@  discard block
 block discarded – undo
236 236
     $paging = $array_paging['first_link'] . $_lang["paging_first"] . (isset($array_paging['first_link']) ? "</a> " : " ");
237 237
     $paging .= $array_paging['previous_link'] . $_lang["paging_prev"] . (isset($array_paging['previous_link']) ? "</a> " : " ");
238 238
     $pagesfound = sizeof($array_row_paging);
239
-    if ($pagesfound > 6) {
239
+    if ($pagesfound > 6) {
240 240
         $paging .= $array_row_paging[$current_row - 2]; // ."&nbsp;";
241 241
         $paging .= $array_row_paging[$current_row - 1]; // ."&nbsp;";
242 242
         $paging .= $array_row_paging[$current_row]; // ."&nbsp;";
243 243
         $paging .= $array_row_paging[$current_row + 1]; // ."&nbsp;";
244 244
         $paging .= $array_row_paging[$current_row + 2]; // ."&nbsp;";
245
-    } else {
246
-        for ($i = 0; $i < $pagesfound; $i++) {
245
+    } else {
246
+        for ($i = 0; $i < $pagesfound; $i++) {
247 247
             $paging .= $array_row_paging[$i] . "&nbsp;";
248 248
         }
249 249
     }
@@ -278,12 +278,12 @@  discard block
 block discarded – undo
278 278
                 // grab the entire log file...
279 279
                 $logentries = array();
280 280
                 $i = 0;
281
-                while ($logentry = $modx->db->getRow($rs)) {
282
-                    if (!preg_match("/^[0-9]+$/", $logentry['itemid'])) {
281
+                while ($logentry = $modx->db->getRow($rs)) {
282
+                    if (!preg_match("/^[0-9]+$/", $logentry['itemid'])) {
283 283
                         $item = '<div style="text-align:center;">-</div>';
284
-                    } elseif ($logentry['action'] == 3 || $logentry['action'] == 27 || $logentry['action'] == 5) {
284
+                    } elseif ($logentry['action'] == 3 || $logentry['action'] == 27 || $logentry['action'] == 5) {
285 285
                         $item = '<a href="index.php?a=3&amp;id=' . $logentry['itemid'] . '">' . $logentry['itemname'] . '</a>';
286
-                    } else {
286
+                    } else {
287 287
                         $item = $logentry['itemname'];
288 288
                     }
289 289
                     //index.php?a=13&searchuser=' . $logentry['internalKey'] . '&action=' . $logentry['action'] . '&itemname=' . $logentry['itemname'] . '&log_submit=true'
@@ -318,6 +318,6 @@  discard block
 block discarded – undo
318 318
     // @see index.php @ 915
319 319
     global $action;
320 320
     $action = 1;
321
-} else {
321
+} else {
322 322
     echo $_lang["mgrlog_noquery"];
323 323
 }
Please login to merge, or discard this patch.
manager/actions/mutate_htmlsnippet.dynamic.php 2 patches
Switch Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -4,18 +4,18 @@
 block discarded – undo
4 4
 }
5 5
 
6 6
 switch ($modx->manager->action) {
7
-    case 78:
8
-        if (!$modx->hasPermission('edit_chunk')) {
9
-            $modx->webAlertAndQuit($_lang["error_no_privileges"]);
10
-        }
11
-        break;
12
-    case 77:
13
-        if (!$modx->hasPermission('new_chunk')) {
7
+        case 78:
8
+            if (!$modx->hasPermission('edit_chunk')) {
9
+                $modx->webAlertAndQuit($_lang["error_no_privileges"]);
10
+            }
11
+            break;
12
+        case 77:
13
+            if (!$modx->hasPermission('new_chunk')) {
14
+                $modx->webAlertAndQuit($_lang["error_no_privileges"]);
15
+            }
16
+            break;
17
+        default:
14 18
             $modx->webAlertAndQuit($_lang["error_no_privileges"]);
15
-        }
16
-        break;
17
-    default:
18
-        $modx->webAlertAndQuit($_lang["error_no_privileges"]);
19 19
 }
20 20
 
21 21
 $id = isset($_REQUEST['id']) ? (int)$_REQUEST['id'] : 0;
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  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
 
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
         $modx->webAlertAndQuit($_lang["error_no_privileges"]);
19 19
 }
20 20
 
21
-$id = isset($_REQUEST['id']) ? (int)$_REQUEST['id'] : 0;
21
+$id = isset($_REQUEST['id']) ? (int) $_REQUEST['id'] : 0;
22 22
 
23 23
 // Get table names (alphabetical)
24 24
 $tbl_site_htmlsnippets = $modx->getFullTableName('site_htmlsnippets');
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
     $content['name'] = $_REQUEST['itemname'];
48 48
 } else {
49 49
     $_SESSION['itemname'] = $_lang["new_htmlsnippet"];
50
-    $content['category'] = (int)$_REQUEST['catid'];
50
+    $content['category'] = (int) $_REQUEST['catid'];
51 51
 }
52 52
 
53 53
 if ($modx->manager->hasFormValues()) {
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
 // Add lock-element JS-Script
66 66
 $lockElementId = $id;
67 67
 $lockElementType = 3;
68
-require_once(MODX_MANAGER_PATH . 'includes/active_user_locks.inc.php');
68
+require_once(MODX_MANAGER_PATH.'includes/active_user_locks.inc.php');
69 69
 
70 70
 // Print RTE Javascript function
71 71
 ?>
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
         <input type="hidden" name="mode" value="<?= $modx->manager->action ?>" />
137 137
 
138 138
         <h1>
139
-            <i class="fa fa-th-large"></i><?= ($content['name'] ? $content['name'] . '<small>(' . $content['id'] . ')</small>' : $_lang['new_htmlsnippet']) ?><i class="fa fa-question-circle help"></i>
139
+            <i class="fa fa-th-large"></i><?= ($content['name'] ? $content['name'].'<small>('.$content['id'].')</small>' : $_lang['new_htmlsnippet']) ?><i class="fa fa-question-circle help"></i>
140 140
         </h1>
141 141
 
142 142
         <?= $_style['actionbuttons']['dynamic']['element'] ?>
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
                             <div class="form-control-name clearfix">
161 161
                                 <input name="name" type="text" maxlength="100" value="<?= $modx->htmlspecialchars($content['name']) ?>" class="form-control form-control-lg" onchange="documentDirty=true;" />
162 162
                                 <?php if ($modx->hasPermission('save_role')): ?>
163
-                                    <label class="custom-control" title="<?= $_lang['lock_htmlsnippet'] . "\n" . $_lang['lock_htmlsnippet_msg'] ?>" tooltip>
163
+                                    <label class="custom-control" title="<?= $_lang['lock_htmlsnippet']."\n".$_lang['lock_htmlsnippet_msg'] ?>" tooltip>
164 164
                                         <input name="locked" type="checkbox" value="on"<?= ($content['locked'] == 1 || $content['locked'] == 'on' ? ' checked="checked"' : '') ?> />
165 165
                                         <i class="fa fa-lock"></i>
166 166
                                     </label>
@@ -184,9 +184,9 @@  discard block
 block discarded – undo
184 184
                             <select name="categoryid" class="form-control" onchange="documentDirty=true;">
185 185
                                 <option>&nbsp;</option>
186 186
                                 <?php
187
-                                include_once(MODX_MANAGER_PATH . 'includes/categories.inc.php');
187
+                                include_once(MODX_MANAGER_PATH.'includes/categories.inc.php');
188 188
                                 foreach (getCategories() as $n => $v) {
189
-                                    echo "\t\t\t\t" . '<option value="' . $v['id'] . '"' . ($content['category'] == $v['id'] || (empty($content['category']) && $_POST['categoryid'] == $v['id']) ? ' selected="selected"' : '') . '>' . $modx->htmlspecialchars($v['category']) . "</option>\n";
189
+                                    echo "\t\t\t\t".'<option value="'.$v['id'].'"'.($content['category'] == $v['id'] || (empty($content['category']) && $_POST['categoryid'] == $v['id']) ? ' selected="selected"' : '').'>'.$modx->htmlspecialchars($v['category'])."</option>\n";
190 190
                                 }
191 191
                                 ?>
192 192
                             </select>
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
                     </div>
201 201
                     <?php if ($_SESSION['mgrRole'] == 1): ?>
202 202
                         <div class="form-row">
203
-                            <label><input name="disabled" type="checkbox" value="on"<?= ($content['disabled'] == 1 ? ' checked="checked"' : '') ?> /> <?= ($content['disabled'] == 1 ? "<span class='text-danger'>" . $_lang['disabled'] . "</span>" : $_lang['disabled']) ?></label>
203
+                            <label><input name="disabled" type="checkbox" value="on"<?= ($content['disabled'] == 1 ? ' checked="checked"' : '') ?> /> <?= ($content['disabled'] == 1 ? "<span class='text-danger'>".$_lang['disabled']."</span>" : $_lang['disabled']) ?></label>
204 204
                         </div>
205 205
                     <?php endif; ?>
206 206
                 </div>
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
                             $evtOut = $modx->invokeEvent('OnRichTextEditorRegister');
217 217
                             if (is_array($evtOut)) {
218 218
                                 foreach ($evtOut as $i => $editor) {
219
-                                    echo "\t" . '<option value="' . $editor . '"' . ($which_editor == $editor ? ' selected="selected"' : '') . '>' . $editor . "</option>\n";
219
+                                    echo "\t".'<option value="'.$editor.'"'.($which_editor == $editor ? ' selected="selected"' : '').'>'.$editor."</option>\n";
220 220
                                 }
221 221
                             }
222 222
                             ?>
Please login to merge, or discard this patch.
manager/actions/move_document.dynamic.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  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_document')) {
@@ -7,13 +7,13 @@  discard block
 block discarded – undo
7 7
 }
8 8
 
9 9
 if (isset($_REQUEST['id'])) {
10
-    $id = (int)$_REQUEST['id'];
10
+    $id = (int) $_REQUEST['id'];
11 11
 } else {
12 12
     $modx->webAlertAndQuit($_lang["error_no_id"]);
13 13
 }
14 14
 
15 15
 // check permissions on the document
16
-include_once MODX_MANAGER_PATH . "processors/user_documents_permissions.class.php";
16
+include_once MODX_MANAGER_PATH."processors/user_documents_permissions.class.php";
17 17
 $udperms = new udperms();
18 18
 $udperms->user = $modx->getLoginUserID();
19 19
 $udperms->document = $id;
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
     },
40 40
     cancel: function() {
41 41
       documentDirty = false;
42
-        <?= ($id == 0 ? 'document.location.href="index.php?a=2";' : 'document.location.href="index.php?a=3&id=' . $id . '";') ?>
42
+        <?= ($id == 0 ? 'document.location.href="index.php?a=2";' : 'document.location.href="index.php?a=3&id='.$id.'";') ?>
43 43
     }
44 44
   };
45 45
 
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
 </script>
81 81
 
82 82
 <h1>
83
-    <i class="fa fa-arrows"></i><?= ($pagetitle ? $pagetitle . '<small>(' . $id . ')</small>' : $_lang['move_resource_title']) ?>
83
+    <i class="fa fa-arrows"></i><?= ($pagetitle ? $pagetitle.'<small>('.$id.')</small>' : $_lang['move_resource_title']) ?>
84 84
 </h1>
85 85
 
86 86
 <?= $_style['actionbuttons']['dynamic']['save'] ?>
Please login to merge, or discard this patch.
manager/actions/mutate_template_tv_rank.dynamic.php 1 patch
Spacing   +6 added lines, -6 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_template')) {
6 6
     $modx->webAlertAndQuit($_lang["error_no_privileges"]);
7 7
 }
8 8
 
9
-$id = isset($_REQUEST['id']) ? (int)$_REQUEST['id'] : 0;
9
+$id = isset($_REQUEST['id']) ? (int) $_REQUEST['id'] : 0;
10 10
 $reset = isset($_POST['reset']) && $_POST['reset'] == 'true' ? 1 : 0;
11 11
 
12 12
 $tbl_site_templates = $modx->getFullTableName('site_templates');
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
 $templatename = '';
20 20
 
21 21
 if (isset($_POST['listSubmitted'])) {
22
-    $updateMsg .= '<div class="text-success" id="updated">' . $_lang['sort_updated'] . '</div>';
22
+    $updateMsg .= '<div class="text-success" id="updated">'.$_lang['sort_updated'].'</div>';
23 23
     foreach ($_POST as $listName => $listValue) {
24 24
         if ($listName == 'listSubmitted' || $listName == 'reset') {
25 25
             continue;
@@ -47,11 +47,11 @@  discard block
 block discarded – undo
47 47
     while ($row = $modx->db->getRow($rs)) {
48 48
         $templatename = $row['templatename'];
49 49
         $caption = $row['caption'] != '' ? $row['caption'] : $row['name'];
50
-        $sortableList .= '<li id="item_' . $row['id'] . '"><i class="fa fa-list-alt"></i> ' . $caption . ' <small class="protectedNode" style="float:right">[*' . $row['name'] . '*]</small></li>';
50
+        $sortableList .= '<li id="item_'.$row['id'].'"><i class="fa fa-list-alt"></i> '.$caption.' <small class="protectedNode" style="float:right">[*'.$row['name'].'*]</small></li>';
51 51
     }
52 52
     $sortableList .= '</ul></div>';
53 53
 } else {
54
-    $updateMsg = '<p class="text-danger">' . $_lang['tmplvars_novars'] . '</p>';
54
+    $updateMsg = '<p class="text-danger">'.$_lang['tmplvars_novars'].'</p>';
55 55
 }
56 56
 ?>
57 57
 
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
 </script>
129 129
 
130 130
 <h1>
131
-    <i class="fa fa-sort-numeric-asc"></i><?= ($templatename ? $templatename . '<small>(' . $id . ')</small>' : $_lang['template_tv_edit_title']) ?>
131
+    <i class="fa fa-sort-numeric-asc"></i><?= ($templatename ? $templatename.'<small>('.$id.')</small>' : $_lang['template_tv_edit_title']) ?>
132 132
 </h1>
133 133
 
134 134
 <?= $_style['actionbuttons']['dynamic']['save'] ?>
Please login to merge, or discard this patch.